[PATCH 22/23] qcalendarsystem: Make monthsInYear(), daysInMonth(), daysInYear(), and isLeapYear() non-virtual.
Jon Severinsson
jon at severinsson.net
Fri Oct 12 15:13:57 UTC 2012
These need to stay in the private class, in order to provide a public version
that validates the arguments, and an internal that don't.
---
kdecore/date/kcalendarsystem.cpp | 9 +++------
kdecore/date/kcalendarsystem.h | 13 +++++--------
kdecore/date/kcalendarsystemcoptic.cpp | 10 ----------
kdecore/date/kcalendarsystemcoptic_p.h | 3 ---
kdecore/date/kcalendarsystemethiopian.cpp | 10 ----------
kdecore/date/kcalendarsystemethiopian_p.h | 3 ---
kdecore/date/kcalendarsystemgregorian.cpp | 10 ----------
kdecore/date/kcalendarsystemgregorian_p.h | 3 ---
kdecore/date/kcalendarsystemhebrew.cpp | 10 ----------
kdecore/date/kcalendarsystemhebrew_p.h | 3 ---
kdecore/date/kcalendarsystemindiannational.cpp | 10 ----------
kdecore/date/kcalendarsystemindiannational_p.h | 3 ---
kdecore/date/kcalendarsystemislamiccivil.cpp | 10 ----------
kdecore/date/kcalendarsystemislamiccivil_p.h | 3 ---
kdecore/date/kcalendarsystemjalali.cpp | 10 ----------
kdecore/date/kcalendarsystemjalali_p.h | 3 ---
kdecore/date/kcalendarsystemjapanese.cpp | 10 ----------
kdecore/date/kcalendarsystemjapanese_p.h | 3 ---
kdecore/date/kcalendarsystemjulian.cpp | 10 ----------
kdecore/date/kcalendarsystemjulian_p.h | 3 ---
kdecore/date/kcalendarsystemminguo.cpp | 10 ----------
kdecore/date/kcalendarsystemminguo_p.h | 3 ---
kdecore/date/kcalendarsystemqdate.cpp | 20 --------------------
kdecore/date/kcalendarsystemqdate_p.h | 7 -------
kdecore/date/kcalendarsystemthai.cpp | 10 ----------
kdecore/date/kcalendarsystemthai_p.h | 3 ---
26 filer ändrade, 8 tillägg(+), 184 borttagningar(-)
diff --git a/kdecore/date/kcalendarsystem.cpp b/kdecore/date/kcalendarsystem.cpp
index b937823..2acaa1a 100644
--- a/kdecore/date/kcalendarsystem.cpp
+++ b/kdecore/date/kcalendarsystem.cpp
@@ -969,7 +969,6 @@ int KCalendarSystem::monthsInYear(const QDate &date) const
return -1;
}
-// NOT VIRTUAL - Uses shared-d instead
int KCalendarSystem::monthsInYear(int year) const
{
Q_D(const KCalendarSystem);
@@ -992,7 +991,6 @@ int KCalendarSystem::daysInYear(const QDate &date) const
return -1;
}
-// NOT VIRTUAL - Uses shared-d instead
int KCalendarSystem::daysInYear(int year) const
{
Q_D(const KCalendarSystem);
@@ -1009,20 +1007,19 @@ int KCalendarSystem::daysInMonth(const QDate &date) const
Q_D(const KCalendarSystem);
if (isValid(date)) {
- int year, month;
- getDate(date, &year, &month, 0);
+ int year, month, day;
+ julianDayToDate(date.toJulianDay(), year, month, day);
return d->daysInMonth(year, month);
}
return -1;
}
-// NOT VIRTUAL - Uses shared-d instead
int KCalendarSystem::daysInMonth(int year, int month) const
{
Q_D(const KCalendarSystem);
- if (isValid(year, 1, 1)) {
+ if (isValid(year, month, 1)) {
return d->daysInMonth(year, month);
}
diff --git a/kdecore/date/kcalendarsystem.h b/kdecore/date/kcalendarsystem.h
index 1ab8b8f..d74d979 100644
--- a/kdecore/date/kcalendarsystem.h
+++ b/kdecore/date/kcalendarsystem.h
@@ -471,9 +471,8 @@ public:
* @param date the date to obtain year from
* @return number of months in the year, -1 if input date invalid
*/
- virtual int monthsInYear(const QDate &date) const;
+ int monthsInYear(const QDate &date) const;
- //KDE5 make virtual?
/**
* @since 4.5
*
@@ -490,9 +489,8 @@ public:
* @param date the date to obtain year from
* @return number of days in year, -1 if input date invalid
*/
- virtual int daysInYear(const QDate &date) const;
+ int daysInYear(const QDate &date) const;
- //KDE5 make virtual?
/**
* @since 4.5
*
@@ -509,9 +507,8 @@ public:
* @param date the date to obtain month from
* @return number of days in month, -1 if input date invalid
*/
- virtual int daysInMonth(const QDate &date) const;
+ int daysInMonth(const QDate &date) const;
- //KDE5 make virtual?
/**
* @since 4.5
*
@@ -542,7 +539,7 @@ public:
* @param year the year to check
* @return @c true if the year is a leap year, @c false otherwise
*/
- virtual bool isLeapYear(int year) const = 0;
+ bool isLeapYear(int year) const;
/**
* Returns whether a given date falls in a leap year.
@@ -553,7 +550,7 @@ public:
* @param date the date to check
* @return @c true if the date falls in a leap year, @c false otherwise
*/
- virtual bool isLeapYear(const QDate &date) const;
+ bool isLeapYear(const QDate &date) const;
//KDE5 Make virtual?
/**
diff --git a/kdecore/date/kcalendarsystemcoptic.cpp b/kdecore/date/kcalendarsystemcoptic.cpp
index 82bcc42..9b90e15 100644
--- a/kdecore/date/kcalendarsystemcoptic.cpp
+++ b/kdecore/date/kcalendarsystemcoptic.cpp
@@ -166,16 +166,6 @@ QDate KCalendarSystemCoptic::latestValidDate() const
return QDate::fromJulianDay(5477164);
}
-bool KCalendarSystemCoptic::isLeapYear(int year) const
-{
- return KCalendarSystem::isLeapYear(year);
-}
-
-bool KCalendarSystemCoptic::isLeapYear(const QDate &date) const
-{
- return KCalendarSystem::isLeapYear(date);
-}
-
bool KCalendarSystemCoptic::isLunar() const
{
return false;
diff --git a/kdecore/date/kcalendarsystemcoptic_p.h b/kdecore/date/kcalendarsystemcoptic_p.h
index cb2a1bf..04ab8fe 100644
--- a/kdecore/date/kcalendarsystemcoptic_p.h
+++ b/kdecore/date/kcalendarsystemcoptic_p.h
@@ -47,9 +47,6 @@ public:
virtual QDate earliestValidDate() const;
virtual QDate latestValidDate() const;
- virtual bool isLeapYear(int year) const;
- virtual bool isLeapYear(const QDate &date) const;
-
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
virtual bool isLunar() const;
diff --git a/kdecore/date/kcalendarsystemethiopian.cpp b/kdecore/date/kcalendarsystemethiopian.cpp
index ac51c76..a2a33a2 100644
--- a/kdecore/date/kcalendarsystemethiopian.cpp
+++ b/kdecore/date/kcalendarsystemethiopian.cpp
@@ -99,16 +99,6 @@ QDate KCalendarSystemEthiopian::latestValidDate() const
return QDate::fromJulianDay(5376721);
}
-bool KCalendarSystemEthiopian::isLeapYear(int year) const
-{
- return KCalendarSystemCoptic::isLeapYear(year);
-}
-
-bool KCalendarSystemEthiopian::isLeapYear(const QDate &date) const
-{
- return KCalendarSystemCoptic::isLeapYear(date);
-}
-
bool KCalendarSystemEthiopian::isLunar() const
{
return KCalendarSystemCoptic::isLunar();
diff --git a/kdecore/date/kcalendarsystemethiopian_p.h b/kdecore/date/kcalendarsystemethiopian_p.h
index 558e090..456fd0e 100644
--- a/kdecore/date/kcalendarsystemethiopian_p.h
+++ b/kdecore/date/kcalendarsystemethiopian_p.h
@@ -48,9 +48,6 @@ public:
virtual QDate earliestValidDate() const;
virtual QDate latestValidDate() const;
- virtual bool isLeapYear(int year) const;
- virtual bool isLeapYear(const QDate &date) const;
-
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
virtual bool isLunar() const;
diff --git a/kdecore/date/kcalendarsystemgregorian.cpp b/kdecore/date/kcalendarsystemgregorian.cpp
index 5c9b070..12ee9b7 100644
--- a/kdecore/date/kcalendarsystemgregorian.cpp
+++ b/kdecore/date/kcalendarsystemgregorian.cpp
@@ -195,16 +195,6 @@ QDate KCalendarSystemGregorian::latestValidDate() const
return QDate::fromJulianDay(5373484);
}
-bool KCalendarSystemGregorian::isLeapYear(int year) const
-{
- return KCalendarSystem::isLeapYear(year);
-}
-
-bool KCalendarSystemGregorian::isLeapYear(const QDate &date) const
-{
- return KCalendarSystem::isLeapYear(date);
-}
-
int KCalendarSystemGregorian::yearStringToInteger(const QString &sNum, int &iLength) const
{
return KCalendarSystem::yearStringToInteger(sNum, iLength);
diff --git a/kdecore/date/kcalendarsystemgregorian_p.h b/kdecore/date/kcalendarsystemgregorian_p.h
index c608a82..6141868 100644
--- a/kdecore/date/kcalendarsystemgregorian_p.h
+++ b/kdecore/date/kcalendarsystemgregorian_p.h
@@ -52,9 +52,6 @@ public:
virtual QDate earliestValidDate() const;
virtual QDate latestValidDate() const;
- virtual bool isLeapYear(int year) const;
- virtual bool isLeapYear(const QDate &date) const;
-
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
virtual int yearStringToInteger(const QString &sNum, int &iLength) const;
diff --git a/kdecore/date/kcalendarsystemhebrew.cpp b/kdecore/date/kcalendarsystemhebrew.cpp
index 3a386b9..6e5128a 100644
--- a/kdecore/date/kcalendarsystemhebrew.cpp
+++ b/kdecore/date/kcalendarsystemhebrew.cpp
@@ -657,16 +657,6 @@ QDate KCalendarSystemHebrew::latestValidDate() const
return QDate::fromJulianDay(3313431);
}
-bool KCalendarSystemHebrew::isLeapYear(int year) const
-{
- return KCalendarSystem::isLeapYear(year);
-}
-
-bool KCalendarSystemHebrew::isLeapYear(const QDate &date) const
-{
- return KCalendarSystem::isLeapYear(date);
-}
-
int KCalendarSystemHebrew::yearStringToInteger(const QString &string, int &readLength) const
{
int result = KCalendarSystem::yearStringToInteger(string, readLength);
diff --git a/kdecore/date/kcalendarsystemhebrew_p.h b/kdecore/date/kcalendarsystemhebrew_p.h
index ccfbb37..aa0a1fb 100644
--- a/kdecore/date/kcalendarsystemhebrew_p.h
+++ b/kdecore/date/kcalendarsystemhebrew_p.h
@@ -51,9 +51,6 @@ public:
virtual QDate earliestValidDate() const;
virtual QDate latestValidDate() const;
- virtual bool isLeapYear(int year) const;
- virtual bool isLeapYear(const QDate &date) const;
-
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
virtual int yearStringToInteger(const QString &sNum, int &iLength) const;
diff --git a/kdecore/date/kcalendarsystemindiannational.cpp b/kdecore/date/kcalendarsystemindiannational.cpp
index 1389cd8..3052c6c 100644
--- a/kdecore/date/kcalendarsystemindiannational.cpp
+++ b/kdecore/date/kcalendarsystemindiannational.cpp
@@ -196,16 +196,6 @@ QDate KCalendarSystemIndianNational::latestValidDate() const
return QDate::fromJulianDay(5402054);
}
-bool KCalendarSystemIndianNational::isLeapYear(int year) const
-{
- return KCalendarSystem::isLeapYear(year);
-}
-
-bool KCalendarSystemIndianNational::isLeapYear(const QDate &date) const
-{
- return KCalendarSystem::isLeapYear(date);
-}
-
bool KCalendarSystemIndianNational::isLunar() const
{
return false;
diff --git a/kdecore/date/kcalendarsystemindiannational_p.h b/kdecore/date/kcalendarsystemindiannational_p.h
index 88d2d9c..af61c00 100644
--- a/kdecore/date/kcalendarsystemindiannational_p.h
+++ b/kdecore/date/kcalendarsystemindiannational_p.h
@@ -51,9 +51,6 @@ public:
virtual QDate earliestValidDate() const;
virtual QDate latestValidDate() const;
- virtual bool isLeapYear(int year) const;
- virtual bool isLeapYear(const QDate &date) const;
-
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
virtual bool isLunar() const;
diff --git a/kdecore/date/kcalendarsystemislamiccivil.cpp b/kdecore/date/kcalendarsystemislamiccivil.cpp
index 1d116b3..90dc353 100644
--- a/kdecore/date/kcalendarsystemislamiccivil.cpp
+++ b/kdecore/date/kcalendarsystemislamiccivil.cpp
@@ -196,16 +196,6 @@ QDate KCalendarSystemIslamicCivil::latestValidDate() const
return QDate::fromJulianDay(5491751);
}
-bool KCalendarSystemIslamicCivil::isLeapYear(int year) const
-{
- return KCalendarSystem::isLeapYear(year);
-}
-
-bool KCalendarSystemIslamicCivil::isLeapYear(const QDate &date) const
-{
- return KCalendarSystem::isLeapYear(date);
-}
-
bool KCalendarSystemIslamicCivil::isLunar() const
{
return true;
diff --git a/kdecore/date/kcalendarsystemislamiccivil_p.h b/kdecore/date/kcalendarsystemislamiccivil_p.h
index 67e5489..5876882 100644
--- a/kdecore/date/kcalendarsystemislamiccivil_p.h
+++ b/kdecore/date/kcalendarsystemislamiccivil_p.h
@@ -53,9 +53,6 @@ public:
virtual QDate earliestValidDate() const;
virtual QDate latestValidDate() const;
- virtual bool isLeapYear(int year) const;
- virtual bool isLeapYear(const QDate &date) const;
-
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
virtual bool isLunar() const;
diff --git a/kdecore/date/kcalendarsystemjalali.cpp b/kdecore/date/kcalendarsystemjalali.cpp
index 339f497..2e3270b 100644
--- a/kdecore/date/kcalendarsystemjalali.cpp
+++ b/kdecore/date/kcalendarsystemjalali.cpp
@@ -204,16 +204,6 @@ QDate KCalendarSystemJalali::latestValidDate() const
return QDate::fromJulianDay(2507140);
}
-bool KCalendarSystemJalali::isLeapYear(int year) const
-{
- return KCalendarSystem::isLeapYear(year);
-}
-
-bool KCalendarSystemJalali::isLeapYear(const QDate &date) const
-{
- return KCalendarSystem::isLeapYear(date);
-}
-
bool KCalendarSystemJalali::isLunar() const
{
return false;
diff --git a/kdecore/date/kcalendarsystemjalali_p.h b/kdecore/date/kcalendarsystemjalali_p.h
index 7f5a4ae..bc2a425 100644
--- a/kdecore/date/kcalendarsystemjalali_p.h
+++ b/kdecore/date/kcalendarsystemjalali_p.h
@@ -42,9 +42,6 @@ public:
virtual QDate earliestValidDate() const;
virtual QDate latestValidDate() const;
- virtual bool isLeapYear(int year) const;
- virtual bool isLeapYear(const QDate &date) const;
-
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
virtual bool isLunar() const;
diff --git a/kdecore/date/kcalendarsystemjapanese.cpp b/kdecore/date/kcalendarsystemjapanese.cpp
index 0ea80cf..85c509c 100644
--- a/kdecore/date/kcalendarsystemjapanese.cpp
+++ b/kdecore/date/kcalendarsystemjapanese.cpp
@@ -140,16 +140,6 @@ QDate KCalendarSystemJapanese::latestValidDate() const
return QDate::fromJulianDay(5373484);
}
-bool KCalendarSystemJapanese::isLeapYear(int year) const
-{
- return KCalendarSystemGregorian::isLeapYear(year);
-}
-
-bool KCalendarSystemJapanese::isLeapYear(const QDate &date) const
-{
- return KCalendarSystemGregorian::isLeapYear(date);
-}
-
int KCalendarSystemJapanese::yearStringToInteger(const QString &sNum, int &iLength) const
{
QString gannen = i18nc("Japanese year 1 of era", "Gannen");
diff --git a/kdecore/date/kcalendarsystemjapanese_p.h b/kdecore/date/kcalendarsystemjapanese_p.h
index fc368a2..86d05f2 100644
--- a/kdecore/date/kcalendarsystemjapanese_p.h
+++ b/kdecore/date/kcalendarsystemjapanese_p.h
@@ -48,9 +48,6 @@ public:
virtual QDate earliestValidDate() const;
virtual QDate latestValidDate() const;
- virtual bool isLeapYear(int year) const;
- virtual bool isLeapYear(const QDate &date) const;
-
virtual int yearStringToInteger(const QString &sNum, int &iLength) const;
virtual bool isLunar() const;
diff --git a/kdecore/date/kcalendarsystemjulian.cpp b/kdecore/date/kcalendarsystemjulian.cpp
index 16cd50e..5a3e6fd 100644
--- a/kdecore/date/kcalendarsystemjulian.cpp
+++ b/kdecore/date/kcalendarsystemjulian.cpp
@@ -205,16 +205,6 @@ QDate KCalendarSystemJulian::latestValidDate() const
return QDate::fromJulianDay(5373557);
}
-bool KCalendarSystemJulian::isLeapYear(int year) const
-{
- return KCalendarSystem::isLeapYear(year);
-}
-
-bool KCalendarSystemJulian::isLeapYear(const QDate &date) const
-{
- return KCalendarSystem::isLeapYear(date);
-}
-
bool KCalendarSystemJulian::isLunar() const
{
return false;
diff --git a/kdecore/date/kcalendarsystemjulian_p.h b/kdecore/date/kcalendarsystemjulian_p.h
index 329d7e5..9e8fefb 100644
--- a/kdecore/date/kcalendarsystemjulian_p.h
+++ b/kdecore/date/kcalendarsystemjulian_p.h
@@ -51,9 +51,6 @@ public:
virtual QDate earliestValidDate() const;
virtual QDate latestValidDate() const;
- virtual bool isLeapYear(int year) const;
- virtual bool isLeapYear(const QDate &date) const;
-
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
virtual bool isLunar() const;
diff --git a/kdecore/date/kcalendarsystemminguo.cpp b/kdecore/date/kcalendarsystemminguo.cpp
index b01ffda..9f1c156 100644
--- a/kdecore/date/kcalendarsystemminguo.cpp
+++ b/kdecore/date/kcalendarsystemminguo.cpp
@@ -114,16 +114,6 @@ QDate KCalendarSystemMinguo::latestValidDate() const
return QDate::fromJulianDay(6071462);
}
-bool KCalendarSystemMinguo::isLeapYear(int year) const
-{
- return KCalendarSystemGregorian::isLeapYear(year);
-}
-
-bool KCalendarSystemMinguo::isLeapYear(const QDate &date) const
-{
- return KCalendarSystemGregorian::isLeapYear(date);
-}
-
bool KCalendarSystemMinguo::isLunar() const
{
return KCalendarSystemGregorian::isLunar();
diff --git a/kdecore/date/kcalendarsystemminguo_p.h b/kdecore/date/kcalendarsystemminguo_p.h
index b0b9fd5..9435485 100644
--- a/kdecore/date/kcalendarsystemminguo_p.h
+++ b/kdecore/date/kcalendarsystemminguo_p.h
@@ -48,9 +48,6 @@ public:
virtual QDate earliestValidDate() const;
virtual QDate latestValidDate() const;
- virtual bool isLeapYear(int year) const;
- virtual bool isLeapYear(const QDate &date) const;
-
virtual bool isLunar() const;
virtual bool isLunisolar() const;
virtual bool isSolar() const;
diff --git a/kdecore/date/kcalendarsystemqdate.cpp b/kdecore/date/kcalendarsystemqdate.cpp
index 1a905a2..bcbd2b2 100644
--- a/kdecore/date/kcalendarsystemqdate.cpp
+++ b/kdecore/date/kcalendarsystemqdate.cpp
@@ -207,31 +207,11 @@ int KCalendarSystemQDate::day(const QDate &date) const
return date.day();
}
-int KCalendarSystemQDate::daysInYear(const QDate &date) const
-{
- return date.daysInYear();
-}
-
-int KCalendarSystemQDate::daysInMonth(const QDate &date) const
-{
- return date.daysInMonth();
-}
-
int KCalendarSystemQDate::dayOfYear(const QDate &date) const
{
return date.dayOfYear();
}
-bool KCalendarSystemQDate::isLeapYear(int year) const
-{
- return QDate::isLeapYear(year);
-}
-
-bool KCalendarSystemQDate::isLeapYear(const QDate &date) const
-{
- return QDate::isLeapYear(date.year());
-}
-
bool KCalendarSystemQDate::isLunar() const
{
return false;
diff --git a/kdecore/date/kcalendarsystemqdate_p.h b/kdecore/date/kcalendarsystemqdate_p.h
index bfe85a6..2577f9b 100644
--- a/kdecore/date/kcalendarsystemqdate_p.h
+++ b/kdecore/date/kcalendarsystemqdate_p.h
@@ -54,15 +54,8 @@ public:
virtual int year(const QDate &date) const;
virtual int month(const QDate &date) const;
virtual int day(const QDate &date) const;
-
- virtual int daysInYear(const QDate &date) const;
- virtual int daysInMonth(const QDate &date) const;
-
virtual int dayOfYear(const QDate &date) const;
- virtual bool isLeapYear(int year) const;
- virtual bool isLeapYear(const QDate &date) const;
-
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
virtual bool isLunar() const;
diff --git a/kdecore/date/kcalendarsystemthai.cpp b/kdecore/date/kcalendarsystemthai.cpp
index 642835c..61de6e3 100644
--- a/kdecore/date/kcalendarsystemthai.cpp
+++ b/kdecore/date/kcalendarsystemthai.cpp
@@ -120,16 +120,6 @@ QDate KCalendarSystemThai::latestValidDate() const
return QDate::fromJulianDay(5175158);
}
-bool KCalendarSystemThai::isLeapYear(int year) const
-{
- return KCalendarSystemGregorian::isLeapYear(year);
-}
-
-bool KCalendarSystemThai::isLeapYear(const QDate &date) const
-{
- return KCalendarSystemGregorian::isLeapYear(date);
-}
-
bool KCalendarSystemThai::isLunar() const
{
return KCalendarSystemGregorian::isLunar();
diff --git a/kdecore/date/kcalendarsystemthai_p.h b/kdecore/date/kcalendarsystemthai_p.h
index a59789a..615a107 100644
--- a/kdecore/date/kcalendarsystemthai_p.h
+++ b/kdecore/date/kcalendarsystemthai_p.h
@@ -48,9 +48,6 @@ public:
virtual QDate earliestValidDate() const;
virtual QDate latestValidDate() const;
- virtual bool isLeapYear(int year) const;
- virtual bool isLeapYear(const QDate &date) const;
-
virtual bool isLunar() const;
virtual bool isLunisolar() const;
virtual bool isSolar() const;
--
1.7.10.4
More information about the Kde-frameworks-devel
mailing list