1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00

get drag/drop to work again

This commit is contained in:
Mitchell Livingston 2008-02-07 11:57:24 +00:00
parent 5e2308daf9
commit d718f410fc

View file

@ -322,8 +322,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[fPrefsController setUpdater: fUpdater]; [fPrefsController setUpdater: fUpdater];
#warning fix [fTableView registerForDraggedTypes: [NSArray arrayWithObject: TORRENT_TABLE_VIEW_DATA_TYPE]];
//[fTableView registerForDraggedTypes: [NSArray arrayWithObject: TORRENT_TABLE_VIEW_DATA_TYPE]];
[fWindow registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, NSURLPboardType, nil]]; [fWindow registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, NSURLPboardType, nil]];
//register for sleep notifications //register for sleep notifications
@ -1632,7 +1631,9 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
case SORT_ORDER_TAG: case SORT_ORDER_TAG:
sortType = SORT_ORDER; sortType = SORT_ORDER;
[fDefaults setBool: NO forKey: @"SortReverse"]; [fDefaults setBool: NO forKey: @"SortReverse"];
[fDefaults setBool: NO forKey: @"SortByGroup"]; [fDefaults setBool: NO forKey: @"SortByGroup"];
[fTableView removeAllCollapsedGroups];
[self applyFilter: nil]; //ensure groups are removed [self applyFilter: nil]; //ensure groups are removed
break; break;
@ -2472,34 +2473,43 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
return [item hashString]; return [item hashString];
} }
#warning fix - (BOOL) outlineView: (NSOutlineView *) outlineView writeItems: (NSArray *) items toPasteboard: (NSPasteboard *) pasteboard
- (BOOL) tableView: (NSTableView *) tableView writeRowsWithIndexes: (NSIndexSet *) indexes toPasteboard: (NSPasteboard *) pasteboard
{ {
//only allow reordering of rows if sorting by order //only allow reordering of rows if sorting by order
if ([[fDefaults stringForKey: @"Sort"] isEqualToString: SORT_ORDER]) if ([[fDefaults stringForKey: @"Sort"] isEqualToString: SORT_ORDER])
{ {
[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: indexes] forType: TORRENT_TABLE_VIEW_DATA_TYPE];
NSMutableIndexSet * indexSet = [NSMutableIndexSet indexSet];
NSEnumerator * enumerator = [items objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
[indexSet addIndex: [fTableView rowForItem: torrent]];
[pasteboard setData: [NSKeyedArchiver archivedDataWithRootObject: indexSet] forType: TORRENT_TABLE_VIEW_DATA_TYPE];
return YES; return YES;
} }
return NO; return NO;
} }
- (NSDragOperation) tableView: (NSTableView *) tableView validateDrop: (id <NSDraggingInfo>) info - (NSDragOperation) outlineView: (NSOutlineView *) outlineView validateDrop: (id < NSDraggingInfo >) info proposedItem: (id) item
proposedRow: (int) row proposedDropOperation: (NSTableViewDropOperation) operation proposedChildIndex: (NSInteger) index
{ {
NSPasteboard * pasteboard = [info draggingPasteboard]; NSPasteboard * pasteboard = [info draggingPasteboard];
if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE]) if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE])
{ {
[fTableView setDropRow: row dropOperation: NSTableViewDropAbove]; if (item)
index = [fTableView rowForItem: item] + 1;
[fTableView setDropItem: nil dropChildIndex: index];
return NSDragOperationGeneric; return NSDragOperationGeneric;
} }
return NSDragOperationNone; return NSDragOperationNone;
} }
- (BOOL) tableView: (NSTableView *) t acceptDrop: (id <NSDraggingInfo>) info - (BOOL) outlineView: (NSOutlineView *) outlineView acceptDrop: (id < NSDraggingInfo >) info item: (id) item
row: (int) newRow dropOperation: (NSTableViewDropOperation) operation childIndex: (NSInteger) newRow
{ {
NSPasteboard * pasteboard = [info draggingPasteboard]; NSPasteboard * pasteboard = [info draggingPasteboard];
if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE]) if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE])