McuSupport: Sort displayed UI elements

The elements are sorted by their CMake variable to keep the order
consistent. Otherwise they would be sorted by their pointer, which leads
to a random order every time.

Task-number: UL-6614
Change-Id: Ie3520fb312044ccca4c9dc853e00ae2710b28d1c
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Yasser Grimes <yasser.grimes@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Rainer Keller
2022-11-09 13:47:04 +01:00
committed by Yasser Grimes
parent f8792dc9e6
commit 9bfc0a5b26

View File

@@ -247,6 +247,15 @@ void McuSupportOptionsWidget::updateStatus()
} }
} }
struct McuPackageSort {
bool operator()(McuPackagePtr a, McuPackagePtr b) const {
if (a->cmakeVariableName() != b->cmakeVariableName())
return a->cmakeVariableName() > b->cmakeVariableName();
else
return a->environmentVariableName() > b->environmentVariableName();
}
};
void McuSupportOptionsWidget::showMcuTargetPackages() void McuSupportOptionsWidget::showMcuTargetPackages()
{ {
McuTargetPtr mcuTarget = currentMcuTarget(); McuTargetPtr mcuTarget = currentMcuTarget();
@@ -257,9 +266,15 @@ void McuSupportOptionsWidget::showMcuTargetPackages()
m_packagesLayout->removeRow(0); m_packagesLayout->removeRow(0);
} }
std::set<McuPackagePtr, McuPackageSort> packages;
for (const auto &package : mcuTarget->packages()) { for (const auto &package : mcuTarget->packages()) {
if (package->label().isEmpty()) if (package->label().isEmpty())
continue; continue;
packages.insert(package);
}
for (const auto &package : packages) {
QWidget *packageWidget = package->widget(); QWidget *packageWidget = package->widget();
m_packagesLayout->addRow(package->label(), packageWidget); m_packagesLayout->addRow(package->label(), packageWidget);
packageWidget->show(); packageWidget->show();