src/hbwidgets/widgets/hbdatetimepicker.cpp
changeset 34 ed14f46c0e55
parent 7 923ff622b8b9
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 #include "hbdatetimepicker.h"
    26 #include "hbdatetimepicker.h"
    27 #include "hbdatetimepicker_p.h"
    27 #include "hbdatetimepicker_p.h"
    28 #include "hbstyleoption_p.h"
    28 #include "hbstyleoption_p.h"
       
    29 #include "hbframeitem.h"
       
    30 #include "hbstyleprimitivedata.h"
       
    31 #include <hbstyleframeprimitivedata.h>
    29 
    32 
    30 /*!
    33 /*!
    31     @beta
    34     @beta
    32     \class HbDateTimePicker
    35     \class HbDateTimePicker
    33     \brief HbDateTimePicker class provides a widget for picking the date, time, date and time. <br>
    36     \brief The HbDateTimePicker class provides a widget that has multiple vertical tumblers 
    34     
    37     for selecting a date, time, or date and time by flick, drag and tap gestures.
    35     By default date picker will be created, with date functionality only.
    38     
    36     For exclusive time or datetime picker creation, use QTime or QDateTime variable as parameter for the constructor.
    39     The number of tumblers depends on the display format. The default constructor creates
    37     \li Date and Time
    40     a widget for selecting a date by internally setting the display format to the default 
    38     \li Date
    41     locale's short date format. Other constructors enable you to create a widget
    39     \li Time
    42     for selecting a time or date and time by passing a QTime or QDateTime variable as an 
    40     
    43     argument. Internally these constructors set the display format to the default locale's
    41     Below is a sample code snippet for datetime picker creation:
    44     short time or date and time format, respectively.
    42     \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,51}
    45     
    43 
    46     Use setDisplayFormat() to set the display format. Be aware that changing the display format 
    44     By default, display format is from HbExtendedLocale. User can set the format using setDisplayFormat API. \sa setDisplayFormat.<br>
    47     can change the widget from one for selecting the date to one for selecting the time, for 
    45     Based on the display format the tumblers or sections will be rearranged.<br>
    48     example.
    46     For each tumbler(TumbleView) in datetime picker, loopingEnabled property is always true.<br>
    49     
    47     
    50     Looping is enabled in the tumblers. The general appearance of the widget depends on the 
    48     HbDateTimePicker provides various date and time range functionalities.<br>
    51     theme that is in use.
    49     Currently the date range is independent of the time range.
    52     
    50     \sa setDateRange \sa setTimeRange \sa setDateTimeRange
    53     <TABLE border="0">
    51     \sa setMinimumTime \sa setMaximumTime \sa setMinimumDate \sa setMaximumDate
    54     <TR><TD>\image html hbdatetimepicker_date.png "Display format: d.MMMM"</TD>
    52     \sa setMinimumDateTime \sa setMaximumDateTime
    55     <TD></TD>
    53 
    56     <TD>\image html hbdatetimepicker_time.png "Display format: h.m.AP"</TD></TR>
    54     \image html hbdatetimepicker_date.png  "Datetime picker with date functionalities, in d/MMMM format"
    57     </TABLE>
    55     \image html hbdatetimepicker_time.png  "Datetime picker with time functionalities, in h.m.AP format"
    58     
    56 
    59     You can set the range of values available in the tumblers by defining minimum and maximum 
    57     <b>Note:</b>Graphics in the above images varies depending on theme.
    60     values or using convenience range functions. If you change the range, if necessary 
    58 */
    61     the widget changes the displayed values so that they are within the new range. Users 
    59 
    62     cannot select a value outside the range. One effect of this is that if you set, 
    60 /*!
    63     for example, an afternoon time range, users cannot scroll to the AM value when the 
    61     \fn void dateChanged(const QDate &date)
    64     display format includes an AM/PM tumbler. The date range is currently independent of the 
    62 
    65     time range.
    63     This signal is emitted when item selection changes in any of the date pickers(day, month, year) in the datetimepicker widget.
    66     
    64     
    67     You can use setInterval() to define the increments for the minute tumbler. This is 
    65     \param date  selected by the user.
    68     useful when you want users to be able to set the time in 15 minute increments, for example.
    66 
    69     
    67 */
    70     The number of rows displayed depends on how much space is available. To change the number 
    68 
    71     of rows shown when the widget is is in a layout, for example, use 
    69 /*!
    72     QGraphicsLayoutItem::setPreferredHeight() to increase the space available. The widget then
    70     \fn void timeChanged(const QTime &time)
    73     increases the number of rows to occupy the available space. 
    71 
    74     
    72     This signal is emitted when item selection changes in any of the time pickers(hour, minute, second, am/pm) in the datetimepicker widget.
    75     %HbDateTimePicker emits a dateChanged(), timeChanged() or dateTimeChanged() signal when 
    73     \param time  selected by the user.
    76     the user selects a new value. The selected date, time, or date and time value is passed
    74 
    77     in a QDate, QTime, or QDateTime argument. 
    75 */
    78     
    76 
    79     \section _usecases_hbdatetimepicker Using HbDateTimePicker
    77 /*!
    80     
    78     \fn void dateTimeChanged(const QDateTime &datetime)
    81     The following example demonstrates creating a widget for selecting a date:
    79 
    82     
    80     This signal is emitted when item selection changes in any of the date and time pickers in the datetimepicker widget.
    83     \code
    81     \param datetime  selected by the user.
    84     // Use the default constructor to create a widget for selecting a date.
    82 
    85     HbDateTimePicker *datePicker = new HbDateTimePicker();
    83 */
    86 
    84 
    87     // Set the minumum and maximum dates to display.
    85 /*!
    88     datePicker->setMinimumDate(QDate::currentDate());
    86     Constructs date picker widget by default.
    89     datePicker->setMaximumDate(QDate::currentDate().addDays(365));
    87 
    90 
    88     \param parent parent item for datetime picker widget.
    91     // Specify the display format.
       
    92     datePicker->setDisplayFormat("dd.MMMM.yyyy");
       
    93     \endcode
       
    94     
       
    95     The following example demonstrates connecting the dateChanged() signal to a slot
       
    96     on an object, \a d, of a class (not shown). This has a \c setMeetingDate() function 
       
    97     that takes a QDate argument.
       
    98     
       
    99     \code
       
   100     QObject::connect(datePicker, SIGNAL(dateChanged(const QDate&)),
       
   101                      d, SLOT(setMeetingDate(const QDate&)));
       
   102     \endcode
       
   103 
       
   104     The following example demonstrates creating a widget for selecting a time:
       
   105     
       
   106     \code
       
   107     // Create a widget for selecting a time.
       
   108     HbDateTimePicker *timePicker = new HbDateTimePicker(QTime());
       
   109 
       
   110     // Set the minimum and maximum times using the convenience range method.
       
   111     timePicker->setTimeRange(QTime::currentTime(),
       
   112                              QTime::currentTime().addSecs(10*60*60));
       
   113     
       
   114     // Set the time interval to be 15 minutes.
       
   115     timePicker->setInterval(QDateTimeEdit::MinuteSection, 15);
       
   116     
       
   117     // Specify the display format.
       
   118     timePicker->setDisplayFormat("hh:mm.ap");
       
   119     \endcode
       
   120     
       
   121     The following example demonstrates creating a widget for selecting a date and time:
       
   122     
       
   123     \code
       
   124     // Create a widget for selecting a date and time.
       
   125     HbDateTimePicker *dateTimePicker =
       
   126             new HbDateTimePicker(QDateTime::currentDateTime());
       
   127 
       
   128     // Specify the display format.
       
   129     dateTimePicker->setDisplayFormat("dd.MM.yyyy.hh.mm.ap");
       
   130     \endcode
       
   131     
       
   132     The properties that hold the minimum and maximum values take a QDate, QTime 
       
   133     or QDateTime object as an argument. DocML does not directly support properties that
       
   134     use QDate, QTime or QDateTime as a parameter. This means that when you add an \b %HbDateTimePicker 
       
   135     widget in Application Designer, you must pass the date, time and date and time to these
       
   136     properties as a string in a valid ISO 8601 extended format. For example, YYYY-MM-DD for dates, 
       
   137     hh:mm:ss for times, and YYYY-MM-DDTHH:MM:SS for combined dates and times. 
       
   138     
       
   139     Here is an example of the \c maximumTime property defined in DocML:
       
   140     
       
   141     \code
       
   142     <widget name="t:dtp" type="HbDateTimePicker">
       
   143         <!-- 'maximumTime' is a QTime property of HbDateTimePicker. -->
       
   144         <string name ="displayFormat" value="hh:mm:ss" />
       
   145         <string name="maximumTime" value="08:30:00" />
       
   146     </widget>
       
   147     \endcode
       
   148     
       
   149     \section _methodgroups_HbDateTimePicker Function groups
       
   150     
       
   151     \li \b Range: setDateRange(), setTimeRange(), setDateTimeRange()
       
   152     \li \b Minimum \b value: setMinimumDate(), setMinimumTime(), setMinimumDateTime()
       
   153     \li \b Maximum \b value: setMaximumDate(), setMaximumTime(), setMaximumDateTime()
       
   154     \li \b Time \b interval: setInterval()
       
   155     
       
   156     \sa HbTumbleView, HbExtendedLocale
       
   157 */
       
   158 
       
   159 /*!
       
   160     \fn void HbDateTimePicker::dateChanged(const QDate &date);
       
   161 
       
   162     This signal is emitted when there is a change in the day, month or year selected.
       
   163     The new date is passed in \a date.
       
   164 
       
   165 */
       
   166 
       
   167 /*!
       
   168     \fn void HbDateTimePicker::timeChanged(const QTime &time);
       
   169 
       
   170     This signal is emitted when there is a change in the hour, minute, second, or AM/PM
       
   171     selected. The new time is passed in \a time.
       
   172 
       
   173 */
       
   174 
       
   175 /*!
       
   176     \fn void HbDateTimePicker::dateTimeChanged(const QDateTime &datetime);
       
   177 
       
   178     This signal is emitted when there is a change in the value selected in any of the
       
   179     tumblers in a date and time picker. The new date and time are passed in \a dateTime.
       
   180 
       
   181 */
       
   182 
       
   183 /*!
       
   184     Constructs an %HbDateTimePicker object with the locale's default short date display format 
       
   185     and with parent \a parent.
       
   186 
    89 */
   187 */
    90 HbDateTimePicker::HbDateTimePicker( QGraphicsItem *parent ):
   188 HbDateTimePicker::HbDateTimePicker( QGraphicsItem *parent ):
    91 HbWidget(*new HbDateTimePickerPrivate, parent)
   189 HbWidget(*new HbDateTimePickerPrivate, parent)
    92 {
   190 {
    93     Q_D(HbDateTimePicker);
   191     Q_D(HbDateTimePicker);
    97 
   195 
    98     setDateTime(QDateTime::currentDateTime());
   196     setDateTime(QDateTime::currentDateTime());
    99 }
   197 }
   100 
   198 
   101 /*!
   199 /*!
   102     Constructs datetime picker widget with both date and time functionalities and with default locale's datetime format. 
   200     Constructs an %HbDateTimePicker object with the locale's default short date and time 
   103     \param datetime Value to be set on datetime picker widget, which has both date and time related tumblers.
   201     display format and with parent \a parent.
       
   202      
   104 */
   203 */
   105 HbDateTimePicker::HbDateTimePicker(const QDateTime &datetime, QGraphicsItem *parent ):
   204 HbDateTimePicker::HbDateTimePicker(const QDateTime &datetime, QGraphicsItem *parent ):
   106 HbWidget(*new HbDateTimePickerPrivate, parent)
   205 HbWidget(*new HbDateTimePickerPrivate, parent)
   107 {
   206 {
   108     Q_D(HbDateTimePicker);
   207     Q_D(HbDateTimePicker);
   110     d->init(QVariant::DateTime);
   209     d->init(QVariant::DateTime);
   111     setDateTime(datetime);
   210     setDateTime(datetime);
   112 }
   211 }
   113 
   212 
   114 /*!
   213 /*!
   115     Constructs datetime picker widget with only date functionalities and with default locale's date format.
   214     Constructs an %HbDateTimePicker object with the locale's default short date 
   116     
   215     display format and with parent \a parent.
   117     \param date QDate value.
   216 
   118 */
   217 */
   119 HbDateTimePicker::HbDateTimePicker(const QDate &date, QGraphicsItem *parent ):
   218 HbDateTimePicker::HbDateTimePicker(const QDate &date, QGraphicsItem *parent ):
   120 HbWidget(*new HbDateTimePickerPrivate, parent)
   219 HbWidget(*new HbDateTimePickerPrivate, parent)
   121 {
   220 {
   122     Q_D(HbDateTimePicker);
   221     Q_D(HbDateTimePicker);
   124     d->init(QVariant::Date);
   223     d->init(QVariant::Date);
   125     setDate(date);
   224     setDate(date);
   126 }
   225 }
   127 
   226 
   128 /*!
   227 /*!
   129     Constructs datetime picker widget with only time functionalities and with with default locale's time format.
   228     Constructs an %HbDateTimePicker object with the locale's default time 
   130     
   229     display format and with parent \a parent.
   131     \param time QTime value.
   230     
   132 */
   231 */
   133 HbDateTimePicker::HbDateTimePicker(const QTime &time, QGraphicsItem *pParent ):
   232 HbDateTimePicker::HbDateTimePicker(const QTime &time, QGraphicsItem *pParent ):
   134 HbWidget(*new HbDateTimePickerPrivate, pParent)
   233 HbWidget(*new HbDateTimePickerPrivate, pParent)
   135 {
   234 {
   136     Q_D(HbDateTimePicker);
   235     Q_D(HbDateTimePicker);
   138     d->init(QVariant::Time);
   237     d->init(QVariant::Time);
   139     setTime(time);
   238     setTime(time);
   140 }
   239 }
   141 
   240 
   142 /*!
   241 /*!
   143     \internal
       
   144     Protected constructor for derivations.
   242     Protected constructor for derivations.
   145     the default mode is DateTimeMode, if other mode is required, set the mDateTimeMode variable.
   243     
   146     this does not set any default datetime, needs to be explicitly done in the derived constructor.
   244     The default mode is date and time. If another mode is required, set the mDateTimeMode 
   147 
   245     variable explicitly in the constructor of the class derived from HbDateTimePicker. This 
   148     \sa setDateTime, setTime, setDate
   246     does not set the default date and time value. 
       
   247 
       
   248     \sa setDateTime(), setTime(), setDate()
   149 */
   249 */
   150 HbDateTimePicker::HbDateTimePicker(HbDateTimePickerPrivate &dd, QGraphicsItem *parent):
   250 HbDateTimePicker::HbDateTimePicker(HbDateTimePickerPrivate &dd, QGraphicsItem *parent):
   151 HbWidget(dd, parent)
   251 HbWidget(dd, parent)
   152 {
   252 {
   153     Q_D(HbDateTimePicker);
   253     Q_D(HbDateTimePicker);
   154 
   254 
   155     d->init(QVariant::DateTime);
   255     d->init(QVariant::DateTime);
   156 }
   256 }
   157 
   257 
   158 /*!
   258 
   159     \reimp
       
   160 */
       
   161 bool HbDateTimePicker::event(QEvent *e)
   259 bool HbDateTimePicker::event(QEvent *e)
   162 {    
   260 {   
       
   261     Q_D(HbDateTimePicker);
       
   262     
   163     bool result = HbWidget::event(e);
   263     bool result = HbWidget::event(e);
   164     if (e->type()==QEvent::LayoutRequest) {
   264     if(e->type() == d->mFormatEventType){
       
   265         d->processFormatEvent();
       
   266     }
       
   267     else if (e->type()==QEvent::LayoutRequest) {
   165         updatePrimitives();
   268         updatePrimitives();
   166     }
   269     }
   167     return result;
   270     return result;
   168 }
   271 }
   169 
   272 
       
   273 
   170 /*!
   274 /*!
   171     Destructor.
   275     Destructor.
   172 */
   276 */
   173 HbDateTimePicker::~HbDateTimePicker()
   277 HbDateTimePicker::~HbDateTimePicker()
   174 {
   278 {
   175 }
   279 }
   176 
   280 
   177 /*!
   281 /*!
   178     Returns current display format as QString value.
   282     Returns the current display format as a QString value.
   179 
       
   180     \return display format of datetime picker widget.
       
   181 
   283 
   182     \sa setDisplayFormat()
   284     \sa setDisplayFormat()
   183  */
   285  */
   184 QString HbDateTimePicker::displayFormat() const
   286 QString HbDateTimePicker::displayFormat() const
   185 {
   287 {
   186     Q_D(const HbDateTimePicker);
   288     Q_D(const HbDateTimePicker);
   187     return d->mFormat;
   289     return d->mFormat;
   188 }
   290 }
   189 
   291 
   190 /*!
   292 /*!
   191     Sets the display \a format . eg: DDMMYY, MMDDYY
   293     Sets the display format using a suitable combination of the following expressions 
   192     
   294     in QString format.
   193     These expressions may be used for the format:
   295     
       
   296     These expressions may be used for the date:
   194 
   297 
   195     <TABLE>
   298     <TABLE>
   196     <TR><TD><b><i> Expression </TD><TD> Output </TD></i></b></TR>
   299     <TR><TD><b><b>Expression </b></TD><TD><b>Output</b> </TD></b></TR>
   197     <TR><TD> d </TD><TD><i> The day as a number without a leading zero (1 to 31)</i></TD></TR>
   300     <TR><TD> d </TD><TD> The day as a number without a leading zero (1 to 31).</TD></TR>
   198     <TR><TD> dd </TD><TD><i> The day as a number with a leading zero (01 to 31) </i></TD></TR>
   301     <TR><TD> dd </TD><TD> The day as a number with a leading zero (01 to 31). </TD></TR>
   199     <TR><TD> ddd </TD><TD><i>
   302     <TR><TD> ddd </TD><TD>The abbreviated localized day name (such as <i>Mon</i> to <i>Sun</i>).
   200           The abbreviated localized day name (e.g. 'Mon' to 'Sun').
   303             Uses QDate::shortDayName().</TD></TR>
   201             Uses QDate::shortDayName().</i></TD></TR>
   304     <TR><TD> dddd </TD><TD>The long localized day name (such as <i>Monday</i> to <i>Sunday</i>).
   202     <TR><TD> dddd </TD><TD><i>
   305             Uses QDate::longDayName().</TD></TR>
   203           The long localized day name (e.g. 'Monday' to 'Sunday').
   306     <TR><TD> M </TD><TD> The month as a number without a leading zero (1 to 12).</TD></TR>
   204             Uses QDate::longDayName().</i></TD></TR>
   307     <TR><TD> MM </TD><TD> The month as a number with a leading zero (01 to 12).</TD></TR>
   205     <TR><TD> M </TD><TD><i> The month as a number without a leading zero (1 to 12)</i></TD></TR>
   308     <TR><TD> MMM </TD><TD>The abbreviated localized month name (such as <i>Jan</i> to <i>Dec</i>).
   206     <TR><TD> MM </TD><TD><i> The month as a number with a leading zero (01 to 12)</i></TD></TR>
   309             Uses QDate::shortMonthName().</TD></TR>
   207     <TR><TD> MMM </TD><TD><i>
   310     <TR><TD> MMMM </TD><TD>The long localized month name (such as <i>January</i> to <i>December</i>).
   208          The abbreviated localized month name (e.g. 'Jan' to 'Dec').
   311             Uses QDate::longMonthName().</TD></TR>
   209             Uses QDate::shortMonthName().</i></TD></TR>
   312     <TR><TD> yy </TD><TD>The year as a two digit number (00 to 99).</TD></TR>
   210     <TR><TD> MMMM </TD><TD><i>
   313     <TR><TD> yyyy </TD><TD>The year as a four digit number. If the year is negative,
   211           The long localized month name (e.g. 'January' to 'December').
   314             a minus sign is prepended.</TD></TR>
   212             Uses QDate::longMonthName().</i></TD></TR>
       
   213     <TR><TD> yy </TD><TD><i> The year as two digit number (00 to 99)</i></TD></TR>
       
   214     <TR><TD> yyyy </TD><TD><i> The year as four digit number. If the year is negative,
       
   215             a minus sign is prepended in addition.</i></TD></TR>
       
   216     </TABLE>
   315     </TABLE>
   217 
   316     
   218     NOTE:setDisplayFormat works only when the separators are mentioned in the format like 'dd.mm.yy' or 'dd mm yy', this
   317     These expressions may be used for the time:
   219          will be fixed in the future versions.
   318 
   220 
   319     <TABLE>
   221     \param format is the display format, for datetime picker widget, in QString format.
   320     <TR><TD><b><b>Expression </b></TD><TD><b>Output</b> </TD></b></TR>
       
   321     <TR><TD> h </TD><TD>The hour without a leading zero (0 to 23 or 1 to 12).</TD></TR>
       
   322     <TR><TD> hh </TD><TD>The hour with a leading zero (00 to 23 or 01 to 12). </TD></TR>
       
   323     <TR><TD>H   </TD><TD>The hour without a leading zero (0 to 23, even with AM/PM display).</TD></TR>
       
   324     <TR><TD>HH  </TD><TD>The hour with a leading zero (00 to 23, even with AM/PM display).</TD></TR>
       
   325     <TR><TD> m </TD><TD>The minute without a leading zero (0 to 59).</TD></TR>
       
   326     <TR><TD> mm </TD><TD>The minute with a leading zero (00 to 59).</TD></TR>
       
   327     <TR><TD> s </TD><TD>The second without a leading zero (0 to 59).</TD></TR>
       
   328     <TR><TD> ss </TD><TD>The second with a leading zero (00 to 59).</TD></TR>
       
   329     <TR><TD>AP or A </TD><TD>Displays AM and PM.</i></TD></TR>
       
   330     <TR><TD>ap or a </TD><TD>Displays am and pm.</TD></TR>
       
   331     </TABLE>
       
   332 
       
   333     \note Currently you must include separators in the format; for example, 'dd.mm.yy'. 
       
   334     \note Use max upto 4 fields like hh:mm:ss:ap in the format. More than 4 fields will not be usable on typical mobile display.
   222 
   335 
   223     \sa displayFormat()
   336     \sa displayFormat()
   224 */
   337 */
   225 void HbDateTimePicker::setDisplayFormat(const QString &format)
   338 void HbDateTimePicker::setDisplayFormat(const QString &format)
   226 {
   339 {
   227     Q_D(HbDateTimePicker);
   340     Q_D(HbDateTimePicker);
   228 
   341 
   229     if(d->isFormatValid(format)){ 
   342     if(d->isFormatValid(format)){
   230         d->mFormat = format;
   343         d->mFormat = format;
   231         d->parseDisplayFormat(format);        
   344             d->postFormatEvent();
   232         d->rearrangeTumbleViews();
   345     }
   233         d->emitDateTimeChange();
   346 }
   234     }//End If format is valid
   347 
   235 }
   348 /*!
   236 
   349     Returns the currently selected date in QDate format.
   237 /*!
   350     
   238     Returns the current date in QDate format.
   351     \note DocML does not directly support properties that use QDate as a parameter. For these 
   239 
   352     properties, pass the date as a string in a valid ISO 8601 extended format,
   240     \return current selected date in datetime picker.
   353     such as YYYY-MM-DD.
   241 
   354 
   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
   355     \code
   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">
   356     <widget name="t:dtp" type="HbDateTimePicker">
   250         <!-- 'date' is a QDate property of HbDateTimePicker. -->
   357         <!-- 'date' is a QDate property of HbDateTimePicker. -->
   251         <string name="date" value="02-02-15" />
   358         <string name="date" value="02-02-15" />
   252     </widget>
   359     </widget>
   253     ...
   360     \endcode
   254     \endcode
   361 
   255 
   362     \sa setDate()
   256     \sa setDate
       
   257 */
   363 */
   258 QDate HbDateTimePicker::date() const
   364 QDate HbDateTimePicker::date() const
   259 {
   365 {
   260     Q_D(const HbDateTimePicker);
   366     Q_D(const HbDateTimePicker);
   261 
   367 
   262     return d->mDateTime.date();
   368     return d->mDateTime.date();
   263 }
   369 }
   264 
   370 
   265 /*!
   371 /*!
   266     Sets the current \a date in the form of QDate.
   372     Sets the current date to \a date.
   267 
   373 
   268     \param date date to be set on the datetime picker in QDate format
   374     \param date The date in QDate format.
   269 
   375 
   270     \sa date
   376     \sa date()
   271 */
   377 */
   272 void HbDateTimePicker::setDate(const QDate& date)
   378 void HbDateTimePicker::setDate(const QDate& date)
   273 {
   379 {
   274     Q_D(HbDateTimePicker);
   380     Q_D(HbDateTimePicker);
   275     setDateTime(QDateTime(date,d->mDateTime.time()));
   381     setDateTime(QDateTime(date,d->mDateTime.time()));
   276 }
   382 }
   277 
   383 
   278 /*!
   384 /*!
   279     Returns minimum date in QDate format.
   385     Returns the minimum date in QDate format.
   280 
   386     
   281     \return Minimum date set on datetime picker in QDate format.
   387     \note DocML does not directly support properties that use QDate as a parameter. For these 
   282 
   388     properties, pass the date as a string in a valid ISO 8601 extended format, such as YYYY-MM-DD.
   283     <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
   389 
   284     as a string, in a valid ISO date format. 
   390     \code
   285     
       
   286     ISO 8601 extended format: either YYYY-MM-DD for dates or YYYY-MM-DDTHH:MM:SS for combined dates and times.
       
   287 
       
   288     \code
       
   289     ...
       
   290     <widget name="t:dtp" type="HbDateTimePicker">
   391     <widget name="t:dtp" type="HbDateTimePicker">
   291         <!-- 'minimumDate' is a QDate property of HbDateTimePicker. -->
   392         <!-- 'minimumDate' is a QDate property of HbDateTimePicker. -->
   292         <string name="minimumDate" value="02-02-15" />
   393         <string name="minimumDate" value="02-02-15" />
   293     </widget>
   394     </widget>
   294     ...
   395     \endcode
   295     \endcode
   396     
   296 
   397     \sa setMinimumDate()
   297     \sa setMinimumDate
       
   298 */
   398 */
   299 QDate HbDateTimePicker::minimumDate()const
   399 QDate HbDateTimePicker::minimumDate()const
   300 {
   400 {
   301     Q_D(const HbDateTimePicker);
   401     Q_D(const HbDateTimePicker);
   302     return d->mMinimumDate.date();
   402     return d->mMinimumDate.date();
   303 }
   403 }
   304 
   404 
   305 /*!
   405 /*!
   306     Sets minimum \a date in QDate format.
   406     Sets the minimum date to \a date. 
   307 
   407 
   308     \param Minimum date to be set on datetime picker in QDate format.
   408     \param date The minimum date in QDate format.
   309     
   409     
   310     \sa minimumDate
   410     \sa minimumDate(), setDateRange()
   311 */
   411 */
   312 void HbDateTimePicker::setMinimumDate(const QDate& date)
   412 void HbDateTimePicker::setMinimumDate(const QDate& date)
   313 {
   413 {
   314     Q_D(HbDateTimePicker);
   414     Q_D(HbDateTimePicker);
   315     setMinimumDateTime(QDateTime(date, d->mMinimumDate.time()));
   415     setMinimumDateTime(QDateTime(date, d->mMinimumDate.time()));
   316 }
   416 }
   317 
   417 
   318 /*!
   418 /*!
   319     Returns maximum date in QDate format.
   419     Returns the maximum date in QDate format.
   320 
   420     
   321     \return Maximum Date set on datetime picker in QDate format.
   421     \note DocML does not directly support properties that use QDate as a parameter. For these 
   322 
   422     properties, pass the date as a string in a valid ISO 8601 extended format, such as YYYY-MM-DD.
   323     <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
   423 
   324     as a string, in a valid ISO date format. 
   424     \code
   325     
       
   326     ISO 8601 extended format: either YYYY-MM-DD for dates or YYYY-MM-DDTHH:MM:SS for combined dates and times.
       
   327 
       
   328     \code
       
   329     ...
       
   330     <widget name="t:dtp" type="HbDateTimePicker">
   425     <widget name="t:dtp" type="HbDateTimePicker">
   331         <!-- 'maximumDate' is a QDate property of HbDateTimePicker. -->
   426         <!-- 'maximumDate' is a QDate property of HbDateTimePicker. -->
   332         <string name="maximumDate" value="02-02-15" />
   427         <string name="maximumDate" value="02-02-15" />
   333     </widget>
   428     </widget>
   334     ...
   429     \endcode
   335     \endcode
   430 
   336 
   431     \sa setMaximumDate()
   337     \sa setMaximumDate
       
   338 */
   432 */
   339 QDate HbDateTimePicker::maximumDate()const
   433 QDate HbDateTimePicker::maximumDate()const
   340 {
   434 {
   341     Q_D(const HbDateTimePicker);
   435     Q_D(const HbDateTimePicker);
   342     return d->mMaximumDate.date();
   436     return d->mMaximumDate.date();
   343 }
   437 }
   344 
   438 
   345 /*!
   439 /*!
   346     Sets maximum \a date in QDate format.
   440     Sets the maximum date to \a date. 
   347 
   441 
   348     \param date Maximum date to be set on datetime picker in QDate format.
   442     \param date The maximum date in QDate format.
   349 
   443 
   350     \sa maximumDate
   444     \sa maximumDate(), setDateRange()
   351 */
   445 */
   352 void HbDateTimePicker::setMaximumDate(const QDate& date)
   446 void HbDateTimePicker::setMaximumDate(const QDate& date)
   353 {
   447 {
   354     Q_D(HbDateTimePicker);
   448     Q_D(HbDateTimePicker);
   355     setMaximumDateTime(QDateTime(date, d->mMaximumDate.time()));
   449     setMaximumDateTime(QDateTime(date, d->mMaximumDate.time()));
   356 }
   450 }
   357 
   451 
   358 /*!
   452 /*!
   359     Sets minimum \a minDate and maximum \a maxDate dates in QDate format. This will allow user to set date range on datetime picker.
   453     Sets the minimum and maximum dates.
   360 
   454 
   361     \param minDate Minimum date in QDate format.
   455     \param minDate The minimum date in QDate format.
   362     \param maxDate Maximum date in QDate format.
   456     \param maxDate The maximum date in QDate format.
   363 
   457 
   364     \sa setMinimumDate \sa setMaximumDate
   458     \sa setMinimumDate(), setMaximumDate()
   365 */
   459 */
   366 void HbDateTimePicker::setDateRange(const QDate &minDate, const QDate &maxDate)
   460 void HbDateTimePicker::setDateRange(const QDate &minDate, const QDate &maxDate)
   367 {
   461 {
   368     Q_D(HbDateTimePicker);
   462     Q_D(HbDateTimePicker);
   369     setDateTimeRange(QDateTime(minDate, d->mMinimumDate.time()),
   463     setDateTimeRange(QDateTime(minDate, d->mMinimumDate.time()),
   370                          QDateTime(maxDate, d->mMaximumDate.time()));
   464                          QDateTime(maxDate, d->mMaximumDate.time()));
   371 }
   465 }
   372 
   466 
   373 /*!
   467 /*!
   374     Returns the current date and time value, selected in datetime picker, in QDateTime format.
   468     Returns the currently selected date and time in QDateTime format.
   375 
   469     
   376     \return date and time value in QDateTime format.
   470     \note DocML does not directly support properties that use QDate, QTime or QDateTime as a 
   377 
   471     parameter. For these properties, pass the date, time or date and time as a string in a 
   378     <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
   472     valid ISO 8601 extended format. For example, YYYY-MM-DD for dates and YYYY-MM-DDTHH:MM:SS
   379     as a string, in a valid ISO date format. 
   473     for combined dates and times.
   380     
   474 
   381     ISO 8601 extended format: either YYYY-MM-DD for dates or YYYY-MM-DDTHH:MM:SS for combined dates and times.
   475     \code
   382 
       
   383     \code
       
   384     ...
       
   385     <widget name="t:dtp" type="HbDateTimePicker">
   476     <widget name="t:dtp" type="HbDateTimePicker">
   386         <!-- 'dateTime' is a QDateTime property of HbDateTimePicker. -->
   477         <!-- 'dateTime' is a QDateTime property of HbDateTimePicker. -->
   387         <string name="dateTime" value="02-02-15T02-15-30" />
   478         <string name="dateTime" value="02-02-15T02-15-30" />
   388     </widget>
   479     </widget>
   389     ...
   480     \endcode
   390     \endcode
   481 
   391 
   482     \sa setDateTime()
   392     \sa setDateTime
       
   393 */
   483 */
   394 QDateTime HbDateTimePicker::dateTime()const
   484 QDateTime HbDateTimePicker::dateTime()const
   395 {
   485 {
   396     Q_D(const HbDateTimePicker);
   486     Q_D(const HbDateTimePicker);
   397     return d->mDateTime;
   487     return d->mDateTime;
   398 }
   488 }
   399 
   489 
   400 /*!
   490 /*!
   401     Sets the current \a datetime value to be set on datetime picker in QDateTime format.
   491     Sets the current date and time.
   402 
   492 
   403     \param datetime in QDateTime format.
   493     \param datetime The date and time in QDateTime format.
   404 
   494 
   405     \sa dateTime
   495     \sa dateTime()
   406 */
   496 */
   407 void HbDateTimePicker::setDateTime(const QDateTime &datetime)
   497 void HbDateTimePicker::setDateTime(const QDateTime &datetime)
   408 {
   498 {
   409     Q_D(HbDateTimePicker);
   499     Q_D(HbDateTimePicker);
   410     d->setDateTime(datetime);
   500     d->setDateTime(datetime);
   411 }
   501 }
   412 
   502 
   413 /*!
   503 /*!
   414     Returns minimum date time value set on datetime picker in QDateTime format.
   504     Returns the minimum date and time in QDateTime format.
   415 
   505     
   416     \return Minimum date and minimum time in QDateTime format.
   506     \note DocML does not directly support properties that use QDate, QTime or QDateTime as a 
   417 
   507     parameter. For these properties, pass the date, time or date and time as a string in a 
   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
   508     valid ISO 8601 extended format. For example, YYYY-MM-DD for dates and YYYY-MM-DDTHH:MM:SS
   419     as a string, in a valid ISO date format. 
   509     for combined dates and times.
   420     
   510 
   421     ISO 8601 extended format: either YYYY-MM-DD for dates or YYYY-MM-DDTHH:MM:SS for combined dates and times.
   511     \code
   422 
       
   423     \code
       
   424     ...
       
   425     <widget name="t:dtp" type="HbDateTimePicker">
   512     <widget name="t:dtp" type="HbDateTimePicker">
   426         <!-- 'minimumDateTime' is a QDateTime property of HbDateTimePicker. -->
   513         <!-- 'minimumDateTime' is a QDateTime property of HbDateTimePicker. -->
   427         <string name="minimumDateTime" value="02-02-15T02-15-30" />
   514         <string name="minimumDateTime" value="02-02-15T02-15-30" />
   428     </widget>
   515     </widget>
   429       ...
   516     \endcode
   430     \endcode
   517 
   431 
   518     \sa setMinimumDateTime()
   432     \sa setMinimumDateTime
       
   433 */
   519 */
   434 QDateTime HbDateTimePicker::minimumDateTime()const
   520 QDateTime HbDateTimePicker::minimumDateTime()const
   435 {
   521 {
   436     Q_D(const HbDateTimePicker);
   522     Q_D(const HbDateTimePicker);
   437     return d->mMinimumDate;
   523     return d->mMinimumDate;
   438 }
   524 }
   439 
   525 
   440 /*!
   526 /*!
   441     Sets minimum \a datetime for datetime picker in QDateTime format.
   527     Sets the minimum date and time.
   442 
   528 
   443     <b>Note:</b> There's no link between Date functionality and time functionality in this API. Using this API, for now,
   529     \note The date and time are not linked in this API. This means that 
   444     would be similar to using a combination of setMinimumDate and setMinimumTime APIs.
   530     calling this function is similar to calling setMinimumDate() and setMinimumTime().
   445 
   531 
   446     \param datetime minimum date and minimum time in QDateTime format.
   532     \param datetime The minimum date and time in QDateTime format.
   447 
   533 
   448     \sa minimumDateTime \sa setMinimumDate \sa setMinimumTime
   534     \sa minimumDateTime(), setDateTimeRange()
   449 */
   535 */
   450 void HbDateTimePicker::setMinimumDateTime(const QDateTime& datetime)
   536 void HbDateTimePicker::setMinimumDateTime(const QDateTime& datetime)
   451 {
   537 {
   452     Q_D(HbDateTimePicker);
   538     Q_D(HbDateTimePicker);
   453     d->setMinimumDateTime(datetime);
   539     d->setMinimumDateTime(datetime);
   454 }
   540 }
   455 
   541 
   456 /*!
   542 /*!
   457     Returns maximum date time, set on datetime picker, in QDateTime format.
   543     Returns the maximum date and time in QDateTime format.
   458 
   544     
   459     \return Maximum date and maximum time in QDateTime format.
   545     \note DocML does not directly support properties that use QDate, QTime or
   460 
   546     QDateTime as parameters. For these properties, pass the date, time, or date and time
   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
   547     as a string in a valid ISO 8601 extended format. For example, YYYY-MM-DD for dates
   462     as a string, in a valid ISO date format. 
   548     or YYYY-MM-DDTHH:MM:SS for combined dates and times.
   463     
   549 
   464     ISO 8601 extended format: either YYYY-MM-DD for dates or YYYY-MM-DDTHH:MM:SS for combined dates and times.
   550     \code
   465 
       
   466     \code
       
   467     ...
       
   468     <widget name="t:dtp" type="HbDateTimePicker">
   551     <widget name="t:dtp" type="HbDateTimePicker">
   469         <!-- 'maximumDateTime' is a QDateTime property of HbDateTimePicker. -->
   552         <!-- 'maximumDateTime' is a QDateTime property of HbDateTimePicker. -->
   470         <string name="maximumDateTime" value="02-02-15T02-15-30" />
   553         <string name="maximumDateTime" value="02-02-15T02-15-30" />
   471     </widget>
   554     </widget>
   472       ...
   555     \endcode
   473     \endcode
   556 
   474 
   557     \sa setMaximumDateTime()
   475     \sa setMaximumDateTime
       
   476 */
   558 */
   477 QDateTime HbDateTimePicker::maximumDateTime()const
   559 QDateTime HbDateTimePicker::maximumDateTime()const
   478 {
   560 {
   479     Q_D(const HbDateTimePicker);
   561     Q_D(const HbDateTimePicker);
   480     return d->mMaximumDate;
   562     return d->mMaximumDate;
   481 }
   563 }
   482 
   564 
   483 /*!
   565 /*!
   484     Sets maximum \a datetime, to be set on datetime picker, in QDateTime format.
   566     Sets the maximum date and time.
   485     
   567     
   486     <b>Note:</b> There's no link between Date functionality and time functionality in this API, using this API for now
   568     \note The date and time are not linked in this API. This means that 
   487     would be similar to using a combination of setMaximumDate and setMaximumTime APIs.
   569     calling this function is similar to calling setMaximumDate() and setMaximumTime().
   488 
   570 
   489     \param date Maximum date and maximum time in QDateTime format.
   571     \param date The maximum date and time in QDateTime format.
   490 
   572 
   491     \sa maximumDateTime \sa setMaximumDate \sa setMaximumTime
   573     \sa maximumDateTime(), setDateTimeRange()
   492 */
   574 */
   493 void HbDateTimePicker::setMaximumDateTime(const QDateTime& date)
   575 void HbDateTimePicker::setMaximumDateTime(const QDateTime& date)
   494 {
   576 {
   495     Q_D(HbDateTimePicker);
   577     Q_D(HbDateTimePicker);
   496     d->setMaximumDateTime(date);
   578     d->setMaximumDateTime(date);
   497 }
   579 }
   498 
   580 
   499 /*!
   581 /*!
   500     Sets minimum \a minDatetime and maximum \a maxDatetime date and time values, to be set on datetime picker, in QDateTime format.
   582     Sets the minimum and maximum date and time.
   501     This will allow the user to set date and time range on datetime picker.
   583     
   502 
   584     \note The date and time are not linked in this API. This means that calling 
   503     <b>Note:</b> There's no link between Date and time in this API, using this API for now
   585     this function is equivalent to calling setMinimumDate(), setMaximumDate(), 
   504     would be similar to using a combination of setMinimumDate, setMaximumTime and 
   586     setMinimumTime(), and setMaximumTime().
   505     setMinimumTime, setMaximumTime APIs.
   587 
   506 
   588     \param minDateTime The minimum date and time in QDateTime format.
   507     \param minDateTime minimum date and time in QDateTime format.
   589     \param maxDateTime The maximum date and time in QDateTime format.
   508     \param maxDateTime maximum date and time in QDateTime format.
   590 
   509 
   591     \sa setMinimumDateTime(), setMaximumDateTime()
   510     \sa setMinimumDateTime \sa setMaximumDateTime \sa setMinimumDate \sa setMaximumDate
       
   511     \sa setMinimumTime \sa setMaximumTime
       
   512 */
   592 */
   513 void HbDateTimePicker::setDateTimeRange(const QDateTime &minDateTime, const QDateTime &maxDateTime)
   593 void HbDateTimePicker::setDateTimeRange(const QDateTime &minDateTime, const QDateTime &maxDateTime)
   514 {
   594 {
   515     Q_D(HbDateTimePicker);
   595     Q_D(HbDateTimePicker);
   516     d->setDateTimeRange(minDateTime, maxDateTime);
   596     d->setDateTimeRange(minDateTime, maxDateTime);
   517 }
   597 }
   518 
   598 
   519 /*!
   599 /*!
   520     Returns the current time, selected in datetime picker widget, in QTime format.
   600     Returns the currently selected time in QTime format.
   521 
   601     
   522     \return time in QTime format.
   602     \note DocML does not directly support properties that use QTime as a parameter.
   523 
   603     For these properties, pass the time as a string in a valid ISO 8601 extended format; 
   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
   604     for example, HH:MM:SS.
   525     as a string, in a valid ISO date format. 
   605 
   526     
   606     \code
   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">
   607     <widget name="t:dtp" type="HbDateTimePicker">
   532         <!-- 'time' is a QTime property of HbDateTimePicker. -->
   608         <!-- 'time' is a QTime property of HbDateTimePicker. -->
   533         <string name="time" value="02-15-30" />
   609         <string name="time" value="02-15-30" />
   534     </widget>
   610     </widget>
   535       ...
   611     \endcode
   536     \endcode
   612 
   537 
   613     \sa setTime()
   538     \sa setTime
       
   539 */
   614 */
   540 QTime HbDateTimePicker::time() const
   615 QTime HbDateTimePicker::time() const
   541 {
   616 {
   542     Q_D(const HbDateTimePicker);
   617     Q_D(const HbDateTimePicker);
   543     return d->mDateTime.time();
   618     return d->mDateTime.time();
   544 }
   619 }
   545 
   620 
   546 /*!
   621 /*!
   547     Sets the current \a time, to be set on datetime picker widget, in QTime format.
   622     Sets the current time to \a time.
   548 
   623 
   549     \param time in QTime format.
   624     \param time The time in QTime format.
   550 
   625 
   551     \sa time
   626     \sa time()
   552 */
   627 */
   553 void HbDateTimePicker::setTime(const QTime &time)
   628 void HbDateTimePicker::setTime(const QTime &time)
   554 {
   629 {
   555     Q_D(HbDateTimePicker);
   630     Q_D(HbDateTimePicker);
   556     setDateTime(QDateTime(d->mDateTime.date(), time));
   631     setDateTime(QDateTime(d->mDateTime.date(), time));
   557 }
   632 }
   558 
   633 
   559 /*!
   634 /*!
   560     Returns minimum time, set on datetime picker, in QTime format.
   635     Returns the minimum time in QTime format.
   561 
   636     
   562     \return Minimum time in QTime format.
   637     \note DocML does not directly support properties that use QTime as a parameter.
   563 
   638     For these properties, pass the time as a string in a valid ISO 8601 extended format; 
   564     <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
   639     for example, HH:MM:SS.
   565     as a string, in a valid ISO date format. 
   640 
   566     
   641     \code
   567     ISO 8601 extended format: either YYYY-MM-DD for dates or YYYY-MM-DDTHH:MM:SS for combined dates and times.
       
   568 
       
   569     \code
       
   570     ...
       
   571     <widget name="t:dtp" type="HbDateTimePicker">
   642     <widget name="t:dtp" type="HbDateTimePicker">
   572         <!-- 'minimumTime' is a QTime property of HbDateTimePicker. -->
   643         <!-- 'minimumTime' is a QTime property of HbDateTimePicker. -->
   573         <string name="minimumTime" value="02-15-30" />
   644         <string name="minimumTime" value="08-00-00" />
   574     </widget>
   645     </widget>
   575       ...
   646     \endcode
   576     \endcode
   647 
   577 
   648     \sa setMinimumTime()
   578     \sa setMinimumTime
       
   579 */
   649 */
   580 QTime HbDateTimePicker::minimumTime()const
   650 QTime HbDateTimePicker::minimumTime()const
   581 {
   651 {
   582     Q_D(const HbDateTimePicker);
   652     Q_D(const HbDateTimePicker);
   583     return d->mMinimumDate.time();
   653     return d->mMinimumDate.time();
   584 }
   654 }
   585 
   655 
   586 /*!
   656 /*!
   587     Sets minimum \a time, to be set on datetime picker, in QTime format.
   657     Sets the minimum time to \a time.
   588 
   658 
   589     \param time minimum time in QTime format.
   659     \param time The minimum time in QTime format.
   590 
   660 
   591     \sa minimumTime
   661     \sa minimumTime(), setTimeRange()
   592 */
   662 */
   593 void HbDateTimePicker::setMinimumTime(const QTime& time)
   663 void HbDateTimePicker::setMinimumTime(const QTime& time)
   594 {
   664 {
   595     Q_D(HbDateTimePicker);
   665     Q_D(HbDateTimePicker);
   596     setMinimumDateTime(QDateTime(d->mDateTime.date(),time));
   666     setMinimumDateTime(QDateTime(d->mDateTime.date(),time));
   597 }
   667 }
   598 
   668 
   599 /*!
   669 /*!
   600     Returns maximum time, set on datetime picker, in QTime format.
   670     Returns the maximum time in QTime format.
   601 
   671 
   602     \return maximum time in QTime format.
   672     \note DocML does not directly support properties that use QTime as a parameter.
   603 
   673     For these properties, pass the time as a string in a valid ISO 8601 extended format; 
   604     <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
   674     for example, HH:MM:SS.
   605     as a string, in a valid ISO date format. 
   675 
   606     
   676     \code
   607     ISO 8601 extended format: either YYYY-MM-DD for dates or YYYY-MM-DDTHH:MM:SS for combined dates and times.
       
   608 
       
   609     \code
       
   610     ...
       
   611     <widget name="t:dtp" type="HbDateTimePicker">
   677     <widget name="t:dtp" type="HbDateTimePicker">
   612         <!-- 'maximumTime' is a QTime property of HbDateTimePicker. -->
   678         <!-- 'maximumTime' is a QTime property of HbDateTimePicker. -->
   613         <string name="maximumTime" value="02-15-30" />
   679         <string name="maximumTime" value="18-30-00" />
   614     </widget>
   680     </widget>
   615       ...
   681     \endcode
   616     \endcode
   682 
   617 
   683     \sa setMaximumTime()
   618     \sa setMaximumTime
       
   619 */
   684 */
   620 QTime HbDateTimePicker::maximumTime()const
   685 QTime HbDateTimePicker::maximumTime()const
   621 {
   686 {
   622     Q_D(const HbDateTimePicker);
   687     Q_D(const HbDateTimePicker);
   623     return d->mMaximumDate.time();
   688     return d->mMaximumDate.time();
   624 }
   689 }
   625 
   690 
   626 /*!
   691 /*!
   627     Sets maximum \a time, to be set on datetime picker, in QTime format.
   692     Sets the maximum time to \a time.
   628 
   693 
   629     \param time maximum time in QTime format
   694     \param time The maximum time in QTime format.
   630 
   695 
   631     \sa maximumTime
   696     \sa maximumTime(), setTimeRange()
   632 */
   697 */
   633 void HbDateTimePicker::setMaximumTime(const QTime& time)
   698 void HbDateTimePicker::setMaximumTime(const QTime& time)
   634 {
   699 {
   635     Q_D(HbDateTimePicker);
   700     Q_D(HbDateTimePicker);
   636     setMaximumDateTime(QDateTime(d->mMaximumDate.date(), time));
   701     setMaximumDateTime(QDateTime(d->mMaximumDate.date(), time));
   637 }
   702 }
   638 
   703 
   639 /*!
   704 /*!
   640     Sets minimum \a minTime and maximum \a maxTime in QTime format. This will allow the user to set a time range on datetime picker.
   705     Sets the minimum and maximum time. 
   641 
   706 
   642     \param minTime minimum time in QTime format.
   707     \param minTime The minimum time in QTime format.
   643     \param maxTime maximum time in QTime format.
   708     \param maxTime The maximum time in QTime format.
   644 
   709 
   645     \sa setMinimumTime \sa setMaximumTime
   710     \sa setMinimumTime(), setMaximumTime()
   646 */
   711 */
   647 void HbDateTimePicker::setTimeRange(const QTime &minTime, const QTime &maxTime)
   712 void HbDateTimePicker::setTimeRange(const QTime &minTime, const QTime &maxTime)
   648 {
   713 {
   649     Q_D(HbDateTimePicker);
   714     Q_D(HbDateTimePicker);
   650     setDateTimeRange(QDateTime(d->mMinimumDate.date(), minTime),
   715     setDateTimeRange(QDateTime(d->mMinimumDate.date(), minTime),
   651                      QDateTime(d->mMinimumDate.date(), maxTime));
   716                      QDateTime(d->mMinimumDate.date(), maxTime));
   652 }
   717 }
   653 
   718 
   654 /*!
   719 /*!
   655   Sets the \a interval or periodic gap for the corresponding \a section.
   720     Sets the interval or periodic gap for a tumbler. Currently this is
   656 
   721     supported for minute tumblers only. 
   657   <b>Note</b>: Only MinuteSection is supported at this time.<br> 
   722 
   658   <b>Note</b>: Minute interval must be a divisor of 60. Divisors of 60 are 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30 
   723     \param section This identifies the tumbler. This must be QDateTimeEdit::MinuteSection.
   659 
   724     \param interval The interval to set on the tumbler. This must be a divisor of 60; that
   660   \param section can be a MinuteSection.
   725                     is, 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, or 30.
   661   \param interval to be set on each picker.
   726     
       
   727     \sa interval()
   662 */
   728 */
   663 void HbDateTimePicker::setInterval(QDateTimeEdit::Section section,int interval)
   729 void HbDateTimePicker::setInterval(QDateTimeEdit::Section section,int interval)
   664 {
   730 {
   665     Q_D(HbDateTimePicker);
   731     Q_D(HbDateTimePicker);
   666 
   732 
   701         d->setMinuteRange(start,end);
   767         d->setMinuteRange(start,end);
   702     }
   768     }
   703 }
   769 }
   704 
   770 
   705 /*!
   771 /*!
   706   returns the \a interval for the corresponding \a section.
   772     Returns the interval set for a tumbler. Currently this is supported for 
   707 
   773     minute tumblers only. 
   708   Note: Only MinuteSection is supported at this time.
   774 
   709 
   775     \param section Identifies the tumbler. This must be QDateTimeEdit::MinuteSection.
   710   \return interval or duration set on a particular \a section.
   776 
       
   777     \sa setInterval()
   711 */
   778 */
   712 int HbDateTimePicker::interval(QDateTimeEdit::Section section) const
   779 int HbDateTimePicker::interval(QDateTimeEdit::Section section) const
   713 {
   780 {
   714     Q_D(const HbDateTimePicker);
   781     Q_D(const HbDateTimePicker);
   715 
   782 
   716     return d->mIntervals[section];
   783     return d->mIntervals[section];
   717 }
   784 }
   718 
   785 
   719 /*!
   786 /*!
   720     \deprecated HbDateTimePicker::primitive(HbStyle::Primitive)
   787     Reimplemented from QGraphicsWidget::setGeometry().
   721         is deprecated.
       
   722 
       
   723     \reimp
       
   724 */
       
   725 QGraphicsItem *HbDateTimePicker::primitive(HbStyle::Primitive primitive) const
       
   726 {
       
   727     Q_D(const HbDateTimePicker);
       
   728     switch(primitive) {
       
   729         case HbStyle::P_DateTimePicker_background:
       
   730             return d->mBackground;
       
   731 
       
   732         case HbStyle::P_DateTimePicker_frame:
       
   733             return d->mFrame;
       
   734 
       
   735         case HbStyle::P_TumbleView_highlight:
       
   736             return d->mHighlight;
       
   737 
       
   738         default:
       
   739             return HbWidget::primitive(primitive);
       
   740     }
       
   741 }
       
   742 
       
   743 /*!
       
   744     \reimp
       
   745 */
   788 */
   746 void HbDateTimePicker::setGeometry(const QRectF &rect) 
   789 void HbDateTimePicker::setGeometry(const QRectF &rect) 
   747 {
   790 {
   748     HbWidget::setGeometry(rect);
   791     HbWidget::setGeometry(rect);
   749     updatePrimitives();
   792     updatePrimitives();
   750 }
   793       Q_D(HbDateTimePicker);
   751 
   794 
   752 /*!
   795     for(int i=0;i<d->mParser.mSectionNodes.count();i++) {
   753     \reimp
   796         switch(d->mParser.mSectionNodes[i].type) {
   754 */
   797             case HbDateTimeParser::AmPmSection:
       
   798                 if(!d->mAmPmPicker){
       
   799                     break;
       
   800                 }
       
   801                 break;
       
   802 
       
   803             case HbDateTimeParser::DaySection:
       
   804             case HbDateTimeParser::DayOfWeekSection:
       
   805                 if(!d->mDayPicker){
       
   806                     break;
       
   807                 }
       
   808                 d->mLabelDay->setPreferredWidth(d->mDayPicker->preferredSize().width());
       
   809                break;
       
   810 
       
   811             case HbDateTimeParser::MonthSection:
       
   812                 if(!d->mMonthPicker){
       
   813                     break;
       
   814                 }
       
   815                 d->mLabelMonth->setPreferredWidth(d->mMonthPicker->preferredSize().width());
       
   816                break;
       
   817 
       
   818             case HbDateTimeParser::YearSection:
       
   819             case HbDateTimeParser::YearSection2Digits:
       
   820                 if(!d->mYearPicker){
       
   821                     break;
       
   822                 }
       
   823 
       
   824                 d->mLabelYear->setPreferredWidth(d->mYearPicker->preferredSize().width());
       
   825                break;
       
   826 
       
   827             case HbDateTimeParser::SecondSection:
       
   828                 if(!d->mSecondPicker){
       
   829                     break;
       
   830                 }
       
   831 
       
   832                 d->mLabelSecond->setPreferredWidth(d->mSecondPicker->preferredSize().width());
       
   833                break;
       
   834 
       
   835             case HbDateTimeParser::MinuteSection:
       
   836                 if(!d->mMinutePicker){
       
   837                     break;
       
   838                 }
       
   839                d->mLabelMinute->setPreferredWidth(d->mMinutePicker->preferredSize().width());
       
   840                break;
       
   841 
       
   842             case HbDateTimeParser::Hour12Section:
       
   843             case HbDateTimeParser::Hour24Section:
       
   844                 if(!d->mHourPicker){
       
   845                     break;
       
   846                 }
       
   847                 d->mLabelHour->setPreferredWidth(d->mHourPicker->preferredSize().width());
       
   848                break;
       
   849 
       
   850             default:
       
   851                 break;
       
   852         }
       
   853     }
       
   854  
       
   855 }
       
   856 
       
   857 void HbDateTimePicker::initPrimitiveData(HbStylePrimitiveData *primitiveData, const QGraphicsObject *primitive)
       
   858 {
       
   859     HbWidget::initPrimitiveData(primitiveData, primitive);
       
   860     QString itemName = HbStyle::itemName(primitive);
       
   861     if(itemName == QLatin1String("background")) {
       
   862         HbStyleFramePrimitiveData *frameItem  = hbstyleprimitivedata_cast<HbStyleFramePrimitiveData*>(primitiveData);
       
   863         frameItem->frameGraphicsName= QLatin1String("qtg_fr_tumbler_bg");
       
   864         frameItem->frameType = HbFrameDrawer::NinePieces;
       
   865         (const_cast<QGraphicsObject *> (primitive))->setZValue(-5);
       
   866     }
       
   867 
       
   868     if(itemName == QLatin1String("frame")) {
       
   869         HbStyleFramePrimitiveData *frameItem  = hbstyleprimitivedata_cast<HbStyleFramePrimitiveData*>(primitiveData);
       
   870         frameItem->frameGraphicsName= QLatin1String("qtg_fr_tumbler_overlay");
       
   871         frameItem->frameType = HbFrameDrawer::NinePieces;
       
   872         (const_cast<QGraphicsObject *> (primitive))->setZValue(1);
       
   873         
       
   874     }
       
   875     if(itemName == QLatin1String("highlight")) {
       
   876         HbStyleFramePrimitiveData *frameItem  = hbstyleprimitivedata_cast<HbStyleFramePrimitiveData*>(primitiveData);
       
   877         frameItem->frameGraphicsName= QLatin1String("qtg_fr_tumbler_highlight_pri");
       
   878         frameItem->frameType = HbFrameDrawer::ThreePiecesHorizontal;
       
   879         (const_cast<QGraphicsObject *> (primitive))->setZValue(-1);
       
   880         
       
   881     }
       
   882 
       
   883 }
       
   884 
   755 void HbDateTimePicker::updatePrimitives()
   885 void HbDateTimePicker::updatePrimitives()
   756 {
   886 {
   757     Q_D(HbDateTimePicker);
   887     Q_D(HbDateTimePicker);
   758     HbStyleOption option;
   888     HbWidget::updatePrimitives();
   759     initStyleOption(&option);
   889     
   760     if(d->mBackground) {
   890     if(d->mBackground) {
   761         style()->updatePrimitive(d->mBackground,HbStyle::P_DateTimePicker_background,&option);
   891         HbStyleFramePrimitiveData data;
   762     }
   892         initPrimitiveData(&data,d->mBackground);
       
   893         style()->updatePrimitive(d->mBackground,&data,this);
       
   894         if(!d->mLastAdded.isNull()){
       
   895             QRectF geom = ((HbFrameItem*)d->mBackground)->geometry();
       
   896             ((HbFrameItem*)d->mBackground)->setGeometry(geom.x(), d->mLastAdded->pos().y(), geom.width(), d->mLastAdded->size().height());
       
   897         }
       
   898     }
       
   899 
   763     if(d->mFrame) {
   900     if(d->mFrame) {
   764         style()->updatePrimitive(d->mFrame,HbStyle::P_DateTimePicker_frame,&option);
   901         HbStyleFramePrimitiveData data;
       
   902         initPrimitiveData(&data,d->mFrame);
       
   903         style()->updatePrimitive(d->mFrame,&data,this);
       
   904         if(!d->mLastAdded.isNull()){
       
   905             QRectF geom = ((HbFrameItem*)d->mFrame)->geometry();
       
   906             ((HbFrameItem*)d->mFrame)->setGeometry(geom.x(), d->mLastAdded->pos().y(), geom.width(), d->mLastAdded->size().height());
       
   907         }
   765     }
   908     }
   766 
   909 
   767     if(d->mHighlight) {
   910     if(d->mHighlight) {
   768         style()->updatePrimitive(d->mHighlight,HbStyle::P_TumbleView_highlight,&option);
   911         HbStyleFramePrimitiveData data;
   769     }
   912         initPrimitiveData (&data,d->mHighlight);
       
   913         style()->updatePrimitive(d->mHighlight,&data,this);
       
   914         if(!d->mLastAdded.isNull()){
       
   915             qreal top = d->mLastAdded->pos().y() + d->mLastAdded->size().height()/2 - ((HbFrameItem*)d->mHighlight)->geometry().height()/2;
       
   916             d->mHighlight->setPos(d->mHighlight->pos().x(), top);
       
   917         }
       
   918 
       
   919     }
       
   920 }
       
   921 
       
   922 QGraphicsItem *HbDateTimePicker::primitive(const QString &itemName) const
       
   923 {
       
   924     Q_D(const HbDateTimePicker);
       
   925 
       
   926     if(!itemName.compare(QString("background"))){
       
   927         return d->mBackground;
       
   928     }
       
   929     if(!itemName.compare(QString("frame"))){
       
   930         return d->mFrame;
       
   931     }
       
   932     if(!itemName.compare(QString("highlight"))){
       
   933         return d->mHighlight;
       
   934     }
       
   935 
       
   936     return HbWidget::primitive(itemName);
   770 }
   937 }
   771 
   938 
   772 #include "moc_hbdatetimepicker.cpp"
   939 #include "moc_hbdatetimepicker.cpp"