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

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

View File

@@ -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

View File

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

View File

@@ -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

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
attribute:NSLayoutAttributeNotAnAttribute
multiplier:1
constant:300];
constant:200];
self.hideConstraint = [NSLayoutConstraint constraintWithItem:[self view] attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:nil

View File

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

View File

@@ -51,7 +51,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{96, 175}, {184, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="662046682"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
@@ -100,7 +99,6 @@
</set>
<string key="NSFrame">{{157, 200}, {48, 48}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="660673733"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@@ -125,7 +123,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{127, 50}, {82, 32}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="769513826"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@@ -154,7 +151,6 @@
</set>
<string key="NSFrame">{{83, 94}, {197, 22}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="132133585"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@@ -179,7 +175,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{86, 123}, {191, 22}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="333885704"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@@ -217,7 +212,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 126}, {64, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="219521947"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
@@ -238,7 +232,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{35, 99}, {46, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1034097047"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
@@ -259,7 +252,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{209, 50}, {74, 32}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<string key="NSHuggingPriority">{250, 250}</string>
<bool key="NSEnabled">YES</bool>
@@ -282,7 +275,6 @@
</array>
<string key="NSFrameSize">{362, 268}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="204058255"/>
<string key="NSAntiCompressionPriority">{751, 750}</string>
<string key="NSClassName">NSView</string>
@@ -1096,69 +1088,7 @@
<nil key="sourceID"/>
<int key="maxID">295</int>
</object>
<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>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>