Subversion Repositories svn1

Rev

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

Rev 148 Rev 149
Line 23... Line 23...
23
    if ( ! file.open(QIODevice::ReadOnly | QIODevice::Text) )
23
    if ( ! file.open(QIODevice::ReadOnly | QIODevice::Text) )
24
    {
24
    {
25
        MainWindow::showMessage("Cannot open external data file");
25
        MainWindow::showMessage("Cannot open external data file");
26
        return;
26
        return;
27
    }
27
    }
-
 
28
    MainWindow::showMessage("Loading External Data");
28
 
29
 
-
 
30
    // Insert column headers
29
    ui->tableWidget->setColumnCount(3 + ( 2 * config.num_legs) );
31
    ui->tableWidget->setColumnCount(3 + ( 2 * config.num_legs) );
-
 
32
    QStringList labels;
-
 
33
    labels << "Team" << "Team Name" << "Cat";
-
 
34
    for (int ii = 1; ii <= config.num_legs; ii++ )
-
 
35
    {
-
 
36
        labels += QString("Leg:%1").arg(QString::number(ii));
-
 
37
        labels += QString("Sex:%1").arg(QString::number(ii));
30
 
38
    }
-
 
39
    ui->tableWidget->setHorizontalHeaderLabels(labels);
31
 
40
 
32
    // Process Each line of the file
41
    // Process Each line of the file
33
    QTextStream in(&file);
42
    QTextStream in(&file);
34
    int ii = 0;
43
    int ii = 0;
35
    int bad_cat = 0;
44
    int bad_cat = 0;
Line 85... Line 94...
85
             }
94
             }
86
             yy += 2;
95
             yy += 2;
87
         }
96
         }
88
         ii++;
97
         ii++;
89
     }
98
     }
-
 
99
    ui->tableWidget->resizeColumnsToContents();
90
 
100
 
91
    // Report errors
101
    // Report errors
92
    if (bad_cat)
102
    if (bad_cat)
93
    {
103
    {
94
        MainWindow::showMessage("Invalid Categories in data");
104
        MainWindow::showMessage("Invalid Categories in data");
Line 193... Line 203...
193
    if (bad_cat)
203
    if (bad_cat)
194
    {
204
    {
195
        MainWindow::showMessage("Invalid Categories in data");
205
        MainWindow::showMessage("Invalid Categories in data");
196
    }
206
    }
197
}
207
}
-
 
208
 
-
 
209
/*========================================================================
-
 
210
 *
-
 
211
 *  Generate team name file
-
 
212
 *
-
 
213
 *  Purpose:
-
 
214
 *      This function is called to Generate team name file in the format
-
 
215
 *      that can be read by the load command
-
 
216
 *
-
 
217
 *      The file contains team number,Team name,Team class
-
 
218
 *      The operator is prompted to enter the name of the file
-
 
219
 *
-
 
220
 *  Parameters:
-
 
221
 *      None
-
 
222
 *
-
 
223
 *  Returns:
-
 
224
 *      Nothing
-
 
225
 *
-
 
226
 *========================================================================*/
-
 
227
void QmDialogLoadExternalTeams::storeData(const QString &efile)
-
 
228
{
-
 
229
    QFile file(efile);
-
 
230
    if ( ! file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text) )
-
 
231
    {
-
 
232
        MainWindow::showMessage("Cannot open external data file");
-
 
233
        return;
-
 
234
    }
-
 
235
    QTextStream out(&file);
-
 
236
 
-
 
237
    // Print headings
-
 
238
    out << "\"Team Number\"," << "\"Team Name\"," << "\"Class Abr\"";
-
 
239
 
-
 
240
    for( int j = 1; j <= config.num_legs; j++ )
-
 
241
    {
-
 
242
        out << ",\"Competitor Name\"";
-
 
243
        out << ",\"Age\"";
-
 
244
    }
-
 
245
    out << endl;
-
 
246
 
-
 
247
    /*
-
 
248
     * Put the data into the file
-
 
249
     */
-
 
250
 
-
 
251
    for(int i = config.min_team; i <= config.max_team; i++ )
-
 
252
    {
-
 
253
        if( valid_field( i ) && g_record( i, &team_buf ) )
-
 
254
        {
-
 
255
            /*
-
 
256
            **  Basic information
-
 
257
            **      - Team number
-
 
258
            **      - Full team name
-
 
259
            */
-
 
260
            out << team_buf.numb;
-
 
261
            out << ",\"" << team_buf.name << "\"";
-
 
262
            out << ",\"" <<(team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr)  << "\"";
-
 
263
 
-
 
264
            for(int j = 1; j <= config.num_legs; j++ )
-
 
265
            {
-
 
266
                out << ",\"" << team_buf.members[j-1].name << "\"";
-
 
267
                out << ",\"" << team_buf.members[j-1].age << "\"";
-
 
268
            }
-
 
269
            out <<endl;
-
 
270
        }
-
 
271
    }
-
 
272
}