qdatetimeedit.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qdatetimeedit.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include <private/qdatetimeedit_p.h>-
35#include <qabstractspinbox.h>-
36#include <qapplication.h>-
37#include <qdatetimeedit.h>-
38#include <qdesktopwidget.h>-
39#include <qdebug.h>-
40#include <qevent.h>-
41#include <qlineedit.h>-
42#include <private/qlineedit_p.h>-
43#include <qlocale.h>-
44#include <qpainter.h>-
45#include <qlayout.h>-
46#include <qset.h>-
47#include <qstyle.h>-
48-
49#ifndef QT_NO_DATETIMEEDIT-
50-
51//#define QDATETIMEEDIT_QDTEDEBUG-
52#ifdef QDATETIMEEDIT_QDTEDEBUG-
53# define QDTEDEBUG qDebug() << QString::fromLatin1("%1:%2").arg(__FILE__).arg(__LINE__)-
54# define QDTEDEBUGN qDebug-
55#else-
56# define QDTEDEBUG if (false) qDebug()-
57# define QDTEDEBUGN if (false) qDebug-
58#endif-
59-
60QT_BEGIN_NAMESPACE-
61-
62// --- QDateTimeEdit ----
63-
64/*!-
65 \class QDateTimeEdit-
66 \brief The QDateTimeEdit class provides a widget for editing dates and times.-
67-
68 \ingroup basicwidgets-
69 \inmodule QtWidgets-
70-
71 QDateTimeEdit allows the user to edit dates by using the keyboard or-
72 the arrow keys to increase and decrease date and time values. The-
73 arrow keys can be used to move from section to section within the-
74 QDateTimeEdit box. Dates and times appear in accordance with the-
75 format set; see setDisplayFormat().-
76-
77 \snippet code/src_gui_widgets_qdatetimeedit.cpp 0-
78-
79 Here we've created a new QDateTimeEdit object initialized with-
80 today's date, and restricted the valid date range to today plus or-
81 minus 365 days. We've set the order to month, day, year.-
82-
83 The minimum value for QDateTimeEdit is 14 September 1752. You can-
84 change this by calling setMinimumDate(), taking into account that-
85 the minimum value for QDate is 2 January 4713BC.-
86-
87 Other useful functions are setMaximumDate(), setMinimumTime()-
88 and setMaximumTime().-
89-
90 \section1 Using a Pop-up Calendar Widget-
91-
92 QDateTimeEdit can be configured to allow a QCalendarWidget to be used-
93 to select dates. This is enabled by setting the calendarPopup property.-
94 Additionally, you can supply a custom calendar widget for use as the-
95 calendar pop-up by calling the setCalendarWidget() function. The existing-
96 calendar widget can be retrieved with calendarWidget().-
97-
98 \table 100%-
99 \row \li \inlineimage windowsvista-datetimeedit.png Screenshot of a Windows Vista style date time editing widget-
100 \li A date time editing widget shown in the \l{Windows Vista Style Widget Gallery}{Windows Vista widget style}.-
101 \row \li \inlineimage macintosh-datetimeedit.png Screenshot of a Macintosh style date time editing widget-
102 \li A date time editing widget shown in the \l{Macintosh Style Widget Gallery}{Macintosh widget style}.-
103 \row \li \inlineimage fusion-datetimeedit.png Screenshot of a Fusion style date time editing widget-
104 \li A date time editing widget shown in the \l{Fusion Style Widget Gallery}{Fusion widget style}.-
105 \endtable-
106-
107 \sa QDateEdit, QTimeEdit, QDate, QTime-
108*/-
109-
110/*!-
111 \enum QDateTimeEdit::Section-
112-
113 \value NoSection-
114 \value AmPmSection-
115 \value MSecSection-
116 \value SecondSection-
117 \value MinuteSection-
118 \value HourSection-
119 \value DaySection-
120 \value MonthSection-
121 \value YearSection-
122 \omitvalue DateSections_Mask-
123 \omitvalue TimeSections_Mask-
124*/-
125-
126/*!-
127 \fn void QDateTimeEdit::dateTimeChanged(const QDateTime &datetime)-
128-
129 This signal is emitted whenever the date or time is changed. The-
130 new date and time is passed in \a datetime.-
131*/-
132-
133/*!-
134 \fn void QDateTimeEdit::timeChanged(const QTime &time)-
135-
136 This signal is emitted whenever the time is changed. The new time-
137 is passed in \a time.-
138*/-
139-
140/*!-
141 \fn void QDateTimeEdit::dateChanged(const QDate &date)-
142-
143 This signal is emitted whenever the date is changed. The new date-
144 is passed in \a date.-
145*/-
146-
147-
148/*!-
149 Constructs an empty date time editor with a \a parent.-
150*/-
151-
152QDateTimeEdit::QDateTimeEdit(QWidget *parent)-
153 : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)-
154{-
155 Q_D(QDateTimeEdit);-
156 d->init(QDateTime(QDATETIMEEDIT_DATE_INITIAL, QDATETIMEEDIT_TIME_MIN));-
157}
never executed: end of block
0
158-
159/*!-
160 Constructs an empty date time editor with a \a parent. The value-
161 is set to \a datetime.-
162*/-
163-
164QDateTimeEdit::QDateTimeEdit(const QDateTime &datetime, QWidget *parent)-
165 : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)-
166{-
167 Q_D(QDateTimeEdit);-
168 d->init(datetime.isValid() ? datetime : QDateTime(QDATETIMEEDIT_DATE_INITIAL,-
169 QDATETIMEEDIT_TIME_MIN));-
170}
never executed: end of block
0
171-
172/*!-
173 \fn QDateTimeEdit::QDateTimeEdit(const QDate &date, QWidget *parent)-
174-
175 Constructs an empty date time editor with a \a parent.-
176 The value is set to \a date.-
177*/-
178-
179QDateTimeEdit::QDateTimeEdit(const QDate &date, QWidget *parent)-
180 : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)-
181{-
182 Q_D(QDateTimeEdit);-
183 d->init(date.isValid() ? date : QDATETIMEEDIT_DATE_INITIAL);-
184}
never executed: end of block
0
185-
186/*!-
187 \fn QDateTimeEdit::QDateTimeEdit(const QTime &time, QWidget *parent)-
188-
189 Constructs an empty date time editor with a \a parent.-
190 The value is set to \a time.-
191*/-
192-
193QDateTimeEdit::QDateTimeEdit(const QTime &time, QWidget *parent)-
194 : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)-
195{-
196 Q_D(QDateTimeEdit);-
197 d->init(time.isValid() ? time : QDATETIMEEDIT_TIME_MIN);-
198}
never executed: end of block
0
199-
200/*!-
201 \internal-
202*/-
203-
204QDateTimeEdit::QDateTimeEdit(const QVariant &var, QVariant::Type parserType, QWidget *parent)-
205 : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)-
206{-
207 Q_D(QDateTimeEdit);-
208 d->parserType = parserType;-
209 d->init(var);-
210}
never executed: end of block
0
211-
212/*!-
213 Destructor.-
214*/-
215QDateTimeEdit::~QDateTimeEdit()-
216{-
217}-
218-
219/*!-
220 \property QDateTimeEdit::dateTime-
221 \brief the QDateTime that is set in the QDateTimeEdit-
222-
223 When setting this property the timespec of the QDateTimeEdit remains the same-
224 and the timespec of the new QDateTime is ignored.-
225-
226 By default, this property contains a date that refers to January 1,-
227 2000 and a time of 00:00:00 and 0 milliseconds.-
228-
229 \sa date, time-
230*/-
231-
232QDateTime QDateTimeEdit::dateTime() const-
233{-
234 Q_D(const QDateTimeEdit);-
235 return d->value.toDateTime();
never executed: return d->value.toDateTime();
0
236}-
237-
238void QDateTimeEdit::setDateTime(const QDateTime &datetime)-
239{-
240 Q_D(QDateTimeEdit);-
241 if (datetime.isValid()) {
datetime.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
242 d->clearCache();-
243 if (!(d->sections & DateSections_Mask))
!(d->sections ...Sections_Mask)Description
TRUEnever evaluated
FALSEnever evaluated
0
244 setDateRange(datetime.date(), datetime.date());
never executed: setDateRange(datetime.date(), datetime.date());
0
245 d->setValue(QDateTime(datetime.date(), datetime.time(), d->spec), EmitIfChanged);-
246 }
never executed: end of block
0
247}
never executed: end of block
0
248-
249/*!-
250 \property QDateTimeEdit::date-
251 \brief the QDate that is set in the widget-
252-
253 By default, this property contains a date that refers to January 1, 2000.-
254-
255 \sa time, dateTime-
256*/-
257-
258/*!-
259 Returns the date of the date time edit.-
260*/-
261QDate QDateTimeEdit::date() const-
262{-
263 Q_D(const QDateTimeEdit);-
264 return d->value.toDate();
never executed: return d->value.toDate();
0
265}-
266-
267void QDateTimeEdit::setDate(const QDate &date)-
268{-
269 Q_D(QDateTimeEdit);-
270 if (date.isValid()) {
date.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
271 if (!(d->sections & DateSections_Mask))
!(d->sections ...Sections_Mask)Description
TRUEnever evaluated
FALSEnever evaluated
0
272 setDateRange(date, date);
never executed: setDateRange(date, date);
0
273-
274 d->clearCache();-
275 d->setValue(QDateTime(date, d->value.toTime(), d->spec), EmitIfChanged);-
276 d->updateTimeSpec();-
277 }
never executed: end of block
0
278}
never executed: end of block
0
279-
280/*!-
281 \property QDateTimeEdit::time-
282 \brief the QTime that is set in the widget-
283-
284 By default, this property contains a time of 00:00:00 and 0 milliseconds.-
285-
286 \sa date, dateTime-
287*/-
288-
289/*!-
290 Returns the time of the date time edit.-
291*/-
292QTime QDateTimeEdit::time() const-
293{-
294 Q_D(const QDateTimeEdit);-
295 return d->value.toTime();
never executed: return d->value.toTime();
0
296}-
297-
298void QDateTimeEdit::setTime(const QTime &time)-
299{-
300 Q_D(QDateTimeEdit);-
301 if (time.isValid()) {
time.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
302 d->clearCache();-
303 d->setValue(QDateTime(d->value.toDate(), time, d->spec), EmitIfChanged);-
304 }
never executed: end of block
0
305}
never executed: end of block
0
306-
307-
308/*!-
309 \property QDateTimeEdit::minimumDateTime-
310 \since 4.4-
311-
312 \brief the minimum datetime of the date time edit-
313-
314 When setting this property the \l maximumDateTime() is adjusted if-
315 necessary to ensure that the range remains valid. If the datetime is-
316 not a valid QDateTime object, this function does nothing.-
317-
318 The default minimumDateTime can be restored with-
319 clearMinimumDateTime()-
320-
321 By default, this property contains a date that refers to September 14,-
322 1752 and a time of 00:00:00 and 0 milliseconds.-
323-
324 \sa maximumDateTime(), minimumTime(), maximumTime(), minimumDate(),-
325 maximumDate(), setDateTimeRange(), setDateRange(), setTimeRange(),-
326 clearMaximumDateTime(), clearMinimumDate(),-
327 clearMaximumDate(), clearMinimumTime(), clearMaximumTime()-
328*/-
329-
330QDateTime QDateTimeEdit::minimumDateTime() const-
331{-
332 Q_D(const QDateTimeEdit);-
333 return d->minimum.toDateTime();
never executed: return d->minimum.toDateTime();
0
334}-
335-
336void QDateTimeEdit::clearMinimumDateTime()-
337{-
338 setMinimumDateTime(QDateTime(QDATETIMEEDIT_COMPAT_DATE_MIN, QDATETIMEEDIT_TIME_MIN));-
339}
never executed: end of block
0
340-
341void QDateTimeEdit::setMinimumDateTime(const QDateTime &dt)-
342{-
343 Q_D(QDateTimeEdit);-
344 if (dt.isValid() && dt.date() >= QDATETIMEEDIT_DATE_MIN) {
dt.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
dt.date() >= QDate(100, 1, 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
345 const QDateTime m = dt.toTimeSpec(d->spec);-
346 const QDateTime max = d->maximum.toDateTime();-
347 d->setRange(m, (max > m ? max : m));-
348 }
never executed: end of block
0
349}
never executed: end of block
0
350-
351/*!-
352 \property QDateTimeEdit::maximumDateTime-
353 \since 4.4-
354-
355 \brief the maximum datetime of the date time edit-
356-
357 When setting this property the \l minimumDateTime() is adjusted if-
358 necessary to ensure that the range remains valid. If the datetime is-
359 not a valid QDateTime object, this function does nothing.-
360-
361 The default maximumDateTime can be restored with-
362 clearMaximumDateTime().-
363-
364 By default, this property contains a date that refers to 31 December,-
365 7999 and a time of 23:59:59 and 999 milliseconds.-
366-
367 \sa minimumDateTime(), minimumTime(), maximumTime(), minimumDate(),-
368 maximumDate(), setDateTimeRange(), setDateRange(), setTimeRange(),-
369 clearMinimumDateTime(), clearMinimumDate(),-
370 clearMaximumDate(), clearMinimumTime(), clearMaximumTime()-
371*/-
372-
373QDateTime QDateTimeEdit::maximumDateTime() const-
374{-
375 Q_D(const QDateTimeEdit);-
376 return d->maximum.toDateTime();
never executed: return d->maximum.toDateTime();
0
377}-
378-
379void QDateTimeEdit::clearMaximumDateTime()-
380{-
381 setMaximumDateTime(QDATETIMEEDIT_DATETIME_MAX);-
382}
never executed: end of block
0
383-
384void QDateTimeEdit::setMaximumDateTime(const QDateTime &dt)-
385{-
386 Q_D(QDateTimeEdit);-
387 if (dt.isValid() && dt.date() <= QDATETIMEEDIT_DATE_MAX) {
dt.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
dt.date() <= Q...(7999, 12, 31)Description
TRUEnever evaluated
FALSEnever evaluated
0
388 const QDateTime m = dt.toTimeSpec(d->spec);-
389 const QDateTime min = d->minimum.toDateTime();-
390 d->setRange((min < m ? min : m), m);-
391 }
never executed: end of block
0
392}
never executed: end of block
0
393-
394-
395/*!-
396 Convenience function to set minimum and maximum date time with one-
397 function call.-
398 \since 4.4-
399-
400 \snippet code/src_gui_widgets_qdatetimeedit.cpp 1-
401-
402 is analogous to:-
403-
404 \snippet code/src_gui_widgets_qdatetimeedit.cpp 2-
405-
406 If either \a min or \a max are not valid, this function does-
407 nothing.-
408-
409 \sa setMinimumDate(), maximumDate(), setMaximumDate(),-
410 clearMinimumDate(), setMinimumTime(), maximumTime(),-
411 setMaximumTime(), clearMinimumTime(), QDateTime::isValid()-
412*/-
413-
414void QDateTimeEdit::setDateTimeRange(const QDateTime &min, const QDateTime &max)-
415{-
416 Q_D(QDateTimeEdit);-
417 const QDateTime minimum = min.toTimeSpec(d->spec);-
418 QDateTime maximum = max.toTimeSpec(d->spec);-
419 if (min > max)
min > maxDescription
TRUEnever evaluated
FALSEnever evaluated
0
420 maximum = minimum;
never executed: maximum = minimum;
0
421 d->setRange(minimum, maximum);-
422}
never executed: end of block
0
423-
424/*!-
425 \property QDateTimeEdit::minimumDate-
426-
427 \brief the minimum date of the date time edit-
428-
429 When setting this property the \l maximumDate is adjusted if-
430 necessary, to ensure that the range remains valid. If the date is-
431 not a valid QDate object, this function does nothing.-
432-
433 By default, this property contains a date that refers to September 14, 1752.-
434 The minimum date must be at least the first day in year 100, otherwise-
435 setMinimumDate() has no effect.-
436-
437 \sa minimumTime(), maximumTime(), setDateRange()-
438*/-
439-
440QDate QDateTimeEdit::minimumDate() const-
441{-
442 Q_D(const QDateTimeEdit);-
443 return d->minimum.toDate();
never executed: return d->minimum.toDate();
0
444}-
445-
446void QDateTimeEdit::setMinimumDate(const QDate &min)-
447{-
448 Q_D(QDateTimeEdit);-
449 if (min.isValid() && min >= QDATETIMEEDIT_DATE_MIN) {
min.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
min >= QDate(100, 1, 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
450 setMinimumDateTime(QDateTime(min, d->minimum.toTime(), d->spec));-
451 }
never executed: end of block
0
452}
never executed: end of block
0
453-
454void QDateTimeEdit::clearMinimumDate()-
455{-
456 setMinimumDate(QDATETIMEEDIT_COMPAT_DATE_MIN);-
457}
never executed: end of block
0
458-
459/*!-
460 \property QDateTimeEdit::maximumDate-
461-
462 \brief the maximum date of the date time edit-
463-
464 When setting this property the \l minimumDate is adjusted if-
465 necessary to ensure that the range remains valid. If the date is-
466 not a valid QDate object, this function does nothing.-
467-
468 By default, this property contains a date that refers to December 31, 7999.-
469-
470 \sa minimumDate, minimumTime, maximumTime, setDateRange()-
471*/-
472-
473QDate QDateTimeEdit::maximumDate() const-
474{-
475 Q_D(const QDateTimeEdit);-
476 return d->maximum.toDate();
never executed: return d->maximum.toDate();
0
477}-
478-
479void QDateTimeEdit::setMaximumDate(const QDate &max)-
480{-
481 Q_D(QDateTimeEdit);-
482 if (max.isValid()) {
max.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
483 setMaximumDateTime(QDateTime(max, d->maximum.toTime(), d->spec));-
484 }
never executed: end of block
0
485}
never executed: end of block
0
486-
487void QDateTimeEdit::clearMaximumDate()-
488{-
489 setMaximumDate(QDATETIMEEDIT_DATE_MAX);-
490}
never executed: end of block
0
491-
492/*!-
493 \property QDateTimeEdit::minimumTime-
494-
495 \brief the minimum time of the date time edit-
496-
497 When setting this property the \l maximumTime is adjusted if-
498 necessary, to ensure that the range remains valid. If the time is-
499 not a valid QTime object, this function does nothing.-
500-
501 By default, this property contains a time of 00:00:00 and 0 milliseconds.-
502-
503 \sa maximumTime, minimumDate, maximumDate, setTimeRange()-
504*/-
505-
506QTime QDateTimeEdit::minimumTime() const-
507{-
508 Q_D(const QDateTimeEdit);-
509 return d->minimum.toTime();
never executed: return d->minimum.toTime();
0
510}-
511-
512void QDateTimeEdit::setMinimumTime(const QTime &min)-
513{-
514 Q_D(QDateTimeEdit);-
515 if (min.isValid()) {
min.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
516 const QDateTime m(d->minimum.toDate(), min, d->spec);-
517 setMinimumDateTime(m);-
518 }
never executed: end of block
0
519}
never executed: end of block
0
520-
521void QDateTimeEdit::clearMinimumTime()-
522{-
523 setMinimumTime(QDATETIMEEDIT_TIME_MIN);-
524}
never executed: end of block
0
525-
526/*!-
527 \property QDateTimeEdit::maximumTime-
528-
529 \brief the maximum time of the date time edit-
530-
531 When setting this property, the \l minimumTime is adjusted if-
532 necessary to ensure that the range remains valid. If the time is-
533 not a valid QTime object, this function does nothing.-
534-
535 By default, this property contains a time of 23:59:59 and 999 milliseconds.-
536-
537 \sa minimumTime, minimumDate, maximumDate, setTimeRange()-
538*/-
539QTime QDateTimeEdit::maximumTime() const-
540{-
541 Q_D(const QDateTimeEdit);-
542 return d->maximum.toTime();
never executed: return d->maximum.toTime();
0
543}-
544-
545void QDateTimeEdit::setMaximumTime(const QTime &max)-
546{-
547 Q_D(QDateTimeEdit);-
548 if (max.isValid()) {
max.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
549 const QDateTime m(d->maximum.toDate(), max);-
550 setMaximumDateTime(m);-
551 }
never executed: end of block
0
552}
never executed: end of block
0
553-
554void QDateTimeEdit::clearMaximumTime()-
555{-
556 setMaximumTime(QDATETIMEEDIT_TIME_MAX);-
557}
never executed: end of block
0
558-
559/*!-
560 Convenience function to set minimum and maximum date with one-
561 function call.-
562-
563 \snippet code/src_gui_widgets_qdatetimeedit.cpp 3-
564-
565 is analogous to:-
566-
567 \snippet code/src_gui_widgets_qdatetimeedit.cpp 4-
568-
569 If either \a min or \a max are not valid, this function does-
570 nothing.-
571-
572 \sa setMinimumDate(), maximumDate(), setMaximumDate(),-
573 clearMinimumDate(), setMinimumTime(), maximumTime(),-
574 setMaximumTime(), clearMinimumTime(), QDate::isValid()-
575*/-
576-
577void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max)-
578{-
579 Q_D(QDateTimeEdit);-
580 if (min.isValid() && max.isValid()) {
min.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
max.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
581 setDateTimeRange(QDateTime(min, d->minimum.toTime(), d->spec),-
582 QDateTime(max, d->maximum.toTime(), d->spec));-
583 }
never executed: end of block
0
584}
never executed: end of block
0
585-
586/*!-
587 Convenience function to set minimum and maximum time with one-
588 function call.-
589-
590 \snippet code/src_gui_widgets_qdatetimeedit.cpp 5-
591-
592 is analogous to:-
593-
594 \snippet code/src_gui_widgets_qdatetimeedit.cpp 6-
595-
596 If either \a min or \a max are not valid, this function does-
597 nothing.-
598-
599 \sa setMinimumDate(), maximumDate(), setMaximumDate(),-
600 clearMinimumDate(), setMinimumTime(), maximumTime(),-
601 setMaximumTime(), clearMinimumTime(), QTime::isValid()-
602*/-
603-
604void QDateTimeEdit::setTimeRange(const QTime &min, const QTime &max)-
605{-
606 Q_D(QDateTimeEdit);-
607 if (min.isValid() && max.isValid()) {
min.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
max.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
608 setDateTimeRange(QDateTime(d->minimum.toDate(), min, d->spec),-
609 QDateTime(d->maximum.toDate(), max, d->spec));-
610 }
never executed: end of block
0
611}
never executed: end of block
0
612-
613/*!-
614 \property QDateTimeEdit::displayedSections-
615-
616 \brief the currently displayed fields of the date time edit-
617-
618 Returns a bit set of the displayed sections for this format.-
619 \a setDisplayFormat(), displayFormat()-
620*/-
621-
622QDateTimeEdit::Sections QDateTimeEdit::displayedSections() const-
623{-
624 Q_D(const QDateTimeEdit);-
625 return d->sections;
never executed: return d->sections;
0
626}-
627-
628/*!-
629 \property QDateTimeEdit::currentSection-
630-
631 \brief the current section of the spinbox-
632 \a setCurrentSection()-
633*/-
634-
635QDateTimeEdit::Section QDateTimeEdit::currentSection() const-
636{-
637 Q_D(const QDateTimeEdit);-
638#ifdef QT_KEYPAD_NAVIGATION-
639 if (QApplication::keypadNavigationEnabled() && d->focusOnButton)-
640 return NoSection;-
641#endif-
642 return d->convertToPublic(d->sectionType(d->currentSectionIndex));
never executed: return d->convertToPublic(d->sectionType(d->currentSectionIndex));
0
643}-
644-
645void QDateTimeEdit::setCurrentSection(Section section)-
646{-
647 Q_D(QDateTimeEdit);-
648 if (section == NoSection || !(section & d->sections))
section == NoSectionDescription
TRUEnever evaluated
FALSEnever evaluated
!(section & d->sections)Description
TRUEnever evaluated
FALSEnever evaluated
0
649 return;
never executed: return;
0
650-
651 d->updateCache(d->value, d->displayText());-
652 const int size = d->sectionNodes.size();-
653 int index = d->currentSectionIndex + 1;-
654 for (int i=0; i<2; ++i) {
i<2Description
TRUEnever evaluated
FALSEnever evaluated
0
655 while (index < size) {
index < sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
656 if (d->convertToPublic(d->sectionType(index)) == section) {
d->convertToPu...x)) == sectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
657 d->edit->setCursorPosition(d->sectionPos(index));-
658 QDTEDEBUG << d->sectionPos(index);
dead code: QMessageLogger(__FILE__, 658, __PRETTY_FUNCTION__).debug() << d->sectionPos(index);
-
659 return;
never executed: return;
0
660 }-
661 ++index;-
662 }
never executed: end of block
0
663 index = 0;-
664 }
never executed: end of block
0
665}
never executed: end of block
0
666-
667/*!-
668 \since 4.3-
669-
670 Returns the Section at \a index.-
671-
672 If the format is 'yyyy/MM/dd', sectionAt(0) returns YearSection,-
673 sectionAt(1) returns MonthSection, and sectionAt(2) returns-
674 YearSection,-
675*/-
676-
677QDateTimeEdit::Section QDateTimeEdit::sectionAt(int index) const-
678{-
679 Q_D(const QDateTimeEdit);-
680 if (index < 0 || index >= d->sectionNodes.size())
index < 0Description
TRUEnever evaluated
FALSEnever evaluated
index >= d->se...onNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
681 return NoSection;
never executed: return NoSection;
0
682 return d->convertToPublic(d->sectionType(index));
never executed: return d->convertToPublic(d->sectionType(index));
0
683}-
684-
685/*!-
686 \since 4.3-
687-
688 \property QDateTimeEdit::sectionCount-
689-
690 \brief the number of sections displayed.-
691 If the format is 'yyyy/yy/yyyy', sectionCount returns 3-
692*/-
693-
694int QDateTimeEdit::sectionCount() const-
695{-
696 Q_D(const QDateTimeEdit);-
697 return d->sectionNodes.size();
never executed: return d->sectionNodes.size();
0
698}-
699-
700-
701/*!-
702 \since 4.3-
703-
704 \property QDateTimeEdit::currentSectionIndex-
705-
706 \brief the current section index of the spinbox-
707-
708 If the format is 'yyyy/MM/dd', the displayText is '2001/05/21', and-
709 the cursorPosition is 5, currentSectionIndex returns 1. If the-
710 cursorPosition is 3, currentSectionIndex is 0, and so on.-
711-
712 \a setCurrentSection()-
713 \sa currentSection()-
714*/-
715-
716int QDateTimeEdit::currentSectionIndex() const-
717{-
718 Q_D(const QDateTimeEdit);-
719 return d->currentSectionIndex;
never executed: return d->currentSectionIndex;
0
720}-
721-
722void QDateTimeEdit::setCurrentSectionIndex(int index)-
723{-
724 Q_D(QDateTimeEdit);-
725 if (index < 0 || index >= d->sectionNodes.size())
index < 0Description
TRUEnever evaluated
FALSEnever evaluated
index >= d->se...onNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
726 return;
never executed: return;
0
727 d->edit->setCursorPosition(d->sectionPos(index));-
728}
never executed: end of block
0
729-
730/*!-
731 \since 4.4-
732-
733 \brief Returns the calendar widget for the editor if calendarPopup is-
734 set to true and (sections() & DateSections_Mask) != 0.-
735-
736 This function creates and returns a calendar widget if none has been set.-
737*/-
738-
739-
740QCalendarWidget *QDateTimeEdit::calendarWidget() const-
741{-
742 Q_D(const QDateTimeEdit);-
743 if (!d->calendarPopup || !(d->sections & QDateTimeParser::DateSectionMask))
!d->calendarPopupDescription
TRUEnever evaluated
FALSEnever evaluated
!(d->sections ...teSectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
744 return 0;
never executed: return 0;
0
745 if (!d->monthCalendar) {
!d->monthCalendarDescription
TRUEnever evaluated
FALSEnever evaluated
0
746 const_cast<QDateTimeEditPrivate*>(d)->initCalendarPopup();-
747 }
never executed: end of block
0
748 return d->monthCalendar->calendarWidget();
never executed: return d->monthCalendar->calendarWidget();
0
749}-
750-
751/*!-
752 \since 4.4-
753-
754 Sets the given \a calendarWidget as the widget to be used for the calendar-
755 pop-up. The editor does not automatically take ownership of the calendar widget.-
756-
757 \note calendarPopup must be set to true before setting the calendar widget.-
758 \sa calendarPopup-
759*/-
760void QDateTimeEdit::setCalendarWidget(QCalendarWidget *calendarWidget)-
761{-
762 Q_D(QDateTimeEdit);-
763 if (!calendarWidget) {
!calendarWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
764 qWarning("QDateTimeEdit::setCalendarWidget: Cannot set a null calendar widget");-
765 return;
never executed: return;
0
766 }-
767-
768 if (!d->calendarPopup) {
!d->calendarPopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
769 qWarning("QDateTimeEdit::setCalendarWidget: calendarPopup is set to false");-
770 return;
never executed: return;
0
771 }-
772-
773 if (!(d->display & QDateTimeParser::DateSectionMask)) {
!(d->display &...teSectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
774 qWarning("QDateTimeEdit::setCalendarWidget: no date sections specified");-
775 return;
never executed: return;
0
776 }-
777 d->initCalendarPopup(calendarWidget);-
778}
never executed: end of block
0
779-
780-
781/*!-
782 \since 4.2-
783-
784 Selects \a section. If \a section doesn't exist in the currently-
785 displayed sections, this function does nothing. If \a section is-
786 NoSection, this function will unselect all text in the editor.-
787 Otherwise, this function will move the cursor and the current section-
788 to the selected section.-
789-
790 \sa currentSection()-
791*/-
792-
793void QDateTimeEdit::setSelectedSection(Section section)-
794{-
795 Q_D(QDateTimeEdit);-
796 if (section == NoSection) {
section == NoSectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
797 d->edit->setSelection(d->edit->cursorPosition(), 0);-
798 } else if (section & d->sections) {
never executed: end of block
section & d->sectionsDescription
TRUEnever evaluated
FALSEnever evaluated
0
799 if (currentSection() != section)
currentSection() != sectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
800 setCurrentSection(section);
never executed: setCurrentSection(section);
0
801 d->setSelected(d->currentSectionIndex);-
802 }
never executed: end of block
0
803}
never executed: end of block
0
804-
805-
806-
807/*!-
808 \fn QString QDateTimeEdit::sectionText(Section section) const-
809-
810 Returns the text from the given \a section.-
811-
812 \sa currentSection()-
813*/-
814-
815QString QDateTimeEdit::sectionText(Section section) const-
816{-
817 Q_D(const QDateTimeEdit);-
818 if (section == QDateTimeEdit::NoSection || !(section & d->sections)) {
section == QDa...dit::NoSectionDescription
TRUEnever evaluated
FALSEnever evaluated
!(section & d->sections)Description
TRUEnever evaluated
FALSEnever evaluated
0
819 return QString();
never executed: return QString();
0
820 }-
821-
822 d->updateCache(d->value, d->displayText());-
823 const int sectionIndex = d->absoluteIndex(section, 0);-
824 return d->sectionText(sectionIndex);
never executed: return d->sectionText(sectionIndex);
0
825}-
826-
827/*!-
828 \property QDateTimeEdit::displayFormat-
829-
830 \brief the format used to display the time/date of the date time edit-
831-
832 This format is described in QDateTime::toString() and QDateTime::fromString()-
833-
834 Example format strings (assuming that the date is 2nd of July 1969):-
835-
836 \table-
837 \header \li Format \li Result-
838 \row \li dd.MM.yyyy \li 02.07.1969-
839 \row \li MMM d yy \li Jul 2 69-
840 \row \li MMMM d yy \li July 2 69-
841 \endtable-
842-
843 Note that if you specify a two digit year, it will be interpreted-
844 to be in the century in which the date time edit was initialized.-
845 The default century is the 21 (2000-2099).-
846-
847 If you specify an invalid format the format will not be set.-
848-
849 \sa QDateTime::toString(), displayedSections()-
850*/-
851-
852QString QDateTimeEdit::displayFormat() const-
853{-
854 Q_D(const QDateTimeEdit);-
855 return isRightToLeft() ? d->unreversedFormat : d->displayFormat;
never executed: return isRightToLeft() ? d->unreversedFormat : d->displayFormat;
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
856}-
857-
858template<typename C> static inline C reverse(const C &l)-
859{-
860 C ret;-
861 for (int i=l.size() - 1; i>=0; --i)
i>=0Description
TRUEnever evaluated
FALSEnever evaluated
0
862 ret.append(l.at(i));
never executed: ret.append(l.at(i));
0
863 return ret;
never executed: return ret;
0
864}-
865-
866void QDateTimeEdit::setDisplayFormat(const QString &format)-
867{-
868 Q_D(QDateTimeEdit);-
869 if (d->parseFormat(format)) {
d->parseFormat(format)Description
TRUEnever evaluated
FALSEnever evaluated
0
870 d->unreversedFormat.clear();-
871 if (isRightToLeft()) {
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
872 d->unreversedFormat = format;-
873 d->displayFormat.clear();-
874 for (int i=d->sectionNodes.size() - 1; i>=0; --i) {
i>=0Description
TRUEnever evaluated
FALSEnever evaluated
0
875 d->displayFormat += d->separators.at(i + 1);-
876 d->displayFormat += d->sectionNode(i).format();-
877 }
never executed: end of block
0
878 d->displayFormat += d->separators.at(0);-
879 d->separators = reverse(d->separators);-
880 d->sectionNodes = reverse(d->sectionNodes);-
881 }
never executed: end of block
0
882-
883 d->formatExplicitlySet = true;-
884 d->sections = d->convertSections(d->display);-
885 d->clearCache();-
886-
887 d->currentSectionIndex = qMin(d->currentSectionIndex, d->sectionNodes.size() - 1);-
888 const bool timeShown = (d->sections & TimeSections_Mask);-
889 const bool dateShown = (d->sections & DateSections_Mask);-
890 Q_ASSERT(dateShown || timeShown);-
891 if (timeShown && !dateShown) {
timeShownDescription
TRUEnever evaluated
FALSEnever evaluated
!dateShownDescription
TRUEnever evaluated
FALSEnever evaluated
0
892 QTime time = d->value.toTime();-
893 setDateRange(d->value.toDate(), d->value.toDate());-
894 if (d->minimum.toTime() >= d->maximum.toTime()) {
d->minimum.toT...ximum.toTime()Description
TRUEnever evaluated
FALSEnever evaluated
0
895 setTimeRange(QDATETIMEEDIT_TIME_MIN, QDATETIMEEDIT_TIME_MAX);-
896 // if the time range became invalid during the adjustment, the time would have been reset-
897 setTime(time);-
898 }
never executed: end of block
0
899 } else if (dateShown && !timeShown) {
never executed: end of block
dateShownDescription
TRUEnever evaluated
FALSEnever evaluated
!timeShownDescription
TRUEnever evaluated
FALSEnever evaluated
0
900 setTimeRange(QDATETIMEEDIT_TIME_MIN, QDATETIMEEDIT_TIME_MAX);-
901 d->value = QDateTime(d->value.toDate(), QTime(), d->spec);-
902 }
never executed: end of block
0
903 d->updateEdit();-
904 d->_q_editorCursorPositionChanged(-1, 0);-
905 }
never executed: end of block
0
906}
never executed: end of block
0
907-
908/*!-
909 \property QDateTimeEdit::calendarPopup-
910 \brief the current calendar pop-up show mode.-
911 \since 4.2-
912-
913 The calendar pop-up will be shown upon clicking the arrow button.-
914 This property is valid only if there is a valid date display format.-
915-
916 \sa setDisplayFormat()-
917*/-
918-
919bool QDateTimeEdit::calendarPopup() const-
920{-
921 Q_D(const QDateTimeEdit);-
922 return d->calendarPopup;
never executed: return d->calendarPopup;
0
923}-
924-
925void QDateTimeEdit::setCalendarPopup(bool enable)-
926{-
927 Q_D(QDateTimeEdit);-
928 if (enable == d->calendarPopup)
enable == d->calendarPopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
929 return;
never executed: return;
0
930 setAttribute(Qt::WA_MacShowFocusRect, !enable);-
931 d->calendarPopup = enable;-
932#ifdef QT_KEYPAD_NAVIGATION-
933 if (!enable)-
934 d->focusOnButton = false;-
935#endif-
936 d->updateEditFieldGeometry();-
937 update();-
938}
never executed: end of block
0
939-
940/*!-
941 \property QDateTimeEdit::timeSpec-
942 \brief the current timespec used by the date time edit.-
943 \since 4.4-
944*/-
945-
946Qt::TimeSpec QDateTimeEdit::timeSpec() const-
947{-
948 Q_D(const QDateTimeEdit);-
949 return d->spec;
never executed: return d->spec;
0
950}-
951-
952void QDateTimeEdit::setTimeSpec(Qt::TimeSpec spec)-
953{-
954 Q_D(QDateTimeEdit);-
955 if (spec != d->spec) {
spec != d->specDescription
TRUEnever evaluated
FALSEnever evaluated
0
956 d->spec = spec;-
957 d->updateTimeSpec();-
958 }
never executed: end of block
0
959}
never executed: end of block
0
960-
961/*!-
962 \reimp-
963*/-
964-
965QSize QDateTimeEdit::sizeHint() const-
966{-
967 Q_D(const QDateTimeEdit);-
968 if (d->cachedSizeHint.isEmpty()) {
d->cachedSizeHint.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
969 ensurePolished();-
970-
971 const QFontMetrics fm(fontMetrics());-
972 int h = d->edit->sizeHint().height();-
973 int w = 0;-
974 QString s;-
975 s = d->textFromValue(d->minimum) + QLatin1Char(' ');-
976 w = qMax<int>(w, fm.width(s));-
977 s = d->textFromValue(d->maximum) + QLatin1Char(' ');-
978 w = qMax<int>(w, fm.width(s));-
979 if (d->specialValueText.size()) {
d->specialValueText.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
980 s = d->specialValueText;-
981 w = qMax<int>(w, fm.width(s));-
982 }
never executed: end of block
0
983 w += 2; // cursor blinking space-
984-
985 QSize hint(w, h);-
986-
987#ifdef Q_OS_MAC-
988 if (d->calendarPopupEnabled()) {-
989 QStyleOptionComboBox opt;-
990 d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_ComboBox, &opt, hint, this);-
991 } else-
992#endif-
993 {-
994 QStyleOptionSpinBox opt;-
995 initStyleOption(&opt);-
996 d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this)-
997 .expandedTo(QApplication::globalStrut());-
998 }-
999-
1000 d->cachedMinimumSizeHint = d->cachedSizeHint;-
1001 // essentially make minimumSizeHint return the same as sizeHint for datetimeedits-
1002 }
never executed: end of block
0
1003 return d->cachedSizeHint;
never executed: return d->cachedSizeHint;
0
1004}-
1005-
1006-
1007/*!-
1008 \reimp-
1009*/-
1010-
1011bool QDateTimeEdit::event(QEvent *event)-
1012{-
1013 Q_D(QDateTimeEdit);-
1014 switch (event->type()) {-
1015 case QEvent::ApplicationLayoutDirectionChange: {
never executed: case QEvent::ApplicationLayoutDirectionChange:
0
1016 const bool was = d->formatExplicitlySet;-
1017 const QString oldFormat = d->displayFormat;-
1018 d->displayFormat.clear();-
1019 setDisplayFormat(oldFormat);-
1020 d->formatExplicitlySet = was;-
1021 break; }
never executed: break;
0
1022 case QEvent::LocaleChange:
never executed: case QEvent::LocaleChange:
0
1023 d->updateEdit();-
1024 break;
never executed: break;
0
1025 case QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
1026#ifdef Q_OS_MAC-
1027 case QEvent::MacSizeChange:-
1028#endif-
1029 d->setLayoutItemMargins(QStyle::SE_DateTimeEditLayoutItem);-
1030 break;
never executed: break;
0
1031 default:
never executed: default:
0
1032 break;
never executed: break;
0
1033 }-
1034 return QAbstractSpinBox::event(event);
never executed: return QAbstractSpinBox::event(event);
0
1035}-
1036-
1037/*!-
1038 \reimp-
1039*/-
1040-
1041void QDateTimeEdit::clear()-
1042{-
1043 Q_D(QDateTimeEdit);-
1044 d->clearSection(d->currentSectionIndex);-
1045}
never executed: end of block
0
1046/*!-
1047 \reimp-
1048*/-
1049-
1050void QDateTimeEdit::keyPressEvent(QKeyEvent *event)-
1051{-
1052 Q_D(QDateTimeEdit);-
1053 int oldCurrent = d->currentSectionIndex;-
1054 bool select = true;-
1055 bool inserted = false;-
1056-
1057 switch (event->key()) {-
1058#ifdef QT_KEYPAD_NAVIGATION-
1059 case Qt::Key_NumberSign: //shortcut to popup calendar-
1060 if (QApplication::keypadNavigationEnabled() && d->calendarPopupEnabled()) {-
1061 d->initCalendarPopup();-
1062 d->positionCalendarPopup();-
1063 d->monthCalendar->show();-
1064 return;-
1065 }-
1066 break;-
1067 case Qt::Key_Select:-
1068 if (QApplication::keypadNavigationEnabled()) {-
1069 if (hasEditFocus()) {-
1070 if (d->focusOnButton) {-
1071 d->initCalendarPopup();-
1072 d->positionCalendarPopup();-
1073 d->monthCalendar->show();-
1074 d->focusOnButton = false;-
1075 return;-
1076 }-
1077 setEditFocus(false);-
1078 selectAll();-
1079 } else {-
1080 setEditFocus(true);-
1081-
1082 //hide cursor-
1083 d->edit->d_func()->setCursorVisible(false);-
1084 d->edit->d_func()->control->setCursorBlinkPeriod(0);-
1085 d->setSelected(0);-
1086 }-
1087 }-
1088 return;-
1089#endif-
1090 case Qt::Key_Enter:
never executed: case Qt::Key_Enter:
0
1091 case Qt::Key_Return:
never executed: case Qt::Key_Return:
0
1092 d->interpret(AlwaysEmit);-
1093 d->setSelected(d->currentSectionIndex, true);-
1094 event->ignore();-
1095 emit editingFinished();-
1096 return;
never executed: return;
0
1097 default:
never executed: default:
0
1098#ifdef QT_KEYPAD_NAVIGATION-
1099 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()-
1100 && !event->text().isEmpty() && event->text().at(0).isLetterOrNumber()) {-
1101 setEditFocus(true);-
1102-
1103 //hide cursor-
1104 d->edit->d_func()->setCursorVisible(false);-
1105 d->edit->d_func()->control->setCursorBlinkPeriod(0);-
1106 d->setSelected(0);-
1107 oldCurrent = 0;-
1108 }-
1109#endif-
1110 if (!d->isSeparatorKey(event)) {
!d->isSeparatorKey(event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1111 inserted = select = !event->text().isEmpty() && event->text().at(0).isPrint()
!event->text().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
event->text().at(0).isPrint()Description
TRUEnever evaluated
FALSEnever evaluated
0
1112 && !(event->modifiers() & ~(Qt::ShiftModifier|Qt::KeypadModifier));
!(event->modif...ypadModifier))Description
TRUEnever evaluated
FALSEnever evaluated
0
1113 break;
never executed: break;
0
1114 }-
1115 case Qt::Key_Left:
code before this statement never executed: case Qt::Key_Left:
never executed: case Qt::Key_Left:
0
1116 case Qt::Key_Right:
never executed: case Qt::Key_Right:
0
1117 if (event->key() == Qt::Key_Left || event->key() == Qt::Key_Right) {
event->key() == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
event->key() == Qt::Key_RightDescription
TRUEnever evaluated
FALSEnever evaluated
0
1118 if (-
1119#ifdef QT_KEYPAD_NAVIGATION-
1120 QApplication::keypadNavigationEnabled() && !hasEditFocus()-
1121 || !QApplication::keypadNavigationEnabled() &&-
1122#endif-
1123 !(event->modifiers() & Qt::ControlModifier)) {
!(event->modif...ntrolModifier)Description
TRUEnever evaluated
FALSEnever evaluated
0
1124 select = false;-
1125 break;
never executed: break;
0
1126 }-
1127#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
1128 else-
1129#ifdef QT_KEYPAD_NAVIGATION-
1130 if (!QApplication::keypadNavigationEnabled())-
1131#endif-
1132 {-
1133 select = (event->modifiers() & Qt::ShiftModifier);-
1134 break;-
1135 }-
1136#endif-
1137 }
never executed: end of block
0
1138 // else fall through-
1139 case Qt::Key_Backtab:
code before this statement never executed: case Qt::Key_Backtab:
never executed: case Qt::Key_Backtab:
0
1140 case Qt::Key_Tab: {
never executed: case Qt::Key_Tab:
0
1141 event->accept();-
1142 if (d->specialValue()) {
d->specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
0
1143 d->edit->setSelection(d->edit->cursorPosition(), 0);-
1144 return;
never executed: return;
0
1145 }-
1146 const bool forward = event->key() != Qt::Key_Left && event->key() != Qt::Key_Backtab
event->key() != Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
event->key() !...t::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
0
1147 && (event->key() != Qt::Key_Tab || !(event->modifiers() & Qt::ShiftModifier));
event->key() != Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
!(event->modif...ShiftModifier)Description
TRUEnever evaluated
FALSEnever evaluated
0
1148#ifdef QT_KEYPAD_NAVIGATION-
1149 int newSection = d->nextPrevSection(d->currentSectionIndex, forward);-
1150 if (QApplication::keypadNavigationEnabled()) {-
1151 if (d->focusOnButton) {-
1152 newSection = forward ? 0 : d->sectionNodes.size() - 1;-
1153 d->focusOnButton = false;-
1154 update();-
1155 } else if (newSection < 0 && select && d->calendarPopupEnabled()) {-
1156 setSelectedSection(NoSection);-
1157 d->focusOnButton = true;-
1158 update();-
1159 return;-
1160 }-
1161 }-
1162 // only allow date/time sections to be selected.-
1163 if (newSection & ~(QDateTimeParser::TimeSectionMask | QDateTimeParser::DateSectionMask))-
1164 return;-
1165#endif-
1166 //key tab and backtab will be managed thrgout QWidget::event-
1167 if (event->key() != Qt::Key_Backtab && event->key() != Qt::Key_Tab)
event->key() !...t::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
event->key() != Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
0
1168 focusNextPrevChild(forward);
never executed: focusNextPrevChild(forward);
0
1169-
1170 return; }
never executed: return;
0
1171 }-
1172 QAbstractSpinBox::keyPressEvent(event);-
1173 if (select && !d->edit->hasSelectedText()) {
selectDescription
TRUEnever evaluated
FALSEnever evaluated
!d->edit->hasSelectedText()Description
TRUEnever evaluated
FALSEnever evaluated
0
1174 if (inserted && d->sectionAt(d->edit->cursorPosition()) == QDateTimeParser::NoSectionIndex) {
insertedDescription
TRUEnever evaluated
FALSEnever evaluated
d->sectionAt(d...NoSectionIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1175 QString str = d->displayText();-
1176 int pos = d->edit->cursorPosition();-
1177 if (validate(str, pos) == QValidator::Acceptable
validate(str, ...or::AcceptableDescription
TRUEnever evaluated
FALSEnever evaluated
0
1178 && (d->sectionNodes.at(oldCurrent).count != 1
d->sectionNode...nt).count != 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1179 || d->sectionMaxSize(oldCurrent) == d->sectionSize(oldCurrent)
d->sectionMaxS...ze(oldCurrent)Description
TRUEnever evaluated
FALSEnever evaluated
0
1180 || d->skipToNextSection(oldCurrent, d->value.toDateTime(), d->sectionText(oldCurrent)))) {
d->skipToNextS...t(oldCurrent))Description
TRUEnever evaluated
FALSEnever evaluated
0
1181 QDTEDEBUG << "Setting currentsection to"
dead code: QMessageLogger(__FILE__, 1181, __PRETTY_FUNCTION__).debug() << "Setting currentsection to" << d->closestSection(d->edit->cursorPosition(), true) << event->key() << oldCurrent << str;
-
1182 << d->closestSection(d->edit->cursorPosition(), true) << event->key()
dead code: QMessageLogger(__FILE__, 1181, __PRETTY_FUNCTION__).debug() << "Setting currentsection to" << d->closestSection(d->edit->cursorPosition(), true) << event->key() << oldCurrent << str;
-
1183 << oldCurrent << str;
dead code: QMessageLogger(__FILE__, 1181, __PRETTY_FUNCTION__).debug() << "Setting currentsection to" << d->closestSection(d->edit->cursorPosition(), true) << event->key() << oldCurrent << str;
-
1184 const int tmp = d->closestSection(d->edit->cursorPosition(), true);-
1185 if (tmp >= 0)
tmp >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1186 d->currentSectionIndex = tmp;
never executed: d->currentSectionIndex = tmp;
0
1187 }
never executed: end of block
0
1188 }
never executed: end of block
0
1189 if (d->currentSectionIndex != oldCurrent) {
d->currentSect... != oldCurrentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1190 d->setSelected(d->currentSectionIndex);-
1191 }
never executed: end of block
0
1192 }
never executed: end of block
0
1193 if (d->specialValue()) {
d->specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
0
1194 d->edit->setSelection(d->edit->cursorPosition(), 0);-
1195 }
never executed: end of block
0
1196}
never executed: end of block
0
1197-
1198/*!-
1199 \reimp-
1200*/-
1201-
1202#ifndef QT_NO_WHEELEVENT-
1203void QDateTimeEdit::wheelEvent(QWheelEvent *event)-
1204{-
1205 QAbstractSpinBox::wheelEvent(event);-
1206}
never executed: end of block
0
1207#endif-
1208-
1209/*!-
1210 \reimp-
1211*/-
1212-
1213void QDateTimeEdit::focusInEvent(QFocusEvent *event)-
1214{-
1215 Q_D(QDateTimeEdit);-
1216 QAbstractSpinBox::focusInEvent(event);-
1217 QString *frm = 0;-
1218 const int oldPos = d->edit->cursorPosition();-
1219 if (!d->formatExplicitlySet) {
!d->formatExplicitlySetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1220 if (d->displayFormat == d->defaultTimeFormat) {
d->displayForm...aultTimeFormatDescription
TRUEnever evaluated
FALSEnever evaluated
0
1221 frm = &d->defaultTimeFormat;-
1222 } else if (d->displayFormat == d->defaultDateFormat) {
never executed: end of block
d->displayForm...aultDateFormatDescription
TRUEnever evaluated
FALSEnever evaluated
0
1223 frm = &d->defaultDateFormat;-
1224 } else if (d->displayFormat == d->defaultDateTimeFormat) {
never executed: end of block
d->displayForm...DateTimeFormatDescription
TRUEnever evaluated
FALSEnever evaluated
0
1225 frm = &d->defaultDateTimeFormat;-
1226 }
never executed: end of block
0
1227-
1228 if (frm) {
frmDescription
TRUEnever evaluated
FALSEnever evaluated
0
1229 d->readLocaleSettings();-
1230 if (d->displayFormat != *frm) {
d->displayFormat != *frmDescription
TRUEnever evaluated
FALSEnever evaluated
0
1231 setDisplayFormat(*frm);-
1232 d->formatExplicitlySet = false;-
1233 d->edit->setCursorPosition(oldPos);-
1234 }
never executed: end of block
0
1235 }
never executed: end of block
0
1236 }
never executed: end of block
0
1237 const bool oldHasHadFocus = d->hasHadFocus;-
1238 d->hasHadFocus = true;-
1239 bool first = true;-
1240 switch (event->reason()) {-
1241 case Qt::BacktabFocusReason:
never executed: case Qt::BacktabFocusReason:
0
1242 first = false;-
1243 break;
never executed: break;
0
1244 case Qt::MouseFocusReason:
never executed: case Qt::MouseFocusReason:
0
1245 case Qt::PopupFocusReason:
never executed: case Qt::PopupFocusReason:
0
1246 return;
never executed: return;
0
1247 case Qt::ActiveWindowFocusReason:
never executed: case Qt::ActiveWindowFocusReason:
0
1248 if (oldHasHadFocus)
oldHasHadFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
1249 return;
never executed: return;
0
1250 case Qt::ShortcutFocusReason:
code before this statement never executed: case Qt::ShortcutFocusReason:
never executed: case Qt::ShortcutFocusReason:
0
1251 case Qt::TabFocusReason:
never executed: case Qt::TabFocusReason:
0
1252 default:
never executed: default:
0
1253 break;
never executed: break;
0
1254 }-
1255 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
1256 first = !first;
never executed: first = !first;
0
1257 d->updateEdit(); // needed to make it update specialValueText-
1258-
1259 d->setSelected(first ? 0 : d->sectionNodes.size() - 1);-
1260}
never executed: end of block
0
1261-
1262/*!-
1263 \reimp-
1264*/-
1265-
1266bool QDateTimeEdit::focusNextPrevChild(bool next)-
1267{-
1268 Q_D(QDateTimeEdit);-
1269 const int newSection = d->nextPrevSection(d->currentSectionIndex, next);-
1270 switch (d->sectionType(newSection)) {-
1271 case QDateTimeParser::NoSection:
never executed: case QDateTimeParser::NoSection:
0
1272 case QDateTimeParser::FirstSection:
never executed: case QDateTimeParser::FirstSection:
0
1273 case QDateTimeParser::LastSection:
never executed: case QDateTimeParser::LastSection:
0
1274 return QAbstractSpinBox::focusNextPrevChild(next);
never executed: return QAbstractSpinBox::focusNextPrevChild(next);
0
1275 default:
never executed: default:
0
1276 d->edit->deselect();-
1277 d->edit->setCursorPosition(d->sectionPos(newSection));-
1278 QDTEDEBUG << d->sectionPos(newSection);
dead code: QMessageLogger(__FILE__, 1278, __PRETTY_FUNCTION__).debug() << d->sectionPos(newSection);
-
1279 d->setSelected(newSection, true);-
1280 return false;
never executed: return false;
0
1281 }-
1282}-
1283-
1284/*!-
1285 \reimp-
1286*/-
1287-
1288void QDateTimeEdit::stepBy(int steps)-
1289{-
1290 Q_D(QDateTimeEdit);-
1291#ifdef QT_KEYPAD_NAVIGATION-
1292 // with keypad navigation and not editFocus, left right change the date/time by a fixed amount.-
1293 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {-
1294 // if date based, shift by day. else shift by 15min-
1295 if (d->sections & DateSections_Mask) {-
1296 setDateTime(dateTime().addDays(steps));-
1297 } else {-
1298 int minutes = time().hour()*60 + time().minute();-
1299 int blocks = minutes/15;-
1300 blocks += steps;-
1301 /* rounding involved */-
1302 if (minutes % 15) {-
1303 if (steps < 0) {-
1304 blocks += 1; // do one less step;-
1305 }-
1306 }-
1307-
1308 minutes = blocks * 15;-
1309-
1310 /* need to take wrapping into account */-
1311 if (!d->wrapping) {-
1312 int max_minutes = d->maximum.toTime().hour()*60 + d->maximum.toTime().minute();-
1313 int min_minutes = d->minimum.toTime().hour()*60 + d->minimum.toTime().minute();-
1314-
1315 if (minutes >= max_minutes) {-
1316 setTime(maximumTime());-
1317 return;-
1318 } else if (minutes <= min_minutes) {-
1319 setTime(minimumTime());-
1320 return;-
1321 }-
1322 }-
1323 setTime(QTime(minutes/60, minutes%60));-
1324 }-
1325 return;-
1326 }-
1327#endif-
1328 // don't optimize away steps == 0. This is the only way to select-
1329 // the currentSection in Qt 4.1.x-
1330 if (d->specialValue() && displayedSections() != AmPmSection) {
d->specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
displayedSecti...!= AmPmSectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1331 for (int i=0; i<d->sectionNodes.size(); ++i) {
i<d->sectionNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1332 if (d->sectionType(i) != QDateTimeParser::AmPmSection) {
d->sectionType...r::AmPmSectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1333 d->currentSectionIndex = i;-
1334 break;
never executed: break;
0
1335 }-
1336 }
never executed: end of block
0
1337 }
never executed: end of block
0
1338 d->setValue(d->stepBy(d->currentSectionIndex, steps, false), EmitIfChanged);-
1339 d->updateCache(d->value, d->displayText());-
1340-
1341 d->setSelected(d->currentSectionIndex);-
1342 d->updateTimeSpec();-
1343}
never executed: end of block
0
1344-
1345/*!-
1346 This virtual function is used by the date time edit whenever it-
1347 needs to display \a dateTime.-
1348-
1349 If you reimplement this, you may also need to reimplement validate().-
1350-
1351 \sa dateTimeFromText(), validate()-
1352*/-
1353QString QDateTimeEdit::textFromDateTime(const QDateTime &dateTime) const-
1354{-
1355 Q_D(const QDateTimeEdit);-
1356 return locale().toString(dateTime, d->displayFormat);
never executed: return locale().toString(dateTime, d->displayFormat);
0
1357}-
1358-
1359-
1360/*!-
1361 Returns an appropriate datetime for the given \a text.-
1362-
1363 This virtual function is used by the datetime edit whenever it-
1364 needs to interpret text entered by the user as a value.-
1365-
1366 \sa textFromDateTime(), validate()-
1367*/-
1368QDateTime QDateTimeEdit::dateTimeFromText(const QString &text) const-
1369{-
1370 Q_D(const QDateTimeEdit);-
1371 QString copy = text;-
1372 int pos = d->edit->cursorPosition();-
1373 QValidator::State state = QValidator::Acceptable;-
1374 return d->validateAndInterpret(copy, pos, state);
never executed: return d->validateAndInterpret(copy, pos, state);
0
1375}-
1376-
1377/*!-
1378 \reimp-
1379*/-
1380-
1381QValidator::State QDateTimeEdit::validate(QString &text, int &pos) const-
1382{-
1383 Q_D(const QDateTimeEdit);-
1384 QValidator::State state;-
1385 d->validateAndInterpret(text, pos, state);-
1386 return state;
never executed: return state;
0
1387}-
1388-
1389/*!-
1390 \reimp-
1391*/-
1392-
1393-
1394void QDateTimeEdit::fixup(QString &input) const-
1395{-
1396 Q_D(const QDateTimeEdit);-
1397 QValidator::State state;-
1398 int copy = d->edit->cursorPosition();-
1399-
1400 d->validateAndInterpret(input, copy, state, true);-
1401}
never executed: end of block
0
1402-
1403-
1404/*!-
1405 \reimp-
1406*/-
1407-
1408QDateTimeEdit::StepEnabled QDateTimeEdit::stepEnabled() const-
1409{-
1410 Q_D(const QDateTimeEdit);-
1411 if (d->readOnly)
d->readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1412 return StepEnabled(0);
never executed: return StepEnabled(0);
0
1413 if (d->specialValue()) {
d->specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
0
1414 return (d->minimum == d->maximum ? StepEnabled(0) : StepEnabled(StepUpEnabled));
never executed: return (d->minimum == d->maximum ? StepEnabled(0) : StepEnabled(StepUpEnabled));
d->minimum == d->maximumDescription
TRUEnever evaluated
FALSEnever evaluated
0
1415 }-
1416-
1417 QAbstractSpinBox::StepEnabled ret = 0;-
1418-
1419#ifdef QT_KEYPAD_NAVIGATION-
1420 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {-
1421 if (d->wrapping)-
1422 return StepEnabled(StepUpEnabled | StepDownEnabled);-
1423 // 3 cases. date, time, datetime. each case look-
1424 // at just the relavant component.-
1425 QVariant max, min, val;-
1426 if (!(d->sections & DateSections_Mask)) {-
1427 // time only, no date-
1428 max = d->maximum.toTime();-
1429 min = d->minimum.toTime();-
1430 val = d->value.toTime();-
1431 } else if (!(d->sections & TimeSections_Mask)) {-
1432 // date only, no time-
1433 max = d->maximum.toDate();-
1434 min = d->minimum.toDate();-
1435 val = d->value.toDate();-
1436 } else {-
1437 // both-
1438 max = d->maximum;-
1439 min = d->minimum;-
1440 val = d->value;-
1441 }-
1442 if (val != min)-
1443 ret |= QAbstractSpinBox::StepDownEnabled;-
1444 if (val != max)-
1445 ret |= QAbstractSpinBox::StepUpEnabled;-
1446 return ret;-
1447 }-
1448#endif-
1449 switch (d->sectionType(d->currentSectionIndex)) {-
1450 case QDateTimeParser::NoSection:
never executed: case QDateTimeParser::NoSection:
0
1451 case QDateTimeParser::FirstSection:
never executed: case QDateTimeParser::FirstSection:
0
1452 case QDateTimeParser::LastSection: return 0;
never executed: return 0;
never executed: case QDateTimeParser::LastSection:
0
1453 default: break;
never executed: break;
never executed: default:
0
1454 }-
1455 if (d->wrapping)
d->wrappingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1456 return StepEnabled(StepDownEnabled|StepUpEnabled);
never executed: return StepEnabled(StepDownEnabled|StepUpEnabled);
0
1457-
1458 QVariant v = d->stepBy(d->currentSectionIndex, 1, true);-
1459 if (v != d->value) {
v != d->valueDescription
TRUEnever evaluated
FALSEnever evaluated
0
1460 ret |= QAbstractSpinBox::StepUpEnabled;-
1461 }
never executed: end of block
0
1462 v = d->stepBy(d->currentSectionIndex, -1, true);-
1463 if (v != d->value) {
v != d->valueDescription
TRUEnever evaluated
FALSEnever evaluated
0
1464 ret |= QAbstractSpinBox::StepDownEnabled;-
1465 }
never executed: end of block
0
1466-
1467 return ret;
never executed: return ret;
0
1468}-
1469-
1470-
1471/*!-
1472 \reimp-
1473*/-
1474-
1475void QDateTimeEdit::mousePressEvent(QMouseEvent *event)-
1476{-
1477 Q_D(QDateTimeEdit);-
1478 if (!d->calendarPopupEnabled()) {
!d->calendarPopupEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
1479 QAbstractSpinBox::mousePressEvent(event);-
1480 return;
never executed: return;
0
1481 }-
1482 d->updateHoverControl(event->pos());-
1483 if (d->hoverControl == QStyle::SC_ComboBoxArrow) {
d->hoverContro..._ComboBoxArrowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1484 event->accept();-
1485 if (d->readOnly) {
d->readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1486 return;
never executed: return;
0
1487 }-
1488 d->updateArrow(QStyle::State_Sunken);-
1489 d->initCalendarPopup();-
1490 d->positionCalendarPopup();-
1491 //Show the calendar-
1492 d->monthCalendar->show();-
1493 } else {
never executed: end of block
0
1494 QAbstractSpinBox::mousePressEvent(event);-
1495 }
never executed: end of block
0
1496}-
1497-
1498/*!-
1499 \class QTimeEdit-
1500 \brief The QTimeEdit class provides a widget for editing times based on-
1501 the QDateTimeEdit widget.-
1502-
1503 \ingroup basicwidgets-
1504 \inmodule QtWidgets-
1505-
1506 Many of the properties and functions provided by QTimeEdit are implemented in-
1507 QDateTimeEdit. These are the relevant properties of this class:-
1508-
1509 \list-
1510 \li \l{QDateTimeEdit::time}{time} holds the time displayed by the widget.-
1511 \li \l{QDateTimeEdit::minimumTime}{minimumTime} defines the minimum (earliest) time-
1512 that can be set by the user.-
1513 \li \l{QDateTimeEdit::maximumTime}{maximumTime} defines the maximum (latest) time-
1514 that can be set by the user.-
1515 \li \l{QDateTimeEdit::displayFormat}{displayFormat} contains a string that is used-
1516 to format the time displayed in the widget.-
1517 \endlist-
1518-
1519 \table 100%-
1520 \row \li \inlineimage windowsvista-timeedit.png Screenshot of a Windows Vista style time editing widget-
1521 \li A time editing widget shown in the \l{Windows Vista Style Widget Gallery}{Windows Vista widget style}.-
1522 \row \li \inlineimage macintosh-timeedit.png Screenshot of a Macintosh style time editing widget-
1523 \li A time editing widget shown in the \l{Macintosh Style Widget Gallery}{Macintosh widget style}.-
1524 \row \li \inlineimage fusion-timeedit.png Screenshot of a Fusion style time editing widget-
1525 \li A time editing widget shown in the \l{Fusion Style Widget Gallery}{Fusion widget style}.-
1526 \endtable-
1527-
1528 \sa QDateEdit, QDateTimeEdit-
1529*/-
1530-
1531/*!-
1532 Constructs an empty time editor with a \a parent.-
1533*/-
1534-
1535-
1536QTimeEdit::QTimeEdit(QWidget *parent)-
1537 : QDateTimeEdit(QDATETIMEEDIT_TIME_MIN, QVariant::Time, parent)-
1538{-
1539 connect(this, SIGNAL(timeChanged(QTime)), SIGNAL(userTimeChanged(QTime)));-
1540}
never executed: end of block
0
1541-
1542/*!-
1543 Constructs an empty time editor with a \a parent. The time is set-
1544 to \a time.-
1545*/-
1546-
1547QTimeEdit::QTimeEdit(const QTime &time, QWidget *parent)-
1548 : QDateTimeEdit(time, QVariant::Time, parent)-
1549{-
1550}
never executed: end of block
0
1551-
1552/*!-
1553 Destructor.-
1554*/-
1555QTimeEdit::~QTimeEdit()-
1556{-
1557}-
1558-
1559/*!-
1560 \property QTimeEdit::time-
1561 \internal-
1562 \sa QDateTimeEdit::time-
1563*/-
1564-
1565/*!-
1566 \fn void QTimeEdit::userTimeChanged(const QTime &time)-
1567-
1568 This signal only exists to fully implement the time Q_PROPERTY on the class.-
1569 Normally timeChanged should be used instead.-
1570-
1571 \internal-
1572*/-
1573-
1574-
1575/*!-
1576 \class QDateEdit-
1577 \brief The QDateEdit class provides a widget for editing dates based on-
1578 the QDateTimeEdit widget.-
1579-
1580 \ingroup basicwidgets-
1581 \inmodule QtWidgets-
1582-
1583 Many of the properties and functions provided by QDateEdit are implemented in-
1584 QDateTimeEdit. These are the relevant properties of this class:-
1585-
1586 \list-
1587 \li \l{QDateTimeEdit::date}{date} holds the date displayed by the widget.-
1588 \li \l{QDateTimeEdit::minimumDate}{minimumDate} defines the minimum (earliest)-
1589 date that can be set by the user.-
1590 \li \l{QDateTimeEdit::maximumDate}{maximumDate} defines the maximum (latest) date-
1591 that can be set by the user.-
1592 \li \l{QDateTimeEdit::displayFormat}{displayFormat} contains a string that is used-
1593 to format the date displayed in the widget.-
1594 \endlist-
1595-
1596 \table 100%-
1597 \row \li \inlineimage windowsvista-dateedit.png Screenshot of a Windows Vista style date editing widget-
1598 \li A date editing widget shown in the \l{Windows Vista Style Widget Gallery}{Windows Vista widget style}.-
1599 \row \li \inlineimage macintosh-dateedit.png Screenshot of a Macintosh style date editing widget-
1600 \li A date editing widget shown in the \l{Macintosh Style Widget Gallery}{Macintosh widget style}.-
1601 \row \li \inlineimage fusion-dateedit.png Screenshot of a Fusion style date editing widget-
1602 \li A date editing widget shown in the \l{Fusion Style Widget Gallery}{Fusion widget style}.-
1603 \endtable-
1604-
1605 \sa QTimeEdit, QDateTimeEdit-
1606*/-
1607-
1608/*!-
1609 Constructs an empty date editor with a \a parent.-
1610*/-
1611-
1612QDateEdit::QDateEdit(QWidget *parent)-
1613 : QDateTimeEdit(QDATETIMEEDIT_DATE_INITIAL, QVariant::Date, parent)-
1614{-
1615 connect(this, SIGNAL(dateChanged(QDate)), SIGNAL(userDateChanged(QDate)));-
1616}
never executed: end of block
0
1617-
1618/*!-
1619 Constructs an empty date editor with a \a parent. The date is set-
1620 to \a date.-
1621*/-
1622-
1623QDateEdit::QDateEdit(const QDate &date, QWidget *parent)-
1624 : QDateTimeEdit(date, QVariant::Date, parent)-
1625{-
1626}
never executed: end of block
0
1627-
1628/*!-
1629 Destructor.-
1630*/-
1631QDateEdit::~QDateEdit()-
1632{-
1633}-
1634-
1635/*!-
1636 \property QDateEdit::date-
1637 \internal-
1638 \sa QDateTimeEdit::date-
1639*/-
1640-
1641/*!-
1642 \fn void QDateEdit::userDateChanged(const QDate &date)-
1643-
1644 This signal only exists to fully implement the date Q_PROPERTY on the class.-
1645 Normally dateChanged should be used instead.-
1646-
1647 \internal-
1648*/-
1649-
1650-
1651// --- QDateTimeEditPrivate ----
1652-
1653/*!-
1654 \internal-
1655 Constructs a QDateTimeEditPrivate object-
1656*/-
1657-
1658-
1659QDateTimeEditPrivate::QDateTimeEditPrivate()-
1660 : QDateTimeParser(QVariant::DateTime, QDateTimeParser::DateTimeEdit)-
1661{-
1662 hasHadFocus = false;-
1663 formatExplicitlySet = false;-
1664 cacheGuard = false;-
1665 fixday = true;-
1666 type = QVariant::DateTime;-
1667 sections = 0;-
1668 cachedDay = -1;-
1669 currentSectionIndex = FirstSectionIndex;-
1670-
1671 first.pos = 0;-
1672 sections = 0;-
1673 calendarPopup = false;-
1674 minimum = QDATETIMEEDIT_COMPAT_DATETIME_MIN;-
1675 maximum = QDATETIMEEDIT_DATETIME_MAX;-
1676 arrowState = QStyle::State_None;-
1677 monthCalendar = 0;-
1678 readLocaleSettings();-
1679-
1680#ifdef QT_KEYPAD_NAVIGATION-
1681 focusOnButton = false;-
1682#endif-
1683}
never executed: end of block
0
1684-
1685QDateTimeEditPrivate::~QDateTimeEditPrivate()-
1686{-
1687}-
1688-
1689void QDateTimeEditPrivate::updateTimeSpec()-
1690{-
1691 minimum = minimum.toDateTime().toTimeSpec(spec);-
1692 maximum = maximum.toDateTime().toTimeSpec(spec);-
1693 value = value.toDateTime().toTimeSpec(spec);-
1694-
1695 // time zone changes can lead to 00:00:00 becomes 01:00:00 and 23:59:59 becomes 00:59:59 (invalid range)-
1696 const bool dateShown = (sections & QDateTimeEdit::DateSections_Mask);-
1697 if (!dateShown) {
!dateShownDescription
TRUEnever evaluated
FALSEnever evaluated
0
1698 if (minimum.toTime() >= maximum.toTime()){
minimum.toTime...ximum.toTime()Description
TRUEnever evaluated
FALSEnever evaluated
0
1699 minimum = QDateTime(value.toDate(), QDATETIMEEDIT_TIME_MIN, spec);-
1700 maximum = QDateTime(value.toDate(), QDATETIMEEDIT_TIME_MAX, spec);-
1701 }
never executed: end of block
0
1702 }
never executed: end of block
0
1703}
never executed: end of block
0
1704-
1705void QDateTimeEditPrivate::updateEdit()-
1706{-
1707 const QString newText = (specialValue() ? specialValueText : textFromValue(value));
specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
0
1708 if (newText == displayText())
newText == displayText()Description
TRUEnever evaluated
FALSEnever evaluated
0
1709 return;
never executed: return;
0
1710 int selsize = edit->selectedText().size();-
1711 const QSignalBlocker blocker(edit);-
1712-
1713 edit->setText(newText);-
1714-
1715 if (!specialValue()
!specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
0
1716#ifdef QT_KEYPAD_NAVIGATION-
1717 && !(QApplication::keypadNavigationEnabled() && !edit->hasEditFocus())-
1718#endif-
1719 ) {-
1720 int cursor = sectionPos(currentSectionIndex);-
1721 QDTEDEBUG << "cursor is " << cursor << currentSectionIndex;
dead code: QMessageLogger(__FILE__, 1721, __PRETTY_FUNCTION__).debug() << "cursor is " << cursor << currentSectionIndex;
-
1722 cursor = qBound(0, cursor, displayText().size());-
1723 QDTEDEBUG << cursor;
dead code: QMessageLogger(__FILE__, 1723, __PRETTY_FUNCTION__).debug() << cursor;
-
1724 if (selsize > 0) {
selsize > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1725 edit->setSelection(cursor, selsize);-
1726 QDTEDEBUG << cursor << selsize;
dead code: QMessageLogger(__FILE__, 1726, __PRETTY_FUNCTION__).debug() << cursor << selsize;
-
1727 } else {
never executed: end of block
0
1728 edit->setCursorPosition(cursor);-
1729 QDTEDEBUG << cursor;
dead code: QMessageLogger(__FILE__, 1729, __PRETTY_FUNCTION__).debug() << cursor;
-
1730-
1731 }
never executed: end of block
0
1732 }-
1733}
never executed: end of block
0
1734-
1735-
1736/*!-
1737 \internal-
1738-
1739 Selects the section \a s. If \a forward is false selects backwards.-
1740*/-
1741-
1742void QDateTimeEditPrivate::setSelected(int sectionIndex, bool forward)-
1743{-
1744 if (specialValue()
specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
0
1745#ifdef QT_KEYPAD_NAVIGATION-
1746 || (QApplication::keypadNavigationEnabled() && !edit->hasEditFocus())-
1747#endif-
1748 ) {-
1749 edit->selectAll();-
1750 } else {
never executed: end of block
0
1751 const SectionNode &node = sectionNode(sectionIndex);-
1752 if (node.type == NoSection || node.type == LastSection || node.type == FirstSection)
node.type == NoSectionDescription
TRUEnever evaluated
FALSEnever evaluated
node.type == LastSectionDescription
TRUEnever evaluated
FALSEnever evaluated
node.type == FirstSectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1753 return;
never executed: return;
0
1754-
1755 updateCache(value, displayText());-
1756 const int size = sectionSize(sectionIndex);-
1757 if (forward) {
forwardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1758 edit->setSelection(sectionPos(node), size);-
1759 } else {
never executed: end of block
0
1760 edit->setSelection(sectionPos(node) + size, -size);-
1761 }
never executed: end of block
0
1762 }-
1763}-
1764-
1765/*!-
1766 \internal-
1767-
1768 Returns the section at index \a index or NoSection if there are no sections there.-
1769*/-
1770-
1771int QDateTimeEditPrivate::sectionAt(int pos) const-
1772{-
1773 if (pos < separators.first().size()) {
pos < separato...first().size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1774 return (pos == 0 ? FirstSectionIndex : NoSectionIndex);
never executed: return (pos == 0 ? FirstSectionIndex : NoSectionIndex);
pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1775 } else if (displayText().size() - pos < separators.last().size() + 1) {
displayText()....t().size() + 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1776 if (separators.last().size() == 0) {
separators.last().size() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1777 return sectionNodes.count() - 1;
never executed: return sectionNodes.count() - 1;
0
1778 }-
1779 return (pos == displayText().size() ? LastSectionIndex : NoSectionIndex);
never executed: return (pos == displayText().size() ? LastSectionIndex : NoSectionIndex);
pos == displayText().size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1780 }-
1781 updateCache(value, displayText());-
1782-
1783 for (int i=0; i<sectionNodes.size(); ++i) {
i<sectionNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1784 const int tmp = sectionPos(i);-
1785 if (pos < tmp + sectionSize(i)) {
pos < tmp + sectionSize(i)Description
TRUEnever evaluated
FALSEnever evaluated
0
1786 return (pos < tmp ? -1 : i);
never executed: return (pos < tmp ? -1 : i);
pos < tmpDescription
TRUEnever evaluated
FALSEnever evaluated
0
1787 }-
1788 }
never executed: end of block
0
1789 return -1;
never executed: return -1;
0
1790}-
1791-
1792/*!-
1793 \internal-
1794-
1795 Returns the closest section of index \a index. Searches forward-
1796 for a section if \a forward is true. Otherwise searches backwards.-
1797*/-
1798-
1799int QDateTimeEditPrivate::closestSection(int pos, bool forward) const-
1800{-
1801 Q_ASSERT(pos >= 0);-
1802 if (pos < separators.first().size()) {
pos < separato...first().size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1803 return forward ? 0 : FirstSectionIndex;
never executed: return forward ? 0 : FirstSectionIndex;
forwardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1804 } else if (displayText().size() - pos < separators.last().size() + 1) {
displayText()....t().size() + 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1805 return forward ? LastSectionIndex : sectionNodes.size() - 1;
never executed: return forward ? LastSectionIndex : sectionNodes.size() - 1;
forwardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1806 }-
1807 updateCache(value, displayText());-
1808 for (int i=0; i<sectionNodes.size(); ++i) {
i<sectionNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1809 const int tmp = sectionPos(sectionNodes.at(i));-
1810 if (pos < tmp + sectionSize(i)) {
pos < tmp + sectionSize(i)Description
TRUEnever evaluated
FALSEnever evaluated
0
1811 if (pos < tmp && !forward) {
pos < tmpDescription
TRUEnever evaluated
FALSEnever evaluated
!forwardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1812 return i-1;
never executed: return i-1;
0
1813 }-
1814 return i;
never executed: return i;
0
1815 } else if (i == sectionNodes.size() - 1 && pos > tmp) {
i == sectionNodes.size() - 1Description
TRUEnever evaluated
FALSEnever evaluated
pos > tmpDescription
TRUEnever evaluated
FALSEnever evaluated
0
1816 return i;
never executed: return i;
0
1817 }-
1818 }
never executed: end of block
0
1819 qWarning("QDateTimeEdit: Internal Error: closestSection returned NoSection");-
1820 return NoSectionIndex;
never executed: return NoSectionIndex;
0
1821}-
1822-
1823/*!-
1824 \internal-
1825-
1826 Returns a copy of the section that is before or after \a current, depending on \a forward.-
1827*/-
1828-
1829int QDateTimeEditPrivate::nextPrevSection(int current, bool forward) const-
1830{-
1831 Q_Q(const QDateTimeEdit);-
1832 if (q->isRightToLeft())
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
1833 forward = !forward;
never executed: forward = !forward;
0
1834-
1835 switch (current) {-
1836 case FirstSectionIndex: return forward ? 0 : FirstSectionIndex;
never executed: return forward ? 0 : FirstSectionIndex;
forwardDescription
TRUEnever evaluated
FALSEnever evaluated
never executed: case FirstSectionIndex:
0
1837 case LastSectionIndex: return (forward ? LastSectionIndex : sectionNodes.size() - 1);
never executed: return (forward ? LastSectionIndex : sectionNodes.size() - 1);
forwardDescription
TRUEnever evaluated
FALSEnever evaluated
never executed: case LastSectionIndex:
0
1838 case NoSectionIndex: return FirstSectionIndex;
never executed: return FirstSectionIndex;
never executed: case NoSectionIndex:
0
1839 default: break;
never executed: break;
never executed: default:
0
1840 }-
1841 Q_ASSERT(current >= 0 && current < sectionNodes.size());-
1842-
1843 current += (forward ? 1 : -1);
forwardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1844 if (current >= sectionNodes.size()) {
current >= sectionNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1845 return LastSectionIndex;
never executed: return LastSectionIndex;
0
1846 } else if (current < 0) {
current < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1847 return FirstSectionIndex;
never executed: return FirstSectionIndex;
0
1848 }-
1849-
1850 return current;
never executed: return current;
0
1851}-
1852-
1853/*!-
1854 \internal-
1855-
1856 Clears the text of section \a s.-
1857*/-
1858-
1859void QDateTimeEditPrivate::clearSection(int index)-
1860{-
1861 const QLatin1Char space(' ');-
1862 int cursorPos = edit->cursorPosition();-
1863 const QSignalBlocker blocker(edit);-
1864 QString t = edit->text();-
1865 const int pos = sectionPos(index);-
1866 if (pos == -1) {
pos == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1867 qWarning("QDateTimeEdit: Internal error (%s:%d)", __FILE__, __LINE__);-
1868 return;
never executed: return;
0
1869 }-
1870 const int size = sectionSize(index);-
1871 t.replace(pos, size, QString().fill(space, size));-
1872 edit->setText(t);-
1873 edit->setCursorPosition(cursorPos);-
1874 QDTEDEBUG << cursorPos;
dead code: QMessageLogger(__FILE__, 1874, __PRETTY_FUNCTION__).debug() << cursorPos;
-
1875}
never executed: end of block
0
1876-
1877-
1878/*!-
1879 \internal-
1880-
1881 updates the cached values-
1882*/-
1883-
1884void QDateTimeEditPrivate::updateCache(const QVariant &val, const QString &str) const-
1885{-
1886 if (val != cachedValue || str != cachedText || cacheGuard) {
val != cachedValueDescription
TRUEnever evaluated
FALSEnever evaluated
str != cachedTextDescription
TRUEnever evaluated
FALSEnever evaluated
cacheGuardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1887 cacheGuard = true;-
1888 QString copy = str;-
1889 int unused = edit->cursorPosition();-
1890 QValidator::State unusedState;-
1891 validateAndInterpret(copy, unused, unusedState);-
1892 cacheGuard = false;-
1893 }
never executed: end of block
0
1894}
never executed: end of block
0
1895-
1896/*!-
1897 \internal-
1898-
1899 parses and validates \a input-
1900*/-
1901-
1902QDateTime QDateTimeEditPrivate::validateAndInterpret(QString &input, int &position,-
1903 QValidator::State &state, bool fixup) const-
1904{-
1905 if (input.isEmpty()) {
input.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1906 if (sectionNodes.size() == 1 || !specialValueText.isEmpty()) {
sectionNodes.size() == 1Description
TRUEnever evaluated
FALSEnever evaluated
!specialValueText.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1907 state = QValidator::Intermediate;-
1908 } else {
never executed: end of block
0
1909 state = QValidator::Invalid;-
1910 }
never executed: end of block
0
1911 return getZeroVariant().toDateTime();
never executed: return getZeroVariant().toDateTime();
0
1912 } else if (cachedText == input && !fixup) {
cachedText == inputDescription
TRUEnever evaluated
FALSEnever evaluated
!fixupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1913 state = cachedState;-
1914 return cachedValue.toDateTime();
never executed: return cachedValue.toDateTime();
0
1915 } else if (!specialValueText.isEmpty()) {
!specialValueText.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1916 bool changeCase = false;-
1917 const int max = qMin(specialValueText.size(), input.size());-
1918 int i;-
1919 for (i=0; i<max; ++i) {
i<maxDescription
TRUEnever evaluated
FALSEnever evaluated
0
1920 const QChar ic = input.at(i);-
1921 const QChar sc = specialValueText.at(i);-
1922 if (ic != sc) {
ic != scDescription
TRUEnever evaluated
FALSEnever evaluated
0
1923 if (sc.toLower() == ic.toLower()) {
sc.toLower() == ic.toLower()Description
TRUEnever evaluated
FALSEnever evaluated
0
1924 changeCase = true;-
1925 } else {
never executed: end of block
0
1926 break;
never executed: break;
0
1927 }-
1928 }-
1929 }
never executed: end of block
0
1930 if (i == max) {
i == maxDescription
TRUEnever evaluated
FALSEnever evaluated
0
1931 state = specialValueText.size() == input.size() ? QValidator::Acceptable : QValidator::Intermediate;
specialValueTe...= input.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1932 if (changeCase) {
changeCaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
1933 input = specialValueText.left(max);-
1934 }
never executed: end of block
0
1935 return minimum.toDateTime();
never executed: return minimum.toDateTime();
0
1936 }-
1937 }
never executed: end of block
0
1938 StateNode tmp = parse(input, position, value.toDateTime(), fixup);-
1939 input = tmp.input;-
1940 state = QValidator::State(int(tmp.state));-
1941 if (state == QValidator::Acceptable) {
state == QVali...or::AcceptableDescription
TRUEnever evaluated
FALSEnever evaluated
0
1942 if (tmp.conflicts && conflictGuard != tmp.value) {
tmp.conflictsDescription
TRUEnever evaluated
FALSEnever evaluated
conflictGuard != tmp.valueDescription
TRUEnever evaluated
FALSEnever evaluated
0
1943 conflictGuard = tmp.value;-
1944 clearCache();-
1945 input = textFromValue(tmp.value);-
1946 updateCache(tmp.value, input);-
1947 conflictGuard.clear();-
1948 } else {
never executed: end of block
0
1949 cachedText = input;-
1950 cachedState = state;-
1951 cachedValue = tmp.value;-
1952 }
never executed: end of block
0
1953 } else {-
1954 clearCache();-
1955 }
never executed: end of block
0
1956 return (tmp.value.isNull() ? getZeroVariant().toDateTime() : tmp.value);
never executed: return (tmp.value.isNull() ? getZeroVariant().toDateTime() : tmp.value);
tmp.value.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1957}-
1958-
1959-
1960/*!-
1961 \internal-
1962*/-
1963-
1964QString QDateTimeEditPrivate::textFromValue(const QVariant &f) const-
1965{-
1966 Q_Q(const QDateTimeEdit);-
1967 return q->textFromDateTime(f.toDateTime());
never executed: return q->textFromDateTime(f.toDateTime());
0
1968}-
1969-
1970/*!-
1971 \internal-
1972-
1973 This function's name is slightly confusing; it is not to be confused-
1974 with QAbstractSpinBox::valueFromText().-
1975*/-
1976-
1977QVariant QDateTimeEditPrivate::valueFromText(const QString &f) const-
1978{-
1979 Q_Q(const QDateTimeEdit);-
1980 return q->dateTimeFromText(f).toTimeSpec(spec);
never executed: return q->dateTimeFromText(f).toTimeSpec(spec);
0
1981}-
1982-
1983-
1984/*!-
1985 \internal-
1986-
1987 Internal function called by QDateTimeEdit::stepBy(). Also takes a-
1988 Section for which section to step on and a bool \a test for-
1989 whether or not to modify the internal cachedDay variable. This is-
1990 necessary because the function is called from the const function-
1991 QDateTimeEdit::stepEnabled() as well as QDateTimeEdit::stepBy().-
1992*/-
1993-
1994QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) const-
1995{-
1996 Q_Q(const QDateTimeEdit);-
1997 QDateTime v = value.toDateTime();-
1998 QString str = displayText();-
1999 int pos = edit->cursorPosition();-
2000 const SectionNode sn = sectionNode(sectionIndex);-
2001-
2002 int val;-
2003 // to make sure it behaves reasonably when typing something and then stepping in non-tracking mode-
2004 if (!test && pendingEmit) {
!testDescription
TRUEnever evaluated
FALSEnever evaluated
pendingEmitDescription
TRUEnever evaluated
FALSEnever evaluated
0
2005 if (q->validate(str, pos) != QValidator::Acceptable) {
q->validate(st...or::AcceptableDescription
TRUEnever evaluated
FALSEnever evaluated
0
2006 v = value.toDateTime();-
2007 } else {
never executed: end of block
0
2008 v = q->dateTimeFromText(str);-
2009 }
never executed: end of block
0
2010 val = getDigit(v, sectionIndex);-
2011 } else {
never executed: end of block
0
2012 val = getDigit(v, sectionIndex);-
2013 }
never executed: end of block
0
2014-
2015 val += steps;-
2016-
2017 const int min = absoluteMin(sectionIndex);-
2018 const int max = absoluteMax(sectionIndex, value.toDateTime());-
2019-
2020 if (val < min) {
val < minDescription
TRUEnever evaluated
FALSEnever evaluated
0
2021 val = (wrapping ? max - (min - val) + 1 : min);
wrappingDescription
TRUEnever evaluated
FALSEnever evaluated
0
2022 } else if (val > max) {
never executed: end of block
val > maxDescription
TRUEnever evaluated
FALSEnever evaluated
0
2023 val = (wrapping ? min + val - max - 1 : max);
wrappingDescription
TRUEnever evaluated
FALSEnever evaluated
0
2024 }
never executed: end of block
0
2025-
2026-
2027 const int oldDay = v.date().day();-
2028-
2029 setDigit(v, sectionIndex, val);-
2030 // if this sets year or month it will make-
2031 // sure that days are lowered if needed.-
2032-
2033 const QDateTime minimumDateTime = minimum.toDateTime();-
2034 const QDateTime maximumDateTime = maximum.toDateTime();-
2035 // changing one section should only modify that section, if possible-
2036 if (sn.type != AmPmSection && (v < minimumDateTime || v > maximumDateTime)) {
sn.type != AmPmSectionDescription
TRUEnever evaluated
FALSEnever evaluated
v < minimumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
v > maximumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2037 const int localmin = getDigit(minimumDateTime, sectionIndex);-
2038 const int localmax = getDigit(maximumDateTime, sectionIndex);-
2039-
2040 if (wrapping) {
wrappingDescription
TRUEnever evaluated
FALSEnever evaluated
0
2041 // just because we hit the roof in one direction, it-
2042 // doesn't mean that we hit the floor in the other-
2043 if (steps > 0) {
steps > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2044 setDigit(v, sectionIndex, min);-
2045 if (!(sn.type & DaySectionMask) && sections & DateSectionMask) {
!(sn.type & DaySectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
sections & DateSectionMaskDescription
TRUEnever evaluated
FALSEnever evaluated
0
2046 const int daysInMonth = v.date().daysInMonth();-
2047 if (v.date().day() < oldDay && v.date().day() < daysInMonth) {
v.date().day() < oldDayDescription
TRUEnever evaluated
FALSEnever evaluated
v.date().day() < daysInMonthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2048 const int adds = qMin(oldDay, daysInMonth);-
2049 v = v.addDays(adds - v.date().day());-
2050 }
never executed: end of block
0
2051 }
never executed: end of block
0
2052-
2053 if (v < minimumDateTime) {
v < minimumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2054 setDigit(v, sectionIndex, localmin);-
2055 if (v < minimumDateTime)
v < minimumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2056 setDigit(v, sectionIndex, localmin + 1);
never executed: setDigit(v, sectionIndex, localmin + 1);
0
2057 }
never executed: end of block
0
2058 } else {
never executed: end of block
0
2059 setDigit(v, sectionIndex, max);-
2060 if (!(sn.type & DaySectionMask) && sections & DateSectionMask) {
!(sn.type & DaySectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
sections & DateSectionMaskDescription
TRUEnever evaluated
FALSEnever evaluated
0
2061 const int daysInMonth = v.date().daysInMonth();-
2062 if (v.date().day() < oldDay && v.date().day() < daysInMonth) {
v.date().day() < oldDayDescription
TRUEnever evaluated
FALSEnever evaluated
v.date().day() < daysInMonthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2063 const int adds = qMin(oldDay, daysInMonth);-
2064 v = v.addDays(adds - v.date().day());-
2065 }
never executed: end of block
0
2066 }
never executed: end of block
0
2067-
2068 if (v > maximumDateTime) {
v > maximumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2069 setDigit(v, sectionIndex, localmax);-
2070 if (v > maximumDateTime)
v > maximumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2071 setDigit(v, sectionIndex, localmax - 1);
never executed: setDigit(v, sectionIndex, localmax - 1);
0
2072 }
never executed: end of block
0
2073 }
never executed: end of block
0
2074 } else {-
2075 setDigit(v, sectionIndex, (steps > 0 ? localmax : localmin));-
2076 }
never executed: end of block
0
2077 }-
2078 if (!test && oldDay != v.date().day() && !(sn.type & DaySectionMask)) {
!testDescription
TRUEnever evaluated
FALSEnever evaluated
oldDay != v.date().day()Description
TRUEnever evaluated
FALSEnever evaluated
!(sn.type & DaySectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
2079 // this should not happen when called from stepEnabled-
2080 cachedDay = qMax<int>(oldDay, cachedDay);-
2081 }
never executed: end of block
0
2082-
2083 if (v < minimumDateTime) {
v < minimumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2084 if (wrapping) {
wrappingDescription
TRUEnever evaluated
FALSEnever evaluated
0
2085 QDateTime t = v;-
2086 setDigit(t, sectionIndex, steps < 0 ? max : min);-
2087 bool mincmp = (t >= minimumDateTime);-
2088 bool maxcmp = (t <= maximumDateTime);-
2089 if (!mincmp || !maxcmp) {
!mincmpDescription
TRUEnever evaluated
FALSEnever evaluated
!maxcmpDescription
TRUEnever evaluated
FALSEnever evaluated
0
2090 setDigit(t, sectionIndex, getDigit(steps < 0-
2091 ? maximumDateTime-
2092 : minimumDateTime, sectionIndex));-
2093 mincmp = (t >= minimumDateTime);-
2094 maxcmp = (t <= maximumDateTime);-
2095 }
never executed: end of block
0
2096 if (mincmp && maxcmp) {
mincmpDescription
TRUEnever evaluated
FALSEnever evaluated
maxcmpDescription
TRUEnever evaluated
FALSEnever evaluated
0
2097 v = t;-
2098 }
never executed: end of block
0
2099 } else {
never executed: end of block
0
2100 v = value.toDateTime();-
2101 }
never executed: end of block
0
2102 } else if (v > maximumDateTime) {
v > maximumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2103 if (wrapping) {
wrappingDescription
TRUEnever evaluated
FALSEnever evaluated
0
2104 QDateTime t = v;-
2105 setDigit(t, sectionIndex, steps > 0 ? min : max);-
2106 bool mincmp = (t >= minimumDateTime);-
2107 bool maxcmp = (t <= maximumDateTime);-
2108 if (!mincmp || !maxcmp) {
!mincmpDescription
TRUEnever evaluated
FALSEnever evaluated
!maxcmpDescription
TRUEnever evaluated
FALSEnever evaluated
0
2109 setDigit(t, sectionIndex, getDigit(steps > 0 ?-
2110 minimumDateTime :-
2111 maximumDateTime, sectionIndex));-
2112 mincmp = (t >= minimumDateTime);-
2113 maxcmp = (t <= maximumDateTime);-
2114 }
never executed: end of block
0
2115 if (mincmp && maxcmp) {
mincmpDescription
TRUEnever evaluated
FALSEnever evaluated
maxcmpDescription
TRUEnever evaluated
FALSEnever evaluated
0
2116 v = t;-
2117 }
never executed: end of block
0
2118 } else {
never executed: end of block
0
2119 v = value.toDateTime();-
2120 }
never executed: end of block
0
2121 }-
2122-
2123 const QDateTime ret = bound(v, value, steps).toDateTime().toTimeSpec(spec);-
2124 return ret;
never executed: return ret;
0
2125}-
2126-
2127/*!-
2128 \internal-
2129*/-
2130-
2131void QDateTimeEditPrivate::emitSignals(EmitPolicy ep, const QVariant &old)-
2132{-
2133 Q_Q(QDateTimeEdit);-
2134 if (ep == NeverEmit) {
ep == NeverEmitDescription
TRUEnever evaluated
FALSEnever evaluated
0
2135 return;
never executed: return;
0
2136 }-
2137 pendingEmit = false;-
2138-
2139 const bool dodate = value.toDate().isValid() && (sections & DateSectionMask);
value.toDate().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
(sections & DateSectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
2140 const bool datechanged = (ep == AlwaysEmit || old.toDate() != value.toDate());
ep == AlwaysEmitDescription
TRUEnever evaluated
FALSEnever evaluated
old.toDate() != value.toDate()Description
TRUEnever evaluated
FALSEnever evaluated
0
2141 const bool dotime = value.toTime().isValid() && (sections & TimeSectionMask);
value.toTime().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
(sections & TimeSectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
2142 const bool timechanged = (ep == AlwaysEmit || old.toTime() != value.toTime());
ep == AlwaysEmitDescription
TRUEnever evaluated
FALSEnever evaluated
old.toTime() != value.toTime()Description
TRUEnever evaluated
FALSEnever evaluated
0
2143-
2144 updateCache(value, displayText());-
2145-
2146 syncCalendarWidget();-
2147 if (datechanged || timechanged)
datechangedDescription
TRUEnever evaluated
FALSEnever evaluated
timechangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2148 emit q->dateTimeChanged(value.toDateTime());
never executed: q->dateTimeChanged(value.toDateTime());
0
2149 if (dodate && datechanged)
dodateDescription
TRUEnever evaluated
FALSEnever evaluated
datechangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2150 emit q->dateChanged(value.toDate());
never executed: q->dateChanged(value.toDate());
0
2151 if (dotime && timechanged)
dotimeDescription
TRUEnever evaluated
FALSEnever evaluated
timechangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2152 emit q->timeChanged(value.toTime());
never executed: q->timeChanged(value.toTime());
0
2153-
2154}
never executed: end of block
0
2155-
2156/*!-
2157 \internal-
2158*/-
2159-
2160void QDateTimeEditPrivate::_q_editorCursorPositionChanged(int oldpos, int newpos)-
2161{-
2162 if (ignoreCursorPositionChanged || specialValue())
ignoreCursorPositionChangedDescription
TRUEnever evaluated
FALSEnever evaluated
specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
0
2163 return;
never executed: return;
0
2164 const QString oldText = displayText();-
2165 updateCache(value, oldText);-
2166-
2167 const bool allowChange = !edit->hasSelectedText();-
2168 const bool forward = oldpos <= newpos;-
2169 ignoreCursorPositionChanged = true;-
2170 int s = sectionAt(newpos);-
2171 if (s == NoSectionIndex && forward && newpos > 0) {
s == NoSectionIndexDescription
TRUEnever evaluated
FALSEnever evaluated
forwardDescription
TRUEnever evaluated
FALSEnever evaluated
newpos > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2172 s = sectionAt(newpos - 1);-
2173 }
never executed: end of block
0
2174-
2175 int c = newpos;-
2176-
2177 const int selstart = edit->selectionStart();-
2178 const int selSection = sectionAt(selstart);-
2179 const int l = selSection != -1 ? sectionSize(selSection) : 0;
selSection != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2180-
2181 if (s == NoSectionIndex) {
s == NoSectionIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
2182 if (l > 0 && selstart == sectionPos(selSection) && edit->selectedText().size() == l) {
l > 0Description
TRUEnever evaluated
FALSEnever evaluated
selstart == se...os(selSection)Description
TRUEnever evaluated
FALSEnever evaluated
edit->selected...().size() == lDescription
TRUEnever evaluated
FALSEnever evaluated
0
2183 s = selSection;-
2184 if (allowChange)
allowChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2185 setSelected(selSection, true);
never executed: setSelected(selSection, true);
0
2186 c = -1;-
2187 } else {
never executed: end of block
0
2188 int closest = closestSection(newpos, forward);-
2189 c = sectionPos(closest) + (forward ? 0 : qMax<int>(0, sectionSize(closest)));
forwardDescription
TRUEnever evaluated
FALSEnever evaluated
0
2190-
2191 if (allowChange) {
allowChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2192 edit->setCursorPosition(c);-
2193 QDTEDEBUG << c;
dead code: QMessageLogger(__FILE__, 2193, __PRETTY_FUNCTION__).debug() << c;
-
2194 }
never executed: end of block
0
2195 s = closest;-
2196 }
never executed: end of block
0
2197 }-
2198-
2199 if (allowChange && currentSectionIndex != s) {
allowChangeDescription
TRUEnever evaluated
FALSEnever evaluated
currentSectionIndex != sDescription
TRUEnever evaluated
FALSEnever evaluated
0
2200 interpret(EmitIfChanged);-
2201 }
never executed: end of block
0
2202 if (c == -1) {
c == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2203 setSelected(s, true);-
2204 } else if (!edit->hasSelectedText()) {
never executed: end of block
!edit->hasSelectedText()Description
TRUEnever evaluated
FALSEnever evaluated
0
2205 if (oldpos < newpos) {
oldpos < newposDescription
TRUEnever evaluated
FALSEnever evaluated
0
2206 edit->setCursorPosition(displayText().size() - (oldText.size() - c));-
2207 } else {
never executed: end of block
0
2208 edit->setCursorPosition(c);-
2209 }
never executed: end of block
0
2210 }-
2211-
2212 QDTEDEBUG << "currentSectionIndex is set to" << sectionNode(s).name()
dead code: QMessageLogger(__FILE__, 2212, __PRETTY_FUNCTION__).debug() << "currentSectionIndex is set to" << sectionNode(s).name() << oldpos << newpos << "was" << sectionNode(currentSectionIndex).name();
-
2213 << oldpos << newpos
dead code: QMessageLogger(__FILE__, 2212, __PRETTY_FUNCTION__).debug() << "currentSectionIndex is set to" << sectionNode(s).name() << oldpos << newpos << "was" << sectionNode(currentSectionIndex).name();
-
2214 << "was" << sectionNode(currentSectionIndex).name();
dead code: QMessageLogger(__FILE__, 2212, __PRETTY_FUNCTION__).debug() << "currentSectionIndex is set to" << sectionNode(s).name() << oldpos << newpos << "was" << sectionNode(currentSectionIndex).name();
-
2215-
2216 currentSectionIndex = s;-
2217 Q_ASSERT_X(currentSectionIndex < sectionNodes.size(),-
2218 "QDateTimeEditPrivate::_q_editorCursorPositionChanged()",-
2219 qPrintable(QString::fromLatin1("Internal error (%1 %2)").-
2220 arg(currentSectionIndex).-
2221 arg(sectionNodes.size())));-
2222-
2223 ignoreCursorPositionChanged = false;-
2224}
never executed: end of block
0
2225-
2226/*!-
2227 \internal-
2228-
2229 Try to get the format from the local settings-
2230*/-
2231void QDateTimeEditPrivate::readLocaleSettings()-
2232{-
2233 const QLocale loc;-
2234 defaultTimeFormat = loc.timeFormat(QLocale::ShortFormat);-
2235 defaultDateFormat = loc.dateFormat(QLocale::ShortFormat);-
2236 defaultDateTimeFormat = loc.dateTimeFormat(QLocale::ShortFormat);-
2237}
never executed: end of block
0
2238-
2239QDateTimeEdit::Section QDateTimeEditPrivate::convertToPublic(QDateTimeParser::Section s)-
2240{-
2241 switch (s & ~Internal) {-
2242 case AmPmSection: return QDateTimeEdit::AmPmSection;
never executed: return QDateTimeEdit::AmPmSection;
never executed: case AmPmSection:
0
2243 case MSecSection: return QDateTimeEdit::MSecSection;
never executed: return QDateTimeEdit::MSecSection;
never executed: case MSecSection:
0
2244 case SecondSection: return QDateTimeEdit::SecondSection;
never executed: return QDateTimeEdit::SecondSection;
never executed: case SecondSection:
0
2245 case MinuteSection: return QDateTimeEdit::MinuteSection;
never executed: return QDateTimeEdit::MinuteSection;
never executed: case MinuteSection:
0
2246 case DayOfWeekSectionShort:
never executed: case DayOfWeekSectionShort:
0
2247 case DayOfWeekSectionLong:
never executed: case DayOfWeekSectionLong:
0
2248 case DaySection: return QDateTimeEdit::DaySection;
never executed: return QDateTimeEdit::DaySection;
never executed: case DaySection:
0
2249 case MonthSection: return QDateTimeEdit::MonthSection;
never executed: return QDateTimeEdit::MonthSection;
never executed: case MonthSection:
0
2250 case YearSection2Digits:
never executed: case YearSection2Digits:
0
2251 case YearSection: return QDateTimeEdit::YearSection;
never executed: return QDateTimeEdit::YearSection;
never executed: case YearSection:
0
2252 case Hour12Section:
never executed: case Hour12Section:
0
2253 case Hour24Section: return QDateTimeEdit::HourSection;
never executed: return QDateTimeEdit::HourSection;
never executed: case Hour24Section:
0
2254 case FirstSection:
never executed: case FirstSection:
0
2255 case NoSection:
never executed: case NoSection:
0
2256 case LastSection: break;
never executed: break;
never executed: case LastSection:
0
2257 }-
2258 return QDateTimeEdit::NoSection;
never executed: return QDateTimeEdit::NoSection;
0
2259}-
2260-
2261QDateTimeEdit::Sections QDateTimeEditPrivate::convertSections(QDateTimeParser::Sections s)-
2262{-
2263 QDateTimeEdit::Sections ret = 0;-
2264 if (s & QDateTimeParser::MSecSection)
s & QDateTimeP...r::MSecSectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2265 ret |= QDateTimeEdit::MSecSection;
never executed: ret |= QDateTimeEdit::MSecSection;
0
2266 if (s & QDateTimeParser::SecondSection)
s & QDateTimeP...:SecondSectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2267 ret |= QDateTimeEdit::SecondSection;
never executed: ret |= QDateTimeEdit::SecondSection;
0
2268 if (s & QDateTimeParser::MinuteSection)
s & QDateTimeP...:MinuteSectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2269 ret |= QDateTimeEdit::MinuteSection;
never executed: ret |= QDateTimeEdit::MinuteSection;
0
2270 if (s & (QDateTimeParser::HourSectionMask))
s & (QDateTime...urSectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
2271 ret |= QDateTimeEdit::HourSection;
never executed: ret |= QDateTimeEdit::HourSection;
0
2272 if (s & QDateTimeParser::AmPmSection)
s & QDateTimeP...r::AmPmSectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2273 ret |= QDateTimeEdit::AmPmSection;
never executed: ret |= QDateTimeEdit::AmPmSection;
0
2274 if (s & (QDateTimeParser::DaySectionMask))
s & (QDateTime...aySectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
2275 ret |= QDateTimeEdit::DaySection;
never executed: ret |= QDateTimeEdit::DaySection;
0
2276 if (s & QDateTimeParser::MonthSection)
s & QDateTimeP...::MonthSectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2277 ret |= QDateTimeEdit::MonthSection;
never executed: ret |= QDateTimeEdit::MonthSection;
0
2278 if (s & (QDateTimeParser::YearSectionMask))
s & (QDateTime...arSectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
2279 ret |= QDateTimeEdit::YearSection;
never executed: ret |= QDateTimeEdit::YearSection;
0
2280-
2281 return ret;
never executed: return ret;
0
2282}-
2283-
2284/*!-
2285 \reimp-
2286*/-
2287-
2288void QDateTimeEdit::paintEvent(QPaintEvent *event)-
2289{-
2290 Q_D(QDateTimeEdit);-
2291 if (!d->calendarPopupEnabled()) {
!d->calendarPopupEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2292 QAbstractSpinBox::paintEvent(event);-
2293 return;
never executed: return;
0
2294 }-
2295-
2296 QStyleOptionSpinBox opt;-
2297 initStyleOption(&opt);-
2298-
2299 QStyleOptionComboBox optCombo;-
2300-
2301 optCombo.init(this);-
2302 optCombo.editable = true;-
2303 optCombo.frame = opt.frame;-
2304 optCombo.subControls = opt.subControls;-
2305 optCombo.activeSubControls = opt.activeSubControls;-
2306 optCombo.state = opt.state;-
2307 if (d->readOnly) {
d->readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
2308 optCombo.state &= ~QStyle::State_Enabled;-
2309 }
never executed: end of block
0
2310-
2311 QPainter p(this);-
2312 style()->drawComplexControl(QStyle::CC_ComboBox, &optCombo, &p, this);-
2313}
never executed: end of block
0
2314-
2315QString QDateTimeEditPrivate::getAmPmText(AmPm ap, Case cs) const-
2316{-
2317 if (ap == AmText) {
ap == AmTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
2318 return (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am"));
never executed: return (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am"));
cs == UpperCaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
2319 } else {-
2320 return (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm"));
never executed: return (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm"));
cs == UpperCaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
2321 }-
2322}-
2323-
2324int QDateTimeEditPrivate::absoluteIndex(QDateTimeEdit::Section s, int index) const-
2325{-
2326 for (int i=0; i<sectionNodes.size(); ++i) {
i<sectionNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
2327 if (convertToPublic(sectionNodes.at(i).type) == s && index-- == 0) {
convertToPubli...(i).type) == sDescription
TRUEnever evaluated
FALSEnever evaluated
index-- == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2328 return i;
never executed: return i;
0
2329 }-
2330 }
never executed: end of block
0
2331 return NoSectionIndex;
never executed: return NoSectionIndex;
0
2332}-
2333-
2334int QDateTimeEditPrivate::absoluteIndex(const SectionNode &s) const-
2335{-
2336 return sectionNodes.indexOf(s);
never executed: return sectionNodes.indexOf(s);
0
2337}-
2338-
2339void QDateTimeEditPrivate::interpret(EmitPolicy ep)-
2340{-
2341 Q_Q(QDateTimeEdit);-
2342 QString tmp = displayText();-
2343 int pos = edit->cursorPosition();-
2344 const QValidator::State state = q->validate(tmp, pos);-
2345 if (state != QValidator::Acceptable
state != QVali...or::AcceptableDescription
TRUEnever evaluated
FALSEnever evaluated
0
2346 && correctionMode == QAbstractSpinBox::CorrectToPreviousValue
correctionMode...oPreviousValueDescription
TRUEnever evaluated
FALSEnever evaluated
0
2347 && (state == QValidator::Invalid
state == QValidator::InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
0
2348 || currentSectionIndex < 0
currentSectionIndex < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2349 || !(fieldInfo(currentSectionIndex) & AllowPartial))) {
!(fieldInfo(cu... AllowPartial)Description
TRUEnever evaluated
FALSEnever evaluated
0
2350 setValue(value, ep);-
2351 updateTimeSpec();-
2352 } else {
never executed: end of block
0
2353 QAbstractSpinBoxPrivate::interpret(ep);-
2354 }
never executed: end of block
0
2355}-
2356-
2357void QDateTimeEditPrivate::clearCache() const-
2358{-
2359 QAbstractSpinBoxPrivate::clearCache();-
2360 cachedDay = -1;-
2361}
never executed: end of block
0
2362-
2363/*!-
2364 Initialize \a option with the values from this QDataTimeEdit. This method-
2365 is useful for subclasses when they need a QStyleOptionSpinBox, but don't want-
2366 to fill in all the information themselves.-
2367-
2368 \sa QStyleOption::initFrom()-
2369*/-
2370void QDateTimeEdit::initStyleOption(QStyleOptionSpinBox *option) const-
2371{-
2372 if (!option)
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2373 return;
never executed: return;
0
2374-
2375 Q_D(const QDateTimeEdit);-
2376 QAbstractSpinBox::initStyleOption(option);-
2377 if (d->calendarPopupEnabled()) {
d->calendarPopupEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2378 option->subControls = QStyle::SC_ComboBoxFrame | QStyle::SC_ComboBoxEditField-
2379 | QStyle::SC_ComboBoxArrow;-
2380 if (d->arrowState == QStyle::State_Sunken)
d->arrowState ...::State_SunkenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2381 option->state |= QStyle::State_Sunken;
never executed: option->state |= QStyle::State_Sunken;
0
2382 else-
2383 option->state &= ~QStyle::State_Sunken;
never executed: option->state &= ~QStyle::State_Sunken;
0
2384 }-
2385}
never executed: end of block
0
2386-
2387void QDateTimeEditPrivate::init(const QVariant &var)-
2388{-
2389 Q_Q(QDateTimeEdit);-
2390 switch (var.type()) {-
2391 case QVariant::Date:
never executed: case QVariant::Date:
0
2392 value = QDateTime(var.toDate(), QDATETIMEEDIT_TIME_MIN);-
2393 updateTimeSpec();-
2394 q->setDisplayFormat(defaultDateFormat);-
2395 if (sectionNodes.isEmpty()) // ### safeguard for broken locale
sectionNodes.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2396 q->setDisplayFormat(QLatin1String("dd/MM/yyyy"));
never executed: q->setDisplayFormat(QLatin1String("dd/MM/yyyy"));
0
2397 break;
never executed: break;
0
2398 case QVariant::DateTime:
never executed: case QVariant::DateTime:
0
2399 value = var;-
2400 updateTimeSpec();-
2401 q->setDisplayFormat(defaultDateTimeFormat);-
2402 if (sectionNodes.isEmpty()) // ### safeguard for broken locale
sectionNodes.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2403 q->setDisplayFormat(QLatin1String("dd/MM/yyyy hh:mm:ss"));
never executed: q->setDisplayFormat(QLatin1String("dd/MM/yyyy hh:mm:ss"));
0
2404 break;
never executed: break;
0
2405 case QVariant::Time:
never executed: case QVariant::Time:
0
2406 value = QDateTime(QDATETIMEEDIT_DATE_INITIAL, var.toTime());-
2407 updateTimeSpec();-
2408 q->setDisplayFormat(defaultTimeFormat);-
2409 if (sectionNodes.isEmpty()) // ### safeguard for broken locale
sectionNodes.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2410 q->setDisplayFormat(QLatin1String("hh:mm:ss"));
never executed: q->setDisplayFormat(QLatin1String("hh:mm:ss"));
0
2411 break;
never executed: break;
0
2412 default:
never executed: default:
0
2413 Q_ASSERT_X(0, "QDateTimeEditPrivate::init", "Internal error");-
2414 break;
never executed: break;
0
2415 }-
2416#ifdef QT_KEYPAD_NAVIGATION-
2417 if (QApplication::keypadNavigationEnabled())-
2418 q->setCalendarPopup(true);-
2419#endif-
2420 q->setInputMethodHints(Qt::ImhPreferNumbers);-
2421 setLayoutItemMargins(QStyle::SE_DateTimeEditLayoutItem);-
2422}
never executed: end of block
0
2423-
2424void QDateTimeEditPrivate::_q_resetButton()-
2425{-
2426 updateArrow(QStyle::State_None);-
2427}
never executed: end of block
0
2428-
2429void QDateTimeEditPrivate::updateArrow(QStyle::StateFlag state)-
2430{-
2431 Q_Q(QDateTimeEdit);-
2432-
2433 if (arrowState == state)
arrowState == stateDescription
TRUEnever evaluated
FALSEnever evaluated
0
2434 return;
never executed: return;
0
2435 arrowState = state;-
2436 if (arrowState != QStyle::State_None)
arrowState != ...le::State_NoneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2437 buttonState |= Mouse;
never executed: buttonState |= Mouse;
0
2438 else {-
2439 buttonState = 0;-
2440 hoverControl = QStyle::SC_ComboBoxFrame;-
2441 }
never executed: end of block
0
2442 q->update();-
2443}
never executed: end of block
0
2444-
2445/*!-
2446 \internal-
2447 Returns the hover control at \a pos.-
2448 This will update the hoverRect and hoverControl.-
2449*/-
2450QStyle::SubControl QDateTimeEditPrivate::newHoverControl(const QPoint &pos)-
2451{-
2452 if (!calendarPopupEnabled())
!calendarPopupEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2453 return QAbstractSpinBoxPrivate::newHoverControl(pos);
never executed: return QAbstractSpinBoxPrivate::newHoverControl(pos);
0
2454-
2455 Q_Q(QDateTimeEdit);-
2456-
2457 QStyleOptionComboBox optCombo;-
2458 optCombo.init(q);-
2459 optCombo.editable = true;-
2460 optCombo.subControls = QStyle::SC_All;-
2461 hoverControl = q->style()->hitTestComplexControl(QStyle::CC_ComboBox, &optCombo, pos, q);-
2462 return hoverControl;
never executed: return hoverControl;
0
2463}-
2464-
2465void QDateTimeEditPrivate::updateEditFieldGeometry()-
2466{-
2467 if (!calendarPopupEnabled()) {
!calendarPopupEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2468 QAbstractSpinBoxPrivate::updateEditFieldGeometry();-
2469 return;
never executed: return;
0
2470 }-
2471-
2472 Q_Q(QDateTimeEdit);-
2473-
2474 QStyleOptionComboBox optCombo;-
2475 optCombo.init(q);-
2476 optCombo.editable = true;-
2477 optCombo.subControls = QStyle::SC_ComboBoxEditField;-
2478 edit->setGeometry(q->style()->subControlRect(QStyle::CC_ComboBox, &optCombo,-
2479 QStyle::SC_ComboBoxEditField, q));-
2480}
never executed: end of block
0
2481-
2482QVariant QDateTimeEditPrivate::getZeroVariant() const-
2483{-
2484 Q_ASSERT(type == QVariant::DateTime);-
2485 return QDateTime(QDATETIMEEDIT_DATE_INITIAL, QTime(), spec);
never executed: return QDateTime(QDate(2000, 1, 1), QTime(), spec);
0
2486}-
2487-
2488void QDateTimeEditPrivate::setRange(const QVariant &min, const QVariant &max)-
2489{-
2490 QAbstractSpinBoxPrivate::setRange(min, max);-
2491 syncCalendarWidget();-
2492}
never executed: end of block
0
2493-
2494-
2495bool QDateTimeEditPrivate::isSeparatorKey(const QKeyEvent *ke) const-
2496{-
2497 if (!ke->text().isEmpty() && currentSectionIndex + 1 < sectionNodes.size() && currentSectionIndex >= 0) {
!ke->text().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
currentSection...onNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
currentSectionIndex >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2498 if (fieldInfo(currentSectionIndex) & Numeric) {
fieldInfo(curr...dex) & NumericDescription
TRUEnever evaluated
FALSEnever evaluated
0
2499 if (ke->text().at(0).isNumber())
ke->text().at(0).isNumber()Description
TRUEnever evaluated
FALSEnever evaluated
0
2500 return false;
never executed: return false;
0
2501 } else if (ke->text().at(0).isLetterOrNumber()) {
never executed: end of block
ke->text().at(...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
0
2502 return false;
never executed: return false;
0
2503 }-
2504 return separators.at(currentSectionIndex + 1).contains(ke->text());
never executed: return separators.at(currentSectionIndex + 1).contains(ke->text());
0
2505 }-
2506 return false;
never executed: return false;
0
2507}-
2508-
2509void QDateTimeEditPrivate::initCalendarPopup(QCalendarWidget *cw)-
2510{-
2511 Q_Q(QDateTimeEdit);-
2512 if (!monthCalendar) {
!monthCalendarDescription
TRUEnever evaluated
FALSEnever evaluated
0
2513 monthCalendar = new QCalendarPopup(q, cw);-
2514 monthCalendar->setObjectName(QLatin1String("qt_datetimedit_calendar"));-
2515 QObject::connect(monthCalendar, SIGNAL(newDateSelected(QDate)), q, SLOT(setDate(QDate)));-
2516 QObject::connect(monthCalendar, SIGNAL(hidingCalendar(QDate)), q, SLOT(setDate(QDate)));-
2517 QObject::connect(monthCalendar, SIGNAL(activated(QDate)), q, SLOT(setDate(QDate)));-
2518 QObject::connect(monthCalendar, SIGNAL(activated(QDate)), monthCalendar, SLOT(close()));-
2519 QObject::connect(monthCalendar, SIGNAL(resetButton()), q, SLOT(_q_resetButton()));-
2520 } else if (cw) {
never executed: end of block
cwDescription
TRUEnever evaluated
FALSEnever evaluated
0
2521 monthCalendar->setCalendarWidget(cw);-
2522 }
never executed: end of block
0
2523 syncCalendarWidget();-
2524}
never executed: end of block
0
2525-
2526void QDateTimeEditPrivate::positionCalendarPopup()-
2527{-
2528 Q_Q(QDateTimeEdit);-
2529 QPoint pos = (q->layoutDirection() == Qt::RightToLeft) ? q->rect().bottomRight() : q->rect().bottomLeft();
(q->layoutDire...::RightToLeft)Description
TRUEnever evaluated
FALSEnever evaluated
0
2530 QPoint pos2 = (q->layoutDirection() == Qt::RightToLeft) ? q->rect().topRight() : q->rect().topLeft();
(q->layoutDire...::RightToLeft)Description
TRUEnever evaluated
FALSEnever evaluated
0
2531 pos = q->mapToGlobal(pos);-
2532 pos2 = q->mapToGlobal(pos2);-
2533 QSize size = monthCalendar->sizeHint();-
2534 QRect screen = QApplication::desktop()->availableGeometry(pos);-
2535 //handle popup falling "off screen"-
2536 if (q->layoutDirection() == Qt::RightToLeft) {
q->layoutDirec...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
2537 pos.setX(pos.x()-size.width());-
2538 pos2.setX(pos2.x()-size.width());-
2539 if (pos.x() < screen.left())
pos.x() < screen.left()Description
TRUEnever evaluated
FALSEnever evaluated
0
2540 pos.setX(qMax(pos.x(), screen.left()));
never executed: pos.setX(qMax(pos.x(), screen.left()));
0
2541 else if (pos.x()+size.width() > screen.right())
pos.x()+size.w...screen.right()Description
TRUEnever evaluated
FALSEnever evaluated
0
2542 pos.setX(qMax(pos.x()-size.width(), screen.right()-size.width()));
never executed: pos.setX(qMax(pos.x()-size.width(), screen.right()-size.width()));
0
2543 } else {
never executed: end of block
0
2544 if (pos.x()+size.width() > screen.right())
pos.x()+size.w...screen.right()Description
TRUEnever evaluated
FALSEnever evaluated
0
2545 pos.setX(screen.right()-size.width());
never executed: pos.setX(screen.right()-size.width());
0
2546 pos.setX(qMax(pos.x(), screen.left()));-
2547 }
never executed: end of block
0
2548 if (pos.y() + size.height() > screen.bottom())
pos.y() + size...creen.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
0
2549 pos.setY(pos2.y() - size.height());
never executed: pos.setY(pos2.y() - size.height());
0
2550 else if (pos.y() < screen.top())
pos.y() < screen.top()Description
TRUEnever evaluated
FALSEnever evaluated
0
2551 pos.setY(screen.top());
never executed: pos.setY(screen.top());
0
2552 if (pos.y() < screen.top())
pos.y() < screen.top()Description
TRUEnever evaluated
FALSEnever evaluated
0
2553 pos.setY(screen.top());
never executed: pos.setY(screen.top());
0
2554 if (pos.y()+size.height() > screen.bottom())
pos.y()+size.h...creen.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
0
2555 pos.setY(screen.bottom()-size.height());
never executed: pos.setY(screen.bottom()-size.height());
0
2556 monthCalendar->move(pos);-
2557}
never executed: end of block
0
2558-
2559bool QDateTimeEditPrivate::calendarPopupEnabled() const-
2560{-
2561 return (calendarPopup && (sections & (DateSectionMask)));
never executed: return (calendarPopup && (sections & (DateSectionMask)));
calendarPopupDescription
TRUEnever evaluated
FALSEnever evaluated
(sections & (DateSectionMask))Description
TRUEnever evaluated
FALSEnever evaluated
0
2562}-
2563-
2564void QDateTimeEditPrivate::syncCalendarWidget()-
2565{-
2566 Q_Q(QDateTimeEdit);-
2567 if (monthCalendar) {
monthCalendarDescription
TRUEnever evaluated
FALSEnever evaluated
0
2568 const QSignalBlocker blocker(monthCalendar);-
2569 monthCalendar->setDateRange(q->minimumDate(), q->maximumDate());-
2570 monthCalendar->setDate(q->date());-
2571 }
never executed: end of block
0
2572}
never executed: end of block
0
2573-
2574QCalendarPopup::QCalendarPopup(QWidget * parent, QCalendarWidget *cw)-
2575 : QWidget(parent, Qt::Popup)-
2576{-
2577 setAttribute(Qt::WA_WindowPropagation);-
2578-
2579 dateChanged = false;-
2580 if (!cw) {
!cwDescription
TRUEnever evaluated
FALSEnever evaluated
0
2581 verifyCalendarInstance();-
2582 } else {
never executed: end of block
0
2583 setCalendarWidget(cw);-
2584 }
never executed: end of block
0
2585}-
2586-
2587QCalendarWidget *QCalendarPopup::verifyCalendarInstance()-
2588{-
2589 if (calendar.isNull()) {
calendar.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2590 QCalendarWidget *cw = new QCalendarWidget(this);-
2591 cw->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);-
2592#ifdef QT_KEYPAD_NAVIGATION-
2593 if (QApplication::keypadNavigationEnabled())-
2594 cw->setHorizontalHeaderFormat(QCalendarWidget::SingleLetterDayNames);-
2595#endif-
2596 setCalendarWidget(cw);-
2597 return cw;
never executed: return cw;
0
2598 } else {-
2599 return calendar.data();
never executed: return calendar.data();
0
2600 }-
2601}-
2602-
2603void QCalendarPopup::setCalendarWidget(QCalendarWidget *cw)-
2604{-
2605 Q_ASSERT(cw);-
2606 QVBoxLayout *widgetLayout = qobject_cast<QVBoxLayout*>(layout());-
2607 if (!widgetLayout) {
!widgetLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
2608 widgetLayout = new QVBoxLayout(this);-
2609 widgetLayout->setMargin(0);-
2610 widgetLayout->setSpacing(0);-
2611 }
never executed: end of block
0
2612 delete calendar.data();-
2613 calendar = QPointer<QCalendarWidget>(cw);-
2614 widgetLayout->addWidget(cw);-
2615-
2616 connect(cw, SIGNAL(activated(QDate)), this, SLOT(dateSelected(QDate)));-
2617 connect(cw, SIGNAL(clicked(QDate)), this, SLOT(dateSelected(QDate)));-
2618 connect(cw, SIGNAL(selectionChanged()), this, SLOT(dateSelectionChanged()));-
2619-
2620 cw->setFocus();-
2621}
never executed: end of block
0
2622-
2623-
2624void QCalendarPopup::setDate(const QDate &date)-
2625{-
2626 oldDate = date;-
2627 verifyCalendarInstance()->setSelectedDate(date);-
2628}
never executed: end of block
0
2629-
2630void QCalendarPopup::setDateRange(const QDate &min, const QDate &max)-
2631{-
2632 QCalendarWidget *cw = verifyCalendarInstance();-
2633 cw->setMinimumDate(min);-
2634 cw->setMaximumDate(max);-
2635}
never executed: end of block
0
2636-
2637void QCalendarPopup::mousePressEvent(QMouseEvent *event)-
2638{-
2639 QDateTimeEdit *dateTime = qobject_cast<QDateTimeEdit *>(parentWidget());-
2640 if (dateTime) {
dateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2641 QStyleOptionComboBox opt;-
2642 opt.init(dateTime);-
2643 QRect arrowRect = dateTime->style()->subControlRect(QStyle::CC_ComboBox, &opt,-
2644 QStyle::SC_ComboBoxArrow, dateTime);-
2645 arrowRect.moveTo(dateTime->mapToGlobal(arrowRect .topLeft()));-
2646 if (arrowRect.contains(event->globalPos()) || rect().contains(event->pos()))
arrowRect.cont...->globalPos())Description
TRUEnever evaluated
FALSEnever evaluated
rect().contains(event->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
2647 setAttribute(Qt::WA_NoMouseReplay);
never executed: setAttribute(Qt::WA_NoMouseReplay);
0
2648 }
never executed: end of block
0
2649 QWidget::mousePressEvent(event);-
2650}
never executed: end of block
0
2651-
2652void QCalendarPopup::mouseReleaseEvent(QMouseEvent*)-
2653{-
2654 emit resetButton();-
2655}
never executed: end of block
0
2656-
2657bool QCalendarPopup::event(QEvent *event)-
2658{-
2659 if (event->type() == QEvent::KeyPress) {
event->type() ...vent::KeyPressDescription
TRUEnever evaluated
FALSEnever evaluated
0
2660 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);-
2661 if (keyEvent->matches(QKeySequence::Cancel))
keyEvent->matc...uence::Cancel)Description
TRUEnever evaluated
FALSEnever evaluated
0
2662 dateChanged = false;
never executed: dateChanged = false;
0
2663 }
never executed: end of block
0
2664 return QWidget::event(event);
never executed: return QWidget::event(event);
0
2665}-
2666-
2667void QCalendarPopup::dateSelectionChanged()-
2668{-
2669 dateChanged = true;-
2670 emit newDateSelected(verifyCalendarInstance()->selectedDate());-
2671}
never executed: end of block
0
2672void QCalendarPopup::dateSelected(const QDate &date)-
2673{-
2674 dateChanged = true;-
2675 emit activated(date);-
2676 close();-
2677}
never executed: end of block
0
2678-
2679void QCalendarPopup::hideEvent(QHideEvent *)-
2680{-
2681 emit resetButton();-
2682 if (!dateChanged)
!dateChangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2683 emit hidingCalendar(oldDate);
never executed: hidingCalendar(oldDate);
0
2684}
never executed: end of block
0
2685-
2686QT_END_NAMESPACE-
2687#include "moc_qdatetimeedit.cpp"-
2688#include "moc_qdatetimeedit_p.cpp"-
2689-
2690#endif // QT_NO_DATETIMEEDIT-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9