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 "hsdialogcontroller.h" |
28 #include "hsmenuevent.h" |
28 #include "hsmenuevent.h" |
29 |
29 |
30 /*! |
30 /*! |
31 \class HsDeleteCollectionState |
31 \class HsDeleteCollectionState |
32 \ingroup group_hsworkerstateplugin |
32 \ingroup group_hsworkerstateplugin |
89 } else { |
90 } else { |
90 message.append(HbParameterLengthLimiter("txt_applib_dialog_delete_1").arg( |
91 message.append(HbParameterLengthLimiter("txt_applib_dialog_delete_1").arg( |
91 HsMenuService::getName(mItemId))); |
92 HsMenuService::getName(mItemId))); |
92 } |
93 } |
93 |
94 |
94 // create and show message box |
95 QScopedPointer<HsDialogController> dialogController( |
95 mDeleteMessage = HsMenuDialogFactory().create(message); |
96 new HsDialogController(message)); |
96 mConfirmAction = mDeleteMessage->actions().value(0); |
97 |
97 mDeleteMessage->open(this, SLOT(deleteMessageFinished(HbAction*))); |
98 connect(dialogController.data(), |
|
99 SIGNAL(acceptActionTriggered(QAction*)), |
|
100 this, |
|
101 SLOT(deleteCollection())); |
|
102 |
|
103 connect(dialogController.data(), |
|
104 SIGNAL(dialogCompleted()), |
|
105 this, |
|
106 SIGNAL(exit())); |
|
107 |
|
108 // ensure dialog is dismissed on app key pressed |
|
109 connect(this, SIGNAL(exited()), |
|
110 dialogController.data(), |
|
111 SLOT(dismissDialog())); |
|
112 |
|
113 dialogController.take()->openDialog(); |
98 |
114 |
99 HSMENUTEST_FUNC_EXIT("HsDeleteCollectionState::onEntry"); |
115 HSMENUTEST_FUNC_EXIT("HsDeleteCollectionState::onEntry"); |
100 } |
116 } |
101 |
117 |
|
118 /*! |
|
119 Slot. Removes collection specified by event passed on entry to the state. |
|
120 \retval void |
|
121 */ |
|
122 void HsDeleteCollectionState::deleteCollection() |
|
123 { |
|
124 HsMenuService::removeCollection(mItemId); |
|
125 machine()->postEvent( |
|
126 HsMenuEventFactory::createCollectionDeletedEvent()); |
|
127 } |
102 |
128 |
103 // --------------------------------------------------------------------------- |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void HsDeleteCollectionState::deleteMessageFinished(HbAction* finishedAction) |
|
107 { |
|
108 if (static_cast<QAction*>(finishedAction) == mConfirmAction) { |
|
109 HsMenuService::removeCollection(mItemId); |
|
110 machine()->postEvent( |
|
111 HsMenuEventFactory::createCollectionDeletedEvent()); |
|
112 } |
|
113 emit exit(); |
|
114 mConfirmAction = NULL; |
|
115 } |
|
116 |
129 |
117 /*! |
130 /*! |
118 Slot launched after state has exited and in destructor. |
131 Slot launched after state has exited and in destructor. |
119 \retval void |
132 \retval void |
120 */ |
133 */ |
121 void HsDeleteCollectionState::cleanUp() |
134 void HsDeleteCollectionState::cleanUp() |
122 { |
135 { |
123 // Close messagebox if App key was pressed |
|
124 if (mDeleteMessage) { |
|
125 mDeleteMessage->close(); |
|
126 mDeleteMessage = NULL; |
|
127 } |
|
128 |
|
129 mConfirmAction = NULL; |
|
130 mItemId = 0; |
136 mItemId = 0; |
131 } |
137 } |