28 #include "hbstyleoption_p.h" |
28 #include "hbstyleoption_p.h" |
29 |
29 |
30 /*! |
30 /*! |
31 @beta |
31 @beta |
32 \class HbDateTimePicker |
32 \class HbDateTimePicker |
33 \brief HbDateTimePicker class provides a widget for picking the date, time, date and time. |
33 \brief HbDateTimePicker class provides a widget for picking the date, time, date and time. <br> |
|
34 |
34 By default date picker will be created, with date functionality only. |
35 By default date picker will be created, with date functionality only. |
35 For exclusive time or datetime picker creation, use QTime or QDateTime variable as parameter for the constructor. |
36 For exclusive time or datetime picker creation, use QTime or QDateTime variable as parameter for the constructor. |
36 \li Date and Time |
37 \li Date and Time |
37 \li Date |
38 \li Date |
38 \li Time |
39 \li Time |
39 |
40 |
|
41 Below is a sample code snippet for datetime picker creation: |
40 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,51} |
42 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,51} |
41 |
43 |
42 By default, display format is from HbExtendedLocale. User can set the format using \sa setDisplayFormat. |
44 By default, display format is from HbExtendedLocale. User can set the format using setDisplayFormat API. \sa setDisplayFormat.<br> |
43 Based on the display format the tumblers or sections will be rearranged. |
45 Based on the display format the tumblers or sections will be rearranged.<br> |
44 |
46 For each tumbler(TumbleView) in datetime picker, loopingEnabled property is always true.<br> |
45 HbDateTimePicker provides various date and time range functionalities. |
47 |
46 currently the date range is independent of the time range. |
48 HbDateTimePicker provides various date and time range functionalities.<br> |
|
49 Currently the date range is independent of the time range. |
47 \sa setDateRange \sa setTimeRange \sa setDateTimeRange |
50 \sa setDateRange \sa setTimeRange \sa setDateTimeRange |
48 \sa setMinimumTime \sa setMaximumTime \sa setMinimumDate \sa setMaximumDate |
51 \sa setMinimumTime \sa setMaximumTime \sa setMinimumDate \sa setMaximumDate |
49 \sa setMinimumDateTime \sa setMaximumDateTime |
52 \sa setMinimumDateTime \sa setMaximumDateTime |
|
53 |
|
54 \image html hbdatetimepicker_date.png "Datetime picker with date functionalities, in d/MMMM format" |
|
55 \image html hbdatetimepicker_time.png "Datetime picker with time functionalities, in h.m.AP format" |
|
56 |
|
57 <b>Note:</b>Graphics in the above images varies depending on theme. |
50 */ |
58 */ |
51 |
59 |
52 /*! |
60 /*! |
53 \fn void dateChanged(const QDate &date) |
61 \fn void dateChanged(const QDate &date) |
54 |
62 |
55 This signal is emitted when item selection changes in any of the date pickers in the datetimepicker widget. |
63 This signal is emitted when item selection changes in any of the date pickers(day, month, year) in the datetimepicker widget. |
56 |
64 |
57 \param date selected by the user. |
65 \param date selected by the user. |
58 |
66 |
59 */ |
67 */ |
60 |
68 |
61 /*! |
69 /*! |
62 \fn void timeChanged(const QTime &time) |
70 \fn void timeChanged(const QTime &time) |
63 |
71 |
64 This signal is emitted when item selection changes in any of the time pickers in the datetimepicker widget. |
72 This signal is emitted when item selection changes in any of the time pickers(hour, minute, second, am/pm) in the datetimepicker widget. |
65 \param time selected by the user. |
73 \param time selected by the user. |
66 |
74 |
67 */ |
75 */ |
68 |
76 |
69 /*! |
77 /*! |
70 \fn void dateTimeChanged(const QDateTime &datetime) |
78 \fn void dateTimeChanged(const QDateTime &datetime) |
71 |
79 |
72 This signal is emitted when item selection changes in any of the pickers in the datetimepicker widget. |
80 This signal is emitted when item selection changes in any of the date and time pickers in the datetimepicker widget. |
73 \param datetime selected by the user. |
81 \param datetime selected by the user. |
74 |
82 |
75 */ |
83 */ |
76 |
84 |
77 /*! |
85 /*! |
78 Constructs date picker widget by default. |
86 Constructs date picker widget by default. |
79 |
87 |
80 \param parent parent item. |
88 \param parent parent item for datetime picker widget. |
81 */ |
89 */ |
82 HbDateTimePicker::HbDateTimePicker( QGraphicsItem *parent ): |
90 HbDateTimePicker::HbDateTimePicker( QGraphicsItem *parent ): |
83 HbWidget(*new HbDateTimePickerPrivate, parent) |
91 HbWidget(*new HbDateTimePickerPrivate, parent) |
84 { |
92 { |
85 Q_D(HbDateTimePicker); |
93 Q_D(HbDateTimePicker); |
86 |
94 |
87 //no mode passed so it should take date as mode by default |
95 //no mode passed so it should take date as mode by default |
88 d->init(QVariant::Date); |
96 d->init(QVariant::Date); |
89 |
97 |
90 setDateTime(QDateTime::currentDateTime()); |
98 setDateTime(QDateTime::currentDateTime()); |
91 } |
99 } |
92 |
100 |
93 /*! |
101 /*! |
94 Constructs datetime picker widget. |
102 Constructs datetime picker widget with both date and time functionalities and with default locale's datetime format. |
95 |
103 \param datetime Value to be set on datetime picker widget, which has both date and time related tumblers. |
96 \param datetime QDateTime value. |
|
97 */ |
104 */ |
98 HbDateTimePicker::HbDateTimePicker(const QDateTime &datetime, QGraphicsItem *parent ): |
105 HbDateTimePicker::HbDateTimePicker(const QDateTime &datetime, QGraphicsItem *parent ): |
99 HbWidget(*new HbDateTimePickerPrivate, parent) |
106 HbWidget(*new HbDateTimePickerPrivate, parent) |
100 { |
107 { |
101 Q_D(HbDateTimePicker); |
108 Q_D(HbDateTimePicker); |
102 |
109 |
103 d->init(QVariant::DateTime); |
110 d->init(QVariant::DateTime); |
104 setDateTime(datetime); |
111 setDateTime(datetime); |
105 } |
112 } |
106 |
113 |
107 /*! |
114 /*! |
108 Constructs date picker widget with default locale's date format. |
115 Constructs datetime picker widget with only date functionalities and with default locale's date format. |
109 |
116 |
110 \param date QDate value. |
117 \param date QDate value. |
111 */ |
118 */ |
112 HbDateTimePicker::HbDateTimePicker(const QDate &date, QGraphicsItem *parent ): |
119 HbDateTimePicker::HbDateTimePicker(const QDate &date, QGraphicsItem *parent ): |
113 HbWidget(*new HbDateTimePickerPrivate, parent) |
120 HbWidget(*new HbDateTimePickerPrivate, parent) |
114 { |
121 { |
115 Q_D(HbDateTimePicker); |
122 Q_D(HbDateTimePicker); |
116 |
123 |
117 d->init(QVariant::Date); |
124 d->init(QVariant::Date); |
118 setDate(date); |
125 setDate(date); |
119 } |
126 } |
120 |
127 |
121 /*! |
128 /*! |
122 Constructs time picker widget with default locale's time format. |
129 Constructs datetime picker widget with only time functionalities and with with default locale's time format. |
123 |
130 |
124 \param time QTime value. |
131 \param time QTime value. |
125 */ |
132 */ |
126 HbDateTimePicker::HbDateTimePicker(const QTime &time, QGraphicsItem *pParent ): |
133 HbDateTimePicker::HbDateTimePicker(const QTime &time, QGraphicsItem *pParent ): |
127 HbWidget(*new HbDateTimePickerPrivate, pParent) |
134 HbWidget(*new HbDateTimePickerPrivate, pParent) |
128 { |
135 { |
129 Q_D(HbDateTimePicker); |
136 Q_D(HbDateTimePicker); |
130 |
137 |
131 d->init(QVariant::Time); |
138 d->init(QVariant::Time); |
132 setTime(time); |
139 setTime(time); |
133 } |
140 } |
134 |
141 |
135 /*! |
142 /*! |
136 Internal. Protected constructor for derivations. |
143 \internal |
|
144 Protected constructor for derivations. |
137 the default mode is DateTimeMode, if other mode is required, set the mDateTimeMode variable. |
145 the default mode is DateTimeMode, if other mode is required, set the mDateTimeMode variable. |
138 this does not set any default datetime, needs to be explicitly done in the derived constructor. |
146 this does not set any default datetime, needs to be explicitly done in the derived constructor. |
139 |
147 |
140 \sa setDateTime, setTime, setDate |
148 \sa setDateTime, setTime, setDate |
141 */ |
149 */ |
142 HbDateTimePicker::HbDateTimePicker(HbDateTimePickerPrivate &dd, QGraphicsItem *parent): |
150 HbDateTimePicker::HbDateTimePicker(HbDateTimePickerPrivate &dd, QGraphicsItem *parent): |
143 HbWidget(dd, parent) |
151 HbWidget(dd, parent) |
144 { |
152 { |
145 Q_D(HbDateTimePicker); |
153 Q_D(HbDateTimePicker); |
146 |
154 |
147 d->init(QVariant::DateTime); |
155 d->init(QVariant::DateTime); |
148 } |
156 } |
149 |
157 |
150 /*! |
158 /*! |
151 \reimp |
159 \reimp |
152 */ |
160 */ |
208 </TABLE> |
216 </TABLE> |
209 |
217 |
210 NOTE:setDisplayFormat works only when the seperators are mentioned in the format like 'dd.mm.yy' or 'dd mm yy', this |
218 NOTE:setDisplayFormat works only when the seperators are mentioned in the format like 'dd.mm.yy' or 'dd mm yy', this |
211 will be fixed in the future versions. |
219 will be fixed in the future versions. |
212 |
220 |
213 \param format is the display format in QString format. |
221 \param format is the display format, for datetime picker widget, in QString format. |
214 |
222 |
215 \sa displayFormat() |
223 \sa displayFormat() |
216 */ |
224 */ |
217 void HbDateTimePicker::setDisplayFormat(const QString &format) |
225 void HbDateTimePicker::setDisplayFormat(const QString &format) |
218 { |
226 { |
219 Q_D(HbDateTimePicker); |
227 Q_D(HbDateTimePicker); |
220 |
228 |
221 if(d->isFormatValid(format)){ |
229 if(d->isFormatValid(format)){ |
222 d->mFormat = format; |
230 d->mFormat = format; |
223 d->parseDisplayFormat(format); |
231 d->parseDisplayFormat(format); |
224 d->rearrangeTumbleViews(); |
232 d->rearrangeTumbleViews(); |
225 d->emitDateTimeChange(); |
233 d->emitDateTimeChange(); |
226 }//End If format is valid |
234 }//End If format is valid |
227 } |
235 } |
228 |
236 |
229 /*! |
237 /*! |
230 Returns the current date in QDate format. |
238 Returns the current date in QDate format. |
231 |
239 |
232 \return Date Picker's current date. |
240 \return current selected date in datetime picker. |
|
241 |
|
242 <b>Note:</b> The DocML does not support directly the properties which uses QDate/QTime/QDateTime as parameters. For the properties to work user has to pass date, time or datetime |
|
243 as a string, in a valid ISO date format. |
|
244 |
|
245 ISO 8601 extended format: either YYYY-MM-DD for dates or YYYY-MM-DDTHH:MM:SS for combined dates and times. |
|
246 |
|
247 \code |
|
248 ... |
|
249 <widget name="t:dtp" type="HbDateTimePicker"> |
|
250 <!-- 'date' is a QDate property of HbDateTimePicker. --> |
|
251 <string name="date" value="02-02-15" /> |
|
252 </widget> |
|
253 ... |
|
254 \endcode |
233 |
255 |
234 \sa setDate |
256 \sa setDate |
235 */ |
257 */ |
236 QDate HbDateTimePicker::date() const |
258 QDate HbDateTimePicker::date() const |
237 { |
259 { |
345 Q_D(HbDateTimePicker); |
409 Q_D(HbDateTimePicker); |
346 d->setDateTime(datetime); |
410 d->setDateTime(datetime); |
347 } |
411 } |
348 |
412 |
349 /*! |
413 /*! |
350 Returns minimum date time in QDateTime format. |
414 Returns minimum date time value set on datetime picker in QDateTime format. |
351 |
415 |
352 \return Minimum date and minimum time in QDateTime format. |
416 \return Minimum date and minimum time in QDateTime format. |
353 |
417 |
|
418 <b>Note:</b> The DocML does not support directly the properties which uses QDate/QTime/QDateTime as parameters. For the properties to work user has to pass date, time or datetime |
|
419 as a string, in a valid ISO date format. |
|
420 |
|
421 ISO 8601 extended format: either YYYY-MM-DD for dates or YYYY-MM-DDTHH:MM:SS for combined dates and times. |
|
422 |
|
423 \code |
|
424 ... |
|
425 <widget name="t:dtp" type="HbDateTimePicker"> |
|
426 <!-- 'minimumDateTime' is a QDateTime property of HbDateTimePicker. --> |
|
427 <string name="minimumDateTime" value="02-02-15T02-15-30" /> |
|
428 </widget> |
|
429 ... |
|
430 \endcode |
|
431 |
354 \sa setMinimumDateTime |
432 \sa setMinimumDateTime |
355 */ |
433 */ |
356 QDateTime HbDateTimePicker::minimumDateTime()const |
434 QDateTime HbDateTimePicker::minimumDateTime()const |
357 { |
435 { |
358 Q_D(const HbDateTimePicker); |
436 Q_D(const HbDateTimePicker); |
359 return d->mMinimumDate; |
437 return d->mMinimumDate; |
360 } |
438 } |
361 |
439 |
362 /*! |
440 /*! |
363 Sets minimum \a datetime in QDateTime format. |
441 Sets minimum \a datetime for datetime picker in QDateTime format. |
364 <b><i>Note:</i></b> There's no link between Date and time in this API, using this API as of now |
442 |
365 would be similar to using combination of \sa setMinimumDate and \sa setMinimumTime |
443 <b>Note:</b> There's no link between Date functionality and time functionality in this API. Using this API, for now, |
|
444 would be similar to using a combination of setMinimumDate and setMinimumTime APIs. |
366 |
445 |
367 \param datetime minimum date and minimum time in QDateTime format. |
446 \param datetime minimum date and minimum time in QDateTime format. |
368 |
447 |
369 \sa minimumDateTime \sa setMinimumDate \sa setMinimumTime |
448 \sa minimumDateTime \sa setMinimumDate \sa setMinimumTime |
370 */ |
449 */ |
373 Q_D(HbDateTimePicker); |
452 Q_D(HbDateTimePicker); |
374 d->setMinimumDateTime(datetime); |
453 d->setMinimumDateTime(datetime); |
375 } |
454 } |
376 |
455 |
377 /*! |
456 /*! |
378 Returns maximum date time in QDateTime format. |
457 Returns maximum date time, set on datetime picker, in QDateTime format. |
379 |
458 |
380 \return Maximum date and maximum time in QDateTime format. |
459 \return Maximum date and maximum time in QDateTime format. |
381 |
460 |
382 \sa setMaximumDate |
461 <b>Note:</b> The DocML does not support directly the properties which uses QDate/QTime/QDateTime as parameters. For the properties to work user has to pass date, time or datetime |
|
462 as a string, in a valid ISO date format. |
|
463 |
|
464 ISO 8601 extended format: either YYYY-MM-DD for dates or YYYY-MM-DDTHH:MM:SS for combined dates and times. |
|
465 |
|
466 \code |
|
467 ... |
|
468 <widget name="t:dtp" type="HbDateTimePicker"> |
|
469 <!-- 'maximumDateTime' is a QDateTime property of HbDateTimePicker. --> |
|
470 <string name="maximumDateTime" value="02-02-15T02-15-30" /> |
|
471 </widget> |
|
472 ... |
|
473 \endcode |
|
474 |
|
475 \sa setMaximumDateTime |
383 */ |
476 */ |
384 QDateTime HbDateTimePicker::maximumDateTime()const |
477 QDateTime HbDateTimePicker::maximumDateTime()const |
385 { |
478 { |
386 Q_D(const HbDateTimePicker); |
479 Q_D(const HbDateTimePicker); |
387 return d->mMaximumDate; |
480 return d->mMaximumDate; |
388 } |
481 } |
389 |
482 |
390 /*! |
483 /*! |
391 Sets maximum \a datetime in QDateTime format. |
484 Sets maximum \a datetime, to be set on datetime picker, in QDateTime format. |
392 |
485 |
393 <b><i>Note:</i></b> There's no link between Date and time in this API, using this API as of now |
486 <b>Note:</b> There's no link between Date functionality and time functionality in this API, using this API for now |
394 would be similar to using combination of \sa setMaximumDate and \sa setMaximumTime |
487 would be similar to using a combination of setMaximumDate and setMaximumTime APIs. |
395 |
488 |
396 \param date Maximum date and maximum time in QDateTime format. |
489 \param date Maximum date and maximum time in QDateTime format. |
397 |
490 |
398 \sa maximumDateTime \sa setMaximumDate \sa setMaximumTime |
491 \sa maximumDateTime \sa setMaximumDate \sa setMaximumTime |
399 */ |
492 */ |
402 Q_D(HbDateTimePicker); |
495 Q_D(HbDateTimePicker); |
403 d->setMaximumDateTime(date); |
496 d->setMaximumDateTime(date); |
404 } |
497 } |
405 |
498 |
406 /*! |
499 /*! |
407 Sets minimum \a minDatetime and maximum \a maxDatetime datetimes in QDateTime format. |
500 Sets minimum \a minDatetime and maximum \a maxDatetime date and time values, to be set on datetime picker, in QDateTime format. |
408 |
501 This will allow the user to set date and time range on datetime picker. |
409 <b><i>Note:</i></b> There's no link between Date and time in this API, using this API as of now |
502 |
410 would be similar to using combination of \sa setMinimumDate \sa setMaximumTime and |
503 <b>Note:</b> There's no link between Date and time in this API, using this API for now |
411 \sa setMinimumTime, \sa setMaximumTime. |
504 would be similar to using a combination of setMinimumDate, setMaximumTime and |
|
505 setMinimumTime, setMaximumTime APIs. |
412 |
506 |
413 \param minDateTime minimum date and time in QDateTime format. |
507 \param minDateTime minimum date and time in QDateTime format. |
414 \param maxDateTime maximum date and time in QDateTime format. |
508 \param maxDateTime maximum date and time in QDateTime format. |
415 |
509 |
416 \sa setMinimumDateTime \sa setMaximumDateTime \sa setMinimumDate \sa setMaximumDate |
510 \sa setMinimumDateTime \sa setMaximumDateTime \sa setMinimumDate \sa setMaximumDate |
417 \sa setMinimumTime \sa setMaximumTime |
511 \sa setMinimumTime \sa setMaximumTime |
418 */ |
512 */ |
419 void HbDateTimePicker::setDateTimeRange(const QDateTime &minDateTime, const QDateTime &maxDateTime) |
513 void HbDateTimePicker::setDateTimeRange(const QDateTime &minDateTime, const QDateTime &maxDateTime) |
420 { |
514 { |
421 Q_D(HbDateTimePicker); |
515 Q_D(HbDateTimePicker); |
422 d->setDateTimeRange(minDateTime, maxDateTime); |
516 d->setDateTimeRange(minDateTime, maxDateTime); |
423 } |
517 } |
424 |
518 |
425 /*! |
519 /*! |
426 Returns the current time in QTime format. |
520 Returns the current time, selected in datetime picker widget, in QTime format. |
427 |
521 |
428 \return time in QTime format. |
522 \return time in QTime format. |
429 |
523 |
|
524 <b>Note:</b> The DocML does not support directly the properties which uses QDate/QTime/QDateTime as parameters. For the properties to work user has to pass date, time or datetime |
|
525 as a string, in a valid ISO date format. |
|
526 |
|
527 ISO 8601 extended format: either YYYY-MM-DD for dates or YYYY-MM-DDTHH:MM:SS for combined dates and times. |
|
528 |
|
529 \code |
|
530 ... |
|
531 <widget name="t:dtp" type="HbDateTimePicker"> |
|
532 <!-- 'time' is a QTime property of HbDateTimePicker. --> |
|
533 <string name="time" value="02-15-30" /> |
|
534 </widget> |
|
535 ... |
|
536 \endcode |
|
537 |
430 \sa setTime |
538 \sa setTime |
431 */ |
539 */ |
432 QTime HbDateTimePicker::time() const |
540 QTime HbDateTimePicker::time() const |
433 { |
541 { |
434 Q_D(const HbDateTimePicker); |
542 Q_D(const HbDateTimePicker); |
435 return d->mDateTime.time(); |
543 return d->mDateTime.time(); |
436 } |
544 } |
437 |
545 |
438 /*! |
546 /*! |
439 Sets the current \a time in the form of QTime. |
547 Sets the current \a time, to be set on datetime picker widget, in QTime format. |
440 |
548 |
441 \param time in QTime format. |
549 \param time in QTime format. |
442 |
550 |
443 \sa time |
551 \sa time |
444 */ |
552 */ |