fix(cpn): Model print global and special functions (#3075)
* fix(cpn): Model print global and special functions * fix(cpn): Model print sf/gf adjust gvar abbreviate further * fix(cpn): Model print gf/sf move to table format * fix(cpn): Model print gf housekeeping
This commit is contained in:
@@ -132,8 +132,11 @@ QString CustomFunctionData::funcToString(const AssignFunc func, const ModelData
|
|||||||
|
|
||||||
QString CustomFunctionData::paramToString(const ModelData * model) const
|
QString CustomFunctionData::paramToString(const ModelData * model) const
|
||||||
{
|
{
|
||||||
|
if (!isParamAvailable())
|
||||||
|
return "";
|
||||||
|
|
||||||
QStringList qs;
|
QStringList qs;
|
||||||
if (func <= FuncInstantTrim) {
|
if ((func >= FuncOverrideCH1 && func <= FuncOverrideCHLast) || func == FuncSetScreen) {
|
||||||
return QString("%1").arg(param);
|
return QString("%1").arg(param);
|
||||||
}
|
}
|
||||||
else if (func == FuncLogs) {
|
else if (func == FuncLogs) {
|
||||||
@@ -148,12 +151,25 @@ QString CustomFunctionData::paramToString(const ModelData * model) const
|
|||||||
else if (func == FuncReset) {
|
else if (func == FuncReset) {
|
||||||
return resetToString(param, model);
|
return resetToString(param, model);
|
||||||
}
|
}
|
||||||
|
else if (func >= FuncSetTimer1 && func <= FuncSetTimerLast) {
|
||||||
|
div_t qrM = div(abs(param), 60);
|
||||||
|
div_t qrH = div(qrM.quot, 60);
|
||||||
|
|
||||||
|
QString val = QString("%1").arg(qrH.rem, 2, 10, QChar('0'));
|
||||||
|
|
||||||
|
if (qrH.quot > 0)
|
||||||
|
val.prepend(QString("%1:").arg(qrH.quot));
|
||||||
|
|
||||||
|
val.append(QString(":%1").arg(qrM.rem, 2, 10, QChar('0')));
|
||||||
|
|
||||||
|
if (param < 0)
|
||||||
|
val.prepend("-");
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
else if (func == FuncVolume || func == FuncPlayValue || func == FuncBacklight) {
|
else if (func == FuncVolume || func == FuncPlayValue || func == FuncBacklight) {
|
||||||
return RawSource(param).toString(model);
|
return RawSource(param).toString(model);
|
||||||
}
|
}
|
||||||
else if (func ==FuncSetScreen) {
|
|
||||||
return QString("%1").arg(param);
|
|
||||||
}
|
|
||||||
else if (func == FuncPlayPrompt || func == FuncPlayBoth) {
|
else if (func == FuncPlayPrompt || func == FuncPlayBoth) {
|
||||||
if ( getCurrentFirmware()->getCapability(VoicesAsNumbers)) {
|
if ( getCurrentFirmware()->getCapability(VoicesAsNumbers)) {
|
||||||
return QString("%1").arg(param);
|
return QString("%1").arg(param);
|
||||||
@@ -162,38 +178,48 @@ QString CustomFunctionData::paramToString(const ModelData * model) const
|
|||||||
return paramarm;
|
return paramarm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (func >= FuncAdjustGV1 && func < FuncCount) {
|
else if (func >= FuncAdjustGV1 && func <= FuncAdjustGVLast) {
|
||||||
switch (adjustMode) {
|
switch (adjustMode) {
|
||||||
case FUNC_ADJUST_GVAR_CONSTANT:
|
case FUNC_ADJUST_GVAR_CONSTANT:
|
||||||
return gvarAdjustModeToString(adjustMode) + QString(" %1").arg(param);
|
return QString("%1").arg(param);
|
||||||
case FUNC_ADJUST_GVAR_SOURCE:
|
case FUNC_ADJUST_GVAR_SOURCE:
|
||||||
case FUNC_ADJUST_GVAR_GVAR:
|
case FUNC_ADJUST_GVAR_GVAR:
|
||||||
return RawSource(param).toString();
|
return RawSource(param).toString();
|
||||||
case FUNC_ADJUST_GVAR_INCDEC:
|
case FUNC_ADJUST_GVAR_INCDEC:
|
||||||
const float val = param * model->gvarData[func - FuncAdjustGV1].multiplierGet();
|
const float val = param * model->gvarData[func - FuncAdjustGV1].multiplierGet();
|
||||||
const QString unit = model->gvarData[func - FuncAdjustGV1].unitToString();
|
const QString unit = model->gvarData[func - FuncAdjustGV1].unitToString();
|
||||||
return gvarAdjustModeToString(adjustMode) + QString(": %1%2").arg(val).arg(unit);
|
return QString("%1= %2%3").arg(val < 0 ? "-" : "+").arg(abs(val)).arg(unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CustomFunctionData::repeatToString() const
|
QString CustomFunctionData::repeatToString(const bool abbrev) const
|
||||||
{
|
{
|
||||||
return repeatToString(repeatParam);
|
return repeatToString(repeatParam, func, abbrev);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
QString CustomFunctionData::repeatToString(const int value)
|
QString CustomFunctionData::repeatToString(const int value, const AssignFunc func, const bool abbrev)
|
||||||
|
{
|
||||||
|
if (!isRepeatParamAvailable(func))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
return repeatToString(value, abbrev);
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
QString CustomFunctionData::repeatToString(const int value, const bool abbrev)
|
||||||
{
|
{
|
||||||
if (value == -1) {
|
if (value == -1) {
|
||||||
return tr("Played once, not during startup");
|
return abbrev ? tr("!1x") : tr("Played once, not during startup");
|
||||||
}
|
}
|
||||||
else if (value == 0) {
|
else if (value == 0) {
|
||||||
return tr("No repeat");
|
return abbrev ? tr("1x") : tr("No repeat");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return tr("Repeat %1s").arg(value);
|
return abbrev ? tr("%1s").arg(value) : tr("Repeat %1s").arg(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,7 +387,7 @@ AbstractStaticItemModel * CustomFunctionData::repeatItemModel()
|
|||||||
mdl->setName("customfunctiondata.repeat");
|
mdl->setName("customfunctiondata.repeat");
|
||||||
|
|
||||||
for (int i = -1; i <= 60; i++) {
|
for (int i = -1; i <= 60; i++) {
|
||||||
mdl->appendToItemList(repeatToString(i), i);
|
mdl->appendToItemList(repeatToString(i, false), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
mdl->loadItemList();
|
mdl->loadItemList();
|
||||||
@@ -409,3 +435,49 @@ AbstractStaticItemModel * CustomFunctionData::gvarAdjustModeItemModel()
|
|||||||
mdl->loadItemList();
|
mdl->loadItemList();
|
||||||
return mdl;
|
return mdl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CustomFunctionData::isParamAvailable() const
|
||||||
|
{
|
||||||
|
// not available list
|
||||||
|
const QList<AssignFunc> funcList = {
|
||||||
|
FuncTrainer,
|
||||||
|
FuncTrainerRUD,
|
||||||
|
FuncTrainerELE,
|
||||||
|
FuncTrainerTHR,
|
||||||
|
FuncTrainerAIL,
|
||||||
|
FuncTrainerChannels,
|
||||||
|
FuncInstantTrim,
|
||||||
|
FuncVario,
|
||||||
|
FuncScreenshot,
|
||||||
|
FuncBackgroundMusicPause,
|
||||||
|
FuncSetFailsafe,
|
||||||
|
FuncRangeCheckInternalModule,
|
||||||
|
FuncRangeCheckExternalModule,
|
||||||
|
FuncBindInternalModule,
|
||||||
|
FuncBindExternalModule,
|
||||||
|
FuncRacingMode,
|
||||||
|
FuncDisableTouch
|
||||||
|
};
|
||||||
|
|
||||||
|
return funcList.contains(func) ? false : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CustomFunctionData::isRepeatParamAvailable() const
|
||||||
|
{
|
||||||
|
return isRepeatParamAvailable(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
bool CustomFunctionData::isRepeatParamAvailable(const AssignFunc func)
|
||||||
|
{
|
||||||
|
const QList<AssignFunc> funcList = {
|
||||||
|
FuncPlaySound,
|
||||||
|
FuncPlayHaptic,
|
||||||
|
FuncPlayValue,
|
||||||
|
FuncPlayPrompt,
|
||||||
|
FuncPlayBoth,
|
||||||
|
FuncSetScreen
|
||||||
|
};
|
||||||
|
|
||||||
|
return funcList.contains(func) ? true : false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -112,11 +112,13 @@ class CustomFunctionData {
|
|||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
QString funcToString(const ModelData * model = nullptr) const;
|
QString funcToString(const ModelData * model = nullptr) const;
|
||||||
QString paramToString(const ModelData * model = nullptr) const;
|
QString paramToString(const ModelData * model = nullptr) const;
|
||||||
QString repeatToString() const;
|
QString repeatToString(const bool abbrev) const;
|
||||||
QString enabledToString() const;
|
QString enabledToString() const;
|
||||||
QString playSoundToString() const;
|
QString playSoundToString() const;
|
||||||
QString harpicToString() const;
|
QString harpicToString() const;
|
||||||
QString gvarAdjustModeToString() const;
|
QString gvarAdjustModeToString() const;
|
||||||
|
bool isRepeatParamAvailable() const;
|
||||||
|
bool isParamAvailable() const;
|
||||||
|
|
||||||
static QString nameToString(const int index, const bool globalContext = false);
|
static QString nameToString(const int index, const bool globalContext = false);
|
||||||
static QString funcToString(const AssignFunc func, const ModelData * model = nullptr);
|
static QString funcToString(const AssignFunc func, const ModelData * model = nullptr);
|
||||||
@@ -125,7 +127,9 @@ class CustomFunctionData {
|
|||||||
static QString resetToString(const int value, const ModelData * model = nullptr);
|
static QString resetToString(const int value, const ModelData * model = nullptr);
|
||||||
static int resetParamCount();
|
static int resetParamCount();
|
||||||
static bool isResetParamAvailable(const int index, const ModelData * model = nullptr);
|
static bool isResetParamAvailable(const int index, const ModelData * model = nullptr);
|
||||||
static QString repeatToString(const int value);
|
static QString repeatToString(const int value, const AssignFunc func, const bool abbrev);
|
||||||
|
static QString repeatToString(const int value, const bool abbrev);
|
||||||
|
static bool isRepeatParamAvailable(const AssignFunc func);
|
||||||
static QStringList playSoundStringList();
|
static QStringList playSoundStringList();
|
||||||
static QString playSoundToString(const int value);
|
static QString playSoundToString(const int value);
|
||||||
static QString harpicToString(const int value);
|
static QString harpicToString(const int value);
|
||||||
|
|||||||
@@ -619,30 +619,6 @@ QString ModelPrinter::printLogicalSwitchLine(int idx)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ModelPrinter::printCustomFunctionLine(int idx, bool gfunc)
|
|
||||||
{
|
|
||||||
QString result;
|
|
||||||
CustomFunctionData cf;
|
|
||||||
if (gfunc) {
|
|
||||||
if (model.noGlobalFunctions)
|
|
||||||
return result;
|
|
||||||
cf = generalSettings.customFn[idx];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
cf = model.customFn[idx];
|
|
||||||
if (cf.swtch.type == SWITCH_TYPE_NONE)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
result += cf.swtch.toString(getCurrentBoard(), &generalSettings) + " - ";
|
|
||||||
result += cf.funcToString(&model) + " (";
|
|
||||||
result += cf.paramToString(&model) + ")";
|
|
||||||
if (!cf.repeatToString().isEmpty())
|
|
||||||
result += " " + cf.repeatToString();
|
|
||||||
if (!cf.enabledToString().isEmpty())
|
|
||||||
result += " " + cf.enabledToString();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ModelPrinter::printCurveName(int idx)
|
QString ModelPrinter::printCurveName(int idx)
|
||||||
{
|
{
|
||||||
return model.curves[idx].nameToString(idx).toHtmlEscaped();
|
return model.curves[idx].nameToString(idx).toHtmlEscaped();
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ class ModelPrinter: public QObject
|
|||||||
QString printInputLine(const ExpoData & ed);
|
QString printInputLine(const ExpoData & ed);
|
||||||
QString printMixerLine(const MixData & md, bool showMultiplex, int highlightedSource = 0);
|
QString printMixerLine(const MixData & md, bool showMultiplex, int highlightedSource = 0);
|
||||||
QString printLogicalSwitchLine(int idx);
|
QString printLogicalSwitchLine(int idx);
|
||||||
QString printCustomFunctionLine(int idx, bool gfunc = false);
|
|
||||||
QString printChannelName(int idx);
|
QString printChannelName(int idx);
|
||||||
QString printCurveName(int idx);
|
QString printCurveName(int idx);
|
||||||
QString printCurve(int idx);
|
QString printCurve(int idx);
|
||||||
@@ -103,6 +102,7 @@ class ModelPrinter: public QObject
|
|||||||
QString printTelemetryScreenType(unsigned int val);
|
QString printTelemetryScreenType(unsigned int val);
|
||||||
QString printTelemetryScreen(unsigned int idx, unsigned int line, unsigned int width);
|
QString printTelemetryScreen(unsigned int idx, unsigned int line, unsigned int width);
|
||||||
QString printChecklist();
|
QString printChecklist();
|
||||||
|
const GeneralSettings * gs() { return &generalSettings; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Firmware * firmware;
|
Firmware * firmware;
|
||||||
|
|||||||
@@ -190,7 +190,8 @@ void MultiModelPrinter::MultiColumns::appendFieldSeparator(const bool sep)
|
|||||||
for (int cc=0; cc < modelPrinterMap.size(); cc++) { \
|
for (int cc=0; cc < modelPrinterMap.size(); cc++) { \
|
||||||
ModelPrinter * modelPrinter = modelPrinterMap.value(cc).second; \
|
ModelPrinter * modelPrinter = modelPrinterMap.value(cc).second; \
|
||||||
const ModelData * model = modelPrinterMap.value(cc).first; \
|
const ModelData * model = modelPrinterMap.value(cc).first; \
|
||||||
(void)(model); (void)(modelPrinter); \
|
const GeneralSettings * generalSettings = modelPrinter->gs(); \
|
||||||
|
(void)(model); (void)(modelPrinter); (void)(generalSettings); \
|
||||||
columns.append(cc, (what)); \
|
columns.append(cc, (what)); \
|
||||||
} \
|
} \
|
||||||
columns.endCompare();
|
columns.endCompare();
|
||||||
@@ -729,6 +730,8 @@ QString MultiModelPrinter::printSpecialFunctions()
|
|||||||
MultiColumns columns(modelPrinterMap.size());
|
MultiColumns columns(modelPrinterMap.size());
|
||||||
int count = 0;
|
int count = 0;
|
||||||
columns.appendSectionTableStart();
|
columns.appendSectionTableStart();
|
||||||
|
columns.appendRowHeader(QStringList() << "" << tr("Switch") << tr("Function") << tr("Parameters") << tr("Repeat") << tr("Enabled"));
|
||||||
|
|
||||||
for (int i=0; i < firmware->getCapability(CustomFunctions); i++) {
|
for (int i=0; i < firmware->getCapability(CustomFunctions); i++) {
|
||||||
bool sfEmpty = true;
|
bool sfEmpty = true;
|
||||||
for (int k=0; k < modelPrinterMap.size(); k++) {
|
for (int k=0; k < modelPrinterMap.size(); k++) {
|
||||||
@@ -739,8 +742,12 @@ QString MultiModelPrinter::printSpecialFunctions()
|
|||||||
}
|
}
|
||||||
if (!sfEmpty) {
|
if (!sfEmpty) {
|
||||||
count++;
|
count++;
|
||||||
columns.appendRowStart(tr("SF%1").arg(i+1), 20);
|
columns.appendRowStart(tr("SF%1").arg(i + 1), 20);
|
||||||
COMPARECELL(modelPrinter->printCustomFunctionLine(i));
|
COMPARECELLWIDTH(!model->customFn[i].isEmpty() ? model->customFn[i].swtch.toString(getCurrentBoard(), &defaultSettings, model) : "", 10);
|
||||||
|
COMPARECELLWIDTH(!model->customFn[i].isEmpty() ? model->customFn[i].funcToString(model) : "", 20);
|
||||||
|
COMPARECELLWIDTH(!model->customFn[i].isEmpty() ? model->customFn[i].paramToString(model) : "", 20);
|
||||||
|
COMPARECELLWIDTH(!model->customFn[i].isEmpty() ? model->customFn[i].repeatToString(true) : "", 10);
|
||||||
|
COMPARECELLWIDTH(!model->customFn[i].isEmpty() ? DataHelpers::boolToString(model->customFn[i].enabled, DataHelpers::BOOL_FMT_YN) : "", 10);
|
||||||
columns.appendRowEnd();
|
columns.appendRowEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -894,6 +901,7 @@ QString MultiModelPrinter::printGlobalFunctions()
|
|||||||
int idx = -1;
|
int idx = -1;
|
||||||
MultiColumns columns(modelPrinterMap.size());
|
MultiColumns columns(modelPrinterMap.size());
|
||||||
columns.appendSectionTableStart();
|
columns.appendSectionTableStart();
|
||||||
|
columns.appendRowHeader(QStringList() << "" << tr("Switch") << tr("Function") << tr("Parameters") << tr("Repeat") << tr("Enabled"));
|
||||||
|
|
||||||
for (int k=0; k < modelPrinterMap.size(); k++) {
|
for (int k=0; k < modelPrinterMap.size(); k++) {
|
||||||
if (!modelPrinterMap.value(k).first->noGlobalFunctions) {
|
if (!modelPrinterMap.value(k).first->noGlobalFunctions) {
|
||||||
@@ -904,13 +912,18 @@ QString MultiModelPrinter::printGlobalFunctions()
|
|||||||
|
|
||||||
if (idx > -1) {
|
if (idx > -1) {
|
||||||
ModelPrinter * modelPrinter = modelPrinterMap.value(idx).second;
|
ModelPrinter * modelPrinter = modelPrinterMap.value(idx).second;
|
||||||
(void)(modelPrinter);
|
const GeneralSettings * generalSettings = modelPrinter->gs();
|
||||||
|
|
||||||
for (int i=0; i < firmware->getCapability(GlobalFunctions); i++) {
|
for (int i = 0; i < firmware->getCapability(GlobalFunctions); i++) {
|
||||||
txt = modelPrinter->printCustomFunctionLine(i, true);
|
if (!generalSettings->customFn[i].isEmpty()) {
|
||||||
if (!txt.isEmpty()) {
|
|
||||||
count++;
|
count++;
|
||||||
ROWLABELCOMPARECELL(tr("GF%1").arg(i+1), 20, modelPrinter->printCustomFunctionLine(i, true), 80);
|
columns.appendRowStart(tr("GF%1").arg(i + 1), 20);
|
||||||
|
COMPARECELLWIDTH(generalSettings->customFn[i].swtch.toString(getCurrentBoard(), &defaultSettings), 10);
|
||||||
|
COMPARECELLWIDTH(generalSettings->customFn[i].funcToString(), 20);
|
||||||
|
COMPARECELLWIDTH(generalSettings->customFn[i].paramToString(), 20);
|
||||||
|
COMPARECELLWIDTH(generalSettings->customFn[i].repeatToString(true), 10);
|
||||||
|
COMPARECELLWIDTH(DataHelpers::boolToString(generalSettings->customFn[i].enabled, DataHelpers::BOOL_FMT_YN), 10);
|
||||||
|
columns.appendRowEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
columns.appendTableEnd();
|
columns.appendTableEnd();
|
||||||
@@ -942,8 +955,7 @@ QString MultiModelPrinter::printChecklist()
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MultiModelPrinter::printFunctionSwitches()
|
||||||
QString MultiModelPrinter::printFunctionSwitches()
|
|
||||||
{
|
{
|
||||||
QString str;
|
QString str;
|
||||||
MultiColumns columns(modelPrinterMap.size());
|
MultiColumns columns(modelPrinterMap.size());
|
||||||
|
|||||||
Reference in New Issue
Block a user