Skip to content

Commit ec3c5bf

Browse files
authoredFeb 6, 2025
fix(cpn): inputs and mixes must have source (#5798)
1 parent 0325bd7 commit ec3c5bf

19 files changed

+481
-21
lines changed
 

‎companion/src/companion.qrc

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<file>images/track.png</file>
1111
<file>images/track0.png</file>
1212
<file>images/taranison.png</file>
13+
<file>images/svg/circle-green.svg</file>
14+
<file>images/svg/circle-orange.svg</file>
15+
<file>images/svg/circle-red.svg</file>
1316
<file>images/simulator/icons/svg/arrow_click.svg</file>
1417
<file>images/simulator/icons/svg/camera.svg</file>
1518
<file>images/simulator/icons/svg/camera-active.svg</file>

‎companion/src/firmwares/modeldata.cpp

+60
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "adjustmentreference.h"
3030
#include "compounditemmodels.h"
3131

32+
#include <QMessageBox>
33+
3234
ModelData::ModelData()
3335
{
3436
clear();
@@ -1924,3 +1926,61 @@ int ModelData::getCustomScreensCount() const
19241926

19251927
return cnt;
19261928
}
1929+
1930+
void ModelData::validate()
1931+
{
1932+
modelErrors = false;
1933+
1934+
for (int i = 0; i < CPN_MAX_INPUTS; i++) {
1935+
if (!expoData[i].isEmpty() && expoData[i].srcRaw == SOURCE_TYPE_NONE) {
1936+
modelErrors = true;
1937+
return;
1938+
}
1939+
}
1940+
1941+
for (int i = 0; i < CPN_MAX_MIXERS; i++) {
1942+
if (!mixData[i].isEmpty() && mixData[i].srcRaw == SOURCE_TYPE_NONE) {
1943+
modelErrors = true;
1944+
return;
1945+
}
1946+
}
1947+
}
1948+
1949+
QStringList ModelData::errorsList()
1950+
{
1951+
QStringList list;
1952+
1953+
for (int i = 0; i < CPN_MAX_INPUTS; i++) {
1954+
if (!expoData[i].isEmpty() && expoData[i].srcRaw == SOURCE_TYPE_NONE)
1955+
list.append(tr("Error - Input %1 Line %2 %3").arg(expoData[i].chn + 1).arg(getInputLine(i)).arg(tr("has no source")));
1956+
}
1957+
1958+
for (int i = 0; i < CPN_MAX_MIXERS; i++) {
1959+
if (!mixData[i].isEmpty() && mixData[i].srcRaw == SOURCE_TYPE_NONE)
1960+
list.append(tr("Error - Mix %1 Line %2 %3").arg(mixData[i].destCh).arg(getMixLine(i)).arg(tr("has no source")));
1961+
}
1962+
1963+
return list;
1964+
}
1965+
1966+
int ModelData::getMixLine(int index) const
1967+
{
1968+
int cnt = 1;
1969+
1970+
for (int i = index - 1; i >= 0 && mixData[i].destCh == mixData[index].destCh; i--)
1971+
cnt++;
1972+
1973+
return cnt;
1974+
}
1975+
1976+
int ModelData::getInputLine(int index) const
1977+
{
1978+
int cnt = 1;
1979+
1980+
for (int i = 0; i < index; i++) {
1981+
if (expoData[i].chn == expoData[index].chn)
1982+
cnt++;
1983+
}
1984+
1985+
return cnt;
1986+
}

‎companion/src/firmwares/modeldata.h

+8
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class ModelData {
140140
char labels[100];
141141
int modelIndex; // Companion only, temporary index position managed by data model.
142142
bool modelUpdated; // Companion only, used to highlight if changed in models list
143+
bool modelErrors; // Companion only, used to highlight if data errors in models list
143144

144145
TimerData timers[CPN_MAX_TIMERS];
145146
bool noGlobalFunctions;
@@ -366,11 +367,18 @@ class ModelData {
366367
static AbstractStaticItemModel * funcSwitchStartItemModel();
367368

368369
int getCustomScreensCount() const;
370+
bool hasErrors() { return modelErrors; }
371+
bool isValid() { return !hasErrors(); }
372+
void validate();
373+
QStringList errorsList();
369374

370375
protected:
371376
void removeGlobalVar(int & var);
372377

373378
private:
379+
int getMixLine(int index) const;
380+
int getInputLine(int index) const;
381+
374382
QVector<UpdateReferenceParams> *updRefList = nullptr;
375383

376384
struct UpdateReferenceInfo

‎companion/src/firmwares/radiodata.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,19 @@ AbstractStaticItemModel * RadioData::modelSortOrderItemModel()
343343
mdl->loadItemList();
344344
return mdl;
345345
}
346+
347+
void RadioData::validateModels()
348+
{
349+
for(auto &model: models)
350+
model.validate();
351+
}
352+
353+
int RadioData::invalidModels()
354+
{
355+
int cnt = 0;
356+
357+
for(auto &model: models)
358+
cnt += model.isValid() ? 0 : 1;
359+
360+
return cnt;
361+
}

‎companion/src/firmwares/radiodata.h

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class RadioData {
6666
void setCurrentModel(unsigned int index);
6767
void fixModelFilenames();
6868
QString getNextModelFilename();
69+
void validateModels();
70+
int invalidModels();
6971

7072
static QString modelSortOrderToString(int value);
7173
static AbstractStaticItemModel * modelSortOrderItemModel();
Loading
Loading
Loading
+48
Loading
+48
Loading

0 commit comments

Comments
 (0)
Failed to load comments.