From 714a06ae49c50e89638d67dcb39efbee630d3325 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sun, 23 Dec 2012 20:59:18 +0000 Subject: Make some improvements to the Table Content Filter, particularly for text fields: - Rename all "IS" entries to "=", to make the intended purpose clearer, and switch the underlying command to use "= BINARY" instead of "LIKE", producing an exact match instead of replicating LIKE functionality. Move LIKE p to just below the = options. This addresses Issue #1441. - Add entries for "matches RegExp" and "does not match RegExp", implementing Issue #1508. - When adding custom filters, add them by default to the Global group if the favourite isn't an on-disk document, addressing filter loss between sessions; this addresses Issue #1381 --- Source/SPContentFilterManager.m | 20 +++++++++++++++++--- Source/SPTableContent.m | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'Source') diff --git a/Source/SPContentFilterManager.m b/Source/SPContentFilterManager.m index cf12ebe0..a0755b92 100644 --- a/Source/SPContentFilterManager.m +++ b/Source/SPContentFilterManager.m @@ -35,6 +35,7 @@ #import "RegexKitLite.h" #import "SPQueryController.h" #import "SPQueryDocumentsController.h" +#import "SPDatabaseDocument.h" #import "SPTableContent.h" #import "SPConnectionController.h" #import "SPSplitView.h" @@ -246,12 +247,25 @@ else filter = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:NSLocalizedString(@"New Filter",@"Content Filter Manager : Initial name for new filter"), @"", @"", nil] forKeys:[NSArray arrayWithObjects:@"MenuLabel", @"Clause", @"ConjunctionLabel", nil]]; - if([contentFilterTableView numberOfSelectedRows] > 0) { + // If a favourite is currently selected, add the new favourite next to it + if ([contentFilterTableView numberOfSelectedRows] > 0) { insertIndex = [[contentFilterTableView selectedRowIndexes] lastIndex]+1; [contentFilters insertObject:filter atIndex:insertIndex]; - } else { - [contentFilters addObject:filter]; + } + + // If the DatabaseDocument is an on-disk document, add the favourite to the bottom of that document's favourites + else if (![tableDocumentInstance isUntitled]) { insertIndex = [contentFilters count] - 1; + [contentFilters addObject:filter]; + } + + // Otherwise, add to the bottom of the Global list by default + else { + insertIndex = 1; + while (![[contentFilters objectAtIndex:insertIndex] objectForKey:@"headerOfFileURL"]) { + insertIndex++; + } + [contentFilters insertObject:filter atIndex:insertIndex]; } [contentFilterArrayController rearrangeObjects]; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index dceea288..71657916 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -444,7 +444,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [fieldField addItemWithTitle:NSLocalizedString(@"field", @"popup menuitem for field (showing only if disabled)")]; [compareField setEnabled:NO]; [compareField removeAllItems]; - [compareField addItemWithTitle:NSLocalizedString(@"is", @"popup menuitem for field IS value")]; + [compareField addItemWithTitle:@"="]; [argumentField setHidden:NO]; [argumentField setEnabled:NO]; [firstBetweenField setEnabled:NO]; -- cgit v1.2.3