homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp
changeset 97 66b5fe3c07fd
parent 90 3ac3aaebaee5
child 98 e6f74eb7f69f
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp	Mon Sep 27 11:52:00 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp	Wed Oct 06 16:06:24 2010 +0300
@@ -152,7 +152,7 @@
                 mCollectionId, mSortAttribute, mCollectionType);
     }
 
-    handleEmptyChange(mModel->rowCount() == 0);
+    reconnectViewComponents(mModel->rowCount() == 0);
 
     makeConnect();
 
@@ -267,6 +267,7 @@
             static_cast<HsBaseViewState*>(this),
             SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
     connect(mModel, SIGNAL(modelReset()), SLOT(updateLabel()));
+    connect(mModel, SIGNAL(countChange()), SLOT(updateLabel()));
     connect(mModel, SIGNAL(empty(bool)),this,
             SLOT(handleEmptyChange(bool)));
     connect(mModel, SIGNAL(empty(bool)),this,
@@ -292,11 +293,11 @@
     disconnect(mModel, SIGNAL(empty(bool)),this,
                SLOT(handleEmptyChange(bool)));
 
-    disconnect(mModel, SIGNAL(empty(bool)),this,
+    disconnect(mModel, SIGNAL(empty(bool)), this,
                SLOT(lockSearchButton(bool)));
 
-    disconnect(mModel, SIGNAL(modelReset()),
-                   this, SLOT(updateLabel()));
+    disconnect(mModel, SIGNAL(modelReset()), this, SLOT(updateLabel()));
+    disconnect(mModel, SIGNAL(countChange()), this, SLOT(updateLabel()));
 }
 
 /*!
@@ -304,7 +305,7 @@
  \param action action taken in context menu
  */
 void HsCollectionState::contextMenuAction(HbAction *action)
-	{
+{
     const int itemId = mContextModelIndex.data(CaItemModel::IdRole).toInt();
     
     if (itemId > 0) {
@@ -336,9 +337,16 @@
  */
 void HsCollectionState::handleEmptyChange(bool empty)
 {
-    EntryFlags flags = mModel->root().data(
-            CaItemModel::FlagsRole).value<EntryFlags> ();
+    reconnectViewComponents(empty);
+    mMenuView->activate();
+}
 
+/*!
+ Reconnects view componets beetwen empty/not empty view.
+ \param empty \a true when model becomes empty \a false otherwise.
+ */
+void HsCollectionState::reconnectViewComponents(bool empty)
+{
     if (empty){
         mMenuView->reset(HsEmptyLabelContext);
     } else {
@@ -348,11 +356,9 @@
             mModel->index(0), HbAbstractItemView::PositionAtTop);
     }
     mMenuView->disableSearch(empty);
-    mMenuView->activate();
     setMenuOptions();
 }
 
-
 /*!
  Handles lock search button
   \param lock if true lock search button.
@@ -410,7 +416,7 @@
     HSMENUTEST_FUNC_ENTRY("HsCollectionState::updateLabel");
     if (mModel) {
         mMenuView->viewLabel()->setHeading(
-            mModel->root().data(Qt::DisplayRole).toString());
+            mModel->root().data(CaItemModel::CollectionTitleRole).toString());
     }
     HSMENUTEST_FUNC_EXIT("HsCollectionState::updateLabel");
 }