diff options
author | Arno <am@disconnect.de> | 2012-09-30 04:34:22 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2012-09-30 04:34:22 +0200 |
commit | 887c2cd696c54af0cd6fdd54950d006626afeacc (patch) | |
tree | 2ad296208a7d8e44ac249612dfcd09919e7ba07d /seriestreewidget.cpp | |
parent | 5addc8a8ec89c1e354949bcf5c3152fea4fe44b9 (diff) | |
download | SheMov-887c2cd696c54af0cd6fdd54950d006626afeacc.tar.gz SheMov-887c2cd696c54af0cd6fdd54950d006626afeacc.tar.bz2 SheMov-887c2cd696c54af0cd6fdd54950d006626afeacc.zip |
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...
Diffstat (limited to 'seriestreewidget.cpp')
-rw-r--r-- | seriestreewidget.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/seriestreewidget.cpp b/seriestreewidget.cpp index 1f96a11..2a487fb 100644 --- a/seriestreewidget.cpp +++ b/seriestreewidget.cpp @@ -68,12 +68,12 @@ SeriesTreeWidget::SeriesTreeWidget(QWidget *parent) : QWidget(parent){ mView = new SeriesTreeView; mProxy = new SeriesTreeSortModel(this); mModel = static_cast<SeriesTreeModel*>(SmGlobals::instance()->model("SeriesModel")); - mProxy->setSourceModel(mModel); - mView->setModel(mProxy); - mView->setSortingEnabled(true); - for(int i = 1; i < SeriesTreeModel::NumFields; ++i){ + mProxy->setSourceModel(mModel); + mView->setModel(mProxy); + mView->setSortingEnabled(true); + for(int i = 1; i < SeriesTreeModel::NumFields; ++i){ mView->setColumnHidden(i, true); - } + } mView->resizeColumnToContents(0); mView->setSelectionMode(QAbstractItemView::ExtendedSelection); mView->setEditTriggers(QAbstractItemView::NoEditTriggers); @@ -495,9 +495,14 @@ bool SeriesTreeSortModel::lessThan(const QModelIndex &left, const QModelIndex &r } bool SeriesTreeSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { - SeriesTreeModel *seriesModel = static_cast<SeriesTreeModel*>(sourceModel()); + SeriesTreeModel *seriesModel = static_cast<SeriesTreeModel*>(sourceModel()); int rowFilter = seriesModel->rowFilter(); - QModelIndex curIdx = sourceModel()->index(source_row, 0, source_parent); + /*QModelIndex parent = source_parent; + if(!parent.isValid()){ + parent = seriesModel->rootIndex(); + }*/ + QModelIndex curIdx = sourceModel()->index(source_row, 0, source_parent); + //QModelIndex curIdx = source_parent; QString name = curIdx.data(SeriesTreeModel::NameRole).toString(); QRegExp filterRe = filterRegExp(); if(rowFilter == SeriesTreeModel::All){ |