Refactoring in printing of byte address items in hex viewier widget.

This commit is contained in:
Nav
2021-12-15 22:09:21 +00:00
parent 7ca9327dc5
commit b3ceab5501

View File

@@ -23,13 +23,13 @@ void ByteAddressContainer::adjustAddressLabels(
for (const auto& mappingPair : byteItemsByRowIndex) { for (const auto& mappingPair : byteItemsByRowIndex) {
const auto rowIndex = static_cast<std::size_t>(mappingPair.first); const auto rowIndex = static_cast<std::size_t>(mappingPair.first);
const auto& byteWidgets = mappingPair.second; const auto& byteItems = mappingPair.second;
if (byteWidgets.empty()) { if (byteItems.empty()) {
continue; continue;
} }
ByteAddressItem* addressLabel; ByteAddressItem* addressLabel = nullptr;
if (static_cast<int>(rowIndex) > layoutItemMaxIndex) { if (static_cast<int>(rowIndex) > layoutItemMaxIndex) {
addressLabel = new ByteAddressItem(this); addressLabel = new ByteAddressItem(this);
this->addressItemsByRowIndex.insert(std::pair(rowIndex, addressLabel)); this->addressItemsByRowIndex.insert(std::pair(rowIndex, addressLabel));
@@ -38,10 +38,11 @@ void ByteAddressContainer::adjustAddressLabels(
addressLabel = this->addressItemsByRowIndex.at(rowIndex); addressLabel = this->addressItemsByRowIndex.at(rowIndex);
} }
addressLabel->setAddressHex(byteWidgets.front()->relativeAddressHex); const auto& firstByteItem = byteItems.front();
addressLabel->setAddressHex(firstByteItem->relativeAddressHex);
addressLabel->setPos( addressLabel->setPos(
0, 0,
margins.top() + static_cast<double>(rowIndex * (ByteAddressItem::HEIGHT + ByteItem::BOTTOM_MARGIN)) firstByteItem->pos().y()
); );
} }