From 039eefb06e9553e86e2fbaa612b0df68f105f4f4 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sat, 20 Oct 2007 19:25:14 +0000 Subject: [PATCH] another if-to-switch --- macosx/FileNameCell.m | 2 +- macosx/FilePriorityCell.m | 37 ++++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/macosx/FileNameCell.m b/macosx/FileNameCell.m index 36785b8d9..e316a8f43 100644 --- a/macosx/FileNameCell.m +++ b/macosx/FileNameCell.m @@ -22,8 +22,8 @@ * DEALINGS IN THE SOFTWARE. *****************************************************************************/ -#import "FileOutlineView.h" #import "FileNameCell.h" +#import "FileOutlineView.h" #import "Torrent.h" #import "NSStringAdditions.h" diff --git a/macosx/FilePriorityCell.m b/macosx/FilePriorityCell.m index 499a07088..cc255bcb3 100644 --- a/macosx/FilePriorityCell.m +++ b/macosx/FilePriorityCell.m @@ -73,8 +73,8 @@ int count = [priorities count]; FileOutlineView * view = (FileOutlineView *)[self controlView]; - int row = [view hoverRow]; - if (count > 0 && row != -1 && [view itemAtRow: row] == dict) + int hoverRow = [view hoverRow]; + if (count > 0 && hoverRow != -1 && [view itemAtRow: hoverRow] == dict) { [super setSelected: [priorities containsObject: [NSNumber numberWithInt: TR_PRI_LOW]] forSegment: 0]; [super setSelected: [priorities containsObject: [NSNumber numberWithInt: TR_PRI_NORMAL]] forSegment: 1]; @@ -97,23 +97,26 @@ fMixedImage = [NSImage imageNamed: @"PriorityMixed.png"]; image = fMixedImage; } - else if ([priorities containsObject: [NSNumber numberWithInt: TR_PRI_NORMAL]]) - { - if (!fNormalImage) - fNormalImage = [NSImage imageNamed: @"PriorityNormal.png"]; - image = fNormalImage; - } - else if ([priorities containsObject: [NSNumber numberWithInt: TR_PRI_LOW]]) - { - if (!fLowImage) - fLowImage = [NSImage imageNamed: @"PriorityLow.png"]; - image = fLowImage; - } else { - if (!fHighImage) - fHighImage = [NSImage imageNamed: @"PriorityHigh.png"]; - image = fHighImage; + switch ([[priorities anyObject] intValue]) + { + case TR_PRI_NORMAL: + if (!fNormalImage) + fNormalImage = [NSImage imageNamed: @"PriorityNormal.png"]; + image = fNormalImage; + break; + case TR_PRI_LOW: + if (!fLowImage) + fLowImage = [NSImage imageNamed: @"PriorityLow.png"]; + image = fLowImage; + break; + case TR_PRI_HIGH: + if (!fHighImage) + fHighImage = [NSImage imageNamed: @"PriorityHigh.png"]; + image = fHighImage; + break; + } } NSSize imageSize = [image size];