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);
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
virtual QList<BuildInfo *> import(const Utils::FileName &importPath, bool silent = false) = 0;
|
||||
virtual QStringList importCandidates() = 0;
|
||||
virtual Target *preferredTarget(const QList<Target *> &possibleTargets) = 0;
|
||||
virtual Target *preferredTarget(const QList<Target *> &possibleTargets);
|
||||
|
||||
bool isUpdating() const { return m_isUpdating; }
|
||||
|
||||
|
||||
@@ -33,9 +33,7 @@
|
||||
#include "qmakestep.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/toolchainmanager.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
@@ -249,28 +247,6 @@ QStringList QmakeProjectImporter::importCandidates()
|
||||
return candidates;
|
||||
}
|
||||
|
||||
Target *QmakeProjectImporter::preferredTarget(const QList<Target *> &possibleTargets)
|
||||
{
|
||||
// Select active target
|
||||
// a) The default target
|
||||
// b) Simulator target
|
||||
// c) Desktop target
|
||||
// d) the first target
|
||||
Target *activeTarget = possibleTargets.isEmpty() ? 0 : possibleTargets.at(0);
|
||||
int activeTargetPriority = 0;
|
||||
foreach (Target *t, possibleTargets) {
|
||||
BaseQtVersion *version = QtKitInformation::qtVersion(t->kit());
|
||||
if (t->kit() == KitManager::defaultKit()) {
|
||||
activeTarget = t;
|
||||
activeTargetPriority = 3;
|
||||
} else if (activeTargetPriority < 1 && version && version->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)) {
|
||||
activeTarget = t;
|
||||
activeTargetPriority = 1;
|
||||
}
|
||||
}
|
||||
return activeTarget;
|
||||
}
|
||||
|
||||
static ToolChain *preferredToolChain(BaseQtVersion *qtVersion, const FileName &ms, const QMakeStepConfig::TargetArchConfig &archConfig)
|
||||
{
|
||||
const FileName spec = ms.isEmpty() ? qtVersion->mkspec() : ms;
|
||||
|
||||
@@ -45,7 +45,6 @@ public:
|
||||
|
||||
QList<ProjectExplorer::BuildInfo *> import(const Utils::FileName &importPath, bool silent = false) final;
|
||||
QStringList importCandidates() final;
|
||||
ProjectExplorer::Target *preferredTarget(const QList<ProjectExplorer::Target *> &possibleTargets) final;
|
||||
|
||||
private:
|
||||
ProjectExplorer::Kit *createTemporaryKit(const QtProjectImporter::QtVersionData &data,
|
||||
|
||||
Reference in New Issue
Block a user