OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / qt-maemo / maemopackagecreationfactory.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of Qt Creator.
8 **
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
14 ** this package.
15 **
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.
23 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "maemopackagecreationfactory.h"
43
44 #include "maemopackagecreationstep.h"
45
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>
52
53 #include <QtCore/QCoreApplication>
54
55 using ProjectExplorer::BuildStepList;
56 using ProjectExplorer::BuildStep;
57
58 namespace Qt4ProjectManager {
59 namespace Internal {
60
61 MaemoPackageCreationFactory::MaemoPackageCreationFactory(QObject *parent)
62     : ProjectExplorer::IBuildStepFactory(parent)
63 {
64 }
65
66 QStringList MaemoPackageCreationFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const
67 {
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;
72     return QStringList();
73 }
74
75 QString MaemoPackageCreationFactory::displayNameForId(const QString &id) const
76 {
77     if (id == MaemoPackageCreationStep::CreatePackageId)
78         return QCoreApplication::translate("Qt4ProjectManager::Internal::MaemoPackageCreationFactory",
79                                            "Create Debian Package");
80     return QString();
81 }
82
83 bool MaemoPackageCreationFactory::canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const
84 {
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);
89 }
90
91 BuildStep *MaemoPackageCreationFactory::create(ProjectExplorer::BuildStepList *parent, const QString &id)
92 {
93     Q_ASSERT(canCreate(parent, id));
94     return new MaemoPackageCreationStep(parent);
95 }
96
97 bool MaemoPackageCreationFactory::canRestore(ProjectExplorer::BuildStepList *parent,
98                                              const QVariantMap &map) const
99 {
100     return canCreate(parent, ProjectExplorer::idFromMap(map));
101 }
102
103 BuildStep *MaemoPackageCreationFactory::restore(ProjectExplorer::BuildStepList *parent,
104                                                 const QVariantMap &map)
105 {
106     Q_ASSERT(canRestore(parent, map));
107     MaemoPackageCreationStep * const step
108         = new MaemoPackageCreationStep(parent);
109     if (!step->fromMap(map)) {
110         delete step;
111         return 0;
112     }
113     return step;
114 }
115
116 bool MaemoPackageCreationFactory::canClone(ProjectExplorer::BuildStepList *parent,
117                                            ProjectExplorer::BuildStep *product) const
118 {
119     return canCreate(parent, product->id());
120 }
121
122 BuildStep *MaemoPackageCreationFactory::clone(ProjectExplorer::BuildStepList *parent,
123                                               ProjectExplorer::BuildStep *product)
124 {
125     Q_ASSERT(canClone(parent, product));
126     return new MaemoPackageCreationStep(parent, static_cast<MaemoPackageCreationStep *>(product));
127 }
128
129 } // namespace Internal
130 } // namespace Qt4ProjectManager