Changeset 2033


Ignore:
Timestamp:
Jun 10, 2007, 10:03:01 PM (15 years ago)
Author:
livings124
Message:

setting of file priorities and checks is now possible through the context menu

Location:
branches/file_selection/macosx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/file_selection/macosx/English.lproj/InfoWindow.nib/classes.nib

    r1949 r2033  
    88                revealFile = id;
    99                revealTorrentFile = id;
     10                setCheck = id;
    1011                setLimitSetting = id;
    1112                setPex = id;
     13                setPriority = id;
    1214                setRatioLimit = id;
    1315                setRatioSetting = id;
     
    3335                fDownloadingFromField = NSTextField;
    3436                fErrorMessageView = NSTextView;
     37                fFileCheckItem = NSMenuItem;
    3538                fFileOutline = NSOutlineView;
     39                fFilePriorityHigh = NSMenuItem;
     40                fFilePriorityLow = NSMenuItem;
     41                fFilePriorityNormal = NSMenuItem;
    3642                fFileTableStatusField = NSTextField;
     43                fFileUncheckItem = NSMenuItem;
    3744                fHashField = NSTextField;
    3845                fImageView = NSImageView;
  • branches/file_selection/macosx/English.lproj/InfoWindow.nib/info.nib

    r1799 r2033  
    88        <dict>
    99                <key>549</key>
    10                 <string>364 417 144 49 0 0 1152 842 </string>
     10                <string>565 283 144 118 0 0 1152 842 </string>
    1111        </dict>
    1212        <key>IBFramework Version</key>
     
    2222        <key>IBOpenObjects</key>
    2323        <array>
     24                <integer>549</integer>
    2425                <integer>5</integer>
    2526        </array>
  • branches/file_selection/macosx/FileOutlineView.m

    r2026 r2033  
    8080}
    8181
    82 - (NSMenu *) menuForEvent: (NSEvent *) e
     82- (NSMenu *) menuForEvent: (NSEvent *) event
    8383{
    84     int row = [self rowAtPoint: [self convertPoint: [e locationInWindow] fromView: nil]];
     84    int row = [self rowAtPoint: [self convertPoint: [event locationInWindow] fromView: nil]];
    8585   
    8686    if (row >= 0)
    8787    {
    88         if ([self itemAtRow: row] && ![self isRowSelected: row])
     88        if (![self isRowSelected: row])
    8989            [self selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection: NO];
    9090    }
  • branches/file_selection/macosx/InfoWindowController.h

    r2012 r2033  
    5555    IBOutlet NSOutlineView * fFileOutline;
    5656    IBOutlet NSTextField * fFileTableStatusField;
     57    IBOutlet NSMenuItem * fFileCheckItem, * fFileUncheckItem,
     58                        * fFilePriorityNormal, * fFilePriorityHigh, * fFilePriorityLow;
    5759   
    5860    IBOutlet NSPopUpButton * fRatioPopUp, * fUploadLimitPopUp, * fDownloadLimitPopUp;
     
    7476- (void) revealFile: (id) sender;
    7577
     78- (void) setCheck: (id) sender;
     79- (void) setPriority: (id) sender;
     80
    7681- (void) setLimitSetting: (id) sender;
    7782- (void) setSpeedLimit: (id) sender;
  • branches/file_selection/macosx/InfoWindowController.m

    r2026 r2033  
    589589        return [fFileOutline numberOfSelectedRows] > 0 &&
    590590            [[[fTabView selectedTabViewItem] identifier] isEqualToString: TAB_FILES_IDENT];
     591   
     592    if (action == @selector(setCheck:))
     593    {
     594        Torrent * torrent = [fTorrents objectAtIndex: 0];
     595        NSDictionary * item;
     596        NSIndexSet * indexSet = [fFileOutline selectedRowIndexes], * itemIndexes;
     597        int i, index, state = (menuItem == fFileCheckItem) ? NSOnState : NSOffState;
     598        for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
     599        {
     600            item = [fFileOutline itemAtRow: i];
     601            if ([[item objectForKey: @"IsFolder"] boolValue])
     602            {
     603                itemIndexes = [item objectForKey: @"Indexes"];
     604                if ([torrent checkForFileFolder: itemIndexes] != state
     605                        && [torrent canChangeDownloadCheckForFileFolder: itemIndexes])
     606                    return YES;
     607            }
     608            else
     609            {
     610                index = [[item objectForKey: @"Index"] intValue];
     611                if ([torrent checkForFile: index] != state && [torrent canChangeDownloadCheckFile: index])
     612                    return YES;
     613            }
     614        }
     615        return NO;
     616    }
     617   
     618    if (action == @selector(setPriority:))
     619    {
     620        return [fFileOutline numberOfSelectedRows] > 0;
     621    }
    591622       
    592623    return YES;
     
    813844    else if ([[tableColumn identifier] isEqualToString: @"Check"])
    814845    {
    815         //[(NSButtonCell *)cell setImagePosition: NSImageOnly];
    816        
    817846        Torrent * torrent = [fTorrents objectAtIndex: 0];
    818847        if ([[item objectForKey: @"IsFolder"] boolValue])
     
    902931        [[NSWorkspace sharedWorkspace] selectFile: [folder stringByAppendingPathComponent:
    903932                [[fFileOutline itemAtRow: i] objectForKey: @"Path"]] inFileViewerRootedAtPath: nil];
     933}
     934
     935- (void) setCheck: (id) sender
     936{
     937    int state = sender == fFileCheckItem ? NSOnState : NSOffState;
     938   
     939    Torrent * torrent = [fTorrents objectAtIndex: 0];
     940    NSIndexSet * indexSet = [fFileOutline selectedRowIndexes];
     941    int i;
     942    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
     943        [torrent setFileCheckState: state forFileItem: [fFileOutline itemAtRow: i]];
     944   
     945    [fFileOutline reloadData];
     946}
     947
     948- (void) setPriority: (id) sender
     949{
     950    int priority;
     951    if (sender == fFilePriorityHigh)
     952        priority = PRIORITY_HIGH;
     953    else if (sender == fFilePriorityLow)
     954        priority = PRIORITY_LOW;
     955    else
     956        priority = PRIORITY_NORMAL;
     957   
     958    Torrent * torrent = [fTorrents objectAtIndex: 0];
     959    NSIndexSet * indexSet = [fFileOutline selectedRowIndexes];
     960    int i;
     961    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
     962        [torrent setFilePriority: priority forFileItem: [fFileOutline itemAtRow: i]];
     963   
     964    [fFileOutline reloadData];
    904965}
    905966
  • branches/file_selection/macosx/Torrent.m

    r2025 r2033  
    13791379- (void) setFilePriority: (int) priority forFileItem: (NSMutableDictionary *) item
    13801380{
    1381     if ([[item objectForKey: @"IsFolder"] boolValue])
    1382         return;
    1383    
    1384     [item setObject: [NSNumber numberWithInt: priority] forKey: @"Priority"];
    1385    
    1386     int index = [[item objectForKey: @"Index"] intValue];
    1387     if ([self checkForFile: index] == NSOnState)
    1388     {
    1389         tr_priority_t actualPriority;
    1390         if (priority == PRIORITY_HIGH)
    1391             actualPriority = TR_PRI_HIGH;
    1392         else if (priority == PRIORITY_LOW)
    1393             actualPriority = TR_PRI_LOW;
    1394         else
    1395             actualPriority = TR_PRI_NORMAL;
    1396         tr_torrentSetFilePriority(fHandle, index, actualPriority);
     1381    if (![[item objectForKey: @"IsFolder"] boolValue])
     1382    {
     1383        [item setObject: [NSNumber numberWithInt: priority] forKey: @"Priority"];
     1384       
     1385        int index = [[item objectForKey: @"Index"] intValue];
     1386        if ([self checkForFile: index] == NSOnState)
     1387        {
     1388            tr_priority_t actualPriority;
     1389            if (priority == PRIORITY_HIGH)
     1390                actualPriority = TR_PRI_HIGH;
     1391            else if (priority == PRIORITY_LOW)
     1392                actualPriority = TR_PRI_LOW;
     1393            else
     1394                actualPriority = TR_PRI_NORMAL;
     1395            tr_torrentSetFilePriority(fHandle, index, actualPriority);
     1396        }
     1397    }
     1398    else
     1399    {
     1400        NSEnumerator * enumerator = [[item objectForKey: @"Children"] objectEnumerator];
     1401        NSMutableDictionary * child;
     1402        while ((child = [enumerator nextObject]))
     1403            [self setFilePriority: priority forFileItem: child];
    13971404    }
    13981405}
Note: See TracChangeset for help on using the changeset viewer.