diff options
author | dmoagx <post@wickenrode.com> | 2011-04-29 20:05:41 +0000 |
---|---|---|
committer | dmoagx <post@wickenrode.com> | 2011-04-29 20:05:41 +0000 |
commit | 7e0ffd0bc334be6e681f35710a8a70da34efbcea (patch) | |
tree | 8b29608a6ea53754586e0ff55387ae0fd791272b | |
parent | c0f8ea3f976f4df58b185d2636b5899c8d48d180 (diff) | |
download | sequelpro-7e0ffd0bc334be6e681f35710a8a70da34efbcea.tar.gz sequelpro-7e0ffd0bc334be6e681f35710a8a70da34efbcea.tar.bz2 sequelpro-7e0ffd0bc334be6e681f35710a8a70da34efbcea.zip |
* Allow table names to be sorted in lists via "AlphabeticalTableSorting" hidden pref key
* Change some [[NSPopupButton selectedItem] title] to [NSPopupButton titleOfSelectedItem]
-rw-r--r-- | Source/SPConstants.h | 1 | ||||
-rw-r--r-- | Source/SPConstants.m | 1 | ||||
-rw-r--r-- | Source/SPTableContent.m | 14 | ||||
-rw-r--r-- | Source/SPTableRelations.h | 1 | ||||
-rw-r--r-- | Source/SPTableRelations.m | 7 |
5 files changed, 14 insertions, 10 deletions
diff --git a/Source/SPConstants.h b/Source/SPConstants.h index e6855132..ffe37d66 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -288,6 +288,7 @@ extern NSString *SPNullValue; extern NSString *SPGlobalResultTableFont; extern NSString *SPFilterTableDefaultOperator; extern NSString *SPFilterTableDefaultOperatorLastItems; +extern NSString *SPAlphabeticalTableSorting; // Favorites Prefpane extern NSString *SPFavorites; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 39b925c1..1f391d47 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -94,6 +94,7 @@ NSString *SPNullValue = @"SPNullValue"; NSString *SPGlobalResultTableFont = @"GlobalResultTableFont"; NSString *SPFilterTableDefaultOperator = @"FilterTableDefaultOperator"; NSString *SPFilterTableDefaultOperatorLastItems = @"FilterTableDefaultOperatorLastItems"; +NSString *SPAlphabeticalTableSorting = @"AlphabeticalTableSorting"; // Favorites Prefpane NSString *SPFavorites = @"favorites"; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index ddc58670..e4fe9dc2 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -609,10 +609,8 @@ // Enable and initialize filter fields (with tags for position of menu item and field position) [fieldField setEnabled:YES]; [fieldField removeAllItems]; - [fieldField addItemsWithTitles:columnNames]; - for ( i = 0 ; i < [fieldField numberOfItems] ; i++ ) { - [[fieldField itemAtIndex:i] setTag:i]; - } + NSArray *columnTitles = ([prefs boolForKey:SPAlphabeticalTableSorting])? [columnNames sortedArrayUsingSelector:@selector(compare:)] : columnNames; + [fieldField addItemsWithTitles:columnTitles]; [compareField setEnabled:YES]; [self setCompareTypes:self]; [argumentField setEnabled:YES]; @@ -2346,8 +2344,8 @@ [compareField removeAllItems]; NSString *fieldTypeGrouping; - if([[tableDataInstance columnWithName:[[fieldField selectedItem] title]] objectForKey:@"typegrouping"]) - fieldTypeGrouping = [NSString stringWithString:[[tableDataInstance columnWithName:[[fieldField selectedItem] title]] objectForKey:@"typegrouping"]]; + if([[tableDataInstance columnWithName:[fieldField titleOfSelectedItem]] objectForKey:@"typegrouping"]) + fieldTypeGrouping = [NSString stringWithString:[[tableDataInstance columnWithName:[fieldField titleOfSelectedItem]] objectForKey:@"typegrouping"]]; else return; @@ -2393,7 +2391,7 @@ } else { compareType = @""; NSBeep(); - NSLog(@"ERROR: unknown type for comparision: %@, in %@", [[tableDataInstance columnWithName:[[fieldField selectedItem] title]] objectForKey:@"type"], fieldTypeGrouping); + NSLog(@"ERROR: unknown type for comparision: %@, in %@", [[tableDataInstance columnWithName:[fieldField titleOfSelectedItem]] objectForKey:@"type"], fieldTypeGrouping); } // Add IS NULL and IS NOT NULL as they should always be available @@ -3330,7 +3328,7 @@ theDictionary = [NSDictionary dictionaryWithObjectsAndKeys: [self tableFilterString], @"menuLabel", - [[fieldField selectedItem] title], @"filterField", + [fieldField titleOfSelectedItem], @"filterField", [[compareField selectedItem] title], @"filterComparison", [NSNumber numberWithInteger:[[compareField selectedItem] tag]], @"filterComparisonTag", [argumentField stringValue], @"filterValue", diff --git a/Source/SPTableRelations.h b/Source/SPTableRelations.h index aa270854..a71b151a 100644 --- a/Source/SPTableRelations.h +++ b/Source/SPTableRelations.h @@ -53,6 +53,7 @@ MCPConnection *connection; NSMutableArray *relationData; + NSUserDefaults *prefs; } @property (readonly) NSMutableArray *relationData; diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index 5160448f..980b8d30 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -49,6 +49,7 @@ { if ((self = [super init])) { relationData = [[NSMutableArray alloc] init]; + prefs = [NSUserDefaults standardUserDefaults]; } return self; @@ -175,7 +176,8 @@ [addRelationTableBox setTitle:[NSString stringWithFormat:NSLocalizedString(@"Table: %@", @"Add Relation sheet title, showing table name"), [tablesListInstance tableName]]]; [columnPopUpButton removeAllItems]; - [columnPopUpButton addItemsWithTitles:[tableDataInstance columnNames]]; + NSArray *columnTitles = ([prefs boolForKey:SPAlphabeticalTableSorting])? [[tableDataInstance columnNames] sortedArrayUsingSelector:@selector(compare:)] : [tableDataInstance columnNames]; + [columnPopUpButton addItemsWithTitles:columnTitles]; [refTablePopUpButton removeAllItems]; @@ -559,7 +561,8 @@ // Add the valid columns if ([validColumns count] > 0) { - [refColumnPopUpButton addItemsWithTitles:validColumns]; + NSArray *columnTitles = ([prefs boolForKey:SPAlphabeticalTableSorting])? [validColumns sortedArrayUsingSelector:@selector(compare:)] : validColumns; + [refColumnPopUpButton addItemsWithTitles:columnTitles]; [refColumnPopUpButton setEnabled:YES]; [confirmAddRelationButton setEnabled:YES]; |