mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 03:32:40 +00:00
Fixed #5 Draggin to children now not possible
This commit is contained in:
@@ -239,6 +239,7 @@
|
|||||||
<string key="NSFrame">{{212, 286}, {32, 25}}</string>
|
<string key="NSFrame">{{212, 286}, {32, 25}}</string>
|
||||||
<reference key="NSSuperview" ref="87082330"/>
|
<reference key="NSSuperview" ref="87082330"/>
|
||||||
<reference key="NSWindow"/>
|
<reference key="NSWindow"/>
|
||||||
|
<reference key="NSNextKeyView"/>
|
||||||
<string key="NSReuseIdentifierKey">_NS:22</string>
|
<string key="NSReuseIdentifierKey">_NS:22</string>
|
||||||
<bool key="NSEnabled">YES</bool>
|
<bool key="NSEnabled">YES</bool>
|
||||||
<object class="NSButtonCell" key="NSCell" id="353877023">
|
<object class="NSButtonCell" key="NSCell" id="353877023">
|
||||||
@@ -1422,7 +1423,6 @@
|
|||||||
<string key="479.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string key="479.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string key="493.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string key="493.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string key="495.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string key="495.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string key="496.CustomClassName">HNHRoundedTextFieldCell</string>
|
|
||||||
<string key="496.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string key="496.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string key="497.CustomClassName">HNHRoundedTextFieldCell</string>
|
<string key="497.CustomClassName">HNHRoundedTextFieldCell</string>
|
||||||
<string key="497.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string key="497.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
|
|||||||
@@ -39,4 +39,7 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
|||||||
- (void)deleteEntry:(KdbEntry *)entry;
|
- (void)deleteEntry:(KdbEntry *)entry;
|
||||||
- (void)deleteGroup:(KdbGroup *)group;
|
- (void)deleteGroup:(KdbGroup *)group;
|
||||||
|
|
||||||
|
- (void)moveGroup:(KdbGroup *)group toGroup:(KdbGroup *)target index:(NSInteger)index;
|
||||||
|
- (BOOL)group:(KdbGroup *)group isMoveableToGroup:(KdbGroup *)target;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#import "KdbPassword.h"
|
#import "KdbPassword.h"
|
||||||
#import "MPDatabaseVersion.h"
|
#import "MPDatabaseVersion.h"
|
||||||
#import "KdbGroup+Undo.h"
|
#import "KdbGroup+Undo.h"
|
||||||
|
#import "KdbGroup+KVOAdditions.h"
|
||||||
#import "KdbEntry+Undo.h"
|
#import "KdbEntry+Undo.h"
|
||||||
|
|
||||||
NSString *const MPDocumentDidAddGroupNotification = @"MPDocumentDidAddGroupNotification";
|
NSString *const MPDocumentDidAddGroupNotification = @"MPDocumentDidAddGroupNotification";
|
||||||
@@ -170,5 +171,35 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)moveGroup:(KdbGroup *)group toGroup:(KdbGroup *)target index:(NSInteger)index {
|
||||||
|
NSInteger oldIndex = [group.parent.groups indexOfObject:group];
|
||||||
|
if(group.parent == target && oldIndex == index) {
|
||||||
|
return; // No changes
|
||||||
|
}
|
||||||
|
[[[self undoManager] prepareWithInvocationTarget:self] moveGroup:group toGroup:group.parent index:oldIndex];
|
||||||
|
[[self undoManager] setActionName:@"MOVE_GROUP"];
|
||||||
|
[group retain]; // Might get freed in the process
|
||||||
|
[group.parent removeObjectFromGroupsAtIndex:oldIndex];
|
||||||
|
if(index < 0 || index > [target.groups count] ) {
|
||||||
|
index = [target.groups count];
|
||||||
|
}
|
||||||
|
[target insertObject:group inGroupsAtIndex:index];
|
||||||
|
[group release];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)group:(KdbGroup *)group isMoveableToGroup:(KdbGroup *)target {
|
||||||
|
if(target == nil) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
BOOL isMovable = YES;
|
||||||
|
KdbGroup *ancestor = target.parent;
|
||||||
|
while(ancestor.parent) {
|
||||||
|
if(ancestor == group) {
|
||||||
|
isMovable = NO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ancestor = ancestor.parent;
|
||||||
|
}
|
||||||
|
return isMovable;
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -29,14 +29,18 @@ NSString *const MPPasteBoardType = @"com.hicknhack.macpass.pasteboard";
|
|||||||
|
|
||||||
- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id<NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index {
|
- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id<NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index {
|
||||||
if(_draggedItem) {
|
if(_draggedItem) {
|
||||||
|
info.animatesToDestination = YES;
|
||||||
KdbGroup *target = [item representedObject];
|
KdbGroup *target = [item representedObject];
|
||||||
if( target == nil) {
|
if( target == nil) {
|
||||||
return NSDragOperationNone; // Draggin over root
|
return NSDragOperationNone; // Draggin over root
|
||||||
}
|
}
|
||||||
BOOL validParent = ( _draggedItem.parent == target && index != NSOutlineViewDropOnItemIndex);
|
BOOL validTarget = YES;
|
||||||
if(validParent || _draggedItem.parent != target) {
|
if( _draggedItem.parent == target ) {
|
||||||
|
validTarget &= index != NSOutlineViewDropOnItemIndex;
|
||||||
|
validTarget &= index != [_draggedItem.parent.groups indexOfObject:_draggedItem];
|
||||||
|
}
|
||||||
|
if( validTarget ) {
|
||||||
return NSDragOperationMove;
|
return NSDragOperationMove;
|
||||||
info.animatesToDestination = YES;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NSDragOperationNone;
|
return NSDragOperationNone;
|
||||||
@@ -45,9 +49,17 @@ NSString *const MPPasteBoardType = @"com.hicknhack.macpass.pasteboard";
|
|||||||
- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id<NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index {
|
- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id<NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index {
|
||||||
NSLog(@"Drag %@ to: %@ index: %ld", _draggedItem, [item representedObject], index);
|
NSLog(@"Drag %@ to: %@ index: %ld", _draggedItem, [item representedObject], index);
|
||||||
KdbGroup *target = [item representedObject];
|
KdbGroup *target = [item representedObject];
|
||||||
BOOL accepted = (target != _draggedItem.parent);
|
BOOL accepted = YES;
|
||||||
|
if( _draggedItem.parent == target ) {
|
||||||
|
accepted &= index != NSOutlineViewDropOnItemIndex;
|
||||||
|
accepted &= index != [_draggedItem.parent.groups indexOfObject:_draggedItem];
|
||||||
|
}
|
||||||
info.animatesToDestination = YES;
|
info.animatesToDestination = YES;
|
||||||
[_draggedItem moveToGroupUndoable:target];
|
MPDocument *document = [[[outlineView window] windowController] document];
|
||||||
|
accepted = [document group:_draggedItem isMoveableToGroup:target];
|
||||||
|
if( accepted ) {
|
||||||
|
[document moveGroup:_draggedItem toGroup:target index:index];
|
||||||
|
}
|
||||||
return accepted;
|
return accepted;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>ABD</string>
|
<string>ACC</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
|||||||
Reference in New Issue
Block a user