1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #include "deployconfiguration.h"
35 #include "buildmanager.h"
36 #include "buildsteplist.h"
37 #include "buildstepspage.h"
38 #include "projectexplorer.h"
39 #include "projectexplorerconstants.h"
42 #include <QtCore/QStringList>
44 using namespace ProjectExplorer;
48 const char * const BUILD_STEP_LIST_COUNT("ProjectExplorer.BuildConfiguration.BuildStepListCount");
49 const char * const BUILD_STEP_LIST_PREFIX("ProjectExplorer.BuildConfiguration.BuildStepList.");
53 DeployConfiguration::DeployConfiguration(Target *target, const QString &id) :
54 ProjectConfiguration(target, id),
58 m_stepList = new BuildStepList(this, QLatin1String(Constants::BUILDSTEPS_DEPLOY));
59 //: Display name of the deploy build step list. Used as part of the labels in the project window.
60 m_stepList->setDefaultDisplayName(tr("Deploy"));
61 //: Default DeployConfiguration display name
62 setDefaultDisplayName(tr("No deployment"));
65 DeployConfiguration::DeployConfiguration(Target *target, DeployConfiguration *source) :
66 ProjectConfiguration(target, source)
69 // Do not clone stepLists here, do that in the derived constructor instead
70 // otherwise BuildStepFactories might reject to set up a BuildStep for us
71 // since we are not yet the derived class!
74 DeployConfiguration::~DeployConfiguration()
79 BuildStepList *DeployConfiguration::stepList() const
84 QVariantMap DeployConfiguration::toMap() const
86 QVariantMap map(ProjectConfiguration::toMap());
87 map.insert(QLatin1String(BUILD_STEP_LIST_COUNT), 1);
88 map.insert(QLatin1String(BUILD_STEP_LIST_PREFIX) + QLatin1String("0"), m_stepList->toMap());
92 DeployConfigurationWidget *DeployConfiguration::configurationWidget() const
97 bool DeployConfiguration::fromMap(const QVariantMap &map)
99 if (!ProjectConfiguration::fromMap(map))
102 int maxI = map.value(QLatin1String(BUILD_STEP_LIST_COUNT), 0).toInt();
105 QVariantMap data = map.value(QLatin1String(BUILD_STEP_LIST_PREFIX) + QLatin1String("0")).toMap();
106 if (!data.isEmpty()) {
107 m_stepList = new BuildStepList(this, data);
108 if (m_stepList->isNull()) {
109 qWarning() << "Failed to restore deploy step list";
114 m_stepList->setDefaultDisplayName(tr("Deploy"));
116 qWarning() << "No data for deploy step list found!";
120 // TODO: We assume that we hold the deploy list
121 Q_ASSERT(m_stepList && m_stepList->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY));
126 Target *DeployConfiguration::target() const
128 return static_cast<Target *>(parent());
131 void DeployConfiguration::cloneSteps(DeployConfiguration *source)
136 m_stepList = new BuildStepList(this, source->stepList());
137 m_stepList->cloneSteps(source->stepList());
141 // DeployConfigurationFactory
144 DeployConfigurationFactory::DeployConfigurationFactory(QObject *parent) :
148 DeployConfigurationFactory::~DeployConfigurationFactory()
151 QStringList DeployConfigurationFactory::availableCreationIds(Target *parent) const
154 return QStringList() << QLatin1String(Constants::DEFAULT_DEPLOYCONFIGURATION_ID);
157 QString DeployConfigurationFactory::displayNameForId(const QString &id) const
159 if (id == QLatin1String(Constants::DEFAULT_DEPLOYCONFIGURATION_ID))
160 //: Display name of the default deploy configuration
161 return tr("Deploy Configuration");
165 bool DeployConfigurationFactory::canCreate(Target *parent, const QString &id) const
168 return id == QLatin1String(Constants::DEFAULT_DEPLOYCONFIGURATION_ID);
171 DeployConfiguration *DeployConfigurationFactory::create(Target *parent, const QString &id)
173 if (!canCreate(parent, id))
175 return new DeployConfiguration(parent, id);
178 bool DeployConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
180 return canCreate(parent, idFromMap(map));
183 DeployConfiguration *DeployConfigurationFactory::restore(Target *parent, const QVariantMap &map)
185 if (!canRestore(parent, map))
187 DeployConfiguration *dc = new DeployConfiguration(parent, idFromMap(map));
188 if (!dc->fromMap(map)) {
195 bool DeployConfigurationFactory::canClone(Target *parent, DeployConfiguration *product) const
197 return canCreate(parent, product->id());
200 DeployConfiguration *DeployConfigurationFactory::clone(Target *parent, DeployConfiguration *product)
202 if (!canClone(parent, product))
204 return new DeployConfiguration(parent, product);
208 // DeployConfigurationWidget
211 DeployConfigurationWidget::DeployConfigurationWidget(QWidget *parent) : NamedWidget(parent)