Subversion Repositories svn1

Rev

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

Rev 226 Rev 380
Line 5... Line 5...
5
#include "structs.h"
5
#include "structs.h"
6
#include "proto.h"
6
#include "proto.h"
7
#include "mainwindow.h"
7
#include "mainwindow.h"
8
#include "twinspinbox.h"
8
#include "twinspinbox.h"
9
#include "qmeditaddendum.h"
9
#include "qmeditaddendum.h"
-
 
10
#include "qmeditawards.h"
10
 
11
 
11
QmConfTeams::QmConfTeams(QWidget *parent) :
12
QmConfTeams::QmConfTeams(QWidget *parent) :
12
    QWidget(parent),
13
    QWidget(parent),
13
    ui(new Ui::QmConfigure)
14
    ui(new Ui::QmConfigure)
14
{
15
{
15
    ui->setupUi(this);
16
    ui->setupUi(this);
16
    connect(ui->pushButtonSave, SIGNAL(clicked()), this, SLOT(save()) );
17
    connect(ui->pushButtonSave, SIGNAL(clicked()), this, SLOT(save()) );
17
    connect(ui->pushButtonRestore, SIGNAL(clicked()), this, SLOT(cancel()) );
18
    connect(ui->pushButtonRestore, SIGNAL(clicked()), this, SLOT(cancel()) );
18
    connect(ui->editAddendum, SIGNAL(clicked()), this, SLOT(editAddendum()));
19
    connect(ui->editAddendum, SIGNAL(clicked()), this, SLOT(editAddendum()));
-
 
20
    connect(ui->editAwardsFileName, SIGNAL(clicked()), this, SLOT(editAwards()));
-
 
21
    connect(ui->pushButtonExit, SIGNAL(clicked()), this, SLOT(quitApplication()));
-
 
22
 
19
 
23
 
20
    ui->spinBox_NeLeg->setMaximum(5);
24
    ui->spinBox_NeLeg->setMaximum(5);
21
    ui->spinBox_NeLeg->setMinimum(0);
25
    ui->spinBox_NeLeg->setMinimum(0);
22
    connect(ui->spinBox_NeLeg, SIGNAL(valueChanged(int)), this,SLOT(updateNe()));
26
    connect(ui->spinBox_NeLeg, SIGNAL(valueChanged(int)), this,SLOT(updateNe()));
23
    connect(ui->legNe1,SIGNAL(clicked()), this,SLOT(calcNe1()));
27
    connect(ui->legNe1,SIGNAL(clicked()), this,SLOT(calcNe1()));
Line 33... Line 37...
33
    connect(ui->legName4, SIGNAL(textChanged(QString)), this, SLOT(changed()));
37
    connect(ui->legName4, SIGNAL(textChanged(QString)), this, SLOT(changed()));
34
    connect(ui->legName5, SIGNAL(textChanged(QString)), this, SLOT(changed()));
38
    connect(ui->legName5, SIGNAL(textChanged(QString)), this, SLOT(changed()));
35
 
39
 
36
    connect(ui->ne_leg_abr, SIGNAL(textChanged(QString)), this, SLOT(changed()));
40
    connect(ui->ne_leg_abr, SIGNAL(textChanged(QString)), this, SLOT(changed()));
37
    connect(ui->addendum, SIGNAL(textChanged(QString)), this, SLOT(changed()));
41
    connect(ui->addendum, SIGNAL(textChanged(QString)), this, SLOT(changed()));
-
 
42
    connect(ui->awardsFileName, SIGNAL(textChanged(QString)), this, SLOT(changed()));
38
    connect(ui->datafilename, SIGNAL(textChanged(QString)), this, SLOT(changed()));
43
    connect(ui->datafilename, SIGNAL(textChanged(QString)), this, SLOT(changed()));
39
    connect(ui->spinBox_LinesPerPage, SIGNAL(valueChanged(int)), this, SLOT(changed()));
44
    connect(ui->spinBox_LinesPerPage, SIGNAL(valueChanged(int)), this, SLOT(changed()));
40
    connect(ui->perfSkip, SIGNAL(stateChanged(int)), this, SLOT(changed()));
45
    connect(ui->perfSkip, SIGNAL(stateChanged(int)), this, SLOT(changed()));
41
 
46
 
42
 
47
 
Line 58... Line 63...
58
    connect(ui->tn7, SIGNAL(changed()), this, SLOT(changed()));
63
    connect(ui->tn7, SIGNAL(changed()), this, SLOT(changed()));
59
    connect(ui->tn8, SIGNAL(changed()), this, SLOT(changed()));
64
    connect(ui->tn8, SIGNAL(changed()), this, SLOT(changed()));
60
 
65
 
61
    populating = false;
66
    populating = false;
62
    dirty = true;
67
    dirty = true;
-
 
68
    mustRestart = false;
-
 
69
    ui->pushButtonExit->hide();
63
    populate();
70
    populate();
64
 
71
 
65
 
72
 
66
}
73
}
67
void QmConfTeams::populate(void)
74
void QmConfTeams::populate(void)
Line 74... Line 81...
74
    ui->addendum->setMaxLength(sizeof(config.addendum)-1);
81
    ui->addendum->setMaxLength(sizeof(config.addendum)-1);
75
 
82
 
76
    ui->datafilename->setText(config.datafilename);
83
    ui->datafilename->setText(config.datafilename);
77
    ui->datafilename->setMaxLength(sizeof(config.datafilename) - 1);
84
    ui->datafilename->setMaxLength(sizeof(config.datafilename) - 1);
78
 
85
 
-
 
86
    ui->awardsFileName->setText(config.awardsfilename);
-
 
87
    ui->awardsFileName->setMaxLength(sizeof(config.awardsfilename) - 1);
-
 
88
 
79
    ui->legName1->setText(config.leg_name[0]);
89
    ui->legName1->setText(config.leg_name[0]);
80
    ui->legName1->setMaxLength(MAX_LEG_NAME);
90
    ui->legName1->setMaxLength(MAX_LEG_NAME);
81
    ui->legName2->setText(config.leg_name[1]);
91
    ui->legName2->setText(config.leg_name[1]);
82
    ui->legName2->setMaxLength(MAX_LEG_NAME);
92
    ui->legName2->setMaxLength(MAX_LEG_NAME);
83
    ui->legName3->setText(config.leg_name[2]);
93
    ui->legName3->setText(config.leg_name[2]);
Line 137... Line 147...
137
    **  Extract data from Widgets
147
    **  Extract data from Widgets
138
    */
148
    */
139
    strncpy(newcfg.event_name, qPrintable(ui->eventName->text()), sizeof(newcfg.event_name)) ;
149
    strncpy(newcfg.event_name, qPrintable(ui->eventName->text()), sizeof(newcfg.event_name)) ;
140
    strncpy(newcfg.datafilename, qPrintable(ui->datafilename->text()), sizeof(newcfg.datafilename)) ;
150
    strncpy(newcfg.datafilename, qPrintable(ui->datafilename->text()), sizeof(newcfg.datafilename)) ;
141
    strncpy(newcfg.addendum, qPrintable(ui->addendum->text()), sizeof(newcfg.addendum)) ;
151
    strncpy(newcfg.addendum, qPrintable(ui->addendum->text()), sizeof(newcfg.addendum)) ;
-
 
152
    strncpy(newcfg.awardsfilename, qPrintable(ui->awardsFileName->text()), sizeof(newcfg.awardsfilename)) ;
142
 
153
 
143
    strncpy(newcfg.leg_name[0], qPrintable(ui->legName1->text()), sizeof(newcfg.leg_name[0])) ;
154
    strncpy(newcfg.leg_name[0], qPrintable(ui->legName1->text()), sizeof(newcfg.leg_name[0])) ;
144
    strncpy(newcfg.leg_name[1], qPrintable(ui->legName2->text()), sizeof(newcfg.leg_name[1])) ;
155
    strncpy(newcfg.leg_name[1], qPrintable(ui->legName2->text()), sizeof(newcfg.leg_name[1])) ;
145
    strncpy(newcfg.leg_name[2], qPrintable(ui->legName3->text()), sizeof(newcfg.leg_name[2])) ;
156
    strncpy(newcfg.leg_name[2], qPrintable(ui->legName3->text()), sizeof(newcfg.leg_name[2])) ;
146
    strncpy(newcfg.leg_name[3], qPrintable(ui->legName4->text()), sizeof(newcfg.leg_name[3])) ;
157
    strncpy(newcfg.leg_name[3], qPrintable(ui->legName4->text()), sizeof(newcfg.leg_name[3])) ;
Line 171... Line 182...
171
        compact( newcfg.event_name );               /* Rip of leading white_space */
182
        compact( newcfg.event_name );               /* Rip of leading white_space */
172
        for( int i = 0; i < MAX_LEGS; i++ )
183
        for( int i = 0; i < MAX_LEGS; i++ )
173
            compact( newcfg.leg_name[i] );
184
            compact( newcfg.leg_name[i] );
174
        compact( newcfg.addendum );
185
        compact( newcfg.addendum );
175
        compact( newcfg.datafilename );
186
        compact( newcfg.datafilename );
-
 
187
        compact( newcfg.awardsfilename );
176
 
188
 
177
        /*
189
        /*
178
     * Do all sorts of consistency tests on the data
190
     * Do all sorts of consistency tests on the data
179
     * Firstly - calculate the number of legs. Justify the data in the array
191
     * Firstly - calculate the number of legs. Justify the data in the array
180
     */
192
     */
Line 281... Line 293...
281
            newcfg.nonequestrian_class = newcfg.lookup_class( newcfg.nonequestrian_class_abr );
293
            newcfg.nonequestrian_class = newcfg.lookup_class( newcfg.nonequestrian_class_abr );
282
            if( newcfg.nonequestrian_class == 0 )
294
            if( newcfg.nonequestrian_class == 0 )
283
                MainWindow::showMessage( "WARNING: Non-equestrian class not found" );
295
                MainWindow::showMessage( "WARNING: Non-equestrian class not found" );
284
        }
296
        }
285
 
297
 
-
 
298
        //  Detect change in the number of legs configured
-
 
299
        //  Need to force application restart
-
 
300
        if ( config.num_legs != newcfg.num_legs || mustRestart ) {
-
 
301
            mustRestart = true;
-
 
302
        }
-
 
303
 
286
        config = newcfg;
304
        config = newcfg;
287
        config.write_config();
305
        config.write_config();
288
        updateChanged(false);
306
        updateChanged(false);
289
 
307
 
290
    }
308
    }
Line 331... Line 349...
331
            ui->Changed->setVisible(false);
349
            ui->Changed->setVisible(false);
332
            ui->pushButtonSave->setEnabled(false);
350
            ui->pushButtonSave->setEnabled(false);
333
            ui->pushButtonSave->setStyleSheet("");
351
            ui->pushButtonSave->setStyleSheet("");
334
        }
352
        }
335
    }
353
    }
-
 
354
 
-
 
355
    if (mustRestart) {
-
 
356
        MainWindow::disableAllTabs();
-
 
357
        ui->pushButtonExit->show();
-
 
358
        ui->pushButtonExit->setEnabled(true);
-
 
359
        ui->pushButtonExit->setStyleSheet("background-color: rgb(255, 0, 0);");
-
 
360
    }
336
}
361
}
337
 
362
 
338
void QmConfTeams::editAddendum(void)
363
void QmConfTeams::editAddendum(void)
339
{
364
{
340
    QString fname = ui->addendum->text();
365
    QString fname = ui->addendum->text();
Line 343... Line 368...
343
        QmEditAddendum dialog(QmConfig::getAddendemFile(fname, true));
368
        QmEditAddendum dialog(QmConfig::getAddendemFile(fname, true));
344
        dialog.exec();
369
        dialog.exec();
345
    }
370
    }
346
}
371
}
347
 
372
 
-
 
373
void QmConfTeams::editAwards(void)
-
 
374
{
-
 
375
    QString fname = ui->awardsFileName->text();
-
 
376
    if ( !fname.isEmpty() )
-
 
377
    {
-
 
378
        QmEditAwards dialog(QmConfig::getAddendemFile(fname, true));
-
 
379
        dialog.exec();
-
 
380
    }
-
 
381
}
-
 
382
 
348
QmConfTeams::~QmConfTeams()
383
QmConfTeams::~QmConfTeams()
349
{
384
{
350
    delete ui;
385
    delete ui;
351
}
386
}
352
 
387
 
Line 360... Line 395...
360
        break;
395
        break;
361
    default:
396
    default:
362
        break;
397
        break;
363
    }
398
    }
364
}
399
}
-
 
400
 
-
 
401
void QmConfTeams::quitApplication(void)
-
 
402
{
-
 
403
    QCoreApplication::quit();
-
 
404
}
-
 
405