diff options
author | Arno <am@disconnect.de> | 2012-03-17 11:48:24 +0100 |
---|---|---|
committer | Arno <am@disconnect.de> | 2012-03-17 11:48:24 +0100 |
commit | 6b8c2cf35525c62b1e7a0279a7ebaa175848d268 (patch) | |
tree | 762291d670475cf7dcd95d8a2f2fc67ac63ea73b /smtreemodel.cpp | |
parent | 77645a5dcfcb968cf5a3e4d43b4e93c12710f79e (diff) | |
download | SheMov-6b8c2cf35525c62b1e7a0279a7ebaa175848d268.tar.gz SheMov-6b8c2cf35525c62b1e7a0279a7ebaa175848d268.tar.bz2 SheMov-6b8c2cf35525c62b1e7a0279a7ebaa175848d268.zip |
Make nodes with children selectable in picture widget
This was a tough one. Lost in recursion. When selecting nodes with
children in the picture widget, all files having this node as mapping
parent are shown.
Had to make some changes to SmTreeModel::findRecursive for this. I hope
I didn't break anything. If I did, I'll fix it :)
Also disposed of some comments and unused member variables.
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(); } |