9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Playback Data provider for playback view. |
14 * Description: Detailed song data provider for Details View. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
|
19 #include <QString> |
|
20 #include <QPixmap> |
|
21 #include <QPainter> |
|
22 #include <QBuffer> |
|
23 #include <QPixmap> |
|
24 #include <QTime> |
|
25 #include <hbicon.h> |
|
26 #include <QIcon> |
|
27 #include <QFile> |
|
28 |
|
29 #include <thumbnailmanager_qt.h> |
18 #include <thumbnailmanager_qt.h> |
30 #include <thumbnaildata.h> |
|
31 #include <thumbnailobjectsource.h> |
|
32 |
19 |
33 #include "mpsongdata.h" |
20 #include "mpsongdata.h" |
34 #include "mptrace.h" |
21 #include "mpsongdata_p.h" |
35 |
|
36 const int KUndefined = -1; |
|
37 |
22 |
38 /*! |
23 /*! |
39 \class MpSongData |
24 \class MpSongData |
40 \brief Music Player song metadata. |
25 \brief Music Player song metadata. |
41 |
26 |
42 Song data provide acces to current playing song metadata |
27 Song data provide access to song metadata. |
43 */ |
28 */ |
44 |
29 |
45 /*! |
30 /*! |
46 \fn void albumArtReady() |
31 \fn void albumArtReady() |
47 |
32 |
48 This signal is albuma alrt is ready. |
33 This signal is emitted album art is ready. |
49 */ |
34 */ |
50 |
35 |
51 /*! |
36 /*! |
52 \fn void playbackInfoChanged() |
37 \fn void playbackInfoChanged() |
53 |
38 |
54 This signal is emitted when basic information is available |
39 This signal is emitted when basic information is available. |
55 */ |
40 */ |
56 |
41 |
57 /*! |
42 /*! |
58 \fn void songDetailInfoChanged() |
43 \fn void songDetailInfoChanged() |
59 |
44 |
60 This signal is emitted when detail information is available |
45 This signal is emitted when detail information is available. |
61 */ |
46 */ |
62 |
47 |
63 |
48 |
64 |
49 /*! |
65 /*! |
50 Constructs a new song data. |
66 Constructs a new MpSongData. |
|
67 */ |
51 */ |
68 MpSongData::MpSongData( QObject *parent ) |
52 MpSongData::MpSongData( QObject *parent ) |
69 : QObject( parent ), |
53 : QObject( parent ) |
70 mAlbumArt(), |
54 { |
71 mReqId( KUndefined ) |
|
72 { |
|
73 TX_ENTRY |
|
74 mThumbnailManager = new ThumbnailManager( this ); |
55 mThumbnailManager = new ThumbnailManager( this ); |
75 mThumbnailManager->setQualityPreference( ThumbnailManager::OptimizeForQuality ); |
56 mThumbnailManager->setQualityPreference( ThumbnailManager::OptimizeForQuality ); |
76 mThumbnailManager->setThumbnailSize( ThumbnailManager::ThumbnailMedium ); |
57 mThumbnailManager->setThumbnailSize( ThumbnailManager::ThumbnailMedium ); |
77 QObject::connect( mThumbnailManager, SIGNAL( thumbnailReady( QPixmap , void * , int , int ) ), |
58 connect( mThumbnailManager, SIGNAL( thumbnailReady(QPixmap, void *, int, int) ), |
78 this, SLOT( thumbnailReady( QPixmap , void * , int , int ) ) ); |
59 this, SLOT( thumbnailReady(QPixmap, void *, int, int) ) ); |
79 |
60 d_ptr = new MpSongDataPrivate(this, mThumbnailManager); |
80 mDefaultAlbumArt = new HbIcon( "qtg_large_music_album" ); |
61 } |
81 TX_EXIT |
62 |
82 } |
63 /*! |
83 |
64 Destructs the song data. |
84 /*! |
|
85 Constructs a new MpSongData. |
|
86 */ |
65 */ |
87 MpSongData::~MpSongData() |
66 MpSongData::~MpSongData() |
88 { |
67 { |
89 TX_ENTRY |
68 delete mThumbnailManager; |
90 if( mThumbnailManager ) { |
69 delete d_ptr; |
91 delete mThumbnailManager; |
70 } |
92 } |
71 |
93 removeAlbumArtFile(); // TODO Remove when base64 is working |
72 /*! |
94 TX_EXIT |
73 Returns the song title. |
95 } |
74 */ |
96 |
75 QString MpSongData::title() const |
97 /*! |
76 { |
98 Returns the song album art on \a pixmap. |
77 return d_ptr->title(); |
99 */ |
78 } |
|
79 |
|
80 /*! |
|
81 Returns the song album. |
|
82 */ |
|
83 QString MpSongData::album() const |
|
84 { |
|
85 return d_ptr->album(); |
|
86 } |
|
87 |
|
88 /*! |
|
89 Returns the song artist. |
|
90 */ |
|
91 QString MpSongData::artist() const |
|
92 { |
|
93 return d_ptr->artist(); |
|
94 } |
|
95 |
|
96 /*! |
|
97 Returns comment |
|
98 */ |
|
99 QString MpSongData::comment() const |
|
100 { |
|
101 return d_ptr->comment(); |
|
102 } |
|
103 |
|
104 /*! |
|
105 Returns the song album art on \a icon. |
|
106 */ |
100 void MpSongData::albumArt( HbIcon& icon ) const |
107 void MpSongData::albumArt( HbIcon& icon ) const |
101 { |
108 { |
102 TX_ENTRY |
109 d_ptr->albumArt(icon); |
103 if ( !mAlbumArt || mAlbumArt->isNull() ) { |
110 } |
104 TX_LOG_ARGS( "Album art is NULL." ); |
111 |
105 icon = HbIcon(); |
112 /*! |
106 } else { |
113 Returns the release date. |
107 TX_LOG_ARGS( "Album art is not NULL." ); |
114 */ |
108 icon = *mAlbumArt ; |
115 QString MpSongData::year() const |
109 } |
116 { |
110 TX_EXIT |
117 return d_ptr->year(); |
111 } |
118 } |
112 |
119 |
113 |
120 /*! |
114 /*! |
121 Returns the song genre. |
115 Returns the song title. |
122 */ |
116 */ |
123 QString MpSongData::genre() const |
117 QString MpSongData::title() const |
124 { |
118 { |
125 return d_ptr->genre(); |
119 TX_LOG |
|
120 return mTitle; |
|
121 } |
|
122 |
|
123 /*! |
|
124 Returns the song album. |
|
125 */ |
|
126 QString MpSongData::album() const |
|
127 { |
|
128 TX_LOG |
|
129 return mAlbum; |
|
130 } |
|
131 |
|
132 /*! |
|
133 Returns the song artist. |
|
134 */ |
|
135 QString MpSongData::artist() const |
|
136 { |
|
137 TX_LOG |
|
138 return mArtist; |
|
139 } |
|
140 |
|
141 /*! |
|
142 Returns comment |
|
143 */ |
|
144 QString MpSongData::comment() const |
|
145 { |
|
146 TX_LOG |
|
147 return mComment; |
|
148 } |
126 } |
149 |
127 |
150 /*! |
128 /*! |
151 Returns the song composer. |
129 Returns the song composer. |
152 */ |
130 */ |
153 QString MpSongData::composer() const |
131 QString MpSongData::composer() const |
154 { |
132 { |
155 TX_LOG |
133 return d_ptr->composer(); |
156 return mComposer; |
134 } |
157 } |
|
158 |
|
159 |
|
160 /*! |
|
161 Returns the song genre. |
|
162 */ |
|
163 QString MpSongData::genre() const |
|
164 { |
|
165 TX_LOG |
|
166 return mGenre; |
|
167 } |
|
168 |
|
169 |
135 |
170 /*! |
136 /*! |
171 Returns the album track. |
137 Returns the album track. |
172 */ |
138 */ |
173 QString MpSongData::albumTrack() const |
139 QString MpSongData::albumTrack() const |
174 { |
140 { |
175 TX_LOG |
141 return d_ptr->albumTrack(); |
176 return mAlbumTrack; |
|
177 } |
142 } |
178 |
143 |
179 /*! |
144 /*! |
180 Returns link |
145 Returns link |
181 */ |
146 */ |
182 QString MpSongData::link() const |
147 QString MpSongData::link() const |
183 { |
148 { |
184 TX_LOG |
149 return d_ptr->link(); |
185 return mLink; |
150 } |
186 } |
151 |
187 |
|
188 /*! |
|
189 Returns the release date. |
|
190 */ |
|
191 QString MpSongData::year() const |
|
192 { |
|
193 TX_LOG |
|
194 return mYear; |
|
195 } |
|
196 |
152 |
197 /*! |
153 /*! |
198 Returns the file name |
154 Returns the file name |
199 */ |
155 */ |
200 QString MpSongData::fileName() const |
156 QString MpSongData::fileName() const |
201 { |
157 { |
202 TX_LOG |
158 return d_ptr->fileName(); |
203 return mFileName; |
|
204 } |
159 } |
205 |
160 |
206 /*! |
161 /*! |
207 Returns the MIME type |
162 Returns the MIME type |
208 */ |
163 */ |
209 QString MpSongData::mimeType() const |
164 QString MpSongData::mimeType() const |
210 { |
165 { |
211 TX_LOG |
166 return d_ptr->mimeType(); |
212 return mMimeType; |
|
213 } |
167 } |
214 |
168 |
215 /*! |
169 /*! |
216 Returns the duration |
170 Returns the duration |
217 */ |
171 */ |
218 QString MpSongData::duration() const |
172 QString MpSongData::duration() const |
219 { |
173 { |
220 TX_LOG |
174 return d_ptr->duration(); |
221 return mDuration; |
|
222 } |
175 } |
223 |
176 |
224 /*! |
177 /*! |
225 Returns the bit rate |
178 Returns the bit rate |
226 */ |
179 */ |
227 QString MpSongData::bitRate() const |
180 QString MpSongData::bitRate() const |
228 { |
181 { |
229 TX_LOG |
182 return d_ptr->bitRate(); |
230 return mBitRate; |
|
231 } |
183 } |
232 |
184 |
233 /*! |
185 /*! |
234 Returns the sampling rate |
186 Returns the sampling rate |
235 */ |
187 */ |
236 QString MpSongData::sampleRate() const |
188 QString MpSongData::sampleRate() const |
237 { |
189 { |
238 TX_LOG |
190 return d_ptr->sampleRate(); |
239 return mSampleRate; |
|
240 } |
191 } |
241 |
192 |
242 /*! |
193 /*! |
243 Returns the size |
194 Returns the size |
244 */ |
195 */ |
245 QString MpSongData::size() const |
196 QString MpSongData::size() const |
246 { |
197 { |
247 TX_LOG |
198 return d_ptr->size(); |
248 return mSize; |
199 } |
249 } |
200 |
250 |
201 /*! |
251 /*! |
202 Returns the modified time |
252 Returns the size |
203 */ |
253 */ |
|
254 QString MpSongData::modified() const |
204 QString MpSongData::modified() const |
255 { |
205 { |
256 TX_LOG |
206 return d_ptr->modified(); |
257 return mModified; |
207 } |
258 } |
208 |
259 |
209 /*! |
260 /*! |
210 Returns the copyright |
261 Returns the copy right |
211 */ |
262 */ |
|
263 QString MpSongData::copyright() const |
212 QString MpSongData::copyright() const |
264 { |
213 { |
265 TX_LOG |
214 return d_ptr->copyright(); |
266 return mCopyright; |
|
267 } |
215 } |
268 |
216 |
269 /*! |
217 /*! |
270 Returns the music URL |
218 Returns the music URL |
271 */ |
219 */ |
272 QString MpSongData::musicURL() const |
220 QString MpSongData::musicURL() const |
273 { |
221 { |
274 TX_LOG |
222 return d_ptr->musicURL(); |
275 return mMusicURL; |
|
276 } |
223 } |
277 |
224 |
278 /*! |
225 /*! |
279 Returns whether the song is protected |
226 Returns whether the song is protected |
280 */ |
227 */ |
281 bool MpSongData::isDrmProtected() const |
228 bool MpSongData::isDrmProtected() const |
282 { |
229 { |
283 TX_LOG |
230 return d_ptr->isDrmProtected(); |
284 return mDrmProtected; |
231 } |
285 } |
232 |
286 |
233 |
287 /*! |
234 /*! |
288 Sets the song \a title, returns true if the value is new. |
235 Retrieve the album art in base64 encoding suitable for inline HTML display for sharing player. |
289 */ |
236 */ |
290 bool MpSongData::setTitle( const QString &title ) |
237 QString MpSongData::albumArtBase64() const |
291 { |
238 { |
292 TX_ENTRY_ARGS( "title =" << title ) |
239 return d_ptr->albumArtBase64(); |
293 bool change = false; |
240 } |
294 if ( title != mTitle ) { |
241 |
295 change = true; |
242 /*! |
296 mTitle = title; |
243 Delete temporary album art file. |
297 } |
244 */ |
298 TX_EXIT |
245 void MpSongData::removeAlbumArtFile() const |
299 return change; |
246 { |
300 } |
247 d_ptr->removeAlbumArtFile(); |
301 |
|
302 /*! |
|
303 Sets the song \a album, returns true if the value is new. |
|
304 */ |
|
305 bool MpSongData::setAlbum( const QString &album ) |
|
306 { |
|
307 TX_ENTRY_ARGS( "album =" << album ) |
|
308 bool change = false; |
|
309 if ( album != mAlbum ) { |
|
310 change = true; |
|
311 mAlbum = album; |
|
312 } |
|
313 TX_EXIT |
|
314 return change; |
|
315 } |
|
316 |
|
317 /*! |
|
318 Sets the song \a artist, returns true if the value is new. |
|
319 */ |
|
320 bool MpSongData::setArtist( const QString &artist ) |
|
321 { |
|
322 TX_ENTRY_ARGS( "artist =" << artist ) |
|
323 bool change = false; |
|
324 if ( artist != mArtist ) { |
|
325 change = true; |
|
326 mArtist = artist; |
|
327 } |
|
328 TX_EXIT |
|
329 return change; |
|
330 } |
|
331 |
|
332 /*! |
|
333 Sets the song \a comment, returns true if the value is new. |
|
334 */ |
|
335 bool MpSongData::setComment( const QString &comment) |
|
336 { |
|
337 TX_ENTRY_ARGS( "comment =" << comment ) |
|
338 bool change = false; |
|
339 if ( comment != mComment ) { |
|
340 change = true; |
|
341 mComment = comment; |
|
342 } |
|
343 TX_EXIT |
|
344 return change; |
|
345 } |
|
346 |
|
347 |
|
348 /*! |
|
349 Sets the song \a composer, returns true if the value is new. |
|
350 */ |
|
351 bool MpSongData::setComposer( const QString &composer ) |
|
352 { |
|
353 TX_ENTRY_ARGS( "composer =" << composer ) |
|
354 bool change = false; |
|
355 if ( composer != mComposer ) { |
|
356 change = true; |
|
357 mComposer = composer; |
|
358 } |
|
359 TX_EXIT |
|
360 return change; |
|
361 } |
|
362 |
|
363 /*! |
|
364 Sets the song \a genre, returns true if the value is new. |
|
365 */ |
|
366 bool MpSongData::setGenre( const QString &genre ) |
|
367 { |
|
368 TX_ENTRY_ARGS( "genre =" << genre ) |
|
369 bool change = false; |
|
370 if ( genre != mGenre ) { |
|
371 change = true; |
|
372 mGenre = genre; |
|
373 } |
|
374 TX_EXIT |
|
375 return change; |
|
376 } |
|
377 |
|
378 |
|
379 /*! |
|
380 Sets the song \a date, returns true if the value is new. |
|
381 */ |
|
382 bool MpSongData::setYear( int year ) |
|
383 { |
|
384 TX_ENTRY_ARGS( "year =" << year ) |
|
385 bool change = false; |
|
386 if ( QString::number(year) != mYear ) { |
|
387 change = true; |
|
388 if ( year >= 0 && year < 9999 ) { |
|
389 mYear = QString::number(year); |
|
390 } else { |
|
391 mYear = QString(); |
|
392 } |
|
393 } |
|
394 TX_EXIT |
|
395 return change; |
|
396 } |
|
397 |
|
398 /*! |
|
399 Sets the \a album track, returns true if the value is new. |
|
400 */ |
|
401 bool MpSongData::setAlbumTrack( const QString &track ) |
|
402 { |
|
403 TX_ENTRY_ARGS( "track =" << track ) |
|
404 bool change = false; |
|
405 if ( track != mAlbumTrack ) { |
|
406 change = true; |
|
407 mAlbumTrack = track; |
|
408 } |
|
409 TX_EXIT |
|
410 return change; |
|
411 } |
248 } |
412 |
249 |
413 /*! |
250 /*! |
414 Sets the \a link |
251 Sets the \a link |
415 */ |
252 */ |
416 void MpSongData::setLink( const QString &link ) |
253 void MpSongData::setLink( const QString &link ) |
417 { |
254 { |
418 TX_ENTRY_ARGS( "Link =" << link ) |
255 d_ptr->setLink(link); |
419 mLink = link; |
256 } |
420 TX_EXIT |
257 |
421 } |
258 /*! |
422 |
259 Sets the media \a media from the MPX framework. |
423 /*! |
260 Internal usage only from MpEngine. |
424 Sets the song \a albumArtUri. |
261 */ |
425 */ |
262 void MpSongData::setMpxMedia( const CMPXMedia& media ) |
426 void MpSongData::setAlbumArtUri( const QString &albumArtUri) |
263 { |
427 { |
264 d_ptr->setMpxMedia(media); |
428 TX_ENTRY_ARGS( "albumArtUri = " << albumArtUri ) |
265 } |
429 if ( !albumArtUri.isEmpty() ) { |
266 |
430 TX_LOG_ARGS( "There is album art" ); |
267 /*! |
431 bool ok = true; |
268 Returns the reserved length. |
432 if ( mReqId != KUndefined ) { |
269 */ |
433 // There is already an outstanding request. Cancel it first. |
270 int MpSongData::reservedLength() const |
434 bool ok = mThumbnailManager->cancelRequest( mReqId ); |
271 { |
435 } |
272 return d_ptr->reservedLength(); |
436 if ( ok ) { |
|
437 mReqId = mThumbnailManager->getThumbnail( albumArtUri ); |
|
438 if ( mReqId == KUndefined ) { |
|
439 // Request failed. Set default album art. |
|
440 mAlbumArt = mDefaultAlbumArt; |
|
441 emit albumArtReady(); |
|
442 } |
|
443 } |
|
444 } |
|
445 else { |
|
446 // No album art uri. Set default album art. |
|
447 TX_LOG_ARGS( "There is No album art" ); |
|
448 mAlbumArt = mDefaultAlbumArt; |
|
449 emit albumArtReady(); |
|
450 } |
|
451 TX_EXIT |
|
452 } |
|
453 |
|
454 /*! |
|
455 Sets the \a file name |
|
456 */ |
|
457 bool MpSongData::setFileName( const QString &fileName ) |
|
458 { |
|
459 TX_ENTRY_ARGS( "File name =" << fileName ) |
|
460 bool change = false; |
|
461 if ( fileName != mFileName ) { |
|
462 change = true; |
|
463 mFileName = fileName; |
|
464 } |
|
465 TX_EXIT |
|
466 return change; |
|
467 } |
|
468 |
|
469 /*! |
|
470 Sets the \a MIME type |
|
471 */ |
|
472 bool MpSongData::setMimeType( const QString &mimeType ) |
|
473 { |
|
474 TX_ENTRY_ARGS( "Mime =" << mimeType ) |
|
475 bool change = false; |
|
476 if ( mimeType != mMimeType ) { |
|
477 change = true; |
|
478 mMimeType = mimeType; |
|
479 } |
|
480 TX_EXIT |
|
481 return change; |
|
482 } |
|
483 |
|
484 /*! |
|
485 Sets the \a duration |
|
486 */ |
|
487 bool MpSongData::setDuration( int duration ) |
|
488 { |
|
489 TX_ENTRY_ARGS( "Duration =" << duration ) |
|
490 bool change = false; |
|
491 QString timeFormatOne("%1:%2:%3"); |
|
492 QString timeFormatTwo("%1:%2"); |
|
493 if ( QString::number( duration ) != mDuration ) { |
|
494 change = true; |
|
495 if ( duration >= 3600 ) { |
|
496 // more than one hours |
|
497 QString hourStr, minStr, secStr; |
|
498 int hour = duration / 3600; |
|
499 int min = duration % 3600 / 60; |
|
500 int sec = duration % 3600 % 60; |
|
501 |
|
502 hourStr = hour >= 10 ? QString::number( hour ) : QString::number( hour ).prepend( "0" ); |
|
503 minStr = min >= 10 ? QString::number( min ) : QString::number( min ).prepend( "0" ); |
|
504 secStr = sec >= 10 ? QString::number( sec ) : QString::number( sec ).prepend( "0" ); |
|
505 mDuration = timeFormatOne.arg( hourStr ).arg( minStr ).arg( secStr ); |
|
506 } else if ( duration >= 60 && duration < 3600 ) { |
|
507 // more than one min && less than one hour |
|
508 QString minStr, secStr; |
|
509 int min = duration / 60; |
|
510 int sec = duration % 60; |
|
511 |
|
512 minStr = min >= 10 ? QString::number( min ) : QString::number( min ).prepend( "0" ); |
|
513 secStr = sec >= 10 ? QString::number( sec ) : QString::number( sec ).prepend( "0" ); |
|
514 mDuration = timeFormatTwo.arg( minStr ).arg( secStr ); |
|
515 } else if ( duration > 0 && duration < 60 ) { |
|
516 QString secStr; |
|
517 secStr = duration >= 10 ? QString::number( duration ) : QString::number( duration ).prepend( "0" ); |
|
518 mDuration = secStr; |
|
519 } else { |
|
520 mDuration = QString(); |
|
521 } |
|
522 } |
|
523 TX_EXIT |
|
524 return change; |
|
525 } |
|
526 |
|
527 /*! |
|
528 Sets bit rate |
|
529 */ |
|
530 bool MpSongData::setBitRate( int bitRate) |
|
531 { |
|
532 TX_ENTRY_ARGS( "Bit rate =" << bitRate ) |
|
533 bool change = false; |
|
534 if ( QString::number( bitRate ) != mBitRate ) { |
|
535 change = true; |
|
536 if ( bitRate > 0 ) { |
|
537 mBitRate = QString::number( bitRate / 1000 ); |
|
538 } else { |
|
539 mBitRate = QString(); |
|
540 } |
|
541 } |
|
542 TX_EXIT |
|
543 return change; |
|
544 } |
|
545 |
|
546 /*! |
|
547 Sets sample rate |
|
548 */ |
|
549 bool MpSongData::setSampleRate( int sampleRate ) |
|
550 { |
|
551 TX_ENTRY_ARGS( "Sample rate =" << sampleRate ) |
|
552 bool change = false; |
|
553 if ( QString::number( sampleRate ) != mSampleRate ) { |
|
554 change = true; |
|
555 if ( sampleRate > 0 ) { |
|
556 mSampleRate = QString::number( sampleRate ); |
|
557 } else { |
|
558 mSampleRate = QString(); |
|
559 } |
|
560 } |
|
561 TX_EXIT |
|
562 return change; |
|
563 } |
|
564 |
|
565 /*! |
|
566 Sets the \a size |
|
567 */ |
|
568 bool MpSongData::setSize( int size ) |
|
569 { |
|
570 TX_ENTRY_ARGS( "Size =" << size ) |
|
571 bool change = false; |
|
572 if ( QString::number( size ) != mSize ) { |
|
573 change = true; |
|
574 mSize = QString::number( size / 1000 ); |
|
575 } |
|
576 TX_EXIT |
|
577 return change; |
|
578 } |
|
579 |
|
580 /*! |
|
581 Sets the \a modification information |
|
582 */ |
|
583 bool MpSongData::setModified( const QString &modified ) |
|
584 { |
|
585 TX_ENTRY_ARGS( "Modified =" << modified ) |
|
586 bool change = false; |
|
587 if ( modified != mModified ) { |
|
588 change = true; |
|
589 mModified = modified; |
|
590 } |
|
591 TX_EXIT |
|
592 return change; |
|
593 } |
|
594 |
|
595 /*! |
|
596 Sets the \a copyright information |
|
597 */ |
|
598 bool MpSongData::setCopyright( const QString ©right ) |
|
599 { |
|
600 TX_ENTRY_ARGS( "Copyright =" << copyright ) |
|
601 bool change = false; |
|
602 if ( copyright != mCopyright ) { |
|
603 change = true; |
|
604 mCopyright = copyright; |
|
605 } |
|
606 TX_EXIT |
|
607 return change; |
|
608 } |
|
609 |
|
610 /*! |
|
611 Sets the \a music URL |
|
612 */ |
|
613 bool MpSongData::setMusicURL( const QString &musicURL ) |
|
614 { |
|
615 TX_ENTRY_ARGS( "Music URL =" << musicURL ) |
|
616 bool change = false; |
|
617 if ( musicURL != mMusicURL ) { |
|
618 change = true; |
|
619 mMusicURL = musicURL; |
|
620 } |
|
621 TX_EXIT |
|
622 return change; |
|
623 } |
|
624 |
|
625 /*! |
|
626 Set whether the song is DRM protected |
|
627 */ |
|
628 bool MpSongData::setDrmProtected( bool drmProtected ) |
|
629 { |
|
630 TX_ENTRY_ARGS( "DRM protected =" << drmProtected ) |
|
631 bool change = false; |
|
632 if ( drmProtected != mDrmProtected ) { |
|
633 change = true; |
|
634 mDrmProtected = drmProtected; |
|
635 } |
|
636 TX_EXIT |
|
637 return change; |
|
638 } |
273 } |
639 |
274 |
640 /*! |
275 /*! |
641 Slot to handle the album art thumb. |
276 Slot to handle the album art thumb. |
642 */ |
277 */ |
643 void MpSongData::thumbnailReady( |
278 void MpSongData::thumbnailReady( QPixmap pixmap, void *data, int id, int error ) |
644 const QPixmap& pixmap, |
279 { |
645 void *data, |
280 d_ptr->thumbnailReady(pixmap, data, id, error); |
646 int id, |
281 } |
647 int error ) |
282 |
648 { |
|
649 TX_ENTRY |
|
650 Q_UNUSED( data ); |
|
651 if ( error == 0 && mReqId == id ) { |
|
652 QIcon qicon; |
|
653 QPixmap mCompositePixmap; |
|
654 mReqId = KUndefined; |
|
655 |
|
656 mCompositePixmap = QPixmap( 360, 360 ); |
|
657 mCompositePixmap.fill( Qt::transparent ); |
|
658 QPainter painter(&mCompositePixmap); |
|
659 painter.setCompositionMode(QPainter::CompositionMode_Clear); |
|
660 painter.setCompositionMode(QPainter::CompositionMode_SourceOver); |
|
661 painter.fillRect(mCompositePixmap.rect(), Qt::transparent); |
|
662 painter.drawPixmap(QRect(0, 0,360,360), pixmap); |
|
663 |
|
664 if ( !mCompositePixmap.isNull() ) { |
|
665 qicon = QIcon( mCompositePixmap ); |
|
666 } |
|
667 else { |
|
668 qicon = QIcon( pixmap ); |
|
669 } |
|
670 |
|
671 if ( mAlbumArt == mDefaultAlbumArt ) { |
|
672 TX_LOG_ARGS( "Album art is default album art." ) |
|
673 delete mAlbumArt; |
|
674 mAlbumArt = new HbIcon(qicon); |
|
675 mDefaultAlbumArt = new HbIcon( "qtg_large_music_album" ); |
|
676 } else { |
|
677 TX_LOG_ARGS( "Album art is NOT default album art." ) |
|
678 delete mAlbumArt; |
|
679 mAlbumArt = new HbIcon(qicon); |
|
680 } |
|
681 |
|
682 emit albumArtReady(); |
|
683 } |
|
684 else { |
|
685 mReqId = KUndefined; |
|
686 mAlbumArt = mDefaultAlbumArt; |
|
687 emit albumArtReady(); |
|
688 } |
|
689 |
|
690 TX_EXIT |
|
691 } |
|
692 |
|
693 /*! |
|
694 Emit signal when playback information changed, such as artist, track name |
|
695 */ |
|
696 void MpSongData::commitPlaybackInfo() |
|
697 { |
|
698 TX_ENTRY |
|
699 emit playbackInfoChanged(); |
|
700 TX_EXIT |
|
701 } |
|
702 |
|
703 /*! |
|
704 Emit signal when song detail information changed |
|
705 */ |
|
706 void MpSongData::commitSongDetailInfo() |
|
707 { |
|
708 TX_ENTRY |
|
709 emit songDetailInfoChanged(); |
|
710 TX_EXIT |
|
711 } |
|
712 |
|
713 /*! |
|
714 Retrieve the album art in base64 encoding suitable for inline HTML display for sharing player. |
|
715 */ |
|
716 QString MpSongData::albumArtBase64() const |
|
717 { |
|
718 /* |
|
719 // Converts the current album art icon to a base64 string, and return the string. |
|
720 TX_LOG |
|
721 if ( mAlbumArt->isNull() ) { |
|
722 TX_ENTRY_ARGS( "MpSongData: album art isNull" ) |
|
723 return "nullimgcraptoberemoved"; |
|
724 } |
|
725 TX_ENTRY_ARGS("MpSongData: album art exists"); |
|
726 QByteArray array; |
|
727 QBuffer buffer( &array ); |
|
728 buffer.open( QIODevice::WriteOnly ); |
|
729 mAlbumArt->pixmap().save( &buffer, "PNG" ); // writes pixmap into bytes in PNG format |
|
730 buffer.close(); |
|
731 QString result = array.toBase64().constData(); |
|
732 TX_ENTRY_ARGS("MpSongData: album art base64 length: " << result.length()); |
|
733 return result; |
|
734 */ |
|
735 // TODO: this is temporary solution until base64 defect in QT is fixed. |
|
736 TX_LOG |
|
737 QByteArray array; |
|
738 |
|
739 // Remove old album art in case new one cannot be written. |
|
740 removeAlbumArtFile(); |
|
741 |
|
742 QString sTimeStamp = QTime::currentTime().toString( "hhmmsszzz" ); |
|
743 QString sTempFileLocation = QString( "e:\\album_art_%1.png" ).arg( sTimeStamp ); |
|
744 |
|
745 ( ( MpSongData* ) this )->mTempAlbumArt = sTempFileLocation; |
|
746 TX_LOG_ARGS( "Create album art file " << mTempAlbumArt ); |
|
747 |
|
748 QFile file( mTempAlbumArt ); |
|
749 file.open( QIODevice::WriteOnly ); |
|
750 if ( mAlbumArt && !mAlbumArt->isNull() && !mAlbumArt->qicon().isNull() ) |
|
751 { |
|
752 QPixmap p = mAlbumArt->qicon().pixmap( QSize( 74, 74 ), QIcon::Normal, QIcon::Off ); |
|
753 p.save( &file, "PNG" ); |
|
754 //mAlbumArt->pixmap().save( &file, "PNG" ); // writes pixmap into bytes in PNG format |
|
755 } |
|
756 file.close(); |
|
757 return mTempAlbumArt; |
|
758 } |
|
759 |
|
760 /*! |
|
761 Delete temporary album art file. |
|
762 */ |
|
763 void MpSongData::removeAlbumArtFile() const |
|
764 { |
|
765 TX_ENTRY |
|
766 if ( !mTempAlbumArt.isEmpty() ) |
|
767 { |
|
768 TX_LOG_ARGS( "Remove album art file " << mTempAlbumArt ); |
|
769 QFile::remove( mTempAlbumArt ); |
|
770 ( ( MpSongData* ) this )->mTempAlbumArt = ""; |
|
771 } |
|
772 else |
|
773 { |
|
774 TX_LOG_ARGS( "Album art filename is empty" ); |
|
775 } |
|
776 TX_EXIT |
|
777 } |
|