| 136 |
- |
1 |
#include "qmdatacheck.h"
|
|
|
2 |
#include "ui_qmdatacheck.h"
|
| 139 |
david |
3 |
#include "consts.h"
|
|
|
4 |
#include "structs.h"
|
|
|
5 |
#include "proto.h"
|
|
|
6 |
#include "QString"
|
|
|
7 |
#include "mainwindow.h"
|
|
|
8 |
#include "qmdialogteameditor.h"
|
| 136 |
- |
9 |
|
| 139 |
david |
10 |
const char *qck_err_mess[] = {
|
|
|
11 |
"No error",
|
|
|
12 |
"Invalid start time",
|
|
|
13 |
"Invalid end time",
|
|
|
14 |
"End before start",
|
| 240 |
- |
15 |
"Team data not entered",
|
| 278 |
david |
16 |
"NE with named competitor" // No longer used
|
| 139 |
david |
17 |
};
|
|
|
18 |
|
| 136 |
- |
19 |
qmDataCheck::qmDataCheck(QWidget *parent) :
|
| 278 |
david |
20 |
QWidget(parent)
|
| 136 |
- |
21 |
{
|
| 139 |
david |
22 |
|
| 278 |
david |
23 |
resize ( 600,400);
|
| 139 |
david |
24 |
|
| 278 |
david |
25 |
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
|
|
|
26 |
verticalLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
27 |
|
|
|
28 |
QGroupBox *groupBox = new QGroupBox("Data Check");
|
|
|
29 |
verticalLayout->addWidget(groupBox);
|
|
|
30 |
|
|
|
31 |
QVBoxLayout *verticalLayout2 = new QVBoxLayout(groupBox);
|
|
|
32 |
|
|
|
33 |
listWidget = new QListWidget(groupBox);
|
|
|
34 |
verticalLayout2->addWidget(listWidget);
|
|
|
35 |
|
|
|
36 |
QHBoxLayout *horizontalLayout;
|
|
|
37 |
horizontalLayout = new QHBoxLayout();
|
|
|
38 |
horizontalLayout->setContentsMargins(0, 0, 0, 5);
|
|
|
39 |
|
|
|
40 |
QGroupBox *groupBox2 = new QGroupBox("Tests");
|
|
|
41 |
verticalLayout2->addLayout(horizontalLayout);
|
|
|
42 |
horizontalLayout->addWidget(groupBox2);
|
|
|
43 |
|
|
|
44 |
QHBoxLayout *horizontalLayout1;
|
|
|
45 |
QSpacerItem *horizontalSpacer1;
|
|
|
46 |
|
|
|
47 |
horizontalLayout1 = new QHBoxLayout();
|
|
|
48 |
horizontalLayout1->setContentsMargins(5, 5, 5, 5);
|
|
|
49 |
groupBox2->setLayout(horizontalLayout1);
|
|
|
50 |
groupBox2->setToolTip("Enable Tests to be performed");
|
|
|
51 |
|
|
|
52 |
cb1 = new QCheckBox("Disq");
|
|
|
53 |
cb1->setChecked(true);
|
|
|
54 |
horizontalLayout1->addWidget(cb1);
|
|
|
55 |
|
|
|
56 |
// cb_ne = new QCheckBox("Non Equest");
|
|
|
57 |
// cb_ne->setTristate(true);
|
|
|
58 |
// horizontalLayout1->addWidget(cb_ne);
|
|
|
59 |
|
|
|
60 |
// cb_enable = new QCheckBox("Enable");
|
|
|
61 |
// cb_enable->setTristate(true);
|
|
|
62 |
// horizontalLayout1->addWidget(cb_enable);
|
|
|
63 |
|
|
|
64 |
// cb_vetcheck = new QCheckBox("Vet Check");
|
|
|
65 |
// cb_vetcheck->setTristate(true);
|
|
|
66 |
// horizontalLayout1->addWidget(cb_vetcheck);
|
|
|
67 |
|
|
|
68 |
horizontalLayout1->addWidget(new QLabel("Leg"));
|
|
|
69 |
leg = new QmTeamSelector();
|
|
|
70 |
horizontalLayout1->addWidget(leg);
|
|
|
71 |
|
|
|
72 |
horizontalSpacer1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
|
|
73 |
horizontalLayout1->addItem(horizontalSpacer1);
|
|
|
74 |
|
|
|
75 |
buttonBox = new QDialogButtonBox();
|
|
|
76 |
pb_check = buttonBox->addButton("Check",QDialogButtonBox::ActionRole );
|
|
|
77 |
pb_cancel = buttonBox->addButton("Clear",QDialogButtonBox::ActionRole );
|
|
|
78 |
horizontalLayout->addWidget(buttonBox);
|
|
|
79 |
|
|
|
80 |
leg->setMinimum(0);
|
|
|
81 |
leg->setMaximum(config.num_legs);
|
|
|
82 |
leg->setValue(config.num_legs);
|
|
|
83 |
|
|
|
84 |
connect(pb_check, SIGNAL(clicked()), this, SLOT(populate()));
|
|
|
85 |
connect(pb_cancel, SIGNAL(clicked()), this, SLOT(cancel()) );
|
|
|
86 |
connect(listWidget,SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(selected(QListWidgetItem *)));
|
| 136 |
- |
87 |
}
|
|
|
88 |
|
|
|
89 |
qmDataCheck::~qmDataCheck()
|
|
|
90 |
{
|
| 278 |
david |
91 |
|
| 136 |
- |
92 |
}
|
| 139 |
david |
93 |
|
| 260 |
- |
94 |
/*----------------------------------------------------------------------------
|
|
|
95 |
** FUNCTION : addItem
|
|
|
96 |
**
|
|
|
97 |
** DESCRIPTION : Add an entry to the list of errored items
|
|
|
98 |
**
|
|
|
99 |
**
|
|
|
100 |
** INPUTS : team - Team
|
|
|
101 |
** leg - May be 0
|
|
|
102 |
** msg - Text error message
|
|
|
103 |
**
|
|
|
104 |
** RETURNS : Nothing
|
|
|
105 |
**
|
|
|
106 |
----------------------------------------------------------------------------*/
|
|
|
107 |
|
|
|
108 |
void qmDataCheck::addItem(int team, int leg, QString msg)
|
|
|
109 |
{
|
|
|
110 |
qmDataCheckItem *item = new qmDataCheckItem(team, leg);
|
|
|
111 |
item->setData(Qt::EditRole, msg);
|
| 278 |
david |
112 |
listWidget->addItem(item);
|
| 260 |
- |
113 |
}
|
|
|
114 |
|
| 139 |
david |
115 |
void qmDataCheck::populate(void)
|
|
|
116 |
{
|
| 278 |
david |
117 |
int leg_end = leg->value();
|
| 260 |
- |
118 |
if ( leg_end < 0 || leg_end > config.num_legs)
|
| 139 |
david |
119 |
{
|
|
|
120 |
MainWindow::showMessage("Bad Leg Number selected");
|
|
|
121 |
return;
|
|
|
122 |
}
|
| 278 |
david |
123 |
listWidget->clear();
|
| 139 |
david |
124 |
|
|
|
125 |
/*
|
|
|
126 |
* Start the testing
|
|
|
127 |
* Read each team into memory and start the testing
|
|
|
128 |
*/
|
|
|
129 |
int count_bad = 0;
|
|
|
130 |
for( int tm = config.min_team; tm <= config.max_team; tm++ )
|
|
|
131 |
{
|
| 260 |
- |
132 |
int badData = 0;
|
| 139 |
david |
133 |
team_type team_buf;
|
|
|
134 |
if( valid_field( tm ) )
|
|
|
135 |
{
|
|
|
136 |
g_record( tm, &team_buf );
|
| 256 |
- |
137 |
if ( !team_buf.flags.disqualified && team_buf.flags.valid)
|
| 139 |
david |
138 |
{
|
| 260 |
- |
139 |
// Test for class not defined
|
|
|
140 |
if ( team_buf.teamclass <= 0)
|
| 240 |
- |
141 |
{
|
| 260 |
- |
142 |
addItem(tm, 0, QString("Team %1, No Class specified").arg(QString::number(tm) ) );
|
|
|
143 |
badData = 1;
|
| 240 |
- |
144 |
}
|
| 260 |
- |
145 |
|
|
|
146 |
if ( strlen (team_buf.name) <= 0)
|
|
|
147 |
{
|
|
|
148 |
addItem(tm, 0, QString("Team %1, No Team Name specified").arg(QString::number(tm) ) );
|
|
|
149 |
badData = 1;
|
|
|
150 |
}
|
|
|
151 |
|
| 276 |
david |
152 |
// Test for NE Team with a team name
|
|
|
153 |
if ( team_buf.flags.non_equestrian && config.equestrian_leg )
|
|
|
154 |
{
|
|
|
155 |
int neindex = config.equestrian_leg - 1;
|
|
|
156 |
char *nptr = team_buf.members[neindex].name;
|
|
|
157 |
|
| 277 |
david |
158 |
// Ignore allowed NE names
|
|
|
159 |
if ( *nptr && strcmp(nptr, "0") != 0
|
|
|
160 |
&& strcmp(nptr, "-") != 0
|
|
|
161 |
&& stricmp(nptr, "N/A") != 0 )
|
| 276 |
david |
162 |
{
|
|
|
163 |
addItem(tm, 0, QString("Team %1, NE with named competitor: %2").arg(QString::number(tm)).arg(nptr) );
|
|
|
164 |
badData = 1;
|
|
|
165 |
}
|
|
|
166 |
}
|
|
|
167 |
|
| 260 |
- |
168 |
// Test Leg Data if required
|
|
|
169 |
if (leg_end)
|
|
|
170 |
{
|
|
|
171 |
test_times( &team_buf, leg_end );
|
|
|
172 |
if( check_error.type > 0 )
|
|
|
173 |
{
|
|
|
174 |
addItem(tm, check_error.leg, QString("Team %1, Leg %2: %3").arg(QString::number(tm)).arg(QString::number(check_error.leg)).arg(qck_err_mess[check_error.type]));
|
|
|
175 |
badData = 1;
|
|
|
176 |
}
|
|
|
177 |
}
|
| 139 |
david |
178 |
}
|
|
|
179 |
}
|
| 260 |
- |
180 |
else
|
|
|
181 |
{
|
|
|
182 |
//
|
|
|
183 |
// Team not within the configured range
|
|
|
184 |
// Warn if the team has time data - may be a miss configuration
|
|
|
185 |
//
|
|
|
186 |
int i;
|
|
|
187 |
g_record( tm, &team_buf );
|
|
|
188 |
for( i = 0; i <= config.num_legs; i++ )
|
|
|
189 |
{
|
|
|
190 |
if ( team_buf.leg[i].start > 0 || team_buf.leg[i].end > 0 )
|
|
|
191 |
{
|
|
|
192 |
addItem(tm, 0, QString("Team %1, Unconfigured team has time information").arg(QString::number(tm) ) );
|
|
|
193 |
badData = 1;
|
|
|
194 |
break;
|
|
|
195 |
}
|
|
|
196 |
}
|
|
|
197 |
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
//
|
|
|
201 |
// Count teams with wonky data
|
|
|
202 |
//
|
|
|
203 |
if (badData)
|
|
|
204 |
count_bad++;
|
| 139 |
david |
205 |
}
|
|
|
206 |
if( count_bad )
|
|
|
207 |
MainWindow::showMessage(QString("%1 teams with inconsistent data").arg(count_bad));
|
|
|
208 |
else
|
|
|
209 |
MainWindow::showMessage("All team data correct");
|
|
|
210 |
}
|
|
|
211 |
|
|
|
212 |
void qmDataCheck::cancel(void)
|
|
|
213 |
{
|
| 278 |
david |
214 |
listWidget->clear();
|
| 139 |
david |
215 |
}
|
|
|
216 |
|
|
|
217 |
void qmDataCheck::selected(QListWidgetItem *item)
|
|
|
218 |
{
|
| 260 |
- |
219 |
//qDebug("Item selected");
|
| 139 |
david |
220 |
qmDataCheckItem *myitem = dynamic_cast<qmDataCheckItem *>(item);
|
|
|
221 |
if ( myitem )
|
|
|
222 |
{
|
| 260 |
- |
223 |
//qDebug(" Team:%d, Leg: %d", myitem->team, myitem->leg);
|
| 139 |
david |
224 |
qmDialogTeamEditor dialog(myitem->team, this);
|
|
|
225 |
dialog.exec();
|
|
|
226 |
}
|
|
|
227 |
}
|
|
|
228 |
|