Changeset 13602


Ignore:
Timestamp:
Oct 30, 2012, 12:22:10 AM (9 years ago)
Author:
livings124
Message:

#2794 Don't apply auto-grouping until torrent is demagnetized

Location:
trunk/macosx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/AddMagnetWindowController.h

    r13479 r13602  
    2424
    2525#import <Cocoa/Cocoa.h>
     26#import "Torrent.h"
    2627
    2728@class Controller;
     
    4849   
    4950    NSInteger fGroupValue;
     51    TorrentDeterminationType fGroupDeterminationType;
    5052}
    5153
  • trunk/macosx/AddMagnetWindowController.m

    r13601 r13602  
    3838- (void) confirmAdd;
    3939
    40 - (void) setDestinationPath: (NSString *) destination;
     40- (void) setDestinationPath: (NSString *) destination determinationType: (TorrentDeterminationType) determinationType;
    4141
    4242- (void) setGroupsMenu;
     
    5959       
    6060        fGroupValue = [torrent groupValue];
     61        fGroupDeterminationType = TorrentDeterminationAutomatic;
    6162    }
    6263    return self;
     
    8990   
    9091    if (fDestination)
    91         [self setDestinationPath: fDestination];
     92        [self setDestinationPath: fDestination determinationType: TorrentDeterminationAutomatic];
    9293    else
    9394    {
     
    190191    [panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
    191192        if (result == NSFileHandlingPanelOKButton)
    192             [self setDestinationPath: [[[panel URLs] objectAtIndex: 0] path]];
     193            [self setDestinationPath: [[[panel URLs] objectAtIndex: 0] path] determinationType:TorrentDeterminationUserSpecified];
    193194        else
    194195        {
     
    252253    {
    253254        fGroupValue = -1;
     255                fGroupDeterminationType = TorrentDeterminationAutomatic;
    254256        [fGroupPopUp selectItemWithTag: fGroupValue];
    255257    }
     
    262264- (void) confirmAdd
    263265{
    264     [fTorrent setGroupValue: fGroupValue];
     266    [fTorrent setGroupValue: fGroupValue determinationType: fGroupDeterminationType];
    265267   
    266268    if ([fStartCheck state] == NSOnState)
     
    271273}
    272274
    273 - (void) setDestinationPath: (NSString *) destination
     275- (void) setDestinationPath: (NSString *) destination determinationType: (TorrentDeterminationType) determinationType
    274276{
    275277    destination = [destination stringByExpandingTildeInPath];
     
    279281        fDestination = [destination retain];
    280282       
    281         [fTorrent changeDownloadFolderBeforeUsing: fDestination];
     283        [fTorrent changeDownloadFolderBeforeUsing: fDestination determinationType: determinationType];
    282284    }
    283285   
     
    299301{
    300302    NSInteger previousGroup = fGroupValue;
    301     fGroupValue = [sender tag];
    302    
     303    fGroupValue = [sender tag];
     304    fGroupDeterminationType = TorrentDeterminationUserSpecified;
     305
    303306    if ([[GroupsController groups] usesCustomDownloadLocationForIndex: fGroupValue])
    304         [self setDestinationPath: [[GroupsController groups] customDownloadLocationForIndex: fGroupValue]];
     307        [self setDestinationPath: [[GroupsController groups] customDownloadLocationForIndex: fGroupValue] determinationType: TorrentDeterminationAutomatic];
    305308    else if ([fDestination isEqualToString: [[GroupsController groups] customDownloadLocationForIndex: previousGroup]])
    306         [self setDestinationPath: [[NSUserDefaults standardUserDefaults] stringForKey: @"DownloadFolder"]];
     309        [self setDestinationPath: [[NSUserDefaults standardUserDefaults] stringForKey: @"DownloadFolder"] determinationType: TorrentDeterminationAutomatic];
    307310    else;
    308311}
  • trunk/macosx/AddWindowController.h

    r13416 r13602  
    2424
    2525#import <Cocoa/Cocoa.h>
     26#import "Torrent.h"
    2627
    2728@class Controller;
     
    5354   
    5455    NSTimer * fTimer;
     56       
     57    TorrentDeterminationType fGroupValueDetermination;
    5558}
    5659
  • trunk/macosx/AddWindowController.m

    r13492 r13602  
    4343- (void) confirmAdd;
    4444
    45 - (void) setDestinationPath: (NSString *) destination;
     45- (void) setDestinationPath: (NSString *) destination determinationType: (TorrentDeterminationType) determinationType;
    4646
    4747- (void) setGroupsMenu;
     
    7272       
    7373        fGroupValue = [torrent groupValue];
    74        
     74        fGroupValueDetermination = TorrentDeterminationAutomatic;
     75
    7576        [fVerifyIndicator setUsesThreadedAnimation: YES];
    7677    }
     
    127128   
    128129    if (fDestination)
    129         [self setDestinationPath: fDestination];
     130        [self setDestinationPath: fDestination determinationType: (fLockDestination ? TorrentDeterminationUserSpecified : TorrentDeterminationAutomatic)];
    130131    else
    131132    {
     
    180181        if (result == NSFileHandlingPanelOKButton)
    181182        {
    182             fLockDestination = NO;
    183             [self setDestinationPath: [[[panel URLs] objectAtIndex: 0] path]];
     183            fLockDestination = YES;
     184            [self setDestinationPath: [[[panel URLs] objectAtIndex: 0] path] determinationType: TorrentDeterminationUserSpecified];
    184185        }
    185186        else
     
    300301    {
    301302        fGroupValue = -1;
     303                fGroupValueDetermination = TorrentDeterminationAutomatic;
    302304        [fGroupPopUp selectItemWithTag: fGroupValue];
    303305    }
     
    336338    [fTimer release];
    337339    fTimer = nil;
    338     [fTorrent setGroupValue: fGroupValue];
    339    
     340    [fTorrent setGroupValue: fGroupValue  determinationType: fGroupValueDetermination];
     341
    340342    if (fTorrentFile && fCanToggleDelete && [fDeleteCheck state] == NSOnState)
    341343        [Torrent trashFile: fTorrentFile];
     
    350352}
    351353
    352 - (void) setDestinationPath: (NSString *) destination
     354- (void) setDestinationPath: (NSString *) destination determinationType: (TorrentDeterminationType) determinationType
    353355{
    354356    destination = [destination stringByExpandingTildeInPath];
     
    358360        fDestination = [destination retain];
    359361       
    360         [fTorrent changeDownloadFolderBeforeUsing: fDestination];
     362        [fTorrent changeDownloadFolderBeforeUsing: fDestination determinationType: determinationType];
    361363    }
    362364   
     
    379381    NSInteger previousGroup = fGroupValue;
    380382    fGroupValue = [sender tag];
    381    
     383    fGroupValueDetermination = TorrentDeterminationUserSpecified;
     384
    382385    if (!fLockDestination)
    383386    {
    384387        if ([[GroupsController groups] usesCustomDownloadLocationForIndex: fGroupValue])
    385             [self setDestinationPath: [[GroupsController groups] customDownloadLocationForIndex: fGroupValue]];
     388            [self setDestinationPath: [[GroupsController groups] customDownloadLocationForIndex: fGroupValue] determinationType: TorrentDeterminationAutomatic];
    386389        else if ([fDestination isEqualToString: [[GroupsController groups] customDownloadLocationForIndex: previousGroup]])
    387             [self setDestinationPath: [[NSUserDefaults standardUserDefaults] stringForKey: @"DownloadFolder"]];
     390            [self setDestinationPath: [[NSUserDefaults standardUserDefaults] stringForKey: @"DownloadFolder"] determinationType: TorrentDeterminationAutomatic];
    388391        else;
    389392    }
  • trunk/macosx/Controller.m

    r13578 r13602  
    533533                    name: @"TorrentFinishedSeeding" object: nil];
    534534   
     535    [nc addObserver: self selector: @selector(applyFilter)
     536                    name: kTorrentDidChangeGroupNotification object: nil];
     537   
    535538    //avoids need of setting delegate
    536539    [nc addObserver: self selector: @selector(torrentTableViewSelectionDidChange:)
     
    947950        {
    948951            location = [[GroupsController groups] customDownloadLocationForIndex: [torrent groupValue]];
    949             [torrent changeDownloadFolderBeforeUsing: location];
     952            [torrent changeDownloadFolderBeforeUsing: location determinationType: TorrentDeterminationAutomatic];
    950953        }
    951954       
     
    10441047    {
    10451048        location = [[GroupsController groups] customDownloadLocationForIndex: [torrent groupValue]];
    1046         [torrent changeDownloadFolderBeforeUsing: location];
     1049        [torrent changeDownloadFolderBeforeUsing: location determinationType: TorrentDeterminationAutomatic];
    10471050    }
    10481051   
     
    28482851        [fTableView removeCollapsedGroup: [torrent groupValue]]; //remove old collapsed group
    28492852       
    2850         [torrent setGroupValue: [(NSMenuItem *)sender tag]];
     2853        [torrent setGroupValue: [(NSMenuItem *)sender tag] determinationType: TorrentDeterminationUserSpecified];
    28512854    }
    28522855   
     
    31973200            //change groups
    31983201            if (item)
    3199                 [torrent setGroupValue: [item groupIndex]];
     3202                [torrent setGroupValue: [item groupIndex] determinationType: TorrentDeterminationUserSpecified];
    32003203        }
    32013204       
     
    47874790    {
    47884791        location = [[GroupsController groups] customDownloadLocationForIndex: [torrent groupValue]];
    4789         [torrent changeDownloadFolderBeforeUsing: location];
     4792        [torrent changeDownloadFolderBeforeUsing: location determinationType: TorrentDeterminationAutomatic];
    47904793    }
    47914794   
  • trunk/macosx/Torrent.h

    r13419 r13602  
    2929@class FileListNode;
    3030
     31typedef enum {
     32        TorrentDeterminationAutomatic = 0,
     33        TorrentDeterminationUserSpecified
     34} TorrentDeterminationType;
     35
     36#define kTorrentDidChangeGroupNotification @"TorrentDidChangeGroup"
     37
    3138@interface Torrent : NSObject <NSCopying, QLPreviewItem>
    3239{
     
    5057   
    5158    NSInteger fGroupValue;
     59        TorrentDeterminationType fGroupValueDetermination;
     60       
     61        TorrentDeterminationType fDownloadFolderDetermination;
    5262   
    5363    BOOL fResumeOnWake;
     
    6676- (void) closeRemoveTorrent: (BOOL) trashFiles;
    6777
    68 - (void) changeDownloadFolderBeforeUsing: (NSString *) folder;
     78- (void) changeDownloadFolderBeforeUsing: (NSString *) folder determinationType: (TorrentDeterminationType) determinationType;
    6979
    7080- (NSString *) currentDirectory;
     
    207217
    208218- (NSInteger) groupValue;
    209 - (void) setGroupValue: (NSInteger) groupValue;
     219- (void) setGroupValue: (NSInteger) groupValue determinationType: (TorrentDeterminationType) determinationType;;
    210220- (NSInteger) groupOrderValue;
    211221- (void) checkGroupValueForRemoval: (NSNotification *) notification;
  • trunk/macosx/Torrent.m

    r13434 r13602  
    243243}
    244244
    245 - (void) changeDownloadFolderBeforeUsing: (NSString *) folder
     245- (void) changeDownloadFolderBeforeUsing: (NSString *) folder determinationType: (TorrentDeterminationType) determinationType
    246246{
    247247    //if data existed in original download location, unexclude it before changing the location
     
    249249   
    250250    tr_torrentSetDownloadDir(fHandle, [folder UTF8String]);
     251       
     252    fDownloadFolderDetermination = determinationType;
    251253}
    252254
     
    645647        if (stats[i].tier != prevTier)
    646648        {
    647             [trackers addObject: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInteger: stats[i].tier + 1], @"Tier",
    648                                     [self name], @"Name", nil]];
     649            [trackers addObject: @{ @"Tier" : @(stats[i].tier + 1), @"Name" : [self name] }];
    649650            prevTier = stats[i].tier;
    650651        }
     
    13121313}
    13131314
    1314 - (void) setGroupValue: (NSInteger) goupValue
    1315 {
    1316     fGroupValue = goupValue;
     1315- (void) setGroupValue: (NSInteger) groupValue determinationType: (TorrentDeterminationType) determinationType;
     1316{
     1317    if (groupValue != fGroupValue)
     1318    {
     1319        fGroupValue = groupValue;
     1320        [[NSNotificationCenter defaultCenter] postNotificationName: kTorrentDidChangeGroupNotification object: self];
     1321        }
     1322    fGroupValueDetermination = determinationType;
    13171323}
    13181324
     
    16501656        [self createFileList];
    16511657       
    1652     fGroupValue = groupValue ? [groupValue intValue] : [[GroupsController groups] groupIndexForTorrent: self];
     1658    fDownloadFolderDetermination = TorrentDeterminationAutomatic;
     1659   
     1660    if (groupValue)
     1661    {
     1662        fGroupValueDetermination = TorrentDeterminationUserSpecified;
     1663        fGroupValue = [groupValue intValue];
     1664    }
     1665    else
     1666    {
     1667        fGroupValueDetermination = TorrentDeterminationAutomatic;
     1668        fGroupValue = [[GroupsController groups] groupIndexForTorrent: self];
     1669    }
    16531670   
    16541671    fRemoveWhenFinishSeeding = removeWhenFinishSeeding ? [removeWhenFinishSeeding boolValue] : [fDefaults boolForKey: @"RemoveWhenFinishSeeding"];
     
    18451862{
    18461863    fStat = tr_torrentStat(fHandle);
    1847    
     1864
    18481865    [self createFileList];
     1866   
     1867    /* If the torrent is in no group, or the group was automatically determined based on criteria evaluated
     1868     * before we had metadata for this torrent, redetermine the group
     1869     */
     1870    if ((fGroupValueDetermination == TorrentDeterminationAutomatic) || ([self groupValue] == -1))
     1871        [self setGroupValue: [[GroupsController groups] groupIndexForTorrent: self] determinationType: TorrentDeterminationAutomatic];
     1872   
     1873    //change the location if the group calls for it and it's either not already set or was set automatically before
     1874    if (((fDownloadFolderDetermination == TorrentDeterminationAutomatic) || !tr_torrentGetCurrentDir(fHandle)) &&
     1875        [[GroupsController groups] usesCustomDownloadLocationForIndex: [self groupValue]])
     1876    {
     1877        NSString *location = [[GroupsController groups] customDownloadLocationForIndex: [self groupValue]];
     1878        [self changeDownloadFolderBeforeUsing: location determinationType:TorrentDeterminationAutomatic];
     1879    }
    18491880   
    18501881    [[NSNotificationCenter defaultCenter] postNotificationName: @"ResetInspector" object: self];
Note: See TracChangeset for help on using the changeset viewer.