summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@nokia.com>2011-02-25 14:42:51 (GMT)
committerZeno Albisser <zeno.albisser@nokia.com>2011-02-25 15:05:50 (GMT)
commit08868df5e94a5b89d9f8ce904e97b43a48313fc1 (patch)
treee698bd1615ceab3456a17224161fa9965c9c2392 /src/corelib
parent4b09e9cbfce4df05f187e6f399738219d3f2853e (diff)
downloadQt-08868df5e94a5b89d9f8ce904e97b43a48313fc1.zip
Qt-08868df5e94a5b89d9f8ce904e97b43a48313fc1.tar.gz
Qt-08868df5e94a5b89d9f8ce904e97b43a48313fc1.tar.bz2
fixed QLocale::quoteString() to allow for QSystemLocale implementation
Reviewed-by: Denis Dzyubenko Task-number: QTBUG-17096
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qlocale.cpp15
-rw-r--r--src/corelib/tools/qlocale.h4
-rw-r--r--src/corelib/tools/qlocale.qdoc4
-rw-r--r--src/corelib/tools/qlocale_mac.mm29
-rw-r--r--src/corelib/tools/qlocale_p.h3
-rw-r--r--src/corelib/tools/qlocale_unix.cpp8
6 files changed, 34 insertions, 29 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index e10ca8a..5027d00 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -651,7 +651,6 @@ QLocale::NumberOptions QLocale::numberOptions() const
*/
QString QLocale::quoteString(const QString &str, QuotationStyle qs) const
{
-
return quoteString(&str, qs);
}
@@ -664,14 +663,18 @@ QString QLocale::quoteString(const QStringRef &str, QuotationStyle qs) const
{
#ifndef QT_NO_SYSTEMLOCALE
if (d() == systemPrivate()) {
- QVariant quotationBegin = systemLocale()->query(QSystemLocale::QuotationBegin, QVariant(qs));
- QVariant quotationEnd = systemLocale()->query(QSystemLocale::QuotationEnd, QVariant(qs));
- if (!quotationBegin.isNull() && !quotationEnd.isNull())
- return quotationBegin.toString() % str % quotationEnd.toString();
+ QVariant res;
+ if (qs == QLocale::StandardQuotation)
+ res = systemLocale()->query(QSystemLocale::StringToStandardQuotation, QVariant::fromValue(str));
+ else
+ res = systemLocale()->query(QSystemLocale::StringToAlternateQuotation, QVariant::fromValue(str));
+
+ if (!res.isNull())
+ return res.toString();
}
#endif
- if (qs == StandardQuotation)
+ if (qs == QLocale::StandardQuotation)
return QChar(d()->m_quotation_start) % str % QChar(d()->m_quotation_end);
else
return QChar(d()->m_alternate_quotation_start) % str % QChar(d()->m_alternate_quotation_end);
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h
index a733732..7900c57 100644
--- a/src/corelib/tools/qlocale.h
+++ b/src/corelib/tools/qlocale.h
@@ -101,8 +101,8 @@ public:
CurrencySymbol, // QString in: format
CurrencyToString, // QString in: qlonglong, qulonglong or double
UILanguages, // QStringList
- QuotationBegin, // QString in: StandardQuotation or AlternateQuotation
- QuotationEnd // QString in: StandardQuotation or AlternateQuotation
+ StringToStandardQuotation, // QString in: QStringRef to quote
+ StringToAlternateQuotation // QString in: QStringRef to quote
};
virtual QVariant query(QueryType type, QVariant in) const;
virtual QLocale fallbackLocale() const;
diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc
index 5154324..20f546d 100644
--- a/src/corelib/tools/qlocale.qdoc
+++ b/src/corelib/tools/qlocale.qdoc
@@ -710,8 +710,8 @@
\value CurrencySymbol a string that represents a currency in a format QLocale::CurrencyFormat.
\value CurrencyToString a localized string representation of a number with a currency symbol.
\value UILanguages a list of strings representing locale names that could be used for UI translation.
- \value QuotationBegin a QString specifying the start of a quotation. the in variant contains a QLocale::QuotationStyle
- \value QuotationEnd a QString specifying the end of a quotation. the in variant contains a QLocale::QuotationStyle
+ \value StringToStandardQuotation a QString containing a quoted version of the string ref stored in the in variant using standard quotes.
+ \value StringToAlternateQuotation a QString containing a quoted version of the string ref stored in the in variant using alternate quotes.
\value WeekendStart a Qt::DayOfWeek enum specifying the first day of the weekend
\value WeekendEnd a Qt::DayOfWeek enum specifying the last day of the weekend
*/
diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm
index b8420e0..6c4829b 100644
--- a/src/corelib/tools/qlocale_mac.mm
+++ b/src/corelib/tools/qlocale_mac.mm
@@ -340,26 +340,23 @@ static QString macFormatCurrency(const QVariant &in)
}
#ifndef QT_NO_SYSTEMLOCALE
-static QVariant macQuotationSymbol(QSystemLocale::QueryType type, const QVariant &in)
+static QVariant macQuoteString(QSystemLocale::QueryType type, const QStringRef &str)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_6)
return QVariant();
+ QString begin, end;
QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent();
switch (type) {
- case QSystemLocale::QuotationBegin:
- if (in.toInt() == QLocale::StandardQuotation)
- return QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleQuotationBeginDelimiterKey)));
- else
- return QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleAlternateQuotationBeginDelimiterKey)));
- break;
- case QSystemLocale::QuotationEnd:
- if (in.toInt() == QLocale::StandardQuotation)
- return QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleQuotationEndDelimiterKey)));
- else
- return QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleAlternateQuotationEndDelimiterKey)));
- break;
+ case QSystemLocale::StringToStandardQuotation:
+ begin = QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleQuotationBeginDelimiterKey)));
+ end = QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleQuotationEndDelimiterKey)));
+ return QString(begin % str % end);
+ case QSystemLocale::StringToAlternateQuotation:
+ begin = QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleAlternateQuotationBeginDelimiterKey)));
+ end = QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleAlternateQuotationEndDelimiterKey)));
+ return QString(begin % str % end);
default:
break;
}
@@ -478,9 +475,9 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
}
return QVariant(result);
}
- case QuotationBegin:
- case QuotationEnd:
- return macQuotationSymbol(type,in);
+ case StringToStandardQuotation:
+ case StringToAlternateQuotation:
+ return macQuoteString(type, in.value<QStringRef>());
default:
break;
}
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index 68c66c1..636cc1d 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -55,6 +55,7 @@
#include "QtCore/qstring.h"
#include "QtCore/qvarlengtharray.h"
+#include "QtCore/qmetatype.h"
#include "qlocale.h"
@@ -64,6 +65,8 @@ class CEnvironmentChangeNotifier;
QT_BEGIN_NAMESPACE
+Q_DECLARE_METATYPE(QStringRef)
+
struct Q_CORE_EXPORT QLocalePrivate
{
public:
diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp
index 6faaf19..74c8c85 100644
--- a/src/corelib/tools/qlocale_unix.cpp
+++ b/src/corelib/tools/qlocale_unix.cpp
@@ -113,6 +113,7 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
const QLocale &lc_numeric = d->lc_numeric;
const QLocale &lc_time = d->lc_time;
const QLocale &lc_monetary = d->lc_monetary;
+ const QLocale &lc_messages = d->lc_messages;
switch (type) {
case DecimalPoint:
@@ -215,9 +216,10 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
}
return QVariant();
}
- case QuotationBegin:
- case QuotationEnd:
- break; // TODO
+ case StringToStandardQuotation:
+ return lc_messages.quoteString(in.value<QStringRef>());
+ case StringToAlternateQuotation:
+ return lc_messages.quoteString(in.value<QStringRef>(), QLocale::AlternateQuotation);
default:
break;
}