| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | /**************************************************************************
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** This file is part of Qt Creator | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-01-26 18:33:46 +01:00
										 |  |  | ** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-07-19 12:26:56 +02:00
										 |  |  | ** Contact: http://www.qt-project.org/
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | ** | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** GNU Lesser General Public License Usage | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2011-04-13 08:42:33 +02:00
										 |  |  | ** This file may be used under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  | ** License version 2.1 as published by the Free Software Foundation and | 
					
						
							|  |  |  | ** appearing in the file LICENSE.LGPL included in the packaging of this file. | 
					
						
							|  |  |  | ** Please review the following information to ensure the GNU Lesser General | 
					
						
							|  |  |  | ** Public License version 2.1 requirements will be met: | 
					
						
							|  |  |  | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2010-12-17 16:01:08 +01:00
										 |  |  | ** In addition, as a special exception, Nokia gives you certain additional | 
					
						
							| 
									
										
										
										
											2011-04-13 08:42:33 +02:00
										 |  |  | ** rights. These rights are described in the Nokia Qt LGPL Exception | 
					
						
							| 
									
										
										
										
											2010-12-17 16:01:08 +01:00
										 |  |  | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2011-04-13 08:42:33 +02:00
										 |  |  | ** Other Usage | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Alternatively, this file may be used in accordance with the terms and | 
					
						
							|  |  |  | ** conditions contained in a signed written agreement between you and Nokia. | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | ** | 
					
						
							|  |  |  | **************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "target.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-20 12:41:52 +02:00
										 |  |  | #include "buildtargetinfo.h"
 | 
					
						
							|  |  |  | #include "deploymentdata.h"
 | 
					
						
							| 
									
										
										
										
											2012-09-03 18:31:44 +02:00
										 |  |  | #include "kit.h"
 | 
					
						
							|  |  |  | #include "kitinformation.h"
 | 
					
						
							|  |  |  | #include "kitmanager.h"
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | #include "buildconfiguration.h"
 | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  | #include "deployconfiguration.h"
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | #include "project.h"
 | 
					
						
							| 
									
										
										
										
											2010-09-09 17:00:26 +02:00
										 |  |  | #include "projectexplorerconstants.h"
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | #include "runconfiguration.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-09 17:00:26 +02:00
										 |  |  | #include <limits>
 | 
					
						
							| 
									
										
										
										
											2012-03-26 11:15:11 +02:00
										 |  |  | #include <coreplugin/coreconstants.h>
 | 
					
						
							| 
									
										
										
										
											2011-10-24 13:10:38 +00:00
										 |  |  | #include <projectexplorer/buildmanager.h>
 | 
					
						
							| 
									
										
										
										
											2012-03-26 11:15:11 +02:00
										 |  |  | #include <projectexplorer/devicesupport/devicemanager.h>
 | 
					
						
							|  |  |  | #include <extensionsystem/pluginmanager.h>
 | 
					
						
							| 
									
										
										
										
											2011-10-24 13:10:38 +00:00
										 |  |  | #include <projectexplorer/projectexplorer.h>
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | #include <utils/qtcassert.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | #include <QDebug>
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QIcon>
 | 
					
						
							| 
									
										
										
										
											2012-03-26 11:15:11 +02:00
										 |  |  | #include <QPainter>
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace { | 
					
						
							| 
									
										
										
										
											2011-11-02 16:45:13 +01:00
										 |  |  | const char ACTIVE_BC_KEY[] = "ProjectExplorer.Target.ActiveBuildConfiguration"; | 
					
						
							|  |  |  | const char BC_KEY_PREFIX[] = "ProjectExplorer.Target.BuildConfiguration."; | 
					
						
							|  |  |  | const char BC_COUNT_KEY[] = "ProjectExplorer.Target.BuildConfigurationCount"; | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-02 16:45:13 +01:00
										 |  |  | const char ACTIVE_DC_KEY[] = "ProjectExplorer.Target.ActiveDeployConfiguration"; | 
					
						
							|  |  |  | const char DC_KEY_PREFIX[] = "ProjectExplorer.Target.DeployConfiguration."; | 
					
						
							|  |  |  | const char DC_COUNT_KEY[] = "ProjectExplorer.Target.DeployConfigurationCount"; | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-02 16:45:13 +01:00
										 |  |  | const char ACTIVE_RC_KEY[] = "ProjectExplorer.Target.ActiveRunConfiguration"; | 
					
						
							|  |  |  | const char RC_KEY_PREFIX[] = "ProjectExplorer.Target.RunConfiguration."; | 
					
						
							|  |  |  | const char RC_COUNT_KEY[] = "ProjectExplorer.Target.RunConfigurationCount"; | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // -------------------------------------------------------------------------
 | 
					
						
							|  |  |  | // Target
 | 
					
						
							|  |  |  | // -------------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  | namespace ProjectExplorer { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-21 15:01:48 +02:00
										 |  |  | class TargetPrivate | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  | public: | 
					
						
							|  |  |  |     TargetPrivate(); | 
					
						
							| 
									
										
										
										
											2011-03-09 12:07:35 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QList<DeployConfigurationFactory *> deployFactories() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     bool m_isEnabled; | 
					
						
							|  |  |  |     QIcon m_icon; | 
					
						
							|  |  |  |     QIcon m_overlayIcon; | 
					
						
							|  |  |  |     QString m_toolTip; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<BuildConfiguration *> m_buildConfigurations; | 
					
						
							|  |  |  |     BuildConfiguration *m_activeBuildConfiguration; | 
					
						
							|  |  |  |     QList<DeployConfiguration *> m_deployConfigurations; | 
					
						
							|  |  |  |     DeployConfiguration *m_activeDeployConfiguration; | 
					
						
							|  |  |  |     QList<RunConfiguration *> m_runConfigurations; | 
					
						
							|  |  |  |     RunConfiguration* m_activeRunConfiguration; | 
					
						
							| 
									
										
										
										
											2012-08-20 12:41:52 +02:00
										 |  |  |     DeploymentData m_deploymentData; | 
					
						
							|  |  |  |     BuildTargetInfoList m_appTargets; | 
					
						
							| 
									
										
										
										
											2012-03-26 11:15:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QPixmap m_connectedPixmap; | 
					
						
							| 
									
										
										
										
											2012-05-29 13:49:34 +02:00
										 |  |  |     QPixmap m_readyToUsePixmap; | 
					
						
							| 
									
										
										
										
											2012-03-26 11:15:11 +02:00
										 |  |  |     QPixmap m_disconnectedPixmap; | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-04 15:27:10 +02:00
										 |  |  |     Kit *m_kit; | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TargetPrivate::TargetPrivate() : | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     m_isEnabled(true), | 
					
						
							|  |  |  |     m_activeBuildConfiguration(0), | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |     m_activeDeployConfiguration(0), | 
					
						
							| 
									
										
										
										
											2012-03-26 11:15:11 +02:00
										 |  |  |     m_activeRunConfiguration(0), | 
					
						
							| 
									
										
										
										
											2012-05-29 13:49:34 +02:00
										 |  |  |     m_connectedPixmap(QLatin1String(":/projectexplorer/images/DeviceConnected.png")), | 
					
						
							|  |  |  |     m_readyToUsePixmap(QLatin1String(":/projectexplorer/images/DeviceReadyToUse.png")), | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |     m_disconnectedPixmap(QLatin1String(":/projectexplorer/images/DeviceDisconnected.png")), | 
					
						
							| 
									
										
										
										
											2012-09-04 15:27:10 +02:00
										 |  |  |     m_kit(0) | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-09 12:07:35 +01:00
										 |  |  | QList<DeployConfigurationFactory *> TargetPrivate::deployFactories() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-18 11:34:15 +02:00
										 |  |  |     return ExtensionSystem::PluginManager::getObjects<DeployConfigurationFactory>(); | 
					
						
							| 
									
										
										
										
											2011-03-09 12:07:35 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-09 20:41:30 +03:00
										 |  |  | Target::Target(Project *project, Kit *k) : | 
					
						
							|  |  |  |     ProjectConfiguration(project, k->id()), | 
					
						
							| 
									
										
										
										
											2012-03-15 17:17:40 +01:00
										 |  |  |     d(new TargetPrivate) | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-27 15:58:59 +02:00
										 |  |  |     connect(DeviceManager::instance(), SIGNAL(updated()), this, SLOT(updateDeviceState())); | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-09 20:41:30 +03:00
										 |  |  |     d->m_kit = k; | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-04 15:27:10 +02:00
										 |  |  |     setDisplayName(d->m_kit->displayName()); | 
					
						
							|  |  |  |     setIcon(d->m_kit->icon()); | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-09 20:41:30 +03:00
										 |  |  |     KitManager *km = KitManager::instance(); | 
					
						
							|  |  |  |     connect(km, SIGNAL(kitUpdated(ProjectExplorer::Kit*)), | 
					
						
							| 
									
										
										
										
											2012-09-03 18:31:44 +02:00
										 |  |  |             this, SLOT(handleKitUpdates(ProjectExplorer::Kit*))); | 
					
						
							| 
									
										
										
										
											2012-09-09 20:41:30 +03:00
										 |  |  |     connect(km, SIGNAL(kitRemoved(ProjectExplorer::Kit*)), | 
					
						
							| 
									
										
										
										
											2012-09-03 18:31:44 +02:00
										 |  |  |             this, SLOT(handleKitRemoval(ProjectExplorer::Kit*))); | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | Target::~Target() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     qDeleteAll(d->m_buildConfigurations); | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |     qDeleteAll(d->m_deployConfigurations); | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     qDeleteAll(d->m_runConfigurations); | 
					
						
							| 
									
										
										
										
											2011-09-16 15:00:41 +02:00
										 |  |  |     delete d; | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::changeEnvironment() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-04-21 15:01:48 +02:00
										 |  |  |     BuildConfiguration *bc = qobject_cast<BuildConfiguration *>(sender()); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     if (bc == activeBuildConfiguration()) | 
					
						
							|  |  |  |         emit environmentChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-19 15:46:01 +01:00
										 |  |  | void Target::changeBuildConfigurationEnabled() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-04-21 15:01:48 +02:00
										 |  |  |     BuildConfiguration *bc = qobject_cast<BuildConfiguration *>(sender()); | 
					
						
							| 
									
										
										
										
											2011-01-19 15:46:01 +01:00
										 |  |  |     if (bc == activeBuildConfiguration()) | 
					
						
							|  |  |  |         emit buildConfigurationEnabledChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 13:16:25 +02:00
										 |  |  | void Target::changeDeployConfigurationEnabled() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     DeployConfiguration *dc = qobject_cast<DeployConfiguration *>(sender()); | 
					
						
							|  |  |  |     if (dc == activeDeployConfiguration()) | 
					
						
							|  |  |  |         emit deployConfigurationEnabledChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::changeRunConfigurationEnabled() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     RunConfiguration *rc = qobject_cast<RunConfiguration *>(sender()); | 
					
						
							|  |  |  |     if (rc == activeRunConfiguration()) | 
					
						
							|  |  |  |         emit runConfigurationEnabledChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | void Target::onBuildDirectoryChanged() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     BuildConfiguration *bc = qobject_cast<BuildConfiguration *>(sender()); | 
					
						
							|  |  |  |     if (bc) | 
					
						
							|  |  |  |         emit buildDirectoryChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-09 20:41:30 +03:00
										 |  |  | void Target::handleKitUpdates(Kit *k) | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-09-09 20:41:30 +03:00
										 |  |  |     if (k != d->m_kit) | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-09 20:41:30 +03:00
										 |  |  |     setDisplayName(k->displayName()); | 
					
						
							|  |  |  |     setIcon(k->icon()); | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |     updateDefaultDeployConfigurations(); | 
					
						
							| 
									
										
										
										
											2012-09-28 14:33:26 +02:00
										 |  |  |     updateDeviceState(); // in case the device changed...
 | 
					
						
							| 
									
										
										
										
											2012-09-03 18:31:44 +02:00
										 |  |  |     emit kitChanged(); | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-09 20:41:30 +03:00
										 |  |  | void Target::handleKitRemoval(Kit *k) | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-09-09 20:41:30 +03:00
										 |  |  |     if (k != d->m_kit) | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2012-09-04 15:27:10 +02:00
										 |  |  |     d->m_kit = 0; | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |     project()->removeTarget(this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | Project *Target::project() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |     return static_cast<Project *>(parent()); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-03 18:31:44 +02:00
										 |  |  | Kit *Target::kit() const | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-09-04 15:27:10 +02:00
										 |  |  |     return d->m_kit; | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | void Target::addBuildConfiguration(BuildConfiguration *configuration) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     QTC_ASSERT(configuration && !d->m_buildConfigurations.contains(configuration), return); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     Q_ASSERT(configuration->target() == this); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Check that we don't have a configuration with the same displayName
 | 
					
						
							|  |  |  |     QString configurationDisplayName = configuration->displayName(); | 
					
						
							|  |  |  |     QStringList displayNames; | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     foreach (const BuildConfiguration *bc, d->m_buildConfigurations) | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |         displayNames << bc->displayName(); | 
					
						
							|  |  |  |     configurationDisplayName = Project::makeUnique(configurationDisplayName, displayNames); | 
					
						
							| 
									
										
										
										
											2011-05-20 12:52:59 +02:00
										 |  |  |     if (configurationDisplayName != configuration->displayName()) { | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         if (configuration->usesDefaultDisplayName()) | 
					
						
							| 
									
										
										
										
											2011-05-20 12:52:59 +02:00
										 |  |  |             configuration->setDefaultDisplayName(configurationDisplayName); | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         else | 
					
						
							| 
									
										
										
										
											2011-05-20 12:52:59 +02:00
										 |  |  |             configuration->setDisplayName(configurationDisplayName); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // add it
 | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     d->m_buildConfigurations.push_back(configuration); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     emit addedBuildConfiguration(configuration); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(configuration, SIGNAL(environmentChanged()), | 
					
						
							|  |  |  |             SLOT(changeEnvironment())); | 
					
						
							| 
									
										
										
										
											2011-01-19 15:46:01 +01:00
										 |  |  |     connect(configuration, SIGNAL(enabledChanged()), | 
					
						
							|  |  |  |             this, SLOT(changeBuildConfigurationEnabled())); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     if (!activeBuildConfiguration()) | 
					
						
							|  |  |  |         setActiveBuildConfiguration(configuration); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-24 13:10:38 +00:00
										 |  |  | bool Target::removeBuildConfiguration(BuildConfiguration *configuration) | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     //todo: this might be error prone
 | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     if (!d->m_buildConfigurations.contains(configuration)) | 
					
						
							| 
									
										
										
										
											2011-10-24 13:10:38 +00:00
										 |  |  |         return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ProjectExplorer::BuildManager *bm = | 
					
						
							|  |  |  |             ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager(); | 
					
						
							|  |  |  |     if (bm->isBuilding(configuration)) | 
					
						
							|  |  |  |         return false; | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     d->m_buildConfigurations.removeOne(configuration); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     emit removedBuildConfiguration(configuration); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (activeBuildConfiguration() == configuration) { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |         if (d->m_buildConfigurations.isEmpty()) | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |             setActiveBuildConfiguration(0); | 
					
						
							|  |  |  |         else | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |             setActiveBuildConfiguration(d->m_buildConfigurations.at(0)); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     delete configuration; | 
					
						
							| 
									
										
										
										
											2011-10-24 13:10:38 +00:00
										 |  |  |     return true; | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QList<BuildConfiguration *> Target::buildConfigurations() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     return d->m_buildConfigurations; | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | BuildConfiguration *Target::activeBuildConfiguration() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     return d->m_activeBuildConfiguration; | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::setActiveBuildConfiguration(BuildConfiguration *configuration) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     if ((!configuration && d->m_buildConfigurations.isEmpty()) || | 
					
						
							|  |  |  |         (configuration && d->m_buildConfigurations.contains(configuration) && | 
					
						
							|  |  |  |          configuration != d->m_activeBuildConfiguration)) { | 
					
						
							|  |  |  |         d->m_activeBuildConfiguration = configuration; | 
					
						
							|  |  |  |         emit activeBuildConfigurationChanged(d->m_activeBuildConfiguration); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |         emit environmentChanged(); | 
					
						
							| 
									
										
										
										
											2011-01-19 15:46:01 +01:00
										 |  |  |         emit buildConfigurationEnabledChanged(); | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         emit buildDirectoryChanged(); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  | void Target::addDeployConfiguration(DeployConfiguration *dc) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     QTC_ASSERT(dc && !d->m_deployConfigurations.contains(dc), return); | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |     Q_ASSERT(dc->target() == this); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-09 12:07:35 +01:00
										 |  |  |     if (d->deployFactories().isEmpty()) | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Check that we don't have a configuration with the same displayName
 | 
					
						
							|  |  |  |     QString configurationDisplayName = dc->displayName(); | 
					
						
							|  |  |  |     QStringList displayNames; | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     foreach (const DeployConfiguration *current, d->m_deployConfigurations) | 
					
						
							| 
									
										
										
										
											2010-08-18 15:38:42 +02:00
										 |  |  |         displayNames << current->displayName(); | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |     configurationDisplayName = Project::makeUnique(configurationDisplayName, displayNames); | 
					
						
							|  |  |  |     dc->setDisplayName(configurationDisplayName); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // add it
 | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     d->m_deployConfigurations.push_back(dc); | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 13:16:25 +02:00
										 |  |  |     connect(dc, SIGNAL(enabledChanged()), this, SLOT(changeDeployConfigurationEnabled())); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |     emit addedDeployConfiguration(dc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     if (!d->m_activeDeployConfiguration) | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |         setActiveDeployConfiguration(dc); | 
					
						
							|  |  |  |     Q_ASSERT(activeDeployConfiguration()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-24 13:10:38 +00:00
										 |  |  | bool Target::removeDeployConfiguration(DeployConfiguration *dc) | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     //todo: this might be error prone
 | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     if (!d->m_deployConfigurations.contains(dc)) | 
					
						
							| 
									
										
										
										
											2011-10-24 13:10:38 +00:00
										 |  |  |         return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ProjectExplorer::BuildManager *bm = | 
					
						
							|  |  |  |             ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager(); | 
					
						
							|  |  |  |     if (bm->isBuilding(dc)) | 
					
						
							|  |  |  |         return false; | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     d->m_deployConfigurations.removeOne(dc); | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     emit removedDeployConfiguration(dc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (activeDeployConfiguration() == dc) { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |         if (d->m_deployConfigurations.isEmpty()) | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |             setActiveDeployConfiguration(0); | 
					
						
							|  |  |  |         else | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |             setActiveDeployConfiguration(d->m_deployConfigurations.at(0)); | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     delete dc; | 
					
						
							| 
									
										
										
										
											2011-10-24 13:10:38 +00:00
										 |  |  |     return true; | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QList<DeployConfiguration *> Target::deployConfigurations() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     return d->m_deployConfigurations; | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | DeployConfiguration *Target::activeDeployConfiguration() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     return d->m_activeDeployConfiguration; | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::setActiveDeployConfiguration(DeployConfiguration *dc) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     if ((!dc && d->m_deployConfigurations.isEmpty()) || | 
					
						
							|  |  |  |         (dc && d->m_deployConfigurations.contains(dc) && | 
					
						
							|  |  |  |          dc != d->m_activeDeployConfiguration)) { | 
					
						
							|  |  |  |         d->m_activeDeployConfiguration = dc; | 
					
						
							|  |  |  |         emit activeDeployConfigurationChanged(d->m_activeDeployConfiguration); | 
					
						
							| 
									
										
										
										
											2012-03-29 13:16:25 +02:00
										 |  |  |         emit deployConfigurationEnabledChanged(); | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-03-26 11:15:11 +02:00
										 |  |  |     updateDeviceState(); | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-20 12:41:52 +02:00
										 |  |  | void Target::setDeploymentData(const DeploymentData &deploymentData) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     d->m_deploymentData = deploymentData; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | DeploymentData Target::deploymentData() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->m_deploymentData; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::setApplicationTargets(const BuildTargetInfoList &appTargets) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     d->m_appTargets = appTargets; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | BuildTargetInfoList Target::applicationTargets() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->m_appTargets; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | QList<RunConfiguration *> Target::runConfigurations() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     return d->m_runConfigurations; | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::addRunConfiguration(RunConfiguration* runConfiguration) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     QTC_ASSERT(runConfiguration && !d->m_runConfigurations.contains(runConfiguration), return); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     Q_ASSERT(runConfiguration->target() == this); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-18 15:38:42 +02:00
										 |  |  |     // Check that we don't have a configuration with the same displayName
 | 
					
						
							|  |  |  |     QString configurationDisplayName = runConfiguration->displayName(); | 
					
						
							|  |  |  |     QStringList displayNames; | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     foreach (const RunConfiguration *rc, d->m_runConfigurations) | 
					
						
							| 
									
										
										
										
											2010-08-18 15:38:42 +02:00
										 |  |  |         displayNames << rc->displayName(); | 
					
						
							|  |  |  |     configurationDisplayName = Project::makeUnique(configurationDisplayName, displayNames); | 
					
						
							|  |  |  |     runConfiguration->setDisplayName(configurationDisplayName); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     d->m_runConfigurations.push_back(runConfiguration); | 
					
						
							| 
									
										
										
										
											2012-03-29 13:16:25 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     connect(runConfiguration, SIGNAL(enabledChanged()), this, SLOT(changeRunConfigurationEnabled())); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     emit addedRunConfiguration(runConfiguration); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!activeRunConfiguration()) | 
					
						
							|  |  |  |         setActiveRunConfiguration(runConfiguration); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::removeRunConfiguration(RunConfiguration* runConfiguration) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     QTC_ASSERT(runConfiguration && d->m_runConfigurations.contains(runConfiguration), return); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     d->m_runConfigurations.removeOne(runConfiguration); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (activeRunConfiguration() == runConfiguration) { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |         if (d->m_runConfigurations.isEmpty()) | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |             setActiveRunConfiguration(0); | 
					
						
							|  |  |  |         else | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |             setActiveRunConfiguration(d->m_runConfigurations.at(0)); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     emit removedRunConfiguration(runConfiguration); | 
					
						
							|  |  |  |     delete runConfiguration; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | RunConfiguration* Target::activeRunConfiguration() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     return d->m_activeRunConfiguration; | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::setActiveRunConfiguration(RunConfiguration* configuration) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     if ((!configuration && d->m_runConfigurations.isEmpty()) || | 
					
						
							|  |  |  |         (configuration && d->m_runConfigurations.contains(configuration) && | 
					
						
							|  |  |  |          configuration != d->m_activeRunConfiguration)) { | 
					
						
							|  |  |  |         d->m_activeRunConfiguration = configuration; | 
					
						
							|  |  |  |         emit activeRunConfigurationChanged(d->m_activeRunConfiguration); | 
					
						
							| 
									
										
										
										
											2012-03-29 13:16:25 +02:00
										 |  |  |         emit runConfigurationEnabledChanged(); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-03-26 11:15:11 +02:00
										 |  |  |     updateDeviceState(); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Target::isEnabled() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     return d->m_isEnabled; | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QIcon Target::icon() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     return d->m_icon; | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::setIcon(QIcon icon) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     d->m_icon = icon; | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     emit iconChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-23 16:52:03 +01:00
										 |  |  | QIcon Target::overlayIcon() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     return d->m_overlayIcon; | 
					
						
							| 
									
										
										
										
											2010-02-23 16:52:03 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::setOverlayIcon(QIcon icon) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     d->m_overlayIcon = icon; | 
					
						
							| 
									
										
										
										
											2010-02-23 16:52:03 +01:00
										 |  |  |     emit overlayIconChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-09 19:05:15 +01:00
										 |  |  | QString Target::toolTip() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     return d->m_toolTip; | 
					
						
							| 
									
										
										
										
											2010-02-09 19:05:15 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::setToolTip(const QString &text) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     d->m_toolTip = text; | 
					
						
							| 
									
										
										
										
											2010-02-09 19:05:15 +01:00
										 |  |  |     emit toolTipChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | QVariantMap Target::toMap() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-09-04 15:27:10 +02:00
										 |  |  |     if (!d->m_kit) // Kit was deleted, target is only around to be copied.
 | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         return QVariantMap(); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QVariantMap map(ProjectConfiguration::toMap()); | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const QList<BuildConfiguration *> bcs = buildConfigurations(); | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     map.insert(QLatin1String(ACTIVE_BC_KEY), bcs.indexOf(d->m_activeBuildConfiguration)); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     map.insert(QLatin1String(BC_COUNT_KEY), bcs.size()); | 
					
						
							|  |  |  |     for (int i = 0; i < bcs.size(); ++i) | 
					
						
							|  |  |  |         map.insert(QString::fromLatin1(BC_KEY_PREFIX) + QString::number(i), bcs.at(i)->toMap()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |     const QList<DeployConfiguration *> dcs = deployConfigurations(); | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     map.insert(QLatin1String(ACTIVE_DC_KEY), dcs.indexOf(d->m_activeDeployConfiguration)); | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |     map.insert(QLatin1String(DC_COUNT_KEY), dcs.size()); | 
					
						
							|  |  |  |     for (int i = 0; i < dcs.size(); ++i) | 
					
						
							|  |  |  |         map.insert(QString::fromLatin1(DC_KEY_PREFIX) + QString::number(i), dcs.at(i)->toMap()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     const QList<RunConfiguration *> rcs = runConfigurations(); | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     map.insert(QLatin1String(ACTIVE_RC_KEY), rcs.indexOf(d->m_activeRunConfiguration)); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     map.insert(QLatin1String(RC_COUNT_KEY), rcs.size()); | 
					
						
							|  |  |  |     for (int i = 0; i < rcs.size(); ++i) | 
					
						
							|  |  |  |         map.insert(QString::fromLatin1(RC_KEY_PREFIX) + QString::number(i), rcs.at(i)->toMap()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return map; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | void Target::updateDefaultBuildConfigurations() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     IBuildConfigurationFactory *bcFactory = IBuildConfigurationFactory::find(this); | 
					
						
							|  |  |  |     if (!bcFactory) { | 
					
						
							|  |  |  |         qWarning("No build configuration factory found for target id '%s'.", qPrintable(id().toString())); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     QList<Core::Id> bcIds = bcFactory->availableCreationIds(this); | 
					
						
							|  |  |  |     foreach (Core::Id id, bcIds) { | 
					
						
							|  |  |  |         if (!bcFactory->canCreate(this, id)) | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         BuildConfiguration *bc = bcFactory->create(this, id, tr("Default build")); | 
					
						
							|  |  |  |         if (!bc) | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         QTC_CHECK(bc->id() == id); | 
					
						
							|  |  |  |         addBuildConfiguration(bc); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::updateDefaultDeployConfigurations() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     DeployConfigurationFactory *dcFactory = DeployConfigurationFactory::find(this); | 
					
						
							|  |  |  |     if (!dcFactory) { | 
					
						
							|  |  |  |         qWarning("No deployment configuration factory found for target id '%s'.", qPrintable(id().toString())); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     QList<Core::Id> dcIds = dcFactory->availableCreationIds(this); | 
					
						
							|  |  |  |     QList<DeployConfiguration *> dcList = deployConfigurations(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     foreach (DeployConfiguration *dc, dcList) { | 
					
						
							|  |  |  |         if (dcIds.contains(dc->id())) | 
					
						
							|  |  |  |             dcIds.removeOne(dc->id()); | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             removeDeployConfiguration(dc); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     foreach (Core::Id id, dcIds) { | 
					
						
							|  |  |  |         if (!dcFactory->canCreate(this, id)) | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         DeployConfiguration *dc = dcFactory->create(this, id); | 
					
						
							|  |  |  |         if (dc) { | 
					
						
							|  |  |  |             QTC_CHECK(dc->id() == id); | 
					
						
							|  |  |  |             addDeployConfiguration(dc); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::updateDefaultRunConfigurations() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QList<IRunConfigurationFactory *> rcFactories = IRunConfigurationFactory::find(this); | 
					
						
							|  |  |  |     if (rcFactories.isEmpty()) { | 
					
						
							|  |  |  |         qWarning("No run configuration factory found for target id '%s'.", qPrintable(id().toString())); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<RunConfiguration *> existingConfigured; // Existing configured RCs
 | 
					
						
							|  |  |  |     QList<RunConfiguration *> existingUnconfigured; // Existing unconfigured RCs
 | 
					
						
							|  |  |  |     QList<RunConfiguration *> newConfigured; // NEW configured Rcs
 | 
					
						
							|  |  |  |     QList<RunConfiguration *> newUnconfigured; // NEW unconfigured RCs
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // sort existing RCs into configured/unconfigured.
 | 
					
						
							|  |  |  |     foreach (RunConfiguration *rc, runConfigurations()) { | 
					
						
							| 
									
										
										
										
											2012-07-03 14:01:11 +02:00
										 |  |  |         if (!rc->isConfigured() && rc != activeRunConfiguration()) | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |             existingUnconfigured << rc; | 
					
						
							| 
									
										
										
										
											2012-07-03 14:01:11 +02:00
										 |  |  |         else | 
					
						
							|  |  |  |             existingConfigured << rc; | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     int configuredCount = existingConfigured.count(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // find all RC ids that can get created:
 | 
					
						
							|  |  |  |     QList<Core::Id> factoryIds; | 
					
						
							|  |  |  |     foreach (IRunConfigurationFactory *rcFactory, rcFactories) | 
					
						
							|  |  |  |         factoryIds.append(rcFactory->availableCreationIds(this)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Put outdated RCs into toRemove, do not bother with factories
 | 
					
						
							|  |  |  |     // that produce already existing RCs
 | 
					
						
							|  |  |  |     QList<RunConfiguration *> toRemove; | 
					
						
							| 
									
										
										
										
											2012-07-03 14:01:11 +02:00
										 |  |  |     QList<Core::Id> toIgnore; | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |     foreach (RunConfiguration *rc, existingConfigured) { | 
					
						
							|  |  |  |         if (factoryIds.contains(rc->id())) | 
					
						
							| 
									
										
										
										
											2012-07-03 14:01:11 +02:00
										 |  |  |             toIgnore.append(rc->id()); // Already there
 | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         else | 
					
						
							|  |  |  |             toRemove << rc; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-03 14:01:11 +02:00
										 |  |  |     foreach (Core::Id i, toIgnore) | 
					
						
							|  |  |  |         factoryIds.removeAll(i); | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |     configuredCount -= toRemove.count(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Create new RCs and put them into newConfigured/newUnconfigured
 | 
					
						
							|  |  |  |     foreach (Core::Id id, factoryIds) { | 
					
						
							|  |  |  |         IRunConfigurationFactory *factory = 0; | 
					
						
							|  |  |  |         foreach (IRunConfigurationFactory *i, rcFactories) { | 
					
						
							|  |  |  |             if (i->canCreate(this, id)) { | 
					
						
							|  |  |  |                 factory = i; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!factory) | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         RunConfiguration *rc = factory->create(this, id); | 
					
						
							|  |  |  |         if (!rc) | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         QTC_CHECK(rc->id() == id); | 
					
						
							|  |  |  |         if (!rc->isConfigured()) | 
					
						
							|  |  |  |             newUnconfigured << rc; | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             newConfigured << rc; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     configuredCount += newConfigured.count(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Decide what to do with the different categories:
 | 
					
						
							|  |  |  |     bool removeExistingUnconfigured = false; | 
					
						
							|  |  |  |     if (configuredCount > 0) { | 
					
						
							|  |  |  |         // new non-Custom Executable RCs were added
 | 
					
						
							|  |  |  |         removeExistingUnconfigured = true; | 
					
						
							|  |  |  |         qDeleteAll(newUnconfigured); | 
					
						
							|  |  |  |         newUnconfigured.clear(); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         // no new RCs, use old or new CERCs?
 | 
					
						
							|  |  |  |         if (!existingUnconfigured.isEmpty()) { | 
					
						
							|  |  |  |             qDeleteAll(newUnconfigured); | 
					
						
							|  |  |  |             newUnconfigured.clear(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Do actual changes:
 | 
					
						
							|  |  |  |     foreach (RunConfiguration *rc, toRemove) | 
					
						
							|  |  |  |         removeRunConfiguration(rc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (removeExistingUnconfigured) { | 
					
						
							|  |  |  |         foreach (RunConfiguration *rc, existingUnconfigured) | 
					
						
							|  |  |  |             removeRunConfiguration(rc); | 
					
						
							|  |  |  |         existingUnconfigured.clear(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     foreach (RunConfiguration *rc, newConfigured) | 
					
						
							|  |  |  |         addRunConfiguration(rc); | 
					
						
							|  |  |  |     foreach (RunConfiguration *rc, newUnconfigured) | 
					
						
							|  |  |  |         addRunConfiguration(rc); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-26 11:15:11 +02:00
										 |  |  | static QString formatToolTip(const IDevice::DeviceInfo &input) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QStringList lines; | 
					
						
							|  |  |  |     foreach (const IDevice::DeviceInfoItem &item, input) | 
					
						
							|  |  |  |         lines << QString::fromLatin1("<b>%1:</b> %2").arg(item.key, item.value); | 
					
						
							|  |  |  |     return lines.join(QLatin1String("<br>")); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Target::updateDeviceState() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-09-03 18:31:44 +02:00
										 |  |  |     IDevice::ConstPtr current = DeviceKitInformation::device(kit()); | 
					
						
							| 
									
										
										
										
											2012-03-26 11:15:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QPixmap overlay; | 
					
						
							| 
									
										
										
										
											2012-04-27 15:58:59 +02:00
										 |  |  |     if (current.isNull()) { | 
					
						
							| 
									
										
										
										
											2012-03-26 11:15:11 +02:00
										 |  |  |         overlay = d->m_disconnectedPixmap; | 
					
						
							| 
									
										
										
										
											2012-04-27 15:58:59 +02:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2012-05-29 13:49:34 +02:00
										 |  |  |         switch (current->deviceState()) { | 
					
						
							|  |  |  |         case IDevice::DeviceStateUnknown: | 
					
						
							| 
									
										
										
										
											2012-04-27 15:58:59 +02:00
										 |  |  |             setOverlayIcon(QIcon()); | 
					
						
							|  |  |  |             setToolTip(QString()); | 
					
						
							|  |  |  |             return; | 
					
						
							| 
									
										
										
										
											2012-05-29 13:49:34 +02:00
										 |  |  |         case IDevice::DeviceReadyToUse: | 
					
						
							|  |  |  |             overlay = d->m_readyToUsePixmap; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case IDevice::DeviceConnected: | 
					
						
							| 
									
										
										
										
											2012-04-27 15:58:59 +02:00
										 |  |  |             overlay = d->m_connectedPixmap; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2012-05-29 13:49:34 +02:00
										 |  |  |         case IDevice::DeviceDisconnected: | 
					
						
							| 
									
										
										
										
											2012-04-27 15:58:59 +02:00
										 |  |  |             overlay = d->m_disconnectedPixmap; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     static const int TARGET_OVERLAY_ORIGINAL_SIZE = 32; | 
					
						
							| 
									
										
										
										
											2012-03-26 11:15:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     double factor = Core::Constants::TARGET_ICON_SIZE / (double)TARGET_OVERLAY_ORIGINAL_SIZE; | 
					
						
							|  |  |  |     QSize overlaySize(overlay.size().width()*factor, overlay.size().height()*factor); | 
					
						
							|  |  |  |     QPixmap pixmap(Core::Constants::TARGET_ICON_SIZE, Core::Constants::TARGET_ICON_SIZE); | 
					
						
							|  |  |  |     pixmap.fill(Qt::transparent); | 
					
						
							|  |  |  |     QPainter painter(&pixmap); | 
					
						
							|  |  |  |     painter.drawPixmap(Core::Constants::TARGET_ICON_SIZE - overlaySize.width(), | 
					
						
							|  |  |  |                        Core::Constants::TARGET_ICON_SIZE - overlaySize.height(), | 
					
						
							|  |  |  |                        overlay.scaled(overlaySize)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setOverlayIcon(QIcon(pixmap)); | 
					
						
							| 
									
										
										
										
											2012-04-27 15:58:59 +02:00
										 |  |  |     setToolTip(current.isNull() ? QString() : formatToolTip(current->deviceInformation())); | 
					
						
							| 
									
										
										
										
											2012-03-26 11:15:11 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | void Target::setEnabled(bool enabled) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     if (enabled == d->m_isEnabled) | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  |     d->m_isEnabled = enabled; | 
					
						
							|  |  |  |     emit targetEnabled(d->m_isEnabled); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Target::fromMap(const QVariantMap &map) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!ProjectConfiguration::fromMap(map)) | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-04 15:27:10 +02:00
										 |  |  |     d->m_kit = KitManager::instance()->find(id()); | 
					
						
							|  |  |  |     if (!d->m_kit) | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         return false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     bool ok; | 
					
						
							| 
									
										
										
										
											2011-04-21 15:01:48 +02:00
										 |  |  |     int bcCount = map.value(QLatin1String(BC_COUNT_KEY), 0).toInt(&ok); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     if (!ok || bcCount < 0) | 
					
						
							|  |  |  |         bcCount = 0; | 
					
						
							| 
									
										
										
										
											2011-04-21 15:01:48 +02:00
										 |  |  |     int activeConfiguration = map.value(QLatin1String(ACTIVE_BC_KEY), 0).toInt(&ok); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     if (!ok || activeConfiguration < 0) | 
					
						
							|  |  |  |         activeConfiguration = 0; | 
					
						
							|  |  |  |     if (0 > activeConfiguration || bcCount < activeConfiguration) | 
					
						
							|  |  |  |         activeConfiguration = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; i < bcCount; ++i) { | 
					
						
							| 
									
										
										
										
											2011-04-21 15:01:48 +02:00
										 |  |  |         const QString key = QString::fromLatin1(BC_KEY_PREFIX) + QString::number(i); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |         if (!map.contains(key)) | 
					
						
							|  |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         const QVariantMap valueMap = map.value(key).toMap(); | 
					
						
							|  |  |  |         IBuildConfigurationFactory *factory = IBuildConfigurationFactory::find(this, valueMap); | 
					
						
							|  |  |  |         if (!factory) { | 
					
						
							|  |  |  |             qWarning("No factory found to restore build configuration!"); | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         BuildConfiguration *bc = factory->restore(this, valueMap); | 
					
						
							|  |  |  |         if (!bc) { | 
					
						
							|  |  |  |             qWarning("Failed '%s' to restore build configuration!", qPrintable(factory->objectName())); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |             continue; | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |         QTC_CHECK(bc->id() == ProjectExplorer::idFromMap(valueMap)); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |         addBuildConfiguration(bc); | 
					
						
							|  |  |  |         if (i == activeConfiguration) | 
					
						
							|  |  |  |             setActiveBuildConfiguration(bc); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |     if (buildConfigurations().isEmpty() && IBuildConfigurationFactory::find(this)) | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |         return false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-21 15:01:48 +02:00
										 |  |  |     int dcCount = map.value(QLatin1String(DC_COUNT_KEY), 0).toInt(&ok); | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |     if (!ok || dcCount < 0) | 
					
						
							|  |  |  |         dcCount = 0; | 
					
						
							|  |  |  |     activeConfiguration = map.value(QLatin1String(ACTIVE_DC_KEY), 0).toInt(&ok); | 
					
						
							|  |  |  |     if (!ok || activeConfiguration < 0) | 
					
						
							|  |  |  |         activeConfiguration = 0; | 
					
						
							|  |  |  |     if (0 > activeConfiguration || dcCount < activeConfiguration) | 
					
						
							|  |  |  |         activeConfiguration = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; i < dcCount; ++i) { | 
					
						
							| 
									
										
										
										
											2011-04-21 15:01:48 +02:00
										 |  |  |         const QString key = QString::fromLatin1(DC_KEY_PREFIX) + QString::number(i); | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |         if (!map.contains(key)) | 
					
						
							|  |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         QVariantMap valueMap = map.value(key).toMap(); | 
					
						
							|  |  |  |         DeployConfigurationFactory *factory = DeployConfigurationFactory::find(this, valueMap); | 
					
						
							|  |  |  |         if (!factory) { | 
					
						
							| 
									
										
										
										
											2012-06-20 15:44:44 +02:00
										 |  |  |             Core::Id id = idFromMap(valueMap); | 
					
						
							|  |  |  |             qWarning("No factory found to restore deployment configuration of id '%s'!", | 
					
						
							|  |  |  |                      qPrintable(id.isValid() ? id.toString() : "UNKNOWN")); | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |             continue; | 
					
						
							| 
									
										
										
										
											2011-03-09 12:07:35 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         DeployConfiguration *dc = factory->restore(this, valueMap); | 
					
						
							|  |  |  |         if (!dc) { | 
					
						
							|  |  |  |             qWarning("Factory '%s' failed to restore deployment configuration!", qPrintable(factory->objectName())); | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |             continue; | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |         QTC_CHECK(dc->id() == ProjectExplorer::idFromMap(valueMap)); | 
					
						
							| 
									
										
										
										
											2010-07-16 14:00:41 +02:00
										 |  |  |         addDeployConfiguration(dc); | 
					
						
							|  |  |  |         if (i == activeConfiguration) | 
					
						
							|  |  |  |             setActiveDeployConfiguration(dc); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-21 15:01:48 +02:00
										 |  |  |     int rcCount = map.value(QLatin1String(RC_COUNT_KEY), 0).toInt(&ok); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |     if (!ok || rcCount < 0) | 
					
						
							|  |  |  |         rcCount = 0; | 
					
						
							|  |  |  |     activeConfiguration = map.value(QLatin1String(ACTIVE_RC_KEY), 0).toInt(&ok); | 
					
						
							|  |  |  |     if (!ok || activeConfiguration < 0) | 
					
						
							|  |  |  |         activeConfiguration = 0; | 
					
						
							|  |  |  |     if (0 > activeConfiguration || rcCount < activeConfiguration) | 
					
						
							|  |  |  |         activeConfiguration = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; i < rcCount; ++i) { | 
					
						
							| 
									
										
										
										
											2011-04-21 15:01:48 +02:00
										 |  |  |         const QString key = QString::fromLatin1(RC_KEY_PREFIX) + QString::number(i); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |         if (!map.contains(key)) | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         // Ignore missing RCs: We will just populate them using the default ones.
 | 
					
						
							| 
									
										
										
										
											2011-04-21 15:01:48 +02:00
										 |  |  |         QVariantMap valueMap = map.value(key).toMap(); | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         IRunConfigurationFactory *factory = IRunConfigurationFactory::find(this, valueMap); | 
					
						
							| 
									
										
										
										
											2012-06-20 15:44:44 +02:00
										 |  |  |         if (!factory) | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |             continue; | 
					
						
							| 
									
										
										
										
											2011-04-21 15:01:48 +02:00
										 |  |  |         RunConfiguration *rc = factory->restore(this, valueMap); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |         if (!rc) | 
					
						
							|  |  |  |             continue; | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  |         QTC_CHECK(rc->id() == ProjectExplorer::idFromMap(valueMap)); | 
					
						
							| 
									
										
										
										
											2010-02-08 15:50:06 +01:00
										 |  |  |         addRunConfiguration(rc); | 
					
						
							|  |  |  |         if (i == activeConfiguration) | 
					
						
							|  |  |  |             setActiveRunConfiguration(rc); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 09:17:37 +02:00
										 |  |  | } // namespace ProjectExplorer
 |