diff options
author | Tobias Hunger <[email protected]> | 2012-04-24 15:49:09 +0200 |
---|---|---|
committer | Tobias Hunger <[email protected]> | 2012-06-21 12:08:12 +0200 |
commit | 24314562165588b56a318b3b8a846bf5deda7c41 (patch) | |
tree | b5dcf951e76d003c2623011b0e91994e06e7e061 /src/plugins/qmlprojectmanager | |
parent | 8c77b8c9d7b25d0c89003c8c4a54e8da5bfb7edd (diff) |
Profile introduction
Introduce Profiles to store sets of values that describe a system/device.
These profiles are held by a target, getting rid of much of the information
stored in the Build-/Run-/DeployConfigurations, greatly simplifying those.
This is a squash of the wip/profile branch which has been on gerrit for a
while, rebased to current master.
Change-Id: I25956c8dd4d1962b2134bfaa8a8076ae3909460f
Reviewed-by: Daniel Teske <[email protected]>
Diffstat (limited to 'src/plugins/qmlprojectmanager')
14 files changed, 84 insertions, 473 deletions
diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index 1e43c76a047..91937d6de02 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -35,7 +35,6 @@ #include "qmlprojectmanagerconstants.h" #include "fileformat/qmlprojectitem.h" #include "qmlprojectrunconfiguration.h" -#include "qmlprojecttarget.h" #include "qmlprojectconstants.h" #include "qmlprojectnodes.h" #include "qmlprojectmanager.h" @@ -47,9 +46,12 @@ #include <qtsupport/qmldumptool.h> #include <qtsupport/baseqtversion.h> #include <qtsupport/qtversionmanager.h> +#include <qtsupport/qtprofileinformation.h> #include <qmljs/qmljsmodelmanagerinterface.h> #include <utils/fileutils.h> -#include <projectexplorer/toolchainmanager.h> +#include <projectexplorer/profileinformation.h> +#include <projectexplorer/profilemanager.h> +#include <projectexplorer/target.h> #include <utils/filesystemwatcher.h> #include <QTextStream> @@ -157,13 +159,9 @@ void QmlProject::refresh(RefreshOptions options) pinfo.importPaths = importPaths(); QtSupport::BaseQtVersion *version = 0; if (activeTarget()) { - if (QmlProjectRunConfiguration *rc = qobject_cast<QmlProjectRunConfiguration *>(activeTarget()->activeRunConfiguration())) - version = rc->qtVersion(); - QList<ProjectExplorer::ToolChain *> tcList; - if (version && !version->qtAbis().isEmpty()) - tcList = ProjectExplorer::ToolChainManager::instance()->findToolChains(version->qtAbis().at(0)); - if (!tcList.isEmpty()) - QtSupport::QmlDumpTool::pathAndEnvironment(this, version, tcList.first(), false, &pinfo.qmlDumpPath, &pinfo.qmlDumpEnvironment); + ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(activeTarget()->profile()); + version = QtSupport::QtProfileInformation::qtVersion(activeTarget()->profile()); + QtSupport::QmlDumpTool::pathAndEnvironment(this, version, tc, false, &pinfo.qmlDumpPath, &pinfo.qmlDumpEnvironment); } if (version) { pinfo.tryQmlDump = true; @@ -273,14 +271,20 @@ ProjectExplorer::IProjectManager *QmlProject::projectManager() const return m_manager; } -QList<ProjectExplorer::BuildConfigWidget*> QmlProject::subConfigWidgets() +bool QmlProject::supportsProfile(ProjectExplorer::Profile *p) const { - return QList<ProjectExplorer::BuildConfigWidget*>(); + Core::Id deviceType = ProjectExplorer::DeviceTypeProfileInformation::deviceTypeId(p); + if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) + return false; + + // TODO: Limit supported versions? + QtSupport::BaseQtVersion *version = QtSupport::QtProfileInformation::qtVersion(p); + return version; } -Internal::QmlProjectTarget *QmlProject::activeTarget() const +QList<ProjectExplorer::BuildConfigWidget*> QmlProject::subConfigWidgets() { - return static_cast<Internal::QmlProjectTarget *>(Project::activeTarget()); + return QList<ProjectExplorer::BuildConfigWidget*>(); } ProjectExplorer::ProjectNode *QmlProject::rootProjectNode() const @@ -298,12 +302,8 @@ bool QmlProject::fromMap(const QVariantMap &map) if (!Project::fromMap(map)) return false; - if (targets().isEmpty()) { - Internal::QmlProjectTargetFactory *factory - = ExtensionSystem::PluginManager::getObject<Internal::QmlProjectTargetFactory>(); - Internal::QmlProjectTarget *target = factory->create(this, Core::Id(Constants::QML_VIEWER_TARGET_ID)); - addTarget(target); - } + if (!activeTarget()) + addTarget(createTarget(ProjectExplorer::ProfileManager::instance()->defaultProfile())); refresh(Everything); // FIXME workaround to guarantee that run/debug actions are enabled if a valid file exists diff --git a/src/plugins/qmlprojectmanager/qmlproject.h b/src/plugins/qmlprojectmanager/qmlproject.h index 94af81d2cec..6f00900b81a 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.h +++ b/src/plugins/qmlprojectmanager/qmlproject.h @@ -39,13 +39,8 @@ #include <QDeclarativeEngine> -namespace QmlJS { -class ModelManagerInterface; -} - -namespace Utils { -class FileSystemWatcher; -} +namespace QmlJS { class ModelManagerInterface; } +namespace Utils { class FileSystemWatcher; } namespace QmlProjectManager { @@ -54,7 +49,6 @@ class QmlProjectItem; namespace Internal { class Manager; class QmlProjectFile; -class QmlProjectTarget; class QmlProjectNode; } // namespace Internal @@ -72,7 +66,8 @@ public: Core::Id id() const; Core::IDocument *document() const; ProjectExplorer::IProjectManager *projectManager() const; - Internal::QmlProjectTarget *activeTarget() const; + + bool supportsProfile(ProjectExplorer::Profile *p) const; QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets(); diff --git a/src/plugins/qmlprojectmanager/qmlprojectmanager.pro b/src/plugins/qmlprojectmanager/qmlprojectmanager.pro index cd40ae3e2f5..5249f4687b0 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectmanager.pro +++ b/src/plugins/qmlprojectmanager/qmlprojectmanager.pro @@ -25,7 +25,6 @@ HEADERS += qmlproject.h \ qmlprojectapplicationwizard.h \ qmlprojectmanager_global.h \ qmlprojectmanagerconstants.h \ - qmlprojecttarget.h \ qmlprojectrunconfigurationwidget.h SOURCES += qmlproject.cpp \ @@ -37,7 +36,6 @@ SOURCES += qmlproject.cpp \ qmlprojectrunconfiguration.cpp \ qmlprojectrunconfigurationfactory.cpp \ qmlprojectapplicationwizard.cpp \ - qmlprojecttarget.cpp \ qmlprojectrunconfigurationwidget.cpp RESOURCES += qmlproject.qrc diff --git a/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs b/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs index 52b421c1237..9ac468e42c3 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs +++ b/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs @@ -37,7 +37,6 @@ QtcPlugin { "qmlprojectapplicationwizard.h", "qmlprojectmanager_global.h", "qmlprojectmanagerconstants.h", - "qmlprojecttarget.h", "qmlprojectrunconfigurationwidget.h", "fileformat/qmlprojectitem.cpp", "fileformat/filefilteritems.cpp", @@ -51,7 +50,6 @@ QtcPlugin { "qmlprojectrunconfiguration.cpp", "qmlprojectrunconfigurationfactory.cpp", "qmlprojectapplicationwizard.cpp", - "qmlprojecttarget.cpp", "qmlprojectrunconfigurationwidget.cpp", "qmlproject.qrc", "QmlProject.mimetypes.xml" diff --git a/src/plugins/qmlprojectmanager/qmlprojectmanagerconstants.h b/src/plugins/qmlprojectmanager/qmlprojectmanagerconstants.h index e8bd9eeb211..2cbbc589e7e 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectmanagerconstants.h +++ b/src/plugins/qmlprojectmanager/qmlprojectmanagerconstants.h @@ -36,9 +36,7 @@ namespace QmlProjectManager { namespace Constants { const char QML_RC_ID[] = "QmlProjectManager.QmlRunConfiguration"; -const char QML_VIEWER_QT_KEY[] = "QmlProjectManager.QmlRunConfiguration.QtVersion"; const char QML_VIEWER_ARGUMENTS_KEY[] = "QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments"; -const char QML_VIEWER_TARGET_ID[] = "QmlProjectManager.QmlTarget"; const char QML_VIEWER_TARGET_DISPLAY_NAME[] = "QML Viewer"; const char QML_MAINSCRIPT_KEY[] = "QmlProjectManager.QmlRunConfiguration.MainScript"; const char USER_ENVIRONMENT_CHANGES_KEY[] = "QmlProjectManager.QmlRunConfiguration.UserEnvironmentChanges"; diff --git a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp index 580e08e9c97..addb170b3fb 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp @@ -37,7 +37,6 @@ #include "qmlproject.h" #include "qmlprojectrunconfigurationfactory.h" #include "qmlprojectruncontrol.h" -#include "qmlprojecttarget.h" #include "fileformat/qmlprojectfileformat.h" #include <extensionsystem/pluginmanager.h> @@ -85,7 +84,6 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage) addAutoReleasedObject(new Internal::QmlProjectRunConfigurationFactory); addAutoReleasedObject(new Internal::QmlProjectRunControlFactory); addAutoReleasedObject(new Internal::QmlProjectApplicationWizard); - addAutoReleasedObject(new Internal::QmlProjectTargetFactory); QmlProjectFileFormat::registerDeclarativeTypes(); diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index 9a3dc44895c..80346d3d13d 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -33,15 +33,15 @@ #include "qmlprojectrunconfiguration.h" #include "qmlproject.h" #include "qmlprojectmanagerconstants.h" -#include "qmlprojecttarget.h" #include "qmlprojectrunconfigurationwidget.h" #include <coreplugin/mimedatabase.h> #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/ieditor.h> #include <coreplugin/icore.h> +#include <projectexplorer/target.h> #include <utils/qtcassert.h> #include <utils/qtcprocess.h> -#include <qtsupport/qtversionmanager.h> +#include <qtsupport/qtprofileinformation.h> #include <qtsupport/qtoutputformatter.h> #include <qtsupport/qtsupportconstants.h> @@ -52,7 +52,6 @@ using Core::EditorManager; using Core::ICore; using Core::IEditor; -using QtSupport::QtVersionManager; using namespace QmlProjectManager::Internal; @@ -60,29 +59,23 @@ namespace QmlProjectManager { const char * const M_CURRENT_FILE = "CurrentFile"; -QmlProjectRunConfiguration::QmlProjectRunConfiguration(QmlProjectTarget *parent) : +QmlProjectRunConfiguration::QmlProjectRunConfiguration(ProjectExplorer::Target *parent) : ProjectExplorer::RunConfiguration(parent, Core::Id(Constants::QML_RC_ID)), - m_qtVersionId(-1), m_scriptFile(M_CURRENT_FILE), - m_projectTarget(parent), m_isEnabled(false) { ctor(); - updateQtVersions(); } -QmlProjectRunConfiguration::QmlProjectRunConfiguration(QmlProjectTarget *parent, +QmlProjectRunConfiguration::QmlProjectRunConfiguration(ProjectExplorer::Target *parent, QmlProjectRunConfiguration *source) : ProjectExplorer::RunConfiguration(parent, source), - m_qtVersionId(source->m_qtVersionId), m_scriptFile(source->m_scriptFile), m_qmlViewerArgs(source->m_qmlViewerArgs), - m_projectTarget(parent), m_isEnabled(source->m_isEnabled), m_userEnvironmentChanges(source->m_userEnvironmentChanges) { ctor(); - updateQtVersions(); } bool QmlProjectRunConfiguration::isEnabled() const @@ -107,8 +100,8 @@ void QmlProjectRunConfiguration::ctor() connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(changeCurrentFile(Core::IEditor*))); - QtVersionManager *qtVersions = QtVersionManager::instance(); - connect(qtVersions, SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)), this, SLOT(updateQtVersions())); + connect(target(), SIGNAL(profileChanged()), + this, SLOT(updateEnabled())); setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name.")); } @@ -117,19 +110,13 @@ QmlProjectRunConfiguration::~QmlProjectRunConfiguration() { } -QmlProjectTarget *QmlProjectRunConfiguration::qmlTarget() const -{ - return static_cast<QmlProjectTarget *>(target()); -} - QString QmlProjectRunConfiguration::viewerPath() const { QtSupport::BaseQtVersion *version = qtVersion(); - if (!version) { + if (!version) return QString(); - } else { + else return version->qmlviewerCommand(); - } } QString QmlProjectRunConfiguration::observerPath() const @@ -150,7 +137,10 @@ QString QmlProjectRunConfiguration::viewerArguments() const QString args = m_qmlViewerArgs; // arguments from .qmlproject file - foreach (const QString &importPath, qmlTarget()->qmlProject()->importPaths()) { + QmlProject *project = qobject_cast<QmlProject *>(target()->project()); + if (!project) + return args; + foreach (const QString &importPath, project->importPaths()) { Utils::QtcProcess::addArg(&args, "-I"); Utils::QtcProcess::addArg(&args, importPath); } @@ -165,26 +155,10 @@ QString QmlProjectRunConfiguration::viewerArguments() const QString QmlProjectRunConfiguration::workingDirectory() const { - QFileInfo projectFile(qmlTarget()->qmlProject()->document()->fileName()); + QFileInfo projectFile(target()->project()->document()->fileName()); return canonicalCapsPath(projectFile.absolutePath()); } -int QmlProjectRunConfiguration::qtVersionId() const -{ - return m_qtVersionId; -} - -void QmlProjectRunConfiguration::setQtVersionId(int id) -{ - if (m_qtVersionId == id) - return; - - m_qtVersionId = id; - qmlTarget()->qmlProject()->refresh(QmlProject::Configuration); - if (m_configurationWidget) - m_configurationWidget.data()->updateQtVersionComboBox(); -} - /* QtDeclarative checks explicitly that the capitalization for any URL / path is exactly like the capitalization on disk.*/ QString QmlProjectRunConfiguration::canonicalCapsPath(const QString &fileName) @@ -201,14 +175,7 @@ QString QmlProjectRunConfiguration::canonicalCapsPath(const QString &fileName) QtSupport::BaseQtVersion *QmlProjectRunConfiguration::qtVersion() const { - if (m_qtVersionId == -1) - return 0; - - QtSupport::QtVersionManager *versionManager = QtSupport::QtVersionManager::instance(); - QtSupport::BaseQtVersion *version = versionManager->version(m_qtVersionId); - QTC_ASSERT(version, return 0); - - return version; + return QtSupport::QtProfileInformation::qtVersion(target()->profile()); } QWidget *QmlProjectRunConfiguration::createConfigurationWidget() @@ -220,16 +187,18 @@ QWidget *QmlProjectRunConfiguration::createConfigurationWidget() Utils::OutputFormatter *QmlProjectRunConfiguration::createOutputFormatter() const { - return new QtSupport::QtOutputFormatter(qmlTarget()->qmlProject()); + return new QtSupport::QtOutputFormatter(target()->project()); } QmlProjectRunConfiguration::MainScriptSource QmlProjectRunConfiguration::mainScriptSource() const { - if (!qmlTarget()->qmlProject()->mainFile().isEmpty()) + QmlProject *project = qobject_cast<QmlProject *>(target()->project()); + if (!project) + return FileInEditor; + if (!project->mainFile().isEmpty()) return FileInProjectFile; - if (!m_mainScriptFilename.isEmpty()) { + if (!m_mainScriptFilename.isEmpty()) return FileInSettings; - } return FileInEditor; } @@ -238,12 +207,15 @@ QmlProjectRunConfiguration::MainScriptSource QmlProjectRunConfiguration::mainScr */ QString QmlProjectRunConfiguration::mainScript() const { - if (!qmlTarget()->qmlProject()->mainFile().isEmpty()) { - const QString pathInProject = qmlTarget()->qmlProject()->mainFile(); + QmlProject *project = qobject_cast<QmlProject *>(target()->project()); + if (!project) + return m_currentFileFilename; + if (!project->mainFile().isEmpty()) { + const QString pathInProject = project->mainFile(); if (QFileInfo(pathInProject).isAbsolute()) return pathInProject; else - return qmlTarget()->qmlProject()->projectDir().absoluteFilePath(pathInProject); + return project->projectDir().absoluteFilePath(pathInProject); } if (!m_mainScriptFilename.isEmpty()) @@ -264,7 +236,7 @@ void QmlProjectRunConfiguration::setScriptSource(MainScriptSource source, } else { // FileInSettings m_scriptFile = settingsPath; m_mainScriptFilename - = qmlTarget()->qmlProject()->projectDir().absoluteFilePath(m_scriptFile); + = target()->project()->projectDirectory() + QLatin1Char('/') + m_scriptFile; } updateEnabled(); if (m_configurationWidget) @@ -289,7 +261,6 @@ QVariantMap QmlProjectRunConfiguration::toMap() const { QVariantMap map(ProjectExplorer::RunConfiguration::toMap()); - map.insert(QLatin1String(Constants::QML_VIEWER_QT_KEY), m_qtVersionId); map.insert(QLatin1String(Constants::QML_VIEWER_ARGUMENTS_KEY), m_qmlViewerArgs); map.insert(QLatin1String(Constants::QML_MAINSCRIPT_KEY), m_scriptFile); map.insert(QLatin1String(Constants::USER_ENVIRONMENT_CHANGES_KEY), @@ -299,30 +270,25 @@ QVariantMap QmlProjectRunConfiguration::toMap() const bool QmlProjectRunConfiguration::fromMap(const QVariantMap &map) { - setQtVersionId(map.value(QLatin1String(Constants::QML_VIEWER_QT_KEY), -1).toInt()); m_qmlViewerArgs = map.value(QLatin1String(Constants::QML_VIEWER_ARGUMENTS_KEY)).toString(); m_scriptFile = map.value(QLatin1String(Constants::QML_MAINSCRIPT_KEY), M_CURRENT_FILE).toString(); m_userEnvironmentChanges = Utils::EnvironmentItem::fromStringList( map.value(QLatin1String(Constants::USER_ENVIRONMENT_CHANGES_KEY)).toStringList()); - - updateQtVersions(); - if (m_scriptFile == M_CURRENT_FILE) { + if (m_scriptFile == M_CURRENT_FILE) setScriptSource(FileInEditor); - } else if (m_scriptFile.isEmpty()) { + else if (m_scriptFile.isEmpty()) setScriptSource(FileInProjectFile); - } else { + else setScriptSource(FileInSettings, m_scriptFile); - } return RunConfiguration::fromMap(map); } void QmlProjectRunConfiguration::changeCurrentFile(Core::IEditor *editor) { - if (editor) { + if (editor) m_currentFileFilename = editor->document()->fileName(); - } updateEnabled(); } @@ -341,7 +307,7 @@ void QmlProjectRunConfiguration::updateEnabled() || db->findByFile(mainScript()).type() == QLatin1String("application/x-qmlproject")) { // find a qml file with lowercase filename. This is slow, but only done // in initialization/other border cases. - foreach(const QString &filename, m_projectTarget->qmlProject()->files()) { + foreach (const QString &filename, target()->project()->files(ProjectExplorer::Project::AllFiles)) { const QFileInfo fi(filename); if (!filename.isEmpty() && fi.baseName()[0].isLower() @@ -367,29 +333,6 @@ void QmlProjectRunConfiguration::updateEnabled() emit enabledChanged(); } -void QmlProjectRunConfiguration::updateQtVersions() -{ - QtVersionManager *qtVersions = QtVersionManager::instance(); - - // - // update m_qtVersionId - // - if (!qtVersions->isValidId(m_qtVersionId) - || !isValidVersion(qtVersions->version(m_qtVersionId))) { - int newVersionId = -1; - // take first one you find - foreach (QtSupport::BaseQtVersion *version, qtVersions->validVersions()) { - if (isValidVersion(version)) { - newVersionId = version->uniqueId(); - break; - } - } - setQtVersionId(newVersionId); - } - - updateEnabled(); -} - bool QmlProjectRunConfiguration::isValidVersion(QtSupport::BaseQtVersion *version) { if (version diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h index 97f29758371..a767cb64ba3 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h @@ -50,14 +50,11 @@ namespace Utils { class EnvironmentItem; } -namespace QtSupport { - class BaseQtVersion; -} +namespace QtSupport { class BaseQtVersion; } namespace QmlProjectManager { namespace Internal { - class QmlProjectTarget; class QmlProjectRunConfigurationFactory; class QmlProjectRunConfigurationWidget; } @@ -68,20 +65,14 @@ class QMLPROJECTMANAGER_EXPORT QmlProjectRunConfiguration : public ProjectExplor friend class Internal::QmlProjectRunConfigurationFactory; friend class Internal::QmlProjectRunConfigurationWidget; - // used in qmldumptool.cpp - Q_PROPERTY(int qtVersionId READ qtVersionId) - public: - QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent); + QmlProjectRunConfiguration(ProjectExplorer::Target *parent); virtual ~QmlProjectRunConfiguration(); - Internal::QmlProjectTarget *qmlTarget() const; - QString viewerPath() const; QString observerPath() const; QString viewerArguments() const; QString workingDirectory() const; - int qtVersionId() const; QtSupport::BaseQtVersion *qtVersion() const; enum MainScriptSource { @@ -110,10 +101,9 @@ public slots: private slots: void updateEnabled(); - void updateQtVersions(); protected: - QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent, + QmlProjectRunConfiguration(ProjectExplorer::Target *parent, QmlProjectRunConfiguration *source); virtual bool fromMap(const QVariantMap &map); void setEnabled(bool value); @@ -121,7 +111,6 @@ protected: private: void ctor(); static bool isValidVersion(QtSupport::BaseQtVersion *version); - void setQtVersionId(int id); static QString canonicalCapsPath(const QString &filePath); @@ -138,7 +127,6 @@ private: QString m_scriptFile; QString m_qmlViewerArgs; - Internal::QmlProjectTarget *m_projectTarget; QWeakPointer<Internal::QmlProjectRunConfigurationWidget> m_configurationWidget; bool m_isEnabled; diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationfactory.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationfactory.cpp index 877cacf0ed1..1704ff0ceb2 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationfactory.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationfactory.cpp @@ -31,20 +31,21 @@ **************************************************************************/ #include "qmlprojectmanagerconstants.h" +#include "qmlproject.h" #include "qmlprojectrunconfiguration.h" #include "qmlprojectrunconfigurationfactory.h" -#include "qmlprojecttarget.h" +#include <projectexplorer/profileinformation.h> #include <projectexplorer/projectconfiguration.h> #include <projectexplorer/runconfiguration.h> +#include <projectexplorer/target.h> namespace QmlProjectManager { namespace Internal { QmlProjectRunConfigurationFactory::QmlProjectRunConfigurationFactory(QObject *parent) : ProjectExplorer::IRunConfigurationFactory(parent) -{ -} +{ setObjectName(QLatin1String("QmlProjectRunConfigurationFactory")); } QmlProjectRunConfigurationFactory::~QmlProjectRunConfigurationFactory() { @@ -52,7 +53,7 @@ QmlProjectRunConfigurationFactory::~QmlProjectRunConfigurationFactory() QList<Core::Id> QmlProjectRunConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const { - if (!qobject_cast<QmlProjectTarget *>(parent)) + if (!canHandle(parent)) return QList<Core::Id>(); return QList<Core::Id>() << Core::Id(Constants::QML_RC_ID); } @@ -66,7 +67,7 @@ QString QmlProjectRunConfigurationFactory::displayNameForId(const Core::Id id) c bool QmlProjectRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, const Core::Id id) const { - if (!qobject_cast<QmlProjectTarget *>(parent)) + if (!canHandle(parent)) return false; return id == Core::Id(Constants::QML_RC_ID); } @@ -75,8 +76,7 @@ ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::create(Pro { if (!canCreate(parent, id)) return 0; - QmlProjectTarget *qmlparent = static_cast<QmlProjectTarget *>(parent); - return new QmlProjectRunConfiguration(qmlparent); + return new QmlProjectRunConfiguration(parent); } bool QmlProjectRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const @@ -88,8 +88,7 @@ ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::restore(Pr { if (!canRestore(parent, map)) return 0; - QmlProjectTarget *qmlparent = static_cast<QmlProjectTarget *>(parent); - QmlProjectRunConfiguration *rc = new QmlProjectRunConfiguration(qmlparent); + QmlProjectRunConfiguration *rc = new QmlProjectRunConfiguration(parent); if (rc->fromMap(map)) return rc; delete rc; @@ -106,8 +105,17 @@ ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::clone(Proj { if (!canClone(parent, source)) return 0; - QmlProjectTarget *qmlparent = static_cast<QmlProjectTarget *>(parent); - return new QmlProjectRunConfiguration(qmlparent, qobject_cast<QmlProjectRunConfiguration *>(source)); + return new QmlProjectRunConfiguration(parent, qobject_cast<QmlProjectRunConfiguration *>(source)); +} + +bool QmlProjectRunConfigurationFactory::canHandle(ProjectExplorer::Target *parent) const +{ + if (!parent->project()->supportsProfile(parent->profile())) + return false; + if (!qobject_cast<QmlProject *>(parent->project())) + return false; + Core::Id deviceType = ProjectExplorer::DeviceTypeProfileInformation::deviceTypeId(parent->profile()); + return deviceType == Core::Id(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); } } // namespace Internal diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationfactory.h b/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationfactory.h index ee2e615deac..8969a35f890 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationfactory.h +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationfactory.h @@ -55,6 +55,9 @@ public: ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map); bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const; ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source); + +private: + bool canHandle(ProjectExplorer::Target *parent) const; }; } // namespace Internal diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp index 8b07a5fe743..886f319ba1f 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp @@ -32,7 +32,6 @@ #include "qmlprojectrunconfigurationwidget.h" #include "qmlprojectrunconfiguration.h" -#include "qmlprojecttarget.h" #include "qmlproject.h" #include <coreplugin/helpmanager.h> @@ -40,11 +39,9 @@ #include <projectexplorer/environmentwidget.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/target.h> #include <utils/detailswidget.h> #include <utils/environment.h> -#include <utils/qtcassert.h> -#include <qtsupport/qtsupportconstants.h> -#include <qtsupport/qtversionmanager.h> #include <QLineEdit> #include <QComboBox> @@ -54,14 +51,12 @@ #include <QStandardItemModel> using Core::ICore; -using QtSupport::QtVersionManager; namespace QmlProjectManager { namespace Internal { QmlProjectRunConfigurationWidget::QmlProjectRunConfigurationWidget(QmlProjectRunConfiguration *rc) : m_runConfiguration(rc), - m_qtVersionComboBox(0), m_fileListCombo(0), m_fileListModel(new QStandardItemModel(this)) { @@ -86,38 +81,16 @@ QmlProjectRunConfigurationWidget::QmlProjectRunConfigurationWidget(QmlProjectRun connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(fileListChanged()), SLOT(updateFileComboBox())); - m_qtVersionComboBox = new QComboBox; - m_qtVersionComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - connect(m_qtVersionComboBox, SIGNAL(activated(int)), - this, SLOT(onQtVersionSelectionChanged())); - - QPushButton *pushButton = new QPushButton; - pushButton->setText(tr("Manage Qt versions...")); - connect(pushButton, SIGNAL(clicked()), this, SLOT(manageQtVersions())); - - QHBoxLayout *qtVersionLayout = new QHBoxLayout; - qtVersionLayout->addWidget(m_qtVersionComboBox); - qtVersionLayout->addWidget(pushButton); - QLineEdit *qmlViewerArgs = new QLineEdit; qmlViewerArgs->setText(rc->m_qmlViewerArgs); connect(qmlViewerArgs, SIGNAL(textChanged(QString)), this, SLOT(onViewerArgsChanged())); - form->addRow(tr("Qt version:"), qtVersionLayout); form->addRow(tr("Arguments:"), qmlViewerArgs); form->addRow(tr("Main QML file:"), m_fileListCombo); layout->addWidget(detailsWidget); // - // Debugging - // - - QtVersionManager *qtVersions = QtVersionManager::instance(); - connect(qtVersions, SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)), - this, SLOT(updateQtVersionComboBox())); - - // // Environment // @@ -145,7 +118,6 @@ QmlProjectRunConfigurationWidget::QmlProjectRunConfigurationWidget(QmlProjectRun layout->addWidget(m_environmentWidget); updateFileComboBox(); - updateQtVersionComboBox(); } static bool caseInsensitiveLessThan(const QString &s1, const QString &s2) @@ -155,8 +127,8 @@ static bool caseInsensitiveLessThan(const QString &s1, const QString &s2) void QmlProjectRunConfigurationWidget::updateFileComboBox() { - QmlProject *project = m_runConfiguration->qmlTarget()->qmlProject(); - QDir projectDir = project->projectDir(); + ProjectExplorer::Project *project = m_runConfiguration->target()->project(); + QDir projectDir(project->projectDirectory()); if (m_runConfiguration->mainScriptSource() == QmlProjectRunConfiguration::FileInProjectFile) { const QString mainScriptInFilePath @@ -172,7 +144,7 @@ void QmlProjectRunConfigurationWidget::updateFileComboBox() m_fileListModel->appendRow(new QStandardItem(CURRENT_FILE)); QModelIndex currentIndex; - QStringList sortedFiles = project->files(); + QStringList sortedFiles = project->files(ProjectExplorer::Project::AllFiles); // make paths relative to project directory QStringList relativeFiles; @@ -216,50 +188,12 @@ void QmlProjectRunConfigurationWidget::setMainScript(int index) } } -void QmlProjectRunConfigurationWidget::onQtVersionSelectionChanged() -{ - QVariant data = m_qtVersionComboBox->itemData(m_qtVersionComboBox->currentIndex()); - QTC_ASSERT(data.isValid() && data.canConvert(QVariant::Int), return); - m_runConfiguration->setQtVersionId(data.toInt()); - m_runConfiguration->updateEnabled(); - m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment()); -} - void QmlProjectRunConfigurationWidget::onViewerArgsChanged() { if (QLineEdit *lineEdit = qobject_cast<QLineEdit*>(sender())) m_runConfiguration->m_qmlViewerArgs = lineEdit->text(); } -void QmlProjectRunConfigurationWidget::manageQtVersions() -{ - ICore::showOptionsDialog(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY, - QtSupport::Constants::QTVERSION_SETTINGS_PAGE_ID); -} - -void QmlProjectRunConfigurationWidget::updateQtVersionComboBox() -{ - m_qtVersionComboBox->clear(); - - QtVersionManager *qtVersions = QtVersionManager::instance(); - foreach (QtSupport::BaseQtVersion *version, qtVersions->validVersions()) { - if (m_runConfiguration->isValidVersion(version)) { - m_qtVersionComboBox->addItem(version->displayName(), version->uniqueId()); - } - } - - if (m_runConfiguration->m_qtVersionId != -1) { - int index = m_qtVersionComboBox->findData(m_runConfiguration->m_qtVersionId); - QTC_ASSERT(index >= 0, return); - m_qtVersionComboBox->setCurrentIndex(index); - } else { - m_qtVersionComboBox->addItem(tr("Invalid Qt version"), -1); - m_qtVersionComboBox->setCurrentIndex(0); - } - // Might have edited the qt version or changed e.g. the sysroot of a SymbianQtVersion - m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment()); -} - void QmlProjectRunConfigurationWidget::userChangesChanged() { m_runConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges()); @@ -270,6 +204,5 @@ void QmlProjectRunConfigurationWidget::userEnvironmentChangesChanged() m_environmentWidget->setUserChanges(m_runConfiguration->userEnvironmentChanges()); } - } // namespace Internal } // namespace QmlProjectManager diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.h b/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.h index 1bf02cdf88e..5acbb950574 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.h +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.h @@ -59,21 +59,17 @@ public: explicit QmlProjectRunConfigurationWidget(QmlProjectRunConfiguration *rc); public slots: - void updateQtVersionComboBox(); void userEnvironmentChangesChanged(); void updateFileComboBox(); private slots: void setMainScript(int index); - void onQtVersionSelectionChanged(); void onViewerArgsChanged(); void userChangesChanged(); - void manageQtVersions(); private: QmlProjectRunConfiguration *m_runConfiguration; - QComboBox *m_qtVersionComboBox; QComboBox *m_fileListCombo; QStandardItemModel *m_fileListModel; diff --git a/src/plugins/qmlprojectmanager/qmlprojecttarget.cpp b/src/plugins/qmlprojectmanager/qmlprojecttarget.cpp deleted file mode 100644 index c5201314337..00000000000 --- a/src/plugins/qmlprojectmanager/qmlprojecttarget.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation ([email protected]) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at [email protected]. -** -**************************************************************************/ - -#include "qmlprojecttarget.h" - -#include "qmlproject.h" -#include "qmlprojectmanagerconstants.h" -#include "qmlprojectrunconfiguration.h" - -#include <QDebug> -#include <QApplication> -#include <QStyle> - -namespace QmlProjectManager { -namespace Internal { - -QmlProjectTarget::QmlProjectTarget(QmlProject *parent) : - ProjectExplorer::Target(parent, Core::Id(Constants::QML_VIEWER_TARGET_ID)) -{ - setDisplayName(QApplication::translate("QmlProjectManager::QmlTarget", - Constants::QML_VIEWER_TARGET_DISPLAY_NAME, - "QML Viewer target display name")); - setIcon(qApp->style()->standardIcon(QStyle::SP_ComputerIcon)); -} - -QmlProjectTarget::~QmlProjectTarget() -{ -} - -ProjectExplorer::BuildConfigWidget *QmlProjectTarget::createConfigWidget() -{ - return 0; -} - -QmlProject *QmlProjectTarget::qmlProject() const -{ - return static_cast<QmlProject *>(project()); -} - -ProjectExplorer::IBuildConfigurationFactory *QmlProjectTarget::buildConfigurationFactory(void) const -{ - return 0; -} - -bool QmlProjectTarget::fromMap(const QVariantMap &map) -{ - if (!Target::fromMap(map)) - return false; - - if (runConfigurations().isEmpty()) { - qWarning() << "Failed to restore run configuration of QML project!"; - return false; - } - - setDisplayName(QApplication::translate("QmlProjectManager::QmlTarget", - Constants::QML_VIEWER_TARGET_DISPLAY_NAME, - "QML Viewer target display name")); - - return true; -} - -QmlProjectTargetFactory::QmlProjectTargetFactory(QObject *parent) : - ITargetFactory(parent) -{ -} - -QmlProjectTargetFactory::~QmlProjectTargetFactory() -{ -} - -bool QmlProjectTargetFactory::supportsTargetId(const Core::Id id) const -{ - return id == Core::Id(Constants::QML_VIEWER_TARGET_ID); -} - -QList<Core::Id> QmlProjectTargetFactory::supportedTargetIds() const -{ - return QList<Core::Id>() << Core::Id(Constants::QML_VIEWER_TARGET_ID); -} - -QString QmlProjectTargetFactory::displayNameForId(const Core::Id id) const -{ - if (id == Core::Id(Constants::QML_VIEWER_TARGET_ID)) - return QCoreApplication::translate("QmlProjectManager::QmlTarget", - Constants::QML_VIEWER_TARGET_DISPLAY_NAME, - "QML Viewer target display name"); - return QString(); -} - -bool QmlProjectTargetFactory::canCreate(ProjectExplorer::Project *parent, const Core::Id id) const -{ - if (!qobject_cast<QmlProject *>(parent)) - return false; - return id == Core::Id(Constants::QML_VIEWER_TARGET_ID); -} - -QmlProjectTarget *QmlProjectTargetFactory::create(ProjectExplorer::Project *parent, const Core::Id id) -{ - if (!canCreate(parent, id)) - return 0; - QmlProject *qmlproject(static_cast<QmlProject *>(parent)); - QmlProjectTarget *target = new QmlProjectTarget(qmlproject); - - // Add RunConfiguration (QML does not have BuildConfigurations) - QmlProjectRunConfiguration *runConf = new QmlProjectRunConfiguration(target); - target->addRunConfiguration(runConf); - - return target; -} - -bool QmlProjectTargetFactory::canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const -{ - return canCreate(parent, ProjectExplorer::idFromMap(map)); -} - -QmlProjectTarget *QmlProjectTargetFactory::restore(ProjectExplorer::Project *parent, const QVariantMap &map) -{ - if (!canRestore(parent, map)) - return 0; - QmlProject *qmlproject(static_cast<QmlProject *>(parent)); - QmlProjectTarget *target(new QmlProjectTarget(qmlproject)); - if (target->fromMap(map)) - return target; - delete target; - return 0; -} - -} // namespace Internal -} // namespace QmlProjectManager diff --git a/src/plugins/qmlprojectmanager/qmlprojecttarget.h b/src/plugins/qmlprojectmanager/qmlprojecttarget.h deleted file mode 100644 index 7359bb81fd2..00000000000 --- a/src/plugins/qmlprojectmanager/qmlprojecttarget.h +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation ([email protected]) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at [email protected]. -** -**************************************************************************/ - -#ifndef QMLPROJECTTARGET_H -#define QMLPROJECTTARGET_H - -#include <projectexplorer/target.h> - -#include <QStringList> -#include <QVariantMap> - -namespace QmlProjectManager { -class QmlProject; -class QmlProjectRunConfiguration; - -namespace Internal { - -class QmlProjectTargetFactory; - -class QmlProjectTarget : public ProjectExplorer::Target -{ - Q_OBJECT - friend class QmlProjectTargetFactory; - -public: - explicit QmlProjectTarget(QmlProject *parent); - ~QmlProjectTarget(); - - ProjectExplorer::BuildConfigWidget *createConfigWidget(); - - QmlProject *qmlProject() const; - - ProjectExplorer::IBuildConfigurationFactory *buildConfigurationFactory() const; - -protected: - bool fromMap(const QVariantMap &map); -}; - -class QmlProjectTargetFactory : public ProjectExplorer::ITargetFactory -{ - Q_OBJECT - -public: - explicit QmlProjectTargetFactory(QObject *parent = 0); - ~QmlProjectTargetFactory(); - - bool supportsTargetId(const Core::Id id) const; - QList<Core::Id> supportedTargetIds() const; - QString displayNameForId(const Core::Id id) const; - - bool canCreate(ProjectExplorer::Project *parent, const Core::Id id) const; - QmlProjectTarget *create(ProjectExplorer::Project *parent, const Core::Id id); - bool canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const; - QmlProjectTarget *restore(ProjectExplorer::Project *parent, const QVariantMap &map); -}; - -} // namespace Internal -} // namespace QmlProjectManager - -#endif // QMLPROJECTTARGET_H |