taskswitcherapp/tsdevicedialogplugin/src/tsentrymodelitem.cpp
changeset 62 341166945d65
parent 57 2e2dc3d30ca8
child 63 52b0f64eeb51
equal deleted inserted replaced
57:2e2dc3d30ca8 62:341166945d65
     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: tsentrymodelitem.cpp
       
    15 *
       
    16 */
       
    17 #include "tsentrymodelitem.h"
       
    18 #include "tsdataroles.h"
       
    19 
       
    20 #include <tstask.h>
       
    21 #include <HbIcon>
       
    22 
       
    23 /*!
       
    24     \class TsEntryModelItem
       
    25     \ingroup group_tsdevicedialogplugin
       
    26     \brief Item presenting running apps in the grid.
       
    27 */
       
    28 
       
    29 /*!
       
    30     Standard C++ constructor
       
    31     /param entry - Content Arsenal data
       
    32 */
       
    33 TsEntryModelItem::TsEntryModelItem(QSharedPointer<TsTask> entry)
       
    34     :
       
    35     mEntry(entry)
       
    36 {
       
    37     //no implementation required
       
    38 }
       
    39 
       
    40 /*!
       
    41     Standard C++ destructor
       
    42 */
       
    43 TsEntryModelItem::~TsEntryModelItem()
       
    44 {
       
    45 }
       
    46 
       
    47 /*!
       
    48     Returns the data stored under the given role.
       
    49     /param role - requested data role
       
    50     /return data encapulated by QVariant
       
    51 */
       
    52 QVariant TsEntryModelItem::data(int role) const
       
    53 {
       
    54     switch (role) {
       
    55         case Qt::DisplayRole:
       
    56             return QVariant(mEntry->name());
       
    57         case Qt::DecorationRole:
       
    58             {
       
    59                 QPixmap icon = mEntry->screenshot().isNull() ? 
       
    60                                mEntry->icon() :
       
    61                                mEntry->screenshot();
       
    62                 if (icon.isNull()) {
       
    63                     return HbIcon("qtg_large_application");
       
    64                 } else {
       
    65                     return QVariant::fromValue<HbIcon>(HbIcon(icon));
       
    66                 }
       
    67             }
       
    68         case TsDataRoles::Closable:
       
    69             return QVariant(mEntry->isClosable());
       
    70         case TsDataRoles::Visible:
       
    71             return QVariant(true);
       
    72         default:
       
    73             return QVariant(QVariant::Invalid);
       
    74     }
       
    75 }
       
    76 
       
    77 /*!
       
    78     Close running application repesented by entry
       
    79 */
       
    80 void TsEntryModelItem::close()
       
    81 {
       
    82     mEntry->close();
       
    83 }
       
    84 
       
    85 /*!
       
    86     Open or move to foreground application repesented by entry
       
    87 */
       
    88 void TsEntryModelItem::open()
       
    89 {
       
    90     mEntry->open();
       
    91 }
       
    92