forked from qt-creator/qt-creator
VCS: Notify project wizard about config changes
... and have the project wizard update the available VCS. Task-number: QTCREATORBUG-4423
This commit is contained in:
@@ -177,3 +177,8 @@ void BazaarControl::changed(const QVariant &v)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BazaarControl::emitConfigurationChanged()
|
||||
{
|
||||
emit configurationChanged();
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ public slots:
|
||||
// files changed signals according to the variant's type:
|
||||
// String -> repository, StringList -> files
|
||||
void changed(const QVariant&);
|
||||
void emitConfigurationChanged();
|
||||
|
||||
private:
|
||||
BazaarClient *m_bazaarClient;
|
||||
|
||||
@@ -208,6 +208,7 @@ void BazaarPlugin::setSettings(const BazaarSettings &settings)
|
||||
m_bazaarSettings = settings;
|
||||
if (userIdChanged)
|
||||
client()->synchronousSetUserId();
|
||||
static_cast<BazaarControl *>(versionControl())->emitConfigurationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,6 +166,7 @@ public:
|
||||
signals:
|
||||
void repositoryChanged(const QString &repository);
|
||||
void filesChanged(const QStringList &files);
|
||||
void configurationChanged();
|
||||
|
||||
// TODO: ADD A WAY TO DETECT WHETHER A FILE IS MANAGED, e.g
|
||||
// virtual bool sccManaged(const QString &filename) = 0;
|
||||
|
||||
@@ -158,3 +158,8 @@ void CVSControl::emitFilesChanged(const QStringList &l)
|
||||
{
|
||||
emit filesChanged(l);
|
||||
}
|
||||
|
||||
void CVSControl::emitConfigurationChanged()
|
||||
{
|
||||
emit configurationChanged();
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ public:
|
||||
|
||||
void emitRepositoryChanged(const QString &s);
|
||||
void emitFilesChanged(const QStringList &l);
|
||||
void emitConfigurationChanged();
|
||||
|
||||
private:
|
||||
CVSPlugin *m_plugin;
|
||||
|
||||
@@ -1320,6 +1320,7 @@ void CVSPlugin::setSettings(const CVSSettings &s)
|
||||
m_settings = s;
|
||||
if (QSettings *settings = Core::ICore::instance()->settings())
|
||||
m_settings.toSettings(settings);
|
||||
cvsVersionControl()->emitConfigurationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2387,6 +2387,7 @@ void GitClient::setSettings(const GitSettings &s)
|
||||
m_binaryPath = m_settings.gitBinaryPath();
|
||||
m_cachedGitVersion = 0u;
|
||||
m_hasCachedGitVersion = false;
|
||||
m_plugin->gitVersionControl()->emitConfigurationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -247,5 +247,10 @@ void GitVersionControl::emitRepositoryChanged(const QString &r)
|
||||
emit repositoryChanged(r);
|
||||
}
|
||||
|
||||
void GitVersionControl::emitConfigurationChanged()
|
||||
{
|
||||
emit configurationChanged();
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // Git
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
|
||||
void emitFilesChanged(const QStringList &);
|
||||
void emitRepositoryChanged(const QString &);
|
||||
void emitConfigurationChanged();
|
||||
|
||||
private:
|
||||
GitClient *m_client;
|
||||
|
||||
@@ -183,3 +183,8 @@ void MercurialControl::changed(const QVariant &v)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MercurialControl::emitConfigurationChanged()
|
||||
{
|
||||
emit configurationChanged();
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ public slots:
|
||||
// files changed signals according to the variant's type:
|
||||
// String -> repository, StringList -> files
|
||||
void changed(const QVariant&);
|
||||
void emitConfigurationChanged();
|
||||
|
||||
private:
|
||||
MercurialClient *mercurialClient;
|
||||
|
||||
@@ -199,6 +199,7 @@ void MercurialPlugin::setSettings(const MercurialSettings &settings)
|
||||
{
|
||||
if (settings != mercurialSettings) {
|
||||
mercurialSettings = settings;
|
||||
static_cast<MercurialControl *>(versionControl())->emitConfigurationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1457,6 +1457,7 @@ void PerforcePlugin::setSettings(const Settings &newSettings)
|
||||
m_managedDirectoryCache.clear();
|
||||
m_settings.toSettings(Core::ICore::instance()->settings());
|
||||
getTopLevel();
|
||||
perforceVersionControl()->emitConfigurationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -175,5 +175,10 @@ void PerforceVersionControl::emitFilesChanged(const QStringList &l)
|
||||
emit filesChanged(l);
|
||||
}
|
||||
|
||||
void PerforceVersionControl::emitConfigurationChanged()
|
||||
{
|
||||
emit configurationChanged();
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // Perforce
|
||||
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
|
||||
void emitRepositoryChanged(const QString &s);
|
||||
void emitFilesChanged(const QStringList &l);
|
||||
void emitConfigurationChanged();
|
||||
|
||||
private:
|
||||
bool m_enabled;
|
||||
|
||||
@@ -169,6 +169,7 @@ struct ProjectWizardContext
|
||||
void clear();
|
||||
|
||||
QList<Core::IVersionControl*> versionControls;
|
||||
QList<Core::IVersionControl*> activeVersionControls;
|
||||
QList<ProjectEntry> projects;
|
||||
ProjectWizardPage *page;
|
||||
bool repositoryExists; // Is VCS 'add' sufficient, or should a repository be created?
|
||||
@@ -185,7 +186,7 @@ ProjectWizardContext::ProjectWizardContext() :
|
||||
|
||||
void ProjectWizardContext::clear()
|
||||
{
|
||||
versionControls.clear();
|
||||
activeVersionControls.clear();
|
||||
projects.clear();
|
||||
commonDirectory.clear();
|
||||
page = 0;
|
||||
@@ -299,6 +300,13 @@ void ProjectFileWizardExtension::firstExtensionPageShown(
|
||||
} else {
|
||||
m_context->page->setCurrentProjectIndex(bestProjectIndex + 1);
|
||||
}
|
||||
|
||||
// Store all version controls for later use:
|
||||
foreach (Core::IVersionControl *vc, ExtensionSystem::PluginManager::instance()->getObjects<Core::IVersionControl>()) {
|
||||
m_context->versionControls.append(vc);
|
||||
connect(vc, SIGNAL(configurationChanged()), this, SLOT(initializeVersionControlChoices()));
|
||||
}
|
||||
|
||||
initializeVersionControlChoices();
|
||||
}
|
||||
|
||||
@@ -308,32 +316,42 @@ void ProjectFileWizardExtension::initializeVersionControlChoices()
|
||||
// 1) Directory is managed and VCS supports "Add" -> List it
|
||||
// 2) Directory is managed and VCS does not support "Add" -> None available
|
||||
// 3) Directory is not managed -> Offer all VCS that support "CreateRepository"
|
||||
m_context->versionControls.clear();
|
||||
|
||||
Core::IVersionControl *currentSelection = 0;
|
||||
int currentIdx = m_context->page->versionControlIndex() - 1;
|
||||
if (currentIdx >= 0 && currentIdx <= m_context->activeVersionControls.size() - 1)
|
||||
currentSelection = m_context->activeVersionControls.at(currentIdx);
|
||||
|
||||
m_context->activeVersionControls.clear();
|
||||
|
||||
QStringList versionControlChoices = QStringList(tr("<None>"));
|
||||
if (!m_context->commonDirectory.isEmpty()) {
|
||||
Core::IVersionControl *managingControl = Core::ICore::instance()->vcsManager()->findVersionControlForDirectory(m_context->commonDirectory);
|
||||
if (managingControl) {
|
||||
// Under VCS
|
||||
if (managingControl->supportsOperation(Core::IVersionControl::AddOperation)) {
|
||||
m_context->versionControls.push_back(managingControl);
|
||||
m_context->activeVersionControls.push_back(managingControl);
|
||||
m_context->repositoryExists = true;
|
||||
}
|
||||
} else {
|
||||
// Create
|
||||
foreach (Core::IVersionControl *vc, ExtensionSystem::PluginManager::instance()->getObjects<Core::IVersionControl>())
|
||||
if (vc->supportsOperation(Core::IVersionControl::CreateRepositoryOperation))
|
||||
m_context->versionControls.push_back(vc);
|
||||
foreach (Core::IVersionControl *vc, m_context->versionControls)
|
||||
if (vc->supportsOperation(Core::IVersionControl::CreateRepositoryOperation)) {
|
||||
versionControlChoices.append(vc->displayName());
|
||||
m_context->activeVersionControls.append(vc);
|
||||
}
|
||||
m_context->repositoryExists = false;
|
||||
}
|
||||
} // has a common root.
|
||||
// Compile names
|
||||
//: No version control system selected
|
||||
QStringList versionControlChoices = QStringList(tr("<None>"));
|
||||
foreach(const Core::IVersionControl *c, m_context->versionControls)
|
||||
versionControlChoices.push_back(c->displayName());
|
||||
|
||||
m_context->page->setVersionControls(versionControlChoices);
|
||||
// Enable adding to version control by default.
|
||||
if (m_context->repositoryExists && versionControlChoices.size() >= 2)
|
||||
m_context->page->setVersionControlIndex(1);
|
||||
if (!m_context->repositoryExists) {
|
||||
int newIdx = m_context->activeVersionControls.indexOf(currentSelection) + 1;
|
||||
m_context->page->setVersionControlIndex(newIdx);
|
||||
}
|
||||
}
|
||||
|
||||
QList<QWizardPage *> ProjectFileWizardExtension::extensionPages(const Core::IWizard *wizard)
|
||||
@@ -442,10 +460,10 @@ bool ProjectFileWizardExtension::processVersionControl(const QList<Core::Generat
|
||||
{
|
||||
// Add files to version control (Entry at 0 is 'None').
|
||||
const int vcsIndex = m_context->page->versionControlIndex() - 1;
|
||||
if (vcsIndex < 0 || vcsIndex >= m_context->versionControls.size())
|
||||
if (vcsIndex < 0 || vcsIndex >= m_context->activeVersionControls.size())
|
||||
return true;
|
||||
QTC_ASSERT(!m_context->commonDirectory.isEmpty(), return false);
|
||||
Core::IVersionControl *versionControl = m_context->versionControls.at(vcsIndex);
|
||||
Core::IVersionControl *versionControl = m_context->activeVersionControls.at(vcsIndex);
|
||||
// Create repository?
|
||||
if (!m_context->repositoryExists) {
|
||||
QTC_ASSERT(versionControl->supportsOperation(Core::IVersionControl::CreateRepositoryOperation), return false);
|
||||
|
||||
@@ -54,10 +54,10 @@ public:
|
||||
|
||||
public slots:
|
||||
void firstExtensionPageShown(const QList<Core::GeneratedFile> &files);
|
||||
void initializeVersionControlChoices();
|
||||
|
||||
private:
|
||||
void initProjectChoices(const QString &generatedProjectFilePath);
|
||||
void initializeVersionControlChoices();
|
||||
bool processProject(const QList<Core::GeneratedFile> &files,
|
||||
bool *removeOpenProjectAttribute, QString *errorMessage);
|
||||
bool processVersionControl(const QList<Core::GeneratedFile> &files, QString *errorMessage);
|
||||
|
||||
@@ -159,3 +159,8 @@ void SubversionControl::emitFilesChanged(const QStringList &l)
|
||||
{
|
||||
emit filesChanged(l);
|
||||
}
|
||||
|
||||
void SubversionControl::emitConfigurationChanged()
|
||||
{
|
||||
emit configurationChanged();
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
|
||||
void emitRepositoryChanged(const QString &);
|
||||
void emitFilesChanged(const QStringList &);
|
||||
void emitConfigurationChanged();
|
||||
|
||||
private:
|
||||
SubversionPlugin *m_plugin;
|
||||
|
||||
@@ -1203,6 +1203,7 @@ void SubversionPlugin::setSettings(const SubversionSettings &s)
|
||||
m_settings = s;
|
||||
if (QSettings *settings = Core::ICore::instance()->settings())
|
||||
m_settings.toSettings(settings);
|
||||
subVersionControl()->emitConfigurationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user