mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-14 22:51:28 +00:00
Fixed: when an outline view node was expanded, selections below it would not stick to their items if the newly expanded node also had previously expanded children.
This commit is contained in:
+10
-8
@@ -349,9 +349,16 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
{
|
||||
[self _noteItemWillExpand:anItem];
|
||||
|
||||
var previousRowCount = [self numberOfRows];
|
||||
|
||||
itemInfo.isExpanded = YES;
|
||||
// XXX Shouldn't the items reload before the notification is sent?
|
||||
[self _noteItemDidExpand:anItem];
|
||||
[self reloadItem:anItem reloadChildren:YES];
|
||||
|
||||
// Shift selection indexes below so that the same items remain selected.
|
||||
var newRowCount = [_outlineViewDataSource outlineView:self numberOfChildrenOfItem:anItem];
|
||||
if (newRowCount)
|
||||
var rowCountDelta = [self numberOfRows] - previousRowCount;
|
||||
if (rowCountDelta)
|
||||
{
|
||||
var selection = [self selectedRowIndexes],
|
||||
expandIndex = [self rowForItem:anItem] + 1;
|
||||
@@ -359,15 +366,10 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
if ([selection intersectsIndexesInRange:CPMakeRange(expandIndex, _itemsForRows.length)])
|
||||
{
|
||||
[self _noteSelectionIsChanging];
|
||||
[selection shiftIndexesStartingAtIndex:expandIndex by:newRowCount];
|
||||
[selection shiftIndexesStartingAtIndex:expandIndex by:rowCountDelta];
|
||||
[self _setSelectedRowIndexes:selection]; // _noteSelectionDidChange will be suppressed.
|
||||
}
|
||||
}
|
||||
|
||||
itemInfo.isExpanded = YES;
|
||||
// XXX Shouldn't the items reload before the notification is sent?
|
||||
[self _noteItemDidExpand:anItem];
|
||||
[self reloadItem:anItem reloadChildren:YES];
|
||||
}
|
||||
|
||||
if (shouldExpandChildren)
|
||||
|
||||
@@ -138,6 +138,29 @@
|
||||
[self assert:1 equals:[delegate selectionChangeCount] message:"selection notifications during expandItem"];
|
||||
}
|
||||
|
||||
/*!
|
||||
Test selection updates when an expanded node has pre-expanded children.
|
||||
*/
|
||||
- (void)testExpandWithSelectionBelowAndExpandedChildren
|
||||
{
|
||||
// [".1", ".1.1", ".1.2", ".1.2.1", ".1.2.2", ".2", ".3", ".3.1"]
|
||||
[outlineView collapseItem:".1"];
|
||||
|
||||
var preSelection = [CPIndexSet indexSet];
|
||||
[preSelection addIndex:[outlineView rowForItem:".2"]];
|
||||
[preSelection addIndex:[outlineView rowForItem:".3.1"]];
|
||||
|
||||
[outlineView selectRowIndexes:preSelection byExtendingSelection:NO];
|
||||
var delegate = [TestNotificationsDelegate new];
|
||||
[delegate setTester:self];
|
||||
[delegate setExpectedSelectedItems:[".2", ".3.1"]];
|
||||
[outlineView setDelegate:delegate];
|
||||
|
||||
[outlineView expandItem:".1"];
|
||||
// The delegate will check the selection update but not the count.
|
||||
[self assert:2 equals:[[outlineView selectedRowIndexes] count] message:"selections should remain"];
|
||||
}
|
||||
|
||||
/*!
|
||||
Test that the outline view is properly careful about not encoding its
|
||||
non-encodable delegate and data source.
|
||||
|
||||
Reference in New Issue
Block a user