addconstraintteachermaxdaysperweekform.cpp

来自「ASP.NET 在线项目注册系统」· C++ 代码 · 共 119 行

CPP
119
字号
/***************************************************************************                          addconstraintteachermaxdaysperweekform.cpp  -  description                             -------------------    begin                : Feb 10, 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 "addconstraintteachermaxdaysperweekform.h"#include "timeconstraint.h"#include <qradiobutton.h>#include <qlabel.h>#include <qlineedit.h>#define yesNo(x)	((x)==0?QObject::tr("no"):QObject::tr("yes"))AddConstraintTeacherMaxDaysPerWeekForm::AddConstraintTeacherMaxDaysPerWeekForm(){	updateMaxDaysSpinBox();	updateTeachersComboBox();}AddConstraintTeacherMaxDaysPerWeekForm::~AddConstraintTeacherMaxDaysPerWeekForm(){}void AddConstraintTeacherMaxDaysPerWeekForm::updateTeachersComboBox(){	teachersComboBox->clear();	for(Teacher* tch=gt.rules.teachersList.first(); tch; tch=gt.rules.teachersList.next())		teachersComboBox->insertItem(tch->name);	constraintChanged();}void AddConstraintTeacherMaxDaysPerWeekForm::updateMaxDaysSpinBox(){	maxDaysSpinBox->setMinValue(0);	maxDaysSpinBox->setMaxValue(gt.rules.nDaysPerWeek);	maxDaysSpinBox->setValue(gt.rules.nDaysPerWeek);}void AddConstraintTeacherMaxDaysPerWeekForm::constraintChanged(){	QString s;	s+=QObject::tr("Current constraint:");	s+="\n";	double weight;	QString tmp=weightLineEdit->text();	sscanf(tmp, "%lf", &weight);	s+=QObject::tr("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("Teacher max days per week");	s+="\n";	s+=QObject::tr("Teacher=%1").arg(teachersComboBox->currentText());	s+="\n";	s+=QObject::tr("Max days per week=%1").arg(maxDaysSpinBox->value());	s+="\n";	currentConstraintTextEdit->setText(s);}void AddConstraintTeacherMaxDaysPerWeekForm::addCurrentConstraint(){	TimeConstraint *ctr=NULL;	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 max_days=maxDaysSpinBox->value();	QString teacher_name=teachersComboBox->currentText();	int teacher_ID=gt.rules.searchTeacher(teacher_name);	if(teacher_ID<0){		QMessageBox::warning(this, QObject::tr("FET information"),			QObject::tr("Invalid teacher"));		return;	}	ctr=new ConstraintTeacherMaxDaysPerWeek(weight, compulsory, max_days, teacher_name);	bool tmp2=gt.rules.addTimeConstraint(ctr);	if(tmp2)		QMessageBox::information(this, QObject::tr("FET information"),			QObject::tr("Constraint added"));	else{		QMessageBox::warning(this, QObject::tr("FET information"),			QObject::tr("Constraint NOT added - please report error"));		delete ctr;	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?