diff -r fd30d51f876b -r a949c2543c15 notes/notesui/notesviews/src/notesfavoriteview.cpp --- a/notes/notesui/notesviews/src/notesfavoriteview.cpp Mon May 03 12:30:32 2010 +0300 +++ b/notes/notesui/notesviews/src/notesfavoriteview.cpp Fri May 14 15:51:09 2010 +0300 @@ -30,6 +30,7 @@ #include #include #include +#include // User includes #include "notesfavoriteview.h" @@ -56,7 +57,8 @@ NotesFavoriteView::NotesFavoriteView(QGraphicsWidget *parent) :HbView(parent), mSelectedItem(0), - mDeleteAction(0) + mDeleteAction(0), + mIsLongTop(false) { // Nothing yet. } @@ -176,35 +178,37 @@ */ void NotesFavoriteView::handleItemReleased(const QModelIndex &index) { - // Sanity check. - if (!index.isValid()) { - return; - } + if (!mIsLongTop) { + // Sanity check. + if (!index.isValid()) { + return; + } - // First get the id of the note and get the corresponding information from - // agendautil. - ulong noteId = index.data(NotesNamespace::IdRole).value(); + // First get the id of the note and get the corresponding information from + // agendautil. + ulong noteId = index.data(NotesNamespace::IdRole).value(); - if (0 >= noteId) { - // Something wrong. - return; - } + if (0 >= noteId) { + // Something wrong. + return; + } - // Get the entry details. - AgendaEntry entry = mAgendaUtil->fetchById(noteId); + // Get the entry details. + AgendaEntry entry = mAgendaUtil->fetchById(noteId); + + if (entry.isNull()) { - if (entry.isNull()) { + // Entry invalid. + return; + } - // Entry invalid. - return; + // Now launch the editor with the obtained info. + mNotesEditor = new NotesEditor(mAgendaUtil, this); + connect( + mNotesEditor, SIGNAL(editingCompleted(bool)), + this, SLOT(handleEditingCompleted(bool))); + mNotesEditor->edit(entry); } - - // Now launch the editor with the obtained info. - mNotesEditor = new NotesEditor(mAgendaUtil, this); - connect( - mNotesEditor, SIGNAL(editingCompleted(bool)), - this, SLOT(handleEditingCompleted(bool))); - mNotesEditor->edit(entry); } /*! @@ -219,6 +223,7 @@ HbAbstractViewItem *item, const QPointF &coords) { mSelectedItem = item; + mIsLongTop = true; // Get the entry of the selected item. ulong noteId = item->modelIndex().data( @@ -227,37 +232,28 @@ // Display a context specific menu. HbMenu *contextMenu = new HbMenu(); + connect( + contextMenu,SIGNAL(aboutToClose()), + this, SLOT(handleMenuClosed())); // Add actions to the context menu. mOpenAction = contextMenu->addAction(hbTrId("txt_common_menu_open")); - connect( - mOpenAction, SIGNAL(triggered()), - this, SLOT(openNote())); mDeleteAction = contextMenu->addAction(hbTrId("txt_common_menu_delete")); - connect( - mDeleteAction, SIGNAL(triggered()), - this, SLOT(deleteNote())); mRemoveFavoriteAction = contextMenu->addAction( hbTrId("txt_notes_menu_remove_from_favorites")); - connect( - mRemoveFavoriteAction, SIGNAL(triggered()), - this, SLOT(markNoteAsNotFavourite())); - mMarkTodoAction = contextMenu->addAction( hbTrId("txt_notes_menu_make_it_as_todo_note")); - connect( - mMarkTodoAction, SIGNAL(triggered()), - this, SLOT(markNoteAsTodo())); // Show the menu. - contextMenu->exec(coords); + contextMenu->open(this, SLOT(selectedMenuAction(HbAction*))); + contextMenu->setPreferredPos(coords); } /*! @@ -352,6 +348,14 @@ // Delete the old entry. mAgendaUtil->deleteEntry(entry.id()); + + // Show the soft notification. + HbNotificationDialog *notificationDialog = new HbNotificationDialog(); + notificationDialog->setTimeout( + HbNotificationDialog::ConfirmationNoteTimeout); + notificationDialog->setTitle( + hbTrId("txt_notes_dpopinfo_note_moved_to_todos")); + notificationDialog->show(); } /*! @@ -430,5 +434,29 @@ // Launch the notes editor with the obtained info. mNotesEditor->edit(entry); } + +/* + Slot to handle the context menu actions. + */ +void NotesFavoriteView::selectedMenuAction(HbAction *action) +{ + if(action == mOpenAction) { + openNote(); + } else if (action == mDeleteAction) { + deleteNote(); + } else if (action ==mRemoveFavoriteAction){ + markNoteAsNotFavourite(); + } else if (action == mMarkTodoAction) { + markNoteAsTodo(); + } +} + +/*! + Slot to handle the context menu closed. + */ +void NotesFavoriteView::handleMenuClosed() +{ + mIsLongTop = false; +} // End of file --Don't remove this.