homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsaddtohomescreenstate.cpp
changeset 60 30f14686fb04
parent 55 03646e8da489
child 61 2b1b11a301d2
equal deleted inserted replaced
55:03646e8da489 60:30f14686fb04
    33 #include "caquery.h"
    33 #include "caquery.h"
    34 #include "hsmenuservice.h"
    34 #include "hsmenuservice.h"
    35 
    35 
    36 const char SHORTCUT_WIDGET_URI[] = "hsshortcutwidgetplugin";
    36 const char SHORTCUT_WIDGET_URI[] = "hsshortcutwidgetplugin";
    37 const char SHORTCUT_ID[] = "caEntryId";
    37 const char SHORTCUT_ID[] = "caEntryId";
    38 const char ADD_TO_HOMESCREEN_STATE[] = "AddToHomeScreenState";
    38 
    39 
    39 
    40 
    40 
    41 /*!
    41 /*!
    42  \class HsAddToHomeScreenState
    42  \class HsAddToHomeScreenState
    43  \ingroup group_hsmenustateplugin
    43  \ingroup group_hsmenustateplugin
    48  (browsing applications and collections)
    48  (browsing applications and collections)
    49  */
    49  */
    50 
    50 
    51 /*!
    51 /*!
    52  Constructor
    52  Constructor
    53  \param parent: parent state
    53  \param parent Parent state.
    54  \retval void
    54  \retval void
    55  */
    55  */
    56 HsAddToHomeScreenState::HsAddToHomeScreenState(QState *parent) :
    56 HsAddToHomeScreenState::HsAddToHomeScreenState(QState *parent) :
    57     HsMenuBaseState(ADD_TO_HOMESCREEN_STATE, parent), 
    57     QState(parent), 
    58     mCorruptedMessage(NULL), mConfirmAction(NULL),
    58     mCorruptedMessage(NULL), mConfirmAction(NULL),
    59     mMenuMode(NormalHsMenuMode),
    59     mMenuMode(NormalHsMenuMode),
    60     mNotifier(0)
    60     mNotifier(0)
    61 {
    61 {
    62     requestServices(QList<QVariant> () << SHORTCUT_SERVICE_KEY
    62     setObjectName("/AddToHomeScreenState");
    63                     << CONTENT_SERVICE_KEY);
    63     
       
    64     if (this->parent()) {
       
    65         setObjectName(this->parent()->objectName() + objectName());
       
    66     }
       
    67     
    64     connect(this, SIGNAL(exited()), SLOT(cleanUp()));
    68     connect(this, SIGNAL(exited()), SLOT(cleanUp()));
    65 }
    69 }
    66 
    70 
    67 /*!
    71 /*!
    68  Destructor. Empty one.
    72  Destructor. Empty one.
    84  \retval void
    88  \retval void
    85  */
    89  */
    86 void HsAddToHomeScreenState::onEntry(QEvent *event)
    90 void HsAddToHomeScreenState::onEntry(QEvent *event)
    87 {
    91 {
    88     HSMENUTEST_FUNC_ENTRY("HsAddToHomeScreenState::onEntry");
    92     HSMENUTEST_FUNC_ENTRY("HsAddToHomeScreenState::onEntry");
    89     HsMenuBaseState::onEntry(event);
    93     QState::onEntry(event);
    90     HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
    94     HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
    91     QVariantMap data = menuEvent->data();
    95     QVariantMap data = menuEvent->data();
    92 
    96 
    93     mEntryId = data.value(itemIdKey()).toInt();
    97     mEntryId = data.value(itemIdKey()).toInt();
    94     QSharedPointer<CaEntry> entry = CaService::instance()->getEntry(mEntryId);
    98     QSharedPointer<CaEntry> entry = CaService::instance()->getEntry(mEntryId);
    97     mMenuMode = static_cast<HsMenuMode>(data.value(menuModeType()).toInt());
   101     mMenuMode = static_cast<HsMenuMode>(data.value(menuModeType()).toInt());
    98 
   102 
    99     bool success = false;
   103     bool success = false;
   100     if (entryTypeName == widgetTypeName()) {
   104     if (entryTypeName == widgetTypeName()) {
   101         const QString uri = entry->attribute(widgetUriAttributeName());
   105         const QString uri = entry->attribute(widgetUriAttributeName());
   102         success = addWidget(*contentService(), uri);
   106         success = addWidget(*HsContentService::instance(), uri);
   103         HsMenuService::touch(mEntryId);        
   107         HsMenuService::touch(mEntryId);        
   104     } else {
   108     } else {
   105         success = addApplication(*contentService(), *entry);
   109         success = addApplication(*HsContentService::instance(), *entry);
   106     }
   110     }
   107     
   111     
   108     if (success && (mMenuMode == NormalHsMenuMode)) {
   112     if (success && (mMenuMode == NormalHsMenuMode)) {
   109         HbNotificationDialog *notificationDialog = new HbNotificationDialog();
   113         HbNotificationDialog *notificationDialog = new HbNotificationDialog();
   110         notificationDialog->setAttribute(Qt::WA_DeleteOnClose);
   114         notificationDialog->setAttribute(Qt::WA_DeleteOnClose);
   151 /*!
   155 /*!
   152  Shows message about corrupted widget library. Deletes widget eventually
   156  Shows message about corrupted widget library. Deletes widget eventually
   153  \param itemId entryId of widget (needed to delete it)
   157  \param itemId entryId of widget (needed to delete it)
   154  \retval void
   158  \retval void
   155  */
   159  */
   156 #ifdef COVERAGE_MEASUREMENT
       
   157 #pragma CTC SKIP
       
   158 #endif //COVERAGE_MEASUREMENT
       
   159 void HsAddToHomeScreenState::showMessageWidgetCorrupted()
   160 void HsAddToHomeScreenState::showMessageWidgetCorrupted()
   160 {
   161 {
   161     HSMENUTEST_FUNC_ENTRY("HsCollectionState::showMessageWidgetCorrupted");
   162     HSMENUTEST_FUNC_ENTRY("HsCollectionState::showMessageWidgetCorrupted");
   162 
   163 
   163     mCorruptedMessage = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   164     mCorruptedMessage = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   177 
   178 
   178     mCorruptedMessage->open(this, SLOT(messageWidgetCorruptedFinished(HbAction*)));
   179     mCorruptedMessage->open(this, SLOT(messageWidgetCorruptedFinished(HbAction*)));
   179 
   180 
   180     HSMENUTEST_FUNC_EXIT("HsCollectionState::showMessageWidgetCorrupted");
   181     HSMENUTEST_FUNC_EXIT("HsCollectionState::showMessageWidgetCorrupted");
   181 }
   182 }
   182 #ifdef COVERAGE_MEASUREMENT
       
   183 #pragma CTC ENDSKIP
       
   184 #endif //COVERAGE_MEASUREMENT
       
   185 
   183 
   186 /*!
   184 /*!
   187  Slot launched on dismissing the corrupted widget error note
   185  Slot launched on dismissing the corrupted widget error note
   188  \retval void
   186  \retval void
   189  */
   187  */