QIfPlayQueue Class
Provides a play queue for the QIfMediaPlayer. More...
Header: | #include <QIfPlayQueue> |
qmake: | QT += ifmedia |
Instantiated By: | PlayQueue |
Inherits: | QAbstractListModel |
Public Types
enum | LoadingType { FetchMore, DataChanged } |
enum | Roles { NameRole, TypeRole, ItemRole } |
Properties
|
|
Public Functions
T | at(int i) const |
int | chunkSize() const |
int | currentIndex() const |
int | fetchMoreThreshold() const |
QVariant | get(int i) const |
void | insert(int index, const QVariant &variant) |
QIfPlayQueue::LoadingType | loadingType() const |
void | move(int cur_index, int new_index) |
void | remove(int index) |
void | setChunkSize(int chunkSize) |
void | setCurrentIndex(int currentIndex) |
void | setFetchMoreThreshold(int fetchMoreThreshold) |
void | setLoadingType(QIfPlayQueue::LoadingType loadingType) |
Reimplemented Public Functions
virtual bool | canFetchMore(const QModelIndex &parent) const override |
virtual QVariant | data(const QModelIndex &index, int role) const override |
virtual void | fetchMore(const QModelIndex &parent) override |
virtual QHash<int, QByteArray> | roleNames() const override |
virtual int | rowCount(const QModelIndex &parent = QModelIndex()) const override |
Signals
void | chunkSizeChanged(int chunkSize) |
void | countChanged() |
void | currentIndexChanged(int currentIndex) |
void | fetchMoreThresholdChanged(int fetchMoreThreshold) |
void | fetchMoreThresholdReached() const |
void | loadingTypeChanged(QIfPlayQueue::LoadingType loadingType) |
Protected Functions
QIfPlayQueue(QIfMediaPlayer *parent = nullptr) |
Detailed Description
The QIfPlayQueue is a model which is used by the QIfMediaPlayer to control the play order of QIfPlayableItems.
It provides mechanisms for adding new items and managing the existing ones by removing or moving them around.
The QIfPlayQueue can't be instantiated by its own and can only be retrieved through the QIfMediaPlayer.
The following roles are available in this model:
Role name | Type | Description |
---|---|---|
name | string | The name of the playable item. E.g. The track name or the name of the web-stream. |
type | string | The type of the playable item. E.g. "track" or "web-stream" |
item | QIfPlayableItem | The playable item instance. This can be used to access type specific properties like the artist. |
Member Type Documentation
enum QIfPlayQueue::LoadingType
Constant | Value | Description |
---|---|---|
QIfPlayQueue::FetchMore | 0 | This is the default and can be used if you don't know the final size of the list (e.g. a infinite list). The list will detect that it is near the end (fetchMoreThreshold) and then fetch the next chunk of data using canFetchMore and fetchMore. The drawback of this method is that, because the final size of the data is not known, you can't display a dynamic scroll-bar indicator which is resized depending on the content of the list. The other problem could be fast scrolling, as the data might not come in-time and scrolling stops. This can be tweaked by the fetchMoreThreshold property. |
QIfPlayQueue::DataChanged | 1 | For this loading type you need to know how many items are in the list, as dummy items are created and the user can already start scrolling even though the data is not yet ready to be displayed. Similar to FetchMore the data is also loaded in chunks. You can safely use a scroll indicator here. The delegate needs to support this approach, as it doesn't have a content when it's first created. |
enum QIfPlayQueue::Roles
Constant | Value | Description |
---|---|---|
QIfPlayQueue::NameRole | Qt::DisplayRole | The name of the playable item. E.g. The track name or the name of the web-stream. |
QIfPlayQueue::TypeRole | Qt::UserRole | The type of the playable item. E.g. "track" or "web-stream" |
QIfPlayQueue::ItemRole | 257 | The playable item instance. This can be used to access type specific properties like the artist. |
Property Documentation
chunkSize : int
Holds the number of rows which are requested from the backend interface.
This property can be used to fine tune the loading performance.
Bigger chunks means less calls to the backend and to a potential IPC underneath, but more data to be transferred and probably longer waiting time until the request was finished.
Access functions:
int | chunkSize() const |
void | setChunkSize(int chunkSize) |
Notifier signal:
void | chunkSizeChanged(int chunkSize) |
[read-only]
count : const int
Holds the current number of rows in this model.
Access functions:
virtual int | rowCount(const QModelIndex &parent = QModelIndex()) const override |
Notifier signal:
void | countChanged() |
currentIndex : int
Holds the index of the currently active track.
Use the get() method to retrieve more information about the active track.
Access functions:
int | currentIndex() const |
void | setCurrentIndex(int currentIndex) |
Notifier signal:
void | currentIndexChanged(int currentIndex) |
fetchMoreThreshold : int
Holds the row delta to the end before the next chunk is loaded
This property can be used to fine tune the loading performance. When the threshold is reached the next chunk of rows are requested from the backend. How many rows are fetched can be defined by using the chunkSize property.
The threshold defines the number of rows before the cached rows ends.
Note: This property is only used when loadingType is set to FetchMore.
Access functions:
int | fetchMoreThreshold() const |
void | setFetchMoreThreshold(int fetchMoreThreshold) |
Notifier signal:
void | fetchMoreThresholdChanged(int fetchMoreThreshold) |
loadingType : QIfPlayQueue::LoadingType
Holds the currently used loading type used for loading the data.
Note: When changing this property the content will be reset.
Access functions:
QIfPlayQueue::LoadingType | loadingType() const |
void | setLoadingType(QIfPlayQueue::LoadingType loadingType) |
Notifier signal:
void | loadingTypeChanged(QIfPlayQueue::LoadingType loadingType) |
Member Function Documentation
[protected]
QIfPlayQueue::QIfPlayQueue(QIfMediaPlayer *parent = nullptr)
Creates a play queue for the QIfMediaPlayer instance parent.
[signal]
void QIfPlayQueue::fetchMoreThresholdReached() const
This signal is emitted whenever the fetchMoreThreshold is reached and new data is requested from the backend.
template <typename T> T QIfPlayQueue::at(int i) const
Returns the item at index i converted to the template type T.
[override virtual]
bool QIfPlayQueue::canFetchMore(const QModelIndex &parent) const
Reimplements: QAbstractItemModel::canFetchMore(const QModelIndex &parent) const.
[override virtual]
QVariant QIfPlayQueue::data(const QModelIndex &index, int role) const
Reimplements: QAbstractItemModel::data(const QModelIndex &index, int role) const.
[override virtual]
void QIfPlayQueue::fetchMore(const QModelIndex &parent)
Reimplements: QAbstractItemModel::fetchMore(const QModelIndex &parent).
[invokable]
QVariant QIfPlayQueue::get(int i) const
Returns the item at index i.
This function is intended to be used from QML. For C++ please use the at() instead.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[invokable]
void QIfPlayQueue::insert(int index, const QVariant &variant)
Insert the variant at the position index.
If the backend doesn't accept the provided item, this operation will end in a no op.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[invokable]
void QIfPlayQueue::move(int cur_index, int new_index)
Moves the item at position cur_index to the new position new_index the play queue.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[invokable]
void QIfPlayQueue::remove(int index)
Removes the item at position index from the play queue.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[override virtual]
QHash<int, QByteArray> QIfPlayQueue::roleNames() const
Reimplements: QAbstractItemModel::roleNames() const.
© 2021 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.