#include <Phonon/ObjectDescriptionModel>
The ObjectDescriptionModel class provides a model from a list of ObjectDescription objects.
ObjectDescriptionModel is a readonly model that supplies a list using ObjectDescription::name() for the text and ObjectDescription::description() for the tooltip. If set the properties "icon" and "available" are used to set the decoration and disable the item (disabled only visually, you can still select and drag it).
It also provides the methods moveUp() and moveDown() to order the list. Additionally drag and drop is possible so that QAbstractItemView::InternalMove can be used. The resulting order of the ObjectDescription::index() values can then be retrieved using tupleIndexOrder().
An example use case would be to give the user a QComboBox to select the output device:
And to retrieve the selected AudioOutputDevice:
Definition at line 166 of file objectdescription.h.
Public Member Functions | |
PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject * | metaObject () const |
PHONON_TEMPLATE_CLASS_MEMBER_EXPORT void * | qt_metacast (const char *_clname) |
int | rowCount (const QModelIndex &parent=QModelIndex()) const |
Returns the number of rows in the model. More... | |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
Returns data from the item with the given index for the specified role . More... | |
Qt::ItemFlags | flags (const QModelIndex &index) const |
Reimplemented to show unavailable devices as disabled (but still selectable). More... | |
QList< int > | tupleIndexOrder () const |
Returns a list of indexes in the same order as they are in the model. More... | |
int | tupleIndexAtPositionIndex (int positionIndex) const |
Returns the ObjectDescription::index for the tuple at the given position positionIndex . More... | |
QMimeData * | mimeData (const QModelIndexList &indexes) const |
Returns the MIME data that dropMimeData() can use to create new items. More... | |
void | moveUp (const QModelIndex &index) |
Moves the item at the given index up. More... | |
void | moveDown (const QModelIndex &index) |
Moves the item at the given index down. More... | |
ObjectDescriptionModel (QObject *parent=0) | |
Constructs a ObjectDescription model with the given parent . More... | |
ObjectDescriptionModel (const QList< ObjectDescription< type > > &data, QObject *parent=0) | |
Constructs a ObjectDescription model with the given parent and the given data . More... | |
void | setModelData (const QList< ObjectDescription< type > > &data) |
Sets the model data using the list provided by data . More... | |
QList< ObjectDescription< type > > | modelData () const |
Returns the model data. More... | |
ObjectDescription< type > | modelData (const QModelIndex &index) const |
Returns one ObjectDescription of the model data for the given index . More... | |
Qt::DropActions | supportedDropActions () const |
This model supports drag and drop to copy or move items. More... | |
bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
Accept drops from other models of the same ObjectDescriptionType. More... | |
bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) |
Removes count rows starting with the given row. More... | |
QStringList | mimeTypes () const |
Returns a list of supported drag and drop MIME types. More... | |
Public Member Functions inherited from QAbstractListModel | |
QAbstractListModel (QObject *parent=0) | |
~QAbstractListModel () | |
QModelIndex | index (int row, int column=0, const QModelIndex &parent=QModelIndex()) const |
bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
Public Member Functions inherited from QAbstractItemModel | |
QAbstractItemModel (QObject *parent=0) | |
virtual | ~QAbstractItemModel () |
bool | hasIndex (int row, int column, const QModelIndex &parent=QModelIndex()) const |
QModelIndex | sibling (int row, int column, const QModelIndex &idx) const |
virtual bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
virtual QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const |
virtual bool | setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole) |
virtual QMap< int, QVariant > | itemData (const QModelIndex &index) const |
virtual bool | setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles) |
Qt::DropActions | supportedDragActions () const |
void | setSupportedDragActions (Qt::DropActions) |
virtual bool | insertRows (int row, int count, const QModelIndex &parent=QModelIndex()) |
virtual bool | insertColumns (int column, int count, const QModelIndex &parent=QModelIndex()) |
virtual bool | removeColumns (int column, int count, const QModelIndex &parent=QModelIndex()) |
bool | insertRow (int row, const QModelIndex &parent=QModelIndex()) |
bool | insertColumn (int column, const QModelIndex &parent=QModelIndex()) |
bool | removeRow (int row, const QModelIndex &parent=QModelIndex()) |
bool | removeColumn (int column, const QModelIndex &parent=QModelIndex()) |
virtual void | fetchMore (const QModelIndex &parent) |
virtual bool | canFetchMore (const QModelIndex &parent) const |
virtual void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) |
virtual QModelIndex | buddy (const QModelIndex &index) const |
virtual QModelIndexList | match (const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const |
virtual QSize | span (const QModelIndex &index) const |
const QHash< int, QByteArray > & | roleNames () const |
Public Member Functions inherited from QObject | |
Q_INVOKABLE | QObject (QObject *parent=0) |
virtual | ~QObject () |
virtual bool | event (QEvent *) |
virtual bool | eventFilter (QObject *, QEvent *) |
QString | objectName () const |
void | setObjectName (const QString &name) |
bool | isWidgetType () const |
bool | signalsBlocked () const |
bool | blockSignals (bool b) |
QThread * | thread () const |
void | moveToThread (QThread *thread) |
int | startTimer (int interval) |
void | killTimer (int id) |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
const QObjectList & | children () const |
void | setParent (QObject *) |
void | installEventFilter (QObject *) |
void | removeEventFilter (QObject *) |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectTree () |
void | dumpObjectInfo () |
bool | setProperty (const char *name, const QVariant &value) |
QVariant | property (const char *name) const |
QList< QByteArray > | dynamicPropertyNames () const |
void | setUserData (uint id, QObjectUserData *data) |
QObjectUserData * | userData (uint id) const |
QObject * | parent () const |
bool | inherits (const char *classname) const |
Static Public Attributes | |
static Q_OBJECT_CHECK PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject | staticMetaObject |
Protected Attributes | |
ObjectDescriptionModelData *const | d |
Protected Attributes inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
|
inlineexplicit |
Constructs a ObjectDescription model with the given parent
.
Definition at line 287 of file objectdescriptionmodel.h.
|
inlineexplicit |
Constructs a ObjectDescription model with the given parent
and the given data
.
Definition at line 293 of file objectdescriptionmodel.h.
PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject* metaObject | ( | ) | const |
PHONON_TEMPLATE_CLASS_MEMBER_EXPORT void* qt_metacast | ( | const char * | _clname | ) |
|
inlinevirtual |
Returns the number of rows in the model.
This value corresponds to the size of the list passed through setModelData.
parent | The optional parent argument is used in most models to specify the parent of the rows to be counted. Because this is a list if a valid parent is specified the result will always be 0. |
Reimplemented from QAbstractItemModel.
Implements QAbstractItemModel.
Definition at line 219 of file objectdescriptionmodel.h.
|
inlinevirtual |
Returns data from the item with the given index
for the specified role
.
If the view requests an invalid index, an invalid variant is returned.
Reimplemented from QAbstractItemModel.
Implements QAbstractItemModel.
Definition at line 232 of file objectdescriptionmodel.h.
|
inlinevirtual |
Reimplemented to show unavailable devices as disabled (but still selectable).
Reimplemented from QAbstractItemModel.
Definition at line 238 of file objectdescriptionmodel.h.
Returns a list of indexes in the same order as they are in the model.
The indexes come from the ObjectDescription::index method.
This is useful to let the user define a list of preference.
Definition at line 247 of file objectdescriptionmodel.h.
Returns the ObjectDescription::index for the tuple at the given position positionIndex
.
For example a QComboBox will give you the currentIndex as the position in the list. But to select the according AudioOutputDevice using AudioOutputDevice::fromIndex you can use this method.
positionIndex | The position in the list. |
Definition at line 259 of file objectdescriptionmodel.h.
|
inlinevirtual |
Returns the MIME data that dropMimeData() can use to create new items.
Reimplemented from QAbstractItemModel.
Definition at line 265 of file objectdescriptionmodel.h.
|
inline |
Moves the item at the given index
up.
In the resulting list the items at index.row() and index.row() - 1 are swapped.
Connected views are updated automatically.
Definition at line 273 of file objectdescriptionmodel.h.
|
inline |
Moves the item at the given index
down.
In the resulting list the items at index.row() and index.row() + 1 are swapped.
Connected views are updated automatically.
Definition at line 281 of file objectdescriptionmodel.h.
|
inline |
Sets the model data using the list provided by data
.
All previous model data is cleared.
Definition at line 301 of file objectdescriptionmodel.h.
|
inline |
Returns the model data.
As the order of the list might have changed this can be different to what was set using setModelData().
Definition at line 315 of file objectdescriptionmodel.h.
|
inline |
Returns one ObjectDescription of the model data for the given index
.
Definition at line 327 of file objectdescriptionmodel.h.
|
inlinevirtual |
This model supports drag and drop to copy or move items.
Reimplemented from QAbstractItemModel.
Definition at line 333 of file objectdescriptionmodel.h.
|
inlinevirtual |
Accept drops from other models of the same ObjectDescriptionType.
If a valid parent
is given the dropped items will be inserted above that item.
Reimplemented from QAbstractItemModel.
Definition at line 341 of file objectdescriptionmodel.h.
|
inlinevirtual |
Removes count rows starting with the given row.
If a valid parent
is given no rows are removed since this is a list model.
Returns true if the rows were successfully removed; otherwise returns false.
Reimplemented from QAbstractItemModel.
Definition at line 353 of file objectdescriptionmodel.h.
|
inlinevirtual |
Returns a list of supported drag and drop MIME types.
Currently it only supports one type used internally.
Reimplemented from QAbstractItemModel.
Definition at line 361 of file objectdescriptionmodel.h.
|
static |
Definition at line 200 of file objectdescriptionmodel.h.
|
protected |
Definition at line 364 of file objectdescriptionmodel.h.