author | hgs |
Mon, 13 Sep 2010 13:03:23 +0300 | |
changeset 86 | e4f038c420f7 |
parent 81 | 7dd137878ff8 |
child 90 | 3ac3aaebaee5 |
permissions | -rw-r--r-- |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: Menu Application Library state. |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include <QDebug> |
69 | 19 |
#include <QScopedPointer> |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#include <HbDialog> |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include <HbDocumentLoader> |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include <HbLabel> |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include <HbAction> |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
|
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
#include "caservice.h" |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
#include "casoftwareregistry.h" |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
|
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
#include "canotifier.h" |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
#include "canotifierfilter.h" |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
|
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
#include "hsviewappdetailsstate.h" |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
#include "hsmenuevent.h" |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
#include "hsmenuitemmodel.h" |
69 | 34 |
#include "hsmenuentryremovedhandler.h" |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
|
63 | 36 |
static const char *const HS_VIEWAPPDETAILS_JAVA_DIALOG_SECTION_NAME= |
37 |
"detailsDialogForJavaApplication"; |
|
62 | 38 |
|
39 |
/*! |
|
40 |
Constructor. |
|
63 | 41 |
/param parent Parent state. |
62 | 42 |
*/ |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
HsViewAppDetailsState::HsViewAppDetailsState(QState *parent) : |
69 | 44 |
QState(parent), mDialog(0) |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
{ |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
construct(); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
47 |
} |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
|
62 | 49 |
/*! |
50 |
Destructor |
|
51 |
*/ |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
HsViewAppDetailsState::~HsViewAppDetailsState() |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
{ |
69 | 54 |
delete mDialog; |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
} |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
|
62 | 57 |
/*! |
58 |
Construction |
|
59 |
*/ |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
void HsViewAppDetailsState::construct() |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
{ |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::construct"); |
63 | 63 |
|
62 | 64 |
setObjectName("/ViewAppDetailsState"); |
65 |
if (this->parent()) { |
|
66 |
setObjectName(this->parent()->objectName() + objectName()); |
|
67 |
} |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::construct"); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
} |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
|
62 | 71 |
/*! |
72 |
Invoked on entering state |
|
73 |
*/ |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
void HsViewAppDetailsState::onEntry(QEvent *event) |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
{ |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::onEntry"); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
QState::onEntry(event); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
QVariantMap data = menuEvent->data(); |
63 | 80 |
|
81 | 81 |
const int entryId = data.value(Hs::itemIdKey).toInt(); |
63 | 82 |
QSharedPointer<const CaEntry> entry |
62 | 83 |
= CaService::instance()->getEntry(entryId); |
86 | 84 |
if (!entry) { |
85 |
stateExited(); |
|
86 |
return; |
|
87 |
} |
|
62 | 88 |
const int componentId = entry->attribute( |
81 | 89 |
Hs::componentIdAttributeName).toInt(); |
86 | 90 |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
QSharedPointer<CaSoftwareRegistry> scr = CaSoftwareRegistry::create(); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
92 |
CaSoftwareRegistry::DetailMap detailMap = scr->entryDetails(componentId); |
63 | 93 |
|
81 | 94 |
QString appType = entry->attribute(Hs::swTypeKey); |
63 | 95 |
|
86 | 96 |
|
63 | 97 |
//TODO: Should we display something In that case? |
98 |
if (detailMap.size() < 1){ |
|
69 | 99 |
stateExited(); |
63 | 100 |
return; |
101 |
} |
|
86 | 102 |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
103 |
HbDocumentLoader loader; |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
104 |
bool loadStatusOk = false; |
63 | 105 |
loader.load(HS_DETAILS_DIALOG_LAYOUT, &loadStatusOk); |
62 | 106 |
Q_ASSERT_X(loadStatusOk, HS_DETAILS_DIALOG_LAYOUT, |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
107 |
"Error while loading docml file."); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
108 |
|
81 | 109 |
if (!appType.compare(Hs::javaSwType)) { |
63 | 110 |
QString section = QString(HS_VIEWAPPDETAILS_JAVA_DIALOG_SECTION_NAME); |
111 |
loader.load(HS_DETAILS_DIALOG_LAYOUT, |
|
112 |
section, &loadStatusOk); |
|
113 |
} |
|
114 |
||
62 | 115 |
mDialog = qobject_cast<HbDialog*>( |
116 |
loader.findWidget(HS_DETAILS_DIALOG_NAME)); |
|
117 |
||
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
118 |
if (mDialog != NULL) { |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
119 |
mDialog->setTimeout(HbPopup::NoTimeout); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
120 |
mDialog->setAttribute(Qt::WA_DeleteOnClose, true); |
63 | 121 |
mDialog->actions()[0]->setParent(mDialog); |
86 | 122 |
|
63 | 123 |
setFieldPresentation(CaSoftwareRegistry::componentNameKey(), |
124 |
detailMap, loader); |
|
125 |
setFieldPresentation(CaSoftwareRegistry::componentVersionKey(), |
|
126 |
detailMap, loader); |
|
127 |
setFieldPresentation(CaSoftwareRegistry::componentVendorKey(), |
|
128 |
detailMap, loader); |
|
129 |
setFieldPresentation(CaSoftwareRegistry::componentDriveInfoKey(), |
|
130 |
detailMap, loader); |
|
131 |
setFieldPresentation(CaSoftwareRegistry::componentSizeKey(), |
|
132 |
detailMap, loader); |
|
133 |
setFieldPresentation(CaSoftwareRegistry::componentTypeKey(), |
|
134 |
detailMap, loader); |
|
135 |
||
81 | 136 |
if (!appType.compare(Hs::javaSwType)) { |
63 | 137 |
setFieldPresentation(CaSoftwareRegistry::componentDescriptionKey(), |
138 |
detailMap, loader); |
|
139 |
setFieldPresentation(CaSoftwareRegistry::componentProtectionDomainKey(), |
|
140 |
detailMap, loader); |
|
141 |
} |
|
86 | 142 |
|
69 | 143 |
QScopedPointer<HsMenuEntryRemovedHandler> entryObserver( |
144 |
new HsMenuEntryRemovedHandler(entryId, this, SIGNAL(exit()))); |
|
86 | 145 |
|
69 | 146 |
entryObserver.take()->setParent(mDialog); |
86 | 147 |
|
69 | 148 |
mDialog->open(this, SLOT(stateExited())); |
149 |
} else { |
|
150 |
stateExited(); |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
151 |
} |
63 | 152 |
HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::onEntry"); |
153 |
} |
|
154 |
||
155 |
/*! |
|
156 |
Extracting label from loader and set content of data field. |
|
157 |
Hide label if the is no data to display. |
|
158 |
\param key detail key. |
|
159 |
\param detailMap detail map. |
|
160 |
\param loader session to document loader |
|
161 |
\retval void |
|
162 |
*/ |
|
163 |
void HsViewAppDetailsState::setFieldPresentation(QString key, |
|
164 |
CaSoftwareRegistry::DetailMap &detailMap, |
|
165 |
HbDocumentLoader &loader) |
|
166 |
{ |
|
167 |
HbLabel* dataLabel = qobject_cast<HbLabel*>( |
|
168 |
loader.findWidget(key)); |
|
169 |
QString data = detailMap[key]; |
|
170 |
if (data.isEmpty()) { |
|
171 |
dataLabel->setVisible(false); |
|
172 |
dataLabel->setMaximumHeight(0); |
|
173 |
HbLabel* titleLabel = qobject_cast<HbLabel*>( |
|
174 |
loader.findWidget(QString("_") + key)); |
|
175 |
titleLabel->setVisible(false); |
|
176 |
titleLabel->setMaximumHeight(0); |
|
177 |
} else { |
|
178 |
dataLabel->setPlainText(data); |
|
179 |
} |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
180 |
} |
62 | 181 |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
182 |
/*! |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
183 |
Slot invoked when a state is exited. |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
184 |
*/ |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
185 |
void HsViewAppDetailsState::stateExited() |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
186 |
{ |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
187 |
HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::stateExited"); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
188 |
emit exit(); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
189 |
HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::stateExited"); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
190 |
qDebug("HsViewAppDetailsState::stateExited()"); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
191 |
} |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
192 |
|
62 | 193 |
/*! |
194 |
Invoked on exiting state |
|
195 |
*/ |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
196 |
void HsViewAppDetailsState::onExit(QEvent *event) |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
197 |
{ |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
198 |
QState::onExit(event); |
62 | 199 |
// Close popups if App key was pressed or |
200 |
// memory card removed |
|
69 | 201 |
if (mDialog != NULL) { |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
202 |
mDialog->close(); |
69 | 203 |
mDialog = NULL; |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
204 |
} |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
205 |
} |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
206 |