diff --git a/core/katvan_completionmanager.cpp b/core/katvan_completionmanager.cpp index c923c3d..0d89593 100644 --- a/core/katvan_completionmanager.cpp +++ b/core/katvan_completionmanager.cpp @@ -174,7 +174,6 @@ QSize CompletionSuggestionDelegate::sizeHint(const QStyleOptionViewItem& option, { QString label = index.data(Qt::DisplayRole).toString(); QString detail = index.data(COMPLETION_DETAIL_ROLE).toString(); - QIcon icon = qvariant_cast(index.data(Qt::DecorationRole)); QFontMetrics labelMetrics { d_labelFont }; QFontMetrics detailMetrics = option.fontMetrics; @@ -182,7 +181,8 @@ QSize CompletionSuggestionDelegate::sizeHint(const QStyleOptionViewItem& option, int width = labelMetrics.horizontalAdvance(label); int height = labelMetrics.height(); - for (QString line : detail.split(QChar::LineFeed)) { + const QStringList lines = detail.split(QChar::LineFeed); + for (const QString& line : lines) { width = qMax(width, detailMetrics.horizontalAdvance(line)); height += detailMetrics.height(); } @@ -239,8 +239,10 @@ void CompletionManager::completionsReady(int line, int column, QByteArray comple return; } + const QJsonArray completionsArray = doc.array(); + QList suggestions; - for (const QJsonValue& value : doc.array()) { + for (const QJsonValue& value : completionsArray) { suggestions.append(value.toObject()); } d_model->setSuggestions(suggestions); diff --git a/core/katvan_diagnosticsmodel.cpp b/core/katvan_diagnosticsmodel.cpp index e56de72..cd8fe0b 100644 --- a/core/katvan_diagnosticsmodel.cpp +++ b/core/katvan_diagnosticsmodel.cpp @@ -148,7 +148,8 @@ QVariant DiagnosticsModel::data(const QModelIndex& index, int role) const } else if (index.column() == COLUMN_MESSAGE && (role == Qt::DisplayRole || role == Qt::ToolTipRole)) { QString message = diagnostic.message(); - for (const QString& hint : diagnostic.hints()) { + QStringList hints = diagnostic.hints(); + for (const QString& hint : std::as_const(hints)) { message += QChar::LineFeed + QStringLiteral("Hint: ") + hint; } return message; diff --git a/core/katvan_document.h b/core/katvan_document.h index 2b9f884..f4bf6ab 100644 --- a/core/katvan_document.h +++ b/core/katvan_document.h @@ -39,8 +39,8 @@ enum class BlockDataKind template concept BlockDataSection = requires { - std::derived_from; - std::same_as; + requires std::derived_from; + requires std::same_as; }; class BlockData : public QTextBlockUserData diff --git a/core/katvan_previewerview.cpp b/core/katvan_previewerview.cpp index 69c5546..5b81dbe 100644 --- a/core/katvan_previewerview.cpp +++ b/core/katvan_previewerview.cpp @@ -127,7 +127,7 @@ void PreviewerView::setPages(QList pages) else if (hadPages) { // In case of new content in an already open preview - invalidate // only pages that have actually changed - QList keys = d_renderCache.keys(); + const QList keys = d_renderCache.keys(); for (int key : keys) { if (key >= pages.size()) { d_renderCache.remove(key); @@ -368,7 +368,8 @@ void PreviewerView::scrollerStateChanged() void PreviewerView::invalidateAllRenderCache() { - for (int page : d_renderCache.keys()) { + const QList pages = d_renderCache.keys(); + for (int page : pages) { d_renderCache.object(page)->invalidated = true; } viewport()->update(); diff --git a/core/katvan_spellchecker_hunspell.cpp b/core/katvan_spellchecker_hunspell.cpp index b72e5ea..82f32b5 100644 --- a/core/katvan_spellchecker_hunspell.cpp +++ b/core/katvan_spellchecker_hunspell.cpp @@ -319,7 +319,8 @@ void HunspellSpellChecker::setPersonalDictionaryPath() loadPersonalDictionary(); - for (const QString& file : d_watcher->files()) { + const QStringList watchedFiles = d_watcher->files(); + for (const QString& file : watchedFiles) { d_watcher->removePath(file); } d_watcher->addPath(d_personalDictionaryPath); diff --git a/core/katvan_typstdriverwrapper.cpp b/core/katvan_typstdriverwrapper.cpp index 87ea06e..88fea26 100644 --- a/core/katvan_typstdriverwrapper.cpp +++ b/core/katvan_typstdriverwrapper.cpp @@ -94,7 +94,7 @@ void TypstDriverWrapper::resetInputFile(const QString& sourceFileName) hasPending = true; } if (!d_pendingEdits.isEmpty()) { - for (const auto& edit : d_pendingEdits) { + for (const auto& edit : std::as_const(d_pendingEdits)) { applyContentEdit(edit.from, edit.to, edit.text); }