Logo Search packages:      
Sourcecode: fet version File versions

bool Rules::removeSubgroup ( const QString &  yearName,
const QString &  groupName,
const QString &  subgroupName 
)

!! please improve this!!!

Definition at line 1226 of file rules.cpp.

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

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

      StudentsGroup* stg;
      for(stg=sty->groupsList.first(); stg; stg=sty->groupsList.next())
            if(stg->name==groupName)
                  break;
      assert(stg);

      StudentsSubgroup* sts;
      for(sts=stg->subgroupsList.first(); sts; sts=stg->subgroupsList.next())
            if(sts->name==subgroupName)
                  break;
      assert(sts);
      stg->subgroupsList.take();
      if(this->searchStudentsSet(sts->name)!=NULL)
            //subgroup still exists, in other group
            return true;

      delete sts;

      this->internalStructureComputed=false;

      //TODO: improve this part
      for(Activity* act=this->activitiesList.first(); act; ){
            act->removeStudents(subgroupName);
            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(subgroupName == crt_constraint->students){
                        this->removeTimeConstraint(ctr);
                        erased=true;
                  }
            }
            else if(ctr->type==CONSTRAINT_STUDENTS_SET_N_HOURS_DAILY){
                  ConstraintStudentsSetNHoursDaily* crt_constraint=(ConstraintStudentsSetNHoursDaily*)ctr;
                  if(subgroupName == crt_constraint->students){
                        this->removeTimeConstraint(ctr);
                        erased=true;
                  }
            }
            else if(ctr->type==CONSTRAINT_STUDENTS_SET_NO_GAPS){
                  ConstraintStudentsSetNoGaps* crt_constraint=(ConstraintStudentsSetNoGaps*)ctr;
                  if(subgroupName == 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(subgroupName == crt_constraint->students){
                        this->removeTimeConstraint(ctr);
                        erased=true;
                  }
            }
            else if(ctr->type==CONSTRAINT_ACTIVITIES_PREFERRED_TIMES){
                  ConstraintActivitiesPreferredTimes* crt_constraint=(ConstraintActivitiesPreferredTimes*)ctr;
                  if(subgroupName == crt_constraint->studentsName){
                        this->removeTimeConstraint(ctr);
                        erased=true;
                  }
            }

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

      return true;
}


Generated by  Doxygen 1.6.0   Back to index