1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
63 \internal |
63 \internal |
64 |
64 |
65 Updates the display text based of the current edit text |
65 Updates the display text based of the current edit text |
66 If the text has changed will emit displayTextChanged() |
66 If the text has changed will emit displayTextChanged() |
67 */ |
67 */ |
68 void QLineControl::updateDisplayText() |
68 void QLineControl::updateDisplayText(bool forceUpdate) |
69 { |
69 { |
70 QString orig = m_textLayout.text(); |
70 QString orig = m_textLayout.text(); |
71 QString str; |
71 QString str; |
72 if (m_echoMode == QLineEdit::NoEcho) |
72 if (m_echoMode == QLineEdit::NoEcho) |
73 str = QString::fromLatin1(""); |
73 str = QString::fromLatin1(""); |
100 m_textLayout.beginLayout(); |
100 m_textLayout.beginLayout(); |
101 QTextLine l = m_textLayout.createLine(); |
101 QTextLine l = m_textLayout.createLine(); |
102 m_textLayout.endLayout(); |
102 m_textLayout.endLayout(); |
103 m_ascent = qRound(l.ascent()); |
103 m_ascent = qRound(l.ascent()); |
104 |
104 |
105 if (str != orig) |
105 if (str != orig || forceUpdate) |
106 emit displayTextChanged(str); |
106 emit displayTextChanged(str); |
107 } |
107 } |
108 |
108 |
109 #ifndef QT_NO_CLIPBOARD |
109 #ifndef QT_NO_CLIPBOARD |
110 /*! |
110 /*! |
508 o.length = m_selend - m_selstart; |
508 o.length = m_selend - m_selstart; |
509 o.format.setBackground(m_palette.brush(QPalette::Highlight)); |
509 o.format.setBackground(m_palette.brush(QPalette::Highlight)); |
510 o.format.setForeground(m_palette.brush(QPalette::HighlightedText)); |
510 o.format.setForeground(m_palette.brush(QPalette::HighlightedText)); |
511 } else { |
511 } else { |
512 // mask selection |
512 // mask selection |
513 o.start = m_cursor; |
513 if(!m_blinkPeriod || m_blinkStatus){ |
514 o.length = 1; |
514 o.start = m_cursor; |
515 o.format.setBackground(m_palette.brush(QPalette::Text)); |
515 o.length = 1; |
516 o.format.setForeground(m_palette.brush(QPalette::Window)); |
516 o.format.setBackground(m_palette.brush(QPalette::Text)); |
|
517 o.format.setForeground(m_palette.brush(QPalette::Window)); |
|
518 } |
517 } |
519 } |
518 selections.append(o); |
520 selections.append(o); |
519 } |
521 } |
520 |
522 |
521 if (flags & DrawText) |
523 if (flags & DrawText) |
522 m_textLayout.draw(painter, offset, selections, clip); |
524 m_textLayout.draw(painter, offset, selections, clip); |
523 |
525 |
524 if (flags & DrawCursor){ |
526 if (flags & DrawCursor){ |
|
527 int cursor = m_cursor; |
|
528 if (m_preeditCursor != -1) |
|
529 cursor += m_preeditCursor; |
525 if(!m_blinkPeriod || m_blinkStatus) |
530 if(!m_blinkPeriod || m_blinkStatus) |
526 m_textLayout.drawCursor(painter, offset, m_cursor, m_cursorWidth); |
531 m_textLayout.drawCursor(painter, offset, cursor, m_cursorWidth); |
527 } |
532 } |
528 } |
533 } |
529 |
534 |
530 /*! |
535 /*! |
531 \internal |
536 \internal |
1364 processKeyEvent(static_cast<QKeyEvent*>(ev)); break; |
1369 processKeyEvent(static_cast<QKeyEvent*>(ev)); break; |
1365 case QEvent::InputMethod: |
1370 case QEvent::InputMethod: |
1366 processInputMethodEvent(static_cast<QInputMethodEvent*>(ev)); break; |
1371 processInputMethodEvent(static_cast<QInputMethodEvent*>(ev)); break; |
1367 #ifndef QT_NO_SHORTCUT |
1372 #ifndef QT_NO_SHORTCUT |
1368 case QEvent::ShortcutOverride:{ |
1373 case QEvent::ShortcutOverride:{ |
|
1374 if (isReadOnly()) |
|
1375 return false; |
1369 QKeyEvent* ke = static_cast<QKeyEvent*>(ev); |
1376 QKeyEvent* ke = static_cast<QKeyEvent*>(ev); |
1370 if (ke == QKeySequence::Copy |
1377 if (ke == QKeySequence::Copy |
1371 || ke == QKeySequence::Paste |
1378 || ke == QKeySequence::Paste |
1372 || ke == QKeySequence::Cut |
1379 || ke == QKeySequence::Cut |
1373 || ke == QKeySequence::Redo |
1380 || ke == QKeySequence::Redo |