forked from qt-creator/qt-creator
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:
committed by
Yasser Grimes
parent
f8792dc9e6
commit
9bfc0a5b26
@@ -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()
|
||||
{
|
||||
McuTargetPtr mcuTarget = currentMcuTarget();
|
||||
@@ -257,9 +266,15 @@ void McuSupportOptionsWidget::showMcuTargetPackages()
|
||||
m_packagesLayout->removeRow(0);
|
||||
}
|
||||
|
||||
std::set<McuPackagePtr, McuPackageSort> packages;
|
||||
|
||||
for (const auto &package : mcuTarget->packages()) {
|
||||
if (package->label().isEmpty())
|
||||
continue;
|
||||
packages.insert(package);
|
||||
}
|
||||
|
||||
for (const auto &package : packages) {
|
||||
QWidget *packageWidget = package->widget();
|
||||
m_packagesLayout->addRow(package->label(), packageWidget);
|
||||
packageWidget->show();
|
||||
|
Reference in New Issue
Block a user