1 /***************************************************************************
2 modifyconstraintteachersmingapsbetweenroomchangesform.cpp - description
3 -------------------
4 begin : 2019
5 copyright : (C) 2019 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 "modifyconstraintteachersmingapsbetweenroomchangesform.h"
21 #include "spaceconstraint.h"
22
ModifyConstraintTeachersMinGapsBetweenRoomChangesForm(QWidget * parent,ConstraintTeachersMinGapsBetweenRoomChanges * ctr)23 ModifyConstraintTeachersMinGapsBetweenRoomChangesForm::ModifyConstraintTeachersMinGapsBetweenRoomChangesForm(QWidget* parent, ConstraintTeachersMinGapsBetweenRoomChanges* 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 minGapsSpinBox->setMinimum(1);
40 minGapsSpinBox->setMaximum(gt.rules.nHoursPerDay);
41 minGapsSpinBox->setValue(ctr->minGapsBetweenRoomChanges);
42 }
43
~ModifyConstraintTeachersMinGapsBetweenRoomChangesForm()44 ModifyConstraintTeachersMinGapsBetweenRoomChangesForm::~ModifyConstraintTeachersMinGapsBetweenRoomChangesForm()
45 {
46 saveFETDialogGeometry(this);
47 }
48
ok()49 void ModifyConstraintTeachersMinGapsBetweenRoomChangesForm::ok()
50 {
51 double weight;
52 QString tmp=weightLineEdit->text();
53 weight_sscanf(tmp, "%lf", &weight);
54 if(weight<100.0 || weight>100.0){
55 QMessageBox::warning(this, tr("FET information"),
56 tr("Invalid weight (percentage). It has to be 100"));
57 return;
58 }
59
60 this->_ctr->weightPercentage=weight;
61 this->_ctr->minGapsBetweenRoomChanges=minGapsSpinBox->value();
62
63 gt.rules.internalStructureComputed=false;
64 setRulesModifiedAndOtherThings(>.rules);
65
66 this->close();
67 }
68
cancel()69 void ModifyConstraintTeachersMinGapsBetweenRoomChangesForm::cancel()
70 {
71 this->close();
72 }
73