mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 11:42:30 +00:00
fixed #152 Sorting now ignored case. All previously saved sorting settings in the entry view will be reverted to the default behaviour
This commit is contained in:
@@ -56,6 +56,7 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
||||
|
||||
+ (void)initialize {
|
||||
[MPSettingsHelper setupDefaults];
|
||||
[MPSettingsHelper migrateDefaults];
|
||||
[MPUppercaseStringValueTransformer registerTransformer];
|
||||
[MPStringLengthValueTransformer registerTransformer];
|
||||
[MPStripLineBreaksTransformer registerTransformer];
|
||||
|
||||
@@ -149,11 +149,11 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
|
||||
[self.entryTable setAutosaveName:@"EntryTable"];
|
||||
[self.entryTable setAutosaveTableColumns:YES];
|
||||
|
||||
NSSortDescriptor *titleColumSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"title" ascending:YES selector:@selector(compare:)];
|
||||
NSSortDescriptor *userNameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"username" ascending:YES selector:@selector(compare:)];
|
||||
NSSortDescriptor *urlSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"url" ascending:YES selector:@selector(compare:)];
|
||||
NSSortDescriptor *groupnameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"parent.name" ascending:YES selector:@selector(compare:)];
|
||||
NSSortDescriptor *dateSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"timeInfo.lastModificationTime" ascending:YES selector:@selector(compare:)];
|
||||
NSSortDescriptor *titleColumSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"title" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
||||
NSSortDescriptor *userNameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"username" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
||||
NSSortDescriptor *urlSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"url" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
||||
NSSortDescriptor *groupnameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"parent.name" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
||||
NSSortDescriptor *dateSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"timeInfo.lastModificationTime" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
||||
|
||||
[titleColumn setSortDescriptorPrototype:titleColumSortDescriptor];
|
||||
[userNameColumn setSortDescriptorPrototype:userNameSortDescriptor];
|
||||
|
||||
@@ -64,6 +64,11 @@ typedef NS_ENUM(NSUInteger, MPPasswordEncoding) {
|
||||
* Registers all the defaults for the applciaiton
|
||||
*/
|
||||
+ (void)setupDefaults;
|
||||
|
||||
/**
|
||||
* Brings the defaults to a current status. Removes obsoltes entries.
|
||||
*/
|
||||
+ (void)migrateDefaults;
|
||||
/**
|
||||
* Convenience Method to create a bind path for the NSUserDefaultsController
|
||||
*
|
||||
|
||||
@@ -43,6 +43,10 @@ NSString *const kMPSettingsKeyEntrySearchFilterMode = @"EntrySearchFilte
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:[self _standardDefaults]];
|
||||
}
|
||||
|
||||
+ (void)migrateDefaults {
|
||||
[self _fixEntryTableSortDescriptors];
|
||||
}
|
||||
|
||||
+ (NSString *)defaultControllerPathForKey:(NSString *)key {
|
||||
return [NSString stringWithFormat:@"values.%@", key];
|
||||
}
|
||||
@@ -72,4 +76,22 @@ NSString *const kMPSettingsKeyEntrySearchFilterMode = @"EntrySearchFilte
|
||||
};
|
||||
}
|
||||
|
||||
+ (void)_fixEntryTableSortDescriptors {
|
||||
/*
|
||||
MacPass < 0.4 did use compare: for the entry table view,
|
||||
this was changed in 0.4 to localizedCaseInsensitiveCompare:
|
||||
*/
|
||||
NSData *descriptorData = [[NSUserDefaults standardUserDefaults] dataForKey:kMPSettingsKeyEntryTableSortDescriptors];
|
||||
if(!descriptorData) {
|
||||
return; // No user defaults
|
||||
}
|
||||
NSArray *sortDescriptors = [NSUnarchiver unarchiveObjectWithData:descriptorData];
|
||||
for(NSSortDescriptor *descriptor in sortDescriptors) {
|
||||
if([descriptor selector] == @selector(compare:)) {
|
||||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kMPSettingsKeyEntryTableSortDescriptors];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user