forked from qt-creator/qt-creator
Vcs: Move editor construction over to new scheme
Change-Id: I491b9f37bfe15ebc800fedd5c683bfaf24e63889 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -41,8 +41,7 @@
|
||||
using namespace Bazaar::Internal;
|
||||
using namespace Bazaar;
|
||||
|
||||
BazaarEditor::BazaarEditor(const VcsBase::VcsBaseEditorParameters *type, QWidget *parent)
|
||||
: VcsBase::VcsBaseEditorWidget(type, parent),
|
||||
BazaarEditor::BazaarEditor() :
|
||||
m_changesetId(QLatin1String(Constants::CHANGESET_ID)),
|
||||
m_exactChangesetId(QLatin1String(Constants::CHANGESET_ID_EXACT))
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ class BazaarEditor : public VcsBase::VcsBaseEditorWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BazaarEditor(const VcsBase::VcsBaseEditorParameters *type, QWidget *parent);
|
||||
BazaarEditor();
|
||||
|
||||
private:
|
||||
QSet<QString> annotationChanges() const;
|
||||
|
||||
@@ -166,8 +166,6 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag
|
||||
Q_UNUSED(arguments);
|
||||
Q_UNUSED(errorMessage);
|
||||
|
||||
typedef VcsEditorFactory<BazaarEditor> BazaarEditorFactory;
|
||||
|
||||
m_client = new BazaarClient(&m_bazaarSettings);
|
||||
initializeVcs(new BazaarControl(m_client));
|
||||
|
||||
@@ -179,8 +177,9 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag
|
||||
|
||||
static const char *describeSlot = SLOT(view(QString,QString));
|
||||
const int editorCount = sizeof(editorParameters) / sizeof(VcsBaseEditorParameters);
|
||||
const auto widgetCreator = []() { return new BazaarEditor; };
|
||||
for (int i = 0; i < editorCount; i++)
|
||||
addAutoReleasedObject(new BazaarEditorFactory(editorParameters + i, m_client, describeSlot));
|
||||
addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, m_client, describeSlot));
|
||||
|
||||
addAutoReleasedObject(new VcsSubmitEditorFactory<CommitEditor>(&submitEditorParameters));
|
||||
|
||||
@@ -657,7 +656,8 @@ void BazaarPlugin::testDiffFileResolving_data()
|
||||
|
||||
void BazaarPlugin::testDiffFileResolving()
|
||||
{
|
||||
BazaarEditor editor(editorParameters + 2, 0);
|
||||
BazaarEditor editor;
|
||||
editor.setParameters(editorParameters + 2);
|
||||
editor.testDiffFileResolving();
|
||||
}
|
||||
|
||||
@@ -681,7 +681,8 @@ void BazaarPlugin::testLogResolving()
|
||||
" (gz) Set approved revision and vote \"Approve\" when using lp-propose\n"
|
||||
" --approve (Jonathan Lange)\n"
|
||||
);
|
||||
BazaarEditor editor(editorParameters, 0);
|
||||
BazaarEditor editor;
|
||||
editor.setParameters(editorParameters);
|
||||
editor.testLogResolving(data, "6572", "6571");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -44,9 +44,7 @@
|
||||
using namespace ClearCase;
|
||||
using namespace ClearCase::Internal;
|
||||
|
||||
ClearCaseEditor::ClearCaseEditor(const VcsBase::VcsBaseEditorParameters *type,
|
||||
QWidget *parent) :
|
||||
VcsBase::VcsBaseEditorWidget(type, parent),
|
||||
ClearCaseEditor::ClearCaseEditor() :
|
||||
m_versionNumberPattern(QLatin1String("[\\\\/]main[\\\\/][^ \t\n\"]*"))
|
||||
{
|
||||
QTC_ASSERT(m_versionNumberPattern.isValid(), return);
|
||||
|
||||
@@ -43,8 +43,7 @@ class ClearCaseEditor : public VcsBase::VcsBaseEditorWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ClearCaseEditor(const VcsBase::VcsBaseEditorParameters *type,
|
||||
QWidget *parent);
|
||||
ClearCaseEditor();
|
||||
|
||||
private:
|
||||
QSet<QString> annotationChanges() const;
|
||||
|
||||
@@ -437,7 +437,6 @@ static const VcsBase::VcsBaseSubmitEditorParameters submitParameters = {
|
||||
bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *errorMessage)
|
||||
{
|
||||
typedef VcsBase::VcsSubmitEditorFactory<ClearCaseSubmitEditor> ClearCaseSubmitEditorFactory;
|
||||
typedef VcsBase::VcsEditorFactory<ClearCaseEditor> ClearCaseEditorFactory;
|
||||
using namespace Constants;
|
||||
|
||||
using namespace Core::Constants;
|
||||
@@ -466,8 +465,9 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
|
||||
// any editor responds to describe (when clicking a version)
|
||||
static const char *describeSlot = SLOT(describe(QString,QString));
|
||||
const int editorCount = sizeof(editorParameters)/sizeof(VcsBase::VcsBaseEditorParameters);
|
||||
const auto widgetCreator = []() { return new ClearCaseEditor; };
|
||||
for (int i = 0; i < editorCount; i++)
|
||||
addAutoReleasedObject(new ClearCaseEditorFactory(editorParameters + i, this, describeSlot));
|
||||
addAutoReleasedObject(new VcsBase::VcsEditorFactory(editorParameters + i, widgetCreator, this, describeSlot));
|
||||
|
||||
const QString description = QLatin1String("ClearCase");
|
||||
const QString prefix = QLatin1String("cc");
|
||||
@@ -2229,7 +2229,8 @@ void ClearCasePlugin::testDiffFileResolving_data()
|
||||
|
||||
void ClearCasePlugin::testDiffFileResolving()
|
||||
{
|
||||
ClearCaseEditor editor(editorParameters + 2, 0);
|
||||
ClearCaseEditor editor;
|
||||
editor.setParameters(editorParameters + 2);
|
||||
editor.testDiffFileResolving();
|
||||
}
|
||||
|
||||
@@ -2239,7 +2240,8 @@ void ClearCasePlugin::testLogResolving()
|
||||
"13-Sep.17:41 user1 create version \"src/plugins/clearcase/clearcaseeditor.h@@/main/branch1/branch2/9\" (baseline1, baseline2, ...)\n"
|
||||
"22-Aug.14:13 user2 create version \"src/plugins/clearcase/clearcaseeditor.h@@/main/branch1/branch2/8\" (baseline3, baseline4, ...)\n"
|
||||
);
|
||||
ClearCaseEditor editor(editorParameters, 0);
|
||||
ClearCaseEditor editor;
|
||||
editor.setParameters(editorParameters);
|
||||
editor.testLogResolving(data,
|
||||
"src/plugins/clearcase/clearcaseeditor.h@@/main/branch1/branch2/9",
|
||||
"src/plugins/clearcase/clearcaseeditor.h@@/main/branch1/branch2/8");
|
||||
|
||||
@@ -47,9 +47,7 @@ namespace Internal {
|
||||
#define CVS_REVISION_PATTERN "[\\d\\.]+"
|
||||
#define CVS_REVISION_AT_START_PATTERN "^(" CVS_REVISION_PATTERN ") "
|
||||
|
||||
CvsEditor::CvsEditor(const VcsBase::VcsBaseEditorParameters *type,
|
||||
QWidget *parent) :
|
||||
VcsBase::VcsBaseEditorWidget(type, parent),
|
||||
CvsEditor::CvsEditor() :
|
||||
m_revisionAnnotationPattern(QLatin1String(CVS_REVISION_AT_START_PATTERN ".*$")),
|
||||
m_revisionLogPattern(QLatin1String("^revision *(" CVS_REVISION_PATTERN ")$"))
|
||||
{
|
||||
|
||||
@@ -42,8 +42,7 @@ class CvsEditor : public VcsBase::VcsBaseEditorWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CvsEditor(const VcsBase::VcsBaseEditorParameters *type,
|
||||
QWidget *parent);
|
||||
CvsEditor();
|
||||
|
||||
private:
|
||||
QSet<QString> annotationChanges() const;
|
||||
|
||||
@@ -231,7 +231,6 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(arguments);
|
||||
typedef VcsSubmitEditorFactory<CvsSubmitEditor> CVSSubmitEditorFactory;
|
||||
typedef VcsEditorFactory<CvsEditor> CVSEditorFactory;
|
||||
using namespace Constants;
|
||||
|
||||
using namespace Core::Constants;
|
||||
@@ -254,8 +253,9 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
|
||||
static const char *describeSlotC = SLOT(slotDescribe(QString,QString));
|
||||
const int editorCount = sizeof(editorParameters) / sizeof(editorParameters[0]);
|
||||
const auto widgetCreator = []() { return new CvsEditor; };
|
||||
for (int i = 0; i < editorCount; i++)
|
||||
addAutoReleasedObject(new CVSEditorFactory(editorParameters + i, this, describeSlotC));
|
||||
addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, this, describeSlotC));
|
||||
|
||||
auto checkoutWizardFactory = new BaseCheckoutWizardFactory;
|
||||
checkoutWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_CVS));
|
||||
@@ -1318,7 +1318,8 @@ void CvsPlugin::testDiffFileResolving_data()
|
||||
|
||||
void CvsPlugin::testDiffFileResolving()
|
||||
{
|
||||
CvsEditor editor(editorParameters + 3, 0);
|
||||
CvsEditor editor;
|
||||
editor.setParameters(editorParameters + 3);
|
||||
editor.testDiffFileResolving();
|
||||
}
|
||||
|
||||
@@ -1345,7 +1346,8 @@ void CvsPlugin::testLogResolving()
|
||||
"added latest commentary\n"
|
||||
"----------------------------\n"
|
||||
);
|
||||
CvsEditor editor(editorParameters + 1, 0);
|
||||
CvsEditor editor;
|
||||
editor.setParameters(editorParameters + 1);
|
||||
editor.testLogResolving(data, "1.3", "1.2");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -58,8 +58,7 @@
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
GitEditorWidget::GitEditorWidget(const VcsBase::VcsBaseEditorParameters *type, QWidget *parent) :
|
||||
VcsBase::VcsBaseEditorWidget(type, parent),
|
||||
GitEditorWidget::GitEditorWidget() :
|
||||
m_changeNumberPattern(QLatin1String(CHANGE_PATTERN))
|
||||
{
|
||||
QTC_ASSERT(m_changeNumberPattern.isValid(), return);
|
||||
|
||||
@@ -46,8 +46,7 @@ class GitEditorWidget : public VcsBase::VcsBaseEditorWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GitEditorWidget(const VcsBase::VcsBaseEditorParameters *type,
|
||||
QWidget *parent);
|
||||
GitEditorWidget();
|
||||
|
||||
public slots:
|
||||
void setPlainTextFiltered(const QString &text);
|
||||
|
||||
@@ -280,7 +280,6 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
|
||||
m_gitClient = new GitClient(&m_settings);
|
||||
|
||||
typedef VcsEditorFactory<GitEditorWidget> GitEditorFactory;
|
||||
typedef VcsSubmitEditorFactory<GitSubmitEditor> GitSubmitEditorFactory;
|
||||
|
||||
initializeVcs(new GitVersionControl(m_gitClient));
|
||||
@@ -293,8 +292,9 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
|
||||
static const char *describeSlot = SLOT(show(QString,QString));
|
||||
const int editorCount = sizeof(editorParameters) / sizeof(editorParameters[0]);
|
||||
const auto widgetCreator = []() { return new GitEditorWidget; };
|
||||
for (int i = 0; i < editorCount; i++)
|
||||
addAutoReleasedObject(new GitEditorFactory(editorParameters + i, m_gitClient, describeSlot));
|
||||
addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, m_gitClient, describeSlot));
|
||||
|
||||
addAutoReleasedObject(new GitSubmitEditorFactory(&submitParameters));
|
||||
|
||||
@@ -1523,7 +1523,8 @@ void GitPlugin::testDiffFileResolving_data()
|
||||
|
||||
void GitPlugin::testDiffFileResolving()
|
||||
{
|
||||
GitEditorWidget editor(editorParameters + 3, 0);
|
||||
GitEditorWidget editor;
|
||||
editor.setParameters(editorParameters + 3);
|
||||
editor.testDiffFileResolving();
|
||||
}
|
||||
|
||||
@@ -1549,7 +1550,8 @@ void GitPlugin::testLogResolving()
|
||||
" \n"
|
||||
" Signed-off-by: Junio C Hamano <gitster@pobox.com>\n"
|
||||
);
|
||||
GitEditorWidget editor(editorParameters + 1, 0);
|
||||
GitEditorWidget editor;
|
||||
editor.setParameters(editorParameters + 1);
|
||||
editor.testLogResolving(data,
|
||||
"50a6b54c - Merge branch 'for-junio' of git://bogomips.org/git-svn",
|
||||
"3587b513 - Update draft release notes to 1.8.2");
|
||||
|
||||
@@ -46,8 +46,7 @@
|
||||
using namespace Mercurial::Internal;
|
||||
using namespace Mercurial;
|
||||
|
||||
MercurialEditor::MercurialEditor(const VcsBase::VcsBaseEditorParameters *type, QWidget *parent)
|
||||
: VcsBase::VcsBaseEditorWidget(type, parent),
|
||||
MercurialEditor::MercurialEditor() :
|
||||
exactIdentifier12(QLatin1String(Constants::CHANGEIDEXACT12)),
|
||||
exactIdentifier40(QLatin1String(Constants::CHANGEIDEXACT40)),
|
||||
changesetIdentifier12(QLatin1String(Constants::CHANGESETID12)),
|
||||
|
||||
@@ -41,7 +41,7 @@ class MercurialEditor : public VcsBase::VcsBaseEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MercurialEditor(const VcsBase::VcsBaseEditorParameters *type, QWidget *parent);
|
||||
MercurialEditor();
|
||||
|
||||
private:
|
||||
QSet<QString> annotationChanges() const;
|
||||
|
||||
@@ -139,8 +139,6 @@ MercurialPlugin::~MercurialPlugin()
|
||||
|
||||
bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString * /*errorMessage */)
|
||||
{
|
||||
typedef VcsEditorFactory<MercurialEditor> MercurialEditorFactory;
|
||||
|
||||
m_client = new MercurialClient(&mercurialSettings);
|
||||
initializeVcs(new MercurialControl(m_client));
|
||||
|
||||
@@ -153,8 +151,9 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString *
|
||||
|
||||
static const char *describeSlot = SLOT(view(QString,QString));
|
||||
const int editorCount = sizeof(editorParameters)/sizeof(editorParameters[0]);
|
||||
const auto widgetCreator = []() { return new MercurialEditor; };
|
||||
for (int i = 0; i < editorCount; i++)
|
||||
addAutoReleasedObject(new MercurialEditorFactory(editorParameters + i, m_client, describeSlot));
|
||||
addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, m_client, describeSlot));
|
||||
|
||||
addAutoReleasedObject(new VcsSubmitEditorFactory<CommitEditor>(&submitEditorParameters));
|
||||
|
||||
@@ -726,7 +725,8 @@ void MercurialPlugin::testDiffFileResolving_data()
|
||||
|
||||
void MercurialPlugin::testDiffFileResolving()
|
||||
{
|
||||
MercurialEditor editor(editorParameters + 2, 0);
|
||||
MercurialEditor editor;
|
||||
editor.setParameters(editorParameters + 2);
|
||||
editor.testDiffFileResolving();
|
||||
}
|
||||
|
||||
@@ -747,7 +747,8 @@ void MercurialPlugin::testLogResolving()
|
||||
"date: Sat Jan 19 04:08:16 2013 +0100\n"
|
||||
"summary: test-rebase: add another test for rebase with multiple roots\n"
|
||||
);
|
||||
MercurialEditor editor(editorParameters, 0);
|
||||
MercurialEditor editor;
|
||||
editor.setParameters(editorParameters);
|
||||
editor.testLogResolving(data, "18473:692cbda1eb50", "18472:37100f30590f");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -56,9 +56,7 @@ namespace Perforce {
|
||||
namespace Internal {
|
||||
|
||||
// ------------ PerforceEditor
|
||||
PerforceEditor::PerforceEditor(const VcsBase::VcsBaseEditorParameters *type,
|
||||
QWidget *parent) :
|
||||
VcsBase::VcsBaseEditorWidget(type, parent),
|
||||
PerforceEditor::PerforceEditor() :
|
||||
m_changeNumberPattern(QLatin1String("^\\d+$"))
|
||||
{
|
||||
QTC_CHECK(m_changeNumberPattern.isValid());
|
||||
@@ -70,8 +68,6 @@ PerforceEditor::PerforceEditor(const VcsBase::VcsBaseEditorParameters *type,
|
||||
setDiffFilePattern(QRegExp(QLatin1String("^(?:={4}|\\+{3}) (.+)(?:\\t|#\\d)")));
|
||||
setLogEntryPattern(QRegExp(QLatin1String("^... #\\d change (\\d+) ")));
|
||||
setAnnotateRevisionTextFormat(tr("Annotate change list \"%1\""));
|
||||
if (Perforce::Constants::debug)
|
||||
qDebug() << "PerforceEditor::PerforceEditor" << type->type << type->id;
|
||||
}
|
||||
|
||||
QSet<QString> PerforceEditor::annotationChanges() const
|
||||
|
||||
@@ -37,15 +37,12 @@
|
||||
namespace Perforce {
|
||||
namespace Internal {
|
||||
|
||||
class PerforcePlugin;
|
||||
|
||||
class PerforceEditor : public VcsBase::VcsBaseEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PerforceEditor(const VcsBase::VcsBaseEditorParameters *type,
|
||||
QWidget *parent);
|
||||
PerforceEditor();
|
||||
|
||||
private:
|
||||
QSet<QString> annotationChanges() const;
|
||||
|
||||
@@ -227,7 +227,6 @@ static const VcsBaseSubmitEditorParameters submitParameters = {
|
||||
|
||||
bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *errorMessage)
|
||||
{
|
||||
typedef VcsEditorFactory<PerforceEditor> PerforceEditorFactory;
|
||||
typedef VcsSubmitEditorFactory<PerforceSubmitEditor> PerforceSubmitEditorFactory;
|
||||
|
||||
initializeVcs(new PerforceVersionControl(this));
|
||||
@@ -245,8 +244,9 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er
|
||||
|
||||
static const char *describeSlot = SLOT(describe(QString,QString));
|
||||
const int editorCount = sizeof(editorParameters) / sizeof(editorParameters[0]);
|
||||
const auto widgetCreator = []() { return new PerforceEditor; };
|
||||
for (int i = 0; i < editorCount; i++)
|
||||
addAutoReleasedObject(new PerforceEditorFactory(editorParameters + i, this, describeSlot));
|
||||
addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, this, describeSlot));
|
||||
|
||||
const QString prefix = QLatin1String("p4");
|
||||
m_commandLocator = new CommandLocator("Perforce", prefix, prefix);
|
||||
@@ -1557,13 +1557,14 @@ void PerforcePlugin::testLogResolving()
|
||||
"\n"
|
||||
" Comment\n"
|
||||
);
|
||||
PerforceEditor editor(editorParameters, 0);
|
||||
PerforceEditor editor;
|
||||
editor.setParameters(editorParameters);
|
||||
editor.testLogResolving(data, "12345", "12344");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace Internal
|
||||
} // namespace Perforce
|
||||
|
||||
Q_EXPORT_PLUGIN(Perforce::Internal::PerforcePlugin)
|
||||
|
||||
|
||||
@@ -44,9 +44,7 @@
|
||||
using namespace Subversion;
|
||||
using namespace Subversion::Internal;
|
||||
|
||||
SubversionEditor::SubversionEditor(const VcsBase::VcsBaseEditorParameters *type,
|
||||
QWidget *parent) :
|
||||
VcsBase::VcsBaseEditorWidget(type, parent),
|
||||
SubversionEditor::SubversionEditor() :
|
||||
m_changeNumberPattern(QLatin1String("^\\d+$")),
|
||||
m_revisionNumberPattern(QLatin1String("^r\\d+$"))
|
||||
{
|
||||
|
||||
@@ -42,8 +42,7 @@ class SubversionEditor : public VcsBase::VcsBaseEditorWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SubversionEditor(const VcsBase::VcsBaseEditorParameters *type,
|
||||
QWidget *parent);
|
||||
SubversionEditor();
|
||||
|
||||
private:
|
||||
QSet<QString> annotationChanges() const;
|
||||
|
||||
@@ -248,7 +248,6 @@ const VcsBaseSubmitEditorParameters submitParameters = {
|
||||
bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *errorMessage)
|
||||
{
|
||||
typedef VcsSubmitEditorFactory<SubversionSubmitEditor> SubversionSubmitEditorFactory;
|
||||
typedef VcsEditorFactory<SubversionEditor> SubversionEditorFactory;
|
||||
using namespace Constants;
|
||||
|
||||
using namespace Core::Constants;
|
||||
@@ -270,8 +269,9 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
|
||||
static const char *describeSlot = SLOT(describe(QString,QString));
|
||||
const int editorCount = sizeof(editorParameters) / sizeof(editorParameters[0]);
|
||||
const auto widgetCreator = []() { return new SubversionEditor; };
|
||||
for (int i = 0; i < editorCount; i++)
|
||||
addAutoReleasedObject(new SubversionEditorFactory(editorParameters + i, this, describeSlot));
|
||||
addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, this, describeSlot));
|
||||
|
||||
auto checkoutWizardFactory = new BaseCheckoutWizardFactory;
|
||||
checkoutWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_SUBVERSION));
|
||||
@@ -1282,7 +1282,8 @@ void SubversionPlugin::testDiffFileResolving_data()
|
||||
|
||||
void SubversionPlugin::testDiffFileResolving()
|
||||
{
|
||||
SubversionEditor editor(editorParameters + 2, 0);
|
||||
SubversionEditor editor;
|
||||
editor.setParameters(editorParameters + 2);
|
||||
editor.testDiffFileResolving();
|
||||
}
|
||||
|
||||
@@ -1304,7 +1305,8 @@ void SubversionPlugin::testLogResolving()
|
||||
" expectations, remove XFail.\n"
|
||||
"\n"
|
||||
);
|
||||
SubversionEditor editor(editorParameters, 0);
|
||||
SubversionEditor editor;
|
||||
editor.setParameters(editorParameters);
|
||||
editor.testLogResolving(data, "r1439551", "r1439540");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QStringList>
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
/*!
|
||||
\class VcsBase::BaseVCSEditorFactory
|
||||
|
||||
@@ -52,44 +54,57 @@ namespace Internal {
|
||||
class BaseVcsEditorFactoryPrivate
|
||||
{
|
||||
public:
|
||||
const VcsBaseEditorParameters *m_type;
|
||||
const VcsBaseEditorParameters *m_parameters;
|
||||
QObject *m_describeReceiver;
|
||||
const char *m_describeSlot;
|
||||
BaseTextEditor::WidgetCreator m_widgetCreator;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
BaseVcsEditorFactory::BaseVcsEditorFactory(const VcsBaseEditorParameters *t,
|
||||
QObject *describeReceiver, const char *describeSlot)
|
||||
VcsEditorFactory::VcsEditorFactory(const VcsBaseEditorParameters *parameters,
|
||||
const BaseTextEditor::WidgetCreator &creator,
|
||||
QObject *describeReceiver, const char *describeSlot)
|
||||
: d(new Internal::BaseVcsEditorFactoryPrivate)
|
||||
{
|
||||
d->m_type = t;
|
||||
d->m_parameters = parameters;
|
||||
d->m_describeReceiver = describeReceiver;
|
||||
d->m_describeSlot = describeSlot;
|
||||
setId(t->id);
|
||||
setDisplayName(QCoreApplication::translate("VCS", t->displayName));
|
||||
if (QLatin1String(t->mimeType) != QLatin1String(DiffEditor::Constants::DIFF_EDITOR_MIMETYPE))
|
||||
addMimeType(t->mimeType);
|
||||
new TextEditor::TextEditorActionHandler(this, t->context);
|
||||
d->m_widgetCreator = creator;
|
||||
setId(parameters->id);
|
||||
setDisplayName(QCoreApplication::translate("VCS", parameters->displayName));
|
||||
if (QLatin1String(parameters->mimeType) != QLatin1String(DiffEditor::Constants::DIFF_EDITOR_MIMETYPE))
|
||||
addMimeType(parameters->mimeType);
|
||||
new TextEditor::TextEditorActionHandler(this, parameters->context);
|
||||
}
|
||||
|
||||
BaseVcsEditorFactory::~BaseVcsEditorFactory()
|
||||
VcsEditorFactory::~VcsEditorFactory()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
Core::IEditor *BaseVcsEditorFactory::createEditor()
|
||||
Core::IEditor *VcsEditorFactory::createEditor()
|
||||
{
|
||||
VcsBaseEditorWidget *vcsEditor = createVcsBaseEditor(d->m_type);
|
||||
TextEditor::BaseTextEditor *editor = new VcsBaseEditor(d->m_parameters);
|
||||
|
||||
vcsEditor->init();
|
||||
VcsBaseEditorWidget *widget = qobject_cast<VcsBaseEditorWidget *>(d->m_widgetCreator());
|
||||
widget->setParameters(d->m_parameters);
|
||||
|
||||
// Pass on signals.
|
||||
connect(widget, SIGNAL(describeRequested(QString,QString)),
|
||||
editor, SIGNAL(describeRequested(QString,QString)));
|
||||
connect(widget, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),
|
||||
editor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)));
|
||||
editor->setEditorWidget(widget);
|
||||
|
||||
widget->init();
|
||||
if (d->m_describeReceiver)
|
||||
connect(vcsEditor, SIGNAL(describeRequested(QString,QString)), d->m_describeReceiver, d->m_describeSlot);
|
||||
connect(widget, SIGNAL(describeRequested(QString,QString)), d->m_describeReceiver, d->m_describeSlot);
|
||||
|
||||
if (!mimeTypes().isEmpty())
|
||||
vcsEditor->textDocument()->setMimeType(mimeTypes().front());
|
||||
widget->textDocument()->setMimeType(mimeTypes().front());
|
||||
|
||||
return vcsEditor->editor();
|
||||
return editor;
|
||||
}
|
||||
|
||||
} // namespace VcsBase
|
||||
|
||||
@@ -34,48 +34,28 @@
|
||||
#include "vcsbaseeditor.h"
|
||||
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
|
||||
namespace VcsBase {
|
||||
namespace Internal { class BaseVcsEditorFactoryPrivate; }
|
||||
|
||||
class VCSBASE_EXPORT BaseVcsEditorFactory : public Core::IEditorFactory
|
||||
class VCSBASE_EXPORT VcsEditorFactory : public Core::IEditorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BaseVcsEditorFactory(const VcsBaseEditorParameters *type,
|
||||
QObject *describeReceiver,
|
||||
const char *describeSlot);
|
||||
~BaseVcsEditorFactory();
|
||||
VcsEditorFactory(const VcsBaseEditorParameters *type,
|
||||
const TextEditor::BaseTextEditor::WidgetCreator &creator,
|
||||
QObject *describeReceiver,
|
||||
const char *describeSlot);
|
||||
~VcsEditorFactory();
|
||||
|
||||
Core::IEditor *createEditor();
|
||||
|
||||
private:
|
||||
// Implement to create and initialize (call init()) a VcsBaseEditor subclass.
|
||||
virtual VcsBaseEditorWidget *createVcsBaseEditor(const VcsBaseEditorParameters *type) = 0;
|
||||
|
||||
Internal::BaseVcsEditorFactoryPrivate *const d;
|
||||
};
|
||||
|
||||
// Utility template to create an editor.
|
||||
template <class Editor>
|
||||
class VcsEditorFactory : public BaseVcsEditorFactory
|
||||
{
|
||||
public:
|
||||
explicit VcsEditorFactory(const VcsBaseEditorParameters *type,
|
||||
QObject *describeReceiver = 0,
|
||||
const char *describeSlot = 0)
|
||||
: BaseVcsEditorFactory(type, describeReceiver, describeSlot)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
VcsBaseEditorWidget *createVcsBaseEditor(const VcsBaseEditorParameters *type)
|
||||
{
|
||||
return new Editor(type, 0);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace VcsBase
|
||||
|
||||
#endif // BASEVCSEDITORFACTORY_H
|
||||
|
||||
@@ -150,18 +150,6 @@ namespace VcsBase {
|
||||
manager passes the editor around.
|
||||
*/
|
||||
|
||||
class VcsBaseEditor : public TextEditor::BaseTextEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VcsBaseEditor(const VcsBaseEditorParameters *type);
|
||||
|
||||
signals:
|
||||
void describeRequested(const QString &source, const QString &change);
|
||||
void annotateRevisionRequested(const QString &workingDirectory, const QString &file,
|
||||
const QString &change, int line);
|
||||
};
|
||||
|
||||
VcsBaseEditor::VcsBaseEditor(const VcsBaseEditorParameters *type)
|
||||
{
|
||||
setContext(Core::Context(type->context, TextEditor::Constants::C_TEXTEDITOR));
|
||||
@@ -547,13 +535,14 @@ void EmailTextCursorHandler::slotOpenUrl()
|
||||
class VcsBaseEditorWidgetPrivate
|
||||
{
|
||||
public:
|
||||
VcsBaseEditorWidgetPrivate(VcsBaseEditorWidget* editorWidget, const VcsBaseEditorParameters *type);
|
||||
VcsBaseEditorWidgetPrivate(VcsBaseEditorWidget *editorWidget);
|
||||
|
||||
AbstractTextCursorHandler *findTextCursorHandler(const QTextCursor &cursor);
|
||||
// creates a browse combo in the toolbar for quick access to entries.
|
||||
// Can be used for diff and log. Combo created on first call.
|
||||
QComboBox *entriesComboBox();
|
||||
|
||||
TextEditor::BaseTextEditorWidget *q;
|
||||
const VcsBaseEditorParameters *m_parameters;
|
||||
|
||||
QString m_workingDirectory;
|
||||
@@ -566,7 +555,6 @@ public:
|
||||
QString m_annotatePreviousRevisionTextFormat;
|
||||
QString m_copyRevisionTextFormat;
|
||||
bool m_fileLogAnnotateEnabled;
|
||||
TextEditor::BaseTextEditor *m_editor;
|
||||
VcsBaseEditorParameterWidget *m_configurationWidget;
|
||||
bool m_mouseDragging;
|
||||
QList<AbstractTextCursorHandler *> m_textCursorHandlers;
|
||||
@@ -576,14 +564,13 @@ private:
|
||||
QComboBox *m_entriesComboBox;
|
||||
};
|
||||
|
||||
VcsBaseEditorWidgetPrivate::VcsBaseEditorWidgetPrivate(VcsBaseEditorWidget *editorWidget,
|
||||
const VcsBaseEditorParameters *type) :
|
||||
m_parameters(type),
|
||||
VcsBaseEditorWidgetPrivate::VcsBaseEditorWidgetPrivate(VcsBaseEditorWidget *editorWidget) :
|
||||
q(editorWidget),
|
||||
m_parameters(0),
|
||||
m_cursorLine(-1),
|
||||
m_annotateRevisionTextFormat(VcsBaseEditorWidget::tr("Annotate \"%1\"")),
|
||||
m_copyRevisionTextFormat(VcsBaseEditorWidget::tr("Copy \"%1\"")),
|
||||
m_fileLogAnnotateEnabled(false),
|
||||
m_editor(0),
|
||||
m_configurationWidget(0),
|
||||
m_mouseDragging(false),
|
||||
m_entriesComboBox(0)
|
||||
@@ -613,8 +600,7 @@ QComboBox *VcsBaseEditorWidgetPrivate::entriesComboBox()
|
||||
policy.setHorizontalPolicy(QSizePolicy::Expanding);
|
||||
m_entriesComboBox->setSizePolicy(policy);
|
||||
|
||||
m_editor->editorWidget()->insertExtraToolBarWidget
|
||||
(TextEditor::BaseTextEditorWidget::Left, m_entriesComboBox);
|
||||
q->insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, m_entriesComboBox);
|
||||
return m_entriesComboBox;
|
||||
}
|
||||
|
||||
@@ -647,15 +633,20 @@ QComboBox *VcsBaseEditorWidgetPrivate::entriesComboBox()
|
||||
\sa VcsBase::BaseVcsEditorFactory, VcsBase::VcsBaseEditorParameters, VcsBase::EditorContentType
|
||||
*/
|
||||
|
||||
VcsBaseEditorWidget::VcsBaseEditorWidget(const VcsBaseEditorParameters *type, QWidget *parent)
|
||||
: BaseTextEditorWidget(parent),
|
||||
d(new Internal::VcsBaseEditorWidgetPrivate(this, type))
|
||||
VcsBaseEditorWidget::VcsBaseEditorWidget()
|
||||
: d(new Internal::VcsBaseEditorWidgetPrivate(this))
|
||||
{
|
||||
BaseTextDocumentPtr doc(new BaseTextDocument);
|
||||
doc->setId(type->id);
|
||||
doc->setMimeType(QLatin1String(d->m_parameters->mimeType));
|
||||
setTextDocument(doc);
|
||||
viewport()->setMouseTracking(true);
|
||||
BaseTextDocumentPtr doc(new BaseTextDocument);
|
||||
setTextDocument(doc);
|
||||
}
|
||||
|
||||
void VcsBaseEditorWidget::setParameters(const VcsBaseEditorParameters *parameters)
|
||||
{
|
||||
QTC_CHECK(d->m_parameters == 0);
|
||||
d->m_parameters = parameters;
|
||||
textDocument()->setId(d->m_parameters->id);
|
||||
textDocument()->setMimeType(QLatin1String(d->m_parameters->mimeType));
|
||||
}
|
||||
|
||||
void VcsBaseEditorWidget::setDiffFilePattern(const QRegExp &pattern)
|
||||
@@ -689,7 +680,6 @@ QString VcsBaseEditorWidget::fileNameForLine(int line) const
|
||||
|
||||
void VcsBaseEditorWidget::init()
|
||||
{
|
||||
d->m_editor = editor();
|
||||
switch (d->m_parameters->type) {
|
||||
case OtherContent:
|
||||
break;
|
||||
@@ -817,14 +807,7 @@ bool VcsBaseEditorWidget::isModified() const
|
||||
|
||||
TextEditor::BaseTextEditor *VcsBaseEditorWidget::createEditor()
|
||||
{
|
||||
TextEditor::BaseTextEditor *editor = new VcsBaseEditor(d->m_parameters);
|
||||
|
||||
// Pass on signals.
|
||||
connect(this, SIGNAL(describeRequested(QString,QString)),
|
||||
editor, SIGNAL(describeRequested(QString,QString)));
|
||||
connect(this, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),
|
||||
editor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)));
|
||||
return editor;
|
||||
QTC_ASSERT("should not happen anymore" && false, return 0);
|
||||
}
|
||||
|
||||
void VcsBaseEditorWidget::slotPopulateDiffBrowser()
|
||||
@@ -1334,11 +1317,11 @@ QString VcsBaseEditorWidget::getTitleId(const QString &workingDirectory,
|
||||
|
||||
bool VcsBaseEditorWidget::setConfigurationWidget(VcsBaseEditorParameterWidget *w)
|
||||
{
|
||||
if (!d->m_editor || d->m_configurationWidget)
|
||||
if (d->m_configurationWidget)
|
||||
return false;
|
||||
|
||||
d->m_configurationWidget = w;
|
||||
d->m_editor->editorWidget()->insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Right, w);
|
||||
insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Right, w);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1569,8 +1552,21 @@ Core::IEditor* VcsBaseEditorWidget::locateEditorByTag(const QString &tag)
|
||||
#ifdef WITH_TESTS
|
||||
#include <QTest>
|
||||
|
||||
// Tests need a fully set-up editor/widget combo.
|
||||
void VcsBase::VcsBaseEditorWidget::addDummyEditor()
|
||||
{
|
||||
TextEditor::BaseTextEditor *editor = new VcsBaseEditor(d->m_parameters);
|
||||
// Pass on signals.
|
||||
connect(this, SIGNAL(describeRequested(QString,QString)),
|
||||
editor, SIGNAL(describeRequested(QString,QString)));
|
||||
connect(this, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),
|
||||
editor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)));
|
||||
editor->setEditorWidget(this);
|
||||
}
|
||||
|
||||
void VcsBase::VcsBaseEditorWidget::testDiffFileResolving()
|
||||
{
|
||||
addDummyEditor();
|
||||
QFETCH(QByteArray, header);
|
||||
QFETCH(QByteArray, fileName);
|
||||
QTextDocument doc(QString::fromLatin1(header));
|
||||
@@ -1583,6 +1579,7 @@ void VcsBase::VcsBaseEditorWidget::testLogResolving(QByteArray &data,
|
||||
const QByteArray &entry1,
|
||||
const QByteArray &entry2)
|
||||
{
|
||||
addDummyEditor();
|
||||
init();
|
||||
textDocument()->setPlainText(QLatin1String(data));
|
||||
QCOMPARE(d->entriesComboBox()->itemText(0), QString::fromLatin1(entry1));
|
||||
|
||||
@@ -87,6 +87,18 @@ public:
|
||||
QByteArray header;
|
||||
};
|
||||
|
||||
class VcsBaseEditor : public TextEditor::BaseTextEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VcsBaseEditor(const VcsBaseEditorParameters *type);
|
||||
|
||||
signals:
|
||||
void describeRequested(const QString &source, const QString &change);
|
||||
void annotateRevisionRequested(const QString &workingDirectory, const QString &file,
|
||||
const QString &change, int line);
|
||||
};
|
||||
|
||||
class VCSBASE_EXPORT VcsBaseEditorWidget : public TextEditor::BaseTextEditorWidget
|
||||
{
|
||||
Q_PROPERTY(QString source READ source WRITE setSource)
|
||||
@@ -100,8 +112,7 @@ class VCSBASE_EXPORT VcsBaseEditorWidget : public TextEditor::BaseTextEditorWidg
|
||||
protected:
|
||||
// Initialization requires calling init() (which in turns calls
|
||||
// virtual functions).
|
||||
explicit VcsBaseEditorWidget(const VcsBaseEditorParameters *type,
|
||||
QWidget *parent);
|
||||
VcsBaseEditorWidget();
|
||||
// Pattern for diff header. File name must be in the first capture group
|
||||
void setDiffFilePattern(const QRegExp &pattern);
|
||||
// Pattern for log entry. hash/revision number must be in the first capture group
|
||||
@@ -111,6 +122,8 @@ protected:
|
||||
|
||||
public:
|
||||
virtual void init();
|
||||
//
|
||||
void setParameters(const VcsBaseEditorParameters *parameters);
|
||||
|
||||
~VcsBaseEditorWidget();
|
||||
|
||||
@@ -281,6 +294,7 @@ private:
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
public:
|
||||
void addDummyEditor();
|
||||
void testDiffFileResolving();
|
||||
void testLogResolving(QByteArray &data, const QByteArray &entry1, const QByteArray &entry2);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user