Browse files

Make mark as done actions use edits instead of special flagging notes

  • Loading branch information...
1 parent 85eaca3 commit b34ea84099d71a81a35e3dbdda8cd10c05cc3b0b @richard richard committed Oct 12, 2009
View
6 Classes/Capture/NoteListController.m
@@ -198,11 +198,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
NSString *createdAtStr = [formatter stringFromDate:[note createdAt]];
[formatter release];
- if (note.flagAction && [note.flagAction length] > 0) {
- cell.detailTextLabel.text = [NSString stringWithFormat:@"F(%@) %@", note.flagAction, createdAtStr];
- } else {
- cell.detailTextLabel.text = [NSString stringWithFormat:@"F() %@", createdAtStr];
- }
+ cell.detailTextLabel.text = createdAtStr;
cell.accessoryType = UIButtonTypeDetailDisclosure;
View
1 Classes/DataModel/Node.h
@@ -65,6 +65,7 @@
- (void)collectLinks:(NSMutableArray*)links;
- (NSString*)htmlForDocumentViewLevel:(int)level;
- (NSString*)ownerFile;
+- (NSString*)bestDoneState;
@end
View
26 Classes/DataModel/Node.m
@@ -536,4 +536,30 @@ - (NSString*)ownerFile {
return nil;
}
+- (NSString*)bestDoneState {
+ NSString *ret = @"DONE";
+
+ // Default to the first DONE entry in the first todo state group
+ NSArray *todoStateGroup = [[[Settings instance] todoStateGroups] objectAtIndex:0];
+ if (todoStateGroup && [todoStateGroup count] > 1) {
+ if ([[todoStateGroup objectAtIndex:1] count] > 0) {
+ ret = [[todoStateGroup objectAtIndex:1] objectAtIndex:0];
+ }
+ }
+
+ // But prefer to use the first DONE entry in the todo state group that owns the current todostate
+ for (NSArray *todoStateGroup in [[Settings instance] todoStateGroups]) {
+ if ([todoStateGroup count] > 1) {
+ if ([[todoStateGroup objectAtIndex:0] containsObject:self.todoState] || [[todoStateGroup objectAtIndex:1] containsObject:self.todoState]) {
+ if ([[todoStateGroup objectAtIndex:1] count] > 0) {
+ ret = [[todoStateGroup objectAtIndex:1] objectAtIndex:0];
+ break;
+ }
+ }
+ }
+ }
+
+ return ret;
+}
+
@end
View
1 Classes/DataModel/Note.h
@@ -31,7 +31,6 @@
@property (nonatomic, retain) NSString * text;
@property (nonatomic, retain) NSDate * createdAt;
@property (nonatomic, retain) NSString * nodeId;
-@property (nonatomic, retain) NSString * flagAction;
@property (nonatomic, retain) NSString * noteId;
@property (nonatomic, retain) NSNumber * locallyModified;
@property (nonatomic, retain) NSNumber * deleted;
View
3 Classes/DataModel/Note.m
@@ -29,7 +29,6 @@ @implementation Note
@dynamic text;
@dynamic createdAt;
@dynamic nodeId;
-@dynamic flagAction;
@dynamic noteId;
@dynamic locallyModified;
@dynamic deleted;
@@ -38,7 +37,7 @@ - (NSString*)heading {
// If it is a flag entry, the flag part is the title, the rest is the body
if ([self isFlagEntry]) {
Node *node = ResolveNode(self.nodeId);
- return [NSString stringWithFormat:@"F(%@) [[%@][%@]]", self.flagAction, self.nodeId, [node headingForDisplay]];
+ return [NSString stringWithFormat:@"F() [[%@][%@]]", self.nodeId, [node headingForDisplay]];
}
if (!self.text || [self.text length] == 0) {
View
21 Classes/Outline/ActionMenuController.m
@@ -28,6 +28,7 @@
#import "Note.h"
#import "NoteListController.h"
#import "OutlineViewController.h"
+#import "LocalEditAction.h"
@implementation ActionMenuController
@@ -48,7 +49,6 @@ - (void)addFlag:(NSString*)action andEdit:(bool)edit {
Note *note = (Note*)[NSEntityDescription insertNewObjectForEntityForName:@"Note" inManagedObjectContext:[node managedObjectContext]];
note.nodeId = [node bestId];
note.createdAt = [NSDate date];
- note.flagAction = action;
note.noteId = UUID();
note.locallyModified = [NSNumber numberWithBool:true];
@@ -62,13 +62,28 @@ - (void)addFlag:(NSString*)action andEdit:(bool)edit {
}
}
+- (void)setTodoState:(NSString*)newState {
+ bool created;
+ LocalEditAction *action = FindOrCreateLocalEditActionForNode(@"edit:todo", node, &created);
+ if (created) {
+ action.oldValue = [node todoState];
+ }
+
+ action.newValue = newState;
+ action.nodeId = [node bestId];
+
+ node.todoState = newState;
+
+ Save();
+}
+
- (void)onDone {
- [self addFlag:@"d" andEdit:false];
+ [self setTodoState:[node bestDoneState]];
[self close];
}
- (void)onDoneAndArchive {
- [self addFlag:@"d-a" andEdit:false];
+ [self setTodoState:@"DONEARCHIVE"];
[self close];
}
View
2 Classes/Parsing/EditEntity.h
@@ -30,7 +30,6 @@
NSString *newValue;
NSString *heading;
NSString *noteId;
- NSString *flagAction;
NSDate *createdAt;
Node *node;
}
@@ -40,7 +39,6 @@
@property (nonatomic, copy) NSString *newValue;
@property (nonatomic, copy) NSString *heading;
@property (nonatomic, copy) NSString *noteId;
-@property (nonatomic, copy) NSString *flagAction;
@property (nonatomic, copy) NSDate *createdAt;
@property (nonatomic, retain) Node *node;
View
2 Classes/Parsing/EditEntity.m
@@ -28,7 +28,6 @@ @implementation EditEntity
@synthesize oldValue, newValue;
@synthesize heading;
@synthesize noteId;
-@synthesize flagAction;
@synthesize createdAt;
@synthesize node;
@@ -38,7 +37,6 @@ - (void)dealloc {
[newValue release];
[heading release];
[noteId release];
- [flagAction release];
[createdAt release];
[node release];
[super dealloc];
View
7 Classes/Parsing/EditsFileParser.m
@@ -144,12 +144,6 @@ - (void)parse {
}
}
- NSString *flagAction = @"";
- NSArray *flagActionCaptures = [line captureComponentsMatchedByRegex:@"F\\((.*)\\) .+"];
- if ([flagActionCaptures count] > 0) {
- flagAction = [flagActionCaptures objectAtIndex:1];
- }
-
// This means we are in a note or otherwise non-edit section of the outline
// In this case, we want to make a simple edit entry with no actionType, and
// get ready to accept the body
@@ -158,7 +152,6 @@ - (void)parse {
EditEntity *entity = [[EditEntity alloc] init];
[entity setEditAction:@""];
[entity setHeading:[line substringFromIndex:2]];
- [entity setFlagAction:flagAction];
[editEntities addObject:entity];
[entity release];
View
9 Classes/Parsing/OrgFileParser.m
@@ -83,6 +83,7 @@ - (void)parse {
Node *lastNode = nil;
int sequenceIndex = 1;
bool readOnlyFile = false;
+ bool addedDefaultTodoStates = false;
lines = [entireFile componentsSeparatedByString:@"\n"];
@@ -287,6 +288,14 @@ - (void)parse {
// Handle headings
if (numStars > 0) {
+ if (isIndex && !addedDefaultTodoStates) {
+ NSMutableArray *todoStateGroup = [NSMutableArray arrayWithCapacity:2];
+ [todoStateGroup addObject:[NSMutableArray arrayWithCapacity:0]];
+ [todoStateGroup addObject:[NSMutableArray arrayWithObject:@"DONEARCHIVE"]];
+ [[Settings instance] addTodoStateGroup:todoStateGroup];
+ addedDefaultTodoStates = true;
+ }
+
// The title is * THIS PART
NSString *title = [[line substringFromIndex:(numStars+1)] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
View
1 Classes/Sync/SyncManager.m
@@ -620,7 +620,6 @@ - (void)doneParsingEditsForApplication {
[newNote setCreatedAt:entity.createdAt];
[newNote setNoteId:entity.noteId];
[newNote setLocallyModified:[NSNumber numberWithBool:false]];
- [newNote setFlagAction:entity.flagAction];
NSString *text = @"";
if (entity.newValue && [entity.newValue length] > 0) {
text = [NSString stringWithFormat:@"%@\n%@", entity.heading, entity.newValue];
View
BIN MobileOrg.xcdatamodel/elements
Binary file not shown.
View
BIN MobileOrg.xcdatamodel/layout
Binary file not shown.

0 comments on commit b34ea84

Please sign in to comment.