summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2010-06-05 19:03:52 (GMT)
committerLars Knoll <lars.knoll@nokia.com>2010-06-09 20:21:38 (GMT)
commit17427887a2847acc74c61424e812aca0fea23226 (patch)
tree99bd84d76c6000e127dc5a8571df017711f5dc33 /src
parenta1f7df67056c24b8b23393401953859f6e59417e (diff)
downloadQt-17427887a2847acc74c61424e812aca0fea23226.zip
Qt-17427887a2847acc74c61424e812aca0fea23226.tar.gz
Qt-17427887a2847acc74c61424e812aca0fea23226.tar.bz2
Fix QString::isRightToLeft() to conform with Unicode Bidi algorithm
Rules P2 and P3 demand us to ignore the LRE/LRO/RLE/RLO characters for determining the paragraph direction. Task-Number: Part of QT-3292
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qstring.cpp20
-rw-r--r--src/corelib/tools/qstring.h2
2 files changed, 12 insertions, 10 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 1172a7b..1d5fab3 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -6916,20 +6916,23 @@ void QString::updateProperties() const
p++;
}
- p = d->data;
- d->righttoleft = false;
+ d->righttoleft = isRightToLeft();
+ d->clean = true;
+}
+
+bool QString::isRightToLeft() const
+{
+ ushort *p = d->data;
+ const ushort * const end = p + d->size;
+ bool righttoleft = false;
while (p < end) {
switch(QChar::direction(*p))
{
case QChar::DirL:
- case QChar::DirLRO:
- case QChar::DirLRE:
goto end;
case QChar::DirR:
case QChar::DirAL:
- case QChar::DirRLO:
- case QChar::DirRLE:
- d->righttoleft = true;
+ righttoleft = true;
goto end;
default:
break;
@@ -6937,8 +6940,7 @@ void QString::updateProperties() const
++p;
}
end:
- d->clean = true;
- return;
+ return righttoleft;
}
/*! \fn bool QString::isSimpleText() const
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index a1c4e77..e52f59f 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -590,7 +590,7 @@ public:
#endif
bool isSimpleText() const { if (!d->clean) updateProperties(); return d->simpletext; }
- bool isRightToLeft() const { if (!d->clean) updateProperties(); return d->righttoleft; }
+ bool isRightToLeft() const;
QString(int size, Qt::Initialization);