Phonon  4.7.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
objectdescriptionmodel.h
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 
33 
34 #ifndef QT_NO_PHONON_OBJECTDESCRIPTIONMODEL
35 
36 namespace Phonon
37 {
38  class ObjectDescriptionModelDataPrivate;
39 
46  class PHONON_EXPORT ObjectDescriptionModelData
47  {
48  public:
61  int rowCount(const QModelIndex &parent = QModelIndex()) const;
62 
74  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
75 
80  Qt::ItemFlags flags(const QModelIndex &index) const;
81 
89  QList<int> tupleIndexOrder() const;
90 
101  int tupleIndexAtPositionIndex(int positionIndex) const;
102 
107  QMimeData *mimeData(ObjectDescriptionType type, const QModelIndexList &indexes) const;
108 
115  void moveUp(const QModelIndex &index);
116 
123  void moveDown(const QModelIndex &index);
124 
125  void setModelData(const QList<QExplicitlySharedDataPointer<ObjectDescriptionData> > &data);
127  QExplicitlySharedDataPointer<ObjectDescriptionData> modelData(const QModelIndex &index) const;
128  Qt::DropActions supportedDropActions() const;
129  bool dropMimeData(ObjectDescriptionType type, const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
130  bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
131  QStringList mimeTypes(ObjectDescriptionType type) const;
132 
133  ObjectDescriptionModelData(QAbstractListModel *);
134  protected:
136  //ObjectDescriptionModelData(ObjectDescriptionModelDataPrivate *dd);
137  ObjectDescriptionModelDataPrivate *const d;
138  };
139 
140 /* Required to ensure template class vtables are exported on both symbian
141 and existing builds. */
142 #if defined(Q_OS_SYMBIAN) && defined(Q_CC_RVCT) || defined(Q_CC_CLANG)
143 // RVCT compiler (2.2.686) requires the export declaration to be on the class to export vtables
144 // MWC compiler works both ways
145 // GCCE compiler is unknown (it can't compile QtCore yet)
146 // Clang also requires the export declaration to be on the class to export vtables
147 #define PHONON_TEMPLATE_CLASS_EXPORT PHONON_EXPORT
148 #define PHONON_TEMPLATE_CLASS_MEMBER_EXPORT
149 #else
150 // Windows builds (at least) do not support export declaration on templated class
151 // But if you export a member function, the vtable is implicitly exported
152 #define PHONON_TEMPLATE_CLASS_EXPORT
153 #define PHONON_TEMPLATE_CLASS_MEMBER_EXPORT PHONON_EXPORT
154 #endif
155 
191  template<ObjectDescriptionType type>
192  class PHONON_TEMPLATE_CLASS_EXPORT ObjectDescriptionModel : public QAbstractListModel
193  {
194  public:
195  Q_OBJECT_CHECK
196 
198  static PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject staticMetaObject;
200  PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject *metaObject() const;
202  PHONON_TEMPLATE_CLASS_MEMBER_EXPORT void *qt_metacast(const char *_clname);
203  //int qt_metacall(QMetaObject::Call _c, int _id, void **_a);
204 
217  inline int rowCount(const QModelIndex &parent = QModelIndex()) const { return d->rowCount(parent); } //krazy:exclude=inline
218 
230  inline QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const { return d->data(index, role); } //krazy:exclude=inline
231 
236  inline Qt::ItemFlags flags(const QModelIndex &index) const { return d->flags(index); } //krazy:exclude=inline
237 
245  inline QList<int> tupleIndexOrder() const { return d->tupleIndexOrder(); } //krazy:exclude=inline
246 
257  inline int tupleIndexAtPositionIndex(int positionIndex) const { return d->tupleIndexAtPositionIndex(positionIndex); } //krazy:exclude=inline
258 
263  inline QMimeData *mimeData(const QModelIndexList &indexes) const { return d->mimeData(type, indexes); } //krazy:exclude=inline
264 
271  inline void moveUp(const QModelIndex &index) { d->moveUp(index); } //krazy:exclude=inline
272 
279  inline void moveDown(const QModelIndex &index) { d->moveDown(index); } //krazy:exclude=inline
280 
285  explicit inline ObjectDescriptionModel(QObject *parent = 0) : QAbstractListModel(parent), d(new ObjectDescriptionModelData(this)) {} //krazy:exclude=inline
286 
291  explicit inline ObjectDescriptionModel(const QList<ObjectDescription<type> > &data, QObject *parent = 0) //krazy:exclude=inline
292  : QAbstractListModel(parent), d(new ObjectDescriptionModelData(this)) { setModelData(data); }
293 
299  inline void setModelData(const QList<ObjectDescription<type> > &data) { //krazy:exclude=inline
301  for (int i = 0; i < data.count(); ++i) {
302  list += data.at(i).d;
303  }
304  d->setModelData(list);
305  }
306 
313  inline QList<ObjectDescription<type> > modelData() const { //krazy:exclude=inline
316  for (int i = 0; i < list.count(); ++i) {
317  ret << ObjectDescription<type>(list.at(i));
318  }
319  return ret;
320  }
321 
325  inline ObjectDescription<type> modelData(const QModelIndex &index) const { return ObjectDescription<type>(d->modelData(index)); } //krazy:exclude=inline
326 
331  inline Qt::DropActions supportedDropActions() const { return d->supportedDropActions(); } //krazy:exclude=inline
332 
339  inline bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { //krazy:exclude=inline
340  return d->dropMimeData(type, data, action, row, column, parent);
341  }
342 
351  inline bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) { //krazy:exclude=inline
352  return d->removeRows(row, count, parent);
353  }
354 
359  inline QStringList mimeTypes() const { return d->mimeTypes(type); } //krazy:exclude=inline
360 
361  protected:
363  };
364 
365  typedef ObjectDescriptionModel<AudioOutputDeviceType> AudioOutputDeviceModel;
366  typedef ObjectDescriptionModel<AudioCaptureDeviceType> AudioCaptureDeviceModel;
367  typedef ObjectDescriptionModel<VideoCaptureDeviceType> VideoCaptureDeviceModel;
368  typedef ObjectDescriptionModel<EffectType> EffectDescriptionModel;
369  typedef ObjectDescriptionModel<AudioChannelType> AudioChannelDescriptionModel;
370  typedef ObjectDescriptionModel<SubtitleType> SubtitleDescriptionModel;
371 /*
372  typedef ObjectDescriptionModel<VideoOutputDeviceType> VideoOutputDeviceModel;
373  typedef ObjectDescriptionModel<AudioCodecType> AudioCodecDescriptionModel;
374  typedef ObjectDescriptionModel<VideoCodecType> VideoCodecDescriptionModel;
375  typedef ObjectDescriptionModel<ContainerFormatType> ContainerFormatDescriptionModel;
376  typedef ObjectDescriptionModel<VisualizationType> VisualizationDescriptionModel;*/
377 
378 }
379 
380 #endif //QT_NO_PHONON_OBJECTDESCRIPTIONMODEL
381 
382 
383 #endif // PHONON_OBJECTDESCRIPTIONMODEL_H
384 // vim: sw=4 ts=4 tw=80