69 |
68 |
70 \return HbAbstractViewItem* Pointer to NotesTodoEditorCustomItem object. |
69 \return HbAbstractViewItem* Pointer to NotesTodoEditorCustomItem object. |
71 */ |
70 */ |
72 HbAbstractViewItem* NotesTodoEditorCustomItem::createItem() |
71 HbAbstractViewItem* NotesTodoEditorCustomItem::createItem() |
73 { |
72 { |
74 qDebug() << "notes: NotesTodoEditorCustomItem::createItem <-->"; |
|
75 |
|
76 return new NotesTodoEditorCustomItem(*this); |
73 return new NotesTodoEditorCustomItem(*this); |
77 } |
74 } |
78 |
75 |
79 /*! |
76 /*! |
80 Create customwidget. |
77 Create customwidget. |
81 |
78 |
82 \return HbWidget* Holds the custom widget pointer. |
79 \return HbWidget* Holds the custom widget pointer. |
83 */ |
80 */ |
84 HbWidget* NotesTodoEditorCustomItem::createCustomWidget() |
81 HbWidget* NotesTodoEditorCustomItem::createCustomWidget() |
85 { |
82 { |
86 qDebug() << "notes: NotesTodoEditorCustomItem::createCustomWidget -->"; |
|
87 |
|
88 HbDataFormModelItem::DataItemType itemType = |
83 HbDataFormModelItem::DataItemType itemType = |
89 static_cast<HbDataFormModelItem::DataItemType>(modelIndex() |
84 static_cast<HbDataFormModelItem::DataItemType>(modelIndex() |
90 .data(HbDataFormModelItem::ItemTypeRole).toInt()); |
85 .data(HbDataFormModelItem::ItemTypeRole).toInt()); |
91 |
86 |
92 switch(itemType) { |
87 switch(itemType) { |
114 mDateWidget = new HbPushButton(); |
109 mDateWidget = new HbPushButton(); |
115 layout->addItem(mDateWidget); |
110 layout->addItem(mDateWidget); |
116 connect( |
111 connect( |
117 mDateWidget, SIGNAL(clicked()), |
112 mDateWidget, SIGNAL(clicked()), |
118 this, SLOT(launchDatePicker())); |
113 this, SLOT(launchDatePicker())); |
119 |
|
120 qDebug() << |
|
121 "notes: NotesTodoEditorCustomItem::createCustomWidget <--"; |
|
122 return widget; |
114 return widget; |
123 } |
115 } |
124 case HbDataFormModelItem::CustomItemBase + ItemOffsetUnKnown: |
116 case HbDataFormModelItem::CustomItemBase + ItemOffsetUnKnown: |
125 default: |
117 default: |
126 qDebug() << |
|
127 "notes: NotesTodoEditorCustomItem::createCustomWidget <--"; |
|
128 return 0; |
118 return 0; |
129 } |
119 } |
130 } |
120 } |
131 |
121 |
132 /*! |
122 /*! |
181 /*! |
171 /*! |
182 Launches the time picker dialog. |
172 Launches the time picker dialog. |
183 */ |
173 */ |
184 void NotesTodoEditorCustomItem::launchTimePicker() |
174 void NotesTodoEditorCustomItem::launchTimePicker() |
185 { |
175 { |
186 qDebug() << "notes: NotesTodoEditorCustomItem::launchTimePicker -->"; |
|
187 |
|
188 if (mTimePickerDialog) { |
176 if (mTimePickerDialog) { |
189 delete mTimePickerDialog; |
177 delete mTimePickerDialog; |
190 } |
178 } |
191 |
179 |
192 // Create the dialog. |
180 // Create the dialog. |
197 // Set the heading for the dialog. |
185 // Set the heading for the dialog. |
198 HbLabel * timeLabel = new HbLabel("Time", mTimePickerDialog); |
186 HbLabel * timeLabel = new HbLabel("Time", mTimePickerDialog); |
199 mTimePickerDialog->setHeadingWidget(timeLabel); |
187 mTimePickerDialog->setHeadingWidget(timeLabel); |
200 // Create the tumbler. |
188 // Create the tumbler. |
201 HbDateTimePicker *timePicker = new HbDateTimePicker(mTimePickerDialog); |
189 HbDateTimePicker *timePicker = new HbDateTimePicker(mTimePickerDialog); |
202 |
190 |
|
191 // Set the format for time picker. |
|
192 timePicker->setDisplayFormat(mNotesTodoeditorPvt->timeFormatString()); |
|
193 // Set the time needs to be displayed in time picker. |
203 timePicker->setTime(QTime::fromString(mTimeWidget->text(), |
194 timePicker->setTime(QTime::fromString(mTimeWidget->text(), |
204 mNotesTodoeditorPvt->timeFormatString())); |
195 mNotesTodoeditorPvt->timeFormatString())); |
205 |
196 |
206 timePicker->setDisplayFormat(mNotesTodoeditorPvt->timeFormatString()); |
|
207 // Set the tumbler as the content widget. |
197 // Set the tumbler as the content widget. |
208 mTimePickerDialog->setContentWidget(timePicker); |
198 mTimePickerDialog->setContentWidget(timePicker); |
209 |
199 |
210 |
200 |
211 HbAction *okAction = new HbAction(QString("Ok"), mTimePickerDialog); |
201 HbAction *okAction = new HbAction(QString("Ok"), mTimePickerDialog); |
220 connect( |
210 connect( |
221 cancelAction, SIGNAL(triggered()), |
211 cancelAction, SIGNAL(triggered()), |
222 this, SLOT(handleCancelAction())); |
212 this, SLOT(handleCancelAction())); |
223 |
213 |
224 mTimePickerDialog->exec(); |
214 mTimePickerDialog->exec(); |
225 |
|
226 qDebug() << "notes: NotesTodoEditorCustomItem::launchTimePicker <--"; |
|
227 } |
215 } |
228 |
216 |
229 /*! |
217 /*! |
230 Launches the date picker dialog. |
218 Launches the date picker dialog. |
231 */ |
219 */ |
232 void NotesTodoEditorCustomItem::launchDatePicker() |
220 void NotesTodoEditorCustomItem::launchDatePicker() |
233 { |
221 { |
234 qDebug() << "notes: NotesTodoEditorCustomItem::launcDatePicker -->"; |
|
235 |
|
236 if (mDatePickerDialog) { |
222 if (mDatePickerDialog) { |
237 delete mDatePickerDialog; |
223 delete mDatePickerDialog; |
238 } |
224 } |
239 |
225 |
240 // Create the dialog. |
226 // Create the dialog. |
250 HbDateTimePicker *datePicker = new HbDateTimePicker(mDatePickerDialog); |
236 HbDateTimePicker *datePicker = new HbDateTimePicker(mDatePickerDialog); |
251 // Set the min/max date for the editor. |
237 // Set the min/max date for the editor. |
252 datePicker->setDateRange(QDate::fromString("01/01/1900", |
238 datePicker->setDateRange(QDate::fromString("01/01/1900", |
253 mNotesTodoeditorPvt->dateFormatString()), QDate::fromString("31/12/2100", |
239 mNotesTodoeditorPvt->dateFormatString()), QDate::fromString("31/12/2100", |
254 mNotesTodoeditorPvt->dateFormatString())); |
240 mNotesTodoeditorPvt->dateFormatString())); |
255 |
241 |
|
242 // Set the date format in date picker. |
|
243 datePicker->setDisplayFormat(mNotesTodoeditorPvt->dateFormatString()); |
|
244 // Set the date needs to be in focus in date picker. |
256 datePicker->setDate(QDate::fromString(mDateWidget->text(), |
245 datePicker->setDate(QDate::fromString(mDateWidget->text(), |
257 mNotesTodoeditorPvt->dateFormatString())); |
246 mNotesTodoeditorPvt->dateFormatString())); |
258 |
247 |
259 datePicker->setDisplayFormat(mNotesTodoeditorPvt->dateFormatString()); |
248 |
260 // Set the tumbler as the content widget. |
249 // Set the tumbler as the content widget. |
261 mDatePickerDialog->setContentWidget(datePicker); |
250 mDatePickerDialog->setContentWidget(datePicker); |
262 |
251 |
263 |
252 |
264 HbAction *okAction = new HbAction(QString("Ok"), mDatePickerDialog); |
253 HbAction *okAction = new HbAction(QString("Ok"), mDatePickerDialog); |
272 connect( |
261 connect( |
273 cancelAction, SIGNAL(triggered()), |
262 cancelAction, SIGNAL(triggered()), |
274 this, SLOT(handleCancelAction())); |
263 this, SLOT(handleCancelAction())); |
275 |
264 |
276 mDatePickerDialog->exec(); |
265 mDatePickerDialog->exec(); |
277 |
|
278 qDebug() << "notes: NotesTodoEditorCustomItem::launchDatePicker <--"; |
|
279 } |
266 } |
280 /*! |
267 /*! |
281 Handles the ok action of date/time picker dialog. |
268 Handles the ok action of date/time picker dialog. |
282 */ |
269 */ |
283 void NotesTodoEditorCustomItem::handleOkAction() |
270 void NotesTodoEditorCustomItem::handleOkAction() |
284 { |
271 { |
285 qDebug() << "notes: NotesTodoEditorCustomItem::handleOkAction -->"; |
|
286 |
|
287 HbExtendedLocale locale = HbExtendedLocale::system(); |
272 HbExtendedLocale locale = HbExtendedLocale::system(); |
288 |
273 |
289 HbDataFormModelItem *modelItem = |
274 HbDataFormModelItem *modelItem = |
290 static_cast<HbDataFormModel*>( |
275 static_cast<HbDataFormModel*>( |
291 itemView()->model())->itemFromIndex(modelIndex());; |
276 itemView()->model())->itemFromIndex(modelIndex());; |
354 alarmDateItem->setContentWidgetData("alarmDate",dueDateText); |
339 alarmDateItem->setContentWidgetData("alarmDate",dueDateText); |
355 } |
340 } |
356 } |
341 } |
357 |
342 |
358 handleCancelAction(); |
343 handleCancelAction(); |
359 |
|
360 qDebug() << "notes: NotesTodoEditorCustomItem::handleOkAction <--"; |
|
361 } |
344 } |
362 /*! |
345 /*! |
363 Handles the ok action of date/time picker dialog. |
346 Handles the ok action of date/time picker dialog. |
364 */ |
347 */ |
365 void NotesTodoEditorCustomItem::handleCancelAction() |
348 void NotesTodoEditorCustomItem::handleCancelAction() |
366 { |
349 { |
367 qDebug() << "notes: NotesTodoEditorCustomItem::handleCancelAction -->"; |
|
368 |
|
369 // Close the dialog. |
350 // Close the dialog. |
370 if (mDatePickerDialog) { |
351 if (mDatePickerDialog) { |
371 mDatePickerDialog->close(); |
352 mDatePickerDialog->close(); |
372 mDatePickerDialog->deleteLater(); |
353 mDatePickerDialog->deleteLater(); |
373 }else { |
354 }else { |
374 mTimePickerDialog->close(); |
355 mTimePickerDialog->close(); |
375 mTimePickerDialog->deleteLater(); |
356 mTimePickerDialog->deleteLater(); |
376 } |
357 } |
377 |
|
378 qDebug() << "notes: NotesTodoEditorCustomItem::handleCancelAction <--"; |
|
379 } |
358 } |
380 |
359 |
381 /* |
360 /* |
382 Launches date picker for selecting the due date |
361 Launches date picker for selecting the due date |
383 */ |
362 */ |
384 void NotesTodoEditorCustomItem::selectDueDate() |
363 void NotesTodoEditorCustomItem::selectDueDate() |
385 { |
364 { |
386 qDebug() <<"notes: NotesTodoEditorCustomItem::selectDueDate -->"; |
|
387 |
|
388 if( mDueDateItem->isDown()) { |
365 if( mDueDateItem->isDown()) { |
389 mDueDateItem->setDown(false); |
366 mDueDateItem->setDown(false); |
390 return; |
367 return; |
391 } |
368 } |
392 |
369 |
405 HbDateTimePicker *datePicker = new HbDateTimePicker(mDatePickerDialog); |
382 HbDateTimePicker *datePicker = new HbDateTimePicker(mDatePickerDialog); |
406 // Set the min/max date for the editor. |
383 // Set the min/max date for the editor. |
407 datePicker->setDateRange(QDate::fromString("01/01/1900", |
384 datePicker->setDateRange(QDate::fromString("01/01/1900", |
408 mNotesTodoeditorPvt->dateFormatString()), QDate::fromString("31/12/2100", |
385 mNotesTodoeditorPvt->dateFormatString()), QDate::fromString("31/12/2100", |
409 mNotesTodoeditorPvt->dateFormatString())); |
386 mNotesTodoeditorPvt->dateFormatString())); |
410 |
387 |
|
388 // Set the format of date picker. |
|
389 datePicker->setDisplayFormat(mNotesTodoeditorPvt->dateFormatString()); |
|
390 // Set the date needs to be displayed in datepicker. |
411 datePicker->setDate(QDate::fromString(mDueDateItem->text(), |
391 datePicker->setDate(QDate::fromString(mDueDateItem->text(), |
412 mNotesTodoeditorPvt->dateFormatString())); |
392 mNotesTodoeditorPvt->dateFormatString())); |
413 |
|
414 datePicker->setDisplayFormat(mNotesTodoeditorPvt->dateFormatString()); |
|
415 |
393 |
416 // Set the heading text |
394 // Set the heading text |
417 HbLabel *label = new HbLabel(hbTrId("txt_notes_formlabel_due_date")); |
395 HbLabel *label = new HbLabel(hbTrId("txt_notes_formlabel_due_date")); |
418 mDatePickerDialog->setHeadingWidget(label); |
396 mDatePickerDialog->setHeadingWidget(label); |
419 |
397 |
430 cancelAction, SIGNAL(triggered()), |
408 cancelAction, SIGNAL(triggered()), |
431 this, SLOT(handleCancelAction())); |
409 this, SLOT(handleCancelAction())); |
432 |
410 |
433 mDatePickerDialog->setContentWidget(datePicker); |
411 mDatePickerDialog->setContentWidget(datePicker); |
434 mDatePickerDialog->exec(); |
412 mDatePickerDialog->exec(); |
435 |
|
436 qDebug() <<"notes: NotesTodoEditorCustomItem::selectDueDate <--"; |
|
437 } |
413 } |
438 |
414 |
439 // End of file --Don't delete. |
415 // End of file --Don't delete. |