#define GROWL_AUTO_ADD @"Torrent Auto Added"
#define GROWL_AUTO_SPEED_LIMIT @"Speed Limit Auto Changed"
-#warning remove when Lion-only
#define TORRENT_TABLE_VIEW_DATA_TYPE @"TorrentTableViewDataType"
#define ROW_HEIGHT_REGULAR 62.0
[fClearCompletedButton setToolTip: NSLocalizedString(@"Remove all transfers that have completed seeding.",
"Main window -> 3rd bottom left button (remove all) tooltip")];
- [fTableView registerForDraggedTypes: [NSArray arrayWithObjects: TORRENT_TABLE_VIEW_DATA_TYPE, NSPasteboardTypeString, nil]];
+ [fTableView registerForDraggedTypes: [NSArray arrayWithObject: TORRENT_TABLE_VIEW_DATA_TYPE]];
[fWindow registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, NSURLPboardType, nil]];
//you would think this would be called later in this method from updateUI, but it's not reached in awakeFromNib
}
}
-#warning remove when Lion-only
- (BOOL) outlineView: (NSOutlineView *) outlineView writeItems: (NSArray *) items toPasteboard: (NSPasteboard *) pasteboard
{
//only allow reordering of rows if sorting by order
[indexSet addIndex: [fTableView rowForItem: torrent]];
}
- [pasteboard declareTypes: [NSArray arrayWithObject: TORRENT_TABLE_VIEW_DATA_TYPE] owner: self];
+ [pasteboard declareTypes: [NSArray arrayWithObject: TORRENT_TABLE_VIEW_DATA_TYPE] owner: self];
[pasteboard setData: [NSKeyedArchiver archivedDataWithRootObject: indexSet] forType: TORRENT_TABLE_VIEW_DATA_TYPE];
return YES;
}
return NO;
}
-- (id <NSPasteboardWriting>) outlineView: (NSOutlineView *) outlineView pasteboardWriterForItem: (id) item
+- (NSDragOperation) outlineView: (NSOutlineView *) outlineView validateDrop: (id < NSDraggingInfo >) info proposedItem: (id) item
+ proposedChildIndex: (NSInteger) index
{
- //only allow reordering of rows if sorting by order
- if ([item isKindOfClass: [Torrent class]] && ([fDefaults boolForKey: @"SortByGroup"] || [[fDefaults stringForKey: @"Sort"] isEqualToString: SORT_ORDER]))
- {
- NSPasteboardItem * pbItem = [[[NSPasteboardItem alloc] init] autorelease];
- #warning might make more sense to use TORRENT_TABLE_VIEW_DATA_TYPE
- [pbItem setData: [NSKeyedArchiver archivedDataWithRootObject: [NSNumber numberWithInteger: [fTableView rowForItem: item]]] forType: NSPasteboardTypeString];
- return pbItem;
- }
- else
- return nil;
-}
-
-- (NSDragOperation) outlineView: (NSOutlineView *) outlineView validateDrop: (id <NSDraggingInfo>) info proposedItem: (id) item proposedChildIndex: (NSInteger) index
-{
- if ([info draggingSource] == outlineView)
+ NSPasteboard * pasteboard = [info draggingPasteboard];
+ if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE])
{
if ([fDefaults boolForKey: @"SortByGroup"])
{
return NSDragOperationNone;
}
-- (BOOL) outlineView: (NSOutlineView *) outlineView acceptDrop: (id <NSDraggingInfo>) info item: (id) item childIndex: (NSInteger) newRow
+- (BOOL) outlineView: (NSOutlineView *) outlineView acceptDrop: (id < NSDraggingInfo >) info item: (id) item
+ childIndex: (NSInteger) newRow
{
- if ([info draggingSource] == outlineView)
+ NSPasteboard * pasteboard = [info draggingPasteboard];
+ if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE])
{
//remember selected rows
NSArray * selectedValues = [fTableView selectedValues];
+
+ NSIndexSet * indexes = [NSKeyedUnarchiver unarchiveObjectWithData: [pasteboard dataForType: TORRENT_TABLE_VIEW_DATA_TYPE]];
- NSMutableArray * movingTorrents;
- if ([[[info draggingPasteboard] types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE])
- {
- NSAssert(![NSApp isOnLionOrBetter], @"Dragging using pre-Lion functionality on Lion or greater");
-
- NSIndexSet * indexes = [NSKeyedUnarchiver unarchiveObjectWithData: [[info draggingPasteboard] dataForType: TORRENT_TABLE_VIEW_DATA_TYPE]];
-
- //get the torrents to move
- movingTorrents = [NSMutableArray arrayWithCapacity: [indexes count]];
- for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
- [movingTorrents addObject: [fTableView itemAtRow: i]];
- }
- else
- {
- NSAssert([NSApp isOnLionOrBetter], @"Dragging using Lion functionality on pre-Lion");
-
- movingTorrents = [NSMutableArray arrayWithCapacity: info.numberOfValidItemsForDrop];
- [info enumerateDraggingItemsWithOptions: 0 forView: outlineView classes: [NSArray arrayWithObject: [NSPasteboardItem class]] searchOptions: nil usingBlock: ^(NSDraggingItem * draggingItem, NSInteger index, BOOL * stop) {
- NSNumber * rowNumber = [NSKeyedUnarchiver unarchiveObjectWithData: [draggingItem.item dataForType: NSPasteboardTypeString]];
- [movingTorrents addObject: [fTableView itemAtRow: [rowNumber integerValue]]];
- }];
- }
+ //get the torrents to move
+ NSMutableArray * movingTorrents = [NSMutableArray arrayWithCapacity: [indexes count]];
+ for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
+ [movingTorrents addObject: [fTableView itemAtRow: i]];
//reset groups
if (item)