1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00

small search field in filter

This commit is contained in:
Mitchell Livingston 2006-07-16 17:59:20 +00:00
parent b81f910a72
commit dc18992d4a
6 changed files with 36 additions and 18 deletions

View file

@ -69,6 +69,7 @@
NSString * fFilterType; NSString * fFilterType;
IBOutlet BarButton * fNoFilterButton, * fPauseFilterButton, IBOutlet BarButton * fNoFilterButton, * fPauseFilterButton,
* fSeedFilterButton, * fDownloadFilterButton; * fSeedFilterButton, * fDownloadFilterButton;
IBOutlet NSSearchField * fSearchFilterField;
IBOutlet NSMenuItem * fNextInfoTabItem, * fPrevInfoTabItem; IBOutlet NSMenuItem * fNextInfoTabItem, * fPrevInfoTabItem;
@ -133,7 +134,7 @@
- (void) sortTorrents; - (void) sortTorrents;
- (void) sortTorrentsIgnoreSelected; - (void) sortTorrentsIgnoreSelected;
- (void) setSort: (id) sender; - (void) setSort: (id) sender;
- (void) applyFilter; - (void) applyFilter: (id) sender;
- (void) setFilter: (id) sender; - (void) setFilter: (id) sender;
- (void) toggleSpeedLimit: (id) sender; - (void) toggleSpeedLimit: (id) sender;

View file

@ -314,7 +314,7 @@ static void sleepCallBack(void * controller, io_service_t y,
selector: @selector(checkAutoImportDirectory:) userInfo: nil repeats: YES]; selector: @selector(checkAutoImportDirectory:) userInfo: nil repeats: YES];
[[NSRunLoop currentRunLoop] addTimer: fAutoImportTimer forMode: NSDefaultRunLoopMode]; [[NSRunLoop currentRunLoop] addTimer: fAutoImportTimer forMode: NSDefaultRunLoopMode];
[self applyFilter]; [self applyFilter: nil];
[fWindow makeKeyAndOrderFront: nil]; [fWindow makeKeyAndOrderFront: nil];
@ -474,7 +474,7 @@ static void sleepCallBack(void * controller, io_service_t y,
[self torrentNumberChanged]; [self torrentNumberChanged];
[self updateUI: nil]; [self updateUI: nil];
[self applyFilter]; [self applyFilter: nil];
[self updateTorrentHistory]; [self updateTorrentHistory];
} }
@ -547,7 +547,7 @@ static void sleepCallBack(void * controller, io_service_t y,
[torrents makeObjectsPerformSelector: @selector(startTransfer)]; [torrents makeObjectsPerformSelector: @selector(startTransfer)];
[self updateUI: nil]; [self updateUI: nil];
[self applyFilter]; [self applyFilter: nil];
[fInfoController updateInfoStatsAndSettings]; [fInfoController updateInfoStatsAndSettings];
[self updateTorrentHistory]; [self updateTorrentHistory];
} }
@ -573,7 +573,7 @@ static void sleepCallBack(void * controller, io_service_t y,
[torrents makeObjectsPerformSelector: @selector(stopTransfer)]; [torrents makeObjectsPerformSelector: @selector(stopTransfer)];
[self updateUI: nil]; [self updateUI: nil];
[self applyFilter]; [self applyFilter: nil];
[fInfoController updateInfoStatsAndSettings]; [fInfoController updateInfoStatsAndSettings];
[self updateTorrentHistory]; [self updateTorrentHistory];
} }
@ -840,7 +840,7 @@ static void sleepCallBack(void * controller, io_service_t y,
if ([torrent justFinished]) if ([torrent justFinished])
{ {
[self applyFilter]; [self applyFilter: nil];
[self checkToStartWaiting: torrent]; [self checkToStartWaiting: torrent];
[GrowlApplicationBridge notifyWithTitle: @"Download Complete" [GrowlApplicationBridge notifyWithTitle: @"Download Complete"
@ -991,7 +991,7 @@ static void sleepCallBack(void * controller, io_service_t y,
[self sortTorrents]; [self sortTorrents];
} }
- (void) applyFilter - (void) applyFilter: (id) sender
{ {
//remember selected rows if needed //remember selected rows if needed
NSArray * selectedTorrents = [fTableView numberOfSelectedRows] > 0 NSArray * selectedTorrents = [fTableView numberOfSelectedRows] > 0
@ -1026,6 +1026,16 @@ static void sleepCallBack(void * controller, io_service_t y,
else else
[tempTorrents setArray: fTorrents]; [tempTorrents setArray: fTorrents];
NSString * searchString = [fSearchFilterField stringValue];
if (![searchString isEqualToString: @""])
{
int i;
for (i = [tempTorrents count] - 1; i >= 0; i--)
if ([[[tempTorrents objectAtIndex: i] name] rangeOfString: searchString
options: NSCaseInsensitiveSearch].location == NSNotFound)
[tempTorrents removeObjectAtIndex: i];
}
[fFilteredTorrents setArray: tempTorrents]; [fFilteredTorrents setArray: tempTorrents];
[tempTorrents release]; [tempTorrents release];
@ -1078,7 +1088,7 @@ static void sleepCallBack(void * controller, io_service_t y,
[fDefaults setObject: fFilterType forKey: @"Filter"]; [fDefaults setObject: fFilterType forKey: @"Filter"];
} }
[self applyFilter]; [self applyFilter: nil];
} }
- (void) toggleSpeedLimit: (id) sender - (void) toggleSpeedLimit: (id) sender
@ -1198,7 +1208,7 @@ static void sleepCallBack(void * controller, io_service_t y,
{ {
[torrentToStart startTransfer]; [torrentToStart startTransfer];
[self applyFilter]; [self applyFilter: nil];
[self updateUI: nil]; [self updateUI: nil];
[fInfoController updateInfoStatsAndSettings]; [fInfoController updateInfoStatsAndSettings];
[self updateTorrentHistory]; [self updateTorrentHistory];
@ -1209,7 +1219,7 @@ static void sleepCallBack(void * controller, io_service_t y,
{ {
[self attemptToStartMultipleAuto: [notification object]]; [self attemptToStartMultipleAuto: [notification object]];
[self applyFilter]; [self applyFilter: nil];
[self updateUI: nil]; [self updateUI: nil];
[fInfoController updateInfoStatsAndSettings]; [fInfoController updateInfoStatsAndSettings];
[self updateTorrentHistory]; [self updateTorrentHistory];
@ -1219,7 +1229,7 @@ static void sleepCallBack(void * controller, io_service_t y,
{ {
[self attemptToStartMultipleAuto: fTorrents]; [self attemptToStartMultipleAuto: fTorrents];
[self applyFilter]; [self applyFilter: nil];
[self updateUI: nil]; [self updateUI: nil];
[fInfoController updateInfoStatsAndSettings]; [fInfoController updateInfoStatsAndSettings];
[self updateTorrentHistory]; [self updateTorrentHistory];
@ -1227,7 +1237,7 @@ static void sleepCallBack(void * controller, io_service_t y,
- (void) torrentStoppedForRatio: (NSNotification *) notification - (void) torrentStoppedForRatio: (NSNotification *) notification
{ {
[self applyFilter]; [self applyFilter: nil];
[fInfoController updateInfoStatsAndSettings]; [fInfoController updateInfoStatsAndSettings];
[GrowlApplicationBridge notifyWithTitle: @"Seeding Complete" [GrowlApplicationBridge notifyWithTitle: @"Seeding Complete"
@ -1561,12 +1571,19 @@ static void sleepCallBack(void * controller, io_service_t y,
- (void) toggleFilterBar: (id) sender - (void) toggleFilterBar: (id) sender
{ {
if (!fFilterBarVisible)
[fSearchFilterField setEnabled: YES];
[self showFilterBar: !fFilterBarVisible animate: YES]; [self showFilterBar: !fFilterBarVisible animate: YES];
[fDefaults setBool: fFilterBarVisible forKey: @"FilterBar"]; [fDefaults setBool: fFilterBarVisible forKey: @"FilterBar"];
//disable filtering when hiding //disable filtering when hiding
if (!fFilterBarVisible) if (!fFilterBarVisible)
{
[fSearchFilterField setEnabled: NO];
[fSearchFilterField setStringValue: @""];
[self setFilter: fNoFilterButton]; [self setFilter: fNoFilterButton];
}
} }
- (void) showFilterBar: (BOOL) show animate: (BOOL) animate - (void) showFilterBar: (BOOL) show animate: (BOOL) animate

View file

@ -3,6 +3,7 @@
{CLASS = BarButton; LANGUAGE = ObjC; SUPERCLASS = NSImageView; }, {CLASS = BarButton; LANGUAGE = ObjC; SUPERCLASS = NSImageView; },
{ {
ACTIONS = { ACTIONS = {
applyFilter = id;
checkUpdate = id; checkUpdate = id;
copyTorrentFile = id; copyTorrentFile = id;
linkForums = id; linkForums = id;
@ -54,6 +55,7 @@
fRatioNotSetItem = NSMenuItem; fRatioNotSetItem = NSMenuItem;
fRatioSetItem = NSMenuItem; fRatioSetItem = NSMenuItem;
fScrollView = NSScrollView; fScrollView = NSScrollView;
fSearchFilterField = NSSearchField;
fSeedFilterButton = BarButton; fSeedFilterButton = BarButton;
fSmallViewItem = NSMenuItem; fSmallViewItem = NSMenuItem;
fSpeedLimitButton = NSButton; fSpeedLimitButton = NSButton;

View file

@ -11,7 +11,7 @@
<key>1480</key> <key>1480</key>
<string>364 490 420 60 0 0 1152 842 </string> <string>364 490 420 60 0 0 1152 842 </string>
<key>1603</key> <key>1603</key>
<string>188 407 477 65 0 0 1152 842 </string> <string>241 540 477 65 0 0 1152 842 </string>
<key>29</key> <key>29</key>
<string>9 780 451 44 0 0 1152 842 </string> <string>9 780 451 44 0 0 1152 842 </string>
<key>456</key> <key>456</key>
@ -31,8 +31,8 @@
<integer>3</integer> <integer>3</integer>
<key>IBOpenObjects</key> <key>IBOpenObjects</key>
<array> <array>
<integer>29</integer>
<integer>1603</integer> <integer>1603</integer>
<integer>29</integer>
</array> </array>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>8J135</string> <string>8J135</string>

Binary file not shown.

View file

@ -285,12 +285,10 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
BOOL highlighted = [self isHighlighted] && [[self highlightColorWithFrame: cellFrame inView: view] BOOL highlighted = [self isHighlighted] && [[self highlightColorWithFrame: cellFrame inView: view]
isEqual: [NSColor alternateSelectedControlColor]]; isEqual: [NSColor alternateSelectedControlColor]];
NSDictionary * nameAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: NSDictionary * nameAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
highlighted ? [NSColor whiteColor] : [NSColor blackColor], highlighted ? [NSColor whiteColor] : [NSColor blackColor], NSForegroundColorAttributeName,
NSForegroundColorAttributeName,
[NSFont messageFontOfSize: 12.0], NSFontAttributeName, nil]; [NSFont messageFontOfSize: 12.0], NSFontAttributeName, nil];
NSDictionary * statusAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: NSDictionary * statusAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
highlighted ? [NSColor whiteColor] : [NSColor darkGrayColor], highlighted ? [NSColor whiteColor] : [NSColor darkGrayColor], NSForegroundColorAttributeName,
NSForegroundColorAttributeName,
[NSFont messageFontOfSize: 9.0], NSFontAttributeName, nil]; [NSFont messageFontOfSize: 9.0], NSFontAttributeName, nil];
NSPoint pen = cellFrame.origin; NSPoint pen = cellFrame.origin;