Commit 9877221a authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

VCS: Rename DiffHighlighter -> DiffAndLogHighlighter

It is also used for log editors

Change-Id: I8755d2aaa717ca47b0d9bbf935b121d4e099ef1b
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent f98c89eb
......@@ -35,7 +35,7 @@
#include "clearcaseplugin.h"
#include <utils/qtcassert.h>
#include <vcsbase/diffhighlighter.h>
#include <vcsbase/diffandloghighlighter.h>
#include <QDir>
#include <QFileInfo>
......
......@@ -35,7 +35,7 @@
#include "cvsconstants.h"
#include <utils/qtcassert.h>
#include <vcsbase/diffhighlighter.h>
#include <vcsbase/diffandloghighlighter.h>
#include <QDebug>
#include <QTextCursor>
......
......@@ -35,7 +35,7 @@
#include "mercurialclient.h"
#include <coreplugin/editormanager/editormanager.h>
#include <vcsbase/diffhighlighter.h>
#include <vcsbase/diffandloghighlighter.h>
#include <QString>
#include <QTextCursor>
......
......@@ -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>
......
......@@ -35,7 +35,7 @@
#include "subversionconstants.h"
#include <utils/qtcassert.h>
#include <vcsbase/diffhighlighter.h>
#include <vcsbase/diffandloghighlighter.h>
#include <QDebug>
#include <QFileInfo>
......
......@@ -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();
}
......
......@@ -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
......@@ -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 \
......
......@@ -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",
......
......@@ -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()) {
......
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