aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/projectimporter.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2016-08-24 16:53:47 +0200
committerTobias Hunger <tobias.hunger@qt.io>2016-09-15 07:55:38 +0000
commitffedf95ef570cb9dfec364da1fd90d4e096fc16f (patch)
treee1a0a175b29851d724565e28af6b365bd289d8a0 /src/plugins/projectexplorer/projectimporter.cpp
parent6281d7c4c94c7dfb54626045e7d4727835f8a177 (diff)
ProjectImporter: Move logic to select preferred target into base class
That way the code can be reused in other importers later. Change-Id: I6318f9c959b73b2af2692408b918eb1fab715137 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/projectimporter.cpp')
-rw-r--r--src/plugins/projectexplorer/projectimporter.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/projectimporter.cpp b/src/plugins/projectexplorer/projectimporter.cpp
index 760db32763e..6aba0c1a82d 100644
--- a/src/plugins/projectexplorer/projectimporter.cpp
+++ b/src/plugins/projectexplorer/projectimporter.cpp
@@ -26,8 +26,11 @@
#include "projectimporter.h"
#include "kit.h"
+#include "kitinformation.h"
#include "kitmanager.h"
#include "project.h"
+#include "projectexplorerconstants.h"
+#include "target.h"
#include <coreplugin/idocument.h>
@@ -49,6 +52,31 @@ ProjectImporter::~ProjectImporter()
removeProject(k);
}
+Target *ProjectImporter::preferredTarget(const QList<Target *> &possibleTargets)
+{
+ // Select active target
+ // a) The default target
+ // c) Desktop target
+ // d) the first target
+ Target *activeTarget = nullptr;
+ if (possibleTargets.isEmpty())
+ return activeTarget;
+
+ activeTarget = possibleTargets.at(0);
+ bool pickedFallback = false;
+ foreach (Target *t, possibleTargets) {
+ if (t->kit() == KitManager::defaultKit())
+ return t;
+ if (pickedFallback)
+ continue;
+ if (DeviceTypeKitInformation::deviceTypeId(t->kit()) == Constants::DESKTOP_DEVICE_TYPE) {
+ activeTarget = t;
+ pickedFallback = true;
+ }
+ }
+ return activeTarget;
+}
+
void ProjectImporter::markTemporary(Kit *k)
{
QTC_ASSERT(!k->hasValue(KIT_IS_TEMPORARY), return);