notes/notesui/notesviews/src/notesmainview.cpp
changeset 45 b6db4fd4947b
parent 23 fd30d51f876b
child 55 2c54b51f39c4
equal deleted inserted replaced
23:fd30d51f876b 45:b6db4fd4947b
    28 #include <HbLabel>
    28 #include <HbLabel>
    29 #include <HbAbstractViewItem>
    29 #include <HbAbstractViewItem>
    30 #include <HbAbstractItemView>
    30 #include <HbAbstractItemView>
    31 #include <HbGroupBox>
    31 #include <HbGroupBox>
    32 #include <HbListViewItem>
    32 #include <HbListViewItem>
       
    33 #include <hbapplication> // hbapplication
       
    34 #include <hbactivitymanager> // hbactivitymanager
    33 
    35 
    34 // User includes
    36 // User includes
    35 #include "agendaeventviewer.h"
    37 #include "agendaeventviewer.h"
    36 #include "notesmainview.h"
    38 #include "notesmainview.h"
    37 #include "notescommon.h"
    39 #include "notescommon.h"
    38 #include "notesdocloader.h"
    40 #include "notesdocloader.h"
    39 #include "agendautil.h"
    41 #include "agendautil.h"
    40 #include "notesmodel.h"
    42 #include "notesmodel.h"
    41 #include "notessortfilterproxymodel.h"
    43 #include "notessortfilterproxymodel.h"
    42 #include "noteseditor.h"
    44 #include "noteseditor.h"
       
    45 #include "notescommon.h" // NotesNamespace
    43 
    46 
    44 /*!
    47 /*!
    45 	\class NotesMainView
    48 	\class NotesMainView
    46 	\brief The main view of the notes application. Responsible for displaying
    49 	\brief The main view of the notes application. Responsible for displaying
    47 			notes and todos.
    50 			notes and todos.
    55 	\param parent The parent of type QGraphicsWidget.
    58 	\param parent The parent of type QGraphicsWidget.
    56  */
    59  */
    57 NotesMainView::NotesMainView(QGraphicsWidget *parent)
    60 NotesMainView::NotesMainView(QGraphicsWidget *parent)
    58 :HbView(parent),
    61 :HbView(parent),
    59  mSelectedItem(0),
    62  mSelectedItem(0),
    60  mDeleteAction(0)
    63  mDeleteAction(0),
       
    64  mIsLongTop(false),
       
    65  mIsScreenShotCapruted(false)
    61 {
    66 {
    62 	// Nothing yet.
    67 	// Nothing yet.
    63 }
    68 }
    64 
    69 
    65 /*!
    70 /*!
   119 			SLOT(handleItemLongPressed(HbAbstractViewItem *, const QPointF &)));
   124 			SLOT(handleItemLongPressed(HbAbstractViewItem *, const QPointF &)));
   120 	connect(
   125 	connect(
   121 			mNotesModel, SIGNAL(rowAdded(QModelIndex)),
   126 			mNotesModel, SIGNAL(rowAdded(QModelIndex)),
   122 			this, SLOT(scrollTo(QModelIndex)));
   127 			this, SLOT(scrollTo(QModelIndex)));
   123 
   128 
       
   129 	// Get the empty list label.
       
   130 	mEmptyListLabel = static_cast<HbLabel *> (
       
   131 			mDocLoader->findWidget("emptyListLabel"));
       
   132 	mEmptyListLabel->hide();
       
   133 
   124 	// Get the view heading label
   134 	// Get the view heading label
   125 	mViewHeading = static_cast<HbLabel *> (
   135 	mSubTitle = static_cast<HbGroupBox *>(
   126 			mDocLoader->findWidget("viewHeading"));
   136 			mDocLoader->findWidget("viewHeading"));
   127 
   137 
       
   138 	// Handles the orientation change for list items
       
   139 	HbMainWindow *window = hbInstance->allMainWindows().first();
       
   140 	handleOrientationChanged(window->orientation());
       
   141 	connect(
       
   142 			window, SIGNAL(orientationChanged(Qt::Orientation)),
       
   143 			this, SLOT(handleOrientationChanged(Qt::Orientation)));
       
   144 
       
   145 	// Set the graphics size for the icons.
       
   146 	HbListViewItem *prototype = mListView->listItemPrototype();
       
   147 	prototype->setGraphicsSize(HbListViewItem::SmallIcon);
       
   148 	
       
   149     // Get a pointer to activity Manager
       
   150     HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
       
   151   
       
   152     // clean up any previous versions of this activity from the activity manager.
       
   153     // ignore return value as the first boot would always return a false
       
   154     // bool declared on for debugging purpose
       
   155     bool ok = activityManager->removeActivity(notes);
       
   156 	
       
   157 	// connect main view for the first time to recieve aboutToQuit signal
       
   158     connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
       
   159     
       
   160  }
       
   161 
       
   162 void NotesMainView::setupAfterViewReady()
       
   163 {
   128 	// Get the toolbar/menu actions.
   164 	// Get the toolbar/menu actions.
   129 	mAddNoteAction = static_cast<HbAction *> (
   165 	mAddNoteAction = static_cast<HbAction *> (
   130 			mDocLoader->findObject("newNoteAction"));
   166 			mDocLoader->findObject("newNoteAction"));
   131 	Q_ASSERT_X(
   167 	Q_ASSERT_X(
   132 			mAddNoteAction,
   168 			mAddNoteAction,
   157 
   193 
   158 	connect(
   194 	connect(
   159 			mViewCollectionAction, SIGNAL(triggered()),
   195 			mViewCollectionAction, SIGNAL(triggered()),
   160 			this, SLOT(displayCollectionView()));
   196 			this, SLOT(displayCollectionView()));
   161 
   197 
   162 	mSubTitle = static_cast<HbGroupBox *>(
       
   163 			mDocLoader->findWidget("viewHeading"));
       
   164 
       
   165 	// Handles the orientation change for list items
       
   166 	HbMainWindow *window = hbInstance->allMainWindows().first();
       
   167 	handleOrientationChanged(window->orientation());
       
   168 	connect(
       
   169 			window, SIGNAL(orientationChanged(Qt::Orientation)),
       
   170 			this, SLOT(handleOrientationChanged(Qt::Orientation)));
       
   171 
       
   172 	// Update sub heading text for main view.
       
   173 	updateSubTitle();
       
   174 
       
   175 	connect(
   198 	connect(
   176 			mAgendaUtil, SIGNAL(entryAdded(ulong)),
   199 			mAgendaUtil, SIGNAL(entryAdded(ulong)),
   177 			this,SLOT(updateSubTitle(ulong)));
   200 			this,SLOT(updateSubTitle(ulong)));
   178 	connect(
   201 	connect(
   179 			mAgendaUtil, SIGNAL(entryDeleted(ulong)),
   202 			mAgendaUtil, SIGNAL(entryDeleted(ulong)),
   180 			this,SLOT(updateSubTitle(ulong)));
   203 			this,SLOT(updateSubTitle(ulong)));
   181 	connect(
   204 	connect(
   182 			mAgendaUtil, SIGNAL(entryUpdated(ulong)),
   205 			mAgendaUtil, SIGNAL(entryUpdated(ulong)),
   183 			this, SLOT(updateSubTitle(ulong)));
   206 			this, SLOT(updateSubTitle(ulong)));
   184 
   207 }
   185 	// Set the graphics size for the icons.
   208 
   186 	HbListViewItem *prototype = mListView->listItemPrototype();
   209 /*
   187 	prototype->setGraphicsSize(HbListViewItem::SmallIcon);
   210 	Updates the title text for the first launch
       
   211  */
       
   212 void NotesMainView::updateTitle()
       
   213 {
       
   214 	updateSubTitle();
   188 }
   215 }
   189 
   216 
   190 /*!
   217 /*!
   191 	Slot which gets called when `+ New note' action is triggered from the view
   218 	Slot which gets called when `+ New note' action is triggered from the view
   192 	toolbar. This is responsible for launching the editor to create a new note.
   219 	toolbar. This is responsible for launching the editor to create a new note.
   198 	mNotesEditor = new NotesEditor(mAgendaUtil, this);
   225 	mNotesEditor = new NotesEditor(mAgendaUtil, this);
   199 	connect(
   226 	connect(
   200 			mNotesEditor, SIGNAL(editingCompleted(bool)),
   227 			mNotesEditor, SIGNAL(editingCompleted(bool)),
   201 			this, SLOT(handleEditingCompleted(bool)));
   228 			this, SLOT(handleEditingCompleted(bool)));
   202 	mNotesEditor->create(NotesEditor::CreateNote);
   229 	mNotesEditor->create(NotesEditor::CreateNote);
       
   230 	// capture screenshot for future use, if application
       
   231 	// is exited/Quit from notesEditor
       
   232 	captureScreenShot(true);
   203 }
   233 }
   204 
   234 
   205 /*!
   235 /*!
   206 	Handles the pressing of a list item in the view.
   236 	Handles the pressing of a list item in the view.
   207 
   237 
   210 	\param index Reference to the QModelIndex representing the view item.
   240 	\param index Reference to the QModelIndex representing the view item.
   211 	\sa HbAbstractViewItem
   241 	\sa HbAbstractViewItem
   212  */
   242  */
   213 void NotesMainView::handleItemReleased(const QModelIndex &index)
   243 void NotesMainView::handleItemReleased(const QModelIndex &index)
   214 {
   244 {
   215 	// Sanity check.
   245 	if(!mIsLongTop) {
   216 	if (!index.isValid()) {
   246 		// Sanity check.
   217 		return;
   247 		if (!index.isValid()) {
   218 	}
   248 			return;
   219 
   249 		}
   220 	// First get the id of the note and get the corresponding information from
   250 
   221 	// agendautil.
   251 		// First get the id of the note and get the corresponding information from
   222 	ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>();
   252 		// agendautil.
   223 
   253 		ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>();
   224 	if (0 >= noteId) {
   254 
   225 		// Something wrong.
   255 		if (0 >= noteId) {
   226 		return;
   256 			// Something wrong.
   227 	}
   257 			return;
   228 
   258 		}
   229 	// Get the entry details.
   259 
   230 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   260 		// Get the entry details.
   231 	if (entry.isNull()) {
   261 		AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   232 		// Entry invalid.
   262 		if (entry.isNull()) {
   233 		return;
   263 			// Entry invalid.
   234 	}
   264 			return;
   235 
   265 		}
   236 	if(AgendaEntry::TypeTodo == entry.type()) {
   266 
   237 		// Construct agenda event viewer.
   267 		if(AgendaEntry::TypeTodo == entry.type()) {
   238 		mAgendaEventViewer = new AgendaEventViewer(mAgendaUtil, this);
   268 			// Construct agenda event viewer.
   239 
   269 			mAgendaEventViewer = new AgendaEventViewer(mAgendaUtil, this);
   240 		connect(
   270 
   241 				mAgendaEventViewer, SIGNAL(viewingCompleted(const QDate)),
   271 			connect(
   242 				this, SLOT(handleViewingCompleted()));
   272 					mAgendaEventViewer, SIGNAL(viewingCompleted(const QDate)),
   243 		// Launch agenda event viewer
   273 					this, SLOT(handleViewingCompleted()));
   244 		mAgendaEventViewer->view(
   274 			// Launch agenda event viewer
   245 				entry, AgendaEventViewer::ActionEditDelete);
   275 			mAgendaEventViewer->view(
   246 	}else if(AgendaEntry::TypeNote == entry.type()) {
   276 					entry, AgendaEventViewer::ActionEditDelete);
   247 		// Construct notes editor.
   277 		}else if(AgendaEntry::TypeNote == entry.type()) {
   248 		mNotesEditor = new NotesEditor(mAgendaUtil, this);
   278 			// Construct notes editor.
   249 		connect(
   279 			mNotesEditor = new NotesEditor(mAgendaUtil, this);
   250 				mNotesEditor, SIGNAL(editingCompleted(bool)),
   280 			connect(
   251 				this, SLOT(handleEditingCompleted(bool)));
   281 					mNotesEditor, SIGNAL(editingCompleted(bool)),
   252 
   282 					this, SLOT(handleEditingCompleted(bool)));
   253 		// Launch the notes editor with the obtained info.
   283 
   254 		mNotesEditor->edit(entry);
   284 			// Launch the notes editor with the obtained info.
       
   285 			mNotesEditor->edit(entry);
       
   286 		}
       
   287 		// capture screenshot for future use, if application
       
   288 		// is exited/Quit from eventViewer/notesEditor
       
   289 		captureScreenShot(true);
   255 	}
   290 	}
   256 }
   291 }
   257 
   292 
   258 /*!
   293 /*!
   259 	Displays a list item specific context menu.
   294 	Displays a list item specific context menu.
   264 	\sa HbAbstractViewItem, HbListView, HbMenu.
   299 	\sa HbAbstractViewItem, HbListView, HbMenu.
   265  */
   300  */
   266 void NotesMainView::handleItemLongPressed(
   301 void NotesMainView::handleItemLongPressed(
   267 		HbAbstractViewItem *item, const QPointF &coords)
   302 		HbAbstractViewItem *item, const QPointF &coords)
   268 {
   303 {
       
   304 	mIsLongTop = true;
   269 	mSelectedItem = item;
   305 	mSelectedItem = item;
   270 
   306 
   271 	ulong noteId = item->modelIndex().data(
   307 	ulong noteId = item->modelIndex().data(
   272 			NotesNamespace::IdRole).value<qulonglong>();
   308 			NotesNamespace::IdRole).value<qulonglong>();
   273 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   309 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   274 
   310 
   275 	// Display a context specific menu.
   311 	// Display a context specific menu.
   276 	HbMenu *contextMenu = new HbMenu();
   312 	HbMenu *contextMenu = new HbMenu();
       
   313 	connect(
       
   314 			contextMenu,SIGNAL(aboutToClose()),
       
   315 			this, SLOT(handleMenuClosed()));
       
   316 
   277 	mOpenAction =
   317 	mOpenAction =
   278 			contextMenu->addAction(hbTrId("txt_common_menu_open"));
   318 			contextMenu->addAction(hbTrId("txt_common_menu_open"));
   279 	connect(
       
   280 			mOpenAction, SIGNAL(triggered()),
       
   281 			this, SLOT(openNote()));
       
   282 
   319 
   283 	// Add actions to the context menu.
   320 	// Add actions to the context menu.
   284 	if (AgendaEntry::TypeTodo == entry.type()) {
   321 	if (AgendaEntry::TypeTodo == entry.type()) {
   285 		mEditTodoAction =
   322 		mEditTodoAction =
   286 				contextMenu->addAction(hbTrId("txt_common_menu_edit"));
   323 				contextMenu->addAction(hbTrId("txt_common_menu_edit"));
   287 		connect(
       
   288 				mEditTodoAction, SIGNAL(triggered()),
       
   289 				this, SLOT(editTodo()));
       
   290 	}
   324 	}
   291 
   325 
   292 	mDeleteAction =
   326 	mDeleteAction =
   293 			contextMenu->addAction(hbTrId("txt_common_menu_delete"));
   327 			contextMenu->addAction(hbTrId("txt_common_menu_delete"));
   294 	connect(
       
   295 			mDeleteAction, SIGNAL(triggered()),
       
   296 			this, SLOT(deleteNote()));
       
   297 
   328 
   298 	if (AgendaEntry::TypeNote == entry.type()) {
   329 	if (AgendaEntry::TypeNote == entry.type()) {
   299 		if (entry.favourite()) {
   330 		if (entry.favourite()) {
   300 			mMakeFavouriteAction = contextMenu->addAction(
   331 			mMakeFavouriteAction = contextMenu->addAction(
   301 					hbTrId("txt_notes_menu_remove_from_favorites"));
   332 					hbTrId("txt_notes_menu_remove_from_favorites"));
   302 
       
   303 			connect(
       
   304 					mMakeFavouriteAction, SIGNAL(triggered()),
       
   305 					this, SLOT(markNoteAsFavourite()));
       
   306 
       
   307 		} else {
   333 		} else {
   308 			mMakeFavouriteAction = contextMenu->addAction(
   334 			mMakeFavouriteAction = contextMenu->addAction(
   309 					hbTrId("txt_notes_menu_mark_as_favorite"));
   335 					hbTrId("txt_notes_menu_mark_as_favorite"));
   310 
       
   311 			connect(
       
   312 					mMakeFavouriteAction, SIGNAL(triggered()),
       
   313 					this, SLOT(markNoteAsFavourite()));
       
   314 		}
   336 		}
   315 
   337 
   316 		mMarkTodoAction =
   338 		mMarkTodoAction =
   317 				contextMenu->addAction(
   339 				contextMenu->addAction(
   318 						hbTrId("txt_notes_menu_make_it_as_todo_note"));
   340 						hbTrId("txt_notes_menu_make_it_as_todo_note"));
   319 		connect(
       
   320 				mMarkTodoAction, SIGNAL(triggered()),
       
   321 				this, SLOT(markNoteAsTodo()));
       
   322 
   341 
   323 	} else if (AgendaEntry::TypeTodo == entry.type()) {
   342 	} else if (AgendaEntry::TypeTodo == entry.type()) {
   324 		if (AgendaEntry::TodoNeedsAction == entry.status()) {
   343 		if (AgendaEntry::TodoNeedsAction == entry.status()) {
   325 			mTodoStatusAction = contextMenu->addAction(
   344 			mTodoStatusAction = contextMenu->addAction(
   326 					hbTrId("txt_notes_menu_mark_as_done"));
   345 					hbTrId("txt_notes_menu_mark_as_done"));
   327 
       
   328 			connect(
       
   329 					mTodoStatusAction , SIGNAL(triggered()),
       
   330 					this, SLOT(markTodoStatus()));
       
   331 
       
   332 		} else if (AgendaEntry::TodoCompleted == entry.status()) {
   346 		} else if (AgendaEntry::TodoCompleted == entry.status()) {
   333 			mTodoStatusAction = contextMenu->addAction(
   347 			mTodoStatusAction = contextMenu->addAction(
   334 					hbTrId("txt_notes_menu_mark_as_not_done"));
   348 					hbTrId("txt_notes_menu_mark_as_not_done"));
   335 
       
   336 			connect(
       
   337 					mTodoStatusAction , SIGNAL(triggered()),
       
   338 					this, SLOT(markTodoStatus()));
       
   339 		}
   349 		}
   340 	}
   350 	}
   341 
   351 
   342 	// Show the menu.
   352 	// Show the menu.
   343 	contextMenu->exec(coords);
   353 	contextMenu->open(this, SLOT(selectedMenuAction(HbAction*)));
   344 
   354 	contextMenu->setPreferredPos(coords);
   345 }
   355 }
   346 
   356 
   347 /*!
   357 /*!
   348 	Slot to delete a selected note.
   358 	Slot to delete a selected note.
   349  */
   359  */
   420 {
   430 {
   421 	Q_UNUSED(status)
   431 	Q_UNUSED(status)
   422 
   432 
   423 	// Cleanup.
   433 	// Cleanup.
   424 	mNotesEditor->deleteLater();
   434 	mNotesEditor->deleteLater();
   425 
   435 	// set captured screenshot as invalid as the control is returned back 
       
   436 	// to the main view
       
   437 	captureScreenShot(false);
   426 }
   438 }
   427 
   439 
   428 /*!
   440 /*!
   429 	Displays the collections' view.
   441 	Displays the collections' view.
   430  */
   442  */
   431 void NotesMainView::displayCollectionView()
   443 void NotesMainView::displayCollectionView()
   432 {
   444 {
   433 
   445     // no need to capture the screen shot for future use as 
       
   446     // NotesViewManager::switchToView takes care of it
   434 	// Switch to collections view.
   447 	// Switch to collections view.
   435 	mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId);
   448 	mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId);
   436 
   449 
   437 }
   450 }
   438 
   451 
   451 
   464 
   452 	\param status Indicates the status of viewing
   465 	\param status Indicates the status of viewing
   453  */
   466  */
   454 void NotesMainView::handleViewingCompleted()
   467 void NotesMainView::handleViewingCompleted()
   455 {
   468 {
   456 
       
   457 
       
   458 	mAgendaEventViewer->deleteLater();
   469 	mAgendaEventViewer->deleteLater();
   459 
   470 	// set captured screenshot as invalid as the control is returned back 
       
   471 	// to the main view
       
   472 	captureScreenShot(false);
   460 }
   473 }
   461 
   474 
   462 /*!
   475 /*!
   463 	Slot to handle the case when the state of an action has changed.
   476 	Slot to handle the case when the state of an action has changed.
   464  */
   477  */
   471 	Launches the to-do editor to edit the to-do entry
   484 	Launches the to-do editor to edit the to-do entry
   472  */
   485  */
   473 
   486 
   474 void NotesMainView::editTodo()
   487 void NotesMainView::editTodo()
   475 {
   488 {
   476 
       
   477 	// Get the selected list item index
   489 	// Get the selected list item index
   478 	QModelIndex index = mSelectedItem->modelIndex();
   490 	QModelIndex index = mSelectedItem->modelIndex();
   479 	if (!index.isValid()) {
   491 	if (!index.isValid()) {
   480 		return;
   492 		return;
   481 	}
   493 	}
   492 			mNotesEditor, SIGNAL(editingCompleted(bool)),
   504 			mNotesEditor, SIGNAL(editingCompleted(bool)),
   493 			this, SLOT(handleEditingCompleted(bool)));
   505 			this, SLOT(handleEditingCompleted(bool)));
   494 
   506 
   495 	// Launch the to-do editor with the obtained info.
   507 	// Launch the to-do editor with the obtained info.
   496 	mNotesEditor->edit(todoId);
   508 	mNotesEditor->edit(todoId);
       
   509 	// capture screenshot for future use, if application
       
   510 	// is exited/Quit from notesEditor
       
   511 	captureScreenShot(true);
   497 
   512 
   498 }
   513 }
   499 
   514 
   500 /*!
   515 /*!
   501 	Handles the orientation changes.Updates the list
   516 	Handles the orientation changes.Updates the list
   525 	QList<ulong> entries = mAgendaUtil->entryIds(
   540 	QList<ulong> entries = mAgendaUtil->entryIds(
   526 			(AgendaUtil::FilterFlags)
   541 			(AgendaUtil::FilterFlags)
   527 			(AgendaUtil::IncludeNotes
   542 			(AgendaUtil::IncludeNotes
   528 			| AgendaUtil::IncludeCompletedTodos
   543 			| AgendaUtil::IncludeCompletedTodos
   529 			| AgendaUtil::IncludeIncompletedTodos));
   544 			| AgendaUtil::IncludeIncompletedTodos));
   530 	int c= entries.count();
   545 	
       
   546 	if (0 >= entries.count()) {
       
   547 		mEmptyListLabel->show();
       
   548 		mListView->hide();
       
   549 	} else {
       
   550 		mEmptyListLabel->hide();
       
   551 		mListView->show();
       
   552 	}
       
   553 	
   531 	mSubTitle->setHeading(
   554 	mSubTitle->setHeading(
   532 			hbTrId("txt_notes_subhead_ln_notes",entries.count()));
   555 			hbTrId("txt_notes_subhead_ln_notes",entries.count()));
   533 }
   556 }
   534 
   557 
   535 /*!
   558 /*!
   616 				this, SLOT(handleViewingCompleted(bool)));
   639 				this, SLOT(handleViewingCompleted(bool)));
   617 		// Launch agenda event viewer
   640 		// Launch agenda event viewer
   618 		mAgendaEventViewer->view(
   641 		mAgendaEventViewer->view(
   619 				entry, AgendaEventViewer::ActionEditDelete);
   642 				entry, AgendaEventViewer::ActionEditDelete);
   620 	}
   643 	}
   621 }
   644 	// capture screenshot for future use, if application
       
   645 	// is exited/Quit from notesEditor/eventViewer
       
   646 	captureScreenShot(true);
       
   647 }
       
   648 
       
   649 /*!
       
   650 	 Slot to handle the selected context menu actions
       
   651  */
       
   652 void NotesMainView::selectedMenuAction(HbAction *action)
       
   653 {
       
   654 	if (action == mOpenAction) {
       
   655 		openNote();
       
   656 	} else if (action == mEditTodoAction) {
       
   657 		editTodo();
       
   658 	} else if (action == mDeleteAction) {
       
   659 		deleteNote();
       
   660 	} else if (action == mMakeFavouriteAction) {
       
   661 		markNoteAsFavourite();
       
   662 	} else if (action == mMarkTodoAction) {
       
   663 		markNoteAsTodo();
       
   664 	} else if (action == mTodoStatusAction) {
       
   665 		markTodoStatus();
       
   666 	}
       
   667 }
       
   668 
       
   669 /*!
       
   670 	Slot to handle the context menu closed.
       
   671  */
       
   672 void NotesMainView::handleMenuClosed()
       
   673 {
       
   674 	mIsLongTop = false;
       
   675 }
       
   676 
       
   677 /*!
       
   678 	CaptureScreenShot captures screen shot 
       
   679 	\param captureScreenShot bool to indicate if screenshot needs to be captured
       
   680 */ 
       
   681 void NotesMainView::captureScreenShot(bool captureScreenShot)
       
   682     {
       
   683     if (captureScreenShot) // check if screen shot needs to be captured
       
   684         {
       
   685         mScreenShot.clear();
       
   686         mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect()));
       
   687         }
       
   688     mIsScreenShotCapruted = captureScreenShot; // set mIsScreenShotCapruted set validity of screenshot
       
   689     }
       
   690 
       
   691 /*!    
       
   692 	saveActivity saves main view as an activity 
       
   693 */ 
       
   694 void NotesMainView::saveActivity()
       
   695  {
       
   696    // Get a pointer to activity Manager
       
   697    HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
       
   698  
       
   699    if (!mIsScreenShotCapruted) // check if a valid screenshot is already captured
       
   700        {
       
   701        mScreenShot.clear();
       
   702        mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect()));
       
   703        }
       
   704  
       
   705    // save any data necessary to save the state
       
   706    QByteArray serializedActivity;
       
   707    QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append);
       
   708    stream << NotesNamespace::NotesMainViewId;
       
   709  
       
   710    // add the activity to the activity manager
       
   711    bool ok = activityManager->addActivity(notes, serializedActivity, mScreenShot);
       
   712    if ( !ok )
       
   713        {
       
   714        qFatal("Add failed" );
       
   715        }
       
   716  }
   622 // End of file	--Don't remove this.
   717 // End of file	--Don't remove this.