summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2019-09-03 15:18:14 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2019-09-04 18:43:35 +0200
commit46ec24d2b9a0fb1d59955f11dab0ead05dd017f9 (patch)
tree552d32c9f7b8d447359771987f25a0fcfa15b764
parent978f579a8c6a6cff3803cc62d4b09c974f476285 (diff)
Rename calendar methods from m{in,ax} to m{in,ax}imum
Words should not be abbreviated. Split a long line and reflowed some comments in the process. Fixes: QTBUG-78008 Change-Id: I52d75409f02e2cecbed3e94d424617ad594c275b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--src/corelib/text/qlocale.cpp4
-rw-r--r--src/corelib/time/qcalendar.cpp49
-rw-r--r--src/corelib/time/qcalendar.h6
-rw-r--r--src/corelib/time/qcalendarbackend_p.h6
-rw-r--r--src/corelib/time/qdatetimeparser.cpp26
-rw-r--r--src/corelib/time/qhijricalendar.cpp2
-rw-r--r--src/corelib/time/qhijricalendar_p.h2
-rw-r--r--src/corelib/time/qromancalendar.cpp2
-rw-r--r--src/corelib/time/qromancalendar_p.h2
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp4
-rw-r--r--tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp4
11 files changed, 55 insertions, 52 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 91e393e343..48d57e5e6e 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -2916,7 +2916,7 @@ static QString rawStandaloneWeekDayName(const QLocaleData *data, const int day,
QString QCalendarBackend::monthName(const QLocale &locale, int month, int,
QLocale::FormatType format) const
{
- Q_ASSERT(month >= 1 && month <= maxMonthsInYear());
+ Q_ASSERT(month >= 1 && month <= maximumMonthsInYear());
return rawMonthName(localeMonthIndexData()[locale.d->m_data_offset],
localeMonthData(), month, format);
}
@@ -2942,7 +2942,7 @@ QString QGregorianCalendar::monthName(const QLocale &locale, int month, int year
QString QCalendarBackend::standaloneMonthName(const QLocale &locale, int month, int,
QLocale::FormatType format) const
{
- Q_ASSERT(month >= 1 && month <= maxMonthsInYear());
+ Q_ASSERT(month >= 1 && month <= maximumMonthsInYear());
return rawStandaloneMonthName(localeMonthIndexData()[locale.d->m_data_offset],
localeMonthData(), month, format);
}
diff --git a/src/corelib/time/qcalendar.cpp b/src/corelib/time/qcalendar.cpp
index 6e68a43a22..d31eee6632 100644
--- a/src/corelib/time/qcalendar.cpp
+++ b/src/corelib/time/qcalendar.cpp
@@ -224,7 +224,7 @@ QString QCalendar::name() const
in the month, although \c{isDateValid(year, month, day)} might return \c true for
some larger values of \c day.
- \sa daysInYear(), monthsInYear(), minDaysInMonth(), maxDaysInMonth()
+ \sa daysInYear(), monthsInYear(), minimumDaysInMonth(), maximumDaysInMonth()
*/
// properties of the calendar
@@ -296,7 +296,7 @@ int QCalendarBackend::daysInYear(int year) const
This base implementation returns 12 for any valid year.
- \sa daysInYear(), maxMonthsInYear(), isDateValid()
+ \sa daysInYear(), maximumMonthsInYear(), isDateValid()
*/
int QCalendarBackend::monthsInYear(int year) const
{
@@ -354,13 +354,14 @@ bool QCalendarBackend::hasYearZero() const
This base implementation returns 31, as this is a common case.
For calendars with intercallary days, although daysInMonth() doesn't include
- the intercallary days in its count for an individual month, maxDaysInMonth()
- should include intercallary days, so that it is the maximum value of \c day
- for which \c{isDateValid(year, month, day)} can be true.
+ the intercallary days in its count for an individual month,
+ maximumDaysInMonth() should include intercallary days, so that it is the
+ maximum value of \c day for which \c{isDateValid(year, month, day)} can be
+ true.
- \sa maxMonthsInYear(), daysInMonth()
+ \sa maximumMonthsInYear(), daysInMonth()
*/
-int QCalendarBackend::maxDaysInMonth() const
+int QCalendarBackend::maximumDaysInMonth() const
{
return 31;
}
@@ -370,9 +371,9 @@ int QCalendarBackend::maxDaysInMonth() const
This base implementation returns 29, as this is a common case.
- \sa maxMonthsInYear(), daysInMonth()
+ \sa maximumMonthsInYear(), daysInMonth()
*/
-int QCalendarBackend::minDaysInMonth() const
+int QCalendarBackend::minimumDaysInMonth() const
{
return 29;
}
@@ -382,9 +383,9 @@ int QCalendarBackend::minDaysInMonth() const
This base implementation returns 12, as this is a common case.
- \sa maxDaysInMonth(), monthsInYear()
+ \sa maximumDaysInMonth(), monthsInYear()
*/
-int QCalendarBackend::maxMonthsInYear() const
+int QCalendarBackend::maximumMonthsInYear() const
{
return 12;
}
@@ -726,7 +727,7 @@ QCalendar::QCalendar(QStringView name)
Months are numbered consecutively, starting with 1 for the first month of each
year.
- \sa maxDaysInMonth(), minDaysInMonth()
+ \sa maximumDaysInMonth(), minimumDaysInMonth()
*/
int QCalendar::daysInMonth(int month, int year) const
{
@@ -868,21 +869,21 @@ bool QCalendar::hasYearZero() const
/*!
Returns the number of days in the longest month in the calendar, in any year.
- \sa daysInMonth(), minDaysInMonth()
+ \sa daysInMonth(), minimumDaysInMonth()
*/
-int QCalendar::maxDaysInMonth() const
+int QCalendar::maximumDaysInMonth() const
{
- return d ? d->maxDaysInMonth() : 0;
+ return d ? d->maximumDaysInMonth() : 0;
}
/*!
Returns the number of days in the shortest month in the calendar, in any year.
- \sa daysInMonth(), maxDaysInMonth()
+ \sa daysInMonth(), maximumDaysInMonth()
*/
-int QCalendar::minDaysInMonth() const
+int QCalendar::minimumDaysInMonth() const
{
- return d ? d->minDaysInMonth() : 0;
+ return d ? d->minimumDaysInMonth() : 0;
}
/*!
@@ -890,9 +891,9 @@ int QCalendar::minDaysInMonth() const
\sa monthName(), standaloneMonthName(), monthsInYear()
*/
-int QCalendar::maxMonthsInYear() const
+int QCalendar::maximumMonthsInYear() const
{
- return d ? d->maxMonthsInYear() : 0;
+ return d ? d->maximumMonthsInYear() : 0;
}
// Julian Day conversions:
@@ -970,12 +971,12 @@ int QCalendar::dayOfWeek(QDate date) const
in the specified \a locale; the \a format determines how fully it shall be
expressed (i.e. to what extent it is abbreviated).
- \sa standaloneMonthName(), maxMonthsInYear(), dateTimeToString()
+ \sa standaloneMonthName(), maximumMonthsInYear(), dateTimeToString()
*/
QString QCalendar::monthName(const QLocale &locale, int month, int year,
QLocale::FormatType format) const
{
- const int maxMonth = year == Unspecified ? maxMonthsInYear() : monthsInYear(year);
+ const int maxMonth = year == Unspecified ? maximumMonthsInYear() : monthsInYear(year);
if (!d || month < 1 || month > maxMonth)
return QString();
@@ -999,12 +1000,12 @@ QString QCalendar::monthName(const QLocale &locale, int month, int year,
specified \a locale; the \a format determines how fully it shall be expressed
(i.e. to what extent it is abbreviated).
- \sa monthName(), maxMonthsInYear(), dateTimeToString()
+ \sa monthName(), maximumMonthsInYear(), dateTimeToString()
*/
QString QCalendar::standaloneMonthName(const QLocale &locale, int month, int year,
QLocale::FormatType format) const
{
- const int maxMonth = year == Unspecified ? maxMonthsInYear() : monthsInYear(year);
+ const int maxMonth = year == Unspecified ? maximumMonthsInYear() : monthsInYear(year);
if (!d || month < 1 || month > maxMonth)
return QString();
diff --git a/src/corelib/time/qcalendar.h b/src/corelib/time/qcalendar.h
index 594ea760a6..dd3df76e17 100644
--- a/src/corelib/time/qcalendar.h
+++ b/src/corelib/time/qcalendar.h
@@ -155,9 +155,9 @@ public:
bool isSolar() const;
bool isProleptic() const;
bool hasYearZero() const;
- int maxDaysInMonth() const;
- int minDaysInMonth() const;
- int maxMonthsInYear() const;
+ int maximumDaysInMonth() const;
+ int minimumDaysInMonth() const;
+ int maximumMonthsInYear() const;
QString name() const;
// QDate conversions:
diff --git a/src/corelib/time/qcalendarbackend_p.h b/src/corelib/time/qcalendarbackend_p.h
index 12db8928ca..21506e9e2c 100644
--- a/src/corelib/time/qcalendarbackend_p.h
+++ b/src/corelib/time/qcalendarbackend_p.h
@@ -95,9 +95,9 @@ public:
virtual bool isSolar() const = 0;
virtual bool isProleptic() const;
virtual bool hasYearZero() const;
- virtual int maxDaysInMonth() const;
- virtual int minDaysInMonth() const;
- virtual int maxMonthsInYear() const;
+ virtual int maximumDaysInMonth() const;
+ virtual int minimumDaysInMonth() const;
+ virtual int maximumMonthsInYear() const;
// Julian Day conversions:
virtual bool dateToJulianDay(int year, int month, int day, qint64 *jd) const = 0;
virtual QCalendar::YearMonthDay julianDayToDate(qint64 jd) const = 0;
diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp
index d0f34358b9..2c566e3584 100644
--- a/src/corelib/time/qdatetimeparser.cpp
+++ b/src/corelib/time/qdatetimeparser.cpp
@@ -223,21 +223,23 @@ int QDateTimeParser::absoluteMax(int s, const QDateTime &cur) const
case TimeZoneSection: return QTimeZone::MaxUtcOffsetSecs;
#endif
case Hour24Section:
- case Hour12Section: return 23; // this is special-cased in
- // parseSection. We want it to be
- // 23 for the stepBy case.
+ case Hour12Section:
+ // This is special-cased in parseSection.
+ // We want it to be 23 for the stepBy case.
+ return 23;
case MinuteSection:
case SecondSection: return 59;
case MSecSection: return 999;
case YearSection2Digits:
- case YearSection: return 9999; // sectionMaxSize will prevent
- // people from typing in a larger
- // number in count == 2 sections.
- // stepBy() will work on real years anyway
- case MonthSection: return calendar.maxMonthsInYear();
+ case YearSection:
+ // sectionMaxSize will prevent people from typing in a larger number in
+ // count == 2 sections; stepBy() will work on real years anyway.
+ return 9999;
+ case MonthSection: return calendar.maximumMonthsInYear();
case DaySection:
case DayOfWeekSectionShort:
- case DayOfWeekSectionLong: return cur.isValid() ? cur.date().daysInMonth(calendar) : calendar.maxDaysInMonth() ;
+ case DayOfWeekSectionLong:
+ return cur.isValid() ? cur.date().daysInMonth(calendar) : calendar.maximumDaysInMonth();
case AmPmSection: return 1;
default: break;
}
@@ -615,7 +617,7 @@ int QDateTimeParser::sectionSize(int sectionIndex) const
int QDateTimeParser::sectionMaxSize(Section s, int count) const
{
#if QT_CONFIG(textdate)
- int mcount = calendar.maxMonthsInYear();
+ int mcount = calendar.maximumMonthsInYear();
#endif
switch (s) {
@@ -1291,9 +1293,9 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
}
if (!calendar.isDateValid(year, month, day)) {
- if (day <= calendar.maxDaysInMonth())
+ if (day <= calendar.maximumDaysInMonth())
cachedDay = day;
- if (day > calendar.minDaysInMonth() && calendar.isDateValid(year, month, 1))
+ if (day > calendar.minimumDaysInMonth() && calendar.isDateValid(year, month, 1))
needfixday = true;
}
if (needfixday) {
diff --git a/src/corelib/time/qhijricalendar.cpp b/src/corelib/time/qhijricalendar.cpp
index 1a1155be6d..9aabe46570 100644
--- a/src/corelib/time/qhijricalendar.cpp
+++ b/src/corelib/time/qhijricalendar.cpp
@@ -102,7 +102,7 @@ int QHijriCalendar::daysInMonth(int month, int year) const
return month % 2 == 0 ? 29 : 30;
}
-int QHijriCalendar::maxDaysInMonth() const
+int QHijriCalendar::maximumDaysInMonth() const
{
return 30;
}
diff --git a/src/corelib/time/qhijricalendar_p.h b/src/corelib/time/qhijricalendar_p.h
index 8f15495d11..60820488b4 100644
--- a/src/corelib/time/qhijricalendar_p.h
+++ b/src/corelib/time/qhijricalendar_p.h
@@ -63,7 +63,7 @@ class Q_CORE_EXPORT QHijriCalendar : public QCalendarBackend
{
public:
int daysInMonth(int month, int year = QCalendar::Unspecified) const override;
- int maxDaysInMonth() const override;
+ int maximumDaysInMonth() const override;
int daysInYear(int year) const override;
bool isLunar() const override;
diff --git a/src/corelib/time/qromancalendar.cpp b/src/corelib/time/qromancalendar.cpp
index 81b8d93d43..36cad01b81 100644
--- a/src/corelib/time/qromancalendar.cpp
+++ b/src/corelib/time/qromancalendar.cpp
@@ -72,7 +72,7 @@ int QRomanCalendar::daysInMonth(int month, int year) const
return 30 | ((month & 1) ^ (month >> 3));
}
-int QRomanCalendar::minDaysInMonth() const
+int QRomanCalendar::minimumDaysInMonth() const
{
return 28;
}
diff --git a/src/corelib/time/qromancalendar_p.h b/src/corelib/time/qromancalendar_p.h
index ea2f9d01f0..49efb3df89 100644
--- a/src/corelib/time/qromancalendar_p.h
+++ b/src/corelib/time/qromancalendar_p.h
@@ -60,7 +60,7 @@ class Q_CORE_EXPORT QRomanCalendar : public QCalendarBackend
public:
// date queries:
int daysInMonth(int month, int year = QCalendar::Unspecified) const override;
- int minDaysInMonth() const override;
+ int minimumDaysInMonth() const override;
// properties of the calendar
bool isLunar() const override;
bool isLuniSolar() const override;
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index ec19b64d4a..cc0c51b237 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -2413,7 +2413,7 @@ void QCalendarWidget::showNextMonth()
Q_D(const QCalendarWidget);
int year = yearShown();
int month = monthShown();
- if (month == d->m_model->m_calendar.maxMonthsInYear()) {
+ if (month == d->m_model->m_calendar.maximumMonthsInYear()) {
++year;
month = 1;
} else {
@@ -2437,7 +2437,7 @@ void QCalendarWidget::showPreviousMonth()
int month = monthShown();
if (month == 1) {
--year;
- month = d->m_model->m_calendar.maxMonthsInYear();
+ month = d->m_model->m_calendar.maximumMonthsInYear();
} else {
--month;
}
diff --git a/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp b/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp
index 5cfdb6daf4..9b41014394 100644
--- a/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp
+++ b/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp
@@ -55,13 +55,13 @@ void tst_QCalendar::checkYear(const QCalendar &cal, int year, bool normal)
QVERIFY(moons > 0);
QVERIFY(!cal.isDateValid(year, moons + 1, 1));
QVERIFY(!cal.isDateValid(year, 0, 1));
- QVERIFY(moons <= cal.maxMonthsInYear());
+ QVERIFY(moons <= cal.maximumMonthsInYear());
const int days = cal.daysInYear(year);
QVERIFY(days > 0);
int sum = 0;
- const int longest = cal.maxDaysInMonth();
+ const int longest = cal.maximumDaysInMonth();
for (int i = moons; i > 0; i--) {
const int last = cal.daysInMonth(i, year);
sum += last;