From 7aaa14438f7d674707d4b8591364ee457248d0e6 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Tue, 23 Sep 2025 17:34:20 +1000 Subject: plugin: fix clazy warnings --- plugin/src/Caelestia/Models/filesystemmodel.cpp | 12 ++++++------ plugin/src/Caelestia/Models/filesystemmodel.hpp | 2 +- plugin/src/Caelestia/appdb.cpp | 11 ++++++----- plugin/src/Caelestia/toaster.hpp | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) (limited to 'plugin/src/Caelestia') diff --git a/plugin/src/Caelestia/Models/filesystemmodel.cpp b/plugin/src/Caelestia/Models/filesystemmodel.cpp index 9cebaec..0eadebb 100644 --- a/plugin/src/Caelestia/Models/filesystemmodel.cpp +++ b/plugin/src/Caelestia/Models/filesystemmodel.cpp @@ -114,7 +114,7 @@ void FileSystemModel::setPath(const QString& path) { m_dir.setPath(m_path); - for (const auto& entry : m_entries) { + for (const auto& entry : std::as_const(m_entries)) { entry->updateRelativePath(m_dir); } @@ -292,10 +292,9 @@ void FileSystemModel::updateEntriesForDir(const QString& dir) { const auto showHidden = m_showHidden; const auto filter = m_filter; const auto nameFilters = m_nameFilters; - const auto baseDir = m_dir; QSet oldPaths; - for (const auto& entry : m_entries) { + for (const auto& entry : std::as_const(m_entries)) { oldPaths << entry->path(); } @@ -306,7 +305,8 @@ void FileSystemModel::updateEntriesForDir(const QString& dir) { if (filter == Images) { QStringList extraNameFilters = nameFilters; - for (const auto& format : QImageReader::supportedImageFormats()) { + const auto formats = QImageReader::supportedImageFormats(); + for (const auto& format : formats) { extraNameFilters << "*." + format; } @@ -400,7 +400,7 @@ void FileSystemModel::applyChanges(const QSet& removedPaths, const QSet int start = -1; int end = -1; - for (int idx : removedIndices) { + for (int idx : std::as_const(removedIndices)) { if (start == -1) { start = idx; end = idx; @@ -438,7 +438,7 @@ void FileSystemModel::applyChanges(const QSet& removedPaths, const QSet int insertStart = -1; int prevRow = -1; QList batchItems; - for (const auto& entry : newEntries) { + for (const auto& entry : std::as_const(newEntries)) { const auto it = std::lower_bound( m_entries.begin(), m_entries.end(), entry, [this](const FileSystemEntry* a, const FileSystemEntry* b) { return compareEntries(a, b); diff --git a/plugin/src/Caelestia/Models/filesystemmodel.hpp b/plugin/src/Caelestia/Models/filesystemmodel.hpp index 07fb1a1..822babd 100644 --- a/plugin/src/Caelestia/Models/filesystemmodel.hpp +++ b/plugin/src/Caelestia/Models/filesystemmodel.hpp @@ -121,7 +121,7 @@ signals: void nameFiltersChanged(); void entriesChanged(); - void added(const FileSystemEntry* entry); + void added(const caelestia::FileSystemEntry* entry); void removed(const QString& path); private: diff --git a/plugin/src/Caelestia/appdb.cpp b/plugin/src/Caelestia/appdb.cpp index 19db096..1fa2d77 100644 --- a/plugin/src/Caelestia/appdb.cpp +++ b/plugin/src/Caelestia/appdb.cpp @@ -154,7 +154,7 @@ void AppDb::incrementFrequency(const QString& id) { query.bindValue(":id", id); query.exec(); - for (auto app : m_apps) { + for (auto* app : std::as_const(m_apps)) { if (app->id() == id) { const auto before = apps(); @@ -186,7 +186,7 @@ quint32 AppDb::getFrequency(const QString& id) const { } void AppDb::updateAppFrequencies() { - for (auto app : m_apps) { + for (auto* app : std::as_const(m_apps)) { app->setFrequency(getFrequency(app->id())); } } @@ -194,7 +194,7 @@ void AppDb::updateAppFrequencies() { void AppDb::updateApps() { bool dirty = false; - for (auto entry : m_entries) { + for (const auto& entry : std::as_const(m_entries)) { const auto id = entry->property("id").toString(); if (!m_apps.contains(id)) { dirty = true; @@ -203,12 +203,13 @@ void AppDb::updateApps() { } QSet newIds; - for (auto entry : m_entries) { + for (const auto& entry : std::as_const(m_entries)) { newIds.insert(entry->property("id").toString()); } QList toDelete; - for (auto id : m_apps.keys()) { + for (auto it = m_apps.keyBegin(); it != m_apps.keyEnd(); ++it) { + const auto& id = *it; if (!newIds.contains(id)) { dirty = true; toDelete << m_apps.take(id); diff --git a/plugin/src/Caelestia/toaster.hpp b/plugin/src/Caelestia/toaster.hpp index 22da212..0197aa1 100644 --- a/plugin/src/Caelestia/toaster.hpp +++ b/plugin/src/Caelestia/toaster.hpp @@ -69,7 +69,7 @@ public: [[nodiscard]] QList toasts() const; Q_INVOKABLE void toast(const QString& title, const QString& message, const QString& icon = QString(), - Toast::Type type = Toast::Type::Info, int timeout = 5000); + caelestia::Toast::Type type = Toast::Type::Info, int timeout = 5000); signals: void toastsChanged(); -- cgit v1.2.3-freya