Fix 'approuve' button, add warning when break is not between day start and day end
This commit is contained in:
@@ -189,6 +189,7 @@ void MainWindow::compute_time() {
|
||||
updateBreakLabel();
|
||||
updateEndLabel();
|
||||
updateValidIcon();
|
||||
updateWarningIcon();
|
||||
|
||||
double late = 0.0;
|
||||
double overtime = 0.0;
|
||||
@@ -213,6 +214,14 @@ void MainWindow::updateValidIcon() {
|
||||
ui->fridayValidate->setVisible(current_week->getFri()->get_validate());
|
||||
}
|
||||
|
||||
void MainWindow::updateWarningIcon() {
|
||||
ui->mondayWarning->setVisible(current_week->getMon()->has_warning());
|
||||
ui->tuesdayWarning->setVisible(current_week->getTue()->has_warning());
|
||||
ui->wednesdayWarning->setVisible(current_week->getWed()->has_warning());
|
||||
ui->thurdayWarning->setVisible(current_week->getThu()->has_warning());
|
||||
ui->fridayWarning->setVisible(current_week->getFri()->has_warning());
|
||||
}
|
||||
|
||||
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"));
|
||||
|
||||
@@ -57,6 +57,7 @@ private:
|
||||
void updateEndLabel();
|
||||
void highlightDayOfWeek();
|
||||
void updateValidIcon();
|
||||
void updateWarningIcon();
|
||||
|
||||
QString get_save_file_path();
|
||||
Identifier get_identifier(QString objectName);
|
||||
|
||||
@@ -84,6 +84,20 @@ QJsonObject Day::to_json()
|
||||
return obj;
|
||||
}
|
||||
|
||||
bool Day::has_warning()
|
||||
{
|
||||
bool warning = false;
|
||||
foreach (BreakPoint val, breaks) {
|
||||
if (val.getStart() < start) {
|
||||
warning = true;
|
||||
}
|
||||
if (val.getEnd() > end) {
|
||||
warning = true;
|
||||
}
|
||||
}
|
||||
return warning;
|
||||
}
|
||||
|
||||
Day* Day::from_json(QJsonObject obj)
|
||||
{
|
||||
Day *result = new Day();
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
float get_time_break();
|
||||
void update(Day *);
|
||||
QJsonObject to_json();
|
||||
bool has_warning();
|
||||
|
||||
float get_total();
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ void SetDayDialog::accept()
|
||||
}
|
||||
|
||||
void SetDayDialog::validate_and_accept() {
|
||||
d->set_validate(true);
|
||||
accept();
|
||||
copy->set_validate(true);
|
||||
this->accept();
|
||||
}
|
||||
|
||||
void SetDayDialog::add_break_point()
|
||||
|
||||
Reference in New Issue
Block a user