diff --git a/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.cpp b/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b36bd46a09a639d8f52e41653a83e7b7bcf76fa0 --- /dev/null +++ b/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "qbsdeployconfigurationfactory.h" + +#include "qbsinstallstep.h" +#include "qbsproject.h" + +#include <projectexplorer/buildsteplist.h> +#include <projectexplorer/target.h> + +namespace QbsProjectManager { +namespace Internal { + +// -------------------------------------------------------------------- +// Helpers: +// -------------------------------------------------------------------- + +static QString genericQbsDisplayName() { + return QCoreApplication::translate("Qbs", "Qbs Install"); +} + +static Core::Id genericQbsDeployConfigurationId() +{ + return Core::Id("Qbs.Deploy"); +} + +// -------------------------------------------------------------------- +// QbsDeployConfiguration: +// -------------------------------------------------------------------- + +QbsDeployConfiguration::QbsDeployConfiguration(ProjectExplorer::Target *target, const Core::Id id) : + ProjectExplorer::DeployConfiguration(target, id) +{ } + +QbsDeployConfiguration::QbsDeployConfiguration(ProjectExplorer::Target *target, + ProjectExplorer::DeployConfiguration *source) : + ProjectExplorer::DeployConfiguration(target, source) +{ + cloneSteps(source); +} + +// -------------------------------------------------------------------- +// QbsDeployConfigurationFactory: +// -------------------------------------------------------------------- + +QbsDeployConfigurationFactory::QbsDeployConfigurationFactory(QObject *parent) : + ProjectExplorer::DeployConfigurationFactory(parent) +{ + setObjectName(QLatin1String("QbsDeployConfiguration")); +} + +QList<Core::Id> QbsDeployConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const +{ + QList<Core::Id> ids; + if (qobject_cast<QbsProject *>(parent->project())) + ids << genericQbsDeployConfigurationId(); + return ids; +} + +QString QbsDeployConfigurationFactory::displayNameForId(const Core::Id id) const +{ + if (id == genericQbsDeployConfigurationId()) + return genericQbsDisplayName(); + return QString(); +} + +bool QbsDeployConfigurationFactory::canCreate(ProjectExplorer::Target *parent, + const Core::Id id) const +{ + return availableCreationIds(parent).contains(id); +} + +ProjectExplorer::DeployConfiguration +*QbsDeployConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id) +{ + Q_ASSERT(canCreate(parent, id)); + + QbsDeployConfiguration *dc = new QbsDeployConfiguration(parent, id); + dc->setDisplayName(genericQbsDisplayName()); + dc->stepList()->insertStep(0, new QbsInstallStep(dc->stepList())); + return dc; +} + +bool QbsDeployConfigurationFactory::canRestore(ProjectExplorer::Target *parent, + const QVariantMap &map) const +{ + return canCreate(parent, ProjectExplorer::idFromMap(map)); +} + +ProjectExplorer::DeployConfiguration +*QbsDeployConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map) +{ + if (!canRestore(parent, map)) + return 0; + Core::Id id = ProjectExplorer::idFromMap(map); + QbsDeployConfiguration *dc = new QbsDeployConfiguration(parent, id); + if (!dc->fromMap(map)) { + delete dc; + return 0; + } + return dc; +} + +ProjectExplorer::DeployConfiguration +*QbsDeployConfigurationFactory::clone(ProjectExplorer::Target *parent, + ProjectExplorer::DeployConfiguration *product) +{ + if (!canClone(parent, product)) + return 0; + return new QbsDeployConfiguration(parent, qobject_cast<QbsDeployConfiguration *>(product)); +} + +} // namespace Internal +} // namespace QbsProjectManager diff --git a/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.h b/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.h new file mode 100644 index 0000000000000000000000000000000000000000..7d021be0ed632fa6987097f055af94c6de9094da --- /dev/null +++ b/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBSDEPLOYCONFIGURATIONFACTORY_H +#define QBSDEPLOYCONFIGURATIONFACTORY_H + +#include <projectexplorer/deployconfiguration.h> + +namespace QbsProjectManager { +namespace Internal { + +class QbsDeployConfigurationFactory; + +class QbsDeployConfiguration : public ProjectExplorer::DeployConfiguration +{ + Q_OBJECT + +private: + QbsDeployConfiguration(ProjectExplorer::Target *target, const Core::Id id); + QbsDeployConfiguration(ProjectExplorer::Target *target, + ProjectExplorer::DeployConfiguration *source); + + friend class QbsDeployConfigurationFactory; +}; + +class QbsDeployConfigurationFactory : public ProjectExplorer::DeployConfigurationFactory +{ + Q_OBJECT + +public: + explicit QbsDeployConfigurationFactory(QObject *parent = 0); + + QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const; + QString displayNameForId(const Core::Id id) const; + bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const; + ProjectExplorer::DeployConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id); + bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const; + ProjectExplorer::DeployConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map); + ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent, + ProjectExplorer::DeployConfiguration *product); +}; + +} // namespace Internal +} // namespace QbsProjectManager + +#endif // QBSDEPLOYCONFIGURATIONFACTORY_H diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index bf1bad50d8ba53f90dd33e3a687315d26e69ab29..194812e9f310f7c6b0df1a2fce774ebda0b549b0 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -239,6 +239,11 @@ const qbs::ProjectData *QbsProject::qbsProjectData() const return m_rootProjectNode->projectData(); } +bool QbsProject::needsSpecialDeployment() const +{ + return true; +} + void QbsProject::handleQbsParsingDone(bool success) { QTC_ASSERT(m_qbsSetupProjectJob, return); diff --git a/src/plugins/qbsprojectmanager/qbsproject.h b/src/plugins/qbsprojectmanager/qbsproject.h index 5e1ec70e886db5fe2f0a187721599356a50c51b3..cf840a92932a6086db5211f2c595f118471ea04b 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.h +++ b/src/plugins/qbsprojectmanager/qbsproject.h @@ -94,6 +94,8 @@ public: const qbs::Project *qbsProject() const; const qbs::ProjectData *qbsProjectData() const; + bool needsSpecialDeployment() const; + public slots: void invalidate(); void parseCurrentBuildConfiguration(); diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro index d228910150eb9652637ccccab968b2fb07f32ad4..5d6c88eb4401353c7015f13e8295e571415a9fd7 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro +++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro @@ -18,6 +18,7 @@ HEADERS = \ qbsbuildconfigurationwidget.h \ qbsbuildstep.h \ qbscleanstep.h \ + qbsdeployconfigurationfactory.h \ qbsinstallstep.h \ qbslogsink.h \ qbsnodes.h \ @@ -35,6 +36,7 @@ SOURCES = \ qbsbuildconfigurationwidget.cpp \ qbsbuildstep.cpp \ qbscleanstep.cpp \ + qbsdeployconfigurationfactory.cpp \ qbsinstallstep.cpp \ qbslogsink.cpp \ qbsnodes.cpp \ diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs index 346751eb5085d30b2d3ccd482fbe8ec971dd8a1d..e15372c23a92910bf2e4828470f4d665895272d5 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs +++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs @@ -59,6 +59,8 @@ QtcPlugin { "qbscleanstep.cpp", "qbscleanstep.h", "qbscleanstepconfigwidget.ui", + "qbsdeployconfigurationfactory.cpp", + "qbsdeployconfigurationfactory.h", "qbsinstallstep.cpp", "qbsinstallstep.h", "qbsinstallstepconfigwidget.ui", diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp index 481392169cccdf869e551421ceab025ca9b954b7..4b93d17c37a3da05b5f4a7e2225349bb5b840bc3 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp @@ -32,6 +32,7 @@ #include "qbsbuildconfiguration.h" #include "qbsbuildstep.h" #include "qbscleanstep.h" +#include "qbsdeployconfigurationfactory.h" #include "qbsinstallstep.h" #include "qbsproject.h" #include "qbsprojectmanager.h" @@ -83,6 +84,7 @@ bool QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString * addAutoReleasedObject(new QbsBuildStepFactory); addAutoReleasedObject(new QbsCleanStepFactory); addAutoReleasedObject(new QbsInstallStepFactory); + addAutoReleasedObject(new QbsDeployConfigurationFactory); //menus // Build Menu: