48 #if !defined(QWS) && defined(Q_OS_MAC) 49 # include "private/qcore_mac_p.h" 50 # include <CoreFoundation/CoreFoundation.h> 77 if (result.
isEmpty() || result !=
"C" 89 if (month < 0 || month > 11)
94 kCFDateFormatterNoStyle, kCFDateFormatterNoStyle);
96 =
static_cast<CFArrayRef>(CFDateFormatterCopyProperty(formatter,
97 short_format ? kCFDateFormatterShortMonthSymbols
98 : kCFDateFormatterMonthSymbols));
108 if (day < 1 || day > 7)
113 kCFDateFormatterNoStyle, kCFDateFormatterNoStyle);
115 short_format ? kCFDateFormatterShortWeekdaySymbols
116 : kCFDateFormatterWeekdaySymbols));
126 CFGregorianDate macGDate;
127 macGDate.year = date.
year();
128 macGDate.month = date.
month();
129 macGDate.day = date.
day();
132 macGDate.second = 0.0;
134 = CFDateCreate(0, CFGregorianDateGetAbsoluteTime(macGDate,
137 CFDateFormatterStyle style = short_format ? kCFDateFormatterShortStyle : kCFDateFormatterLongStyle;
139 = CFDateFormatterCreate(kCFAllocatorDefault,
141 kCFDateFormatterNoStyle);
142 return QCFString(CFDateFormatterCreateStringWithDate(0, myFormatter, myDate));
147 CFGregorianDate macGDate;
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();
157 = CFDateCreate(0, CFGregorianDateGetAbsoluteTime(macGDate,
161 CFDateFormatterStyle style = short_format ? kCFDateFormatterShortStyle : kCFDateFormatterLongStyle;
164 kCFDateFormatterNoStyle,
166 return QCFString(CFDateFormatterCreateStringWithDate(0, myFormatter, myDate));
179 while (i < sys_fmt.
size()) {
297 l, style, kCFDateFormatterNoStyle);
305 l, kCFDateFormatterNoStyle, style);
312 CFTypeRef value = CFLocaleGetValue(locale, key);
331 quint8 day =
static_cast<quint8>(CFCalendarGetFirstWeekday(calendar))-1;
342 return QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleCurrencyCode)));
344 return QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleCurrencySymbol)));
347 QCFType<CFStringRef> value = CFLocaleCopyDisplayNameForPropertyValue(locale, kCFLocaleCurrencyCode, code);
356 #ifndef QT_NO_SYSTEMLOCALE 364 value = CFNumberCreate(NULL, kCFNumberIntType, &v);
369 value = CFNumberCreate(NULL, kCFNumberDoubleType, &v);
375 value = CFNumberCreate(NULL, kCFNumberLongLongType, &v);
384 CFNumberFormatterCreate(NULL, locale, kCFNumberFormatterCurrencyStyle);
386 CFNumberFormatterSetProperty(currencyFormatter, kCFNumberFormatterCurrencySymbol,
389 QCFType<CFStringRef> result = CFNumberFormatterCreateStringWithNumber(NULL, currencyFormatter, value);
395 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 && !defined(Q_OS_IOS) 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);
416 #endif //QT_NO_SYSTEMLOCALE 418 #ifndef QT_NO_SYSTEMLOCALE 441 ? kCFDateFormatterShortStyle
442 : kCFDateFormatterLongStyle);
446 ? kCFDateFormatterShortStyle
447 : kCFDateFormatterLongStyle);
476 (
type ==
AMText ? kCFDateFormatterAMSymbol : kCFDateFormatterPMSymbol)));
487 CFSTR(
"AppleLanguages"),
488 kCFPreferencesAnyApplication,
489 kCFPreferencesCurrentUser,
490 kCFPreferencesAnyHost);
495 CFTypeID typeId = CFGetTypeID(languages);
496 if (typeId == CFArrayGetTypeID()) {
497 const int cnt = CFArrayGetCount(languages.
as<
CFArrayRef>());
499 for (
int i = 0; i < cnt; ++i) {
501 static_cast<CFStringRef>(CFArrayGetValueAtIndex(languages.
as<
CFArrayRef>(), i)));
504 }
else if (typeId == CFStringGetTypeID()) {
507 qWarning(
"QLocale::uiLanguages(): CFPreferencesCopyValue returned unhandled type \"%s\"; please report to http://bugreports.qt-project.org",
521 #endif // QT_NO_SYSTEMLOCALE The QVariant class acts like a union for the most common Qt data types.
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.
#define QT_END_NAMESPACE
This macro expands to.
static QLocale::MeasurementSystem macMeasurementSystem()
const QChar at(int i) const
Returns the character at the given index position in the string.
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
The QByteArray class provides an array of bytes.
int month() const
Returns the number corresponding to the month of this date, using the following convention: ...
static QString getCFLocaleValue(CFStringRef key)
static QByteArray envVarLocale()
static CFStringRef toCFStringRef(const QString &str)
static QString toQString(CFStringRef cfstr)
static QString macTimeToString(const QTime &time, bool short_format)
int day() const
Returns the day of the month (1 to 31) of this date.
The QDate class provides date functions.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool qt_splitLocaleName(const QString &name, QString &lang, QString &script, QString &cntry)
The QString class provides a Unicode character string.
The QChar class provides a 16-bit Unicode character.
static quint8 macFirstDayOfWeek()
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
static QVariant macQuoteString(QSystemLocale::QueryType type, const QStringRef &str)
static QString macDayName(int day, bool short_format)
void append(const T &t)
Inserts value at the end of the list.
int qt_repeatCount(const QString &s, int i)
The QTime class provides clock time functions.
#define QT_BEGIN_NAMESPACE
This macro expands to.
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.
static QString macCurrencySymbol(QLocale::CurrencySymbolFormat format)
static QString getMacTimeFormat(CFDateFormatterStyle style)
QString qt_readEscapedFormatString(const QString &format, int *idx)
int size() const
Returns the number of characters in this string.
static QDate currentDate()
Returns the current date, as reported by the system clock.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString getMacDateFormat(CFDateFormatterStyle style)
The QStringList class provides a list of strings.
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Q_CORE_EXPORT void qWarning(const char *,...)
int second() const
Returns the second part (0 to 59) of the time.
int minute() const
Returns the minute part (0 to 59) of the time.
CurrencySymbolFormat
Specifies the format of the currency symbol.
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
The QStringRef class provides a thin wrapper around QString substrings.
static QString macFormatCurrency(const QSystemLocale::CurrencyToStringArgument &arg)
Type type() const
Returns the storage type of the value stored in the variant.
static QString macMonthName(int month, bool short_format)
static QString macDateToString(const QDate &date, bool short_format)
virtual QVariant query(QueryType type, QVariant in) const
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
virtual QLocale fallbackLocale() const
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
static QByteArray getMacLocaleName()
int year() const
Returns the year of this date.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
static QString macToQtFormat(const QString &sys_fmt)
static const KeyPair *const end
const struct __CFArray * CFArrayRef
#define qPrintable(string)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
void reserve(int size)
Reserve space for alloc elements.
int hour() const
Returns the hour part (0 to 23) of the time.