cleaned up the pieces view segment control code a bit, and clicking the view will toggle it

This commit is contained in:
Mitchell Livingston 2007-06-21 23:21:19 +00:00
parent f1a2fe0218
commit 6d55430138
5 changed files with 35 additions and 8 deletions

View File

@ -7,7 +7,7 @@
<key>IBEditorPositions</key>
<dict>
<key>549</key>
<string>565 283 144 118 0 0 1152 842 </string>
<string>565 283 174 149 0 0 1152 842 </string>
</dict>
<key>IBFramework Version</key>
<string>446.1</string>
@ -21,7 +21,6 @@
</array>
<key>IBOpenObjects</key>
<array>
<integer>549</integer>
<integer>5</integer>
</array>
<key>IBSystem Version</key>

View File

@ -73,6 +73,7 @@
- (void) setPreviousTab;
- (void) setPiecesView: (id) sender;
- (void) setPiecesViewForAvailable: (BOOL) available;
- (void) revealTorrentFile: (id) sender;
- (void) revealDataFile: (id) sender;

View File

@ -100,10 +100,6 @@
[fTabView selectTabViewItemWithIdentifier: identifier];
[self setWindowForTab: identifier animate: NO];
//set pieces control
[fPiecesControl setSelectedSegment: [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"]
? PIECES_CONTROL_AVAILABLE : PIECES_CONTROL_PROGRESS];
//initially sort peer table by IP
if ([[fPeerTable sortDescriptors] count] == 0)
[fPeerTable setSortDescriptors: [NSArray arrayWithObject: [[fPeerTable tableColumnWithIdentifier: @"IP"]
@ -223,6 +219,11 @@
[fPiecesControl setEnabled: NO];
[fPiecesView setTorrent: nil];
[fPiecesControl setSelected: NO forSegment: PIECES_CONTROL_AVAILABLE];
[fPiecesControl setSelected: NO forSegment: PIECES_CONTROL_PROGRESS];
[fPiecesControl setEnabled: NO];
[fPiecesView setTorrent: nil];
if (fPeers)
{
[fPeers release];
@ -285,7 +286,12 @@
[fTorrentLocationField setSelectable: YES];
[fDataLocationField setSelectable: YES];
//set pieces view
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];
//set file table
@ -993,8 +999,15 @@
- (void) setPiecesView: (id) sender
{
[[NSUserDefaults standardUserDefaults] setBool: [sender selectedSegment] == PIECES_CONTROL_AVAILABLE
forKey: @"PiecesViewShowAvailability"];
[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: YES];
}

View File

@ -23,6 +23,7 @@
*****************************************************************************/
#import "PiecesView.h"
#import "InfoWindowController.h"
#define MAX_ACROSS 18
#define BETWEEN 1.0
@ -375,4 +376,17 @@
free(piecesPercent);
}
- (BOOL) acceptsFirstMouse: (NSEvent *) event
{
return YES;
}
- (void) mouseDown: (NSEvent *) event
{
if (fTorrent)
[[[self window] windowController] setPiecesViewForAvailable:
![[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"]];
[super mouseDown: event];
}
@end