VDOTCalculator::VDOTCalculator(QWidget *parent) : QDialog(parent)
{
    bool metricRnPace = appsettings->value(this, GC_PACE, true).toBool();
    setWindowTitle(tr("VDOT and T-Pace Calculator"));

    HelpWhatsThis *help = new HelpWhatsThis(this);
    this->setWhatsThis(help->getWhatsThisText(HelpWhatsThis::MenuBar_Tools_VDOT_CALC));

    setAttribute(Qt::WA_DeleteOnClose);

    setMinimumSize(300 *dpiXFactor, 300 *dpiYFactor);

    QVBoxLayout *mainVBox = new QVBoxLayout(this);

    QHBoxLayout *distHBox = new QHBoxLayout;
    distHBox->addWidget(new QLabel(tr("Your Test Race:")));
    distHBox->addStretch();
    distSpinBox = new QDoubleSpinBox(this);
    distSpinBox->setDecimals(3);
    if (metricRnPace) {
        distSpinBox->setRange(1.5, 42.195);
        distSpinBox->setSuffix(tr(" km"));
        distSpinBox->setValue(10.0);
    } else {
        distSpinBox->setRange(1.5/KM_PER_MILE, 42.195/KM_PER_MILE);
        distSpinBox->setSuffix(tr(" mi"));
        distSpinBox->setValue(10.0/KM_PER_MILE);
    }
    distSpinBox->setSingleStep(1.0);
    distSpinBox->setWrapping(false);
    distSpinBox->setAlignment(Qt::AlignRight);
    distHBox->addWidget(distSpinBox);
    distHBox->addStretch();
    mainVBox->addLayout(distHBox);

    QHBoxLayout *timeHBox = new QHBoxLayout;
    hoursSpinBox = new QDoubleSpinBox(this);
    hoursSpinBox->setDecimals(0);
    hoursSpinBox->setRange(0, 6);
    hoursSpinBox->setSuffix(tr(" hours"));
    hoursSpinBox->setSingleStep(1.0);
    hoursSpinBox->setWrapping(false);
    hoursSpinBox->setAlignment(Qt::AlignRight);
    hoursSpinBox->setValue(0.0);
    timeHBox->addWidget(hoursSpinBox);
    minsSpinBox = new QDoubleSpinBox(this);
    minsSpinBox->setDecimals(0);
    minsSpinBox->setRange(0.0, 59.0);
    minsSpinBox->setSuffix(tr(" mins"));
    minsSpinBox->setSingleStep(1.0);
    minsSpinBox->setWrapping(false);
    minsSpinBox->setAlignment(Qt::AlignRight);
    minsSpinBox->setValue(40.0);
    timeHBox->addWidget(minsSpinBox);
    secsSpinBox = new QDoubleSpinBox(this);
    secsSpinBox->setDecimals(0);
    secsSpinBox->setRange(0.0, 59.0);
    secsSpinBox->setSuffix(tr(" secs"));
    secsSpinBox->setSingleStep(1.0);
    secsSpinBox->setWrapping(true);
    secsSpinBox->setAlignment(Qt::AlignRight);
    timeHBox->addWidget(secsSpinBox);
    mainVBox->addLayout(timeHBox);

    mainVBox->addStretch();

    QHBoxLayout *vdotHBox = new QHBoxLayout;
    vdotHBox->addStretch();
    labelVDOT = new QLabel(tr("Your Daniels VDOT:"));
    vdotHBox->addWidget(labelVDOT);
    txtVDOT = new QLineEdit(this);
    txtVDOT->setAlignment(Qt::AlignRight);
    txtVDOT->setReadOnly(true);
    vdotHBox->addWidget(txtVDOT, Qt::AlignLeft);
    vdotHBox->addStretch();
    mainVBox->addLayout(vdotHBox);

    mainVBox->addStretch();

    // Training Pace Table
    QVBoxLayout *tableLayout = new QVBoxLayout;
    labelTPACE = new QLabel(tr("Your Training Paces:"));
    tableLayout->addWidget(labelTPACE);
    tableWidgetTPACE = new QTableWidget(5, 3, this);
    tableWidgetTPACE->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    for (int j = 0; j< 3; j++) tableWidgetTPACE->setColumnWidth(j, 60*dpiXFactor);
    QStringList vLabels;
    vLabels<<tr("E-Pace")<<tr("M-Pace")<< tr("T-Pace")<<tr("I-Pace")<<tr("R-Pace");
    tableWidgetTPACE->setVerticalHeaderLabels(vLabels);
    tableWidgetTPACE->verticalHeader()->setStretchLastSection(true);
    QStringList hLabels;
    hLabels<< tr("200")<<tr("400")<<(metricRnPace ? tr("1000") : tr("mile"));
    tableWidgetTPACE->setHorizontalHeaderLabels(hLabels);
    tableWidgetTPACE->horizontalHeader()->setStretchLastSection(true);
    for (int i = 0; i < tableWidgetTPACE->rowCount(); i++) {
        for (int j = 0; j < tableWidgetTPACE->rowCount(); j++) {
            QTableWidgetItem *item = new QTableWidgetItem();
            item->setFlags(item->flags() ^ Qt::ItemIsEditable);
            item->setTextAlignment(Qt::AlignCenter);
            tableWidgetTPACE->setItem(i, j, item);
        }
    }
    tableWidgetTPACE->selectRow(2); // Highlight T-Pace
    tableWidgetTPACE->resizeRowsToContents();
    tableLayout->addWidget(tableWidgetTPACE);
    mainVBox->addLayout(tableLayout);

    mainVBox->addStretch();

    QHBoxLayout *targetHBox = new QHBoxLayout;
    targetHBox->addWidget(new QLabel(tr("Your Target Race:")));
    targetHBox->addStretch();
    targetSpinBox = new QDoubleSpinBox(this);
    targetSpinBox->setDecimals(3);
    if (metricRnPace) {
        targetSpinBox->setRange(1.5, 42.195);
        targetSpinBox->setSuffix(tr(" km"));
        targetSpinBox->setValue(21.0975);
    } else {
        targetSpinBox->setRange(1.5/KM_PER_MILE, 42.195/KM_PER_MILE);
        targetSpinBox->setSuffix(tr(" mi"));
        targetSpinBox->setValue(21.0975/KM_PER_MILE);
    }
    targetSpinBox->setSingleStep(1.0);
    targetSpinBox->setWrapping(false);
    targetSpinBox->setAlignment(Qt::AlignRight);
    targetHBox->addWidget(targetSpinBox);
    targetHBox->addStretch();
    mainVBox->addLayout(targetHBox);
    QHBoxLayout *eqvHBox = new QHBoxLayout;
    eqvHBox->addStretch();
    labelEQV = new QLabel(tr("Equivalent Time:"));
    eqvHBox->addWidget(labelEQV);
    txtEQV = new QLineEdit(this);
    txtEQV->setAlignment(Qt::AlignRight);
    txtEQV->setReadOnly(true);
    eqvHBox->addWidget(txtEQV, Qt::AlignLeft);
    eqvHBox->addStretch();
    mainVBox->addLayout(eqvHBox);

    mainVBox->addStretch();

    QHBoxLayout *buttonHBox = new QHBoxLayout;
    btnCalculate = new QPushButton(this);
    btnCalculate->setText(tr("Calculate"));
    buttonHBox->addStretch();
    buttonHBox->addWidget(btnCalculate);
    btnOK = new QPushButton(this);
    btnOK->setText(tr("Done"));
    buttonHBox->addWidget(btnOK);
    mainVBox->addLayout(buttonHBox);

    connect(btnOK, SIGNAL(clicked()), this, SLOT(on_btnOK_clicked()));
    connect(btnCalculate, SIGNAL(clicked()), this, SLOT(on_btnCalculate_clicked()));
}
Пример #2
0
EstimateCPDialog::EstimateCPDialog(QWidget *parent) : QDialog(parent)
{
    setWindowTitle(tr("Critical Power Estimator"));

    HelpWhatsThis *help = new HelpWhatsThis(this);
    this->setWhatsThis(help->getWhatsThisText(HelpWhatsThis::MenuBar_Tools_CP_EST));

    setAttribute(Qt::WA_DeleteOnClose);

    setFixedSize(300, 300);

    QVBoxLayout *mainVBox = new QVBoxLayout(this);

    QHBoxLayout *hlayout = new QHBoxLayout;
    QLabel *sportLabel = new QLabel(tr("Sport"));
    sportCombo = new QComboBox();
    sportCombo->addItem(tr("Bike"));
    sportCombo->addItem(tr("Run"));
    sportCombo->addItem(tr("Swim"));
    sportCombo->setCurrentIndex(0);
    hlayout->addStretch();
    hlayout->addWidget(sportLabel);
    hlayout->addWidget(sportCombo);
    hlayout->addStretch();
    mainVBox->addLayout(hlayout);

    mainVBox->addWidget(new QLabel(tr("Your best short effort (3-5 min):")));
    mainVBox->addLayout(setupMinsSecs(shortMinsSpinBox, shortSecsSpinBox,
                                      shortWattsSpinBox, 5.0, 3.0));

    mainVBox->addWidget(new QLabel(tr("Your best long effort (15-60 min):")));
    mainVBox->addLayout(setupMinsSecs(longMinsSpinBox, longSecsSpinBox,
                                      longWattsSpinBox, 60.0, 20.0));
    mainVBox->addStretch();

    QHBoxLayout *cpHBox = new QHBoxLayout;
    cpHBox->addStretch();
    labelCP = new QLabel(tr("Your critical power:"));
    cpHBox->addWidget(labelCP);
    txtCP = new QLineEdit(this);
    txtCP->setAlignment(Qt::AlignRight);
    txtCP->setReadOnly(true);
    cpHBox->addWidget(txtCP, Qt::AlignLeft);
    cpHBox->addStretch();
    mainVBox->addLayout(cpHBox);

    QHBoxLayout *wpHBox = new QHBoxLayout;
    wpHBox->addStretch();
    labelWP = new QLabel(tr("Your W':"));
    wpHBox->addWidget(labelWP);
    txtWP = new QLineEdit(this);
    txtWP->setAlignment(Qt::AlignRight);
    txtWP->setReadOnly(true);
    wpHBox->addWidget(txtWP, Qt::AlignLeft);
    wpHBox->addStretch();
    mainVBox->addLayout(wpHBox);

    mainVBox->addStretch();

    QHBoxLayout *buttonHBox = new QHBoxLayout;
    btnCalculate = new QPushButton(this);
    btnCalculate->setText(tr("Estimate"));
    buttonHBox->addStretch();
    buttonHBox->addWidget(btnCalculate);
    btnOK = new QPushButton(this);
    btnOK->setText(tr("Done"));
    buttonHBox->addWidget(btnOK);
    mainVBox->addLayout(buttonHBox);

    connect(sportCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changeSport()));
    connect(btnOK, SIGNAL(clicked()), this, SLOT(on_btnOK_clicked()));
    connect(btnCalculate, SIGNAL(clicked()), this, SLOT(on_btnCalculate_clicked()));
}