Pinned Group and Index columns. Disabled reordering of those two columns

This commit is contained in:
Michael Starke
2018-09-11 17:00:08 +02:00
parent c6be6ec819
commit 6ed82d8f15

View File

@@ -204,7 +204,16 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
options:@{ NSValueTransformerNameBindingOption: NSUnarchiveFromDataTransformerName }];
[self _setupHeaderMenu];
/* Move index and parent column to dedicated places if it was moved by the user before */
parentColumn.hidden = YES;
NSUInteger indexIndex = [self.entryTable columnWithIdentifier:MPEntryTableIndexColumnIdentifier];
if(indexIndex != 0) {
[self.entryTable moveColumn:indexIndex toColumn:0];
}
NSUInteger parentIndex = [self.entryTable columnWithIdentifier:MPEntryTableParentColumnIdentifier];
if(parentIndex != 1) {
[self.entryTable moveColumn:parentIndex toColumn:1];
}
}
- (NSResponder *)reconmendedFirstResponder {
@@ -376,6 +385,18 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
document.selectedEntries = self.entryArrayController.selectedObjects;
}
- (BOOL)tableView:(NSTableView *)tableView shouldReorderColumn:(NSInteger)columnIndex toColumn:(NSInteger)newColumnIndex {
NSTableColumn *column = tableView.tableColumns[columnIndex];
/* Do not allow to set as first column */
if(newColumnIndex == 1 || newColumnIndex == 0) {
return NO;
}
BOOL isParentColumn = [column.identifier isEqualToString:MPEntryTableParentColumnIdentifier];
BOOL isIndexColumn = [column.identifier isEqualToString:MPEntryTableIndexColumnIdentifier];
return !(isParentColumn || isIndexColumn);
}
#pragma mark MPTargetItemResolving
- (NSArray<KPKEntry *> *)currentTargetEntries {
NSInteger activeRow = self.entryTable.clickedRow;