For interacting with lists in Qt applications, you usually want to use Qt's ListView classes, which are based on the Model-View-Controller pattern. QtIvi offers support classes, making it easy to provide your own models.
When designing features like a contacts list of a connected mobile phone, you may want to use QtIvi's frontend/backend separation by deriving from QIviAbstractFeature and at the same time make it possible to use this feature with a QAbstractItemView derived class to show your contacts in a list form.
The QIviSearchAndBrowseModel is not directly a base class, but intended to be used as-is. As the name suggests, it provides a model, that supports searching the model content as well as browsing through a set of model data. Let's go through all its features in more detail:
As we don't have control over the interfaces of the data providers, the QIviSearchAndBrowseModel supports two distinct fetch modes:
- If the number of items in the model is not known from the beginning, the FetchMore mode should be used. This mode will fetch a number of items from the backend once they are needed and the backend tells the frontend whether there is more data to be fetched.
- The second fetch mode - DataChanged - will fill the complete model with empty data and use the QAbstractItemModel::dataChanged() signal to tell the View about the actual content. For this mode to work correctly, the number of items in the list needs to be known from the beginning.
See the QIviSearchAndBrowseModel documentation for a more detailed description of the fetch modes and their (dis)advantages.
Modifying the Content
QIviSearchAndBrowseModel provides some generic methods for modifying the content of the model:
Filtering and Sorting (Search)
For filtering and sorting, QIviSearchAndBrowseModel uses the Qt IVI Query Language. This makes the system very flexible and powerful at the same time. See the next page for more information about the query language.
Although the Qt IVI Query Language supports very complex queries, enabling you to filter list content, it might still not be suitable for all use-cases. With the query language, the frontend developer defines which data is needed next. This is sometimes not possible, as the backend already defines a specific browsing order. A DLNA backend for example already specifies that first an artist needs to be selected and only then a list of all albums of that artist is presented.
For this scenario, the QIviSearchAndBrowseModel provides some methods to navigate through the models using the following methods:
You might not need all of the above features at the same time or your backend doesn't even support them. In this case, there is a capability system within the QIviSearchAndBrowseModel. The backend reports which capabilities it can support. Based on that information, only the supported functionalities are enabled in the frontend API.
© 2018 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.