18 #include "locationpickerappwindow.h" |
18 #include "locationpickerappwindow.h" |
19 |
19 |
20 #include "qlocationpickeritem.h" |
20 #include "qlocationpickeritem.h" |
21 |
21 |
22 #include "locationpickersearchview.h" |
22 #include "locationpickersearchview.h" |
23 #include "locationpickerpotraitview.h" |
23 #include "locationpickerview.h" |
24 #include "locationpickerservice.h" |
24 #include "locationpickerservice.h" |
25 #include "locationpickerdatamanager.h" |
25 #include "locationpickerdatamanager.h" |
26 #include "locationpickerdocumentloader.h" |
26 #include "locationpickerdocumentloader.h" |
27 #include "locationpickerlandscapeview.h" |
|
28 #include "locationpickercontent.h" |
27 #include "locationpickercontent.h" |
29 |
28 |
30 // ---------------------------------------------------------------------------- |
29 // ---------------------------------------------------------------------------- |
31 // LocationPickerAppWindow::LocationPickerAppWindow() |
30 // LocationPickerAppWindow::LocationPickerAppWindow() |
32 // ---------------------------------------------------------------------------- |
31 // ---------------------------------------------------------------------------- |
33 LocationPickerAppWindow::LocationPickerAppWindow( QWidget *parent, Hb::WindowFlags windowFlags ) |
32 LocationPickerAppWindow::LocationPickerAppWindow( QWidget *parent, Hb::WindowFlags windowFlags ) |
34 :HbMainWindow(parent, windowFlags), |
33 :HbMainWindow(parent, windowFlags), |
35 mLocationPickerSearchView(NULL), |
34 mLocationPickerSearchView(NULL), |
36 mLocationPickerDocumentLoader(NULL), |
35 mLocationPickerDocumentLoader(NULL), |
37 mLocationPickerPotraitView(NULL), |
36 mLocationPickerView(NULL), |
38 mLocationPickerLandscapeView(NULL), |
|
39 mLocationPickerContent(NULL), |
37 mLocationPickerContent(NULL), |
40 mService(NULL), |
38 mService(NULL) |
41 mviewType(ELocationPickerContent) |
|
42 { |
39 { |
43 // create the service object; |
40 // create the service object; |
44 mService = new LocationPickerService(this); |
41 mService = new LocationPickerService(this); |
45 mLocationPickerContent = new LocationPickerContent(); |
42 mLocationPickerContent = new LocationPickerContent(); |
46 |
43 |
47 //create document loader object |
44 //create document loader object |
48 mLocationPickerDocumentLoader = new LocationPickerDocumentLoader(); |
45 mLocationPickerDocumentLoader = new LocationPickerDocumentLoader(); |
49 |
|
50 bool ok = false; |
46 bool ok = false; |
51 //load the Locationpicker portrait view |
47 //load the Locationpicker view |
52 mLocationPickerDocumentLoader->load(":/locationpickerpotrait.docml", &ok); |
48 mLocationPickerDocumentLoader->load(":/locationpickerview.docml", &ok); |
53 Q_ASSERT_X(ok, "locationpickerservice", "invalid DocML file"); |
49 Q_ASSERT_X(ok, "locationpickerservice", "invalid DocML file"); |
54 //find graphics location picker potrait view |
50 //find graphics location picker potrait view |
55 QGraphicsWidget *locationPickerWidget = mLocationPickerDocumentLoader->findWidget("LocationPickerPotraitView"); |
51 QGraphicsWidget *locationPickerWidget = mLocationPickerDocumentLoader->findWidget("LocationPickerView"); |
56 Q_ASSERT_X((locationPickerWidget != 0), "locationpickerservice", "invalid DocML file"); |
52 Q_ASSERT_X((locationPickerWidget != 0), "locationpickerservice", "invalid DocML file"); |
57 mLocationPickerPotraitView = qobject_cast<LocationPickerPotraitView*>(locationPickerWidget); |
53 mLocationPickerView = qobject_cast<LocationPickerView*>(locationPickerWidget); |
58 bool populated = mLocationPickerContent->populateModel(Qt::Vertical); |
54 bool populated = mLocationPickerContent->populateModel(); |
59 //initialize potrait widgets and connect to respective signals |
55 connectSlots(); |
60 mLocationPickerPotraitView->init(populated, Qt::Vertical, mLocationPickerContent->getStandardListModel()); |
|
61 connectPotraitSlots(); |
|
62 if(!populated) |
56 if(!populated) |
63 { |
57 { |
64 mLocationPickerPotraitView->disableTabs(mLocationPickerContent->getStandardListModel()); |
58 mLocationPickerView->disableTabs(); |
65 addView( mLocationPickerPotraitView ); |
59 addView(mLocationPickerView); |
66 setCurrentView(mLocationPickerPotraitView); |
60 setCurrentView(mLocationPickerView); |
67 } |
61 } |
68 else |
62 else |
69 { |
63 { |
70 addView( mLocationPickerPotraitView ); |
64 //initialize potrait widgets and connect to respective signals |
71 |
65 mLocationPickerView->init( this->orientation(), mLocationPickerContent->getStandardModel()); |
72 mLocationPickerDocumentLoader->reset(); |
66 addView( mLocationPickerView ); |
73 |
67 setCurrentView(mLocationPickerView); |
74 //load the Locationpicker landscape view |
68 //connect to orientationChanged signal |
75 mLocationPickerDocumentLoader->load(":/locationpickerlandscape.docml", &ok); |
69 connect(this, SIGNAL(orientationChanged(Qt::Orientation)),this, SLOT(changeOrientation(Qt::Orientation))); |
76 Q_ASSERT_X(ok, "locationpickerservice", "invalid DocML file"); |
70 connect(this, SIGNAL(aboutToChangeOrientation()),this, SLOT(closeDetailsDialog())); |
77 //find graphics location picker landscape view |
71 |
78 locationPickerWidget = mLocationPickerDocumentLoader->findWidget("LocationPickerLandscapeView"); |
|
79 Q_ASSERT_X((locationPickerWidget != 0), "locationpickerservice", "invalid DocML file"); |
|
80 mLocationPickerLandscapeView = qobject_cast<LocationPickerLandscapeView*>(locationPickerWidget); |
|
81 mLocationPickerContent->populateModel(Qt::Horizontal); |
|
82 //initialize widgets and connect to respective signals |
|
83 mLocationPickerLandscapeView->init(Qt::Horizontal, mLocationPickerContent->getStandardModel()); |
|
84 connectLandscapeSlots(); |
|
85 addView(mLocationPickerLandscapeView); |
|
86 //connect to orientationChanged signal |
|
87 connect(this, SIGNAL(orientationChanged(Qt::Orientation)),this, SLOT(changeOrientation(Qt::Orientation))); |
|
88 //launch the view in current orientation |
|
89 changeOrientation(this->orientation()); |
|
90 } |
72 } |
91 } |
73 } |
92 |
74 |
93 // ---------------------------------------------------------------------------- |
75 // ---------------------------------------------------------------------------- |
94 // LocationPickerAppWindow::~LocationPickerAppWindow() |
76 // LocationPickerAppWindow::~LocationPickerAppWindow() |
137 Q_ASSERT_X((locationPickerSearchWidget != 0), "locationpickerService", "invalid DocML file"); |
118 Q_ASSERT_X((locationPickerSearchWidget != 0), "locationpickerService", "invalid DocML file"); |
138 mLocationPickerSearchView = qobject_cast<LocationPickerSearchView*>(locationPickerSearchWidget); |
119 mLocationPickerSearchView = qobject_cast<LocationPickerSearchView*>(locationPickerSearchWidget); |
139 Q_ASSERT_X((mLocationPickerSearchView != 0), "mLocationPickerSearchView", |
120 Q_ASSERT_X((mLocationPickerSearchView != 0), "mLocationPickerSearchView", |
140 "qobject cast failure"); |
121 "qobject cast failure"); |
141 //initialize the action items and connect to slots |
122 //initialize the action items and connect to slots |
142 mLocationPickerSearchView->init(mLocationPickerContent->getStandardListModel()); |
123 mLocationPickerSearchView->init(mLocationPickerContent->getStandardModel()); |
143 connect(mLocationPickerSearchView,SIGNAL(switchView()),this,SLOT(activateLocationPickerView())); |
124 connect(mLocationPickerSearchView,SIGNAL(switchView()),this,SLOT(activateLocationPickerView())); |
144 connect(mLocationPickerSearchView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); |
125 connect(mLocationPickerSearchView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); |
145 addView(mLocationPickerSearchView); |
126 addView(mLocationPickerSearchView); |
146 } |
127 } |
147 //set LocationPickerSearchview as current view |
128 //set LocationPickerSearchview as current view |
148 setCurrentView(mLocationPickerSearchView); |
129 setCurrentView(mLocationPickerSearchView); |
149 mviewType = ELocationPickerSearchView; |
130 |
150 } |
131 } |
|
132 |
151 |
133 |
152 // ---------------------------------------------------------------------------- |
134 // ---------------------------------------------------------------------------- |
153 // LocationPickerAppWindow::activateLocationPickerView() |
135 // LocationPickerAppWindow::activateLocationPickerView() |
154 // ---------------------------------------------------------------------------- |
136 // ---------------------------------------------------------------------------- |
155 void LocationPickerAppWindow::activateLocationPickerView() |
137 void LocationPickerAppWindow::activateLocationPickerView() |
156 { |
138 { |
157 mviewType = ELocationPickerContent; |
139 mLocationPickerView->setViewType( ELocationPickerContent ); |
158 //check the orientation and load view accordingly |
140 //check the orientation and load view accordingly |
159 if(this->orientation() == Qt::Horizontal) |
141 if(this->orientation() == Qt::Horizontal) |
160 { |
142 { |
161 mLocationPickerLandscapeView->setViewType( ELocationPickerContent ); |
143 mLocationPickerView->manageHgWidget(); |
162 mLocationPickerLandscapeView->manageHgWidget(); |
|
163 setCurrentView(mLocationPickerLandscapeView); |
|
164 } |
144 } |
165 else |
145 else |
166 { |
146 { |
167 mLocationPickerPotraitView->setViewType( ELocationPickerContent ); |
147 mLocationPickerView->manageListView(); |
168 mLocationPickerPotraitView->manageListView(); |
|
169 setCurrentView( mLocationPickerPotraitView ); |
|
170 } |
148 } |
|
149 setCurrentView(mLocationPickerView); |
171 } |
150 } |
172 |
151 |
173 // ---------------------------------------------------------------------------- |
152 // ---------------------------------------------------------------------------- |
174 // LocationPickerAppWindow::changeOrientation() |
153 // LocationPickerAppWindow::changeOrientation() |
175 // ---------------------------------------------------------------------------- |
154 // ---------------------------------------------------------------------------- |
176 void LocationPickerAppWindow::changeOrientation( Qt::Orientation ) |
155 void LocationPickerAppWindow::changeOrientation( Qt::Orientation ) |
177 { |
156 { |
178 //check the orientation and load view accordingly |
157 //check the orientation and load view accordingly |
179 if( orientation() == (Qt::Horizontal )) |
158 if(mLocationPickerView->getViewType()== ELocationPickerCollectionContent || |
|
159 mLocationPickerView->getViewType()== ELocationPickerContent ) |
180 { |
160 { |
181 loadLandscape(); |
161 if(this->orientation() == Qt::Vertical) |
182 } |
162 { |
183 else |
163 mLocationPickerView->manageListView(); |
184 { |
164 |
185 loadPotrait(); |
165 } |
|
166 |
|
167 else if(this->orientation() == Qt::Horizontal) |
|
168 { |
|
169 mLocationPickerView->manageHgWidget(); |
|
170 } |
186 } |
171 } |
187 } |
172 } |
188 |
173 |
189 // ---------------------------------------------------------------------------- |
174 // ---------------------------------------------------------------------------- |
190 // LocationPickerAppWindow::loadPotrait() |
175 // LocationPickerAppWindow::closeDetailsDialog() |
191 // ---------------------------------------------------------------------------- |
176 // ---------------------------------------------------------------------------- |
192 void LocationPickerAppWindow::loadPotrait() |
177 void LocationPickerAppWindow::closeDetailsDialog() |
193 { |
178 { |
194 //load potrait view except for search view |
179 mLocationPickerView->closeDetailsDialog(); |
195 if(mviewType != ELocationPickerSearchView) |
|
196 { |
|
197 if(mLocationPickerLandscapeView->getViewType() == ELocationPickerContent) |
|
198 { |
|
199 mLocationPickerPotraitView->setViewType(ELocationPickerContent); |
|
200 } |
|
201 mLocationPickerPotraitView->manageListView(); |
|
202 setCurrentView( mLocationPickerPotraitView ); |
|
203 } |
|
204 } |
180 } |
205 |
181 |
206 // ---------------------------------------------------------------------------- |
182 // ---------------------------------------------------------------------------- |
207 // LocationPickerAppWindow::loadLandscape() |
183 // LocationPickerAppWindow::connectSlots() |
208 // ---------------------------------------------------------------------------- |
184 // ---------------------------------------------------------------------------- |
209 void LocationPickerAppWindow::loadLandscape() |
185 void LocationPickerAppWindow::connectSlots() |
210 { |
|
211 if(mviewType != ELocationPickerSearchView) |
|
212 { |
|
213 //load landscape view in current potrait content |
|
214 mLocationPickerLandscapeView->setViewType( mLocationPickerPotraitView->getViewType() ); |
|
215 //load landscape for all content except collectionlistcontent |
|
216 if(mLocationPickerPotraitView->getViewType() != ELocationPickerCollectionListContent) |
|
217 { |
|
218 mLocationPickerLandscapeView->manageHgWidget(); |
|
219 setCurrentView(mLocationPickerLandscapeView); |
|
220 } |
|
221 } |
|
222 } |
|
223 |
|
224 // ---------------------------------------------------------------------------- |
|
225 // LocationPickerAppWindow::loadLandscape() |
|
226 // ---------------------------------------------------------------------------- |
|
227 void LocationPickerAppWindow::connectPotraitSlots() |
|
228 { |
186 { |
229 connect(mLocationPickerPotraitView,SIGNAL(switchToSearchView()),this,SLOT(activateSearchView())); |
187 connect(mLocationPickerView,SIGNAL(switchToSearchView()),this,SLOT(activateSearchView())); |
230 connect(mLocationPickerPotraitView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); |
188 connect(mLocationPickerView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); |
231 connect(mLocationPickerPotraitView,SIGNAL(completeService()),this,SLOT(serviceComplete())); |
189 connect(mLocationPickerView,SIGNAL(completeService()),this,SLOT(serviceComplete())); |
232 connect(mLocationPickerPotraitView,SIGNAL(sendCategoryID( quint32 )),this,SLOT(setCategoryId( quint32 ))); |
|
233 connect(mLocationPickerPotraitView,SIGNAL(handleAllList()),this,SLOT(allListHandle())); |
|
234 connect(mLocationPickerPotraitView,SIGNAL(collectionContentExited()),this,SLOT(clearContentModels())); |
|
235 } |
|
236 |
|
237 // ---------------------------------------------------------------------------- |
|
238 // LocationPickerAppWindow::loadLandscape() |
|
239 // ---------------------------------------------------------------------------- |
|
240 void LocationPickerAppWindow::connectLandscapeSlots() |
|
241 { |
|
242 connect(mLocationPickerLandscapeView,SIGNAL(switchToSearchView()),this,SLOT(activateSearchView())); |
|
243 connect(mLocationPickerLandscapeView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); |
|
244 connect(mLocationPickerLandscapeView,SIGNAL(completeService()),this,SLOT(serviceComplete())); |
|
245 connect(mLocationPickerLandscapeView,SIGNAL(sendCategoryID( quint32 )),this,SLOT(setCategoryId( quint32 ))); |
|
246 connect(mLocationPickerLandscapeView,SIGNAL(handleCollectionList()),this,SLOT(handleCollectionList())); |
|
247 connect(mLocationPickerLandscapeView,SIGNAL(collectionContentExited()),this,SLOT(clearContentModels())); |
|
248 } |
|
249 |
|
250 // ---------------------------------------------------------------------------- |
|
251 // LocationPickerAppWindow::setCategoryId() |
|
252 // ---------------------------------------------------------------------------- |
|
253 void LocationPickerAppWindow::setCategoryId( quint32 acategoryId ) |
|
254 { |
|
255 //set the same category id to both views |
|
256 mLocationPickerPotraitView->setCategoryID(acategoryId); |
|
257 mLocationPickerLandscapeView->setCategoryID(acategoryId); |
|
258 //Load the collectioncontent in appropriate orientation |
|
259 if(orientation() == Qt::Vertical) |
|
260 { |
|
261 mviewType = ELocationPickerCollectionContent; |
|
262 mLocationPickerPotraitView->manageListView(); |
|
263 setCurrentView( mLocationPickerPotraitView ); |
|
264 } |
|
265 else |
|
266 { |
|
267 mviewType = ELocationPickerCollectionContent; |
|
268 loadLandscape(); |
|
269 } |
|
270 } |
|
271 |
|
272 // ---------------------------------------------------------------------------- |
|
273 // LocationPickerAppWindow::handleCollectionList() |
|
274 // ---------------------------------------------------------------------------- |
|
275 void LocationPickerAppWindow::handleCollectionList() |
|
276 { |
|
277 //In collection List both view should look same(list) |
|
278 mLocationPickerPotraitView->setViewType( ELocationPickerCollectionListContent ); |
|
279 mviewType = ELocationPickerCollectionListContent; |
|
280 mLocationPickerPotraitView->manageListView(); |
|
281 setCurrentView( mLocationPickerPotraitView ); |
|
282 } |
|
283 |
|
284 // ---------------------------------------------------------------------------- |
|
285 // LocationPickerAppWindow::allListHandle() |
|
286 // ---------------------------------------------------------------------------- |
|
287 void LocationPickerAppWindow::allListHandle() |
|
288 { |
|
289 //all list after collection list in horizontal orientation |
|
290 mLocationPickerLandscapeView->setViewType( ELocationPickerContent ); |
|
291 mLocationPickerLandscapeView->manageHgWidget(); |
|
292 setCurrentView(mLocationPickerLandscapeView); |
|
293 } |
|
294 |
|
295 // ---------------------------------------------------------------------------- |
|
296 // LocationPickerAppWindow::clearContentModels() |
|
297 // ---------------------------------------------------------------------------- |
|
298 void LocationPickerAppWindow::clearContentModels() |
|
299 { |
|
300 mLocationPickerLandscapeView->clearContentModel(); |
|
301 mLocationPickerPotraitView->clearContentModel(); |
|
302 } |
190 } |
303 |
191 |
304 Q_IMPLEMENT_USER_METATYPE(QLocationPickerItem) |
192 Q_IMPLEMENT_USER_METATYPE(QLocationPickerItem) |