[PATCH 13/23] kcalendarsystem: Make weekStartDay() inline rather than virtual.

Jon Severinsson jon at severinsson.net
Fri Oct 12 15:13:48 UTC 2012


This is locale dependent, not calendar system dependent, so no need to be virtual.
Also remove bogous tests, would break if tests were run on a non-standard locale.
---
 kdecore/date/kcalendarsystem.cpp |    5 -----
 kdecore/date/kcalendarsystem.h   |   11 +++++++----
 kdecore/tests/kcalendartest.cpp  |   16 ----------------
 3 filer ändrade, 7 tillägg(+), 25 borttagningar(-)

diff --git a/kdecore/date/kcalendarsystem.cpp b/kdecore/date/kcalendarsystem.cpp
index a31b978..5872a2c 100644
--- a/kdecore/date/kcalendarsystem.cpp
+++ b/kdecore/date/kcalendarsystem.cpp
@@ -2088,11 +2088,6 @@ int KCalendarSystem::applyShortYearWindow(int inputYear) const
     return d->applyShortYearWindow(inputYear);
 }
 
-int KCalendarSystem::weekStartDay() const
-{
-    return locale()->weekStartDay();
-}
-
 const KLocale * KCalendarSystem::locale() const
 {
     Q_D(const KCalendarSystem);
diff --git a/kdecore/date/kcalendarsystem.h b/kdecore/date/kcalendarsystem.h
index 25af454..9214847 100644
--- a/kdecore/date/kcalendarsystem.h
+++ b/kdecore/date/kcalendarsystem.h
@@ -1390,15 +1390,18 @@ public:
      * Use this to determine which day is the first day of the week.
      *
      * Uses the calendar system's internal locale set when the instance was
-     * created, which ensures that the correct calendar system and locale
-     * settings are respected, which would not occur in some cases if using
-     * the global locale.  Defaults to global locale.
+     * created, which ensures that the the caller will use the same value
+     * as the calendar system, which would not necessisarily happen if
+     * @c KLocale::weekStartDay() was used directly.
      *
      * @see KLocale::weekStartDay
      *
      * @return an integer (Monday = 1, ..., Sunday = 7)
      */
-    virtual int weekStartDay() const;
+    inline int weekStartDay() const
+    {
+        return locale()->weekStartDay();
+    }
 
     /**
      * @deprecated use KLocale::weekDayOfPray() instead
diff --git a/kdecore/tests/kcalendartest.cpp b/kdecore/tests/kcalendartest.cpp
index 2e372d7..1459183 100644
--- a/kdecore/tests/kcalendartest.cpp
+++ b/kdecore/tests/kcalendartest.cpp
@@ -1315,8 +1315,6 @@ void KCalendarTest::testQDateCalendarBasic()
 
     QCOMPARE(calendar->monthsInYear(QDate(2007, 1, 1)), 12);
 
-    QCOMPARE(calendar->weekStartDay(), 1);
-
     QCOMPARE(calendar->isProleptic(), false);
     QCOMPARE(calendar->isLunar(), false);
     QCOMPARE(calendar->isLunisolar(), false);
@@ -1399,8 +1397,6 @@ void KCalendarTest::testGregorianBasic()
 
     QCOMPARE(calendar->monthsInYear(QDate(2007, 1, 1)), 12);
 
-    QCOMPARE(calendar->weekStartDay(), 1);
-
     QCOMPARE(calendar->isProleptic(), true);
     QCOMPARE(calendar->isLunar(), false);
     QCOMPARE(calendar->isLunisolar(), false);
@@ -1453,8 +1449,6 @@ void KCalendarTest::testHebrewBasic()
     testWeekDayName(calendar, 4, testDate, "T", "Thu", "Thursday");
     testMonthName(calendar, 1, 5707, testDate, "T", "Tis", "Tishrey", "of Tis", "of Tishrey");
 
-    QCOMPARE(calendar->weekStartDay(), 1);
-
     QCOMPARE(calendar->isProleptic(), false);
     QCOMPARE(calendar->isLunar(), false);
     QCOMPARE(calendar->isLunisolar(), true);
@@ -1531,8 +1525,6 @@ void KCalendarTest::testIslamicCivilBasic()
 
     QCOMPARE(calendar->monthsInYear(testDate), 12);
 
-    QCOMPARE(calendar->weekStartDay(), 1);
-
     QCOMPARE(calendar->isProleptic(), false);
     QCOMPARE(calendar->isLunar(), true);
     QCOMPARE(calendar->isLunisolar(), false);
@@ -1589,8 +1581,6 @@ void KCalendarTest::testJalaliBasic()
 
     QCOMPARE(calendar->monthsInYear(testDate), 12);
 
-    QCOMPARE(calendar->weekStartDay(), 1);
-
     QCOMPARE(calendar->isProleptic(), false);
     QCOMPARE(calendar->isLunar(), false);
     QCOMPARE(calendar->isLunisolar(), false);
@@ -1679,8 +1669,6 @@ void KCalendarTest::testJapaneseBasic()
 
     QCOMPARE(calendar->monthsInYear(QDate(2007, 1, 1)), 12);
 
-    QCOMPARE(calendar->weekStartDay(), 1);
-
     QCOMPARE(calendar->isProleptic(), false);
     QCOMPARE(calendar->isLunar(), false);
     QCOMPARE(calendar->isLunisolar(), false);
@@ -1776,8 +1764,6 @@ void KCalendarTest::testMinguoBasic()
 
     QCOMPARE(calendar->monthsInYear(QDate(2007, 1, 1)), 12);
 
-    QCOMPARE(calendar->weekStartDay(), 1);
-
     QCOMPARE(calendar->isProleptic(), false);
     QCOMPARE(calendar->isLunar(), false);
     QCOMPARE(calendar->isLunisolar(), false);
@@ -1824,8 +1810,6 @@ void KCalendarTest::testThaiBasic()
 
     QCOMPARE(calendar->monthsInYear(QDate(2007, 1, 1)), 12);
 
-    QCOMPARE(calendar->weekStartDay(), 1);
-
     QCOMPARE(calendar->isProleptic(), false);
     QCOMPARE(calendar->isLunar(), false);
     QCOMPARE(calendar->isLunisolar(), false);
-- 
1.7.10.4



More information about the Kde-frameworks-devel mailing list