rename class
This commit is contained in:
2026-02-14 14:30:48 +01:00
parent 051bf3dfd1
commit fbcac58feb
7 changed files with 31 additions and 31 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ class MainWindow : public QMainWindow
Web_socket_wrapper *m_web_socket; Web_socket_wrapper *m_web_socket;
NetworkError *m_error_dialog; NetworkError *m_error_dialog;
std::map<QString, SimulatorBase *> m_sims; std::map<QString, Simulator_base *> m_sims;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H
+24 -24
View File
@@ -1,7 +1,7 @@
#include "simulator_base.h" #include "simulator_base.h"
#include "can_transceive.h" #include "can_transceive.h"
SimulatorBase::SimulatorBase(Web_socket_wrapper *web_socket, QWidget *parent) Simulator_base::Simulator_base(Web_socket_wrapper *web_socket, QWidget *parent)
: QMainWindow{parent}, m_error_dialog(new NetworkError(this)), m_timer_update(new QTimer()), : QMainWindow{parent}, m_error_dialog(new NetworkError(this)), m_timer_update(new QTimer()),
m_web_socket(web_socket) m_web_socket(web_socket)
{ {
@@ -9,12 +9,12 @@ SimulatorBase::SimulatorBase(Web_socket_wrapper *web_socket, QWidget *parent)
m_ui_lookup.reserve(40); m_ui_lookup.reserve(40);
} }
QWidget *SimulatorBase::id_to_ui(size_t id) QWidget *Simulator_base::id_to_ui(size_t id)
{ {
return m_ui_lookup.at(id); return m_ui_lookup.at(id);
} }
void SimulatorBase::showEvent(QShowEvent *event) void Simulator_base::showEvent(QShowEvent *event)
{ {
QWidget::showEvent(event); QWidget::showEvent(event);
SPDLOG_DEBUG("Connecting callbacks"); SPDLOG_DEBUG("Connecting callbacks");
@@ -28,7 +28,7 @@ void SimulatorBase::showEvent(QShowEvent *event)
m_open = true; m_open = true;
} }
void SimulatorBase::closeEvent(QCloseEvent *event) void Simulator_base::closeEvent(QCloseEvent *event)
{ {
if (m_open == true) if (m_open == true)
{ {
@@ -41,7 +41,7 @@ void SimulatorBase::closeEvent(QCloseEvent *event)
} }
} }
void SimulatorBase::on_cmd_cb(json &j) void Simulator_base::on_cmd_cb(json &j)
{ {
auto response = magic_enum::enum_cast<Web_socket_wrapper::Command>(std::string(j.at("type"))) auto response = magic_enum::enum_cast<Web_socket_wrapper::Command>(std::string(j.at("type")))
.value_or(Web_socket_wrapper::Command::end); .value_or(Web_socket_wrapper::Command::end);
@@ -56,7 +56,7 @@ void SimulatorBase::on_cmd_cb(json &j)
} }
} }
void SimulatorBase::on_event_cb(json &j) void Simulator_base::on_event_cb(json &j)
{ {
auto response = magic_enum::enum_cast<Web_socket_wrapper::Event>(std::string(j.at("type"))) auto response = magic_enum::enum_cast<Web_socket_wrapper::Event>(std::string(j.at("type")))
.value_or(Web_socket_wrapper::Event::end); .value_or(Web_socket_wrapper::Event::end);
@@ -70,13 +70,13 @@ void SimulatorBase::on_event_cb(json &j)
} }
} }
void SimulatorBase::push_ui_item(QWidget *item) void Simulator_base::push_ui_item(QWidget *item)
{ {
m_ui_lookup.emplace_back(item); m_ui_lookup.emplace_back(item);
setup_ui_item(item, m_ui_lookup.size() - 1); setup_ui_item(item, m_ui_lookup.size() - 1);
} }
void SimulatorBase::UI_item_parser(json &input) void Simulator_base::UI_item_parser(json &input)
{ {
for (auto &uiItem : input["UI_items"]) for (auto &uiItem : input["UI_items"])
{ {
@@ -133,7 +133,7 @@ void SimulatorBase::UI_item_parser(json &input)
} }
} }
void SimulatorBase::process_ui_label(json &uiItem) void Simulator_base::process_ui_label(json &uiItem)
{ {
QWidget *widget = id_to_ui(uiItem["id"]); QWidget *widget = id_to_ui(uiItem["id"]);
if (widget == nullptr) if (widget == nullptr)
@@ -157,7 +157,7 @@ void SimulatorBase::process_ui_label(json &uiItem)
} }
} }
void SimulatorBase::process_ui_slider(json &uiItem) void Simulator_base::process_ui_slider(json &uiItem)
{ {
QLabel *label = id_to_label(uiItem["id"]); QLabel *label = id_to_label(uiItem["id"]);
QWidget *widget = id_to_ui(uiItem["id"]); QWidget *widget = id_to_ui(uiItem["id"]);
@@ -202,7 +202,7 @@ void SimulatorBase::process_ui_slider(json &uiItem)
return; return;
} }
void SimulatorBase::process_ui_dial(json &uiItem) void Simulator_base::process_ui_dial(json &uiItem)
{ {
QLabel *label = id_to_label(uiItem["id"]); QLabel *label = id_to_label(uiItem["id"]);
QWidget *widget = id_to_ui(uiItem["id"]); QWidget *widget = id_to_ui(uiItem["id"]);
@@ -240,7 +240,7 @@ void SimulatorBase::process_ui_dial(json &uiItem)
return; return;
} }
void SimulatorBase::process_ui_thermo(json &uiItem) void Simulator_base::process_ui_thermo(json &uiItem)
{ {
QLabel *label = id_to_label(uiItem["id"]); QLabel *label = id_to_label(uiItem["id"]);
QWidget *widget = id_to_ui(uiItem["id"]); QWidget *widget = id_to_ui(uiItem["id"]);
@@ -278,12 +278,12 @@ void SimulatorBase::process_ui_thermo(json &uiItem)
return; return;
} }
void SimulatorBase::process_ui_textbox(json &uiItem) void Simulator_base::process_ui_textbox(json &uiItem)
{ {
SPDLOG_CRITICAL("Not implemented"); SPDLOG_CRITICAL("Not implemented");
} }
void SimulatorBase::process_ui_combobox(json &uiItem) void Simulator_base::process_ui_combobox(json &uiItem)
{ {
QWidget *widget = id_to_ui(uiItem["id"]); QWidget *widget = id_to_ui(uiItem["id"]);
if (widget == nullptr) if (widget == nullptr)
@@ -313,12 +313,12 @@ void SimulatorBase::process_ui_combobox(json &uiItem)
} }
} }
void SimulatorBase::process_ui_radiobutton(json &uiItem) void Simulator_base::process_ui_radiobutton(json &uiItem)
{ {
SPDLOG_CRITICAL("Not implemented"); SPDLOG_CRITICAL("Not implemented");
} }
void SimulatorBase::process_ui_button(json &uiItem) void Simulator_base::process_ui_button(json &uiItem)
{ {
// TODO: fix bgcolor and color // TODO: fix bgcolor and color
QWidget *widget = id_to_ui(uiItem["id"]); QWidget *widget = id_to_ui(uiItem["id"]);
@@ -380,7 +380,7 @@ void SimulatorBase::process_ui_button(json &uiItem)
} }
} }
void SimulatorBase::process_ui_led(json &uiItem) void Simulator_base::process_ui_led(json &uiItem)
{ {
QWidget *widget = id_to_ui(uiItem["id"]); QWidget *widget = id_to_ui(uiItem["id"]);
if (widget == nullptr) if (widget == nullptr)
@@ -435,7 +435,7 @@ void SimulatorBase::process_ui_led(json &uiItem)
} }
} }
void SimulatorBase::process_ui_can(json &uiItem) void Simulator_base::process_ui_can(json &uiItem)
{ {
QWidget *widget = id_to_ui(uiItem["id"]); QWidget *widget = id_to_ui(uiItem["id"]);
if (widget == nullptr) if (widget == nullptr)
@@ -463,7 +463,7 @@ void SimulatorBase::process_ui_can(json &uiItem)
} }
} }
void SimulatorBase::setup_ui_item(QWidget *item, size_t index) void Simulator_base::setup_ui_item(QWidget *item, size_t index)
{ {
setup_button(item, index); setup_button(item, index);
setup_combobox(item, index); setup_combobox(item, index);
@@ -472,7 +472,7 @@ void SimulatorBase::setup_ui_item(QWidget *item, size_t index)
setup_can_ui(item, index); setup_can_ui(item, index);
} }
void SimulatorBase::setup_button(QWidget *item, size_t index) void Simulator_base::setup_button(QWidget *item, size_t index)
{ {
QPushButton *button = qobject_cast<QPushButton *>(item); QPushButton *button = qobject_cast<QPushButton *>(item);
if (button == nullptr) if (button == nullptr)
@@ -481,7 +481,7 @@ void SimulatorBase::setup_button(QWidget *item, size_t index)
[=, this] { m_web_socket->send_event(Web_socket_wrapper::Event::clicked, index); }); [=, this] { m_web_socket->send_event(Web_socket_wrapper::Event::clicked, index); });
} }
void SimulatorBase::setup_combobox(QWidget *item, size_t index) void Simulator_base::setup_combobox(QWidget *item, size_t index)
{ {
QComboBox *combobox = qobject_cast<QComboBox *>(item); QComboBox *combobox = qobject_cast<QComboBox *>(item);
if (combobox == nullptr) if (combobox == nullptr)
@@ -492,7 +492,7 @@ void SimulatorBase::setup_combobox(QWidget *item, size_t index)
}); });
} }
void SimulatorBase::setup_dial(QWidget *item, size_t index) void Simulator_base::setup_dial(QWidget *item, size_t index)
{ {
QwtDial *dial = qobject_cast<QwtDial *>(item); QwtDial *dial = qobject_cast<QwtDial *>(item);
if (dial == nullptr) if (dial == nullptr)
@@ -501,7 +501,7 @@ void SimulatorBase::setup_dial(QWidget *item, size_t index)
create_dial_needle(dial); create_dial_needle(dial);
} }
void SimulatorBase::setup_slider(QWidget *item, size_t index) void Simulator_base::setup_slider(QWidget *item, size_t index)
{ {
QwtSlider *slider = qobject_cast<QwtSlider *>(item); QwtSlider *slider = qobject_cast<QwtSlider *>(item);
if (slider == nullptr) if (slider == nullptr)
@@ -511,7 +511,7 @@ void SimulatorBase::setup_slider(QWidget *item, size_t index)
[=, this] { m_web_socket->send_event(Web_socket_wrapper::Event::value_changed, index, slider->value()); }); [=, this] { m_web_socket->send_event(Web_socket_wrapper::Event::value_changed, index, slider->value()); });
} }
void SimulatorBase::setup_can_ui(QWidget *item, size_t index) void Simulator_base::setup_can_ui(QWidget *item, size_t index)
{ {
Can_Transceive *can = qobject_cast<Can_Transceive *>(item); Can_Transceive *can = qobject_cast<Can_Transceive *>(item);
if (can == nullptr) if (can == nullptr)
+2 -2
View File
@@ -13,11 +13,11 @@
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using json = nlohmann::json;
class SimulatorBase : public QMainWindow class Simulator_base : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SimulatorBase(Web_socket_wrapper *api, QWidget *parent = nullptr); explicit Simulator_base(Web_socket_wrapper *api, QWidget *parent = nullptr);
void sim_update(void); void sim_update(void);
QWidget *id_to_ui(size_t id); QWidget *id_to_ui(size_t id);
virtual QLabel *id_to_label(size_t name) virtual QLabel *id_to_label(size_t name)
+1 -1
View File
@@ -2,7 +2,7 @@
#include "ui_sim-can_debugger.h" #include "ui_sim-can_debugger.h"
Can_Debugger::Can_Debugger(Web_socket_wrapper *web_socket, QWidget *parent) Can_Debugger::Can_Debugger(Web_socket_wrapper *web_socket, QWidget *parent)
: SimulatorBase(web_socket, parent), ui(new Ui::Can_Debugger) : Simulator_base(web_socket, parent), ui(new Ui::Can_Debugger)
{ {
ui->setupUi(this); ui->setupUi(this);
this->setWindowTitle("CAN Debugger"); this->setWindowTitle("CAN Debugger");
+1 -1
View File
@@ -9,7 +9,7 @@ namespace Ui
class Can_Debugger; class Can_Debugger;
} }
class Can_Debugger : public SimulatorBase class Can_Debugger : public Simulator_base
{ {
Q_OBJECT Q_OBJECT
+1 -1
View File
@@ -2,7 +2,7 @@
#include "ui_sim-test.h" #include "ui_sim-test.h"
Test_Sim::Test_Sim(Web_socket_wrapper *web_socket, QWidget *parent) Test_Sim::Test_Sim(Web_socket_wrapper *web_socket, QWidget *parent)
: SimulatorBase(web_socket, parent), ui(new Ui::Test_Sim) : Simulator_base(web_socket, parent), ui(new Ui::Test_Sim)
{ {
ui->setupUi(this); ui->setupUi(this);
this->setWindowTitle("Test Sim"); this->setWindowTitle("Test Sim");
+1 -1
View File
@@ -10,7 +10,7 @@ namespace Ui
class Test_Sim; class Test_Sim;
} }
class Test_Sim : public SimulatorBase class Test_Sim : public Simulator_base
{ {
Q_OBJECT Q_OBJECT