Subversion Repositories svn1-original

Rev

Rev 369 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 369 Rev 378
Line 24... Line 24...
24
    ui->legNumber->setMaximum(config.num_legs);
24
    ui->legNumber->setMaximum(config.num_legs);
25
 
25
 
26
    // Connect up buttons
26
    // Connect up buttons
27
    connect(ui->load, SIGNAL(clicked()), this, SLOT(load()));
27
    connect(ui->load, SIGNAL(clicked()), this, SLOT(load()));
28
    connect(ui->fromClip, SIGNAL(clicked()), this, SLOT(fromClip()));
28
    connect(ui->fromClip, SIGNAL(clicked()), this, SLOT(fromClip()));
-
 
29
    connect(ui->fromEvent, SIGNAL(clicked()), this, SLOT(fromEvent()));
29
    connect(ui->clear, SIGNAL(clicked()), this, SLOT(clear()));
30
    connect(ui->clear, SIGNAL(clicked()), this, SLOT(clear()));
30
    connect(ui->cancel,SIGNAL(clicked()), this, SLOT(close()));
31
    connect(ui->cancel,SIGNAL(clicked()), this, SLOT(close()));
31
    connect(ui->update,SIGNAL(clicked()), this, SLOT(update()));
32
    connect(ui->update,SIGNAL(clicked()), this, SLOT(update()));
32
    connect(ui->deltaTime, SIGNAL(timeChanged(QTime)), this, SLOT(updateDeltaDisplay()));
33
    connect(ui->deltaTime, SIGNAL(timeChanged(QTime)), this, SLOT(updateDeltaDisplay()));
33
    connect(ui->hideOk, SIGNAL(clicked()), this, SLOT(updateDeltaDisplay()));
34
    connect(ui->hideOk, SIGNAL(clicked()), this, SLOT(updateDeltaDisplay()));
-
 
35
    connect(ui->legNumber, SIGNAL(valueChanged(int)), this, SLOT(legNumberChanged(int)));
34
 
36
 
35
 
37
 
36
    // Set up the table
38
    // Set up the table
37
    // First column is not a 'time' column
39
    // First column is not a 'time' column
38
    ui->tableWidget->setColumnCount(1);
40
    ui->tableWidget->setColumnCount(1);
Line 44... Line 46...
44
    // Wire up the table
46
    // Wire up the table
45
    connect(ui->tableWidget,SIGNAL(itemDoubleClicked (QTableWidgetItem*)), this,SLOT(itemActivated(QTableWidgetItem*)));
47
    connect(ui->tableWidget,SIGNAL(itemDoubleClicked (QTableWidgetItem*)), this,SLOT(itemActivated(QTableWidgetItem*)));
46
 
48
 
47
    // Init status
49
    // Init status
48
    ui->status->setText("Load Leg File");
50
    ui->status->setText("Load Leg File");
-
 
51
    legNumberChanged(0);
49
}
52
}
50
 
53
 
51
QmDialogUploadLegTimes::~QmDialogUploadLegTimes()
54
QmDialogUploadLegTimes::~QmDialogUploadLegTimes()
52
{
55
{
53
    delete ui;
56
    delete ui;
Line 72... Line 75...
72
 
75
 
73
    // Update Error information
76
    // Update Error information
74
    updateDeltaDisplay();
77
    updateDeltaDisplay();
75
}
78
}
76
 
79
 
-
 
80
void QmDialogUploadLegTimes::fromEvent(void)
-
 
81
{
-
 
82
    team_type   team_buf;
-
 
83
 
-
 
84
    /* Determine the leg to load - from other dialog */
-
 
85
    int leg = ui->legNumber->value() ;
-
 
86
    if (leg <= 0 || leg > config.num_legs)
-
 
87
    {
-
 
88
        ui->status->setText("Must select leg number");
-
 
89
        return;
-
 
90
    }
-
 
91
 
-
 
92
    ui->status->setText("Load existing data from leg:" + QString::number(leg));
-
 
93
    for( int i = config.min_team; i <= config.max_team; i++ )
-
 
94
    {
-
 
95
        if( valid_field( i ) && g_record( i, &team_buf ) )
-
 
96
        {
-
 
97
            int secs;
-
 
98
            if ( ui->legStart->isChecked()) {
-
 
99
                secs = team_buf.leg[leg].start;
-
 
100
            } else {
-
 
101
                secs = team_buf.leg[leg].end;
-
 
102
            }
-
 
103
 
-
 
104
            QTime data = QTime().addSecs(secs);
-
 
105
            //qDebug() << "Team:"<< i << " Time:" << data.toString("hh:mm:ss");
-
 
106
            addDataToTable(i, data, true);
-
 
107
        }
-
 
108
    }
-
 
109
 
-
 
110
    // Update Error information
-
 
111
    updateDeltaDisplay();
-
 
112
}
-
 
113
 
77
void QmDialogUploadLegTimes::fromClip(void)
114
void QmDialogUploadLegTimes::fromClip(void)
78
{
115
{
79
    QClipboard *clipboard = QApplication::clipboard();
116
    QClipboard *clipboard = QApplication::clipboard();
80
    QString text = clipboard->text();
117
    QString text = clipboard->text();
81
    if (text.length() > 0) {
118
    if (text.length() > 0) {
Line 89... Line 126...
89
 
126
 
90
        // Update Error information
127
        // Update Error information
91
        updateDeltaDisplay();
128
        updateDeltaDisplay();
92
    }
129
    }
93
}
130
}
-
 
131
 
94
void QmDialogUploadLegTimes::processOneLine(QString line)
132
void QmDialogUploadLegTimes::processOneLine(QString line)
95
{
133
{
96
    QStringList parts;
134
    QStringList parts;
97
    line = line.trimmed();             // Remove leading and training White Space
135
    line = line.trimmed();             // Remove leading and training White Space
98
    if (line.size() <= 0)
136
    if (line.size() <= 0)
Line 134... Line 172...
134
    if ( ! ok || team <= 0 || team > 999 )
172
    if ( ! ok || team <= 0 || team > 999 )
135
    {
173
    {
136
        qDebug("Bad Team Number: %s", qPrintable(line));
174
        qDebug("Bad Team Number: %s", qPrintable(line));
137
        return;
175
        return;
138
    }
176
    }
-
 
177
 
-
 
178
    addDataToTable(team, QTime::fromString(parts.value(2),"hh:mm:ss"), false);
-
 
179
}
-
 
180
 
-
 
181
void QmDialogUploadLegTimes::addDataToTable(int team, QTime ltime, bool isYellow)
-
 
182
{
-
 
183
    if ( team <= 0 || team > 999 )
-
 
184
    {
-
 
185
        //qDebug("Team Number out of range: %s", qPrintable(line));
-
 
186
        return;
-
 
187
    }
-
 
188
 
139
    if (team > ui->tableWidget->rowCount())
189
    if (team > ui->tableWidget->rowCount())
140
    {
190
    {
141
        ui->tableWidget->setRowCount(team);
191
        ui->tableWidget->setRowCount(team);
142
    }
192
    }
143
 
193
 
Line 162... Line 212...
162
 
212
 
163
    //  Insert the time at the first available slot
213
    //  Insert the time at the first available slot
164
    //  Scan for max an min as we go
214
    //  Scan for max an min as we go
165
    int ii;
215
    int ii;
166
    QTableWidgetItem *titem = NULL;
216
    QTableWidgetItem *titem = NULL;
167
    QTime ltime = QTime::fromString(parts.value(2),"hh:mm:ss");
217
    //QTime ltime = QTime::fromString(parts.value(2),"hh:mm:ss");
168
    unsigned int lsecs = QTime(0,0,0).secsTo(ltime);
218
    unsigned int lsecs = QTime(0,0,0).secsTo(ltime);
169
    if ( lsecs <= 0)
219
    if ( lsecs <= 0)
170
    {
220
    {
171
        qDebug("Funny Line: %s", qPrintable(line));
221
        //qDebug("Funny Line: %s", qPrintable(line));
172
        return;
222
        return;
173
    }
223
    }
174
    //qDebug("Tead: %d, Secs: %d", team, lsecs );
224
    //qDebug("Tead: %d, Secs: %d", team, lsecs );
175
    unsigned int min_time = lsecs;
225
    unsigned int min_time = lsecs;
176
    unsigned int max_time = lsecs;
226
    unsigned int max_time = lsecs;
Line 204... Line 254...
204
    // Insert data into cell
254
    // Insert data into cell
205
    titem = new QTableWidgetItem();
255
    titem = new QTableWidgetItem();
206
    titem->setData(Qt::EditRole, ltime);
256
    titem->setData(Qt::EditRole, ltime);
207
    titem->setFlags(titem->flags() & ~(Qt::ItemIsEditable|Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled));
257
    titem->setFlags(titem->flags() & ~(Qt::ItemIsEditable|Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled));
208
    ui->tableWidget->setItem(team-1,ii,titem);
258
    ui->tableWidget->setItem(team-1,ii,titem);
-
 
259
 
-
 
260
    //  Color if needed
-
 
261
    if (isYellow)
-
 
262
        titem->setBackgroundColor(QColor(255,255,0,30));
-
 
263
 
209
    //qDebug("Team: %d, %d of %d", team-1, ii, ui->tableWidget->columnCount() );
264
    //qDebug("Team: %d, %d of %d", team-1, ii, ui->tableWidget->columnCount() );
210
 
265
 
211
    if (ii == 3)
266
    if (ii == 3)
212
    {
267
    {
213
        titem = new QTableWidgetItem();
268
        titem = new QTableWidgetItem();
Line 247... Line 302...
247
        MainWindow::showMessage("Cannot open Leg Data file");
302
        MainWindow::showMessage("Cannot open Leg Data file");
248
        return;
303
        return;
249
    }
304
    }
250
    ui->status->setText("Loading Data");
305
    ui->status->setText("Loading Data");
251
    // Insert column headers
306
    // Insert column headers
252
    ui->tableWidget->clearContents();
307
    //ui->tableWidget->clearContents();
253
    ui->tableWidget->setRowCount(0);
308
    //ui->tableWidget->setRowCount(0);
254
 
309
 
255
 
310
 
256
    // Process Each line of the file
311
    // Process Each line of the file
257
    //  Format (original) is TeamNumber Time
312
    //  Format (original) is TeamNumber Time
258
    //  Format (alternate) is TeamNumber Date Time
313
    //  Format (alternate) is TeamNumber Date Time
Line 375... Line 430...
375
        titem->setFlags(titem->flags()| Qt::ItemIsEditable);
430
        titem->setFlags(titem->flags()| Qt::ItemIsEditable);
376
        ui->tableWidget->setItem(uitem->row(),2,titem);
431
        ui->tableWidget->setItem(uitem->row(),2,titem);
377
        titem->setBackgroundColor(QColor(0,0,255,30));
432
        titem->setBackgroundColor(QColor(0,0,255,30));
378
    }
433
    }
379
}
434
}
-
 
435
 
-
 
436
void QmDialogUploadLegTimes::legNumberChanged(int leg)
-
 
437
{
-
 
438
    //qDebug() << "Leg:" << leg;
-
 
439
    ui->fromEvent->setEnabled(leg != 0);
-
 
440
    ui->update->setEnabled( leg != 0);
-
 
441
}