From 959607aeb1ecec386ad0e3b8799893af2bf61271 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 29 Sep 2010 13:48:18 +0000 Subject: =?UTF-8?q?=E2=80=A2=20Filter=20Table=20-=20minor=20GUI=20improvem?= =?UTF-8?q?ents=20-=20try=20to=20fix=20issue=201654?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPTableContent.h | 2 +- Source/SPTableContent.m | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'Source') diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h index 5f3aba47..a23aec65 100644 --- a/Source/SPTableContent.h +++ b/Source/SPTableContent.h @@ -72,7 +72,7 @@ IBOutlet NSButton *filterTableClearButton; IBOutlet SPTextView *filterTableWhereClause; IBOutlet id filterTableNegateCheckbox; - IBOutlet id filterTableDistinctCheckbox; + IBOutlet NSMenuItem *filterTableDistinctMenuItem; IBOutlet id filterTableLiveSearchCheckbox; IBOutlet NSMenuItem *filterTableGearLookAllFields; IBOutlet NSPanel *filterTableSetDefaultOperatorSheet; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index bb7754cc..d9bd1edf 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -172,7 +172,7 @@ [contentViewPane addSubview:paginationView]; // Init Filter Table GUI - [filterTableDistinctCheckbox setState:(filterTableDistinct) ? NSOnState : NSOffState]; + [filterTableDistinctMenuItem setState:(filterTableDistinct) ? NSOnState : NSOffState]; [filterTableNegateCheckbox setState:(filterTableNegate) ? NSOnState : NSOffState]; [filterTableLiveSearchCheckbox setState:NSOffState]; filterTableDefaultOperator = [[self escapeFilterTableDefaultOperator:[prefs objectForKey:SPFilterTableDefaultOperator]] retain]; @@ -636,7 +636,7 @@ [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance]; // Start construction of the query string - queryString = [NSMutableString stringWithFormat:@"SELECT %@%@ FROM %@", (activeFilter == 1 && [self tableFilterString] && [filterTableDistinctCheckbox state] == NSOnState) ? @"DISTINCT " : @"", [self fieldListForQuery], [selectedTable backtickQuotedString]]; + queryString = [NSMutableString stringWithFormat:@"SELECT %@%@ FROM %@", (activeFilter == 1 && [self tableFilterString] && filterTableDistinct) ? @"DISTINCT " : @"", [self fieldListForQuery], [selectedTable backtickQuotedString]]; // Add a filter string if appropriate filterString = [self tableFilterString]; @@ -2933,6 +2933,8 @@ { filterTableDistinct = !filterTableDistinct; + [filterTableDistinctMenuItem setState:(filterTableDistinct) ? NSOnState : NSOffState]; + // If live search is set perform filtering if([filterTableLiveSearchCheckbox state] == NSOnState) [self filterTable:filterTableFilterButton]; @@ -4205,7 +4207,10 @@ */ - (NSString*)escapeFilterTableDefaultOperator:(NSString*)anOperator { - NSMutableString *newOp = [NSMutableString string]; + + if(anOperator == nil) return @""; + + NSMutableString *newOp = [[[NSMutableString alloc] initWithCapacity:[anOperator length]] autorelease]; [newOp setString:anOperator]; [newOp replaceOccurrencesOfRegex:@"%" withString:@"%%"]; [newOp replaceOccurrencesOfRegex:@"(?