Add function switches to model print and compare

This commit is contained in:
elecpower
2021-12-17 17:08:49 +01:00
committed by Raphael Coeffic
parent 9a07b83b00
commit f5b398b32c
4 changed files with 65 additions and 12 deletions
+8 -8
View File
@@ -1654,16 +1654,16 @@ AbstractStaticItemModel * ModelData::trainerModeItemModel(const GeneralSettings
return mdl; return mdl;
} }
QString ModelData::funcSwitchConfigToString(unsigned int index) const QString ModelData::funcSwitchConfigToString(const int index) const
{ {
if (index < CPN_MAX_FUNCTION_SWITCHES) if (index < CPN_MAX_FUNCTION_SWITCHES)
return funcSwitchConfigToString((functionSwitchConfig >> (2 * index)) & 0x03); return funcSwitchConfigToString(index, (int)(functionSwitchConfig >> (2 * index)) & 0x03);
else else
return CPN_STR_UNKNOWN_ITEM; return CPN_STR_UNKNOWN_ITEM;
} }
// static // static
QString ModelData::funcSwitchConfigToString(int value) QString ModelData::funcSwitchConfigToString(const int index, const int value)
{ {
switch (value) { switch (value) {
case FUNC_SWITCH_CONFIG_NONE: case FUNC_SWITCH_CONFIG_NONE:
@@ -1684,23 +1684,23 @@ AbstractStaticItemModel * ModelData::funcSwitchConfigItemModel()
mdl->setName(AIM_MODELDATA_FUNCSWITCHCONFIG); mdl->setName(AIM_MODELDATA_FUNCSWITCHCONFIG);
for (int i = FUNC_SWITCH_CONFIG_FIRST; i <= FUNC_SWITCH_CONFIG_LAST; i++) { for (int i = FUNC_SWITCH_CONFIG_FIRST; i <= FUNC_SWITCH_CONFIG_LAST; i++) {
mdl->appendToItemList(funcSwitchConfigToString(i), i); mdl->appendToItemList(funcSwitchConfigToString(0, i), i);
} }
mdl->loadItemList(); mdl->loadItemList();
return mdl; return mdl;
} }
QString ModelData::funcSwitchStartToString(unsigned int index) const QString ModelData::funcSwitchStartToString(const int index) const
{ {
if (index < CPN_MAX_FUNCTION_SWITCHES) if (index < CPN_MAX_FUNCTION_SWITCHES)
return funcSwitchStartToString((functionSwitchStartConfig >> (2 * index)) & 0x03); return funcSwitchStartToString(index, (int)(functionSwitchStartConfig >> (2 * index)) & 0x03);
else else
return CPN_STR_UNKNOWN_ITEM; return CPN_STR_UNKNOWN_ITEM;
} }
// static // static
QString ModelData::funcSwitchStartToString(int value) QString ModelData::funcSwitchStartToString(const int index, const int value)
{ {
switch (value) { switch (value) {
case FUNC_SWITCH_START_INACTIVE: case FUNC_SWITCH_START_INACTIVE:
@@ -1721,7 +1721,7 @@ AbstractStaticItemModel * ModelData::funcSwitchStartItemModel()
mdl->setName(AIM_MODELDATA_FUNCSWITCHSTART); mdl->setName(AIM_MODELDATA_FUNCSWITCHSTART);
for (int i = FUNC_SWITCH_START_FIRST; i <= FUNC_SWITCH_START_LAST; i++) { for (int i = FUNC_SWITCH_START_FIRST; i <= FUNC_SWITCH_START_LAST; i++) {
mdl->appendToItemList(funcSwitchStartToString(i), i); mdl->appendToItemList(funcSwitchStartToString(0, i), i);
} }
mdl->loadItemList(); mdl->loadItemList();
+4 -4
View File
@@ -286,11 +286,11 @@ class ModelData {
static QString trainerModeToString(const int value); static QString trainerModeToString(const int value);
static bool isTrainerModeAvailable(const GeneralSettings & generalSettings, const Firmware * firmware, const int value); static bool isTrainerModeAvailable(const GeneralSettings & generalSettings, const Firmware * firmware, const int value);
static AbstractStaticItemModel * trainerModeItemModel(const GeneralSettings & generalSettings, const Firmware * firmware); static AbstractStaticItemModel * trainerModeItemModel(const GeneralSettings & generalSettings, const Firmware * firmware);
QString funcSwitchConfigToString(unsigned int index) const; QString funcSwitchConfigToString(const int index) const;
static QString funcSwitchConfigToString(const int value); static QString funcSwitchConfigToString(const int index, const int value);
static AbstractStaticItemModel * funcSwitchConfigItemModel(); static AbstractStaticItemModel * funcSwitchConfigItemModel();
QString funcSwitchStartToString(unsigned int index) const; QString funcSwitchStartToString(const int index) const;
static QString funcSwitchStartToString(const int value); static QString funcSwitchStartToString(const int index, const int value);
static AbstractStaticItemModel * funcSwitchStartItemModel(); static AbstractStaticItemModel * funcSwitchStartItemModel();
protected: protected:
+52
View File
@@ -277,6 +277,9 @@ QString MultiModelPrinter::print(QTextDocument * document)
if (firmware->getCapability(Timers)) { if (firmware->getCapability(Timers)) {
str.append(printTimers()); str.append(printTimers());
} }
if (Boards::getCapability(firmware->getBoard(), Board::NumFunctionSwitches)) {
str.append(printFunctionSwitches());
}
str.append(printModules()); str.append(printModules());
if (firmware->getCapability(Heli)) if (firmware->getCapability(Heli))
str.append(printHeliSetup()); str.append(printHeliSetup());
@@ -938,3 +941,52 @@ QString MultiModelPrinter::printChecklist()
} }
return str; return str;
} }
QString MultiModelPrinter::printFunctionSwitches()
{
QString str;
MultiColumns columns(modelPrinterMap.size());
columns.appendSectionTableStart();
int numFS = Boards::getCapability(firmware->getBoard(), Board::NumFunctionSwitches);
int colwidth = 80 / numFS;
QStringList headings = { tr("Function Switches") };
for (int i = 0; i < numFS; i++) {
headings << tr("Switch %1").arg(i + 1);
}
columns.appendRowHeader(headings);
columns.appendRowStart(tr("Name"), 20);
for (int i = 0; i < numFS; i++) {
COMPARECELLWIDTH(model->functionSwitchNames[i], colwidth);
}
columns.appendRowEnd();
columns.appendRowStart(tr("Type"), 20);
for (int i = 0; i < numFS; i++) {
COMPARECELLWIDTH(model->funcSwitchConfigToString((unsigned int)i), colwidth);
}
columns.appendRowEnd();
columns.appendRowStart(tr("Start"), 20);
for (int i = 0; i < numFS; i++) {
COMPARECELLWIDTH(model->funcSwitchStartToString((unsigned int)i), colwidth);
}
columns.appendRowEnd();
columns.appendRowStart(tr("Group"), 20);
for (int i = 0; i < numFS; i++) {
COMPARECELLWIDTH((model->functionSwitchGroup >> (2 * i)) & 0x03, colwidth);
}
columns.appendRowEnd();
columns.appendTableEnd();
str.append(columns.print());
return str;
}
+1
View File
@@ -95,6 +95,7 @@ class MultiModelPrinter: public QObject
QString printTelemetryScreens(); QString printTelemetryScreens();
QString printGlobalFunctions(); QString printGlobalFunctions();
QString printChecklist(); QString printChecklist();
QString printFunctionSwitches();
}; };
#endif // _MULTIMODELPRINTER_H_ #endif // _MULTIMODELPRINTER_H_