src/gui/widgets/qlinecontrol.cpp
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
--- a/src/gui/widgets/qlinecontrol.cpp	Tue Feb 02 00:43:10 2010 +0200
+++ b/src/gui/widgets/qlinecontrol.cpp	Wed Mar 31 11:06:36 2010 +0300
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 **
@@ -65,7 +65,7 @@
     Updates the display text based of the current edit text
     If the text has changed will emit displayTextChanged()
 */
-void QLineControl::updateDisplayText()
+void QLineControl::updateDisplayText(bool forceUpdate)
 {
     QString orig = m_textLayout.text();
     QString str;
@@ -102,7 +102,7 @@
     m_textLayout.endLayout();
     m_ascent = qRound(l.ascent());
 
-    if (str != orig)
+    if (str != orig || forceUpdate)
         emit displayTextChanged(str);
 }
 
@@ -476,7 +476,7 @@
         }
     }
     m_textLayout.setAdditionalFormats(formats);
-    updateDisplayText();
+    updateDisplayText(/*force*/ true);
     if (cursorPositionChanged)
         emitCursorPositionChanged();
     if (isGettingInput)
@@ -510,10 +510,12 @@
             o.format.setForeground(m_palette.brush(QPalette::HighlightedText));
         } else {
             // mask selection
-            o.start = m_cursor;
-            o.length = 1;
-            o.format.setBackground(m_palette.brush(QPalette::Text));
-            o.format.setForeground(m_palette.brush(QPalette::Window));
+            if(!m_blinkPeriod || m_blinkStatus){
+                o.start = m_cursor;
+                o.length = 1;
+                o.format.setBackground(m_palette.brush(QPalette::Text));
+                o.format.setForeground(m_palette.brush(QPalette::Window));
+            }
         }
         selections.append(o);
     }
@@ -522,8 +524,11 @@
         m_textLayout.draw(painter, offset, selections, clip);
 
     if (flags & DrawCursor){
+        int cursor = m_cursor;
+        if (m_preeditCursor != -1)
+            cursor += m_preeditCursor;
         if(!m_blinkPeriod || m_blinkStatus)
-            m_textLayout.drawCursor(painter, offset, m_cursor, m_cursorWidth);
+            m_textLayout.drawCursor(painter, offset, cursor, m_cursorWidth);
     }
 }
 
@@ -1366,6 +1371,8 @@
             processInputMethodEvent(static_cast<QInputMethodEvent*>(ev)); break;
 #ifndef QT_NO_SHORTCUT
         case QEvent::ShortcutOverride:{
+            if (isReadOnly())
+                return false;
             QKeyEvent* ke = static_cast<QKeyEvent*>(ev);
             if (ke == QKeySequence::Copy
                 || ke == QKeySequence::Paste