Week late and overtime
This commit is contained in:
@@ -8,6 +8,7 @@ WeekOption::WeekOption(Week *w, QWidget *parent) :
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -24,4 +25,22 @@ int WeekOption::get_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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user