Starting working on non working days

This commit is contained in:
Aurélie Delhaie
2022-10-16 14:49:10 +02:00
parent 63d1ca329f
commit 6a44c4afd9
6 changed files with 83 additions and 125 deletions

View File

@@ -203,6 +203,8 @@ void MainWindow::compute_time() {
overtime += (w->total() - week_template->total()) + w->getTimeDeltaInHours();
}
}
late -= current_week->getTimeDeltaInHours();
overtime += - current_week->getTimeDeltaInHours();
ui->late_time_label->setText(Tools::double_to_string_time((late > 0.0) ? late : 0.0));
ui->overtime_time_label->setText(Tools::double_to_string_time((overtime > 0.0) ? overtime : 0.0));
}

View File

@@ -28,6 +28,9 @@ Day::~Day()
}
float Day::get_total() {
if (notWorking) {
return 0.0;
}
int sec = start.secsTo(end);
int minutes = sec / 60;
float breakTime = get_time_break();
@@ -48,6 +51,11 @@ void Day::set_validate(bool value) {
validate = value;
}
void Day::set_working(bool value)
{
this->notWorking = value;
}
void Day::setBreaks(QVector<BreakPoint*> breaks)
{
this->breaks = breaks;
@@ -119,6 +127,11 @@ bool Day::get_validate() {
return validate;
}
bool Day::not_working()
{
return notWorking;
}
float Day::get_time_break()
{
float result = 0;
@@ -133,6 +146,7 @@ void Day::update(Day *old)
this->start = old->start;
this->end = old->end;
this->validate = old->validate;
this->notWorking = old->notWorking;
foreach (BreakPoint *bp, breaks) {
delete bp;

View File

@@ -21,6 +21,7 @@ private:
QTime end;
QVector<BreakPoint*> breaks;
bool validate;
bool notWorking;
public:
Day();
@@ -30,12 +31,14 @@ public:
void set_start(QTime value);
void set_end(QTime value);
void set_validate(bool);
void set_working(bool);
void setBreaks(QVector<BreakPoint*>);
QTime get_start();
QTime get_end();
QVector<BreakPoint*> getBreaks();
bool get_validate();
bool not_working();
float get_time_break();
void update(Day *);
QJsonObject to_json();

View File

@@ -55,7 +55,7 @@ void SetDayDialog::accept()
}
void SetDayDialog::validate_and_accept() {
copy->set_validate(true);
copy->set_validate(!copy->not_working());
this->accept();
}

View File

@@ -34,9 +34,9 @@
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>200</x>
<y>373</y>
<width>201</width>
<x>10</x>
<y>410</y>
<width>191</width>
<height>23</height>
</rect>
</property>
@@ -137,74 +137,12 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>18</x>
<y>372</y>
<width>156</width>
<height>62</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/clock/pictures/clock-8-128.png) 0 0 0 0 stretch stretch;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<property name="text">
<string>Temps total</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="total_label">
<property name="styleSheet">
<string notr="true">font-size: 28px;
color: white;</string>
</property>
<property name="text">
<string>0h</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QPushButton" name="validateButton">
<property name="geometry">
<rect>
<x>200</x>
<y>403</y>
<width>201</width>
<x>220</x>
<y>410</y>
<width>191</width>
<height>23</height>
</rect>
</property>
@@ -273,7 +211,7 @@ color: white;</string>
<property name="geometry">
<rect>
<x>0</x>
<y>350</y>
<y>380</y>
<width>421</width>
<height>20</height>
</rect>
@@ -314,6 +252,52 @@ color: rgb(255, 255, 255);</string>
<enum>Qt::IgnoreAction</enum>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>10</x>
<y>370</y>
<width>91</width>
<height>19</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<property name="text">
<string>Temps total</string>
</property>
</widget>
<widget class="QLabel" name="total_label">
<property name="geometry">
<rect>
<x>100</x>
<y>360</y>
<width>101</width>
<height>31</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font-size: 28px;
color: white;</string>
</property>
<property name="text">
<string>0h</string>
</property>
</widget>
<widget class="QCheckBox" name="notWorkingCheckbox">
<property name="geometry">
<rect>
<x>210</x>
<y>350</y>
<width>191</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Jour non travaillé</string>
</property>
</widget>
</widget>
<resources/>
<connections/>

View File

@@ -121,67 +121,22 @@
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QLabel" name="total_label">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>156</width>
<height>62</height>
<y>107</y>
<width>152</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/clock/pictures/clock-8-128.png) 0 0 0 0 stretch stretch;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<property name="text">
<string>Temps total</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="total_label">
<property name="styleSheet">
<string notr="true">font-size: 28px;
<property name="styleSheet">
<string notr="true">font-size: 28px;
color: white;</string>
</property>
<property name="text">
<string>0h</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</property>
<property name="text">
<string>0h</string>
</property>
</widget>
</widget>
<resources/>