tizendeployconfiguration.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 "tizendeployconfiguration.h"
  30. #include "tizenconfigurations.h"
  31. #include "tizendeploydirectorycreationstep.h"
  32. #include "tizendeploypackagecreationstep.h"
  33. #include "tizendeploypackageinstallationstep.h"
  34. #include "tizenconstants.h"
  35. #include "tizenmanager.h"
  36. #include <projectexplorer/buildsteplist.h>
  37. #include <projectexplorer/target.h>
  38. #include <projectexplorer/toolchain.h>
  39. #include <projectexplorer/buildconfiguration.h>
  40. #include <qt4projectmanager/qt4project.h>
  41. #include <qt4projectmanager/qt4nodes.h>
  42. #include <qtsupport/qtkitinformation.h>
  43. #include <qtsupport/qtsupportconstants.h>
  44. using namespace ProjectExplorer;
  45. namespace Tizen {
  46. namespace Internal {
  47. TizenDeployConfiguration::TizenDeployConfiguration(Target *parent, Core::Id id)
  48. : DeployConfiguration(parent, id)
  49. {
  50. setDisplayName(tr("Deploy to Tizen device"));
  51. setDefaultDisplayName(displayName());
  52. }
  53. TizenDeployConfiguration::TizenDeployConfiguration(Target *parent, DeployConfiguration *source)
  54. : DeployConfiguration(parent, source)
  55. {
  56. cloneSteps(source);
  57. }
  58. TizenDeployConfigurationFactory::TizenDeployConfigurationFactory(QObject *parent)
  59. : DeployConfigurationFactory(parent)
  60. {
  61. setObjectName(QLatin1String("TizenDeployConfigurationFactory"));
  62. }
  63. bool TizenDeployConfigurationFactory::canCreate(Target *parent, const Core::Id id) const
  64. {
  65. qWarning()<< "can create:"<<"id:"<<id.toString()<<" available creations:";
  66. return availableCreationIds(parent).contains(id);
  67. }
  68. DeployConfiguration *TizenDeployConfigurationFactory::create(Target *parent, const Core::Id id)
  69. {
  70. TizenDeployConfiguration *dc = new TizenDeployConfiguration(parent, id);
  71. if (!dc)
  72. return 0;
  73. dc->stepList()->insertStep(0, new TizenDeployDirectoryCreationStep(dc->stepList()));
  74. Qt4ProjectManager::Qt4Project *project = qobject_cast<Qt4ProjectManager::Qt4Project *>(parent->project());
  75. if (!project) {
  76. return 0;
  77. }
  78. Qt4ProjectManager::Qt4ProFileNode * rootQt4ProjectNode = project->rootQt4ProjectNode();
  79. if ( rootQt4ProjectNode && rootQt4ProjectNode->projectType() == Qt4ProjectManager::ApplicationTemplate
  80. && QFile::exists(TizenManager::manifestPath(parent).toString())) {
  81. dc->stepList()->insertStep(1, new TizenDeployPackageCreationStep(dc->stepList()));
  82. dc->stepList()->insertStep(2, new TizenDeployPackageInstallationStep(dc->stepList()));
  83. }
  84. return dc;
  85. }
  86. bool TizenDeployConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
  87. {
  88. return canCreate(parent, idFromMap(map));
  89. }
  90. DeployConfiguration *TizenDeployConfigurationFactory::restore(Target *parent, const QVariantMap &map)
  91. {
  92. if (!canRestore(parent, map))
  93. return 0;
  94. TizenDeployConfiguration *dc = new TizenDeployConfiguration(parent, idFromMap(map));
  95. if (dc->fromMap(map))
  96. return dc;
  97. delete dc;
  98. return 0;
  99. }
  100. bool TizenDeployConfigurationFactory::canClone(Target *, DeployConfiguration *source) const
  101. {
  102. return source->id() == TIZEN_DEPLOYCONFIGURATION_ID;
  103. }
  104. DeployConfiguration *TizenDeployConfigurationFactory::clone(Target *parent, DeployConfiguration *source)
  105. {
  106. if (!canClone(parent, source))
  107. return 0;
  108. return new TizenDeployConfiguration(parent, source);
  109. }
  110. QList<Core::Id> TizenDeployConfigurationFactory::availableCreationIds(Target *parent) const
  111. {
  112. QList<Core::Id> ids;
  113. if (!qobject_cast<Qt4ProjectManager::Qt4Project *>(parent->project())) {
  114. return ids;
  115. }
  116. if (!parent->project()->supportsKit(parent->kit()))
  117. return ids;
  118. ToolChain *tc = ToolChainKitInformation::toolChain(parent->kit());
  119. if (!tc || tc->type() != QLatin1String(Constants::TIZEN_TOOLCHAIN_GCC_TYPE))
  120. return ids;
  121. if (QtSupport::QtKitInformation::qtVersion(parent->kit())->type() != QLatin1String(Constants::TIZEN_QT))
  122. return ids;
  123. ids << Core::Id(TIZEN_DEPLOYCONFIGURATION_ID);
  124. return ids;
  125. }
  126. QString TizenDeployConfigurationFactory::displayNameForId(const Core::Id id) const
  127. {
  128. if (id.name().startsWith(TIZEN_DC_PREFIX))
  129. return tr("Deploy on Tizen");
  130. return QString();
  131. }
  132. bool TizenDeployConfigurationFactory::canHandle(Target *parent) const
  133. {
  134. return TizenManager::supportsTizen(parent);
  135. }
  136. } // namespace Internal
  137. } // namespace Tizen