Fix remaining model editor sync issues with RawSource changes. (#5936)

* [Companion] Fix RawSource updates in Custom Function selectors (part fix for #4917).

* [Companion] Fix RawSource updates in HeliPanel selectors (closes #4917).
This commit is contained in:
Max Paperno
2018-06-03 23:20:14 +02:00
committed by Bertrand Songis
parent 9796654816
commit 3af2b090e5
4 changed files with 40 additions and 9 deletions
+25 -6
View File
@@ -69,6 +69,9 @@ void RepeatComboBox::update()
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware):
GenericPanel(parent, model, generalSettings, firmware),
functions(model ? model->customFn : generalSettings.customFn),
rawSwitchItemModel(NULL),
rawSrcInputsItemModel(NULL),
rawSrcAllItemModel(NULL),
mediaPlayerCurrent(-1),
mediaPlayer(NULL)
{
@@ -76,11 +79,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
lock = true;
int num_fsw = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions);
rawSwitchItemModel = new RawSwitchFilterItemModel(&generalSettings, model, model ? SpecialFunctionsContext : GlobalFunctionsContext);
rawSrcInputsItemModel = Helpers::getRawSourceItemModel(&generalSettings, model, POPULATE_NONE|POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS|POPULATE_SWITCHES);
rawSrcInputsItemModel->setParent(this);
rawSrcAllItemModel = Helpers::getRawSourceItemModel(&generalSettings, model, POPULATE_NONE|POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRY|POPULATE_TELEMETRYEXT|POPULATE_SCRIPT_OUTPUTS);
rawSrcAllItemModel->setParent(this);
setDataModels();
if (!firmware->getCapability(VoicesAsNumbers)) {
tracksSet = getFilesSet(getSoundsPath(generalSettings), QStringList() << "*.wav" << "*.WAV", firmware->getCapability(VoicesMaxLength));
@@ -251,6 +250,26 @@ CustomFunctionsPanel::~CustomFunctionsPanel()
{
}
void CustomFunctionsPanel::setDataModels()
{
if (rawSwitchItemModel)
rawSwitchItemModel->update();
else
rawSwitchItemModel = new RawSwitchFilterItemModel(&generalSettings, model, model ? SpecialFunctionsContext : GlobalFunctionsContext);
// The RawSource item models have to be reloaded on every update(). TODO: convert to filtered model like for RawSwitches
if (rawSrcInputsItemModel)
rawSrcInputsItemModel->deleteLater();
if (rawSrcAllItemModel)
rawSrcAllItemModel->deleteLater();
rawSrcInputsItemModel = Helpers::getRawSourceItemModel(&generalSettings, model, POPULATE_NONE|POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS|POPULATE_SWITCHES);
rawSrcInputsItemModel->setParent(this);
rawSrcAllItemModel = Helpers::getRawSourceItemModel(&generalSettings, model, POPULATE_NONE|POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRY|POPULATE_TELEMETRYEXT|POPULATE_SCRIPT_OUTPUTS);
rawSrcAllItemModel->setParent(this);
}
void CustomFunctionsPanel::onMediaPlayerStateChanged(QMediaPlayer::State state)
{
if (!lock) {
@@ -589,7 +608,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
void CustomFunctionsPanel::update()
{
rawSwitchItemModel->update();
setDataModels();
lock = true;
int num_fsw = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions);
@@ -60,6 +60,7 @@ class CustomFunctionsPanel : public GenericPanel
CustomFunctionData * functions;
private slots:
void setDataModels();
void customFunctionEdited();
void functionEdited();
void fsw_customContextMenuRequested(QPoint pos);
+13 -3
View File
@@ -24,12 +24,12 @@
HeliPanel::HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
ModelPanel(parent, model, generalSettings, firmware),
ui(new Ui::Heli)
ui(new Ui::Heli),
rawSourceItemModel(nullptr)
{
ui->setupUi(this);
rawSourceItemModel = Helpers::getRawSourceItemModel(&generalSettings, &model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
rawSourceItemModel->setParent(this);
setDataModels();
connect(ui->swashType, SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
connect(ui->swashRingVal, SIGNAL(editingFinished()), this, SLOT(edited()));
@@ -66,9 +66,19 @@ HeliPanel::~HeliPanel()
delete ui;
}
void HeliPanel::setDataModels()
{
if (rawSourceItemModel)
rawSourceItemModel->deleteLater();
rawSourceItemModel = Helpers::getRawSourceItemModel(&generalSettings, model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
rawSourceItemModel->setParent(this);
}
void HeliPanel::update()
{
lock = true;
setDataModels();
ui->swashType->setCurrentIndex(model->swashRingData.type);
ui->swashCollectiveSource->setModel(rawSourceItemModel);
+1
View File
@@ -37,6 +37,7 @@ class HeliPanel : public ModelPanel
void update();
private slots:
void setDataModels();
void edited();
private: