widgets/qdatetimeedit.cpp

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

Generated by Squish Coco Non-Commercial