Add Sensor settings dialog

This commit is contained in:
Carl Philipp Klemm 2026-04-21 16:59:58 +02:00
parent 09f7e55b4e
commit 2fbfd1d458
6 changed files with 221 additions and 0 deletions

View file

@ -4,6 +4,8 @@
#include <QHeaderView>
#include <QScroller>
#include "sensorsettingsdialog.h"
SensorListWidget::SensorListWidget(const bool showHidden, QWidget *parent): QTableWidget(parent),
showHidden_(showHidden)
{
@ -15,12 +17,31 @@ SensorListWidget::SensorListWidget(const bool showHidden, QWidget *parent): QTab
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
sensorsChanged(std::vector<Sensor>());
verticalHeader()->hide();
connect(this, &QTableWidget::doubleClicked, this, &SensorListWidget::onDoubleClick);
}
SensorListWidget::SensorListWidget(SensorStore& sensorStore, const bool showHidden,
QWidget* parent): QTableWidget (parent), showHidden_(showHidden)
{
sensorsChanged(*(sensorStore.getSensors()));
connect(this, &QTableWidget::doubleClicked, this, &SensorListWidget::onDoubleClick);
}
void SensorListWidget::onDoubleClick(const QModelIndex &index)
{
if(index.isValid())
{
const Sensor& sensor = getSensorForIndex(index);
SensorSettingsDialog diag(sensor, this);
if(diag.exec())
{
Sensor updatedSensor = sensor;
updatedSensor.name = diag.getName();
updatedSensor.hidden = diag.getHidden();
globalSensors.sensorGotState(updatedSensor, SENSOR_UPDATE_USER);
}
}
}
void SensorListWidget::sensorsChanged(std::vector<Sensor> sensors)