87 QState::onEntry(event); |
87 QState::onEntry(event); |
88 qDebug("HsUninstallItemState::onEntry()"); |
88 qDebug("HsUninstallItemState::onEntry()"); |
89 HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
89 HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
90 QVariantMap data = menuEvent->data(); |
90 QVariantMap data = menuEvent->data(); |
91 |
91 |
92 mItemId = data.value(itemIdKey()).toInt(); |
92 mItemId = data.value(Hs::itemIdKey).toInt(); |
93 QSharedPointer<CaEntry> entry = CaService::instance()->getEntry(mItemId); |
93 QSharedPointer<CaEntry> entry = CaService::instance()->getEntry(mItemId); |
94 QString appType = entry->attribute(swTypeKey()); |
94 QString appType = entry->attribute(Hs::swTypeKey); |
95 if (!appType.compare(javaSwType())) { |
95 if (!appType.compare(Hs::javaSwType)) { |
96 // java |
96 // java |
97 createUninstallJavaMessage(); |
97 createUninstallJavaMessage(); |
98 } else { |
98 } else { |
99 // other |
99 // other |
100 createUninstallMessage(); |
100 createSimpleUninstallMessage(); |
101 } |
101 } |
102 |
102 |
103 HSMENUTEST_FUNC_EXIT("HsUninstallItemState::onEntry"); |
103 HSMENUTEST_FUNC_EXIT("HsUninstallItemState::onEntry"); |
104 } |
104 } |
105 |
105 |
109 \retval void |
109 \retval void |
110 */ |
110 */ |
111 void HsUninstallItemState::uninstallMessageFinished(HbAction* finishedAction) |
111 void HsUninstallItemState::uninstallMessageFinished(HbAction* finishedAction) |
112 { |
112 { |
113 if (static_cast<QAction*>(finishedAction) == mConfirmAction) { |
113 if (static_cast<QAction*>(finishedAction) == mConfirmAction) { |
114 HsMenuService::executeAction(mItemId, removeActionIdentifier()); |
114 HsMenuService::executeAction(mItemId, Hs::removeActionIdentifier); |
115 } |
115 } |
116 mConfirmAction = NULL; |
116 mConfirmAction = NULL; |
117 mUninstallMessage = NULL; |
117 mUninstallMessage = NULL; |
118 mUninstallJavaMessage = NULL; |
118 mUninstallJavaMessage = NULL; |
119 emit exit(); |
119 emit exit(); |
136 confirmationMessage.clear(); |
136 confirmationMessage.clear(); |
137 |
137 |
138 QSharedPointer<CaService> service = CaService::instance(); |
138 QSharedPointer<CaService> service = CaService::instance(); |
139 QSharedPointer<CaEntry> entry = service->getEntry(mItemId); |
139 QSharedPointer<CaEntry> entry = service->getEntry(mItemId); |
140 const int componentId = |
140 const int componentId = |
141 entry->attribute(componentIdAttributeName()).toInt(); |
141 entry->attribute(Hs::componentIdAttributeName).toInt(); |
142 |
142 |
143 QSharedPointer<CaSoftwareRegistry> softwareRegistry = |
143 QSharedPointer<CaSoftwareRegistry> softwareRegistry = |
144 CaSoftwareRegistry::create(); |
144 CaSoftwareRegistry::create(); |
145 QStringList appUids; |
145 QStringList appUids; |
146 bool retval = softwareRegistry->getUninstallDetails(componentId, |
146 bool retval = softwareRegistry->getUninstallDetails(componentId, |
148 appUids, |
148 appUids, |
149 confirmationMessage); |
149 confirmationMessage); |
150 if (retval) { |
150 if (retval) { |
151 CaQuery query; |
151 CaQuery query; |
152 foreach (QString uid, appUids) { |
152 foreach (QString uid, appUids) { |
153 query.setAttribute(applicationUidEntryKey(), uid); |
153 query.setAttribute(Hs::applicationUidEntryKey, uid); |
154 QList< QSharedPointer<CaEntry> > entries = |
154 QList< QSharedPointer<CaEntry> > entries = |
155 service->getEntries(query); |
155 service->getEntries(query); |
156 if (entries.length() > 0) { |
156 if (entries.length() > 0) { |
157 applicationsNames << entries[0]->text(); |
157 applicationsNames << entries[0]->text(); |
158 } |
158 } |
189 |
189 |
190 /*! |
190 /*! |
191 Method create uninstall confirmation message. |
191 Method create uninstall confirmation message. |
192 \retval void |
192 \retval void |
193 */ |
193 */ |
194 void HsUninstallItemState::createUninstallMessage() |
194 void HsUninstallItemState::createSimpleUninstallMessage(bool isJava) |
195 { |
195 { |
196 CaQuery parentsQuery; |
196 CaQuery parentsQuery; |
197 parentsQuery.setChildId(mItemId); |
197 parentsQuery.setChildId(mItemId); |
198 parentsQuery.setEntryTypeNames(QStringList(collectionTypeName())); |
198 parentsQuery.setEntryTypeNames(QStringList(Hs::collectionTypeName)); |
199 QList<int> parentsIds = CaService::instance()->getEntryIds( |
199 QList<int> parentsIds = CaService::instance()->getEntryIds( |
200 parentsQuery); |
200 parentsQuery); |
201 QString message; |
201 QString message; |
202 if (HsShortcutService::instance()->isItemShortcutWidget(mItemId) || (parentsIds.count() > 0)) { |
202 if (HsShortcutService::instance()->isItemShortcutWidget(mItemId) || (parentsIds.count() > 0)) { |
203 message.append( |
203 message.append( |
209 HsMenuService::getName(mItemId))); |
209 HsMenuService::getName(mItemId))); |
210 } |
210 } |
211 |
211 |
212 // create and show message box |
212 // create and show message box |
213 mUninstallMessage = HsMenuDialogFactory().create(message); |
213 mUninstallMessage = HsMenuDialogFactory().create(message); |
|
214 if( isJava ){ |
|
215 QSharedPointer<CaEntry> entry = CaService::instance()->getEntry(mItemId); |
|
216 HbIcon icon = entry->makeIcon(); |
|
217 mUninstallMessage->setIcon(icon); |
|
218 } |
214 mConfirmAction = mUninstallMessage->actions().value(0); |
219 mConfirmAction = mUninstallMessage->actions().value(0); |
215 |
220 |
216 QScopedPointer<HsMenuEntryRemovedHandler> entryObserver( |
221 QScopedPointer<HsMenuEntryRemovedHandler> entryObserver( |
217 new HsMenuEntryRemovedHandler(mItemId, this, SIGNAL(exit()))); |
222 new HsMenuEntryRemovedHandler(mItemId, this, SIGNAL(exit()))); |
218 entryObserver.take()->setParent(mUninstallMessage); |
223 entryObserver.take()->setParent(mUninstallMessage); |
219 |
224 |
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_dialog_1_will_be_removed_from_phone_c").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 |
|
248 mUninstallMessage->open(this, SLOT(uninstallMessageFinished(HbAction*))); |
225 mUninstallMessage->open(this, SLOT(uninstallMessageFinished(HbAction*))); |
249 } |
226 } |
250 |
227 |
251 /*! |
228 /*! |
252 Method create uninstall confirmation dialog for java. |
229 Method create uninstall confirmation dialog for java. |
267 QString detailsMessage; |
244 QString detailsMessage; |
268 getApplicationsNames(componentName, applicationsNames, detailsMessage); |
245 getApplicationsNames(componentName, applicationsNames, detailsMessage); |
269 |
246 |
270 QString section; |
247 QString section; |
271 if (applicationsNames.isEmpty() && detailsMessage.isEmpty()) { |
248 if (applicationsNames.isEmpty() && detailsMessage.isEmpty()) { |
272 createSimpleUninstallJavaMessage(); |
249 createSimpleUninstallMessage(true); |
273 } |
250 } |
274 else { |
251 else { |
275 if ( (!applicationsNames.isEmpty()) && (!detailsMessage.isEmpty())) { |
252 if ( (!applicationsNames.isEmpty()) && (!detailsMessage.isEmpty())) { |
276 mDialogType = UninstallDialogDefinition02; |
253 mDialogType = UninstallDialogDefinition02; |
277 section = QString("uninstallDialogDefinition02"); |
254 section = QString("uninstallDialogDefinition02"); |
305 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_ICON)); |
282 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_ICON)); |
306 QSharedPointer<CaEntry> entry2 = CaService::instance()->getEntry(mItemId); |
283 QSharedPointer<CaEntry> entry2 = CaService::instance()->getEntry(mItemId); |
307 HbIcon icon = entry2->makeIcon(); |
284 HbIcon icon = entry2->makeIcon(); |
308 iconLabel->setIcon(icon); |
285 iconLabel->setIcon(icon); |
309 |
286 |
|
287 CaQuery parentsQuery; |
|
288 parentsQuery.setChildId(mItemId); |
|
289 parentsQuery.setEntryTypeNames(QStringList(Hs::collectionTypeName)); |
|
290 QList<int> parentsIds = CaService::instance()->getEntryIds( |
|
291 parentsQuery); |
|
292 |
310 HbLabel* textLabel = |
293 HbLabel* textLabel = |
311 qobject_cast<HbLabel*>( |
294 qobject_cast<HbLabel*>( |
312 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_LABEL)); |
295 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_LABEL)); |
313 textLabel->setPlainText(textLabel->plainText().arg(componentName)); |
296 if (HsShortcutService::instance()->isItemShortcutWidget(mItemId) || |
|
297 (parentsIds.count() > 0)) { |
|
298 textLabel->setPlainText(HbParameterLengthLimiter( |
|
299 "txt_applib_info_delete_1_all_its_shortcuts_and").arg( |
|
300 componentName)); |
|
301 } else { |
|
302 textLabel->setPlainText(HbParameterLengthLimiter( |
|
303 "txt_applib_info_delete_1_and_associated_data").arg( |
|
304 componentName)); |
|
305 } |
314 |
306 |
315 HbLabel* detailsUninstalLabel; |
307 HbLabel* detailsUninstalLabel; |
316 if ((mDialogType == UninstallDialogDefinition02) || |
308 if ((mDialogType == UninstallDialogDefinition02) || |
317 (mDialogType == UninstallDialogDefinition04)) { |
309 (mDialogType == UninstallDialogDefinition04)) { |
318 detailsUninstalLabel= qobject_cast<HbLabel*>( |
310 detailsUninstalLabel= qobject_cast<HbLabel*>( |