1
/***************************************************************************
2
addconstraintteachermaxhourscontinuouslyform.cpp - description
5
copyright : (C) 2007 by Lalescu Liviu
6
email : Please see http://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address)
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
16
***************************************************************************/
18
#include "addconstraintteachermaxhourscontinuouslyform.h"
19
#include "timeconstraint.h"
21
#include <qradiobutton.h>
23
#include <qlineedit.h>
25
#include <QDesktopWidget>
27
AddConstraintTeacherMaxHoursContinuouslyForm::AddConstraintTeacherMaxHoursContinuouslyForm()
29
//setWindowFlags(Qt::Window);
30
setWindowFlags(windowFlags() | Qt::WindowMinMaxButtonsHint);
31
QDesktopWidget* desktop=QApplication::desktop();
32
int xx=desktop->width()/2 - frameGeometry().width()/2;
33
int yy=desktop->height()/2 - frameGeometry().height()/2;
36
updateMaxHoursSpinBox();
38
teachersComboBox->clear();
39
for(int i=0; i<gt.rules.teachersList.size(); i++){
40
Teacher* tch=gt.rules.teachersList[i];
41
teachersComboBox->insertItem(tch->name);
47
AddConstraintTeacherMaxHoursContinuouslyForm::~AddConstraintTeacherMaxHoursContinuouslyForm()
51
void AddConstraintTeacherMaxHoursContinuouslyForm::updateMaxHoursSpinBox(){
52
maxHoursSpinBox->setMinValue(1);
53
maxHoursSpinBox->setMaxValue(gt.rules.nHoursPerDay);
54
maxHoursSpinBox->setValue(gt.rules.nHoursPerDay);
57
void AddConstraintTeacherMaxHoursContinuouslyForm::constraintChanged()
60
s+=QObject::tr("Current constraint:");
64
QString tmp=weightLineEdit->text();
65
sscanf(tmp, "%lf", &weight);
66
s+=QObject::tr("Weight (percentage)=%1").arg(weight);
69
/*bool compulsory=false;
70
if(compulsoryCheckBox->isChecked())
72
s+=QObject::tr("Compulsory=%1").arg(yesNo(compulsory));
75
s+=QObject::tr("Teacher max hours continuously");
78
s+=QObject::tr("Teacher=%1").arg(teachersComboBox->currentText());
81
s+=QObject::tr("Max hours continuously=%1").arg(maxHoursSpinBox->value());
84
currentConstraintTextEdit->setText(s);
87
void AddConstraintTeacherMaxHoursContinuouslyForm::addCurrentConstraint()
89
TimeConstraint *ctr=NULL;
92
QString tmp=weightLineEdit->text();
93
sscanf(tmp, "%lf", &weight);
94
if(weight<0.0 || weight>100.0){
95
QMessageBox::warning(this, QObject::tr("FET information"),
96
QObject::tr("Invalid weight (percentage)"));
100
QMessageBox::warning(this, QObject::tr("FET information"),
101
QObject::tr("Invalid weight (percentage) - must be 100%"));
105
QString teacher_name=teachersComboBox->currentText();
106
int teacher_ID=gt.rules.searchTeacher(teacher_name);
108
QMessageBox::warning(this, QObject::tr("FET information"),
109
QObject::tr("Invalid teacher"));
113
/*bool compulsory=false;
114
if(compulsoryCheckBox->isChecked())
117
int max_hours=maxHoursSpinBox->value();
119
ctr=new ConstraintTeacherMaxHoursContinuously(weight, /*compulsory,*/ max_hours, teacher_name);
121
bool tmp2=gt.rules.addTimeConstraint(ctr);
123
QMessageBox::information(this, QObject::tr("FET information"),
124
QObject::tr("Constraint added"));
126
QMessageBox::warning(this, QObject::tr("FET information"),
127
QObject::tr("Constraint NOT added - please report error"));