mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontainerplaylists.cpp
changeset 29 8192e5b5c935
parent 20 82baf59ce8dd
child 32 c163ef0b758d
equal deleted inserted replaced
25:3ec52facab4d 29:8192e5b5c935
    21 #include <hblistview.h>
    21 #include <hblistview.h>
    22 #include <hbgroupbox.h>
    22 #include <hbgroupbox.h>
    23 #include <hblabel.h>
    23 #include <hblabel.h>
    24 
    24 
    25 #include "mpcollectioncontainerplaylists.h"
    25 #include "mpcollectioncontainerplaylists.h"
       
    26 #include "mpcollectiondatamodel.h"
    26 #include "mpmpxcollectiondata.h"
    27 #include "mpmpxcollectiondata.h"
    27 #include "mptrace.h"
    28 #include "mptrace.h"
    28 
    29 
    29 
    30 
    30 /*!
    31 /*!
    46  Constructs the collection container.
    47  Constructs the collection container.
    47  This container handles the both the auto playlists and user created playlists.
    48  This container handles the both the auto playlists and user created playlists.
    48  */
    49  */
    49 MpCollectionContainerPlaylists::MpCollectionContainerPlaylists( HbDocumentLoader *loader, QGraphicsItem *parent )
    50 MpCollectionContainerPlaylists::MpCollectionContainerPlaylists( HbDocumentLoader *loader, QGraphicsItem *parent )
    50     : MpCollectionListContainer(loader, parent),
    51     : MpCollectionListContainer(loader, parent),
    51       mInfoBar(0)
    52       mInfoBar(0),
       
    53       mCurrentPlaylistIndex(0)
    52 {
    54 {
    53     TX_LOG
    55     TX_LOG
       
    56     mCollectionContext = ECollectionContextPlaylists;
       
    57 
    54 }
    58 }
    55 
    59 
    56 /*!
    60 /*!
    57  Destructs the collection container.
    61  Destructs the collection container.
    58  */
    62  */
    59 MpCollectionContainerPlaylists::~MpCollectionContainerPlaylists()
    63 MpCollectionContainerPlaylists::~MpCollectionContainerPlaylists()
    60 {
    64 {
    61     TX_ENTRY
    65     TX_ENTRY
    62     delete mInfoBar;
    66     delete mInfoBar;
    63     delete mList;
    67     delete mList;
       
    68     TX_EXIT
       
    69 }
       
    70 
       
    71 /*!
       
    72  Sets the data model for the container.
       
    73  */
       
    74 void MpCollectionContainerPlaylists::setDataModel( MpCollectionDataModel *dataModel )
       
    75 {
       
    76     TX_ENTRY
       
    77     MpCollectionListContainer::setDataModel(dataModel);
       
    78     if ( mCollectionContext == ECollectionContextPlaylists ) {
       
    79         if ( mList ) {
       
    80             if ( mCollectionData->count() ) {
       
    81                 mList->scrollTo( dataModel->index(mCurrentPlaylistIndex, 0) );
       
    82             }
       
    83         }
       
    84     }
       
    85     TX_EXIT
       
    86 }
       
    87 
       
    88 /*!
       
    89  Slot to be called when an item is selected by the user.
       
    90 */
       
    91 void MpCollectionContainerPlaylists::itemActivated( const QModelIndex &index )
       
    92 {
       
    93     if ( mCollectionContext == ECollectionContextPlaylists ) {
       
    94         mCurrentPlaylistIndex = index.row();
       
    95         TX_ENTRY_ARGS("mCurrentPlaylistIndex=" << mCurrentPlaylistIndex);
       
    96     }
       
    97     MpCollectionListContainer::itemActivated(index);
       
    98     TX_EXIT
       
    99 }
       
   100 
       
   101 /*!
       
   102  Slot to be called data model has new data.
       
   103  */
       
   104 void MpCollectionContainerPlaylists::dataReloaded()
       
   105 {
       
   106     TX_ENTRY
       
   107     MpCollectionListContainer::dataReloaded();
       
   108     if ( mCollectionContext == ECollectionContextPlaylistSongs ) {
       
   109         // Playlist could have been renamed.
       
   110         QString details = mCollectionData->collectionTitle();
       
   111         mInfoBar->setHeading(details);
       
   112     }
    64     TX_EXIT
   113     TX_EXIT
    65 }
   114 }
    66 
   115 
    67 /*!
   116 /*!
    68  Sets up the container by organizing widgets according to its layout.
   117  Sets up the container by organizing widgets according to its layout.
   101             widget = mDocumentLoader->findWidget(QString("playlistSongsDetail"));
   150             widget = mDocumentLoader->findWidget(QString("playlistSongsDetail"));
   102             mInfoBar = qobject_cast<HbGroupBox*>(widget);
   151             mInfoBar = qobject_cast<HbGroupBox*>(widget);
   103 
   152 
   104             QString details;
   153             QString details;
   105             if ( mViewMode == MpCommon::FetchView ) {
   154             if ( mViewMode == MpCommon::FetchView ) {
   106                 details = "Select a song";
   155                 details = hbTrId("txt_mus_subtitle_select_a_song");
   107             }
   156             }
   108             else {
   157             else {
   109                 details = mCollectionData->collectionTitle();
   158                 details = mCollectionData->collectionTitle();
   110             }
   159             }
   111             mInfoBar->setHeading(details);
   160             mInfoBar->setHeading(details);