Temporarily disabled drag and drop until it's working properly

Fixed issues with clearing the trash
This commit is contained in:
michael starke
2013-07-10 01:20:08 +02:00
parent c34d840e35
commit 75c9aa6873
7 changed files with 57 additions and 40 deletions

View File

@@ -32,6 +32,5 @@ APPKIT_EXTERN NSString *const MPEntryNotesUndoableKey;
- (void)deleteUndoable; - (void)deleteUndoable;
- (void)moveToGroupUndoable:(KdbGroup *)group atIndex:(NSUInteger)index; - (void)moveToGroupUndoable:(KdbGroup *)group atIndex:(NSUInteger)index;
- (void)moveToTrashUndoable:(KdbGroup *)trash atIndex:(NSUInteger)index; - (void)moveToTrashUndoable:(KdbGroup *)trash atIndex:(NSUInteger)index;
- (void)restoreFromTrashUndoable:(KdbGroup *)group atIndex:(NSUInteger)index;
@end @end

View File

@@ -20,7 +20,7 @@ NSString *const MPEntryNotesUndoableKey = @"notesUndoable";
#ifndef MPSetActionName #ifndef MPSetActionName
#define MPSetActionName(key, comment) \ #define MPSetActionName(key, comment) \
if(![[self undoManager] isUndoing]) {\ 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 #endif
@@ -52,14 +52,22 @@ if(![[self undoManager] isUndoing]) {\
- (void)setTitleUndoable:(NSString *)title { - (void)setTitleUndoable:(NSString *)title {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.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 setLastModificationTime:[NSDate date]];
[self setTitle:title]; [self setTitle:title];
} }
- (void)setUsernameUndoable:(NSString *)username { - (void)setUsernameUndoable:(NSString *)username {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setUsernameUndoable:) object:self.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 setLastModificationTime:[NSDate date]];
[self setUsername:username]; [self setUsername:username];
} }
@@ -67,6 +75,11 @@ if(![[self undoManager] isUndoing]) {\
- (void)setPasswordUndoable:(NSString *)password { - (void)setPasswordUndoable:(NSString *)password {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setPasswordUndoable:) object:self.password]; [[self undoManager] registerUndoWithTarget:self selector:@selector(setPasswordUndoable:) object:self.password];
MPSetActionName(@"SET_PASSWORT", "Undo set password"); MPSetActionName(@"SET_PASSWORT", "Undo set password");
if(![[self undoManager] isUndoing]) {
[[self undoManager] setActionName:NSLocalizedString(@"SET_TITLE", "Set Title")];
}
[self setLastModificationTime:[NSDate date]]; [self setLastModificationTime:[NSDate date]];
[self setPassword:password]; [self setPassword:password];
} }
@@ -74,6 +87,11 @@ if(![[self undoManager] isUndoing]) {\
- (void)setUrlUndoable:(NSString *)url { - (void)setUrlUndoable:(NSString *)url {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setUrlUndoable:) object:self.url]; [[self undoManager] registerUndoWithTarget:self selector:@selector(setUrlUndoable:) object:self.url];
MPSetActionName(@"SET_URL", "Undo set URL"); MPSetActionName(@"SET_URL", "Undo set URL");
if(![[self undoManager] isUndoing]) {
[[self undoManager] setActionName:NSLocalizedString(@"SET_TITLE", "Set Title")];
}
[self setLastModificationTime:[NSDate date]]; [self setLastModificationTime:[NSDate date]];
[self setUrl:url]; [self setUrl:url];
} }
@@ -81,6 +99,11 @@ if(![[self undoManager] isUndoing]) {\
- (void)setNotesUndoable:(NSString *)notes { - (void)setNotesUndoable:(NSString *)notes {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setNotesUndoable:) object:self.notes]; [[self undoManager] registerUndoWithTarget:self selector:@selector(setNotesUndoable:) object:self.notes];
MPSetActionName(@"SET_NOTES", "Set Notes"); MPSetActionName(@"SET_NOTES", "Set Notes");
if(![[self undoManager] isUndoing]) {
[[self undoManager] setActionName:NSLocalizedString(@"SET_TITLE", "Set Title")];
}
[self setLastModificationTime:[NSDate date]]; [self setLastModificationTime:[NSDate date]];
[self setNotes:notes]; [self setNotes:notes];
} }
@@ -94,39 +117,24 @@ if(![[self undoManager] isUndoing]) {\
return; // We're not in our parents entries list return; // We're not in our parents entries list
} }
[[[self undoManager] prepareWithInvocationTarget:self.parent] addEntryUndoable:self atIndex:oldIndex]; [[[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]; [[NSNotificationCenter defaultCenter] postNotificationName:@"" object:self userInfo:nil];
[self.parent removeObjectFromEntriesAtIndex:oldIndex]; [self.parent removeObjectFromEntriesAtIndex:oldIndex];
} }
- (void)moveToGroupUndoable:(KdbGroup *)group atIndex:(NSUInteger)index { - (void)moveToGroupUndoable:(KdbGroup *)group atIndex:(NSUInteger)index {
if(!group || !self.parent) { [self _moveToGroup:group atIndex:index actionName:NSLocalizedString(@"MOVE_ENTRY", "Move Group")];
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];
} }
- (void)moveToTrashUndoable:(KdbGroup *)trash atIndex:(NSUInteger)index { - (void)moveToTrashUndoable:(KdbGroup *)trash atIndex:(NSUInteger)index {
if(!trash || !self.parent) { [self _moveToGroup:trash atIndex:index actionName:NSLocalizedString(@"MOVE_ENTRY_TO_TRASH", "Move Entryo to Trash")];
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];
} }
- (void)restoreFromTrashUndoable:(KdbGroup *)group atIndex:(NSUInteger)index { - (void)_moveToGroup:(KdbGroup *)group atIndex:(NSUInteger)index actionName:(NSString *)name {
if(!group || !self.parent) { if(!group || !self.parent) {
return; // Nothing to be moved about return; // Nothing to be moved about
} }
@@ -134,11 +142,16 @@ if(![[self undoManager] isUndoing]) {\
if(oldIndex == NSNotFound) { if(oldIndex == NSNotFound) {
return; // Not found in entries of parent! return; // Not found in entries of parent!
} }
[[[self undoManager] prepareWithInvocationTarget:self] moveToTrashUndoable:self.parent atIndex:oldIndex]; [[[self undoManager] prepareWithInvocationTarget:self] _moveToGroup:self.parent atIndex:oldIndex actionName:name];
MPSetActionName(@"RESTORE_ENTRY", "Restore Entry from Trash")
if(![[self undoManager] isUndoing]) {
[[self undoManager] setActionName:name];
}
[self.parent removeObjectFromEntriesAtIndex:oldIndex]; [self.parent removeObjectFromEntriesAtIndex:oldIndex];
[group insertObject:self inEntriesAtIndex:index]; [group insertObject:self inEntriesAtIndex:index];
} }
@end @end

View File

@@ -24,13 +24,12 @@
} }
- (void)clear { - (void)clear {
for(KdbGroup *group in self.groups) { NSUInteger groupCount = [_groups count];
[group clear]; for(NSInteger index = (groupCount - 1); index > -1; index--) {
NSUInteger index = [self.groups indexOfObject:group];
[self removeObjectFromGroupsAtIndex:index]; [self removeObjectFromGroupsAtIndex:index];
} }
for(KdbEntry *entry in self.entries) { NSUInteger entryCount = [_entries count];
NSUInteger index = [self.entries indexOfObject:entry]; for(NSInteger index = (entryCount - 1); index > -1; index--) {
[self removeObjectFromEntriesAtIndex:index]; [self removeObjectFromEntriesAtIndex:index];
} }
} }

View File

@@ -408,8 +408,14 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
#pragma mark Actions #pragma mark Actions
- (void)emptyTrash:(id)sender { - (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]; [self.trash clear];
// TODO: Notify that entries should be deslected
} }
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem { - (BOOL)validateMenuItem:(NSMenuItem *)menuItem {

View File

@@ -124,7 +124,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
[self.entryTable setDoubleAction:@selector(_columnDoubleClick:)]; [self.entryTable setDoubleAction:@selector(_columnDoubleClick:)];
[self.entryTable setTarget:self]; [self.entryTable setTarget:self];
[self.entryTable setFloatsGroupRows:NO]; [self.entryTable setFloatsGroupRows:NO];
[self.entryTable registerForDraggedTypes:@[MPPasteBoardType]]; //[self.entryTable registerForDraggedTypes:@[MPPasteBoardType]];
[self _setupEntryMenu]; [self _setupEntryMenu];
NSTableColumn *parentColumn = [self.entryTable tableColumns][0]; NSTableColumn *parentColumn = [self.entryTable tableColumns][0];

View File

@@ -64,7 +64,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
[_outlineView setMenu:[self _contextMenu]]; [_outlineView setMenu:[self _contextMenu]];
[_outlineView setAllowsEmptySelection:YES]; [_outlineView setAllowsEmptySelection:YES];
[_outlineView setFloatsGroupRows:NO]; [_outlineView setFloatsGroupRows:NO];
[_outlineView registerForDraggedTypes:@[ MPPasteBoardType ]]; //[_outlineView registerForDraggedTypes:@[ MPPasteBoardType ]];
[_outlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES]; [_outlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES];
[_bottomBar setBorderType:HNHBorderTop]; [_bottomBar setBorderType:HNHBorderTop];
[_addGroupButton setAction:[MPActionHelper actionOfType:MPActionAddGroup]]; [_addGroupButton setAction:[MPActionHelper actionOfType:MPActionAddGroup]];

View File

@@ -48,7 +48,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2331</string> <string>2335</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string> <string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>