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