29 |
30 |
30 /*! |
31 /*! |
31 \class HsAddAppsToCollectionState |
32 \class HsAddAppsToCollectionState |
32 \ingroup group_hsmenuworkerstateplugin |
33 \ingroup group_hsmenuworkerstateplugin |
33 \brief Manages adding to homescreen state |
34 \brief Manages adding to homescreen state |
34 */ |
35 State responsible for adding new applications to collections. |
35 |
36 \lib ?library |
36 /*! |
37 \see StateMachine |
37 \fn void transitToSaveState(const QString &collectionName); |
38 */ |
|
39 |
|
40 /*! |
|
41 \enum HsAddAppsToCollectionState::CollectionActionType |
|
42 Types of collection's related actions. |
|
43 */ |
|
44 |
|
45 /*! \var HsAddAppsToCollectionState::CollectionActionType HsAddAppsToCollectionState::NoActionType |
|
46 No action. |
|
47 */ |
|
48 |
|
49 /*! \var HsAddAppsToCollectionState::CollectionActionType HsAddAppsToCollectionState::ViaItemSpecificMenuType |
|
50 Adding a specific application to an existing collection via item specific menu. |
|
51 */ |
|
52 |
|
53 /*! \var HsAddAppsToCollectionState::CollectionActionType HsAddAppsToCollectionState::ViaAllViewOptionMenuType |
|
54 Add one/many applications to a new/an existing collection via the All view. |
|
55 */ |
|
56 |
|
57 /*! \var HsAddAppsToCollectionState::CollectionActionType HsAddAppsToCollectionState::ViaAllCollectionsViewType |
|
58 Adding a new collection via the Collections view. |
|
59 */ |
|
60 |
|
61 /*! \var HsAddAppsToCollectionState::CollectionActionType HsAddAppsToCollectionState::ViaCollectionsViewOptionsMenuType |
|
62 Add items to a collection via the collection's view options menu. |
|
63 */ |
|
64 |
|
65 /*! \var HsAddAppsToCollectionState::CollectionActionType HsAddAppsToCollectionState::ViaCollectionSpecificMenuType |
|
66 Add a specific item to a collection via collection specific menu. |
|
67 */ |
|
68 |
|
69 /*! |
|
70 \var HsAddAppsToCollectionState::mCollectionName |
|
71 Collection name. |
|
72 */ |
|
73 |
|
74 /*! |
|
75 \var HsAddAppsToCollectionState::mCollectionId |
|
76 Collection id. |
|
77 */ |
|
78 |
|
79 /*! |
|
80 \var HsAddAppsToCollectionState::mAppList |
|
81 Applications list. |
|
82 */ |
|
83 |
|
84 /*! |
|
85 \var HsAddAppsToCollectionState::mShowConfirmation |
|
86 Bool indicating need of confirmation note after saving in content arsenal. |
|
87 */ |
|
88 |
|
89 /*! |
|
90 \var HsAddAppsToCollectionState::mInitialState |
|
91 Initial state. |
|
92 */ |
|
93 |
|
94 /*! |
|
95 \var HsAddAppsToCollectionState::mSelectCollectionState |
|
96 Select collection state. |
|
97 */ |
|
98 |
|
99 /*! |
|
100 \var HsAddAppsToCollectionState::mNewCollectionState |
|
101 Collection name state. |
|
102 */ |
|
103 |
|
104 /*! |
|
105 \var HsAddAppsToCollectionState::mAppsCheckListState |
|
106 Collection name state. |
|
107 */ |
|
108 |
|
109 /*! |
|
110 \var HsAddAppsToCollectionState::mActionType |
|
111 Collection action type. |
|
112 */ |
|
113 |
|
114 /*! |
|
115 \var HsAddAppsToCollectionState::mApplicationsSortAttribute |
|
116 Applications sort order. |
|
117 */ |
|
118 |
|
119 /*! |
|
120 \var HsAddAppsToCollectionState::mCollectionsSortAttribute |
|
121 Collections sort order. |
|
122 */ |
|
123 |
|
124 /*! |
|
125 \var HsAddAppsToCollectionState::mAppsCheckList |
|
126 Applications check list. |
|
127 */ |
|
128 |
|
129 /*! |
|
130 \fn void HsAddAppsToCollectionState::transitToSaveState(const QString &collectionName); |
38 Signal emitted when collection name is selected. |
131 Signal emitted when collection name is selected. |
39 \param collectionName name of collection. |
132 \param collectionName name of collection. |
40 */ |
133 */ |
41 |
134 |
42 /*! |
135 /*! |
43 \fn void transitToAppsCheckListState(const QString &collectionName); |
136 \fn void HsAddAppsToCollectionState::transitToAppsCheckListState(const QString &collectionName); |
44 Signal emitted when collection name is selected - version to trigger |
137 Signal emitted when collection name is selected - version to trigger |
45 transition to mAppCheckListState. |
138 transition to mAppCheckListState. |
46 \param collectionName name of collection. |
139 \param collectionName name of collection. |
47 */ |
140 */ |
48 |
141 |
49 /*! |
142 /*! |
50 \fn void void transitToSaveState(int collectionId); |
143 \fn void void HsAddAppsToCollectionState::transitToSaveState(int collectionId); |
51 Signal emitted when collection id is selected. |
144 Signal emitted when collection id is selected. |
52 \param collectionId id of collection. |
145 \param collectionId id of collection. |
53 */ |
146 */ |
54 |
147 |
55 /*! |
148 /*! |
56 \fn void transitToAppsCheckListState(int collectionId); |
149 \fn void HsAddAppsToCollectionState::transitToAppsCheckListState(int collectionId); |
57 Signal emitted when collection name is selected - version to trigger |
150 Signal emitted when collection name is selected - version to trigger |
58 transition to mAppCheckListState. |
151 transition to mAppCheckListState. |
59 \param collectionId id of collection. |
152 \param collectionId id of collection. |
60 */ |
153 */ |
61 |
154 |
62 /*! |
155 /*! |
63 \fn void transitToNewCollectionState(); |
156 \fn void HsAddAppsToCollectionState::transitToNewCollectionState(); |
64 Signal emitted when user selects creating new collection. |
157 Signal emitted when user selects creating new collection. |
65 */ |
158 */ |
66 |
159 |
67 /*! |
160 /*! |
68 \fn void transitToSaveState(const QList<int> &appList); |
161 \fn void HsAddAppsToCollectionState::transitToSaveState(const QList<int> &appList); |
69 Signal emitted when applications are selected. |
162 Signal emitted when applications are selected. |
70 \param appList application list. |
163 \param appList application list. |
71 */ |
164 */ |
72 |
165 |
73 /*! |
166 /*! |
74 \fn void transitToFinalState(); |
167 \fn void HsAddAppsToCollectionState::transitToFinalState(); |
75 Signal emitted when user selects cancel. |
168 Signal emitted when user selects cancel. |
76 \param collectionName name of collection. |
169 \param collectionName name of collection. |
77 */ |
170 */ |
78 |
171 |
79 /*! |
172 /*! |
80 Constructor. |
173 Constructor. |
81 \return \a true on success, \a false otherwise. |
174 \return \a true on success, \a false otherwise. |
82 \param parent Owner. |
175 \param parent Owner. |
83 */ |
176 */ |
84 HsAddAppsToCollectionState::HsAddAppsToCollectionState(QState *parent) : |
177 HsAddAppsToCollectionState::HsAddAppsToCollectionState(QState *parent) : |
85 QState(parent), mCollectionName(0), mCollectionId(0), mAppList(), |
178 QState(parent), mCollectionName(), mCollectionId(0), mAppList(), |
86 mShowConfirmation(0), mInitialState(0), mSelectCollectionState(0), |
179 mShowConfirmation(0), mInitialState(0), mSelectCollectionState(0), |
87 mNewCollectionState(0), mAppsCheckListState(0), mActionType( |
180 mNewCollectionState(0), mAppsCheckListState(0), mActionType( |
88 NoActionType), mApplicationsSortAttribute(NoHsSortAttribute), |
181 NoActionType), mApplicationsSortAttribute(NoHsSortAttribute), |
89 mCollectionsSortAttribute(NoHsSortAttribute), mAppsCheckList(0) |
182 mCollectionsSortAttribute(NoHsSortAttribute), mAppsCheckList(0), |
|
183 mEditorDialog(0), mEditorFinishedEntered(false), mListDialog(0), |
|
184 mListFinishedEntered(false) |
90 { |
185 { |
91 construct(); |
186 construct(); |
92 } |
187 } |
93 |
188 |
94 /*! |
189 /*! |
95 Destructor. |
190 Destructor. |
96 |
191 |
97 */ |
192 */ |
98 HsAddAppsToCollectionState::~HsAddAppsToCollectionState() |
193 HsAddAppsToCollectionState::~HsAddAppsToCollectionState() |
99 { |
194 { |
100 delete mAppsCheckList; |
195 |
101 } |
196 } |
102 |
197 |
103 /*! |
198 /*! |
104 Constructor part. |
199 Constructor part. |
105 */ |
200 */ |
293 #pragma CTC SKIP |
396 #pragma CTC SKIP |
294 #endif //COVERAGE_MEASUREMENT |
397 #endif //COVERAGE_MEASUREMENT |
295 void HsAddAppsToCollectionState::newCollection() |
398 void HsAddAppsToCollectionState::newCollection() |
296 { |
399 { |
297 qDebug("HsAddAppsToCollectionState::newCollection"); |
400 qDebug("HsAddAppsToCollectionState::newCollection"); |
298 |
|
299 HSMENUTEST_FUNC_ENTRY("HsAddAppsToCollectionState::newCollection"); |
401 HSMENUTEST_FUNC_ENTRY("HsAddAppsToCollectionState::newCollection"); |
300 HsCollectionNameDialog editor; |
402 mEditorFinishedEntered = false; |
301 HbAction *result = editor.exec(); |
403 mEditorDialog = new HsCollectionNameDialog(); |
302 if (result == editor.primaryAction()) { |
404 mEditorDialog->open(this, SLOT(editorDialogFinished(HbAction*))); |
303 QString newName(editor.newName(editor.value().toString(), true)); |
405 |
304 if (mActionType == ViaAllViewOptionMenuType) { |
|
305 qDebug("HsAddAppsToCollectionState::newCollection() " |
|
306 "- emit collectionNameSelectedCl(newName)"); |
|
307 emit transitToAppsCheckListState(newName); |
|
308 } else { |
|
309 qDebug("HsAddAppsToCollectionState::newCollection() " |
|
310 "- emit collectionNameSelected(newName)"); |
|
311 emit transitToSaveState(newName); |
|
312 } |
|
313 } else { |
|
314 qDebug( |
|
315 "HsAddAppsToCollectionState::newCollection() - emit cancel()"); |
|
316 emit transitToFinalState(); |
|
317 } |
|
318 HSMENUTEST_FUNC_EXIT("HsAddAppsToCollectionState::newCollection"); |
406 HSMENUTEST_FUNC_EXIT("HsAddAppsToCollectionState::newCollection"); |
319 } |
407 } |
320 #ifdef COVERAGE_MEASUREMENT |
408 #ifdef COVERAGE_MEASUREMENT |
321 #pragma CTC ENDSKIP |
409 #pragma CTC ENDSKIP |
322 #endif //COVERAGE_MEASUREMENT |
410 #endif //COVERAGE_MEASUREMENT |
323 |
411 |
324 /*! |
412 |
325 Slot invoked when select collection state is entered. |
413 // --------------------------------------------------------------------------- |
326 */ |
414 // --------------------------------------------------------------------------- |
327 #ifdef COVERAGE_MEASUREMENT |
415 // |
328 #pragma CTC SKIP |
416 void HsAddAppsToCollectionState::editorDialogFinished(HbAction* finishedAction) |
329 #endif //COVERAGE_MEASUREMENT |
417 { |
330 void HsAddAppsToCollectionState::selectCollection() |
418 if (!mEditorFinishedEntered) { |
331 { |
419 mEditorFinishedEntered = true; |
332 qDebug("HsAddAppsToCollectionState::selectCollection()"); |
420 |
333 |
421 if (finishedAction == mEditorDialog->actions().value(0)) { |
334 HSMENUTEST_FUNC_ENTRY("HsAddAppsToCollectionState::selectCollection"); |
422 QString newName(mEditorDialog->newName(mEditorDialog->value().toString(), true)); |
335 HsCollectionsListDialog listView(mCollectionsSortAttribute, |
|
336 mCollectionId); |
|
337 if (listView.exec() != listView.secondaryAction()) { |
|
338 int itemId = listView.getItemId(); |
|
339 if (itemId) { |
|
340 if (mActionType == ViaAllViewOptionMenuType) { |
423 if (mActionType == ViaAllViewOptionMenuType) { |
341 qDebug("emit collectionSelectedCl(%d)", itemId); |
424 qDebug("HsAddAppsToCollectionState::newCollection() " |
342 emit transitToAppsCheckListState(itemId); |
425 "- emit collectionNameSelectedCl(newName)"); |
|
426 emit transitToAppsCheckListState(newName); |
343 } else { |
427 } else { |
344 qDebug("emit collectionSelected(%d)", itemId); |
428 qDebug("HsAddAppsToCollectionState::newCollection() " |
345 emit transitToSaveState(itemId); |
429 "- emit collectionNameSelected(newName)"); |
|
430 emit transitToSaveState(newName); |
346 } |
431 } |
347 } else { |
432 } else { |
348 qDebug("emit createNewCollection()"); |
433 qDebug( |
349 emit transitToNewCollectionState(); |
434 "HsAddAppsToCollectionState::newCollection() - emit cancel()"); |
|
435 emit transitToFinalState(); |
350 } |
436 } |
|
437 mEditorDialog = NULL; // set to null since this will be deleted after close |
|
438 |
351 } else { |
439 } else { |
352 qDebug("emit cancel()"); |
440 // (work-around if more then one action is selected in HbDialog) |
353 emit transitToFinalState(); |
441 qWarning("Another signal finished was emited."); |
354 } |
442 } |
|
443 } |
|
444 |
|
445 /*! |
|
446 Slot invoked when select collection state is entered. |
|
447 */ |
|
448 #ifdef COVERAGE_MEASUREMENT |
|
449 #pragma CTC SKIP |
|
450 #endif //COVERAGE_MEASUREMENT |
|
451 void HsAddAppsToCollectionState::selectCollection() |
|
452 { |
|
453 qDebug("HsAddAppsToCollectionState::selectCollection()"); |
|
454 HSMENUTEST_FUNC_ENTRY("HsAddAppsToCollectionState::selectCollection"); |
|
455 mListFinishedEntered = false; |
|
456 mListDialog = new HsCollectionsListDialog(mCollectionsSortAttribute, |
|
457 mCollectionId); |
|
458 mListDialog->open(this, SLOT(listDialogFinished(HbAction*))); |
355 HSMENUTEST_FUNC_EXIT("HsAddAppsToCollectionState::selectCollection"); |
459 HSMENUTEST_FUNC_EXIT("HsAddAppsToCollectionState::selectCollection"); |
356 } |
460 } |
357 |
461 |
358 #ifdef COVERAGE_MEASUREMENT |
462 #ifdef COVERAGE_MEASUREMENT |
359 #pragma CTC ENDSKIP |
463 #pragma CTC ENDSKIP |
360 #endif //COVERAGE_MEASUREMENT |
464 #endif //COVERAGE_MEASUREMENT |
|
465 |
|
466 |
|
467 // --------------------------------------------------------------------------- |
|
468 // --------------------------------------------------------------------------- |
|
469 // |
|
470 void HsAddAppsToCollectionState::listDialogFinished(HbAction* finishedAction) |
|
471 { |
|
472 if (!mListFinishedEntered) { |
|
473 mListFinishedEntered = true; |
|
474 |
|
475 if (finishedAction != mListDialog->actions().value(1)) { |
|
476 int itemId = mListDialog->getItemId(); |
|
477 if (itemId) { |
|
478 if (mActionType == ViaAllViewOptionMenuType) { |
|
479 qDebug("emit collectionSelectedCl(%d)", itemId); |
|
480 emit transitToAppsCheckListState(itemId); |
|
481 } else { |
|
482 qDebug("emit collectionSelected(%d)", itemId); |
|
483 emit transitToSaveState(itemId); |
|
484 } |
|
485 } else { |
|
486 qDebug("emit createNewCollection()"); |
|
487 emit transitToNewCollectionState(); |
|
488 } |
|
489 } else { |
|
490 qDebug("emit cancel()"); |
|
491 emit transitToFinalState(); |
|
492 } |
|
493 |
|
494 mListDialog = NULL; // set to null since this will be deleted after close |
|
495 |
|
496 } else { |
|
497 // (work-around if more then one action is selected in HbDialog) |
|
498 qWarning("Another signal finished was emited."); |
|
499 } |
|
500 } |
|
501 |
361 /*! |
502 /*! |
362 Slot connected to saving action of state. |
503 Slot connected to saving action of state. |
363 It is called when new application are addend to collection. |
504 It is called when new application are addend to collection. |
364 \param id Id of collection to which applications were added. |
505 \param id Id of collection to which applications were added. |
365 */ |
506 */ |