[Companion] Sensor switches support added

+ some refactoring to hide irrelevant switches in the combobox

More refactoring to come:
 - have only one SwitchModel per model instead of one per tab
 - only do the update work if something has changed
This commit is contained in:
Bertrand Songis
2017-07-30 12:12:27 +02:00
parent b814f997f8
commit b55070f939
18 changed files with 290 additions and 111 deletions
+4 -2
View File
@@ -19,6 +19,7 @@
*/
#include "customfunctions.h"
#include "switchitemmodel.h"
#include "helpers.h"
#include "appdata.h"
@@ -73,8 +74,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
lock = true;
int num_fsw = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions);
rawSwitchItemModel = Helpers::getRawSwitchItemModel(&generalSettings, model ? Helpers::SpecialFunctionsContext : Helpers::GlobalFunctionsContext);
rawSwitchItemModel->setParent(this);
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);
@@ -584,6 +584,8 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
void CustomFunctionsPanel::update()
{
rawSwitchItemModel->update();
lock = true;
int num_fsw = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions);
for (int i=0; i<num_fsw; i++) {