Finis support for ENUM item types
This commit is contained in:
parent
e881472e7c
commit
3794e0031b
4 changed files with 96 additions and 1 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include "ui_itemwidget.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QDebug>
|
||||
#include <QSlider>
|
||||
#include "itemsettingsdialog.h"
|
||||
|
|
@ -26,6 +27,16 @@ ItemWidget::ItemWidget(std::weak_ptr<Item> item, bool noGroupEdit, QWidget *pare
|
|||
ui->checkBox->hide();
|
||||
ui->slider->hide();
|
||||
}
|
||||
else if(workingItem->getValueType() == ITEM_VALUE_ENUM)
|
||||
{
|
||||
ui->slider->hide();
|
||||
ui->checkBox->hide();
|
||||
QStringList list;
|
||||
for(const QString& name : workingItem->getValueNames())
|
||||
list.append(name);
|
||||
ui->comboBox->addItems(list);
|
||||
ui->comboBox->setCurrentIndex(workingItem->getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->slider->hide();
|
||||
|
|
@ -37,6 +48,8 @@ ItemWidget::ItemWidget(std::weak_ptr<Item> item, bool noGroupEdit, QWidget *pare
|
|||
|
||||
if(workingItem->getValueType() == ITEM_VALUE_UINT)
|
||||
connect(ui->slider, &QSlider::valueChanged, this, &ItemWidget::moveToValue);
|
||||
else if(workingItem->getValueType() == ITEM_VALUE_ENUM)
|
||||
connect(ui->comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ItemWidget::moveToValue);
|
||||
else
|
||||
connect(ui->checkBox, &QCheckBox::toggled, this, &ItemWidget::moveToState);
|
||||
connect(ui->pushButton, &QPushButton::clicked, this, &ItemWidget::showSettingsDialog);
|
||||
|
|
@ -84,6 +97,7 @@ void ItemWidget::disable()
|
|||
ui->checkBox->setEnabled(false);
|
||||
ui->label->setEnabled(false);
|
||||
ui->slider->setEnabled(false);
|
||||
ui->comboBox->setEnabled(false);
|
||||
ui->pushButton_Remove->setEnabled(false);
|
||||
}
|
||||
|
||||
|
|
@ -115,6 +129,16 @@ std::weak_ptr<Item> ItemWidget::getItem()
|
|||
|
||||
void ItemWidget::onItemUpdated(ItemUpdateRequest update)
|
||||
{
|
||||
if(update.changes.valueNames)
|
||||
{
|
||||
ui->comboBox->blockSignals(true);
|
||||
ui->comboBox->clear();
|
||||
QStringList list;
|
||||
for(const QString& name : update.payload.getValueNames())
|
||||
list.append(name);
|
||||
ui->comboBox->addItems(list);
|
||||
ui->comboBox->blockSignals(false);
|
||||
}
|
||||
stateChanged(update.payload.getValue());
|
||||
}
|
||||
|
||||
|
|
@ -126,6 +150,9 @@ void ItemWidget::stateChanged(int state)
|
|||
ui->checkBox->blockSignals(true);
|
||||
ui->checkBox->setChecked(state);
|
||||
ui->checkBox->blockSignals(false);
|
||||
ui->comboBox->blockSignals(true);
|
||||
ui->comboBox->setCurrentIndex(state);
|
||||
ui->comboBox->blockSignals(false);
|
||||
}
|
||||
|
||||
ItemWidget::~ItemWidget()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue