36 #include <HbPushButton> |
38 #include <HbPushButton> |
37 #include <HbCheckBox> |
39 #include <HbCheckBox> |
38 #include <HbDialog> |
40 #include <HbDialog> |
39 #include <HbGroupBox> |
41 #include <HbGroupBox> |
40 #include <HbMessageBox> |
42 #include <HbMessageBox> |
|
43 #include <HbTranslator> |
|
44 #include <HbApplication> |
41 |
45 |
42 // User includes |
46 // User includes |
43 #include "notestodoeditor.h" |
47 #include "notestodoeditor.h" |
44 #include "notestodoeditorcustomitem.h" |
48 #include "notestodoeditorcustomitem.h" |
45 #include "noteseditor_p.h" |
49 #include "noteseditor_p.h" |
73 NotesEditorPrivate* owner, QObject *parent) |
77 NotesEditorPrivate* owner, QObject *parent) |
74 :QObject(parent), |
78 :QObject(parent), |
75 mOwner(owner), |
79 mOwner(owner), |
76 mReminderEnabler(0), |
80 mReminderEnabler(0), |
77 mReminderItem(0), |
81 mReminderItem(0), |
|
82 mTranslator(0), |
78 mDescriptionItemIndex(5), |
83 mDescriptionItemIndex(5), |
79 mDiscardChangesActive(false) |
84 mDiscardChangesActive(false), |
|
85 mForcedExit(false) |
80 { |
86 { |
81 OstTraceFunctionEntry0( NOTESTODOEDITOR_NOTESTODOEDITOR_ENTRY ); |
87 OstTraceFunctionEntry0( NOTESTODOEDITOR_NOTESTODOEDITOR_ENTRY ); |
|
88 |
|
89 mTranslator = new HbTranslator("todoeditor"); |
|
90 |
82 mDocLoader = new NotesEditorDocLoader; |
91 mDocLoader = new NotesEditorDocLoader; |
83 Q_ASSERT(mDocLoader); |
92 Q_ASSERT(mDocLoader); |
84 |
93 |
85 bool success; |
94 bool success; |
86 // Load the to-do editor docml file. |
95 // Load the to-do editor docml file. |
109 NotesTodoEditorCustomItem *customItem = |
118 NotesTodoEditorCustomItem *customItem = |
110 new NotesTodoEditorCustomItem(mOwner, mDataForm); |
119 new NotesTodoEditorCustomItem(mOwner, mDataForm); |
111 QList <HbAbstractViewItem*> prototypes = mDataForm->itemPrototypes(); |
120 QList <HbAbstractViewItem*> prototypes = mDataForm->itemPrototypes(); |
112 prototypes.append(customItem); |
121 prototypes.append(customItem); |
113 mDataForm->setItemPrototypes(prototypes); |
122 mDataForm->setItemPrototypes(prototypes); |
|
123 |
|
124 //if editor is open in background, and user close the app from task switcher |
|
125 //entry should get saved |
|
126 connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), |
|
127 this, SLOT(forcedExit())); |
|
128 |
|
129 |
114 OstTraceFunctionExit0( NOTESTODOEDITOR_NOTESTODOEDITOR_EXIT ); |
130 OstTraceFunctionExit0( NOTESTODOEDITOR_NOTESTODOEDITOR_EXIT ); |
115 } |
131 } |
116 |
132 |
117 /*! |
133 /*! |
118 Destructor. |
134 Destructor. |
263 */ |
288 */ |
264 void NotesTodoEditor::addDiscardChangesAction() |
289 void NotesTodoEditor::addDiscardChangesAction() |
265 { |
290 { |
266 OstTraceFunctionEntry0( NOTESTODOEDITOR_ADDDISCARDCHANGESACTION_ENTRY ); |
291 OstTraceFunctionEntry0( NOTESTODOEDITOR_ADDDISCARDCHANGESACTION_ENTRY ); |
267 if(!mDiscardChangesActive) { |
292 if(!mDiscardChangesActive) { |
268 mDiscardAction = new HbAction(hbTrId("txt_notes_opt_discard_changes")); |
293 mDiscardAction = new HbAction(hbTrId("txt_calendar_opt_discard_changes")); |
269 |
294 |
270 mEditor->menu()->addAction(mDiscardAction); |
295 mEditor->menu()->addAction(mDiscardAction); |
271 |
296 |
272 connect( |
297 connect( |
273 mDiscardAction, SIGNAL(triggered()), |
298 mDiscardAction, SIGNAL(triggered()), |
296 // Update the description menu item |
321 // Update the description menu item |
297 if (entry.description().length()) { |
322 if (entry.description().length()) { |
298 // Insert description item |
323 // Insert description item |
299 insertDescriptionItem(); |
324 insertDescriptionItem(); |
300 |
325 |
301 mDescriptionAction->setText(hbTrId("txt_notes_opt_remove_description")); |
326 mDescriptionAction->setText(hbTrId("txt_calendar_opt_remove_description")); |
302 viewMenu->addAction(mDescriptionAction); |
327 viewMenu->addAction(mDescriptionAction); |
303 |
328 |
304 connect( |
329 connect( |
305 mDescriptionAction, SIGNAL(triggered()), |
330 mDescriptionAction, SIGNAL(triggered()), |
306 this, SLOT(handleRemoveDescriptionAction())); |
331 this, SLOT(handleRemoveDescriptionAction())); |
307 } else { |
332 } else { |
308 mDescriptionAction->setText(hbTrId("txt_notes_opt_add_description")); |
333 mDescriptionAction->setText(hbTrId("txt_calendar_opt_add_description")); |
309 viewMenu->addAction(mDescriptionAction); |
334 viewMenu->addAction(mDescriptionAction); |
310 |
335 |
311 connect( |
336 connect( |
312 mDescriptionAction, SIGNAL(triggered()), |
337 mDescriptionAction, SIGNAL(triggered()), |
313 this, SLOT(handleAddDescriptionAction())); |
338 this, SLOT(handleAddDescriptionAction())); |
314 } |
339 } |
315 |
340 |
316 // Update the sub heading based on the new /existing entry |
341 // Update the sub heading based on the new /existing entry |
317 if (mOwner->mNewEntry) { |
342 if (mOwner->mNewEntry) { |
318 mSubHeading->setHeading(hbTrId("txt_notes_subhead_new_todo")); |
343 mSubHeading->setHeading(hbTrId("txt_calendar_subhead_new_todo")); |
319 } else { |
344 } else { |
320 mSubHeading->setHeading(hbTrId("txt_notes_subhead_todo")); |
345 mSubHeading->setHeading(hbTrId("txt_calendar_subhead_todo")); |
321 } |
346 } |
322 |
347 |
323 // Store the current view and set our view as the current view. |
348 // Store the current view and set our view as the current view. |
324 HbMainWindow *window = hbInstance->allMainWindows().first(); |
349 HbMainWindow *window = hbInstance->allMainWindows().first(); |
325 HbAction *action = new HbAction(Hb::BackNaviAction); |
350 HbAction *action = new HbAction(Hb::BackNaviAction); |
404 HbDataFormModelItem::DataItemType itemType = |
429 HbDataFormModelItem::DataItemType itemType = |
405 static_cast<HbDataFormModelItem::DataItemType> |
430 static_cast<HbDataFormModelItem::DataItemType> |
406 (HbDataFormModelItem::CustomItemBase + DueDateItemOffset); |
431 (HbDataFormModelItem::CustomItemBase + DueDateItemOffset); |
407 |
432 |
408 mDueDateItem = mFormModel->appendDataFormItem( |
433 mDueDateItem = mFormModel->appendDataFormItem( |
409 itemType, hbTrId("txt_notes_formlabel_due_date"), |
434 itemType, hbTrId("txt_calendar_formlabel_due_date"), |
410 mFormModel->invisibleRootItem()); |
435 mFormModel->invisibleRootItem()); |
411 |
436 |
412 QString dueDateText; |
437 QString dueDateText; |
413 |
438 |
414 if (mOwner->mModifiedNote.endTime().isNull()) { |
439 if (mOwner->mModifiedNote.endTime().isNull()) { |
434 mReminderEnabler = mFormModel->appendDataFormItem( |
459 mReminderEnabler = mFormModel->appendDataFormItem( |
435 HbDataFormModelItem::CheckBoxItem, |
460 HbDataFormModelItem::CheckBoxItem, |
436 tr(""), mFormModel->invisibleRootItem()); |
461 tr(""), mFormModel->invisibleRootItem()); |
437 |
462 |
438 mReminderEnabler->setContentWidgetData( |
463 mReminderEnabler->setContentWidgetData( |
439 QString("text"), QString(hbTrId("txt_notes_formlabel_alarm"))); |
464 QString("text"), QString(hbTrId("txt_calendar_formlabel_alarm"))); |
440 |
465 |
441 if (!mOwner->mModifiedNote.alarm().isNull()) { |
466 if (!mOwner->mModifiedNote.alarm().isNull()) { |
442 mReminderEnabler->setContentWidgetData("checkState",Qt::Checked); |
467 mReminderEnabler->setContentWidgetData("checkState",Qt::Checked); |
443 } else { |
468 } else { |
444 mReminderEnabler->setContentWidgetData("checkState",Qt::Unchecked); |
469 mReminderEnabler->setContentWidgetData("checkState",Qt::Unchecked); |
460 HbDataFormModelItem::DataItemType itemType = |
485 HbDataFormModelItem::DataItemType itemType = |
461 static_cast<HbDataFormModelItem::DataItemType> |
486 static_cast<HbDataFormModelItem::DataItemType> |
462 (HbDataFormModelItem::CustomItemBase + AlarmDateItemOffset); |
487 (HbDataFormModelItem::CustomItemBase + AlarmDateItemOffset); |
463 |
488 |
464 mReminderItem = mFormModel->insertDataFormItem( |
489 mReminderItem = mFormModel->insertDataFormItem( |
465 3,itemType,hbTrId("txt_notes_formlabel_alarm_date_and_time")); |
490 3,itemType,hbTrId("txt_calendar_formlabel_alarm_date_and_time")); |
466 |
491 |
467 // Set alarm time to the buttton. |
492 // Set alarm time to the buttton. |
468 QString alarmTimeText; |
493 QString alarmTimeText; |
469 if (mOwner->mModifiedNote.alarm().isNull()) { |
494 if (mOwner->mModifiedNote.alarm().isNull()) { |
470 QTime alarmTime(8, 0, 0, 0); |
495 QTime alarmTime(8, 0, 0, 0); |
534 void NotesTodoEditor::insertPriorityItem() |
559 void NotesTodoEditor::insertPriorityItem() |
535 { |
560 { |
536 OstTraceFunctionEntry0( NOTESTODOEDITOR_INSERTPRIORITYITEM_ENTRY ); |
561 OstTraceFunctionEntry0( NOTESTODOEDITOR_INSERTPRIORITYITEM_ENTRY ); |
537 mPriorityItem = mFormModel->appendDataFormItem( |
562 mPriorityItem = mFormModel->appendDataFormItem( |
538 HbDataFormModelItem::ComboBoxItem, |
563 HbDataFormModelItem::ComboBoxItem, |
539 hbTrId("txt_notes_setlabel_priority"), |
564 hbTrId("txt_calendar_setlabel_priority"), |
540 mFormModel->invisibleRootItem()); |
565 mFormModel->invisibleRootItem()); |
541 |
566 |
542 QStringList priorityList; |
567 QStringList priorityList; |
543 priorityList << hbTrId("txt_notes_setlabel_priority_val_high") |
568 priorityList << hbTrId("txt_calendar_setlabel_repeat_val_high") |
544 << hbTrId("txt_notes_setlabel_priority_val_normal") |
569 << hbTrId("txt_calendar_setlabel_repeat_val_normal") |
545 << hbTrId("txt_notes_setlabel_priority_val_low"); |
570 << hbTrId("txt_calendar_setlabel_repeat_val_low"); |
546 mPriorityItem->setContentWidgetData(QString("items"), priorityList); |
571 mPriorityItem->setContentWidgetData(QString("items"), priorityList); |
547 |
572 |
548 int priority = mOwner->mModifiedNote.priority(); |
573 int priority = mOwner->mModifiedNote.priority(); |
549 // If priority is not set,set to Normal. |
574 // If priority is not set,set to Normal. |
550 if (PriorityUnKnown == priority ) { |
575 if (PriorityUnKnown == priority ) { |
565 void NotesTodoEditor::insertDescriptionItem() |
590 void NotesTodoEditor::insertDescriptionItem() |
566 { |
591 { |
567 OstTraceFunctionEntry0( NOTESTODOEDITOR_INSERTDESCRIPTIONITEM_ENTRY ); |
592 OstTraceFunctionEntry0( NOTESTODOEDITOR_INSERTDESCRIPTIONITEM_ENTRY ); |
568 mDescriptionItem = mFormModel->appendDataFormItem( |
593 mDescriptionItem = mFormModel->appendDataFormItem( |
569 HbDataFormModelItem::TextItem, |
594 HbDataFormModelItem::TextItem, |
570 hbTrId("txt_notes_formlabel_val_description"), |
595 hbTrId("txt_calendar_formlabel_description"), |
571 mFormModel->invisibleRootItem()); |
596 mFormModel->invisibleRootItem()); |
572 |
597 |
573 mDescriptionItemIndex = |
598 mDescriptionItemIndex = |
574 mFormModel->indexFromItem(mDescriptionItem).row(); |
599 mFormModel->indexFromItem(mDescriptionItem).row(); |
|
600 |
|
601 QModelIndex modelIndex = mFormModel->indexFromItem(mDescriptionItem); |
575 |
602 |
576 mDescriptionItem->setContentWidgetData("maxRows", MaxRowsInTextItem); |
603 mDescriptionItem->setContentWidgetData("maxRows", MaxRowsInTextItem); |
577 mDescriptionItem->setContentWidgetData( |
604 mDescriptionItem->setContentWidgetData( |
578 QString("text"), mOwner->mModifiedNote.description()); |
605 QString("text"), mOwner->mModifiedNote.description()); |
579 |
606 |
580 mDataForm->addConnection( |
607 mDataForm->addConnection( |
581 mDescriptionItem, SIGNAL(textChanged(const QString)), |
608 mDescriptionItem, SIGNAL(textChanged(const QString)), |
582 this, SLOT(updateDescription(const QString))); |
609 this, SLOT(updateDescription(const QString))); |
|
610 |
|
611 HbDataFormViewItem* view_Item = static_cast<HbDataFormViewItem*>( |
|
612 static_cast<HbAbstractItemView*>(mDataForm)->itemByIndex(modelIndex)); |
|
613 mDataForm->scrollTo(modelIndex,HbAbstractItemView::PositionAtCenter); |
|
614 |
|
615 if(view_Item) { |
|
616 HbLineEdit* lineEdit = static_cast<HbLineEdit*>(view_Item->dataItemContentWidget()); |
|
617 if ( lineEdit ) { |
|
618 |
|
619 lineEdit->setFocus(Qt::OtherFocusReason); |
|
620 |
|
621 QInputContext *ic = qApp->inputContext(); |
|
622 if (ic) { |
|
623 QEvent *openEvent = new QEvent(QEvent::RequestSoftwareInputPanel); |
|
624 ic->filterEvent(openEvent); |
|
625 delete openEvent; |
|
626 } |
|
627 } |
|
628 |
|
629 } |
|
630 |
583 OstTraceFunctionExit0( NOTESTODOEDITOR_INSERTDESCRIPTIONITEM_EXIT ); |
631 OstTraceFunctionExit0( NOTESTODOEDITOR_INSERTDESCRIPTIONITEM_EXIT ); |
584 } |
632 } |
585 |
633 |
586 /*! |
634 /*! |
587 Inserts actions to the view menu. |
635 Inserts actions to the view menu. |
616 |
664 |
617 // Cleanup. |
665 // Cleanup. |
618 disconnect( |
666 disconnect( |
619 action, SIGNAL(triggered()), |
667 action, SIGNAL(triggered()), |
620 this, SLOT(saveTodo())); |
668 this, SLOT(saveTodo())); |
621 |
669 //if editor is open in background, and user close the app from task switcher |
|
670 //entry should get saved |
|
671 disconnect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), |
|
672 this, SLOT(forcedExit())); |
|
673 |
622 mOwner->editingCompleted(status); |
674 mOwner->editingCompleted(status); |
623 } |
675 } |
624 OstTraceFunctionExit0( NOTESTODOEDITOR_SAVETODO_EXIT ); |
676 OstTraceFunctionExit0( NOTESTODOEDITOR_SAVETODO_EXIT ); |
625 } |
677 } |
626 |
678 |
647 OstTraceFunctionEntry0( NOTESTODOEDITOR_HANDLEADDDESCRIPTIONACTION_ENTRY ); |
699 OstTraceFunctionEntry0( NOTESTODOEDITOR_HANDLEADDDESCRIPTIONACTION_ENTRY ); |
648 // Now we add the description item here. |
700 // Now we add the description item here. |
649 insertDescriptionItem(); |
701 insertDescriptionItem(); |
650 |
702 |
651 // Update the text in the menu action. |
703 // Update the text in the menu action. |
652 mDescriptionAction->setText(hbTrId("txt_notes_opt_remove_description")); |
704 mDescriptionAction->setText(hbTrId("txt_calendar_opt_remove_description")); |
653 |
705 |
654 disconnect( |
706 disconnect( |
655 mDescriptionAction, SIGNAL(triggered()), |
707 mDescriptionAction, SIGNAL(triggered()), |
656 this, SLOT(handleAddDescriptionAction())); |
708 this, SLOT(handleAddDescriptionAction())); |
657 |
709 |
673 |
725 |
674 // Now we remove the Description data form item. |
726 // Now we remove the Description data form item. |
675 mFormModel->removeItem(mFormModel->item(mDescriptionItemIndex)); |
727 mFormModel->removeItem(mFormModel->item(mDescriptionItemIndex)); |
676 |
728 |
677 // Update the text in the menu action. |
729 // Update the text in the menu action. |
678 mDescriptionAction->setText(hbTrId("txt_notes_opt_add_description")); |
730 mDescriptionAction->setText(hbTrId("txt_calendar_opt_add_description")); |
679 |
731 |
680 disconnect( |
732 disconnect( |
681 mDescriptionAction, SIGNAL(triggered()), |
733 mDescriptionAction, SIGNAL(triggered()), |
682 this, SLOT(handleRemoveDescriptionAction())); |
734 this, SLOT(handleRemoveDescriptionAction())); |
683 |
735 |