qtbase/examples/widgets
Volker Hilsheimer 00ce45efe1 QSortFilterProxyModel: add a protected beginFilterChange
If the filter gets changed and invalidated while there is no mapping
(perhaps because the model had been invalidated first), then we fail
to notice the change and don't emit rowsInserted/Removed. And as the
new filter is already in place by the time invalidateFilter gets
called, we cannot know what the size of the model was before the
change.

The only way to fix that is to introduce a beginFilterChange protected
function that makes sure that we have a mapping from the source model
with the old filter. That is a no-op if a mapping is already in place,
costing only the lookup in a hash table.

By calling this function, custom models with their own filtering logic
can make sure that their model emits the changed-signals as expected.

Add test coverage and documentation and fix the relevant examples
snippet to use that new protected function as recommended, and to
invalidate only the rows filter.

[ChangeLog][Core][QSortFilterProxyModel] Added a new protected
function beginFilterChange() that subclasses overriding
filterAcceptsRow or filterAcceptsColumn should call before the filter
parameter is changed. This makes sure that the signals informing
about rows or columns changing get correctly emitted.

Fixes: QTBUG-115717
Change-Id: Ib73a7119ac9dd9c4bcf220f1274d6b4ed093e7ff
Reviewed-by: David Faure <david.faure@kdab.com>
2024-08-28 02:28:24 +02:00
..
animation Add copyright and licensing to build system files missing it 2024-05-21 17:23:21 +02:00
desktop systray example: if there is no system tray, allow waiting for one 2024-06-05 01:40:10 +00:00
dialogs CMake: Add deployment API to our examples 2024-03-22 20:23:52 +01:00
doc Replace 'Qt Designer' and 'Qt Widgets Designer' in code 2024-05-16 13:04:41 +01:00
draganddrop CMake: Add deployment API to our examples 2024-03-22 20:23:52 +01:00
gallery Widget gallery example: set color scheme before constructing UI 2024-06-11 20:28:07 +02:00
gestures CMake: Add deployment API to our examples 2024-03-22 20:23:52 +01:00
graphicsview CMake: Add deployment API to our examples 2024-03-22 20:23:52 +01:00
itemviews QSortFilterProxyModel: add a protected beginFilterChange 2024-08-28 02:28:24 +02:00
layouts CMake: Add deployment API to our examples 2024-03-22 20:23:52 +01:00
mainwindows CMake: Add deployment API to our examples 2024-03-22 20:23:52 +01:00
painting CMake: Add deployment API to our examples 2024-03-22 20:23:52 +01:00
qnx/foreignwindows Doc: Fix license of foreignwindows example 2023-06-30 18:46:54 +02:00
rhi CMake: Add deployment API to our examples 2024-03-22 20:23:52 +01:00
richtext CMake: Add deployment API to our examples 2024-03-22 20:23:52 +01:00
tools CMake: Add deployment API to our examples 2024-03-22 20:23:52 +01:00
touch CMake: Add deployment API to our examples 2024-03-22 20:23:52 +01:00
tutorials Doc: Update \externalpage entries for Qt Creator documentation 2024-08-02 14:18:19 +02:00
widgets Add copyright and licensing to build system files missing it 2024-05-21 17:23:21 +02:00
CMakeLists.txt Correct license for examples files 2024-03-07 11:06:43 +01:00
widgets.pro Add QRhiWidget 2023-08-14 17:05:36 +02:00