Files
MacPass/MacPass/MPEntryTableDataSource.m
michael starke ae0fae13c1 Renamed Categories better
Introduced Drag'n'Drop of Entries to outline view. Unfinished and fragile!
2013-06-10 01:12:32 +02:00

43 lines
1.0 KiB
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 "UUID.h"
#import "MPConstants.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 entry = [self.viewController.entryArrayController arrangedObjects][[rowIndexes firstIndex]];
if(![entry respondsToSelector:@selector(uuid)]) {
return NO; // Invalid item for dragging
}
UUID *uuid = (UUID *)[entry uuid];
NSPasteboardItem *pBoardItem = [[NSPasteboardItem alloc] init];
[pBoardItem setString:[uuid description] forType:MPPasteBoardType];
[pboard writeObjects:@[pBoardItem]];
[pBoardItem release];
return YES;
}
//TODO: Validation and adding
@end