Enablers for using QGlyphRun in SceneGraph
[profile/ivi/qtbase.git] / src / gui / widgets / qlinecontrol_p.h
index c6105f8..d4c4154 100644 (file)
@@ -65,6 +65,9 @@
 #include "QtCore/qpoint.h"
 #include "QtGui/qcompleter.h"
 #include "QtGui/qaccessible.h"
+#include "QtCore/qthread.h"
+
+#include "qplatformdefs.h"
 
 QT_BEGIN_HEADER
 
@@ -85,6 +88,13 @@ public:
         m_ascent(0), m_maxLength(32767), m_lastCursorPos(-1),
         m_tripleClickTimer(0), m_maskData(0), m_modifiedState(0), m_undoState(0),
         m_selstart(0), m_selend(0), m_passwordEchoEditing(false)
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+        , m_passwordEchoTimer(0)
+#endif
+#if defined(Q_WS_MAC)
+        , m_threadChecks(false)
+        , m_textLayoutThread(0)
+ #endif
     {
         init(txt);
     }
@@ -222,6 +232,7 @@ public:
     uint echoMode() const { return m_echoMode; }
     void setEchoMode(uint mode)
     {
+        cancelPasswordEchoTimer();
         m_echoMode = mode;
         m_passwordEchoEditing = false;
         updateDisplayText();
@@ -271,7 +282,13 @@ public:
     QString preeditAreaText() const { return m_textLayout.preeditAreaText(); }
 
     void updatePasswordEchoEditing(bool editing);
-    bool passwordEchoEditing() const { return m_passwordEchoEditing; }
+    bool passwordEchoEditing() const {
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+        if (m_passwordEchoTimer != 0)
+            return true;
+#endif
+        return m_passwordEchoEditing ;
+    }
 
     QChar passwordCharacter() const { return m_passwordCharacter; }
     void setPasswordCharacter(const QChar &character) { m_passwordCharacter = character; updateDisplayText(); }
@@ -320,11 +337,27 @@ public:
 
     bool processEvent(QEvent *ev);
 
-    QTextLayout *textLayout()
+    QTextLayout *textLayout() const
     {
+#if defined(Q_WS_MAC)
+        if (m_threadChecks && QThread::currentThread() != m_textLayoutThread)
+            redoTextLayout();
+#endif
         return &m_textLayout;
     }
 
+#if defined(Q_WS_MAC)
+    void setThreadChecks(bool threadChecks)
+    {
+        m_threadChecks = threadChecks;
+    }
+
+    bool threadChecks() const
+    {
+        return m_threadChecks;
+    }
+#endif
+
 private:
     void init(const QString &txt);
     void removeSelectedText();
@@ -421,11 +454,29 @@ private:
     QString stripString(const QString &str) const;
     int findInMask(int pos, bool forward, bool findSeparator, QChar searchChar = QChar()) const;
 
-    // complex text layout
-    QTextLayout m_textLayout;
+    // complex text layout (must be mutable so it can be reshaped at will)
+    mutable QTextLayout m_textLayout;
 
     bool m_passwordEchoEditing;
     QChar m_passwordCharacter;
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+    int m_passwordEchoTimer;
+#endif
+    void cancelPasswordEchoTimer()
+    {
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+        if (m_passwordEchoTimer != 0) {
+            killTimer(m_passwordEchoTimer);
+            m_passwordEchoTimer = 0;
+        }
+#endif
+    }
+
+    int redoTextLayout() const;
+#if defined(Q_WS_MAC)
+    bool m_threadChecks;
+    mutable QThread *m_textLayoutThread;
+#endif
 
 Q_SIGNALS:
     void cursorPositionChanged(int, int);