Change the default value of QSortFilterProxyModel::dynamicSortFilter
authorStephen Kelly <stephen.kelly@kdab.com>
Tue, 20 Dec 2011 11:56:01 +0000 (12:56 +0100)
committerQt by Nokia <qt-info@nokia.com>
Mon, 2 Jan 2012 15:43:02 +0000 (16:43 +0100)
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>
dist/changes-5.0.0
examples/itemviews/addressbook/addresswidget.cpp
examples/itemviews/basicsortfiltermodel/window.cpp
examples/itemviews/customsortfiltermodel/window.cpp
src/corelib/itemmodels/qsortfilterproxymodel.cpp
tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
tests/auto/corelib/kernel/qitemmodel/modelstotest.cpp

index 7f253a6..b16eb66 100644 (file)
@@ -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
index d9d3f46..82ae508 100644 (file)
@@ -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);
index 08bdc04..02d9666 100644 (file)
@@ -45,7 +45,6 @@
 Window::Window()
 {
     proxyModel = new QSortFilterProxyModel;
-    proxyModel->setDynamicSortFilter(true);
 
     sourceView = new QTreeView;
     sourceView->setRootIsDecorated(false);
index 95b5f58..7b08491 100644 (file)
@@ -47,7 +47,6 @@
 Window::Window()
 {
     proxyModel = new MySortFilterProxyModel(this);
-    proxyModel->setDynamicSortFilter(true);
     //! [0]
 
     //! [1]
index 4a9c100..085ade1 100644 (file)
@@ -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
 {
index 7b591be..67b55a9 100644 (file)
@@ -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) {
index 496789d..67d5024 100644 (file)
@@ -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;
     }