mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 15:12:21 +00:00
Adopting new KeePassKit API.
Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
This commit is contained in:
Submodule KeePassKit updated: c36388419f...25b5fd840b
@@ -8,7 +8,7 @@
|
||||
|
||||
#import "MPDocument.h"
|
||||
|
||||
@class MPEditSession;
|
||||
@class MPEditingSession;
|
||||
|
||||
@interface MPDocument (EditingSession)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#import "MPDocument+EditingSession.h"
|
||||
|
||||
#import "KPKNode.h"
|
||||
#import "MPEditSession.h"
|
||||
#import "MPEditingSession.h"
|
||||
|
||||
@implementation MPDocument (EditingSession)
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
|
||||
#pragma mark Private
|
||||
- (void)_commitEditingSession:(MPEditSession *)session {
|
||||
- (void)_commitEditingSession:(MPEditingSession *)session {
|
||||
if(nil == session) {
|
||||
return; // No session to commit
|
||||
}
|
||||
@@ -35,13 +35,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_cancelEditingSession:(MPEditSession *)session {
|
||||
- (void)_cancelEditingSession:(MPEditingSession *)session {
|
||||
if(nil == session) {
|
||||
return; // No session to cancel
|
||||
}
|
||||
[[self.undoManager prepareWithInvocationTarget:self] _commitEditingSession:session];
|
||||
if(session.hasChanges) {
|
||||
[session.node updateTo:session.rollbackNode];
|
||||
[session.node updateToNode:session.rollbackNode];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
@class KPKAttribute;
|
||||
@class KPKCompositeKey;
|
||||
@class KPKNode;
|
||||
@class MPEditSession;
|
||||
@class MPEditingSession;
|
||||
|
||||
@interface MPDocument : NSDocument <MPTargetNodeResolving>
|
||||
|
||||
@@ -91,7 +91,7 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
/*
|
||||
Editing Session
|
||||
*/
|
||||
@property (nonatomic, strong) MPEditSession *editingSession;
|
||||
@property (nonatomic, strong) MPEditingSession *editingSession;
|
||||
|
||||
+ (KPKVersion)versionForFileType:(NSString *)fileType;
|
||||
+ (NSString *)fileTypeForVersion:(KPKVersion)version;
|
||||
|
||||
@@ -408,7 +408,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
- (void)setTree:(KPKTree *)tree {
|
||||
if(_tree != tree) {
|
||||
_tree = tree;
|
||||
_tree.undoManager = [self undoManager];
|
||||
if(nil == _treeDelgate) {
|
||||
_treeDelgate = [[MPTreeDelegate alloc] initWithDocument:self];
|
||||
}
|
||||
@@ -516,7 +515,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
if(!self.trash) {
|
||||
[self _createTrashGroup];
|
||||
}
|
||||
[entry moveToGroup:self.trash atIndex:[self.trash.entries count]];
|
||||
[entry moveToGroup:self.trash];
|
||||
[[self undoManager] setActionName:NSLocalizedString(@"TRASH_ENTRY", "Move Entry to Trash")];
|
||||
}
|
||||
else {
|
||||
@@ -626,8 +625,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
|
||||
- (void)duplicateEntry:(id)sender {
|
||||
KPKEntry *duplicate = [self.selectedEntry copyWithTitle:nil];
|
||||
NSInteger index = [self.selectedEntry.parent.entries indexOfObject:self.selectedEntry];
|
||||
[self.selectedEntry.parent addEntry:duplicate atIndex:index+1];
|
||||
[self.selectedEntry.parent addEntry:duplicate];
|
||||
[self.undoManager setActionName:NSLocalizedString(@"DUPLICATE_ENTRY", "")];
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
|
||||
@interface MPEditingSession : NSObject
|
||||
|
||||
@property (strong, readonly) KPKNode *node;
|
||||
@property (copy, readonly) KPKNode *rollbackNode;
|
||||
@property (copy, readonly) KPKNode *node;
|
||||
@property (weak, readonly) KPKNode *source;
|
||||
|
||||
- (instancetype)initWithNode:(KPKNode *)node;
|
||||
- (instancetype)initWithSource:(KPKNode *)node;
|
||||
|
||||
- (BOOL)hasChanges;
|
||||
|
||||
|
||||
@@ -11,29 +11,29 @@
|
||||
|
||||
@interface MPEditingSession ()
|
||||
|
||||
@property (strong) KPKNode *node;
|
||||
@property (copy) KPKNode *rollbackNode;
|
||||
@property (copy) KPKNode *node;
|
||||
@property (weak) KPKNode *source;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPEditingSession
|
||||
|
||||
- (instancetype)init {
|
||||
self = [self initWithNode:nil];
|
||||
self = [self initWithSource:nil];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithNode:(KPKNode *)node {
|
||||
- (instancetype)initWithSource:(KPKNode *)node {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
self.node = node;
|
||||
self.rollbackNode = node;
|
||||
self.source = node;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)hasChanges {
|
||||
return [self.node isEqual:self.rollbackNode];
|
||||
return ![self.node isEqual:self.source];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -160,12 +160,12 @@
|
||||
else if(draggedEntry) {
|
||||
if(copyItem || (nil == self.localDraggedEntry)) {
|
||||
draggedEntry = [draggedEntry copyWithTitle:nil];
|
||||
[targetGroup addEntry:draggedEntry atIndex:index];
|
||||
[targetGroup addEntry:draggedEntry];
|
||||
[targetGroup.undoManager setActionName:NSLocalizedString(@"COPY_ENTRY", "")];
|
||||
return YES;
|
||||
}
|
||||
else if(self.localDraggedEntry) {
|
||||
[self.localDraggedEntry moveToGroup:targetGroup atIndex:index];
|
||||
[self.localDraggedEntry moveToGroup:targetGroup];
|
||||
[self.localDraggedEntry.undoManager setActionName:NSLocalizedString(@"MOVE_ENTRY", "")];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -36,4 +36,8 @@
|
||||
return (NO == self.document.isReadOnly);
|
||||
}
|
||||
|
||||
- (NSUndoManager *)undoManagerForTree:(KPKTree *)tree {
|
||||
return self.document.undoManager;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user