aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableContent.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2011-09-21 00:38:56 +0000
committerrowanbeentje <rowan@beent.je>2011-09-21 00:38:56 +0000
commit549d28e50a35d432531926a6916755dbe26d91c4 (patch)
treecf5ef7d9440fedb7226ea60e7f2b22d5907d428e /Source/SPTableContent.m
parent6278cbbf9d76d69f44d1d7ddf34792b9e0310272 (diff)
downloadsequelpro-549d28e50a35d432531926a6916755dbe26d91c4.tar.gz
sequelpro-549d28e50a35d432531926a6916755dbe26d91c4.tar.bz2
sequelpro-549d28e50a35d432531926a6916755dbe26d91c4.zip
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)
Diffstat (limited to 'Source/SPTableContent.m')
-rw-r--r--Source/SPTableContent.m40
1 files changed, 29 insertions, 11 deletions
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