mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontaineralbums.cpp
changeset 51 560ce2306a17
parent 43 0f32e550d9d8
child 55 f3930dda3342
equal deleted inserted replaced
47:4cc1412daed0 51:560ce2306a17
    27 #include "mpcollectioncontaineralbums.h"
    27 #include "mpcollectioncontaineralbums.h"
    28 #include "mpmpxcollectiondata.h"
    28 #include "mpmpxcollectiondata.h"
    29 #include "mpcollectiondatamodel.h"
    29 #include "mpcollectiondatamodel.h"
    30 #include "mpcollectiontbonelistdatamodel.h"
    30 #include "mpcollectiontbonelistdatamodel.h"
    31 #include "mptrace.h"
    31 #include "mptrace.h"
       
    32 #include "mpenginefactory.h"
    32 
    33 
    33 /*!
    34 /*!
    34     \class MpCollectionContainerAlbums
    35     \class MpCollectionContainerAlbums
    35     \brief Music Player collection container definition - Albums.
    36     \brief Music Player collection container definition - Albums.
    36 
    37 
    48 /*!
    49 /*!
    49  Constructs the collection container.
    50  Constructs the collection container.
    50  */
    51  */
    51 MpCollectionContainerAlbums::MpCollectionContainerAlbums( HbDocumentLoader *loader, QGraphicsItem *parent )
    52 MpCollectionContainerAlbums::MpCollectionContainerAlbums( HbDocumentLoader *loader, QGraphicsItem *parent )
    52     : MpCollectionListContainer(loader, parent),
    53     : MpCollectionListContainer(loader, parent),
    53       mInfoBar(0),
       
    54       mTBone(0),
    54       mTBone(0),
    55       mTBoneListModel(0),
    55       mTBoneListModel(0),
    56       mCurrentAlbumIndex(0)
    56       mCurrentAlbumIndex(0)
    57 {
    57 {
    58     TX_LOG
    58     TX_LOG
    63  Destructs the collection container.
    63  Destructs the collection container.
    64  */
    64  */
    65 MpCollectionContainerAlbums::~MpCollectionContainerAlbums()
    65 MpCollectionContainerAlbums::~MpCollectionContainerAlbums()
    66 {
    66 {
    67     TX_ENTRY
    67     TX_ENTRY
    68 	delete mInfoBar;
    68 	delete mTBone;
    69     delete mTBone;
       
    70     delete mList;
    69     delete mList;
    71     delete mTBoneListModel;
    70     delete mTBoneListModel;
    72     TX_EXIT
    71     TX_EXIT
    73 }
    72 }
    74 
    73 
    90     else if ( mCollectionContext == ECollectionContextAlbumsTBone ) {
    89     else if ( mCollectionContext == ECollectionContextAlbumsTBone ) {
    91         if ( mTBone ) {
    90         if ( mTBone ) {
    92             mTBone->setModel(dataModel);
    91             mTBone->setModel(dataModel);
    93             mTBone->scrollTo( dataModel->index(mCurrentAlbumIndex, 0) );
    92             mTBone->scrollTo( dataModel->index(mCurrentAlbumIndex, 0) );
    94             if ( mTBoneListModel == 0 ) {
    93             if ( mTBoneListModel == 0 ) {
    95                 mTBoneListModel = new MpCollectionTBoneListDataModel(mCollectionData);
    94                 mTBoneListModel = new MpCollectionTBoneListDataModel(mCollectionData, MpEngineFactory::sharedEngine()->playbackData());
    96                 connect( mTBoneListModel, SIGNAL(albumDataChanged()), this, SLOT(albumDataChanged()) );
    95                 connect( mTBoneListModel, SIGNAL(albumDataChanged()), this, SLOT(albumDataChanged()) );
    97                 connect( mTBoneListModel, SIGNAL(albumDataAvailable()), this, SLOT(albumDataAvailable()) );
    96                 connect( mTBoneListModel, SIGNAL(albumDataAvailable()), this, SLOT(albumDataAvailable()) );
    98             }
    97             }
    99             mList->setModel(mTBoneListModel);
    98             mList->setModel(mTBoneListModel);
   100             if ( mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) {
    99             if ( mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) {
   245  \reimp
   244  \reimp
   246  */
   245  */
   247 void MpCollectionContainerAlbums::setupContainer()
   246 void MpCollectionContainerAlbums::setupContainer()
   248 {
   247 {
   249     TX_ENTRY_ARGS("mCollectionContext=" << mCollectionContext);
   248     TX_ENTRY_ARGS("mCollectionContext=" << mCollectionContext);
       
   249     
       
   250     mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "showInfoBar");
       
   251     
   250     if ( mCollectionData->count() ) {
   252     if ( mCollectionData->count() ) {
   251         bool ok = false;
   253         bool ok = false;
   252         QGraphicsWidget *widget;
   254         QGraphicsWidget *widget;
   253         if ( mCollectionContext == ECollectionContextAlbums ) {
   255         if ( mCollectionContext == ECollectionContextAlbums ) {
   254             mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "albums", &ok);
   256             mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "albums", &ok);
   260                 widget = mDocumentLoader->findWidget(QString("albumsList"));
   262                 widget = mDocumentLoader->findWidget(QString("albumsList"));
   261                 mList = qobject_cast<HbListView*>(widget);
   263                 mList = qobject_cast<HbListView*>(widget);
   262                 mIndexFeedback->setItemView(mList);
   264                 mIndexFeedback->setItemView(mList);
   263                 initializeList();
   265                 initializeList();
   264             }
   266             }
   265             if ( mInfoBar ) {
       
   266                 delete mInfoBar;
       
   267                 mInfoBar = 0;
       
   268             }
       
   269             if ( mTBone ) {
   267             if ( mTBone ) {
   270                 delete mTBone;
   268                 delete mTBone;
   271                 mTBone = 0;
   269                 mTBone = 0;
   272             }
   270             }
       
   271                         
       
   272             mInfoBar->setHeading(hbTrId("txt_mus_subhead_albums_1l").arg(mCollectionData->count()));
       
   273             
   273         }
   274         }
   274         else if ( mCollectionContext == ECollectionContextAlbumsTBone ) {
   275         else if ( mCollectionContext == ECollectionContextAlbumsTBone ) {
   275             if ( mViewMode == MpCommon::FetchView ) {
   276             if ( mViewMode == MpCommon::FetchView ) {
   276                 mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "albumTBoneFetcher", &ok);
   277                 mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "albumTBoneFetcher", &ok);
   277                 if ( !ok ) {
   278                 if ( !ok ) {
   278                     TX_LOG_ARGS("Error: invalid xml file.");
   279                     TX_LOG_ARGS("Error: invalid xml file.");
   279                     Q_ASSERT_X(ok, "MpCollectionContainerAlbums::setupContainer", "invalid xml file");
   280                     Q_ASSERT_X(ok, "MpCollectionContainerAlbums::setupContainer", "invalid xml file");
   280                 }
   281                 }
   281                 widget = mDocumentLoader->findWidget(QString("albumTBoneDetail"));
   282  
   282                 mInfoBar = qobject_cast<HbGroupBox*>(widget);
   283                 mInfoBar->setHeading(hbTrId("txt_mus_subtitle_select_song"));
   283                 mInfoBar->setHeading( hbTrId("txt_mus_subtitle_select_a_song") );
       
   284             }
   284             }
   285             else {
   285             else {
   286                 mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "albumTBone", &ok);
   286                 mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "albumTBone", &ok);
   287                 if ( !ok ) {
   287                 if ( !ok ) {
   288                     TX_LOG_ARGS("Error: invalid xml file.");
   288                     TX_LOG_ARGS("Error: invalid xml file.");
   289                     Q_ASSERT_X(ok, "MpCollectionContainerAlbums::setupContainer", "invalid xml file");
   289                     Q_ASSERT_X(ok, "MpCollectionContainerAlbums::setupContainer", "invalid xml file");
   290                 }
   290                 }
       
   291                 
       
   292                 mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "hideInfoBar");
       
   293                 
   291             }
   294             }
   292             widget = mDocumentLoader->findWidget(QString("albumWall"));
   295             widget = mDocumentLoader->findWidget(QString("albumWall"));
   293             mTBone = qobject_cast<HgMediawall*>(widget);
   296             mTBone = qobject_cast<HgMediawall*>(widget);
   294             HbIcon defaultIcon( "qtg_large_album_art" );
   297             HbIcon defaultIcon( "qtg_large_album_art" );
   295             defaultIcon.setSize(mTBone->itemSize());
   298             defaultIcon.setSize(mTBone->itemSize());
   300             connect( mTBone, SIGNAL(animationAboutToEnd(QModelIndex)), this, SLOT(albumCentered(QModelIndex)) );
   303             connect( mTBone, SIGNAL(animationAboutToEnd(QModelIndex)), this, SLOT(albumCentered(QModelIndex)) );
   301         }
   304         }
   302     }
   305     }
   303     else {
   306     else {
   304         // Must delete widgets when last song is deleted and view is reloaded.
   307         // Must delete widgets when last song is deleted and view is reloaded.
   305         if ( mInfoBar ) {
       
   306             delete mInfoBar;
       
   307             mInfoBar = 0;
       
   308         }
       
   309         if ( mTBone ) {
   308         if ( mTBone ) {
   310             delete mTBone;
   309             delete mTBone;
   311             mTBone = 0;
   310             mTBone = 0;
   312         }
   311         }
       
   312         
       
   313         mInfoBar->setHeading(hbTrId("txt_mus_subhead_albums_1l").arg(0));
       
   314         
   313         // Call empty list from base class
   315         // Call empty list from base class
   314         setupEmptyListContainer();
   316         setupEmptyListContainer();
   315     }
   317     }
   316     TX_EXIT
   318     TX_EXIT
   317 }
   319 }