update the group filter when groups are changed or removed

This commit is contained in:
Mitchell Livingston 2007-12-19 21:11:49 +00:00
parent c770135086
commit cc4eb2be94
5 changed files with 27 additions and 10 deletions

View File

@ -195,7 +195,8 @@
- (void) showGroups: (id) sender;
- (void) setGroup: (id) sender;
- (void) setGroupFilter: (id) sender;
- (void) updateGroupFilterButton;
- (void) updateGroupsFilterButton;
- (void) updateGroupsFilters: (NSNotification *) notification;
- (void) toggleSpeedLimit: (id) sender;
- (void) autoSpeedLimitChange: (NSNotification *) notification;

View File

@ -291,7 +291,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[fPauseFilterButton setFrame: pauseRect];
}
[self updateGroupFilterButton];
[self updateGroupsFilterButton];
//set up filter bar
NSView * contentView = [fWindow contentView];
@ -449,6 +449,10 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
//open newly created torrent file
[nc addObserver: self selector: @selector(openCreatedFile:)
name: @"OpenCreatedTorrentFile" object: nil];
//update when groups change
[nc addObserver: self selector: @selector(updateGroupsFilters:)
name: @"UpdateGroups" object: nil];
//timer to update the interface every second
[self updateUI];
@ -2105,11 +2109,11 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
- (void) setGroupFilter: (id) sender
{
[fDefaults setInteger: [sender tag] forKey: @"FilterGroup"];
[self updateGroupFilterButton];
[self updateGroupsFilterButton];
[self applyFilter: nil];
}
- (void) updateGroupFilterButton
- (void) updateGroupsFilterButton
{
int index = [fDefaults integerForKey: @"FilterGroup"];
@ -2136,6 +2140,12 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[fGroupsButton setToolTip: toolTip];
}
- (void) updateGroupsFilters: (NSNotification *) notification
{
[self updateGroupsFilterButton];
[self applyFilter: nil];
}
- (void) toggleSpeedLimit: (id) sender
{
[fDefaults setBool: ![fDefaults boolForKey: @"SpeedLimit"] forKey: @"SpeedLimit"];

View File

@ -192,6 +192,8 @@ GroupsWindowController * fGroupsWindowInstance = nil;
{
[[fGroups objectAtIndex: row] setObject: object forKey: @"Name"];
[self saveGroups];
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateGroups" object: self];
}
else if ([identifier isEqualToString: @"Button"])
{
@ -273,7 +275,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
[fTableView reloadData];
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateUI" object: self];
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateGroups" object: self];
}
return YES;
@ -330,13 +332,17 @@ GroupsWindowController * fGroupsWindowInstance = nil;
[[NSNotificationCenter defaultCenter] postNotificationName: @"GroupValueRemoved" object: self userInfo:
[NSDictionary dictionaryWithObject: indexes forKey: @"Indexes"]];
if ([indexes containsIndex: [[NSUserDefaults standardUserDefaults] integerForKey: @"FilterGroup"]])
[[NSUserDefaults standardUserDefaults] setInteger: -2 forKey: @"FilterGroup"];
break;
default:
return;
}
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateUI" object: self];
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateGroups" object: self];
[self saveGroups];
}
@ -390,7 +396,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
[fTableView reloadData];
[self saveGroups];
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateUI" object: self];
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateGroups" object: self];
}
- (NSImage *) imageForGroup: (NSDictionary *) dict isSmall: (BOOL) small

View File

@ -211,7 +211,7 @@ typedef enum
- (int) groupValue;
- (void) setGroupValue: (int) groupValue;
- (int) groupOrderValue;
- (void) checkGroupValue: (NSNotification *) notification;
- (void) checkGroupValueForRemoval: (NSNotification *) notification;
- (NSArray *) fileList;
- (int) fileCount;

View File

@ -1202,7 +1202,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
return [[GroupsWindowController groupsController] orderValueForIndex: fGroupValue];
}
- (void) checkGroupValue: (NSNotification *) notification
- (void) checkGroupValueForRemoval: (NSNotification *) notification
{
if (fGroupValue != -1 && [[[notification userInfo] objectForKey: @"Indexes"] containsIndex: fGroupValue])
fGroupValue = -1;
@ -1518,7 +1518,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
[self createFileList];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(checkGroupValue:)
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(checkGroupValueForRemoval:)
name: @"GroupValueRemoved" object: nil];
[self update];