add revertToHistoryEntry action

This commit is contained in:
michael starke
2017-04-24 12:09:11 +02:00
parent 420f325dc1
commit d65c548f64
7 changed files with 22 additions and 7 deletions

View File

@@ -200,7 +200,7 @@
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
</buttonCell> </buttonCell>
<connections> <connections>
<action selector="restoreHistoryEntry:" target="-1" id="CI5-4s-85Z"/> <action selector="revertToHistoryEntry:" target="-1" id="n70-c5-0JJ"/>
</connections> </connections>
</button> </button>
</subviews> </subviews>

View File

@@ -14,6 +14,7 @@ typedef NS_ENUM(NSUInteger, MPActionType) {
MPActionAddGroup, // Add a new group MPActionAddGroup, // Add a new group
MPActionDuplicateEntry, // Simply duplicate an entry (including history) MPActionDuplicateEntry, // Simply duplicate an entry (including history)
MPActionDuplicateEntryWithOptions, // Request user input on what to duplicate MPActionDuplicateEntryWithOptions, // Request user input on what to duplicate
MPActionReverToHistoryEntry, // Restore an entry to an older state in history
MPActionDelete, // Delete entry or group MPActionDelete, // Delete entry or group
MPActionCopyUsername, // copy username to pasteboard MPActionCopyUsername, // copy username to pasteboard
MPActionCopyPassword, // copy password to pasteboard MPActionCopyPassword, // copy password to pasteboard

View File

@@ -23,6 +23,7 @@
@(MPActionAddGroup): NSStringFromSelector(@selector(createGroup:)), @(MPActionAddGroup): NSStringFromSelector(@selector(createGroup:)),
@(MPActionDuplicateEntry): NSStringFromSelector(@selector(duplicateEntry:)), @(MPActionDuplicateEntry): NSStringFromSelector(@selector(duplicateEntry:)),
@(MPActionDuplicateEntryWithOptions): NSStringFromSelector(@selector(duplicateEntryWithOptions:)), @(MPActionDuplicateEntryWithOptions): NSStringFromSelector(@selector(duplicateEntryWithOptions:)),
@(MPActionReverToHistoryEntry): NSStringFromSelector(@selector(revertToHistoryEntry::)),
@(MPActionCopyPassword): NSStringFromSelector(@selector(copyPassword:)), @(MPActionCopyPassword): NSStringFromSelector(@selector(copyPassword:)),
@(MPActionCopyURL): NSStringFromSelector(@selector(copyURL:)), @(MPActionCopyURL): NSStringFromSelector(@selector(copyURL:)),
@(MPActionCopyUsername): NSStringFromSelector(@selector(copyUsername:)), @(MPActionCopyUsername): NSStringFromSelector(@selector(copyUsername:)),

View File

@@ -32,7 +32,7 @@ NSString *const MPDocumentHideEntryHistoryNotification = @"MPDocumentHideEntryH
object:self]; object:self];
} }
- (void)restoreEntry:(KPKEntry *)entry toEntry:(KPKEntry *)historyEntry { - (void)revertEntry:(KPKEntry *)entry toEntry:(KPKEntry *)historyEntry {
[entry revertToEntry:historyEntry]; [entry revertToEntry:historyEntry];
[self.undoManager setActionName:NSLocalizedString(@"RESTORE_HISTORY_ENTRY", "Action to restore and Entry to a previous state of it's history")]; [self.undoManager setActionName:NSLocalizedString(@"RESTORE_HISTORY_ENTRY", "Action to restore and Entry to a previous state of it's history")];
} }

View File

@@ -233,6 +233,7 @@ FOUNDATION_EXPORT NSString *const MPDocumentHideEntryHistoryNotification;
- (IBAction)showEntryHistory:(id)sender; - (IBAction)showEntryHistory:(id)sender;
- (IBAction)hideEntryHistory:(id)sender; - (IBAction)hideEntryHistory:(id)sender;
- (IBAction)revertEntry:(KPKEntry *)entry toEntry:(KPKEntry *)historyEntry;
@end @end

View File

@@ -39,11 +39,15 @@ typedef NS_ENUM(NSUInteger, MPDisplayMode) {
- (void)registerNotificationsForDocument:(MPDocument *)document; - (void)registerNotificationsForDocument:(MPDocument *)document;
/* Copy/Paste */ /* Copy/Paste */
- (void)copyUsername:(id)sender; - (IBAction)copyUsername:(id)sender;
- (void)copyPassword:(id)sender; - (IBAction)copyPassword:(id)sender;
- (void)copyCustomAttribute:(id)sender; - (IBAction)copyCustomAttribute:(id)sender;
- (void)copyURL:(id)sender; - (IBAction)copyURL:(id)sender;
- (void)openURL:(id)sender; - (IBAction)openURL:(id)sender;
/* More Actions */
- (IBAction)delete:(id)sender;
- (IBAction)revertToHistoryEntry:(id)sender;
@end @end

View File

@@ -730,6 +730,14 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
} }
} }
- (void)revertToHistoryEntry:(id)sender {
MPDocument *document = self.windowController.document;
NSArray<KPKEntry *> *historyEntries = [self currentTargetEntries];
if(historyEntries.count != 1) {
return;
}
//[document restoreEntry:entry toEntry:historyEntries.firstObject];
}
- (void)_columnDoubleClick:(id)sender { - (void)_columnDoubleClick:(id)sender {
if(0 == [[self.entryArrayController arrangedObjects] count]) { if(0 == [[self.entryArrayController arrangedObjects] count]) {