Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
IgKh committed Feb 5, 2025
1 parent 2a570bd commit e1e6eaf
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
8 changes: 5 additions & 3 deletions core/katvan_completionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ 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<QIcon>(index.data(Qt::DecorationRole));

QFontMetrics labelMetrics { d_labelFont };
QFontMetrics detailMetrics = option.fontMetrics;

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();
}
Expand Down Expand Up @@ -239,8 +239,10 @@ void CompletionManager::completionsReady(int line, int column, QByteArray comple
return;
}

const QJsonArray completionsArray = doc.array();

QList<QJsonObject> suggestions;
for (const QJsonValue& value : doc.array()) {
for (const QJsonValue& value : completionsArray) {
suggestions.append(value.toObject());
}
d_model->setSuggestions(suggestions);
Expand Down
3 changes: 2 additions & 1 deletion core/katvan_diagnosticsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions core/katvan_document.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ enum class BlockDataKind

template <typename T>
concept BlockDataSection = requires {
std::derived_from<T, QTextBlockUserData>;
std::same_as<decltype(T::DATA_KIND), BlockDataKind>;
requires std::derived_from<T, QTextBlockUserData>;
requires std::same_as<decltype(T::DATA_KIND), const BlockDataKind>;
};

class BlockData : public QTextBlockUserData
Expand Down
5 changes: 3 additions & 2 deletions core/katvan_previewerview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void PreviewerView::setPages(QList<typstdriver::PreviewPageData> pages)
else if (hadPages) {
// In case of new content in an already open preview - invalidate
// only pages that have actually changed
QList<int> keys = d_renderCache.keys();
const QList<int> keys = d_renderCache.keys();
for (int key : keys) {
if (key >= pages.size()) {
d_renderCache.remove(key);
Expand Down Expand Up @@ -368,7 +368,8 @@ void PreviewerView::scrollerStateChanged()

void PreviewerView::invalidateAllRenderCache()
{
for (int page : d_renderCache.keys()) {
const QList<int> pages = d_renderCache.keys();
for (int page : pages) {
d_renderCache.object(page)->invalidated = true;
}
viewport()->update();
Expand Down
3 changes: 2 additions & 1 deletion core/katvan_spellchecker_hunspell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion core/katvan_typstdriverwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit e1e6eaf

Please # to comment.