150 mModel = |
150 mModel = |
151 HsMenuService::getCollectionModel( |
151 HsMenuService::getCollectionModel( |
152 mCollectionId, mSortAttribute, mCollectionType); |
152 mCollectionId, mSortAttribute, mCollectionType); |
153 } |
153 } |
154 |
154 |
155 handleEmptyChange(mModel->rowCount() == 0); |
155 reconnectViewComponents(mModel->rowCount() == 0); |
156 |
156 |
157 makeConnect(); |
157 makeConnect(); |
158 |
158 |
159 mMenuView->viewLabel()->setHeading( |
159 mMenuView->viewLabel()->setHeading( |
160 mModel->root().data(CaItemModel::CollectionTitleRole).toString()); |
160 mModel->root().data(CaItemModel::CollectionTitleRole).toString()); |
265 connect(mMenuView.data(), |
265 connect(mMenuView.data(), |
266 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), |
266 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), |
267 static_cast<HsBaseViewState*>(this), |
267 static_cast<HsBaseViewState*>(this), |
268 SLOT(showContextMenu(HbAbstractViewItem *, QPointF))); |
268 SLOT(showContextMenu(HbAbstractViewItem *, QPointF))); |
269 connect(mModel, SIGNAL(modelReset()), SLOT(updateLabel())); |
269 connect(mModel, SIGNAL(modelReset()), SLOT(updateLabel())); |
|
270 connect(mModel, SIGNAL(countChange()), SLOT(updateLabel())); |
270 connect(mModel, SIGNAL(empty(bool)),this, |
271 connect(mModel, SIGNAL(empty(bool)),this, |
271 SLOT(handleEmptyChange(bool))); |
272 SLOT(handleEmptyChange(bool))); |
272 connect(mModel, SIGNAL(empty(bool)),this, |
273 connect(mModel, SIGNAL(empty(bool)),this, |
273 SLOT(lockSearchButton(bool))); |
274 SLOT(lockSearchButton(bool))); |
274 } |
275 } |
290 static_cast<HsBaseViewState*>(this), |
291 static_cast<HsBaseViewState*>(this), |
291 SLOT(showContextMenu(HbAbstractViewItem *, QPointF))); |
292 SLOT(showContextMenu(HbAbstractViewItem *, QPointF))); |
292 disconnect(mModel, SIGNAL(empty(bool)),this, |
293 disconnect(mModel, SIGNAL(empty(bool)),this, |
293 SLOT(handleEmptyChange(bool))); |
294 SLOT(handleEmptyChange(bool))); |
294 |
295 |
295 disconnect(mModel, SIGNAL(empty(bool)),this, |
296 disconnect(mModel, SIGNAL(empty(bool)), this, |
296 SLOT(lockSearchButton(bool))); |
297 SLOT(lockSearchButton(bool))); |
297 |
298 |
298 disconnect(mModel, SIGNAL(modelReset()), |
299 disconnect(mModel, SIGNAL(modelReset()), this, SLOT(updateLabel())); |
299 this, SLOT(updateLabel())); |
300 disconnect(mModel, SIGNAL(countChange()), this, SLOT(updateLabel())); |
300 } |
301 } |
301 |
302 |
302 /*! |
303 /*! |
303 Handles context menu actions |
304 Handles context menu actions |
304 \param action action taken in context menu |
305 \param action action taken in context menu |
305 */ |
306 */ |
306 void HsCollectionState::contextMenuAction(HbAction *action) |
307 void HsCollectionState::contextMenuAction(HbAction *action) |
307 { |
308 { |
308 const int itemId = mContextModelIndex.data(CaItemModel::IdRole).toInt(); |
309 const int itemId = mContextModelIndex.data(CaItemModel::IdRole).toInt(); |
309 |
310 |
310 if (itemId > 0) { |
311 if (itemId > 0) { |
311 Hs::HsContextAction command = |
312 Hs::HsContextAction command = |
312 static_cast<Hs::HsContextAction> (action->data().toInt()); |
313 static_cast<Hs::HsContextAction> (action->data().toInt()); |
334 Handler to be called when model becomes not empty or model becomes empty. |
335 Handler to be called when model becomes not empty or model becomes empty. |
335 \param empty \a true when model becomes empty \a false otherwise. |
336 \param empty \a true when model becomes empty \a false otherwise. |
336 */ |
337 */ |
337 void HsCollectionState::handleEmptyChange(bool empty) |
338 void HsCollectionState::handleEmptyChange(bool empty) |
338 { |
339 { |
339 EntryFlags flags = mModel->root().data( |
340 reconnectViewComponents(empty); |
340 CaItemModel::FlagsRole).value<EntryFlags> (); |
341 mMenuView->activate(); |
341 |
342 } |
|
343 |
|
344 /*! |
|
345 Reconnects view componets beetwen empty/not empty view. |
|
346 \param empty \a true when model becomes empty \a false otherwise. |
|
347 */ |
|
348 void HsCollectionState::reconnectViewComponents(bool empty) |
|
349 { |
342 if (empty){ |
350 if (empty){ |
343 mMenuView->reset(HsEmptyLabelContext); |
351 mMenuView->reset(HsEmptyLabelContext); |
344 } else { |
352 } else { |
345 mMenuView->reset(HsItemViewContext); |
353 mMenuView->reset(HsItemViewContext); |
346 mMenuView->setModel(mModel); |
354 mMenuView->setModel(mModel); |
347 mMenuView->listView()->scrollTo( |
355 mMenuView->listView()->scrollTo( |
348 mModel->index(0), HbAbstractItemView::PositionAtTop); |
356 mModel->index(0), HbAbstractItemView::PositionAtTop); |
349 } |
357 } |
350 mMenuView->disableSearch(empty); |
358 mMenuView->disableSearch(empty); |
351 mMenuView->activate(); |
|
352 setMenuOptions(); |
359 setMenuOptions(); |
353 } |
360 } |
354 |
|
355 |
361 |
356 /*! |
362 /*! |
357 Handles lock search button |
363 Handles lock search button |
358 \param lock if true lock search button. |
364 \param lock if true lock search button. |
359 */ |
365 */ |
408 void HsCollectionState::updateLabel() |
414 void HsCollectionState::updateLabel() |
409 { |
415 { |
410 HSMENUTEST_FUNC_ENTRY("HsCollectionState::updateLabel"); |
416 HSMENUTEST_FUNC_ENTRY("HsCollectionState::updateLabel"); |
411 if (mModel) { |
417 if (mModel) { |
412 mMenuView->viewLabel()->setHeading( |
418 mMenuView->viewLabel()->setHeading( |
413 mModel->root().data(Qt::DisplayRole).toString()); |
419 mModel->root().data(CaItemModel::CollectionTitleRole).toString()); |
414 } |
420 } |
415 HSMENUTEST_FUNC_EXIT("HsCollectionState::updateLabel"); |
421 HSMENUTEST_FUNC_EXIT("HsCollectionState::updateLabel"); |
416 } |
422 } |
417 |
423 |
418 /*! |
424 /*! |