Subversion Repositories svn1

Rev

Rev 129 | Rev 131 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
126 david 1
#include "mainwindow.h"
2
#include "ui_mainwindow.h"
3
#include "qmconfigure.h"
4
#include "qmconfclass.h"
5
#include "qmconfwinners.h"
6
#include "qmteamdisplay.h"
7
#include "QMessageBox"
129 david 8
#include "QInputDialog"
130 - 9
#include "QTime"
10
#include "qmdialoglegstarttimes.h"
126 david 11
 
12
#include    "consts.h"
13
#include    "structs.h"
14
#include    "proto.h"
15
 
16
MainWindow *mw = NULL;
17
 
18
MainWindow::MainWindow(QWidget *parent) :
19
    QMainWindow(parent),
20
    ui(new Ui::MainWindow)
21
{
22
    ui->setupUi(this);
23
    mw = this;
24
 
25
    ui->tabWidget->addTab( new QmConfigure,   "Configure");
26
    ui->tabWidget->addTab( new QmConfClass,   "Class");
27
    ui->tabWidget->addTab( new QmConfWinners, "Winners");
28
    ui->tabWidget->addTab( new qmTeamDisplay, "Team Data");
29
 
127 - 30
    QMenu *m1 = new QMenu ("Leg Time Setup");
31
    ui->menuBar->addMenu(m1);
126 david 32
    m1->addAction("Set Start Times", this, SLOT(setStartTimes()));
127 - 33
    m1->addAction("Clear ALL Leg Times", this, SLOT(clearLegTimes()));
34
    m1->addAction("Reset All Team Data", this, SLOT(resetTeamData()));
128 - 35
    m1->addAction("Generate dummy team names", this, SLOT(generateDummyTeamNames()));
129 david 36
    m1->addAction("Clear single leg start times", this, SLOT(ClearOneLegTimes()));
37
    m1->addAction("Set calculated leg start", this, SLOT(setCalcLegStart()));
126 david 38
 
39
 
127 - 40
 
129 david 41
 
126 david 42
}
43
 
44
MainWindow::~MainWindow()
45
{
46
    delete ui;
47
}
48
 
49
void MainWindow::changeEvent(QEvent *e)
50
{
51
    QMainWindow::changeEvent(e);
52
    switch (e->type()) {
53
    case QEvent::LanguageChange:
54
        ui->retranslateUi(this);
55
        break;
56
    default:
57
        break;
58
    }
59
}
60
 
61
void MainWindow::setStartTimes(void)
62
{
127 - 63
    if ( QMessageBox::Ok == QMessageBox::warning(this, tr("Mara"),
126 david 64
                                    tr("This will reset the start times for all teams.\n"
65
                                       "Are you sure you want to do this?"),
66
                                    QMessageBox::Cancel,
67
                                    QMessageBox::Ok))
68
    {
127 - 69
        leg_start();
126 david 70
    }
127 - 71
 
126 david 72
}
73
 
127 - 74
void MainWindow::clearLegTimes(void)
75
{
76
    if ( QMessageBox::Ok == QMessageBox::warning(this, tr("Mara"),
77
                                    tr("This will clear ALL leg times for ALL teams.\n"
78
                                       "Are you sure you want to do this?"),
79
                                    QMessageBox::Cancel,
80
                                    QMessageBox::Ok))
81
    {
82
        leg_ini();
83
    }
84
}
85
 
86
void MainWindow::resetTeamData(void)
87
{
88
    if ( QMessageBox::Ok == QMessageBox::warning(this, tr("Mara"),
89
                                    tr("This will clear ALL team information.\n"
90
                                       "Are you sure you want to do this?"),
91
                                    QMessageBox::Cancel,
92
                                    QMessageBox::Ok))
93
    {
94
        tm_init();
95
    }
96
}
97
 
128 - 98
void MainWindow::generateDummyTeamNames(void)
99
{
100
    if ( QMessageBox::Ok == QMessageBox::warning(this, tr("Mara"),
101
                                    tr("This will generate DUMMY team names.\n"
102
                                       "Are you sure you want to do this?"),
103
                                    QMessageBox::Cancel,
104
                                    QMessageBox::Ok))
105
    {
106
        tm_gen();
107
    }
108
}
109
 
129 david 110
void MainWindow::ClearOneLegTimes(void)
111
{
112
    bool ok;
113
    int leg = QInputDialog::getInt(this, tr("Clear One Leg Start Time"),
114
                                              tr("Leg:"), 0, 0, config.num_legs, 1, &ok);
115
    if ( ok && leg)
116
    {
117
        tm_clearleg_specified(leg, FALSE, 6);
118
    }
119
}
120
 
121
void MainWindow::setCalcLegStart(void)
122
{
130 - 123
    QmDialogLegStartTimes dialog("Calculate Leg Start Time",this);
124
    if ( QDialog::Accepted == dialog.exec() )
129 david 125
    {
130 - 126
        if ( dialog.getLeg() )
127
        {
128
            tm_lgs(dialog.getLeg(),
129
                   dialog.getTime(),
130
                   dialog.getReport(),
131
                   dialog.getClear() );
132
        }
129 david 133
    }
130 - 134
 
129 david 135
}
126 david 136
/*========================================================================
137
 *
138
 *  Position the cursor on the screen
139
 *
140
 *  Purpose:
141
 *      This function is called to Position the cursor on the screen
142
 *
143
 *  Parameters:
144
 *      x               col number
145
 *      y               line number
146
 *
147
 *  Returns:
148
 *      Nothing
149
 *
150
 *========================================================================*/
151
 
152
void cur( int x, int y )
153
{
154
}
155
 
156
/*========================================================================
157
 *
158
 *  Clears the vdu screen
159
 *
160
 *  Purpose:
161
 *      This function is called to Clears the vdu screen
162
 *      From the Microsoft Web Site
163
 *
164
 *  Parameters:
165
 *      None
166
 *
167
 *  Returns:
168
 *      Nothing
169
 *
170
 *========================================================================*/
171
 
172
void clearscreen( void )
173
{
174
}
175
#include    <stdio.h>
176
int printf( const char *format, ... )
177
{
178
    va_list     ap;
179
    char        pp[200];
180
    int         len;
181
 
182
 
183
 
184
    va_start( ap, format );
185
    len = vsprintf( pp, format, ap );
186
    va_end( ap );
187
    qDebug("%s",pp);
188
    return ( len );
189
}
190