Go
to the documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PHONON_OBJECTDESCRIPTIONMODEL_H
00024 #define PHONON_OBJECTDESCRIPTIONMODEL_H
00025
00026 #include "phonon_export.h"
00027 #include "phonondefs.h"
00028 #include "objectdescription.h"
00029 #include <QtCore/QList>
00030 #include <QtCore/QModelIndex>
00031 #include <QtCore/QStringList>
00032
00033 QT_BEGIN_HEADER
00034 QT_BEGIN_NAMESPACE
00035
00036 #ifndef QT_NO_PHONON_OBJECTDESCRIPTIONMODEL
00037
00038 namespace Phonon
00039 {
00040 class ObjectDescriptionModelDataPrivate;
00041
00048 class PHONON_EXPORT ObjectDescriptionModelData
00049 {
00050 public:
00063 int rowCount(const QModelIndex &parent = QModelIndex()) const;
00064
00076 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00077
00082 Qt::ItemFlags flags(const QModelIndex &index) const;
00083
00091 QList<int> tupleIndexOrder() const;
00092
00103 int tupleIndexAtPositionIndex(int positionIndex) const;
00104
00109 QMimeData *mimeData(ObjectDescriptionType type, const QModelIndexList &indexes) const;
00110
00117 void moveUp(const QModelIndex &index);
00118
00125 void moveDown(const QModelIndex &index);
00126
00127 void setModelData(const QList<QExplicitlySharedDataPointer<ObjectDescriptionData> > &data);
00128 QList<QExplicitlySharedDataPointer<ObjectDescriptionData> > modelData() const;
00129 QExplicitlySharedDataPointer<ObjectDescriptionData> modelData(const QModelIndex &index) const;
00130 Qt::DropActions supportedDropActions() const;
00131 bool dropMimeData(ObjectDescriptionType type, const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
00132 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
00133 QStringList mimeTypes(ObjectDescriptionType type) const;
00134
00135 ObjectDescriptionModelData(QAbstractListModel *);
00136 protected:
00137 ~ObjectDescriptionModelData();
00138
00139 ObjectDescriptionModelDataPrivate *const d;
00140 };
00141
00142
00143
00144 #if defined(Q_OS_SYMBIAN) && defined(Q_CC_RVCT)
00145
00146
00147
00148 #define PHONON_TEMPLATE_CLASS_EXPORT PHONON_EXPORT
00149 #define PHONON_TEMPLATE_CLASS_MEMBER_EXPORT
00150 #else
00151
00152
00153 #define PHONON_TEMPLATE_CLASS_EXPORT
00154 #define PHONON_TEMPLATE_CLASS_MEMBER_EXPORT PHONON_EXPORT
00155 #endif
00156
00192 template<ObjectDescriptionType type>
00193 class PHONON_TEMPLATE_CLASS_EXPORT ObjectDescriptionModel : public QAbstractListModel
00194 {
00195 public:
00196 Q_OBJECT_CHECK
00197
00199 static PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject staticMetaObject;
00201 PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject *metaObject() const;
00203 PHONON_TEMPLATE_CLASS_MEMBER_EXPORT void *qt_metacast(const char *_clname);
00204
00205
00218 inline int rowCount(const QModelIndex &parent = QModelIndex()) const { return d->rowCount(parent); }
00219
00231 inline QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const { return d->data(index, role); }
00232
00237 inline Qt::ItemFlags flags(const QModelIndex &index) const { return d->flags(index); }
00238
00246 inline QList<int> tupleIndexOrder() const { return d->tupleIndexOrder(); }
00247
00258 inline int tupleIndexAtPositionIndex(int positionIndex) const { return d->tupleIndexAtPositionIndex(positionIndex); }
00259
00264 inline QMimeData *mimeData(const QModelIndexList &indexes) const { return d->mimeData(type, indexes); }
00265
00272 inline void moveUp(const QModelIndex &index) { d->moveUp(index); }
00273
00280 inline void moveDown(const QModelIndex &index) { d->moveDown(index); }
00281
00286 explicit inline ObjectDescriptionModel(QObject *parent = 0) : QAbstractListModel(parent), d(new ObjectDescriptionModelData(this)) {}
00287
00292 explicit inline ObjectDescriptionModel(const QList<ObjectDescription<type> > &data, QObject *parent = 0)
00293 : QAbstractListModel(parent), d(new ObjectDescriptionModelData(this)) { setModelData(data); }
00294
00300 inline void setModelData(const QList<ObjectDescription<type> > &data) {
00301 QList<QExplicitlySharedDataPointer<ObjectDescriptionData> > list;
00302 for (int i = 0; i < data.count(); ++i) {
00303 list += data.at(i).d;
00304 }
00305 d->setModelData(list);
00306 }
00307
00314 inline QList<ObjectDescription<type> > modelData() const {
00315 QList<ObjectDescription<type> > ret;
00316 QList<QExplicitlySharedDataPointer<ObjectDescriptionData> > list = d->modelData();
00317 for (int i = 0; i < list.count(); ++i) {
00318 ret << ObjectDescription<type>(list.at(i));
00319 }
00320 return ret;
00321 }
00322
00326 inline ObjectDescription<type> modelData(const QModelIndex &index) const { return ObjectDescription<type>(d->modelData(index)); }
00327
00332 inline Qt::DropActions supportedDropActions() const { return d->supportedDropActions(); }
00333
00340 inline bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) {
00341 return d->dropMimeData(type, data, action, row, column, parent);
00342 }
00343
00352 inline bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) {
00353 return d->removeRows(row, count, parent);
00354 }
00355
00360 inline QStringList mimeTypes() const { return d->mimeTypes(type); }
00361
00362 protected:
00363 ObjectDescriptionModelData *const d;
00364 };
00365
00366 typedef ObjectDescriptionModel<AudioOutputDeviceType> AudioOutputDeviceModel;
00367 typedef ObjectDescriptionModel<AudioCaptureDeviceType> AudioCaptureDeviceModel;
00368 typedef ObjectDescriptionModel<EffectType> EffectDescriptionModel;
00369 typedef ObjectDescriptionModel<AudioChannelType> AudioChannelDescriptionModel;
00370 typedef ObjectDescriptionModel<SubtitleType> SubtitleDescriptionModel;
00371
00372
00373
00374
00375
00376
00377
00378
00379 }
00380
00381 #endif //QT_NO_PHONON_OBJECTDESCRIPTIONMODEL
00382
00383 QT_END_NAMESPACE
00384 QT_END_HEADER
00385
00386 #endif // PHONON_OBJECTDESCRIPTIONMODEL_H
00387