mpviewplugins/mpdetailsviewplugin/tsrc/unittest_mpmpxdetailsframeworkwrapper/stub/src/mpsongdata.cpp
changeset 43 0f32e550d9d8
parent 38 b93f525c9244
child 45 612c4815aebe
equal deleted inserted replaced
38:b93f525c9244 43:0f32e550d9d8
     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 <thumbnailmanager_qt.h>
       
    23 #include <thumbnaildata.h>
       
    24 #include <thumbnailobjectsource.h>
       
    25 
       
    26 #include "mpsongdata.h"
       
    27 #include "mptrace.h"
       
    28 
       
    29 
       
    30 const int KUndefined = -1;
       
    31 
       
    32 /*!
       
    33     \class MpSongData
       
    34     \brief Music Player song metadata.
       
    35 
       
    36     Song data provide acces to current playing song metadata
       
    37 */
       
    38     
       
    39 /*!
       
    40     \fn void albumArtReady()
       
    41 
       
    42     This signal is albuma alrt is ready.
       
    43  */
       
    44 
       
    45 /*!
       
    46     \fn void playbackInfoChanged()
       
    47 
       
    48     This signal is emitted when basic information is available
       
    49  */
       
    50     
       
    51 /*!
       
    52     \fn void songDetailInfoChanged()
       
    53 
       
    54     This signal is emitted when detail information is available
       
    55  */
       
    56     
       
    57        
       
    58 
       
    59 /*!
       
    60     Constructs a new MpSongData.
       
    61  */
       
    62 MpSongData::MpSongData( QObject *parent )
       
    63     : QObject( parent ),
       
    64       mTitle( NULL ),
       
    65       mAlbum( NULL ),
       
    66       mArtist( NULL ),
       
    67       mComposer( NULL),
       
    68       mGenre( NULL ),
       
    69       mYear( NULL ),
       
    70       mAlbumTrack( NULL ),
       
    71       mAlbumArt(),
       
    72       mReqId( KUndefined )
       
    73 {
       
    74     TX_ENTRY_ARGS("STUB")
       
    75 
       
    76     mDefaultAlbumArt = QPixmap( ":/playbackviewicons/defaultalbumart.png" );
       
    77     TX_EXIT_ARGS("STUB")
       
    78 }
       
    79 
       
    80 /*!
       
    81  Constructs a new MpSongData.
       
    82  */
       
    83 MpSongData::~MpSongData()
       
    84 {
       
    85     TX_ENTRY_ARGS("STUB")
       
    86 
       
    87     TX_EXIT_ARGS("STUB")
       
    88 }
       
    89 
       
    90 /*!
       
    91  Returns the song album art on \a pixmap.
       
    92 */
       
    93 void MpSongData::albumArt( QPixmap& pixmap )
       
    94 {
       
    95     TX_ENTRY_ARGS("STUB")
       
    96      if ( !mAlbumArt.isNull() ) {
       
    97         pixmap = mAlbumArt;
       
    98      }
       
    99      else {
       
   100          pixmap = QPixmap();
       
   101      }
       
   102     TX_EXIT_ARGS("STUB")
       
   103 }
       
   104 
       
   105 
       
   106 /*!
       
   107  Returns the song title.
       
   108 */
       
   109 QString MpSongData::title() const
       
   110 {
       
   111     TX_ENTRY_ARGS("STUB")
       
   112     return mTitle;
       
   113 }
       
   114 
       
   115 /*!
       
   116  Returns the song album.
       
   117 */
       
   118 QString MpSongData::album() const
       
   119 {
       
   120     TX_ENTRY_ARGS("STUB")
       
   121     return mAlbum;
       
   122 }
       
   123 
       
   124 /*!
       
   125  Returns the song artist.
       
   126 */
       
   127 QString MpSongData::artist() const
       
   128 {
       
   129     TX_ENTRY_ARGS("STUB")
       
   130     return mArtist;
       
   131 }
       
   132 
       
   133 /*!
       
   134  Returns comment
       
   135 */
       
   136 QString MpSongData::comment() const
       
   137 {
       
   138     TX_ENTRY_ARGS("STUB")
       
   139     return mComment;
       
   140 }
       
   141 
       
   142 /*!
       
   143  Returns the song composer.
       
   144 */
       
   145 QString MpSongData::composer() const
       
   146 {
       
   147     TX_ENTRY_ARGS("STUB")
       
   148     return mComposer;
       
   149 }
       
   150 
       
   151 
       
   152 /*!
       
   153  Returns the song genre.
       
   154 */
       
   155 QString MpSongData::genre() const
       
   156 {
       
   157     TX_ENTRY_ARGS("STUB")
       
   158     return mGenre;
       
   159 }
       
   160 
       
   161 
       
   162 /*!
       
   163  Returns the album track.
       
   164 */
       
   165 QString MpSongData::albumTrack() const
       
   166 {
       
   167     TX_ENTRY_ARGS("STUB")
       
   168     return mAlbumTrack;
       
   169 }
       
   170 
       
   171 /*!
       
   172  Returns link
       
   173 */
       
   174 QString MpSongData::link() const
       
   175 {
       
   176     TX_ENTRY_ARGS("STUB")
       
   177     return mLink;
       
   178 }
       
   179 
       
   180 /*!
       
   181  Returns the release date.
       
   182 */
       
   183 QString MpSongData::year() const
       
   184 {
       
   185     TX_ENTRY_ARGS("STUB")    
       
   186     return mYear;
       
   187 }
       
   188 
       
   189 
       
   190 /*!
       
   191  Sets the song \a title, returns true if the value is new.
       
   192 */
       
   193 bool MpSongData::setTitle( const QString &title )
       
   194 {
       
   195     TX_ENTRY_ARGS("STUB title =" << title )
       
   196     bool change = false;
       
   197     if ( title != mTitle ) {
       
   198         change = true;
       
   199         mTitle = title;
       
   200     }
       
   201     TX_EXIT_ARGS("STUB")
       
   202     return change;
       
   203 }
       
   204 
       
   205 /*!
       
   206  Sets the song \a album, returns true if the value is new.
       
   207 */
       
   208 bool MpSongData::setAlbum( const QString &album )
       
   209 {
       
   210     TX_ENTRY_ARGS("STUB album =" << album )
       
   211     bool change = false;
       
   212     if ( album != mAlbum ) {
       
   213         change = true;
       
   214         mAlbum = album;
       
   215     }
       
   216     TX_EXIT_ARGS("STUB")
       
   217     return change;
       
   218 }
       
   219 
       
   220 /*!
       
   221  Sets the song \a artist, returns true if the value is new.
       
   222 */
       
   223 bool MpSongData::setArtist( const QString &artist )
       
   224 {
       
   225     TX_ENTRY_ARGS("STUB artist =" << artist )
       
   226     bool change = false;
       
   227     if ( artist != mArtist ) {
       
   228         change = true;
       
   229         mArtist = artist;
       
   230     }
       
   231     TX_EXIT_ARGS("STUB")
       
   232     return change;
       
   233 }
       
   234 
       
   235 /*!
       
   236  Sets the song \a comment, returns true if the value is new.
       
   237 */
       
   238 bool MpSongData::setComment( const QString &comment)
       
   239 {
       
   240     TX_ENTRY_ARGS("STUB comment =" << comment )
       
   241     bool change = false;
       
   242     if ( comment != mComment ) {
       
   243         change = true;
       
   244         mComment = comment;
       
   245     }
       
   246     TX_EXIT_ARGS("STUB")
       
   247     return change;
       
   248 }
       
   249 
       
   250 
       
   251 /*!
       
   252  Sets the song \a composer, returns true if the value is new.
       
   253 */
       
   254 bool MpSongData::setComposer( const QString &composer )
       
   255 {
       
   256     TX_ENTRY_ARGS("STUB composer =" << composer )
       
   257     bool change = false;
       
   258     if ( composer != mComposer ) {
       
   259         change = true;
       
   260         mComposer = composer;
       
   261     }
       
   262     TX_EXIT_ARGS("STUB")
       
   263     return change;
       
   264 }
       
   265 
       
   266 /*!
       
   267  Sets the song \a genre, returns true if the value is new.
       
   268 */
       
   269 bool MpSongData::setGenre( const QString &genre )
       
   270 {
       
   271     TX_ENTRY_ARGS("STUB genre =" << genre )
       
   272     bool change = false;
       
   273     if ( genre != mGenre ) {
       
   274         change = true;
       
   275         mGenre = genre;
       
   276     }
       
   277     TX_EXIT_ARGS("STUB")
       
   278     return change;
       
   279 }
       
   280 
       
   281 
       
   282 /*!
       
   283  Sets the song \a date, returns true if the value is new.
       
   284 */
       
   285 bool MpSongData::setYear( int year )
       
   286 {
       
   287     TX_ENTRY_ARGS("STUB year =" << year )
       
   288     bool change = false;
       
   289     if ( QString::number(year) != mYear ) {
       
   290         change = true;
       
   291         if ( year >= 0 && year < 9999 ) {
       
   292             mYear = QString::number(year);
       
   293         } else {
       
   294             mYear = QString();
       
   295         }
       
   296     }
       
   297     TX_EXIT_ARGS("STUB")
       
   298     return change;
       
   299 }
       
   300 
       
   301 /*!
       
   302  Sets the \a album track, returns true if the value is new.
       
   303 */
       
   304 bool MpSongData::setAlbumTrack( const QString &track )
       
   305 {
       
   306     TX_ENTRY_ARGS("STUB track =" << track )
       
   307     bool change = false;
       
   308     if ( track != mAlbumTrack ) {
       
   309         change = true;
       
   310         mAlbumTrack = track;
       
   311     }
       
   312     TX_EXIT_ARGS("STUB")
       
   313     return change;
       
   314 }
       
   315 
       
   316 /*!
       
   317  Sets the \a link
       
   318 */
       
   319 void MpSongData::setLink( const QString &link )
       
   320 {
       
   321     TX_ENTRY_ARGS("STUB Link =" << link )
       
   322     mLink = link;
       
   323     TX_EXIT_ARGS("STUB")
       
   324 }
       
   325 
       
   326 /*!
       
   327  Sets the song \a albumArtUri.
       
   328 */
       
   329 void MpSongData::setAlbumArtUri( const QString &albumArtUri)
       
   330 {
       
   331     TX_ENTRY_ARGS("STUB albumArtUri =" << albumArtUri )
       
   332 
       
   333     // No album art uri. Set default album art.
       
   334     mAlbumArt = mDefaultAlbumArt;
       
   335     emit albumArtReady();
       
   336     TX_EXIT_ARGS("STUB")
       
   337 }
       
   338 
       
   339 
       
   340 /*!
       
   341  Slot to handle the album art thumb.
       
   342 */
       
   343 void MpSongData::thumbnailReady(
       
   344         const QPixmap& pixmap,
       
   345         void *data,
       
   346         int id,
       
   347         int error  )
       
   348 {
       
   349     TX_ENTRY_ARGS("STUB")
       
   350     Q_UNUSED( data );
       
   351     if ( error == 0 && mReqId == id ) {
       
   352         mReqId = 0;
       
   353         mAlbumArt = pixmap;
       
   354         emit albumArtReady();
       
   355     }
       
   356     else {
       
   357         mReqId = 0;
       
   358         mAlbumArt = mDefaultAlbumArt; 
       
   359         emit albumArtReady();
       
   360     }
       
   361 
       
   362     TX_EXIT_ARGS("STUB")
       
   363 }
       
   364 
       
   365 /*!
       
   366  Emit signal when playback information changed, such as artist, track name
       
   367 */
       
   368 void MpSongData::commitPlaybackInfo()
       
   369 {
       
   370     TX_ENTRY_ARGS("STUB")
       
   371     emit playbackInfoChanged();
       
   372     TX_EXIT_ARGS("STUB")
       
   373 }
       
   374 
       
   375 /*!
       
   376  Emit signal when song detail information changed
       
   377 */
       
   378 void MpSongData::commitSongDetailInfo()
       
   379 {
       
   380     TX_ENTRY_ARGS("STUB")
       
   381     emit songDetailInfoChanged();
       
   382     TX_EXIT_ARGS("STUB")
       
   383 }
       
   384