Removed redundant 'Bloom' namespace from entire codebase

This commit is contained in:
Nav
2023-08-13 15:47:51 +01:00
parent 0935ba65cf
commit 5896306f1a
555 changed files with 6254 additions and 6510 deletions

View File

@@ -8,39 +8,36 @@
#include "src/Services/PathService.hpp"
#include "src/Application.hpp"
namespace Bloom
{
using namespace Exceptions;
using namespace Exceptions;
AboutWindow::AboutWindow(QWidget* parent): QObject(parent) {
auto aboutWindowUiFile = QFile(QString::fromStdString(
Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/UiFiles/AboutWindow.ui"
)
);
auto aboutWindowStylesheet = QFile(QString::fromStdString(
Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/AboutWindow.qss"
)
);
AboutWindow::AboutWindow(QWidget* parent): QObject(parent) {
auto aboutWindowUiFile = QFile(QString::fromStdString(
Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/UiFiles/AboutWindow.ui"
)
);
auto aboutWindowStylesheet = QFile(QString::fromStdString(
Services::PathService::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/AboutWindow.qss"
)
);
if (!aboutWindowUiFile.open(QFile::ReadOnly)) {
throw Exception("Failed to open AboutWindow UI file");
}
if (!aboutWindowUiFile.open(QFile::ReadOnly)) {
throw Exception("Failed to open AboutWindow UI file");
}
if (!aboutWindowStylesheet.open(QFile::ReadOnly)) {
throw Exception("Failed to open AboutWindow QSS file");
}
if (!aboutWindowStylesheet.open(QFile::ReadOnly)) {
throw Exception("Failed to open AboutWindow QSS file");
}
auto uiLoader = UiLoader(this);
this->windowWidget = uiLoader.load(&aboutWindowUiFile, parent);
this->windowWidget->setStyleSheet(aboutWindowStylesheet.readAll());
this->windowWidget->setFixedSize(400, 300);
auto uiLoader = UiLoader(this);
this->windowWidget = uiLoader.load(&aboutWindowUiFile, parent);
this->windowWidget->setStyleSheet(aboutWindowStylesheet.readAll());
this->windowWidget->setFixedSize(400, 300);
auto versionLabel = this->windowWidget->findChild<Widgets::Label*>("version-label");
auto versionLabel = this->windowWidget->findChild<Widgets::Label*>("version-label");
if (versionLabel != nullptr) {
versionLabel->setText("Bloom v" + QString::fromStdString(Application::VERSION.toString()));
}
if (versionLabel != nullptr) {
versionLabel->setText("Bloom v" + QString::fromStdString(Application::VERSION.toString()));
}
}

View File

@@ -5,25 +5,22 @@
#include <QtUiTools/QtUiTools>
#include <memory>
namespace Bloom
class AboutWindow: public QObject
{
class AboutWindow: public QObject
{
Q_OBJECT
Q_OBJECT
public:
explicit AboutWindow(QWidget* parent);
public:
explicit AboutWindow(QWidget* parent);
void show() {
if (this->windowWidget != nullptr) {
this->windowWidget->move(
this->windowWidget->parentWidget()->geometry().center() - this->windowWidget->rect().center()
);
this->windowWidget->show();
}
void show() {
if (this->windowWidget != nullptr) {
this->windowWidget->move(
this->windowWidget->parentWidget()->geometry().center() - this->windowWidget->rect().center()
);
this->windowWidget->show();
}
}
private:
QWidget* windowWidget = nullptr;
};
}
private:
QWidget* windowWidget = nullptr;
};

View File

@@ -1,17 +1,14 @@
#include "BloomProxyStyle.hpp"
namespace Bloom
{
int BloomProxyStyle::styleHint(
StyleHint hint,
const QStyleOption* option,
const QWidget* widget,
QStyleHintReturn* returnData
) const {
if (hint == QStyle::SH_ComboBox_Popup) {
return 0;
}
return QProxyStyle::styleHint(hint, option, widget, returnData);
int BloomProxyStyle::styleHint(
StyleHint hint,
const QStyleOption* option,
const QWidget* widget,
QStyleHintReturn* returnData
) const {
if (hint == QStyle::SH_ComboBox_Popup) {
return 0;
}
return QProxyStyle::styleHint(hint, option, widget, returnData);
}

View File

@@ -2,18 +2,15 @@
#include <QProxyStyle>
namespace Bloom
class BloomProxyStyle: public QProxyStyle
{
class BloomProxyStyle: public QProxyStyle
{
Q_OBJECT
Q_OBJECT
public:
int styleHint(
StyleHint hint,
const QStyleOption* option = nullptr,
const QWidget* widget = nullptr,
QStyleHintReturn* returnData = nullptr
) const override;
};
}
public:
int styleHint(
StyleHint hint,
const QStyleOption* option = nullptr,
const QWidget* widget = nullptr,
QStyleHintReturn* returnData = nullptr
) const override;
};

File diff suppressed because it is too large Load Diff

View File

@@ -25,107 +25,104 @@
#include "Widgets/TaskIndicator/TaskIndicator.hpp"
#include "AboutWindow.hpp"
namespace Bloom
class InsightWindow: public QMainWindow
{
class InsightWindow: public QMainWindow
{
Q_OBJECT
Q_OBJECT
public:
InsightWindow(
const EnvironmentConfig& environmentConfig,
const InsightConfig& insightConfig,
InsightProjectSettings& insightProjectSettings,
const Targets::TargetDescriptor& targetDescriptor
);
public:
InsightWindow(
const EnvironmentConfig& environmentConfig,
const InsightConfig& insightConfig,
InsightProjectSettings& insightProjectSettings,
const Targets::TargetDescriptor& targetDescriptor
);
protected:
void resizeEvent(QResizeEvent* event) override;
void showEvent(QShowEvent* event) override;
void closeEvent(QCloseEvent* event) override;
protected:
void resizeEvent(QResizeEvent* event) override;
void showEvent(QShowEvent* event) override;
void closeEvent(QCloseEvent* event) override;
private:
InsightProjectSettings& insightProjectSettings;
private:
InsightProjectSettings& insightProjectSettings;
InsightConfig insightConfig;
EnvironmentConfig environmentConfig;
TargetConfig targetConfig;
InsightConfig insightConfig;
EnvironmentConfig environmentConfig;
TargetConfig targetConfig;
const Targets::TargetDescriptor& targetDescriptor;
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
const Targets::TargetDescriptor& targetDescriptor;
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
QWidget* windowContainer = nullptr;
QMenuBar* mainMenuBar = nullptr;
QWidget* layoutContainer = nullptr;
QWidget* container = nullptr;
QMenu* variantMenu = nullptr;
Widgets::Label* targetNameLabel = nullptr;
Widgets::Label* targetIdLabel = nullptr;
AboutWindow* aboutWindowWidget = nullptr;
QWidget* windowContainer = nullptr;
QMenuBar* mainMenuBar = nullptr;
QWidget* layoutContainer = nullptr;
QWidget* container = nullptr;
QMenu* variantMenu = nullptr;
Widgets::Label* targetNameLabel = nullptr;
Widgets::Label* targetIdLabel = nullptr;
AboutWindow* aboutWindowWidget = nullptr;
QWidget* header = nullptr;
Widgets::SvgToolButton* refreshIoInspectionButton = nullptr;
QWidget* header = nullptr;
Widgets::SvgToolButton* refreshIoInspectionButton = nullptr;
QWidget* leftMenuBar = nullptr;
Widgets::PanelWidget* leftPanel = nullptr;
Widgets::TargetRegistersPaneWidget* targetRegistersSidePane = nullptr;
QToolButton* targetRegistersButton = nullptr;
QWidget* leftMenuBar = nullptr;
Widgets::PanelWidget* leftPanel = nullptr;
Widgets::TargetRegistersPaneWidget* targetRegistersSidePane = nullptr;
QToolButton* targetRegistersButton = nullptr;
Widgets::Label* ioUnavailableWidget = nullptr;
Widgets::InsightTargetWidgets::TargetPackageWidgetContainer* ioContainerWidget = nullptr;
Widgets::InsightTargetWidgets::TargetPackageWidget* targetPackageWidget = nullptr;
Widgets::Label* ioUnavailableWidget = nullptr;
Widgets::InsightTargetWidgets::TargetPackageWidgetContainer* ioContainerWidget = nullptr;
Widgets::InsightTargetWidgets::TargetPackageWidget* targetPackageWidget = nullptr;
QWidget* bottomMenuBar = 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;
QWidget* bottomMenuBar = 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;
QWidget* footer = nullptr;
Widgets::Label* targetStatusLabel = nullptr;
Widgets::Label* programCounterValueLabel = nullptr;
Widgets::TaskIndicator* taskIndicator = nullptr;
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;
bool uiDisabled = false;
std::map<QString, Targets::TargetVariant> supportedVariantsByName;
const Targets::TargetVariant* selectedVariant = nullptr;
std::optional<Targets::TargetVariant> previouslySelectedVariant;
bool uiDisabled = false;
static bool isVariantSupported(const Targets::TargetVariant& variant);
static bool isVariantSupported(const Targets::TargetVariant& variant);
void setUiDisabled(bool disable);
void setUiDisabled(bool disable);
void populateVariantMenu();
void selectDefaultVariant();
void selectVariant(const Targets::TargetVariant* variant);
void createPanes();
void populateVariantMenu();
void selectDefaultVariant();
void selectVariant(const Targets::TargetVariant* variant);
void createPanes();
void adjustPanels();
void adjustMinimumSize();
void adjustPanels();
void adjustMinimumSize();
void onTargetStateUpdate(Targets::TargetState newState);
void refresh();
void refreshPinStates();
void refreshProgramCounter(std::optional<std::function<void(void)>> callback = std::nullopt);
void openReportIssuesUrl();
void openGettingStartedUrl();
void openAboutWindow();
void toggleTargetRegistersPane();
void toggleRamInspectionPane();
void toggleEepromInspectionPane();
void toggleFlashInspectionPane();
void onRegistersPaneStateChanged();
void onRamInspectionPaneStateChanged();
void onEepromInspectionPaneStateChanged();
void onFlashInspectionPaneStateChanged();
void onProgrammingModeEnabled();
void onProgrammingModeDisabled();
};
}
void onTargetStateUpdate(Targets::TargetState newState);
void refresh();
void refreshPinStates();
void refreshProgramCounter(std::optional<std::function<void(void)>> callback = std::nullopt);
void openReportIssuesUrl();
void openGettingStartedUrl();
void openAboutWindow();
void toggleTargetRegistersPane();
void toggleRamInspectionPane();
void toggleEepromInspectionPane();
void toggleFlashInspectionPane();
void onRegistersPaneStateChanged();
void onRamInspectionPaneStateChanged();
void onEepromInspectionPaneStateChanged();
void onFlashInspectionPaneStateChanged();
void onProgrammingModeEnabled();
void onProgrammingModeDisabled();
};

View File

@@ -14,113 +14,110 @@
#include "Widgets/ExpandingHeightScrollAreaWidget.hpp"
#include "Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp"
namespace Bloom
{
using namespace Bloom::Widgets;
using namespace Widgets;
UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
this->customWidgetConstructorsByWidgetName = {
{
"Label",
[this] (QWidget* parent, const QString& name) {
auto* widget = new Label(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"RotatableLabel",
[this] (QWidget* parent, const QString& name) {
auto* widget = new RotatableLabel("", parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"LabeledSeparator",
[this] (QWidget* parent, const QString& name) {
auto* widget = new LabeledSeparator(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"TextInput",
[this] (QWidget* parent, const QString& name) {
auto* widget = new TextInput(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"PlainTextEdit",
[this] (QWidget* parent, const QString& name) {
auto* widget = new PlainTextEdit(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"PushButton",
[this] (QWidget* parent, const QString& name) {
auto* widget = new PushButton(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"ExpandingHeightScrollAreaWidget",
[this] (QWidget* parent, const QString& name) {
auto* widget = new ExpandingHeightScrollAreaWidget(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"SvgWidget",
[this] (QWidget* parent, const QString& name) {
auto* widget = new SvgWidget(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"SvgToolButton",
[this] (QWidget* parent, const QString& name) {
auto* widget = new SvgToolButton(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"TargetPackageWidgetContainer",
[this] (QWidget* parent, const QString& name) {
auto* widget = new InsightTargetWidgets::TargetPackageWidgetContainer(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
};
}
QWidget* UiLoader::createWidget(const QString& className, QWidget* parent, const QString& name) {
const auto widgetConstructorIt = this->customWidgetConstructorsByWidgetName.find(className);
if (widgetConstructorIt != this->customWidgetConstructorsByWidgetName.end()) {
// This is a custom widget - call the mapped constructor
return widgetConstructorIt->second(parent, name);
}
return QUiLoader::createWidget(className, parent, name);
}
UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
this->customWidgetConstructorsByWidgetName = {
{
"Label",
[this] (QWidget* parent, const QString& name) {
auto* widget = new Label(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"RotatableLabel",
[this] (QWidget* parent, const QString& name) {
auto* widget = new RotatableLabel("", parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"LabeledSeparator",
[this] (QWidget* parent, const QString& name) {
auto* widget = new LabeledSeparator(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"TextInput",
[this] (QWidget* parent, const QString& name) {
auto* widget = new TextInput(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"PlainTextEdit",
[this] (QWidget* parent, const QString& name) {
auto* widget = new PlainTextEdit(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"PushButton",
[this] (QWidget* parent, const QString& name) {
auto* widget = new PushButton(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"ExpandingHeightScrollAreaWidget",
[this] (QWidget* parent, const QString& name) {
auto* widget = new ExpandingHeightScrollAreaWidget(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"SvgWidget",
[this] (QWidget* parent, const QString& name) {
auto* widget = new SvgWidget(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"SvgToolButton",
[this] (QWidget* parent, const QString& name) {
auto* widget = new SvgToolButton(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"TargetPackageWidgetContainer",
[this] (QWidget* parent, const QString& name) {
auto* widget = new InsightTargetWidgets::TargetPackageWidgetContainer(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
};
}
QWidget* UiLoader::createWidget(const QString& className, QWidget* parent, const QString& name) {
const auto widgetConstructorIt = this->customWidgetConstructorsByWidgetName.find(className);
if (widgetConstructorIt != this->customWidgetConstructorsByWidgetName.end()) {
// This is a custom widget - call the mapped constructor
return widgetConstructorIt->second(parent, name);
}
return QUiLoader::createWidget(className, parent, name);
}

View File

@@ -3,21 +3,18 @@
#include <QUiLoader>
#include <QSize>
namespace Bloom
class UiLoader: public QUiLoader
{
class UiLoader: public QUiLoader
{
Q_OBJECT
Q_OBJECT
public:
explicit UiLoader(QObject* parent);
public:
explicit UiLoader(QObject* parent);
QWidget* createWidget(const QString& className, QWidget* parent, const QString& name) override;
QWidget* createWidget(const QString& className, QWidget* parent, const QString& name) override;
private:
std::map<
QString,
std::function<QWidget*(QWidget* parent, const QString& name)>
> customWidgetConstructorsByWidgetName = {};
};
}
private:
std::map<
QString,
std::function<QWidget*(QWidget* parent, const QString& name)>
> customWidgetConstructorsByWidgetName = {};
};

View File

@@ -1,6 +1,6 @@
#include "ClickableWidget.hpp"
namespace Bloom::Widgets
namespace Widgets
{
void ClickableWidget::mouseReleaseEvent(QMouseEvent* event) {
if (event->button() == Qt::MouseButton::LeftButton) {

View File

@@ -4,7 +4,7 @@
#include <QEvent>
#include <QMouseEvent>
namespace Bloom::Widgets
namespace Widgets
{
class ClickableWidget: public QFrame
{

View File

@@ -1,6 +1,6 @@
#include "ConfirmationDialog.hpp"
namespace Bloom::Widgets
namespace Widgets
{
ConfirmationDialog::ConfirmationDialog(
const QString& windowTitle,

View File

@@ -6,7 +6,7 @@
#include "Dialog/Dialog.hpp"
#include "PushButton.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class ConfirmationDialog: public Dialog
{

View File

@@ -6,9 +6,9 @@
#include "src/Services/PathService.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::Widgets
namespace Widgets
{
using Bloom::Exceptions::Exception;
using Exceptions::Exception;
Dialog::Dialog(
const QString& windowTitle,

View File

@@ -7,7 +7,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class Dialog: public QDialog
{

View File

@@ -7,9 +7,9 @@
#include "src/Services/PathService.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::Widgets
namespace Widgets
{
using Bloom::Exceptions::Exception;
using Exceptions::Exception;
ErrorDialogue::ErrorDialogue(
const QString& windowTitle,

View File

@@ -6,11 +6,11 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
namespace Bloom::Widgets
namespace Widgets
{
/**
* @deprecated
* TODO: Bin this. Replace all usages with Bloom::Widgets::Dialog.
* TODO: Bin this. Replace all usages with Widgets::Dialog.
*/
class ErrorDialogue: public QDialog
{

View File

@@ -4,7 +4,7 @@
#include <QScrollArea>
#include <QSize>
namespace Bloom::Widgets
namespace Widgets
{
class ExpandingHeightScrollAreaWidget: public QScrollArea
{

View File

@@ -2,7 +2,7 @@
#include <QLabel>
namespace Bloom::Widgets
namespace Widgets
{
class Label: public QLabel
{

View File

@@ -1,6 +1,6 @@
#include "LabeledSeparator.hpp"
namespace Bloom::Widgets
namespace Widgets
{
LabeledSeparator::LabeledSeparator(QString title, QWidget* parent): title(std::move(title)), QWidget(parent) {
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);

View File

@@ -6,7 +6,7 @@
#include <QPaintEvent>
#include <QPainter>
namespace Bloom::Widgets
namespace Widgets
{
class LabeledSeparator: public QWidget
{

View File

@@ -8,7 +8,7 @@
#include <QGraphicsView>
#include <QGraphicsScene>
namespace Bloom::Widgets
namespace Widgets
{
class ListItem: public QGraphicsItem
{

View File

@@ -6,7 +6,7 @@
#include <QByteArray>
#include <algorithm>
namespace Bloom::Widgets
namespace Widgets
{
ListScene::ListScene(
ListScene::ListItemSetType&& items,

View File

@@ -15,7 +15,7 @@
#include "ListItem.hpp"
#include "src/Helpers/DereferenceLessComparator.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class ListScene: public QGraphicsScene
{

View File

@@ -1,6 +1,6 @@
#include "ListView.hpp"
namespace Bloom::Widgets
namespace Widgets
{
ListView::ListView(
ListScene::ListItemSetType&& items,

View File

@@ -7,7 +7,7 @@
#include "ListScene.hpp"
#include "ListItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class ListView: public QGraphicsView
{

View File

@@ -4,7 +4,7 @@
#include <QPoint>
#include <optional>
namespace Bloom::Widgets
namespace Widgets
{
struct DetachedWindowState
{

View File

@@ -1,6 +1,6 @@
#include "PaneWidget.hpp"
namespace Bloom::Widgets
namespace Widgets
{
PaneWidget::PaneWidget(PaneState& state, PanelWidget* parent)
: state(state)

View File

@@ -7,7 +7,7 @@
#include "PanelWidget.hpp"
#include "PaneState.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class PaneWidget: public QWidget
{

View File

@@ -1,6 +1,6 @@
#pragma once
namespace Bloom::Widgets
namespace Widgets
{
struct PanelState
{

View File

@@ -5,7 +5,7 @@
#include "PaneWidget.hpp"
namespace Bloom::Widgets
namespace Widgets
{
PanelWidget::PanelWidget(PanelWidgetType type, PanelState& state, QWidget* parent)
: panelType(type)

View File

@@ -9,7 +9,7 @@
#include "PanelState.hpp"
namespace Bloom::Widgets
namespace Widgets
{
Q_NAMESPACE

View File

@@ -3,7 +3,7 @@
#include <QMenu>
#include <QAction>
namespace Bloom::Widgets
namespace Widgets
{
PlainTextEdit::PlainTextEdit(QWidget* parent)
: QPlainTextEdit(parent)

View File

@@ -3,7 +3,7 @@
#include <QPlainTextEdit>
#include <QContextMenuEvent>
namespace Bloom::Widgets
namespace Widgets
{
class PlainTextEdit: public QPlainTextEdit
{

View File

@@ -1,6 +1,6 @@
#include "PushButton.hpp"
namespace Bloom::Widgets
namespace Widgets
{
PushButton::PushButton(QWidget* parent)
: QPushButton(parent)

View File

@@ -3,7 +3,7 @@
#include <QPushButton>
#include <QString>
namespace Bloom::Widgets
namespace Widgets
{
class PushButton: public QPushButton
{

View File

@@ -2,7 +2,7 @@
#include <QPainter>
namespace Bloom::Widgets
namespace Widgets
{
void RotatableLabel::paintEvent(QPaintEvent* event) {
auto painter = QPainter(this);

View File

@@ -4,7 +4,7 @@
#include "Label.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class RotatableLabel: public Label
{

View File

@@ -1,6 +1,6 @@
#include "SvgToolButton.hpp"
namespace Bloom::Widgets
namespace Widgets
{
SvgToolButton::SvgToolButton(QWidget* parent): QToolButton(parent) {
this->setButtonWidth(10);

View File

@@ -8,7 +8,7 @@
#include "SvgWidget.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class SvgToolButton: public QToolButton
{

View File

@@ -3,7 +3,7 @@
#include <QPainter>
#include <cmath>
namespace Bloom::Widgets
namespace Widgets
{
SvgWidget::SvgWidget(QWidget* parent): QFrame(parent) {
this->renderer.setAspectRatioMode(Qt::AspectRatioMode::KeepAspectRatioByExpanding);

View File

@@ -7,7 +7,7 @@
#include <QSize>
#include <QPropertyAnimation>
namespace Bloom::Widgets
namespace Widgets
{
class SvgWidget: public QFrame
{

View File

@@ -2,11 +2,8 @@
#include <cstdint>
namespace Bloom
enum class AddressType: std::uint8_t
{
enum class AddressType: std::uint8_t
{
ABSOLUTE,
RELATIVE,
};
}
ABSOLUTE,
RELATIVE,
};

View File

@@ -2,21 +2,18 @@
#include "src/Exceptions/Exception.hpp"
namespace Bloom
{
ExcludedMemoryRegion::ExcludedMemoryRegion(
const QString& name,
Targets::TargetMemoryType memoryType,
const Targets::TargetMemoryAddressRange& addressRange
)
: MemoryRegion(name, memoryType, MemoryRegionType::EXCLUDED, addressRange)
{}
ExcludedMemoryRegion::ExcludedMemoryRegion(
const QString& name,
Targets::TargetMemoryType memoryType,
const Targets::TargetMemoryAddressRange& addressRange
)
: MemoryRegion(name, memoryType, MemoryRegionType::EXCLUDED, addressRange)
{}
ExcludedMemoryRegion::ExcludedMemoryRegion(const QJsonObject& jsonObject)
: MemoryRegion(jsonObject)
{
if (this->type != MemoryRegionType::EXCLUDED) {
throw Exceptions::Exception("Invalid memory region type");
}
ExcludedMemoryRegion::ExcludedMemoryRegion(const QJsonObject& jsonObject)
: MemoryRegion(jsonObject)
{
if (this->type != MemoryRegionType::EXCLUDED) {
throw Exceptions::Exception("Invalid memory region type");
}
}

View File

@@ -2,17 +2,14 @@
#include "MemoryRegion.hpp"
namespace Bloom
class ExcludedMemoryRegion: public MemoryRegion
{
class ExcludedMemoryRegion: public MemoryRegion
{
public:
ExcludedMemoryRegion(
const QString& name,
Targets::TargetMemoryType memoryType,
const Targets::TargetMemoryAddressRange& addressRange
);
public:
ExcludedMemoryRegion(
const QString& name,
Targets::TargetMemoryType memoryType,
const Targets::TargetMemoryAddressRange& addressRange
);
ExcludedMemoryRegion(const QJsonObject& jsonObject);
};
}
ExcludedMemoryRegion(const QJsonObject& jsonObject);
};

View File

@@ -2,38 +2,35 @@
#include "src/Exceptions/Exception.hpp"
namespace Bloom
FocusedMemoryRegion::FocusedMemoryRegion(
const QString& name,
Targets::TargetMemoryType memoryType,
const Targets::TargetMemoryAddressRange& addressRange
)
: MemoryRegion(name, memoryType, MemoryRegionType::FOCUSED, addressRange)
{}
FocusedMemoryRegion::FocusedMemoryRegion(const QJsonObject& jsonObject)
: MemoryRegion(jsonObject)
{
FocusedMemoryRegion::FocusedMemoryRegion(
const QString& name,
Targets::TargetMemoryType memoryType,
const Targets::TargetMemoryAddressRange& addressRange
)
: MemoryRegion(name, memoryType, MemoryRegionType::FOCUSED, addressRange)
{}
using Exceptions::Exception;
FocusedMemoryRegion::FocusedMemoryRegion(const QJsonObject& jsonObject)
: MemoryRegion(jsonObject)
{
using Exceptions::Exception;
if (this->type != MemoryRegionType::FOCUSED) {
throw Exception("Invalid memory region type");
}
if (!jsonObject.contains("dataType") || !jsonObject.contains("endianness")) {
throw Exception("Missing data");
}
this->dataType = FocusedMemoryRegion::regionDataTypesByName.at(jsonObject.find("dataType")->toString());
this->endianness = FocusedMemoryRegion::regionEndiannessByName.at(jsonObject.find("endianness")->toString());
if (this->type != MemoryRegionType::FOCUSED) {
throw Exception("Invalid memory region type");
}
QJsonObject FocusedMemoryRegion::toJson() const {
auto jsonObject = MemoryRegion::toJson();
jsonObject.insert("dataType", FocusedMemoryRegion::regionDataTypesByName.at(this->dataType));
jsonObject.insert("endianness", FocusedMemoryRegion::regionEndiannessByName.at(this->endianness));
return jsonObject;
if (!jsonObject.contains("dataType") || !jsonObject.contains("endianness")) {
throw Exception("Missing data");
}
this->dataType = FocusedMemoryRegion::regionDataTypesByName.at(jsonObject.find("dataType")->toString());
this->endianness = FocusedMemoryRegion::regionEndiannessByName.at(jsonObject.find("endianness")->toString());
}
QJsonObject FocusedMemoryRegion::toJson() const {
auto jsonObject = MemoryRegion::toJson();
jsonObject.insert("dataType", FocusedMemoryRegion::regionDataTypesByName.at(this->dataType));
jsonObject.insert("endianness", FocusedMemoryRegion::regionEndiannessByName.at(this->endianness));
return jsonObject;
}

View File

@@ -6,43 +6,40 @@
#include "src/Helpers/BiMap.hpp"
namespace Bloom
enum class MemoryRegionDataType: std::uint8_t
{
enum class MemoryRegionDataType: std::uint8_t
{
UNKNOWN,
UNSIGNED_INTEGER,
SIGNED_INTEGER,
ASCII_STRING,
UNKNOWN,
UNSIGNED_INTEGER,
SIGNED_INTEGER,
ASCII_STRING,
};
class FocusedMemoryRegion: public MemoryRegion
{
public:
MemoryRegionDataType dataType = MemoryRegionDataType::UNKNOWN;
Targets::TargetMemoryEndianness endianness = Targets::TargetMemoryEndianness::LITTLE;
FocusedMemoryRegion(
const QString& name,
Targets::TargetMemoryType memoryType,
const Targets::TargetMemoryAddressRange& addressRange
);
FocusedMemoryRegion(const QJsonObject& jsonObject);
QJsonObject toJson() const override;
private:
static const inline BiMap<MemoryRegionDataType, QString> regionDataTypesByName = {
{MemoryRegionDataType::UNKNOWN, "other"},
{MemoryRegionDataType::UNSIGNED_INTEGER, "unsigned_int"},
{MemoryRegionDataType::SIGNED_INTEGER, "signed_int"},
{MemoryRegionDataType::ASCII_STRING, "ascii_string"},
};
class FocusedMemoryRegion: public MemoryRegion
{
public:
MemoryRegionDataType dataType = MemoryRegionDataType::UNKNOWN;
Targets::TargetMemoryEndianness endianness = Targets::TargetMemoryEndianness::LITTLE;
FocusedMemoryRegion(
const QString& name,
Targets::TargetMemoryType memoryType,
const Targets::TargetMemoryAddressRange& addressRange
);
FocusedMemoryRegion(const QJsonObject& jsonObject);
QJsonObject toJson() const override;
private:
static const inline BiMap<MemoryRegionDataType, QString> regionDataTypesByName = {
{MemoryRegionDataType::UNKNOWN, "other"},
{MemoryRegionDataType::UNSIGNED_INTEGER, "unsigned_int"},
{MemoryRegionDataType::SIGNED_INTEGER, "signed_int"},
{MemoryRegionDataType::ASCII_STRING, "ascii_string"},
};
static const inline BiMap<Targets::TargetMemoryEndianness, QString> regionEndiannessByName = {
{Targets::TargetMemoryEndianness::LITTLE, "little"},
{Targets::TargetMemoryEndianness::BIG, "big"},
};
static const inline BiMap<Targets::TargetMemoryEndianness, QString> regionEndiannessByName = {
{Targets::TargetMemoryEndianness::LITTLE, "little"},
{Targets::TargetMemoryEndianness::BIG, "big"},
};
}
};

View File

@@ -1,6 +1,6 @@
#include "ByteAddressContainer.hpp"
namespace Bloom::Widgets
namespace Widgets
{
ByteAddressContainer::ByteAddressContainer(const HexViewerSharedState& hexViewerState)
: hexViewerState(hexViewerState)

View File

@@ -8,7 +8,7 @@
#include "HexViewerSharedState.hpp"
#include "ByteAddressItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class ByteAddressContainer: public QGraphicsItem
{

View File

@@ -1,6 +1,6 @@
#include "ByteAddressItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
ByteAddressItem::ByteAddressItem(const HexViewerSharedState& hexViewerState, QGraphicsItem* parent)
: hexViewerState(hexViewerState)

View File

@@ -6,7 +6,7 @@
#include "ByteItem.hpp"
#include "HexViewerSharedState.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class ByteAddressItem: public QGraphicsItem
{

View File

@@ -1,6 +1,6 @@
#include "ByteItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
ByteItem::ByteItem(Targets::TargetMemoryAddress address)
: HexViewerItem(address)

View File

@@ -8,7 +8,7 @@
#include "HexViewerItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
#pragma pack(push, 1)
class ByteItem: public HexViewerItem

View File

@@ -1,6 +1,6 @@
#include "ContextMenuAction.hpp"
namespace Bloom::Widgets
namespace Widgets
{
ContextMenuAction::ContextMenuAction(
const QString& text,

View File

@@ -9,7 +9,7 @@
#include "src/Targets/TargetMemory.hpp"
#include "ByteItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class ContextMenuAction: public QAction
{

View File

@@ -2,7 +2,7 @@
#include <cassert>
namespace Bloom::Widgets
namespace Widgets
{
FocusedRegionGroupItem::FocusedRegionGroupItem(
const FocusedMemoryRegion& focusedRegion,

View File

@@ -9,7 +9,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class FocusedRegionGroupItem: public GroupItem
{

View File

@@ -1,6 +1,6 @@
#include "GroupItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
GroupItem::~GroupItem() {
for (auto& byteItem : this->items) {

View File

@@ -11,7 +11,7 @@
#include "src/Targets/TargetMemory.hpp"
#include "HexViewerSharedState.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class GroupItem: public HexViewerItem
{

View File

@@ -1,6 +1,6 @@
#include "HexViewerItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
HexViewerItem::HexViewerItem(Targets::TargetMemoryAddress startAddress, HexViewerItem* parent)
: startAddress(startAddress)

View File

@@ -7,7 +7,7 @@
#include "src/Targets/TargetMemory.hpp"
#include "HexViewerSharedState.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class GraphicsItem;

View File

@@ -3,7 +3,7 @@
#include <cassert>
#include <cmath>
namespace Bloom::Widgets
namespace Widgets
{
HexViewerItemIndex::HexViewerItemIndex(
const TopLevelGroupItem* topLevelGroupItem,

View File

@@ -10,7 +10,7 @@
#include "TopLevelGroupItem.hpp"
#include "ByteItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
/**
* This class maintains indices of hex viewer item positions and provides fast lookups for items within certain

View File

@@ -3,7 +3,7 @@
#include <QScrollBar>
#include <QColor>
namespace Bloom::Widgets
namespace Widgets
{
HexViewerItemRenderer::HexViewerItemRenderer(
const HexViewerSharedState& hexViewerState,

View File

@@ -19,7 +19,7 @@
#include "FocusedRegionGroupItem.hpp"
#include "StackMemoryGroupItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
/**
* Renders hex viewer items in a QGraphicsScene.

View File

@@ -5,7 +5,7 @@
#include "src/Targets/TargetMemory.hpp"
#include "HexViewerWidgetSettings.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class ByteItem;

View File

@@ -10,11 +10,11 @@
#include "src/Services/PathService.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::Widgets
namespace Widgets
{
using namespace Bloom::Exceptions;
using namespace Exceptions;
using Bloom::Targets::TargetMemoryDescriptor;
using Targets::TargetMemoryDescriptor;
HexViewerWidget::HexViewerWidget(
const TargetMemoryDescriptor& targetMemoryDescriptor,

View File

@@ -21,7 +21,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class HexViewerWidget: public QWidget
{

View File

@@ -2,7 +2,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp"
namespace Bloom::Widgets
namespace Widgets
{
struct HexViewerWidgetSettings
{

View File

@@ -15,7 +15,7 @@
#include "src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
ItemGraphicsScene::ItemGraphicsScene(
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,

View File

@@ -37,7 +37,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class ItemGraphicsScene: public QGraphicsScene
{

View File

@@ -4,9 +4,9 @@
#include "ByteItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
using Bloom::Targets::TargetMemoryDescriptor;
using Targets::TargetMemoryDescriptor;
ItemGraphicsView::ItemGraphicsView(
const TargetMemoryDescriptor& targetMemoryDescriptor,

View File

@@ -10,7 +10,7 @@
#include "src/Targets/TargetMemory.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class ItemGraphicsView: public QGraphicsView
{

View File

@@ -2,7 +2,7 @@
#include <cassert>
namespace Bloom::Widgets
namespace Widgets
{
StackMemoryGroupItem::StackMemoryGroupItem(
Targets::TargetStackPointer stackPointer,

View File

@@ -9,7 +9,7 @@
#include "src/Targets/TargetMemory.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class StackMemoryGroupItem: public GroupItem
{

View File

@@ -1,6 +1,6 @@
#include "TopLevelGroupItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
TopLevelGroupItem::TopLevelGroupItem(
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,

View File

@@ -15,7 +15,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class TopLevelGroupItem: public GroupItem
{

View File

@@ -3,65 +3,62 @@
#include "src/Helpers/EnumToStringMappings.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom
{
MemoryRegion::MemoryRegion(
const QString& name,
Targets::TargetMemoryType memoryType,
MemoryRegionType type,
const Targets::TargetMemoryAddressRange& addressRange
)
: name(name)
, memoryType(memoryType)
, type(type)
, addressRange(addressRange)
{}
MemoryRegion::MemoryRegion(
const QString& name,
Targets::TargetMemoryType memoryType,
MemoryRegionType type,
const Targets::TargetMemoryAddressRange& addressRange
)
: name(name)
, memoryType(memoryType)
, type(type)
, addressRange(addressRange)
{}
MemoryRegion::MemoryRegion(const QJsonObject& jsonObject) {
using Exceptions::Exception;
MemoryRegion::MemoryRegion(const QJsonObject& jsonObject) {
using Exceptions::Exception;
if (
!jsonObject.contains("name")
|| !jsonObject.contains("memoryType")
|| !jsonObject.contains("type")
|| !jsonObject.contains("createdTimestamp")
|| !jsonObject.contains("addressInputType")
|| !jsonObject.contains("addressRange")
) {
throw Exception("Missing data");
}
const auto addressRangeObj = jsonObject.find("addressRange")->toObject();
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()),
};
if (
!jsonObject.contains("name")
|| !jsonObject.contains("memoryType")
|| !jsonObject.contains("type")
|| !jsonObject.contains("createdTimestamp")
|| !jsonObject.contains("addressInputType")
|| !jsonObject.contains("addressRange")
) {
throw Exception("Missing data");
}
QJsonObject MemoryRegion::toJson() const {
return QJsonObject({
{"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({
{"startAddress", static_cast<qint64>(this->addressRange.startAddress)},
{"endAddress", static_cast<qint64>(this->addressRange.endAddress)},
})},
});
const auto addressRangeObj = jsonObject.find("addressRange")->toObject();
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()),
};
}
QJsonObject MemoryRegion::toJson() const {
return QJsonObject({
{"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({
{"startAddress", static_cast<qint64>(this->addressRange.startAddress)},
{"endAddress", static_cast<qint64>(this->addressRange.endAddress)},
})},
});
}

View File

@@ -13,79 +13,76 @@
#include "src/Helpers/BiMap.hpp"
namespace Bloom
enum class MemoryRegionType: std::uint8_t
{
enum class MemoryRegionType: std::uint8_t
{
FOCUSED,
EXCLUDED,
FOCUSED,
EXCLUDED,
};
enum class MemoryRegionAddressInputType: std::uint8_t
{
ABSOLUTE,
RELATIVE,
};
class MemoryRegion
{
public:
QString name;
QDateTime createdDate = Services::DateTimeService::currentDateTime();
Targets::TargetMemoryType memoryType;
MemoryRegionType type;
/**
* The addressRangeType holds the user's preference when inputting address ranges in the memory region manager
* window, for this particular memory region.
*
* It has no significance anywhere else. We never store the address in relative form - this->addressRange will
* always be in absolute form. Conversion is done at the point of applying the changes.
*
* For more, see the following and their call sites:
* See RegionItem::convertRelativeToAbsoluteAddressRange()
* See RegionItem::convertAbsoluteToRelativeAddressRange()
*/
AddressType addressRangeInputType = AddressType::ABSOLUTE;
/**
* This address range will always be in absolute form. Regardless of the value of this->addressRangeType.
* See the comment above, for this->addressRangeType, for more.
*/
Targets::TargetMemoryAddressRange addressRange;
MemoryRegion(
const QString& name,
Targets::TargetMemoryType memoryType,
MemoryRegionType type,
const Targets::TargetMemoryAddressRange& addressRange
);
MemoryRegion(const QJsonObject& jsonObject);
virtual QJsonObject toJson() const;
virtual ~MemoryRegion() = default;
MemoryRegion(const MemoryRegion& other) = default;
MemoryRegion(MemoryRegion&& other) = default;
MemoryRegion& operator = (const MemoryRegion& other) = default;
MemoryRegion& operator = (MemoryRegion&& other) = default;
[[nodiscard]] bool intersectsWith(const MemoryRegion& other) const {
return this->addressRange.intersectsWith(other.addressRange);
}
private:
static const inline BiMap<MemoryRegionType, QString> memoryRegionTypesByName = {
{MemoryRegionType::EXCLUDED, "excluded"},
{MemoryRegionType::FOCUSED, "focused"},
};
enum class MemoryRegionAddressInputType: std::uint8_t
{
ABSOLUTE,
RELATIVE,
static const inline BiMap<AddressType, QString> addressTypesByName = {
{AddressType::ABSOLUTE, "absolute"},
{AddressType::RELATIVE, "relative"},
};
class MemoryRegion
{
public:
QString name;
QDateTime createdDate = Services::DateTimeService::currentDateTime();
Targets::TargetMemoryType memoryType;
MemoryRegionType type;
/**
* The addressRangeType holds the user's preference when inputting address ranges in the memory region manager
* window, for this particular memory region.
*
* It has no significance anywhere else. We never store the address in relative form - this->addressRange will
* always be in absolute form. Conversion is done at the point of applying the changes.
*
* For more, see the following and their call sites:
* See RegionItem::convertRelativeToAbsoluteAddressRange()
* See RegionItem::convertAbsoluteToRelativeAddressRange()
*/
AddressType addressRangeInputType = AddressType::ABSOLUTE;
/**
* This address range will always be in absolute form. Regardless of the value of this->addressRangeType.
* See the comment above, for this->addressRangeType, for more.
*/
Targets::TargetMemoryAddressRange addressRange;
MemoryRegion(
const QString& name,
Targets::TargetMemoryType memoryType,
MemoryRegionType type,
const Targets::TargetMemoryAddressRange& addressRange
);
MemoryRegion(const QJsonObject& jsonObject);
virtual QJsonObject toJson() const;
virtual ~MemoryRegion() = default;
MemoryRegion(const MemoryRegion& other) = default;
MemoryRegion(MemoryRegion&& other) = default;
MemoryRegion& operator = (const MemoryRegion& other) = default;
MemoryRegion& operator = (MemoryRegion&& other) = default;
[[nodiscard]] bool intersectsWith(const MemoryRegion& other) const {
return this->addressRange.intersectsWith(other.addressRange);
}
private:
static const inline BiMap<MemoryRegionType, QString> memoryRegionTypesByName = {
{MemoryRegionType::EXCLUDED, "excluded"},
{MemoryRegionType::FOCUSED, "focused"},
};
static const inline BiMap<AddressType, QString> addressTypesByName = {
{AddressType::ABSOLUTE, "absolute"},
{AddressType::RELATIVE, "relative"},
};
};
}
};

View File

@@ -6,7 +6,7 @@
#include "src/Exceptions/Exception.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp"
namespace Bloom::Widgets
namespace Widgets
{
ExcludedRegionItem::ExcludedRegionItem(
const ExcludedMemoryRegion& region,
@@ -23,7 +23,7 @@ namespace Bloom::Widgets
);
if (!formUiFile.open(QFile::ReadOnly)) {
throw Bloom::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);

View File

@@ -3,7 +3,7 @@
#include "RegionItem.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class ExcludedRegionItem: public RegionItem
{

View File

@@ -6,7 +6,7 @@
#include "src/Exceptions/Exception.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp"
namespace Bloom::Widgets
namespace Widgets
{
using Targets::TargetMemoryAddressRange;
@@ -25,7 +25,7 @@ namespace Bloom::Widgets
);
if (!formUiFile.open(QFile::ReadOnly)) {
throw Bloom::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);

View File

@@ -3,7 +3,7 @@
#include "RegionItem.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp"
namespace Bloom::Widgets
namespace Widgets
{
struct DataTypeOption
{

View File

@@ -11,9 +11,9 @@
#include "src/Helpers/EnumToStringMappings.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::Widgets
namespace Widgets
{
using Bloom::Exceptions::Exception;
using Exceptions::Exception;
MemoryRegionManagerWindow::MemoryRegionManagerWindow(
const Targets::TargetMemoryDescriptor& memoryDescriptor,

View File

@@ -21,7 +21,7 @@
#include "FocusedRegionItem.hpp"
#include "ExcludedRegionItem.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class MemoryRegionManagerWindow: public QWidget
{

View File

@@ -3,7 +3,7 @@
#include <QHBoxLayout>
#include <QString>
namespace Bloom::Widgets
namespace Widgets
{
using Targets::TargetMemoryAddressRange;

View File

@@ -14,7 +14,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom::Widgets
namespace Widgets
{
struct AddressRangeTypeOption
{

View File

@@ -7,137 +7,134 @@
#include "src/Helpers/EnumToStringMappings.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom
{
MemorySnapshot::MemorySnapshot(
const QString& name,
const QString& description,
Targets::TargetMemoryType memoryType,
const Targets::TargetMemoryBuffer& data,
Targets::TargetProgramCounter programCounter,
Targets::TargetStackPointer stackPointer,
const std::vector<FocusedMemoryRegion>& focusedRegions,
const std::vector<ExcludedMemoryRegion>& excludedRegions
)
: id(QUuid::createUuid().toString(QUuid::StringFormat::WithoutBraces))
, name(name)
, description(description)
, memoryType(memoryType)
, data(data)
, programCounter(programCounter)
, stackPointer(stackPointer)
, focusedRegions(focusedRegions)
, excludedRegions(excludedRegions)
{}
MemorySnapshot::MemorySnapshot(
const QString& name,
const QString& description,
Targets::TargetMemoryType memoryType,
const Targets::TargetMemoryBuffer& data,
Targets::TargetProgramCounter programCounter,
Targets::TargetStackPointer stackPointer,
const std::vector<FocusedMemoryRegion>& focusedRegions,
const std::vector<ExcludedMemoryRegion>& excludedRegions
)
: id(QUuid::createUuid().toString(QUuid::StringFormat::WithoutBraces))
, name(name)
, description(description)
, memoryType(memoryType)
, data(data)
, programCounter(programCounter)
, stackPointer(stackPointer)
, focusedRegions(focusedRegions)
, excludedRegions(excludedRegions)
{}
MemorySnapshot::MemorySnapshot(const QJsonObject& jsonObject) {
using Exceptions::Exception;
MemorySnapshot::MemorySnapshot(const QJsonObject& jsonObject) {
using Exceptions::Exception;
if (
!jsonObject.contains("id")
|| !jsonObject.contains("name")
|| !jsonObject.contains("description")
|| !jsonObject.contains("memoryType")
|| !jsonObject.contains("hexData")
|| !jsonObject.contains("programCounter")
|| !jsonObject.contains("stackPointer")
|| !jsonObject.contains("createdTimestamp")
|| !jsonObject.contains("focusedRegions")
|| !jsonObject.contains("excludedRegions")
) {
throw Exception("Missing data");
}
if (
!jsonObject.contains("id")
|| !jsonObject.contains("name")
|| !jsonObject.contains("description")
|| !jsonObject.contains("memoryType")
|| !jsonObject.contains("hexData")
|| !jsonObject.contains("programCounter")
|| !jsonObject.contains("stackPointer")
|| !jsonObject.contains("createdTimestamp")
|| !jsonObject.contains("focusedRegions")
|| !jsonObject.contains("excludedRegions")
) {
throw Exception("Missing data");
}
this->id = jsonObject.find("id")->toString();
this->name = jsonObject.find("name")->toString();
this->description = jsonObject.find("description")->toString();
this->memoryType = EnumToStringMappings::targetMemoryTypes.at(jsonObject.find("memoryType")->toString());
this->programCounter = static_cast<Targets::TargetProgramCounter>(jsonObject.find("programCounter")->toInteger());
this->stackPointer = static_cast<Targets::TargetStackPointer>(jsonObject.find("stackPointer")->toInteger());
this->createdDate.setSecsSinceEpoch(jsonObject.find("createdTimestamp")->toInteger());
this->id = jsonObject.find("id")->toString();
this->name = jsonObject.find("name")->toString();
this->description = jsonObject.find("description")->toString();
this->memoryType = EnumToStringMappings::targetMemoryTypes.at(jsonObject.find("memoryType")->toString());
this->programCounter = static_cast<Targets::TargetProgramCounter>(jsonObject.find("programCounter")->toInteger());
this->stackPointer = static_cast<Targets::TargetStackPointer>(jsonObject.find("stackPointer")->toInteger());
this->createdDate.setSecsSinceEpoch(jsonObject.find("createdTimestamp")->toInteger());
const auto hexData = QByteArray::fromHex(jsonObject.find("hexData")->toString().toUtf8());
this->data = Targets::TargetMemoryBuffer(hexData.begin(), hexData.end());
const auto hexData = QByteArray::fromHex(jsonObject.find("hexData")->toString().toUtf8());
this->data = Targets::TargetMemoryBuffer(hexData.begin(), hexData.end());
if (jsonObject.contains("focusedRegions")) {
for (const auto& regionValue : jsonObject.find("focusedRegions")->toArray()) {
try {
this->focusedRegions.emplace_back(regionValue.toObject());
if (jsonObject.contains("focusedRegions")) {
for (const auto& regionValue : jsonObject.find("focusedRegions")->toArray()) {
try {
this->focusedRegions.emplace_back(regionValue.toObject());
} catch (Exception exception) {
throw Exception("Invalid focused memory region");
}
}
}
if (jsonObject.contains("excludedRegions")) {
for (const auto& regionValue : jsonObject.find("excludedRegions")->toArray()) {
try {
this->excludedRegions.emplace_back(regionValue.toObject());
} catch (Exception exception) {
throw Exception("Invalid excluded memory region");
}
} catch (Exception exception) {
throw Exception("Invalid focused memory region");
}
}
}
QJsonObject MemorySnapshot::toJson() const {
auto focusedRegions = QJsonArray();
for (const auto& focusedRegion : this->focusedRegions) {
focusedRegions.push_back(focusedRegion.toJson());
}
if (jsonObject.contains("excludedRegions")) {
for (const auto& regionValue : jsonObject.find("excludedRegions")->toArray()) {
try {
this->excludedRegions.emplace_back(regionValue.toObject());
auto excludedRegions = QJsonArray();
for (const auto& excludedRegion : this->excludedRegions) {
excludedRegions.push_back(excludedRegion.toJson());
}
return QJsonObject({
{"id", this->id},
{"name", this->name},
{"description", this->description},
{"memoryType", EnumToStringMappings::targetMemoryTypes.at(this->memoryType)},
{"hexData", QString(QByteArray(
reinterpret_cast<const char*>(this->data.data()),
static_cast<qsizetype>(this->data.size())
).toHex())},
{"programCounter", static_cast<qint64>(this->programCounter)},
{"stackPointer", static_cast<qint64>(this->stackPointer)},
{"createdTimestamp", this->createdDate.toSecsSinceEpoch()},
{"focusedRegions", focusedRegions},
{"excludedRegions", excludedRegions},
});
}
bool MemorySnapshot::isCompatible(const Targets::TargetMemoryDescriptor& memoryDescriptor) const {
if (this->memoryType != memoryDescriptor.type) {
return false;
}
if (this->data.size() != memoryDescriptor.size()) {
return false;
}
const auto& memoryAddressRange = memoryDescriptor.addressRange;
for (const auto& focusedRegion : this->focusedRegions) {
if (
focusedRegion.addressRange.startAddress < memoryAddressRange.startAddress
|| focusedRegion.addressRange.endAddress > memoryAddressRange.endAddress
) {
return false;
} catch (Exception exception) {
throw Exception("Invalid excluded memory region");
}
}
for (const auto& excludedRegion : this->excludedRegions) {
if (
excludedRegion.addressRange.startAddress < memoryAddressRange.startAddress
|| excludedRegion.addressRange.endAddress > memoryAddressRange.endAddress
) {
return false;
}
}
return true;
}
}
QJsonObject MemorySnapshot::toJson() const {
auto focusedRegions = QJsonArray();
for (const auto& focusedRegion : this->focusedRegions) {
focusedRegions.push_back(focusedRegion.toJson());
}
auto excludedRegions = QJsonArray();
for (const auto& excludedRegion : this->excludedRegions) {
excludedRegions.push_back(excludedRegion.toJson());
}
return QJsonObject({
{"id", this->id},
{"name", this->name},
{"description", this->description},
{"memoryType", EnumToStringMappings::targetMemoryTypes.at(this->memoryType)},
{"hexData", QString(QByteArray(
reinterpret_cast<const char*>(this->data.data()),
static_cast<qsizetype>(this->data.size())
).toHex())},
{"programCounter", static_cast<qint64>(this->programCounter)},
{"stackPointer", static_cast<qint64>(this->stackPointer)},
{"createdTimestamp", this->createdDate.toSecsSinceEpoch()},
{"focusedRegions", focusedRegions},
{"excludedRegions", excludedRegions},
});
}
bool MemorySnapshot::isCompatible(const Targets::TargetMemoryDescriptor& memoryDescriptor) const {
if (this->memoryType != memoryDescriptor.type) {
return false;
}
if (this->data.size() != memoryDescriptor.size()) {
return false;
}
const auto& memoryAddressRange = memoryDescriptor.addressRange;
for (const auto& focusedRegion : this->focusedRegions) {
if (
focusedRegion.addressRange.startAddress < memoryAddressRange.startAddress
|| focusedRegion.addressRange.endAddress > memoryAddressRange.endAddress
) {
return false;
}
}
for (const auto& excludedRegion : this->excludedRegions) {
if (
excludedRegion.addressRange.startAddress < memoryAddressRange.startAddress
|| excludedRegion.addressRange.endAddress > memoryAddressRange.endAddress
) {
return false;
}
}
return true;
}

View File

@@ -12,46 +12,43 @@
#include "FocusedMemoryRegion.hpp"
#include "ExcludedMemoryRegion.hpp"
namespace Bloom
struct MemorySnapshot
{
struct MemorySnapshot
{
public:
QString id;
QString name;
QString description;
Targets::TargetMemoryType memoryType;
Targets::TargetMemoryBuffer data;
Targets::TargetProgramCounter programCounter;
Targets::TargetStackPointer stackPointer;
QDateTime createdDate = Services::DateTimeService::currentDateTime();
public:
QString id;
QString name;
QString description;
Targets::TargetMemoryType memoryType;
Targets::TargetMemoryBuffer data;
Targets::TargetProgramCounter programCounter;
Targets::TargetStackPointer stackPointer;
QDateTime createdDate = Services::DateTimeService::currentDateTime();
std::vector<FocusedMemoryRegion> focusedRegions;
std::vector<ExcludedMemoryRegion> excludedRegions;
std::vector<FocusedMemoryRegion> focusedRegions;
std::vector<ExcludedMemoryRegion> excludedRegions;
MemorySnapshot(
const QString& name,
const QString& description,
Targets::TargetMemoryType memoryType,
const Targets::TargetMemoryBuffer& data,
Targets::TargetProgramCounter programCounter,
Targets::TargetStackPointer stackPointer,
const std::vector<FocusedMemoryRegion>& focusedRegions,
const std::vector<ExcludedMemoryRegion>& excludedRegions
);
MemorySnapshot(
const QString& name,
const QString& description,
Targets::TargetMemoryType memoryType,
const Targets::TargetMemoryBuffer& data,
Targets::TargetProgramCounter programCounter,
Targets::TargetStackPointer stackPointer,
const std::vector<FocusedMemoryRegion>& focusedRegions,
const std::vector<ExcludedMemoryRegion>& excludedRegions
);
MemorySnapshot(const QJsonObject& jsonObject);
MemorySnapshot(const QJsonObject& jsonObject);
QJsonObject toJson() const;
QJsonObject toJson() const;
bool isCompatible(const Targets::TargetMemoryDescriptor& memoryDescriptor) const;
bool isCompatible(const Targets::TargetMemoryDescriptor& memoryDescriptor) const;
virtual ~MemorySnapshot() = default;
virtual ~MemorySnapshot() = default;
MemorySnapshot(const MemorySnapshot& other) = default;
MemorySnapshot(MemorySnapshot&& other) = default;
MemorySnapshot(const MemorySnapshot& other) = default;
MemorySnapshot(MemorySnapshot&& other) = default;
MemorySnapshot& operator = (const MemorySnapshot& other) = default;
MemorySnapshot& operator = (MemorySnapshot&& other) = default;
};
}
MemorySnapshot& operator = (const MemorySnapshot& other) = default;
MemorySnapshot& operator = (MemorySnapshot&& other) = default;
};

View File

@@ -12,9 +12,9 @@
#include "src/Helpers/EnumToStringMappings.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::Widgets
namespace Widgets
{
using Bloom::Exceptions::Exception;
using Exceptions::Exception;
CreateSnapshotWindow::CreateSnapshotWindow(
Targets::TargetMemoryType memoryType,

View File

@@ -12,7 +12,7 @@
#include "src/Targets/TargetMemory.hpp"
#include "src/Targets/TargetState.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class CreateSnapshotWindow: public QWidget
{

View File

@@ -2,7 +2,7 @@
#include "src/Services/DateTimeService.hpp"
namespace Bloom::Widgets
namespace Widgets
{
MemorySnapshotItem::MemorySnapshotItem(const MemorySnapshot& memorySnapshot)
: memorySnapshot(memorySnapshot)

View File

@@ -7,7 +7,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class MemorySnapshotItem: public ListItem
{

View File

@@ -6,7 +6,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.hpp"
namespace Bloom::Widgets
namespace Widgets
{
DifferentialHexViewerItemRenderer::DifferentialHexViewerItemRenderer(
DifferentialHexViewerWidgetType differentialHexViewerWidgetType,

View File

@@ -3,7 +3,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemRenderer.hpp"
#include "DifferentialHexViewerWidgetType.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class DifferentialHexViewerItemRenderer: public HexViewerItemRenderer
{

View File

@@ -2,7 +2,7 @@
#include <unordered_set>
namespace Bloom::Widgets
namespace Widgets
{
struct DifferentialHexViewerSharedState
{

View File

@@ -3,7 +3,7 @@
#include <QVBoxLayout>
#include <cassert>
namespace Bloom::Widgets
namespace Widgets
{
DifferentialHexViewerWidget::DifferentialHexViewerWidget(
DifferentialHexViewerWidgetType type,

View File

@@ -8,7 +8,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiffSettings.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class DifferentialHexViewerWidget final: public HexViewerWidget
{

View File

@@ -2,7 +2,7 @@
#include <cstdint>
namespace Bloom::Widgets
namespace Widgets
{
enum class DifferentialHexViewerWidgetType: std::uint8_t
{

View File

@@ -4,7 +4,7 @@
#include "DifferentialHexViewerItemRenderer.hpp"
namespace Bloom::Widgets
namespace Widgets
{
DifferentialItemGraphicsScene::DifferentialItemGraphicsScene(
DifferentialHexViewerWidgetType differentialHexViewerWidgetType,

View File

@@ -8,7 +8,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiffSettings.hpp"
namespace Bloom::Widgets
namespace Widgets
{
class DifferentialItemGraphicsScene final: public ItemGraphicsScene
{

Some files were not shown because too many files have changed in this diff Show More