Subversion Repositories svn1-original

Rev

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

Rev 178 Rev 189
Line 21... Line 21...
21
 
21
 
22
    // Connect up buttons
22
    // Connect up buttons
23
    connect(ui->load, SIGNAL(clicked()), this, SLOT(load()));
23
    connect(ui->load, SIGNAL(clicked()), this, SLOT(load()));
24
    connect(ui->cancel,SIGNAL(clicked()), this, SLOT(close()));
24
    connect(ui->cancel,SIGNAL(clicked()), this, SLOT(close()));
25
    connect(ui->update,SIGNAL(clicked()), this, SLOT(update()));
25
    connect(ui->update,SIGNAL(clicked()), this, SLOT(update()));
26
    connect(ui->deltaTime, SIGNAL(valueChanged(int)), this, SLOT(updateDeltaDisplay(int)));
26
    connect(ui->deltaTime, SIGNAL(valueChanged(int)), this, SLOT(updateDeltaDisplay()));
-
 
27
    connect(ui->hideOk, SIGNAL(clicked()), this, SLOT(updateDeltaDisplay()));
27
 
28
 
28
 
29
 
29
    // Set up the table
30
    // Set up the table
30
     ui->tableWidget->setColumnCount(5);
31
     ui->tableWidget->setColumnCount(5);
31
 
32
 
Line 48... Line 49...
48
 
49
 
49
void QmDialogUploadLegTimes::load(void)
50
void QmDialogUploadLegTimes::load(void)
50
{
51
{
51
    QString fileName = QFileDialog::getOpenFileName(this, tr("Load File"),
52
    QString fileName = QFileDialog::getOpenFileName(this, tr("Load File"),
52
                                                 filepath,
53
                                                 filepath,
53
                                                 tr("Data (*.leg);;All (*.*)"),
54
                                                 tr("Legs (*leg*);;Data (*.leg);;All (*.*)"),
54
                                                 0,
55
                                                 0,
55
                                                 QFileDialog::ReadOnly);
56
                                                 QFileDialog::ReadOnly);
56
    if ( fileName.isEmpty() )
57
    if ( fileName.isEmpty() )
57
    {
58
    {
58
        MainWindow::showMessage("No File Specified");
59
        MainWindow::showMessage("No File Specified");
Line 80... Line 81...
80
    {
81
    {
81
        QString line = in.readLine();
82
        QString line = in.readLine();
82
        line = line.trimmed();             // Remove leading and training White Space
83
        line = line.trimmed();             // Remove leading and training White Space
83
        QStringList parts = line.split(" ");
84
        QStringList parts = line.split(" ");
84
        QString first = parts.value(0);
85
        QString first = parts.value(0);
-
 
86
        if ( parts.count() != 2)
-
 
87
        {
-
 
88
            qDebug("Funny Line: %s", qPrintable(line));
-
 
89
            continue;
-
 
90
        }
85
 
91
 
86
        bool ok;
92
        bool ok;
87
        int team = first.toInt(&ok);
93
        int team = first.toInt(&ok);
88
        if ( ! ok || team <= 0 )
94
        if ( ! ok || team <= 0 )
89
            continue;
95
            continue;
Line 140... Line 146...
140
            ui->tableWidget->item(team-1,1)->setData(Qt::EditRole, QTime().addSecs(delta));
146
            ui->tableWidget->item(team-1,1)->setData(Qt::EditRole, QTime().addSecs(delta));
141
        }
147
        }
142
    }
148
    }
143
 
149
 
144
    // Update Error information
150
    // Update Error information
145
    updateDeltaDisplay( ui->deltaTime->value() );
151
    updateDeltaDisplay();
146
 
152
 
147
}
153
}
148
 
154
 
149
void QmDialogUploadLegTimes::updateDeltaDisplay( int delta_secs )
155
void QmDialogUploadLegTimes::updateDeltaDisplay( void )
150
{
156
{
151
    bool isFlagged = false;
157
    bool isFlagged = false;
-
 
158
    QTime maxDelta(0,0,0,0);
152
    QTime delta = QTime().addSecs(delta_secs);
159
    QTime delta = QTime().addSecs(ui->deltaTime->value());
153
    for ( int ii = 0; ii < ui->tableWidget->rowCount(); ii++)
160
    for ( int ii = 0; ii < ui->tableWidget->rowCount(); ii++)
154
    {
161
    {
-
 
162
        bool show = true;
155
        QTableWidgetItem *item;
163
        QTableWidgetItem *item;
156
        item = ui->tableWidget->item(ii, 1);
164
        item = ui->tableWidget->item(ii, 1);
157
        if (item)
165
        if (item)
158
        {
166
        {
159
            QTime time = item->data(Qt::EditRole).toTime();
167
            QTime time = item->data(Qt::EditRole).toTime();
-
 
168
            if ( time > maxDelta)
-
 
169
            {
-
 
170
                maxDelta = time;
-
 
171
            }
160
            if ( time > delta )
172
            if ( time > delta )
161
            {
173
            {
162
                item->setBackgroundColor(QColor(255,0,0,50));
174
                item->setBackgroundColor(QColor(255,0,0,50));
163
                isFlagged = true;
175
                isFlagged = true;
164
            }
176
            }
165
            else
177
            else
166
            {
178
            {
167
                item->setBackgroundColor(QColor(255,255,255));
179
                item->setBackgroundColor(QColor(255,255,255));
-
 
180
                if ( ui->hideOk->isChecked())
-
 
181
                {
-
 
182
                    show = false;
-
 
183
                }
168
            }
184
            }
169
        }
185
        }
-
 
186
 
-
 
187
        // Hide if not a valid time and we have no time ebtry for it
-
 
188
        if ( !valid_field(ii+1) && item == NULL )
-
 
189
        {
-
 
190
            show = false;
-
 
191
        }
-
 
192
        ui->tableWidget->setRowHidden(ii,!show);
-
 
193
 
170
    }
194
    }
-
 
195
    //ui->maxDeltaTime->setText(QString::number(QTime(0,0,0).secsTo(maxDelta)));
-
 
196
    ui->maxDeltaTime->setText(maxDelta.toString("hh:mm:ss"));
171
    if (isFlagged)
197
    if (isFlagged)
172
    {
198
    {
173
        ui->status->setText("Large Delta Times");
199
        ui->status->setText("Large Delta Times");
174
    }
200
    }
175
    else
201
    else