diff options
author | Marco Bubke <marco.bubke@theqtcompany.com> | 2015-09-21 16:09:53 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@theqtcompany.com> | 2015-09-23 16:10:25 +0000 |
commit | 0c53561c757d957e729a7161bd8cb0ce70605dbd (patch) | |
tree | ecf087447646f682793c374d1a56a80bb363f37e /src/plugins/clangcodemodel | |
parent | a9193243b9b1b362d9c5537453e3519f2037f281 (diff) | |
download | qt-creator-0c53561c757d957e729a7161bd8cb0ce70605dbd.tar.gz |
Clang: Refactor icon setting in ClangTextMark
Change-Id: Ie0c2185d83d3b8344c2f88467236c1eac3b07a6b
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
Diffstat (limited to 'src/plugins/clangcodemodel')
-rw-r--r-- | src/plugins/clangcodemodel/clangtextmark.cpp | 24 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/clangtextmark.h | 3 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/plugins/clangcodemodel/clangtextmark.cpp b/src/plugins/clangcodemodel/clangtextmark.cpp index 156f4c575d..dfb1905992 100644 --- a/src/plugins/clangcodemodel/clangtextmark.cpp +++ b/src/plugins/clangcodemodel/clangtextmark.cpp @@ -50,7 +50,8 @@ bool isWarningOrNote(ClangBackEnd::DiagnosticSeverity severity) case DiagnosticSeverity::Ignored: case DiagnosticSeverity::Note: case DiagnosticSeverity::Warning: return true; - default: return false; + case DiagnosticSeverity::Error: + case DiagnosticSeverity::Fatal: return false; } Q_UNREACHABLE(); @@ -61,21 +62,24 @@ Core::Id cartegoryForSeverity(ClangBackEnd::DiagnosticSeverity severity) 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 ClangTextMark::ClangTextMark(const QString &fileName, int lineNumber, ClangBackEnd::DiagnosticSeverity severity) : TextEditor::TextMark(fileName, lineNumber, cartegoryForSeverity(severity)) { 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 diff --git a/src/plugins/clangcodemodel/clangtextmark.h b/src/plugins/clangcodemodel/clangtextmark.h index 5d7752ad43..55aa3c68ef 100644 --- a/src/plugins/clangcodemodel/clangtextmark.h +++ b/src/plugins/clangcodemodel/clangtextmark.h @@ -46,6 +46,9 @@ public: ClangTextMark(ClangTextMark &other) = delete; ClangTextMark &operator=(ClangTextMark &other) = delete; + +private: + void setIcon(ClangBackEnd::DiagnosticSeverity severity); }; } // namespace ClangCodeModel |