Subversion Repositories svn1

Rev

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

Rev 224 Rev 380
Line 11... Line 11...
11
#include "qmdisqualified.h"
11
#include "qmdisqualified.h"
12
#include "qmdatacheck.h"
12
#include "qmdatacheck.h"
13
#include "qmdialogloadexternalteams.h"
13
#include "qmdialogloadexternalteams.h"
14
#include "QFileDialog"
14
#include "QFileDialog"
15
#include "qmdialoguploadlegtimes.h"
15
#include "qmdialoguploadlegtimes.h"
16
#include "qmdialogstatus.h"
-
 
17
#include "qmreportwindow.h"
16
#include "qmreportwindow.h"
18
#include "QTabWidget"
17
#include "QTabWidget"
19
#include "QLayout"
18
#include "QLayout"
20
#include "qmeventstatus.h"
19
#include "qmeventstatus.h"
21
#include "qmdownloadlegtimes.h"
20
#include "qmdownloadlegtimes.h"
22
#include "qmdialogabout.h"
21
#include "qmdialogabout.h"
-
 
22
#include "qmhttppath.h"
-
 
23
#include "qmdialogchangeteamnumber.h"
-
 
24
#include "qmfulldata.h"
23
 
25
 
24
#include    "consts.h"
26
#include    "consts.h"
25
#include    "structs.h"
27
#include    "structs.h"
26
#include    "proto.h"
28
#include    "proto.h"
27
 
29
 
28
MainWindow *mw = NULL;
30
MainWindow *mw = NULL;
-
 
31
bool MainWindow::shutDown = false;
29
 
32
 
30
MainWindow::MainWindow(QWidget *parent) :
33
MainWindow::MainWindow(QWidget *parent) :
31
    QMainWindow(parent),
34
    QMainWindow(parent),
32
    ui(new Ui::MainWindow)
35
    ui(new Ui::MainWindow)
33
{
36
{
34
    ui->setupUi(this);
37
    ui->setupUi(this);
35
    mw = this;
38
    mw = this;
-
 
39
    setWindowTitle("Mara");
36
 
40
 
37
    QTabWidget *tabWidget = new QTabWidget();
41
    tabWidget = new QTabWidget();
38
    setCentralWidget(tabWidget);
42
    setCentralWidget(tabWidget);
39
 
43
 
40
    tabWidget->addTab( new QmConfTeams,    "Configure");
44
    tabWidget->addTab( new QmConfTeams,    "Configure");
41
    tabWidget->addTab( new QmConfClass,    "Class");
45
    tabWidget->addTab( new QmConfClass,    "Class");
42
    tabWidget->addTab( new QmConfWinners,  "Winners");
46
    tabWidget->addTab( new QmConfWinners,  "Winners");
43
    tabWidget->addTab( new QmEventStatus,  "Status");
47
    tabWidget->addTab( new QmEventStatus,  "Status");
44
    tabWidget->addTab( new qmTeamDisplay,  "Team Data");
48
    tabWidget->addTab( new qmTeamDisplay,  "Team Data");
45
    tabWidget->addTab( new qmDisqualified, "Disqual");
49
    tabWidget->addTab( new qmDisqualified, "Disqual");
46
    tabWidget->addTab( new qmDataCheck,    "Data Check");
50
    tabWidget->addTab( new qmDataCheck,    "Data Check");
-
 
51
    tabWidget->addTab( new qmFullData,     "Full Data");
47
    tabWidget->addTab( reportWindow = new QmReportWindow, "Reports");
52
    tabWidget->addTab( reportWindow = new QmReportWindow, "Reports");
48
 
53
 
49
    QMenu *m0 = new QMenu ("Team");
54
    QMenu *m0 = new QMenu ("Team");
50
    ui->menuBar->addMenu(m0);
55
    ui->menuBar->addMenu(m0);
51
    m0->addAction("Reset All Team Data", this, SLOT(resetTeamData()));
56
    m0->addAction("Reset All Team Data", this, SLOT(resetTeamData()));
52
    m0->addAction("Generate dummy team names", this, SLOT(generateDummyTeamNames()));
57
    m0->addAction("Generate dummy team names", this, SLOT(generateDummyTeamNames()));
-
 
58
    m0->addAction("Copy/Move/Swap Team Data", this, SLOT(changeTeamNumber()));
53
 
59
 
54
    QMenu *m1 = new QMenu ("Leg Time Setup");
60
    QMenu *m1 = new QMenu ("Leg Time Setup");
55
    ui->menuBar->addMenu(m1);
61
    ui->menuBar->addMenu(m1);
56
    m1->addAction("Clear ALL Leg Times", this, SLOT(clearLegTimes()));
62
    m1->addAction("Clear ALL Leg Times", this, SLOT(clearLegTimes()));
57
    m1->addAction("Clear single leg start times", this, SLOT(ClearOneLegTimes()));
63
    m1->addAction("Clear single leg start times", this, SLOT(ClearOneLegTimes()));
Line 60... Line 66...
60
    m1->addSeparator();
66
    m1->addSeparator();
61
    m1->addAction("Set calculated leg start", this, SLOT(setCalcLegStart()));
67
    m1->addAction("Set calculated leg start", this, SLOT(setCalcLegStart()));
62
    m1->addAction("Set ordered incremental leg start", this, SLOT(setOrderedIncLegStart()));
68
    m1->addAction("Set ordered incremental leg start", this, SLOT(setOrderedIncLegStart()));
63
    m1->addAction("Set staggered start time", this, SLOT(setStaggeredLegStart()));
69
    m1->addAction("Set staggered start time", this, SLOT(setStaggeredLegStart()));
64
    m1->addAction("Set fixed start time", this, SLOT(setFixedLegStart()));
70
    m1->addAction("Set fixed start time", this, SLOT(setFixedLegStart()));
-
 
71
    m1->addSeparator();
-
 
72
    m1->addAction("Recalculate elapsed times", this, SLOT(recalcLegTimes()));
65
 
73
 
66
    QMenu *m2 = new QMenu ("Upload");
74
    QMenu *m2 = new QMenu ("Upload");
67
    ui->menuBar->addMenu(m2);
75
    ui->menuBar->addMenu(m2);
68
    m2->addAction("Load team information from external file", this, SLOT(loadExternalTeams()));
76
    m2->addAction("Load team information from external file", this, SLOT(loadExternalTeams()));
-
 
77
    m2->addAction("Load team information from Web Page", this, SLOT(loadExternalHtmlTeams()));
69
    m2->addAction("Upload time information", this, SLOT(uploadLegData()));
78
    m2->addAction("Upload time information", this, SLOT(uploadLegData()));
70
 
79
 
71
    QMenu *m3 = new QMenu ("Export");
80
    QMenu *m3 = new QMenu ("Export");
72
    ui->menuBar->addMenu(m3);
81
    ui->menuBar->addMenu(m3);
73
    m3->addAction("Store team information to external file", this, SLOT(storeExternalTeams()));
82
    m3->addAction("Store team information to external file", this, SLOT(storeExternalTeams()));
-
 
83
    //m3->addAction("Store basic team info to external file", this, SLOT(storeTeamInfo()));
74
    m3->addAction("Create external leg data file", this, SLOT(storeLegData()));
84
    m3->addAction("Create external leg data file", this, SLOT(storeLegData()));
75
 
85
 
76
    QMenu *m4 = new QMenu ("Reports");
86
    QMenu *m4 = new QMenu ("Reports");
77
    ui->menuBar->addMenu(m4);
87
    ui->menuBar->addMenu(m4);
78
    m4->addAction("Generate All Reports", this, SLOT(generateReports()));
88
    m4->addAction("Generate All Reports", this, SLOT(generateReports()));
79
    m4->addAction("Display Summary", this, SLOT(displaySummary()));
-
 
80
 
89
 
81
    ui->menuBar->addAction("About", this, SLOT(showAbout()));
90
    ui->menuBar->addAction("About", this, SLOT(showAbout()));
82
}
91
}
83
 
92
 
84
MainWindow::~MainWindow()
93
MainWindow::~MainWindow()
Line 161... Line 170...
161
    {
170
    {
162
        tm_gen();
171
        tm_gen();
163
    }
172
    }
164
}
173
}
165
 
174
 
-
 
175
void MainWindow::changeTeamNumber(void)
-
 
176
{
-
 
177
    QmDialogChangeTeamNumber dialog("Copy/Move/Swap Team Data",this);
-
 
178
    dialog.exec();
-
 
179
}
-
 
180
 
166
void MainWindow::ClearOneLegTimes(void)
181
void MainWindow::ClearOneLegTimes(void)
167
{
182
{
168
    bool ok;
183
    bool ok;
169
    int leg = QInputDialog::getInt(this, tr("Clear One Leg Start Time"),
184
    int leg = QInputDialog::getInt(this, tr("Clear One Leg Start Time"),
170
                                              tr("Leg:"), 0, 0, config.num_legs, 1, &ok);
185
                                              tr("Leg:"), 0, 0, config.num_legs, 1, &ok);
Line 247... Line 262...
247
                   dialog.getClear() );
262
                   dialog.getClear() );
248
        }
263
        }
249
    }
264
    }
250
}
265
}
251
 
266
 
-
 
267
void MainWindow::recalcLegTimes(void)
-
 
268
{
-
 
269
    QmDialogLegStartTimes dialog("Recalc Elesped Times",this);
-
 
270
    dialog.setDescription("The elasped times for all teams is recaclulated. This should not be neeed.");
-
 
271
    if ( QDialog::Accepted == dialog.exec() )
-
 
272
    {
-
 
273
        if ( dialog.getLeg() )
-
 
274
        {
-
 
275
            tm_recalcElapsed(dialog.getLeg());
-
 
276
        }
-
 
277
    }
-
 
278
}
-
 
279
 
252
void MainWindow::loadExternalTeams(void)
280
void MainWindow::loadExternalTeams(void)
253
{
281
{
254
    QString fileName = QFileDialog::getOpenFileName(this, tr("Load File"),
282
    QString fileName = QFileDialog::getOpenFileName(
255
                                                     filepath,
283
            this, tr("Load File"),
256
                                                     tr("Data (*.csv);;All (*.*)"),
284
            appSettings->value("Recent/ExternalTeams",filepath).toString(),
257
                                                     0,
285
            tr("Data (*.csv);;All (*.*)"),
-
 
286
            0,
258
                                                     QFileDialog::ReadOnly);
287
            QFileDialog::ReadOnly);
-
 
288
 
259
    if ( fileName.isEmpty() )
289
    if ( fileName.isEmpty() )
260
    {
290
    {
261
        return;
291
        return;
262
    }
292
    }
-
 
293
    appSettings->setValue("Recent/ExternalTeams", fileName); 
263
 
294
 
264
    QmDialogLoadExternalTeams dialog(fileName,this);
295
    QmDialogLoadExternalTeams dialog(fileName,this);
265
    dialog.exec();
296
    dialog.exec();
266
}
297
}
267
 
298
 
-
 
299
void MainWindow::loadExternalHtmlTeams(void)
-
 
300
{
-
 
301
    Qmhttppath msgBox;
-
 
302
    int rv = msgBox.exec();
-
 
303
    if (rv == QDialog::Accepted)
-
 
304
    {
-
 
305
        QmDialogLoadExternalTeams dialog( msgBox.urlLineEdit->text(), &msgBox.allData ,this);
-
 
306
        dialog.exec();
-
 
307
    }
-
 
308
    else
-
 
309
    {
-
 
310
         MainWindow::showMessage("No Web Address selected. No teams uploaded");
-
 
311
    }
-
 
312
}
-
 
313
 
268
void MainWindow::storeExternalTeams(void)
314
void MainWindow::storeExternalTeams(void)
269
{
315
{
270
    QString fileName = QFileDialog::getSaveFileName(this, tr("Store File"),
316
    QString fileName = QFileDialog::getSaveFileName(
271
                                                     filepath,
317
            this, tr("Store File"),
272
                                                     tr("Data (*.csv);;All (*.*)"),
318
            appSettings->value("Recent/storeExternalTeams",filepath).toString(),
273
                                                     0
319
            tr("Data (*.csv);;All (*.*)"),
-
 
320
            0
274
                                                     );
321
            );
275
    if ( fileName.isEmpty() )
322
    if ( fileName.isEmpty() )
276
    {
323
    {
277
        return;
324
        return;
278
    }
325
    }
-
 
326
    appSettings->setValue("Recent/storeExternalTeams", fileName); 
279
    MainWindow::showMessage("Writing external data");
327
    MainWindow::showMessage("Writing external data");
280
    QmDialogLoadExternalTeams::storeData(fileName);
328
    QmDialogLoadExternalTeams::storeData(fileName);
281
    MainWindow::showMessage("Writing external data completed");
329
    MainWindow::showMessage("Writing external data completed");
282
}
330
}
283
 
331
 
284
void MainWindow::storeTeamInfo(void)
332
void MainWindow::storeTeamInfo(void)
285
{
333
{
286
    QString fileName = QFileDialog::getSaveFileName(this, tr("Store Team Info File"),
334
    QString fileName = QFileDialog::getSaveFileName(
287
                                                     filepath,
335
            this, tr("Store Team Info File"),
288
                                                     tr("Data (*.txt);;All (*.*)"),
336
            appSettings->value("Recent/storeTeamInfo",filepath).toString(),
289
                                                     0
337
            tr("Data (*.txt);;All (*.*)"),
-
 
338
            0
290
                                                     );
339
            );
291
    if ( fileName.isEmpty() )
340
    if ( fileName.isEmpty() )
292
    {
341
    {
293
        return;
342
        return;
294
    }
343
    }
-
 
344
    appSettings->setValue("Recent/storeTeamInfo", fileName); 
295
    MainWindow::showMessage("Writing team info");
345
    MainWindow::showMessage("Writing team info");
296
    QmDialogLoadExternalTeams::storeTeamInfo(fileName);
346
    QmDialogLoadExternalTeams::storeTeamInfo(fileName);
297
    MainWindow::showMessage("Writing team info completed");
347
    MainWindow::showMessage("Writing team info completed");
298
}
348
}
299
 
349
 
Line 315... Line 365...
315
    {
365
    {
316
        pri_all_reports();
366
        pri_all_reports();
317
    }
367
    }
318
}
368
}
319
 
369
 
320
 
-
 
321
void MainWindow::displaySummary(void)
-
 
322
{
-
 
323
    QmDialogStatus dialog(this);
-
 
324
    dialog.exec();
-
 
325
}
-
 
326
 
-
 
327
void MainWindow::showAbout(void)
370
void MainWindow::showAbout(void)
328
{
371
{
329
    QmDialogAbout dialog(this);
372
    QmDialogAbout dialog(this);
330
    dialog.setText(QString("Build Date: ") + __DATE__ + " " + __TIME__ + "\nVersion: " + VERSION);
373
    dialog.setText(QString("Build Date: ") + __DATE__ + " " + __TIME__ + "\nVersion: " + VERSION);
-
 
374
    dialog.setPath(filepath);
331
    dialog.exec();
375
    dialog.exec();
332
}
376
}
333
 
377
 
-
 
378
void MainWindow::disableAllMenus(QMenu *menu)
-
 
379
{
-
 
380
    if (menu) {
-
 
381
        foreach (QAction *action, menu->actions() ) {
-
 
382
            if (action->isSeparator()) {
-
 
383
            } else if (action->menu()) {
-
 
384
                //qDebug(">>> this action is associated with a submenu, iterating it recursively...");
-
 
385
                mw->disableAllMenus(action->menu());
-
 
386
            } else {
-
 
387
                action->setDisabled(true);
-
 
388
            }
-
 
389
        }
-
 
390
    }
-
 
391
}
-
 
392
 
-
 
393
void MainWindow::disableAllTabs(void)
-
 
394
{
-
 
395
    MainWindow::showMessage ("Number of legs has changed - Restart application");
-
 
396
    shutDown = true;
-
 
397
 
-
 
398
    for(int ii = 0; ii < mw->tabWidget->count() ; ii++) {
-
 
399
        mw->tabWidget->setTabEnabled(ii, false);
-
 
400
    }
-
 
401
 
-
 
402
    foreach (QAction *action, mw->ui->menuBar->actions() ) {
-
 
403
        mw->disableAllMenus(action->menu());
-
 
404
    }
-
 
405
 
-
 
406
}
-
 
407
 
-
 
408
 
334
 
409