Changeset 2338


Ignore:
Timestamp:
Jul 13, 2007, 4:52:40 AM (15 years ago)
Author:
livings124
Message:

for priorities experiment with a set instead of an array

Location:
trunk/macosx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/FileOutlineView.m

    r2337 r2338  
    110110        else
    111111        {
    112             NSArray * priorities = [torrent filePrioritiesForIndexes: [item objectForKey: @"Indexes"]];
     112            NSSet * priorities = [torrent filePrioritiesForIndexes: [item objectForKey: @"Indexes"]];
    113113            if ([priorities count] == 0)
    114114                [fNormalColor set];
    115115            else
    116116            {
    117                 int priority = [[priorities objectAtIndex: 0] intValue];
     117                int priority = [[priorities anyObject] intValue];
    118118                if (priority == TR_PRI_LOW)
    119119                    [fLowPriorityColor set];
     
    149149            if (![[item objectForKey: @"IsFolder"] boolValue])
    150150            {
    151                 NSArray * priorities = [torrent filePrioritiesForIndexes: [item objectForKey: @"Indexes"]];
     151                NSSet * priorities = [torrent filePrioritiesForIndexes: [item objectForKey: @"Indexes"]];
    152152                if ([priorities count] == 1)
    153153                {
    154                     int priority = [[priorities objectAtIndex: 0] intValue];
     154                    int priority = [[priorities anyObject] intValue];
    155155                    if (priority == TR_PRI_LOW)
    156156                        [fLowPriorityColor set];
  • trunk/macosx/FilePriorityCell.m

    r2318 r2338  
    5353{
    5454    Torrent * torrent = [(InfoWindowController *)[[[self controlView] window] windowController] selectedTorrent];
    55     NSIndexSet * indexSet = [fItem objectForKey: @"Indexes"];
     55    NSSet * priorities = [torrent filePrioritiesForIndexes: [fItem objectForKey: @"Indexes"]];
    5656   
    57     if (![torrent canChangeDownloadCheckForFiles: indexSet])
     57    if ([priorities count] == 0)
    5858        return;
    5959   
    60     BOOL low = [torrent hasFilePriority: TR_PRI_LOW forIndexes: indexSet],
    61         normal = [torrent hasFilePriority: TR_PRI_NORMAL forIndexes: indexSet],
    62         high = [torrent hasFilePriority: TR_PRI_HIGH forIndexes: indexSet];
     60    BOOL low = [priorities containsObject: [NSNumber numberWithInt: TR_PRI_LOW]],
     61        normal = [priorities containsObject: [NSNumber numberWithInt: TR_PRI_NORMAL]],
     62        high = [priorities containsObject: [NSNumber numberWithInt: TR_PRI_HIGH]];
    6363   
    6464    FileOutlineView * view = (FileOutlineView *)[self controlView];
  • trunk/macosx/InfoWindowController.m

    r2337 r2338  
    933933    else if ([ident isEqualToString: @"Priority"])
    934934    {
    935         NSArray * priorities = [[fTorrents objectAtIndex: 0] filePrioritiesForIndexes: [item objectForKey: @"Indexes"]];
     935        NSSet * priorities = [[fTorrents objectAtIndex: 0] filePrioritiesForIndexes: [item objectForKey: @"Indexes"]];
    936936       
    937937        int count = [priorities count];
     
    942942        else
    943943        {
    944             int priority = [[priorities objectAtIndex: 0] intValue];
     944            int priority = [[priorities anyObject] intValue];
    945945            if (priority == TR_PRI_LOW)
    946946                return NSLocalizedString(@"Low Priority", "Inspector -> files tab -> tooltip");
  • trunk/macosx/Torrent.h

    r2337 r2338  
    207207- (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
    208208- (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
    209 - (NSArray *) filePrioritiesForIndexes: (NSIndexSet *) indexSet;
     209- (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet;
    210210
    211211- (NSDate *) dateAdded;
  • trunk/macosx/Torrent.m

    r2337 r2338  
    13531353}
    13541354
    1355 - (NSArray *) filePrioritiesForIndexes: (NSIndexSet *) indexSet
     1355- (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet
    13561356{
    13571357    BOOL low = NO, normal = NO, high = NO;
    1358     NSMutableArray * priorities = [NSMutableArray arrayWithCapacity: 3];
     1358    NSMutableSet * priorities = [NSMutableSet setWithCapacity: 3];
    13591359   
    13601360    int index, priority;
     
    13671367        if (priority == TR_PRI_LOW)
    13681368        {
    1369             if (!low)
    1370                 low = YES;
    1371             else
     1369            if (low)
    13721370                continue;
     1371            low = YES;
    13731372        }
    13741373        else if (priority == TR_PRI_HIGH)
    13751374        {
    1376             if (!high)
    1377                 high = YES;
    1378             else
     1375            if (high)
    13791376                continue;
     1377            high = YES;
    13801378        }
    13811379        else
    13821380        {
    1383             if (!normal)
    1384                 normal = YES;
    1385             else
     1381            if (normal)
    13861382                continue;
     1383            normal = YES;
    13871384        }
    13881385       
    13891386        [priorities addObject: [NSNumber numberWithInt: priority]];
    1390        
    13911387        if (low && normal && high)
    13921388            break;
Note: See TracChangeset for help on using the changeset viewer.