From 1678753c9b19d745dc7dde7a7d500f8962fc1aa6 Mon Sep 17 00:00:00 2001 From: elecpower Date: Wed, 17 Mar 2021 22:39:14 +1100 Subject: [PATCH] Use data model for throttle src --- companion/src/modeledit/setup.cpp | 35 ++++--------------------------- companion/src/modeledit/setup.h | 2 -- companion/src/modeledit/setup.ui | 2 +- 3 files changed, 5 insertions(+), 34 deletions(-) diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 9bfd8fd3e..db3fb8b33 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -1113,6 +1113,9 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge ui->toplcdTimer->hide(); } + ui->throttleSource->setModel(panelFilteredModels->getItemModel(FIM_THRSOURCE)); + ui->throttleSource->setField(model.thrTraceSrc, this); + if (!firmware->getCapability(HasDisplayText)) { ui->displayText->hide(); ui->editText->hide(); @@ -1279,14 +1282,6 @@ void SetupPanel::on_trimIncrement_currentIndexChanged(int index) emit modified(); } -void SetupPanel::on_throttleSource_currentIndexChanged(int index) -{ - if (!lock) { - model->thrTraceSrc = ui->throttleSource->currentData().toUInt(); - emit modified(); - } -} - void SetupPanel::on_throttleTrimSwitch_currentIndexChanged(int index) { if (!lock) { @@ -1345,28 +1340,6 @@ void SetupPanel::on_image_currentIndexChanged(int index) } } -void SetupPanel::populateThrottleSourceCB() -{ - Board::Type board = firmware->getBoard(); - lock = true; - ui->throttleSource->clear(); - ui->throttleSource->addItem(tr("THR"), 0); - - int idx = 1; - for (int i = 0; i < getBoardCapability(board, Board::Pots) + getBoardCapability(board, Board::Sliders); i++, idx++) { - if (RawSource(SOURCE_TYPE_STICK, 4 + i).isAvailable(model, &generalSettings, board)) { - ui->throttleSource->addItem(firmware->getAnalogInputName(4 + i), idx); - } - } - for (int i = 0; i < firmware->getCapability(Outputs); i++, idx++) { - ui->throttleSource->addItem(RawSource(SOURCE_TYPE_CH, i).toString(model, &generalSettings), idx); - } - - int thrTraceSrcIdx = ui->throttleSource->findData(model->thrTraceSrc); - ui->throttleSource->setCurrentIndex(thrTraceSrcIdx); - lock = false; -} - void SetupPanel::populateThrottleTrimSwitchCB() { Board::Type board = firmware->getBoard(); @@ -1394,7 +1367,7 @@ void SetupPanel::update() { ui->name->setText(model->name); ui->throttleReverse->setChecked(model->throttleReversed); - populateThrottleSourceCB(); + ui->throttleSource->updateValue(); populateThrottleTrimSwitchCB(); ui->throttleWarning->setChecked(!model->disableThrottleWarning); ui->trimIncrement->setCurrentIndex(model->trimInc+2); diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h index eeb34aef6..82e69ec75 100644 --- a/companion/src/modeledit/setup.h +++ b/companion/src/modeledit/setup.h @@ -142,7 +142,6 @@ class SetupPanel : public ModelPanel private slots: void on_name_editingFinished(); - void on_throttleSource_currentIndexChanged(int index); void on_throttleTrimSwitch_currentIndexChanged(int index); void on_throttleTrim_toggled(bool checked); void on_extendedLimits_toggled(bool checked); @@ -185,7 +184,6 @@ class SetupPanel : public ModelPanel void updateStartupSwitches(); void updatePotWarnings(); void updateBeepCenter(); - void populateThrottleSourceCB(); void populateThrottleTrimSwitchCB(); int timersCount; int selectedTimerIndex; diff --git a/companion/src/modeledit/setup.ui b/companion/src/modeledit/setup.ui index 8b2409191..ee0ec28a3 100644 --- a/companion/src/modeledit/setup.ui +++ b/companion/src/modeledit/setup.ui @@ -604,7 +604,7 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi - + 0