mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 21:42:32 +00:00
Some work to get Drag and Drop back up again. Might be useful to postpone it until KeePassKit is ready to replace MiniKeePassLib
This commit is contained in:
Submodule KeePassKit updated: 07349e3bcb...cad68d0f6b
@@ -259,6 +259,7 @@
|
||||
4CECB31717AC326D00EAFB0F /* KPKLegacyWritingTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CECB31617AC326D00EAFB0F /* KPKLegacyWritingTest.m */; };
|
||||
4CF1F0CA1786B37900CD920E /* NSData+Gzip.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF1F0C81786B37900CD920E /* NSData+Gzip.m */; };
|
||||
4CF29BF417879D0000851B60 /* 26_FileSaveTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CF29BF317879D0000851B60 /* 26_FileSaveTemplate.pdf */; };
|
||||
4CF4FEE017AEA4A400712774 /* UUID+Pasterboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF4FEDF17AEA4A400712774 /* UUID+Pasterboard.m */; };
|
||||
4CF62B86179385D700B660B6 /* KPKAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF62B85179385D700B660B6 /* KPKAttribute.m */; };
|
||||
4CF6C711176F4533007A811D /* MPStringLengthValueTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF6C710176F4533007A811D /* MPStringLengthValueTransformer.m */; };
|
||||
4CF6C718176F5234007A811D /* MPAssociateRequestHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF6C717176F5234007A811D /* MPAssociateRequestHandler.m */; };
|
||||
@@ -756,6 +757,8 @@
|
||||
4CF1F0C81786B37900CD920E /* NSData+Gzip.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Gzip.m"; sourceTree = "<group>"; };
|
||||
4CF1F0C91786B37900CD920E /* NSData+Gzip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+Gzip.h"; sourceTree = "<group>"; };
|
||||
4CF29BF317879D0000851B60 /* 26_FileSaveTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 26_FileSaveTemplate.pdf; sourceTree = "<group>"; };
|
||||
4CF4FEDE17AEA4A400712774 /* UUID+Pasterboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UUID+Pasterboard.h"; sourceTree = "<group>"; };
|
||||
4CF4FEDF17AEA4A400712774 /* UUID+Pasterboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UUID+Pasterboard.m"; sourceTree = "<group>"; };
|
||||
4CF62B84179385D700B660B6 /* KPKAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKAttribute.h; sourceTree = "<group>"; };
|
||||
4CF62B85179385D700B660B6 /* KPKAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKAttribute.m; sourceTree = "<group>"; };
|
||||
4CF6C70F176F4533007A811D /* MPStringLengthValueTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPStringLengthValueTransformer.h; sourceTree = "<group>"; };
|
||||
@@ -1090,6 +1093,8 @@
|
||||
4C45100B1798C65C00219998 /* Kdb4Entry+MPAdditions.m */,
|
||||
4CFB5E9D17AAD20200D9B10C /* Kdb4Group+Undo.h */,
|
||||
4CFB5E9E17AAD20200D9B10C /* Kdb4Group+Undo.m */,
|
||||
4CF4FEDE17AEA4A400712774 /* UUID+Pasterboard.h */,
|
||||
4CF4FEDF17AEA4A400712774 /* UUID+Pasterboard.m */,
|
||||
);
|
||||
name = "KeePassLib Categories";
|
||||
sourceTree = "<group>";
|
||||
@@ -2094,6 +2099,7 @@
|
||||
4C79E80317A9187400AC6CD2 /* KPKXmlHeaderWriter.m in Sources */,
|
||||
4CFB5E9F17AAD20200D9B10C /* Kdb4Group+Undo.m in Sources */,
|
||||
4CE3E62617AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.m in Sources */,
|
||||
4CF4FEE017AEA4A400712774 /* UUID+Pasterboard.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
FOUNDATION_EXPORT NSString *const MPPasteBoardType;
|
||||
FOUNDATION_EXPORT NSString *const MPEntryUTI;
|
||||
FOUNDATION_EXPORT NSString *const MPGroupUTI;
|
||||
FOUNDATION_EXTERN NSString *const MPUUIDUTI;
|
||||
FOUNDATION_EXPORT NSString *const MPErrorDomain;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,4 +11,5 @@
|
||||
NSString *const MPPasteBoardType = @"com.hicknhack.macpass.pasteboard";
|
||||
NSString *const MPErrorDomain = @"com.hicknhack.macpass.error";
|
||||
NSString *const MPEntryUTI = @"com.hicknhack.macpass.entry";
|
||||
NSString *const MPGroupUTI = @"com.hicknhack.macpass.group";
|
||||
NSString *const MPGroupUTI = @"com.hicknhack.macpass.group";
|
||||
NSString *const MPUUIDUTI = @"com.hicknhack.macpass.UUID";
|
||||
@@ -8,7 +8,10 @@
|
||||
|
||||
#import "MPEntryTableDataSource.h"
|
||||
#import "MPEntryViewController.h"
|
||||
#import "UUID.h"
|
||||
|
||||
#import "Kdb.h"
|
||||
#import "UUID+Pasterboard.h"
|
||||
|
||||
#import "MPConstants.h"
|
||||
|
||||
@interface MPEntryTableDataSource ()
|
||||
@@ -23,19 +26,13 @@
|
||||
return NO; // No valid drag
|
||||
}
|
||||
|
||||
id entry = [self.viewController.entryArrayController arrangedObjects][[rowIndexes firstIndex]];
|
||||
|
||||
if(![entry respondsToSelector:@selector(uuid)]) {
|
||||
return NO; // Invalid item for dragging
|
||||
id item = [self.viewController.entryArrayController arrangedObjects][[rowIndexes firstIndex]];
|
||||
if(![item isKindOfClass:[KdbEntry class]]) {
|
||||
return NO;
|
||||
}
|
||||
UUID *uuid = (UUID *)[entry uuid];
|
||||
NSPasteboardItem *pBoardItem = [[NSPasteboardItem alloc] init];
|
||||
[pBoardItem setString:[uuid description] forType:MPPasteBoardType];
|
||||
[pboard writeObjects:@[pBoardItem]];
|
||||
|
||||
KdbEntry *entry = (KdbEntry *)item;
|
||||
[pboard writeObjects:@[entry.uuid]];
|
||||
return YES;
|
||||
}
|
||||
|
||||
//TODO: Validation and adding
|
||||
|
||||
@end
|
||||
|
||||
@@ -138,7 +138,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
|
||||
[self.entryTable setDoubleAction:@selector(_columnDoubleClick:)];
|
||||
[self.entryTable setTarget:self];
|
||||
[self.entryTable setFloatsGroupRows:NO];
|
||||
//[self.entryTable registerForDraggedTypes:@[MPPasteBoardType]];
|
||||
[self.entryTable registerForDraggedTypes:@[MPEntryUTI]];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(_didBecomFirstResponder:)
|
||||
name:MPDidActivateViewNotification
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class KdbGroup;
|
||||
@interface MPOutlineDataSource : NSObject <NSOutlineViewDataSource>
|
||||
|
||||
@interface MPOutlineDataSource : NSObject <NSOutlineViewDataSource> {
|
||||
KdbGroup *_draggedItem;
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -17,25 +17,30 @@
|
||||
#import "KdbGroup+MPTreeTools.h"
|
||||
#import "KdbEntry+MPTreeTools.h"
|
||||
|
||||
|
||||
#import "UUID.h"
|
||||
#import "UUID+Pasterboard.h"
|
||||
|
||||
@interface MPOutlineDataSource ()
|
||||
|
||||
@property (weak) KdbGroup *draggedGroup;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation MPOutlineDataSource
|
||||
|
||||
|
||||
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pasteboard {
|
||||
_draggedItem = nil;
|
||||
[pasteboard setString:@"Weee" forType:MPPasteBoardType];
|
||||
self.draggedGroup = nil;
|
||||
if([items count] == 1) {
|
||||
_draggedItem = [[items lastObject] representedObject];
|
||||
return (nil != _draggedItem.parent);
|
||||
[pasteboard setString:self.draggedGroup.name forType:MPGroupUTI];
|
||||
self.draggedGroup = [[items lastObject] representedObject];
|
||||
return (nil != self.draggedGroup.parent);
|
||||
}
|
||||
return YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id<NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index {
|
||||
if(_draggedItem) {
|
||||
info.animatesToDestination = YES;
|
||||
/* info.animatesToDestination = YES;
|
||||
NSDragOperation oprationMask = NSDragOperationMove;
|
||||
if([info draggingSourceOperationMask] == NSDragOperationCopy) {
|
||||
oprationMask = NSDragOperationCopy;
|
||||
@@ -50,9 +55,9 @@
|
||||
}
|
||||
KdbGroup *targetGroup = targetItem;
|
||||
BOOL validTarget = YES;
|
||||
if( _draggedItem.parent == targetGroup ) {
|
||||
if( self.draggedGroup.parent == targetGroup ) {
|
||||
validTarget &= index != NSOutlineViewDropOnItemIndex;
|
||||
validTarget &= index != [_draggedItem.parent.groups indexOfObject:_draggedItem];
|
||||
validTarget &= index != [self.draggedGroup.parent.groups indexOfObject:self.draggedGroup];
|
||||
}
|
||||
if( validTarget ) {
|
||||
return oprationMask;
|
||||
@@ -65,23 +70,27 @@
|
||||
[outlineView setDropItem:item dropChildIndex:NSOutlineViewDropOnItemIndex];
|
||||
}
|
||||
return NSDragOperationMove;
|
||||
}
|
||||
}*/
|
||||
self.draggedGroup = nil;
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id<NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index {
|
||||
KdbGroup *target = [item representedObject];
|
||||
if(_draggedItem) {
|
||||
self.draggedGroup = nil;
|
||||
/*
|
||||
KdbGroup *target = [item representedObject];
|
||||
if(self.draggedGroup) {
|
||||
BOOL accepted = YES;
|
||||
if( _draggedItem.parent == target ) {
|
||||
if( self.draggedGroup.parent == target ) {
|
||||
accepted &= index != NSOutlineViewDropOnItemIndex;
|
||||
accepted &= index != [_draggedItem.parent.groups indexOfObject:_draggedItem];
|
||||
accepted &= index != [self.draggedGroup.parent.groups indexOfObject:self.draggedGroup];
|
||||
}
|
||||
accepted = ![_draggedItem isAnchestorOfGroup:target];
|
||||
accepted = ![self.draggedGroup isAnchestorOfGroup:target];
|
||||
if( accepted ) {
|
||||
[_draggedItem moveToGroupUndoable:target atIndex:index];
|
||||
[self.draggedGroup moveToGroupUndoable:target atIndex:index];
|
||||
}
|
||||
info.animatesToDestination = !accepted;
|
||||
self.draggedGroup = nil;
|
||||
return accepted;
|
||||
}
|
||||
NSPasteboard *pasteBoard = [info draggingPasteboard];
|
||||
@@ -99,6 +108,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return NO;
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -72,7 +72,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
||||
[_outlineView setMenu:[self _contextMenu]];
|
||||
[_outlineView setAllowsEmptySelection:YES];
|
||||
[_outlineView setFloatsGroupRows:NO];
|
||||
//[_outlineView registerForDraggedTypes:@[ MPPasteBoardType ]];
|
||||
[_outlineView registerForDraggedTypes:@[ MPGroupUTI, MPEntryUTI, MPUUIDUTI ]];
|
||||
[_outlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES];
|
||||
[_bottomBar setBorderType:HNHBorderTop];
|
||||
[_addGroupButton setAction:[MPActionHelper actionOfType:MPActionAddGroup]];
|
||||
|
||||
13
MacPass/UUID+Pasterboard.h
Normal file
13
MacPass/UUID+Pasterboard.h
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// UUID+Pasterboard.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 04.08.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UUID.h"
|
||||
|
||||
@interface UUID (Pasterboard) <NSPasteboardReading, NSPasteboardWriting, NSCoding>
|
||||
|
||||
@end
|
||||
49
MacPass/UUID+Pasterboard.m
Normal file
49
MacPass/UUID+Pasterboard.m
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// UUID+Pasterboard.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 04.08.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UUID+Pasterboard.h"
|
||||
#import "MPConstants.h"
|
||||
|
||||
@implementation UUID (Pasterboard)
|
||||
|
||||
#pragma mark NSCoding
|
||||
|
||||
- (id)initWithCoder:(NSCoder *)aDecoder {
|
||||
NSData *data = [aDecoder decodeObjectForKey:@"data"];
|
||||
self = [self initWithData:data];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeObject:[self getData] forKey:@"data"];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark NSPasteboardReading
|
||||
|
||||
+ (NSArray *)readableTypesForPasteboard:(NSPasteboard *)pasteboard {
|
||||
return @[ MPUUIDUTI ];
|
||||
}
|
||||
|
||||
+ (NSPasteboardReadingOptions)readingOptionsForType:(NSString *)type pasteboard:(NSPasteboard *)pasteboard {
|
||||
NSAssert([type isEqualToString:MPUUIDUTI], @"Only MPUUID type is supported");
|
||||
return NSPasteboardReadingAsKeyedArchive;
|
||||
}
|
||||
#pragma mark -
|
||||
#pragma mark NSPasteboardWriting
|
||||
|
||||
- (id)pasteboardPropertyListForType:(NSString *)type {
|
||||
NSAssert([type isEqualToString:MPUUIDUTI], @"Only MPUUID type is supported");
|
||||
return [NSKeyedArchiver archivedDataWithRootObject:self];
|
||||
}
|
||||
|
||||
- (NSArray *)writableTypesForPasteboard:(NSPasteboard *)pasteboard {
|
||||
return @[ MPUUIDUTI ];
|
||||
}
|
||||
|
||||
@end
|
||||
Submodule MiniKeePassLib updated: 692f6fbf11...f8829af211
Reference in New Issue
Block a user