SIC: QLocale: Make QSystemLocale a private class
As discussed on list and approved by Lars and Thiago. Make QSystemLocale private to give us time and space to change it to a better implementation. Change-Id: Ifd806972f3996c43a876f544f78c6557ad71cd75 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
29c4a27a94
commit
23457bd6d9
2
dist/changes-5.0.0
vendored
2
dist/changes-5.0.0
vendored
@ -198,6 +198,8 @@ information about a particular change.
|
||||
longer take a parameter for base, they will only perform localised base 10
|
||||
conversions. For converting other bases use the QString methods instead.
|
||||
|
||||
- QSystemLocale has been removed from the public API.
|
||||
|
||||
****************************************************************************
|
||||
* General *
|
||||
****************************************************************************
|
||||
|
@ -61,71 +61,6 @@ class QTextStreamPrivate;
|
||||
|
||||
class QLocale;
|
||||
|
||||
#ifndef QT_NO_SYSTEMLOCALE
|
||||
class Q_CORE_EXPORT QSystemLocale
|
||||
{
|
||||
public:
|
||||
QSystemLocale();
|
||||
virtual ~QSystemLocale();
|
||||
|
||||
struct CurrencyToStringArgument
|
||||
{
|
||||
CurrencyToStringArgument() { }
|
||||
CurrencyToStringArgument(const QVariant &v, const QString &s)
|
||||
: value(v), symbol(s) { }
|
||||
QVariant value;
|
||||
QString symbol;
|
||||
};
|
||||
|
||||
enum QueryType {
|
||||
LanguageId, // uint
|
||||
CountryId, // uint
|
||||
DecimalPoint, // QString
|
||||
GroupSeparator, // QString
|
||||
ZeroDigit, // QString
|
||||
NegativeSign, // QString
|
||||
DateFormatLong, // QString
|
||||
DateFormatShort, // QString
|
||||
TimeFormatLong, // QString
|
||||
TimeFormatShort, // QString
|
||||
DayNameLong, // QString, in: int
|
||||
DayNameShort, // QString, in: int
|
||||
MonthNameLong, // QString, in: int
|
||||
MonthNameShort, // QString, in: int
|
||||
DateToStringLong, // QString, in: QDate
|
||||
DateToStringShort, // QString in: QDate
|
||||
TimeToStringLong, // QString in: QTime
|
||||
TimeToStringShort, // QString in: QTime
|
||||
DateTimeFormatLong, // QString
|
||||
DateTimeFormatShort, // QString
|
||||
DateTimeToStringLong, // QString in: QDateTime
|
||||
DateTimeToStringShort, // QString in: QDateTime
|
||||
MeasurementSystem, // uint
|
||||
PositiveSign, // QString
|
||||
AMText, // QString
|
||||
PMText, // QString
|
||||
FirstDayOfWeek, // Qt::DayOfWeek
|
||||
Weekdays, // QList<Qt::DayOfWeek>
|
||||
CurrencySymbol, // QString in: CurrencyToStringArgument
|
||||
CurrencyToString, // QString in: qlonglong, qulonglong or double
|
||||
UILanguages, // QStringList
|
||||
StringToStandardQuotation, // QString in: QStringRef to quote
|
||||
StringToAlternateQuotation, // QString in: QStringRef to quote
|
||||
ScriptId, // uint
|
||||
ListToSeparatedString, // QString
|
||||
LocaleChanged, // system locale changed
|
||||
NativeLanguageName, // QString
|
||||
NativeCountryName // QString
|
||||
};
|
||||
virtual QVariant query(QueryType type, QVariant in) const;
|
||||
virtual QLocale fallbackLocale() const;
|
||||
|
||||
private:
|
||||
QSystemLocale(bool);
|
||||
friend QSystemLocale *QSystemLocale_globalSystemLocale();
|
||||
};
|
||||
#endif
|
||||
|
||||
struct QLocalePrivate;
|
||||
class Q_CORE_EXPORT QLocale
|
||||
{
|
||||
@ -811,10 +746,6 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QLocale &);
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_SYSTEMLOCALE
|
||||
Q_DECLARE_METATYPE(QSystemLocale::CurrencyToStringArgument)
|
||||
#endif
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QLOCALE_H
|
||||
|
@ -711,6 +711,7 @@
|
||||
*/
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\class QSystemLocale
|
||||
\brief The QSystemLocale class can be used to finetune the system locale
|
||||
of the user.
|
||||
|
@ -61,6 +61,71 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_SYSTEMLOCALE
|
||||
class QSystemLocale
|
||||
{
|
||||
public:
|
||||
QSystemLocale();
|
||||
virtual ~QSystemLocale();
|
||||
|
||||
struct CurrencyToStringArgument
|
||||
{
|
||||
CurrencyToStringArgument() { }
|
||||
CurrencyToStringArgument(const QVariant &v, const QString &s)
|
||||
: value(v), symbol(s) { }
|
||||
QVariant value;
|
||||
QString symbol;
|
||||
};
|
||||
|
||||
enum QueryType {
|
||||
LanguageId, // uint
|
||||
CountryId, // uint
|
||||
DecimalPoint, // QString
|
||||
GroupSeparator, // QString
|
||||
ZeroDigit, // QString
|
||||
NegativeSign, // QString
|
||||
DateFormatLong, // QString
|
||||
DateFormatShort, // QString
|
||||
TimeFormatLong, // QString
|
||||
TimeFormatShort, // QString
|
||||
DayNameLong, // QString, in: int
|
||||
DayNameShort, // QString, in: int
|
||||
MonthNameLong, // QString, in: int
|
||||
MonthNameShort, // QString, in: int
|
||||
DateToStringLong, // QString, in: QDate
|
||||
DateToStringShort, // QString in: QDate
|
||||
TimeToStringLong, // QString in: QTime
|
||||
TimeToStringShort, // QString in: QTime
|
||||
DateTimeFormatLong, // QString
|
||||
DateTimeFormatShort, // QString
|
||||
DateTimeToStringLong, // QString in: QDateTime
|
||||
DateTimeToStringShort, // QString in: QDateTime
|
||||
MeasurementSystem, // uint
|
||||
PositiveSign, // QString
|
||||
AMText, // QString
|
||||
PMText, // QString
|
||||
FirstDayOfWeek, // Qt::DayOfWeek
|
||||
Weekdays, // QList<Qt::DayOfWeek>
|
||||
CurrencySymbol, // QString in: CurrencyToStringArgument
|
||||
CurrencyToString, // QString in: qlonglong, qulonglong or double
|
||||
UILanguages, // QStringList
|
||||
StringToStandardQuotation, // QString in: QStringRef to quote
|
||||
StringToAlternateQuotation, // QString in: QStringRef to quote
|
||||
ScriptId, // uint
|
||||
ListToSeparatedString, // QString
|
||||
LocaleChanged, // system locale changed
|
||||
NativeLanguageName, // QString
|
||||
NativeCountryName // QString
|
||||
};
|
||||
virtual QVariant query(QueryType type, QVariant in) const;
|
||||
virtual QLocale fallbackLocale() const;
|
||||
|
||||
private:
|
||||
QSystemLocale(bool);
|
||||
friend QSystemLocale *QSystemLocale_globalSystemLocale();
|
||||
};
|
||||
#endif
|
||||
|
||||
struct Q_CORE_EXPORT QLocalePrivate
|
||||
{
|
||||
public:
|
||||
@ -261,5 +326,8 @@ QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QStringRef)
|
||||
Q_DECLARE_METATYPE(QList<Qt::DayOfWeek>)
|
||||
#ifndef QT_NO_SYSTEMLOCALE
|
||||
Q_DECLARE_METATYPE(QSystemLocale::CurrencyToStringArgument)
|
||||
#endif
|
||||
|
||||
#endif // QLOCALE_P_H
|
||||
|
@ -123,9 +123,6 @@ private slots:
|
||||
void monthName();
|
||||
void standaloneMonthName();
|
||||
|
||||
// QSystemLocale tests
|
||||
void queryDateTime();
|
||||
|
||||
void ampm();
|
||||
void currency();
|
||||
void quoteString();
|
||||
@ -1778,43 +1775,6 @@ a(QLatin1String("0.0000000000000000000000000000000000000000000000000000000000000
|
||||
QVERIFY(!ok);
|
||||
}
|
||||
|
||||
class SystemLocale : public QSystemLocale
|
||||
{
|
||||
public:
|
||||
virtual QVariant query(QueryType type, QVariant in) const
|
||||
{
|
||||
switch (type) {
|
||||
case DateTimeFormatLong: return QLatin1String("dddd ddd dd d MMMM MMM MM M yyyy hh:mm:ss.zzz");
|
||||
case DateTimeFormatShort: return QLatin1String("d M yy h:m");
|
||||
case DateTimeToStringLong:
|
||||
case DateTimeToStringShort:
|
||||
return in.toDateTime().toString(type == DateTimeToStringShort
|
||||
? QLatin1String("dMyyhm")
|
||||
: QLatin1String("ddMMyyyyhhmmsszzz"));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QSystemLocale::query(type, in);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
void tst_QLocale::queryDateTime()
|
||||
{
|
||||
SystemLocale loc;
|
||||
QCOMPARE(QLocale::system().dateTimeFormat(QLocale::LongFormat),
|
||||
loc.query(QSystemLocale::DateTimeFormatLong, QVariant()).toString());
|
||||
QCOMPARE(QLocale::system().dateTimeFormat(QLocale::ShortFormat),
|
||||
loc.query(QSystemLocale::DateTimeFormatShort, QVariant()).toString());
|
||||
QCOMPARE(QLocale::system().toString(QDateTime(QDate(1974, 12, 1), QTime(1, 2, 3, 4)), QLocale::ShortFormat),
|
||||
QString("1127412"));
|
||||
QCOMPARE(QLocale::system().toString(QDateTime(QDate(1974, 12, 1), QTime(1, 2, 3, 4)), QLocale::NarrowFormat),
|
||||
QLocale::system().toString(QDateTime(QDate(1974, 12, 1), QTime(1, 2, 3, 4)), QLocale::ShortFormat));
|
||||
QCOMPARE(QLocale::system().toString(QDateTime(QDate(1974, 12, 1), QTime(1, 2, 3, 4)), QLocale::LongFormat),
|
||||
QString("01121974010203004"));
|
||||
}
|
||||
|
||||
void tst_QLocale::ampm()
|
||||
{
|
||||
QLocale c(QLocale::C);
|
||||
|
Loading…
x
Reference in New Issue
Block a user