From 6b389129af20c9f17b5e30e73361e096bf1f4f6c Mon Sep 17 00:00:00 2001 From: dt <qtc-committer@nokia.com> Date: Tue, 30 Mar 2010 12:58:58 +0200 Subject: [PATCH] Coding style fixes --- .../cmakeprojectmanager/cmakeeditor.cpp | 33 +++++----- src/plugins/cmakeprojectmanager/cmakeeditor.h | 1 - .../cmakeprojectmanager/cmakehighlighter.cpp | 66 +++++++------------ 3 files changed, 39 insertions(+), 61 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp index bfa8379d5e2..1168d810917 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp @@ -54,7 +54,6 @@ CMakeEditorEditable::CMakeEditorEditable(CMakeEditor *editor) Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); m_context << uidm->uniqueIdentifier(CMakeProjectManager::Constants::C_CMAKEEDITOR); m_context << uidm->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); -// m_contexts << uidm->uniqueIdentifier(Qt4ProjectManager::Constants::PROJECT_KIND); } QList<int> CMakeEditorEditable::context() const @@ -103,23 +102,21 @@ TextEditor::BaseTextEditorEditable *CMakeEditor::createEditableInterface() void CMakeEditor::setFontSettings(const TextEditor::FontSettings &fs) { -// TextEditor::BaseTextEditor::setFontSettings(fs); -// return; - CMakeHighlighter *highlighter = qobject_cast<CMakeHighlighter*>(baseTextDocument()->syntaxHighlighter()); - if (!highlighter) - return; - - static QVector<QString> categories; - if (categories.isEmpty()) { - categories << QLatin1String(TextEditor::Constants::C_LABEL) // variables - << QLatin1String(TextEditor::Constants::C_LINK) // functions - << QLatin1String(TextEditor::Constants::C_COMMENT) - << QLatin1String(TextEditor::Constants::C_STRING); - } - - const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories); - highlighter->setFormats(formats.constBegin(), formats.constEnd()); - highlighter->rehighlight(); + CMakeHighlighter *highlighter = qobject_cast<CMakeHighlighter*>(baseTextDocument()->syntaxHighlighter()); + if (!highlighter) + return; + + static QVector<QString> categories; + if (categories.isEmpty()) { + categories << QLatin1String(TextEditor::Constants::C_LABEL) // variables + << QLatin1String(TextEditor::Constants::C_LINK) // functions + << QLatin1String(TextEditor::Constants::C_COMMENT) + << QLatin1String(TextEditor::Constants::C_STRING); + } + + const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories); + highlighter->setFormats(formats.constBegin(), formats.constEnd()); + highlighter->rehighlight(); } // diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.h b/src/plugins/cmakeprojectmanager/cmakeeditor.h index 178696ced79..c4d1bfb8d9c 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.h +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.h @@ -74,7 +74,6 @@ public: bool save(const QString &fileName = QString()); - CMakeEditorFactory *factory() { return m_factory; } TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; } protected: diff --git a/src/plugins/cmakeprojectmanager/cmakehighlighter.cpp b/src/plugins/cmakeprojectmanager/cmakehighlighter.cpp index ffe14305b21..b42a5705862 100644 --- a/src/plugins/cmakeprojectmanager/cmakehighlighter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakehighlighter.cpp @@ -39,11 +39,9 @@ using namespace CMakeProjectManager::Internal; static bool isVariable(const QString &word) { - if (word.length() < 4) { // must be at least "${.}" - return false; - } - - return word.startsWith("${") && word.endsWith('}'); + if (word.length() < 4) // must be at least "${.}" + return false; + return word.startsWith("${") && word.endsWith('}'); } @@ -65,44 +63,34 @@ void CMakeHighlighter::highlightBlock(const QString &text) const QChar c = text.at(i); if (inCommentMode) { setFormat(i, 1, m_formats[CMakeCommentFormat]); - } - else { + } else { if (c == '#') { if (!inStringMode) { inCommentMode = true; setFormat(i, 1, m_formats[CMakeCommentFormat]); buf.clear(); - } - else { + } else { buf += c; } - } - else if (c == '(') { + } else if (c == '(') { if (!inStringMode) { - if (!buf.isEmpty()) { + if (!buf.isEmpty()) setFormat(i - buf.length(), buf.length(), m_formats[CMakeFunctionFormat]); - } buf.clear(); + } else { + buf += c; } - else { - buf += c; - } - } - else if (c.isSpace()) { - if (!inStringMode) { + } else if (c.isSpace()) { + if (!inStringMode) buf.clear(); - } - else { + else buf += c; - } - } - else if (c == '\"') { + } else if (c == '\"') { buf += c; if (inStringMode) { setFormat(i + 1 - buf.length(), buf.length(), m_formats[CMakeStringFormat]); buf.clear(); - } - else { + } else { setFormat(i, 1, m_formats[CMakeStringFormat]); } inStringMode = !inStringMode; @@ -116,24 +104,19 @@ void CMakeHighlighter::highlightBlock(const QString &text) setFormat(i, 1, emptyFormat); buf += c; } - } - else if (c == '$') { - if (inStringMode) { - setFormat(i - buf.length(), buf.length(), m_formats[CMakeStringFormat]); - } - buf.clear(); - buf += c; - setFormat(i, 1, emptyFormat); - } - else if (c == '}') { + } else if (c == '$') { + if (inStringMode) + setFormat(i - buf.length(), buf.length(), m_formats[CMakeStringFormat]); + buf.clear(); buf += c; - if (isVariable(buf)) - { + setFormat(i, 1, emptyFormat); + } else if (c == '}') { + buf += c; + if (isVariable(buf)) { setFormat(i + 1 - buf.length(), buf.length(), m_formats[CMakeVariableFormat]); buf.clear(); } - } - else { + } else { buf += c; setFormat(i, 1, emptyFormat); } @@ -143,8 +126,7 @@ void CMakeHighlighter::highlightBlock(const QString &text) if (inStringMode) { setFormat(i - buf.length(), buf.length(), m_formats[CMakeStringFormat]); setCurrentBlockState(1); - } - else { + } else { setCurrentBlockState(0); } } -- GitLab