Deprecate QDesktopServices::storageLocation/displayName
Which required porting the related unittests to qstandardpaths Change-Id: I6eb63c46845f05cd29cc42b59872707526277c90 Reviewed-by: Thiago Macieira (Intel) <thiago.macieira@intel.com>
This commit is contained in:
parent
59f91c0194
commit
dfa24768a3
@ -100,9 +100,9 @@ void Images::open()
|
||||
imageScaling->waitForFinished();
|
||||
}
|
||||
|
||||
// Show a file open dialog at QDesktopServices::PicturesLocation.
|
||||
// Show a file open dialog at QStandardPaths::PicturesLocation.
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, tr("Select Images"),
|
||||
QDesktopServices::storageLocation(QDesktopServices::PicturesLocation),
|
||||
QStandardPaths::writableLocation(QStandardPaths::PicturesLocation),
|
||||
"*.jpg *.png");
|
||||
|
||||
if (files.count() == 0)
|
||||
|
@ -270,21 +270,16 @@ void QDesktopServices::unsetUrlHandler(const QString &scheme)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\deprecated Use QStandardPaths::writableLocation()
|
||||
\fn QString QDesktopServices::storageLocation(StandardLocation type)
|
||||
\obsolete
|
||||
Use QStandardPaths::writableLocation()
|
||||
*/
|
||||
QString QDesktopServices::storageLocation(StandardLocation type)
|
||||
{
|
||||
return QStandardPaths::writableLocation(static_cast<QStandardPaths::StandardLocation>(type));
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\deprecated Use QStandardPaths::displayName()
|
||||
\fn QString QDesktopServices::displayName(StandardLocation type)
|
||||
\obsolete
|
||||
Use QStandardPaths::displayName()
|
||||
*/
|
||||
QString QDesktopServices::displayName(StandardLocation type)
|
||||
{
|
||||
return QStandardPaths::displayName(static_cast<QStandardPaths::StandardLocation>(type));
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -43,6 +43,9 @@
|
||||
#define QDESKTOPSERVICES_H
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
#if QT_DEPRECATED_SINCE(5, 0)
|
||||
#include <QtCore/qstandardpaths.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
@ -63,6 +66,7 @@ public:
|
||||
static void setUrlHandler(const QString &scheme, QObject *receiver, const char *method);
|
||||
static void unsetUrlHandler(const QString &scheme);
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 0)
|
||||
enum StandardLocation {
|
||||
DesktopLocation,
|
||||
DocumentsLocation,
|
||||
@ -77,8 +81,13 @@ public:
|
||||
CacheLocation
|
||||
};
|
||||
|
||||
static QString storageLocation(StandardLocation type);
|
||||
static QString displayName(StandardLocation type);
|
||||
QT_DEPRECATED static QString storageLocation(StandardLocation type) {
|
||||
return QStandardPaths::writableLocation(static_cast<QStandardPaths::StandardLocation>(type));
|
||||
}
|
||||
QT_DEPRECATED static QString displayName(StandardLocation type) {
|
||||
return QStandardPaths::displayName(static_cast<QStandardPaths::StandardLocation>(type));
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // QT_NO_DESKTOPSERVICES
|
||||
|
@ -61,11 +61,6 @@ private slots:
|
||||
void cleanup();
|
||||
void openUrl();
|
||||
void handlers();
|
||||
void storageLocation_data();
|
||||
void storageLocation();
|
||||
|
||||
void storageLocationDoesNotEndWithSlash_data();
|
||||
void storageLocationDoesNotEndWithSlash();
|
||||
};
|
||||
|
||||
tst_qdesktopservices::tst_qdesktopservices()
|
||||
@ -126,44 +121,5 @@ void tst_qdesktopservices::handlers()
|
||||
QCOMPARE(barHandler.lastHandledUrl.toString(), barUrl.toString());
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(QDesktopServices::StandardLocation)
|
||||
void tst_qdesktopservices::storageLocation_data()
|
||||
{
|
||||
QTest::addColumn<QDesktopServices::StandardLocation>("location");
|
||||
QTest::newRow("DesktopLocation") << QDesktopServices::DesktopLocation;
|
||||
QTest::newRow("DocumentsLocation") << QDesktopServices::DocumentsLocation;
|
||||
QTest::newRow("FontsLocation") << QDesktopServices::FontsLocation;
|
||||
QTest::newRow("ApplicationsLocation") << QDesktopServices::ApplicationsLocation;
|
||||
QTest::newRow("MusicLocation") << QDesktopServices::MusicLocation;
|
||||
QTest::newRow("MoviesLocation") << QDesktopServices::MoviesLocation;
|
||||
QTest::newRow("PicturesLocation") << QDesktopServices::PicturesLocation;
|
||||
QTest::newRow("TempLocation") << QDesktopServices::TempLocation;
|
||||
QTest::newRow("HomeLocation") << QDesktopServices::HomeLocation;
|
||||
QTest::newRow("DataLocation") << QDesktopServices::DataLocation;
|
||||
}
|
||||
|
||||
void tst_qdesktopservices::storageLocation()
|
||||
{
|
||||
QFETCH(QDesktopServices::StandardLocation, location);
|
||||
QDesktopServices::storageLocation(location);
|
||||
QDesktopServices::displayName(location);
|
||||
}
|
||||
|
||||
void tst_qdesktopservices::storageLocationDoesNotEndWithSlash_data()
|
||||
{
|
||||
storageLocation_data();
|
||||
}
|
||||
|
||||
void tst_qdesktopservices::storageLocationDoesNotEndWithSlash()
|
||||
{
|
||||
// Currently all desktop locations return their storage location
|
||||
// with "Unix-style" paths (i.e. they use a slash, not backslash).
|
||||
QFETCH(QDesktopServices::StandardLocation, location);
|
||||
QString loc = QDesktopServices::storageLocation(location);
|
||||
if (loc.size() > 1) // workaround for unlikely case of locations that return '/'
|
||||
QCOMPARE(loc.endsWith(QLatin1Char('/')), false);
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(tst_qdesktopservices)
|
||||
#include "tst_qdesktopservices.moc"
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include <QDebug>
|
||||
#include <QtTest/QtTest>
|
||||
#include <QIODevice>
|
||||
#include <QDesktopServices>
|
||||
#include <QStandardPaths>
|
||||
|
||||
|
||||
|
||||
@ -109,8 +109,8 @@ void tst_qnetworkdiskcache::timeInsertion_data()
|
||||
{
|
||||
QTest::addColumn<QString>("cacheRootDirectory");
|
||||
|
||||
QString cacheLoc = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
|
||||
QTest::newRow("QDesktopServices Cache Location") << cacheLoc;
|
||||
QString cacheLoc = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
||||
QTest::newRow("QStandardPaths Cache Location") << cacheLoc;
|
||||
}
|
||||
|
||||
//This functions times an insert() operation.
|
||||
@ -170,8 +170,8 @@ void tst_qnetworkdiskcache::timeRead_data()
|
||||
{
|
||||
QTest::addColumn<QString>("cacheRootDirectory");
|
||||
|
||||
QString cacheLoc = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
|
||||
QTest::newRow("QDesktopServices Cache Location") << cacheLoc;
|
||||
QString cacheLoc = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
||||
QTest::newRow("QStandardPaths Cache Location") << cacheLoc;
|
||||
}
|
||||
|
||||
//Times metadata as well payload lookup
|
||||
@ -229,8 +229,8 @@ void tst_qnetworkdiskcache::timeRemoval_data()
|
||||
{
|
||||
QTest::addColumn<QString>("cacheRootDirectory");
|
||||
|
||||
QString cacheLoc = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
|
||||
QTest::newRow("QDesktopServices Cache Location") << cacheLoc;
|
||||
QString cacheLoc = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
||||
QTest::newRow("QStandardPaths Cache Location") << cacheLoc;
|
||||
}
|
||||
|
||||
void tst_qnetworkdiskcache::timeRemoval()
|
||||
@ -279,8 +279,8 @@ void tst_qnetworkdiskcache::timeExpiration_data()
|
||||
{
|
||||
QTest::addColumn<QString>("cacheRootDirectory");
|
||||
|
||||
QString cacheLoc = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
|
||||
QTest::newRow("QDesktopServices Cache Location") << cacheLoc;
|
||||
QString cacheLoc = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
||||
QTest::newRow("QStandardPaths Cache Location") << cacheLoc;
|
||||
}
|
||||
|
||||
void tst_qnetworkdiskcache::timeExpiration()
|
||||
|
Loading…
x
Reference in New Issue
Block a user