diff options
Diffstat (limited to 'src/widgets/widgets/qcalendarwidget.cpp')
-rw-r--r-- | src/widgets/widgets/qcalendarwidget.cpp | 60 |
1 files changed, 43 insertions, 17 deletions
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 42ef8c4a35..034127b4f3 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -37,13 +37,13 @@ enum { MinimumDayOffset = 1 }; -namespace { - static QString formatNumber(int number, int fieldWidth) { return QString::number(number).rightJustified(fieldWidth, u'0'); } +namespace QtPrivate { + class QCalendarDateSectionValidator { public: @@ -72,7 +72,7 @@ QString QCalendarDateSectionValidator::highlightString(const QString &str, int p { if (pos == 0) return "<b>"_L1 + str + "</b>"_L1; - int startPos = str.length() - pos; + int startPos = str.size() - pos; return QStringView{str}.mid(0, startPos) + "<b>"_L1 + QStringView{str}.mid(startPos, pos) + "</b>"_L1; } @@ -398,9 +398,11 @@ struct SectionToken { QCalendarDateSectionValidator *validator; int repeat; }; -} // unnamed namespace -Q_DECLARE_TYPEINFO(SectionToken, Q_PRIMITIVE_TYPE); -namespace { +} // namespace QtPrivate + +Q_DECLARE_TYPEINFO(QtPrivate::SectionToken, Q_PRIMITIVE_TYPE); + +namespace QtPrivate { class QCalendarDateValidator { @@ -727,8 +729,8 @@ bool QCalendarTextNavigator::eventFilter(QObject *o, QEvent *e) { if (m_widget) { if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) { - QKeyEvent* ke = (QKeyEvent*)e; - if ((ke->text().length() > 0 && ke->text().at(0).isPrint()) || m_dateFrame) { + QKeyEvent *ke = static_cast<QKeyEvent *>(e); + if ((ke->text().size() > 0 && ke->text().at(0).isPrint()) || m_dateFrame) { if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Select) { applyDate(); emit editingFinished(); @@ -1606,7 +1608,20 @@ protected: } }; -} // unnamed namespace +} // namespace QtPrivate + +using QCalendarDateSectionValidator = QtPrivate::QCalendarDateSectionValidator; +using QCalendarDayValidator = QtPrivate::QCalendarDayValidator; +using QCalendarMonthValidator = QtPrivate::QCalendarMonthValidator; +using QCalendarYearValidator = QtPrivate::QCalendarYearValidator; +using QCalendarDateValidator = QtPrivate::QCalendarDateValidator; +using QPrevNextCalButton = QtPrivate::QPrevNextCalButton; +using QCalendarDelegate = QtPrivate::QCalendarDelegate; +using QCalToolButton = QtPrivate::QCalToolButton; +using QCalendarDelegate = QtPrivate::QCalendarDelegate; +using QCalendarModel = QtPrivate::QCalendarModel; +using QCalendarView = QtPrivate::QCalendarView; +using QCalendarTextNavigator = QtPrivate::QCalendarTextNavigator; class QCalendarWidgetPrivate : public QWidgetPrivate { @@ -2185,7 +2200,7 @@ QSize QCalendarWidget::minimumSizeHint() const QStyleOption option; option.initFrom(this); - const int marginH = (style()->pixelMetric(QStyle::PM_FocusFrameHMargin, &option) + 1) * 2; + const int marginH = (style()->pixelMetric(QStyle::PM_FocusFrameHMargin, &option, this) + 1) * 2; if (horizontalHeaderFormat() == QCalendarWidget::NoHorizontalHeader) { rows = 6; @@ -2477,14 +2492,14 @@ void QCalendarWidget::showToday() \snippet code/src_gui_widgets_qcalendarwidget.cpp 1 \endtable - By default, the minimum date is the earliest date that the QDate - class can handle. - When setting a minimum date, the maximumDate and selectedDate properties are adjusted if the selection range becomes invalid. If the provided date is not a valid QDate object, the setMinimumDate() function does nothing. + The default minimum date is November 25, 4714 BCE. + You can restore this default by calling clearMinimumDate() (since Qt 6.6). + \sa setDateRange() */ @@ -2513,6 +2528,11 @@ void QCalendarWidget::setMinimumDate(QDate date) } } +void QCalendarWidget::clearMinimumDate() +{ + setMinimumDate(QDate::fromJulianDay(1)); +} + /*! \property QCalendarWidget::maximumDate \brief the maximum date of the currently specified date range. @@ -2528,14 +2548,14 @@ void QCalendarWidget::setMinimumDate(QDate date) \snippet code/src_gui_widgets_qcalendarwidget.cpp 2 \endtable - By default, the maximum date is the last day the QDate class can - handle. - When setting a maximum date, the minimumDate and selectedDate properties are adjusted if the selection range becomes invalid. If the provided date is not a valid QDate object, the setMaximumDate() function does nothing. + The default maximum date is December 31, 9999 CE. + You can restore this default by calling clearMaximumDate() (since Qt 6.6). + \sa setDateRange() */ @@ -2564,6 +2584,11 @@ void QCalendarWidget::setMaximumDate(QDate date) } } +void QCalendarWidget::clearMaximumDate() +{ + setMaximumDate(QDate(9999, 12, 31)); +} + /*! Defines a date range by setting the minimumDate and maximumDate properties. @@ -2848,7 +2873,7 @@ QMap<QDate, QTextCharFormat> QCalendarWidget::dateTextFormat() const } /*! - Returns a QTextCharFormat for \a date. The char format can be be + Returns a QTextCharFormat for \a date. The char format can be empty if the date is not renderd specially. */ QTextCharFormat QCalendarWidget::dateTextFormat(QDate date) const @@ -3074,6 +3099,7 @@ bool QCalendarWidget::event(QEvent *event) case QEvent::StyleChange: d->cachedSizeHint = QSize(); d->m_view->updateGeometry(); + break; default: break; } |