179 |
179 |
180 // Create the dialog. |
180 // Create the dialog. |
181 mTimePickerDialog = new HbDialog; |
181 mTimePickerDialog = new HbDialog; |
182 mTimePickerDialog->setTimeout(HbDialog::NoTimeout); |
182 mTimePickerDialog->setTimeout(HbDialog::NoTimeout); |
183 mTimePickerDialog->setDismissPolicy(HbDialog::NoDismiss); |
183 mTimePickerDialog->setDismissPolicy(HbDialog::NoDismiss); |
|
184 mTimePickerDialog->setAttribute(Qt::WA_DeleteOnClose, true); |
184 |
185 |
185 // Set the heading for the dialog. |
186 // Set the heading for the dialog. |
186 HbLabel * timeLabel = new HbLabel("Time", mTimePickerDialog); |
187 HbLabel * timeLabel = new HbLabel("Time", mTimePickerDialog); |
187 mTimePickerDialog->setHeadingWidget(timeLabel); |
188 mTimePickerDialog->setHeadingWidget(timeLabel); |
188 // Create the tumbler. |
189 // Create the tumbler. |
189 HbDateTimePicker *timePicker = new HbDateTimePicker(mTimePickerDialog); |
190 HbDateTimePicker *timePicker = new HbDateTimePicker(mTimePickerDialog); |
190 |
191 |
191 // Set the format for time picker. |
192 // Set the format for time picker. |
192 timePicker->setDisplayFormat(mNotesTodoeditorPvt->timeFormatString()); |
193 timePicker->setDisplayFormat(mNotesTodoeditorPvt->timeFormatString()); |
193 // Set the time needs to be displayed in time picker. |
194 // Set the time needs to be displayed in time picker. |
194 timePicker->setTime(QTime::fromString(mTimeWidget->text(), |
195 timePicker->setTime(QTime::fromString(mTimeWidget->text(), |
195 mNotesTodoeditorPvt->timeFormatString())); |
196 mNotesTodoeditorPvt->timeFormatString())); |
196 |
197 |
197 // Set the tumbler as the content widget. |
198 // Set the tumbler as the content widget. |
198 mTimePickerDialog->setContentWidget(timePicker); |
199 mTimePickerDialog->setContentWidget(timePicker); |
199 |
200 |
200 |
201 mOkAction = new HbAction( |
201 HbAction *okAction = new HbAction(QString("Ok"), mTimePickerDialog); |
202 hbTrId("txt_common_button_ok"), mTimePickerDialog); |
202 mTimePickerDialog->setPrimaryAction(okAction); |
203 mTimePickerDialog->addAction(mOkAction); |
203 connect( |
204 |
204 okAction, SIGNAL(triggered()), |
205 mCancelAction = new HbAction( |
205 this, SLOT(handleOkAction())); |
206 hbTrId("txt_common_button_cancel"), mTimePickerDialog); |
206 |
207 mTimePickerDialog->addAction(mCancelAction); |
207 HbAction *cancelAction = new HbAction(QString("Cancel"), mTimePickerDialog); |
208 |
208 mTimePickerDialog->setSecondaryAction(cancelAction); |
209 mTimePickerDialog->open(this, SLOT(selectedAction(HbAction *))); |
209 |
|
210 connect( |
|
211 cancelAction, SIGNAL(triggered()), |
|
212 this, SLOT(handleCancelAction())); |
|
213 |
|
214 mTimePickerDialog->exec(); |
|
215 } |
210 } |
216 |
211 |
217 /*! |
212 /*! |
218 Launches the date picker dialog. |
213 Launches the date picker dialog. |
219 */ |
214 */ |
225 |
220 |
226 // Create the dialog. |
221 // Create the dialog. |
227 mDatePickerDialog = new HbDialog; |
222 mDatePickerDialog = new HbDialog; |
228 mDatePickerDialog->setTimeout(HbDialog::NoTimeout); |
223 mDatePickerDialog->setTimeout(HbDialog::NoTimeout); |
229 mDatePickerDialog->setDismissPolicy(HbDialog::NoDismiss); |
224 mDatePickerDialog->setDismissPolicy(HbDialog::NoDismiss); |
230 |
225 mDatePickerDialog->setAttribute(Qt::WA_DeleteOnClose, true); |
|
226 |
231 // Set the heading for the dialog. |
227 // Set the heading for the dialog. |
232 HbLabel * timeLabel = new HbLabel("Date", mDatePickerDialog); |
228 HbLabel * timeLabel = new HbLabel("Date", mDatePickerDialog); |
233 mDatePickerDialog->setHeadingWidget(timeLabel); |
229 mDatePickerDialog->setHeadingWidget(timeLabel); |
234 |
230 |
235 // Create the tumbler. |
231 // Create the tumbler. |
236 HbDateTimePicker *datePicker = new HbDateTimePicker(mDatePickerDialog); |
232 HbDateTimePicker *datePicker = new HbDateTimePicker(mDatePickerDialog); |
237 // Set the min/max date for the editor. |
233 // Set the min/max date for the editor. |
238 datePicker->setDateRange(QDate::fromString("01/01/1900", |
234 datePicker->setDateRange(QDate::fromString("01/01/1900", |
239 mNotesTodoeditorPvt->dateFormatString()), QDate::fromString("31/12/2100", |
235 mNotesTodoeditorPvt->dateFormatString()), QDate::fromString("31/12/2100", |
240 mNotesTodoeditorPvt->dateFormatString())); |
236 mNotesTodoeditorPvt->dateFormatString())); |
241 |
237 |
242 // Set the date format in date picker. |
238 // Set the date format in date picker. |
243 datePicker->setDisplayFormat(mNotesTodoeditorPvt->dateFormatString()); |
239 datePicker->setDisplayFormat(mNotesTodoeditorPvt->dateFormatString()); |
244 // Set the date needs to be in focus in date picker. |
240 // Set the date needs to be in focus in date picker. |
245 datePicker->setDate(QDate::fromString(mDateWidget->text(), |
241 datePicker->setDate(QDate::fromString(mDateWidget->text(), |
246 mNotesTodoeditorPvt->dateFormatString())); |
242 mNotesTodoeditorPvt->dateFormatString())); |
247 |
243 |
248 |
244 |
249 // Set the tumbler as the content widget. |
245 // Set the tumbler as the content widget. |
250 mDatePickerDialog->setContentWidget(datePicker); |
246 mDatePickerDialog->setContentWidget(datePicker); |
251 |
247 |
252 |
248 mOkAction = new HbAction( |
253 HbAction *okAction = new HbAction(QString("Ok"), mDatePickerDialog); |
249 hbTrId("txt_common_button_ok"), mDatePickerDialog); |
254 mDatePickerDialog->setPrimaryAction(okAction); |
250 mDatePickerDialog->addAction(mOkAction); |
255 connect( |
251 |
256 okAction, SIGNAL(triggered()), |
252 mCancelAction = new HbAction( |
257 this, SLOT(handleOkAction())); |
253 hbTrId("txt_common_button_cancel"), mDatePickerDialog); |
258 |
254 mDatePickerDialog->addAction(mCancelAction); |
259 HbAction *cancelAction = new HbAction(QString("Cancel"), mDatePickerDialog); |
255 |
260 mDatePickerDialog->setSecondaryAction(cancelAction); |
256 mDatePickerDialog->open(this, SLOT(selectedAction(HbAction *))); |
261 connect( |
257 } |
262 cancelAction, SIGNAL(triggered()), |
258 |
263 this, SLOT(handleCancelAction())); |
259 /* |
264 |
260 Launches date picker for selecting the due date |
265 mDatePickerDialog->exec(); |
261 */ |
266 } |
262 void NotesTodoEditorCustomItem::selectDueDate() |
|
263 { |
|
264 if( mDueDateItem->isDown()) { |
|
265 mDueDateItem->setDown(false); |
|
266 return; |
|
267 } |
|
268 |
|
269 mDueDatePickerIsActive = true; |
|
270 |
|
271 if (mDatePickerDialog) { |
|
272 delete mDatePickerDialog; |
|
273 } |
|
274 |
|
275 // Create the dialog. |
|
276 mDatePickerDialog = new HbDialog; |
|
277 mDatePickerDialog->setTimeout(HbDialog::NoTimeout); |
|
278 mDatePickerDialog->setDismissPolicy(HbDialog::NoDismiss); |
|
279 mDatePickerDialog->setAttribute(Qt::WA_DeleteOnClose, true); |
|
280 |
|
281 // Create date picker |
|
282 HbDateTimePicker *datePicker = new HbDateTimePicker(mDatePickerDialog); |
|
283 // Set the min/max date for the editor. |
|
284 datePicker->setDateRange(QDate::fromString("01/01/1900", |
|
285 mNotesTodoeditorPvt->dateFormatString()), QDate::fromString("31/12/2100", |
|
286 mNotesTodoeditorPvt->dateFormatString())); |
|
287 |
|
288 // Set the format of date picker. |
|
289 datePicker->setDisplayFormat(mNotesTodoeditorPvt->dateFormatString()); |
|
290 // Set the date needs to be displayed in datepicker. |
|
291 datePicker->setDate(QDate::fromString(mDueDateItem->text(), |
|
292 mNotesTodoeditorPvt->dateFormatString())); |
|
293 |
|
294 // Set the heading text |
|
295 HbLabel *label = new HbLabel(hbTrId("txt_notes_formlabel_due_date")); |
|
296 mDatePickerDialog->setHeadingWidget(label); |
|
297 |
|
298 // Set the tumbler as the content widget. |
|
299 mDatePickerDialog->setContentWidget(datePicker); |
|
300 |
|
301 mOkAction = new HbAction( |
|
302 hbTrId("txt_common_button_ok"), mDatePickerDialog); |
|
303 mDatePickerDialog->addAction(mOkAction); |
|
304 |
|
305 mCancelAction = new HbAction( |
|
306 hbTrId("txt_common_button_cancel"), mDatePickerDialog); |
|
307 mDatePickerDialog->addAction(mCancelAction); |
|
308 |
|
309 mDatePickerDialog->open(this, SLOT(selectedAction(HbAction *))); |
|
310 } |
|
311 |
|
312 /*! |
|
313 Slot to handle the selected action. |
|
314 */ |
|
315 void NotesTodoEditorCustomItem::selectedAction(HbAction *action) |
|
316 { |
|
317 if (action == mOkAction) { |
|
318 handleOkAction(); |
|
319 } |
|
320 } |
|
321 |
267 /*! |
322 /*! |
268 Handles the ok action of date/time picker dialog. |
323 Handles the ok action of date/time picker dialog. |
269 */ |
324 */ |
270 void NotesTodoEditorCustomItem::handleOkAction() |
325 void NotesTodoEditorCustomItem::handleOkAction() |
271 { |
326 { |
337 (HbDataFormModelItem::CustomItemBase + AlarmDateItemOffset) |
392 (HbDataFormModelItem::CustomItemBase + AlarmDateItemOffset) |
338 == itemType)) { |
393 == itemType)) { |
339 alarmDateItem->setContentWidgetData("alarmDate",dueDateText); |
394 alarmDateItem->setContentWidgetData("alarmDate",dueDateText); |
340 } |
395 } |
341 } |
396 } |
342 |
|
343 handleCancelAction(); |
|
344 } |
|
345 /*! |
|
346 Handles the ok action of date/time picker dialog. |
|
347 */ |
|
348 void NotesTodoEditorCustomItem::handleCancelAction() |
|
349 { |
|
350 // Close the dialog. |
|
351 if (mDatePickerDialog) { |
|
352 mDatePickerDialog->close(); |
|
353 mDatePickerDialog->deleteLater(); |
|
354 }else { |
|
355 mTimePickerDialog->close(); |
|
356 mTimePickerDialog->deleteLater(); |
|
357 } |
|
358 } |
|
359 |
|
360 /* |
|
361 Launches date picker for selecting the due date |
|
362 */ |
|
363 void NotesTodoEditorCustomItem::selectDueDate() |
|
364 { |
|
365 if( mDueDateItem->isDown()) { |
|
366 mDueDateItem->setDown(false); |
|
367 return; |
|
368 } |
|
369 |
|
370 mDueDatePickerIsActive = true; |
|
371 |
|
372 if (mDatePickerDialog) { |
|
373 delete mDatePickerDialog; |
|
374 } |
|
375 |
|
376 // Create the dialog. |
|
377 mDatePickerDialog = new HbDialog; |
|
378 mDatePickerDialog->setTimeout(HbDialog::NoTimeout); |
|
379 mDatePickerDialog->setDismissPolicy(HbDialog::NoDismiss); |
|
380 |
|
381 // Create date picker |
|
382 HbDateTimePicker *datePicker = new HbDateTimePicker(mDatePickerDialog); |
|
383 // Set the min/max date for the editor. |
|
384 datePicker->setDateRange(QDate::fromString("01/01/1900", |
|
385 mNotesTodoeditorPvt->dateFormatString()), QDate::fromString("31/12/2100", |
|
386 mNotesTodoeditorPvt->dateFormatString())); |
|
387 |
|
388 // Set the format of date picker. |
|
389 datePicker->setDisplayFormat(mNotesTodoeditorPvt->dateFormatString()); |
|
390 // Set the date needs to be displayed in datepicker. |
|
391 datePicker->setDate(QDate::fromString(mDueDateItem->text(), |
|
392 mNotesTodoeditorPvt->dateFormatString())); |
|
393 |
|
394 // Set the heading text |
|
395 HbLabel *label = new HbLabel(hbTrId("txt_notes_formlabel_due_date")); |
|
396 mDatePickerDialog->setHeadingWidget(label); |
|
397 |
|
398 // Add actions to date picker |
|
399 HbAction *okAction = new HbAction(tr("Ok")); |
|
400 mDatePickerDialog->setPrimaryAction(okAction); |
|
401 connect( |
|
402 okAction, SIGNAL(triggered()), |
|
403 this, SLOT(handleOkAction())); |
|
404 |
|
405 HbAction *cancelAction = new HbAction(tr("Cancel")); |
|
406 mDatePickerDialog->setSecondaryAction(cancelAction); |
|
407 connect( |
|
408 cancelAction, SIGNAL(triggered()), |
|
409 this, SLOT(handleCancelAction())); |
|
410 |
|
411 mDatePickerDialog->setContentWidget(datePicker); |
|
412 mDatePickerDialog->exec(); |
|
413 } |
397 } |
414 |
398 |
415 // End of file --Don't delete. |
399 // End of file --Don't delete. |