Skip to content
Browse files

Merge branch 'master' of github.com:myellow/Less-2-Do

Conflicts:
	toodledo-objc
  • Loading branch information...
2 parents da68d9d + 4f2f08d commit b58da2aa6c0b1a550217b9b2dd2d6b09112747cd @myell0w committed
View
7 Classes/ContextsFirstLevelViewController.m
@@ -152,6 +152,13 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd
NSUInteger row = [indexPath row];
NSError *error;
Context *context = [list objectAtIndex:row];
+
+ for (Task *t in context.tasks) {
+ t.context = nil;
+ }
+
+ [context removeTasks:context.tasks];
+
DLog ("Try to delete Context '%@'", context.name);
[self.controllersSection1 removeObjectAtIndex:row];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
View
7 Classes/ContextsGPSViewController.m
@@ -58,6 +58,13 @@ - (void)viewDidLoad {
[super viewDidLoad];
}
+- (void)viewWillAppear:(BOOL)animated {
+ ALog ("ContextsGPSViewController appeared");
+ if(self.listViewController != nil)
+ [self.listViewController loadData];
+ [super viewWillAppear:animated];
+}
+
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
View
15 Classes/Entities/Context.m
@@ -117,8 +117,19 @@ + (NSArray *)getAllContextsInStore:(NSError **)error
+ (NSArray *) getAllContexts:(NSError **)error
{
- NSArray* objects = [Context getContextsWithFilterString:@"deleted == NO" error:error];
- return objects;
+ NSArray* objects = [Context getContextsWithFilterString:@"deleted == NO" error:error];
+
+ NSMutableArray *notDeleted = [NSMutableArray array];
+
+ for(Context *c in objects)
+ {
+ if([c.deleted boolValue] == NO)
+ {
+ [notDeleted addObject:c];
+ }
+ }
+
+ return [NSArray arrayWithArray:notDeleted];
}
+ (NSArray *)getRemoteStoredContexts:(NSError **)error
View
15 Classes/Entities/Folder.m
@@ -110,7 +110,20 @@ + (NSArray *)getAllFoldersInStore:(NSError **)error
+ (NSArray *) getAllFolders:(NSError **)error
{
NSArray* objects = [Folder getFoldersWithFilterString:@"deleted == NO" error:error];
- return objects;
+
+ NSMutableArray *notDeleted = [NSMutableArray array];
+
+ for(Folder *f in objects)
+ {
+ if([f.deleted boolValue] == NO)
+ {
+ [notDeleted addObject:f];
+ }
+ }
+
+ return [NSArray arrayWithArray:notDeleted];
+
+ //return objects;
}
+ (NSArray *)getFolderWithRGB:(NSNumber *)red green:(NSNumber *)green blue:(NSNumber *)blue error:(NSError *)error
View
10 Classes/FolderFirstLevelController.m
@@ -63,7 +63,7 @@ - (void)viewWillAppear:(BOOL)animated {
{
// for schleife objekte erzeugen und array addObject:currentContext
for (int i=0; i<[objects count]; i++) {
- Context *folder = [objects objectAtIndex:i];
+ Folder *folder = [objects objectAtIndex:i];
TasksListViewController *folderView = [[TasksListViewController alloc] initWithStyle:UITableViewStylePlain];
folderView.title = folder.name;
folderView.selector = @selector(getTasksInFolder:error:);
@@ -177,10 +177,16 @@ -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(N
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
-
NSUInteger row = [indexPath row];
NSError *error;
Folder *folder = [self.list objectAtIndex:row];
+
+ for (Task *t in folder.tasks) {
+ t.folder = nil;
+ }
+
+ [folder removeTasks:folder.tasks];
+
DLog ("Try to delete Folder '%@'", folder.name);
[self.controllersSection1 removeObjectAtIndex:row];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
View
2 Classes/HomeNavigationController.m
@@ -173,7 +173,7 @@ -(IBAction)syncButtonPressed:(id)sender
if(error == nil)
{
BOOL successful = NO;
- if(settings.preferToodleDo)
+ if([settings.preferToodleDo boolValue])
successful = [syncManager syncWithPreference:SyncPreferRemote error:&error];
else
successful = [syncManager syncWithPreference:SyncPreferLocal error:&error];
View
49 Classes/SyncManager.m
@@ -99,7 +99,7 @@ -(BOOL)syncWithPreference:(SyncPreference)preference error:(NSError**)error
/*
Führt eine Synchronisation durch, bei der im Falle gleicher Datensätze die lokale
Version bevorzugt wird.
-*/
+ */
-(BOOL)overwriteLocal:(NSError**)error
{
// 1. init members
@@ -183,7 +183,7 @@ -(BOOL)overwriteLocal:(NSError**)error
/*
Führt eine Synchronisation durch, bei der im Falle gleicher Datensätze die remote-
Version bevorzugt wird.
-*/
+ */
-(BOOL)overwriteRemote:(NSError**)error
{
// 1. init members
@@ -469,7 +469,7 @@ -(BOOL)syncFoldersPreferRemote
if([localFolder.remoteId integerValue] == remoteFolder.uid)
{
foundLocalEntity = YES;
-
+
localFolder.deleted = [NSNumber numberWithInteger:0]; // verhindere möglichen Löschvorgang
// überschreibe lokale Felder
localFolder.name = remoteFolder.title;
@@ -793,7 +793,7 @@ -(BOOL)syncTasksMatchDates
if([remoteTask.date_modified compare:localTask.lastLocalModification] == NSOrderedDescending || localTask.lastLocalModification == nil) // Remote aktueller als Folder
{
localTask.deleted = [NSNumber numberWithInteger:0]; // verhindere möglichen Löschvorgang
- // überschreibe lokale Felder
+ // überschreibe lokale Felder
localTask.lastSyncDate = currentDate;
localTask.name = remoteTask.title;
localTask.creationDate = remoteTask.date_created;
@@ -801,6 +801,16 @@ -(BOOL)syncTasksMatchDates
localTask.startDateAnnoy = remoteTask.date_start; // ???
localTask.dueDate = remoteTask.date_due;
+ NSMutableArray *tagsToRemove = [NSMutableArray array];
+ for(Tag *tag in localTask.tags)
+ {
+ [tagsToRemove addObject:tag];
+ }
+ for(Tag *tag in tagsToRemove)
+ {
+ [tag removeTasksObject:localTask];
+ }
+ [localTask removeTags:localTask.tags];
for(NSString *remoteTag in remoteTask.tags)
{
if(![remoteTag isEqualToString:@""])
@@ -820,6 +830,11 @@ -(BOOL)syncTasksMatchDates
}
}
+ if(localTask.folder != nil)
+ {
+ [localTask.folder removeTasksObject:localTask];
+ localTask.folder = nil;
+ }
Folder *folder = [Folder getFolderWithRemoteId:[NSNumber numberWithInteger:remoteTask.folder] error:&syncError];
if(syncError != nil)
return NO;
@@ -828,6 +843,12 @@ -(BOOL)syncTasksMatchDates
[folder addTasksObject:localTask];
[localTask setFolder:folder];
}
+
+ if(localTask.context != nil)
+ {
+ [localTask.context removeTasksObject:localTask];
+ localTask.context = nil;
+ }
Context *context = [Context getContextWithRemoteId:[NSNumber numberWithInteger:remoteTask.context] error:&syncError];
if(syncError != nil)
return NO;
@@ -852,7 +873,7 @@ -(BOOL)syncTasksMatchDates
else
{
[usedLocalEntityVersion addObject:localTask];
-
+
}
[localTasksWithRemoteId removeObject:localTask];
foundLocalEntity = YES;
@@ -917,6 +938,24 @@ -(BOOL)syncTasksMatchDates
}
}
+ // lösche alle remote gelöschten tasks, die nach der letzten lokalen änderung gelöscht wurden
+ NSArray *deletedTasks = [tdApi getDeleted:&syncError];
+ if(syncError != nil)
+ return NO;
+ for(GtdTask *deletedTask in deletedTasks)
+ {
+ for(int i=0;i<[localTasksWithRemoteId count];i++)
+ {
+ Task *localTask = [localTasksWithRemoteId objectAtIndex:i];
+ ALog(@"local task: %@ - date local %@ - date deleted %@", localTask, localTask.lastLocalModification, deletedTask.date_deleted);
+ if(deletedTask.uid == [localTask.remoteId integerValue] && [deletedTask.date_deleted compare:localTask.lastLocalModification] == NSOrderedDescending)
+ {
+ localTask.deleted = [NSNumber numberWithBool:YES];
+ [localTasksWithRemoteId removeObject:localTask];
+ }
+ }
+ }
+
// füge nun remote gelöschte task wieder hinzu, aber nur wenn sie nicht
// auch zufällig lokal als deleted gekennzeichnet wurden
for(int i=0;i<[localTasksWithRemoteId count];i++)
View
14 Classes/TagsFirstLevelController.m
@@ -147,12 +147,24 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd
NSUInteger row = [indexPath row];
NSError *error;
Tag *tag = [list objectAtIndex:row];
+
+ NSMutableArray *tasksToRemove = [NSMutableArray array];
+ for(Task *t in tag.tasks)
+ {
+ [tasksToRemove addObject:t];
+ }
+ for(Task *t in tasksToRemove)
+ {
+ [t removeTagsObject:tag];
+ }
+ [tag removeTasks:[NSSet setWithArray:tasksToRemove]];
+
DLog ("Try to delete Tag '%@'", tag.name);
[self.controllersSection1 removeObjectAtIndex:row];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
DLog ("Removed Tag '%@' from SectionController", tag.name);
- if(![BaseManagedObject deleteObject:tag error:&error]) {
+ if(![BaseManagedObject deleteObjectFromPersistentStore:tag error:&error]) {
ALog("Error occured while deleting Tag");
}
else
View
2 Less2Do.xcodeproj/project.pbxproj
@@ -1241,6 +1241,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@@ -1266,6 +1267,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
COPY_PHASE_STRIP = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",

0 comments on commit b58da2a

Please sign in to comment.
Something went wrong with that request. Please try again.