Rev 244 | Rev 280 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include "qmdatacheck.h"#include "ui_qmdatacheck.h"#include "consts.h"#include "structs.h"#include "proto.h"#include "QString"#include "mainwindow.h"#include "qmdialogteameditor.h"const char *qck_err_mess[] = {"No error","Invalid start time","Invalid end time","End before start","Team data not entered","NE with named competitor"};qmDataCheck::qmDataCheck(QWidget *parent) :QWidget(parent),ui(new Ui::qmDataCheck){ui->setupUi(this);ui->leg->setMinimum(1);ui->leg->setMaximum(config.num_legs);ui->leg->setValue(config.num_legs);connect( ui->buttonBox, SIGNAL(accepted()), this, SLOT(populate()));connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(cancel()) );connect(ui->listWidget,SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(selected(QListWidgetItem *)));}qmDataCheck::~qmDataCheck(){delete ui;}void qmDataCheck::populate(void){int leg_end = ui->leg->value();if ( leg_end <= 0 || leg_end > config.num_legs){MainWindow::showMessage("Bad Leg Number selected");return;}ui->listWidget->clear();/** Start the testing* Read each team into memory and start the testing*/int count_bad = 0;for( int tm = config.min_team; tm <= config.max_team; tm++ ){team_type team_buf;if( valid_field( tm ) ){g_record( tm, &team_buf );if ( !team_buf.flags.disqualified && team_buf.flags.valid){test_times( &team_buf, leg_end );if( check_error.type > 0 ){count_bad++;qmDataCheckItem *item = new qmDataCheckItem( tm, check_error.leg);QString msg = QString("Team %1, Leg %2: %3").arg(QString::number(tm)).arg(QString::number(check_error.leg)).arg(qck_err_mess[check_error.type]);item->setData(Qt::EditRole, msg);ui->listWidget->addItem(item);}}}}if( count_bad )MainWindow::showMessage(QString("%1 teams with inconsistent data").arg(count_bad));elseMainWindow::showMessage("All team data correct");}void qmDataCheck::cancel(void){ui->listWidget->clear();}void qmDataCheck::selected(QListWidgetItem *item){qDebug("Item selected");qmDataCheckItem *myitem = dynamic_cast<qmDataCheckItem *>(item);if ( myitem ){qDebug(" Team:%d, Leg: %d", myitem->team, myitem->leg);qmDialogTeamEditor dialog(myitem->team, this);dialog.exec();}}