Week late and overtime
This commit is contained in:
@@ -188,6 +188,7 @@ void MainWindow::compute_time() {
|
||||
updateStartLabel();
|
||||
updateBreakLabel();
|
||||
updateEndLabel();
|
||||
updateWeekTime();
|
||||
updateValidIcon();
|
||||
updateWarningIcon();
|
||||
|
||||
@@ -222,6 +223,21 @@ void MainWindow::updateWarningIcon() {
|
||||
ui->fridayWarning->setVisible(current_week->getFri()->has_warning());
|
||||
}
|
||||
|
||||
void MainWindow::updateWeekTime()
|
||||
{
|
||||
double t = (current_week->total() + current_week->getTimeDeltaInHours()) - week_template->total();
|
||||
if (t > 0) {
|
||||
ui->overtime_time_label_week->setText(Tools::double_to_string_time(t));
|
||||
ui->late_time_label_week->setText("0h");
|
||||
} else if(t < 0) {
|
||||
ui->late_time_label_week->setText(Tools::double_to_string_time(-t));
|
||||
ui->overtime_time_label_week->setText("0h");
|
||||
} else {
|
||||
ui->overtime_time_label_week->setText("0h");
|
||||
ui->late_time_label_week->setText("0h");
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateStartLabel() {
|
||||
ui->monStartLabel->setText(current_week->getMon()->get_start().toString("HH:mm"));
|
||||
ui->tueStartLabel->setText(current_week->getTue()->get_start().toString("HH:mm"));
|
||||
|
||||
@@ -58,6 +58,7 @@ private:
|
||||
void highlightDayOfWeek();
|
||||
void updateValidIcon();
|
||||
void updateWarningIcon();
|
||||
void updateWeekTime();
|
||||
|
||||
QString get_save_file_path();
|
||||
Identifier get_identifier(QString objectName);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <QDialog>
|
||||
|
||||
#include "models/week.h"
|
||||
#include "tools.h"
|
||||
|
||||
namespace Ui {
|
||||
class WeekOption;
|
||||
@@ -24,6 +25,8 @@ private slots:
|
||||
private:
|
||||
Ui::WeekOption *ui;
|
||||
|
||||
void compute();
|
||||
|
||||
int time_delta;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>WeekOption</class>
|
||||
<widget class="QDialog" name="WeekOption">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>372</width>
|
||||
<height>159</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>372</width>
|
||||
<height>159</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>372</width>
|
||||
<height>159</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<widget class="QSpinBox" name="time_delta_spinbox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>40</y>
|
||||
<width>81</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> min</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-1000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>101</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Réalignement</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>44</y>
|
||||
<width>131</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delta (en minutes)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="validate_button">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>120</y>
|
||||
<width>88</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Valider</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>142</x>
|
||||
<y>55</y>
|
||||
<width>131</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="midLineWidth">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>16</y>
|
||||
<width>241</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>validate_button</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>WeekOption</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>313</x>
|
||||
<y>132</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>185</x>
|
||||
<y>79</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user