From 887c2cd696c54af0cd6fdd54950d006626afeacc Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 30 Sep 2012 04:34:22 +0200 Subject: Foremost a fix for SmTreeModel Not working again, but I eventually have to commit the changes. Fixes to SmTreeModel: * Fix SmTreeModel::index(). The previous comment was quite valid. I'm surprised that it worked at all. I have no clue why to return an invalid QModelIndex if the column isn't 0. Now an index with any valid column number can be created. * Fix SmTreeModel::parent(). Again, why shouldn't we create a parent index with a column other than 0? No idea... * Fix SmTreeModel::headerData(). Add some sanity checks. * Fix SmTreeModel::findRecursive(). Well, what is there to say. It never worked for models with a depth > 1, but obviously it didn't really matter until now. To make it work I had to change SmTreeItem as well. SmTreeItem::next() returns the next valid parent/sibling, or 0 if there isn't one. There may be some fallout from these changes, but they're yet to be seen. Changes to PictureView: * fix selecting an item according to the new datasbase layout * same goes for editing items. If an update actually works has to be checked. Overall, it's an intermediate commit that should have been a sane series of commits. Can't be changed now... --- smtreemodel.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'smtreemodel.h') diff --git a/smtreemodel.h b/smtreemodel.h index 515f7b3..7037e4c 100644 --- a/smtreemodel.h +++ b/smtreemodel.h @@ -37,11 +37,12 @@ class SmTreeModel : public QAbstractItemModel { virtual QVariant data(const QModelIndex &index, int role) const; virtual bool setData(const QModelIndex &index, const QVariant &value, int role); virtual QModelIndex find(const QVariant &value, int column = 0, const QModelIndex &parent = QModelIndex()) const; - virtual QModelIndex findRecursive(const QVariant &value, int column = 0, const QModelIndex &parent = QModelIndex()) const; + virtual QModelIndex findRecursive(const QVariant &value, int column, const QModelIndex &start) const; // root + parent item bool setRoot(SmTreeItem *rootItem); SmTreeItem *root() const { return mRootItem; } + QModelIndex rootIndex() const; SmTreeItem *parentItem(const QModelIndex &child) const; void reparent(const QModelIndex &idx, const QModelIndex &newParent, bool sorted = false); -- cgit v1.2.3-70-g09d2