mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-05 20:25:32 +00:00
implement setDropItem:dropChildIndex on CPOutlineView
This commit is contained in:
1 parent
0375e7a881
commit
78b4bbb06e
3 files changed
+53
-57
No files matched your search
+45
-47
@@ -201,6 +201,9 @@ CPOutlineViewDropOnItemIndex = -1;
|
||||
itemInfo = _rootItemInfo;
|
||||
else
|
||||
itemInfo = _itemInfosForItems[[anItem UID]];
|
||||
|
||||
if (!itemInfo)
|
||||
return;
|
||||
|
||||
itemInfo.isExpanded = YES;
|
||||
[self reloadItem:anItem reloadChildren:YES];
|
||||
@@ -508,63 +511,58 @@ CPOutlineViewDropOnItemIndex = -1;
|
||||
|
||||
- (void)setDropItem:(id)theItem dropChildIndex:(int)theIndex
|
||||
{
|
||||
[self doesNotRecognizeSelector:_cmd];
|
||||
// var dropRow = [self rowForItem:theItem],
|
||||
// dropOperation = CPTableViewDropOn;
|
||||
//
|
||||
// if (theIndex !== CPOutlineViewDropOnItemIndex)
|
||||
// {
|
||||
// dropOperation = CPTableViewDropAbove;
|
||||
//
|
||||
// var itemInfo = _itemInfosForItems[[theItem UID]];
|
||||
//
|
||||
// if (!itemInfo)
|
||||
// itemInfo = _rootItemInfo;
|
||||
//
|
||||
// var children = itemInfo.children;
|
||||
//
|
||||
// if (theIndex < [children count])
|
||||
// {
|
||||
// childItem = [children objectAtIndex:theIndex];
|
||||
// itemInfo = _itemInfosForItems[[childItem UID]];
|
||||
// dropRow = itemInfo.row;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // We dropped outside of the range of children for this item
|
||||
// // Determine the tableviews dropped row indexes by asking for the row index of the last item + 1
|
||||
// dropRow = [self rowForItem:[children lastObject]] + 1;
|
||||
// }
|
||||
//
|
||||
// // CPLog.debug(@"changed drop operation: %i", dropOperation);
|
||||
// }
|
||||
//
|
||||
// CPLog.debug(@"set drop row: %i operation: %i", dropRow, dropOperation);
|
||||
//
|
||||
// [self setDropRow:dropRow dropOperation:dropOperation];
|
||||
var dropRow = [self rowForItem:theItem],
|
||||
dropOperation = CPTableViewDropOn;
|
||||
|
||||
if (theIndex !== CPOutlineViewDropOnItemIndex)
|
||||
{
|
||||
dropOperation = CPTableViewDropAbove;
|
||||
|
||||
var itemInfo = nil;
|
||||
if (!theItem)
|
||||
itemInfo = _rootItemInfo;
|
||||
else
|
||||
itemInfo = _itemInfosForItems[[theItem UID]];
|
||||
|
||||
var children = itemInfo.children;
|
||||
|
||||
if (theIndex < [children count])
|
||||
{
|
||||
childItem = [children objectAtIndex:theIndex];
|
||||
itemInfo = _itemInfosForItems[[childItem UID]];
|
||||
dropRow = itemInfo.row;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We dropped outside of the range of children for this item
|
||||
// Determine the tableviews dropped row indexes by asking for the row index of the last item + 1
|
||||
dropRow = [self rowForItem:[children lastObject]] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
[self setDropRow:dropRow dropOperation:dropOperation];
|
||||
}
|
||||
|
||||
- (id)_parentItemForUpperRow:(int)theUpperRowIndex andLowerRow:(int)theLowerRowIndex atMouseOffset:(CPPoint)theOffset
|
||||
{
|
||||
var lowerLevel = [self levelForRow:theLowerRowIndex]
|
||||
upperItem = [self itemAtRow:theUpperRowIndex];
|
||||
upperItem = [self itemAtRow:theUpperRowIndex];
|
||||
upperLevel = [self levelForItem:upperItem];
|
||||
|
||||
// If the row above us has a higher level the item can be added to multiple parent items
|
||||
// Determine which one by looping through all possible parents and return the first
|
||||
// of which the indentation level is larger than the current x offset
|
||||
while (upperLevel > lowerLevel)
|
||||
{
|
||||
upperLevel = [self levelForItem:upperItem];
|
||||
while (upperLevel > lowerLevel)
|
||||
{
|
||||
upperLevel = [self levelForItem:upperItem];
|
||||
|
||||
// See if this item's indentation level matches the mouse offset
|
||||
if (theOffset.x > (upperLevel + 1) * [self indentationPerLevel])
|
||||
return [self parentForItem:upperItem];
|
||||
// See if this item's indentation level matches the mouse offset
|
||||
if (theOffset.x > (upperLevel + 1) * [self indentationPerLevel])
|
||||
return [self parentForItem:upperItem];
|
||||
|
||||
// Check the next parent
|
||||
upperItem = [self parentForItem:upperItem];
|
||||
}
|
||||
// Check the next parent
|
||||
upperItem = [self parentForItem:upperItem];
|
||||
}
|
||||
|
||||
return [self parentForItem:[self itemAtRow:theLowerRowIndex]];
|
||||
}
|
||||
@@ -575,10 +573,10 @@ CPOutlineViewDropOnItemIndex = -1;
|
||||
var rect = [super _rectForDropHighlightViewBetweenUpperRow:theUpperRowIndex andLowerRow:theLowerRowIndex offset:theOffset],
|
||||
parentItem = [self _parentItemForUpperRow:theUpperRowIndex andLowerRow:theLowerRowIndex atMouseOffset:theOffset],
|
||||
level = [self levelForItem:parentItem];
|
||||
|
||||
|
||||
rect.origin.x = (level + 1) * [self indentationPerLevel];
|
||||
rect.size.width -= rect.origin.x; // This assumes that the x returned by super is zero
|
||||
|
||||
rect.size.width -= rect.origin.x; // This assumes that the x returned by super is zero
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
||||
@@ -2641,8 +2641,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
dropOperation = [self _proposedDropOperationAtPoint:location],
|
||||
numberOfRows = [self numberOfRows];
|
||||
|
||||
// CPLog.debug(@"offset: %@", CPStringFromPoint(location));
|
||||
|
||||
var row = [self _proposedRowAtPoint:location],
|
||||
dragOperation = [self _validateDrop:sender proposedRow:row proposedDropOperation:dropOperation];
|
||||
exposedClipRect = [self exposedClipRect];
|
||||
|
||||
@@ -196,8 +196,8 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
var column = [[CPTableColumn alloc] initWithIdentifier:@"One"];
|
||||
[_outlineView addTableColumn:column];
|
||||
[_outlineView setOutlineTableColumn:column];
|
||||
|
||||
[_outlineView addTableColumn:[[CPTableColumn alloc] initWithIdentifier:@"Two"]];
|
||||
|
||||
[_outlineView addTableColumn:[[CPTableColumn alloc] initWithIdentifier:@"Two"]];
|
||||
|
||||
[_outlineView registerForDraggedTypes:[CustomOutlineViewDragType]];
|
||||
|
||||
@@ -248,9 +248,9 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
|
||||
- (id)outlineView:(CPOutlineView)anOutlineView objectValueForTableColumn:(CPTableColumn)theColumn byItem:(id)theItem
|
||||
{
|
||||
// if ([theColumn identifier] === @"Two")
|
||||
// return @"Two";
|
||||
|
||||
// if ([theColumn identifier] === @"Two")
|
||||
// return @"Two";
|
||||
|
||||
if (theItem === nil)
|
||||
theItem = [self menu];
|
||||
|
||||
@@ -271,11 +271,11 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
- (CPDragOperation)outlineView:(CPOutlineView)anOutlineView validateDrop:(id < CPDraggingInfo >)theInfo proposedItem:(id)theItem proposedChildIndex:(int)theIndex
|
||||
{
|
||||
if (theItem === nil)
|
||||
theItem = [self menu];
|
||||
[anOutlineView setDropItem:nil dropChildIndex:theIndex];
|
||||
|
||||
// CPLog.debug(@"validate item: %@ at index: %i", theItem, theIndex);
|
||||
// [anOutlineView setDropItem:theItem dropChildIndex:theIndex];
|
||||
|
||||
[anOutlineView setDropItem:theItem dropChildIndex:theIndex];
|
||||
|
||||
return CPDragOperationEvery;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user