--- a/notes/notesui/noteseditor/src/notestodoeditorcustomitem.cpp Mon May 03 12:30:32 2010 +0300
+++ b/notes/notesui/noteseditor/src/notestodoeditorcustomitem.cpp Mon Jun 28 15:22:02 2010 +0530
@@ -181,13 +181,14 @@
mTimePickerDialog = new HbDialog;
mTimePickerDialog->setTimeout(HbDialog::NoTimeout);
mTimePickerDialog->setDismissPolicy(HbDialog::NoDismiss);
+ mTimePickerDialog->setAttribute(Qt::WA_DeleteOnClose, true);
// Set the heading for the dialog.
HbLabel * timeLabel = new HbLabel("Time", mTimePickerDialog);
mTimePickerDialog->setHeadingWidget(timeLabel);
// Create the tumbler.
HbDateTimePicker *timePicker = new HbDateTimePicker(mTimePickerDialog);
-
+
// Set the format for time picker.
timePicker->setDisplayFormat(mNotesTodoeditorPvt->timeFormatString());
// Set the time needs to be displayed in time picker.
@@ -197,21 +198,15 @@
// Set the tumbler as the content widget.
mTimePickerDialog->setContentWidget(timePicker);
-
- HbAction *okAction = new HbAction(QString("Ok"), mTimePickerDialog);
- mTimePickerDialog->setPrimaryAction(okAction);
- connect(
- okAction, SIGNAL(triggered()),
- this, SLOT(handleOkAction()));
+ mOkAction = new HbAction(
+ hbTrId("txt_common_button_ok"), mTimePickerDialog);
+ mTimePickerDialog->addAction(mOkAction);
- HbAction *cancelAction = new HbAction(QString("Cancel"), mTimePickerDialog);
- mTimePickerDialog->setSecondaryAction(cancelAction);
+ mCancelAction = new HbAction(
+ hbTrId("txt_common_button_cancel"), mTimePickerDialog);
+ mTimePickerDialog->addAction(mCancelAction);
- connect(
- cancelAction, SIGNAL(triggered()),
- this, SLOT(handleCancelAction()));
-
- mTimePickerDialog->exec();
+ mTimePickerDialog->open(this, SLOT(selectedAction(HbAction *)));
}
/*!
@@ -227,7 +222,8 @@
mDatePickerDialog = new HbDialog;
mDatePickerDialog->setTimeout(HbDialog::NoTimeout);
mDatePickerDialog->setDismissPolicy(HbDialog::NoDismiss);
-
+ mDatePickerDialog->setAttribute(Qt::WA_DeleteOnClose, true);
+
// Set the heading for the dialog.
HbLabel * timeLabel = new HbLabel("Date", mDatePickerDialog);
mDatePickerDialog->setHeadingWidget(timeLabel);
@@ -238,32 +234,91 @@
datePicker->setDateRange(QDate::fromString("01/01/1900",
mNotesTodoeditorPvt->dateFormatString()), QDate::fromString("31/12/2100",
mNotesTodoeditorPvt->dateFormatString()));
-
+
// Set the date format in date picker.
datePicker->setDisplayFormat(mNotesTodoeditorPvt->dateFormatString());
// Set the date needs to be in focus in date picker.
datePicker->setDate(QDate::fromString(mDateWidget->text(),
mNotesTodoeditorPvt->dateFormatString()));
-
+
// Set the tumbler as the content widget.
mDatePickerDialog->setContentWidget(datePicker);
+ mOkAction = new HbAction(
+ hbTrId("txt_common_button_ok"), mDatePickerDialog);
+ mDatePickerDialog->addAction(mOkAction);
- HbAction *okAction = new HbAction(QString("Ok"), mDatePickerDialog);
- mDatePickerDialog->setPrimaryAction(okAction);
- connect(
- okAction, SIGNAL(triggered()),
- this, SLOT(handleOkAction()));
+ mCancelAction = new HbAction(
+ hbTrId("txt_common_button_cancel"), mDatePickerDialog);
+ mDatePickerDialog->addAction(mCancelAction);
+
+ mDatePickerDialog->open(this, SLOT(selectedAction(HbAction *)));
+}
+
+/*
+ Launches date picker for selecting the due date
+ */
+void NotesTodoEditorCustomItem::selectDueDate()
+{
+ if( mDueDateItem->isDown()) {
+ mDueDateItem->setDown(false);
+ return;
+ }
+
+ mDueDatePickerIsActive = true;
+
+ if (mDatePickerDialog) {
+ delete mDatePickerDialog;
+ }
- HbAction *cancelAction = new HbAction(QString("Cancel"), mDatePickerDialog);
- mDatePickerDialog->setSecondaryAction(cancelAction);
- connect(
- cancelAction, SIGNAL(triggered()),
- this, SLOT(handleCancelAction()));
+ // Create the dialog.
+ mDatePickerDialog = new HbDialog;
+ mDatePickerDialog->setTimeout(HbDialog::NoTimeout);
+ mDatePickerDialog->setDismissPolicy(HbDialog::NoDismiss);
+ mDatePickerDialog->setAttribute(Qt::WA_DeleteOnClose, true);
+
+ // Create date picker
+ HbDateTimePicker *datePicker = new HbDateTimePicker(mDatePickerDialog);
+ // Set the min/max date for the editor.
+ datePicker->setDateRange(QDate::fromString("01/01/1900",
+ mNotesTodoeditorPvt->dateFormatString()), QDate::fromString("31/12/2100",
+ mNotesTodoeditorPvt->dateFormatString()));
+
+ // Set the format of date picker.
+ datePicker->setDisplayFormat(mNotesTodoeditorPvt->dateFormatString());
+ // Set the date needs to be displayed in datepicker.
+ datePicker->setDate(QDate::fromString(mDueDateItem->text(),
+ mNotesTodoeditorPvt->dateFormatString()));
+
+ // Set the heading text
+ HbLabel *label = new HbLabel(hbTrId("txt_notes_formlabel_due_date"));
+ mDatePickerDialog->setHeadingWidget(label);
- mDatePickerDialog->exec();
+ // Set the tumbler as the content widget.
+ mDatePickerDialog->setContentWidget(datePicker);
+
+ mOkAction = new HbAction(
+ hbTrId("txt_common_button_ok"), mDatePickerDialog);
+ mDatePickerDialog->addAction(mOkAction);
+
+ mCancelAction = new HbAction(
+ hbTrId("txt_common_button_cancel"), mDatePickerDialog);
+ mDatePickerDialog->addAction(mCancelAction);
+
+ mDatePickerDialog->open(this, SLOT(selectedAction(HbAction *)));
}
+
+/*!
+ Slot to handle the selected action.
+ */
+void NotesTodoEditorCustomItem::selectedAction(HbAction *action)
+{
+ if (action == mOkAction) {
+ handleOkAction();
+ }
+}
+
/*!
Handles the ok action of date/time picker dialog.
*/
@@ -339,77 +394,6 @@
alarmDateItem->setContentWidgetData("alarmDate",dueDateText);
}
}
-
- handleCancelAction();
-}
-/*!
- Handles the ok action of date/time picker dialog.
- */
-void NotesTodoEditorCustomItem::handleCancelAction()
-{
- // Close the dialog.
- if (mDatePickerDialog) {
- mDatePickerDialog->close();
- mDatePickerDialog->deleteLater();
- }else {
- mTimePickerDialog->close();
- mTimePickerDialog->deleteLater();
- }
-}
-
-/*
- Launches date picker for selecting the due date
- */
-void NotesTodoEditorCustomItem::selectDueDate()
-{
- if( mDueDateItem->isDown()) {
- mDueDateItem->setDown(false);
- return;
- }
-
- mDueDatePickerIsActive = true;
-
- if (mDatePickerDialog) {
- delete mDatePickerDialog;
- }
-
- // Create the dialog.
- mDatePickerDialog = new HbDialog;
- mDatePickerDialog->setTimeout(HbDialog::NoTimeout);
- mDatePickerDialog->setDismissPolicy(HbDialog::NoDismiss);
-
- // Create date picker
- HbDateTimePicker *datePicker = new HbDateTimePicker(mDatePickerDialog);
- // Set the min/max date for the editor.
- datePicker->setDateRange(QDate::fromString("01/01/1900",
- mNotesTodoeditorPvt->dateFormatString()), QDate::fromString("31/12/2100",
- mNotesTodoeditorPvt->dateFormatString()));
-
- // Set the format of date picker.
- datePicker->setDisplayFormat(mNotesTodoeditorPvt->dateFormatString());
- // Set the date needs to be displayed in datepicker.
- datePicker->setDate(QDate::fromString(mDueDateItem->text(),
- mNotesTodoeditorPvt->dateFormatString()));
-
- // Set the heading text
- HbLabel *label = new HbLabel(hbTrId("txt_notes_formlabel_due_date"));
- mDatePickerDialog->setHeadingWidget(label);
-
- // Add actions to date picker
- HbAction *okAction = new HbAction(tr("Ok"));
- mDatePickerDialog->setPrimaryAction(okAction);
- connect(
- okAction, SIGNAL(triggered()),
- this, SLOT(handleOkAction()));
-
- HbAction *cancelAction = new HbAction(tr("Cancel"));
- mDatePickerDialog->setSecondaryAction(cancelAction);
- connect(
- cancelAction, SIGNAL(triggered()),
- this, SLOT(handleCancelAction()));
-
- mDatePickerDialog->setContentWidget(datePicker);
- mDatePickerDialog->exec();
}
// End of file --Don't delete.