mirror of
https://github.com/transmission/transmission
synced 2025-02-25 15:32:33 +00:00
add an option to reverse the sort order
This commit is contained in:
parent
21a77e02c7
commit
8345d49e29
7 changed files with 58 additions and 42 deletions
|
@ -82,6 +82,14 @@ void tr_ioLoadResume( tr_torrent_t * tor )
|
|||
free( io );
|
||||
}
|
||||
|
||||
void tr_ioRemoveResume( tr_torrent_t * tor )
|
||||
{
|
||||
if( !tor->io )
|
||||
{
|
||||
fastResumeRemove( tor );
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* tr_ioInit
|
||||
***********************************************************************
|
||||
|
@ -103,14 +111,6 @@ tr_io_t * tr_ioInit( tr_torrent_t * tor )
|
|||
return io;
|
||||
}
|
||||
|
||||
void tr_ioRemoveResume( tr_torrent_t * tor )
|
||||
{
|
||||
if( !tor->io )
|
||||
{
|
||||
fastResumeRemove( tor );
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* tr_ioRead
|
||||
**********************************************************************/
|
||||
|
|
|
@ -162,6 +162,7 @@
|
|||
- (void) sortTorrents;
|
||||
- (void) sortTorrentsIgnoreSelected;
|
||||
- (void) setSort: (id) sender;
|
||||
- (void) setSortReverse: (id) sender;
|
||||
- (void) applyFilter: (id) sender;
|
||||
- (void) setFilter: (id) sender;
|
||||
- (void) switchFilter: (id) sender;
|
||||
|
|
|
@ -322,16 +322,16 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
currentSortItem = fProgressSortItem;
|
||||
currentSortActionItem = fProgressSortActionItem;
|
||||
}
|
||||
else if ([sortType isEqualToString: @"Date"])
|
||||
{
|
||||
currentSortItem = fDateSortItem;
|
||||
currentSortActionItem = fDateSortActionItem;
|
||||
}
|
||||
else
|
||||
else if ([sortType isEqualToString: @"Order"])
|
||||
{
|
||||
currentSortItem = fOrderSortItem;
|
||||
currentSortActionItem = fOrderSortActionItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentSortItem = fDateSortItem;
|
||||
currentSortActionItem = fDateSortActionItem;
|
||||
}
|
||||
[currentSortItem setState: NSOnState];
|
||||
[currentSortActionItem setState: NSOnState];
|
||||
|
||||
|
@ -1424,11 +1424,12 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
- (void) sortTorrentsIgnoreSelected
|
||||
{
|
||||
NSString * sortType = [fDefaults stringForKey: @"Sort"];
|
||||
BOOL asc = ![fDefaults boolForKey: @"SortReverse"];
|
||||
|
||||
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name"
|
||||
ascending: YES selector: @selector(caseInsensitiveCompare:)] autorelease],
|
||||
ascending: asc selector: @selector(caseInsensitiveCompare:)] autorelease],
|
||||
* orderDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"orderValue"
|
||||
ascending: YES] autorelease];
|
||||
ascending: asc] autorelease];
|
||||
|
||||
NSArray * descriptors;
|
||||
if ([sortType isEqualToString: @"Name"])
|
||||
|
@ -1436,11 +1437,11 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
else if ([sortType isEqualToString: @"State"])
|
||||
{
|
||||
NSSortDescriptor * stateDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
@"stateSortKey" ascending: NO] autorelease],
|
||||
@"stateSortKey" ascending: !asc] autorelease],
|
||||
* progressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
@"progressSortKey" ascending: NO] autorelease],
|
||||
@"progressSortKey" ascending: !asc] autorelease],
|
||||
* ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
@"ratioSortKey" ascending: NO] autorelease];
|
||||
@"ratioSortKey" ascending: !asc] autorelease];
|
||||
|
||||
descriptors = [[NSArray alloc] initWithObjects: stateDescriptor, progressDescriptor, ratioDescriptor,
|
||||
nameDescriptor, orderDescriptor, nil];
|
||||
|
@ -1448,21 +1449,21 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
else if ([sortType isEqualToString: @"Progress"])
|
||||
{
|
||||
NSSortDescriptor * progressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
@"progressSortKey" ascending: YES] autorelease],
|
||||
@"progressSortKey" ascending: asc] autorelease],
|
||||
* ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
@"ratioSortKey" ascending: YES] autorelease];
|
||||
@"ratioSortKey" ascending: asc] autorelease];
|
||||
|
||||
descriptors = [[NSArray alloc] initWithObjects: progressDescriptor, ratioDescriptor,
|
||||
nameDescriptor, orderDescriptor, nil];
|
||||
}
|
||||
else if ([sortType isEqualToString: @"Date"])
|
||||
else if ([sortType isEqualToString: @"Order"])
|
||||
descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
|
||||
else
|
||||
{
|
||||
NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"dateAdded" ascending: YES] autorelease];
|
||||
NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"dateAdded" ascending: asc] autorelease];
|
||||
|
||||
descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, orderDescriptor, nil];
|
||||
}
|
||||
else
|
||||
descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
|
||||
|
||||
[fDisplayedTorrents sortUsingDescriptors: descriptors];
|
||||
[descriptors release];
|
||||
|
@ -1491,16 +1492,16 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
prevSortItem = fProgressSortItem;
|
||||
prevSortActionItem = fProgressSortActionItem;
|
||||
}
|
||||
else if ([oldSortType isEqualToString: @"Date"])
|
||||
{
|
||||
prevSortItem = fDateSortItem;
|
||||
prevSortActionItem = fDateSortActionItem;
|
||||
}
|
||||
else
|
||||
else if ([oldSortType isEqualToString: @"Order"])
|
||||
{
|
||||
prevSortItem = fOrderSortItem;
|
||||
prevSortActionItem = fOrderSortActionItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
prevSortItem = fDateSortItem;
|
||||
prevSortActionItem = fDateSortActionItem;
|
||||
}
|
||||
|
||||
if (sender != prevSortItem && sender != prevSortActionItem)
|
||||
{
|
||||
|
@ -1525,17 +1526,19 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
currentSortActionItem = fProgressSortActionItem;
|
||||
sortType = @"Progress";
|
||||
}
|
||||
else if (sender == fDateSortItem || sender == fDateSortActionItem)
|
||||
{
|
||||
currentSortItem = fDateSortItem;
|
||||
currentSortActionItem = fDateSortActionItem;
|
||||
sortType = @"Date";
|
||||
}
|
||||
else
|
||||
else if (sender == fOrderSortItem || sender == fOrderSortActionItem)
|
||||
{
|
||||
currentSortItem = fOrderSortItem;
|
||||
currentSortActionItem = fOrderSortActionItem;
|
||||
sortType = @"Order";
|
||||
|
||||
[fDefaults setBool: NO forKey: @"SortReverse"];
|
||||
}
|
||||
else
|
||||
{
|
||||
currentSortItem = fDateSortItem;
|
||||
currentSortActionItem = fDateSortActionItem;
|
||||
sortType = @"Date";
|
||||
}
|
||||
|
||||
[fDefaults setObject: sortType forKey: @"Sort"];
|
||||
|
@ -1549,6 +1552,11 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[self sortTorrents];
|
||||
}
|
||||
|
||||
- (void) setSortReverse: (id) sender
|
||||
{
|
||||
[self sortTorrents];
|
||||
}
|
||||
|
||||
- (void) applyFilter: (id) sender
|
||||
{
|
||||
//remember selected rows if needed
|
||||
|
@ -2623,6 +2631,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
if (action == @selector(copyTorrentFile:))
|
||||
return canUseTable && [fTableView numberOfSelectedRows] > 0;
|
||||
|
||||
//enable reverse sort item
|
||||
if (action == @selector(setSortReverse:))
|
||||
return ![[fDefaults stringForKey: @"Sort"] isEqualToString: @"Order"];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,8 @@
|
|||
<false/>
|
||||
<key>Sort</key>
|
||||
<string>Order</string>
|
||||
<key>SortReverse</key>
|
||||
<false/>
|
||||
<key>SpeedLimit</key>
|
||||
<false/>
|
||||
<key>SpeedLimitAuto</key>
|
||||
|
|
1
macosx/English.lproj/MainMenu.nib/classes.nib
generated
1
macosx/English.lproj/MainMenu.nib/classes.nib
generated
|
@ -31,6 +31,7 @@
|
|||
setQuickLimitGlobal = id;
|
||||
setQuickRatioGlobal = id;
|
||||
setSort = id;
|
||||
setSortReverse = id;
|
||||
showInfo = id;
|
||||
showMainWindow = id;
|
||||
showMessageWindow = id;
|
||||
|
|
6
macosx/English.lproj/MainMenu.nib/info.nib
generated
6
macosx/English.lproj/MainMenu.nib/info.nib
generated
|
@ -7,13 +7,13 @@
|
|||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>1041</key>
|
||||
<string>438 418 208 149 0 0 1152 842 </string>
|
||||
<string>324 252 208 149 0 0 1152 842 </string>
|
||||
<key>1480</key>
|
||||
<string>366 546 420 63 0 0 1152 842 </string>
|
||||
<key>1603</key>
|
||||
<string>337 545 477 67 0 0 1152 842 </string>
|
||||
<key>29</key>
|
||||
<string>242 698 451 44 0 0 1152 842 </string>
|
||||
<string>118 704 451 44 0 0 1152 842 </string>
|
||||
<key>456</key>
|
||||
<string>396 374 240 225 0 0 1152 842 </string>
|
||||
<key>581</key>
|
||||
|
@ -31,7 +31,7 @@
|
|||
<integer>3</integer>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>21</integer>
|
||||
<integer>1041</integer>
|
||||
<integer>29</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
|
|
BIN
macosx/English.lproj/MainMenu.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/MainMenu.nib/keyedobjects.nib
generated
Binary file not shown.
Loading…
Reference in a new issue