|
|
|
|
@ -175,53 +175,3 @@ ProgressTreeModel::setupModelData()
|
|
|
|
|
m_rootItem->appendChild( new ViewStepItem( step, m_rootItem ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QModelIndex
|
|
|
|
|
ProgressTreeModel::indexFromItem( ProgressTreeItem* item )
|
|
|
|
|
{
|
|
|
|
|
if ( !item || !item->parent() )
|
|
|
|
|
{
|
|
|
|
|
return QModelIndex();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reconstructs a QModelIndex from a ProgressTreeItem that is somewhere in the tree.
|
|
|
|
|
// Traverses the item to the root node, then rebuilds the qmodelindices from there
|
|
|
|
|
// back down; each int is the row of that item in the parent.
|
|
|
|
|
/**
|
|
|
|
|
* In this diagram, if the item is G, childIndexList will contain [0, 2, 0]
|
|
|
|
|
*
|
|
|
|
|
* A
|
|
|
|
|
* D
|
|
|
|
|
* E
|
|
|
|
|
* F
|
|
|
|
|
* G
|
|
|
|
|
* H
|
|
|
|
|
* B
|
|
|
|
|
* C
|
|
|
|
|
*
|
|
|
|
|
**/
|
|
|
|
|
QList< int > childIndexList;
|
|
|
|
|
ProgressTreeItem* curItem = item;
|
|
|
|
|
while ( curItem != m_rootItem )
|
|
|
|
|
{
|
|
|
|
|
int row = curItem->row(); //relative to its parent
|
|
|
|
|
if ( row < 0 ) // something went wrong, bail
|
|
|
|
|
{
|
|
|
|
|
return QModelIndex();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
childIndexList << row;
|
|
|
|
|
|
|
|
|
|
curItem = curItem->parent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Now we rebuild the QModelIndex we need
|
|
|
|
|
QModelIndex idx;
|
|
|
|
|
for ( int i = childIndexList.size() - 1; i >= 0; i-- )
|
|
|
|
|
{
|
|
|
|
|
idx = index( childIndexList[ i ], 0, idx );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return idx;
|
|
|
|
|
}
|
|
|
|
|
|