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

View File

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

View File

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

View File

@@ -34,9 +34,9 @@
<widget class="QPushButton" name="pushButton"> <widget class="QPushButton" name="pushButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>200</x> <x>10</x>
<y>373</y> <y>410</y>
<width>201</width> <width>191</width>
<height>23</height> <height>23</height>
</rect> </rect>
</property> </property>
@@ -137,74 +137,12 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </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"> <widget class="QPushButton" name="validateButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>200</x> <x>220</x>
<y>403</y> <y>410</y>
<width>201</width> <width>191</width>
<height>23</height> <height>23</height>
</rect> </rect>
</property> </property>
@@ -273,7 +211,7 @@ color: white;</string>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>350</y> <y>380</y>
<width>421</width> <width>421</width>
<height>20</height> <height>20</height>
</rect> </rect>
@@ -314,6 +252,52 @@ color: rgb(255, 255, 255);</string>
<enum>Qt::IgnoreAction</enum> <enum>Qt::IgnoreAction</enum>
</property> </property>
</widget> </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> </widget>
<resources/> <resources/>
<connections/> <connections/>

View File

@@ -121,55 +121,15 @@
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
<widget class="QWidget" name="layoutWidget"> <widget class="QLabel" name="total_label">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>90</y> <y>107</y>
<width>156</width> <width>152</width>
<height>62</height> <height>41</height>
</rect> </rect>
</property> </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"> <property name="styleSheet">
<string notr="true">font-size: 28px; <string notr="true">font-size: 28px;
color: white;</string> color: white;</string>
@@ -178,11 +138,6 @@ color: white;</string>
<string>0h</string> <string>0h</string>
</property> </property>
</widget> </widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget> </widget>
<resources/> <resources/>
<connections> <connections>