47 lines
987 B
C++
47 lines
987 B
C++
#include "weekoption.h"
|
|
#include "ui_weekoption.h"
|
|
|
|
WeekOption::WeekOption(Week *w, QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::WeekOption)
|
|
{
|
|
ui->setupUi(this);
|
|
this->time_delta = w->getTimeDelta();
|
|
ui->time_delta_spinbox->setValue(time_delta);
|
|
compute();
|
|
connect(ui->time_delta_spinbox, &QSpinBox::valueChanged, this, &WeekOption::set_time_delta);
|
|
}
|
|
|
|
WeekOption::~WeekOption()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
int WeekOption::get_time_delta()
|
|
{
|
|
return this->time_delta;
|
|
}
|
|
|
|
void WeekOption::set_time_delta(int value)
|
|
{
|
|
this->time_delta = value;
|
|
compute();
|
|
}
|
|
|
|
void WeekOption::compute()
|
|
{
|
|
int m = this->time_delta;
|
|
int h = 0;
|
|
while (m > 59) {
|
|
h++;
|
|
m -= 60;
|
|
}
|
|
QString minutes = "";
|
|
if (m >= 10) {
|
|
minutes = QString::number(m, 'g', 2);
|
|
} else {
|
|
minutes = QString("0%1").arg(QString::number(m, 'g', 2));
|
|
}
|
|
ui->total_label->setText(QString("%1h%2").arg(QString::number(h, 'g', 2), minutes));
|
|
}
|