Changeset 153


Ignore:
Timestamp:
Mar 14, 2006, 11:43:16 PM (16 years ago)
Author:
titer
Message:

Simplifies removing torrents code

File:
1 edited

Legend:

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

    r151 r153  
    460460    Torrent * torrent = [fTorrents objectAtIndex: idx];
    461461
    462     if( [torrent isActive] )
    463     {
    464         if ([fDefaults boolForKey: @"CheckRemove"])
    465         {
    466             NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys:
    467                         [NSString stringWithFormat: @"%d", idx], @"Index",
    468                         [NSString stringWithFormat: @"%d", deleteTorrent], @"DeleteTorrent",
    469                         [NSString stringWithFormat: @"%d", deleteData], @"DeleteData",
    470                         nil];
    471             [dict retain];
    472 
    473             NSBeginAlertSheet(@"Confirm Remove",
    474                                 @"Remove", @"Cancel", nil,
    475                                 fWindow, self,
    476                                 @selector(removeSheetDidEnd:returnCode:contextInfo:),
    477                                 NULL, dict, @"This torrent is active. Do you really want to remove it?");
    478             return;
    479         }
    480         //stop if not stopped
    481         else
    482             [self stopTorrentWithIndex:idx];
    483     }
    484 
    485     [self confirmRemoveTorrentWithIndex: idx
    486             deleteTorrent: deleteTorrent
    487             deleteData: deleteData];
     462    if( [torrent isActive] && [fDefaults boolForKey: @"CheckRemove"] )
     463    {
     464        NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys:
     465            [NSString stringWithFormat: @"%d", idx], @"Index",
     466            [NSString stringWithFormat: @"%d", deleteTorrent], @"DeleteTorrent",
     467            [NSString stringWithFormat: @"%d", deleteData], @"DeleteData",
     468            nil];
     469        [dict retain];
     470
     471        NSBeginAlertSheet(@"Confirm Remove",
     472            @"Remove", @"Cancel", nil, fWindow, self,
     473            @selector(removeSheetDidEnd:returnCode:contextInfo:),  NULL, dict,
     474            @"This torrent is active. Do you really want to remove it?");
     475    }
     476    else
     477    {
     478        [self confirmRemoveTorrentWithIndex: idx
     479                deleteTorrent: deleteTorrent
     480                deleteData: deleteData];
     481    }
    488482}
    489483
     
    492486{
    493487    [NSApp stopModal];
    494     if (returnCode != NSAlertDefaultReturn)
    495     {
    496         [dict release];
    497         return;
    498     }
    499 
    500     int idx = [[dict objectForKey:@"Index"] intValue];
    501 
    502     [self stopTorrentWithIndex:idx];
    503 
    504     [self confirmRemoveTorrentWithIndex: idx
    505         deleteTorrent: [[dict objectForKey:@"DeleteTorrent"] intValue]
    506         deleteData: [[dict objectForKey:@"DeleteData"] intValue]];
     488
     489    if( returnCode == NSAlertDefaultReturn )
     490    {
     491        int idx = [[dict objectForKey:@"Index"] intValue];
     492
     493        [self confirmRemoveTorrentWithIndex: idx
     494            deleteTorrent: [[dict objectForKey:@"DeleteTorrent"] intValue]
     495            deleteData: [[dict objectForKey:@"DeleteData"] intValue]];
     496    }
     497
    507498    [dict release];
    508499}
     
    512503            deleteData: (BOOL) deleteData
    513504{
     505    /* Pause if not paused already */
     506    [self stopTorrentWithIndex:idx];
     507
    514508#if 0
    515509    if( deleteData )
Note: See TracChangeset for help on using the changeset viewer.