1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Playback Data provider for playback view. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <QString> |
|
20 #include <QPixmap> |
|
21 |
|
22 #include "mpsongdata.h" |
|
23 #include "mptrace.h" |
|
24 |
|
25 |
|
26 const int KUndefined = -1; |
|
27 |
|
28 /*! |
|
29 \class MpSongData |
|
30 \brief Music Player song metadata. |
|
31 |
|
32 Song data provide acces to current playing song metadata |
|
33 */ |
|
34 |
|
35 /*! |
|
36 \fn void albumArtReady() |
|
37 |
|
38 This signal is albuma alrt is ready. |
|
39 */ |
|
40 |
|
41 /*! |
|
42 \fn void playbackInfoChanged() |
|
43 |
|
44 This signal is emitted when basic information is available |
|
45 */ |
|
46 |
|
47 /*! |
|
48 \fn void songDetailInfoChanged() |
|
49 |
|
50 This signal is emitted when detail information is available |
|
51 */ |
|
52 |
|
53 |
|
54 |
|
55 /*! |
|
56 Constructs a new MpSongData. |
|
57 */ |
|
58 MpSongData::MpSongData( QObject *parent ) |
|
59 : QObject( parent ), |
|
60 mTitle( NULL ), |
|
61 mAlbum( NULL ), |
|
62 mArtist( NULL ), |
|
63 mComposer( NULL), |
|
64 mGenre( NULL ), |
|
65 mYear( NULL ), |
|
66 mAlbumTrack( NULL ), |
|
67 mAlbumArt(), |
|
68 mReqId( KUndefined ) |
|
69 { |
|
70 //TX_ENTRY |
|
71 //TX_EXIT |
|
72 } |
|
73 |
|
74 /*! |
|
75 Constructs a new MpSongData. |
|
76 */ |
|
77 MpSongData::~MpSongData() |
|
78 { |
|
79 //TX_ENTRY |
|
80 //TX_EXIT |
|
81 } |
|
82 |
|
83 /*! |
|
84 Returns the song album art on \a pixmap. |
|
85 */ |
|
86 void MpSongData::albumArt( QPixmap& pixmap ) |
|
87 { |
|
88 //TX_ENTRY |
|
89 if ( !mAlbumArt.isNull() ) { |
|
90 pixmap = mAlbumArt; |
|
91 } |
|
92 else { |
|
93 pixmap = QPixmap(); |
|
94 } |
|
95 //TX_EXIT |
|
96 } |
|
97 |
|
98 |
|
99 /*! |
|
100 Returns the song title. |
|
101 */ |
|
102 QString MpSongData::title() const |
|
103 { |
|
104 //TX_LOG |
|
105 return mTitle; |
|
106 } |
|
107 |
|
108 /*! |
|
109 Returns the song album. |
|
110 */ |
|
111 QString MpSongData::album() const |
|
112 { |
|
113 //TX_LOG |
|
114 return mAlbum; |
|
115 } |
|
116 |
|
117 /*! |
|
118 Returns the song artist. |
|
119 */ |
|
120 QString MpSongData::artist() const |
|
121 { |
|
122 //TX_LOG |
|
123 return mArtist; |
|
124 } |
|
125 |
|
126 /*! |
|
127 Returns comment |
|
128 */ |
|
129 QString MpSongData::comment() const |
|
130 { |
|
131 //TX_LOG |
|
132 return mComment; |
|
133 } |
|
134 |
|
135 /*! |
|
136 Returns the song composer. |
|
137 */ |
|
138 QString MpSongData::composer() const |
|
139 { |
|
140 //TX_LOG |
|
141 return mComposer; |
|
142 } |
|
143 |
|
144 |
|
145 /*! |
|
146 Returns the song genre. |
|
147 */ |
|
148 QString MpSongData::genre() const |
|
149 { |
|
150 //TX_LOG |
|
151 return mGenre; |
|
152 } |
|
153 |
|
154 |
|
155 /*! |
|
156 Returns the album track. |
|
157 */ |
|
158 QString MpSongData::albumTrack() const |
|
159 { |
|
160 //TX_LOG |
|
161 return mAlbumTrack; |
|
162 } |
|
163 |
|
164 /*! |
|
165 Returns link |
|
166 */ |
|
167 QString MpSongData::link() const |
|
168 { |
|
169 //TX_LOG |
|
170 return mLink; |
|
171 } |
|
172 |
|
173 /*! |
|
174 Returns the release date. |
|
175 */ |
|
176 QString MpSongData::year() const |
|
177 { |
|
178 //TX_LOG |
|
179 return mYear; |
|
180 } |
|
181 |
|
182 |
|
183 /*! |
|
184 Sets the song \a title, returns true if the value is new. |
|
185 */ |
|
186 bool MpSongData::setTitle( const QString &title ) |
|
187 { |
|
188 //TX_ENTRY_ARGS( "title =" << title ) |
|
189 bool change = false; |
|
190 if ( title != mTitle ) { |
|
191 change = true; |
|
192 mTitle = title; |
|
193 } |
|
194 //TX_EXIT |
|
195 return change; |
|
196 } |
|
197 |
|
198 /*! |
|
199 Sets the song \a album, returns true if the value is new. |
|
200 */ |
|
201 bool MpSongData::setAlbum( const QString &album ) |
|
202 { |
|
203 //TX_ENTRY_ARGS( "album =" << album ) |
|
204 bool change = false; |
|
205 if ( album != mAlbum ) { |
|
206 change = true; |
|
207 mAlbum = album; |
|
208 } |
|
209 //TX_EXIT |
|
210 return change; |
|
211 } |
|
212 |
|
213 /*! |
|
214 Sets the song \a artist, returns true if the value is new. |
|
215 */ |
|
216 bool MpSongData::setArtist( const QString &artist ) |
|
217 { |
|
218 //TX_ENTRY_ARGS( "artist =" << artist ) |
|
219 bool change = false; |
|
220 if ( artist != mArtist ) { |
|
221 change = true; |
|
222 mArtist = artist; |
|
223 } |
|
224 //TX_EXIT |
|
225 return change; |
|
226 } |
|
227 |
|
228 /*! |
|
229 Sets the song \a comment, returns true if the value is new. |
|
230 */ |
|
231 bool MpSongData::setComment( const QString &comment) |
|
232 { |
|
233 //TX_ENTRY_ARGS( "comment =" << comment ) |
|
234 bool change = false; |
|
235 if ( comment != mComment ) { |
|
236 change = true; |
|
237 mComment = comment; |
|
238 } |
|
239 //TX_EXIT |
|
240 return change; |
|
241 } |
|
242 |
|
243 |
|
244 /*! |
|
245 Sets the song \a composer, returns true if the value is new. |
|
246 */ |
|
247 bool MpSongData::setComposer( const QString &composer ) |
|
248 { |
|
249 //TX_ENTRY_ARGS( "composer =" << composer ) |
|
250 bool change = false; |
|
251 if ( composer != mComposer ) { |
|
252 change = true; |
|
253 mComposer = composer; |
|
254 } |
|
255 //TX_EXIT |
|
256 return change; |
|
257 } |
|
258 |
|
259 /*! |
|
260 Sets the song \a genre, returns true if the value is new. |
|
261 */ |
|
262 bool MpSongData::setGenre( const QString &genre ) |
|
263 { |
|
264 //TX_ENTRY_ARGS( "genre =" << genre ) |
|
265 bool change = false; |
|
266 if ( genre != mGenre ) { |
|
267 change = true; |
|
268 mGenre = genre; |
|
269 } |
|
270 //TX_EXIT |
|
271 return change; |
|
272 } |
|
273 |
|
274 |
|
275 /*! |
|
276 Sets the song \a date, returns true if the value is new. |
|
277 */ |
|
278 bool MpSongData::setYear( int year ) |
|
279 { |
|
280 //TX_ENTRY_ARGS( "year =" << year ) |
|
281 bool change = false; |
|
282 if ( QString::number(year) != mYear ) { |
|
283 change = true; |
|
284 if ( year >= 0 && year < 9999 ) { |
|
285 mYear = QString::number(year); |
|
286 } |
|
287 } |
|
288 //TX_EXIT |
|
289 return change; |
|
290 } |
|
291 |
|
292 /*! |
|
293 Sets the \a album track, returns true if the value is new. |
|
294 */ |
|
295 bool MpSongData::setAlbumTrack( const QString &track ) |
|
296 { |
|
297 //TX_ENTRY_ARGS( "track =" << track ) |
|
298 bool change = false; |
|
299 if ( track != mAlbumTrack ) { |
|
300 change = true; |
|
301 mAlbumTrack = track; |
|
302 } |
|
303 //TX_EXIT |
|
304 return change; |
|
305 } |
|
306 |
|
307 /*! |
|
308 Sets the \a link |
|
309 */ |
|
310 void MpSongData::setLink( const QString &link ) |
|
311 { |
|
312 //TX_ENTRY_ARGS( "Link =" << link ) |
|
313 mLink = link; |
|
314 //TX_EXIT |
|
315 } |
|
316 |
|
317 /*! |
|
318 Sets the song \a albumArtUri. |
|
319 */ |
|
320 void MpSongData::setAlbumArtUri( const QString &albumArtUri) |
|
321 { |
|
322 //TX_ENTRY |
|
323 mAlbumArt = mDefaultAlbumArt; |
|
324 emit albumArtReady(); |
|
325 //TX_EXIT |
|
326 } |
|
327 |
|
328 |
|
329 /*! |
|
330 Slot to handle the album art thumb. |
|
331 */ |
|
332 void MpSongData::thumbnailReady( |
|
333 const QPixmap& pixmap, |
|
334 void *data, |
|
335 int id, |
|
336 int error ) |
|
337 { |
|
338 //TX_ENTRY |
|
339 Q_UNUSED( data ); |
|
340 |
|
341 //TX_EXIT |
|
342 } |
|
343 |
|
344 /*! |
|
345 Emit signal when playback information changed, such as artist, track name |
|
346 */ |
|
347 void MpSongData::commitPlaybackInfo() |
|
348 { |
|
349 //TX_ENTRY |
|
350 emit playbackInfoChanged(); |
|
351 //TX_EXIT |
|
352 } |
|
353 |
|
354 /*! |
|
355 Emit signal when song detail information changed |
|
356 */ |
|
357 void MpSongData::commitSongDetailInfo() |
|
358 { |
|
359 //TX_ENTRY |
|
360 emit songDetailInfoChanged(); |
|
361 //TX_EXIT |
|
362 } |
|
363 |
|
364 QString MpSongData::albumArtBase64() const |
|
365 { |
|
366 // Converts the current album art pixmap to a base64 string, and return the string. |
|
367 // TX_ENTRY |
|
368 // QByteArray array; |
|
369 // QBuffer buffer(&array); |
|
370 // buffer.open(QIODevice::WriteOnly); |
|
371 // mAlbumArt.save(&buffer, "PNG"); // writes pixmap into bytes in PNG format |
|
372 // buffer.close(); |
|
373 // QByteArray base64 = array.toBase64(); |
|
374 // TX_EXIT |
|
375 // return base64.constData(); |
|
376 return QString(""); |
|
377 } |
|
378 |
|
379 void MpSongData::removeAlbumArtFile() const |
|
380 { |
|
381 |
|
382 } |
|