aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-12-17 22:27:00 +0000
committerrowanbeentje <rowan@beent.je>2012-12-17 22:27:00 +0000
commit094b7ca1746c8ed94b9a8362929b2532e2fb76f5 (patch)
tree3106efbde2f27211ded8e9f635f5238dbf7e4fc4
parentd3deb39a483d9cdf81c1e45dc9474cd30a7182ef (diff)
downloadsequelpro-094b7ca1746c8ed94b9a8362929b2532e2fb76f5.tar.gz
sequelpro-094b7ca1746c8ed94b9a8362929b2532e2fb76f5.tar.bz2
sequelpro-094b7ca1746c8ed94b9a8362929b2532e2fb76f5.zip
- If the favourite is not an on-disk document, add any new query favourites to the bottom of the Global list if a selection is not active, to address query favorite loss (Issue #1417)
-rw-r--r--Source/SPQueryFavoriteManager.m23
1 files changed, 18 insertions, 5 deletions
diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m
index 3d5a2e9a..36740ca7 100644
--- a/Source/SPQueryFavoriteManager.m
+++ b/Source/SPQueryFavoriteManager.m
@@ -35,6 +35,7 @@
#import "SPEncodingPopupAccessory.h"
#import "SPQueryController.h"
#import "SPQueryDocumentsController.h"
+#import "SPDatabaseDocument.h"
#import "SPConnectionController.h"
#import "RegexKitLite.h"
#import "SPTextView.h"
@@ -68,7 +69,7 @@
if(managerDelegate == nil) {
NSBeep();
- NSLog(@"Query Favorite Manger was called without a delegate.");
+ NSLog(@"Query Favorite Manager was called without a delegate.");
return nil;
}
tableDocumentInstance = [managerDelegate valueForKeyPath:@"tableDocumentInstance"];
@@ -208,14 +209,26 @@
// Add a new favorite
else
favorite = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"New Favorite", @"", nil] forKeys:[NSArray arrayWithObjects:@"name", @"query", nil]];
-
+
+ // If a favourite is currently selected, add the new favourite next to it
if ([favoritesTableView numberOfSelectedRows] > 0) {
insertIndex = [[favoritesTableView selectedRowIndexes] lastIndex]+1;
[favorites insertObject:favorite atIndex:insertIndex];
- }
- else {
- [favorites addObject:favorite];
+ }
+
+ // If the DatabaseDocument is an on-disk document, add the favourite to the bottom of it
+ else if (![tableDocumentInstance isUntitled]) {
insertIndex = [favorites count] - 1;
+ [favorites addObject:favorite];
+ }
+
+ // Otherwise, add to the bottom of the Global array by default
+ else {
+ insertIndex = 1;
+ while (![[favorites objectAtIndex:insertIndex] objectForKey:@"headerOfFileURL"]) {
+ insertIndex++;
+ }
+ [favorites insertObject:favorite atIndex:insertIndex];
}
[favoritesArrayController rearrangeObjects];