Entry positions are now editable in groups

Added undo wrapper for moving to new group and moving to new indexes for Entries
This commit is contained in:
michael starke
2013-05-18 01:21:31 +02:00
parent 10f827c867
commit 8a21b194df
10 changed files with 81 additions and 75 deletions

View File

@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
4C1DDCDD1711ECEB00C98DA3 /* PasswordCreatorWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */; }; 4C1DDCDD1711ECEB00C98DA3 /* PasswordCreatorWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */; };
4C22040D1746ED160054C916 /* KdbGroup+Undo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C22040C1746ED160054C916 /* KdbGroup+Undo.m */; };
4C25D58516CF0F8800F6806C /* WelcomeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C25D58416CF0F8800F6806C /* WelcomeView.xib */; }; 4C25D58516CF0F8800F6806C /* WelcomeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C25D58416CF0F8800F6806C /* WelcomeView.xib */; };
4C25D58716CF0FAA00F6806C /* EntryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C25D58616CF0FAA00F6806C /* EntryView.xib */; }; 4C25D58716CF0FAA00F6806C /* EntryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C25D58616CF0FAA00F6806C /* EntryView.xib */; };
4C2C4C2C16D3BE3700D49295 /* KdbGroup+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2C4C2B16D3BE3700D49295 /* KdbGroup+MPAdditions.m */; }; 4C2C4C2C16D3BE3700D49295 /* KdbGroup+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2C4C2B16D3BE3700D49295 /* KdbGroup+MPAdditions.m */; };
@@ -121,6 +122,8 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordCreatorWindow.xib; sourceTree = "<group>"; }; 4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordCreatorWindow.xib; sourceTree = "<group>"; };
4C22040B1746ED160054C916 /* KdbGroup+Undo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbGroup+Undo.h"; sourceTree = "<group>"; };
4C22040C1746ED160054C916 /* KdbGroup+Undo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbGroup+Undo.m"; sourceTree = "<group>"; };
4C25D58416CF0F8800F6806C /* WelcomeView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WelcomeView.xib; sourceTree = "<group>"; }; 4C25D58416CF0F8800F6806C /* WelcomeView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WelcomeView.xib; sourceTree = "<group>"; };
4C25D58616CF0FAA00F6806C /* EntryView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = EntryView.xib; sourceTree = "<group>"; }; 4C25D58616CF0FAA00F6806C /* EntryView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = EntryView.xib; sourceTree = "<group>"; };
4C2C4C2A16D3BE3700D49295 /* KdbGroup+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbGroup+MPAdditions.h"; sourceTree = "<group>"; }; 4C2C4C2A16D3BE3700D49295 /* KdbGroup+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbGroup+MPAdditions.h"; sourceTree = "<group>"; };
@@ -372,6 +375,8 @@
4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */, 4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */,
4CCF9752173EFBA500460BD2 /* KdbEntry+Undo.h */, 4CCF9752173EFBA500460BD2 /* KdbEntry+Undo.h */,
4CCF9753173EFBA500460BD2 /* KdbEntry+Undo.m */, 4CCF9753173EFBA500460BD2 /* KdbEntry+Undo.m */,
4C22040B1746ED160054C916 /* KdbGroup+Undo.h */,
4C22040C1746ED160054C916 /* KdbGroup+Undo.m */,
); );
name = KeePassLibAdditions; name = KeePassLibAdditions;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -944,6 +949,7 @@
4C7E832A172DE2F2002493D8 /* MPPasswordEditViewController.m in Sources */, 4C7E832A172DE2F2002493D8 /* MPPasswordEditViewController.m in Sources */,
4CE5B54B173AFBA700207B39 /* MPDocument.m in Sources */, 4CE5B54B173AFBA700207B39 /* MPDocument.m in Sources */,
4CCF9754173EFBA500460BD2 /* KdbEntry+Undo.m in Sources */, 4CCF9754173EFBA500460BD2 /* KdbEntry+Undo.m in Sources */,
4C22040D1746ED160054C916 /* KdbGroup+Undo.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@@ -22,4 +22,7 @@
- (void)setUrlUndoable:(NSString *)url; - (void)setUrlUndoable:(NSString *)url;
- (void)setNotesUndoable:(NSString *)notes; - (void)setNotesUndoable:(NSString *)notes;
- (void)moveToIndexUndoable:(NSNumber *)index;
- (void)moveToGroupUndoable:(KdbGroup *)newGroup;
@end @end

View File

@@ -7,6 +7,7 @@
// //
#import "KdbEntry+Undo.h" #import "KdbEntry+Undo.h"
#import "KdbGroup+MPAdditions.h"
@implementation KdbEntry (Undo) @implementation KdbEntry (Undo)
@@ -65,4 +66,30 @@
[[document 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];
} }
@end
- (void)moveToIndexUndoable:(NSNumber *)index {
if(!self.parent) {
return;
}
NSUInteger iIndex = [index unsignedIntegerValue];
NSNumber *oldIndex = @([self.parent.entries indexOfObject:self]);
NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument];
[[document undoManager] registerUndoWithTarget:self selector:@selector(moveToIndexUndoable:) object:oldIndex];
[[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_POSITION", "Undo set entry position")];
[self.parent moveEntry:self toIndex:iIndex];
}
- (void)moveToGroupUndoable:(KdbGroup *)newGroup {
if(self.parent == newGroup) {
return;
}
if(!self.parent || !newGroup) {
return;
}
NSDocument *document = [[NSDocumentController sharedDocumentController] currentDocument];
[[document undoManager] registerUndoWithTarget:self selector:@selector(moveToGroupUndoable:) object:self.parent];
[[document undoManager] setActionName:NSLocalizedString(@"UNDO_MOVE_ENTRY", "Undo move entry to group")];
[self.parent moveEntry:self toGroup:newGroup];
}
@end

View File

@@ -14,4 +14,6 @@
- (NSArray *)childEntries; - (NSArray *)childEntries;
- (void)moveEntry:(KdbEntry *)entry toIndex:(NSUInteger)index;
@end @end

View File

@@ -27,4 +27,16 @@
return childEntries; return childEntries;
} }
- (void)moveEntry:(KdbEntry *)entry toIndex:(NSUInteger)index {
if([entries count] > index) {
return;
}
NSUInteger oldIndex = [entries indexOfObject:entry];
if(oldIndex == NSNotFound) {
return;
}
[entries exchangeObjectAtIndex:oldIndex withObjectAtIndex:index];
}
@end @end

13
MacPass/KdbGroup+Undo.h Normal file
View File

@@ -0,0 +1,13 @@
//
// KdbGroup+Undo.h
// MacPass
//
// Created by Michael Starke on 18.05.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "Kdb.h"
@interface KdbGroup (Undo)
@end

13
MacPass/KdbGroup+Undo.m Normal file
View File

@@ -0,0 +1,13 @@
//
// KdbGroup+Undo.m
// MacPass
//
// Created by Michael Starke on 18.05.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "KdbGroup+Undo.h"
@implementation KdbGroup (Undo)
@end

View File

@@ -88,7 +88,7 @@
toItem:nil toItem:nil
attribute:NSLayoutAttributeNotAnAttribute attribute:NSLayoutAttributeNotAnAttribute
multiplier:1 multiplier:1
constant:300]; constant:200];
self.hideConstraint = [NSLayoutConstraint constraintWithItem:[self view] attribute:NSLayoutAttributeWidth self.hideConstraint = [NSLayoutConstraint constraintWithItem:[self view] attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual relatedBy:NSLayoutRelationEqual
toItem:nil toItem:nil

View File

@@ -46,7 +46,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>6E6</string> <string>6E9</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

@@ -51,7 +51,6 @@
<int key="NSvFlags">268</int> <int key="NSvFlags">268</int>
<string key="NSFrame">{{96, 175}, {184, 17}}</string> <string key="NSFrame">{{96, 175}, {184, 17}}</string>
<reference key="NSSuperview" ref="1005"/> <reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="662046682"/> <reference key="NSNextKeyView" ref="662046682"/>
<string key="NSReuseIdentifierKey">_NS:1535</string> <string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
@@ -100,7 +99,6 @@
</set> </set>
<string key="NSFrame">{{157, 200}, {48, 48}}</string> <string key="NSFrame">{{157, 200}, {48, 48}}</string>
<reference key="NSSuperview" ref="1005"/> <reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="660673733"/> <reference key="NSNextKeyView" ref="660673733"/>
<string key="NSReuseIdentifierKey">_NS:9</string> <string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
@@ -125,7 +123,6 @@
<int key="NSvFlags">268</int> <int key="NSvFlags">268</int>
<string key="NSFrame">{{127, 50}, {82, 32}}</string> <string key="NSFrame">{{127, 50}, {82, 32}}</string>
<reference key="NSSuperview" ref="1005"/> <reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="769513826"/> <reference key="NSNextKeyView" ref="769513826"/>
<string key="NSReuseIdentifierKey">_NS:9</string> <string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
@@ -154,7 +151,6 @@
</set> </set>
<string key="NSFrame">{{83, 94}, {197, 22}}</string> <string key="NSFrame">{{83, 94}, {197, 22}}</string>
<reference key="NSSuperview" ref="1005"/> <reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="132133585"/> <reference key="NSNextKeyView" ref="132133585"/>
<string key="NSReuseIdentifierKey">_NS:9</string> <string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
@@ -179,7 +175,6 @@
<int key="NSvFlags">268</int> <int key="NSvFlags">268</int>
<string key="NSFrame">{{86, 123}, {191, 22}}</string> <string key="NSFrame">{{86, 123}, {191, 22}}</string>
<reference key="NSSuperview" ref="1005"/> <reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="333885704"/> <reference key="NSNextKeyView" ref="333885704"/>
<string key="NSReuseIdentifierKey">_NS:9</string> <string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
@@ -217,7 +212,6 @@
<int key="NSvFlags">268</int> <int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 126}, {64, 17}}</string> <string key="NSFrame">{{17, 126}, {64, 17}}</string>
<reference key="NSSuperview" ref="1005"/> <reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="219521947"/> <reference key="NSNextKeyView" ref="219521947"/>
<string key="NSReuseIdentifierKey">_NS:1535</string> <string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
@@ -238,7 +232,6 @@
<int key="NSvFlags">268</int> <int key="NSvFlags">268</int>
<string key="NSFrame">{{35, 99}, {46, 17}}</string> <string key="NSFrame">{{35, 99}, {46, 17}}</string>
<reference key="NSSuperview" ref="1005"/> <reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1034097047"/> <reference key="NSNextKeyView" ref="1034097047"/>
<string key="NSReuseIdentifierKey">_NS:1535</string> <string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
@@ -259,7 +252,7 @@
<int key="NSvFlags">268</int> <int key="NSvFlags">268</int>
<string key="NSFrame">{{209, 50}, {74, 32}}</string> <string key="NSFrame">{{209, 50}, {74, 32}}</string>
<reference key="NSSuperview" ref="1005"/> <reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/> <reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string> <string key="NSReuseIdentifierKey">_NS:9</string>
<string key="NSHuggingPriority">{250, 250}</string> <string key="NSHuggingPriority">{250, 250}</string>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
@@ -282,7 +275,6 @@
</array> </array>
<string key="NSFrameSize">{362, 268}</string> <string key="NSFrameSize">{362, 268}</string>
<reference key="NSSuperview"/> <reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="204058255"/> <reference key="NSNextKeyView" ref="204058255"/>
<string key="NSAntiCompressionPriority">{751, 750}</string> <string key="NSAntiCompressionPriority">{751, 750}</string>
<string key="NSClassName">NSView</string> <string key="NSClassName">NSView</string>
@@ -1096,69 +1088,7 @@
<nil key="sourceID"/> <nil key="sourceID"/>
<int key="maxID">295</int> <int key="maxID">295</int>
</object> </object>
<object class="IBClassDescriber" key="IBDocument.Classes"> <object class="IBClassDescriber" key="IBDocument.Classes"/>
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">MPPasswordInputController</string>
<string key="superclassName">MPViewController</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">_decrypt:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">_decrypt:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">_decrypt:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="errorImageView">NSImageView</string>
<string key="errorInfoTextField">NSTextField</string>
<string key="keyPathControl">NSPathControl</string>
<string key="passwordTextField">NSSecureTextField</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="errorImageView">
<string key="name">errorImageView</string>
<string key="candidateClassName">NSImageView</string>
</object>
<object class="IBToOneOutletInfo" key="errorInfoTextField">
<string key="name">errorInfoTextField</string>
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBToOneOutletInfo" key="keyPathControl">
<string key="name">keyPathControl</string>
<string key="candidateClassName">NSPathControl</string>
</object>
<object class="IBToOneOutletInfo" key="passwordTextField">
<string key="name">passwordTextField</string>
<string key="candidateClassName">NSSecureTextField</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MPPasswordInputController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">MPViewController</string>
<string key="superclassName">NSViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MPViewController.h</string>
</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>
</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>