2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "qtkitinformation.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2017-03-09 23:02:32 +01:00
|
|
|
#include <QRegExp>
|
|
|
|
|
|
2012-09-25 10:47:35 +02:00
|
|
|
#include "qtsupportconstants.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "qtversionmanager.h"
|
2012-11-02 12:45:09 +01:00
|
|
|
#include "qtparser.h"
|
2019-03-06 17:58:28 +01:00
|
|
|
#include "qttestparser.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2019-02-06 15:04:17 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2015-11-27 14:02:44 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/task.h>
|
2014-10-30 15:51:47 +01:00
|
|
|
#include <utils/algorithm.h>
|
2013-07-29 17:04:28 +02:00
|
|
|
#include <utils/buildablehelperlibrary.h>
|
2014-10-13 12:49:05 +02:00
|
|
|
#include <utils/macroexpander.h>
|
2013-02-28 15:30:35 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2019-02-06 15:04:17 +01:00
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
|
2014-07-23 09:09:20 +02:00
|
|
|
using namespace ProjectExplorer;
|
2014-10-10 14:15:57 +02:00
|
|
|
using namespace Utils;
|
2014-07-23 09:09:20 +02:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
namespace QtSupport {
|
2019-02-06 15:04:17 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class QtKitAspectWidget : public KitAspectWidget
|
|
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(QtSupport::QtKitAspectWidget)
|
|
|
|
|
public:
|
|
|
|
|
QtKitAspectWidget(Kit *k, const KitAspect *ki) : KitAspectWidget(k, ki)
|
|
|
|
|
{
|
|
|
|
|
m_combo = new QComboBox;
|
|
|
|
|
m_combo->setSizePolicy(QSizePolicy::Ignored, m_combo->sizePolicy().verticalPolicy());
|
|
|
|
|
m_combo->addItem(tr("None"), -1);
|
|
|
|
|
|
|
|
|
|
QList<int> versionIds = Utils::transform(QtVersionManager::versions(), &BaseQtVersion::uniqueId);
|
|
|
|
|
versionsChanged(versionIds, QList<int>(), QList<int>());
|
|
|
|
|
|
|
|
|
|
m_manageButton = new QPushButton(KitAspectWidget::msgManage());
|
|
|
|
|
|
|
|
|
|
refresh();
|
2019-02-11 17:10:03 +01:00
|
|
|
m_combo->setToolTip(ki->description());
|
2019-02-06 15:04:17 +01:00
|
|
|
|
2019-02-26 09:40:49 +01:00
|
|
|
connect(m_combo, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
2019-02-06 15:04:17 +01:00
|
|
|
this, &QtKitAspectWidget::currentWasChanged);
|
|
|
|
|
|
|
|
|
|
connect(QtVersionManager::instance(), &QtVersionManager::qtVersionsChanged,
|
|
|
|
|
this, &QtKitAspectWidget::versionsChanged);
|
|
|
|
|
|
|
|
|
|
connect(m_manageButton, &QAbstractButton::clicked, this, &QtKitAspectWidget::manageQtVersions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~QtKitAspectWidget() override
|
|
|
|
|
{
|
|
|
|
|
delete m_combo;
|
|
|
|
|
delete m_manageButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void makeReadOnly() override { m_combo->setEnabled(false); }
|
|
|
|
|
QWidget *mainWidget() const override { return m_combo; }
|
|
|
|
|
QWidget *buttonWidget() const override { return m_manageButton; }
|
|
|
|
|
|
|
|
|
|
void refresh() override
|
|
|
|
|
{
|
|
|
|
|
m_combo->setCurrentIndex(findQtVersion(QtKitAspect::qtVersionId(m_kit)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
static QString itemNameFor(const BaseQtVersion *v)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(v, return QString());
|
|
|
|
|
QString name = v->displayName();
|
|
|
|
|
if (!v->isValid())
|
|
|
|
|
name = QCoreApplication::translate("QtSupport::Internal::QtKitConfigWidget", "%1 (invalid)").arg(v->displayName());
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void versionsChanged(const QList<int> &added, const QList<int> &removed, const QList<int> &changed)
|
|
|
|
|
{
|
|
|
|
|
foreach (const int id, added) {
|
|
|
|
|
BaseQtVersion *v = QtVersionManager::version(id);
|
|
|
|
|
QTC_CHECK(v);
|
|
|
|
|
QTC_CHECK(findQtVersion(id) < 0);
|
|
|
|
|
m_combo->addItem(itemNameFor(v), id);
|
|
|
|
|
}
|
|
|
|
|
foreach (const int id, removed) {
|
|
|
|
|
int pos = findQtVersion(id);
|
|
|
|
|
if (pos >= 0) // We do not include invalid Qt versions, so do not try to remove those.
|
|
|
|
|
m_combo->removeItem(pos);
|
|
|
|
|
}
|
|
|
|
|
foreach (const int id, changed) {
|
|
|
|
|
BaseQtVersion *v = QtVersionManager::version(id);
|
|
|
|
|
int pos = findQtVersion(id);
|
|
|
|
|
QTC_CHECK(pos >= 0);
|
|
|
|
|
m_combo->setItemText(pos, itemNameFor(v));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void manageQtVersions()
|
|
|
|
|
{
|
|
|
|
|
Core::ICore::showOptionsDialog(Constants::QTVERSION_SETTINGS_PAGE_ID, buttonWidget());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void currentWasChanged(int idx)
|
|
|
|
|
{
|
|
|
|
|
QtKitAspect::setQtVersionId(m_kit, m_combo->itemData(idx).toInt());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int findQtVersion(const int id) const
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < m_combo->count(); ++i) {
|
|
|
|
|
if (id == m_combo->itemData(i).toInt())
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QComboBox *m_combo;
|
|
|
|
|
QPushButton *m_manageButton;
|
|
|
|
|
};
|
|
|
|
|
} // namespace Internal
|
2014-07-09 15:31:09 +02:00
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QtKitAspect::QtKitAspect()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2019-02-06 12:50:51 +01:00
|
|
|
setObjectName(QLatin1String("QtKitAspect"));
|
|
|
|
|
setId(QtKitAspect::id());
|
2019-02-06 16:16:07 +01:00
|
|
|
setDisplayName(tr("Qt version"));
|
|
|
|
|
setDescription(tr("The Qt library to use for all projects using this kit.<br>"
|
|
|
|
|
"A Qt version is required for qmake-based projects "
|
|
|
|
|
"and optional when using other build systems."));
|
2013-08-28 18:57:25 +02:00
|
|
|
setPriority(26000);
|
|
|
|
|
|
2015-11-27 14:02:44 +01:00
|
|
|
connect(KitManager::instance(), &KitManager::kitsLoaded,
|
2019-02-06 12:50:51 +01:00
|
|
|
this, &QtKitAspect::kitsWereLoaded);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-12 16:50:39 +01:00
|
|
|
void QtKitAspect::setup(ProjectExplorer::Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2019-05-06 14:55:34 +02:00
|
|
|
if (!k || k->hasValue(id()))
|
|
|
|
|
return;
|
2019-03-14 18:07:56 +01:00
|
|
|
const Abi tcAbi = ToolChainKitAspect::targetAbi(k);
|
|
|
|
|
const Core::Id deviceType = DeviceTypeKitAspect::deviceTypeId(k);
|
|
|
|
|
|
|
|
|
|
const QList<BaseQtVersion *> matches
|
|
|
|
|
= QtVersionManager::versions([&tcAbi, &deviceType](const BaseQtVersion *qt) {
|
|
|
|
|
return qt->targetDeviceTypes().contains(deviceType)
|
|
|
|
|
&& Utils::contains(qt->qtAbis(), [&tcAbi](const Abi &qtAbi) {
|
|
|
|
|
return qtAbi.isCompatibleWith(tcAbi); });
|
|
|
|
|
});
|
|
|
|
|
if (matches.empty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// An MSVC 2015 toolchain is compatible with an MSVC 2017 Qt, but we prefer an
|
|
|
|
|
// MSVC 2015 Qt if we find one.
|
|
|
|
|
const QList<BaseQtVersion *> exactMatches = Utils::filtered(matches,
|
|
|
|
|
[&tcAbi](const BaseQtVersion *qt) {
|
|
|
|
|
return qt->qtAbis().contains(tcAbi);
|
|
|
|
|
});
|
|
|
|
|
const QList<BaseQtVersion *> &candidates = !exactMatches.empty() ? exactMatches : matches;
|
|
|
|
|
|
|
|
|
|
BaseQtVersion * const qtFromPath = QtVersionManager::version(
|
|
|
|
|
equal(&BaseQtVersion::autodetectionSource, QString::fromLatin1("PATH")));
|
|
|
|
|
if (qtFromPath && candidates.contains(qtFromPath))
|
|
|
|
|
k->setValue(id(), qtFromPath->uniqueId());
|
|
|
|
|
else
|
|
|
|
|
k->setValue(id(), candidates.first()->uniqueId());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:09:44 +02:00
|
|
|
Tasks QtKitAspect::validate(const ProjectExplorer::Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2015-11-27 14:02:44 +01:00
|
|
|
QTC_ASSERT(QtVersionManager::isLoaded(), return { });
|
2012-10-11 13:47:23 +02:00
|
|
|
BaseQtVersion *version = qtVersion(k);
|
|
|
|
|
if (!version)
|
2015-11-27 14:02:44 +01:00
|
|
|
return { };
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
return version->validateKit(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void QtKitAspect::fix(ProjectExplorer::Kit *k)
|
2012-10-11 13:47:23 +02:00
|
|
|
{
|
2013-08-29 14:11:29 +02:00
|
|
|
QTC_ASSERT(QtVersionManager::isLoaded(), return);
|
2012-10-11 13:47:23 +02:00
|
|
|
BaseQtVersion *version = qtVersion(k);
|
2013-04-04 10:34:18 +02:00
|
|
|
if (!version && qtVersionId(k) >= 0) {
|
2013-02-28 17:06:36 +01:00
|
|
|
qWarning("Qt version is no longer known, removing from kit \"%s\".", qPrintable(k->displayName()));
|
2012-10-11 13:47:23 +02:00
|
|
|
setQtVersionId(k, -1);
|
2013-02-28 17:06:36 +01:00
|
|
|
}
|
2012-10-11 13:47:23 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
ProjectExplorer::KitAspectWidget *QtKitAspect::createConfigWidget(ProjectExplorer::Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2018-02-12 12:49:22 +01:00
|
|
|
QTC_ASSERT(k, return nullptr);
|
2019-02-06 12:50:51 +01:00
|
|
|
return new Internal::QtKitAspectWidget(k, this);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QString QtKitAspect::displayNamePostfix(const ProjectExplorer::Kit *k) const
|
2012-08-07 13:09:56 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
BaseQtVersion *version = qtVersion(k);
|
2012-08-07 13:09:56 +02:00
|
|
|
return version ? version->displayName() : QString();
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
ProjectExplorer::KitAspect::ItemList
|
|
|
|
|
QtKitAspect::toUserOutput(const ProjectExplorer::Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
BaseQtVersion *version = qtVersion(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
return ItemList() << qMakePair(tr("Qt version"), version ? version->displayName() : tr("None"));
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void QtKitAspect::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
BaseQtVersion *version = qtVersion(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
if (version)
|
2012-09-09 20:41:30 +03:00
|
|
|
version->addToEnvironment(k, env);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
ProjectExplorer::IOutputParser *QtKitAspect::createOutputParser(const ProjectExplorer::Kit *k) const
|
2012-11-02 12:45:09 +01:00
|
|
|
{
|
2019-03-06 17:58:28 +01:00
|
|
|
if (qtVersion(k)) {
|
|
|
|
|
const auto parser = new Internal::QtTestParser;
|
|
|
|
|
parser->appendOutputParser(new QtParser);
|
|
|
|
|
return parser;
|
|
|
|
|
}
|
2018-02-12 12:49:22 +01:00
|
|
|
return nullptr;
|
2012-11-02 12:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
2018-03-02 15:44:50 +01:00
|
|
|
class QtMacroSubProvider
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QtMacroSubProvider(Kit *kit)
|
|
|
|
|
: expander(BaseQtVersion::createMacroExpander(
|
2019-02-06 12:50:51 +01:00
|
|
|
[kit] { return QtKitAspect::qtVersion(kit); }))
|
2018-03-02 15:44:50 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
MacroExpander *operator()() const
|
|
|
|
|
{
|
|
|
|
|
return expander.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<MacroExpander> expander;
|
|
|
|
|
};
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void QtKitAspect::addToMacroExpander(Kit *kit, MacroExpander *expander) const
|
2014-07-09 15:31:09 +02:00
|
|
|
{
|
2018-02-12 12:49:22 +01:00
|
|
|
QTC_ASSERT(kit, return);
|
2018-03-02 15:44:50 +01:00
|
|
|
expander->registerSubProvider(QtMacroSubProvider(kit));
|
2014-10-20 23:13:13 +02:00
|
|
|
|
2014-10-22 14:25:15 +02:00
|
|
|
expander->registerVariable("Qt:Name", tr("Name of Qt Version"),
|
2017-09-07 17:05:47 +02:00
|
|
|
[kit]() -> QString {
|
2014-10-20 23:13:13 +02:00
|
|
|
BaseQtVersion *version = qtVersion(kit);
|
|
|
|
|
return version ? version->displayName() : tr("unknown");
|
|
|
|
|
});
|
2016-03-16 11:56:06 +01:00
|
|
|
expander->registerVariable("Qt:qmakeExecutable", tr("Path to the qmake executable"),
|
2017-09-07 17:05:47 +02:00
|
|
|
[kit]() -> QString {
|
2016-03-16 11:56:06 +01:00
|
|
|
BaseQtVersion *version = qtVersion(kit);
|
|
|
|
|
return version ? version->qmakeCommand().toString() : QString();
|
|
|
|
|
});
|
2014-07-09 15:31:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
Core::Id QtKitAspect::id()
|
2013-09-09 17:10:41 +02:00
|
|
|
{
|
|
|
|
|
return "QtSupport.QtInformation";
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
int QtKitAspect::qtVersionId(const ProjectExplorer::Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
if (!k)
|
2012-04-24 15:49:09 +02:00
|
|
|
return -1;
|
2012-09-18 15:47:08 +02:00
|
|
|
|
|
|
|
|
int id = -1;
|
2019-02-06 12:50:51 +01:00
|
|
|
QVariant data = k->value(QtKitAspect::id(), -1);
|
2012-09-18 15:47:08 +02:00
|
|
|
if (data.type() == QVariant::Int) {
|
|
|
|
|
bool ok;
|
|
|
|
|
id = data.toInt(&ok);
|
|
|
|
|
if (!ok)
|
|
|
|
|
id = -1;
|
|
|
|
|
} else {
|
|
|
|
|
QString source = data.toString();
|
2017-01-11 14:43:48 +01:00
|
|
|
BaseQtVersion *v = QtVersionManager::version([source](const BaseQtVersion *v) { return v->autodetectionSource() == source; });
|
|
|
|
|
if (v)
|
2012-09-18 15:47:08 +02:00
|
|
|
id = v->uniqueId();
|
|
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void QtKitAspect::setQtVersionId(ProjectExplorer::Kit *k, const int id)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2018-02-12 12:49:22 +01:00
|
|
|
QTC_ASSERT(k, return);
|
2019-02-06 12:50:51 +01:00
|
|
|
k->setValue(QtKitAspect::id(), id);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
BaseQtVersion *QtKitAspect::qtVersion(const ProjectExplorer::Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-08-29 14:11:29 +02:00
|
|
|
return QtVersionManager::version(qtVersionId(k));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void QtKitAspect::setQtVersion(ProjectExplorer::Kit *k, const BaseQtVersion *v)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
if (!v)
|
2012-09-09 20:41:30 +03:00
|
|
|
setQtVersionId(k, -1);
|
2012-04-24 15:49:09 +02:00
|
|
|
else
|
2012-09-09 20:41:30 +03:00
|
|
|
setQtVersionId(k, v->uniqueId());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void QtKitAspect::qtVersionsChanged(const QList<int> &addedIds,
|
2012-10-17 17:27:17 +02:00
|
|
|
const QList<int> &removedIds,
|
|
|
|
|
const QList<int> &changedIds)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(addedIds);
|
|
|
|
|
Q_UNUSED(removedIds);
|
2013-09-25 11:53:29 +02:00
|
|
|
foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::kits()) {
|
|
|
|
|
if (changedIds.contains(qtVersionId(k))) {
|
|
|
|
|
k->validate(); // Qt version may have become (in)valid
|
2012-10-17 17:27:17 +02:00
|
|
|
notifyAboutUpdate(k);
|
2013-09-25 11:53:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
2012-10-17 17:27:17 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void QtKitAspect::kitsWereLoaded()
|
2013-02-28 15:30:35 +01:00
|
|
|
{
|
2013-08-21 12:48:46 +02:00
|
|
|
foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::kits())
|
2013-02-28 15:30:35 +01:00
|
|
|
fix(k);
|
|
|
|
|
|
2016-06-05 22:22:11 +03:00
|
|
|
connect(QtVersionManager::instance(), &QtVersionManager::qtVersionsChanged,
|
2019-02-06 12:50:51 +01:00
|
|
|
this, &QtKitAspect::qtVersionsChanged);
|
2013-02-28 15:30:35 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
Kit::Predicate QtKitAspect::platformPredicate(Core::Id platform)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2017-01-11 17:25:58 +01:00
|
|
|
return [platform](const Kit *kit) -> bool {
|
2019-02-06 12:50:51 +01:00
|
|
|
BaseQtVersion *version = QtKitAspect::qtVersion(kit);
|
2015-11-27 16:14:14 +01:00
|
|
|
return version && version->targetDeviceTypes().contains(platform);
|
2017-01-11 17:25:58 +01:00
|
|
|
};
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
Kit::Predicate QtKitAspect::qtVersionPredicate(const QSet<Core::Id> &required,
|
2017-01-11 17:25:58 +01:00
|
|
|
const QtVersionNumber &min,
|
|
|
|
|
const QtVersionNumber &max)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2017-01-11 17:25:58 +01:00
|
|
|
return [required, min, max](const Kit *kit) -> bool {
|
2019-02-06 12:50:51 +01:00
|
|
|
BaseQtVersion *version = QtKitAspect::qtVersion(kit);
|
2014-07-23 09:09:20 +02:00
|
|
|
if (!version)
|
|
|
|
|
return false;
|
|
|
|
|
QtVersionNumber current = version->qtVersion();
|
|
|
|
|
if (min.majorVersion > -1 && current < min)
|
|
|
|
|
return false;
|
|
|
|
|
if (max.majorVersion > -1 && current > max)
|
|
|
|
|
return false;
|
2018-01-15 13:58:46 +01:00
|
|
|
return version->features().contains(required);
|
2017-01-11 17:25:58 +01:00
|
|
|
};
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QSet<Core::Id> QtKitAspect::supportedPlatforms(const Kit *k) const
|
2014-07-29 15:15:27 +02:00
|
|
|
{
|
2019-02-06 12:50:51 +01:00
|
|
|
BaseQtVersion *version = QtKitAspect::qtVersion(k);
|
2015-11-27 16:14:14 +01:00
|
|
|
return version ? version->targetDeviceTypes() : QSet<Core::Id>();
|
2014-07-29 15:15:27 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QSet<Core::Id> QtKitAspect::availableFeatures(const Kit *k) const
|
2014-07-29 15:15:27 +02:00
|
|
|
{
|
2019-02-06 12:50:51 +01:00
|
|
|
BaseQtVersion *version = QtKitAspect::qtVersion(k);
|
2018-01-15 13:58:46 +01:00
|
|
|
return version ? version->features() : QSet<Core::Id>();
|
2014-07-29 15:15:27 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-14 18:07:56 +01:00
|
|
|
int QtKitAspect::weight(const Kit *k) const
|
|
|
|
|
{
|
|
|
|
|
const BaseQtVersion * const qt = qtVersion(k);
|
|
|
|
|
if (!qt)
|
|
|
|
|
return 0;
|
|
|
|
|
if (!qt->targetDeviceTypes().contains(DeviceTypeKitAspect::deviceTypeId(k)))
|
|
|
|
|
return 0;
|
|
|
|
|
const Abi tcAbi = ToolChainKitAspect::targetAbi(k);
|
|
|
|
|
if (qt->qtAbis().contains(tcAbi))
|
|
|
|
|
return 2;
|
|
|
|
|
return Utils::contains(qt->qtAbis(), [&tcAbi](const Abi &qtAbi) {
|
|
|
|
|
return qtAbi.isCompatibleWith(tcAbi); }) ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
} // namespace QtSupport
|