[Qt-interest] Qt 4.5: What is the correct way of notifying a proxy model of removed rows of its source model?
Arnold Krille
arnold at arnoldarts.de
Tue Sep 7 19:03:16 CEST 2010
Hi,
On Tuesday 07 September 2010 15:33:14 Tilmann Krüger wrote:
> one would think that QAbstractProxyModel takes care of this all by itself.
> A closer look in the source code reveals that this is not the case.
>
> My guess is to implement slots for the rowsAboutToBeRemoved() and
> rowsRemoved() signals of the source model, which call beginRemoveRows() and
> endRemoveRows() with the correct rows for the proxy.
>
> This, however, raises the question of how one is supposed to get the
> corresponding set of row numbers of the proxy model, which - to make
> things even more complicated - is not necessarily contiguous as the region
> in the source model.
When you get the "rowsAboutToBeRemoved"-signal, the rows are still there. So
your proxy-model can still sync its mapping to the source's indizes. If the
rows to be removed affect the rows the proxy-model exports (doesn't necessarily
have to be that way), it has to call beginRemoveRows itself with its own
indizes that will be affected. Then you should call endRemoveRows in your proxy
so the connected proxies/views don't use the old indizes anymore. Then you
return and wait for the source-models rowsRemoved()-signal. Or you ignore that
as your proxy doesn't "know" about that rows anymore anyway...
Maybe that helps,
Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100907/0f088cdc/attachment.bin
More information about the Qt-interest-old
mailing list