Subversion Repositories svn1

Rev

Rev 256 | Rev 276 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 256 Rev 260
Line 20... Line 20...
20
    QWidget(parent),
20
    QWidget(parent),
21
    ui(new Ui::qmDataCheck)
21
    ui(new Ui::qmDataCheck)
22
{
22
{
23
    ui->setupUi(this);
23
    ui->setupUi(this);
24
 
24
 
25
    ui->leg->setMinimum(1);
25
    ui->leg->setMinimum(0);
26
    ui->leg->setMaximum(config.num_legs);
26
    ui->leg->setMaximum(config.num_legs);
27
    ui->leg->setValue(config.num_legs);
27
    ui->leg->setValue(config.num_legs);
28
 
28
 
29
    connect( ui->buttonBox, SIGNAL(accepted()), this, SLOT(populate()));
29
    connect( ui->buttonBox, SIGNAL(accepted()), this, SLOT(populate()));
30
    connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(cancel()) );
30
    connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(cancel()) );
Line 34... Line 34...
34
qmDataCheck::~qmDataCheck()
34
qmDataCheck::~qmDataCheck()
35
{
35
{
36
    delete ui;
36
    delete ui;
37
}
37
}
38
 
38
 
-
 
39
/*----------------------------------------------------------------------------
-
 
40
** FUNCTION           : addItem
-
 
41
**
-
 
42
** DESCRIPTION        : Add an entry to the list of errored items
-
 
43
**
-
 
44
**
-
 
45
** INPUTS             : team            - Team
-
 
46
**                      leg             - May be 0
-
 
47
**                      msg             - Text error message
-
 
48
**
-
 
49
** RETURNS            : Nothing
-
 
50
**
-
 
51
----------------------------------------------------------------------------*/
-
 
52
 
-
 
53
void qmDataCheck::addItem(int team, int leg, QString msg)
-
 
54
{
-
 
55
    qmDataCheckItem *item = new qmDataCheckItem(team, leg);
-
 
56
    item->setData(Qt::EditRole, msg);
-
 
57
    ui->listWidget->addItem(item);
-
 
58
}
-
 
59
 
39
void qmDataCheck::populate(void)
60
void qmDataCheck::populate(void)
40
{
61
{
41
    int leg_end = ui->leg->value();
62
    int leg_end = ui->leg->value();
42
    if ( leg_end <= 0 || leg_end > config.num_legs)
63
    if ( leg_end < 0 || leg_end > config.num_legs)
43
    {
64
    {
44
        MainWindow::showMessage("Bad Leg Number selected");
65
        MainWindow::showMessage("Bad Leg Number selected");
45
        return;
66
        return;
46
    }
67
    }
47
    ui->listWidget->clear();
68
    ui->listWidget->clear();
Line 51... Line 72...
51
     * Read each team into memory and start the testing
72
     * Read each team into memory and start the testing
52
     */
73
     */
53
    int count_bad = 0;
74
    int count_bad = 0;
54
    for( int tm = config.min_team; tm <= config.max_team; tm++ )
75
    for( int tm = config.min_team; tm <= config.max_team; tm++ )
55
    {
76
    {
-
 
77
        int badData = 0;
56
        team_type team_buf;
78
        team_type team_buf;
57
        if( valid_field( tm ) )
79
        if( valid_field( tm ) )
58
        {
80
        {
59
            g_record( tm, &team_buf );
81
            g_record( tm, &team_buf );
60
            if ( !team_buf.flags.disqualified && team_buf.flags.valid)
82
            if ( !team_buf.flags.disqualified && team_buf.flags.valid)
61
            {
83
            {
-
 
84
                // Test for class not defined
-
 
85
                if ( team_buf.teamclass <= 0)
-
 
86
                {
-
 
87
                    addItem(tm, 0, QString("Team %1, No Class specified").arg(QString::number(tm) ) );
-
 
88
                    badData = 1;
-
 
89
                }
-
 
90
 
-
 
91
                if ( strlen (team_buf.name) <= 0)
-
 
92
                {
-
 
93
                    addItem(tm, 0, QString("Team %1, No Team Name specified").arg(QString::number(tm) ) );
-
 
94
                    badData = 1;
-
 
95
                }
-
 
96
 
-
 
97
                // Test Leg Data if required
-
 
98
                if (leg_end)
-
 
99
                {
62
                test_times( &team_buf, leg_end );
100
                    test_times( &team_buf, leg_end );
63
                if( check_error.type > 0 )
101
                    if( check_error.type > 0 )
-
 
102
                    {
-
 
103
                        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]));
-
 
104
                        badData = 1;
-
 
105
                    }
-
 
106
                }
-
 
107
            }
-
 
108
        }
-
 
109
        else
-
 
110
        {
-
 
111
            //
-
 
112
            // Team not within the configured range
-
 
113
            // Warn if the team has time data - may be a miss configuration
-
 
114
            //
-
 
115
            int i;
-
 
116
            g_record( tm, &team_buf );
-
 
117
            for( i = 0; i <= config.num_legs; i++ )
-
 
118
            {
-
 
119
                if ( team_buf.leg[i].start > 0 || team_buf.leg[i].end > 0 )
64
                {
120
                {
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]);
121
                    addItem(tm, 0, QString("Team %1, Unconfigured team has time information").arg(QString::number(tm) ) );
68
                    item->setData(Qt::EditRole, msg);
122
                    badData = 1;
69
                    ui->listWidget->addItem(item);
123
                    break;
70
                }
124
                }
71
            }
125
            }
-
 
126
 
72
        }
127
        }
-
 
128
 
-
 
129
        //
-
 
130
        //  Count teams with wonky data
-
 
131
        //
-
 
132
        if (badData)
-
 
133
            count_bad++;
73
    }
134
    }
74
    if( count_bad )
135
    if( count_bad )
75
        MainWindow::showMessage(QString("%1 teams with inconsistent data").arg(count_bad));
136
        MainWindow::showMessage(QString("%1 teams with inconsistent data").arg(count_bad));
76
    else
137
    else
77
        MainWindow::showMessage("All team data correct");
138
        MainWindow::showMessage("All team data correct");
Line 82... Line 143...
82
    ui->listWidget->clear();
143
    ui->listWidget->clear();
83
}
144
}
84
 
145
 
85
void qmDataCheck::selected(QListWidgetItem *item)
146
void qmDataCheck::selected(QListWidgetItem *item)
86
{
147
{
87
    qDebug("Item selected");
148
    //qDebug("Item selected");
88
    qmDataCheckItem *myitem = dynamic_cast<qmDataCheckItem *>(item);
149
    qmDataCheckItem *myitem = dynamic_cast<qmDataCheckItem *>(item);
89
    if ( myitem )
150
    if ( myitem )
90
    {
151
    {
91
        qDebug("   Team:%d, Leg: %d", myitem->team, myitem->leg);
152
        //qDebug("   Team:%d, Leg: %d", myitem->team, myitem->leg);
92
        qmDialogTeamEditor dialog(myitem->team, this);
153
        qmDialogTeamEditor dialog(myitem->team, this);
93
        dialog.exec();
154
        dialog.exec();
94
    }
155
    }
95
 
-
 
96
}
156
}
97
 
157