notes/notesui/notesviews/src/notestodoview.cpp
changeset 23 fd30d51f876b
parent 18 c198609911f9
child 26 a949c2543c15
child 45 b6db4fd4947b
--- a/notes/notesui/notesviews/src/notestodoview.cpp	Fri Apr 16 14:57:40 2010 +0300
+++ b/notes/notesui/notesviews/src/notestodoview.cpp	Mon May 03 12:30:32 2010 +0300
@@ -17,7 +17,6 @@
 */
 
 // System includes
-#include <QDebug>
 #include <QDateTime>
 #include <HbListView>
 #include <HbListWidget>
@@ -60,11 +59,7 @@
  mSelectedItem(0),
  mDeleteAction(0)
 {
-	qDebug() << "notes: NotesTodoView::NotesTodoView -->";
-
 	// Nothing yet.
-
-	qDebug() << "notes: NotesTodoView::NotesTodoView <--";
 }
 
 /*!
@@ -72,14 +67,10 @@
  */
 NotesTodoView::~NotesTodoView()
 {
-	qDebug() << "notes: NotesTodoView::~NotesTodoView -->";
-
 	if (mDocLoader) {
 	    delete mDocLoader;
 	    mDocLoader = 0;
     }
-
-	qDebug() << "notes: NotesTodoView::~NotesTodoView <--";
 }
 
 /*!
@@ -92,8 +83,6 @@
 void NotesTodoView::setupView(
 		NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader)
 {
-	qDebug() << "notes: NotesMainView::setupView -->";
-
 	mDocLoader = docLoader;
 	mAppControllerIf = &controllerIf;
 	mNotesModel = mAppControllerIf->notesModel();
@@ -173,7 +162,9 @@
 			mAgendaUtil, SIGNAL(entryUpdated(ulong)),
 			this, SLOT(updateSubTitle(ulong)));
 
-	qDebug() << "notes: NotesMainView::setupView <--";
+	// Set the graphics size for the icons.
+	HbListViewItem *prototype = mListView->listItemPrototype();
+	prototype->setGraphicsSize(HbListViewItem::SmallIcon);
 }
 
 /*!
@@ -181,16 +172,12 @@
  */
 void NotesTodoView::createNewTodo()
 {
-	qDebug() << "notes: NotesTodoView::createNewTodo -->";
-
 	mNotesEditor = new NotesEditor(mAgendaUtil, this);
 	connect(
 			mNotesEditor, SIGNAL(editingCompleted(bool)),
 			this, SLOT(handleEditingCompleted(bool)));
 
 	mNotesEditor->create(NotesEditor::CreateTodo);
-
-	qDebug() << "notes: NotesTodoView::createNewTodo -->";
 }
 
 /*!
@@ -203,12 +190,8 @@
  */
 void NotesTodoView::handleItemReleased(const QModelIndex &index)
 {
-	qDebug() << "notes: NotesTodoView::handleItemReleased -->";
-
 	// Sanity check.
 	if (!index.isValid()) {
-		qDebug() << "notes: NotesTodoView::handleItemReleased <--";
-
 		return;
 	}
 
@@ -217,8 +200,6 @@
 	ulong toDoId = index.data(NotesNamespace::IdRole).value<qulonglong>();
 
 	if (0 >= toDoId) {
-		qDebug() << "notes: NotesTodoView::handleItemReleased <--";
-
 		// Something wrong.
 		return;
 	}
@@ -227,12 +208,10 @@
 	mAgendaEventViewer = new AgendaEventViewer(mAgendaUtil, this);
 
 	connect(
-			mAgendaEventViewer, SIGNAL(viewingCompleted(bool)),
+			mAgendaEventViewer, SIGNAL(viewingCompleted(const QDate)),
 			this, SLOT(handleViewingCompleted()));
 	// Launch agenda event viewer
 	mAgendaEventViewer->view(toDoId, AgendaEventViewer::ActionEditDelete);
-
-	qDebug() << "notes: NotesTodoView::handleItemReleased <--";
 }
 
 /*!
@@ -246,8 +225,6 @@
 void NotesTodoView::handleItemLongPressed(
 		HbAbstractViewItem *item, const QPointF &coords)
 {
-	qDebug() << "notes: NotesTodoView::handleItemLongPressed -->";
-
 	mSelectedItem = item;
 
 	// Get the entry of the selected item.
@@ -259,13 +236,18 @@
 	HbMenu *contextMenu = new HbMenu();
 
 	// Add actions to the context menu.
+	mOpenAction =
+			contextMenu->addAction(hbTrId("txt_common_menu_open"));
+	connect(
+			mOpenAction, SIGNAL(triggered()),
+			this, SLOT(openTodo()));
+
 	mEditAction = contextMenu->addAction(
 			hbTrId("txt_common_menu_edit"));
 	connect(
 			mEditAction, SIGNAL(triggered()),
 			this, SLOT(editTodo()));
 
-
 	mDeleteAction = contextMenu->addAction(
 			hbTrId("txt_common_menu_delete"));
 	connect(
@@ -292,8 +274,6 @@
 
 	// Show the menu.
 	contextMenu->exec(coords);
-
-	qDebug() << "notes: NotesTodoView::handleItemLongPressed <--";
 }
 
 /*!
@@ -301,30 +281,22 @@
  */
 void NotesTodoView::deleteTodo()
 {
-	qDebug() << "notes: NotesTodoView::deleteTodo -->";
-
 	Q_ASSERT(mSelectedItem);
 
 	QModelIndex index = mSelectedItem->modelIndex();
 	if (!index.isValid()) {
-		qDebug() << "notes: NotesTodoView::deleteTodo <--";
-
 		return;
 	}
 	ulong entryId =
 			index.data(NotesNamespace::IdRole).value<qulonglong>();
 	if (!entryId) {
-		qDebug() << "notes: NotesTodoView::deleteTodo <--";
-
 		return;
 	}
 
-	// Delete the given note.
-	mAgendaUtil->deleteEntry(entryId);
+	// Emit the signal. Delete would be handled in view manager.
+	emit deleteEntry(entryId);
 
 	mSelectedItem = 0;
-
-	qDebug() << "notes: NotesTodoView::deleteTodo <--";
 }
 
 /*!
@@ -332,8 +304,6 @@
  */
 void NotesTodoView::markTodoStatus()
 {
-	qDebug() << "notes: NotesTodoView::markTodoStatus -->";
-
 	ulong entryId = mSelectedItem->modelIndex().data(
 			NotesNamespace::IdRole).value<qulonglong>();
 	AgendaEntry entry = mAgendaUtil->fetchById(entryId);
@@ -345,8 +315,6 @@
 	} else if (AgendaEntry::TodoCompleted == entry.status()) {
 		mAgendaUtil->setCompleted(entry, false, currentDateTime);
 	}
-
-	qDebug() << "notes: NotesTodoView::markTodoStatus <-- ";
 }
 
 /*!
@@ -354,14 +322,10 @@
  */
 void NotesTodoView::editTodo()
 {
-	qDebug() << "notes: NotesTodoView::editTodo -->";
-
 	QModelIndex index = mSelectedItem->modelIndex();
 
 	// Sanity check.
 	if (!index.isValid()) {
-		qDebug() << "notes: NotesTodoView::editTodo <--";
-
 		return;
 	}
 
@@ -370,8 +334,6 @@
 	ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>();
 
 	if (0 >= noteId) {
-		qDebug() << "notes: NotesTodoView::editTodo <--";
-
 		// Something wrong.
 		return;
 	}
@@ -380,8 +342,6 @@
 	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
 
 	if (entry.isNull()) {
-		qDebug() << "notes: NotesTodoView::editTodo <--";
-
 		// Entry invalid.
 		return;
 	}
@@ -392,8 +352,6 @@
 			mNotesEditor, SIGNAL(editingCompleted(bool)),
 			this, SLOT(handleEditingCompleted(bool)));
 	mNotesEditor->edit(entry);
-
-	qDebug() << "notes: NotesTodoView::editTodo <--";
 }
 
 /*!
@@ -405,14 +363,10 @@
  */
 void NotesTodoView::handleEditingCompleted(bool status)
 {
-	qDebug() << "notes: NotesMainView::handleEditingCompleted -->";
-
 	Q_UNUSED(status)
 
 	// Cleanup.
 	mNotesEditor->deleteLater();
-
-	qDebug() << "notes: NotesMainView::handleEditingCompleted <--";
 }
 
 /*!
@@ -420,12 +374,8 @@
  */
 void NotesTodoView::displayCollectionView()
 {
-	qDebug() << "notes: NotesTodoView::displayCollectionView -->";
-
 	// Switch to collections view.
 	mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId);
-
-	qDebug() << "notes: NotesTodoView::displayCollectionView <--";
 }
 
 /*!
@@ -433,12 +383,8 @@
  */
 void NotesTodoView::displayAllNotesView()
 {
-	qDebug() << "notes: NotesTodoView::displayAllNotesView -->";
-
 	// Switch to collections view.
 	mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId);
-
-	qDebug() << "notes: NotesTodoView::displayAllNotesView <--";
 }
 
 /*!
@@ -446,26 +392,17 @@
  */
 void NotesTodoView::handleEditingCompleted()
 {
-	qDebug() <<"notes: NotesTodoView::handleEditingCompleted -->";
-
 	// Cleanup.
 	mNotesEditor->deleteLater();
-
-	qDebug() <<"notes: NotesTodoView::handleEditingCompleted <--";
 }
 
 /*!
 	Slot to handle signal handleViewingompleted by the agenda event viewer
  */
-void NotesTodoView::handleViewingCompleted(bool status)
+void NotesTodoView::handleViewingCompleted()
 {
-	qDebug() <<"notes: NotesTodoView::handleEditingCompleted -->";
-
-	Q_UNUSED(status)
 	// Cleanup.
 	mAgendaEventViewer->deleteLater();
-
-	qDebug() <<"notes: NotesTodoView::handleEditingCompleted <--";
 }
 
 /*!
@@ -473,11 +410,7 @@
  */
 void NotesTodoView::handleActionStateChanged()
 {
-	qDebug() << "notes: NotesTodoView::handleActionStateChanged -->";
-
 	mAllNotesAction->setChecked(true);
-
-	qDebug() << "notes: NotesTodoView::handleActionStateChanged <--";
 }
 
 /*!
@@ -492,18 +425,8 @@
 
 	if (Qt::Horizontal == orientation) {
 		prototype->setStretchingStyle(HbListViewItem::StretchLandscape);
-
-		// Set the text in landscape mode
-		mAllNotesAction->setText(hbTrId("txt_notes_button_all"));
-		mViewCollectionAction->setText(hbTrId("txt_notes_button_collections"));
-		mAddTodoAction->setText(hbTrId("txt_notes_button_new_todo"));
 	} else {
 		prototype->setStretchingStyle(HbListViewItem::NoStretching);
-
-		// Set empty text in portriat mode so that only icons are visible.
-		mAllNotesAction->setText("");
-		mViewCollectionAction->setText("");
-		mAddTodoAction->setText("");
 	}
 }
 
@@ -521,4 +444,25 @@
 			hbTrId("txt_notes_subhead_todos_ln_pending",entries.count()));
 }
 
+/*
+	Opens the to-do viewer to view the to-do.
+ */
+void NotesTodoView::openTodo()
+{
+	ulong noteId = mSelectedItem->modelIndex().data(
+			NotesNamespace::IdRole).value<qulonglong>();
+	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
+
+	// Construct agenda event viewer.
+	mAgendaEventViewer = new AgendaEventViewer(mAgendaUtil, this);
+
+	connect(
+			mAgendaEventViewer, SIGNAL(viewingCompleted(bool)),
+			this, SLOT(handleViewingCompleted(bool)));
+
+	// Launch agenda event viewer
+	mAgendaEventViewer->view(
+			entry, AgendaEventViewer::ActionEditDelete);
+}
+
 // End of file	--Don't remove this.