22 #include <HbDocumentLoader> |
22 #include <HbDocumentLoader> |
23 #include <HbLabel> |
23 #include <HbLabel> |
24 #include <HbListView> |
24 #include <HbListView> |
25 #include <HbParameterLengthLimiter> |
25 #include <HbParameterLengthLimiter> |
26 |
26 |
27 |
27 #include <QScopedPointer> |
28 #include <QStandardItemModel> |
28 #include <QStandardItemModel> |
29 #include <QStandardItem> |
29 #include <QStandardItem> |
30 #include <casoftwareregistry.h> |
30 #include <casoftwareregistry.h> |
31 #include <caquery.h> |
31 #include <caquery.h> |
32 #include <canotifier.h> |
32 #include <canotifier.h> |
33 |
33 |
34 #include "hsuninstallitemstate.h" |
34 #include "hsuninstallitemstate.h" |
35 #include "hsmenuevent.h" |
35 #include "hsmenuevent.h" |
36 #include "hsmenudialogfactory.h" |
36 #include "hsmenudialogfactory.h" |
37 |
37 #include "hsmenuentryremovedhandler.h" |
38 /*! |
38 /*! |
39 \class HsUninstallItemState |
39 \class HsUninstallItemState |
40 \ingroup group_hsworkerstateplugin |
40 \ingroup group_hsworkerstateplugin |
41 \brief Uninstall Item State. |
41 \brief Uninstall Item State. |
42 Deletes app from collection. |
42 Deletes app from collection. |
163 } |
163 } |
164 } |
164 } |
165 return retval; |
165 return retval; |
166 } |
166 } |
167 |
167 |
168 /*! |
|
169 Subscribe for memory card remove. |
|
170 */ |
|
171 void HsUninstallItemState::subscribeForMemoryCardRemove() |
|
172 { |
|
173 CaNotifierFilter filter; |
|
174 filter.setIds(QList<int>() << mItemId); |
|
175 mNotifier = CaService::instance()->createNotifier(filter); |
|
176 mNotifier->setParent(this); |
|
177 connect(mNotifier, |
|
178 SIGNAL(entryChanged(CaEntry,ChangeType)), |
|
179 SIGNAL(exit())); |
|
180 } |
|
181 |
168 |
182 /*! |
169 /*! |
183 Slot launched after state has exited and in destructor. |
170 Slot launched after state has exited and in destructor. |
184 \retval void |
171 \retval void |
185 */ |
172 */ |
186 void HsUninstallItemState::cleanUp() |
173 void HsUninstallItemState::cleanUp() |
187 { |
174 { |
188 // Close messagebox if App key was pressed |
175 // Close messagebox if App key was pressed |
189 if (mUninstallMessage) { |
176 if (mUninstallMessage != NULL) { |
190 disconnect(mUninstallMessage, SIGNAL(finished(HbAction*)), |
|
191 this, SLOT(uninstallMessageFinished(HbAction*))); |
|
192 mUninstallMessage->close(); |
177 mUninstallMessage->close(); |
193 mUninstallMessage = NULL; |
178 mUninstallMessage = NULL; |
194 } |
179 } |
195 |
180 |
196 if (mUninstallJavaMessage) { |
181 if (mUninstallJavaMessage != NULL) { |
197 disconnect(mUninstallJavaMessage, SIGNAL(finished(HbAction*)), this, SLOT(uninstallMessageFinished(HbAction*))); |
|
198 mUninstallJavaMessage->close(); |
182 mUninstallJavaMessage->close(); |
199 mUninstallJavaMessage = NULL; |
183 mUninstallJavaMessage = NULL; |
200 } |
184 } |
201 |
185 |
202 delete mNotifier; |
|
203 mNotifier = NULL; |
|
204 mConfirmAction = NULL; |
186 mConfirmAction = NULL; |
205 mItemId = 0; |
187 mItemId = 0; |
206 } |
188 } |
207 |
189 |
208 /*! |
190 /*! |
228 } |
210 } |
229 |
211 |
230 // create and show message box |
212 // create and show message box |
231 mUninstallMessage = HsMenuDialogFactory().create(message); |
213 mUninstallMessage = HsMenuDialogFactory().create(message); |
232 mConfirmAction = mUninstallMessage->actions().value(0); |
214 mConfirmAction = mUninstallMessage->actions().value(0); |
|
215 |
|
216 QScopedPointer<HsMenuEntryRemovedHandler> entryObserver( |
|
217 new HsMenuEntryRemovedHandler(mItemId, this, SIGNAL(exit()))); |
|
218 entryObserver.take()->setParent(mUninstallMessage); |
|
219 |
|
220 mUninstallMessage->open(this, SLOT(uninstallMessageFinished(HbAction*))); |
|
221 } |
|
222 |
|
223 /*! |
|
224 Method create uninstall confirmation message. |
|
225 Used for java applications without deletion confirmation |
|
226 and with midlet name equal to app name |
|
227 \retval void |
|
228 */ |
|
229 void HsUninstallItemState::createSimpleUninstallJavaMessage() |
|
230 { |
|
231 QString message; |
|
232 message.append( |
|
233 HbParameterLengthLimiter("txt_applib_info_remove_1_all_its_shortcuts_and").arg( |
|
234 HsMenuService::getName(mItemId))); |
|
235 |
|
236 // create and show message box |
|
237 mUninstallMessage = HsMenuDialogFactory().create(message); |
|
238 |
|
239 QSharedPointer<CaEntry> entry = CaService::instance()->getEntry(mItemId); |
|
240 HbIcon icon = entry->makeIcon(); |
|
241 mUninstallMessage->setIcon(icon); |
|
242 mConfirmAction = mUninstallMessage->actions().value(0); |
|
243 |
|
244 QScopedPointer<HsMenuEntryRemovedHandler> entryObserver( |
|
245 new HsMenuEntryRemovedHandler(mItemId, this, SIGNAL(exit()))); |
|
246 entryObserver.take()->setParent(mUninstallMessage); |
|
247 |
233 mUninstallMessage->open(this, SLOT(uninstallMessageFinished(HbAction*))); |
248 mUninstallMessage->open(this, SLOT(uninstallMessageFinished(HbAction*))); |
234 } |
249 } |
235 |
250 |
236 /*! |
251 /*! |
237 Method create uninstall confirmation dialog for java. |
252 Method create uninstall confirmation dialog for java. |
251 QStringList applicationsNames; |
266 QStringList applicationsNames; |
252 QString detailsMessage; |
267 QString detailsMessage; |
253 getApplicationsNames(componentName, applicationsNames, detailsMessage); |
268 getApplicationsNames(componentName, applicationsNames, detailsMessage); |
254 |
269 |
255 QString section; |
270 QString section; |
256 if (applicationsNames.isEmpty() && detailsMessage.isEmpty()) { |
271 if (applicationsNames.isEmpty() && detailsMessage.isEmpty()) { |
257 mDialogType = UninstallDialogDefinition01; |
272 createSimpleUninstallJavaMessage(); |
258 section = QString("uninstallDialogDefinition01"); |
273 } |
259 loader.load( |
274 else { |
|
275 if ( (!applicationsNames.isEmpty()) && (!detailsMessage.isEmpty())) { |
|
276 mDialogType = UninstallDialogDefinition02; |
|
277 section = QString("uninstallDialogDefinition02"); |
|
278 loader.load( |
260 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk); |
279 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk); |
261 } else if ( (!applicationsNames.isEmpty()) && (!detailsMessage.isEmpty())) { |
280 } |
262 mDialogType = UninstallDialogDefinition02; |
281 else if ( (!applicationsNames.isEmpty() && detailsMessage.isEmpty())) { |
263 section = QString("uninstallDialogDefinition02"); |
282 mDialogType = UninstallDialogDefinition03; |
264 loader.load( |
283 section = QString("uninstallDialogDefinition03"); |
|
284 loader.load( |
265 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk); |
285 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk); |
266 } else if ( (!applicationsNames.isEmpty() && detailsMessage.isEmpty())) { |
286 } |
267 mDialogType = UninstallDialogDefinition03; |
287 else if (applicationsNames.isEmpty() && (!detailsMessage.isEmpty())) { |
268 section = QString("uninstallDialogDefinition03"); |
288 mDialogType = UninstallDialogDefinition04; |
269 loader.load( |
289 section = QString("uninstallDialogDefinition04"); |
|
290 loader.load( |
270 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk); |
291 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk); |
271 } else if (applicationsNames.isEmpty() && (!detailsMessage.isEmpty())) { |
292 } |
272 mDialogType = UninstallDialogDefinition04; |
293 |
273 section = QString("uninstallDialogDefinition04"); |
294 mUninstallJavaMessage = qobject_cast<HbDialog*>( |
274 loader.load( |
|
275 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk); |
|
276 } |
|
277 |
|
278 mUninstallJavaMessage = |
|
279 qobject_cast<HbDialog*>( |
|
280 loader.findWidget(HS_UNINSTALL_DIALOG_NAME)); |
295 loader.findWidget(HS_UNINSTALL_DIALOG_NAME)); |
281 if (mUninstallJavaMessage != NULL) { |
296 |
282 mUninstallJavaMessage->setAttribute(Qt::WA_DeleteOnClose); |
297 if (mUninstallJavaMessage) { |
283 mUninstallJavaMessage->setTimeout(HbPopup::NoTimeout); |
298 mUninstallJavaMessage->setAttribute(Qt::WA_DeleteOnClose); |
284 mUninstallJavaMessage->actions()[0]->setParent(mUninstallJavaMessage); |
299 mUninstallJavaMessage->setTimeout(HbPopup::NoTimeout); |
285 mUninstallJavaMessage->actions()[1]->setParent(mUninstallJavaMessage); |
300 mUninstallJavaMessage->actions()[0]->setParent(mUninstallJavaMessage); |
286 |
301 mUninstallJavaMessage->actions()[1]->setParent(mUninstallJavaMessage); |
287 HbLabel* iconLabel = |
302 |
|
303 HbLabel* iconLabel = |
288 qobject_cast<HbLabel*>( |
304 qobject_cast<HbLabel*>( |
289 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_ICON)); |
305 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_ICON)); |
290 QSharedPointer<CaEntry> entry2 = CaService::instance()->getEntry(mItemId); |
306 QSharedPointer<CaEntry> entry2 = CaService::instance()->getEntry(mItemId); |
291 HbIcon icon = entry2->makeIcon(); |
307 HbIcon icon = entry2->makeIcon(); |
292 iconLabel->setIcon(icon); |
308 iconLabel->setIcon(icon); |
293 |
309 |
294 HbLabel* textLabel = |
310 HbLabel* textLabel = |
295 qobject_cast<HbLabel*>( |
311 qobject_cast<HbLabel*>( |
296 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_LABEL)); |
312 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_LABEL)); |
297 textLabel->setPlainText(textLabel->plainText().arg(componentName)); |
313 textLabel->setPlainText(textLabel->plainText().arg(componentName)); |
298 |
314 |
299 HbLabel* detailsUninstalLabel; |
315 HbLabel* detailsUninstalLabel; |
300 if ((mDialogType == UninstallDialogDefinition02) || |
316 if ((mDialogType == UninstallDialogDefinition02) || |
301 (mDialogType == UninstallDialogDefinition04)) { |
317 (mDialogType == UninstallDialogDefinition04)) { |
302 detailsUninstalLabel= qobject_cast<HbLabel*>( |
318 detailsUninstalLabel= qobject_cast<HbLabel*>( |
303 loader.findWidget(HS_UNINSTALL_DIALOG_DELETE_LABEL)); |
319 loader.findWidget(HS_UNINSTALL_DIALOG_DELETE_LABEL)); |
304 detailsUninstalLabel->setPlainText(detailsMessage); |
320 detailsUninstalLabel->setPlainText(detailsMessage); |
305 } |
321 } |
306 |
322 |
307 HbLabel* listView; |
323 HbLabel* listView; |
308 QString applicationsList; |
324 QString applicationsList; |
309 QString newLine("\n"); |
325 QString newLine("\n"); |
310 if ((mDialogType == UninstallDialogDefinition02) || |
326 if ((mDialogType == UninstallDialogDefinition02) || |
311 (mDialogType == UninstallDialogDefinition03)) { |
327 (mDialogType == UninstallDialogDefinition03)) { |
312 listView = qobject_cast<HbLabel*>( |
328 listView = qobject_cast<HbLabel*>( |
313 loader.findWidget(HS_UNINSTALL_DIALOG_LIST_VIEW_LABEL)); |
329 loader.findWidget(HS_UNINSTALL_DIALOG_LIST_VIEW_LABEL)); |
314 |
330 |
315 for (int i=0; i<applicationsNames.count(); i++) { |
331 for (int i=0; i<applicationsNames.count(); i++) { |
316 applicationsList = applicationsList + applicationsNames[i] + newLine; |
332 applicationsList = applicationsList + applicationsNames[i] + newLine; |
|
333 } |
|
334 listView->setPlainText(applicationsList); |
317 } |
335 } |
318 listView->setPlainText(applicationsList); |
336 |
319 } |
337 mConfirmAction = qobject_cast<HbAction*>(loader.findObject( |
320 |
338 HS_UNINSTALL_DIALOG_CONFIRMATION_ACTION)); |
321 mConfirmAction = qobject_cast<HbAction*>(loader.findObject( |
339 |
322 HS_UNINSTALL_DIALOG_CONFIRMATION_ACTION)); |
340 QScopedPointer<HsMenuEntryRemovedHandler> entryObserver( |
323 |
341 new HsMenuEntryRemovedHandler(mItemId, this, SIGNAL(exit()))); |
324 mUninstallJavaMessage->open(this, SLOT(uninstallMessageFinished(HbAction*))); |
342 entryObserver.take()->setParent(mUninstallJavaMessage); |
325 } |
343 |
326 } |
344 mUninstallJavaMessage->open(this, SLOT(uninstallMessageFinished(HbAction*))); |
|
345 } |
|
346 } |
|
347 } |