diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-05-25 16:32:46 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-05-26 08:37:07 (GMT) |
commit | 2a390bb481a2433a239a9198e463c9337a26db59 (patch) | |
tree | 8c8661482ab497a97fb557fad63fc748c10d4d5d /src/gui/itemviews/qtreeview.cpp | |
parent | 5839b16a73c36ff7636c13f841d26e6a5e0c5435 (diff) | |
download | Qt-2a390bb481a2433a239a9198e463c9337a26db59.zip Qt-2a390bb481a2433a239a9198e463c9337a26db59.tar.gz Qt-2a390bb481a2433a239a9198e463c9337a26db59.tar.bz2 |
Fixed: QSortFilterProxyModel setDynamicSortFilter doesn't works when setting the model initially
This was caused by two different bug:
- In the QSortFilterProxyModel, we need to re-sort when setting the
source model change the sorting column (happen when setting a model
initially)
- In the treeview, we need to activate the sorting even if there is no
column yet (because the initial model is empty
Task-number: 254234
Reviewed-by: Thierry
BT:
Diffstat (limited to 'src/gui/itemviews/qtreeview.cpp')
-rw-r--r-- | src/gui/itemviews/qtreeview.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 62c1277..1070648 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -246,7 +246,7 @@ void QTreeView::setModel(QAbstractItemModel *model) connect(d->model, SIGNAL(modelAboutToBeReset()), SLOT(_q_modelAboutToBeReset())); if (d->sortingEnabled) - sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); + d->_q_sortIndicatorChanged(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); } /*! @@ -846,17 +846,19 @@ void QTreeView::setExpanded(const QModelIndex &index, bool expanded) void QTreeView::setSortingEnabled(bool enable) { Q_D(QTreeView); - d->sortingEnabled = enable; header()->setSortIndicatorShown(enable); header()->setClickable(enable); if (enable) { + //sortByColumn has to be called before we connect or set the sortingEnabled flag + // because otherwise it will not call sort on the model. + sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(_q_sortIndicatorChanged(int, Qt::SortOrder))); - sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); } else { disconnect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(_q_sortIndicatorChanged(int, Qt::SortOrder))); } + d->sortingEnabled = enable; } bool QTreeView::isSortingEnabled() const |