summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/widgets/qlinecontrol_p.h2
-rw-r--r--src/gui/widgets/qlineedit.cpp2
-rw-r--r--src/gui/widgets/qlineedit.h1
-rw-r--r--src/gui/widgets/qlineedit_p.cpp8
-rw-r--r--src/gui/widgets/qlineedit_p.h2
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp27
6 files changed, 29 insertions, 13 deletions
diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h
index adea742..0db6279 100644
--- a/src/gui/widgets/qlinecontrol_p.h
+++ b/src/gui/widgets/qlinecontrol_p.h
@@ -349,7 +349,7 @@ Q_SIGNALS:
protected:
virtual void timerEvent(QTimerEvent *event);
-private slots:
+private Q_SLOTS:
void _q_clipboardChanged();
void _q_deleteSelected();
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index f36a995..059aaf1 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -2002,7 +2002,7 @@ QMenu *QLineEdit::createStandardContextMenu()
action = popup->addAction(QLineEdit::tr("Delete"));
action->setEnabled(!d->control->isReadOnly() && !d->control->text().isEmpty() && d->control->hasSelectedText());
- connect(action, SIGNAL(triggered()), SLOT(_q_deleteSelected()));
+ connect(action, SIGNAL(triggered()), d->control, SLOT(_q_deleteSelected()));
popup->addSeparator();
diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h
index 03d4376..cd37ad0 100644
--- a/src/gui/widgets/qlineedit.h
+++ b/src/gui/widgets/qlineedit.h
@@ -267,7 +267,6 @@ private:
Q_DISABLE_COPY(QLineEdit)
Q_DECLARE_PRIVATE(QLineEdit)
Q_PRIVATE_SLOT(d_func(), void _q_handleWindowActivate())
- Q_PRIVATE_SLOT(d_func(), void _q_deleteSelected())
Q_PRIVATE_SLOT(d_func(), void _q_textEdited(const QString &))
Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged(int, int))
#ifndef QT_NO_COMPLETER
diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp
index cec34da..4218630 100644
--- a/src/gui/widgets/qlineedit_p.cpp
+++ b/src/gui/widgets/qlineedit_p.cpp
@@ -93,10 +93,6 @@ void QLineEditPrivate::_q_completionHighlighted(QString newText)
#endif // QT_NO_COMPLETER
-void QLineEditPrivate::_q_clipboardChanged()
-{
-}
-
void QLineEditPrivate::_q_handleWindowActivate()
{
Q_Q(QLineEdit);
@@ -104,10 +100,6 @@ void QLineEditPrivate::_q_handleWindowActivate()
control->deselect();
}
-void QLineEditPrivate::_q_deleteSelected()
-{
-}
-
void QLineEditPrivate::_q_textEdited(const QString &text)
{
Q_Q(QLineEdit);
diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h
index 3521dcb..260bc19 100644
--- a/src/gui/widgets/qlineedit_p.h
+++ b/src/gui/widgets/qlineedit_p.h
@@ -122,9 +122,7 @@ public:
QRect adjustedContentsRect() const;
- void _q_clipboardChanged();
void _q_handleWindowActivate();
- void _q_deleteSelected();
void _q_textEdited(const QString &);
void _q_cursorPositionChanged(int, int);
#ifdef QT_KEYPAD_NAVIGATION
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 1616154..93aa64c 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -190,6 +190,7 @@ private slots:
void selectedText();
void hasSelectedText();
+ void deleteSelectedText();
void textChangedAndTextEdited();
void returnPressed();
@@ -2054,6 +2055,32 @@ void tst_QLineEdit::hasSelectedText()
DEPENDS_ON("selectedText");
}
+void tst_QLineEdit::deleteSelectedText()
+{
+ const QString text = QString::fromLatin1("bar");
+ QLineEdit edit( text );
+ QCOMPARE(edit.text(), text);
+
+ edit.selectAll();
+
+ QTest::keyClick(&edit, Qt::Key_Delete, 0);
+ QVERIFY(edit.text().isEmpty());
+
+ edit.setText(text);
+ edit.selectAll();
+
+ QMenu *menu = edit.createStandardContextMenu();
+ for (int i = 0; i < menu->actions().count(); ++i) {
+ QAction *current = menu->actions().at(i);
+ if (current->text() == QLineEdit::tr("Delete")) {
+ current->trigger(); //this will delete the whole text selected
+ QVERIFY(edit.text().isEmpty());
+ }
+ }
+
+}
+
+
void tst_QLineEdit::textChangedAndTextEdited()
{
changed_count = 0;