diff options
-rw-r--r-- | src/gui/dialogs/qsidebar.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qsidebar/tst_qsidebar.cpp | 26 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/gui/dialogs/qsidebar.cpp b/src/gui/dialogs/qsidebar.cpp index bfdb37e..26108d7 100644 --- a/src/gui/dialogs/qsidebar.cpp +++ b/src/gui/dialogs/qsidebar.cpp @@ -248,7 +248,11 @@ void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move) if (!url.isValid() || url.scheme() != QLatin1String("file")) continue; for (int j = 0; move && j < rowCount(); ++j) { +#if defined(Q_OS_WIN) + if (index(j, 0).data(UrlRole).toUrl().toLocalFile().toLower() == url.toLocalFile().toLower()) { +#else if (index(j, 0).data(UrlRole) == url) { +#endif removeRow(j); if (j <= row) row--; diff --git a/tests/auto/qsidebar/tst_qsidebar.cpp b/tests/auto/qsidebar/tst_qsidebar.cpp index 7a262e6..705e222 100644 --- a/tests/auto/qsidebar/tst_qsidebar.cpp +++ b/tests/auto/qsidebar/tst_qsidebar.cpp @@ -176,6 +176,32 @@ void tst_QSidebar::addUrls() qsidebar.addUrls(urls, -1); qsidebar.addUrls(moreUrls, -1); QCOMPARE(qsidebar.urls()[0], urls[0]); + + QList<QUrl> doubleUrls; + //tow exact same paths, we have only one entry + doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath()); + doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath()); + qsidebar.setUrls(emptyUrls); + qsidebar.addUrls(doubleUrls, 1); + QCOMPARE(qsidebar.urls().size(), 1); + +#if defined(Q_OS_WIN) + //Windows is case insensitive so no duplicate entries in that case + doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath()); + doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath().toUpper()); + qsidebar.setUrls(emptyUrls); + qsidebar.addUrls(doubleUrls, 1); + QCOMPARE(qsidebar.urls().size(), 1); +#else + //Two different paths we should have two entries + doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath()); + doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath().toUpper()); + qsidebar.setUrls(emptyUrls); + qsidebar.addUrls(doubleUrls, 1); + QCOMPARE(qsidebar.urls().size(), 2); +#endif + + } void tst_QSidebar::goToUrl() |