28 #include <HbInstance> |
28 #include <HbInstance> |
29 #include <HbNotificationDialog> |
29 #include <HbNotificationDialog> |
30 #include <HbLabel> |
30 #include <HbLabel> |
31 |
31 |
32 // User includes |
32 // User includes |
|
33 #include <agendautil.h> |
33 #include "notesnoteview.h" |
34 #include "notesnoteview.h" |
34 #include "notescommon.h" |
35 #include "notescommon.h" |
35 #include "notesdocloader.h" |
36 #include "notesdocloader.h" |
36 #include "notesmodel.h" |
37 #include "notesmodel.h" |
37 #include "notessortfilterproxymodel.h" |
38 #include "notessortfilterproxymodel.h" |
38 #include "noteseditor.h" |
39 #include "noteseditor.h" |
39 #include "agendautil.h" |
40 #include "OstTraceDefinitions.h" |
|
41 #ifdef OST_TRACE_COMPILER_IN_USE |
|
42 #include "notesnoteviewTraces.h" |
|
43 #endif |
|
44 |
40 |
45 |
41 |
46 |
42 /*! |
47 /*! |
43 \class NotesNoteView |
48 \class NotesNoteView |
44 \brief The Note view of the notes application. Responsible for displaying |
49 \brief The Note view of the notes application. Responsible for displaying |
80 \param docLoader Pointer to NotesDocLoader object. |
89 \param docLoader Pointer to NotesDocLoader object. |
81 */ |
90 */ |
82 void NotesNoteView::setupView( |
91 void NotesNoteView::setupView( |
83 NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader) |
92 NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader) |
84 { |
93 { |
|
94 OstTraceFunctionEntry0( NOTESNOTEVIEW_SETUPVIEW_ENTRY ); |
85 mDocLoader = docLoader; |
95 mDocLoader = docLoader; |
86 mAppControllerIf = &controllerIf; |
96 mAppControllerIf = &controllerIf; |
87 mNotesModel = mAppControllerIf->notesModel(); |
97 mNotesModel = mAppControllerIf->notesModel(); |
88 mAgendaUtil = mAppControllerIf->agendaUtil(); |
98 mAgendaUtil = mAppControllerIf->agendaUtil(); |
89 |
99 |
162 |
172 |
163 |
173 |
164 // Set the graphics size for the icons. |
174 // Set the graphics size for the icons. |
165 HbListViewItem *prototype = mListView->listItemPrototype(); |
175 HbListViewItem *prototype = mListView->listItemPrototype(); |
166 prototype->setGraphicsSize(HbListViewItem::SmallIcon); |
176 prototype->setGraphicsSize(HbListViewItem::SmallIcon); |
|
177 OstTraceFunctionExit0( NOTESNOTEVIEW_SETUPVIEW_EXIT ); |
167 } |
178 } |
168 |
179 |
169 /* |
180 /* |
170 Updates the note view either to show notes or emptyListLabel. |
181 Updates the note view either to show notes or emptyListLabel. |
171 */ |
182 */ |
172 void NotesNoteView::updateNoteView() |
183 void NotesNoteView::updateNoteView() |
173 { |
184 { |
|
185 OstTraceFunctionEntry0( NOTESNOTEVIEW_UPDATENOTEVIEW_ENTRY ); |
174 updateView(); |
186 updateView(); |
|
187 OstTraceFunctionExit0( NOTESNOTEVIEW_UPDATENOTEVIEW_EXIT ); |
175 } |
188 } |
176 |
189 |
177 /*! |
190 /*! |
178 Opens the note editor to create a new note. |
191 Opens the note editor to create a new note. |
179 */ |
192 */ |
180 void NotesNoteView::createNewNote() |
193 void NotesNoteView::createNewNote() |
181 { |
194 { |
|
195 OstTraceFunctionEntry0( NOTESNOTEVIEW_CREATENEWNOTE_ENTRY ); |
182 // Here we Display an editor to the use to enter text. |
196 // Here we Display an editor to the use to enter text. |
183 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
197 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
184 connect( |
198 connect( |
185 mNotesEditor, SIGNAL(editingCompleted(bool)), |
199 mNotesEditor, SIGNAL(editingCompleted(bool)), |
186 this, SLOT(handleEditingCompleted(bool))); |
200 this, SLOT(handleEditingCompleted(bool))); |
187 mNotesEditor->create(NotesEditor::CreateNote); |
201 mNotesEditor->create(NotesEditor::CreateNote); |
|
202 OstTraceFunctionExit0( NOTESNOTEVIEW_CREATENEWNOTE_EXIT ); |
188 } |
203 } |
189 |
204 |
190 /*! |
205 /*! |
191 Handles the pressing of a list item in the view. |
206 Handles the pressing of a list item in the view. |
192 |
207 |
195 \param index Reference to the QModelIndex representing the view item. |
210 \param index Reference to the QModelIndex representing the view item. |
196 \sa HbAbstractViewItem |
211 \sa HbAbstractViewItem |
197 */ |
212 */ |
198 void NotesNoteView::handleItemReleased(const QModelIndex &index) |
213 void NotesNoteView::handleItemReleased(const QModelIndex &index) |
199 { |
214 { |
|
215 OstTraceFunctionEntry0( NOTESNOTEVIEW_HANDLEITEMRELEASED_ENTRY ); |
200 if(!mIsLongTop) { |
216 if(!mIsLongTop) { |
201 // Sanity check. |
217 // Sanity check. |
202 if (!index.isValid()) { |
218 if (!index.isValid()) { |
|
219 OstTraceFunctionExit0( NOTESNOTEVIEW_HANDLEITEMRELEASED_EXIT ); |
203 return; |
220 return; |
204 } |
221 } |
205 |
222 |
206 // First get the id of the note and get the corresponding information from |
223 // First get the id of the note and get the corresponding information |
207 // agendautil. |
224 // from agendautil. |
208 ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>(); |
225 ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>(); |
209 |
226 |
210 if (0 >= noteId) { |
227 if (0 >= noteId) { |
211 // Something wrong. |
228 // Something wrong. |
|
229 OstTraceFunctionExit0( DUP1_NOTESNOTEVIEW_HANDLEITEMRELEASED_EXIT ); |
212 return; |
230 return; |
213 } |
231 } |
214 |
232 |
215 // Get the entry details. |
233 // Get the entry details. |
216 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
234 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
217 |
235 |
218 if (entry.isNull()) { |
236 if (entry.isNull()) { |
219 // Entry invalid. |
237 // Entry invalid. |
|
238 OstTraceFunctionExit0( DUP2_NOTESNOTEVIEW_HANDLEITEMRELEASED_EXIT ); |
220 return; |
239 return; |
221 } |
240 } |
222 |
241 |
223 // Now launch the editor with the obtained info. |
242 // Now launch the editor with the obtained info. |
224 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
243 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
225 connect( |
244 connect( |
226 mNotesEditor, SIGNAL(editingCompleted(bool)), |
245 mNotesEditor, SIGNAL(editingCompleted(bool)), |
227 this, SLOT(handleEditingCompleted(bool))); |
246 this, SLOT(handleEditingCompleted(bool))); |
228 mNotesEditor->edit(entry); |
247 mNotesEditor->edit(entry); |
229 } |
248 } |
|
249 OstTraceFunctionExit0( DUP3_NOTESNOTEVIEW_HANDLEITEMRELEASED_EXIT ); |
230 } |
250 } |
231 |
251 |
232 /*! |
252 /*! |
233 Displays a list item specific context menu. |
253 Displays a list item specific context menu. |
234 |
254 |
238 \sa HbAbstractViewItem, HbListView, HbMenu. |
258 \sa HbAbstractViewItem, HbListView, HbMenu. |
239 */ |
259 */ |
240 void NotesNoteView::handleItemLongPressed( |
260 void NotesNoteView::handleItemLongPressed( |
241 HbAbstractViewItem *item, const QPointF &coords) |
261 HbAbstractViewItem *item, const QPointF &coords) |
242 { |
262 { |
|
263 OstTraceFunctionEntry0( NOTESNOTEVIEW_HANDLEITEMLONGPRESSED_ENTRY ); |
243 mSelectedItem = item; |
264 mSelectedItem = item; |
244 mIsLongTop = true; |
265 mIsLongTop = true; |
245 |
266 |
246 ulong noteId = item->modelIndex().data( |
267 ulong noteId = item->modelIndex().data( |
247 NotesNamespace::IdRole).value<qulonglong>(); |
268 NotesNamespace::IdRole).value<qulonglong>(); |
273 } |
294 } |
274 |
295 |
275 // Show the menu. |
296 // Show the menu. |
276 contextMenu->open(this, SLOT(selectedMenuAction(HbAction*))); |
297 contextMenu->open(this, SLOT(selectedMenuAction(HbAction*))); |
277 contextMenu->setPreferredPos(coords); |
298 contextMenu->setPreferredPos(coords); |
|
299 OstTraceFunctionExit0( NOTESNOTEVIEW_HANDLEITEMLONGPRESSED_EXIT ); |
278 } |
300 } |
279 |
301 |
280 /*! |
302 /*! |
281 Slot to delete a selected note. |
303 Slot to delete a selected note. |
282 */ |
304 */ |
283 void NotesNoteView::deleteNote() |
305 void NotesNoteView::deleteNote() |
284 { |
306 { |
|
307 OstTraceFunctionEntry0( NOTESNOTEVIEW_DELETENOTE_ENTRY ); |
285 Q_ASSERT(mSelectedItem); |
308 Q_ASSERT(mSelectedItem); |
286 |
309 |
287 QModelIndex index = mSelectedItem->modelIndex(); |
310 QModelIndex index = mSelectedItem->modelIndex(); |
288 if (!index.isValid()) { |
311 if (!index.isValid()) { |
|
312 OstTraceFunctionExit0( NOTESNOTEVIEW_DELETENOTE_EXIT ); |
289 return; |
313 return; |
290 } |
314 } |
291 ulong noteId = |
315 ulong noteId = |
292 index.data(NotesNamespace::IdRole).value<qulonglong>(); |
316 index.data(NotesNamespace::IdRole).value<qulonglong>(); |
293 if (!noteId) { |
317 if (!noteId) { |
|
318 OstTraceFunctionExit0( DUP1_NOTESNOTEVIEW_DELETENOTE_EXIT ); |
294 return; |
319 return; |
295 } |
320 } |
296 // Emitting the signal , deletion would be handle in view manager. |
321 // Emitting the signal , deletion would be handle in view manager. |
297 emit deleteEntry(noteId); |
322 emit deleteEntry(noteId); |
298 |
323 |
299 mSelectedItem = 0; |
324 mSelectedItem = 0; |
|
325 OstTraceFunctionExit0( DUP2_NOTESNOTEVIEW_DELETENOTE_EXIT ); |
300 } |
326 } |
301 |
327 |
302 /*! |
328 /*! |
303 Marks/unmarks the note as favourite. |
329 Marks/unmarks the note as favourite. |
304 */ |
330 */ |
305 void NotesNoteView::markNoteAsFavourite() |
331 void NotesNoteView::markNoteAsFavourite() |
306 { |
332 { |
|
333 OstTraceFunctionEntry0( NOTESNOTEVIEW_MARKNOTEASFAVOURITE_ENTRY ); |
307 ulong noteId = mSelectedItem->modelIndex().data( |
334 ulong noteId = mSelectedItem->modelIndex().data( |
308 NotesNamespace::IdRole).value<qulonglong>(); |
335 NotesNamespace::IdRole).value<qulonglong>(); |
309 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
336 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
310 |
337 |
311 if (entry.favourite()) { |
338 if (entry.favourite()) { |
312 entry.setFavourite(0); |
339 entry.setFavourite(0); |
313 } else { |
340 } else { |
314 entry.setFavourite(1); |
341 entry.setFavourite(1); |
315 } |
342 } |
316 mAgendaUtil->updateEntry(entry); |
343 mAgendaUtil->store(entry); |
317 } |
344 OstTraceFunctionExit0( NOTESNOTEVIEW_MARKNOTEASFAVOURITE_EXIT ); |
318 |
345 } |
319 /*! |
346 |
320 Slot to make a note as to-do. |
347 /*! |
|
348 Slot to make a note as to-do. |
321 */ |
349 */ |
322 void NotesNoteView::markNoteAsTodo() |
350 void NotesNoteView::markNoteAsTodo() |
323 { |
351 { |
|
352 OstTraceFunctionEntry0( NOTESNOTEVIEW_MARKNOTEASTODO_ENTRY ); |
324 Q_ASSERT(mSelectedItem); |
353 Q_ASSERT(mSelectedItem); |
325 |
354 |
326 QModelIndex index = mSelectedItem->modelIndex(); |
355 QModelIndex index = mSelectedItem->modelIndex(); |
327 if (!index.isValid()) { |
356 if (!index.isValid()) { |
|
357 OstTraceFunctionExit0( NOTESNOTEVIEW_MARKNOTEASTODO_EXIT ); |
328 return; |
358 return; |
329 } |
359 } |
330 ulong noteId = |
360 ulong noteId = |
331 index.data(NotesNamespace::IdRole).value<qulonglong>(); |
361 index.data(NotesNamespace::IdRole).value<qulonglong>(); |
332 if (!noteId) { |
362 if (!noteId) { |
|
363 OstTraceFunctionExit0( DUP1_NOTESNOTEVIEW_MARKNOTEASTODO_EXIT ); |
333 return; |
364 return; |
334 } |
365 } |
335 // Get the entry details. |
366 // Get the entry details. |
336 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
367 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
337 |
368 |
338 if (entry.isNull()) { |
369 if (entry.isNull()) { |
339 // Entry invalid. |
370 // Entry invalid. |
|
371 OstTraceFunctionExit0( DUP2_NOTESNOTEVIEW_MARKNOTEASTODO_EXIT ); |
340 return; |
372 return; |
341 } |
373 } |
342 |
374 |
343 // Here change the type of modified note and destroy the noteeditor and |
375 // Here change the type of modified note and destroy the noteeditor and |
344 // construct the to-do editor. |
376 // construct the to-do editor. |
387 |
420 |
388 \sa NotesEditor. |
421 \sa NotesEditor. |
389 */ |
422 */ |
390 void NotesNoteView::handleEditingCompleted(bool status) |
423 void NotesNoteView::handleEditingCompleted(bool status) |
391 { |
424 { |
|
425 OstTraceFunctionEntry0( NOTESNOTEVIEW_HANDLEEDITINGCOMPLETED_ENTRY ); |
392 Q_UNUSED(status) |
426 Q_UNUSED(status) |
393 |
427 |
394 // Cleanup. |
428 // Cleanup. |
395 mNotesEditor->deleteLater(); |
429 mNotesEditor->deleteLater(); |
|
430 OstTraceFunctionExit0( NOTESNOTEVIEW_HANDLEEDITINGCOMPLETED_EXIT ); |
396 } |
431 } |
397 |
432 |
398 /*! |
433 /*! |
399 Directs the view manager to display the Collections view. |
434 Directs the view manager to display the Collections view. |
400 */ |
435 */ |
401 void NotesNoteView::displayCollectionView() |
436 void NotesNoteView::displayCollectionView() |
402 { |
437 { |
|
438 OstTraceFunctionEntry0( NOTESNOTEVIEW_DISPLAYCOLLECTIONVIEW_ENTRY ); |
403 // Switch to collections view. |
439 // Switch to collections view. |
404 mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId); |
440 mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId); |
405 |
441 |
|
442 OstTraceFunctionExit0( NOTESNOTEVIEW_DISPLAYCOLLECTIONVIEW_EXIT ); |
406 } |
443 } |
407 |
444 |
408 /*! |
445 /*! |
409 Directs the view manager to display the All notes view. |
446 Directs the view manager to display the All notes view. |
410 */ |
447 */ |
411 void NotesNoteView::displayAllNotesView() |
448 void NotesNoteView::displayAllNotesView() |
412 { |
449 { |
|
450 OstTraceFunctionEntry0( NOTESNOTEVIEW_DISPLAYALLNOTESVIEW_ENTRY ); |
413 // Switch to collections view. |
451 // Switch to collections view. |
414 mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId); |
452 mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId); |
|
453 OstTraceFunctionExit0( NOTESNOTEVIEW_DISPLAYALLNOTESVIEW_EXIT ); |
415 } |
454 } |
416 |
455 |
417 /*! |
456 /*! |
418 Slot to handle the case when the state of an action has changed. |
457 Slot to handle the case when the state of an action has changed. |
419 */ |
458 */ |
420 void NotesNoteView::handleActionStateChanged() |
459 void NotesNoteView::handleActionStateChanged() |
421 { |
460 { |
|
461 OstTraceFunctionEntry0( NOTESNOTEVIEW_HANDLEACTIONSTATECHANGED_ENTRY ); |
422 mAllNotesAction->setChecked(true); |
462 mAllNotesAction->setChecked(true); |
|
463 OstTraceFunctionExit0( NOTESNOTEVIEW_HANDLEACTIONSTATECHANGED_EXIT ); |
423 } |
464 } |
424 |
465 |
425 /*! |
466 /*! |
426 Handles the orientation changes.Updates the list |
467 Handles the orientation changes.Updates the list |
427 item when orientation is changed |
468 item when orientation is changed |
428 |
469 |
429 \param orientation Value of the orientation |
470 \param orientation Value of the orientation |
430 */ |
471 */ |
431 void NotesNoteView::handleOrientationChanged(Qt::Orientation orientation) |
472 void NotesNoteView::handleOrientationChanged(Qt::Orientation orientation) |
432 { |
473 { |
|
474 OstTraceFunctionEntry0( NOTESNOTEVIEW_HANDLEORIENTATIONCHANGED_ENTRY ); |
433 HbListViewItem *prototype = mListView->listItemPrototype(); |
475 HbListViewItem *prototype = mListView->listItemPrototype(); |
434 |
476 |
435 if (Qt::Horizontal == orientation) { |
477 if (Qt::Horizontal == orientation) { |
436 prototype->setStretchingStyle(HbListViewItem::StretchLandscape); |
478 prototype->setStretchingStyle(HbListViewItem::StretchLandscape); |
437 } else { |
479 } else { |
438 prototype->setStretchingStyle(HbListViewItem::NoStretching); |
480 prototype->setStretchingStyle(HbListViewItem::NoStretching); |
439 } |
481 } |
|
482 OstTraceFunctionExit0( NOTESNOTEVIEW_HANDLEORIENTATIONCHANGED_EXIT ); |
440 } |
483 } |
441 |
484 |
442 /* |
485 /* |
443 Opens the notes editor to edit the note. |
486 Opens the notes editor to edit the note. |
444 */ |
487 */ |
445 void NotesNoteView::openNote() |
488 void NotesNoteView::openNote() |
446 { |
489 { |
|
490 OstTraceFunctionEntry0( NOTESNOTEVIEW_OPENNOTE_ENTRY ); |
447 ulong noteId = mSelectedItem->modelIndex().data( |
491 ulong noteId = mSelectedItem->modelIndex().data( |
448 NotesNamespace::IdRole).value<qulonglong>(); |
492 NotesNamespace::IdRole).value<qulonglong>(); |
449 |
493 |
450 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
494 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
451 |
495 |
455 mNotesEditor, SIGNAL(editingCompleted(bool)), |
499 mNotesEditor, SIGNAL(editingCompleted(bool)), |
456 this, SLOT(handleEditingCompleted(bool))); |
500 this, SLOT(handleEditingCompleted(bool))); |
457 |
501 |
458 // Launch the notes editor with the obtained info. |
502 // Launch the notes editor with the obtained info. |
459 mNotesEditor->edit(entry); |
503 mNotesEditor->edit(entry); |
|
504 OstTraceFunctionExit0( NOTESNOTEVIEW_OPENNOTE_EXIT ); |
460 } |
505 } |
461 |
506 |
462 /*! |
507 /*! |
463 Slot to handle context menu actions. |
508 Slot to handle context menu actions. |
464 */ |
509 */ |
465 void NotesNoteView::selectedMenuAction(HbAction *action) |
510 void NotesNoteView::selectedMenuAction(HbAction *action) |
466 { |
511 { |
|
512 OstTraceFunctionEntry0( NOTESNOTEVIEW_SELECTEDMENUACTION_ENTRY ); |
467 if (action == mOpenAction) { |
513 if (action == mOpenAction) { |
468 openNote(); |
514 openNote(); |
469 } else if (action == mDeleteAction) { |
515 } else if (action == mDeleteAction) { |
470 deleteNote(); |
516 deleteNote(); |
471 } else if (action == mMakeFavouriteAction) { |
517 } else if (action == mMakeFavouriteAction) { |
472 markNoteAsFavourite(); |
518 markNoteAsFavourite(); |
473 } else if (action == mMarkTodoAction) { |
519 } else if (action == mMarkTodoAction) { |
474 markNoteAsTodo(); |
520 markNoteAsTodo(); |
475 } |
521 } |
|
522 OstTraceFunctionExit0( NOTESNOTEVIEW_SELECTEDMENUACTION_EXIT ); |
476 } |
523 } |
477 |
524 |
478 /*! |
525 /*! |
479 Slot to handle the context menu closed. |
526 Slot to handle the context menu closed. |
480 */ |
527 */ |
481 void NotesNoteView::handleMenuClosed() |
528 void NotesNoteView::handleMenuClosed() |
482 { |
529 { |
|
530 OstTraceFunctionEntry0( NOTESNOTEVIEW_HANDLEMENUCLOSED_ENTRY ); |
483 mIsLongTop = false; |
531 mIsLongTop = false; |
|
532 OstTraceFunctionExit0( NOTESNOTEVIEW_HANDLEMENUCLOSED_EXIT ); |
484 } |
533 } |
485 |
534 |
486 /*! |
535 /*! |
487 Handles the visibility of empty list label. |
536 Handles the visibility of empty list label. |
488 */ |
537 */ |
489 void NotesNoteView::updateView(ulong id) |
538 void NotesNoteView::updateView(ulong id) |
490 { |
539 { |
|
540 OstTraceFunctionEntry0( NOTESNOTEVIEW_UPDATEVIEW_ENTRY ); |
491 Q_UNUSED(id) |
541 Q_UNUSED(id) |
492 |
542 |
493 // Get the numbers of notes. |
543 // Get the numbers of notes. |
494 if (0 >= mListView->model()->rowCount()) { |
544 if (0 >= mListView->model()->rowCount()) { |
495 mEmptyListLabel->show(); |
545 mEmptyListLabel->show(); |
496 mListView->hide(); |
546 mListView->hide(); |
497 } else { |
547 } else { |
498 mEmptyListLabel->hide(); |
548 mEmptyListLabel->hide(); |
499 mListView->show(); |
549 mListView->show(); |
500 } |
550 } |
|
551 OstTraceFunctionExit0( NOTESNOTEVIEW_UPDATEVIEW_EXIT ); |
501 } |
552 } |
502 |
553 |
503 // End of file --Don't remove this. |
554 // End of file --Don't remove this. |
504 |
|