mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 15:12:21 +00:00
Testing Undo/Redo
This commit is contained in:
@@ -26,5 +26,7 @@
|
|||||||
|
|
||||||
- (KdbGroup *)createGroup:(KdbGroup *)parent;
|
- (KdbGroup *)createGroup:(KdbGroup *)parent;
|
||||||
- (KdbEntry *)createEntry:(KdbGroup *)parent;
|
- (KdbEntry *)createEntry:(KdbGroup *)parent;
|
||||||
|
- (void)deleteEntry:(KdbEntry *)entry;
|
||||||
|
- (void)deleteGroup:(KdbGroup *)group;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
@property (nonatomic, readonly) KdbPassword *passwordHash;
|
@property (nonatomic, readonly) KdbPassword *passwordHash;
|
||||||
@property (assign) MPDatabaseVersion version;
|
@property (assign) MPDatabaseVersion version;
|
||||||
@property (assign) BOOL isDecrypted;
|
@property (assign) BOOL isDecrypted;
|
||||||
|
@property (assign) BOOL isDirty;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@
|
|||||||
}
|
}
|
||||||
KdbGroup *newGroup = [self.tree createGroup:self.tree.root];
|
KdbGroup *newGroup = [self.tree createGroup:self.tree.root];
|
||||||
newGroup.name = @"Default";
|
newGroup.name = @"Default";
|
||||||
|
self.tree.root = newGroup;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -126,6 +128,8 @@
|
|||||||
- (KdbEntry *)createEntry:(KdbGroup *)parent {
|
- (KdbEntry *)createEntry:(KdbGroup *)parent {
|
||||||
KdbEntry *newEntry = [self.tree createEntry:parent];
|
KdbEntry *newEntry = [self.tree createEntry:parent];
|
||||||
newEntry.title = NSLocalizedString(@"DEFAULT_ENTRY_TITLE", @"Title for a newly created entry");
|
newEntry.title = NSLocalizedString(@"DEFAULT_ENTRY_TITLE", @"Title for a newly created entry");
|
||||||
|
[[[self undoManager] prepareWithInvocationTarget:self] deleteEntry:newEntry];
|
||||||
|
[[self undoManager] setActionName:NSLocalizedString(@"ADD_ENTRY_UNDO", @"Create Entry Undo")];
|
||||||
[parent addEntry:newEntry];
|
[parent addEntry:newEntry];
|
||||||
return newEntry;
|
return newEntry;
|
||||||
}
|
}
|
||||||
@@ -133,8 +137,26 @@
|
|||||||
- (KdbGroup *)createGroup:(KdbGroup *)parent {
|
- (KdbGroup *)createGroup:(KdbGroup *)parent {
|
||||||
KdbGroup *newGroup = [self.tree createGroup:parent];
|
KdbGroup *newGroup = [self.tree createGroup:parent];
|
||||||
newGroup.name = NSLocalizedString(@"DEFAULT_GROUP_NAME", @"Title for a newly created group");
|
newGroup.name = NSLocalizedString(@"DEFAULT_GROUP_NAME", @"Title for a newly created group");
|
||||||
|
|
||||||
|
[[[self undoManager] prepareWithInvocationTarget:self] deleteGroup:newGroup];
|
||||||
|
[[self undoManager] setActionName:NSLocalizedString(@"ADD_GROUP_UNDO", @"Create Group Undo")];
|
||||||
[parent addGroup:newGroup];
|
[parent addGroup:newGroup];
|
||||||
|
|
||||||
return newGroup;
|
return newGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)deleteEntry:(KdbEntry *)entry {
|
||||||
|
if(entry.parent) {
|
||||||
|
[entry.parent removeEntry:entry];
|
||||||
|
self.isDirty = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)deleteGroup:(KdbGroup *)group {
|
||||||
|
if(group.parent) {
|
||||||
|
[group.parent removeGroup:group];
|
||||||
|
self.isDirty = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -454,6 +454,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
|
|||||||
KdbEntry *selectedEntry = [self _clickedOrSelectedEntry];
|
KdbEntry *selectedEntry = [self _clickedOrSelectedEntry];
|
||||||
if(selectedEntry) {
|
if(selectedEntry) {
|
||||||
[self.entryArrayController removeObject:selectedEntry];
|
[self.entryArrayController removeObject:selectedEntry];
|
||||||
|
[selectedEntry.parent removeEntry:selectedEntry];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,18 +80,23 @@
|
|||||||
|
|
||||||
- (void)createGroup:(id)sender {
|
- (void)createGroup:(id)sender {
|
||||||
KdbGroup *group = [self _clickedOrSelectedGroup];
|
KdbGroup *group = [self _clickedOrSelectedGroup];
|
||||||
if(group) {
|
|
||||||
MPDocument *document = [[NSDocumentController sharedDocumentController] currentDocument];
|
MPDocument *document = [[NSDocumentController sharedDocumentController] currentDocument];
|
||||||
|
if(!group) {
|
||||||
|
group = document.root;
|
||||||
|
}
|
||||||
[document createGroup:group];
|
[document createGroup:group];
|
||||||
[self.outlineView reloadData];
|
[self.outlineView reloadData];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
- (void)createEntry:(id)sender {
|
- (void)createEntry:(id)sender {
|
||||||
KdbGroup *group = [self _clickedOrSelectedGroup];
|
KdbGroup *group = [self _clickedOrSelectedGroup];
|
||||||
|
if(!group.parent) {
|
||||||
|
return; // Entries are not allowed in root group
|
||||||
|
}
|
||||||
if(group) {
|
if(group) {
|
||||||
MPDocument *document = [[NSDocumentController sharedDocumentController] currentDocument];
|
MPDocument *document = [[NSDocumentController sharedDocumentController] currentDocument];
|
||||||
[document createEntry:group];
|
[document createEntry:group];
|
||||||
|
// Notify the the entry view about changes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,9 +57,6 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
|||||||
NSOutlineView *outlineView = [notification object];
|
NSOutlineView *outlineView = [notification object];
|
||||||
KdbGroup *selectedGroup = [outlineView itemAtRow:[outlineView selectedRow]];
|
KdbGroup *selectedGroup = [outlineView itemAtRow:[outlineView selectedRow]];
|
||||||
self.selectedGroup = selectedGroup;
|
self.selectedGroup = selectedGroup;
|
||||||
#ifdef DEBUG
|
|
||||||
NSLog(@"Selected: %@", self.selectedGroup);
|
|
||||||
#endif
|
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPOutlineViewDidChangeGroupSelection object:self userInfo:nil];
|
[[NSNotificationCenter defaultCenter] postNotificationName:MPOutlineViewDidChangeGroupSelection object:self userInfo:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>668</string>
|
<string>67C</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user