mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 00:02:28 +00:00
added index column and custom index sorting
This commit is contained in:
2
Cartfile
2
Cartfile
@@ -1,3 +1,3 @@
|
|||||||
github "sparkle-project/Sparkle" ~> 1.13.1
|
github "sparkle-project/Sparkle" ~> 1.13.1
|
||||||
github "mstarke/KeePassKit" "d66c888b299358481da2ba2672ec7c644cce56ec"
|
github "mstarke/KeePassKit" "8803a3df186371827171f9a033d7c61eb56f25c1"
|
||||||
github "mstarke/HNHUi" ~> 1.1
|
github "mstarke/HNHUi" ~> 1.1
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
github "mstarke/HNHUi" "1.1"
|
github "mstarke/HNHUi" "1.1"
|
||||||
github "mstarke/KeePassKit" "d66c888b299358481da2ba2672ec7c644cce56ec"
|
github "mstarke/KeePassKit" "8803a3df186371827171f9a033d7c61eb56f25c1"
|
||||||
github "sparkle-project/Sparkle" "1.14.0"
|
github "sparkle-project/Sparkle" "1.14.0"
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ typedef NS_ENUM(NSUInteger,MPOVerlayInfoType) {
|
|||||||
MPOverlayInfoCustom,
|
MPOverlayInfoCustom,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
NSString *const MPEntryTableIndexColumnIdentifier = @"MPEntryTableIndexColumnIdentifier";
|
||||||
NSString *const MPEntryTableUserNameColumnIdentifier = @"MPUserNameColumnIdentifier";
|
NSString *const MPEntryTableUserNameColumnIdentifier = @"MPUserNameColumnIdentifier";
|
||||||
NSString *const MPEntryTableTitleColumnIdentifier = @"MPTitleColumnIdentifier";
|
NSString *const MPEntryTableTitleColumnIdentifier = @"MPTitleColumnIdentifier";
|
||||||
NSString *const MPEntryTablePasswordColumnIdentifier = @"MPPasswordColumnIdentifier";
|
NSString *const MPEntryTablePasswordColumnIdentifier = @"MPPasswordColumnIdentifier";
|
||||||
@@ -130,14 +131,17 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
NSTableColumn *notesColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableNotesColumnIdentifier];
|
NSTableColumn *notesColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableNotesColumnIdentifier];
|
||||||
NSTableColumn *modifiedColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableModfiedColumnIdentifier];
|
NSTableColumn *modifiedColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableModfiedColumnIdentifier];
|
||||||
NSTableColumn *historyColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableHistoryColumnIdentifier];
|
NSTableColumn *historyColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableHistoryColumnIdentifier];
|
||||||
|
NSTableColumn *indexColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableIndexColumnIdentifier];
|
||||||
notesColumn.minWidth = 40.0;
|
notesColumn.minWidth = 40.0;
|
||||||
attachmentsColumn.minWidth = 40.0;
|
attachmentsColumn.minWidth = 40.0;
|
||||||
modifiedColumn.minWidth = 40.0;
|
modifiedColumn.minWidth = 40.0;
|
||||||
historyColumn.minWidth = 40.0;
|
historyColumn.minWidth = 40.0;
|
||||||
|
indexColumn.minWidth = 16.0;
|
||||||
[self.entryTable addTableColumn:notesColumn];
|
[self.entryTable addTableColumn:notesColumn];
|
||||||
[self.entryTable addTableColumn:attachmentsColumn];
|
[self.entryTable addTableColumn:attachmentsColumn];
|
||||||
[self.entryTable addTableColumn:modifiedColumn];
|
[self.entryTable addTableColumn:modifiedColumn];
|
||||||
[self.entryTable addTableColumn:historyColumn];
|
[self.entryTable addTableColumn:historyColumn];
|
||||||
|
[self.entryTable addTableColumn:indexColumn];
|
||||||
|
|
||||||
parentColumn.identifier = MPEntryTableParentColumnIdentifier;
|
parentColumn.identifier = MPEntryTableParentColumnIdentifier;
|
||||||
titleColumn.identifier = MPEntryTableTitleColumnIdentifier;
|
titleColumn.identifier = MPEntryTableTitleColumnIdentifier;
|
||||||
@@ -151,12 +155,15 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
NSString *parentTitleKeyPath = [[NSString alloc] initWithFormat:@"%@.%@", NSStringFromSelector(@selector(parent)), NSStringFromSelector(@selector(title))];
|
NSString *parentTitleKeyPath = [[NSString alloc] initWithFormat:@"%@.%@", NSStringFromSelector(@selector(parent)), NSStringFromSelector(@selector(title))];
|
||||||
NSString *timeInfoModificationTimeKeyPath = [[NSString alloc] initWithFormat:@"%@.%@", NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(modificationDate))];
|
NSString *timeInfoModificationTimeKeyPath = [[NSString alloc] initWithFormat:@"%@.%@", NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(modificationDate))];
|
||||||
|
|
||||||
|
indexColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(index)) ascending:YES selector:@selector(compare:)];
|
||||||
titleColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(title))ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
titleColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(title))ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
||||||
userNameColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(username)) ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
userNameColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(username)) ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
||||||
urlColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(url)) ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
urlColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(url)) ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
||||||
parentColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:parentTitleKeyPath ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
parentColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:parentTitleKeyPath ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
|
||||||
modifiedColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:timeInfoModificationTimeKeyPath ascending:YES selector:@selector(compare:)];
|
modifiedColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:timeInfoModificationTimeKeyPath ascending:YES selector:@selector(compare:)];
|
||||||
|
|
||||||
|
|
||||||
|
indexColumn.headerCell.stringValue = @"";
|
||||||
parentColumn.headerCell.stringValue = NSLocalizedString(@"GROUP", "");
|
parentColumn.headerCell.stringValue = NSLocalizedString(@"GROUP", "");
|
||||||
titleColumn.headerCell.stringValue = NSLocalizedString(@"TITLE", "");
|
titleColumn.headerCell.stringValue = NSLocalizedString(@"TITLE", "");
|
||||||
userNameColumn.headerCell.stringValue = NSLocalizedString(@"USERNAME", "");
|
userNameColumn.headerCell.stringValue = NSLocalizedString(@"USERNAME", "");
|
||||||
@@ -232,6 +239,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
|
|
||||||
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||||
|
|
||||||
|
BOOL isIndexColumn = [tableColumn.identifier isEqualToString:MPEntryTableIndexColumnIdentifier];
|
||||||
BOOL isTitleColumn = [tableColumn.identifier isEqualToString:MPEntryTableTitleColumnIdentifier];
|
BOOL isTitleColumn = [tableColumn.identifier isEqualToString:MPEntryTableTitleColumnIdentifier];
|
||||||
BOOL isGroupColumn = [tableColumn.identifier isEqualToString:MPEntryTableParentColumnIdentifier];
|
BOOL isGroupColumn = [tableColumn.identifier isEqualToString:MPEntryTableParentColumnIdentifier];
|
||||||
BOOL isPasswordColum = [tableColumn.identifier isEqualToString:MPEntryTablePasswordColumnIdentifier];
|
BOOL isPasswordColum = [tableColumn.identifier isEqualToString:MPEntryTablePasswordColumnIdentifier];
|
||||||
@@ -285,6 +293,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
/* clean up old formatter that might be left */
|
/* clean up old formatter that might be left */
|
||||||
view.textField.formatter = nil;
|
view.textField.formatter = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isModifedColumn) {
|
if(isModifedColumn) {
|
||||||
if(!view.textField.formatter) {
|
if(!view.textField.formatter) {
|
||||||
/* Just use one formatter instance since it's expensive to create */
|
/* Just use one formatter instance since it's expensive to create */
|
||||||
@@ -333,10 +342,13 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
}
|
}
|
||||||
else if(isHistoryColumn) {
|
else if(isHistoryColumn) {
|
||||||
NSString *historyCountKeyPath = [NSString stringWithFormat:@"%@.%@.@count",
|
NSString *historyCountKeyPath = [NSString stringWithFormat:@"%@.%@.@count",
|
||||||
NSStringFromSelector(@selector(objectValue)),
|
NSStringFromSelector(@selector(objectValue)),
|
||||||
NSStringFromSelector(@selector(history))];
|
NSStringFromSelector(@selector(history))];
|
||||||
[view.textField bind:NSValueBinding toObject:view withKeyPath:historyCountKeyPath options:nil];
|
[view.textField bind:NSValueBinding toObject:view withKeyPath:historyCountKeyPath options:nil];
|
||||||
}
|
}
|
||||||
|
else if(isIndexColumn) {
|
||||||
|
view.textField.stringValue = @"";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@@ -360,10 +372,10 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
#pragma mark MPTargetItemResolving
|
#pragma mark MPTargetItemResolving
|
||||||
- (NSArray<KPKEntry *> *)currentTargetEntries {
|
- (NSArray<KPKEntry *> *)currentTargetEntries {
|
||||||
/*NSInteger activeRow = self.entryTable.clickedRow;
|
/*NSInteger activeRow = self.entryTable.clickedRow;
|
||||||
if(activeRow > -1) {
|
if(activeRow > -1) {
|
||||||
return @[ [self.entryArrayController arrangedObjects][activeRow] ];
|
return @[ [self.entryArrayController arrangedObjects][activeRow] ];
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
return self.entryArrayController.selectedObjects;
|
return self.entryArrayController.selectedObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,7 +626,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
[item bind:NSValueBinding toObject:column withKeyPath:NSHiddenBinding options:options];
|
[item bind:NSValueBinding toObject:column withKeyPath:NSHiddenBinding options:options];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[self.entryTable headerView] setMenu:headerMenu];
|
self.entryTable.headerView.menu = headerMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark Actions
|
#pragma mark Actions
|
||||||
|
|||||||
Reference in New Issue
Block a user