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