chore(cpn): move global variables from flight/drive modes tab to own tab (#6624)
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
#define CPN_MAX_CURVES 32
|
||||
#define CPN_MAX_POINTS 17
|
||||
#define CPN_MAX_GVARS 15 // 0, 9, 15
|
||||
#define CPN_MAX_ENCODERS 2 // rotary encoders
|
||||
#define CPN_MAX_CHNOUT 32 // number of real output channels
|
||||
#define CPN_MAX_LOGICAL_SWITCHES 64 // number of custom switches
|
||||
#define CPN_MAX_SPECIAL_FUNCTIONS 64 // number of functions assigned to switches
|
||||
|
||||
@@ -1182,7 +1182,7 @@ bool Boards::isSwitchFunc(int index, Board::Type board)
|
||||
return getBoardJson(board)->isSwitchFunc(index);
|
||||
}
|
||||
|
||||
QString Boards::getRadioTypeString(Board::Type board)
|
||||
QString Boards::getRadioModeString(Board::Type board)
|
||||
{
|
||||
return getCapability(board == Board::BOARD_UNKNOWN ? getCurrentBoard() : board, Board::Air) ? tr("Flight") : tr("Drive");
|
||||
}
|
||||
|
||||
@@ -465,7 +465,7 @@ class Boards
|
||||
static AbstractStaticItemModel * flexTypeItemModel();
|
||||
|
||||
static std::string getLegacyAnalogMappedInputTag(const char * legacytag, Board::Type board = Board::BOARD_UNKNOWN);
|
||||
static QString getRadioTypeString(Board::Type board = Board::BOARD_UNKNOWN);
|
||||
static QString getRadioModeString(Board::Type board = Board::BOARD_UNKNOWN);
|
||||
static bool isAir(Board::Type board = Board::BOARD_UNKNOWN);
|
||||
static bool isSurface(Board::Type board = Board::BOARD_UNKNOWN);
|
||||
|
||||
|
||||
@@ -69,7 +69,6 @@ enum Capability {
|
||||
CustomAndSwitches,
|
||||
HasNegAndSwitches,
|
||||
LogicalSwitchesExt,
|
||||
RotaryEncoders,
|
||||
Outputs,
|
||||
ChannelsName,
|
||||
ExtraInputs,
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "flightmodedata.h"
|
||||
#include "radiodata.h"
|
||||
#include "radiodataconversionstate.h"
|
||||
#include "compounditemmodels.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
void FlightModeData::convert(RadioDataConversionState & cstate)
|
||||
{
|
||||
@@ -33,35 +35,44 @@ void FlightModeData::convert(RadioDataConversionState & cstate)
|
||||
void FlightModeData::clear(const int phaseIdx)
|
||||
{
|
||||
memset(reinterpret_cast<void *>(this), 0, sizeof(FlightModeData));
|
||||
|
||||
for (int i = 0; i < CPN_MAX_GVARS; i++) {
|
||||
gvars[i] = linkedGVarFlightModeZero(phaseIdx);
|
||||
}
|
||||
for (int i = 0; i < CPN_MAX_ENCODERS; i++) {
|
||||
rotaryEncoders[i] = linkedREncFlightModeZero(phaseIdx);
|
||||
}
|
||||
}
|
||||
|
||||
QString FlightModeData::nameToString(int phaseIdx) const
|
||||
{
|
||||
return RadioData::getElementName(Boards::isAir() ? tr("FM") : tr("DM"), phaseIdx, name); // names are zero-based, FM0, FM1, etc
|
||||
return RadioData::getElementName(tr("%1M").arg(modeAbbrev()), phaseIdx, name); // names are zero-based, FM0, FM1, etc
|
||||
}
|
||||
|
||||
// static
|
||||
QString FlightModeData::modeAbbrev()
|
||||
{
|
||||
return Boards::isAir() ? tr("F") : tr("D");
|
||||
}
|
||||
|
||||
// static
|
||||
QString FlightModeData::modeName()
|
||||
{
|
||||
return Boards::isAir() ? tr("Flight") : tr("Drive");
|
||||
}
|
||||
|
||||
bool FlightModeData::isEmpty(int phaseIdx) const
|
||||
{
|
||||
if (name[0] != '\0' || swtch.isSet() || fadeIn != 0 || fadeOut != 0)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < CPN_MAX_TRIMS; i++) {
|
||||
if (trim[i] != 0 || trimRef[i] != 0 || trimMode[i] != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < CPN_MAX_GVARS; i++) {
|
||||
if (!isGVarEmpty(phaseIdx, i))
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < CPN_MAX_ENCODERS; i++) {
|
||||
if (!isREncEmpty(phaseIdx, i))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -69,13 +80,7 @@ bool FlightModeData::isGVarEmpty(int phaseIdx, int gvIdx) const
|
||||
{
|
||||
if ((phaseIdx == 0 && gvars[gvIdx] == 0) || (phaseIdx != 0 && gvars[gvIdx] == linkedGVarFlightModeZero(phaseIdx)))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FlightModeData::isREncEmpty(int phaseIdx, int reIdx) const
|
||||
{
|
||||
if ((phaseIdx == 0 && rotaryEncoders[reIdx] == 0) || (phaseIdx != 0 && rotaryEncoders[reIdx] == linkedREncFlightModeZero(phaseIdx)))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -83,6 +88,7 @@ int FlightModeData::linkedFlightModeZero(int phaseIdx, int maxOwnValue) const
|
||||
{
|
||||
if (phaseIdx == 0)
|
||||
return 0;
|
||||
|
||||
return maxOwnValue + 1;
|
||||
}
|
||||
|
||||
@@ -91,7 +97,19 @@ int FlightModeData::linkedGVarFlightModeZero(int phaseIdx) const
|
||||
return linkedFlightModeZero(phaseIdx, GVAR_MAX_VALUE);
|
||||
}
|
||||
|
||||
int FlightModeData::linkedREncFlightModeZero(int phaseIdx) const
|
||||
// static
|
||||
AbstractStaticItemModel * FlightModeData::gvarModesItemModel(int excludeMode)
|
||||
{
|
||||
return linkedFlightModeZero(phaseIdx, RENC_MAX_VALUE);
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName(AIM_FLIGHTMODEDATA_GVARFM);
|
||||
int modes = getCurrentFirmware()->getCapability(FlightModes);
|
||||
|
||||
for (int i = 0; i < modes; i++) {
|
||||
if (i != excludeMode)
|
||||
mdl->appendToItemList(tr("%1M%2").arg(modeAbbrev()).arg(i),
|
||||
GVAR_MAX_VALUE + 1 + i - (i > excludeMode ? 1 : 0));
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
@@ -25,12 +25,15 @@
|
||||
#include "rawswitch.h"
|
||||
|
||||
#include <QtCore>
|
||||
#include <QComboBox>
|
||||
|
||||
class RadioDataConversionState;
|
||||
class AbstractStaticItemModel;
|
||||
class Firmware;
|
||||
|
||||
#define FLIGHTMODE_NAME_LEN 10
|
||||
#define RENC_MAX_VALUE 1024
|
||||
#define RENC_MIN_VALUE -RENC_MAX_VALUE
|
||||
|
||||
constexpr char AIM_FLIGHTMODEDATA_GVARFM[] {"flightmodedata.gvarfm"};
|
||||
|
||||
class FlightModeData {
|
||||
Q_DECLARE_TR_FUNCTIONS(FlightModeData)
|
||||
@@ -45,7 +48,6 @@ class FlightModeData {
|
||||
char name[FLIGHTMODE_NAME_LEN + 1];
|
||||
unsigned int fadeIn;
|
||||
unsigned int fadeOut;
|
||||
int rotaryEncoders[CPN_MAX_ENCODERS];
|
||||
int gvars[CPN_MAX_GVARS];
|
||||
|
||||
void convert(RadioDataConversionState & cstate);
|
||||
@@ -53,8 +55,9 @@ class FlightModeData {
|
||||
bool isEmpty(int phaseIdx) const;
|
||||
QString nameToString(int phaseIdx) const;
|
||||
bool isGVarEmpty(int phaseIdx, int gvIdx) const;
|
||||
bool isREncEmpty(int phaseIdx, int reIdx) const;
|
||||
int linkedFlightModeZero(int phaseIdx, int maxOwnValue) const;
|
||||
int linkedGVarFlightModeZero(int phaseIdx) const;
|
||||
int linkedREncFlightModeZero(int phaseIdx) const;
|
||||
static AbstractStaticItemModel * gvarModesItemModel(int excludeMode);
|
||||
static QString modeAbbrev();
|
||||
static QString modeName();
|
||||
};
|
||||
|
||||
@@ -20,12 +20,17 @@
|
||||
*/
|
||||
|
||||
#include "gvardata.h"
|
||||
|
||||
#include "radiodata.h"
|
||||
#include "compounditemmodels.h"
|
||||
|
||||
QString GVarData::unitToString() const
|
||||
{
|
||||
switch (unit) {
|
||||
return unitToString(unit);
|
||||
}
|
||||
|
||||
QString GVarData::unitToString(int val)
|
||||
{
|
||||
switch (val) {
|
||||
case GVAR_UNIT_NUMBER:
|
||||
return tr("");
|
||||
case GVAR_UNIT_PERCENT:
|
||||
@@ -37,7 +42,12 @@ QString GVarData::unitToString() const
|
||||
|
||||
QString GVarData::precToString() const
|
||||
{
|
||||
switch (prec) {
|
||||
return precToString(prec);
|
||||
}
|
||||
|
||||
QString GVarData::precToString(int val)
|
||||
{
|
||||
switch (val) {
|
||||
case GVAR_PREC_MUL10:
|
||||
return tr("0._");
|
||||
case GVAR_PREC_MUL1:
|
||||
@@ -96,3 +106,44 @@ bool GVarData::isEmpty() const
|
||||
{
|
||||
return (name[0] == '\0' && min == 0 && max == 0 && (!popup) && prec == 0 && unit == 0);
|
||||
}
|
||||
|
||||
AbstractStaticItemModel * GVarData::precItemModel()
|
||||
{
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName(AIM_GVARDATA_UNIT);
|
||||
|
||||
for (int i = 0; i < GVAR_PREC_COUNT; i++) {
|
||||
mdl->appendToItemList(precToString(i), i);
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
AbstractStaticItemModel * GVarData::unitItemModel()
|
||||
{
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName(AIM_GVARDATA_UNIT);
|
||||
|
||||
for (int i = 0; i < GVAR_UNIT_COUNT; i++) {
|
||||
mdl->appendToItemList(unitToString(i), i);
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const GVarData &data) {
|
||||
QByteArray name(data.name);
|
||||
name.resize(sizeof(data.name));
|
||||
out << name << data.min << data.max << data.prec << data.unit;
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, GVarData &data) {
|
||||
QByteArray name;
|
||||
name.resize(sizeof(data.name));
|
||||
in >> name >> data.min >> data.max >> data.prec >> data.unit;
|
||||
memcpy(data.name, name.constData(), sizeof(data.name));
|
||||
return in;
|
||||
}
|
||||
|
||||
@@ -19,15 +19,19 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GVARDATA_H
|
||||
#define GVARDATA_H
|
||||
#pragma once
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
constexpr char AIM_GVARDATA_PREC[] {"gvardata.prec"};
|
||||
constexpr char AIM_GVARDATA_UNIT[] {"gvardata.unit"};
|
||||
|
||||
#define GVAR_NAME_LEN 3
|
||||
#define GVAR_MAX_VALUE 1024
|
||||
#define GVAR_MIN_VALUE -GVAR_MAX_VALUE
|
||||
|
||||
class AbstractStaticItemModel;
|
||||
|
||||
class GVarData {
|
||||
Q_DECLARE_TR_FUNCTIONS(GVarData)
|
||||
|
||||
@@ -36,12 +40,14 @@ class GVarData {
|
||||
|
||||
enum {
|
||||
GVAR_UNIT_NUMBER,
|
||||
GVAR_UNIT_PERCENT
|
||||
GVAR_UNIT_PERCENT,
|
||||
GVAR_UNIT_COUNT
|
||||
};
|
||||
|
||||
enum {
|
||||
GVAR_PREC_MUL10,
|
||||
GVAR_PREC_MUL1
|
||||
GVAR_PREC_MUL1,
|
||||
GVAR_PREC_COUNT
|
||||
};
|
||||
|
||||
char name[GVAR_NAME_LEN + 1];
|
||||
@@ -53,7 +59,9 @@ class GVarData {
|
||||
|
||||
void clear() {memset(this, 0, sizeof(GVarData)); }
|
||||
QString unitToString() const;
|
||||
static QString unitToString(int val);
|
||||
QString precToString() const;
|
||||
static QString precToString(int val);
|
||||
QString nameToString(int index) const;
|
||||
int multiplierSet();
|
||||
float multiplierGet() const;
|
||||
@@ -64,7 +72,9 @@ class GVarData {
|
||||
float getMinPrec() const;
|
||||
float getMaxPrec() const;
|
||||
bool isEmpty() const;
|
||||
static AbstractStaticItemModel * unitItemModel();
|
||||
static AbstractStaticItemModel * precItemModel();
|
||||
};
|
||||
|
||||
|
||||
#endif // GVARDATA_H
|
||||
QDataStream &operator<<(QDataStream &out, const GVarData &obj);
|
||||
QDataStream &operator>>(QDataStream &in, GVarData &obj);
|
||||
|
||||
@@ -304,39 +304,6 @@ int ModelData::getGVarValue(int phaseIdx, int gvarIdx)
|
||||
return flightModeData[0].gvars[gvarIdx]; // circular linked so return FM0 value
|
||||
}
|
||||
|
||||
bool ModelData::isREncLinked(int phaseIdx, int reIdx)
|
||||
{
|
||||
return flightModeData[phaseIdx].rotaryEncoders[reIdx] > RENC_MAX_VALUE;
|
||||
}
|
||||
|
||||
bool ModelData::isREncLinkedCircular(int phaseIdx, int reIdx)
|
||||
{
|
||||
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
|
||||
int val = flightModeData[phaseIdx].rotaryEncoders[reIdx];
|
||||
if (phaseIdx == 0 || val <= RENC_MAX_VALUE)
|
||||
return false;
|
||||
int nextPhase = val - (RENC_MAX_VALUE + 1);
|
||||
if (nextPhase >= phaseIdx)
|
||||
nextPhase += 1;
|
||||
phaseIdx = nextPhase;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int ModelData::getREncValue(int phaseIdx, int reIdx)
|
||||
{
|
||||
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
|
||||
int val = flightModeData[phaseIdx].rotaryEncoders[reIdx];
|
||||
if (phaseIdx == 0 || val <= RENC_MAX_VALUE)
|
||||
return val;
|
||||
int nextPhase = val - (RENC_MAX_VALUE + 1);
|
||||
if (nextPhase >= phaseIdx)
|
||||
nextPhase += 1;
|
||||
phaseIdx = nextPhase;
|
||||
}
|
||||
return flightModeData[0].rotaryEncoders[reIdx]; // circular linked so return FM0 value
|
||||
}
|
||||
|
||||
void ModelData::setTrimValue(int phaseIdx, int trimIdx, int value)
|
||||
{
|
||||
for (uint8_t i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
|
||||
@@ -1346,18 +1313,6 @@ void ModelData::setGVarFlightModeIndexToValue(const int phaseIdx, const int gvar
|
||||
flightModeData[phaseIdx].gvars[gvarIdx] = linkedFlightModeIndexToValue(phaseIdx, useFmIdx, GVAR_MAX_VALUE);
|
||||
}
|
||||
|
||||
int ModelData::getREncFlightModeIndex(const int phaseIdx, const int reIdx)
|
||||
{
|
||||
if (!isREncLinked(phaseIdx, reIdx))
|
||||
return -1;
|
||||
return (linkedFlightModeValueToIndex(phaseIdx, flightModeData[phaseIdx].rotaryEncoders[reIdx], RENC_MAX_VALUE));
|
||||
}
|
||||
|
||||
void ModelData::setREncFlightModeIndexToValue(const int phaseIdx, const int reIdx, const int useFmIdx)
|
||||
{
|
||||
flightModeData[phaseIdx].rotaryEncoders[reIdx] = linkedFlightModeIndexToValue(phaseIdx, useFmIdx, RENC_MAX_VALUE);
|
||||
}
|
||||
|
||||
bool ModelData::isExpoParent(const int index)
|
||||
{
|
||||
const ExpoData &ed = expoData[index];
|
||||
@@ -1494,7 +1449,7 @@ void ModelData::updateResetParam(CustomFunctionData * cfd)
|
||||
idxAdj = -2; // reverse earlier offset required for rawsource
|
||||
break;
|
||||
case REF_UPD_TYPE_SENSOR:
|
||||
idxAdj = 5/*3 Timers + Flight + Telemetery*/ + firmware->getCapability(RotaryEncoders);
|
||||
idxAdj = 5/*3 Timers + Flight + Telemetery*/;
|
||||
if (cfd->param < idxAdj || cfd->param > (idxAdj + firmware->getCapability(Sensors)))
|
||||
return;
|
||||
break;
|
||||
@@ -2051,3 +2006,123 @@ QString ModelData::getChecklistFilename() const
|
||||
{
|
||||
return QString(name).replace(" ", "_").append(".txt").toLower();
|
||||
}
|
||||
|
||||
void ModelData::gvarClear(const int index, bool updateRefs)
|
||||
{
|
||||
gvarData[index].clear();
|
||||
|
||||
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
|
||||
FlightModeData &fm = flightModeData[i];
|
||||
fm.gvars[index] = fm.linkedGVarFlightModeZero(i);
|
||||
}
|
||||
|
||||
if (updateRefs) {
|
||||
updateAllReferences(ModelData::REF_UPD_TYPE_GLOBAL_VARIABLE,
|
||||
ModelData::REF_UPD_ACT_CLEAR, index);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelData::gvarSetMax(const int index, const float value)
|
||||
{
|
||||
gvarData[index].setMax(value);
|
||||
|
||||
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
|
||||
if (!isGVarLinked(i, index)) {
|
||||
if (flightModeData[i].gvars[index] > gvarData[index].getMax()) {
|
||||
flightModeData[i].gvars[index] = gvarData[index].getMax();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ModelData::gvarSetMin(const int index, const float value)
|
||||
{
|
||||
gvarData[index].setMin(value);
|
||||
|
||||
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
|
||||
if (!isGVarLinked(i, index)) {
|
||||
if (flightModeData[i].gvars[index] < gvarData[index].getMin()) {
|
||||
flightModeData[i].gvars[index] = gvarData[index].getMin();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ModelData::gvarSwap(const int index1, const int index2)
|
||||
{
|
||||
if (index1 != index2) {
|
||||
GVarData gvtmp = gvarData[index2];
|
||||
GVarData *gv1 = &gvarData[index1];
|
||||
GVarData *gv2 = &gvarData[index2];
|
||||
memcpy(gv2, gv1, sizeof(GVarData));
|
||||
memcpy(gv1, &gvtmp, sizeof(GVarData));
|
||||
|
||||
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
|
||||
FlightModeData &fm = flightModeData[i];
|
||||
int gvar = fm.gvars[index2];
|
||||
fm.gvars[index2] = fm.gvars[index1];
|
||||
fm.gvars[index1] = gvar;
|
||||
}
|
||||
|
||||
updateAllReferences(ModelData::REF_UPD_TYPE_GLOBAL_VARIABLE,
|
||||
ModelData::REF_UPD_ACT_SWAP, index1, index2);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelData::gvarDelete(const int index)
|
||||
{
|
||||
memmove(&gvarData[index], &gvarData[index + 1],
|
||||
(CPN_MAX_GVARS - (index + 1)) * sizeof(GVarData));
|
||||
gvarData[CPN_MAX_GVARS - 1].clear();
|
||||
|
||||
for (int j = 0; j < CPN_MAX_FLIGHT_MODES; j++) {
|
||||
for (int i = index; i < (CPN_MAX_GVARS - 1); i++) {
|
||||
flightModeData[j].gvars[i] = flightModeData[j].gvars[i + 1];
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < CPN_MAX_FLIGHT_MODES; j++) {
|
||||
flightModeData[j].gvars[CPN_MAX_GVARS - 1] = flightModeData[j].linkedGVarFlightModeZero(j);
|
||||
}
|
||||
|
||||
updateAllReferences(ModelData::REF_UPD_TYPE_GLOBAL_VARIABLE,
|
||||
ModelData::REF_UPD_ACT_SHIFT, index, 0, -1);
|
||||
}
|
||||
|
||||
void ModelData::gvarInsert(const int index)
|
||||
{
|
||||
memmove(&gvarData[index + 1], &gvarData[index],
|
||||
(CPN_MAX_GVARS - (index + 1)) * sizeof(GVarData));
|
||||
gvarData[index].clear();
|
||||
|
||||
for (int j = 0; j < CPN_MAX_FLIGHT_MODES; j++) {
|
||||
for (int i = (CPN_MAX_GVARS - 1); i > index; i--) {
|
||||
flightModeData[j].gvars[i] = flightModeData[j].gvars[i - 1];
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < CPN_MAX_FLIGHT_MODES; j++) {
|
||||
flightModeData[j].gvars[index] = flightModeData[j].linkedGVarFlightModeZero(j);
|
||||
}
|
||||
|
||||
updateAllReferences(ModelData::REF_UPD_TYPE_GLOBAL_VARIABLE,
|
||||
ModelData::REF_UPD_ACT_SHIFT, index, 0, 1);
|
||||
}
|
||||
|
||||
bool ModelData::gvarInsertAllowed(const int index)
|
||||
{
|
||||
bool ret = true;
|
||||
int gvars = getCurrentFirmware()->getCapability(Gvars);
|
||||
|
||||
if (index == (gvars - 1) || !gvarData[gvars - 1].isEmpty())
|
||||
ret = false;
|
||||
|
||||
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
|
||||
if (flightModeData[i].gvars[gvars - 1] !=
|
||||
flightModeData[i].linkedGVarFlightModeZero(i))
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
@@ -262,12 +262,13 @@ class ModelData {
|
||||
float getGVarValuePrec(int phaseIdx, int gvarIdx);
|
||||
int getGVarFlightModeIndex(const int phaseIdx, const int gvarIdx);
|
||||
void setGVarFlightModeIndexToValue(const int phaseIdx, const int gvarIdx, const int useFmIdx);
|
||||
|
||||
bool isREncLinked(int phaseIdx, int reIdx);
|
||||
bool isREncLinkedCircular(int phaseIdx, int reIdx);
|
||||
int getREncValue(int phaseIdx, int reIdx);
|
||||
int getREncFlightModeIndex(const int phaseIdx, const int reIdx);
|
||||
void setREncFlightModeIndexToValue(const int phaseIdx, const int reIdx, const int useFmIdx);
|
||||
void gvarClear(const int index, bool updateRefs = true);
|
||||
void gvarSetMax(const int index, const float value);
|
||||
void gvarSetMin(const int index, const float value);
|
||||
void gvarSwap(const int index1, const int index2);
|
||||
void gvarDelete(const int index);
|
||||
void gvarInsert(const int index);
|
||||
bool gvarInsertAllowed(const int index);
|
||||
|
||||
ModelData removeGlobalVars();
|
||||
|
||||
|
||||
@@ -138,8 +138,6 @@ int OpenTxFirmware::getCapability(::Capability capability)
|
||||
return getCapability(LogicalSwitches);
|
||||
case LogicalSwitchesExt:
|
||||
return true;
|
||||
case RotaryEncoders:
|
||||
return 0;
|
||||
case Outputs:
|
||||
return 32;
|
||||
case NumCurvePoints:
|
||||
|
||||
@@ -188,9 +188,6 @@ QString RawSource::toString(const ModelData * model, const GeneralSettings * con
|
||||
(Boards::isAir(board) ? CHECK_IN_ARRAY(trimsAir, index) :
|
||||
CHECK_IN_ARRAY(trimsSurface, index)));
|
||||
|
||||
case SOURCE_TYPE_ROTARY_ENCODER:
|
||||
return CHECK_IN_ARRAY(rotary, index);
|
||||
|
||||
case SOURCE_TYPE_MIN:
|
||||
return tr("MIN");
|
||||
|
||||
|
||||
@@ -167,7 +167,6 @@ enum RawSourceType {
|
||||
SOURCE_TYPE_VIRTUAL_INPUT,
|
||||
SOURCE_TYPE_LUA_OUTPUT,
|
||||
SOURCE_TYPE_INPUT,
|
||||
SOURCE_TYPE_ROTARY_ENCODER,
|
||||
SOURCE_TYPE_TRIM,
|
||||
SOURCE_TYPE_MIN,
|
||||
SOURCE_TYPE_MAX,
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "hardware.h"
|
||||
#include "../modeledit/customfunctions.h"
|
||||
#include "generaloptions.h"
|
||||
#include "verticalscrollarea.h"
|
||||
#include "scrollarea.h"
|
||||
#include "compounditemmodels.h"
|
||||
|
||||
GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * firmware) :
|
||||
@@ -96,7 +96,7 @@ void GeneralEdit::addTab(GenericPanel *panel, QString text)
|
||||
panels << panel;
|
||||
QWidget * widget = new QWidget(ui->tabWidget);
|
||||
QVBoxLayout *baseLayout = new QVBoxLayout(widget);
|
||||
VerticalScrollArea * area = new VerticalScrollArea(widget, panel);
|
||||
ScrollArea * area = new ScrollArea(widget, panel);
|
||||
baseLayout->addWidget(area);
|
||||
ui->tabWidget->addTab(widget, text);
|
||||
connect(panel, &GenericPanel::modified, this, &GeneralEdit::onTabModified);
|
||||
|
||||
@@ -68,7 +68,7 @@ GeneralOptionsPanel::GeneralOptionsPanel(QWidget * parent, GeneralSettings & gen
|
||||
addParams();
|
||||
}
|
||||
|
||||
addLabel(tr("%1 Modes").arg(Boards::getRadioTypeString(board)));
|
||||
addLabel(tr("%1 Modes").arg(Boards::getRadioModeString(board)));
|
||||
AutoCheckBox *fmDisable = new AutoCheckBox(this);
|
||||
fmDisable->setField(generalSettings.modelFMDisabled, this, true);
|
||||
params->append(fmDisable);
|
||||
|
||||
@@ -145,14 +145,6 @@ ui(new Ui::GeneralSetup)
|
||||
ui->faimode_CB->setChecked(generalSettings.fai);
|
||||
}
|
||||
|
||||
if (!firmware->getCapability(RotaryEncoderNavigation)) {
|
||||
ui->rotEncMode_CB->hide();
|
||||
ui->rotEncMode_label->hide();
|
||||
}
|
||||
else {
|
||||
populateRotEncModeCB();
|
||||
}
|
||||
|
||||
if (!firmware->getCapability(HasPxxCountry)) {
|
||||
ui->countrycode_label->hide();
|
||||
ui->countrycode_CB->hide();
|
||||
@@ -260,15 +252,6 @@ ui(new Ui::GeneralSetup)
|
||||
ui->hapticmodeCB->setDisabled(true);
|
||||
}
|
||||
|
||||
int reCount = firmware->getCapability(RotaryEncoders);
|
||||
if (reCount == 0) {
|
||||
ui->re_label->hide();
|
||||
ui->re_CB->hide();
|
||||
}
|
||||
else {
|
||||
populateRotEncCB(reCount);
|
||||
}
|
||||
|
||||
if (Boards::getCapability(firmware->getBoard(), Board::HasColorLcd)) {
|
||||
ui->backlightautoSB->setMinimum(5);
|
||||
}
|
||||
@@ -505,18 +488,6 @@ void GeneralSetupPanel::updateVarioPitchRange()
|
||||
ui->varioPMax_SB->setMinimum(700 + (generalSettings.varioPitch * 10) + 1000 - 800);
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::populateRotEncCB(int reCount)
|
||||
{
|
||||
QString strings[] = { tr("No"), tr("RotEnc A"), tr("Rot Enc B"), tr("Rot Enc C"), tr("Rot Enc D"), tr("Rot Enc E")};
|
||||
QComboBox * b = ui->re_CB;
|
||||
|
||||
b->clear();
|
||||
for (int i = 0; i <= reCount; i++) {
|
||||
b->addItem(strings[i]);
|
||||
}
|
||||
b->setCurrentIndex(generalSettings.reNavigation);
|
||||
}
|
||||
|
||||
int pwrDelayFromYaml(int delay)
|
||||
{
|
||||
static int8_t vals[] = { 1, 4, 3, 2, 0 };
|
||||
@@ -631,31 +602,6 @@ void GeneralSetupPanel::on_faimode_CB_stateChanged(int)
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::populateRotEncModeCB()
|
||||
{
|
||||
QComboBox * b = ui->rotEncMode_CB;
|
||||
QString strings[] = { tr("Normal"), tr("Inverted"), tr("Vertical Inverted, Horizontal Normal"), tr("Vertical Inverted, Horizontal Alternate"), tr("Normal, Edit Inverted") };
|
||||
int itemCount = 5;
|
||||
|
||||
if (Boards::getCapability(firmware->getBoard(), Board::HasColorLcd)) {
|
||||
itemCount = 2;
|
||||
}
|
||||
|
||||
b->clear();
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
b->addItem(strings[i], 0);
|
||||
}
|
||||
b->setCurrentIndex(generalSettings.rotEncMode);
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::on_rotEncMode_CB_currentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
generalSettings.rotEncMode = index;
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::on_speakerPitchSB_editingFinished()
|
||||
{
|
||||
if (!lock) {
|
||||
@@ -835,14 +781,6 @@ void GeneralSetupPanel::on_vBatMaxDSB_editingFinished()
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::on_re_CB_currentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
generalSettings.reNavigation = ui->re_CB->currentIndex();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::on_countrycode_CB_currentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _GENERALSETUP_H_
|
||||
#define _GENERALSETUP_H_
|
||||
#pragma once
|
||||
|
||||
#include "generaledit.h"
|
||||
#include "eeprominterface.h"
|
||||
@@ -48,12 +47,10 @@ class GeneralSetupPanel : public GeneralPanel
|
||||
void on_displayTypeCB_currentIndexChanged(int index);
|
||||
void on_BLBright_SB_editingFinished();
|
||||
void on_OFFBright_SB_editingFinished();
|
||||
void on_re_CB_currentIndexChanged(int index);
|
||||
void on_countrycode_CB_currentIndexChanged(int index);
|
||||
void on_units_CB_currentIndexChanged(int index);
|
||||
void on_ppm_units_CB_currentIndexChanged(int index);
|
||||
void on_faimode_CB_stateChanged(int );
|
||||
void on_rotEncMode_CB_currentIndexChanged(int index);
|
||||
void on_speakerPitchSB_editingFinished();
|
||||
void on_timezoneLE_textEdited(const QString &text);
|
||||
void on_adjustRTC_stateChanged(int);
|
||||
@@ -116,9 +113,5 @@ class GeneralSetupPanel : public GeneralPanel
|
||||
void setValues();
|
||||
void populateBacklightCB();
|
||||
void populateVoiceLangCB();
|
||||
void populateRotEncCB(int reCount);
|
||||
void populateRotEncModeCB();
|
||||
void updateVarioPitchRange();
|
||||
};
|
||||
|
||||
#endif // _GENERALSETUP_H_
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+33
-10
@@ -626,16 +626,7 @@ TableLayout::TableLayout(QWidget * parent, int rowCount, const QStringList & hea
|
||||
|
||||
int col = 0;
|
||||
foreach(QString text, headerLabels) {
|
||||
QLabel *label = new QLabel();
|
||||
label->setFrameShape(QFrame::Panel);
|
||||
label->setFrameShadow(QFrame::Raised);
|
||||
label->setMidLineWidth(0);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
label->setMargin(5);
|
||||
label->setText(text);
|
||||
// if (!minimize)
|
||||
// label->setMinimumWidth(100);
|
||||
gridWidget->addWidget(label, 0, col++);
|
||||
addColumnHead(text, col++);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -718,6 +709,38 @@ void TableLayout::setColumnStretch(int col, int stretch)
|
||||
#endif
|
||||
}
|
||||
|
||||
void TableLayout::addColumnHead(QString text, int col, int colSpan)
|
||||
{
|
||||
QLabel *label = new QLabel();
|
||||
label->setFrameShape(QFrame::Panel);
|
||||
label->setFrameShadow(QFrame::Raised);
|
||||
label->setMidLineWidth(0);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
label->setMargin(2);
|
||||
label->setText(text);
|
||||
// if (!minimize)
|
||||
// label->setMinimumWidth(100);
|
||||
gridWidget->addWidget(label, 0, col, 1, colSpan);
|
||||
}
|
||||
|
||||
void TableLayout::updateColumnHeading(int col, QString &text)
|
||||
{
|
||||
#if defined(TABLE_LAYOUT)
|
||||
#else
|
||||
QLayoutItem *item = gridWidget->itemAtPosition(0, col);
|
||||
|
||||
if (item) {
|
||||
QWidget *widget = item->widget();
|
||||
if (widget) {
|
||||
QLabel *lbl = qobject_cast<QLabel*>(widget);
|
||||
if (lbl) {
|
||||
lbl->setText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QString Helpers::removeAccents(const QString & str)
|
||||
{
|
||||
// UTF-8 ASCII Table
|
||||
|
||||
@@ -118,7 +118,6 @@ namespace Helpers
|
||||
QString concatPath(const QString & str1, const QString & str2, bool onlyonesep = true);
|
||||
QString concatPath(const QString & str1, QString & str2, bool onlyonesep = true);
|
||||
QString concatPath(QString & str1, const QString & str2, bool onlyonesep = true);
|
||||
|
||||
} // namespace Helpers
|
||||
|
||||
// TODO : move globals to Helpers namespace
|
||||
@@ -205,6 +204,8 @@ public:
|
||||
void pushRowsUp(int row);
|
||||
void pushColumnsLeft(int col);
|
||||
void setColumnStretch(int col, int stretch);
|
||||
void addColumnHead(QString text, int col, int colSpan = 1);
|
||||
void updateColumnHeading(int col, QString &text);
|
||||
|
||||
private:
|
||||
#if defined(TABLE_LAYOUT)
|
||||
|
||||
@@ -9,6 +9,7 @@ set(${PROJECT_NAME}_NAMES
|
||||
customfunctions
|
||||
expodialog
|
||||
flightmodes
|
||||
gvars
|
||||
inputs
|
||||
heli
|
||||
logicalswitches
|
||||
|
||||
@@ -333,7 +333,7 @@ CustomScreenPanel::CustomScreenPanel(QWidget * parent, ModelData & model, int in
|
||||
str = tr("Top bar");
|
||||
break;
|
||||
case LAYOUT_OPTION_FM:
|
||||
str = tr("%1 mode").arg(Boards::getRadioTypeString(firmware->getBoard()));
|
||||
str = tr("%1 mode").arg(Boards::getRadioModeString(firmware->getBoard()));
|
||||
break;
|
||||
case LAYOUT_OPTION_SLIDERS:
|
||||
str = tr("Sliders");
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>610</width>
|
||||
<height>499</height>
|
||||
<height>593</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -61,7 +61,7 @@
|
||||
<item row="0" column="6" rowspan="2">
|
||||
<spacer name="spacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -88,7 +88,7 @@
|
||||
<item row="0" column="4">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -101,10 +101,10 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QSlider" name="trim2Slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -114,7 +114,7 @@
|
||||
<item row="0" column="3">
|
||||
<widget class="QSlider" name="trim3Slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
@@ -123,7 +123,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -133,10 +133,10 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
<enum>QFrame::Shape::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<enum>QFrame::Shadow::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
@@ -146,7 +146,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3c_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -162,7 +162,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim2Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -178,7 +178,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4a_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -195,7 +195,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_5b_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -211,7 +211,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim1Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -227,7 +227,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_6b_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -245,7 +245,7 @@
|
||||
<string notr="true">trim2</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -255,7 +255,7 @@
|
||||
<string notr="true">trim1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -273,10 +273,10 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -292,10 +292,10 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -305,10 +305,10 @@
|
||||
<item row="0" column="2">
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
<enum>QFrame::Shape::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<enum>QFrame::Shadow::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
@@ -319,7 +319,7 @@
|
||||
<string notr="true">trim4</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -328,7 +328,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_9d_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -344,7 +344,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim4Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -360,7 +360,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_10c_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -377,7 +377,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_7b_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -393,7 +393,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim3Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -409,7 +409,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_8d_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -427,7 +427,7 @@
|
||||
<string notr="true">trim3</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -444,7 +444,7 @@
|
||||
<string>trim6</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -456,7 +456,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim6Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -474,10 +474,10 @@
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
<enum>QSizePolicy::Policy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -492,10 +492,10 @@
|
||||
<item row="4" column="2">
|
||||
<widget class="QSlider" name="trim6Slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -510,7 +510,7 @@
|
||||
<string>trim8</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -522,7 +522,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim8Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -540,10 +540,10 @@
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
<enum>QSizePolicy::Policy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -558,10 +558,10 @@
|
||||
<item row="6" column="2">
|
||||
<widget class="QSlider" name="trim8Slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -571,10 +571,10 @@
|
||||
<item row="4" column="1">
|
||||
<widget class="QSlider" name="trim5Slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -589,7 +589,7 @@
|
||||
<string>trim5</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -601,7 +601,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim5Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -619,10 +619,10 @@
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
<enum>QSizePolicy::Policy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -637,10 +637,10 @@
|
||||
<item row="6" column="1">
|
||||
<widget class="QSlider" name="trim7Slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -655,7 +655,7 @@
|
||||
<string>trim7</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -667,7 +667,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim7Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -685,10 +685,10 @@
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_11">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
<enum>QSizePolicy::Policy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -702,23 +702,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gvNreLayout" columnstretch="1,1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="gvGB"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="reGB"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -41,14 +41,16 @@ class FlightModePanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FlightModePanel(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
FilteredItemModel * rawSwitchFilteredModel, QString radioType);
|
||||
FlightModePanel(QWidget *parent, ModelData &model, int modeIdx,
|
||||
GeneralSettings & generalSettings,
|
||||
Firmware * firmware,
|
||||
FilteredItemModel * rawSwitchFilteredModel,
|
||||
QString radioMode);
|
||||
virtual ~FlightModePanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
signals:
|
||||
void gvNameChanged();
|
||||
void phaseDataChanged();
|
||||
void phaseNameChanged();
|
||||
void phaseSwitchChanged();
|
||||
@@ -64,16 +66,6 @@ class FlightModePanel : public ModelPanel
|
||||
void phaseTrimUse_currentIndexChanged(int index);
|
||||
void phaseTrim_valueChanged();
|
||||
void phaseTrimSlider_valueChanged();
|
||||
void GVName_editingFinished();
|
||||
void phaseGVValue_editingFinished();
|
||||
void phaseGVUse_currentIndexChanged(int index);
|
||||
void phaseGVPopupToggled(bool checked);
|
||||
void phaseGVUnit_currentIndexChanged(int index);
|
||||
void phaseGVPrec_currentIndexChanged(int index);
|
||||
void phaseGVMin_editingFinished();
|
||||
void phaseGVMax_editingFinished();
|
||||
void phaseREValue_editingFinished();
|
||||
void phaseREUse_currentIndexChanged(int index);
|
||||
void onCustomContextMenuRequested(QPoint pos);
|
||||
void cmClear(bool prompt = true);
|
||||
void cmClearAll();
|
||||
@@ -84,16 +76,6 @@ class FlightModePanel : public ModelPanel
|
||||
void cmPaste();
|
||||
void cmMoveDown();
|
||||
void cmMoveUp();
|
||||
void gvOnCustomContextMenuRequested(QPoint pos);
|
||||
void gvCmClear(bool prompt = true);
|
||||
void gvCmClearAll();
|
||||
void gvCmCopy();
|
||||
void gvCmCut();
|
||||
void gvCmDelete();
|
||||
void gvCmInsert();
|
||||
void gvCmPaste();
|
||||
void gvCmMoveDown();
|
||||
void gvCmMoveUp();
|
||||
void onItemModelAboutToBeUpdated();
|
||||
void onItemModelUpdateComplete();
|
||||
|
||||
@@ -102,49 +84,22 @@ class FlightModePanel : public ModelPanel
|
||||
int phaseIdx;
|
||||
FlightModeData & phase;
|
||||
int fmCount;
|
||||
int reCount;
|
||||
int gvCount;
|
||||
int gvIdx;
|
||||
int trimCount;
|
||||
int gvCount;
|
||||
QVector<QLabel *> trimsLabel;
|
||||
QLineEdit * gvNames[CPN_MAX_GVARS];
|
||||
QDoubleSpinBox * gvValues[CPN_MAX_GVARS];
|
||||
QCheckBox * gvPopups[CPN_MAX_GVARS];
|
||||
QComboBox * gvUse[CPN_MAX_GVARS];
|
||||
QComboBox * gvUnit[CPN_MAX_GVARS];
|
||||
QComboBox * gvPrec[CPN_MAX_GVARS];
|
||||
QDoubleSpinBox * gvMin[CPN_MAX_GVARS];
|
||||
QDoubleSpinBox * gvMax[CPN_MAX_GVARS];
|
||||
QSpinBox * reValues[CPN_MAX_ENCODERS];
|
||||
QComboBox * reUse[CPN_MAX_ENCODERS];
|
||||
QVector<QComboBox *> trimsUse;
|
||||
QVector<QSpinBox *> trimsValue;
|
||||
QVector<QSlider *> trimsSlider;
|
||||
Board::Type board;
|
||||
QString radioType;
|
||||
QString radioMode;
|
||||
|
||||
void trimUpdate(unsigned int trim);
|
||||
void updateGVar(int index);
|
||||
void updateRotaryEncoder(int index);
|
||||
void setGVSB(QDoubleSpinBox * spinBox, int min, int max, int val);
|
||||
void populateGvarUnitCB(QComboBox * cb);
|
||||
void populateGvarPrecCB(QComboBox * cb);
|
||||
bool hasClipboardData(QByteArray * data = nullptr) const;
|
||||
bool insertAllowed() const;
|
||||
bool moveDownAllowed() const;
|
||||
bool moveUpAllowed() const;
|
||||
void swapData(int idx1, int idx2);
|
||||
bool gvHasClipboardData() const;
|
||||
bool gvHasDefnClipboardData(QByteArray * data = nullptr) const;
|
||||
bool gvHasValueClipboardData(QByteArray * data = nullptr) const;
|
||||
bool gvHasAllValuesClipboardData(QByteArray * data = nullptr) const;
|
||||
bool gvDeleteAllowed() const;
|
||||
bool gvInsertAllowed() const;
|
||||
bool gvMoveDownAllowed() const;
|
||||
bool gvMoveUpAllowed() const;
|
||||
void gvSwapData(int idx1, int idx2);
|
||||
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
||||
void populateGvarUseCB(QComboBox *b, unsigned int phase);
|
||||
};
|
||||
|
||||
class FlightModesPanel : public ModelPanel
|
||||
@@ -152,7 +107,11 @@ class FlightModesPanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FlightModesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CompoundItemModelFactory * sharedItemModels);
|
||||
FlightModesPanel(QWidget *parent, ModelData & model,
|
||||
GeneralSettings & generalSettings,
|
||||
Firmware * firmware,
|
||||
CompoundItemModelFactory * sharedItemModels,
|
||||
QString radioModes);
|
||||
virtual ~FlightModesPanel();
|
||||
|
||||
public slots:
|
||||
@@ -177,7 +136,7 @@ class FlightModesPanel : public ModelPanel
|
||||
CompoundItemModelFactory *sharedItemModels;
|
||||
FilteredItemModel *rawSwitchFilteredModel;
|
||||
QVector<GenericPanel *> panels;
|
||||
QString radioType;
|
||||
QString radioMode;
|
||||
|
||||
void updateItemModels();
|
||||
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
||||
|
||||
@@ -0,0 +1,620 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "gvars.h"
|
||||
#include "gvardata.h"
|
||||
#include "flightmodedata.h"
|
||||
#include "filtereditemmodels.h"
|
||||
#include "eeprominterface.h"
|
||||
#include "helpers.h"
|
||||
#include "namevalidator.h"
|
||||
|
||||
GlobalVariablesPanel::GlobalVariablesPanel(QWidget * parent, ModelData & model,
|
||||
GeneralSettings & generalSettings,
|
||||
Firmware * firmware,
|
||||
CompoundItemModelFactory * sharedItemModels) :
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
sharedItemModels(sharedItemModels),
|
||||
selectedIndex(0),
|
||||
modelsUpdateCnt(0),
|
||||
gvars(firmware->getCapability(Gvars)),
|
||||
modes(firmware->getCapability(FlightModes)),
|
||||
modeName(FlightModeData::modeName()),
|
||||
modePrefix(FlightModeData::modeAbbrev())
|
||||
{
|
||||
AbstractStaticItemModel *unitItemModel = GVarData::unitItemModel();
|
||||
AbstractStaticItemModel *precItemModel = GVarData::precItemModel();
|
||||
CompoundItemModelFactory *gvarModesIMF = new CompoundItemModelFactory(&generalSettings, &model);
|
||||
|
||||
int firstmidx = 0;
|
||||
for (int i = 0; i < modes; i++) {
|
||||
int id = gvarModesIMF->registerItemModel(FlightModeData::gvarModesItemModel(i));
|
||||
if (i == 0)
|
||||
firstmidx = id;
|
||||
}
|
||||
|
||||
// add mode headers post table construction as they span columns
|
||||
QStringList headerLabels;
|
||||
headerLabels << "#" << tr("Name") << tr("Unit") << tr("Prec") << tr("Min")
|
||||
<< tr("Max") << tr("Popup");
|
||||
|
||||
tableLayout = new TableLayout(this, gvars, headerLabels);
|
||||
|
||||
for (int i = 0; i < gvars; i++) {
|
||||
int col = 0;
|
||||
// label
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setText(tr("GV%1").arg(i + 1));
|
||||
label->setProperty("index", i);
|
||||
label->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
label->setToolTip(tr("Popup menu available"));
|
||||
label->setMouseTracking(true);
|
||||
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
connect(label, &QWidget::customContextMenuRequested, this,
|
||||
&GlobalVariablesPanel::onCustomContextMenuRequested);
|
||||
tableLayout->addWidget(i, col++, label);
|
||||
|
||||
// name
|
||||
leName[i] = new QLineEdit(this);
|
||||
QLineEdit *name = leName[i];
|
||||
name->setProperty("index", i);
|
||||
name->setValidator(new NameValidator(firmware->getBoard(), this));
|
||||
name->setMaxLength(firmware->getCapability(GvarsName));
|
||||
connect(name, &QLineEdit::editingFinished, this, &GlobalVariablesPanel::nameEditingFinished);
|
||||
tableLayout->addWidget(i, col++, name);
|
||||
|
||||
// unit
|
||||
cboUnit[i] = new QComboBox(this);
|
||||
QComboBox *unit = cboUnit[i];
|
||||
unit->setProperty("index", i);
|
||||
unit->setModel(unitItemModel);
|
||||
connect(unit, &QComboBox::currentIndexChanged, this, &GlobalVariablesPanel::unitCurrentIndexChanged);
|
||||
tableLayout->addWidget(i, col++, unit);
|
||||
|
||||
// precision
|
||||
cboPrec[i] = new QComboBox(this);
|
||||
QComboBox *prec = cboPrec[i];
|
||||
prec->setProperty("index", i);
|
||||
prec->setModel(precItemModel);
|
||||
connect(prec, &QComboBox::currentIndexChanged, this, &GlobalVariablesPanel::precCurrentIndexChanged);
|
||||
tableLayout->addWidget(i, col++, prec);
|
||||
|
||||
// min
|
||||
dsbMin[i] = new QDoubleSpinBox(this);
|
||||
QDoubleSpinBox *min = dsbMin[i];
|
||||
min->setProperty("index", i);
|
||||
connect(min, &QDoubleSpinBox::editingFinished, this, &GlobalVariablesPanel::minEditingFinished);
|
||||
tableLayout->addWidget(i, col++, min);
|
||||
|
||||
// max
|
||||
dsbMax[i] = new QDoubleSpinBox(this);
|
||||
QDoubleSpinBox *max = dsbMax[i];
|
||||
max->setProperty("index", i);
|
||||
connect(max, &QDoubleSpinBox::editingFinished, this, &GlobalVariablesPanel::maxEditingFinished);
|
||||
tableLayout->addWidget(i, col++, max);
|
||||
|
||||
// popup
|
||||
chkPopup[i] = new QCheckBox(this);
|
||||
QCheckBox *popup = chkPopup[i];
|
||||
popup->setProperty("index", i);
|
||||
connect(popup, &QCheckBox::toggled, this, &GlobalVariablesPanel::popupToggled);
|
||||
tableLayout->addWidget(i, col++, popup, Qt::AlignHCenter);
|
||||
|
||||
// radio modes (drive/flight)
|
||||
for (int j = 0; j < modes; j++) {
|
||||
if (j > 0) {
|
||||
// use mode
|
||||
chkUseMode[i][j] = new QCheckBox(tr("%1M").arg(modePrefix),this);
|
||||
QCheckBox *usemode = chkUseMode[i][j];
|
||||
setIndexes(usemode, i, j);
|
||||
connect(usemode, &QCheckBox::toggled, this, &GlobalVariablesPanel::useModeToggled);
|
||||
tableLayout->addWidget(i, col++, usemode, Qt::AlignHCenter);
|
||||
|
||||
// mode
|
||||
cboMode[i][j] = new QComboBox(this);
|
||||
QComboBox *mode = cboMode[i][j];
|
||||
setIndexes(mode, i, j);
|
||||
mode->setModel(gvarModesIMF->getItemModel(firstmidx + j));
|
||||
connect(mode, &QComboBox::currentIndexChanged, this, &GlobalVariablesPanel::modeCurrentIndexChanged);
|
||||
tableLayout->addWidget(i, col, mode); // do not increment col as either cboMode or dsbValue visible
|
||||
}
|
||||
|
||||
// value
|
||||
dsbValue[i][j] = new QDoubleSpinBox(this);
|
||||
QDoubleSpinBox *value = dsbValue[i][j];
|
||||
setIndexes(value, i, j);
|
||||
connect(value, &QDoubleSpinBox::editingFinished, this, &GlobalVariablesPanel::valueEditingFinished);
|
||||
tableLayout->addWidget(i, col++, value);
|
||||
}
|
||||
}
|
||||
|
||||
int col = headerLabels.size();
|
||||
|
||||
for (int i = 0; i < modes; i++) {
|
||||
int colspan = i > 0 ? 2 : 1;
|
||||
tableLayout->addColumnHead(model.flightModeData[i].nameToString(i), col, colspan);
|
||||
col += colspan;
|
||||
}
|
||||
|
||||
disableMouseScrolling();
|
||||
tableLayout->resizeColumnsToContents();
|
||||
tableLayout->pushRowsUp(gvars + 1);
|
||||
tableLayout->pushColumnsLeft(col);
|
||||
}
|
||||
|
||||
GlobalVariablesPanel::~GlobalVariablesPanel()
|
||||
{
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmClear(bool prompt)
|
||||
{
|
||||
if (prompt) {
|
||||
if (QMessageBox::question(this, tr("Edit Global Variables"),
|
||||
tr("Clear global variable #%1. Are you sure?").arg(selectedIndex + 1),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
return;
|
||||
}
|
||||
|
||||
model->gvarClear(selectedIndex);
|
||||
updateLine(selectedIndex);
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmClearAll()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Edit Global Variables"),
|
||||
tr("Clear all global variables. Are you sure?"),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < gvars; i++) {
|
||||
model->gvarClear(i);
|
||||
}
|
||||
|
||||
update();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmCopy()
|
||||
{
|
||||
QByteArray data;
|
||||
QDataStream stream(&data, QIODevice::WriteOnly);
|
||||
stream << model->gvarData[selectedIndex];
|
||||
|
||||
for (int j = 0; j < modes; j++) {
|
||||
stream << model->flightModeData[j].gvars[selectedIndex];
|
||||
}
|
||||
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
mimeData->setData(MIMETYPE_GLOBAL_VARIABLE, data);
|
||||
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmCut()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Edit Global Variables"),
|
||||
tr("Cut global variable #%1. Are you sure?").arg(selectedIndex + 1),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
return;
|
||||
|
||||
cmCopy();
|
||||
cmClear(false);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmDelete()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Edit Global Variables"),
|
||||
tr("Delete global variable #%1. Are you sure?").arg(selectedIndex + 1),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
return;
|
||||
|
||||
model->gvarDelete(selectedIndex);
|
||||
|
||||
for (int i = selectedIndex; i < gvars; i++) {
|
||||
updateLine(i);
|
||||
}
|
||||
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmInsert()
|
||||
{
|
||||
model->gvarInsert(selectedIndex);
|
||||
|
||||
for (int i = selectedIndex; i < gvars; i++) {
|
||||
updateLine(i);
|
||||
}
|
||||
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmMoveDown()
|
||||
{
|
||||
swapData(selectedIndex, selectedIndex + 1);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmMoveUp()
|
||||
{
|
||||
swapData(selectedIndex, selectedIndex - 1);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmPaste()
|
||||
{
|
||||
QByteArray data;
|
||||
if (hasClipboardData(&data)) {
|
||||
QDataStream stream(&data, QIODevice::ReadOnly);
|
||||
stream >> model->gvarData[selectedIndex];
|
||||
|
||||
for (int j = 0; j < modes; j++) {
|
||||
stream >> model->flightModeData[j].gvars[selectedIndex];
|
||||
}
|
||||
|
||||
updateLine(selectedIndex);
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::connectItemModelEvents(const FilteredItemModel * itemModel)
|
||||
{
|
||||
connect(itemModel, &FilteredItemModel::aboutToBeUpdated, this,
|
||||
&GlobalVariablesPanel::onItemModelAboutToBeUpdated);
|
||||
connect(itemModel, &FilteredItemModel::updateComplete, this,
|
||||
&GlobalVariablesPanel::onItemModelUpdateComplete);
|
||||
}
|
||||
|
||||
bool GlobalVariablesPanel::deleteAllowed() const
|
||||
{
|
||||
return selectedIndex < gvars - 1;
|
||||
}
|
||||
|
||||
bool GlobalVariablesPanel::getIndexes(QWidget * widget, int &gvarIdx, int &modeIdx) {
|
||||
bool ok = false;
|
||||
unsigned int i = (unsigned int)widget->property("index").toInt(&ok);
|
||||
|
||||
if (!ok)
|
||||
return false;
|
||||
|
||||
modeIdx = (int)Helpers::getBitmappedValue(i, 0, 8);
|
||||
gvarIdx = (int)Helpers::getBitmappedValue(i, 1, 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GlobalVariablesPanel::hasClipboardData(QByteArray * data) const
|
||||
{
|
||||
const QClipboard * clipboard = QApplication::clipboard();
|
||||
const QMimeData * mimeData = clipboard->mimeData();
|
||||
|
||||
if (mimeData->hasFormat(MIMETYPE_GLOBAL_VARIABLE)) {
|
||||
if (data) {
|
||||
data->append(mimeData->data(MIMETYPE_GLOBAL_VARIABLE));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::maxEditingFinished()
|
||||
{
|
||||
if (!lock) {
|
||||
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
bool ok;
|
||||
int gidx = dsb->property("index").toInt(&ok);
|
||||
|
||||
if (ok) {
|
||||
model->gvarSetMax(gidx, dsb->value());
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::minEditingFinished()
|
||||
{
|
||||
if (!lock) {
|
||||
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
bool ok;
|
||||
int gidx = dsb->property("index").toInt(&ok);
|
||||
|
||||
if (ok) {
|
||||
model->gvarSetMin(gidx, dsb->value());
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::modeCurrentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
QComboBox *cbo = qobject_cast<QComboBox*>(sender());
|
||||
int gidx = 0;
|
||||
int midx = 0;
|
||||
|
||||
if (getIndexes(cbo, gidx, midx)) {
|
||||
model->flightModeData[midx].gvars[gidx] = cbo->currentData().toInt();
|
||||
|
||||
if (model->isGVarLinkedCircular(midx, gidx)) {
|
||||
QMessageBox::warning(this, tr("Edit Global Variables"),
|
||||
tr("Warning: Global variable links back to itself, %1M0 used.")
|
||||
.arg(modePrefix));
|
||||
model->flightModeData[midx].gvars[gidx] =
|
||||
model->flightModeData->linkedGVarFlightModeZero(midx);
|
||||
}
|
||||
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GlobalVariablesPanel::moveDownAllowed() const
|
||||
{
|
||||
return selectedIndex < gvars - 1;
|
||||
}
|
||||
|
||||
bool GlobalVariablesPanel::moveUpAllowed() const
|
||||
{
|
||||
return selectedIndex > 0;
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::nameEditingFinished()
|
||||
{
|
||||
if (!lock) {
|
||||
QLineEdit *lineedit = qobject_cast<QLineEdit*>(sender());
|
||||
bool ok;
|
||||
int gidx = lineedit->property("index").toInt(&ok);
|
||||
|
||||
if (ok) {
|
||||
memset(&model->gvarData[gidx].name, 0, sizeof(model->gvarData[gidx].name));
|
||||
strcpy(model->gvarData[gidx].name, lineedit->text().toLatin1());
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::onCustomContextMenuRequested(QPoint pos)
|
||||
{
|
||||
QLabel *label = (QLabel *)sender();
|
||||
selectedIndex = label->property("index").toInt();
|
||||
QPoint globalPos = label->mapToGlobal(pos);
|
||||
|
||||
QMenu contextMenu;
|
||||
contextMenu.addAction(CompanionIcon("copy.png"), tr("Copy"), this,
|
||||
SLOT(cmCopy()));
|
||||
contextMenu.addAction(CompanionIcon("cut.png"), tr("Cut"), this,
|
||||
SLOT(cmCut()));
|
||||
contextMenu.addAction(CompanionIcon("paste.png"), tr("Paste"), this,
|
||||
SLOT(cmPaste()))->setEnabled(hasClipboardData());
|
||||
contextMenu.addAction(CompanionIcon("clear.png"), tr("Clear"), this,
|
||||
SLOT(cmClear()));
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction(CompanionIcon("arrow-right.png"), tr("Insert"), this,
|
||||
SLOT(cmInsert()))->setEnabled(model->gvarInsertAllowed(selectedIndex));
|
||||
contextMenu.addAction(CompanionIcon("arrow-left.png"), tr("Delete"), this,
|
||||
SLOT(cmDelete()))->setEnabled(deleteAllowed());
|
||||
contextMenu.addAction(CompanionIcon("moveup.png"), tr("Move Up"), this,
|
||||
SLOT(cmMoveUp()))->setEnabled(moveUpAllowed());
|
||||
contextMenu.addAction(CompanionIcon("movedown.png"), tr("Move Down"), this,
|
||||
SLOT(cmMoveDown()))->setEnabled(moveDownAllowed());
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction(CompanionIcon("clear.png"), tr("Clear All"), this,
|
||||
SLOT(cmClearAll()));
|
||||
contextMenu.exec(globalPos);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::onItemModelAboutToBeUpdated()
|
||||
{
|
||||
lock = true;
|
||||
modelsUpdateCnt++;
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::onItemModelUpdateComplete()
|
||||
{
|
||||
modelsUpdateCnt--;
|
||||
|
||||
if (modelsUpdateCnt < 1) {
|
||||
update();
|
||||
lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::popupToggled(bool checked)
|
||||
{
|
||||
if (!lock) {
|
||||
QCheckBox *chk = qobject_cast<QCheckBox*>(sender());
|
||||
bool ok;
|
||||
int gidx = chk->property("index").toInt(&ok);
|
||||
|
||||
if (ok) {
|
||||
model->gvarData[gidx].popup = checked;
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::precCurrentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
|
||||
int gidx = comboBox->property("index").toInt();
|
||||
model->gvarData[gidx].prec = index;
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::setIndexes(QWidget * widget, int gvarIdx, int modeIdx) {
|
||||
unsigned int i = 0;
|
||||
Helpers::setBitmappedValue(i, modeIdx, 0, 8);
|
||||
Helpers::setBitmappedValue(i, gvarIdx, 1, 8);
|
||||
widget->setProperty("index", i);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::setMinMax(QDoubleSpinBox * dsb, int min, int max, int val)
|
||||
{
|
||||
bool ok;
|
||||
int gidx = dsb->property("index").toInt(&ok);
|
||||
|
||||
if (ok) {
|
||||
float mul = model->gvarData[gidx].multiplierGet();
|
||||
dsb->setDecimals(model->gvarData[gidx].prec);
|
||||
dsb->setSingleStep(mul);
|
||||
dsb->setSuffix(model->gvarData[gidx].unitToString());
|
||||
dsb->setMinimum(min * mul);
|
||||
dsb->setMaximum(max * mul);
|
||||
dsb->setValue(val * mul);
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::setValue(QDoubleSpinBox * dsb, int val)
|
||||
{
|
||||
int gidx = 0;
|
||||
int midx = 0;
|
||||
|
||||
if (getIndexes(dsb, gidx, midx)) {
|
||||
float mul = model->gvarData[gidx].multiplierGet();
|
||||
dsb->setDecimals(model->gvarData[gidx].prec);
|
||||
dsb->setSingleStep(mul);
|
||||
dsb->setSuffix(model->gvarData[gidx].unitToString());
|
||||
dsb->setMinimum(model->gvarData[gidx].getMinPrec());
|
||||
dsb->setMaximum(model->gvarData[gidx].getMaxPrec());
|
||||
dsb->setValue(val * mul);
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::swapData(int index1, int index2)
|
||||
{
|
||||
if ((index1 != index2)) {
|
||||
model->gvarSwap(index1, index2);
|
||||
updateLine(index1);
|
||||
updateLine(index2);
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::unitCurrentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
|
||||
int gidx = comboBox->property("index").toInt();
|
||||
model->gvarData[gidx].unit = index;
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::update()
|
||||
{
|
||||
int col = 7;
|
||||
|
||||
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
|
||||
QString text(model->flightModeData[i].nameToString(i));
|
||||
tableLayout->updateColumnHeading(col, text);
|
||||
i == 0 ? col++ : col += 2;
|
||||
}
|
||||
|
||||
for (int i = 0; i < gvars; i++) {
|
||||
updateLine(i);
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::updateLine(int index)
|
||||
{
|
||||
if (index < 0 || index >= gvars)
|
||||
return;
|
||||
|
||||
lock = true;
|
||||
leName[index]->setText(model->gvarData[index].name);
|
||||
cboUnit[index]->setCurrentIndex(model->gvarData[index].unit);
|
||||
cboPrec[index]->setCurrentIndex(model->gvarData[index].prec);
|
||||
setMinMax(dsbMin[index], GVAR_MIN_VALUE, model->gvarData[index].getMax(),
|
||||
model->gvarData[index].getMin());
|
||||
setMinMax(dsbMax[index], model->gvarData[index].getMin(), GVAR_MAX_VALUE,
|
||||
model->gvarData[index].getMax());
|
||||
chkPopup[index]->setChecked(model->gvarData[index].popup);
|
||||
|
||||
for (int j = 0; j < modes; j++) {
|
||||
if (!model->isGVarLinked(j, index)) {
|
||||
if (j > 0) {
|
||||
chkUseMode[index][j]->setChecked(false);
|
||||
cboMode[index][j]->setCurrentIndex(0);
|
||||
cboMode[index][j]->setVisible(false);
|
||||
}
|
||||
|
||||
dsbValue[index][j]->setVisible(true);
|
||||
setValue(dsbValue[index][j], model->getGVarValue(j, index));
|
||||
} else {
|
||||
chkUseMode[index][j]->setChecked(true);
|
||||
cboMode[index][j]->setVisible(true);
|
||||
cboMode[index][j]->setCurrentIndex(cboMode[index][j]->findData(model->flightModeData[j].gvars[index]));
|
||||
dsbValue[index][j]->setValue(0);
|
||||
dsbValue[index][j]->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::updateItemModels()
|
||||
{
|
||||
sharedItemModels->update(AbstractItemModel::IMUE_GVars);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::useModeToggled(bool checked)
|
||||
{
|
||||
if (!lock) {
|
||||
QCheckBox *chk = qobject_cast<QCheckBox*>(sender());
|
||||
int gidx = 0;
|
||||
int midx = 0;
|
||||
|
||||
if (getIndexes(chk, gidx, midx)) {
|
||||
int val = checked ? model->flightModeData->linkedGVarFlightModeZero(midx) : 0;
|
||||
model->flightModeData[midx].gvars[gidx] = val;
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::valueEditingFinished()
|
||||
{
|
||||
if (!lock) {
|
||||
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
int gidx = 0;
|
||||
int midx = 0;
|
||||
|
||||
if (getIndexes(dsb, gidx, midx)) {
|
||||
model->flightModeData[midx].gvars[gidx] = dsb->value() *
|
||||
model->gvarData[gidx].multiplierSet();
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "constants.h"
|
||||
#include "boards.h"
|
||||
|
||||
class CompoundItemModelFactory;
|
||||
class FilteredItemModel;
|
||||
class TableLayout;
|
||||
|
||||
constexpr char MIMETYPE_GLOBAL_VARIABLE[] = "application/x-companion-global-variable";
|
||||
|
||||
class GlobalVariablesPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GlobalVariablesPanel(QWidget *parent, ModelData & model,
|
||||
GeneralSettings & generalSettings,
|
||||
Firmware * firmware,
|
||||
CompoundItemModelFactory * sharedItemModels);
|
||||
virtual ~GlobalVariablesPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
void cmClear(bool prompt = true);
|
||||
void cmClearAll();
|
||||
void cmCopy();
|
||||
void cmCut();
|
||||
void cmDelete();
|
||||
void cmInsert();
|
||||
void cmMoveDown();
|
||||
void cmMoveUp();
|
||||
void cmPaste();
|
||||
void maxEditingFinished();
|
||||
void minEditingFinished();
|
||||
void modeCurrentIndexChanged(int index);
|
||||
void nameEditingFinished();
|
||||
void onCustomContextMenuRequested(QPoint pos);
|
||||
void onItemModelAboutToBeUpdated();
|
||||
void onItemModelUpdateComplete();
|
||||
void popupToggled(bool checked);
|
||||
void precCurrentIndexChanged(int index);
|
||||
void unitCurrentIndexChanged(int index);
|
||||
void useModeToggled(bool checked);
|
||||
void valueEditingFinished();
|
||||
|
||||
private:
|
||||
CompoundItemModelFactory *sharedItemModels;
|
||||
int selectedIndex;
|
||||
int modelsUpdateCnt;
|
||||
int gvars;
|
||||
int modes;
|
||||
QString modeName;
|
||||
QString modePrefix;
|
||||
|
||||
TableLayout *tableLayout;
|
||||
QLineEdit *leName[CPN_MAX_GVARS];
|
||||
QComboBox *cboUnit[CPN_MAX_GVARS];
|
||||
QComboBox *cboPrec[CPN_MAX_GVARS];
|
||||
QDoubleSpinBox *dsbMin[CPN_MAX_GVARS];
|
||||
QDoubleSpinBox *dsbMax[CPN_MAX_GVARS];
|
||||
QCheckBox *chkPopup[CPN_MAX_GVARS];
|
||||
QCheckBox *chkUseMode[CPN_MAX_GVARS][CPN_MAX_FLIGHT_MODES];
|
||||
QComboBox *cboMode[CPN_MAX_GVARS][CPN_MAX_FLIGHT_MODES];
|
||||
QDoubleSpinBox *dsbValue[CPN_MAX_GVARS][CPN_MAX_FLIGHT_MODES];
|
||||
|
||||
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
||||
bool deleteAllowed() const;
|
||||
bool getIndexes(QWidget * widget, int &gvarIdx, int &modeIdx);
|
||||
bool hasClipboardData(QByteArray * data = nullptr) const;
|
||||
bool moveDownAllowed() const;
|
||||
bool moveUpAllowed() const;
|
||||
void setIndexes(QWidget * widget, int gvarIdx, int modeIdx);
|
||||
void setValue(QDoubleSpinBox * spinBox, int val);
|
||||
void setMinMax(QDoubleSpinBox * spinBox, int min, int max, int val);
|
||||
void swapData(int index1, int index2);
|
||||
void updateLine(const int index);
|
||||
void updateItemModels();
|
||||
};
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "mixes.h"
|
||||
#include "channels.h"
|
||||
#include "curves.h"
|
||||
#include "verticalscrollarea.h"
|
||||
#include "scrollarea.h"
|
||||
#include "logicalswitches.h"
|
||||
#include "customfunctions.h"
|
||||
#include "telemetry.h"
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "modeloptions.h"
|
||||
#include "appdata.h"
|
||||
#include "compounditemmodels.h"
|
||||
#include "gvars.h"
|
||||
|
||||
ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmware * firmware) :
|
||||
QDialog(parent),
|
||||
@@ -57,6 +58,7 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
|
||||
|
||||
GeneralSettings &generalSettings = radioData.generalSettings;
|
||||
ModelData &model = radioData.models[modelId];
|
||||
QString radioMode = Boards::getRadioModeString(firmware->getBoard());
|
||||
|
||||
sharedItemModels = new CompoundItemModelFactory(&generalSettings, &model);
|
||||
sharedItemModels->addItemModel(AbstractItemModel::IMID_RawSource);
|
||||
@@ -81,10 +83,10 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
|
||||
s1.report("Heli");
|
||||
}
|
||||
|
||||
QString radioType = QString(tr("%1 Modes").arg(Boards::getRadioTypeString(firmware->getBoard())));
|
||||
FlightModesPanel *flightModesPanel = new FlightModesPanel(this, model, generalSettings, firmware, sharedItemModels);
|
||||
addTab(flightModesPanel, radioType);
|
||||
s1.report(radioType);
|
||||
QString tabTitle = QString(tr("%1 Modes").arg(Boards::getRadioModeString(firmware->getBoard())));
|
||||
FlightModesPanel *flightModesPanel = new FlightModesPanel(this, model, generalSettings, firmware, sharedItemModels, radioMode);
|
||||
addTab(flightModesPanel, tabTitle);
|
||||
s1.report(tabTitle);
|
||||
|
||||
addTab(new InputsPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Inputs"));
|
||||
s1.report("Inputs");
|
||||
@@ -99,6 +101,11 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
|
||||
addTab(new CurvesPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Curves"));
|
||||
s1.report("Curves");
|
||||
|
||||
if (firmware->getCapability(Gvars)) {
|
||||
addTab(new GlobalVariablesPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Global Variables"));
|
||||
s1.report("Global Variables");
|
||||
}
|
||||
|
||||
addTab(new LogicalSwitchesPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Logical Switches"));
|
||||
s1.report("Logical Switches");
|
||||
|
||||
@@ -149,7 +156,7 @@ void ModelEdit::addTab(GenericPanel *panel, QString text)
|
||||
panels << panel;
|
||||
QWidget * widget = new QWidget(ui->tabWidget);
|
||||
QVBoxLayout *baseLayout = new QVBoxLayout(widget);
|
||||
VerticalScrollArea * area = new VerticalScrollArea(widget, panel);
|
||||
ScrollArea * area = new ScrollArea(widget, panel);
|
||||
baseLayout->addWidget(area);
|
||||
ui->tabWidget->addTab(widget, text);
|
||||
connect(panel, &GenericPanel::modified, this, &ModelEdit::modified);
|
||||
|
||||
@@ -82,7 +82,7 @@ ModelOptionsPanel::ModelOptionsPanel(QWidget * parent, ModelData & model, Genera
|
||||
addParams();
|
||||
}
|
||||
|
||||
addLabel(tr("%1 Modes").arg(Boards::getRadioTypeString(firmware->getBoard())));
|
||||
addLabel(tr("%1 Modes").arg(Boards::getRadioModeString(firmware->getBoard())));
|
||||
AutoComboBox *fmDisable = new AutoComboBox(this);
|
||||
fmDisable->setModel(mdl);
|
||||
fmDisable->setField(model.modelFMDisabled, this);
|
||||
|
||||
@@ -199,8 +199,8 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
const int ttlFlexInputs = Boards::getBoardCapability(board, Board::FlexInputs);
|
||||
const int ttlInputs = ttlSticks + ttlFlexInputs;
|
||||
|
||||
for (int i = 0; i < ttlInputs + firmware->getCapability(RotaryEncoders); i++) {
|
||||
RawSource src((i < ttlInputs) ? SOURCE_TYPE_INPUT : SOURCE_TYPE_ROTARY_ENCODER, (i < ttlInputs) ? i + 1 : i - ttlInputs);
|
||||
for (int i = 0; i < ttlInputs; i++) {
|
||||
RawSource src(SOURCE_TYPE_INPUT, i + 1);
|
||||
QCheckBox * checkbox = new QCheckBox(this);
|
||||
checkbox->setProperty("index", i);
|
||||
checkbox->setText(src.toString(&model, &generalSettings));
|
||||
|
||||
@@ -274,9 +274,9 @@ QString ModelPrinter::printCenterBeep()
|
||||
Board::Type board = getCurrentBoard();
|
||||
int inputs = Boards::getBoardCapability(board, Board::Inputs);
|
||||
|
||||
for (int i = 0; i < inputs + firmware->getCapability(RotaryEncoders); i++) {
|
||||
for (int i = 0; i < inputs; i++) {
|
||||
if (model.beepANACenter & (0x01 << i)) {
|
||||
RawSource src((i < inputs) ? SOURCE_TYPE_INPUT : SOURCE_TYPE_ROTARY_ENCODER, (i < inputs) ? i : inputs - i);
|
||||
RawSource src(SOURCE_TYPE_INPUT, i + 1);
|
||||
strl << src.toString(&model, &generalSettings);
|
||||
}
|
||||
}
|
||||
@@ -325,20 +325,6 @@ QString ModelPrinter::printGlobalVar(int flightModeIndex, int gvarIndex)
|
||||
}
|
||||
}
|
||||
|
||||
QString ModelPrinter::printRotaryEncoder(int flightModeIndex, int reIndex)
|
||||
{
|
||||
const FlightModeData & fm = model.flightModeData[flightModeIndex];
|
||||
|
||||
if (fm.rotaryEncoders[reIndex] <= 1024) {
|
||||
return QString("%1").arg(fm.rotaryEncoders[reIndex]);
|
||||
}
|
||||
else {
|
||||
int num = fm.rotaryEncoders[reIndex] - 1025;
|
||||
if (num >= flightModeIndex) num++;
|
||||
return tr("FM%1").arg(num);
|
||||
}
|
||||
}
|
||||
|
||||
QString ModelPrinter::printInputName(int idx)
|
||||
{
|
||||
RawSourceType srcType = (firmware->getCapability(VirtualInputs) ? SOURCE_TYPE_VIRTUAL_INPUT : SOURCE_TYPE_INPUT);
|
||||
|
||||
@@ -52,7 +52,6 @@ class ModelPrinter: public QObject
|
||||
QString printHeliSwashType();
|
||||
QString printTrim(int flightModeIndex, int stickIndex);
|
||||
QString printGlobalVar(int flightModeIndex, int gvarIndex);
|
||||
QString printRotaryEncoder(int flightModeIndex, int reIndex);
|
||||
QString printInputName(int idx);
|
||||
QString printInputLine(int idx);
|
||||
QString printInputLine(const ExpoData & ed);
|
||||
|
||||
@@ -460,9 +460,10 @@ QString MultiModelPrinter::printFlightModes()
|
||||
str.append(columns.print());
|
||||
}
|
||||
|
||||
// GVars and Rotary Encoders
|
||||
// GVars
|
||||
int gvars = firmware->getCapability(Gvars);
|
||||
if ((gvars && firmware->getCapability(GvarsFlightModes)) || firmware->getCapability(RotaryEncoders)) {
|
||||
|
||||
if (gvars && firmware->getCapability(GvarsFlightModes)) {
|
||||
MultiColumns columns(modelPrinterMap.size());
|
||||
columns.appendSectionTableStart();
|
||||
QStringList hd = QStringList() << tr("Global vars");
|
||||
@@ -471,9 +472,6 @@ QString MultiModelPrinter::printFlightModes()
|
||||
hd << tr("GV%1").arg(i + 1);
|
||||
}
|
||||
}
|
||||
for (int i=0; i<firmware->getCapability(RotaryEncoders); i++) {
|
||||
hd << tr("RE%1").arg(i + 1);
|
||||
}
|
||||
columns.appendRowHeader(hd);
|
||||
int wd = 80 / gvars;
|
||||
if (firmware->getCapability(GvarsFlightModes)) {
|
||||
@@ -524,9 +522,7 @@ QString MultiModelPrinter::printFlightModes()
|
||||
COMPARECELL(modelPrinter->printGlobalVar(i, k));
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < firmware->getCapability(RotaryEncoders); k++) {
|
||||
COMPARECELL(modelPrinter->printRotaryEncoder(i, k));
|
||||
}
|
||||
|
||||
columns.appendRowEnd();
|
||||
}
|
||||
columns.appendTableEnd();
|
||||
|
||||
@@ -18,7 +18,7 @@ set(${PROJECT_NAME}_NAMES
|
||||
curveimagewidget
|
||||
curvedialog
|
||||
genericpanel
|
||||
verticalscrollarea
|
||||
scrollarea
|
||||
textvalidator
|
||||
)
|
||||
|
||||
|
||||
@@ -19,25 +19,24 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "verticalscrollarea.h"
|
||||
#include "scrollarea.h"
|
||||
#include "genericpanel.h"
|
||||
#include <QEvent>
|
||||
#include <QScrollBar>
|
||||
|
||||
VerticalScrollArea::VerticalScrollArea(QWidget * parent, GenericPanel * panel):
|
||||
ScrollArea::ScrollArea(QWidget * parent, GenericPanel * panel):
|
||||
QScrollArea(parent),
|
||||
panel(panel)
|
||||
{
|
||||
setWidgetResizable(true);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setWidget(panel);
|
||||
panel->installEventFilter(this);
|
||||
}
|
||||
|
||||
bool VerticalScrollArea::eventFilter(QObject * o, QEvent * e)
|
||||
bool ScrollArea::eventFilter(QObject * o, QEvent * e)
|
||||
{
|
||||
if (o == panel && e->type() == QEvent::Resize) {
|
||||
setMinimumWidth(panel->minimumSizeHint().width() + verticalScrollBar()->width());
|
||||
setMinimumWidth(panel->minimumSizeHint().width() * 0.75);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -25,12 +25,12 @@
|
||||
|
||||
class GenericPanel;
|
||||
|
||||
class VerticalScrollArea : public QScrollArea
|
||||
class ScrollArea : public QScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VerticalScrollArea(QWidget * parent, GenericPanel * panel);
|
||||
ScrollArea(QWidget * parent, GenericPanel * panel);
|
||||
|
||||
protected:
|
||||
virtual bool eventFilter(QObject * o, QEvent * e);
|
||||
Reference in New Issue
Block a user