Ignore:
Timestamp:
May 20, 2012, 12:19:55 AM (10 years ago)
Author:
livings124
Message:

#4912 Filter and check all/uncheck all in Add Transfer window

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/AddWindowController.m

    r13251 r13309  
    8080- (void) awakeFromNib
    8181{
    82     [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(updateStatusField:)
    83         name: @"TorrentFileCheckChange" object: fTorrent];
    84    
    85     [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(updateGroupMenu:)
    86         name: @"UpdateGroups" object: nil];
     82    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(updateCheckButtons:) name: @"TorrentFileCheckChange" object: fTorrent];
     83   
     84    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(updateGroupMenu:) name: @"UpdateGroups" object: nil];
    8785   
    8886    [fFileController setTorrent: fTorrent];
     
    9593    [fIconView setImage: [fTorrent icon]];
    9694   
    97     [self updateStatusField: nil];
     95    [fFileFilterField setEnabled: [fTorrent isFolder]];
     96   
     97    [self updateCheckButtons: nil];
    9898   
    9999    [self setGroupsMenu];
     
    218218}
    219219
     220- (void) setFileFilterText: (id) sender
     221{
     222    [fFileController setFilterText: [sender stringValue]];
     223}
     224
     225- (IBAction) checkAll: (id) sender
     226{
     227    [fFileController checkAll];
     228}
     229
     230- (IBAction) uncheckAll: (id) sender
     231{
     232    [fFileController uncheckAll];
     233}
     234
    220235- (void) verifyLocalData: (id) sender
    221236{
     
    237252}
    238253
    239 - (void) updateStatusField: (NSNotification *) notification
     254- (void) updateCheckButtons: (NSNotification *) notification
    240255{
    241256    NSString * statusString = [NSString stringForFileSize: [fTorrent size]];
    242257    if ([fTorrent isFolder])
    243258    {
     259        //check buttons
     260        //keep synced with identical code in InfoFileViewController.m
     261        const NSInteger filesCheckState = [fTorrent checkForFiles: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fTorrent fileCount])]];
     262        [fCheckAllButton setEnabled: filesCheckState != NSOnState]; //if anything is unchecked
     263        [fUncheckAllButton setEnabled: ![fTorrent allDownloaded]]; //if there are any checked files that aren't finished
     264       
     265        //status field
    244266        NSString * fileString;
    245267        NSInteger count = [fTorrent fileCount];
     
    279301    [fFileController refresh];
    280302   
     303    [self updateCheckButtons: nil]; //call in case button state changed by checking
     304   
    281305    if ([fTorrent isChecking])
    282306    {
Note: See TracChangeset for help on using the changeset viewer.