Slightly simplify proposed drop index determination
No real changes, just reorganize the code in a way that should hopefully be more clear to understand.
This commit is contained in:
@@ -2233,15 +2233,25 @@ wxDataViewMainWindow::DropItemInfo wxDataViewMainWindow::GetDropItemInfo(const w
|
|||||||
if (m_owner->GetModel()->IsContainer(ascendNode->GetItem()))
|
if (m_owner->GetModel()->IsContainer(ascendNode->GetItem()))
|
||||||
{
|
{
|
||||||
// Item can be inserted
|
// Item can be inserted
|
||||||
|
|
||||||
int itemPosition = ascendNode->FindChildByItem(prevAscendNode->GetItem());
|
|
||||||
dropItemInfo.m_proposedDropIndex = itemPosition == wxNOT_FOUND ? 0 : itemPosition + 1;
|
|
||||||
dropItemInfo.m_item = ascendNode->GetItem();
|
dropItemInfo.m_item = ascendNode->GetItem();
|
||||||
|
|
||||||
// We must break the loop if the applied node is expanded (opened)
|
int itemPosition = ascendNode->FindChildByItem(prevAscendNode->GetItem());
|
||||||
// and the proposed drop position is not the last in this node
|
if ( itemPosition == wxNOT_FOUND )
|
||||||
if (ascendNode->IsOpen() && dropItemInfo.m_proposedDropIndex != static_cast<int>(ascendNode->GetChildNodes().size()))
|
itemPosition = 0;
|
||||||
|
else
|
||||||
|
itemPosition++;
|
||||||
|
|
||||||
|
dropItemInfo.m_proposedDropIndex = itemPosition;
|
||||||
|
|
||||||
|
// We must break the loop if the applied node is expanded
|
||||||
|
// (opened) and the proposed drop position is not the last
|
||||||
|
// in this node.
|
||||||
|
if ( ascendNode->IsOpen() )
|
||||||
|
{
|
||||||
|
const size_t lastPos = ascendNode->GetChildNodes().size();
|
||||||
|
if ( static_cast<size_t>(itemPosition) != lastPos )
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
int indent = GetOwner()->GetIndent()*level + expanderWidth;
|
int indent = GetOwner()->GetIndent()*level + expanderWidth;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user