1 /***************************************************************************
2 modifyconstraintteachersminrestinghoursform.cpp - description
3 -------------------
4 begin : 2017
5 copyright : (C) 2017 by Lalescu Liviu
6 email : Please see https://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address)
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software: you can redistribute it and/or modify *
12 * it under the terms of the GNU Affero General Public License as *
13 * published by the Free Software Foundation, either version 3 of the *
14 * License, or (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18 #include <QMessageBox>
19
20 #include "modifyconstraintteachersminrestinghoursform.h"
21 #include "timeconstraint.h"
22
ModifyConstraintTeachersMinRestingHoursForm(QWidget * parent,ConstraintTeachersMinRestingHours * ctr)23 ModifyConstraintTeachersMinRestingHoursForm::ModifyConstraintTeachersMinRestingHoursForm(QWidget* parent, ConstraintTeachersMinRestingHours* ctr): QDialog(parent)
24 {
25 setupUi(this);
26
27 okPushButton->setDefault(true);
28
29 connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
30 connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
31
32 centerWidgetOnScreen(this);
33 restoreFETDialogGeometry(this);
34
35 this->_ctr=ctr;
36
37 weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));
38
39 circularCheckBox->setChecked(ctr->circular);
40
41 minRestingHoursSpinBox->setMinimum(1);
42 minRestingHoursSpinBox->setMaximum(gt.rules.nHoursPerDay);
43 minRestingHoursSpinBox->setValue(ctr->minRestingHours);
44 }
45
~ModifyConstraintTeachersMinRestingHoursForm()46 ModifyConstraintTeachersMinRestingHoursForm::~ModifyConstraintTeachersMinRestingHoursForm()
47 {
48 saveFETDialogGeometry(this);
49 }
50
ok()51 void ModifyConstraintTeachersMinRestingHoursForm::ok()
52 {
53 double weight;
54 QString tmp=weightLineEdit->text();
55 weight_sscanf(tmp, "%lf", &weight);
56 if(weight<0.0 || weight>100.0){
57 QMessageBox::warning(this, tr("FET information"),
58 tr("Invalid weight (percentage)"));
59 return;
60 }
61 if(weight!=100.0){
62 QMessageBox::warning(this, tr("FET information"),
63 tr("Invalid weight (percentage) - it must be 100%"));
64 return;
65 }
66
67 this->_ctr->weightPercentage=weight;
68
69 this->_ctr->minRestingHours=minRestingHoursSpinBox->value();
70 this->_ctr->circular=circularCheckBox->isChecked();
71
72 gt.rules.internalStructureComputed=false;
73 setRulesModifiedAndOtherThings(>.rules);
74
75 this->close();
76 }
77
cancel()78 void ModifyConstraintTeachersMinRestingHoursForm::cancel()
79 {
80 this->close();
81 }
82