QKeySequenceEdit: simplify clear()
As the test case shows, clear() is semantically equivalent to setKeySequence(QKeySequence()), so implement it that way. Change-Id: Id68edbbf85aac3bcff82c81310c38274ed8e6708 Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>bb10
parent
6b745d6c63
commit
4d1ece8b44
|
|
@ -224,15 +224,7 @@ void QKeySequenceEdit::setKeySequence(const QKeySequence &keySequence)
|
|||
*/
|
||||
void QKeySequenceEdit::clear()
|
||||
{
|
||||
Q_D(QKeySequenceEdit);
|
||||
|
||||
d->resetState();
|
||||
|
||||
d->lineEdit->clear();
|
||||
d->keySequence = QKeySequence();
|
||||
d->keyNum = d->key[0] = d->key[1] = d->key[2] = d->key[3] = 0;
|
||||
d->prevKey = -1;
|
||||
emit keySequenceChanged(d->keySequence);
|
||||
setKeySequence(QKeySequence());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@
|
|||
#include <QtTest/QtTest>
|
||||
|
||||
#include <QKeySequenceEdit>
|
||||
#include <QLineEdit>
|
||||
#include <QString>
|
||||
|
||||
Q_DECLARE_METATYPE(Qt::Key)
|
||||
Q_DECLARE_METATYPE(Qt::KeyboardModifiers)
|
||||
|
|
@ -55,6 +57,7 @@ private slots:
|
|||
void testSetters();
|
||||
void testKeys_data();
|
||||
void testKeys();
|
||||
void testLineEditContents();
|
||||
};
|
||||
|
||||
void tst_QKeySequenceEdit::testSetters()
|
||||
|
|
@ -100,5 +103,26 @@ void tst_QKeySequenceEdit::testKeys()
|
|||
QTRY_COMPARE(spy.count(), 1);
|
||||
}
|
||||
|
||||
void tst_QKeySequenceEdit::testLineEditContents()
|
||||
{
|
||||
QKeySequenceEdit edit;
|
||||
QLineEdit *le = edit.findChild<QLineEdit*>();
|
||||
QVERIFY(le);
|
||||
|
||||
QCOMPARE(le->text(), QString());
|
||||
|
||||
edit.setKeySequence(QKeySequence::New);
|
||||
QCOMPARE(edit.keySequence(), QKeySequence(QKeySequence::New));
|
||||
|
||||
edit.clear();
|
||||
QCOMPARE(le->text(), QString());
|
||||
|
||||
edit.setKeySequence(QKeySequence::New);
|
||||
QVERIFY(le->text() != QString());
|
||||
|
||||
edit.setKeySequence(QKeySequence());
|
||||
QCOMPARE(le->text(), QString());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QKeySequenceEdit)
|
||||
#include "tst_qkeysequenceedit.moc"
|
||||
|
|
|
|||
Loading…
Reference in New Issue