Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include "qmdownloadlegtimes.h"#include "ui_qmdownloadlegtimes.h"#include "mainwindow.h"#include "consts.h"#include "structs.h"#include "proto.h"QmDownloadLegTimes::QmDownloadLegTimes(QWidget *parent) :QDialog(parent),ui(new Ui::QmDownloadLegTimes){ui->setupUi(this);connect(ui->cancel, SIGNAL(clicked()), this, SLOT(close()));connect(ui->save, SIGNAL(clicked()), this, SLOT(save()));connect(ui->legNumber, SIGNAL(valueChanged(int)), this, SLOT(legNumberChanged(int)));ui->legNumber->setMaximum(config.num_legs);legNumberChanged(0);}QmDownloadLegTimes::~QmDownloadLegTimes(){delete ui;}void QmDownloadLegTimes::legNumberChanged(int leg){ui->save->setEnabled(leg != 0);}void QmDownloadLegTimes::save(void){bool manstart = !ui->legEnd->isChecked();int leg = ui->legNumber->value();/** Locate the required data file and prepare for processing*/QString filename;filename = QString("%1leg%2.txt").arg(manstart ? "S" : "").arg(QString::number(leg));MainWindow::showMessage(QString("Using: ") + filename);filename.prepend(filepath);qDebug("Using:%s", qPrintable(filename));QFile file;file.setFileName(filename);if ( ! file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text) ){MainWindow::showMessage("Cannot open external leg file");return;}QTextStream out(&file);/** Write the data to the data file*/team_type team_buf;for(int i = config.min_team; i <= config.max_team; i++ ){if( valid_field( i ) && g_record( i, &team_buf ) ){time_t ptime;if (manstart)ptime = team_buf.leg[leg].start ;elseptime = team_buf.leg[leg].end;if (ptime >= 0 ){out << i;out << " ";out << time_a( ptime );out << endl;}}}}