📄 constraintstudentssetnhoursdailyform.cpp
字号:
/*************************************************************************** constraintstudentssetnhoursdailyform.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 "constraintstudentssetnhoursdailyform.h"#include "addconstraintstudentssetnhoursdailyform.h"#include "modifyconstraintstudentssetnhoursdailyform.h"ConstraintStudentsSetNHoursDailyForm::ConstraintStudentsSetNHoursDailyForm(){ studentsComboBox->insertItem(""); 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); } } } this->visibleConstraintsList.setAutoDelete(false); this->filterChanged();}ConstraintStudentsSetNHoursDailyForm::~ConstraintStudentsSetNHoursDailyForm(){}bool ConstraintStudentsSetNHoursDailyForm::filterOk(TimeConstraint* ctr){ if(ctr->type==CONSTRAINT_STUDENTS_SET_N_HOURS_DAILY){ ConstraintStudentsSetNHoursDaily* c=(ConstraintStudentsSetNHoursDaily*) ctr; return c->students==studentsComboBox->currentText() || studentsComboBox->currentText()==""; } else return false;}void ConstraintStudentsSetNHoursDailyForm::filterChanged(){ this->visibleConstraintsList.clear(); constraintsListBox->clear(); for(TimeConstraint* ctr=gt.rules.timeConstraintsList.first(); ctr; ctr=gt.rules.timeConstraintsList.next()) if(filterOk(ctr)){ visibleConstraintsList.append(ctr); constraintsListBox->insertItem(ctr->getDescription(gt.rules)); }}void ConstraintStudentsSetNHoursDailyForm::constraintChanged(int index){ if(index<0) return; assert((uint)(index)<this->visibleConstraintsList.count()); TimeConstraint* ctr=this->visibleConstraintsList.at(index); assert(ctr!=NULL); currentConstraintTextEdit->setText(ctr->getDetailedDescription(gt.rules));}void ConstraintStudentsSetNHoursDailyForm::addConstraint(){ AddConstraintStudentsSetNHoursDailyForm *addConstraintStudentsSetNHoursDailyForm=new AddConstraintStudentsSetNHoursDailyForm(); addConstraintStudentsSetNHoursDailyForm->exec(); filterChanged(); constraintsListBox->setCurrentItem(constraintsListBox->count()-1);}void ConstraintStudentsSetNHoursDailyForm::modifyConstraint(){ int i=constraintsListBox->currentItem(); if(i<0){ QMessageBox::information(this, QObject::tr("FET information"), QObject::tr("Invalid selected constraint")); return; } TimeConstraint* ctr=this->visibleConstraintsList.at(i); ModifyConstraintStudentsSetNHoursDailyForm *modifyConstraintStudentsSetNHoursDailyForm = new ModifyConstraintStudentsSetNHoursDailyForm((ConstraintStudentsSetNHoursDaily*)ctr); modifyConstraintStudentsSetNHoursDailyForm->exec(); filterChanged(); constraintsListBox->setCurrentItem(i);}void ConstraintStudentsSetNHoursDailyForm::removeConstraint(){ int i=constraintsListBox->currentItem(); if(i<0){ QMessageBox::information(this, QObject::tr("FET information"), QObject::tr("Invalid selected constraint")); return; } TimeConstraint* ctr=this->visibleConstraintsList.at(i); QString s; s=QObject::tr("Removing constraint:\n"); s+=ctr->getDetailedDescription(gt.rules); s+=QObject::tr("\nAre you sure?"); switch( QMessageBox::warning( this, QObject::tr("FET warning"), s, QObject::tr("OK"), QObject::tr("Cancel"), 0, 0, 1 ) ){ case 0: // The user clicked the OK again button or pressed Enter gt.rules.removeTimeConstraint(ctr); filterChanged(); break; case 1: // The user clicked the Cancel or pressed Escape break; } if((uint)(i) >= constraintsListBox->count()) i=constraintsListBox->count()-1; constraintsListBox->setCurrentItem(i);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -