1 /***************************************************************************
2 modifyconstraintteachersminmorningsperweekform.cpp - description
3 -------------------
4 begin : 2009
5 copyright : (C) 2009 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
19
20 #include "modifyconstraintteachersminmorningsperweekform.h"
21 #include "timeconstraint.h"
22
23 #include <QMessageBox>
24
ModifyConstraintTeachersMinMorningsPerWeekForm(QWidget * parent,ConstraintTeachersMinMorningsPerWeek * ctr)25 ModifyConstraintTeachersMinMorningsPerWeekForm::ModifyConstraintTeachersMinMorningsPerWeekForm(QWidget* parent, ConstraintTeachersMinMorningsPerWeek* ctr): QDialog(parent)
26 {
27 setupUi(this);
28
29 okPushButton->setDefault(true);
30
31 connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
32 connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
33
34 centerWidgetOnScreen(this);
35 restoreFETDialogGeometry(this);
36
37 this->_ctr=ctr;
38
39 weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));
40
41 updateMinMorningsSpinBox();
42
43 minMorningsSpinBox->setValue(ctr->minMorningsPerWeek);
44 }
45
~ModifyConstraintTeachersMinMorningsPerWeekForm()46 ModifyConstraintTeachersMinMorningsPerWeekForm::~ModifyConstraintTeachersMinMorningsPerWeekForm()
47 {
48 saveFETDialogGeometry(this);
49 }
50
updateMinMorningsSpinBox()51 void ModifyConstraintTeachersMinMorningsPerWeekForm::updateMinMorningsSpinBox(){
52 minMorningsSpinBox->setMinimum(1);
53 minMorningsSpinBox->setMaximum(gt.rules.nDaysPerWeek/2);
54 }
55
ok()56 void ModifyConstraintTeachersMinMorningsPerWeekForm::ok()
57 {
58 double weight;
59 QString tmp=weightLineEdit->text();
60 weight_sscanf(tmp, "%lf", &weight);
61 if(weight<0.0 || weight>100.0){
62 QMessageBox::warning(this, tr("FET information"),
63 tr("Invalid weight (percentage)"));
64 return;
65 }
66 if(weight!=100.0){
67 QMessageBox::warning(this, tr("FET information"),
68 tr("Invalid weight (percentage) - it has to be 100%"));
69 return;
70 }
71
72 int min_mornings=minMorningsSpinBox->value();
73
74 this->_ctr->weightPercentage=weight;
75 this->_ctr->minMorningsPerWeek=min_mornings;
76
77 gt.rules.internalStructureComputed=false;
78 setRulesModifiedAndOtherThings(>.rules);
79
80 this->close();
81 }
82
cancel()83 void ModifyConstraintTeachersMinMorningsPerWeekForm::cancel()
84 {
85 this->close();
86 }
87