More work on undo/redo

Updated README
This commit is contained in:
michael starke
2013-05-23 22:50:34 +02:00
parent 130a14de54
commit 2b1d2dca06
10 changed files with 172 additions and 37 deletions

View File

@@ -11,6 +11,7 @@
<string key="NS.object.0">3084</string> <string key="NS.object.0">3084</string>
</object> </object>
<array key="IBDocument.IntegratedClassDependencies"> <array key="IBDocument.IntegratedClassDependencies">
<string>IBNSLayoutConstraint</string>
<string>NSCustomObject</string> <string>NSCustomObject</string>
<string>NSCustomView</string> <string>NSCustomView</string>
<string>NSSplitView</string> <string>NSSplitView</string>
@@ -80,7 +81,6 @@
<string key="NSFrame">{{527, 0}, {200, 449}}</string> <string key="NSFrame">{{527, 0}, {200, 449}}</string>
<reference key="NSSuperview" ref="947682332"/> <reference key="NSSuperview" ref="947682332"/>
<reference key="NSWindow"/> <reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string> <string key="NSReuseIdentifierKey">_NS:9</string>
<string key="NSClassName">NSView</string> <string key="NSClassName">NSView</string>
</object> </object>
@@ -110,7 +110,7 @@
<reference key="NSWindow"/> <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="947682332"/> <reference key="NSNextKeyView" ref="947682332"/>
</object> </object>
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string> <string key="NSScreenRect">{{0, 0}, {1920, 1058}}</string>
<string key="NSMinSize">{400, 422}</string> <string key="NSMinSize">{400, 422}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string> <string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<bool key="NSWindowIsRestorable">YES</bool> <bool key="NSWindowIsRestorable">YES</bool>
@@ -198,6 +198,70 @@
<reference key="object" ref="1006"/> <reference key="object" ref="1006"/>
<array class="NSMutableArray" key="children"> <array class="NSMutableArray" key="children">
<reference ref="947682332"/> <reference ref="947682332"/>
<object class="IBNSLayoutConstraint" id="631622849">
<reference key="firstItem" ref="947682332"/>
<int key="firstAttribute">5</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1006"/>
<int key="secondAttribute">5</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">0.0</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1006"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="645864882">
<reference key="firstItem" ref="947682332"/>
<int key="firstAttribute">4</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1006"/>
<int key="secondAttribute">4</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">0.0</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1006"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="855545557">
<reference key="firstItem" ref="947682332"/>
<int key="firstAttribute">3</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1006"/>
<int key="secondAttribute">3</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">0.0</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1006"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="667679916">
<reference key="firstItem" ref="947682332"/>
<int key="firstAttribute">6</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1006"/>
<int key="secondAttribute">6</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">0.0</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1006"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
</array> </array>
<reference key="parent" ref="1005"/> <reference key="parent" ref="1005"/>
</object> </object>
@@ -227,6 +291,26 @@
<reference key="object" ref="350501330"/> <reference key="object" ref="350501330"/>
<reference key="parent" ref="947682332"/> <reference key="parent" ref="947682332"/>
</object> </object>
<object class="IBObjectRecord">
<int key="objectID">677</int>
<reference key="object" ref="667679916"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">678</int>
<reference key="object" ref="855545557"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">679</int>
<reference key="object" ref="645864882"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">680</int>
<reference key="object" ref="631622849"/>
<reference key="parent" ref="1006"/>
</object>
</array> </array>
</object> </object>
<dictionary class="NSMutableDictionary" key="flattenedProperties"> <dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -238,17 +322,28 @@
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1.IBWindowTemplateEditedContentRect">{{357, 418}, {480, 270}}</string> <string key="1.IBWindowTemplateEditedContentRect">{{357, 418}, {480, 270}}</string>
<boolean value="NO" key="1.NSWindowTemplate.visibleAtLaunch"/> <boolean value="NO" key="1.NSWindowTemplate.visibleAtLaunch"/>
<array key="2.IBNSViewMetadataConstraints">
<reference ref="667679916"/>
<reference ref="855545557"/>
<reference ref="645864882"/>
<reference ref="631622849"/>
</array>
<string key="2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="NO" key="603.IBNSViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
<string key="603.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="603.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="605.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="605.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="628.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="628.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="675.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="675.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="677.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="678.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="679.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="680.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
</dictionary> </dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/> <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/> <nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/> <dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/> <nil key="sourceID"/>
<int key="maxID">676</int> <int key="maxID">680</int>
</object> </object>
<object class="IBClassDescriber" key="IBDocument.Classes"> <object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions"> <array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -305,11 +400,20 @@
<string key="minorKey">./Classes/MPDocumentWindowController.h</string> <string key="minorKey">./Classes/MPDocumentWindowController.h</string>
</object> </object>
</object> </object>
<object class="IBPartialClassDescription">
<string key="className">NSLayoutConstraint</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/NSLayoutConstraint.h</string>
</object>
</object>
</array> </array>
</object> </object>
<int key="IBDocument.localizationMode">0</int> <int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string> <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int> <int key="IBDocument.defaultPropertyAccessControl">3</int>
<bool key="IBDocument.UseAutolayout">YES</bool>
</data> </data>
</archive> </archive>

View File

@@ -10,6 +10,8 @@
@interface KdbEntry (Undo) @interface KdbEntry (Undo)
+ (NSUndoManager *)undoManager;
- (NSString *)titleUndoable; - (NSString *)titleUndoable;
- (NSString *)usernameUndoable; - (NSString *)usernameUndoable;
- (NSString *)passwordUndoable; - (NSString *)passwordUndoable;

View File

@@ -11,6 +11,10 @@
@implementation KdbEntry (Undo) @implementation KdbEntry (Undo)
+ (NSUndoManager *)undoManager {
return [[[NSDocumentController sharedDocumentController] currentDocument] undoManager];
}
- (NSString *)titleUndoable { - (NSString *)titleUndoable {
return [self title]; return [self title];
} }
@@ -33,37 +37,32 @@
- (void)setTitleUndoable:(NSString *)title { - (void)setTitleUndoable:(NSString *)title {
NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.title];
[[document undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.title]; [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_TITLE", "Undo set title")];
[[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_TITLE", "Undo set title")];
[self setTitle:title]; [self setTitle:title];
} }
- (void)setUsernameUndoable:(NSString *)username { - (void)setUsernameUndoable:(NSString *)username {
NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setUsernameUndoable:) object:self.username];
[[document undoManager] registerUndoWithTarget:self selector:@selector(setUsernameUndoable:) object:self.username]; [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_USERNAME", "Undo set username")];
[[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_USERNAME", "Undo set username")];
[self setUsername:username]; [self setUsername:username];
} }
- (void)setPasswordUndoable:(NSString *)password { - (void)setPasswordUndoable:(NSString *)password {
NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.password];
[[document undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.password]; [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_PASSWORT", "Undo set password")];
[[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_PASSWORT", "Undo set password")];
[self setPassword:password]; [self setPassword:password];
} }
- (void)setUrlUndoable:(NSString *)url { - (void)setUrlUndoable:(NSString *)url {
NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.url];
[[document undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.url]; [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_URL", "Undo set URL")];
[[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_URL", "Undo set URL")];
[self setUrl:url]; [self setUrl:url];
} }
- (void)setNotesUndoable:(NSString *)notes { - (void)setNotesUndoable:(NSString *)notes {
NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.notes];
[[document undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.notes]; [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_NOTES", "Undo set notes")];
[[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_NOTES", "Undo set notes")];
[self setNotes:notes]; [self setNotes:notes];
} }
@@ -73,9 +72,8 @@
} }
NSUInteger iIndex = [index unsignedIntegerValue]; NSUInteger iIndex = [index unsignedIntegerValue];
NSNumber *oldIndex = @([self.parent.entries indexOfObject:self]); NSNumber *oldIndex = @([self.parent.entries indexOfObject:self]);
NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(moveToIndexUndoable:) object:oldIndex];
[[document undoManager] registerUndoWithTarget:self selector:@selector(moveToIndexUndoable:) object:oldIndex]; [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_POSITION", "Undo set entry position")];
[[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_POSITION", "Undo set entry position")];
[self.parent moveEntry:self toIndex:iIndex]; [self.parent moveEntry:self toIndex:iIndex];
} }
@@ -87,9 +85,8 @@
if(!self.parent || !newGroup) { if(!self.parent || !newGroup) {
return; return;
} }
NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(moveToGroupUndoable:) object:self.parent];
[[document undoManager] registerUndoWithTarget:self selector:@selector(moveToGroupUndoable:) object:self.parent]; [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_MOVE_ENTRY", "Undo move entry to group")];
[[document undoManager] setActionName:NSLocalizedString(@"UNDO_MOVE_ENTRY", "Undo move entry to group")];
[self.parent moveEntry:self toGroup:newGroup]; [self.parent moveEntry:self toGroup:newGroup];
} }
@end @end

View File

@@ -10,4 +10,9 @@
@interface KdbGroup (Undo) @interface KdbGroup (Undo)
+ (NSUndoManager *)undoManager;
- (void)removeEntryUndoable:(KdbEntry *)entry;
- (void)addEntryUndoable:(KdbEntry *)entry;
@end @end

View File

@@ -10,4 +10,20 @@
@implementation KdbGroup (Undo) @implementation KdbGroup (Undo)
+ (NSUndoManager *)undoManager {
return [[[NSDocumentController sharedDocumentController] currentDocument] undoManager];
}
- (void)removeEntryUndoable:(KdbEntry *)entry {
[[KdbGroup undoManager] registerUndoWithTarget:self selector:@selector(addEntryUndoable:) object:entry];
[[KdbGroup undoManager] setActionName:NSLocalizedString(@"UNDO_DELETE_ENTRY", "Undo deleting of entry")];
[self removeEntry:entry];
}
- (void)addEntryUndoable:(KdbEntry *)entry {
[[KdbGroup undoManager] registerUndoWithTarget:self selector:@selector(removeEntryUndoable:) object:entry];
[[KdbGroup undoManager] setActionName:NSLocalizedString(@"UNDO_ADD_ENTRY", "Undo adding of entry")];
[self addEntry:entry];
}
@end @end

View File

@@ -83,17 +83,19 @@
[self.toolbar setDelegate:self.toolbarDelegate]; [self.toolbar setDelegate:self.toolbarDelegate];
[self.window setToolbar:self.toolbar]; [self.window setToolbar:self.toolbar];
[self.splitView setTranslatesAutoresizingMaskIntoConstraints:NO];
/* Add outlineview */ /* Add outlineview */
const NSRect outlineFrame = [self.outlineView frame]; //const NSRect outlineFrame = [self.outlineView frame];
[self.outlineViewController.view setFrame:outlineFrame]; //[self.outlineViewController.view setFrame:outlineFrame];
[self.outlineViewController.view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; //[self.outlineViewController.view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[self.splitView replaceSubview:self.outlineView with:[self.outlineViewController view]]; [self.splitView replaceSubview:self.outlineView with:[self.outlineViewController view]];
[self.outlineViewController updateResponderChain]; [self.outlineViewController updateResponderChain];
/* Add inspector view */ /* Add inspector view */
const NSRect inspectorFrame = [self.inspectorView frame]; //const NSRect inspectorFrame = [self.inspectorView frame];
[self.inspectorTabViewController.view setFrame:inspectorFrame]; //[self.inspectorTabViewController.view setFrame:inspectorFrame];
[self.inspectorTabViewController.view setAutoresizesSubviews:NSViewWidthSizable | NSViewHeightSizable ]; //[self.inspectorTabViewController.view setAutoresizesSubviews:NSViewWidthSizable | NSViewHeightSizable ];
[self.splitView replaceSubview:self.inspectorView with:[self.inspectorTabViewController view]]; [self.splitView replaceSubview:self.inspectorView with:[self.inspectorTabViewController view]];
[self.inspectorTabViewController updateResponderChain]; [self.inspectorTabViewController updateResponderChain];

View File

@@ -49,6 +49,7 @@ typedef enum {
- (void)openURL:(id)sender; - (void)openURL:(id)sender;
/* Entry Handling*/ /* Entry Handling*/
- (void)createEntry:(id)sender;
- (void)deleteEntry:(id)sender; - (void)deleteEntry:(id)sender;
@end @end

View File

@@ -16,6 +16,7 @@
#import "MPPasteBoardController.h" #import "MPPasteBoardController.h"
#import "MPOverlayWindowController.h" #import "MPOverlayWindowController.h"
#import "KdbGroup+MPAdditions.h" #import "KdbGroup+MPAdditions.h"
#import "KdbEntry+Undo.h"
NSString *const MPDidChangeSelectedEntryNotification = @"com.macpass.MPDidChangeSelectedEntryNotification"; NSString *const MPDidChangeSelectedEntryNotification = @"com.macpass.MPDidChangeSelectedEntryNotification";
@@ -472,12 +473,12 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
} }
} }
- (void)createEntry:(id)sender {
// TODO:
}
- (void)deleteEntry:(id)sender { - (void)deleteEntry:(id)sender {
KdbEntry *selectedEntry = [self _clickedOrSelectedEntry]; // TODO:
if(selectedEntry) {
[self.entryArrayController removeObject:selectedEntry];
[selectedEntry.parent removeEntry:selectedEntry];
}
} }
- (void)_toggleFilterSpace:(id)sender { - (void)_toggleFilterSpace:(id)sender {

View File

@@ -46,7 +46,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>6EE</string> <string>6F7</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string> <string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>

View File

@@ -6,13 +6,20 @@ KeePass can be used via Mono on OS X but lacks vital functionality and feels slu
This is an attempt to create an OS X port that should at least be able to read KeePass files. This is an attempt to create an OS X port that should at least be able to read KeePass files.
Status
------
The Project is in heavy development and it's likely to take some time till it reaches a usable state.
Beware that I'm going to shift things around so stuff is going to break. A lot.
Alternatives Alternatives
------------ ------------
Currently there is an alpha Version available of [KeePassX](http://www.keepassx.org). Currently there is an alpha Version available of [KeePassX](http://www.keepassx.org).
It's Qt based KeePass manager, than can handle KeePass 1 and 2 containers rather nicely. It's Qt based KeePass manager, than can handle KeePass 1 and 2 containers rather nicely.
Compared to running KeePass with Mono it very fast and remarkably stable for an alpha relaese. Compared to running KeePass with Mono it very fast and remarkably stable for an alpha relaese.
Feel free to give it a try. Feel free to give it a try. The biggest draw-back is it's inablity to create passwords via a wizzard.
What does it look like? What does it look like?
----------------------- -----------------------