1
/***************************************************************************
2
modifyconstraintstudentssetearlymaxbeginningsatsecondhourform.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 "modifyconstraintstudentssetearlymaxbeginningsatsecondhourform.h"
19
#include "timeconstraint.h"
21
#include <qradiobutton.h>
23
#include <qlineedit.h>
25
#include <QDesktopWidget>
27
//#define yesNo(x) ((x)==0?tr("no"):tr("yes"))
29
ModifyConstraintStudentsSetEarlyMaxBeginningsAtSecondHourForm::ModifyConstraintStudentsSetEarlyMaxBeginningsAtSecondHourForm(ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour* ctr)
31
//setWindowFlags(Qt::Window);
32
setWindowFlags(windowFlags() | Qt::WindowMinMaxButtonsHint);
33
QDesktopWidget* desktop=QApplication::desktop();
34
int xx=desktop->width()/2 - frameGeometry().width()/2;
35
int yy=desktop->height()/2 - frameGeometry().height()/2;
40
//compulsoryCheckBox->setChecked(ctr->compulsory);
41
weightLineEdit->setText(QString::number(ctr->weightPercentage));
43
studentsComboBox->clear();
45
for(int m=0; m<gt.rules.yearsList.size(); m++){
46
StudentsYear* sty=gt.rules.yearsList[m];
47
studentsComboBox->insertItem(sty->name);
48
if(sty->name==this->_ctr->students)
51
for(int n=0; n<sty->groupsList.size(); n++){
52
StudentsGroup* stg=sty->groupsList[n];
53
studentsComboBox->insertItem(stg->name);
54
if(stg->name==this->_ctr->students)
57
for(int p=0; p<stg->subgroupsList.size(); p++){
58
StudentsSubgroup* sts=stg->subgroupsList[p];
59
studentsComboBox->insertItem(sts->name);
60
if(sts->name==this->_ctr->students)
67
studentsComboBox->setCurrentItem(j);
70
maxBeginningsSpinBox->setMinValue(0);
71
maxBeginningsSpinBox->setMaxValue(gt.rules.nDaysPerWeek);
72
maxBeginningsSpinBox->setValue(ctr->maxBeginningsAtSecondHour);
75
ModifyConstraintStudentsSetEarlyMaxBeginningsAtSecondHourForm::~ModifyConstraintStudentsSetEarlyMaxBeginningsAtSecondHourForm()
79
void ModifyConstraintStudentsSetEarlyMaxBeginningsAtSecondHourForm::constraintChanged()
82
s+=tr("Current constraint:");
85
s+=tr("Students set=%1").arg(studentsComboBox->currentText());
89
QString tmp=weightLineEdit->text();
90
sscanf(tmp, "%lf", &weight);
91
s+=tr("Weight (percentage)=%1").arg(weight);
94
/*bool compulsory=false;
95
if(compulsoryCheckBox->isChecked())
97
s+=tr("Compulsory=%1").arg(yesNo(compulsory));
100
//s+=tr("Students set must begin activities as early as possible (permitted by not available and break)");
102
s+=tr("Students set must begin activities early, with maximum %1 beginnings at the second available hour, per week (not available and break not counted)")
103
.arg(maxBeginningsSpinBox->value());
106
currentConstraintTextEdit->setText(s);
109
void ModifyConstraintStudentsSetEarlyMaxBeginningsAtSecondHourForm::ok()
112
QString tmp=weightLineEdit->text();
113
sscanf(tmp, "%lf", &weight);
114
if(weight<0.0 || weight>100.0){
115
QMessageBox::warning(this, tr("FET information"),
116
tr("Invalid weight (percentage)"));
120
QMessageBox::warning(this, tr("FET information"),
121
tr("Invalid weight (percentage) - it must be 100%"));
125
QString students_name=studentsComboBox->currentText();
126
StudentsSet* s=gt.rules.searchStudentsSet(students_name);
128
QMessageBox::warning(this, tr("FET information"),
129
tr("Invalid students set"));
133
/*bool compulsory=false;
134
if(compulsoryCheckBox->isChecked())
137
this->_ctr->students=students_name;
138
this->_ctr->weightPercentage=weight;
139
//this->_ctr->compulsory=compulsory;
141
this->_ctr->maxBeginningsAtSecondHour=maxBeginningsSpinBox->value();
143
gt.rules.internalStructureComputed=false;
148
void ModifyConstraintStudentsSetEarlyMaxBeginningsAtSecondHourForm::cancel()