📄 timetableallocatehoursroomsform.cpp
字号:
tos<<"<p/>"<<endl; time_t ltime; tzset(); time(<ime); tos<<QObject::tr("Timetable generated with FET %1 on %2").arg(FET_VERSION).arg(ctime(<ime)); tos<<"</body>\n</html>\n"; file.close();}/**Function writing the students' timetable (with rooms) html format to a file (var. 2)*/void TimetableAllocateHoursRoomsForm::writeStudentsTimetableWithRooms2Html(const QString& htmlfilename){ assert(gt.rules.initialized && gt.rules.internalStructureComputed); assert(gt.timeSpacePopulation.initialized); assert(students_schedule_ready2 && teachers_schedule_ready2 && rooms_schedule_ready2); SpaceChromosome* c=(SpaceChromosome*)(>.timeSpacePopulation.bestChromosome(gt.rules)); //Writing the timetable in xml format QFile file(htmlfilename); if(!file.open(IO_WriteOnly)) assert(0); QTextStream tos(&file); tos << "<html>\n<body>\n<table border=\"1\">\n"; tos<<"<tr><td></td>\n"; for(int k=0; k<gt.rules.nDaysPerWeek; k++) tos << "<td align=\"center\" colspan=\"" << gt.rules.nHoursPerDay <<"\">" << protect2(gt.rules.daysOfTheWeek[k]) << "</td>\n"; tos<<"</tr>\n"; tos<<"<tr>\n"; tos<<"<td></td>\n"; for(int k=0; k<gt.rules.nDaysPerWeek; k++) for(int j=0; j<gt.rules.nHoursPerDay; j++) tos << "<td>" << protect2(gt.rules.hoursOfTheDay[j]) << "</td>\n"; for(int i=0; i<gt.rules.nInternalSubgroups; i++){ tos<<"<tr>\n"; tos << "<td>" << gt.rules.internalSubgroupsList[i]->name << "</td>\n"; for(int k=0; k<gt.rules.nDaysPerWeek; k++){ for(int j=0; j<gt.rules.nHoursPerDay; j++){ tos<<"<td>"; int ai=students_timetable_week1[i][k][j]; //activity index //Activity* act=gt.rules.activitiesList.at(ai); if(ai!=UNALLOCATED_ACTIVITY){ Activity* act=>.rules.internalActivitiesList[ai]; for(QStringList::Iterator it=act->teachersNames.begin(); it!=act->teachersNames.end(); it++) tos<<protect2(*it)<<"<br/>"; tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>"; int ri=c->rooms[ai]; //room index QString roomName; if(ri==UNALLOCATED_SPACE) roomName="UNALLOCATED_SPACE"; else roomName=gt.rules.roomsList.at(ri)->name; tos<<protect2(roomName)<<"<br/>"; } else tos<<" "; ai=students_timetable_week2[i][k][j]; //activity index //act=gt.rules.activitiesList.at(ai); if(ai!=UNALLOCATED_ACTIVITY){ Activity* act=>.rules.internalActivitiesList[ai]; tos<<"/<br/>"; for(QStringList::Iterator it=act->teachersNames.begin(); it!=act->teachersNames.end(); it++) tos << protect2(*it) <<"<br/>"; tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>"; int ri=c->rooms[ai]; //room index QString roomName; if(ri==UNALLOCATED_SPACE) roomName="UNALLOCATED_SPACE"; else roomName=gt.rules.roomsList.at(ri)->name; tos<<protect2(roomName)<<"<br/>"; } tos<<"</td>\n"; } } tos<<"</tr>\n"; } tos<<"</table>\n"; tos<<"<p/>"<<endl; time_t ltime; tzset(); time(<ime); tos<<QObject::tr("Timetable generated with FET %1 on %2").arg(FET_VERSION).arg(ctime(<ime)); tos<<"</body>\n</html>\n"; file.close();}/**Function writing the teachers' timetable (with rooms) html format to a file (var. 1).Days horizontal.*/void TimetableAllocateHoursRoomsForm::writeTeachersTimetableWithRooms1DaysHorizontalHtml(const QString& htmlfilename){ assert(gt.rules.initialized && gt.rules.internalStructureComputed); assert(gt.timeSpacePopulation.initialized); assert(students_schedule_ready2 && teachers_schedule_ready2 && rooms_schedule_ready2); SpaceChromosome* c=(SpaceChromosome*)(>.timeSpacePopulation.bestChromosome(gt.rules)); //Writing the timetable in xml format QFile file(htmlfilename); if(!file.open(IO_WriteOnly)) assert(0); QTextStream tos(&file); tos<<"<html>\n<title>"<<protect2(gt.rules.institutionName)<<"</title>\n"; tos<<"<body>\n"; tos<<"<center><h3>"<<protect2(gt.rules.institutionName)<<"</h3></center><br>\n"; for(int i=0; i<gt.rules.nInternalTeachers; i++){ tos<<"<p align=\"center\">"<<protect2(gt.rules.internalTeachersList[i]->name)<<"</p>\n"; tos<<"<table width=\"100%\" border=\"1\" cellpadding=\"6\">\n"; tos<<"<tr>\n<td></td>\n"; for(int j=0; j<gt.rules.nDaysPerWeek; j++) tos << "<td>" << protect2(gt.rules.daysOfTheWeek[j]) << "</td>\n"; tos<<"</tr>\n"; for(int j=0; j<gt.rules.nHoursPerDay; j++){ tos<<"<tr>\n"; tos<<"<td>"<<protect2(gt.rules.hoursOfTheDay[j])<<"</td>\n"; for(int k=0; k<gt.rules.nDaysPerWeek; k++){ tos<<"<td style=\"width:14em;\">"; int ai=teachers_timetable_week1[i][k][j]; //activity index //Activity* act=gt.rules.activitiesList.at(ai); if(ai!=UNALLOCATED_ACTIVITY){ Activity* act=>.rules.internalActivitiesList[ai]; for(QStringList::Iterator it=act->studentsNames.begin(); it!=act->studentsNames.end(); it++) tos << protect2(*it) << "<br/>"; tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>"; int ri=c->rooms[ai]; //room index QString roomName; if(ri==UNALLOCATED_SPACE) roomName="UNALLOCATED_SPACE"; else roomName=gt.rules.roomsList.at(ri)->name; tos<<protect2(roomName)<<"<br/>"; } else tos<<" "; ai=teachers_timetable_week2[i][k][j]; //activity index //act=gt.rules.activitiesList.at(ai); if(ai!=UNALLOCATED_ACTIVITY){ Activity* act=>.rules.internalActivitiesList[ai]; tos<<"/<br/>\n"; for(QStringList::Iterator it=act->studentsNames.begin(); it!=act->studentsNames.end(); it++) tos << protect2(*it) << "<br/>"; tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>"; int ri=c->rooms[ai]; //room index QString roomName; if(ri==UNALLOCATED_SPACE) roomName="UNALLOCATED_SPACE"; else roomName=gt.rules.roomsList.at(ri)->name; tos<<protect2(roomName)<<"<br/>"; } tos<<"</td>\n"; } tos << "</tr>\n"; } tos<<"</table>\n"; } tos<<"<p/>"<<endl; time_t ltime; tzset(); time(<ime); tos<<QObject::tr("Timetable generated with FET %1 on %2").arg(FET_VERSION).arg(ctime(<ime)); tos<<"</body>\n</html>\n"; file.close();}/**Function writing the teachers' timetable (with rooms) html format to a file (var. 1).Days vertical.*/void TimetableAllocateHoursRoomsForm::writeTeachersTimetableWithRooms1DaysVerticalHtml(const QString& htmlfilename){ assert(gt.rules.initialized && gt.rules.internalStructureComputed); assert(gt.timeSpacePopulation.initialized); assert(students_schedule_ready2 && teachers_schedule_ready2 && rooms_schedule_ready2); SpaceChromosome* c=(SpaceChromosome*)(>.timeSpacePopulation.bestChromosome(gt.rules)); //Writing the timetable in xml format QFile file(htmlfilename); if(!file.open(IO_WriteOnly)) assert(0); QTextStream tos(&file); tos<<"<html>\n<title>"<<protect2(gt.rules.institutionName)<<"</title>\n"; tos<<"<body>\n"; tos<<"<center><h3>"<<protect2(gt.rules.institutionName)<<"</h3></center><br>\n"; for(int i=0; i<gt.rules.nInternalTeachers; i++){ tos<<"<p align=\"center\">"<<protect2(gt.rules.internalTeachersList[i]->name)<<"</p>\n"; tos<<"<table width=\"100%\" border=\"1\" cellpadding=\"6\">\n"; tos<<"<tr>\n<td></td>\n"; for(int j=0; j<gt.rules.nHoursPerDay; j++) tos << "<td>" << protect2(gt.rules.hoursOfTheDay[j]) << "</td>\n"; tos<<"</tr>\n"; for(int k=0; k<gt.rules.nDaysPerWeek; k++){ tos<<"<tr>\n"; tos<<"<td>"<<protect2(gt.rules.daysOfTheWeek[k])<<"</td>\n"; for(int j=0; j<gt.rules.nHoursPerDay; j++){ tos<<"<td style=\"width:14em;\">"; int ai=teachers_timetable_week1[i][k][j]; //activity index //Activity* act=gt.rules.activitiesList.at(ai); if(ai!=UNALLOCATED_ACTIVITY){ Activity* act=>.rules.internalActivitiesList[ai]; for(QStringList::Iterator it=act->studentsNames.begin(); it!=act->studentsNames.end(); it++) tos << protect2(*it) << "<br/>"; tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>"; int ri=c->rooms[ai]; //room index QString roomName; if(ri==UNALLOCATED_SPACE) roomName="UNALLOCATED_SPACE"; else roomName=gt.rules.roomsList.at(ri)->name; tos<<protect2(roomName)<<"<br/>"; } else tos<<" "; ai=teachers_timetable_week2[i][k][j]; //activity index //act=gt.rules.activitiesList.at(ai); if(ai!=UNALLOCATED_ACTIVITY){ Activity* act=>.rules.internalActivitiesList[ai]; tos<<"/<br/>\n"; for(QStringList::Iterator it=act->studentsNames.begin(); it!=act->studentsNames.end(); it++) tos << protect2(*it) << "<br/>"; tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>"; int ri=c->rooms[ai]; //room index QString roomName; if(ri==UNALLOCATED_SPACE) roomName="UNALLOCATED_SPACE"; else roomName=gt.rules.roomsList.at(ri)->name; tos<<protect2(roomName)<<"<br/>"; } tos<<"</td>\n"; } tos << "</tr>\n"; } tos<<"</table>\n"; } tos<<"<p/>"<<endl; time_t ltime; tzset(); time(<ime); tos<<QObject::tr("Timetable generated with FET %1 on %2").arg(FET_VERSION).arg(ctime(<ime)); tos<<"</body>\n</html>\n"; file.close();}/**Function writing the teachers' timetable (with rooms) html format to a file (var. 2)*/void TimetableAllocateHoursRoomsForm::writeTeachersTimetableWithRooms2Html(const QString& htmlfilename){ assert(gt.rules.initialized && gt.rules.internalStructureComputed); assert(gt.timeSpacePopulation.initialized); assert(students_schedule_ready2 && teachers_schedule_ready2 && rooms_schedule_ready2); SpaceChromosome* c=(SpaceChromosome*)(>.timeSpacePopulation.bestChromosome(gt.rules)); //Writing the timetable in xml format QFile file(htmlfilename); if(!file.open(IO_WriteOnly)) assert(0); QTextStream tos(&file); tos << "<html>\n<body>\n<table border=\"1\">\n"; tos<<"<tr><td></td>\n"; for(int k=0; k<gt.rules.nDaysPerWeek; k++) tos << "<td align=\"center\" colspan=\"" << gt.rules.nHoursPerDay <<"\">" << protect2(gt.rules.daysOfTheWeek[k]) << "</td>\n"; tos<<"</tr>\n"; tos<<"<tr>\n"; tos<<"<td></td>\n"; for(int k=0; k<gt.rules.nDaysPerWeek; k++) for(int j=0; j<gt.rules.nHoursPerDay; j++) tos << "<td>" << protect2(gt.rules.hoursOfTheDay[j]) << "</td>\n"; for(int i=0; i<gt.rules.nInternalTeachers; i++){ tos<<"<tr>\n"; tos << "<td>" << gt.rules.internalTeachersList[i]->name << "</td>\n"; for(int k=0; k<gt.rules.nDaysPerWeek; k++){ for(int j=0; j<gt.rules.nHoursPerDay; j++){ tos<<"<td>"; int ai=teachers_timetable_week1[i][k][j]; //activity index //Activity* act=gt.rules.activitiesList.at(ai); if(ai!=UNALLOCATED_ACTIVITY){ Activity* act=>.rules.internalActivitiesList[ai]; for(QStringList::Iterator it=act->studentsNames.begin(); it!=act->studentsNames.end(); it++) tos<<protect2(*it)<<"<br/>"; tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>"; int ri=c->rooms[ai]; //room index QString roomName; if(ri==UNALLOCATED_SPACE) roomName="UNALLOCATED_SPACE"; else roomName=gt.rules.roomsList.at(ri)->name; tos<<protect2(roomName)<<"<br/>"; } else tos<<" "; ai=teachers_timetable_week2[i][k][j]; //activity index //act=gt.rules.activitiesList.at(ai); if(ai!=UNALLOCATED_ACTIVITY){ Activity* act=>.rules.internalActivitiesList[ai]; tos<<"/<br/>"; for(QStringList::Iterator it=act->studentsNames.begin(); it!=act->studentsNames.end(); it++) tos << protect2(*it) <<"<br/>"; tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>"; int ri=c->rooms[ai]; //room index QString roomName; if(ri==UNALLOCATED_SPACE) roomName="UNALLOCATED_SPACE"; else roomName=gt.rules.roomsList.at(ri)->name; tos<<protect2(roomName)<<"<br/>"; } tos<<"</td>\n"; } } tos<<"</tr>\n"; } tos<<"</table>\n"; tos<<"<p/>"<<endl; time_t ltime; tzset(); time(<ime); tos<<QObject::tr("Timetable generated with FET %1 on %2").arg(FET_VERSION).arg(ctime(<ime)); tos<<"</body>\n</html>\n"; file.close();}/**Function writing the rooms' timetable in html format to a file.Days horizontal.*/void TimetableAllocateHoursRoomsForm::writeRoomsTimetable1DaysHorizontalHtml(const QString& htmlfilename){ assert(gt.rules.initialized && gt.rules.internalStructureComputed); assert(gt.timeSpacePopulation.initialized); assert(students_schedule_ready2 && teachers_schedule_ready2); assert(rooms_schedule_ready2); //Writing the timetable in html format QFile file(htmlfilename);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -