74 */ |
74 */ |
75 void HsCollectionNameState::construct() |
75 void HsCollectionNameState::construct() |
76 { |
76 { |
77 setObjectName(this->parent()->objectName() + "/collectionnamestate"); |
77 setObjectName(this->parent()->objectName() + "/collectionnamestate"); |
78 connect(this, SIGNAL(exited()), SLOT(cleanUp())); |
78 connect(this, SIGNAL(exited()), SLOT(cleanUp())); |
79 |
|
80 } |
79 } |
81 |
80 |
82 /*! |
81 /*! |
83 Sets entry event. |
82 Sets entry event. |
84 \param event entry event. |
83 \param event entry event. |
91 qDebug("CollectionState::onEntry()"); |
90 qDebug("CollectionState::onEntry()"); |
92 HSMENUTEST_FUNC_ENTRY("HsCollectionNameState::onEntry"); |
91 HSMENUTEST_FUNC_ENTRY("HsCollectionNameState::onEntry"); |
93 QState::onEntry(event); |
92 QState::onEntry(event); |
94 |
93 |
95 mItemId = 0; |
94 mItemId = 0; |
96 mFinishedEntered = false; |
|
97 if (event->type() == HsMenuEvent::eventType()) { |
95 if (event->type() == HsMenuEvent::eventType()) { |
98 HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
96 HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
99 QVariantMap data = menuEvent->data(); |
97 QVariantMap data = menuEvent->data(); |
100 |
98 |
101 mItemId = data.value(itemIdKey()).toInt(); |
99 mItemId = data.value(itemIdKey()).toInt(); |
113 // --------------------------------------------------------------------------- |
111 // --------------------------------------------------------------------------- |
114 // --------------------------------------------------------------------------- |
112 // --------------------------------------------------------------------------- |
115 // |
113 // |
116 void HsCollectionNameState::dialogFinished(HbAction* finishedAction) |
114 void HsCollectionNameState::dialogFinished(HbAction* finishedAction) |
117 { |
115 { |
118 if (!mFinishedEntered) { |
116 if (finishedAction == mCollectionNameDialog->actions().value(0)) { |
119 mFinishedEntered = true; |
117 QString newName(mCollectionNameDialog->newName(mCollectionNameDialog->value().toString(), true)); |
120 if (finishedAction == mCollectionNameDialog->actions().value(0)) { |
118 if (mItemId) { |
121 QString newName(mCollectionNameDialog->newName(mCollectionNameDialog->value().toString(), true)); |
119 if (newName != HsMenuService::getName(mItemId)) { |
122 if (mItemId) { |
120 HsMenuService::renameCollection(mItemId, newName); |
123 if (newName != HsMenuService::getName(mItemId)) { |
|
124 HsMenuService::renameCollection(mItemId, newName); |
|
125 } |
|
126 } else { |
|
127 HsMenuService::createCollection(newName); |
|
128 } |
121 } |
|
122 } else { |
|
123 HsMenuService::createCollection(newName); |
129 } |
124 } |
130 mCollectionNameDialog = NULL; //set to NULL since this will be deleted atfer close |
|
131 emit exit(); |
|
132 } else { |
|
133 // (work-around if more then one action is selected in HbDialog) |
|
134 qWarning("Another signal finished was emited."); |
|
135 } |
125 } |
|
126 mCollectionNameDialog = NULL; //set to NULL since this will be deleted atfer close |
|
127 emit exit(); |
136 } |
128 } |
137 |
129 |
138 // --------------------------------------------------------------------------- |
130 // --------------------------------------------------------------------------- |
139 // --------------------------------------------------------------------------- |
131 // --------------------------------------------------------------------------- |
140 // |
132 // |
141 void HsCollectionNameState::cleanUp() |
133 void HsCollectionNameState::cleanUp() |
142 { |
134 { |
143 if (mCollectionNameDialog) { |
135 if (mCollectionNameDialog) { |
|
136 disconnect(mCollectionNameDialog, SIGNAL(finished(HbAction*)), this, SLOT(dialogFinished(HbAction*))); |
144 mCollectionNameDialog->close(); |
137 mCollectionNameDialog->close(); |
145 mCollectionNameDialog = NULL; |
138 mCollectionNameDialog = NULL; |
146 } |
139 } |
147 } |
140 } |