1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "qphononmetadataprovider.h" |
|
43 |
|
44 #include <QtCore/qstringlist.h> |
|
45 |
|
46 #include <QDebug> |
|
47 |
|
48 QPhononMetaDataProvider::QPhononMetaDataProvider(Phonon::MediaObject *session, QObject *parent) |
|
49 :QMetaDataControl(parent), m_session(session), m_metaDataAvailable(false) |
|
50 { |
|
51 connect(m_session, SIGNAL(metaDataChanged()), SLOT(updateTags())); |
|
52 |
|
53 m_keysMap["TITLE"] = QtMedia::Title; |
|
54 m_keysMap["ALBUM"] = QtMedia::AlbumTitle; |
|
55 m_keysMap["TRACKNUMBER"] = QtMedia::TrackNumber; |
|
56 m_keysMap["ARTIST"] = QtMedia::AlbumArtist; |
|
57 m_keysMap["PERFORMER"] = QtMedia::ContributingArtist; |
|
58 m_keysMap["COPYRIGHT"] = QtMedia::Copyright; |
|
59 m_keysMap["DESCRIPTION"] = QtMedia::Description; |
|
60 m_keysMap["GENRE"] = QtMedia::Genre; |
|
61 m_keysMap["DATE"] = QtMedia::Date; |
|
62 } |
|
63 |
|
64 QPhononMetaDataProvider::~QPhononMetaDataProvider() |
|
65 { |
|
66 } |
|
67 |
|
68 bool QPhononMetaDataProvider::isMetaDataAvailable() const |
|
69 { |
|
70 return !m_session->metaData().isEmpty(); |
|
71 } |
|
72 |
|
73 bool QPhononMetaDataProvider::isWritable() const |
|
74 { |
|
75 return false; |
|
76 } |
|
77 |
|
78 QVariant QPhononMetaDataProvider::metaData(QtMedia::MetaData key) const |
|
79 { |
|
80 switch (key) { |
|
81 case QtMedia::AlbumArtist: |
|
82 return m_session->metaData(Phonon::ArtistMetaData); |
|
83 case QtMedia::ContributingArtist: |
|
84 return m_session->metaData("PERFORMER"); |
|
85 case QtMedia::AlbumTitle: |
|
86 return m_session->metaData(Phonon::AlbumMetaData); |
|
87 case QtMedia::Title: |
|
88 return m_session->metaData(Phonon::TitleMetaData); |
|
89 case QtMedia::Date: |
|
90 return m_session->metaData(Phonon::DateMetaData); |
|
91 case QtMedia::TrackNumber: |
|
92 return m_session->metaData(Phonon::TracknumberMetaData); |
|
93 case QtMedia::Description: |
|
94 return m_session->metaData(Phonon::DescriptionMetaData); |
|
95 default: |
|
96 return QVariant(); |
|
97 } |
|
98 } |
|
99 |
|
100 void QPhononMetaDataProvider::setMetaData(QtMedia::MetaData key, QVariant const &value) |
|
101 { |
|
102 Q_UNUSED(key); |
|
103 Q_UNUSED(value); |
|
104 } |
|
105 |
|
106 QList<QtMedia::MetaData> QPhononMetaDataProvider::availableMetaData() const |
|
107 { |
|
108 QList<QtMedia::MetaData> res; |
|
109 QMap<QString,QString> metaData = m_session->metaData(); |
|
110 QMapIterator<QString, QString> i(metaData); |
|
111 while (i.hasNext()) { |
|
112 i.next(); |
|
113 QtMedia::MetaData tag = m_keysMap.value(i.key(), QtMedia::MetaData(-1)); |
|
114 |
|
115 if (tag != -1) |
|
116 res.append(tag); |
|
117 } |
|
118 |
|
119 return res; |
|
120 } |
|
121 |
|
122 QVariant QPhononMetaDataProvider::extendedMetaData(const QString &key) const |
|
123 { |
|
124 return m_session->metaData(key); |
|
125 } |
|
126 |
|
127 void QPhononMetaDataProvider::setExtendedMetaData(const QString &key, QVariant const &value) |
|
128 { |
|
129 Q_UNUSED(key); |
|
130 Q_UNUSED(value); |
|
131 } |
|
132 |
|
133 QStringList QPhononMetaDataProvider::availableExtendedMetaData() const |
|
134 { |
|
135 return m_session->metaData().keys(); |
|
136 } |
|
137 |
|
138 void QPhononMetaDataProvider::updateTags() |
|
139 { |
|
140 emit metaDataChanged(); |
|
141 if (isMetaDataAvailable() != m_metaDataAvailable) { |
|
142 m_metaDataAvailable = !m_metaDataAvailable; |
|
143 emit metaDataAvailableChanged(m_metaDataAvailable); |
|
144 } |
|
145 } |
|