diff options
Diffstat (limited to 'smtreemodel.cpp')
-rw-r--r-- | smtreemodel.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/smtreemodel.cpp b/smtreemodel.cpp index 802eebc..7df30d3 100644 --- a/smtreemodel.cpp +++ b/smtreemodel.cpp @@ -145,21 +145,23 @@ QModelIndex SmTreeModel::find(const QVariant &value, int column, const QModelInd QModelIndex SmTreeModel::findRecursive(const QVariant &value, int column, const QModelIndex &parent) const{ SmTreeItem *parentItem = 0; if(!parent.isValid()){ - //return QModelIndex(); parentItem = mRootItem; }else{ parentItem = static_cast<SmTreeItem*>(parent.internalPointer()); } + if(parentItem->data(column) == value){ + return parent; + } for(int i = 0; i < parentItem->childCount(); ++i){ SmTreeItem *child = parentItem->child(i); + if(child->data(column) == value){ + return createIndex(i, column, child); + } if(child->childCount()){ return findRecursive(value, column, createIndex(i, column, child)); } - if(child->data(column) == value){ - return createIndex(i, column, child); - } } - QModelIndex next = index(parent.row() + 1, column, parent.parent()); + QModelIndex next = index(parent.row() + 1, column, parent.parent()); if(!next.isValid()){ return QModelIndex(); } |