tsdevicedialog/tsdevicedialogplugin/src/tsentrymodelitem.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 31 Aug 2010 15:30:51 +0300
branchRCL_3
changeset 113 0efa10d348c0
permissions -rw-r--r--
Revision: 201033 Kit: 201035

/*
* 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: tsentrymodelitem.cpp
*
*/

#include "tsentrymodelitem.h"

#include <HbIcon>

#include <tstask.h>

#include "tsdataroles.h"

/*!
    \class TsEntryModelItem
    \ingroup group_tsdevicedialogplugin
    \brief Item presenting running apps in the grid.
*/

/*!
    Standard C++ constructor
    /param entry - Task Monitor data
*/
TsEntryModelItem::TsEntryModelItem(QSharedPointer<TsTask> entry)
    :
    mEntry(entry)
{
    //no implementation required
}

/*!
    Standard C++ destructor
*/
TsEntryModelItem::~TsEntryModelItem()
{
}

/*!
    Returns the data stored under the given role.
    /param role - requested data role
    /return data encapulated by QVariant
*/
QVariant TsEntryModelItem::data(int role) const
{
    switch (role) {
        case Qt::DisplayRole:
            return QVariant(mEntry->name());
        case Qt::DecorationRole:
            return QVariant::fromValue<HbIcon>(HbIcon(mEntry->screenshot()));
        case TsDataRoles::Closable:
            return QVariant(mEntry->isClosable());
        case TsDataRoles::Active:
            return QVariant(mEntry->isActive());
        default:
            return QVariant(QVariant::Invalid);
    }
}

/*!
    Close running application repesented by entry
*/
void TsEntryModelItem::close()
{
    mEntry->close();
}

/*!
    Open or move to foreground application repesented by entry
*/
void TsEntryModelItem::open()
{
    mEntry->open();
}