Commit c5c42a84 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Fix warnings

parent 39699f06
......@@ -40,7 +40,7 @@ PKTransaction::PKTransaction(const QVector<AbstractResource*>& apps, Transaction
Q_ASSERT(!apps.contains(nullptr));
foreach(auto r, apps) {
PackageKitResource* res = qobject_cast<PackageKitResource*>(r);
m_pkgnames.unite(res->allPackageNames().toSet());
m_pkgnames.unite(kToSet(res->allPackageNames()));
}
QTimer::singleShot(0, this, &PKTransaction::start);
......@@ -178,7 +178,7 @@ void PKTransaction::cleanup(PackageKit::Transaction::Exit exit, uint runtime)
i.remove();
}
}
removedResources.subtract(kVectorToSet(m_apps));
removedResources.subtract(kToSet(m_apps));
if (!packagesToRemove.isEmpty() || !removedResources.isEmpty()) {
QString msg = QLatin1String("<ul><li>") + PackageKitResource::joinPackages(packagesToRemove, QLatin1String("</li><li>"), {});
......
......@@ -691,7 +691,7 @@ void PackageKitBackend::fetchDetails(const QSet<QString>& pkgid)
void PackageKitBackend::performDetailsFetch()
{
Q_ASSERT(!m_packageNamesToFetchDetails.isEmpty());
const auto ids = m_packageNamesToFetchDetails.toList();
const auto ids = m_packageNamesToFetchDetails.values();
PackageKit::Transaction* transaction = PackageKit::Daemon::getDetails(ids);
connect(transaction, &PackageKit::Transaction::details, this, &PackageKitBackend::packageDetails);
......@@ -740,5 +740,4 @@ int PackageKitBackend::fetchingUpdatesProgress() const
return percentage;
}
#include "PackageKitBackend.moc"
......@@ -31,6 +31,7 @@
#include <KLocalizedString>
#include "libdiscover_backend_debug.h"
#include "utils.h"
int percentageWithStatus(PackageKit::Transaction::Status status, uint percentage)
{
......@@ -87,7 +88,7 @@ void PackageKitUpdater::prepare()
void PackageKitUpdater::setupTransaction(PackageKit::Transaction::TransactionFlags flags)
{
m_packagesModified.clear();
auto pkgs = involvedPackages(m_toUpgrade).toList();
auto pkgs = involvedPackages(m_toUpgrade).values();
pkgs.sort();
m_transaction = PackageKit::Daemon::updatePackages(pkgs, flags);
m_isCancelable = m_transaction->allowCancel();
......@@ -119,7 +120,7 @@ QSet<AbstractResource*> PackageKitUpdater::packagesForPackageId(const QSet<QStri
QSet<AbstractResource*> ret;
foreach (AbstractResource * res, m_allUpgradeable) {
PackageKitResource* pres = qobject_cast<PackageKitResource*>(res);
if (packages.contains(pres->allPackageNames().toSet())) {
if (packages.contains(kToSet(pres->allPackageNames()))) {
ret.insert(res);
}
}
......@@ -262,19 +263,24 @@ qreal PackageKitUpdater::progress() const
void PackageKitUpdater::removeResources(const QList<AbstractResource*>& apps)
{
QSet<QString> pkgs = involvedPackages(apps.toSet());
QSet<QString> pkgs = involvedPackages(kToSet(apps));
m_toUpgrade.subtract(packagesForPackageId(pkgs));
}
void PackageKitUpdater::addResources(const QList<AbstractResource*>& apps)
{
QSet<QString> pkgs = involvedPackages(apps.toSet());
QSet<QString> pkgs = involvedPackages(kToSet(apps));
m_toUpgrade.unite(packagesForPackageId(pkgs));
}
QList<AbstractResource*> PackageKitUpdater::toUpdate() const
{
return m_toUpgrade.toList();
return m_toUpgrade
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
.values();
#else
.toList();
#endif
}
bool PackageKitUpdater::isMarked(AbstractResource* res) const
......
......@@ -41,7 +41,7 @@ QDebug operator<<(QDebug debug, const QSnapdPlug& plug)
debug.nospace() << "snap:" << plug.snap() << ',';
debug.nospace() << "label:" << plug.label() << ',';
debug.nospace() << "interface:" << plug.interface() << ',';
debug.nospace() << "connectionCount:" << plug.connectionCount();
// debug.nospace() << "connectionCount:" << plug.connectionSlotCount();
debug.nospace() << ')';
return debug;
}
......@@ -54,7 +54,7 @@ QDebug operator<<(QDebug debug, const QSnapdSlot& slot)
debug.nospace() << "label:" << slot.label() << ',';
debug.nospace() << "snap:" << slot.snap() << ',';
debug.nospace() << "interface:" << slot.interface() << ',';
debug.nospace() << "connectionCount:" << slot.connectionCount();
// debug.nospace() << "connectionCount:" << slot.connectionSlotCount();
debug.nospace() << ')';
return debug;
}
......
......@@ -68,10 +68,10 @@ void SnapTransaction::finishTransaction()
p->setProgram(QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR "/discover/SnapMacaroonDialog"));
p->start();
connect(p, static_cast<void(QProcess::*)(int)>(&QProcess::finished), this, [this, p] (int code) {
connect(p, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, [this, p] (int code, QProcess::ExitStatus status) {
p->deleteLater();
if (code != 0) {
qWarning() << "login failed... code:" << code << p->readAll();
qWarning() << "login failed... code:" << code << status << p->readAll();
Q_EMIT passiveMessage(m_request->errorString());
setStatus(DoneWithErrorStatus);
return;
......
......@@ -36,9 +36,7 @@ class SnapAuthHelper : public QObject
Q_OBJECT
QSnapdClient m_client;
public:
SnapAuthHelper() {
m_client.connect()->runAsync();
}
SnapAuthHelper() {}
public Q_SLOTS:
KAuth::ActionReply login(const QVariantMap &args)
......
......@@ -233,7 +233,7 @@ void ResourcesProxyModel::setFiltersFromCategory(Category *category)
void ResourcesProxyModel::fetchSubcategories()
{
auto cats = kVectorToSet(m_filters.category ? m_filters.category->subCategories() : CategoryModel::global()->rootCategories());
auto cats = kToSet(m_filters.category ? m_filters.category->subCategories() : CategoryModel::global()->rootCategories());
const int count = rowCount();
QSet<Category*> done;
......
......@@ -217,22 +217,14 @@ int StandardBackendUpdater::updatesCount() const
void StandardBackendUpdater::addResources(const QList< AbstractResource* >& apps)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
const QSet<AbstractResource *> upgradeableApps(apps.begin(), apps.end());
#else
const QSet<AbstractResource *> upgradeableApps = apps.toSet();
#endif
const QSet<AbstractResource *> upgradeableApps = kToSet(apps);
Q_ASSERT(m_upgradeable.contains(upgradeableApps));
m_toUpgrade += upgradeableApps;
}
void StandardBackendUpdater::removeResources(const QList< AbstractResource* >& apps)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
const QSet<AbstractResource *> upgradeableApps(apps.begin(), apps.end());
#else
const QSet<AbstractResource *> upgradeableApps = apps.toSet();
#endif
const QSet<AbstractResource *> upgradeableApps = kToSet(apps);
Q_ASSERT(m_upgradeable.contains(upgradeableApps));
Q_ASSERT(m_toUpgrade.contains(upgradeableApps));
m_toUpgrade -= upgradeableApps;
......
......@@ -88,13 +88,27 @@ static QVector<T> kSetToVector(const QSet<T> & set)
}
template <typename T>
static QSet<T> kVectorToSet(const QVector<T> & set)
static QSet<T> kToSet(const QVector<T> & set)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
return QSet<T>(set.begin(), set.end());
#else
QSet<T> ret;
ret.reserve(set.size());
for(auto &x: set)
ret.insert(x);
return ret;
#endif
}
template <typename T>
static QSet<T> kToSet(const QList<T> & set)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
return QSet<T>(set.begin(), set.end());
#else
return set.toSet();
#endif
}
class ElapsedDebug : private QElapsedTimer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment