Subversion Repositories svn1

Rev

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

Rev 315 Rev 320
Line 4... Line 4...
4
#include <QObject>
4
#include <QObject>
5
#include <QMessageBox>
5
#include <QMessageBox>
6
#include <QFileInfo>
6
#include <QFileInfo>
7
#include <QFile>
7
#include <QFile>
8
#include <QCoreApplication>
8
#include <QCoreApplication>
-
 
9
#include <QSettings>
9
 
10
 
10
//#define DISPLAY_STRUCTURES
11
//#define DISPLAY_STRUCTURES
11
 
12
 
12
// Global Data
13
// Global Data
13
QmConfig    config;
14
QmConfig    config;
14
 
15
 
-
 
16
// Application Config
-
 
17
//  Only use this to store user setting
-
 
18
//  Thinks like : 
-
 
19
//      Last path for loaded file
-
 
20
//      Last entered uploaded leg
-
 
21
//      Swim Start: Leg Set up Delta and base
-
 
22
 
-
 
23
QSettings   *appSettings = NULL;
-
 
24
 
15
 
25
 
16
/*
26
/*
17
**  Local definitions
27
**  Local definitions
18
*/
28
*/
19
char        datfile[20];                         /* Name of the data file */
29
char        datfile[20];                         /* Name of the data file */
20
char        filebase[20];                        /* Event file name base */
30
char        filebase[20];                        /* Event file name base */
21
char        filepath[300];
31
char        filepath[300];
22
 
32
 
-
 
33
/*----------------------------------------------------------------------------
-
 
34
** FUNCTION           : QmConfig 
-
 
35
**
-
 
36
** DESCRIPTION        : Constructor
-
 
37
**
-
 
38
**
-
 
39
** INPUTS             :
-
 
40
**
-
 
41
----------------------------------------------------------------------------*/
-
 
42
 
-
 
43
QmConfig::QmConfig(void)
-
 
44
{
-
 
45
    /*
-
 
46
    ** Init appSettings - once !
-
 
47
    */
-
 
48
    if (!appSettings)
-
 
49
    {
-
 
50
        appSettings = new QSettings(getAddendemFile("mara.ini", true), QSettings::IniFormat); 
-
 
51
    }
-
 
52
}
-
 
53
 
-
 
54
/*----------------------------------------------------------------------------
-
 
55
** FUNCTION           : ~QmConfig
-
 
56
**
-
 
57
** DESCRIPTION        : Destructor
-
 
58
**
-
 
59
**
-
 
60
----------------------------------------------------------------------------*/
-
 
61
 
-
 
62
QmConfig::~QmConfig()
-
 
63
{
-
 
64
    /*
-
 
65
    ** This will force the items to be flushed
-
 
66
    */
-
 
67
    if (appSettings)
-
 
68
    {
-
 
69
        delete(appSettings);
-
 
70
    }
-
 
71
}
23
 
72
 
24
void QmConfig::load(const QString &cnfFile)
73
void QmConfig::load(const QString &cnfFile)
25
{
74
{
26
#ifdef DISPLAY_STRUCTURES
75
#ifdef DISPLAY_STRUCTURES
27
    display_structures();
76
    display_structures();
Line 170... Line 219...
170
        return ( FALSE );
219
        return ( FALSE );
171
 
220
 
172
    /*
221
    /*
173
     * Number of legs
222
     * Number of legs
174
     */
223
     */
175
 
-
 
176
//qDebug( "Reading: Leg Nums" );
224
//qDebug( "Reading: Leg Nums" );
177
    fsize = sizeof( num_legs  );
225
    fsize = sizeof( num_legs  );
178
    len = configFile.read( (char *)&num_legs, fsize );
226
    len = configFile.read( (char *)&num_legs, fsize );
179
    if( len != fsize)
227
    if( len != fsize)
180
        return ( FALSE );
228
        return ( FALSE );
181
 
229
 
182
    /*
230
    /*
183
     * Number of team splits
231
     * Number of team splits
184
     */
232
     */
185
 
-
 
186
//qDebug( "Reading: Team Splits" );
233
//qDebug( "Reading: Team Splits" );
187
    fsize = sizeof( num_teams  );
234
    fsize = sizeof( num_teams  );
188
    len = configFile.read( (char *)&num_teams, fsize );
235
    len = configFile.read( (char *)&num_teams, fsize );
189
    if( len != fsize )
236
    if( len != fsize )
190
        return ( FALSE );
237
        return ( FALSE );
Line 206... Line 253...
206
        return ( FALSE );
253
        return ( FALSE );
207
 
254
 
208
    /*
255
    /*
209
     * Country list
256
     * Country list
210
     */
257
     */
211
 
-
 
212
//qDebug( "Reading: Country Data, Name" );
258
//qDebug( "Reading: Country Data, Name" );
213
    fsize = sizeof( country_name  );
259
    fsize = sizeof( country_name  );
214
    len = configFile.read( (char *)country_name, fsize );
260
    len = configFile.read( (char *)country_name, fsize );
215
    if( len != fsize )
261
    if( len != fsize )
216
        return ( FALSE );
262
        return ( FALSE );
Line 222... Line 268...
222
        return ( FALSE );
268
        return ( FALSE );
223
 
269
 
224
    /*
270
    /*
225
     * Addendum file
271
     * Addendum file
226
     */
272
     */
227
 
-
 
228
//qDebug( "Reading: Addendum File" );
273
//qDebug( "Reading: Addendum File" );
229
    fsize = sizeof( addendum );
274
    fsize = sizeof( addendum );
230
    len = configFile.read( addendum, fsize );
275
    len = configFile.read( addendum, fsize );
231
    if( len != fsize )
276
    if( len != fsize )
232
        return ( configFile.atEnd() );
277
        return ( configFile.atEnd() );
Line 288... Line 333...
288
    len = configFile.read( (char *)&num_fame, fsize );
333
    len = configFile.read( (char *)&num_fame, fsize );
289
    if( len != fsize )
334
    if( len != fsize )
290
        return ( configFile.atEnd() );
335
        return ( configFile.atEnd() );
291
 
336
 
292
//qDebug( "Reading: NE Winners Info" );
337
//qDebug( "Reading: NE Winners Info" );
293
        fsize = sizeof( class_ne_winners );
338
    fsize = sizeof( class_ne_winners );
294
        len = configFile.read( (char *)&class_ne_winners, fsize );
339
    len = configFile.read( (char *)&class_ne_winners, fsize );
295
        if( len != fsize )
340
    if( len != fsize )
296
             return ( configFile.atEnd() );
341
         return ( configFile.atEnd() );
297
 
342
 
298
//qDebug( "Reading: Web Import Url" );
343
//qDebug( "Reading: Web Import Url" );
299
        fsize = sizeof( webUrl );
344
    fsize = sizeof( webUrl );
300
        len = configFile.read( (char *)&webUrl, fsize );
345
    len = configFile.read( (char *)&webUrl, fsize );
301
        if( len != fsize )
346
    if( len != fsize )
302
            return ( configFile.atEnd() );
347
        return ( configFile.atEnd() );
303
 
348
 
304
    return ( TRUE );
349
    return ( TRUE );
305
}
350
}
306
 
351
 
307
/*----------------------------------------------------------------------------
352
/*----------------------------------------------------------------------------