Files
MacPass/MacPass/MPEntryTableDataSource.m
michael starke 64e56fd876 Changed drag and drop architecture to use pasteboard and encoded entries/groups
First steps to enhance drag and drop to for cross document dragging and inter-document copying
2013-09-15 23:41:02 +02:00

37 lines
840 B
Objective-C

//
// MPEntyTableDataSource.m
// MacPass
//
// Created by Michael Starke on 09.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPEntryTableDataSource.h"
#import "MPEntryViewController.h"
#import "KPKEntry.h"
#import "NSUUID+KeePassKit.h"
@interface MPEntryTableDataSource ()
@end
@implementation MPEntryTableDataSource
- (BOOL)tableView:(NSTableView *)tableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard {
if([rowIndexes count] != 1) {
return NO; // No valid drag
}
id item = [self.viewController.entryArrayController arrangedObjects][[rowIndexes firstIndex]];
if(![item isKindOfClass:[KPKEntry class]]) {
return NO;
}
KPKEntry *draggedEntry = (KPKEntry *)item;
[pboard writeObjects:@[draggedEntry]];
return YES;
}
@end