Changeset 155


Ignore:
Timestamp:
Mar 15, 2006, 12:05:22 AM (16 years ago)
Author:
titer
Message:

Fixes pause/resume button, adds a more standard way of clicking items
in the table view (rows are selected on mouse down rather than up), and
makes it so that pause and reveal require to be clicked down on and
released on rather than just released on

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_api/macosx/TorrentTableView.m

    r151 r155  
    3434- (void) pauseOrResume: (int) row
    3535{
    36 #if 0
    37     if( fStat[row].status & TR_STATUS_PAUSE )
     36    Torrent * torrent = [fTorrents objectAtIndex: row];
     37
     38    if( [torrent isPaused] )
    3839    {
    3940        [fController resumeTorrentWithIndex: row];
    4041    }
    41     else if( fStat[row].status & ( TR_STATUS_CHECK |
    42               TR_STATUS_DOWNLOAD | TR_STATUS_SEED ) )
     42    else if( [torrent isActive] )
    4343    {
    4444        [fController stopTorrentWithIndex: row];
    45     }                                                                   
    46 #endif
    47 }
    48 
    49 - (void) mouseDown: (NSEvent *) e
    50 {
    51     fClickPoint = [self convertPoint: [e locationInWindow] fromView: NULL];
    52     [self display];
     45    }
     46    else;
    5347}
    5448
     
    9185}
    9286
     87
     88- (void) mouseDown: (NSEvent *) e
     89{
     90    fClickPoint = [self convertPoint: [e locationInWindow] fromView: nil];
     91    int row = [self rowAtPoint: fClickPoint];
     92
     93    if( [e modifierFlags] & NSAlternateKeyMask )
     94    {
     95        [fController advancedChanged: self];
     96        fClickPoint = NSMakePoint( 0, 0 );
     97    }
     98    else if( ![self pointInPauseRect: fClickPoint] &&
     99             ![self pointInRevealRect: fClickPoint] )
     100    {
     101        if( row >= 0 )
     102        {
     103            [self selectRowIndexes: [NSIndexSet indexSetWithIndex: row]
     104                byExtendingSelection: NO];
     105        }
     106        else
     107        {
     108            [self deselectAll: self];
     109        }
     110    }
     111    else;
     112
     113    [self display];
     114}
     115
    93116- (void) mouseUp: (NSEvent *) e
    94117{
    95118    NSPoint point;
    96     int row, col;
     119    int row;
     120    bool sameRow;
    97121    Torrent * torrent;
    98122
    99     point = [self convertPoint: [e locationInWindow] fromView: NULL];
     123    point = [self convertPoint: [e locationInWindow] fromView: nil];
    100124    row   = [self rowAtPoint: point];
    101     col   = [self columnAtPoint: point];
    102 
    103     if( row < 0 )
    104     {
    105         [self deselectAll: NULL];
    106     }
    107     else if( [self pointInPauseRect: point] )
     125    sameRow = row == [self rowAtPoint: fClickPoint];
     126   
     127    if( sameRow && [self pointInPauseRect: point]
     128            && [self pointInPauseRect: fClickPoint] )
    108129    {
    109130        [self pauseOrResume: row];
    110131    }
    111     else if( [self pointInRevealRect: point] )
     132    else if( sameRow && [self pointInRevealRect: point]
     133                && [self pointInRevealRect: fClickPoint] )
    112134    {
    113135        torrent = [fTorrents objectAtIndex: row];
    114136        [torrent reveal];
    115         [self display];
    116     }
    117     else if( row >= 0 && ( [e modifierFlags] & NSAlternateKeyMask ) )
    118     {
    119         [fController advancedChanged: self];
    120     }
    121     else
     137    }
     138    else;
     139
     140    [self display];
     141    fClickPoint = NSMakePoint( 0, 0 );
     142}
     143
     144- (NSMenu *) menuForEvent: (NSEvent *) e
     145{
     146    NSPoint point;
     147    int row;
     148
     149    point = [self convertPoint: [e locationInWindow] fromView: nil];
     150    row = [self rowAtPoint: point];
     151   
     152    if( row >= 0 )
    122153    {
    123154        [self selectRowIndexes: [NSIndexSet indexSetWithIndex: row]
    124155            byExtendingSelection: NO];
    125     }
    126 
    127     fClickPoint = NSMakePoint( 0, 0 );
    128 }
    129 
    130 - (NSMenu *) menuForEvent: (NSEvent *) e
    131 {
    132     NSPoint point;
    133     int row;
    134 
    135     point = [self convertPoint: [e locationInWindow] fromView: NULL];
    136     row = [self rowAtPoint: point];
    137    
    138     [self selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
    139 
    140     return row >= 0 ? fContextRow : fContextNoRow;
     156        return fContextRow;
     157    }
     158    else
     159    {
     160        [self deselectAll: self];
     161        return fContextNoRow;
     162    }
    141163}
    142164
    143165- (void) drawRect: (NSRect) r
    144166{
    145     int i;
     167    unsigned i;
    146168    NSRect rect;
    147     NSPoint point;
    148169    NSImage * image;
     170    Torrent * torrent;
    149171
    150172    [super drawRect: r];
    151173
    152     for( i = 0; i < [self numberOfRows]; i++ )
    153     {
     174    for( i = 0; i < [fTorrents count]; i++ )
     175    {
     176        torrent = [fTorrents objectAtIndex: i];
    154177        rect  = [self pauseRectForRow: i];
    155         image = NULL;
    156 #if 0
    157         if( fStat[i].status & TR_STATUS_PAUSE )
    158         {
    159 #endif
     178        image = nil;
     179
     180        if( [torrent isPaused] )
     181        {
    160182            image = NSPointInRect( fClickPoint, rect ) ?
    161183                [NSImage imageNamed: @"ResumeOn.png"] :
    162184                [NSImage imageNamed: @"ResumeOff.png"];
    163 #if 0
    164         }
    165         else if( fStat[i].status &
    166                  ( TR_STATUS_CHECK | TR_STATUS_DOWNLOAD | TR_STATUS_SEED ) )
     185        }
     186        else if( [torrent isActive] )
    167187        {
    168188            image = NSPointInRect( fClickPoint, rect ) ?
     
    170190                [NSImage imageNamed: @"PauseOff.png"];
    171191        }
    172 #endif
     192        else;
     193
    173194        if( image )
    174195        {
Note: See TracChangeset for help on using the changeset viewer.