From 8a21b194df8e78a4b93734ef1f401a010c869408 Mon Sep 17 00:00:00 2001 From: michael starke Date: Sat, 18 May 2013 01:21:31 +0200 Subject: [PATCH] Entry positions are now editable in groups Added undo wrapper for moving to new group and moving to new indexes for Entries --- MacPass.xcodeproj/project.pbxproj | 6 +++ MacPass/KdbEntry+Undo.h | 3 ++ MacPass/KdbEntry+Undo.m | 29 +++++++++- MacPass/KdbGroup+MPAdditions.h | 2 + MacPass/KdbGroup+MPAdditions.m | 12 +++++ MacPass/KdbGroup+Undo.h | 13 +++++ MacPass/KdbGroup+Undo.m | 13 +++++ MacPass/MPInspectorTabViewController.m | 2 +- MacPass/MacPass-Info.plist | 2 +- MacPass/PasswordInputView.xib | 74 +------------------------- 10 files changed, 81 insertions(+), 75 deletions(-) create mode 100644 MacPass/KdbGroup+Undo.h create mode 100644 MacPass/KdbGroup+Undo.m diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 57e910ac..bff728b4 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 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 */; }; 4C25D58716CF0FAA00F6806C /* EntryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C25D58616CF0FAA00F6806C /* EntryView.xib */; }; 4C2C4C2C16D3BE3700D49295 /* KdbGroup+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2C4C2B16D3BE3700D49295 /* KdbGroup+MPAdditions.m */; }; @@ -121,6 +122,8 @@ /* Begin PBXFileReference section */ 4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordCreatorWindow.xib; sourceTree = ""; }; + 4C22040B1746ED160054C916 /* KdbGroup+Undo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbGroup+Undo.h"; sourceTree = ""; }; + 4C22040C1746ED160054C916 /* KdbGroup+Undo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbGroup+Undo.m"; sourceTree = ""; }; 4C25D58416CF0F8800F6806C /* WelcomeView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WelcomeView.xib; sourceTree = ""; }; 4C25D58616CF0FAA00F6806C /* EntryView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = EntryView.xib; sourceTree = ""; }; 4C2C4C2A16D3BE3700D49295 /* KdbGroup+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbGroup+MPAdditions.h"; sourceTree = ""; }; @@ -372,6 +375,8 @@ 4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */, 4CCF9752173EFBA500460BD2 /* KdbEntry+Undo.h */, 4CCF9753173EFBA500460BD2 /* KdbEntry+Undo.m */, + 4C22040B1746ED160054C916 /* KdbGroup+Undo.h */, + 4C22040C1746ED160054C916 /* KdbGroup+Undo.m */, ); name = KeePassLibAdditions; sourceTree = ""; @@ -944,6 +949,7 @@ 4C7E832A172DE2F2002493D8 /* MPPasswordEditViewController.m in Sources */, 4CE5B54B173AFBA700207B39 /* MPDocument.m in Sources */, 4CCF9754173EFBA500460BD2 /* KdbEntry+Undo.m in Sources */, + 4C22040D1746ED160054C916 /* KdbGroup+Undo.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/KdbEntry+Undo.h b/MacPass/KdbEntry+Undo.h index 97ac82e5..fe28ef9a 100644 --- a/MacPass/KdbEntry+Undo.h +++ b/MacPass/KdbEntry+Undo.h @@ -22,4 +22,7 @@ - (void)setUrlUndoable:(NSString *)url; - (void)setNotesUndoable:(NSString *)notes; +- (void)moveToIndexUndoable:(NSNumber *)index; +- (void)moveToGroupUndoable:(KdbGroup *)newGroup; + @end diff --git a/MacPass/KdbEntry+Undo.m b/MacPass/KdbEntry+Undo.m index 6a45d0a1..57777943 100644 --- a/MacPass/KdbEntry+Undo.m +++ b/MacPass/KdbEntry+Undo.m @@ -7,6 +7,7 @@ // #import "KdbEntry+Undo.h" +#import "KdbGroup+MPAdditions.h" @implementation KdbEntry (Undo) @@ -65,4 +66,30 @@ [[document undoManager] setActionName:NSLocalizedString(@"UNDO_SET_NOTES", "Undo set 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 \ No newline at end of file diff --git a/MacPass/KdbGroup+MPAdditions.h b/MacPass/KdbGroup+MPAdditions.h index 338ce2b6..6fbd2fa5 100644 --- a/MacPass/KdbGroup+MPAdditions.h +++ b/MacPass/KdbGroup+MPAdditions.h @@ -14,4 +14,6 @@ - (NSArray *)childEntries; +- (void)moveEntry:(KdbEntry *)entry toIndex:(NSUInteger)index; + @end diff --git a/MacPass/KdbGroup+MPAdditions.m b/MacPass/KdbGroup+MPAdditions.m index 98d2e4b8..ae3d17b0 100644 --- a/MacPass/KdbGroup+MPAdditions.m +++ b/MacPass/KdbGroup+MPAdditions.m @@ -27,4 +27,16 @@ 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 diff --git a/MacPass/KdbGroup+Undo.h b/MacPass/KdbGroup+Undo.h new file mode 100644 index 00000000..f5f5f476 --- /dev/null +++ b/MacPass/KdbGroup+Undo.h @@ -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 diff --git a/MacPass/KdbGroup+Undo.m b/MacPass/KdbGroup+Undo.m new file mode 100644 index 00000000..c157e52c --- /dev/null +++ b/MacPass/KdbGroup+Undo.m @@ -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 diff --git a/MacPass/MPInspectorTabViewController.m b/MacPass/MPInspectorTabViewController.m index dfd29972..93e76d3e 100644 --- a/MacPass/MPInspectorTabViewController.m +++ b/MacPass/MPInspectorTabViewController.m @@ -88,7 +88,7 @@ toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 - constant:300]; + constant:200]; self.hideConstraint = [NSLayoutConstraint constraintWithItem:[self view] attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index a1399c67..2904ff7d 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -46,7 +46,7 @@ CFBundleSignature ???? CFBundleVersion - 6E6 + 6E9 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/PasswordInputView.xib b/MacPass/PasswordInputView.xib index d2b7bb3b..0a2f644b 100644 --- a/MacPass/PasswordInputView.xib +++ b/MacPass/PasswordInputView.xib @@ -51,7 +51,6 @@ 268 {{96, 175}, {184, 17}} - _NS:1535 YES @@ -100,7 +99,6 @@ {{157, 200}, {48, 48}} - _NS:9 YES @@ -125,7 +123,6 @@ 268 {{127, 50}, {82, 32}} - _NS:9 YES @@ -154,7 +151,6 @@ {{83, 94}, {197, 22}} - _NS:9 YES @@ -179,7 +175,6 @@ 268 {{86, 123}, {191, 22}} - _NS:9 YES @@ -217,7 +212,6 @@ 268 {{17, 126}, {64, 17}} - _NS:1535 YES @@ -238,7 +232,6 @@ 268 {{35, 99}, {46, 17}} - _NS:1535 YES @@ -259,7 +252,7 @@ 268 {{209, 50}, {74, 32}} - + _NS:9 {250, 250} YES @@ -282,7 +275,6 @@ {362, 268} - {751, 750} NSView @@ -1096,69 +1088,7 @@ 295 - - - - MPPasswordInputController - MPViewController - - _decrypt: - id - - - _decrypt: - - _decrypt: - id - - - - NSImageView - NSTextField - NSPathControl - NSSecureTextField - - - - errorImageView - NSImageView - - - errorInfoTextField - NSTextField - - - keyPathControl - NSPathControl - - - passwordTextField - NSSecureTextField - - - - IBProjectSource - ./Classes/MPPasswordInputController.h - - - - MPViewController - NSViewController - - IBProjectSource - ./Classes/MPViewController.h - - - - NSLayoutConstraint - NSObject - - IBProjectSource - ./Classes/NSLayoutConstraint.h - - - - + 0 IBCocoaFramework YES