1 /***************************************************************************
2 modifyconstraintteachersmaxhourscontinuouslyform.cpp - description
3 -------------------
4 begin : Feb 10, 2005
5 copyright : (C) 2005 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 "modifyconstraintteachersmaxhourscontinuouslyform.h"
21 #include "timeconstraint.h"
22
ModifyConstraintTeachersMaxHoursContinuouslyForm(QWidget * parent,ConstraintTeachersMaxHoursContinuously * ctr)23 ModifyConstraintTeachersMaxHoursContinuouslyForm::ModifyConstraintTeachersMaxHoursContinuouslyForm(QWidget* parent, ConstraintTeachersMaxHoursContinuously* 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 updateMaxHoursSpinBox();
40
41 maxHoursSpinBox->setValue(ctr->maxHoursContinuously);
42 }
43
~ModifyConstraintTeachersMaxHoursContinuouslyForm()44 ModifyConstraintTeachersMaxHoursContinuouslyForm::~ModifyConstraintTeachersMaxHoursContinuouslyForm()
45 {
46 saveFETDialogGeometry(this);
47 }
48
updateMaxHoursSpinBox()49 void ModifyConstraintTeachersMaxHoursContinuouslyForm::updateMaxHoursSpinBox(){
50 maxHoursSpinBox->setMinimum(1);
51 maxHoursSpinBox->setMaximum(gt.rules.nHoursPerDay);
52 }
53
ok()54 void ModifyConstraintTeachersMaxHoursContinuouslyForm::ok()
55 {
56 double weight;
57 QString tmp=weightLineEdit->text();
58 weight_sscanf(tmp, "%lf", &weight);
59 if(weight<0.0 || weight>100.0){
60 QMessageBox::warning(this, tr("FET information"),
61 tr("Invalid weight (percentage)"));
62 return;
63 }
64
65 int max_hours=maxHoursSpinBox->value();
66
67 this->_ctr->weightPercentage=weight;
68 this->_ctr->maxHoursContinuously=max_hours;
69
70 gt.rules.internalStructureComputed=false;
71 setRulesModifiedAndOtherThings(>.rules);
72
73 this->close();
74 }
75
cancel()76 void ModifyConstraintTeachersMaxHoursContinuouslyForm::cancel()
77 {
78 this->close();
79 }
80