Public Slots |
| void | get (const QString &resourcePath, const QVariantMap &filters=QVariantMap()) |
| | Retrieves a list of SoundCloud resources belonging to resourcePath.
|
| void | insert (const QVariantMap &resource) |
| | Inserts a new SoundCloud resource into the current resourcePath.
|
| void | insert (int row, const QString &resourcePath) |
| | Inserts the SoundCloud resource at row into resourcePath.
|
|
void | update (int row, const QVariantMap &resource) |
| | Updates the SoundCloud resource at row with resource.
|
|
void | del (int row) |
| | Deletes the SoundCloud resource at row from the current resourcePath.
|
|
void | del (int row, const QString &resourcePath) |
| | Deletes the SoundCloud resource at row from resourcePath.
|
| void | cancel () |
| | Cancels the current request.
|
|
void | reload () |
| | Clears any existing data and retreives a new list of SoundCloud resources using the existing parameters.
|
|
void | clear () |
| | Removes all items.
|
Public Member Functions |
| void | setNetworkAccessManager (QNetworkAccessManager *manager) |
| | Sets the QNetworkAccessManager instance to be used when making requests to the SoundCloud Data API.
|
|
int | rowCount (const QModelIndex &parent=QModelIndex()) const |
| | Returns the number of items in the model.
|
|
QVariant | data (const QModelIndex &index, int role) const |
| | Re-implemented from QAbstractListModel::data()
|
|
QMap< int, QVariant > | itemData (const QModelIndex &index) const |
| | Re-implemented from QAbstractListModel::itemData()
|
|
bool | setData (const QModelIndex &index, const QVariant &value, int role) |
| | Re-implemented from QAbstractListModel::setData()
|
|
bool | setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles) |
| | Re-implemented from QAbstractListModel::setItemData()
|
|
void | append (const QMap< int, QVariant > &roles) |
| | Appends an item using the data in roles.
|
| void | insert (const QModelIndex &index, const QMap< int, QVariant > &roles) |
| | Inserts an item before index using the data in roles.
|
| bool | remove (const QModelIndex &index) |
| | Removes the item at index.
|
|
Q_INVOKABLE QVariantMap | get (int row) const |
| | Returns the item at row.
|
| Q_INVOKABLE bool | setProperty (int row, const QString &property, const QVariant &value) |
| | Sets the property of the item at row to value.
|
| Q_INVOKABLE bool | set (int row, const QVariantMap &properties) |
| | Sets the properties of the item at row to properties.
|
|
Q_INVOKABLE void | append (const QVariantMap &properties) |
| | Appends an item to the model using properties.
|
| Q_INVOKABLE void | insert (int row, const QVariantMap &properties) |
| | Inserts an item before row to the model using properties.
|
| Q_INVOKABLE bool | remove (int row) |
| | Removes the item at row.
|
A list model for displaying SoundCloud resources.
The ResourcesModel is a list model used for displaying SoundCloud resources in a list view. ResourcesModel provides the same methods that are available in ResourcesRequest, so it is better to simply use that class if you do not need the additional features provided by a data model.
Roles
The roles and role names of ResourcesModel are created dynamically when the model is populated with data. The roles are created by iterating through the keys of the first item in alphabetical order, starting at Qt::UserRole + 1. The role names are the keys themselves.
Example usage:
C++
using namespace QSoundCloud;
...
QListView *view = new QListView(this);
QVariantMap filters;
filters["limit"] = 10;
filters["q"] = "Qt";
model->get("/tracks", filters);
QML
import QtQuick 1.0
import QSoundCloud 1.0
ListView {
id: view
width: 800
height: 480
model: ResourcesModel {
id: resourcesModel
}
delegate: Text {
width: view.width
height: 50
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
text: title
}
Component.onCompleted: resourcesModel.get("/tracks", {limit: 10, search: "Qt"})
}
- See Also
- ResourcesRequest