mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontainerallsongs.cpp
changeset 19 4e84c994a771
child 20 82baf59ce8dd
equal deleted inserted replaced
5:2a40e88564c8 19:4e84c994a771
       
     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: Music Player collection container definition - All Songs.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtCore>
       
    19 
       
    20 #include <hbdocumentloader.h>
       
    21 #include <hblistview.h>
       
    22 #include <hblabel.h>
       
    23 
       
    24 #include "mpcollectioncontainerallsongs.h"
       
    25 #include "mpmpxcollectiondata.h"
       
    26 #include "mpcollectioninfobar.h"
       
    27 #include "mptrace.h"
       
    28 
       
    29 /*!
       
    30     \class MpCollectionContainerAllSongs
       
    31     \brief Music Player collection container definition - All Songs.
       
    32 
       
    33     'All Songs' collection container implements the interface specified
       
    34     by MpCollectionContainer. It provides a layout and widgets for the
       
    35     'All Songs' view.
       
    36 
       
    37     \sa MpCollectionContainer
       
    38 */
       
    39 
       
    40 /*!
       
    41  Constructs the collection container.
       
    42  */
       
    43 MpCollectionContainerAllSongs::MpCollectionContainerAllSongs( HbDocumentLoader *loader, QGraphicsItem *parent )
       
    44     : MpCollectionListContainer(loader, parent),
       
    45       mInfoBar(0)
       
    46 {
       
    47     TX_LOG
       
    48 }
       
    49 
       
    50 /*!
       
    51  Destructs the collection container.
       
    52  */
       
    53 MpCollectionContainerAllSongs::~MpCollectionContainerAllSongs()
       
    54 {
       
    55     TX_ENTRY
       
    56     delete mInfoBar;
       
    57     delete mList;
       
    58     TX_EXIT
       
    59 }
       
    60 
       
    61 /*!
       
    62  Sets up the container by organizing widgets according to its layout.
       
    63 
       
    64  \reimp
       
    65  */
       
    66 void MpCollectionContainerAllSongs::setupContainer()
       
    67 {
       
    68     TX_ENTRY
       
    69     bool ok = false;
       
    70     mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "allSongs", &ok);
       
    71     if ( !ok ) {
       
    72         TX_LOG_ARGS("Error: invalid xml file.");
       
    73         Q_ASSERT_X(ok, "MpCollectionContainerAllSongs::setupContainer", "invalid xml file");
       
    74     }
       
    75 
       
    76     QString details;
       
    77     if ( mViewMode == MpCommon::FetchView ) {
       
    78         details = "Select a song";
       
    79     }
       
    80     else {
       
    81         int count = mCollectionData->count();
       
    82         details.setNum(count);
       
    83         details.append(" songs");
       
    84     }
       
    85 
       
    86     QGraphicsWidget *widget;
       
    87     widget = mDocumentLoader->findWidget(QString("allSongsDetail"));
       
    88     mInfoBar = qobject_cast<MpCollectionInfoBar*>(widget);
       
    89     mInfoBar->setText(details);
       
    90 
       
    91     widget = mDocumentLoader->findWidget(QString("allSongsList"));
       
    92     mList = qobject_cast<HbListView*>(widget);
       
    93     initializeList();
       
    94     TX_EXIT
       
    95 }
       
    96