mirror of
https://github.com/transmission/transmission
synced 2025-03-03 18:25:35 +00:00
simplify the method for adding groups to the torrent array
This commit is contained in:
parent
4035d22b05
commit
2761220369
2 changed files with 24 additions and 29 deletions
macosx
|
@ -191,7 +191,7 @@ typedef enum
|
||||||
|
|
||||||
- (void) updateTorrentHistory;
|
- (void) updateTorrentHistory;
|
||||||
|
|
||||||
- (void) updateDisplay: (id) sender;
|
- (void) updateDisplay;
|
||||||
|
|
||||||
- (void) setSort: (id) sender;
|
- (void) setSort: (id) sender;
|
||||||
- (void) setSortByGroup: (id) sender;
|
- (void) setSortByGroup: (id) sender;
|
||||||
|
|
|
@ -458,7 +458,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||||
[[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSModalPanelRunLoopMode];
|
[[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSModalPanelRunLoopMode];
|
||||||
[[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSEventTrackingRunLoopMode];
|
[[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSEventTrackingRunLoopMode];
|
||||||
|
|
||||||
[self updateDisplay: nil];
|
[self updateDisplay];
|
||||||
|
|
||||||
[fWindow makeKeyAndOrderFront: nil];
|
[fWindow makeKeyAndOrderFront: nil];
|
||||||
|
|
||||||
|
@ -1028,7 +1028,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||||
[torrent startTransfer];
|
[torrent startTransfer];
|
||||||
|
|
||||||
[self updateUI];
|
[self updateUI];
|
||||||
[self updateDisplay: nil];
|
[self updateDisplay];
|
||||||
[self updateTorrentHistory];
|
[self updateTorrentHistory];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1336,7 +1336,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||||
while ((torrent = [enumerator nextObject]))
|
while ((torrent = [enumerator nextObject]))
|
||||||
[torrent resetCache];
|
[torrent resetCache];
|
||||||
|
|
||||||
[self updateDisplay: nil];
|
[self updateDisplay];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) showPreferenceWindow: (id) sender
|
- (void) showPreferenceWindow: (id) sender
|
||||||
|
@ -1390,7 +1390,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||||
{
|
{
|
||||||
if ([fWindow isVisible])
|
if ([fWindow isVisible])
|
||||||
{
|
{
|
||||||
[self updateDisplay: nil];
|
[self updateDisplay];
|
||||||
|
|
||||||
//update status bar
|
//update status bar
|
||||||
if (![fStatusBar isHidden])
|
if (![fStatusBar isHidden])
|
||||||
|
@ -1630,19 +1630,19 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||||
}
|
}
|
||||||
|
|
||||||
[fDefaults setObject: sortType forKey: @"Sort"];
|
[fDefaults setObject: sortType forKey: @"Sort"];
|
||||||
[self updateDisplay: nil];
|
[self updateDisplay];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setSortByGroup: (id) sender
|
- (void) setSortByGroup: (id) sender
|
||||||
{
|
{
|
||||||
[fDefaults setBool: ![fDefaults boolForKey: @"SortByGroup"] forKey: @"SortByGroup"];
|
[fDefaults setBool: ![fDefaults boolForKey: @"SortByGroup"] forKey: @"SortByGroup"];
|
||||||
[self updateDisplay: nil];
|
[self updateDisplay];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setSortReverse: (id) sender
|
- (void) setSortReverse: (id) sender
|
||||||
{
|
{
|
||||||
[fDefaults setBool: ![fDefaults boolForKey: @"SortReverse"] forKey: @"SortReverse"];
|
[fDefaults setBool: ![fDefaults boolForKey: @"SortReverse"] forKey: @"SortReverse"];
|
||||||
[self updateDisplay: nil];
|
[self updateDisplay];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) prepareForDisplay
|
- (void) prepareForDisplay
|
||||||
|
@ -1735,39 +1735,34 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||||
[fDisplayedGroupIndexes removeAllIndexes];
|
[fDisplayedGroupIndexes removeAllIndexes];
|
||||||
if (group && total > 0 && [NSApp isOnLeopardOrBetter])
|
if (group && total > 0 && [NSApp isOnLeopardOrBetter])
|
||||||
{
|
{
|
||||||
#warning make more efficient
|
int i, groupValue = [[fDisplayedTorrents objectAtIndex: 0] groupValue], newGroupValue, count = 1, start = 0;
|
||||||
NSMutableIndexSet * tempGroupIndexes = [[NSMutableIndexSet alloc] init];
|
for (i = 0; i < [fDisplayedTorrents count]; i++)
|
||||||
|
|
||||||
int i, groupValue = [[fDisplayedTorrents objectAtIndex: total-1] groupValue], newGroupValue, count = 1;
|
|
||||||
for (i = total-1; i >= 0; i--)
|
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i < [fDisplayedTorrents count]-1)
|
||||||
newGroupValue = [[fDisplayedTorrents objectAtIndex: i-1] groupValue];
|
newGroupValue = [[fDisplayedTorrents objectAtIndex: i+1] groupValue];
|
||||||
if (groupValue != newGroupValue || i == 0)
|
if (groupValue != newGroupValue || i == [fDisplayedTorrents count]-1)
|
||||||
{
|
{
|
||||||
#warning count can be derived...elliminate
|
#warning count can be derived...elliminate
|
||||||
NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt: groupValue], @"Group",
|
NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt: groupValue], @"Group",
|
||||||
[NSNumber numberWithInt: count], @"Count", nil];
|
[NSNumber numberWithInt: count], @"Count", nil];
|
||||||
[fDisplayedTorrents insertObject: dict atIndex: i];
|
[fDisplayedTorrents insertObject: dict atIndex: start];
|
||||||
[tempGroupIndexes addIndex: i];
|
[fDisplayedGroupIndexes addIndex: start];
|
||||||
|
|
||||||
groupValue = newGroupValue;
|
groupValue = newGroupValue;
|
||||||
count = 1;
|
count = 1;
|
||||||
|
|
||||||
|
start = i+2;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = [tempGroupIndexes firstIndex], count = 0; i != NSNotFound; i = [tempGroupIndexes indexGreaterThanIndex: i], count++)
|
|
||||||
[fDisplayedGroupIndexes addIndex: i+count];
|
|
||||||
|
|
||||||
[tempGroupIndexes release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[fTableView reloadData];
|
[fTableView reloadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) updateDisplay: (id) sender
|
- (void) updateDisplay
|
||||||
{
|
{
|
||||||
NSMutableArray * previousTorrents = [fDisplayedTorrents mutableCopy];
|
NSMutableArray * previousTorrents = [fDisplayedTorrents mutableCopy];
|
||||||
[previousTorrents removeObjectsAtIndexes: fDisplayedGroupIndexes];
|
[previousTorrents removeObjectsAtIndexes: fDisplayedGroupIndexes];
|
||||||
|
@ -1953,7 +1948,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||||
else
|
else
|
||||||
[sender setState: NSOnState];
|
[sender setState: NSOnState];
|
||||||
|
|
||||||
[self updateDisplay: nil];
|
[self updateDisplay];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setFilterSearchType: (id) sender
|
- (void) setFilterSearchType: (id) sender
|
||||||
|
@ -1979,7 +1974,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||||
[[fSearchFilterField cell] setPlaceholderString: [sender title]];
|
[[fSearchFilterField cell] setPlaceholderString: [sender title]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self updateDisplay: nil];
|
[self updateDisplay];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) switchFilter: (id) sender
|
- (void) switchFilter: (id) sender
|
||||||
|
@ -2113,7 +2108,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||||
{
|
{
|
||||||
[fDefaults setInteger: [sender tag] forKey: @"FilterGroup"];
|
[fDefaults setInteger: [sender tag] forKey: @"FilterGroup"];
|
||||||
[self updateGroupsFilterButton];
|
[self updateGroupsFilterButton];
|
||||||
[self updateDisplay: nil];
|
[self updateDisplay];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) updateGroupsFilterButton
|
- (void) updateGroupsFilterButton
|
||||||
|
@ -2146,7 +2141,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||||
- (void) updateGroupsFilters: (NSNotification *) notification
|
- (void) updateGroupsFilters: (NSNotification *) notification
|
||||||
{
|
{
|
||||||
[self updateGroupsFilterButton];
|
[self updateGroupsFilterButton];
|
||||||
[self updateDisplay: nil];
|
[self updateDisplay];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) toggleSpeedLimit: (id) sender
|
- (void) toggleSpeedLimit: (id) sender
|
||||||
|
@ -2469,7 +2464,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||||
|
|
||||||
[sortedTorrents release];
|
[sortedTorrents release];
|
||||||
|
|
||||||
[self updateDisplay: nil];
|
[self updateDisplay];
|
||||||
|
|
||||||
//set selected rows
|
//set selected rows
|
||||||
[fTableView selectValues: selectedValues];
|
[fTableView selectValues: selectedValues];
|
||||||
|
|
Loading…
Reference in a new issue