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