mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontainerallsongs.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Mar 2010 09:28:13 +0200
changeset 19 4e84c994a771
child 20 82baf59ce8dd
permissions -rw-r--r--
Revision: 201007 Kit: 201011

/*
* 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 <hblabel.h>

#include "mpcollectioncontainerallsongs.h"
#include "mpmpxcollectiondata.h"
#include "mpcollectioninfobar.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
    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");
    }

    QString details;
    if ( mViewMode == MpCommon::FetchView ) {
        details = "Select a song";
    }
    else {
        int count = mCollectionData->count();
        details.setNum(count);
        details.append(" songs");
    }

    QGraphicsWidget *widget;
    widget = mDocumentLoader->findWidget(QString("allSongsDetail"));
    mInfoBar = qobject_cast<MpCollectionInfoBar*>(widget);
    mInfoBar->setText(details);

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