summaryrefslogtreecommitdiffstats
path: root/src/concurrent/doc/snippets/snippets.pro
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2025-02-05 19:59:02 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2025-03-21 22:31:50 +0100
commitf5115a913738aef2ee37b880c2e7275f1045b8ae (patch)
treefd29b4d61e141f7ccb004d781c55ec8ca66e367d /src/concurrent/doc/snippets/snippets.pro
parent17a9343ace849fcc6c3514b0b744bc0827472455 (diff)
Long live QGenericItemModel for lists and tables
QGenericItemModel provides a QAbstractItemModel implementation that can make any C++ range with a cbegin/cend iterator pair available to Qt's model/view framework. To avoid subclassing a polymorphic type with a template, resulting in weak vtables, the calls are dispatched through a set of static helpers similar to existing pattern in e.g. QObject or QRunnable. The public QGenericItemModel class is then a subclass of QAbstractItemModel, where only the constructor is a template that instantiates the specialization of QGenericItemModelImpl. The virtual function overrides dispatch the call through the static helper to the template class operating on the range. The core of the implementation is the template class QGenericItemModelImpl, that implements the QAbstractItemModel functionality on top of iterator APIs. Implementations that are specific to the structure of the model, i.e. whether it is a flat table or list model, or (in a later commit) a tree, are in a base class of QGenericItemModelImpl, QGenericItemModelStructureImpl. It uses CRTP with decltype(auto) where we would otherwise have a return type that is dependent on the (not yet fully specialized) implementation type. The data for the model can be provided by copy, rvalue reference, or pointer. If provided by pointer, the model will modify the original data. Functionality that requires that the model itself, or the data in the model, can be modified is compiled out if the model or data is const. The initial implementation supports lists and tables, where tables can be nested containers (like `std::vector<std::vector<item_type>>`), or as structs that implement the C++ tuple protocol. Include test framework and documentation, as well as a snippet-project that tests the code snippets. [ChangeLog][QtCore] Added QGenericItemModel, a QAbstractItemModel implementation that make any C++ range with a cbegin/cend iterator pair available to Qt's model/view framework. Change-Id: I8ff2b95cde2566f422f3aee7912660a8cb217397 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
Diffstat (limited to 'src/concurrent/doc/snippets/snippets.pro')
0 files changed, 0 insertions, 0 deletions