From 549d28e50a35d432531926a6916755dbe26d91c4 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Wed, 21 Sep 2011 00:38:56 +0000 Subject: Rework linebreak handling in content and custom query result views, as triggered by Issue #1184: - Display table cells on a single line for preview purposes - Display gray pilcrow/reverse pilcrow placeholders instead of linebreaks - If a cell contains linebreaks, automatically trigger sheet editing mode - Handle newly displayed linebreaks in column width detection - If using the up/down arrow keys in a field editor, allow them to select the previous/next line within an editor if appropriat (instead of always moving to the previous/next row) --- Source/SPTableContent.m | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'Source/SPTableContent.m') diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 425bc6b1..4f12f021 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -4429,12 +4429,25 @@ } } - // Open the sheet if the multipleLineEditingButton is enabled or the column was a blob or a text. - if (( + // Determine whether to open the sheet for editing; do so if the multipleLineEditingButton is enabled, + // or if the column was a blob or a text, or if it contains linebreaks. + BOOL useFieldEditor = NO; #ifndef SP_REFACTOR - [multipleLineEditingButton state] == NSOnState || + if ([multipleLineEditingButton state] == NSOnState) useFieldEditor = YES; #endif - isBlob) && ![[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"enum"]) { + if (!useFieldEditor && ![[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"enum"] && isBlob) useFieldEditor = YES; + if (!useFieldEditor) { + id cellValue = [tableValues cellDataAtRow:rowIndex column:[[aTableColumn identifier] integerValue]]; + if (![cellValue isNSNull] + && [[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"string"] + && [cellValue rangeOfCharacterFromSet:[NSCharacterSet newlineCharacterSet] options:NSLiteralSearch].location != NSNotFound) + { + useFieldEditor = YES; + } + } + + // Open the sheet if required + if (useFieldEditor) { // A table is per definitionem editable isFieldEditable = YES; @@ -4769,16 +4782,21 @@ } - NSString *fieldType; + // Use the field editor sheet instead of inline editing if the target field is a text, blob, or binary + // type; if it contains linebreaks; or if the force-editing button is enabled. + BOOL useFieldEditor = NO; + NSString *fieldType = [[tableDataInstance columnWithName:[[NSArrayObjectAtIndex([tableContentView tableColumns], column) headerCell] stringValue]] objectForKey:@"typegrouping"]; - // Check if current edited field is a blob - if ((fieldType = [[tableDataInstance columnWithName:[[NSArrayObjectAtIndex([tableContentView tableColumns], column) headerCell] stringValue]] objectForKey:@"typegrouping"]) - && ![fieldType isEqualToString:@"enum"] && ([fieldType isEqualToString:@"textdata"] || [fieldType isEqualToString:@"blobdata"] #ifndef SP_REFACTOR - || [multipleLineEditingButton state] == NSOnState + if ([multipleLineEditingButton state] == NSOnState) useFieldEditor = YES; #endif - )) - { + + if (!useFieldEditor && fieldType && ![fieldType isEqualToString:@"enum"] && ([fieldType isEqualToString:@"textdata"] || [fieldType isEqualToString:@"blobdata"])) useFieldEditor = YES; + + if (!useFieldEditor && [[aFieldEditor string] rangeOfCharacterFromSet:[NSCharacterSet newlineCharacterSet]].location != NSNotFound) useFieldEditor = YES; + + // Open the field editor sheet if required + if (useFieldEditor) { [tableContentView setFieldEditorSelectedRange:[aFieldEditor selectedRange]]; // Cancel editing -- cgit v1.2.3