diff --git a/MacPass/MPDocument.h b/MacPass/MPDocument.h
index 2092f45a..9f838726 100644
--- a/MacPass/MPDocument.h
+++ b/MacPass/MPDocument.h
@@ -26,5 +26,7 @@
- (KdbGroup *)createGroup:(KdbGroup *)parent;
- (KdbEntry *)createEntry:(KdbGroup *)parent;
+- (void)deleteEntry:(KdbEntry *)entry;
+- (void)deleteGroup:(KdbGroup *)group;
@end
diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m
index a6e3e426..0bcf59fc 100644
--- a/MacPass/MPDocument.m
+++ b/MacPass/MPDocument.m
@@ -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
diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m
index eb4a5ae6..6e2c9da7 100644
--- a/MacPass/MPEntryViewController.m
+++ b/MacPass/MPEntryViewController.m
@@ -454,6 +454,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
KdbEntry *selectedEntry = [self _clickedOrSelectedEntry];
if(selectedEntry) {
[self.entryArrayController removeObject:selectedEntry];
+ [selectedEntry.parent removeEntry:selectedEntry];
}
}
diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m
index 2103a781..0be1594b 100644
--- a/MacPass/MPOutlineViewController.m
+++ b/MacPass/MPOutlineViewController.m
@@ -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
}
}
diff --git a/MacPass/MPOutlineViewDelegate.m b/MacPass/MPOutlineViewDelegate.m
index a3ef81d3..6006296b 100644
--- a/MacPass/MPOutlineViewDelegate.m
+++ b/MacPass/MPOutlineViewDelegate.m
@@ -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];
}
diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist
index ab1ee475..617f4b9e 100644
--- a/MacPass/MacPass-Info.plist
+++ b/MacPass/MacPass-Info.plist
@@ -46,7 +46,7 @@
CFBundleSignature
????
CFBundleVersion
- 668
+ 67C
LSMinimumSystemVersion
${MACOSX_DEPLOYMENT_TARGET}
NSHumanReadableCopyright
diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings
index 9e4dd45a..74a2fde2 100644
Binary files a/MacPass/en.lproj/Localizable.strings and b/MacPass/en.lproj/Localizable.strings differ