qt5base-lts/tests/auto/corelib/itemmodels
Olivier Goffart 49c8923282 QSortFilterProxyModel: Don't forward the hint from source's layoutChanged signal
We can't forward a VerticalSortHint or HorizontalSortHint hint, because we might
be filtering extra items.

The documentation of QAbstractItemModel::LayoutChangeHint states:

    Note that VerticalSortHint and HorizontalSortHint carry the meaning that
    items are being moved within the same parent, not moved to a different
    parent in the model, and not filtered out or in.

And some of the views rely on this assumption (QQmlDelegateModel for example)

What happens in the test is the following:
- 'model' emit the dataChanged signal when its data is changed.
- 'proxi1' QSortFilterProxyModelPrivate::_q_sourceDataChanged does not forward
  the dataChanged signal imediatly, it will instead first re-sort the model and
  call layoutAboutToBeChanged / layouChanged with the VerticalSortHint
- 'proxy2' would forward the layoutAboutToBeChanged with the hint, but in
  QSortFilterProxyModelPrivate::_q_sourceLayoutChanged, it will redo the mapping
  which will cause the changed data to be filtered.
So proxy2 can't forward the VerticalSortHint as it removed rows in the process.

Change-Id: I20b6983e9d18bf7509fe6144c74f37d24e4a18c2
Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2016-08-01 14:08:15 +00:00
..
qabstractitemmodel Tests: Replace Q[TRY]_VERIFY(v == true|false) by QVERIFY(v)|QVERIFY(!v). 2015-07-27 12:09:19 +00:00
qabstractproxymodel Update copyright headers 2015-02-11 06:49:51 +00:00
qidentityproxymodel Update copyright headers 2015-02-11 06:49:51 +00:00
qitemmodel tst_QItemModel: Use a QTemporaryDir for test data of QDirModel. 2015-11-27 22:50:26 +00:00
qitemselectionmodel Clean unused parameter warning from QItemSelectionModel test 2015-09-30 06:36:21 +00:00
qsortfilterproxymodel QSortFilterProxyModel: Don't forward the hint from source's layoutChanged signal 2016-08-01 14:08:15 +00:00
qstringlistmodel Update copyright headers 2015-02-11 06:49:51 +00:00
itemmodels.pro exclude gui-needing tests from -no-gui build 2013-10-18 20:05:27 +02:00