20 #include <HbMainWindow> |
20 #include <HbMainWindow> |
21 #include <qstandarditemmodel.h> |
21 #include <qstandarditemmodel.h> |
22 #include <HbListView> |
22 #include <HbListView> |
23 #include <HbListViewItem> |
23 #include <HbListViewItem> |
24 #include <HbAction> |
24 #include <HbAction> |
|
25 #include <QTimer> |
|
26 #include <HbToolBar> |
25 |
27 |
26 #include "locationpickerproxymodel.h" |
28 #include "locationpickerproxymodel.h" |
27 #include "locationpickerdatamanager.h" |
29 #include "locationpickerdatamanager.h" |
28 #include "locationpickercontent.h" |
30 #include "locationpickercontent.h" |
29 #include "locationpickercollectionlistcontent.h" |
31 #include "locationpickercollectionlistcontent.h" |
113 mProxyModel->sort(0, Qt::AscendingOrder); |
115 mProxyModel->sort(0, Qt::AscendingOrder); |
114 } |
116 } |
115 //Get HbAction items |
117 //Get HbAction items |
116 mListView = qobject_cast<HbListView*> (mDocumentLoader->findObject(QString( |
118 mListView = qobject_cast<HbListView*> (mDocumentLoader->findObject(QString( |
117 "ListView"))); |
119 "ListView"))); |
118 //get the action items from docml |
120 HbToolBar* toolbar = new HbToolBar(); |
119 mAllAction = qobject_cast<HbAction*> (mDocumentLoader->findObject(QString( |
121 //Create Action Items |
120 "allAction"))); |
122 mAllAction = new HbAction(); |
121 mCollectionAction = qobject_cast<HbAction*> (mDocumentLoader->findObject( |
123 mAllAction->setIcon(QString("qtg_mono_location")); |
122 QString("collectionAction"))); |
124 mAllAction->setCheckable(true); |
123 mSearchAction = qobject_cast<HbAction*> (mDocumentLoader->findObject(QString( |
125 mCollectionAction =new HbAction(); |
124 "searchAction"))); |
126 mCollectionAction->setIcon(QString("qtg_mono_location_collection")); |
|
127 mCollectionAction->setCheckable(true); |
|
128 mSearchAction = new HbAction(); |
|
129 mSearchAction->setIcon(QString("qtg_mono_search")); |
|
130 |
|
131 toolbar->addAction(mAllAction); |
|
132 toolbar->addAction(mCollectionAction); |
|
133 toolbar->addAction(mSearchAction); |
|
134 this->setToolBar(toolbar); |
125 mAscendingAction = qobject_cast<HbAction*> (mDocumentLoader->findObject( |
135 mAscendingAction = qobject_cast<HbAction*> (mDocumentLoader->findObject( |
126 QString("ascendingAction"))); |
136 QString("ascendingAction"))); |
127 mDescendingAction = qobject_cast<HbAction*> (mDocumentLoader->findObject( |
137 mDescendingAction = qobject_cast<HbAction*> (mDocumentLoader->findObject( |
128 QString("descendingAction"))); |
138 QString("descendingAction"))); |
129 if( !mAllAction || !mCollectionAction || !mSearchAction || !mAscendingAction || !mDescendingAction || !mListView) |
139 if( !mAllAction || !mCollectionAction || !mSearchAction || !mAscendingAction || !mDescendingAction || !mListView) |
193 } |
203 } |
194 |
204 |
195 // ----------------------------------------------------------------------------- |
205 // ----------------------------------------------------------------------------- |
196 // LocationPickerView::handleActivated() |
206 // LocationPickerView::handleActivated() |
197 // ----------------------------------------------------------------------------- |
207 // ----------------------------------------------------------------------------- |
198 void LocationPickerPotraitView::handleActivated( const QModelIndex &aIndex ) |
208 void LocationPickerPotraitView::handleActivated(const QModelIndex &aIndex) |
|
209 { |
|
210 mIndex = aIndex; |
|
211 QTimer::singleShot(0, this, SLOT(changeModel())); |
|
212 } |
|
213 |
|
214 // ----------------------------------------------------------------------------- |
|
215 // LocationPickerPotraitView::changeModel() |
|
216 // ----------------------------------------------------------------------------- |
|
217 void LocationPickerPotraitView::changeModel() |
199 { |
218 { |
200 //handle the activated signal according to model set |
219 //handle the activated signal according to model set |
201 switch(mViewType) |
220 switch(mViewType) |
202 { |
221 { |
203 case ELocationPickerContent: |
222 case ELocationPickerContent: |
205 if(!mProxyModel) |
224 if(!mProxyModel) |
206 { |
225 { |
207 break; |
226 break; |
208 } |
227 } |
209 QModelIndex index = mProxyModel->mapToSource( |
228 QModelIndex index = mProxyModel->mapToSource( |
210 aIndex); |
229 mIndex); |
211 quint32 lm = 0; |
230 quint32 lm = 0; |
212 QStandardItem* item = mModel->item( index.row(), index.column() ); |
231 QStandardItem* item = mModel->item( index.row(), index.column() ); |
213 QVariant var = item->data( Qt::UserRole ); |
232 QVariant var = item->data( Qt::UserRole ); |
214 lm = var.toUInt(); |
233 lm = var.toUInt(); |
215 //item selected, complete request |
234 //item selected, complete request |
217 } |
236 } |
218 break; |
237 break; |
219 case ELocationPickerCollectionListContent: |
238 case ELocationPickerCollectionListContent: |
220 { |
239 { |
221 mLocationPickerCollectionListContent->getData( |
240 mLocationPickerCollectionListContent->getData( |
222 aIndex, mCategoryId ); |
241 mIndex, mCategoryId ); |
223 mViewType = ELocationPickerCollectionContent; |
242 mViewType = ELocationPickerCollectionContent; |
224 //send categoryID to set the collection content |
243 //send categoryID to set the collection content |
225 emit sendCategoryID(mCategoryId); |
244 emit sendCategoryID(mCategoryId); |
226 } |
245 } |
227 break; |
246 break; |
230 if(!mCollectionContent->getProxyModel()) |
249 if(!mCollectionContent->getProxyModel()) |
231 { |
250 { |
232 break; |
251 break; |
233 } |
252 } |
234 QModelIndex index = mCollectionContent->getProxyModel()->mapToSource( |
253 QModelIndex index = mCollectionContent->getProxyModel()->mapToSource( |
235 aIndex); |
254 mIndex); |
236 quint32 lm = 0; |
255 quint32 lm = 0; |
237 mCollectionContent->getData(index, lm); |
256 mCollectionContent->getData(index, lm); |
238 //item selected, complete request |
257 //item selected, complete request |
239 emit selectItem(lm); |
258 emit selectItem(lm); |
240 } |
259 } |
243 break; |
262 break; |
244 } |
263 } |
245 } |
264 } |
246 |
265 |
247 // ----------------------------------------------------------------------------- |
266 // ----------------------------------------------------------------------------- |
248 // LocationPickerView::sortAscending() |
267 // LocationPickerPotraitView::sortAscending() |
249 // ----------------------------------------------------------------------------- |
268 // ----------------------------------------------------------------------------- |
250 void LocationPickerPotraitView::sortAscending() |
269 void LocationPickerPotraitView::sortAscending() |
251 { |
270 { |
252 //check the model set and do sorting accordingly |
271 //check the model set and do sorting accordingly |
253 if (mViewType == ELocationPickerContent) |
272 if (mViewType == ELocationPickerContent) |
259 mCollectionContent->getProxyModel()->sort(0, Qt::AscendingOrder); |
278 mCollectionContent->getProxyModel()->sort(0, Qt::AscendingOrder); |
260 } |
279 } |
261 } |
280 } |
262 |
281 |
263 // ----------------------------------------------------------------------------- |
282 // ----------------------------------------------------------------------------- |
264 // LocationPickerView::sortDescending() |
283 // LocationPickerPotraitView::sortDescending() |
265 // ----------------------------------------------------------------------------- |
284 // ----------------------------------------------------------------------------- |
266 void LocationPickerPotraitView::sortDescending() |
285 void LocationPickerPotraitView::sortDescending() |
267 { |
286 { |
268 //check the model set and do sorting accordingly |
287 //check the model set and do sorting accordingly |
269 if (mViewType == ELocationPickerContent) |
288 if (mViewType == ELocationPickerContent) |
275 mCollectionContent->getProxyModel()->sort(0, Qt::DescendingOrder); |
294 mCollectionContent->getProxyModel()->sort(0, Qt::DescendingOrder); |
276 } |
295 } |
277 } |
296 } |
278 |
297 |
279 // ----------------------------------------------------------------------------- |
298 // ----------------------------------------------------------------------------- |
280 // LocationPickerView::handleAllTab() |
299 // LocationPickerPotraitView::handleAllTab() |
281 // ----------------------------------------------------------------------------- |
300 // ----------------------------------------------------------------------------- |
282 void LocationPickerPotraitView::allTabTriggered() |
301 void LocationPickerPotraitView::allTabTriggered() |
283 { |
302 { |
284 //execute only if tab is not pressed |
303 //execute only if tab is not pressed |
285 if (mAllAction->isChecked()) |
304 if (mAllAction->isChecked()) |
312 } |
331 } |
313 |
332 |
314 } |
333 } |
315 |
334 |
316 // ----------------------------------------------------------------------------- |
335 // ----------------------------------------------------------------------------- |
317 // LocationPickerView::handleCollectionTab() |
336 // LocationPickerPotraitView::handleCollectionTab() |
318 // ----------------------------------------------------------------------------- |
337 // ----------------------------------------------------------------------------- |
319 void LocationPickerPotraitView::colectionTabTriggered() |
338 void LocationPickerPotraitView::colectionTabTriggered() |
320 { |
339 { |
321 //execute only if tab is not pressed |
340 //execute only if tab is not pressed |
322 if (mCollectionAction->isChecked()) |
341 if (mCollectionAction->isChecked()) |
334 mCollectionAction->setChecked(true); |
353 mCollectionAction->setChecked(true); |
335 } |
354 } |
336 } |
355 } |
337 |
356 |
338 // ----------------------------------------------------------------------------- |
357 // ----------------------------------------------------------------------------- |
339 // LocationPickerView::searchTabTriggered() |
358 // LocationPickerPotraitView::searchTabTriggered() |
340 // ----------------------------------------------------------------------------- |
359 // ----------------------------------------------------------------------------- |
341 void LocationPickerPotraitView::searchTabTriggered() |
360 void LocationPickerPotraitView::searchTabTriggered() |
342 { |
361 { |
343 emit switchToSearchView(); |
362 emit switchToSearchView(); |
344 } |
363 } |
345 |
364 |
346 // ----------------------------------------------------------------------------- |
365 // ----------------------------------------------------------------------------- |
347 // LocationPickerView::setCollectionData() |
366 // LocationPickerPotraitView::setCollectionData() |
348 // ----------------------------------------------------------------------------- |
367 // ----------------------------------------------------------------------------- |
349 void LocationPickerPotraitView::setCollectionData( quint32 acategoryId ) |
368 void LocationPickerPotraitView::setCollectionData( quint32 acategoryId ) |
350 { |
369 { |
351 |
370 |
352 if(!mCollectionContent) |
371 if(!mCollectionContent) |
369 mDescendingAction->setEnabled(true); |
388 mDescendingAction->setEnabled(true); |
370 mCollectionAction->setChecked(true); |
389 mCollectionAction->setChecked(true); |
371 } |
390 } |
372 |
391 |
373 // ----------------------------------------------------------------------------- |
392 // ----------------------------------------------------------------------------- |
374 // LocationPickerView::setCategoryID() |
393 // LocationPickerPotraitView::setCategoryID() |
375 // ----------------------------------------------------------------------------- |
394 // ----------------------------------------------------------------------------- |
376 void LocationPickerPotraitView::setCategoryID( quint32 aCategoryId ) |
395 void LocationPickerPotraitView::setCategoryID( quint32 aCategoryId ) |
377 { |
396 { |
378 mCategoryId = aCategoryId; |
397 mCategoryId = aCategoryId; |
379 } |
398 } |
380 |
399 |
381 // ----------------------------------------------------------------------------- |
400 // ----------------------------------------------------------------------------- |
382 // LocationPickerView::getViewType() |
401 // LocationPickerPotraitView::getViewType() |
383 // ----------------------------------------------------------------------------- |
402 // ----------------------------------------------------------------------------- |
384 TViewType LocationPickerPotraitView::getViewType() |
403 TViewType LocationPickerPotraitView::getViewType() |
385 { |
404 { |
386 return mViewType; |
405 return mViewType; |
387 } |
406 } |
388 |
407 |
389 // ----------------------------------------------------------------------------- |
408 // ----------------------------------------------------------------------------- |
390 // LocationPickerView::setViewType() |
409 // LocationPickerPotraitView::setViewType() |
391 // ----------------------------------------------------------------------------- |
410 // ----------------------------------------------------------------------------- |
392 void LocationPickerPotraitView::setViewType(TViewType aViewType) |
411 void LocationPickerPotraitView::setViewType(TViewType aViewType) |
393 { |
412 { |
394 mViewType = aViewType; |
413 mViewType = aViewType; |
395 } |
414 } |
396 |
415 |
397 |
416 |
398 // ----------------------------------------------------------------------------- |
417 // ----------------------------------------------------------------------------- |
399 // LocationPickerView::clearContentModel() |
418 // LocationPickerPotraitView::clearContentModel() |
400 // ----------------------------------------------------------------------------- |
419 // ----------------------------------------------------------------------------- |
401 void LocationPickerPotraitView::clearContentModel() |
420 void LocationPickerPotraitView::clearContentModel() |
402 { |
421 { |
403 if(mCollectionContent) |
422 if(mCollectionContent) |
404 { |
423 { |