diff --git a/src/plugins/clearcase/clearcaseeditor.cpp b/src/plugins/clearcase/clearcaseeditor.cpp index db361a562421bf063503648d0f4dbee672c16a59..17622062af86dd182e50e42fa45a55ea8c7829d5 100644 --- a/src/plugins/clearcase/clearcaseeditor.cpp +++ b/src/plugins/clearcase/clearcaseeditor.cpp @@ -35,7 +35,7 @@ #include "clearcaseplugin.h" #include <utils/qtcassert.h> -#include <vcsbase/diffhighlighter.h> +#include <vcsbase/diffandloghighlighter.h> #include <QDir> #include <QFileInfo> diff --git a/src/plugins/cvs/cvseditor.cpp b/src/plugins/cvs/cvseditor.cpp index b7ba81a79a00a37637833827b584977724b794d4..2f532f4c38ce5581fa5591b14e4b08a745d289e3 100644 --- a/src/plugins/cvs/cvseditor.cpp +++ b/src/plugins/cvs/cvseditor.cpp @@ -35,7 +35,7 @@ #include "cvsconstants.h" #include <utils/qtcassert.h> -#include <vcsbase/diffhighlighter.h> +#include <vcsbase/diffandloghighlighter.h> #include <QDebug> #include <QTextCursor> diff --git a/src/plugins/mercurial/mercurialeditor.cpp b/src/plugins/mercurial/mercurialeditor.cpp index 6d8a2bc936ed0137f074d66dd5eb232b6c2db5d3..11215e3a38bd9354f27fef6dfa1fbc600cd0995f 100644 --- a/src/plugins/mercurial/mercurialeditor.cpp +++ b/src/plugins/mercurial/mercurialeditor.cpp @@ -35,7 +35,7 @@ #include "mercurialclient.h" #include <coreplugin/editormanager/editormanager.h> -#include <vcsbase/diffhighlighter.h> +#include <vcsbase/diffandloghighlighter.h> #include <QString> #include <QTextCursor> diff --git a/src/plugins/perforce/perforceeditor.cpp b/src/plugins/perforce/perforceeditor.cpp index ee4359a919cd5460c50222b5bb86fe4ac7c77a99..50c449be8ba43eddef00c9ab813ca7c76dbe25c3 100644 --- a/src/plugins/perforce/perforceeditor.cpp +++ b/src/plugins/perforce/perforceeditor.cpp @@ -36,7 +36,7 @@ #include <coreplugin/editormanager/editormanager.h> #include <utils/qtcassert.h> -#include <vcsbase/diffhighlighter.h> +#include <vcsbase/diffandloghighlighter.h> #include <QDebug> #include <QFileInfo> diff --git a/src/plugins/subversion/subversioneditor.cpp b/src/plugins/subversion/subversioneditor.cpp index 57e5050d7ba4204de31656c718845359f9bb51bf..f67c30499a95c95172ae77d3611c3c5e4b2d067f 100644 --- a/src/plugins/subversion/subversioneditor.cpp +++ b/src/plugins/subversion/subversioneditor.cpp @@ -35,7 +35,7 @@ #include "subversionconstants.h" #include <utils/qtcassert.h> -#include <vcsbase/diffhighlighter.h> +#include <vcsbase/diffandloghighlighter.h> #include <QDebug> #include <QFileInfo> diff --git a/src/plugins/vcsbase/diffhighlighter.cpp b/src/plugins/vcsbase/diffandloghighlighter.cpp similarity index 86% rename from src/plugins/vcsbase/diffhighlighter.cpp rename to src/plugins/vcsbase/diffandloghighlighter.cpp index 342451a70937a932a50f1b06b59a8e6747d1c396..f2491cbdebb41a2f3cc3b089abadba30e1445a99 100644 --- a/src/plugins/vcsbase/diffhighlighter.cpp +++ b/src/plugins/vcsbase/diffandloghighlighter.cpp @@ -28,7 +28,7 @@ ** ****************************************************************************/ -#include "diffhighlighter.h" +#include "diffandloghighlighter.h" #include <texteditor/textdocumentlayout.h> @@ -38,11 +38,11 @@ #include <QRegExp> /*! - \class VcsBase::DiffHighlighter + \class VcsBase::DiffAndLogHighlighter - \brief The DiffHighlighter class provides a highlighter for diffs. + \brief The DiffAndLogHighlighter class provides a highlighter for diffs and log editors. - Parametrizable by the file indicator, which is for example '^====' in case of p4: + Diff is parametrizable by the file indicator, which is for example '^====' in case of p4: \code ==== //depot/research/main/qdynamicmainwindow3/qdynamicdockwidgetlayout_p.h#34 (text) ==== \endcode @@ -66,7 +66,7 @@ static const int LOCATION_LEVEL = 2; namespace VcsBase { namespace Internal { -// Formats used by DiffHighlighter +// Formats used by DiffAndLogHighlighter enum DiffFormats { DiffTextFormat, DiffInFormat, @@ -92,13 +92,13 @@ static inline QTextCharFormat invertedColorFormat(const QTextCharFormat &in) return rc; } -// --- DiffHighlighterPrivate -class DiffHighlighterPrivate +// --- DiffAndLogHighlighterPrivate +class DiffAndLogHighlighterPrivate { - DiffHighlighter *q_ptr; - Q_DECLARE_PUBLIC(DiffHighlighter) + DiffAndLogHighlighter *q_ptr; + Q_DECLARE_PUBLIC(DiffAndLogHighlighter) public: - DiffHighlighterPrivate(const QRegExp &filePattern); + DiffAndLogHighlighterPrivate(const QRegExp &filePattern); Internal::DiffFormats analyzeLine(const QString &block) const; void updateOtherFormats(); @@ -112,7 +112,7 @@ public: Internal::FoldingState m_foldingState; }; -DiffHighlighterPrivate::DiffHighlighterPrivate(const QRegExp &filePattern) : +DiffAndLogHighlighterPrivate::DiffAndLogHighlighterPrivate(const QRegExp &filePattern) : q_ptr(0), m_filePattern(filePattern), m_locationIndicator(QLatin1String("@@")), @@ -123,7 +123,7 @@ DiffHighlighterPrivate::DiffHighlighterPrivate(const QRegExp &filePattern) : QTC_CHECK(filePattern.isValid()); } -Internal::DiffFormats DiffHighlighterPrivate::analyzeLine(const QString &text) const +Internal::DiffFormats DiffAndLogHighlighterPrivate::analyzeLine(const QString &text) const { // Do not match on git "--- a/" as a deleted line, check // file first @@ -138,21 +138,21 @@ Internal::DiffFormats DiffHighlighterPrivate::analyzeLine(const QString &text) c return Internal::DiffTextFormat; } -void DiffHighlighterPrivate::updateOtherFormats() +void DiffAndLogHighlighterPrivate::updateOtherFormats() { - Q_Q(DiffHighlighter); + Q_Q(DiffAndLogHighlighter); m_addedTrailingWhiteSpaceFormat = invertedColorFormat(q->formatForCategory(Internal::DiffInFormat)); } -// --- DiffHighlighter -DiffHighlighter::DiffHighlighter(const QRegExp &filePattern) : +// --- DiffAndLogHighlighter +DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern) : TextEditor::SyntaxHighlighter(static_cast<QTextDocument *>(0)), - d_ptr(new DiffHighlighterPrivate(filePattern)) + d_ptr(new DiffAndLogHighlighterPrivate(filePattern)) { d_ptr->q_ptr = this; - Q_D(DiffHighlighter); + Q_D(DiffAndLogHighlighter); static QVector<TextEditor::TextStyle> categories; if (categories.isEmpty()) { @@ -166,7 +166,7 @@ DiffHighlighter::DiffHighlighter(const QRegExp &filePattern) : d->updateOtherFormats(); } -DiffHighlighter::~DiffHighlighter() +DiffAndLogHighlighter::~DiffAndLogHighlighter() { } @@ -185,9 +185,9 @@ static inline int trimmedLength(const QString &in) * 1 for all the following lines of the diff header and all @@ lines. * 2 for everything else */ -void DiffHighlighter::highlightBlock(const QString &text) +void DiffAndLogHighlighter::highlightBlock(const QString &text) { - Q_D(DiffHighlighter); + Q_D(DiffAndLogHighlighter); if (text.isEmpty()) return; @@ -265,9 +265,9 @@ void DiffHighlighter::highlightBlock(const QString &text) } } -void DiffHighlighter::setFontSettings(const TextEditor::FontSettings &fontSettings) +void DiffAndLogHighlighter::setFontSettings(const TextEditor::FontSettings &fontSettings) { - Q_D(DiffHighlighter); + Q_D(DiffAndLogHighlighter); SyntaxHighlighter::setFontSettings(fontSettings); d->updateOtherFormats(); } diff --git a/src/plugins/vcsbase/diffhighlighter.h b/src/plugins/vcsbase/diffandloghighlighter.h similarity index 82% rename from src/plugins/vcsbase/diffhighlighter.h rename to src/plugins/vcsbase/diffandloghighlighter.h index a2259abf403dce2bb65a4577005f91de4b7a2a42..801b75ea2cda70ba0841a1f7a2e2c27e7a15e7b1 100644 --- a/src/plugins/vcsbase/diffhighlighter.h +++ b/src/plugins/vcsbase/diffandloghighlighter.h @@ -28,8 +28,8 @@ ** ****************************************************************************/ -#ifndef DIFFHIGHLIGHTER_H -#define DIFFHIGHLIGHTER_H +#ifndef DIFFANDLOGHIGHLIGHTER_H +#define DIFFANDLOGHIGHLIGHTER_H #include "vcsbase_global.h" @@ -45,24 +45,24 @@ namespace TextEditor { class FontSettingsPage; } namespace VcsBase { -class DiffHighlighterPrivate; +class DiffAndLogHighlighterPrivate; -class VCSBASE_EXPORT DiffHighlighter : public TextEditor::SyntaxHighlighter +class VCSBASE_EXPORT DiffAndLogHighlighter : public TextEditor::SyntaxHighlighter { Q_OBJECT - Q_DECLARE_PRIVATE(DiffHighlighter) + Q_DECLARE_PRIVATE(DiffAndLogHighlighter) public: - explicit DiffHighlighter(const QRegExp &filePattern); - ~DiffHighlighter(); + explicit DiffAndLogHighlighter(const QRegExp &filePattern); + ~DiffAndLogHighlighter(); void highlightBlock(const QString &text); virtual void setFontSettings(const TextEditor::FontSettings &fontSettings); private: - QScopedPointer<DiffHighlighterPrivate> d_ptr; + QScopedPointer<DiffAndLogHighlighterPrivate> d_ptr; }; } // namespace VcsBase -#endif // DIFFHIGHLIGHTER_H +#endif // DIFFANDLOGHIGHLIGHTER_H diff --git a/src/plugins/vcsbase/vcsbase.pro b/src/plugins/vcsbase/vcsbase.pro index 5f4eae91c023cf39e4709f5b74833b4699c5d8dd..80f0fcbeb5294df037ec6d927762b7876bab0e17 100644 --- a/src/plugins/vcsbase/vcsbase.pro +++ b/src/plugins/vcsbase/vcsbase.pro @@ -9,7 +9,7 @@ HEADERS += vcsbase_global.h \ corelistener.h \ vcsbaseplugin.h \ baseannotationhighlighter.h \ - diffhighlighter.h \ + diffandloghighlighter.h \ vcsbaseeditor.h \ vcsbasesubmiteditor.h \ basevcseditorfactory.h \ @@ -40,7 +40,7 @@ SOURCES += vcsplugin.cpp \ wizard/vcsjsextension.cpp \ corelistener.cpp \ baseannotationhighlighter.cpp \ - diffhighlighter.cpp \ + diffandloghighlighter.cpp \ vcsbaseeditor.cpp \ vcsbasesubmiteditor.cpp \ basevcseditorfactory.cpp \ diff --git a/src/plugins/vcsbase/vcsbase.qbs b/src/plugins/vcsbase/vcsbase.qbs index 111ec88962806d33329bdd55015755ab07dc03db..5b8d7a335815fe50c0818589b1e5eca5ba39d8b4 100644 --- a/src/plugins/vcsbase/vcsbase.qbs +++ b/src/plugins/vcsbase/vcsbase.qbs @@ -39,8 +39,8 @@ QtcPlugin { "commonvcssettings.h", "corelistener.cpp", "corelistener.h", - "diffhighlighter.cpp", - "diffhighlighter.h", + "diffandloghighlighter.cpp", + "diffandloghighlighter.h", "nicknamedialog.cpp", "nicknamedialog.h", "nicknamedialog.ui", diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index 7499d8b836c28e3fbc0dae73770fcbccba9ea257..fcfaa7976bb5cd48f1ae079d5d0fb0bedc4e8db6 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -29,7 +29,7 @@ ****************************************************************************/ #include "vcsbaseeditor.h" -#include "diffhighlighter.h" +#include "diffandloghighlighter.h" #include "baseannotationhighlighter.h" #include "basevcseditorfactory.h" #include "vcsbaseplugin.h" @@ -736,7 +736,7 @@ void VcsBaseEditorWidget::init() break; } if (hasDiff()) { - auto dh = new DiffHighlighter(d->m_diffFilePattern); + auto dh = new DiffAndLogHighlighter(d->m_diffFilePattern); setCodeFoldingSupported(true); textDocument()->setSyntaxHighlighter(dh); } @@ -1120,9 +1120,11 @@ void VcsBaseEditorWidget::jumpToChangeFromDiff(QTextCursor cursor) const QChar deletionIndicator = QLatin1Char('-'); // find nearest change hunk QTextBlock block = cursor.block(); - if (TextDocumentLayout::foldingIndent(block) <= 1) - /* We are in a diff header, do not jump anywhere. DiffHighlighter sets the foldingIndent for us. */ + if (TextDocumentLayout::foldingIndent(block) <= 1) { + // We are in a diff header, do not jump anywhere. + // DiffAndLogHighlighter sets the foldingIndent for us. return; + } for ( ; block.isValid() ; block = block.previous()) { const QString line = block.text(); if (checkChunkLine(line, &chunkStart)) { @@ -1159,9 +1161,11 @@ DiffChunk VcsBaseEditorWidget::diffChunk(QTextCursor cursor) const QTC_ASSERT(hasDiff(), return rc); // Search back for start of chunk. QTextBlock block = cursor.block(); - if (block.isValid() && TextDocumentLayout::foldingIndent(block) <= 1) - /* We are in a diff header, not in a chunk! DiffHighlighter sets the foldingIndent for us. */ + if (block.isValid() && TextDocumentLayout::foldingIndent(block) <= 1) { + // We are in a diff header, not in a chunk! + // DiffAndLogHighlighter sets the foldingIndent for us. return rc; + } int chunkStart = 0; for ( ; block.isValid() ; block = block.previous()) {