30 #include <HbAbstractViewItem> |
30 #include <HbAbstractViewItem> |
31 #include <HbGroupBox> |
31 #include <HbGroupBox> |
32 #include <HbListViewItem> |
32 #include <HbListViewItem> |
33 |
33 |
34 // User includes |
34 // User includes |
|
35 #include <agendautil.h> |
35 #include "agendaeventviewer.h" |
36 #include "agendaeventviewer.h" |
36 #include "notestodoview.h" |
37 #include "notestodoview.h" |
37 #include "notescommon.h" |
38 #include "notescommon.h" |
38 #include "notesdocloader.h" |
39 #include "notesdocloader.h" |
39 #include "agendautil.h" |
|
40 #include "notesmodel.h" |
40 #include "notesmodel.h" |
41 #include "notessortfilterproxymodel.h" |
41 #include "notessortfilterproxymodel.h" |
42 #include "noteseditor.h" |
42 #include "noteseditor.h" |
|
43 #include "OstTraceDefinitions.h" |
|
44 #ifdef OST_TRACE_COMPILER_IN_USE |
|
45 #include "notestodoviewTraces.h" |
|
46 #endif |
|
47 |
43 |
48 |
44 /*! |
49 /*! |
45 \class NotesTodoView |
50 \class NotesTodoView |
46 \brief The main view of the notes application. Responsible for displaying |
51 \brief The main view of the notes application. Responsible for displaying |
47 notes and todos. |
52 notes and todos. |
82 \param docLoader Pointer to NotesDocLoader object. |
91 \param docLoader Pointer to NotesDocLoader object. |
83 */ |
92 */ |
84 void NotesTodoView::setupView( |
93 void NotesTodoView::setupView( |
85 NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader) |
94 NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader) |
86 { |
95 { |
|
96 OstTraceFunctionEntry0( NOTESTODOVIEW_SETUPVIEW_ENTRY ); |
87 mDocLoader = docLoader; |
97 mDocLoader = docLoader; |
88 mAppControllerIf = &controllerIf; |
98 mAppControllerIf = &controllerIf; |
89 mNotesModel = mAppControllerIf->notesModel(); |
99 mNotesModel = mAppControllerIf->notesModel(); |
90 mAgendaUtil = mAppControllerIf->agendaUtil(); |
100 mAgendaUtil = mAppControllerIf->agendaUtil(); |
91 |
101 |
164 this, SLOT(updateSubTitle(ulong))); |
174 this, SLOT(updateSubTitle(ulong))); |
165 |
175 |
166 // Set the graphics size for the icons. |
176 // Set the graphics size for the icons. |
167 HbListViewItem *prototype = mListView->listItemPrototype(); |
177 HbListViewItem *prototype = mListView->listItemPrototype(); |
168 prototype->setGraphicsSize(HbListViewItem::SmallIcon); |
178 prototype->setGraphicsSize(HbListViewItem::SmallIcon); |
|
179 OstTraceFunctionExit0( NOTESTODOVIEW_SETUPVIEW_EXIT ); |
169 } |
180 } |
170 |
181 |
171 /* |
182 /* |
172 Updates the title text for the first launch |
183 Updates the title text for the first launch |
173 */ |
184 */ |
174 void NotesTodoView::updateTitle() |
185 void NotesTodoView::updateTitle() |
175 { |
186 { |
|
187 OstTraceFunctionEntry0( NOTESTODOVIEW_UPDATETITLE_ENTRY ); |
176 updateSubTitle(); |
188 updateSubTitle(); |
|
189 OstTraceFunctionExit0( NOTESTODOVIEW_UPDATETITLE_EXIT ); |
177 } |
190 } |
178 |
191 |
179 /*! |
192 /*! |
180 Opens the to-do editor to create a new to-do. |
193 Opens the to-do editor to create a new to-do. |
181 */ |
194 */ |
182 void NotesTodoView::createNewTodo() |
195 void NotesTodoView::createNewTodo() |
183 { |
196 { |
|
197 OstTraceFunctionEntry0( NOTESTODOVIEW_CREATENEWTODO_ENTRY ); |
184 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
198 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
185 connect( |
199 connect( |
186 mNotesEditor, SIGNAL(editingCompleted(bool)), |
200 mNotesEditor, SIGNAL(editingCompleted(bool)), |
187 this, SLOT(handleEditingCompleted(bool))); |
201 this, SLOT(handleEditingCompleted(bool))); |
188 |
202 |
189 mNotesEditor->create(NotesEditor::CreateTodo); |
203 mNotesEditor->create(NotesEditor::CreateTodo); |
|
204 OstTraceFunctionExit0( NOTESTODOVIEW_CREATENEWTODO_EXIT ); |
190 } |
205 } |
191 |
206 |
192 /*! |
207 /*! |
193 Handles the pressing of a list item in the view. |
208 Handles the pressing of a list item in the view. |
194 |
209 |
197 \param index Reference to the QModelIndex representing the view item. |
212 \param index Reference to the QModelIndex representing the view item. |
198 \sa HbAbstractViewItem |
213 \sa HbAbstractViewItem |
199 */ |
214 */ |
200 void NotesTodoView::handleItemReleased(const QModelIndex &index) |
215 void NotesTodoView::handleItemReleased(const QModelIndex &index) |
201 { |
216 { |
|
217 OstTraceFunctionEntry0( NOTESTODOVIEW_HANDLEITEMRELEASED_ENTRY ); |
202 if(!mIsLongTop) { |
218 if(!mIsLongTop) { |
203 // Sanity check. |
219 // Sanity check. |
204 if (!index.isValid()) { |
220 if (!index.isValid()) { |
|
221 OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEITEMRELEASED_EXIT ); |
205 return; |
222 return; |
206 } |
223 } |
207 |
224 |
208 // First get the id of the to-do and get the corresponding information from |
225 // First get the id of the to-do and get the corresponding information from |
209 // agendautil. |
226 // agendautil. |
210 ulong toDoId = index.data(NotesNamespace::IdRole).value<qulonglong>(); |
227 ulong toDoId = index.data(NotesNamespace::IdRole).value<qulonglong>(); |
211 |
228 |
212 if (0 >= toDoId) { |
229 if (0 >= toDoId) { |
213 // Something wrong. |
230 // Something wrong. |
|
231 OstTraceFunctionExit0( DUP1_NOTESTODOVIEW_HANDLEITEMRELEASED_EXIT ); |
214 return; |
232 return; |
215 } |
233 } |
216 |
234 |
217 // Construct agenda event viewer. |
235 // Construct agenda event viewer. |
218 mAgendaEventViewer = new AgendaEventViewer(mAgendaUtil, this); |
236 mAgendaEventViewer = new AgendaEventViewer(mAgendaUtil, this); |
272 } |
292 } |
273 |
293 |
274 // Show the menu. |
294 // Show the menu. |
275 contextMenu->open(this, SLOT(selectedMenuAction(HbAction*))); |
295 contextMenu->open(this, SLOT(selectedMenuAction(HbAction*))); |
276 contextMenu->setPreferredPos(coords); |
296 contextMenu->setPreferredPos(coords); |
|
297 OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEITEMLONGPRESSED_EXIT ); |
277 } |
298 } |
278 |
299 |
279 /*! |
300 /*! |
280 Slot to delete a selected to-do. |
301 Slot to delete a selected to-do. |
281 */ |
302 */ |
282 void NotesTodoView::deleteTodo() |
303 void NotesTodoView::deleteTodo() |
283 { |
304 { |
|
305 OstTraceFunctionEntry0( NOTESTODOVIEW_DELETETODO_ENTRY ); |
284 Q_ASSERT(mSelectedItem); |
306 Q_ASSERT(mSelectedItem); |
285 |
307 |
286 QModelIndex index = mSelectedItem->modelIndex(); |
308 QModelIndex index = mSelectedItem->modelIndex(); |
287 if (!index.isValid()) { |
309 if (!index.isValid()) { |
|
310 OstTraceFunctionExit0( NOTESTODOVIEW_DELETETODO_EXIT ); |
288 return; |
311 return; |
289 } |
312 } |
290 ulong entryId = |
313 ulong entryId = |
291 index.data(NotesNamespace::IdRole).value<qulonglong>(); |
314 index.data(NotesNamespace::IdRole).value<qulonglong>(); |
292 if (!entryId) { |
315 if (!entryId) { |
|
316 OstTraceFunctionExit0( DUP1_NOTESTODOVIEW_DELETETODO_EXIT ); |
293 return; |
317 return; |
294 } |
318 } |
295 |
319 |
296 // Emit the signal. Delete would be handled in view manager. |
320 // Emit the signal. Delete would be handled in view manager. |
297 emit deleteEntry(entryId); |
321 emit deleteEntry(entryId); |
298 |
322 |
299 mSelectedItem = 0; |
323 mSelectedItem = 0; |
|
324 OstTraceFunctionExit0( DUP2_NOTESTODOVIEW_DELETETODO_EXIT ); |
300 } |
325 } |
301 |
326 |
302 /*! |
327 /*! |
303 Marks to-do entry as done or undone based on the completed value. |
328 Marks to-do entry as done or undone based on the completed value. |
304 */ |
329 */ |
305 void NotesTodoView::markTodoStatus() |
330 void NotesTodoView::markTodoStatus() |
306 { |
331 { |
|
332 OstTraceFunctionEntry0( NOTESTODOVIEW_MARKTODOSTATUS_ENTRY ); |
307 ulong entryId = mSelectedItem->modelIndex().data( |
333 ulong entryId = mSelectedItem->modelIndex().data( |
308 NotesNamespace::IdRole).value<qulonglong>(); |
334 NotesNamespace::IdRole).value<qulonglong>(); |
309 AgendaEntry entry = mAgendaUtil->fetchById(entryId); |
335 AgendaEntry entry = mAgendaUtil->fetchById(entryId); |
310 |
336 |
311 QDateTime currentDateTime = QDateTime::currentDateTime(); |
337 QDateTime currentDateTime = QDateTime::currentDateTime(); |
313 if (AgendaEntry::TodoNeedsAction == entry.status()) { |
339 if (AgendaEntry::TodoNeedsAction == entry.status()) { |
314 mAgendaUtil->setCompleted(entry, true, currentDateTime); |
340 mAgendaUtil->setCompleted(entry, true, currentDateTime); |
315 } else if (AgendaEntry::TodoCompleted == entry.status()) { |
341 } else if (AgendaEntry::TodoCompleted == entry.status()) { |
316 mAgendaUtil->setCompleted(entry, false, currentDateTime); |
342 mAgendaUtil->setCompleted(entry, false, currentDateTime); |
317 } |
343 } |
|
344 OstTraceFunctionExit0( NOTESTODOVIEW_MARKTODOSTATUS_EXIT ); |
318 } |
345 } |
319 |
346 |
320 /*! |
347 /*! |
321 Opens to-do in an editor. |
348 Opens to-do in an editor. |
322 */ |
349 */ |
323 void NotesTodoView::editTodo() |
350 void NotesTodoView::editTodo() |
324 { |
351 { |
|
352 OstTraceFunctionEntry0( NOTESTODOVIEW_EDITTODO_ENTRY ); |
325 QModelIndex index = mSelectedItem->modelIndex(); |
353 QModelIndex index = mSelectedItem->modelIndex(); |
326 |
354 |
327 // Sanity check. |
355 // Sanity check. |
328 if (!index.isValid()) { |
356 if (!index.isValid()) { |
|
357 OstTraceFunctionExit0( NOTESTODOVIEW_EDITTODO_EXIT ); |
329 return; |
358 return; |
330 } |
359 } |
331 |
360 |
332 // First get the id of the note and get the corresponding information from |
361 // First get the id of the note and get the corresponding information from |
333 // agendautil. |
362 // agendautil. |
334 ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>(); |
363 ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>(); |
335 |
364 |
336 if (0 >= noteId) { |
365 if (0 >= noteId) { |
337 // Something wrong. |
366 // Something wrong. |
|
367 OstTraceFunctionExit0( DUP1_NOTESTODOVIEW_EDITTODO_EXIT ); |
338 return; |
368 return; |
339 } |
369 } |
340 |
370 |
341 // Get the entry details. |
371 // Get the entry details. |
342 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
372 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
343 |
373 |
344 if (entry.isNull()) { |
374 if (entry.isNull()) { |
345 // Entry invalid. |
375 // Entry invalid. |
|
376 OstTraceFunctionExit0( DUP2_NOTESTODOVIEW_EDITTODO_EXIT ); |
346 return; |
377 return; |
347 } |
378 } |
348 |
379 |
349 // Now launch the editor with the obtained info. |
380 // Now launch the editor with the obtained info. |
350 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
381 mNotesEditor = new NotesEditor(mAgendaUtil, this); |
351 connect( |
382 connect( |
352 mNotesEditor, SIGNAL(editingCompleted(bool)), |
383 mNotesEditor, SIGNAL(editingCompleted(bool)), |
353 this, SLOT(handleEditingCompleted(bool))); |
384 this, SLOT(handleEditingCompleted(bool))); |
354 mNotesEditor->edit(entry); |
385 mNotesEditor->edit(entry); |
|
386 OstTraceFunctionExit0( DUP3_NOTESTODOVIEW_EDITTODO_EXIT ); |
355 } |
387 } |
356 |
388 |
357 /*! |
389 /*! |
358 Slot to handle the signal editingCompleted by the notes editor. |
390 Slot to handle the signal editingCompleted by the notes editor. |
359 |
391 |
361 |
393 |
362 \sa NotesEditor. |
394 \sa NotesEditor. |
363 */ |
395 */ |
364 void NotesTodoView::handleEditingCompleted(bool status) |
396 void NotesTodoView::handleEditingCompleted(bool status) |
365 { |
397 { |
|
398 OstTraceFunctionEntry0( NOTESTODOVIEW_HANDLEEDITINGCOMPLETED_ENTRY ); |
366 Q_UNUSED(status) |
399 Q_UNUSED(status) |
367 |
400 |
368 // Cleanup. |
401 // Cleanup. |
369 mNotesEditor->deleteLater(); |
402 mNotesEditor->deleteLater(); |
|
403 OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEEDITINGCOMPLETED_EXIT ); |
370 } |
404 } |
371 |
405 |
372 /*! |
406 /*! |
373 Directs the view manager to display the Collections view. |
407 Directs the view manager to display the Collections view. |
374 */ |
408 */ |
375 void NotesTodoView::displayCollectionView() |
409 void NotesTodoView::displayCollectionView() |
376 { |
410 { |
|
411 OstTraceFunctionEntry0( NOTESTODOVIEW_DISPLAYCOLLECTIONVIEW_ENTRY ); |
377 // Switch to collections view. |
412 // Switch to collections view. |
378 mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId); |
413 mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId); |
|
414 OstTraceFunctionExit0( NOTESTODOVIEW_DISPLAYCOLLECTIONVIEW_EXIT ); |
379 } |
415 } |
380 |
416 |
381 /*! |
417 /*! |
382 Directs the view manager to display the All notes view. |
418 Directs the view manager to display the All notes view. |
383 */ |
419 */ |
384 void NotesTodoView::displayAllNotesView() |
420 void NotesTodoView::displayAllNotesView() |
385 { |
421 { |
|
422 OstTraceFunctionEntry0( NOTESTODOVIEW_DISPLAYALLNOTESVIEW_ENTRY ); |
386 // Switch to collections view. |
423 // Switch to collections view. |
387 mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId); |
424 mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId); |
|
425 OstTraceFunctionExit0( NOTESTODOVIEW_DISPLAYALLNOTESVIEW_EXIT ); |
388 } |
426 } |
389 |
427 |
390 /*! |
428 /*! |
391 Slot to handle signal editingCompleted by the to-do editor |
429 Slot to handle signal editingCompleted by the to-do editor |
392 */ |
430 */ |
393 void NotesTodoView::handleEditingCompleted() |
431 void NotesTodoView::handleEditingCompleted() |
394 { |
432 { |
|
433 OstTraceFunctionEntry0( DUP1_NOTESTODOVIEW_HANDLEEDITINGCOMPLETED_ENTRY ); |
395 // Cleanup. |
434 // Cleanup. |
396 mNotesEditor->deleteLater(); |
435 mNotesEditor->deleteLater(); |
|
436 OstTraceFunctionExit0( DUP1_NOTESTODOVIEW_HANDLEEDITINGCOMPLETED_EXIT ); |
397 } |
437 } |
398 |
438 |
399 /*! |
439 /*! |
400 Slot to handle signal handleViewingompleted by the agenda event viewer |
440 Slot to handle signal handleViewingompleted by the agenda event viewer |
401 */ |
441 */ |
402 void NotesTodoView::handleViewingCompleted() |
442 void NotesTodoView::handleViewingCompleted() |
403 { |
443 { |
|
444 OstTraceFunctionEntry0( NOTESTODOVIEW_HANDLEVIEWINGCOMPLETED_ENTRY ); |
404 // Cleanup. |
445 // Cleanup. |
405 mAgendaEventViewer->deleteLater(); |
446 mAgendaEventViewer->deleteLater(); |
|
447 OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEVIEWINGCOMPLETED_EXIT ); |
406 } |
448 } |
407 |
449 |
408 /*! |
450 /*! |
409 Slot to handle the case when the state of an action has changed. |
451 Slot to handle the case when the state of an action has changed. |
410 */ |
452 */ |
411 void NotesTodoView::handleActionStateChanged() |
453 void NotesTodoView::handleActionStateChanged() |
412 { |
454 { |
|
455 OstTraceFunctionEntry0( NOTESTODOVIEW_HANDLEACTIONSTATECHANGED_ENTRY ); |
413 mAllNotesAction->setChecked(true); |
456 mAllNotesAction->setChecked(true); |
|
457 OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEACTIONSTATECHANGED_EXIT ); |
414 } |
458 } |
415 |
459 |
416 /*! |
460 /*! |
417 Handles the orientation changes.Updates the list |
461 Handles the orientation changes.Updates the list |
418 item when orientation is changed |
462 item when orientation is changed |
419 |
463 |
420 \param orientation Value of the orientation |
464 \param orientation Value of the orientation |
421 */ |
465 */ |
422 void NotesTodoView::handleOrientationChanged(Qt::Orientation orientation) |
466 void NotesTodoView::handleOrientationChanged(Qt::Orientation orientation) |
423 { |
467 { |
|
468 OstTraceFunctionEntry0( NOTESTODOVIEW_HANDLEORIENTATIONCHANGED_ENTRY ); |
424 HbListViewItem *prototype = mListView->listItemPrototype(); |
469 HbListViewItem *prototype = mListView->listItemPrototype(); |
425 |
470 |
426 if (Qt::Horizontal == orientation) { |
471 if (Qt::Horizontal == orientation) { |
427 prototype->setStretchingStyle(HbListViewItem::StretchLandscape); |
472 prototype->setStretchingStyle(HbListViewItem::StretchLandscape); |
428 } else { |
473 } else { |
429 prototype->setStretchingStyle(HbListViewItem::NoStretching); |
474 prototype->setStretchingStyle(HbListViewItem::NoStretching); |
430 } |
475 } |
|
476 OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEORIENTATIONCHANGED_EXIT ); |
431 } |
477 } |
432 |
478 |
433 /*! |
479 /*! |
434 Updates the sub heading text |
480 Updates the sub heading text |
435 */ |
481 */ |
436 void NotesTodoView::updateSubTitle(ulong id) |
482 void NotesTodoView::updateSubTitle(ulong id) |
437 { |
483 { |
|
484 OstTraceFunctionEntry0( NOTESTODOVIEW_UPDATESUBTITLE_ENTRY ); |
438 Q_UNUSED(id) |
485 Q_UNUSED(id) |
439 |
486 |
440 // Get the number of notes and to-do entries. |
487 // Get the number of notes and to-do entries. |
441 QList<ulong> entries = mAgendaUtil->entryIds( |
488 QList<ulong> entries = mAgendaUtil->entryIds( |
442 AgendaUtil::IncludeIncompletedTodos); |
489 AgendaUtil::IncludeIncompletedTodos); |
469 this, SLOT(handleViewingCompleted(bool))); |
518 this, SLOT(handleViewingCompleted(bool))); |
470 |
519 |
471 // Launch agenda event viewer |
520 // Launch agenda event viewer |
472 mAgendaEventViewer->view( |
521 mAgendaEventViewer->view( |
473 entry, AgendaEventViewer::ActionEditDelete); |
522 entry, AgendaEventViewer::ActionEditDelete); |
|
523 OstTraceFunctionExit0( NOTESTODOVIEW_OPENTODO_EXIT ); |
474 } |
524 } |
475 |
525 |
476 /* |
526 /* |
477 Slot to handle the context menu actions. |
527 Slot to handle the context menu actions. |
478 */ |
528 */ |
479 void NotesTodoView::selectedMenuAction(HbAction *action) |
529 void NotesTodoView::selectedMenuAction(HbAction *action) |
480 { |
530 { |
|
531 OstTraceFunctionEntry0( NOTESTODOVIEW_SELECTEDMENUACTION_ENTRY ); |
481 if (action == mOpenAction) { |
532 if (action == mOpenAction) { |
482 openTodo(); |
533 openTodo(); |
483 } else if (action == mEditAction) { |
534 } else if (action == mEditAction) { |
484 editTodo(); |
535 editTodo(); |
485 } else if (action == mDeleteAction) { |
536 } else if (action == mDeleteAction) { |
486 deleteTodo(); |
537 deleteTodo(); |
487 } else if (action == mTodoStatusAction) { |
538 } else if (action == mTodoStatusAction) { |
488 markTodoStatus(); |
539 markTodoStatus(); |
489 } |
540 } |
|
541 OstTraceFunctionExit0( NOTESTODOVIEW_SELECTEDMENUACTION_EXIT ); |
490 } |
542 } |
491 |
543 |
492 |
544 |
493 /*! |
545 /*! |
494 Slot to handle the context menu closed. |
546 Slot to handle the context menu closed. |
495 */ |
547 */ |
496 void NotesTodoView::handleMenuClosed() |
548 void NotesTodoView::handleMenuClosed() |
497 { |
549 { |
|
550 OstTraceFunctionEntry0( NOTESTODOVIEW_HANDLEMENUCLOSED_ENTRY ); |
498 mIsLongTop = false; |
551 mIsLongTop = false; |
499 } |
552 OstTraceFunctionExit0( NOTESTODOVIEW_HANDLEMENUCLOSED_EXIT ); |
|
553 } |
|
554 |
500 // End of file --Don't remove this. |
555 // End of file --Don't remove this. |