summaryrefslogtreecommitdiffstats
path: root/src/tools/uic/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/uic/utils.h')
-rw-r--r--src/tools/uic/utils.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/tools/uic/utils.h b/src/tools/uic/utils.h
index c864305891..c6dbe548cb 100644
--- a/src/tools/uic/utils.h
+++ b/src/tools/uic/utils.h
@@ -55,18 +55,21 @@ inline bool toBool(const QString &str)
inline QString toString(const DomString *str)
{ return str ? str->text() : QString(); }
-inline QString fixString(const QString &str, const QString &indent)
+inline QString fixString(const QString &str, const QString &indent, bool *isUtf8Ret=0)
{
QString cursegment;
QStringList result;
const QByteArray utf8 = str.toUtf8();
const int utf8Length = utf8.length();
+ bool isUtf8 = false;
+
for (int i = 0; i < utf8Length; ++i) {
const uchar cbyte = utf8.at(i);
if (cbyte >= 0x80) {
cursegment += QLatin1Char('\\');
cursegment += QString::number(cbyte, 8);
+ isUtf8 = true;
} else {
switch(cbyte) {
case '\\':
@@ -100,9 +103,21 @@ inline QString fixString(const QString &str, const QString &indent)
QString rc(QLatin1Char('"'));
rc += result.join(joinstr);
rc += QLatin1Char('"');
+ if (isUtf8Ret)
+ *isUtf8Ret = isUtf8;
return rc;
}
+inline QString writeString(const QString &s, const QString &indent)
+{
+ bool isUtf8 = false;
+ const QString ret = fixString(s, indent, &isUtf8);
+ if (isUtf8)
+ return QLatin1String("QString::fromUtf8(") + ret + QLatin1Char(')');
+ else
+ return QLatin1String("QStringLiteral(") + ret + QLatin1Char(')');
+}
+
inline QHash<QString, DomProperty *> propertyMap(const QList<DomProperty *> &properties)
{
QHash<QString, DomProperty *> map;