Changeset 721 for trunk/macosx


Ignore:
Timestamp:
Aug 6, 2006, 5:06:05 PM (16 years ago)
Author:
livings124
Message:

validate open menu item

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/BarButton.m

    r720 r721  
    3636- (id) initWithCoder: (NSCoder *) coder
    3737{
    38         if ((self = [super initWithCoder: coder]))
     38    if ((self = [super initWithCoder: coder]))
    3939    {
    4040        fEnabled = NO;
     
    5656        [nc addObserver: self selector: @selector(resetBounds:)
    5757                    name: NSViewBoundsDidChangeNotification object: nil];
    58         }
    59         return self;
     58    }
     59    return self;
    6060}
    6161
  • trunk/macosx/Controller.h

    r716 r721  
    4343    int                             fCompleted;
    4444   
    45     NSMutableArray                  * fTorrents, * fFilteredTorrents;
     45    NSMutableArray                  * fTorrents, * fDisplayedTorrents;
    4646   
    4747    PrefsController                 * fPrefsController;
  • trunk/macosx/Controller.m

    r720 r721  
    7070       
    7171        fTorrents = [[NSMutableArray alloc] initWithCapacity: 10];
    72         fFilteredTorrents = [[NSMutableArray alloc] initWithCapacity: 10];
     72        fDisplayedTorrents = [[NSMutableArray alloc] initWithCapacity: 10];
    7373       
    7474        fDefaults = [NSUserDefaults standardUserDefaults];
     
    8989
    9090    [fTorrents release];
    91     [fFilteredTorrents release];
     91    [fDisplayedTorrents release];
    9292   
    9393    [fToolbar release];
     
    184184    [fSpeedLimitButton setToolTip: @"Speed Limit overrides the total bandwidth limits with its own limits."];
    185185
    186     [fTableView setTorrents: fFilteredTorrents];
     186    [fTableView setTorrents: fDisplayedTorrents];
    187187    [[fTableView tableColumnWithIdentifier: @"Torrent"] setDataCell: [[TorrentCell alloc] init]];
    188188
     
    433433- (NSArray *) torrentsAtIndexes: (NSIndexSet *) indexSet
    434434{
    435     if ([fFilteredTorrents respondsToSelector: @selector(objectsAtIndexes:)])
    436         return [fFilteredTorrents objectsAtIndexes: indexSet];
     435    if ([fDisplayedTorrents respondsToSelector: @selector(objectsAtIndexes:)])
     436        return [fDisplayedTorrents objectsAtIndexes: indexSet];
    437437    else
    438438    {
     
    440440        unsigned int i;
    441441        for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    442             [torrents addObject: [fFilteredTorrents objectAtIndex: i]];
     442            [torrents addObject: [fDisplayedTorrents objectAtIndex: i]];
    443443
    444444        return torrents;
    445445    }
    446 }
    447 
    448 - (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code
    449     contextInfo: (Torrent *) torrent
    450 {
    451     if (code == NSOKButton)
    452     {
    453         [torrent setDownloadFolder: [[openPanel filenames] objectAtIndex: 0]];
    454         [torrent update];
    455         [self attemptToStartAuto: torrent];
    456        
    457         [fTorrents addObject: torrent];
    458     }
    459    
    460     [NSApp stopModal];
    461446}
    462447
     
    519504}
    520505
     506- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code
     507    contextInfo: (Torrent *) torrent
     508{
     509    if (code == NSOKButton)
     510    {
     511        [torrent setDownloadFolder: [[openPanel filenames] objectAtIndex: 0]];
     512        [torrent update];
     513        [self attemptToStartAuto: torrent];
     514       
     515        [fTorrents addObject: torrent];
     516    }
     517   
     518    [NSApp stopModal];
     519}
     520
    521521//called on by applescript
    522522- (void) open: (NSArray *) files
     
    652652            {
    653653                title = [NSString stringWithFormat: @"Comfirm Removal of \"%@\"",
    654                             [[fFilteredTorrents objectAtIndex: [fTableView selectedRow]] name]];
     654                            [[fDisplayedTorrents objectAtIndex: [fTableView selectedRow]] name]];
    655655                message = @"This transfer is active."
    656656                            " Once removed, continuing the transfer will require the torrent file."
     
    721721       
    722722        [fTorrents removeObject: torrent];
    723         [fFilteredTorrents removeObject: torrent];
     723        [fDisplayedTorrents removeObject: torrent];
    724724    }
    725725    [torrents release];
     
    834834    unsigned int i;
    835835    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    836         [[fFilteredTorrents objectAtIndex: i] revealData];
     836        [[fDisplayedTorrents objectAtIndex: i] revealData];
    837837}
    838838
     
    931931    NSArray * selectedTorrents = nil;
    932932    int numSelected = [fTableView numberOfSelectedRows];
    933     if (numSelected > 0 && numSelected < [fFilteredTorrents count])
     933    if (numSelected > 0 && numSelected < [fDisplayedTorrents count])
    934934        selectedTorrents = [self torrentsAtIndexes: [fTableView selectedRowIndexes]];
    935935
     
    943943        NSMutableIndexSet * indexSet = [[NSMutableIndexSet alloc] init];
    944944        while ((torrent = [enumerator nextObject]))
    945             [indexSet addIndex: [fFilteredTorrents indexOfObject: torrent]];
     945            [indexSet addIndex: [fDisplayedTorrents indexOfObject: torrent]];
    946946       
    947947        [fTableView selectRowIndexes: indexSet byExtendingSelection: NO];
     
    987987        descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
    988988
    989     [fFilteredTorrents sortUsingDescriptors: descriptors];
     989    [fDisplayedTorrents sortUsingDescriptors: descriptors];
    990990    [descriptors release];
    991991   
     
    11201120    }
    11211121   
    1122     [fFilteredTorrents setArray: tempTorrents];
     1122    [fDisplayedTorrents setArray: tempTorrents];
    11231123    [tempTorrents release];
    11241124   
     
    11331133        unsigned index;
    11341134        while ((torrent = [enumerator nextObject]))
    1135             if ((index = [fFilteredTorrents indexOfObject: torrent]) != NSNotFound)
     1135            if ((index = [fDisplayedTorrents indexOfObject: torrent]) != NSNotFound)
    11361136                [indexSet addIndex: index];
    11371137       
     
    11431143    NSMutableString * totalTorrentsString = [NSMutableString stringWithString: @""];
    11441144    if (filtering)
    1145         [totalTorrentsString appendFormat: @"%d/", [fFilteredTorrents count]];
     1145        [totalTorrentsString appendFormat: @"%d/", [fDisplayedTorrents count]];
    11461146   
    11471147    int totalCount = [fTorrents count];
     
    14661466- (int) numberOfRowsInTableView: (NSTableView *) t
    14671467{
    1468     return [fFilteredTorrents count];
     1468    return [fDisplayedTorrents count];
    14691469}
    14701470
     
    14721472    forTableColumn: (NSTableColumn *) tableColumn row: (int) row
    14731473{
    1474     [cell setTorrent: [fFilteredTorrents objectAtIndex: row]];
     1474    [cell setTorrent: [fDisplayedTorrents objectAtIndex: row]];
    14751475}
    14761476
     
    15111511        return NSDragOperationGeneric;
    15121512    }
    1513     else;
    1514    
    1515     return NSDragOperationNone;
     1513    else
     1514        return NSDragOperationNone;
    15161515}
    15171516
     
    15381537        NSArray * selectedTorrents = nil;
    15391538        int numSelected = [fTableView numberOfSelectedRows];
    1540         if (numSelected > 0 && numSelected < [fFilteredTorrents count])
     1539        if (numSelected > 0 && numSelected < [fDisplayedTorrents count])
    15411540            selectedTorrents = [self torrentsAtIndexes: [fTableView selectedRowIndexes]];
    15421541   
     
    15461545        //move torrent in array
    15471546        NSArray * movingTorrents = [[self torrentsAtIndexes: indexes] retain];
    1548         [fFilteredTorrents removeObjectsInArray: movingTorrents];
     1547        [fDisplayedTorrents removeObjectsInArray: movingTorrents];
    15491548       
    15501549        //determine the insertion index now that transfers to move have been removed
     
    15551554        //insert objects at new location
    15561555        for (i = 0; i < [movingTorrents count]; i++)
    1557             [fFilteredTorrents insertObject: [movingTorrents objectAtIndex: i] atIndex: newRow - decrease + i];
     1556            [fDisplayedTorrents insertObject: [movingTorrents objectAtIndex: i] atIndex: newRow - decrease + i];
    15581557       
    15591558        [movingTorrents release];
     
    15681567       
    15691568        for (i = low; i <= high; i++)
    1570             [[fFilteredTorrents objectAtIndex: i] setOrderValue: i];
     1569            [[fDisplayedTorrents objectAtIndex: i] setOrderValue: i];
    15711570       
    15721571        [fTableView reloadData];
     
    15791578            NSMutableIndexSet * indexSet = [[NSMutableIndexSet alloc] init];
    15801579            while ((torrent = [enumerator nextObject]))
    1581                 [indexSet addIndex: [fFilteredTorrents indexOfObject: torrent]];
     1580                [indexSet addIndex: [fDisplayedTorrents indexOfObject: torrent]];
    15821581           
    15831582            [fTableView selectRowIndexes: indexSet byExtendingSelection: NO];
     
    16361635- (void) showStatusBar: (BOOL) show animate: (BOOL) animate
    16371636{
    1638     if (show == ![fStatusBar isHidden])
     1637    if (show != [fStatusBar isHidden])
    16391638        return;
    16401639
     
    16971696- (void) showFilterBar: (BOOL) show animate: (BOOL) animate
    16981697{
    1699     if (show == ![fFilterBar isHidden])
     1698    if (show != [fFilterBar isHidden])
    17001699        return;
    17011700
     
    18961895       
    18971896        for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    1898             if ([[fFilteredTorrents objectAtIndex: i] isActive])
     1897            if ([[fDisplayedTorrents objectAtIndex: i] isActive])
    18991898                return YES;
    19001899        return NO;
     
    19081907       
    19091908        for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    1910             if ([[fFilteredTorrents objectAtIndex: i] isPaused])
     1909            if ([[fDisplayedTorrents objectAtIndex: i] isPaused])
    19111910                return YES;
    19121911        return NO;
     
    19221921    //only enable some items if it is in a context menu or the window is useable
    19231922    BOOL canUseMenu = [fWindow isKeyWindow] || [[[menuItem menu] title] isEqualToString: @"Context"];
     1923
     1924    //enable open items
     1925    if (action == @selector(openShowSheet:))
     1926        return [fWindow attachedSheet] == nil;
    19241927
    19251928    //enable show info
     
    19741977        for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    19751978        {
    1976             torrent = [fFilteredTorrents objectAtIndex: i];
     1979            torrent = [fDisplayedTorrents objectAtIndex: i];
    19771980            if (!warning && [torrent isActive])
    19781981            {
     
    20532056        for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    20542057        {
    2055             torrent = [fFilteredTorrents objectAtIndex: i];
     2058            torrent = [fDisplayedTorrents objectAtIndex: i];
    20562059            if ([torrent isActive])
    20572060                return YES;
     
    20722075        for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    20732076        {
    2074             torrent = [fFilteredTorrents objectAtIndex: i];
     2077            torrent = [fDisplayedTorrents objectAtIndex: i];
    20752078            if ([torrent isPaused])
    20762079                return YES;
     
    21722175    NSRect frame = [fWindow frame];
    21732176    float newHeight = frame.size.height - [fScrollView frame].size.height
    2174         + [fFilteredTorrents count] * ([fTableView rowHeight] + [fTableView intercellSpacing].height);
     2177        + [fDisplayedTorrents count] * ([fTableView rowHeight] + [fTableView intercellSpacing].height);
    21752178
    21762179    float minHeight = [fWindow minSize].height;
Note: See TracChangeset for help on using the changeset viewer.