forked from qt-creator/qt-creator
Refactoring: Move QtVersionManager instance() into the ProjectExplorer
And add a instance() method to it.
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
#include "session.h"
|
||||
#include "sessiondialog.h"
|
||||
#include "buildparserfactory.h"
|
||||
#include "qtversionmanager.h"
|
||||
|
||||
#include <coreplugin/basemode.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
@@ -194,6 +195,9 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
connect(m_buildManager, SIGNAL(tasksChanged()),
|
||||
this, SLOT(updateTaskActions()));
|
||||
|
||||
m_versionManager = new QtVersionManager();
|
||||
addAutoReleasedObject(m_versionManager);
|
||||
|
||||
addAutoReleasedObject(new CoreListenerCheckingForRunningBuild(m_buildManager));
|
||||
|
||||
m_outputPane = new OutputPane;
|
||||
@@ -1905,4 +1909,9 @@ void ProjectExplorerPlugin::setSession(QAction *action)
|
||||
m_session->loadSession(session);
|
||||
}
|
||||
|
||||
QtVersionManager *ProjectExplorerPlugin::qtVersionManager() const
|
||||
{
|
||||
return m_versionManager;
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(ProjectExplorerPlugin)
|
||||
|
||||
@@ -64,6 +64,7 @@ class RunConfiguration;
|
||||
class RunControl;
|
||||
class SessionManager;
|
||||
class IRunConfigurationRunner;
|
||||
class QtVersionManager;
|
||||
|
||||
namespace Internal {
|
||||
class ApplicationOutput;
|
||||
@@ -104,6 +105,8 @@ public:
|
||||
|
||||
void showContextMenu(const QPoint &globalPos, Node *node);
|
||||
|
||||
QtVersionManager *qtVersionManager() const;
|
||||
|
||||
//PluginInterface
|
||||
bool initialize(const QStringList &arguments, QString *error_message);
|
||||
void extensionsInitialized();
|
||||
@@ -246,6 +249,7 @@ private:
|
||||
Node *m_currentNode;
|
||||
|
||||
BuildManager *m_buildManager;
|
||||
QtVersionManager *m_versionManager;
|
||||
|
||||
QList<Internal::ProjectFileFactory*> m_fileFactories;
|
||||
QStringList m_profileMimeTypes;
|
||||
|
||||
@@ -32,12 +32,14 @@
|
||||
#include "projectexplorerconstants.h"
|
||||
#include "ui_showbuildlog.h"
|
||||
#include "ui_qtversionmanager.h"
|
||||
#include "cesdkhandler.h"
|
||||
#include "toolchain.h"
|
||||
|
||||
#include "projectexplorer.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <projectexplorer/cesdkhandler.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <help/helpplugin.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -113,6 +115,11 @@ QtVersionManager::~QtVersionManager()
|
||||
m_emptyVersion = 0;
|
||||
}
|
||||
|
||||
QtVersionManager::QtVersionManager *instance()
|
||||
{
|
||||
return ProjectExplorerPlugin::instance()->qtVersionManager();
|
||||
}
|
||||
|
||||
void QtVersionManager::addVersion(QtVersion *version)
|
||||
{
|
||||
m_versions.append(version);
|
||||
@@ -162,8 +169,6 @@ QString QtVersionManager::trCategory() const
|
||||
|
||||
QWidget *QtVersionManager::createPage(QWidget *parent)
|
||||
{
|
||||
if (m_widget)
|
||||
delete m_widget;
|
||||
m_widget = new QtDirWidget(parent, m_versions, m_defaultVersion);
|
||||
return m_widget;
|
||||
}
|
||||
@@ -1354,8 +1359,7 @@ int QtVersion::uniqueId() const
|
||||
|
||||
int QtVersion::getUniqueId()
|
||||
{
|
||||
QtVersionManager *vm = ExtensionSystem::PluginManager::instance()->getObject<QtVersionManager>();
|
||||
return vm->getUniqueId();
|
||||
return QtVersionManager::instance()->getUniqueId();
|
||||
}
|
||||
|
||||
bool QtVersion::isValid() const
|
||||
|
||||
@@ -171,11 +171,12 @@ private slots:
|
||||
class PROJECTEXPLORER_EXPORT QtVersionManager : public Core::IOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtVersionManager();
|
||||
~QtVersionManager();
|
||||
|
||||
static QtVersionManager *instance();
|
||||
|
||||
QString id() const;
|
||||
QString trName() const;
|
||||
QString category() const;
|
||||
@@ -210,7 +211,6 @@ signals:
|
||||
void defaultQtVersionChanged();
|
||||
void qtVersionsChanged();
|
||||
private:
|
||||
|
||||
void addNewVersionsFromInstaller();
|
||||
void updateSystemVersion();
|
||||
void updateDocumentation();
|
||||
@@ -218,7 +218,7 @@ private:
|
||||
static int indexOfVersionInList(const QtVersion * const version, const QList<QtVersion *> &list);
|
||||
void updateUniqueIdToIndexMap();
|
||||
|
||||
QPointer<QtDirWidget> m_widget;
|
||||
QtDirWidget *m_widget;
|
||||
|
||||
QtVersion *m_emptyVersion;
|
||||
int m_defaultVersion;
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include "qmakestep.h"
|
||||
#include "makestep.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QtGui/QCheckBox>
|
||||
#include <QtGui/QHeaderView>
|
||||
#include <QtGui/QLabel>
|
||||
@@ -48,7 +50,7 @@ using ProjectExplorer::QtVersion;
|
||||
ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::WindowFlags flags)
|
||||
: QWizard(parent, flags), m_project(project), m_importVersion(0), m_temporaryVersion(false)
|
||||
{
|
||||
ProjectExplorer::QtVersionManager * vm = project->qt4ProjectManager()->versionManager();
|
||||
ProjectExplorer::QtVersionManager * vm = ProjectExplorer::QtVersionManager::instance();
|
||||
QString directory = QFileInfo(project->file()->fileName()).absolutePath();
|
||||
QString importVersion = vm->findQtVersionFromMakefile(directory);
|
||||
|
||||
@@ -127,6 +129,7 @@ void ProjectLoadWizard::addBuildConfiguration(QString name, QtVersion *qtversion
|
||||
|
||||
void ProjectLoadWizard::done(int result)
|
||||
{
|
||||
ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance();
|
||||
QWizard::done(result);
|
||||
// This normally happens on showing the final page, but since we
|
||||
// don't show it anymore, do it here
|
||||
@@ -135,7 +138,7 @@ void ProjectLoadWizard::done(int result)
|
||||
if (m_importVersion && importCheckbox->isChecked()) {
|
||||
// Importing
|
||||
if (m_temporaryVersion)
|
||||
m_project->qt4ProjectManager()->versionManager()->addVersion(m_importVersion);
|
||||
vm->addVersion(m_importVersion);
|
||||
// Import the existing stuff
|
||||
// qDebug()<<"Creating m_buildconfiguration entry from imported stuff";
|
||||
// qDebug()<<((m_importBuildConfig& QtVersion::BuildAll)? "debug_and_release" : "")<<((m_importBuildConfig & QtVersion::DebugBuild)? "debug" : "release");
|
||||
@@ -158,7 +161,7 @@ void ProjectLoadWizard::done(int result)
|
||||
delete m_importVersion;
|
||||
// Create default
|
||||
bool buildAll = false;
|
||||
QtVersion *defaultVersion = m_project->qt4ProjectManager()->versionManager()->version(0);
|
||||
QtVersion *defaultVersion = vm->version(0);
|
||||
if (defaultVersion && defaultVersion->isValid() && (defaultVersion->defaultBuildConfig() & QtVersion::BuildAll))
|
||||
buildAll = true;
|
||||
if (buildAll) {
|
||||
|
||||
@@ -236,9 +236,11 @@ Qt4Project::Qt4Project(Qt4Manager *manager, const QString& fileName) :
|
||||
{
|
||||
m_manager->registerProject(this);
|
||||
|
||||
connect(qt4ProjectManager()->versionManager(), SIGNAL(defaultQtVersionChanged()),
|
||||
ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance();
|
||||
|
||||
connect(vm, SIGNAL(defaultQtVersionChanged()),
|
||||
this, SLOT(defaultQtVersionChanged()));
|
||||
connect(qt4ProjectManager()->versionManager(), SIGNAL(qtVersionsChanged()),
|
||||
connect(vm, SIGNAL(qtVersionsChanged()),
|
||||
this, SLOT(qtVersionsChanged()));
|
||||
|
||||
m_updateCodeModelTimer.setSingleShot(true);
|
||||
@@ -266,8 +268,9 @@ void Qt4Project::defaultQtVersionChanged()
|
||||
|
||||
void Qt4Project::qtVersionsChanged()
|
||||
{
|
||||
QtVersionManager *vm = QtVersionManager::instance();
|
||||
foreach (QString bc, buildConfigurations()) {
|
||||
if (!qt4ProjectManager()->versionManager()->version(qtVersionId(bc))->isValid()) {
|
||||
if (!vm->version(qtVersionId(bc))->isValid()) {
|
||||
setQtVersion(bc, 0);
|
||||
if (bc == activeBuildConfiguration())
|
||||
m_rootProjectNode->update();
|
||||
@@ -740,18 +743,19 @@ QString Qt4Project::qtDir(const QString &buildConfiguration) const
|
||||
|
||||
QtVersion *Qt4Project::qtVersion(const QString &buildConfiguration) const
|
||||
{
|
||||
return m_manager->versionManager()->version(qtVersionId(buildConfiguration));
|
||||
return QtVersionManager::instance()->version(qtVersionId(buildConfiguration));
|
||||
}
|
||||
|
||||
int Qt4Project::qtVersionId(const QString &buildConfiguration) const
|
||||
{
|
||||
QtVersionManager *vm = QtVersionManager::instance();
|
||||
if (debug)
|
||||
qDebug()<<"Looking for qtVersion ID of "<<buildConfiguration;
|
||||
int id = 0;
|
||||
QVariant vid = value(buildConfiguration, "QtVersionId");
|
||||
if (vid.isValid()) {
|
||||
id = vid.toInt();
|
||||
if (m_manager->versionManager()->version(id)->isValid()) {
|
||||
if (vm->version(id)->isValid()) {
|
||||
return id;
|
||||
} else {
|
||||
const_cast<Qt4Project *>(this)->setValue(buildConfiguration, "QtVersionId", 0);
|
||||
@@ -763,7 +767,7 @@ int Qt4Project::qtVersionId(const QString &buildConfiguration) const
|
||||
if (debug)
|
||||
qDebug()<<" Backward compatibility reading QtVersion"<<vname;
|
||||
if (!vname.isEmpty()) {
|
||||
const QList<QtVersion *> &versions = m_manager->versionManager()->versions();
|
||||
const QList<QtVersion *> &versions = vm->versions();
|
||||
foreach (const QtVersion * const version, versions) {
|
||||
if (version->name() == vname) {
|
||||
if (debug)
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mainwindow.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QtGui/QFileDialog>
|
||||
|
||||
@@ -83,7 +84,9 @@ Qt4ProjectConfigWidget::Qt4ProjectConfigWidget(Qt4Project *project)
|
||||
connect(m_ui->manageQtVersionPushButtons, SIGNAL(clicked()),
|
||||
this, SLOT(manageQtVersions()));
|
||||
|
||||
connect(m_pro->qt4ProjectManager()->versionManager(), SIGNAL(qtVersionsChanged()),
|
||||
ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance();
|
||||
|
||||
connect(vm, SIGNAL(qtVersionsChanged()),
|
||||
this, SLOT(setupQtVersionsComboBox()));
|
||||
}
|
||||
|
||||
@@ -143,7 +146,7 @@ void Qt4ProjectConfigWidget::setupQtVersionsComboBox()
|
||||
m_ui->invalidQtWarningLabel->setVisible(false);
|
||||
}
|
||||
// Add Qt Versions to the combo box
|
||||
QtVersionManager *vm = m_pro->qt4ProjectManager()->versionManager();
|
||||
QtVersionManager *vm = QtVersionManager::instance();
|
||||
const QList<QtVersion *> &versions = vm->versions();
|
||||
for (int i = 0; i < versions.size(); ++i) {
|
||||
m_ui->qtVersionComboBox->addItem(versions.at(i)->name(), versions.at(i)->uniqueId());
|
||||
@@ -181,7 +184,8 @@ void Qt4ProjectConfigWidget::updateImportLabel()
|
||||
{
|
||||
m_ui->importLabel->setVisible(false);
|
||||
if (m_ui->shadowBuildCheckBox->isChecked()) {
|
||||
QString qtPath = m_pro->qt4ProjectManager()->versionManager()->findQtVersionFromMakefile(m_ui->shadowBuildDirEdit->path());
|
||||
ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance();
|
||||
QString qtPath = vm->findQtVersionFromMakefile(m_ui->shadowBuildDirEdit->path());
|
||||
if (!qtPath.isEmpty()) {
|
||||
m_ui->importLabel->setVisible(true);
|
||||
}
|
||||
@@ -215,7 +219,7 @@ void Qt4ProjectConfigWidget::importLabelClicked()
|
||||
if (m_ui->shadowBuildCheckBox->isChecked()) {
|
||||
QString directory = m_ui->shadowBuildDirEdit->path();
|
||||
if (!directory.isEmpty()) {
|
||||
QtVersionManager *vm = m_pro->qt4ProjectManager()->versionManager();
|
||||
QtVersionManager *vm = QtVersionManager::instance();
|
||||
QString qtPath = vm->findQtVersionFromMakefile(directory);
|
||||
if (!qtPath.isEmpty()) {
|
||||
QtVersion *version = vm->qtVersionForDirectory(qtPath);
|
||||
@@ -265,7 +269,8 @@ void Qt4ProjectConfigWidget::qtVersionComboBoxCurrentIndexChanged(const QString
|
||||
} else {
|
||||
newQtVersion = m_ui->qtVersionComboBox->itemData(m_ui->qtVersionComboBox->currentIndex()).toInt();
|
||||
}
|
||||
bool isValid = m_pro->qt4ProjectManager()->versionManager()->version(newQtVersion)->isValid();
|
||||
ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance();
|
||||
bool isValid = vm->version(newQtVersion)->isValid();
|
||||
m_ui->invalidQtWarningLabel->setVisible(!isValid);
|
||||
if (newQtVersion != m_pro->qtVersionId(m_buildConfiguration)) {
|
||||
m_pro->setQtVersion(m_buildConfiguration, newQtVersion);
|
||||
|
||||
@@ -189,11 +189,6 @@ ProjectExplorer::Project *Qt4Manager::contextProject() const
|
||||
return m_contextProject;
|
||||
}
|
||||
|
||||
QtVersionManager *Qt4Manager::versionManager() const
|
||||
{
|
||||
return m_plugin->versionManager();
|
||||
}
|
||||
|
||||
void Qt4Manager::runQMake()
|
||||
{
|
||||
runQMake(m_projectExplorer->currentProject());
|
||||
|
||||
@@ -85,8 +85,6 @@ public:
|
||||
void setContextProject(ProjectExplorer::Project *project);
|
||||
ProjectExplorer::Project *contextProject() const;
|
||||
|
||||
ProjectExplorer::QtVersionManager *versionManager() const;
|
||||
|
||||
// Return the id string of a file
|
||||
static QString fileTypeId(ProjectExplorer::FileType type);
|
||||
|
||||
|
||||
@@ -71,9 +71,6 @@ Qt4ProjectManagerPlugin::~Qt4ProjectManagerPlugin()
|
||||
//removeObject(m_embeddedPropertiesPage);
|
||||
//delete m_embeddedPropertiesPage;
|
||||
|
||||
removeObject(m_qtVersionManager);
|
||||
delete m_qtVersionManager;
|
||||
|
||||
removeObject(m_proFileEditorFactory);
|
||||
delete m_proFileEditorFactory;
|
||||
removeObject(m_qt4ProjectManager);
|
||||
@@ -125,9 +122,6 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
|
||||
addAutoReleasedObject(new QMakeStepFactory);
|
||||
addAutoReleasedObject(new MakeStepFactory);
|
||||
|
||||
m_qtVersionManager = new QtVersionManager;
|
||||
addObject(m_qtVersionManager);
|
||||
|
||||
addAutoReleasedObject(new Qt4RunConfigurationFactory);
|
||||
addAutoReleasedObject(new Qt4RunConfigurationFactoryUser);
|
||||
|
||||
@@ -191,11 +185,6 @@ void Qt4ProjectManagerPlugin::updateContextMenu(Project *project,
|
||||
}
|
||||
}
|
||||
|
||||
QtVersionManager *Qt4ProjectManagerPlugin::versionManager() const
|
||||
{
|
||||
return m_qtVersionManager;
|
||||
}
|
||||
|
||||
void Qt4ProjectManagerPlugin::currentProjectChanged()
|
||||
{
|
||||
m_runQMakeAction->setEnabled(!m_projectExplorer->buildManager()->isBuilding(m_projectExplorer->currentProject()));
|
||||
|
||||
@@ -62,8 +62,6 @@ public:
|
||||
void extensionsInitialized();
|
||||
|
||||
int projectContext() const { return m_projectContext; }
|
||||
ProjectExplorer::QtVersionManager *versionManager() const;
|
||||
|
||||
|
||||
private slots:
|
||||
void updateContextMenu(ProjectExplorer::Project *project,
|
||||
@@ -80,8 +78,6 @@ private:
|
||||
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
|
||||
ProFileEditorFactory *m_proFileEditorFactory;
|
||||
Qt4Manager *m_qt4ProjectManager;
|
||||
ProjectExplorer::QtVersionManager *m_qtVersionManager;
|
||||
EmbeddedPropertiesPage *m_embeddedPropertiesPage;
|
||||
|
||||
int m_projectContext;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user