forked from qt-creator/qt-creator
Kits: Sort kit parts by device
Change-Id: I00e1db4897071ac6baf97c5bb6214c2658a7b9fb Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -75,22 +75,15 @@ public:
|
|||||||
m_comboBox->setEnabled(false);
|
m_comboBox->setEnabled(false);
|
||||||
m_comboBox->setToolTip(ki->description());
|
m_comboBox->setToolTip(ki->description());
|
||||||
|
|
||||||
const QList<CMakeTool *> tools = CMakeToolManager::cmakeTools();
|
|
||||||
for (const CMakeTool *tool : tools)
|
|
||||||
cmakeToolAdded(tool->id());
|
|
||||||
|
|
||||||
updateComboBox();
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
connect(m_comboBox, &QComboBox::currentIndexChanged,
|
connect(m_comboBox, &QComboBox::currentIndexChanged,
|
||||||
this, &CMakeKitAspectWidget::currentCMakeToolChanged);
|
this, &CMakeKitAspectWidget::currentCMakeToolChanged);
|
||||||
|
|
||||||
CMakeToolManager *cmakeMgr = CMakeToolManager::instance();
|
CMakeToolManager *cmakeMgr = CMakeToolManager::instance();
|
||||||
connect(cmakeMgr, &CMakeToolManager::cmakeAdded,
|
connect(cmakeMgr, &CMakeToolManager::cmakeAdded, this, &CMakeKitAspectWidget::refresh);
|
||||||
this, &CMakeKitAspectWidget::cmakeToolAdded);
|
connect(cmakeMgr, &CMakeToolManager::cmakeRemoved, this, &CMakeKitAspectWidget::refresh);
|
||||||
connect(cmakeMgr, &CMakeToolManager::cmakeRemoved,
|
connect(cmakeMgr, &CMakeToolManager::cmakeUpdated, this, &CMakeKitAspectWidget::refresh);
|
||||||
this, &CMakeKitAspectWidget::cmakeToolRemoved);
|
|
||||||
connect(cmakeMgr, &CMakeToolManager::cmakeUpdated,
|
|
||||||
this, &CMakeKitAspectWidget::cmakeToolUpdated);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~CMakeKitAspectWidget() override
|
~CMakeKitAspectWidget() override
|
||||||
@@ -112,6 +105,37 @@ private:
|
|||||||
|
|
||||||
void refresh() override
|
void refresh() override
|
||||||
{
|
{
|
||||||
|
const GuardLocker locker(m_ignoreChanges);
|
||||||
|
m_comboBox->clear();
|
||||||
|
|
||||||
|
IDeviceConstPtr device = BuildDeviceKitAspect::device(kit());
|
||||||
|
const FilePath rootPath = device->rootPath();
|
||||||
|
|
||||||
|
const auto list = CMakeToolManager::cmakeTools();
|
||||||
|
|
||||||
|
m_comboBox->setEnabled(!list.isEmpty());
|
||||||
|
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
m_comboBox->addItem(Tr::tr("<No CMake Tool available>"), Id().toSetting());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<CMakeTool *> same = Utils::filtered(list, [rootPath](CMakeTool *item) {
|
||||||
|
return item->cmakeExecutable().isSameDevice(rootPath);
|
||||||
|
});
|
||||||
|
const QList<CMakeTool *> other = Utils::filtered(list, [rootPath](CMakeTool *item) {
|
||||||
|
return !item->cmakeExecutable().isSameDevice(rootPath);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (CMakeTool *item : same)
|
||||||
|
m_comboBox->addItem(item->displayName(), item->id().toSetting());
|
||||||
|
|
||||||
|
if (!same.isEmpty() && !other.isEmpty())
|
||||||
|
m_comboBox->insertSeparator(m_comboBox->count());
|
||||||
|
|
||||||
|
for (CMakeTool *item : other)
|
||||||
|
m_comboBox->addItem(item->displayName(), item->id().toSetting());
|
||||||
|
|
||||||
CMakeTool *tool = CMakeKitAspect::cmakeTool(m_kit);
|
CMakeTool *tool = CMakeKitAspect::cmakeTool(m_kit);
|
||||||
m_comboBox->setCurrentIndex(tool ? indexOf(tool->id()) : -1);
|
m_comboBox->setCurrentIndex(tool ? indexOf(tool->id()) : -1);
|
||||||
}
|
}
|
||||||
@@ -125,58 +149,6 @@ private:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateComboBox()
|
|
||||||
{
|
|
||||||
// remove unavailable cmake tool:
|
|
||||||
int pos = indexOf(Id());
|
|
||||||
if (pos >= 0)
|
|
||||||
m_comboBox->removeItem(pos);
|
|
||||||
|
|
||||||
if (m_comboBox->count() == 0) {
|
|
||||||
m_comboBox->addItem(Tr::tr("<No CMake Tool available>"), Id().toSetting());
|
|
||||||
m_comboBox->setEnabled(false);
|
|
||||||
} else {
|
|
||||||
m_comboBox->setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmakeToolAdded(Id id)
|
|
||||||
{
|
|
||||||
const CMakeTool *tool = CMakeToolManager::findById(id);
|
|
||||||
QTC_ASSERT(tool, return);
|
|
||||||
|
|
||||||
m_comboBox->addItem(tool->displayName(), tool->id().toSetting());
|
|
||||||
updateComboBox();
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmakeToolUpdated(Id id)
|
|
||||||
{
|
|
||||||
const int pos = indexOf(id);
|
|
||||||
QTC_ASSERT(pos >= 0, return);
|
|
||||||
|
|
||||||
const CMakeTool *tool = CMakeToolManager::findById(id);
|
|
||||||
QTC_ASSERT(tool, return);
|
|
||||||
|
|
||||||
m_comboBox->setItemText(pos, tool->displayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmakeToolRemoved(Id id)
|
|
||||||
{
|
|
||||||
const int pos = indexOf(id);
|
|
||||||
QTC_ASSERT(pos >= 0, return);
|
|
||||||
|
|
||||||
{
|
|
||||||
// do not handle the current index changed signal
|
|
||||||
const GuardLocker locker(m_ignoreChanges);
|
|
||||||
m_comboBox->removeItem(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update the checkbox and set the current index
|
|
||||||
updateComboBox();
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
void currentCMakeToolChanged(int index)
|
void currentCMakeToolChanged(int index)
|
||||||
{
|
{
|
||||||
if (m_ignoreChanges.isLocked())
|
if (m_ignoreChanges.isLocked())
|
||||||
|
@@ -78,7 +78,25 @@ private:
|
|||||||
const GuardLocker locker(m_ignoreChanges);
|
const GuardLocker locker(m_ignoreChanges);
|
||||||
m_comboBox->clear();
|
m_comboBox->clear();
|
||||||
m_comboBox->addItem(Tr::tr("None"), QString());
|
m_comboBox->addItem(Tr::tr("None"), QString());
|
||||||
for (const DebuggerItem &item : DebuggerItemManager::debuggers())
|
|
||||||
|
IDeviceConstPtr device = BuildDeviceKitAspect::device(kit());
|
||||||
|
const Utils::FilePath path = device->rootPath();
|
||||||
|
const QList<DebuggerItem> list = DebuggerItemManager::debuggers();
|
||||||
|
|
||||||
|
const QList<DebuggerItem> same = Utils::filtered(list, [path](const DebuggerItem &item) {
|
||||||
|
return item.command().isSameDevice(path);
|
||||||
|
});
|
||||||
|
const QList<DebuggerItem> other = Utils::filtered(list, [path](const DebuggerItem &item) {
|
||||||
|
return !item.command().isSameDevice(path);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const DebuggerItem &item : same)
|
||||||
|
m_comboBox->addItem(item.displayName(), item.id());
|
||||||
|
|
||||||
|
if (!same.isEmpty() && !other.isEmpty())
|
||||||
|
m_comboBox->insertSeparator(m_comboBox->count());
|
||||||
|
|
||||||
|
for (const DebuggerItem &item : other)
|
||||||
m_comboBox->addItem(item.displayName(), item.id());
|
m_comboBox->addItem(item.displayName(), item.id());
|
||||||
|
|
||||||
const DebuggerItem *item = DebuggerKitAspect::debugger(m_kit);
|
const DebuggerItem *item = DebuggerKitAspect::debugger(m_kit);
|
||||||
|
@@ -239,6 +239,8 @@ private:
|
|||||||
|
|
||||||
void refresh() override
|
void refresh() override
|
||||||
{
|
{
|
||||||
|
IDeviceConstPtr device = BuildDeviceKitAspect::device(kit());
|
||||||
|
|
||||||
const GuardLocker locker(m_ignoreChanges);
|
const GuardLocker locker(m_ignoreChanges);
|
||||||
const QList<Id> keys = m_languageComboboxMap.keys();
|
const QList<Id> keys = m_languageComboboxMap.keys();
|
||||||
for (const Id l : keys) {
|
for (const Id l : keys) {
|
||||||
@@ -248,8 +250,21 @@ private:
|
|||||||
cb->clear();
|
cb->clear();
|
||||||
cb->addItem(Tr::tr("<No compiler>"), QByteArray());
|
cb->addItem(Tr::tr("<No compiler>"), QByteArray());
|
||||||
|
|
||||||
for (ToolChain *tc : ltcList)
|
const QList<ToolChain *> same = Utils::filtered(ltcList, [device](ToolChain *tc) {
|
||||||
cb->addItem(tc->displayName(), tc->id());
|
return tc->compilerCommand().isSameDevice(device->rootPath());
|
||||||
|
});
|
||||||
|
const QList<ToolChain *> other = Utils::filtered(ltcList, [device](ToolChain *tc) {
|
||||||
|
return !tc->compilerCommand().isSameDevice(device->rootPath());
|
||||||
|
});
|
||||||
|
|
||||||
|
for (ToolChain *item : same)
|
||||||
|
cb->addItem(item->displayName(), item->id());
|
||||||
|
|
||||||
|
if (!same.isEmpty() && !other.isEmpty())
|
||||||
|
cb->insertSeparator(cb->count());
|
||||||
|
|
||||||
|
for (ToolChain *item : other)
|
||||||
|
cb->addItem(item->displayName(), item->id());
|
||||||
|
|
||||||
cb->setEnabled(cb->count() > 1 && !m_isReadOnly);
|
cb->setEnabled(cb->count() > 1 && !m_isReadOnly);
|
||||||
const int index = indexOf(cb, ToolChainKitAspect::toolChain(m_kit, l));
|
const int index = indexOf(cb, ToolChainKitAspect::toolChain(m_kit, l));
|
||||||
@@ -471,8 +486,7 @@ void ToolChainKitAspect::setup(Kit *k)
|
|||||||
// ID is not found: Might be an ABI string...
|
// ID is not found: Might be an ABI string...
|
||||||
lockToolchains = false;
|
lockToolchains = false;
|
||||||
const QString abi = QString::fromUtf8(id);
|
const QString abi = QString::fromUtf8(id);
|
||||||
const Toolchains possibleTcs = ToolChainManager::toolchains(
|
const Toolchains possibleTcs = ToolChainManager::toolchains([abi, l](const ToolChain *t) {
|
||||||
[abi, l](const ToolChain *t) {
|
|
||||||
return t->targetAbi().toString() == abi && t->language() == l;
|
return t->targetAbi().toString() == abi && t->language() == l;
|
||||||
});
|
});
|
||||||
ToolChain *bestTc = nullptr;
|
ToolChain *bestTc = nullptr;
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
#include "qttestparser.h"
|
#include "qttestparser.h"
|
||||||
#include "qtversionmanager.h"
|
#include "qtversionmanager.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/devicesupport/idevice.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/task.h>
|
#include <projectexplorer/task.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/buildablehelperlibrary.h>
|
#include <utils/buildablehelperlibrary.h>
|
||||||
|
#include <utils/guard.h>
|
||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/macroexpander.h>
|
#include <utils/macroexpander.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -37,18 +39,20 @@ public:
|
|||||||
m_combo->setSizePolicy(QSizePolicy::Ignored, m_combo->sizePolicy().verticalPolicy());
|
m_combo->setSizePolicy(QSizePolicy::Ignored, m_combo->sizePolicy().verticalPolicy());
|
||||||
m_combo->addItem(Tr::tr("None"), -1);
|
m_combo->addItem(Tr::tr("None"), -1);
|
||||||
|
|
||||||
QList<int> versionIds = Utils::transform(QtVersionManager::versions(), &QtVersion::uniqueId);
|
|
||||||
versionsChanged(versionIds, QList<int>(), QList<int>());
|
|
||||||
|
|
||||||
m_manageButton = createManageButton(Constants::QTVERSION_SETTINGS_PAGE_ID);
|
m_manageButton = createManageButton(Constants::QTVERSION_SETTINGS_PAGE_ID);
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
m_combo->setToolTip(ki->description());
|
m_combo->setToolTip(ki->description());
|
||||||
|
|
||||||
connect(m_combo, &QComboBox::currentIndexChanged,
|
connect(m_combo, &QComboBox::currentIndexChanged, this, [this] {
|
||||||
this, &QtKitAspectWidget::currentWasChanged);
|
if (!m_ignoreChanges.isLocked())
|
||||||
connect(QtVersionManager::instance(), &QtVersionManager::qtVersionsChanged,
|
currentWasChanged(m_combo->currentIndex());
|
||||||
this, &QtKitAspectWidget::versionsChanged);
|
});
|
||||||
|
|
||||||
|
connect(QtVersionManager::instance(),
|
||||||
|
&QtVersionManager::qtVersionsChanged,
|
||||||
|
this,
|
||||||
|
&QtKitAspectWidget::refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
~QtKitAspectWidget() final
|
~QtKitAspectWidget() final
|
||||||
@@ -69,6 +73,30 @@ private:
|
|||||||
|
|
||||||
void refresh() final
|
void refresh() final
|
||||||
{
|
{
|
||||||
|
const GuardLocker locker(m_ignoreChanges);
|
||||||
|
m_combo->clear();
|
||||||
|
|
||||||
|
IDeviceConstPtr device = BuildDeviceKitAspect::device(kit());
|
||||||
|
const FilePath deviceRoot = device->rootPath();
|
||||||
|
|
||||||
|
const QtVersions versions = QtVersionManager::versions();
|
||||||
|
|
||||||
|
const QList<QtVersion *> same = Utils::filtered(versions, [device](QtVersion *qt) {
|
||||||
|
return qt->qmakeFilePath().isSameDevice(device->rootPath());
|
||||||
|
});
|
||||||
|
const QList<QtVersion *> other = Utils::filtered(versions, [device](QtVersion *qt) {
|
||||||
|
return !qt->qmakeFilePath().isSameDevice(device->rootPath());
|
||||||
|
});
|
||||||
|
|
||||||
|
for (QtVersion *item : same)
|
||||||
|
m_combo->addItem(item->displayName(), item->uniqueId());
|
||||||
|
|
||||||
|
if (!same.isEmpty() && !other.isEmpty())
|
||||||
|
m_combo->insertSeparator(m_combo->count());
|
||||||
|
|
||||||
|
for (QtVersion *item : other)
|
||||||
|
m_combo->addItem(item->displayName(), item->uniqueId());
|
||||||
|
|
||||||
m_combo->setCurrentIndex(findQtVersion(QtKitAspect::qtVersionId(m_kit)));
|
m_combo->setCurrentIndex(findQtVersion(QtKitAspect::qtVersionId(m_kit)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,27 +110,6 @@ private:
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void versionsChanged(const QList<int> &added, const QList<int> &removed, const QList<int> &changed)
|
|
||||||
{
|
|
||||||
for (const int id : added) {
|
|
||||||
QtVersion *v = QtVersionManager::version(id);
|
|
||||||
QTC_CHECK(v);
|
|
||||||
QTC_CHECK(findQtVersion(id) < 0);
|
|
||||||
m_combo->addItem(itemNameFor(v), id);
|
|
||||||
}
|
|
||||||
for (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);
|
|
||||||
}
|
|
||||||
for (const int id : changed) {
|
|
||||||
QtVersion *v = QtVersionManager::version(id);
|
|
||||||
int pos = findQtVersion(id);
|
|
||||||
QTC_CHECK(pos >= 0);
|
|
||||||
m_combo->setItemText(pos, itemNameFor(v));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void currentWasChanged(int idx)
|
void currentWasChanged(int idx)
|
||||||
{
|
{
|
||||||
QtKitAspect::setQtVersionId(m_kit, m_combo->itemData(idx).toInt());
|
QtKitAspect::setQtVersionId(m_kit, m_combo->itemData(idx).toInt());
|
||||||
@@ -117,6 +124,7 @@ private:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Guard m_ignoreChanges;
|
||||||
QComboBox *m_combo;
|
QComboBox *m_combo;
|
||||||
QWidget *m_manageButton;
|
QWidget *m_manageButton;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user