homescreenapp/hsutils/src/hstrashbinwidget.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Mar 2010 09:27:44 +0200
changeset 35 f9ce957a272c
child 36 cdae8c6c3876
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: Trash bin widget.
*
*/

#include <QGraphicsLinearLayout>
#include <HbIconItem>

#include "hstrashbinwidget.h"

const char* KTrashBinNormalItemImageName = "qtg_graf_hs_delete_normal";
const char* KTrashBinHighlightItemImageName = "qtg_graf_hs_delete_highlight";

/*!
    \internal
    \class HsTrashBinWidget
    \ingroup group_hsutils
    \brief Trash bin widget.
*/

/*!
    \internal
    Constructor.
    
    \a parent Owner.
*/
HsTrashBinWidget::HsTrashBinWidget(QGraphicsItem *parent)
    : HbWidget(parent),
      mIconItem(0),
      mNormalIcon(0),
      mHighlightIcon(0),
      mNormalIconVisible(false)
{
    mIconItem = new HbIconItem(this);

    mNormalIcon = new HbIcon(KTrashBinNormalItemImageName);
    mHighlightIcon = new HbIcon(KTrashBinHighlightItemImageName);

    mIconItem->setIcon(*mNormalIcon);
    setPreferredSize(80,80); // workaround for icon updating problem when changing theme
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal);
    layout->addItem(mIconItem);
    setLayout(layout);
}

/*!
    \internal
    Destructor.    
*/
HsTrashBinWidget::~HsTrashBinWidget()
{

}

/*!
    \internal
*/
void HsTrashBinWidget::activate()
{
    if (mNormalIconVisible) {
        mIconItem->setIcon(*mHighlightIcon);
        mNormalIconVisible = false;
    }
}

/*!
    \internal
*/
void HsTrashBinWidget::deactivate()
{
    if (!mNormalIconVisible) {
        mIconItem->setIcon(*mNormalIcon);
        mNormalIconVisible = true;
    }
}