MauiKit Controls
mauilist.h
32 * A helper class for easily setting up a list model to be feed into MauiModel::list, and to be used by the browsing views in Mauikit controls.
34 * @warning This method of setting up a data model is very limited by the lingo supported by the FMH::MODEL_KEY dictionary.
35 * So only consider using this class if your data model structure is based on only string text and can be represented by the FMH::MODEL_KEY dictionary entries.
38 * This inherits from the QQmlParserStatus class, so t can be aware of its creation status in the QML engine. This is useful to lazy-loading parts when needed, as when the component presenting the data model is ready and loaded.
40 * The list generated by sub-classing MauiList is meant to be used as the list for the MauiModel class, exposed to QML as the `BaseModel` type. The MauiModel supports features, such as filtering and sorting.
48 * First wee need to setup the MauiList data. In the example below the data is manually added. The data must be modeled using the FMH::MODEL_LIST, which is an array list of FMH::MODEL, which is a map of key pairs, where the key must be a FMH::MODEL_KEY enum type, and the value a string text.
77 * In this example the data is only retrieved once the QML engine has completely loaded the component using the MauiList, for this we override the `componentComplete()` virtual method, and there we inform the MauiModel with the signals that the list data is ready.
104 * data << FMH::MODEL {{FMH::MODEL_KEY::TITLE, QStringLiteral("Acanthaceae")}, {FMH::MODEL_KEY::CATEGORY, QStringLiteral("Acanthus")}};
106 * data << FMH::MODEL {{FMH::MODEL_KEY::TITLE, QStringLiteral("Agavaceae")}, {FMH::MODEL_KEY::CATEGORY, QStringLiteral("Agave")}};
108 * data << FMH::MODEL {{FMH::MODEL_KEY::TITLE, QStringLiteral("Bixaceae")}, {FMH::MODEL_KEY::CATEGORY, QStringLiteral("Annatto")}};
110 * data << FMH::MODEL {{FMH::MODEL_KEY::TITLE, QStringLiteral("Asteraceae")}, {FMH::MODEL_KEY::CATEGORY, QStringLiteral("Aster")}};
112 * data << FMH::MODEL {{FMH::MODEL_KEY::TITLE, QStringLiteral("Leguminaceae")}, {FMH::MODEL_KEY::CATEGORY, QStringLiteral("Bean")}};
137 * And finally, we can consume the data list by hooking it up to the MauiModel exposed type `BaseModel`.
177 * <a href="https://invent.kde.org/maui/mauikit/-/blob/qt6-2/examples/mauilist/">You can find a more complete example at this link.</a>
190 * @note This needs to be setup manually, as in emitting the signal when new items are appended or removed, etc.
196 * @brief Default constructor. The usage of this class is meant to be via inheritance by sub-classing it.
202 * @note The data must be modeled using the FMH::MODEL_LIST, which is an array list of FMH::MODEL elements, which is a map of key pairs, where the key must be a FMH::MODEL_KEY enum type, and the value a string text.
219 * @brief This function is called once the MauiList has been hooked to the MauiModel, using the MauiModel::list property.
226 * @brief Request to get an item in the list, the item is represented as a FMH::MODEL key pair value.
228 * @return The found item/map in the list at the index. If not item is found at the given index, then an empty map is returned.
234 * @brief Request to get an item in the list, the item is represented as a QVariantMap for easy consumption within the QML scope. This function is exposed to be invoked from QML.
236 * @return The found item/map in the list at the index. If not item is found at the given index, then an empty map is returned.
259 * @brief This signal should be emitted by the implementation before appending a new item to the list data model.
264 * @brief This signal should be emitted by the implementation before appending a multiple new items to the list data model.
270 * @brief This signal should be emitted by the implementation after one or multiple new items have finished being added into the list data model.
275 * @brief This signal should be emitted by the implementation before a new item has been inserted at a given index to the list data model.
281 * @brief This signal should be emitted by the implementation before an item has been removed at the given index position.
287 * @brief This signal should be emitted by the implementation after an item has been successfully removed from the list data model.
292 * @brief This signal should be emitted by the implementation when changes have been done in the list data model.
299 * @brief This signal should be emitted by the implementation before the list data model has been assigned or populated.
304 * @brief This signal should be emitted by the implementation after the list data model is set and done.
309 * @brief This signal should be emitted by the implementation when an item has been moved from one index position to another.
virtual void modelHooked()
This function is called once the MauiList has been hooked to the MauiModel, using the MauiModel::list...
Definition mauilist.h:221
void preItemAppendedAt(int index)
This signal should be emitted by the implementation before a new item has been inserted at a given in...
void preItemAppended()
This signal should be emitted by the implementation before appending a new item to the list data mode...
void countChanged()
This signal should be emitted by the implementation when the number of elements in the list data mode...
void updateModel(int index, QVector< int > roles)
This signal should be emitted by the implementation when changes have been done in the list data mode...
void postItemAppended()
This signal should be emitted by the implementation after one or multiple new items have finished bei...
void preItemRemoved(int index)
This signal should be emitted by the implementation before an item has been removed at the given inde...
void preItemsAppended(uint count)
This signal should be emitted by the implementation before appending a multiple new items to the list...
virtual void classBegin() override
See the Qt documentation on the QQmlParserStatus.
Definition mauilist.h:211
void itemMoved(int index, int to)
This signal should be emitted by the implementation when an item has been moved from one index positi...
virtual void componentComplete() override
See the Qt documentation on the QQmlParserStatus.
Definition mauilist.h:216
void preListChanged()
This signal should be emitted by the implementation before the list data model has been assigned or p...
void postListChanged()
This signal should be emitted by the implementation after the list data model is set and done.
virtual const FMH::MODEL_LIST & items() const =0
The modeled data represented by a FMH::MODEL_LIST.
void postItemRemoved()
This signal should be emitted by the implementation after an item has been successfully removed from ...
QHash< MODEL_KEY, QString > MODEL
The key-value pair model structure, where the values are strings.
Definition fmh.h:532
QObject(QObject *parent)
Q_INTERFACES(...)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Apr 25 2025 11:53:32 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Apr 25 2025 11:53:32 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.