forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user