⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addconstraintstudentssetnogapsform.cpp

📁 基于遗传算法的排课软件源码 根据需要安排合理的课程时间等
💻 CPP
字号:
/***************************************************************************                          addconstraintstudentssetnogapsform.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 "addconstraintstudentssetnogapsform.h"#include "timeconstraint.h"#include <qradiobutton.h>#include <qlabel.h>#include <qlineedit.h>#define yesNo(x)	((x)==0?QObject::tr("no"):QObject::tr("yes"))AddConstraintStudentsSetNoGapsForm::AddConstraintStudentsSetNoGapsForm(){	updateStudentsSetComboBox();}AddConstraintStudentsSetNoGapsForm::~AddConstraintStudentsSetNoGapsForm(){}void AddConstraintStudentsSetNoGapsForm::updateStudentsSetComboBox(){	studentsComboBox->clear();		for(StudentsYear* sty=gt.rules.yearsList.first(); sty; sty=gt.rules.yearsList.next()){		studentsComboBox->insertItem(sty->name);		for(StudentsGroup* stg=sty->groupsList.first(); stg; stg=sty->groupsList.next()){			studentsComboBox->insertItem(stg->name);			for(StudentsSubgroup* sts=stg->subgroupsList.first(); sts; sts=stg->subgroupsList.next()){				studentsComboBox->insertItem(sts->name);			}		}	}	constraintChanged();}void AddConstraintStudentsSetNoGapsForm::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("Students set no gaps");	s+="\n";	s+=QObject::tr("Students set=%1").arg(studentsComboBox->currentText());	s+="\n";	currentConstraintTextEdit->setText(s);}void AddConstraintStudentsSetNoGapsForm::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;	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;	}	ctr=new ConstraintStudentsSetNoGaps(weight, compulsory, students_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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -