[vlc-devel] [PATCH 03/13] qt: medialib: do not count on item()

Romain Vimont rom1v at videolabs.io
Mon Nov 23 18:24:28 CET 2020


On Mon, Nov 23, 2020 at 05:52:05PM +0100, Steve Lhomme wrote:
> It would be simpler to use rowCount() instead of the m_total_count value.
> This way you don't require to call rowCount() before.

rowCount() is the function called by Qml when it wants to know the size
of the list: https://doc.qt.io/qt-5/qabstractitemmodel.html#rowCount

It feels odd to call "rowCount(const QModelIndex &)" from there (but it
would probably work).

This patch is based on the assumption that Qml will never request an
item before the rowCount(), to simplify the implementation/refactor.

In the end (at the end of this patchset), it does not matter (both
methods call validateCache()).

Regards


More information about the vlc-devel mailing list