QIviSearchAndBrowseModelInterface Class

The QIviSearchAndBrowseModelInterface defines the interface for backends to the QIviSearchAndBrowseModel feature class. More...

Header: #include <QIviSearchAndBrowseModelInterface>
qmake: QT += ivicore
Inherits: QIviFeatureInterface

Public Functions

QIviSearchAndBrowseModelInterface(QObject *parent = nullptr)
~QIviSearchAndBrowseModelInterface()
virtual QSet<QString> availableContentTypes() const
virtual bool canGoBack(const QUuid &identifier, const QString &type) = 0
virtual bool canGoForward(const QUuid &identifier, const QString &type, const QString &itemId) = 0
virtual void fetchData(const QUuid &identifier, const QString &type, QIviAbstractQueryTerm *term, const QList<QIviOrderTerm> &orderTerms, int start, int count) = 0
virtual QString goBack(const QUuid &identifier, const QString &type) = 0
virtual QString goForward(const QUuid &identifier, const QString &type, const QString &itemId) = 0
virtual int indexOf(const QUuid &identifier, const QString &type, const QIviSearchAndBrowseModelItem *item) = 0
virtual void insert(const QUuid &identifier, const QString &type, int index, const QIviSearchAndBrowseModelItem *item) = 0
virtual void move(const QUuid &identifier, const QString &type, int currentIndex, int newIndex) = 0
virtual void remove(const QUuid &identifier, const QString &type, int index) = 0
virtual QSet<QString> supportedIdentifiers(const QString &contentType) const

Signals

void countChanged(const QUuid &identifier, int newLength)
void dataChanged(const QUuid &identifier, const QList<QVariant> &data, int start, int count)
void dataFetched(const QUuid &identifier, const QList<QVariant> &data, int start, bool moreAvailable)
void indexOfCallResult(const QUuid &identifier, int callID, int index)
void supportedCapabilitiesChanged(const QUuid &identifier, QIviSearchAndBrowseModel::Capabilities capabilities)

Protected Functions

void registerContentType(const QString &contentType)
  • 9 protected functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QIviSearchAndBrowseModelInterface defines the interface for backends to the QIviSearchAndBrowseModel feature class.

The QIviSearchAndBrowseModelInterface is the interface used by QIviSearchAndBrowseModel

The interface is discovered by a QIviSearchAndBrowseModel object, which connects to it and sets it up.

Every QIviSearchAndBrowseModel generates its own QUuid which is passed to the backend interface and can be used to identify a model instance.

//TODO explain how the interface works on a example <example of a fully featured backend>

See also QIviSearchAndBrowseModel.

Member Function Documentation

QIviSearchAndBrowseModelInterface::QIviSearchAndBrowseModelInterface(QObject *parent = nullptr)

Constructs a backend interface.

The parent is sent to the QObject constructor.

QIviSearchAndBrowseModelInterface::~QIviSearchAndBrowseModelInterface()

Destroys the instance of QIviSearchAndBrowseModelInterface.

[virtual] QSet<QString> QIviSearchAndBrowseModelInterface::availableContentTypes() const

Returns all the available content types for this backend instance.

It's recommended to use the registerContentType() function instead, which takes care of this function for you.

[pure virtual] bool QIviSearchAndBrowseModelInterface::canGoBack(const QUuid &identifier, const QString &type)

Returns true when the QIviSearchAndBrowseModel instance identified by identifier can go back and return to the previously shown data set. The type parameter holds the currently displayed content type.

See Browsing for more information on how this is used.

See also goBack().

[pure virtual] bool QIviSearchAndBrowseModelInterface::canGoForward(const QUuid &identifier, const QString &type, const QString &itemId)

Returns true when the QIviSearchAndBrowseModel instance identified by identifier and the current content type type has an item identified by itemId and this item can be used to show a new set of data.

See Browsing for more information on how this is used.

See also goForward.

[signal] void QIviSearchAndBrowseModelInterface::countChanged(const QUuid &identifier, int newLength)

This signal is emitted when the current number of items in the QIviSearchAndBrowseModel instance identified by identifier changed. The new number of items is returned as newLength.

This signal is expected to be emitted after the model instance has requested new data for the first time by calling fetchData() and should be emitted before the data is returned by emitting the dataFetched() signal

See also fetchData() and dataFetched().

[signal] void QIviSearchAndBrowseModelInterface::dataChanged(const QUuid &identifier, const QList<QVariant> &data, int start, int count)

This signal is emitted whenever the data in the QIviSearchAndBrowseModel instance identified by identifier changed and the model needs to be updated. The new data is passed as data. The arguments start and count can be used to define the set of items which should be replaced with the new data.

For inserting a new item, the item is passed in data and start is used for where the item should be inserted, the count argument needs to be 0 as we don't want to replace existing data:

QList<ExampleItem> list;
ExampleItem item = ExampleItem();
list.insert(index, item);
QVariantList items = { QVariant::fromValue(item) };
emit dataChanged(items, index, 0);

Removing an item is very similar, start is used to indicate which item and count to indicate how much:

list.removeAt(index);
emit dataChanged(identifier, QVariantList(), index, 1);

See also insert(), remove(), and move().

[signal] void QIviSearchAndBrowseModelInterface::dataFetched(const QUuid &identifier, const QList<QVariant> &data, int start, bool moreAvailable)

This signal is emitted as a result of a call to fetchData() and returns the requested data in the argument data to the QIviSearchAndBrowseModel instance identified by identifier. The arguments start holds the index where the data starts and moreAvailable holds whether there is more data available and a new fetchData() call can be used to retrieve this data.

See also fetchData() and dataFetched().

[pure virtual] void QIviSearchAndBrowseModelInterface::fetchData(const QUuid &identifier, const QString &type, QIviAbstractQueryTerm *term, const QList<QIviOrderTerm> &orderTerms, int start, int count)

This function is called whenever new data of the given type type needs to be retrieved by a QIviSearchAndBrowseModel identified by identifier. The term and orderTerms properties are representations of the query which is used for filtering and sorting. The term pointer is null when the backend doesn't support filtering and sorting or when no query was defined in the QIviSearchAndBrowseModel instance.

The parameters start and count define the range of data which should be fetched. This method is expected to emit the dataFetched() signal once the new data is ready.

See also dataFetched().

[pure virtual] QString QIviSearchAndBrowseModelInterface::goBack(const QUuid &identifier, const QString &type)

Requests to go back to the previous displayed data set of the QIviSearchAndBrowseModel instance identified by identifier. The current content type is passed as type and the new content type should be returned.

See Browsing for more information on how this is used.

See also canGoBack().

[pure virtual] QString QIviSearchAndBrowseModelInterface::goForward(const QUuid &identifier, const QString &type, const QString &itemId)

Requests to go to the next data set of the QIviSearchAndBrowseModel instance identified by identifier and the current content type type. The item which is used for the new set of data is passed as itemId and the new content type should be returned.

See Browsing for more information on how this is used.

See also canGoForward().

[pure virtual] int QIviSearchAndBrowseModelInterface::indexOf(const QUuid &identifier, const QString &type, const QIviSearchAndBrowseModelItem *item)

Determines the index of item in the model identified by identifier and type. An id will be returned which identifies this call (-1 for an error, or not supported). The result is sent by emitting the indexOfCallResult() signal

The following code shows and example usage:

QVector<ExampleItem> list;

ExampleItem item = *static_cast<const ExampleItem*>(item);
static int callID = 0;

emit indexOfCallResult(identifier, callID, list.indexOf(item));

return callID++;

See also indexOfCallResult().

[signal] void QIviSearchAndBrowseModelInterface::indexOfCallResult(const QUuid &identifier, int callID, int index)

This signal is emitted as a result of a call to indexOf() and returns the index of the requested item. If the item is not part of the list -1 should be returned. The identifier and callID arguments are used to map this result to the matching model and the call.

See also indexOf().

[pure virtual] void QIviSearchAndBrowseModelInterface::insert(const QUuid &identifier, const QString &type, int index, const QIviSearchAndBrowseModelItem *item)

Adds the browsable item into the current dataset of the QIviSearchAndBrowseModel instance identified by identifier and the current content type type at index. The provided item could be owned by another model or QML, because of that it's expected that the backend stores its internal representation.

See also dataChanged().

[pure virtual] void QIviSearchAndBrowseModelInterface::move(const QUuid &identifier, const QString &type, int currentIndex, int newIndex)

Moves the browsable item at position currentIndex of the current dataset of the QIviSearchAndBrowseModel instance identified by identifier and the current content type type to the new position newIndex.

See also dataChanged().

[protected] void QIviSearchAndBrowseModelInterface::registerContentType(const QString &contentType)

Registers the type T with the name contentType. In addition all properties of type T will be registered as identifiers for the Qt IVI Query Language

[pure virtual] void QIviSearchAndBrowseModelInterface::remove(const QUuid &identifier, const QString &type, int index)

Removes the browsable item at position index from the current dataset of the QIviSearchAndBrowseModel instance identified by identifier and the current content type type.

See also dataChanged().

[signal] void QIviSearchAndBrowseModelInterface::supportedCapabilitiesChanged(const QUuid &identifier, QIviSearchAndBrowseModel::Capabilities capabilities)

Emitted when the capabilities of the model instance identified by identifier changed.

[virtual] QSet<QString> QIviSearchAndBrowseModelInterface::supportedIdentifiers(const QString &contentType) const

Returns the available identifiers for the given contentType.

Every identifier can be used in the Qt IVI Query Language for filtering or sorting.

It's recommended to use the registerContentType() function instead, which takes care of this function for you.

© 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.