mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
client
change id_to_label to use qwidget pointer instead of id
This commit is contained in:
@@ -239,7 +239,7 @@ void Simulator_base::process_ui_label(json &ui_item, QWidget *widget)
|
|||||||
|
|
||||||
void Simulator_base::process_ui_slider(json &ui_item, QWidget *widget)
|
void Simulator_base::process_ui_slider(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
QLabel *label = id_to_label(ui_item.at("id"));
|
QLabel *label = id_to_label(id_to_ui(ui_item.at("id")));
|
||||||
|
|
||||||
auto slider = qobject_cast<QwtSlider *>(widget);
|
auto slider = qobject_cast<QwtSlider *>(widget);
|
||||||
if (slider == nullptr)
|
if (slider == nullptr)
|
||||||
@@ -278,7 +278,7 @@ void Simulator_base::process_ui_slider(json &ui_item, QWidget *widget)
|
|||||||
|
|
||||||
void Simulator_base::process_ui_dial(json &ui_item, QWidget *widget)
|
void Simulator_base::process_ui_dial(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
QLabel *label = id_to_label(ui_item.at("id"));
|
QLabel *label = id_to_label(id_to_ui(ui_item.at("id")));
|
||||||
|
|
||||||
auto dial = qobject_cast<QwtDial *>(widget);
|
auto dial = qobject_cast<QwtDial *>(widget);
|
||||||
if (dial == nullptr)
|
if (dial == nullptr)
|
||||||
@@ -310,7 +310,7 @@ void Simulator_base::process_ui_dial(json &ui_item, QWidget *widget)
|
|||||||
|
|
||||||
void Simulator_base::process_ui_thermo(json &ui_item, QWidget *widget)
|
void Simulator_base::process_ui_thermo(json &ui_item, QWidget *widget)
|
||||||
{
|
{
|
||||||
QLabel *label = id_to_label(ui_item.at("id"));
|
QLabel *label = id_to_label(id_to_ui(ui_item.at("id")));
|
||||||
|
|
||||||
auto thermo = qobject_cast<QwtThermo *>(widget);
|
auto thermo = qobject_cast<QwtThermo *>(widget);
|
||||||
if (thermo == nullptr)
|
if (thermo == nullptr)
|
||||||
|
|||||||
@@ -26,8 +26,9 @@ class Simulator_base : public QMainWindow
|
|||||||
void sim_update(void);
|
void sim_update(void);
|
||||||
QString name() const;
|
QString name() const;
|
||||||
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(QWidget *widget)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(widget);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,9 +31,8 @@ Test_Sim::~Test_Sim()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
QLabel *Test_Sim::id_to_label(size_t id)
|
QLabel *Test_Sim::id_to_label(QWidget *widget)
|
||||||
{
|
{
|
||||||
QWidget *widget = id_to_ui(id);
|
|
||||||
if (widget == ui->slider)
|
if (widget == ui->slider)
|
||||||
return ui->slider_label;
|
return ui->slider_label;
|
||||||
if (widget == ui->thermo)
|
if (widget == ui->thermo)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class Test_Sim : public Simulator_base
|
|||||||
explicit Test_Sim(Web_socket_wrapper *web_socket = nullptr, QWidget *parent = nullptr);
|
explicit Test_Sim(Web_socket_wrapper *web_socket = nullptr, QWidget *parent = nullptr);
|
||||||
~Test_Sim();
|
~Test_Sim();
|
||||||
|
|
||||||
QLabel *id_to_label(size_t name) override;
|
QLabel *id_to_label(QWidget *widget) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Test_Sim *ui;
|
Ui::Test_Sim *ui;
|
||||||
|
|||||||
Reference in New Issue
Block a user