Skip to content
This repository has been archived by the owner on Dec 20, 2017. It is now read-only.

Commit

Permalink
add tag to drop down
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Allen committed Mar 1, 2010
1 parent 7cf6637 commit 463acc3
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions MilkMaidWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "MilkMaidWindowController.h"
#define TOKEN @"Token"
#define LAST_LIST @"LastList"
#define TAGS @"Tags"

@implementation MilkMaidWindowController

Expand All @@ -21,7 +22,14 @@ -(void)awakeFromNib {
priority2Image = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"priority2" ofType:@"png"]];
priority3Image = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"priority3" ofType:@"png"]];

tagList = [[NSMutableArray alloc] init];
id tags = [[NSUserDefaults standardUserDefaults] objectForKey:TAGS];
if (tags) {
tagList = (NSMutableArray*)tags;
NSLog(@"%@", tagList);
} else {
tagList = [[NSMutableArray alloc] init];
}


[progress setForeColor:[NSColor whiteColor]];
[progress startAnimation:nil];
Expand Down Expand Up @@ -120,20 +128,31 @@ -(void)listSelected:(id)sender {
selectedIndex--;
if (selectedIndex != -1 && [currentList objectForKey:@"id"] != [[lists objectAtIndex:selectedIndex] objectForKey:@"id"]) {
currentList = [lists objectAtIndex:selectedIndex];
globalTaskAttributes = @"";
[[NSUserDefaults standardUserDefaults] setObject:[currentList objectForKey:@"name"] forKey:LAST_LIST];
[[taskScroll contentView] scrollToPoint:NSMakePoint(0, 0)];
[NSThread detachNewThreadSelector:@selector(getTasks) toTarget:self withObject:nil];

if ([[currentList objectForKey:@"type"] isEqualToString:@"search"]) {
globalTaskAttributes = [currentList objectForKey:@"globals"];
} else {
globalTaskAttributes = @"";
[[NSUserDefaults standardUserDefaults] setObject:[currentList objectForKey:@"name"] forKey:LAST_LIST];
}
[NSThread detachNewThreadSelector:@selector(getTasks) toTarget:self withObject:nil];
[currentList retain];
}
}

-(void)getTasksFromCurrentList {
[progress setHidden:NO];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDictionary *params = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:[currentList objectForKey:@"id"], @"status:incomplete", nil]
NSDictionary *params;
if ([[currentList objectForKey:@"type"] isEqualToString:@"search"]) {
NSString *filter = [NSString stringWithFormat:@"(%@) and status:incomplete", [currentList objectForKey:@"id"]];
params = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:filter, nil]
forKeys:[NSArray arrayWithObjects:@"filter", nil]];
} else {
params = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:[currentList objectForKey:@"id"], @"status:incomplete", nil]
forKeys:[NSArray arrayWithObjects:@"list_id", @"filter", nil]];
}
NSDictionary *data = [rtmController dataByCallingMethod:@"rtm.tasks.getList" andParameters:params withToken:YES];

RTMHelper *rtmHelper = [[RTMHelper alloc] init];
Expand All @@ -150,8 +169,12 @@ -(void)getTasksFromCurrentList {

-(void)searchTasks:(NSString*)searchString {
[progress setHidden:NO];
[listPopUp selectItemAtIndex:0];
[[taskScroll contentView] scrollToPoint:NSMakePoint(0, 0)];
[listPopUp addItemWithTitle:searchString];
[listPopUp selectItemWithTitle:searchString];
[lists addObject:[[NSDictionary alloc] initWithObjectsAndKeys:searchString, @"id", searchString,
@"name", @"search", @"type", globalTaskAttributes, @"globals", nil]];

NSString *newSearch = [NSString stringWithFormat:@"(%@) AND status:incomplete", searchString];

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
Expand Down Expand Up @@ -249,6 +272,7 @@ -(void)addGlobalTags:(NSArray*)tags {
if (![tagList containsObject:tag])
[tagList addObject:tag];
}
[[NSUserDefaults standardUserDefaults] setObject:tagList forKey:TAGS];
}


Expand Down Expand Up @@ -298,7 +322,7 @@ -(void)addTask:(NSString*)task {

NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithObjects:[NSArray arrayWithObjects:timeline, task, @"1", nil]
forKeys:[NSArray arrayWithObjects:@"timeline", @"name", @"parse", nil]];
if (currentList) {
if (currentList && ![[currentList objectForKey:@"type"] isEqualToString:@"search"]) {
[params setObject:[currentList objectForKey:@"id"] forKey:@"list_id"];
}
[rtmController dataByCallingMethod:@"rtm.tasks.add" andParameters:params withToken:YES];
Expand Down

0 comments on commit 463acc3

Please sign in to comment.