diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2009-09-30 12:30:12 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2009-09-30 12:32:43 (GMT) |
commit | 71b3a015d5f051c732646ead395e56a609cc51af (patch) | |
tree | a98820d8b224117a4bce99878bf97163c995df26 | |
parent | 79aee2c16479a1dff1af886a6ccc6b2776ad6537 (diff) | |
download | Qt-71b3a015d5f051c732646ead395e56a609cc51af.zip Qt-71b3a015d5f051c732646ead395e56a609cc51af.tar.gz Qt-71b3a015d5f051c732646ead395e56a609cc51af.tar.bz2 |
Be consistant between static method and regular QFileDialog contructor.
The protected constructor of QFileDialog call selectAll() on the
line edit. This constructor is only called by static methods. But the
regular constructor didn't behave the same. Now it does :D.
Task-number:QTBUG-4419
Reviewed-by:jasplin
-rw-r--r-- | src/gui/dialogs/qfiledialog.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qfiledialog/tst_qfiledialog.cpp | 29 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 14f19f2..297c900 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -317,6 +317,7 @@ QFileDialog::QFileDialog(QWidget *parent, Qt::WindowFlags f) { Q_D(QFileDialog); d->init(); + d->lineEdit()->selectAll(); } /*! @@ -334,6 +335,7 @@ QFileDialog::QFileDialog(QWidget *parent, { Q_D(QFileDialog); d->init(directory, filter, caption); + d->lineEdit()->selectAll(); } /*! diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index 1aa5ee1..9b083ea 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -169,6 +169,8 @@ private slots: void task257579_sideBarWithNonCleanUrls(); void task259105_filtersCornerCases(); + void QTBUG4419_lineEditSelectAll(); + private: QByteArray userSettings; }; @@ -2153,5 +2155,32 @@ void tst_QFiledialog::task259105_filtersCornerCases() filters->setCurrentIndex(1); QCOMPARE(filters->currentText(), QLatin1String("Text Files")); } + +void tst_QFiledialog::QTBUG4419_lineEditSelectAll() +{ + QString tempPath = QDir::tempPath(); + QTemporaryFile *t; + t = new QTemporaryFile; + t->open(); + QNonNativeFileDialog fd(0, "TestFileDialog", t->fileName()); + + fd.setDirectory(tempPath); + fd.setViewMode(QFileDialog::List); + fd.setAcceptMode(QFileDialog::AcceptSave); + fd.setFileMode(QFileDialog::AnyFile); + + fd.show(); + QApplication::setActiveWindow(&fd); + QTest::qWaitForWindowShown(&fd); + QTRY_COMPARE(fd.isVisible(), true); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); + + QTest::qWait(500); + QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); + + QCOMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName()); + QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName()); +} + QTEST_MAIN(tst_QFiledialog) #include "tst_qfiledialog.moc" |