homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsdeletecollectionstate.cpp
changeset 63 52b0f64eeb51
parent 62 341166945d65
child 81 7dd137878ff8
equal deleted inserted replaced
62:341166945d65 63:52b0f64eeb51
    14  * Description: Menu delete collection state
    14  * Description: Menu delete collection state
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 #include <QStateMachine>
    18 #include <QStateMachine>
    19 #include <hbmessagebox.h>
    19 #include <HbMessageBox>
    20 #include <hbaction.h>
    20 #include <hbaction.h>
    21 #include <hsmenuservice.h>
    21 #include <hsmenuservice.h>
    22 #include <HbParameterLengthLimiter>
    22 #include <HbParameterLengthLimiter>
    23 #include <hsshortcutservice.h>
    23 #include <hsshortcutservice.h>
    24 #include <hsmenueventfactory.h>
    24 #include <hsmenueventfactory.h>
    25 
    25 
    26 #include "hsdeletecollectionstate.h"
    26 #include "hsdeletecollectionstate.h"
       
    27 #include "hsmenudialogfactory.h"
    27 #include "hsmenuevent.h"
    28 #include "hsmenuevent.h"
    28 
    29 
    29 /*!
    30 /*!
    30  \class HsDeleteCollectionState
    31  \class HsDeleteCollectionState
    31  \ingroup group_hsworkerstateplugin
    32  \ingroup group_hsworkerstateplugin
    89         message.append(HbParameterLengthLimiter("txt_applib_dialog_delete_1").arg(
    90         message.append(HbParameterLengthLimiter("txt_applib_dialog_delete_1").arg(
    90                            HsMenuService::getName(mItemId)));
    91                            HsMenuService::getName(mItemId)));
    91     }
    92     }
    92 
    93 
    93     // create and show message box
    94     // create and show message box
    94     mDeleteMessage = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
    95     mDeleteMessage = HsMenuDialogFactory().create(message);
    95     mDeleteMessage->setAttribute(Qt::WA_DeleteOnClose);
    96     mConfirmAction = mDeleteMessage->actions().value(0);
       
    97     mDeleteMessage->open(this, SLOT(deleteMessageFinished(HbAction*)));
    96 
    98 
    97     mDeleteMessage->setText(message);
       
    98 
       
    99     mDeleteMessage->clearActions();
       
   100     mConfirmAction = new HbAction(hbTrId("txt_common_button_ok"), mDeleteMessage);
       
   101     mDeleteMessage->addAction(mConfirmAction);
       
   102 
       
   103     HbAction *secondaryAction = new HbAction(hbTrId("txt_common_button_cancel"), mDeleteMessage);
       
   104     mDeleteMessage->addAction(secondaryAction);
       
   105 
       
   106     mDeleteMessage->open(this, SLOT(deleteMessageFinished(HbAction*)));
       
   107     HSMENUTEST_FUNC_EXIT("HsDeleteCollectionState::onEntry");
    99     HSMENUTEST_FUNC_EXIT("HsDeleteCollectionState::onEntry");
   108 }
   100 }
   109 
   101 
   110 
   102 
   111 // ---------------------------------------------------------------------------
   103 // ---------------------------------------------------------------------------
   112 // ---------------------------------------------------------------------------
   104 // ---------------------------------------------------------------------------
   113 //
   105 //
   114 void HsDeleteCollectionState::deleteMessageFinished(HbAction* finishedAction)
   106 void HsDeleteCollectionState::deleteMessageFinished(HbAction* finishedAction)
   115 {
   107 {
   116     if (finishedAction == mConfirmAction) {
   108     if (static_cast<QAction*>(finishedAction) == mConfirmAction) {
   117         HsMenuService::removeCollection(mItemId);
   109         HsMenuService::removeCollection(mItemId);
   118         machine()->postEvent(
   110         machine()->postEvent(
   119         HsMenuEventFactory::createCollectionDeletedEvent());
   111         HsMenuEventFactory::createCollectionDeletedEvent());
   120     }
   112     }
   121     emit exit();
   113     emit exit();
       
   114     mConfirmAction = NULL;
   122 }
   115 }
   123 
   116 
   124 /*!
   117 /*!
   125  Slot launched after state has exited and in destructor.
   118  Slot launched after state has exited and in destructor.
   126  \retval void
   119  \retval void
   127  */
   120  */
   128 void HsDeleteCollectionState::cleanUp()
   121 void HsDeleteCollectionState::cleanUp()
   129 {
   122 {
   130     // Close messagebox if App key was pressed
   123     // Close messagebox if App key was pressed
   131     if (mDeleteMessage) {
   124     if (mDeleteMessage) {
   132         disconnect(mDeleteMessage, SIGNAL(finished(HbAction*)), this, SLOT(deleteMessageFinished(HbAction*)));
       
   133         mDeleteMessage->close();
   125         mDeleteMessage->close();
   134         mDeleteMessage = NULL;
   126         mDeleteMessage = NULL;
   135     }
   127     }
   136 
   128 
   137     mConfirmAction = NULL;
   129     mConfirmAction = NULL;