From ada4b51b62baad20d98754bed1b3ae9391c44404 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Wed, 14 Nov 2018 17:38:04 +0100 Subject: [PATCH] Only allow for reordering drag if the sorting is index based --- MacPass/MPEntryTableDataSource.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MacPass/MPEntryTableDataSource.m b/MacPass/MPEntryTableDataSource.m index ded31811..f2850283 100644 --- a/MacPass/MPEntryTableDataSource.m +++ b/MacPass/MPEntryTableDataSource.m @@ -54,8 +54,16 @@ if(MPDisplayModeEntries != self.viewController.displayMode) { return NSDragOperationNone; } + BOOL isLocalDrag = info.draggingSource == tableView; + if(isLocalDrag) { + /* local drag is not usefull if the table is displaying sorted */ + NSArray * sortDescriptors = tableView.sortDescriptors; + if(sortDescriptors.count != 0 && sortDescriptors.firstObject.key != NSStringFromSelector(@selector(index))) { + return NSDragOperationNone; + } + } + BOOL makeCopy = !isLocalDrag || (info.draggingSourceOperationMask == NSDragOperationCopy); - BOOL makeCopy = (info.draggingSourceOperationMask == NSDragOperationCopy); if(dropOperation == NSTableViewDropOn) { [tableView setDropRow:row+1 dropOperation:NSTableViewDropAbove]; } @@ -88,6 +96,7 @@ [entry.undoManager setActionName:NSLocalizedString(@"MOVE_ENTRY", @"Action name when an entry was moved")]; } } + [self.viewController.entryArrayController rearrangeObjects]; return YES; } else {