notes/notesui/notesviews/src/notesmainview.cpp
changeset 55 2c54b51f39c4
parent 45 b6db4fd4947b
child 70 a5ed90760192
equal deleted inserted replaced
51:0b38fc5b94c6 55:2c54b51f39c4
    32 #include <HbListViewItem>
    32 #include <HbListViewItem>
    33 #include <hbapplication> // hbapplication
    33 #include <hbapplication> // hbapplication
    34 #include <hbactivitymanager> // hbactivitymanager
    34 #include <hbactivitymanager> // hbactivitymanager
    35 
    35 
    36 // User includes
    36 // User includes
       
    37 #include <agendautil.h>
    37 #include "agendaeventviewer.h"
    38 #include "agendaeventviewer.h"
    38 #include "notesmainview.h"
    39 #include "notesmainview.h"
    39 #include "notescommon.h"
    40 #include "notescommon.h"
    40 #include "notesdocloader.h"
    41 #include "notesdocloader.h"
    41 #include "agendautil.h"
       
    42 #include "notesmodel.h"
    42 #include "notesmodel.h"
    43 #include "notessortfilterproxymodel.h"
    43 #include "notessortfilterproxymodel.h"
    44 #include "noteseditor.h"
    44 #include "noteseditor.h"
    45 #include "notescommon.h" // NotesNamespace
    45 #include "notescommon.h"
       
    46 #include "OstTraceDefinitions.h"
       
    47 #ifdef OST_TRACE_COMPILER_IN_USE
       
    48 #include "notesmainviewTraces.h"
       
    49 #endif
       
    50  // NotesNamespace
    46 
    51 
    47 /*!
    52 /*!
    48 	\class NotesMainView
    53 	\class NotesMainView
    49 	\brief The main view of the notes application. Responsible for displaying
    54 	\brief The main view of the notes application. Responsible for displaying
    50 			notes and todos.
    55 			notes and todos.
    62  mSelectedItem(0),
    67  mSelectedItem(0),
    63  mDeleteAction(0),
    68  mDeleteAction(0),
    64  mIsLongTop(false),
    69  mIsLongTop(false),
    65  mIsScreenShotCapruted(false)
    70  mIsScreenShotCapruted(false)
    66 {
    71 {
       
    72 	OstTraceFunctionEntry0( NOTESMAINVIEW_NOTESMAINVIEW_ENTRY );
    67 	// Nothing yet.
    73 	// Nothing yet.
       
    74 	OstTraceFunctionExit0( NOTESMAINVIEW_NOTESMAINVIEW_EXIT );
    68 }
    75 }
    69 
    76 
    70 /*!
    77 /*!
    71 	Destructor.
    78 	Destructor.
    72  */
    79  */
    73 NotesMainView::~NotesMainView()
    80 NotesMainView::~NotesMainView()
    74 {
    81 {
       
    82 	OstTraceFunctionEntry0( DUP1_NOTESMAINVIEW_NOTESMAINVIEW_ENTRY );
    75 	if (mDocLoader) {
    83 	if (mDocLoader) {
    76 		delete mDocLoader;
    84 		delete mDocLoader;
    77 		mDocLoader = 0;
    85 		mDocLoader = 0;
    78 	}
    86 	}
    79 
    87 
       
    88 	OstTraceFunctionExit0( DUP1_NOTESMAINVIEW_NOTESMAINVIEW_EXIT );
    80 }
    89 }
    81 
    90 
    82 /*!
    91 /*!
    83 	Called by the NotesViewManager after loading the view from the docml.
    92 	Called by the NotesViewManager after loading the view from the docml.
    84 	The initializaion/setup of the view is done here.
    93 	The initializaion/setup of the view is done here.
    87 	\param docLoader Pointer to NotesDocLoader object.
    96 	\param docLoader Pointer to NotesDocLoader object.
    88  */
    97  */
    89 void NotesMainView::setupView(
    98 void NotesMainView::setupView(
    90 		NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader)
    99 		NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader)
    91 {
   100 {
       
   101 	OstTraceFunctionEntry0( NOTESMAINVIEW_SETUPVIEW_ENTRY );
    92 
   102 
    93 	mDocLoader = docLoader;
   103 	mDocLoader = docLoader;
    94 	mAppControllerIf = &controllerIf;
   104 	mAppControllerIf = &controllerIf;
    95 	mNotesModel = mAppControllerIf->notesModel();
   105 	mNotesModel = mAppControllerIf->notesModel();
    96 	mAgendaUtil = mAppControllerIf->agendaUtil();
   106 	mAgendaUtil = mAppControllerIf->agendaUtil();
   144 
   154 
   145 	// Set the graphics size for the icons.
   155 	// Set the graphics size for the icons.
   146 	HbListViewItem *prototype = mListView->listItemPrototype();
   156 	HbListViewItem *prototype = mListView->listItemPrototype();
   147 	prototype->setGraphicsSize(HbListViewItem::SmallIcon);
   157 	prototype->setGraphicsSize(HbListViewItem::SmallIcon);
   148 	
   158 	
   149     // Get a pointer to activity Manager
   159 	// Get a pointer to activity Manager
   150     HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
   160 	HbActivityManager* activityManager =
   151   
   161 			qobject_cast<HbApplication*>(qApp)->activityManager();
   152     // clean up any previous versions of this activity from the activity manager.
   162 
   153     // ignore return value as the first boot would always return a false
   163 	// clean up any previous versions of this activity from the activity manager
   154     // bool declared on for debugging purpose
   164 	// ignore return value as the first boot would always return a false
   155     bool ok = activityManager->removeActivity(notes);
   165 	// bool declared on for debugging purpose
       
   166 	bool ok = activityManager->removeActivity(notes);
       
   167 
       
   168 	// connect main view for the first time to recieve aboutToQuit signal
       
   169 	connect(
       
   170 			qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()),
       
   171 			this, SLOT(saveActivity()));
   156 	
   172 	
   157 	// connect main view for the first time to recieve aboutToQuit signal
   173 	OstTraceFunctionExit0( NOTESMAINVIEW_SETUPVIEW_EXIT );
   158     connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
   174 }
   159     
       
   160  }
       
   161 
   175 
   162 void NotesMainView::setupAfterViewReady()
   176 void NotesMainView::setupAfterViewReady()
   163 {
   177 {
       
   178 	OstTraceFunctionEntry0( NOTESMAINVIEW_SETUPAFTERVIEWREADY_ENTRY );
   164 	// Get the toolbar/menu actions.
   179 	// Get the toolbar/menu actions.
   165 	mAddNoteAction = static_cast<HbAction *> (
   180 	mAddNoteAction = static_cast<HbAction *> (
   166 			mDocLoader->findObject("newNoteAction"));
   181 			mDocLoader->findObject("newNoteAction"));
   167 	Q_ASSERT_X(
   182 	Q_ASSERT_X(
   168 			mAddNoteAction,
   183 			mAddNoteAction,
   202 			mAgendaUtil, SIGNAL(entryDeleted(ulong)),
   217 			mAgendaUtil, SIGNAL(entryDeleted(ulong)),
   203 			this,SLOT(updateSubTitle(ulong)));
   218 			this,SLOT(updateSubTitle(ulong)));
   204 	connect(
   219 	connect(
   205 			mAgendaUtil, SIGNAL(entryUpdated(ulong)),
   220 			mAgendaUtil, SIGNAL(entryUpdated(ulong)),
   206 			this, SLOT(updateSubTitle(ulong)));
   221 			this, SLOT(updateSubTitle(ulong)));
       
   222 	OstTraceFunctionExit0( NOTESMAINVIEW_SETUPAFTERVIEWREADY_EXIT );
   207 }
   223 }
   208 
   224 
   209 /*
   225 /*
   210 	Updates the title text for the first launch
   226 	Updates the title text for the first launch
   211  */
   227  */
   212 void NotesMainView::updateTitle()
   228 void NotesMainView::updateTitle()
   213 {
   229 {
       
   230 	OstTraceFunctionEntry0( NOTESMAINVIEW_UPDATETITLE_ENTRY );
   214 	updateSubTitle();
   231 	updateSubTitle();
       
   232 	OstTraceFunctionExit0( NOTESMAINVIEW_UPDATETITLE_EXIT );
   215 }
   233 }
   216 
   234 
   217 /*!
   235 /*!
   218 	Slot which gets called when `+ New note' action is triggered from the view
   236 	Slot which gets called when `+ New note' action is triggered from the view
   219 	toolbar. This is responsible for launching the editor to create a new note.
   237 	toolbar. This is responsible for launching the editor to create a new note.
   220  */
   238  */
   221 void NotesMainView::createNewNote()
   239 void NotesMainView::createNewNote()
   222 {
   240 {
       
   241 	OstTraceFunctionEntry0( NOTESMAINVIEW_CREATENEWNOTE_ENTRY );
   223 
   242 
   224 	// Here we Display an editor to the use to enter text.
   243 	// Here we Display an editor to the use to enter text.
   225 	mNotesEditor = new NotesEditor(mAgendaUtil, this);
   244 	mNotesEditor = new NotesEditor(mAgendaUtil, this);
   226 	connect(
   245 	connect(
   227 			mNotesEditor, SIGNAL(editingCompleted(bool)),
   246 			mNotesEditor, SIGNAL(editingCompleted(bool)),
   228 			this, SLOT(handleEditingCompleted(bool)));
   247 			this, SLOT(handleEditingCompleted(bool)));
   229 	mNotesEditor->create(NotesEditor::CreateNote);
   248 	mNotesEditor->create(NotesEditor::CreateNote);
   230 	// capture screenshot for future use, if application
   249 	// capture screenshot for future use, if application
   231 	// is exited/Quit from notesEditor
   250 	// is exited/Quit from notesEditor
   232 	captureScreenShot(true);
   251 	captureScreenShot(true);
       
   252 	OstTraceFunctionExit0( NOTESMAINVIEW_CREATENEWNOTE_EXIT );
   233 }
   253 }
   234 
   254 
   235 /*!
   255 /*!
   236 	Handles the pressing of a list item in the view.
   256 	Handles the pressing of a list item in the view.
   237 
   257 
   240 	\param index Reference to the QModelIndex representing the view item.
   260 	\param index Reference to the QModelIndex representing the view item.
   241 	\sa HbAbstractViewItem
   261 	\sa HbAbstractViewItem
   242  */
   262  */
   243 void NotesMainView::handleItemReleased(const QModelIndex &index)
   263 void NotesMainView::handleItemReleased(const QModelIndex &index)
   244 {
   264 {
       
   265 	OstTraceFunctionEntry0( NOTESMAINVIEW_HANDLEITEMRELEASED_ENTRY );
   245 	if(!mIsLongTop) {
   266 	if(!mIsLongTop) {
   246 		// Sanity check.
   267 		// Sanity check.
   247 		if (!index.isValid()) {
   268 		if (!index.isValid()) {
       
   269 			OstTraceFunctionExit0( NOTESMAINVIEW_HANDLEITEMRELEASED_EXIT );
   248 			return;
   270 			return;
   249 		}
   271 		}
   250 
   272 
   251 		// First get the id of the note and get the corresponding information from
   273 		// First get the id of the note and get the corresponding information
   252 		// agendautil.
   274 		// from agendautil.
   253 		ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>();
   275 		ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>();
   254 
   276 
   255 		if (0 >= noteId) {
   277 		if (0 >= noteId) {
   256 			// Something wrong.
   278 			// Something wrong.
       
   279 			OstTraceFunctionExit0( DUP1_NOTESMAINVIEW_HANDLEITEMRELEASED_EXIT );
   257 			return;
   280 			return;
   258 		}
   281 		}
   259 
   282 
   260 		// Get the entry details.
   283 		// Get the entry details.
   261 		AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   284 		AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   262 		if (entry.isNull()) {
   285 		if (entry.isNull()) {
   263 			// Entry invalid.
   286 			// Entry invalid.
       
   287 			OstTraceFunctionExit0( DUP2_NOTESMAINVIEW_HANDLEITEMRELEASED_EXIT );
   264 			return;
   288 			return;
   265 		}
   289 		}
   266 
   290 
   267 		if(AgendaEntry::TypeTodo == entry.type()) {
   291 		if(AgendaEntry::TypeTodo == entry.type()) {
   268 			// Construct agenda event viewer.
   292 			// Construct agenda event viewer.
   286 		}
   310 		}
   287 		// capture screenshot for future use, if application
   311 		// capture screenshot for future use, if application
   288 		// is exited/Quit from eventViewer/notesEditor
   312 		// is exited/Quit from eventViewer/notesEditor
   289 		captureScreenShot(true);
   313 		captureScreenShot(true);
   290 	}
   314 	}
       
   315 	OstTraceFunctionExit0( DUP3_NOTESMAINVIEW_HANDLEITEMRELEASED_EXIT );
   291 }
   316 }
   292 
   317 
   293 /*!
   318 /*!
   294 	Displays a list item specific context menu.
   319 	Displays a list item specific context menu.
   295 
   320 
   299 	\sa HbAbstractViewItem, HbListView, HbMenu.
   324 	\sa HbAbstractViewItem, HbListView, HbMenu.
   300  */
   325  */
   301 void NotesMainView::handleItemLongPressed(
   326 void NotesMainView::handleItemLongPressed(
   302 		HbAbstractViewItem *item, const QPointF &coords)
   327 		HbAbstractViewItem *item, const QPointF &coords)
   303 {
   328 {
       
   329 	OstTraceFunctionEntry0( NOTESMAINVIEW_HANDLEITEMLONGPRESSED_ENTRY );
   304 	mIsLongTop = true;
   330 	mIsLongTop = true;
   305 	mSelectedItem = item;
   331 	mSelectedItem = item;
   306 
   332 
   307 	ulong noteId = item->modelIndex().data(
   333 	ulong noteId = item->modelIndex().data(
   308 			NotesNamespace::IdRole).value<qulonglong>();
   334 			NotesNamespace::IdRole).value<qulonglong>();
   350 	}
   376 	}
   351 
   377 
   352 	// Show the menu.
   378 	// Show the menu.
   353 	contextMenu->open(this, SLOT(selectedMenuAction(HbAction*)));
   379 	contextMenu->open(this, SLOT(selectedMenuAction(HbAction*)));
   354 	contextMenu->setPreferredPos(coords);
   380 	contextMenu->setPreferredPos(coords);
       
   381 	OstTraceFunctionExit0( NOTESMAINVIEW_HANDLEITEMLONGPRESSED_EXIT );
   355 }
   382 }
   356 
   383 
   357 /*!
   384 /*!
   358 	Slot to delete a selected note.
   385 	Slot to delete a selected note.
   359  */
   386  */
   360 void NotesMainView::deleteNote()
   387 void NotesMainView::deleteNote()
   361 {
   388 {
       
   389 	OstTraceFunctionEntry0( NOTESMAINVIEW_DELETENOTE_ENTRY );
   362 	Q_ASSERT(mSelectedItem);
   390 	Q_ASSERT(mSelectedItem);
   363 
   391 
   364 	QModelIndex index = mSelectedItem->modelIndex();
   392 	QModelIndex index = mSelectedItem->modelIndex();
   365 	if (!index.isValid()) {
   393 	if (!index.isValid()) {
       
   394 		OstTraceFunctionExit0( NOTESMAINVIEW_DELETENOTE_EXIT );
   366 		return;
   395 		return;
   367 	}
   396 	}
   368 	ulong noteId =
   397 	ulong noteId =
   369 			index.data(NotesNamespace::IdRole).value<qulonglong>();
   398 			index.data(NotesNamespace::IdRole).value<qulonglong>();
   370 	if (!noteId) {
   399 	if (!noteId) {
   371 
   400 
       
   401 		OstTraceFunctionExit0( DUP1_NOTESMAINVIEW_DELETENOTE_EXIT );
   372 		return;
   402 		return;
   373 	}
   403 	}
   374 
   404 
   375 	// Emit the signal.Deletion would happen in view manager.
   405 	// Emit the signal.Deletion would happen in view manager.
   376 	emit deleteEntry(noteId);
   406 	emit deleteEntry(noteId);
   377 
   407 
   378 	mSelectedItem = 0;
   408 	mSelectedItem = 0;
       
   409 	OstTraceFunctionExit0( DUP2_NOTESMAINVIEW_DELETENOTE_EXIT );
   379 }
   410 }
   380 
   411 
   381 /*!
   412 /*!
   382 	Marks to-do entry as done or undone based on the completed value
   413 	Marks to-do entry as done or undone based on the completed value
   383 
   414 
   385 	\param status is true if to-do entry to be marked as done
   416 	\param status is true if to-do entry to be marked as done
   386 			is false if to-do entry to be marked as undone
   417 			is false if to-do entry to be marked as undone
   387  */
   418  */
   388 void NotesMainView::markTodoStatus()
   419 void NotesMainView::markTodoStatus()
   389 {
   420 {
       
   421 	OstTraceFunctionEntry0( NOTESMAINVIEW_MARKTODOSTATUS_ENTRY );
   390 	ulong noteId = mSelectedItem->modelIndex().data(
   422 	ulong noteId = mSelectedItem->modelIndex().data(
   391 			NotesNamespace::IdRole).value<qulonglong>();
   423 			NotesNamespace::IdRole).value<qulonglong>();
   392 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   424 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   393 
   425 
   394 	QDateTime currentDateTime = QDateTime::currentDateTime();
   426 	QDateTime currentDateTime = QDateTime::currentDateTime();
   397 		mAgendaUtil->setCompleted(entry, true, currentDateTime);
   429 		mAgendaUtil->setCompleted(entry, true, currentDateTime);
   398 	} else if (AgendaEntry::TodoCompleted == entry.status()) {
   430 	} else if (AgendaEntry::TodoCompleted == entry.status()) {
   399 		mAgendaUtil->setCompleted(entry, false, currentDateTime);
   431 		mAgendaUtil->setCompleted(entry, false, currentDateTime);
   400 	}
   432 	}
   401 
   433 
       
   434 	OstTraceFunctionExit0( NOTESMAINVIEW_MARKTODOSTATUS_EXIT );
   402 }
   435 }
   403 
   436 
   404 /*!
   437 /*!
   405 	Marks/unmarks the note as favourite.
   438 	Marks/unmarks the note as favourite.
   406  */
   439  */
   407 void NotesMainView::markNoteAsFavourite()
   440 void NotesMainView::markNoteAsFavourite()
   408 {
   441 {
       
   442 	OstTraceFunctionEntry0( NOTESMAINVIEW_MARKNOTEASFAVOURITE_ENTRY );
   409 	ulong noteId = mSelectedItem->modelIndex().data(
   443 	ulong noteId = mSelectedItem->modelIndex().data(
   410 				NotesNamespace::IdRole).value<qulonglong>();
   444 				NotesNamespace::IdRole).value<qulonglong>();
   411 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   445 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   412 
   446 
   413 	if (entry.favourite()) {
   447 	if (entry.favourite()) {
   414 		entry.setFavourite(0);
   448 		entry.setFavourite(0);
   415 	} else {
   449 	} else {
   416 		entry.setFavourite(1);
   450 		entry.setFavourite(1);
   417 	}
   451 	}
   418 	mAgendaUtil->updateEntry(entry);
   452 	mAgendaUtil->store(entry);
   419 
   453 
       
   454 	OstTraceFunctionExit0( NOTESMAINVIEW_MARKNOTEASFAVOURITE_EXIT );
   420 }
   455 }
   421 
   456 
   422 /*!
   457 /*!
   423 	Slot to handle the signal editingCompleted by the notes editor.
   458 	Slot to handle the signal editingCompleted by the notes editor.
   424 
   459 
   426 
   461 
   427 	\sa NotesEditor.
   462 	\sa NotesEditor.
   428  */
   463  */
   429 void NotesMainView::handleEditingCompleted(bool status)
   464 void NotesMainView::handleEditingCompleted(bool status)
   430 {
   465 {
       
   466 	OstTraceFunctionEntry0( NOTESMAINVIEW_HANDLEEDITINGCOMPLETED_ENTRY );
   431 	Q_UNUSED(status)
   467 	Q_UNUSED(status)
   432 
   468 
   433 	// Cleanup.
   469 	// Cleanup.
   434 	mNotesEditor->deleteLater();
   470 	mNotesEditor->deleteLater();
   435 	// set captured screenshot as invalid as the control is returned back 
   471 	// set captured screenshot as invalid as the control is returned back 
   436 	// to the main view
   472 	// to the main view
   437 	captureScreenShot(false);
   473 	captureScreenShot(false);
       
   474 	OstTraceFunctionExit0( NOTESMAINVIEW_HANDLEEDITINGCOMPLETED_EXIT );
   438 }
   475 }
   439 
   476 
   440 /*!
   477 /*!
   441 	Displays the collections' view.
   478 	Displays the collections' view.
   442  */
   479  */
   443 void NotesMainView::displayCollectionView()
   480 void NotesMainView::displayCollectionView()
   444 {
   481 {
   445     // no need to capture the screen shot for future use as 
   482 	OstTraceFunctionEntry0( NOTESMAINVIEW_DISPLAYCOLLECTIONVIEW_ENTRY );
   446     // NotesViewManager::switchToView takes care of it
   483 	// no need to capture the screen shot for future use as 
       
   484 	// NotesViewManager::switchToView takes care of it
   447 	// Switch to collections view.
   485 	// Switch to collections view.
   448 	mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId);
   486 	mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId);
   449 
   487 
       
   488 	OstTraceFunctionExit0( NOTESMAINVIEW_DISPLAYCOLLECTIONVIEW_EXIT );
   450 }
   489 }
   451 
   490 
   452 /*!
   491 /*!
   453 	Slot where the list view is made to scroll to the QModelIndex index.
   492 	Slot where the list view is made to scroll to the QModelIndex index.
   454 
   493 
   455 	\param index QModelIndex to be scrolled to.
   494 	\param index QModelIndex to be scrolled to.
   456  */
   495  */
   457 void NotesMainView::scrollTo(QModelIndex index)
   496 void NotesMainView::scrollTo(QModelIndex index)
   458 {
   497 {
       
   498 	OstTraceFunctionEntry0( NOTESMAINVIEW_SCROLLTO_ENTRY );
   459 	mListView->scrollTo(index, HbAbstractItemView::EnsureVisible);
   499 	mListView->scrollTo(index, HbAbstractItemView::EnsureVisible);
       
   500 	OstTraceFunctionExit0( NOTESMAINVIEW_SCROLLTO_EXIT );
   460 }
   501 }
   461 
   502 
   462 /*!
   503 /*!
   463 	Slot to handle viewing Completed signal from agenda event viewer
   504 	Slot to handle viewing Completed signal from agenda event viewer
   464 
   505 
   465 	\param status Indicates the status of viewing
   506 	\param status Indicates the status of viewing
   466  */
   507  */
   467 void NotesMainView::handleViewingCompleted()
   508 void NotesMainView::handleViewingCompleted()
   468 {
   509 {
       
   510 	OstTraceFunctionEntry0( NOTESMAINVIEW_HANDLEVIEWINGCOMPLETED_ENTRY );
   469 	mAgendaEventViewer->deleteLater();
   511 	mAgendaEventViewer->deleteLater();
   470 	// set captured screenshot as invalid as the control is returned back 
   512 	// set captured screenshot as invalid as the control is returned back 
   471 	// to the main view
   513 	// to the main view
   472 	captureScreenShot(false);
   514 	captureScreenShot(false);
       
   515 	OstTraceFunctionExit0( NOTESMAINVIEW_HANDLEVIEWINGCOMPLETED_EXIT );
   473 }
   516 }
   474 
   517 
   475 /*!
   518 /*!
   476 	Slot to handle the case when the state of an action has changed.
   519 	Slot to handle the case when the state of an action has changed.
   477  */
   520  */
   478 void NotesMainView::handleActionStateChanged()
   521 void NotesMainView::handleActionStateChanged()
   479 {
   522 {
       
   523 	OstTraceFunctionEntry0( NOTESMAINVIEW_HANDLEACTIONSTATECHANGED_ENTRY );
   480 	mAllNotesAction->setChecked(true);
   524 	mAllNotesAction->setChecked(true);
       
   525 	OstTraceFunctionExit0( NOTESMAINVIEW_HANDLEACTIONSTATECHANGED_EXIT );
   481 }
   526 }
   482 
   527 
   483 /*!
   528 /*!
   484 	Launches the to-do editor to edit the to-do entry
   529 	Launches the to-do editor to edit the to-do entry
   485  */
   530  */
   486 
   531 
   487 void NotesMainView::editTodo()
   532 void NotesMainView::editTodo()
   488 {
   533 {
       
   534 	OstTraceFunctionEntry0( NOTESMAINVIEW_EDITTODO_ENTRY );
   489 	// Get the selected list item index
   535 	// Get the selected list item index
   490 	QModelIndex index = mSelectedItem->modelIndex();
   536 	QModelIndex index = mSelectedItem->modelIndex();
   491 	if (!index.isValid()) {
   537 	if (!index.isValid()) {
       
   538 		OstTraceFunctionExit0( NOTESMAINVIEW_EDITTODO_EXIT );
   492 		return;
   539 		return;
   493 	}
   540 	}
   494 	ulong todoId =
   541 	ulong todoId =
   495 			index.data(NotesNamespace::IdRole).value<qulonglong>();
   542 			index.data(NotesNamespace::IdRole).value<qulonglong>();
   496 	if (!todoId) {
   543 	if (!todoId) {
   497 
   544 
       
   545 		OstTraceFunctionExit0( DUP1_NOTESMAINVIEW_EDITTODO_EXIT );
   498 		return;
   546 		return;
   499 	}
   547 	}
   500 
   548 
   501 	// Construct notes editor.
   549 	// Construct notes editor.
   502 	mNotesEditor = new NotesEditor(mAgendaUtil, this);
   550 	mNotesEditor = new NotesEditor(mAgendaUtil, this);
   508 	mNotesEditor->edit(todoId);
   556 	mNotesEditor->edit(todoId);
   509 	// capture screenshot for future use, if application
   557 	// capture screenshot for future use, if application
   510 	// is exited/Quit from notesEditor
   558 	// is exited/Quit from notesEditor
   511 	captureScreenShot(true);
   559 	captureScreenShot(true);
   512 
   560 
       
   561 	OstTraceFunctionExit0( DUP2_NOTESMAINVIEW_EDITTODO_EXIT );
   513 }
   562 }
   514 
   563 
   515 /*!
   564 /*!
   516 	Handles the orientation changes.Updates the list
   565 	Handles the orientation changes.Updates the list
   517 	item when orientation is changed
   566 	item when orientation is changed
   518 
   567 
   519 	\param orientation Value of the orientation
   568 	\param orientation Value of the orientation
   520  */
   569  */
   521 void NotesMainView::handleOrientationChanged(Qt::Orientation orientation)
   570 void NotesMainView::handleOrientationChanged(Qt::Orientation orientation)
   522 {
   571 {
       
   572 	OstTraceFunctionEntry0( NOTESMAINVIEW_HANDLEORIENTATIONCHANGED_ENTRY );
   523 	HbListViewItem *prototype = mListView->listItemPrototype();
   573 	HbListViewItem *prototype = mListView->listItemPrototype();
   524 
   574 
   525 	if (Qt::Horizontal == orientation) {
   575 	if (Qt::Horizontal == orientation) {
   526 		prototype->setStretchingStyle(HbListViewItem::StretchLandscape);
   576 		prototype->setStretchingStyle(HbListViewItem::StretchLandscape);
   527 	} else {
   577 	} else {
   528 		prototype->setStretchingStyle(HbListViewItem::NoStretching);
   578 		prototype->setStretchingStyle(HbListViewItem::NoStretching);
   529 	}
   579 	}
       
   580 	OstTraceFunctionExit0( NOTESMAINVIEW_HANDLEORIENTATIONCHANGED_EXIT );
   530 }
   581 }
   531 
   582 
   532 /*!
   583 /*!
   533 	Updates the sub heading text
   584 	Updates the sub heading text
   534  */
   585  */
   535 void NotesMainView::updateSubTitle(ulong id)
   586 void NotesMainView::updateSubTitle(ulong id)
   536 {
   587 {
       
   588 	OstTraceFunctionEntry0( NOTESMAINVIEW_UPDATESUBTITLE_ENTRY );
   537 	Q_UNUSED(id)
   589 	Q_UNUSED(id)
   538 
   590 
   539 	// Get the number of notes and to-do entries.
   591 	// Get the number of notes and to-do entries.
   540 	QList<ulong> entries = mAgendaUtil->entryIds(
   592 	QList<ulong> entries = mAgendaUtil->entryIds(
   541 			(AgendaUtil::FilterFlags)
   593 			(AgendaUtil::FilterFlags)
   551 		mListView->show();
   603 		mListView->show();
   552 	}
   604 	}
   553 	
   605 	
   554 	mSubTitle->setHeading(
   606 	mSubTitle->setHeading(
   555 			hbTrId("txt_notes_subhead_ln_notes",entries.count()));
   607 			hbTrId("txt_notes_subhead_ln_notes",entries.count()));
       
   608 	OstTraceFunctionExit0( NOTESMAINVIEW_UPDATESUBTITLE_EXIT );
   556 }
   609 }
   557 
   610 
   558 /*!
   611 /*!
   559 	Slot to make a note as to-do.
   612 	Slot to make a note as to-do.
   560  */
   613  */
   561 void NotesMainView::markNoteAsTodo()
   614 void NotesMainView::markNoteAsTodo()
   562 {
   615 {
       
   616 	OstTraceFunctionEntry0( NOTESMAINVIEW_MARKNOTEASTODO_ENTRY );
   563 	Q_ASSERT(mSelectedItem);
   617 	Q_ASSERT(mSelectedItem);
   564 
   618 
   565 	QModelIndex index = mSelectedItem->modelIndex();
   619 	QModelIndex index = mSelectedItem->modelIndex();
   566 	if (!index.isValid()) {
   620 	if (!index.isValid()) {
       
   621 		OstTraceFunctionExit0( NOTESMAINVIEW_MARKNOTEASTODO_EXIT );
   567 		return;
   622 		return;
   568 	}
   623 	}
   569 	ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong> ();
   624 	ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong> ();
   570 	if (!noteId) {
   625 	if (!noteId) {
       
   626 		OstTraceFunctionExit0( DUP1_NOTESMAINVIEW_MARKNOTEASTODO_EXIT );
   571 		return;
   627 		return;
   572 	}
   628 	}
   573 	// Get the entry details.
   629 	// Get the entry details.
   574 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   630 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   575 
   631 
   576 	if (entry.isNull()) {
   632 	if (entry.isNull()) {
   577 		// Entry invalid.
   633 		// Entry invalid.
       
   634 		OstTraceFunctionExit0( DUP2_NOTESMAINVIEW_MARKNOTEASTODO_EXIT );
   578 		return;
   635 		return;
   579 	}
   636 	}
   580 
   637 
   581 	// Here change the type of modified note and destroy the noteeditor and
   638 	// Here change the type of modified note and destroy the noteeditor and
   582 	// construct the to-do editor.
   639 	// construct the to-do editor.
   596 		entry.setDescription("");
   653 		entry.setDescription("");
   597 	}
   654 	}
   598 
   655 
   599 	// Remove favourite if marked so.
   656 	// Remove favourite if marked so.
   600 	entry.setFavourite(0);
   657 	entry.setFavourite(0);
       
   658 	
       
   659 	// Set the priority of the to-do as normal
       
   660 	entry.setPriority(2);
   601 
   661 
   602 	// Set the status of the to-do.
   662 	// Set the status of the to-do.
   603 	entry.setStatus(AgendaEntry::TodoNeedsAction);
   663 	entry.setStatus(AgendaEntry::TodoNeedsAction);
   604 
   664 
   605 	// First clone the todoEntry for the new type.
   665 	// First clone the todoEntry for the new type.
   606 	mAgendaUtil->cloneEntry(entry, AgendaEntry::TypeTodo);
   666 	mAgendaUtil->cloneEntry(entry, AgendaEntry::TypeTodo);
   607 
   667 
   608 	// Delete the old entry.
   668 	// Delete the old entry.
   609 	mAgendaUtil->deleteEntry(entry.id());
   669 	mAgendaUtil->deleteEntry(entry.id());
       
   670 	OstTraceFunctionExit0( DUP3_NOTESMAINVIEW_MARKNOTEASTODO_EXIT );
   610 }
   671 }
   611 
   672 
   612 
   673 
   613 /*
   674 /*
   614 	Opens the notes editor if selected item is note otherwise opens
   675 	Opens the notes editor if selected item is note otherwise opens
   615 	to-do viewer if selected item is to-do event
   676 	to-do viewer if selected item is to-do event
   616  */
   677  */
   617 void NotesMainView::openNote()
   678 void NotesMainView::openNote()
   618 {
   679 {
       
   680 	OstTraceFunctionEntry0( NOTESMAINVIEW_OPENNOTE_ENTRY );
   619 	ulong noteId = mSelectedItem->modelIndex().data(
   681 	ulong noteId = mSelectedItem->modelIndex().data(
   620 			NotesNamespace::IdRole).value<qulonglong>();
   682 			NotesNamespace::IdRole).value<qulonglong>();
   621 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   683 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   622 
   684 
   623 	if (AgendaEntry::TypeNote == entry.type()) {
   685 	if (AgendaEntry::TypeNote == entry.type()) {
   642 				entry, AgendaEventViewer::ActionEditDelete);
   704 				entry, AgendaEventViewer::ActionEditDelete);
   643 	}
   705 	}
   644 	// capture screenshot for future use, if application
   706 	// capture screenshot for future use, if application
   645 	// is exited/Quit from notesEditor/eventViewer
   707 	// is exited/Quit from notesEditor/eventViewer
   646 	captureScreenShot(true);
   708 	captureScreenShot(true);
       
   709 	OstTraceFunctionExit0( NOTESMAINVIEW_OPENNOTE_EXIT );
   647 }
   710 }
   648 
   711 
   649 /*!
   712 /*!
   650 	 Slot to handle the selected context menu actions
   713 	 Slot to handle the selected context menu actions
   651  */
   714  */
   652 void NotesMainView::selectedMenuAction(HbAction *action)
   715 void NotesMainView::selectedMenuAction(HbAction *action)
   653 {
   716 {
       
   717 	OstTraceFunctionEntry0( NOTESMAINVIEW_SELECTEDMENUACTION_ENTRY );
   654 	if (action == mOpenAction) {
   718 	if (action == mOpenAction) {
   655 		openNote();
   719 		openNote();
   656 	} else if (action == mEditTodoAction) {
   720 	} else if (action == mEditTodoAction) {
   657 		editTodo();
   721 		editTodo();
   658 	} else if (action == mDeleteAction) {
   722 	} else if (action == mDeleteAction) {
   662 	} else if (action == mMarkTodoAction) {
   726 	} else if (action == mMarkTodoAction) {
   663 		markNoteAsTodo();
   727 		markNoteAsTodo();
   664 	} else if (action == mTodoStatusAction) {
   728 	} else if (action == mTodoStatusAction) {
   665 		markTodoStatus();
   729 		markTodoStatus();
   666 	}
   730 	}
       
   731 	OstTraceFunctionExit0( NOTESMAINVIEW_SELECTEDMENUACTION_EXIT );
   667 }
   732 }
   668 
   733 
   669 /*!
   734 /*!
   670 	Slot to handle the context menu closed.
   735 	Slot to handle the context menu closed.
   671  */
   736  */
   672 void NotesMainView::handleMenuClosed()
   737 void NotesMainView::handleMenuClosed()
   673 {
   738 {
       
   739 	OstTraceFunctionEntry0( NOTESMAINVIEW_HANDLEMENUCLOSED_ENTRY );
   674 	mIsLongTop = false;
   740 	mIsLongTop = false;
       
   741 	OstTraceFunctionExit0( NOTESMAINVIEW_HANDLEMENUCLOSED_EXIT );
   675 }
   742 }
   676 
   743 
   677 /*!
   744 /*!
   678 	CaptureScreenShot captures screen shot 
   745 	CaptureScreenShot captures screen shot 
   679 	\param captureScreenShot bool to indicate if screenshot needs to be captured
   746 	\param captureScreenShot bool to indicate if screenshot needs to be captured
   680 */ 
   747 */ 
   681 void NotesMainView::captureScreenShot(bool captureScreenShot)
   748 void NotesMainView::captureScreenShot(bool captureScreenShot)
   682     {
   749 {
   683     if (captureScreenShot) // check if screen shot needs to be captured
   750 	OstTraceFunctionEntry0( NOTESMAINVIEW_CAPTURESCREENSHOT_ENTRY );
   684         {
   751 	// check if screen shot needs to be captured
   685         mScreenShot.clear();
   752 	if (captureScreenShot) {
   686         mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect()));
   753 		mScreenShot.clear();
   687         }
   754 		mScreenShot.insert(
   688     mIsScreenShotCapruted = captureScreenShot; // set mIsScreenShotCapruted set validity of screenshot
   755 				"screenshot", QPixmap::grabWidget(
   689     }
   756 						mainWindow(), mainWindow()->rect()));
   690 
   757 	}
   691 /*!    
   758 	// set mIsScreenShotCapruted set validity of screenshot
       
   759 	mIsScreenShotCapruted = captureScreenShot;
       
   760 	OstTraceFunctionExit0( NOTESMAINVIEW_CAPTURESCREENSHOT_EXIT );
       
   761 }
       
   762 
       
   763 /*!
   692 	saveActivity saves main view as an activity 
   764 	saveActivity saves main view as an activity 
   693 */ 
   765 */
   694 void NotesMainView::saveActivity()
   766 void NotesMainView::saveActivity()
   695  {
   767 {
   696    // Get a pointer to activity Manager
   768 	OstTraceFunctionEntry0( NOTESMAINVIEW_SAVEACTIVITY_ENTRY );
   697    HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
   769 	// Get a pointer to activity Manager
   698  
   770 	HbActivityManager* activityManager =
   699    if (!mIsScreenShotCapruted) // check if a valid screenshot is already captured
   771 			qobject_cast<HbApplication*>(qApp)->activityManager();
   700        {
   772 	
   701        mScreenShot.clear();
   773 	// check if a valid screenshot is already captured
   702        mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect()));
   774 	if (!mIsScreenShotCapruted) {
   703        }
   775 		mScreenShot.clear();
   704  
   776 		mScreenShot.insert(
   705    // save any data necessary to save the state
   777 				"screenshot", QPixmap::grabWidget(
   706    QByteArray serializedActivity;
   778 						mainWindow(), mainWindow()->rect()));
   707    QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append);
   779 	}
   708    stream << NotesNamespace::NotesMainViewId;
   780 
   709  
   781 	// save any data necessary to save the state
   710    // add the activity to the activity manager
   782 	QByteArray serializedActivity;
   711    bool ok = activityManager->addActivity(notes, serializedActivity, mScreenShot);
   783 	QDataStream stream(
   712    if ( !ok )
   784 			&serializedActivity, QIODevice::WriteOnly | QIODevice::Append);
   713        {
   785 	stream << NotesNamespace::NotesMainViewId;
   714        qFatal("Add failed" );
   786 
   715        }
   787 	// add the activity to the activity manager
   716  }
   788 	bool ok = activityManager->addActivity(
       
   789 			notes, serializedActivity, mScreenShot);
       
   790 	if (!ok) {
       
   791 		qFatal("Add failed" );
       
   792 	}
       
   793 	OstTraceFunctionExit0( NOTESMAINVIEW_SAVEACTIVITY_EXIT );
       
   794 }
       
   795 
   717 // End of file	--Don't remove this.
   796 // End of file	--Don't remove this.