forked from qt-creator/qt-creator
ProjectExplorer: Filter out unusable kits
As side-effect, fix missing expansion of subitems in some cases. Task-number: QTCREATORBUG-17110 Change-Id: Ib0c74e968d6d814f9dadbb37b323c8ac68cda310 Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -234,6 +234,11 @@ public:
|
|||||||
{
|
{
|
||||||
Q_UNUSED(column)
|
Q_UNUSED(column)
|
||||||
|
|
||||||
|
if (role == ItemUpdatedFromBelowRole) {
|
||||||
|
announceChange();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (role == ItemDeactivatedFromBelowRole) {
|
if (role == ItemDeactivatedFromBelowRole) {
|
||||||
announceChange();
|
announceChange();
|
||||||
return true;
|
return true;
|
||||||
@@ -375,16 +380,13 @@ public:
|
|||||||
this, &SelectorModel::openContextMenu);
|
this, &SelectorModel::openContextMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void announceChange()
|
|
||||||
{
|
|
||||||
m_changeListener(m_projectsModel.rootItem()->childAt(0)->data(0, PanelWidgetRole).value<QWidget *>());
|
|
||||||
}
|
|
||||||
|
|
||||||
void updatePanel()
|
void updatePanel()
|
||||||
{
|
{
|
||||||
announceChange();
|
ProjectItem *projectItem = m_projectsModel.rootItem()->childAt(0);
|
||||||
|
m_changeListener(projectItem->data(0, PanelWidgetRole).value<QWidget *>());
|
||||||
|
|
||||||
QModelIndex activeIndex = m_projectsModel.rootItem()->childAt(0)->activeIndex();
|
QModelIndex activeIndex = projectItem->activeIndex();
|
||||||
|
m_selectorTree->expandAll();
|
||||||
m_selectorTree->selectionModel()->clear();
|
m_selectorTree->selectionModel()->clear();
|
||||||
m_selectorTree->selectionModel()->select(activeIndex, QItemSelectionModel::Select);
|
m_selectorTree->selectionModel()->select(activeIndex, QItemSelectionModel::Select);
|
||||||
}
|
}
|
||||||
|
@@ -42,6 +42,7 @@ enum {
|
|||||||
ItemActivatedFromBelowRole, // A subitem gots activated and gives us the opportunity to adjust
|
ItemActivatedFromBelowRole, // A subitem gots activated and gives us the opportunity to adjust
|
||||||
ItemActivatedFromAboveRole, // A parent item gots activated and makes us its active child.
|
ItemActivatedFromAboveRole, // A parent item gots activated and makes us its active child.
|
||||||
ItemDeactivatedFromBelowRole, // A subitem got deactivated and gives us the opportunity to adjust
|
ItemDeactivatedFromBelowRole, // A subitem got deactivated and gives us the opportunity to adjust
|
||||||
|
ItemUpdatedFromBelowRole, // A subitem got updated, re-expansion is necessary.
|
||||||
ActiveItemRole, // The index of the currently selected item in the tree view
|
ActiveItemRole, // The index of the currently selected item in the tree view
|
||||||
PanelWidgetRole // This item's widget to be shown as central widget.
|
PanelWidgetRole // This item's widget to be shown as central widget.
|
||||||
};
|
};
|
||||||
|
@@ -212,6 +212,7 @@ public:
|
|||||||
|
|
||||||
void handleRemovedKit(Kit *kit);
|
void handleRemovedKit(Kit *kit);
|
||||||
void handleAddedKit(Kit *kit);
|
void handleAddedKit(Kit *kit);
|
||||||
|
void handleUpdatedKit(Kit *kit);
|
||||||
|
|
||||||
void handleTargetAdded(Target *target);
|
void handleTargetAdded(Target *target);
|
||||||
void handleTargetRemoved(Target *target);
|
void handleTargetRemoved(Target *target);
|
||||||
@@ -755,6 +756,8 @@ TargetGroupItemPrivate::TargetGroupItemPrivate(TargetGroupItem *q, Project *proj
|
|||||||
this, &TargetGroupItemPrivate::handleAddedKit);
|
this, &TargetGroupItemPrivate::handleAddedKit);
|
||||||
connect(KitManager::instance(), &KitManager::kitRemoved,
|
connect(KitManager::instance(), &KitManager::kitRemoved,
|
||||||
this, &TargetGroupItemPrivate::handleRemovedKit);
|
this, &TargetGroupItemPrivate::handleRemovedKit);
|
||||||
|
connect(KitManager::instance(), &KitManager::kitUpdated,
|
||||||
|
this, &TargetGroupItemPrivate::handleUpdatedKit);
|
||||||
|
|
||||||
rebuildContents();
|
rebuildContents();
|
||||||
}
|
}
|
||||||
@@ -789,7 +792,7 @@ QVariant TargetGroupItem::data(int column, int role) const
|
|||||||
bool TargetGroupItem::setData(int column, const QVariant &data, int role)
|
bool TargetGroupItem::setData(int column, const QVariant &data, int role)
|
||||||
{
|
{
|
||||||
Q_UNUSED(data)
|
Q_UNUSED(data)
|
||||||
if (role == ItemActivatedFromBelowRole) {
|
if (role == ItemActivatedFromBelowRole || role == ItemUpdatedFromBelowRole) {
|
||||||
// Bubble up to trigger setting the active project.
|
// Bubble up to trigger setting the active project.
|
||||||
parent()->setData(column, QVariant::fromValue(static_cast<TreeItem *>(this)), role);
|
parent()->setData(column, QVariant::fromValue(static_cast<TreeItem *>(this)), role);
|
||||||
return true;
|
return true;
|
||||||
@@ -823,9 +826,16 @@ void TargetGroupItemPrivate::handleRemovedKit(Kit *kit)
|
|||||||
rebuildContents();
|
rebuildContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TargetGroupItemPrivate::handleUpdatedKit(Kit *kit)
|
||||||
|
{
|
||||||
|
Q_UNUSED(kit);
|
||||||
|
rebuildContents();
|
||||||
|
}
|
||||||
|
|
||||||
void TargetGroupItemPrivate::handleAddedKit(Kit *kit)
|
void TargetGroupItemPrivate::handleAddedKit(Kit *kit)
|
||||||
{
|
{
|
||||||
q->appendChild(new TargetItem(m_project, kit->id()));
|
if (m_project->supportsKit(kit))
|
||||||
|
q->appendChild(new TargetItem(m_project, kit->id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetItem::updateSubItems()
|
void TargetItem::updateSubItems()
|
||||||
@@ -843,8 +853,14 @@ void TargetGroupItemPrivate::rebuildContents()
|
|||||||
{
|
{
|
||||||
q->removeChildren();
|
q->removeChildren();
|
||||||
|
|
||||||
foreach (Kit *kit, KitManager::sortKits(KitManager::kits()))
|
KitMatcher matcher([this](const Kit *kit) { return m_project->supportsKit(const_cast<Kit *>(kit)); });
|
||||||
|
const QList<Kit *> kits = KitManager::sortKits(KitManager::matchingKits(matcher));
|
||||||
|
for (Kit *kit : kits)
|
||||||
q->appendChild(new TargetItem(m_project, kit->id()));
|
q->appendChild(new TargetItem(m_project, kit->id()));
|
||||||
|
|
||||||
|
if (q->parent())
|
||||||
|
q->parent()->setData(0, QVariant::fromValue(static_cast<TreeItem *>(q)),
|
||||||
|
ItemUpdatedFromBelowRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetGroupItemPrivate::handleTargetAdded(Target *target)
|
void TargetGroupItemPrivate::handleTargetAdded(Target *target)
|
||||||
|
Reference in New Issue
Block a user