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

Solve some clazy warnings

parent adb4da6f
......@@ -41,6 +41,6 @@ QNetworkReply * CachedNetworkAccessManager::createRequest(Operation op, const QN
{
QNetworkRequest req(request);
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
return QNetworkAccessManager::createRequest(op, request, outgoingData);
return KIO::AccessManager::createRequest(op, request, outgoingData);
}
......@@ -225,7 +225,7 @@ void Category::addSubcategory(QVector< Category* >& list, Category* newcat)
void Category::addSubcategory(Category* cat)
{
int i = 0;
for(Category* subCat : m_subCategories) {
for(Category* subCat : qAsConst(m_subCategories)) {
if(!categoryLessThan(subCat, cat)) {
break;
}
......
......@@ -65,11 +65,7 @@ class KNSBackendFactory : public AbstractResourcesBackendFactory {
QVector<AbstractResourcesBackend*> newInstance(QObject* parent, const QString &/*name*/) const override
{
QVector<AbstractResourcesBackend*> ret;
#if KNEWSTUFFCORE_VERSION_MAJOR==5 && KNEWSTUFFCORE_VERSION_MINOR>=57
QStringList locations = KNSCore::Engine::configSearchLocations();
#else
QStringList locations = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation);
#endif
const QStringList locations = KNSCore::Engine::configSearchLocations();
QSet<QString> files;
for (const QString &path: locations) {
QDirIterator dirIt(path, {QStringLiteral("*.knsrc")}, QDir::Files);
......@@ -154,9 +150,9 @@ KNSBackend::KNSBackend(QObject* parent, const QString& iconName, const QString &
}
QVector<Category*> topCategories{categories};
for (const auto &cat: categories) {
for (const auto &cat: qAsConst(categories)) {
const QString catName = cat->name().append(QLatin1Char('/'));
for (const auto& potentialSubCat: categories) {
for (const auto& potentialSubCat: qAsConst(categories)) {
if(potentialSubCat->name().startsWith(catName)) {
cat->addSubcategory(potentialSubCat);
topCategories.removeOne(potentialSubCat);
......@@ -170,10 +166,10 @@ KNSBackend::KNSBackend(QObject* parent, const QString& iconName, const QString &
connect(m_engine, &KNSCore::Engine::signalEntryChanged, this, &KNSBackend::statusChanged, Qt::QueuedConnection);
connect(m_engine, &KNSCore::Engine::signalEntryDetailsLoaded, this, &KNSBackend::detailsLoaded);
connect(m_engine, &KNSCore::Engine::signalProvidersLoaded, this, &KNSBackend::fetchInstalled);
connect(m_engine, &KNSCore::Engine::signalCategoriesMetadataLoded, this, [categories](const QList< KNSCore::Provider::CategoryMetadata>& categoryMetadatas){
connect(m_engine, &KNSCore::Engine::signalCategoriesMetadataLoded, this, [categories] (const QList<KNSCore::Provider::CategoryMetadata>& categoryMetadatas){
for (const KNSCore::Provider::CategoryMetadata& category : categoryMetadatas) {
for (Category* cat : categories) {
if (cat->orFilters().count() > 0 && cat->orFilters().first().second == category.name) {
for (Category* cat : qAsConst(categories)) {
if (cat->orFilters().count() > 0 && cat->orFilters().constFirst().second == category.name) {
cat->setName(category.displayName);
break;
}
......@@ -643,7 +639,7 @@ QString KNSBackend::displayName() const
void KNSBackend::detailsLoaded(const KNSCore::EntryInternal& entry)
{
auto res = resourceForEntry(entry);
res->longDescriptionChanged();
Q_EMIT res->longDescriptionChanged();
}
#include "KNSBackend.moc"
......@@ -111,12 +111,12 @@ QStringList AppPackageKitResource::mimetypes() const
return m_appdata.provided(AppStream::Provided::KindMimetype).items();
}
static const QVector<AppStream::Component::Kind> s_addonKinds = {AppStream::Component::KindAddon, AppStream::Component::KindCodec};
static constexpr auto s_addonKinds = {AppStream::Component::KindAddon, AppStream::Component::KindCodec};
QStringList AppPackageKitResource::categories()
{
auto cats = m_appdata.categories();
if (!s_addonKinds.contains(m_appdata.kind()))
if (!kContainsValue(s_addonKinds, m_appdata.kind()))
cats.append(QStringLiteral("Application"));
return cats;
}
......@@ -166,7 +166,7 @@ AbstractResource::Type AppPackageKitResource::type() const
{
static QString desktop = QString::fromUtf8(qgetenv("XDG_CURRENT_DESKTOP"));
const auto desktops = m_appdata.compulsoryForDesktops();
return s_addonKinds.contains(m_appdata.kind()) ? Addon
return kContainsValue(s_addonKinds, m_appdata.kind()) ? Addon
: (desktops.isEmpty() || !desktops.contains(desktop)) ? Application
: Technical;
}
......
......@@ -176,10 +176,9 @@ static DelayedAppStreamLoad loadAppStream(AppStream::Pool* appdata)
{
DelayedAppStreamLoad ret;
QString error;
ret.correct = appdata->load(&error);
ret.correct = appdata->load();
if (!ret.correct) {
qWarning() << "Could not open the AppStream metadata pool" << error;
qWarning() << "Could not open the AppStream metadata pool" << appdata->lastError();
}
const auto components = appdata->components();
......@@ -293,8 +292,8 @@ void PackageKitBackend::fetchUpdates()
m_hasSecurityUpdates = false;
m_updater->setProgressing(true);
fetchingUpdatesProgressChanged();
Q_EMIT fetchingUpdatesProgressChanged();
}
void PackageKitBackend::addPackageArch(PackageKit::Transaction::Info info, const QString& packageId, const QString& summary)
......@@ -469,7 +468,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters
auto f = [this, filter, stream] {
const auto resources = kTransform<QVector<AbstractResource*>>(m_packages.extendedBy.value(filter.extends), [](AppPackageKitResource* a){ return a; });
if (!resources.isEmpty()) {
Q_EMIT stream->setResources(resources);
stream->setResources(resources);
}
};
runWhenInitialized(f, stream);
......@@ -509,7 +508,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters
auto f = [this, filter, stream] {
auto resources = kFilter<QVector<AbstractResource*>>(m_packages.packages, [](AbstractResource* res) { return res->type() != AbstractResource::Technical && !qobject_cast<PackageKitResource*>(res)->extendsItself(); });
if (!resources.isEmpty()) {
Q_EMIT stream->setResources(resources);
stream->setResources(resources);
}
};
runWhenInitialized(f, stream);
......@@ -521,7 +520,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters
const QStringList ids = kTransform<QStringList>(components, [](const AppStream::Component& comp) { return comp.id(); });
if (!ids.isEmpty()) {
const auto resources = kFilter<QVector<AbstractResource*>>(resourcesByPackageNames<QVector<AbstractResource*>>(ids), [](AbstractResource* res){ return !qobject_cast<PackageKitResource*>(res)->extendsItself(); });
Q_EMIT stream->setResources(resources);
stream->setResources(resources);
}
PackageKit::Transaction * tArch = PackageKit::Daemon::resolve(filter.search, PackageKit::Transaction::FilterArch);
......@@ -535,7 +534,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters
const auto packageId = stream->property("packageId");
if (!packageId.isNull()) {
const auto res = resourcesByPackageNames<QVector<AbstractResource*>>({PackageKit::Daemon::packageName(packageId.toString())});
Q_EMIT stream->setResources(kFilter<QVector<AbstractResource*>>(res, [ids](AbstractResource* res){ return !ids.contains(res->appstreamId()); }));
stream->setResources(kFilter<QVector<AbstractResource*>>(res, [ids](AbstractResource* res){ return !ids.contains(res->appstreamId()); }));
}
}
stream->finish();
......
......@@ -271,8 +271,8 @@ void PackageKitResource::updateDetail(const QString& packageID, const QStringLis
const QString& /*changelog*/, PackageKit::Transaction::UpdateState state, const QDateTime& /*issued*/, const QDateTime& /*updated*/)
{
#if defined(WITH_MARKDOWN)
const char* xx = _updateText.toUtf8().constData();
MMIOT *markdownHandle = mkd_string(xx, _updateText.size(), 0);
const QByteArray xx = _updateText.toUtf8();
MMIOT *markdownHandle = mkd_string(xx.constData(), _updateText.size(), 0);
QString updateText;
if ( !mkd_compile( markdownHandle, MKD_FENCEDCODE | MKD_GITHUBTAGS | MKD_AUTOLINK ) ) {
......
......@@ -38,8 +38,8 @@ int main(int argc, char** argv)
KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(service);
job->start();
QObject::connect(job, &KIO::ApplicationLauncherJob::finished, &app, [&] {
app.exit(job->error());
QObject::connect(job, &KIO::ApplicationLauncherJob::finished, &app, [job] {
QCoreApplication::instance()->exit(job->error());
});
return app.exec();
}
......@@ -70,7 +70,7 @@ ResourcesModel::ResourcesModel(QObject* parent, bool load)
return 0;
int sum = 0;
for(auto backend: m_backends) {
for(auto backend: qAsConst(m_backends)) {
sum += backend->fetchingUpdatesProgress();
}
return sum / m_backends.count();
......
......@@ -160,7 +160,8 @@ void StandardBackendUpdater::refreshProgress()
}
int allProgresses = (m_toUpgrade.size() - m_pendingResources.size()) * 100;
for (auto t: transactions()) {
const auto allTransactions = transactions();
for (auto t: allTransactions) {
allProgresses += t->progress();
}
setProgress(allProgresses / m_toUpgrade.size());
......
......@@ -100,6 +100,10 @@ template <typename Q, typename W>
static bool kContains(const Q& list, W func)
{ return std::any_of(list.begin(), list.end(), func); }
template <typename Q, typename W>
static bool kContainsValue(const Q& list, W value)
{ return std::find(list.begin(), list.end(), value) != list.end(); }
template <typename T>
static QVector<T> kSetToVector(const QSet<T> & set)
{
......
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