notes/notesui/notesviews/src/notesmainview.cpp
changeset 23 fd30d51f876b
parent 18 c198609911f9
child 26 a949c2543c15
child 45 b6db4fd4947b
equal deleted inserted replaced
18:c198609911f9 23:fd30d51f876b
    15 * Definition file for NotesMainView class.
    15 * Definition file for NotesMainView class.
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 // System includes
    19 // System includes
    20 #include <QDebug>
       
    21 #include <QDateTime>
    20 #include <QDateTime>
    22 #include <HbListView>
    21 #include <HbListView>
    23 #include <HbListWidget>
    22 #include <HbListWidget>
    24 #include <HbAction>
    23 #include <HbAction>
    25 #include <HbTextEdit>
    24 #include <HbTextEdit>
    58 NotesMainView::NotesMainView(QGraphicsWidget *parent)
    57 NotesMainView::NotesMainView(QGraphicsWidget *parent)
    59 :HbView(parent),
    58 :HbView(parent),
    60  mSelectedItem(0),
    59  mSelectedItem(0),
    61  mDeleteAction(0)
    60  mDeleteAction(0)
    62 {
    61 {
    63 	qDebug() << "notes: NotesMainView::NotesMainView -->";
       
    64 
       
    65 	// Nothing yet.
    62 	// Nothing yet.
    66 
       
    67 	qDebug() << "notes: NotesMainView::NotesMainView <--";
       
    68 }
    63 }
    69 
    64 
    70 /*!
    65 /*!
    71 	Destructor.
    66 	Destructor.
    72  */
    67  */
    73 NotesMainView::~NotesMainView()
    68 NotesMainView::~NotesMainView()
    74 {
    69 {
    75 	qDebug() << "notes: NotesMainView::~NotesMainView -->";
       
    76 
       
    77 	if (mDocLoader) {
    70 	if (mDocLoader) {
    78 		delete mDocLoader;
    71 		delete mDocLoader;
    79 		mDocLoader = 0;
    72 		mDocLoader = 0;
    80 	}
    73 	}
    81 
    74 
    82 	qDebug() << "notes: NotesMainView::~NotesMainView <--";
       
    83 }
    75 }
    84 
    76 
    85 /*!
    77 /*!
    86 	Called by the NotesViewManager after loading the view from the docml.
    78 	Called by the NotesViewManager after loading the view from the docml.
    87 	The initializaion/setup of the view is done here.
    79 	The initializaion/setup of the view is done here.
    90 	\param docLoader Pointer to NotesDocLoader object.
    82 	\param docLoader Pointer to NotesDocLoader object.
    91  */
    83  */
    92 void NotesMainView::setupView(
    84 void NotesMainView::setupView(
    93 		NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader)
    85 		NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader)
    94 {
    86 {
    95 	qDebug() << "notes: NotesMainView::setupView -->";
       
    96 
    87 
    97 	mDocLoader = docLoader;
    88 	mDocLoader = docLoader;
    98 	mAppControllerIf = &controllerIf;
    89 	mAppControllerIf = &controllerIf;
    99 	mNotesModel = mAppControllerIf->notesModel();
    90 	mNotesModel = mAppControllerIf->notesModel();
   100 	mAgendaUtil = mAppControllerIf->agendaUtil();
    91 	mAgendaUtil = mAppControllerIf->agendaUtil();
   188 			mAgendaUtil, SIGNAL(entryDeleted(ulong)),
   179 			mAgendaUtil, SIGNAL(entryDeleted(ulong)),
   189 			this,SLOT(updateSubTitle(ulong)));
   180 			this,SLOT(updateSubTitle(ulong)));
   190 	connect(
   181 	connect(
   191 			mAgendaUtil, SIGNAL(entryUpdated(ulong)),
   182 			mAgendaUtil, SIGNAL(entryUpdated(ulong)),
   192 			this, SLOT(updateSubTitle(ulong)));
   183 			this, SLOT(updateSubTitle(ulong)));
   193 	qDebug() << "notes: NotesMainView::setupView <--";
   184 
       
   185 	// Set the graphics size for the icons.
       
   186 	HbListViewItem *prototype = mListView->listItemPrototype();
       
   187 	prototype->setGraphicsSize(HbListViewItem::SmallIcon);
   194 }
   188 }
   195 
   189 
   196 /*!
   190 /*!
   197 	Slot which gets called when `+ New note' action is triggered from the view
   191 	Slot which gets called when `+ New note' action is triggered from the view
   198 	toolbar. This is responsible for launching the editor to create a new note.
   192 	toolbar. This is responsible for launching the editor to create a new note.
   199  */
   193  */
   200 void NotesMainView::createNewNote()
   194 void NotesMainView::createNewNote()
   201 {
   195 {
   202 	qDebug() << "notes: NotesMainView::createNewNote -->";
       
   203 
   196 
   204 	// Here we Display an editor to the use to enter text.
   197 	// Here we Display an editor to the use to enter text.
   205 	mNotesEditor = new NotesEditor(mAgendaUtil, this);
   198 	mNotesEditor = new NotesEditor(mAgendaUtil, this);
   206 	connect(
   199 	connect(
   207 			mNotesEditor, SIGNAL(editingCompleted(bool)),
   200 			mNotesEditor, SIGNAL(editingCompleted(bool)),
   208 			this, SLOT(handleEditingCompleted(bool)));
   201 			this, SLOT(handleEditingCompleted(bool)));
   209 	mNotesEditor->create(NotesEditor::CreateNote);
   202 	mNotesEditor->create(NotesEditor::CreateNote);
   210 
       
   211 	qDebug() << "notes: NotesMainView::createNewNote <--";
       
   212 }
   203 }
   213 
   204 
   214 /*!
   205 /*!
   215 	Handles the pressing of a list item in the view.
   206 	Handles the pressing of a list item in the view.
   216 
   207 
   219 	\param index Reference to the QModelIndex representing the view item.
   210 	\param index Reference to the QModelIndex representing the view item.
   220 	\sa HbAbstractViewItem
   211 	\sa HbAbstractViewItem
   221  */
   212  */
   222 void NotesMainView::handleItemReleased(const QModelIndex &index)
   213 void NotesMainView::handleItemReleased(const QModelIndex &index)
   223 {
   214 {
   224 	qDebug() << "notes: NotesMainView::handleItemReleased -->";
       
   225 
       
   226 	// Sanity check.
   215 	// Sanity check.
   227 	if (!index.isValid()) {
   216 	if (!index.isValid()) {
   228 		qDebug() << "notes: NotesMainView::handleItemReleased <--";
       
   229 
       
   230 		return;
   217 		return;
   231 	}
   218 	}
   232 
   219 
   233 	// First get the id of the note and get the corresponding information from
   220 	// First get the id of the note and get the corresponding information from
   234 	// agendautil.
   221 	// agendautil.
   235 	ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>();
   222 	ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>();
   236 
   223 
   237 	if (0 >= noteId) {
   224 	if (0 >= noteId) {
   238 		qDebug() << "notes: NotesMainView::handleItemReleased <--";
       
   239 
       
   240 		// Something wrong.
   225 		// Something wrong.
   241 		return;
   226 		return;
   242 	}
   227 	}
   243 
   228 
   244 	// Get the entry details.
   229 	// Get the entry details.
   245 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   230 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   246 	if (entry.isNull()) {
   231 	if (entry.isNull()) {
   247 		qDebug() << "notes: NotesMainView::handleItemReleased <--";
       
   248 
       
   249 		// Entry invalid.
   232 		// Entry invalid.
   250 		return;
   233 		return;
   251 	}
   234 	}
   252 
   235 
   253 	if(AgendaEntry::TypeTodo == entry.type()) {
   236 	if(AgendaEntry::TypeTodo == entry.type()) {
   254 		// Construct agenda event viewer.
   237 		// Construct agenda event viewer.
   255 		mAgendaEventViewer = new AgendaEventViewer(mAgendaUtil, this);
   238 		mAgendaEventViewer = new AgendaEventViewer(mAgendaUtil, this);
   256 
   239 
   257 		connect(
   240 		connect(
   258 				mAgendaEventViewer, SIGNAL(viewingCompleted(bool)),
   241 				mAgendaEventViewer, SIGNAL(viewingCompleted(const QDate)),
   259 				this, SLOT(handleViewingCompleted(bool)));
   242 				this, SLOT(handleViewingCompleted()));
   260 		// Launch agenda event viewer
   243 		// Launch agenda event viewer
   261 		mAgendaEventViewer->view(
   244 		mAgendaEventViewer->view(
   262 				entry, AgendaEventViewer::ActionEditDelete);
   245 				entry, AgendaEventViewer::ActionEditDelete);
   263 	}else if(AgendaEntry::TypeNote == entry.type()) {
   246 	}else if(AgendaEntry::TypeNote == entry.type()) {
   264 		// Construct notes editor.
   247 		// Construct notes editor.
   268 				this, SLOT(handleEditingCompleted(bool)));
   251 				this, SLOT(handleEditingCompleted(bool)));
   269 
   252 
   270 		// Launch the notes editor with the obtained info.
   253 		// Launch the notes editor with the obtained info.
   271 		mNotesEditor->edit(entry);
   254 		mNotesEditor->edit(entry);
   272 	}
   255 	}
   273 
       
   274 	qDebug() << "notes: NotesMainView::handleItemReleased <--";
       
   275 }
   256 }
   276 
   257 
   277 /*!
   258 /*!
   278 	Displays a list item specific context menu.
   259 	Displays a list item specific context menu.
   279 
   260 
   283 	\sa HbAbstractViewItem, HbListView, HbMenu.
   264 	\sa HbAbstractViewItem, HbListView, HbMenu.
   284  */
   265  */
   285 void NotesMainView::handleItemLongPressed(
   266 void NotesMainView::handleItemLongPressed(
   286 		HbAbstractViewItem *item, const QPointF &coords)
   267 		HbAbstractViewItem *item, const QPointF &coords)
   287 {
   268 {
   288 	qDebug() << "notes: NotesMainView::handleItemLongPressed -->";
       
   289 
       
   290 	mSelectedItem = item;
   269 	mSelectedItem = item;
   291 
   270 
   292 	ulong noteId = item->modelIndex().data(
   271 	ulong noteId = item->modelIndex().data(
   293 			NotesNamespace::IdRole).value<qulonglong>();
   272 			NotesNamespace::IdRole).value<qulonglong>();
   294 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   273 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   295 
   274 
   296 	// Display a context specific menu.
   275 	// Display a context specific menu.
   297 	HbMenu *contextMenu = new HbMenu();
   276 	HbMenu *contextMenu = new HbMenu();
       
   277 	mOpenAction =
       
   278 			contextMenu->addAction(hbTrId("txt_common_menu_open"));
       
   279 	connect(
       
   280 			mOpenAction, SIGNAL(triggered()),
       
   281 			this, SLOT(openNote()));
   298 
   282 
   299 	// Add actions to the context menu.
   283 	// Add actions to the context menu.
   300 	if (AgendaEntry::TypeTodo == entry.type()) {
   284 	if (AgendaEntry::TypeTodo == entry.type()) {
   301 		mEditTodoAction =
   285 		mEditTodoAction =
   302 				contextMenu->addAction(hbTrId("txt_common_menu_edit"));
   286 				contextMenu->addAction(hbTrId("txt_common_menu_edit"));
   327 			connect(
   311 			connect(
   328 					mMakeFavouriteAction, SIGNAL(triggered()),
   312 					mMakeFavouriteAction, SIGNAL(triggered()),
   329 					this, SLOT(markNoteAsFavourite()));
   313 					this, SLOT(markNoteAsFavourite()));
   330 		}
   314 		}
   331 
   315 
       
   316 		mMarkTodoAction =
       
   317 				contextMenu->addAction(
       
   318 						hbTrId("txt_notes_menu_make_it_as_todo_note"));
       
   319 		connect(
       
   320 				mMarkTodoAction, SIGNAL(triggered()),
       
   321 				this, SLOT(markNoteAsTodo()));
       
   322 
   332 	} else if (AgendaEntry::TypeTodo == entry.type()) {
   323 	} else if (AgendaEntry::TypeTodo == entry.type()) {
   333 		if (AgendaEntry::TodoNeedsAction == entry.status()) {
   324 		if (AgendaEntry::TodoNeedsAction == entry.status()) {
   334 			mTodoStatusAction = contextMenu->addAction(
   325 			mTodoStatusAction = contextMenu->addAction(
   335 					hbTrId("txt_notes_menu_mark_as_done"));
   326 					hbTrId("txt_notes_menu_mark_as_done"));
   336 
   327 
   349 	}
   340 	}
   350 
   341 
   351 	// Show the menu.
   342 	// Show the menu.
   352 	contextMenu->exec(coords);
   343 	contextMenu->exec(coords);
   353 
   344 
   354 	qDebug() << "notes: NotesMainView::handleItemLongPressed <--";
       
   355 }
   345 }
   356 
   346 
   357 /*!
   347 /*!
   358 	Slot to delete a selected note.
   348 	Slot to delete a selected note.
   359  */
   349  */
   360 void NotesMainView::deleteNote()
   350 void NotesMainView::deleteNote()
   361 {
   351 {
   362 	qDebug() << "notes: NotesMainView::deleteNote -->";
       
   363 
       
   364 	Q_ASSERT(mSelectedItem);
   352 	Q_ASSERT(mSelectedItem);
   365 
   353 
   366 	QModelIndex index = mSelectedItem->modelIndex();
   354 	QModelIndex index = mSelectedItem->modelIndex();
   367 	if (!index.isValid()) {
   355 	if (!index.isValid()) {
   368 		qDebug() << "notes: NotesMainView::deleteNote <--";
       
   369 
       
   370 		return;
   356 		return;
   371 	}
   357 	}
   372 	ulong noteId =
   358 	ulong noteId =
   373 			index.data(NotesNamespace::IdRole).value<qulonglong>();
   359 			index.data(NotesNamespace::IdRole).value<qulonglong>();
   374 	if (!noteId) {
   360 	if (!noteId) {
   375 		qDebug() << "notes: NotesMainView::deleteNote <--";
   361 
   376 
   362 		return;
   377 		return;
   363 	}
   378 	}
   364 
   379 
   365 	// Emit the signal.Deletion would happen in view manager.
   380 	// Delete the given note.
   366 	emit deleteEntry(noteId);
   381 	mAgendaUtil->deleteEntry(noteId);
       
   382 
   367 
   383 	mSelectedItem = 0;
   368 	mSelectedItem = 0;
   384 
       
   385 	qDebug() << "notes: NotesMainView::deleteNote <--";
       
   386 }
   369 }
   387 
   370 
   388 /*!
   371 /*!
   389 	Marks to-do entry as done or undone based on the completed value
   372 	Marks to-do entry as done or undone based on the completed value
   390 
   373 
   392 	\param status is true if to-do entry to be marked as done
   375 	\param status is true if to-do entry to be marked as done
   393 			is false if to-do entry to be marked as undone
   376 			is false if to-do entry to be marked as undone
   394  */
   377  */
   395 void NotesMainView::markTodoStatus()
   378 void NotesMainView::markTodoStatus()
   396 {
   379 {
   397 	qDebug() << "notes: NotesMainView::markTodoStatus -->";
       
   398 
       
   399 	ulong noteId = mSelectedItem->modelIndex().data(
   380 	ulong noteId = mSelectedItem->modelIndex().data(
   400 			NotesNamespace::IdRole).value<qulonglong>();
   381 			NotesNamespace::IdRole).value<qulonglong>();
   401 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   382 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   402 
   383 
   403 	QDateTime currentDateTime = QDateTime::currentDateTime();
   384 	QDateTime currentDateTime = QDateTime::currentDateTime();
   406 		mAgendaUtil->setCompleted(entry, true, currentDateTime);
   387 		mAgendaUtil->setCompleted(entry, true, currentDateTime);
   407 	} else if (AgendaEntry::TodoCompleted == entry.status()) {
   388 	} else if (AgendaEntry::TodoCompleted == entry.status()) {
   408 		mAgendaUtil->setCompleted(entry, false, currentDateTime);
   389 		mAgendaUtil->setCompleted(entry, false, currentDateTime);
   409 	}
   390 	}
   410 
   391 
   411 	qDebug() << "notes: NotesMainView::markTodoStatus <-- ";
       
   412 }
   392 }
   413 
   393 
   414 /*!
   394 /*!
   415 	Marks/unmarks the note as favourite.
   395 	Marks/unmarks the note as favourite.
   416  */
   396  */
   417 void NotesMainView::markNoteAsFavourite()
   397 void NotesMainView::markNoteAsFavourite()
   418 {
   398 {
   419 	qDebug() << "notes : NotesMainView::markNoteAsFavourite -->";
       
   420 
       
   421 	ulong noteId = mSelectedItem->modelIndex().data(
   399 	ulong noteId = mSelectedItem->modelIndex().data(
   422 				NotesNamespace::IdRole).value<qulonglong>();
   400 				NotesNamespace::IdRole).value<qulonglong>();
   423 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   401 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
   424 
   402 
   425 	if (entry.favourite()) {
   403 	if (entry.favourite()) {
   427 	} else {
   405 	} else {
   428 		entry.setFavourite(1);
   406 		entry.setFavourite(1);
   429 	}
   407 	}
   430 	mAgendaUtil->updateEntry(entry);
   408 	mAgendaUtil->updateEntry(entry);
   431 
   409 
   432 	qDebug() << "notes : NotesMainView::markNoteAsFavourite <--";
       
   433 }
   410 }
   434 
   411 
   435 /*!
   412 /*!
   436 	Slot to handle the signal editingCompleted by the notes editor.
   413 	Slot to handle the signal editingCompleted by the notes editor.
   437 
   414 
   439 
   416 
   440 	\sa NotesEditor.
   417 	\sa NotesEditor.
   441  */
   418  */
   442 void NotesMainView::handleEditingCompleted(bool status)
   419 void NotesMainView::handleEditingCompleted(bool status)
   443 {
   420 {
   444 	qDebug() << "notes: NotesMainView::handleEditingCompleted -->";
       
   445 
       
   446 	Q_UNUSED(status)
   421 	Q_UNUSED(status)
   447 
   422 
   448 	// Cleanup.
   423 	// Cleanup.
   449 	mNotesEditor->deleteLater();
   424 	mNotesEditor->deleteLater();
   450 
   425 
   451 	qDebug() << "notes: NotesMainView::handleEditingCompleted <--";
       
   452 }
   426 }
   453 
   427 
   454 /*!
   428 /*!
   455 	Displays the collections' view.
   429 	Displays the collections' view.
   456  */
   430  */
   457 void NotesMainView::displayCollectionView()
   431 void NotesMainView::displayCollectionView()
   458 {
   432 {
   459 	qDebug() << "notes: NotesMainView::displayCollectionView -->";
       
   460 
   433 
   461 	// Switch to collections view.
   434 	// Switch to collections view.
   462 	mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId);
   435 	mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId);
   463 
   436 
   464 	qDebug() << "notes: NotesMainView::displayCollectionView <--";
       
   465 }
   437 }
   466 
   438 
   467 /*!
   439 /*!
   468 	Slot where the list view is made to scroll to the QModelIndex index.
   440 	Slot where the list view is made to scroll to the QModelIndex index.
   469 
   441 
   470 	\param index QModelIndex to be scrolled to.
   442 	\param index QModelIndex to be scrolled to.
   471  */
   443  */
   472 void NotesMainView::scrollTo(QModelIndex index)
   444 void NotesMainView::scrollTo(QModelIndex index)
   473 {
   445 {
   474 	qDebug() << "notes: NotesMainView::scrollTo -->";
       
   475 
       
   476 	mListView->scrollTo(index, HbAbstractItemView::EnsureVisible);
   446 	mListView->scrollTo(index, HbAbstractItemView::EnsureVisible);
   477 
       
   478 	qDebug() << "notes: NotesMainView::scrollTo <--";
       
   479 }
   447 }
   480 
   448 
   481 /*!
   449 /*!
   482 	Slot to handle viewing Completed signal from agenda event viewer
   450 	Slot to handle viewing Completed signal from agenda event viewer
   483 
   451 
   484 	\param status Indicates the status of viewing
   452 	\param status Indicates the status of viewing
   485  */
   453  */
   486 void NotesMainView::handleViewingCompleted(bool status)
   454 void NotesMainView::handleViewingCompleted()
   487 {
   455 {
   488 	qDebug() << "notes: NotesMainView::handleViewingCompleted -->";
   456 
   489 
       
   490 	Q_UNUSED(status)
       
   491 
   457 
   492 	mAgendaEventViewer->deleteLater();
   458 	mAgendaEventViewer->deleteLater();
   493 
   459 
   494 	qDebug() << "notes: NotesMainView::handleViewingCompleted <--";
       
   495 }
   460 }
   496 
   461 
   497 /*!
   462 /*!
   498 	Slot to handle the case when the state of an action has changed.
   463 	Slot to handle the case when the state of an action has changed.
   499  */
   464  */
   500 void NotesMainView::handleActionStateChanged()
   465 void NotesMainView::handleActionStateChanged()
   501 {
   466 {
   502 	qDebug() << "notes: NotesMainView::handleActionStateChanged -->";
       
   503 
       
   504 	mAllNotesAction->setChecked(true);
   467 	mAllNotesAction->setChecked(true);
   505 
       
   506 	qDebug() << "notes: NotesMainView::handleActionStateChanged <--";
       
   507 }
   468 }
   508 
   469 
   509 /*!
   470 /*!
   510 	Launches the to-do editor to edit the to-do entry
   471 	Launches the to-do editor to edit the to-do entry
   511  */
   472  */
   512 
   473 
   513 void NotesMainView::editTodo()
   474 void NotesMainView::editTodo()
   514 {
   475 {
   515 	qDebug() << "notes: NotesMainView::editTodo -->";
       
   516 
   476 
   517 	// Get the selected list item index
   477 	// Get the selected list item index
   518 	QModelIndex index = mSelectedItem->modelIndex();
   478 	QModelIndex index = mSelectedItem->modelIndex();
   519 	if (!index.isValid()) {
   479 	if (!index.isValid()) {
   520 		qDebug() << "notes: NotesMainView::editTodo <--";
       
   521 		return;
   480 		return;
   522 	}
   481 	}
   523 	ulong todoId =
   482 	ulong todoId =
   524 			index.data(NotesNamespace::IdRole).value<qulonglong>();
   483 			index.data(NotesNamespace::IdRole).value<qulonglong>();
   525 	if (!todoId) {
   484 	if (!todoId) {
   526 		qDebug() << "notes: NotesMainView::editTodo <--";
       
   527 
   485 
   528 		return;
   486 		return;
   529 	}
   487 	}
   530 
   488 
   531 	// Construct notes editor.
   489 	// Construct notes editor.
   535 			this, SLOT(handleEditingCompleted(bool)));
   493 			this, SLOT(handleEditingCompleted(bool)));
   536 
   494 
   537 	// Launch the to-do editor with the obtained info.
   495 	// Launch the to-do editor with the obtained info.
   538 	mNotesEditor->edit(todoId);
   496 	mNotesEditor->edit(todoId);
   539 
   497 
   540 	qDebug() << "notes: NotesMainView::editTodo <--";
       
   541 }
   498 }
   542 
   499 
   543 /*!
   500 /*!
   544 	Handles the orientation changes.Updates the list
   501 	Handles the orientation changes.Updates the list
   545 	item when orientation is changed
   502 	item when orientation is changed
   550 {
   507 {
   551 	HbListViewItem *prototype = mListView->listItemPrototype();
   508 	HbListViewItem *prototype = mListView->listItemPrototype();
   552 
   509 
   553 	if (Qt::Horizontal == orientation) {
   510 	if (Qt::Horizontal == orientation) {
   554 		prototype->setStretchingStyle(HbListViewItem::StretchLandscape);
   511 		prototype->setStretchingStyle(HbListViewItem::StretchLandscape);
   555 
       
   556 		// Set the text in landscape mode
       
   557 		mAllNotesAction->setText(hbTrId("txt_notes_button_all"));
       
   558 		mViewCollectionAction->setText(hbTrId("txt_notes_button_collections"));
       
   559 		mAddNoteAction->setText(hbTrId("txt_notes_button_new_note"));
       
   560 	} else {
   512 	} else {
   561 		prototype->setStretchingStyle(HbListViewItem::NoStretching);
   513 		prototype->setStretchingStyle(HbListViewItem::NoStretching);
   562 
       
   563 		// Set empty text in portriat mode so that only icons are visible.
       
   564 		mAllNotesAction->setText("");
       
   565 		mViewCollectionAction->setText("");
       
   566 		mAddNoteAction->setText("");
       
   567 	}
   514 	}
   568 }
   515 }
   569 
   516 
   570 /*!
   517 /*!
   571 	Updates the sub heading text
   518 	Updates the sub heading text
   582 			| AgendaUtil::IncludeIncompletedTodos));
   529 			| AgendaUtil::IncludeIncompletedTodos));
   583 	int c= entries.count();
   530 	int c= entries.count();
   584 	mSubTitle->setHeading(
   531 	mSubTitle->setHeading(
   585 			hbTrId("txt_notes_subhead_ln_notes",entries.count()));
   532 			hbTrId("txt_notes_subhead_ln_notes",entries.count()));
   586 }
   533 }
       
   534 
       
   535 /*!
       
   536 	Slot to make a note as to-do.
       
   537  */
       
   538 void NotesMainView::markNoteAsTodo()
       
   539 {
       
   540 	Q_ASSERT(mSelectedItem);
       
   541 
       
   542 	QModelIndex index = mSelectedItem->modelIndex();
       
   543 	if (!index.isValid()) {
       
   544 		return;
       
   545 	}
       
   546 	ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong> ();
       
   547 	if (!noteId) {
       
   548 		return;
       
   549 	}
       
   550 	// Get the entry details.
       
   551 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
       
   552 
       
   553 	if (entry.isNull()) {
       
   554 		// Entry invalid.
       
   555 		return;
       
   556 	}
       
   557 
       
   558 	// Here change the type of modified note and destroy the noteeditor and
       
   559 	// construct the to-do editor.
       
   560 	entry.setType(AgendaEntry::TypeTodo);
       
   561 
       
   562 	QDateTime dueDateTime;
       
   563 	QDate currentDate(QDate::currentDate());
       
   564 	dueDateTime.setDate(
       
   565 			QDate(currentDate.year(),currentDate.month(),currentDate.day()+1));
       
   566 	dueDateTime.setTime(QTime::fromString("12:00 am", "hh:mm ap"));
       
   567 
       
   568 	entry.setStartAndEndTime(dueDateTime, dueDateTime);
       
   569 
       
   570 	entry.setSummary(entry.description().left(80));
       
   571 
       
   572 	if (80 > entry.description().length()) {
       
   573 		entry.setDescription("");
       
   574 	}
       
   575 
       
   576 	// Remove favourite if marked so.
       
   577 	entry.setFavourite(0);
       
   578 
       
   579 	// Set the status of the to-do.
       
   580 	entry.setStatus(AgendaEntry::TodoNeedsAction);
       
   581 
       
   582 	// First clone the todoEntry for the new type.
       
   583 	mAgendaUtil->cloneEntry(entry, AgendaEntry::TypeTodo);
       
   584 
       
   585 	// Delete the old entry.
       
   586 	mAgendaUtil->deleteEntry(entry.id());
       
   587 }
       
   588 
       
   589 
       
   590 /*
       
   591 	Opens the notes editor if selected item is note otherwise opens
       
   592 	to-do viewer if selected item is to-do event
       
   593  */
       
   594 void NotesMainView::openNote()
       
   595 {
       
   596 	ulong noteId = mSelectedItem->modelIndex().data(
       
   597 			NotesNamespace::IdRole).value<qulonglong>();
       
   598 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
       
   599 
       
   600 	if (AgendaEntry::TypeNote == entry.type()) {
       
   601 		// Construct notes editor.
       
   602 		mNotesEditor = new NotesEditor(mAgendaUtil, this);
       
   603 		connect(
       
   604 				mNotesEditor, SIGNAL(editingCompleted(bool)),
       
   605 				this, SLOT(handleEditingCompleted(bool)));
       
   606 
       
   607 		// Launch the notes editor with the obtained info.
       
   608 		mNotesEditor->edit(entry);
       
   609 	} else if (AgendaEntry::TypeTodo == entry.type()) {
       
   610 
       
   611 		// Construct agenda event viewer.
       
   612 		mAgendaEventViewer = new AgendaEventViewer(mAgendaUtil, this);
       
   613 
       
   614 		connect(
       
   615 				mAgendaEventViewer, SIGNAL(viewingCompleted(bool)),
       
   616 				this, SLOT(handleViewingCompleted(bool)));
       
   617 		// Launch agenda event viewer
       
   618 		mAgendaEventViewer->view(
       
   619 				entry, AgendaEventViewer::ActionEditDelete);
       
   620 	}
       
   621 }
   587 // End of file	--Don't remove this.
   622 // End of file	--Don't remove this.