notes/notesui/notesviews/src/notesfavoriteview.cpp
changeset 50 579cc610882e
parent 26 a949c2543c15
child 58 ef813d54df51
--- a/notes/notesui/notesviews/src/notesfavoriteview.cpp	Wed Jun 23 18:11:28 2010 +0300
+++ b/notes/notesui/notesviews/src/notesfavoriteview.cpp	Tue Jul 06 14:14:56 2010 +0300
@@ -118,6 +118,10 @@
 			this,
 			SLOT(handleItemLongPressed(HbAbstractViewItem *, const QPointF &)));
 
+	// Get the empty list label.
+	mEmptyListLabel = static_cast<HbLabel *> (
+			mDocLoader->findWidget("emptyListLabel"));
+	
 	// Get the toolbar/menu actions.
 	mAddNoteAction = static_cast<HbAction *> (
 			mDocLoader->findObject("newNoteAction"));
@@ -133,8 +137,7 @@
 
 	mViewCollectionAction = static_cast<HbAction *> (
 			mDocLoader->findObject("displayCollectionsAction"));
-	mViewCollectionAction->setCheckable(true);
-	mViewCollectionAction->setChecked(true);
+
 	connect(
 			mViewCollectionAction, SIGNAL(changed()),
 			this, SLOT(handleActionStateChanged()));
@@ -149,11 +152,29 @@
 			window, SIGNAL(orientationChanged(Qt::Orientation)),
 			this, SLOT(handleOrientationChanged(Qt::Orientation)));
 
+	connect(
+			mAgendaUtil, SIGNAL(entryAdded(ulong)),
+			this,SLOT(updateView(ulong)));
+	connect(
+			mAgendaUtil, SIGNAL(entryDeleted(ulong)),
+			this,SLOT(updateView(ulong)));
+	connect(
+			mAgendaUtil, SIGNAL(entryUpdated(ulong)),
+			this, SLOT(updateView(ulong)));
+	
 	// Set the graphics size for the icons.
 	HbListViewItem *prototype = mListView->listItemPrototype();
 	prototype->setGraphicsSize(HbListViewItem::SmallIcon);
 }
 
+/*
+	Updates the favorite view either to show notes or emptyListLabel.
+ */
+void NotesFavoriteView::updateFavoriteView()
+{
+	updateView();
+}
+
 /*!
 	Slot which gets called when `+ New note' action is triggered from the view
 	toolbar. This is responsible for launching the editor to create a new note.
@@ -458,5 +479,23 @@
 {
 	mIsLongTop = false;
 }
+
+/*!
+	Handles the visibility of empty list label.
+ */
+void NotesFavoriteView::updateView(ulong id)
+{
+	Q_UNUSED(id)
+
+	// Get the numbers of favorite notes.
+	if (0 >= mListView->model()->rowCount()) {
+		mEmptyListLabel->show();
+		mListView->hide();
+	} else {
+		mEmptyListLabel->hide();
+		mListView->show();
+	}
+}
+
 // End of file	--Don't remove this.