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 #include <QPainter> |
|
22 #include <QBuffer> |
|
23 #include <hbicon.h> |
|
24 #include "stub/inc/mpsongdata.h" |
|
25 #include "mptrace.h" |
|
26 |
|
27 const int KUndefined = -1; |
|
28 |
|
29 |
|
30 MpSongData::MpSongData( QObject *parent ) |
|
31 : QObject( parent ), |
|
32 mTitle( NULL ), |
|
33 mAlbum( NULL ), |
|
34 mArtist( NULL ), |
|
35 mComposer( NULL), |
|
36 mGenre( NULL ), |
|
37 mYear( NULL ), |
|
38 mAlbumTrack( NULL ), |
|
39 mAlbumArt(), |
|
40 mReqId( KUndefined ) |
|
41 { |
|
42 TX_ENTRY_ARGS("Stub") |
|
43 TX_EXIT_ARGS("Stub") |
|
44 } |
|
45 |
|
46 MpSongData::~MpSongData() |
|
47 { |
|
48 TX_ENTRY_ARGS("Stub") |
|
49 TX_EXIT_ARGS("Stub") |
|
50 } |
|
51 |
|
52 void MpSongData::albumArt( HbIcon& icon ) const |
|
53 { |
|
54 TX_ENTRY_ARGS("Stub") |
|
55 TX_EXIT_ARGS("Stub") |
|
56 } |
|
57 |
|
58 |
|
59 QString MpSongData::title() const |
|
60 { |
|
61 TX_ENTRY_ARGS("Stub") |
|
62 return mTitle; |
|
63 } |
|
64 |
|
65 QString MpSongData::album() const |
|
66 { |
|
67 TX_ENTRY_ARGS("Stub") |
|
68 return mAlbum; |
|
69 } |
|
70 |
|
71 QString MpSongData::artist() const |
|
72 { |
|
73 TX_ENTRY_ARGS("Stub") |
|
74 return mArtist; |
|
75 } |
|
76 |
|
77 QString MpSongData::comment() const |
|
78 { |
|
79 TX_ENTRY_ARGS("Stub") |
|
80 return mComment; |
|
81 } |
|
82 |
|
83 QString MpSongData::composer() const |
|
84 { |
|
85 TX_ENTRY_ARGS("Stub") |
|
86 return mComposer; |
|
87 } |
|
88 |
|
89 |
|
90 QString MpSongData::genre() const |
|
91 { |
|
92 TX_ENTRY_ARGS("Stub") |
|
93 return mGenre; |
|
94 } |
|
95 |
|
96 |
|
97 QString MpSongData::albumTrack() const |
|
98 { |
|
99 TX_ENTRY_ARGS("Stub") |
|
100 return mAlbumTrack; |
|
101 } |
|
102 |
|
103 QString MpSongData::link() const |
|
104 { |
|
105 TX_ENTRY_ARGS("Stub") |
|
106 return mLink; |
|
107 } |
|
108 |
|
109 QString MpSongData::year() const |
|
110 { |
|
111 TX_ENTRY_ARGS("Stub") |
|
112 return mYear; |
|
113 } |
|
114 |
|
115 QString MpSongData::fileName() const |
|
116 { |
|
117 TX_ENTRY_ARGS("Stub") |
|
118 return mFileName; |
|
119 } |
|
120 |
|
121 QString MpSongData::mimeType() const |
|
122 { |
|
123 TX_ENTRY_ARGS("Stub") |
|
124 return mMimeType; |
|
125 } |
|
126 |
|
127 QString MpSongData::duration() const |
|
128 { |
|
129 TX_ENTRY_ARGS("Stub") |
|
130 return mDuration; |
|
131 } |
|
132 |
|
133 QString MpSongData::bitRate() const |
|
134 { |
|
135 TX_ENTRY_ARGS("Stub") |
|
136 return mBitRate; |
|
137 } |
|
138 |
|
139 QString MpSongData::sampleRate() const |
|
140 { |
|
141 TX_ENTRY_ARGS("Stub") |
|
142 return mSampleRate; |
|
143 } |
|
144 |
|
145 QString MpSongData::size() const |
|
146 { |
|
147 TX_ENTRY_ARGS("Stub") |
|
148 return mSize; |
|
149 } |
|
150 |
|
151 QString MpSongData::modified() const |
|
152 { |
|
153 TX_ENTRY_ARGS("Stub") |
|
154 return mModified; |
|
155 } |
|
156 |
|
157 QString MpSongData::copyright() const |
|
158 { |
|
159 TX_ENTRY_ARGS("Stub") |
|
160 return mCopyright; |
|
161 } |
|
162 |
|
163 QString MpSongData::musicURL() const |
|
164 { |
|
165 TX_ENTRY_ARGS("Stub") |
|
166 return mMusicURL; |
|
167 } |
|
168 |
|
169 bool MpSongData::isDrmProtected() const |
|
170 { |
|
171 TX_ENTRY_ARGS("Stub") |
|
172 return mDrmProtected; |
|
173 } |
|
174 bool MpSongData::setTitle( const QString &title ) |
|
175 { |
|
176 TX_ENTRY_ARGS("Stub title =" << title ) |
|
177 bool change = false; |
|
178 if ( title != mTitle ) { |
|
179 change = true; |
|
180 mTitle = title; |
|
181 } |
|
182 TX_EXIT_ARGS("Stub") |
|
183 return change; |
|
184 } |
|
185 |
|
186 bool MpSongData::setAlbum( const QString &album ) |
|
187 { |
|
188 TX_ENTRY_ARGS( "Stub album =" << album ) |
|
189 bool change = false; |
|
190 if ( album != mAlbum ) { |
|
191 change = true; |
|
192 mAlbum = album; |
|
193 } |
|
194 |
|
195 return change; |
|
196 } |
|
197 |
|
198 bool MpSongData::setArtist( const QString &artist ) |
|
199 { |
|
200 TX_ENTRY_ARGS("Stub artist =" << artist ) |
|
201 bool change = false; |
|
202 if ( artist != mArtist ) { |
|
203 change = true; |
|
204 mArtist = artist; |
|
205 } |
|
206 TX_EXIT_ARGS("Stub") |
|
207 return change; |
|
208 } |
|
209 |
|
210 bool MpSongData::setComment( const QString &comment) |
|
211 { |
|
212 TX_ENTRY_ARGS("Stub comment =" << comment ) |
|
213 bool change = false; |
|
214 if ( comment != mComment ) { |
|
215 change = true; |
|
216 mComment = comment; |
|
217 } |
|
218 TX_EXIT_ARGS("Stub") |
|
219 return change; |
|
220 } |
|
221 |
|
222 bool MpSongData::setComposer( const QString &composer ) |
|
223 { |
|
224 TX_ENTRY_ARGS("Stub composer =" << composer ) |
|
225 bool change = false; |
|
226 if ( composer != mComposer ) { |
|
227 change = true; |
|
228 mComposer = composer; |
|
229 } |
|
230 TX_EXIT_ARGS("Stub") |
|
231 return change; |
|
232 } |
|
233 |
|
234 bool MpSongData::setGenre( const QString &genre ) |
|
235 { |
|
236 TX_ENTRY_ARGS("Stub genre =" << genre ) |
|
237 bool change = false; |
|
238 if ( genre != mGenre ) { |
|
239 change = true; |
|
240 mGenre = genre; |
|
241 } |
|
242 TX_EXIT_ARGS("Stub") |
|
243 return change; |
|
244 } |
|
245 |
|
246 |
|
247 bool MpSongData::setYear( int year ) |
|
248 { |
|
249 TX_ENTRY_ARGS("Stub year =" << year ) |
|
250 bool change = false; |
|
251 if ( QString::number(year) != mYear ) { |
|
252 change = true; |
|
253 if ( year >= 0 && year < 9999 ) { |
|
254 mYear = QString::number(year); |
|
255 } |
|
256 } |
|
257 TX_EXIT_ARGS("Stub") |
|
258 return change; |
|
259 } |
|
260 |
|
261 bool MpSongData::setAlbumTrack( const QString &track ) |
|
262 { |
|
263 TX_ENTRY_ARGS("Stub track =" << track ) |
|
264 bool change = false; |
|
265 if ( track != mAlbumTrack ) { |
|
266 change = true; |
|
267 mAlbumTrack = track; |
|
268 } |
|
269 TX_EXIT_ARGS("Stub") |
|
270 return change; |
|
271 } |
|
272 |
|
273 void MpSongData::setLink( const QString &link ) |
|
274 { |
|
275 TX_ENTRY_ARGS("Stub Link =" << link ) |
|
276 mLink = link; |
|
277 TX_EXIT_ARGS("Stub") |
|
278 } |
|
279 |
|
280 void MpSongData::setAlbumArtUri( const QString &albumArtUri) |
|
281 { |
|
282 TX_ENTRY_ARGS("Stub albumArtUri = " << albumArtUri ) |
|
283 // Set default album art. |
|
284 mAlbumArt = mDefaultAlbumArt; |
|
285 emit albumArtReady(); |
|
286 TX_EXIT |
|
287 } |
|
288 |
|
289 bool MpSongData::setFileName( const QString &fileName ) |
|
290 { |
|
291 TX_ENTRY_ARGS( "File name =" << fileName ) |
|
292 bool change = false; |
|
293 if ( fileName != mFileName ) { |
|
294 change = true; |
|
295 mFileName = fileName; |
|
296 } |
|
297 TX_EXIT |
|
298 return change; |
|
299 } |
|
300 |
|
301 bool MpSongData::setMimeType( const QString &mimeType ) |
|
302 { |
|
303 TX_ENTRY_ARGS( "Mime =" << mimeType ) |
|
304 bool change = false; |
|
305 if ( mimeType != mMimeType ) { |
|
306 change = true; |
|
307 mMimeType = mimeType; |
|
308 } |
|
309 TX_EXIT |
|
310 return change; |
|
311 } |
|
312 |
|
313 bool MpSongData::setDuration( int duration ) |
|
314 { |
|
315 TX_ENTRY_ARGS( "Duration =" << duration ) |
|
316 bool change = false; |
|
317 QString timeFormatOne("%1:%2:%3"); |
|
318 QString timeFormatTwo("%1:%2"); |
|
319 if ( QString::number( duration ) != mDuration ) { |
|
320 change = true; |
|
321 if ( duration >= 3600 ) { |
|
322 // more than one hours |
|
323 QString hourStr, minStr, secStr; |
|
324 int hour = duration / 3600; |
|
325 int min = duration % 3600 / 60; |
|
326 int sec = duration % 3600 % 60; |
|
327 |
|
328 hourStr = hour >= 10 ? QString::number( hour ) : QString::number( hour ).prepend( "0" ); |
|
329 minStr = min >= 10 ? QString::number( min ) : QString::number( min ).prepend( "0" ); |
|
330 secStr = sec >= 10 ? QString::number( sec ) : QString::number( sec ).prepend( "0" ); |
|
331 mDuration = timeFormatOne.arg( hourStr ).arg( minStr ).arg( secStr ); |
|
332 } else if ( duration >= 60 && duration < 3600 ) { |
|
333 // more than one min && less than one hour |
|
334 QString minStr, secStr; |
|
335 int min = duration / 60; |
|
336 int sec = duration % 60; |
|
337 |
|
338 minStr = min >= 10 ? QString::number( min ) : QString::number( min ).prepend( "0" ); |
|
339 secStr = sec >= 10 ? QString::number( sec ) : QString::number( sec ).prepend( "0" ); |
|
340 mDuration = timeFormatTwo.arg( minStr ).arg( secStr ); |
|
341 } else if ( duration > 0 && duration < 60 ) { |
|
342 QString secStr; |
|
343 secStr = duration >= 10 ? QString::number( duration ) : QString::number( duration ).prepend( "0" ); |
|
344 mDuration = secStr; |
|
345 } else { |
|
346 mDuration = QString(); |
|
347 } |
|
348 } |
|
349 TX_EXIT |
|
350 return change; |
|
351 } |
|
352 |
|
353 bool MpSongData::setBitRate( int bitRate) |
|
354 { |
|
355 TX_ENTRY_ARGS( "Bit rate =" << bitRate ) |
|
356 bool change = false; |
|
357 if ( QString::number( bitRate ) != mBitRate ) { |
|
358 change = true; |
|
359 if ( bitRate > 0 ) { |
|
360 mBitRate = QString::number( bitRate / 1000 ); |
|
361 } else { |
|
362 mBitRate = QString(); |
|
363 } |
|
364 } |
|
365 TX_EXIT |
|
366 return change; |
|
367 } |
|
368 |
|
369 bool MpSongData::setSampleRate( int sampleRate ) |
|
370 { |
|
371 TX_ENTRY_ARGS( "Sample rate =" << sampleRate ) |
|
372 bool change = false; |
|
373 if ( QString::number( sampleRate ) != mSampleRate ) { |
|
374 change = true; |
|
375 if ( sampleRate > 0 ) { |
|
376 mSampleRate = QString::number( sampleRate ); |
|
377 } else { |
|
378 mSampleRate = QString(); |
|
379 } |
|
380 } |
|
381 TX_EXIT |
|
382 return change; |
|
383 } |
|
384 |
|
385 bool MpSongData::setSize( int size ) |
|
386 { |
|
387 TX_ENTRY_ARGS( "Size =" << size ) |
|
388 bool change = false; |
|
389 if ( QString::number( size ) != mSize ) { |
|
390 change = true; |
|
391 mSize = QString::number( size / 1000 ).append( " MB" ); |
|
392 } |
|
393 TX_EXIT |
|
394 return change; |
|
395 } |
|
396 |
|
397 bool MpSongData::setModified( const QString &modified ) |
|
398 { |
|
399 TX_ENTRY_ARGS( "Modified =" << modified ) |
|
400 bool change = false; |
|
401 if ( modified != mModified ) { |
|
402 change = true; |
|
403 mModified = modified; |
|
404 } |
|
405 TX_EXIT |
|
406 return change; |
|
407 } |
|
408 |
|
409 bool MpSongData::setCopyright( const QString ©right ) |
|
410 { |
|
411 TX_ENTRY_ARGS( "Copyright =" << copyright ) |
|
412 bool change = false; |
|
413 if ( copyright != mCopyright ) { |
|
414 change = true; |
|
415 mCopyright = copyright; |
|
416 } |
|
417 TX_EXIT |
|
418 return change; |
|
419 } |
|
420 |
|
421 bool MpSongData::setMusicURL( const QString &musicURL ) |
|
422 { |
|
423 TX_ENTRY_ARGS( "Music URL =" << musicURL ) |
|
424 bool change = false; |
|
425 if ( musicURL != mMusicURL ) { |
|
426 change = true; |
|
427 mMusicURL = musicURL; |
|
428 } |
|
429 TX_EXIT |
|
430 return change; |
|
431 } |
|
432 |
|
433 /*! |
|
434 Set whether the song is DRM protected |
|
435 */ |
|
436 bool MpSongData::setDrmProtected( bool drmProtected ) |
|
437 { |
|
438 TX_ENTRY_ARGS( "STUB DRM protected =" << drmProtected ) |
|
439 bool change = false; |
|
440 if ( drmProtected != mDrmProtected ) { |
|
441 change = true; |
|
442 mDrmProtected = drmProtected; |
|
443 } |
|
444 TX_EXIT |
|
445 return change; |
|
446 } |
|
447 |
|
448 void MpSongData::thumbnailReady( |
|
449 const QPixmap& pixmap, |
|
450 void *data, |
|
451 int id, |
|
452 int error ) |
|
453 { |
|
454 TX_ENTRY_ARGS("Stub") |
|
455 Q_UNUSED( data ); |
|
456 TX_EXIT_ARGS("Stub") |
|
457 } |
|
458 |
|
459 void MpSongData::commitPlaybackInfo() |
|
460 { |
|
461 TX_ENTRY_ARGS("Stub") |
|
462 emit playbackInfoChanged(); |
|
463 TX_EXIT_ARGS("Stub") |
|
464 } |
|
465 |
|
466 void MpSongData::commitSongDetailInfo() |
|
467 { |
|
468 TX_ENTRY_ARGS("Stub") |
|
469 emit songDetailInfoChanged(); |
|
470 TX_EXIT_ARGS("Stub") |
|
471 } |
|
472 |
|
473 QString MpSongData::albumArtBase64() const |
|
474 { |
|
475 TX_ENTRY_ARGS("Stub") |
|
476 return QString(); |
|
477 } |
|