aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2008-12-07 17:43:18 +0000
committerrowanbeentje <rowan@beent.je>2008-12-07 17:43:18 +0000
commit0eff207065c74b903c1358a91f7bffadd631b8e7 (patch)
tree7e4ace44adaf971ad6638e560be0a9cd033025e6
parent97766ed8605f019389928a9c8046373ff48f7e4a (diff)
downloadsequelpro-0eff207065c74b903c1358a91f7bffadd631b8e7.tar.gz
sequelpro-0eff207065c74b903c1358a91f7bffadd631b8e7.tar.bz2
sequelpro-0eff207065c74b903c1358a91f7bffadd631b8e7.zip
- Add new favourites as NSMutableDictionaries instead of NSDictionaries - properly fixes Issue #110.
- Save favourites on exit - this saves edits such as favourite name changes within the connection sheet which aren't otherwise caught. - Removes an outdated property (selectedFavourite)
-rw-r--r--TableDocument.h1
-rw-r--r--TableDocument.m14
2 files changed, 5 insertions, 10 deletions
diff --git a/TableDocument.h b/TableDocument.h
index 2a54a37c..ac20b335 100644
--- a/TableDocument.h
+++ b/TableDocument.h
@@ -81,7 +81,6 @@
NSMutableArray *favorites;
NSArray *variables;
NSString *selectedDatabase;
- NSString *selectedFavorite;
NSString *mySQLVersion;
NSUserDefaults *prefs;
diff --git a/TableDocument.m b/TableDocument.m
index 59aad2e0..e88a62ad 100644
--- a/TableDocument.m
+++ b/TableDocument.m
@@ -260,9 +260,6 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
[portField setStringValue:[self valueForKeyPath:@"selectedFavorite.port"]];
[databaseField setStringValue:[self valueForKeyPath:@"selectedFavorite.database"]];
[passwordField setStringValue:[self selectedFavoritePassword]];
-
- [selectedFavorite release];
- selectedFavorite = [[favoritesButton titleOfSelectedItem] retain];
}
/**
@@ -368,7 +365,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
[self willChangeValueForKey:@"favorites"];
// write favorites and password
- NSDictionary *newFavorite = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:favoriteName, host, socket, user, port, database, nil]
+ NSMutableDictionary *newFavorite = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:favoriteName, host, socket, user, port, database, nil]
forKeys:[NSArray arrayWithObjects:@"name", @"host", @"socket", @"user", @"port", @"database", nil]];
[favorites addObject:newFavorite];
@@ -378,9 +375,6 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
account:[NSString stringWithFormat:@"%@@%@/%@", user, host, database]];
}
- // select new favorite
- selectedFavorite = [favoriteName retain];
-
[self didChangeValueForKey:@"favorites"];
[favoritesController setSelectedObjects:[NSArray arrayWithObject:newFavorite]];
}
@@ -1428,7 +1422,6 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
// [tableWindow makeKeyAndOrderFront:self];
prefs = [[NSUserDefaults standardUserDefaults] retain];
- selectedFavorite = [[NSString alloc] initWithString:NSLocalizedString(@"Custom", @"menu item for custom connection")];
//register for notifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willPerformQuery:)
@@ -1593,6 +1586,10 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
- (IBAction)terminate:(id)sender
{
[[NSApp orderedDocuments] makeObjectsPerformSelector:@selector(cancelConnectSheet:) withObject:nil];
+
+ // Save the favourites - commits any unsaved changes ie favourite renames
+ [prefs setObject:[self favorites] forKey:@"favorites"];
+
[NSApp terminate:sender];
}
@@ -1603,7 +1600,6 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
[favorites release];
[variables release];
[selectedDatabase release];
- [selectedFavorite release];
[mySQLVersion release];
[prefs release];