Refactored Insight GUI to accommodate the many changes made to Bloom's internals
Also lots of tidying.
This commit is contained in:
@@ -29,14 +29,11 @@ target_sources(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/InsightWorkerTask.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/ReadTargetRegisters.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/WriteTargetRegister.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/RefreshTargetPinStates.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/SetTargetPinState.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/ReadTargetGpioPadStates.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/SetTargetGpioPadState.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/ReadTargetMemory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/WriteTargetMemory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/ReadStackPointer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/ReadProgramCounter.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/GetTargetState.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/GetTargetDescriptor.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/CaptureMemorySnapshot.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/RetrieveMemorySnapshots.cpp
|
||||
@@ -73,6 +70,7 @@ target_sources(
|
||||
|
||||
# Target register side pane
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/PeripheralItem.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterGroupItem.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterItem.cpp
|
||||
|
||||
@@ -87,6 +85,7 @@ target_sources(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitBodyWidget.cpp
|
||||
|
||||
# Target memory inspection pane
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ToolButton.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.cpp
|
||||
|
||||
@@ -5,17 +5,14 @@
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include "src/Services/PathService.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
#include "src/EventManager/EventManager.hpp"
|
||||
#include "UserInterfaces/InsightWindow/BloomProxyStyle.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
#include "src/Application.hpp"
|
||||
|
||||
#include "InsightWorker/Tasks/GetTargetState.hpp"
|
||||
#include "InsightWorker/Tasks/GetTargetDescriptor.hpp"
|
||||
|
||||
using namespace Exceptions;
|
||||
using Targets::TargetState;
|
||||
using Targets::TargetExecutionState;
|
||||
|
||||
Insight::Insight(
|
||||
EventListener& eventListener,
|
||||
@@ -31,15 +28,13 @@ Insight::Insight(
|
||||
, environmentConfig(environmentConfig)
|
||||
, insightConfig(insightConfig)
|
||||
, insightProjectSettings(insightProjectSettings)
|
||||
, targetDescriptor(this->targetControllerService.getTargetDescriptor())
|
||||
, targetState(this->targetControllerService.getTargetState())
|
||||
{
|
||||
Logger::info("Starting Insight");
|
||||
|
||||
this->eventListener.registerCallbackForEventType<Events::TargetExecutionStopped>(
|
||||
std::bind(&Insight::onTargetStoppedEvent, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
this->eventListener.registerCallbackForEventType<Events::TargetExecutionResumed>(
|
||||
std::bind(&Insight::onTargetResumedEvent, this, std::placeholders::_1)
|
||||
this->eventListener.registerCallbackForEventType<Events::TargetStateChanged>(
|
||||
std::bind(&Insight::onTargetStateChangedEvent, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
this->eventListener.registerCallbackForEventType<Events::TargetReset>(
|
||||
@@ -63,13 +58,11 @@ Insight::Insight(
|
||||
);
|
||||
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
QApplication::setStyle(new BloomProxyStyle());
|
||||
QApplication::setStyle(new BloomProxyStyle{});
|
||||
|
||||
qRegisterMetaType<Targets::TargetDescriptor>();
|
||||
qRegisterMetaType<Targets::TargetPinDescriptor>();
|
||||
qRegisterMetaType<Targets::TargetPinState>();
|
||||
qRegisterMetaType<Targets::TargetState>();
|
||||
qRegisterMetaType<std::map<int, Targets::TargetPinState>>();
|
||||
|
||||
// Load Ubuntu fonts
|
||||
QFontDatabase::addApplicationFont(
|
||||
@@ -115,22 +108,23 @@ Insight::Insight(
|
||||
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-Th.ttf")
|
||||
);
|
||||
|
||||
auto globalStylesheet = QFile(
|
||||
auto globalStylesheet = QFile{
|
||||
QString::fromStdString(
|
||||
Services::PathService::compiledResourcesPath() + "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/Global.qss"
|
||||
Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/Global.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!globalStylesheet.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open global stylesheet file");
|
||||
throw Exception{"Failed to open global stylesheet file"};
|
||||
}
|
||||
|
||||
this->globalStylesheet = globalStylesheet.readAll();
|
||||
|
||||
// Construct and start worker threads
|
||||
for (std::uint8_t i = 0; i < Insight::INSIGHT_WORKER_COUNT; ++i) {
|
||||
auto* insightWorker = new InsightWorker();
|
||||
auto* workerThread = new QThread();
|
||||
for (auto i = std::uint8_t{0}; i < Insight::INSIGHT_WORKER_COUNT; ++i) {
|
||||
auto* insightWorker = new InsightWorker{};
|
||||
auto* workerThread = new QThread{};
|
||||
|
||||
workerThread->setObjectName("IW" + QString::number(insightWorker->id));
|
||||
insightWorker->moveToThread(workerThread);
|
||||
@@ -138,7 +132,7 @@ Insight::Insight(
|
||||
QObject::connect(workerThread, &QThread::finished, insightWorker, &QObject::deleteLater);
|
||||
QObject::connect(workerThread, &QThread::finished, workerThread, &QThread::deleteLater);
|
||||
|
||||
this->insightWorkersById[insightWorker->id] = std::pair(insightWorker, workerThread);
|
||||
this->insightWorkersById[insightWorker->id] = std::pair{insightWorker, workerThread};
|
||||
|
||||
Logger::debug("Starting InsightWorker" + std::to_string(insightWorker->id));
|
||||
workerThread->start();
|
||||
@@ -149,18 +143,16 @@ Insight::Insight(
|
||||
|
||||
void Insight::activateMainWindow() {
|
||||
if (this->mainWindow == nullptr) {
|
||||
this->mainWindow = new InsightWindow(
|
||||
this->mainWindow = new InsightWindow{
|
||||
this->insightProjectSettings,
|
||||
this->insightConfig,
|
||||
this->environmentConfig,
|
||||
this->targetDescriptor
|
||||
);
|
||||
this->targetDescriptor,
|
||||
this->targetState
|
||||
};
|
||||
|
||||
this->mainWindow->setStyleSheet(this->globalStylesheet);
|
||||
|
||||
QObject::connect(this->mainWindow, &QObject::destroyed, this, &Insight::onInsightWindowDestroyed);
|
||||
|
||||
this->refreshTargetState();
|
||||
}
|
||||
|
||||
this->mainWindow->show();
|
||||
@@ -186,77 +178,39 @@ void Insight::shutdown() {
|
||||
}
|
||||
}
|
||||
|
||||
void Insight::refreshTargetState() {
|
||||
const auto getTargetStateTask = QSharedPointer<GetTargetState>(new GetTargetState(), &QObject::deleteLater);
|
||||
QObject::connect(
|
||||
getTargetStateTask.get(),
|
||||
&GetTargetState::targetState,
|
||||
this,
|
||||
[this] (Targets::TargetState targetState) {
|
||||
this->lastTargetState = targetState;
|
||||
emit this->insightSignals->targetStateUpdated(this->lastTargetState);
|
||||
}
|
||||
);
|
||||
|
||||
InsightWorker::queueTask(getTargetStateTask);
|
||||
}
|
||||
|
||||
void Insight::onInsightWindowDestroyed() {
|
||||
this->mainWindow = nullptr;
|
||||
EventManager::triggerEvent(std::make_shared<Events::InsightMainWindowClosed>());
|
||||
}
|
||||
|
||||
void Insight::onTargetStoppedEvent(const Events::TargetExecutionStopped& event) {
|
||||
if (this->lastTargetState == TargetState::STOPPED) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->lastTargetState = TargetState::STOPPED;
|
||||
|
||||
if (this->targetStepping) {
|
||||
if (this->targetResumeTimer == nullptr) {
|
||||
this->targetResumeTimer = new QTimer(this);
|
||||
this->targetResumeTimer->setSingleShot(true);
|
||||
|
||||
this->targetResumeTimer->callOnTimeout(this, [this] {
|
||||
if (this->lastTargetState != TargetState::STOPPED) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit this->insightSignals->targetStateUpdated(TargetState::STOPPED);
|
||||
});
|
||||
void Insight::onTargetStateChangedEvent(const Events::TargetStateChanged& event) {
|
||||
if (event.previousState.mode != event.newState.mode) {
|
||||
if (event.newState.mode == Targets::TargetMode::PROGRAMMING) {
|
||||
emit this->insightSignals->programmingModeEnabled();
|
||||
}
|
||||
|
||||
this->targetResumeTimer->start(1500);
|
||||
if (event.newState.mode == Targets::TargetMode::DEBUGGING) {
|
||||
emit this->insightSignals->programmingModeDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.previousState.executionState == event.newState.executionState) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->targetResumeTimer != nullptr && this->targetResumeTimer->isActive()) {
|
||||
this->targetResumeTimer->stop();
|
||||
}
|
||||
|
||||
emit this->insightSignals->targetStateUpdated(TargetState::STOPPED);
|
||||
}
|
||||
|
||||
void Insight::onTargetResumedEvent(const Events::TargetExecutionResumed& event) {
|
||||
this->targetStepping = event.stepping;
|
||||
|
||||
if (this->lastTargetState != TargetState::RUNNING) {
|
||||
this->lastTargetState = TargetState::RUNNING;
|
||||
emit this->insightSignals->targetStateUpdated(TargetState::RUNNING);
|
||||
}
|
||||
emit this->insightSignals->targetStateUpdated(event.newState, event.previousState);
|
||||
}
|
||||
|
||||
void Insight::onTargetResetEvent(const Events::TargetReset& event) {
|
||||
try {
|
||||
if (this->lastTargetState != TargetState::STOPPED) {
|
||||
this->lastTargetState = TargetState::STOPPED;
|
||||
emit this->insightSignals->targetStateUpdated(TargetState::STOPPED);
|
||||
if (this->targetState.executionState != TargetExecutionState::STOPPED) {
|
||||
// Reset event came in too late, target has already resumed execution. Ignore
|
||||
return;
|
||||
}
|
||||
|
||||
emit this->insightSignals->targetReset();
|
||||
|
||||
} catch (const Exceptions::Exception& exception) {
|
||||
} catch (const Exception& exception) {
|
||||
Logger::debug("Error handling TargetReset event - " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -267,8 +221,9 @@ void Insight::onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarg
|
||||
|
||||
void Insight::onTargetMemoryWrittenEvent(const Events::MemoryWrittenToTarget& event) {
|
||||
emit this->insightSignals->targetMemoryWritten(
|
||||
event.memoryType,
|
||||
Targets::TargetMemoryAddressRange(event.startAddress, event.startAddress + (event.size - 1))
|
||||
event.addressSpaceDescriptor,
|
||||
event.memorySegmentDescriptor,
|
||||
Targets::TargetMemoryAddressRange{event.startAddress, event.startAddress + (event.size - 1)}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
|
||||
#include "src/Helpers/Thread.hpp"
|
||||
#include "src/Services/PathService.hpp"
|
||||
@@ -75,25 +74,20 @@ private:
|
||||
|
||||
InsightProjectSettings& insightProjectSettings;
|
||||
|
||||
Services::TargetControllerService targetControllerService = Services::TargetControllerService();
|
||||
Services::TargetControllerService targetControllerService = {};
|
||||
|
||||
Targets::TargetDescriptor targetDescriptor = this->targetControllerService.getTargetDescriptor();
|
||||
const Targets::TargetDescriptor& targetDescriptor;
|
||||
const Targets::TargetState& targetState;
|
||||
|
||||
QString globalStylesheet;
|
||||
|
||||
std::map<decltype(InsightWorker::id), std::pair<InsightWorker*, QThread*>> insightWorkersById;
|
||||
InsightWindow* mainWindow = nullptr;
|
||||
|
||||
Targets::TargetState lastTargetState = Targets::TargetState::UNKNOWN;
|
||||
bool targetStepping = false;
|
||||
QTimer* targetResumeTimer = nullptr;
|
||||
|
||||
InsightSignals* insightSignals = InsightSignals::instance();
|
||||
|
||||
void refreshTargetState();
|
||||
void onInsightWindowDestroyed();
|
||||
void onTargetStoppedEvent(const Events::TargetExecutionStopped& event);
|
||||
void onTargetResumedEvent(const Events::TargetExecutionResumed& event);
|
||||
void onTargetStateChangedEvent(const Events::TargetStateChanged& event);
|
||||
void onTargetResetEvent(const Events::TargetReset& event);
|
||||
void onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event);
|
||||
void onTargetMemoryWrittenEvent(const Events::MemoryWrittenToTarget& event);
|
||||
|
||||
@@ -5,9 +5,12 @@
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
#include "src/Targets/TargetDescriptor.hpp"
|
||||
#include "src/Targets/TargetRegisterDescriptor.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
|
||||
#include "InsightWorker/Tasks/InsightWorkerTask.hpp"
|
||||
|
||||
/**
|
||||
@@ -20,7 +23,7 @@ class InsightSignals: public QObject
|
||||
|
||||
public:
|
||||
static InsightSignals* instance() {
|
||||
static auto instance = InsightSignals();
|
||||
static auto instance = InsightSignals{};
|
||||
return &instance;
|
||||
}
|
||||
|
||||
@@ -31,10 +34,14 @@ signals:
|
||||
void taskQueued(QSharedPointer<InsightWorkerTask> task);
|
||||
void taskProcessed(QSharedPointer<InsightWorkerTask> task);
|
||||
|
||||
void targetStateUpdated(Targets::TargetState newState);
|
||||
void targetStateUpdated(Targets::TargetState newState, Targets::TargetState previousState);
|
||||
void targetReset();
|
||||
void targetRegistersWritten(const Targets::TargetRegisters& targetRegisters, const QDateTime& timestamp);
|
||||
void targetMemoryWritten(Targets::TargetMemoryType memoryType, Targets::TargetMemoryAddressRange addressRange);
|
||||
void targetRegistersWritten(const Targets::TargetRegisterDescriptorAndValuePairs& targetRegisters, const QDateTime& timestamp);
|
||||
void targetMemoryWritten(
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
Targets::TargetMemoryAddressRange addressRange
|
||||
);
|
||||
void programmingModeEnabled();
|
||||
void programmingModeDisabled();
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ void InsightWorker::executeTasks() {
|
||||
return std::nullopt;
|
||||
};
|
||||
|
||||
auto queuedTask = std::optional<QSharedPointer<InsightWorkerTask>>();
|
||||
auto queuedTask = std::optional<QSharedPointer<InsightWorkerTask>>{};
|
||||
|
||||
while ((queuedTask = getQueuedTask())) {
|
||||
auto& task = *queuedTask;
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
static inline Synchronised<std::map<InsightWorkerTask::IdType, QSharedPointer<InsightWorkerTask>>> queuedTasksById = {};
|
||||
static inline Synchronised<TaskGroups> taskGroupsInExecution = {};
|
||||
|
||||
Services::TargetControllerService targetControllerService = Services::TargetControllerService();
|
||||
Services::TargetControllerService targetControllerService = {};
|
||||
|
||||
void executeTasks();
|
||||
};
|
||||
|
||||
@@ -13,52 +13,58 @@ using Services::TargetControllerService;
|
||||
CaptureMemorySnapshot::CaptureMemorySnapshot(
|
||||
const QString& name,
|
||||
const QString& description,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const std::vector<FocusedMemoryRegion>& focusedRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedRegions,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data
|
||||
)
|
||||
: name(name)
|
||||
, description(description)
|
||||
, memoryType(memoryType)
|
||||
, addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, focusedRegions(focusedRegions)
|
||||
, excludedRegions(excludedRegions)
|
||||
, data(data)
|
||||
{}
|
||||
|
||||
QString CaptureMemorySnapshot::brief() const {
|
||||
return "Capturing memory snapshot";
|
||||
}
|
||||
|
||||
TaskGroups CaptureMemorySnapshot::taskGroups() const {
|
||||
return {
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
};
|
||||
}
|
||||
|
||||
void CaptureMemorySnapshot::run(TargetControllerService& targetControllerService) {
|
||||
using Targets::TargetMemorySize;
|
||||
|
||||
Logger::info("Capturing snapshot");
|
||||
|
||||
const auto& targetDescriptor = targetControllerService.getTargetDescriptor();
|
||||
const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType);
|
||||
|
||||
if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) {
|
||||
throw Exceptions::Exception("Invalid memory type");
|
||||
}
|
||||
|
||||
const auto& memoryDescriptor = memoryDescriptorIt->second;
|
||||
const auto memorySize = memoryDescriptor.size();
|
||||
const auto memorySize = this->memorySegmentDescriptor.size();
|
||||
|
||||
if (!this->data.has_value()) {
|
||||
Logger::info("Reading data for snapshot capture");
|
||||
|
||||
this->data = Targets::TargetMemoryBuffer();
|
||||
this->data = Targets::TargetMemoryBuffer{};
|
||||
this->data->reserve(memorySize);
|
||||
|
||||
const auto readSize = std::max(
|
||||
TargetMemorySize(256),
|
||||
memoryDescriptor.pageSize.value_or(TargetMemorySize(0))
|
||||
TargetMemorySize{256},
|
||||
this->memorySegmentDescriptor.pageSize.value_or(TargetMemorySize{0})
|
||||
);
|
||||
const auto readsRequired = static_cast<std::uint32_t>(
|
||||
std::ceil(static_cast<float>(memorySize) / static_cast<float>(readSize))
|
||||
);
|
||||
|
||||
for (std::uint32_t i = 0; i < readsRequired; i++) {
|
||||
for (auto i = std::size_t{0}; i < readsRequired; i++) {
|
||||
auto dataSegment = targetControllerService.readMemory(
|
||||
this->memoryType,
|
||||
memoryDescriptor.addressRange.startAddress + static_cast<Targets::TargetMemoryAddress>(readSize * i),
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->memorySegmentDescriptor.addressRange.startAddress
|
||||
+ static_cast<Targets::TargetMemoryAddress>(readSize * i),
|
||||
(memorySize - this->data->size()) >= readSize
|
||||
? readSize
|
||||
: static_cast<Targets::TargetMemorySize>(memorySize - this->data->size()),
|
||||
@@ -75,32 +81,31 @@ void CaptureMemorySnapshot::run(TargetControllerService& targetControllerService
|
||||
|
||||
assert(this->data->size() == memorySize);
|
||||
|
||||
auto snapshot = MemorySnapshot(
|
||||
std::move(this->name),
|
||||
std::move(this->description),
|
||||
this->memoryType,
|
||||
std::move(*this->data),
|
||||
auto snapshot = MemorySnapshot{
|
||||
this->name,
|
||||
this->description,
|
||||
QString::fromStdString(this->addressSpaceDescriptor.key),
|
||||
QString::fromStdString(this->memorySegmentDescriptor.key),
|
||||
*this->data,
|
||||
targetControllerService.getProgramCounter(),
|
||||
targetControllerService.getStackPointer(),
|
||||
std::move(this->focusedRegions),
|
||||
std::move(this->excludedRegions)
|
||||
);
|
||||
|
||||
const auto snapshotDirPath = QString::fromStdString(Services::PathService::projectSettingsDirPath())
|
||||
+ "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(snapshot.memoryType);
|
||||
this->focusedRegions,
|
||||
this->excludedRegions
|
||||
};
|
||||
|
||||
const auto snapshotDirPath = QString::fromStdString(Services::PathService::memorySnapshotsPath());
|
||||
QDir().mkpath(snapshotDirPath);
|
||||
|
||||
const auto snapshotFilePath = snapshotDirPath + "/" + snapshot.id + ".json";
|
||||
|
||||
auto outputFile = QFile(snapshotFilePath);
|
||||
auto outputFile = QFile{snapshotFilePath};
|
||||
|
||||
if (!outputFile.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) {
|
||||
Logger::error("Failed to save snapshot - cannot open " + snapshotFilePath.toStdString());
|
||||
return;
|
||||
}
|
||||
|
||||
outputFile.write(QJsonDocument(snapshot.toJson()).toJson(QJsonDocument::JsonFormat::Compact));
|
||||
outputFile.write(QJsonDocument{snapshot.toJson()}.toJson(QJsonDocument::JsonFormat::Compact));
|
||||
outputFile.close();
|
||||
|
||||
Logger::info("Snapshot captured - UUID: " + snapshot.id.toStdString());
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
#include "InsightWorkerTask.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp"
|
||||
|
||||
class CaptureMemorySnapshot: public InsightWorkerTask
|
||||
@@ -16,21 +19,15 @@ public:
|
||||
CaptureMemorySnapshot(
|
||||
const QString& name,
|
||||
const QString& description,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const std::vector<FocusedMemoryRegion>& focusedRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedRegions,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data
|
||||
);
|
||||
|
||||
QString brief() const override {
|
||||
return "Capturing memory snapshot";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
[[nodiscard]] QString brief() const override;
|
||||
[[nodiscard]] TaskGroups taskGroups() const override;
|
||||
|
||||
signals:
|
||||
void memorySnapshotCaptured(MemorySnapshot snapshot);
|
||||
@@ -41,7 +38,8 @@ protected:
|
||||
private:
|
||||
QString name;
|
||||
QString description;
|
||||
Targets::TargetMemoryType memoryType;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
std::vector<FocusedMemoryRegion> focusedRegions;
|
||||
std::vector<ExcludedMemoryRegion> excludedRegions;
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@ ConstructHexViewerTopLevelGroupItem::ConstructHexViewerTopLevelGroupItem(
|
||||
, hexViewerState(hexViewerState)
|
||||
{}
|
||||
|
||||
QString ConstructHexViewerTopLevelGroupItem::brief() const {
|
||||
return "Preparing hex viewer";
|
||||
}
|
||||
|
||||
void ConstructHexViewerTopLevelGroupItem::run(Services::TargetControllerService&) {
|
||||
auto* item = new Widgets::TopLevelGroupItem(
|
||||
this->focusedMemoryRegions,
|
||||
|
||||
@@ -18,14 +18,7 @@ public:
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
const Widgets::HexViewerSharedState& hexViewerState
|
||||
);
|
||||
|
||||
QString brief() const override {
|
||||
return "Preparing hex viewer";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups();
|
||||
};
|
||||
QString brief() const override;
|
||||
|
||||
signals:
|
||||
void topLevelGroupItem(Widgets::TopLevelGroupItem* item);
|
||||
|
||||
@@ -3,30 +3,25 @@
|
||||
#include <QFile>
|
||||
|
||||
#include "src/Services/PathService.hpp"
|
||||
#include "src/Helpers/EnumToStringMappings.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
using Services::TargetControllerService;
|
||||
|
||||
DeleteMemorySnapshot::DeleteMemorySnapshot(
|
||||
const QString& snapshotId,
|
||||
Targets::TargetMemoryType memoryType
|
||||
)
|
||||
DeleteMemorySnapshot::DeleteMemorySnapshot(const QString& snapshotId)
|
||||
: snapshotId(snapshotId)
|
||||
, memoryType(memoryType)
|
||||
{}
|
||||
|
||||
void DeleteMemorySnapshot::run(TargetControllerService&) {
|
||||
using Targets::TargetMemorySize;
|
||||
QString DeleteMemorySnapshot::brief() const {
|
||||
return "Deleting memory snapshot " + this->snapshotId;
|
||||
}
|
||||
|
||||
void DeleteMemorySnapshot::run(TargetControllerService&) {
|
||||
Logger::info("Deleting snapshot " + this->snapshotId.toStdString());
|
||||
|
||||
const auto snapshotFilePath = QString::fromStdString(Services::PathService::projectSettingsDirPath())
|
||||
+ "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(this->memoryType) + "/"
|
||||
+ this->snapshotId + ".json";
|
||||
|
||||
auto snapshotFile = QFile(snapshotFilePath);
|
||||
const auto snapshotFilePath = QString::fromStdString(Services::PathService::memorySnapshotsPath())
|
||||
+ this->snapshotId + ".json";
|
||||
|
||||
auto snapshotFile = QFile{snapshotFilePath};
|
||||
if (!snapshotFile.exists()) {
|
||||
Logger::warning(
|
||||
"Could not find snapshot file for " + this->snapshotId.toStdString() + " - expected path: "
|
||||
|
||||
@@ -4,23 +4,17 @@
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
class DeleteMemorySnapshot: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DeleteMemorySnapshot(const QString& snapshotId, Targets::TargetMemoryType memoryType);
|
||||
|
||||
QString brief() const override {
|
||||
return "Deleting memory snapshot " + this->snapshotId;
|
||||
}
|
||||
explicit DeleteMemorySnapshot(const QString& snapshotId);
|
||||
[[nodiscard]] QString brief() const override ;
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
QString snapshotId;
|
||||
Targets::TargetMemoryType memoryType;
|
||||
};
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#include "GetTargetDescriptor.hpp"
|
||||
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void GetTargetDescriptor::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetDescriptor(targetControllerService.getTargetDescriptor());
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
|
||||
#include "src/Targets/TargetDescriptor.hpp"
|
||||
|
||||
class GetTargetDescriptor: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GetTargetDescriptor() = default;
|
||||
|
||||
QString brief() const override {
|
||||
return "Obtaining target descriptor";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
signals:
|
||||
void targetDescriptor(Targets::TargetDescriptor targetDescriptor);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
#include "GetTargetState.hpp"
|
||||
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void GetTargetState::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetState(targetControllerService.getTargetState());
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
|
||||
class GetTargetState: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GetTargetState() = default;
|
||||
|
||||
QString brief() const override {
|
||||
return "Obtaining target state";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
signals:
|
||||
void targetState(Targets::TargetState state);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
};
|
||||
@@ -8,6 +8,10 @@ InsightWorkerTask::InsightWorkerTask()
|
||||
: QObject(nullptr)
|
||||
{}
|
||||
|
||||
TaskGroups InsightWorkerTask::taskGroups() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
void InsightWorkerTask::execute(TargetControllerService& targetControllerService) {
|
||||
try {
|
||||
this->state = InsightWorkerTaskState::STARTED;
|
||||
@@ -19,7 +23,7 @@ void InsightWorkerTask::execute(TargetControllerService& targetControllerService
|
||||
this->setProgressPercentage(100);
|
||||
emit this->completed();
|
||||
|
||||
} catch (std::exception& exception) {
|
||||
} catch (const std::exception& exception) {
|
||||
this->state = InsightWorkerTaskState::FAILED;
|
||||
Logger::debug("InsightWorker task failed - " + std::string(exception.what()));
|
||||
emit this->failed(QString::fromStdString(exception.what()));
|
||||
|
||||
@@ -30,12 +30,8 @@ public:
|
||||
std::atomic<std::uint8_t> progressPercentage = 0;
|
||||
|
||||
InsightWorkerTask();
|
||||
|
||||
virtual QString brief() const = 0;
|
||||
|
||||
virtual TaskGroups taskGroups() const {
|
||||
return TaskGroups();
|
||||
};
|
||||
[[nodiscard]] virtual QString brief() const = 0;
|
||||
[[nodiscard]] virtual TaskGroups taskGroups() const;
|
||||
|
||||
void execute(Services::TargetControllerService& targetControllerService);
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#include "ReadProgramCounter.hpp"
|
||||
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void ReadProgramCounter::run(TargetControllerService& targetControllerService) {
|
||||
emit this->programCounterRead(targetControllerService.getProgramCounter());
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
class ReadProgramCounter: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ReadProgramCounter() = default;
|
||||
|
||||
QString brief() const override {
|
||||
return "Reading program counter";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
signals:
|
||||
void programCounterRead(Targets::TargetMemoryAddress programCounter);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
};
|
||||
@@ -2,6 +2,16 @@
|
||||
|
||||
using Services::TargetControllerService;
|
||||
|
||||
QString ReadStackPointer::brief() const {
|
||||
return "Reading stack pointer";
|
||||
}
|
||||
|
||||
TaskGroups ReadStackPointer::taskGroups() const {
|
||||
return {
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
};
|
||||
}
|
||||
|
||||
void ReadStackPointer::run(TargetControllerService& targetControllerService) {
|
||||
emit this->stackPointerRead(targetControllerService.getStackPointer());
|
||||
}
|
||||
|
||||
@@ -10,16 +10,8 @@ class ReadStackPointer: public InsightWorkerTask
|
||||
|
||||
public:
|
||||
ReadStackPointer() = default;
|
||||
|
||||
QString brief() const override {
|
||||
return "Reading stack pointer";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
[[nodiscard]] QString brief() const override;
|
||||
[[nodiscard]] TaskGroups taskGroups() const override;
|
||||
|
||||
signals:
|
||||
void stackPointerRead(Targets::TargetStackPointer stackPointer);
|
||||
|
||||
21
src/Insight/InsightWorker/Tasks/ReadTargetGpioPadStates.cpp
Normal file
21
src/Insight/InsightWorker/Tasks/ReadTargetGpioPadStates.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "ReadTargetGpioPadStates.hpp"
|
||||
|
||||
using Services::TargetControllerService;
|
||||
|
||||
ReadTargetGpioPadStates::ReadTargetGpioPadStates(const Targets::TargetPadDescriptors& padDescriptors)
|
||||
: padDescriptors(padDescriptors)
|
||||
{}
|
||||
|
||||
QString ReadTargetGpioPadStates::brief() const {
|
||||
return "Reading target pin states";
|
||||
}
|
||||
|
||||
TaskGroups ReadTargetGpioPadStates::taskGroups() const {
|
||||
return {
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
};
|
||||
}
|
||||
|
||||
void ReadTargetGpioPadStates::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetGpioPadStatesRead(targetControllerService.getGpioPadStates(this->padDescriptors));
|
||||
}
|
||||
25
src/Insight/InsightWorker/Tasks/ReadTargetGpioPadStates.hpp
Normal file
25
src/Insight/InsightWorker/Tasks/ReadTargetGpioPadStates.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
|
||||
#include "src/Targets/TargetPadDescriptor.hpp"
|
||||
#include "src/Targets/TargetGpioPadState.hpp"
|
||||
|
||||
class ReadTargetGpioPadStates: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ReadTargetGpioPadStates(const Targets::TargetPadDescriptors& padDescriptors);
|
||||
[[nodiscard]] QString brief() const override;
|
||||
[[nodiscard]] TaskGroups taskGroups() const override;
|
||||
|
||||
signals:
|
||||
void targetGpioPadStatesRead(Targets::TargetGpioPadDescriptorAndStatePairs pairs);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
const Targets::TargetPadDescriptors& padDescriptors;
|
||||
};
|
||||
@@ -1,25 +1,43 @@
|
||||
#include "ReadTargetMemory.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <QLocale>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
|
||||
using Services::TargetControllerService;
|
||||
|
||||
ReadTargetMemory::ReadTargetMemory(
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
Targets::TargetMemorySize size,
|
||||
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges
|
||||
)
|
||||
: addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, startAddress(startAddress)
|
||||
, size(size)
|
||||
, excludedAddressRanges(excludedAddressRanges)
|
||||
{}
|
||||
|
||||
QString ReadTargetMemory::brief() const {
|
||||
return "Reading " + QLocale{QLocale::English}.toString(this->size) + " byte(s) from \""
|
||||
+ QString::fromStdString(this->memorySegmentDescriptor.name) + "\" segment, via \""
|
||||
+ QString::fromStdString(this->addressSpaceDescriptor.key) + "\" address space";
|
||||
}
|
||||
|
||||
TaskGroups ReadTargetMemory::taskGroups() const {
|
||||
return {
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
};
|
||||
}
|
||||
|
||||
void ReadTargetMemory::run(TargetControllerService& targetControllerService) {
|
||||
using Targets::TargetMemorySize;
|
||||
|
||||
const auto& targetDescriptor = targetControllerService.getTargetDescriptor();
|
||||
const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType);
|
||||
|
||||
if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) {
|
||||
throw Exceptions::Exception("Invalid memory type");
|
||||
}
|
||||
|
||||
const auto& memoryDescriptor = memoryDescriptorIt->second;
|
||||
|
||||
/*
|
||||
* To prevent locking up the TargetController for too long, we split the read into numerous reads.
|
||||
*
|
||||
@@ -27,27 +45,27 @@ void ReadTargetMemory::run(TargetControllerService& targetControllerService) {
|
||||
* command timeouts when we're reading lots of data.
|
||||
*/
|
||||
const auto readSize = std::max(
|
||||
TargetMemorySize(256),
|
||||
memoryDescriptor.pageSize.value_or(TargetMemorySize(0))
|
||||
TargetMemorySize{256},
|
||||
this->memorySegmentDescriptor.pageSize.value_or(TargetMemorySize{0})
|
||||
);
|
||||
const auto readsRequired = static_cast<std::uint32_t>(
|
||||
std::ceil(static_cast<float>(this->size) / static_cast<float>(readSize))
|
||||
);
|
||||
|
||||
Targets::TargetMemoryBuffer data;
|
||||
auto data = Targets::TargetMemoryBuffer{};
|
||||
data.reserve(this->size);
|
||||
|
||||
for (std::uint32_t i = 0; i < readsRequired; i++) {
|
||||
for (auto i = std::size_t{0}; i < readsRequired; i++) {
|
||||
auto dataSegment = targetControllerService.readMemory(
|
||||
this->memoryType,
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->startAddress + static_cast<Targets::TargetMemoryAddress>(readSize * i),
|
||||
(this->size - data.size()) >= readSize
|
||||
? readSize
|
||||
: static_cast<Targets::TargetMemorySize>(this->size - data.size()),
|
||||
(this->size - data.size()) >= readSize ? readSize : static_cast<TargetMemorySize>(this->size - data.size()),
|
||||
true,
|
||||
this->excludedAddressRanges
|
||||
);
|
||||
|
||||
std::move(dataSegment.begin(), dataSegment.end(), std::back_inserter(data));
|
||||
data.insert(data.end(), dataSegment.begin(), dataSegment.end());
|
||||
this->setProgressPercentage(static_cast<std::uint8_t>(
|
||||
(static_cast<float>(i) + 1) / (static_cast<float>(readsRequired) / 100)
|
||||
));
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Helpers/EnumToStringMappings.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
|
||||
class ReadTargetMemory: public InsightWorkerTask
|
||||
{
|
||||
@@ -13,26 +12,14 @@ class ReadTargetMemory: public InsightWorkerTask
|
||||
|
||||
public:
|
||||
ReadTargetMemory(
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
Targets::TargetMemorySize size,
|
||||
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
|
||||
)
|
||||
: memoryType(memoryType)
|
||||
, startAddress(startAddress)
|
||||
, size(size)
|
||||
, excludedAddressRanges(excludedAddressRanges)
|
||||
{}
|
||||
|
||||
QString brief() const override {
|
||||
return "Reading target " + EnumToStringMappings::targetMemoryTypes.at(this->memoryType).toUpper();
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
);
|
||||
[[nodiscard]] QString brief() const override ;
|
||||
[[nodiscard]] TaskGroups taskGroups() const override;
|
||||
|
||||
signals:
|
||||
void targetMemoryRead(Targets::TargetMemoryBuffer buffer);
|
||||
@@ -41,7 +28,8 @@ protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetMemoryType memoryType;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
Targets::TargetMemoryAddress startAddress;
|
||||
Targets::TargetMemorySize size;
|
||||
std::set<Targets::TargetMemoryAddressRange> excludedAddressRanges;
|
||||
|
||||
@@ -1,7 +1,25 @@
|
||||
#include "ReadTargetRegisters.hpp"
|
||||
|
||||
#include <QLocale>
|
||||
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void ReadTargetRegisters::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetRegistersRead(targetControllerService.readRegisters(this->descriptorIds));
|
||||
ReadTargetRegisters::ReadTargetRegisters(const Targets::TargetRegisterDescriptors& descriptors)
|
||||
: descriptors(descriptors)
|
||||
{}
|
||||
|
||||
QString ReadTargetRegisters::brief() const {
|
||||
return this->descriptors.size() == 1
|
||||
? "Reading \"" + QString::fromStdString(this->descriptors.front()->name) + "\" target register"
|
||||
: "Reading " + QLocale{QLocale::English}.toString(this->descriptors.size()) + " target registers";
|
||||
}
|
||||
|
||||
TaskGroups ReadTargetRegisters::taskGroups() const {
|
||||
return {
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
};
|
||||
}
|
||||
|
||||
void ReadTargetRegisters::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetRegistersRead(targetControllerService.readRegisters(this->descriptors));
|
||||
}
|
||||
|
||||
@@ -2,33 +2,22 @@
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
#include "src/Targets/TargetRegisterDescriptor.hpp"
|
||||
#include "src/Targets/TargetRegister.hpp"
|
||||
|
||||
class ReadTargetRegisters: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ReadTargetRegisters(const Targets::TargetRegisterDescriptorIds& descriptorIds)
|
||||
: descriptorIds(descriptorIds)
|
||||
{}
|
||||
|
||||
QString brief() const override {
|
||||
return "Reading " + QString::number(this->descriptorIds.size()) + " target register(s)";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
explicit ReadTargetRegisters(const Targets::TargetRegisterDescriptors& descriptors);
|
||||
[[nodiscard]] QString brief() const override;
|
||||
[[nodiscard]] TaskGroups taskGroups() const override;
|
||||
|
||||
signals:
|
||||
void targetRegistersRead(Targets::TargetRegisters registers);
|
||||
void targetRegistersRead(Targets::TargetRegisterDescriptorAndValuePairs registers);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetRegisterDescriptorIds descriptorIds;
|
||||
Targets::TargetRegisterDescriptors descriptors;
|
||||
};
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#include "RefreshTargetPinStates.hpp"
|
||||
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void RefreshTargetPinStates::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetPinStatesRetrieved(targetControllerService.getPinStates(this->variantId));
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
#include "src/Targets/TargetPinDescriptor.hpp"
|
||||
|
||||
class RefreshTargetPinStates: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RefreshTargetPinStates(int variantId)
|
||||
: variantId(variantId)
|
||||
{}
|
||||
|
||||
QString brief() const override {
|
||||
return "Reading target pin states";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
signals:
|
||||
void targetPinStatesRetrieved(Targets::TargetPinStateMapping pinStatesByNumber);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
int variantId;
|
||||
};
|
||||
@@ -2,48 +2,74 @@
|
||||
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QStringList>
|
||||
#include <QDirIterator>
|
||||
#include <QJsonDocument>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "src/Services/PathService.hpp"
|
||||
#include "src/Helpers/EnumToStringMappings.hpp"
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
|
||||
using Services::TargetControllerService;
|
||||
|
||||
RetrieveMemorySnapshots::RetrieveMemorySnapshots(Targets::TargetMemoryType memoryType)
|
||||
: memoryType(memoryType)
|
||||
RetrieveMemorySnapshots::RetrieveMemorySnapshots(
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor
|
||||
)
|
||||
: addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, targetDescriptor(targetDescriptor)
|
||||
{}
|
||||
|
||||
void RetrieveMemorySnapshots::run(TargetControllerService& targetControllerService) {
|
||||
emit this->memorySnapshotsRetrieved(this->getSnapshots(this->memoryType));
|
||||
QString RetrieveMemorySnapshots::brief() const {
|
||||
return "Loading \"" + QString::fromStdString(this->memorySegmentDescriptor.name)
|
||||
+ "\" memory snapshots";
|
||||
}
|
||||
|
||||
std::vector<MemorySnapshot> RetrieveMemorySnapshots::getSnapshots(Targets::TargetMemoryType memoryType) {
|
||||
constexpr auto MAX_SNAPSHOTS = 30;
|
||||
auto snapshotDir = QDir(QString::fromStdString(Services::PathService::projectSettingsDirPath())
|
||||
+ "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(memoryType));
|
||||
void RetrieveMemorySnapshots::run(TargetControllerService& targetControllerService) {
|
||||
if (
|
||||
this->targetDescriptor.family == Targets::TargetFamily::AVR_8
|
||||
&& (
|
||||
this->memorySegmentDescriptor.type == Targets::TargetMemorySegmentType::FLASH
|
||||
|| this->memorySegmentDescriptor.type == Targets::TargetMemorySegmentType::EEPROM
|
||||
|| this->memorySegmentDescriptor.type == Targets::TargetMemorySegmentType::RAM
|
||||
)
|
||||
) {
|
||||
/*
|
||||
* Support for RISC-V targets was introduced in the same release as the new snapshots, so all old snapshots
|
||||
* will be for AVR targets. This is why we only need to perform snapshot migration for AVR targets.
|
||||
*/
|
||||
this->migrateOldSnapshotFiles();
|
||||
}
|
||||
|
||||
emit this->memorySnapshotsRetrieved(this->getSnapshots());
|
||||
}
|
||||
|
||||
std::vector<MemorySnapshot> RetrieveMemorySnapshots::getSnapshots() {
|
||||
constexpr auto MAX_SNAPSHOTS = 30;
|
||||
|
||||
const auto snapshotDir = QDir{QString::fromStdString(Services::PathService::memorySnapshotsPath())};
|
||||
if (!snapshotDir.exists()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto snapshots = std::vector<MemorySnapshot>();
|
||||
|
||||
const auto snapshotFileEntries = snapshotDir.entryInfoList(
|
||||
QStringList("*.json"),
|
||||
{"*.json"},
|
||||
QDir::Files,
|
||||
QDir::SortFlag::Time
|
||||
);
|
||||
|
||||
auto snapshots = std::vector<MemorySnapshot>{};
|
||||
for (const auto& snapshotFileEntry : snapshotFileEntries) {
|
||||
auto snapshotFile = QFile(snapshotFileEntry.absoluteFilePath());
|
||||
auto snapshotFile = QFile{snapshotFileEntry.absoluteFilePath()};
|
||||
|
||||
if (snapshots.size() >= MAX_SNAPSHOTS) {
|
||||
Logger::warning(
|
||||
"The total number of " + EnumToStringMappings::targetMemoryTypes.at(memoryType).toUpper().toStdString()
|
||||
+ " snapshots exceeds the hard limit of " + std::to_string(MAX_SNAPSHOTS)
|
||||
"The total number of \"" + this->memorySegmentDescriptor.key
|
||||
+ "\" snapshots exceeds the hard limit of " + std::to_string(MAX_SNAPSHOTS)
|
||||
+ ". Only the most recent " + std::to_string(MAX_SNAPSHOTS) + " snapshots will be loaded."
|
||||
);
|
||||
break;
|
||||
@@ -51,10 +77,18 @@ std::vector<MemorySnapshot> RetrieveMemorySnapshots::getSnapshots(Targets::Targe
|
||||
|
||||
try {
|
||||
if (!snapshotFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
throw Exceptions::Exception("Failed to open snapshot file");
|
||||
throw Exceptions::Exception{"Failed to open snapshot file"};
|
||||
}
|
||||
|
||||
snapshots.emplace_back(QJsonDocument::fromJson(snapshotFile.readAll()).object());
|
||||
auto snapshot = MemorySnapshot{QJsonDocument::fromJson(snapshotFile.readAll()).object(), targetDescriptor};
|
||||
if (
|
||||
snapshot.addressSpaceKey != QString::fromStdString(this->addressSpaceDescriptor.key)
|
||||
|| snapshot.memorySegmentKey != QString::fromStdString(this->memorySegmentDescriptor.key)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
snapshots.emplace_back(std::move(snapshot));
|
||||
|
||||
} catch (const Exceptions::Exception& exception) {
|
||||
Logger::error(
|
||||
@@ -68,3 +102,70 @@ std::vector<MemorySnapshot> RetrieveMemorySnapshots::getSnapshots(Targets::Targe
|
||||
|
||||
return snapshots;
|
||||
}
|
||||
|
||||
void RetrieveMemorySnapshots::migrateOldSnapshotFiles() {
|
||||
const auto newSnapshotDirPath = QString::fromStdString(Services::PathService::memorySnapshotsPath());
|
||||
auto oldSnapshotDir = QDir{
|
||||
this->memorySegmentDescriptor.type == Targets::TargetMemorySegmentType::FLASH
|
||||
? QString::fromStdString(Services::PathService::memorySnapshotsPath()) + "/flash/"
|
||||
: this->memorySegmentDescriptor.type == Targets::TargetMemorySegmentType::EEPROM
|
||||
? QString::fromStdString(Services::PathService::memorySnapshotsPath()) + "/eeprom/"
|
||||
: QString::fromStdString(Services::PathService::memorySnapshotsPath()) + "/ram/"
|
||||
};
|
||||
|
||||
if (!oldSnapshotDir.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto snapshotFileEntries = oldSnapshotDir.entryInfoList(
|
||||
{"*.json"},
|
||||
QDir::Files,
|
||||
QDir::SortFlag::Time
|
||||
);
|
||||
|
||||
for (const auto& snapshotFileEntry : snapshotFileEntries) {
|
||||
auto snapshotFile = QFile{snapshotFileEntry.absoluteFilePath()};
|
||||
Logger::info("Migrating memory snapshot file \"" + snapshotFileEntry.absoluteFilePath().toStdString() + "\"");
|
||||
|
||||
try {
|
||||
if (!snapshotFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
throw Exceptions::Exception{"Failed to open snapshot file"};
|
||||
}
|
||||
|
||||
auto snapshot = MemorySnapshot{QJsonDocument::fromJson(snapshotFile.readAll()).object(), targetDescriptor};
|
||||
if (
|
||||
snapshot.addressSpaceKey != QString::fromStdString(this->addressSpaceDescriptor.key)
|
||||
|| snapshot.memorySegmentKey != QString::fromStdString(this->memorySegmentDescriptor.key)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto snapshotFilePath = newSnapshotDirPath + "/" + snapshot.id + ".json";
|
||||
Logger::info("Saving new memory snapshot file to \"" + snapshotFilePath.toStdString() + "\"");
|
||||
|
||||
auto outputFile = QFile{snapshotFilePath};
|
||||
if (!outputFile.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) {
|
||||
Logger::error("Failed to save snapshot - cannot open " + snapshotFilePath.toStdString());
|
||||
return;
|
||||
}
|
||||
|
||||
outputFile.write(QJsonDocument{snapshot.toJson()}.toJson(QJsonDocument::JsonFormat::Compact));
|
||||
outputFile.close();
|
||||
|
||||
snapshotFile.remove();
|
||||
|
||||
} catch (const Exceptions::Exception& exception) {
|
||||
Logger::error(
|
||||
"Failed to migrate snapshot file " + snapshotFileEntry.absoluteFilePath().toStdString() + " - "
|
||||
+ exception.getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
snapshotFile.close();
|
||||
}
|
||||
|
||||
// if (oldSnapshotDir.isEmpty()) {
|
||||
// Logger::info("Deleting old snapshot directory: \"" + oldSnapshotDir.absolutePath().toStdString() + "\"");
|
||||
// oldSnapshotDir.removeRecursively();
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <QFileInfo>
|
||||
#include <QString>
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Targets/TargetDescriptor.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp"
|
||||
#include "src/Helpers/EnumToStringMappings.hpp"
|
||||
|
||||
@@ -13,12 +19,12 @@ class RetrieveMemorySnapshots: public InsightWorkerTask
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RetrieveMemorySnapshots(Targets::TargetMemoryType memoryType);
|
||||
|
||||
QString brief() const override {
|
||||
return "Loading saved " + EnumToStringMappings::targetMemoryTypes.at(this->memoryType).toUpper()
|
||||
+ " memory snapshots";
|
||||
}
|
||||
RetrieveMemorySnapshots(
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor
|
||||
);
|
||||
[[nodiscard]] QString brief() const override;
|
||||
|
||||
signals:
|
||||
void memorySnapshotsRetrieved(std::vector<MemorySnapshot> snapshots);
|
||||
@@ -27,7 +33,10 @@ protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetMemoryType memoryType;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
const Targets::TargetDescriptor& targetDescriptor;
|
||||
|
||||
std::vector<MemorySnapshot> getSnapshots(Targets::TargetMemoryType memoryType);
|
||||
std::vector<MemorySnapshot> getSnapshots();
|
||||
void migrateOldSnapshotFiles();
|
||||
};
|
||||
|
||||
25
src/Insight/InsightWorker/Tasks/SetTargetGpioPadState.cpp
Normal file
25
src/Insight/InsightWorker/Tasks/SetTargetGpioPadState.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "SetTargetGpioPadState.hpp"
|
||||
|
||||
using Services::TargetControllerService;
|
||||
|
||||
SetTargetGpioPadState::SetTargetGpioPadState(
|
||||
const Targets::TargetPadDescriptor& padDescriptor,
|
||||
const Targets::TargetGpioPadState& state
|
||||
)
|
||||
: padDescriptor(padDescriptor)
|
||||
, state(state)
|
||||
{}
|
||||
|
||||
QString SetTargetGpioPadState::brief() const {
|
||||
return "Updating target pin state";
|
||||
}
|
||||
|
||||
TaskGroups SetTargetGpioPadState::taskGroups() const {
|
||||
return {
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
};
|
||||
}
|
||||
|
||||
void SetTargetGpioPadState::run(TargetControllerService& targetControllerService) {
|
||||
targetControllerService.setGpioPadState(this->padDescriptor, this->state);
|
||||
}
|
||||
22
src/Insight/InsightWorker/Tasks/SetTargetGpioPadState.hpp
Normal file
22
src/Insight/InsightWorker/Tasks/SetTargetGpioPadState.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
#include "src/Targets/TargetPadDescriptor.hpp"
|
||||
#include "src/Targets/TargetGpioPadState.hpp"
|
||||
|
||||
class SetTargetGpioPadState: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SetTargetGpioPadState(const Targets::TargetPadDescriptor& padDescriptor, const Targets::TargetGpioPadState& state);
|
||||
[[nodiscard]] QString brief() const override;
|
||||
[[nodiscard]] TaskGroups taskGroups() const override;
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
const Targets::TargetPadDescriptor& padDescriptor;
|
||||
Targets::TargetGpioPadState state;
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
#include "SetTargetPinState.hpp"
|
||||
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void SetTargetPinState::run(TargetControllerService& targetControllerService) {
|
||||
targetControllerService.setPinState(this->pinDescriptor, this->pinState);
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
#include "src/Targets/TargetPinDescriptor.hpp"
|
||||
|
||||
class SetTargetPinState: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SetTargetPinState(const Targets::TargetPinDescriptor& pinDescriptor, const Targets::TargetPinState& pinState)
|
||||
: pinDescriptor(pinDescriptor)
|
||||
, pinState(pinState)
|
||||
{}
|
||||
|
||||
QString brief() const override {
|
||||
return "Updating target pin state";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetPinDescriptor pinDescriptor;
|
||||
Targets::TargetPinState pinState;
|
||||
};
|
||||
@@ -1,18 +1,52 @@
|
||||
#include "WriteTargetMemory.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <QLocale>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
|
||||
using Services::TargetControllerService;
|
||||
using Targets::TargetMemorySize;
|
||||
|
||||
WriteTargetMemory::WriteTargetMemory(
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
std::vector<Block>&& blocks
|
||||
)
|
||||
: addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, blocks(std::move(blocks))
|
||||
{}
|
||||
|
||||
WriteTargetMemory::WriteTargetMemory(
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
const Targets::TargetMemoryBuffer& data
|
||||
)
|
||||
: WriteTargetMemory(
|
||||
addressSpaceDescriptor,
|
||||
memorySegmentDescriptor,
|
||||
std::vector<Block>{{startAddress, data}}
|
||||
)
|
||||
{}
|
||||
|
||||
QString WriteTargetMemory::brief() const {
|
||||
return "Writing " + QLocale{QLocale::English}.toString(this->totalSize()) + " byte(s) to \""
|
||||
+ QString::fromStdString(this->memorySegmentDescriptor.name) + "\"";
|
||||
}
|
||||
|
||||
TaskGroups WriteTargetMemory::taskGroups() const {
|
||||
return {
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
};
|
||||
}
|
||||
|
||||
void WriteTargetMemory::run(TargetControllerService& targetControllerService) {
|
||||
using Targets::TargetMemorySize;
|
||||
|
||||
if (!this->memoryDescriptor.access.writeableDuringDebugSession) {
|
||||
throw Exceptions::Exception("Invalid request - cannot write to this memory type during a debug session.");
|
||||
if (!this->memorySegmentDescriptor.debugModeAccess.writeable) {
|
||||
throw Exceptions::Exception{"Invalid request - cannot write to this memory segment during a debug session."};
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -23,20 +57,12 @@ void WriteTargetMemory::run(TargetControllerService& targetControllerService) {
|
||||
* command timeouts when we're writing lots of data.
|
||||
*/
|
||||
const auto maxBlockSize = std::max(
|
||||
TargetMemorySize(256),
|
||||
this->memoryDescriptor.pageSize.value_or(TargetMemorySize(0))
|
||||
TargetMemorySize{256},
|
||||
this->memorySegmentDescriptor.pageSize.value_or(TargetMemorySize{0})
|
||||
);
|
||||
|
||||
const TargetMemorySize totalBytesToWrite = std::accumulate(
|
||||
this->blocks.begin(),
|
||||
this->blocks.end(),
|
||||
TargetMemorySize{0},
|
||||
[] (TargetMemorySize bytes, const Block& block) {
|
||||
return bytes + block.data.size();
|
||||
}
|
||||
);
|
||||
|
||||
TargetMemorySize totalBytesWritten = 0;
|
||||
const auto writeSize = this->totalSize();
|
||||
auto totalBytesWritten = TargetMemorySize{0};
|
||||
|
||||
for (const auto& block : this->blocks) {
|
||||
const auto totalBytes = block.data.size();
|
||||
@@ -50,22 +76,34 @@ void WriteTargetMemory::run(TargetControllerService& targetControllerService) {
|
||||
);
|
||||
|
||||
targetControllerService.writeMemory(
|
||||
this->memoryDescriptor.type,
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
block.startAddress + bytesWritten,
|
||||
Targets::TargetMemoryBuffer(
|
||||
Targets::TargetMemoryBuffer{
|
||||
block.data.begin() + bytesWritten,
|
||||
block.data.begin() + bytesWritten + bytesToWrite
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
bytesWritten += bytesToWrite;
|
||||
totalBytesWritten += bytesToWrite;
|
||||
|
||||
this->setProgressPercentage(static_cast<std::uint8_t>(
|
||||
(static_cast<float>(totalBytesWritten) + 1) / (static_cast<float>(totalBytesToWrite) / 100)
|
||||
(static_cast<float>(totalBytesWritten) + 1) / (static_cast<float>(writeSize) / 100)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
emit this->targetMemoryWritten(totalBytesWritten);
|
||||
}
|
||||
|
||||
TargetMemorySize WriteTargetMemory::totalSize() const {
|
||||
return std::accumulate(
|
||||
this->blocks.begin(),
|
||||
this->blocks.end(),
|
||||
TargetMemorySize{0},
|
||||
[] (TargetMemorySize bytes, const Block& block) {
|
||||
return bytes + block.data.size();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include "InsightWorkerTask.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Helpers/EnumToStringMappings.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
|
||||
class WriteTargetMemory: public InsightWorkerTask
|
||||
{
|
||||
@@ -30,33 +31,18 @@ public:
|
||||
};
|
||||
|
||||
WriteTargetMemory(
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
std::vector<Block>&& blocks
|
||||
)
|
||||
: memoryDescriptor(memoryDescriptor)
|
||||
, blocks(std::move(blocks))
|
||||
{}
|
||||
|
||||
);
|
||||
WriteTargetMemory(
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
const Targets::TargetMemoryBuffer& data
|
||||
)
|
||||
: WriteTargetMemory(memoryDescriptor, std::vector<Block>({{startAddress, data}}))
|
||||
{}
|
||||
|
||||
QString brief() const override {
|
||||
return
|
||||
"Writing to target " + EnumToStringMappings::targetMemoryTypes.at(
|
||||
this->memoryDescriptor.type
|
||||
).toUpper();
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
}
|
||||
);
|
||||
[[nodiscard]] QString brief() const override;
|
||||
[[nodiscard]] TaskGroups taskGroups() const override;
|
||||
|
||||
signals:
|
||||
void targetMemoryWritten(Targets::TargetMemorySize bytesWritten);
|
||||
@@ -65,6 +51,9 @@ protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetMemoryDescriptor memoryDescriptor;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
std::vector<Block> blocks;
|
||||
|
||||
[[nodiscard]] Targets::TargetMemorySize totalSize() const;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,20 @@
|
||||
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void WriteTargetRegister::run(TargetControllerService& targetControllerService) {
|
||||
targetControllerService.writeRegisters({this->targetRegister});
|
||||
WriteTargetRegister::WriteTargetRegister(const Targets::TargetRegisterDescriptorAndValuePair& registerPair)
|
||||
: registerPair(registerPair)
|
||||
{}
|
||||
|
||||
QString WriteTargetRegister::brief() const {
|
||||
return "Writing to target register \"" + QString::fromStdString(this->registerPair.first.name) + "\"";
|
||||
}
|
||||
|
||||
TaskGroups WriteTargetRegister::taskGroups() const {
|
||||
return {
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
};
|
||||
}
|
||||
|
||||
void WriteTargetRegister::run(TargetControllerService& targetControllerService) {
|
||||
targetControllerService.writeRegisters({this->registerPair});
|
||||
}
|
||||
|
||||
@@ -1,30 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
#include "src/Targets/TargetRegister.hpp"
|
||||
#include "src/Targets/TargetRegisterDescriptor.hpp"
|
||||
|
||||
class WriteTargetRegister: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WriteTargetRegister(const Targets::TargetRegister& targetRegister)
|
||||
: targetRegister(targetRegister)
|
||||
{}
|
||||
|
||||
QString brief() const override {
|
||||
return "Writing target register";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
explicit WriteTargetRegister(const Targets::TargetRegisterDescriptorAndValuePair& registerPair);
|
||||
[[nodiscard]] QString brief() const override;
|
||||
[[nodiscard]] TaskGroups taskGroups() const override;
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetRegister targetRegister;
|
||||
Targets::TargetRegisterDescriptorAndValuePair registerPair;
|
||||
};
|
||||
|
||||
@@ -11,26 +11,28 @@
|
||||
using namespace Exceptions;
|
||||
|
||||
AboutWindow::AboutWindow(QWidget* parent): QObject(parent) {
|
||||
auto aboutWindowUiFile = QFile(QString::fromStdString(
|
||||
auto aboutWindowUiFile = QFile{
|
||||
QString::fromStdString(
|
||||
Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/UiFiles/AboutWindow.ui"
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/UiFiles/AboutWindow.ui"
|
||||
)
|
||||
);
|
||||
auto aboutWindowStylesheet = QFile(QString::fromStdString(
|
||||
};
|
||||
auto aboutWindowStylesheet = QFile{
|
||||
QString::fromStdString(
|
||||
Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/AboutWindow.qss"
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/AboutWindow.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!aboutWindowUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open AboutWindow UI file");
|
||||
throw Exception{"Failed to open AboutWindow UI file"};
|
||||
}
|
||||
|
||||
if (!aboutWindowStylesheet.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open AboutWindow QSS file");
|
||||
throw Exception{"Failed to open AboutWindow QSS file"};
|
||||
}
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->windowWidget = uiLoader.load(&aboutWindowUiFile, parent);
|
||||
this->windowWidget->setStyleSheet(aboutWindowStylesheet.readAll());
|
||||
this->windowWidget->setFixedSize(400, 300);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,8 @@
|
||||
|
||||
#include "src/Targets/TargetDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetVariantDescriptor.hpp"
|
||||
#include "src/Targets/TargetPinoutDescriptor.hpp"
|
||||
|
||||
#include "Widgets/Label.hpp"
|
||||
#include "Widgets/SvgToolButton.hpp"
|
||||
@@ -20,6 +22,7 @@
|
||||
#include "Widgets/PanelWidget.hpp"
|
||||
#include "Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp"
|
||||
#include "Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp"
|
||||
#include "Widgets/TargetMemoryInspectionPane/ToolButton.hpp"
|
||||
#include "Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPaneSettings.hpp"
|
||||
#include "Widgets/TaskIndicator/TaskIndicator.hpp"
|
||||
#include "AboutWindow.hpp"
|
||||
@@ -33,7 +36,8 @@ public:
|
||||
InsightProjectSettings& insightProjectSettings,
|
||||
const InsightConfig& insightConfig,
|
||||
const EnvironmentConfig& environmentConfig,
|
||||
const Targets::TargetDescriptor& targetDescriptor
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
const Targets::TargetState& targetState
|
||||
);
|
||||
|
||||
protected:
|
||||
@@ -49,7 +53,7 @@ private:
|
||||
TargetConfig targetConfig;
|
||||
|
||||
const Targets::TargetDescriptor& targetDescriptor;
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
const Targets::TargetState& targetState;
|
||||
|
||||
QWidget* windowContainer = nullptr;
|
||||
QMenuBar* mainMenuBar = nullptr;
|
||||
@@ -68,60 +72,46 @@ private:
|
||||
Widgets::TargetRegistersPaneWidget* targetRegistersSidePane = nullptr;
|
||||
QToolButton* targetRegistersButton = nullptr;
|
||||
|
||||
Widgets::Label* ioUnavailableWidget = nullptr;
|
||||
Widgets::InsightTargetWidgets::TargetPackageWidgetContainer* ioContainerWidget = nullptr;
|
||||
Widgets::InsightTargetWidgets::TargetPackageWidget* targetPackageWidget = nullptr;
|
||||
|
||||
QWidget* bottomMenuBar = nullptr;
|
||||
QHBoxLayout* bottomMenuBarLayout = nullptr;
|
||||
Widgets::PanelWidget* bottomPanel = nullptr;
|
||||
Widgets::TargetMemoryInspectionPane* ramInspectionPane = nullptr;
|
||||
Widgets::TargetMemoryInspectionPane* eepromInspectionPane = nullptr;
|
||||
Widgets::TargetMemoryInspectionPane* flashInspectionPane = nullptr;
|
||||
std::map<
|
||||
Targets::TargetMemoryType,
|
||||
Widgets::TargetMemoryInspectionPaneSettings
|
||||
> memoryInspectionPaneSettingsByMemoryType;
|
||||
QToolButton* ramInspectionButton = nullptr;
|
||||
QToolButton* eepromInspectionButton = nullptr;
|
||||
QToolButton* flashInspectionButton = nullptr;
|
||||
std::vector<Widgets::TargetMemoryInspectionPane*> memoryInspectionPaneWidgets = {};
|
||||
|
||||
QWidget* footer = nullptr;
|
||||
Widgets::Label* targetStatusLabel = nullptr;
|
||||
Widgets::Label* programCounterValueLabel = nullptr;
|
||||
Widgets::TaskIndicator* taskIndicator = nullptr;
|
||||
|
||||
std::map<QString, Targets::TargetVariant> supportedVariantsByName;
|
||||
const Targets::TargetVariant* selectedVariant = nullptr;
|
||||
std::optional<Targets::TargetVariant> previouslySelectedVariant;
|
||||
const Targets::TargetVariantDescriptor* selectedVariantDescriptor = nullptr;
|
||||
bool uiDisabled = false;
|
||||
|
||||
static bool isVariantSupported(const Targets::TargetVariant& variant);
|
||||
static bool isPinoutSupported(const Targets::TargetPinoutDescriptor& pinoutDescriptor);
|
||||
|
||||
void setUiDisabled(bool disable);
|
||||
|
||||
void populateVariantMenu();
|
||||
void selectDefaultVariant();
|
||||
void selectVariant(const Targets::TargetVariant* variant);
|
||||
void selectVariant(const Targets::TargetVariantDescriptor* variantDescriptor);
|
||||
void createPanes();
|
||||
|
||||
void adjustPanels();
|
||||
void adjustMinimumSize();
|
||||
|
||||
void onTargetStateUpdate(Targets::TargetState newState);
|
||||
void onTargetStateUpdate(Targets::TargetState newState, Targets::TargetState previousState);
|
||||
void refresh();
|
||||
void refreshPinStates();
|
||||
void refreshProgramCounter(std::optional<std::function<void(void)>> callback = std::nullopt);
|
||||
void refreshPadStates();
|
||||
void openReportIssuesUrl();
|
||||
void openGettingStartedUrl();
|
||||
void openAboutWindow();
|
||||
void toggleTargetRegistersPane();
|
||||
void toggleRamInspectionPane();
|
||||
void toggleMemoryInspectionPane(Widgets::TargetMemoryInspectionPane* pane);
|
||||
void toggleEepromInspectionPane();
|
||||
void toggleFlashInspectionPane();
|
||||
void onRegistersPaneStateChanged();
|
||||
void onRamInspectionPaneStateChanged();
|
||||
void onEepromInspectionPaneStateChanged();
|
||||
void onFlashInspectionPaneStateChanged();
|
||||
void onMemoryInspectionPaneStateChanged(Widgets::TargetMemoryInspectionPane* pane, Widgets::ToolButton* toolBtn);
|
||||
void onProgrammingModeEnabled();
|
||||
void onProgrammingModeDisabled();
|
||||
};
|
||||
|
||||
@@ -188,38 +188,14 @@ QToolTip {
|
||||
border-top: 1px solid #2F2F2D;
|
||||
}
|
||||
|
||||
#bottom-menu-bar #ram-inspection-btn,
|
||||
#bottom-menu-bar #eeprom-inspection-btn,
|
||||
#bottom-menu-bar #flash-inspection-btn {
|
||||
#bottom-menu-bar QToolButton {
|
||||
position: relative;
|
||||
border: none;
|
||||
min-height: 22px;
|
||||
}
|
||||
|
||||
#bottom-menu-bar #ram-inspection-btn {
|
||||
min-width: 73px;
|
||||
}
|
||||
|
||||
#bottom-menu-bar #eeprom-inspection-btn {
|
||||
min-width: 99px;
|
||||
}
|
||||
|
||||
#bottom-menu-bar #flash-inspection-btn {
|
||||
min-width: 85px;
|
||||
}
|
||||
|
||||
#bottom-menu-bar #ram-inspection-btn #ram-inspection-btn-icon,
|
||||
#bottom-menu-bar #eeprom-inspection-btn #eeprom-inspection-btn-icon,
|
||||
#bottom-menu-bar #flash-inspection-btn #flash-inspection-btn-icon {
|
||||
margin-left: 6px;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
#bottom-menu-bar #ram-inspection-btn #ram-inspection-btn-label,
|
||||
#bottom-menu-bar #eeprom-inspection-btn #eeprom-inspection-btn-label,
|
||||
#bottom-menu-bar #flash-inspection-btn #flash-inspection-btn-label {
|
||||
#bottom-menu-bar QToolButton QLabel {
|
||||
color: #999a9d;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
#bottom-menu-bar QToolButton:hover,
|
||||
|
||||
@@ -250,159 +250,6 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="ram-inspection-btn">
|
||||
<property name="toolTip">
|
||||
<string>Inspect RAM</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="disabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="SvgWidget" name="ram-inspection-btn-icon">
|
||||
<property name="containerHeight">
|
||||
<number>22</number>
|
||||
</property>
|
||||
<property name="containerWidth">
|
||||
<number>26</number>
|
||||
</property>
|
||||
<property name="svgFilePath">
|
||||
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/memory-inspection-icon.svg</string>
|
||||
</property>
|
||||
<property name="disabledSvgFilePath">
|
||||
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/memory-inspection-icon-disabled.svg</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="Label" name="ram-inspection-btn-label">
|
||||
<property name="text">
|
||||
<string>RAM</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<spacer name="horizontal-spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="eeprom-inspection-btn">
|
||||
<property name="toolTip">
|
||||
<string>Inspect EEPROM</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="disabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="SvgWidget" name="eeprom-inspection-btn-icon">
|
||||
<property name="containerHeight">
|
||||
<number>22</number>
|
||||
</property>
|
||||
<property name="containerWidth">
|
||||
<number>26</number>
|
||||
</property>
|
||||
<property name="svgFilePath">
|
||||
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/memory-inspection-icon.svg</string>
|
||||
</property>
|
||||
<property name="disabledSvgFilePath">
|
||||
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/memory-inspection-icon-disabled.svg</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="Label" name="eeprom-inspection-btn-label">
|
||||
<property name="text">
|
||||
<string>EEPROM</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<spacer name="horizontal-spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="flash-inspection-btn">
|
||||
<property name="toolTip">
|
||||
<string>Inspect FLASH</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="disabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="SvgWidget" name="flash-inspection-btn-icon">
|
||||
<property name="containerHeight">
|
||||
<number>22</number>
|
||||
</property>
|
||||
<property name="containerWidth">
|
||||
<number>26</number>
|
||||
</property>
|
||||
<property name="svgFilePath">
|
||||
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/memory-inspection-icon.svg</string>
|
||||
</property>
|
||||
<property name="disabledSvgFilePath">
|
||||
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/memory-inspection-icon-disabled.svg</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="Label" name="flash-inspection-btn-label">
|
||||
<property name="text">
|
||||
<string>FLASH</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<spacer name="horizontal-spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontal-spacer">
|
||||
<property name="orientation">
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
|
||||
using namespace Widgets;
|
||||
|
||||
UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
UiLoader::UiLoader(QObject* parent)
|
||||
: QUiLoader(parent)
|
||||
{
|
||||
this->customWidgetConstructorsByWidgetName = {
|
||||
{
|
||||
"Label",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new Label(parent);
|
||||
auto* widget = new Label{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -30,7 +32,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"RotatableLabel",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new RotatableLabel("", parent);
|
||||
auto* widget = new RotatableLabel{"", parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -39,7 +41,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"LabeledSeparator",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new LabeledSeparator(parent);
|
||||
auto* widget = new LabeledSeparator{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -48,7 +50,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"TextInput",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new TextInput(parent);
|
||||
auto* widget = new TextInput{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -57,7 +59,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"PlainTextEdit",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new PlainTextEdit(parent);
|
||||
auto* widget = new PlainTextEdit{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -66,7 +68,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"PushButton",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new PushButton(parent);
|
||||
auto* widget = new PushButton{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -75,7 +77,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"ExpandingHeightScrollAreaWidget",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new ExpandingHeightScrollAreaWidget(parent);
|
||||
auto* widget = new ExpandingHeightScrollAreaWidget{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -84,7 +86,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"SvgWidget",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new SvgWidget(parent);
|
||||
auto* widget = new SvgWidget{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -93,7 +95,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"SvgToolButton",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new SvgToolButton(parent);
|
||||
auto* widget = new SvgToolButton{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -102,7 +104,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"TargetPackageWidgetContainer",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new InsightTargetWidgets::TargetPackageWidgetContainer(parent);
|
||||
auto* widget = new InsightTargetWidgets::TargetPackageWidgetContainer{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
|
||||
@@ -11,7 +11,9 @@ namespace Widgets
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ClickableWidget(QWidget* parent): QFrame(parent) {};
|
||||
explicit ClickableWidget(QWidget* parent)
|
||||
: QFrame(parent)
|
||||
{};
|
||||
|
||||
signals:
|
||||
void rightClicked();
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Widgets
|
||||
void aborted();
|
||||
|
||||
protected:
|
||||
PushButton* confirmButton = new PushButton(this);
|
||||
PushButton* cancelButton = new PushButton(this);
|
||||
PushButton* confirmButton = new PushButton{this};
|
||||
PushButton* cancelButton = new PushButton{this};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,29 +21,29 @@ namespace Widgets
|
||||
this->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
this->setWindowTitle(windowTitle);
|
||||
|
||||
auto dialogUiFile = QFile(
|
||||
auto dialogUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/Dialog/UiFiles/Dialog.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
auto dialogStylesheet = QFile(
|
||||
auto dialogStylesheet = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/Dialog/Stylesheets/Dialog.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!dialogUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open Dialog UI file");
|
||||
throw Exception{"Failed to open Dialog UI file"};
|
||||
}
|
||||
|
||||
if (!dialogStylesheet.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open Dialog stylesheet file");
|
||||
throw Exception{"Failed to open Dialog stylesheet file"};
|
||||
}
|
||||
|
||||
this->setStyleSheet(dialogStylesheet.readAll());
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->container = uiLoader.load(&dialogUiFile, this);
|
||||
|
||||
this->textLabel = this->container->findChild<Label*>("text-label");
|
||||
@@ -58,10 +58,10 @@ namespace Widgets
|
||||
|
||||
void Dialog::showEvent(QShowEvent* event) {
|
||||
const auto containerSize = this->container->sizeHint();
|
||||
const auto windowSize = QSize(
|
||||
const auto windowSize = QSize{
|
||||
std::max(containerSize.width(), 500),
|
||||
std::max(containerSize.height(), 100)
|
||||
);
|
||||
};
|
||||
|
||||
this->setFixedSize(windowSize);
|
||||
this->container->setFixedSize(windowSize);
|
||||
|
||||
@@ -22,29 +22,29 @@ namespace Widgets
|
||||
this->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
this->setWindowTitle(windowTitle);
|
||||
|
||||
auto dialogueUiFile = QFile(
|
||||
auto dialogueUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/UiFiles/ErrorDialogue.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
auto dialogueStylesheet = QFile(
|
||||
auto dialogueStylesheet = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Stylesheets/ErrorDialogue.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!dialogueUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open ErrorDialogue UI file");
|
||||
throw Exception{"Failed to open ErrorDialogue UI file"};
|
||||
}
|
||||
|
||||
if (!dialogueStylesheet.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open ErrorDialogue stylesheet file");
|
||||
throw Exception{"Failed to open ErrorDialogue stylesheet file"};
|
||||
}
|
||||
|
||||
this->setStyleSheet(dialogueStylesheet.readAll());
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->container = uiLoader.load(&dialogueUiFile, this);
|
||||
|
||||
this->errorMessageDescriptionLabel = this->container->findChild<Label*>(
|
||||
@@ -61,10 +61,10 @@ namespace Widgets
|
||||
|
||||
void ErrorDialogue::showEvent(QShowEvent* event) {
|
||||
const auto containerSize = this->container->sizeHint();
|
||||
const auto windowSize = QSize(
|
||||
const auto windowSize = QSize{
|
||||
std::max(containerSize.width(), 500),
|
||||
std::max(containerSize.height(), 100)
|
||||
);
|
||||
};
|
||||
|
||||
this->setFixedSize(windowSize);
|
||||
this->container->setFixedSize(windowSize);
|
||||
|
||||
@@ -11,7 +11,9 @@ namespace Widgets
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ExpandingHeightScrollAreaWidget(QWidget* parent): QScrollArea(parent) {};
|
||||
explicit ExpandingHeightScrollAreaWidget(QWidget* parent)
|
||||
: QScrollArea(parent)
|
||||
{};
|
||||
|
||||
protected:
|
||||
[[nodiscard]] QSize scrollAreaSize() const {
|
||||
|
||||
@@ -11,25 +11,25 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void LabeledSeparator::paintEvent(QPaintEvent* event) {
|
||||
auto painter = QPainter(this);
|
||||
auto painter = QPainter{this};
|
||||
this->drawWidget(painter);
|
||||
}
|
||||
|
||||
void LabeledSeparator::drawWidget(QPainter& painter) {
|
||||
const auto fontMetrics = painter.fontMetrics();
|
||||
const auto titleSize = fontMetrics.size(Qt::TextFlag::TextSingleLine, this->title);
|
||||
const auto titleRect = QRect(
|
||||
QPoint(this->marginLeft, (this->height() - titleSize.height()) / 2),
|
||||
const auto titleRect = QRect{
|
||||
QPoint{this->marginLeft, (this->height() - titleSize.height()) / 2},
|
||||
titleSize
|
||||
);
|
||||
};
|
||||
|
||||
const auto lineYPosition = titleRect.y() + (titleRect.height() / 2);
|
||||
const auto line = QLine(
|
||||
const auto line = QLine{
|
||||
titleRect.right() + 8,
|
||||
lineYPosition,
|
||||
this->width() - this->marginRight,
|
||||
lineYPosition
|
||||
);
|
||||
};
|
||||
|
||||
painter.drawText(titleRect, Qt::AlignCenter, this->title);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Widgets
|
||||
static constexpr int DEFAULT_HEIGHT = 20;
|
||||
|
||||
QString title;
|
||||
QColor lineColor = QColor(0x4A, 0x4A, 0x4A);
|
||||
QColor lineColor = QColor{0x4A, 0x4A, 0x4A};
|
||||
int marginLeft = 0;
|
||||
int marginRight = 10;
|
||||
};
|
||||
|
||||
@@ -7,26 +7,36 @@
|
||||
#include <QWidget>
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsScene>
|
||||
#include <set>
|
||||
|
||||
#include "src/Helpers/DereferenceLessComparator.hpp"
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
class ListItem: public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
using ListItemSetType = std::set<ListItem*, DereferenceLessComparator<ListItem*>>;
|
||||
|
||||
bool selected = false;
|
||||
QSize size = QSize();
|
||||
bool excluded = false;
|
||||
QSize size = {};
|
||||
|
||||
ListItem() = default;
|
||||
|
||||
explicit ListItem(QGraphicsItem* parent)
|
||||
: QGraphicsItem(parent)
|
||||
{}
|
||||
|
||||
[[nodiscard]] QRectF boundingRect() const override {
|
||||
return QRectF(QPointF(0, 0), this->size);
|
||||
return QRectF{QPointF{0, 0}, this->size};
|
||||
}
|
||||
|
||||
virtual void onGeometryChanged() {
|
||||
return;
|
||||
}
|
||||
virtual void onGeometryChanged() {}
|
||||
|
||||
virtual bool operator < (const ListItem& rhs) const = 0;
|
||||
virtual bool operator < (const ListItem& rhs) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator > (const ListItem& rhs) const {
|
||||
return rhs < *this;
|
||||
|
||||
@@ -8,15 +8,12 @@
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
ListScene::ListScene(
|
||||
ListScene::ListItemSetType&& items,
|
||||
QGraphicsView* parent
|
||||
)
|
||||
ListScene::ListScene(const ListItem::ListItemSetType& items, QGraphicsView* parent)
|
||||
: QGraphicsScene(parent)
|
||||
, parent(parent)
|
||||
{
|
||||
this->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||
this->setItems(std::move(items));
|
||||
this->setItems(items);
|
||||
}
|
||||
|
||||
void ListScene::setSelectionLimit(std::uint8_t selectionLimit) {
|
||||
@@ -32,7 +29,7 @@ namespace Widgets
|
||||
auto startYPosition = this->margins.top();
|
||||
|
||||
for (auto& listItem : this->listItems) {
|
||||
if (!listItem->isVisible()) {
|
||||
if (listItem->excluded || !listItem->isVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -54,7 +51,7 @@ namespace Widgets
|
||||
this->update();
|
||||
}
|
||||
|
||||
void ListScene::setItems(const ListScene::ListItemSetType& items) {
|
||||
void ListScene::setItems(const ListItem::ListItemSetType& items) {
|
||||
this->clearListItems();
|
||||
|
||||
this->listItems = items;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <QPointF>
|
||||
|
||||
#include "ListItem.hpp"
|
||||
#include "src/Helpers/DereferenceLessComparator.hpp"
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
@@ -22,17 +21,16 @@ namespace Widgets
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using ListItemSetType = std::set<ListItem*, DereferenceLessComparator<ListItem*>>;
|
||||
QMargins margins = QMargins(0, 0, 0, 10);
|
||||
QMargins margins = {0, 0, 0, 10};
|
||||
|
||||
ListScene(
|
||||
ListScene::ListItemSetType&& items,
|
||||
const ListItem::ListItemSetType& items,
|
||||
QGraphicsView* parent
|
||||
);
|
||||
|
||||
void refreshGeometry();
|
||||
void setSelectionLimit(std::uint8_t selectionLimit);
|
||||
void setItems(const ListScene::ListItemSetType& items);
|
||||
void setItems(const ListItem::ListItemSetType& items);
|
||||
void addListItem(ListItem* item);
|
||||
void removeListItem(ListItem* item);
|
||||
void clearListItems();
|
||||
@@ -53,7 +51,7 @@ namespace Widgets
|
||||
void keyPressEvent(QKeyEvent* keyEvent) override;
|
||||
|
||||
private:
|
||||
ListScene::ListItemSetType listItems;
|
||||
ListItem::ListItemSetType listItems;
|
||||
QGraphicsView* const parent;
|
||||
bool enabled = false;
|
||||
bool keyNavigationEnabled = true;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Widgets
|
||||
{
|
||||
ListView::ListView(
|
||||
ListScene::ListItemSetType&& items,
|
||||
ListItem::ListItemSetType&& items,
|
||||
QWidget* parent
|
||||
)
|
||||
: QGraphicsView(parent)
|
||||
@@ -19,7 +19,7 @@ namespace Widgets
|
||||
this->setCacheMode(QGraphicsView::CacheModeFlag::CacheNone);
|
||||
this->setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
this->scene = new ListScene(std::move(items), this);
|
||||
this->scene = new ListScene{std::move(items), this};
|
||||
this->setScene(this->scene);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Widgets
|
||||
|
||||
public:
|
||||
ListView(
|
||||
ListScene::ListItemSetType&& items,
|
||||
ListItem::ListItemSetType&& items,
|
||||
QWidget* parent
|
||||
);
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ namespace Widgets
|
||||
bool open = false;
|
||||
|
||||
PanelState() = default;
|
||||
PanelState(int size, bool open): size(size), open(open) {};
|
||||
PanelState(int size, bool open)
|
||||
: size(size)
|
||||
, open(open)
|
||||
{};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Widgets
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
this->setMaximumResize(this->window()->height() - 100);
|
||||
|
||||
auto* layout = new QHBoxLayout(this);
|
||||
auto* layout = new QHBoxLayout{this};
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
this->setLayout(layout);
|
||||
@@ -30,7 +30,7 @@ namespace Widgets
|
||||
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
|
||||
this->setMaximumResize(this->window()->width() - 100);
|
||||
|
||||
auto* layout = new QVBoxLayout(this);
|
||||
auto* layout = new QVBoxLayout{this};
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
this->setLayout(layout);
|
||||
@@ -83,8 +83,6 @@ namespace Widgets
|
||||
}
|
||||
|
||||
bool PanelWidget::eventFilter(QObject* object, QEvent* event) {
|
||||
const auto eventType = event->type();
|
||||
|
||||
if (event->isSinglePointEvent()) {
|
||||
auto* pointerEvent = dynamic_cast<QSinglePointEvent*>(event);
|
||||
|
||||
@@ -168,23 +166,23 @@ namespace Widgets
|
||||
|
||||
switch (this->panelType) {
|
||||
case PanelWidgetType::LEFT: {
|
||||
return std::pair(
|
||||
QPoint(currentSize.width() - this->handleSize, 0),
|
||||
QPoint(currentSize.width(), currentSize.height())
|
||||
);
|
||||
return std::pair{
|
||||
QPoint{currentSize.width() - this->handleSize, 0},
|
||||
QPoint{currentSize.width(), currentSize.height()}
|
||||
};
|
||||
}
|
||||
case PanelWidgetType::RIGHT: {
|
||||
return std::pair(
|
||||
QPoint(0, 0),
|
||||
QPoint(this->handleSize, currentSize.height())
|
||||
);
|
||||
return std::pair{
|
||||
QPoint{0, 0},
|
||||
QPoint{this->handleSize, currentSize.height()}
|
||||
};
|
||||
}
|
||||
case PanelWidgetType::BOTTOM:
|
||||
default: {
|
||||
return std::pair(
|
||||
QPoint(0, 0),
|
||||
QPoint(currentSize.width(), this->handleSize)
|
||||
);
|
||||
return std::pair{
|
||||
QPoint{0, 0},
|
||||
QPoint{currentSize.width(), this->handleSize}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,9 +190,8 @@ namespace Widgets
|
||||
bool PanelWidget::isPositionWithinHandleArea(const QPoint& position) const {
|
||||
const auto handleArea = this->getHandleArea();
|
||||
|
||||
return (
|
||||
return
|
||||
position.x() >= handleArea.first.x() && position.x() <= handleArea.second.x()
|
||||
&& position.y() >= handleArea.first.y() && position.y() <= handleArea.second.y()
|
||||
);
|
||||
&& position.y() >= handleArea.first.y() && position.y() <= handleArea.second.y();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
namespace Widgets
|
||||
{
|
||||
void RotatableLabel::paintEvent(QPaintEvent* event) {
|
||||
auto painter = QPainter(this);
|
||||
auto painter = QPainter{this};
|
||||
const auto containerSize = this->getContainerSize();
|
||||
const auto textSize = QLabel::minimumSizeHint();
|
||||
const auto margins = this->contentsMargins();
|
||||
@@ -13,7 +13,7 @@ namespace Widgets
|
||||
painter.setClipRect(0, 0, containerSize.width(), containerSize.height());
|
||||
painter.save();
|
||||
painter.setPen(Qt::PenStyle::SolidLine);
|
||||
painter.setPen(QColor(this->isEnabled() ? "#999a9d" : "#808484"));
|
||||
painter.setPen(QColor{this->isEnabled() ? "#999a9d" : "#808484"});
|
||||
painter.translate(std::ceil(containerSize.width() / 2), std::ceil(containerSize.height() / 2));
|
||||
painter.rotate(this->angle);
|
||||
painter.drawText(
|
||||
@@ -29,7 +29,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
QSize RotatableLabel::getContainerSize() const {
|
||||
auto size = QSize();
|
||||
auto size = QSize{};
|
||||
auto textSize = QLabel::sizeHint();
|
||||
|
||||
if (this->angle % 360 == 0 || this->angle % 180 == 0) {
|
||||
@@ -52,11 +52,11 @@ namespace Widgets
|
||||
|
||||
size.setWidth(static_cast<int>(
|
||||
std::cos(angleRadians) * textSize.width()
|
||||
+ std::ceil(std::sin(angleRadians) * textSize.height())
|
||||
+ std::ceil(std::sin(angleRadians) * textSize.height())
|
||||
));
|
||||
size.setHeight(static_cast<int>(
|
||||
std::sin(angleRadians) * textSize.width()
|
||||
+ std::ceil(std::cos(angleRadians) * textSize.height())
|
||||
+ std::ceil(std::cos(angleRadians) * textSize.height())
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Widgets
|
||||
|
||||
void SvgToolButton::contextMenuEvent(QContextMenuEvent* event) {
|
||||
if (this->contextMenu != nullptr) {
|
||||
this->contextMenu->exec(this->mapToGlobal(QPoint(0, this->height())));
|
||||
this->contextMenu->exec(this->mapToGlobal(QPoint{0, this->height()}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
namespace Widgets
|
||||
{
|
||||
SvgWidget::SvgWidget(QWidget* parent): QFrame(parent) {
|
||||
this->renderer.setAspectRatioMode(Qt::AspectRatioMode::KeepAspectRatioByExpanding);
|
||||
this->renderer->setAspectRatioMode(Qt::AspectRatioMode::KeepAspectRatioByExpanding);
|
||||
}
|
||||
|
||||
void SvgWidget::startSpin() {
|
||||
if (this->spinningAnimation == nullptr) {
|
||||
this->spinningAnimation = new QPropertyAnimation(this, "angle", this);
|
||||
this->spinningAnimation = new QPropertyAnimation{this, "angle", this};
|
||||
this->spinningAnimation->setDuration(2000);
|
||||
this->spinningAnimation->setStartValue(0);
|
||||
this->spinningAnimation->setEndValue(360);
|
||||
@@ -33,7 +33,7 @@ namespace Widgets
|
||||
|
||||
void SvgWidget::paintEvent(QPaintEvent* paintEvent) {
|
||||
auto painter = QPainter(this);
|
||||
auto svgSize = this->renderer.defaultSize();
|
||||
auto svgSize = this->renderer->defaultSize();
|
||||
auto margins = this->contentsMargins();
|
||||
const auto containerSize = this->frameSize();
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Widgets
|
||||
);
|
||||
}
|
||||
|
||||
this->renderer.render(&painter, QRectF(
|
||||
this->renderer->render(&painter, QRectF(
|
||||
std::ceil(
|
||||
static_cast<float>(containerSize.width() - svgSize.width()) / 2 + static_cast<float>(margins.left())
|
||||
),
|
||||
@@ -66,10 +66,10 @@ namespace Widgets
|
||||
void SvgWidget::changeEvent(QEvent* event) {
|
||||
if (event->type() == QEvent::EnabledChange && !this->disabledSvgFilePath.isEmpty()) {
|
||||
if (!this->isEnabled()) {
|
||||
this->renderer.load(this->disabledSvgFilePath);
|
||||
this->renderer->load(this->disabledSvgFilePath);
|
||||
|
||||
} else {
|
||||
this->renderer.load(this->svgFilePath);
|
||||
this->renderer->load(this->svgFilePath);
|
||||
}
|
||||
|
||||
this->repaint();
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Widgets
|
||||
|
||||
void setSvgFilePath(const QString& svgFilePath) {
|
||||
this->svgFilePath = svgFilePath;
|
||||
this->renderer.load(this->svgFilePath);
|
||||
this->renderer->load(this->svgFilePath);
|
||||
}
|
||||
|
||||
QString getSvgFilePath() {
|
||||
@@ -86,7 +86,7 @@ namespace Widgets
|
||||
void changeEvent(QEvent* event) override;
|
||||
|
||||
private:
|
||||
QSvgRenderer renderer = new QSvgRenderer(this);
|
||||
QSvgRenderer* renderer = new QSvgRenderer{this};
|
||||
QString svgFilePath;
|
||||
QString disabledSvgFilePath;
|
||||
int containerWidth = 0;
|
||||
|
||||
@@ -4,16 +4,19 @@
|
||||
|
||||
ExcludedMemoryRegion::ExcludedMemoryRegion(
|
||||
const QString& name,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetMemoryAddressRange& addressRange
|
||||
)
|
||||
: MemoryRegion(name, memoryType, MemoryRegionType::EXCLUDED, addressRange)
|
||||
: MemoryRegion(
|
||||
name,
|
||||
MemoryRegionType::EXCLUDED,
|
||||
addressRange
|
||||
)
|
||||
{}
|
||||
|
||||
ExcludedMemoryRegion::ExcludedMemoryRegion(const QJsonObject& jsonObject)
|
||||
: MemoryRegion(jsonObject)
|
||||
{
|
||||
if (this->type != MemoryRegionType::EXCLUDED) {
|
||||
throw Exceptions::Exception("Invalid memory region type");
|
||||
throw Exceptions::Exception{"Invalid memory region type"};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,8 @@ class ExcludedMemoryRegion: public MemoryRegion
|
||||
public:
|
||||
ExcludedMemoryRegion(
|
||||
const QString& name,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetMemoryAddressRange& addressRange
|
||||
);
|
||||
|
||||
ExcludedMemoryRegion(const QJsonObject& jsonObject);
|
||||
explicit ExcludedMemoryRegion(const QJsonObject& jsonObject);
|
||||
};
|
||||
|
||||
@@ -4,10 +4,13 @@
|
||||
|
||||
FocusedMemoryRegion::FocusedMemoryRegion(
|
||||
const QString& name,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetMemoryAddressRange& addressRange
|
||||
)
|
||||
: MemoryRegion(name, memoryType, MemoryRegionType::FOCUSED, addressRange)
|
||||
: MemoryRegion(
|
||||
name,
|
||||
MemoryRegionType::FOCUSED,
|
||||
addressRange
|
||||
)
|
||||
{}
|
||||
|
||||
FocusedMemoryRegion::FocusedMemoryRegion(const QJsonObject& jsonObject)
|
||||
@@ -16,11 +19,11 @@ FocusedMemoryRegion::FocusedMemoryRegion(const QJsonObject& jsonObject)
|
||||
using Exceptions::Exception;
|
||||
|
||||
if (this->type != MemoryRegionType::FOCUSED) {
|
||||
throw Exception("Invalid memory region type");
|
||||
throw Exception{"Invalid memory region type"};
|
||||
}
|
||||
|
||||
if (!jsonObject.contains("dataType") || !jsonObject.contains("endianness")) {
|
||||
throw Exception("Missing data");
|
||||
throw Exception{"Missing data"};
|
||||
}
|
||||
|
||||
this->dataType = FocusedMemoryRegion::regionDataTypesByName.at(jsonObject.find("dataType")->toString());
|
||||
|
||||
@@ -22,12 +22,10 @@ public:
|
||||
|
||||
FocusedMemoryRegion(
|
||||
const QString& name,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetMemoryAddressRange& addressRange
|
||||
);
|
||||
|
||||
FocusedMemoryRegion(const QJsonObject& jsonObject);
|
||||
|
||||
explicit FocusedMemoryRegion(const QJsonObject& jsonObject);
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Widgets
|
||||
static constexpr int leftMargin = 10;
|
||||
|
||||
const auto addressItemCount = this->addressItems.size();
|
||||
decltype(this->addressItems)::size_type rowIndex = 0;
|
||||
auto rowIndex = decltype(this->addressItems)::size_type{0};
|
||||
|
||||
for (const auto& byteItem : firstByteItemByLine) {
|
||||
auto addressItem = addressItemCount > 0 && rowIndex <= addressItemCount - 1
|
||||
@@ -49,8 +49,8 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void ByteAddressContainer::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
|
||||
static const auto backgroundColor = QColor(0x35, 0x36, 0x33);
|
||||
static const auto borderColor = QColor(0x41, 0x42, 0x3F);
|
||||
static const auto backgroundColor = QColor{0x35, 0x36, 0x33};
|
||||
static const auto borderColor = QColor{0x41, 0x42, 0x3F};
|
||||
|
||||
painter->setPen(Qt::PenStyle::NoPen);
|
||||
painter->setBrush(backgroundColor);
|
||||
|
||||
@@ -15,15 +15,10 @@ namespace Widgets
|
||||
public:
|
||||
static constexpr int WIDTH = 88;
|
||||
|
||||
ByteAddressContainer(const HexViewerSharedState& hexViewerState);
|
||||
explicit ByteAddressContainer(const HexViewerSharedState& hexViewerState);
|
||||
|
||||
[[nodiscard]] QRectF boundingRect() const override {
|
||||
return QRectF(
|
||||
0,
|
||||
0,
|
||||
ByteAddressContainer::WIDTH,
|
||||
this->scene()->height()
|
||||
);
|
||||
return {0, 0, ByteAddressContainer::WIDTH, this->scene()->height()};
|
||||
}
|
||||
|
||||
void adjustAddressLabels(const std::vector<const ByteItem*>& firstByteItemByLine);
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace Widgets
|
||||
{}
|
||||
|
||||
void ByteAddressItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
|
||||
static auto fontColor = QColor(0x8F, 0x91, 0x92);
|
||||
static auto font = QFont("'Ubuntu', sans-serif");
|
||||
static auto fontColor = QColor{0x8F, 0x91, 0x92};
|
||||
static auto font = QFont{"'Ubuntu', sans-serif"};
|
||||
font.setPixelSize(12);
|
||||
|
||||
painter->setRenderHints(
|
||||
@@ -28,7 +28,7 @@ namespace Widgets
|
||||
Qt::AlignLeft,
|
||||
this->hexViewerState.settings.addressLabelType == AddressType::RELATIVE
|
||||
? "0x" + QString::number(
|
||||
this->address - this->hexViewerState.memoryDescriptor.addressRange.startAddress,
|
||||
this->address - this->hexViewerState.memorySegmentDescriptor.addressRange.startAddress,
|
||||
16
|
||||
).rightJustified(8, '0').toUpper()
|
||||
: "0x" + QString::number(this->address, 16).rightJustified(8, '0').toUpper()
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainter>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
#include "ByteItem.hpp"
|
||||
#include "HexViewerSharedState.hpp"
|
||||
|
||||
@@ -19,12 +21,7 @@ namespace Widgets
|
||||
explicit ByteAddressItem(const HexViewerSharedState& hexViewerState, QGraphicsItem* parent);
|
||||
|
||||
[[nodiscard]] QRectF boundingRect() const override {
|
||||
return {
|
||||
0,
|
||||
0,
|
||||
ByteAddressItem::WIDTH,
|
||||
ByteAddressItem::HEIGHT
|
||||
};
|
||||
return {0, 0, ByteAddressItem::WIDTH, ByteAddressItem::HEIGHT};
|
||||
}
|
||||
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace Widgets
|
||||
|
||||
explicit ByteItem(Targets::TargetMemoryAddress address);
|
||||
|
||||
QSize size() const override {
|
||||
return QSize(ByteItem::WIDTH, ByteItem::HEIGHT);
|
||||
[[nodiscard]] QSize size() const override {
|
||||
return {ByteItem::WIDTH, ByteItem::HEIGHT};
|
||||
}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
@@ -56,11 +56,11 @@ namespace Widgets
|
||||
|
||||
const auto regionStartAddress = this->focusedMemoryRegion.addressRange.startAddress;
|
||||
const auto regionEndAddress = this->focusedMemoryRegion.addressRange.endAddress;
|
||||
const auto startIndex = regionStartAddress - hexViewerState.memoryDescriptor.addressRange.startAddress;
|
||||
auto value = Targets::TargetMemoryBuffer(
|
||||
const auto startIndex = regionStartAddress - hexViewerState.memorySegmentDescriptor.addressRange.startAddress;
|
||||
auto value = Targets::TargetMemoryBuffer{
|
||||
hexViewerState.data->begin() + startIndex,
|
||||
hexViewerState.data->begin() + startIndex + (regionEndAddress - regionStartAddress + 1)
|
||||
);
|
||||
};
|
||||
|
||||
if (this->focusedMemoryRegion.endianness == Targets::TargetMemoryEndianness::LITTLE) {
|
||||
std::reverse(value.begin(), value.end());
|
||||
@@ -90,7 +90,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
if (valueSize <= 4) {
|
||||
std::int32_t integerValue = 0;
|
||||
auto integerValue = std::int32_t{0};
|
||||
for (const auto& byte : value) {
|
||||
integerValue = (integerValue << 8) | byte;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace Widgets
|
||||
break;
|
||||
}
|
||||
|
||||
std::int64_t integerValue = 0;
|
||||
auto integerValue = std::int64_t{0};
|
||||
for (const auto& byte : value) {
|
||||
integerValue = (integerValue << 8) | byte;
|
||||
}
|
||||
@@ -138,40 +138,40 @@ namespace Widgets
|
||||
|
||||
QMargins FocusedRegionGroupItem::groupMargins(
|
||||
const HexViewerSharedState* hexViewerState,
|
||||
const int maximumWidth
|
||||
int maximumWidth
|
||||
) const {
|
||||
if (hexViewerState->settings.displayAnnotations) {
|
||||
constexpr auto averageSymbolWidth = 8;
|
||||
const auto nameLabelWidth = static_cast<int>(this->focusedMemoryRegion.name.size() * averageSymbolWidth);
|
||||
const auto valueLabelWidth = static_cast<int>(
|
||||
this->valueLabel.has_value() ? this->valueLabel->size() * averageSymbolWidth : 0
|
||||
);
|
||||
|
||||
const auto minimumWidth = std::min(std::max(nameLabelWidth, valueLabelWidth), maximumWidth);
|
||||
|
||||
const auto byteItemSize = (this->focusedMemoryRegion.addressRange.endAddress
|
||||
- this->focusedMemoryRegion.addressRange.startAddress + 1);
|
||||
const auto estimatedWidth = static_cast<int>(
|
||||
byteItemSize * (ByteItem::WIDTH + ByteItem::RIGHT_MARGIN) - ByteItem::RIGHT_MARGIN
|
||||
);
|
||||
|
||||
const auto annotationMargin = std::min(
|
||||
static_cast<int>(
|
||||
estimatedWidth < minimumWidth ? minimumWidth - estimatedWidth : 0
|
||||
),
|
||||
std::max(maximumWidth - estimatedWidth, 0)
|
||||
);
|
||||
|
||||
return QMargins(
|
||||
annotationMargin / 2,
|
||||
this->focusedMemoryRegion.dataType != MemoryRegionDataType::UNKNOWN
|
||||
? FocusedRegionGroupItem::ANNOTATION_HEIGHT
|
||||
: 0,
|
||||
annotationMargin / 2,
|
||||
FocusedRegionGroupItem::ANNOTATION_HEIGHT
|
||||
);
|
||||
if (!hexViewerState->settings.displayAnnotations) {
|
||||
return QMargins{0, 0, 0, 0};
|
||||
}
|
||||
|
||||
return QMargins(0, 0, 0, 0);
|
||||
constexpr auto averageSymbolWidth = 8;
|
||||
const auto nameLabelWidth = static_cast<int>(this->focusedMemoryRegion.name.size() * averageSymbolWidth);
|
||||
const auto valueLabelWidth = static_cast<int>(
|
||||
this->valueLabel.has_value() ? this->valueLabel->size() * averageSymbolWidth : 0
|
||||
);
|
||||
|
||||
const auto minimumWidth = std::min(std::max(nameLabelWidth, valueLabelWidth), maximumWidth);
|
||||
|
||||
const auto byteItemSize = (this->focusedMemoryRegion.addressRange.endAddress
|
||||
- this->focusedMemoryRegion.addressRange.startAddress + 1);
|
||||
const auto estimatedWidth = static_cast<int>(
|
||||
byteItemSize * (ByteItem::WIDTH + ByteItem::RIGHT_MARGIN) - ByteItem::RIGHT_MARGIN
|
||||
);
|
||||
|
||||
const auto annotationMargin = std::min(
|
||||
static_cast<int>(
|
||||
estimatedWidth < minimumWidth ? minimumWidth - estimatedWidth : 0
|
||||
),
|
||||
std::max(maximumWidth - estimatedWidth, 0)
|
||||
);
|
||||
|
||||
return QMargins{
|
||||
annotationMargin / 2,
|
||||
this->focusedMemoryRegion.dataType != MemoryRegionDataType::UNKNOWN
|
||||
? FocusedRegionGroupItem::ANNOTATION_HEIGHT
|
||||
: 0,
|
||||
annotationMargin / 2,
|
||||
FocusedRegionGroupItem::ANNOTATION_HEIGHT
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,6 @@ namespace Widgets
|
||||
void refreshValue(const HexViewerSharedState& hexViewerState);
|
||||
|
||||
protected:
|
||||
QMargins groupMargins(const HexViewerSharedState* hexViewerState, const int maximumWidth) const override;
|
||||
QMargins groupMargins(const HexViewerSharedState* hexViewerState, int maximumWidth) const override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,16 +8,16 @@ namespace Widgets
|
||||
}
|
||||
}
|
||||
|
||||
void GroupItem::adjustItemPositions(const int maximumWidth, const HexViewerSharedState* hexViewerState) {
|
||||
void GroupItem::adjustItemPositions(int maximumWidth, const HexViewerSharedState* hexViewerState) {
|
||||
const auto margins = this->groupMargins(hexViewerState, maximumWidth);
|
||||
|
||||
int width = margins.left();
|
||||
int height = margins.top();
|
||||
|
||||
this->multiLine = false;
|
||||
auto position = QPoint(margins.left(), margins.top());
|
||||
auto position = QPoint{margins.left(), margins.top()};
|
||||
|
||||
auto currentLineItems = std::vector<HexViewerItem*>();
|
||||
auto currentLineItems = std::vector<HexViewerItem*>{};
|
||||
const ByteItem* lastByteItem = nullptr;
|
||||
|
||||
for (const auto& item : this->items) {
|
||||
@@ -69,11 +69,11 @@ namespace Widgets
|
||||
lastByteItem = byteItem;
|
||||
}
|
||||
|
||||
this->groupSize = QSize(width + margins.right(), height + margins.bottom());
|
||||
this->groupSize = QSize{width + margins.right(), height + margins.bottom()};
|
||||
}
|
||||
|
||||
std::vector<HexViewerItem*> GroupItem::flattenedItems() const {
|
||||
auto flattenedItems = std::vector<HexViewerItem*>();
|
||||
auto flattenedItems = std::vector<HexViewerItem*>{};
|
||||
|
||||
for (const auto& item : this->items) {
|
||||
flattenedItems.push_back(item);
|
||||
@@ -88,10 +88,7 @@ namespace Widgets
|
||||
return flattenedItems;
|
||||
}
|
||||
|
||||
GroupItem::GroupItem(
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
HexViewerItem* parent
|
||||
)
|
||||
GroupItem::GroupItem(Targets::TargetMemoryAddress startAddress, HexViewerItem* parent)
|
||||
: HexViewerItem(startAddress, parent)
|
||||
{}
|
||||
|
||||
|
||||
@@ -22,29 +22,29 @@ namespace Widgets
|
||||
|
||||
~GroupItem();
|
||||
|
||||
QSize size() const override {
|
||||
[[nodiscard]] QSize size() const override {
|
||||
return this->groupSize;
|
||||
}
|
||||
|
||||
virtual void adjustItemPositions(const int maximumWidth, const HexViewerSharedState* hexViewerState);
|
||||
virtual void adjustItemPositions(int maximumWidth, const HexViewerSharedState* hexViewerState);
|
||||
|
||||
[[nodiscard]] std::vector<HexViewerItem*> flattenedItems() const;
|
||||
|
||||
protected:
|
||||
GroupItem(
|
||||
explicit GroupItem(
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
HexViewerItem* parent = nullptr
|
||||
);
|
||||
|
||||
virtual QMargins groupMargins(const HexViewerSharedState* hexViewerState, const int maximumWidth) const {
|
||||
return QMargins(0, 0, 0, 0);
|
||||
virtual QMargins groupMargins(const HexViewerSharedState* hexViewerState, int maximumWidth) const {
|
||||
return {0, 0, 0, 0};
|
||||
}
|
||||
|
||||
virtual bool positionOnNewLine(const int maximumWidth) {
|
||||
return this->multiLine;
|
||||
}
|
||||
|
||||
ByteItem* firstByteItem() const;
|
||||
[[nodiscard]] ByteItem* firstByteItem() const;
|
||||
|
||||
void sortItems();
|
||||
};
|
||||
|
||||
@@ -18,15 +18,15 @@ namespace Widgets
|
||||
static constexpr int RIGHT_MARGIN = 5;
|
||||
static constexpr int BOTTOM_MARGIN = 5;
|
||||
|
||||
const Targets::TargetMemoryAddress startAddress = 0;
|
||||
const Targets::TargetMemoryAddress startAddress;
|
||||
|
||||
HexViewerItem* parent = nullptr;
|
||||
|
||||
QPoint relativePosition = {};
|
||||
|
||||
HexViewerItem(Targets::TargetMemoryAddress startAddress, HexViewerItem* parent = nullptr);
|
||||
QPoint position() const;
|
||||
virtual QSize size() const = 0;
|
||||
explicit HexViewerItem(Targets::TargetMemoryAddress startAddress, HexViewerItem* parent = nullptr);
|
||||
[[nodiscard]] QPoint position() const;
|
||||
[[nodiscard]] virtual QSize size() const = 0;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Widgets
|
||||
);
|
||||
|
||||
if (startGridPointIndex >= gridPointCount) {
|
||||
return HexViewerItemIndex::ItemRangeType();
|
||||
return HexViewerItemIndex::ItemRangeType{};
|
||||
}
|
||||
|
||||
const auto endGridPointIndex = static_cast<decltype(this->byteItemGrid)::size_type>(std::min(
|
||||
@@ -44,12 +44,12 @@ namespace Widgets
|
||||
gridPointCount - 1
|
||||
));
|
||||
|
||||
return HexViewerItemIndex::ItemRangeType(
|
||||
return HexViewerItemIndex::ItemRangeType{
|
||||
this->byteItemGrid[startGridPointIndex],
|
||||
endGridPointIndex == gridPointCount - 1
|
||||
? this->flattenedItems.end()
|
||||
: this->byteItemGrid[endGridPointIndex]
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
ByteItem* HexViewerItemIndex::byteItemAt(const QPointF& position) const {
|
||||
@@ -115,11 +115,11 @@ namespace Widgets
|
||||
// Sanity check
|
||||
assert(gridPointCount > gridPointIndex);
|
||||
|
||||
return static_cast<ByteItem*>(*(this->byteItemGrid[gridPointIndex]));
|
||||
return dynamic_cast<ByteItem*>(*(this->byteItemGrid[gridPointIndex]));
|
||||
}
|
||||
|
||||
std::vector<ByteItem*> HexViewerItemIndex::intersectingByteItems(const QRectF& rect) const {
|
||||
auto output = std::vector<ByteItem*>();
|
||||
auto output = std::vector<ByteItem*>{};
|
||||
|
||||
const auto yStart = static_cast<int>(std::max(rect.y(), static_cast<qreal>(0)));
|
||||
const auto yEnd = static_cast<int>(std::max(rect.y() + rect.height(), static_cast<qreal>(0)));
|
||||
@@ -127,7 +127,7 @@ namespace Widgets
|
||||
const auto items = this->items(yStart, yEnd);
|
||||
|
||||
for (auto& item : items) {
|
||||
const auto itemRect = QRectF(item->position(), item->size());
|
||||
const auto itemRect = QRectF{item->position(), item->size()};
|
||||
|
||||
if (itemRect.y() > yEnd) {
|
||||
break;
|
||||
@@ -252,7 +252,7 @@ namespace Widgets
|
||||
|
||||
if (itemYEndPosition >= currentByteItemGridPoint) {
|
||||
// This byte item is the first to exceed or intersect with the currentByteItemGridPoint
|
||||
this->byteItemGrid.push_back(itemIt);
|
||||
this->byteItemGrid.emplace_back(itemIt);
|
||||
currentByteItemGridPoint += HexViewerItemIndex::GRID_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Widgets
|
||||
this->hexViewerState.hoveredByteItem != nullptr
|
||||
&& this->hexViewerState.settings.highlightHoveredRowAndCol
|
||||
) {
|
||||
static const auto hoverRectBackgroundColor = QColor(0x8E, 0x8B, 0x83, 45);
|
||||
static const auto hoverRectBackgroundColor = QColor{0x8E, 0x8B, 0x83, 45};
|
||||
|
||||
painter->setBrush(hoverRectBackgroundColor);
|
||||
painter->setPen(Qt::NoPen);
|
||||
@@ -108,7 +108,7 @@ namespace Widgets
|
||||
|
||||
void HexViewerItemRenderer::paintByteItem(const ByteItem* item, QPainter* painter) {
|
||||
const auto position = item->position();
|
||||
const auto boundingRect = QRect(position.x(), position.y(), ByteItem::WIDTH, ByteItem::HEIGHT);
|
||||
const auto boundingRect = QRect{position.x(), position.y(), ByteItem::WIDTH, ByteItem::HEIGHT};
|
||||
|
||||
painter->setOpacity(
|
||||
!this->isEnabled()
|
||||
@@ -133,7 +133,8 @@ namespace Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
const auto byteIndex = item->startAddress - this->hexViewerState.memoryDescriptor.addressRange.startAddress;
|
||||
const auto byteIndex = item->startAddress
|
||||
- this->hexViewerState.memorySegmentDescriptor.addressRange.startAddress;
|
||||
const auto value = (*(this->hexViewerState.data))[byteIndex];
|
||||
|
||||
const auto hoveredPrimary = this->hexViewerState.hoveredByteItem == item;
|
||||
@@ -257,7 +258,7 @@ namespace Widgets
|
||||
const auto endItemPos = endItem->position();
|
||||
const auto endItemSize = endItem->size();
|
||||
|
||||
auto painterPath = QPainterPath();
|
||||
auto painterPath = QPainterPath{};
|
||||
|
||||
if (startItemPos.y() != endItemPos.y()) {
|
||||
// The highlighted range spans more than one line - draw the border around all lines containing the range
|
||||
@@ -288,7 +289,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
painter->setRenderHints(QPainter::RenderHint::Antialiasing | QPainter::RenderHint::SmoothPixmapTransform, true);
|
||||
painter->setPen(QPen(QColor(0x58, 0x58, 0x58), 2));
|
||||
painter->setPen(QPen{QColor{0x58, 0x58, 0x58}, 2});
|
||||
painter->setBrush(Qt::BrushStyle::NoBrush);
|
||||
painter->drawPath(painterPath);
|
||||
}
|
||||
@@ -304,10 +305,10 @@ namespace Widgets
|
||||
{
|
||||
auto labelText = item->focusedMemoryRegion.name;
|
||||
|
||||
static constexpr auto lineColor = QColor(0x4F, 0x4F, 0x4F);
|
||||
static constexpr auto labelFontColor = QColor(0x68, 0x68, 0x68);
|
||||
static constexpr auto lineColor = QColor{0x4F, 0x4F, 0x4F};
|
||||
static constexpr auto labelFontColor = QColor{0x68, 0x68, 0x68};
|
||||
|
||||
static auto labelFont = QFont("'Ubuntu', sans-serif");
|
||||
static auto labelFont = QFont{"'Ubuntu', sans-serif"};
|
||||
labelFont.setPixelSize(12);
|
||||
|
||||
painter->setFont(labelFont);
|
||||
@@ -329,51 +330,50 @@ namespace Widgets
|
||||
const auto verticalLineYStart = position.y() + static_cast<int>(heightOffset);
|
||||
const auto verticalLineYEnd = position.y() + static_cast<int>(heightOffset + 5);
|
||||
|
||||
const auto labelRect = QRect(
|
||||
const auto labelRect = QRect{
|
||||
position.x() + (groupWidth - labelSize.width()) / 2,
|
||||
verticalLineYEnd + 10,
|
||||
labelSize.width(),
|
||||
labelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->setPen(lineColor);
|
||||
|
||||
if (item->focusedMemoryRegion.addressRange.startAddress !=
|
||||
item->focusedMemoryRegion.addressRange.endAddress) {
|
||||
if (item->focusedMemoryRegion.addressRange.startAddress != item->focusedMemoryRegion.addressRange.endAddress) {
|
||||
const auto lineStartX =
|
||||
position.x() + item->items.front()->relativePosition.x() + (ByteItem::WIDTH / 2);
|
||||
const auto lineEndX = item->multiLine
|
||||
? position.x() + groupWidth - (ByteItem::WIDTH / 2)
|
||||
: position.x() + item->items.back()->relativePosition.x() + (ByteItem::WIDTH / 2);
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineStartX,
|
||||
verticalLineYStart,
|
||||
lineStartX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineEndX,
|
||||
verticalLineYStart,
|
||||
lineEndX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineStartX,
|
||||
verticalLineYEnd,
|
||||
lineEndX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
position.x() + groupWidth / 2,
|
||||
verticalLineYEnd,
|
||||
position.x() + groupWidth / 2,
|
||||
verticalLineYEnd + 4
|
||||
));
|
||||
});
|
||||
|
||||
painter->setPen(labelFontColor);
|
||||
painter->drawText(labelRect, Qt::AlignCenter, labelText);
|
||||
@@ -385,10 +385,10 @@ namespace Widgets
|
||||
|
||||
auto labelText = item->valueLabel.value_or("??");
|
||||
|
||||
static const auto lineColor = QColor(0x4F, 0x4F, 0x4F);
|
||||
static const auto labelFontColor = QColor(0x94, 0x6F, 0x30);
|
||||
static const auto lineColor = QColor{0x4F, 0x4F, 0x4F};
|
||||
static const auto labelFontColor = QColor{0x94, 0x6F, 0x30};
|
||||
|
||||
static auto labelFont = QFont("'Ubuntu', sans-serif");
|
||||
static auto labelFont = QFont{"'Ubuntu', sans-serif"};
|
||||
labelFont.setPixelSize(12);
|
||||
labelFont.setItalic(true);
|
||||
|
||||
@@ -399,11 +399,7 @@ namespace Widgets
|
||||
auto labelSize = fontMetrics.size(Qt::TextSingleLine, labelText);
|
||||
if (labelSize.width() > groupWidth) {
|
||||
labelSize.setWidth(groupWidth);
|
||||
labelText = fontMetrics.elidedText(
|
||||
labelText,
|
||||
Qt::TextElideMode::ElideRight,
|
||||
groupWidth
|
||||
);
|
||||
labelText = fontMetrics.elidedText(labelText, Qt::TextElideMode::ElideRight, groupWidth);
|
||||
}
|
||||
|
||||
const auto heightOffset = FocusedRegionGroupItem::ANNOTATION_HEIGHT - 4;
|
||||
@@ -411,12 +407,12 @@ namespace Widgets
|
||||
const auto verticalLineYStart = position.y() + static_cast<int>(heightOffset - 5);
|
||||
const auto verticalLineYEnd = position.y() + static_cast<int>(heightOffset);
|
||||
|
||||
const auto labelRect = QRect(
|
||||
const auto labelRect = QRect{
|
||||
position.x() + (groupWidth - labelSize.width()) / 2,
|
||||
verticalLineYStart - 10 - labelSize.height(),
|
||||
labelSize.width(),
|
||||
labelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->setPen(lineColor);
|
||||
|
||||
@@ -426,26 +422,26 @@ namespace Widgets
|
||||
? position.x() + groupWidth - + (ByteItem::WIDTH / 2)
|
||||
: position.x() + item->items.back()->relativePosition.x() + (ByteItem::WIDTH / 2);
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineStartX,
|
||||
verticalLineYStart,
|
||||
lineStartX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineEndX,
|
||||
verticalLineYStart,
|
||||
lineEndX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineStartX,
|
||||
verticalLineYStart,
|
||||
lineEndX,
|
||||
verticalLineYStart
|
||||
));
|
||||
});
|
||||
|
||||
/*
|
||||
* Draw a circle just above the first byte item of the region, to indicate the first byte used to generate
|
||||
@@ -455,23 +451,23 @@ namespace Widgets
|
||||
|
||||
constexpr auto radius = 2;
|
||||
painter->drawEllipse(
|
||||
QPoint(
|
||||
QPoint{
|
||||
item->focusedMemoryRegion.endianness == TargetMemoryEndianness::BIG ? lineStartX : lineEndX,
|
||||
!item->multiLine || item->focusedMemoryRegion.endianness == TargetMemoryEndianness::BIG
|
||||
? verticalLineYStart
|
||||
: position.y() + item->groupSize.height() - FocusedRegionGroupItem::ANNOTATION_HEIGHT + 4 + 5
|
||||
),
|
||||
},
|
||||
radius,
|
||||
radius
|
||||
);
|
||||
}
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
position.x() + groupWidth / 2,
|
||||
verticalLineYStart - 4,
|
||||
position.x() + groupWidth / 2,
|
||||
verticalLineYStart
|
||||
));
|
||||
});
|
||||
|
||||
painter->setPen(labelFontColor);
|
||||
painter->drawText(labelRect, Qt::AlignCenter, labelText);
|
||||
@@ -481,30 +477,31 @@ namespace Widgets
|
||||
void HexViewerItemRenderer::paintStackMemoryGroupItem(const StackMemoryGroupItem* item, QPainter* painter) {
|
||||
const auto position = item->position();
|
||||
|
||||
const auto headingText = QString("Stack Memory");
|
||||
const auto headingText = QString{"Stack Memory"};
|
||||
|
||||
const auto stackSize = this->hexViewerState.memoryDescriptor.addressRange.endAddress - item->startAddress + 1;
|
||||
const auto& memoryCapacity = this->hexViewerState.memoryDescriptor.size();
|
||||
const auto stackSize = this->hexViewerState.memorySegmentDescriptor.addressRange.endAddress
|
||||
- item->startAddress + 1;
|
||||
const auto& memoryCapacity = this->hexViewerState.memorySegmentDescriptor.size();
|
||||
|
||||
const auto stackSizeHeadingText = QString("Stack size:");
|
||||
const auto stackSizeHeadingText = QString{"Stack size:"};
|
||||
const auto stackSizeValueText = QString::number(stackSize) + " byte(s) ("
|
||||
+ QString::number(static_cast<float>(stackSize) / static_cast<float>(memoryCapacity / 100), 'f' , 1)
|
||||
+ "% of memory capacity)";
|
||||
|
||||
const auto stackPointerHeadingText = QString("Stack pointer:");
|
||||
const auto stackPointerHeadingText = QString{"Stack pointer:"};
|
||||
const auto stackPointerValueText = "0x" + QString::number(
|
||||
item->stackPointer,
|
||||
16
|
||||
).rightJustified(8, '0').toUpper();
|
||||
|
||||
static constexpr auto lineColor = QColor(0x4F, 0x4F, 0x4F);
|
||||
static constexpr auto headingLabelFontColor = QColor(0x6F, 0x6F, 0x6F);
|
||||
static constexpr auto valueLabelFontColor = QColor(0x94, 0x6F, 0x30, 230);
|
||||
static constexpr auto lineColor = QColor{0x4F, 0x4F, 0x4F};
|
||||
static constexpr auto headingLabelFontColor = QColor{0x6F, 0x6F, 0x6F};
|
||||
static constexpr auto valueLabelFontColor = QColor{0x94, 0x6F, 0x30, 230};
|
||||
|
||||
static auto headingLabelFont = QFont("'Ubuntu', sans-serif");
|
||||
static auto headingLabelFont = QFont{"'Ubuntu', sans-serif"};
|
||||
headingLabelFont.setPixelSize(13);
|
||||
|
||||
static auto valueFont = QFont("'Ubuntu', sans-serif");
|
||||
static auto valueFont = QFont{"'Ubuntu', sans-serif"};
|
||||
valueFont.setPixelSize(13);
|
||||
valueFont.setItalic(true);
|
||||
|
||||
@@ -534,75 +531,75 @@ namespace Widgets
|
||||
const auto lineStartX = position.x() + ByteItem::WIDTH / 2;
|
||||
const auto lineEndX = position.x() + groupWidth - (ByteItem::WIDTH / 2);
|
||||
|
||||
const auto labelRect = QRect(
|
||||
const auto labelRect = QRect{
|
||||
position.x() + (groupWidth - headingLabelSize.width()) / 2,
|
||||
verticalLineYStart - stackPointerHeadingLabelSize.height() - stackSizeHeadingLabelSize.height()
|
||||
- headingLabelSize.height() - labelLineHeight - (labelBottomMargin * 2) - 3,
|
||||
headingLabelSize.width(),
|
||||
headingLabelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
const auto stackPointerHeadingLabelRect = QRect(
|
||||
const auto stackPointerHeadingLabelRect = QRect{
|
||||
labelRect.left() + (labelRect.width() / 2) - (
|
||||
(stackPointerHeadingLabelSize.width() + stackPointerLabelSize.width()) / 2
|
||||
),
|
||||
labelRect.bottom() + labelBottomMargin,
|
||||
stackPointerHeadingLabelSize.width(),
|
||||
stackPointerHeadingLabelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
const auto stackPointerValueLabelRect = QRect(
|
||||
const auto stackPointerValueLabelRect = QRect{
|
||||
stackPointerHeadingLabelRect.right() + labelRightMargin,
|
||||
labelRect.bottom() + labelBottomMargin,
|
||||
stackPointerLabelSize.width(),
|
||||
stackPointerLabelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
const auto stackSizeHeadingLabelRect = QRect(
|
||||
const auto stackSizeHeadingLabelRect = QRect{
|
||||
labelRect.left() + (labelRect.width() / 2) - (
|
||||
(stackSizeHeadingLabelSize.width() + stackSizeLabelSize.width()) / 2
|
||||
),
|
||||
stackPointerHeadingLabelRect.bottom() + labelBottomMargin,
|
||||
stackSizeHeadingLabelSize.width(),
|
||||
stackSizeHeadingLabelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
const auto stackSizeValueLabelRect = QRect(
|
||||
const auto stackSizeValueLabelRect = QRect{
|
||||
stackSizeHeadingLabelRect.right() + labelRightMargin,
|
||||
stackPointerHeadingLabelRect.bottom() + labelBottomMargin,
|
||||
stackSizeLabelSize.width(),
|
||||
stackSizeLabelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->setPen(lineColor);
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineStartX,
|
||||
verticalLineYStart,
|
||||
lineStartX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineEndX,
|
||||
verticalLineYStart,
|
||||
lineEndX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineStartX,
|
||||
verticalLineYStart,
|
||||
lineEndX,
|
||||
verticalLineYStart
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
position.x() + groupWidth / 2,
|
||||
verticalLineYStart - labelLineHeight,
|
||||
position.x() + groupWidth / 2,
|
||||
verticalLineYStart
|
||||
));
|
||||
});
|
||||
|
||||
painter->setPen(headingLabelFontColor);
|
||||
|
||||
@@ -623,77 +620,77 @@ namespace Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
static constexpr auto standardBackgroundColor = QColor(0x32, 0x33, 0x30, 0);
|
||||
static constexpr auto selectedBackgroundColor = QColor(0x3C, 0x59, 0x5C, 255);
|
||||
static constexpr auto primaryHighlightedBackgroundColor = QColor(0x3B, 0x59, 0x37, 255);
|
||||
static constexpr auto groupedBackgroundColor = QColor(0x44, 0x44, 0x41, 255);
|
||||
static constexpr auto stackMemoryBackgroundColor = QColor(0x44, 0x44, 0x41, 200);
|
||||
static constexpr auto stackMemoryBarColor = QColor(0x67, 0x57, 0x20, 255);
|
||||
static constexpr auto changedMemoryBackgroundColor = QColor(0x5C, 0x49, 0x5D, 200);
|
||||
static constexpr auto changedMemoryFadedBackgroundColor = QColor(0x5C, 0x49, 0x5D, 125);
|
||||
static constexpr auto standardBackgroundColor = QColor{0x32, 0x33, 0x30, 0};
|
||||
static constexpr auto selectedBackgroundColor = QColor{0x3C, 0x59, 0x5C, 255};
|
||||
static constexpr auto primaryHighlightedBackgroundColor = QColor{0x3B, 0x59, 0x37, 255};
|
||||
static constexpr auto groupedBackgroundColor = QColor{0x44, 0x44, 0x41, 255};
|
||||
static constexpr auto stackMemoryBackgroundColor = QColor{0x44, 0x44, 0x41, 200};
|
||||
static constexpr auto stackMemoryBarColor = QColor{0x67, 0x57, 0x20, 255};
|
||||
static constexpr auto changedMemoryBackgroundColor = QColor{0x5C, 0x49, 0x5D, 200};
|
||||
static constexpr auto changedMemoryFadedBackgroundColor = QColor{0x5C, 0x49, 0x5D, 125};
|
||||
|
||||
static const auto hoveredStackMemoryBackgroundColor = QColor(
|
||||
static const auto hoveredStackMemoryBackgroundColor = QColor{
|
||||
stackMemoryBackgroundColor.red(),
|
||||
stackMemoryBackgroundColor.green(),
|
||||
stackMemoryBackgroundColor.blue(),
|
||||
255
|
||||
);
|
||||
};
|
||||
|
||||
static constexpr auto hoveredBackgroundColor = QColor(0x8E, 0x8B, 0x83, 70);
|
||||
static constexpr auto hoveredBackgroundColor = QColor{0x8E, 0x8B, 0x83, 70};
|
||||
|
||||
static constexpr auto standardFontColor = QColor(0xAF, 0xB1, 0xB3);
|
||||
static constexpr auto fadedFontColor = QColor(0xAF, 0xB1, 0xB3, 100);
|
||||
static constexpr auto asciiFontColor = QColor(0xA7, 0x77, 0x26);
|
||||
static constexpr auto changedMemoryAsciiFontColor = QColor(0xB7, 0x7F, 0x21);
|
||||
static constexpr auto standardFontColor = QColor{0xAF, 0xB1, 0xB3};
|
||||
static constexpr auto fadedFontColor = QColor{0xAF, 0xB1, 0xB3, 100};
|
||||
static constexpr auto asciiFontColor = QColor{0xA7, 0x77, 0x26};
|
||||
static constexpr auto changedMemoryAsciiFontColor = QColor{0xB7, 0x7F, 0x21};
|
||||
|
||||
const auto byteItemRect = QRect(0, 0, ByteItem::WIDTH, ByteItem::HEIGHT);
|
||||
const auto byteItemRect = QRect{0, 0, ByteItem::WIDTH, ByteItem::HEIGHT};
|
||||
const auto byteItemSize = byteItemRect.size();
|
||||
|
||||
auto standardTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto standardTemplatePixmap = QPixmap{byteItemSize};
|
||||
standardTemplatePixmap.fill(standardBackgroundColor);
|
||||
|
||||
auto primaryHighlightedTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto primaryHighlightedTemplatePixmap = QPixmap{byteItemSize};
|
||||
primaryHighlightedTemplatePixmap.fill(primaryHighlightedBackgroundColor);
|
||||
|
||||
auto selectedTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto selectedTemplatePixmap = QPixmap{byteItemSize};
|
||||
selectedTemplatePixmap.fill(selectedBackgroundColor);
|
||||
|
||||
auto groupedTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto groupedTemplatePixmap = QPixmap{byteItemSize};
|
||||
groupedTemplatePixmap.fill(groupedBackgroundColor);
|
||||
|
||||
auto stackMemoryTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto stackMemoryTemplatePixmap = QPixmap{byteItemSize};
|
||||
stackMemoryTemplatePixmap.fill(stackMemoryBackgroundColor);
|
||||
|
||||
{
|
||||
auto painter = QPainter(&stackMemoryTemplatePixmap);
|
||||
auto painter = QPainter{&stackMemoryTemplatePixmap};
|
||||
painter.setBrush(stackMemoryBarColor);
|
||||
painter.setPen(Qt::PenStyle::NoPen);
|
||||
painter.drawRect(0, byteItemSize.height() - 3, byteItemSize.width(), 3);
|
||||
}
|
||||
|
||||
auto changedMemoryTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto changedMemoryTemplatePixmap = QPixmap{byteItemSize};
|
||||
changedMemoryTemplatePixmap.fill(changedMemoryBackgroundColor);
|
||||
|
||||
auto changedMemoryFadedTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto changedMemoryFadedTemplatePixmap = QPixmap{byteItemSize};
|
||||
changedMemoryFadedTemplatePixmap.fill(changedMemoryFadedBackgroundColor);
|
||||
|
||||
auto hoveredStackMemoryTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto hoveredStackMemoryTemplatePixmap = QPixmap{byteItemSize};
|
||||
hoveredStackMemoryTemplatePixmap.fill(hoveredStackMemoryBackgroundColor);
|
||||
|
||||
auto hoveredPrimaryTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto hoveredPrimaryTemplatePixmap = QPixmap{byteItemSize};
|
||||
hoveredPrimaryTemplatePixmap.fill(hoveredBackgroundColor);
|
||||
|
||||
static auto font = QFont("'Ubuntu', sans-serif", 8);
|
||||
static auto font = QFont{"'Ubuntu', sans-serif", 8};
|
||||
|
||||
for (std::uint16_t value = 0x00; value <= 0xFF; ++value) {
|
||||
for (auto value = std::uint16_t{0}; value <= 0xFF; ++value) {
|
||||
const auto hexValue = QString::number(value, 16).rightJustified(2, '0').toUpper();
|
||||
const auto asciiValue = value >= 32 && value <= 126
|
||||
? std::optional("'" + QString(QChar(value)) + "'")
|
||||
? std::optional{"'" + QString{QChar{value}} + "'"}
|
||||
: std::nullopt;
|
||||
|
||||
{
|
||||
auto standardPixmap = standardTemplatePixmap;
|
||||
auto painter = QPainter(&standardPixmap);
|
||||
auto painter = QPainter{&standardPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -703,7 +700,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto selectedPixmap = selectedTemplatePixmap;
|
||||
auto painter = QPainter(&selectedPixmap);
|
||||
auto painter = QPainter{&selectedPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -713,7 +710,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto primaryHighlightedPixmap = primaryHighlightedTemplatePixmap;
|
||||
auto painter = QPainter(&primaryHighlightedPixmap);
|
||||
auto painter = QPainter{&primaryHighlightedPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -723,7 +720,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto groupedPixmap = groupedTemplatePixmap;
|
||||
auto painter = QPainter(&groupedPixmap);
|
||||
auto painter = QPainter{&groupedPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -733,7 +730,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto stackMemoryPixmap = stackMemoryTemplatePixmap;
|
||||
auto painter = QPainter(&stackMemoryPixmap);
|
||||
auto painter = QPainter{&stackMemoryPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -743,7 +740,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto changedMemoryPixmap = changedMemoryTemplatePixmap;
|
||||
auto painter = QPainter(&changedMemoryPixmap);
|
||||
auto painter = QPainter{&changedMemoryPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -753,7 +750,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto hoveredPrimaryPixmap = hoveredPrimaryTemplatePixmap;
|
||||
auto painter = QPainter(&hoveredPrimaryPixmap);
|
||||
auto painter = QPainter{&hoveredPrimaryPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -763,7 +760,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto standardAsciiPixmap = standardTemplatePixmap;
|
||||
auto painter = QPainter(&standardAsciiPixmap);
|
||||
auto painter = QPainter{&standardAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? asciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -773,7 +770,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto selectedAsciiPixmap = selectedTemplatePixmap;
|
||||
auto painter = QPainter(&selectedAsciiPixmap);
|
||||
auto painter = QPainter{&selectedAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? asciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -783,7 +780,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto primaryHighlightedAsciiPixmap = primaryHighlightedTemplatePixmap;
|
||||
auto painter = QPainter(&primaryHighlightedAsciiPixmap);
|
||||
auto painter = QPainter{&primaryHighlightedAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? asciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -795,7 +792,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto groupedAsciiPixmap = groupedTemplatePixmap;
|
||||
auto painter = QPainter(&groupedAsciiPixmap);
|
||||
auto painter = QPainter{&groupedAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? asciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -805,7 +802,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto stackMemoryAsciiPixmap = stackMemoryTemplatePixmap;
|
||||
auto painter = QPainter(&stackMemoryAsciiPixmap);
|
||||
auto painter = QPainter{&stackMemoryAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? asciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -818,7 +815,7 @@ namespace Widgets
|
||||
? changedMemoryTemplatePixmap
|
||||
: changedMemoryFadedTemplatePixmap;
|
||||
|
||||
auto painter = QPainter(&changedMemoryAsciiPixmap);
|
||||
auto painter = QPainter{&changedMemoryAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? changedMemoryAsciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -828,7 +825,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto hoveredPrimaryAsciiPixmap = hoveredPrimaryTemplatePixmap;
|
||||
auto painter = QPainter(&hoveredPrimaryAsciiPixmap);
|
||||
auto painter = QPainter{&hoveredPrimaryAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? asciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -839,7 +836,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
HexViewerItemRenderer::missingDataPixmap = standardTemplatePixmap;
|
||||
auto painter = QPainter(&HexViewerItemRenderer::missingDataPixmap.value());
|
||||
auto painter = QPainter{&HexViewerItemRenderer::missingDataPixmap.value()};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, "??");
|
||||
@@ -847,7 +844,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
HexViewerItemRenderer::selectedMissingDataPixmap = selectedTemplatePixmap;
|
||||
auto painter = QPainter(&HexViewerItemRenderer::selectedMissingDataPixmap.value());
|
||||
auto painter = QPainter{&HexViewerItemRenderer::selectedMissingDataPixmap.value()};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, "??");
|
||||
@@ -855,7 +852,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
HexViewerItemRenderer::primaryHighlightedMissingDataPixmap = primaryHighlightedTemplatePixmap;
|
||||
auto painter = QPainter(&HexViewerItemRenderer::primaryHighlightedMissingDataPixmap.value());
|
||||
auto painter = QPainter{&HexViewerItemRenderer::primaryHighlightedMissingDataPixmap.value()};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, "??");
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Widgets
|
||||
);
|
||||
|
||||
[[nodiscard]] QRectF boundingRect() const override {
|
||||
return QRectF(0, 0, this->size.width(), this->size.height());
|
||||
return QRectF{0, 0, static_cast<qreal>(this->size.width()), static_cast<qreal>(this->size.height())};
|
||||
}
|
||||
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
#include <optional>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
|
||||
#include "HexViewerWidgetSettings.hpp"
|
||||
|
||||
namespace Widgets
|
||||
@@ -12,7 +15,9 @@ namespace Widgets
|
||||
struct HexViewerSharedState
|
||||
{
|
||||
public:
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data;
|
||||
|
||||
HexViewerWidgetSettings& settings;
|
||||
@@ -23,11 +28,13 @@ namespace Widgets
|
||||
std::set<Targets::TargetMemoryAddressRange> highlightedPrimaryAddressRanges;
|
||||
|
||||
HexViewerSharedState(
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
HexViewerWidgetSettings& settings
|
||||
)
|
||||
: memoryDescriptor(memoryDescriptor)
|
||||
: addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, data(data)
|
||||
, settings(settings)
|
||||
{}
|
||||
|
||||
@@ -14,10 +14,14 @@ namespace Widgets
|
||||
{
|
||||
using namespace Exceptions;
|
||||
|
||||
using Targets::TargetMemoryDescriptor;
|
||||
using Targets::TargetAddressSpaceDescriptor;
|
||||
using Targets::TargetMemorySegmentDescriptor;
|
||||
using Targets::TargetState;
|
||||
|
||||
HexViewerWidget::HexViewerWidget(
|
||||
const TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
HexViewerWidgetSettings& settings,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
@@ -25,7 +29,9 @@ namespace Widgets
|
||||
QWidget* parent
|
||||
)
|
||||
: QWidget(parent)
|
||||
, targetMemoryDescriptor(targetMemoryDescriptor)
|
||||
, addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, targetState(targetState)
|
||||
, data(data)
|
||||
, settings(settings)
|
||||
, focusedMemoryRegions(focusedMemoryRegions)
|
||||
@@ -34,29 +40,29 @@ namespace Widgets
|
||||
this->setObjectName("hex-viewer-widget");
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
auto widgetUiFile = QFile(
|
||||
auto widgetUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget"
|
||||
+ "/UiFiles/HexViewerWidget.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
auto stylesheetFile = QFile(
|
||||
auto stylesheetFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget"
|
||||
+ "/Stylesheets/HexViewerWidget.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!widgetUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open HexViewerWidget UI file");
|
||||
throw Exception{"Failed to open HexViewerWidget UI file"};
|
||||
}
|
||||
|
||||
if (!stylesheetFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open HexViewerWidget stylesheet file");
|
||||
throw Exception{"Failed to open HexViewerWidget stylesheet file"};
|
||||
}
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->container = uiLoader.load(&widgetUiFile, this);
|
||||
this->setStyleSheet(stylesheetFile.readAll());
|
||||
this->container->setFixedSize(this->size());
|
||||
@@ -95,7 +101,7 @@ namespace Widgets
|
||||
this->setAnnotationsEnabled(this->settings.displayAnnotations);
|
||||
this->setDisplayAsciiEnabled(this->settings.displayAsciiValues);
|
||||
|
||||
if (this->targetMemoryDescriptor.type == Targets::TargetMemoryType::RAM) {
|
||||
if (this->memorySegmentDescriptor.type == Targets::TargetMemorySegmentType::RAM) {
|
||||
this->groupStackMemoryButton->show();
|
||||
this->setStackMemoryGroupingEnabled(this->settings.groupStackMemory);
|
||||
|
||||
@@ -163,25 +169,20 @@ namespace Widgets
|
||||
&HexViewerWidget::onGoToAddressInputChanged
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
InsightSignals::instance(),
|
||||
&InsightSignals::targetStateUpdated,
|
||||
this,
|
||||
&HexViewerWidget::onTargetStateChanged
|
||||
);
|
||||
|
||||
this->show();
|
||||
}
|
||||
|
||||
void HexViewerWidget::init() {
|
||||
this->byteItemGraphicsView = new ItemGraphicsView(
|
||||
this->targetMemoryDescriptor,
|
||||
this->byteItemGraphicsView = new ItemGraphicsView{
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetState,
|
||||
this->data,
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->settings,
|
||||
this->container
|
||||
);
|
||||
};
|
||||
|
||||
this->byteItemGraphicsView->hide();
|
||||
|
||||
@@ -271,11 +272,6 @@ namespace Widgets
|
||||
QWidget::showEvent(event);
|
||||
}
|
||||
|
||||
void HexViewerWidget::onTargetStateChanged(Targets::TargetState newState) {
|
||||
using Targets::TargetState;
|
||||
this->targetState = newState;
|
||||
}
|
||||
|
||||
void HexViewerWidget::setStackMemoryGroupingEnabled(bool enabled) {
|
||||
this->groupStackMemoryButton->setChecked(enabled);
|
||||
this->settings.groupStackMemory = enabled;
|
||||
@@ -336,12 +332,14 @@ namespace Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
auto addressConversionOk = false;
|
||||
const auto address = this->goToAddressInput->text().toUInt(&addressConversionOk, 16);
|
||||
auto conversionStatus = false;
|
||||
const auto address = this->goToAddressInput->text().toUInt(&conversionStatus, 16);
|
||||
|
||||
const auto& memoryAddressRange = this->targetMemoryDescriptor.addressRange;
|
||||
|
||||
if (addressConversionOk && memoryAddressRange.contains(address) && this->goToAddressInput->hasFocus()) {
|
||||
if (
|
||||
conversionStatus
|
||||
&& this->memorySegmentDescriptor.addressRange.contains(address)
|
||||
&& this->goToAddressInput->hasFocus()
|
||||
) {
|
||||
this->byteItemGraphicsScene->selectByteItems({address});
|
||||
this->byteItemGraphicsView->scrollToByteItemAtAddress(address);
|
||||
return;
|
||||
@@ -361,7 +359,7 @@ namespace Widgets
|
||||
16
|
||||
).rightJustified(8, '0').toUpper();
|
||||
|
||||
const auto relativeAddress = *address - this->targetMemoryDescriptor.addressRange.startAddress;
|
||||
const auto relativeAddress = *address - this->memorySegmentDescriptor.addressRange.startAddress;
|
||||
const auto relativeAddressHex = "0x" + QString::number(
|
||||
relativeAddress,
|
||||
16
|
||||
@@ -383,7 +381,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
this->selectionCountLabel->setText(
|
||||
QLocale(QLocale::English).toString(selectionCount) + " " + QString(selectionCount == 1 ? "byte" : "bytes")
|
||||
QLocale{QLocale::English}.toString(selectionCount) + " " + QString(selectionCount == 1 ? "byte" : "bytes")
|
||||
+ " selected"
|
||||
);
|
||||
this->selectionCountLabel->show();
|
||||
@@ -392,7 +390,7 @@ namespace Widgets
|
||||
std::set<Targets::TargetMemoryAddress> HexViewerWidget::addressRangesToAddresses(
|
||||
const std::set<Targets::TargetMemoryAddressRange>& addressRanges
|
||||
) {
|
||||
auto addresses = std::set<Targets::TargetMemoryAddress>();
|
||||
auto addresses = std::set<Targets::TargetMemoryAddress>{};
|
||||
auto addressesIt = addresses.end();
|
||||
|
||||
for (const auto& range : addressRanges) {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <optional>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
|
||||
@@ -29,7 +31,9 @@ namespace Widgets
|
||||
|
||||
public:
|
||||
HexViewerWidget(
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
HexViewerWidgetSettings& settings,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
@@ -52,7 +56,9 @@ namespace Widgets
|
||||
void settingsChanged(const HexViewerWidgetSettings& settings);
|
||||
|
||||
protected:
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
const Targets::TargetState& targetState;
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data;
|
||||
|
||||
HexViewerWidgetSettings& settings;
|
||||
@@ -78,8 +84,6 @@ namespace Widgets
|
||||
|
||||
TextInput* goToAddressInput = nullptr;
|
||||
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
void showEvent(QShowEvent* event) override;
|
||||
void onTargetStateChanged(Targets::TargetState newState);
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "src/Insight/InsightWorker/InsightWorker.hpp"
|
||||
#include "src/Insight/InsightSignals.hpp"
|
||||
|
||||
#include "src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.hpp"
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
ItemGraphicsScene::ItemGraphicsScene(
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
@@ -27,19 +27,21 @@ namespace Widgets
|
||||
)
|
||||
: QGraphicsScene(parent)
|
||||
, state(
|
||||
HexViewerSharedState(
|
||||
targetMemoryDescriptor,
|
||||
HexViewerSharedState{
|
||||
addressSpaceDescriptor,
|
||||
memorySegmentDescriptor,
|
||||
data,
|
||||
settings
|
||||
)
|
||||
}
|
||||
)
|
||||
, targetState(targetState)
|
||||
, focusedMemoryRegions(focusedMemoryRegions)
|
||||
, excludedMemoryRegions(excludedMemoryRegions)
|
||||
, parent(parent)
|
||||
{
|
||||
this->setObjectName("byte-widget-container");
|
||||
|
||||
this->byteAddressContainer = new ByteAddressContainer(this->state);
|
||||
this->byteAddressContainer = new ByteAddressContainer{this->state};
|
||||
this->addItem(this->byteAddressContainer);
|
||||
|
||||
this->displayRelativeAddressAction->setCheckable(true);
|
||||
@@ -48,13 +50,6 @@ namespace Widgets
|
||||
this->setAddressType(this->state.settings.addressLabelType);
|
||||
this->setItemIndexMethod(QGraphicsScene::ItemIndexMethod::NoIndex);
|
||||
|
||||
QObject::connect(
|
||||
InsightSignals::instance(),
|
||||
&InsightSignals::targetStateUpdated,
|
||||
this,
|
||||
&ItemGraphicsScene::onTargetStateChanged
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
this->displayRelativeAddressAction,
|
||||
&QAction::triggered,
|
||||
@@ -168,14 +163,14 @@ namespace Widgets
|
||||
void ItemGraphicsScene::init() {
|
||||
this->byteAddressContainer->setPos(this->addressContainerPosition());
|
||||
|
||||
const auto constructHexViewerTopLevelGroupItem = QSharedPointer<ConstructHexViewerTopLevelGroupItem>(
|
||||
new ConstructHexViewerTopLevelGroupItem(
|
||||
const auto constructHexViewerTopLevelGroupItem = QSharedPointer<ConstructHexViewerTopLevelGroupItem>{
|
||||
new ConstructHexViewerTopLevelGroupItem{
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->state
|
||||
),
|
||||
},
|
||||
&QObject::deleteLater
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
constructHexViewerTopLevelGroupItem.get(),
|
||||
@@ -186,7 +181,7 @@ namespace Widgets
|
||||
|
||||
this->topLevelGroup.reset(item);
|
||||
this->topLevelGroup->setPosition(
|
||||
QPoint(ByteAddressContainer::WIDTH + margins.left(), margins.top())
|
||||
QPoint{ByteAddressContainer::WIDTH + margins.left(), margins.top()}
|
||||
);
|
||||
|
||||
this->itemIndex = std::make_unique<HexViewerItemIndex>(this->topLevelGroup.get(), this);
|
||||
@@ -267,14 +262,13 @@ namespace Widgets
|
||||
this->topLevelGroup->adjustItemPositions(availableWidth);
|
||||
this->itemIndex->refreshIndex();
|
||||
|
||||
const auto sceneSize = QSize(
|
||||
const auto sceneSize = QSize{
|
||||
width,
|
||||
std::max(
|
||||
static_cast<int>(this->topLevelGroup->size().height())
|
||||
+ margins.top() + margins.bottom(),
|
||||
static_cast<int>(this->topLevelGroup->size().height()) + margins.top() + margins.bottom(),
|
||||
this->parent->height()
|
||||
)
|
||||
);
|
||||
};
|
||||
this->setSceneRect(
|
||||
0,
|
||||
0,
|
||||
@@ -317,7 +311,7 @@ namespace Widgets
|
||||
return byteItemIt->second.position();
|
||||
}
|
||||
|
||||
return QPointF();
|
||||
return QPointF{};
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::addExternalContextMenuAction(ContextMenuAction* action) {
|
||||
@@ -329,22 +323,22 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::initRenderer() {
|
||||
this->renderer = new HexViewerItemRenderer(
|
||||
this->renderer = new HexViewerItemRenderer{
|
||||
this->state,
|
||||
*(this->topLevelGroup.get()),
|
||||
*(this->itemIndex.get()),
|
||||
this->views().first()
|
||||
);
|
||||
};
|
||||
this->renderer->setPos(0, 0);
|
||||
this->addItem(this->renderer);
|
||||
}
|
||||
|
||||
QMargins ItemGraphicsScene::margins() {
|
||||
return QMargins(10, 10, 10, 10);
|
||||
return QMargins{10, 10, 10, 10};
|
||||
}
|
||||
|
||||
QPointF ItemGraphicsScene::addressContainerPosition() {
|
||||
return QPointF(0, 0);
|
||||
return QPointF{0, 0};
|
||||
}
|
||||
|
||||
bool ItemGraphicsScene::event(QEvent* event) {
|
||||
@@ -360,8 +354,8 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* mouseEvent) {
|
||||
static const auto rubberBandRectBackgroundColor = QColor(0x3C, 0x59, 0x5C, 0x82);
|
||||
static const auto rubberBandRectBorderColor = QColor(0x3C, 0x59, 0x5C, 255);
|
||||
static const auto rubberBandRectBackgroundColor = QColor{0x3C, 0x59, 0x5C, 0x82};
|
||||
static const auto rubberBandRectBorderColor = QColor{0x3C, 0x59, 0x5C, 255};
|
||||
|
||||
const auto button = mouseEvent->button();
|
||||
const auto mousePosition = mouseEvent->buttonDownScenePos(button);
|
||||
@@ -377,7 +371,7 @@ namespace Widgets
|
||||
this->update();
|
||||
|
||||
if (button == Qt::MouseButton::RightButton) {
|
||||
ByteItem* clickedByteItem = this->itemIndex->byteItemAt(mousePosition);
|
||||
auto* clickedByteItem = this->itemIndex->byteItemAt(mousePosition);
|
||||
|
||||
if (clickedByteItem == nullptr || clickedByteItem->selected) {
|
||||
return;
|
||||
@@ -389,12 +383,12 @@ namespace Widgets
|
||||
this->clearSelectionRectItem();
|
||||
|
||||
this->rubberBandInitPoint = std::move(mousePosition);
|
||||
this->rubberBandRectItem = new QGraphicsRectItem(
|
||||
this->rubberBandRectItem = new QGraphicsRectItem{
|
||||
this->rubberBandInitPoint->x(),
|
||||
this->rubberBandInitPoint->y(),
|
||||
1,
|
||||
1
|
||||
);
|
||||
};
|
||||
this->rubberBandRectItem->setBrush(rubberBandRectBackgroundColor);
|
||||
this->rubberBandRectItem->setPen(rubberBandRectBorderColor);
|
||||
this->addItem(this->rubberBandRectItem);
|
||||
@@ -409,7 +403,7 @@ namespace Widgets
|
||||
if ((modifiers & Qt::ShiftModifier) != 0) {
|
||||
for (
|
||||
auto i = static_cast<std::int64_t>(clickedByteItem->startAddress);
|
||||
i >= this->state.memoryDescriptor.addressRange.startAddress;
|
||||
i >= this->state.memorySegmentDescriptor.addressRange.startAddress;
|
||||
--i
|
||||
) {
|
||||
auto& byteItem = this->topLevelGroup->byteItemsByAddress.at(
|
||||
@@ -500,11 +494,11 @@ namespace Widgets
|
||||
|
||||
void ItemGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) {
|
||||
if (event->scenePos().x() <= ByteAddressContainer::WIDTH) {
|
||||
auto* menu = new QMenu(this->parent);
|
||||
auto* menu = new QMenu{this->parent};
|
||||
menu->setLayoutDirection(Qt::LayoutDirection::LeftToRight);
|
||||
menu->setObjectName("byte-item-address-container-context-menu");
|
||||
|
||||
auto* addressTypeMenu = new QMenu("Address Type", menu);
|
||||
auto* addressTypeMenu = new QMenu{"Address Type", menu};
|
||||
addressTypeMenu->addAction(this->displayAbsoluteAddressAction);
|
||||
addressTypeMenu->addAction(this->displayRelativeAddressAction);
|
||||
menu->addMenu(addressTypeMenu);
|
||||
@@ -515,13 +509,13 @@ namespace Widgets
|
||||
|
||||
const auto itemsSelected = !this->selectedByteItemAddresses.empty();
|
||||
|
||||
auto* menu = new QMenu(this->parent);
|
||||
auto* menu = new QMenu{this->parent};
|
||||
menu->setLayoutDirection(Qt::LayoutDirection::LeftToRight);
|
||||
menu->addAction(this->selectAllByteItemsAction);
|
||||
menu->addAction(this->deselectByteItemsAction);
|
||||
menu->addSeparator();
|
||||
|
||||
auto* copyMenu = new QMenu("Copy Selection", menu);
|
||||
auto* copyMenu = new QMenu{"Copy Selection", menu};
|
||||
copyMenu->addAction(this->copyAbsoluteAddressAction);
|
||||
copyMenu->addAction(this->copyRelativeAddressAction);
|
||||
copyMenu->addSeparator();
|
||||
@@ -561,10 +555,6 @@ namespace Widgets
|
||||
return this->views().first()->verticalScrollBar()->value();
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::onTargetStateChanged(Targets::TargetState newState) {
|
||||
this->targetState = newState;
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::onByteItemEnter(ByteItem& byteItem) {
|
||||
if (this->state.hoveredByteItem != nullptr) {
|
||||
if (this->state.hoveredByteItem == &byteItem) {
|
||||
@@ -646,7 +636,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
std::set<Targets::TargetMemoryAddress> ItemGraphicsScene::excludedAddresses() {
|
||||
auto output = std::set<Targets::TargetMemoryAddress>();
|
||||
auto output = std::set<Targets::TargetMemoryAddress>{};
|
||||
|
||||
for (const auto& excludedRegion : this->excludedMemoryRegions) {
|
||||
const auto regionAddresses = excludedRegion.addressRange.addresses();
|
||||
@@ -661,8 +651,8 @@ namespace Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
auto data = QString();
|
||||
const auto memoryStartAddress = this->state.memoryDescriptor.addressRange.startAddress;
|
||||
auto data = QString{};
|
||||
const auto memoryStartAddress = this->state.memorySegmentDescriptor.addressRange.startAddress;
|
||||
|
||||
for (const auto& address : this->selectedByteItemAddresses) {
|
||||
data.append(
|
||||
@@ -684,12 +674,12 @@ namespace Widgets
|
||||
}
|
||||
|
||||
const auto excludedAddresses = this->excludedAddresses();
|
||||
auto data = QString();
|
||||
auto data = QString{};
|
||||
|
||||
for (const auto& address : this->selectedByteItemAddresses) {
|
||||
const unsigned char byteValue = excludedAddresses.contains(address)
|
||||
? 0x00
|
||||
: (*this->state.data)[address - this->state.memoryDescriptor.addressRange.startAddress];
|
||||
: (*this->state.data)[address - this->state.memorySegmentDescriptor.addressRange.startAddress];
|
||||
|
||||
data.append(
|
||||
withDelimiters
|
||||
@@ -707,12 +697,12 @@ namespace Widgets
|
||||
}
|
||||
|
||||
const auto excludedAddresses = this->excludedAddresses();
|
||||
auto data = QString();
|
||||
auto data = QString{};
|
||||
|
||||
for (const auto& address : this->selectedByteItemAddresses) {
|
||||
const unsigned char byteValue = excludedAddresses.contains(address)
|
||||
? 0x00
|
||||
: (*this->state.data)[address - this->state.memoryDescriptor.addressRange.startAddress];
|
||||
: (*this->state.data)[address - this->state.memorySegmentDescriptor.addressRange.startAddress];
|
||||
data.append(QString::number(byteValue, 10) + "\n");
|
||||
}
|
||||
|
||||
@@ -725,12 +715,12 @@ namespace Widgets
|
||||
}
|
||||
|
||||
const auto excludedAddresses = this->excludedAddresses();
|
||||
auto data = QString();
|
||||
auto data = QString{};
|
||||
|
||||
for (const auto& address : this->selectedByteItemAddresses) {
|
||||
const unsigned char byteValue = excludedAddresses.contains(address)
|
||||
? 0x00
|
||||
: (*this->state.data)[address - this->state.memoryDescriptor.addressRange.startAddress];
|
||||
: (*this->state.data)[address - this->state.memorySegmentDescriptor.addressRange.startAddress];
|
||||
|
||||
data.append(
|
||||
withDelimiters
|
||||
@@ -748,12 +738,12 @@ namespace Widgets
|
||||
}
|
||||
|
||||
const auto excludedAddresses = this->excludedAddresses();
|
||||
auto data = QJsonObject();
|
||||
auto data = QJsonObject{};
|
||||
|
||||
for (const auto& address : this->selectedByteItemAddresses) {
|
||||
const unsigned char byteValue = excludedAddresses.contains(address)
|
||||
? 0x00
|
||||
: (*this->state.data)[address - this->state.memoryDescriptor.addressRange.startAddress];
|
||||
: (*this->state.data)[address - this->state.memorySegmentDescriptor.addressRange.startAddress];
|
||||
|
||||
data.insert(
|
||||
"0x" + QString::number(address, 16).rightJustified(8, '0').toUpper(),
|
||||
@@ -761,7 +751,7 @@ namespace Widgets
|
||||
);
|
||||
}
|
||||
|
||||
QApplication::clipboard()->setText(QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Indented));
|
||||
QApplication::clipboard()->setText(QJsonDocument{data}.toJson(QJsonDocument::JsonFormat::Indented));
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::copyAsciiValueToClipboard() {
|
||||
@@ -770,17 +760,17 @@ namespace Widgets
|
||||
}
|
||||
|
||||
const auto excludedAddresses = this->excludedAddresses();
|
||||
auto data = QString();
|
||||
auto data = QString{};
|
||||
|
||||
for (const auto& address : this->selectedByteItemAddresses) {
|
||||
const unsigned char byteValue =
|
||||
(*this->state.data)[address - this->state.memoryDescriptor.addressRange.startAddress];
|
||||
(*this->state.data)[address - this->state.memorySegmentDescriptor.addressRange.startAddress];
|
||||
|
||||
if (excludedAddresses.contains(address) || byteValue < 32 || byteValue > 126) {
|
||||
continue;
|
||||
}
|
||||
|
||||
data.append(QChar(byteValue));
|
||||
data.append(QChar{byteValue});
|
||||
}
|
||||
|
||||
QApplication::clipboard()->setText(std::move(data));
|
||||
@@ -789,7 +779,7 @@ namespace Widgets
|
||||
std::set<Targets::TargetMemoryAddress> ItemGraphicsScene::addressRangesToAddresses(
|
||||
const std::set<Targets::TargetMemoryAddressRange>& addressRanges
|
||||
) {
|
||||
auto addresses = std::set<Targets::TargetMemoryAddress>();
|
||||
auto addresses = std::set<Targets::TargetMemoryAddress>{};
|
||||
|
||||
for (const auto& range : addressRanges) {
|
||||
const auto rangeAddresses = range.addresses();
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
|
||||
@@ -45,7 +47,9 @@ namespace Widgets
|
||||
|
||||
public:
|
||||
ItemGraphicsScene(
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
@@ -76,6 +80,7 @@ namespace Widgets
|
||||
bool enabled = true;
|
||||
|
||||
HexViewerSharedState state;
|
||||
const Targets::TargetState& targetState;
|
||||
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions;
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
||||
@@ -85,8 +90,6 @@ namespace Widgets
|
||||
|
||||
HexViewerItemRenderer* renderer = nullptr;
|
||||
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
|
||||
QGraphicsView* parent = nullptr;
|
||||
|
||||
ByteAddressContainer* byteAddressContainer = nullptr;
|
||||
@@ -143,7 +146,6 @@ namespace Widgets
|
||||
void keyPressEvent(QKeyEvent* keyEvent) override;
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent* event) override;
|
||||
int getScrollbarValue();
|
||||
void onTargetStateChanged(Targets::TargetState newState);
|
||||
void onByteItemEnter(ByteItem& byteItem);
|
||||
void onByteItemLeave();
|
||||
void clearSelectionRectItem();
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
using Targets::TargetMemoryDescriptor;
|
||||
using Targets::TargetMemorySegmentDescriptor;
|
||||
|
||||
ItemGraphicsView::ItemGraphicsView(
|
||||
const TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
@@ -17,7 +19,9 @@ namespace Widgets
|
||||
QWidget* parent
|
||||
)
|
||||
: QGraphicsView(parent)
|
||||
, targetMemoryDescriptor(targetMemoryDescriptor)
|
||||
, addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, targetState(targetState)
|
||||
, data(data)
|
||||
, focusedMemoryRegions(focusedMemoryRegions)
|
||||
, excludedMemoryRegions(excludedMemoryRegions)
|
||||
@@ -40,14 +44,16 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void ItemGraphicsView::initScene() {
|
||||
this->scene = new ItemGraphicsScene(
|
||||
this->targetMemoryDescriptor,
|
||||
this->scene = new ItemGraphicsScene{
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetState,
|
||||
this->data,
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->settings,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
this->setScene(this->scene);
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
#include "ItemGraphicsScene.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
|
||||
|
||||
namespace Widgets
|
||||
@@ -18,7 +22,9 @@ namespace Widgets
|
||||
|
||||
public:
|
||||
ItemGraphicsView(
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
@@ -38,7 +44,10 @@ namespace Widgets
|
||||
void sceneReady();
|
||||
|
||||
protected:
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
const Targets::TargetState& targetState;
|
||||
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data;
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions;
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Widgets
|
||||
, hexViewerState(hexViewerState)
|
||||
{
|
||||
const auto startAddress = this->startAddress;
|
||||
const auto endAddress = this->hexViewerState.memoryDescriptor.addressRange.endAddress;
|
||||
const auto endAddress = this->hexViewerState.memorySegmentDescriptor.addressRange.endAddress;
|
||||
|
||||
// Sanity check
|
||||
assert(byteItemsByAddress.contains(startAddress) && byteItemsByAddress.contains(endAddress));
|
||||
@@ -74,10 +74,7 @@ namespace Widgets
|
||||
updateChildItems(this->items, updateChildItems);
|
||||
}
|
||||
|
||||
void StackMemoryGroupItem::adjustItemPositions(
|
||||
const int maximumWidth,
|
||||
const HexViewerSharedState* hexViewerState
|
||||
) {
|
||||
void StackMemoryGroupItem::adjustItemPositions(int maximumWidth, const HexViewerSharedState* hexViewerState) {
|
||||
GroupItem::adjustItemPositions(maximumWidth, hexViewerState);
|
||||
this->groupSize.setWidth(maximumWidth);
|
||||
}
|
||||
@@ -88,10 +85,7 @@ namespace Widgets
|
||||
}
|
||||
}
|
||||
|
||||
QMargins StackMemoryGroupItem::groupMargins(
|
||||
const HexViewerSharedState* hexViewerState,
|
||||
const int maximumWidth
|
||||
) const {
|
||||
return QMargins(0, 100, 0, 20);
|
||||
QMargins StackMemoryGroupItem::groupMargins(const HexViewerSharedState* hexViewerState, int maximumWidth) const {
|
||||
return {0, 100, 0, 20};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ namespace Widgets
|
||||
|
||||
~StackMemoryGroupItem();
|
||||
|
||||
void adjustItemPositions(const int maximumWidth, const HexViewerSharedState* hexViewerState) override;
|
||||
void adjustItemPositions(int maximumWidth, const HexViewerSharedState* hexViewerState) override;
|
||||
|
||||
void refreshValues();
|
||||
|
||||
protected:
|
||||
QMargins groupMargins(const HexViewerSharedState* hexViewerState, const int maximumWidth) const override;
|
||||
QMargins groupMargins(const HexViewerSharedState* hexViewerState, int maximumWidth) const override;
|
||||
|
||||
bool positionOnNewLine(const int maximumWidth) override {
|
||||
return true;
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace Widgets
|
||||
, excludedMemoryRegions(excludedMemoryRegions)
|
||||
, hexViewerState(hexViewerState)
|
||||
{
|
||||
const auto memorySize = this->hexViewerState.memoryDescriptor.size();
|
||||
const auto startAddress = this->hexViewerState.memoryDescriptor.addressRange.startAddress;
|
||||
const auto memorySize = this->hexViewerState.memorySegmentDescriptor.size();
|
||||
const auto startAddress = this->hexViewerState.memorySegmentDescriptor.addressRange.startAddress;
|
||||
|
||||
for (Targets::TargetMemorySize i = 0; i < memorySize; i++) {
|
||||
const auto address = startAddress + i;
|
||||
@@ -29,8 +29,8 @@ namespace Widgets
|
||||
const auto& currentStackPointer = this->hexViewerState.currentStackPointer;
|
||||
const auto stackGroupingRequired = currentStackPointer.has_value()
|
||||
&& this->hexViewerState.settings.groupStackMemory
|
||||
&& *currentStackPointer >= this->hexViewerState.memoryDescriptor.addressRange.startAddress
|
||||
&& (*currentStackPointer + 1) <= this->hexViewerState.memoryDescriptor.addressRange.endAddress;
|
||||
&& *currentStackPointer >= this->hexViewerState.memorySegmentDescriptor.addressRange.startAddress
|
||||
&& (*currentStackPointer + 1) <= this->hexViewerState.memorySegmentDescriptor.addressRange.endAddress;
|
||||
|
||||
for (const auto& focusedRegion : this->focusedMemoryRegions) {
|
||||
if (
|
||||
@@ -48,7 +48,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
this->focusedRegionGroupItems.emplace_back(focusedRegion, this->byteItemsByAddress, this);
|
||||
items.emplace_back(&(this->focusedRegionGroupItems.back()));
|
||||
this->items.emplace_back(&(this->focusedRegionGroupItems.back()));
|
||||
}
|
||||
|
||||
if (stackGroupingRequired) {
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Widgets
|
||||
|
||||
void refreshValues();
|
||||
|
||||
void adjustItemPositions(const int maximumWidth) {
|
||||
void adjustItemPositions(int maximumWidth) {
|
||||
GroupItem::adjustItemPositions(maximumWidth, &(this->hexViewerState));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="20"
|
||||
width="14"
|
||||
height="16"
|
||||
viewBox="0 0 5.2916667 4.2333333"
|
||||
viewBox="0 0 3.7041667 4.2333333"
|
||||
version="1.1"
|
||||
id="svg974"
|
||||
sodipodi:docname="memory-inspection-icon.svg"
|
||||
inkscape:version="1.0.1 (1.0.1+r75)">
|
||||
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#">
|
||||
<defs
|
||||
id="defs968" />
|
||||
<sodipodi:namedview
|
||||
@@ -24,33 +23,29 @@
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="44.8"
|
||||
inkscape:cx="19.284495"
|
||||
inkscape:cy="7.1191996"
|
||||
inkscape:cx="19.0625"
|
||||
inkscape:cy="7.1205357"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer2"
|
||||
inkscape:document-rotation="0"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:snap-page="true"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-width="3440"
|
||||
inkscape:window-height="1353"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-x="2560"
|
||||
inkscape:window-y="34"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:snap-smooth-nodes="true"
|
||||
inkscape:snap-bbox="true"
|
||||
inkscape:snap-bbox-midpoints="true"
|
||||
inkscape:snap-bbox-edge-midpoints="true" />
|
||||
inkscape:snap-bbox-edge-midpoints="true"
|
||||
inkscape:pagecheckerboard="0" />
|
||||
<metadata
|
||||
id="metadata971">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
rdf:about="" />
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
@@ -66,105 +61,105 @@
|
||||
id="rect1537-3"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="1.5874999"
|
||||
x="0.79374993"
|
||||
y="1.058333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-6"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="0.79374987"
|
||||
x="-1.4002266e-07"
|
||||
y="1.058333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-7"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="2.3812499"
|
||||
x="1.5875"
|
||||
y="1.058333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="1.5875001"
|
||||
x="0.79375017"
|
||||
y="1.8520831" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-6"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="2.3812501"
|
||||
x="1.5875002"
|
||||
y="1.8520831" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-2"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="0.79374987"
|
||||
x="-1.4002266e-07"
|
||||
y="1.8520831" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-9"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="1.5875003"
|
||||
x="0.79375041"
|
||||
y="2.6458333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-6-1"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="2.3812501"
|
||||
x="1.5875002"
|
||||
y="2.6458333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-2-2"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="0.79374987"
|
||||
x="-1.4002266e-07"
|
||||
y="2.6458333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-70"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="3.175"
|
||||
x="2.3812499"
|
||||
y="1.058333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-7-9"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="3.9687502"
|
||||
x="3.1750002"
|
||||
y="1.058333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-3"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="3.1750002"
|
||||
x="2.3812501"
|
||||
y="1.8520831" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-6-6"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="3.9687502"
|
||||
x="3.1750002"
|
||||
y="1.8520831" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-9-0"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="3.1750004"
|
||||
x="2.3812504"
|
||||
y="2.6458335" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-6-1-6"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="3.9687502"
|
||||
x="3.1750002"
|
||||
y="2.6458335" />
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.6 KiB |
@@ -5,12 +5,10 @@
|
||||
|
||||
MemoryRegion::MemoryRegion(
|
||||
const QString& name,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
MemoryRegionType type,
|
||||
const Targets::TargetMemoryAddressRange& addressRange
|
||||
)
|
||||
: name(name)
|
||||
, memoryType(memoryType)
|
||||
, type(type)
|
||||
, addressRange(addressRange)
|
||||
{}
|
||||
@@ -20,45 +18,38 @@ MemoryRegion::MemoryRegion(const QJsonObject& jsonObject) {
|
||||
|
||||
if (
|
||||
!jsonObject.contains("name")
|
||||
|| !jsonObject.contains("memoryType")
|
||||
|| !jsonObject.contains("type")
|
||||
|| !jsonObject.contains("createdTimestamp")
|
||||
|| !jsonObject.contains("addressInputType")
|
||||
|| !jsonObject.contains("addressRange")
|
||||
) {
|
||||
throw Exception("Missing data");
|
||||
throw Exception{"Missing data"};
|
||||
}
|
||||
|
||||
const auto addressRangeObj = jsonObject.find("addressRange")->toObject();
|
||||
if (
|
||||
!addressRangeObj.contains("startAddress")
|
||||
|| !addressRangeObj.contains("endAddress")
|
||||
) {
|
||||
throw Exception("Missing address range data");
|
||||
if (!addressRangeObj.contains("startAddress") || !addressRangeObj.contains("endAddress")) {
|
||||
throw Exception{"Missing address range data"};
|
||||
}
|
||||
|
||||
this->name = jsonObject.find("name")->toString();
|
||||
this->memoryType = EnumToStringMappings::targetMemoryTypes.at(jsonObject.find("memoryType")->toString());
|
||||
this->type = MemoryRegion::memoryRegionTypesByName.at(jsonObject.find("type")->toString());
|
||||
this->createdDate.setSecsSinceEpoch(jsonObject.find("createdTimestamp")->toInteger());
|
||||
this->addressRangeInputType = MemoryRegion::addressTypesByName.at(jsonObject.find("addressInputType")->toString());
|
||||
|
||||
this->addressRange = {
|
||||
static_cast<std::uint32_t>(addressRangeObj.find("startAddress")->toInteger()),
|
||||
static_cast<std::uint32_t>(addressRangeObj.find("endAddress")->toInteger()),
|
||||
static_cast<Targets::TargetMemoryAddress>(addressRangeObj.find("startAddress")->toInteger()),
|
||||
static_cast<Targets::TargetMemoryAddress>(addressRangeObj.find("endAddress")->toInteger()),
|
||||
};
|
||||
}
|
||||
|
||||
QJsonObject MemoryRegion::toJson() const {
|
||||
return QJsonObject({
|
||||
return {
|
||||
{"name", this->name},
|
||||
{"memoryType", EnumToStringMappings::targetMemoryTypes.at(this->memoryType)},
|
||||
{"type", MemoryRegion::memoryRegionTypesByName.at(this->type)},
|
||||
{"createdTimestamp", this->createdDate.toSecsSinceEpoch()},
|
||||
{"addressInputType", MemoryRegion::addressTypesByName.at(this->addressRangeInputType)},
|
||||
{"addressRange", QJsonObject({
|
||||
{"addressRange", QJsonObject{
|
||||
{"startAddress", static_cast<qint64>(this->addressRange.startAddress)},
|
||||
{"endAddress", static_cast<qint64>(this->addressRange.endAddress)},
|
||||
})},
|
||||
});
|
||||
}},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ class MemoryRegion
|
||||
public:
|
||||
QString name;
|
||||
QDateTime createdDate = Services::DateTimeService::currentDateTime();
|
||||
Targets::TargetMemoryType memoryType;
|
||||
MemoryRegionType type;
|
||||
|
||||
/**
|
||||
@@ -54,12 +53,11 @@ public:
|
||||
|
||||
MemoryRegion(
|
||||
const QString& name,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
MemoryRegionType type,
|
||||
const Targets::TargetMemoryAddressRange& addressRange
|
||||
);
|
||||
|
||||
MemoryRegion(const QJsonObject& jsonObject);
|
||||
explicit MemoryRegion(const QJsonObject& jsonObject);
|
||||
|
||||
virtual QJsonObject toJson() const;
|
||||
|
||||
|
||||
@@ -10,41 +10,39 @@ namespace Widgets
|
||||
{
|
||||
ExcludedRegionItem::ExcludedRegionItem(
|
||||
const ExcludedMemoryRegion& region,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
QWidget* parent
|
||||
)
|
||||
: RegionItem(region, memoryDescriptor, parent)
|
||||
: RegionItem(region, memorySegmentDescriptor, parent)
|
||||
, memoryRegion(region)
|
||||
{
|
||||
auto formUiFile = QFile(
|
||||
auto formUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/MemoryRegionManager/UiFiles/ExcludedMemoryRegionForm.ui"
|
||||
+ "/MemoryRegionManager/UiFiles/ExcludedMemoryRegionForm.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!formUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exceptions::Exception("Failed to open excluded region item form UI file");
|
||||
throw Exceptions::Exception{"Failed to open excluded region item form UI file"};
|
||||
}
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->formWidget = uiLoader.load(&formUiFile, this);
|
||||
|
||||
this->initFormInputs();
|
||||
}
|
||||
|
||||
void ExcludedRegionItem::applyChanges() {
|
||||
using Targets::TargetMemoryAddressRange;
|
||||
|
||||
this->memoryRegion.name = this->nameInput->text();
|
||||
|
||||
const auto inputAddressRange = TargetMemoryAddressRange(
|
||||
const auto inputAddressRange = Targets::TargetMemoryAddressRange{
|
||||
this->startAddressInput->text().toUInt(nullptr, 16),
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Widgets
|
||||
public:
|
||||
ExcludedRegionItem(
|
||||
const ExcludedMemoryRegion& region,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
QWidget *parent
|
||||
);
|
||||
|
||||
|
||||
@@ -12,24 +12,24 @@ namespace Widgets
|
||||
|
||||
FocusedRegionItem::FocusedRegionItem(
|
||||
const FocusedMemoryRegion& region,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
QWidget* parent
|
||||
)
|
||||
: RegionItem(region, memoryDescriptor, parent)
|
||||
: RegionItem(region, memorySegmentDescriptor, parent)
|
||||
, memoryRegion(region)
|
||||
{
|
||||
auto formUiFile = QFile(
|
||||
auto formUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/MemoryRegionManager/UiFiles/FocusedMemoryRegionForm.ui"
|
||||
+ "/MemoryRegionManager/UiFiles/FocusedMemoryRegionForm.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!formUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exceptions::Exception("Failed to open focused region item form UI file");
|
||||
throw Exceptions::Exception{"Failed to open focused region item form UI file"};
|
||||
}
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->formWidget = uiLoader.load(&formUiFile, this);
|
||||
|
||||
this->initFormInputs();
|
||||
@@ -38,10 +38,10 @@ namespace Widgets
|
||||
void FocusedRegionItem::applyChanges() {
|
||||
this->memoryRegion.name = this->nameInput->text();
|
||||
|
||||
const auto inputAddressRange = TargetMemoryAddressRange(
|
||||
const auto inputAddressRange = Targets::TargetMemoryAddressRange{
|
||||
this->startAddressInput->text().toUInt(nullptr, 16),
|
||||
this->endAddressInput->text().toUInt(nullptr, 16)
|
||||
);
|
||||
};
|
||||
this->memoryRegion.addressRangeInputType = this->getSelectedAddressInputType();
|
||||
this->memoryRegion.addressRange = this->memoryRegion.addressRangeInputType == AddressType::RELATIVE
|
||||
? this->convertRelativeToAbsoluteAddressRange(inputAddressRange)
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Widgets
|
||||
public:
|
||||
FocusedRegionItem(
|
||||
const FocusedMemoryRegion& region,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
QWidget *parent
|
||||
);
|
||||
|
||||
@@ -52,20 +52,16 @@ namespace Widgets
|
||||
QComboBox* dataTypeInput = nullptr;
|
||||
QComboBox* endiannessInput = nullptr;
|
||||
|
||||
static const inline std::map<QString, DataTypeOption> dataTypeOptionsByName = std::map<
|
||||
QString, DataTypeOption
|
||||
>({
|
||||
{"other", DataTypeOption("Other", MemoryRegionDataType::UNKNOWN)},
|
||||
{"unsigned_integer", DataTypeOption("Unsigned Integer", MemoryRegionDataType::UNSIGNED_INTEGER)},
|
||||
{"signed_integer", DataTypeOption("Signed Integer", MemoryRegionDataType::SIGNED_INTEGER)},
|
||||
{"ascii", DataTypeOption("ASCII String", MemoryRegionDataType::ASCII_STRING)},
|
||||
});
|
||||
static const inline std::map<QString, DataTypeOption> dataTypeOptionsByName = {
|
||||
{"other", DataTypeOption{"Other", MemoryRegionDataType::UNKNOWN}},
|
||||
{"unsigned_integer", DataTypeOption{"Unsigned Integer", MemoryRegionDataType::UNSIGNED_INTEGER}},
|
||||
{"signed_integer", DataTypeOption{"Signed Integer", MemoryRegionDataType::SIGNED_INTEGER}},
|
||||
{"ascii", DataTypeOption{"ASCII String", MemoryRegionDataType::ASCII_STRING}},
|
||||
};
|
||||
|
||||
static const inline std::map<QString, EndiannessOption> endiannessOptionsByName = std::map<
|
||||
QString, EndiannessOption
|
||||
>({
|
||||
{"little", EndiannessOption("Little-endian", Targets::TargetMemoryEndianness::LITTLE)},
|
||||
{"big", EndiannessOption("Big-endian", Targets::TargetMemoryEndianness::BIG)},
|
||||
});
|
||||
static const inline std::map<QString, EndiannessOption> endiannessOptionsByName = {
|
||||
{"little", EndiannessOption{"Little-endian", Targets::TargetMemoryEndianness::LITTLE}},
|
||||
{"big", EndiannessOption{"Big-endian", Targets::TargetMemoryEndianness::BIG}},
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,48 +16,50 @@ namespace Widgets
|
||||
using Exceptions::Exception;
|
||||
|
||||
MemoryRegionManagerWindow::MemoryRegionManagerWindow(
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
QWidget* parent
|
||||
)
|
||||
: QWidget(parent)
|
||||
, memoryDescriptor(memoryDescriptor)
|
||||
, addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, focusedMemoryRegions(focusedMemoryRegions)
|
||||
, excludedMemoryRegions(excludedMemoryRegions)
|
||||
{
|
||||
this->setWindowFlag(Qt::Window);
|
||||
this->setObjectName("memory-region-manager-window");
|
||||
this->setWindowTitle(
|
||||
"Memory Regions - " + EnumToStringMappings::targetMemoryTypes.at(this->memoryDescriptor.type).toUpper()
|
||||
"Memory Regions - " + QString::fromStdString(this->memorySegmentDescriptor.name)
|
||||
);
|
||||
|
||||
auto windowUiFile = QFile(
|
||||
auto windowUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/MemoryRegionManager/UiFiles/MemoryRegionManagerWindow.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
auto windowStylesheet = QFile(
|
||||
auto windowStylesheet = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/MemoryRegionManager/Stylesheets/MemoryRegionManagerWindow.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!windowUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open MemoryRegionManagerWindow UI file");
|
||||
throw Exception{"Failed to open MemoryRegionManagerWindow UI file"};
|
||||
}
|
||||
|
||||
if (!windowStylesheet.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open MemoryRegionManagerWindow stylesheet file");
|
||||
throw Exception{"Failed to open MemoryRegionManagerWindow stylesheet file"};
|
||||
}
|
||||
|
||||
this->setStyleSheet(windowStylesheet.readAll());
|
||||
this->setFixedSize(QSize(970, 540));
|
||||
this->setFixedSize(QSize{970, 540});
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->container = uiLoader.load(&windowUiFile, this);
|
||||
|
||||
this->container->setFixedSize(this->size());
|
||||
@@ -210,11 +212,11 @@ namespace Widgets
|
||||
}
|
||||
|
||||
FocusedRegionItem* MemoryRegionManagerWindow::addFocusedRegion(const FocusedMemoryRegion& region) {
|
||||
auto* focusedRegionItem = new FocusedRegionItem(
|
||||
auto* focusedRegionItem = new FocusedRegionItem{
|
||||
region,
|
||||
this->memoryDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->regionItemScrollAreaViewport
|
||||
);
|
||||
};
|
||||
this->focusedRegionItems.insert(focusedRegionItem);
|
||||
|
||||
this->regionItemScrollAreaViewportLayout->addWidget(focusedRegionItem);
|
||||
@@ -231,11 +233,11 @@ namespace Widgets
|
||||
}
|
||||
|
||||
ExcludedRegionItem* MemoryRegionManagerWindow::addExcludedRegion(const ExcludedMemoryRegion& region) {
|
||||
auto* excludedRegionItem = new ExcludedRegionItem(
|
||||
auto* excludedRegionItem = new ExcludedRegionItem{
|
||||
region,
|
||||
this->memoryDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->regionItemScrollAreaViewport
|
||||
);
|
||||
};
|
||||
this->excludedRegionItems.insert(excludedRegionItem);
|
||||
|
||||
this->regionItemScrollAreaViewportLayout->addWidget(excludedRegionItem);
|
||||
@@ -263,14 +265,15 @@ namespace Widgets
|
||||
void MemoryRegionManagerWindow::onNewFocusedRegionTrigger() {
|
||||
using Targets::TargetMemoryAddressRange;
|
||||
|
||||
auto* region = this->addFocusedRegion(FocusedMemoryRegion(
|
||||
"Untitled Region",
|
||||
this->memoryDescriptor.type,
|
||||
TargetMemoryAddressRange(
|
||||
this->memoryDescriptor.addressRange.startAddress,
|
||||
this->memoryDescriptor.addressRange.startAddress + 10
|
||||
)
|
||||
));
|
||||
auto* region = this->addFocusedRegion(
|
||||
FocusedMemoryRegion{
|
||||
"Untitled Region",
|
||||
TargetMemoryAddressRange{
|
||||
this->memorySegmentDescriptor.addressRange.startAddress,
|
||||
this->memorySegmentDescriptor.addressRange.startAddress + 10
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
region->setSelected(true);
|
||||
}
|
||||
@@ -278,14 +281,15 @@ namespace Widgets
|
||||
void MemoryRegionManagerWindow::onNewExcludedRegionTrigger() {
|
||||
using Targets::TargetMemoryAddressRange;
|
||||
|
||||
auto* region = this->addExcludedRegion(ExcludedMemoryRegion(
|
||||
"Untitled Region",
|
||||
this->memoryDescriptor.type,
|
||||
TargetMemoryAddressRange(
|
||||
this->memoryDescriptor.addressRange.startAddress,
|
||||
this->memoryDescriptor.addressRange.startAddress + 10
|
||||
)
|
||||
));
|
||||
auto* region = this->addExcludedRegion(
|
||||
ExcludedMemoryRegion{
|
||||
"Untitled Region",
|
||||
TargetMemoryAddressRange{
|
||||
this->memorySegmentDescriptor.addressRange.startAddress,
|
||||
this->memorySegmentDescriptor.addressRange.startAddress + 10
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
region->setSelected(true);
|
||||
}
|
||||
@@ -331,19 +335,19 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void MemoryRegionManagerWindow::applyChanges() {
|
||||
auto processedFocusedMemoryRegions = std::vector<FocusedMemoryRegion>();
|
||||
auto processedExcludedMemoryRegions = std::vector<ExcludedMemoryRegion>();
|
||||
auto processedFocusedMemoryRegions = std::vector<FocusedMemoryRegion>{};
|
||||
auto processedExcludedMemoryRegions = std::vector<ExcludedMemoryRegion>{};
|
||||
|
||||
for (auto* focusedRegionItem : this->focusedRegionItems) {
|
||||
const auto validationFailures = focusedRegionItem->getValidationFailures();
|
||||
|
||||
if (!validationFailures.empty()) {
|
||||
auto* errorDialogue = new ErrorDialogue(
|
||||
auto* errorDialogue = new ErrorDialogue{
|
||||
"Invalid Memory Region",
|
||||
"Invalid memory region \"" + focusedRegionItem->getRegionNameInputValue() + "\""
|
||||
+ "\n\n- " + validationFailures.join("\n- "),
|
||||
this
|
||||
);
|
||||
};
|
||||
errorDialogue->show();
|
||||
return;
|
||||
}
|
||||
@@ -352,13 +356,13 @@ namespace Widgets
|
||||
const auto& focusedRegion = focusedRegionItem->getMemoryRegion();
|
||||
for (const auto& processedFocusedRegion : processedFocusedMemoryRegions) {
|
||||
if (processedFocusedRegion.intersectsWith(focusedRegion)) {
|
||||
auto* errorDialogue = new ErrorDialogue(
|
||||
auto* errorDialogue = new ErrorDialogue{
|
||||
"Intersecting Region Found",
|
||||
"Region \"" + focusedRegionItem->getRegionNameInputValue()
|
||||
+ "\" intersects with region \"" + processedFocusedRegion.name + "\". "
|
||||
+ "Regions cannot intersect. Please review the relevant address ranges.",
|
||||
this
|
||||
);
|
||||
};
|
||||
errorDialogue->show();
|
||||
return;
|
||||
}
|
||||
@@ -371,12 +375,12 @@ namespace Widgets
|
||||
const auto validationFailures = excludedRegionItem->getValidationFailures();
|
||||
|
||||
if (!validationFailures.empty()) {
|
||||
auto* errorDialogue = new ErrorDialogue(
|
||||
auto* errorDialogue = new ErrorDialogue{
|
||||
"Invalid Memory Region",
|
||||
"Invalid memory region \"" + excludedRegionItem->getRegionNameInputValue() + "\""
|
||||
+ "<br/><br/>- " + validationFailures.join("<br/>- "),
|
||||
this
|
||||
);
|
||||
};
|
||||
errorDialogue->show();
|
||||
return;
|
||||
}
|
||||
@@ -385,13 +389,13 @@ namespace Widgets
|
||||
auto excludedRegion = excludedRegionItem->getMemoryRegion();
|
||||
for (const auto& processedFocusedRegion : processedFocusedMemoryRegions) {
|
||||
if (processedFocusedRegion.intersectsWith(excludedRegion)) {
|
||||
auto* errorDialogue = new ErrorDialogue(
|
||||
auto* errorDialogue = new ErrorDialogue{
|
||||
"Intersecting Region Found",
|
||||
"Region \"" + excludedRegionItem->getRegionNameInputValue()
|
||||
+ "\" intersects with region \"" + processedFocusedRegion.name + "\". "
|
||||
+ "Regions cannot intersect. Please review the relevant address ranges.",
|
||||
this
|
||||
);
|
||||
};
|
||||
errorDialogue->show();
|
||||
return;
|
||||
}
|
||||
@@ -399,13 +403,13 @@ namespace Widgets
|
||||
|
||||
for (const auto& processedExcludedRegion : processedExcludedMemoryRegions) {
|
||||
if (processedExcludedRegion.intersectsWith(excludedRegion)) {
|
||||
auto* errorDialogue = new ErrorDialogue(
|
||||
auto* errorDialogue = new ErrorDialogue{
|
||||
"Intersecting Region Found",
|
||||
"Region \"" + excludedRegionItem->getRegionNameInputValue()
|
||||
+ "\" intersects with region \"" + processedExcludedRegion.name + "\". "
|
||||
+ "Regions cannot intersect. Please review the relevant address ranges.",
|
||||
this
|
||||
);
|
||||
};
|
||||
errorDialogue->show();
|
||||
return;
|
||||
}
|
||||
@@ -422,7 +426,7 @@ namespace Widgets
|
||||
|
||||
void MemoryRegionManagerWindow::openHelpPage() {
|
||||
QDesktopServices::openUrl(
|
||||
QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/docs/manage-memory-regions"))
|
||||
QUrl{QString::fromStdString(Services::PathService::homeDomainName() + "/docs/manage-memory-regions")}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user