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
|
||||
{
|
||||
if (!isParamAvailable())
|
||||
return "";
|
||||
|
||||
QStringList qs;
|
||||
if (func <= FuncInstantTrim) {
|
||||
if ((func >= FuncOverrideCH1 && func <= FuncOverrideCHLast) || func == FuncSetScreen) {
|
||||
return QString("%1").arg(param);
|
||||
}
|
||||
else if (func == FuncLogs) {
|
||||
@@ -148,12 +151,25 @@ QString CustomFunctionData::paramToString(const ModelData * model) const
|
||||
else if (func == FuncReset) {
|
||||
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) {
|
||||
return RawSource(param).toString(model);
|
||||
}
|
||||
else if (func ==FuncSetScreen) {
|
||||
return QString("%1").arg(param);
|
||||
}
|
||||
else if (func == FuncPlayPrompt || func == FuncPlayBoth) {
|
||||
if ( getCurrentFirmware()->getCapability(VoicesAsNumbers)) {
|
||||
return QString("%1").arg(param);
|
||||
@@ -162,38 +178,48 @@ QString CustomFunctionData::paramToString(const ModelData * model) const
|
||||
return paramarm;
|
||||
}
|
||||
}
|
||||
else if (func >= FuncAdjustGV1 && func < FuncCount) {
|
||||
else if (func >= FuncAdjustGV1 && func <= FuncAdjustGVLast) {
|
||||
switch (adjustMode) {
|
||||
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_GVAR:
|
||||
return RawSource(param).toString();
|
||||
case FUNC_ADJUST_GVAR_INCDEC:
|
||||
const float val = param * model->gvarData[func - FuncAdjustGV1].multiplierGet();
|
||||
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 "";
|
||||
}
|
||||
|
||||
QString CustomFunctionData::repeatToString() const
|
||||
QString CustomFunctionData::repeatToString(const bool abbrev) const
|
||||
{
|
||||
return repeatToString(repeatParam);
|
||||
return repeatToString(repeatParam, func, abbrev);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
return tr("Played once, not during startup");
|
||||
return abbrev ? tr("!1x") : tr("Played once, not during startup");
|
||||
}
|
||||
else if (value == 0) {
|
||||
return tr("No repeat");
|
||||
return abbrev ? tr("1x") : tr("No repeat");
|
||||
}
|
||||
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");
|
||||
|
||||
for (int i = -1; i <= 60; i++) {
|
||||
mdl->appendToItemList(repeatToString(i), i);
|
||||
mdl->appendToItemList(repeatToString(i, false), i);
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
@@ -409,3 +435,49 @@ AbstractStaticItemModel * CustomFunctionData::gvarAdjustModeItemModel()
|
||||
mdl->loadItemList();
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user