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"
|
|
26 |
|
|
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) :
|
|
39 |
QState(parent),
|
|
40 |
mInstalationLogDialog(NULL)
|
|
41 |
{
|
|
42 |
construct();
|
|
43 |
}
|
|
44 |
|
|
45 |
/*!
|
|
46 |
Destructor.
|
|
47 |
*/
|
|
48 |
HsInstallationLogState::~HsInstallationLogState()
|
|
49 |
{
|
|
50 |
cleanUp(); // in case of throw
|
|
51 |
}
|
|
52 |
|
|
53 |
/*!
|
|
54 |
Constructs contained objects.
|
|
55 |
*/
|
|
56 |
void HsInstallationLogState::construct()
|
|
57 |
{
|
|
58 |
setObjectName("/InstallationLogState");
|
|
59 |
if (this->parent()) {
|
|
60 |
setObjectName(this->parent()->objectName() + objectName());
|
|
61 |
}
|
|
62 |
connect(this, SIGNAL(exited()), SLOT(cleanUp()));
|
|
63 |
}
|
|
64 |
|
|
65 |
/*!
|
|
66 |
Sets entry event.
|
|
67 |
\param event entry event.
|
|
68 |
*/
|
|
69 |
void HsInstallationLogState::onEntry(QEvent *event)
|
|
70 |
{
|
|
71 |
HSMENUTEST_FUNC_ENTRY("HsInstallationLogState::onEntry");
|
|
72 |
QState::onEntry(event);
|
|
73 |
qDebug("HsInstallationLogState::onEntry()");
|
|
74 |
|
|
75 |
createInstallationLogDialog();
|
|
76 |
|
|
77 |
HSMENUTEST_FUNC_EXIT("HsInstallationLogState::onEntry");
|
|
78 |
}
|
|
79 |
|
|
80 |
/*!
|
|
81 |
Invoked on exiting state
|
|
82 |
*/
|
|
83 |
void HsInstallationLogState::onExit(QEvent *event)
|
|
84 |
{
|
|
85 |
QState::onExit(event);
|
|
86 |
}
|
|
87 |
|
|
88 |
/*!
|
|
89 |
Create installation log dialog.
|
|
90 |
\retval void
|
|
91 |
*/
|
|
92 |
void HsInstallationLogState::createInstallationLogDialog()
|
|
93 |
{
|
|
94 |
QList<CaSoftwareRegistry::DetailMap> detailsList =
|
|
95 |
CaSoftwareRegistry::create()->retrieveLogEntries();
|
|
96 |
|
|
97 |
HbDocumentLoader loader;
|
|
98 |
bool loadStatusOk = false;
|
|
99 |
loader.load(HS_INSTALLATION_LOG_DIALOG_LAYOUT, &loadStatusOk);
|
|
100 |
Q_ASSERT_X(loadStatusOk, HS_INSTALLATION_LOG_DIALOG_LAYOUT,
|
|
101 |
"Error while loading docml file.");
|
|
102 |
|
|
103 |
mInstalationLogDialog = qobject_cast<HbDialog*>(
|
|
104 |
loader.findWidget(HS_INSTALLATION_LOG_DIALOG_NAME));
|
|
105 |
|
|
106 |
if (mInstalationLogDialog != NULL) {
|
|
107 |
mInstalationLogDialog->actions()[0]->setParent(mInstalationLogDialog);
|
|
108 |
mInstalationLogDialog->setTimeout(HbPopup::NoTimeout);
|
|
109 |
mInstalationLogDialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
110 |
|
|
111 |
HbLabel* logList;
|
|
112 |
QString applicationsList;
|
|
113 |
QString listElement("%1 (%2)\n%3 - ");
|
|
114 |
QString applicationName;
|
|
115 |
QString version;
|
|
116 |
QString date;
|
|
117 |
QString type;
|
|
118 |
QString installed(hbTrId("txt_applib_dialog_installed"));
|
|
119 |
QString removed(hbTrId("txt_applib_dialog_removed"));
|
|
120 |
QString newLine("\n");
|
|
121 |
|
|
122 |
logList = qobject_cast<HbLabel*>(
|
|
123 |
loader.findWidget(HS_INSTALLATION_LOG_DIALOG_LOG_LABEL));
|
|
124 |
|
|
125 |
for (int i=0; i<detailsList.count(); i++) {
|
|
126 |
applicationName = detailsList[i].value(CaSoftwareRegistry::componentNameKey());
|
|
127 |
version = detailsList[i].value(CaSoftwareRegistry::componentVersionKey());
|
|
128 |
date = detailsList[i].value(CaSoftwareRegistry::componentTimeKey());
|
|
129 |
QString localListElement(listElement);
|
|
130 |
localListElement = localListElement.arg(applicationName).arg(version).arg(date);
|
|
131 |
type = detailsList[i].value(CaSoftwareRegistry::componentOperationTypeKey());
|
|
132 |
if ((type.compare(CaSoftwareRegistry::componentInstallValue()) == 0) ||
|
|
133 |
(type.compare(CaSoftwareRegistry::componentUpgradeValue()) == 0)) {
|
|
134 |
localListElement = localListElement + installed;
|
|
135 |
applicationsList = applicationsList + localListElement +
|
|
136 |
newLine + newLine;
|
|
137 |
} else if (type.compare(CaSoftwareRegistry::componentUninstallValue()) == 0) {
|
|
138 |
localListElement = localListElement + removed;
|
|
139 |
applicationsList = applicationsList + localListElement +
|
|
140 |
newLine + newLine;
|
|
141 |
}
|
|
142 |
}
|
69
|
143 |
|
|
144 |
applicationsList.chop(2 * newLine.size());
|
63
|
145 |
logList->setPlainText(applicationsList);
|
|
146 |
|
|
147 |
mInstalationLogDialog->open(this, SLOT(stateExited()));
|
|
148 |
}
|
|
149 |
}
|
|
150 |
|
|
151 |
void HsInstallationLogState::stateExited()
|
|
152 |
{
|
|
153 |
mInstalationLogDialog = NULL;
|
|
154 |
emit exit();
|
|
155 |
}
|
|
156 |
|
|
157 |
/*!
|
|
158 |
Slot launched after state has exited and in destructor.
|
|
159 |
\retval void
|
|
160 |
*/
|
|
161 |
void HsInstallationLogState::cleanUp()
|
|
162 |
{
|
|
163 |
// Close popups if App key was pressed
|
|
164 |
if (mInstalationLogDialog) {
|
|
165 |
mInstalationLogDialog->close();
|
|
166 |
mInstalationLogDialog = NULL;
|
|
167 |
}
|
|
168 |
}
|
|
169 |
|