From b9fc86cd9f51c80a1103e5e896940b49bf552b07 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 9 Jul 2009 09:47:18 +1000 Subject: Accidental Behavioural changes have been identified and rectified. createStandardContextMenu should still only cut/copy in normal echo mode and the Qt3Support function validateAndSet will again only set if it is validated. --- src/gui/widgets/qlineedit.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 8e7fdec..2d6ef03 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -692,9 +692,14 @@ int QLineEdit::cursorPositionAt(const QPoint &pos) bool QLineEdit::validateAndSet(const QString &newText, int newPos, int newMarkAnchor, int newMarkDrag) { - // Note, this doesn't validate', but then neither - // does the suggested functions above in the docs. + // The suggested functions above in the docs don't seem to validate, + // below code tries to mimic previous behaviour. + QString oldText = text(); setText(newText); + if(!hasAcceptableInput()){ + setText(oldText); + return false; + } setCursorPosition(newPos); setSelection(qMin(newMarkAnchor, newMarkDrag), qAbs(newMarkAnchor - newMarkDrag)); return true; @@ -1947,11 +1952,13 @@ QMenu *QLineEdit::createStandardContextMenu() #ifndef QT_NO_CLIPBOARD action = popup->addAction(QLineEdit::tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut)); - action->setEnabled(!d->control->isReadOnly() && d->control->hasSelectedText()); + action->setEnabled(!d->control->isReadOnly() && d->control->hasSelectedText() + && d->control->echoMode() == QLineEdit::Normal); connect(action, SIGNAL(triggered()), SLOT(cut())); action = popup->addAction(QLineEdit::tr("&Copy") + ACCEL_KEY(QKeySequence::Copy)); - action->setEnabled(d->control->hasSelectedText()); + action->setEnabled(d->control->hasSelectedText() + && d->control->echoMode() == QLineEdit::Normal); connect(action, SIGNAL(triggered()), SLOT(copy())); action = popup->addAction(QLineEdit::tr("&Paste") + ACCEL_KEY(QKeySequence::Paste)); -- cgit v0.12