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 <eike.ziller@qt.io>
This commit is contained in:
Artem Sokolovskii
2024-06-11 14:34:27 +02:00
parent 32fdd72f14
commit 76e176afe6
2 changed files with 19 additions and 2 deletions

View File

@@ -30,7 +30,8 @@ enum {
ItemUpdatedFromBelowRole, // A subitem got updated, re-expansion is necessary. 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
KitIdRole, // The kit id in case the item is associated with a kit. 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; class ProjectWindowPrivate;

View File

@@ -170,6 +170,7 @@ public:
void ensureWidget(); void ensureWidget();
void rebuildContents(); void rebuildContents();
void ensureShowMoreItem();
void setShowAllKits(bool showAllKits) void setShowAllKits(bool showAllKits)
{ {
@@ -206,6 +207,10 @@ public:
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
return !m_p->showAllKits() ? Tr::tr("Show All Kits") : Tr::tr("Hide Inactive Kits"); return !m_p->showAllKits() ? Tr::tr("Show All Kits") : Tr::tr("Hide Inactive Kits");
} }
if (role == IsShowMoreRole)
return true;
return {}; 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() void TargetGroupItemPrivate::rebuildContents()
{ {
QGuiApplication::setOverrideCursor(Qt::WaitCursor); QGuiApplication::setOverrideCursor(Qt::WaitCursor);
@@ -829,7 +842,7 @@ void TargetGroupItemPrivate::rebuildContents()
} }
if (isAnyKitNotEnabled) if (isAnyKitNotEnabled)
q->appendChild(new ShowMoreItem(this)); ensureShowMoreItem();
if (q->parent()) { if (q->parent()) {
q->parent() q->parent()
@@ -843,6 +856,7 @@ void TargetGroupItemPrivate::handleTargetAdded(Target *target)
{ {
if (TargetItem *item = q->targetItem(target)) if (TargetItem *item = q->targetItem(target))
item->updateSubItems(); item->updateSubItems();
ensureShowMoreItem();
q->update(); q->update();
} }
@@ -850,6 +864,7 @@ void TargetGroupItemPrivate::handleTargetRemoved(Target *target)
{ {
if (TargetItem *item = q->targetItem(target)) if (TargetItem *item = q->targetItem(target))
item->updateSubItems(); item->updateSubItems();
ensureShowMoreItem();
q->parent()->setData(0, QVariant::fromValue(static_cast<TreeItem *>(q)), q->parent()->setData(0, QVariant::fromValue(static_cast<TreeItem *>(q)),
ItemDeactivatedFromBelowRole); ItemDeactivatedFromBelowRole);
} }
@@ -858,6 +873,7 @@ void TargetGroupItemPrivate::handleTargetChanged(Target *target)
{ {
if (TargetItem *item = q->targetItem(target)) if (TargetItem *item = q->targetItem(target))
item->updateSubItems(); item->updateSubItems();
ensureShowMoreItem();
q->setData(0, QVariant(), ItemActivatedFromBelowRole); q->setData(0, QVariant(), ItemActivatedFromBelowRole);
} }