summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextengine.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2010-06-05 21:23:42 (GMT)
committerLars Knoll <lars.knoll@nokia.com>2010-06-09 22:08:16 (GMT)
commit726607baf707318de6f685573553d22df4966f61 (patch)
tree16f7d7a64661920f52a46b3afa31eefab78b82bf /src/gui/text/qtextengine.cpp
parentb69e592b2b8fb3eae75c112e491e3ed90fc0248a (diff)
downloadQt-726607baf707318de6f685573553d22df4966f61.zip
Qt-726607baf707318de6f685573553d22df4966f61.tar.gz
Qt-726607baf707318de6f685573553d22df4966f61.tar.bz2
consistent handling of directionality in QTextLayout
Make sure we use the same method to determine RTL/LTR for the layout everywhere. Task-number: Part of QT-3292 Reviewed-by: Simon Hausmann
Diffstat (limited to 'src/gui/text/qtextengine.cpp')
-rw-r--r--src/gui/text/qtextengine.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 191508c..ac1fffd 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1405,17 +1405,7 @@ void QTextEngine::itemize() const
bool ignore = ignoreBidi;
#endif
- bool rtl = false;
- switch (option.textDirection()) {
- case Qt::LeftToRight:
- break;
- case Qt::RightToLeft:
- rtl = true;
- break;
- case Qt::LayoutDirectionAuto:
- rtl = layoutData->string.isRightToLeft();
- break;
- }
+ bool rtl = isRightToLeft();
if (!ignore && !rtl) {
ignore = true;
@@ -1528,6 +1518,23 @@ void QTextEngine::itemize() const
resolveAdditionalFormats();
}
+bool QTextEngine::isRightToLeft() const
+{
+ switch (option.textDirection()) {
+ case Qt::LeftToRight:
+ return false;
+ case Qt::RightToLeft:
+ return true;
+ default:
+ break;
+ }
+ // this places the cursor in the right position depending on the keyboard layout
+ if (layoutData->string.isEmpty())
+ return QApplication::keyboardInputDirection() == Qt::RightToLeft;
+ return layoutData->string.isRightToLeft();
+}
+
+
int QTextEngine::findItem(int strPos) const
{
itemize();
@@ -2524,7 +2531,7 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const
QList<QTextOption::Tab> tabArray = option.tabs();
if (!tabArray.isEmpty()) {
- if (option.textDirection() == Qt::RightToLeft) { // rebase the tabArray positions.
+ if (isRightToLeft()) { // rebase the tabArray positions.
QList<QTextOption::Tab> newTabs;
QList<QTextOption::Tab>::Iterator iter = tabArray.begin();
while(iter != tabArray.end()) {