From 195bc4ef218eb3d35ee66506845f66943925990b Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 9 Feb 2010 14:59:35 +0100 Subject: [PATCH] Eliminated code duplication in ResultsWindow. --- cocoa/base/ResultWindow.m | 24 ++++++++++++++++++++++++ cocoa/me/ResultWindow.m | 25 ------------------------- cocoa/pe/ResultWindow.m | 25 ------------------------- cocoa/se/ResultWindow.m | 25 ------------------------- 4 files changed, 24 insertions(+), 75 deletions(-) diff --git a/cocoa/base/ResultWindow.m b/cocoa/base/ResultWindow.m index e9a5040c..db63915f 100644 --- a/cocoa/base/ResultWindow.m +++ b/cocoa/base/ResultWindow.m @@ -501,6 +501,30 @@ http://www.hardcoded.net/licenses/hs_license [self reloadMatches]; } +- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item +{ + OVNode *node = item; + if ([[tableColumn identifier] isEqual:@"mark"]) { + [cell setEnabled: [node isMarkable]]; + } + if ([cell isKindOfClass:[NSTextFieldCell class]]) { + // Determine if the text color will be blue due to directory being reference. + NSTextFieldCell *textCell = cell; + if ([node isMarkable]) { + [textCell setTextColor:[NSColor blackColor]]; + } + else { + [textCell setTextColor:[NSColor blueColor]]; + } + if ((_displayDelta) && (_powerMode || ([node level] > 1))) { + NSInteger i = [[tableColumn identifier] integerValue]; + if ([_deltaColumns containsIndex:i]) { + [textCell setTextColor:[NSColor orangeColor]]; + } + } + } +} + /* Notifications */ - (void)windowWillClose:(NSNotification *)aNotification { diff --git a/cocoa/me/ResultWindow.m b/cocoa/me/ResultWindow.m index ffc7ae70..7599fb4e 100644 --- a/cocoa/me/ResultWindow.m +++ b/cocoa/me/ResultWindow.m @@ -111,31 +111,6 @@ http://www.hardcoded.net/licenses/hs_license [_resultColumns addObject:[self getColumnForIdentifier:18 title:@"Dupe Count" width:80 refCol:refCol]]; } -/* Delegate */ -- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item -{ - OVNode *node = item; - if ([[tableColumn identifier] isEqual:@"mark"]) - { - [cell setEnabled: [node isMarkable]]; - } - if ([cell isKindOfClass:[NSTextFieldCell class]]) - { - // Determine if the text color will be blue due to directory being reference. - NSTextFieldCell *textCell = cell; - if ([node isMarkable]) - [textCell setTextColor:[NSColor blackColor]]; - else - [textCell setTextColor:[NSColor blueColor]]; - if ((_displayDelta) && (_powerMode || ([node level] > 1))) - { - int i = [[tableColumn identifier] intValue]; - if ([_deltaColumns containsIndex:i]) - [textCell setTextColor:[NSColor orangeColor]]; - } - } -} - /* Notifications */ - (void)jobCompleted:(NSNotification *)aNotification { diff --git a/cocoa/pe/ResultWindow.m b/cocoa/pe/ResultWindow.m index 024e09f5..eea4d5cb 100644 --- a/cocoa/pe/ResultWindow.m +++ b/cocoa/pe/ResultWindow.m @@ -98,29 +98,4 @@ http://www.hardcoded.net/licenses/hs_license [_resultColumns addObject:[self getColumnForIdentifier:7 title:@"Match %" width:58 refCol:refCol]]; [_resultColumns addObject:[self getColumnForIdentifier:8 title:@"Dupe Count" width:80 refCol:refCol]]; } - -/* Delegate */ -- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item -{ - OVNode *node = item; - if ([[tableColumn identifier] isEqual:@"mark"]) - { - [cell setEnabled: [node isMarkable]]; - } - if ([cell isKindOfClass:[NSTextFieldCell class]]) - { - // Determine if the text color will be blue due to directory being reference. - NSTextFieldCell *textCell = cell; - if ([node isMarkable]) - [textCell setTextColor:[NSColor blackColor]]; - else - [textCell setTextColor:[NSColor blueColor]]; - if ((_displayDelta) && (_powerMode || ([node level] > 1))) - { - int i = [[tableColumn identifier] intValue]; - if ([_deltaColumns containsIndex:i]) - [textCell setTextColor:[NSColor orangeColor]]; - } - } -} @end \ No newline at end of file diff --git a/cocoa/se/ResultWindow.m b/cocoa/se/ResultWindow.m index 0f4087f1..b5287ad5 100644 --- a/cocoa/se/ResultWindow.m +++ b/cocoa/se/ResultWindow.m @@ -87,29 +87,4 @@ http://www.hardcoded.net/licenses/hs_license [_resultColumns addObject:[self getColumnForIdentifier:7 title:@"Words Used" width:120 refCol:refCol]]; [_resultColumns addObject:[self getColumnForIdentifier:8 title:@"Dupe Count" width:80 refCol:refCol]]; } - -/* Delegate */ -- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item -{ - OVNode *node = item; - if ([[tableColumn identifier] isEqual:@"mark"]) - { - [cell setEnabled: [node isMarkable]]; - } - if ([cell isKindOfClass:[NSTextFieldCell class]]) - { - // Determine if the text color will be blue due to directory being reference. - NSTextFieldCell *textCell = cell; - if ([node isMarkable]) - [textCell setTextColor:[NSColor blackColor]]; - else - [textCell setTextColor:[NSColor blueColor]]; - if ((_displayDelta) && (_powerMode || ([node level] > 1))) - { - int i = [[tableColumn identifier] intValue]; - if ([_deltaColumns containsIndex:i]) - [textCell setTextColor:[NSColor orangeColor]]; - } - } -} @end