63
|
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: Menu delete collection item state
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <HbDocumentLoader>
|
|
19 |
#include <HbLabel>
|
|
20 |
#include <HbMessageBox>
|
|
21 |
#include <QAction>
|
|
22 |
#include <hsmenuservice.h>
|
|
23 |
#include <casoftwareregistry.h>
|
|
24 |
|
|
25 |
#include "hsinstallationlogstate.h"
|
90
|
26 |
#include "hsdialogcontroller.h"
|
63
|
27 |
/*!
|
|
28 |
\class HsInstallationLogState
|
|
29 |
\ingroup group_hsworkerstateplugin
|
|
30 |
\brief Uninstall Item State.
|
|
31 |
Deletes app from collection.
|
|
32 |
*/
|
|
33 |
|
|
34 |
/*!
|
|
35 |
Constructor.
|
|
36 |
\param parent Parent state.
|
|
37 |
*/
|
|
38 |
HsInstallationLogState::HsInstallationLogState(QState *parent) :
|
90
|
39 |
QState(parent)
|
63
|
40 |
{
|
|
41 |
construct();
|
|
42 |
}
|
|
43 |
|
|
44 |
/*!
|
|
45 |
Destructor.
|
|
46 |
*/
|
|
47 |
HsInstallationLogState::~HsInstallationLogState()
|
|
48 |
{
|
90
|
49 |
QT_TRY {
|
|
50 |
emit exit();
|
|
51 |
} QT_CATCH (...) {
|
|
52 |
}
|
63
|
53 |
}
|
|
54 |
|
|
55 |
/*!
|
|
56 |
Constructs contained objects.
|
|
57 |
*/
|
|
58 |
void HsInstallationLogState::construct()
|
|
59 |
{
|
|
60 |
setObjectName("/InstallationLogState");
|
|
61 |
if (this->parent()) {
|
|
62 |
setObjectName(this->parent()->objectName() + objectName());
|
|
63 |
}
|
|
64 |
}
|
|
65 |
|
|
66 |
/*!
|
|
67 |
Sets entry event.
|
|
68 |
\param event entry event.
|
|
69 |
*/
|
|
70 |
void HsInstallationLogState::onEntry(QEvent *event)
|
|
71 |
{
|
|
72 |
HSMENUTEST_FUNC_ENTRY("HsInstallationLogState::onEntry");
|
|
73 |
QState::onEntry(event);
|
|
74 |
qDebug("HsInstallationLogState::onEntry()");
|
|
75 |
|
|
76 |
createInstallationLogDialog();
|
|
77 |
|
|
78 |
HSMENUTEST_FUNC_EXIT("HsInstallationLogState::onEntry");
|
|
79 |
}
|
|
80 |
|
|
81 |
|
|
82 |
/*!
|
|
83 |
Create installation log dialog.
|
|
84 |
\retval void
|
|
85 |
*/
|
|
86 |
void HsInstallationLogState::createInstallationLogDialog()
|
|
87 |
{
|
|
88 |
QList<CaSoftwareRegistry::DetailMap> detailsList =
|
|
89 |
CaSoftwareRegistry::create()->retrieveLogEntries();
|
|
90 |
|
|
91 |
HbDocumentLoader loader;
|
|
92 |
bool loadStatusOk = false;
|
|
93 |
loader.load(HS_INSTALLATION_LOG_DIALOG_LAYOUT, &loadStatusOk);
|
|
94 |
Q_ASSERT_X(loadStatusOk, HS_INSTALLATION_LOG_DIALOG_LAYOUT,
|
|
95 |
"Error while loading docml file.");
|
|
96 |
|
90
|
97 |
QScopedPointer<HbDialog> dialog(qobject_cast<HbDialog*>(
|
|
98 |
loader.findWidget(HS_INSTALLATION_LOG_DIALOG_NAME)));
|
63
|
99 |
|
90
|
100 |
if (!dialog.isNull()) {
|
|
101 |
dialog->actions()[0]->setParent(dialog.data());
|
|
102 |
dialog->setTimeout(HbPopup::NoTimeout);
|
|
103 |
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
63
|
104 |
|
|
105 |
HbLabel* logList;
|
|
106 |
QString applicationsList;
|
|
107 |
QString listElement("%1 (%2)\n%3 - ");
|
|
108 |
QString applicationName;
|
|
109 |
QString version;
|
|
110 |
QString date;
|
|
111 |
QString type;
|
|
112 |
QString installed(hbTrId("txt_applib_dialog_installed"));
|
|
113 |
QString removed(hbTrId("txt_applib_dialog_removed"));
|
|
114 |
QString newLine("\n");
|
|
115 |
|
|
116 |
logList = qobject_cast<HbLabel*>(
|
|
117 |
loader.findWidget(HS_INSTALLATION_LOG_DIALOG_LOG_LABEL));
|
|
118 |
|
|
119 |
for (int i=0; i<detailsList.count(); i++) {
|
|
120 |
applicationName = detailsList[i].value(CaSoftwareRegistry::componentNameKey());
|
|
121 |
version = detailsList[i].value(CaSoftwareRegistry::componentVersionKey());
|
|
122 |
date = detailsList[i].value(CaSoftwareRegistry::componentTimeKey());
|
|
123 |
QString localListElement(listElement);
|
|
124 |
localListElement = localListElement.arg(applicationName).arg(version).arg(date);
|
|
125 |
type = detailsList[i].value(CaSoftwareRegistry::componentOperationTypeKey());
|
|
126 |
if ((type.compare(CaSoftwareRegistry::componentInstallValue()) == 0) ||
|
|
127 |
(type.compare(CaSoftwareRegistry::componentUpgradeValue()) == 0)) {
|
|
128 |
localListElement = localListElement + installed;
|
|
129 |
applicationsList = applicationsList + localListElement +
|
|
130 |
newLine + newLine;
|
|
131 |
} else if (type.compare(CaSoftwareRegistry::componentUninstallValue()) == 0) {
|
|
132 |
localListElement = localListElement + removed;
|
|
133 |
applicationsList = applicationsList + localListElement +
|
|
134 |
newLine + newLine;
|
|
135 |
}
|
|
136 |
}
|
69
|
137 |
|
|
138 |
applicationsList.chop(2 * newLine.size());
|
63
|
139 |
logList->setPlainText(applicationsList);
|
90
|
140 |
|
|
141 |
|
|
142 |
QScopedPointer<HsDialogController> dialogController(
|
|
143 |
new HsDialogController(dialog.take(),
|
|
144 |
HsMenuDialogFactory::acceptActionIndex(),
|
|
145 |
HsMenuDialogFactory::rejectActionIndex()));
|
|
146 |
|
|
147 |
connect(dialogController.data(),
|
|
148 |
SIGNAL(dialogCompleted()),
|
|
149 |
this,
|
|
150 |
SIGNAL(exit()));
|
|
151 |
|
|
152 |
// ensure dialog is dismissed on app key pressed
|
|
153 |
connect(this, SIGNAL(exited()),
|
|
154 |
dialogController.data(),
|
|
155 |
SLOT(dismissDialog()));
|
|
156 |
|
|
157 |
dialogController.take()->openDialog();
|
63
|
158 |
}
|
|
159 |
}
|
|
160 |
|
|
161 |
|
|
162 |
|