QYouTube
A Qt/C++ library and QML module to access the YouTube Data API.
 All Classes Functions Enumerations Properties Groups Pages
Public Types | Public Slots | Signals | Public Member Functions | Properties | List of all members
QYouTube::SubtitlesModel Class Reference

A list model for displaying list of subtitles for a YouTube video. More...

Inheritance diagram for QYouTube::SubtitlesModel:
QYouTube::Model

Public Types

enum  Roles
 The data roles available for accessing the model data. More...

Public Slots

void list (const QString &id)
 Retrieves a list of subtitles for a YouTube video.
void cancel ()
 Cancels the current request.
void reload ()
 Clears any existing data and retreives a new list of subtitles using the existing parameters.
- Public Slots inherited from QYouTube::Model
void clear ()
 Removes all items.

Signals

void statusChanged (QYouTube::SubtitlesRequest::Status s)
 Emitted when the status changes.
- Signals inherited from QYouTube::Model
void countChanged (int c)
 Emitted when items are added/removed.

Public Member Functions

void setNetworkAccessManager (QNetworkAccessManager *manager)
 Sets the QNetworkAccessManager instance to be used when making requests.
- Public Member Functions inherited from QYouTube::Model
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.

Properties

QYouTube::SubtitlesRequest::Status status
 The current status of the model.
QVariant result
 The current result of the model.
QYouTube::SubtitlesRequest::Error error
 The error type of the model.
QString errorString
 A description of the error of the model.
- Properties inherited from QYouTube::Model
int count
 The number of items in the model.

Detailed Description

A list model for displaying list of subtitles for a YouTube video.

The SubtitlesModel is a list model used for displaying YouTube video subtitles in a list view. SubtitlesModel provides the same methods that are available in SubtitlesRequest, so it is better to simply use that class if you do not need the additional features provided by a data model.

SubtitlesModel provides the following roles and role names:

Role Role name
IdRole id
LanguageCodeRole languageCode
OriginalLanguageRole originalLanguage
TranslatedLanguageRole translatedLanguage
UrlRole url

Example usage:

C++

using namespace QYouTube;
...
QListView *view = new QListView(this);
SubtitlesModel *model = new SubtitlesModel(this);
view->setModel(model);
model->list(VIDEO_ID);

QML

import QtQuick 1.0
import QYouTube 1.0
ListView {
id: view
width: 800
height: 480
model: SubtitlesModel {
id: subtitlesModel
}
delegate: Text {
width: view.width
height: 50
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
text: language
}
Component.onCompleted: subtitlesModel.list(VIDEO_ID)
}
See Also
SubtitlesRequest

Member Enumeration Documentation

The data roles available for accessing the model data.

See the detailed description for the list of available roles.

Member Function Documentation

void QYouTube::SubtitlesModel::cancel ( )
slot

Cancels the current request.

See Also
SubtitlesRequest::cancel()
void QYouTube::SubtitlesModel::list ( const QString &  id)
slot

Retrieves a list of subtitles for a YouTube video.

See Also
SubtitlesRequest::list()
void QYouTube::SubtitlesModel::setNetworkAccessManager ( QNetworkAccessManager *  manager)

Sets the QNetworkAccessManager instance to be used when making requests.

SubtitlesModel does not take ownership of manager.

If no QNetworkAccessManager is set, one will be created when required.

See Also
SubtitlesRequest::setNetworkAccessManager()

Property Documentation

SubtitlesRequest::Error QYouTube::SubtitlesModel::error
read

The error type of the model.

See Also
SubtitlesRequest::error
QString QYouTube::SubtitlesModel::errorString
read

A description of the error of the model.

See Also
SubtitlesRequest::status
QVariant QYouTube::SubtitlesModel::result
read

The current result of the model.

See Also
SubtitlesRequest::result
SubtitlesRequest::Status QYouTube::SubtitlesModel::status
read

The current status of the model.

See Also
SubtitlesRequest::status