- fixed a bug where the tableview would send the wrong concluded dropped row to it's datasource

- implemented CPCollectioView drop on behavior
This commit is contained in:
Klaas Pieter Annema committed 2010-01-29 14:58:45 +01:00
1 parent 436f1d1541
commit ec5dcb47c9
3 files changed
+35 -13

No files matched your search

+29 -9
View File
@@ -854,28 +854,48 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
{
if (!_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_validateDrop_proposedItem_proposedChildIndex_)
return CPDragOperationNone;
var droppedItem = [_outlineView itemAtRow:theRow],
parentItem = [_outlineView parentForItem:droppedItem],
var itemInfo = (parentItem != nil) ? _outlineView._itemInfosForItems[[parentItem UID]] : _outlineView._rootItemInfo,
children = itemInfo.children,
parentItem = [_outlineView parentForItem:droppedItem];
childIndex = CPNotFound;
if (theOperation === CPTableViewDropAbove)
{
var itemInfo = (parentItem != nil) ? _outlineView._itemInfosForItems[[parentItem UID]] : _outlineView._rootItemInfo,
children = itemInfo.children,
childIndex = [children indexOfObject:droppedItem];
}
else if (theOperation === CPTableViewDropOn)
{
parentItem = droppedItem;
childIndex = -1;
}
return [_outlineView._outlineViewDataSource outlineView:_outlineView validateDrop:theInfo proposedItem:parentItem proposedChildIndex:childIndex];
}
- (BOOL)tableView:(CPTableView)aTableView acceptDrop:(id <CPDraggingInfo>)theInfo row:(int)theRow dropOperation:(CPTableViewDropOperation)theOperation
{
{
if (!_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_acceptDrop_item_childIndex_)
return NO;
var droppedItem = [_outlineView itemAtRow:theRow],
parentItem = [_outlineView parentForItem:droppedItem],
parentItem = [_outlineView parentForItem:droppedItem];
childIndex = CPNotFound;
if (theOperation === CPTableViewDropAbove)
{
var itemInfo = (parentItem != nil) ? _outlineView._itemInfosForItems[[parentItem UID]] : _outlineView._rootItemInfo,
children = itemInfo.children,
var itemInfo = (parentItem != nil) ? _outlineView._itemInfosForItems[[parentItem UID]] : _outlineView._rootItemInfo,
children = itemInfo.children,
childIndex = [children indexOfObject:droppedItem];
}
else if (theOperation === CPTableViewDropOn)
{
parentItem = droppedItem;
childIndex = -1;
}
return [_outlineView._outlineViewDataSource outlineView:_outlineView acceptDrop:theInfo item:parentItem childIndex:childIndex];
}
+5 -3
View File
@@ -2507,9 +2507,11 @@ window.setTimeout(function(){
else if (dropOperation === CPTableViewDropOn)
{
dropOperationFeedbackView = [self viewForDropHighlightOnRow:row];
// FIXME: this doesn't work for tableviews that have alternating row background colors
[self addSubview:dropOperationFeedbackView positioned:CPWindowBelow relativeTo:nil];
}
[self _setDropOperationFeedbackView:dropOperationFeedbackView];
if (CGRectIsNull([[self _dropOperationFeedbackView] frame]))
@@ -2542,12 +2544,12 @@ window.setTimeout(function(){
- (BOOL)performDragOperation:(id)sender
{
var location = [self convertPoint:[sender draggingLocation] fromView:nil];
operation = [self _proposedDropOperationAtPoint:location],
operation = [self _proposedDropOperationAtPoint:location];
if(_retargetedDropRow !== nil)
var row = _retargetedDropRow;
else
var row = [self rowAtPoint:location] - 1;
var row = [self rowAtPoint:location];
return [_dataSource tableView:self acceptDrop:sender row:row dropOperation:operation];
}
@@ -207,7 +207,7 @@ CPLogRegister(CPLogConsole);
- (CPDragOperation)outlineView:(CPOutlineView)anOutlineView validateDrop:(id < CPDraggingInfo >)theInfo proposedItem:(id)theItem proposedChildIndex:(int)theIndex
{
// CPLog.debug(@"parent: %@ index: %i", theItem, theIndex);
CPLog.debug(@"validate drop at index: %i item: %@", theIndex, theItem);
return CPDragOperationEvery;
}