1 /***************************************************************************
2 modifyconstraintstudentsmaxhoursdailyform.cpp - description
3 -------------------
4 begin : July 19, 2007
5 copyright : (C) 2007 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 "modifyconstraintstudentsmaxhoursdailyform.h"
21 #include "timeconstraint.h"
22
ModifyConstraintStudentsMaxHoursDailyForm(QWidget * parent,ConstraintStudentsMaxHoursDaily * ctr)23 ModifyConstraintStudentsMaxHoursDailyForm::ModifyConstraintStudentsMaxHoursDailyForm(QWidget* parent, ConstraintStudentsMaxHoursDaily* 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 maxHoursSpinBox->setMinimum(1);
40 maxHoursSpinBox->setMaximum(gt.rules.nHoursPerDay);
41 maxHoursSpinBox->setValue(ctr->maxHoursDaily);
42 }
43
~ModifyConstraintStudentsMaxHoursDailyForm()44 ModifyConstraintStudentsMaxHoursDailyForm::~ModifyConstraintStudentsMaxHoursDailyForm()
45 {
46 saveFETDialogGeometry(this);
47 }
48
ok()49 void ModifyConstraintStudentsMaxHoursDailyForm::ok()
50 {
51 double weight;
52 QString tmp=weightLineEdit->text();
53 weight_sscanf(tmp, "%lf", &weight);
54 if(weight<0.0 || weight>100.0){
55 QMessageBox::warning(this, tr("FET information"),
56 tr("Invalid weight (percentage)"));
57 return;
58 }
59
60 if(weight<100.0){
61 int t=QMessageBox::warning(this, tr("FET warning"),
62 tr("You selected a weight less than 100%. The generation algorithm is not perfectly optimized to work with such weights (even"
63 " if in practice it might work well). It is recommended to work only with 100% weights for these constraints. Are you sure you want to continue?"),
64 QMessageBox::Yes | QMessageBox::Cancel);
65 if(t==QMessageBox::Cancel)
66 return;
67 }
68
69 this->_ctr->weightPercentage=weight;
70 this->_ctr->maxHoursDaily=maxHoursSpinBox->value();
71
72 gt.rules.internalStructureComputed=false;
73 setRulesModifiedAndOtherThings(>.rules);
74
75 this->close();
76 }
77
cancel()78 void ModifyConstraintStudentsMaxHoursDailyForm::cancel()
79 {
80 this->close();
81 }
82