From 96d3be9039baaebc64f5de5d6917dd56d7ed192b Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 7 Jul 2009 18:13:18 +1000 Subject: Finish remaining TODOs for QLineControl Didn't notice there were still some TODO markers left. They have now all been done. --- src/gui/widgets/qlinecontrol.cpp | 16 +++++++--------- src/gui/widgets/qlinecontrol_p.h | 14 ++++++++++++++ src/gui/widgets/qlineedit.cpp | 4 ++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 08574b5..fc0a173 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -1232,7 +1232,6 @@ bool QLineControl::processEvent(QEvent* ev) return true; } } - //TODO: Needs a call to processKeyEvent? } else if (e->type() == QEvent::EnterEditFocus) { end(false); int cft = QApplication::cursorFlashTime(); @@ -1450,11 +1449,10 @@ void QLineControl::processKeyEvent(QKeyEvent* event) // ### resets current content. dubious code; you can // navigate with keys up, down, back, and select(?), but if you press // "left" or "right" it clears? - updatePasswordEchoEditing(true);//TODO: used to set a WA too + updatePasswordEchoEditing(true); clear(); } - //setCursorVisible(true);TODO: Who handles this? if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { if (hasAcceptableInput() || fixup()) { emit accepted(); @@ -1652,19 +1650,19 @@ void QLineControl::processKeyEvent(QKeyEvent* event) #endif } break; -#ifdef QT_KEYPAD_NAVIGATION//TODO: This section +#ifdef QT_KEYPAD_NAVIGATION case Qt::Key_Back: if (QApplication::keypadNavigationEnabled() && !event->isAutoRepeat() && !isReadOnly()) { if (text().length() == 0) { - setText(d->origText); + setText(m_cancelText); - if (d->passwordEchoEditing) - d->updatePasswordEchoEditing(false); + if (passwordEchoEditing) + updatePasswordEchoEditing(false); setEditFocus(false); - } else if (!d->deleteAllTimer.isActive()) { - d->deleteAllTimer.start(750, this); + } else if (!deleteAllTimer) { + deleteAllTimer = startTimer(750); } } else { unknown = true; diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index bb27778..600206d 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -217,6 +217,9 @@ public: int cursorBlinkPeriod() const; void setCursorBlinkPeriod(int msec); + QString cancelText() const; + void setCancelText(QString); + enum DrawFlags { DrawText = 0x01, DrawSelections = 0x02, @@ -265,6 +268,7 @@ private: QList transactions; QPoint m_tripleClick; int m_tripleClickTimer; + QString m_cancelText; void emitCursorPositionChanged(); @@ -706,6 +710,16 @@ inline int QLineControl::cursorBlinkPeriod() const return m_blinkPeriod; } +QString QLineControl::cancelText() const +{ + return m_cancelText; +} + +void QLineControl::setCancelText(QString s) +{ + m_cancelText = s; +} + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index baaad32..7fdda6c 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1663,7 +1663,7 @@ void QLineEdit::focusInEvent(QFocusEvent *e) qt_mac_secure_keyboard(true); #endif #ifdef QT_KEYPAD_NAVIGATION - d->origText = d->text; + d->control->setCancelText(d->text); #endif #ifndef QT_NO_COMPLETER if (d->control->completer()) { @@ -1718,7 +1718,7 @@ void QLineEdit::focusOutEvent(QFocusEvent *e) qt_mac_secure_keyboard(false); #endif #ifdef QT_KEYPAD_NAVIGATION - d->origText = QString(); + d->control->setCancelText(QString()); #endif #ifndef QT_NO_COMPLETER if (d->control->completer()) { -- cgit v0.12