Sort in the action menu.

This commit is contained in:
Mitchell Livingston 2006-07-22 14:08:35 +00:00
parent 2c44a4ef0a
commit 25e75ec312
5 changed files with 89 additions and 26 deletions

View File

@ -63,7 +63,9 @@
NSString * fSortType; NSString * fSortType;
IBOutlet NSMenuItem * fNameSortItem, * fStateSortItem, * fProgressSortItem, IBOutlet NSMenuItem * fNameSortItem, * fStateSortItem, * fProgressSortItem,
* fDateSortItem, * fOrderSortItem; * fDateSortItem, * fOrderSortItem,
* fNameSortActionItem, * fStateSortActionItem, * fProgressSortActionItem,
* fDateSortActionItem, * fOrderSortActionItem;
IBOutlet ImageBackgroundView * fFilterBar; IBOutlet ImageBackgroundView * fFilterBar;
BOOL fFilterBarVisible; BOOL fFilterBarVisible;

View File

@ -217,18 +217,34 @@ static void sleepCallBack(void * controller, io_service_t y,
//set sort //set sort
fSortType = [[fDefaults stringForKey: @"Sort"] retain]; fSortType = [[fDefaults stringForKey: @"Sort"] retain];
NSMenuItem * currentSortItem; NSMenuItem * currentSortItem, * currentSortActionItem;
if ([fSortType isEqualToString: @"Name"]) if ([fSortType isEqualToString: @"Name"])
{
currentSortItem = fNameSortItem; currentSortItem = fNameSortItem;
currentSortActionItem = fNameSortActionItem;
}
else if ([fSortType isEqualToString: @"State"]) else if ([fSortType isEqualToString: @"State"])
{
currentSortItem = fStateSortItem; currentSortItem = fStateSortItem;
currentSortActionItem = fStateSortActionItem;
}
else if ([fSortType isEqualToString: @"Progress"]) else if ([fSortType isEqualToString: @"Progress"])
{
currentSortItem = fProgressSortItem; currentSortItem = fProgressSortItem;
currentSortActionItem = fProgressSortActionItem;
}
else if ([fSortType isEqualToString: @"Date"]) else if ([fSortType isEqualToString: @"Date"])
{
currentSortItem = fDateSortItem; currentSortItem = fDateSortItem;
currentSortActionItem = fDateSortActionItem;
}
else else
{
currentSortItem = fOrderSortItem; currentSortItem = fOrderSortItem;
currentSortActionItem = fOrderSortActionItem;
}
[currentSortItem setState: NSOnState]; [currentSortItem setState: NSOnState];
[currentSortActionItem setState: NSOnState];
//set filter //set filter
fFilterType = [[fDefaults stringForKey: @"Filter"] retain]; fFilterType = [[fDefaults stringForKey: @"Filter"] retain];
@ -973,34 +989,75 @@ static void sleepCallBack(void * controller, io_service_t y,
- (void) setSort: (id) sender - (void) setSort: (id) sender
{ {
NSMenuItem * prevSortItem; //get checked items
NSMenuItem * prevSortItem, * prevSortActionItem;
if ([fSortType isEqualToString: @"Name"]) if ([fSortType isEqualToString: @"Name"])
prevSortItem = fNameSortItem;
else if ([fSortType isEqualToString: @"State"])
prevSortItem = fStateSortItem;
else if ([fSortType isEqualToString: @"Progress"])
prevSortItem = fProgressSortItem;
else if ([fSortType isEqualToString: @"Date"])
prevSortItem = fDateSortItem;
else
prevSortItem = fOrderSortItem;
if (sender != prevSortItem)
{ {
[prevSortItem setState: NSOffState]; prevSortItem = fNameSortItem;
[sender setState: NSOnState]; prevSortActionItem = fNameSortActionItem;
}
[fSortType release]; else if ([fSortType isEqualToString: @"State"])
if (sender == fNameSortItem) {
fSortType = [[NSString alloc] initWithString: @"Name"]; prevSortItem = fStateSortItem;
else if (sender == fStateSortItem) prevSortActionItem = fStateSortActionItem;
fSortType = [[NSString alloc] initWithString: @"State"]; }
else if (sender == fProgressSortItem) else if ([fSortType isEqualToString: @"Progress"])
fSortType = [[NSString alloc] initWithString: @"Progress"]; {
else if (sender == fDateSortItem) prevSortItem = fProgressSortItem;
fSortType = [[NSString alloc] initWithString: @"Date"]; prevSortActionItem = fProgressSortActionItem;
}
else if ([fSortType isEqualToString: @"Date"])
{
prevSortItem = fDateSortItem;
prevSortActionItem = fDateSortActionItem;
}
else else
{
prevSortItem = fOrderSortItem;
prevSortActionItem = fOrderSortActionItem;
}
if (sender != prevSortItem && sender != prevSortActionItem)
{
[fSortType release];
//get new items to check
NSMenuItem * currentSortItem, * currentSortActionItem;
if (sender == fNameSortItem || sender == fNameSortActionItem)
{
currentSortItem = fNameSortItem;
currentSortActionItem = fNameSortActionItem;
fSortType = [[NSString alloc] initWithString: @"Name"];
}
else if (sender == fStateSortItem || sender == fStateSortActionItem)
{
currentSortItem = fStateSortItem;
currentSortActionItem = fStateSortActionItem;
fSortType = [[NSString alloc] initWithString: @"State"];
}
else if (sender == fProgressSortItem || sender == fProgressSortActionItem)
{
currentSortItem = fProgressSortItem;
currentSortActionItem = fProgressSortActionItem;
fSortType = [[NSString alloc] initWithString: @"Progress"];
}
else if (sender == fDateSortItem || sender == fDateSortActionItem)
{
currentSortItem = fDateSortItem;
currentSortActionItem = fDateSortActionItem;
fSortType = [[NSString alloc] initWithString: @"Date"];
}
else
{
currentSortItem = fOrderSortItem;
currentSortActionItem = fOrderSortActionItem;
fSortType = [[NSString alloc] initWithString: @"Order"]; fSortType = [[NSString alloc] initWithString: @"Order"];
}
[prevSortItem setState: NSOffState];
[prevSortActionItem setState: NSOffState];
[currentSortItem setState: NSOnState];
[currentSortActionItem setState: NSOnState];
[fDefaults setObject: fSortType forKey: @"Sort"]; [fDefaults setObject: fSortType forKey: @"Sort"];
} }

View File

@ -39,18 +39,22 @@
OUTLETS = { OUTLETS = {
fActionButton = NSButton; fActionButton = NSButton;
fAdvancedBarItem = NSMenuItem; fAdvancedBarItem = NSMenuItem;
fDateSortActionItem = NSMenuItem;
fDateSortItem = NSMenuItem; fDateSortItem = NSMenuItem;
fDownloadFilterButton = BarButton; fDownloadFilterButton = BarButton;
fDownloadLimitItem = NSMenuItem; fDownloadLimitItem = NSMenuItem;
fDownloadMenu = NSMenu; fDownloadMenu = NSMenu;
fDownloadNoLimitItem = NSMenuItem; fDownloadNoLimitItem = NSMenuItem;
fFilterBar = ImageBackgroundView; fFilterBar = ImageBackgroundView;
fNameSortActionItem = NSMenuItem;
fNameSortItem = NSMenuItem; fNameSortItem = NSMenuItem;
fNextInfoTabItem = NSMenuItem; fNextInfoTabItem = NSMenuItem;
fNoFilterButton = BarButton; fNoFilterButton = BarButton;
fOrderSortActionItem = NSMenuItem;
fOrderSortItem = NSMenuItem; fOrderSortItem = NSMenuItem;
fPauseFilterButton = BarButton; fPauseFilterButton = BarButton;
fPrevInfoTabItem = NSMenuItem; fPrevInfoTabItem = NSMenuItem;
fProgressSortActionItem = NSMenuItem;
fProgressSortItem = NSMenuItem; fProgressSortItem = NSMenuItem;
fRatioNotSetItem = NSMenuItem; fRatioNotSetItem = NSMenuItem;
fRatioSetItem = NSMenuItem; fRatioSetItem = NSMenuItem;
@ -61,6 +65,7 @@
fSpeedLimitButton = NSButton; fSpeedLimitButton = NSButton;
fSpeedLimitDockItem = NSMenuItem; fSpeedLimitDockItem = NSMenuItem;
fSpeedLimitItem = NSMenuItem; fSpeedLimitItem = NSMenuItem;
fStateSortActionItem = NSMenuItem;
fStateSortItem = NSMenuItem; fStateSortItem = NSMenuItem;
fStatusBar = ImageBackgroundView; fStatusBar = ImageBackgroundView;
fTableView = TorrentTableView; fTableView = TorrentTableView;

View File

@ -7,7 +7,7 @@
<key>IBEditorPositions</key> <key>IBEditorPositions</key>
<dict> <dict>
<key>1041</key> <key>1041</key>
<string>344 478 208 99 0 0 1152 842 </string> <string>344 478 208 130 0 0 1152 842 </string>
<key>1480</key> <key>1480</key>
<string>366 546 420 63 0 0 1152 842 </string> <string>366 546 420 63 0 0 1152 842 </string>
<key>1603</key> <key>1603</key>
@ -31,9 +31,8 @@
<integer>3</integer> <integer>3</integer>
<key>IBOpenObjects</key> <key>IBOpenObjects</key>
<array> <array>
<integer>21</integer>
<integer>1480</integer>
<integer>29</integer> <integer>29</integer>
<integer>1041</integer>
<integer>1603</integer> <integer>1603</integer>
</array> </array>
<key>IBSystem Version</key> <key>IBSystem Version</key>

Binary file not shown.