23 #include "locationpickerpotraitview.h" |
23 #include "locationpickerpotraitview.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" |
27 #include "locationpickerlandscapeview.h" |
|
28 #include "locationpickercontent.h" |
28 |
29 |
29 // ---------------------------------------------------------------------------- |
30 // ---------------------------------------------------------------------------- |
30 // LocationPickerAppWindow::LocationPickerAppWindow() |
31 // LocationPickerAppWindow::LocationPickerAppWindow() |
31 // ---------------------------------------------------------------------------- |
32 // ---------------------------------------------------------------------------- |
32 LocationPickerAppWindow::LocationPickerAppWindow(QWidget *parent, Hb::WindowFlags windowFlags) |
33 LocationPickerAppWindow::LocationPickerAppWindow( QWidget *parent, Hb::WindowFlags windowFlags ) |
33 :HbMainWindow(parent, windowFlags), |
34 :HbMainWindow(parent, windowFlags), |
34 mLocationPickerSearchView(NULL), |
35 mLocationPickerSearchView(NULL), |
35 mLocationPickerDocumentLoader(NULL), |
36 mLocationPickerDocumentLoader(NULL), |
36 mLocationPickerPotraitView(NULL), |
37 mLocationPickerPotraitView(NULL), |
37 mLocationPickerLandscapeView(NULL), |
38 mLocationPickerLandscapeView(NULL), |
|
39 mLocationPickerContent(NULL), |
38 mService(NULL), |
40 mService(NULL), |
39 mviewType(ELocationPickerContent) |
41 mviewType(ELocationPickerContent) |
40 { |
42 { |
41 // create the service object; |
43 // create the service object; |
42 mService = new LocationPickerService(this); |
44 mService = new LocationPickerService(this); |
|
45 mLocationPickerContent = new LocationPickerContent(); |
|
46 |
43 //create document loader object |
47 //create document loader object |
44 mLocationPickerDocumentLoader = new LocationPickerDocumentLoader(); |
48 mLocationPickerDocumentLoader = new LocationPickerDocumentLoader(); |
45 |
49 |
46 bool ok = false; |
50 bool ok = false; |
47 //load the Locationpicker portrait view |
51 //load the Locationpicker portrait view |
49 Q_ASSERT_X(ok, "locationpickerservice", "invalid DocML file"); |
53 Q_ASSERT_X(ok, "locationpickerservice", "invalid DocML file"); |
50 //find graphics location picker potrait view |
54 //find graphics location picker potrait view |
51 QGraphicsWidget *locationPickerWidget = mLocationPickerDocumentLoader->findWidget("LocationPickerPotraitView"); |
55 QGraphicsWidget *locationPickerWidget = mLocationPickerDocumentLoader->findWidget("LocationPickerPotraitView"); |
52 Q_ASSERT_X((locationPickerWidget != 0), "locationpickerservice", "invalid DocML file"); |
56 Q_ASSERT_X((locationPickerWidget != 0), "locationpickerservice", "invalid DocML file"); |
53 mLocationPickerPotraitView = qobject_cast<LocationPickerPotraitView*>(locationPickerWidget); |
57 mLocationPickerPotraitView = qobject_cast<LocationPickerPotraitView*>(locationPickerWidget); |
|
58 bool populated = mLocationPickerContent->populateModel(Qt::Vertical); |
54 //initialize potrait widgets and connect to respective signals |
59 //initialize potrait widgets and connect to respective signals |
55 mLocationPickerPotraitView->init(Qt::Vertical); |
60 mLocationPickerPotraitView->init(populated, Qt::Vertical, mLocationPickerContent->getStandardListModel()); |
56 connectPotraitSlots(); |
61 connectPotraitSlots(); |
57 addView( mLocationPickerPotraitView ); |
62 if(!populated) |
58 |
63 { |
59 mLocationPickerDocumentLoader->reset(); |
64 mLocationPickerPotraitView->disableTabs(mLocationPickerContent->getStandardListModel()); |
60 |
65 addView( mLocationPickerPotraitView ); |
61 //load the Locationpicker landscape view |
66 setCurrentView(mLocationPickerPotraitView); |
62 mLocationPickerDocumentLoader->load(":/locationpickerlandscape.docml", &ok); |
67 } |
63 Q_ASSERT_X(ok, "locationpickerservice", "invalid DocML file"); |
68 else |
64 //find graphics location picker landscape view |
69 { |
65 locationPickerWidget = mLocationPickerDocumentLoader->findWidget("LocationPickerLandscapeView"); |
70 addView( mLocationPickerPotraitView ); |
66 Q_ASSERT_X((locationPickerWidget != 0), "locationpickerservice", "invalid DocML file"); |
71 |
67 mLocationPickerLandscapeView = qobject_cast<LocationPickerLandscapeView*>(locationPickerWidget); |
72 mLocationPickerDocumentLoader->reset(); |
68 //initialize widgets and connect to respective signals |
73 |
69 mLocationPickerLandscapeView->init(Qt::Horizontal); |
74 //load the Locationpicker landscape view |
70 connectLandscapeSlots(); |
75 mLocationPickerDocumentLoader->load(":/locationpickerlandscape.docml", &ok); |
71 addView(mLocationPickerLandscapeView); |
76 Q_ASSERT_X(ok, "locationpickerservice", "invalid DocML file"); |
72 //connect to orientationChanged signal |
77 //find graphics location picker landscape view |
73 connect(this, SIGNAL(orientationChanged(Qt::Orientation)),this, SLOT(changeOrientation(Qt::Orientation))); |
78 locationPickerWidget = mLocationPickerDocumentLoader->findWidget("LocationPickerLandscapeView"); |
74 //launch the view in current orientation |
79 Q_ASSERT_X((locationPickerWidget != 0), "locationpickerservice", "invalid DocML file"); |
75 changeOrientation(this->orientation()); |
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->getStandardGridModel()); |
|
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 } |
76 } |
91 } |
77 |
92 |
78 // ---------------------------------------------------------------------------- |
93 // ---------------------------------------------------------------------------- |
79 // LocationPickerAppWindow::~LocationPickerAppWindow() |
94 // LocationPickerAppWindow::~LocationPickerAppWindow() |
80 // ---------------------------------------------------------------------------- |
95 // ---------------------------------------------------------------------------- |
83 delete mService; |
98 delete mService; |
84 delete mLocationPickerSearchView; |
99 delete mLocationPickerSearchView; |
85 delete mLocationPickerDocumentLoader; |
100 delete mLocationPickerDocumentLoader; |
86 delete mLocationPickerPotraitView; |
101 delete mLocationPickerPotraitView; |
87 delete mLocationPickerLandscapeView; |
102 delete mLocationPickerLandscapeView; |
|
103 delete mLocationPickerContent; |
88 } |
104 } |
89 |
105 |
90 // ---------------------------------------------------------------------------- |
106 // ---------------------------------------------------------------------------- |
91 // LocationPickerAppWindow::itemSelected() |
107 // LocationPickerAppWindow::itemSelected() |
92 // ---------------------------------------------------------------------------- |
108 // ---------------------------------------------------------------------------- |
93 void LocationPickerAppWindow::itemSelected( quint32 aLmid ) |
109 void LocationPickerAppWindow::itemSelected( quint32 aLmid ) |
94 { |
110 { |
95 QLocationPickerItem item; |
111 QLocationPickerItem item; |
96 LocationPickerDataManager dataManager; |
112 LocationPickerDataManager::getInstance()->getLocationItem(aLmid, item); |
97 dataManager.getLocationItem(aLmid, item); |
|
98 // complete the request |
113 // complete the request |
99 mService->complete(item); |
114 mService->complete(item); |
100 } |
115 } |
101 |
116 |
102 void LocationPickerAppWindow::serviceComplete() |
117 void LocationPickerAppWindow::serviceComplete() |
122 Q_ASSERT_X((locationPickerSearchWidget != 0), "locationpickerService", "invalid DocML file"); |
137 Q_ASSERT_X((locationPickerSearchWidget != 0), "locationpickerService", "invalid DocML file"); |
123 mLocationPickerSearchView = qobject_cast<LocationPickerSearchView*>(locationPickerSearchWidget); |
138 mLocationPickerSearchView = qobject_cast<LocationPickerSearchView*>(locationPickerSearchWidget); |
124 Q_ASSERT_X((mLocationPickerSearchView != 0), "mLocationPickerSearchView", |
139 Q_ASSERT_X((mLocationPickerSearchView != 0), "mLocationPickerSearchView", |
125 "qobject cast failure"); |
140 "qobject cast failure"); |
126 //initialize the action items and connect to slots |
141 //initialize the action items and connect to slots |
127 mLocationPickerSearchView->init(); |
142 mLocationPickerSearchView->init(mLocationPickerContent->getStandardListModel()); |
128 connect(mLocationPickerSearchView,SIGNAL(switchView()),this,SLOT(activateLocationPickerView())); |
143 connect(mLocationPickerSearchView,SIGNAL(switchView()),this,SLOT(activateLocationPickerView())); |
129 connect(mLocationPickerSearchView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); |
144 connect(mLocationPickerSearchView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); |
130 addView(mLocationPickerSearchView); |
145 addView(mLocationPickerSearchView); |
131 } |
146 } |
132 //set LocationPickerSearchview as current view |
147 //set LocationPickerSearchview as current view |
133 setCurrentView(mLocationPickerSearchView); |
148 setCurrentView(mLocationPickerSearchView); |
134 mviewType = ELocationPickerSearchView; |
149 mviewType = ELocationPickerSearchView; |
|
150 |
135 } |
151 } |
136 |
152 |
137 // ---------------------------------------------------------------------------- |
153 // ---------------------------------------------------------------------------- |
138 // LocationPickerAppWindow::activateLocationPickerView() |
154 // LocationPickerAppWindow::activateLocationPickerView() |
139 // ---------------------------------------------------------------------------- |
155 // ---------------------------------------------------------------------------- |
212 void LocationPickerAppWindow::connectPotraitSlots() |
228 void LocationPickerAppWindow::connectPotraitSlots() |
213 { |
229 { |
214 connect(mLocationPickerPotraitView,SIGNAL(switchToSearchView()),this,SLOT(activateSearchView())); |
230 connect(mLocationPickerPotraitView,SIGNAL(switchToSearchView()),this,SLOT(activateSearchView())); |
215 connect(mLocationPickerPotraitView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); |
231 connect(mLocationPickerPotraitView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); |
216 connect(mLocationPickerPotraitView,SIGNAL(completeService()),this,SLOT(serviceComplete())); |
232 connect(mLocationPickerPotraitView,SIGNAL(completeService()),this,SLOT(serviceComplete())); |
217 connect(mLocationPickerPotraitView,SIGNAL(sendCategoryID( quint32 )),this,SLOT(setCategoryID( quint32 ))); |
233 connect(mLocationPickerPotraitView,SIGNAL(sendCategoryID( quint32 )),this,SLOT(setCategoryId( quint32 ))); |
218 connect(mLocationPickerPotraitView,SIGNAL(handleAllList()),this,SLOT(allListHandle())); |
234 connect(mLocationPickerPotraitView,SIGNAL(handleAllList()),this,SLOT(allListHandle())); |
|
235 connect(mLocationPickerPotraitView,SIGNAL(collectionContentExited()),this,SLOT(clearContentModels())); |
219 } |
236 } |
220 |
237 |
221 // ---------------------------------------------------------------------------- |
238 // ---------------------------------------------------------------------------- |
222 // LocationPickerAppWindow::loadLandscape() |
239 // LocationPickerAppWindow::loadLandscape() |
223 // ---------------------------------------------------------------------------- |
240 // ---------------------------------------------------------------------------- |
224 void LocationPickerAppWindow::connectLandscapeSlots() |
241 void LocationPickerAppWindow::connectLandscapeSlots() |
225 { |
242 { |
226 connect(mLocationPickerLandscapeView,SIGNAL(switchToSearchView()),this,SLOT(activateSearchView())); |
243 connect(mLocationPickerLandscapeView,SIGNAL(switchToSearchView()),this,SLOT(activateSearchView())); |
227 connect(mLocationPickerLandscapeView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); |
244 connect(mLocationPickerLandscapeView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); |
228 connect(mLocationPickerLandscapeView,SIGNAL(completeService()),this,SLOT(serviceComplete())); |
245 connect(mLocationPickerLandscapeView,SIGNAL(completeService()),this,SLOT(serviceComplete())); |
229 connect(mLocationPickerLandscapeView,SIGNAL(sendCategoryID( quint32 )),this,SLOT(setCategoryID( quint32 ))); |
246 connect(mLocationPickerLandscapeView,SIGNAL(sendCategoryID( quint32 )),this,SLOT(setCategoryId( quint32 ))); |
230 connect(mLocationPickerLandscapeView,SIGNAL(handleCollectionList()),this,SLOT(handleCollectionList())); |
247 connect(mLocationPickerLandscapeView,SIGNAL(handleCollectionList()),this,SLOT(handleCollectionList())); |
231 } |
248 connect(mLocationPickerLandscapeView,SIGNAL(collectionContentExited()),this,SLOT(clearContentModels())); |
232 |
249 } |
233 // ---------------------------------------------------------------------------- |
250 |
234 // LocationPickerAppWindow::setCategoryID() |
251 // ---------------------------------------------------------------------------- |
235 // ---------------------------------------------------------------------------- |
252 // LocationPickerAppWindow::setCategoryId() |
236 void LocationPickerAppWindow::setCategoryID( quint32 acategoryId ) |
253 // ---------------------------------------------------------------------------- |
|
254 void LocationPickerAppWindow::setCategoryId( quint32 acategoryId ) |
237 { |
255 { |
238 //set the same category id to both views |
256 //set the same category id to both views |
239 mLocationPickerPotraitView->setCategoryID(acategoryId); |
257 mLocationPickerPotraitView->setCategoryID(acategoryId); |
240 mLocationPickerLandscapeView->setCategoryID(acategoryId); |
258 mLocationPickerLandscapeView->setCategoryID(acategoryId); |
241 //Load the collectioncontent in appropriate orientation |
259 //Load the collectioncontent in appropriate orientation |