qdatetimeedit.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qdatetimeedit.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2QDateTimeEdit::QDateTimeEdit(QWidget *parent)-
3 : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)-
4{-
5 QDateTimeEditPrivate * const d = d_func();-
6 d->init(QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0, 0)));-
7}
never executed: end of block
0
8-
9-
10-
11-
12-
13-
14QDateTimeEdit::QDateTimeEdit(const QDateTime &datetime, QWidget *parent)-
15 : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)-
16{-
17 QDateTimeEditPrivate * const d = d_func();-
18 d->init(datetime.isValid() ? datetime : QDateTime(QDate(2000, 1, 1),-
19 QTime(0, 0, 0, 0)));-
20}
never executed: end of block
0
21QDateTimeEdit::QDateTimeEdit(const QDate &date, QWidget *parent)-
22 : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)-
23{-
24 QDateTimeEditPrivate * const d = d_func();-
25 d->init(date.isValid() ? date : QDate(2000, 1, 1));-
26}
never executed: end of block
0
27QDateTimeEdit::QDateTimeEdit(const QTime &time, QWidget *parent)-
28 : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)-
29{-
30 QDateTimeEditPrivate * const d = d_func();-
31 d->init(time.isValid() ? time : QTime(0, 0, 0, 0));-
32}
never executed: end of block
0
33-
34-
35-
36-
37-
38QDateTimeEdit::QDateTimeEdit(const QVariant &var, QVariant::Type parserType, QWidget *parent)-
39 : QAbstractSpinBox(*new QDateTimeEditPrivate, parent)-
40{-
41 QDateTimeEditPrivate * const d = d_func();-
42 d->parserType = parserType;-
43 d->init(var);-
44}
never executed: end of block
0
45-
46-
47-
48-
49QDateTimeEdit::~QDateTimeEdit()-
50{-
51}-
52QDateTime QDateTimeEdit::dateTime() const-
53{-
54 const QDateTimeEditPrivate * const d = d_func();-
55 return
never executed: return d->value.toDateTime();
d->value.toDateTime();
never executed: return d->value.toDateTime();
0
56}-
57-
58void QDateTimeEdit::setDateTime(const QDateTime &datetime)-
59{-
60 QDateTimeEditPrivate * const d = d_func();-
61 if (datetime.isValid()
datetime.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
62 d->clearCache();-
63 const QDate date = datetime.date();-
64 if (!(d->sections & DateSections_Mask)
!(d->sections ...Sections_Mask)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
65 setDateRange(date, date);
never executed: setDateRange(date, date);
0
66 d->setValue(QDateTime(date, datetime.time(), d->spec), EmitIfChanged);-
67 }
never executed: end of block
0
68}
never executed: end of block
0
69QDate QDateTimeEdit::date() const-
70{-
71 const QDateTimeEditPrivate * const d = d_func();-
72 return
never executed: return d->value.toDate();
d->value.toDate();
never executed: return d->value.toDate();
0
73}-
74-
75void QDateTimeEdit::setDate(const QDate &date)-
76{-
77 QDateTimeEditPrivate * const d = d_func();-
78 if (date.isValid()
date.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
79 if (!(d->sections & DateSections_Mask)
!(d->sections ...Sections_Mask)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
80 setDateRange(date, date);
never executed: setDateRange(date, date);
0
81-
82 d->clearCache();-
83 d->setValue(QDateTime(date, d->value.toTime(), d->spec), EmitIfChanged);-
84 d->updateTimeSpec();-
85 }
never executed: end of block
0
86}
never executed: end of block
0
87QTime QDateTimeEdit::time() const-
88{-
89 const QDateTimeEditPrivate * const d = d_func();-
90 return
never executed: return d->value.toTime();
d->value.toTime();
never executed: return d->value.toTime();
0
91}-
92-
93void QDateTimeEdit::setTime(const QTime &time)-
94{-
95 QDateTimeEditPrivate * const d = d_func();-
96 if (time.isValid()
time.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
97 d->clearCache();-
98 d->setValue(QDateTime(d->value.toDate(), time, d->spec), EmitIfChanged);-
99 }
never executed: end of block
0
100}
never executed: end of block
0
101QDateTime QDateTimeEdit::minimumDateTime() const-
102{-
103 const QDateTimeEditPrivate * const d = d_func();-
104 return
never executed: return d->minimum.toDateTime();
d->minimum.toDateTime();
never executed: return d->minimum.toDateTime();
0
105}-
106-
107void QDateTimeEdit::clearMinimumDateTime()-
108{-
109 setMinimumDateTime(QDateTime(QDate(1752, 9, 14), QTime(0, 0, 0, 0)));-
110}
never executed: end of block
0
111-
112void QDateTimeEdit::setMinimumDateTime(const QDateTime &dt)-
113{-
114 QDateTimeEditPrivate * const d = d_func();-
115 if (dt.isValid()
dt.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& dt.date() >= QDate(100, 1, 1)
dt.date() >= QDate(100, 1, 1)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
116 const QDateTime m = dt.toTimeSpec(d->spec);-
117 const QDateTime max = d->maximum.toDateTime();-
118 d->setRange(m, (max > m ? max : m));-
119 }
never executed: end of block
0
120}
never executed: end of block
0
121QDateTime QDateTimeEdit::maximumDateTime() const-
122{-
123 const QDateTimeEditPrivate * const d = d_func();-
124 return
never executed: return d->maximum.toDateTime();
d->maximum.toDateTime();
never executed: return d->maximum.toDateTime();
0
125}-
126-
127void QDateTimeEdit::clearMaximumDateTime()-
128{-
129 setMaximumDateTime(QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999)));-
130}
never executed: end of block
0
131-
132void QDateTimeEdit::setMaximumDateTime(const QDateTime &dt)-
133{-
134 QDateTimeEditPrivate * const d = d_func();-
135 if (dt.isValid()
dt.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& dt.date() <= QDate(7999, 12, 31)
dt.date() <= Q...(7999, 12, 31)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
136 const QDateTime m = dt.toTimeSpec(d->spec);-
137 const QDateTime min = d->minimum.toDateTime();-
138 d->setRange((min < m ? min : m), m);-
139 }
never executed: end of block
0
140}
never executed: end of block
0
141void QDateTimeEdit::setDateTimeRange(const QDateTime &min, const QDateTime &max)-
142{-
143 QDateTimeEditPrivate * const d = d_func();-
144 const QDateTime minimum = min.toTimeSpec(d->spec);-
145 QDateTime maximum = max.toTimeSpec(d->spec);-
146 if (min > max
min > maxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
147 maximum = minimum;
never executed: maximum = minimum;
0
148 d->setRange(minimum, maximum);-
149}
never executed: end of block
0
150QDate QDateTimeEdit::minimumDate() const-
151{-
152 const QDateTimeEditPrivate * const d = d_func();-
153 return
never executed: return d->minimum.toDate();
d->minimum.toDate();
never executed: return d->minimum.toDate();
0
154}-
155-
156void QDateTimeEdit::setMinimumDate(const QDate &min)-
157{-
158 QDateTimeEditPrivate * const d = d_func();-
159 if (min.isValid()
min.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& min >= QDate(100, 1, 1)
min >= QDate(100, 1, 1)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
160 setMinimumDateTime(QDateTime(min, d->minimum.toTime(), d->spec));-
161 }
never executed: end of block
0
162}
never executed: end of block
0
163-
164void QDateTimeEdit::clearMinimumDate()-
165{-
166 setMinimumDate(QDate(1752, 9, 14));-
167}
never executed: end of block
0
168QDate QDateTimeEdit::maximumDate() const-
169{-
170 const QDateTimeEditPrivate * const d = d_func();-
171 return
never executed: return d->maximum.toDate();
d->maximum.toDate();
never executed: return d->maximum.toDate();
0
172}-
173-
174void QDateTimeEdit::setMaximumDate(const QDate &max)-
175{-
176 QDateTimeEditPrivate * const d = d_func();-
177 if (max.isValid()
max.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
178 setMaximumDateTime(QDateTime(max, d->maximum.toTime(), d->spec));-
179 }
never executed: end of block
0
180}
never executed: end of block
0
181-
182void QDateTimeEdit::clearMaximumDate()-
183{-
184 setMaximumDate(QDate(7999, 12, 31));-
185}
never executed: end of block
0
186QTime QDateTimeEdit::minimumTime() const-
187{-
188 const QDateTimeEditPrivate * const d = d_func();-
189 return
never executed: return d->minimum.toTime();
d->minimum.toTime();
never executed: return d->minimum.toTime();
0
190}-
191-
192void QDateTimeEdit::setMinimumTime(const QTime &min)-
193{-
194 QDateTimeEditPrivate * const d = d_func();-
195 if (min.isValid()
min.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
196 const QDateTime m(d->minimum.toDate(), min, d->spec);-
197 setMinimumDateTime(m);-
198 }
never executed: end of block
0
199}
never executed: end of block
0
200-
201void QDateTimeEdit::clearMinimumTime()-
202{-
203 setMinimumTime(QTime(0, 0, 0, 0));-
204}
never executed: end of block
0
205QTime QDateTimeEdit::maximumTime() const-
206{-
207 const QDateTimeEditPrivate * const d = d_func();-
208 return
never executed: return d->maximum.toTime();
d->maximum.toTime();
never executed: return d->maximum.toTime();
0
209}-
210-
211void QDateTimeEdit::setMaximumTime(const QTime &max)-
212{-
213 QDateTimeEditPrivate * const d = d_func();-
214 if (max.isValid()
max.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
215 const QDateTime m(d->maximum.toDate(), max);-
216 setMaximumDateTime(m);-
217 }
never executed: end of block
0
218}
never executed: end of block
0
219-
220void QDateTimeEdit::clearMaximumTime()-
221{-
222 setMaximumTime(QTime(23, 59, 59, 999));-
223}
never executed: end of block
0
224void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max)-
225{-
226 QDateTimeEditPrivate * const d = d_func();-
227 if (min.isValid()
min.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& max.isValid()
max.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
228 setDateTimeRange(QDateTime(min, d->minimum.toTime(), d->spec),-
229 QDateTime(max, d->maximum.toTime(), d->spec));-
230 }
never executed: end of block
0
231}
never executed: end of block
0
232void QDateTimeEdit::setTimeRange(const QTime &min, const QTime &max)-
233{-
234 QDateTimeEditPrivate * const d = d_func();-
235 if (min.isValid()
min.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& max.isValid()
max.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
236 setDateTimeRange(QDateTime(d->minimum.toDate(), min, d->spec),-
237 QDateTime(d->maximum.toDate(), max, d->spec));-
238 }
never executed: end of block
0
239}
never executed: end of block
0
240QDateTimeEdit::Sections QDateTimeEdit::displayedSections() const-
241{-
242 const QDateTimeEditPrivate * const d = d_func();-
243 return
never executed: return d->sections;
d->sections;
never executed: return d->sections;
0
244}-
245QDateTimeEdit::Section QDateTimeEdit::currentSection() const-
246{-
247 const QDateTimeEditPrivate * const d = d_func();-
248-
249-
250-
251-
252 return
never executed: return d->convertToPublic(d->sectionType(d->currentSectionIndex));
d->convertToPublic(d->sectionType(d->currentSectionIndex));
never executed: return d->convertToPublic(d->sectionType(d->currentSectionIndex));
0
253}-
254-
255void QDateTimeEdit::setCurrentSection(Section section)-
256{-
257 QDateTimeEditPrivate * const d = d_func();-
258 if (section == NoSection
section == NoSectionDescription
TRUEnever evaluated
FALSEnever evaluated
|| !(section & d->sections)
!(section & d->sections)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
259 return;
never executed: return;
0
260-
261 d->updateCache(d->value, d->displayText());-
262 const int size = d->sectionNodes.size();-
263 int index = d->currentSectionIndex + 1;-
264 for (int i=0; i<2
i<2Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
265 while (index < size
index < sizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
266 if (d->convertToPublic(d->sectionType(index)) == section
d->convertToPu...x)) == sectionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
267 d->edit->setCursorPosition(d->sectionPos(index));-
268 if (false) QMessageLogger(__FILE__, 667, __PRETTY_FUNCTION__).debug() << d->sectionPos(index);
dead code: QMessageLogger(__FILE__, 667, __PRETTY_FUNCTION__).debug() << d->sectionPos(index);
-
269 return;
never executed: return;
0
270 }-
271 ++index;-
272 }
never executed: end of block
0
273 index = 0;-
274 }
never executed: end of block
0
275}
never executed: end of block
0
276QDateTimeEdit::Section QDateTimeEdit::sectionAt(int index) const-
277{-
278 const QDateTimeEditPrivate * const d = d_func();-
279 if (index < 0
index < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| index >= d->sectionNodes.size()
index >= d->se...onNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
280 return
never executed: return NoSection;
NoSection;
never executed: return NoSection;
0
281 return
never executed: return d->convertToPublic(d->sectionType(index));
d->convertToPublic(d->sectionType(index));
never executed: return d->convertToPublic(d->sectionType(index));
0
282}-
283int QDateTimeEdit::sectionCount() const-
284{-
285 const QDateTimeEditPrivate * const d = d_func();-
286 return
never executed: return d->sectionNodes.size();
d->sectionNodes.size();
never executed: return d->sectionNodes.size();
0
287}-
288int QDateTimeEdit::currentSectionIndex() const-
289{-
290 const QDateTimeEditPrivate * const d = d_func();-
291 return
never executed: return d->currentSectionIndex;
d->currentSectionIndex;
never executed: return d->currentSectionIndex;
0
292}-
293-
294void QDateTimeEdit::setCurrentSectionIndex(int index)-
295{-
296 QDateTimeEditPrivate * const d = d_func();-
297 if (index < 0
index < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| index >= d->sectionNodes.size()
index >= d->se...onNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
298 return;
never executed: return;
0
299 d->edit->setCursorPosition(d->sectionPos(index));-
300}
never executed: end of block
0
301QCalendarWidget *QDateTimeEdit::calendarWidget() const-
302{-
303 const QDateTimeEditPrivate * const d = d_func();-
304 if (!d->calendarPopup
!d->calendarPopupDescription
TRUEnever evaluated
FALSEnever evaluated
|| !(d->sections & QDateTimeParser::DateSectionMask)
!(d->sections ...teSectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
305 return
never executed: return 0;
0;
never executed: return 0;
0
306 if (!d->monthCalendar
!d->monthCalendarDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
307 const_cast<QDateTimeEditPrivate*>(d)->initCalendarPopup();-
308 }
never executed: end of block
0
309 return
never executed: return d->monthCalendar->calendarWidget();
d->monthCalendar->calendarWidget();
never executed: return d->monthCalendar->calendarWidget();
0
310}-
311void QDateTimeEdit::setCalendarWidget(QCalendarWidget *calendarWidget)-
312{-
313 QDateTimeEditPrivate * const d = d_func();-
314 if (__builtin_expect(!!(!calendarWidget), false)
__builtin_expe...idget), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
315 QMessageLogger(__FILE__, 773, __PRETTY_FUNCTION__).warning("QDateTimeEdit::setCalendarWidget: Cannot set a null calendar widget");-
316 return;
never executed: return;
0
317 }-
318-
319 if (__builtin_expect(!!(!d->calendarPopup), false)
__builtin_expe...Popup), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
320 QMessageLogger(__FILE__, 778, __PRETTY_FUNCTION__).warning("QDateTimeEdit::setCalendarWidget: calendarPopup is set to false");-
321 return;
never executed: return;
0
322 }-
323-
324 if (__builtin_expect(!!(!(d->display & QDateTimeParser::DateSectionMask)), false)
__builtin_expe...Mask)), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
325 QMessageLogger(__FILE__, 783, __PRETTY_FUNCTION__).warning("QDateTimeEdit::setCalendarWidget: no date sections specified");-
326 return;
never executed: return;
0
327 }-
328 d->initCalendarPopup(calendarWidget);-
329}
never executed: end of block
0
330void QDateTimeEdit::setSelectedSection(Section section)-
331{-
332 QDateTimeEditPrivate * const d = d_func();-
333 if (section == NoSection
section == NoSectionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
334 d->edit->setSelection(d->edit->cursorPosition(), 0);-
335 }
never executed: end of block
else if (section & d->sections
section & d->sectionsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
336 if (currentSection() != section
currentSection() != sectionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
337 setCurrentSection(section);
never executed: setCurrentSection(section);
0
338 d->setSelected(d->currentSectionIndex);-
339 }
never executed: end of block
0
340}
never executed: end of block
0
341QString QDateTimeEdit::sectionText(Section section) const-
342{-
343 const QDateTimeEditPrivate * const d = d_func();-
344 if (section == QDateTimeEdit::NoSection
section == QDa...dit::NoSectionDescription
TRUEnever evaluated
FALSEnever evaluated
|| !(section & d->sections)
!(section & d->sections)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
345 return
never executed: return QString();
QString();
never executed: return QString();
0
346 }-
347-
348 d->updateCache(d->value, d->displayText());-
349 const int sectionIndex = d->absoluteIndex(section, 0);-
350 return
never executed: return d->sectionText(sectionIndex);
d->sectionText(sectionIndex);
never executed: return d->sectionText(sectionIndex);
0
351}-
352QString QDateTimeEdit::displayFormat() const-
353{-
354 const QDateTimeEditPrivate * const d = d_func();-
355 return
never executed: return isRightToLeft() ? d->unreversedFormat : d->displayFormat;
isRightToLeft() ? d->unreversedFormat : d->displayFormat;
never executed: return isRightToLeft() ? d->unreversedFormat : d->displayFormat;
0
356}-
357-
358void QDateTimeEdit::setDisplayFormat(const QString &format)-
359{-
360 QDateTimeEditPrivate * const d = d_func();-
361 if (d->parseFormat(format)
d->parseFormat(format)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
362 d->unreversedFormat.clear();-
363 if (isRightToLeft()
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
364 d->unreversedFormat = format;-
365 d->displayFormat.clear();-
366 for (int i=d->sectionNodes.size() - 1; i>=0
i>=0Description
TRUEnever evaluated
FALSEnever evaluated
; --i) {
0
367 d->displayFormat += d->separators.at(i + 1);-
368 d->displayFormat += d->sectionNode(i).format();-
369 }
never executed: end of block
0
370 d->displayFormat += d->separators.at(0);-
371 std::reverse(d->separators.begin(), d->separators.end());-
372 std::reverse(d->sectionNodes.begin(), d->sectionNodes.end());-
373 }
never executed: end of block
0
374-
375 d->formatExplicitlySet = true;-
376 d->sections = d->convertSections(d->display);-
377 d->clearCache();-
378-
379 d->currentSectionIndex = qMin(d->currentSectionIndex, d->sectionNodes.size() - 1);-
380 const bool timeShown = (d->sections & TimeSections_Mask);-
381 const bool dateShown = (d->sections & DateSections_Mask);-
382 ((!(dateShown || timeShown)) ? qt_assert("dateShown || timeShown",__FILE__,891) : qt_noop());-
383 if (timeShown
timeShownDescription
TRUEnever evaluated
FALSEnever evaluated
&& !dateShown
!dateShownDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
384 QTime time = d->value.toTime();-
385 setDateRange(d->value.toDate(), d->value.toDate());-
386 if (d->minimum.toTime() >= d->maximum.toTime()
d->minimum.toT...ximum.toTime()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
387 setTimeRange(QTime(0, 0, 0, 0), QTime(23, 59, 59, 999));-
388-
389 setTime(time);-
390 }
never executed: end of block
0
391 }
never executed: end of block
else if (dateShown
dateShownDescription
TRUEnever evaluated
FALSEnever evaluated
&& !timeShown
!timeShownDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
392 setTimeRange(QTime(0, 0, 0, 0), QTime(23, 59, 59, 999));-
393 d->value = QDateTime(d->value.toDate(), QTime(), d->spec);-
394 }
never executed: end of block
0
395 d->updateEdit();-
396 d->_q_editorCursorPositionChanged(-1, 0);-
397 }
never executed: end of block
0
398}
never executed: end of block
0
399bool QDateTimeEdit::calendarPopup() const-
400{-
401 const QDateTimeEditPrivate * const d = d_func();-
402 return
never executed: return d->calendarPopup;
d->calendarPopup;
never executed: return d->calendarPopup;
0
403}-
404-
405void QDateTimeEdit::setCalendarPopup(bool enable)-
406{-
407 QDateTimeEditPrivate * const d = d_func();-
408 if (enable == d->calendarPopup
enable == d->calendarPopupDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
409 return;
never executed: return;
0
410 setAttribute(Qt::WA_MacShowFocusRect, !enable);-
411 d->calendarPopup = enable;-
412-
413-
414-
415-
416 d->updateEditFieldGeometry();-
417 update();-
418}
never executed: end of block
0
419-
420-
421-
422-
423-
424-
425-
426Qt::TimeSpec QDateTimeEdit::timeSpec() const-
427{-
428 const QDateTimeEditPrivate * const d = d_func();-
429 return
never executed: return d->spec;
d->spec;
never executed: return d->spec;
0
430}-
431-
432void QDateTimeEdit::setTimeSpec(Qt::TimeSpec spec)-
433{-
434 QDateTimeEditPrivate * const d = d_func();-
435 if (spec != d->spec
spec != d->specDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
436 d->spec = spec;-
437 d->updateTimeSpec();-
438 }
never executed: end of block
0
439}
never executed: end of block
0
440-
441-
442-
443-
444-
445QSize QDateTimeEdit::sizeHint() const-
446{-
447 const QDateTimeEditPrivate * const d = d_func();-
448 if (d->cachedSizeHint.isEmpty()
d->cachedSizeHint.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
449 ensurePolished();-
450-
451 const QFontMetrics fm(fontMetrics());-
452 int h = d->edit->sizeHint().height();-
453 int w = 0;-
454 QString s;-
455 s = d->textFromValue(d->minimum) + QLatin1Char(' ');-
456 w = qMax<int>(w, fm.width(s));-
457 s = d->textFromValue(d->maximum) + QLatin1Char(' ');-
458 w = qMax<int>(w, fm.width(s));-
459 if (d->specialValueText.size()
d->specialValueText.size()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
460 s = d->specialValueText;-
461 w = qMax<int>(w, fm.width(s));-
462 }
never executed: end of block
0
463 w += 2;-
464-
465 QSize hint(w, h);-
466-
467-
468-
469-
470-
471-
472-
473 {-
474 QStyleOptionSpinBox opt;-
475 initStyleOption(&opt);-
476 d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this)-
477 .expandedTo(QApplication::globalStrut());-
478 }-
479-
480 d->cachedMinimumSizeHint = d->cachedSizeHint;-
481-
482 }
never executed: end of block
0
483 return
never executed: return d->cachedSizeHint;
d->cachedSizeHint;
never executed: return d->cachedSizeHint;
0
484}-
485-
486-
487-
488-
489-
490-
491bool QDateTimeEdit::event(QEvent *event)-
492{-
493 QDateTimeEditPrivate * const d = d_func();-
494 switch (event->type()) {-
495 case
never executed: case QEvent::ApplicationLayoutDirectionChange:
QEvent::ApplicationLayoutDirectionChange:
never executed: case QEvent::ApplicationLayoutDirectionChange:
{
0
496 const bool was = d->formatExplicitlySet;-
497 const QString oldFormat = d->displayFormat;-
498 d->displayFormat.clear();-
499 setDisplayFormat(oldFormat);-
500 d->formatExplicitlySet = was;-
501 break;
never executed: break;
}
0
502 case
never executed: case QEvent::LocaleChange:
QEvent::LocaleChange:
never executed: case QEvent::LocaleChange:
0
503 d->updateEdit();-
504 break;
never executed: break;
0
505 case
never executed: case QEvent::StyleChange:
QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
506-
507-
508-
509 d->setLayoutItemMargins(QStyle::SE_DateTimeEditLayoutItem);-
510 break;
never executed: break;
0
511 default
never executed: default:
:
never executed: default:
0
512 break;
never executed: break;
0
513 }-
514 return
never executed: return QAbstractSpinBox::event(event);
QAbstractSpinBox::event(event);
never executed: return QAbstractSpinBox::event(event);
0
515}-
516-
517-
518-
519-
520-
521void QDateTimeEdit::clear()-
522{-
523 QDateTimeEditPrivate * const d = d_func();-
524 d->clearSection(d->currentSectionIndex);-
525}
never executed: end of block
0
526-
527-
528-
529-
530void QDateTimeEdit::keyPressEvent(QKeyEvent *event)-
531{-
532 QDateTimeEditPrivate * const d = d_func();-
533 int oldCurrent = d->currentSectionIndex;-
534 bool select = true;-
535 bool inserted = false;-
536-
537 switch (event->key()) {-
538 case
never executed: case Qt::Key_Enter:
Qt::Key_Enter:
never executed: case Qt::Key_Enter:
0
539 case
never executed: case Qt::Key_Return:
Qt::Key_Return:
never executed: case Qt::Key_Return:
0
540 d->interpret(AlwaysEmit);-
541 d->setSelected(d->currentSectionIndex, true);-
542 event->ignore();-
543 editingFinished();-
544 return;
never executed: return;
0
545 default
never executed: default:
:
never executed: default:
0
546 if (!d->isSeparatorKey(event)
!d->isSeparatorKey(event)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
547 inserted = select = !event->text().isEmpty()
!event->text().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& event->text().at(0).isPrint()
event->text().at(0).isPrint()Description
TRUEnever evaluated
FALSEnever evaluated
0
548 && !(event->modifiers() & ~(Qt::ShiftModifier|Qt::KeypadModifier))
!(event->modif...ypadModifier))Description
TRUEnever evaluated
FALSEnever evaluated
;
0
549 break;
never executed: break;
0
550 }-
551 case
never executed: case Qt::Key_Left:
Qt::Key_Left:
never executed: case Qt::Key_Left:
code before this statement never executed: case Qt::Key_Left:
0
552 case
never executed: case Qt::Key_Right:
Qt::Key_Right:
never executed: case Qt::Key_Right:
0
553 if (event->key() == Qt::Key_Left
event->key() == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
|| event->key() == Qt::Key_Right
event->key() == Qt::Key_RightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
554 if (-
555-
556-
557-
558-
559 !(event->modifiers() & Qt::ControlModifier)
!(event->modif...ntrolModifier)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
560 select = false;-
561 break;
never executed: break;
0
562 }-
563 }
never executed: end of block
0
564-
565 case
never executed: case Qt::Key_Backtab:
Qt::Key_Backtab:
never executed: case Qt::Key_Backtab:
code before this statement never executed: case Qt::Key_Backtab:
0
566 case
never executed: case Qt::Key_Tab:
Qt::Key_Tab:
never executed: case Qt::Key_Tab:
{
0
567 event->accept();-
568 if (d->specialValue()
d->specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
569 d->edit->setSelection(d->edit->cursorPosition(), 0);-
570 return;
never executed: return;
0
571 }-
572 const bool forward = event->key() != Qt::Key_Left
event->key() != Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
&& event->key() != Qt::Key_Backtab
event->key() !...t::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
0
573 && (event->key() != Qt::Key_Tab
event->key() != Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
|| !(event->modifiers() & Qt::ShiftModifier)
!(event->modif...ShiftModifier)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
574 if (event->key() != Qt::Key_Backtab
event->key() !...t::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
&& event->key() != Qt::Key_Tab
event->key() != Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
575 focusNextPrevChild(forward);
never executed: focusNextPrevChild(forward);
0
576-
577 return;
never executed: return;
}
0
578 }-
579 QAbstractSpinBox::keyPressEvent(event);-
580 if (select
selectDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->edit->hasSelectedText()
!d->edit->hasSelectedText()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
581 if (inserted
insertedDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->sectionAt(d->edit->cursorPosition()) == QDateTimeParser::NoSectionIndex
d->sectionAt(d...NoSectionIndexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
582 QString str = d->displayText();-
583 int pos = d->edit->cursorPosition();-
584 if (validate(str, pos) == QValidator::Acceptable
validate(str, ...or::AcceptableDescription
TRUEnever evaluated
FALSEnever evaluated
0
585 && (d->sectionNodes.at(oldCurrent).count != 1
d->sectionNode...nt).count != 1Description
TRUEnever evaluated
FALSEnever evaluated
0
586 || d->sectionMaxSize(oldCurrent) == d->sectionSize(oldCurrent)
d->sectionMaxS...ze(oldCurrent)Description
TRUEnever evaluated
FALSEnever evaluated
0
587 || d->skipToNextSection(oldCurrent, d->value.toDateTime(), d->sectionText(oldCurrent))
d->skipToNextS...t(oldCurrent))Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
588 if (false) QMessageLogger(__FILE__, 1182, __PRETTY_FUNCTION__).debug() << "Setting currentsection to"
dead code: QMessageLogger(__FILE__, 1182, __PRETTY_FUNCTION__).debug() << "Setting currentsection to" << d->closestSection(d->edit->cursorPosition(), true) << event->key() << oldCurrent << str;
-
589 << d->closestSection(d->edit->cursorPosition(), true) << event->key()
dead code: QMessageLogger(__FILE__, 1182, __PRETTY_FUNCTION__).debug() << "Setting currentsection to" << d->closestSection(d->edit->cursorPosition(), true) << event->key() << oldCurrent << str;
-
590 << oldCurrent << str;
dead code: QMessageLogger(__FILE__, 1182, __PRETTY_FUNCTION__).debug() << "Setting currentsection to" << d->closestSection(d->edit->cursorPosition(), true) << event->key() << oldCurrent << str;
-
591 const int tmp = d->closestSection(d->edit->cursorPosition(), true);-
592 if (tmp >= 0
tmp >= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
593 d->currentSectionIndex = tmp;
never executed: d->currentSectionIndex = tmp;
0
594 }
never executed: end of block
0
595 }
never executed: end of block
0
596 if (d->currentSectionIndex != oldCurrent
d->currentSect... != oldCurrentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
597 d->setSelected(d->currentSectionIndex);-
598 }
never executed: end of block
0
599 }
never executed: end of block
0
600 if (d->specialValue()
d->specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
601 d->edit->setSelection(d->edit->cursorPosition(), 0);-
602 }
never executed: end of block
0
603}
never executed: end of block
0
604-
605-
606-
607-
608-
609-
610void QDateTimeEdit::wheelEvent(QWheelEvent *event)-
611{-
612 QAbstractSpinBox::wheelEvent(event);-
613}
never executed: end of block
0
614-
615-
616-
617-
618-
619-
620void QDateTimeEdit::focusInEvent(QFocusEvent *event)-
621{-
622 QDateTimeEditPrivate * const d = d_func();-
623 QAbstractSpinBox::focusInEvent(event);-
624 QString *frm = 0;-
625 const int oldPos = d->edit->cursorPosition();-
626 if (!d->formatExplicitlySet
!d->formatExplicitlySetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
627 if (d->displayFormat == d->defaultTimeFormat
d->displayForm...aultTimeFormatDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
628 frm = &d->defaultTimeFormat;-
629 }
never executed: end of block
else if (d->displayFormat == d->defaultDateFormat
d->displayForm...aultDateFormatDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
630 frm = &d->defaultDateFormat;-
631 }
never executed: end of block
else if (d->displayFormat == d->defaultDateTimeFormat
d->displayForm...DateTimeFormatDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
632 frm = &d->defaultDateTimeFormat;-
633 }
never executed: end of block
0
634-
635 if (frm
frmDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
636 d->readLocaleSettings();-
637 if (d->displayFormat != *frm
d->displayFormat != *frmDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
638 setDisplayFormat(*frm);-
639 d->formatExplicitlySet = false;-
640 d->edit->setCursorPosition(oldPos);-
641 }
never executed: end of block
0
642 }
never executed: end of block
0
643 }
never executed: end of block
0
644 const bool oldHasHadFocus = d->hasHadFocus;-
645 d->hasHadFocus = true;-
646 bool first = true;-
647 switch (event->reason()) {-
648 case
never executed: case Qt::BacktabFocusReason:
Qt::BacktabFocusReason:
never executed: case Qt::BacktabFocusReason:
0
649 first = false;-
650 break;
never executed: break;
0
651 case
never executed: case Qt::MouseFocusReason:
Qt::MouseFocusReason:
never executed: case Qt::MouseFocusReason:
0
652 case
never executed: case Qt::PopupFocusReason:
Qt::PopupFocusReason:
never executed: case Qt::PopupFocusReason:
0
653 return;
never executed: return;
0
654 case
never executed: case Qt::ActiveWindowFocusReason:
Qt::ActiveWindowFocusReason:
never executed: case Qt::ActiveWindowFocusReason:
0
655 if (oldHasHadFocus
oldHasHadFocusDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
656 return;
never executed: return;
0
657 case
never executed: case Qt::ShortcutFocusReason:
Qt::ShortcutFocusReason:
never executed: case Qt::ShortcutFocusReason:
code before this statement never executed: case Qt::ShortcutFocusReason:
0
658 case
never executed: case Qt::TabFocusReason:
Qt::TabFocusReason:
never executed: case Qt::TabFocusReason:
0
659 default
never executed: default:
:
never executed: default:
0
660 break;
never executed: break;
0
661 }-
662 if (isRightToLeft()
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
663 first = !first;
never executed: first = !first;
0
664 d->updateEdit();-
665-
666 d->setSelected(first ? 0 : d->sectionNodes.size() - 1);-
667}
never executed: end of block
0
668-
669-
670-
671-
672-
673bool QDateTimeEdit::focusNextPrevChild(bool next)-
674{-
675 QDateTimeEditPrivate * const d = d_func();-
676 const int newSection = d->nextPrevSection(d->currentSectionIndex, next);-
677 switch (d->sectionType(newSection)) {-
678 case
never executed: case QDateTimeParser::NoSection:
QDateTimeParser::NoSection:
never executed: case QDateTimeParser::NoSection:
0
679 case
never executed: case QDateTimeParser::FirstSection:
QDateTimeParser::FirstSection:
never executed: case QDateTimeParser::FirstSection:
0
680 case
never executed: case QDateTimeParser::LastSection:
QDateTimeParser::LastSection:
never executed: case QDateTimeParser::LastSection:
0
681 return
never executed: return QAbstractSpinBox::focusNextPrevChild(next);
QAbstractSpinBox::focusNextPrevChild(next);
never executed: return QAbstractSpinBox::focusNextPrevChild(next);
0
682 default
never executed: default:
:
never executed: default:
0
683 d->edit->deselect();-
684 d->edit->setCursorPosition(d->sectionPos(newSection));-
685 if (false) QMessageLogger(__FILE__, 1279, __PRETTY_FUNCTION__).debug() << d->sectionPos(newSection);
dead code: QMessageLogger(__FILE__, 1279, __PRETTY_FUNCTION__).debug() << d->sectionPos(newSection);
-
686 d->setSelected(newSection, true);-
687 return
never executed: return false;
false;
never executed: return false;
0
688 }-
689}-
690-
691-
692-
693-
694-
695void QDateTimeEdit::stepBy(int steps)-
696{-
697 QDateTimeEditPrivate * const d = d_func();-
698 if (d->specialValue()
d->specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
&& displayedSections() != AmPmSection
displayedSecti...!= AmPmSectionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
699 for (int i=0; i<d->sectionNodes.size()
i<d->sectionNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
700 if (d->sectionType(i) != QDateTimeParser::AmPmSection
d->sectionType...r::AmPmSectionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
701 d->currentSectionIndex = i;-
702 break;
never executed: break;
0
703 }-
704 }
never executed: end of block
0
705 }
never executed: end of block
0
706 d->setValue(d->stepBy(d->currentSectionIndex, steps, false), EmitIfChanged);-
707 d->updateCache(d->value, d->displayText());-
708-
709 d->setSelected(d->currentSectionIndex);-
710 d->updateTimeSpec();-
711}
never executed: end of block
0
712QString QDateTimeEdit::textFromDateTime(const QDateTime &dateTime) const-
713{-
714 const QDateTimeEditPrivate * const d = d_func();-
715 return
never executed: return locale().toString(dateTime, d->displayFormat);
locale().toString(dateTime, d->displayFormat);
never executed: return locale().toString(dateTime, d->displayFormat);
0
716}-
717QDateTime QDateTimeEdit::dateTimeFromText(const QString &text) const-
718{-
719 const QDateTimeEditPrivate * const d = d_func();-
720 QString copy = text;-
721 int pos = d->edit->cursorPosition();-
722 QValidator::State state = QValidator::Acceptable;-
723 return
never executed: return d->validateAndInterpret(copy, pos, state);
d->validateAndInterpret(copy, pos, state);
never executed: return d->validateAndInterpret(copy, pos, state);
0
724}-
725-
726-
727-
728-
729-
730QValidator::State QDateTimeEdit::validate(QString &text, int &pos) const-
731{-
732 const QDateTimeEditPrivate * const d = d_func();-
733 QValidator::State state;-
734 d->validateAndInterpret(text, pos, state);-
735 return
never executed: return state;
state;
never executed: return state;
0
736}-
737-
738-
739-
740-
741-
742-
743void QDateTimeEdit::fixup(QString &input) const-
744{-
745 const QDateTimeEditPrivate * const d = d_func();-
746 QValidator::State state;-
747 int copy = d->edit->cursorPosition();-
748-
749 d->validateAndInterpret(input, copy, state, true);-
750}
never executed: end of block
0
751-
752-
753-
754-
755-
756-
757QDateTimeEdit::StepEnabled QDateTimeEdit::stepEnabled() const-
758{-
759 const QDateTimeEditPrivate * const d = d_func();-
760 if (d->readOnly
d->readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
761 return
never executed: return StepEnabled(0);
StepEnabled(0);
never executed: return StepEnabled(0);
0
762 if (d->specialValue()
d->specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
763 return
never executed: return (d->minimum == d->maximum ? StepEnabled(0) : StepEnabled(StepUpEnabled));
(d->minimum == d->maximum ? StepEnabled(0) : StepEnabled(StepUpEnabled));
never executed: return (d->minimum == d->maximum ? StepEnabled(0) : StepEnabled(StepUpEnabled));
0
764 }-
765-
766 QAbstractSpinBox::StepEnabled ret = 0;-
767 switch (d->sectionType(d->currentSectionIndex)) {-
768 case
never executed: case QDateTimeParser::NoSection:
QDateTimeParser::NoSection:
never executed: case QDateTimeParser::NoSection:
0
769 case
never executed: case QDateTimeParser::FirstSection:
QDateTimeParser::FirstSection:
never executed: case QDateTimeParser::FirstSection:
0
770 case
never executed: case QDateTimeParser::LastSection:
QDateTimeParser::LastSection:
never executed: case QDateTimeParser::LastSection:
return
never executed: return 0;
0;
never executed: return 0;
0
771 default
never executed: default:
:
never executed: default:
break;
never executed: break;
0
772 }-
773 if (d->wrapping
d->wrappingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
774 return
never executed: return StepEnabled(StepDownEnabled|StepUpEnabled);
StepEnabled(StepDownEnabled|StepUpEnabled);
never executed: return StepEnabled(StepDownEnabled|StepUpEnabled);
0
775-
776 QVariant v = d->stepBy(d->currentSectionIndex, 1, true);-
777 if (v != d->value
v != d->valueDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
778 ret |= QAbstractSpinBox::StepUpEnabled;-
779 }
never executed: end of block
0
780 v = d->stepBy(d->currentSectionIndex, -1, true);-
781 if (v != d->value
v != d->valueDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
782 ret |= QAbstractSpinBox::StepDownEnabled;-
783 }
never executed: end of block
0
784-
785 return
never executed: return ret;
ret;
never executed: return ret;
0
786}-
787-
788-
789-
790-
791-
792-
793void QDateTimeEdit::mousePressEvent(QMouseEvent *event)-
794{-
795 QDateTimeEditPrivate * const d = d_func();-
796 if (!d->calendarPopupEnabled()
!d->calendarPopupEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
797 QAbstractSpinBox::mousePressEvent(event);-
798 return;
never executed: return;
0
799 }-
800 d->updateHoverControl(event->pos());-
801 if (d->hoverControl == QStyle::SC_ComboBoxArrow
d->hoverContro..._ComboBoxArrowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
802 event->accept();-
803 if (d->readOnly
d->readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
804 return;
never executed: return;
0
805 }-
806 d->updateArrow(QStyle::State_Sunken);-
807 d->initCalendarPopup();-
808 d->positionCalendarPopup();-
809-
810 d->monthCalendar->show();-
811 }
never executed: end of block
else {
0
812 QAbstractSpinBox::mousePressEvent(event);-
813 }
never executed: end of block
0
814}-
815QTimeEdit::QTimeEdit(QWidget *parent)-
816 : QDateTimeEdit(QTime(0, 0, 0, 0), QVariant::Time, parent)-
817{-
818 connect(this, qFlagLocation("2""timeChanged(QTime)" "\0" __FILE__ ":" "1540"), qFlagLocation("2""userTimeChanged(QTime)" "\0" __FILE__ ":" "1540"));-
819}
never executed: end of block
0
820-
821-
822-
823-
824-
825-
826QTimeEdit::QTimeEdit(const QTime &time, QWidget *parent)-
827 : QDateTimeEdit(time, QVariant::Time, parent)-
828{-
829}
never executed: end of block
0
830-
831-
832-
833-
834QTimeEdit::~QTimeEdit()-
835{-
836}-
837QDateEdit::QDateEdit(QWidget *parent)-
838 : QDateTimeEdit(QDate(2000, 1, 1), QVariant::Date, parent)-
839{-
840 connect(this, qFlagLocation("2""dateChanged(QDate)" "\0" __FILE__ ":" "1616"), qFlagLocation("2""userDateChanged(QDate)" "\0" __FILE__ ":" "1616"));-
841}
never executed: end of block
0
842-
843-
844-
845-
846-
847-
848QDateEdit::QDateEdit(const QDate &date, QWidget *parent)-
849 : QDateTimeEdit(date, QVariant::Date, parent)-
850{-
851}
never executed: end of block
0
852-
853-
854-
855-
856QDateEdit::~QDateEdit()-
857{-
858}-
859QDateTimeEditPrivate::QDateTimeEditPrivate()-
860 : QDateTimeParser(QVariant::DateTime, QDateTimeParser::DateTimeEdit)-
861{-
862 hasHadFocus = false;-
863 formatExplicitlySet = false;-
864 cacheGuard = false;-
865 fixday = true;-
866 type = QVariant::DateTime;-
867 sections = 0;-
868 cachedDay = -1;-
869 currentSectionIndex = FirstSectionIndex;-
870-
871 first.pos = 0;-
872 sections = 0;-
873 calendarPopup = false;-
874 minimum = QDateTime(QDate(1752, 9, 14), QTime(0, 0, 0, 0));-
875 maximum = QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999));-
876 arrowState = QStyle::State_None;-
877 monthCalendar = 0;-
878 readLocaleSettings();-
879-
880-
881-
882-
883}
never executed: end of block
0
884-
885QDateTimeEditPrivate::~QDateTimeEditPrivate()-
886{-
887}-
888-
889void QDateTimeEditPrivate::updateTimeSpec()-
890{-
891 minimum = minimum.toDateTime().toTimeSpec(spec);-
892 maximum = maximum.toDateTime().toTimeSpec(spec);-
893 value = value.toDateTime().toTimeSpec(spec);-
894-
895-
896 const bool dateShown = (sections & QDateTimeEdit::DateSections_Mask);-
897 if (!dateShown
!dateShownDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
898 if (minimum.toTime() >= maximum.toTime()
minimum.toTime...ximum.toTime()Description
TRUEnever evaluated
FALSEnever evaluated
){
0
899 minimum = QDateTime(value.toDate(), QTime(0, 0, 0, 0), spec);-
900 maximum = QDateTime(value.toDate(), QTime(23, 59, 59, 999), spec);-
901 }
never executed: end of block
0
902 }
never executed: end of block
0
903}
never executed: end of block
0
904-
905void QDateTimeEditPrivate::updateEdit()-
906{-
907 const QString newText = (specialValue()
specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
? specialValueText : textFromValue(value));
0
908 if (newText == displayText()
newText == displayText()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
909 return;
never executed: return;
0
910 int selsize = edit->selectedText().size();-
911 const QSignalBlocker blocker(edit);-
912-
913 edit->setText(newText);-
914-
915 if (!specialValue()
!specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
0
916-
917-
918-
919 ) {-
920 int cursor = sectionPos(currentSectionIndex);-
921 if (false) QMessageLogger(__FILE__, 1722, __PRETTY_FUNCTION__).debug() << "cursor is " << cursor << currentSectionIndex;
dead code: QMessageLogger(__FILE__, 1722, __PRETTY_FUNCTION__).debug() << "cursor is " << cursor << currentSectionIndex;
-
922 cursor = qBound(0, cursor, displayText().size());-
923 if (false) QMessageLogger(__FILE__, 1724, __PRETTY_FUNCTION__).debug() << cursor;
dead code: QMessageLogger(__FILE__, 1724, __PRETTY_FUNCTION__).debug() << cursor;
-
924 if (selsize > 0
selsize > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
925 edit->setSelection(cursor, selsize);-
926 if (false) QMessageLogger(__FILE__, 1727, __PRETTY_FUNCTION__).debug() << cursor << selsize;
dead code: QMessageLogger(__FILE__, 1727, __PRETTY_FUNCTION__).debug() << cursor << selsize;
-
927 }
never executed: end of block
else {
0
928 edit->setCursorPosition(cursor);-
929 if (false) QMessageLogger(__FILE__, 1730, __PRETTY_FUNCTION__).debug() << cursor;
dead code: QMessageLogger(__FILE__, 1730, __PRETTY_FUNCTION__).debug() << cursor;
-
930-
931 }
never executed: end of block
0
932 }-
933}
never executed: end of block
0
934void QDateTimeEditPrivate::setSelected(int sectionIndex, bool forward)-
935{-
936 if (specialValue()
specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
0
937-
938-
939-
940 ) {-
941 edit->selectAll();-
942 }
never executed: end of block
else {
0
943 const SectionNode &node = sectionNode(sectionIndex);-
944 if (node.type == NoSection
node.type == NoSectionDescription
TRUEnever evaluated
FALSEnever evaluated
|| node.type == LastSection
node.type == LastSectionDescription
TRUEnever evaluated
FALSEnever evaluated
|| node.type == FirstSection
node.type == FirstSectionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
945 return;
never executed: return;
0
946-
947 updateCache(value, displayText());-
948 const int size = sectionSize(sectionIndex);-
949 if (forward
forwardDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
950 edit->setSelection(sectionPos(node), size);-
951 }
never executed: end of block
else {
0
952 edit->setSelection(sectionPos(node) + size, -size);-
953 }
never executed: end of block
0
954 }-
955}-
956-
957-
958-
959-
960-
961-
962-
963int QDateTimeEditPrivate::sectionAt(int pos) const-
964{-
965 if (pos < separators.first().size()
pos < separato...first().size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
966 return
never executed: return (pos == 0 ? FirstSectionIndex : NoSectionIndex);
(pos == 0 ? FirstSectionIndex : NoSectionIndex);
never executed: return (pos == 0 ? FirstSectionIndex : NoSectionIndex);
0
967-
968 const QString text = displayText();-
969 const int textSize = text.size();-
970 if (textSize - pos < separators.last().size() + 1
textSize - pos...t().size() + 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
971 if (separators.last().size() == 0
separators.last().size() == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
972 return
never executed: return sectionNodes.count() - 1;
sectionNodes.count() - 1;
never executed: return sectionNodes.count() - 1;
0
973 }-
974 return
never executed: return (pos == textSize ? LastSectionIndex : NoSectionIndex);
(pos == textSize ? LastSectionIndex : NoSectionIndex);
never executed: return (pos == textSize ? LastSectionIndex : NoSectionIndex);
0
975 }-
976 updateCache(value, text);-
977-
978 for (int i=0; i<sectionNodes.size()
i<sectionNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
979 const int tmp = sectionPos(i);-
980 if (pos < tmp + sectionSize(i)
pos < tmp + sectionSize(i)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
981 return
never executed: return (pos < tmp ? -1 : i);
(pos < tmp ? -1 : i);
never executed: return (pos < tmp ? -1 : i);
0
982 }-
983 }
never executed: end of block
0
984 return
never executed: return -1;
-1;
never executed: return -1;
0
985}-
986int QDateTimeEditPrivate::closestSection(int pos, bool forward) const-
987{-
988 ((!(pos >= 0)) ? qt_assert("pos >= 0",__FILE__,1805) : qt_noop());-
989 if (pos < separators.first().size()
pos < separato...first().size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
990 return
never executed: return forward ? 0 : FirstSectionIndex;
forward ? 0 : FirstSectionIndex;
never executed: return forward ? 0 : FirstSectionIndex;
0
991-
992 const QString text = displayText();-
993 if (text.size() - pos < separators.last().size() + 1
text.size() - ...t().size() + 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
994 return
never executed: return forward ? LastSectionIndex : sectionNodes.size() - 1;
forward ? LastSectionIndex : sectionNodes.size() - 1;
never executed: return forward ? LastSectionIndex : sectionNodes.size() - 1;
0
995-
996 updateCache(value, text);-
997 for (int i=0; i<sectionNodes.size()
i<sectionNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
998 const int tmp = sectionPos(sectionNodes.at(i));-
999 if (pos < tmp + sectionSize(i)
pos < tmp + sectionSize(i)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1000 if (pos < tmp
pos < tmpDescription
TRUEnever evaluated
FALSEnever evaluated
&& !forward
!forwardDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1001 return
never executed: return i-1;
i-1;
never executed: return i-1;
0
1002 }-
1003 return
never executed: return i;
i;
never executed: return i;
0
1004 } else if (i == sectionNodes.size() - 1
i == sectionNodes.size() - 1Description
TRUEnever evaluated
FALSEnever evaluated
&& pos > tmp
pos > tmpDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1005 return
never executed: return i;
i;
never executed: return i;
0
1006 }-
1007 }
never executed: end of block
0
1008 QMessageLogger(__FILE__, 1825, __PRETTY_FUNCTION__).warning("QDateTimeEdit: Internal Error: closestSection returned NoSection");-
1009 return
never executed: return NoSectionIndex;
NoSectionIndex;
never executed: return NoSectionIndex;
0
1010}-
1011-
1012-
1013-
1014-
1015-
1016-
1017-
1018int QDateTimeEditPrivate::nextPrevSection(int current, bool forward) const-
1019{-
1020 const QDateTimeEdit * const q = q_func();-
1021 if (q->isRightToLeft()
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1022 forward = !forward;
never executed: forward = !forward;
0
1023-
1024 switch (current) {-
1025 case
never executed: case FirstSectionIndex:
FirstSectionIndex:
never executed: case FirstSectionIndex:
return
never executed: return forward ? 0 : FirstSectionIndex;
forward ? 0 : FirstSectionIndex;
never executed: return forward ? 0 : FirstSectionIndex;
0
1026 case
never executed: case LastSectionIndex:
LastSectionIndex:
never executed: case LastSectionIndex:
return
never executed: return (forward ? LastSectionIndex : sectionNodes.size() - 1);
(forward ? LastSectionIndex : sectionNodes.size() - 1);
never executed: return (forward ? LastSectionIndex : sectionNodes.size() - 1);
0
1027 case
never executed: case NoSectionIndex:
NoSectionIndex:
never executed: case NoSectionIndex:
return
never executed: return FirstSectionIndex;
FirstSectionIndex;
never executed: return FirstSectionIndex;
0
1028 default
never executed: default:
:
never executed: default:
break;
never executed: break;
0
1029 }-
1030 ((!(current >= 0 && current < sectionNodes.size())) ? qt_assert("current >= 0 && current < sectionNodes.size()",__FILE__,1847) : qt_noop());-
1031-
1032 current += (forward
forwardDescription
TRUEnever evaluated
FALSEnever evaluated
? 1 : -1);
0
1033 if (current >= sectionNodes.size()
current >= sectionNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1034 return
never executed: return LastSectionIndex;
LastSectionIndex;
never executed: return LastSectionIndex;
0
1035 } else if (current < 0
current < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1036 return
never executed: return FirstSectionIndex;
FirstSectionIndex;
never executed: return FirstSectionIndex;
0
1037 }-
1038-
1039 return
never executed: return current;
current;
never executed: return current;
0
1040}-
1041-
1042-
1043-
1044-
1045-
1046-
1047-
1048void QDateTimeEditPrivate::clearSection(int index)-
1049{-
1050 const QLatin1Char space(' ');-
1051 int cursorPos = edit->cursorPosition();-
1052 const QSignalBlocker blocker(edit);-
1053 QString t = edit->text();-
1054 const int pos = sectionPos(index);-
1055 if (__builtin_expect(!!(pos == -1), false)
__builtin_expe...== -1), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1056 QMessageLogger(__FILE__, 1873, __PRETTY_FUNCTION__).warning("QDateTimeEdit: Internal error (%s:%d)", __FILE__, 1873);-
1057 return;
never executed: return;
0
1058 }-
1059 const int size = sectionSize(index);-
1060 t.replace(pos, size, QString().fill(space, size));-
1061 edit->setText(t);-
1062 edit->setCursorPosition(cursorPos);-
1063 if (false) QMessageLogger(__FILE__, 1880, __PRETTY_FUNCTION__).debug() << cursorPos;
dead code: QMessageLogger(__FILE__, 1880, __PRETTY_FUNCTION__).debug() << cursorPos;
-
1064}
never executed: end of block
0
1065void QDateTimeEditPrivate::updateCache(const QVariant &val, const QString &str) const-
1066{-
1067 if (val != cachedValue
val != cachedValueDescription
TRUEnever evaluated
FALSEnever evaluated
|| str != cachedText
str != cachedTextDescription
TRUEnever evaluated
FALSEnever evaluated
|| cacheGuard
cacheGuardDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1068 cacheGuard = true;-
1069 QString copy = str;-
1070 int unused = edit->cursorPosition();-
1071 QValidator::State unusedState;-
1072 validateAndInterpret(copy, unused, unusedState);-
1073 cacheGuard = false;-
1074 }
never executed: end of block
0
1075}
never executed: end of block
0
1076-
1077-
1078-
1079-
1080-
1081-
1082-
1083QDateTime QDateTimeEditPrivate::validateAndInterpret(QString &input, int &position,-
1084 QValidator::State &state, bool fixup) const-
1085{-
1086 if (input.isEmpty()
input.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1087 if (sectionNodes.size() == 1
sectionNodes.size() == 1Description
TRUEnever evaluated
FALSEnever evaluated
|| !specialValueText.isEmpty()
!specialValueText.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1088 state = QValidator::Intermediate;-
1089 }
never executed: end of block
else {
0
1090 state = QValidator::Invalid;-
1091 }
never executed: end of block
0
1092 return
never executed: return getZeroVariant().toDateTime();
getZeroVariant().toDateTime();
never executed: return getZeroVariant().toDateTime();
0
1093 } else if (cachedText == input
cachedText == inputDescription
TRUEnever evaluated
FALSEnever evaluated
&& !fixup
!fixupDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1094 state = cachedState;-
1095 return
never executed: return cachedValue.toDateTime();
cachedValue.toDateTime();
never executed: return cachedValue.toDateTime();
0
1096 } else if (!specialValueText.isEmpty()
!specialValueText.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1097 bool changeCase = false;-
1098 const int max = qMin(specialValueText.size(), input.size());-
1099 int i;-
1100 for (i=0; i<max
i<maxDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1101 const QChar ic = input.at(i);-
1102 const QChar sc = specialValueText.at(i);-
1103 if (ic != sc
ic != scDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1104 if (sc.toLower() == ic.toLower()
sc.toLower() == ic.toLower()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1105 changeCase = true;-
1106 }
never executed: end of block
else {
0
1107 break;
never executed: break;
0
1108 }-
1109 }-
1110 }
never executed: end of block
0
1111 if (i == max
i == maxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1112 state = specialValueText.size() == input.size()
specialValueTe...= input.size()Description
TRUEnever evaluated
FALSEnever evaluated
? QValidator::Acceptable : QValidator::Intermediate;
0
1113 if (changeCase
changeCaseDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1114 input = specialValueText.left(max);-
1115 }
never executed: end of block
0
1116 return
never executed: return minimum.toDateTime();
minimum.toDateTime();
never executed: return minimum.toDateTime();
0
1117 }-
1118 }
never executed: end of block
0
1119 StateNode tmp = parse(input, position, value.toDateTime(), fixup);-
1120 input = tmp.input;-
1121 state = QValidator::State(int(tmp.state));-
1122 if (state == QValidator::Acceptable
state == QVali...or::AcceptableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1123 if (tmp.conflicts
tmp.conflictsDescription
TRUEnever evaluated
FALSEnever evaluated
&& conflictGuard != tmp.value
conflictGuard != tmp.valueDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1124 conflictGuard = tmp.value;-
1125 clearCache();-
1126 input = textFromValue(tmp.value);-
1127 updateCache(tmp.value, input);-
1128 conflictGuard.clear();-
1129 }
never executed: end of block
else {
0
1130 cachedText = input;-
1131 cachedState = state;-
1132 cachedValue = tmp.value;-
1133 }
never executed: end of block
0
1134 } else {-
1135 clearCache();-
1136 }
never executed: end of block
0
1137 return
never executed: return (tmp.value.isNull() ? getZeroVariant().toDateTime() : tmp.value);
(tmp.value.isNull() ? getZeroVariant().toDateTime() : tmp.value);
never executed: return (tmp.value.isNull() ? getZeroVariant().toDateTime() : tmp.value);
0
1138}-
1139-
1140-
1141-
1142-
1143-
1144-
1145QString QDateTimeEditPrivate::textFromValue(const QVariant &f) const-
1146{-
1147 const QDateTimeEdit * const q = q_func();-
1148 return
never executed: return q->textFromDateTime(f.toDateTime());
q->textFromDateTime(f.toDateTime());
never executed: return q->textFromDateTime(f.toDateTime());
0
1149}-
1150QVariant QDateTimeEditPrivate::valueFromText(const QString &f) const-
1151{-
1152 const QDateTimeEdit * const q = q_func();-
1153 return
never executed: return q->dateTimeFromText(f).toTimeSpec(spec);
q->dateTimeFromText(f).toTimeSpec(spec);
never executed: return q->dateTimeFromText(f).toTimeSpec(spec);
0
1154}-
1155QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) const-
1156{-
1157 const QDateTimeEdit * const q = q_func();-
1158 QDateTime v = value.toDateTime();-
1159 QString str = displayText();-
1160 int pos = edit->cursorPosition();-
1161 const SectionNode sn = sectionNode(sectionIndex);-
1162-
1163 int val;-
1164-
1165 if (!test
!testDescription
TRUEnever evaluated
FALSEnever evaluated
&& pendingEmit
pendingEmitDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1166 if (q->validate(str, pos) != QValidator::Acceptable
q->validate(st...or::AcceptableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1167 v = value.toDateTime();-
1168 }
never executed: end of block
else {
0
1169 v = q->dateTimeFromText(str);-
1170 }
never executed: end of block
0
1171 val = getDigit(v, sectionIndex);-
1172 }
never executed: end of block
else {
0
1173 val = getDigit(v, sectionIndex);-
1174 }
never executed: end of block
0
1175-
1176 val += steps;-
1177-
1178 const int min = absoluteMin(sectionIndex);-
1179 const int max = absoluteMax(sectionIndex, value.toDateTime());-
1180-
1181 if (val < min
val < minDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1182 val = (wrapping
wrappingDescription
TRUEnever evaluated
FALSEnever evaluated
? max - (min - val) + 1 : min);
0
1183 }
never executed: end of block
else if (val > max
val > maxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1184 val = (wrapping
wrappingDescription
TRUEnever evaluated
FALSEnever evaluated
? min + val - max - 1 : max);
0
1185 }
never executed: end of block
0
1186-
1187-
1188 const int oldDay = v.date().day();-
1189-
1190 setDigit(v, sectionIndex, val);-
1191-
1192-
1193-
1194 const QDateTime minimumDateTime = minimum.toDateTime();-
1195 const QDateTime maximumDateTime = maximum.toDateTime();-
1196-
1197 if (sn.type != AmPmSection
sn.type != AmPmSectionDescription
TRUEnever evaluated
FALSEnever evaluated
&& (v < minimumDateTime
v < minimumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
|| v > maximumDateTime
v > maximumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
1198 const int localmin = getDigit(minimumDateTime, sectionIndex);-
1199 const int localmax = getDigit(maximumDateTime, sectionIndex);-
1200-
1201 if (wrapping
wrappingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1202-
1203-
1204 if (steps > 0
steps > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1205 setDigit(v, sectionIndex, min);-
1206 if (!(sn.type & DaySectionMask)
!(sn.type & DaySectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
&& sections & DateSectionMask
sections & DateSectionMaskDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1207 const int daysInMonth = v.date().daysInMonth();-
1208 if (v.date().day() < oldDay
v.date().day() < oldDayDescription
TRUEnever evaluated
FALSEnever evaluated
&& v.date().day() < daysInMonth
v.date().day() < daysInMonthDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1209 const int adds = qMin(oldDay, daysInMonth);-
1210 v = v.addDays(adds - v.date().day());-
1211 }
never executed: end of block
0
1212 }
never executed: end of block
0
1213-
1214 if (v < minimumDateTime
v < minimumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1215 setDigit(v, sectionIndex, localmin);-
1216 if (v < minimumDateTime
v < minimumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1217 setDigit(v, sectionIndex, localmin + 1);
never executed: setDigit(v, sectionIndex, localmin + 1);
0
1218 }
never executed: end of block
0
1219 }
never executed: end of block
else {
0
1220 setDigit(v, sectionIndex, max);-
1221 if (!(sn.type & DaySectionMask)
!(sn.type & DaySectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
&& sections & DateSectionMask
sections & DateSectionMaskDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1222 const int daysInMonth = v.date().daysInMonth();-
1223 if (v.date().day() < oldDay
v.date().day() < oldDayDescription
TRUEnever evaluated
FALSEnever evaluated
&& v.date().day() < daysInMonth
v.date().day() < daysInMonthDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1224 const int adds = qMin(oldDay, daysInMonth);-
1225 v = v.addDays(adds - v.date().day());-
1226 }
never executed: end of block
0
1227 }
never executed: end of block
0
1228-
1229 if (v > maximumDateTime
v > maximumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1230 setDigit(v, sectionIndex, localmax);-
1231 if (v > maximumDateTime
v > maximumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1232 setDigit(v, sectionIndex, localmax - 1);
never executed: setDigit(v, sectionIndex, localmax - 1);
0
1233 }
never executed: end of block
0
1234 }
never executed: end of block
0
1235 } else {-
1236 setDigit(v, sectionIndex, (steps > 0 ? localmax : localmin));-
1237 }
never executed: end of block
0
1238 }-
1239 if (!test
!testDescription
TRUEnever evaluated
FALSEnever evaluated
&& oldDay != v.date().day()
oldDay != v.date().day()Description
TRUEnever evaluated
FALSEnever evaluated
&& !(sn.type & DaySectionMask)
!(sn.type & DaySectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1240-
1241 cachedDay = qMax<int>(oldDay, cachedDay);-
1242 }
never executed: end of block
0
1243-
1244 if (v < minimumDateTime
v < minimumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1245 if (wrapping
wrappingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1246 QDateTime t = v;-
1247 setDigit(t, sectionIndex, steps < 0 ? max : min);-
1248 bool mincmp = (t >= minimumDateTime);-
1249 bool maxcmp = (t <= maximumDateTime);-
1250 if (!mincmp
!mincmpDescription
TRUEnever evaluated
FALSEnever evaluated
|| !maxcmp
!maxcmpDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1251 setDigit(t, sectionIndex, getDigit(steps < 0-
1252 ? maximumDateTime-
1253 : minimumDateTime, sectionIndex));-
1254 mincmp = (t >= minimumDateTime);-
1255 maxcmp = (t <= maximumDateTime);-
1256 }
never executed: end of block
0
1257 if (mincmp
mincmpDescription
TRUEnever evaluated
FALSEnever evaluated
&& maxcmp
maxcmpDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1258 v = t;-
1259 }
never executed: end of block
0
1260 }
never executed: end of block
else {
0
1261 v = value.toDateTime();-
1262 }
never executed: end of block
0
1263 } else if (v > maximumDateTime
v > maximumDateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1264 if (wrapping
wrappingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1265 QDateTime t = v;-
1266 setDigit(t, sectionIndex, steps > 0 ? min : max);-
1267 bool mincmp = (t >= minimumDateTime);-
1268 bool maxcmp = (t <= maximumDateTime);-
1269 if (!mincmp
!mincmpDescription
TRUEnever evaluated
FALSEnever evaluated
|| !maxcmp
!maxcmpDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1270 setDigit(t, sectionIndex, getDigit(steps > 0 ?-
1271 minimumDateTime :-
1272 maximumDateTime, sectionIndex));-
1273 mincmp = (t >= minimumDateTime);-
1274 maxcmp = (t <= maximumDateTime);-
1275 }
never executed: end of block
0
1276 if (mincmp
mincmpDescription
TRUEnever evaluated
FALSEnever evaluated
&& maxcmp
maxcmpDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1277 v = t;-
1278 }
never executed: end of block
0
1279 }
never executed: end of block
else {
0
1280 v = value.toDateTime();-
1281 }
never executed: end of block
0
1282 }-
1283-
1284 const QDateTime ret = bound(v, value, steps).toDateTime().toTimeSpec(spec);-
1285 return
never executed: return ret;
ret;
never executed: return ret;
0
1286}-
1287-
1288-
1289-
1290-
1291-
1292void QDateTimeEditPrivate::emitSignals(EmitPolicy ep, const QVariant &old)-
1293{-
1294 QDateTimeEdit * const q = q_func();-
1295 if (ep == NeverEmit
ep == NeverEmitDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1296 return;
never executed: return;
0
1297 }-
1298 pendingEmit = false;-
1299-
1300 const bool dodate = value.toDate().isValid()
value.toDate().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(sections & DateSectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
sections & DateSectionMask)
(sections & DateSectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
;
0
1301 const bool datechanged = (ep == AlwaysEmit
ep == AlwaysEmitDescription
TRUEnever evaluated
FALSEnever evaluated
|| old.toDate() != value.toDate()
old.toDate() != value.toDate()Description
TRUEnever evaluated
FALSEnever evaluated
);
0
1302 const bool dotime = value.toTime().isValid()
value.toTime().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(sections & TimeSectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
sections & TimeSectionMask)
(sections & TimeSectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
;
0
1303 const bool timechanged = (ep == AlwaysEmit
ep == AlwaysEmitDescription
TRUEnever evaluated
FALSEnever evaluated
|| old.toTime() != value.toTime()
old.toTime() != value.toTime()Description
TRUEnever evaluated
FALSEnever evaluated
);
0
1304-
1305 updateCache(value, displayText());-
1306-
1307 syncCalendarWidget();-
1308 if (datechanged
datechangedDescription
TRUEnever evaluated
FALSEnever evaluated
|| timechanged
timechangedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1309 q->dateTimeChanged(value.toDateTime());
never executed: q->dateTimeChanged(value.toDateTime());
0
1310 if (dodate
dodateDescription
TRUEnever evaluated
FALSEnever evaluated
&& datechanged
datechangedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1311 q->dateChanged(value.toDate());
never executed: q->dateChanged(value.toDate());
0
1312 if (dotime
dotimeDescription
TRUEnever evaluated
FALSEnever evaluated
&& timechanged
timechangedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1313 q->timeChanged(value.toTime());
never executed: q->timeChanged(value.toTime());
0
1314-
1315}
never executed: end of block
0
1316-
1317-
1318-
1319-
1320-
1321void QDateTimeEditPrivate::_q_editorCursorPositionChanged(int oldpos, int newpos)-
1322{-
1323 if (ignoreCursorPositionChanged
ignoreCursorPositionChangedDescription
TRUEnever evaluated
FALSEnever evaluated
|| specialValue()
specialValue()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1324 return;
never executed: return;
0
1325 const QString oldText = displayText();-
1326 updateCache(value, oldText);-
1327-
1328 const bool allowChange = !edit->hasSelectedText();-
1329 const bool forward = oldpos <= newpos;-
1330 ignoreCursorPositionChanged = true;-
1331 int s = sectionAt(newpos);-
1332 if (s == NoSectionIndex
s == NoSectionIndexDescription
TRUEnever evaluated
FALSEnever evaluated
&& forward
forwardDescription
TRUEnever evaluated
FALSEnever evaluated
&& newpos > 0
newpos > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1333 s = sectionAt(newpos - 1);-
1334 }
never executed: end of block
0
1335-
1336 int c = newpos;-
1337-
1338 const int selstart = edit->selectionStart();-
1339 const int selSection = sectionAt(selstart);-
1340 const int l = selSection != -1
selSection != -1Description
TRUEnever evaluated
FALSEnever evaluated
? sectionSize(selSection) : 0;
0
1341-
1342 if (s == NoSectionIndex
s == NoSectionIndexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1343 if (l > 0
l > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& selstart == sectionPos(selSection)
selstart == se...os(selSection)Description
TRUEnever evaluated
FALSEnever evaluated
&& edit->selectedText().size() == l
edit->selected...().size() == lDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1344 s = selSection;-
1345 if (allowChange
allowChangeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1346 setSelected(selSection, true);
never executed: setSelected(selSection, true);
0
1347 c = -1;-
1348 }
never executed: end of block
else {
0
1349 int closest = closestSection(newpos, forward);-
1350 c = sectionPos(closest) + (forward
forwardDescription
TRUEnever evaluated
FALSEnever evaluated
? 0 : qMax<int>(0, sectionSize(closest)));
0
1351-
1352 if (allowChange
allowChangeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1353 edit->setCursorPosition(c);-
1354 if (false) QMessageLogger(__FILE__, 2199, __PRETTY_FUNCTION__).debug() << c;
dead code: QMessageLogger(__FILE__, 2199, __PRETTY_FUNCTION__).debug() << c;
-
1355 }
never executed: end of block
0
1356 s = closest;-
1357 }
never executed: end of block
0
1358 }-
1359-
1360 if (allowChange
allowChangeDescription
TRUEnever evaluated
FALSEnever evaluated
&& currentSectionIndex != s
currentSectionIndex != sDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1361 interpret(EmitIfChanged);-
1362 }
never executed: end of block
0
1363 if (c == -1
c == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1364 setSelected(s, true);-
1365 }
never executed: end of block
else if (!edit->hasSelectedText()
!edit->hasSelectedText()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1366 if (oldpos < newpos
oldpos < newposDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1367 edit->setCursorPosition(displayText().size() - (oldText.size() - c));-
1368 }
never executed: end of block
else {
0
1369 edit->setCursorPosition(c);-
1370 }
never executed: end of block
0
1371 }-
1372-
1373 if (false) QMessageLogger(__FILE__, 2218, __PRETTY_FUNCTION__).debug() << "currentSectionIndex is set to" << sectionNode(s).name()
dead code: QMessageLogger(__FILE__, 2218, __PRETTY_FUNCTION__).debug() << "currentSectionIndex is set to" << sectionNode(s).name() << oldpos << newpos << "was" << sectionNode(currentSectionIndex).name();
-
1374 << oldpos << newpos
dead code: QMessageLogger(__FILE__, 2218, __PRETTY_FUNCTION__).debug() << "currentSectionIndex is set to" << sectionNode(s).name() << oldpos << newpos << "was" << sectionNode(currentSectionIndex).name();
-
1375 << "was" << sectionNode(currentSectionIndex).name();
dead code: QMessageLogger(__FILE__, 2218, __PRETTY_FUNCTION__).debug() << "currentSectionIndex is set to" << sectionNode(s).name() << oldpos << newpos << "was" << sectionNode(currentSectionIndex).name();
-
1376-
1377 currentSectionIndex = s;-
1378 ((!(currentSectionIndex < sectionNodes.size())) ? qt_assert_x("QDateTimeEditPrivate::_q_editorCursorPositionChanged()", QString(QString::fromLatin1("Internal error (%1 %2)"). arg(currentSectionIndex). arg(sectionNodes.size())).toLocal8Bit().constData(),-
1379-
1380-
1381-
1382 __FILE__-
1383 ,-
1384-
1385-
1386-
1387 2227-
1388 ) : qt_noop())-
1389-
1390-
1391-
1392 ;-
1393-
1394 ignoreCursorPositionChanged = false;-
1395}
never executed: end of block
0
1396-
1397-
1398-
1399-
1400-
1401-
1402void QDateTimeEditPrivate::readLocaleSettings()-
1403{-
1404 const QLocale loc;-
1405 defaultTimeFormat = loc.timeFormat(QLocale::ShortFormat);-
1406 defaultDateFormat = loc.dateFormat(QLocale::ShortFormat);-
1407 defaultDateTimeFormat = loc.dateTimeFormat(QLocale::ShortFormat);-
1408}
never executed: end of block
0
1409-
1410QDateTimeEdit::Section QDateTimeEditPrivate::convertToPublic(QDateTimeParser::Section s)-
1411{-
1412 switch (s & ~Internal) {-
1413 case
never executed: case AmPmSection:
AmPmSection:
never executed: case AmPmSection:
return
never executed: return QDateTimeEdit::AmPmSection;
QDateTimeEdit::AmPmSection;
never executed: return QDateTimeEdit::AmPmSection;
0
1414 case
never executed: case MSecSection:
MSecSection:
never executed: case MSecSection:
return
never executed: return QDateTimeEdit::MSecSection;
QDateTimeEdit::MSecSection;
never executed: return QDateTimeEdit::MSecSection;
0
1415 case
never executed: case SecondSection:
SecondSection:
never executed: case SecondSection:
return
never executed: return QDateTimeEdit::SecondSection;
QDateTimeEdit::SecondSection;
never executed: return QDateTimeEdit::SecondSection;
0
1416 case
never executed: case MinuteSection:
MinuteSection:
never executed: case MinuteSection:
return
never executed: return QDateTimeEdit::MinuteSection;
QDateTimeEdit::MinuteSection;
never executed: return QDateTimeEdit::MinuteSection;
0
1417 case
never executed: case DayOfWeekSectionShort:
DayOfWeekSectionShort:
never executed: case DayOfWeekSectionShort:
0
1418 case
never executed: case DayOfWeekSectionLong:
DayOfWeekSectionLong:
never executed: case DayOfWeekSectionLong:
0
1419 case
never executed: case DaySection:
DaySection:
never executed: case DaySection:
return
never executed: return QDateTimeEdit::DaySection;
QDateTimeEdit::DaySection;
never executed: return QDateTimeEdit::DaySection;
0
1420 case
never executed: case MonthSection:
MonthSection:
never executed: case MonthSection:
return
never executed: return QDateTimeEdit::MonthSection;
QDateTimeEdit::MonthSection;
never executed: return QDateTimeEdit::MonthSection;
0
1421 case
never executed: case YearSection2Digits:
YearSection2Digits:
never executed: case YearSection2Digits:
0
1422 case
never executed: case YearSection:
YearSection:
never executed: case YearSection:
return
never executed: return QDateTimeEdit::YearSection;
QDateTimeEdit::YearSection;
never executed: return QDateTimeEdit::YearSection;
0
1423 case
never executed: case Hour12Section:
Hour12Section:
never executed: case Hour12Section:
0
1424 case
never executed: case Hour24Section:
Hour24Section:
never executed: case Hour24Section:
return
never executed: return QDateTimeEdit::HourSection;
QDateTimeEdit::HourSection;
never executed: return QDateTimeEdit::HourSection;
0
1425 case
never executed: case FirstSection:
FirstSection:
never executed: case FirstSection:
0
1426 case
never executed: case NoSection:
NoSection:
never executed: case NoSection:
0
1427 case
never executed: case LastSection:
LastSection:
never executed: case LastSection:
break;
never executed: break;
0
1428 }-
1429 return
never executed: return QDateTimeEdit::NoSection;
QDateTimeEdit::NoSection;
never executed: return QDateTimeEdit::NoSection;
0
1430}-
1431-
1432QDateTimeEdit::Sections QDateTimeEditPrivate::convertSections(QDateTimeParser::Sections s)-
1433{-
1434 QDateTimeEdit::Sections ret = 0;-
1435 if (s & QDateTimeParser::MSecSection
s & QDateTimeP...r::MSecSectionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1436 ret |= QDateTimeEdit::MSecSection;
never executed: ret |= QDateTimeEdit::MSecSection;
0
1437 if (s & QDateTimeParser::SecondSection
s & QDateTimeP...:SecondSectionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1438 ret |= QDateTimeEdit::SecondSection;
never executed: ret |= QDateTimeEdit::SecondSection;
0
1439 if (s & QDateTimeParser::MinuteSection
s & QDateTimeP...:MinuteSectionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1440 ret |= QDateTimeEdit::MinuteSection;
never executed: ret |= QDateTimeEdit::MinuteSection;
0
1441 if (s & (QDateTimeParser::HourSectionMask)
s & (QDateTime...urSectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1442 ret |= QDateTimeEdit::HourSection;
never executed: ret |= QDateTimeEdit::HourSection;
0
1443 if (s & QDateTimeParser::AmPmSection
s & QDateTimeP...r::AmPmSectionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1444 ret |= QDateTimeEdit::AmPmSection;
never executed: ret |= QDateTimeEdit::AmPmSection;
0
1445 if (s & (QDateTimeParser::DaySectionMask)
s & (QDateTime...aySectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1446 ret |= QDateTimeEdit::DaySection;
never executed: ret |= QDateTimeEdit::DaySection;
0
1447 if (s & QDateTimeParser::MonthSection
s & QDateTimeP...::MonthSectionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1448 ret |= QDateTimeEdit::MonthSection;
never executed: ret |= QDateTimeEdit::MonthSection;
0
1449 if (s & (QDateTimeParser::YearSectionMask)
s & (QDateTime...arSectionMask)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1450 ret |= QDateTimeEdit::YearSection;
never executed: ret |= QDateTimeEdit::YearSection;
0
1451-
1452 return
never executed: return ret;
ret;
never executed: return ret;
0
1453}-
1454-
1455-
1456-
1457-
1458-
1459void QDateTimeEdit::paintEvent(QPaintEvent *event)-
1460{-
1461 QDateTimeEditPrivate * const d = d_func();-
1462 if (!d->calendarPopupEnabled()
!d->calendarPopupEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1463 QAbstractSpinBox::paintEvent(event);-
1464 return;
never executed: return;
0
1465 }-
1466-
1467 QStyleOptionSpinBox opt;-
1468 initStyleOption(&opt);-
1469-
1470 QStyleOptionComboBox optCombo;-
1471-
1472 optCombo.init(this);-
1473 optCombo.editable = true;-
1474 optCombo.frame = opt.frame;-
1475 optCombo.subControls = opt.subControls;-
1476 optCombo.activeSubControls = opt.activeSubControls;-
1477 optCombo.state = opt.state;-
1478 if (d->readOnly
d->readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1479 optCombo.state &= ~QStyle::State_Enabled;-
1480 }
never executed: end of block
0
1481-
1482 QPainter p(this);-
1483 style()->drawComplexControl(QStyle::CC_ComboBox, &optCombo, &p, this);-
1484}
never executed: end of block
0
1485-
1486QString QDateTimeEditPrivate::getAmPmText(AmPm ap, Case cs) const-
1487{-
1488 if (ap == AmText
ap == AmTextDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1489 return
never executed: return (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am"));
(cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am"));
never executed: return (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am"));
0
1490 } else {-
1491 return
never executed: return (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm"));
(cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm"));
never executed: return (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm"));
0
1492 }-
1493}-
1494-
1495int QDateTimeEditPrivate::absoluteIndex(QDateTimeEdit::Section s, int index) const-
1496{-
1497 for (int i=0; i<sectionNodes.size()
i<sectionNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1498 if (convertToPublic(sectionNodes.at(i).type) == s
convertToPubli...(i).type) == sDescription
TRUEnever evaluated
FALSEnever evaluated
&& index-- == 0
index-- == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1499 return
never executed: return i;
i;
never executed: return i;
0
1500 }-
1501 }
never executed: end of block
0
1502 return
never executed: return NoSectionIndex;
NoSectionIndex;
never executed: return NoSectionIndex;
0
1503}-
1504-
1505int QDateTimeEditPrivate::absoluteIndex(const SectionNode &s) const-
1506{-
1507 return
never executed: return sectionNodes.indexOf(s);
sectionNodes.indexOf(s);
never executed: return sectionNodes.indexOf(s);
0
1508}-
1509-
1510void QDateTimeEditPrivate::interpret(EmitPolicy ep)-
1511{-
1512 QDateTimeEdit * const q = q_func();-
1513 QString tmp = displayText();-
1514 int pos = edit->cursorPosition();-
1515 const QValidator::State state = q->validate(tmp, pos);-
1516 if (state != QValidator::Acceptable
state != QVali...or::AcceptableDescription
TRUEnever evaluated
FALSEnever evaluated
0
1517 && correctionMode == QAbstractSpinBox::CorrectToPreviousValue
correctionMode...oPreviousValueDescription
TRUEnever evaluated
FALSEnever evaluated
0
1518 && (state == QValidator::Invalid
state == QValidator::InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
0
1519 || currentSectionIndex < 0
currentSectionIndex < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1520 || !(fieldInfo(currentSectionIndex) & AllowPartial)
!(fieldInfo(cu... AllowPartial)Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
1521 setValue(value, ep);-
1522 updateTimeSpec();-
1523 }
never executed: end of block
else {
0
1524 QAbstractSpinBoxPrivate::interpret(ep);-
1525 }
never executed: end of block
0
1526}-
1527-
1528void QDateTimeEditPrivate::clearCache() const-
1529{-
1530 QAbstractSpinBoxPrivate::clearCache();-
1531 cachedDay = -1;-
1532}
never executed: end of block
0
1533void QDateTimeEdit::initStyleOption(QStyleOptionSpinBox *option) const-
1534{-
1535 if (!option
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1536 return;
never executed: return;
0
1537-
1538 const QDateTimeEditPrivate * const d = d_func();-
1539 QAbstractSpinBox::initStyleOption(option);-
1540 if (d->calendarPopupEnabled()
d->calendarPopupEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1541 option->subControls = QStyle::SC_ComboBoxFrame | QStyle::SC_ComboBoxEditField-
1542 | QStyle::SC_ComboBoxArrow;-
1543 if (d->arrowState == QStyle::State_Sunken
d->arrowState ...::State_SunkenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1544 option->state |= QStyle::State_Sunken;
never executed: option->state |= QStyle::State_Sunken;
0
1545 else-
1546 option->state &= ~QStyle::State_Sunken;
never executed: option->state &= ~QStyle::State_Sunken;
0
1547 }-
1548}
never executed: end of block
0
1549-
1550void QDateTimeEditPrivate::init(const QVariant &var)-
1551{-
1552 QDateTimeEdit * const q = q_func();-
1553 switch (var.type()) {-
1554 case
never executed: case QVariant::Date:
QVariant::Date:
never executed: case QVariant::Date:
0
1555 value = QDateTime(var.toDate(), QTime(0, 0, 0, 0));-
1556 updateTimeSpec();-
1557 q->setDisplayFormat(defaultDateFormat);-
1558 if (sectionNodes.isEmpty()
sectionNodes.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1559 q->setDisplayFormat(QLatin1String("dd/MM/yyyy"));
never executed: q->setDisplayFormat(QLatin1String("dd/MM/yyyy"));
0
1560 break;
never executed: break;
0
1561 case
never executed: case QVariant::DateTime:
QVariant::DateTime:
never executed: case QVariant::DateTime:
0
1562 value = var;-
1563 updateTimeSpec();-
1564 q->setDisplayFormat(defaultDateTimeFormat);-
1565 if (sectionNodes.isEmpty()
sectionNodes.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1566 q->setDisplayFormat(QLatin1String("dd/MM/yyyy hh:mm:ss"));
never executed: q->setDisplayFormat(QLatin1String("dd/MM/yyyy hh:mm:ss"));
0
1567 break;
never executed: break;
0
1568 case
never executed: case QVariant::Time:
QVariant::Time:
never executed: case QVariant::Time:
0
1569 value = QDateTime(QDate(2000, 1, 1), var.toTime());-
1570 updateTimeSpec();-
1571 q->setDisplayFormat(defaultTimeFormat);-
1572 if (sectionNodes.isEmpty()
sectionNodes.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1573 q->setDisplayFormat(QLatin1String("hh:mm:ss"));
never executed: q->setDisplayFormat(QLatin1String("hh:mm:ss"));
0
1574 break;
never executed: break;
0
1575 default
never executed: default:
:
never executed: default:
0
1576 ((!(0)) ? qt_assert_x("QDateTimeEditPrivate::init", "Internal error",__FILE__,2419) : qt_noop());-
1577 break;
never executed: break;
0
1578 }-
1579-
1580-
1581-
1582-
1583 q->setInputMethodHints(Qt::ImhPreferNumbers);-
1584 setLayoutItemMargins(QStyle::SE_DateTimeEditLayoutItem);-
1585}
never executed: end of block
0
1586-
1587void QDateTimeEditPrivate::_q_resetButton()-
1588{-
1589 updateArrow(QStyle::State_None);-
1590}
never executed: end of block
0
1591-
1592void QDateTimeEditPrivate::updateArrow(QStyle::StateFlag state)-
1593{-
1594 QDateTimeEdit * const q = q_func();-
1595-
1596 if (arrowState == state
arrowState == stateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1597 return;
never executed: return;
0
1598 arrowState = state;-
1599 if (arrowState != QStyle::State_None
arrowState != ...le::State_NoneDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1600 buttonState |= Mouse;
never executed: buttonState |= Mouse;
0
1601 else {-
1602 buttonState = 0;-
1603 hoverControl = QStyle::SC_ComboBoxFrame;-
1604 }
never executed: end of block
0
1605 q->update();-
1606}
never executed: end of block
0
1607-
1608-
1609-
1610-
1611-
1612-
1613QStyle::SubControl QDateTimeEditPrivate::newHoverControl(const QPoint &pos)-
1614{-
1615 if (!calendarPopupEnabled()
!calendarPopupEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1616 return
never executed: return QAbstractSpinBoxPrivate::newHoverControl(pos);
QAbstractSpinBoxPrivate::newHoverControl(pos);
never executed: return QAbstractSpinBoxPrivate::newHoverControl(pos);
0
1617-
1618 QDateTimeEdit * const q = q_func();-
1619-
1620 QStyleOptionComboBox optCombo;-
1621 optCombo.init(q);-
1622 optCombo.editable = true;-
1623 optCombo.subControls = QStyle::SC_All;-
1624 hoverControl = q->style()->hitTestComplexControl(QStyle::CC_ComboBox, &optCombo, pos, q);-
1625 return
never executed: return hoverControl;
hoverControl;
never executed: return hoverControl;
0
1626}-
1627-
1628void QDateTimeEditPrivate::updateEditFieldGeometry()-
1629{-
1630 if (!calendarPopupEnabled()
!calendarPopupEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1631 QAbstractSpinBoxPrivate::updateEditFieldGeometry();-
1632 return;
never executed: return;
0
1633 }-
1634-
1635 QDateTimeEdit * const q = q_func();-
1636-
1637 QStyleOptionComboBox optCombo;-
1638 optCombo.init(q);-
1639 optCombo.editable = true;-
1640 optCombo.subControls = QStyle::SC_ComboBoxEditField;-
1641 edit->setGeometry(q->style()->subControlRect(QStyle::CC_ComboBox, &optCombo,-
1642 QStyle::SC_ComboBoxEditField, q));-
1643}
never executed: end of block
0
1644-
1645QVariant QDateTimeEditPrivate::getZeroVariant() const-
1646{-
1647 ((!(type == QVariant::DateTime)) ? qt_assert("type == QVariant::DateTime",__FILE__,2490) : qt_noop());-
1648 return
never executed: return QDateTime(QDate(2000, 1, 1), QTime(), spec);
QDateTime(QDate(2000, 1, 1), QTime(), spec);
never executed: return QDateTime(QDate(2000, 1, 1), QTime(), spec);
0
1649}-
1650-
1651void QDateTimeEditPrivate::setRange(const QVariant &min, const QVariant &max)-
1652{-
1653 QAbstractSpinBoxPrivate::setRange(min, max);-
1654 syncCalendarWidget();-
1655}
never executed: end of block
0
1656-
1657-
1658bool QDateTimeEditPrivate::isSeparatorKey(const QKeyEvent *ke) const-
1659{-
1660 if (!ke->text().isEmpty()
!ke->text().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& currentSectionIndex + 1 < sectionNodes.size()
currentSection...onNodes.size()Description
TRUEnever evaluated
FALSEnever evaluated
&& currentSectionIndex >= 0
currentSectionIndex >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1661 if (fieldInfo(currentSectionIndex) & Numeric
fieldInfo(curr...dex) & NumericDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1662 if (ke->text().at(0).isNumber()
ke->text().at(0).isNumber()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1663 return
never executed: return false;
false;
never executed: return false;
0
1664 }
never executed: end of block
else if (ke->text().at(0).isLetterOrNumber()
ke->text().at(...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1665 return
never executed: return false;
false;
never executed: return false;
0
1666 }-
1667 return
never executed: return separators.at(currentSectionIndex + 1).contains(ke->text());
separators.at(currentSectionIndex + 1).contains(ke->text());
never executed: return separators.at(currentSectionIndex + 1).contains(ke->text());
0
1668 }-
1669 return
never executed: return false;
false;
never executed: return false;
0
1670}-
1671-
1672void QDateTimeEditPrivate::initCalendarPopup(QCalendarWidget *cw)-
1673{-
1674 QDateTimeEdit * const q = q_func();-
1675 if (!monthCalendar
!monthCalendarDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1676 monthCalendar = new QCalendarPopup(q, cw);-
1677 monthCalendar->setObjectName(QLatin1String("qt_datetimedit_calendar"));-
1678 QObject::connect(monthCalendar, qFlagLocation("2""newDateSelected(QDate)" "\0" __FILE__ ":" "2521"), q, qFlagLocation("1""setDate(QDate)" "\0" __FILE__ ":" "2521"));-
1679 QObject::connect(monthCalendar, qFlagLocation("2""hidingCalendar(QDate)" "\0" __FILE__ ":" "2522"), q, qFlagLocation("1""setDate(QDate)" "\0" __FILE__ ":" "2522"));-
1680 QObject::connect(monthCalendar, qFlagLocation("2""activated(QDate)" "\0" __FILE__ ":" "2523"), q, qFlagLocation("1""setDate(QDate)" "\0" __FILE__ ":" "2523"));-
1681 QObject::connect(monthCalendar, qFlagLocation("2""activated(QDate)" "\0" __FILE__ ":" "2524"), monthCalendar, qFlagLocation("1""close()" "\0" __FILE__ ":" "2524"));-
1682 QObject::connect(monthCalendar, qFlagLocation("2""resetButton()" "\0" __FILE__ ":" "2525"), q, qFlagLocation("1""_q_resetButton()" "\0" __FILE__ ":" "2525"));-
1683 }
never executed: end of block
else if (cw
cwDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1684 monthCalendar->setCalendarWidget(cw);-
1685 }
never executed: end of block
0
1686 syncCalendarWidget();-
1687}
never executed: end of block
0
1688-
1689void QDateTimeEditPrivate::positionCalendarPopup()-
1690{-
1691 QDateTimeEdit * const q = q_func();-
1692 QPoint pos = (
(q->layoutDire...::RightToLeft)Description
TRUEnever evaluated
FALSEnever evaluated
q->layoutDirection() == Qt::RightToLeft)
(q->layoutDire...::RightToLeft)Description
TRUEnever evaluated
FALSEnever evaluated
? q->rect().bottomRight() : q->rect().bottomLeft();
0
1693 QPoint pos2 = (
(q->layoutDire...::RightToLeft)Description
TRUEnever evaluated
FALSEnever evaluated
q->layoutDirection() == Qt::RightToLeft)
(q->layoutDire...::RightToLeft)Description
TRUEnever evaluated
FALSEnever evaluated
? q->rect().topRight() : q->rect().topLeft();
0
1694 pos = q->mapToGlobal(pos);-
1695 pos2 = q->mapToGlobal(pos2);-
1696 QSize size = monthCalendar->sizeHint();-
1697 QRect screen = QApplication::desktop()->availableGeometry(pos);-
1698-
1699 if (q->layoutDirection() == Qt::RightToLeft
q->layoutDirec...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1700 pos.setX(pos.x()-size.width());-
1701 pos2.setX(pos2.x()-size.width());-
1702 if (pos.x() < screen.left()
pos.x() < screen.left()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1703 pos.setX(qMax(pos.x(), screen.left()));
never executed: pos.setX(qMax(pos.x(), screen.left()));
0
1704 else if (pos.x()+size.width() > screen.right()
pos.x()+size.w...screen.right()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1705 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
1706 }
never executed: end of block
else {
0
1707 if (pos.x()+size.width() > screen.right()
pos.x()+size.w...screen.right()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1708 pos.setX(screen.right()-size.width());
never executed: pos.setX(screen.right()-size.width());
0
1709 pos.setX(qMax(pos.x(), screen.left()));-
1710 }
never executed: end of block
0
1711 if (pos.y() + size.height() > screen.bottom()
pos.y() + size...creen.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1712 pos.setY(pos2.y() - size.height());
never executed: pos.setY(pos2.y() - size.height());
0
1713 else if (pos.y() < screen.top()
pos.y() < screen.top()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1714 pos.setY(screen.top());
never executed: pos.setY(screen.top());
0
1715 if (pos.y() < screen.top()
pos.y() < screen.top()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1716 pos.setY(screen.top());
never executed: pos.setY(screen.top());
0
1717 if (pos.y()+size.height() > screen.bottom()
pos.y()+size.h...creen.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1718 pos.setY(screen.bottom()-size.height());
never executed: pos.setY(screen.bottom()-size.height());
0
1719 monthCalendar->move(pos);-
1720}
never executed: end of block
0
1721-
1722bool QDateTimeEditPrivate::calendarPopupEnabled() const-
1723{-
1724 return
never executed: return (calendarPopup && (sections & (DateSectionMask)));
(calendarPopup && (sections & (DateSectionMask)));
never executed: return (calendarPopup && (sections & (DateSectionMask)));
0
1725}-
1726-
1727void QDateTimeEditPrivate::syncCalendarWidget()-
1728{-
1729 QDateTimeEdit * const q = q_func();-
1730 if (monthCalendar
monthCalendarDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1731 const QSignalBlocker blocker(monthCalendar);-
1732 monthCalendar->setDateRange(q->minimumDate(), q->maximumDate());-
1733 monthCalendar->setDate(q->date());-
1734 }
never executed: end of block
0
1735}
never executed: end of block
0
1736-
1737QCalendarPopup::QCalendarPopup(QWidget * parent, QCalendarWidget *cw)-
1738 : QWidget(parent, Qt::Popup)-
1739{-
1740 setAttribute(Qt::WA_WindowPropagation);-
1741-
1742 dateChanged = false;-
1743 if (!cw
!cwDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1744 verifyCalendarInstance();-
1745 }
never executed: end of block
else {
0
1746 setCalendarWidget(cw);-
1747 }
never executed: end of block
0
1748}-
1749-
1750QCalendarWidget *QCalendarPopup::verifyCalendarInstance()-
1751{-
1752 if (calendar.isNull()
calendar.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1753 QCalendarWidget *cw = new QCalendarWidget(this);-
1754 cw->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);-
1755-
1756-
1757-
1758-
1759 setCalendarWidget(cw);-
1760 return
never executed: return cw;
cw;
never executed: return cw;
0
1761 } else {-
1762 return
never executed: return calendar.data();
calendar.data();
never executed: return calendar.data();
0
1763 }-
1764}-
1765-
1766void QCalendarPopup::setCalendarWidget(QCalendarWidget *cw)-
1767{-
1768 ((!(cw)) ? qt_assert("cw",__FILE__,2611) : qt_noop());-
1769 QVBoxLayout *widgetLayout = qobject_cast<QVBoxLayout*>(layout());-
1770 if (!widgetLayout
!widgetLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1771 widgetLayout = new QVBoxLayout(this);-
1772 widgetLayout->setMargin(0);-
1773 widgetLayout->setSpacing(0);-
1774 }
never executed: end of block
0
1775 delete calendar.data();-
1776 calendar = QPointer<QCalendarWidget>(cw);-
1777 widgetLayout->addWidget(cw);-
1778-
1779 connect(cw, qFlagLocation("2""activated(QDate)" "\0" __FILE__ ":" "2622"), this, qFlagLocation("1""dateSelected(QDate)" "\0" __FILE__ ":" "2622"));-
1780 connect(cw, qFlagLocation("2""clicked(QDate)" "\0" __FILE__ ":" "2623"), this, qFlagLocation("1""dateSelected(QDate)" "\0" __FILE__ ":" "2623"));-
1781 connect(cw, qFlagLocation("2""selectionChanged()" "\0" __FILE__ ":" "2624"), this, qFlagLocation("1""dateSelectionChanged()" "\0" __FILE__ ":" "2624"));-
1782-
1783 cw->setFocus();-
1784}
never executed: end of block
0
1785-
1786-
1787void QCalendarPopup::setDate(const QDate &date)-
1788{-
1789 oldDate = date;-
1790 verifyCalendarInstance()->setSelectedDate(date);-
1791}
never executed: end of block
0
1792-
1793void QCalendarPopup::setDateRange(const QDate &min, const QDate &max)-
1794{-
1795 QCalendarWidget *cw = verifyCalendarInstance();-
1796 cw->setMinimumDate(min);-
1797 cw->setMaximumDate(max);-
1798}
never executed: end of block
0
1799-
1800void QCalendarPopup::mousePressEvent(QMouseEvent *event)-
1801{-
1802 QDateTimeEdit *dateTime = qobject_cast<QDateTimeEdit *>(parentWidget());-
1803 if (dateTime
dateTimeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1804 QStyleOptionComboBox opt;-
1805 opt.init(dateTime);-
1806 QRect arrowRect = dateTime->style()->subControlRect(QStyle::CC_ComboBox, &opt,-
1807 QStyle::SC_ComboBoxArrow, dateTime);-
1808 arrowRect.moveTo(dateTime->mapToGlobal(arrowRect .topLeft()));-
1809 if (arrowRect.contains(event->globalPos())
arrowRect.cont...->globalPos())Description
TRUEnever evaluated
FALSEnever evaluated
|| rect().contains(event->pos())
rect().contains(event->pos())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1810 setAttribute(Qt::WA_NoMouseReplay);
never executed: setAttribute(Qt::WA_NoMouseReplay);
0
1811 }
never executed: end of block
0
1812 QWidget::mousePressEvent(event);-
1813}
never executed: end of block
0
1814-
1815void QCalendarPopup::mouseReleaseEvent(QMouseEvent*)-
1816{-
1817 resetButton();-
1818}
never executed: end of block
0
1819-
1820bool QCalendarPopup::event(QEvent *event)-
1821{-
1822 if (event->type() == QEvent::KeyPress
event->type() ...vent::KeyPressDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1823 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);-
1824 if (keyEvent->matches(QKeySequence::Cancel)
keyEvent->matc...uence::Cancel)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1825 dateChanged = false;
never executed: dateChanged = false;
0
1826 }
never executed: end of block
0
1827 return
never executed: return QWidget::event(event);
QWidget::event(event);
never executed: return QWidget::event(event);
0
1828}-
1829-
1830void QCalendarPopup::dateSelectionChanged()-
1831{-
1832 dateChanged = true;-
1833 newDateSelected(verifyCalendarInstance()->selectedDate());-
1834}
never executed: end of block
0
1835void QCalendarPopup::dateSelected(const QDate &date)-
1836{-
1837 dateChanged = true;-
1838 activated(date);-
1839 close();-
1840}
never executed: end of block
0
1841-
1842void QCalendarPopup::hideEvent(QHideEvent *)-
1843{-
1844 resetButton();-
1845 if (!dateChanged
!dateChangedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1846 hidingCalendar(oldDate);
never executed: hidingCalendar(oldDate);
0
1847}
never executed: end of block
0
1848-
1849-
Switch to Source codePreprocessed file

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