diff -r fd30d51f876b -r b6db4fd4947b 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 Mon Jun 28 15:22:02 2010 +0530 @@ -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. } @@ -116,6 +118,10 @@ this, SLOT(handleItemLongPressed(HbAbstractViewItem *, const QPointF &))); + // Get the empty list label. + mEmptyListLabel = static_cast ( + mDocLoader->findWidget("emptyListLabel")); + // Get the toolbar/menu actions. mAddNoteAction = static_cast ( mDocLoader->findObject("newNoteAction")); @@ -131,8 +137,7 @@ mViewCollectionAction = static_cast ( mDocLoader->findObject("displayCollectionsAction")); - mViewCollectionAction->setCheckable(true); - mViewCollectionAction->setChecked(true); + connect( mViewCollectionAction, SIGNAL(changed()), this, SLOT(handleActionStateChanged())); @@ -147,11 +152,29 @@ window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(handleOrientationChanged(Qt::Orientation))); + connect( + mAgendaUtil, SIGNAL(entryAdded(ulong)), + this,SLOT(updateView(ulong))); + connect( + mAgendaUtil, SIGNAL(entryDeleted(ulong)), + this,SLOT(updateView(ulong))); + connect( + mAgendaUtil, SIGNAL(entryUpdated(ulong)), + this, SLOT(updateView(ulong))); + // Set the graphics size for the icons. HbListViewItem *prototype = mListView->listItemPrototype(); prototype->setGraphicsSize(HbListViewItem::SmallIcon); } +/* + Updates the favorite view either to show notes or emptyListLabel. + */ +void NotesFavoriteView::updateFavoriteView() +{ + updateView(); +} + /*! Slot which gets called when `+ New note' action is triggered from the view toolbar. This is responsible for launching the editor to create a new note. @@ -176,35 +199,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 +244,7 @@ HbAbstractViewItem *item, const QPointF &coords) { mSelectedItem = item; + mIsLongTop = true; // Get the entry of the selected item. ulong noteId = item->modelIndex().data( @@ -227,37 +253,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 +369,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 +455,47 @@ // 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; +} + +/*! + Handles the visibility of empty list label. + */ +void NotesFavoriteView::updateView(ulong id) +{ + Q_UNUSED(id) + + // Get the numbers of favorite notes. + if (0 >= mListView->model()->rowCount()) { + mEmptyListLabel->show(); + mListView->hide(); + } else { + mEmptyListLabel->hide(); + mListView->show(); + } +} + // End of file --Don't remove this.