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 <HbIcon> |
|
21 |
|
22 /*! |
|
23 \class TsEntryModelItem |
|
24 \ingroup group_tsdevicedialogplugin |
|
25 \brief Item presenting running apps in the grid. |
|
26 */ |
|
27 |
|
28 /*! |
|
29 Standard C++ constructor |
|
30 /param service - reference to initialized Content Aresnal client instance |
|
31 /param entry - Content Arsenal data |
|
32 /param size - icon size |
|
33 */ |
|
34 TsEntryModelItem::TsEntryModelItem(CaService& service, QSharedPointer<CaEntry> entry, QSize size) |
|
35 : |
|
36 mService(service), |
|
37 mEntry(entry), |
|
38 mSize(size) |
|
39 { |
|
40 //no implementation required |
|
41 } |
|
42 |
|
43 /*! |
|
44 Standard C++ destructor |
|
45 */ |
|
46 TsEntryModelItem::~TsEntryModelItem() |
|
47 { |
|
48 } |
|
49 |
|
50 /*! |
|
51 Returns the data stored under the given role. |
|
52 /param role - requested data role |
|
53 /return data encapulated by QVariant |
|
54 */ |
|
55 QVariant TsEntryModelItem::data(int role) const |
|
56 { |
|
57 switch (role) { |
|
58 case Qt::DisplayRole: |
|
59 return QVariant(mEntry->text()); |
|
60 case Qt::DecorationRole: |
|
61 return QVariant(mEntry->makeIcon(mSize)); |
|
62 case TsDataRoles::Closable: |
|
63 return QVariant(closable()); |
|
64 case TsDataRoles::Visible: |
|
65 return QVariant(true); |
|
66 default: |
|
67 return QVariant(QVariant::Invalid); |
|
68 } |
|
69 } |
|
70 |
|
71 /*! |
|
72 Close running application repesented by entry |
|
73 */ |
|
74 void TsEntryModelItem::close() |
|
75 { |
|
76 mService.executeCommand(mEntry->id(), QString("close")); |
|
77 } |
|
78 |
|
79 /*! |
|
80 Open or move to foreground application repesented by entry |
|
81 */ |
|
82 void TsEntryModelItem::open() |
|
83 { |
|
84 mService.executeCommand(mEntry->id(), QString("open")); |
|
85 } |
|
86 |
|
87 /*! |
|
88 Check if application represented by entry is running. |
|
89 /return true if application is running, false otherwise |
|
90 */ |
|
91 bool TsEntryModelItem::closable() const |
|
92 { |
|
93 return (mEntry->flags().testFlag(RunningEntryFlag) && |
|
94 !mEntry->flags().testFlag(SystemEntryFlag)); |
|
95 } |
|