Excluded empty peripherals from Insight registers pane
This commit is contained in:
@@ -31,8 +31,13 @@ namespace Widgets
|
||||
flattenedRegisterDescriptors,
|
||||
this
|
||||
};
|
||||
registerGroupItem->setVisible(this->expanded);
|
||||
|
||||
if (registerGroupItem->isEmpty()) {
|
||||
delete registerGroupItem;
|
||||
continue;
|
||||
}
|
||||
|
||||
registerGroupItem->setVisible(this->expanded);
|
||||
this->registerGroupItems.push_back(registerGroupItem);
|
||||
}
|
||||
|
||||
@@ -49,6 +54,16 @@ namespace Widgets
|
||||
}
|
||||
}
|
||||
|
||||
bool PeripheralItem::isEmpty() const {
|
||||
for (const auto* groupItem : this->registerGroupItems) {
|
||||
if (!groupItem->isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PeripheralItem::setExpanded(bool expanded) {
|
||||
if (expanded == this->expanded) {
|
||||
return;
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace Widgets
|
||||
Targets::TargetRegisterDescriptors& flattenedRegisterDescriptors
|
||||
);
|
||||
|
||||
[[nodiscard]] bool isEmpty() const;
|
||||
|
||||
bool isExpanded() const {
|
||||
return this->expanded;
|
||||
}
|
||||
|
||||
@@ -38,12 +38,21 @@ namespace Widgets
|
||||
flattenedRegisterDescriptors,
|
||||
this
|
||||
};
|
||||
subgroupItem->setVisible(this->expanded);
|
||||
|
||||
if (subgroupItem->isEmpty()) {
|
||||
delete subgroupItem;
|
||||
continue;
|
||||
}
|
||||
|
||||
subgroupItem->setVisible(this->expanded);
|
||||
this->childItems.emplace_back(subgroupItem);
|
||||
}
|
||||
|
||||
for (const auto& [registerKey, registerDescriptor] : this->registerGroupDescriptor.registerDescriptorsByKey) {
|
||||
if (!registerDescriptor.access.readable) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* registerItem = new RegisterItem{registerDescriptor, this->nestedLevel + 1, this};
|
||||
registerItem->setVisible(this->expanded);
|
||||
|
||||
@@ -75,6 +84,26 @@ namespace Widgets
|
||||
}
|
||||
}
|
||||
|
||||
bool RegisterGroupItem::isEmpty() const {
|
||||
for (const auto* childItem : this->childItems) {
|
||||
const auto* subgroupItem = dynamic_cast<const RegisterGroupItem*>(childItem);
|
||||
if (subgroupItem != nullptr) {
|
||||
if (!subgroupItem->isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto* registerItem = dynamic_cast<const RegisterItem*>(childItem);
|
||||
if (registerItem != nullptr) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RegisterGroupItem::setExpanded(bool expanded) {
|
||||
if (expanded == this->expanded) {
|
||||
return;
|
||||
|
||||
@@ -37,6 +37,8 @@ namespace Widgets
|
||||
QGraphicsItem* parent
|
||||
);
|
||||
|
||||
[[nodiscard]] bool isEmpty() const;
|
||||
|
||||
[[nodiscard]] bool isExpanded() const {
|
||||
return this->expanded;
|
||||
}
|
||||
|
||||
@@ -88,13 +88,18 @@ namespace Widgets
|
||||
});
|
||||
|
||||
for (const auto& [peripheralKey, peripheralDescriptor] : this->targetDescriptor.peripheralDescriptorsByKey) {
|
||||
this->peripheralItems.emplace_back(
|
||||
new PeripheralItem{
|
||||
auto* peripheralItem = new PeripheralItem{
|
||||
peripheralDescriptor,
|
||||
this->flattenedRegisterItemsByRegisterId,
|
||||
this->flattenedRegisterDescriptors
|
||||
};
|
||||
|
||||
if (peripheralItem->isEmpty()) {
|
||||
delete peripheralItem;
|
||||
continue;
|
||||
}
|
||||
);
|
||||
|
||||
this->peripheralItems.emplace_back(peripheralItem);
|
||||
}
|
||||
|
||||
this->registerListView = new ListView{
|
||||
|
||||
Reference in New Issue
Block a user