1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-04 10:38:13 +00:00

Don't reload the whole inspector when only settings need to be changed.

This commit is contained in:
Mitchell Livingston 2006-07-04 17:26:18 +00:00
parent 5f8e0d613e
commit 28cce2a6a1
3 changed files with 71 additions and 64 deletions

View file

@ -480,7 +480,7 @@ static void sleepCallBack(void * controller, io_service_t y,
[[fTorrents objectAtIndex: i] startTransfer]; [[fTorrents objectAtIndex: i] startTransfer];
[self updateUI: nil]; [self updateUI: nil];
[self reloadInspector: nil]; [fInfoController updateInfoSettings];
[self updateTorrentHistory]; [self updateTorrentHistory];
} }
@ -510,7 +510,7 @@ static void sleepCallBack(void * controller, io_service_t y,
[[fTorrents objectAtIndex: i] stopTransfer]; [[fTorrents objectAtIndex: i] stopTransfer];
[self updateUI: nil]; [self updateUI: nil];
[self reloadInspector: nil]; [fInfoController updateInfoSettings];
[self updateTorrentHistory]; [self updateTorrentHistory];
} }
@ -1030,7 +1030,7 @@ static void sleepCallBack(void * controller, io_service_t y,
[torrentToStart startTransfer]; [torrentToStart startTransfer];
[self updateUI: nil]; [self updateUI: nil];
[self reloadInspector: nil]; [fInfoController updateInfoSettings];
[self updateTorrentHistory]; [self updateTorrentHistory];
} }
} }
@ -1040,7 +1040,7 @@ static void sleepCallBack(void * controller, io_service_t y,
[self attemptToStartMultipleAuto: fTorrents]; [self attemptToStartMultipleAuto: fTorrents];
[self updateUI: nil]; [self updateUI: nil];
[self reloadInspector: nil]; [fInfoController updateInfoSettings];
[self updateTorrentHistory]; [self updateTorrentHistory];
} }
@ -1049,7 +1049,7 @@ static void sleepCallBack(void * controller, io_service_t y,
[self attemptToStartMultipleAuto: [notification object]]; [self attemptToStartMultipleAuto: [notification object]];
[self updateUI: nil]; [self updateUI: nil];
[self reloadInspector: nil]; [fInfoController updateInfoSettings];
[self updateTorrentHistory]; [self updateTorrentHistory];
} }

View file

@ -56,6 +56,7 @@
- (void) updateInfoForTorrents: (NSArray *) torrents; - (void) updateInfoForTorrents: (NSArray *) torrents;
- (void) updateInfoStats; - (void) updateInfoStats;
- (void) updateInfoSettings;
- (void) setNextTab; - (void) setNextTab;
- (void) setPreviousTab; - (void) setPreviousTab;

View file

@ -178,6 +178,7 @@
[fDateStartedField setObjectValue: [torrent date]]; [fDateStartedField setObjectValue: [torrent date]];
} }
[self updateInfoStats]; [self updateInfoStats];
[self updateInfoSettings];
//set file table //set file table
[fFiles removeAllObjects]; [fFiles removeAllObjects];
@ -189,13 +190,75 @@
[fFileTable deselectAll: nil]; [fFileTable deselectAll: nil];
[fFileTable reloadData]; [fFileTable reloadData];
}
- (void) updateInfoStats
{
int numberSelected = [fTorrents count];
if (numberSelected > 0)
{
//float downloadRate = 0, uploadRate = 0;
float downloadedValid = 0;
uint64_t downloadedTotal = 0, uploadedTotal = 0;
Torrent * torrent;
NSEnumerator * enumerator = [fTorrents objectEnumerator];
while ((torrent = [enumerator nextObject]))
{
/*downloadRate += [torrent downloadRate];
uploadRate += [torrent uploadRate];
*/
downloadedValid += [torrent downloadedValid];
downloadedTotal += [torrent downloadedTotal];
uploadedTotal += [torrent uploadedTotal];
}
/*
[fDownloadRateField setStringValue: [NSString stringForSpeed: downloadRate]];
[fUploadRateField setStringValue: [NSString stringForSpeed: uploadRate]];
*/
[fDownloadedValidField setStringValue: [NSString stringForFileSize: downloadedValid]];
[fDownloadedTotalField setStringValue: [NSString stringForFileSize: downloadedTotal]];
[fUploadedTotalField setStringValue: [NSString stringForFileSize: uploadedTotal]];
if (numberSelected == 1)
{
torrent = [fTorrents objectAtIndex: 0];
/*
[fStateField setStringValue: [torrent state]];
[fPercentField setStringValue: [NSString stringWithFormat:
@"%.2f%%", 100.0 * [torrent progress]]];
*/
int seeders = [torrent seeders], leechers = [torrent leechers];
[fSeedersField setStringValue: seeders < 0 ?
@"N/A" : [NSString stringWithInt: seeders]];
[fLeechersField setStringValue: leechers < 0 ?
@"N/A" : [NSString stringWithInt: leechers]];
BOOL active = [torrent isActive];
[fConnectedPeersField setStringValue: active ? [NSString
stringWithInt: [torrent totalPeers]] : @"N/A"];
[fDownloadingFromField setStringValue: active ? [NSString
stringWithInt: [torrent peersUploading]] : @"N/A"];
[fUploadingToField setStringValue: active ? [NSString
stringWithInt: [torrent peersDownloading]] : @"N/A"];
[fRatioField setStringValue: [NSString stringForRatioWithDownload:
downloadedTotal upload: uploadedTotal]];
}
}
}
- (void) updateInfoSettings
{
int numberSelected = [fTorrents count];
//set wait to start //set wait to start
BOOL waiting = NO, notWaiting = NO, canEnableWaiting = numberSelected > 0, BOOL waiting = NO, notWaiting = NO, canEnableWaiting = numberSelected > 0,
waitingSettingOn = [[[NSUserDefaults standardUserDefaults] stringForKey: @"StartSetting"] waitingSettingOn = [[[NSUserDefaults standardUserDefaults] stringForKey: @"StartSetting"]
isEqualToString: @"Wait"]; isEqualToString: @"Wait"];
enumerator = [fTorrents objectEnumerator]; NSEnumerator * enumerator = [fTorrents objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject])) while ((torrent = [enumerator nextObject]))
{ {
if ([torrent waitingToStart]) if ([torrent waitingToStart])
@ -263,62 +326,6 @@
} }
} }
- (void) updateInfoStats
{
int numberSelected = [fTorrents count];
if (numberSelected > 0)
{
//float downloadRate = 0, uploadRate = 0;
float downloadedValid = 0;
uint64_t downloadedTotal = 0, uploadedTotal = 0;
Torrent * torrent;
NSEnumerator * enumerator = [fTorrents objectEnumerator];
while ((torrent = [enumerator nextObject]))
{
/*downloadRate += [torrent downloadRate];
uploadRate += [torrent uploadRate];
*/
downloadedValid += [torrent downloadedValid];
downloadedTotal += [torrent downloadedTotal];
uploadedTotal += [torrent uploadedTotal];
}
/*
[fDownloadRateField setStringValue: [NSString stringForSpeed: downloadRate]];
[fUploadRateField setStringValue: [NSString stringForSpeed: uploadRate]];
*/
[fDownloadedValidField setStringValue: [NSString stringForFileSize: downloadedValid]];
[fDownloadedTotalField setStringValue: [NSString stringForFileSize: downloadedTotal]];
[fUploadedTotalField setStringValue: [NSString stringForFileSize: uploadedTotal]];
if (numberSelected == 1)
{
torrent = [fTorrents objectAtIndex: 0];
/*
[fStateField setStringValue: [torrent state]];
[fPercentField setStringValue: [NSString stringWithFormat:
@"%.2f%%", 100.0 * [torrent progress]]];
*/
int seeders = [torrent seeders], leechers = [torrent leechers];
[fSeedersField setStringValue: seeders < 0 ?
@"N/A" : [NSString stringWithInt: seeders]];
[fLeechersField setStringValue: leechers < 0 ?
@"N/A" : [NSString stringWithInt: leechers]];
BOOL active = [torrent isActive];
[fConnectedPeersField setStringValue: active ? [NSString
stringWithInt: [torrent totalPeers]] : @"N/A"];
[fDownloadingFromField setStringValue: active ? [NSString
stringWithInt: [torrent peersUploading]] : @"N/A"];
[fUploadingToField setStringValue: active ? [NSString
stringWithInt: [torrent peersDownloading]] : @"N/A"];
[fRatioField setStringValue: [NSString stringForRatioWithDownload:
downloadedTotal upload: uploadedTotal]];
}
}
}
- (BOOL) validateMenuItem: (NSMenuItem *) menuItem - (BOOL) validateMenuItem: (NSMenuItem *) menuItem
{ {
SEL action = [menuItem action]; SEL action = [menuItem action];
@ -379,8 +386,7 @@
- (void) setNextTab - (void) setNextTab
{ {
if ([fTabView indexOfTabViewItem: [fTabView selectedTabViewItem]] if ([fTabView indexOfTabViewItem: [fTabView selectedTabViewItem]] == [fTabView numberOfTabViewItems] - 1)
== [fTabView numberOfTabViewItems] - 1)
[fTabView selectFirstTabViewItem: nil]; [fTabView selectFirstTabViewItem: nil];
else else
[fTabView selectNextTabViewItem: nil]; [fTabView selectNextTabViewItem: nil];