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>bb10
parent
a23a5487eb
commit
f29e55448b
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@
|
|||
Window::Window()
|
||||
{
|
||||
proxyModel = new QSortFilterProxyModel;
|
||||
proxyModel->setDynamicSortFilter(true);
|
||||
|
||||
sourceView = new QTreeView;
|
||||
sourceView->setRootIsDecorated(false);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@
|
|||
Window::Window()
|
||||
{
|
||||
proxyModel = new MySortFilterProxyModel(this);
|
||||
proxyModel->setDynamicSortFilter(true);
|
||||
//! [0]
|
||||
|
||||
//! [1]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue