Rev 156 | Rev 160 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include "mainwindow.h"#include "ui_mainwindow.h"#include "qmconfigure.h"#include "qmconfclass.h"#include "qmconfwinners.h"#include "qmteamdisplay.h"#include "QMessageBox"#include "QInputDialog"#include "QTime"#include "qmdialoglegstarttimes.h"#include "qmdisqualified.h"#include "qmdatacheck.h"#include "qmdialogloadexternalteams.h"#include "QFileDialog"#include "QDir"#include "qmdialoguploadlegtimes.h"#include "consts.h"#include "structs.h"#include "proto.h"MainWindow *mw = NULL;MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow){ui->setupUi(this);mw = this;ui->tabWidget->addTab( new QmConfigure, "Configure");ui->tabWidget->addTab( new QmConfClass, "Class");ui->tabWidget->addTab( new QmConfWinners, "Winners");ui->tabWidget->addTab( new qmTeamDisplay, "Team Data");ui->tabWidget->addTab( new qmDisqualified, "Disqual");ui->tabWidget->addTab( new qmDataCheck, "Data Check");QMenu *m0 = new QMenu ("Team");ui->menuBar->addMenu(m0);m0->addAction("Reset All Team Data", this, SLOT(resetTeamData()));m0->addAction("Generate dummy team names", this, SLOT(generateDummyTeamNames()));QMenu *m1 = new QMenu ("Leg Time Setup");ui->menuBar->addMenu(m1);m1->addAction("Clear ALL Leg Times", this, SLOT(clearLegTimes()));m1->addAction("Clear single leg start times", this, SLOT(ClearOneLegTimes()));m1->addSeparator();m1->addAction("Set Start Times", this, SLOT(setStartTimes()));m1->addAction("Set calculated leg start", this, SLOT(setCalcLegStart()));m1->addAction("Set ordered incremental leg start", this, SLOT(setOrderedIncLegStart()));m1->addAction("Set staggered start time", this, SLOT(setStaggeredLegStart()));m1->addAction("Set fixed start time", this, SLOT(setFixedLegStart()));QMenu *m2 = new QMenu ("Upload");ui->menuBar->addMenu(m2);m2->addAction("Load team information from external file", this, SLOT(loadExternalTeams()));m2->addAction("Store team information to external file", this, SLOT(storeExternalTeams()));m2->addAction("Create external leg data file", this, SLOT(storeLegData()));m2->addAction("Upload time information", this, SLOT(uploadLegData()));}MainWindow::~MainWindow(){delete ui;}void MainWindow::showMessage( const QString & msg, int timeout){if ( mw ){mw->ui->statusBar->showMessage(msg, timeout);}}void MainWindow::changeEvent(QEvent *e){QMainWindow::changeEvent(e);switch (e->type()) {case QEvent::LanguageChange:ui->retranslateUi(this);break;default:break;}}void MainWindow::setStartTimes(void){if ( QMessageBox::Ok == QMessageBox::warning(this, tr("Mara"),tr("This will reset the start times for all teams based on the Category configuration.\n""Are you sure you want to do this?"),QMessageBox::Cancel,QMessageBox::Ok)){leg_start();}}void MainWindow::clearLegTimes(void){if ( QMessageBox::Ok == QMessageBox::warning(this, tr("Mara"),tr("This will clear ALL leg times for ALL teams.\n""Are you sure you want to do this?"),QMessageBox::Cancel,QMessageBox::Ok)){leg_ini();}}void MainWindow::resetTeamData(void){if ( QMessageBox::Ok == QMessageBox::warning(this, tr("Mara"),tr("This will clear ALL team information.\n""Are you sure you want to do this?"),QMessageBox::Cancel,QMessageBox::Ok)){tm_init();}}void MainWindow::generateDummyTeamNames(void){if ( QMessageBox::Ok == QMessageBox::warning(this, tr("Mara"),tr("This will generate DUMMY team names.\n""Are you sure you want to do this?"),QMessageBox::Cancel,QMessageBox::Ok)){tm_gen();}}void MainWindow::ClearOneLegTimes(void){bool ok;int leg = QInputDialog::getInt(this, tr("Clear One Leg Start Time"),tr("Leg:"), 0, 0, config.num_legs, 1, &ok);if ( ok && leg){tm_clearleg_specified(leg, FALSE);}}void MainWindow::setCalcLegStart(void){QmDialogLegStartTimes dialog("Calculate Leg Start Time",this);dialog.setDeltaTimeLabel("Delta Time");qDebug ("Must disable stuff");if ( QDialog::Accepted == dialog.exec() ){if ( dialog.getLeg() ){tm_lgs(dialog.getLeg(),dialog.getDeltaTime(),dialog.getReport(),dialog.getClear() );}}}void MainWindow::setOrderedIncLegStart(void){QmDialogLegStartTimes dialog("Ordered Incremental Leg Start Time",this);dialog.setTimeLabel("Start Time");dialog.setDeltaTimeLabel("Delta Time");if ( QDialog::Accepted == dialog.exec() ){if ( dialog.getLeg() ){tm_lgs1(dialog.getLeg(),dialog.getTime(),dialog.getDeltaTime(),dialog.getReport(),dialog.getClear() );}}}void MainWindow::setStaggeredLegStart(void){QmDialogLegStartTimes dialog("Staggered Leg Start Time",this);dialog.setTimeLabel("Start Time");dialog.setDeltaTimeLabel("Stagger Time");if ( QDialog::Accepted == dialog.exec() ){if ( dialog.getLeg() ){tm_staggered(dialog.getLeg(),dialog.getTime(),dialog.getDeltaTime(),dialog.getReport(),dialog.getClear() );}}}void MainWindow::setFixedLegStart(void){QmDialogLegStartTimes dialog("Fixed Leg Start Time",this);dialog.setTimeLabel("Start Time");//dialog.setDeltaTimeLabel("Stagger Time");qDebug ("Must Hide stagger time");if ( QDialog::Accepted == dialog.exec() ){if ( dialog.getLeg() ){tm_fixedstart(dialog.getLeg(),dialog.getTime(),//dialog.getDeltaTime(),dialog.getReport(),dialog.getClear() );}}}void MainWindow::loadExternalTeams(void){QString fileName = QFileDialog::getOpenFileName(this, tr("Load File"),QDir::currentPath(),tr("Data (*.csv);;All (*.*)"),0,QFileDialog::ReadOnly);if ( fileName.isEmpty() ){return;}QmDialogLoadExternalTeams dialog(fileName,this);dialog.exec();}void MainWindow::storeExternalTeams(void){QString fileName = QFileDialog::getSaveFileName(this, tr("Store File"),QDir::currentPath(),tr("Data (*.csv);;All (*.*)"),0);if ( fileName.isEmpty() ){return;}MainWindow::showMessage("Writing external data");QmDialogLoadExternalTeams::storeData(fileName);MainWindow::showMessage("Writing external data completed");}void MainWindow::storeTeamInfo(void){QString fileName = QFileDialog::getSaveFileName(this, tr("Store Team Info File"),QDir::currentPath(),tr("Data (*.txt);;All (*.*)"),0);if ( fileName.isEmpty() ){return;}MainWindow::showMessage("Writing team info");QmDialogLoadExternalTeams::storeTeamInfo(fileName);MainWindow::showMessage("Writing team info completed");}void MainWindow::storeLegData(void){MainWindow::showMessage("Store Leg Data: Not yet implemented");}void MainWindow::uploadLegData(void){QmDialogUploadLegTimes dialog(this);dialog.exec();}/*========================================================================** Position the cursor on the screen** Purpose:* This function is called to Position the cursor on the screen** Parameters:* x col number* y line number** Returns:* Nothing**========================================================================*/void cur( int x, int y ){}/*========================================================================** Clears the vdu screen** Purpose:* This function is called to Clears the vdu screen* From the Microsoft Web Site** Parameters:* None** Returns:* Nothing**========================================================================*/void clearscreen( void ){}#include <stdio.h>int printf( const char *format, ... ){va_list ap;char pp[200];int len;va_start( ap, format );len = vsprintf( pp, format, ap );va_end( ap );qDebug("%s",pp);return ( len );}