Fix QLocale::standaloneMonthName when d->m_data == systemData()

At the moment if  d->m_data == systemData() it calls
systemLocale()->query but forgets about the standalone part
so you get the wrong data

This patch introduces the new enums so that backends can implement
properly the standaloneMonthName feature properly. At the moment the Windows
and Mac ones still return the monthName, the Unix and Blackberry ones return
the data we store in months_data

Change-Id: Idc5a50b04ab1f914f16c7385be1dca2e027feae3
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Reviewed-by: Mehdi Fekari <mfekari@blackberry.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Albert Astals Cid 2013-04-18 18:58:18 +02:00 committed by The Qt Project
parent 05984c910f
commit b1de018e9a
6 changed files with 17 additions and 3 deletions

View File

@ -2243,7 +2243,7 @@ QString QLocale::standaloneMonthName(int month, FormatType type) const
#ifndef QT_NO_SYSTEMLOCALE #ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == systemData()) { if (d->m_data == systemData()) {
QVariant res = systemLocale()->query(type == LongFormat QVariant res = systemLocale()->query(type == LongFormat
? QSystemLocale::MonthNameLong : QSystemLocale::MonthNameShort, ? QSystemLocale::StandaloneMonthNameLong : QSystemLocale::StandaloneMonthNameShort,
month); month);
if (!res.isNull()) if (!res.isNull())
return res.toString(); return res.toString();

View File

@ -280,6 +280,10 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
return lc_language.monthName(in.toInt(), QLocale::LongFormat); return lc_language.monthName(in.toInt(), QLocale::LongFormat);
case MonthNameShort: case MonthNameShort:
return lc_language.monthName(in.toInt(), QLocale::ShortFormat); return lc_language.monthName(in.toInt(), QLocale::ShortFormat);
case StandaloneMonthNameLong:
return lc_language.standaloneMonthName(in.toInt(), QLocale::LongFormat);
case StandaloneMonthNameShort:
return lc_language.standaloneMonthName(in.toInt(), QLocale::ShortFormat);
case DateToStringLong: case DateToStringLong:
return lc_region.toString(in.toDate(), QLocale::LongFormat); return lc_region.toString(in.toDate(), QLocale::LongFormat);
case DateToStringShort: case DateToStringShort:

View File

@ -401,7 +401,9 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
return macDayName(in.toInt(), (type == DayNameShort)); return macDayName(in.toInt(), (type == DayNameShort));
case MonthNameLong: case MonthNameLong:
case MonthNameShort: case MonthNameShort:
return macMonthName(in.toInt(), (type == MonthNameShort)); case StandaloneMonthNameLong:
case StandaloneMonthNameShort:
return macMonthName(in.toInt(), (type == MonthNameShort || type == StandaloneMonthNameShort));
case DateToStringShort: case DateToStringShort:
case DateToStringLong: case DateToStringLong:
return macDateToString(in.toDate(), (type == DateToStringShort)); return macDateToString(in.toDate(), (type == DateToStringShort));

View File

@ -115,7 +115,9 @@ public:
ListToSeparatedString, // QString ListToSeparatedString, // QString
LocaleChanged, // system locale changed LocaleChanged, // system locale changed
NativeLanguageName, // QString NativeLanguageName, // QString
NativeCountryName // QString NativeCountryName, // QString
StandaloneMonthNameLong, // QString, in: int
StandaloneMonthNameShort // QString, in: int
}; };
virtual QVariant query(QueryType type, QVariant in) const; virtual QVariant query(QueryType type, QVariant in) const;
virtual QLocale fallbackUiLocale() const; virtual QLocale fallbackUiLocale() const;

View File

@ -173,6 +173,10 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
return lc_time.monthName(in.toInt(), QLocale::LongFormat); return lc_time.monthName(in.toInt(), QLocale::LongFormat);
case MonthNameShort: case MonthNameShort:
return lc_time.monthName(in.toInt(), QLocale::ShortFormat); return lc_time.monthName(in.toInt(), QLocale::ShortFormat);
case StandaloneMonthNameLong:
return lc_time.standaloneMonthName(in.toInt(), QLocale::LongFormat);
case StandaloneMonthNameShort:
return lc_time.standaloneMonthName(in.toInt(), QLocale::ShortFormat);
case DateToStringLong: case DateToStringLong:
return lc_time.toString(in.toDate(), QLocale::LongFormat); return lc_time.toString(in.toDate(), QLocale::LongFormat);
case DateToStringShort: case DateToStringShort:

View File

@ -684,8 +684,10 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
case DayNameShort: case DayNameShort:
return d->dayName(in.toInt(), QLocale::ShortFormat); return d->dayName(in.toInt(), QLocale::ShortFormat);
case MonthNameLong: case MonthNameLong:
case StandaloneMonthNameLong:
return d->monthName(in.toInt(), QLocale::LongFormat); return d->monthName(in.toInt(), QLocale::LongFormat);
case MonthNameShort: case MonthNameShort:
case StandaloneMonthNameShort:
return d->monthName(in.toInt(), QLocale::ShortFormat); return d->monthName(in.toInt(), QLocale::ShortFormat);
case DateToStringShort: case DateToStringShort:
return d->toString(in.toDate(), QLocale::ShortFormat); return d->toString(in.toDate(), QLocale::ShortFormat);