aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2011-05-07 21:06:46 +0000
committerstuconnolly <stuart02@gmail.com>2011-05-07 21:06:46 +0000
commitdfb28b2af2478e5b249de0b2b4381479e55f2980 (patch)
tree8922228e813201169cbbf0c8ed79ed80423891eb
parent303ea1c0bc71be56d7943be9fac274e9fe9800ea (diff)
downloadsequelpro-dfb28b2af2478e5b249de0b2b4381479e55f2980.tar.gz
sequelpro-dfb28b2af2478e5b249de0b2b4381479e55f2980.tar.bz2
sequelpro-dfb28b2af2478e5b249de0b2b4381479e55f2980.zip
When refreshing the export dialog's table list, preserve the user's current selection. Fixes issue #1000.
-rw-r--r--Source/SPExportController.m40
1 files changed, 38 insertions, 2 deletions
diff --git a/Source/SPExportController.m b/Source/SPExportController.m
index f7825050..0ff78c1f 100644
--- a/Source/SPExportController.m
+++ b/Source/SPExportController.m
@@ -176,7 +176,7 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
}
[self updateDisplayedExportFilename];
- [self refreshTableList:self];
+ [self refreshTableList:nil];
[exporters removeAllObjects];
[exportFiles removeAllObjects];
@@ -410,6 +410,21 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
*/
- (IBAction)refreshTableList:(id)sender
{
+ NSMutableDictionary *tableDict = [[NSMutableDictionary alloc] init];
+
+ // Before refreshing the list, preserve the user's table selection, but only if it was triggered by the UI.
+ if (sender) {
+ for (NSMutableArray *item in tables)
+ {
+ [tableDict setObject:[NSArray arrayWithObjects:
+ [item objectAtIndex:1],
+ [item objectAtIndex:2],
+ [item objectAtIndex:3],
+ nil]
+ forKey:[item objectAtIndex:0]];
+ }
+ }
+
[tables removeAllObjects];
// For all modes, retrieve table and view names
@@ -454,7 +469,28 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
}
}
+ if (sender) {
+ // Restore the user's table selection
+ for (NSUInteger i = 0; i < [tables count]; i++)
+ {
+ NSMutableArray *oldSelection = [tableDict objectForKey:[[tables objectAtIndex:i] objectAtIndex:0]];
+
+ if (oldSelection) {
+
+ NSMutableArray *newItem = [[NSMutableArray alloc] initWithArray:oldSelection];
+
+ [newItem insertObject:[[tables objectAtIndex:i] objectAtIndex:0] atIndex:0];
+
+ [tables replaceObjectAtIndex:i withObject:newItem];
+
+ [newItem release];
+ }
+ }
+ }
+
[exportTableList reloadData];
+
+ [tableDict release];
}
/**
@@ -465,7 +501,7 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
BOOL toggleStructure = NO;
BOOL toggleDropTable = NO;
- [self refreshTableList:self];
+ [self refreshTableList:nil];
// Determine whether the structure and drop items should also be toggled
if (exportType == SPSQLExport) {