forked from qt-creator/qt-creator
TreeModel: Introduce a TreeItem::indexInParent() convenience function
To shorten user code and hide the ugly const_cast. Change-Id: I798bd105932004ea17cb95b243fc38ccfcda0a2c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -766,6 +766,11 @@ int TreeItem::level() const
|
||||
return l;
|
||||
}
|
||||
|
||||
int TreeItem::indexInParent() const
|
||||
{
|
||||
return m_parent ? m_parent->m_children.indexOf(const_cast<TreeItem *>(this)) : -1;
|
||||
}
|
||||
|
||||
QModelIndex TreeItem::index() const
|
||||
{
|
||||
QTC_ASSERT(m_model, return QModelIndex());
|
||||
|
||||
Reference in New Issue
Block a user