notes/notesui/notesviews/src/notestodoview.cpp
branchRCL_3
changeset 29 12af337248b1
equal deleted inserted replaced
28:96907930389d 29: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 NotesTodoView 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 
       
    34 // User includes
       
    35 #include <agendautil.h>
       
    36 #include "agendaeventviewer.h"
       
    37 #include "notestodoview.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 "notestodoviewTraces.h"
       
    46 #endif
       
    47 
       
    48 
       
    49 /*!
       
    50 	\class NotesTodoView
       
    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 NotesTodoView object.
       
    59 
       
    60 	\param parent The parent of type QGraphicsWidget.
       
    61  */
       
    62 NotesTodoView::NotesTodoView(QGraphicsWidget *parent)
       
    63 :HbView(parent),
       
    64  mSelectedItem(0),
       
    65  mDeleteAction(0),
       
    66  mIsLongTop(false)
       
    67 {
       
    68 	OstTraceFunctionEntry0( NOTESTODOVIEW_NOTESTODOVIEW_ENTRY );
       
    69 	// Nothing yet.
       
    70 	OstTraceFunctionExit0( NOTESTODOVIEW_NOTESTODOVIEW_EXIT );
       
    71 }
       
    72 
       
    73 /*!
       
    74 	Destructor.
       
    75  */
       
    76 NotesTodoView::~NotesTodoView()
       
    77 {
       
    78 	OstTraceFunctionEntry0( DUP1_NOTESTODOVIEW_NOTESTODOVIEW_ENTRY );
       
    79 	if (mDocLoader) {
       
    80 		delete mDocLoader;
       
    81 		mDocLoader = 0;
       
    82 	}
       
    83 	OstTraceFunctionExit0( DUP1_NOTESTODOVIEW_NOTESTODOVIEW_EXIT );
       
    84 }
       
    85 
       
    86 /*!
       
    87 	Called by the NotesViewManager after loading the view from the docml.
       
    88 	The initializaion/setup of the view is done here.
       
    89 
       
    90 	\param controller The NotesAppController object.
       
    91 	\param docLoader Pointer to NotesDocLoader object.
       
    92  */
       
    93 void NotesTodoView::setupView(
       
    94 		NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader)
       
    95 {
       
    96 	OstTraceFunctionEntry0( NOTESTODOVIEW_SETUPVIEW_ENTRY );
       
    97 	mDocLoader = docLoader;
       
    98 	mAppControllerIf = &controllerIf;
       
    99 	mNotesModel = mAppControllerIf->notesModel();
       
   100 	mAgendaUtil = mAppControllerIf->agendaUtil();
       
   101 
       
   102 	mProxyModel = new NotesSortFilterProxyModel(*mAgendaUtil, this);
       
   103 	mProxyModel->setDynamicSortFilter(true);
       
   104 	mProxyModel->setSourceModel(mNotesModel->sourceModel());
       
   105 
       
   106 	mProxyModel->setFilterRole(NotesNamespace::TypeRole);
       
   107 	mProxyModel->setFilterRegExp(QRegExp(QString("todo")));
       
   108 
       
   109 	NotesSortFilterProxyModel *subModel =
       
   110 			new NotesSortFilterProxyModel(*mAgendaUtil, this);
       
   111 	subModel->setDynamicSortFilter(true);
       
   112 	subModel->setSourceModel(mProxyModel);
       
   113 
       
   114 	// Get the list object from the document and update the model.
       
   115 	mListView = static_cast<HbListView *>
       
   116 			(mDocLoader->findWidget("todoListView"));
       
   117 	// Update the list view model.
       
   118 	mListView->setModel(subModel);
       
   119 	// Setup the operations that can be done with a list view.
       
   120 	connect(
       
   121 			mListView, SIGNAL(activated(const QModelIndex &)),
       
   122 			this, SLOT(handleItemReleased(const QModelIndex &)));
       
   123 	connect(
       
   124 			mListView,
       
   125 			SIGNAL(longPressed(HbAbstractViewItem *, const QPointF &)),
       
   126 			this,
       
   127 			SLOT(handleItemLongPressed(HbAbstractViewItem *, const QPointF &)));
       
   128 	
       
   129 	// Get the empty list string.
       
   130 	mEmptyListLabel = static_cast<HbLabel *> (
       
   131 			mDocLoader->findWidget("emptyListLabel"));
       
   132 	
       
   133 	// Get the toolbar/menu actions.
       
   134 	mAddTodoAction = static_cast<HbAction *> (
       
   135 			mDocLoader->findObject("newTodoAction"));
       
   136 	connect(
       
   137 			mAddTodoAction, SIGNAL(triggered()),
       
   138 			this, SLOT(createNewTodo()));
       
   139 
       
   140 	mAllNotesAction = static_cast<HbAction *> (
       
   141 			mDocLoader->findObject("allNotesAction"));
       
   142 	connect(
       
   143 			mAllNotesAction, SIGNAL(triggered()),
       
   144 			this, SLOT(displayAllNotesView()));
       
   145 
       
   146 	mViewCollectionAction = static_cast<HbAction *> (
       
   147 			mDocLoader->findObject("displayCollectionsAction"));
       
   148 	
       
   149 	connect(
       
   150 			mViewCollectionAction, SIGNAL(changed()),
       
   151 			this, SLOT(handleActionStateChanged()));
       
   152 	connect(
       
   153 			mViewCollectionAction, SIGNAL(triggered()),
       
   154 			this, SLOT(displayCollectionView()));
       
   155 
       
   156 	// Handles the orientation change for list items
       
   157 	HbMainWindow *window = hbInstance->allMainWindows().first();
       
   158 	handleOrientationChanged(window->orientation());
       
   159 	connect(
       
   160 			window, SIGNAL(orientationChanged(Qt::Orientation)),
       
   161 			this, SLOT(handleOrientationChanged(Qt::Orientation)));
       
   162 
       
   163 	mSubTitle = static_cast<HbGroupBox *>(
       
   164 			mDocLoader->findWidget("subtitleGroupBox"));
       
   165 
       
   166 	connect(
       
   167 			mAgendaUtil, SIGNAL(entryAdded(ulong)),
       
   168 			this,SLOT(updateSubTitle(ulong)));
       
   169 	connect(
       
   170 			mAgendaUtil, SIGNAL(entryDeleted(ulong)),
       
   171 			this,SLOT(updateSubTitle(ulong)));
       
   172 	connect(
       
   173 			mAgendaUtil, SIGNAL(entryUpdated(ulong)),
       
   174 			this, SLOT(updateSubTitle(ulong)));
       
   175 
       
   176 	// Set the graphics size for the icons.
       
   177 	HbListViewItem *prototype = mListView->listItemPrototype();
       
   178 	prototype->setGraphicsSize(HbListViewItem::SmallIcon);
       
   179 	OstTraceFunctionExit0( NOTESTODOVIEW_SETUPVIEW_EXIT );
       
   180 }
       
   181 
       
   182 /*
       
   183 	Updates the title text for the first launch
       
   184  */
       
   185 void NotesTodoView::updateTitle()
       
   186 {
       
   187 	OstTraceFunctionEntry0( NOTESTODOVIEW_UPDATETITLE_ENTRY );
       
   188 	updateSubTitle();
       
   189 	OstTraceFunctionExit0( NOTESTODOVIEW_UPDATETITLE_EXIT );
       
   190 }
       
   191 
       
   192 /*!
       
   193 	Opens the to-do editor to create a new to-do.
       
   194  */
       
   195 void NotesTodoView::createNewTodo()
       
   196 {
       
   197 	OstTraceFunctionEntry0( NOTESTODOVIEW_CREATENEWTODO_ENTRY );
       
   198 	mNotesEditor = new NotesEditor(mAgendaUtil, this);
       
   199 	connect(
       
   200 			mNotesEditor, SIGNAL(editingCompleted(bool)),
       
   201 			this, SLOT(handleEditingCompleted(bool)));
       
   202 
       
   203 	mNotesEditor->create(NotesEditor::CreateTodo);
       
   204 	OstTraceFunctionExit0( NOTESTODOVIEW_CREATENEWTODO_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 NotesTodoView::handleItemReleased(const QModelIndex &index)
       
   216 {
       
   217 	OstTraceFunctionEntry0( NOTESTODOVIEW_HANDLEITEMRELEASED_ENTRY );
       
   218 	if(!mIsLongTop) {
       
   219 		// Sanity check.
       
   220 		if (!index.isValid()) {
       
   221 			OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEITEMRELEASED_EXIT );
       
   222 			return;
       
   223 		}
       
   224 
       
   225 		// First get the id of the to-do and get the corresponding information from
       
   226 		// agendautil.
       
   227 		ulong toDoId = index.data(NotesNamespace::IdRole).value<qulonglong>();
       
   228 
       
   229 		if (0 >= toDoId) {
       
   230 			// Something wrong.
       
   231 			OstTraceFunctionExit0( DUP1_NOTESTODOVIEW_HANDLEITEMRELEASED_EXIT );
       
   232 			return;
       
   233 		}
       
   234 
       
   235 		// Construct agenda event viewer.
       
   236 		mAgendaEventViewer = new AgendaEventViewer(mAgendaUtil, this);
       
   237 
       
   238 		connect(
       
   239 				mAgendaEventViewer, SIGNAL(viewingCompleted(const QDate)),
       
   240 				this, SLOT(handleViewingCompleted()));
       
   241 		// Launch agenda event viewer
       
   242 		mAgendaEventViewer->view(toDoId, AgendaEventViewer::ActionEditDelete);
       
   243 	}
       
   244 	OstTraceFunctionExit0( DUP2_NOTESTODOVIEW_HANDLEITEMRELEASED_EXIT );
       
   245 }
       
   246 
       
   247 /*!
       
   248 	Displays a list item specific context menu.
       
   249 
       
   250 	\param item The HbAbstractViewItem that was long pressed.
       
   251 	\param coords The position where mouse was pressed.
       
   252 
       
   253 	\sa HbAbstractViewItem, HbListView, HbMenu.
       
   254  */
       
   255 void NotesTodoView::handleItemLongPressed(
       
   256 		HbAbstractViewItem *item, const QPointF &coords)
       
   257 {
       
   258 	OstTraceFunctionEntry0( NOTESTODOVIEW_HANDLEITEMLONGPRESSED_ENTRY );
       
   259 	mSelectedItem = item;
       
   260 	mIsLongTop = true;
       
   261 
       
   262 	// Get the entry of the selected item.
       
   263 	ulong noteId = item->modelIndex().data(
       
   264 			NotesNamespace::IdRole).value<qulonglong>();
       
   265 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
       
   266 
       
   267 	// Display a context specific menu.
       
   268 	HbMenu *contextMenu = new HbMenu();
       
   269 	connect(
       
   270 			contextMenu,SIGNAL(aboutToClose()),
       
   271 			this, SLOT(handleMenuClosed()));
       
   272 
       
   273 	// Add actions to the context menu.
       
   274 	mOpenAction =
       
   275 			contextMenu->addAction(hbTrId("txt_common_menu_open"));
       
   276 
       
   277 	mEditAction = contextMenu->addAction(
       
   278 			hbTrId("txt_common_menu_edit"));
       
   279 
       
   280 	mDeleteAction = contextMenu->addAction(
       
   281 			hbTrId("txt_common_menu_delete"));
       
   282 
       
   283 	if (AgendaEntry::TypeTodo == entry.type()) {
       
   284 		if (AgendaEntry::TodoNeedsAction == entry.status()) {
       
   285 			mTodoStatusAction = contextMenu->addAction(
       
   286 					hbTrId("txt_notes_menu_mark_as_done"));
       
   287 		} else if (AgendaEntry::TodoCompleted == entry.status()) {
       
   288 			mTodoStatusAction =
       
   289 					contextMenu->addAction(
       
   290 							hbTrId("txt_notes_menu_mark_as_not_done"));
       
   291 		}
       
   292 	}
       
   293 
       
   294 	// Show the menu.
       
   295 	contextMenu->open(this, SLOT(selectedMenuAction(HbAction*)));
       
   296 	contextMenu->setPreferredPos(coords);
       
   297 	OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEITEMLONGPRESSED_EXIT );
       
   298 }
       
   299 
       
   300 /*!
       
   301 	Slot to delete a selected to-do.
       
   302  */
       
   303 void NotesTodoView::deleteTodo()
       
   304 {
       
   305 	OstTraceFunctionEntry0( NOTESTODOVIEW_DELETETODO_ENTRY );
       
   306 	Q_ASSERT(mSelectedItem);
       
   307 
       
   308 	QModelIndex index = mSelectedItem->modelIndex();
       
   309 	if (!index.isValid()) {
       
   310 		OstTraceFunctionExit0( NOTESTODOVIEW_DELETETODO_EXIT );
       
   311 		return;
       
   312 	}
       
   313 	ulong entryId =
       
   314 			index.data(NotesNamespace::IdRole).value<qulonglong>();
       
   315 	if (!entryId) {
       
   316 		OstTraceFunctionExit0( DUP1_NOTESTODOVIEW_DELETETODO_EXIT );
       
   317 		return;
       
   318 	}
       
   319 
       
   320 	// Emit the signal. Delete would be handled in view manager.
       
   321 	emit deleteEntry(entryId);
       
   322 
       
   323 	mSelectedItem = 0;
       
   324 	OstTraceFunctionExit0( DUP2_NOTESTODOVIEW_DELETETODO_EXIT );
       
   325 }
       
   326 
       
   327 /*!
       
   328 	Marks to-do entry as done or undone based on the completed value.
       
   329  */
       
   330 void NotesTodoView::markTodoStatus()
       
   331 {
       
   332 	OstTraceFunctionEntry0( NOTESTODOVIEW_MARKTODOSTATUS_ENTRY );
       
   333 	ulong entryId = mSelectedItem->modelIndex().data(
       
   334 			NotesNamespace::IdRole).value<qulonglong>();
       
   335 	AgendaEntry entry = mAgendaUtil->fetchById(entryId);
       
   336 
       
   337 	QDateTime currentDateTime = QDateTime::currentDateTime();
       
   338 
       
   339 	if (AgendaEntry::TodoNeedsAction == entry.status()) {
       
   340 		mAgendaUtil->setCompleted(entry, true, currentDateTime);
       
   341 	} else if (AgendaEntry::TodoCompleted == entry.status()) {
       
   342 		mAgendaUtil->setCompleted(entry, false, currentDateTime);
       
   343 	}
       
   344 	OstTraceFunctionExit0( NOTESTODOVIEW_MARKTODOSTATUS_EXIT );
       
   345 }
       
   346 
       
   347 /*!
       
   348 	Opens to-do in an editor.
       
   349  */
       
   350 void NotesTodoView::editTodo()
       
   351 {
       
   352 	OstTraceFunctionEntry0( NOTESTODOVIEW_EDITTODO_ENTRY );
       
   353 	QModelIndex index = mSelectedItem->modelIndex();
       
   354 
       
   355 	// Sanity check.
       
   356 	if (!index.isValid()) {
       
   357 		OstTraceFunctionExit0( NOTESTODOVIEW_EDITTODO_EXIT );
       
   358 		return;
       
   359 	}
       
   360 
       
   361 	// First get the id of the note and get the corresponding information from
       
   362 	// agendautil.
       
   363 	ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>();
       
   364 
       
   365 	if (0 >= noteId) {
       
   366 		// Something wrong.
       
   367 		OstTraceFunctionExit0( DUP1_NOTESTODOVIEW_EDITTODO_EXIT );
       
   368 		return;
       
   369 	}
       
   370 
       
   371 	// Get the entry details.
       
   372 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
       
   373 
       
   374 	if (entry.isNull()) {
       
   375 		// Entry invalid.
       
   376 		OstTraceFunctionExit0( DUP2_NOTESTODOVIEW_EDITTODO_EXIT );
       
   377 		return;
       
   378 	}
       
   379 
       
   380 	// Now launch the editor with the obtained info.
       
   381 	mNotesEditor = new NotesEditor(mAgendaUtil, this);
       
   382 	connect(
       
   383 			mNotesEditor, SIGNAL(editingCompleted(bool)),
       
   384 			this, SLOT(handleEditingCompleted(bool)));
       
   385 	mNotesEditor->edit(entry);
       
   386 	OstTraceFunctionExit0( DUP3_NOTESTODOVIEW_EDITTODO_EXIT );
       
   387 }
       
   388 
       
   389 /*!
       
   390 	Slot to handle the signal editingCompleted by the notes editor.
       
   391 
       
   392 	\param status Boolean value indicating whether the note was saved or not.
       
   393 
       
   394 	\sa NotesEditor.
       
   395  */
       
   396 void NotesTodoView::handleEditingCompleted(bool status)
       
   397 {
       
   398 	OstTraceFunctionEntry0( NOTESTODOVIEW_HANDLEEDITINGCOMPLETED_ENTRY );
       
   399 	Q_UNUSED(status)
       
   400 
       
   401 	// Cleanup.
       
   402 	mNotesEditor->deleteLater();
       
   403 	OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEEDITINGCOMPLETED_EXIT );
       
   404 }
       
   405 
       
   406 /*!
       
   407 	Directs the view manager to display the Collections view.
       
   408  */
       
   409 void NotesTodoView::displayCollectionView()
       
   410 {
       
   411 	OstTraceFunctionEntry0( NOTESTODOVIEW_DISPLAYCOLLECTIONVIEW_ENTRY );
       
   412 	// Switch to collections view.
       
   413 	mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId);
       
   414 	OstTraceFunctionExit0( NOTESTODOVIEW_DISPLAYCOLLECTIONVIEW_EXIT );
       
   415 }
       
   416 
       
   417 /*!
       
   418 	Directs the view manager to display the All notes view.
       
   419  */
       
   420 void NotesTodoView::displayAllNotesView()
       
   421 {
       
   422 	OstTraceFunctionEntry0( NOTESTODOVIEW_DISPLAYALLNOTESVIEW_ENTRY );
       
   423 	// Switch to collections view.
       
   424 	mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId);
       
   425 	OstTraceFunctionExit0( NOTESTODOVIEW_DISPLAYALLNOTESVIEW_EXIT );
       
   426 }
       
   427 
       
   428 /*!
       
   429 	Slot to handle signal editingCompleted by the to-do editor
       
   430  */
       
   431 void NotesTodoView::handleEditingCompleted()
       
   432 {
       
   433 	OstTraceFunctionEntry0( DUP1_NOTESTODOVIEW_HANDLEEDITINGCOMPLETED_ENTRY );
       
   434 	// Cleanup.
       
   435 	mNotesEditor->deleteLater();
       
   436 	OstTraceFunctionExit0( DUP1_NOTESTODOVIEW_HANDLEEDITINGCOMPLETED_EXIT );
       
   437 }
       
   438 
       
   439 /*!
       
   440 	Slot to handle signal handleViewingompleted by the agenda event viewer
       
   441  */
       
   442 void NotesTodoView::handleViewingCompleted()
       
   443 {
       
   444 	OstTraceFunctionEntry0( NOTESTODOVIEW_HANDLEVIEWINGCOMPLETED_ENTRY );
       
   445 	// Cleanup.
       
   446 	mAgendaEventViewer->deleteLater();
       
   447 	OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEVIEWINGCOMPLETED_EXIT );
       
   448 }
       
   449 
       
   450 /*!
       
   451 	Slot to handle the case when the state of an action has changed.
       
   452  */
       
   453 void NotesTodoView::handleActionStateChanged()
       
   454 {
       
   455 	OstTraceFunctionEntry0( NOTESTODOVIEW_HANDLEACTIONSTATECHANGED_ENTRY );
       
   456 	mAllNotesAction->setChecked(true);
       
   457 	OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEACTIONSTATECHANGED_EXIT );
       
   458 }
       
   459 
       
   460 /*!
       
   461 	Handles the orientation changes.Updates the list
       
   462 	item when orientation is changed
       
   463 
       
   464 	\param orientation Value of the orientation
       
   465  */
       
   466 void NotesTodoView::handleOrientationChanged(Qt::Orientation orientation)
       
   467 {
       
   468 	OstTraceFunctionEntry0( NOTESTODOVIEW_HANDLEORIENTATIONCHANGED_ENTRY );
       
   469 	HbListViewItem *prototype = mListView->listItemPrototype();
       
   470 
       
   471 	if (Qt::Horizontal == orientation) {
       
   472 		prototype->setStretchingStyle(HbListViewItem::StretchLandscape);
       
   473 	} else {
       
   474 		prototype->setStretchingStyle(HbListViewItem::NoStretching);
       
   475 	}
       
   476 	OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEORIENTATIONCHANGED_EXIT );
       
   477 }
       
   478 
       
   479 /*!
       
   480 	Updates the sub heading text
       
   481  */
       
   482 void NotesTodoView::updateSubTitle(ulong id)
       
   483 {
       
   484 	OstTraceFunctionEntry0( NOTESTODOVIEW_UPDATESUBTITLE_ENTRY );
       
   485 	Q_UNUSED(id)
       
   486 
       
   487 	// Get the number of incompleted to-do entries.
       
   488 	QList<ulong> entries = mAgendaUtil->entryIds(
       
   489 		AgendaUtil::IncludeIncompletedTodos);
       
   490 	mSubTitle->setHeading(
       
   491 			hbTrId("txt_notes_subhead_todos_ln_pending",entries.count()));
       
   492 	
       
   493 	if (0 < mProxyModel->rowCount()) {
       
   494 		mEmptyListLabel->hide();
       
   495 		mListView->show();
       
   496 	} else {
       
   497 		mEmptyListLabel->show();
       
   498 		mListView->hide();
       
   499 	}
       
   500 	OstTraceFunctionExit0( NOTESTODOVIEW_UPDATESUBTITLE_EXIT );
       
   501 }
       
   502 
       
   503 /*
       
   504 	Opens the to-do viewer to view the to-do.
       
   505  */
       
   506 void NotesTodoView::openTodo()
       
   507 {
       
   508 	OstTraceFunctionEntry0( NOTESTODOVIEW_OPENTODO_ENTRY );
       
   509 	ulong noteId = mSelectedItem->modelIndex().data(
       
   510 			NotesNamespace::IdRole).value<qulonglong>();
       
   511 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
       
   512 
       
   513 	// Construct agenda event viewer.
       
   514 	mAgendaEventViewer = new AgendaEventViewer(mAgendaUtil, this);
       
   515 
       
   516 	connect(
       
   517 			mAgendaEventViewer, SIGNAL(viewingCompleted(bool)),
       
   518 			this, SLOT(handleViewingCompleted(bool)));
       
   519 
       
   520 	// Launch agenda event viewer
       
   521 	mAgendaEventViewer->view(
       
   522 			entry, AgendaEventViewer::ActionEditDelete);
       
   523 	OstTraceFunctionExit0( NOTESTODOVIEW_OPENTODO_EXIT );
       
   524 }
       
   525 
       
   526 /*
       
   527 	Slot to handle the context menu actions.
       
   528  */
       
   529 void NotesTodoView::selectedMenuAction(HbAction *action)
       
   530 {
       
   531 	OstTraceFunctionEntry0( NOTESTODOVIEW_SELECTEDMENUACTION_ENTRY );
       
   532 	if (action == mOpenAction) {
       
   533 		openTodo();
       
   534 	} else if (action == mEditAction) {
       
   535 		editTodo();
       
   536 	} else if (action == mDeleteAction) {
       
   537 		deleteTodo();
       
   538 	} else if (action == mTodoStatusAction) {
       
   539 		markTodoStatus();
       
   540 	}
       
   541 	OstTraceFunctionExit0( NOTESTODOVIEW_SELECTEDMENUACTION_EXIT );
       
   542 }
       
   543 
       
   544 
       
   545 /*!
       
   546 	Slot to handle the context menu closed.
       
   547  */
       
   548 void NotesTodoView::handleMenuClosed()
       
   549 {
       
   550 	OstTraceFunctionEntry0( NOTESTODOVIEW_HANDLEMENUCLOSED_ENTRY );
       
   551 	mIsLongTop = false;
       
   552 	OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEMENUCLOSED_EXIT );
       
   553 }
       
   554 
       
   555 // End of file	--Don't remove this.