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 "fossilclient.h"
|
||||||
|
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "fossileditor.h"
|
|
||||||
#include "fossiltr.h"
|
#include "fossiltr.h"
|
||||||
|
|
||||||
#include <vcsbase/vcsbaseplugin.h>
|
#include <vcsbase/vcsbaseplugin.h>
|
||||||
@@ -701,7 +700,7 @@ void FossilClient::annotate(const FilePath &workingDir, const QString &file, int
|
|||||||
VcsBaseEditor::getCodec(source),
|
VcsBaseEditor::getCodec(source),
|
||||||
vcsCmdString.toLatin1().constData(), id);
|
vcsCmdString.toLatin1().constData(), id);
|
||||||
|
|
||||||
auto *fossilEditor = qobject_cast<FossilEditorWidget *>(editor);
|
auto fossilEditor = qobject_cast<VcsBaseEditorWidget *>(editor);
|
||||||
QTC_ASSERT(fossilEditor, return);
|
QTC_ASSERT(fossilEditor, return);
|
||||||
|
|
||||||
if (!fossilEditor->editorConfig()) {
|
if (!fossilEditor->editorConfig()) {
|
||||||
@@ -905,7 +904,7 @@ void FossilClient::log(const FilePath &workingDir, const QStringList &files,
|
|||||||
VcsBaseEditor::getCodec(source),
|
VcsBaseEditor::getCodec(source),
|
||||||
vcsCmdString.toLatin1().constData(), id);
|
vcsCmdString.toLatin1().constData(), id);
|
||||||
|
|
||||||
auto *fossilEditor = qobject_cast<FossilEditorWidget *>(editor);
|
auto fossilEditor = qobject_cast<VcsBaseEditorWidget *>(editor);
|
||||||
QTC_ASSERT(fossilEditor, return);
|
QTC_ASSERT(fossilEditor, return);
|
||||||
|
|
||||||
fossilEditor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
|
fossilEditor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
|
||||||
@@ -961,7 +960,7 @@ void FossilClient::logCurrentFile(const FilePath &workingDir, const QStringList
|
|||||||
VcsBaseEditor::getCodec(source),
|
VcsBaseEditor::getCodec(source),
|
||||||
vcsCmdString.toLatin1().constData(), id);
|
vcsCmdString.toLatin1().constData(), id);
|
||||||
|
|
||||||
auto *fossilEditor = qobject_cast<FossilEditorWidget *>(editor);
|
auto fossilEditor = qobject_cast<VcsBaseEditorWidget *>(editor);
|
||||||
QTC_ASSERT(fossilEditor, return);
|
QTC_ASSERT(fossilEditor, return);
|
||||||
|
|
||||||
fossilEditor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
|
fossilEditor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
|
||||||
|
|||||||
@@ -10,26 +10,20 @@
|
|||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <vcsbase/vcsbaseeditor.h>
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QTextCursor>
|
#include <QTextCursor>
|
||||||
|
|
||||||
namespace Fossil::Internal {
|
namespace Fossil::Internal {
|
||||||
|
|
||||||
class FossilEditorWidgetPrivate
|
class FossilEditorWidget final : public VcsBase::VcsBaseEditorWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FossilEditorWidgetPrivate() :
|
FossilEditorWidget()
|
||||||
m_exactChangesetId(Constants::CHANGESET_ID_EXACT)
|
: 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"));
|
setAnnotateRevisionTextFormat(Tr::tr("&Annotate %1"));
|
||||||
setAnnotatePreviousRevisionTextFormat(Tr::tr("Annotate &Parent Revision %1"));
|
setAnnotatePreviousRevisionTextFormat(Tr::tr("Annotate &Parent Revision %1"));
|
||||||
setDiffFilePattern(Constants::DIFFFILE_ID_EXACT);
|
setDiffFilePattern(Constants::DIFFFILE_ID_EXACT);
|
||||||
@@ -37,10 +31,14 @@ FossilEditorWidget::FossilEditorWidget() :
|
|||||||
setAnnotationEntryPattern(QString("^") + Constants::CHANGESET_ID + " ");
|
setAnnotationEntryPattern(QString("^") + Constants::CHANGESET_ID + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
FossilEditorWidget::~FossilEditorWidget()
|
private:
|
||||||
{
|
QString changeUnderCursor(const QTextCursor &cursor) const final;
|
||||||
delete d;
|
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
|
QString FossilEditorWidget::changeUnderCursor(const QTextCursor &cursorIn) const
|
||||||
{
|
{
|
||||||
@@ -48,7 +46,7 @@ QString FossilEditorWidget::changeUnderCursor(const QTextCursor &cursorIn) const
|
|||||||
cursor.select(QTextCursor::WordUnderCursor);
|
cursor.select(QTextCursor::WordUnderCursor);
|
||||||
if (cursor.hasSelection()) {
|
if (cursor.hasSelection()) {
|
||||||
const QString change = cursor.selectedText();
|
const QString change = cursor.selectedText();
|
||||||
const QRegularExpressionMatch exactChangesetIdMatch = d->m_exactChangesetId.match(change);
|
const QRegularExpressionMatch exactChangesetIdMatch = m_exactChangesetId.match(change);
|
||||||
if (exactChangesetIdMatch.hasMatch())
|
if (exactChangesetIdMatch.hasMatch())
|
||||||
return change;
|
return change;
|
||||||
}
|
}
|
||||||
@@ -94,4 +92,9 @@ VcsBase::BaseAnnotationHighlighterCreator FossilEditorWidget::annotationHighligh
|
|||||||
return VcsBase::getAnnotationHighlighterCreator<FossilAnnotationHighlighter>();
|
return VcsBase::getAnnotationHighlighterCreator<FossilAnnotationHighlighter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget *createFossilEditorWidget()
|
||||||
|
{
|
||||||
|
return new FossilEditorWidget;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Fossil::Internal
|
} // namespace Fossil::Internal
|
||||||
|
|||||||
@@ -3,29 +3,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vcsbase/vcsbaseeditor.h>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace Fossil {
|
namespace Fossil::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class FossilEditorWidgetPrivate;
|
QWidget *createFossilEditorWidget();
|
||||||
|
|
||||||
class FossilEditorWidget final : public VcsBase::VcsBaseEditorWidget
|
} // Fossil::Internal
|
||||||
{
|
|
||||||
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
|
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ public:
|
|||||||
Constants::FILELOG_ID,
|
Constants::FILELOG_ID,
|
||||||
VcsBase::Tr::tr("Fossil File Log Editor"),
|
VcsBase::Tr::tr("Fossil File Log Editor"),
|
||||||
Constants::LOGAPP,
|
Constants::LOGAPP,
|
||||||
[] { return new FossilEditorWidget; },
|
&createFossilEditorWidget,
|
||||||
std::bind(&FossilPluginPrivate::vcsDescribe, this, _1, _2)
|
std::bind(&FossilPluginPrivate::vcsDescribe, this, _1, _2)
|
||||||
}};
|
}};
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ public:
|
|||||||
Constants::ANNOTATELOG_ID,
|
Constants::ANNOTATELOG_ID,
|
||||||
VcsBase::Tr::tr("Fossil Annotation Editor"),
|
VcsBase::Tr::tr("Fossil Annotation Editor"),
|
||||||
Constants::ANNOTATEAPP,
|
Constants::ANNOTATEAPP,
|
||||||
[] { return new FossilEditorWidget; },
|
&createFossilEditorWidget,
|
||||||
std::bind(&FossilPluginPrivate::vcsDescribe, this, _1, _2)
|
std::bind(&FossilPluginPrivate::vcsDescribe, this, _1, _2)
|
||||||
}};
|
}};
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ public:
|
|||||||
Constants::DIFFLOG_ID,
|
Constants::DIFFLOG_ID,
|
||||||
VcsBase::Tr::tr("Fossil Diff Editor"),
|
VcsBase::Tr::tr("Fossil Diff Editor"),
|
||||||
Constants::DIFFAPP,
|
Constants::DIFFAPP,
|
||||||
[] { return new FossilEditorWidget; },
|
&createFossilEditorWidget,
|
||||||
std::bind(&FossilPluginPrivate::vcsDescribe, this, _1, _2)
|
std::bind(&FossilPluginPrivate::vcsDescribe, this, _1, _2)
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user