mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
Moving simulatorbase to size_t ids
This commit is contained in:
+68
-20
@@ -118,10 +118,17 @@ void SimulatorBase::UI_item_parser(json& input)
|
||||
|
||||
void SimulatorBase::process_ui_label(json& uiItem)
|
||||
{
|
||||
QLabel* label = id_to_label(QString::fromStdString(uiItem["id"]));
|
||||
QWidget* widget = id_to_ui(uiItem["id"]);
|
||||
if (widget == nullptr)
|
||||
{
|
||||
QD << "id_to_ui returned null on " << QString::number((size_t)uiItem["id"]);
|
||||
return;
|
||||
}
|
||||
|
||||
auto label = qobject_cast<QLabel*>(widget);
|
||||
if (label == nullptr)
|
||||
{
|
||||
QD << "id_to_label returned null on " << QString::fromStdString(uiItem["id"]);
|
||||
QD << "widget is not of type QLabel";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -135,11 +142,18 @@ void SimulatorBase::process_ui_label(json& uiItem)
|
||||
|
||||
void SimulatorBase::process_ui_slider(json& uiItem)
|
||||
{
|
||||
QwtSlider* slider = id_to_slider(QString::fromStdString(uiItem["id"]));
|
||||
QLabel* label = id_to_slider_label(QString::fromStdString(uiItem["id"]));
|
||||
QLabel* label = id_to_label(uiItem["id"]);
|
||||
QWidget* widget = id_to_ui(uiItem["id"]);
|
||||
if (widget == nullptr)
|
||||
{
|
||||
QD << "id_to_ui returned null on " << QString::number((size_t)uiItem["id"]);
|
||||
return;
|
||||
}
|
||||
|
||||
auto slider = qobject_cast<QwtSlider*>(widget);
|
||||
if (slider == nullptr)
|
||||
{
|
||||
QD << "id_to_slider returned null on " << QString::fromStdString(uiItem["id"]);
|
||||
QD << "widget is not of type QwtSlider";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -151,7 +165,7 @@ void SimulatorBase::process_ui_slider(json& uiItem)
|
||||
{
|
||||
if (label != nullptr)
|
||||
{
|
||||
label->setText(format_slider_value(QString::fromStdString(uiItem["id"]), value));
|
||||
label->setText(format_value((size_t)uiItem.at("id"), value));
|
||||
}
|
||||
slider->setValue(value);
|
||||
}
|
||||
@@ -171,11 +185,18 @@ void SimulatorBase::process_ui_slider(json& uiItem)
|
||||
|
||||
void SimulatorBase::process_ui_dial(json& uiItem)
|
||||
{
|
||||
QwtDial* dial = id_to_dial(QString::fromStdString(uiItem["id"]));
|
||||
QLabel* label = id_to_dial_label(QString::fromStdString(uiItem["id"]));
|
||||
QLabel* label = id_to_label(uiItem["id"]);
|
||||
QWidget* widget = id_to_ui(uiItem["id"]);
|
||||
if (widget == nullptr)
|
||||
{
|
||||
QD << "id_to_ui returned null on " << QString::number((size_t)uiItem["id"]);
|
||||
return;
|
||||
}
|
||||
|
||||
auto dial = qobject_cast<QwtDial*>(widget);
|
||||
if (dial == nullptr)
|
||||
{
|
||||
QD << "id_to_dial returned null on " << QString::fromStdString(uiItem["id"]);
|
||||
QD << "widget is not of type QwtDial";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,7 +207,7 @@ void SimulatorBase::process_ui_dial(json& uiItem)
|
||||
{
|
||||
if (label != nullptr)
|
||||
{
|
||||
label->setText(format_slider_value(QString::fromStdString(uiItem["id"]), value));
|
||||
label->setText(format_value(uiItem["id"], value));
|
||||
}
|
||||
dial->setValue(value);
|
||||
}
|
||||
@@ -201,11 +222,18 @@ void SimulatorBase::process_ui_dial(json& uiItem)
|
||||
|
||||
void SimulatorBase::process_ui_thermo(json& uiItem)
|
||||
{
|
||||
QwtThermo* thermo = id_to_thermo(QString::fromStdString(uiItem["id"]));
|
||||
QLabel* label = id_to_thermo_label(QString::fromStdString(uiItem["id"]));
|
||||
QLabel* label = id_to_label(uiItem["id"]);
|
||||
QWidget* widget = id_to_ui(uiItem["id"]);
|
||||
if (widget == nullptr)
|
||||
{
|
||||
QD << "id_to_ui returned null on " << QString::number((size_t)uiItem["id"]);
|
||||
return;
|
||||
}
|
||||
|
||||
auto thermo = qobject_cast<QwtThermo*>(widget);
|
||||
if (thermo == nullptr)
|
||||
{
|
||||
QD << "id_to_dial returned null on " << QString::fromStdString(uiItem["id"]);
|
||||
QD << "widget is not of type QwtThermo";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -216,7 +244,7 @@ void SimulatorBase::process_ui_thermo(json& uiItem)
|
||||
{
|
||||
if (label != nullptr)
|
||||
{
|
||||
label->setText(format_slider_value(QString::fromStdString(uiItem["id"]), value));
|
||||
label->setText(format_value(uiItem["id"], value));
|
||||
}
|
||||
thermo->setValue(value);
|
||||
}
|
||||
@@ -237,10 +265,17 @@ void SimulatorBase::process_ui_textbox(json& uiItem)
|
||||
|
||||
void SimulatorBase::process_ui_combobox(json& uiItem)
|
||||
{
|
||||
QComboBox* combobox = id_to_combobox(QString::fromStdString(uiItem["id"]));
|
||||
QWidget* widget = id_to_ui(uiItem["id"]);
|
||||
if (widget == nullptr)
|
||||
{
|
||||
QD << "id_to_ui returned null on " << QString::number((size_t)uiItem["id"]);
|
||||
return;
|
||||
}
|
||||
|
||||
auto combobox = qobject_cast<QComboBox*>(widget);
|
||||
if (combobox == nullptr)
|
||||
{
|
||||
QD << "id_to_combobox returned null on " << QString::fromStdString(uiItem["id"]);
|
||||
QD << "widget is not of type QComboBox";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -267,11 +302,17 @@ void SimulatorBase::process_ui_radiobutton(json& uiItem)
|
||||
void SimulatorBase::process_ui_button(json& uiItem)
|
||||
{
|
||||
//TODO: fix bgcolor and color
|
||||
QPushButton* button = id_to_button(QString::fromStdString(uiItem["id"]));
|
||||
QWidget* widget = id_to_ui(uiItem["id"]);
|
||||
if (widget == nullptr)
|
||||
{
|
||||
QD << "id_to_ui returned null on " << QString::number((size_t)uiItem["id"]);
|
||||
return;
|
||||
}
|
||||
|
||||
auto button = qobject_cast<QPushButton*>(widget);
|
||||
if (button == nullptr)
|
||||
{
|
||||
QD << "id_to_button returned null on " << QString::fromStdString(uiItem["id"]);
|
||||
QD << "widget is not of type QPushButton";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -322,10 +363,17 @@ void SimulatorBase::process_ui_button(json& uiItem)
|
||||
|
||||
void SimulatorBase::process_ui_led(json& uiItem)
|
||||
{
|
||||
QPushButton* led = id_to_led(QString::fromStdString(uiItem["id"]));
|
||||
QWidget* widget = id_to_ui(uiItem["id"]);
|
||||
if (widget == nullptr)
|
||||
{
|
||||
QD << "id_to_ui returned null on " << QString::number((size_t)uiItem["id"]);
|
||||
return;
|
||||
}
|
||||
|
||||
auto led = qobject_cast<QPushButton*>(widget);
|
||||
if (led == nullptr)
|
||||
{
|
||||
QD << "id_to_led returned null on " << QString::fromStdString(uiItem["id"]);
|
||||
QD << "widget is not of type led";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+3
-14
@@ -20,20 +20,9 @@ class SimulatorBase : public QMainWindow {
|
||||
explicit SimulatorBase(Web_socket_wrapper* api, QWidget* parent = nullptr);
|
||||
void setup_cb(void);
|
||||
void sim_update(void);
|
||||
virtual QLabel* id_to_label(QString name) {return nullptr;}
|
||||
virtual QPushButton* id_to_led(QString name) {return nullptr;}
|
||||
virtual QPushButton* id_to_button(QString name) {return nullptr;}
|
||||
virtual QwtSlider* id_to_slider(QString name) {return nullptr;}
|
||||
virtual QLabel* id_to_slider_label(QString name) {return nullptr;}
|
||||
virtual QString format_slider_value(QString name, double val) {return QString();}
|
||||
virtual QwtDial* id_to_dial(QString name) {return nullptr;}
|
||||
virtual QLabel* id_to_dial_label(QString name) {return nullptr;}
|
||||
virtual QString format_dial_value(QString name, double val) {return QString();}
|
||||
virtual QwtThermo* id_to_thermo(QString name) {return nullptr;}
|
||||
virtual QLabel* id_to_thermo_label(QString name) {return nullptr;}
|
||||
virtual QString format_thermo_label(QString name) {return QString();}
|
||||
virtual QComboBox* id_to_combobox(QString name) {return nullptr;}
|
||||
virtual QTextEdit* id_to_textbox(QString name) {return nullptr;}
|
||||
virtual QWidget* id_to_ui(size_t id) {return nullptr;}
|
||||
virtual QLabel* id_to_label(size_t name) {return nullptr;}
|
||||
virtual QString format_value(size_t name, double val) {return QString();}
|
||||
|
||||
signals:
|
||||
void quit();
|
||||
|
||||
Reference in New Issue
Block a user