19 files changed +481
-21
lines changed Original file line number Diff line number Diff line change 10
10
<file>images/track.png</file>
11
11
<file>images/track0.png</file>
12
12
<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>
13
16
<file>images/simulator/icons/svg/arrow_click.svg</file>
14
17
<file>images/simulator/icons/svg/camera.svg</file>
15
18
<file>images/simulator/icons/svg/camera-active.svg</file>
Original file line number Diff line number Diff line change 29
29
#include " adjustmentreference.h"
30
30
#include " compounditemmodels.h"
31
31
32
+ #include < QMessageBox>
33
+
32
34
ModelData::ModelData ()
33
35
{
34
36
clear ();
@@ -1924,3 +1926,61 @@ int ModelData::getCustomScreensCount() const
1924
1926
1925
1927
return cnt;
1926
1928
}
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
+ }
Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ class ModelData {
140
140
char labels[100 ];
141
141
int modelIndex; // Companion only, temporary index position managed by data model.
142
142
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
143
144
144
145
TimerData timers[CPN_MAX_TIMERS];
145
146
bool noGlobalFunctions;
@@ -366,11 +367,18 @@ class ModelData {
366
367
static AbstractStaticItemModel * funcSwitchStartItemModel ();
367
368
368
369
int getCustomScreensCount () const ;
370
+ bool hasErrors () { return modelErrors; }
371
+ bool isValid () { return !hasErrors (); }
372
+ void validate ();
373
+ QStringList errorsList ();
369
374
370
375
protected:
371
376
void removeGlobalVar (int & var);
372
377
373
378
private:
379
+ int getMixLine (int index) const ;
380
+ int getInputLine (int index) const ;
381
+
374
382
QVector<UpdateReferenceParams> *updRefList = nullptr ;
375
383
376
384
struct UpdateReferenceInfo
Original file line number Diff line number Diff line change @@ -343,3 +343,19 @@ AbstractStaticItemModel * RadioData::modelSortOrderItemModel()
343
343
mdl->loadItemList ();
344
344
return mdl;
345
345
}
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
+ }
Original file line number Diff line number Diff line change @@ -66,6 +66,8 @@ class RadioData {
66
66
void setCurrentModel (unsigned int index);
67
67
void fixModelFilenames ();
68
68
QString getNextModelFilename ();
69
+ void validateModels ();
70
+ int invalidModels ();
69
71
70
72
static QString modelSortOrderToString (int value);
71
73
static AbstractStaticItemModel * modelSortOrderItemModel ();
0 commit comments