Details
-
Suggestion
-
Resolution: Out of scope
-
P4: Low
-
5.0.0
-
None
-
Any
Description
====
Feature request: let QSortFilterProxyModel emit a new signal 'proxyRowsInserted', immediately before it does 'emit rowsInserted'.
(and similar for the other QAbstractItemModel signals: 'proxyDataChanged' etc.)
====
Rationale:
I recently did some work in Amarok, which contains a subclass that inherits from QSortFilterProxyModel.
This subclass tries to maintain some internal state for each row in the proxy model, and offers some per-row info functions to "upstream" callers.
The subclass does this by connecting to its own 'rowsInserted' signal (which is emitted by the QSortFilterProxyModel parent class). Some signals handlers "upstream" also connect to that same 'rowsInserted' signal.
The existing code happens to work, but that's mostly by luck. The following scenario is possible:
- QSortFilterProxyModel emits rowsInserted( newRow )
- Upstream signal handler is called first
- Upstream handler does 'proxy->getFoo newRow )'
- proxy->getFoo() returns bad info, based on its stale internal state
- QSFPM_Subclass signal handler is called second
- We bring our internal state in sync, but it's already too late!
With the proposed new feature, it would work robustly as follows:
- QSortFilterProxyModel emits proxyRowsInserted( newRow )
- QSFPM_Subclass signal handler is called
- We bring our internal state in sync
- QSortFilterProxyModel emits rowsInserted( newRow )
- Upstream signal handler is called
- Upstream handler does proxy->getFoo( newRow )
- getFoo() returns correct info
====
I'm willing to prepare a patch if desired.