Changeset 2011


Ignore:
Timestamp:
Jun 9, 2007, 9:17:02 PM (15 years ago)
Author:
livings124
Message:

improve the file selection gui methods a bit...still very buggy

Location:
branches/file_selection/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/file_selection/macosx/InfoWindowController.m

    r2010 r2011  
    794794   
    795795    if ([[tableColumn identifier] isEqualToString: @"Check"])
    796         return [NSNumber numberWithInt: [[fTorrents objectAtIndex: 0] shouldDownloadItem: item]];
     796    {
     797        Torrent * torrent = [fTorrents objectAtIndex: 0];
     798        NSIndexSet * indexSet;
     799        if ([[item objectForKey: @"IsFolder"] boolValue])
     800            indexSet = [item objectForKey: @"Indexes"];
     801        else
     802            indexSet = [NSIndexSet indexSetWithIndex: [[item objectForKey: @"Index"] intValue]];
     803        return [NSNumber numberWithInt: [[fTorrents objectAtIndex: 0] shouldDownloadFiles: indexSet]];
     804    }
    797805    else
    798806        return item;
     
    815823            [cell setImage: [item objectForKey: @"Icon"]];
    816824            [(FileBrowserCell *)cell setProgress: [[fTorrents objectAtIndex: 0] fileProgress:
    817                                                     [[item objectForKey: @"Index"] floatValue]]];
     825                                                    [[item objectForKey: @"Index"] intValue]]];
    818826        }
    819827    }
     
    828836       
    829837        [(NSButtonCell *)cell setImagePosition: NSImageOnly];
    830         [cell setEnabled: [[fTorrents objectAtIndex: 0] canChangeDownloadItemCheck: item]];
     838       
     839        Torrent * torrent = [fTorrents objectAtIndex: 0];
     840        NSIndexSet * indexSet;
     841        if ([[item objectForKey: @"IsFolder"] boolValue])
     842            indexSet = [item objectForKey: @"Indexes"];
     843        else
     844            indexSet = [NSIndexSet indexSetWithIndex: [[item objectForKey: @"Index"] intValue]];
     845        [cell setEnabled: [torrent canChangeDownloadCheckFiles: indexSet]];
    831846    }
    832847    else;
  • branches/file_selection/macosx/Torrent.h

    r2010 r2011  
    203203- (int) fileCount;
    204204- (float) fileProgress: (int) index;
    205 - (int) shouldDownloadItem: (NSDictionary *) item;
    206 - (BOOL) canChangeDownloadItemCheck: (NSDictionary *) item;
     205- (int) shouldDownloadFiles: (NSIndexSet *) indexSet;
     206- (BOOL) canChangeDownloadCheckFiles: (NSIndexSet *) indexSet;
    207207- (void) setFileCheckState: (int) state forFileItem: (NSDictionary *) item;
    208208
  • branches/file_selection/macosx/Torrent.m

    r2010 r2011  
    13161316}
    13171317
    1318 - (int) shouldDownloadItem: (NSDictionary *) item
    1319 {
    1320     if ([[item objectForKey: @"IsFolder"] boolValue])
    1321     {
    1322         #warning do
    1323         return NSOnState;
    1324     }
    1325     else
    1326     {
    1327         int index = [[item objectForKey: @"Index"] intValue];
    1328         return tr_torrentGetFilePriority(fHandle, index) != TR_PRI_DND || [self fileProgress: index] >= 1.0
    1329                 ? NSOnState : NSOffState;
    1330     }
    1331 }
    1332 
    1333 - (BOOL) canChangeDownloadItemCheck: (NSDictionary *) item
    1334 {
    1335     if ([[item objectForKey: @"IsFolder"] boolValue])
    1336     {
    1337         #warning do
    1338         return YES;
    1339     }
    1340     else
    1341     {
    1342         #warning why is this happening?
    1343         float progress = [self fileProgress: [[item objectForKey: @"Index"] intValue]];
    1344         if (progress < 1.0)
    1345             NSLog(@"hi %f", progress);
     1318- (int) shouldDownloadFiles: (NSIndexSet *) indexSet
     1319{
     1320    BOOL onState = NO, offState = NO;
     1321    int index;
     1322    for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
     1323    {
     1324        if (tr_torrentGetFilePriority(fHandle, index) != TR_PRI_DND || [self fileProgress: index] >= 1.0)
     1325            onState = YES;
    13461326        else
    1347             NSLog(@"asdgagh %f", progress);
    1348         return [self fileProgress: [[item objectForKey: @"Index"] intValue]] < 1.0;
    1349     }
     1327            offState = YES;
     1328       
     1329        if (onState == offState)
     1330            return NSMixedState;
     1331    }
     1332    return onState ? NSOnState : NSOffState;
     1333}
     1334
     1335- (BOOL) canChangeDownloadCheckFiles: (NSIndexSet *) indexSet
     1336{
     1337    int index;
     1338    for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
     1339        if ([self fileProgress: index] < 1.0)
     1340            return YES;
     1341    return NO;
    13501342}
    13511343
     
    16081600        {
    16091601            [dict setObject: [NSMutableArray array] forKey: @"Children"];
     1602            [dict setObject: [NSMutableIndexSet indexSetWithIndex: index] forKey: @"Indexes"];
    16101603        }
    16111604        else
     
    16221615    {
    16231616        if (isFolder)
     1617        {
    16241618            [dict setObject: [NSNumber numberWithInt: [[dict objectForKey: @"Remaining"] intValue]+1] forKey: @"Remaining"];
     1619            [[dict objectForKey: @"Indexes"] addIndex: index];
     1620        }
    16251621    }
    16261622   
Note: See TracChangeset for help on using the changeset viewer.