qcalendarwidget.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qcalendarwidget.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9enum {-
10 RowCount = 6,-
11 ColumnCount = 7,-
12 HeaderColumn = 0,-
13 HeaderRow = 0,-
14 MinimumDayOffset = 1-
15};-
16-
17namespace {-
18-
19static QString formatNumber(int number, int fieldWidth)-
20{-
21 return
never executed: return QString::number(number).rightJustified(fieldWidth, QLatin1Char('0'));
QString::number(number).rightJustified(fieldWidth, QLatin1Char('0'));
never executed: return QString::number(number).rightJustified(fieldWidth, QLatin1Char('0'));
0
22}-
23-
24class QCalendarDateSectionValidator-
25{-
26public:-
27-
28 enum Section {-
29 NextSection,-
30 ThisSection,-
31 PrevSection-
32 };-
33-
34 QCalendarDateSectionValidator() {}-
35 virtual ~QCalendarDateSectionValidator() {}-
36 virtual Section handleKey(int key) = 0;-
37 virtual QDate applyToDate(const QDate &date) const = 0;-
38 virtual void setDate(const QDate &date) = 0;-
39 virtual QString text() const = 0;-
40 virtual QString text(const QDate &date, int repeat) const = 0;-
41-
42 QLocale m_locale;-
43-
44protected:-
45 static QString highlightString(const QString &str, int pos);-
46private:-
47};-
48-
49QString QCalendarDateSectionValidator::highlightString(const QString &str, int pos)-
50{-
51 if (pos == 0
pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
52 return
never executed: return QLatin1String("<b>") + str + QLatin1String("</b>");
QLatin1String("<b>") + str + QLatin1String("</b>");
never executed: return QLatin1String("<b>") + str + QLatin1String("</b>");
0
53 int startPos = str.length() - pos;-
54 return
never executed: return str.midRef(0, startPos) + QLatin1String("<b>") + str.midRef(startPos, pos) + QLatin1String("</b>");
str.midRef(0, startPos) + QLatin1String("<b>") + str.midRef(startPos, pos) + QLatin1String("</b>");
never executed: return str.midRef(0, startPos) + QLatin1String("<b>") + str.midRef(startPos, pos) + QLatin1String("</b>");
0
55-
56}-
57-
58class QCalendarDayValidator : public QCalendarDateSectionValidator-
59{-
60-
61public:-
62 QCalendarDayValidator();-
63 virtual Section handleKey(int key) override;-
64 virtual QDate applyToDate(const QDate &date) const override;-
65 virtual void setDate(const QDate &date) override;-
66 virtual QString text() const override;-
67 virtual QString text(const QDate &date, int repeat) const override;-
68private:-
69 int m_pos;-
70 int m_day;-
71 int m_oldDay;-
72};-
73-
74QCalendarDayValidator::QCalendarDayValidator()-
75 : QCalendarDateSectionValidator(), m_pos(0), m_day(1), m_oldDay(1)-
76{-
77}
never executed: end of block
0
78-
79QCalendarDateSectionValidator::Section QCalendarDayValidator::handleKey(int key)-
80{-
81 if (key == Qt::Key_Right
key == Qt::Key_RightDescription
TRUEnever evaluated
FALSEnever evaluated
|| key == Qt::Key_Left
key == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
82 m_pos = 0;-
83 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
84 } else if (key == Qt::Key_Up
key == Qt::Key_UpDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
85 m_pos = 0;-
86 ++m_day;-
87 if (m_day > 31
m_day > 31Description
TRUEnever evaluated
FALSEnever evaluated
)
0
88 m_day = 1;
never executed: m_day = 1;
0
89 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
90 } else if (key == Qt::Key_Down
key == Qt::Key_DownDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
91 m_pos = 0;-
92 --m_day;-
93 if (m_day < 1
m_day < 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
94 m_day = 31;
never executed: m_day = 31;
0
95 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
96 } else if (key == Qt::Key_Back
key == Qt::Key_BackDescription
TRUEnever evaluated
FALSEnever evaluated
|| key == Qt::Key_Backspace
key == Qt::Key_BackspaceDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
97 --m_pos;-
98 if (m_pos < 0
m_pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
99 m_pos = 1;
never executed: m_pos = 1;
0
100-
101 if (m_pos == 0
m_pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
102 m_day = m_oldDay;
never executed: m_day = m_oldDay;
0
103 else-
104 m_day = m_day / 10;
never executed: m_day = m_day / 10;
0
105-
106-
107 if (m_pos == 0
m_pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
108 return
never executed: return QCalendarDateSectionValidator::PrevSection;
QCalendarDateSectionValidator::PrevSection;
never executed: return QCalendarDateSectionValidator::PrevSection;
0
109 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
110 }-
111 if (key < Qt::Key_0
key < Qt::Key_0Description
TRUEnever evaluated
FALSEnever evaluated
|| key > Qt::Key_9
key > Qt::Key_9Description
TRUEnever evaluated
FALSEnever evaluated
)
0
112 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
113 int pressedKey = key - Qt::Key_0;-
114 if (m_pos == 0
m_pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
115 m_day = pressedKey;
never executed: m_day = pressedKey;
0
116 else-
117 m_day = m_day % 10 * 10 + pressedKey;
never executed: m_day = m_day % 10 * 10 + pressedKey;
0
118 if (m_day > 31
m_day > 31Description
TRUEnever evaluated
FALSEnever evaluated
)
0
119 m_day = 31;
never executed: m_day = 31;
0
120 ++m_pos;-
121 if (m_pos > 1
m_pos > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
122 m_pos = 0;-
123 return
never executed: return QCalendarDateSectionValidator::NextSection;
QCalendarDateSectionValidator::NextSection;
never executed: return QCalendarDateSectionValidator::NextSection;
0
124 }-
125 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
126}-
127-
128QDate QCalendarDayValidator::applyToDate(const QDate &date) const-
129{-
130 int day = m_day;-
131 if (day < 1
day < 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
132 day = 1;
never executed: day = 1;
0
133 else if (day > 31
day > 31Description
TRUEnever evaluated
FALSEnever evaluated
)
0
134 day = 31;
never executed: day = 31;
0
135 if (day > date.daysInMonth()
day > date.daysInMonth()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
136 day = date.daysInMonth();
never executed: day = date.daysInMonth();
0
137 return
never executed: return QDate(date.year(), date.month(), day);
QDate(date.year(), date.month(), day);
never executed: return QDate(date.year(), date.month(), day);
0
138}-
139-
140void QCalendarDayValidator::setDate(const QDate &date)-
141{-
142 m_day = m_oldDay = date.day();-
143 m_pos = 0;-
144}
never executed: end of block
0
145-
146QString QCalendarDayValidator::text() const-
147{-
148 return
never executed: return highlightString(formatNumber(m_day, 2), m_pos);
highlightString(formatNumber(m_day, 2), m_pos);
never executed: return highlightString(formatNumber(m_day, 2), m_pos);
0
149}-
150-
151QString QCalendarDayValidator::text(const QDate &date, int repeat) const-
152{-
153 if (repeat <= 1
repeat <= 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
154 return
never executed: return QString::number(date.day());
QString::number(date.day());
never executed: return QString::number(date.day());
0
155 } else if (repeat == 2
repeat == 2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
156 return
never executed: return formatNumber(date.day(), 2);
formatNumber(date.day(), 2);
never executed: return formatNumber(date.day(), 2);
0
157 } else if (repeat == 3
repeat == 3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
158 return
never executed: return m_locale.dayName(date.dayOfWeek(), QLocale::ShortFormat);
m_locale.dayName(date.dayOfWeek(), QLocale::ShortFormat);
never executed: return m_locale.dayName(date.dayOfWeek(), QLocale::ShortFormat);
0
159 } else {-
160 return
never executed: return m_locale.dayName(date.dayOfWeek(), QLocale::LongFormat);
m_locale.dayName(date.dayOfWeek(), QLocale::LongFormat);
never executed: return m_locale.dayName(date.dayOfWeek(), QLocale::LongFormat);
0
161 }-
162}-
163-
164-
165-
166class QCalendarMonthValidator : public QCalendarDateSectionValidator-
167{-
168-
169public:-
170 QCalendarMonthValidator();-
171 virtual Section handleKey(int key) override;-
172 virtual QDate applyToDate(const QDate &date) const override;-
173 virtual void setDate(const QDate &date) override;-
174 virtual QString text() const override;-
175 virtual QString text(const QDate &date, int repeat) const override;-
176private:-
177 int m_pos;-
178 int m_month;-
179 int m_oldMonth;-
180};-
181-
182QCalendarMonthValidator::QCalendarMonthValidator()-
183 : QCalendarDateSectionValidator(), m_pos(0), m_month(1), m_oldMonth(1)-
184{-
185}
never executed: end of block
0
186-
187QCalendarDateSectionValidator::Section QCalendarMonthValidator::handleKey(int key)-
188{-
189 if (key == Qt::Key_Right
key == Qt::Key_RightDescription
TRUEnever evaluated
FALSEnever evaluated
|| key == Qt::Key_Left
key == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
190 m_pos = 0;-
191 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
192 } else if (key == Qt::Key_Up
key == Qt::Key_UpDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
193 m_pos = 0;-
194 ++m_month;-
195 if (m_month > 12
m_month > 12Description
TRUEnever evaluated
FALSEnever evaluated
)
0
196 m_month = 1;
never executed: m_month = 1;
0
197 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
198 } else if (key == Qt::Key_Down
key == Qt::Key_DownDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
199 m_pos = 0;-
200 --m_month;-
201 if (m_month < 1
m_month < 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
202 m_month = 12;
never executed: m_month = 12;
0
203 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
204 } else if (key == Qt::Key_Back
key == Qt::Key_BackDescription
TRUEnever evaluated
FALSEnever evaluated
|| key == Qt::Key_Backspace
key == Qt::Key_BackspaceDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
205 --m_pos;-
206 if (m_pos < 0
m_pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
207 m_pos = 1;
never executed: m_pos = 1;
0
208-
209 if (m_pos == 0
m_pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
210 m_month = m_oldMonth;
never executed: m_month = m_oldMonth;
0
211 else-
212 m_month = m_month / 10;
never executed: m_month = m_month / 10;
0
213-
214-
215 if (m_pos == 0
m_pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
216 return
never executed: return QCalendarDateSectionValidator::PrevSection;
QCalendarDateSectionValidator::PrevSection;
never executed: return QCalendarDateSectionValidator::PrevSection;
0
217 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
218 }-
219 if (key < Qt::Key_0
key < Qt::Key_0Description
TRUEnever evaluated
FALSEnever evaluated
|| key > Qt::Key_9
key > Qt::Key_9Description
TRUEnever evaluated
FALSEnever evaluated
)
0
220 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
221 int pressedKey = key - Qt::Key_0;-
222 if (m_pos == 0
m_pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
223 m_month = pressedKey;
never executed: m_month = pressedKey;
0
224 else-
225 m_month = m_month % 10 * 10 + pressedKey;
never executed: m_month = m_month % 10 * 10 + pressedKey;
0
226 if (m_month > 12
m_month > 12Description
TRUEnever evaluated
FALSEnever evaluated
)
0
227 m_month = 12;
never executed: m_month = 12;
0
228 ++m_pos;-
229 if (m_pos > 1
m_pos > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
230 m_pos = 0;-
231 return
never executed: return QCalendarDateSectionValidator::NextSection;
QCalendarDateSectionValidator::NextSection;
never executed: return QCalendarDateSectionValidator::NextSection;
0
232 }-
233 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
234}-
235-
236QDate QCalendarMonthValidator::applyToDate(const QDate &date) const-
237{-
238 int month = m_month;-
239 if (month < 1
month < 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
240 month = 1;
never executed: month = 1;
0
241 else if (month > 12
month > 12Description
TRUEnever evaluated
FALSEnever evaluated
)
0
242 month = 12;
never executed: month = 12;
0
243 QDate newDate(date.year(), m_month, 1);-
244 int day = date.day();-
245 if (day > newDate.daysInMonth()
day > newDate.daysInMonth()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
246 day = newDate.daysInMonth();
never executed: day = newDate.daysInMonth();
0
247 return
never executed: return QDate(date.year(), month, day);
QDate(date.year(), month, day);
never executed: return QDate(date.year(), month, day);
0
248}-
249-
250void QCalendarMonthValidator::setDate(const QDate &date)-
251{-
252 m_month = m_oldMonth = date.month();-
253 m_pos = 0;-
254}
never executed: end of block
0
255-
256QString QCalendarMonthValidator::text() const-
257{-
258 return
never executed: return highlightString(formatNumber(m_month, 2), m_pos);
highlightString(formatNumber(m_month, 2), m_pos);
never executed: return highlightString(formatNumber(m_month, 2), m_pos);
0
259}-
260-
261QString QCalendarMonthValidator::text(const QDate &date, int repeat) const-
262{-
263 if (repeat <= 1
repeat <= 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
264 return
never executed: return QString::number(date.month());
QString::number(date.month());
never executed: return QString::number(date.month());
0
265 } else if (repeat == 2
repeat == 2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
266 return
never executed: return formatNumber(date.month(), 2);
formatNumber(date.month(), 2);
never executed: return formatNumber(date.month(), 2);
0
267 } else if (repeat == 3
repeat == 3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
268 return
never executed: return m_locale.standaloneMonthName(date.month(), QLocale::ShortFormat);
m_locale.standaloneMonthName(date.month(), QLocale::ShortFormat);
never executed: return m_locale.standaloneMonthName(date.month(), QLocale::ShortFormat);
0
269 } else {-
270 return
never executed: return m_locale.standaloneMonthName(date.month(), QLocale::LongFormat);
m_locale.standaloneMonthName(date.month(), QLocale::LongFormat);
never executed: return m_locale.standaloneMonthName(date.month(), QLocale::LongFormat);
0
271 }-
272}-
273-
274-
275-
276class QCalendarYearValidator : public QCalendarDateSectionValidator-
277{-
278-
279public:-
280 QCalendarYearValidator();-
281 virtual Section handleKey(int key) override;-
282 virtual QDate applyToDate(const QDate &date) const override;-
283 virtual void setDate(const QDate &date) override;-
284 virtual QString text() const override;-
285 virtual QString text(const QDate &date, int repeat) const override;-
286private:-
287 int pow10(int n);-
288 int m_pos;-
289 int m_year;-
290 int m_oldYear;-
291};-
292-
293QCalendarYearValidator::QCalendarYearValidator()-
294 : QCalendarDateSectionValidator(), m_pos(0), m_year(2000), m_oldYear(2000)-
295{-
296}
never executed: end of block
0
297-
298int QCalendarYearValidator::pow10(int n)-
299{-
300 int power = 1;-
301 for (int i = 0; i < n
i < nDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
302 power *= 10;
never executed: power *= 10;
0
303 return
never executed: return power;
power;
never executed: return power;
0
304}-
305-
306QCalendarDateSectionValidator::Section QCalendarYearValidator::handleKey(int key)-
307{-
308 if (key == Qt::Key_Right
key == Qt::Key_RightDescription
TRUEnever evaluated
FALSEnever evaluated
|| key == Qt::Key_Left
key == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
309 m_pos = 0;-
310 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
311 } else if (key == Qt::Key_Up
key == Qt::Key_UpDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
312 m_pos = 0;-
313 ++m_year;-
314 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
315 } else if (key == Qt::Key_Down
key == Qt::Key_DownDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
316 m_pos = 0;-
317 --m_year;-
318 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
319 } else if (key == Qt::Key_Back
key == Qt::Key_BackDescription
TRUEnever evaluated
FALSEnever evaluated
|| key == Qt::Key_Backspace
key == Qt::Key_BackspaceDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
320 --m_pos;-
321 if (m_pos < 0
m_pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
322 m_pos = 3;
never executed: m_pos = 3;
0
323-
324 int pow = pow10(m_pos);-
325 m_year = m_oldYear / pow * pow + m_year % (pow * 10) / 10;-
326-
327 if (m_pos == 0
m_pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
328 return
never executed: return QCalendarDateSectionValidator::PrevSection;
QCalendarDateSectionValidator::PrevSection;
never executed: return QCalendarDateSectionValidator::PrevSection;
0
329 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
330 }-
331 if (key < Qt::Key_0
key < Qt::Key_0Description
TRUEnever evaluated
FALSEnever evaluated
|| key > Qt::Key_9
key > Qt::Key_9Description
TRUEnever evaluated
FALSEnever evaluated
)
0
332 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
333 int pressedKey = key - Qt::Key_0;-
334 int pow = pow10(m_pos);-
335 m_year = m_year / (pow * 10) * (pow * 10) + m_year % pow * 10 + pressedKey;-
336 ++m_pos;-
337 if (m_pos > 3
m_pos > 3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
338 m_pos = 0;-
339 return
never executed: return QCalendarDateSectionValidator::NextSection;
QCalendarDateSectionValidator::NextSection;
never executed: return QCalendarDateSectionValidator::NextSection;
0
340 }-
341 return
never executed: return QCalendarDateSectionValidator::ThisSection;
QCalendarDateSectionValidator::ThisSection;
never executed: return QCalendarDateSectionValidator::ThisSection;
0
342}-
343-
344QDate QCalendarYearValidator::applyToDate(const QDate &date) const-
345{-
346 int year = m_year;-
347 if (year < 1
year < 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
348 year = 1;
never executed: year = 1;
0
349 QDate newDate(year, date.month(), 1);-
350 int day = date.day();-
351 if (day > newDate.daysInMonth()
day > newDate.daysInMonth()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
352 day = newDate.daysInMonth();
never executed: day = newDate.daysInMonth();
0
353 return
never executed: return QDate(year, date.month(), day);
QDate(year, date.month(), day);
never executed: return QDate(year, date.month(), day);
0
354}-
355-
356void QCalendarYearValidator::setDate(const QDate &date)-
357{-
358 m_year = m_oldYear = date.year();-
359 m_pos = 0;-
360}
never executed: end of block
0
361-
362QString QCalendarYearValidator::text() const-
363{-
364 return
never executed: return highlightString(formatNumber(m_year, 4), m_pos);
highlightString(formatNumber(m_year, 4), m_pos);
never executed: return highlightString(formatNumber(m_year, 4), m_pos);
0
365}-
366-
367QString QCalendarYearValidator::text(const QDate &date, int repeat) const-
368{-
369 if (repeat < 4
repeat < 4Description
TRUEnever evaluated
FALSEnever evaluated
)
0
370 return
never executed: return formatNumber(date.year() % 100, 2);
formatNumber(date.year() % 100, 2);
never executed: return formatNumber(date.year() % 100, 2);
0
371 return
never executed: return QString::number(date.year());
QString::number(date.year());
never executed: return QString::number(date.year());
0
372}-
373-
374-
375-
376struct SectionToken {-
377 constexpr SectionToken(QCalendarDateSectionValidator *v, int rep)-
378 : validator(v), repeat(rep) {}-
379-
380 QCalendarDateSectionValidator *validator;-
381 int repeat;-
382};-
383}-
384template<> class QTypeInfo<SectionToken > { public: enum { isComplex = (((Q_PRIMITIVE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_PRIMITIVE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_PRIMITIVE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(SectionToken)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< SectionToken >::value, isDummy = (((Q_PRIMITIVE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(SectionToken) }; static inline const char *name() { return "SectionToken"; } };-
385namespace {-
386-
387class QCalendarDateValidator-
388{-
389public:-
390 QCalendarDateValidator();-
391 ~QCalendarDateValidator();-
392-
393 void handleKeyEvent(QKeyEvent *keyEvent);-
394 QString currentText() const;-
395 QDate currentDate() const { return
never executed: return m_currentDate;
m_currentDate;
never executed: return m_currentDate;
}
0
396 void setFormat(const QString &format);-
397 void setInitialDate(const QDate &date);-
398-
399 void setLocale(const QLocale &locale);-
400-
401private:-
402 void toNextToken();-
403 void toPreviousToken();-
404 void applyToDate();-
405-
406 int countRepeat(const QString &str, int index) const;-
407 void clear();-
408-
409 QStringList m_separators;-
410 std::vector<SectionToken> m_tokens;-
411 QCalendarYearValidator m_yearValidator;-
412 QCalendarMonthValidator m_monthValidator;-
413 QCalendarDayValidator m_dayValidator;-
414-
415 int m_currentToken;-
416-
417 QDate m_initialDate;-
418 QDate m_currentDate;-
419-
420 QCalendarDateSectionValidator::Section m_lastSectionMove;-
421};-
422-
423QCalendarDateValidator::QCalendarDateValidator()-
424 : m_currentToken(-1),-
425 m_initialDate(QDate::currentDate()),-
426 m_currentDate(m_initialDate),-
427 m_lastSectionMove(QCalendarDateSectionValidator::ThisSection)-
428{-
429}
never executed: end of block
0
430-
431void QCalendarDateValidator::setLocale(const QLocale &locale)-
432{-
433 m_yearValidator.m_locale = locale;-
434 m_monthValidator.m_locale = locale;-
435 m_dayValidator.m_locale = locale;-
436}
never executed: end of block
0
437-
438QCalendarDateValidator::~QCalendarDateValidator()-
439{-
440 clear();-
441}
never executed: end of block
0
442-
443-
444int QCalendarDateValidator::countRepeat(const QString &str, int index) const-
445{-
446 ((!(index >= 0 && index < str.size())) ? qt_assert("index >= 0 && index < str.size()",__FILE__,503) : qt_noop());-
447 int count = 1;-
448 const QChar ch = str.at(index);-
449 while (index + count < str.size()
index + count < str.size()Description
TRUEnever evaluated
FALSEnever evaluated
&& str.at(index + count) == ch
str.at(index + count) == chDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
450 ++
never executed: ++count;
count;
never executed: ++count;
0
451 return
never executed: return count;
count;
never executed: return count;
0
452}-
453-
454void QCalendarDateValidator::setInitialDate(const QDate &date)-
455{-
456 m_yearValidator.setDate(date);-
457 m_monthValidator.setDate(date);-
458 m_dayValidator.setDate(date);-
459 m_initialDate = date;-
460 m_currentDate = date;-
461 m_lastSectionMove = QCalendarDateSectionValidator::ThisSection;-
462}
never executed: end of block
0
463-
464QString QCalendarDateValidator::currentText() const-
465{-
466 QString str;-
467 const int numSeps = m_separators.size();-
468 const int numTokens = int(m_tokens.size());-
469 for (int i = 0; i < numSeps
i < numSepsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
470 str += m_separators.at(i);-
471 if (i < numTokens
i < numTokensDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
472 const SectionToken &token = m_tokens[i];-
473 if (i == m_currentToken
i == m_currentTokenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
474 str += token.validator->text();
never executed: str += token.validator->text();
0
475 else-
476 str += token.validator->text(m_currentDate, token.repeat);
never executed: str += token.validator->text(m_currentDate, token.repeat);
0
477 }-
478 }
never executed: end of block
0
479 return
never executed: return str;
str;
never executed: return str;
0
480}-
481-
482void QCalendarDateValidator::clear()-
483{-
484 m_tokens.clear();-
485 m_separators.clear();-
486-
487 m_currentToken = -1;-
488}
never executed: end of block
0
489-
490void QCalendarDateValidator::setFormat(const QString &format)-
491{-
492 clear();-
493-
494 int pos = 0;-
495 const QLatin1Char quote('\'');-
496 bool quoting = false;-
497 QString separator;-
498 while (pos < format.size()
pos < format.size()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
499 const QStringRef mid = format.midRef(pos);-
500 int offset = 1;-
501-
502 if (mid.startsWith(quote)
mid.startsWith(quote)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
503 quoting = !quoting;-
504 }
never executed: end of block
else {
0
505 const QChar nextChar = format.at(pos);-
506 if (quoting
quotingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
507 separator += nextChar;-
508 quoting = false;-
509 }
never executed: end of block
else {
0
510 QCalendarDateSectionValidator *validator = 0;-
511 if (nextChar == QLatin1Char('d')
nextChar == QLatin1Char('d')Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
512 offset = qMin(4, countRepeat(format, pos));-
513 validator = &m_dayValidator;-
514 }
never executed: end of block
else if (nextChar == QLatin1Char('M')
nextChar == QLatin1Char('M')Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
515 offset = qMin(4, countRepeat(format, pos));-
516 validator = &m_monthValidator;-
517 }
never executed: end of block
else if (nextChar == QLatin1Char('y')
nextChar == QLatin1Char('y')Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
518 offset = qMin(4, countRepeat(format, pos));-
519 validator = &m_yearValidator;-
520 }
never executed: end of block
else {
0
521 separator += nextChar;-
522 }
never executed: end of block
0
523 if (validator
validatorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
524 m_tokens.push_back(SectionToken(validator, offset));-
525 m_separators.append(separator);-
526 separator = QString();-
527 if (m_currentToken < 0
m_currentToken < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
528 m_currentToken = int(m_tokens.size()) - 1;
never executed: m_currentToken = int(m_tokens.size()) - 1;
0
529-
530 }
never executed: end of block
0
531 }
never executed: end of block
0
532 }-
533 pos += offset;-
534 }
never executed: end of block
0
535 m_separators += separator;-
536}
never executed: end of block
0
537-
538void QCalendarDateValidator::applyToDate()-
539{-
540 m_currentDate = m_yearValidator.applyToDate(m_currentDate);-
541 m_currentDate = m_monthValidator.applyToDate(m_currentDate);-
542 m_currentDate = m_dayValidator.applyToDate(m_currentDate);-
543}
never executed: end of block
0
544-
545void QCalendarDateValidator::toNextToken()-
546{-
547 if (m_currentToken < 0
m_currentToken < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
548 return;
never executed: return;
0
549 ++m_currentToken;-
550 m_currentToken %= m_tokens.size();-
551}
never executed: end of block
0
552-
553void QCalendarDateValidator::toPreviousToken()-
554{-
555 if (m_currentToken < 0
m_currentToken < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
556 return;
never executed: return;
0
557 --m_currentToken;-
558 m_currentToken %= m_tokens.size();-
559}
never executed: end of block
0
560-
561void QCalendarDateValidator::handleKeyEvent(QKeyEvent *keyEvent)-
562{-
563 if (m_currentToken < 0
m_currentToken < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
564 return;
never executed: return;
0
565-
566 int key = keyEvent->key();-
567 if (m_lastSectionMove == QCalendarDateSectionValidator::NextSection
m_lastSectionM...r::NextSectionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
568 if (key == Qt::Key_Back
key == Qt::Key_BackDescription
TRUEnever evaluated
FALSEnever evaluated
|| key == Qt::Key_Backspace
key == Qt::Key_BackspaceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
569 toPreviousToken();
never executed: toPreviousToken();
0
570 }
never executed: end of block
0
571 if (key == Qt::Key_Right
key == Qt::Key_RightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
572 toNextToken();
never executed: toNextToken();
0
573 else if (key == Qt::Key_Left
key == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
574 toPreviousToken();
never executed: toPreviousToken();
0
575-
576 m_lastSectionMove = m_tokens[m_currentToken].validator->handleKey(key);-
577-
578 applyToDate();-
579 if (m_lastSectionMove == QCalendarDateSectionValidator::NextSection
m_lastSectionM...r::NextSectionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
580 toNextToken();
never executed: toNextToken();
0
581 else if (m_lastSectionMove == QCalendarDateSectionValidator::PrevSection
m_lastSectionM...r::PrevSectionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
582 toPreviousToken();
never executed: toPreviousToken();
0
583}
never executed: end of block
0
584-
585-
586-
587class QCalendarTextNavigator: public QObject-
588{-
589 public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; }-
590#pragma GCC diagnostic push-
591 static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);-
592#pragma GCC diagnostic pop-
593 struct QPrivateSignal {};-
594public:-
595 QCalendarTextNavigator(QObject *parent = 0)-
596 : QObject(parent), m_dateText(0), m_dateFrame(0), m_dateValidator(0), m_widget(0), m_editDelay(1500), m_date(QDate::currentDate()) { }
never executed: end of block
0
597-
598 QWidget *widget() const;-
599 void setWidget(QWidget *widget);-
600-
601 int dateEditAcceptDelay() const;-
602 void setDateEditAcceptDelay(int delay);-
603-
604 void setDate(const QDate &date);-
605-
606 bool eventFilter(QObject *o, QEvent *e) override;-
607 void timerEvent(QTimerEvent *e) override;-
608-
609public :-
610 void dateChanged(const QDate &date);-
611 void editingFinished();-
612-
613private:-
614 void applyDate();-
615 void updateDateLabel();-
616 void createDateLabel();-
617 void removeDateLabel();-
618-
619 QLabel *m_dateText;-
620 QFrame *m_dateFrame;-
621 QBasicTimer m_acceptTimer;-
622 QCalendarDateValidator *m_dateValidator;-
623 QWidget *m_widget;-
624 int m_editDelay;-
625-
626 QDate m_date;-
627};-
628-
629QWidget *QCalendarTextNavigator::widget() const-
630{-
631 return
never executed: return m_widget;
m_widget;
never executed: return m_widget;
0
632}-
633-
634void QCalendarTextNavigator::setWidget(QWidget *widget)-
635{-
636 m_widget = widget;-
637}
never executed: end of block
0
638-
639void QCalendarTextNavigator::setDate(const QDate &date)-
640{-
641 m_date = date;-
642}
never executed: end of block
0
643-
644void QCalendarTextNavigator::updateDateLabel()-
645{-
646 if (!m_widget
!m_widgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
647 return;
never executed: return;
0
648-
649 m_acceptTimer.start(m_editDelay, this);-
650-
651 m_dateText->setText(m_dateValidator->currentText());-
652-
653 QSize s = m_dateFrame->sizeHint();-
654 QRect r = m_widget->geometry();-
655 QRect newRect((r.width() - s.width()) / 2, (r.height() - s.height()) / 2, s.width(), s.height());-
656 m_dateFrame->setGeometry(newRect);-
657-
658-
659 QPalette p = m_dateFrame->palette();-
660 p.setBrush(QPalette::Window, m_dateFrame->window()->palette().brush(QPalette::Window));-
661 m_dateFrame->setPalette(p);-
662-
663 m_dateFrame->raise();-
664 m_dateFrame->show();-
665}
never executed: end of block
0
666-
667void QCalendarTextNavigator::applyDate()-
668{-
669 QDate date = m_dateValidator->currentDate();-
670 if (m_date == date
m_date == dateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
671 return;
never executed: return;
0
672-
673 m_date = date;-
674 dateChanged(date);-
675}
never executed: end of block
0
676-
677void QCalendarTextNavigator::createDateLabel()-
678{-
679 if (m_dateFrame
m_dateFrameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
680 return;
never executed: return;
0
681 m_dateFrame = new QFrame(m_widget);-
682 QVBoxLayout *vl = new QVBoxLayout;-
683 m_dateText = new QLabel;-
684 vl->addWidget(m_dateText);-
685 m_dateFrame->setLayout(vl);-
686 m_dateFrame->setFrameShadow(QFrame::Plain);-
687 m_dateFrame->setFrameShape(QFrame::Box);-
688 m_dateValidator = new QCalendarDateValidator();-
689 m_dateValidator->setLocale(m_widget->locale());-
690 m_dateValidator->setFormat(m_widget->locale().dateFormat(QLocale::ShortFormat));-
691 m_dateValidator->setInitialDate(m_date);-
692-
693 m_dateFrame->setAutoFillBackground(true);-
694 m_dateFrame->setBackgroundRole(QPalette::Window);-
695}
never executed: end of block
0
696-
697void QCalendarTextNavigator::removeDateLabel()-
698{-
699 if (!m_dateFrame
!m_dateFrameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
700 return;
never executed: return;
0
701 m_acceptTimer.stop();-
702 m_dateFrame->hide();-
703 m_dateFrame->deleteLater();-
704 delete m_dateValidator;-
705 m_dateFrame = 0;-
706 m_dateText = 0;-
707 m_dateValidator = 0;-
708}
never executed: end of block
0
709-
710bool QCalendarTextNavigator::eventFilter(QObject *o, QEvent *e)-
711{-
712 if (m_widget
m_widgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
713 if (e->type() == QEvent::KeyPress
e->type() == QEvent::KeyPressDescription
TRUEnever evaluated
FALSEnever evaluated
|| e->type() == QEvent::KeyRelease
e->type() == Q...nt::KeyReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
714 QKeyEvent* ke = (QKeyEvent*)e;-
715 if ((ke->text().length() > 0
ke->text().length() > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& ke->text()[0].isPrint()
ke->text()[0].isPrint()Description
TRUEnever evaluated
FALSEnever evaluated
) || m_dateFrame
m_dateFrameDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
716 if (ke->key() == Qt::Key_Return
ke->key() == Qt::Key_ReturnDescription
TRUEnever evaluated
FALSEnever evaluated
|| ke->key() == Qt::Key_Enter
ke->key() == Qt::Key_EnterDescription
TRUEnever evaluated
FALSEnever evaluated
|| ke->key() == Qt::Key_Select
ke->key() == Qt::Key_SelectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
717 applyDate();-
718 editingFinished();-
719 removeDateLabel();-
720 }
never executed: end of block
else if (ke->matches(QKeySequence::Cancel)
ke->matches(QK...uence::Cancel)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
721 removeDateLabel();-
722 }
never executed: end of block
else if (e->type() == QEvent::KeyPress
e->type() == QEvent::KeyPressDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
723 createDateLabel();-
724 m_dateValidator->handleKeyEvent(ke);-
725 updateDateLabel();-
726 }
never executed: end of block
0
727 ke->accept();-
728 return
never executed: return true;
true;
never executed: return true;
0
729 }-
730 }
never executed: end of block
0
731 }
never executed: end of block
0
732 return
never executed: return QObject::eventFilter(o,e);
QObject::eventFilter(o,e);
never executed: return QObject::eventFilter(o,e);
0
733}-
734-
735void QCalendarTextNavigator::timerEvent(QTimerEvent *e)-
736{-
737 if (e->timerId() == m_acceptTimer.timerId()
e->timerId() =...imer.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
738 applyDate();-
739 removeDateLabel();-
740 }
never executed: end of block
0
741}
never executed: end of block
0
742-
743int QCalendarTextNavigator::dateEditAcceptDelay() const-
744{-
745 return
never executed: return m_editDelay;
m_editDelay;
never executed: return m_editDelay;
0
746}-
747-
748void QCalendarTextNavigator::setDateEditAcceptDelay(int delay)-
749{-
750 m_editDelay = delay;-
751}
never executed: end of block
0
752-
753class QCalendarView;-
754-
755-
756-
757-
758-
759-
760#pragma GCC diagnostic push-
761-
762-
763-
764template <typename T>-
765class StaticDayOfWeekAssociativeArray {-
766 bool contained[7];-
767 T data[7];-
768-
769 static constexpr int day2idx(Qt::DayOfWeek day) noexcept { return int(day) - 1; }-
770public:-
771 constexpr StaticDayOfWeekAssociativeArray() noexcept(noexcept(T()))-
772 : contained(), data() {}-
773-
774 constexpr bool contains(Qt::DayOfWeek day) const noexcept { return contained[day2idx(day)]; }-
775 constexpr const T &value(Qt::DayOfWeek day) const noexcept { return data[day2idx(day)]; }-
776-
777 T &operator[](Qt::DayOfWeek day) noexcept-
778 {-
779 const int idx = day2idx(day);-
780 contained[idx] = true;-
781 return
never executed: return data[idx];
data[idx];
never executed: return data[idx];
0
782 }-
783-
784 void insert(Qt::DayOfWeek day, T v) noexcept-
785 {-
786 operator[](day).swap(v);-
787 }
never executed: end of block
0
788};-
789-
790-
791#pragma GCC diagnostic pop-
792-
793-
794class QCalendarModel : public QAbstractTableModel-
795{-
796 public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; }-
797#pragma GCC diagnostic push-
798 static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);-
799#pragma GCC diagnostic pop-
800 struct QPrivateSignal {};-
801public:-
802 QCalendarModel(QObject *parent = 0);-
803-
804 int rowCount(const QModelIndex &) const override-
805 { return
never executed: return RowCount + m_firstRow;
RowCount + m_firstRow;
never executed: return RowCount + m_firstRow;
}
0
806 int columnCount(const QModelIndex &) const override-
807 { return
never executed: return ColumnCount + m_firstColumn;
ColumnCount + m_firstColumn;
never executed: return ColumnCount + m_firstColumn;
}
0
808 QVariant data(const QModelIndex &index, int role) const override;-
809 Qt::ItemFlags flags(const QModelIndex &index) const override;-
810-
811 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override-
812 {-
813 beginInsertRows(parent, row, row + count - 1);-
814 endInsertRows();-
815 return
never executed: return true;
true;
never executed: return true;
0
816 }-
817 bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override-
818 {-
819 beginInsertColumns(parent, column, column + count - 1);-
820 endInsertColumns();-
821 return
never executed: return true;
true;
never executed: return true;
0
822 }-
823 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override-
824 {-
825 beginRemoveRows(parent, row, row + count - 1);-
826 endRemoveRows();-
827 return
never executed: return true;
true;
never executed: return true;
0
828 }-
829 bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override-
830 {-
831 beginRemoveColumns(parent, column, column + count - 1);-
832 endRemoveColumns();-
833 return
never executed: return true;
true;
never executed: return true;
0
834 }-
835-
836 void showMonth(int year, int month);-
837 void setDate(const QDate &d);-
838-
839 void setMinimumDate(const QDate &date);-
840 void setMaximumDate(const QDate &date);-
841-
842 void setRange(const QDate &min, const QDate &max);-
843-
844 void setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat format);-
845-
846 void setFirstColumnDay(Qt::DayOfWeek dayOfWeek);-
847 Qt::DayOfWeek firstColumnDay() const;-
848-
849 bool weekNumbersShown() const;-
850 void setWeekNumbersShown(bool show);-
851-
852 QTextCharFormat formatForCell(int row, int col) const;-
853 Qt::DayOfWeek dayOfWeekForColumn(int section) const;-
854 int columnForDayOfWeek(Qt::DayOfWeek day) const;-
855 QDate dateForCell(int row, int column) const;-
856 void cellForDate(const QDate &date, int *row, int *column) const;-
857 QString dayName(Qt::DayOfWeek day) const;-
858-
859 void setView(QCalendarView *view)-
860 { m_view = view; }
never executed: end of block
0
861-
862 void internalUpdate();-
863 QDate referenceDate() const;-
864 int columnForFirstOfMonth(const QDate &date) const;-
865-
866 int m_firstColumn;-
867 int m_firstRow;-
868 QDate m_date;-
869 QDate m_minimumDate;-
870 QDate m_maximumDate;-
871 int m_shownYear;-
872 int m_shownMonth;-
873 Qt::DayOfWeek m_firstDay;-
874 QCalendarWidget::HorizontalHeaderFormat m_horizontalHeaderFormat;-
875 bool m_weekNumbersShown;-
876 StaticDayOfWeekAssociativeArray<QTextCharFormat> m_dayFormats;-
877 QMap<QDate, QTextCharFormat> m_dateFormats;-
878 QTextCharFormat m_headerFormat;-
879 QCalendarView *m_view;-
880};-
881-
882class QCalendarView : public QTableView-
883{-
884 public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; }-
885#pragma GCC diagnostic push-
886 static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);-
887#pragma GCC diagnostic pop-
888 struct QPrivateSignal {};-
889public:-
890 QCalendarView(QWidget *parent = 0);-
891-
892 void internalUpdate() { updateGeometries(); }
never executed: end of block
0
893 void setReadOnly(bool enable);-
894 virtual void keyboardSearch(const QString & search) override { (void)search; }
never executed: end of block
0
895-
896public :-
897 void showDate(const QDate &date);-
898 void changeDate(const QDate &date, bool changeMonth);-
899 void clicked(const QDate &date);-
900 void editingFinished();-
901protected:-
902 QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;-
903 void mouseDoubleClickEvent(QMouseEvent *event) override;-
904 void mousePressEvent(QMouseEvent *event) override;-
905 void mouseMoveEvent(QMouseEvent *event) override;-
906 void mouseReleaseEvent(QMouseEvent *event) override;-
907-
908 void wheelEvent(QWheelEvent *event) override;-
909-
910 void keyPressEvent(QKeyEvent *event) override;-
911 bool event(QEvent *event) override;-
912-
913 QDate handleMouseEvent(QMouseEvent *event);-
914public:-
915 bool readOnly;-
916private:-
917 bool validDateClicked;-
918-
919-
920-
921};-
922-
923QCalendarModel::QCalendarModel(QObject *parent)-
924 : QAbstractTableModel(parent),-
925 m_firstColumn(1),-
926 m_firstRow(1),-
927 m_date(QDate::currentDate()),-
928 m_minimumDate(QDate::fromJulianDay(1)),-
929 m_maximumDate(7999, 12, 31),-
930 m_shownYear(m_date.year()),-
931 m_shownMonth(m_date.month()),-
932 m_firstDay(QLocale().firstDayOfWeek()),-
933 m_horizontalHeaderFormat(QCalendarWidget::ShortDayNames),-
934 m_weekNumbersShown(true),-
935 m_view(nullptr)-
936{-
937}
never executed: end of block
0
938-
939Qt::DayOfWeek QCalendarModel::dayOfWeekForColumn(int column) const-
940{-
941 int col = column - m_firstColumn;-
942 if (col < 0
col < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| col > 6
col > 6Description
TRUEnever evaluated
FALSEnever evaluated
)
0
943 return
never executed: return Qt::Sunday;
Qt::Sunday;
never executed: return Qt::Sunday;
0
944 int day = m_firstDay + col;-
945 if (day > 7
day > 7Description
TRUEnever evaluated
FALSEnever evaluated
)
0
946 day -= 7;
never executed: day -= 7;
0
947 return
never executed: return Qt::DayOfWeek(day);
Qt::DayOfWeek(day);
never executed: return Qt::DayOfWeek(day);
0
948}-
949-
950int QCalendarModel::columnForDayOfWeek(Qt::DayOfWeek day) const-
951{-
952 if (day < 1
day < 1Description
TRUEnever evaluated
FALSEnever evaluated
|| day > 7
day > 7Description
TRUEnever evaluated
FALSEnever evaluated
)
0
953 return
never executed: return -1;
-1;
never executed: return -1;
0
954 int column = (int)day - (int)m_firstDay;-
955 if (column < 0
column < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
956 column += 7;
never executed: column += 7;
0
957 return
never executed: return column + m_firstColumn;
column + m_firstColumn;
never executed: return column + m_firstColumn;
0
958}-
959QDate QCalendarModel::referenceDate() const-
960{-
961 int refDay = 1;-
962 while (refDay <= 31
refDay <= 31Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
963 QDate refDate(m_shownYear, m_shownMonth, refDay);-
964 if (refDate.isValid()
refDate.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
965 return
never executed: return refDate;
refDate;
never executed: return refDate;
0
966 refDay += 1;-
967 }
never executed: end of block
0
968 return
never executed: return QDate();
QDate();
never executed: return QDate();
0
969}-
970-
971int QCalendarModel::columnForFirstOfMonth(const QDate &date) const-
972{-
973 return
never executed: return (columnForDayOfWeek(static_cast<Qt::DayOfWeek>(date.dayOfWeek())) - (date.day() % 7) + 8) % 7;
(columnForDayOfWeek(static_cast<Qt::DayOfWeek>(date.dayOfWeek())) - (date.day() % 7) + 8) % 7;
never executed: return (columnForDayOfWeek(static_cast<Qt::DayOfWeek>(date.dayOfWeek())) - (date.day() % 7) + 8) % 7;
0
974}-
975-
976QDate QCalendarModel::dateForCell(int row, int column) const-
977{-
978 if (row < m_firstRow
row < m_firstRowDescription
TRUEnever evaluated
FALSEnever evaluated
|| row > m_firstRow + RowCount - 1
row > m_firstR...+ RowCount - 1Description
TRUEnever evaluated
FALSEnever evaluated
||
0
979 column < m_firstColumn
column < m_firstColumnDescription
TRUEnever evaluated
FALSEnever evaluated
|| column > m_firstColumn + ColumnCount - 1
column > m_fir...olumnCount - 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
980 return
never executed: return QDate();
QDate();
never executed: return QDate();
0
981 const QDate refDate = referenceDate();-
982 if (!refDate.isValid()
!refDate.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
983 return
never executed: return QDate();
QDate();
never executed: return QDate();
0
984-
985 const int columnForFirstOfShownMonth = columnForFirstOfMonth(refDate);-
986 if (columnForFirstOfShownMonth - m_firstColumn < MinimumDayOffset
columnForFirst...nimumDayOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
987 row -= 1;
never executed: row -= 1;
0
988-
989 const int requestedDay = 7 * (row - m_firstRow) + column - columnForFirstOfShownMonth - refDate.day() + 1;-
990 return
never executed: return refDate.addDays(requestedDay);
refDate.addDays(requestedDay);
never executed: return refDate.addDays(requestedDay);
0
991}-
992-
993void QCalendarModel::cellForDate(const QDate &date, int *row, int *column) const-
994{-
995 if (!row
!rowDescription
TRUEnever evaluated
FALSEnever evaluated
&& !column
!columnDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
996 return;
never executed: return;
0
997-
998 if (row
rowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
999 *
never executed: *row = -1;
row = -1;
never executed: *row = -1;
0
1000 if (column
columnDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1001 *
never executed: *column = -1;
column = -1;
never executed: *column = -1;
0
1002-
1003 const QDate refDate = referenceDate();-
1004 if (!refDate.isValid()
!refDate.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1005 return;
never executed: return;
0
1006-
1007 const int columnForFirstOfShownMonth = columnForFirstOfMonth(refDate);-
1008 const int requestedPosition = refDate.daysTo(date) - m_firstColumn + columnForFirstOfShownMonth + refDate.day() - 1;-
1009-
1010 int c = requestedPosition % 7;-
1011 int r = requestedPosition / 7;-
1012 if (c < 0
c < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1013 c += 7;-
1014 r -= 1;-
1015 }
never executed: end of block
0
1016-
1017 if (columnForFirstOfShownMonth - m_firstColumn < MinimumDayOffset
columnForFirst...nimumDayOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1018 r += 1;
never executed: r += 1;
0
1019-
1020 if (r < 0
r < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| r > RowCount - 1
r > RowCount - 1Description
TRUEnever evaluated
FALSEnever evaluated
|| c < 0
c < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| c > ColumnCount - 1
c > ColumnCount - 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1021 return;
never executed: return;
0
1022-
1023 if (row
rowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1024 *
never executed: *row = r + m_firstRow;
row = r + m_firstRow;
never executed: *row = r + m_firstRow;
0
1025 if (column
columnDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1026 *
never executed: *column = c + m_firstColumn;
column = c + m_firstColumn;
never executed: *column = c + m_firstColumn;
0
1027}
never executed: end of block
0
1028-
1029QString QCalendarModel::dayName(Qt::DayOfWeek day) const-
1030{-
1031 switch (m_horizontalHeaderFormat) {-
1032 case
never executed: case QCalendarWidget::SingleLetterDayNames:
QCalendarWidget::SingleLetterDayNames:
never executed: case QCalendarWidget::SingleLetterDayNames:
{
0
1033 QString standaloneDayName = m_view->locale().standaloneDayName(day, QLocale::NarrowFormat);-
1034 if (standaloneDayName == m_view->locale().dayName(day, QLocale::NarrowFormat)
standaloneDayN...:NarrowFormat)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1035 return
never executed: return standaloneDayName.left(1);
standaloneDayName.left(1);
never executed: return standaloneDayName.left(1);
0
1036 return
never executed: return standaloneDayName;
standaloneDayName;
never executed: return standaloneDayName;
0
1037 }-
1038 case
never executed: case QCalendarWidget::ShortDayNames:
QCalendarWidget::ShortDayNames:
never executed: case QCalendarWidget::ShortDayNames:
0
1039 return
never executed: return m_view->locale().dayName(day, QLocale::ShortFormat);
m_view->locale().dayName(day, QLocale::ShortFormat);
never executed: return m_view->locale().dayName(day, QLocale::ShortFormat);
0
1040 case
never executed: case QCalendarWidget::LongDayNames:
QCalendarWidget::LongDayNames:
never executed: case QCalendarWidget::LongDayNames:
0
1041 return
never executed: return m_view->locale().dayName(day, QLocale::LongFormat);
m_view->locale().dayName(day, QLocale::LongFormat);
never executed: return m_view->locale().dayName(day, QLocale::LongFormat);
0
1042 default
never executed: default:
:
never executed: default:
0
1043 break;
never executed: break;
0
1044 }-
1045 return
never executed: return QString();
QString();
never executed: return QString();
0
1046}-
1047-
1048QTextCharFormat QCalendarModel::formatForCell(int row, int col) const-
1049{-
1050 QPalette pal;-
1051 QPalette::ColorGroup cg = QPalette::Active;-
1052 if (m_view
m_viewDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1053 pal = m_view->palette();-
1054 if (!m_view->isEnabled()
!m_view->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1055 cg = QPalette::Disabled;
never executed: cg = QPalette::Disabled;
0
1056 else if (!m_view->isActiveWindow()
!m_view->isActiveWindow()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1057 cg = QPalette::Inactive;
never executed: cg = QPalette::Inactive;
0
1058 }
never executed: end of block
0
1059-
1060 QTextCharFormat format;-
1061 format.setFont(m_view->font());-
1062 bool header = (m_weekNumbersShown
m_weekNumbersShownDescription
TRUEnever evaluated
FALSEnever evaluated
&& col == HeaderColumn
col == HeaderColumnDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1063 || (m_horizontalHeaderFormat != QCalendarWidget::NoHorizontalHeader
m_horizontalHe...rizontalHeaderDescription
TRUEnever evaluated
FALSEnever evaluated
&& row == HeaderRow
row == HeaderRowDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
1064 format.setBackground(pal.brush(cg, header ? QPalette::AlternateBase : QPalette::Base));-
1065 format.setForeground(pal.brush(cg, QPalette::Text));-
1066 if (header
headerDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1067 format.merge(m_headerFormat);-
1068 }
never executed: end of block
0
1069-
1070 if (col >= m_firstColumn
col >= m_firstColumnDescription
TRUEnever evaluated
FALSEnever evaluated
&& col < m_firstColumn + ColumnCount
col < m_firstC... + ColumnCountDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1071 Qt::DayOfWeek dayOfWeek = dayOfWeekForColumn(col);-
1072 if (m_dayFormats.contains(dayOfWeek)
m_dayFormats.c...ins(dayOfWeek)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1073 format.merge(m_dayFormats.value(dayOfWeek));
never executed: format.merge(m_dayFormats.value(dayOfWeek));
0
1074 }
never executed: end of block
0
1075-
1076 if (!header
!headerDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1077 QDate date = dateForCell(row, col);-
1078 format.merge(m_dateFormats.value(date));-
1079 if(date < m_minimumDate
date < m_minimumDateDescription
TRUEnever evaluated
FALSEnever evaluated
|| date > m_maximumDate
date > m_maximumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1080 format.setBackground(pal.brush(cg, QPalette::Window));
never executed: format.setBackground(pal.brush(cg, QPalette::Window));
0
1081 if (m_shownMonth != date.month()
m_shownMonth != date.month()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1082 format.setForeground(pal.brush(QPalette::Disabled, QPalette::Text));
never executed: format.setForeground(pal.brush(QPalette::Disabled, QPalette::Text));
0
1083 }
never executed: end of block
0
1084 return
never executed: return format;
format;
never executed: return format;
0
1085}-
1086-
1087QVariant QCalendarModel::data(const QModelIndex &index, int role) const-
1088{-
1089 if (role == Qt::TextAlignmentRole
role == Qt::TextAlignmentRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1090 return
never executed: return (int) Qt::AlignCenter;
(int) Qt::AlignCenter;
never executed: return (int) Qt::AlignCenter;
0
1091-
1092 int row = index.row();-
1093 int column = index.column();-
1094-
1095 if(role == Qt::DisplayRole
role == Qt::DisplayRoleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1096 if (m_weekNumbersShown
m_weekNumbersShownDescription
TRUEnever evaluated
FALSEnever evaluated
&& column == HeaderColumn
column == HeaderColumnDescription
TRUEnever evaluated
FALSEnever evaluated
0
1097 && row >= m_firstRow
row >= m_firstRowDescription
TRUEnever evaluated
FALSEnever evaluated
&& row < m_firstRow + RowCount
row < m_firstRow + RowCountDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1098 QDate date = dateForCell(row, columnForDayOfWeek(Qt::Monday));-
1099 if (date.isValid()
date.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1100 return
never executed: return date.weekNumber();
date.weekNumber();
never executed: return date.weekNumber();
0
1101 }
never executed: end of block
0
1102 if (m_horizontalHeaderFormat != QCalendarWidget::NoHorizontalHeader
m_horizontalHe...rizontalHeaderDescription
TRUEnever evaluated
FALSEnever evaluated
&& row == HeaderRow
row == HeaderRowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1103 && column >= m_firstColumn
column >= m_firstColumnDescription
TRUEnever evaluated
FALSEnever evaluated
&& column < m_firstColumn + ColumnCount
column < m_fir... + ColumnCountDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1104 return
never executed: return dayName(dayOfWeekForColumn(column));
dayName(dayOfWeekForColumn(column));
never executed: return dayName(dayOfWeekForColumn(column));
0
1105 QDate date = dateForCell(row, column);-
1106 if (date.isValid()
date.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1107 return
never executed: return date.day();
date.day();
never executed: return date.day();
0
1108 return
never executed: return QString();
QString();
never executed: return QString();
0
1109 }-
1110-
1111 QTextCharFormat fmt = formatForCell(row, column);-
1112 if (role == Qt::BackgroundColorRole
role == Qt::Ba...roundColorRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1113 return
never executed: return fmt.background().color();
fmt.background().color();
never executed: return fmt.background().color();
0
1114 if (role == Qt::TextColorRole
role == Qt::TextColorRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1115 return
never executed: return fmt.foreground().color();
fmt.foreground().color();
never executed: return fmt.foreground().color();
0
1116 if (role == Qt::FontRole
role == Qt::FontRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1117 return
never executed: return fmt.font();
fmt.font();
never executed: return fmt.font();
0
1118 if (role == Qt::ToolTipRole
role == Qt::ToolTipRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1119 return
never executed: return fmt.toolTip();
fmt.toolTip();
never executed: return fmt.toolTip();
0
1120 return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
1121}-
1122-
1123Qt::ItemFlags QCalendarModel::flags(const QModelIndex &index) const-
1124{-
1125 QDate date = dateForCell(index.row(), index.column());-
1126 if (!date.isValid()
!date.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1127 return
never executed: return QAbstractTableModel::flags(index);
QAbstractTableModel::flags(index);
never executed: return QAbstractTableModel::flags(index);
0
1128 if (date < m_minimumDate
date < m_minimumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1129 return
never executed: return 0;
0;
never executed: return 0;
0
1130 if (date > m_maximumDate
date > m_maximumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1131 return
never executed: return 0;
0;
never executed: return 0;
0
1132 return
never executed: return QAbstractTableModel::flags(index);
QAbstractTableModel::flags(index);
never executed: return QAbstractTableModel::flags(index);
0
1133}-
1134-
1135void QCalendarModel::setDate(const QDate &d)-
1136{-
1137 m_date = d;-
1138 if (m_date < m_minimumDate
m_date < m_minimumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1139 m_date = m_minimumDate;
never executed: m_date = m_minimumDate;
0
1140 else if (m_date > m_maximumDate
m_date > m_maximumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1141 m_date = m_maximumDate;
never executed: m_date = m_maximumDate;
0
1142}
never executed: end of block
0
1143-
1144void QCalendarModel::showMonth(int year, int month)-
1145{-
1146 if (m_shownYear == year
m_shownYear == yearDescription
TRUEnever evaluated
FALSEnever evaluated
&& m_shownMonth == month
m_shownMonth == monthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1147 return;
never executed: return;
0
1148-
1149 m_shownYear = year;-
1150 m_shownMonth = month;-
1151-
1152 internalUpdate();-
1153}
never executed: end of block
0
1154-
1155void QCalendarModel::setMinimumDate(const QDate &d)-
1156{-
1157 if (!d.isValid()
!d.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
|| d == m_minimumDate
d == m_minimumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1158 return;
never executed: return;
0
1159-
1160 m_minimumDate = d;-
1161 if (m_maximumDate < m_minimumDate
m_maximumDate < m_minimumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1162 m_maximumDate = m_minimumDate;
never executed: m_maximumDate = m_minimumDate;
0
1163 if (m_date < m_minimumDate
m_date < m_minimumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1164 m_date = m_minimumDate;
never executed: m_date = m_minimumDate;
0
1165 internalUpdate();-
1166}
never executed: end of block
0
1167-
1168void QCalendarModel::setMaximumDate(const QDate &d)-
1169{-
1170 if (!d.isValid()
!d.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
|| d == m_maximumDate
d == m_maximumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1171 return;
never executed: return;
0
1172-
1173 m_maximumDate = d;-
1174 if (m_minimumDate > m_maximumDate
m_minimumDate > m_maximumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1175 m_minimumDate = m_maximumDate;
never executed: m_minimumDate = m_maximumDate;
0
1176 if (m_date > m_maximumDate
m_date > m_maximumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1177 m_date = m_maximumDate;
never executed: m_date = m_maximumDate;
0
1178 internalUpdate();-
1179}
never executed: end of block
0
1180-
1181void QCalendarModel::setRange(const QDate &min, const QDate &max)-
1182{-
1183 m_minimumDate = min;-
1184 m_maximumDate = max;-
1185 if (m_minimumDate > m_maximumDate
m_minimumDate > m_maximumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1186 qSwap(m_minimumDate, m_maximumDate);
never executed: qSwap(m_minimumDate, m_maximumDate);
0
1187 if (m_date < m_minimumDate
m_date < m_minimumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1188 m_date = m_minimumDate;
never executed: m_date = m_minimumDate;
0
1189 if (m_date > m_maximumDate
m_date > m_maximumDateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1190 m_date = m_maximumDate;
never executed: m_date = m_maximumDate;
0
1191 internalUpdate();-
1192}
never executed: end of block
0
1193-
1194void QCalendarModel::internalUpdate()-
1195{-
1196 QModelIndex begin = index(0, 0);-
1197 QModelIndex end = index(m_firstRow + RowCount - 1, m_firstColumn + ColumnCount - 1);-
1198 dataChanged(begin, end);-
1199 headerDataChanged(Qt::Vertical, 0, m_firstRow + RowCount - 1);-
1200 headerDataChanged(Qt::Horizontal, 0, m_firstColumn + ColumnCount - 1);-
1201}
never executed: end of block
0
1202-
1203void QCalendarModel::setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat format)-
1204{-
1205 if (m_horizontalHeaderFormat == format
m_horizontalHe...rmat == formatDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1206 return;
never executed: return;
0
1207-
1208 int oldFormat = m_horizontalHeaderFormat;-
1209 m_horizontalHeaderFormat = format;-
1210 if (oldFormat == QCalendarWidget::NoHorizontalHeader
oldFormat == Q...rizontalHeaderDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1211 m_firstRow = 1;-
1212 insertRow(0);-
1213 }
never executed: end of block
else if (m_horizontalHeaderFormat == QCalendarWidget::NoHorizontalHeader
m_horizontalHe...rizontalHeaderDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1214 m_firstRow = 0;-
1215 removeRow(0);-
1216 }
never executed: end of block
0
1217 internalUpdate();-
1218}
never executed: end of block
0
1219-
1220void QCalendarModel::setFirstColumnDay(Qt::DayOfWeek dayOfWeek)-
1221{-
1222 if (m_firstDay == dayOfWeek
m_firstDay == dayOfWeekDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1223 return;
never executed: return;
0
1224-
1225 m_firstDay = dayOfWeek;-
1226 internalUpdate();-
1227}
never executed: end of block
0
1228-
1229Qt::DayOfWeek QCalendarModel::firstColumnDay() const-
1230{-
1231 return
never executed: return m_firstDay;
m_firstDay;
never executed: return m_firstDay;
0
1232}-
1233-
1234bool QCalendarModel::weekNumbersShown() const-
1235{-
1236 return
never executed: return m_weekNumbersShown;
m_weekNumbersShown;
never executed: return m_weekNumbersShown;
0
1237}-
1238-
1239void QCalendarModel::setWeekNumbersShown(bool show)-
1240{-
1241 if (m_weekNumbersShown == show
m_weekNumbersShown == showDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1242 return;
never executed: return;
0
1243-
1244 m_weekNumbersShown = show;-
1245 if (show
showDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1246 m_firstColumn = 1;-
1247 insertColumn(0);-
1248 }
never executed: end of block
else {
0
1249 m_firstColumn = 0;-
1250 removeColumn(0);-
1251 }
never executed: end of block
0
1252 internalUpdate();-
1253}
never executed: end of block
0
1254-
1255QCalendarView::QCalendarView(QWidget *parent)-
1256 : QTableView(parent),-
1257 readOnly(false),-
1258 validDateClicked(false)-
1259{-
1260 setTabKeyNavigation(false);-
1261 setShowGrid(false);-
1262 verticalHeader()->setVisible(false);-
1263 horizontalHeader()->setVisible(false);-
1264 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);-
1265 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);-
1266}
never executed: end of block
0
1267-
1268QModelIndex QCalendarView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)-
1269{-
1270 QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model());-
1271 if (!calendarModel
!calendarModelDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1272 return
never executed: return QTableView::moveCursor(cursorAction, modifiers);
QTableView::moveCursor(cursorAction, modifiers);
never executed: return QTableView::moveCursor(cursorAction, modifiers);
0
1273-
1274 if (readOnly
readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1275 return
never executed: return currentIndex();
currentIndex();
never executed: return currentIndex();
0
1276-
1277 QModelIndex index = currentIndex();-
1278 QDate currentDate = static_cast<QCalendarModel*>(model())->dateForCell(index.row(), index.column());-
1279 switch (cursorAction) {-
1280 case
never executed: case QAbstractItemView::MoveUp:
QAbstractItemView::MoveUp:
never executed: case QAbstractItemView::MoveUp:
0
1281 currentDate = currentDate.addDays(-7);-
1282 break;
never executed: break;
0
1283 case
never executed: case QAbstractItemView::MoveDown:
QAbstractItemView::MoveDown:
never executed: case QAbstractItemView::MoveDown:
0
1284 currentDate = currentDate.addDays(7);-
1285 break;
never executed: break;
0
1286 case
never executed: case QAbstractItemView::MoveLeft:
QAbstractItemView::MoveLeft:
never executed: case QAbstractItemView::MoveLeft:
0
1287 currentDate = currentDate.addDays(isRightToLeft() ? 1 : -1);-
1288 break;
never executed: break;
0
1289 case
never executed: case QAbstractItemView::MoveRight:
QAbstractItemView::MoveRight:
never executed: case QAbstractItemView::MoveRight:
0
1290 currentDate = currentDate.addDays(isRightToLeft() ? -1 : 1);-
1291 break;
never executed: break;
0
1292 case
never executed: case QAbstractItemView::MoveHome:
QAbstractItemView::MoveHome:
never executed: case QAbstractItemView::MoveHome:
0
1293 currentDate = QDate(currentDate.year(), currentDate.month(), 1);-
1294 break;
never executed: break;
0
1295 case
never executed: case QAbstractItemView::MoveEnd:
QAbstractItemView::MoveEnd:
never executed: case QAbstractItemView::MoveEnd:
0
1296 currentDate = QDate(currentDate.year(), currentDate.month(), currentDate.daysInMonth());-
1297 break;
never executed: break;
0
1298 case
never executed: case QAbstractItemView::MovePageUp:
QAbstractItemView::MovePageUp:
never executed: case QAbstractItemView::MovePageUp:
0
1299 currentDate = currentDate.addMonths(-1);-
1300 break;
never executed: break;
0
1301 case
never executed: case QAbstractItemView::MovePageDown:
QAbstractItemView::MovePageDown:
never executed: case QAbstractItemView::MovePageDown:
0
1302 currentDate = currentDate.addMonths(1);-
1303 break;
never executed: break;
0
1304 case
never executed: case QAbstractItemView::MoveNext:
QAbstractItemView::MoveNext:
never executed: case QAbstractItemView::MoveNext:
0
1305 case
never executed: case QAbstractItemView::MovePrevious:
QAbstractItemView::MovePrevious:
never executed: case QAbstractItemView::MovePrevious:
0
1306 return
never executed: return currentIndex();
currentIndex();
never executed: return currentIndex();
0
1307 default
never executed: default:
:
never executed: default:
0
1308 break;
never executed: break;
0
1309 }-
1310 changeDate(currentDate, true);-
1311 return
never executed: return currentIndex();
currentIndex();
never executed: return currentIndex();
0
1312}-
1313-
1314void QCalendarView::keyPressEvent(QKeyEvent *event)-
1315{-
1316 if (!readOnly
!readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1317 switch (event->key()) {-
1318 case
never executed: case Qt::Key_Return:
Qt::Key_Return:
never executed: case Qt::Key_Return:
0
1319 case
never executed: case Qt::Key_Enter:
Qt::Key_Enter:
never executed: case Qt::Key_Enter:
0
1320 case
never executed: case Qt::Key_Select:
Qt::Key_Select:
never executed: case Qt::Key_Select:
0
1321 editingFinished();-
1322 return;
never executed: return;
0
1323 default
never executed: default:
:
never executed: default:
0
1324 break;
never executed: break;
0
1325 }-
1326 }-
1327 QTableView::keyPressEvent(event);-
1328}
never executed: end of block
0
1329-
1330-
1331void QCalendarView::wheelEvent(QWheelEvent *event)-
1332{-
1333 const int numDegrees = event->delta() / 8;-
1334 const int numSteps = numDegrees / 15;-
1335 const QModelIndex index = currentIndex();-
1336 QDate currentDate = static_cast<QCalendarModel*>(model())->dateForCell(index.row(), index.column());-
1337 currentDate = currentDate.addMonths(-numSteps);-
1338 showDate(currentDate);-
1339}
never executed: end of block
0
1340-
1341-
1342bool QCalendarView::event(QEvent *event)-
1343{-
1344 return
never executed: return QTableView::event(event);
QTableView::event(event);
never executed: return QTableView::event(event);
0
1345}-
1346-
1347QDate QCalendarView::handleMouseEvent(QMouseEvent *event)-
1348{-
1349 QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model());-
1350 if (!calendarModel
!calendarModelDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1351 return
never executed: return QDate();
QDate();
never executed: return QDate();
0
1352-
1353 QPoint pos = event->pos();-
1354 QModelIndex index = indexAt(pos);-
1355 QDate date = calendarModel->dateForCell(index.row(), index.column());-
1356 if (date.isValid()
date.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& date >= calendarModel->m_minimumDate
date >= calend...>m_minimumDateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1357 && date <= calendarModel->m_maximumDate
date <= calend...>m_maximumDateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1358 return
never executed: return date;
date;
never executed: return date;
0
1359 }-
1360 return
never executed: return QDate();
QDate();
never executed: return QDate();
0
1361}-
1362-
1363void QCalendarView::mouseDoubleClickEvent(QMouseEvent *event)-
1364{-
1365 QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model());-
1366 if (!calendarModel
!calendarModelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1367 QTableView::mouseDoubleClickEvent(event);-
1368 return;
never executed: return;
0
1369 }-
1370-
1371 if (readOnly
readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1372 return;
never executed: return;
0
1373-
1374 QDate date = handleMouseEvent(event);-
1375 validDateClicked = false;-
1376 if (date == calendarModel->m_date
date == calendarModel->m_dateDescription
TRUEnever evaluated
FALSEnever evaluated
&& !style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick)
!style()->styl...OnSingleClick)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1377 editingFinished();-
1378 }
never executed: end of block
0
1379}
never executed: end of block
0
1380-
1381void QCalendarView::mousePressEvent(QMouseEvent *event)-
1382{-
1383 QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model());-
1384 if (!calendarModel
!calendarModelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1385 QTableView::mousePressEvent(event);-
1386 return;
never executed: return;
0
1387 }-
1388-
1389 if (readOnly
readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1390 return;
never executed: return;
0
1391-
1392 if (event->button() != Qt::LeftButton
event->button(...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1393 return;
never executed: return;
0
1394-
1395 QDate date = handleMouseEvent(event);-
1396 if (date.isValid()
date.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1397 validDateClicked = true;-
1398 int row = -1, col = -1;-
1399 static_cast<QCalendarModel *>(model())->cellForDate(date, &row, &col);-
1400 if (row != -1
row != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& col != -1
col != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1401 selectionModel()->setCurrentIndex(model()->index(row, col), QItemSelectionModel::NoUpdate);-
1402 }
never executed: end of block
0
1403 }
never executed: end of block
else {
0
1404 validDateClicked = false;-
1405 event->ignore();-
1406 }
never executed: end of block
0
1407}-
1408-
1409void QCalendarView::mouseMoveEvent(QMouseEvent *event)-
1410{-
1411 QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model());-
1412 if (!calendarModel
!calendarModelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1413 QTableView::mouseMoveEvent(event);-
1414 return;
never executed: return;
0
1415 }-
1416-
1417 if (readOnly
readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1418 return;
never executed: return;
0
1419-
1420 if (validDateClicked
validDateClickedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1421 QDate date = handleMouseEvent(event);-
1422 if (date.isValid()
date.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1423 int row = -1, col = -1;-
1424 static_cast<QCalendarModel *>(model())->cellForDate(date, &row, &col);-
1425 if (row != -1
row != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& col != -1
col != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1426 selectionModel()->setCurrentIndex(model()->index(row, col), QItemSelectionModel::NoUpdate);-
1427 }
never executed: end of block
0
1428 }
never executed: end of block
0
1429 }
never executed: end of block
else {
0
1430 event->ignore();-
1431 }
never executed: end of block
0
1432}-
1433-
1434void QCalendarView::mouseReleaseEvent(QMouseEvent *event)-
1435{-
1436 QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model());-
1437 if (!calendarModel
!calendarModelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1438 QTableView::mouseReleaseEvent(event);-
1439 return;
never executed: return;
0
1440 }-
1441-
1442 if (event->button() != Qt::LeftButton
event->button(...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1443 return;
never executed: return;
0
1444-
1445 if (readOnly
readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1446 return;
never executed: return;
0
1447-
1448 if (validDateClicked
validDateClickedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1449 QDate date = handleMouseEvent(event);-
1450 if (date.isValid()
date.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1451 changeDate(date, true);-
1452 clicked(date);-
1453 if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick)
style()->style...OnSingleClick)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1454 editingFinished();
never executed: editingFinished();
0
1455 }
never executed: end of block
0
1456 validDateClicked = false;-
1457 }
never executed: end of block
else {
0
1458 event->ignore();-
1459 }
never executed: end of block
0
1460}-
1461-
1462class QCalendarDelegate : public QItemDelegate-
1463{-
1464 public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; }-
1465#pragma GCC diagnostic push-
1466 static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);-
1467#pragma GCC diagnostic pop-
1468 struct QPrivateSignal {};-
1469public:-
1470 QCalendarDelegate(QCalendarWidgetPrivate *w, QObject *parent = 0)-
1471 : QItemDelegate(parent), calendarWidgetPrivate(w)-
1472 { }
never executed: end of block
0
1473 virtual void paint(QPainter *painter, const QStyleOptionViewItem &option,-
1474 const QModelIndex &index) const override;-
1475 void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const;-
1476-
1477private:-
1478 QCalendarWidgetPrivate *calendarWidgetPrivate;-
1479 mutable QStyleOptionViewItem storedOption;-
1480};-
1481-
1482-
1483class QCalToolButton: public QToolButton-
1484{-
1485public:-
1486 QCalToolButton(QWidget * parent)-
1487 : QToolButton(parent)-
1488 { }
never executed: end of block
0
1489protected:-
1490 void paintEvent(QPaintEvent *e) override-
1491 {-
1492 (void)e;-
1493-
1494-
1495 QStyleOptionToolButton opt;-
1496 initStyleOption(&opt);-
1497-
1498 if (opt.state & QStyle::State_MouseOver
opt.state & QS...tate_MouseOverDescription
TRUEnever evaluated
FALSEnever evaluated
|| isDown()
isDown()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1499-
1500 setPalette(QPalette());-
1501 }
never executed: end of block
else {
0
1502-
1503 QPalette toolPalette = palette();-
1504 toolPalette.setColor(QPalette::ButtonText, toolPalette.color(QPalette::HighlightedText));-
1505 setPalette(toolPalette);-
1506 }
never executed: end of block
0
1507-
1508 QToolButton::paintEvent(e);-
1509 }
never executed: end of block
0
1510};-
1511-
1512class QPrevNextCalButton : public QToolButton-
1513{-
1514 public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; }-
1515#pragma GCC diagnostic push-
1516 static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);-
1517#pragma GCC diagnostic pop-
1518 struct QPrivateSignal {};-
1519public:-
1520 QPrevNextCalButton(QWidget *parent) : QToolButton(parent) {}
never executed: end of block
0
1521protected:-
1522 void paintEvent(QPaintEvent *) override {-
1523 QStylePainter painter(this);-
1524 QStyleOptionToolButton opt;-
1525 initStyleOption(&opt);-
1526 opt.state &= ~QStyle::State_HasFocus;-
1527 painter.drawComplexControl(QStyle::CC_ToolButton, opt);-
1528 }
never executed: end of block
0
1529};-
1530-
1531}-
1532-
1533class QCalendarWidgetPrivate : public QWidgetPrivate-
1534{-
1535 inline QCalendarWidget* q_func() { return static_cast<QCalendarWidget *>(q_ptr); } inline const QCalendarWidget* q_func() const { return static_cast<const QCalendarWidget *>(q_ptr); } friend class QCalendarWidget;-
1536public:-
1537 QCalendarWidgetPrivate();-
1538-
1539 void showMonth(int year, int month);-
1540 void update();-
1541 void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const;-
1542-
1543 void _q_slotShowDate(const QDate &date);-
1544 void _q_slotChangeDate(const QDate &date);-
1545 void _q_slotChangeDate(const QDate &date, bool changeMonth);-
1546 void _q_editingFinished();-
1547 void _q_monthChanged(QAction*);-
1548 void _q_prevMonthClicked();-
1549 void _q_nextMonthClicked();-
1550 void _q_yearEditingFinished();-
1551 void _q_yearClicked();-
1552-
1553 void createNavigationBar(QWidget *widget);-
1554 void updateButtonIcons();-
1555 void updateMonthMenu();-
1556 void updateMonthMenuNames();-
1557 void updateNavigationBar();-
1558 void updateCurrentPage(const QDate &newDate);-
1559 inline QDate getCurrentDate();-
1560 void setNavigatorEnabled(bool enable);-
1561-
1562 QCalendarModel *m_model;-
1563 QCalendarView *m_view;-
1564 QCalendarDelegate *m_delegate;-
1565 QItemSelectionModel *m_selection;-
1566 QCalendarTextNavigator *m_navigator;-
1567 bool m_dateEditEnabled;-
1568-
1569 QToolButton *nextMonth;-
1570 QToolButton *prevMonth;-
1571 QCalToolButton *monthButton;-
1572 QMenu *monthMenu;-
1573 QMap<int, QAction *> monthToAction;-
1574 QCalToolButton *yearButton;-
1575 QSpinBox *yearEdit;-
1576 QWidget *navBarBackground;-
1577 QSpacerItem *spaceHolder;-
1578-
1579 bool navBarVisible;-
1580 mutable QSize cachedSizeHint;-
1581 Qt::FocusPolicy oldFocusPolicy;-
1582};-
1583-
1584void QCalendarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,-
1585 const QModelIndex &index) const-
1586{-
1587 QDate date = calendarWidgetPrivate->m_model->dateForCell(index.row(), index.column());-
1588 if (date.isValid()
date.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1589 storedOption = option;-
1590 QRect rect = option.rect;-
1591 calendarWidgetPrivate->paintCell(painter, rect, date);-
1592 }
never executed: end of block
else {
0
1593 QItemDelegate::paint(painter, option, index);-
1594 }
never executed: end of block
0
1595}-
1596-
1597void QCalendarDelegate::paintCell(QPainter *painter, const QRect &rect, const QDate &date) const-
1598{-
1599 storedOption.rect = rect;-
1600 int row = -1;-
1601 int col = -1;-
1602 calendarWidgetPrivate->m_model->cellForDate(date, &row, &col);-
1603 QModelIndex idx = calendarWidgetPrivate->m_model->index(row, col);-
1604 QItemDelegate::paint(painter, storedOption, idx);-
1605}
never executed: end of block
0
1606-
1607QCalendarWidgetPrivate::QCalendarWidgetPrivate()-
1608 : QWidgetPrivate()-
1609{-
1610 m_model = 0;-
1611 m_view = 0;-
1612 m_delegate = 0;-
1613 m_selection = 0;-
1614 m_navigator = 0;-
1615 m_dateEditEnabled = false;-
1616 navBarVisible = true;-
1617 oldFocusPolicy = Qt::StrongFocus;-
1618}
never executed: end of block
0
1619-
1620void QCalendarWidgetPrivate::setNavigatorEnabled(bool enable)-
1621{-
1622 QCalendarWidget * const q = q_func();-
1623-
1624 bool navigatorEnabled = (m_navigator->widget() != 0);-
1625 if (enable == navigatorEnabled
enable == navigatorEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1626 return;
never executed: return;
0
1627-
1628 if (enable
enableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1629 m_navigator->setWidget(q);-
1630 q->connect(m_navigator, qFlagLocation("2""dateChanged(QDate)" "\0" __FILE__ ":" "1713"),-
1631 q, qFlagLocation("1""_q_slotChangeDate(QDate)" "\0" __FILE__ ":" "1714"));-
1632 q->connect(m_navigator, qFlagLocation("2""editingFinished()" "\0" __FILE__ ":" "1715"),-
1633 q, qFlagLocation("1""_q_editingFinished()" "\0" __FILE__ ":" "1716"));-
1634 m_view->installEventFilter(m_navigator);-
1635 }
never executed: end of block
else {
0
1636 m_navigator->setWidget(0);-
1637 q->disconnect(m_navigator, qFlagLocation("2""dateChanged(QDate)" "\0" __FILE__ ":" "1720"),-
1638 q, qFlagLocation("1""_q_slotChangeDate(QDate)" "\0" __FILE__ ":" "1721"));-
1639 q->disconnect(m_navigator, qFlagLocation("2""editingFinished()" "\0" __FILE__ ":" "1722"),-
1640 q, qFlagLocation("1""_q_editingFinished()" "\0" __FILE__ ":" "1723"));-
1641 m_view->removeEventFilter(m_navigator);-
1642 }
never executed: end of block
0
1643}-
1644-
1645void QCalendarWidgetPrivate::createNavigationBar(QWidget *widget)-
1646{-
1647 QCalendarWidget * const q = q_func();-
1648 navBarBackground = new QWidget(widget);-
1649 navBarBackground->setObjectName(QLatin1String("qt_calendar_navigationbar"));-
1650 navBarBackground->setAutoFillBackground(true);-
1651 navBarBackground->setBackgroundRole(QPalette::Highlight);-
1652-
1653 prevMonth = new QPrevNextCalButton(navBarBackground);-
1654 nextMonth = new QPrevNextCalButton(navBarBackground);-
1655 prevMonth->setAutoRaise(true);-
1656 nextMonth->setAutoRaise(true);-
1657 prevMonth->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);-
1658 nextMonth->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);-
1659 nextMonth->setAutoRaise(true);-
1660 updateButtonIcons();-
1661 prevMonth->setAutoRepeat(true);-
1662 nextMonth->setAutoRepeat(true);-
1663-
1664 monthButton = new QCalToolButton(navBarBackground);-
1665 monthButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);-
1666 monthButton->setAutoRaise(true);-
1667 monthButton->setPopupMode(QToolButton::InstantPopup);-
1668 monthMenu = new QMenu(monthButton);-
1669 for (int i = 1; i <= 12
i <= 12Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1670 QString monthName(q->locale().standaloneMonthName(i, QLocale::LongFormat));-
1671 QAction *act = monthMenu->addAction(monthName);-
1672 act->setData(i);-
1673 monthToAction[i] = act;-
1674 }
never executed: end of block
0
1675 monthButton->setMenu(monthMenu);-
1676 yearButton = new QCalToolButton(navBarBackground);-
1677 yearButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);-
1678 yearButton->setAutoRaise(true);-
1679 yearEdit = new QSpinBox(navBarBackground);-
1680-
1681 QFont font = q->font();-
1682 font.setBold(true);-
1683 monthButton->setFont(font);-
1684 yearButton->setFont(font);-
1685 yearEdit->setFrame(false);-
1686 yearEdit->setMinimum(m_model->m_minimumDate.year());-
1687 yearEdit->setMaximum(m_model->m_maximumDate.year());-
1688 yearEdit->hide();-
1689 spaceHolder = new QSpacerItem(0,0);-
1690-
1691 QHBoxLayout *headerLayout = new QHBoxLayout;-
1692 headerLayout->setMargin(0);-
1693 headerLayout->setSpacing(0);-
1694 headerLayout->addWidget(prevMonth);-
1695 headerLayout->insertStretch(headerLayout->count());-
1696 headerLayout->addWidget(monthButton);-
1697 headerLayout->addItem(spaceHolder);-
1698 headerLayout->addWidget(yearButton);-
1699 headerLayout->insertStretch(headerLayout->count());-
1700 headerLayout->addWidget(nextMonth);-
1701 navBarBackground->setLayout(headerLayout);-
1702-
1703 yearEdit->setFocusPolicy(Qt::StrongFocus);-
1704 prevMonth->setFocusPolicy(Qt::NoFocus);-
1705 nextMonth->setFocusPolicy(Qt::NoFocus);-
1706 yearButton->setFocusPolicy(Qt::NoFocus);-
1707 monthButton->setFocusPolicy(Qt::NoFocus);-
1708-
1709-
1710 prevMonth->setObjectName(QLatin1String("qt_calendar_prevmonth"));-
1711 nextMonth->setObjectName(QLatin1String("qt_calendar_nextmonth"));-
1712 monthButton->setObjectName(QLatin1String("qt_calendar_monthbutton"));-
1713 yearButton->setObjectName(QLatin1String("qt_calendar_yearbutton"));-
1714 yearEdit->setObjectName(QLatin1String("qt_calendar_yearedit"));-
1715-
1716 updateMonthMenu();-
1717 showMonth(m_model->m_date.year(), m_model->m_date.month());-
1718}
never executed: end of block
0
1719-
1720void QCalendarWidgetPrivate::updateButtonIcons()-
1721{-
1722 QCalendarWidget * const q = q_func();-
1723 prevMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowRight : QStyle::SP_ArrowLeft, 0, q));-
1724 nextMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowLeft : QStyle::SP_ArrowRight, 0, q));-
1725}
never executed: end of block
0
1726-
1727void QCalendarWidgetPrivate::updateMonthMenu()-
1728{-
1729 int beg = 1, end = 12;-
1730 bool prevEnabled = true;-
1731 bool nextEnabled = true;-
1732 if (m_model->m_shownYear == m_model->m_minimumDate.year()
m_model->m_sho...mumDate.year()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1733 beg = m_model->m_minimumDate.month();-
1734 if (m_model->m_shownMonth == m_model->m_minimumDate.month()
m_model->m_sho...umDate.month()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1735 prevEnabled = false;
never executed: prevEnabled = false;
0
1736 }
never executed: end of block
0
1737 if (m_model->m_shownYear == m_model->m_maximumDate.year()
m_model->m_sho...mumDate.year()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1738 end = m_model->m_maximumDate.month();-
1739 if (m_model->m_shownMonth == m_model->m_maximumDate.month()
m_model->m_sho...umDate.month()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1740 nextEnabled = false;
never executed: nextEnabled = false;
0
1741 }
never executed: end of block
0
1742 prevMonth->setEnabled(prevEnabled);-
1743 nextMonth->setEnabled(nextEnabled);-
1744 for (int i = 1; i <= 12
i <= 12Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1745 bool monthEnabled = true;-
1746 if (i < beg
i < begDescription
TRUEnever evaluated
FALSEnever evaluated
|| i > end
i > endDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1747 monthEnabled = false;
never executed: monthEnabled = false;
0
1748 monthToAction[i]->setEnabled(monthEnabled);-
1749 }
never executed: end of block
0
1750}
never executed: end of block
0
1751-
1752void QCalendarWidgetPrivate::updateMonthMenuNames()-
1753{-
1754 QCalendarWidget * const q = q_func();-
1755-
1756 for (int i = 1; i <= 12
i <= 12Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1757 QString monthName(q->locale().standaloneMonthName(i, QLocale::LongFormat));-
1758 monthToAction[i]->setText(monthName);-
1759 }
never executed: end of block
0
1760}
never executed: end of block
0
1761-
1762void QCalendarWidgetPrivate::updateCurrentPage(const QDate &date)-
1763{-
1764 QCalendarWidget * const q = q_func();-
1765-
1766 QDate newDate = date;-
1767 QDate minDate = q->minimumDate();-
1768 QDate maxDate = q->maximumDate();-
1769 if (minDate.isValid()
minDate.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& minDate.daysTo(newDate) < 0
minDate.daysTo(newDate) < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1770 newDate = minDate;
never executed: newDate = minDate;
0
1771 if (maxDate.isValid()
maxDate.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& maxDate.daysTo(newDate) > 0
maxDate.daysTo(newDate) > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1772 newDate = maxDate;
never executed: newDate = maxDate;
0
1773 showMonth(newDate.year(), newDate.month());-
1774 int row = -1, col = -1;-
1775 m_model->cellForDate(newDate, &row, &col);-
1776 if (row != -1
row != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& col != -1
col != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1777 {-
1778 m_view->selectionModel()->setCurrentIndex(m_model->index(row, col),-
1779 QItemSelectionModel::NoUpdate);-
1780 }
never executed: end of block
0
1781}
never executed: end of block
0
1782-
1783void QCalendarWidgetPrivate::_q_monthChanged(QAction *act)-
1784{-
1785 monthButton->setText(act->text());-
1786 QDate currentDate = getCurrentDate();-
1787 QDate newDate = currentDate.addMonths(act->data().toInt()-currentDate.month());-
1788 updateCurrentPage(newDate);-
1789}
never executed: end of block
0
1790-
1791QDate QCalendarWidgetPrivate::getCurrentDate()-
1792{-
1793 QModelIndex index = m_view->currentIndex();-
1794 return
never executed: return m_model->dateForCell(index.row(), index.column());
m_model->dateForCell(index.row(), index.column());
never executed: return m_model->dateForCell(index.row(), index.column());
0
1795}-
1796-
1797void QCalendarWidgetPrivate::_q_prevMonthClicked()-
1798{-
1799 QDate currentDate = getCurrentDate().addMonths(-1);-
1800 updateCurrentPage(currentDate);-
1801}
never executed: end of block
0
1802-
1803void QCalendarWidgetPrivate::_q_nextMonthClicked()-
1804{-
1805 QDate currentDate = getCurrentDate().addMonths(1);-
1806 updateCurrentPage(currentDate);-
1807}
never executed: end of block
0
1808-
1809void QCalendarWidgetPrivate::_q_yearEditingFinished()-
1810{-
1811 QCalendarWidget * const q = q_func();-
1812 yearButton->setText(yearEdit->text());-
1813 yearEdit->hide();-
1814 q->setFocusPolicy(oldFocusPolicy);-
1815 (static_cast<QApplication *>(QCoreApplication::instance()))->removeEventFilter(q);-
1816 spaceHolder->changeSize(0, 0);-
1817 yearButton->show();-
1818 QDate currentDate = getCurrentDate();-
1819 currentDate = currentDate.addYears(yearEdit->text().toInt() - currentDate.year());-
1820 updateCurrentPage(currentDate);-
1821}
never executed: end of block
0
1822-
1823void QCalendarWidgetPrivate::_q_yearClicked()-
1824{-
1825 QCalendarWidget * const q = q_func();-
1826-
1827 yearEdit->setGeometry(yearButton->x(), yearButton->y(),-
1828 yearEdit->sizeHint().width(), yearButton->height());-
1829 spaceHolder->changeSize(yearButton->width(), 0);-
1830 yearButton->hide();-
1831 oldFocusPolicy = q->focusPolicy();-
1832 q->setFocusPolicy(Qt::NoFocus);-
1833 yearEdit->show();-
1834 (static_cast<QApplication *>(QCoreApplication::instance()))->installEventFilter(q);-
1835 yearEdit->raise();-
1836 yearEdit->selectAll();-
1837 yearEdit->setFocus(Qt::MouseFocusReason);-
1838}
never executed: end of block
0
1839-
1840void QCalendarWidgetPrivate::showMonth(int year, int month)-
1841{-
1842 if (m_model->m_shownYear == year
m_model->m_shownYear == yearDescription
TRUEnever evaluated
FALSEnever evaluated
&& m_model->m_shownMonth == month
m_model->m_shownMonth == monthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1843 return;
never executed: return;
0
1844 QCalendarWidget * const q = q_func();-
1845 m_model->showMonth(year, month);-
1846 updateNavigationBar();-
1847 q->currentPageChanged(year, month);-
1848 m_view->internalUpdate();-
1849 cachedSizeHint = QSize();-
1850 update();-
1851 updateMonthMenu();-
1852}
never executed: end of block
0
1853-
1854void QCalendarWidgetPrivate::updateNavigationBar()-
1855{-
1856 QCalendarWidget * const q = q_func();-
1857-
1858 QString monthName = q->locale().standaloneMonthName(m_model->m_shownMonth, QLocale::LongFormat);-
1859-
1860 monthButton->setText(monthName);-
1861 yearButton->setText(QString::number(m_model->m_shownYear));-
1862 yearEdit->setValue(m_model->m_shownYear);-
1863}
never executed: end of block
0
1864-
1865void QCalendarWidgetPrivate::update()-
1866{-
1867 QDate currentDate = m_model->m_date;-
1868 int row, column;-
1869 m_model->cellForDate(currentDate, &row, &column);-
1870 QModelIndex idx;-
1871 m_selection->clear();-
1872 if (row != -1
row != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& column != -1
column != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1873 idx = m_model->index(row, column);-
1874 m_selection->setCurrentIndex(idx, QItemSelectionModel::SelectCurrent);-
1875 }
never executed: end of block
0
1876}
never executed: end of block
0
1877-
1878void QCalendarWidgetPrivate::paintCell(QPainter *painter, const QRect &rect, const QDate &date) const-
1879{-
1880 const QCalendarWidget * const q = q_func();-
1881 q->paintCell(painter, rect, date);-
1882}
never executed: end of block
0
1883-
1884void QCalendarWidgetPrivate::_q_slotShowDate(const QDate &date)-
1885{-
1886 updateCurrentPage(date);-
1887}
never executed: end of block
0
1888-
1889void QCalendarWidgetPrivate::_q_slotChangeDate(const QDate &date)-
1890{-
1891 _q_slotChangeDate(date, true);-
1892}
never executed: end of block
0
1893-
1894void QCalendarWidgetPrivate::_q_slotChangeDate(const QDate &date, bool changeMonth)-
1895{-
1896 QDate oldDate = m_model->m_date;-
1897 m_model->setDate(date);-
1898 QDate newDate = m_model->m_date;-
1899 if (changeMonth
changeMonthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1900 showMonth(newDate.year(), newDate.month());
never executed: showMonth(newDate.year(), newDate.month());
0
1901 if (oldDate != newDate
oldDate != newDateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1902 update();-
1903 QCalendarWidget * const q = q_func();-
1904 m_navigator->setDate(newDate);-
1905 q->selectionChanged();-
1906 }
never executed: end of block
0
1907}
never executed: end of block
0
1908-
1909void QCalendarWidgetPrivate::_q_editingFinished()-
1910{-
1911 QCalendarWidget * const q = q_func();-
1912 q->activated(m_model->m_date);-
1913}
never executed: end of block
0
1914QCalendarWidget::QCalendarWidget(QWidget *parent)-
1915 : QWidget(*new QCalendarWidgetPrivate, parent, 0)-
1916{-
1917 QCalendarWidgetPrivate * const d = d_func();-
1918-
1919 setAutoFillBackground(true);-
1920 setBackgroundRole(QPalette::Window);-
1921-
1922 QVBoxLayout *layoutV = new QVBoxLayout(this);-
1923 layoutV->setMargin(0);-
1924 d->m_model = new QCalendarModel(this);-
1925 QTextCharFormat fmt;-
1926 fmt.setForeground(QBrush(Qt::red));-
1927 d->m_model->m_dayFormats.insert(Qt::Saturday, fmt);-
1928 d->m_model->m_dayFormats.insert(Qt::Sunday, fmt);-
1929 d->m_view = new QCalendarView(this);-
1930 d->m_view->setObjectName(QLatin1String("qt_calendar_calendarview"));-
1931 d->m_view->setModel(d->m_model);-
1932 d->m_model->setView(d->m_view);-
1933 d->m_view->setSelectionBehavior(QAbstractItemView::SelectItems);-
1934 d->m_view->setSelectionMode(QAbstractItemView::SingleSelection);-
1935 d->m_view->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);-
1936 d->m_view->horizontalHeader()->setSectionsClickable(false);-
1937 d->m_view->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);-
1938 d->m_view->verticalHeader()->setSectionsClickable(false);-
1939 d->m_selection = d->m_view->selectionModel();-
1940 d->createNavigationBar(this);-
1941 d->m_view->setFrameStyle(QFrame::NoFrame);-
1942 d->m_delegate = new QCalendarDelegate(d, this);-
1943 d->m_view->setItemDelegate(d->m_delegate);-
1944 d->update();-
1945 d->updateNavigationBar();-
1946 setFocusPolicy(Qt::StrongFocus);-
1947 setFocusProxy(d->m_view);-
1948 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);-
1949-
1950 connect(d->m_view, qFlagLocation("2""showDate(QDate)" "\0" __FILE__ ":" "2125"),-
1951 this, qFlagLocation("1""_q_slotShowDate(QDate)" "\0" __FILE__ ":" "2126"));-
1952 connect(d->m_view, qFlagLocation("2""changeDate(QDate,bool)" "\0" __FILE__ ":" "2127"),-
1953 this, qFlagLocation("1""_q_slotChangeDate(QDate,bool)" "\0" __FILE__ ":" "2128"));-
1954 connect(d->m_view, qFlagLocation("2""clicked(QDate)" "\0" __FILE__ ":" "2129"),-
1955 this, qFlagLocation("2""clicked(QDate)" "\0" __FILE__ ":" "2130"));-
1956 connect(d->m_view, qFlagLocation("2""editingFinished()" "\0" __FILE__ ":" "2131"),-
1957 this, qFlagLocation("1""_q_editingFinished()" "\0" __FILE__ ":" "2132"));-
1958-
1959 connect(d->prevMonth, qFlagLocation("2""clicked(bool)" "\0" __FILE__ ":" "2134"),-
1960 this, qFlagLocation("1""_q_prevMonthClicked()" "\0" __FILE__ ":" "2135"));-
1961 connect(d->nextMonth, qFlagLocation("2""clicked(bool)" "\0" __FILE__ ":" "2136"),-
1962 this, qFlagLocation("1""_q_nextMonthClicked()" "\0" __FILE__ ":" "2137"));-
1963 connect(d->yearButton, qFlagLocation("2""clicked(bool)" "\0" __FILE__ ":" "2138"),-
1964 this, qFlagLocation("1""_q_yearClicked()" "\0" __FILE__ ":" "2139"));-
1965 connect(d->monthMenu, qFlagLocation("2""triggered(QAction*)" "\0" __FILE__ ":" "2140"),-
1966 this, qFlagLocation("1""_q_monthChanged(QAction*)" "\0" __FILE__ ":" "2141"));-
1967 connect(d->yearEdit, qFlagLocation("2""editingFinished()" "\0" __FILE__ ":" "2142"),-
1968 this, qFlagLocation("1""_q_yearEditingFinished()" "\0" __FILE__ ":" "2143"));-
1969-
1970 layoutV->setMargin(0);-
1971 layoutV->setSpacing(0);-
1972 layoutV->addWidget(d->navBarBackground);-
1973 layoutV->addWidget(d->m_view);-
1974-
1975 d->m_navigator = new QCalendarTextNavigator(this);-
1976 setDateEditEnabled(true);-
1977}
never executed: end of block
0
1978-
1979-
1980-
1981-
1982QCalendarWidget::~QCalendarWidget()-
1983{-
1984}-
1985-
1986-
1987-
1988-
1989QSize QCalendarWidget::sizeHint() const-
1990{-
1991 return
never executed: return minimumSizeHint();
minimumSizeHint();
never executed: return minimumSizeHint();
0
1992}-
1993-
1994-
1995-
1996-
1997QSize QCalendarWidget::minimumSizeHint() const-
1998{-
1999 const QCalendarWidgetPrivate * const d = d_func();-
2000 if (d->cachedSizeHint.isValid()
d->cachedSizeHint.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2001 return
never executed: return d->cachedSizeHint;
d->cachedSizeHint;
never executed: return d->cachedSizeHint;
0
2002-
2003 ensurePolished();-
2004-
2005 int w = 0;-
2006 int h = 0;-
2007-
2008 int end = 53;-
2009 int rows = 7;-
2010 int cols = 8;-
2011-
2012 const int marginH = (style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1) * 2;-
2013-
2014 if (horizontalHeaderFormat() == QCalendarWidget::NoHorizontalHeader
horizontalHead...rizontalHeaderDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2015 rows = 6;-
2016 }
never executed: end of block
else {
0
2017 for (int i = 1; i <= 7
i <= 7Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
2018 QFontMetrics fm(d->m_model->formatForCell(0, i).font());-
2019 w = qMax(w, fm.width(d->m_model->dayName(d->m_model->dayOfWeekForColumn(i))) + marginH);-
2020 h = qMax(h, fm.height());-
2021 }
never executed: end of block
0
2022 }
never executed: end of block
0
2023-
2024 if (verticalHeaderFormat() == QCalendarWidget::NoVerticalHeader
verticalHeader...VerticalHeaderDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2025 cols = 7;-
2026 }
never executed: end of block
else {
0
2027 for (int i = 1; i <= 6
i <= 6Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
2028 QFontMetrics fm(d->m_model->formatForCell(i, 0).font());-
2029 for (int j = 1; j < end
j < endDescription
TRUEnever evaluated
FALSEnever evaluated
; j++)
0
2030 w = qMax(w, fm.width(QString::number(j)) + marginH);
never executed: w = qMax(w, fm.width(QString::number(j)) + marginH);
0
2031 h = qMax(h, fm.height());-
2032 }
never executed: end of block
0
2033 }
never executed: end of block
0
2034-
2035 QFontMetrics fm(d->m_model->formatForCell(1, 1).font());-
2036 for (int i = 1; i <= end
i <= endDescription
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
2037 w = qMax(w, fm.width(QString::number(i)) + marginH);-
2038 h = qMax(h, fm.height());-
2039 }
never executed: end of block
0
2040-
2041 if (d->m_view->showGrid()
d->m_view->showGrid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2042-
2043 w += 1;-
2044 h += 1;-
2045 }
never executed: end of block
0
2046-
2047 w += 1;-
2048-
2049 h = qMax(h, d->m_view->verticalHeader()->minimumSectionSize());-
2050 w = qMax(w, d->m_view->horizontalHeader()->minimumSectionSize());-
2051-
2052-
2053 QSize headerSize(0, 0);-
2054 if (d->navBarVisible
d->navBarVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2055 int headerH = d->navBarBackground->sizeHint().height();-
2056 int headerW = 0;-
2057-
2058 headerW += d->prevMonth->sizeHint().width();-
2059 headerW += d->nextMonth->sizeHint().width();-
2060-
2061 QFontMetrics fm = d->monthButton->fontMetrics();-
2062 int monthW = 0;-
2063 for (int i = 1; i < 12
i < 12Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
2064 QString monthName = locale().standaloneMonthName(i, QLocale::LongFormat);-
2065 monthW = qMax(monthW, fm.boundingRect(monthName).width());-
2066 }
never executed: end of block
0
2067 const int buttonDecoMargin = d->monthButton->sizeHint().width() - fm.boundingRect(d->monthButton->text()).width();-
2068 headerW += monthW + buttonDecoMargin;-
2069-
2070 fm = d->yearButton->fontMetrics();-
2071 headerW += fm.boundingRect(QLatin1String("5555")).width() + buttonDecoMargin;-
2072-
2073 headerSize = QSize(headerW, headerH);-
2074 }
never executed: end of block
0
2075 w *= cols;-
2076 w = qMax(headerSize.width(), w);-
2077 h = (h * rows) + headerSize.height();-
2078 QMargins cm = contentsMargins();-
2079 w += cm.left() + cm.right();-
2080 h += cm.top() + cm.bottom();-
2081 d->cachedSizeHint = QSize(w, h);-
2082 return
never executed: return d->cachedSizeHint;
d->cachedSizeHint;
never executed: return d->cachedSizeHint;
0
2083}-
2084-
2085-
2086-
2087-
2088-
2089void QCalendarWidget::paintCell(QPainter *painter, const QRect &rect, const QDate &date) const-
2090{-
2091 const QCalendarWidgetPrivate * const d = d_func();-
2092 d->m_delegate->paintCell(painter, rect, date);-
2093}
never executed: end of block
0
2094QDate QCalendarWidget::selectedDate() const-
2095{-
2096 const QCalendarWidgetPrivate * const d = d_func();-
2097 return
never executed: return d->m_model->m_date;
d->m_model->m_date;
never executed: return d->m_model->m_date;
0
2098}-
2099-
2100void QCalendarWidget::setSelectedDate(const QDate &date)-
2101{-
2102 QCalendarWidgetPrivate * const d = d_func();-
2103 if (d->m_model->m_date == date
d->m_model->m_date == dateDescription
TRUEnever evaluated
FALSEnever evaluated
&& date == d->getCurrentDate()
date == d->getCurrentDate()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2104 return;
never executed: return;
0
2105-
2106 if (!date.isValid()
!date.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2107 return;
never executed: return;
0
2108-
2109 d->m_model->setDate(date);-
2110 d->update();-
2111 QDate newDate = d->m_model->m_date;-
2112 d->showMonth(newDate.year(), newDate.month());-
2113 selectionChanged();-
2114}
never executed: end of block
0
2115int QCalendarWidget::yearShown() const-
2116{-
2117 const QCalendarWidgetPrivate * const d = d_func();-
2118 return
never executed: return d->m_model->m_shownYear;
d->m_model->m_shownYear;
never executed: return d->m_model->m_shownYear;
0
2119}-
2120int QCalendarWidget::monthShown() const-
2121{-
2122 const QCalendarWidgetPrivate * const d = d_func();-
2123 return
never executed: return d->m_model->m_shownMonth;
d->m_model->m_shownMonth;
never executed: return d->m_model->m_shownMonth;
0
2124}-
2125void QCalendarWidget::setCurrentPage(int year, int month)-
2126{-
2127 QCalendarWidgetPrivate * const d = d_func();-
2128 QDate currentDate = d->getCurrentDate();-
2129 int day = currentDate.day();-
2130 int daysInMonths = QDate(year, month, 1).daysInMonth();-
2131 if (day > daysInMonths
day > daysInMonthsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2132 day = daysInMonths;
never executed: day = daysInMonths;
0
2133-
2134 d->showMonth(year, month);-
2135-
2136 QDate newDate(year, month, day);-
2137 int row = -1, col = -1;-
2138 d->m_model->cellForDate(newDate, &row, &col);-
2139 if (row != -1
row != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& col != -1
col != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2140 d->m_view->selectionModel()->setCurrentIndex(d->m_model->index(row, col),-
2141 QItemSelectionModel::NoUpdate);-
2142 }
never executed: end of block
0
2143}
never executed: end of block
0
2144void QCalendarWidget::showNextMonth()-
2145{-
2146 int year = yearShown();-
2147 int month = monthShown();-
2148 if (month == 12
month == 12Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2149 ++year;-
2150 month = 1;-
2151 }
never executed: end of block
else {
0
2152 ++month;-
2153 }
never executed: end of block
0
2154 setCurrentPage(year, month);-
2155}
never executed: end of block
0
2156void QCalendarWidget::showPreviousMonth()-
2157{-
2158 int year = yearShown();-
2159 int month = monthShown();-
2160 if (month == 1
month == 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2161 --year;-
2162 month = 12;-
2163 }
never executed: end of block
else {
0
2164 --month;-
2165 }
never executed: end of block
0
2166 setCurrentPage(year, month);-
2167}
never executed: end of block
0
2168void QCalendarWidget::showNextYear()-
2169{-
2170 int year = yearShown();-
2171 int month = monthShown();-
2172 ++year;-
2173 setCurrentPage(year, month);-
2174}
never executed: end of block
0
2175void QCalendarWidget::showPreviousYear()-
2176{-
2177 int year = yearShown();-
2178 int month = monthShown();-
2179 --year;-
2180 setCurrentPage(year, month);-
2181}
never executed: end of block
0
2182-
2183-
2184-
2185-
2186-
2187-
2188void QCalendarWidget::showSelectedDate()-
2189{-
2190 QDate currentDate = selectedDate();-
2191 setCurrentPage(currentDate.year(), currentDate.month());-
2192}
never executed: end of block
0
2193-
2194-
2195-
2196-
2197-
2198-
2199void QCalendarWidget::showToday()-
2200{-
2201 QDate currentDate = QDate::currentDate();-
2202 setCurrentPage(currentDate.year(), currentDate.month());-
2203}
never executed: end of block
0
2204QDate QCalendarWidget::minimumDate() const-
2205{-
2206 const QCalendarWidgetPrivate * const d = d_func();-
2207 return
never executed: return d->m_model->m_minimumDate;
d->m_model->m_minimumDate;
never executed: return d->m_model->m_minimumDate;
0
2208}-
2209-
2210void QCalendarWidget::setMinimumDate(const QDate &date)-
2211{-
2212 QCalendarWidgetPrivate * const d = d_func();-
2213 if (!date.isValid()
!date.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
|| d->m_model->m_minimumDate == date
d->m_model->m_...umDate == dateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2214 return;
never executed: return;
0
2215-
2216 QDate oldDate = d->m_model->m_date;-
2217 d->m_model->setMinimumDate(date);-
2218 d->yearEdit->setMinimum(d->m_model->m_minimumDate.year());-
2219 d->updateMonthMenu();-
2220 QDate newDate = d->m_model->m_date;-
2221 if (oldDate != newDate
oldDate != newDateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2222 d->update();-
2223 d->showMonth(newDate.year(), newDate.month());-
2224 d->m_navigator->setDate(newDate);-
2225 selectionChanged();-
2226 }
never executed: end of block
0
2227}
never executed: end of block
0
2228QDate QCalendarWidget::maximumDate() const-
2229{-
2230 const QCalendarWidgetPrivate * const d = d_func();-
2231 return
never executed: return d->m_model->m_maximumDate;
d->m_model->m_maximumDate;
never executed: return d->m_model->m_maximumDate;
0
2232}-
2233-
2234void QCalendarWidget::setMaximumDate(const QDate &date)-
2235{-
2236 QCalendarWidgetPrivate * const d = d_func();-
2237 if (!date.isValid()
!date.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
|| d->m_model->m_maximumDate == date
d->m_model->m_...umDate == dateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2238 return;
never executed: return;
0
2239-
2240 QDate oldDate = d->m_model->m_date;-
2241 d->m_model->setMaximumDate(date);-
2242 d->yearEdit->setMaximum(d->m_model->m_maximumDate.year());-
2243 d->updateMonthMenu();-
2244 QDate newDate = d->m_model->m_date;-
2245 if (oldDate != newDate
oldDate != newDateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2246 d->update();-
2247 d->showMonth(newDate.year(), newDate.month());-
2248 d->m_navigator->setDate(newDate);-
2249 selectionChanged();-
2250 }
never executed: end of block
0
2251}
never executed: end of block
0
2252void QCalendarWidget::setDateRange(const QDate &min, const QDate &max)-
2253{-
2254 QCalendarWidgetPrivate * const d = d_func();-
2255 if (d->m_model->m_minimumDate == min
d->m_model->m_...mumDate == minDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->m_model->m_maximumDate == max
d->m_model->m_...mumDate == maxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2256 return;
never executed: return;
0
2257 if (!min.isValid()
!min.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
|| !max.isValid()
!max.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2258 return;
never executed: return;
0
2259-
2260 QDate oldDate = d->m_model->m_date;-
2261 d->m_model->setRange(min, max);-
2262 d->yearEdit->setMinimum(d->m_model->m_minimumDate.year());-
2263 d->yearEdit->setMaximum(d->m_model->m_maximumDate.year());-
2264 d->updateMonthMenu();-
2265 QDate newDate = d->m_model->m_date;-
2266 if (oldDate != newDate
oldDate != newDateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2267 d->update();-
2268 d->showMonth(newDate.year(), newDate.month());-
2269 d->m_navigator->setDate(newDate);-
2270 selectionChanged();-
2271 }
never executed: end of block
0
2272}
never executed: end of block
0
2273void QCalendarWidget::setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat format)-
2274{-
2275 QCalendarWidgetPrivate * const d = d_func();-
2276 if (d->m_model->m_horizontalHeaderFormat == format
d->m_model->m_...rmat == formatDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2277 return;
never executed: return;
0
2278-
2279 d->m_model->setHorizontalHeaderFormat(format);-
2280 d->cachedSizeHint = QSize();-
2281 d->m_view->viewport()->update();-
2282 d->m_view->updateGeometry();-
2283}
never executed: end of block
0
2284-
2285QCalendarWidget::HorizontalHeaderFormat QCalendarWidget::horizontalHeaderFormat() const-
2286{-
2287 const QCalendarWidgetPrivate * const d = d_func();-
2288 return
never executed: return d->m_model->m_horizontalHeaderFormat;
d->m_model->m_horizontalHeaderFormat;
never executed: return d->m_model->m_horizontalHeaderFormat;
0
2289}-
2290QCalendarWidget::VerticalHeaderFormat QCalendarWidget::verticalHeaderFormat() const-
2291{-
2292 const QCalendarWidgetPrivate * const d = d_func();-
2293 bool shown = d->m_model->weekNumbersShown();-
2294 if (shown
shownDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2295 return
never executed: return QCalendarWidget::ISOWeekNumbers;
QCalendarWidget::ISOWeekNumbers;
never executed: return QCalendarWidget::ISOWeekNumbers;
0
2296 return
never executed: return QCalendarWidget::NoVerticalHeader;
QCalendarWidget::NoVerticalHeader;
never executed: return QCalendarWidget::NoVerticalHeader;
0
2297}-
2298-
2299void QCalendarWidget::setVerticalHeaderFormat(QCalendarWidget::VerticalHeaderFormat format)-
2300{-
2301 QCalendarWidgetPrivate * const d = d_func();-
2302 bool show = false;-
2303 if (format == QCalendarWidget::ISOWeekNumbers
format == QCal...ISOWeekNumbersDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2304 show = true;
never executed: show = true;
0
2305 if (d->m_model->weekNumbersShown() == show
d->m_model->we...hown() == showDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2306 return;
never executed: return;
0
2307 d->m_model->setWeekNumbersShown(show);-
2308 d->cachedSizeHint = QSize();-
2309 d->m_view->viewport()->update();-
2310 d->m_view->updateGeometry();-
2311}
never executed: end of block
0
2312bool QCalendarWidget::isGridVisible() const-
2313{-
2314 const QCalendarWidgetPrivate * const d = d_func();-
2315 return
never executed: return d->m_view->showGrid();
d->m_view->showGrid();
never executed: return d->m_view->showGrid();
0
2316}-
2317-
2318void QCalendarWidget::setGridVisible(bool show)-
2319{-
2320 QCalendarWidgetPrivate * const d = d_func();-
2321 d->m_view->setShowGrid(show);-
2322 d->cachedSizeHint = QSize();-
2323 d->m_view->viewport()->update();-
2324 d->m_view->updateGeometry();-
2325}
never executed: end of block
0
2326QCalendarWidget::SelectionMode QCalendarWidget::selectionMode() const-
2327{-
2328 const QCalendarWidgetPrivate * const d = d_func();-
2329 return
never executed: return d->m_view->readOnly ? QCalendarWidget::NoSelection : QCalendarWidget::SingleSelection;
d->m_view->readOnly ? QCalendarWidget::NoSelection : QCalendarWidget::SingleSelection;
never executed: return d->m_view->readOnly ? QCalendarWidget::NoSelection : QCalendarWidget::SingleSelection;
0
2330}-
2331-
2332void QCalendarWidget::setSelectionMode(SelectionMode mode)-
2333{-
2334 QCalendarWidgetPrivate * const d = d_func();-
2335 d->m_view->readOnly = (mode == QCalendarWidget::NoSelection);-
2336 d->setNavigatorEnabled(isDateEditEnabled() && (selectionMode() != QCalendarWidget::NoSelection));-
2337 d->update();-
2338}
never executed: end of block
0
2339void QCalendarWidget::setFirstDayOfWeek(Qt::DayOfWeek dayOfWeek)-
2340{-
2341 QCalendarWidgetPrivate * const d = d_func();-
2342 if ((
(Qt::DayOfWeek...) == dayOfWeekDescription
TRUEnever evaluated
FALSEnever evaluated
Qt::DayOfWeek)d->m_model->firstColumnDay() == dayOfWeek
(Qt::DayOfWeek...) == dayOfWeekDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2343 return;
never executed: return;
0
2344-
2345 d->m_model->setFirstColumnDay(dayOfWeek);-
2346 d->update();-
2347}
never executed: end of block
0
2348-
2349Qt::DayOfWeek QCalendarWidget::firstDayOfWeek() const-
2350{-
2351 const QCalendarWidgetPrivate * const d = d_func();-
2352 return
never executed: return (Qt::DayOfWeek)d->m_model->firstColumnDay();
(Qt::DayOfWeek)d->m_model->firstColumnDay();
never executed: return (Qt::DayOfWeek)d->m_model->firstColumnDay();
0
2353}-
2354-
2355-
2356-
2357-
2358QTextCharFormat QCalendarWidget::headerTextFormat() const-
2359{-
2360 const QCalendarWidgetPrivate * const d = d_func();-
2361 return
never executed: return d->m_model->m_headerFormat;
d->m_model->m_headerFormat;
never executed: return d->m_model->m_headerFormat;
0
2362}-
2363void QCalendarWidget::setHeaderTextFormat(const QTextCharFormat &format)-
2364{-
2365 QCalendarWidgetPrivate * const d = d_func();-
2366 d->m_model->m_headerFormat = format;-
2367 d->cachedSizeHint = QSize();-
2368 d->m_view->viewport()->update();-
2369 d->m_view->updateGeometry();-
2370}
never executed: end of block
0
2371-
2372-
2373-
2374-
2375-
2376-
2377QTextCharFormat QCalendarWidget::weekdayTextFormat(Qt::DayOfWeek dayOfWeek) const-
2378{-
2379 const QCalendarWidgetPrivate * const d = d_func();-
2380 return
never executed: return d->m_model->m_dayFormats.value(dayOfWeek);
d->m_model->m_dayFormats.value(dayOfWeek);
never executed: return d->m_model->m_dayFormats.value(dayOfWeek);
0
2381}-
2382void QCalendarWidget::setWeekdayTextFormat(Qt::DayOfWeek dayOfWeek, const QTextCharFormat &format)-
2383{-
2384 QCalendarWidgetPrivate * const d = d_func();-
2385 d->m_model->m_dayFormats[dayOfWeek] = format;-
2386 d->cachedSizeHint = QSize();-
2387 d->m_view->viewport()->update();-
2388 d->m_view->updateGeometry();-
2389}
never executed: end of block
0
2390-
2391-
2392-
2393-
2394-
2395QMap<QDate, QTextCharFormat> QCalendarWidget::dateTextFormat() const-
2396{-
2397 const QCalendarWidgetPrivate * const d = d_func();-
2398 return
never executed: return d->m_model->m_dateFormats;
d->m_model->m_dateFormats;
never executed: return d->m_model->m_dateFormats;
0
2399}-
2400-
2401-
2402-
2403-
2404-
2405QTextCharFormat QCalendarWidget::dateTextFormat(const QDate &date) const-
2406{-
2407 const QCalendarWidgetPrivate * const d = d_func();-
2408 return
never executed: return d->m_model->m_dateFormats.value(date);
d->m_model->m_dateFormats.value(date);
never executed: return d->m_model->m_dateFormats.value(date);
0
2409}-
2410-
2411-
2412-
2413-
2414-
2415-
2416void QCalendarWidget::setDateTextFormat(const QDate &date, const QTextCharFormat &format)-
2417{-
2418 QCalendarWidgetPrivate * const d = d_func();-
2419 if (date.isNull()
date.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2420 d->m_model->m_dateFormats.clear();
never executed: d->m_model->m_dateFormats.clear();
0
2421 else-
2422 d->m_model->m_dateFormats[date] = format;
never executed: d->m_model->m_dateFormats[date] = format;
0
2423 d->m_view->viewport()->update();-
2424 d->m_view->updateGeometry();-
2425}
never executed: end of block
0
2426bool QCalendarWidget::isDateEditEnabled() const-
2427{-
2428 const QCalendarWidgetPrivate * const d = d_func();-
2429 return
never executed: return d->m_dateEditEnabled;
d->m_dateEditEnabled;
never executed: return d->m_dateEditEnabled;
0
2430}-
2431-
2432void QCalendarWidget::setDateEditEnabled(bool enable)-
2433{-
2434 QCalendarWidgetPrivate * const d = d_func();-
2435 if (isDateEditEnabled() == enable
isDateEditEnabled() == enableDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2436 return;
never executed: return;
0
2437-
2438 d->m_dateEditEnabled = enable;-
2439-
2440 d->setNavigatorEnabled(enable && (selectionMode() != QCalendarWidget::NoSelection));-
2441}
never executed: end of block
0
2442int QCalendarWidget::dateEditAcceptDelay() const-
2443{-
2444 const QCalendarWidgetPrivate * const d = d_func();-
2445 return
never executed: return d->m_navigator->dateEditAcceptDelay();
d->m_navigator->dateEditAcceptDelay();
never executed: return d->m_navigator->dateEditAcceptDelay();
0
2446}-
2447-
2448void QCalendarWidget::setDateEditAcceptDelay(int delay)-
2449{-
2450 QCalendarWidgetPrivate * const d = d_func();-
2451 d->m_navigator->setDateEditAcceptDelay(delay);-
2452}
never executed: end of block
0
2453void QCalendarWidget::updateCell(const QDate &date)-
2454{-
2455 if (__builtin_expect(!!(!date.isValid()), false)
__builtin_expe...lid()), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2456 QMessageLogger(__FILE__, 2920, __PRETTY_FUNCTION__).warning("QCalendarWidget::updateCell: Invalid date");-
2457 return;
never executed: return;
0
2458 }-
2459-
2460 if (!isVisible()
!isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2461 return;
never executed: return;
0
2462-
2463 QCalendarWidgetPrivate * const d = d_func();-
2464 int row, column;-
2465 d->m_model->cellForDate(date, &row, &column);-
2466 if (row == -1
row == -1Description
TRUEnever evaluated
FALSEnever evaluated
|| column == -1
column == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2467 return;
never executed: return;
0
2468-
2469 QModelIndex modelIndex = d->m_model->index(row, column);-
2470 if (!modelIndex.isValid()
!modelIndex.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2471 return;
never executed: return;
0
2472-
2473 d->m_view->viewport()->update(d->m_view->visualRect(modelIndex));-
2474}
never executed: end of block
0
2475void QCalendarWidget::updateCells()-
2476{-
2477 QCalendarWidgetPrivate * const d = d_func();-
2478 if (isVisible()
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2479 d->m_view->viewport()->update();
never executed: d->m_view->viewport()->update();
0
2480}
never executed: end of block
0
2481bool QCalendarWidget::isNavigationBarVisible() const-
2482{-
2483 const QCalendarWidgetPrivate * const d = d_func();-
2484 return
never executed: return d->navBarVisible;
d->navBarVisible;
never executed: return d->navBarVisible;
0
2485}-
2486-
2487-
2488void QCalendarWidget::setNavigationBarVisible(bool visible)-
2489{-
2490 QCalendarWidgetPrivate * const d = d_func();-
2491 d->navBarVisible = visible;-
2492 d->cachedSizeHint = QSize();-
2493 d->navBarBackground->setVisible(visible);-
2494 updateGeometry();-
2495}
never executed: end of block
0
2496-
2497-
2498-
2499-
2500bool QCalendarWidget::event(QEvent *event)-
2501{-
2502 QCalendarWidgetPrivate * const d = d_func();-
2503 switch (event->type()) {-
2504 case
never executed: case QEvent::LayoutDirectionChange:
QEvent::LayoutDirectionChange:
never executed: case QEvent::LayoutDirectionChange:
0
2505 d->updateButtonIcons();-
2506 break;
never executed: break;
0
2507 case
never executed: case QEvent::LocaleChange:
QEvent::LocaleChange:
never executed: case QEvent::LocaleChange:
0
2508 d->m_model->setFirstColumnDay(locale().firstDayOfWeek());-
2509 d->cachedSizeHint = QSize();-
2510 d->updateMonthMenuNames();-
2511 d->updateNavigationBar();-
2512 d->m_view->updateGeometry();-
2513 break;
never executed: break;
0
2514 case
never executed: case QEvent::FontChange:
QEvent::FontChange:
never executed: case QEvent::FontChange:
0
2515 case
never executed: case QEvent::ApplicationFontChange:
QEvent::ApplicationFontChange:
never executed: case QEvent::ApplicationFontChange:
0
2516 d->cachedSizeHint = QSize();-
2517 d->m_view->updateGeometry();-
2518 break;
never executed: break;
0
2519 case
never executed: case QEvent::StyleChange:
QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
2520 d->cachedSizeHint = QSize();-
2521 d->m_view->updateGeometry();-
2522 default
never executed: default:
:
never executed: default:
code before this statement never executed: default:
0
2523 break;
never executed: break;
0
2524 }-
2525 return
never executed: return QWidget::event(event);
QWidget::event(event);
never executed: return QWidget::event(event);
0
2526}-
2527-
2528-
2529-
2530-
2531bool QCalendarWidget::eventFilter(QObject *watched, QEvent *event)-
2532{-
2533 QCalendarWidgetPrivate * const d = d_func();-
2534 if (event->type() == QEvent::MouseButtonPress
event->type() ...useButtonPressDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->yearEdit->hasFocus()
d->yearEdit->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2535 QWidget *tlw = window();-
2536 QWidget *widget = static_cast<QWidget*>(watched);-
2537-
2538-
2539 if (widget->window() == tlw
widget->window() == tlwDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2540 QPoint mousePos = widget->mapTo(tlw, static_cast<QMouseEvent *>(event)->pos());-
2541 QRect geom = QRect(d->yearEdit->mapTo(tlw, QPoint(0, 0)), d->yearEdit->size());-
2542 if (!geom.contains(mousePos)
!geom.contains(mousePos)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2543 event->accept();-
2544 d->_q_yearEditingFinished();-
2545 setFocus();-
2546 return
never executed: return true;
true;
never executed: return true;
0
2547 }-
2548 }
never executed: end of block
0
2549 }
never executed: end of block
0
2550 return
never executed: return QWidget::eventFilter(watched, event);
QWidget::eventFilter(watched, event);
never executed: return QWidget::eventFilter(watched, event);
0
2551}-
2552-
2553-
2554-
2555-
2556void QCalendarWidget::mousePressEvent(QMouseEvent *event)-
2557{-
2558 setAttribute(Qt::WA_NoMouseReplay);-
2559 QWidget::mousePressEvent(event);-
2560 setFocus();-
2561}
never executed: end of block
0
2562-
2563-
2564-
2565-
2566void QCalendarWidget::resizeEvent(QResizeEvent * event)-
2567{-
2568 QCalendarWidgetPrivate * const d = d_func();-
2569-
2570-
2571-
2572-
2573 if(d->yearEdit->isVisible()
d->yearEdit->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
&& event->size().width() != event->oldSize().width()
event->size()....Size().width()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2574 d->_q_yearEditingFinished();
never executed: d->_q_yearEditingFinished();
0
2575-
2576 QWidget::resizeEvent(event);-
2577}
never executed: end of block
0
2578-
2579-
2580-
2581-
2582void QCalendarWidget::keyPressEvent(QKeyEvent * event)-
2583{-
2584 QCalendarWidgetPrivate * const d = d_func();-
2585 if (d->yearEdit->isVisible()
d->yearEdit->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
&& event->matches(QKeySequence::Cancel)
event->matches...uence::Cancel)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2586 d->yearEdit->setValue(yearShown());-
2587 d->_q_yearEditingFinished();-
2588 return;
never executed: return;
0
2589 }-
2590 QWidget::keyPressEvent(event);-
2591}
never executed: end of block
0
2592-
2593-
2594-
Switch to Source codePreprocessed file

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