Ignore:
Timestamp:
Jun 25, 2007, 10:26:33 PM (15 years ago)
Author:
livings124
Message:

fix #233 (move menu item applies to all items)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r2188 r2198  
    11841184- (void) moveDataFiles: (id) sender
    11851185{
    1186     [self moveDataFileForTorrents: [[NSMutableArray alloc] initWithArray:
    1187             [fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]]]];
    1188 }
    1189 
    1190 - (void) moveDataFileForTorrents: (NSMutableArray *) torrents
    1191 {
    1192     if ([torrents count] <= 0)
    1193     {
    1194         [torrents release];
    1195         return;
    1196     }
    1197 
    1198     Torrent * torrent = [torrents objectAtIndex: 0];
    1199 
    12001186    NSOpenPanel * panel = [NSOpenPanel openPanel];
    1201    
    12021187    [panel setPrompt: NSLocalizedString(@"Select", "Move torrent -> prompt")];
    12031188    [panel setAllowsMultipleSelection: NO];
     
    12051190    [panel setCanChooseDirectories: YES];
    12061191    [panel setCanCreateDirectories: YES];
    1207 
    1208     [panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the new folder for \"%@\"",
    1209                         "Move torrent -> select destination folder"), [torrent name]]];
    1210        
    1211     [panel beginSheetForDirectory: nil file: [torrent name] modalForWindow: fWindow modalDelegate: self
     1192   
     1193    NSArray * torrents = [[fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]] retain];
     1194    int count = [torrents count];
     1195    if (count == 1)
     1196        [panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the new folder for \"%@\".",
     1197                            "Move torrent -> select destination folder"), [[torrents objectAtIndex: 0] name]]];
     1198    else
     1199        [panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the new folder for %d data files.",
     1200                            "Move torrent -> select destination folder"), count]];
     1201       
     1202    [panel beginSheetForDirectory: nil file: nil modalForWindow: fWindow modalDelegate: self
    12121203        didEndSelector: @selector(moveDataFileChoiceClosed:returnCode:contextInfo:) contextInfo: torrents];
    12131204}
    12141205
    1215 - (void) moveDataFileChoiceClosed: (NSOpenPanel *) panel returnCode: (int) code contextInfo: (NSMutableArray *) torrents
    1216 {
    1217     //move torrent data file to new location
     1206- (void) moveDataFileChoiceClosed: (NSOpenPanel *) panel returnCode: (int) code contextInfo: (NSArray *) torrents
     1207{
    12181208    if (code == NSOKButton)
    1219         [[torrents objectAtIndex: 0] moveTorrentDataFileTo: [[panel filenames] objectAtIndex: 0]];
    1220    
    1221     [torrents removeObjectAtIndex: 0];
    1222     [self performSelectorOnMainThread: @selector(moveDataFileForTorrents:) withObject: torrents waitUntilDone: NO];
     1209    {
     1210        //move torrent data file to new location
     1211        NSEnumerator * enumerator = [torrents objectEnumerator];
     1212        Torrent * torrent;
     1213        while ((torrent = [enumerator nextObject]))
     1214            [torrent moveTorrentDataFileTo: [[panel filenames] objectAtIndex: 0]];
     1215    }
     1216   
     1217    [torrents release];
    12231218}
    12241219
Note: See TracChangeset for help on using the changeset viewer.