diff options
author | rowanbeentje <rowan@beent.je> | 2012-10-10 23:44:09 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2012-10-10 23:44:09 +0000 |
commit | c4e9a4be8f5a9a9e7e7884dbdf9ea744481e8bc8 (patch) | |
tree | 7248f185fbd019f1e7c0583bc6dbe915a5fe3cbd | |
parent | ca71a7d3fe9818ea9f2b2e7f1eca643eb6e07ff1 (diff) | |
download | sequelpro-c4e9a4be8f5a9a9e7e7884dbdf9ea744481e8bc8.tar.gz sequelpro-c4e9a4be8f5a9a9e7e7884dbdf9ea744481e8bc8.tar.bz2 sequelpro-c4e9a4be8f5a9a9e7e7884dbdf9ea744481e8bc8.zip |
- Alter favourite sorting in the connection interface: name sorts are now case-insensitive for a more Mac-like feel, groups are sorted alphabetically among favourite nodes when name sorting is being used, and above (or below when reversed) other favourites in type/host mode
- Update localisable strings and fix a warning
-rw-r--r-- | Resources/English.lproj/ConnectionView.strings | bin | 42630 -> 43380 bytes | |||
-rw-r--r-- | Source/SPConnectionController.m | 49 |
2 files changed, 29 insertions, 20 deletions
diff --git a/Resources/English.lproj/ConnectionView.strings b/Resources/English.lproj/ConnectionView.strings Binary files differindex b1fb2824..995eae7f 100644 --- a/Resources/English.lproj/ConnectionView.strings +++ b/Resources/English.lproj/ConnectionView.strings diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index d610dba8..409b89c0 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -1402,16 +1402,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, } NSMutableIndexSet *indexes = [[NSMutableIndexSet alloc] init]; - NSMutableArray *groupNodes = [[NSMutableArray alloc] init]; - - for (SPTreeNode *innerNode in nodes) - { - if ([innerNode isGroup]) { - [groupNodes addObject:innerNode]; - [indexes addIndex:[nodes indexOfObject:innerNode]]; - } - } - + NSUInteger i = [indexes lastIndex]; while (i != NSNotFound) @@ -1424,15 +1415,12 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [indexes release]; [nodes sortUsingFunction:_compareFavoritesUsingKey context:key]; - - [nodes addObjectsFromArray:groupNodes]; - + if (reverseFavoritesSort) [nodes reverse]; [[node mutableChildNodes] setArray:nodes]; [nodes release]; - [groupNodes release]; } /** @@ -1447,10 +1435,31 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, void *key) { NSString *dictKey = (NSString *)key; - - id value1 = [[(SPFavoriteNode *)[(SPTreeNode *)favorite1 representedObject] nodeFavorite] objectForKey:dictKey]; - id value2 = [[(SPFavoriteNode *)[(SPTreeNode *)favorite2 representedObject] nodeFavorite] objectForKey:dictKey]; - + id value1, value2; + + if ([favorite1 isGroup]) { + if ([dictKey isEqualToString:SPFavoriteNameKey] || [favorite2 isGroup]) { + value1 = [[favorite1 representedObject] nodeName]; + } else { + value1 = nil; + } + } else { + value1 = [[(SPFavoriteNode *)[(SPTreeNode *)favorite1 representedObject] nodeFavorite] objectForKey:dictKey]; + } + + if ([favorite2 isGroup]) { + if ([dictKey isEqualToString:SPFavoriteNameKey] || [favorite1 isGroup]) { + value2 = [[favorite2 representedObject] nodeName]; + } else { + value2 = nil; + } + } else { + value2 = [[(SPFavoriteNode *)[(SPTreeNode *)favorite2 representedObject] nodeFavorite] objectForKey:dictKey]; + } + + if ([value1 isKindOfClass:[NSString class]]) { + return [value1 caseInsensitiveCompare:value2]; + } return [value1 compare:value2]; } @@ -1729,11 +1738,11 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, if (isEditingConnection) return; // Fade and move the edit button area in - [editButtonsView setAlphaValue:0.0]; + [editButtonsView setAlphaValue:0.0f]; [editButtonsView setHidden:NO]; [editButtonsView setFrameOrigin:NSMakePoint([editButtonsView frame].origin.x, [editButtonsView frame].origin.y - 30)]; [[editButtonsView animator] setFrameOrigin:NSMakePoint([editButtonsView frame].origin.x, [editButtonsView frame].origin.y + 30)]; - [[editButtonsView animator] setAlphaValue:1.0]; + [[editButtonsView animator] setAlphaValue:1.0f]; // Update the "Save" button state as appropriate [saveFavoriteButton setEnabled:([self selectedFavorite] != nil)]; |