restore ability to toggle pieces view by clicking on it

This commit is contained in:
Mitchell Livingston
2010-04-06 01:41:16 +00:00
parent 62ceb344f6
commit 909b710f04
4 changed files with 32 additions and 19 deletions
+3 -3
View File
@@ -251,11 +251,11 @@ GroupsController * fGroupsInstance = nil;
- (void) addNewGroup
{
//find the lowest index
NSMutableIndexSet * indexSet = [NSMutableIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fGroups count]+1)]; //candidates
NSMutableIndexSet * candidates = [NSMutableIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fGroups count]+1)];
for (NSDictionary * dict in fGroups)
[indexSet removeIndex: [[dict objectForKey: @"Index"] integerValue]];
[candidates removeIndex: [[dict objectForKey: @"Index"] integerValue]];
const NSInteger index = [indexSet firstIndex];
const NSInteger index = [candidates firstIndex];
[fGroups addObject: [NSMutableDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInteger: index], @"Index",
[NSColor colorWithCalibratedRed: 0.0 green: 0.65 blue: 1.0 alpha: 1.0], @"Color", @"", @"Name", nil]];
-1
View File
@@ -49,7 +49,6 @@
- (void) updateInfo;
- (void) setPiecesView: (id) sender;
- (void) setPiecesViewForAvailable: (BOOL) available;
- (void) clearView;
@end
+24 -11
View File
@@ -35,6 +35,8 @@
- (void) setupInfo;
- (void) updatePiecesView;
@end
@implementation InfoActivityViewController
@@ -49,8 +51,15 @@
return self;
}
- (void) awakeFromNib
{
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(updatePiecesView) name: @"UpdatePiecesView" object: nil];
}
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
[fTorrents release];
[super dealloc];
@@ -140,16 +149,9 @@
- (void) setPiecesView: (id) sender
{
[self setPiecesViewForAvailable: [sender selectedSegment] == PIECES_CONTROL_AVAILABLE];
}
- (void) setPiecesViewForAvailable: (BOOL) available
{
[fPiecesControl setSelected: available forSegment: PIECES_CONTROL_AVAILABLE];
[fPiecesControl setSelected: !available forSegment: PIECES_CONTROL_PROGRESS];
[[NSUserDefaults standardUserDefaults] setBool: available forKey: @"PiecesViewShowAvailability"];
[fPiecesView updateView];
const BOOL availability = [sender selectedSegment] == PIECES_CONTROL_AVAILABLE;
[[NSUserDefaults standardUserDefaults] setBool: availability forKey: @"PiecesViewShowAvailability"];
[self updatePiecesView];
}
- (void) clearView
@@ -195,14 +197,25 @@
[fDateAddedField setObjectValue: [torrent dateAdded]];
BOOL piecesAvailableSegment = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
const BOOL piecesAvailableSegment = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
[fPiecesControl setSelected: piecesAvailableSegment forSegment: PIECES_CONTROL_AVAILABLE];
[fPiecesControl setSelected: !piecesAvailableSegment forSegment: PIECES_CONTROL_PROGRESS];
[fPiecesControl setEnabled: YES];
[fPiecesView setTorrent: torrent];
}
fSet = YES;
}
- (void) updatePiecesView
{
const BOOL piecesAvailableSegment = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
[fPiecesControl setSelected: piecesAvailableSegment forSegment: PIECES_CONTROL_AVAILABLE];
[fPiecesControl setSelected: !piecesAvailableSegment forSegment: PIECES_CONTROL_PROGRESS];
[fPiecesView updateView];
}
@end
+5 -4
View File
@@ -209,10 +209,11 @@ enum
- (void) mouseDown: (NSEvent *) event
{
#warning fix
/*if (fTorrent)
[[[self window] windowController] setPiecesViewForAvailable:
![[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"]];*/
const BOOL availability = ![[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
[[NSUserDefaults standardUserDefaults] setBool: availability forKey: @"PiecesViewShowAvailability"];
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdatePiecesView" object: self];
[super mouseDown: event];
}