summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2009-05-27 23:04:41 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2009-05-27 23:04:41 +0200
commitfcfdccc03b6dd26a82e87a6b6a0ca48d67f78cf6 (patch)
tree2cdd417bc0be39b12674f33052462d19d9e38ef9 /src/gui/itemviews
parent7b1f8c542bc9f41408f0a54b853d75d0c09a2775 (diff)
parentd0bc0a26f8ac4c2f02819c262b8aa7c3dd1cad3b (diff)
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts: tests/auto/qtreeview/tst_qtreeview.cpp
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r--src/gui/itemviews/qheaderview.cpp4
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.cpp3
-rw-r--r--src/gui/itemviews/qtreeview.cpp8
3 files changed, 10 insertions, 5 deletions
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index 6238df54b2..ad93922458 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1267,8 +1267,10 @@ void QHeaderView::setSortIndicator(int logicalIndex, Qt::SortOrder order)
d->sortIndicatorSection = logicalIndex;
d->sortIndicatorOrder = order;
- if (logicalIndex >= d->sectionCount)
+ if (logicalIndex >= d->sectionCount) {
+ emit sortIndicatorChanged(logicalIndex, order);
return; // nothing to do
+ }
if (old != logicalIndex
&& ((logicalIndex >= 0 && resizeMode(logicalIndex) == ResizeToContents)
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp
index 56925b8ffa..96eb6f02e7 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.cpp
+++ b/src/gui/itemviews/qsortfilterproxymodel.cpp
@@ -1539,7 +1539,8 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
d->clear_mapping();
reset();
- d->update_source_sort_column();
+ if (d->update_source_sort_column() && d->dynamic_sortfilter)
+ d->sort();
}
/*!
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index d742698e36..c3fca8e061 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());
}
/*!
@@ -844,17 +844,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