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