From c94a4917c4ba72c08958df535c4b325b3ed595dc Mon Sep 17 00:00:00 2001 From: Giorgos Tsiapaliwkas Date: Fri, 23 Mar 2012 15:46:46 +0200 Subject: [PATCH] fix the calendarSystemsList list --- declarativeimports/locale/calendarsystem.cpp | 6 +-- declarativeimports/locale/calendarsystem.h | 38 +------------------ .../tests/contents/code/klocaleqmltest.qml | 8 +++- 3 files changed, 12 insertions(+), 40 deletions(-) diff --git a/declarativeimports/locale/calendarsystem.cpp b/declarativeimports/locale/calendarsystem.cpp index 116a53314..d60f982d0 100644 --- a/declarativeimports/locale/calendarsystem.cpp +++ b/declarativeimports/locale/calendarsystem.cpp @@ -32,12 +32,12 @@ CalendarSystem::CalendarSystem(QObject* parent) m_calendarSystem = KCalendarSystem::create(KGlobal::locale()->calendarSystem()); } -QList CalendarSystem::calendarSystemsList() +QList CalendarSystem::calendarSystemsList() { - QList list; + QList list; foreach(KLocale::CalendarSystem calendarSystem, KCalendarSystem::calendarSystemsList()) { - list.append((Locale::CalendarSystem)calendarSystem); + list.append((int)calendarSystem); } return list; diff --git a/declarativeimports/locale/calendarsystem.h b/declarativeimports/locale/calendarsystem.h index c80b445c4..ced4cd829 100644 --- a/declarativeimports/locale/calendarsystem.h +++ b/declarativeimports/locale/calendarsystem.h @@ -49,6 +49,7 @@ Q_ENUMS(DateTimeComponent) Q_ENUMS(DateTimeComponentFormat) //properties +Q_PROPERTY(QList calendarSystemsList READ calendarSystemsList) Q_PROPERTY(Locale::CalendarSystem calendarSystem READ calendarSystem NOTIFY calendarSystemChanged)//read-only Q_PROPERTY(QString calendarLabel READ calendarLabel NOTIFY calendarLabelChanged)//read-only Q_PROPERTY(QDate epoch READ epoch NOTIFY epochChanged)//read-only @@ -172,41 +173,7 @@ public: * Returns the list of currently supported Calendar Systems * @return list of Calendar Systems */ - static QList calendarSystemsList();//TODO - - /** - * - * Returns a localized label to display for the required Calendar System type. - * - * Use with calendarSystemsList() to populate selection lists of available - * calendar systems. - * - * @param calendarSystem the specific calendar type to return the label for - * @param locale the locale to use for the label, defaults to global - * @return label for calendar - */ - Q_INVOKABLE static QString calendarLabel(Locale::CalendarSystem calendarSystem, const KLocale *locale = KGlobal::locale()); - - /** - * - * Returns the Calendar System enum value for a given Calendar Type, - * e.g. Locale::QDateCalendar for "gregorian" - * - * @param calendarType the calendar type to convert - * @return calendar system for calendar type - */ - Q_INVOKABLE static Locale::CalendarSystem calendarSystem(const QString &calendarType); - - //KDE5 remove - /** - * - * Returns the deprecated Calendar Type for a given Calendar System enum value, - * e.g. "gregorian" for Locale::QDateCalendar - * - * @param calendarSystem the calendar system to convert - * @return calendar type for calendar system - */ - Q_INVOKABLE static QString calendarType(Locale::CalendarSystem calendarSystem); + static QList calendarSystemsList(); /** * @@ -216,7 +183,6 @@ public: */ Locale::CalendarSystem calendarSystem() const; - //KDE5 make virtual? /** * * Returns a localized label to display for the current Calendar System type. diff --git a/declarativeimports/locale/tests/contents/code/klocaleqmltest.qml b/declarativeimports/locale/tests/contents/code/klocaleqmltest.qml index 9b441cc26..bac186628 100644 --- a/declarativeimports/locale/tests/contents/code/klocaleqmltest.qml +++ b/declarativeimports/locale/tests/contents/code/klocaleqmltest.qml @@ -85,6 +85,7 @@ Item { console.log("decimalSymbol:" + locale.decimalSymbol) locale.digitSet = Locale.EasternArabicIndicDigits + console.log("digitSet:" + locale.digitSet) console.log("language:" + locale.language) @@ -205,7 +206,7 @@ Item { console.log("convertDigits:" + locale.convertDigits(locale.digitSet, Locale.ArabicDigits)) for (var i in locale.allDigitSetsList) { - console.log("digits:" + locale.allDigitSetsList[i]) + console.log("allDigitSetsList:" + locale.allDigitSetsList[i]) } console.log("===========end===========") @@ -303,6 +304,7 @@ Item { console.log("applyShortYearWindow:" + calendar.applyShortYearWindow(50)) + console.log("calendarSystem:" + calendar.calendarSystem) console.log("getDate:") hash = calendar.getDate("2012-02-03") for (var i in hash) { @@ -315,6 +317,10 @@ Item { console.log(" " + i, "=", hash[i]) } + for (var i in calendar.calendarSystemsList) { + console.log("calendarSystemsList:" + calendar.calendarSystemsList[i]) + } + console.log("===============end===============") } }