Subversion Repositories svn1

Rev

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

Rev 340 Rev 341
Line 63... Line 63...
63
 
63
 
64
void QmDialogUploadLegTimes::load(void)
64
void QmDialogUploadLegTimes::load(void)
65
{
65
{
66
    QString fileName = QFileDialog::getOpenFileName(this, tr("Load File"),
66
    QString fileName = QFileDialog::getOpenFileName(this, tr("Load File"),
67
                                                 appSettings->value("LegTimeUpload/LastFile",filepath).toString(),
67
                                                 appSettings->value("LegTimeUpload/LastFile",filepath).toString(),
68
                                                 tr("Legs (*leg*);;Data (*.leg);;All (*.*)"),
68
                                                 tr("Legs (*leg*);;Data (*.leg);;Text (*.txt);;All (*.*)"),
69
                                                 0,
69
                                                 0,
70
                                                 QFileDialog::ReadOnly);
70
                                                 QFileDialog::ReadOnly);
71
    if ( fileName.isEmpty() )
71
    if ( fileName.isEmpty() )
72
    {
72
    {
73
        MainWindow::showMessage("No File Specified");
73
        MainWindow::showMessage("No File Specified");
Line 90... Line 90...
90
    ui->tableWidget->clearContents();
90
    ui->tableWidget->clearContents();
91
    ui->tableWidget->setRowCount(0);
91
    ui->tableWidget->setRowCount(0);
92
 
92
 
93
 
93
 
94
    // Process Each line of the file
94
    // Process Each line of the file
95
    //  Format is TeamNumber Time
95
    //  Format (original) is TeamNumber Time
-
 
96
    //  Format (alternate) is TeamNumber Date Time
-
 
97
    //                                       Time has milliseconds
96
    QTextStream in(&file);
98
    QTextStream in(&file);
97
    while (!in.atEnd())
99
    while (!in.atEnd())
98
    {
100
    {
-
 
101
        QStringList parts;
99
        QString line = in.readLine();
102
        QString line = in.readLine();
100
        line = line.trimmed();             // Remove leading and training White Space
103
        line = line.trimmed();             // Remove leading and training White Space
-
 
104
 
101
        QStringList parts = line.split(" ");
105
        QRegExp rxOriginal("^(\\d+)\\s+(\\d+:\\d+:\\d+)$");
102
        QString first = parts.value(0);
106
        QRegExp rxAlternate("^(\\d+)\\s+\\d+-\\d+-\\d+\\s+(\\d+:\\d+:\\d+)\\.\\d+$");
-
 
107
 
103
        if ( parts.count() != 2)
108
        if(rxOriginal.indexIn(line) == 0)
104
        {
109
        {
-
 
110
            parts = rxOriginal.capturedTexts();
-
 
111
        }
-
 
112
        else if (rxAlternate.indexIn(line) == 0)
-
 
113
        {
-
 
114
            parts = rxAlternate.capturedTexts();
-
 
115
        }
-
 
116
        else
-
 
117
        {
105
            qDebug("Funny Line: %s", qPrintable(line));
118
            qDebug("Funny Line regex: %s", qPrintable(line));
-
 
119
            continue;
-
 
120
        }
-
 
121
 
-
 
122
        QString first = parts.value(1);
-
 
123
        if ( parts.count() != 3)
-
 
124
        {
-
 
125
            qDebug("Funny Line parts: %s", qPrintable(line));
106
            continue;
126
            continue;
107
        }
127
        }
108
 
128
 
109
        bool ok;
129
        bool ok;
110
        int team = first.toInt(&ok);
130
        int team = first.toInt(&ok);
Line 136... Line 156...
136
 
156
 
137
        //  Insert the time at the first available slot
157
        //  Insert the time at the first available slot
138
        //  Scan for max an min as we go
158
        //  Scan for max an min as we go
139
        int ii;
159
        int ii;
140
        QTableWidgetItem *titem = NULL;
160
        QTableWidgetItem *titem = NULL;
141
        QTime ltime = QTime::fromString(parts.value(1),"hh:mm:ss");
161
        QTime ltime = QTime::fromString(parts.value(2),"hh:mm:ss");
142
        unsigned int lsecs = QTime(0,0,0).secsTo(ltime);
162
        unsigned int lsecs = QTime(0,0,0).secsTo(ltime);
143
        if ( lsecs <= 0)
163
        if ( lsecs <= 0)
144
        {
164
        {
145
            qDebug("Funny Line: %s", qPrintable(line));
165
            qDebug("Funny Line: %s", qPrintable(line));
146
            continue;
166
            continue;