|
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 - Task Monitor 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 default: |
|
71 return QVariant(QVariant::Invalid); |
|
72 } |
|
73 } |
|
74 |
|
75 /*! |
|
76 Close running application repesented by entry |
|
77 */ |
|
78 void TsEntryModelItem::close() |
|
79 { |
|
80 mEntry->close(); |
|
81 } |
|
82 |
|
83 /*! |
|
84 Open or move to foreground application repesented by entry |
|
85 */ |
|
86 void TsEntryModelItem::open() |
|
87 { |
|
88 mEntry->open(); |
|
89 } |
|
90 |