Source

OPML / OPML / OPMLOutlineView.m

Full commit
//
//  OPMLOutlineView.m
//  OPML
//
//  Created by Ivan Vučica on 07.01.2012..
//  Copyright (c) 2012 Ivan Vučica. All rights reserved.
//

#import "OPMLOutlineView.h"
#import "OPMLOutline+ViewRelated.h"

#if GNUSTEP
#define CGRect NSRect
#endif

@implementation OPMLOutlineView
-(CGRect)frameOfOutlineCellAtRow:(NSInteger)row
{
    CGRect frame = [super frameOfOutlineCellAtRow:row];
    frame.size.height = [self rowHeight];
    return frame;
}
- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
{
    NSLog(@"Inquiring about %@ and %@", sendType, returnType);
    if([sendType isEqualToString:OPMLOutline_NodeDragAndDropPboardType] && [returnType isEqualToString:NSPasteboardTypeString])
        return self;
    if([sendType isEqualToString:NSPasteboardTypeString] && [returnType isEqualToString:NSPasteboardTypeString])
        return self;
    
    if(sendType == nil && [returnType isEqualToString:NSPasteboardTypeString])
        return self;
    
    if([sendType isEqualToString:OPMLOutline_NodeDragAndDropPboardType] && returnType == nil)
        return self;
    if([sendType isEqualToString:NSPasteboardTypeString] && returnType == nil)
        return self;
    
    return [super validRequestorForSendType:sendType returnType:returnType];
}
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types
{
    return [[self dataSource] outlineView:self 
                               writeItems:[NSArray arrayWithObject:[self itemAtRow:[self selectedRow]]]
                             toPasteboard:pboard];
}

- (IBAction)copy:(id)sender
{
    NSPasteboard * pboard = [NSPasteboard generalPasteboard];
    [self writeSelectionToPasteboard:pboard types:[((OPMLOutline*)[self dataSource]) writablePasteboardTypes]];
}

- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal
{
    if(isLocal)
        return NSDragOperationMove | NSDragOperationCopy;
    else
        return NSDragOperationCopy;
}
@end