forked from qt-creator/qt-creator
ProjectExplorer: Move KitAspect into its own set of files
There is no reason to lump it together with KitManager. Change-Id: I6cd225e390297c3dc7573ed4786c227c80ab17ce Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/buildsystem.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <projectexplorer/buildsystem.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/toolchainkitaspect.h>
|
||||
|
||||
#include <qtsupport/qtkitaspect.h>
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include "androidrunnerworker.h"
|
||||
#include "androidtr.h"
|
||||
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/projectexplorersettings.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
|
@@ -6,6 +6,9 @@
|
||||
#include <cppeditor/cpptoolstestcase.h>
|
||||
#include <cppeditor/projectinfo.h>
|
||||
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/toolchainkitaspect.h>
|
||||
|
||||
#include <qtsupport/qtkitaspect.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
@@ -34,7 +34,9 @@
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/environmentaspectwidget.h>
|
||||
#include <projectexplorer/environmentwidget.h>
|
||||
#include <projectexplorer/kitaspect.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/namedwidget.h>
|
||||
#include <projectexplorer/processparameters.h>
|
||||
#include <projectexplorer/project.h>
|
||||
|
@@ -16,7 +16,9 @@
|
||||
#include <ios/iosconstants.h>
|
||||
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/kitaspect.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectexplorersettings.h>
|
||||
|
@@ -7,7 +7,9 @@
|
||||
|
||||
#include "cmakeconfigitem.h"
|
||||
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <utils/id.h>
|
||||
|
||||
namespace ProjectExplorer { class KitAspect; }
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include <projectexplorer/buildinfo.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <projectexplorer/buildinfo.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/taskhub.h>
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/kitaspect.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
|
||||
#include <utils/detailswidget.h>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/kitaspect.h>
|
||||
#include <projectexplorer/kitoptionspage.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectexplorericons.h>
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include "debuggertr.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/kitaspect.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
@@ -6,8 +6,9 @@
|
||||
#include "debugger_global.h"
|
||||
#include "debuggerconstants.h"
|
||||
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/task.h>
|
||||
|
||||
namespace ProjectExplorer { class Kit; }
|
||||
namespace Utils { class ProcessRunData; }
|
||||
|
||||
namespace Debugger {
|
||||
|
@@ -61,6 +61,7 @@
|
||||
#include <projectexplorer/devicesupport/sshparameters.h>
|
||||
#include <projectexplorer/itaskhandler.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorericons.h>
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <projectexplorer/devicesupport/deviceprocessesdialog.h>
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/environmentaspect.h> // For the environment
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorericons.h>
|
||||
|
@@ -8,6 +8,8 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorertr.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/toolchainmanager.h>
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <projectexplorer/deploymentdata.h>
|
||||
#include <projectexplorer/headerpath.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include <projectexplorer/deployconfiguration.h>
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
|
@@ -5,7 +5,8 @@
|
||||
#include "mcusupporttr.h"
|
||||
|
||||
#include <cmakeprojectmanager/cmakekitaspect.h>
|
||||
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitaspect.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
@@ -3,7 +3,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <utils/environmentfwd.h>
|
||||
#include <utils/namevaluedictionary.h>
|
||||
|
||||
namespace ProjectExplorer { class Kit; }
|
||||
namespace Utils { class Id; }
|
||||
|
||||
namespace McuSupport::Internal {
|
||||
|
||||
|
@@ -23,6 +23,8 @@
|
||||
#include <debugger/debuggeritemmanager.h>
|
||||
#include <debugger/debuggerkitaspect.h>
|
||||
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
|
@@ -19,11 +19,12 @@
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <debugger/debuggerkitaspect.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/infobar.h>
|
||||
#include <qtsupport/qtkitaspect.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/infobar.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <projectexplorer/customtoolchain.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
@@ -7,6 +7,8 @@
|
||||
#include "mesonprojectmanagertr.h"
|
||||
#include "mesontools.h"
|
||||
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitaspect.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
|
@@ -5,8 +5,7 @@
|
||||
|
||||
#include "mesontools.h"
|
||||
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
namespace ProjectExplorer { class Kit; }
|
||||
|
||||
namespace MesonProjectManager::Internal {
|
||||
|
||||
|
@@ -103,6 +103,7 @@ add_qtc_plugin(ProjectExplorer
|
||||
jsonwizard/wizarddebug.h
|
||||
jsonwizard/jsonwizardscannergenerator.cpp jsonwizard/jsonwizardscannergenerator.h
|
||||
kit.cpp kit.h
|
||||
kitaspect.cpp kitaspect.h
|
||||
kitaspects.cpp kitaspects.h
|
||||
kitchooser.cpp kitchooser.h
|
||||
kitfeatureprovider.h
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "filterkitaspectsdialog.h"
|
||||
|
||||
#include "kitaspect.h"
|
||||
#include "kitmanager.h"
|
||||
#include "projectexplorertr.h"
|
||||
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "devicesupport/idevice.h"
|
||||
#include "devicesupport/idevicefactory.h"
|
||||
#include "kitaspect.h"
|
||||
#include "kitaspects.h"
|
||||
#include "kitmanager.h"
|
||||
#include "ioutputparser.h"
|
||||
|
290
src/plugins/projectexplorer/kitaspect.cpp
Normal file
290
src/plugins/projectexplorer/kitaspect.cpp
Normal file
@@ -0,0 +1,290 @@
|
||||
// Copyright (C) 2024 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "kitaspect.h"
|
||||
|
||||
#include "kit.h"
|
||||
#include "kitaspects.h"
|
||||
#include "projectexplorertr.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/treemodel.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
namespace {
|
||||
class KitAspectSortModel : public SortModel
|
||||
{
|
||||
public:
|
||||
using SortModel::SortModel;
|
||||
|
||||
private:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
|
||||
{
|
||||
const auto getValue = [&](const QModelIndex &index, KitAspect::ItemRole role) {
|
||||
return sourceModel()->data(index, role);
|
||||
};
|
||||
|
||||
// Criterion 1: "None" comes last.
|
||||
if (getValue(source_left, KitAspect::IsNoneRole).toBool())
|
||||
return false;
|
||||
if (getValue(source_right, KitAspect::IsNoneRole).toBool())
|
||||
return true;
|
||||
|
||||
// Criterion 2: "Quality", i.e. how likely is the respective entry to be usable.
|
||||
if (const int qual1 = getValue(source_left, KitAspect::QualityRole).toInt(),
|
||||
qual2 = getValue(source_right, KitAspect::QualityRole).toInt();
|
||||
qual1 != qual2) {
|
||||
return qual1 > qual2;
|
||||
}
|
||||
|
||||
// Criterion 3: Name.
|
||||
return SortModel::lessThan(source_left, source_right);
|
||||
}
|
||||
};
|
||||
|
||||
class KitAspectFactories
|
||||
{
|
||||
public:
|
||||
void onKitsLoaded() const
|
||||
{
|
||||
for (KitAspectFactory *factory : m_aspectList)
|
||||
factory->onKitsLoaded();
|
||||
}
|
||||
|
||||
void addKitAspect(KitAspectFactory *factory)
|
||||
{
|
||||
QTC_ASSERT(!m_aspectList.contains(factory), return);
|
||||
m_aspectList.append(factory);
|
||||
m_aspectListIsSorted = false;
|
||||
}
|
||||
|
||||
void removeKitAspect(KitAspectFactory *factory)
|
||||
{
|
||||
int removed = m_aspectList.removeAll(factory);
|
||||
QTC_CHECK(removed == 1);
|
||||
}
|
||||
|
||||
const QList<KitAspectFactory *> kitAspectFactories()
|
||||
{
|
||||
if (!m_aspectListIsSorted) {
|
||||
Utils::sort(m_aspectList, [](const KitAspectFactory *a, const KitAspectFactory *b) {
|
||||
return a->priority() > b->priority();
|
||||
});
|
||||
m_aspectListIsSorted = true;
|
||||
}
|
||||
return m_aspectList;
|
||||
}
|
||||
|
||||
// Sorted by priority, in descending order...
|
||||
QList<KitAspectFactory *> m_aspectList;
|
||||
// ... if this here is set:
|
||||
bool m_aspectListIsSorted = true;
|
||||
};
|
||||
|
||||
static KitAspectFactories &kitAspectFactoriesStorage()
|
||||
{
|
||||
static KitAspectFactories theKitAspectFactories;
|
||||
return theKitAspectFactories;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
KitAspect::KitAspect(Kit *kit, const KitAspectFactory *factory)
|
||||
: m_kit(kit), m_factory(factory)
|
||||
{
|
||||
const Id id = factory->id();
|
||||
m_mutableAction = new QAction(Tr::tr("Mark as Mutable"));
|
||||
m_mutableAction->setCheckable(true);
|
||||
m_mutableAction->setChecked(m_kit->isMutable(id));
|
||||
m_mutableAction->setEnabled(!m_kit->isSticky(id));
|
||||
connect(m_mutableAction, &QAction::toggled, this, [this, id] {
|
||||
m_kit->setMutable(id, m_mutableAction->isChecked());
|
||||
});
|
||||
}
|
||||
|
||||
KitAspect::~KitAspect()
|
||||
{
|
||||
delete m_mutableAction;
|
||||
}
|
||||
|
||||
void KitAspect::refresh()
|
||||
{
|
||||
if (!m_listAspectSpec)
|
||||
return;
|
||||
const GuardLocker locker(m_ignoreChanges);
|
||||
m_listAspectSpec->resetModel();
|
||||
m_comboBox->model()->sort(0);
|
||||
const QVariant itemId = m_listAspectSpec->getter(*kit());
|
||||
m_comboBox->setCurrentIndex(m_comboBox->findData(itemId, IdRole));
|
||||
}
|
||||
|
||||
void KitAspect::makeStickySubWidgetsReadOnly()
|
||||
{
|
||||
if (!m_kit->isSticky(m_factory->id()))
|
||||
return;
|
||||
|
||||
if (m_manageButton)
|
||||
m_manageButton->setEnabled(false);
|
||||
|
||||
makeReadOnly();
|
||||
}
|
||||
|
||||
void KitAspect::makeReadOnly()
|
||||
{
|
||||
if (m_comboBox)
|
||||
m_comboBox->setEnabled(false);
|
||||
}
|
||||
|
||||
void KitAspect::addToInnerLayout(Layouting::Layout &parentItem)
|
||||
{
|
||||
if (m_comboBox) {
|
||||
addMutableAction(m_comboBox);
|
||||
parentItem.addItem(m_comboBox);
|
||||
}
|
||||
}
|
||||
|
||||
void KitAspect::setListAspectSpec(ListAspectSpec &&listAspectSpec)
|
||||
{
|
||||
m_listAspectSpec = std::move(listAspectSpec);
|
||||
|
||||
m_comboBox = createSubWidget<QComboBox>();
|
||||
m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy());
|
||||
m_comboBox->setEnabled(true);
|
||||
const auto sortModel = new KitAspectSortModel(this);
|
||||
sortModel->setSourceModel(m_listAspectSpec->model);
|
||||
m_comboBox->setModel(sortModel);
|
||||
|
||||
refresh();
|
||||
|
||||
const auto updateTooltip = [this] {
|
||||
m_comboBox->setToolTip(
|
||||
m_comboBox->itemData(m_comboBox->currentIndex(), Qt::ToolTipRole).toString());
|
||||
};
|
||||
updateTooltip();
|
||||
connect(m_comboBox, &QComboBox::currentIndexChanged, this, [this, updateTooltip] {
|
||||
if (m_ignoreChanges.isLocked())
|
||||
return;
|
||||
updateTooltip();
|
||||
m_listAspectSpec->setter(
|
||||
*kit(), m_comboBox->itemData(m_comboBox->currentIndex(), IdRole));
|
||||
});
|
||||
}
|
||||
|
||||
void KitAspect::addToLayoutImpl(Layouting::Layout &layout)
|
||||
{
|
||||
auto label = createSubWidget<QLabel>(m_factory->displayName() + ':');
|
||||
label->setToolTip(m_factory->description());
|
||||
connect(label, &QLabel::linkActivated, this, [this](const QString &link) {
|
||||
emit labelLinkActivated(link);
|
||||
});
|
||||
|
||||
layout.addItem(label);
|
||||
addToInnerLayout(layout);
|
||||
if (m_managingPageId.isValid()) {
|
||||
m_manageButton = createSubWidget<QPushButton>(msgManage());
|
||||
connect(m_manageButton, &QPushButton::clicked, [this] {
|
||||
Core::ICore::showOptionsDialog(m_managingPageId, settingsPageItemToPreselect());
|
||||
});
|
||||
layout.addItem(m_manageButton);
|
||||
}
|
||||
layout.addItem(Layouting::br);
|
||||
}
|
||||
|
||||
void KitAspect::addMutableAction(QWidget *child)
|
||||
{
|
||||
QTC_ASSERT(child, return);
|
||||
if (factory()->id() == DeviceKitAspect::id())
|
||||
return;
|
||||
child->addAction(m_mutableAction);
|
||||
child->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
}
|
||||
|
||||
QString KitAspect::msgManage()
|
||||
{
|
||||
return Tr::tr("Manage...");
|
||||
}
|
||||
|
||||
KitAspectFactory::KitAspectFactory()
|
||||
{
|
||||
kitAspectFactoriesStorage().addKitAspect(this);
|
||||
}
|
||||
|
||||
KitAspectFactory::~KitAspectFactory()
|
||||
{
|
||||
kitAspectFactoriesStorage().removeKitAspect(this);
|
||||
}
|
||||
|
||||
int KitAspectFactory::weight(const Kit *k) const
|
||||
{
|
||||
return k->value(id()).isValid() ? 1 : 0;
|
||||
}
|
||||
|
||||
void KitAspectFactory::addToBuildEnvironment(const Kit *k, Environment &env) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
Q_UNUSED(env)
|
||||
}
|
||||
|
||||
void KitAspectFactory::addToRunEnvironment(const Kit *k, Environment &env) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
Q_UNUSED(env)
|
||||
}
|
||||
|
||||
QList<OutputLineParser *> KitAspectFactory::createOutputParsers(const Kit *k) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
return {};
|
||||
}
|
||||
|
||||
QString KitAspectFactory::displayNamePostfix(const Kit *k) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
return {};
|
||||
}
|
||||
|
||||
QSet<Id> KitAspectFactory::supportedPlatforms(const Kit *k) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
return {};
|
||||
}
|
||||
|
||||
QSet<Id> KitAspectFactory::availableFeatures(const Kit *k) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
return {};
|
||||
}
|
||||
|
||||
void KitAspectFactory::addToMacroExpander(Kit *k, MacroExpander *expander) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
Q_UNUSED(expander)
|
||||
}
|
||||
|
||||
void KitAspectFactory::notifyAboutUpdate(Kit *k)
|
||||
{
|
||||
if (k)
|
||||
k->kitUpdated();
|
||||
}
|
||||
|
||||
void KitAspectFactory::handleKitsLoaded()
|
||||
{
|
||||
kitAspectFactoriesStorage().onKitsLoaded();
|
||||
}
|
||||
|
||||
const QList<KitAspectFactory *> KitAspectFactory::kitAspectFactories()
|
||||
{
|
||||
return kitAspectFactoriesStorage().kitAspectFactories();
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
171
src/plugins/projectexplorer/kitaspect.h
Normal file
171
src/plugins/projectexplorer/kitaspect.h
Normal file
@@ -0,0 +1,171 @@
|
||||
// Copyright (C) 2024 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "projectexplorer_export.h"
|
||||
#include "task.h"
|
||||
|
||||
#include <utils/aspects.h>
|
||||
#include <utils/guard.h>
|
||||
|
||||
#include <QPair>
|
||||
#include <QPushButton>
|
||||
#include <QSet>
|
||||
|
||||
#include <functional>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractItemModel;
|
||||
class QAction;
|
||||
class QComboBox;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
class Environment;
|
||||
class MacroExpander;
|
||||
class OutputLineParser;
|
||||
} // namespace Utils
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class Kit;
|
||||
class KitAspect;
|
||||
|
||||
/**
|
||||
* @brief The KitAspectFactory class
|
||||
*
|
||||
* A KitAspectFactory can create instances of one type of KitAspect.
|
||||
* A KitAspect handles a specific piece of information stored in the kit.
|
||||
*
|
||||
* They auto-register with the \a KitManager for their life time
|
||||
*/
|
||||
class PROJECTEXPLORER_EXPORT KitAspectFactory : public QObject
|
||||
{
|
||||
public:
|
||||
using Item = QPair<QString, QString>;
|
||||
using ItemList = QList<Item>;
|
||||
|
||||
Utils::Id id() const { return m_id; }
|
||||
int priority() const { return m_priority; }
|
||||
QString displayName() const { return m_displayName; }
|
||||
QString description() const { return m_description; }
|
||||
bool isEssential() const { return m_essential; }
|
||||
|
||||
// called to find issues with the kit
|
||||
virtual Tasks validate(const Kit *) const = 0;
|
||||
// called after restoring a kit, so upgrading of kit information settings can be done
|
||||
virtual void upgrade(Kit *) { return; }
|
||||
// called to fix issues with this kitinformation. Does not modify the rest of the kit.
|
||||
virtual void fix(Kit *) { return; }
|
||||
// called on initial setup of a kit.
|
||||
virtual void setup(Kit *) { return; }
|
||||
|
||||
virtual int weight(const Kit *k) const;
|
||||
|
||||
virtual ItemList toUserOutput(const Kit *) const = 0;
|
||||
|
||||
virtual KitAspect *createKitAspect(Kit *) const = 0;
|
||||
|
||||
virtual void addToBuildEnvironment(const Kit *k, Utils::Environment &env) const;
|
||||
virtual void addToRunEnvironment(const Kit *k, Utils::Environment &env) const;
|
||||
|
||||
virtual QList<Utils::OutputLineParser *> createOutputParsers(const Kit *k) const;
|
||||
|
||||
virtual QString displayNamePostfix(const Kit *k) const;
|
||||
|
||||
virtual QSet<Utils::Id> supportedPlatforms(const Kit *k) const;
|
||||
virtual QSet<Utils::Id> availableFeatures(const Kit *k) const;
|
||||
|
||||
virtual void addToMacroExpander(ProjectExplorer::Kit *kit, Utils::MacroExpander *expander) const;
|
||||
|
||||
virtual void onKitsLoaded() {}
|
||||
|
||||
static void handleKitsLoaded();
|
||||
static const QList<KitAspectFactory *> kitAspectFactories();
|
||||
|
||||
protected:
|
||||
KitAspectFactory();
|
||||
~KitAspectFactory();
|
||||
|
||||
void setId(Utils::Id id) { m_id = id; }
|
||||
void setDisplayName(const QString &name) { m_displayName = name; }
|
||||
void setDescription(const QString &desc) { m_description = desc; }
|
||||
void makeEssential() { m_essential = true; }
|
||||
void setPriority(int priority) { m_priority = priority; }
|
||||
void notifyAboutUpdate(Kit *k);
|
||||
|
||||
private:
|
||||
QString m_displayName;
|
||||
QString m_description;
|
||||
Utils::Id m_id;
|
||||
int m_priority = 0; // The higher the closer to the top.
|
||||
bool m_essential = false;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT KitAspect : public Utils::BaseAspect
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ItemRole { IdRole = Qt::UserRole + 100, IsNoneRole, QualityRole };
|
||||
|
||||
KitAspect(Kit *kit, const KitAspectFactory *factory);
|
||||
~KitAspect();
|
||||
|
||||
virtual void refresh();
|
||||
|
||||
void addToLayoutImpl(Layouting::Layout &layout) override;
|
||||
static QString msgManage();
|
||||
|
||||
Kit *kit() const { return m_kit; }
|
||||
const KitAspectFactory *factory() const { return m_factory; }
|
||||
QAction *mutableAction() const { return m_mutableAction; }
|
||||
void addMutableAction(QWidget *child);
|
||||
void setManagingPage(Utils::Id pageId) { m_managingPageId = pageId; }
|
||||
|
||||
void makeStickySubWidgetsReadOnly();
|
||||
|
||||
protected:
|
||||
virtual void makeReadOnly();
|
||||
virtual void addToInnerLayout(Layouting::Layout &parentItem);
|
||||
virtual Utils::Id settingsPageItemToPreselect() const { return {}; }
|
||||
|
||||
// Convenience for aspects that provide a list model from which one value can be chosen.
|
||||
// It will be exposed via a QComboBox.
|
||||
class ListAspectSpec
|
||||
{
|
||||
public:
|
||||
using Getter = std::function<QVariant(const Kit &)>;
|
||||
using Setter = std::function<void(Kit &, const QVariant &)>;
|
||||
using ResetModel = std::function<void()>;
|
||||
|
||||
ListAspectSpec(
|
||||
QAbstractItemModel *model,
|
||||
Getter &&getter,
|
||||
Setter &&setter,
|
||||
ResetModel &&resetModel)
|
||||
: model(model)
|
||||
, getter(std::move(getter))
|
||||
, setter(std::move(setter))
|
||||
, resetModel(std::move(resetModel))
|
||||
{}
|
||||
|
||||
QAbstractItemModel *model;
|
||||
Getter getter;
|
||||
Setter setter;
|
||||
ResetModel resetModel;
|
||||
};
|
||||
void setListAspectSpec(ListAspectSpec &&listAspectSpec);
|
||||
|
||||
private:
|
||||
Kit *m_kit;
|
||||
const KitAspectFactory *m_factory;
|
||||
QAction *m_mutableAction = nullptr;
|
||||
Utils::Id m_managingPageId;
|
||||
QPushButton *m_manageButton = nullptr;
|
||||
QComboBox *m_comboBox = nullptr;
|
||||
std::optional<ListAspectSpec> m_listAspectSpec;
|
||||
Utils::Guard m_ignoreChanges;
|
||||
};
|
||||
|
||||
} // namespace ProjectExplorer
|
@@ -11,6 +11,8 @@
|
||||
#include "projectexplorerconstants.h"
|
||||
#include "projectexplorertr.h"
|
||||
#include "kit.h"
|
||||
#include "kitaspect.h"
|
||||
#include "kitmanager.h"
|
||||
#include "toolchain.h"
|
||||
#include "toolchainmanager.h"
|
||||
|
||||
|
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "abi.h"
|
||||
#include "devicesupport/idevicefwd.h"
|
||||
#include "kitmanager.h"
|
||||
#include "kit.h"
|
||||
#include "toolchainkitaspect.h"
|
||||
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "kitchooser.h"
|
||||
|
||||
#include "kitaspect.h"
|
||||
#include "kitmanager.h"
|
||||
#include "projectexplorerconstants.h"
|
||||
#include "projectexplorertr.h"
|
||||
|
@@ -9,8 +9,6 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <functional>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QComboBox;
|
||||
class QPushButton;
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#include "devicesupport/idevicefactory.h"
|
||||
#include "kit.h"
|
||||
#include "kitfeatureprovider.h"
|
||||
#include "kitaspect.h"
|
||||
#include "kitaspects.h"
|
||||
#include "projectexplorerconstants.h"
|
||||
#include "projectexplorertr.h"
|
||||
@@ -26,17 +27,10 @@
|
||||
#include <utils/pointeralgorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/treemodel.h>
|
||||
|
||||
#include <nanotrace/nanotrace.h>
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QAction>
|
||||
#include <QComboBox>
|
||||
#include <QHash>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QStyle>
|
||||
|
||||
#include <optional>
|
||||
|
||||
@@ -69,85 +63,10 @@ static FilePath settingsFileName()
|
||||
return ICore::userResourcePath(KIT_FILENAME);
|
||||
}
|
||||
|
||||
class KitAspectSortModel : public SortModel
|
||||
{
|
||||
public:
|
||||
using SortModel::SortModel;
|
||||
|
||||
private:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
|
||||
{
|
||||
const auto getValue = [&](const QModelIndex &index, KitAspect::ItemRole role) {
|
||||
return sourceModel()->data(index, role);
|
||||
};
|
||||
|
||||
// Criterion 1: "None" comes last.
|
||||
if (getValue(source_left, KitAspect::IsNoneRole).toBool())
|
||||
return false;
|
||||
if (getValue(source_right, KitAspect::IsNoneRole).toBool())
|
||||
return true;
|
||||
|
||||
// Criterion 2: "Quality", i.e. how likely is the respective entry to be usable.
|
||||
if (const int qual1 = getValue(source_left, KitAspect::QualityRole).toInt(),
|
||||
qual2 = getValue(source_right, KitAspect::QualityRole).toInt();
|
||||
qual1 != qual2) {
|
||||
return qual1 > qual2;
|
||||
}
|
||||
|
||||
// Criterion 3: Name.
|
||||
return SortModel::lessThan(source_left, source_right);
|
||||
}
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// KitManagerPrivate:
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
class KitAspectFactories
|
||||
{
|
||||
public:
|
||||
void onKitsLoaded() const
|
||||
{
|
||||
for (KitAspectFactory *factory : m_aspectList)
|
||||
factory->onKitsLoaded();
|
||||
}
|
||||
|
||||
void addKitAspect(KitAspectFactory *factory)
|
||||
{
|
||||
QTC_ASSERT(!m_aspectList.contains(factory), return);
|
||||
m_aspectList.append(factory);
|
||||
m_aspectListIsSorted = false;
|
||||
}
|
||||
|
||||
void removeKitAspect(KitAspectFactory *factory)
|
||||
{
|
||||
int removed = m_aspectList.removeAll(factory);
|
||||
QTC_CHECK(removed == 1);
|
||||
}
|
||||
|
||||
const QList<KitAspectFactory *> kitAspectFactories()
|
||||
{
|
||||
if (!m_aspectListIsSorted) {
|
||||
Utils::sort(m_aspectList, [](const KitAspectFactory *a, const KitAspectFactory *b) {
|
||||
return a->priority() > b->priority();
|
||||
});
|
||||
m_aspectListIsSorted = true;
|
||||
}
|
||||
return m_aspectList;
|
||||
}
|
||||
|
||||
// Sorted by priority, in descending order...
|
||||
QList<KitAspectFactory *> m_aspectList;
|
||||
// ... if this here is set:
|
||||
bool m_aspectListIsSorted = true;
|
||||
};
|
||||
|
||||
static KitAspectFactories &kitAspectFactoriesStorage()
|
||||
{
|
||||
static KitAspectFactories theKitAspectFactories;
|
||||
return theKitAspectFactories;
|
||||
}
|
||||
|
||||
class KitManagerPrivate
|
||||
{
|
||||
public:
|
||||
@@ -430,7 +349,7 @@ void KitManager::restoreKits()
|
||||
|
||||
d->m_writer = std::make_unique<PersistentSettingsWriter>(settingsFileName(), "QtCreatorProfiles");
|
||||
|
||||
kitAspectFactoriesStorage().onKitsLoaded();
|
||||
KitAspectFactory::handleKitsLoaded();
|
||||
|
||||
emit instance()->kitsLoaded();
|
||||
emit instance()->kitsChanged();
|
||||
@@ -607,7 +526,7 @@ Kit *KitManager::defaultKit()
|
||||
|
||||
const QList<KitAspectFactory *> KitManager::kitAspectFactories()
|
||||
{
|
||||
return kitAspectFactoriesStorage().kitAspectFactories();
|
||||
return KitAspectFactory::kitAspectFactories();
|
||||
}
|
||||
|
||||
const QSet<Id> KitManager::irrelevantAspects()
|
||||
@@ -715,188 +634,6 @@ void KitManager::completeKit(Kit *k)
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// KitAspect:
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
KitAspectFactory::KitAspectFactory()
|
||||
{
|
||||
kitAspectFactoriesStorage().addKitAspect(this);
|
||||
}
|
||||
|
||||
KitAspectFactory::~KitAspectFactory()
|
||||
{
|
||||
kitAspectFactoriesStorage().removeKitAspect(this);
|
||||
}
|
||||
|
||||
int KitAspectFactory::weight(const Kit *k) const
|
||||
{
|
||||
return k->value(id()).isValid() ? 1 : 0;
|
||||
}
|
||||
|
||||
void KitAspectFactory::addToBuildEnvironment(const Kit *k, Environment &env) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
Q_UNUSED(env)
|
||||
}
|
||||
|
||||
void KitAspectFactory::addToRunEnvironment(const Kit *k, Environment &env) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
Q_UNUSED(env)
|
||||
}
|
||||
|
||||
QList<OutputLineParser *> KitAspectFactory::createOutputParsers(const Kit *k) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
return {};
|
||||
}
|
||||
|
||||
QString KitAspectFactory::displayNamePostfix(const Kit *k) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
return {};
|
||||
}
|
||||
|
||||
QSet<Id> KitAspectFactory::supportedPlatforms(const Kit *k) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
return {};
|
||||
}
|
||||
|
||||
QSet<Id> KitAspectFactory::availableFeatures(const Kit *k) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
return {};
|
||||
}
|
||||
|
||||
void KitAspectFactory::addToMacroExpander(Kit *k, MacroExpander *expander) const
|
||||
{
|
||||
Q_UNUSED(k)
|
||||
Q_UNUSED(expander)
|
||||
}
|
||||
|
||||
void KitAspectFactory::notifyAboutUpdate(Kit *k)
|
||||
{
|
||||
if (k)
|
||||
k->kitUpdated();
|
||||
}
|
||||
|
||||
KitAspect::KitAspect(Kit *kit, const KitAspectFactory *factory)
|
||||
: m_kit(kit), m_factory(factory)
|
||||
{
|
||||
const Id id = factory->id();
|
||||
m_mutableAction = new QAction(Tr::tr("Mark as Mutable"));
|
||||
m_mutableAction->setCheckable(true);
|
||||
m_mutableAction->setChecked(m_kit->isMutable(id));
|
||||
m_mutableAction->setEnabled(!m_kit->isSticky(id));
|
||||
connect(m_mutableAction, &QAction::toggled, this, [this, id] {
|
||||
m_kit->setMutable(id, m_mutableAction->isChecked());
|
||||
});
|
||||
}
|
||||
|
||||
KitAspect::~KitAspect()
|
||||
{
|
||||
delete m_mutableAction;
|
||||
}
|
||||
|
||||
void KitAspect::refresh()
|
||||
{
|
||||
if (!m_listAspectSpec)
|
||||
return;
|
||||
const GuardLocker locker(m_ignoreChanges);
|
||||
m_listAspectSpec->resetModel();
|
||||
m_comboBox->model()->sort(0);
|
||||
const QVariant itemId = m_listAspectSpec->getter(*kit());
|
||||
m_comboBox->setCurrentIndex(m_comboBox->findData(itemId, IdRole));
|
||||
}
|
||||
|
||||
void KitAspect::makeStickySubWidgetsReadOnly()
|
||||
{
|
||||
if (!m_kit->isSticky(m_factory->id()))
|
||||
return;
|
||||
|
||||
if (m_manageButton)
|
||||
m_manageButton->setEnabled(false);
|
||||
|
||||
makeReadOnly();
|
||||
}
|
||||
|
||||
void KitAspect::makeReadOnly()
|
||||
{
|
||||
if (m_comboBox)
|
||||
m_comboBox->setEnabled(false);
|
||||
}
|
||||
|
||||
void KitAspect::addToInnerLayout(Layouting::Layout &parentItem)
|
||||
{
|
||||
if (m_comboBox) {
|
||||
addMutableAction(m_comboBox);
|
||||
parentItem.addItem(m_comboBox);
|
||||
}
|
||||
}
|
||||
|
||||
void KitAspect::setListAspectSpec(ListAspectSpec &&listAspectSpec)
|
||||
{
|
||||
m_listAspectSpec = std::move(listAspectSpec);
|
||||
|
||||
m_comboBox = createSubWidget<QComboBox>();
|
||||
m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy());
|
||||
m_comboBox->setEnabled(true);
|
||||
const auto sortModel = new KitAspectSortModel(this);
|
||||
sortModel->setSourceModel(m_listAspectSpec->model);
|
||||
m_comboBox->setModel(sortModel);
|
||||
|
||||
refresh();
|
||||
|
||||
const auto updateTooltip = [this] {
|
||||
m_comboBox->setToolTip(
|
||||
m_comboBox->itemData(m_comboBox->currentIndex(), Qt::ToolTipRole).toString());
|
||||
};
|
||||
updateTooltip();
|
||||
connect(m_comboBox, &QComboBox::currentIndexChanged, this, [this, updateTooltip] {
|
||||
if (m_ignoreChanges.isLocked())
|
||||
return;
|
||||
updateTooltip();
|
||||
m_listAspectSpec->setter(
|
||||
*kit(), m_comboBox->itemData(m_comboBox->currentIndex(), IdRole));
|
||||
});
|
||||
}
|
||||
|
||||
void KitAspect::addToLayoutImpl(Layouting::Layout &layout)
|
||||
{
|
||||
auto label = createSubWidget<QLabel>(m_factory->displayName() + ':');
|
||||
label->setToolTip(m_factory->description());
|
||||
connect(label, &QLabel::linkActivated, this, [this](const QString &link) {
|
||||
emit labelLinkActivated(link);
|
||||
});
|
||||
|
||||
layout.addItem(label);
|
||||
addToInnerLayout(layout);
|
||||
if (m_managingPageId.isValid()) {
|
||||
m_manageButton = createSubWidget<QPushButton>(msgManage());
|
||||
connect(m_manageButton, &QPushButton::clicked, [this] {
|
||||
Core::ICore::showOptionsDialog(m_managingPageId, settingsPageItemToPreselect());
|
||||
});
|
||||
layout.addItem(m_manageButton);
|
||||
}
|
||||
layout.addItem(Layouting::br);
|
||||
}
|
||||
|
||||
void KitAspect::addMutableAction(QWidget *child)
|
||||
{
|
||||
QTC_ASSERT(child, return);
|
||||
if (factory()->id() == DeviceKitAspect::id())
|
||||
return;
|
||||
child->addAction(m_mutableAction);
|
||||
child->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
}
|
||||
|
||||
QString KitAspect::msgManage()
|
||||
{
|
||||
return Tr::tr("Manage...");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// KitFeatureProvider:
|
||||
// --------------------------------------------------------------------
|
||||
|
@@ -7,171 +7,19 @@
|
||||
|
||||
#include "kit.h"
|
||||
|
||||
#include <coreplugin/featureprovider.h>
|
||||
|
||||
#include <utils/aspects.h>
|
||||
#include <utils/guard.h>
|
||||
|
||||
#include <QPair>
|
||||
#include <QPushButton>
|
||||
#include <QSet>
|
||||
|
||||
#include <functional>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractItemModel;
|
||||
class QComboBox;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
class Environment;
|
||||
class FilePath;
|
||||
class MacroExpander;
|
||||
class OutputLineParser;
|
||||
} // namespace Utils
|
||||
namespace Utils { class FilePath; }
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class KitAspect;
|
||||
class KitManager;
|
||||
class KitAspectFactory;
|
||||
|
||||
namespace Internal {
|
||||
class KitManagerConfigWidget;
|
||||
} // namespace Internal
|
||||
|
||||
/**
|
||||
* @brief The KitAspectFactory class
|
||||
*
|
||||
* A KitAspectFactory can create instances of one type of KitAspect.
|
||||
* A KitAspect handles a specific piece of information stored in the kit.
|
||||
*
|
||||
* They auto-register with the \a KitManager for their life time
|
||||
*/
|
||||
class PROJECTEXPLORER_EXPORT KitAspectFactory : public QObject
|
||||
{
|
||||
public:
|
||||
using Item = QPair<QString, QString>;
|
||||
using ItemList = QList<Item>;
|
||||
|
||||
Utils::Id id() const { return m_id; }
|
||||
int priority() const { return m_priority; }
|
||||
QString displayName() const { return m_displayName; }
|
||||
QString description() const { return m_description; }
|
||||
bool isEssential() const { return m_essential; }
|
||||
|
||||
// called to find issues with the kit
|
||||
virtual Tasks validate(const Kit *) const = 0;
|
||||
// called after restoring a kit, so upgrading of kit information settings can be done
|
||||
virtual void upgrade(Kit *) { return; }
|
||||
// called to fix issues with this kitinformation. Does not modify the rest of the kit.
|
||||
virtual void fix(Kit *) { return; }
|
||||
// called on initial setup of a kit.
|
||||
virtual void setup(Kit *) { return; }
|
||||
|
||||
virtual int weight(const Kit *k) const;
|
||||
|
||||
virtual ItemList toUserOutput(const Kit *) const = 0;
|
||||
|
||||
virtual KitAspect *createKitAspect(Kit *) const = 0;
|
||||
|
||||
virtual void addToBuildEnvironment(const Kit *k, Utils::Environment &env) const;
|
||||
virtual void addToRunEnvironment(const Kit *k, Utils::Environment &env) const;
|
||||
|
||||
virtual QList<Utils::OutputLineParser *> createOutputParsers(const Kit *k) const;
|
||||
|
||||
virtual QString displayNamePostfix(const Kit *k) const;
|
||||
|
||||
virtual QSet<Utils::Id> supportedPlatforms(const Kit *k) const;
|
||||
virtual QSet<Utils::Id> availableFeatures(const Kit *k) const;
|
||||
|
||||
virtual void addToMacroExpander(ProjectExplorer::Kit *kit, Utils::MacroExpander *expander) const;
|
||||
|
||||
virtual void onKitsLoaded() {}
|
||||
|
||||
protected:
|
||||
KitAspectFactory();
|
||||
~KitAspectFactory();
|
||||
|
||||
void setId(Utils::Id id) { m_id = id; }
|
||||
void setDisplayName(const QString &name) { m_displayName = name; }
|
||||
void setDescription(const QString &desc) { m_description = desc; }
|
||||
void makeEssential() { m_essential = true; }
|
||||
void setPriority(int priority) { m_priority = priority; }
|
||||
void notifyAboutUpdate(Kit *k);
|
||||
|
||||
private:
|
||||
QString m_displayName;
|
||||
QString m_description;
|
||||
Utils::Id m_id;
|
||||
int m_priority = 0; // The higher the closer to the top.
|
||||
bool m_essential = false;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT KitAspect : public Utils::BaseAspect
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ItemRole { IdRole = Qt::UserRole + 100, IsNoneRole, QualityRole };
|
||||
|
||||
KitAspect(Kit *kit, const KitAspectFactory *factory);
|
||||
~KitAspect();
|
||||
|
||||
virtual void refresh();
|
||||
|
||||
void addToLayoutImpl(Layouting::Layout &layout) override;
|
||||
static QString msgManage();
|
||||
|
||||
Kit *kit() const { return m_kit; }
|
||||
const KitAspectFactory *factory() const { return m_factory; }
|
||||
QAction *mutableAction() const { return m_mutableAction; }
|
||||
void addMutableAction(QWidget *child);
|
||||
void setManagingPage(Utils::Id pageId) { m_managingPageId = pageId; }
|
||||
|
||||
void makeStickySubWidgetsReadOnly();
|
||||
|
||||
protected:
|
||||
virtual void makeReadOnly();
|
||||
virtual void addToInnerLayout(Layouting::Layout &parentItem);
|
||||
virtual Utils::Id settingsPageItemToPreselect() const { return {}; }
|
||||
|
||||
// Convenience for aspects that provide a list model from which one value can be chosen.
|
||||
// It will be exposed via a QComboBox.
|
||||
class ListAspectSpec
|
||||
{
|
||||
public:
|
||||
using Getter = std::function<QVariant(const Kit &)>;
|
||||
using Setter = std::function<void(Kit &, const QVariant &)>;
|
||||
using ResetModel = std::function<void()>;
|
||||
|
||||
ListAspectSpec(
|
||||
QAbstractItemModel *model,
|
||||
Getter &&getter,
|
||||
Setter &&setter,
|
||||
ResetModel &&resetModel)
|
||||
: model(model)
|
||||
, getter(std::move(getter))
|
||||
, setter(std::move(setter))
|
||||
, resetModel(std::move(resetModel))
|
||||
{}
|
||||
|
||||
QAbstractItemModel *model;
|
||||
Getter getter;
|
||||
Setter setter;
|
||||
ResetModel resetModel;
|
||||
};
|
||||
void setListAspectSpec(ListAspectSpec &&listAspectSpec);
|
||||
|
||||
private:
|
||||
Kit *m_kit;
|
||||
const KitAspectFactory *m_factory;
|
||||
QAction *m_mutableAction = nullptr;
|
||||
Utils::Id m_managingPageId;
|
||||
QPushButton *m_manageButton = nullptr;
|
||||
QComboBox *m_comboBox = nullptr;
|
||||
std::optional<ListAspectSpec> m_listAspectSpec;
|
||||
Utils::Guard m_ignoreChanges;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT KitManager final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "devicesupport/idevicefactory.h"
|
||||
#include "kit.h"
|
||||
#include "kitaspect.h"
|
||||
#include "kitaspects.h"
|
||||
#include "kitmanager.h"
|
||||
#include "projectexplorertr.h"
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "kitmanager.h"
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
@@ -17,6 +17,8 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class Kit;
|
||||
class KitAspect;
|
||||
class KitAspectFactory;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#include "buildmanager.h"
|
||||
#include "deployconfiguration.h"
|
||||
#include "kit.h"
|
||||
#include "kitaspect.h"
|
||||
#include "kitmanager.h"
|
||||
#include "project.h"
|
||||
#include "projectexplorer.h"
|
||||
|
@@ -77,6 +77,7 @@ QtcPlugin {
|
||||
"ipotentialkit.h",
|
||||
"itaskhandler.h",
|
||||
"kit.cpp", "kit.h",
|
||||
"kitaspect.cpp", "kitaspect.h",
|
||||
"kitaspects.cpp", "kitaspects.h",
|
||||
"kitchooser.cpp", "kitchooser.h",
|
||||
"kitfeatureprovider.h",
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#include "buildinfo.h"
|
||||
#include "projectexplorerconstants.h"
|
||||
#include "projectexplorertr.h"
|
||||
#include "kitmanager.h"
|
||||
#include "kitaspect.h"
|
||||
#include "kitoptionspage.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "devicesupport/idevice.h"
|
||||
#include "kit.h"
|
||||
#include "kitaspect.h"
|
||||
#include "kitaspects.h"
|
||||
#include "kitmanager.h"
|
||||
#include "projectexplorerconstants.h"
|
||||
|
@@ -8,7 +8,8 @@
|
||||
#include "pythontr.h"
|
||||
#include "pythonutils.h"
|
||||
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitaspect.h>
|
||||
|
||||
#include <utils/guard.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include "qbssettings.h"
|
||||
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectexplorertr.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
@@ -7,7 +7,8 @@
|
||||
#include "qbsprofilemanager.h"
|
||||
#include "qbsprojectmanagertr.h"
|
||||
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitaspect.h>
|
||||
|
||||
#include <utils/elidinglabel.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
@@ -3,7 +3,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <QVariantMap>
|
||||
|
||||
namespace ProjectExplorer { class Kit; }
|
||||
namespace Utils { class Id; }
|
||||
|
||||
namespace QbsProjectManager::Internal {
|
||||
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include <projectexplorer/headerpath.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectupdater.h>
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include <projectexplorer/buildpropertiessettings.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/makestep.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectexplorertr.h>
|
||||
|
@@ -6,6 +6,8 @@
|
||||
#include "qmakeprojectmanagerconstants.h"
|
||||
#include "qmakeprojectmanagertr.h"
|
||||
|
||||
#include <projectexplorer/kitaspect.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/toolchainmanager.h>
|
||||
|
@@ -3,7 +3,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <QString>
|
||||
|
||||
namespace ProjectExplorer { class Kit; }
|
||||
namespace Utils { class Id; }
|
||||
|
||||
namespace QmakeProjectManager::Internal {
|
||||
|
||||
|
@@ -28,6 +28,8 @@
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/extracompiler.h>
|
||||
#include <projectexplorer/headerpath.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectupdater.h>
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <projectexplorer/buildinfo.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/toolchainmanager.h>
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#include <projectexplorer/buildmanager.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/gnumakeparser.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/makestep.h>
|
||||
#include <projectexplorer/processparameters.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <texteditor/textdocument.h>
|
||||
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <qmljs/qmljsconstants.h>
|
||||
#include <qtsupport/qtkitaspect.h>
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#include <QDir>
|
||||
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/buildsystem.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
|
@@ -3,26 +3,26 @@
|
||||
|
||||
#include "qmlproject.h"
|
||||
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtkitaspect.h>
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include "qmlprojectconstants.h"
|
||||
#include "qmlprojectmanagertr.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include "projectexplorer/devicesupport/idevice.h"
|
||||
#include "qmlprojectconstants.h"
|
||||
#include "qmlprojectmanagertr.h"
|
||||
#include "utils/algorithm.h"
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtkitaspect.h>
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
|
||||
#include <texteditor/textdocument.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
@@ -16,11 +16,12 @@
|
||||
#include <debugger/debuggerkitaspect.h>
|
||||
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/toolchainmanager.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <projectexplorer/buildsystem.h>
|
||||
#include <projectexplorer/buildtargetinfo.h>
|
||||
#include <projectexplorer/environmentaspect.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <projectexplorer/deployablefile.h>
|
||||
#include <projectexplorer/deploymentdata.h>
|
||||
#include <projectexplorer/headerpath.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
|
@@ -4,6 +4,8 @@
|
||||
#include "exampleslistmodel.h"
|
||||
|
||||
#include "examplesparser.h"
|
||||
#include "qtkitaspect.h"
|
||||
#include "qtversionmanager.h"
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QApplication>
|
||||
@@ -13,13 +15,10 @@
|
||||
#include <QUrl>
|
||||
|
||||
#include <android/androidconstants.h>
|
||||
#include <ios/iosconstants.h>
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <qtsupport/qtkitaspect.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
|
||||
#include <ios/iosconstants.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/filepath.h>
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include <coreplugin/coreplugintr.h>
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
|
@@ -3,10 +3,11 @@
|
||||
|
||||
#include "qscxmlcgenerator.h"
|
||||
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtkitaspect.h>
|
||||
#include "baseqtversion.h"
|
||||
#include "qtkitaspect.h"
|
||||
|
||||
#include <projectexplorer/extracompiler.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
@@ -11,6 +11,9 @@
|
||||
#include "qtversionmanager.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/kitaspect.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/task.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "baseqtversion.h"
|
||||
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
|
||||
namespace QtSupport {
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/kitaspect.h>
|
||||
#include <projectexplorer/kitoptionspage.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectexplorericons.h>
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include "qtversionmanager.h"
|
||||
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
Reference in New Issue
Block a user