diff --git a/companion/src/modeledit/expodialog.cpp b/companion/src/modeledit/expodialog.cpp index 1df0ffaf0..fc336bfb9 100644 --- a/companion/src/modeledit/expodialog.cpp +++ b/companion/src/modeledit/expodialog.cpp @@ -24,8 +24,8 @@ #include "helpers.h" ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, GeneralSettings & generalSettings, - Firmware * firmware, QString & inputName, RawSourceItemModel * rawSourceItemModel, - RawSwitchItemModel * rawSwitchItemModel) : + Firmware * firmware, QString & inputName, RawItemFilteredModel * rawSourceModel, + RawItemFilteredModel * rawSwitchModel) : QDialog(parent), ui(new Ui::ExpoDialog), model(model), @@ -37,8 +37,6 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G lock(false) { ui->setupUi(this); - rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, (RawSource::InputSourceGroups & ~RawSource::InputsGroup) | RawSource::TelemGroup, this); - rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this); QLabel * lb_fp[CPN_MAX_FLIGHT_MODES] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 }; QCheckBox * tmp[CPN_MAX_FLIGHT_MODES] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; diff --git a/companion/src/modeledit/expodialog.h b/companion/src/modeledit/expodialog.h index 1a3cc26af..8bd0f52e4 100644 --- a/companion/src/modeledit/expodialog.h +++ b/companion/src/modeledit/expodialog.h @@ -27,8 +27,6 @@ class GVarGroup; class CurveGroup; -class RawSourceItemModel; -class RawSwitchItemModel; class RawItemFilteredModel; namespace Ui { @@ -39,8 +37,8 @@ class ExpoDialog : public QDialog { Q_OBJECT public: ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expodata, GeneralSettings & generalSettings, - Firmware * firmware, QString & inputName, RawSourceItemModel * rawSourceItemModel, - RawSwitchItemModel * rawSwitchItemModel); + Firmware * firmware, QString & inputName, RawItemFilteredModel * rawSourceItemModel, + RawItemFilteredModel * rawSwitchItemModel); ~ExpoDialog(); protected: @@ -67,8 +65,6 @@ class ExpoDialog : public QDialog { ModelPrinter modelPrinter; bool lock; QCheckBox * cb_fp[CPN_MAX_FLIGHT_MODES]; - RawItemFilteredModel * rawSourceModel; - RawItemFilteredModel * rawSwitchModel; }; #endif // _EXPODIALOG_H_ diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp index 624f1fdbd..ebdd5ecf1 100644 --- a/companion/src/modeledit/inputs.cpp +++ b/companion/src/modeledit/inputs.cpp @@ -21,15 +21,22 @@ #include "inputs.h" #include "expodialog.h" #include "helpers.h" +#include "rawitemfilteredmodel.h" InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel): ModelPanel(parent, model, generalSettings, firmware), expoInserted(false), - modelPrinter(firmware, generalSettings, model), - rawSourceItemModel(rawSourceItemModel), - rawSwitchItemModel(rawSwitchItemModel) + modelPrinter(firmware, generalSettings, model) { + rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, (RawSource::InputSourceGroups & ~RawSource::InputsGroup), this); + connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &InputsPanel::onModelDataAboutToBeUpdated); + connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &InputsPanel::onModelDataUpdateComplete); + + rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this); + connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &InputsPanel::onModelDataAboutToBeUpdated); + connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &InputsPanel::onModelDataUpdateComplete); + inputsCount = firmware->getCapability(VirtualInputs); if (inputsCount == 0) inputsCount = CPN_MAX_STICKS; @@ -68,6 +75,8 @@ InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & g InputsPanel::~InputsPanel() { + delete rawSourceModel; + delete rawSwitchModel; } void InputsPanel::update() @@ -183,7 +192,7 @@ void InputsPanel::gm_openExpo(int index) if (firmware->getCapability(VirtualInputs)) inputName = model->inputNames[ed.chn]; - ExpoDialog *g = new ExpoDialog(this, *model, &ed, generalSettings, firmware, inputName, rawSourceItemModel, rawSwitchItemModel); + ExpoDialog *g = new ExpoDialog(this, *model, &ed, generalSettings, firmware, inputName, rawSourceModel, rawSwitchModel); if (g->exec()) { model->expoData[index] = ed; if (firmware->getCapability(VirtualInputs)) @@ -709,3 +718,13 @@ int InputsPanel::getInputIndexFromSelected() } return idx; } + +void InputsPanel::onModelDataAboutToBeUpdated() +{ + lock = true; +} + +void InputsPanel::onModelDataUpdateComplete() +{ + update(); +} diff --git a/companion/src/modeledit/inputs.h b/companion/src/modeledit/inputs.h index 0922305ce..5a31592b7 100644 --- a/companion/src/modeledit/inputs.h +++ b/companion/src/modeledit/inputs.h @@ -24,7 +24,10 @@ #include "modeledit.h" #include "mixerslistwidget.h" #include "modelprinter.h" -#include "rawitemdatamodels.h" + +class RawSourceItemModel; +class RawSwitchItemModel; +class RawItemFilteredModel; constexpr char MIMETYPE_EXPO[] = "application/x-companion-expo"; @@ -61,6 +64,8 @@ class InputsPanel : public ModelPanel void cmInputInsert(); void cmInputMoveDown(); void cmInputMoveUp(); + void onModelDataAboutToBeUpdated(); + void onModelDataUpdateComplete(); signals: void updateDataModels(); @@ -72,8 +77,8 @@ class InputsPanel : public ModelPanel ModelPrinter modelPrinter; int selectedIdx; int inputIdx; - RawSourceItemModel *rawSourceItemModel; - RawSwitchItemModel *rawSwitchItemModel; + RawItemFilteredModel *rawSourceModel; + RawItemFilteredModel *rawSwitchModel; int getExpoIndex(unsigned int dch); bool gm_insertExpo(int idx);