mirror of
https://github.com/Fishwaldo/qt-openzwave.git
synced 2025-07-22 21:18:22 +00:00
Rename this directory to avoid binary clash
This commit is contained in:
parent
77ddc7e6ae
commit
38f0d765f9
18 changed files with 3 additions and 2 deletions
47
qt-simpleclient/bitsetwidget.cpp
Normal file
47
qt-simpleclient/bitsetwidget.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include <QCheckBox>
|
||||
#include <QDebug>
|
||||
|
||||
#include "bitsetwidget.h"
|
||||
#include "ui_bitsetwidget.h"
|
||||
|
||||
BitSetWidget::BitSetWidget(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::BitSetWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
BitSetWidget::~BitSetWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void BitSetWidget::setValue(QTOZW_ValueIDBitSet value) {
|
||||
this->m_value = value;
|
||||
for (uint8_t i = 0; i <= this->m_value.values.size() -1; ++i) {
|
||||
if (this->m_value.mask.at(i)) {
|
||||
QCheckBox *cb = new QCheckBox(this);
|
||||
cb->setText(this->m_value.label[i]);
|
||||
cb->setChecked(this->m_value.values.at(i));
|
||||
cb->setToolTip(this->m_value.help[i]);
|
||||
cb->setProperty("BitSetIndex", i);
|
||||
QObject::connect(cb, &QCheckBox::stateChanged, this, &BitSetWidget::cbChanged);
|
||||
this->ui->gridLayout_2->addWidget(cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BitSetWidget::cbChanged() {
|
||||
QCheckBox *cb = qobject_cast<QCheckBox *>(sender());
|
||||
if (!cb)
|
||||
throw std::logic_error("Widget is not of Type QCheckBox");
|
||||
int index = cb->property("BitSetIndex").toInt();
|
||||
if (this->m_value.values.at(index) != cb->isChecked())
|
||||
this->m_value.values[index] = cb->isChecked();
|
||||
emit stateChanged();
|
||||
}
|
||||
|
||||
QTOZW_ValueIDBitSet BitSetWidget::getValue() {
|
||||
return this->m_value;
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue