mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontainerplaylists.cpp
changeset 20 82baf59ce8dd
parent 19 4e84c994a771
child 29 8192e5b5c935
equal deleted inserted replaced
19:4e84c994a771 20:82baf59ce8dd
    17 
    17 
    18 #include <QtCore>
    18 #include <QtCore>
    19 
    19 
    20 #include <hbdocumentloader.h>
    20 #include <hbdocumentloader.h>
    21 #include <hblistview.h>
    21 #include <hblistview.h>
       
    22 #include <hbgroupbox.h>
       
    23 #include <hblabel.h>
    22 
    24 
    23 #include "mpcollectioncontainerplaylists.h"
    25 #include "mpcollectioncontainerplaylists.h"
    24 #include "mpmpxcollectiondata.h"
    26 #include "mpmpxcollectiondata.h"
    25 #include "mpcollectioninfobar.h"
       
    26 #include "mptrace.h"
    27 #include "mptrace.h"
    27 
    28 
    28 
    29 
    29 /*!
    30 /*!
    30     \class MpCollectionContainerPlaylists
    31     \class MpCollectionContainerPlaylists
    45  Constructs the collection container.
    46  Constructs the collection container.
    46  This container handles the both the auto playlists and user created playlists.
    47  This container handles the both the auto playlists and user created playlists.
    47  */
    48  */
    48 MpCollectionContainerPlaylists::MpCollectionContainerPlaylists( HbDocumentLoader *loader, QGraphicsItem *parent )
    49 MpCollectionContainerPlaylists::MpCollectionContainerPlaylists( HbDocumentLoader *loader, QGraphicsItem *parent )
    49     : MpCollectionListContainer(loader, parent),
    50     : MpCollectionListContainer(loader, parent),
    50       mInfoBar(0),
    51       mInfoBar(0)
    51       mListInitialized(false)
       
    52 {
    52 {
    53     TX_LOG
    53     TX_LOG
    54 }
    54 }
    55 
    55 
    56 /*!
    56 /*!
    70  \reimp
    70  \reimp
    71  */
    71  */
    72 void MpCollectionContainerPlaylists::setupContainer()
    72 void MpCollectionContainerPlaylists::setupContainer()
    73 {
    73 {
    74     TX_ENTRY_ARGS("mCollectionContext=" << mCollectionContext);
    74     TX_ENTRY_ARGS("mCollectionContext=" << mCollectionContext);
       
    75     if ( mCollectionData->count() ) {
       
    76         bool ok = false;
       
    77         QGraphicsWidget *widget;
       
    78         if ( mCollectionContext == ECollectionContextPlaylists ) {
       
    79             mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "playlists", &ok);
       
    80             if ( !ok ) {
       
    81                 TX_LOG_ARGS("Error: invalid xml file.");
       
    82                 Q_ASSERT_X(ok, "MpCollectionContainerPlaylists::setupContainer", "invalid xml file");
       
    83             }
       
    84             if ( !mList ) {
       
    85                 widget = mDocumentLoader->findWidget(QString("playlistsList"));
       
    86                 mList = qobject_cast<HbListView*>(widget);
       
    87                 initializeList();
       
    88             }
       
    89             if ( mInfoBar ) {
       
    90                 delete mInfoBar;
       
    91                 mInfoBar = 0;
       
    92             }
       
    93         }
       
    94         else if ( mCollectionContext == ECollectionContextPlaylistSongs ) {
       
    95             mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "playlistSongs", &ok);
       
    96             if ( !ok ) {
       
    97                 TX_LOG_ARGS("Error: invalid xml file.");
       
    98                 Q_ASSERT_X(ok, "MpCollectionContainerPlaylists::setupContainer", "invalid xml file");
       
    99             }
    75 
   100 
    76     if ( !mList ) {
   101             widget = mDocumentLoader->findWidget(QString("playlistSongsDetail"));
    77         bool ok = false;
   102             mInfoBar = qobject_cast<HbGroupBox*>(widget);
    78         mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "playlist", &ok);
       
    79 
   103 
    80         if ( !ok ) {
   104             QString details;
    81             TX_LOG_ARGS("Error: invalid xml file.");
   105             if ( mViewMode == MpCommon::FetchView ) {
    82             Q_ASSERT_X(ok, "MpCollectionContainerPlaylists::setupContainer", "invalid xml file");
   106                 details = "Select a song";
       
   107             }
       
   108             else {
       
   109                 details = mCollectionData->collectionTitle();
       
   110             }
       
   111             mInfoBar->setHeading(details);
    83         }
   112         }
    84 
   113         if ( mNoMusic ) {
    85         QGraphicsWidget *widget;
   114             delete mNoMusic;
    86         widget = mDocumentLoader->findWidget(QString("playlistDetail"));
   115             mNoMusic = 0;
    87         mInfoBar = qobject_cast<MpCollectionInfoBar*>(widget);
   116         }
    88 
       
    89         widget = mDocumentLoader->findWidget(QString("playlistList"));
       
    90         mList = qobject_cast<HbListView*>(widget);
       
    91         initializeList();
       
    92     }
   117     }
    93 
   118     else {
    94     int count = mCollectionData->count();
   119         if ( mInfoBar ) {
    95     QString details;
   120             delete mInfoBar;
    96     QString detailsCount;
   121             mInfoBar = 0;
    97     QString playlist;
       
    98     switch ( mCollectionContext ) {
       
    99     case ECollectionContextPlaylists:
       
   100         details.setNum(count);
       
   101         details.append( tr(" playlist(s)") );
       
   102         mInfoBar->setText(details);
       
   103         break;
       
   104     case ECollectionContextPlaylistSongs:
       
   105         if ( mViewMode == MpCommon::FetchView ) {
       
   106             details = "Select a song";
       
   107         }
   122         }
   108         else {
   123         // Call empty list from base class
   109             details = QString( tr("Playlist: ") );
   124         setupEmptyListContainer();
   110             playlist = mCollectionData->collectionTitle();
       
   111             if ( playlist.isEmpty() ) {
       
   112                 playlist = QString( tr("Unknown") );
       
   113             }
       
   114             details.append(playlist);
       
   115             detailsCount.setNum(count);
       
   116         }
       
   117         mInfoBar->setText(details, detailsCount);
       
   118         break;
       
   119     default:
       
   120         TX_LOG_ARGS("Error: Wrong context; should never get here.");
       
   121         break;
       
   122     }
   125     }
   123     TX_EXIT
   126     TX_EXIT
   124 }
   127 }
   125 
   128