From 6b8c2cf35525c62b1e7a0279a7ebaa175848d268 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 17 Mar 2012 11:48:24 +0100 Subject: 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. --- smtreemodel.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'smtreemodel.cpp') 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(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(); } -- cgit v1.2.3-70-g09d2