author | hgs |
Mon, 20 Sep 2010 10:19:07 +0300 | |
changeset 90 | 3ac3aaebaee5 |
parent 86 | e4f038c420f7 |
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" |
90 | 34 |
#include "hsdialogcontroller.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) : |
90 | 44 |
QState(parent) |
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 |
{ |
90 | 54 |
QT_TRY { |
55 |
emit exit(); |
|
56 |
} QT_CATCH (...) { |
|
57 |
} |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
} |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
|
62 | 60 |
/*! |
61 |
Construction |
|
62 |
*/ |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
void HsViewAppDetailsState::construct() |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
64 |
{ |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::construct"); |
63 | 66 |
|
62 | 67 |
setObjectName("/ViewAppDetailsState"); |
68 |
if (this->parent()) { |
|
69 |
setObjectName(this->parent()->objectName() + objectName()); |
|
70 |
} |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::construct"); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
} |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
|
62 | 74 |
/*! |
75 |
Invoked on entering state |
|
76 |
*/ |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
void HsViewAppDetailsState::onEntry(QEvent *event) |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
{ |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::onEntry"); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
QState::onEntry(event); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
81 |
HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
82 |
QVariantMap data = menuEvent->data(); |
63 | 83 |
|
81 | 84 |
const int entryId = data.value(Hs::itemIdKey).toInt(); |
63 | 85 |
QSharedPointer<const CaEntry> entry |
62 | 86 |
= CaService::instance()->getEntry(entryId); |
86 | 87 |
if (!entry) { |
90 | 88 |
emit exit(); |
86 | 89 |
return; |
90 |
} |
|
62 | 91 |
const int componentId = entry->attribute( |
81 | 92 |
Hs::componentIdAttributeName).toInt(); |
86 | 93 |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
94 |
QSharedPointer<CaSoftwareRegistry> scr = CaSoftwareRegistry::create(); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
95 |
CaSoftwareRegistry::DetailMap detailMap = scr->entryDetails(componentId); |
63 | 96 |
|
81 | 97 |
QString appType = entry->attribute(Hs::swTypeKey); |
63 | 98 |
|
86 | 99 |
|
63 | 100 |
//TODO: Should we display something In that case? |
101 |
if (detailMap.size() < 1){ |
|
90 | 102 |
emit exit(); |
63 | 103 |
return; |
104 |
} |
|
86 | 105 |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
106 |
HbDocumentLoader loader; |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
107 |
bool loadStatusOk = false; |
63 | 108 |
loader.load(HS_DETAILS_DIALOG_LAYOUT, &loadStatusOk); |
62 | 109 |
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
|
110 |
"Error while loading docml file."); |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
111 |
|
81 | 112 |
if (!appType.compare(Hs::javaSwType)) { |
63 | 113 |
QString section = QString(HS_VIEWAPPDETAILS_JAVA_DIALOG_SECTION_NAME); |
114 |
loader.load(HS_DETAILS_DIALOG_LAYOUT, |
|
115 |
section, &loadStatusOk); |
|
116 |
} |
|
117 |
||
90 | 118 |
QScopedPointer<HbDialog> dialog(qobject_cast<HbDialog*>( |
119 |
loader.findWidget(HS_DETAILS_DIALOG_NAME))); |
|
62 | 120 |
|
90 | 121 |
if (!dialog.isNull()) { |
122 |
dialog->setTimeout(HbPopup::NoTimeout); |
|
123 |
dialog->actions()[0]->setParent(dialog.data()); |
|
86 | 124 |
|
63 | 125 |
setFieldPresentation(CaSoftwareRegistry::componentNameKey(), |
126 |
detailMap, loader); |
|
127 |
setFieldPresentation(CaSoftwareRegistry::componentVersionKey(), |
|
128 |
detailMap, loader); |
|
129 |
setFieldPresentation(CaSoftwareRegistry::componentVendorKey(), |
|
130 |
detailMap, loader); |
|
131 |
setFieldPresentation(CaSoftwareRegistry::componentDriveInfoKey(), |
|
132 |
detailMap, loader); |
|
133 |
setFieldPresentation(CaSoftwareRegistry::componentSizeKey(), |
|
134 |
detailMap, loader); |
|
135 |
setFieldPresentation(CaSoftwareRegistry::componentTypeKey(), |
|
136 |
detailMap, loader); |
|
137 |
||
81 | 138 |
if (!appType.compare(Hs::javaSwType)) { |
63 | 139 |
setFieldPresentation(CaSoftwareRegistry::componentDescriptionKey(), |
140 |
detailMap, loader); |
|
141 |
setFieldPresentation(CaSoftwareRegistry::componentProtectionDomainKey(), |
|
142 |
detailMap, loader); |
|
143 |
} |
|
86 | 144 |
|
90 | 145 |
QScopedPointer<HsDialogController> dialogController( |
146 |
new HsDialogController(dialog.take(), |
|
147 |
HsMenuDialogFactory::acceptActionIndex(), |
|
148 |
HsMenuDialogFactory::rejectActionIndex())); |
|
86 | 149 |
|
90 | 150 |
connect(dialogController.data(), |
151 |
SIGNAL(dialogCompleted()), |
|
152 |
this, |
|
153 |
SIGNAL(exit())); |
|
86 | 154 |
|
90 | 155 |
// ensure dialog is dismissed on app key pressed |
156 |
connect(this, SIGNAL(exited()), |
|
157 |
dialogController.data(), |
|
158 |
SLOT(dismissDialog())); |
|
159 |
||
160 |
dialogController.take()->openDialog(entryId); |
|
69 | 161 |
} else { |
90 | 162 |
emit exit(); |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
163 |
} |
63 | 164 |
HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::onEntry"); |
165 |
} |
|
166 |
||
167 |
/*! |
|
168 |
Extracting label from loader and set content of data field. |
|
169 |
Hide label if the is no data to display. |
|
170 |
\param key detail key. |
|
171 |
\param detailMap detail map. |
|
172 |
\param loader session to document loader |
|
173 |
\retval void |
|
174 |
*/ |
|
175 |
void HsViewAppDetailsState::setFieldPresentation(QString key, |
|
176 |
CaSoftwareRegistry::DetailMap &detailMap, |
|
177 |
HbDocumentLoader &loader) |
|
178 |
{ |
|
179 |
HbLabel* dataLabel = qobject_cast<HbLabel*>( |
|
180 |
loader.findWidget(key)); |
|
181 |
QString data = detailMap[key]; |
|
182 |
if (data.isEmpty()) { |
|
183 |
dataLabel->setVisible(false); |
|
184 |
dataLabel->setMaximumHeight(0); |
|
185 |
HbLabel* titleLabel = qobject_cast<HbLabel*>( |
|
186 |
loader.findWidget(QString("_") + key)); |
|
187 |
titleLabel->setVisible(false); |
|
188 |
titleLabel->setMaximumHeight(0); |
|
189 |
} else { |
|
190 |
dataLabel->setPlainText(data); |
|
191 |
} |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
192 |
} |
62 | 193 |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
194 |
|
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
195 |