174 \param index Reference to the QModelIndex representing the view item. |
176 \param index Reference to the QModelIndex representing the view item. |
175 \sa HbAbstractViewItem |
177 \sa HbAbstractViewItem |
176 */ |
178 */ |
177 void NotesFavoriteView::handleItemReleased(const QModelIndex &index) |
179 void NotesFavoriteView::handleItemReleased(const QModelIndex &index) |
178 { |
180 { |
179 // Sanity check. |
181 if (!mIsLongTop) { |
180 if (!index.isValid()) { |
182 // Sanity check. |
181 return; |
183 if (!index.isValid()) { |
182 } |
184 return; |
183 |
185 } |
184 // First get the id of the note and get the corresponding information from |
186 |
185 // agendautil. |
187 // First get the id of the note and get the corresponding information from |
186 ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>(); |
188 // agendautil. |
187 |
189 ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>(); |
188 if (0 >= noteId) { |
190 |
189 // Something wrong. |
191 if (0 >= noteId) { |
190 return; |
192 // Something wrong. |
191 } |
193 return; |
192 |
194 } |
193 // Get the entry details. |
195 |
194 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
196 // Get the entry details. |
195 |
197 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
196 if (entry.isNull()) { |
198 |
197 |
199 if (entry.isNull()) { |
198 // Entry invalid. |
200 |
199 return; |
201 // Entry invalid. |
200 } |
202 return; |
201 |
203 } |
202 // Now launch the editor with the obtained info. |
204 |
203 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
205 // Now launch the editor with the obtained info. |
204 connect( |
206 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
205 mNotesEditor, SIGNAL(editingCompleted(bool)), |
207 connect( |
206 this, SLOT(handleEditingCompleted(bool))); |
208 mNotesEditor, SIGNAL(editingCompleted(bool)), |
207 mNotesEditor->edit(entry); |
209 this, SLOT(handleEditingCompleted(bool))); |
|
210 mNotesEditor->edit(entry); |
|
211 } |
208 } |
212 } |
209 |
213 |
210 /*! |
214 /*! |
211 Displays a list item specific context menu. |
215 Displays a list item specific context menu. |
212 |
216 |
217 */ |
221 */ |
218 void NotesFavoriteView::handleItemLongPressed( |
222 void NotesFavoriteView::handleItemLongPressed( |
219 HbAbstractViewItem *item, const QPointF &coords) |
223 HbAbstractViewItem *item, const QPointF &coords) |
220 { |
224 { |
221 mSelectedItem = item; |
225 mSelectedItem = item; |
|
226 mIsLongTop = true; |
222 |
227 |
223 // Get the entry of the selected item. |
228 // Get the entry of the selected item. |
224 ulong noteId = item->modelIndex().data( |
229 ulong noteId = item->modelIndex().data( |
225 NotesNamespace::IdRole).value<qulonglong>(); |
230 NotesNamespace::IdRole).value<qulonglong>(); |
226 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
231 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
227 |
232 |
228 // Display a context specific menu. |
233 // Display a context specific menu. |
229 HbMenu *contextMenu = new HbMenu(); |
234 HbMenu *contextMenu = new HbMenu(); |
|
235 connect( |
|
236 contextMenu,SIGNAL(aboutToClose()), |
|
237 this, SLOT(handleMenuClosed())); |
230 |
238 |
231 // Add actions to the context menu. |
239 // Add actions to the context menu. |
232 mOpenAction = |
240 mOpenAction = |
233 contextMenu->addAction(hbTrId("txt_common_menu_open")); |
241 contextMenu->addAction(hbTrId("txt_common_menu_open")); |
234 connect( |
|
235 mOpenAction, SIGNAL(triggered()), |
|
236 this, SLOT(openNote())); |
|
237 |
242 |
238 mDeleteAction = |
243 mDeleteAction = |
239 contextMenu->addAction(hbTrId("txt_common_menu_delete")); |
244 contextMenu->addAction(hbTrId("txt_common_menu_delete")); |
240 connect( |
|
241 mDeleteAction, SIGNAL(triggered()), |
|
242 this, SLOT(deleteNote())); |
|
243 |
245 |
244 mRemoveFavoriteAction = |
246 mRemoveFavoriteAction = |
245 contextMenu->addAction( |
247 contextMenu->addAction( |
246 hbTrId("txt_notes_menu_remove_from_favorites")); |
248 hbTrId("txt_notes_menu_remove_from_favorites")); |
247 |
249 |
248 connect( |
|
249 mRemoveFavoriteAction, SIGNAL(triggered()), |
|
250 this, SLOT(markNoteAsNotFavourite())); |
|
251 |
|
252 mMarkTodoAction = |
250 mMarkTodoAction = |
253 contextMenu->addAction( |
251 contextMenu->addAction( |
254 hbTrId("txt_notes_menu_make_it_as_todo_note")); |
252 hbTrId("txt_notes_menu_make_it_as_todo_note")); |
255 connect( |
|
256 mMarkTodoAction, SIGNAL(triggered()), |
|
257 this, SLOT(markNoteAsTodo())); |
|
258 |
253 |
259 // Show the menu. |
254 // Show the menu. |
260 contextMenu->exec(coords); |
255 contextMenu->open(this, SLOT(selectedMenuAction(HbAction*))); |
|
256 contextMenu->setPreferredPos(coords); |
261 } |
257 } |
262 |
258 |
263 /*! |
259 /*! |
264 Deletes the note. |
260 Deletes the note. |
265 */ |
261 */ |
350 // First clone the todoEntry for the new type. |
346 // First clone the todoEntry for the new type. |
351 mAgendaUtil->cloneEntry(entry, AgendaEntry::TypeTodo); |
347 mAgendaUtil->cloneEntry(entry, AgendaEntry::TypeTodo); |
352 |
348 |
353 // Delete the old entry. |
349 // Delete the old entry. |
354 mAgendaUtil->deleteEntry(entry.id()); |
350 mAgendaUtil->deleteEntry(entry.id()); |
|
351 |
|
352 // Show the soft notification. |
|
353 HbNotificationDialog *notificationDialog = new HbNotificationDialog(); |
|
354 notificationDialog->setTimeout( |
|
355 HbNotificationDialog::ConfirmationNoteTimeout); |
|
356 notificationDialog->setTitle( |
|
357 hbTrId("txt_notes_dpopinfo_note_moved_to_todos")); |
|
358 notificationDialog->show(); |
355 } |
359 } |
356 |
360 |
357 /*! |
361 /*! |
358 Slot to handle the signal editingCompleted by the notes editor. |
362 Slot to handle the signal editingCompleted by the notes editor. |
359 |
363 |
428 this, SLOT(handleEditingCompleted(bool))); |
432 this, SLOT(handleEditingCompleted(bool))); |
429 |
433 |
430 // Launch the notes editor with the obtained info. |
434 // Launch the notes editor with the obtained info. |
431 mNotesEditor->edit(entry); |
435 mNotesEditor->edit(entry); |
432 } |
436 } |
|
437 |
|
438 /* |
|
439 Slot to handle the context menu actions. |
|
440 */ |
|
441 void NotesFavoriteView::selectedMenuAction(HbAction *action) |
|
442 { |
|
443 if(action == mOpenAction) { |
|
444 openNote(); |
|
445 } else if (action == mDeleteAction) { |
|
446 deleteNote(); |
|
447 } else if (action ==mRemoveFavoriteAction){ |
|
448 markNoteAsNotFavourite(); |
|
449 } else if (action == mMarkTodoAction) { |
|
450 markNoteAsTodo(); |
|
451 } |
|
452 } |
|
453 |
|
454 /*! |
|
455 Slot to handle the context menu closed. |
|
456 */ |
|
457 void NotesFavoriteView::handleMenuClosed() |
|
458 { |
|
459 mIsLongTop = false; |
|
460 } |
433 // End of file --Don't remove this. |
461 // End of file --Don't remove this. |
434 |
462 |