aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPHistoryController.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-03-25 00:33:42 +0000
committerrowanbeentje <rowan@beent.je>2010-03-25 00:33:42 +0000
commit5061643c1bf92a3583e4ede059951e1f17befac9 (patch)
tree431bdc27b6c5b37cd91f8b0d96954a551f047c91 /Source/SPHistoryController.m
parent3b70bf3ed475602fac435b86ab564423ae1dfdb0 (diff)
downloadsequelpro-5061643c1bf92a3583e4ede059951e1f17befac9.tar.gz
sequelpro-5061643c1bf92a3583e4ede059951e1f17befac9.tar.bz2
sequelpro-5061643c1bf92a3583e4ede059951e1f17befac9.zip
- Correctly store scroll and selection for the navigation history when filtering content tables
Diffstat (limited to 'Source/SPHistoryController.m')
-rw-r--r--Source/SPHistoryController.m17
1 files changed, 15 insertions, 2 deletions
diff --git a/Source/SPHistoryController.m b/Source/SPHistoryController.m
index aae33e81..dd302969 100644
--- a/Source/SPHistoryController.m
+++ b/Source/SPHistoryController.m
@@ -211,6 +211,8 @@
if (contentSortCol) [contentState setObject:contentSortCol forKey:@"sortCol"];
if (contentSelectedIndexSet) [contentState setObject:contentSelectedIndexSet forKey:@"selection"];
if (contentFilter) [contentState setObject:contentFilter forKey:@"filter"];
+
+ // 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]]];
}
@@ -219,7 +221,7 @@
[history removeObjectsInRange:NSMakeRange(historyPosition + 1, [history count] - historyPosition - 1)];
} else if (historyPosition != NSNotFound && historyPosition == [history count] - 1) {
- NSDictionary *currentHistoryEntry = [history objectAtIndex:historyPosition];
+ NSMutableDictionary *currentHistoryEntry = [history objectAtIndex:historyPosition];
// If the table is the same, and the filter settings haven't changed, delete the
// last entry so it can be replaced. This updates navigation within a table, rather than
@@ -236,6 +238,17 @@
{
[history removeLastObject];
+ // If the only db/table/view are the same, but the filter settings have changed, also store the
+ // position details on the *previous* history item
+ } else if ([[currentHistoryEntry objectForKey:@"database"] isEqualToString:theDatabase]
+ && [[currentHistoryEntry objectForKey:@"table"] isEqualToString:theTable]
+ && ([[currentHistoryEntry objectForKey:@"view"] integerValue] == theView
+ || ((![currentHistoryEntry objectForKey:@"contentFilter"] && contentFilter)
+ || ![[currentHistoryEntry objectForKey:@"contentFilter"] isEqualToDictionary:contentFilter])))
+ {
+ [currentHistoryEntry setObject:[NSValue valueWithRect:contentViewport] forKey:@"contentViewport"];
+ if (contentSelectedIndexSet) [currentHistoryEntry setObject:contentSelectedIndexSet forKey:@"contentSelectedIndexSet"];
+
// Special case: if the last history item is currently active, and has no table,
// but the new selection does - delete the last entry, in order to replace it.
// This improves history flow.
@@ -260,7 +273,7 @@
if (contentFilter) [newEntry setObject:contentFilter forKey:@"contentFilter"];
[history addObject:newEntry];
-
+
// If there are now more than fifty history entries, remove one from the start
if ([history count] > 50) [history removeObjectAtIndex:0];