Commit 0c53561c authored by Marco Bubke's avatar Marco Bubke

Clang: Refactor icon setting in ClangTextMark

Change-Id: Ie0c2185d83d3b8344c2f88467236c1eac3b07a6b
Reviewed-by: default avatarMarco Bubke <marco.bubke@theqtcompany.com>
parent a9193243
...@@ -50,7 +50,8 @@ bool isWarningOrNote(ClangBackEnd::DiagnosticSeverity severity) ...@@ -50,7 +50,8 @@ bool isWarningOrNote(ClangBackEnd::DiagnosticSeverity severity)
case DiagnosticSeverity::Ignored: case DiagnosticSeverity::Ignored:
case DiagnosticSeverity::Note: case DiagnosticSeverity::Note:
case DiagnosticSeverity::Warning: return true; case DiagnosticSeverity::Warning: return true;
default: return false; case DiagnosticSeverity::Error:
case DiagnosticSeverity::Fatal: return false;
} }
Q_UNREACHABLE(); Q_UNREACHABLE();
...@@ -61,21 +62,24 @@ Core::Id cartegoryForSeverity(ClangBackEnd::DiagnosticSeverity severity) ...@@ -61,21 +62,24 @@ Core::Id cartegoryForSeverity(ClangBackEnd::DiagnosticSeverity severity)
return isWarningOrNote(severity) ? Constants::CLANG_WARNING : Constants::CLANG_ERROR; return isWarningOrNote(severity) ? Constants::CLANG_WARNING : Constants::CLANG_ERROR;
} }
const QIcon &iconForSeverity(ClangBackEnd::DiagnosticSeverity severity)
{
static const QIcon errorIcon{QLatin1String(Core::Constants::ICON_ERROR)};
static const QIcon warningIcon{QLatin1String(Core::Constants::ICON_WARNING)};
return isWarningOrNote(severity) ? warningIcon : errorIcon;
}
} // anonymous namespace } // anonymous namespace
ClangTextMark::ClangTextMark(const QString &fileName, int lineNumber, ClangBackEnd::DiagnosticSeverity severity) ClangTextMark::ClangTextMark(const QString &fileName, int lineNumber, ClangBackEnd::DiagnosticSeverity severity)
: TextEditor::TextMark(fileName, lineNumber, cartegoryForSeverity(severity)) : TextEditor::TextMark(fileName, lineNumber, cartegoryForSeverity(severity))
{ {
setPriority(TextEditor::TextMark::HighPriority); setPriority(TextEditor::TextMark::HighPriority);
setIcon(iconForSeverity(severity)); setIcon(severity);
}
void ClangTextMark::setIcon(ClangBackEnd::DiagnosticSeverity severity)
{
static const QIcon errorIcon{QLatin1String(Core::Constants::ICON_ERROR)};
static const QIcon warningIcon{QLatin1String(Core::Constants::ICON_WARNING)};
if (isWarningOrNote(severity))
TextMark::setIcon(warningIcon);
else
TextMark::setIcon(errorIcon);
} }
ClangTextMark::ClangTextMark(ClangTextMark &&other) Q_DECL_NOEXCEPT ClangTextMark::ClangTextMark(ClangTextMark &&other) Q_DECL_NOEXCEPT
......
...@@ -46,6 +46,9 @@ public: ...@@ -46,6 +46,9 @@ public:
ClangTextMark(ClangTextMark &other) = delete; ClangTextMark(ClangTextMark &other) = delete;
ClangTextMark &operator=(ClangTextMark &other) = delete; ClangTextMark &operator=(ClangTextMark &other) = delete;
private:
void setIcon(ClangBackEnd::DiagnosticSeverity severity);
}; };
} // namespace ClangCodeModel } // namespace ClangCodeModel
......
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