| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qcalendarwidget.h" | - |
| 43 | | - |
| 44 | #ifndef QT_NO_CALENDARWIDGET | - |
| 45 | | - |
| 46 | #include <qabstractitemmodel.h> | - |
| 47 | #include <qitemdelegate.h> | - |
| 48 | #include <qdatetime.h> | - |
| 49 | #include <qtableview.h> | - |
| 50 | #include <qlayout.h> | - |
| 51 | #include <qevent.h> | - |
| 52 | #include <qtextformat.h> | - |
| 53 | #include <qheaderview.h> | - |
| 54 | #include <private/qwidget_p.h> | - |
| 55 | #include <qpushbutton.h> | - |
| 56 | #include <qtoolbutton.h> | - |
| 57 | #include <qlabel.h> | - |
| 58 | #include <qspinbox.h> | - |
| 59 | #include <qmenu.h> | - |
| 60 | #include <qapplication.h> | - |
| 61 | #include <qbasictimer.h> | - |
| 62 | #include <qstylepainter.h> | - |
| 63 | #include <private/qcalendartextnavigator_p.h> | - |
| 64 | | - |
| 65 | QT_BEGIN_NAMESPACE | - |
| 66 | | - |
| 67 | enum { | - |
| 68 | RowCount = 6, | - |
| 69 | ColumnCount = 7, | - |
| 70 | HeaderColumn = 0, | - |
| 71 | HeaderRow = 0, | - |
| 72 | MinimumDayOffset = 1 | - |
| 73 | }; | - |
| 74 | | - |
| 75 | class QCalendarDateSectionValidator | - |
| 76 | { | - |
| 77 | public: | - |
| 78 | | - |
| 79 | enum Section { | - |
| 80 | NextSection, | - |
| 81 | ThisSection, | - |
| 82 | PrevSection | - |
| 83 | }; | - |
| 84 | | - |
| 85 | QCalendarDateSectionValidator() {} | - |
| 86 | virtual ~QCalendarDateSectionValidator() {} | - |
| 87 | virtual Section handleKey(int key) = 0; | - |
| 88 | virtual QDate applyToDate(const QDate &date) const = 0; | - |
| 89 | virtual void setDate(const QDate &date) = 0; | - |
| 90 | virtual QString text() const = 0; | - |
| 91 | virtual QString text(const QDate &date, int repeat) const = 0; | - |
| 92 | | - |
| 93 | QLocale m_locale; | - |
| 94 | | - |
| 95 | protected: | - |
| 96 | QString highlightString(const QString &str, int pos) const; | - |
| 97 | private: | - |
| 98 | }; | - |
| 99 | | - |
| 100 | QString QCalendarDateSectionValidator::highlightString(const QString &str, int pos) const | - |
| 101 | { | - |
| 102 | if (pos == 0) never evaluated: pos == 0 | 0 |
| 103 | return QLatin1String("<b>") + str + QLatin1String("</b>"); never executed: return QLatin1String("<b>") + str + QLatin1String("</b>"); | 0 |
| 104 | int startPos = str.length() - pos; never executed (the execution status of this line is deduced): int startPos = str.length() - pos; | - |
| 105 | return str.mid(0, startPos) + QLatin1String("<b>") + str.mid(startPos, pos) + QLatin1String("</b>"); never executed: return str.mid(0, startPos) + QLatin1String("<b>") + str.mid(startPos, pos) + QLatin1String("</b>"); | 0 |
| 106 | | - |
| 107 | } | - |
| 108 | | - |
| 109 | class QCalendarDayValidator : public QCalendarDateSectionValidator | - |
| 110 | { | - |
| 111 | | - |
| 112 | public: | - |
| 113 | QCalendarDayValidator(); | - |
| 114 | virtual Section handleKey(int key); | - |
| 115 | virtual QDate applyToDate(const QDate &date) const; | - |
| 116 | virtual void setDate(const QDate &date); | - |
| 117 | virtual QString text() const; | - |
| 118 | virtual QString text(const QDate &date, int repeat) const; | - |
| 119 | private: | - |
| 120 | int m_pos; | - |
| 121 | int m_day; | - |
| 122 | int m_oldDay; | - |
| 123 | }; | - |
| 124 | | - |
| 125 | QCalendarDayValidator::QCalendarDayValidator() | - |
| 126 | : QCalendarDateSectionValidator(), m_pos(0), m_day(1), m_oldDay(1) | - |
| 127 | { | - |
| 128 | } | 0 |
| 129 | | - |
| 130 | QCalendarDateSectionValidator::Section QCalendarDayValidator::handleKey(int key) | - |
| 131 | { | - |
| 132 | if (key == Qt::Key_Right || key == Qt::Key_Left) { never evaluated: key == Qt::Key_Right never evaluated: key == Qt::Key_Left | 0 |
| 133 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 134 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 135 | } else if (key == Qt::Key_Up) { never evaluated: key == Qt::Key_Up | 0 |
| 136 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 137 | ++m_day; never executed (the execution status of this line is deduced): ++m_day; | - |
| 138 | if (m_day > 31) never evaluated: m_day > 31 | 0 |
| 139 | m_day = 1; never executed: m_day = 1; | 0 |
| 140 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 141 | } else if (key == Qt::Key_Down) { never evaluated: key == Qt::Key_Down | 0 |
| 142 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 143 | --m_day; never executed (the execution status of this line is deduced): --m_day; | - |
| 144 | if (m_day < 1) never evaluated: m_day < 1 | 0 |
| 145 | m_day = 31; never executed: m_day = 31; | 0 |
| 146 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 147 | } else if (key == Qt::Key_Back || key == Qt::Key_Backspace) { never evaluated: key == Qt::Key_Back never evaluated: key == Qt::Key_Backspace | 0 |
| 148 | --m_pos; never executed (the execution status of this line is deduced): --m_pos; | - |
| 149 | if (m_pos < 0) never evaluated: m_pos < 0 | 0 |
| 150 | m_pos = 1; never executed: m_pos = 1; | 0 |
| 151 | | - |
| 152 | if (m_pos == 0) never evaluated: m_pos == 0 | 0 |
| 153 | m_day = m_oldDay; never executed: m_day = m_oldDay; | 0 |
| 154 | else | - |
| 155 | m_day = m_day / 10; never executed: m_day = m_day / 10; | 0 |
| 156 | //m_day = m_oldDay / 10 * 10 + m_day / 10; | - |
| 157 | | - |
| 158 | if (m_pos == 0) never evaluated: m_pos == 0 | 0 |
| 159 | return QCalendarDateSectionValidator::PrevSection; never executed: return QCalendarDateSectionValidator::PrevSection; | 0 |
| 160 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 161 | } | - |
| 162 | if (key < Qt::Key_0 || key > Qt::Key_9) never evaluated: key < Qt::Key_0 never evaluated: key > Qt::Key_9 | 0 |
| 163 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 164 | int pressedKey = key - Qt::Key_0; never executed (the execution status of this line is deduced): int pressedKey = key - Qt::Key_0; | - |
| 165 | if (m_pos == 0) never evaluated: m_pos == 0 | 0 |
| 166 | m_day = pressedKey; never executed: m_day = pressedKey; | 0 |
| 167 | else | - |
| 168 | m_day = m_day % 10 * 10 + pressedKey; never executed: m_day = m_day % 10 * 10 + pressedKey; | 0 |
| 169 | if (m_day > 31) never evaluated: m_day > 31 | 0 |
| 170 | m_day = 31; never executed: m_day = 31; | 0 |
| 171 | ++m_pos; never executed (the execution status of this line is deduced): ++m_pos; | - |
| 172 | if (m_pos > 1) { never evaluated: m_pos > 1 | 0 |
| 173 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 174 | return QCalendarDateSectionValidator::NextSection; never executed: return QCalendarDateSectionValidator::NextSection; | 0 |
| 175 | } | - |
| 176 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 177 | } | - |
| 178 | | - |
| 179 | QDate QCalendarDayValidator::applyToDate(const QDate &date) const | - |
| 180 | { | - |
| 181 | int day = m_day; never executed (the execution status of this line is deduced): int day = m_day; | - |
| 182 | if (day < 1) | 0 |
| 183 | day = 1; | 0 |
| 184 | else if (day > 31) never evaluated: day > 31 | 0 |
| 185 | day = 31; never executed: day = 31; | 0 |
| 186 | if (day > date.daysInMonth()) never evaluated: day > date.daysInMonth() | 0 |
| 187 | day = date.daysInMonth(); never executed: day = date.daysInMonth(); | 0 |
| 188 | return QDate(date.year(), date.month(), day); never executed: return QDate(date.year(), date.month(), day); | 0 |
| 189 | } | - |
| 190 | | - |
| 191 | void QCalendarDayValidator::setDate(const QDate &date) | - |
| 192 | { | - |
| 193 | m_day = m_oldDay = date.day(); never executed (the execution status of this line is deduced): m_day = m_oldDay = date.day(); | - |
| 194 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 195 | } | 0 |
| 196 | | - |
| 197 | QString QCalendarDayValidator::text() const | - |
| 198 | { | - |
| 199 | QString str; never executed (the execution status of this line is deduced): QString str; | - |
| 200 | if (m_day / 10 == 0) never evaluated: m_day / 10 == 0 | 0 |
| 201 | str += QLatin1Char('0'); never executed: str += QLatin1Char('0'); | 0 |
| 202 | str += QString::number(m_day); never executed (the execution status of this line is deduced): str += QString::number(m_day); | - |
| 203 | return highlightString(str, m_pos); never executed: return highlightString(str, m_pos); | 0 |
| 204 | } | - |
| 205 | | - |
| 206 | QString QCalendarDayValidator::text(const QDate &date, int repeat) const | - |
| 207 | { | - |
| 208 | if (repeat <= 1) { never evaluated: repeat <= 1 | 0 |
| 209 | return QString::number(date.day()); never executed: return QString::number(date.day()); | 0 |
| 210 | } else if (repeat == 2) { never evaluated: repeat == 2 | 0 |
| 211 | QString str; never executed (the execution status of this line is deduced): QString str; | - |
| 212 | if (date.day() / 10 == 0) never evaluated: date.day() / 10 == 0 | 0 |
| 213 | str += QLatin1Char('0'); never executed: str += QLatin1Char('0'); | 0 |
| 214 | return str + QString::number(date.day()); never executed: return str + QString::number(date.day()); | 0 |
| 215 | } else if (repeat == 3) { never evaluated: repeat == 3 | 0 |
| 216 | return m_locale.dayName(date.dayOfWeek(), QLocale::ShortFormat); never executed: return m_locale.dayName(date.dayOfWeek(), QLocale::ShortFormat); | 0 |
| 217 | } else if (repeat >= 4) { never evaluated: repeat >= 4 | 0 |
| 218 | return m_locale.dayName(date.dayOfWeek(), QLocale::LongFormat); never executed: return m_locale.dayName(date.dayOfWeek(), QLocale::LongFormat); | 0 |
| 219 | } | - |
| 220 | return QString(); never executed: return QString(); | 0 |
| 221 | } | - |
| 222 | | - |
| 223 | ////////////////////////////////// | - |
| 224 | | - |
| 225 | class QCalendarMonthValidator : public QCalendarDateSectionValidator | - |
| 226 | { | - |
| 227 | | - |
| 228 | public: | - |
| 229 | QCalendarMonthValidator(); | - |
| 230 | virtual Section handleKey(int key); | - |
| 231 | virtual QDate applyToDate(const QDate &date) const; | - |
| 232 | virtual void setDate(const QDate &date); | - |
| 233 | virtual QString text() const; | - |
| 234 | virtual QString text(const QDate &date, int repeat) const; | - |
| 235 | private: | - |
| 236 | int m_pos; | - |
| 237 | int m_month; | - |
| 238 | int m_oldMonth; | - |
| 239 | }; | - |
| 240 | | - |
| 241 | QCalendarMonthValidator::QCalendarMonthValidator() | - |
| 242 | : QCalendarDateSectionValidator(), m_pos(0), m_month(1), m_oldMonth(1) | - |
| 243 | { | - |
| 244 | } | 0 |
| 245 | | - |
| 246 | QCalendarDateSectionValidator::Section QCalendarMonthValidator::handleKey(int key) | - |
| 247 | { | - |
| 248 | if (key == Qt::Key_Right || key == Qt::Key_Left) { never evaluated: key == Qt::Key_Right never evaluated: key == Qt::Key_Left | 0 |
| 249 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 250 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 251 | } else if (key == Qt::Key_Up) { never evaluated: key == Qt::Key_Up | 0 |
| 252 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 253 | ++m_month; never executed (the execution status of this line is deduced): ++m_month; | - |
| 254 | if (m_month > 12) never evaluated: m_month > 12 | 0 |
| 255 | m_month = 1; never executed: m_month = 1; | 0 |
| 256 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 257 | } else if (key == Qt::Key_Down) { never evaluated: key == Qt::Key_Down | 0 |
| 258 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 259 | --m_month; never executed (the execution status of this line is deduced): --m_month; | - |
| 260 | if (m_month < 1) never evaluated: m_month < 1 | 0 |
| 261 | m_month = 12; never executed: m_month = 12; | 0 |
| 262 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 263 | } else if (key == Qt::Key_Back || key == Qt::Key_Backspace) { never evaluated: key == Qt::Key_Back never evaluated: key == Qt::Key_Backspace | 0 |
| 264 | --m_pos; never executed (the execution status of this line is deduced): --m_pos; | - |
| 265 | if (m_pos < 0) never evaluated: m_pos < 0 | 0 |
| 266 | m_pos = 1; never executed: m_pos = 1; | 0 |
| 267 | | - |
| 268 | if (m_pos == 0) never evaluated: m_pos == 0 | 0 |
| 269 | m_month = m_oldMonth; never executed: m_month = m_oldMonth; | 0 |
| 270 | else | - |
| 271 | m_month = m_month / 10; never executed: m_month = m_month / 10; | 0 |
| 272 | //m_month = m_oldMonth / 10 * 10 + m_month / 10; | - |
| 273 | | - |
| 274 | if (m_pos == 0) never evaluated: m_pos == 0 | 0 |
| 275 | return QCalendarDateSectionValidator::PrevSection; never executed: return QCalendarDateSectionValidator::PrevSection; | 0 |
| 276 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 277 | } | - |
| 278 | if (key < Qt::Key_0 || key > Qt::Key_9) never evaluated: key < Qt::Key_0 never evaluated: key > Qt::Key_9 | 0 |
| 279 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 280 | int pressedKey = key - Qt::Key_0; never executed (the execution status of this line is deduced): int pressedKey = key - Qt::Key_0; | - |
| 281 | if (m_pos == 0) never evaluated: m_pos == 0 | 0 |
| 282 | m_month = pressedKey; never executed: m_month = pressedKey; | 0 |
| 283 | else | - |
| 284 | m_month = m_month % 10 * 10 + pressedKey; never executed: m_month = m_month % 10 * 10 + pressedKey; | 0 |
| 285 | if (m_month > 12) never evaluated: m_month > 12 | 0 |
| 286 | m_month = 12; never executed: m_month = 12; | 0 |
| 287 | ++m_pos; never executed (the execution status of this line is deduced): ++m_pos; | - |
| 288 | if (m_pos > 1) { never evaluated: m_pos > 1 | 0 |
| 289 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 290 | return QCalendarDateSectionValidator::NextSection; never executed: return QCalendarDateSectionValidator::NextSection; | 0 |
| 291 | } | - |
| 292 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 293 | } | - |
| 294 | | - |
| 295 | QDate QCalendarMonthValidator::applyToDate(const QDate &date) const | - |
| 296 | { | - |
| 297 | int month = m_month; never executed (the execution status of this line is deduced): int month = m_month; | - |
| 298 | if (month < 1) never evaluated: month < 1 | 0 |
| 299 | month = 1; never executed: month = 1; | 0 |
| 300 | else if (month > 12) never evaluated: month > 12 | 0 |
| 301 | month = 12; never executed: month = 12; | 0 |
| 302 | QDate newDate(date.year(), m_month, 1); never executed (the execution status of this line is deduced): QDate newDate(date.year(), m_month, 1); | - |
| 303 | int day = date.day(); never executed (the execution status of this line is deduced): int day = date.day(); | - |
| 304 | if (day > newDate.daysInMonth()) never evaluated: day > newDate.daysInMonth() | 0 |
| 305 | day = newDate.daysInMonth(); never executed: day = newDate.daysInMonth(); | 0 |
| 306 | return QDate(date.year(), month, day); never executed: return QDate(date.year(), month, day); | 0 |
| 307 | } | - |
| 308 | | - |
| 309 | void QCalendarMonthValidator::setDate(const QDate &date) | - |
| 310 | { | - |
| 311 | m_month = m_oldMonth = date.month(); never executed (the execution status of this line is deduced): m_month = m_oldMonth = date.month(); | - |
| 312 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 313 | } | 0 |
| 314 | | - |
| 315 | QString QCalendarMonthValidator::text() const | - |
| 316 | { | - |
| 317 | QString str; never executed (the execution status of this line is deduced): QString str; | - |
| 318 | if (m_month / 10 == 0) never evaluated: m_month / 10 == 0 | 0 |
| 319 | str += QLatin1Char('0'); never executed: str += QLatin1Char('0'); | 0 |
| 320 | str += QString::number(m_month); never executed (the execution status of this line is deduced): str += QString::number(m_month); | - |
| 321 | return highlightString(str, m_pos); never executed: return highlightString(str, m_pos); | 0 |
| 322 | } | - |
| 323 | | - |
| 324 | QString QCalendarMonthValidator::text(const QDate &date, int repeat) const | - |
| 325 | { | - |
| 326 | if (repeat <= 1) { never evaluated: repeat <= 1 | 0 |
| 327 | return QString::number(date.month()); never executed: return QString::number(date.month()); | 0 |
| 328 | } else if (repeat == 2) { never evaluated: repeat == 2 | 0 |
| 329 | QString str; never executed (the execution status of this line is deduced): QString str; | - |
| 330 | if (date.month() / 10 == 0) never evaluated: date.month() / 10 == 0 | 0 |
| 331 | str += QLatin1Char('0'); never executed: str += QLatin1Char('0'); | 0 |
| 332 | return str + QString::number(date.month()); never executed: return str + QString::number(date.month()); | 0 |
| 333 | } else if (repeat == 3) { never evaluated: repeat == 3 | 0 |
| 334 | return m_locale.standaloneMonthName(date.month(), QLocale::ShortFormat); never executed: return m_locale.standaloneMonthName(date.month(), QLocale::ShortFormat); | 0 |
| 335 | } else /*if (repeat >= 4)*/ { | - |
| 336 | return m_locale.standaloneMonthName(date.month(), QLocale::LongFormat); never executed: return m_locale.standaloneMonthName(date.month(), QLocale::LongFormat); | 0 |
| 337 | } | - |
| 338 | } | - |
| 339 | | - |
| 340 | ////////////////////////////////// | - |
| 341 | | - |
| 342 | class QCalendarYearValidator : public QCalendarDateSectionValidator | - |
| 343 | { | - |
| 344 | | - |
| 345 | public: | - |
| 346 | QCalendarYearValidator(); | - |
| 347 | virtual Section handleKey(int key); | - |
| 348 | virtual QDate applyToDate(const QDate &date) const; | - |
| 349 | virtual void setDate(const QDate &date); | - |
| 350 | virtual QString text() const; | - |
| 351 | virtual QString text(const QDate &date, int repeat) const; | - |
| 352 | private: | - |
| 353 | int pow10(int n); | - |
| 354 | int m_pos; | - |
| 355 | int m_year; | - |
| 356 | int m_oldYear; | - |
| 357 | }; | - |
| 358 | | - |
| 359 | QCalendarYearValidator::QCalendarYearValidator() | - |
| 360 | : QCalendarDateSectionValidator(), m_pos(0), m_year(2000), m_oldYear(2000) | - |
| 361 | { | - |
| 362 | } | 0 |
| 363 | | - |
| 364 | int QCalendarYearValidator::pow10(int n) | - |
| 365 | { | - |
| 366 | int power = 1; never executed (the execution status of this line is deduced): int power = 1; | - |
| 367 | for (int i = 0; i < n; i++) | 0 |
| 368 | power *= 10; never executed: power *= 10; | 0 |
| 369 | return power; never executed: return power; | 0 |
| 370 | } | - |
| 371 | | - |
| 372 | QCalendarDateSectionValidator::Section QCalendarYearValidator::handleKey(int key) | - |
| 373 | { | - |
| 374 | if (key == Qt::Key_Right || key == Qt::Key_Left) { never evaluated: key == Qt::Key_Right never evaluated: key == Qt::Key_Left | 0 |
| 375 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 376 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 377 | } else if (key == Qt::Key_Up) { never evaluated: key == Qt::Key_Up | 0 |
| 378 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 379 | ++m_year; never executed (the execution status of this line is deduced): ++m_year; | - |
| 380 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 381 | } else if (key == Qt::Key_Down) { never evaluated: key == Qt::Key_Down | 0 |
| 382 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 383 | --m_year; never executed (the execution status of this line is deduced): --m_year; | - |
| 384 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 385 | } else if (key == Qt::Key_Back || key == Qt::Key_Backspace) { never evaluated: key == Qt::Key_Back never evaluated: key == Qt::Key_Backspace | 0 |
| 386 | --m_pos; never executed (the execution status of this line is deduced): --m_pos; | - |
| 387 | if (m_pos < 0) never evaluated: m_pos < 0 | 0 |
| 388 | m_pos = 3; never executed: m_pos = 3; | 0 |
| 389 | | - |
| 390 | int pow = pow10(m_pos); never executed (the execution status of this line is deduced): int pow = pow10(m_pos); | - |
| 391 | m_year = m_oldYear / pow * pow + m_year % (pow * 10) / 10; never executed (the execution status of this line is deduced): m_year = m_oldYear / pow * pow + m_year % (pow * 10) / 10; | - |
| 392 | | - |
| 393 | if (m_pos == 0) never evaluated: m_pos == 0 | 0 |
| 394 | return QCalendarDateSectionValidator::PrevSection; never executed: return QCalendarDateSectionValidator::PrevSection; | 0 |
| 395 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 396 | } | - |
| 397 | if (key < Qt::Key_0 || key > Qt::Key_9) never evaluated: key < Qt::Key_0 never evaluated: key > Qt::Key_9 | 0 |
| 398 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 399 | int pressedKey = key - Qt::Key_0; never executed (the execution status of this line is deduced): int pressedKey = key - Qt::Key_0; | - |
| 400 | int pow = pow10(m_pos); never executed (the execution status of this line is deduced): int pow = pow10(m_pos); | - |
| 401 | m_year = m_year / (pow * 10) * (pow * 10) + m_year % pow * 10 + pressedKey; never executed (the execution status of this line is deduced): m_year = m_year / (pow * 10) * (pow * 10) + m_year % pow * 10 + pressedKey; | - |
| 402 | ++m_pos; never executed (the execution status of this line is deduced): ++m_pos; | - |
| 403 | if (m_pos > 3) { never evaluated: m_pos > 3 | 0 |
| 404 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 405 | return QCalendarDateSectionValidator::NextSection; never executed: return QCalendarDateSectionValidator::NextSection; | 0 |
| 406 | } | - |
| 407 | return QCalendarDateSectionValidator::ThisSection; never executed: return QCalendarDateSectionValidator::ThisSection; | 0 |
| 408 | } | - |
| 409 | | - |
| 410 | QDate QCalendarYearValidator::applyToDate(const QDate &date) const | - |
| 411 | { | - |
| 412 | int year = m_year; never executed (the execution status of this line is deduced): int year = m_year; | - |
| 413 | if (year < 1) never evaluated: year < 1 | 0 |
| 414 | year = 1; never executed: year = 1; | 0 |
| 415 | QDate newDate(year, date.month(), 1); never executed (the execution status of this line is deduced): QDate newDate(year, date.month(), 1); | - |
| 416 | int day = date.day(); never executed (the execution status of this line is deduced): int day = date.day(); | - |
| 417 | if (day > newDate.daysInMonth()) never evaluated: day > newDate.daysInMonth() | 0 |
| 418 | day = newDate.daysInMonth(); never executed: day = newDate.daysInMonth(); | 0 |
| 419 | return QDate(year, date.month(), day); never executed: return QDate(year, date.month(), day); | 0 |
| 420 | } | - |
| 421 | | - |
| 422 | void QCalendarYearValidator::setDate(const QDate &date) | - |
| 423 | { | - |
| 424 | m_year = m_oldYear = date.year(); never executed (the execution status of this line is deduced): m_year = m_oldYear = date.year(); | - |
| 425 | m_pos = 0; never executed (the execution status of this line is deduced): m_pos = 0; | - |
| 426 | } | 0 |
| 427 | | - |
| 428 | QString QCalendarYearValidator::text() const | - |
| 429 | { | - |
| 430 | QString str; never executed (the execution status of this line is deduced): QString str; | - |
| 431 | int pow = 10; never executed (the execution status of this line is deduced): int pow = 10; | - |
| 432 | for (int i = 0; i < 3; i++) { | 0 |
| 433 | if (m_year / pow == 0) never evaluated: m_year / pow == 0 | 0 |
| 434 | str += QLatin1Char('0'); never executed: str += QLatin1Char('0'); | 0 |
| 435 | pow *= 10; never executed (the execution status of this line is deduced): pow *= 10; | - |
| 436 | } | 0 |
| 437 | str += QString::number(m_year); never executed (the execution status of this line is deduced): str += QString::number(m_year); | - |
| 438 | return highlightString(str, m_pos); never executed: return highlightString(str, m_pos); | 0 |
| 439 | } | - |
| 440 | | - |
| 441 | QString QCalendarYearValidator::text(const QDate &date, int repeat) const | - |
| 442 | { | - |
| 443 | if (repeat < 4) { never evaluated: repeat < 4 | 0 |
| 444 | QString str; never executed (the execution status of this line is deduced): QString str; | - |
| 445 | int year = date.year() % 100; never executed (the execution status of this line is deduced): int year = date.year() % 100; | - |
| 446 | if (year / 10 == 0) never evaluated: year / 10 == 0 | 0 |
| 447 | str = QLatin1Char('0'); never executed: str = QLatin1Char('0'); | 0 |
| 448 | return str + QString::number(year); never executed: return str + QString::number(year); | 0 |
| 449 | } | - |
| 450 | return QString::number(date.year()); never executed: return QString::number(date.year()); | 0 |
| 451 | } | - |
| 452 | | - |
| 453 | /////////////////////////////////// | - |
| 454 | | - |
| 455 | class QCalendarDateValidator | - |
| 456 | { | - |
| 457 | public: | - |
| 458 | QCalendarDateValidator(); | - |
| 459 | ~QCalendarDateValidator(); | - |
| 460 | | - |
| 461 | void handleKeyEvent(QKeyEvent *keyEvent); | - |
| 462 | QString currentText() const; | - |
| 463 | QDate currentDate() const { return m_currentDate; } never executed: return m_currentDate; | 0 |
| 464 | void setFormat(const QString &format); | - |
| 465 | void setInitialDate(const QDate &date); | - |
| 466 | | - |
| 467 | void setLocale(const QLocale &locale); | - |
| 468 | | - |
| 469 | private: | - |
| 470 | | - |
| 471 | struct SectionToken { | - |
| 472 | SectionToken(QCalendarDateSectionValidator *val, int rep) : validator(val), repeat(rep) {} | 0 |
| 473 | QCalendarDateSectionValidator *validator; | - |
| 474 | int repeat; | - |
| 475 | }; | - |
| 476 | | - |
| 477 | void toNextToken(); | - |
| 478 | void toPreviousToken(); | - |
| 479 | void applyToDate(); | - |
| 480 | | - |
| 481 | int countRepeat(const QString &str, int index) const; | - |
| 482 | void clear(); | - |
| 483 | | - |
| 484 | QStringList m_separators; | - |
| 485 | QList<SectionToken *> m_tokens; | - |
| 486 | QCalendarDateSectionValidator *m_yearValidator; | - |
| 487 | QCalendarDateSectionValidator *m_monthValidator; | - |
| 488 | QCalendarDateSectionValidator *m_dayValidator; | - |
| 489 | | - |
| 490 | SectionToken *m_currentToken; | - |
| 491 | | - |
| 492 | QDate m_initialDate; | - |
| 493 | QDate m_currentDate; | - |
| 494 | | - |
| 495 | QCalendarDateSectionValidator::Section m_lastSectionMove; | - |
| 496 | }; | - |
| 497 | | - |
| 498 | QCalendarDateValidator::QCalendarDateValidator() | - |
| 499 | : m_currentToken(0), m_lastSectionMove(QCalendarDateSectionValidator::ThisSection) | - |
| 500 | { | - |
| 501 | m_initialDate = m_currentDate = QDate::currentDate(); never executed (the execution status of this line is deduced): m_initialDate = m_currentDate = QDate::currentDate(); | - |
| 502 | m_yearValidator = new QCalendarYearValidator(); never executed (the execution status of this line is deduced): m_yearValidator = new QCalendarYearValidator(); | - |
| 503 | m_monthValidator = new QCalendarMonthValidator(); never executed (the execution status of this line is deduced): m_monthValidator = new QCalendarMonthValidator(); | - |
| 504 | m_dayValidator = new QCalendarDayValidator(); never executed (the execution status of this line is deduced): m_dayValidator = new QCalendarDayValidator(); | - |
| 505 | } | 0 |
| 506 | | - |
| 507 | void QCalendarDateValidator::setLocale(const QLocale &locale) | - |
| 508 | { | - |
| 509 | m_yearValidator->m_locale = locale; never executed (the execution status of this line is deduced): m_yearValidator->m_locale = locale; | - |
| 510 | m_monthValidator->m_locale = locale; never executed (the execution status of this line is deduced): m_monthValidator->m_locale = locale; | - |
| 511 | m_dayValidator->m_locale = locale; never executed (the execution status of this line is deduced): m_dayValidator->m_locale = locale; | - |
| 512 | } | 0 |
| 513 | | - |
| 514 | QCalendarDateValidator::~QCalendarDateValidator() | - |
| 515 | { | - |
| 516 | delete m_yearValidator; never executed (the execution status of this line is deduced): delete m_yearValidator; | - |
| 517 | delete m_monthValidator; never executed (the execution status of this line is deduced): delete m_monthValidator; | - |
| 518 | delete m_dayValidator; never executed (the execution status of this line is deduced): delete m_dayValidator; | - |
| 519 | clear(); never executed (the execution status of this line is deduced): clear(); | - |
| 520 | } | 0 |
| 521 | | - |
| 522 | // from qdatetime.cpp | - |
| 523 | int QCalendarDateValidator::countRepeat(const QString &str, int index) const | - |
| 524 | { | - |
| 525 | Q_ASSERT(index >= 0 && index < str.size()); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 526 | int count = 1; never executed (the execution status of this line is deduced): int count = 1; | - |
| 527 | const QChar ch = str.at(index); never executed (the execution status of this line is deduced): const QChar ch = str.at(index); | - |
| 528 | while (index + count < str.size() && str.at(index + count) == ch) never evaluated: index + count < str.size() never evaluated: str.at(index + count) == ch | 0 |
| 529 | ++count; | 0 |
| 530 | return count; never executed: return count; | 0 |
| 531 | } | - |
| 532 | | - |
| 533 | void QCalendarDateValidator::setInitialDate(const QDate &date) | - |
| 534 | { | - |
| 535 | m_yearValidator->setDate(date); never executed (the execution status of this line is deduced): m_yearValidator->setDate(date); | - |
| 536 | m_monthValidator->setDate(date); never executed (the execution status of this line is deduced): m_monthValidator->setDate(date); | - |
| 537 | m_dayValidator->setDate(date); never executed (the execution status of this line is deduced): m_dayValidator->setDate(date); | - |
| 538 | m_initialDate = date; never executed (the execution status of this line is deduced): m_initialDate = date; | - |
| 539 | m_currentDate = date; never executed (the execution status of this line is deduced): m_currentDate = date; | - |
| 540 | m_lastSectionMove = QCalendarDateSectionValidator::ThisSection; never executed (the execution status of this line is deduced): m_lastSectionMove = QCalendarDateSectionValidator::ThisSection; | - |
| 541 | } | 0 |
| 542 | | - |
| 543 | QString QCalendarDateValidator::currentText() const | - |
| 544 | { | - |
| 545 | QString str; never executed (the execution status of this line is deduced): QString str; | - |
| 546 | QStringListIterator itSep(m_separators); never executed (the execution status of this line is deduced): QStringListIterator itSep(m_separators); | - |
| 547 | QListIterator<SectionToken *> itTok(m_tokens); never executed (the execution status of this line is deduced): QListIterator<SectionToken *> itTok(m_tokens); | - |
| 548 | while (itSep.hasNext()) { never evaluated: itSep.hasNext() | 0 |
| 549 | str += itSep.next(); never executed (the execution status of this line is deduced): str += itSep.next(); | - |
| 550 | if (itTok.hasNext()) { never evaluated: itTok.hasNext() | 0 |
| 551 | SectionToken *token = itTok.next(); never executed (the execution status of this line is deduced): SectionToken *token = itTok.next(); | - |
| 552 | QCalendarDateSectionValidator *validator = token->validator; never executed (the execution status of this line is deduced): QCalendarDateSectionValidator *validator = token->validator; | - |
| 553 | if (m_currentToken == token) never evaluated: m_currentToken == token | 0 |
| 554 | str += validator->text(); never executed: str += validator->text(); | 0 |
| 555 | else | - |
| 556 | str += validator->text(m_currentDate, token->repeat); never executed: str += validator->text(m_currentDate, token->repeat); | 0 |
| 557 | } | - |
| 558 | } | 0 |
| 559 | return str; never executed: return str; | 0 |
| 560 | } | - |
| 561 | | - |
| 562 | void QCalendarDateValidator::clear() | - |
| 563 | { | - |
| 564 | QListIterator<SectionToken *> it(m_tokens); never executed (the execution status of this line is deduced): QListIterator<SectionToken *> it(m_tokens); | - |
| 565 | while (it.hasNext()) never evaluated: it.hasNext() | 0 |
| 566 | delete it.next(); never executed: delete it.next(); | 0 |
| 567 | | - |
| 568 | m_tokens.clear(); never executed (the execution status of this line is deduced): m_tokens.clear(); | - |
| 569 | m_separators.clear(); never executed (the execution status of this line is deduced): m_separators.clear(); | - |
| 570 | | - |
| 571 | m_currentToken = 0; never executed (the execution status of this line is deduced): m_currentToken = 0; | - |
| 572 | } | 0 |
| 573 | | - |
| 574 | void QCalendarDateValidator::setFormat(const QString &format) | - |
| 575 | { | - |
| 576 | clear(); never executed (the execution status of this line is deduced): clear(); | - |
| 577 | | - |
| 578 | int pos = 0; never executed (the execution status of this line is deduced): int pos = 0; | - |
| 579 | const QLatin1Char quote('\''); never executed (the execution status of this line is deduced): const QLatin1Char quote('\''); | - |
| 580 | bool quoting = false; never executed (the execution status of this line is deduced): bool quoting = false; | - |
| 581 | QString separator; never executed (the execution status of this line is deduced): QString separator; | - |
| 582 | while (pos < format.size()) { never evaluated: pos < format.size() | 0 |
| 583 | QString mid = format.mid(pos); never executed (the execution status of this line is deduced): QString mid = format.mid(pos); | - |
| 584 | int offset = 1; never executed (the execution status of this line is deduced): int offset = 1; | - |
| 585 | | - |
| 586 | if (mid.startsWith(quote)) { never evaluated: mid.startsWith(quote) | 0 |
| 587 | quoting = !quoting; never executed (the execution status of this line is deduced): quoting = !quoting; | - |
| 588 | } else { | 0 |
| 589 | const QChar nextChar = format.at(pos); never executed (the execution status of this line is deduced): const QChar nextChar = format.at(pos); | - |
| 590 | if (quoting) { | 0 |
| 591 | separator += nextChar; never executed (the execution status of this line is deduced): separator += nextChar; | - |
| 592 | } else { | 0 |
| 593 | SectionToken *token = 0; never executed (the execution status of this line is deduced): SectionToken *token = 0; | - |
| 594 | if (nextChar == QLatin1Char('d')) { never evaluated: nextChar == QLatin1Char('d') | 0 |
| 595 | offset = qMin(4, countRepeat(format, pos)); never executed (the execution status of this line is deduced): offset = qMin(4, countRepeat(format, pos)); | - |
| 596 | token = new SectionToken(m_dayValidator, offset); never executed (the execution status of this line is deduced): token = new SectionToken(m_dayValidator, offset); | - |
| 597 | } else if (nextChar == QLatin1Char('M')) { never executed: } never evaluated: nextChar == QLatin1Char('M') | 0 |
| 598 | offset = qMin(4, countRepeat(format, pos)); never executed (the execution status of this line is deduced): offset = qMin(4, countRepeat(format, pos)); | - |
| 599 | token = new SectionToken(m_monthValidator, offset); never executed (the execution status of this line is deduced): token = new SectionToken(m_monthValidator, offset); | - |
| 600 | } else if (nextChar == QLatin1Char('y')) { never executed: } never evaluated: nextChar == QLatin1Char('y') | 0 |
| 601 | offset = qMin(4, countRepeat(format, pos)); never executed (the execution status of this line is deduced): offset = qMin(4, countRepeat(format, pos)); | - |
| 602 | token = new SectionToken(m_yearValidator, offset); never executed (the execution status of this line is deduced): token = new SectionToken(m_yearValidator, offset); | - |
| 603 | } else { | 0 |
| 604 | separator += nextChar; never executed (the execution status of this line is deduced): separator += nextChar; | - |
| 605 | } | 0 |
| 606 | if (token) { | 0 |
| 607 | m_tokens.append(token); never executed (the execution status of this line is deduced): m_tokens.append(token); | - |
| 608 | m_separators.append(separator); never executed (the execution status of this line is deduced): m_separators.append(separator); | - |
| 609 | separator = QString(); never executed (the execution status of this line is deduced): separator = QString(); | - |
| 610 | if (!m_currentToken) never evaluated: !m_currentToken | 0 |
| 611 | m_currentToken = token; never executed: m_currentToken = token; | 0 |
| 612 | | - |
| 613 | } | 0 |
| 614 | } | 0 |
| 615 | } | - |
| 616 | pos += offset; never executed (the execution status of this line is deduced): pos += offset; | - |
| 617 | } | 0 |
| 618 | m_separators += separator; never executed (the execution status of this line is deduced): m_separators += separator; | - |
| 619 | } | 0 |
| 620 | | - |
| 621 | void QCalendarDateValidator::applyToDate() | - |
| 622 | { | - |
| 623 | m_currentDate = m_yearValidator->applyToDate(m_currentDate); never executed (the execution status of this line is deduced): m_currentDate = m_yearValidator->applyToDate(m_currentDate); | - |
| 624 | m_currentDate = m_monthValidator->applyToDate(m_currentDate); never executed (the execution status of this line is deduced): m_currentDate = m_monthValidator->applyToDate(m_currentDate); | - |
| 625 | m_currentDate = m_dayValidator->applyToDate(m_currentDate); never executed (the execution status of this line is deduced): m_currentDate = m_dayValidator->applyToDate(m_currentDate); | - |
| 626 | } | 0 |
| 627 | | - |
| 628 | void QCalendarDateValidator::toNextToken() | - |
| 629 | { | - |
| 630 | const int idx = m_tokens.indexOf(m_currentToken); never executed (the execution status of this line is deduced): const int idx = m_tokens.indexOf(m_currentToken); | - |
| 631 | if (idx == -1) never evaluated: idx == -1 | 0 |
| 632 | return; | 0 |
| 633 | if (idx + 1 >= m_tokens.count()) never evaluated: idx + 1 >= m_tokens.count() | 0 |
| 634 | m_currentToken = m_tokens.first(); never executed: m_currentToken = m_tokens.first(); | 0 |
| 635 | else | - |
| 636 | m_currentToken = m_tokens.at(idx + 1); never executed: m_currentToken = m_tokens.at(idx + 1); | 0 |
| 637 | } | - |
| 638 | | - |
| 639 | void QCalendarDateValidator::toPreviousToken() | - |
| 640 | { | - |
| 641 | const int idx = m_tokens.indexOf(m_currentToken); never executed (the execution status of this line is deduced): const int idx = m_tokens.indexOf(m_currentToken); | - |
| 642 | if (idx == -1) never evaluated: idx == -1 | 0 |
| 643 | return; | 0 |
| 644 | if (idx - 1 < 0) never evaluated: idx - 1 < 0 | 0 |
| 645 | m_currentToken = m_tokens.last(); never executed: m_currentToken = m_tokens.last(); | 0 |
| 646 | else | - |
| 647 | m_currentToken = m_tokens.at(idx - 1); never executed: m_currentToken = m_tokens.at(idx - 1); | 0 |
| 648 | } | - |
| 649 | | - |
| 650 | void QCalendarDateValidator::handleKeyEvent(QKeyEvent *keyEvent) | - |
| 651 | { | - |
| 652 | if (!m_currentToken) never evaluated: !m_currentToken | 0 |
| 653 | return; | 0 |
| 654 | | - |
| 655 | int key = keyEvent->key(); never executed (the execution status of this line is deduced): int key = keyEvent->key(); | - |
| 656 | if (m_lastSectionMove == QCalendarDateSectionValidator::NextSection) { never evaluated: m_lastSectionMove == QCalendarDateSectionValidator::NextSection | 0 |
| 657 | if (key == Qt::Key_Back || key == Qt::Key_Backspace) never evaluated: key == Qt::Key_Back never evaluated: key == Qt::Key_Backspace | 0 |
| 658 | toPreviousToken(); never executed: toPreviousToken(); | 0 |
| 659 | } | 0 |
| 660 | if (key == Qt::Key_Right) never evaluated: key == Qt::Key_Right | 0 |
| 661 | toNextToken(); never executed: toNextToken(); | 0 |
| 662 | else if (key == Qt::Key_Left) never evaluated: key == Qt::Key_Left | 0 |
| 663 | toPreviousToken(); never executed: toPreviousToken(); | 0 |
| 664 | | - |
| 665 | m_lastSectionMove = m_currentToken->validator->handleKey(key); never executed (the execution status of this line is deduced): m_lastSectionMove = m_currentToken->validator->handleKey(key); | - |
| 666 | | - |
| 667 | applyToDate(); never executed (the execution status of this line is deduced): applyToDate(); | - |
| 668 | if (m_lastSectionMove == QCalendarDateSectionValidator::NextSection) never evaluated: m_lastSectionMove == QCalendarDateSectionValidator::NextSection | 0 |
| 669 | toNextToken(); never executed: toNextToken(); | 0 |
| 670 | else if (m_lastSectionMove == QCalendarDateSectionValidator::PrevSection) never evaluated: m_lastSectionMove == QCalendarDateSectionValidator::PrevSection | 0 |
| 671 | toPreviousToken(); never executed: toPreviousToken(); | 0 |
| 672 | } | - |
| 673 | | - |
| 674 | QWidget *QCalendarTextNavigator::widget() const | - |
| 675 | { | - |
| 676 | return m_widget; executed: return m_widget;Execution Count:29 | 29 |
| 677 | } | - |
| 678 | | - |
| 679 | void QCalendarTextNavigator::setWidget(QWidget *widget) | - |
| 680 | { | - |
| 681 | m_widget = widget; executed (the execution status of this line is deduced): m_widget = widget; | - |
| 682 | } executed: }Execution Count:29 | 29 |
| 683 | | - |
| 684 | QDate QCalendarTextNavigator::date() const | - |
| 685 | { | - |
| 686 | return m_date; never executed: return m_date; | 0 |
| 687 | } | - |
| 688 | | - |
| 689 | void QCalendarTextNavigator::setDate(const QDate &date) | - |
| 690 | { | - |
| 691 | m_date = date; executed (the execution status of this line is deduced): m_date = date; | - |
| 692 | } executed: }Execution Count:8 | 8 |
| 693 | | - |
| 694 | void QCalendarTextNavigator::updateDateLabel() | - |
| 695 | { | - |
| 696 | if (!m_widget) never evaluated: !m_widget | 0 |
| 697 | return; | 0 |
| 698 | | - |
| 699 | m_acceptTimer.start(m_editDelay, this); never executed (the execution status of this line is deduced): m_acceptTimer.start(m_editDelay, this); | - |
| 700 | | - |
| 701 | m_dateText->setText(m_dateValidator->currentText()); never executed (the execution status of this line is deduced): m_dateText->setText(m_dateValidator->currentText()); | - |
| 702 | | - |
| 703 | QSize s = m_dateFrame->sizeHint(); never executed (the execution status of this line is deduced): QSize s = m_dateFrame->sizeHint(); | - |
| 704 | QRect r = m_widget->geometry(); // later, just the table section never executed (the execution status of this line is deduced): QRect r = m_widget->geometry(); | - |
| 705 | QRect newRect((r.width() - s.width()) / 2, (r.height() - s.height()) / 2, s.width(), s.height()); never executed (the execution status of this line is deduced): QRect newRect((r.width() - s.width()) / 2, (r.height() - s.height()) / 2, s.width(), s.height()); | - |
| 706 | m_dateFrame->setGeometry(newRect); never executed (the execution status of this line is deduced): m_dateFrame->setGeometry(newRect); | - |
| 707 | // need to set palette after geometry update as phonestyle sets transparency | - |
| 708 | // effect in move event. | - |
| 709 | QPalette p = m_dateFrame->palette(); never executed (the execution status of this line is deduced): QPalette p = m_dateFrame->palette(); | - |
| 710 | p.setBrush(QPalette::Window, m_dateFrame->window()->palette().brush(QPalette::Window)); never executed (the execution status of this line is deduced): p.setBrush(QPalette::Window, m_dateFrame->window()->palette().brush(QPalette::Window)); | - |
| 711 | m_dateFrame->setPalette(p); never executed (the execution status of this line is deduced): m_dateFrame->setPalette(p); | - |
| 712 | | - |
| 713 | m_dateFrame->raise(); never executed (the execution status of this line is deduced): m_dateFrame->raise(); | - |
| 714 | m_dateFrame->show(); never executed (the execution status of this line is deduced): m_dateFrame->show(); | - |
| 715 | } | 0 |
| 716 | | - |
| 717 | void QCalendarTextNavigator::applyDate() | - |
| 718 | { | - |
| 719 | QDate date = m_dateValidator->currentDate(); never executed (the execution status of this line is deduced): QDate date = m_dateValidator->currentDate(); | - |
| 720 | if (m_date == date) never evaluated: m_date == date | 0 |
| 721 | return; | 0 |
| 722 | | - |
| 723 | m_date = date; never executed (the execution status of this line is deduced): m_date = date; | - |
| 724 | emit dateChanged(date); never executed (the execution status of this line is deduced): dateChanged(date); | - |
| 725 | } | 0 |
| 726 | | - |
| 727 | void QCalendarTextNavigator::createDateLabel() | - |
| 728 | { | - |
| 729 | if (m_dateFrame) never evaluated: m_dateFrame | 0 |
| 730 | return; | 0 |
| 731 | m_dateFrame = new QFrame(m_widget); never executed (the execution status of this line is deduced): m_dateFrame = new QFrame(m_widget); | - |
| 732 | QVBoxLayout *vl = new QVBoxLayout; never executed (the execution status of this line is deduced): QVBoxLayout *vl = new QVBoxLayout; | - |
| 733 | m_dateText = new QLabel; never executed (the execution status of this line is deduced): m_dateText = new QLabel; | - |
| 734 | vl->addWidget(m_dateText); never executed (the execution status of this line is deduced): vl->addWidget(m_dateText); | - |
| 735 | m_dateFrame->setLayout(vl); never executed (the execution status of this line is deduced): m_dateFrame->setLayout(vl); | - |
| 736 | m_dateFrame->setFrameShadow(QFrame::Plain); never executed (the execution status of this line is deduced): m_dateFrame->setFrameShadow(QFrame::Plain); | - |
| 737 | m_dateFrame->setFrameShape(QFrame::Box); never executed (the execution status of this line is deduced): m_dateFrame->setFrameShape(QFrame::Box); | - |
| 738 | m_dateValidator = new QCalendarDateValidator(); never executed (the execution status of this line is deduced): m_dateValidator = new QCalendarDateValidator(); | - |
| 739 | m_dateValidator->setLocale(m_widget->locale()); never executed (the execution status of this line is deduced): m_dateValidator->setLocale(m_widget->locale()); | - |
| 740 | m_dateValidator->setFormat(m_widget->locale().dateFormat(QLocale::ShortFormat)); never executed (the execution status of this line is deduced): m_dateValidator->setFormat(m_widget->locale().dateFormat(QLocale::ShortFormat)); | - |
| 741 | m_dateValidator->setInitialDate(m_date); never executed (the execution status of this line is deduced): m_dateValidator->setInitialDate(m_date); | - |
| 742 | | - |
| 743 | m_dateFrame->setAutoFillBackground(true); never executed (the execution status of this line is deduced): m_dateFrame->setAutoFillBackground(true); | - |
| 744 | m_dateFrame->setBackgroundRole(QPalette::Window); never executed (the execution status of this line is deduced): m_dateFrame->setBackgroundRole(QPalette::Window); | - |
| 745 | } | 0 |
| 746 | | - |
| 747 | void QCalendarTextNavigator::removeDateLabel() | - |
| 748 | { | - |
| 749 | if (!m_dateFrame) never evaluated: !m_dateFrame | 0 |
| 750 | return; | 0 |
| 751 | m_acceptTimer.stop(); never executed (the execution status of this line is deduced): m_acceptTimer.stop(); | - |
| 752 | m_dateFrame->hide(); never executed (the execution status of this line is deduced): m_dateFrame->hide(); | - |
| 753 | m_dateFrame->deleteLater(); never executed (the execution status of this line is deduced): m_dateFrame->deleteLater(); | - |
| 754 | delete m_dateValidator; never executed (the execution status of this line is deduced): delete m_dateValidator; | - |
| 755 | m_dateFrame = 0; never executed (the execution status of this line is deduced): m_dateFrame = 0; | - |
| 756 | m_dateText = 0; never executed (the execution status of this line is deduced): m_dateText = 0; | - |
| 757 | m_dateValidator = 0; never executed (the execution status of this line is deduced): m_dateValidator = 0; | - |
| 758 | } | 0 |
| 759 | | - |
| 760 | bool QCalendarTextNavigator::eventFilter(QObject *o, QEvent *e) | - |
| 761 | { | - |
| 762 | if (m_widget) { partially evaluated: m_widget| yes Evaluation Count:563 | no Evaluation Count:0 |
| 0-563 |
| 763 | if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) { evaluated: e->type() == QEvent::KeyPress| yes Evaluation Count:1 | yes Evaluation Count:562 |
evaluated: e->type() == QEvent::KeyRelease| yes Evaluation Count:1 | yes Evaluation Count:561 |
| 1-562 |
| 764 | QKeyEvent* ke = (QKeyEvent*)e; executed (the execution status of this line is deduced): QKeyEvent* ke = (QKeyEvent*)e; | - |
| 765 | if ((ke->text().length() > 0 && ke->text()[0].isPrint()) || m_dateFrame) { partially evaluated: ke->text().length() > 0| no Evaluation Count:0 | yes Evaluation Count:2 |
never evaluated: ke->text()[0].isPrint() partially evaluated: m_dateFrame| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 766 | if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Select) { never evaluated: ke->key() == Qt::Key_Return never evaluated: ke->key() == Qt::Key_Enter never evaluated: ke->key() == Qt::Key_Select | 0 |
| 767 | applyDate(); never executed (the execution status of this line is deduced): applyDate(); | - |
| 768 | emit editingFinished(); never executed (the execution status of this line is deduced): editingFinished(); | - |
| 769 | removeDateLabel(); never executed (the execution status of this line is deduced): removeDateLabel(); | - |
| 770 | } else if (ke->key() == Qt::Key_Escape) { never executed: } never evaluated: ke->key() == Qt::Key_Escape | 0 |
| 771 | removeDateLabel(); never executed (the execution status of this line is deduced): removeDateLabel(); | - |
| 772 | } else if (e->type() == QEvent::KeyPress) { never executed: } never evaluated: e->type() == QEvent::KeyPress | 0 |
| 773 | createDateLabel(); never executed (the execution status of this line is deduced): createDateLabel(); | - |
| 774 | m_dateValidator->handleKeyEvent(ke); never executed (the execution status of this line is deduced): m_dateValidator->handleKeyEvent(ke); | - |
| 775 | updateDateLabel(); never executed (the execution status of this line is deduced): updateDateLabel(); | - |
| 776 | } | 0 |
| 777 | ke->accept(); never executed (the execution status of this line is deduced): ke->accept(); | - |
| 778 | return true; never executed: return true; | 0 |
| 779 | } | - |
| 780 | // If we are navigating let the user finish his date in old locate. | - |
| 781 | // If we change our mind and want it to update immediately simply uncomment below | - |
| 782 | /* | - |
| 783 | } else if (e->type() == QEvent::LocaleChange) { | - |
| 784 | if (m_dateValidator) { | - |
| 785 | m_dateValidator->setLocale(m_widget->locale()); | - |
| 786 | m_dateValidator->setFormat(m_widget->locale().dateFormat(QLocale::ShortFormat)); | - |
| 787 | updateDateLabel(); | - |
| 788 | } | - |
| 789 | */ | - |
| 790 | } executed: }Execution Count:2 | 2 |
| 791 | } executed: }Execution Count:563 | 563 |
| 792 | return QObject::eventFilter(o,e); executed: return QObject::eventFilter(o,e);Execution Count:563 | 563 |
| 793 | } | - |
| 794 | | - |
| 795 | void QCalendarTextNavigator::timerEvent(QTimerEvent *e) | - |
| 796 | { | - |
| 797 | if (e->timerId() == m_acceptTimer.timerId()) { never evaluated: e->timerId() == m_acceptTimer.timerId() | 0 |
| 798 | applyDate(); never executed (the execution status of this line is deduced): applyDate(); | - |
| 799 | removeDateLabel(); never executed (the execution status of this line is deduced): removeDateLabel(); | - |
| 800 | } | 0 |
| 801 | } | 0 |
| 802 | | - |
| 803 | int QCalendarTextNavigator::dateEditAcceptDelay() const | - |
| 804 | { | - |
| 805 | return m_editDelay; never executed: return m_editDelay; | 0 |
| 806 | } | - |
| 807 | | - |
| 808 | void QCalendarTextNavigator::setDateEditAcceptDelay(int delay) | - |
| 809 | { | - |
| 810 | m_editDelay = delay; never executed (the execution status of this line is deduced): m_editDelay = delay; | - |
| 811 | } | 0 |
| 812 | | - |
| 813 | class QCalendarView; | - |
| 814 | | - |
| 815 | class QCalendarModel : public QAbstractTableModel | - |
| 816 | { | - |
| 817 | Q_OBJECT | - |
| 818 | public: | - |
| 819 | QCalendarModel(QObject *parent = 0); | - |
| 820 | | - |
| 821 | int rowCount(const QModelIndex &) const | - |
| 822 | { return RowCount + m_firstRow; } executed: return RowCount + m_firstRow;Execution Count:7687 | 7687 |
| 823 | int columnCount(const QModelIndex &) const | - |
| 824 | { return ColumnCount + m_firstColumn; } executed: return ColumnCount + m_firstColumn;Execution Count:8212 | 8212 |
| 825 | QVariant data(const QModelIndex &index, int role) const; | - |
| 826 | Qt::ItemFlags flags(const QModelIndex &index) const; | - |
| 827 | | - |
| 828 | bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) | - |
| 829 | { | - |
| 830 | beginInsertRows(parent, row, row + count - 1); executed (the execution status of this line is deduced): beginInsertRows(parent, row, row + count - 1); | - |
| 831 | endInsertRows(); executed (the execution status of this line is deduced): endInsertRows(); | - |
| 832 | return true; executed: return true;Execution Count:1 | 1 |
| 833 | } | - |
| 834 | bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) | - |
| 835 | { | - |
| 836 | beginInsertColumns(parent, column, column + count - 1); never executed (the execution status of this line is deduced): beginInsertColumns(parent, column, column + count - 1); | - |
| 837 | endInsertColumns(); never executed (the execution status of this line is deduced): endInsertColumns(); | - |
| 838 | return true; never executed: return true; | 0 |
| 839 | } | - |
| 840 | bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) | - |
| 841 | { | - |
| 842 | beginRemoveRows(parent, row, row + count - 1); executed (the execution status of this line is deduced): beginRemoveRows(parent, row, row + count - 1); | - |
| 843 | endRemoveRows(); executed (the execution status of this line is deduced): endRemoveRows(); | - |
| 844 | return true; executed: return true;Execution Count:1 | 1 |
| 845 | } | - |
| 846 | bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) | - |
| 847 | { | - |
| 848 | beginRemoveColumns(parent, column, column + count - 1); executed (the execution status of this line is deduced): beginRemoveColumns(parent, column, column + count - 1); | - |
| 849 | endRemoveColumns(); executed (the execution status of this line is deduced): endRemoveColumns(); | - |
| 850 | return true; executed: return true;Execution Count:5 | 5 |
| 851 | } | - |
| 852 | | - |
| 853 | void showMonth(int year, int month); | - |
| 854 | void setDate(const QDate &d); | - |
| 855 | | - |
| 856 | void setMinimumDate(const QDate &date); | - |
| 857 | void setMaximumDate(const QDate &date); | - |
| 858 | | - |
| 859 | void setRange(const QDate &min, const QDate &max); | - |
| 860 | | - |
| 861 | void setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat format); | - |
| 862 | | - |
| 863 | void setFirstColumnDay(Qt::DayOfWeek dayOfWeek); | - |
| 864 | Qt::DayOfWeek firstColumnDay() const; | - |
| 865 | | - |
| 866 | bool weekNumbersShown() const; | - |
| 867 | void setWeekNumbersShown(bool show); | - |
| 868 | | - |
| 869 | QTextCharFormat formatForCell(int row, int col) const; | - |
| 870 | Qt::DayOfWeek dayOfWeekForColumn(int section) const; | - |
| 871 | int columnForDayOfWeek(Qt::DayOfWeek day) const; | - |
| 872 | QDate dateForCell(int row, int column) const; | - |
| 873 | void cellForDate(const QDate &date, int *row, int *column) const; | - |
| 874 | QString dayName(Qt::DayOfWeek day) const; | - |
| 875 | | - |
| 876 | void setView(QCalendarView *view) | - |
| 877 | { m_view = view; } executed: }Execution Count:27 | 27 |
| 878 | | - |
| 879 | void internalUpdate(); | - |
| 880 | QDate referenceDate() const; | - |
| 881 | int columnForFirstOfMonth(const QDate &date) const; | - |
| 882 | | - |
| 883 | int m_firstColumn; | - |
| 884 | int m_firstRow; | - |
| 885 | QDate m_date; | - |
| 886 | QDate m_minimumDate; | - |
| 887 | QDate m_maximumDate; | - |
| 888 | int m_shownYear; | - |
| 889 | int m_shownMonth; | - |
| 890 | Qt::DayOfWeek m_firstDay; | - |
| 891 | QCalendarWidget::HorizontalHeaderFormat m_horizontalHeaderFormat; | - |
| 892 | bool m_weekNumbersShown; | - |
| 893 | QMap<Qt::DayOfWeek, QTextCharFormat> m_dayFormats; | - |
| 894 | QMap<QDate, QTextCharFormat> m_dateFormats; | - |
| 895 | QTextCharFormat m_headerFormat; | - |
| 896 | QCalendarView *m_view; | - |
| 897 | }; | - |
| 898 | | - |
| 899 | class QCalendarView : public QTableView | - |
| 900 | { | - |
| 901 | Q_OBJECT | - |
| 902 | public: | - |
| 903 | QCalendarView(QWidget *parent = 0); | - |
| 904 | | - |
| 905 | void internalUpdate() { updateGeometries(); } executed: }Execution Count:586 | 586 |
| 906 | void setReadOnly(bool enable); | - |
| 907 | virtual void keyboardSearch(const QString & search) { Q_UNUSED(search) } | 0 |
| 908 | | - |
| 909 | signals: | - |
| 910 | void showDate(const QDate &date); | - |
| 911 | void changeDate(const QDate &date, bool changeMonth); | - |
| 912 | void clicked(const QDate &date); | - |
| 913 | void editingFinished(); | - |
| 914 | protected: | - |
| 915 | QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers); | - |
| 916 | void mouseDoubleClickEvent(QMouseEvent *event); | - |
| 917 | void mousePressEvent(QMouseEvent *event); | - |
| 918 | void mouseMoveEvent(QMouseEvent *event); | - |
| 919 | void mouseReleaseEvent(QMouseEvent *event); | - |
| 920 | #ifndef QT_NO_WHEELEVENT | - |
| 921 | void wheelEvent(QWheelEvent *event); | - |
| 922 | #endif | - |
| 923 | void keyPressEvent(QKeyEvent *event); | - |
| 924 | bool event(QEvent *event); | - |
| 925 | | - |
| 926 | QDate handleMouseEvent(QMouseEvent *event); | - |
| 927 | public: | - |
| 928 | bool readOnly; | - |
| 929 | private: | - |
| 930 | bool validDateClicked; | - |
| 931 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 932 | QDate origDate; | - |
| 933 | #endif | - |
| 934 | }; | - |
| 935 | | - |
| 936 | QCalendarModel::QCalendarModel(QObject *parent) | - |
| 937 | : QAbstractTableModel(parent) | - |
| 938 | { | - |
| 939 | m_date = QDate::currentDate(); executed (the execution status of this line is deduced): m_date = QDate::currentDate(); | - |
| 940 | m_minimumDate = QDate::fromJulianDay(1); executed (the execution status of this line is deduced): m_minimumDate = QDate::fromJulianDay(1); | - |
| 941 | m_maximumDate = QDate(7999, 12, 31); executed (the execution status of this line is deduced): m_maximumDate = QDate(7999, 12, 31); | - |
| 942 | m_shownYear = m_date.year(); executed (the execution status of this line is deduced): m_shownYear = m_date.year(); | - |
| 943 | m_shownMonth = m_date.month(); executed (the execution status of this line is deduced): m_shownMonth = m_date.month(); | - |
| 944 | m_firstDay = QLocale().firstDayOfWeek(); executed (the execution status of this line is deduced): m_firstDay = QLocale().firstDayOfWeek(); | - |
| 945 | m_horizontalHeaderFormat = QCalendarWidget::ShortDayNames; executed (the execution status of this line is deduced): m_horizontalHeaderFormat = QCalendarWidget::ShortDayNames; | - |
| 946 | m_weekNumbersShown = true; executed (the execution status of this line is deduced): m_weekNumbersShown = true; | - |
| 947 | m_firstColumn = 1; executed (the execution status of this line is deduced): m_firstColumn = 1; | - |
| 948 | m_firstRow = 1; executed (the execution status of this line is deduced): m_firstRow = 1; | - |
| 949 | m_view = 0; executed (the execution status of this line is deduced): m_view = 0; | - |
| 950 | } executed: }Execution Count:27 | 27 |
| 951 | | - |
| 952 | Qt::DayOfWeek QCalendarModel::dayOfWeekForColumn(int column) const | - |
| 953 | { | - |
| 954 | int col = column - m_firstColumn; executed (the execution status of this line is deduced): int col = column - m_firstColumn; | - |
| 955 | if (col < 0 || col > 6) partially evaluated: col < 0| no Evaluation Count:0 | yes Evaluation Count:12549 |
evaluated: col > 6| yes Evaluation Count:1 | yes Evaluation Count:12548 |
| 0-12549 |
| 956 | return Qt::Sunday; executed: return Qt::Sunday;Execution Count:1 | 1 |
| 957 | int day = m_firstDay + col; executed (the execution status of this line is deduced): int day = m_firstDay + col; | - |
| 958 | if (day > 7) evaluated: day > 7| yes Evaluation Count:10727 | yes Evaluation Count:1821 |
| 1821-10727 |
| 959 | day -= 7; executed: day -= 7;Execution Count:10727 | 10727 |
| 960 | return Qt::DayOfWeek(day); executed: return Qt::DayOfWeek(day);Execution Count:12548 | 12548 |
| 961 | } | - |
| 962 | | - |
| 963 | int QCalendarModel::columnForDayOfWeek(Qt::DayOfWeek day) const | - |
| 964 | { | - |
| 965 | if (day < 1 || day > 7) partially evaluated: day < 1| no Evaluation Count:0 | yes Evaluation Count:22226 |
partially evaluated: day > 7| no Evaluation Count:0 | yes Evaluation Count:22226 |
| 0-22226 |
| 966 | return -1; never executed: return -1; | 0 |
| 967 | int column = (int)day - (int)m_firstDay; executed (the execution status of this line is deduced): int column = (int)day - (int)m_firstDay; | - |
| 968 | if (column < 0) evaluated: column < 0| yes Evaluation Count:20098 | yes Evaluation Count:2128 |
| 2128-20098 |
| 969 | column += 7; executed: column += 7;Execution Count:20098 | 20098 |
| 970 | return column + m_firstColumn; executed: return column + m_firstColumn;Execution Count:22226 | 22226 |
| 971 | } | - |
| 972 | | - |
| 973 | /* | - |
| 974 | This simple algorithm tries to generate a valid date from the month shown. | - |
| 975 | Some months don't contain a first day (e.g. Jan of -4713 year, | - |
| 976 | so QDate (-4713, 1, 1) would be invalid). In that case we try to generate | - |
| 977 | another valid date for that month. Later, returned date's day is the number of cells | - |
| 978 | calendar widget will reserve for days before referenceDate. (E.g. if returned date's | - |
| 979 | day is 16, that day will be placed in 3rd or 4th row, not in the 1st or 2nd row). | - |
| 980 | Depending on referenceData we can change behaviour of Oct 1582. If referenceDate is 1st | - |
| 981 | of Oct we render 1 Oct in 1st or 2nd row. If referenceDate is 17 of Oct we show always 16 | - |
| 982 | dates before 17 of Oct, and since this month contains the hole 5-14 Oct, the first of Oct | - |
| 983 | will be rendered in 2nd or 3rd row, showing more dates from previous month. | - |
| 984 | */ | - |
| 985 | QDate QCalendarModel::referenceDate() const | - |
| 986 | { | - |
| 987 | int refDay = 1; executed (the execution status of this line is deduced): int refDay = 1; | - |
| 988 | while (refDay <= 31) { partially evaluated: refDay <= 31| yes Evaluation Count:21932 | no Evaluation Count:0 |
| 0-21932 |
| 989 | QDate refDate(m_shownYear, m_shownMonth, refDay); executed (the execution status of this line is deduced): QDate refDate(m_shownYear, m_shownMonth, refDay); | - |
| 990 | if (refDate.isValid()) partially evaluated: refDate.isValid()| yes Evaluation Count:21932 | no Evaluation Count:0 |
| 0-21932 |
| 991 | return refDate; executed: return refDate;Execution Count:21932 | 21932 |
| 992 | refDay += 1; never executed (the execution status of this line is deduced): refDay += 1; | - |
| 993 | } | 0 |
| 994 | return QDate(); never executed: return QDate(); | 0 |
| 995 | } | - |
| 996 | | - |
| 997 | int QCalendarModel::columnForFirstOfMonth(const QDate &date) const | - |
| 998 | { | - |
| 999 | return (columnForDayOfWeek(static_cast<Qt::DayOfWeek>(date.dayOfWeek())) - (date.day() % 7) + 8) % 7; executed: return (columnForDayOfWeek(static_cast<Qt::DayOfWeek>(date.dayOfWeek())) - (date.day() % 7) + 8) % 7;Execution Count:21932 | 21932 |
| 1000 | } | - |
| 1001 | | - |
| 1002 | QDate QCalendarModel::dateForCell(int row, int column) const | - |
| 1003 | { | - |
| 1004 | if (row < m_firstRow || row > m_firstRow + RowCount - 1 || evaluated: row < m_firstRow| yes Evaluation Count:1137 | yes Evaluation Count:19467 |
partially evaluated: row > m_firstRow + RowCount - 1| no Evaluation Count:0 | yes Evaluation Count:19467 |
| 0-19467 |
| 1005 | column < m_firstColumn || column > m_firstColumn + ColumnCount - 1) evaluated: column < m_firstColumn| yes Evaluation Count:816 | yes Evaluation Count:18651 |
partially evaluated: column > m_firstColumn + ColumnCount - 1| no Evaluation Count:0 | yes Evaluation Count:18651 |
| 0-18651 |
| 1006 | return QDate(); executed: return QDate();Execution Count:1953 | 1953 |
| 1007 | const QDate refDate = referenceDate(); executed (the execution status of this line is deduced): const QDate refDate = referenceDate(); | - |
| 1008 | if (!refDate.isValid()) partially evaluated: !refDate.isValid()| no Evaluation Count:0 | yes Evaluation Count:18651 |
| 0-18651 |
| 1009 | return QDate(); never executed: return QDate(); | 0 |
| 1010 | | - |
| 1011 | const int columnForFirstOfShownMonth = columnForFirstOfMonth(refDate); executed (the execution status of this line is deduced): const int columnForFirstOfShownMonth = columnForFirstOfMonth(refDate); | - |
| 1012 | if (columnForFirstOfShownMonth - m_firstColumn < MinimumDayOffset) evaluated: columnForFirstOfShownMonth - m_firstColumn < MinimumDayOffset| yes Evaluation Count:14207 | yes Evaluation Count:4444 |
| 4444-14207 |
| 1013 | row -= 1; executed: row -= 1;Execution Count:14207 | 14207 |
| 1014 | | - |
| 1015 | const int requestedDay = 7 * (row - m_firstRow) + column - columnForFirstOfShownMonth - refDate.day() + 1; executed (the execution status of this line is deduced): const int requestedDay = 7 * (row - m_firstRow) + column - columnForFirstOfShownMonth - refDate.day() + 1; | - |
| 1016 | return refDate.addDays(requestedDay); executed: return refDate.addDays(requestedDay);Execution Count:18651 | 18651 |
| 1017 | } | - |
| 1018 | | - |
| 1019 | void QCalendarModel::cellForDate(const QDate &date, int *row, int *column) const | - |
| 1020 | { | - |
| 1021 | if (!row && !column) partially evaluated: !row| no Evaluation Count:0 | yes Evaluation Count:3281 |
never evaluated: !column | 0-3281 |
| 1022 | return; | 0 |
| 1023 | | - |
| 1024 | if (row) partially evaluated: row| yes Evaluation Count:3281 | no Evaluation Count:0 |
| 0-3281 |
| 1025 | *row = -1; executed: *row = -1;Execution Count:3281 | 3281 |
| 1026 | if (column) partially evaluated: column| yes Evaluation Count:3281 | no Evaluation Count:0 |
| 0-3281 |
| 1027 | *column = -1; executed: *column = -1;Execution Count:3281 | 3281 |
| 1028 | | - |
| 1029 | const QDate refDate = referenceDate(); executed (the execution status of this line is deduced): const QDate refDate = referenceDate(); | - |
| 1030 | if (!refDate.isValid()) partially evaluated: !refDate.isValid()| no Evaluation Count:0 | yes Evaluation Count:3281 |
| 0-3281 |
| 1031 | return; | 0 |
| 1032 | | - |
| 1033 | const int columnForFirstOfShownMonth = columnForFirstOfMonth(refDate); executed (the execution status of this line is deduced): const int columnForFirstOfShownMonth = columnForFirstOfMonth(refDate); | - |
| 1034 | const int requestedPosition = refDate.daysTo(date) - m_firstColumn + columnForFirstOfShownMonth + refDate.day() - 1; executed (the execution status of this line is deduced): const int requestedPosition = refDate.daysTo(date) - m_firstColumn + columnForFirstOfShownMonth + refDate.day() - 1; | - |
| 1035 | | - |
| 1036 | int c = requestedPosition % 7; executed (the execution status of this line is deduced): int c = requestedPosition % 7; | - |
| 1037 | int r = requestedPosition / 7; executed (the execution status of this line is deduced): int r = requestedPosition / 7; | - |
| 1038 | if (c < 0) { evaluated: c < 0| yes Evaluation Count:695 | yes Evaluation Count:2586 |
| 695-2586 |
| 1039 | c += 7; executed (the execution status of this line is deduced): c += 7; | - |
| 1040 | r -= 1; executed (the execution status of this line is deduced): r -= 1; | - |
| 1041 | } executed: }Execution Count:695 | 695 |
| 1042 | | - |
| 1043 | if (columnForFirstOfShownMonth - m_firstColumn < MinimumDayOffset) evaluated: columnForFirstOfShownMonth - m_firstColumn < MinimumDayOffset| yes Evaluation Count:1771 | yes Evaluation Count:1510 |
| 1510-1771 |
| 1044 | r += 1; executed: r += 1;Execution Count:1771 | 1771 |
| 1045 | | - |
| 1046 | if (r < 0 || r > RowCount - 1 || c < 0 || c > ColumnCount - 1) evaluated: r < 0| yes Evaluation Count:543 | yes Evaluation Count:2738 |
evaluated: r > RowCount - 1| yes Evaluation Count:33 | yes Evaluation Count:2705 |
partially evaluated: c < 0| no Evaluation Count:0 | yes Evaluation Count:2705 |
partially evaluated: c > ColumnCount - 1| no Evaluation Count:0 | yes Evaluation Count:2705 |
| 0-2738 |
| 1047 | return; executed: return;Execution Count:576 | 576 |
| 1048 | | - |
| 1049 | if (row) partially evaluated: row| yes Evaluation Count:2705 | no Evaluation Count:0 |
| 0-2705 |
| 1050 | *row = r + m_firstRow; executed: *row = r + m_firstRow;Execution Count:2705 | 2705 |
| 1051 | if (column) partially evaluated: column| yes Evaluation Count:2705 | no Evaluation Count:0 |
| 0-2705 |
| 1052 | *column = c + m_firstColumn; executed: *column = c + m_firstColumn;Execution Count:2705 | 2705 |
| 1053 | } executed: }Execution Count:2705 | 2705 |
| 1054 | | - |
| 1055 | QString QCalendarModel::dayName(Qt::DayOfWeek day) const | - |
| 1056 | { | - |
| 1057 | switch (m_horizontalHeaderFormat) { | - |
| 1058 | case QCalendarWidget::SingleLetterDayNames: { | - |
| 1059 | QString standaloneDayName = m_view->locale().standaloneDayName(day, QLocale::NarrowFormat); never executed (the execution status of this line is deduced): QString standaloneDayName = m_view->locale().standaloneDayName(day, QLocale::NarrowFormat); | - |
| 1060 | if (standaloneDayName == m_view->locale().dayName(day, QLocale::NarrowFormat)) never evaluated: standaloneDayName == m_view->locale().dayName(day, QLocale::NarrowFormat) | 0 |
| 1061 | return standaloneDayName.left(1); never executed: return standaloneDayName.left(1); | 0 |
| 1062 | return standaloneDayName; never executed: return standaloneDayName; | 0 |
| 1063 | } | - |
| 1064 | case QCalendarWidget::ShortDayNames: | - |
| 1065 | return m_view->locale().dayName(day, QLocale::ShortFormat); executed: return m_view->locale().dayName(day, QLocale::ShortFormat);Execution Count:455 | 455 |
| 1066 | case QCalendarWidget::LongDayNames: | - |
| 1067 | return m_view->locale().dayName(day, QLocale::LongFormat); never executed: return m_view->locale().dayName(day, QLocale::LongFormat); | 0 |
| 1068 | default: | - |
| 1069 | break; | 0 |
| 1070 | } | - |
| 1071 | return QString(); never executed: return QString(); | 0 |
| 1072 | } | - |
| 1073 | | - |
| 1074 | QTextCharFormat QCalendarModel::formatForCell(int row, int col) const | - |
| 1075 | { | - |
| 1076 | QPalette pal; executed (the execution status of this line is deduced): QPalette pal; | - |
| 1077 | QPalette::ColorGroup cg = QPalette::Active; executed (the execution status of this line is deduced): QPalette::ColorGroup cg = QPalette::Active; | - |
| 1078 | if (m_view) { partially evaluated: m_view| yes Evaluation Count:13900 | no Evaluation Count:0 |
| 0-13900 |
| 1079 | pal = m_view->palette(); executed (the execution status of this line is deduced): pal = m_view->palette(); | - |
| 1080 | if (!m_view->isEnabled()) partially evaluated: !m_view->isEnabled()| no Evaluation Count:0 | yes Evaluation Count:13900 |
| 0-13900 |
| 1081 | cg = QPalette::Disabled; never executed: cg = QPalette::Disabled; | 0 |
| 1082 | else if (!m_view->isActiveWindow()) evaluated: !m_view->isActiveWindow()| yes Evaluation Count:4682 | yes Evaluation Count:9218 |
| 4682-9218 |
| 1083 | cg = QPalette::Inactive; executed: cg = QPalette::Inactive;Execution Count:4682 | 4682 |
| 1084 | } | - |
| 1085 | | - |
| 1086 | QTextCharFormat format; executed (the execution status of this line is deduced): QTextCharFormat format; | - |
| 1087 | format.setFont(m_view->font()); executed (the execution status of this line is deduced): format.setFont(m_view->font()); | - |
| 1088 | bool header = (m_weekNumbersShown && col == HeaderColumn) evaluated: m_weekNumbersShown| yes Evaluation Count:13892 | yes Evaluation Count:8 |
evaluated: col == HeaderColumn| yes Evaluation Count:1805 | yes Evaluation Count:12087 |
| 8-13892 |
| 1089 | || (m_horizontalHeaderFormat != QCalendarWidget::NoHorizontalHeader && row == HeaderRow); partially evaluated: m_horizontalHeaderFormat != QCalendarWidget::NoHorizontalHeader| yes Evaluation Count:12095 | no Evaluation Count:0 |
evaluated: row == HeaderRow| yes Evaluation Count:1827 | yes Evaluation Count:10268 |
| 0-12095 |
| 1090 | format.setBackground(pal.brush(cg, header ? QPalette::AlternateBase : QPalette::Base)); executed (the execution status of this line is deduced): format.setBackground(pal.brush(cg, header ? QPalette::AlternateBase : QPalette::Base)); | - |
| 1091 | format.setForeground(pal.brush(cg, QPalette::Text)); executed (the execution status of this line is deduced): format.setForeground(pal.brush(cg, QPalette::Text)); | - |
| 1092 | if (header) { evaluated: header| yes Evaluation Count:3632 | yes Evaluation Count:10268 |
| 3632-10268 |
| 1093 | format.merge(m_headerFormat); executed (the execution status of this line is deduced): format.merge(m_headerFormat); | - |
| 1094 | } executed: }Execution Count:3632 | 3632 |
| 1095 | | - |
| 1096 | if (col >= m_firstColumn && col < m_firstColumn + ColumnCount) { evaluated: col >= m_firstColumn| yes Evaluation Count:12095 | yes Evaluation Count:1805 |
evaluated: col < m_firstColumn + ColumnCount| yes Evaluation Count:12094 | yes Evaluation Count:1 |
| 1-12095 |
| 1097 | Qt::DayOfWeek dayOfWeek = dayOfWeekForColumn(col); executed (the execution status of this line is deduced): Qt::DayOfWeek dayOfWeek = dayOfWeekForColumn(col); | - |
| 1098 | if (m_dayFormats.contains(dayOfWeek)) evaluated: m_dayFormats.contains(dayOfWeek)| yes Evaluation Count:3476 | yes Evaluation Count:8618 |
| 3476-8618 |
| 1099 | format.merge(m_dayFormats.value(dayOfWeek)); executed: format.merge(m_dayFormats.value(dayOfWeek));Execution Count:3476 | 3476 |
| 1100 | } executed: }Execution Count:12094 | 12094 |
| 1101 | | - |
| 1102 | if (!header) { evaluated: !header| yes Evaluation Count:10268 | yes Evaluation Count:3632 |
| 3632-10268 |
| 1103 | QDate date = dateForCell(row, col); executed (the execution status of this line is deduced): QDate date = dateForCell(row, col); | - |
| 1104 | format.merge(m_dateFormats.value(date)); executed (the execution status of this line is deduced): format.merge(m_dateFormats.value(date)); | - |
| 1105 | if(date < m_minimumDate || date > m_maximumDate) evaluated: date < m_minimumDate| yes Evaluation Count:35 | yes Evaluation Count:10233 |
partially evaluated: date > m_maximumDate| no Evaluation Count:0 | yes Evaluation Count:10233 |
| 0-10233 |
| 1106 | format.setBackground(pal.brush(cg, QPalette::Window)); executed: format.setBackground(pal.brush(cg, QPalette::Window));Execution Count:35 | 35 |
| 1107 | if (m_shownMonth != date.month()) evaluated: m_shownMonth != date.month()| yes Evaluation Count:2919 | yes Evaluation Count:7349 |
| 2919-7349 |
| 1108 | format.setForeground(pal.brush(QPalette::Disabled, QPalette::Text)); executed: format.setForeground(pal.brush(QPalette::Disabled, QPalette::Text));Execution Count:2919 | 2919 |
| 1109 | } executed: }Execution Count:10268 | 10268 |
| 1110 | return format; executed: return format;Execution Count:13900 | 13900 |
| 1111 | } | - |
| 1112 | | - |
| 1113 | QVariant QCalendarModel::data(const QModelIndex &index, int role) const | - |
| 1114 | { | - |
| 1115 | if (role == Qt::TextAlignmentRole) evaluated: role == Qt::TextAlignmentRole| yes Evaluation Count:2744 | yes Evaluation Count:16426 |
| 2744-16426 |
| 1116 | return (int) Qt::AlignCenter; executed: return (int) Qt::AlignCenter;Execution Count:2744 | 2744 |
| 1117 | | - |
| 1118 | int row = index.row(); executed (the execution status of this line is deduced): int row = index.row(); | - |
| 1119 | int column = index.column(); executed (the execution status of this line is deduced): int column = index.column(); | - |
| 1120 | | - |
| 1121 | if(role == Qt::DisplayRole) { evaluated: role == Qt::DisplayRole| yes Evaluation Count:2744 | yes Evaluation Count:13682 |
| 2744-13682 |
| 1122 | if (m_weekNumbersShown && column == HeaderColumn partially evaluated: m_weekNumbersShown| yes Evaluation Count:2744 | no Evaluation Count:0 |
evaluated: column == HeaderColumn| yes Evaluation Count:343 | yes Evaluation Count:2401 |
| 0-2744 |
| 1123 | && row >= m_firstRow && row < m_firstRow + RowCount) { evaluated: row >= m_firstRow| yes Evaluation Count:294 | yes Evaluation Count:49 |
partially evaluated: row < m_firstRow + RowCount| yes Evaluation Count:294 | no Evaluation Count:0 |
| 0-294 |
| 1124 | QDate date = dateForCell(row, columnForDayOfWeek(Qt::Monday)); executed (the execution status of this line is deduced): QDate date = dateForCell(row, columnForDayOfWeek(Qt::Monday)); | - |
| 1125 | if (date.isValid()) partially evaluated: date.isValid()| yes Evaluation Count:294 | no Evaluation Count:0 |
| 0-294 |
| 1126 | return date.weekNumber(); executed: return date.weekNumber();Execution Count:294 | 294 |
| 1127 | } | 0 |
| 1128 | if (m_horizontalHeaderFormat != QCalendarWidget::NoHorizontalHeader && row == HeaderRow partially evaluated: m_horizontalHeaderFormat != QCalendarWidget::NoHorizontalHeader| yes Evaluation Count:2450 | no Evaluation Count:0 |
evaluated: row == HeaderRow| yes Evaluation Count:392 | yes Evaluation Count:2058 |
| 0-2450 |
| 1129 | && column >= m_firstColumn && column < m_firstColumn + ColumnCount) evaluated: column >= m_firstColumn| yes Evaluation Count:343 | yes Evaluation Count:49 |
partially evaluated: column < m_firstColumn + ColumnCount| yes Evaluation Count:343 | no Evaluation Count:0 |
| 0-343 |
| 1130 | return dayName(dayOfWeekForColumn(column)); executed: return dayName(dayOfWeekForColumn(column));Execution Count:343 | 343 |
| 1131 | QDate date = dateForCell(row, column); executed (the execution status of this line is deduced): QDate date = dateForCell(row, column); | - |
| 1132 | if (date.isValid()) evaluated: date.isValid()| yes Evaluation Count:2058 | yes Evaluation Count:49 |
| 49-2058 |
| 1133 | return date.day(); executed: return date.day();Execution Count:2058 | 2058 |
| 1134 | return QString(); executed: return QString();Execution Count:49 | 49 |
| 1135 | } | - |
| 1136 | | - |
| 1137 | QTextCharFormat fmt = formatForCell(row, column); executed (the execution status of this line is deduced): QTextCharFormat fmt = formatForCell(row, column); | - |
| 1138 | if (role == Qt::BackgroundColorRole) evaluated: role == Qt::BackgroundColorRole| yes Evaluation Count:2706 | yes Evaluation Count:10976 |
| 2706-10976 |
| 1139 | return fmt.background().color(); executed: return fmt.background().color();Execution Count:2706 | 2706 |
| 1140 | if (role == Qt::TextColorRole) evaluated: role == Qt::TextColorRole| yes Evaluation Count:2744 | yes Evaluation Count:8232 |
| 2744-8232 |
| 1141 | return fmt.foreground().color(); executed: return fmt.foreground().color();Execution Count:2744 | 2744 |
| 1142 | if (role == Qt::FontRole) evaluated: role == Qt::FontRole| yes Evaluation Count:2744 | yes Evaluation Count:5488 |
| 2744-5488 |
| 1143 | return fmt.font(); executed: return fmt.font();Execution Count:2744 | 2744 |
| 1144 | if (role == Qt::ToolTipRole) partially evaluated: role == Qt::ToolTipRole| no Evaluation Count:0 | yes Evaluation Count:5488 |
| 0-5488 |
| 1145 | return fmt.toolTip(); never executed: return fmt.toolTip(); | 0 |
| 1146 | return QVariant(); executed: return QVariant();Execution Count:5488 | 5488 |
| 1147 | } | - |
| 1148 | | - |
| 1149 | Qt::ItemFlags QCalendarModel::flags(const QModelIndex &index) const | - |
| 1150 | { | - |
| 1151 | QDate date = dateForCell(index.row(), index.column()); executed (the execution status of this line is deduced): QDate date = dateForCell(index.row(), index.column()); | - |
| 1152 | if (!date.isValid()) evaluated: !date.isValid()| yes Evaluation Count:1218 | yes Evaluation Count:3755 |
| 1218-3755 |
| 1153 | return QAbstractTableModel::flags(index); executed: return QAbstractTableModel::flags(index);Execution Count:1218 | 1218 |
| 1154 | if (date < m_minimumDate) evaluated: date < m_minimumDate| yes Evaluation Count:14 | yes Evaluation Count:3741 |
| 14-3741 |
| 1155 | return 0; executed: return 0;Execution Count:14 | 14 |
| 1156 | if (date > m_maximumDate) partially evaluated: date > m_maximumDate| no Evaluation Count:0 | yes Evaluation Count:3741 |
| 0-3741 |
| 1157 | return 0; never executed: return 0; | 0 |
| 1158 | return QAbstractTableModel::flags(index); executed: return QAbstractTableModel::flags(index);Execution Count:3741 | 3741 |
| 1159 | } | - |
| 1160 | | - |
| 1161 | void QCalendarModel::setDate(const QDate &d) | - |
| 1162 | { | - |
| 1163 | m_date = d; executed (the execution status of this line is deduced): m_date = d; | - |
| 1164 | if (m_date < m_minimumDate) evaluated: m_date < m_minimumDate| yes Evaluation Count:1 | yes Evaluation Count:550 |
| 1-550 |
| 1165 | m_date = m_minimumDate; executed: m_date = m_minimumDate;Execution Count:1 | 1 |
| 1166 | else if (m_date > m_maximumDate) evaluated: m_date > m_maximumDate| yes Evaluation Count:1 | yes Evaluation Count:549 |
| 1-549 |
| 1167 | m_date = m_maximumDate; executed: m_date = m_maximumDate;Execution Count:1 | 1 |
| 1168 | } | - |
| 1169 | | - |
| 1170 | void QCalendarModel::showMonth(int year, int month) | - |
| 1171 | { | - |
| 1172 | if (m_shownYear == year && m_shownMonth == month) evaluated: m_shownYear == year| yes Evaluation Count:26 | yes Evaluation Count:560 |
partially evaluated: m_shownMonth == month| no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-560 |
| 1173 | return; | 0 |
| 1174 | | - |
| 1175 | m_shownYear = year; executed (the execution status of this line is deduced): m_shownYear = year; | - |
| 1176 | m_shownMonth = month; executed (the execution status of this line is deduced): m_shownMonth = month; | - |
| 1177 | | - |
| 1178 | internalUpdate(); executed (the execution status of this line is deduced): internalUpdate(); | - |
| 1179 | } executed: }Execution Count:586 | 586 |
| 1180 | | - |
| 1181 | void QCalendarModel::setMinimumDate(const QDate &d) | - |
| 1182 | { | - |
| 1183 | if (!d.isValid() || d == m_minimumDate) partially evaluated: !d.isValid()| no Evaluation Count:0 | yes Evaluation Count:18 |
partially evaluated: d == m_minimumDate| no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
| 1184 | return; | 0 |
| 1185 | | - |
| 1186 | m_minimumDate = d; executed (the execution status of this line is deduced): m_minimumDate = d; | - |
| 1187 | if (m_maximumDate < m_minimumDate) partially evaluated: m_maximumDate < m_minimumDate| no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
| 1188 | m_maximumDate = m_minimumDate; never executed: m_maximumDate = m_minimumDate; | 0 |
| 1189 | if (m_date < m_minimumDate) evaluated: m_date < m_minimumDate| yes Evaluation Count:2 | yes Evaluation Count:16 |
| 2-16 |
| 1190 | m_date = m_minimumDate; executed: m_date = m_minimumDate;Execution Count:2 | 2 |
| 1191 | internalUpdate(); executed (the execution status of this line is deduced): internalUpdate(); | - |
| 1192 | } executed: }Execution Count:18 | 18 |
| 1193 | | - |
| 1194 | void QCalendarModel::setMaximumDate(const QDate &d) | - |
| 1195 | { | - |
| 1196 | if (!d.isValid() || d == m_maximumDate) partially evaluated: !d.isValid()| no Evaluation Count:0 | yes Evaluation Count:13 |
partially evaluated: d == m_maximumDate| no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
| 1197 | return; | 0 |
| 1198 | | - |
| 1199 | m_maximumDate = d; executed (the execution status of this line is deduced): m_maximumDate = d; | - |
| 1200 | if (m_minimumDate > m_maximumDate) partially evaluated: m_minimumDate > m_maximumDate| no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
| 1201 | m_minimumDate = m_maximumDate; never executed: m_minimumDate = m_maximumDate; | 0 |
| 1202 | if (m_date > m_maximumDate) evaluated: m_date > m_maximumDate| yes Evaluation Count:3 | yes Evaluation Count:10 |
| 3-10 |
| 1203 | m_date = m_maximumDate; executed: m_date = m_maximumDate;Execution Count:3 | 3 |
| 1204 | internalUpdate(); executed (the execution status of this line is deduced): internalUpdate(); | - |
| 1205 | } executed: }Execution Count:13 | 13 |
| 1206 | | - |
| 1207 | void QCalendarModel::setRange(const QDate &min, const QDate &max) | - |
| 1208 | { | - |
| 1209 | m_minimumDate = min; executed (the execution status of this line is deduced): m_minimumDate = min; | - |
| 1210 | m_maximumDate = max; executed (the execution status of this line is deduced): m_maximumDate = max; | - |
| 1211 | if (m_minimumDate > m_maximumDate) partially evaluated: m_minimumDate > m_maximumDate| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 1212 | qSwap(m_minimumDate, m_maximumDate); never executed: qSwap(m_minimumDate, m_maximumDate); | 0 |
| 1213 | if (m_date < m_minimumDate) partially evaluated: m_date < m_minimumDate| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 1214 | m_date = m_minimumDate; executed: m_date = m_minimumDate;Execution Count:2 | 2 |
| 1215 | if (m_date > m_maximumDate) partially evaluated: m_date > m_maximumDate| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 1216 | m_date = m_maximumDate; never executed: m_date = m_maximumDate; | 0 |
| 1217 | internalUpdate(); executed (the execution status of this line is deduced): internalUpdate(); | - |
| 1218 | } executed: }Execution Count:2 | 2 |
| 1219 | | - |
| 1220 | void QCalendarModel::internalUpdate() | - |
| 1221 | { | - |
| 1222 | QModelIndex begin = index(0, 0); executed (the execution status of this line is deduced): QModelIndex begin = index(0, 0); | - |
| 1223 | QModelIndex end = index(m_firstRow + RowCount - 1, m_firstColumn + ColumnCount - 1); executed (the execution status of this line is deduced): QModelIndex end = index(m_firstRow + RowCount - 1, m_firstColumn + ColumnCount - 1); | - |
| 1224 | emit dataChanged(begin, end); executed (the execution status of this line is deduced): dataChanged(begin, end); | - |
| 1225 | emit headerDataChanged(Qt::Vertical, 0, m_firstRow + RowCount - 1); executed (the execution status of this line is deduced): headerDataChanged(Qt::Vertical, 0, m_firstRow + RowCount - 1); | - |
| 1226 | emit headerDataChanged(Qt::Horizontal, 0, m_firstColumn + ColumnCount - 1); executed (the execution status of this line is deduced): headerDataChanged(Qt::Horizontal, 0, m_firstColumn + ColumnCount - 1); | - |
| 1227 | } executed: }Execution Count:630 | 630 |
| 1228 | | - |
| 1229 | void QCalendarModel::setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat format) | - |
| 1230 | { | - |
| 1231 | if (m_horizontalHeaderFormat == format) partially evaluated: m_horizontalHeaderFormat == format| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 1232 | return; | 0 |
| 1233 | | - |
| 1234 | int oldFormat = m_horizontalHeaderFormat; executed (the execution status of this line is deduced): int oldFormat = m_horizontalHeaderFormat; | - |
| 1235 | m_horizontalHeaderFormat = format; executed (the execution status of this line is deduced): m_horizontalHeaderFormat = format; | - |
| 1236 | if (oldFormat == QCalendarWidget::NoHorizontalHeader) { evaluated: oldFormat == QCalendarWidget::NoHorizontalHeader| yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
| 1237 | m_firstRow = 1; executed (the execution status of this line is deduced): m_firstRow = 1; | - |
| 1238 | insertRow(0); executed (the execution status of this line is deduced): insertRow(0); | - |
| 1239 | } else if (m_horizontalHeaderFormat == QCalendarWidget::NoHorizontalHeader) { executed: }Execution Count:1 evaluated: m_horizontalHeaderFormat == QCalendarWidget::NoHorizontalHeader| yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
| 1240 | m_firstRow = 0; executed (the execution status of this line is deduced): m_firstRow = 0; | - |
| 1241 | removeRow(0); executed (the execution status of this line is deduced): removeRow(0); | - |
| 1242 | } executed: }Execution Count:1 | 1 |
| 1243 | internalUpdate(); executed (the execution status of this line is deduced): internalUpdate(); | - |
| 1244 | } executed: }Execution Count:4 | 4 |
| 1245 | | - |
| 1246 | void QCalendarModel::setFirstColumnDay(Qt::DayOfWeek dayOfWeek) | - |
| 1247 | { | - |
| 1248 | if (m_firstDay == dayOfWeek) evaluated: m_firstDay == dayOfWeek| yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
| 1249 | return; executed: return;Execution Count:3 | 3 |
| 1250 | | - |
| 1251 | m_firstDay = dayOfWeek; executed (the execution status of this line is deduced): m_firstDay = dayOfWeek; | - |
| 1252 | internalUpdate(); executed (the execution status of this line is deduced): internalUpdate(); | - |
| 1253 | } executed: }Execution Count:2 | 2 |
| 1254 | | - |
| 1255 | Qt::DayOfWeek QCalendarModel::firstColumnDay() const | - |
| 1256 | { | - |
| 1257 | return m_firstDay; executed: return m_firstDay;Execution Count:8 | 8 |
| 1258 | } | - |
| 1259 | | - |
| 1260 | bool QCalendarModel::weekNumbersShown() const | - |
| 1261 | { | - |
| 1262 | return m_weekNumbersShown; executed: return m_weekNumbersShown;Execution Count:24 | 24 |
| 1263 | } | - |
| 1264 | | - |
| 1265 | void QCalendarModel::setWeekNumbersShown(bool show) | - |
| 1266 | { | - |
| 1267 | if (m_weekNumbersShown == show) partially evaluated: m_weekNumbersShown == show| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 1268 | return; | 0 |
| 1269 | | - |
| 1270 | m_weekNumbersShown = show; executed (the execution status of this line is deduced): m_weekNumbersShown = show; | - |
| 1271 | if (show) { partially evaluated: show| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 1272 | m_firstColumn = 1; never executed (the execution status of this line is deduced): m_firstColumn = 1; | - |
| 1273 | insertColumn(0); never executed (the execution status of this line is deduced): insertColumn(0); | - |
| 1274 | } else { | 0 |
| 1275 | m_firstColumn = 0; executed (the execution status of this line is deduced): m_firstColumn = 0; | - |
| 1276 | removeColumn(0); executed (the execution status of this line is deduced): removeColumn(0); | - |
| 1277 | } executed: }Execution Count:5 | 5 |
| 1278 | internalUpdate(); executed (the execution status of this line is deduced): internalUpdate(); | - |
| 1279 | } executed: }Execution Count:5 | 5 |
| 1280 | | - |
| 1281 | QCalendarView::QCalendarView(QWidget *parent) | - |
| 1282 | : QTableView(parent), | - |
| 1283 | readOnly(false), | - |
| 1284 | validDateClicked(false) | - |
| 1285 | { | - |
| 1286 | setTabKeyNavigation(false); executed (the execution status of this line is deduced): setTabKeyNavigation(false); | - |
| 1287 | setShowGrid(false); executed (the execution status of this line is deduced): setShowGrid(false); | - |
| 1288 | verticalHeader()->setVisible(false); executed (the execution status of this line is deduced): verticalHeader()->setVisible(false); | - |
| 1289 | horizontalHeader()->setVisible(false); executed (the execution status of this line is deduced): horizontalHeader()->setVisible(false); | - |
| 1290 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); executed (the execution status of this line is deduced): setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | - |
| 1291 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); executed (the execution status of this line is deduced): setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | - |
| 1292 | } executed: }Execution Count:27 | 27 |
| 1293 | | - |
| 1294 | QModelIndex QCalendarView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) | - |
| 1295 | { | - |
| 1296 | QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model()); executed (the execution status of this line is deduced): QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model()); | - |
| 1297 | if (!calendarModel) partially evaluated: !calendarModel| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 1298 | return QTableView::moveCursor(cursorAction, modifiers); never executed: return QTableView::moveCursor(cursorAction, modifiers); | 0 |
| 1299 | | - |
| 1300 | if (readOnly) partially evaluated: readOnly| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 1301 | return currentIndex(); never executed: return currentIndex(); | 0 |
| 1302 | | - |
| 1303 | QModelIndex index = currentIndex(); executed (the execution status of this line is deduced): QModelIndex index = currentIndex(); | - |
| 1304 | QDate currentDate = static_cast<QCalendarModel*>(model())->dateForCell(index.row(), index.column()); executed (the execution status of this line is deduced): QDate currentDate = static_cast<QCalendarModel*>(model())->dateForCell(index.row(), index.column()); | - |
| 1305 | switch (cursorAction) { | - |
| 1306 | case QAbstractItemView::MoveUp: | - |
| 1307 | currentDate = currentDate.addDays(-7); never executed (the execution status of this line is deduced): currentDate = currentDate.addDays(-7); | - |
| 1308 | break; | 0 |
| 1309 | case QAbstractItemView::MoveDown: | - |
| 1310 | currentDate = currentDate.addDays(7); executed (the execution status of this line is deduced): currentDate = currentDate.addDays(7); | - |
| 1311 | break; executed: break;Execution Count:1 | 1 |
| 1312 | case QAbstractItemView::MoveLeft: | - |
| 1313 | currentDate = currentDate.addDays(isRightToLeft() ? 1 : -1); never executed (the execution status of this line is deduced): currentDate = currentDate.addDays(isRightToLeft() ? 1 : -1); | - |
| 1314 | break; | 0 |
| 1315 | case QAbstractItemView::MoveRight: | - |
| 1316 | currentDate = currentDate.addDays(isRightToLeft() ? -1 : 1); never executed (the execution status of this line is deduced): currentDate = currentDate.addDays(isRightToLeft() ? -1 : 1); | - |
| 1317 | break; | 0 |
| 1318 | case QAbstractItemView::MoveHome: | - |
| 1319 | currentDate = QDate(currentDate.year(), currentDate.month(), 1); never executed (the execution status of this line is deduced): currentDate = QDate(currentDate.year(), currentDate.month(), 1); | - |
| 1320 | break; | 0 |
| 1321 | case QAbstractItemView::MoveEnd: | - |
| 1322 | currentDate = QDate(currentDate.year(), currentDate.month(), currentDate.daysInMonth()); never executed (the execution status of this line is deduced): currentDate = QDate(currentDate.year(), currentDate.month(), currentDate.daysInMonth()); | - |
| 1323 | break; | 0 |
| 1324 | case QAbstractItemView::MovePageUp: | - |
| 1325 | currentDate = currentDate.addMonths(-1); never executed (the execution status of this line is deduced): currentDate = currentDate.addMonths(-1); | - |
| 1326 | break; | 0 |
| 1327 | case QAbstractItemView::MovePageDown: | - |
| 1328 | currentDate = currentDate.addMonths(1); never executed (the execution status of this line is deduced): currentDate = currentDate.addMonths(1); | - |
| 1329 | break; | 0 |
| 1330 | case QAbstractItemView::MoveNext: | - |
| 1331 | case QAbstractItemView::MovePrevious: | - |
| 1332 | return currentIndex(); never executed: return currentIndex(); | 0 |
| 1333 | default: | - |
| 1334 | break; | 0 |
| 1335 | } | - |
| 1336 | emit changeDate(currentDate, true); executed (the execution status of this line is deduced): changeDate(currentDate, true); | - |
| 1337 | return currentIndex(); executed: return currentIndex();Execution Count:1 | 1 |
| 1338 | } | - |
| 1339 | | - |
| 1340 | void QCalendarView::keyPressEvent(QKeyEvent *event) | - |
| 1341 | { | - |
| 1342 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 1343 | if (event->key() == Qt::Key_Select) { | - |
| 1344 | if (QApplication::keypadNavigationEnabled()) { | - |
| 1345 | if (!hasEditFocus()) { | - |
| 1346 | setEditFocus(true); | - |
| 1347 | return; | - |
| 1348 | } | - |
| 1349 | } | - |
| 1350 | } else if (event->key() == Qt::Key_Back) { | - |
| 1351 | if (QApplication::keypadNavigationEnabled() && hasEditFocus()) { | - |
| 1352 | if (qobject_cast<QCalendarModel *>(model())) { | - |
| 1353 | emit changeDate(origDate, true); //changes selection back to origDate, but doesn't activate | - |
| 1354 | setEditFocus(false); | - |
| 1355 | return; | - |
| 1356 | } | - |
| 1357 | } | - |
| 1358 | } | - |
| 1359 | #endif | - |
| 1360 | | - |
| 1361 | if (!readOnly) { partially evaluated: !readOnly| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 1362 | switch (event->key()) { | - |
| 1363 | case Qt::Key_Return: | - |
| 1364 | case Qt::Key_Enter: | - |
| 1365 | case Qt::Key_Select: | - |
| 1366 | emit editingFinished(); never executed (the execution status of this line is deduced): editingFinished(); | - |
| 1367 | return; | 0 |
| 1368 | default: | - |
| 1369 | break; executed: break;Execution Count:1 | 1 |
| 1370 | } | - |
| 1371 | } executed: }Execution Count:1 | 1 |
| 1372 | QTableView::keyPressEvent(event); executed (the execution status of this line is deduced): QTableView::keyPressEvent(event); | - |
| 1373 | } executed: }Execution Count:1 | 1 |
| 1374 | | - |
| 1375 | #ifndef QT_NO_WHEELEVENT | - |
| 1376 | void QCalendarView::wheelEvent(QWheelEvent *event) | - |
| 1377 | { | - |
| 1378 | const int numDegrees = event->delta() / 8; never executed (the execution status of this line is deduced): const int numDegrees = event->delta() / 8; | - |
| 1379 | const int numSteps = numDegrees / 15; never executed (the execution status of this line is deduced): const int numSteps = numDegrees / 15; | - |
| 1380 | const QModelIndex index = currentIndex(); never executed (the execution status of this line is deduced): const QModelIndex index = currentIndex(); | - |
| 1381 | QDate currentDate = static_cast<QCalendarModel*>(model())->dateForCell(index.row(), index.column()); never executed (the execution status of this line is deduced): QDate currentDate = static_cast<QCalendarModel*>(model())->dateForCell(index.row(), index.column()); | - |
| 1382 | currentDate = currentDate.addMonths(-numSteps); never executed (the execution status of this line is deduced): currentDate = currentDate.addMonths(-numSteps); | - |
| 1383 | emit showDate(currentDate); never executed (the execution status of this line is deduced): showDate(currentDate); | - |
| 1384 | } | 0 |
| 1385 | #endif | - |
| 1386 | | - |
| 1387 | bool QCalendarView::event(QEvent *event) | - |
| 1388 | { | - |
| 1389 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 1390 | if (event->type() == QEvent::FocusIn) { | - |
| 1391 | if (QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model())) { | - |
| 1392 | origDate = calendarModel->m_date; | - |
| 1393 | } | - |
| 1394 | } | - |
| 1395 | #endif | - |
| 1396 | | - |
| 1397 | return QTableView::event(event); executed: return QTableView::event(event);Execution Count:590 | 590 |
| 1398 | } | - |
| 1399 | | - |
| 1400 | QDate QCalendarView::handleMouseEvent(QMouseEvent *event) | - |
| 1401 | { | - |
| 1402 | QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model()); never executed (the execution status of this line is deduced): QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model()); | - |
| 1403 | if (!calendarModel) never evaluated: !calendarModel | 0 |
| 1404 | return QDate(); never executed: return QDate(); | 0 |
| 1405 | | - |
| 1406 | QPoint pos = event->pos(); never executed (the execution status of this line is deduced): QPoint pos = event->pos(); | - |
| 1407 | QModelIndex index = indexAt(pos); never executed (the execution status of this line is deduced): QModelIndex index = indexAt(pos); | - |
| 1408 | QDate date = calendarModel->dateForCell(index.row(), index.column()); never executed (the execution status of this line is deduced): QDate date = calendarModel->dateForCell(index.row(), index.column()); | - |
| 1409 | if (date.isValid() && date >= calendarModel->m_minimumDate never evaluated: date.isValid() never evaluated: date >= calendarModel->m_minimumDate | 0 |
| 1410 | && date <= calendarModel->m_maximumDate) { never evaluated: date <= calendarModel->m_maximumDate | 0 |
| 1411 | return date; never executed: return date; | 0 |
| 1412 | } | - |
| 1413 | return QDate(); never executed: return QDate(); | 0 |
| 1414 | } | - |
| 1415 | | - |
| 1416 | void QCalendarView::mouseDoubleClickEvent(QMouseEvent *event) | - |
| 1417 | { | - |
| 1418 | QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model()); never executed (the execution status of this line is deduced): QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model()); | - |
| 1419 | if (!calendarModel) { never evaluated: !calendarModel | 0 |
| 1420 | QTableView::mouseDoubleClickEvent(event); never executed (the execution status of this line is deduced): QTableView::mouseDoubleClickEvent(event); | - |
| 1421 | return; | 0 |
| 1422 | } | - |
| 1423 | | - |
| 1424 | if (readOnly) never evaluated: readOnly | 0 |
| 1425 | return; | 0 |
| 1426 | | - |
| 1427 | QDate date = handleMouseEvent(event); never executed (the execution status of this line is deduced): QDate date = handleMouseEvent(event); | - |
| 1428 | validDateClicked = false; never executed (the execution status of this line is deduced): validDateClicked = false; | - |
| 1429 | if (date == calendarModel->m_date && !style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick)) { never evaluated: date == calendarModel->m_date never evaluated: !style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) | 0 |
| 1430 | emit editingFinished(); never executed (the execution status of this line is deduced): editingFinished(); | - |
| 1431 | } | 0 |
| 1432 | } | 0 |
| 1433 | | - |
| 1434 | void QCalendarView::mousePressEvent(QMouseEvent *event) | - |
| 1435 | { | - |
| 1436 | QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model()); never executed (the execution status of this line is deduced): QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model()); | - |
| 1437 | if (!calendarModel) { never evaluated: !calendarModel | 0 |
| 1438 | QTableView::mousePressEvent(event); never executed (the execution status of this line is deduced): QTableView::mousePressEvent(event); | - |
| 1439 | return; | 0 |
| 1440 | } | - |
| 1441 | | - |
| 1442 | if (readOnly) never evaluated: readOnly | 0 |
| 1443 | return; | 0 |
| 1444 | | - |
| 1445 | if (event->button() != Qt::LeftButton) never evaluated: event->button() != Qt::LeftButton | 0 |
| 1446 | return; | 0 |
| 1447 | | - |
| 1448 | QDate date = handleMouseEvent(event); never executed (the execution status of this line is deduced): QDate date = handleMouseEvent(event); | - |
| 1449 | if (date.isValid()) { never evaluated: date.isValid() | 0 |
| 1450 | validDateClicked = true; never executed (the execution status of this line is deduced): validDateClicked = true; | - |
| 1451 | int row = -1, col = -1; never executed (the execution status of this line is deduced): int row = -1, col = -1; | - |
| 1452 | static_cast<QCalendarModel *>(model())->cellForDate(date, &row, &col); never executed (the execution status of this line is deduced): static_cast<QCalendarModel *>(model())->cellForDate(date, &row, &col); | - |
| 1453 | if (row != -1 && col != -1) { never evaluated: row != -1 never evaluated: col != -1 | 0 |
| 1454 | selectionModel()->setCurrentIndex(model()->index(row, col), QItemSelectionModel::NoUpdate); never executed (the execution status of this line is deduced): selectionModel()->setCurrentIndex(model()->index(row, col), QItemSelectionModel::NoUpdate); | - |
| 1455 | } | 0 |
| 1456 | } else { | 0 |
| 1457 | validDateClicked = false; never executed (the execution status of this line is deduced): validDateClicked = false; | - |
| 1458 | event->ignore(); never executed (the execution status of this line is deduced): event->ignore(); | - |
| 1459 | } | 0 |
| 1460 | } | - |
| 1461 | | - |
| 1462 | void QCalendarView::mouseMoveEvent(QMouseEvent *event) | - |
| 1463 | { | - |
| 1464 | QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model()); never executed (the execution status of this line is deduced): QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model()); | - |
| 1465 | if (!calendarModel) { never evaluated: !calendarModel | 0 |
| 1466 | QTableView::mouseMoveEvent(event); never executed (the execution status of this line is deduced): QTableView::mouseMoveEvent(event); | - |
| 1467 | return; | 0 |
| 1468 | } | - |
| 1469 | | - |
| 1470 | if (readOnly) never evaluated: readOnly | 0 |
| 1471 | return; | 0 |
| 1472 | | - |
| 1473 | if (validDateClicked) { never evaluated: validDateClicked | 0 |
| 1474 | QDate date = handleMouseEvent(event); never executed (the execution status of this line is deduced): QDate date = handleMouseEvent(event); | - |
| 1475 | if (date.isValid()) { never evaluated: date.isValid() | 0 |
| 1476 | int row = -1, col = -1; never executed (the execution status of this line is deduced): int row = -1, col = -1; | - |
| 1477 | static_cast<QCalendarModel *>(model())->cellForDate(date, &row, &col); never executed (the execution status of this line is deduced): static_cast<QCalendarModel *>(model())->cellForDate(date, &row, &col); | - |
| 1478 | if (row != -1 && col != -1) { never evaluated: row != -1 never evaluated: col != -1 | 0 |
| 1479 | selectionModel()->setCurrentIndex(model()->index(row, col), QItemSelectionModel::NoUpdate); never executed (the execution status of this line is deduced): selectionModel()->setCurrentIndex(model()->index(row, col), QItemSelectionModel::NoUpdate); | - |
| 1480 | } | 0 |
| 1481 | } | 0 |
| 1482 | } else { | 0 |
| 1483 | event->ignore(); never executed (the execution status of this line is deduced): event->ignore(); | - |
| 1484 | } | 0 |
| 1485 | } | - |
| 1486 | | - |
| 1487 | void QCalendarView::mouseReleaseEvent(QMouseEvent *event) | - |
| 1488 | { | - |
| 1489 | QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model()); never executed (the execution status of this line is deduced): QCalendarModel *calendarModel = qobject_cast<QCalendarModel *>(model()); | - |
| 1490 | if (!calendarModel) { never evaluated: !calendarModel | 0 |
| 1491 | QTableView::mouseReleaseEvent(event); never executed (the execution status of this line is deduced): QTableView::mouseReleaseEvent(event); | - |
| 1492 | return; | 0 |
| 1493 | } | - |
| 1494 | | - |
| 1495 | if (event->button() != Qt::LeftButton) never evaluated: event->button() != Qt::LeftButton | 0 |
| 1496 | return; | 0 |
| 1497 | | - |
| 1498 | if (readOnly) never evaluated: readOnly | 0 |
| 1499 | return; | 0 |
| 1500 | | - |
| 1501 | if (validDateClicked) { never evaluated: validDateClicked | 0 |
| 1502 | QDate date = handleMouseEvent(event); never executed (the execution status of this line is deduced): QDate date = handleMouseEvent(event); | - |
| 1503 | if (date.isValid()) { never evaluated: date.isValid() | 0 |
| 1504 | emit changeDate(date, true); never executed (the execution status of this line is deduced): changeDate(date, true); | - |
| 1505 | emit clicked(date); never executed (the execution status of this line is deduced): clicked(date); | - |
| 1506 | if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick)) never evaluated: style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) | 0 |
| 1507 | emit editingFinished(); never executed: editingFinished(); | 0 |
| 1508 | } | 0 |
| 1509 | validDateClicked = false; never executed (the execution status of this line is deduced): validDateClicked = false; | - |
| 1510 | } else { | 0 |
| 1511 | event->ignore(); never executed (the execution status of this line is deduced): event->ignore(); | - |
| 1512 | } | 0 |
| 1513 | } | - |
| 1514 | | - |
| 1515 | class QCalendarDelegate : public QItemDelegate | - |
| 1516 | { | - |
| 1517 | Q_OBJECT | - |
| 1518 | public: | - |
| 1519 | QCalendarDelegate(QCalendarWidgetPrivate *w, QObject *parent = 0) | - |
| 1520 | : QItemDelegate(parent), calendarWidgetPrivate(w) | - |
| 1521 | { } executed: }Execution Count:27 | 27 |
| 1522 | virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, | - |
| 1523 | const QModelIndex &index) const; | - |
| 1524 | void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const; | - |
| 1525 | | - |
| 1526 | private: | - |
| 1527 | QCalendarWidgetPrivate *calendarWidgetPrivate; | - |
| 1528 | mutable QStyleOptionViewItem storedOption; | - |
| 1529 | }; | - |
| 1530 | | - |
| 1531 | //Private tool button class | - |
| 1532 | class QCalToolButton: public QToolButton | - |
| 1533 | { | - |
| 1534 | public: | - |
| 1535 | QCalToolButton(QWidget * parent) | - |
| 1536 | : QToolButton(parent) | - |
| 1537 | { } executed: }Execution Count:54 | 54 |
| 1538 | protected: | - |
| 1539 | void paintEvent(QPaintEvent *e) | - |
| 1540 | { | - |
| 1541 | Q_UNUSED(e) executed (the execution status of this line is deduced): (void)e; | - |
| 1542 | | - |
| 1543 | #ifndef Q_WS_MAC | - |
| 1544 | QStyleOptionToolButton opt; executed (the execution status of this line is deduced): QStyleOptionToolButton opt; | - |
| 1545 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 1546 | | - |
| 1547 | if (opt.state & QStyle::State_MouseOver || isDown()) { partially evaluated: opt.state & QStyle::State_MouseOver| no Evaluation Count:0 | yes Evaluation Count:93 |
evaluated: isDown()| yes Evaluation Count:1 | yes Evaluation Count:92 |
| 0-93 |
| 1548 | //act as normal button | - |
| 1549 | setPalette(QPalette()); executed (the execution status of this line is deduced): setPalette(QPalette()); | - |
| 1550 | } else { executed: }Execution Count:1 | 1 |
| 1551 | //set the highlight color for button text | - |
| 1552 | QPalette toolPalette = palette(); executed (the execution status of this line is deduced): QPalette toolPalette = palette(); | - |
| 1553 | toolPalette.setColor(QPalette::ButtonText, toolPalette.color(QPalette::HighlightedText)); executed (the execution status of this line is deduced): toolPalette.setColor(QPalette::ButtonText, toolPalette.color(QPalette::HighlightedText)); | - |
| 1554 | setPalette(toolPalette); executed (the execution status of this line is deduced): setPalette(toolPalette); | - |
| 1555 | } executed: }Execution Count:92 | 92 |
| 1556 | #endif | - |
| 1557 | QToolButton::paintEvent(e); executed (the execution status of this line is deduced): QToolButton::paintEvent(e); | - |
| 1558 | } executed: }Execution Count:93 | 93 |
| 1559 | }; | - |
| 1560 | | - |
| 1561 | class QPrevNextCalButton : public QToolButton | - |
| 1562 | { | - |
| 1563 | Q_OBJECT | - |
| 1564 | public: | - |
| 1565 | QPrevNextCalButton(QWidget *parent) : QToolButton(parent) {} executed: }Execution Count:54 | 54 |
| 1566 | protected: | - |
| 1567 | void paintEvent(QPaintEvent *) { | - |
| 1568 | QStylePainter painter(this); executed (the execution status of this line is deduced): QStylePainter painter(this); | - |
| 1569 | QStyleOptionToolButton opt; executed (the execution status of this line is deduced): QStyleOptionToolButton opt; | - |
| 1570 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 1571 | opt.state &= ~QStyle::State_HasFocus; executed (the execution status of this line is deduced): opt.state &= ~QStyle::State_HasFocus; | - |
| 1572 | painter.drawComplexControl(QStyle::CC_ToolButton, opt); executed (the execution status of this line is deduced): painter.drawComplexControl(QStyle::CC_ToolButton, opt); | - |
| 1573 | } executed: }Execution Count:66 | 66 |
| 1574 | }; | - |
| 1575 | | - |
| 1576 | class QCalendarWidgetPrivate : public QWidgetPrivate | - |
| 1577 | { | - |
| 1578 | Q_DECLARE_PUBLIC(QCalendarWidget) | - |
| 1579 | public: | - |
| 1580 | QCalendarWidgetPrivate(); | - |
| 1581 | | - |
| 1582 | void showMonth(int year, int month); | - |
| 1583 | void update(); | - |
| 1584 | void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const; | - |
| 1585 | | - |
| 1586 | void _q_slotShowDate(const QDate &date); | - |
| 1587 | void _q_slotChangeDate(const QDate &date); | - |
| 1588 | void _q_slotChangeDate(const QDate &date, bool changeMonth); | - |
| 1589 | void _q_editingFinished(); | - |
| 1590 | void _q_monthChanged(QAction*); | - |
| 1591 | void _q_prevMonthClicked(); | - |
| 1592 | void _q_nextMonthClicked(); | - |
| 1593 | void _q_yearEditingFinished(); | - |
| 1594 | void _q_yearClicked(); | - |
| 1595 | | - |
| 1596 | void createNavigationBar(QWidget *widget); | - |
| 1597 | void updateButtonIcons(); | - |
| 1598 | void updateMonthMenu(); | - |
| 1599 | void updateMonthMenuNames(); | - |
| 1600 | void updateNavigationBar(); | - |
| 1601 | void updateCurrentPage(const QDate &newDate); | - |
| 1602 | inline QDate getCurrentDate(); | - |
| 1603 | void setNavigatorEnabled(bool enable); | - |
| 1604 | | - |
| 1605 | QCalendarModel *m_model; | - |
| 1606 | QCalendarView *m_view; | - |
| 1607 | QCalendarDelegate *m_delegate; | - |
| 1608 | QItemSelectionModel *m_selection; | - |
| 1609 | QCalendarTextNavigator *m_navigator; | - |
| 1610 | bool m_dateEditEnabled; | - |
| 1611 | | - |
| 1612 | QToolButton *nextMonth; | - |
| 1613 | QToolButton *prevMonth; | - |
| 1614 | QCalToolButton *monthButton; | - |
| 1615 | QMenu *monthMenu; | - |
| 1616 | QMap<int, QAction *> monthToAction; | - |
| 1617 | QCalToolButton *yearButton; | - |
| 1618 | QSpinBox *yearEdit; | - |
| 1619 | QWidget *navBarBackground; | - |
| 1620 | QSpacerItem *spaceHolder; | - |
| 1621 | | - |
| 1622 | bool navBarVisible; | - |
| 1623 | mutable QSize cachedSizeHint; | - |
| 1624 | Qt::FocusPolicy oldFocusPolicy; | - |
| 1625 | }; | - |
| 1626 | | - |
| 1627 | void QCalendarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, | - |
| 1628 | const QModelIndex &index) const | - |
| 1629 | { | - |
| 1630 | QDate date = calendarWidgetPrivate->m_model->dateForCell(index.row(), index.column()); executed (the execution status of this line is deduced): QDate date = calendarWidgetPrivate->m_model->dateForCell(index.row(), index.column()); | - |
| 1631 | if (date.isValid()) { evaluated: date.isValid()| yes Evaluation Count:2058 | yes Evaluation Count:686 |
| 686-2058 |
| 1632 | storedOption = option; executed (the execution status of this line is deduced): storedOption = option; | - |
| 1633 | QRect rect = option.rect; executed (the execution status of this line is deduced): QRect rect = option.rect; | - |
| 1634 | calendarWidgetPrivate->paintCell(painter, rect, date); executed (the execution status of this line is deduced): calendarWidgetPrivate->paintCell(painter, rect, date); | - |
| 1635 | } else { executed: }Execution Count:2058 | 2058 |
| 1636 | QItemDelegate::paint(painter, option, index); executed (the execution status of this line is deduced): QItemDelegate::paint(painter, option, index); | - |
| 1637 | } executed: }Execution Count:686 | 686 |
| 1638 | } | - |
| 1639 | | - |
| 1640 | void QCalendarDelegate::paintCell(QPainter *painter, const QRect &rect, const QDate &date) const | - |
| 1641 | { | - |
| 1642 | storedOption.rect = rect; executed (the execution status of this line is deduced): storedOption.rect = rect; | - |
| 1643 | int row = -1; executed (the execution status of this line is deduced): int row = -1; | - |
| 1644 | int col = -1; executed (the execution status of this line is deduced): int col = -1; | - |
| 1645 | calendarWidgetPrivate->m_model->cellForDate(date, &row, &col); executed (the execution status of this line is deduced): calendarWidgetPrivate->m_model->cellForDate(date, &row, &col); | - |
| 1646 | QModelIndex idx = calendarWidgetPrivate->m_model->index(row, col); executed (the execution status of this line is deduced): QModelIndex idx = calendarWidgetPrivate->m_model->index(row, col); | - |
| 1647 | QItemDelegate::paint(painter, storedOption, idx); executed (the execution status of this line is deduced): QItemDelegate::paint(painter, storedOption, idx); | - |
| 1648 | } executed: }Execution Count:2058 | 2058 |
| 1649 | | - |
| 1650 | QCalendarWidgetPrivate::QCalendarWidgetPrivate() | - |
| 1651 | : QWidgetPrivate() | - |
| 1652 | { | - |
| 1653 | m_model = 0; executed (the execution status of this line is deduced): m_model = 0; | - |
| 1654 | m_view = 0; executed (the execution status of this line is deduced): m_view = 0; | - |
| 1655 | m_delegate = 0; executed (the execution status of this line is deduced): m_delegate = 0; | - |
| 1656 | m_selection = 0; executed (the execution status of this line is deduced): m_selection = 0; | - |
| 1657 | m_navigator = 0; executed (the execution status of this line is deduced): m_navigator = 0; | - |
| 1658 | m_dateEditEnabled = false; executed (the execution status of this line is deduced): m_dateEditEnabled = false; | - |
| 1659 | navBarVisible = true; executed (the execution status of this line is deduced): navBarVisible = true; | - |
| 1660 | oldFocusPolicy = Qt::StrongFocus; executed (the execution status of this line is deduced): oldFocusPolicy = Qt::StrongFocus; | - |
| 1661 | } executed: }Execution Count:27 | 27 |
| 1662 | | - |
| 1663 | void QCalendarWidgetPrivate::setNavigatorEnabled(bool enable) | - |
| 1664 | { | - |
| 1665 | Q_Q(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidget * const q = q_func(); | - |
| 1666 | | - |
| 1667 | bool navigatorEnabled = (m_navigator->widget() != 0); executed (the execution status of this line is deduced): bool navigatorEnabled = (m_navigator->widget() != 0); | - |
| 1668 | if (enable == navigatorEnabled) partially evaluated: enable == navigatorEnabled| no Evaluation Count:0 | yes Evaluation Count:29 |
| 0-29 |
| 1669 | return; | 0 |
| 1670 | | - |
| 1671 | if (enable) { evaluated: enable| yes Evaluation Count:28 | yes Evaluation Count:1 |
| 1-28 |
| 1672 | m_navigator->setWidget(q); executed (the execution status of this line is deduced): m_navigator->setWidget(q); | - |
| 1673 | q->connect(m_navigator, SIGNAL(dateChanged(QDate)), executed (the execution status of this line is deduced): q->connect(m_navigator, "2""dateChanged(QDate)", | - |
| 1674 | q, SLOT(_q_slotChangeDate(QDate))); executed (the execution status of this line is deduced): q, "1""_q_slotChangeDate(QDate)"); | - |
| 1675 | q->connect(m_navigator, SIGNAL(editingFinished()), executed (the execution status of this line is deduced): q->connect(m_navigator, "2""editingFinished()", | - |
| 1676 | q, SLOT(_q_editingFinished())); executed (the execution status of this line is deduced): q, "1""_q_editingFinished()"); | - |
| 1677 | m_view->installEventFilter(m_navigator); executed (the execution status of this line is deduced): m_view->installEventFilter(m_navigator); | - |
| 1678 | } else { executed: }Execution Count:28 | 28 |
| 1679 | m_navigator->setWidget(0); executed (the execution status of this line is deduced): m_navigator->setWidget(0); | - |
| 1680 | q->disconnect(m_navigator, SIGNAL(dateChanged(QDate)), executed (the execution status of this line is deduced): q->disconnect(m_navigator, "2""dateChanged(QDate)", | - |
| 1681 | q, SLOT(_q_slotChangeDate(QDate))); executed (the execution status of this line is deduced): q, "1""_q_slotChangeDate(QDate)"); | - |
| 1682 | q->disconnect(m_navigator, SIGNAL(editingFinished()), executed (the execution status of this line is deduced): q->disconnect(m_navigator, "2""editingFinished()", | - |
| 1683 | q, SLOT(_q_editingFinished())); executed (the execution status of this line is deduced): q, "1""_q_editingFinished()"); | - |
| 1684 | m_view->removeEventFilter(m_navigator); executed (the execution status of this line is deduced): m_view->removeEventFilter(m_navigator); | - |
| 1685 | } executed: }Execution Count:1 | 1 |
| 1686 | } | - |
| 1687 | | - |
| 1688 | void QCalendarWidgetPrivate::createNavigationBar(QWidget *widget) | - |
| 1689 | { | - |
| 1690 | Q_Q(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidget * const q = q_func(); | - |
| 1691 | navBarBackground = new QWidget(widget); executed (the execution status of this line is deduced): navBarBackground = new QWidget(widget); | - |
| 1692 | navBarBackground->setObjectName(QLatin1String("qt_calendar_navigationbar")); executed (the execution status of this line is deduced): navBarBackground->setObjectName(QLatin1String("qt_calendar_navigationbar")); | - |
| 1693 | navBarBackground->setAutoFillBackground(true); executed (the execution status of this line is deduced): navBarBackground->setAutoFillBackground(true); | - |
| 1694 | navBarBackground->setBackgroundRole(QPalette::Highlight); executed (the execution status of this line is deduced): navBarBackground->setBackgroundRole(QPalette::Highlight); | - |
| 1695 | | - |
| 1696 | prevMonth = new QPrevNextCalButton(navBarBackground); executed (the execution status of this line is deduced): prevMonth = new QPrevNextCalButton(navBarBackground); | - |
| 1697 | nextMonth = new QPrevNextCalButton(navBarBackground); executed (the execution status of this line is deduced): nextMonth = new QPrevNextCalButton(navBarBackground); | - |
| 1698 | prevMonth->setAutoRaise(true); executed (the execution status of this line is deduced): prevMonth->setAutoRaise(true); | - |
| 1699 | nextMonth->setAutoRaise(true); executed (the execution status of this line is deduced): nextMonth->setAutoRaise(true); | - |
| 1700 | prevMonth->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); executed (the execution status of this line is deduced): prevMonth->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); | - |
| 1701 | nextMonth->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); executed (the execution status of this line is deduced): nextMonth->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); | - |
| 1702 | nextMonth->setAutoRaise(true); executed (the execution status of this line is deduced): nextMonth->setAutoRaise(true); | - |
| 1703 | updateButtonIcons(); executed (the execution status of this line is deduced): updateButtonIcons(); | - |
| 1704 | prevMonth->setAutoRepeat(true); executed (the execution status of this line is deduced): prevMonth->setAutoRepeat(true); | - |
| 1705 | nextMonth->setAutoRepeat(true); executed (the execution status of this line is deduced): nextMonth->setAutoRepeat(true); | - |
| 1706 | | - |
| 1707 | monthButton = new QCalToolButton(navBarBackground); executed (the execution status of this line is deduced): monthButton = new QCalToolButton(navBarBackground); | - |
| 1708 | monthButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); executed (the execution status of this line is deduced): monthButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); | - |
| 1709 | monthButton->setAutoRaise(true); executed (the execution status of this line is deduced): monthButton->setAutoRaise(true); | - |
| 1710 | monthButton->setPopupMode(QToolButton::InstantPopup); executed (the execution status of this line is deduced): monthButton->setPopupMode(QToolButton::InstantPopup); | - |
| 1711 | monthMenu = new QMenu(monthButton); executed (the execution status of this line is deduced): monthMenu = new QMenu(monthButton); | - |
| 1712 | for (int i = 1; i <= 12; i++) { evaluated: i <= 12| yes Evaluation Count:324 | yes Evaluation Count:27 |
| 27-324 |
| 1713 | QString monthName(q->locale().standaloneMonthName(i, QLocale::LongFormat)); executed (the execution status of this line is deduced): QString monthName(q->locale().standaloneMonthName(i, QLocale::LongFormat)); | - |
| 1714 | QAction *act = monthMenu->addAction(monthName); executed (the execution status of this line is deduced): QAction *act = monthMenu->addAction(monthName); | - |
| 1715 | act->setData(i); executed (the execution status of this line is deduced): act->setData(i); | - |
| 1716 | monthToAction[i] = act; executed (the execution status of this line is deduced): monthToAction[i] = act; | - |
| 1717 | } executed: }Execution Count:324 | 324 |
| 1718 | monthButton->setMenu(monthMenu); executed (the execution status of this line is deduced): monthButton->setMenu(monthMenu); | - |
| 1719 | yearButton = new QCalToolButton(navBarBackground); executed (the execution status of this line is deduced): yearButton = new QCalToolButton(navBarBackground); | - |
| 1720 | yearButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); executed (the execution status of this line is deduced): yearButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); | - |
| 1721 | yearButton->setAutoRaise(true); executed (the execution status of this line is deduced): yearButton->setAutoRaise(true); | - |
| 1722 | yearEdit = new QSpinBox(navBarBackground); executed (the execution status of this line is deduced): yearEdit = new QSpinBox(navBarBackground); | - |
| 1723 | | - |
| 1724 | QFont font = q->font(); executed (the execution status of this line is deduced): QFont font = q->font(); | - |
| 1725 | font.setBold(true); executed (the execution status of this line is deduced): font.setBold(true); | - |
| 1726 | monthButton->setFont(font); executed (the execution status of this line is deduced): monthButton->setFont(font); | - |
| 1727 | yearButton->setFont(font); executed (the execution status of this line is deduced): yearButton->setFont(font); | - |
| 1728 | yearEdit->setFrame(false); executed (the execution status of this line is deduced): yearEdit->setFrame(false); | - |
| 1729 | yearEdit->setMinimum(m_model->m_minimumDate.year()); executed (the execution status of this line is deduced): yearEdit->setMinimum(m_model->m_minimumDate.year()); | - |
| 1730 | yearEdit->setMaximum(m_model->m_maximumDate.year()); executed (the execution status of this line is deduced): yearEdit->setMaximum(m_model->m_maximumDate.year()); | - |
| 1731 | yearEdit->hide(); executed (the execution status of this line is deduced): yearEdit->hide(); | - |
| 1732 | spaceHolder = new QSpacerItem(0,0); executed (the execution status of this line is deduced): spaceHolder = new QSpacerItem(0,0); | - |
| 1733 | | - |
| 1734 | QHBoxLayout *headerLayout = new QHBoxLayout; executed (the execution status of this line is deduced): QHBoxLayout *headerLayout = new QHBoxLayout; | - |
| 1735 | headerLayout->setMargin(0); executed (the execution status of this line is deduced): headerLayout->setMargin(0); | - |
| 1736 | headerLayout->setSpacing(0); executed (the execution status of this line is deduced): headerLayout->setSpacing(0); | - |
| 1737 | headerLayout->addWidget(prevMonth); executed (the execution status of this line is deduced): headerLayout->addWidget(prevMonth); | - |
| 1738 | headerLayout->insertStretch(headerLayout->count()); executed (the execution status of this line is deduced): headerLayout->insertStretch(headerLayout->count()); | - |
| 1739 | headerLayout->addWidget(monthButton); executed (the execution status of this line is deduced): headerLayout->addWidget(monthButton); | - |
| 1740 | headerLayout->addItem(spaceHolder); executed (the execution status of this line is deduced): headerLayout->addItem(spaceHolder); | - |
| 1741 | headerLayout->addWidget(yearButton); executed (the execution status of this line is deduced): headerLayout->addWidget(yearButton); | - |
| 1742 | headerLayout->insertStretch(headerLayout->count()); executed (the execution status of this line is deduced): headerLayout->insertStretch(headerLayout->count()); | - |
| 1743 | headerLayout->addWidget(nextMonth); executed (the execution status of this line is deduced): headerLayout->addWidget(nextMonth); | - |
| 1744 | navBarBackground->setLayout(headerLayout); executed (the execution status of this line is deduced): navBarBackground->setLayout(headerLayout); | - |
| 1745 | | - |
| 1746 | yearEdit->setFocusPolicy(Qt::StrongFocus); executed (the execution status of this line is deduced): yearEdit->setFocusPolicy(Qt::StrongFocus); | - |
| 1747 | prevMonth->setFocusPolicy(Qt::NoFocus); executed (the execution status of this line is deduced): prevMonth->setFocusPolicy(Qt::NoFocus); | - |
| 1748 | nextMonth->setFocusPolicy(Qt::NoFocus); executed (the execution status of this line is deduced): nextMonth->setFocusPolicy(Qt::NoFocus); | - |
| 1749 | yearButton->setFocusPolicy(Qt::NoFocus); executed (the execution status of this line is deduced): yearButton->setFocusPolicy(Qt::NoFocus); | - |
| 1750 | monthButton->setFocusPolicy(Qt::NoFocus); executed (the execution status of this line is deduced): monthButton->setFocusPolicy(Qt::NoFocus); | - |
| 1751 | | - |
| 1752 | //set names for the header controls. | - |
| 1753 | prevMonth->setObjectName(QLatin1String("qt_calendar_prevmonth")); executed (the execution status of this line is deduced): prevMonth->setObjectName(QLatin1String("qt_calendar_prevmonth")); | - |
| 1754 | nextMonth->setObjectName(QLatin1String("qt_calendar_nextmonth")); executed (the execution status of this line is deduced): nextMonth->setObjectName(QLatin1String("qt_calendar_nextmonth")); | - |
| 1755 | monthButton->setObjectName(QLatin1String("qt_calendar_monthbutton")); executed (the execution status of this line is deduced): monthButton->setObjectName(QLatin1String("qt_calendar_monthbutton")); | - |
| 1756 | yearButton->setObjectName(QLatin1String("qt_calendar_yearbutton")); executed (the execution status of this line is deduced): yearButton->setObjectName(QLatin1String("qt_calendar_yearbutton")); | - |
| 1757 | yearEdit->setObjectName(QLatin1String("qt_calendar_yearedit")); executed (the execution status of this line is deduced): yearEdit->setObjectName(QLatin1String("qt_calendar_yearedit")); | - |
| 1758 | | - |
| 1759 | updateMonthMenu(); executed (the execution status of this line is deduced): updateMonthMenu(); | - |
| 1760 | showMonth(m_model->m_date.year(), m_model->m_date.month()); executed (the execution status of this line is deduced): showMonth(m_model->m_date.year(), m_model->m_date.month()); | - |
| 1761 | } executed: }Execution Count:27 | 27 |
| 1762 | | - |
| 1763 | void QCalendarWidgetPrivate::updateButtonIcons() | - |
| 1764 | { | - |
| 1765 | Q_Q(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidget * const q = q_func(); | - |
| 1766 | prevMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowRight : QStyle::SP_ArrowLeft, 0, q)); executed (the execution status of this line is deduced): prevMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowRight : QStyle::SP_ArrowLeft, 0, q)); | - |
| 1767 | nextMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowLeft : QStyle::SP_ArrowRight, 0, q)); executed (the execution status of this line is deduced): nextMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowLeft : QStyle::SP_ArrowRight, 0, q)); | - |
| 1768 | } executed: }Execution Count:29 | 29 |
| 1769 | | - |
| 1770 | void QCalendarWidgetPrivate::updateMonthMenu() | - |
| 1771 | { | - |
| 1772 | int beg = 1, end = 12; executed (the execution status of this line is deduced): int beg = 1, end = 12; | - |
| 1773 | bool prevEnabled = true; executed (the execution status of this line is deduced): bool prevEnabled = true; | - |
| 1774 | bool nextEnabled = true; executed (the execution status of this line is deduced): bool nextEnabled = true; | - |
| 1775 | if (m_model->m_shownYear == m_model->m_minimumDate.year()) { evaluated: m_model->m_shownYear == m_model->m_minimumDate.year()| yes Evaluation Count:22 | yes Evaluation Count:624 |
| 22-624 |
| 1776 | beg = m_model->m_minimumDate.month(); executed (the execution status of this line is deduced): beg = m_model->m_minimumDate.month(); | - |
| 1777 | if (m_model->m_shownMonth == m_model->m_minimumDate.month()) evaluated: m_model->m_shownMonth == m_model->m_minimumDate.month()| yes Evaluation Count:16 | yes Evaluation Count:6 |
| 6-16 |
| 1778 | prevEnabled = false; executed: prevEnabled = false;Execution Count:16 | 16 |
| 1779 | } executed: }Execution Count:22 | 22 |
| 1780 | if (m_model->m_shownYear == m_model->m_maximumDate.year()) { evaluated: m_model->m_shownYear == m_model->m_maximumDate.year()| yes Evaluation Count:16 | yes Evaluation Count:630 |
| 16-630 |
| 1781 | end = m_model->m_maximumDate.month(); executed (the execution status of this line is deduced): end = m_model->m_maximumDate.month(); | - |
| 1782 | if (m_model->m_shownMonth == m_model->m_maximumDate.month()) evaluated: m_model->m_shownMonth == m_model->m_maximumDate.month()| yes Evaluation Count:13 | yes Evaluation Count:3 |
| 3-13 |
| 1783 | nextEnabled = false; executed: nextEnabled = false;Execution Count:13 | 13 |
| 1784 | } executed: }Execution Count:16 | 16 |
| 1785 | prevMonth->setEnabled(prevEnabled); executed (the execution status of this line is deduced): prevMonth->setEnabled(prevEnabled); | - |
| 1786 | nextMonth->setEnabled(nextEnabled); executed (the execution status of this line is deduced): nextMonth->setEnabled(nextEnabled); | - |
| 1787 | for (int i = 1; i <= 12; i++) { evaluated: i <= 12| yes Evaluation Count:7752 | yes Evaluation Count:646 |
| 646-7752 |
| 1788 | bool monthEnabled = true; executed (the execution status of this line is deduced): bool monthEnabled = true; | - |
| 1789 | if (i < beg || i > end) evaluated: i < beg| yes Evaluation Count:51 | yes Evaluation Count:7701 |
evaluated: i > end| yes Evaluation Count:116 | yes Evaluation Count:7585 |
| 51-7701 |
| 1790 | monthEnabled = false; executed: monthEnabled = false;Execution Count:167 | 167 |
| 1791 | monthToAction[i]->setEnabled(monthEnabled); executed (the execution status of this line is deduced): monthToAction[i]->setEnabled(monthEnabled); | - |
| 1792 | } executed: }Execution Count:7752 | 7752 |
| 1793 | } executed: }Execution Count:646 | 646 |
| 1794 | | - |
| 1795 | void QCalendarWidgetPrivate::updateMonthMenuNames() | - |
| 1796 | { | - |
| 1797 | Q_Q(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidget * const q = q_func(); | - |
| 1798 | | - |
| 1799 | for (int i = 1; i <= 12; i++) { evaluated: i <= 12| yes Evaluation Count:48 | yes Evaluation Count:4 |
| 4-48 |
| 1800 | QString monthName(q->locale().standaloneMonthName(i, QLocale::LongFormat)); executed (the execution status of this line is deduced): QString monthName(q->locale().standaloneMonthName(i, QLocale::LongFormat)); | - |
| 1801 | monthToAction[i]->setText(monthName); executed (the execution status of this line is deduced): monthToAction[i]->setText(monthName); | - |
| 1802 | } executed: }Execution Count:48 | 48 |
| 1803 | } executed: }Execution Count:4 | 4 |
| 1804 | | - |
| 1805 | void QCalendarWidgetPrivate::updateCurrentPage(const QDate &date) | - |
| 1806 | { | - |
| 1807 | Q_Q(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidget * const q = q_func(); | - |
| 1808 | | - |
| 1809 | QDate newDate = date; executed (the execution status of this line is deduced): QDate newDate = date; | - |
| 1810 | QDate minDate = q->minimumDate(); executed (the execution status of this line is deduced): QDate minDate = q->minimumDate(); | - |
| 1811 | QDate maxDate = q->maximumDate(); executed (the execution status of this line is deduced): QDate maxDate = q->maximumDate(); | - |
| 1812 | if (minDate.isValid()&& minDate.daysTo(newDate) < 0) partially evaluated: minDate.isValid()| yes Evaluation Count:18 | no Evaluation Count:0 |
partially evaluated: minDate.daysTo(newDate) < 0| no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
| 1813 | newDate = minDate; never executed: newDate = minDate; | 0 |
| 1814 | if (maxDate.isValid()&& maxDate.daysTo(newDate) > 0) partially evaluated: maxDate.isValid()| yes Evaluation Count:18 | no Evaluation Count:0 |
partially evaluated: maxDate.daysTo(newDate) > 0| no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
| 1815 | newDate = maxDate; never executed: newDate = maxDate; | 0 |
| 1816 | showMonth(newDate.year(), newDate.month()); executed (the execution status of this line is deduced): showMonth(newDate.year(), newDate.month()); | - |
| 1817 | int row = -1, col = -1; executed (the execution status of this line is deduced): int row = -1, col = -1; | - |
| 1818 | m_model->cellForDate(newDate, &row, &col); executed (the execution status of this line is deduced): m_model->cellForDate(newDate, &row, &col); | - |
| 1819 | if (row != -1 && col != -1) partially evaluated: row != -1| yes Evaluation Count:18 | no Evaluation Count:0 |
partially evaluated: col != -1| yes Evaluation Count:18 | no Evaluation Count:0 |
| 0-18 |
| 1820 | { | - |
| 1821 | m_view->selectionModel()->setCurrentIndex(m_model->index(row, col), executed (the execution status of this line is deduced): m_view->selectionModel()->setCurrentIndex(m_model->index(row, col), | - |
| 1822 | QItemSelectionModel::NoUpdate); executed (the execution status of this line is deduced): QItemSelectionModel::NoUpdate); | - |
| 1823 | } executed: }Execution Count:18 | 18 |
| 1824 | } executed: }Execution Count:18 | 18 |
| 1825 | | - |
| 1826 | void QCalendarWidgetPrivate::_q_monthChanged(QAction *act) | - |
| 1827 | { | - |
| 1828 | monthButton->setText(act->text()); never executed (the execution status of this line is deduced): monthButton->setText(act->text()); | - |
| 1829 | QDate currentDate = getCurrentDate(); never executed (the execution status of this line is deduced): QDate currentDate = getCurrentDate(); | - |
| 1830 | QDate newDate = currentDate.addMonths(act->data().toInt()-currentDate.month()); never executed (the execution status of this line is deduced): QDate newDate = currentDate.addMonths(act->data().toInt()-currentDate.month()); | - |
| 1831 | updateCurrentPage(newDate); never executed (the execution status of this line is deduced): updateCurrentPage(newDate); | - |
| 1832 | } | 0 |
| 1833 | | - |
| 1834 | QDate QCalendarWidgetPrivate::getCurrentDate() | - |
| 1835 | { | - |
| 1836 | QModelIndex index = m_view->currentIndex(); executed (the execution status of this line is deduced): QModelIndex index = m_view->currentIndex(); | - |
| 1837 | return m_model->dateForCell(index.row(), index.column()); executed: return m_model->dateForCell(index.row(), index.column());Execution Count:217 | 217 |
| 1838 | } | - |
| 1839 | | - |
| 1840 | void QCalendarWidgetPrivate::_q_prevMonthClicked() | - |
| 1841 | { | - |
| 1842 | QDate currentDate = getCurrentDate().addMonths(-1); executed (the execution status of this line is deduced): QDate currentDate = getCurrentDate().addMonths(-1); | - |
| 1843 | updateCurrentPage(currentDate); executed (the execution status of this line is deduced): updateCurrentPage(currentDate); | - |
| 1844 | } executed: }Execution Count:14 | 14 |
| 1845 | | - |
| 1846 | void QCalendarWidgetPrivate::_q_nextMonthClicked() | - |
| 1847 | { | - |
| 1848 | QDate currentDate = getCurrentDate().addMonths(1); executed (the execution status of this line is deduced): QDate currentDate = getCurrentDate().addMonths(1); | - |
| 1849 | updateCurrentPage(currentDate); executed (the execution status of this line is deduced): updateCurrentPage(currentDate); | - |
| 1850 | } executed: }Execution Count:2 | 2 |
| 1851 | | - |
| 1852 | void QCalendarWidgetPrivate::_q_yearEditingFinished() | - |
| 1853 | { | - |
| 1854 | Q_Q(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidget * const q = q_func(); | - |
| 1855 | yearButton->setText(yearEdit->text()); executed (the execution status of this line is deduced): yearButton->setText(yearEdit->text()); | - |
| 1856 | yearEdit->hide(); executed (the execution status of this line is deduced): yearEdit->hide(); | - |
| 1857 | q->setFocusPolicy(oldFocusPolicy); executed (the execution status of this line is deduced): q->setFocusPolicy(oldFocusPolicy); | - |
| 1858 | qApp->removeEventFilter(q); executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->removeEventFilter(q); | - |
| 1859 | spaceHolder->changeSize(0, 0); executed (the execution status of this line is deduced): spaceHolder->changeSize(0, 0); | - |
| 1860 | yearButton->show(); executed (the execution status of this line is deduced): yearButton->show(); | - |
| 1861 | QDate currentDate = getCurrentDate(); executed (the execution status of this line is deduced): QDate currentDate = getCurrentDate(); | - |
| 1862 | currentDate = currentDate.addYears(yearEdit->text().toInt() - currentDate.year()); executed (the execution status of this line is deduced): currentDate = currentDate.addYears(yearEdit->text().toInt() - currentDate.year()); | - |
| 1863 | updateCurrentPage(currentDate); executed (the execution status of this line is deduced): updateCurrentPage(currentDate); | - |
| 1864 | } executed: }Execution Count:2 | 2 |
| 1865 | | - |
| 1866 | void QCalendarWidgetPrivate::_q_yearClicked() | - |
| 1867 | { | - |
| 1868 | Q_Q(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidget * const q = q_func(); | - |
| 1869 | //show the spinbox on top of the button | - |
| 1870 | yearEdit->setGeometry(yearButton->x(), yearButton->y(), executed (the execution status of this line is deduced): yearEdit->setGeometry(yearButton->x(), yearButton->y(), | - |
| 1871 | yearEdit->sizeHint().width(), yearButton->height()); executed (the execution status of this line is deduced): yearEdit->sizeHint().width(), yearButton->height()); | - |
| 1872 | spaceHolder->changeSize(yearButton->width(), 0); executed (the execution status of this line is deduced): spaceHolder->changeSize(yearButton->width(), 0); | - |
| 1873 | yearButton->hide(); executed (the execution status of this line is deduced): yearButton->hide(); | - |
| 1874 | oldFocusPolicy = q->focusPolicy(); executed (the execution status of this line is deduced): oldFocusPolicy = q->focusPolicy(); | - |
| 1875 | q->setFocusPolicy(Qt::NoFocus); executed (the execution status of this line is deduced): q->setFocusPolicy(Qt::NoFocus); | - |
| 1876 | yearEdit->show(); executed (the execution status of this line is deduced): yearEdit->show(); | - |
| 1877 | qApp->installEventFilter(q); executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->installEventFilter(q); | - |
| 1878 | yearEdit->raise(); executed (the execution status of this line is deduced): yearEdit->raise(); | - |
| 1879 | yearEdit->selectAll(); executed (the execution status of this line is deduced): yearEdit->selectAll(); | - |
| 1880 | yearEdit->setFocus(Qt::MouseFocusReason); executed (the execution status of this line is deduced): yearEdit->setFocus(Qt::MouseFocusReason); | - |
| 1881 | } executed: }Execution Count:1 | 1 |
| 1882 | | - |
| 1883 | void QCalendarWidgetPrivate::showMonth(int year, int month) | - |
| 1884 | { | - |
| 1885 | if (m_model->m_shownYear == year && m_model->m_shownMonth == month) evaluated: m_model->m_shownYear == year| yes Evaluation Count:74 | yes Evaluation Count:560 |
evaluated: m_model->m_shownMonth == month| yes Evaluation Count:48 | yes Evaluation Count:26 |
| 26-560 |
| 1886 | return; executed: return;Execution Count:48 | 48 |
| 1887 | Q_Q(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidget * const q = q_func(); | - |
| 1888 | m_model->showMonth(year, month); executed (the execution status of this line is deduced): m_model->showMonth(year, month); | - |
| 1889 | updateNavigationBar(); executed (the execution status of this line is deduced): updateNavigationBar(); | - |
| 1890 | emit q->currentPageChanged(year, month); executed (the execution status of this line is deduced): q->currentPageChanged(year, month); | - |
| 1891 | m_view->internalUpdate(); executed (the execution status of this line is deduced): m_view->internalUpdate(); | - |
| 1892 | cachedSizeHint = QSize(); executed (the execution status of this line is deduced): cachedSizeHint = QSize(); | - |
| 1893 | update(); executed (the execution status of this line is deduced): update(); | - |
| 1894 | updateMonthMenu(); executed (the execution status of this line is deduced): updateMonthMenu(); | - |
| 1895 | } executed: }Execution Count:586 | 586 |
| 1896 | | - |
| 1897 | void QCalendarWidgetPrivate::updateNavigationBar() | - |
| 1898 | { | - |
| 1899 | Q_Q(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidget * const q = q_func(); | - |
| 1900 | | - |
| 1901 | QString monthName = q->locale().standaloneMonthName(m_model->m_shownMonth, QLocale::LongFormat); executed (the execution status of this line is deduced): QString monthName = q->locale().standaloneMonthName(m_model->m_shownMonth, QLocale::LongFormat); | - |
| 1902 | | - |
| 1903 | monthButton->setText(monthName); executed (the execution status of this line is deduced): monthButton->setText(monthName); | - |
| 1904 | yearButton->setText(QString::number(m_model->m_shownYear)); executed (the execution status of this line is deduced): yearButton->setText(QString::number(m_model->m_shownYear)); | - |
| 1905 | yearEdit->setValue(m_model->m_shownYear); executed (the execution status of this line is deduced): yearEdit->setValue(m_model->m_shownYear); | - |
| 1906 | } executed: }Execution Count:617 | 617 |
| 1907 | | - |
| 1908 | void QCalendarWidgetPrivate::update() | - |
| 1909 | { | - |
| 1910 | QDate currentDate = m_model->m_date; executed (the execution status of this line is deduced): QDate currentDate = m_model->m_date; | - |
| 1911 | int row, column; executed (the execution status of this line is deduced): int row, column; | - |
| 1912 | m_model->cellForDate(currentDate, &row, &column); executed (the execution status of this line is deduced): m_model->cellForDate(currentDate, &row, &column); | - |
| 1913 | QModelIndex idx; executed (the execution status of this line is deduced): QModelIndex idx; | - |
| 1914 | m_selection->clear(); executed (the execution status of this line is deduced): m_selection->clear(); | - |
| 1915 | if (row != -1 && column != -1) { evaluated: row != -1| yes Evaluation Count:598 | yes Evaluation Count:576 |
partially evaluated: column != -1| yes Evaluation Count:598 | no Evaluation Count:0 |
| 0-598 |
| 1916 | idx = m_model->index(row, column); executed (the execution status of this line is deduced): idx = m_model->index(row, column); | - |
| 1917 | m_selection->setCurrentIndex(idx, QItemSelectionModel::SelectCurrent); executed (the execution status of this line is deduced): m_selection->setCurrentIndex(idx, QItemSelectionModel::SelectCurrent); | - |
| 1918 | } executed: }Execution Count:598 | 598 |
| 1919 | } executed: }Execution Count:1174 | 1174 |
| 1920 | | - |
| 1921 | void QCalendarWidgetPrivate::paintCell(QPainter *painter, const QRect &rect, const QDate &date) const | - |
| 1922 | { | - |
| 1923 | Q_Q(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidget * const q = q_func(); | - |
| 1924 | q->paintCell(painter, rect, date); executed (the execution status of this line is deduced): q->paintCell(painter, rect, date); | - |
| 1925 | } executed: }Execution Count:2058 | 2058 |
| 1926 | | - |
| 1927 | void QCalendarWidgetPrivate::_q_slotShowDate(const QDate &date) | - |
| 1928 | { | - |
| 1929 | updateCurrentPage(date); never executed (the execution status of this line is deduced): updateCurrentPage(date); | - |
| 1930 | } | 0 |
| 1931 | | - |
| 1932 | void QCalendarWidgetPrivate::_q_slotChangeDate(const QDate &date) | - |
| 1933 | { | - |
| 1934 | _q_slotChangeDate(date, true); never executed (the execution status of this line is deduced): _q_slotChangeDate(date, true); | - |
| 1935 | } | 0 |
| 1936 | | - |
| 1937 | void QCalendarWidgetPrivate::_q_slotChangeDate(const QDate &date, bool changeMonth) | - |
| 1938 | { | - |
| 1939 | QDate oldDate = m_model->m_date; executed (the execution status of this line is deduced): QDate oldDate = m_model->m_date; | - |
| 1940 | m_model->setDate(date); executed (the execution status of this line is deduced): m_model->setDate(date); | - |
| 1941 | QDate newDate = m_model->m_date; executed (the execution status of this line is deduced): QDate newDate = m_model->m_date; | - |
| 1942 | if (changeMonth) partially evaluated: changeMonth| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 1943 | showMonth(newDate.year(), newDate.month()); executed: showMonth(newDate.year(), newDate.month());Execution Count:1 | 1 |
| 1944 | if (oldDate != newDate) { partially evaluated: oldDate != newDate| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 1945 | update(); executed (the execution status of this line is deduced): update(); | - |
| 1946 | Q_Q(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidget * const q = q_func(); | - |
| 1947 | m_navigator->setDate(newDate); executed (the execution status of this line is deduced): m_navigator->setDate(newDate); | - |
| 1948 | emit q->selectionChanged(); executed (the execution status of this line is deduced): q->selectionChanged(); | - |
| 1949 | } executed: }Execution Count:1 | 1 |
| 1950 | } executed: }Execution Count:1 | 1 |
| 1951 | | - |
| 1952 | void QCalendarWidgetPrivate::_q_editingFinished() | - |
| 1953 | { | - |
| 1954 | Q_Q(QCalendarWidget); never executed (the execution status of this line is deduced): QCalendarWidget * const q = q_func(); | - |
| 1955 | emit q->activated(m_model->m_date); never executed (the execution status of this line is deduced): q->activated(m_model->m_date); | - |
| 1956 | } | 0 |
| 1957 | | - |
| 1958 | /*! | - |
| 1959 | \class QCalendarWidget | - |
| 1960 | \brief The QCalendarWidget class provides a monthly based | - |
| 1961 | calendar widget allowing the user to select a date. | - |
| 1962 | \since 4.2 | - |
| 1963 | | - |
| 1964 | \ingroup advanced | - |
| 1965 | \inmodule QtWidgets | - |
| 1966 | | - |
| 1967 | \image fusion-calendarwidget.png | - |
| 1968 | | - |
| 1969 | The widget is initialized with the current month and year, but | - |
| 1970 | QCalendarWidget provides several public slots to change the year | - |
| 1971 | and month that is shown. | - |
| 1972 | | - |
| 1973 | By default, today's date is selected, and the user can select a | - |
| 1974 | date using both mouse and keyboard. The currently selected date | - |
| 1975 | can be retrieved using the selectedDate() function. It is | - |
| 1976 | possible to constrain the user selection to a given date range by | - |
| 1977 | setting the minimumDate and maximumDate properties. | - |
| 1978 | Alternatively, both properties can be set in one go using the | - |
| 1979 | setDateRange() convenience slot. Set the \l selectionMode | - |
| 1980 | property to NoSelection to prohibit the user from selecting at | - |
| 1981 | all. Note that a date also can be selected programmatically using | - |
| 1982 | the setSelectedDate() slot. | - |
| 1983 | | - |
| 1984 | The currently displayed month and year can be retrieved using the | - |
| 1985 | monthShown() and yearShown() functions, respectively. | - |
| 1986 | | - |
| 1987 | A newly created calendar widget uses abbreviated day names, and | - |
| 1988 | both Saturdays and Sundays are marked in red. The calendar grid is | - |
| 1989 | not visible. The week numbers are displayed, and the first column | - |
| 1990 | day is the first day of the week for the calendar's locale. | - |
| 1991 | | - |
| 1992 | The notation of the days can be altered to a single letter | - |
| 1993 | abbreviations ("M" for "Monday") by setting the | - |
| 1994 | horizontalHeaderFormat property to | - |
| 1995 | QCalendarWidget::SingleLetterDayNames. Setting the same property | - |
| 1996 | to QCalendarWidget::LongDayNames makes the header display the | - |
| 1997 | complete day names. The week numbers can be removed by setting | - |
| 1998 | the verticalHeaderFormat property to | - |
| 1999 | QCalendarWidget::NoVerticalHeader. The calendar grid can be | - |
| 2000 | turned on by setting the gridVisible property to true using the | - |
| 2001 | setGridVisible() function: | - |
| 2002 | | - |
| 2003 | \table | - |
| 2004 | \row \li | - |
| 2005 | \image qcalendarwidget-grid.png | - |
| 2006 | \row \li | - |
| 2007 | \snippet code/src_gui_widgets_qcalendarwidget.cpp 0 | - |
| 2008 | \endtable | - |
| 2009 | | - |
| 2010 | Finally, the day in the first column can be altered using the | - |
| 2011 | setFirstDayOfWeek() function. | - |
| 2012 | | - |
| 2013 | The QCalendarWidget class also provides three signals, | - |
| 2014 | selectionChanged(), activated() and currentPageChanged() making it | - |
| 2015 | possible to respond to user interaction. | - |
| 2016 | | - |
| 2017 | The rendering of the headers, weekdays or single days can be | - |
| 2018 | largely customized by setting QTextCharFormat's for some special | - |
| 2019 | weekday, a special date or for the rendering of the headers. | - |
| 2020 | | - |
| 2021 | Only a subset of the properties in QTextCharFormat are used by the | - |
| 2022 | calendar widget. Currently, the foreground, background and font | - |
| 2023 | properties are used to determine the rendering of individual cells | - |
| 2024 | in the widget. | - |
| 2025 | | - |
| 2026 | \sa QDate, QDateEdit, QTextCharFormat | - |
| 2027 | */ | - |
| 2028 | | - |
| 2029 | /*! | - |
| 2030 | \enum QCalendarWidget::SelectionMode | - |
| 2031 | | - |
| 2032 | This enum describes the types of selection offered to the user for | - |
| 2033 | selecting dates in the calendar. | - |
| 2034 | | - |
| 2035 | \value NoSelection Dates cannot be selected. | - |
| 2036 | \value SingleSelection Single dates can be selected. | - |
| 2037 | | - |
| 2038 | \sa selectionMode | - |
| 2039 | */ | - |
| 2040 | | - |
| 2041 | /*! | - |
| 2042 | Constructs a calendar widget with the given \a parent. | - |
| 2043 | | - |
| 2044 | The widget is initialized with the current month and year, and the | - |
| 2045 | currently selected date is today. | - |
| 2046 | | - |
| 2047 | \sa setCurrentPage() | - |
| 2048 | */ | - |
| 2049 | QCalendarWidget::QCalendarWidget(QWidget *parent) | - |
| 2050 | : QWidget(*new QCalendarWidgetPrivate, parent, 0) | - |
| 2051 | { | - |
| 2052 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2053 | | - |
| 2054 | setAutoFillBackground(true); executed (the execution status of this line is deduced): setAutoFillBackground(true); | - |
| 2055 | setBackgroundRole(QPalette::Window); executed (the execution status of this line is deduced): setBackgroundRole(QPalette::Window); | - |
| 2056 | | - |
| 2057 | QVBoxLayout *layoutV = new QVBoxLayout(this); executed (the execution status of this line is deduced): QVBoxLayout *layoutV = new QVBoxLayout(this); | - |
| 2058 | layoutV->setMargin(0); executed (the execution status of this line is deduced): layoutV->setMargin(0); | - |
| 2059 | d->m_model = new QCalendarModel(this); executed (the execution status of this line is deduced): d->m_model = new QCalendarModel(this); | - |
| 2060 | QTextCharFormat fmt; executed (the execution status of this line is deduced): QTextCharFormat fmt; | - |
| 2061 | fmt.setForeground(QBrush(Qt::red)); executed (the execution status of this line is deduced): fmt.setForeground(QBrush(Qt::red)); | - |
| 2062 | d->m_model->m_dayFormats.insert(Qt::Saturday, fmt); executed (the execution status of this line is deduced): d->m_model->m_dayFormats.insert(Qt::Saturday, fmt); | - |
| 2063 | d->m_model->m_dayFormats.insert(Qt::Sunday, fmt); executed (the execution status of this line is deduced): d->m_model->m_dayFormats.insert(Qt::Sunday, fmt); | - |
| 2064 | d->m_view = new QCalendarView(this); executed (the execution status of this line is deduced): d->m_view = new QCalendarView(this); | - |
| 2065 | d->m_view->setObjectName(QLatin1String("qt_calendar_calendarview")); executed (the execution status of this line is deduced): d->m_view->setObjectName(QLatin1String("qt_calendar_calendarview")); | - |
| 2066 | d->m_view->setModel(d->m_model); executed (the execution status of this line is deduced): d->m_view->setModel(d->m_model); | - |
| 2067 | d->m_model->setView(d->m_view); executed (the execution status of this line is deduced): d->m_model->setView(d->m_view); | - |
| 2068 | d->m_view->setSelectionBehavior(QAbstractItemView::SelectItems); executed (the execution status of this line is deduced): d->m_view->setSelectionBehavior(QAbstractItemView::SelectItems); | - |
| 2069 | d->m_view->setSelectionMode(QAbstractItemView::SingleSelection); executed (the execution status of this line is deduced): d->m_view->setSelectionMode(QAbstractItemView::SingleSelection); | - |
| 2070 | d->m_view->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); executed (the execution status of this line is deduced): d->m_view->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); | - |
| 2071 | d->m_view->horizontalHeader()->setSectionsClickable(false); executed (the execution status of this line is deduced): d->m_view->horizontalHeader()->setSectionsClickable(false); | - |
| 2072 | d->m_view->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); executed (the execution status of this line is deduced): d->m_view->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); | - |
| 2073 | d->m_view->verticalHeader()->setSectionsClickable(false); executed (the execution status of this line is deduced): d->m_view->verticalHeader()->setSectionsClickable(false); | - |
| 2074 | d->m_selection = d->m_view->selectionModel(); executed (the execution status of this line is deduced): d->m_selection = d->m_view->selectionModel(); | - |
| 2075 | d->createNavigationBar(this); executed (the execution status of this line is deduced): d->createNavigationBar(this); | - |
| 2076 | d->m_view->setFrameStyle(QFrame::NoFrame); executed (the execution status of this line is deduced): d->m_view->setFrameStyle(QFrame::NoFrame); | - |
| 2077 | d->m_delegate = new QCalendarDelegate(d, this); executed (the execution status of this line is deduced): d->m_delegate = new QCalendarDelegate(d, this); | - |
| 2078 | d->m_view->setItemDelegate(d->m_delegate); executed (the execution status of this line is deduced): d->m_view->setItemDelegate(d->m_delegate); | - |
| 2079 | d->update(); executed (the execution status of this line is deduced): d->update(); | - |
| 2080 | d->updateNavigationBar(); executed (the execution status of this line is deduced): d->updateNavigationBar(); | - |
| 2081 | setFocusPolicy(Qt::StrongFocus); executed (the execution status of this line is deduced): setFocusPolicy(Qt::StrongFocus); | - |
| 2082 | setFocusProxy(d->m_view); executed (the execution status of this line is deduced): setFocusProxy(d->m_view); | - |
| 2083 | setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); executed (the execution status of this line is deduced): setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); | - |
| 2084 | | - |
| 2085 | connect(d->m_view, SIGNAL(showDate(QDate)), executed (the execution status of this line is deduced): connect(d->m_view, "2""showDate(QDate)", | - |
| 2086 | this, SLOT(_q_slotShowDate(QDate))); executed (the execution status of this line is deduced): this, "1""_q_slotShowDate(QDate)"); | - |
| 2087 | connect(d->m_view, SIGNAL(changeDate(QDate,bool)), executed (the execution status of this line is deduced): connect(d->m_view, "2""changeDate(QDate,bool)", | - |
| 2088 | this, SLOT(_q_slotChangeDate(QDate,bool))); executed (the execution status of this line is deduced): this, "1""_q_slotChangeDate(QDate,bool)"); | - |
| 2089 | connect(d->m_view, SIGNAL(clicked(QDate)), executed (the execution status of this line is deduced): connect(d->m_view, "2""clicked(QDate)", | - |
| 2090 | this, SIGNAL(clicked(QDate))); executed (the execution status of this line is deduced): this, "2""clicked(QDate)"); | - |
| 2091 | connect(d->m_view, SIGNAL(editingFinished()), executed (the execution status of this line is deduced): connect(d->m_view, "2""editingFinished()", | - |
| 2092 | this, SLOT(_q_editingFinished())); executed (the execution status of this line is deduced): this, "1""_q_editingFinished()"); | - |
| 2093 | | - |
| 2094 | connect(d->prevMonth, SIGNAL(clicked(bool)), executed (the execution status of this line is deduced): connect(d->prevMonth, "2""clicked(bool)", | - |
| 2095 | this, SLOT(_q_prevMonthClicked())); executed (the execution status of this line is deduced): this, "1""_q_prevMonthClicked()"); | - |
| 2096 | connect(d->nextMonth, SIGNAL(clicked(bool)), executed (the execution status of this line is deduced): connect(d->nextMonth, "2""clicked(bool)", | - |
| 2097 | this, SLOT(_q_nextMonthClicked())); executed (the execution status of this line is deduced): this, "1""_q_nextMonthClicked()"); | - |
| 2098 | connect(d->yearButton, SIGNAL(clicked(bool)), executed (the execution status of this line is deduced): connect(d->yearButton, "2""clicked(bool)", | - |
| 2099 | this, SLOT(_q_yearClicked())); executed (the execution status of this line is deduced): this, "1""_q_yearClicked()"); | - |
| 2100 | connect(d->monthMenu, SIGNAL(triggered(QAction*)), executed (the execution status of this line is deduced): connect(d->monthMenu, "2""triggered(QAction*)", | - |
| 2101 | this, SLOT(_q_monthChanged(QAction*))); executed (the execution status of this line is deduced): this, "1""_q_monthChanged(QAction*)"); | - |
| 2102 | connect(d->yearEdit, SIGNAL(editingFinished()), executed (the execution status of this line is deduced): connect(d->yearEdit, "2""editingFinished()", | - |
| 2103 | this, SLOT(_q_yearEditingFinished())); executed (the execution status of this line is deduced): this, "1""_q_yearEditingFinished()"); | - |
| 2104 | | - |
| 2105 | layoutV->setMargin(0); executed (the execution status of this line is deduced): layoutV->setMargin(0); | - |
| 2106 | layoutV->setSpacing(0); executed (the execution status of this line is deduced): layoutV->setSpacing(0); | - |
| 2107 | layoutV->addWidget(d->navBarBackground); executed (the execution status of this line is deduced): layoutV->addWidget(d->navBarBackground); | - |
| 2108 | layoutV->addWidget(d->m_view); executed (the execution status of this line is deduced): layoutV->addWidget(d->m_view); | - |
| 2109 | | - |
| 2110 | d->m_navigator = new QCalendarTextNavigator(this); executed (the execution status of this line is deduced): d->m_navigator = new QCalendarTextNavigator(this); | - |
| 2111 | setDateEditEnabled(true); executed (the execution status of this line is deduced): setDateEditEnabled(true); | - |
| 2112 | } executed: }Execution Count:27 | 27 |
| 2113 | | - |
| 2114 | /*! | - |
| 2115 | Destroys the calendar widget. | - |
| 2116 | */ | - |
| 2117 | QCalendarWidget::~QCalendarWidget() | - |
| 2118 | { | - |
| 2119 | } | - |
| 2120 | | - |
| 2121 | /*! | - |
| 2122 | \reimp | - |
| 2123 | */ | - |
| 2124 | QSize QCalendarWidget::sizeHint() const | - |
| 2125 | { | - |
| 2126 | return minimumSizeHint(); executed: return minimumSizeHint();Execution Count:18 | 18 |
| 2127 | } | - |
| 2128 | | - |
| 2129 | /*! | - |
| 2130 | \reimp | - |
| 2131 | */ | - |
| 2132 | QSize QCalendarWidget::minimumSizeHint() const | - |
| 2133 | { | - |
| 2134 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2135 | if (d->cachedSizeHint.isValid()) evaluated: d->cachedSizeHint.isValid()| yes Evaluation Count:6 | yes Evaluation Count:16 |
| 6-16 |
| 2136 | return d->cachedSizeHint; executed: return d->cachedSizeHint;Execution Count:6 | 6 |
| 2137 | | - |
| 2138 | ensurePolished(); executed (the execution status of this line is deduced): ensurePolished(); | - |
| 2139 | | - |
| 2140 | int w = 0; executed (the execution status of this line is deduced): int w = 0; | - |
| 2141 | int h = 0; executed (the execution status of this line is deduced): int h = 0; | - |
| 2142 | | - |
| 2143 | int end = 53; executed (the execution status of this line is deduced): int end = 53; | - |
| 2144 | int rows = 7; executed (the execution status of this line is deduced): int rows = 7; | - |
| 2145 | int cols = 8; executed (the execution status of this line is deduced): int cols = 8; | - |
| 2146 | | - |
| 2147 | const int marginH = (style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1) * 2; executed (the execution status of this line is deduced): const int marginH = (style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1) * 2; | - |
| 2148 | | - |
| 2149 | if (horizontalHeaderFormat() == QCalendarWidget::NoHorizontalHeader) { partially evaluated: horizontalHeaderFormat() == QCalendarWidget::NoHorizontalHeader| no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
| 2150 | rows = 6; never executed (the execution status of this line is deduced): rows = 6; | - |
| 2151 | } else { | 0 |
| 2152 | for (int i = 1; i <= 7; i++) { evaluated: i <= 7| yes Evaluation Count:112 | yes Evaluation Count:16 |
| 16-112 |
| 2153 | QFontMetrics fm(d->m_model->formatForCell(0, i).font()); executed (the execution status of this line is deduced): QFontMetrics fm(d->m_model->formatForCell(0, i).font()); | - |
| 2154 | w = qMax(w, fm.width(d->m_model->dayName(d->m_model->dayOfWeekForColumn(i))) + marginH); executed (the execution status of this line is deduced): w = qMax(w, fm.width(d->m_model->dayName(d->m_model->dayOfWeekForColumn(i))) + marginH); | - |
| 2155 | h = qMax(h, fm.height()); executed (the execution status of this line is deduced): h = qMax(h, fm.height()); | - |
| 2156 | } executed: }Execution Count:112 | 112 |
| 2157 | } executed: }Execution Count:16 | 16 |
| 2158 | | - |
| 2159 | if (verticalHeaderFormat() == QCalendarWidget::NoVerticalHeader) { evaluated: verticalHeaderFormat() == QCalendarWidget::NoVerticalHeader| yes Evaluation Count:1 | yes Evaluation Count:15 |
| 1-15 |
| 2160 | cols = 7; executed (the execution status of this line is deduced): cols = 7; | - |
| 2161 | } else { executed: }Execution Count:1 | 1 |
| 2162 | for (int i = 1; i <= 6; i++) { evaluated: i <= 6| yes Evaluation Count:90 | yes Evaluation Count:15 |
| 15-90 |
| 2163 | QFontMetrics fm(d->m_model->formatForCell(i, 0).font()); executed (the execution status of this line is deduced): QFontMetrics fm(d->m_model->formatForCell(i, 0).font()); | - |
| 2164 | for (int j = 1; j < end; j++) evaluated: j < end| yes Evaluation Count:4680 | yes Evaluation Count:90 |
| 90-4680 |
| 2165 | w = qMax(w, fm.width(QString::number(j)) + marginH); executed: w = qMax(w, fm.width(QString::number(j)) + marginH);Execution Count:4680 | 4680 |
| 2166 | h = qMax(h, fm.height()); executed (the execution status of this line is deduced): h = qMax(h, fm.height()); | - |
| 2167 | } executed: }Execution Count:90 | 90 |
| 2168 | } executed: }Execution Count:15 | 15 |
| 2169 | | - |
| 2170 | QFontMetrics fm(d->m_model->formatForCell(1, 1).font()); executed (the execution status of this line is deduced): QFontMetrics fm(d->m_model->formatForCell(1, 1).font()); | - |
| 2171 | for (int i = 1; i <= end; i++) { evaluated: i <= end| yes Evaluation Count:848 | yes Evaluation Count:16 |
| 16-848 |
| 2172 | w = qMax(w, fm.width(QString::number(i)) + marginH); executed (the execution status of this line is deduced): w = qMax(w, fm.width(QString::number(i)) + marginH); | - |
| 2173 | h = qMax(h, fm.height()); executed (the execution status of this line is deduced): h = qMax(h, fm.height()); | - |
| 2174 | } executed: }Execution Count:848 | 848 |
| 2175 | | - |
| 2176 | if (d->m_view->showGrid()) { partially evaluated: d->m_view->showGrid()| no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
| 2177 | // hardcoded in tableview | - |
| 2178 | w += 1; never executed (the execution status of this line is deduced): w += 1; | - |
| 2179 | h += 1; never executed (the execution status of this line is deduced): h += 1; | - |
| 2180 | } | 0 |
| 2181 | | - |
| 2182 | w += 1; // default column span executed (the execution status of this line is deduced): w += 1; | - |
| 2183 | | - |
| 2184 | h = qMax(h, d->m_view->verticalHeader()->minimumSectionSize()); executed (the execution status of this line is deduced): h = qMax(h, d->m_view->verticalHeader()->minimumSectionSize()); | - |
| 2185 | w = qMax(w, d->m_view->horizontalHeader()->minimumSectionSize()); executed (the execution status of this line is deduced): w = qMax(w, d->m_view->horizontalHeader()->minimumSectionSize()); | - |
| 2186 | | - |
| 2187 | //add the size of the header. | - |
| 2188 | QSize headerSize(0, 0); executed (the execution status of this line is deduced): QSize headerSize(0, 0); | - |
| 2189 | if (d->navBarVisible) { partially evaluated: d->navBarVisible| yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
| 2190 | int headerH = d->navBarBackground->sizeHint().height(); executed (the execution status of this line is deduced): int headerH = d->navBarBackground->sizeHint().height(); | - |
| 2191 | int headerW = 0; executed (the execution status of this line is deduced): int headerW = 0; | - |
| 2192 | | - |
| 2193 | headerW += d->prevMonth->sizeHint().width(); executed (the execution status of this line is deduced): headerW += d->prevMonth->sizeHint().width(); | - |
| 2194 | headerW += d->nextMonth->sizeHint().width(); executed (the execution status of this line is deduced): headerW += d->nextMonth->sizeHint().width(); | - |
| 2195 | | - |
| 2196 | QFontMetrics fm = d->monthButton->fontMetrics(); executed (the execution status of this line is deduced): QFontMetrics fm = d->monthButton->fontMetrics(); | - |
| 2197 | int monthW = 0; executed (the execution status of this line is deduced): int monthW = 0; | - |
| 2198 | for (int i = 1; i < 12; i++) { evaluated: i < 12| yes Evaluation Count:176 | yes Evaluation Count:16 |
| 16-176 |
| 2199 | QString monthName = locale().standaloneMonthName(i, QLocale::LongFormat); executed (the execution status of this line is deduced): QString monthName = locale().standaloneMonthName(i, QLocale::LongFormat); | - |
| 2200 | monthW = qMax(monthW, fm.boundingRect(monthName).width()); executed (the execution status of this line is deduced): monthW = qMax(monthW, fm.boundingRect(monthName).width()); | - |
| 2201 | } executed: }Execution Count:176 | 176 |
| 2202 | const int buttonDecoMargin = d->monthButton->sizeHint().width() - fm.boundingRect(d->monthButton->text()).width(); executed (the execution status of this line is deduced): const int buttonDecoMargin = d->monthButton->sizeHint().width() - fm.boundingRect(d->monthButton->text()).width(); | - |
| 2203 | headerW += monthW + buttonDecoMargin; executed (the execution status of this line is deduced): headerW += monthW + buttonDecoMargin; | - |
| 2204 | | - |
| 2205 | fm = d->yearButton->fontMetrics(); executed (the execution status of this line is deduced): fm = d->yearButton->fontMetrics(); | - |
| 2206 | headerW += fm.boundingRect(QLatin1String("5555")).width() + buttonDecoMargin; executed (the execution status of this line is deduced): headerW += fm.boundingRect(QLatin1String("5555")).width() + buttonDecoMargin; | - |
| 2207 | | - |
| 2208 | headerSize = QSize(headerW, headerH); executed (the execution status of this line is deduced): headerSize = QSize(headerW, headerH); | - |
| 2209 | } executed: }Execution Count:16 | 16 |
| 2210 | w *= cols; executed (the execution status of this line is deduced): w *= cols; | - |
| 2211 | w = qMax(headerSize.width(), w); executed (the execution status of this line is deduced): w = qMax(headerSize.width(), w); | - |
| 2212 | h = (h * rows) + headerSize.height(); executed (the execution status of this line is deduced): h = (h * rows) + headerSize.height(); | - |
| 2213 | d->cachedSizeHint = QSize(w, h); executed (the execution status of this line is deduced): d->cachedSizeHint = QSize(w, h); | - |
| 2214 | return d->cachedSizeHint; executed: return d->cachedSizeHint;Execution Count:16 | 16 |
| 2215 | } | - |
| 2216 | | - |
| 2217 | /*! | - |
| 2218 | Paints the cell specified by the given \a date, using the given \a painter and \a rect. | - |
| 2219 | */ | - |
| 2220 | | - |
| 2221 | void QCalendarWidget::paintCell(QPainter *painter, const QRect &rect, const QDate &date) const | - |
| 2222 | { | - |
| 2223 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2224 | d->m_delegate->paintCell(painter, rect, date); executed (the execution status of this line is deduced): d->m_delegate->paintCell(painter, rect, date); | - |
| 2225 | } executed: }Execution Count:2058 | 2058 |
| 2226 | | - |
| 2227 | /*! | - |
| 2228 | \property QCalendarWidget::selectedDate | - |
| 2229 | \brief the currently selected date. | - |
| 2230 | | - |
| 2231 | The selected date must be within the date range specified by the | - |
| 2232 | minimumDate and maximumDate properties. By default, the selected | - |
| 2233 | date is the current date. | - |
| 2234 | | - |
| 2235 | \sa setDateRange() | - |
| 2236 | */ | - |
| 2237 | | - |
| 2238 | QDate QCalendarWidget::selectedDate() const | - |
| 2239 | { | - |
| 2240 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2241 | return d->m_model->m_date; executed: return d->m_model->m_date;Execution Count:561 | 561 |
| 2242 | } | - |
| 2243 | | - |
| 2244 | void QCalendarWidget::setSelectedDate(const QDate &date) | - |
| 2245 | { | - |
| 2246 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2247 | if (d->m_model->m_date == date && date == d->getCurrentDate()) evaluated: d->m_model->m_date == date| yes Evaluation Count:168 | yes Evaluation Count:550 |
partially evaluated: date == d->getCurrentDate()| yes Evaluation Count:168 | no Evaluation Count:0 |
| 0-550 |
| 2248 | return; executed: return;Execution Count:168 | 168 |
| 2249 | | - |
| 2250 | if (!date.isValid()) partially evaluated: !date.isValid()| no Evaluation Count:0 | yes Evaluation Count:550 |
| 0-550 |
| 2251 | return; | 0 |
| 2252 | | - |
| 2253 | d->m_model->setDate(date); executed (the execution status of this line is deduced): d->m_model->setDate(date); | - |
| 2254 | d->update(); executed (the execution status of this line is deduced): d->update(); | - |
| 2255 | QDate newDate = d->m_model->m_date; executed (the execution status of this line is deduced): QDate newDate = d->m_model->m_date; | - |
| 2256 | d->showMonth(newDate.year(), newDate.month()); executed (the execution status of this line is deduced): d->showMonth(newDate.year(), newDate.month()); | - |
| 2257 | emit selectionChanged(); executed (the execution status of this line is deduced): selectionChanged(); | - |
| 2258 | } executed: }Execution Count:550 | 550 |
| 2259 | | - |
| 2260 | /*! | - |
| 2261 | Returns the year of the currently displayed month. Months are | - |
| 2262 | numbered from 1 to 12. | - |
| 2263 | | - |
| 2264 | \sa monthShown(), setCurrentPage() | - |
| 2265 | */ | - |
| 2266 | | - |
| 2267 | int QCalendarWidget::yearShown() const | - |
| 2268 | { | - |
| 2269 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2270 | return d->m_model->m_shownYear; executed: return d->m_model->m_shownYear;Execution Count:60 | 60 |
| 2271 | } | - |
| 2272 | | - |
| 2273 | /*! | - |
| 2274 | Returns the currently displayed month. Months are numbered from 1 to | - |
| 2275 | 12. | - |
| 2276 | | - |
| 2277 | \sa yearShown(), setCurrentPage() | - |
| 2278 | */ | - |
| 2279 | | - |
| 2280 | int QCalendarWidget::monthShown() const | - |
| 2281 | { | - |
| 2282 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2283 | return d->m_model->m_shownMonth; executed: return d->m_model->m_shownMonth;Execution Count:65 | 65 |
| 2284 | } | - |
| 2285 | | - |
| 2286 | /*! | - |
| 2287 | Displays the given \a month of the given \a year without changing | - |
| 2288 | the selected date. Use the setSelectedDate() function to alter the | - |
| 2289 | selected date. | - |
| 2290 | | - |
| 2291 | The currently displayed month and year can be retrieved using the | - |
| 2292 | monthShown() and yearShown() functions respectively. | - |
| 2293 | | - |
| 2294 | \sa yearShown(), monthShown(), showPreviousMonth(), showNextMonth(), | - |
| 2295 | showPreviousYear(), showNextYear() | - |
| 2296 | */ | - |
| 2297 | | - |
| 2298 | void QCalendarWidget::setCurrentPage(int year, int month) | - |
| 2299 | { | - |
| 2300 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2301 | QDate currentDate = d->getCurrentDate(); executed (the execution status of this line is deduced): QDate currentDate = d->getCurrentDate(); | - |
| 2302 | int day = currentDate.day(); executed (the execution status of this line is deduced): int day = currentDate.day(); | - |
| 2303 | int daysInMonths = QDate(year, month, 1).daysInMonth(); executed (the execution status of this line is deduced): int daysInMonths = QDate(year, month, 1).daysInMonth(); | - |
| 2304 | if (day > daysInMonths) evaluated: day > daysInMonths| yes Evaluation Count:3 | yes Evaluation Count:28 |
| 3-28 |
| 2305 | day = daysInMonths; executed: day = daysInMonths;Execution Count:3 | 3 |
| 2306 | | - |
| 2307 | d->showMonth(year, month); executed (the execution status of this line is deduced): d->showMonth(year, month); | - |
| 2308 | | - |
| 2309 | QDate newDate(year, month, day); executed (the execution status of this line is deduced): QDate newDate(year, month, day); | - |
| 2310 | int row = -1, col = -1; executed (the execution status of this line is deduced): int row = -1, col = -1; | - |
| 2311 | d->m_model->cellForDate(newDate, &row, &col); executed (the execution status of this line is deduced): d->m_model->cellForDate(newDate, &row, &col); | - |
| 2312 | if (row != -1 && col != -1) { partially evaluated: row != -1| yes Evaluation Count:31 | no Evaluation Count:0 |
partially evaluated: col != -1| yes Evaluation Count:31 | no Evaluation Count:0 |
| 0-31 |
| 2313 | d->m_view->selectionModel()->setCurrentIndex(d->m_model->index(row, col), executed (the execution status of this line is deduced): d->m_view->selectionModel()->setCurrentIndex(d->m_model->index(row, col), | - |
| 2314 | QItemSelectionModel::NoUpdate); executed (the execution status of this line is deduced): QItemSelectionModel::NoUpdate); | - |
| 2315 | } executed: }Execution Count:31 | 31 |
| 2316 | } executed: }Execution Count:31 | 31 |
| 2317 | | - |
| 2318 | /*! | - |
| 2319 | Shows the next month relative to the currently displayed | - |
| 2320 | month. Note that the selected date is not changed. | - |
| 2321 | | - |
| 2322 | \sa showPreviousMonth(), setCurrentPage(), setSelectedDate() | - |
| 2323 | */ | - |
| 2324 | | - |
| 2325 | void QCalendarWidget::showNextMonth() | - |
| 2326 | { | - |
| 2327 | int year = yearShown(); executed (the execution status of this line is deduced): int year = yearShown(); | - |
| 2328 | int month = monthShown(); executed (the execution status of this line is deduced): int month = monthShown(); | - |
| 2329 | if (month == 12) { evaluated: month == 12| yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
| 2330 | ++year; executed (the execution status of this line is deduced): ++year; | - |
| 2331 | month = 1; executed (the execution status of this line is deduced): month = 1; | - |
| 2332 | } else { executed: }Execution Count:1 | 1 |
| 2333 | ++month; executed (the execution status of this line is deduced): ++month; | - |
| 2334 | } executed: }Execution Count:4 | 4 |
| 2335 | setCurrentPage(year, month); executed (the execution status of this line is deduced): setCurrentPage(year, month); | - |
| 2336 | } executed: }Execution Count:5 | 5 |
| 2337 | | - |
| 2338 | /*! | - |
| 2339 | Shows the previous month relative to the currently displayed | - |
| 2340 | month. Note that the selected date is not changed. | - |
| 2341 | | - |
| 2342 | \sa showNextMonth(), setCurrentPage(), setSelectedDate() | - |
| 2343 | */ | - |
| 2344 | | - |
| 2345 | void QCalendarWidget::showPreviousMonth() | - |
| 2346 | { | - |
| 2347 | int year = yearShown(); executed (the execution status of this line is deduced): int year = yearShown(); | - |
| 2348 | int month = monthShown(); executed (the execution status of this line is deduced): int month = monthShown(); | - |
| 2349 | if (month == 1) { evaluated: month == 1| yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
| 2350 | --year; executed (the execution status of this line is deduced): --year; | - |
| 2351 | month = 12; executed (the execution status of this line is deduced): month = 12; | - |
| 2352 | } else { executed: }Execution Count:1 | 1 |
| 2353 | --month; executed (the execution status of this line is deduced): --month; | - |
| 2354 | } executed: }Execution Count:3 | 3 |
| 2355 | setCurrentPage(year, month); executed (the execution status of this line is deduced): setCurrentPage(year, month); | - |
| 2356 | } executed: }Execution Count:4 | 4 |
| 2357 | | - |
| 2358 | /*! | - |
| 2359 | Shows the currently displayed month in the \e next year relative | - |
| 2360 | to the currently displayed year. Note that the selected date is | - |
| 2361 | not changed. | - |
| 2362 | | - |
| 2363 | \sa showPreviousYear(), setCurrentPage(), setSelectedDate() | - |
| 2364 | */ | - |
| 2365 | | - |
| 2366 | void QCalendarWidget::showNextYear() | - |
| 2367 | { | - |
| 2368 | int year = yearShown(); executed (the execution status of this line is deduced): int year = yearShown(); | - |
| 2369 | int month = monthShown(); executed (the execution status of this line is deduced): int month = monthShown(); | - |
| 2370 | ++year; executed (the execution status of this line is deduced): ++year; | - |
| 2371 | setCurrentPage(year, month); executed (the execution status of this line is deduced): setCurrentPage(year, month); | - |
| 2372 | } executed: }Execution Count:3 | 3 |
| 2373 | | - |
| 2374 | /*! | - |
| 2375 | Shows the currently displayed month in the \e previous year | - |
| 2376 | relative to the currently displayed year. Note that the selected | - |
| 2377 | date is not changed. | - |
| 2378 | | - |
| 2379 | \sa showNextYear(), setCurrentPage(), setSelectedDate() | - |
| 2380 | */ | - |
| 2381 | | - |
| 2382 | void QCalendarWidget::showPreviousYear() | - |
| 2383 | { | - |
| 2384 | int year = yearShown(); executed (the execution status of this line is deduced): int year = yearShown(); | - |
| 2385 | int month = monthShown(); executed (the execution status of this line is deduced): int month = monthShown(); | - |
| 2386 | --year; executed (the execution status of this line is deduced): --year; | - |
| 2387 | setCurrentPage(year, month); executed (the execution status of this line is deduced): setCurrentPage(year, month); | - |
| 2388 | } executed: }Execution Count:3 | 3 |
| 2389 | | - |
| 2390 | /*! | - |
| 2391 | Shows the month of the selected date. | - |
| 2392 | | - |
| 2393 | \sa selectedDate(), setCurrentPage() | - |
| 2394 | */ | - |
| 2395 | void QCalendarWidget::showSelectedDate() | - |
| 2396 | { | - |
| 2397 | QDate currentDate = selectedDate(); executed (the execution status of this line is deduced): QDate currentDate = selectedDate(); | - |
| 2398 | setCurrentPage(currentDate.year(), currentDate.month()); executed (the execution status of this line is deduced): setCurrentPage(currentDate.year(), currentDate.month()); | - |
| 2399 | } executed: }Execution Count:4 | 4 |
| 2400 | | - |
| 2401 | /*! | - |
| 2402 | Shows the month of the today's date. | - |
| 2403 | | - |
| 2404 | \sa selectedDate(), setCurrentPage() | - |
| 2405 | */ | - |
| 2406 | void QCalendarWidget::showToday() | - |
| 2407 | { | - |
| 2408 | QDate currentDate = QDate::currentDate(); executed (the execution status of this line is deduced): QDate currentDate = QDate::currentDate(); | - |
| 2409 | setCurrentPage(currentDate.year(), currentDate.month()); executed (the execution status of this line is deduced): setCurrentPage(currentDate.year(), currentDate.month()); | - |
| 2410 | } executed: }Execution Count:2 | 2 |
| 2411 | | - |
| 2412 | /*! | - |
| 2413 | \property QCalendarWidget::minimumDate | - |
| 2414 | \brief the minimum date of the currently specified date range. | - |
| 2415 | | - |
| 2416 | The user will not be able to select a date that is before the | - |
| 2417 | currently set minimum date. | - |
| 2418 | | - |
| 2419 | \table | - |
| 2420 | \row | - |
| 2421 | \li \image qcalendarwidget-minimum.png | - |
| 2422 | \row | - |
| 2423 | \li | - |
| 2424 | \snippet code/src_gui_widgets_qcalendarwidget.cpp 1 | - |
| 2425 | \endtable | - |
| 2426 | | - |
| 2427 | By default, the minimum date is the earliest date that the QDate | - |
| 2428 | class can handle. | - |
| 2429 | | - |
| 2430 | When setting a minimum date, the maximumDate and selectedDate | - |
| 2431 | properties are adjusted if the selection range becomes invalid. If | - |
| 2432 | the provided date is not a valid QDate object, the | - |
| 2433 | setMinimumDate() function does nothing. | - |
| 2434 | | - |
| 2435 | \sa setDateRange() | - |
| 2436 | */ | - |
| 2437 | | - |
| 2438 | QDate QCalendarWidget::minimumDate() const | - |
| 2439 | { | - |
| 2440 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2441 | return d->m_model->m_minimumDate; executed: return d->m_model->m_minimumDate;Execution Count:21 | 21 |
| 2442 | } | - |
| 2443 | | - |
| 2444 | void QCalendarWidget::setMinimumDate(const QDate &date) | - |
| 2445 | { | - |
| 2446 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2447 | if (!date.isValid() || d->m_model->m_minimumDate == date) partially evaluated: !date.isValid()| no Evaluation Count:0 | yes Evaluation Count:703 |
evaluated: d->m_model->m_minimumDate == date| yes Evaluation Count:685 | yes Evaluation Count:18 |
| 0-703 |
| 2448 | return; executed: return;Execution Count:685 | 685 |
| 2449 | | - |
| 2450 | QDate oldDate = d->m_model->m_date; executed (the execution status of this line is deduced): QDate oldDate = d->m_model->m_date; | - |
| 2451 | d->m_model->setMinimumDate(date); executed (the execution status of this line is deduced): d->m_model->setMinimumDate(date); | - |
| 2452 | d->yearEdit->setMinimum(d->m_model->m_minimumDate.year()); executed (the execution status of this line is deduced): d->yearEdit->setMinimum(d->m_model->m_minimumDate.year()); | - |
| 2453 | d->updateMonthMenu(); executed (the execution status of this line is deduced): d->updateMonthMenu(); | - |
| 2454 | QDate newDate = d->m_model->m_date; executed (the execution status of this line is deduced): QDate newDate = d->m_model->m_date; | - |
| 2455 | if (oldDate != newDate) { evaluated: oldDate != newDate| yes Evaluation Count:2 | yes Evaluation Count:16 |
| 2-16 |
| 2456 | d->update(); executed (the execution status of this line is deduced): d->update(); | - |
| 2457 | d->showMonth(newDate.year(), newDate.month()); executed (the execution status of this line is deduced): d->showMonth(newDate.year(), newDate.month()); | - |
| 2458 | d->m_navigator->setDate(newDate); executed (the execution status of this line is deduced): d->m_navigator->setDate(newDate); | - |
| 2459 | emit selectionChanged(); executed (the execution status of this line is deduced): selectionChanged(); | - |
| 2460 | } executed: }Execution Count:2 | 2 |
| 2461 | } executed: }Execution Count:18 | 18 |
| 2462 | | - |
| 2463 | /*! | - |
| 2464 | \property QCalendarWidget::maximumDate | - |
| 2465 | \brief the maximum date of the currently specified date range. | - |
| 2466 | | - |
| 2467 | The user will not be able to select a date which is after the | - |
| 2468 | currently set maximum date. | - |
| 2469 | | - |
| 2470 | \table | - |
| 2471 | \row | - |
| 2472 | \li \image qcalendarwidget-maximum.png | - |
| 2473 | \row | - |
| 2474 | \li | - |
| 2475 | \snippet code/src_gui_widgets_qcalendarwidget.cpp 2 | - |
| 2476 | \endtable | - |
| 2477 | | - |
| 2478 | By default, the maximum date is the last day the QDate class can | - |
| 2479 | handle. | - |
| 2480 | | - |
| 2481 | When setting a maximum date, the minimumDate and selectedDate | - |
| 2482 | properties are adjusted if the selection range becomes invalid. If | - |
| 2483 | the provided date is not a valid QDate object, the | - |
| 2484 | setMaximumDate() function does nothing. | - |
| 2485 | | - |
| 2486 | \sa setDateRange() | - |
| 2487 | */ | - |
| 2488 | | - |
| 2489 | QDate QCalendarWidget::maximumDate() const | - |
| 2490 | { | - |
| 2491 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2492 | return d->m_model->m_maximumDate; executed: return d->m_model->m_maximumDate;Execution Count:21 | 21 |
| 2493 | } | - |
| 2494 | | - |
| 2495 | void QCalendarWidget::setMaximumDate(const QDate &date) | - |
| 2496 | { | - |
| 2497 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2498 | if (!date.isValid() || d->m_model->m_maximumDate == date) partially evaluated: !date.isValid()| no Evaluation Count:0 | yes Evaluation Count:703 |
evaluated: d->m_model->m_maximumDate == date| yes Evaluation Count:690 | yes Evaluation Count:13 |
| 0-703 |
| 2499 | return; executed: return;Execution Count:690 | 690 |
| 2500 | | - |
| 2501 | QDate oldDate = d->m_model->m_date; executed (the execution status of this line is deduced): QDate oldDate = d->m_model->m_date; | - |
| 2502 | d->m_model->setMaximumDate(date); executed (the execution status of this line is deduced): d->m_model->setMaximumDate(date); | - |
| 2503 | d->yearEdit->setMaximum(d->m_model->m_maximumDate.year()); executed (the execution status of this line is deduced): d->yearEdit->setMaximum(d->m_model->m_maximumDate.year()); | - |
| 2504 | d->updateMonthMenu(); executed (the execution status of this line is deduced): d->updateMonthMenu(); | - |
| 2505 | QDate newDate = d->m_model->m_date; executed (the execution status of this line is deduced): QDate newDate = d->m_model->m_date; | - |
| 2506 | if (oldDate != newDate) { evaluated: oldDate != newDate| yes Evaluation Count:3 | yes Evaluation Count:10 |
| 3-10 |
| 2507 | d->update(); executed (the execution status of this line is deduced): d->update(); | - |
| 2508 | d->showMonth(newDate.year(), newDate.month()); executed (the execution status of this line is deduced): d->showMonth(newDate.year(), newDate.month()); | - |
| 2509 | d->m_navigator->setDate(newDate); executed (the execution status of this line is deduced): d->m_navigator->setDate(newDate); | - |
| 2510 | emit selectionChanged(); executed (the execution status of this line is deduced): selectionChanged(); | - |
| 2511 | } executed: }Execution Count:3 | 3 |
| 2512 | } executed: }Execution Count:13 | 13 |
| 2513 | | - |
| 2514 | /*! | - |
| 2515 | Defines a date range by setting the minimumDate and maximumDate | - |
| 2516 | properties. | - |
| 2517 | | - |
| 2518 | The date range restricts the user selection, i.e. the user can | - |
| 2519 | only select dates within the specified date range. Note that | - |
| 2520 | | - |
| 2521 | \snippet code/src_gui_widgets_qcalendarwidget.cpp 3 | - |
| 2522 | | - |
| 2523 | is analogous to | - |
| 2524 | | - |
| 2525 | \snippet code/src_gui_widgets_qcalendarwidget.cpp 4 | - |
| 2526 | | - |
| 2527 | If either the \a min or \a max parameters are not valid QDate | - |
| 2528 | objects, this function does nothing. | - |
| 2529 | | - |
| 2530 | \sa setMinimumDate(), setMaximumDate() | - |
| 2531 | */ | - |
| 2532 | | - |
| 2533 | void QCalendarWidget::setDateRange(const QDate &min, const QDate &max) | - |
| 2534 | { | - |
| 2535 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2536 | if (d->m_model->m_minimumDate == min && d->m_model->m_maximumDate == max) partially evaluated: d->m_model->m_minimumDate == min| no Evaluation Count:0 | yes Evaluation Count:2 |
never evaluated: d->m_model->m_maximumDate == max | 0-2 |
| 2537 | return; | 0 |
| 2538 | if (!min.isValid() || !max.isValid()) partially evaluated: !min.isValid()| no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: !max.isValid()| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 2539 | return; | 0 |
| 2540 | | - |
| 2541 | QDate oldDate = d->m_model->m_date; executed (the execution status of this line is deduced): QDate oldDate = d->m_model->m_date; | - |
| 2542 | d->m_model->setRange(min, max); executed (the execution status of this line is deduced): d->m_model->setRange(min, max); | - |
| 2543 | d->yearEdit->setMinimum(d->m_model->m_minimumDate.year()); executed (the execution status of this line is deduced): d->yearEdit->setMinimum(d->m_model->m_minimumDate.year()); | - |
| 2544 | d->yearEdit->setMaximum(d->m_model->m_maximumDate.year()); executed (the execution status of this line is deduced): d->yearEdit->setMaximum(d->m_model->m_maximumDate.year()); | - |
| 2545 | d->updateMonthMenu(); executed (the execution status of this line is deduced): d->updateMonthMenu(); | - |
| 2546 | QDate newDate = d->m_model->m_date; executed (the execution status of this line is deduced): QDate newDate = d->m_model->m_date; | - |
| 2547 | if (oldDate != newDate) { partially evaluated: oldDate != newDate| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 2548 | d->update(); executed (the execution status of this line is deduced): d->update(); | - |
| 2549 | d->showMonth(newDate.year(), newDate.month()); executed (the execution status of this line is deduced): d->showMonth(newDate.year(), newDate.month()); | - |
| 2550 | d->m_navigator->setDate(newDate); executed (the execution status of this line is deduced): d->m_navigator->setDate(newDate); | - |
| 2551 | emit selectionChanged(); executed (the execution status of this line is deduced): selectionChanged(); | - |
| 2552 | } executed: }Execution Count:2 | 2 |
| 2553 | } executed: }Execution Count:2 | 2 |
| 2554 | | - |
| 2555 | | - |
| 2556 | /*! \enum QCalendarWidget::HorizontalHeaderFormat | - |
| 2557 | | - |
| 2558 | This enum type defines the various formats the horizontal header can display. | - |
| 2559 | | - |
| 2560 | \value SingleLetterDayNames The header displays a single letter abbreviation for day names (e.g. M for Monday). | - |
| 2561 | \value ShortDayNames The header displays a short abbreviation for day names (e.g. Mon for Monday). | - |
| 2562 | \value LongDayNames The header displays complete day names (e.g. Monday). | - |
| 2563 | \value NoHorizontalHeader The header is hidden. | - |
| 2564 | | - |
| 2565 | \sa horizontalHeaderFormat(), VerticalHeaderFormat | - |
| 2566 | */ | - |
| 2567 | | - |
| 2568 | /*! | - |
| 2569 | \property QCalendarWidget::horizontalHeaderFormat | - |
| 2570 | \brief the format of the horizontal header. | - |
| 2571 | | - |
| 2572 | The default value is QCalendarWidget::ShortDayNames. | - |
| 2573 | */ | - |
| 2574 | | - |
| 2575 | void QCalendarWidget::setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat format) | - |
| 2576 | { | - |
| 2577 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2578 | if (d->m_model->m_horizontalHeaderFormat == format) partially evaluated: d->m_model->m_horizontalHeaderFormat == format| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 2579 | return; | 0 |
| 2580 | | - |
| 2581 | d->m_model->setHorizontalHeaderFormat(format); executed (the execution status of this line is deduced): d->m_model->setHorizontalHeaderFormat(format); | - |
| 2582 | d->cachedSizeHint = QSize(); executed (the execution status of this line is deduced): d->cachedSizeHint = QSize(); | - |
| 2583 | d->m_view->viewport()->update(); executed (the execution status of this line is deduced): d->m_view->viewport()->update(); | - |
| 2584 | d->m_view->updateGeometry(); executed (the execution status of this line is deduced): d->m_view->updateGeometry(); | - |
| 2585 | } executed: }Execution Count:4 | 4 |
| 2586 | | - |
| 2587 | QCalendarWidget::HorizontalHeaderFormat QCalendarWidget::horizontalHeaderFormat() const | - |
| 2588 | { | - |
| 2589 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2590 | return d->m_model->m_horizontalHeaderFormat; executed: return d->m_model->m_horizontalHeaderFormat;Execution Count:20 | 20 |
| 2591 | } | - |
| 2592 | | - |
| 2593 | | - |
| 2594 | /*! | - |
| 2595 | \enum QCalendarWidget::VerticalHeaderFormat | - |
| 2596 | | - |
| 2597 | This enum type defines the various formats the vertical header can display. | - |
| 2598 | | - |
| 2599 | \value ISOWeekNumbers The header displays ISO week numbers as described by \l QDate::weekNumber(). | - |
| 2600 | \value NoVerticalHeader The header is hidden. | - |
| 2601 | | - |
| 2602 | \sa verticalHeaderFormat(), HorizontalHeaderFormat | - |
| 2603 | */ | - |
| 2604 | | - |
| 2605 | /*! | - |
| 2606 | \property QCalendarWidget::verticalHeaderFormat | - |
| 2607 | \brief the format of the vertical header. | - |
| 2608 | | - |
| 2609 | The default value is QCalendarWidget::ISOWeekNumber. | - |
| 2610 | */ | - |
| 2611 | | - |
| 2612 | QCalendarWidget::VerticalHeaderFormat QCalendarWidget::verticalHeaderFormat() const | - |
| 2613 | { | - |
| 2614 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2615 | bool shown = d->m_model->weekNumbersShown(); executed (the execution status of this line is deduced): bool shown = d->m_model->weekNumbersShown(); | - |
| 2616 | if (shown) evaluated: shown| yes Evaluation Count:16 | yes Evaluation Count:2 |
| 2-16 |
| 2617 | return QCalendarWidget::ISOWeekNumbers; executed: return QCalendarWidget::ISOWeekNumbers;Execution Count:16 | 16 |
| 2618 | return QCalendarWidget::NoVerticalHeader; executed: return QCalendarWidget::NoVerticalHeader;Execution Count:2 | 2 |
| 2619 | } | - |
| 2620 | | - |
| 2621 | void QCalendarWidget::setVerticalHeaderFormat(QCalendarWidget::VerticalHeaderFormat format) | - |
| 2622 | { | - |
| 2623 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2624 | bool show = false; executed (the execution status of this line is deduced): bool show = false; | - |
| 2625 | if (format == QCalendarWidget::ISOWeekNumbers) evaluated: format == QCalendarWidget::ISOWeekNumbers| yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
| 2626 | show = true; executed: show = true;Execution Count:1 | 1 |
| 2627 | if (d->m_model->weekNumbersShown() == show) evaluated: d->m_model->weekNumbersShown() == show| yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
| 2628 | return; executed: return;Execution Count:1 | 1 |
| 2629 | d->m_model->setWeekNumbersShown(show); executed (the execution status of this line is deduced): d->m_model->setWeekNumbersShown(show); | - |
| 2630 | d->cachedSizeHint = QSize(); executed (the execution status of this line is deduced): d->cachedSizeHint = QSize(); | - |
| 2631 | d->m_view->viewport()->update(); executed (the execution status of this line is deduced): d->m_view->viewport()->update(); | - |
| 2632 | d->m_view->updateGeometry(); executed (the execution status of this line is deduced): d->m_view->updateGeometry(); | - |
| 2633 | } executed: }Execution Count:5 | 5 |
| 2634 | | - |
| 2635 | /*! | - |
| 2636 | \property QCalendarWidget::gridVisible | - |
| 2637 | \brief whether the table grid is displayed. | - |
| 2638 | | - |
| 2639 | \table | - |
| 2640 | \row | - |
| 2641 | \li \inlineimage qcalendarwidget-grid.png | - |
| 2642 | \row | - |
| 2643 | \li | - |
| 2644 | \snippet code/src_gui_widgets_qcalendarwidget.cpp 5 | - |
| 2645 | \endtable | - |
| 2646 | | - |
| 2647 | The default value is false. | - |
| 2648 | */ | - |
| 2649 | | - |
| 2650 | bool QCalendarWidget::isGridVisible() const | - |
| 2651 | { | - |
| 2652 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2653 | return d->m_view->showGrid(); executed: return d->m_view->showGrid();Execution Count:2 | 2 |
| 2654 | } | - |
| 2655 | | - |
| 2656 | void QCalendarWidget::setGridVisible(bool show) | - |
| 2657 | { | - |
| 2658 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2659 | d->m_view->setShowGrid(show); executed (the execution status of this line is deduced): d->m_view->setShowGrid(show); | - |
| 2660 | d->cachedSizeHint = QSize(); executed (the execution status of this line is deduced): d->cachedSizeHint = QSize(); | - |
| 2661 | d->m_view->viewport()->update(); executed (the execution status of this line is deduced): d->m_view->viewport()->update(); | - |
| 2662 | d->m_view->updateGeometry(); executed (the execution status of this line is deduced): d->m_view->updateGeometry(); | - |
| 2663 | } executed: }Execution Count:2 | 2 |
| 2664 | | - |
| 2665 | /*! | - |
| 2666 | \property QCalendarWidget::selectionMode | - |
| 2667 | \brief the type of selection the user can make in the calendar | - |
| 2668 | | - |
| 2669 | When this property is set to SingleSelection, the user can select a date | - |
| 2670 | within the minimum and maximum allowed dates, using either the mouse or | - |
| 2671 | the keyboard. | - |
| 2672 | | - |
| 2673 | When the property is set to NoSelection, the user will be unable to select | - |
| 2674 | dates, but they can still be selected programmatically. Note that the date | - |
| 2675 | that is selected when the property is set to NoSelection will still be | - |
| 2676 | the selected date of the calendar. | - |
| 2677 | | - |
| 2678 | The default value is SingleSelection. | - |
| 2679 | */ | - |
| 2680 | | - |
| 2681 | QCalendarWidget::SelectionMode QCalendarWidget::selectionMode() const | - |
| 2682 | { | - |
| 2683 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2684 | return d->m_view->readOnly ? QCalendarWidget::NoSelection : QCalendarWidget::SingleSelection; executed: return d->m_view->readOnly ? QCalendarWidget::NoSelection : QCalendarWidget::SingleSelection;Execution Count:32 | 32 |
| 2685 | } | - |
| 2686 | | - |
| 2687 | void QCalendarWidget::setSelectionMode(SelectionMode mode) | - |
| 2688 | { | - |
| 2689 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2690 | d->m_view->readOnly = (mode == QCalendarWidget::NoSelection); executed (the execution status of this line is deduced): d->m_view->readOnly = (mode == QCalendarWidget::NoSelection); | - |
| 2691 | d->setNavigatorEnabled(isDateEditEnabled() && (selectionMode() != QCalendarWidget::NoSelection)); executed (the execution status of this line is deduced): d->setNavigatorEnabled(isDateEditEnabled() && (selectionMode() != QCalendarWidget::NoSelection)); | - |
| 2692 | d->update(); executed (the execution status of this line is deduced): d->update(); | - |
| 2693 | } executed: }Execution Count:2 | 2 |
| 2694 | | - |
| 2695 | /*! | - |
| 2696 | \property QCalendarWidget::firstDayOfWeek | - |
| 2697 | \brief a value identifying the day displayed in the first column. | - |
| 2698 | | - |
| 2699 | By default, the day displayed in the first column | - |
| 2700 | is the first day of the week for the calendar's locale. | - |
| 2701 | */ | - |
| 2702 | | - |
| 2703 | void QCalendarWidget::setFirstDayOfWeek(Qt::DayOfWeek dayOfWeek) | - |
| 2704 | { | - |
| 2705 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2706 | if ((Qt::DayOfWeek)d->m_model->firstColumnDay() == dayOfWeek) partially evaluated: (Qt::DayOfWeek)d->m_model->firstColumnDay() == dayOfWeek| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2707 | return; | 0 |
| 2708 | | - |
| 2709 | d->m_model->setFirstColumnDay(dayOfWeek); executed (the execution status of this line is deduced): d->m_model->setFirstColumnDay(dayOfWeek); | - |
| 2710 | d->update(); executed (the execution status of this line is deduced): d->update(); | - |
| 2711 | } executed: }Execution Count:1 | 1 |
| 2712 | | - |
| 2713 | Qt::DayOfWeek QCalendarWidget::firstDayOfWeek() const | - |
| 2714 | { | - |
| 2715 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2716 | return (Qt::DayOfWeek)d->m_model->firstColumnDay(); executed: return (Qt::DayOfWeek)d->m_model->firstColumnDay();Execution Count:7 | 7 |
| 2717 | } | - |
| 2718 | | - |
| 2719 | /*! | - |
| 2720 | Returns the text char format for rendering the header. | - |
| 2721 | */ | - |
| 2722 | QTextCharFormat QCalendarWidget::headerTextFormat() const | - |
| 2723 | { | - |
| 2724 | Q_D(const QCalendarWidget); never executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2725 | return d->m_model->m_headerFormat; never executed: return d->m_model->m_headerFormat; | 0 |
| 2726 | } | - |
| 2727 | | - |
| 2728 | /*! | - |
| 2729 | Sets the text char format for rendering the header to \a format. | - |
| 2730 | If you also set a weekday text format, this format's foreground and | - |
| 2731 | background color will take precedence over the header's format. | - |
| 2732 | The other formatting information will still be decided by | - |
| 2733 | the header's format. | - |
| 2734 | */ | - |
| 2735 | void QCalendarWidget::setHeaderTextFormat(const QTextCharFormat &format) | - |
| 2736 | { | - |
| 2737 | Q_D(QCalendarWidget); never executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2738 | d->m_model->m_headerFormat = format; never executed (the execution status of this line is deduced): d->m_model->m_headerFormat = format; | - |
| 2739 | d->cachedSizeHint = QSize(); never executed (the execution status of this line is deduced): d->cachedSizeHint = QSize(); | - |
| 2740 | d->m_view->viewport()->update(); never executed (the execution status of this line is deduced): d->m_view->viewport()->update(); | - |
| 2741 | d->m_view->updateGeometry(); never executed (the execution status of this line is deduced): d->m_view->updateGeometry(); | - |
| 2742 | } | 0 |
| 2743 | | - |
| 2744 | /*! | - |
| 2745 | Returns the text char format for rendering of day in the week \a dayOfWeek. | - |
| 2746 | | - |
| 2747 | \sa headerTextFormat() | - |
| 2748 | */ | - |
| 2749 | QTextCharFormat QCalendarWidget::weekdayTextFormat(Qt::DayOfWeek dayOfWeek) const | - |
| 2750 | { | - |
| 2751 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2752 | return d->m_model->m_dayFormats.value(dayOfWeek); executed: return d->m_model->m_dayFormats.value(dayOfWeek);Execution Count:31 | 31 |
| 2753 | } | - |
| 2754 | | - |
| 2755 | /*! | - |
| 2756 | Sets the text char format for rendering of day in the week \a dayOfWeek to \a format. | - |
| 2757 | The format will take precedence over the header format in case of foreground | - |
| 2758 | and background color. Other text formatting information is taken from the headers format. | - |
| 2759 | | - |
| 2760 | \sa setHeaderTextFormat() | - |
| 2761 | */ | - |
| 2762 | void QCalendarWidget::setWeekdayTextFormat(Qt::DayOfWeek dayOfWeek, const QTextCharFormat &format) | - |
| 2763 | { | - |
| 2764 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2765 | d->m_model->m_dayFormats[dayOfWeek] = format; executed (the execution status of this line is deduced): d->m_model->m_dayFormats[dayOfWeek] = format; | - |
| 2766 | d->cachedSizeHint = QSize(); executed (the execution status of this line is deduced): d->cachedSizeHint = QSize(); | - |
| 2767 | d->m_view->viewport()->update(); executed (the execution status of this line is deduced): d->m_view->viewport()->update(); | - |
| 2768 | d->m_view->updateGeometry(); executed (the execution status of this line is deduced): d->m_view->updateGeometry(); | - |
| 2769 | } executed: }Execution Count:1 | 1 |
| 2770 | | - |
| 2771 | /*! | - |
| 2772 | Returns a QMap from QDate to QTextCharFormat showing all dates | - |
| 2773 | that use a special format that alters their rendering. | - |
| 2774 | */ | - |
| 2775 | QMap<QDate, QTextCharFormat> QCalendarWidget::dateTextFormat() const | - |
| 2776 | { | - |
| 2777 | Q_D(const QCalendarWidget); never executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2778 | return d->m_model->m_dateFormats; never executed: return d->m_model->m_dateFormats; | 0 |
| 2779 | } | - |
| 2780 | | - |
| 2781 | /*! | - |
| 2782 | Returns a QTextCharFormat for \a date. The char format can be be | - |
| 2783 | empty if the date is not renderd specially. | - |
| 2784 | */ | - |
| 2785 | QTextCharFormat QCalendarWidget::dateTextFormat(const QDate &date) const | - |
| 2786 | { | - |
| 2787 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2788 | return d->m_model->m_dateFormats.value(date); executed: return d->m_model->m_dateFormats.value(date);Execution Count:2 | 2 |
| 2789 | } | - |
| 2790 | | - |
| 2791 | /*! | - |
| 2792 | Sets the format used to render the given \a date to that specified by \a format. | - |
| 2793 | | - |
| 2794 | If \a date is null, all date formats are cleared. | - |
| 2795 | */ | - |
| 2796 | void QCalendarWidget::setDateTextFormat(const QDate &date, const QTextCharFormat &format) | - |
| 2797 | { | - |
| 2798 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2799 | if (date.isNull()) evaluated: date.isNull()| yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
| 2800 | d->m_model->m_dateFormats.clear(); executed: d->m_model->m_dateFormats.clear();Execution Count:1 | 1 |
| 2801 | else | - |
| 2802 | d->m_model->m_dateFormats[date] = format; executed: d->m_model->m_dateFormats[date] = format;Execution Count:2 | 2 |
| 2803 | d->m_view->viewport()->update(); executed (the execution status of this line is deduced): d->m_view->viewport()->update(); | - |
| 2804 | d->m_view->updateGeometry(); executed (the execution status of this line is deduced): d->m_view->updateGeometry(); | - |
| 2805 | } executed: }Execution Count:3 | 3 |
| 2806 | | - |
| 2807 | /*! | - |
| 2808 | \property QCalendarWidget::dateEditEnabled | - |
| 2809 | \brief whether the date edit popup is enabled | - |
| 2810 | \since 4.3 | - |
| 2811 | | - |
| 2812 | If this property is enabled, pressing a non-modifier key will cause a | - |
| 2813 | date edit to popup if the calendar widget has focus, allowing the user | - |
| 2814 | to specify a date in the form specified by the current locale. | - |
| 2815 | | - |
| 2816 | By default, this property is enabled. | - |
| 2817 | | - |
| 2818 | The date edit is simpler in appearance than QDateEdit, but allows the | - |
| 2819 | user to navigate between fields using the left and right cursor keys, | - |
| 2820 | increment and decrement individual fields using the up and down cursor | - |
| 2821 | keys, and enter values directly using the number keys. | - |
| 2822 | | - |
| 2823 | \sa QCalendarWidget::dateEditAcceptDelay | - |
| 2824 | */ | - |
| 2825 | bool QCalendarWidget::isDateEditEnabled() const | - |
| 2826 | { | - |
| 2827 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2828 | return d->m_dateEditEnabled; executed: return d->m_dateEditEnabled;Execution Count:29 | 29 |
| 2829 | } | - |
| 2830 | | - |
| 2831 | void QCalendarWidget::setDateEditEnabled(bool enable) | - |
| 2832 | { | - |
| 2833 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2834 | if (isDateEditEnabled() == enable) partially evaluated: isDateEditEnabled() == enable| no Evaluation Count:0 | yes Evaluation Count:27 |
| 0-27 |
| 2835 | return; | 0 |
| 2836 | | - |
| 2837 | d->m_dateEditEnabled = enable; executed (the execution status of this line is deduced): d->m_dateEditEnabled = enable; | - |
| 2838 | | - |
| 2839 | d->setNavigatorEnabled(enable && (selectionMode() != QCalendarWidget::NoSelection)); executed (the execution status of this line is deduced): d->setNavigatorEnabled(enable && (selectionMode() != QCalendarWidget::NoSelection)); | - |
| 2840 | } executed: }Execution Count:27 | 27 |
| 2841 | | - |
| 2842 | /*! | - |
| 2843 | \property QCalendarWidget::dateEditAcceptDelay | - |
| 2844 | \brief the time an inactive date edit is shown before its contents are accepted | - |
| 2845 | \since 4.3 | - |
| 2846 | | - |
| 2847 | If the calendar widget's \l{dateEditEnabled}{date edit is enabled}, this | - |
| 2848 | property specifies the amount of time (in millseconds) that the date edit | - |
| 2849 | remains open after the most recent user input. Once this time has elapsed, | - |
| 2850 | the date specified in the date edit is accepted and the popup is closed. | - |
| 2851 | | - |
| 2852 | By default, the delay is defined to be 1500 milliseconds (1.5 seconds). | - |
| 2853 | */ | - |
| 2854 | int QCalendarWidget::dateEditAcceptDelay() const | - |
| 2855 | { | - |
| 2856 | Q_D(const QCalendarWidget); never executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2857 | return d->m_navigator->dateEditAcceptDelay(); never executed: return d->m_navigator->dateEditAcceptDelay(); | 0 |
| 2858 | } | - |
| 2859 | | - |
| 2860 | void QCalendarWidget::setDateEditAcceptDelay(int delay) | - |
| 2861 | { | - |
| 2862 | Q_D(QCalendarWidget); never executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2863 | d->m_navigator->setDateEditAcceptDelay(delay); never executed (the execution status of this line is deduced): d->m_navigator->setDateEditAcceptDelay(delay); | - |
| 2864 | } | 0 |
| 2865 | | - |
| 2866 | /*! | - |
| 2867 | \since 4.4 | - |
| 2868 | | - |
| 2869 | Updates the cell specified by the given \a date unless updates | - |
| 2870 | are disabled or the cell is hidden. | - |
| 2871 | | - |
| 2872 | \sa updateCells(), yearShown(), monthShown() | - |
| 2873 | */ | - |
| 2874 | void QCalendarWidget::updateCell(const QDate &date) | - |
| 2875 | { | - |
| 2876 | if (!date.isValid()) { never evaluated: !date.isValid() | 0 |
| 2877 | qWarning("QCalendarWidget::updateCell: Invalid date"); never executed (the execution status of this line is deduced): QMessageLogger("widgets/qcalendarwidget.cpp", 2877, __PRETTY_FUNCTION__).warning("QCalendarWidget::updateCell: Invalid date"); | - |
| 2878 | return; | 0 |
| 2879 | } | - |
| 2880 | | - |
| 2881 | if (!isVisible()) never evaluated: !isVisible() | 0 |
| 2882 | return; | 0 |
| 2883 | | - |
| 2884 | Q_D(QCalendarWidget); never executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2885 | int row, column; never executed (the execution status of this line is deduced): int row, column; | - |
| 2886 | d->m_model->cellForDate(date, &row, &column); never executed (the execution status of this line is deduced): d->m_model->cellForDate(date, &row, &column); | - |
| 2887 | if (row == -1 || column == -1) never evaluated: row == -1 never evaluated: column == -1 | 0 |
| 2888 | return; | 0 |
| 2889 | | - |
| 2890 | QModelIndex modelIndex = d->m_model->index(row, column); never executed (the execution status of this line is deduced): QModelIndex modelIndex = d->m_model->index(row, column); | - |
| 2891 | if (!modelIndex.isValid()) never evaluated: !modelIndex.isValid() | 0 |
| 2892 | return; | 0 |
| 2893 | | - |
| 2894 | d->m_view->viewport()->update(d->m_view->visualRect(modelIndex)); never executed (the execution status of this line is deduced): d->m_view->viewport()->update(d->m_view->visualRect(modelIndex)); | - |
| 2895 | } | 0 |
| 2896 | | - |
| 2897 | /*! | - |
| 2898 | \since 4.4 | - |
| 2899 | | - |
| 2900 | Updates all visible cells unless updates are disabled. | - |
| 2901 | | - |
| 2902 | \sa updateCell() | - |
| 2903 | */ | - |
| 2904 | void QCalendarWidget::updateCells() | - |
| 2905 | { | - |
| 2906 | Q_D(QCalendarWidget); never executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2907 | if (isVisible()) never evaluated: isVisible() | 0 |
| 2908 | d->m_view->viewport()->update(); never executed: d->m_view->viewport()->update(); | 0 |
| 2909 | } | 0 |
| 2910 | | - |
| 2911 | /*! | - |
| 2912 | \fn void QCalendarWidget::selectionChanged() | - |
| 2913 | | - |
| 2914 | This signal is emitted when the currently selected date is | - |
| 2915 | changed. | - |
| 2916 | | - |
| 2917 | The currently selected date can be changed by the user using the | - |
| 2918 | mouse or keyboard, or by the programmer using setSelectedDate(). | - |
| 2919 | | - |
| 2920 | \sa selectedDate() | - |
| 2921 | */ | - |
| 2922 | | - |
| 2923 | /*! | - |
| 2924 | \fn void QCalendarWidget::currentPageChanged(int year, int month) | - |
| 2925 | | - |
| 2926 | This signal is emitted when the currently shown month is changed. | - |
| 2927 | The new \a year and \a month are passed as parameters. | - |
| 2928 | | - |
| 2929 | \sa setCurrentPage() | - |
| 2930 | */ | - |
| 2931 | | - |
| 2932 | /*! | - |
| 2933 | \fn void QCalendarWidget::activated(const QDate &date) | - |
| 2934 | | - |
| 2935 | This signal is emitted whenever the user presses the Return or | - |
| 2936 | Enter key or double-clicks a \a date in the calendar | - |
| 2937 | widget. | - |
| 2938 | */ | - |
| 2939 | | - |
| 2940 | /*! | - |
| 2941 | \fn void QCalendarWidget::clicked(const QDate &date) | - |
| 2942 | | - |
| 2943 | This signal is emitted when a mouse button is clicked. The date | - |
| 2944 | the mouse was clicked on is specified by \a date. The signal is | - |
| 2945 | only emitted when clicked on a valid date, e.g., dates are not | - |
| 2946 | outside the minimumDate() and maximumDate(). If the selection mode | - |
| 2947 | is NoSelection, this signal will not be emitted. | - |
| 2948 | | - |
| 2949 | */ | - |
| 2950 | | - |
| 2951 | /*! | - |
| 2952 | \property QCalendarWidget::navigationBarVisible | - |
| 2953 | \brief whether the navigation bar is shown or not | - |
| 2954 | | - |
| 2955 | \since 4.3 | - |
| 2956 | | - |
| 2957 | When this property is true (the default), the next month, | - |
| 2958 | previous month, month selection, year selection controls are | - |
| 2959 | shown on top. | - |
| 2960 | | - |
| 2961 | When the property is set to false, these controls are hidden. | - |
| 2962 | */ | - |
| 2963 | | - |
| 2964 | bool QCalendarWidget::isNavigationBarVisible() const | - |
| 2965 | { | - |
| 2966 | Q_D(const QCalendarWidget); executed (the execution status of this line is deduced): const QCalendarWidgetPrivate * const d = d_func(); | - |
| 2967 | return d->navBarVisible; executed: return d->navBarVisible;Execution Count:39 | 39 |
| 2968 | } | - |
| 2969 | | - |
| 2970 | | - |
| 2971 | void QCalendarWidget::setNavigationBarVisible(bool visible) | - |
| 2972 | { | - |
| 2973 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2974 | d->navBarVisible = visible; executed (the execution status of this line is deduced): d->navBarVisible = visible; | - |
| 2975 | d->cachedSizeHint = QSize(); executed (the execution status of this line is deduced): d->cachedSizeHint = QSize(); | - |
| 2976 | d->navBarBackground->setVisible(visible); executed (the execution status of this line is deduced): d->navBarBackground->setVisible(visible); | - |
| 2977 | updateGeometry(); executed (the execution status of this line is deduced): updateGeometry(); | - |
| 2978 | } executed: }Execution Count:4 | 4 |
| 2979 | | - |
| 2980 | /*! | - |
| 2981 | \reimp | - |
| 2982 | */ | - |
| 2983 | bool QCalendarWidget::event(QEvent *event) | - |
| 2984 | { | - |
| 2985 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 2986 | switch (event->type()) { | - |
| 2987 | case QEvent::LayoutDirectionChange: | - |
| 2988 | d->updateButtonIcons(); executed (the execution status of this line is deduced): d->updateButtonIcons(); | - |
| 2989 | case QEvent::LocaleChange: code before this statement executed: case QEvent::LocaleChange:Execution Count:2 | 2 |
| 2990 | d->m_model->setFirstColumnDay(locale().firstDayOfWeek()); executed (the execution status of this line is deduced): d->m_model->setFirstColumnDay(locale().firstDayOfWeek()); | - |
| 2991 | d->cachedSizeHint = QSize(); executed (the execution status of this line is deduced): d->cachedSizeHint = QSize(); | - |
| 2992 | d->updateMonthMenuNames(); executed (the execution status of this line is deduced): d->updateMonthMenuNames(); | - |
| 2993 | d->updateNavigationBar(); executed (the execution status of this line is deduced): d->updateNavigationBar(); | - |
| 2994 | d->m_view->updateGeometry(); executed (the execution status of this line is deduced): d->m_view->updateGeometry(); | - |
| 2995 | break; executed: break;Execution Count:4 | 4 |
| 2996 | case QEvent::FontChange: | - |
| 2997 | case QEvent::ApplicationFontChange: | - |
| 2998 | d->cachedSizeHint = QSize(); never executed (the execution status of this line is deduced): d->cachedSizeHint = QSize(); | - |
| 2999 | d->m_view->updateGeometry(); never executed (the execution status of this line is deduced): d->m_view->updateGeometry(); | - |
| 3000 | break; | 0 |
| 3001 | case QEvent::StyleChange: | - |
| 3002 | d->cachedSizeHint = QSize(); executed (the execution status of this line is deduced): d->cachedSizeHint = QSize(); | - |
| 3003 | d->m_view->updateGeometry(); executed (the execution status of this line is deduced): d->m_view->updateGeometry(); | - |
| 3004 | default: | - |
| 3005 | break; executed: break;Execution Count:558 | 558 |
| 3006 | } | - |
| 3007 | return QWidget::event(event); executed: return QWidget::event(event);Execution Count:562 | 562 |
| 3008 | } | - |
| 3009 | | - |
| 3010 | /*! | - |
| 3011 | \reimp | - |
| 3012 | */ | - |
| 3013 | bool QCalendarWidget::eventFilter(QObject *watched, QEvent *event) | - |
| 3014 | { | - |
| 3015 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 3016 | if (event->type() == QEvent::MouseButtonPress && d->yearEdit->hasFocus()) { evaluated: event->type() == QEvent::MouseButtonPress| yes Evaluation Count:1 | yes Evaluation Count:55 |
partially evaluated: d->yearEdit->hasFocus()| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-55 |
| 3017 | QWidget *tlw = window(); executed (the execution status of this line is deduced): QWidget *tlw = window(); | - |
| 3018 | QWidget *widget = static_cast<QWidget*>(watched); executed (the execution status of this line is deduced): QWidget *widget = static_cast<QWidget*>(watched); | - |
| 3019 | //as we have a event filter on the whole application we first make sure that the top level widget | - |
| 3020 | //of both this and the watched widget are the same to decide if we should finish the year edition. | - |
| 3021 | if (widget->window() == tlw) { partially evaluated: widget->window() == tlw| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 3022 | QPoint mousePos = widget->mapTo(tlw, static_cast<QMouseEvent *>(event)->pos()); executed (the execution status of this line is deduced): QPoint mousePos = widget->mapTo(tlw, static_cast<QMouseEvent *>(event)->pos()); | - |
| 3023 | QRect geom = QRect(d->yearEdit->mapTo(tlw, QPoint(0, 0)), d->yearEdit->size()); executed (the execution status of this line is deduced): QRect geom = QRect(d->yearEdit->mapTo(tlw, QPoint(0, 0)), d->yearEdit->size()); | - |
| 3024 | if (!geom.contains(mousePos)) { partially evaluated: !geom.contains(mousePos)| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 3025 | event->accept(); executed (the execution status of this line is deduced): event->accept(); | - |
| 3026 | d->_q_yearEditingFinished(); executed (the execution status of this line is deduced): d->_q_yearEditingFinished(); | - |
| 3027 | setFocus(); executed (the execution status of this line is deduced): setFocus(); | - |
| 3028 | return true; executed: return true;Execution Count:1 | 1 |
| 3029 | } | - |
| 3030 | } | 0 |
| 3031 | } | 0 |
| 3032 | return QWidget::eventFilter(watched, event); executed: return QWidget::eventFilter(watched, event);Execution Count:55 | 55 |
| 3033 | } | - |
| 3034 | | - |
| 3035 | /*! | - |
| 3036 | \reimp | - |
| 3037 | */ | - |
| 3038 | void QCalendarWidget::mousePressEvent(QMouseEvent *event) | - |
| 3039 | { | - |
| 3040 | setAttribute(Qt::WA_NoMouseReplay); never executed (the execution status of this line is deduced): setAttribute(Qt::WA_NoMouseReplay); | - |
| 3041 | QWidget::mousePressEvent(event); never executed (the execution status of this line is deduced): QWidget::mousePressEvent(event); | - |
| 3042 | setFocus(); never executed (the execution status of this line is deduced): setFocus(); | - |
| 3043 | } | 0 |
| 3044 | | - |
| 3045 | /*! | - |
| 3046 | \reimp | - |
| 3047 | */ | - |
| 3048 | void QCalendarWidget::resizeEvent(QResizeEvent * event) | - |
| 3049 | { | - |
| 3050 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 3051 | | - |
| 3052 | // XXX Should really use a QWidgetStack for yearEdit and yearButton, | - |
| 3053 | // XXX here we hide the year edit when the layout is likely to break | - |
| 3054 | // XXX the manual positioning of the yearEdit over the yearButton. | - |
| 3055 | if(d->yearEdit->isVisible() && event->size().width() != event->oldSize().width()) partially evaluated: d->yearEdit->isVisible()| no Evaluation Count:0 | yes Evaluation Count:32 |
never evaluated: event->size().width() != event->oldSize().width() | 0-32 |
| 3056 | d->_q_yearEditingFinished(); never executed: d->_q_yearEditingFinished(); | 0 |
| 3057 | | - |
| 3058 | QWidget::resizeEvent(event); executed (the execution status of this line is deduced): QWidget::resizeEvent(event); | - |
| 3059 | } executed: }Execution Count:32 | 32 |
| 3060 | | - |
| 3061 | /*! | - |
| 3062 | \reimp | - |
| 3063 | */ | - |
| 3064 | void QCalendarWidget::keyPressEvent(QKeyEvent * event) | - |
| 3065 | { | - |
| 3066 | Q_D(QCalendarWidget); executed (the execution status of this line is deduced): QCalendarWidgetPrivate * const d = d_func(); | - |
| 3067 | if(d->yearEdit->isVisible()&& event->key() == Qt::Key_Escape) partially evaluated: d->yearEdit->isVisible()| no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: event->key() == Qt::Key_Escape | 0-1 |
| 3068 | { | - |
| 3069 | d->yearEdit->setValue(yearShown()); never executed (the execution status of this line is deduced): d->yearEdit->setValue(yearShown()); | - |
| 3070 | d->_q_yearEditingFinished(); never executed (the execution status of this line is deduced): d->_q_yearEditingFinished(); | - |
| 3071 | return; | 0 |
| 3072 | } | - |
| 3073 | QWidget::keyPressEvent(event); executed (the execution status of this line is deduced): QWidget::keyPressEvent(event); | - |
| 3074 | } executed: }Execution Count:1 | 1 |
| 3075 | | - |
| 3076 | QT_END_NAMESPACE | - |
| 3077 | | - |
| 3078 | #include "qcalendarwidget.moc" | - |
| 3079 | #include "moc_qcalendarwidget.cpp" | - |
| 3080 | | - |
| 3081 | #endif //QT_NO_CALENDARWIDGET | - |
| 3082 | | - |
| | |