diff options
author | stuconnolly <stuart02@gmail.com> | 2009-08-26 02:21:53 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2009-08-26 02:21:53 +0000 |
commit | 86085ceb7de7772dd3f85fb61f397e240b4a0e66 (patch) | |
tree | 5351e3d467288fd056a191db11c645606f2052a1 /Source/SPPreferenceController.m | |
parent | 7de1a9a8517c2004e6a97543fbb1462d9c32f4d1 (diff) | |
download | sequelpro-86085ceb7de7772dd3f85fb61f397e240b4a0e66.tar.gz sequelpro-86085ceb7de7772dd3f85fb61f397e240b4a0e66.tar.bz2 sequelpro-86085ceb7de7772dd3f85fb61f397e240b4a0e66.zip |
Completely redesigned query favorite manager, including:
- The ability to name query favorites
- The ability to edit query favorites using the same editor in the cutom query view
- The ability to save your query favorites to a file
Note that any already saved query favorites will be upgraded to accommodate the new format, that is including a name associated with the query. The default name is the first 32 chars of the query with '...' appended.
Also, added menu item validation to the 'Save Query to Favorites' menu item.
Diffstat (limited to 'Source/SPPreferenceController.m')
-rw-r--r-- | Source/SPPreferenceController.m | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m index f9618249..d27234d7 100644 --- a/Source/SPPreferenceController.m +++ b/Source/SPPreferenceController.m @@ -111,6 +111,7 @@ // ------------------------------------------------------------------------------- - (void)applyRevisionChanges { + int i; int currentVersionNumber, recordedVersionNumber = 0; // Get the current bundle version number (the SVN build number) for per-version upgrades @@ -202,7 +203,6 @@ // For versions prior to r567 (0.9.5), add a timestamp-based identifier to favorites and keychain entries if (recordedVersionNumber < 567 && [prefs objectForKey:@"favorites"]) { - int i; NSMutableArray *favoritesArray = [NSMutableArray arrayWithArray:[prefs objectForKey:@"favorites"]]; NSMutableDictionary *favorite; NSString *password, *keychainName, *keychainAccount; @@ -231,7 +231,6 @@ // For versions prior to r981 (~0.9.6), upgrade the favourites to include a connection type for each if (recordedVersionNumber < 981 && [prefs objectForKey:@"favorites"]) { - int i; NSMutableArray *favoritesArray = [NSMutableArray arrayWithArray:[prefs objectForKey:@"favorites"]]; NSMutableDictionary *favorite; @@ -269,6 +268,25 @@ [toolbarDict removeObjectForKey:@"TB Item Identifiers"]; [prefs setObject:[NSDictionary dictionaryWithDictionary:toolbarDict] forKey:@"NSToolbar Configuration TableWindowToolbar"]; } + + // For versions prior to r1263 (~0.9.7), convert the query favorites array to an array of dictionaries + if (recordedVersionNumber < 1263 && [prefs objectForKey:@"queryFavorites"]) { + NSMutableArray *queryFavoritesArray = [NSMutableArray arrayWithArray:[prefs objectForKey:@"queryFavorites"]]; + + for (i = 0; i < [queryFavoritesArray count]; i++) + { + id favorite = [queryFavoritesArray objectAtIndex:i]; + + if (([favorite isKindOfClass:[NSDictionary class]]) && ([favorite objectForKey:@"name"]) && ([favorite objectForKey:@"query"])) continue; + + // By default make the query's name the first 32 characters of the query with '...' appended + NSString *favoriteName = [[[favorite stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]] substringToIndex:32] stringByAppendingString:@"..."]; + + [queryFavoritesArray replaceObjectAtIndex:i withObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:favoriteName, favorite, nil] forKeys:[NSArray arrayWithObjects:@"name", @"query", nil]]]; + } + + [prefs setObject:queryFavoritesArray forKey:@"queryFavorites"]; + } // Update the prefs revision [prefs setObject:[NSNumber numberWithInt:currentVersionNumber] forKey:@"LastUsedVersion"]; |