From 76e176afe6bcc855461b8fea027c061c8bb82160 Mon Sep 17 00:00:00 2001 From: Artem Sokolovskii Date: Tue, 11 Jun 2024 14:34:27 +0200 Subject: [PATCH] Core: Fix "Show All Kits" button appears after configure project "Show All Kits" now button appears when project has been just configured. Change-Id: I68c61aa56aca27c98afb60ada4a4d900db404a6c Reviewed-by: Eike Ziller --- src/plugins/projectexplorer/projectwindow.h | 3 ++- .../projectexplorer/targetsettingspanel.cpp | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/projectwindow.h b/src/plugins/projectexplorer/projectwindow.h index ed88f4403e6..692cc5a287e 100644 --- a/src/plugins/projectexplorer/projectwindow.h +++ b/src/plugins/projectexplorer/projectwindow.h @@ -30,7 +30,8 @@ enum { ItemUpdatedFromBelowRole, // A subitem got updated, re-expansion is necessary. ActiveItemRole, // The index of the currently selected item in the tree view KitIdRole, // The kit id in case the item is associated with a kit. - PanelWidgetRole // This item's widget to be shown as central widget. + PanelWidgetRole, // This item's widget to be shown as central widget. + IsShowMoreRole // This item is a "show more" item. }; class ProjectWindowPrivate; diff --git a/src/plugins/projectexplorer/targetsettingspanel.cpp b/src/plugins/projectexplorer/targetsettingspanel.cpp index aba55e7a6d0..bfcb274ac1a 100644 --- a/src/plugins/projectexplorer/targetsettingspanel.cpp +++ b/src/plugins/projectexplorer/targetsettingspanel.cpp @@ -170,6 +170,7 @@ public: void ensureWidget(); void rebuildContents(); + void ensureShowMoreItem(); void setShowAllKits(bool showAllKits) { @@ -206,6 +207,10 @@ public: if (role == Qt::DisplayRole) { return !m_p->showAllKits() ? Tr::tr("Show All Kits") : Tr::tr("Hide Inactive Kits"); } + + if (role == IsShowMoreRole) + return true; + return {}; } @@ -814,6 +819,14 @@ void TargetItem::updateSubItems() } } +void TargetGroupItemPrivate::ensureShowMoreItem() +{ + if (q->findAnyChild([](TreeItem *item) { return item->data(0, IsShowMoreRole).toBool(); })) + return; + + q->appendChild(new ShowMoreItem(this)); +} + void TargetGroupItemPrivate::rebuildContents() { QGuiApplication::setOverrideCursor(Qt::WaitCursor); @@ -829,7 +842,7 @@ void TargetGroupItemPrivate::rebuildContents() } if (isAnyKitNotEnabled) - q->appendChild(new ShowMoreItem(this)); + ensureShowMoreItem(); if (q->parent()) { q->parent() @@ -843,6 +856,7 @@ void TargetGroupItemPrivate::handleTargetAdded(Target *target) { if (TargetItem *item = q->targetItem(target)) item->updateSubItems(); + ensureShowMoreItem(); q->update(); } @@ -850,6 +864,7 @@ void TargetGroupItemPrivate::handleTargetRemoved(Target *target) { if (TargetItem *item = q->targetItem(target)) item->updateSubItems(); + ensureShowMoreItem(); q->parent()->setData(0, QVariant::fromValue(static_cast(q)), ItemDeactivatedFromBelowRole); } @@ -858,6 +873,7 @@ void TargetGroupItemPrivate::handleTargetChanged(Target *target) { if (TargetItem *item = q->targetItem(target)) item->updateSubItems(); + ensureShowMoreItem(); q->setData(0, QVariant(), ItemActivatedFromBelowRole); }