notes/notesui/notesviews/src/notesfavoriteview.cpp
branchRCL_3
changeset 65 12af337248b1
equal deleted inserted replaced
60:96907930389d 65:12af337248b1
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Definition file for NotesFavoriteView class.
       
    16 *
       
    17 */
       
    18 
       
    19 // System includes
       
    20 #include <QDateTime>
       
    21 #include <HbListView>
       
    22 #include <HbListWidget>
       
    23 #include <HbAction>
       
    24 #include <HbTextEdit>
       
    25 #include <HbInstance>
       
    26 #include <HbMainWindow>
       
    27 #include <HbMenu>
       
    28 #include <HbDialog>
       
    29 #include <HbLabel>
       
    30 #include <HbAbstractViewItem>
       
    31 #include <HbGroupBox>
       
    32 #include <HbListViewItem>
       
    33 #include <HbNotificationDialog>
       
    34 
       
    35 // User includes
       
    36 #include <agendautil.h>
       
    37 #include "notesfavoriteview.h"
       
    38 #include "notescommon.h"
       
    39 #include "notesdocloader.h"
       
    40 #include "notesmodel.h"
       
    41 #include "notessortfilterproxymodel.h"
       
    42 #include "noteseditor.h"
       
    43 #include "OstTraceDefinitions.h"
       
    44 #ifdef OST_TRACE_COMPILER_IN_USE
       
    45 #include "notesfavoriteviewTraces.h"
       
    46 #endif
       
    47 
       
    48 
       
    49 /*!
       
    50 	\class NotesFavoriteView
       
    51 	\brief The main view of the notes application. Responsible for displaying
       
    52 			notes and todos.
       
    53 
       
    54 	\sa NotesViewManager
       
    55  */
       
    56 
       
    57 /*!
       
    58 	Constructs the NotesFavoriteView object.
       
    59 
       
    60 	\param parent The parent of type QGraphicsWidget.
       
    61  */
       
    62 NotesFavoriteView::NotesFavoriteView(QGraphicsWidget *parent)
       
    63 :HbView(parent),
       
    64  mSelectedItem(0),
       
    65  mDeleteAction(0),
       
    66  mIsLongTop(false)
       
    67 {
       
    68 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_NOTESFAVORITEVIEW_ENTRY );
       
    69 	// Nothing yet.
       
    70 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_NOTESFAVORITEVIEW_EXIT );
       
    71 }
       
    72 
       
    73 /*!
       
    74 	Destructor.
       
    75  */
       
    76 NotesFavoriteView::~NotesFavoriteView()
       
    77 {
       
    78 	OstTraceFunctionEntry0( DUP1_NOTESFAVORITEVIEW_NOTESFAVORITEVIEW_ENTRY );
       
    79 	if (mDocLoader) {
       
    80 	    delete mDocLoader;
       
    81 	    mDocLoader = 0;
       
    82     }
       
    83 
       
    84 	OstTraceFunctionExit0( DUP1_NOTESFAVORITEVIEW_NOTESFAVORITEVIEW_EXIT );
       
    85 }
       
    86 
       
    87 /*!
       
    88 	Called by the NotesViewManager after loading the view from the docml.
       
    89 	The initializaion/setup of the view is done here.
       
    90 
       
    91 	\param controller The NotesAppController object.
       
    92 	\param docLoader Pointer to NotesDocLoader object.
       
    93  */
       
    94 void NotesFavoriteView::setupView(
       
    95 		NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader)
       
    96 {
       
    97 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_SETUPVIEW_ENTRY );
       
    98 	mDocLoader = docLoader;
       
    99 	mAppControllerIf = &controllerIf;
       
   100 	mNotesModel = mAppControllerIf->notesModel();
       
   101 	mAgendaUtil = mAppControllerIf->agendaUtil();
       
   102 
       
   103 	mProxyModel = new NotesSortFilterProxyModel(*mAgendaUtil, this);
       
   104 	mProxyModel->setDynamicSortFilter(true);
       
   105 	mProxyModel->setSourceModel(mNotesModel->sourceModel());
       
   106 
       
   107 	// Apply the filter
       
   108 	mProxyModel->setFilterRole(NotesNamespace::FavouriteRole);
       
   109 	mProxyModel->setFilterRegExp(QRegExp(QString("favourites")));
       
   110 
       
   111 	NotesSortFilterProxyModel *subModel =
       
   112 			new NotesSortFilterProxyModel(*mAgendaUtil, this);
       
   113 	subModel->setDynamicSortFilter(true);
       
   114 	subModel->setSourceModel(mProxyModel);
       
   115 
       
   116 	// Get the list object from the document and update the model.
       
   117 	mListView = static_cast<HbListView *>
       
   118 			(mDocLoader->findWidget("favoritesListView"));
       
   119 	// Update the list view model.
       
   120 	mListView->setModel(subModel);
       
   121 	// Setup the operations that can be done with a list view.
       
   122 	connect(
       
   123 			mListView, SIGNAL(released(const QModelIndex &)),
       
   124 			this, SLOT(handleItemReleased(const QModelIndex &)));
       
   125 	connect(
       
   126 			mListView,
       
   127 			SIGNAL(longPressed(HbAbstractViewItem *, const QPointF &)),
       
   128 			this,
       
   129 			SLOT(handleItemLongPressed(HbAbstractViewItem *, const QPointF &)));
       
   130 
       
   131 	// Get the empty list label.
       
   132 	mEmptyListLabel = static_cast<HbLabel *> (
       
   133 			mDocLoader->findWidget("emptyListLabel"));
       
   134 	
       
   135 	// Get the toolbar/menu actions.
       
   136 	mAddNoteAction = static_cast<HbAction *> (
       
   137 			mDocLoader->findObject("newNoteAction"));
       
   138 	connect(
       
   139 			mAddNoteAction, SIGNAL(triggered()),
       
   140 			this, SLOT(createNewNote()));
       
   141 
       
   142 	mAllNotesAction = static_cast<HbAction *> (
       
   143 			mDocLoader->findObject("allNotesAction"));
       
   144 	connect(
       
   145 			mAllNotesAction, SIGNAL(triggered()),
       
   146 			this, SLOT(displayAllNotesView()));
       
   147 
       
   148 	mViewCollectionAction = static_cast<HbAction *> (
       
   149 			mDocLoader->findObject("displayCollectionsAction"));
       
   150 
       
   151 	connect(
       
   152 			mViewCollectionAction, SIGNAL(changed()),
       
   153 			this, SLOT(handleActionStateChanged()));
       
   154 	connect(
       
   155 			mViewCollectionAction, SIGNAL(triggered()),
       
   156 			this, SLOT(displayCollectionView()));
       
   157 
       
   158 	// Handles the orientation change for list items
       
   159 	HbMainWindow *window = hbInstance->allMainWindows().first();
       
   160 	handleOrientationChanged(window->orientation());
       
   161 	connect(
       
   162 			window, SIGNAL(orientationChanged(Qt::Orientation)),
       
   163 			this, SLOT(handleOrientationChanged(Qt::Orientation)));
       
   164 
       
   165 	connect(
       
   166 			mAgendaUtil, SIGNAL(entryAdded(ulong)),
       
   167 			this,SLOT(updateView(ulong)));
       
   168 	connect(
       
   169 			mAgendaUtil, SIGNAL(entryDeleted(ulong)),
       
   170 			this,SLOT(updateView(ulong)));
       
   171 	connect(
       
   172 			mAgendaUtil, SIGNAL(entryUpdated(ulong)),
       
   173 			this, SLOT(updateView(ulong)));
       
   174 	
       
   175 	// Set the graphics size for the icons.
       
   176 	HbListViewItem *prototype = mListView->listItemPrototype();
       
   177 	prototype->setGraphicsSize(HbListViewItem::SmallIcon);
       
   178 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_SETUPVIEW_EXIT );
       
   179 }
       
   180 
       
   181 /*
       
   182 	Updates the favorite view either to show notes or emptyListLabel.
       
   183  */
       
   184 void NotesFavoriteView::updateFavoriteView()
       
   185 {
       
   186 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_UPDATEFAVORITEVIEW_ENTRY );
       
   187 	updateView();
       
   188 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_UPDATEFAVORITEVIEW_EXIT );
       
   189 }
       
   190 
       
   191 /*!
       
   192 	Slot which gets called when `+ New note' action is triggered from the view
       
   193 	toolbar. This is responsible for launching the editor to create a new note.
       
   194  */
       
   195 void NotesFavoriteView::createNewNote()
       
   196 {
       
   197 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_CREATENEWNOTE_ENTRY );
       
   198 	// Here we Display an editor to the use to enter text.
       
   199 	mNotesEditor = new NotesEditor(mAgendaUtil, this);
       
   200 	connect(
       
   201 			mNotesEditor, SIGNAL(editingCompleted(bool)),
       
   202 			this, SLOT(handleEditingCompleted(bool)));
       
   203 	mNotesEditor->create(NotesEditor::CreateNote);
       
   204 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_CREATENEWNOTE_EXIT );
       
   205 }
       
   206 
       
   207 /*!
       
   208 	Handles the pressing of a list item in the view.
       
   209 
       
   210 	Here we open the editor for viewing/editing.
       
   211 
       
   212 	\param index Reference to the QModelIndex representing the view item.
       
   213 	\sa HbAbstractViewItem
       
   214  */
       
   215 void NotesFavoriteView::handleItemReleased(const QModelIndex &index)
       
   216 {
       
   217 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_HANDLEITEMRELEASED_ENTRY );
       
   218 	if (!mIsLongTop) {
       
   219 		// Sanity check.
       
   220 		if (!index.isValid()) {
       
   221 			OstTraceFunctionExit0( NOTESFAVORITEVIEW_HANDLEITEMRELEASED_EXIT );
       
   222 			return;
       
   223 		}
       
   224 
       
   225 		// First get the id of the note and get the corresponding information from
       
   226 		// agendautil.
       
   227 		ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>();
       
   228 
       
   229 		if (0 >= noteId) {
       
   230 			// Something wrong.
       
   231 			OstTraceFunctionExit0( DUP1_NOTESFAVORITEVIEW_HANDLEITEMRELEASED_EXIT );
       
   232 			return;
       
   233 		}
       
   234 
       
   235 		// Get the entry details.
       
   236 		AgendaEntry entry = mAgendaUtil->fetchById(noteId);
       
   237 
       
   238 		if (entry.isNull()) {
       
   239 
       
   240 			// Entry invalid.
       
   241 			OstTraceFunctionExit0( DUP2_NOTESFAVORITEVIEW_HANDLEITEMRELEASED_EXIT );
       
   242 			return;
       
   243 		}
       
   244 
       
   245 		// Now launch the editor with the obtained info.
       
   246 		mNotesEditor = new NotesEditor(mAgendaUtil, this);
       
   247 		connect(
       
   248 				mNotesEditor, SIGNAL(editingCompleted(bool)),
       
   249 				this, SLOT(handleEditingCompleted(bool)));
       
   250 		mNotesEditor->edit(entry);
       
   251 	}
       
   252 	OstTraceFunctionExit0( DUP3_NOTESFAVORITEVIEW_HANDLEITEMRELEASED_EXIT );
       
   253 }
       
   254 
       
   255 /*!
       
   256 	Displays a list item specific context menu.
       
   257 
       
   258 	\param item The HbAbstractViewItem that was long pressed.
       
   259 	\param coords The position where mouse was pressed.
       
   260 
       
   261 	\sa HbAbstractViewItem, HbListView, HbMenu.
       
   262  */
       
   263 void NotesFavoriteView::handleItemLongPressed(
       
   264 		HbAbstractViewItem *item, const QPointF &coords)
       
   265 {
       
   266 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_HANDLEITEMLONGPRESSED_ENTRY );
       
   267 	mSelectedItem = item;
       
   268 	mIsLongTop = true;
       
   269 
       
   270 	// Get the entry of the selected item.
       
   271 	ulong noteId = item->modelIndex().data(
       
   272 			NotesNamespace::IdRole).value<qulonglong>();
       
   273 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
       
   274 
       
   275 	// Display a context specific menu.
       
   276 	HbMenu *contextMenu = new HbMenu();
       
   277 	connect(
       
   278 			contextMenu,SIGNAL(aboutToClose()),
       
   279 			this, SLOT(handleMenuClosed()));
       
   280 
       
   281 	// Add actions to the context menu.
       
   282 	mOpenAction =
       
   283 			contextMenu->addAction(hbTrId("txt_common_menu_open"));
       
   284 
       
   285 	mDeleteAction =
       
   286 			contextMenu->addAction(hbTrId("txt_common_menu_delete"));
       
   287 
       
   288 	mRemoveFavoriteAction =
       
   289 			contextMenu->addAction(
       
   290 					hbTrId("txt_notes_menu_remove_from_favorites"));
       
   291 
       
   292 	mMarkTodoAction =
       
   293 			contextMenu->addAction(
       
   294 					hbTrId("txt_notes_menu_make_it_as_todo_note"));
       
   295 
       
   296 	// Show the menu.
       
   297 	contextMenu->open(this, SLOT(selectedMenuAction(HbAction*)));
       
   298 	contextMenu->setPreferredPos(coords);
       
   299 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_HANDLEITEMLONGPRESSED_EXIT );
       
   300 }
       
   301 
       
   302 /*!
       
   303 	Deletes the note.
       
   304  */
       
   305 void NotesFavoriteView::deleteNote()
       
   306 {
       
   307 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_DELETENOTE_ENTRY );
       
   308 	Q_ASSERT(mSelectedItem);
       
   309 
       
   310 	QModelIndex index = mSelectedItem->modelIndex();
       
   311 	if (!index.isValid()) {
       
   312 		OstTraceFunctionExit0( NOTESFAVORITEVIEW_DELETENOTE_EXIT );
       
   313 		return;
       
   314 	}
       
   315 	ulong entryId =
       
   316 			index.data(NotesNamespace::IdRole).value<qulonglong>();
       
   317 	if (!entryId) {
       
   318 		OstTraceFunctionExit0( DUP1_NOTESFAVORITEVIEW_DELETENOTE_EXIT );
       
   319 		return;
       
   320 	}
       
   321 
       
   322 	// Emit the signal.Deletion would happen in view manager.
       
   323 	emit deleteEntry(entryId);
       
   324 
       
   325 	mSelectedItem = 0;
       
   326 	OstTraceFunctionExit0( DUP2_NOTESFAVORITEVIEW_DELETENOTE_EXIT );
       
   327 }
       
   328 
       
   329 /*!
       
   330 	Removes the note from favorites.
       
   331  */
       
   332 void NotesFavoriteView::markNoteAsNotFavourite()
       
   333 {
       
   334 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_MARKNOTEASNOTFAVOURITE_ENTRY );
       
   335 	ulong noteId = mSelectedItem->modelIndex().data(
       
   336 			NotesNamespace::IdRole).value<qulonglong>();
       
   337 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
       
   338 
       
   339 	if (entry.favourite()) {
       
   340 		entry.setFavourite(0);
       
   341 	}
       
   342 	mAgendaUtil->store(entry);
       
   343 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_MARKNOTEASNOTFAVOURITE_EXIT );
       
   344 }
       
   345 
       
   346 /*!
       
   347     Slot to make a note as to-do.
       
   348  */
       
   349 void NotesFavoriteView::markNoteAsTodo()
       
   350 {
       
   351 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_MARKNOTEASTODO_ENTRY );
       
   352 	Q_ASSERT(mSelectedItem);
       
   353 
       
   354 	QModelIndex index = mSelectedItem->modelIndex();
       
   355 	if (!index.isValid()) {
       
   356 
       
   357 		OstTraceFunctionExit0( NOTESFAVORITEVIEW_MARKNOTEASTODO_EXIT );
       
   358 		return;
       
   359 	}
       
   360 	ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong> ();
       
   361 	if (!noteId) {
       
   362 		OstTraceFunctionExit0( DUP1_NOTESFAVORITEVIEW_MARKNOTEASTODO_EXIT );
       
   363 		return;
       
   364 	}
       
   365 	// Get the entry details.
       
   366 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
       
   367 
       
   368 	if (entry.isNull()) {
       
   369 		// Entry invalid.
       
   370 		OstTraceFunctionExit0( DUP2_NOTESFAVORITEVIEW_MARKNOTEASTODO_EXIT );
       
   371 		return;
       
   372 	}
       
   373 
       
   374 	// Here change the type of modified note and destroy the noteeditor and
       
   375 	// construct the to-do editor.
       
   376 	entry.setType(AgendaEntry::TypeTodo);
       
   377 
       
   378 	QDateTime dueDateTime;
       
   379 	QDate currentDate(QDate::currentDate());
       
   380 	dueDateTime.setDate(
       
   381 			QDate(currentDate.year(),currentDate.month(),currentDate.day()+1));
       
   382 
       
   383 	dueDateTime.setTime(QTime::fromString("12:00 am", "hh:mm ap"));
       
   384 
       
   385 	entry.setStartAndEndTime(dueDateTime, dueDateTime);
       
   386 
       
   387 	entry.setSummary(entry.description().left(80));
       
   388 
       
   389 	if (80 > entry.description().length()) {
       
   390 		entry.setDescription("");
       
   391 	}
       
   392 
       
   393 	// Remove favourite if marked so.
       
   394 	entry.setFavourite(0);
       
   395 
       
   396 	// Set the status of the to-do.
       
   397 	entry.setStatus(AgendaEntry::TodoNeedsAction);
       
   398 
       
   399 	// First clone the todoEntry for the new type.
       
   400 	mAgendaUtil->cloneEntry(entry, AgendaEntry::TypeTodo);
       
   401 
       
   402 	// Delete the old entry.
       
   403 	mAgendaUtil->deleteEntry(entry.id());
       
   404 
       
   405 	// Show the soft notification.
       
   406 	HbNotificationDialog *notificationDialog = new HbNotificationDialog();
       
   407 	notificationDialog->setTimeout(
       
   408 			HbNotificationDialog::ConfirmationNoteTimeout);
       
   409 	notificationDialog->setTitle(
       
   410 			hbTrId("txt_notes_dpopinfo_note_moved_to_todos"));
       
   411 	notificationDialog->show();
       
   412 	OstTraceFunctionExit0( DUP3_NOTESFAVORITEVIEW_MARKNOTEASTODO_EXIT );
       
   413 }
       
   414 
       
   415 /*!
       
   416 	Slot to handle the signal editingCompleted by the notes editor.
       
   417 
       
   418 	\param status Boolean value indicating whether the note was saved or not.
       
   419 
       
   420 	\sa NotesEditor.
       
   421  */
       
   422 void NotesFavoriteView::handleEditingCompleted(bool status)
       
   423 {
       
   424 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_HANDLEEDITINGCOMPLETED_ENTRY );
       
   425 	Q_UNUSED(status)
       
   426 
       
   427 	// Cleanup.
       
   428 	mNotesEditor->deleteLater();
       
   429 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_HANDLEEDITINGCOMPLETED_EXIT );
       
   430 }
       
   431 
       
   432 /*!
       
   433 	Directs the view manager to display the Collections view.
       
   434  */
       
   435 void NotesFavoriteView::displayCollectionView()
       
   436 {
       
   437 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_DISPLAYCOLLECTIONVIEW_ENTRY );
       
   438 	// Switch to collections view.
       
   439 	mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId);
       
   440 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_DISPLAYCOLLECTIONVIEW_EXIT );
       
   441 }
       
   442 
       
   443 /*!
       
   444 	Directs the view manager to display the All notes view.
       
   445  */
       
   446 void NotesFavoriteView::displayAllNotesView()
       
   447 {
       
   448 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_DISPLAYALLNOTESVIEW_ENTRY );
       
   449 	// Switch to collections view.
       
   450 	mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId);
       
   451 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_DISPLAYALLNOTESVIEW_EXIT );
       
   452 }
       
   453 
       
   454 /*!
       
   455 	Slot to handle the case when the state of an action has changed.
       
   456  */
       
   457 void NotesFavoriteView::handleActionStateChanged()
       
   458 {
       
   459 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_HANDLEACTIONSTATECHANGED_ENTRY );
       
   460 	mAllNotesAction->setChecked(true);
       
   461 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_HANDLEACTIONSTATECHANGED_EXIT );
       
   462 }
       
   463 
       
   464 /*!
       
   465 	Handles the orientation changes.Updates the list
       
   466 	item when orientation is changed
       
   467 
       
   468 	\param orientation Value of the orientation
       
   469  */
       
   470 void NotesFavoriteView::handleOrientationChanged(Qt::Orientation orientation)
       
   471 {
       
   472 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_HANDLEORIENTATIONCHANGED_ENTRY );
       
   473 	HbListViewItem *prototype = mListView->listItemPrototype();
       
   474 
       
   475 	if (Qt::Horizontal == orientation) {
       
   476 		prototype->setStretchingStyle(HbListViewItem::StretchLandscape);
       
   477 	} else {
       
   478 		prototype->setStretchingStyle(HbListViewItem::NoStretching);
       
   479 	}
       
   480 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_HANDLEORIENTATIONCHANGED_EXIT );
       
   481 }
       
   482 
       
   483 /*
       
   484 	Opens the notes editor to edit the favorite note.
       
   485  */
       
   486 void NotesFavoriteView::openNote()
       
   487 {
       
   488 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_OPENNOTE_ENTRY );
       
   489 	ulong noteId = mSelectedItem->modelIndex().data(
       
   490 			NotesNamespace::IdRole).value<qulonglong>();
       
   491 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
       
   492 
       
   493 	// Construct notes editor.
       
   494 	mNotesEditor = new NotesEditor(mAgendaUtil, this);
       
   495 	connect(
       
   496 			mNotesEditor, SIGNAL(editingCompleted(bool)),
       
   497 			this, SLOT(handleEditingCompleted(bool)));
       
   498 
       
   499 	// Launch the notes editor with the obtained info.
       
   500 	mNotesEditor->edit(entry);
       
   501 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_OPENNOTE_EXIT );
       
   502 }
       
   503 
       
   504 /*
       
   505 	Slot to handle the context menu actions.
       
   506  */
       
   507 void NotesFavoriteView::selectedMenuAction(HbAction *action)
       
   508 {
       
   509 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_SELECTEDMENUACTION_ENTRY );
       
   510 	if(action == mOpenAction) {
       
   511 		openNote();
       
   512 	} else if (action == mDeleteAction) {
       
   513 		deleteNote();
       
   514 	} else if (action ==mRemoveFavoriteAction){
       
   515 		markNoteAsNotFavourite();
       
   516 	} else if (action == mMarkTodoAction) {
       
   517 		markNoteAsTodo();
       
   518 	}
       
   519 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_SELECTEDMENUACTION_EXIT );
       
   520 }
       
   521 
       
   522 /*!
       
   523 	Slot to handle the context menu closed.
       
   524  */
       
   525 void NotesFavoriteView::handleMenuClosed()
       
   526 {
       
   527 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_HANDLEMENUCLOSED_ENTRY );
       
   528 	mIsLongTop = false;
       
   529 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_HANDLEMENUCLOSED_EXIT );
       
   530 }
       
   531 
       
   532 /*!
       
   533 	Handles the visibility of empty list label.
       
   534  */
       
   535 void NotesFavoriteView::updateView(ulong id)
       
   536 {
       
   537 	OstTraceFunctionEntry0( NOTESFAVORITEVIEW_UPDATEVIEW_ENTRY );
       
   538 	Q_UNUSED(id)
       
   539 
       
   540 	// Get the numbers of favorite notes.
       
   541 	if (0 >= mListView->model()->rowCount()) {
       
   542 		mEmptyListLabel->show();
       
   543 		mListView->hide();
       
   544 	} else {
       
   545 		mEmptyListLabel->hide();
       
   546 		mListView->show();
       
   547 	}
       
   548 	OstTraceFunctionExit0( NOTESFAVORITEVIEW_UPDATEVIEW_EXIT );
       
   549 }
       
   550 
       
   551 // End of file	--Don't remove this.