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