Changeset 13121 for trunk/macosx/Controller.m
- Timestamp:
- Dec 29, 2011, 6:40:17 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.m
r13108 r13121 115 115 #define GROWL_AUTO_SPEED_LIMIT @"Speed Limit Auto Changed" 116 116 117 #warning remove when Lion-only 117 118 #define TORRENT_TABLE_VIEW_DATA_TYPE @"TorrentTableViewDataType" 118 119 … … 399 400 "Main window -> 3rd bottom left button (remove all) tooltip")]; 400 401 401 [fTableView registerForDraggedTypes: [NSArray arrayWithObject : TORRENT_TABLE_VIEW_DATA_TYPE]];402 [fTableView registerForDraggedTypes: [NSArray arrayWithObjects: TORRENT_TABLE_VIEW_DATA_TYPE, NSPasteboardTypeString, nil]]; 402 403 [fWindow registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, NSURLPboardType, nil]]; 403 404 … … 2476 2477 } 2477 2478 2479 #warning remove when Lion-only 2478 2480 - (BOOL) outlineView: (NSOutlineView *) outlineView writeItems: (NSArray *) items toPasteboard: (NSPasteboard *) pasteboard 2479 2481 { … … 2490 2492 } 2491 2493 2492 [pasteboard declareTypes: [NSArray arrayWithObject: TORRENT_TABLE_VIEW_DATA_TYPE] owner: self];2493 2494 [pasteboard setData: [NSKeyedArchiver archivedDataWithRootObject: indexSet] forType: TORRENT_TABLE_VIEW_DATA_TYPE]; 2494 2495 return YES; … … 2497 2498 } 2498 2499 2499 - (NSDragOperation) outlineView: (NSOutlineView *) outlineView validateDrop: (id < NSDraggingInfo >) info proposedItem: (id) item 2500 proposedChildIndex: (NSInteger) index 2501 { 2502 NSPasteboard * pasteboard = [info draggingPasteboard]; 2503 if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE]) 2500 - (id <NSPasteboardWriting>) outlineView: (NSOutlineView *) outlineView pasteboardWriterForItem: (id) item 2501 { 2502 //only allow reordering of rows if sorting by order 2503 if ([item isKindOfClass: [Torrent class]] && ([fDefaults boolForKey: @"SortByGroup"] || [[fDefaults stringForKey: @"Sort"] isEqualToString: SORT_ORDER])) 2504 { 2505 NSPasteboardItem * pbItem = [[[NSPasteboardItem alloc] init] autorelease]; 2506 #warning might make more sense to use TORRENT_TABLE_VIEW_DATA_TYPE 2507 [pbItem setData: [NSKeyedArchiver archivedDataWithRootObject: [NSNumber numberWithInteger: [fTableView rowForItem: item]]] forType: NSPasteboardTypeString]; 2508 return pbItem; 2509 } 2510 else 2511 return nil; 2512 } 2513 2514 - (NSDragOperation) outlineView: (NSOutlineView *) outlineView validateDrop: (id <NSDraggingInfo>) info proposedItem: (id) item proposedChildIndex: (NSInteger) index 2515 { 2516 if ([info draggingSource] == outlineView) 2504 2517 { 2505 2518 if ([fDefaults boolForKey: @"SortByGroup"]) … … 2540 2553 } 2541 2554 2542 - (BOOL) outlineView: (NSOutlineView *) outlineView acceptDrop: (id < NSDraggingInfo >) info item: (id) item 2543 childIndex: (NSInteger) newRow 2544 { 2545 NSPasteboard * pasteboard = [info draggingPasteboard]; 2546 if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE]) 2555 - (BOOL) outlineView: (NSOutlineView *) outlineView acceptDrop: (id <NSDraggingInfo>) info item: (id) item childIndex: (NSInteger) newRow 2556 { 2557 if ([info draggingSource] == outlineView) 2547 2558 { 2548 2559 //remember selected rows 2549 2560 NSArray * selectedValues = [fTableView selectedValues]; 2550 2551 NSIndexSet * indexes = [NSKeyedUnarchiver unarchiveObjectWithData: [pasteboard dataForType: TORRENT_TABLE_VIEW_DATA_TYPE]]; 2552 2553 //get the torrents to move 2554 NSMutableArray * movingTorrents = [NSMutableArray arrayWithCapacity: [indexes count]]; 2555 for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i]) 2556 [movingTorrents addObject: [fTableView itemAtRow: i]]; 2561 2562 NSMutableArray * movingTorrents; 2563 if ([[[info draggingPasteboard] types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE]) 2564 { 2565 NSAssert(![NSApp isOnLionOrBetter], @"Dragging using pre-Lion functionality on Lion or greater"); 2566 2567 NSIndexSet * indexes = [NSKeyedUnarchiver unarchiveObjectWithData: [[info draggingPasteboard] dataForType: TORRENT_TABLE_VIEW_DATA_TYPE]]; 2568 2569 //get the torrents to move 2570 movingTorrents = [NSMutableArray arrayWithCapacity: [indexes count]]; 2571 for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i]) 2572 [movingTorrents addObject: [fTableView itemAtRow: i]]; 2573 } 2574 else 2575 { 2576 NSAssert([NSApp isOnLionOrBetter], @"Dragging using Lion functionality on pre-Lion"); 2577 2578 movingTorrents = [NSMutableArray arrayWithCapacity: info.numberOfValidItemsForDrop]; 2579 [info enumerateDraggingItemsWithOptions: 0 forView: outlineView classes: [NSArray arrayWithObject: [NSPasteboardItem class]] searchOptions: nil usingBlock: ^(NSDraggingItem * draggingItem, NSInteger index, BOOL * stop) { 2580 NSNumber * rowNumber = [NSKeyedUnarchiver unarchiveObjectWithData: [draggingItem.item dataForType: NSPasteboardTypeString]]; 2581 [movingTorrents addObject: [fTableView itemAtRow: [rowNumber integerValue]]]; 2582 }]; 2583 } 2557 2584 2558 2585 //reset groups
Note: See TracChangeset
for help on using the changeset viewer.