75 setObjectName("/UninstallItemState"); |
83 setObjectName("/UninstallItemState"); |
76 if (this->parent()) { |
84 if (this->parent()) { |
77 setObjectName(this->parent()->objectName() + objectName()); |
85 setObjectName(this->parent()->objectName() + objectName()); |
78 } |
86 } |
79 connect(this, SIGNAL(exited()), SLOT(cleanUp())); |
87 connect(this, SIGNAL(exited()), SLOT(cleanUp())); |
80 |
|
81 } |
88 } |
82 |
89 |
83 /*! |
90 /*! |
84 Sets entry event. |
91 Sets entry event. |
85 \param event entry event. |
92 \param event entry event. |
86 */ |
93 */ |
87 void HsUninstallItemState::onEntry(QEvent *event) |
94 void HsUninstallItemState::onEntry(QEvent *event) |
88 { |
95 { |
89 HSMENUTEST_FUNC_ENTRY("HsUninstallItemState::onEntry"); |
96 HSMENUTEST_FUNC_ENTRY("HsUninstallItemState::onEntry"); |
|
97 qDebug("HsUninstallItemState::onEntry()"); |
|
98 |
90 QState::onEntry(event); |
99 QState::onEntry(event); |
91 qDebug("HsUninstallItemState::onEntry()"); |
100 |
92 HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
101 HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
93 QVariantMap data = menuEvent->data(); |
102 int itemId = menuEvent->data().value(Hs::itemIdKey).toInt(); |
94 |
103 mEntry = CaService::instance()->getEntry(itemId); |
95 mItemId = data.value(Hs::itemIdKey).toInt(); |
104 |
96 QSharedPointer<CaEntry> entry = CaService::instance()->getEntry(mItemId); |
105 if (mEntry) { |
97 QString appType = entry->attribute(Hs::swTypeKey); |
106 QString appType = mEntry->attribute(Hs::swTypeKey); |
98 if (!appType.compare(Hs::javaSwType)) { |
107 |
99 // java |
108 if (!appType.compare(Hs::javaSwType)) { |
100 createUninstallJavaMessage(); |
109 // java |
101 } else { |
110 createUninstallJavaMessage(); |
102 // other |
111 } else { |
103 createSimpleUninstallMessage(); |
112 // other |
104 } |
113 createSimpleUninstallMessage(); |
105 |
114 } |
|
115 } |
106 HSMENUTEST_FUNC_EXIT("HsUninstallItemState::onEntry"); |
116 HSMENUTEST_FUNC_EXIT("HsUninstallItemState::onEntry"); |
107 } |
117 } |
108 |
118 |
109 /*! |
119 /*! |
110 Action after closed confirmation dialog. |
120 Slots. Uninstalls item controlled by the state. |
111 \param finishedAction chosen action. |
121 \retval void |
112 \retval void |
122 */ |
113 */ |
123 #ifdef COVERAGE_MEASUREMENT |
114 void HsUninstallItemState::uninstallMessageFinished(HbAction* finishedAction) |
124 #pragma CTC SKIP |
115 { |
125 #endif //COVERAGE_MEASUREMENT |
116 if (static_cast<QAction*>(finishedAction) == mConfirmAction) { |
126 void HsUninstallItemState::uninstallItem() |
117 |
127 { |
118 HsMenuService::executeAction(mItemId, Hs::removeActionIdentifier, |
128 HsMenuService::executeAction(*mEntry.data(), Hs::removeActionIdentifier, |
119 this, SLOT(uninstallFailed(int))); |
129 this, SLOT(uninstallFailed(int))); |
120 } |
130 } |
121 mConfirmAction = NULL; |
131 #ifdef COVERAGE_MEASUREMENT |
122 mUninstallMessage = NULL; |
132 #pragma CTC ENDSKIP |
123 mUninstallJavaMessage = NULL; |
133 #endif //COVERAGE_MEASUREMENT |
124 emit exit(); |
|
125 } |
|
126 |
134 |
127 /*! |
135 /*! |
128 Return information about a component: component name, a list of names |
136 Return information about a component: component name, a list of names |
129 of applications in this component and a delete message. |
137 of applications in this component and a delete message. |
130 \param[out] componentName component name. |
138 \param[out] componentName component name. |
214 \retval void |
205 \retval void |
215 */ |
206 */ |
216 void HsUninstallItemState::createSimpleUninstallMessage(bool isJava) |
207 void HsUninstallItemState::createSimpleUninstallMessage(bool isJava) |
217 { |
208 { |
218 CaQuery parentsQuery; |
209 CaQuery parentsQuery; |
219 parentsQuery.setChildId(mItemId); |
210 parentsQuery.setChildId(mEntry->id()); |
220 parentsQuery.setEntryTypeNames(QStringList(Hs::collectionTypeName)); |
211 parentsQuery.setEntryTypeNames(QStringList(Hs::collectionTypeName)); |
221 QList<int> parentsIds = CaService::instance()->getEntryIds( |
212 QList<int> parentsIds = CaService::instance()->getEntryIds(parentsQuery); |
222 parentsQuery); |
|
223 QString message; |
213 QString message; |
224 if (HsShortcutService::instance()->isItemShortcutWidget(mItemId) || (parentsIds.count() > 0)) { |
214 if (HsShortcutService::instance()->isItemShortcutWidget(mEntry->id()) |
225 message.append( |
215 || (parentsIds.count() > 0)) { |
226 HbParameterLengthLimiter("txt_applib_dialog_uninstalls_1_and_deletes_all_sh").arg( |
216 message.append(HbParameterLengthLimiter( |
227 HsMenuService::getName(mItemId))); |
217 "txt_applib_dialog_uninstalls_1_and_deletes_all_sh").arg( |
|
218 mEntry->text())); |
228 } else { |
219 } else { |
229 message.append( |
220 message.append(HbParameterLengthLimiter( |
230 HbParameterLengthLimiter("txt_applib_dialog_1_will_be_removed_from_phone_c").arg( |
221 "txt_applib_dialog_1_will_be_removed_from_phone_c").arg( |
231 HsMenuService::getName(mItemId))); |
222 mEntry->text())); |
232 } |
223 } |
233 |
224 |
234 // create and show message box |
225 // create and show message box |
235 mUninstallMessage = HsMenuDialogFactory().create(message); |
226 |
236 if( isJava ){ |
227 QScopedPointer<HbMessageBox> dialog( |
237 QSharedPointer<CaEntry> entry = CaService::instance()->getEntry(mItemId); |
228 HsMenuDialogFactory().create(message)); |
238 HbIcon icon = entry->makeIcon(); |
229 if (isJava){ |
239 mUninstallMessage->setIcon(icon); |
230 dialog->setIcon(mEntry->makeIcon()); |
240 } |
231 } |
241 mConfirmAction = mUninstallMessage->actions().value(0); |
232 |
242 |
233 QScopedPointer<HsDialogController> dialogController( |
243 QScopedPointer<HsMenuEntryRemovedHandler> entryObserver( |
234 new HsDialogController(dialog.take(), |
244 new HsMenuEntryRemovedHandler(mItemId, this, SIGNAL(exit()))); |
235 HsMenuDialogFactory::acceptActionIndex(), |
245 entryObserver.take()->setParent(mUninstallMessage); |
236 HsMenuDialogFactory::rejectActionIndex())); |
246 |
237 |
247 mUninstallMessage->open(this, SLOT(uninstallMessageFinished(HbAction*))); |
238 connect(dialogController.data(), SIGNAL(acceptActionTriggered(QAction*)), |
|
239 this, SLOT(uninstallItem())); |
|
240 |
|
241 connect(dialogController.data(), SIGNAL(dialogCompleted()), |
|
242 this, SIGNAL(exit())); |
|
243 |
|
244 // ensure dialog is dismissed on app key pressed |
|
245 connect(this, SIGNAL(exited()), |
|
246 dialogController.data(), SLOT(dismissDialog())); |
|
247 |
|
248 dialogController.take()->openDialog(mEntry->id()); |
248 } |
249 } |
249 |
250 |
250 /*! |
251 /*! |
251 Method create uninstall confirmation dialog for java. |
252 Method create uninstall confirmation dialog for java. |
252 \retval void |
253 \retval void |
253 */ |
254 */ |
254 void HsUninstallItemState::createUninstallJavaMessage() |
255 void HsUninstallItemState::createUninstallJavaMessage() |
255 { |
256 { |
256 HbDocumentLoader loader; |
|
257 bool loadStatusOk = false; |
|
258 loader.load(HS_UNINSTALL_DIALOG_LAYOUT, &loadStatusOk); |
|
259 |
|
260 Q_ASSERT_X(loadStatusOk, |
|
261 HS_UNINSTALL_DIALOG_LAYOUT, |
|
262 "Error while loading docml file."); |
|
263 |
|
264 QString componentName; |
257 QString componentName; |
265 QStringList applicationsNames; |
258 QStringList applicationsNames; |
266 QString detailsMessage; |
259 QString detailsMessage; |
267 getApplicationsNames(componentName, applicationsNames, detailsMessage); |
260 getApplicationsNames(componentName, applicationsNames, detailsMessage); |
268 |
261 |
|
262 if (applicationsNames.isEmpty() && detailsMessage.isEmpty()) { |
|
263 createSimpleUninstallMessage(true); |
|
264 } else { |
|
265 HbDocumentLoader loader; |
|
266 |
|
267 QString section = loadProperSection(applicationsNames, |
|
268 detailsMessage, loader); |
|
269 if (!section.isNull()) { |
|
270 HbDialog *const dialog = qobject_cast<HbDialog*>( |
|
271 loader.findWidget(HS_UNINSTALL_DIALOG_NAME)); |
|
272 |
|
273 if (dialog) { |
|
274 prepareDialog(dialog); |
|
275 |
|
276 HbLabel* iconLabel = qobject_cast<HbLabel*>(loader.findWidget( |
|
277 HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_ICON)); |
|
278 iconLabel->setIcon(mEntry->makeIcon()); |
|
279 |
|
280 prepareDialogLabel(componentName, loader); |
|
281 |
|
282 if ((section == definition02) || (section == definition04)) { |
|
283 qobject_cast<HbLabel*>( loader.findWidget( |
|
284 HS_UNINSTALL_DIALOG_DELETE_LABEL))->setPlainText( |
|
285 detailsMessage); |
|
286 } |
|
287 |
|
288 if ((section == definition02) || (section == definition03)) { |
|
289 prepareApplicationListLabel(applicationsNames, loader); |
|
290 } |
|
291 |
|
292 QScopedPointer<HsDialogController> dialogController( |
|
293 new HsDialogController( dialog, |
|
294 HsMenuDialogFactory::acceptActionIndex(), |
|
295 HsMenuDialogFactory::rejectActionIndex())); |
|
296 connect(dialogController.data(), SIGNAL(acceptActionTriggered(QAction*)), |
|
297 this, SLOT(uninstallItem())); |
|
298 connect(dialogController.data(), SIGNAL(dialogCompleted()), |
|
299 this, SIGNAL(exit())); |
|
300 connect(this, SIGNAL(exited()), |
|
301 dialogController.data(), SLOT(dismissDialog())); |
|
302 |
|
303 dialogController.take()->openDialog(mEntry->id()); |
|
304 } |
|
305 } |
|
306 } |
|
307 } |
|
308 |
|
309 void HsUninstallItemState::prepareDialogLabel( |
|
310 QString &componentName, HbDocumentLoader &loader) |
|
311 { |
|
312 CaQuery parentsQuery; |
|
313 parentsQuery.setChildId(mEntry->id()); |
|
314 parentsQuery.setEntryTypeNames(QStringList(Hs::collectionTypeName)); |
|
315 QList<int> parentsIds = CaService::instance()->getEntryIds(parentsQuery); |
|
316 |
|
317 HbLabel* textLabel = qobject_cast<HbLabel*>(loader.findWidget( |
|
318 HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_LABEL)); |
|
319 |
|
320 QString plainText; |
|
321 if (HsShortcutService::instance()->isItemShortcutWidget(mEntry->id()) |
|
322 || parentsIds.count()) { |
|
323 plainText = HbParameterLengthLimiter( |
|
324 "txt_applib_info_delete_1_all_its_shortcuts_and").arg( |
|
325 componentName); |
|
326 } else { |
|
327 plainText = HbParameterLengthLimiter( |
|
328 "txt_applib_info_delete_1_and_associated_data").arg( |
|
329 componentName); |
|
330 } |
|
331 textLabel->setPlainText(plainText); |
|
332 } |
|
333 |
|
334 void HsUninstallItemState::prepareApplicationListLabel( |
|
335 QStringList & applicationsNames, HbDocumentLoader & loader) |
|
336 { |
|
337 QString applicationsList; |
|
338 QString newLine("\n"); |
|
339 for(int i = 0;i < applicationsNames.count();i++){ |
|
340 applicationsList += applicationsNames[i] + newLine; |
|
341 } |
|
342 |
|
343 HbLabel *listView; |
|
344 listView = qobject_cast<HbLabel*>(loader.findWidget( |
|
345 HS_UNINSTALL_DIALOG_LIST_VIEW_LABEL)); |
|
346 listView->setPlainText(applicationsList); |
|
347 } |
|
348 |
|
349 QString HsUninstallItemState::loadProperSection( |
|
350 QStringList &applicationsNames, QString &detailsMessage, |
|
351 HbDocumentLoader &loader) |
|
352 { |
269 QString section; |
353 QString section; |
270 if (applicationsNames.isEmpty() && detailsMessage.isEmpty()) { |
354 if (!applicationsNames.isEmpty() && !detailsMessage.isEmpty()) { |
271 createSimpleUninstallMessage(true); |
355 section = QString(definition02); |
272 } |
356 } else if (!applicationsNames.isEmpty() && detailsMessage.isEmpty()) { |
273 else { |
357 section = QString(definition03); |
274 if ( (!applicationsNames.isEmpty()) && (!detailsMessage.isEmpty())) { |
358 }else if (applicationsNames.isEmpty() && !detailsMessage.isEmpty()) { |
275 mDialogType = UninstallDialogDefinition02; |
359 section = QString(definition04); |
276 section = QString("uninstallDialogDefinition02"); |
360 } |
277 loader.load( |
361 if(!section.isNull()){ |
|
362 bool loadStatusOk = false; |
|
363 loader.load(HS_UNINSTALL_DIALOG_LAYOUT, &loadStatusOk); |
|
364 |
|
365 Q_ASSERT_X(loadStatusOk, |
|
366 HS_UNINSTALL_DIALOG_LAYOUT, |
|
367 "Error while loading docml file."); |
|
368 |
|
369 loader.load( |
278 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk); |
370 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk); |
279 } |
371 Q_ASSERT_X(loadStatusOk, |
280 else if ( (!applicationsNames.isEmpty() && detailsMessage.isEmpty())) { |
372 HS_UNINSTALL_DIALOG_LAYOUT, |
281 mDialogType = UninstallDialogDefinition03; |
373 "Error while loading docml file section."); |
282 section = QString("uninstallDialogDefinition03"); |
374 } |
283 loader.load( |
375 return section; |
284 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk); |
376 } |
285 } |
377 |
286 else if (applicationsNames.isEmpty() && (!detailsMessage.isEmpty())) { |
378 HsDialogController *HsUninstallItemState::prepareDialog( |
287 mDialogType = UninstallDialogDefinition04; |
379 HbDialog *dialog) |
288 section = QString("uninstallDialogDefinition04"); |
380 { |
289 loader.load( |
381 dialog->setAttribute(Qt::WA_DeleteOnClose); |
290 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk); |
382 dialog->setTimeout(HbPopup::NoTimeout); |
291 } |
383 dialog->actions()[0]->setParent(dialog); |
292 |
384 dialog->actions()[1]->setParent(dialog); |
293 mUninstallJavaMessage = qobject_cast<HbDialog*>( |
385 return NULL; |
294 loader.findWidget(HS_UNINSTALL_DIALOG_NAME)); |
386 } |
295 |
|
296 if (mUninstallJavaMessage) { |
|
297 mUninstallJavaMessage->setAttribute(Qt::WA_DeleteOnClose); |
|
298 mUninstallJavaMessage->setTimeout(HbPopup::NoTimeout); |
|
299 mUninstallJavaMessage->actions()[0]->setParent(mUninstallJavaMessage); |
|
300 mUninstallJavaMessage->actions()[1]->setParent(mUninstallJavaMessage); |
|
301 |
|
302 HbLabel* iconLabel = |
|
303 qobject_cast<HbLabel*>( |
|
304 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_ICON)); |
|
305 QSharedPointer<CaEntry> entry2 = CaService::instance()->getEntry(mItemId); |
|
306 HbIcon icon = entry2->makeIcon(); |
|
307 iconLabel->setIcon(icon); |
|
308 |
|
309 CaQuery parentsQuery; |
|
310 parentsQuery.setChildId(mItemId); |
|
311 parentsQuery.setEntryTypeNames(QStringList(Hs::collectionTypeName)); |
|
312 QList<int> parentsIds = CaService::instance()->getEntryIds( |
|
313 parentsQuery); |
|
314 |
|
315 HbLabel* textLabel = |
|
316 qobject_cast<HbLabel*>( |
|
317 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_LABEL)); |
|
318 if (HsShortcutService::instance()->isItemShortcutWidget(mItemId) || |
|
319 (parentsIds.count() > 0)) { |
|
320 textLabel->setPlainText(HbParameterLengthLimiter( |
|
321 "txt_applib_info_delete_1_all_its_shortcuts_and").arg( |
|
322 componentName)); |
|
323 } else { |
|
324 textLabel->setPlainText(HbParameterLengthLimiter( |
|
325 "txt_applib_info_delete_1_and_associated_data").arg( |
|
326 componentName)); |
|
327 } |
|
328 |
|
329 HbLabel* detailsUninstalLabel; |
|
330 if ((mDialogType == UninstallDialogDefinition02) || |
|
331 (mDialogType == UninstallDialogDefinition04)) { |
|
332 detailsUninstalLabel= qobject_cast<HbLabel*>( |
|
333 loader.findWidget(HS_UNINSTALL_DIALOG_DELETE_LABEL)); |
|
334 detailsUninstalLabel->setPlainText(detailsMessage); |
|
335 } |
|
336 |
|
337 HbLabel* listView; |
|
338 QString applicationsList; |
|
339 QString newLine("\n"); |
|
340 if ((mDialogType == UninstallDialogDefinition02) || |
|
341 (mDialogType == UninstallDialogDefinition03)) { |
|
342 listView = qobject_cast<HbLabel*>( |
|
343 loader.findWidget(HS_UNINSTALL_DIALOG_LIST_VIEW_LABEL)); |
|
344 |
|
345 for (int i=0; i<applicationsNames.count(); i++) { |
|
346 applicationsList = applicationsList + applicationsNames[i] + newLine; |
|
347 } |
|
348 listView->setPlainText(applicationsList); |
|
349 } |
|
350 |
|
351 mConfirmAction = qobject_cast<HbAction*>(loader.findObject( |
|
352 HS_UNINSTALL_DIALOG_CONFIRMATION_ACTION)); |
|
353 |
|
354 QScopedPointer<HsMenuEntryRemovedHandler> entryObserver( |
|
355 new HsMenuEntryRemovedHandler(mItemId, this, SIGNAL(exit()))); |
|
356 entryObserver.take()->setParent(mUninstallJavaMessage); |
|
357 |
|
358 mUninstallJavaMessage->open(this, SLOT(uninstallMessageFinished(HbAction*))); |
|
359 } |
|
360 } |
|
361 } |
|