libqt5-qtbase/0002-QUrl-fromLocalFile-QString-should-lead-to-an-empty-U.patch
Stephan Kulow e4c21e8f38 Accepting request 255354 from KDE:Qt5
- Added 0001-QFileDialog-emit-urlsSelected-urlSelected-in-accept.patch,
  0002-QUrl-fromLocalFile-QString-should-lead-to-an-empty-U.patch,
  0003-QFileDialog-turn-workingDirectory-into-a-QUrl.patch and
  0004-QFileDialog-implement-getOpenFileUrl-and-friends-for.patch
  from upstream to improve QFileDialog behaviour with both local
  and remote URL's
- Added 0001-QKdeTheme-use-system-wide-kdeglobals-as-a-fallback.patch:
  QTBUG-36184
- Added 0001-Add-QFont-strategy-to-disable-subpixel-antialiasing.patch,
  0002-Move-SubpixelAntialiasingType-from-QFontEngineFT-to-.patch,
  0003-Support-autohint-and-lcdfilter-fontconfig-configurat.patch
  and 0004-GTK2-theme-should-use-GTK-configured-font-variant.patch
  QTBUG-40396, QTBUG-32254, QTBUG-39643

OBS-URL: https://build.opensuse.org/request/show/255354
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/libqt5-qtbase?expand=0&rev=30
2014-10-14 11:24:52 +00:00

101 lines
3.9 KiB
Diff

From 18bb76b3b27edf8d980e414bc2b91c44ad80aab2 Mon Sep 17 00:00:00 2001
From: David Faure <david.faure@kdab.com>
Date: Wed, 9 Jul 2014 15:03:35 +0200
Subject: [PATCH 2/4] QUrl: fromLocalFile(QString()) should lead to an empty
URL.
This is much more useful than the URL "file:", it allows to use
"empty path" and "empty URL" for the same meaning (e.g. not set).
QFileDialog actually uses "file:" though, as the URL for the
"My Computer" item in the sidebar. This patch preserves that.
[ChangeLog][QtCore][QUrl] QUrl::fromLocalFile now returns an empty URL
if the input string is empty.
Change-Id: Ib5ce1a3cdf5f229368e5bcd83c62c1d1ac9f8a17
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit fd331a5b3a122393cd697a8b856dd52cfd31d698)
---
src/corelib/io/qurl.cpp | 4 ++++
src/widgets/dialogs/qfiledialog.cpp | 4 ++--
src/widgets/dialogs/qsidebar.cpp | 3 ++-
tests/auto/corelib/io/qurl/tst_qurl.cpp | 5 +++++
4 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index c109fc4..00ffc4f 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -3714,11 +3714,15 @@ bool QUrl::isDetached() const
"//servername/path/to/file.txt". Note that only certain platforms can
actually open this file using QFile::open().
+ An empty \a localFile leads to an empty URL (since Qt 5.4).
+
\sa toLocalFile(), isLocalFile(), QDir::toNativeSeparators()
*/
QUrl QUrl::fromLocalFile(const QString &localFile)
{
QUrl url;
+ if (localFile.isEmpty())
+ return url;
url.setScheme(fileScheme());
QString deslashified = QDir::fromNativeSeparators(localFile);
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 037964b..82a4a4c 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -2783,7 +2783,7 @@ void QFileDialogPrivate::createWidgets()
qFileDialogUi->setupUi(q);
QList<QUrl> initialBookmarks;
- initialBookmarks << QUrl::fromLocalFile(QLatin1String(""))
+ initialBookmarks << QUrl(QLatin1String("file:"))
<< QUrl::fromLocalFile(QDir::homePath());
qFileDialogUi->sidebar->setModelAndUrls(model, initialBookmarks);
QFileDialog::connect(qFileDialogUi->sidebar, SIGNAL(goToUrl(QUrl)),
@@ -3760,7 +3760,7 @@ void QFileDialogComboBox::showPopup()
idx = idx.parent();
}
// add "my computer"
- list.append(QUrl::fromLocalFile(QLatin1String("")));
+ list.append(QUrl(QLatin1String("file:")));
urlModel->addUrls(list, 0);
idx = model()->index(model()->rowCount() - 1, 0);
diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp
index 3d22992..7b691dc 100644
--- a/src/widgets/dialogs/qsidebar.cpp
+++ b/src/widgets/dialogs/qsidebar.cpp
@@ -249,7 +249,8 @@ void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move)
continue;
//this makes sure the url is clean
const QString cleanUrl = QDir::cleanPath(url.toLocalFile());
- url = QUrl::fromLocalFile(cleanUrl);
+ if (!cleanUrl.isEmpty())
+ url = QUrl::fromLocalFile(cleanUrl);
for (int j = 0; move && j < rowCount(); ++j) {
QString local = index(j, 0).data(UrlRole).toUrl().toLocalFile();
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index d5eab54..b8bab87 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -235,6 +235,11 @@ void tst_QUrl::constructing()
QVERIFY(url == url);
QVERIFY(!(url < url));
+ QUrl fromLocal = QUrl::fromLocalFile(QString());
+ QVERIFY(!fromLocal.isValid());
+ QVERIFY(fromLocal.isEmpty());
+ QCOMPARE(fromLocal.toString(), QString());
+
QUrl justHost("qt-project.org");
QVERIFY(!justHost.isEmpty());
QVERIFY(justHost.host().isEmpty());
--
2.1.1