|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <hsmenueventtransition.h> |
|
19 |
|
20 #include "hsaddtohomescreenstate.h" |
|
21 #include "hsaddappstocollectionstate.h" |
|
22 #include "hsdeletecollectionstate.h" |
|
23 #include "hsdeletecollectionitemstate.h" |
|
24 #include "hsmenuworkerstate.h" |
|
25 #include "hscollectionnamestate.h" |
|
26 #include "hsarrangestate.h" |
|
27 #include "hspreviewhswidgetstate.h" |
|
28 /*! |
|
29 \class HsMenuWorkerState |
|
30 \ingroup group_hsmenustateplugin |
|
31 \brief Menu Worker State. |
|
32 */ |
|
33 |
|
34 /*! |
|
35 Constructor. |
|
36 \param parent Owner. |
|
37 */ |
|
38 HsMenuWorkerState::HsMenuWorkerState(QState *parent) : |
|
39 QState(parent), mInitialState(0) |
|
40 { |
|
41 construct(); |
|
42 } |
|
43 |
|
44 /*! |
|
45 Destructor. |
|
46 */ |
|
47 HsMenuWorkerState::~HsMenuWorkerState() |
|
48 { |
|
49 |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 void HsMenuWorkerState::construct() |
|
56 { |
|
57 HSMENUTEST_FUNC_ENTRY("HsMenuWorkerState::construct"); |
|
58 setObjectName("homescreen.nokia.com/state/MenuWorkerState"); |
|
59 |
|
60 mInitialState = new QState(this); |
|
61 setInitialState(mInitialState); |
|
62 |
|
63 // use templated creation method - less boilerplate code |
|
64 createChildState<HsAddToHomeScreenState> (HsMenuEvent::AddToHomeScreen); |
|
65 createChildState<HsDeleteCollectionState> ( |
|
66 HsMenuEvent::DeleteCollection); |
|
67 createChildState<HsDeleteCollectionItemState> ( |
|
68 HsMenuEvent::RemoveAppFromCollection); |
|
69 createChildState<HsArrangeState> (HsMenuEvent::ArrangeCollection); |
|
70 |
|
71 // create a new child state based on the template |
|
72 HsCollectionNameState *newChildState = new HsCollectionNameState(this); |
|
73 // create a transition to the new child state which will be triggered by |
|
74 // an event with specified operation type |
|
75 HsMenuEventTransition *renameCollectionTransition = |
|
76 new HsMenuEventTransition(HsMenuEvent::RenameCollection, |
|
77 mInitialState, newChildState); |
|
78 mInitialState->addTransition(renameCollectionTransition); |
|
79 |
|
80 HsMenuEventTransition *createCollectionTransition = |
|
81 new HsMenuEventTransition(HsMenuEvent::CreateCollection, |
|
82 mInitialState, newChildState); |
|
83 mInitialState->addTransition(createCollectionTransition); |
|
84 // set a transition to the initial state after child processing finished |
|
85 newChildState->addTransition(mInitialState); |
|
86 |
|
87 HsAddAppsToCollectionState *addAppsToCollectionState = |
|
88 new HsAddAppsToCollectionState(this); |
|
89 // create a transition to the new child state which will be triggered by |
|
90 // an event with specified operation type |
|
91 HsMenuEventTransition *addAppsToCollectionTransition = |
|
92 new HsMenuEventTransition(HsMenuEvent::AddAppsToCollection, |
|
93 mInitialState, addAppsToCollectionState); |
|
94 mInitialState->addTransition(addAppsToCollectionTransition); |
|
95 // set a transition to the initial state after child processing finished |
|
96 addAppsToCollectionState->addTransition(addAppsToCollectionState, |
|
97 SIGNAL(finished()), mInitialState); |
|
98 |
|
99 createChildState<HsPreviewHSWidgetState> (HsMenuEvent::PreviewHSWidget); |
|
100 |
|
101 HSMENUTEST_FUNC_EXIT("HsMenuWorkerState::construct"); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 template<class T> |
|
108 T *HsMenuWorkerState::createChildState( |
|
109 HsMenuEvent::OperationType operation) |
|
110 { |
|
111 HSMENUTEST_FUNC_ENTRY("HsMenuWorkerState::createChildState"); |
|
112 // create a new child state based on the template |
|
113 T *newChildState = new T(this); |
|
114 // create a transition to the new child state which will be triggered by |
|
115 // an event with specified operation type |
|
116 HsMenuEventTransition *newChildStateTransition = |
|
117 new HsMenuEventTransition(operation, mInitialState, newChildState); |
|
118 mInitialState->addTransition(newChildStateTransition); |
|
119 // set a transition to the initial state after child processing finished |
|
120 newChildState->addTransition(mInitialState); |
|
121 HSMENUTEST_FUNC_EXIT("HsMenuWorkerState::createChildState"); |
|
122 |
|
123 return newChildState; |
|
124 } |