homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsdeletecollectionstate.cpp
changeset 60 30f14686fb04
parent 55 03646e8da489
child 63 52b0f64eeb51
equal deleted inserted replaced
55:03646e8da489 60:30f14686fb04
    17 
    17 
    18 #include <QStateMachine>
    18 #include <QStateMachine>
    19 #include <hbmessagebox.h>
    19 #include <hbmessagebox.h>
    20 #include <hbaction.h>
    20 #include <hbaction.h>
    21 #include <hsmenuservice.h>
    21 #include <hsmenuservice.h>
       
    22 #include <HbParameterLengthLimiter>
    22 #include <hsshortcutservice.h>
    23 #include <hsshortcutservice.h>
    23 #include <hsmenueventfactory.h>
    24 #include <hsmenueventfactory.h>
    24 
    25 
    25 #include "hsdeletecollectionstate.h"
    26 #include "hsdeletecollectionstate.h"
    26 #include "hsmenuevent.h"
    27 #include "hsmenuevent.h"
    32  Deletes collections.
    33  Deletes collections.
    33  */
    34  */
    34 
    35 
    35 /*!
    36 /*!
    36  Constructor.
    37  Constructor.
    37  \param parent Owner.
    38  \param parent Parent state.
    38  */
    39  */
    39 HsDeleteCollectionState::HsDeleteCollectionState(QState *parent) :
    40 HsDeleteCollectionState::HsDeleteCollectionState(QState *parent) :
    40     QState(parent),
    41     QState(parent),
    41     mItemId(0),
    42     mItemId(0),
    42     mDeleteMessage(NULL),
    43     mDeleteMessage(NULL),
    56 /*!
    57 /*!
    57  Constructs contained objects.
    58  Constructs contained objects.
    58  */
    59  */
    59 void HsDeleteCollectionState::construct()
    60 void HsDeleteCollectionState::construct()
    60 {
    61 {
    61     setObjectName(this->parent()->objectName() + "/DeleteCollectionState");
    62     setObjectName("/DeleteCollectionState");
    62     setProperty(HS_SERVICES_REGISTRATION_KEY, QList<QVariant> ()
    63     if (this->parent()) {
    63                 << SHORTCUT_SERVICE_KEY);
    64         setObjectName(this->parent()->objectName() + objectName());
       
    65     }
    64     connect(this, SIGNAL(exited()), SLOT(cleanUp()));
    66     connect(this, SIGNAL(exited()), SLOT(cleanUp()));
    65 }
    67 }
    66 
    68 
    67 /*!
    69 /*!
    68  Sets entry event.
    70  Sets entry event.
    69  \param event entry event.
    71  \param event entry event.
    70  */
    72  */
    71 #ifdef COVERAGE_MEASUREMENT
       
    72 #pragma CTC SKIP
       
    73 #endif //COVERAGE_MEASUREMENT
       
    74 void HsDeleteCollectionState::onEntry(QEvent *event)
    73 void HsDeleteCollectionState::onEntry(QEvent *event)
    75 {
    74 {
    76     HSMENUTEST_FUNC_ENTRY("HsDeleteCollectionState::onEntry");
    75     HSMENUTEST_FUNC_ENTRY("HsDeleteCollectionState::onEntry");
    77     QState::onEntry(event);
    76     QState::onEntry(event);
    78     qDebug("CollectionState::onEntry()");
    77     qDebug("CollectionState::onEntry()");
    80     HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
    79     HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
    81     QVariantMap data = menuEvent->data();
    80     QVariantMap data = menuEvent->data();
    82     mItemId = data.value(itemIdKey()).toInt();
    81     mItemId = data.value(itemIdKey()).toInt();
    83 
    82 
    84     QString message;
    83     QString message;
    85     if (shortcutService()->isItemShortcutWidget(mItemId)) {
    84     if (HsShortcutService::instance()->isItemShortcutWidget(mItemId)) {
    86         message.append(hbTrId(
    85         message.append(HbParameterLengthLimiter(
    87                            "txt_applib_dialog_deletes_1_also_from_home_screen"). arg(
    86                            "txt_applib_dialog_deletes_1_also_from_home_screen"). arg(
    88                            HsMenuService::getName(mItemId)));
    87                            HsMenuService::getName(mItemId)));
    89     } else {
    88     } else {
    90         message.append(hbTrId("txt_applib_dialog_delete_1").arg(
    89         message.append(HbParameterLengthLimiter("txt_applib_dialog_delete_1").arg(
    91                            HsMenuService::getName(mItemId)));
    90                            HsMenuService::getName(mItemId)));
    92     }
    91     }
    93 
    92 
    94     // create and show message box
    93     // create and show message box
    95     mDeleteMessage = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
    94     mDeleteMessage = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   105     mDeleteMessage->addAction(secondaryAction);
   104     mDeleteMessage->addAction(secondaryAction);
   106 
   105 
   107     mDeleteMessage->open(this, SLOT(deleteMessageFinished(HbAction*)));
   106     mDeleteMessage->open(this, SLOT(deleteMessageFinished(HbAction*)));
   108     HSMENUTEST_FUNC_EXIT("HsDeleteCollectionState::onEntry");
   107     HSMENUTEST_FUNC_EXIT("HsDeleteCollectionState::onEntry");
   109 }
   108 }
   110 #ifdef COVERAGE_MEASUREMENT
       
   111 #pragma CTC ENDSKIP
       
   112 #endif //COVERAGE_MEASUREMENT
       
   113 
   109 
   114 /*!
       
   115  Convenience method returning the shortcut service.
       
   116  \since S60 ?S60_version.
       
   117  \return Shortcut Service.
       
   118  */
       
   119 HsShortcutService *HsDeleteCollectionState::shortcutService() const
       
   120 {
       
   121     return property(SHORTCUT_SERVICE_KEY).value<HsShortcutService *> ();
       
   122 }
       
   123 
   110 
   124 // ---------------------------------------------------------------------------
   111 // ---------------------------------------------------------------------------
   125 // ---------------------------------------------------------------------------
   112 // ---------------------------------------------------------------------------
   126 //
   113 //
   127 void HsDeleteCollectionState::deleteMessageFinished(HbAction* finishedAction)
   114 void HsDeleteCollectionState::deleteMessageFinished(HbAction* finishedAction)