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:
committed by
Bertrand Songis
parent
9796654816
commit
3af2b090e5
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user