diff --git a/cocoa/base/ResultOutline.h b/cocoa/base/ResultOutline.h index 243dd7d1..eb37b627 100644 --- a/cocoa/base/ResultOutline.h +++ b/cocoa/base/ResultOutline.h @@ -21,6 +21,7 @@ http://www.hardcoded.net/licenses/hs_license - (BOOL)deltaValuesMode; - (void)setDeltaValuesMode:(BOOL)aDeltaValuesMode; - (void)setDeltaColumns:(NSIndexSet *)aDeltaColumns; +- (NSInteger)selectedDupeCount; - (IBAction)markSelected:(id)sender; @end; \ No newline at end of file diff --git a/cocoa/base/ResultOutline.m b/cocoa/base/ResultOutline.m index be3a287b..8048174e 100644 --- a/cocoa/base/ResultOutline.m +++ b/cocoa/base/ResultOutline.m @@ -59,6 +59,23 @@ http://www.hardcoded.net/licenses/hs_license _deltaColumns = [aDeltaColumns retain]; } +- (NSInteger)selectedDupeCount +{ + NSArray *selected = [self selectedIndexPaths]; + if ([self powerMarkerMode]) { + return [selected count]; + } + else { + NSInteger r = 0; + for (NSArray *path in selected) { + if ([path count] == 1) { + r++; + } + } + return r; + } +} + - (IBAction)markSelected:(id)sender { [[self py] markSelected]; diff --git a/cocoa/base/ResultWindow.h b/cocoa/base/ResultWindow.h index 7db623e4..13ad4c55 100644 --- a/cocoa/base/ResultWindow.h +++ b/cocoa/base/ResultWindow.h @@ -38,7 +38,6 @@ http://www.hardcoded.net/licenses/hs_license - (NSTableColumn *)getColumnForIdentifier:(NSInteger)aIdentifier title:(NSString *)aTitle width:(NSInteger)aWidth refCol:(NSTableColumn *)aColumn; - (NSArray *)getColumnsOrder; - (NSDictionary *)getColumnsWidth; -- (NSArray *)getSelectedPaths:(BOOL)aDupesOnly; - (void)initResultColumns; - (void)restoreColumnsPosition:(NSArray *)aColumnsOrder widths:(NSDictionary *)aColumnsWidth; diff --git a/cocoa/base/ResultWindow.m b/cocoa/base/ResultWindow.m index fd628a7a..c080309c 100644 --- a/cocoa/base/ResultWindow.m +++ b/cocoa/base/ResultWindow.m @@ -109,22 +109,6 @@ http://www.hardcoded.net/licenses/hs_license return result; } -- (NSArray *)getSelectedPaths:(BOOL)aDupesOnly -{ - if ([outline powerMarkerMode]) - aDupesOnly = NO; - NSIndexSet *indexes = [matches selectedRowIndexes]; - NSMutableArray *nodeList = [NSMutableArray array]; - NSInteger i = [indexes firstIndex]; - while (i != NSNotFound) { - NSIndexPath *path = [matches itemAtRow:i]; - if (!aDupesOnly || ([path length] > 1)) - [nodeList addObject:p2a(path)]; - i = [indexes indexGreaterThanIndex:i]; - } - return nodeList; -} - - (void)initResultColumns { // Virtual @@ -220,10 +204,10 @@ http://www.hardcoded.net/licenses/hs_license - (IBAction)ignoreSelected:(id)sender { - NSArray *pathList = [self getSelectedPaths:YES]; - if (![pathList count]) + NSInteger selectedDupeCount = [outline selectedDupeCount]; + if (!selectedDupeCount) return; - NSString *msg = [NSString stringWithFormat:@"All selected %d matches are going to be ignored in all subsequent scans. Continue?",[pathList count]]; + NSString *msg = [NSString stringWithFormat:@"All selected %d matches are going to be ignored in all subsequent scans. Continue?",selectedDupeCount]; if ([Dialogs askYesNo:msg] == NSAlertSecondButtonReturn) // NO return; [py addSelectedToIgnoreList]; @@ -295,10 +279,11 @@ http://www.hardcoded.net/licenses/hs_license - (IBAction)removeSelected:(id)sender { - NSArray *pathList = [self getSelectedPaths:YES]; - if (![pathList count]) + NSInteger selectedDupeCount = [outline selectedDupeCount]; + if (!selectedDupeCount) return; - if ([Dialogs askYesNo:[NSString stringWithFormat:@"You are about to remove %d files from results. Continue?",[pathList count]]] == NSAlertSecondButtonReturn) // NO + NSString *msg = [NSString stringWithFormat:@"You are about to remove %d files from results. Continue?",selectedDupeCount]; + if ([Dialogs askYesNo:msg] == NSAlertSecondButtonReturn) // NO return; [py removeSelected]; }