1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

Fix gcc warnings

This commit is contained in:
Jon 2022-09-16 11:41:40 +01:00
parent 598f166cd3
commit 460576e640
14 changed files with 81 additions and 47 deletions

View File

@ -162,6 +162,7 @@ void RemoteControlDeviceDialog::enableWidgets()
void RemoteControlDeviceDialog::controlSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) void RemoteControlDeviceDialog::controlSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{ {
(void)deselected;
bool arrowsEnabled = (selected.indexes().size() > 0); bool arrowsEnabled = (selected.indexes().size() > 0);
bool editEnabled = arrowsEnabled && (ui->protocol->currentText() == "VISA"); bool editEnabled = arrowsEnabled && (ui->protocol->currentText() == "VISA");
@ -173,6 +174,7 @@ void RemoteControlDeviceDialog::controlSelectionChanged(const QItemSelection &se
void RemoteControlDeviceDialog::sensorSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) void RemoteControlDeviceDialog::sensorSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{ {
(void)deselected;
bool arrowsEnabled = (selected.indexes().size() > 0); bool arrowsEnabled = (selected.indexes().size() > 0);
bool editEnabled = arrowsEnabled && (ui->protocol->currentText() == "VISA"); bool editEnabled = arrowsEnabled && (ui->protocol->currentText() == "VISA");
@ -419,8 +421,6 @@ void RemoteControlDeviceDialog::on_controlEdit_clicked()
RemoteControlVISAControlDialog dialog(m_settings, m_rcDevice, control, false); RemoteControlVISAControlDialog dialog(m_settings, m_rcDevice, control, false);
if (dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
DeviceDiscoverer::DeviceInfo *info = &m_deviceInfo[ui->device->currentIndex()];
ui->controls->item(row, COL_NAME)->setText(control->m_name); ui->controls->item(row, COL_NAME)->setText(control->m_name);
ui->controls->item(row, COL_UNITS)->setText(control->m_units); ui->controls->item(row, COL_UNITS)->setText(control->m_units);
ui->controls->item(row, COL_ID)->setText(control->m_id); ui->controls->item(row, COL_ID)->setText(control->m_id);
@ -430,6 +430,7 @@ void RemoteControlDeviceDialog::on_controlEdit_clicked()
void RemoteControlDeviceDialog::on_controls_cellDoubleClicked(int row, int column) void RemoteControlDeviceDialog::on_controls_cellDoubleClicked(int row, int column)
{ {
(void)row;
if ((ui->protocol->currentText() == "VISA") && (column <= COL_ID)) { if ((ui->protocol->currentText() == "VISA") && (column <= COL_ID)) {
on_controlEdit_clicked(); on_controlEdit_clicked();
} }
@ -547,8 +548,6 @@ void RemoteControlDeviceDialog::on_sensorEdit_clicked()
RemoteControlVISASensorDialog dialog(m_settings, m_rcDevice, sensor, false); RemoteControlVISASensorDialog dialog(m_settings, m_rcDevice, sensor, false);
if (dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
DeviceDiscoverer::DeviceInfo *info = &m_deviceInfo[ui->device->currentIndex()];
ui->sensors->item(row, COL_NAME)->setText(sensor->m_name); ui->sensors->item(row, COL_NAME)->setText(sensor->m_name);
ui->sensors->item(row, COL_ID)->setText(sensor->m_id); ui->sensors->item(row, COL_ID)->setText(sensor->m_id);
ui->sensors->item(row, COL_UNITS)->setText(sensor->m_units); ui->sensors->item(row, COL_UNITS)->setText(sensor->m_units);
@ -558,6 +557,7 @@ void RemoteControlDeviceDialog::on_sensorEdit_clicked()
void RemoteControlDeviceDialog::on_sensors_cellDoubleClicked(int row, int column) void RemoteControlDeviceDialog::on_sensors_cellDoubleClicked(int row, int column)
{ {
(void)row;
if ((ui->protocol->currentText() == "VISA") && (column <= COL_ID)) { if ((ui->protocol->currentText() == "VISA") && (column <= COL_ID)) {
on_sensorEdit_clicked(); on_sensorEdit_clicked();
} }

View File

@ -471,6 +471,7 @@ void RemoteControlGUI::createControls(RemoteControlDeviceGUI *gui, QBoxLayout *v
connect(button, &QToolButton::clicked, connect(button, &QToolButton::clicked,
[=] (bool checked) [=] (bool checked)
{ {
(void) checked;
RemoteControl::MsgDeviceSetState *message = RemoteControl::MsgDeviceSetState::create(gui->m_rcDevice->m_protocol, RemoteControl::MsgDeviceSetState *message = RemoteControl::MsgDeviceSetState::create(gui->m_rcDevice->m_protocol,
gui->m_rcDevice->m_info.m_id, gui->m_rcDevice->m_info.m_id,
control.m_id, control.m_id,
@ -483,6 +484,9 @@ void RemoteControlGUI::createControls(RemoteControlDeviceGUI *gui, QBoxLayout *v
} }
break; break;
default:
qDebug() << "RemoteControlGUI::createControls: Unexpected type for control.";
break;
} }
gui->m_controls.insert(control.m_id, widgets); gui->m_controls.insert(control.m_id, widgets);
@ -824,7 +828,7 @@ void RemoteControlGUI::updateControl(QWidget *widget, const DeviceDiscoverer::Co
{ {
if (ButtonSwitch *button = qobject_cast<ButtonSwitch *>(widget)) if (ButtonSwitch *button = qobject_cast<ButtonSwitch *>(widget))
{ {
if (value.type() == QMetaType::QString) if ((QMetaType::Type)value.type() == QMetaType::QString)
{ {
if (value.toString() == "unavailable") if (value.toString() == "unavailable")
{ {
@ -1007,7 +1011,7 @@ void RemoteControlGUI::updateChart(RemoteControlDeviceGUI *deviceGUI, const QStr
{ {
formattedValue = QString::asprintf(format.toUtf8(), value.toInt()); formattedValue = QString::asprintf(format.toUtf8(), value.toInt());
} }
else if ((value.type() == QMetaType::Double) || (value.type() == QMetaType::Float)) else if (((QMetaType::Type)value.type() == QMetaType::Double) || ((QMetaType::Type)value.type() == QMetaType::Float))
{ {
if (format.isEmpty()) { if (format.isEmpty()) {
format = "%.1f"; format = "%.1f";

View File

@ -23,8 +23,8 @@
RemoteControlSettingsDialog::RemoteControlSettingsDialog(RemoteControlSettings *settings, QWidget* parent) : RemoteControlSettingsDialog::RemoteControlSettingsDialog(RemoteControlSettings *settings, QWidget* parent) :
QDialog(parent), QDialog(parent),
m_settings(settings), ui(new Ui::RemoteControlSettingsDialog),
ui(new Ui::RemoteControlSettingsDialog) m_settings(settings)
{ {
ui->setupUi(this); ui->setupUi(this);
resizeTable(); resizeTable();
@ -121,11 +121,14 @@ void RemoteControlSettingsDialog::accept()
void RemoteControlSettingsDialog::on_devices_cellDoubleClicked(int row, int column) void RemoteControlSettingsDialog::on_devices_cellDoubleClicked(int row, int column)
{ {
(void)row;
(void)column;
on_edit_clicked(); on_edit_clicked();
} }
void RemoteControlSettingsDialog::devicesSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) void RemoteControlSettingsDialog::devicesSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{ {
(void)deselected;
bool enabled = selected.indexes().size() > 0; bool enabled = selected.indexes().size() > 0;
ui->remove->setEnabled(enabled); ui->remove->setEnabled(enabled);
ui->edit->setEnabled(enabled); ui->edit->setEnabled(enabled);

View File

@ -155,11 +155,13 @@ void RemoteControlVISAControlDialog::on_name_textChanged(const QString &text)
void RemoteControlVISAControlDialog::on_id_textChanged(const QString &text) void RemoteControlVISAControlDialog::on_id_textChanged(const QString &text)
{ {
(void)text;
validate(); validate();
} }
void RemoteControlVISAControlDialog::on_id_textEdited(const QString &text) void RemoteControlVISAControlDialog::on_id_textEdited(const QString &text)
{ {
(void)text;
m_userHasEditedId = true; m_userHasEditedId = true;
} }

View File

@ -65,11 +65,13 @@ void RemoteControlVISASensorDialog::on_name_textChanged(const QString &text)
void RemoteControlVISASensorDialog::on_id_textChanged(const QString &text) void RemoteControlVISASensorDialog::on_id_textChanged(const QString &text)
{ {
(void)text;
validate(); validate();
} }
void RemoteControlVISASensorDialog::on_id_textEdited(const QString &text) void RemoteControlVISASensorDialog::on_id_textEdited(const QString &text)
{ {
(void)text;
m_userHasEditedId = true; m_userHasEditedId = true;
} }

View File

@ -102,22 +102,22 @@ bool RemoteControlWorker::handleMessage(const Message& cmd)
QString id = msg.getId(); QString id = msg.getId();
QVariant variant = msg.getValue(); QVariant variant = msg.getValue();
if (variant.type() == QMetaType::Bool) if ((QMetaType::Type)variant.type() == QMetaType::Bool)
{ {
bool b = variant.toBool(); bool b = variant.toBool();
device->setState(id, b); device->setState(id, b);
} }
else if (variant.type() == QMetaType::Int) else if ((QMetaType::Type)variant.type() == QMetaType::Int)
{ {
int i = variant.toInt(); int i = variant.toInt();
device->setState(id, i); device->setState(id, i);
} }
else if (variant.type() == QMetaType::Float) else if ((QMetaType::Type)variant.type() == QMetaType::Float)
{ {
float f = variant.toFloat(); float f = variant.toFloat();
device->setState(id, f); device->setState(id, f);
} }
else if (variant.type() == QMetaType::QString) else if ((QMetaType::Type)variant.type() == QMetaType::QString)
{ {
QString s = variant.toString(); QString s = variant.toString();
device->setState(id, s); device->setState(id, s);

View File

@ -52,42 +52,41 @@ Device* Device::create(const QHash<QString, QVariant>& settings, const QString&
else else
{ {
qDebug() << "Device::create: A deviceId is required for: " << protocol; qDebug() << "Device::create: A deviceId is required for: " << protocol;
return nullptr;
} }
} }
else if (protocol == "HomeAssistant") else if (protocol == "HomeAssistant")
{ {
if (checkSettings(settings, protocol)) if (settings.contains("deviceId"))
{ {
if (settings.contains("deviceId")) return new HomeAssistantDevice(settings.value("apiKey").toString(),
{ settings.value("url").toString(),
return new HomeAssistantDevice(settings.value("apiKey").toString(), settings.value("deviceId").toString(),
settings.value("url").toString(), settings.value("controlIds").toStringList(),
settings.value("deviceId").toString(), settings.value("sensorIds").toStringList(),
settings.value("controlIds").toStringList(), info);
settings.value("sensorIds").toStringList(), }
info); else
} {
else qDebug() << "Device::create: A deviceId is required for: " << protocol;
{
qDebug() << "Device::create: A deviceId is required for: " << protocol;
return nullptr;
}
} }
} }
else if (protocol == "VISA") else if (protocol == "VISA")
{ {
return new VISADevice(settings, if (settings.contains("deviceId"))
settings.value("deviceId").toString(), {
settings.value("controlIds").toStringList(), return new VISADevice(settings,
settings.value("sensorIds").toStringList(), settings.value("deviceId").toString(),
info); settings.value("controlIds").toStringList(),
settings.value("sensorIds").toStringList(),
info);
}
else
{
qDebug() << "Device::create: A deviceId is required for: " << protocol;
}
} }
} }
else return nullptr;
{
return nullptr;
}
} }
bool Device::checkSettings(const QHash<QString, QVariant>& settings, const QString& protocol) bool Device::checkSettings(const QHash<QString, QVariant>& settings, const QString& protocol)
@ -135,6 +134,26 @@ bool Device::checkSettings(const QHash<QString, QVariant>& settings, const QStri
} }
} }
void Device::setState(const QString &controlId, bool state)
{
qDebug() << "Device::setState: " << getProtocol() << " doesn't support bool. Can't set " << controlId << " to " << state;
}
void Device::setState(const QString &controlId, int state)
{
qDebug() << "Device::setState: " << getProtocol() << " doesn't support int. Can't set " << controlId << " to " << state;
}
void Device::setState(const QString &controlId, float state)
{
qDebug() << "Device::setState: " << getProtocol() << " doesn't support float. Can't set " << controlId << " to " << state;
}
void Device::setState(const QString &controlId, const QString &state)
{
qDebug() << "Device::setState: " << getProtocol() << " doesn't support QString. Can't set " << controlId << " to " << state;
}
const QStringList DeviceDiscoverer::m_typeStrings = { const QStringList DeviceDiscoverer::m_typeStrings = {
"Auto", "Auto",
"Boolean", "Boolean",
@ -446,7 +465,7 @@ void DeviceDiscoverer::DeviceInfo::deleteSensor(const QString &id)
QDataStream& operator<<(QDataStream& out, const DeviceDiscoverer::ControlInfo* control) QDataStream& operator<<(QDataStream& out, const DeviceDiscoverer::ControlInfo* control)
{ {
int typeId; int typeId;
if (const VISADevice::VISAControl* c = dynamic_cast<const VISADevice::VISAControl *>(control)) { if (dynamic_cast<const VISADevice::VISAControl *>(control)) {
typeId = 1; typeId = 1;
} else { } else {
typeId = 0; typeId = 0;
@ -474,7 +493,7 @@ QDataStream& operator>>(QDataStream& in, DeviceDiscoverer::ControlInfo*& control
QDataStream& operator<<(QDataStream& out, const DeviceDiscoverer::SensorInfo* sensor) QDataStream& operator<<(QDataStream& out, const DeviceDiscoverer::SensorInfo* sensor)
{ {
int typeId; int typeId;
if (const VISADevice::VISASensor* s = dynamic_cast<const VISADevice::VISASensor *>(sensor)) { if (dynamic_cast<const VISADevice::VISASensor *>(sensor)) {
typeId = 1; typeId = 1;
} else { } else {
typeId = 0; typeId = 0;

View File

@ -57,6 +57,7 @@ public:
QString m_units; QString m_units;
ControlInfo(); ControlInfo();
virtual ~ControlInfo() {}
operator QString() const; operator QString() const;
virtual ControlInfo *clone() const; virtual ControlInfo *clone() const;
virtual QByteArray serialize() const; virtual QByteArray serialize() const;
@ -69,6 +70,7 @@ public:
Type m_type; Type m_type;
QString m_units; // W/Watts etc QString m_units; // W/Watts etc
virtual ~SensorInfo() {}
operator QString() const; operator QString() const;
virtual SensorInfo *clone() const; virtual SensorInfo *clone() const;
virtual QByteArray serialize() const; virtual QByteArray serialize() const;
@ -122,10 +124,10 @@ public:
static bool checkSettings(const QHash<QString, QVariant>& settings, const QString& protocol); static bool checkSettings(const QHash<QString, QVariant>& settings, const QString& protocol);
virtual void getState() = 0; virtual void getState() = 0;
virtual void setState(const QString &controlId, bool state) {} virtual void setState(const QString &controlId, bool state);
virtual void setState(const QString &controlId, int state) {} virtual void setState(const QString &controlId, int state);
virtual void setState(const QString &controlId, float state) {} virtual void setState(const QString &controlId, float state);
virtual void setState(const QString &controlId, const QString &state) {} virtual void setState(const QString &controlId, const QString &state);
virtual QString getProtocol() const = 0; virtual QString getProtocol() const = 0;
virtual QString getDeviceId() const = 0; virtual QString getDeviceId() const = 0;

View File

@ -30,9 +30,9 @@ HomeAssistantDevice::HomeAssistantDevice(const QString& apiKey, const QString& u
const QStringList &controls, const QStringList &sensors, const QStringList &controls, const QStringList &sensors,
DeviceDiscoverer::DeviceInfo *info) : DeviceDiscoverer::DeviceInfo *info) :
Device(info), Device(info),
m_deviceId(deviceId),
m_apiKey(apiKey), m_apiKey(apiKey),
m_url(url), m_url(url)
m_deviceId(deviceId)
{ {
m_entities = controls; m_entities = controls;
m_entities.append(sensors); m_entities.append(sensors);

View File

@ -30,6 +30,7 @@ public:
DeviceDiscoverer::DeviceInfo *info=nullptr); DeviceDiscoverer::DeviceInfo *info=nullptr);
~HomeAssistantDevice(); ~HomeAssistantDevice();
virtual void getState() override; virtual void getState() override;
using Device::setState;
virtual void setState(const QString &controlId, bool state) override; virtual void setState(const QString &controlId, bool state) override;
virtual QString getProtocol() const override { return "HomeAssistant"; } virtual QString getProtocol() const override { return "HomeAssistant"; }
virtual QString getDeviceId() const override { return m_deviceId; } virtual QString getDeviceId() const override { return m_deviceId; }

View File

@ -285,7 +285,6 @@ void TPLinkDevice::handleReply(QNetworkReply* reply)
QJsonObject sysInfoObj = systemObj.value(QStringLiteral("get_sysinfo")).toObject(); QJsonObject sysInfoObj = systemObj.value(QStringLiteral("get_sysinfo")).toObject();
if (sysInfoObj.contains(QStringLiteral("child_num"))) if (sysInfoObj.contains(QStringLiteral("child_num")))
{ {
int childNum = sysInfoObj.value(QStringLiteral("child_num")).toInt();
QJsonArray children = sysInfoObj.value(QStringLiteral("children")).toArray(); QJsonArray children = sysInfoObj.value(QStringLiteral("children")).toArray();
for (auto childRef : children) for (auto childRef : children)
{ {
@ -495,7 +494,6 @@ void TPLinkDeviceDiscoverer::handleReply(QNetworkReply* reply)
} }
if (sysInfoObj.contains(QStringLiteral("child_num"))) if (sysInfoObj.contains(QStringLiteral("child_num")))
{ {
int childNum = sysInfoObj.value(QStringLiteral("child_num")).toInt();
QJsonArray children = sysInfoObj.value(QStringLiteral("children")).toArray(); QJsonArray children = sysInfoObj.value(QStringLiteral("children")).toArray();
int child = 1; int child = 1;
for (auto childRef : children) for (auto childRef : children)

View File

@ -44,6 +44,7 @@ public:
TPLinkDevice(const QString& username, const QString &password, const QString &deviceId, DeviceDiscoverer::DeviceInfo *info=nullptr); TPLinkDevice(const QString& username, const QString &password, const QString &deviceId, DeviceDiscoverer::DeviceInfo *info=nullptr);
~TPLinkDevice(); ~TPLinkDevice();
virtual void getState() override; virtual void getState() override;
using Device::setState;
virtual void setState(const QString &controlId, bool state) override; virtual void setState(const QString &controlId, bool state) override;
virtual QString getProtocol() const override { return "TPLink"; } virtual QString getProtocol() const override { return "TPLink"; }
virtual QString getDeviceId() const override { return m_deviceId; } virtual QString getDeviceId() const override { return m_deviceId; }

View File

@ -47,6 +47,7 @@ public:
DeviceDiscoverer::DeviceInfo *info=nullptr); DeviceDiscoverer::DeviceInfo *info=nullptr);
~VISADevice(); ~VISADevice();
virtual void getState() override; virtual void getState() override;
using Device::setState;
virtual void setState(const QString &controlId, bool state) override; virtual void setState(const QString &controlId, bool state) override;
virtual void setState(const QString &controlId, int state) override; virtual void setState(const QString &controlId, int state) override;
virtual void setState(const QString &controlId, float state) override; virtual void setState(const QString &controlId, float state) override;

View File

@ -3,6 +3,7 @@
#include <QString> #include <QString>
#include <QMap> #include <QMap>
#include <QDataStream>
#include "dsp/dsptypes.h" #include "dsp/dsptypes.h"
#include "export.h" #include "export.h"