Removed unused Code

This commit is contained in:
michael starke
2013-07-20 16:42:35 +02:00
parent 030dbd5be7
commit e5e8d01dff
5 changed files with 23 additions and 39 deletions

View File

@@ -20,4 +20,6 @@
/* Returns the group with the UUID */
- (KdbGroup *)groupForUUID:(UUID *)uuid;
- (BOOL)isAnchestorOfGroup:(KdbGroup *)group;
@end

View File

@@ -49,4 +49,18 @@
return [filteredGroups lastObject];
}
- (BOOL)isAnchestorOfGroup:(KdbGroup *)group {
if(group == nil) {
return NO;
}
KdbGroup *ancestor = self.parent;
while(ancestor.parent) {
if(group == self) {
return YES;
}
ancestor = ancestor.parent;
}
return NO;
}
@end

View File

@@ -83,7 +83,6 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
/*
All non-setter undoable actions
*/
- (BOOL)group:(KdbGroup *)group isMoveableToGroup:(KdbGroup *)target;
/* TODO in UNDO auslagen */
- (void)addStringField:(StringField *)field toEntry:(Kdb4Entry *)entry atIndex:(NSUInteger)index;

View File

@@ -347,6 +347,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
if(!parent) {
return nil; // No parent
}
if(parent == self.trash) {
return nil; // no new Groups in trash
}
KdbEntry *newEntry = [self.tree createEntry:parent];
newEntry.title = NSLocalizedString(@"DEFAULT_ENTRY_TITLE", @"Title for a newly created entry");
if(self.treeV4 && ([self.treeV4.defaultUserName length] > 0)) {
@@ -362,6 +365,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
if(!parent) {
return nil; // no parent!
}
if(parent == self.trash) {
return nil; // no new Groups in trash
}
KdbGroup *newGroup = [self.tree createGroup:parent];
newGroup.name = NSLocalizedString(@"DEFAULT_GROUP_NAME", @"Title for a newly created group");
newGroup.image = MPIconFolder;
@@ -385,42 +391,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
return newStringField;
}
- (void)moveGroup:(KdbGroup *)group toGroup:(KdbGroup *)target index:(NSInteger)index {
NSInteger oldIndex = [group.parent.groups indexOfObject:group];
if(group.parent == target && oldIndex == index) {
return; // No changes
}
[[[self undoManager] prepareWithInvocationTarget:self] moveGroup:group toGroup:group.parent index:oldIndex];
if(self.trash == target) {
[[self undoManager] setActionName:@"UNDO_DELETE_GROUP"];
}
else {
[[self undoManager] setActionName:@"MOVE_GROUP"];
}
[group.parent removeObjectFromGroupsAtIndex:oldIndex];
if(index < 0 || index > [target.groups count] ) {
index = [target.groups count];
}
[target insertObject:group inGroupsAtIndex:index];
}
- (BOOL)group:(KdbGroup *)group isMoveableToGroup:(KdbGroup *)target {
if(target == nil) {
return NO;
}
BOOL isMovable = YES;
KdbGroup *ancestor = target.parent;
while(ancestor.parent) {
if(ancestor == group) {
isMovable = NO;
break;
}
ancestor = ancestor.parent;
}
return isMovable;
}
- (void)deleteEntry:(KdbEntry *)entry {
if(self.useTrash) {
if(!self.trash) {

View File

@@ -77,8 +77,7 @@
accepted &= index != NSOutlineViewDropOnItemIndex;
accepted &= index != [_draggedItem.parent.groups indexOfObject:_draggedItem];
}
MPDocument *document = [[[outlineView window] windowController] document];
accepted = [document group:_draggedItem isMoveableToGroup:target];
accepted = ![_draggedItem isAnchestorOfGroup:target];
if( accepted ) {
[_draggedItem moveToGroupUndoable:target atIndex:index];
}