diff options
author | Andy Shaw <andy.shaw@digia.com> | 2014-12-05 10:22:28 +0100 |
---|---|---|
committer | Andy Shaw <andy.shaw@digia.com> | 2014-12-19 15:55:07 +0100 |
commit | a07120d496c43d45792dc5ca92d93eea37f32cec (patch) | |
tree | b1f7646e5e32b68a96def7be1c01d9ee0ab983cd /src/widgets/widgets | |
parent | 7393bb0af4c98cabef3138e4db60692e70d4c444 (diff) |
Don't clear lineedit in non normal echo mode when validation is invalid
This fixes a regression introduced with
c09e9f71173a698670d6c728291ee24f53d50800 which caused the lineedit to
clear the whole text when an invalid character was entered into a lineedit
with an echo mode that was not Normal and a validator was set.
Now if undo() is called directly then it will still clear the text as it
is considered to be called as a user. Whereas the validation will take
care of the invalid entry by using internalUndo() as before which avoids
the clearing of the entire text.
Task-number: QTBUG-29318
Change-Id: I5ff5777a75ab864de2217441b5f518f50646bd8f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qwidgetlinecontrol.cpp | 23 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgetlinecontrol_p.h | 2 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index e6385ba390..7033eeea22 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -279,6 +279,23 @@ void QWidgetLineControl::clear() separate(); finishChange(priorState, /*update*/false, /*edited*/false); } +/*! + \internal + + Undoes the previous operation. +*/ + +void QWidgetLineControl::undo() +{ + // Undo works only for clearing the line when in any of password the modes + if (m_echoMode == QLineEdit::Normal) { + internalUndo(); + finishChange(-1, true); + } else { + cancelPasswordEchoTimer(); + clear(); + } +} /*! \internal @@ -1278,12 +1295,6 @@ void QWidgetLineControl::internalUndo(int until) cancelPasswordEchoTimer(); internalDeselect(); - // Undo works only for clearing the line when in any of password the modes - if (m_echoMode != QLineEdit::Normal) { - clear(); - return; - } - while (m_undoState && m_undoState > until) { Command& cmd = m_history[--m_undoState]; switch (cmd.type) { diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index f21d88177c..49d9413fc0 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -245,7 +245,7 @@ public: void insert(const QString &); void clear(); - void undo() { internalUndo(); finishChange(-1, true); } + void undo(); void redo() { internalRedo(); finishChange(); } void selectWordAtPos(int); |