tizendeploypackagecreationfactory.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /**************************************************************************
  2. **
  3. ** Copyright (c) 2013 Tomasz Olszak <olszak.tomasz@gmail.com>
  4. ** Contact: http://www.qt-project.org/legal
  5. **
  6. ** This file is part of Qt Creator.
  7. **
  8. ** Commercial License Usage
  9. ** Licensees holding valid commercial Qt licenses may use this file in
  10. ** accordance with the commercial license agreement provided with the
  11. ** Software or, alternatively, in accordance with the terms contained in
  12. ** a written agreement between you and Digia. For licensing terms and
  13. ** conditions see http://qt.digia.com/licensing. For further information
  14. ** use the contact form at http://qt.digia.com/contact-us.
  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, Digia gives you certain additional
  25. ** rights. These rights are described in the Digia Qt LGPL Exception
  26. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  27. **
  28. ****************************************************************************/
  29. #include "tizendeploypackagecreationfactory.h"
  30. #include "tizendeploypackagecreationstep.h"
  31. #include <projectexplorer/buildsteplist.h>
  32. #include <projectexplorer/projectexplorerconstants.h>
  33. #include <projectexplorer/target.h>
  34. #include <qtsupport/qtkitinformation.h>
  35. #include <qtsupport/qtsupportconstants.h>
  36. using namespace ProjectExplorer;
  37. namespace Tizen {
  38. namespace Internal {
  39. TizenDeployPackageCreationFactory::TizenDeployPackageCreationFactory(QObject *parent)
  40. : IBuildStepFactory(parent)
  41. {
  42. }
  43. QList<Core::Id> TizenDeployPackageCreationFactory::availableCreationIds(BuildStepList *parent) const
  44. {
  45. if (parent->id() != ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
  46. return QList<Core::Id>();
  47. if (parent->contains(TizenDeployPackageCreationStep::Id))
  48. return QList<Core::Id>();
  49. return QList<Core::Id>() << TizenDeployPackageCreationStep::Id;
  50. }
  51. QString TizenDeployPackageCreationFactory::displayNameForId(const Core::Id id) const
  52. {
  53. if (id == TizenDeployPackageCreationStep::Id)
  54. return tr("Deploy to device");
  55. return QString();
  56. }
  57. bool TizenDeployPackageCreationFactory::canCreate(BuildStepList *parent, const Core::Id id) const
  58. {
  59. return availableCreationIds(parent).contains(id);
  60. }
  61. BuildStep *TizenDeployPackageCreationFactory::create(BuildStepList *parent, const Core::Id id)
  62. {
  63. Q_ASSERT(canCreate(parent, id));
  64. Q_UNUSED(id);
  65. return new TizenDeployPackageCreationStep(parent);
  66. }
  67. bool TizenDeployPackageCreationFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const
  68. {
  69. return canCreate(parent, idFromMap(map));
  70. }
  71. BuildStep *TizenDeployPackageCreationFactory::restore(BuildStepList *parent, const QVariantMap &map)
  72. {
  73. Q_ASSERT(canRestore(parent, map));
  74. TizenDeployPackageCreationStep * const step = new TizenDeployPackageCreationStep(parent);
  75. if (!step->fromMap(map)) {
  76. delete step;
  77. return 0;
  78. }
  79. return step;
  80. }
  81. bool TizenDeployPackageCreationFactory::canClone(BuildStepList *parent, BuildStep *product) const
  82. {
  83. return canCreate(parent, product->id());
  84. }
  85. BuildStep *TizenDeployPackageCreationFactory::clone(BuildStepList *parent, BuildStep *product)
  86. {
  87. Q_ASSERT(canClone(parent, product));
  88. return new TizenDeployPackageCreationStep(parent, static_cast<TizenDeployPackageCreationStep*>(product));
  89. }
  90. } // namespace Internal
  91. } // namespace Tizen