forked from qt-creator/qt-creator
Fossil: Hide FossilEditorWidget definition
... and de-pimpl. Change-Id: I360379350a696b2d465e869b47c6c02fbd4aa996 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
#include "fossilclient.h"
|
||||
|
||||
#include "constants.h"
|
||||
#include "fossileditor.h"
|
||||
#include "fossiltr.h"
|
||||
|
||||
#include <vcsbase/vcsbaseplugin.h>
|
||||
@@ -701,7 +700,7 @@ void FossilClient::annotate(const FilePath &workingDir, const QString &file, int
|
||||
VcsBaseEditor::getCodec(source),
|
||||
vcsCmdString.toLatin1().constData(), id);
|
||||
|
||||
auto *fossilEditor = qobject_cast<FossilEditorWidget *>(editor);
|
||||
auto fossilEditor = qobject_cast<VcsBaseEditorWidget *>(editor);
|
||||
QTC_ASSERT(fossilEditor, return);
|
||||
|
||||
if (!fossilEditor->editorConfig()) {
|
||||
@@ -905,7 +904,7 @@ void FossilClient::log(const FilePath &workingDir, const QStringList &files,
|
||||
VcsBaseEditor::getCodec(source),
|
||||
vcsCmdString.toLatin1().constData(), id);
|
||||
|
||||
auto *fossilEditor = qobject_cast<FossilEditorWidget *>(editor);
|
||||
auto fossilEditor = qobject_cast<VcsBaseEditorWidget *>(editor);
|
||||
QTC_ASSERT(fossilEditor, return);
|
||||
|
||||
fossilEditor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
|
||||
@@ -961,7 +960,7 @@ void FossilClient::logCurrentFile(const FilePath &workingDir, const QStringList
|
||||
VcsBaseEditor::getCodec(source),
|
||||
vcsCmdString.toLatin1().constData(), id);
|
||||
|
||||
auto *fossilEditor = qobject_cast<FossilEditorWidget *>(editor);
|
||||
auto fossilEditor = qobject_cast<VcsBaseEditorWidget *>(editor);
|
||||
QTC_ASSERT(fossilEditor, return);
|
||||
|
||||
fossilEditor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
|
||||
|
||||
@@ -10,37 +10,35 @@
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QTextCursor>
|
||||
|
||||
namespace Fossil::Internal {
|
||||
|
||||
class FossilEditorWidgetPrivate
|
||||
class FossilEditorWidget final : public VcsBase::VcsBaseEditorWidget
|
||||
{
|
||||
public:
|
||||
FossilEditorWidgetPrivate() :
|
||||
m_exactChangesetId(Constants::CHANGESET_ID_EXACT)
|
||||
FossilEditorWidget()
|
||||
: m_exactChangesetId(Constants::CHANGESET_ID_EXACT)
|
||||
{
|
||||
QTC_ASSERT(m_exactChangesetId.isValid(), return);
|
||||
}
|
||||
|
||||
const QRegularExpression m_exactChangesetId;
|
||||
};
|
||||
|
||||
FossilEditorWidget::FossilEditorWidget() :
|
||||
d(new FossilEditorWidgetPrivate)
|
||||
{
|
||||
QTC_CHECK(m_exactChangesetId.isValid());
|
||||
setAnnotateRevisionTextFormat(Tr::tr("&Annotate %1"));
|
||||
setAnnotatePreviousRevisionTextFormat(Tr::tr("Annotate &Parent Revision %1"));
|
||||
setDiffFilePattern(Constants::DIFFFILE_ID_EXACT);
|
||||
setLogEntryPattern("^.*\\[([0-9a-f]{5,40})\\]");
|
||||
setAnnotationEntryPattern(QString("^") + Constants::CHANGESET_ID + " ");
|
||||
}
|
||||
}
|
||||
|
||||
FossilEditorWidget::~FossilEditorWidget()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
private:
|
||||
QString changeUnderCursor(const QTextCursor &cursor) const final;
|
||||
QString decorateVersion(const QString &revision) const final;
|
||||
QStringList annotationPreviousVersions(const QString &revision) const final;
|
||||
VcsBase::BaseAnnotationHighlighterCreator annotationHighlighterCreator() const final;
|
||||
|
||||
const QRegularExpression m_exactChangesetId;
|
||||
};
|
||||
|
||||
QString FossilEditorWidget::changeUnderCursor(const QTextCursor &cursorIn) const
|
||||
{
|
||||
@@ -48,7 +46,7 @@ QString FossilEditorWidget::changeUnderCursor(const QTextCursor &cursorIn) const
|
||||
cursor.select(QTextCursor::WordUnderCursor);
|
||||
if (cursor.hasSelection()) {
|
||||
const QString change = cursor.selectedText();
|
||||
const QRegularExpressionMatch exactChangesetIdMatch = d->m_exactChangesetId.match(change);
|
||||
const QRegularExpressionMatch exactChangesetIdMatch = m_exactChangesetId.match(change);
|
||||
if (exactChangesetIdMatch.hasMatch())
|
||||
return change;
|
||||
}
|
||||
@@ -94,4 +92,9 @@ VcsBase::BaseAnnotationHighlighterCreator FossilEditorWidget::annotationHighligh
|
||||
return VcsBase::getAnnotationHighlighterCreator<FossilAnnotationHighlighter>();
|
||||
}
|
||||
|
||||
QWidget *createFossilEditorWidget()
|
||||
{
|
||||
return new FossilEditorWidget;
|
||||
}
|
||||
|
||||
} // namespace Fossil::Internal
|
||||
|
||||
@@ -3,29 +3,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Fossil {
|
||||
namespace Internal {
|
||||
namespace Fossil::Internal {
|
||||
|
||||
class FossilEditorWidgetPrivate;
|
||||
QWidget *createFossilEditorWidget();
|
||||
|
||||
class FossilEditorWidget final : public VcsBase::VcsBaseEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FossilEditorWidget();
|
||||
~FossilEditorWidget() final;
|
||||
|
||||
private:
|
||||
QString changeUnderCursor(const QTextCursor &cursor) const final;
|
||||
QString decorateVersion(const QString &revision) const final;
|
||||
QStringList annotationPreviousVersions(const QString &revision) const final;
|
||||
VcsBase::BaseAnnotationHighlighterCreator annotationHighlighterCreator() const final;
|
||||
|
||||
FossilEditorWidgetPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Fossil
|
||||
} // Fossil::Internal
|
||||
|
||||
@@ -138,7 +138,7 @@ public:
|
||||
Constants::FILELOG_ID,
|
||||
VcsBase::Tr::tr("Fossil File Log Editor"),
|
||||
Constants::LOGAPP,
|
||||
[] { return new FossilEditorWidget; },
|
||||
&createFossilEditorWidget,
|
||||
std::bind(&FossilPluginPrivate::vcsDescribe, this, _1, _2)
|
||||
}};
|
||||
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
Constants::ANNOTATELOG_ID,
|
||||
VcsBase::Tr::tr("Fossil Annotation Editor"),
|
||||
Constants::ANNOTATEAPP,
|
||||
[] { return new FossilEditorWidget; },
|
||||
&createFossilEditorWidget,
|
||||
std::bind(&FossilPluginPrivate::vcsDescribe, this, _1, _2)
|
||||
}};
|
||||
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
Constants::DIFFLOG_ID,
|
||||
VcsBase::Tr::tr("Fossil Diff Editor"),
|
||||
Constants::DIFFAPP,
|
||||
[] { return new FossilEditorWidget; },
|
||||
&createFossilEditorWidget,
|
||||
std::bind(&FossilPluginPrivate::vcsDescribe, this, _1, _2)
|
||||
}};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user