From 05ca719522877bc5623afb261655aa97cf4f940f Mon Sep 17 00:00:00 2001 From: Neil Horne Date: Mon, 16 Jan 2017 01:27:23 +1100 Subject: [PATCH] Port #4189 to next (#4235) Add data modification for su trim, min and max --- companion/src/helpers.cpp | 8 ++++++-- companion/src/helpers.h | 4 +++- companion/src/modeledit/channels.cpp | 10 +++++----- companion/src/modeledit/channels.h | 2 +- companion/src/shared/genericpanel.h | 1 + 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 0d52756fd..d73eb0d8b 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -127,7 +127,7 @@ void populatePhasesCB(QComboBox *b, int value) b->setCurrentIndex(value + GetCurrentFirmware()->getCapability(FlightModes)); } -GVarGroup::GVarGroup(QCheckBox * weightGV, QAbstractSpinBox * weightSB, QComboBox * weightCB, int & weight, const ModelData & model, const int deflt, const int mini, const int maxi, const double step, bool allowGvars): +GVarGroup::GVarGroup(QCheckBox * weightGV, QAbstractSpinBox * weightSB, QComboBox * weightCB, int & weight, const ModelData & model, const int deflt, const int mini, const int maxi, const double step, bool allowGvars, ModelPanel * panel): QObject(), weightGV(weightGV), weightSB(weightSB), @@ -136,7 +136,8 @@ GVarGroup::GVarGroup(QCheckBox * weightGV, QAbstractSpinBox * weightSB, QComboBo weightCB(weightCB), weight(weight), step(step), - lock(true) + lock(true), + panel(panel) { if (allowGvars && GetCurrentFirmware()->getCapability(Gvars)) { populateGVCB(*weightCB, weight, model); @@ -200,6 +201,9 @@ void GVarGroup::valuesChanged() weight = sb->value(); else weight = round(dsb->value()/step); + if (panel) + emit panel->modified(); + } } diff --git a/companion/src/helpers.h b/companion/src/helpers.h index 9b2647b9e..2db44e334 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -27,6 +27,7 @@ #include #include #include "eeprominterface.h" +#include "modeledit/modeledit.h" extern const QColor colors[CPN_MAX_CURVES]; @@ -66,7 +67,7 @@ class GVarGroup: public QObject { Q_OBJECT public: - GVarGroup(QCheckBox * weightGV, QAbstractSpinBox * weightSB, QComboBox * weightCB, int & weight, const ModelData & model, const int deflt, const int mini, const int maxi, const double step=1.0, bool allowGVars=true); + GVarGroup(QCheckBox * weightGV, QAbstractSpinBox * weightSB, QComboBox * weightCB, int & weight, const ModelData & model, const int deflt, const int mini, const int maxi, const double step=1.0, bool allowGVars=true, ModelPanel * panel=NULL); protected slots: void gvarCBChanged(int); @@ -81,6 +82,7 @@ class GVarGroup: public QObject { int & weight; double step; bool lock; + ModelPanel * panel; }; #define HIDE_DIFF 0x01 diff --git a/companion/src/modeledit/channels.cpp b/companion/src/modeledit/channels.cpp index 7cb1e8f8f..e96c02080 100644 --- a/companion/src/modeledit/channels.cpp +++ b/companion/src/modeledit/channels.cpp @@ -21,7 +21,7 @@ #include "channels.h" #include "helpers.h" -LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout * tableLayout, int row, int col, int & value, const ModelData & model, int min, int max, int deflt): +LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout * tableLayout, int row, int col, int & value, const ModelData & model, int min, int max, int deflt, ModelPanel * panel): firmware(firmware), spinbox(new QDoubleSpinBox()), value(value), @@ -64,7 +64,7 @@ LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout * tableLayout, int row horizontalLayout->addWidget(cb); horizontalLayout->addWidget(spinbox); tableLayout->addLayout(row, col, horizontalLayout); - gvarGroup = new GVarGroup(gv, spinbox, cb, value, model, deflt, min, max, displayStep, allowGVars); + gvarGroup = new GVarGroup(gv, spinbox, cb, value, model, deflt, min, max, displayStep, allowGVars, panel); } LimitsGroup::~LimitsGroup() @@ -133,13 +133,13 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera } // Channel offset - limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].offset, model, -1000, 1000, 0); + limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].offset, model, -1000, 1000, 0, this); // Channel min - limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].min, model, -model.getChannelsMax()*10, 0, -1000); + limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].min, model, -model.getChannelsMax()*10, 0, -1000, this); // Channel max - limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].max, model, 0, model.getChannelsMax()*10, 1000); + limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].max, model, 0, model.getChannelsMax()*10, 1000, this); // Channel inversion QComboBox * invCB = new QComboBox(this); diff --git a/companion/src/modeledit/channels.h b/companion/src/modeledit/channels.h index 80df22e6a..defd0cbbb 100644 --- a/companion/src/modeledit/channels.h +++ b/companion/src/modeledit/channels.h @@ -29,7 +29,7 @@ class GVarGroup; class LimitsGroup { public: - LimitsGroup(Firmware * firmware, TableLayout *tableLayout, int row, int col, int & value, const ModelData & model, int min, int max, int deflt); + LimitsGroup(Firmware * firmware, TableLayout *tableLayout, int row, int col, int & value, const ModelData & model, int min, int max, int deflt, ModelPanel * panel=NULL); ~LimitsGroup(); void updateMinMax(int max); diff --git a/companion/src/shared/genericpanel.h b/companion/src/shared/genericpanel.h index ceb720f53..36402917b 100644 --- a/companion/src/shared/genericpanel.h +++ b/companion/src/shared/genericpanel.h @@ -38,6 +38,7 @@ class GenericPanel : public QWidget friend class AutoCheckBox; friend class AutoHexSpinBox; friend class AutoLineEdit; + friend class GVarGroup; public: GenericPanel(QWidget *parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware);