From 6ef9094f6db1ee6e00d96c04ce7e8aa212fdfdab Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Wed, 4 Mar 2020 08:57:14 +0100 Subject: [PATCH] Make it compile against qt5.15. SkipEmptyParts is part of Qt::. --- libdiscover/DiscoverBackendsFactory.cpp | 4 ++++ libdiscover/appstream/AppStreamUtils.cpp | 4 ++++ libdiscover/appstream/OdrsReviewsBackend.cpp | 12 ------------ libdiscover/backends/KNSBackend/KNSBackend.cpp | 4 ++++ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libdiscover/DiscoverBackendsFactory.cpp b/libdiscover/DiscoverBackendsFactory.cpp index ef817306..890ffef7 100644 --- a/libdiscover/DiscoverBackendsFactory.cpp +++ b/libdiscover/DiscoverBackendsFactory.cpp @@ -122,7 +122,11 @@ void DiscoverBackendsFactory::setupCommandLine(QCommandLineParser* parser) void DiscoverBackendsFactory::processCommandLine(QCommandLineParser* parser, bool test) { +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) QStringList backends = test ? QStringList{ QStringLiteral("dummy-backend") } : parser->value(QStringLiteral("backends")).split(QLatin1Char(','), QString::SkipEmptyParts); +#else + QStringList backends = test ? QStringList{ QStringLiteral("dummy-backend") } : parser->value(QStringLiteral("backends")).split(QLatin1Char(','), Qt::SkipEmptyParts); +#endif for(auto &backend: backends) { if (!backend.endsWith(QLatin1String("-backend"))) backend.append(QLatin1String("-backend")); diff --git a/libdiscover/appstream/AppStreamUtils.cpp b/libdiscover/appstream/AppStreamUtils.cpp index 94e62c79..9cf68099 100644 --- a/libdiscover/appstream/AppStreamUtils.cpp +++ b/libdiscover/appstream/AppStreamUtils.cpp @@ -111,7 +111,11 @@ QStringList AppStreamUtils::appstreamIds(const QUrl &appstreamUrl) ret += appstreamUrl.host().isEmpty() ? appstreamUrl.path() : appstreamUrl.host(); if (appstreamUrl.hasQuery()) { QUrlQuery query(appstreamUrl); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) ret << query.queryItemValue(QStringLiteral("alt")).split(QLatin1Char(','), QString::SkipEmptyParts); +#else + ret << query.queryItemValue(QStringLiteral("alt")).split(QLatin1Char(','), Qt::SkipEmptyParts); +#endif } return ret; } diff --git a/libdiscover/appstream/OdrsReviewsBackend.cpp b/libdiscover/appstream/OdrsReviewsBackend.cpp index 3d6c7981..15eb7deb 100644 --- a/libdiscover/appstream/OdrsReviewsBackend.cpp +++ b/libdiscover/appstream/OdrsReviewsBackend.cpp @@ -142,11 +142,7 @@ void OdrsReviewsBackend::reviewsFetched() QNetworkReply* reply = qobject_cast(sender()); QScopedPointer replyPtr(reply); const QByteArray data = reply->readAll(); -#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) const auto networkError = reply->error(); -#else - const auto networkError = reply->networkError(); -#endif if (networkError != QNetworkReply::NoError) { qCWarning(LIBDISCOVER_LOG) << "error fetching reviews:" << reply->errorString() << data; m_isFetching = false; @@ -189,11 +185,7 @@ void OdrsReviewsBackend::submitUsefulness(Review *review, bool useful) void OdrsReviewsBackend::usefulnessSubmitted() { QNetworkReply* reply = qobject_cast(sender()); -#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) const auto networkError = reply->error(); -#else - const auto networkError = reply->networkError(); -#endif if (networkError == QNetworkReply::NoError) { qCWarning(LIBDISCOVER_LOG) << "Usefulness submitted"; } else { @@ -239,11 +231,7 @@ void OdrsReviewsBackend::submitReview(AbstractResource *res, const QString &summ void OdrsReviewsBackend::reviewSubmitted(QNetworkReply *reply) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) const auto networkError = reply->error(); -#else - const auto networkError = reply->networkError(); -#endif if (networkError == QNetworkReply::NoError) { AbstractResource *resource = qobject_cast(reply->request().originatingObject()); qCWarning(LIBDISCOVER_LOG) << "Review submitted" << resource; diff --git a/libdiscover/backends/KNSBackend/KNSBackend.cpp b/libdiscover/backends/KNSBackend/KNSBackend.cpp index 278d5e2d..d4cf5dba 100644 --- a/libdiscover/backends/KNSBackend/KNSBackend.cpp +++ b/libdiscover/backends/KNSBackend/KNSBackend.cpp @@ -554,7 +554,11 @@ ResultsStream * KNSBackend::findResourceByPackageName(const QUrl& search) if (search.scheme() != QLatin1String("kns") || search.host() != name()) return voidStream(); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) const auto pathParts = search.path().split(QLatin1Char('/'), QString::SkipEmptyParts); +#else + const auto pathParts = search.path().split(QLatin1Char('/'), Qt::SkipEmptyParts); +#endif if (pathParts.size() != 2) { Q_EMIT passiveMessage(i18n("Wrong KNewStuff URI: %1", search.toString())); return voidStream(); -- 2.25.1