VCS: Rename DiffHighlighter -> DiffAndLogHighlighter

It is also used for log editors

Change-Id: I8755d2aaa717ca47b0d9bbf935b121d4e099ef1b
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-03-25 10:31:55 +02:00
committed by Orgad Shaneh
parent f98c89ebf3
commit 9877221a3d
10 changed files with 51 additions and 47 deletions

View File

@@ -35,7 +35,7 @@
#include "clearcaseplugin.h" #include "clearcaseplugin.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <vcsbase/diffhighlighter.h> #include <vcsbase/diffandloghighlighter.h>
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>

View File

@@ -35,7 +35,7 @@
#include "cvsconstants.h" #include "cvsconstants.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <vcsbase/diffhighlighter.h> #include <vcsbase/diffandloghighlighter.h>
#include <QDebug> #include <QDebug>
#include <QTextCursor> #include <QTextCursor>

View File

@@ -35,7 +35,7 @@
#include "mercurialclient.h" #include "mercurialclient.h"
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <vcsbase/diffhighlighter.h> #include <vcsbase/diffandloghighlighter.h>
#include <QString> #include <QString>
#include <QTextCursor> #include <QTextCursor>

View File

@@ -36,7 +36,7 @@
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <vcsbase/diffhighlighter.h> #include <vcsbase/diffandloghighlighter.h>
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>

View File

@@ -35,7 +35,7 @@
#include "subversionconstants.h" #include "subversionconstants.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <vcsbase/diffhighlighter.h> #include <vcsbase/diffandloghighlighter.h>
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "diffhighlighter.h" #include "diffandloghighlighter.h"
#include <texteditor/textdocumentlayout.h> #include <texteditor/textdocumentlayout.h>
@@ -38,11 +38,11 @@
#include <QRegExp> #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 \code
==== //depot/research/main/qdynamicmainwindow3/qdynamicdockwidgetlayout_p.h#34 (text) ==== ==== //depot/research/main/qdynamicmainwindow3/qdynamicdockwidgetlayout_p.h#34 (text) ====
\endcode \endcode
@@ -66,7 +66,7 @@ static const int LOCATION_LEVEL = 2;
namespace VcsBase { namespace VcsBase {
namespace Internal { namespace Internal {
// Formats used by DiffHighlighter // Formats used by DiffAndLogHighlighter
enum DiffFormats { enum DiffFormats {
DiffTextFormat, DiffTextFormat,
DiffInFormat, DiffInFormat,
@@ -92,13 +92,13 @@ static inline QTextCharFormat invertedColorFormat(const QTextCharFormat &in)
return rc; return rc;
} }
// --- DiffHighlighterPrivate // --- DiffAndLogHighlighterPrivate
class DiffHighlighterPrivate class DiffAndLogHighlighterPrivate
{ {
DiffHighlighter *q_ptr; DiffAndLogHighlighter *q_ptr;
Q_DECLARE_PUBLIC(DiffHighlighter) Q_DECLARE_PUBLIC(DiffAndLogHighlighter)
public: public:
DiffHighlighterPrivate(const QRegExp &filePattern); DiffAndLogHighlighterPrivate(const QRegExp &filePattern);
Internal::DiffFormats analyzeLine(const QString &block) const; Internal::DiffFormats analyzeLine(const QString &block) const;
void updateOtherFormats(); void updateOtherFormats();
@@ -112,7 +112,7 @@ public:
Internal::FoldingState m_foldingState; Internal::FoldingState m_foldingState;
}; };
DiffHighlighterPrivate::DiffHighlighterPrivate(const QRegExp &filePattern) : DiffAndLogHighlighterPrivate::DiffAndLogHighlighterPrivate(const QRegExp &filePattern) :
q_ptr(0), q_ptr(0),
m_filePattern(filePattern), m_filePattern(filePattern),
m_locationIndicator(QLatin1String("@@")), m_locationIndicator(QLatin1String("@@")),
@@ -123,7 +123,7 @@ DiffHighlighterPrivate::DiffHighlighterPrivate(const QRegExp &filePattern) :
QTC_CHECK(filePattern.isValid()); 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 // Do not match on git "--- a/" as a deleted line, check
// file first // file first
@@ -138,21 +138,21 @@ Internal::DiffFormats DiffHighlighterPrivate::analyzeLine(const QString &text) c
return Internal::DiffTextFormat; return Internal::DiffTextFormat;
} }
void DiffHighlighterPrivate::updateOtherFormats() void DiffAndLogHighlighterPrivate::updateOtherFormats()
{ {
Q_Q(DiffHighlighter); Q_Q(DiffAndLogHighlighter);
m_addedTrailingWhiteSpaceFormat = m_addedTrailingWhiteSpaceFormat =
invertedColorFormat(q->formatForCategory(Internal::DiffInFormat)); invertedColorFormat(q->formatForCategory(Internal::DiffInFormat));
} }
// --- DiffHighlighter // --- DiffAndLogHighlighter
DiffHighlighter::DiffHighlighter(const QRegExp &filePattern) : DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern) :
TextEditor::SyntaxHighlighter(static_cast<QTextDocument *>(0)), TextEditor::SyntaxHighlighter(static_cast<QTextDocument *>(0)),
d_ptr(new DiffHighlighterPrivate(filePattern)) d_ptr(new DiffAndLogHighlighterPrivate(filePattern))
{ {
d_ptr->q_ptr = this; d_ptr->q_ptr = this;
Q_D(DiffHighlighter); Q_D(DiffAndLogHighlighter);
static QVector<TextEditor::TextStyle> categories; static QVector<TextEditor::TextStyle> categories;
if (categories.isEmpty()) { if (categories.isEmpty()) {
@@ -166,7 +166,7 @@ DiffHighlighter::DiffHighlighter(const QRegExp &filePattern) :
d->updateOtherFormats(); 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. * 1 for all the following lines of the diff header and all @@ lines.
* 2 for everything else * 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()) if (text.isEmpty())
return; 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); SyntaxHighlighter::setFontSettings(fontSettings);
d->updateOtherFormats(); d->updateOtherFormats();
} }

View File

@@ -28,8 +28,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef DIFFHIGHLIGHTER_H #ifndef DIFFANDLOGHIGHLIGHTER_H
#define DIFFHIGHLIGHTER_H #define DIFFANDLOGHIGHLIGHTER_H
#include "vcsbase_global.h" #include "vcsbase_global.h"
@@ -45,24 +45,24 @@ namespace TextEditor { class FontSettingsPage; }
namespace VcsBase { namespace VcsBase {
class DiffHighlighterPrivate; class DiffAndLogHighlighterPrivate;
class VCSBASE_EXPORT DiffHighlighter : public TextEditor::SyntaxHighlighter class VCSBASE_EXPORT DiffAndLogHighlighter : public TextEditor::SyntaxHighlighter
{ {
Q_OBJECT Q_OBJECT
Q_DECLARE_PRIVATE(DiffHighlighter) Q_DECLARE_PRIVATE(DiffAndLogHighlighter)
public: public:
explicit DiffHighlighter(const QRegExp &filePattern); explicit DiffAndLogHighlighter(const QRegExp &filePattern);
~DiffHighlighter(); ~DiffAndLogHighlighter();
void highlightBlock(const QString &text); void highlightBlock(const QString &text);
virtual void setFontSettings(const TextEditor::FontSettings &fontSettings); virtual void setFontSettings(const TextEditor::FontSettings &fontSettings);
private: private:
QScopedPointer<DiffHighlighterPrivate> d_ptr; QScopedPointer<DiffAndLogHighlighterPrivate> d_ptr;
}; };
} // namespace VcsBase } // namespace VcsBase
#endif // DIFFHIGHLIGHTER_H #endif // DIFFANDLOGHIGHLIGHTER_H

View File

@@ -9,7 +9,7 @@ HEADERS += vcsbase_global.h \
corelistener.h \ corelistener.h \
vcsbaseplugin.h \ vcsbaseplugin.h \
baseannotationhighlighter.h \ baseannotationhighlighter.h \
diffhighlighter.h \ diffandloghighlighter.h \
vcsbaseeditor.h \ vcsbaseeditor.h \
vcsbasesubmiteditor.h \ vcsbasesubmiteditor.h \
basevcseditorfactory.h \ basevcseditorfactory.h \
@@ -40,7 +40,7 @@ SOURCES += vcsplugin.cpp \
wizard/vcsjsextension.cpp \ wizard/vcsjsextension.cpp \
corelistener.cpp \ corelistener.cpp \
baseannotationhighlighter.cpp \ baseannotationhighlighter.cpp \
diffhighlighter.cpp \ diffandloghighlighter.cpp \
vcsbaseeditor.cpp \ vcsbaseeditor.cpp \
vcsbasesubmiteditor.cpp \ vcsbasesubmiteditor.cpp \
basevcseditorfactory.cpp \ basevcseditorfactory.cpp \

View File

@@ -39,8 +39,8 @@ QtcPlugin {
"commonvcssettings.h", "commonvcssettings.h",
"corelistener.cpp", "corelistener.cpp",
"corelistener.h", "corelistener.h",
"diffhighlighter.cpp", "diffandloghighlighter.cpp",
"diffhighlighter.h", "diffandloghighlighter.h",
"nicknamedialog.cpp", "nicknamedialog.cpp",
"nicknamedialog.h", "nicknamedialog.h",
"nicknamedialog.ui", "nicknamedialog.ui",

View File

@@ -29,7 +29,7 @@
****************************************************************************/ ****************************************************************************/
#include "vcsbaseeditor.h" #include "vcsbaseeditor.h"
#include "diffhighlighter.h" #include "diffandloghighlighter.h"
#include "baseannotationhighlighter.h" #include "baseannotationhighlighter.h"
#include "basevcseditorfactory.h" #include "basevcseditorfactory.h"
#include "vcsbaseplugin.h" #include "vcsbaseplugin.h"
@@ -736,7 +736,7 @@ void VcsBaseEditorWidget::init()
break; break;
} }
if (hasDiff()) { if (hasDiff()) {
auto dh = new DiffHighlighter(d->m_diffFilePattern); auto dh = new DiffAndLogHighlighter(d->m_diffFilePattern);
setCodeFoldingSupported(true); setCodeFoldingSupported(true);
textDocument()->setSyntaxHighlighter(dh); textDocument()->setSyntaxHighlighter(dh);
} }
@@ -1120,9 +1120,11 @@ void VcsBaseEditorWidget::jumpToChangeFromDiff(QTextCursor cursor)
const QChar deletionIndicator = QLatin1Char('-'); const QChar deletionIndicator = QLatin1Char('-');
// find nearest change hunk // find nearest change hunk
QTextBlock block = cursor.block(); QTextBlock block = cursor.block();
if (TextDocumentLayout::foldingIndent(block) <= 1) if (TextDocumentLayout::foldingIndent(block) <= 1) {
/* We are in a diff header, do not jump anywhere. DiffHighlighter sets the foldingIndent for us. */ // We are in a diff header, do not jump anywhere.
// DiffAndLogHighlighter sets the foldingIndent for us.
return; return;
}
for ( ; block.isValid() ; block = block.previous()) { for ( ; block.isValid() ; block = block.previous()) {
const QString line = block.text(); const QString line = block.text();
if (checkChunkLine(line, &chunkStart)) { if (checkChunkLine(line, &chunkStart)) {
@@ -1159,9 +1161,11 @@ DiffChunk VcsBaseEditorWidget::diffChunk(QTextCursor cursor) const
QTC_ASSERT(hasDiff(), return rc); QTC_ASSERT(hasDiff(), return rc);
// Search back for start of chunk. // Search back for start of chunk.
QTextBlock block = cursor.block(); QTextBlock block = cursor.block();
if (block.isValid() && TextDocumentLayout::foldingIndent(block) <= 1) if (block.isValid() && TextDocumentLayout::foldingIndent(block) <= 1) {
/* We are in a diff header, not in a chunk! DiffHighlighter sets the foldingIndent for us. */ // We are in a diff header, not in a chunk!
// DiffAndLogHighlighter sets the foldingIndent for us.
return rc; return rc;
}
int chunkStart = 0; int chunkStart = 0;
for ( ; block.isValid() ; block = block.previous()) { for ( ; block.isValid() ; block = block.previous()) {