From 4bf5a93747dd1f9f28816194a234710862857570 Mon Sep 17 00:00:00 2001 From: elecpower Date: Sat, 24 Oct 2020 14:40:39 +1100 Subject: [PATCH] Reimplement LS update ui models on function changed from or to none --- companion/src/modeledit/logicalswitches.cpp | 28 ++++++++------------- companion/src/modeledit/logicalswitches.h | 1 - 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index ad440c177..cacd5c6fd 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -172,6 +172,7 @@ void LogicalSwitchesPanel::onFunctionChanged() if (model->logicalSw[i].func == newFunc) return; + unsigned oldFunc = model->logicalSw[i].func; CSFunctionFamily oldFuncFamily = model->logicalSw[i].getFunctionFamily(); model->logicalSw[i].func = newFunc; CSFunctionFamily newFuncFamily = model->logicalSw[i].getFunctionFamily(); @@ -189,6 +190,10 @@ void LogicalSwitchesPanel::onFunctionChanged() } updateLine(i); + + if (oldFunc == LS_FN_OFF || newFunc == LS_FN_OFF) + updateItemModels(); + emit modified(); } } @@ -487,7 +492,7 @@ void LogicalSwitchesPanel::cmPaste() if (hasClipboardData(&data)) { memcpy(&model->logicalSw[selectedIndex], data.constData(), sizeof(LogicalSwitchData)); updateLine(selectedIndex); - updateCBLists(); + updateItemModels(); emit modified(); } } @@ -502,7 +507,7 @@ void LogicalSwitchesPanel::cmDelete() model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, -1); update(); - updateCBLists(); + updateItemModels(); emit modified(); } @@ -592,7 +597,7 @@ void LogicalSwitchesPanel::cmClear(bool prompt) model->logicalSw[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_CLEAR, selectedIndex); updateLine(selectedIndex); - updateCBLists(); + updateItemModels(); emit modified(); } @@ -606,7 +611,7 @@ void LogicalSwitchesPanel::cmClearAll() model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_CLEAR, i); } update(); - updateCBLists(); + updateItemModels(); emit modified(); } @@ -616,7 +621,7 @@ void LogicalSwitchesPanel::cmInsert() model->logicalSw[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1); update(); - updateCBLists(); + updateItemModels(); emit modified(); } @@ -631,22 +636,11 @@ void LogicalSwitchesPanel::swapData(int idx1, int idx2) model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); updateLine(idx1); updateLine(idx2); - updateCBLists(); + updateItemModels(); emit modified(); } } -void LogicalSwitchesPanel::updateCBLists() -{ - // We need to update the data models as (de)activating the current LS needs to be reflected in all LS source and switch lists - // However triggering after the input or mix edit dialogs displayed causes the application to crash - // So this workaround gives time for other events to be processed before refreshing - // Not sure if this an OS related issue or a QT bug in QT 5.7 (and higher?) - // The delay is abitary - //QTimer::singleShot(1000, this, &LogicalSwitchesPanel::updateItemModels); - updateItemModels(); -} - void LogicalSwitchesPanel::updateItemModels() { lock = true; diff --git a/companion/src/modeledit/logicalswitches.h b/companion/src/modeledit/logicalswitches.h index 61837a372..87a360408 100644 --- a/companion/src/modeledit/logicalswitches.h +++ b/companion/src/modeledit/logicalswitches.h @@ -88,7 +88,6 @@ class LogicalSwitchesPanel : public ModelPanel bool moveDownAllowed() const; bool moveUpAllowed() const; int modelsUpdateCnt; - void updateCBLists(); void updateItemModels(); };