Lots of tidying
This commit is contained in:
@@ -480,35 +480,41 @@ namespace Bloom
|
||||
return;
|
||||
}
|
||||
|
||||
std::optional<QString> previouslySelectedVariantName = (this->previouslySelectedVariant.has_value()) ?
|
||||
std::optional(QString::fromStdString(this->previouslySelectedVariant->name).toLower())
|
||||
std::optional<QString> previouslySelectedVariantName = (this->previouslySelectedVariant.has_value())
|
||||
? std::optional(QString::fromStdString(this->previouslySelectedVariant->name).toLower())
|
||||
: std::nullopt;
|
||||
|
||||
if (
|
||||
previouslySelectedVariantName.has_value()
|
||||
&& this->supportedVariantsByName.contains(previouslySelectedVariantName.value())
|
||||
) {
|
||||
this->selectVariant(&(this->supportedVariantsByName.at(previouslySelectedVariantName.value())));
|
||||
if (previouslySelectedVariantName.has_value()) {
|
||||
const auto previouslySelectedVariantIt = this->supportedVariantsByName.find(*previouslySelectedVariantName);
|
||||
|
||||
} else if (this->targetConfig.variantName.has_value()) {
|
||||
auto selectedVariantName = QString::fromStdString(this->targetConfig.variantName.value());
|
||||
if (this->supportedVariantsByName.contains(selectedVariantName)) {
|
||||
// The user has specified a valid variant name in their config file, so use that as the default
|
||||
this->selectVariant(&(this->supportedVariantsByName.at(selectedVariantName)));
|
||||
|
||||
} else {
|
||||
Logger::error("Invalid target variant name \"" + this->targetConfig.variantName.value()
|
||||
+ "\" - no such variant with the given name was found.");
|
||||
if (previouslySelectedVariantIt != this->supportedVariantsByName.end()) {
|
||||
this->selectVariant(&(previouslySelectedVariantIt->second));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->selectedVariant == nullptr) {
|
||||
/*
|
||||
* Given that we haven't been able to select a variant at this point, we will just fall back to the first
|
||||
* one that is available.
|
||||
*/
|
||||
this->selectVariant(&(this->supportedVariantsByName.begin()->second));
|
||||
if (this->targetConfig.variantName.has_value()) {
|
||||
const auto variantIt = this->supportedVariantsByName.find(
|
||||
QString::fromStdString(*this->targetConfig.variantName)
|
||||
);
|
||||
|
||||
if (variantIt != this->supportedVariantsByName.end()) {
|
||||
// The user has specified a valid variant name in their config file, so use that as the default
|
||||
this->selectVariant(&(variantIt->second));
|
||||
|
||||
} else {
|
||||
Logger::error(
|
||||
"Invalid target variant name \"" + this->targetConfig.variantName.value()
|
||||
+ "\" - no such variant with the given name was found."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Given that we haven't been able to select a variant at this point, we will just fall back to the first
|
||||
* one that is available.
|
||||
*/
|
||||
this->selectVariant(&(this->supportedVariantsByName.begin()->second));
|
||||
}
|
||||
|
||||
void InsightWindow::selectVariant(const TargetVariant* variant) {
|
||||
@@ -598,19 +604,22 @@ namespace Bloom
|
||||
|
||||
// Target memory inspection panes
|
||||
auto* bottomPanelLayout = this->bottomPanel->layout();
|
||||
if (this->targetDescriptor.memoryDescriptorsByType.contains(TargetMemoryType::RAM)) {
|
||||
|
||||
// We only support inspection of RAM and EEPROM, for now.
|
||||
const auto ramDescriptorIt = this->targetDescriptor.memoryDescriptorsByType.find(TargetMemoryType::RAM);
|
||||
const auto eepromDescriptorIt = this->targetDescriptor.memoryDescriptorsByType.find(TargetMemoryType::EEPROM);
|
||||
|
||||
if (ramDescriptorIt != this->targetDescriptor.memoryDescriptorsByType.end()) {
|
||||
if (!this->insightProjectSettings.ramInspectionPaneState.has_value()) {
|
||||
this->insightProjectSettings.ramInspectionPaneState = PaneState(false, true, std::nullopt);
|
||||
}
|
||||
|
||||
auto& ramDescriptor = this->targetDescriptor.memoryDescriptorsByType.at(TargetMemoryType::RAM);
|
||||
|
||||
if (!memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::RAM)) {
|
||||
memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::RAM] = TargetMemoryInspectionPaneSettings();
|
||||
}
|
||||
|
||||
this->ramInspectionPane = new TargetMemoryInspectionPane(
|
||||
ramDescriptor,
|
||||
ramDescriptorIt->second,
|
||||
memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::RAM],
|
||||
*(this->insightProjectSettings.ramInspectionPaneState),
|
||||
this->bottomPanel
|
||||
@@ -641,19 +650,17 @@ namespace Bloom
|
||||
this->onRamInspectionPaneStateChanged();
|
||||
}
|
||||
|
||||
if (this->targetDescriptor.memoryDescriptorsByType.contains(TargetMemoryType::EEPROM)) {
|
||||
if (eepromDescriptorIt != this->targetDescriptor.memoryDescriptorsByType.end()) {
|
||||
if (!this->insightProjectSettings.eepromInspectionPaneState.has_value()) {
|
||||
this->insightProjectSettings.eepromInspectionPaneState = PaneState(false, true, std::nullopt);
|
||||
}
|
||||
|
||||
auto& eepromDescriptor = this->targetDescriptor.memoryDescriptorsByType.at(TargetMemoryType::EEPROM);
|
||||
|
||||
if (!memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::EEPROM)) {
|
||||
memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::EEPROM] = TargetMemoryInspectionPaneSettings();
|
||||
}
|
||||
|
||||
this->eepromInspectionPane = new TargetMemoryInspectionPane(
|
||||
eepromDescriptor,
|
||||
eepromDescriptorIt->second,
|
||||
memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::EEPROM],
|
||||
*(this->insightProjectSettings.eepromInspectionPaneState),
|
||||
this->bottomPanel
|
||||
|
||||
@@ -94,9 +94,11 @@ namespace Bloom
|
||||
}
|
||||
|
||||
QWidget* UiLoader::createWidget(const QString& className, QWidget* parent, const QString& name) {
|
||||
if (this->customWidgetConstructorsByWidgetName.contains(className)) {
|
||||
const auto widgetContructorIt = this->customWidgetConstructorsByWidgetName.find(className);
|
||||
|
||||
if (widgetContructorIt != this->customWidgetConstructorsByWidgetName.end()) {
|
||||
// This is a custom widget - call the mapped constructor
|
||||
return this->customWidgetConstructorsByWidgetName.at(className)(parent, name);
|
||||
return widgetContructorIt->second(parent, name);
|
||||
}
|
||||
|
||||
return QUiLoader::createWidget(className, parent, name);
|
||||
|
||||
@@ -312,8 +312,9 @@ namespace Bloom::Widgets
|
||||
}
|
||||
|
||||
QPointF ByteItemGraphicsScene::getByteItemPositionByAddress(std::uint32_t address) {
|
||||
if (this->byteItemsByAddress.contains(address)) {
|
||||
return this->byteItemsByAddress.at(address)->pos();
|
||||
const auto byteItemIt = this->byteItemsByAddress.find(address);
|
||||
if (byteItemIt != this->byteItemsByAddress.end()) {
|
||||
return byteItemIt->second->pos();
|
||||
}
|
||||
|
||||
return QPointF();
|
||||
@@ -623,12 +624,13 @@ namespace Bloom::Widgets
|
||||
}
|
||||
|
||||
for (auto* annotationItem : this->annotationItems) {
|
||||
if (!this->byteItemsByAddress.contains(annotationItem->startAddress)) {
|
||||
const auto firstByteItemIt = this->byteItemsByAddress.find(annotationItem->startAddress);
|
||||
if (firstByteItemIt == this->byteItemsByAddress.end()) {
|
||||
annotationItem->hide();
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto firstByteItemPosition = this->byteItemsByAddress.at(annotationItem->startAddress)->pos();
|
||||
const auto firstByteItemPosition = firstByteItemIt->second->pos();
|
||||
|
||||
if (annotationItem->position == AnnotationItemPosition::TOP) {
|
||||
annotationItem->setPos(
|
||||
@@ -646,7 +648,6 @@ namespace Bloom::Widgets
|
||||
}
|
||||
|
||||
void ByteItemGraphicsScene::onTargetStateChanged(Targets::TargetState newState) {
|
||||
using Targets::TargetState;
|
||||
this->targetState = newState;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,22 +42,24 @@ namespace Bloom::Widgets
|
||||
this->endAddressInput->text().toUInt(nullptr, 16)
|
||||
);
|
||||
this->memoryRegion.addressRangeInputType = this->getSelectedAddressInputType();
|
||||
this->memoryRegion.addressRange =
|
||||
this->memoryRegion.addressRangeInputType == AddressType::RELATIVE ?
|
||||
this->convertRelativeToAbsoluteAddressRange(inputAddressRange) : inputAddressRange;
|
||||
this->memoryRegion.addressRange = this->memoryRegion.addressRangeInputType == AddressType::RELATIVE
|
||||
? this->convertRelativeToAbsoluteAddressRange(inputAddressRange)
|
||||
: inputAddressRange;
|
||||
|
||||
auto selectedDataTypeOptionName = this->dataTypeInput->currentData().toString();
|
||||
if (FocusedRegionItem::dataTypeOptionsByName.contains(selectedDataTypeOptionName)) {
|
||||
this->memoryRegion.dataType = FocusedRegionItem::dataTypeOptionsByName.at(
|
||||
selectedDataTypeOptionName
|
||||
).dataType;
|
||||
const auto selectedDataTypeIt = FocusedRegionItem::dataTypeOptionsByName.find(
|
||||
this->dataTypeInput->currentData().toString()
|
||||
);
|
||||
|
||||
if (selectedDataTypeIt != FocusedRegionItem::dataTypeOptionsByName.end()) {
|
||||
this->memoryRegion.dataType = selectedDataTypeIt->second.dataType;
|
||||
}
|
||||
|
||||
auto selectedEndiannessOptionName = this->endiannessInput->currentData().toString();
|
||||
if (FocusedRegionItem::endiannessOptionsByName.contains(selectedEndiannessOptionName)) {
|
||||
this->memoryRegion.endianness = FocusedRegionItem::endiannessOptionsByName.at(
|
||||
selectedEndiannessOptionName
|
||||
).endianness;
|
||||
const auto selectedEndiannessIt = FocusedRegionItem::endiannessOptionsByName.find(
|
||||
this->endiannessInput->currentData().toString()
|
||||
);
|
||||
|
||||
if (selectedEndiannessIt != FocusedRegionItem::endiannessOptionsByName.end()) {
|
||||
this->memoryRegion.endianness = selectedEndiannessIt->second.endianness;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -176,9 +176,12 @@ namespace Bloom::Widgets
|
||||
}
|
||||
|
||||
AddressType RegionItem::getSelectedAddressInputType() const {
|
||||
auto selectedAddressTypeOptionName = this->addressTypeInput->currentData().toString();
|
||||
if (RegionItem::addressRangeTypeOptionsByName.contains(selectedAddressTypeOptionName)) {
|
||||
return RegionItem::addressRangeTypeOptionsByName.at(selectedAddressTypeOptionName).addressType;
|
||||
const auto selectedAddressTypeIt = RegionItem::addressRangeTypeOptionsByName.find(
|
||||
this->addressTypeInput->currentData().toString()
|
||||
);
|
||||
|
||||
if (selectedAddressTypeIt != RegionItem::addressRangeTypeOptionsByName.end()) {
|
||||
return selectedAddressTypeIt->second.addressType;
|
||||
}
|
||||
|
||||
return AddressType::ABSOLUTE;
|
||||
|
||||
@@ -395,7 +395,8 @@ namespace Bloom::Widgets
|
||||
};
|
||||
|
||||
for (const auto& focusedRegion : this->settings.focusedMemoryRegions) {
|
||||
if (!this->targetMemoryDescriptor.addressRange.contains(focusedRegion.addressRange)
|
||||
if (
|
||||
!this->targetMemoryDescriptor.addressRange.contains(focusedRegion.addressRange)
|
||||
|| regionIntersects(focusedRegion)
|
||||
) {
|
||||
continue;
|
||||
@@ -405,7 +406,8 @@ namespace Bloom::Widgets
|
||||
}
|
||||
|
||||
for (const auto& excludedRegion : this->settings.excludedMemoryRegions) {
|
||||
if (!this->targetMemoryDescriptor.addressRange.contains(excludedRegion.addressRange)
|
||||
if (
|
||||
!this->targetMemoryDescriptor.addressRange.contains(excludedRegion.addressRange)
|
||||
|| regionIntersects(excludedRegion)
|
||||
) {
|
||||
continue;
|
||||
|
||||
@@ -243,10 +243,10 @@ namespace Bloom::Widgets
|
||||
const auto& descriptor = targetRegister.descriptor;
|
||||
|
||||
for (const auto& registerGroupWidget : this->registerGroupWidgets) {
|
||||
if (registerGroupWidget->registerWidgetsMappedByDescriptor.contains(descriptor)) {
|
||||
registerGroupWidget->registerWidgetsMappedByDescriptor.at(
|
||||
descriptor
|
||||
)->setRegisterValue(targetRegister);
|
||||
const auto registerWidgetit = registerGroupWidget->registerWidgetsMappedByDescriptor.find(descriptor);
|
||||
|
||||
if (registerWidgetit != registerGroupWidget->registerWidgetsMappedByDescriptor.end()) {
|
||||
registerWidgetit->second->setRegisterValue(targetRegister);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,9 +73,10 @@ namespace Bloom::Widgets::InsightTargetWidgets
|
||||
|
||||
void TargetPackageWidget::updatePinStates(const Targets::TargetPinStateMapping& pinStatesByNumber) {
|
||||
for (auto& pinWidget : this->pinWidgets) {
|
||||
auto pinNumber = pinWidget->getPinNumber();
|
||||
if (pinStatesByNumber.contains(pinNumber)) {
|
||||
pinWidget->updatePinState(pinStatesByNumber.at(pinNumber));
|
||||
const auto pinStateIt = pinStatesByNumber.find(pinWidget->getPinNumber());
|
||||
|
||||
if (pinStateIt != pinStatesByNumber.end()) {
|
||||
pinWidget->updatePinState(pinStateIt->second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user