forked from qt-creator/qt-creator
Vcs: Jump to the current source line in Fossil Annotate editor
* Keep track of the current source line number and pass it to Annotate action. * Add a 'List Versions' toggle in Annotate editor to prepend a list of commits that make up the annotated source. * By default do not show the version list so that annotated line number could be matched to the source line. NOTE: VcsBaseEditorWidget::configurationWidget() query is no longer available, yet Fossil client needs it in order to process the effective arguments. So we re-implement it in FossilEditorWidget sub-class. Change-Id: Idc4c21d074ccf4e1c6d041cce2abceb78665c8f2 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <vcsbase/diffandloghighlighter.h>
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QRegExp>
|
||||
#include <QString>
|
||||
#include <QTextCursor>
|
||||
@@ -44,15 +45,31 @@
|
||||
namespace Fossil {
|
||||
namespace Internal {
|
||||
|
||||
FossilEditorWidget::FossilEditorWidget() :
|
||||
m_exactChangesetId(Constants::CHANGESET_ID_EXACT),
|
||||
m_firstChangesetId(QString("\n") + Constants::CHANGESET_ID + " "),
|
||||
m_nextChangesetId(m_firstChangesetId)
|
||||
class FossilEditorWidgetPrivate
|
||||
{
|
||||
QTC_ASSERT(m_exactChangesetId.isValid(), return);
|
||||
QTC_ASSERT(m_firstChangesetId.isValid(), return);
|
||||
QTC_ASSERT(m_nextChangesetId.isValid(), return);
|
||||
public:
|
||||
FossilEditorWidgetPrivate() :
|
||||
m_exactChangesetId(Constants::CHANGESET_ID_EXACT),
|
||||
m_firstChangesetId(QString("\n") + Constants::CHANGESET_ID + " "),
|
||||
m_nextChangesetId(m_firstChangesetId),
|
||||
m_configurationWidget(nullptr)
|
||||
{
|
||||
QTC_ASSERT(m_exactChangesetId.isValid(), return);
|
||||
QTC_ASSERT(m_firstChangesetId.isValid(), return);
|
||||
QTC_ASSERT(m_nextChangesetId.isValid(), return);
|
||||
}
|
||||
|
||||
|
||||
const QRegularExpression m_exactChangesetId;
|
||||
const QRegularExpression m_firstChangesetId;
|
||||
const QRegularExpression m_nextChangesetId;
|
||||
|
||||
VcsBase::VcsBaseEditorConfig *m_configurationWidget;
|
||||
};
|
||||
|
||||
FossilEditorWidget::FossilEditorWidget() :
|
||||
d(new FossilEditorWidgetPrivate)
|
||||
{
|
||||
setAnnotateRevisionTextFormat(tr("&Annotate %1"));
|
||||
setAnnotatePreviousRevisionTextFormat(tr("Annotate &Parent Revision %1"));
|
||||
|
||||
@@ -65,6 +82,26 @@ FossilEditorWidget::FossilEditorWidget() :
|
||||
setLogEntryPattern(logChangePattern);
|
||||
}
|
||||
|
||||
FossilEditorWidget::~FossilEditorWidget()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool FossilEditorWidget::setConfigurationWidget(VcsBase::VcsBaseEditorConfig *w)
|
||||
{
|
||||
if (configurationAdded())
|
||||
return false;
|
||||
|
||||
d->m_configurationWidget = w;
|
||||
setConfigurationAdded();
|
||||
return true;
|
||||
}
|
||||
|
||||
VcsBase::VcsBaseEditorConfig *FossilEditorWidget::configurationWidget() const
|
||||
{
|
||||
return d->m_configurationWidget;
|
||||
}
|
||||
|
||||
QSet<QString> FossilEditorWidget::annotationChanges() const
|
||||
{
|
||||
|
||||
@@ -77,12 +114,12 @@ QSet<QString> FossilEditorWidget::annotationChanges() const
|
||||
|
||||
QSet<QString> changes;
|
||||
|
||||
QRegularExpressionMatch firstChangesetIdMatch = m_firstChangesetId.match(txt);
|
||||
QRegularExpressionMatch firstChangesetIdMatch = d->m_firstChangesetId.match(txt);
|
||||
if (firstChangesetIdMatch.hasMatch()) {
|
||||
QString changeId = firstChangesetIdMatch.captured(1);
|
||||
changes.insert(changeId);
|
||||
|
||||
QRegularExpressionMatchIterator i = m_nextChangesetId.globalMatch(txt);
|
||||
QRegularExpressionMatchIterator i = d->m_nextChangesetId.globalMatch(txt);
|
||||
while (i.hasNext()) {
|
||||
const QRegularExpressionMatch nextChangesetIdMatch = i.next();
|
||||
changeId = nextChangesetIdMatch.captured(1);
|
||||
@@ -98,7 +135,7 @@ QString FossilEditorWidget::changeUnderCursor(const QTextCursor &cursorIn) const
|
||||
cursor.select(QTextCursor::WordUnderCursor);
|
||||
if (cursor.hasSelection()) {
|
||||
const QString change = cursor.selectedText();
|
||||
QRegularExpressionMatch exactChangesetIdMatch = m_exactChangesetId.match(change);
|
||||
QRegularExpressionMatch exactChangesetIdMatch = d->m_exactChangesetId.match(change);
|
||||
if (exactChangesetIdMatch.hasMatch())
|
||||
return change;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user