aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPQueryFavoriteManager.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-10-17 00:35:09 +0000
committerstuconnolly <stuart02@gmail.com>2009-10-17 00:35:09 +0000
commit6a4e2994d17220eb43015162522deec1efdd429b (patch)
treef1d2abc0691948bcbd901929c82347137ee0de85 /Source/SPQueryFavoriteManager.m
parentc3eb7de88f2baf7774749f4311a84b75ef833eb7 (diff)
downloadsequelpro-6a4e2994d17220eb43015162522deec1efdd429b.tar.gz
sequelpro-6a4e2994d17220eb43015162522deec1efdd429b.tar.bz2
sequelpro-6a4e2994d17220eb43015162522deec1efdd429b.zip
Replace the use of hard coded preference keys with constants to prevent issues such as the one fixed in revision 1419. All future preference usage should be done so using these constants.
Diffstat (limited to 'Source/SPQueryFavoriteManager.m')
-rw-r--r--Source/SPQueryFavoriteManager.m28
1 files changed, 12 insertions, 16 deletions
diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m
index eb409500..c499f742 100644
--- a/Source/SPQueryFavoriteManager.m
+++ b/Source/SPQueryFavoriteManager.m
@@ -27,15 +27,11 @@
#import "ImageAndTextCell.h"
#import "SPEncodingPopupAccessory.h"
#import "SPQueryController.h"
-
-#define DEFAULT_QUERY_FAVORITE_FILE_EXTENSION @"sql"
-#define DEFAULT_SEQUELPRO_FILE_EXTENSION @"spf"
+#import "SPConstants.h"
#define SP_MULTIPLE_SELECTION_PLACEHOLDER_STRING NSLocalizedString(@"[multiple selection]", @"[multiple selection]")
#define SP_NO_SELECTION_PLACEHOLDER_STRING NSLocalizedString(@"[no selection]", @"[no selection]")
-#define QUERY_FAVORITES_PB_DRAG_TYPE @"SequelProQueryFavoritesPasteboard"
-
@interface SPQueryFavoriteManager (Private)
- (void)_initWithNoSelection;
@end
@@ -96,8 +92,8 @@
// Build data source for global queryFavorites (as mutable copy! otherwise each
// change will be stored in the prefs at once)
- if([prefs objectForKey:@"queryFavorites"]) {
- for(id fav in [prefs objectForKey:@"queryFavorites"])
+ if([prefs objectForKey:SPQueryFavorites]) {
+ for(id fav in [prefs objectForKey:SPQueryFavorites])
[favorites addObject:[[fav mutableCopy] autorelease]];
}
@@ -294,7 +290,7 @@
[panel setCanSelectHiddenExtension:YES];
[panel setCanCreateDirectories:YES];
- [panel setAccessoryView:[SPEncodingPopupAccessory encodingAccessory:[prefs integerForKey:@"lastSqlFileEncoding"] includeDefaultEntry:NO encodingPopUp:&encodingPopUp]];
+ [panel setAccessoryView:[SPEncodingPopupAccessory encodingAccessory:[prefs integerForKey:SPLastSQLFileEncoding] includeDefaultEntry:NO encodingPopUp:&encodingPopUp]];
[encodingPopUp setEnabled:YES];
@@ -305,7 +301,7 @@
{
NSSavePanel *panel = [NSSavePanel savePanel];
- [panel setRequiredFileType:DEFAULT_SEQUELPRO_FILE_EXTENSION];
+ [panel setRequiredFileType:DEFAULT_SEQUEL_PRO_FILE_EXTENSION];
[panel setExtensionHidden:NO];
[panel setAllowsOtherFileTypes:NO];
@@ -368,7 +364,7 @@
[self queryFavoritesForFileURL:delegatesFileURL] forFileURL:delegatesFileURL];
// Update global preferences' list
- [prefs setObject:[self queryFavoritesForFileURL:nil] forKey:@"queryFavorites"];
+ [prefs setObject:[self queryFavoritesForFileURL:nil] forKey:SPQueryFavorites];
// Inform all opened documents to update the query favorites list
for(id doc in [[NSDocumentController sharedDocumentController] documents])
@@ -730,17 +726,17 @@
return;
}
- if([spf objectForKey:@"queryFavorites"] && [[spf objectForKey:@"queryFavorites"] count]) {
+ if([spf objectForKey:SPQueryFavorites] && [[spf objectForKey:SPQueryFavorites] count]) {
// if([favoritesTableView numberOfSelectedRows] > 0) {
// // Insert imported queries after the last selected favorite
// NSUInteger insertIndex = [[favoritesTableView selectedRowIndexes] lastIndex] + 1;
// NSUInteger i;
- // for(i=0; i<[[spf objectForKey:@"queryFavorites"] count]; i++) {
- // [favorites insertObject:[[spf objectForKey:@"queryFavorites"] objectAtIndex:i] atIndex:insertIndex+i];
+ // for(i=0; i<[[spf objectForKey:SPQueryFavorites] count]; i++) {
+ // [favorites insertObject:[[spf objectForKey:SPQueryFavorites] objectAtIndex:i] atIndex:insertIndex+i];
// }
// } else {
// // If no selection add them
- [favorites addObjectsFromArray:[spf objectForKey:@"queryFavorites"]];
+ [favorites addObjectsFromArray:[spf objectForKey:SPQueryFavorites]];
// }
[favoritesArrayController rearrangeObjects];
[favoritesTableView reloadData];
@@ -770,7 +766,7 @@
if (returnCode == NSOKButton) {
NSError *error = nil;
- [prefs setInteger:[[encodingPopUp selectedItem] tag] forKey:@"lastSqlFileEncoding"];
+ [prefs setInteger:[[encodingPopUp selectedItem] tag] forKey:SPLastSQLFileEncoding];
[prefs synchronize];
[[favoriteQueryTextView string] writeToFile:[panel filename] atomically:YES encoding:[[encodingPopUp selectedItem] tag] error:&error];
@@ -798,7 +794,7 @@
if([indexes containsIndex:i])
[favoriteData addObject:[favorites objectAtIndex:i]];
- [spfdata setObject:favoriteData forKey:@"queryFavorites"];
+ [spfdata setObject:favoriteData forKey:SPQueryFavorites];
NSString *err = nil;
NSData *plist = [NSPropertyListSerialization dataFromPropertyList:spfdata