diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2011-12-20 12:56:01 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-02 16:43:02 +0100 |
commit | f29e55448b8e0c0a156e3af960589c6733cc4d7d (patch) | |
tree | 68ace1683067cea9895fa8171cd8c56ef77e47fb | |
parent | a23a5487eb60c0f8b3c99d32a5e8e3cf636e4911 (diff) |
Change the default value of QSortFilterProxyModel::dynamicSortFilter
The value is changed to true. It is a common bug that developers expect
this proxy model to reflect the source model when the source changes.
That requires setDynamicSortFilter(true), so we change the default to
optimize for the common case.
Change-Id: I9bf7efdbda10309fa77aed9391c33054aaae4a29
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
7 files changed, 9 insertions, 9 deletions
diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index 7f253a6036..b16eb666ae 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -167,6 +167,9 @@ QtCore should now also connect to (and disconnect from) the rowsAboutToBeMoved and rowsMoved signals. +* The default value of the property QSortFilterProxyModel::dynamicSortFilter was + changed from false to true. + QtGui ----- * Accessibility has been refactored. The hierachy of accessible objects is implemented via diff --git a/examples/itemviews/addressbook/addresswidget.cpp b/examples/itemviews/addressbook/addresswidget.cpp index d9d3f46fed..82ae5083f3 100644 --- a/examples/itemviews/addressbook/addresswidget.cpp +++ b/examples/itemviews/addressbook/addresswidget.cpp @@ -167,8 +167,7 @@ void AddressWidget::setupTabs() proxyModel = new QSortFilterProxyModel(this); proxyModel->setSourceModel(table); - proxyModel->setDynamicSortFilter(true); - + QTableView *tableView = new QTableView; tableView->setModel(proxyModel); tableView->setSortingEnabled(true); diff --git a/examples/itemviews/basicsortfiltermodel/window.cpp b/examples/itemviews/basicsortfiltermodel/window.cpp index 08bdc04009..02d96667cd 100644 --- a/examples/itemviews/basicsortfiltermodel/window.cpp +++ b/examples/itemviews/basicsortfiltermodel/window.cpp @@ -45,7 +45,6 @@ Window::Window() { proxyModel = new QSortFilterProxyModel; - proxyModel->setDynamicSortFilter(true); sourceView = new QTreeView; sourceView->setRootIsDecorated(false); diff --git a/examples/itemviews/customsortfiltermodel/window.cpp b/examples/itemviews/customsortfiltermodel/window.cpp index 95b5f581d7..7b08491232 100644 --- a/examples/itemviews/customsortfiltermodel/window.cpp +++ b/examples/itemviews/customsortfiltermodel/window.cpp @@ -47,7 +47,6 @@ Window::Window() { proxyModel = new MySortFilterProxyModel(this); - proxyModel->setDynamicSortFilter(true); //! [0] //! [1] diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 4a9c100613..085ade1680 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -1528,7 +1528,7 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved( or vice versa, use mapToSource(), mapFromSource(), mapSelectionToSource(), and mapSelectionFromSource(). - \note By default, the model does not dynamically re-sort and re-filter data + \note By default, the model dynamically re-sorts and re-filters data whenever the original model changes. This behavior can be changed by setting the \l{QSortFilterProxyModel::dynamicSortFilter}{dynamicSortFilter} property. @@ -1657,7 +1657,7 @@ QSortFilterProxyModel::QSortFilterProxyModel(QObject *parent) d->sort_localeaware = false; d->filter_column = 0; d->filter_role = Qt::DisplayRole; - d->dynamic_sortfilter = false; + d->dynamic_sortfilter = true; connect(this, SIGNAL(modelReset()), this, SLOT(_q_clearMapping())); } @@ -2402,7 +2402,7 @@ void QSortFilterProxyModel::setFilterFixedString(const QString &pattern) call \l{QSortFilterProxyModel::}{sort()} after adding items to the QComboBox. - The default value is false. + The default value is true. */ bool QSortFilterProxyModel::dynamicSortFilter() const { diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 7b591be8cc..67b55a92e7 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -2518,6 +2518,7 @@ void tst_QSortFilterProxyModel::dynamicSorting() const QStringList initial = QString("bateau avion dragon hirondelle flamme camion elephant").split(" "); model1.setStringList(initial); QSortFilterProxyModel proxy1; + proxy1.setDynamicSortFilter(false); proxy1.sort(0); proxy1.setSourceModel(&model1); @@ -2563,7 +2564,6 @@ void tst_QSortFilterProxyModel::dynamicSorting() //set up the sorting before seting the model up QSortFilterProxyModel proxy2; - proxy2.setDynamicSortFilter(true); proxy2.sort(0); proxy2.setSourceModel(&model2); for (int row = 0; row < proxy2.rowCount(QModelIndex()); ++row) { diff --git a/tests/auto/corelib/kernel/qitemmodel/modelstotest.cpp b/tests/auto/corelib/kernel/qitemmodel/modelstotest.cpp index 496789d408..67d5024944 100644 --- a/tests/auto/corelib/kernel/qitemmodel/modelstotest.cpp +++ b/tests/auto/corelib/kernel/qitemmodel/modelstotest.cpp @@ -163,7 +163,7 @@ QAbstractItemModel *ModelsToTest::createModel(const QString &modelType) QStandardItemModel *standardItemModel = new QStandardItemModel; model->setSourceModel(standardItemModel); populateTestArea(model); - model->setFilterRegExp(QRegExp("(^$|0.*)")); + model->setFilterRegExp(QRegExp("(^$|I.*)")); return model; } |