TargetSetupPage: Keep selected kits selected on filter change

If a selected kit stays visible after a kit filter change, then keep
this kit selected.

Kits that do not get matched by the filter are unselected automatically.

I find this way more intuitive to use: E.g. when you filter a selection,
check something while filtered and then reset the filter the selection
now stays.

Change-Id: Ib557d5149a2009725a946183445911f13db76af5
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Tobias Hunger
2020-02-05 12:52:37 +01:00
parent faa56b1965
commit 1722a3c837

View File

@@ -498,9 +498,21 @@ void TargetSetupPage::kitSelectionChanged()
void TargetSetupPage::kitFilterChanged(const QString &filterText)
{
// Remember selected kits:
const std::vector<TargetSetupWidget *> selectedWidgets
= filtered(m_widgets, &TargetSetupWidget::isKitSelected);
const QVector<Core::Id> selectedKitIds = transform<QVector>(selectedWidgets,
[](const TargetSetupWidget *w) {
return w->kit()->id();
});
// Reset currently shown kits
reset();
setupWidgets(filterText);
// Re-select kits:
for (TargetSetupWidget *w : qAsConst(m_widgets))
w->setKitSelected(selectedKitIds.contains(w->kit()->id()));
}
void TargetSetupPage::doInitializePage()