Ui: support showing and hideing hidden items in the sensor list
This commit is contained in:
parent
a07b019a22
commit
93999abafa
6 changed files with 14 additions and 5 deletions
|
|
@ -6,7 +6,7 @@
|
|||
PowerItem::PowerItem(uint32_t itemIdIn, QString name, uint8_t value, QObject* parent):
|
||||
Item(itemIdIn, name, value, parent)
|
||||
{
|
||||
stateChanged(Sensor(Sensor::TYPE_SHUTDOWN_IMMINENT, 0, 0, "Shutdown Imminent", true), SENSOR_UPDATE_BACKEND);
|
||||
globalSensors.sensorGotState(Sensor(Sensor::TYPE_SHUTDOWN_IMMINENT, 0, 0, "Shutdown Imminent", true), SENSOR_UPDATE_BACKEND);
|
||||
value_ = true;
|
||||
hidden_ = true;
|
||||
type_ = ITEM_VALUE_NO_VALUE;
|
||||
|
|
@ -18,7 +18,7 @@ void PowerItem::enactValue(uint8_t value)
|
|||
{
|
||||
qDebug()<<"shutdown";
|
||||
QTimer::singleShot(5000, this, &PowerItem::timeout);
|
||||
stateChanged(Sensor(Sensor::TYPE_SHUTDOWN_IMMINENT, 0, 1, "Shutdown Imminent", true), SENSOR_UPDATE_BACKEND);
|
||||
globalSensors.sensorGotState(Sensor(Sensor::TYPE_SHUTDOWN_IMMINENT, 0, 1, "Shutdown Imminent", true), SENSOR_UPDATE_BACKEND);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ class PowerItem: public Item
|
|||
private:
|
||||
|
||||
signals:
|
||||
|
||||
void stateChanged(Sensor sensor, sensor_update_type_t type = SENSOR_UPDATE_BACKEND);
|
||||
|
||||
private slots:
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ MainWindow::MainWindow(MainObject * const mainObject, QWidget *parent) :
|
|||
|
||||
connect(ui->pushButton_addItem, &QPushButton::clicked, this, &MainWindow::showItemCreationDialog);
|
||||
connect(ui->relayList, &ItemScrollBox::deleteRequest, &globalItems, &ItemStore::removeItem);
|
||||
connect(ui->checkBox_sensorsShowHidden, &QCheckBox::clicked, ui->sensorListView, &SensorListWidget::setShowHidden);
|
||||
|
||||
ui->splitter->setStretchFactor(1, 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_sensorsShowHidden">
|
||||
<property name="text">
|
||||
<string>Show Hidden</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ const Sensor& SensorListWidget::getSensorForIndex(const QModelIndex &index)
|
|||
void SensorListWidget::setShowHidden(const bool showHidden)
|
||||
{
|
||||
showHidden_ = showHidden;
|
||||
sensorsChanged(*globalSensors.getSensors());
|
||||
}
|
||||
|
||||
const Sensor& SensorListItem::getSensor()
|
||||
|
|
|
|||
|
|
@ -23,11 +23,12 @@ public:
|
|||
SensorListWidget(const bool showHidden = true, QWidget* parent = nullptr);
|
||||
SensorListWidget(SensorStore& sensorStore, const bool showHidden = true, QWidget* parent = nullptr);
|
||||
virtual ~SensorListWidget() {}
|
||||
void setShowHidden(const bool showHidden);
|
||||
|
||||
const Sensor& getSensorForIndex(const QModelIndex &index);
|
||||
|
||||
public slots:
|
||||
|
||||
void setShowHidden(const bool showHidden);
|
||||
void sensorsChanged(std::vector<Sensor> sensors);
|
||||
|
||||
private slots:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue