Changeset 10448


Ignore:
Timestamp:
Apr 6, 2010, 1:41:16 AM (12 years ago)
Author:
livings124
Message:

restore ability to toggle pieces view by clicking on it

Location:
trunk/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/GroupsController.m

    r10446 r10448  
    252252{
    253253    //find the lowest index
    254     NSMutableIndexSet * indexSet = [NSMutableIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fGroups count]+1)]; //candidates
     254    NSMutableIndexSet * candidates = [NSMutableIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fGroups count]+1)];
    255255    for (NSDictionary * dict in fGroups)
    256         [indexSet removeIndex: [[dict objectForKey: @"Index"] integerValue]];
    257    
    258     const NSInteger index = [indexSet firstIndex];
     256        [candidates removeIndex: [[dict objectForKey: @"Index"] integerValue]];
     257   
     258    const NSInteger index = [candidates firstIndex];
    259259   
    260260    [fGroups addObject: [NSMutableDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInteger: index], @"Index",
  • trunk/macosx/InfoActivityViewController.h

    r10389 r10448  
    5050
    5151- (void) setPiecesView: (id) sender;
    52 - (void) setPiecesViewForAvailable: (BOOL) available;
    5352- (void) clearView;
    5453
  • trunk/macosx/InfoActivityViewController.m

    r10389 r10448  
    3636- (void) setupInfo;
    3737
     38- (void) updatePiecesView;
     39
    3840@end
    3941
     
    5052}
    5153
     54- (void) awakeFromNib
     55{
     56    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(updatePiecesView) name: @"UpdatePiecesView" object: nil];
     57}
     58
    5259- (void) dealloc
    5360{
     61    [[NSNotificationCenter defaultCenter] removeObserver: self];
     62   
    5463    [fTorrents release];
    5564   
     
    141150- (void) setPiecesView: (id) sender
    142151{
    143     [self setPiecesViewForAvailable: [sender selectedSegment] == PIECES_CONTROL_AVAILABLE];
    144 }
    145 
    146 - (void) setPiecesViewForAvailable: (BOOL) available
    147 {
    148     [fPiecesControl setSelected: available forSegment: PIECES_CONTROL_AVAILABLE];
    149     [fPiecesControl setSelected: !available forSegment: PIECES_CONTROL_PROGRESS];
    150    
    151     [[NSUserDefaults standardUserDefaults] setBool: available forKey: @"PiecesViewShowAvailability"];
    152     [fPiecesView updateView];
     152    const BOOL availability = [sender selectedSegment] == PIECES_CONTROL_AVAILABLE;
     153    [[NSUserDefaults standardUserDefaults] setBool: availability forKey: @"PiecesViewShowAvailability"];
     154    [self updatePiecesView];
    153155}
    154156
     
    196198        [fDateAddedField setObjectValue: [torrent dateAdded]];
    197199       
    198         BOOL piecesAvailableSegment = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
     200        const BOOL piecesAvailableSegment = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
    199201        [fPiecesControl setSelected: piecesAvailableSegment forSegment: PIECES_CONTROL_AVAILABLE];
    200202        [fPiecesControl setSelected: !piecesAvailableSegment forSegment: PIECES_CONTROL_PROGRESS];
    201203        [fPiecesControl setEnabled: YES];
     204       
    202205        [fPiecesView setTorrent: torrent];
    203206    }
     
    206209}
    207210
     211- (void) updatePiecesView
     212{
     213    const BOOL piecesAvailableSegment = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
     214   
     215    [fPiecesControl setSelected: piecesAvailableSegment forSegment: PIECES_CONTROL_AVAILABLE];
     216    [fPiecesControl setSelected: !piecesAvailableSegment forSegment: PIECES_CONTROL_PROGRESS];
     217   
     218    [fPiecesView updateView];
     219}
     220
    208221@end
  • trunk/macosx/PiecesView.m

    r10309 r10448  
    210210- (void) mouseDown: (NSEvent *) event
    211211{
    212     #warning fix
    213     /*if (fTorrent)
    214         [[[self window] windowController] setPiecesViewForAvailable:
    215             ![[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"]];*/
     212    const BOOL availability = ![[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
     213    [[NSUserDefaults standardUserDefaults] setBool: availability forKey: @"PiecesViewShowAvailability"];
     214   
     215    [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdatePiecesView" object: self];
     216   
    216217    [super mouseDown: event];
    217218}
Note: See TracChangeset for help on using the changeset viewer.