Qt 4.8
qlocale_mac.mm
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qlocale_p.h"
43 
44 #include "qstringlist.h"
45 #include "qvariant.h"
46 #include "qdatetime.h"
47 
48 #if !defined(QWS) && defined(Q_OS_MAC)
49 # include "private/qcore_mac_p.h"
50 # include <CoreFoundation/CoreFoundation.h>
51 #endif
52 
54 
55 /******************************************************************************
56 ** Wrappers for Mac locale system functions
57 */
58 
60 {
61  static QByteArray lang = 0;
62 #ifdef Q_OS_UNIX
63  lang = qgetenv("LC_ALL");
64  if (lang.isEmpty())
65  lang = qgetenv("LC_NUMERIC");
66  if (lang.isEmpty())
67 #endif
68  lang = qgetenv("LANG");
69  return lang;
70 }
71 
73 {
74  QByteArray result = envVarLocale();
75 
76  QString lang, script, cntry;
77  if (result.isEmpty() || result != "C"
78  && !qt_splitLocaleName(QString::fromLocal8Bit(result), lang, script, cntry)) {
79  QCFType<CFLocaleRef> l = CFLocaleCopyCurrent();
80  CFStringRef locale = CFLocaleGetIdentifier(l);
81  result = QCFString::toQString(locale).toUtf8();
82  }
83  return result;
84 }
85 
86 static QString macMonthName(int month, bool short_format)
87 {
88  month -= 1;
89  if (month < 0 || month > 11)
90  return QString();
91 
93  = CFDateFormatterCreate(0, QCFType<CFLocaleRef>(CFLocaleCopyCurrent()),
94  kCFDateFormatterNoStyle, kCFDateFormatterNoStyle);
96  = static_cast<CFArrayRef>(CFDateFormatterCopyProperty(formatter,
97  short_format ? kCFDateFormatterShortMonthSymbols
98  : kCFDateFormatterMonthSymbols));
99  if (values != 0) {
100  CFStringRef cfstring = static_cast<CFStringRef>(CFArrayGetValueAtIndex(values, month));
101  return QCFString::toQString(cfstring);
102  }
103  return QString();
104 }
105 
106 static QString macDayName(int day, bool short_format)
107 {
108  if (day < 1 || day > 7)
109  return QString();
110 
112  = CFDateFormatterCreate(0, QCFType<CFLocaleRef>(CFLocaleCopyCurrent()),
113  kCFDateFormatterNoStyle, kCFDateFormatterNoStyle);
114  QCFType<CFArrayRef> values = static_cast<CFArrayRef>(CFDateFormatterCopyProperty(formatter,
115  short_format ? kCFDateFormatterShortWeekdaySymbols
116  : kCFDateFormatterWeekdaySymbols));
117  if (values != 0) {
118  CFStringRef cfstring = static_cast<CFStringRef>(CFArrayGetValueAtIndex(values, day % 7));
119  return QCFString::toQString(cfstring);
120  }
121  return QString();
122 }
123 
124 static QString macDateToString(const QDate &date, bool short_format)
125 {
126  CFGregorianDate macGDate;
127  macGDate.year = date.year();
128  macGDate.month = date.month();
129  macGDate.day = date.day();
130  macGDate.hour = 0;
131  macGDate.minute = 0;
132  macGDate.second = 0.0;
133  QCFType<CFDateRef> myDate
134  = CFDateCreate(0, CFGregorianDateGetAbsoluteTime(macGDate,
135  QCFType<CFTimeZoneRef>(CFTimeZoneCopyDefault())));
136  QCFType<CFLocaleRef> mylocale = CFLocaleCopyCurrent();
137  CFDateFormatterStyle style = short_format ? kCFDateFormatterShortStyle : kCFDateFormatterLongStyle;
138  QCFType<CFDateFormatterRef> myFormatter
139  = CFDateFormatterCreate(kCFAllocatorDefault,
140  mylocale, style,
141  kCFDateFormatterNoStyle);
142  return QCFString(CFDateFormatterCreateStringWithDate(0, myFormatter, myDate));
143 }
144 
145 static QString macTimeToString(const QTime &time, bool short_format)
146 {
147  CFGregorianDate macGDate;
148  // Assume this is local time and the current date
149  QDate dt = QDate::currentDate();
150  macGDate.year = dt.year();
151  macGDate.month = dt.month();
152  macGDate.day = dt.day();
153  macGDate.hour = time.hour();
154  macGDate.minute = time.minute();
155  macGDate.second = time.second();
156  QCFType<CFDateRef> myDate
157  = CFDateCreate(0, CFGregorianDateGetAbsoluteTime(macGDate,
158  QCFType<CFTimeZoneRef>(CFTimeZoneCopyDefault())));
159 
160  QCFType<CFLocaleRef> mylocale = CFLocaleCopyCurrent();
161  CFDateFormatterStyle style = short_format ? kCFDateFormatterShortStyle : kCFDateFormatterLongStyle;
162  QCFType<CFDateFormatterRef> myFormatter = CFDateFormatterCreate(kCFAllocatorDefault,
163  mylocale,
164  kCFDateFormatterNoStyle,
165  style);
166  return QCFString(CFDateFormatterCreateStringWithDate(0, myFormatter, myDate));
167 }
168 
169 // Mac uses the Unicode CLDR format codes
170 // http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
171 // See also qtbase/util/local_database/dateconverter.py
172 // Makes the assumption that input formats are always well formed and consecutive letters
173 // never exceed the maximum for the format code.
174 static QString macToQtFormat(const QString &sys_fmt)
175 {
176  QString result;
177  int i = 0;
178 
179  while (i < sys_fmt.size()) {
180  if (sys_fmt.at(i).unicode() == '\'') {
181  QString text = qt_readEscapedFormatString(sys_fmt, &i);
182  if (text == QLatin1String("'"))
183  result += QLatin1String("''");
184  else
185  result += QLatin1Char('\'') + text + QLatin1Char('\'');
186  continue;
187  }
188 
189  QChar c = sys_fmt.at(i);
190  int repeat = qt_repeatCount(sys_fmt, i);
191 
192  switch (c.unicode()) {
193  // Qt does not support the following options
194  case 'G': // Era (1..5): 4 = long, 1..3 = short, 5 = narrow
195  case 'Y': // Year of Week (1..n): 1..n = padded number
196  case 'U': // Cyclic Year Name (1..5): 4 = long, 1..3 = short, 5 = narrow
197  case 'Q': // Quarter (1..4): 4 = long, 3 = short, 1..2 = padded number
198  case 'q': // Standalone Quarter (1..4): 4 = long, 3 = short, 1..2 = padded number
199  case 'w': // Week of Year (1..2): 1..2 = padded number
200  case 'W': // Week of Month (1): 1 = number
201  case 'D': // Day of Year (1..3): 1..3 = padded number
202  case 'F': // Day of Week in Month (1): 1 = number
203  case 'g': // Modified Julian Day (1..n): 1..n = padded number
204  case 'A': // Milliseconds in Day (1..n): 1..n = padded number
205  break;
206 
207  case 'y': // Year (1..n): 2 = short year, 1 & 3..n = padded number
208  case 'u': // Extended Year (1..n): 2 = short year, 1 & 3..n = padded number
209  // Qt only supports long (4) or short (2) year, use long for all others
210  if (repeat == 2)
211  result += QLatin1String("yy");
212  else
213  result += QLatin1String("yyyy");
214  break;
215  case 'M': // Month (1..5): 4 = long, 3 = short, 1..2 = number, 5 = narrow
216  case 'L': // Standalone Month (1..5): 4 = long, 3 = short, 1..2 = number, 5 = narrow
217  // Qt only supports long, short and number, use short for narrow
218  if (repeat == 5)
219  result += QLatin1String("MMM");
220  else
221  result += QString(repeat, QLatin1Char('M'));
222  break;
223  case 'd': // Day of Month (1..2): 1..2 padded number
224  result += QString(repeat, c);
225  break;
226  case 'E': // Day of Week (1..6): 4 = long, 1..3 = short, 5..6 = narrow
227  // Qt only supports long, short and padded number, use short for narrow
228  if (repeat == 4)
229  result += QLatin1String("dddd");
230  else
231  result += QLatin1String("ddd");
232  break;
233  case 'e': // Local Day of Week (1..6): 4 = long, 3 = short, 5..6 = narrow, 1..2 padded number
234  case 'c': // Standalone Local Day of Week (1..6): 4 = long, 3 = short, 5..6 = narrow, 1..2 padded number
235  // Qt only supports long, short and padded number, use short for narrow
236  if (repeat >= 5)
237  result += QLatin1String("ddd");
238  else
239  result += QString(repeat, QLatin1Char('d'));
240  break;
241  case 'a': // AM/PM (1): 1 = short
242  // Translate to Qt uppercase AM/PM
243  result += QLatin1String("AP");
244  break;
245  case 'h': // Hour [1..12] (1..2): 1..2 = padded number
246  case 'K': // Hour [0..11] (1..2): 1..2 = padded number
247  case 'j': // Local Hour [12 or 24] (1..2): 1..2 = padded number
248  // Qt h is local hour
249  result += QString(repeat, QLatin1Char('h'));
250  break;
251  case 'H': // Hour [0..23] (1..2): 1..2 = padded number
252  case 'k': // Hour [1..24] (1..2): 1..2 = padded number
253  // Qt H is 0..23 hour
254  result += QString(repeat, QLatin1Char('H'));
255  break;
256  case 'm': // Minutes (1..2): 1..2 = padded number
257  case 's': // Seconds (1..2): 1..2 = padded number
258  result += QString(repeat, c);
259  break;
260  case 'S': // Fractional second (1..n): 1..n = truncates to decimal places
261  // Qt uses msecs either unpadded or padded to 3 places
262  if (repeat < 3)
263  result += QLatin1Char('z');
264  else
265  result += QLatin1String("zzz");
266  break;
267  case 'z': // Time Zone (1..4)
268  case 'Z': // Time Zone (1..5)
269  case 'O': // Time Zone (1, 4)
270  case 'v': // Time Zone (1, 4)
271  case 'V': // Time Zone (1..4)
272  case 'X': // Time Zone (1..5)
273  case 'x': // Time Zone (1..5)
274  result += QLatin1Char('t');
275  break;
276  default:
277  // a..z and A..Z are reserved for format codes, so any occurrence of these not
278  // already processed are not known and so unsupported formats to be ignored.
279  // All other chars are allowed as literals.
280  if (c < QLatin1Char('A') || c > QLatin1Char('z') ||
281  (c > QLatin1Char('Z') && c < QLatin1Char('a'))) {
282  result += QString(repeat, c);
283  }
284  break;
285  }
286 
287  i += repeat;
288  }
289 
290  return result;
291 }
292 
293 QString getMacDateFormat(CFDateFormatterStyle style)
294 {
295  QCFType<CFLocaleRef> l = CFLocaleCopyCurrent();
296  QCFType<CFDateFormatterRef> formatter = CFDateFormatterCreate(kCFAllocatorDefault,
297  l, style, kCFDateFormatterNoStyle);
298  return macToQtFormat(QCFString::toQString(CFDateFormatterGetFormat(formatter)));
299 }
300 
301 static QString getMacTimeFormat(CFDateFormatterStyle style)
302 {
303  QCFType<CFLocaleRef> l = CFLocaleCopyCurrent();
304  QCFType<CFDateFormatterRef> formatter = CFDateFormatterCreate(kCFAllocatorDefault,
305  l, kCFDateFormatterNoStyle, style);
306  return macToQtFormat(QCFString::toQString(CFDateFormatterGetFormat(formatter)));
307 }
308 
310 {
311  QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent();
312  CFTypeRef value = CFLocaleGetValue(locale, key);
313  return QCFString::toQString(CFStringRef(static_cast<CFTypeRef>(value)));
314 }
315 
317 {
318  QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent();
319  CFStringRef system = static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleMeasurementSystem));
320  if (QCFString::toQString(system) == QLatin1String("Metric")) {
321  return QLocale::MetricSystem;
322  } else {
324  }
325 }
326 
327 
329 {
330  QCFType<CFCalendarRef> calendar = CFCalendarCopyCurrent();
331  quint8 day = static_cast<quint8>(CFCalendarGetFirstWeekday(calendar))-1;
332  if (day == 0)
333  day = 7;
334  return day;
335 }
336 
338 {
339  QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent();
340  switch (format) {
342  return QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleCurrencyCode)));
344  return QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleCurrencySymbol)));
346  CFStringRef code = static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleCurrencyCode));
347  QCFType<CFStringRef> value = CFLocaleCopyDisplayNameForPropertyValue(locale, kCFLocaleCurrencyCode, code);
348  return QCFString::toQString(value);
349  }
350  default:
351  break;
352  }
353  return QString();
354 }
355 
356 #ifndef QT_NO_SYSTEMLOCALE
358 {
359  QCFType<CFNumberRef> value;
360  switch (arg.value.type()) {
361  case QVariant::Int:
362  case QVariant::UInt: {
363  int v = arg.value.toInt();
364  value = CFNumberCreate(NULL, kCFNumberIntType, &v);
365  break;
366  }
367  case QVariant::Double: {
368  double v = arg.value.toDouble();
369  value = CFNumberCreate(NULL, kCFNumberDoubleType, &v);
370  break;
371  }
372  case QVariant::LongLong:
373  case QVariant::ULongLong: {
374  qint64 v = arg.value.toLongLong();
375  value = CFNumberCreate(NULL, kCFNumberLongLongType, &v);
376  break;
377  }
378  default:
379  return QString();
380  }
381 
382  QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent();
383  QCFType<CFNumberFormatterRef> currencyFormatter =
384  CFNumberFormatterCreate(NULL, locale, kCFNumberFormatterCurrencyStyle);
385  if (!arg.symbol.isEmpty()) {
386  CFNumberFormatterSetProperty(currencyFormatter, kCFNumberFormatterCurrencySymbol,
388  }
389  QCFType<CFStringRef> result = CFNumberFormatterCreateStringWithNumber(NULL, currencyFormatter, value);
390  return QCFString::toQString(result);
391 }
392 
394 {
395 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 && !defined(Q_OS_IOS)
397  return QVariant();
398 
399  QString begin, end;
400  QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent();
401  switch (type) {
403  begin = QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleQuotationBeginDelimiterKey)));
404  end = QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleQuotationEndDelimiterKey)));
405  return QString(begin % str % end);
407  begin = QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleAlternateQuotationBeginDelimiterKey)));
408  end = QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleAlternateQuotationEndDelimiterKey)));
409  return QString(begin % str % end);
410  default:
411  break;
412  }
413 #endif
414  return QVariant();
415 }
416 #endif //QT_NO_SYSTEMLOCALE
417 
418 #ifndef QT_NO_SYSTEMLOCALE
419 
421 {
422  return QLocale(QString::fromUtf8(getMacLocaleName().constData()));
423 }
424 
426 {
427  switch(type) {
428 // case Name:
429 // return getMacLocaleName();
430  case DecimalPoint: {
431  QString value = getCFLocaleValue(kCFLocaleDecimalSeparator);
432  return value.isEmpty() ? QVariant() : value;
433  }
434  case GroupSeparator: {
435  QString value = getCFLocaleValue(kCFLocaleGroupingSeparator);
436  return value.isEmpty() ? QVariant() : value;
437  }
438  case DateFormatLong:
439  case DateFormatShort:
441  ? kCFDateFormatterShortStyle
442  : kCFDateFormatterLongStyle);
443  case TimeFormatLong:
444  case TimeFormatShort:
446  ? kCFDateFormatterShortStyle
447  : kCFDateFormatterLongStyle);
448  case DayNameLong:
449  case DayNameShort:
450  return macDayName(in.toInt(), (type == DayNameShort));
451  case MonthNameLong:
452  case MonthNameShort:
455  return macMonthName(in.toInt(), (type == MonthNameShort || type == StandaloneMonthNameShort));
456  case DateToStringShort:
457  case DateToStringLong:
458  return macDateToString(in.toDate(), (type == DateToStringShort));
459  case TimeToStringShort:
460  case TimeToStringLong:
461  return macTimeToString(in.toTime(), (type == TimeToStringShort));
462 
463  case NegativeSign:
464  case PositiveSign:
465  case ZeroDigit:
466  break;
467 
468  case MeasurementSystem:
469  return QVariant(static_cast<int>(macMeasurementSystem()));
470 
471  case AMText:
472  case PMText: {
473  QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent();
474  QCFType<CFDateFormatterRef> formatter = CFDateFormatterCreate(NULL, locale, kCFDateFormatterLongStyle, kCFDateFormatterLongStyle);
475  QCFType<CFStringRef> value = static_cast<CFStringRef>(CFDateFormatterCopyProperty(formatter,
476  (type == AMText ? kCFDateFormatterAMSymbol : kCFDateFormatterPMSymbol)));
477  return QCFString::toQString(value);
478  }
479  case FirstDayOfWeek:
480  return QVariant(macFirstDayOfWeek());
481  case CurrencySymbol:
483  case CurrencyToString:
485  case UILanguages: {
486  QCFType<CFPropertyListRef> languages = CFPreferencesCopyValue(
487  CFSTR("AppleLanguages"),
488  kCFPreferencesAnyApplication,
489  kCFPreferencesCurrentUser,
490  kCFPreferencesAnyHost);
491  QStringList result;
492  if (!languages)
493  return QVariant(result);
494 
495  CFTypeID typeId = CFGetTypeID(languages);
496  if (typeId == CFArrayGetTypeID()) {
497  const int cnt = CFArrayGetCount(languages.as<CFArrayRef>());
498  result.reserve(cnt);
499  for (int i = 0; i < cnt; ++i) {
500  const QString lang = QCFString::toQString(
501  static_cast<CFStringRef>(CFArrayGetValueAtIndex(languages.as<CFArrayRef>(), i)));
502  result.append(lang);
503  }
504  } else if (typeId == CFStringGetTypeID()) {
505  result = QStringList(QCFString::toQString(languages.as<CFStringRef>()));
506  } else {
507  qWarning("QLocale::uiLanguages(): CFPreferencesCopyValue returned unhandled type \"%s\"; please report to http://bugreports.qt-project.org",
508  qPrintable(QCFString::toQString(CFCopyTypeIDDescription(typeId))));
509  }
510  return QVariant(result);
511  }
514  return macQuoteString(type, in.value<QStringRef>());
515  default:
516  break;
517  }
518  return QVariant();
519 }
520 
521 #endif // QT_NO_SYSTEMLOCALE
522 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
const struct __CFString * CFStringRef
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
int type
Definition: qmetatype.cpp:239
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
static QLocale::MeasurementSystem macMeasurementSystem()
Definition: qlocale_mac.mm:316
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int month() const
Returns the number corresponding to the month of this date, using the following convention: ...
Definition: qdatetime.cpp:382
static QString getCFLocaleValue(CFStringRef key)
Definition: qlocale_mac.mm:309
static QByteArray envVarLocale()
Definition: qlocale_mac.mm:59
static CFStringRef toCFStringRef(const QString &str)
Definition: qcore_mac.cpp:69
static QString toQString(CFStringRef cfstr)
Definition: qcore_mac.cpp:47
static QString macTimeToString(const QTime &time, bool short_format)
Definition: qlocale_mac.mm:145
int day() const
Returns the day of the month (1 to 31) of this date.
Definition: qdatetime.cpp:395
The QDate class provides date functions.
Definition: qdatetime.h:55
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
X as() const
Definition: qcore_mac_p.h:128
bool qt_splitLocaleName(const QString &name, QString &lang, QString &script, QString &cntry)
Definition: qlocale.cpp:302
unsigned char quint8
Definition: qglobal.h:934
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static quint8 macFirstDayOfWeek()
Definition: qlocale_mac.mm:328
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
static QVariant macQuoteString(QSystemLocale::QueryType type, const QStringRef &str)
Definition: qlocale_mac.mm:393
static QString macDayName(int day, bool short_format)
Definition: qlocale_mac.mm:106
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int qt_repeatCount(const QString &s, int i)
Definition: qlocale.cpp:421
The QTime class provides clock time functions.
Definition: qdatetime.h:148
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
qlonglong toLongLong(bool *ok=0) const
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0.
Definition: qvariant.cpp:2659
static QString macCurrencySymbol(QLocale::CurrencySymbolFormat format)
Definition: qlocale_mac.mm:337
static QString getMacTimeFormat(CFDateFormatterStyle style)
Definition: qlocale_mac.mm:301
QString qt_readEscapedFormatString(const QString &format, int *idx)
Definition: qlocale.cpp:387
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
static QDate currentDate()
Returns the current date, as reported by the system clock.
Definition: qdatetime.cpp:3115
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString getMacDateFormat(CFDateFormatterStyle style)
Definition: qlocale_mac.mm:293
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
Q_CORE_EXPORT void qWarning(const char *,...)
int second() const
Returns the second part (0 to 59) of the time.
Definition: qdatetime.cpp:1600
__int64 qint64
Definition: qglobal.h:942
int minute() const
Returns the minute part (0 to 59) of the time.
Definition: qdatetime.cpp:1589
quint16 values[128]
CurrencySymbolFormat
Specifies the format of the currency symbol.
Definition: qlocale.h:666
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
const void * CFTypeRef
static QString macFormatCurrency(const QSystemLocale::CurrencyToStringArgument &arg)
Definition: qlocale_mac.mm:357
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
static QString macMonthName(int month, bool short_format)
Definition: qlocale_mac.mm:86
static QString macDateToString(const QDate &date, bool short_format)
Definition: qlocale_mac.mm:124
int key
QFactoryLoader * l
virtual QVariant query(QueryType type, QVariant in) const
MeasurementSystem
Definition: qlocale.h:657
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
virtual QLocale fallbackLocale() const
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646
static QByteArray getMacLocaleName()
Definition: qlocale_mac.mm:72
int year() const
Returns the year of this date.
Definition: qdatetime.cpp:353
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
static QString macToQtFormat(const QString &sys_fmt)
Definition: qlocale_mac.mm:174
static const KeyPair *const end
const struct __CFArray * CFArrayRef
#define qPrintable(string)
Definition: qglobal.h:1750
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
void reserve(int size)
Reserve space for alloc elements.
Definition: qlist.h:496
#define text
Definition: qobjectdefs.h:80
int hour() const
Returns the hour part (0 to 23) of the time.
Definition: qdatetime.cpp:1578