Subversion Repositories svn1

Rev

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