From 3ce1d7df43becdff874a9ccd647d9159c4da951b Mon Sep 17 00:00:00 2001 From: Nav Date: Wed, 1 Mar 2023 22:12:22 +0000 Subject: [PATCH] Tidying --- .../HexViewerWidget/ItemGraphicsScene.cpp | 11 ++--------- .../HexViewerWidget/ItemGraphicsView.cpp | 13 ++++++------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp index 3ea81b41..99ff1a67 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp @@ -44,6 +44,7 @@ namespace Bloom::Widgets this->displayAbsoluteAddressAction->setCheckable(true); this->setAddressType(this->state.settings.addressLabelType); + this->setItemIndexMethod(QGraphicsScene::NoIndex); QObject::connect( InsightSignals::instance(), @@ -133,7 +134,6 @@ namespace Bloom::Widgets this->addItem(this->hoverRectX); this->addItem(this->hoverRectY); - this->setItemIndexMethod(QGraphicsScene::NoIndex); } void ItemGraphicsScene::init() { @@ -152,9 +152,6 @@ namespace Bloom::Widgets ); InsightWorker::queueTask(constructHexViewerTopLevelGroupItem); - - auto* vScrollBar = this->views().first()->verticalScrollBar(); - vScrollBar->setSingleStep((ByteItem::HEIGHT + (ByteItem::BOTTOM_MARGIN / 2))); } void ItemGraphicsScene::updateStackPointer(std::uint32_t stackPointer) { @@ -282,13 +279,9 @@ namespace Bloom::Widgets auto allocatableGraphicsItemsCount = allocatableGraphicsItems.size(); const auto allocateRangeStartItemIt = this->gridPoints[gridPointIndex]; - const auto allocateRangeEndItemIt = allocateRangeStartItemIt + std::min( - std::distance(allocateRangeStartItemIt, this->flattenedItems.end() - 1), - static_cast(allocatableGraphicsItemsCount) - ); + const auto allocateRangeEndItemIt = this->flattenedItems.end(); const auto& firstItem = *allocateRangeStartItemIt; - const auto& lastItem = *allocateRangeEndItemIt; /* * Ensure that a graphics item for each parent, grandparent, etc. is allocated for the first item in the diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.cpp index 0e762b1c..6eb35438 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.cpp @@ -1,5 +1,7 @@ #include "ItemGraphicsView.hpp" +#include "ByteItem.hpp" + namespace Bloom::Widgets { using Bloom::Targets::TargetMemoryDescriptor; @@ -37,6 +39,7 @@ namespace Bloom::Widgets ); this->setScene(this->scene); + this->verticalScrollBar()->setSingleStep((ByteItem::HEIGHT + (ByteItem::BOTTOM_MARGIN / 2))); } void ItemGraphicsView::initScene() { @@ -54,14 +57,12 @@ namespace Bloom::Widgets } void ItemGraphicsView::scrollToByteItemAtAddress(Targets::TargetMemoryAddress address) { - if (this->scene != nullptr) { - this->centerOn(this->scene->getByteItemPositionByAddress(address)); - } + this->centerOn(this->scene->getByteItemPositionByAddress(address)); } bool ItemGraphicsView::event(QEvent* event) { const auto eventType = event->type(); - if (eventType == QEvent::Type::EnabledChange && this->scene != nullptr) { + if (eventType == QEvent::Type::EnabledChange) { this->scene->setEnabled(this->isEnabled()); } @@ -71,9 +72,7 @@ namespace Bloom::Widgets void ItemGraphicsView::resizeEvent(QResizeEvent* event) { QGraphicsView::resizeEvent(event); - if (this->scene != nullptr) { - this->scene->adjustSize(); - } + this->scene->adjustSize(); } void ItemGraphicsView::scrollContentsBy(int dx, int dy) {