From 75c9aa68736965b327c7a90e1961899819105130 Mon Sep 17 00:00:00 2001 From: michael starke Date: Wed, 10 Jul 2013 01:20:08 +0200 Subject: [PATCH] Temporarily disabled drag and drop until it's working properly Fixed issues with clearing the trash --- MacPass/KdbEntry+Undo.h | 1 - MacPass/KdbEntry+Undo.m | 73 ++++++++++++++++++------------- MacPass/KdbGroup+MPAdditions.m | 9 ++-- MacPass/MPDocument.m | 8 +++- MacPass/MPEntryViewController.m | 2 +- MacPass/MPOutlineViewController.m | 2 +- MacPass/MacPass-Info.plist | 2 +- 7 files changed, 57 insertions(+), 40 deletions(-) diff --git a/MacPass/KdbEntry+Undo.h b/MacPass/KdbEntry+Undo.h index 69ca3c8f..5c80cb13 100644 --- a/MacPass/KdbEntry+Undo.h +++ b/MacPass/KdbEntry+Undo.h @@ -32,6 +32,5 @@ APPKIT_EXTERN NSString *const MPEntryNotesUndoableKey; - (void)deleteUndoable; - (void)moveToGroupUndoable:(KdbGroup *)group atIndex:(NSUInteger)index; - (void)moveToTrashUndoable:(KdbGroup *)trash atIndex:(NSUInteger)index; -- (void)restoreFromTrashUndoable:(KdbGroup *)group atIndex:(NSUInteger)index; @end diff --git a/MacPass/KdbEntry+Undo.m b/MacPass/KdbEntry+Undo.m index 8e69aaac..0b05b7c9 100644 --- a/MacPass/KdbEntry+Undo.m +++ b/MacPass/KdbEntry+Undo.m @@ -20,7 +20,7 @@ NSString *const MPEntryNotesUndoableKey = @"notesUndoable"; #ifndef MPSetActionName #define MPSetActionName(key, comment) \ if(![[self undoManager] isUndoing]) {\ - [[self undoManager] setActionName:[[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]];\ +[[self undoManager] setActionName:[[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]];\ } #endif @@ -52,14 +52,22 @@ if(![[self undoManager] isUndoing]) {\ - (void)setTitleUndoable:(NSString *)title { [[self undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.title]; - MPSetActionName(@"SET_TITLE", "Set Title"); + + if(![[self undoManager] isUndoing]) { + [[self undoManager] setActionName:NSLocalizedString(@"SET_TITLE", "Set Title")]; + } + [self setLastModificationTime:[NSDate date]]; [self setTitle:title]; } - (void)setUsernameUndoable:(NSString *)username { [[self undoManager] registerUndoWithTarget:self selector:@selector(setUsernameUndoable:) object:self.username]; - MPSetActionName(@"SET_USERNAME", "Undo set username"); + + if(![[self undoManager] isUndoing]) { + [[self undoManager] setActionName:NSLocalizedString(@"SET_USERNAME", "Undo set username")]; + } + [self setLastModificationTime:[NSDate date]]; [self setUsername:username]; } @@ -67,6 +75,11 @@ if(![[self undoManager] isUndoing]) {\ - (void)setPasswordUndoable:(NSString *)password { [[self undoManager] registerUndoWithTarget:self selector:@selector(setPasswordUndoable:) object:self.password]; MPSetActionName(@"SET_PASSWORT", "Undo set password"); + + if(![[self undoManager] isUndoing]) { + [[self undoManager] setActionName:NSLocalizedString(@"SET_TITLE", "Set Title")]; + } + [self setLastModificationTime:[NSDate date]]; [self setPassword:password]; } @@ -74,6 +87,11 @@ if(![[self undoManager] isUndoing]) {\ - (void)setUrlUndoable:(NSString *)url { [[self undoManager] registerUndoWithTarget:self selector:@selector(setUrlUndoable:) object:self.url]; MPSetActionName(@"SET_URL", "Undo set URL"); + + if(![[self undoManager] isUndoing]) { + [[self undoManager] setActionName:NSLocalizedString(@"SET_TITLE", "Set Title")]; + } + [self setLastModificationTime:[NSDate date]]; [self setUrl:url]; } @@ -81,6 +99,11 @@ if(![[self undoManager] isUndoing]) {\ - (void)setNotesUndoable:(NSString *)notes { [[self undoManager] registerUndoWithTarget:self selector:@selector(setNotesUndoable:) object:self.notes]; MPSetActionName(@"SET_NOTES", "Set Notes"); + + if(![[self undoManager] isUndoing]) { + [[self undoManager] setActionName:NSLocalizedString(@"SET_TITLE", "Set Title")]; + } + [self setLastModificationTime:[NSDate date]]; [self setNotes:notes]; } @@ -94,39 +117,24 @@ if(![[self undoManager] isUndoing]) {\ return; // We're not in our parents entries list } [[[self undoManager] prepareWithInvocationTarget:self.parent] addEntryUndoable:self atIndex:oldIndex]; - MPSetActionName(@"DELETE_ENTRY", "Delete Entry"); + + if(![[self undoManager] isUndoing]) { + [[self undoManager] setActionName:NSLocalizedString(@"DELETE_ENTRY", "Set Title")]; + } + [[NSNotificationCenter defaultCenter] postNotificationName:@"" object:self userInfo:nil]; [self.parent removeObjectFromEntriesAtIndex:oldIndex]; } - (void)moveToGroupUndoable:(KdbGroup *)group atIndex:(NSUInteger)index { - if(!group || !self.parent) { - return; // Nothing to be moved about - } - NSUInteger oldIndex = [self.parent.entries indexOfObject:self]; - if(oldIndex == NSNotFound) { - return; // Not found in entries of parent! - } - [[[self undoManager] prepareWithInvocationTarget:self] moveToGroupUndoable:self.parent atIndex:oldIndex]; - MPSetActionName(@"MOVE_ENTRY", "Move Entry") - [self.parent removeObjectFromEntriesAtIndex:oldIndex]; - [group insertObject:self inEntriesAtIndex:index]; + [self _moveToGroup:group atIndex:index actionName:NSLocalizedString(@"MOVE_ENTRY", "Move Group")]; } + - (void)moveToTrashUndoable:(KdbGroup *)trash atIndex:(NSUInteger)index { - if(!trash || !self.parent) { - return; // Nothing to be moved about - } - NSUInteger oldIndex = [self.parent.entries indexOfObject:self]; - if(oldIndex == NSNotFound) { - return; // Not found in entries of parent! - } - [[[self undoManager] prepareWithInvocationTarget:self] restoreFromTrashUndoable:self.parent atIndex:oldIndex]; - MPSetActionName(@"MOVE_ENTRY_TO_TRASH", "Move Entryo to Trash") - [self.parent removeObjectFromEntriesAtIndex:oldIndex]; - [trash insertObject:self inEntriesAtIndex:index]; + [self _moveToGroup:trash atIndex:index actionName:NSLocalizedString(@"MOVE_ENTRY_TO_TRASH", "Move Entryo to Trash")]; } -- (void)restoreFromTrashUndoable:(KdbGroup *)group atIndex:(NSUInteger)index { +- (void)_moveToGroup:(KdbGroup *)group atIndex:(NSUInteger)index actionName:(NSString *)name { if(!group || !self.parent) { return; // Nothing to be moved about } @@ -134,11 +142,16 @@ if(![[self undoManager] isUndoing]) {\ if(oldIndex == NSNotFound) { return; // Not found in entries of parent! } - [[[self undoManager] prepareWithInvocationTarget:self] moveToTrashUndoable:self.parent atIndex:oldIndex]; - MPSetActionName(@"RESTORE_ENTRY", "Restore Entry from Trash") + [[[self undoManager] prepareWithInvocationTarget:self] _moveToGroup:self.parent atIndex:oldIndex actionName:name]; + + if(![[self undoManager] isUndoing]) { + [[self undoManager] setActionName:name]; + } + [self.parent removeObjectFromEntriesAtIndex:oldIndex]; [group insertObject:self inEntriesAtIndex:index]; - } + + @end \ No newline at end of file diff --git a/MacPass/KdbGroup+MPAdditions.m b/MacPass/KdbGroup+MPAdditions.m index 6904e672..655d8363 100644 --- a/MacPass/KdbGroup+MPAdditions.m +++ b/MacPass/KdbGroup+MPAdditions.m @@ -24,13 +24,12 @@ } - (void)clear { - for(KdbGroup *group in self.groups) { - [group clear]; - NSUInteger index = [self.groups indexOfObject:group]; + NSUInteger groupCount = [_groups count]; + for(NSInteger index = (groupCount - 1); index > -1; index--) { [self removeObjectFromGroupsAtIndex:index]; } - for(KdbEntry *entry in self.entries) { - NSUInteger index = [self.entries indexOfObject:entry]; + NSUInteger entryCount = [_entries count]; + for(NSInteger index = (entryCount - 1); index > -1; index--) { [self removeObjectFromEntriesAtIndex:index]; } } diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 1d7ac9bb..a5a2ce6c 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -408,8 +408,14 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; #pragma mark Actions - (void)emptyTrash:(id)sender { + for(KdbEntry *entry in [self.trash childEntries]) { + [[self undoManager] removeAllActionsWithTarget:entry]; + } + for(KdbGroup *group in [self.trash childGroups]) { + [[self undoManager] removeAllActionsWithTarget:group]; + } + [self.trash clear]; - // TODO: Notify that entries should be deslected } - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index a5b01997..cacbf81a 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -124,7 +124,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; [self.entryTable setDoubleAction:@selector(_columnDoubleClick:)]; [self.entryTable setTarget:self]; [self.entryTable setFloatsGroupRows:NO]; - [self.entryTable registerForDraggedTypes:@[MPPasteBoardType]]; + //[self.entryTable registerForDraggedTypes:@[MPPasteBoardType]]; [self _setupEntryMenu]; NSTableColumn *parentColumn = [self.entryTable tableColumns][0]; diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index d441a425..cd8184fc 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -64,7 +64,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; [_outlineView setMenu:[self _contextMenu]]; [_outlineView setAllowsEmptySelection:YES]; [_outlineView setFloatsGroupRows:NO]; - [_outlineView registerForDraggedTypes:@[ MPPasteBoardType ]]; + //[_outlineView registerForDraggedTypes:@[ MPPasteBoardType ]]; [_outlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES]; [_bottomBar setBorderType:HNHBorderTop]; [_addGroupButton setAction:[MPActionHelper actionOfType:MPActionAddGroup]]; diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index c36c1b4f..80ee4e2e 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -48,7 +48,7 @@ CFBundleSignature ???? CFBundleVersion - 2331 + 2335 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright