moved history display actino to MPDocument

This commit is contained in:
michael starke
2017-04-19 11:45:39 +02:00
parent 223bef5c6c
commit abdec9b2c0
4 changed files with 10 additions and 11 deletions

View File

@@ -14,7 +14,12 @@ NSString *const MPDocumentHideEntryHistoryNotification = @"MPDocumentHideEntryH
@implementation MPDocument (HistoryBrowsing)
- (void)showEntryHistory:(id)sender {
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentShowEntryHistoryNotification object:self];
id<MPTargetNodeResolving> resolver = [NSApp targetForAction:@selector(currentTargetEntries)];
NSArray *entries = resolver.currentTargetEntries;
if(entries.count != 1) {
return; // only single selection is used
}
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentShowEntryHistoryNotification object:self userInfo:@{ MPDocumentEntryKey: entries.firstObject }];
}
- (void)hideEntryHistory:(id)sender {

View File

@@ -222,6 +222,10 @@ FOUNDATION_EXPORT NSString *const MPDocumentGroupKey;
#pragma mark -
#pragma mark History Browsing
/**
* Posted by the document to signal a reqest for history display.
* the userInfo dictionary has one key MPDocumentEntryKey with the entry to display the history for
*/
FOUNDATION_EXPORT NSString *const MPDocumentShowEntryHistoryNotification;
FOUNDATION_EXPORT NSString *const MPDocumentHideEntryHistoryNotification;

View File

@@ -53,8 +53,6 @@
- (IBAction)pickExpiryDate:(id)sender;
- (IBAction)performAutotypeForEntry:(id)sender;
- (IBAction)showEntryHistory:(id)sender;
- (IBAction)hideEntryHistory:(id)sender;
#pragma mark Helper
- (IBAction)fixAutotype:(id)sender;

View File

@@ -495,14 +495,6 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
[contentView layoutSubtreeIfNeeded];
}
- (void)showEntryHistory:(id)sender {
id<MPTargetNodeResolving> resolver = [NSApp targetForAction:@selector(currentTargetEntries)];
NSArray *entries = resolver.currentTargetEntries;
if(entries.count != 1) {
return; // only single selection is used
}
}
#pragma mark Validation
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
return ([self.document validateMenuItem:menuItem]);