aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableContent.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-10-01 16:35:44 +0000
committerBibiko <bibiko@eva.mpg.de>2009-10-01 16:35:44 +0000
commitcf243d99127441ce2fd3b4641427cb49ab155402 (patch)
treef06c68cc3abfe7e5fb0695b4203a683147ab83b3 /Source/TableContent.m
parent11c7eea329acef790b667a27312a09528364140c (diff)
downloadsequelpro-cf243d99127441ce2fd3b4641427cb49ab155402.tar.gz
sequelpro-cf243d99127441ce2fd3b4641427cb49ab155402.tar.bz2
sequelpro-cf243d99127441ce2fd3b4641427cb49ab155402.zip
• first implementation of a Content Filter Editor
- user-defined content filter can be saved globally (Prefs) or in SPF files - BETA - further tests are needed due to complexity - SPQueryController now handles the local user-defined content filters - tooltips are now generated automatically if not defined explicitly (incl. if $BINARY placeholder was used) • if user added local query favorites or content filters to an Untitled document and s/he wants to close it the standard sheet will be displayed (Don't Save - Cancel - Save) - due to that changed old [TableDocument displayName] to 'displaySPName' to be conform with Cocoa • changed behavior while importing query favorites - now they will append at the list (not inserted after selected row - makes more sense) • introduced to history filter dict the key 'menuLabel' which will be set to [TableContent tableFilterString] for displaying the history menu title and simplified the SPHistoryController logic for that • minor code changes
Diffstat (limited to 'Source/TableContent.m')
-rw-r--r--Source/TableContent.m23
1 files changed, 15 insertions, 8 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 369cfaec..f5b0fa47 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -774,7 +774,7 @@
- (IBAction)toggleFilterField:(id)sender
{
- // Check if user called "Edit filter…"
+ // Check if user called "Edit Filter…"
if([[compareField selectedItem] tag] == [[contentFilters objectForKey:compareType] count]) {
[self openContentFilterManager];
return;
@@ -784,10 +784,11 @@
lastSelectedContentFilterIndex = [[compareField selectedItem] tag];
NSDictionary *filter = [[contentFilters objectForKey:compareType] objectAtIndex:lastSelectedContentFilterIndex];
+ NSUInteger numOfArgs = [[filter objectForKey:@"NumberOfArguments"] intValue];
if ([[filter objectForKey:@"NumberOfArguments"] intValue] == 2) {
[argumentField setHidden:YES];
- if([filter objectForKey:@"ConjunctionLabels"] && [[filter objectForKey:@"ConjunctionLabels"] count] == 1)
+ if(numOfArgs == 1)
[betweenTextField setStringValue:[[filter objectForKey:@"ConjunctionLabels"] objectAtIndex:0]];
[betweenTextField setHidden:NO];
[firstBetweenField setHidden:NO];
@@ -797,7 +798,7 @@
[secondBetweenField setEnabled:YES];
[firstBetweenField selectText:self];
}
- else if ([[filter objectForKey:@"NumberOfArguments"] intValue] == 1){
+ else if (numOfArgs == 1){
[argumentField setHidden:NO];
[argumentField setEnabled:YES];
[argumentField selectText:self];
@@ -815,7 +816,8 @@
[secondBetweenField setHidden:YES];
// Start search if no argument is required
- [self filterTable:self];
+ if(numOfArgs == 0)
+ [self filterTable:self];
}
}
@@ -1200,7 +1202,7 @@
}
}
- // Load user-defined content filters
+ // Load global user-defined content filters
if([prefs objectForKey:@"ContentFilters"]
&& [contentFilters objectForKey:compareType]
&& [[prefs objectForKey:@"ContentFilters"] objectForKey:compareType])
@@ -1208,6 +1210,13 @@
[[contentFilters objectForKey:compareType] addObjectsFromArray:[[prefs objectForKey:@"ContentFilters"] objectForKey:compareType]];
}
+ // Load doc-based user-defined content filters
+ if([[SPQueryController sharedQueryController] contentFilterForFileURL:[tableDocumentInstance fileURL]]) {
+ id filters = [[SPQueryController sharedQueryController] contentFilterForFileURL:[tableDocumentInstance fileURL]];
+ if([filters objectForKey:compareType])
+ [[contentFilters objectForKey:compareType] addObjectsFromArray:[filters objectForKey:compareType]];
+ }
+
// Rebuild operator popup menu
NSUInteger i = 0;
NSMenu *menu = [compareField menu];
@@ -1255,9 +1264,6 @@
{
[compareField selectItemWithTag:lastSelectedContentFilterIndex];
- [SPTooltip showWithObject:@"<h1><font color='#0000FB'>&nbsp;&nbsp;Please be patient. Under constructions. <span style='font-size:50pt'>☺</span>&nbsp;&nbsp;</font></h1>" atLocation:[NSEvent mouseLocation] ofType:@"html"];
- return;
-
// init query favorites controller
[prefs synchronize];
if(contentFilterManager) [contentFilterManager release];
@@ -1858,6 +1864,7 @@
if (![fieldField isEnabled]) return nil;
theDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
+ [self tableFilterString], @"menuLabel",
[[fieldField selectedItem] title], @"filterField",
[[compareField selectedItem] title], @"filterComparison",
[NSNumber numberWithInt:[[compareField selectedItem] tag]], @"filterComparisonTag",