mpdata/src/mpplaybackdata.cpp
changeset 29 8192e5b5c935
parent 22 ecf06a08d4d9
child 32 c163ef0b758d
equal deleted inserted replaced
25:3ec52facab4d 29:8192e5b5c935
    13 *
    13 *
    14 * Description: Playback Data provider for playback view.
    14 * Description: Playback Data provider for playback view.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <qicon>
    18 #include <QIcon>
    19 #include <qstring>
    19 #include <QString>
    20 #include <qpixmap>
    20 #include <QPixmap>
    21 #include <qpainter>
    21 #include <QPainter>
    22 #include <hbicon.h>
    22 #include <hbicon.h>
    23 #include <thumbnailmanager_qt.h>
    23 #include <thumbnailmanager_qt.h>
    24 
    24 
    25 #include "mpplaybackdata.h"
    25 #include "mpplaybackdata.h"
    26 #include "mptrace.h"
    26 #include "mptrace.h"
    72 
    72 
    73 /*!
    73 /*!
    74     Constructs a new MpPlaybackData.
    74     Constructs a new MpPlaybackData.
    75  */
    75  */
    76 MpPlaybackData::MpPlaybackData( QObject *parent )
    76 MpPlaybackData::MpPlaybackData( QObject *parent )
    77     : QObject(parent),
    77     : QObject( parent ),
    78       mThumbnailManager(0),
    78       mThumbnailManager( new ThumbnailManager( this ) ),
    79       mReqId(KUndefined),
    79       mReqId( KUndefined ),
    80       mDuration(0),
    80       mDuration(0),
    81       mPosition(0),
    81       mPosition(0),
    82       mAlbumArt(),
    82       mAlbum( hbTrId ( "txt_mus_other_unknown4" ) ),
    83       mPlaybackState(Stopped)
    83       mArtist( hbTrId ( "txt_mus_other_unknown3") ),
       
    84       mAlbumId(0),
       
    85       mId(0),
       
    86       mAlbumArt( "qtg_large_music_album" ),
       
    87       mDefaultAlbumArt( "qtg_large_music_album" ),
       
    88       mPlaybackState( NotPlaying ),
       
    89       mRealAudio( false )
    84 {
    90 {
    85     TX_ENTRY
    91     TX_ENTRY
    86     mThumbnailManager = new ThumbnailManager(this);
    92     mThumbnailManager->setQualityPreference( ThumbnailManager::OptimizeForQuality );
    87     mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality);
    93     mThumbnailManager->setThumbnailSize( ThumbnailManager::ThumbnailLarge );
    88     mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
    94     connect( mThumbnailManager, SIGNAL( thumbnailReady(QPixmap, void *, int, int ) ),
    89     connect( mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
    95              this, SLOT(thumbnailReady( QPixmap, void *, int, int ) ) );
    90              this, SLOT(thumbnailReady(QPixmap, void *, int, int)) );
       
    91 
       
    92     //TODO: Change to final resource when available
       
    93     mDefaultAlbumArt =  new HbIcon("qtg_large_music");
       
    94     TX_EXIT
    96     TX_EXIT
    95 }
    97 }
    96 
    98 
    97 /*!
    99 /*!
    98  Constructs a new MpPlaybackData.
   100  Constructs a new MpPlaybackData.
   175 {
   177 {
   176     TX_ENTRY_ARGS( "artist = " << artist )
   178     TX_ENTRY_ARGS( "artist = " << artist )
   177     bool change = false;
   179     bool change = false;
   178     if ( artist != mArtist ) {
   180     if ( artist != mArtist ) {
   179         change = true;
   181         change = true;
   180         mArtist = artist;
   182         if ( artist.isEmpty() ){
       
   183             mArtist = hbTrId( "txt_mus_other_unknown3" );      
       
   184         }
       
   185         else {
       
   186             mArtist = artist;
       
   187         }
   181     }
   188     }
   182     TX_EXIT
   189     TX_EXIT
   183     return change;
   190     return change;
   184 }
   191 }
   185 
   192 
   199 {
   206 {
   200     TX_ENTRY_ARGS( "album = " << album )
   207     TX_ENTRY_ARGS( "album = " << album )
   201     bool change = false;
   208     bool change = false;
   202     if ( album != mAlbum ) {
   209     if ( album != mAlbum ) {
   203         change = true;
   210         change = true;
   204         mAlbum = album;
   211         if ( album.isEmpty() ){
       
   212             mAlbum = hbTrId( "txt_mus_other_unknown4" );
       
   213         }
       
   214         else{
       
   215             mAlbum = album;            
       
   216         }
   205     }
   217     }
   206     TX_EXIT
   218     TX_EXIT
   207     return change;
   219     return change;
   208 }
   220 }
   209 
   221 
   273  Returns the song album art on \a icon.
   285  Returns the song album art on \a icon.
   274 */
   286 */
   275 void MpPlaybackData::albumArt( HbIcon& icon ) const
   287 void MpPlaybackData::albumArt( HbIcon& icon ) const
   276 {
   288 {
   277     TX_ENTRY
   289     TX_ENTRY
   278     if ( mAlbumArt->isNull() ) {
   290     icon = mAlbumArt ;
   279         icon = HbIcon();
   291     TX_EXIT
   280      }
   292 }
   281      else {
   293 
   282         icon = *mAlbumArt ;
   294 /*!
   283      }
   295  Sets the song's album \a id, returns true if the value is new.
   284     TX_EXIT
   296 */
       
   297 bool MpPlaybackData::setAlbumId( int id )
       
   298 {
       
   299     bool change = false;
       
   300     if (mAlbumId != id) {
       
   301         mAlbumId = id;
       
   302         change = true;
       
   303     }
       
   304     return change;
       
   305 }
       
   306 
       
   307 /*!
       
   308  Returns the id of the album to which the song belongs.
       
   309 */
       
   310 int MpPlaybackData::albumId()
       
   311 {
       
   312     return mAlbumId;
       
   313 }
       
   314 
       
   315 /*!
       
   316  Sets the song's \a id, returns true if the value is new.
       
   317 */
       
   318 bool MpPlaybackData::setId( int id )
       
   319 {
       
   320     bool change = false;
       
   321     if (mId != id) {
       
   322         mId = id;
       
   323         change = true;
       
   324     }
       
   325     return change;
       
   326 }
       
   327 
       
   328 /*!
       
   329  Returns the id the song.
       
   330 */
       
   331 int MpPlaybackData::id()
       
   332 {
       
   333     return mId;
       
   334 }
       
   335 /*!
       
   336 Set Real Audio \a mode.
       
   337 */
       
   338 bool MpPlaybackData::setRealAudio( bool mode )
       
   339 {
       
   340     TX_ENTRY
       
   341     bool change = false;
       
   342     if (mRealAudio != mode) {
       
   343         mRealAudio = mode;
       
   344         change = true;
       
   345     }
       
   346     TX_EXIT
       
   347     return change;
       
   348 }
       
   349 
       
   350 /*!
       
   351  Returns the mode of Real Audio.
       
   352 */
       
   353 bool MpPlaybackData::realAudio()
       
   354 {
       
   355     return mRealAudio;
   285 }
   356 }
   286 
   357 
   287 /*!
   358 /*!
   288  Sets the playback \a state.
   359  Sets the playback \a state.
   289 */
   360 */
   313 {
   384 {
   314     TX_ENTRY
   385     TX_ENTRY
   315     emit playbackInfoChanged();
   386     emit playbackInfoChanged();
   316     TX_EXIT
   387     TX_EXIT
   317 }
   388 }
       
   389 
   318 
   390 
   319 /*!
   391 /*!
   320  Slot to handle the album art thumb.
   392  Slot to handle the album art thumb.
   321 */
   393 */
   322 void MpPlaybackData::thumbnailReady(
   394 void MpPlaybackData::thumbnailReady(
   343         else {
   415         else {
   344             qicon = QIcon( pixmap );
   416             qicon = QIcon( pixmap );
   345         }
   417         }
   346         
   418         
   347         
   419         
   348         mAlbumArt = new HbIcon(qicon);
   420         mAlbumArt = HbIcon(qicon);
   349         
   421         
   350         emit albumArtReady();
   422         emit albumArtReady();
   351     }
   423     }
   352     else {
   424     else {
   353         mReqId = KUndefined;
   425         mReqId = KUndefined;