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

📄 addactivityform.cpp

📁 基于遗传算法的排课软件源码 根据需要安排合理的课程时间等
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************                          addactivityform.cpp  -  description                             -------------------    begin                : Wed Apr 23 2003    copyright            : (C) 2003 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 "addactivityform.h"#include "teacher.h"#include "subject.h"#include "studentsset.h"#include <qlabel.h>#include <qtabwidget.h>#include <qlistbox.h>#define subTab(i)	subactivitiesTabWidget->page(i)#define prefDay(i)	(i==0?preferredDay1ComboBox:				\			(i==1?preferredDay2ComboBox:				\			(i==2?preferredDay3ComboBox:				\			(i==3?preferredDay4ComboBox:				\			(i==4?preferredDay5ComboBox:				\			(i==5?preferredDay6ComboBox:				\			(i==6?preferredDay7ComboBox:				\			(preferredDay8ComboBox))))))))#define prefHour(i)	(i==0?preferredHour1ComboBox:				\			(i==1?preferredHour2ComboBox:				\			(i==2?preferredHour3ComboBox:				\			(i==3?preferredHour4ComboBox:				\			(i==4?preferredHour5ComboBox:				\			(i==5?preferredHour6ComboBox:				\			(i==6?preferredHour7ComboBox:				\			(preferredHour8ComboBox))))))))#define par(i)		(i==0?parity1CheckBox:					\			(i==1?parity2CheckBox:					\			(i==2?parity3CheckBox:					\			(i==3?parity4CheckBox:					\			(i==4?parity5CheckBox:					\			(i==5?parity6CheckBox:					\			(i==6?parity7CheckBox:					\			(parity8CheckBox))))))))#define dur(i)		(i==0?duration1SpinBox:					\			(i==1?duration2SpinBox:					\			(i==2?duration3SpinBox:					\			(i==3?duration4SpinBox:					\			(i==4?duration5SpinBox:					\			(i==5?duration6SpinBox:					\			(i==6?duration7SpinBox:					\			(duration1SpinBox))))))))#define activ(i)		(i==0?active1CheckBox:					\			(i==1?active2CheckBox:					\			(i==2?active3CheckBox:					\			(i==3?active4CheckBox:					\			(i==4?active5CheckBox:					\			(i==5?active6CheckBox:					\			(i==6?active7CheckBox:					\			(active8CheckBox))))))))AddActivityForm::AddActivityForm(){	updatePreferredDaysComboBox();	updatePreferredHoursComboBox();	updateStudentsListBox();	updateTeachersListBox();	updateSubjectsComboBox();	updateSubjectTagsComboBox();	minDayDistanceSpinBox->setMaxValue(gt.rules.nDaysPerWeek-1);	minDayDistanceSpinBox->setMinValue(0);	minDayDistanceSpinBox->setValue(0);	int nSplit=splitSpinBox->value();	for(int i=0; i<8; i++)		if(i<nSplit)			subTab(i)->setEnabled(true);		else			subTab(i)->setDisabled(true);}AddActivityForm::~AddActivityForm(){}void AddActivityForm::updateTeachersListBox(){	allTeachersListBox->clear();	for(Teacher* tch=gt.rules.teachersList.first(); tch; tch=gt.rules.teachersList.next())		allTeachersListBox->insertItem(tch->name);			selectedTeachersListBox->clear();	activityChanged();}void AddActivityForm::addTeacher(){	if(allTeachersListBox->currentItem()<0 || (uint)(allTeachersListBox->currentItem())>=allTeachersListBox->count())		return;		for(uint i=0; i<selectedTeachersListBox->count(); i++)		if(selectedTeachersListBox->text(i)==allTeachersListBox->currentText())			return;				selectedTeachersListBox->insertItem(allTeachersListBox->currentText());	activityChanged();}void AddActivityForm::removeTeacher(){	if(selectedTeachersListBox->count()<=0 || selectedTeachersListBox->currentItem()<0 ||	 (uint)(selectedTeachersListBox->currentItem())>=selectedTeachersListBox->count())		return;			selectedTeachersListBox->removeItem(selectedTeachersListBox->currentItem());	activityChanged();}void AddActivityForm::addStudents(){	if(allStudentsListBox->currentItem()<0 || (uint)(allStudentsListBox->currentItem())>=allStudentsListBox->count())		return;		for(uint i=0; i<selectedStudentsListBox->count(); i++)		if(selectedStudentsListBox->text(i)==allStudentsListBox->currentText())			return;				selectedStudentsListBox->insertItem(allStudentsListBox->currentText());		activityChanged();}void AddActivityForm::removeStudents(){	if(selectedStudentsListBox->count()<=0 || selectedStudentsListBox->currentItem()<0 ||	 (uint)(selectedStudentsListBox->currentItem())>=selectedStudentsListBox->count())		return;			selectedStudentsListBox->removeItem(selectedStudentsListBox->currentItem());	activityChanged();}void AddActivityForm::updateSubjectsComboBox(){	subjectsComboBox->clear();	for(Subject* sbj=gt.rules.subjectsList.first(); sbj; sbj=gt.rules.subjectsList.next())		subjectsComboBox->insertItem(sbj->name);	subjectChanged(subjectsComboBox->currentText());}void AddActivityForm::updateSubjectTagsComboBox(){	subjectTagsComboBox->clear();	subjectTagsComboBox->insertItem("");	for(SubjectTag* sbt=gt.rules.subjectTagsList.first(); sbt; sbt=gt.rules.subjectTagsList.next())		subjectTagsComboBox->insertItem(sbt->name);			subjectTagsComboBox->setCurrentItem(0);	subjectTagChanged(subjectTagsComboBox->currentText());}void AddActivityForm::showYearsChanged(){	updateStudentsListBox();}void AddActivityForm::showGroupsChanged(){	updateStudentsListBox();}void AddActivityForm::showSubgroupsChanged(){	updateStudentsListBox();}void AddActivityForm::updateStudentsListBox(){	bool showYears=yearsCheckBox->isChecked();		bool showGroups=groupsCheckBox->isChecked();		bool showSubgroups=subgroupsCheckBox->isChecked();		allStudentsListBox->clear();	for(StudentsYear* sty=gt.rules.yearsList.first(); sty; sty=gt.rules.yearsList.next()){		if(showYears)			allStudentsListBox->insertItem(sty->name);		for(StudentsGroup* stg=sty->groupsList.first(); stg; stg=sty->groupsList.next()){			if(showGroups)				allStudentsListBox->insertItem(stg->name);			for(StudentsSubgroup* sts=stg->subgroupsList.first(); sts; sts=stg->subgroupsList.next())				if(showSubgroups)					allStudentsListBox->insertItem(sts->name);		}	}		selectedStudentsListBox->clear();	activityChanged();}void AddActivityForm::updatePreferredDaysComboBox(){	for(int j=0; j<8; j++){		prefDay(j)->clear();		prefDay(j)->insertItem(QObject::tr("Any"));		for(int i=0; i<gt.rules.nDaysPerWeek; i++)			prefDay(j)->insertItem(gt.rules.daysOfTheWeek[i]);	}}void AddActivityForm::updatePreferredHoursComboBox(){	for(int j=0; j<8; j++){		prefHour(j)->clear();		prefHour(j)->insertItem(QObject::tr("Any"));		for(int i=0; i<gt.rules.nHoursPerDay; i++)			prefHour(j)->insertItem(gt.rules.hoursOfTheDay[i]);	}}void AddActivityForm::subjectChanged(const QString& dummy){	if(dummy=="")		;	activityChanged();}void AddActivityForm::subjectTagChanged(const QString& dummy){	if(dummy=="")		;	activityChanged();}void AddActivityForm::splitChanged(){	int nSplit=splitSpinBox->value();	minDayDistanceTextLabel->setEnabled(nSplit>=2);	minDayDistanceSpinBox->setEnabled(nSplit>=2);	for(int i=0; i<8; i++)		if(i<nSplit)			subTab(i)->setEnabled(true);		else			subTab(i)->setDisabled(true);

⌨️ 快捷键说明

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