5 // Created by Pieter de Bie on 6/17/08.
6 // Copyright 2008 __MyCompanyName__. All rights reserved.
9 #import "PBQLOutlineView.h"
12 @implementation PBQLOutlineView
14 - initWithCoder: (NSCoder *) coder
16 id a = [super initWithCoder:coder];
18 [a registerForDraggedTypes: [NSArray arrayWithObject:NSFilesPromisePboardType]];
22 /* Needed to drag outside application */
23 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL) local
25 return NSDragOperationCopy;
28 - (void) keyDown: (NSEvent *) event
30 if ([[event characters] isEqualToString:@" "]) {
31 [controller toggleQuickView:self];
35 [super keyDown:event];
38 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *) pb
40 NSMutableArray* fileNames = [NSMutableArray array];
41 for (id tree in items)
42 [fileNames addObject: [[[tree representedObject] path] pathExtension]];
44 [pb declareTypes:[NSArray arrayWithObject:NSFilesPromisePboardType] owner:self];
45 [pb setPropertyList:fileNames forType:NSFilesPromisePboardType];
50 - (NSArray *)outlineView:(NSOutlineView *)outlineView namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination forDraggedItems:(NSArray *)items
52 NSMutableArray* fileNames = [NSMutableArray array];
53 for (id obj in items) {
54 PBGitTree* tree = [obj representedObject];
55 [fileNames addObject: [tree path]];
56 [tree saveToFolder:[dropDestination path]];
61 - (NSMenu *)menuForEvent:(NSEvent *)theEvent
63 if ([theEvent type] == NSRightMouseDown)
65 // get the current selections for the outline view.
66 NSIndexSet *selectedRowIndexes = [self selectedRowIndexes];
68 // select the row that was clicked before showing the menu for the event
69 NSPoint mousePoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
70 int row = [self rowAtPoint:mousePoint];
72 // figure out if the row that was just clicked on is currently selected
73 if ([selectedRowIndexes containsIndex:row] == NO)
74 [self selectRow:row byExtendingSelection:NO];
77 return [controller contextMenuForTreeView];
80 /* Implemented to satisfy datasourcee protocol */
81 - (BOOL) outlineView: (NSOutlineView *)ov
82 isItemExpandable: (id)item { return NO; }
84 - (NSInteger) outlineView: (NSOutlineView *)ov
85 numberOfChildrenOfItem:(id)item { return 0; }
87 - (id) outlineView: (NSOutlineView *)ov
88 child:(NSInteger)index
89 ofItem:(id)item { return nil; }
91 - (id) outlineView: (NSOutlineView *)ov
92 objectValueForTableColumn:(NSTableColumn*)col
93 byItem:(id)item { return nil; }