14 * Description: Implementation of the SEARCH default runtime. |
14 * Description: Implementation of the SEARCH default runtime. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "searchruntime.h" |
18 #include "searchruntime.h" |
19 #include "Search_global.h" |
19 #include "search_global.h" |
20 #include "hsstatefactory.h" |
20 #include "searchstateprovider.h" |
21 |
21 |
22 #include <qstatemachine.h> |
22 #include <qstatemachine.h> |
23 #include <qstate.h> |
23 #include <qstate.h> |
24 #include <qfinalstate.h> |
24 #include <qfinalstate.h> |
25 #include <qdebug.h> |
25 #include <qdebug.h> |
26 |
26 |
27 #include <hbmainwindow.h> |
27 #include <hbmainwindow.h> |
28 |
28 |
29 // plugin factory const |
29 |
30 const char factoryManifestDir[] = "searchresources/plugins/stateproviders"; |
|
31 const char factoryPluginDir[] = "searchresources/plugins/stateproviders"; |
|
32 const char stateLibrary[] = "searchstateprovider.dll"; |
|
33 |
30 |
34 // states |
31 // states |
35 const char wizardProgressiveStateUri[] = |
32 const char wizardProgressiveStateUri[] = |
36 "search.nokia.com/state/wizardprogressivestate"; |
33 "search.nokia.com/state/wizardprogressivestate"; |
37 const char wizardSettingStateUri[] = |
34 const char wizardSettingStateUri[] = |
40 // --------------------------------------------------------------------------- |
37 // --------------------------------------------------------------------------- |
41 // searchRuntime::SearchRuntime |
38 // searchRuntime::SearchRuntime |
42 // --------------------------------------------------------------------------- |
39 // --------------------------------------------------------------------------- |
43 // |
40 // |
44 SearchRuntime::SearchRuntime(QObject* aParent) : |
41 SearchRuntime::SearchRuntime(QObject* aParent) : |
45 HsRuntime(aParent), mStateMachine(0), mWindow(0) |
42 QStateMachine(aParent),mWindow(0) |
46 { |
43 { |
47 mStateMachine = new QStateMachine(this); |
|
48 createGuiServiceParts(); |
44 createGuiServiceParts(); |
49 createStates(); |
45 createStates(); |
50 } |
46 } |
51 |
47 |
52 // --------------------------------------------------------------------------- |
48 // --------------------------------------------------------------------------- |
54 // --------------------------------------------------------------------------- |
50 // --------------------------------------------------------------------------- |
55 // |
51 // |
56 SearchRuntime::~SearchRuntime() |
52 SearchRuntime::~SearchRuntime() |
57 { |
53 { |
58 delete mWindow; |
54 delete mWindow; |
59 delete mStateMachine; |
55 // delete mStateMachine; |
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // SearchRuntime::start() |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 void SearchRuntime::start() |
|
67 { |
|
68 mStateMachine->start(); |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // SearchRuntime::stop() |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 void SearchRuntime::stop() |
|
76 { |
|
77 mStateMachine->stop(); |
|
78 } |
56 } |
79 |
57 |
80 // --------------------------------------------------------------------------- |
58 // --------------------------------------------------------------------------- |
81 // SearchRuntime::handleStateMachineStarted() |
59 // SearchRuntime::handleStateMachineStarted() |
82 // --------------------------------------------------------------------------- |
60 // --------------------------------------------------------------------------- |
83 // |
61 // |
84 void SearchRuntime::handleStateMachineStarted() |
62 void SearchRuntime::handleStateMachineStarted() |
85 { |
63 { |
86 emit started(); |
64 // emit started(); |
87 } |
65 } |
88 |
66 |
89 // --------------------------------------------------------------------------- |
67 // --------------------------------------------------------------------------- |
90 // SearchRuntime::handleStateMachineStopped() |
68 // SearchRuntime::handleStateMachineStopped() |
91 // --------------------------------------------------------------------------- |
69 // --------------------------------------------------------------------------- |
109 // SearchRuntime::createStates() |
87 // SearchRuntime::createStates() |
110 // --------------------------------------------------------------------------- |
88 // --------------------------------------------------------------------------- |
111 // |
89 // |
112 void SearchRuntime::createStates() |
90 void SearchRuntime::createStates() |
113 { |
91 { |
114 HsStateFactory factory(factoryManifestDir, factoryPluginDir); |
|
115 HsStateToken token; |
|
116 |
92 |
|
93 SearchStateProvider stateProvider; |
|
94 |
117 QFinalState* finalState = new QFinalState(); |
95 QFinalState* finalState = new QFinalState(); |
118 mStateMachine->addState(finalState); |
96 this->addState(finalState); |
119 |
97 |
120 // parallel state activates all children states |
98 // parallel state activates all children states |
121 QState* parallel = new QState(QState::ParallelStates); |
99 QState* parallel = new QState(QState::ParallelStates); |
122 mStateMachine->addState(parallel); |
100 this->addState(parallel); |
123 parallel->addTransition(this, SIGNAL(stopStateMachine()), finalState); |
101 parallel->addTransition(this, SIGNAL(stopStateMachine()), finalState); |
124 |
102 |
125 // root GUI state |
103 // root GUI state |
126 QState* guiRootState = new QState(parallel); |
104 QState* guiRootState = new QState(parallel); |
127 |
105 |
128 QState* searchRootState = new QState(guiRootState); |
106 QState* searchRootState = new QState(guiRootState); |
129 |
107 |
130 // create state based on token |
108 |
131 token.mLibrary = stateLibrary; |
109 QState* wizardProgressiveState = stateProvider.createState(wizardProgressiveStateUri); |
132 token.mUri = wizardProgressiveStateUri; |
|
133 QState* wizardProgressiveState = factory.createState(token); |
|
134 // set state specific data |
110 // set state specific data |
135 wizardProgressiveState->setParent(searchRootState); |
111 wizardProgressiveState->setParent(searchRootState); |
136 wizardProgressiveState->setObjectName(token.mUri); |
112 wizardProgressiveState->setObjectName(wizardProgressiveStateUri); |
137 token.mUri = wizardSettingStateUri; |
|
138 |
113 |
139 QState* wizardSettingState = factory.createState(token); |
114 |
|
115 QState* wizardSettingState = stateProvider.createState(wizardSettingStateUri); |
140 wizardSettingState->setParent(searchRootState); |
116 wizardSettingState->setParent(searchRootState); |
141 wizardSettingState->setObjectName(token.mUri); |
117 wizardSettingState->setObjectName(wizardSettingStateUri); |
142 |
118 |
143 wizardProgressiveState->addTransition(wizardProgressiveState, |
119 wizardProgressiveState->addTransition(wizardProgressiveState, |
144 SIGNAL(settingsState()), wizardSettingState); |
120 SIGNAL(settingsState()), wizardSettingState); |
145 |
121 |
146 // From activated back to menu |
122 // From activated back to menu |
157 wizardProgressiveState, SLOT(_customizeGoButton(bool))); |
133 wizardProgressiveState, SLOT(_customizeGoButton(bool))); |
158 |
134 |
159 // set initial state for statemachine |
135 // set initial state for statemachine |
160 searchRootState->setInitialState(wizardProgressiveState); |
136 searchRootState->setInitialState(wizardProgressiveState); |
161 guiRootState->setInitialState(searchRootState); |
137 guiRootState->setInitialState(searchRootState); |
162 mStateMachine->setInitialState(parallel); |
138 this->setInitialState(parallel); |
163 |
139 |
164 connect(mStateMachine, SIGNAL(started()), |
140 connect(this, SIGNAL(started()), |
165 SLOT(handleStateMachineStarted())); |
141 SLOT(handleStateMachineStarted())); |
166 connect(mStateMachine, SIGNAL(stopped()), |
142 connect(this, SIGNAL(stopped()), |
167 SLOT(handleStateMachineStopped())); |
143 SLOT(handleStateMachineStopped())); |
168 connect(mStateMachine, SIGNAL(finished()), |
144 connect(this, SIGNAL(finished()), |
169 SLOT(handleStateMachineStopped())); |
145 SLOT(handleStateMachineStopped())); |
170 |
146 |
171 } |
147 } |