Browse Source

Strict check for table.

v1.4.1
Abhishek Banthia 7 years ago
parent
commit
cdc6e14696
  1. BIN
      Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishekbanthia.xcuserdatad/UserInterfaceState.xcuserstate
  2. 89
      Clocker/Preferences/CLPreferencesViewController.m

BIN
Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishekbanthia.xcuserdatad/UserInterfaceState.xcuserstate generated

Binary file not shown.

89
Clocker/Preferences/CLPreferencesViewController.m

@ -694,56 +694,61 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
-(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn
{
static NSStringCompareOptions comparisonOptions = NSCaseInsensitiveSearch | NSNumericSearch | NSForcedOrderingSearch | NSWidthInsensitiveSearch;
[self.selectedTimeZones sortUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2){
if (tableView == self.timezoneTableView)
{
static NSStringCompareOptions comparisonOptions = NSCaseInsensitiveSearch | NSNumericSearch | NSForcedOrderingSearch | NSWidthInsensitiveSearch;
CLTimezoneData *object1 = [CLTimezoneData getCustomObject:obj1];
CLTimezoneData *object2 = [CLTimezoneData getCustomObject:obj2];
[self.selectedTimeZones sortUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2){
CLTimezoneData *object1 = [CLTimezoneData getCustomObject:obj1];
CLTimezoneData *object2 = [CLTimezoneData getCustomObject:obj2];
NSString *formattedAddress1, *formattedAddress2;
if ([tableColumn.identifier isEqualToString:CLPreferencesTimezoneNameIdentifier]) {
formattedAddress1 = object1.formattedAddress.length > 0 ? object1.formattedAddress : object1.timezoneID;
formattedAddress2 = object2.formattedAddress.length > 0 ? object2.formattedAddress : object2.timezoneID;
}
else
{
formattedAddress1 = object1.customLabel.length > 0 ? object1.customLabel : object1.formattedAddress.length > 0 ? object1.formattedAddress : object1.timezoneID;
formattedAddress2 = object2.customLabel.length > 0 ? object2.customLabel : object2.formattedAddress.length > 0 ? object2.formattedAddress : object2.timezoneID;
}
NSRange string1Range = NSMakeRange(0, [formattedAddress1 length]);
if (!self.arePlacesSortedInAscendingOrder) {
return [formattedAddress1 compare:formattedAddress2
options:comparisonOptions
range:string1Range
locale:[NSLocale localeWithLocaleIdentifier:@"en_us"]];
}
else
{
return -[formattedAddress1 compare:formattedAddress2
options:comparisonOptions
range:string1Range
locale:[NSLocale localeWithLocaleIdentifier:@"en_us"]];
}
}];
NSString *formattedAddress1, *formattedAddress2;
self.arePlacesSortedInAscendingOrder ? [self.timezoneTableView setIndicatorImage:[NSImage imageNamed:@"NSDescendingSortIndicator"] inTableColumn:tableColumn] : [self.timezoneTableView setIndicatorImage:[NSImage imageNamed:@"NSAscendingSortIndicator"] inTableColumn:tableColumn];
if ([tableColumn.identifier isEqualToString:CLPreferencesTimezoneNameIdentifier]) {
formattedAddress1 = object1.formattedAddress.length > 0 ? object1.formattedAddress : object1.timezoneID;
formattedAddress2 = object2.formattedAddress.length > 0 ? object2.formattedAddress : object2.timezoneID;
}
else
{
formattedAddress1 = object1.customLabel.length > 0 ? object1.customLabel : object1.formattedAddress.length > 0 ? object1.formattedAddress : object1.timezoneID;
formattedAddress2 = object2.customLabel.length > 0 ? object2.customLabel : object2.formattedAddress.length > 0 ? object2.formattedAddress : object2.timezoneID;
}
self.arePlacesSortedInAscendingOrder = !self.arePlacesSortedInAscendingOrder;
NSRange string1Range = NSMakeRange(0, [formattedAddress1 length]);
NSMutableArray *newDefaults = [[NSMutableArray alloc] initWithArray:self.selectedTimeZones];
if (!self.arePlacesSortedInAscendingOrder) {
return [formattedAddress1 compare:formattedAddress2
options:comparisonOptions
range:string1Range
locale:[NSLocale localeWithLocaleIdentifier:@"en_us"]];
}
else
{
return -[formattedAddress1 compare:formattedAddress2
options:comparisonOptions
range:string1Range
locale:[NSLocale localeWithLocaleIdentifier:@"en_us"]];
}
[[NSUserDefaults standardUserDefaults] setObject:newDefaults forKey:CLDefaultPreferenceKey];
[self.timezoneTableView reloadData];
}];
self.arePlacesSortedInAscendingOrder ? [self.timezoneTableView setIndicatorImage:[NSImage imageNamed:@"NSDescendingSortIndicator"] inTableColumn:tableColumn] : [self.timezoneTableView setIndicatorImage:[NSImage imageNamed:@"NSAscendingSortIndicator"] inTableColumn:tableColumn];
self.arePlacesSortedInAscendingOrder = !self.arePlacesSortedInAscendingOrder;
NSMutableArray *newDefaults = [[NSMutableArray alloc] initWithArray:self.selectedTimeZones];
[[NSUserDefaults standardUserDefaults] setObject:newDefaults forKey:CLDefaultPreferenceKey];
[self.timezoneTableView reloadData];
[self refreshMainTableview];
[self refreshMainTableview];
}
}
#pragma mark Other Methods

Loading…
Cancel
Save