forked from qt-creator/qt-creator
VcsBase: Make VcsConfiguration page more dynamic
... again making it more useful for the JSON wizard Change-Id: Ic7a454c4efc93eb48a44ab2a37ecd39f8c6f3ba7 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -58,8 +58,11 @@ CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
|
|||||||
setStartedStatus(tr("Cloning started..."));
|
setStartedStatus(tr("Cloning started..."));
|
||||||
|
|
||||||
const Core::IVersionControl *vc = BazaarPlugin::instance()->versionControl();
|
const Core::IVersionControl *vc = BazaarPlugin::instance()->versionControl();
|
||||||
if (!vc->isConfigured())
|
if (!vc->isConfigured()) {
|
||||||
addPage(new VcsConfigurationPage(vc));
|
VcsConfigurationPage *configPage = new VcsConfigurationPage;
|
||||||
|
configPage->setVersionControl(vc);
|
||||||
|
addPage(configPage);
|
||||||
|
}
|
||||||
CloneWizardPage *page = new CloneWizardPage;
|
CloneWizardPage *page = new CloneWizardPage;
|
||||||
page->setPath(path.toString());
|
page->setPath(path.toString());
|
||||||
addPage(page);
|
addPage(page);
|
||||||
|
@@ -51,8 +51,11 @@ CheckoutWizard::CheckoutWizard(const Utils::FileName &path, QWidget *parent) :
|
|||||||
BaseCheckoutWizard(path, parent)
|
BaseCheckoutWizard(path, parent)
|
||||||
{
|
{
|
||||||
const Core::IVersionControl *vc = CvsPlugin::instance()->versionControl();
|
const Core::IVersionControl *vc = CvsPlugin::instance()->versionControl();
|
||||||
if (!vc->isConfigured())
|
if (!vc->isConfigured()) {
|
||||||
addPage(new VcsConfigurationPage(vc));
|
VcsConfigurationPage *configPage = new VcsConfigurationPage;
|
||||||
|
configPage->setVersionControl(vc);
|
||||||
|
addPage(configPage);
|
||||||
|
}
|
||||||
CheckoutWizardPage *cwp = new CheckoutWizardPage;
|
CheckoutWizardPage *cwp = new CheckoutWizardPage;
|
||||||
cwp->setPath(path.toString());
|
cwp->setPath(path.toString());
|
||||||
addPage(cwp);
|
addPage(cwp);
|
||||||
|
@@ -54,8 +54,11 @@ CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
|
|||||||
setStartedStatus(tr("Cloning started..."));
|
setStartedStatus(tr("Cloning started..."));
|
||||||
|
|
||||||
const Internal::GitVersionControl *vc = Internal::GitPlugin::instance()->gitVersionControl();
|
const Internal::GitVersionControl *vc = Internal::GitPlugin::instance()->gitVersionControl();
|
||||||
if (!vc->isConfigured())
|
if (!vc->isConfigured()) {
|
||||||
addPage(new VcsConfigurationPage(vc));
|
VcsConfigurationPage *configPage = new VcsConfigurationPage;
|
||||||
|
configPage->setVersionControl(vc);
|
||||||
|
addPage(configPage);
|
||||||
|
}
|
||||||
CloneWizardPage *cwp = new CloneWizardPage;
|
CloneWizardPage *cwp = new CloneWizardPage;
|
||||||
cwp->setPath(path.toString());
|
cwp->setPath(path.toString());
|
||||||
addPage(cwp);
|
addPage(cwp);
|
||||||
|
@@ -53,8 +53,11 @@ CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
|
|||||||
setStartedStatus(tr("Cloning started..."));
|
setStartedStatus(tr("Cloning started..."));
|
||||||
|
|
||||||
const Core::IVersionControl *vc = MercurialPlugin::instance()->versionControl();
|
const Core::IVersionControl *vc = MercurialPlugin::instance()->versionControl();
|
||||||
if (!vc->isConfigured())
|
if (!vc->isConfigured()) {
|
||||||
addPage(new VcsConfigurationPage(vc));
|
VcsConfigurationPage *configPage = new VcsConfigurationPage;
|
||||||
|
configPage->setVersionControl(vc);
|
||||||
|
addPage(configPage);
|
||||||
|
}
|
||||||
CloneWizardPage *page = new CloneWizardPage;
|
CloneWizardPage *page = new CloneWizardPage;
|
||||||
page->setPath(path.toString());
|
page->setPath(path.toString());
|
||||||
addPage(page);
|
addPage(page);
|
||||||
|
@@ -54,8 +54,11 @@ CheckoutWizard::CheckoutWizard(const FileName &path, QWidget *parent) :
|
|||||||
BaseCheckoutWizard(path, parent)
|
BaseCheckoutWizard(path, parent)
|
||||||
{
|
{
|
||||||
const Core::IVersionControl *vc = SubversionPlugin::instance()->versionControl();
|
const Core::IVersionControl *vc = SubversionPlugin::instance()->versionControl();
|
||||||
if (!vc->isConfigured())
|
if (!vc->isConfigured()) {
|
||||||
addPage(new VcsConfigurationPage(vc));
|
VcsConfigurationPage *configPage = new VcsConfigurationPage;
|
||||||
|
configPage->setVersionControl(vc);
|
||||||
|
addPage(configPage);
|
||||||
|
}
|
||||||
CheckoutWizardPage *cwp = new CheckoutWizardPage;
|
CheckoutWizardPage *cwp = new CheckoutWizardPage;
|
||||||
cwp->setPath(path.toString());
|
cwp->setPath(path.toString());
|
||||||
addPage(cwp);
|
addPage(cwp);
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/iversioncontrol.h>
|
#include <coreplugin/iversioncontrol.h>
|
||||||
#include <coreplugin/vcsmanager.h>
|
#include <coreplugin/vcsmanager.h>
|
||||||
|
#include <projectexplorer/jsonwizard/jsonwizard.h>
|
||||||
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
|
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
@@ -67,10 +68,10 @@ Utils::WizardPage *VcsConfigurationPageFactory::create(JsonWizard *wizard, Id ty
|
|||||||
const QString vcsId = tmp.value(QLatin1String("vcsId")).toString();
|
const QString vcsId = tmp.value(QLatin1String("vcsId")).toString();
|
||||||
QTC_ASSERT(!vcsId.isEmpty(), return 0);
|
QTC_ASSERT(!vcsId.isEmpty(), return 0);
|
||||||
|
|
||||||
IVersionControl *vc = VcsManager::versionControl(Id::fromString(vcsId));
|
VcsConfigurationPage *page = new VcsConfigurationPage;
|
||||||
QTC_ASSERT(vc, return 0);
|
page->setVersionControlId(vcsId);
|
||||||
|
|
||||||
return new VcsConfigurationPage(vc);
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VcsConfigurationPageFactory::validateData(Id typeId, const QVariant &data,
|
bool VcsConfigurationPageFactory::validateData(Id typeId, const QVariant &data,
|
||||||
@@ -91,17 +92,6 @@ bool VcsConfigurationPageFactory::validateData(Id typeId, const QVariant &data,
|
|||||||
"\"VcsConfiguration\" page requires a \"vcsId\" set.");
|
"\"VcsConfiguration\" page requires a \"vcsId\" set.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!VcsManager::versionControl(Id::fromString(vcsId))) {
|
|
||||||
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
|
|
||||||
"\"vcsId\" (\"%1\") is invalid for \"VcsConfiguration\" page. "
|
|
||||||
"Possible values are: %2.")
|
|
||||||
.arg(vcsId)
|
|
||||||
.arg(QStringList(Utils::transform(VcsManager::versionControls(), [](const IVersionControl *vc) {
|
|
||||||
return vc->id().toString();
|
|
||||||
})).join(QLatin1String(", ")));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,21 +99,19 @@ class VcsConfigurationPagePrivate
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const IVersionControl *m_versionControl;
|
const IVersionControl *m_versionControl;
|
||||||
|
QString m_versionControlId;
|
||||||
QPushButton *m_configureButton;
|
QPushButton *m_configureButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
VcsConfigurationPage::VcsConfigurationPage(const IVersionControl *vc, QWidget *parent) :
|
VcsConfigurationPage::VcsConfigurationPage() : d(new Internal::VcsConfigurationPagePrivate)
|
||||||
Utils::WizardPage(parent),
|
|
||||||
d(new Internal::VcsConfigurationPagePrivate)
|
|
||||||
{
|
{
|
||||||
QTC_ASSERT(vc, return);
|
|
||||||
setTitle(tr("Configuration"));
|
setTitle(tr("Configuration"));
|
||||||
setSubTitle(tr("Please configure <b>%1</b> now.").arg(vc->displayName()));
|
|
||||||
|
|
||||||
d->m_versionControl = vc;
|
d->m_versionControl = 0;
|
||||||
d->m_configureButton = new QPushButton(ICore::msgShowOptionsDialog(), this);
|
d->m_configureButton = new QPushButton(ICore::msgShowOptionsDialog(), this);
|
||||||
|
d->m_configureButton->setEnabled(false);
|
||||||
|
|
||||||
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
|
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
|
||||||
verticalLayout->addWidget(d->m_configureButton);
|
verticalLayout->addWidget(d->m_configureButton);
|
||||||
@@ -137,9 +125,51 @@ VcsConfigurationPage::~VcsConfigurationPage()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VcsConfigurationPage::setVersionControl(const IVersionControl *vc)
|
||||||
|
{
|
||||||
|
if (vc)
|
||||||
|
d->m_versionControlId = vc->id().toString();
|
||||||
|
else
|
||||||
|
d->m_versionControlId.clear();
|
||||||
|
d->m_versionControl = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VcsConfigurationPage::setVersionControlId(const QString &id)
|
||||||
|
{
|
||||||
|
d->m_versionControlId = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VcsConfigurationPage::initializePage()
|
||||||
|
{
|
||||||
|
if (!d->m_versionControlId.isEmpty()) {
|
||||||
|
auto jw = qobject_cast<JsonWizard *>(wizard());
|
||||||
|
if (!jw)
|
||||||
|
emit reportError(tr("No version control set on \"VcsConfiguration\" page."));
|
||||||
|
|
||||||
|
const QString vcsId = jw ? jw->expander()->expand(d->m_versionControlId) : d->m_versionControlId;
|
||||||
|
|
||||||
|
d->m_versionControl = VcsManager::versionControl(Id::fromString(vcsId));
|
||||||
|
if (!d->m_versionControl) {
|
||||||
|
emit reportError(
|
||||||
|
tr("\"vcsId\" (\"%1\") is invalid for \"VcsConfiguration\" page. "
|
||||||
|
"Possible values are: %2.")
|
||||||
|
.arg(vcsId)
|
||||||
|
.arg(QStringList(Utils::transform(VcsManager::versionControls(), [](const IVersionControl *vc) {
|
||||||
|
return vc->id().toString();
|
||||||
|
})).join(QLatin1String(", "))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
d->m_configureButton->setEnabled(d->m_versionControl);
|
||||||
|
if (d->m_versionControl)
|
||||||
|
setSubTitle(tr("Please configure <b>%1</b> now.").arg(d->m_versionControl->displayName()));
|
||||||
|
else
|
||||||
|
setSubTitle(tr("No known version control selected."));
|
||||||
|
}
|
||||||
|
|
||||||
bool VcsConfigurationPage::isComplete() const
|
bool VcsConfigurationPage::isComplete() const
|
||||||
{
|
{
|
||||||
return d->m_versionControl->isConfigured();
|
return d->m_versionControl ? d->m_versionControl->isConfigured() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsConfigurationPage::openConfiguration()
|
void VcsConfigurationPage::openConfiguration()
|
||||||
|
@@ -61,10 +61,13 @@ class VCSBASE_EXPORT VcsConfigurationPage : public Utils::WizardPage
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// TODO: Make this set the VCS only in initializePage.
|
VcsConfigurationPage();
|
||||||
explicit VcsConfigurationPage(const Core::IVersionControl *, QWidget *parent = 0);
|
|
||||||
~VcsConfigurationPage();
|
~VcsConfigurationPage();
|
||||||
|
|
||||||
|
void setVersionControl(const Core::IVersionControl *vc);
|
||||||
|
void setVersionControlId(const QString &id);
|
||||||
|
|
||||||
|
void initializePage();
|
||||||
bool isComplete() const;
|
bool isComplete() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
Reference in New Issue
Block a user