homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsuninstallitemstate.cpp
changeset 63 52b0f64eeb51
parent 62 341166945d65
child 69 87476091b3f5
equal deleted inserted replaced
62:341166945d65 63:52b0f64eeb51
    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 
    37 
    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.
   109  \param finishedAction chosen action.
   110  \param finishedAction chosen action.
   110  \retval void
   111  \retval void
   111  */
   112  */
   112 void HsUninstallItemState::uninstallMessageFinished(HbAction* finishedAction)
   113 void HsUninstallItemState::uninstallMessageFinished(HbAction* finishedAction)
   113 {
   114 {
   114     if (finishedAction == mConfirmAction) {
   115     if (static_cast<QAction*>(finishedAction) == mConfirmAction) {
   115         HsMenuService::executeAction(mItemId, removeActionIdentifier());
   116         HsMenuService::executeAction(mItemId, removeActionIdentifier());
   116     }
   117     }
       
   118     mConfirmAction = NULL;
   117     emit exit();
   119     emit exit();
   118 }
   120 }
   119 
   121 
   120 /*!
   122 /*!
   121  Return information about a component: component name, a list of names
   123  Return information about a component: component name, a list of names
   224             HbParameterLengthLimiter("txt_applib_dialog_1_will_be_removed_from_phone_c").arg(
   226             HbParameterLengthLimiter("txt_applib_dialog_1_will_be_removed_from_phone_c").arg(
   225                 HsMenuService::getName(mItemId)));
   227                 HsMenuService::getName(mItemId)));
   226     }
   228     }
   227 
   229 
   228     // create and show message box
   230     // create and show message box
   229     mUninstallMessage = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   231     mUninstallMessage = HsMenuDialogFactory().create(message);
   230     mUninstallMessage->setAttribute(Qt::WA_DeleteOnClose);
   232     mConfirmAction = mUninstallMessage->actions().value(0);
   231 
       
   232     mUninstallMessage->setText(message);
       
   233 
       
   234     mUninstallMessage->clearActions();
       
   235     mConfirmAction = new HbAction(hbTrId("txt_common_button_ok"),
       
   236             mUninstallMessage);
       
   237     mUninstallMessage->addAction(mConfirmAction);
       
   238 
       
   239     HbAction *secondaryAction = new HbAction(hbTrId("txt_common_button_cancel"),
       
   240             mUninstallMessage);
       
   241     mUninstallMessage->addAction(secondaryAction);
       
   242 
       
   243     mUninstallMessage->open(this, SLOT(uninstallMessageFinished(HbAction*)));
   233     mUninstallMessage->open(this, SLOT(uninstallMessageFinished(HbAction*)));
   244 }
   234 }
   245 
   235 
   246 /*!
   236 /*!
   247  Method create uninstall confirmation dialog for java.
   237  Method create uninstall confirmation dialog for java.
   249  */
   239  */
   250 void HsUninstallItemState::createUninstallJavaMessage()
   240 void HsUninstallItemState::createUninstallJavaMessage()
   251 {
   241 {
   252     HbDocumentLoader loader;
   242     HbDocumentLoader loader;
   253     bool loadStatusOk = false;
   243     bool loadStatusOk = false;
   254     mObjectList = loader.load(HS_UNINSTALL_DIALOG_LAYOUT, &loadStatusOk);
   244     loader.load(HS_UNINSTALL_DIALOG_LAYOUT, &loadStatusOk);
   255     
   245     
   256     Q_ASSERT_X(loadStatusOk,
   246     Q_ASSERT_X(loadStatusOk,
   257             HS_UNINSTALL_DIALOG_LAYOUT,
   247             HS_UNINSTALL_DIALOG_LAYOUT,
   258            "Error while loading docml file.");
   248            "Error while loading docml file.");
   259 
   249 
   264     
   254     
   265     QString section;
   255     QString section;
   266     if (applicationsNames.isEmpty() && detailsMessage.isEmpty()) {
   256     if (applicationsNames.isEmpty() && detailsMessage.isEmpty()) {
   267         mDialogType = UninstallDialogDefinition01;
   257         mDialogType = UninstallDialogDefinition01;
   268         section = QString("uninstallDialogDefinition01");
   258         section = QString("uninstallDialogDefinition01");
   269         mObjectList = loader.load(
   259         loader.load(
   270                 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk);
   260                 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk);
   271     } else if ( (!applicationsNames.isEmpty()) && (!detailsMessage.isEmpty())) {
   261     } else if ( (!applicationsNames.isEmpty()) && (!detailsMessage.isEmpty())) {
   272         mDialogType = UninstallDialogDefinition02;
   262         mDialogType = UninstallDialogDefinition02;
   273         section = QString("uninstallDialogDefinition02");
   263         section = QString("uninstallDialogDefinition02");
   274         mObjectList = loader.load(
   264         loader.load(
   275                 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk);
   265                 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk);
   276     } else if ( (!applicationsNames.isEmpty() && detailsMessage.isEmpty())) {
   266     } else if ( (!applicationsNames.isEmpty() && detailsMessage.isEmpty())) {
   277         mDialogType = UninstallDialogDefinition03;
   267         mDialogType = UninstallDialogDefinition03;
   278         section = QString("uninstallDialogDefinition03");
   268         section = QString("uninstallDialogDefinition03");
   279         mObjectList = loader.load(
   269         loader.load(
   280                 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk);
   270                 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk);
   281     } else if (applicationsNames.isEmpty()  && (!detailsMessage.isEmpty())) {
   271     } else if (applicationsNames.isEmpty()  && (!detailsMessage.isEmpty())) {
   282         mDialogType = UninstallDialogDefinition04;
   272         mDialogType = UninstallDialogDefinition04;
   283         section = QString("uninstallDialogDefinition04");
   273         section = QString("uninstallDialogDefinition04");
   284         mObjectList = loader.load(
   274         loader.load(
   285                 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk);
   275                 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk);
   286     }
   276     }
   287  
   277  
   288     mUninstallJavaMessage = 
   278     mUninstallJavaMessage = 
   289         qobject_cast<HbDialog*>(
   279         qobject_cast<HbDialog*>(
   290             loader.findWidget(HS_UNINSTALL_DIALOG_NAME));
   280             loader.findWidget(HS_UNINSTALL_DIALOG_NAME));
   291     
   281     if (mUninstallJavaMessage != NULL) {
   292     HbLabel* iconLabel = 
   282         mUninstallJavaMessage->setAttribute(Qt::WA_DeleteOnClose);
   293         qobject_cast<HbLabel*>(
   283         mUninstallJavaMessage->setTimeout(HbPopup::NoTimeout);
   294             loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_ICON));
   284         mUninstallJavaMessage->actions()[0]->setParent(mUninstallJavaMessage);
   295     QSharedPointer<CaEntry> entry2 = CaService::instance()->getEntry(mItemId);
   285         mUninstallJavaMessage->actions()[1]->setParent(mUninstallJavaMessage);
   296     HbIcon icon = entry2->makeIcon();
   286     
   297     iconLabel->setIcon(icon);
   287         HbLabel* iconLabel =
   298     
   288             qobject_cast<HbLabel*>(
   299     HbLabel* textLabel = 
   289                 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_ICON));
   300         qobject_cast<HbLabel*>(
   290         QSharedPointer<CaEntry> entry2 = CaService::instance()->getEntry(mItemId);
   301             loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_LABEL));
   291         HbIcon icon = entry2->makeIcon();
   302     textLabel->setPlainText(textLabel->plainText().arg(componentName));
   292         iconLabel->setIcon(icon);
   303     
   293     
   304     HbLabel* detailsUninstalLabel;
   294         HbLabel* textLabel =
   305     if ((mDialogType == UninstallDialogDefinition02) ||
   295             qobject_cast<HbLabel*>(
   306         (mDialogType == UninstallDialogDefinition04)) {
   296                 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_LABEL));
   307         detailsUninstalLabel= qobject_cast<HbLabel*>(
   297         textLabel->setPlainText(textLabel->plainText().arg(componentName));
   308                 loader.findWidget(HS_UNINSTALL_DIALOG_DELETE_LABEL));
   298     
   309         detailsUninstalLabel->setPlainText(detailsMessage);
   299         HbLabel* detailsUninstalLabel;
   310     }
   300         if ((mDialogType == UninstallDialogDefinition02) ||
   311 
   301             (mDialogType == UninstallDialogDefinition04)) {
   312     HbLabel* listView;
   302             detailsUninstalLabel= qobject_cast<HbLabel*>(
   313     QString applicationsList;
   303                     loader.findWidget(HS_UNINSTALL_DIALOG_DELETE_LABEL));
   314     QString newLine("\n");
   304             detailsUninstalLabel->setPlainText(detailsMessage);
   315     if ((mDialogType == UninstallDialogDefinition02) ||
       
   316         (mDialogType == UninstallDialogDefinition03)) {
       
   317         listView = qobject_cast<HbLabel*>(
       
   318                 loader.findWidget(HS_UNINSTALL_DIALOG_LIST_VIEW_LABEL));
       
   319 
       
   320         for (int i=0; i<applicationsNames.count(); i++) {
       
   321             applicationsList = applicationsList + applicationsNames[i] + newLine;
       
   322         }
   305         }
   323         listView->setPlainText(applicationsList);
   306 
   324     }
   307         HbLabel* listView;
   325 
   308         QString applicationsList;
   326     mUninstallJavaMessage->setAttribute(Qt::WA_DeleteOnClose);
   309         QString newLine("\n");
   327     mUninstallJavaMessage->setTimeout(HbPopup::NoTimeout);
   310         if ((mDialogType == UninstallDialogDefinition02) ||
   328     mConfirmAction = qobject_cast<HbAction*>(loader.findObject(
   311             (mDialogType == UninstallDialogDefinition03)) {
   329             HS_UNINSTALL_DIALOG_CONFIRMATION_ACTION));
   312             listView = qobject_cast<HbLabel*>(
   330     
   313                     loader.findWidget(HS_UNINSTALL_DIALOG_LIST_VIEW_LABEL));
   331     mUninstallJavaMessage->open(this, SLOT(uninstallMessageFinished(HbAction*)));
   314 
   332 }
   315             for (int i=0; i<applicationsNames.count(); i++) {
       
   316                 applicationsList = applicationsList + applicationsNames[i] + newLine;
       
   317             }
       
   318             listView->setPlainText(applicationsList);
       
   319         }
       
   320 
       
   321         mConfirmAction = qobject_cast<HbAction*>(loader.findObject(
       
   322                 HS_UNINSTALL_DIALOG_CONFIRMATION_ACTION));
       
   323     
       
   324         mUninstallJavaMessage->open(this, SLOT(uninstallMessageFinished(HbAction*)));
       
   325     }
       
   326 }