phonon/objectdescriptionmodel.h Source File

objectdescriptionmodel.h
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  Copyright (C) 2006-2007 Matthias Kretz <kretz@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) version 3, or any
8  later version accepted by the membership of KDE e.V. (or its
9  successor approved by the membership of KDE e.V.), Nokia Corporation
10  (or its successors, if any) and the KDE Free Qt Foundation, which shall
11  act as a proxy defined in Section 6 of version 3 of the license.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library. If not, see <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifndef PHONON_OBJECTDESCRIPTIONMODEL_H
24 #define PHONON_OBJECTDESCRIPTIONMODEL_H
25 
26 #include "phonon_export.h"
27 #include "phonondefs.h"
28 #include "objectdescription.h"
29 #include <QtCore/QList>
30 #include <QtCore/QModelIndex>
31 #include <QtCore/QStringList>
32 
35 
36 #ifndef QT_NO_PHONON_OBJECTDESCRIPTIONMODEL
37 
38 namespace Phonon
39 {
40  class ObjectDescriptionModelDataPrivate;
41 
49  {
50  public:
63  int rowCount(const QModelIndex &parent = QModelIndex()) const;
64 
76  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
77 
82  Qt::ItemFlags flags(const QModelIndex &index) const;
83 
91  QList<int> tupleIndexOrder() const;
92 
103  int tupleIndexAtPositionIndex(int positionIndex) const;
104 
109  QMimeData *mimeData(ObjectDescriptionType type, const QModelIndexList &indexes) const;
110 
117  void moveUp(const QModelIndex &index);
118 
125  void moveDown(const QModelIndex &index);
126 
127  void setModelData(const QList<QExplicitlySharedDataPointer<ObjectDescriptionData> > &data);
130  Qt::DropActions supportedDropActions() const;
131  bool dropMimeData(ObjectDescriptionType type, const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
132  bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
133  QStringList mimeTypes(ObjectDescriptionType type) const;
134 
136  protected:
138  //ObjectDescriptionModelData(ObjectDescriptionModelDataPrivate *dd);
139  ObjectDescriptionModelDataPrivate *const d;
140  };
141 
142 /* Required to ensure template class vtables are exported on both symbian
143 and existing builds. */
144 #if (defined(Q_OS_SYMBIAN) && defined(Q_CC_RVCT)) || defined(Q_CC_CLANG)
145 // RVCT compiler (2.2.686) requires the export declaration to be on the class to export vtables
146 // MWC compiler works both ways
147 // GCCE compiler is unknown (it can't compile QtCore yet)
148 // Clang also requires the export declaration to be on the class to export vtables
149 #define PHONON_TEMPLATE_CLASS_EXPORT PHONON_EXPORT
150 #define PHONON_TEMPLATE_CLASS_MEMBER_EXPORT
151 #else
152 // Windows builds (at least) do not support export declaration on templated class
153 // But if you export a member function, the vtable is implicitly exported
154 #define PHONON_TEMPLATE_CLASS_EXPORT
155 #define PHONON_TEMPLATE_CLASS_MEMBER_EXPORT PHONON_EXPORT
156 #endif
157 
193  template<ObjectDescriptionType type>
194  class PHONON_TEMPLATE_CLASS_EXPORT ObjectDescriptionModel : public QAbstractListModel
195  {
196  public:
198 
202  PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject *metaObject() const;
204  PHONON_TEMPLATE_CLASS_MEMBER_EXPORT void *qt_metacast(const char *_clname);
205  //int qt_metacall(QMetaObject::Call _c, int _id, void **_a);
206 
219  inline int rowCount(const QModelIndex &parent = QModelIndex()) const { return d->rowCount(parent); } //krazy:exclude=inline
220 
232  inline QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const { return d->data(index, role); } //krazy:exclude=inline
233 
238  inline Qt::ItemFlags flags(const QModelIndex &index) const { return d->flags(index); } //krazy:exclude=inline
239 
247  inline QList<int> tupleIndexOrder() const { return d->tupleIndexOrder(); } //krazy:exclude=inline
248 
259  inline int tupleIndexAtPositionIndex(int positionIndex) const { return d->tupleIndexAtPositionIndex(positionIndex); } //krazy:exclude=inline
260 
265  inline QMimeData *mimeData(const QModelIndexList &indexes) const { return d->mimeData(type, indexes); } //krazy:exclude=inline
266 
273  inline void moveUp(const QModelIndex &index) { d->moveUp(index); } //krazy:exclude=inline
274 
281  inline void moveDown(const QModelIndex &index) { d->moveDown(index); } //krazy:exclude=inline
282 
287  explicit inline ObjectDescriptionModel(QObject *parent = 0) : QAbstractListModel(parent), d(new ObjectDescriptionModelData(this)) {} //krazy:exclude=inline
288 
293  explicit inline ObjectDescriptionModel(const QList<ObjectDescription<type> > &data, QObject *parent = 0) //krazy:exclude=inline
294  : QAbstractListModel(parent), d(new ObjectDescriptionModelData(this)) { setModelData(data); }
295 
301  inline void setModelData(const QList<ObjectDescription<type> > &data) { //krazy:exclude=inline
303  for (int i = 0; i < data.count(); ++i) {
304  list += data.at(i).d;
305  }
306  d->setModelData(list);
307  }
308 
315  inline QList<ObjectDescription<type> > modelData() const { //krazy:exclude=inline
318  for (int i = 0; i < list.count(); ++i) {
319  ret << ObjectDescription<type>(list.at(i));
320  }
321  return ret;
322  }
323 
327  inline ObjectDescription<type> modelData(const QModelIndex &index) const { return ObjectDescription<type>(d->modelData(index)); } //krazy:exclude=inline
328 
333  inline Qt::DropActions supportedDropActions() const { return d->supportedDropActions(); } //krazy:exclude=inline
334 
341  inline bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { //krazy:exclude=inline
342  return d->dropMimeData(type, data, action, row, column, parent);
343  }
344 
353  inline bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) { //krazy:exclude=inline
354  return d->removeRows(row, count, parent);
355  }
356 
361  inline QStringList mimeTypes() const { return d->mimeTypes(type); } //krazy:exclude=inline
362 
363  protected:
365  };
366 
372 /*
373  typedef ObjectDescriptionModel<VideoOutputDeviceType> VideoOutputDeviceModel;
374  typedef ObjectDescriptionModel<VideoCaptureDeviceType> VideoCaptureDeviceModel;
375  typedef ObjectDescriptionModel<AudioCodecType> AudioCodecDescriptionModel;
376  typedef ObjectDescriptionModel<VideoCodecType> VideoCodecDescriptionModel;
377  typedef ObjectDescriptionModel<ContainerFormatType> ContainerFormatDescriptionModel;
378  typedef ObjectDescriptionModel<VisualizationType> VisualizationDescriptionModel;*/
379 
380 }
381 
382 #endif //QT_NO_PHONON_OBJECTDESCRIPTIONMODEL
383 
386 
387 #endif // PHONON_OBJECTDESCRIPTIONMODEL_H
388 // vim: sw=4 ts=4 tw=80
GLuint GLuint GLsizei GLenum type
Definition: GLee.h:872
void setModelData(const QList< ObjectDescription< type > > &data)
Sets the model data using the list provided by data.
The ObjectDescriptionModel class provides a model from a list of ObjectDescription objects...
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
QList< int > tupleIndexOrder() const
Returns a list of indexes in the same order as they are in the model.
Qt::ItemFlags flags(const QModelIndex &index) const
Reimplemented to show unavailable devices as disabled (but still selectable).
ObjectDescriptionType
Defines the type of information that is contained in a ObjectDescription object.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Returns data from the item with the given index for the specified role.
void moveDown(const QModelIndex &index)
Moves the item at the given index down.
QMimeData * mimeData(const QModelIndexList &indexes) const
Returns the MIME data that dropMimeData() can use to create new items.
ObjectDescriptionModel< AudioCaptureDeviceType > AudioCaptureDeviceModel
ObjectDescriptionModelDataPrivate *const d
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Accept drops from other models of the same ObjectDescriptionType.
int tupleIndexAtPositionIndex(int positionIndex) const
Returns the ObjectDescription::index for the tuple at the given position positionIndex.
void moveUp(const QModelIndex &index)
Moves the item at the given index up.
ObjectDescriptionModel(const QList< ObjectDescription< type > > &data, QObject *parent=0)
Constructs a ObjectDescription model with the given parent and the given data.
#define PHONON_TEMPLATE_CLASS_MEMBER_EXPORT
ObjectDescriptionModel< SubtitleType > SubtitleDescriptionModel
GLenum GLenum GLvoid * row
Definition: GLee.h:893
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
int rowCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of rows in the model.
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: GLee.h:880
ObjectDescriptionModel< AudioOutputDeviceType > AudioOutputDeviceModel
Provides a tuple of enduser visible name and description.
const T & at(int i) const
Definition: qlist.h:468
GLuint GLuint GLsizei count
Definition: GLee.h:872
static Q_OBJECT_CHECK PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject staticMetaObject
DropAction
Definition: qnamespace.h:1597
ObjectDescriptionModel(QObject *parent=0)
Constructs a ObjectDescription model with the given parent.
ObjectDescriptionModel< EffectType > EffectDescriptionModel
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
Removes count rows starting with the given row.
int count(const T &t) const
Definition: qlist.h:891
#define Q_OBJECT_CHECK
Definition: qobjectdefs.h:139
GLenum GLenum GLvoid GLvoid * column
Definition: GLee.h:893
ObjectDescriptionModel< AudioChannelType > AudioChannelDescriptionModel
The KDE Multimedia classes.
#define PHONON_TEMPLATE_CLASS_EXPORT
QList< ObjectDescription< type > > modelData() const
Returns the model data.
Data class for models for ObjectDescription objects.
QStringList mimeTypes() const
Returns a list of supported drag and drop MIME types.
ObjectDescription< type > modelData(const QModelIndex &index) const
Returns one ObjectDescription of the model data for the given index.
#define PHONON_EXPORT
Definition: phonon_export.h:38
#define QT_END_HEADER
Definition: qglobal.h:142
ObjectDescriptionModelData *const d
void * data()
GLuint index
Definition: GLee.h:1704
Qt::DropActions supportedDropActions() const
This model supports drag and drop to copy or move items.