diff options
author | Bibiko <bibiko@eva.mpg.de> | 2011-01-24 11:55:00 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2011-01-24 11:55:00 +0000 |
commit | f1b7ccbcdd139a040adb8caae3366f998b2df75a (patch) | |
tree | 9edde6fe5060508c87ff1a300a37db83d962c8dc | |
parent | 0c5422bb4e45e5890ce647001758371307a445d0 (diff) | |
download | sequelpro-f1b7ccbcdd139a040adb8caae3366f998b2df75a.tar.gz sequelpro-f1b7ccbcdd139a040adb8caae3366f998b2df75a.tar.bz2 sequelpro-f1b7ccbcdd139a040adb8caae3366f998b2df75a.zip |
• fixed minor issue for filterTable approach in Content
- prepared some stuff for table state history
-rw-r--r-- | Source/SPHistoryController.m | 2 | ||||
-rw-r--r-- | Source/SPTableContent.h | 2 | ||||
-rw-r--r-- | Source/SPTableContent.m | 26 |
3 files changed, 28 insertions, 2 deletions
diff --git a/Source/SPHistoryController.m b/Source/SPHistoryController.m index 3fb0e100..107c24cb 100644 --- a/Source/SPHistoryController.m +++ b/Source/SPHistoryController.m @@ -269,6 +269,7 @@ NSIndexSet *contentSelectedIndexSet = [tableContentInstance selectedRowIndexes]; NSRect contentViewport = [tableContentInstance viewport]; NSDictionary *contentFilter = [tableContentInstance filterSettings]; + NSData *filterTableData = [tableContentInstance filterTableData]; if (!theDatabase) return; // If a table is selected, save state information @@ -283,6 +284,7 @@ if (contentSortCol) [contentState setObject:contentSortCol forKey:@"sortCol"]; if (contentSelectedIndexSet) [contentState setObject:contentSelectedIndexSet forKey:@"selection"]; if (contentFilter) [contentState setObject:contentFilter forKey:@"filter"]; + if (filterTableData) [contentState setObject:filterTableData forKey:@"filterTable"]; // Update the table content states with this information - used when switching tables to restore last used view. [tableContentStates setObject:contentState forKey:[NSString stringWithFormat:@"%@.%@", [theDatabase backtickQuotedString], [theTable backtickQuotedString]]]; diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h index 597c695d..0b33146b 100644 --- a/Source/SPTableContent.h +++ b/Source/SPTableContent.h @@ -226,6 +226,8 @@ - (void) setFiltersToRestore:(NSDictionary *)filterSettings; - (void) storeCurrentDetailsForRestoration; - (void) clearDetailsToRestore; +- (void) setFilterTableData:(NSData*)arcData; +- (NSData*) filterTableData; - (NSString *)escapeFilterArgument:(NSString *)argument againstClause:(NSString *)clause; - (void)openContentFilterManager; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 064b08f1..b136d90a 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -3297,6 +3297,25 @@ [self setFiltersToRestore:nil]; } +- (void) setFilterTableData:(NSData*)arcData +{ + if(!arcData) return; + NSDictionary *filterData = [NSUnarchiver unarchiveObjectWithData:arcData]; + [filterTableData removeAllObjects]; + [filterTableData addEntriesFromDictionary:filterData]; + [filterTableWindow makeKeyAndOrderFront:nil]; + // [filterTableView reloadData]; +} + +- (NSData*) filterTableData +{ + if(![filterTableWindow isVisible]) return nil; + + [filterTableView deselectAll:nil]; + + return [NSArchiver archivedDataWithRootObject:filterTableData]; +} + #pragma mark - #pragma mark Table drawing and editing @@ -3513,8 +3532,9 @@ return c; } else return NSArrayObjectAtIndex([[filterTableData objectForKey:[NSNumber numberWithInteger:rowIndex]] objectForKey:@"filter"], [[aTableColumn identifier] integerValue]-1); - else + else { return NSArrayObjectAtIndex([[filterTableData objectForKey:[aTableColumn identifier]] objectForKey:@"filter"], rowIndex); + } } else if(aTableView == tableContentView) { @@ -4470,6 +4490,8 @@ NSString *re1 = @"^\\s*(<[=>]?|>=?|!?=|≠|≤|≥)\\s*(.*?)\\s*$"; NSString *re2 = @"^\\s*(.*)\\s+(.*?)\\s*$"; NSCharacterSet *whiteSpaceCharSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; + NSInteger editedRow = [filterTableView editedRow]; + if(currentValue == filterTableGearLookAllFields) { numberOfRows = 1; @@ -4503,7 +4525,7 @@ } // Take value from currently edited table cell } else if([currentValue isKindOfClass:[NSString class]]){ - if(index == [filterTableView editedColumn] && i == [filterTableView editedRow]) + if(i == editedRow && index == [[NSArrayObjectAtIndex([filterTableView tableColumns], [filterTableView editedColumn]) identifier] integerValue]) filterCell = (NSString*)currentValue; else filterCell = NSArrayObjectAtIndex([filterCellData objectForKey:@"filter"], i); |