Use enhanced autocombobox for timer mode

This commit is contained in:
elecpower
2021-03-17 21:48:51 +11:00
parent 950fa3d105
commit 44cfbd43fb
3 changed files with 3 additions and 18 deletions
+2 -16
View File
@@ -56,10 +56,8 @@ TimerPanel::TimerPanel(QWidget * parent, ModelData & model, TimerData & timer, G
ui->value->setField(timer.val, this);
ui->value->setMaximumTime(firmware->getMaxTimerStart());
// Mode
ui->mode->setModel(panelFilteredModels->getItemModel(FIM_TIMERSWITCH));
ui->mode->setCurrentIndex(ui->mode->findData(timer.mode.toValue()));
connect(ui->mode, SIGNAL(activated(int)), this, SLOT(onModeChanged(int)));
ui->mode->setField(timer.mode, this);
ui->countdownBeep->setModel(panelItemModels->getItemModel(AIM_TIMER_COUNTDOWNBEEP));
ui->countdownBeep->setField(timer.countdownBeep, this);
@@ -102,7 +100,7 @@ void TimerPanel::update()
lock = true;
ui->name->updateValue();
ui->mode->setCurrentIndex(ui->mode->findData(timer.mode.toValue()));
ui->mode->updateValue();
ui->value->updateValue();
ui->countdownBeep->updateValue();
@@ -128,18 +126,6 @@ QWidget * TimerPanel::getLastFocus()
return ui->persistent;
}
void TimerPanel::onModeChanged(int index)
{
if (!lock) {
bool ok;
const RawSwitch rs(ui->mode->itemData(index).toInt(&ok));
if (ok && timer.mode.toValue() != rs.toValue()) {
timer.mode = rs;
emit modified();
}
}
}
void TimerPanel::connectItemModelEvents(const FilteredItemModel * itemModel)
{
connect(itemModel, &FilteredItemModel::aboutToBeUpdated, this, &TimerPanel::onItemModelAboutToBeUpdated);