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