Logo Search packages:      
Sourcecode: fet version File versions

bool Rules::removeYear ( const QString &  yearName  ) 

!! please improve this!!!

Definition at line 872 of file rules.cpp.

References activitiesList, internalStructureComputed, removeActivity(), removeTimeConstraint(), ConstraintStudentsSetIntervalMaxDaysPerWeek::students, ConstraintStudentsSetNoGaps::students, ConstraintStudentsSetNHoursDaily::students, ConstraintStudentsSetNotAvailable::students, ConstraintActivitiesPreferredTimes::studentsName, timeConstraintsList, and yearsList.

{
      //TODO: improve this part
      for(Activity* act=this->activitiesList.first(); act; ){
            act->removeStudents(yearName);
            if(act->studentsNames.count()==0){
                  this->removeActivity(act->id, act->activityGroupId);
                  act=this->activitiesList.first(); //!!! please improve this!!!
                  //(You have to be careful, there can be erased more activities here)
            }
            else
                  act=this->activitiesList.next();
      }

      for(TimeConstraint* ctr=this->timeConstraintsList.first(); ctr; ){
            bool erased=false;
            if(ctr->type==CONSTRAINT_STUDENTS_SET_NOT_AVAILABLE){
                  ConstraintStudentsSetNotAvailable* crt_constraint=(ConstraintStudentsSetNotAvailable*)ctr;
                  if(yearName == crt_constraint->students){
                        this->removeTimeConstraint(ctr);
                        erased=true;
                  }
            }
            else if(ctr->type==CONSTRAINT_STUDENTS_SET_N_HOURS_DAILY){
                  ConstraintStudentsSetNHoursDaily* crt_constraint=(ConstraintStudentsSetNHoursDaily*)ctr;
                  if(yearName == crt_constraint->students){
                        this->removeTimeConstraint(ctr);
                        erased=true;
                  }
            }
            else if(ctr->type==CONSTRAINT_STUDENTS_SET_NO_GAPS){
                  ConstraintStudentsSetNoGaps* crt_constraint=(ConstraintStudentsSetNoGaps*)ctr;
                  if(yearName == crt_constraint->students){
                        this->removeTimeConstraint(ctr);
                        erased=true;
                  }
            }
            else if(ctr->type==CONSTRAINT_STUDENTS_SET_INTERVAL_MAX_DAYS_PER_WEEK){
                  ConstraintStudentsSetIntervalMaxDaysPerWeek* crt_constraint=(ConstraintStudentsSetIntervalMaxDaysPerWeek*)ctr;
                  if(yearName == crt_constraint->students){
                        this->removeTimeConstraint(ctr);
                        erased=true;
                  }
            }
            else if(ctr->type==CONSTRAINT_ACTIVITIES_PREFERRED_TIMES){
                  ConstraintActivitiesPreferredTimes* crt_constraint=(ConstraintActivitiesPreferredTimes*)ctr;
                  if(yearName == crt_constraint->studentsName){
                        this->removeTimeConstraint(ctr);
                        erased=true;
                  }
            }

            if(!erased)
                  ctr=this->timeConstraintsList.next();
            else
                  ctr=this->timeConstraintsList.current();
      }

      StudentsYear* sty;
      for(sty=this->yearsList.first(); sty; sty=this->yearsList.next())
            if(sty->name==yearName)
                  break;
      assert(sty);
      this->yearsList.remove();

      this->internalStructureComputed=false;
      return true;
}


Generated by  Doxygen 1.6.0   Back to index