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_OBJECTDESCRIPTION_H
00024 #define PHONON_OBJECTDESCRIPTION_H
00025
00026 #include "phonon_export.h"
00027
00028 #include <QtCore/QExplicitlySharedDataPointer>
00029 #include <QtCore/QtDebug>
00030 #include <QtCore/QList>
00031 #include <QtCore/QSharedData>
00032 #include <QtCore/QString>
00033 #include <QtCore/QVariant>
00034
00035 QT_BEGIN_HEADER
00036 QT_BEGIN_NAMESPACE
00037
00038 namespace Phonon
00039 {
00040 class ObjectDescriptionPrivate;
00041
00048 enum ObjectDescriptionType
00049 {
00060 AudioOutputDeviceType,
00061
00065 EffectType,
00066 AudioChannelType,
00067 SubtitleType,
00068
00079 AudioCaptureDeviceType
00080
00081
00082
00083
00084
00085
00086
00087 };
00088
00096 class PHONON_EXPORT ObjectDescriptionData : public QSharedData
00097 {
00098 public:
00103 bool operator==(const ObjectDescriptionData &otherDescription) const;
00104
00111 QString name() const;
00112
00120 QString description() const;
00121
00129 QVariant property(const char *name) const;
00130
00136 QList<QByteArray> propertyNames() const;
00137
00142 bool isValid() const;
00143
00150 int index() const;
00151
00152 static ObjectDescriptionData *fromIndex(ObjectDescriptionType type, int index);
00153
00154 ~ObjectDescriptionData();
00155
00156 ObjectDescriptionData(ObjectDescriptionPrivate * = 0);
00157 ObjectDescriptionData(int index, const QHash<QByteArray, QVariant> &properties);
00158
00159 protected:
00160 ObjectDescriptionPrivate *const d;
00161
00162 private:
00163 ObjectDescriptionData &operator=(const ObjectDescriptionData &rhs);
00164 };
00165
00166 template<ObjectDescriptionType T> class ObjectDescriptionModel;
00167
00179 template<ObjectDescriptionType T>
00180 class ObjectDescription
00181 {
00182 public:
00187 static inline ObjectDescription<T> fromIndex(int index) {
00188 return ObjectDescription<T>(QExplicitlySharedDataPointer<ObjectDescriptionData>(ObjectDescriptionData::fromIndex(T, index)));
00189 }
00190
00195 inline bool operator==(const ObjectDescription &otherDescription) const {
00196 return *d == *otherDescription.d;
00197 }
00198
00203 inline bool operator!=(const ObjectDescription &otherDescription) const {
00204 return !operator==(otherDescription);
00205 }
00206
00213 inline QString name() const { return d->name(); }
00214
00222 inline QString description() const { return d->description(); }
00223
00231 inline QVariant property(const char *name) const { return d->property(name); }
00232
00238 inline QList<QByteArray> propertyNames() const { return d->propertyNames(); }
00239
00244 inline bool isValid() const { return d->isValid(); }
00245
00252 inline int index() const { return d->index(); }
00253
00254 ObjectDescription() : d(new ObjectDescriptionData(0)) {}
00255 ObjectDescription(int index, const QHash<QByteArray, QVariant> &properties) : d(new ObjectDescriptionData(index, properties)) {}
00256
00257 protected:
00258 friend class ObjectDescriptionModel<T>;
00259 ObjectDescription(const QExplicitlySharedDataPointer<ObjectDescriptionData> &dd) : d(dd) {}
00260 QExplicitlySharedDataPointer<ObjectDescriptionData> d;
00261 };
00262
00263 template<ObjectDescriptionType T>
00264 inline QDebug operator<<(QDebug s, const ObjectDescription<T> &o)
00265 {
00266 return s << o.name();
00267 }
00268
00272 typedef ObjectDescription<AudioOutputDeviceType> AudioOutputDevice;
00276 #ifndef QT_NO_PHONON_AUDIOCAPTURE
00277 typedef ObjectDescription<AudioCaptureDeviceType> AudioCaptureDevice;
00278 #endif //QT_NO_PHONON_AUDIOCAPTURE
00279
00282
00286
00290 #ifndef QT_NO_PHONON_EFFECT
00291 typedef ObjectDescription<EffectType> EffectDescription;
00292 #endif //QT_NO_PHONON_EFFECT
00293
00297
00301
00305
00309
00310 #ifndef QT_NO_PHONON_MEDIACONTROLLER
00311 typedef ObjectDescription<AudioChannelType> AudioChannelDescription;
00312 typedef ObjectDescription<SubtitleType> SubtitleDescription;
00313 #endif //QT_NO_PHONON_MEDIACONTROLLER
00314
00315 }
00316
00317 QT_END_NAMESPACE
00318
00319 Q_DECLARE_METATYPE(Phonon::AudioOutputDevice)
00320 Q_DECLARE_METATYPE(QList<Phonon::AudioOutputDevice>)
00321
00322 #ifndef QT_NO_PHONON_AUDIOCAPTURE
00323 Q_DECLARE_METATYPE(Phonon::AudioCaptureDevice)
00324 Q_DECLARE_METATYPE(QList<Phonon::AudioCaptureDevice>)
00325 #endif //QT_NO_PHONON_AUDIOCAPTURE
00326
00327 #ifndef QT_NO_PHONON_EFFECT
00328 Q_DECLARE_METATYPE(QList<Phonon::EffectDescription>)
00329 Q_DECLARE_METATYPE(Phonon::EffectDescription)
00330 #endif //QT_NO_PHONON_EFFECT
00331
00332
00333 #ifndef QT_NO_PHONON_MEDIACONTROLLER
00334 Q_DECLARE_METATYPE(Phonon::AudioChannelDescription)
00335 Q_DECLARE_METATYPE(Phonon::SubtitleDescription)
00336 Q_DECLARE_METATYPE(QList<Phonon::AudioChannelDescription>)
00337 Q_DECLARE_METATYPE(QList<Phonon::SubtitleDescription>)
00338 #endif //QT_NO_PHONON_MEDIACONTROLLER
00339
00340 QT_END_HEADER
00341
00342 #endif // PHONON_OBJECTDESCRIPTION_H