📄 modifyconstraintstudentssetintervalmaxdaysperweekform.cpp
字号:
/*************************************************************************** modifyconstraintstudentssetintervalmaxdaysperweekform.cpp - description ------------------- begin : Feb 11, 2005 copyright : (C) 2005 by Lalescu Liviu email : liviu@lalescu.ro ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#include "modifyconstraintstudentssetintervalmaxdaysperweekform.h"#include "timeconstraint.h"#include <qradiobutton.h>#include <qlabel.h>#include <qlineedit.h>#define yesNo(x) ((x)==0?QObject::tr("no"):QObject::tr("yes"))ModifyConstraintStudentsSetIntervalMaxDaysPerWeekForm::ModifyConstraintStudentsSetIntervalMaxDaysPerWeekForm(ConstraintStudentsSetIntervalMaxDaysPerWeek* ctr){ this->_ctr=ctr; compulsoryCheckBox->setChecked(ctr->compulsory); weightLineEdit->setText(QString::number(ctr->weight)); updatePeriodGroupBox(); updateStudentsComboBox(); startHourComboBox->setCurrentItem(ctr->h1); endHourComboBox->setCurrentItem(ctr->h2); maxDaysSpinBox->setValue(ctr->n); constraintChanged();}ModifyConstraintStudentsSetIntervalMaxDaysPerWeekForm::~ModifyConstraintStudentsSetIntervalMaxDaysPerWeekForm(){}void ModifyConstraintStudentsSetIntervalMaxDaysPerWeekForm::updateStudentsComboBox(){ studentsComboBox->clear(); int i=0, j=-1; for(StudentsYear* sty=gt.rules.yearsList.first(); sty; sty=gt.rules.yearsList.next()){ studentsComboBox->insertItem(sty->name); if(sty->name==this->_ctr->students) j=i; i++; for(StudentsGroup* stg=sty->groupsList.first(); stg; stg=sty->groupsList.next()){ studentsComboBox->insertItem(stg->name); if(stg->name==this->_ctr->students) j=i; i++; for(StudentsSubgroup* sts=stg->subgroupsList.first(); sts; sts=stg->subgroupsList.next()){ studentsComboBox->insertItem(sts->name); if(sts->name==this->_ctr->students) j=i; i++; } } } assert(j>=0); studentsComboBox->setCurrentItem(j); constraintChanged();}void ModifyConstraintStudentsSetIntervalMaxDaysPerWeekForm::updatePeriodGroupBox(){ startHourComboBox->clear(); for(int i=0; i<=gt.rules.nHoursPerDay; i++) startHourComboBox->insertItem(gt.rules.hoursOfTheDay[i]); endHourComboBox->clear(); for(int i=0; i<=gt.rules.nHoursPerDay; i++) endHourComboBox->insertItem(gt.rules.hoursOfTheDay[i]); maxDaysSpinBox->setMinValue(0); maxDaysSpinBox->setMaxValue(gt.rules.nDaysPerWeek); }void ModifyConstraintStudentsSetIntervalMaxDaysPerWeekForm::constraintChanged(){ QString s; s+=QObject::tr("Current constraint:"); s+="\n"; double weight; QString tmp=weightLineEdit->text(); sscanf(tmp, "%lf", &weight); s+=QObject::tr(QString("Weight=%1").arg(weight)); s+="\n"; bool compulsory=false; if(compulsoryCheckBox->isChecked()) compulsory=true; s+=QObject::tr("Compulsory=%1").arg(yesNo(compulsory)); s+="\n"; s+=QObject::tr("Students set interval max days per week"); s+="\n"; s+=QObject::tr("Students set=%1").arg(studentsComboBox->currentText()); s+="\n"; s+=QObject::tr("Max days=%1").arg(maxDaysSpinBox->value()); s+="\n"; int startHour=startHourComboBox->currentItem(); if(startHour<0 || startHour>gt.rules.nHoursPerDay){ s+=QObject::tr("Invalid start hour"); s+="\n"; } else{ s+=QObject::tr("Start hour:%1").arg(startHourComboBox->currentText()); s+="\n"; } int endHour=endHourComboBox->currentItem(); if(endHour<0 || endHour>gt.rules.nHoursPerDay){ s+=QObject::tr("Invalid end hour"); s+="\n"; } else{ s+=QObject::tr("End hour:%1").arg(endHourComboBox->currentText()); s+="\n"; } currentConstraintTextEdit->setText(s);}void ModifyConstraintStudentsSetIntervalMaxDaysPerWeekForm::ok(){ double weight; QString tmp=weightLineEdit->text(); sscanf(tmp, "%lf", &weight); if(weight<0.0){ QMessageBox::warning(this, QObject::tr("FET information"), QObject::tr("Invalid weight")); return; } bool compulsory=false; if(compulsoryCheckBox->isChecked()) compulsory=true; int startHour=startHourComboBox->currentItem(); if(startHour<0 || startHour>gt.rules.nHoursPerDay){ QMessageBox::warning(this, QObject::tr("FET information"), QObject::tr("Invalid start hour")); return; } int endHour=-1; endHour=endHourComboBox->currentItem(); if(endHour<0 || endHour>gt.rules.nHoursPerDay){ QMessageBox::warning(this, QObject::tr("FET information"), QObject::tr("Invalid end hour")); return; } if(endHour<=startHour){ QMessageBox::warning(this, QObject::tr("FET information"), QObject::tr("End hour <= start hour - impossible")); return; } QString students_name=studentsComboBox->currentText(); StudentsSet* s=gt.rules.searchStudentsSet(students_name); if(s==NULL){ QMessageBox::warning(this, QObject::tr("FET information"), QObject::tr("Invalid students set")); return; } this->_ctr->weight=weight; this->_ctr->compulsory=compulsory; this->_ctr->students=students_name; this->_ctr->h1=startHour; this->_ctr->h2=endHour; this->_ctr->n=maxDaysSpinBox->value(); gt.rules.internalStructureComputed=false; this->close();}void ModifyConstraintStudentsSetIntervalMaxDaysPerWeekForm::cancel(){ this->close();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -