plugin: fix clazy warnings

This commit is contained in:
2 * r + 2 * t 2025-09-23 17:34:20 +10:00
parent 0a02e0d407
commit 7aaa14438f
4 changed files with 14 additions and 13 deletions

View file

@ -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<QString> 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<QString>& 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<QString>& removedPaths, const QSet
int insertStart = -1;
int prevRow = -1;
QList<FileSystemEntry*> 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);

View file

@ -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:

View file

@ -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<QString> newIds;
for (auto entry : m_entries) {
for (const auto& entry : std::as_const(m_entries)) {
newIds.insert(entry->property("id").toString());
}
QList<AppEntry*> 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);

View file

@ -69,7 +69,7 @@ public:
[[nodiscard]] QList<Toast*> 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();