| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | | - |
| 23 | | - |
| 24 | | - |
| 25 | | - |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | | - |
| 39 | | - |
| 40 | #include "qlocale_p.h" | - |
| 41 | | - |
| 42 | #include "qstringbuilder.h" | - |
| 43 | #include "qdatetime.h" | - |
| 44 | #include "qstringlist.h" | - |
| 45 | #include "qvariant.h" | - |
| 46 | #include "qreadwritelock.h" | - |
| 47 | | - |
| 48 | QT_BEGIN_NAMESPACE | - |
| 49 | | - |
| 50 | #ifndef QT_NO_SYSTEMLOCALE | - |
| 51 | struct QSystemLocaleData | - |
| 52 | { | - |
| 53 | QSystemLocaleData() | - |
| 54 | : lc_numeric(QLocale::C) | - |
| 55 | ,lc_time(QLocale::C) | - |
| 56 | ,lc_monetary(QLocale::C) | - |
| 57 | ,lc_messages(QLocale::C) | - |
| 58 | { | - |
| 59 | readEnvironment(); | - |
| 60 | } | - |
| 61 | | - |
| 62 | void readEnvironment(); | - |
| 63 | | - |
| 64 | QReadWriteLock lock; | - |
| 65 | | - |
| 66 | QLocale lc_numeric; | - |
| 67 | QLocale lc_time; | - |
| 68 | QLocale lc_monetary; | - |
| 69 | QLocale lc_messages; | - |
| 70 | QByteArray lc_messages_var; | - |
| 71 | QByteArray lc_measurement_var; | - |
| 72 | QStringList uiLanguages; | - |
| 73 | }; | - |
| 74 | | - |
| 75 | void QSystemLocaleData::readEnvironment() | - |
| 76 | { | - |
| 77 | QWriteLocker locker(&lock); | - |
| 78 | | - |
| 79 | QByteArray all = qgetenv("LC_ALL"); | - |
| 80 | QByteArray numeric = all.isEmpty() ? qgetenv("LC_NUMERIC") : all; | - |
| 81 | QByteArray time = all.isEmpty() ? qgetenv("LC_TIME") : all; | - |
| 82 | QByteArray monetary = all.isEmpty() ? qgetenv("LC_MONETARY") : all; | - |
| 83 | lc_messages_var = all.isEmpty() ? qgetenv("LC_MESSAGES") : all; | - |
| 84 | lc_measurement_var = all.isEmpty() ? qgetenv("LC_MEASUREMENT") : all; | - |
| 85 | QByteArray lang = qgetenv("LANG"); | - |
| 86 | if (lang.isEmpty()) | - |
| 87 | lang = QByteArray("C"); | - |
| 88 | if (numeric.isEmpty()) | - |
| 89 | numeric = lang; | - |
| 90 | if (time.isEmpty()) | - |
| 91 | time = lang; | - |
| 92 | if (monetary.isEmpty()) | - |
| 93 | monetary = lang; | - |
| 94 | if (lc_messages_var.isEmpty()) | - |
| 95 | lc_messages_var = lang; | - |
| 96 | if (lc_measurement_var.isEmpty()) | - |
| 97 | lc_measurement_var = lang; | - |
| 98 | lc_numeric = QLocale(QString::fromLatin1(numeric)); | - |
| 99 | lc_time = QLocale(QString::fromLatin1(time)); | - |
| 100 | lc_monetary = QLocale(QString::fromLatin1(monetary)); | - |
| 101 | lc_messages = QLocale(QString::fromLatin1(lc_messages_var)); | - |
| 102 | } | - |
| 103 | | - |
| 104 | Q_GLOBAL_STATIC(QSystemLocaleData, qSystemLocaleData) | - |
| 105 | | - |
| 106 | #endif | - |
| 107 | | - |
| 108 | #ifndef QT_NO_SYSTEMLOCALE | - |
| 109 | | - |
| 110 | QLocale QSystemLocale::fallbackUiLocale() const | - |
| 111 | { | - |
| 112 | QByteArray lang = qgetenv("LC_ALL"); | - |
| 113 | if (lang.isEmpty())| TRUE | evaluated 1015 times by 12 testsEvaluated by:- tst_qapplication - unknown status
- tst_qdbusabstractadaptor - unknown status
- tst_qdbusabstractinterface - unknown status
- tst_qdbusinterface - unknown status
- tst_qdbusmarshall - unknown status
- tst_qdbusxml2cpp - unknown status
- tst_qlogging - unknown status
- tst_qobject - unknown status
- tst_qprocess - unknown status
- tst_qsharedmemory - unknown status
- tst_qsystemsemaphore - unknown status
- tst_selftests - unknown status
| | FALSE | never evaluated |
| 0-1015 |
| 114 | lang = qgetenv("LC_MESSAGES");executed 1015 times by 12 tests: lang = qgetenv("LC_MESSAGES");Executed by:- tst_qapplication - unknown status
- tst_qdbusabstractadaptor - unknown status
- tst_qdbusabstractinterface - unknown status
- tst_qdbusinterface - unknown status
- tst_qdbusmarshall - unknown status
- tst_qdbusxml2cpp - unknown status
- tst_qlogging - unknown status
- tst_qobject - unknown status
- tst_qprocess - unknown status
- tst_qsharedmemory - unknown status
- tst_qsystemsemaphore - unknown status
- tst_selftests - unknown status
| 1015 |
| 115 | if (lang.isEmpty())| TRUE | evaluated 1015 times by 12 testsEvaluated by:- tst_qapplication - unknown status
- tst_qdbusabstractadaptor - unknown status
- tst_qdbusabstractinterface - unknown status
- tst_qdbusinterface - unknown status
- tst_qdbusmarshall - unknown status
- tst_qdbusxml2cpp - unknown status
- tst_qlogging - unknown status
- tst_qobject - unknown status
- tst_qprocess - unknown status
- tst_qsharedmemory - unknown status
- tst_qsystemsemaphore - unknown status
- tst_selftests - unknown status
| | FALSE | never evaluated |
| 0-1015 |
| 116 | lang = qgetenv("LANG");executed 1015 times by 12 tests: lang = qgetenv("LANG");Executed by:- tst_qapplication - unknown status
- tst_qdbusabstractadaptor - unknown status
- tst_qdbusabstractinterface - unknown status
- tst_qdbusinterface - unknown status
- tst_qdbusmarshall - unknown status
- tst_qdbusxml2cpp - unknown status
- tst_qlogging - unknown status
- tst_qobject - unknown status
- tst_qprocess - unknown status
- tst_qsharedmemory - unknown status
- tst_qsystemsemaphore - unknown status
- tst_selftests - unknown status
| 1015 |
| 117 | | - |
| 118 | if (lang.isEmpty() || lang == QByteArray("C") || lang == QByteArray("POSIX"))| TRUE | evaluated 789 times by 1 testEvaluated by:- tst_selftests - unknown status
| | FALSE | evaluated 226 times by 11 testsEvaluated by:- tst_qapplication - unknown status
- tst_qdbusabstractadaptor - unknown status
- tst_qdbusabstractinterface - unknown status
- tst_qdbusinterface - unknown status
- tst_qdbusmarshall - unknown status
- tst_qdbusxml2cpp - unknown status
- tst_qlogging - unknown status
- tst_qobject - unknown status
- tst_qprocess - unknown status
- tst_qsharedmemory - unknown status
- tst_qsystemsemaphore - unknown status
|
| TRUE | never evaluated | | FALSE | evaluated 226 times by 11 testsEvaluated by:- tst_qapplication - unknown status
- tst_qdbusabstractadaptor - unknown status
- tst_qdbusabstractinterface - unknown status
- tst_qdbusinterface - unknown status
- tst_qdbusmarshall - unknown status
- tst_qdbusxml2cpp - unknown status
- tst_qlogging - unknown status
- tst_qobject - unknown status
- tst_qprocess - unknown status
- tst_qsharedmemory - unknown status
- tst_qsystemsemaphore - unknown status
|
| TRUE | never evaluated | | FALSE | evaluated 226 times by 11 testsEvaluated by:- tst_qapplication - unknown status
- tst_qdbusabstractadaptor - unknown status
- tst_qdbusabstractinterface - unknown status
- tst_qdbusinterface - unknown status
- tst_qdbusmarshall - unknown status
- tst_qdbusxml2cpp - unknown status
- tst_qlogging - unknown status
- tst_qobject - unknown status
- tst_qprocess - unknown status
- tst_qsharedmemory - unknown status
- tst_qsystemsemaphore - unknown status
|
| 0-789 |
| 119 | return QLocale(QString::fromLatin1(lang));executed 789 times by 1 test: return QLocale(QString::fromLatin1(lang));Executed by:- tst_selftests - unknown status
| 789 |
| 120 | | - |
| 121 | | - |
| 122 | | - |
| 123 | QByteArray language = qgetenv("LANGUAGE"); | - |
| 124 | if (!language.isEmpty()) {| TRUE | evaluated 226 times by 11 testsEvaluated by:- tst_qapplication - unknown status
- tst_qdbusabstractadaptor - unknown status
- tst_qdbusabstractinterface - unknown status
- tst_qdbusinterface - unknown status
- tst_qdbusmarshall - unknown status
- tst_qdbusxml2cpp - unknown status
- tst_qlogging - unknown status
- tst_qobject - unknown status
- tst_qprocess - unknown status
- tst_qsharedmemory - unknown status
- tst_qsystemsemaphore - unknown status
| | FALSE | never evaluated |
| 0-226 |
| 125 | language = language.split(':').firstconstFirst(); | - |
| 126 | if (!language.isEmpty())| TRUE | evaluated 226 times by 11 testsEvaluated by:- tst_qapplication - unknown status
- tst_qdbusabstractadaptor - unknown status
- tst_qdbusabstractinterface - unknown status
- tst_qdbusinterface - unknown status
- tst_qdbusmarshall - unknown status
- tst_qdbusxml2cpp - unknown status
- tst_qlogging - unknown status
- tst_qobject - unknown status
- tst_qprocess - unknown status
- tst_qsharedmemory - unknown status
- tst_qsystemsemaphore - unknown status
| | FALSE | never evaluated |
| 0-226 |
| 127 | return QLocale(QString::fromLatin1(language));executed 226 times by 11 tests: return QLocale(QString::fromLatin1(language));Executed by:- tst_qapplication - unknown status
- tst_qdbusabstractadaptor - unknown status
- tst_qdbusabstractinterface - unknown status
- tst_qdbusinterface - unknown status
- tst_qdbusmarshall - unknown status
- tst_qdbusxml2cpp - unknown status
- tst_qlogging - unknown status
- tst_qobject - unknown status
- tst_qprocess - unknown status
- tst_qsharedmemory - unknown status
- tst_qsystemsemaphore - unknown status
| 226 |
| 128 | } never executed: end of block | 0 |
| 129 | | - |
| 130 | return QLocale(QString::fromLatin1(lang)); never executed: return QLocale(QString::fromLatin1(lang)); | 0 |
| 131 | } | - |
| 132 | | - |
| 133 | QVariant QSystemLocale::query(QueryType type, QVariant in) const | - |
| 134 | { | - |
| 135 | QSystemLocaleData *d = qSystemLocaleData(); | - |
| 136 | | - |
| 137 | if (type == LocaleChanged) { | - |
| 138 | d->readEnvironment(); | - |
| 139 | return QVariant(); | - |
| 140 | } | - |
| 141 | | - |
| 142 | QReadLocker locker(&d->lock); | - |
| 143 | | - |
| 144 | const QLocale &lc_numeric = d->lc_numeric; | - |
| 145 | const QLocale &lc_time = d->lc_time; | - |
| 146 | const QLocale &lc_monetary = d->lc_monetary; | - |
| 147 | const QLocale &lc_messages = d->lc_messages; | - |
| 148 | | - |
| 149 | switch (type) { | - |
| 150 | case DecimalPoint: | - |
| 151 | return lc_numeric.decimalPoint(); | - |
| 152 | case GroupSeparator: | - |
| 153 | return lc_numeric.groupSeparator(); | - |
| 154 | case ZeroDigit: | - |
| 155 | return lc_numeric.zeroDigit(); | - |
| 156 | case NegativeSign: | - |
| 157 | return lc_numeric.negativeSign(); | - |
| 158 | case DateFormatLong: | - |
| 159 | return lc_time.dateFormat(QLocale::LongFormat); | - |
| 160 | case DateFormatShort: | - |
| 161 | return lc_time.dateFormat(QLocale::ShortFormat); | - |
| 162 | case TimeFormatLong: | - |
| 163 | return lc_time.timeFormat(QLocale::LongFormat); | - |
| 164 | case TimeFormatShort: | - |
| 165 | return lc_time.timeFormat(QLocale::ShortFormat); | - |
| 166 | case DayNameLong: | - |
| 167 | return lc_time.dayName(in.toInt(), QLocale::LongFormat); | - |
| 168 | case DayNameShort: | - |
| 169 | return lc_time.dayName(in.toInt(), QLocale::ShortFormat); | - |
| 170 | case MonthNameLong: | - |
| 171 | return lc_time.monthName(in.toInt(), QLocale::LongFormat); | - |
| 172 | case MonthNameShort: | - |
| 173 | return lc_time.monthName(in.toInt(), QLocale::ShortFormat); | - |
| 174 | case StandaloneMonthNameLong: | - |
| 175 | return lc_time.standaloneMonthName(in.toInt(), QLocale::LongFormat); | - |
| 176 | case StandaloneMonthNameShort: | - |
| 177 | return lc_time.standaloneMonthName(in.toInt(), QLocale::ShortFormat); | - |
| 178 | case DateToStringLong: | - |
| 179 | return lc_time.toString(in.toDate(), QLocale::LongFormat); | - |
| 180 | case DateToStringShort: | - |
| 181 | return lc_time.toString(in.toDate(), QLocale::ShortFormat); | - |
| 182 | case TimeToStringLong: | - |
| 183 | return lc_time.toString(in.toTime(), QLocale::LongFormat); | - |
| 184 | case TimeToStringShort: | - |
| 185 | return lc_time.toString(in.toTime(), QLocale::ShortFormat); | - |
| 186 | case DateTimeFormatLong: | - |
| 187 | return lc_time.dateTimeFormat(QLocale::LongFormat); | - |
| 188 | case DateTimeFormatShort: | - |
| 189 | return lc_time.dateTimeFormat(QLocale::ShortFormat); | - |
| 190 | case DateTimeToStringLong: | - |
| 191 | return lc_time.toString(in.toDateTime(), QLocale::LongFormat); | - |
| 192 | case DateTimeToStringShort: | - |
| 193 | return lc_time.toString(in.toDateTime(), QLocale::ShortFormat); | - |
| 194 | case PositiveSign: | - |
| 195 | return lc_numeric.positiveSign(); | - |
| 196 | case AMText: | - |
| 197 | return lc_time.amText(); | - |
| 198 | case PMText: | - |
| 199 | return lc_time.pmText(); | - |
| 200 | case FirstDayOfWeek: | - |
| 201 | return lc_time.firstDayOfWeek(); | - |
| 202 | case CurrencySymbol: | - |
| 203 | return lc_monetary.currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt())); | - |
| 204 | case CurrencyToString: { | - |
| 205 | switch (in.type()) { | - |
| 206 | case QVariant::Int: | - |
| 207 | return lc_monetary.toCurrencyString(in.toInt()); | - |
| 208 | case QVariant::UInt: | - |
| 209 | return lc_monetary.toCurrencyString(in.toUInt()); | - |
| 210 | case QVariant::Double: | - |
| 211 | return lc_monetary.toCurrencyString(in.toDouble()); | - |
| 212 | case QVariant::LongLong: | - |
| 213 | return lc_monetary.toCurrencyString(in.toLongLong()); | - |
| 214 | case QVariant::ULongLong: | - |
| 215 | return lc_monetary.toCurrencyString(in.toULongLong()); | - |
| 216 | default: | - |
| 217 | break; | - |
| 218 | } | - |
| 219 | return QString(); | - |
| 220 | } | - |
| 221 | case MeasurementSystem: { | - |
| 222 | const QString meas_locale = QString::fromLatin1(d->lc_measurement_var.constData(), d->lc_measurement_var.size()); | - |
| 223 | if (meas_locale.compare(QLatin1String("Metric"), Qt::CaseInsensitive) == 0) | - |
| 224 | return QLocale::MetricSystem; | - |
| 225 | if (meas_locale.compare(QLatin1String("Other"), Qt::CaseInsensitive) == 0) | - |
| 226 | return QLocale::MetricSystem; | - |
| 227 | return QVariant((int)QLocale(meas_locale).measurementSystem()); | - |
| 228 | } | - |
| 229 | case UILanguages: { | - |
| 230 | if (!d->uiLanguages.isEmpty()) | - |
| 231 | return d->uiLanguages; | - |
| 232 | QString languages = QString::fromLatin1(qgetenv("LANGUAGE")); | - |
| 233 | QStringList lst; | - |
| 234 | if (languages.isEmpty()) | - |
| 235 | lst.append(QString::fromLatin1(d->lc_messages_var)); | - |
| 236 | else | - |
| 237 | lst = languages.split(QLatin1Char(':')); | - |
| 238 | | - |
| 239 | for (int i = 0; i < lst.size(); ++i) { | - |
| 240 | const QString &name = lst.at(i); | - |
| 241 | QString lang, script, cntry; | - |
| 242 | if (qt_splitLocaleName(name, lang, script, cntry)) { | - |
| 243 | if (!cntry.length()) | - |
| 244 | d->uiLanguages.append(lang); | - |
| 245 | else | - |
| 246 | d->uiLanguages.append(lang % QLatin1Char('-') % cntry); | - |
| 247 | } | - |
| 248 | } | - |
| 249 | return d->uiLanguages.isEmpty() ? QVariant() : QVariant(d->uiLanguages); | - |
| 250 | } | - |
| 251 | case StringToStandardQuotation: | - |
| 252 | return lc_messages.quoteString(in.value<QStringRef>()); | - |
| 253 | case StringToAlternateQuotation: | - |
| 254 | return lc_messages.quoteString(in.value<QStringRef>(), QLocale::AlternateQuotation); | - |
| 255 | case ListToSeparatedString: | - |
| 256 | return lc_messages.createSeparatedList(in.toStringList()); | - |
| 257 | case LocaleChanged: | - |
| 258 | Q_ASSERT(false); | - |
| 259 | default: | - |
| 260 | break; | - |
| 261 | } | - |
| 262 | return QVariant(); | - |
| 263 | } | - |
| 264 | #endif // QT_NO_SYSTEMLOCALE | - |
| 265 | | - |
| 266 | QT_END_NAMESPACE | - |
| | |