From 67ae1b0dac175f48875507f3187ed49276a29ddf Mon Sep 17 00:00:00 2001
From: Jason Barron <jbarron@trolltech.com>
Date: Tue, 4 Aug 2009 12:33:24 +0200
Subject: Fix more compile breakages after merging qt/master-stable.

A lot of the logic was factored out of QLineEdit(Private) and into a
private class called QLineControl, however the changes did not compile
when keypad navigation is enabled so fix them.
---
 src/gui/widgets/qdatetimeedit.cpp | 10 ++--------
 src/gui/widgets/qlinecontrol.cpp  | 11 ++++++-----
 src/gui/widgets/qlineedit.cpp     | 18 ++++++++++--------
 src/gui/widgets/qlineedit_p.h     |  3 ++-
 4 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp
index db57b43..1533edb 100644
--- a/src/gui/widgets/qdatetimeedit.cpp
+++ b/src/gui/widgets/qdatetimeedit.cpp
@@ -1086,10 +1086,7 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event)
 
                 //hide cursor
                 d->edit->d_func()->setCursorVisible(false);
-                if (d->edit->d_func()->cursorTimer > 0)
-                    killTimer(d->edit->d_func()->cursorTimer);
-                d->edit->d_func()->cursorTimer = 0;
-
+                d->edit->d_func()->control->setCursorBlinkPeriod(0);
                 d->setSelected(0);
             }
         }
@@ -1110,10 +1107,7 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event)
 
             //hide cursor
             d->edit->d_func()->setCursorVisible(false);
-            if (d->edit->d_func()->cursorTimer > 0)
-                killTimer(d->edit->d_func()->cursorTimer);
-            d->edit->d_func()->cursorTimer = 0;
-
+            d->edit->d_func()->control->setCursorBlinkPeriod(0);
             d->setSelected(0);
             oldCurrent = 0;
         }
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index 106d8f2..90ec1e3 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -1295,7 +1295,7 @@ bool QLineControl::processEvent(QEvent* ev)
                 }
                 if ((ev->type() == QEvent::KeyRelease)
                     && !isReadOnly()
-                    && deleteAllTimer) {
+                    && m_deleteAllTimer) {
                     killTimer(m_deleteAllTimer);
                     m_deleteAllTimer = 0;
                     backspace();
@@ -1701,12 +1701,13 @@ void QLineControl::processKeyEvent(QKeyEvent* event)
                     if (text().length() == 0) {
                         setText(m_cancelText);
 
-                        if (passwordEchoEditing)
+                        if (passwordEchoEditing())
                             updatePasswordEchoEditing(false);
 
-                        setEditFocus(false);
-                    } else if (!deleteAllTimer) {
-                        deleteAllTimer = startTimer(750);
+                        // ### TODO this needs to be fixed.
+                        // setEditFocus(false);
+                    } else if (!m_deleteAllTimer) {
+                        m_deleteAllTimer = startTimer(750);
                     }
                 } else {
                     unknown = true;
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 01d4890..8ab30fa 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1665,12 +1665,12 @@ QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const
     case Qt::ImMaximumTextLength:
         return QVariant(maxLength());
     case Qt::ImAnchorPosition:
-        if (d->selstart == d->selend)
-            return QVariant(d->cursor);
-        else if (d->selstart == d->cursor)
-            return QVariant(d->selend);
+        if (d->control->selectionStart() == d->control->selectionEnd())
+            return QVariant(d->control->cursor());
+        else if (d->control->selectionStart() == d->control->cursor())
+            return QVariant(d->control->selectionEnd());
         else
-            return QVariant(d->selstart);
+            return QVariant(d->control->selectionStart());
     default:
         return QVariant();
     }
@@ -1695,8 +1695,10 @@ void QLineEdit::focusInEvent(QFocusEvent *e)
 #ifdef QT_KEYPAD_NAVIGATION
     if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason))
 #endif
-    int cft = QApplication::cursorFlashTime();
-    d->control->setCursorBlinkPeriod(cft/2);
+    {
+        int cft = QApplication::cursorFlashTime();
+        d->control->setCursorBlinkPeriod(cft/2);
+    }
     QStyleOptionFrameV2 opt;
     initStyleOption(&opt);
     if((!hasSelectedText() && d->control->preeditAreaText().isEmpty())
@@ -1707,7 +1709,7 @@ void QLineEdit::focusInEvent(QFocusEvent *e)
         qt_mac_secure_keyboard(true);
 #endif
 #ifdef QT_KEYPAD_NAVIGATION
-    d->control->setCancelText(d->text);
+    d->control->setCancelText(d->control->text());
 #endif
 #ifndef QT_NO_COMPLETER
     if (d->control->completer()) {
diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h
index 230023d..b09c3f0 100644
--- a/src/gui/widgets/qlineedit_p.h
+++ b/src/gui/widgets/qlineedit_p.h
@@ -76,7 +76,7 @@ public:
 
     QLineEditPrivate()
         : control(0), frame(1), contextMenuEnabled(1), cursorVisible(0),
-        dragEnabled(0), hscroll(0), vscroll(0),
+        dragEnabled(0), hscroll(0), vscroll(0), clickCausedFocus(0),
         alignment(Qt::AlignLeading | Qt::AlignVCenter),
         leftTextMargin(0), topTextMargin(0), rightTextMargin(0), bottomTextMargin(0)
     {
@@ -110,6 +110,7 @@ public:
     uint contextMenuEnabled : 1;
     uint cursorVisible : 1;
     uint dragEnabled : 1;
+    uint clickCausedFocus : 1;
     int hscroll;
     int vscroll;
     uint alignment;
-- 
cgit v0.12