19 #include <hbaction.h> |
19 #include <hbaction.h> |
20 #include <HbParameterLengthLimiter> |
20 #include <HbParameterLengthLimiter> |
21 #include <hsmenuservice.h> |
21 #include <hsmenuservice.h> |
22 #include <hsmenueventfactory.h> |
22 #include <hsmenueventfactory.h> |
23 |
23 |
24 #include "hsmenudialogfactory.h" |
24 #include "hsdialogcontroller.h" |
25 #include "hsdeletecollectionitemstate.h" |
25 #include "hsdeletecollectionitemstate.h" |
26 #include "hsmenuevent.h" |
26 #include "hsmenuevent.h" |
27 |
27 |
28 /*! |
28 /*! |
29 \class HsDeleteCollectionItemState |
29 \class HsDeleteCollectionItemState |
81 mItemId = data.value(Hs::itemIdKey).toInt(); |
82 mItemId = data.value(Hs::itemIdKey).toInt(); |
82 mCollectionId = data.value(Hs::collectionIdKey).toInt(); |
83 mCollectionId = data.value(Hs::collectionIdKey).toInt(); |
83 |
84 |
84 QString message; |
85 QString message; |
85 message.append( |
86 message.append( |
86 HbParameterLengthLimiter("txt_applib_dialog_remove_1_from_collection").arg( |
87 HbParameterLengthLimiter( |
87 HsMenuService::getName(mItemId))); |
88 "txt_applib_dialog_remove_1_from_collection").arg( |
|
89 HsMenuService::getName(mItemId))); |
88 |
90 |
89 // create and show message box |
91 QScopedPointer<HsDialogController> dialogController( |
90 mDeleteMessage = HsMenuDialogFactory().create(message); |
92 new HsDialogController(message)); |
91 mConfirmAction = mDeleteMessage->actions().value(0); |
93 |
92 mDeleteMessage->open(this, SLOT(deleteMessageFinished(HbAction*))); |
94 connect(dialogController.data(), |
|
95 SIGNAL(acceptActionTriggered(QAction*)), |
|
96 this, |
|
97 SLOT(removeApplicationFromCollection())); |
|
98 |
|
99 connect(dialogController.data(), |
|
100 SIGNAL(dialogCompleted()), |
|
101 this, |
|
102 SIGNAL(exit())); |
|
103 |
|
104 // ensure dialog is dismissed on app key pressed |
|
105 connect(this, SIGNAL(exited()), |
|
106 dialogController.data(), |
|
107 SLOT(dismissDialog())); |
|
108 |
|
109 dialogController.take()->openDialog(); |
93 |
110 |
94 HSMENUTEST_FUNC_EXIT("HsDeleteCollectionItemState::onEntry"); |
111 HSMENUTEST_FUNC_EXIT("HsDeleteCollectionItemState::onEntry"); |
95 } |
112 } |
96 |
113 |
|
114 |
|
115 #ifdef COVERAGE_MEASUREMENT |
|
116 #pragma CTC SKIP |
|
117 #endif //COVERAGE_MEASUREMENT |
97 /*! |
118 /*! |
98 Action after closed confirmation dialog. |
119 Slot. Removes application from collection, both specified by event |
99 \param finishedAction chosen action. |
120 passed to the state on entry. |
100 \retval void |
121 \retval void |
101 */ |
122 */ |
102 void HsDeleteCollectionItemState::deleteMessageFinished(HbAction* finishedAction) |
123 void HsDeleteCollectionItemState::removeApplicationFromCollection() |
103 { |
124 { |
104 if (static_cast<QAction*>(finishedAction) == mConfirmAction) { |
125 HsMenuService::removeApplicationFromCollection(mItemId, mCollectionId); |
105 HsMenuService::removeApplicationFromCollection(mItemId, mCollectionId); |
|
106 } |
|
107 emit exit(); |
|
108 mConfirmAction = NULL; |
|
109 } |
126 } |
|
127 #ifdef COVERAGE_MEASUREMENT |
|
128 #pragma CTC ENDSKIP |
|
129 #endif //COVERAGE_MEASUREMENT |
110 |
130 |
111 /*! |
131 /*! |
112 Slot launched after state has exited and in destructor. |
132 Slot launched after state has exited and in destructor. |
113 \retval void |
133 \retval void |
114 */ |
134 */ |
115 void HsDeleteCollectionItemState::cleanUp() |
135 void HsDeleteCollectionItemState::cleanUp() |
116 { |
136 { |
117 // Close messagebox if App key was pressed |
|
118 if (mDeleteMessage) { |
|
119 disconnect(mDeleteMessage, SIGNAL(finished(HbAction*)), this, SLOT(deleteMessageFinished(HbAction*))); |
|
120 mDeleteMessage->close(); |
|
121 mDeleteMessage = NULL; |
|
122 } |
|
123 |
|
124 mConfirmAction = NULL; |
|
125 mItemId = 0; |
137 mItemId = 0; |
126 mCollectionId = 0; |
138 mCollectionId = 0; |
127 } |
139 } |