Subversion Repositories svn1-original

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
140 - 1
#include "qmdatacheck.h"
2
#include "ui_qmdatacheck.h"
143 david 3
#include    "consts.h"
4
#include    "structs.h"
5
#include    "proto.h"
6
#include "QString"
7
#include "mainwindow.h"
8
#include "qmdialogteameditor.h"
140 - 9
 
143 david 10
const char       *qck_err_mess[] = {
11
    "No error",
12
    "Invalid start time",
13
    "Invalid end time",
14
    "End before start",
244 - 15
    "Team data not entered",
16
    "NE with named competitor"
143 david 17
};
18
 
140 - 19
qmDataCheck::qmDataCheck(QWidget *parent) :
20
    QWidget(parent),
21
    ui(new Ui::qmDataCheck)
22
{
23
    ui->setupUi(this);
143 david 24
 
25
    ui->leg->setMinimum(1);
26
    ui->leg->setMaximum(config.num_legs);
27
    ui->leg->setValue(config.num_legs);
28
 
29
    connect( ui->buttonBox, SIGNAL(accepted()), this, SLOT(populate()));
30
    connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(cancel()) );
31
    connect(ui->listWidget,SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(selected(QListWidgetItem *)));
140 - 32
}
33
 
34
qmDataCheck::~qmDataCheck()
35
{
36
    delete ui;
37
}
143 david 38
 
39
void qmDataCheck::populate(void)
40
{
41
    int leg_end = ui->leg->value();
42
    if ( leg_end <= 0 || leg_end > config.num_legs)
43
    {
44
        MainWindow::showMessage("Bad Leg Number selected");
45
        return;
46
    }
47
    ui->listWidget->clear();
48
 
49
    /*
50
     * Start the testing
51
     * Read each team into memory and start the testing
52
     */
53
    int count_bad = 0;
54
    for( int tm = config.min_team; tm <= config.max_team; tm++ )
55
    {
56
        team_type team_buf;
57
        if( valid_field( tm ) )
58
        {
59
            g_record( tm, &team_buf );
244 - 60
            if ( !team_buf.flags.disqualified)
143 david 61
            {
244 - 62
                test_times( &team_buf, leg_end );
63
                if( check_error.type > 0 )
64
                {
65
                    count_bad++;
66
                    qmDataCheckItem *item = new qmDataCheckItem( tm, check_error.leg);
67
                    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]);
68
                    item->setData(Qt::EditRole, msg);
69
                    ui->listWidget->addItem(item);
70
                }
143 david 71
            }
72
        }
73
    }
74
    if( count_bad )
75
        MainWindow::showMessage(QString("%1 teams with inconsistent data").arg(count_bad));
76
    else
77
        MainWindow::showMessage("All team data correct");
78
}
79
 
80
void qmDataCheck::cancel(void)
81
{
82
    ui->listWidget->clear();
83
}
84
 
85
void qmDataCheck::selected(QListWidgetItem *item)
86
{
87
    qDebug("Item selected");
88
    qmDataCheckItem *myitem = dynamic_cast<qmDataCheckItem *>(item);
89
    if ( myitem )
90
    {
91
        qDebug("   Team:%d, Leg: %d", myitem->team, myitem->leg);
92
        qmDialogTeamEditor dialog(myitem->team, this);
93
        dialog.exec();
94
    }
95
 
96
}
97