Make method names less generic to avoid conflicts.

Use methods in the Torrent class whenever possible.
This commit is contained in:
Mitchell Livingston 2006-06-21 23:46:41 +00:00
parent c7b97ad2b6
commit 5ab5baa008
6 changed files with 32 additions and 43 deletions

View File

@ -44,12 +44,12 @@
fDownloadBadge = [NSImage imageNamed: @"DownloadBadge"];
NSShadow * stringShadow = [[NSShadow alloc] init];
[stringShadow setShadowOffset: NSMakeSize(2, -2)];
[stringShadow setShadowBlurRadius: 4];
[stringShadow setShadowOffset: NSMakeSize(2.0, -2.0)];
[stringShadow setShadowBlurRadius: 4.0];
fAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSColor whiteColor], NSForegroundColorAttributeName,
[NSFont fontWithName: @"Helvetica-Bold" size: 28], NSFontAttributeName,
[NSFont fontWithName: @"Helvetica-Bold" size: 28.0], NSFontAttributeName,
stringShadow, NSShadowAttributeName, nil];
[stringShadow release];
@ -65,7 +65,6 @@
{
[fDockIcon release];
[fBadgedDockIcon release];
[fAttributes release];
[super dealloc];
@ -82,7 +81,6 @@
if (fCompleted != completed)
{
fCompleted = completed;
dockIcon = [fDockIcon copy];
//set completed badge to top right
@ -125,13 +123,13 @@
BOOL speedShown = uploadRateString || downloadRateString;
if (speedShown)
{
NSRect badgeRect, stringRect;
NSRect badgeRect;
badgeRect.size = [fUploadBadge size];
badgeRect.origin = NSZeroPoint;
//ignore shadow of badge when placing string
NSRect stringRect = badgeRect;
float badgeBottomExtra = 2.0;
stringRect = badgeRect;
stringRect.size.height -= badgeBottomExtra;
stringRect.origin.y += badgeBottomExtra;
@ -177,7 +175,6 @@
dockIcon = [fBadgedDockIcon copy];
[NSApp setApplicationIconImage: dockIcon];
[dockIcon release];
}

View File

@ -319,7 +319,7 @@ static void sleepCallBack(void * controller, io_service_t y,
{
[torrent setDownloadFolder: [[openPanel filenames] objectAtIndex: 0]];
if ([fDefaults boolForKey: @"AutoStartDownload"])
[torrent start];
[torrent startTransfer];
[fTorrents addObject: torrent];
[self torrentNumberChanged];
@ -371,7 +371,7 @@ static void sleepCallBack(void * controller, io_service_t y,
[torrent setDownloadFolder: folder];
if (autoStart)
[torrent start];
[torrent startTransfer];
[fTorrents addObject: torrent];
}
@ -461,10 +461,9 @@ static void sleepCallBack(void * controller, io_service_t y,
- (void) resumeTorrentWithIndex: (NSIndexSet *) indexSet
{
Torrent * torrent;
unsigned int i;
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
[[fTorrents objectAtIndex: i] start];
[[fTorrents objectAtIndex: i] startTransfer];
[self updateUI: nil];
[self updateTorrentHistory];
@ -484,12 +483,8 @@ static void sleepCallBack(void * controller, io_service_t y,
- (void) stopTorrentWithIndex: (NSIndexSet *) indexSet
{
unsigned int i;
Torrent * torrent;
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
{
torrent = [fTorrents objectAtIndex: i];
[torrent stop];
}
[[fTorrents objectAtIndex: i] stopTransfer];
[self updateUI: nil];
[self updateTorrentHistory];
@ -539,8 +534,7 @@ static void sleepCallBack(void * controller, io_service_t y,
" Do you really want to remove them?"];
}
NSBeginAlertSheet(title,
@"Remove", @"Cancel", nil, fWindow, self,
NSBeginAlertSheet(title, @"Remove", @"Cancel", nil, fWindow, self,
@selector(removeSheetDidEnd:returnCode:contextInfo:), nil, dict, message);
}
else
@ -570,7 +564,7 @@ static void sleepCallBack(void * controller, io_service_t y,
NSEnumerator * enumerator = [torrents objectEnumerator];
while ((torrent = [enumerator nextObject]))
{
[torrent stop];
[torrent stopTransfer];
if (deleteData)
[torrent trashData];
@ -669,15 +663,11 @@ static void sleepCallBack(void * controller, io_service_t y,
- (void) revealFile: (id) sender
{
Torrent * torrent;
NSIndexSet * indexSet = [fTableView selectedRowIndexes];
unsigned int i;
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
{
torrent = [fTorrents objectAtIndex: i];
[torrent reveal];
}
[[fTorrents objectAtIndex: i] revealData];
}
- (void) showPreferenceWindow: (id) sender

View File

@ -64,16 +64,16 @@
unit = @" GB";
}
NSString * value;
NSString * sizeString;
//attempt to have values with 3 digits
if (convertedSize < 10.0)
value = [NSString stringWithFormat: @"%.2f", convertedSize];
sizeString = [NSString stringWithFormat: @"%.2f", convertedSize];
else if (convertedSize < 100.0)
value = [NSString stringWithFormat: @"%.1f", convertedSize];
sizeString = [NSString stringWithFormat: @"%.1f", convertedSize];
else
value = [NSString stringWithFormat: @"%.0f", convertedSize];
sizeString = [NSString stringWithFormat: @"%.0f", convertedSize];
return [value stringByAppendingString: unit];
return [sizeString stringByAppendingString: unit];
}
+ (NSString *) stringForSpeed: (float) speed

View File

@ -62,8 +62,8 @@
- (void) getAvailability: (int8_t *) tab size: (int) size;
- (void) update;
- (void) start;
- (void) stop;
- (void) startTransfer;
- (void) stopTransfer;
- (void) removeForever;
- (void) sleep;
- (void) wakeUp;
@ -74,7 +74,7 @@
- (float) ratioLimit;
- (void) setRatioLimit: (float) limit;
- (void) reveal;
- (void) revealData;
- (void) trashData;
- (void) trashTorrent;

View File

@ -71,7 +71,7 @@
NSString * paused;
if (!(paused = [history objectForKey: @"Paused"]) || [paused isEqualToString: @"NO"])
[self start];
[self startTransfer];
}
return self;
}
@ -137,7 +137,7 @@
|| (fStopRatioSetting == RATIO_GLOBAL && [fDefaults boolForKey: @"RatioCheck"]
&& [self ratio] >= [fDefaults floatForKey: @"RatioLimit"])))
{
[self stop];
[self stopTransfer];
[self setStopRatioSetting: RATIO_NO_CHECK];
fFinishedSeeding = YES;
@ -216,7 +216,7 @@
}
}
- (void) start
- (void) startTransfer
{
if (![self isActive])
{
@ -225,7 +225,7 @@
}
}
- (void) stop
- (void) stopTransfer
{
if ([self isActive])
tr_torrentStop(fHandle);
@ -233,20 +233,20 @@
- (void) removeForever
{
if (fInfo->flags & TR_FSAVEPRIVATE)
if (fPrivateTorrent)
tr_torrentRemoveSaved(fHandle);
}
- (void) sleep
{
if ((fResumeOnWake = [self isActive]))
[self stop];
[self stopTransfer];
}
- (void) wakeUp
{
if (fResumeOnWake)
[self start];
[self startTransfer];
}
- (float) ratio
@ -276,7 +276,7 @@
fRatioLimit = limit;
}
- (void) reveal
- (void) revealData
{
[[NSWorkspace sharedWorkspace] selectFile: [self dataLocation] inFileViewerRootedAtPath: nil];
}

View File

@ -54,6 +54,8 @@
fPauseOffIcon = [NSImage imageNamed: @"PauseOff.png"];
fRevealOnIcon = [NSImage imageNamed: @"RevealOn.png"];
fRevealOffIcon = [NSImage imageNamed: @"RevealOff.png"];
fClickPoint = NSZeroPoint;
}
return self;
@ -103,11 +105,11 @@
else;
}
else if (sameRow && [self pointInRevealRect: point] && [self pointInRevealRect: fClickPoint])
[[fTorrents objectAtIndex: row] reveal];
[[fTorrents objectAtIndex: row] revealData];
else if ([event clickCount] == 2)
{
if ([self pointInIconRect: point])
[[fTorrents objectAtIndex: row] reveal];
[[fTorrents objectAtIndex: row] revealData];
else
[fController showInfo: nil];
}