Fix current directory setting in manual dialog test.

It was always constructing a QUrl from the string causing the warning
"Non-native QFileDialog supports only local files" with the
new QUrl-based implementations of getOpenFileUrl(), etc.

Change-Id: Idd9bb432a48865df137f8f39f53014dda150ffe9
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Friedemann Kleint 2014-07-14 10:11:39 +02:00
parent 0fe2713e26
commit b62e22c1d9
2 changed files with 12 additions and 6 deletions

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal ** Contact: http://www.qt-project.org/legal
** **
** This file is part of the test suite of the Qt Toolkit. ** This file is part of the test suite of the Qt Toolkit.
@ -292,6 +292,11 @@ QString FileDialogPanel::filterString() const
return m_nameFilters->toPlainText().trimmed().replace(QLatin1String("\n"), QLatin1String(";;")); return m_nameFilters->toPlainText().trimmed().replace(QLatin1String("\n"), QLatin1String(";;"));
} }
QUrl FileDialogPanel::currentDirectoryUrl() const
{
return QUrl::fromUserInput(m_directory->text().trimmed());
}
QFileDialog::Options FileDialogPanel::options() const QFileDialog::Options FileDialogPanel::options() const
{ {
QFileDialog::Options result; QFileDialog::Options result;
@ -338,7 +343,7 @@ void FileDialogPanel::getOpenFileUrls()
QString selectedFilter = m_selectedNameFilter->text().trimmed(); QString selectedFilter = m_selectedNameFilter->text().trimmed();
const QList<QUrl> files = const QList<QUrl> files =
QFileDialog::getOpenFileUrls(this, tr("getOpenFileNames Qt %1").arg(QLatin1String(QT_VERSION_STR)), QFileDialog::getOpenFileUrls(this, tr("getOpenFileNames Qt %1").arg(QLatin1String(QT_VERSION_STR)),
QUrl(m_directory->text()), filterString(), &selectedFilter, options(), currentDirectoryUrl(), filterString(), &selectedFilter, options(),
allowedSchemes()); allowedSchemes());
if (!files.isEmpty()) { if (!files.isEmpty()) {
QString result; QString result;
@ -371,7 +376,7 @@ void FileDialogPanel::getOpenFileUrl()
QString selectedFilter = m_selectedNameFilter->text().trimmed(); QString selectedFilter = m_selectedNameFilter->text().trimmed();
const QUrl file = const QUrl file =
QFileDialog::getOpenFileUrl(this, tr("getOpenFileUrl Qt %1").arg(QLatin1String(QT_VERSION_STR)), QFileDialog::getOpenFileUrl(this, tr("getOpenFileUrl Qt %1").arg(QLatin1String(QT_VERSION_STR)),
QUrl(m_directory->text()), filterString(), &selectedFilter, options(), currentDirectoryUrl(), filterString(), &selectedFilter, options(),
allowedSchemes()); allowedSchemes());
if (file.isValid()) { if (file.isValid()) {
QString result; QString result;
@ -404,7 +409,7 @@ void FileDialogPanel::getSaveFileUrl()
QString selectedFilter = m_selectedNameFilter->text().trimmed(); QString selectedFilter = m_selectedNameFilter->text().trimmed();
const QUrl file = const QUrl file =
QFileDialog::getSaveFileUrl(this, tr("getSaveFileName Qt %1").arg(QLatin1String(QT_VERSION_STR)), QFileDialog::getSaveFileUrl(this, tr("getSaveFileName Qt %1").arg(QLatin1String(QT_VERSION_STR)),
QUrl(m_directory->text()), filterString(), &selectedFilter, options(), currentDirectoryUrl(), filterString(), &selectedFilter, options(),
allowedSchemes()); allowedSchemes());
if (file.isValid()) { if (file.isValid()) {
QString result; QString result;
@ -430,7 +435,7 @@ void FileDialogPanel::getExistingDirectoryUrl()
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
const QUrl dir = const QUrl dir =
QFileDialog::getExistingDirectoryUrl(this, tr("getExistingDirectory Qt %1").arg(QLatin1String(QT_VERSION_STR)), QFileDialog::getExistingDirectoryUrl(this, tr("getExistingDirectory Qt %1").arg(QLatin1String(QT_VERSION_STR)),
QUrl(m_directory->text()), options() | QFileDialog::ShowDirsOnly, currentDirectoryUrl(), options() | QFileDialog::ShowDirsOnly,
allowedSchemes()); allowedSchemes());
if (!dir.isEmpty()) if (!dir.isEmpty())
QMessageBox::information(this, tr("getExistingDirectory"), QLatin1String("Directory: ") + dir.toString(), QMessageBox::Ok); QMessageBox::information(this, tr("getExistingDirectory"), QLatin1String("Directory: ") + dir.toString(), QMessageBox::Ok);

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal ** Contact: http://www.qt-project.org/legal
** **
** This file is part of the test suite of the Qt Toolkit. ** This file is part of the test suite of the Qt Toolkit.
@ -86,6 +86,7 @@ private slots:
void useMimeTypeFilters(bool); void useMimeTypeFilters(bool);
private: private:
QUrl currentDirectoryUrl() const;
QString filterString() const; QString filterString() const;
QFileDialog::Options options() const; QFileDialog::Options options() const;
QStringList allowedSchemes() const; QStringList allowedSchemes() const;