1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of Qt Creator.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #include "maemopackagecreationfactory.h"
44 #include "maemopackagecreationstep.h"
46 #include <projectexplorer/buildconfiguration.h>
47 #include <projectexplorer/buildsteplist.h>
48 #include <projectexplorer/deployconfiguration.h>
49 #include <projectexplorer/projectexplorerconstants.h>
50 #include <projectexplorer/target.h>
51 #include <qt4projectmanagerconstants.h>
53 #include <QtCore/QCoreApplication>
55 using ProjectExplorer::BuildStepList;
56 using ProjectExplorer::BuildStep;
58 namespace Qt4ProjectManager {
61 MaemoPackageCreationFactory::MaemoPackageCreationFactory(QObject *parent)
62 : ProjectExplorer::IBuildStepFactory(parent)
66 QStringList MaemoPackageCreationFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const
68 if (parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
69 && parent->target()->id() == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID)
70 && !parent->contains(MaemoPackageCreationStep::CreatePackageId))
71 return QStringList() << MaemoPackageCreationStep::CreatePackageId;
75 QString MaemoPackageCreationFactory::displayNameForId(const QString &id) const
77 if (id == MaemoPackageCreationStep::CreatePackageId)
78 return QCoreApplication::translate("Qt4ProjectManager::Internal::MaemoPackageCreationFactory",
79 "Create Debian Package");
83 bool MaemoPackageCreationFactory::canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const
85 return parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
86 && id == QLatin1String(MaemoPackageCreationStep::CreatePackageId)
87 && parent->target()->id() == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID)
88 && !parent->contains(MaemoPackageCreationStep::CreatePackageId);
91 BuildStep *MaemoPackageCreationFactory::create(ProjectExplorer::BuildStepList *parent, const QString &id)
93 Q_ASSERT(canCreate(parent, id));
94 return new MaemoPackageCreationStep(parent);
97 bool MaemoPackageCreationFactory::canRestore(ProjectExplorer::BuildStepList *parent,
98 const QVariantMap &map) const
100 return canCreate(parent, ProjectExplorer::idFromMap(map));
103 BuildStep *MaemoPackageCreationFactory::restore(ProjectExplorer::BuildStepList *parent,
104 const QVariantMap &map)
106 Q_ASSERT(canRestore(parent, map));
107 MaemoPackageCreationStep * const step
108 = new MaemoPackageCreationStep(parent);
109 if (!step->fromMap(map)) {
116 bool MaemoPackageCreationFactory::canClone(ProjectExplorer::BuildStepList *parent,
117 ProjectExplorer::BuildStep *product) const
119 return canCreate(parent, product->id());
122 BuildStep *MaemoPackageCreationFactory::clone(ProjectExplorer::BuildStepList *parent,
123 ProjectExplorer::BuildStep *product)
125 Q_ASSERT(canClone(parent, product));
126 return new MaemoPackageCreationStep(parent, static_cast<MaemoPackageCreationStep *>(product));
129 } // namespace Internal
130 } // namespace Qt4ProjectManager