remove dependency to QStyle::visualAlignment
authorLars Knoll <lars.knoll@nokia.com>
Wed, 4 May 2011 09:51:33 +0000 (11:51 +0200)
committerLars Knoll <lars.knoll@nokia.com>
Wed, 4 May 2011 09:51:33 +0000 (11:51 +0200)
The current position of the code in QGuiAppPrivate
is a bit messy, but we can later on consider
consolidating some of this in some helper
namespace.

src/gui/kernel/qapplication.cpp
src/gui/kernel/qguiapplication_p.h
src/gui/painting/qpainter.cpp
src/gui/styles/qstyle.cpp
src/gui/text/qtextdocumentlayout.cpp
src/gui/text/qtextlayout.cpp

index 6e3f327..08a6f54 100644 (file)
@@ -3547,7 +3547,7 @@ int QApplication::startDragDistance()
 #ifdef QT3_SUPPORT
 Qt::Alignment QApplication::horizontalAlignment(Qt::Alignment align)
 {
-    return QStyle::visualAlignment(layoutDirection(), align);
+    return QGuiApplicationPrivate::visualAlignment(layoutDirection(), align);
 }
 #endif
 
index 23b3a4b..2cc2e54 100644 (file)
@@ -105,6 +105,19 @@ public:
     static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
     static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
 
+    static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
+    {
+        if (!(alignment & Qt::AlignHorizontal_Mask))
+            alignment |= Qt::AlignLeft;
+        if ((alignment & Qt::AlignAbsolute) == 0 && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
+            if (direction == Qt::RightToLeft)
+                alignment ^= (Qt::AlignLeft | Qt::AlignRight);
+            alignment |= Qt::AlignAbsolute;
+        }
+        return alignment;
+    }
+
+
     static bool app_do_modal;
 
     static QPointer<QWidget> qt_last_mouse_receiver;
index 889c2e3..dded864 100644 (file)
@@ -56,7 +56,6 @@
 #include "qpixmapcache.h"
 #include "qpolygon.h"
 #include "qtextlayout.h"
-#include "qstyle.h"
 #include "qthread.h"
 #include "qvarlengtharray.h"
 #include "qstatictext.h"
@@ -72,6 +71,7 @@
 #include <private/qstatictext_p.h>
 #include <private/qglyphs_p.h>
 #include <private/qhexstring_p.h>
+#include <private/qguiapplication_p.h>
 #include <private/qrawfont_p.h>
 
 QT_BEGIN_NAMESPACE
@@ -7547,7 +7547,7 @@ void qt_format_text(const QFont &fnt, const QRectF &_r,
     else
         layout_direction = Qt::LeftToRight;
 
-    tf = QStyle::visualAlignment(layout_direction, QFlag(tf));
+    tf = QGuiApplicationPrivate::visualAlignment(layout_direction, QFlag(tf));
 
     bool isRightToLeft = layout_direction == Qt::RightToLeft;
     bool expandtabs = ((tf & Qt::TextExpandTabs) &&
index 500e827..ecb5ee5 100644 (file)
@@ -47,6 +47,7 @@
 #include "qpixmapcache.h"
 #include "qstyleoption.h"
 #include "private/qstyle_p.h"
+#include "private/qguiapplication_p.h"
 #ifndef QT_NO_DEBUG
 #include "qdebug.h"
 #endif
@@ -2096,14 +2097,7 @@ QRect QStyle::alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
 */
 Qt::Alignment QStyle::visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
 {
-    if (!(alignment & Qt::AlignHorizontal_Mask))
-        alignment |= Qt::AlignLeft;
-    if ((alignment & Qt::AlignAbsolute) == 0 && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
-        if (direction == Qt::RightToLeft)
-            alignment ^= (Qt::AlignLeft | Qt::AlignRight);
-        alignment |= Qt::AlignAbsolute;
-    }
-    return alignment;
+    return QGuiApplicationPrivate::visualAlignment(direction, alignment);
 }
 
 /*!
index ce157be..b53dfe1 100644 (file)
@@ -46,6 +46,7 @@
 #include "qtextlist.h"
 #include "qtextengine_p.h"
 #include "private/qcssutil_p.h"
+#include "private/qguiapplication_p.h"
 
 #include "qabstracttextdocumentlayout_p.h"
 #include "qcssparser_p.h"
@@ -57,7 +58,6 @@
 #include <qdebug.h>
 #include <qvarlengtharray.h>
 #include <limits.h>
-#include <qstyle.h>
 #include <qbasictimer.h>
 #include "private/qfunctions_p.h"
 
@@ -2572,7 +2572,7 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi
         Qt::Alignment align = docPrivate->defaultTextOption.alignment();
         if (blockFormat.hasProperty(QTextFormat::BlockAlignment))
             align = blockFormat.alignment();
-        option.setAlignment(QStyle::visualAlignment(dir, align)); // for paragraph that are RTL, alignment is auto-reversed;
+        option.setAlignment(QGuiApplicationPrivate::visualAlignment(dir, align)); // for paragraph that are RTL, alignment is auto-reversed;
 
         if (blockFormat.nonBreakableLines() || document->pageSize().width() < 0) {
             option.setWrapMode(QTextOption::ManualWrap);
index 37762b6..66b0427 100644 (file)
@@ -49,7 +49,6 @@
 #include <qabstracttextdocumentlayout.h>
 #include "qtextdocument_p.h"
 #include "qtextformat_p.h"
-#include "qstyleoption.h"
 #include "qpainterpath.h"
 #include "qglyphs.h"
 #include "qglyphs_p.h"