mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontainerallsongs.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 16 Apr 2010 14:56:30 +0300
changeset 20 82baf59ce8dd
parent 19 4e84c994a771
child 29 8192e5b5c935
permissions -rw-r--r--
Revision: 201011 Kit: 201015

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: Music Player collection container definition - All Songs.
*
*/

#include <QtCore>

#include <hbdocumentloader.h>
#include <hblistview.h>
#include <hbgroupbox.h>
#include <hbindexfeedback.h>

#include "mpcollectioncontainerallsongs.h"
#include "mpmpxcollectiondata.h"
#include "mptrace.h"

/*!
    \class MpCollectionContainerAllSongs
    \brief Music Player collection container definition - All Songs.

    'All Songs' collection container implements the interface specified
    by MpCollectionContainer. It provides a layout and widgets for the
    'All Songs' view.

    \sa MpCollectionContainer
*/

/*!
 Constructs the collection container.
 */
MpCollectionContainerAllSongs::MpCollectionContainerAllSongs( HbDocumentLoader *loader, QGraphicsItem *parent )
    : MpCollectionListContainer(loader, parent),
      mInfoBar(0)
{
    TX_LOG
}

/*!
 Destructs the collection container.
 */
MpCollectionContainerAllSongs::~MpCollectionContainerAllSongs()
{
    TX_ENTRY
    delete mInfoBar;
    delete mList;
    TX_EXIT
}

/*!
 Sets up the container by organizing widgets according to its layout.

 \reimp
 */
void MpCollectionContainerAllSongs::setupContainer()
{
    TX_ENTRY
    if ( mCollectionData->count() ) {
        bool ok = false;
        mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "allSongs", &ok);
        if ( !ok ) {
            TX_LOG_ARGS("Error: invalid xml file.");
            Q_ASSERT_X(ok, "MpCollectionContainerAllSongs::setupContainer", "invalid xml file");
        }
        QGraphicsWidget *widget;
        widget = mDocumentLoader->findWidget(QString("allSongsDetail"));
        mInfoBar = qobject_cast<HbGroupBox*>(widget);

        widget = mDocumentLoader->findWidget(QString("allSongsList"));
        mList = qobject_cast<HbListView*>(widget);
        mIndexFeedback->setItemView(mList);
        initializeList();

        QString details;
        if ( mViewMode == MpCommon::FetchView ) {
            details = "Select a song";
        }
        else {
            int count = mCollectionData->count();
            details = hbTrId("txt_mus_subhead_ln_songs", count);
        }
        mInfoBar->setHeading(details);
    }
    else {
        // Call empty list from base class
        setupEmptyListContainer();
    }
    TX_EXIT
}