Logo Search packages:      
Sourcecode: fet version File versions

bool Rules::modifySubjectTag ( const QString &  initialSubjectTagName,
const QString &  finalSubjectTagName 
)

Modifies (renames) this subject tag and takes care of all related activities. Returns true on success, false on failure (if not found)

Definition at line 807 of file rules.cpp.

References activitiesList, internalStructureComputed, searchSubject(), spaceConstraintsList, ConstraintSubjectSubjectTagRequireEquipments::subjectTagName, and subjectTagsList.

{
      assert(this->searchSubject(finalSubjectTagName)==-1);
      assert(this->searchSubject(initialSubjectTagName)>=0);

      //check the activities first
      for(Activity* act=this->activitiesList.first(); act; act=this->activitiesList.next())
            if( act->subjectTagName == initialSubjectTagName)
                  act->subjectTagName=finalSubjectTagName;
      
      //modify the space constraints related to this subject
      for(SpaceConstraint* ctr=this->spaceConstraintsList.first(); ctr; ctr=this->spaceConstraintsList.next())
            if(ctr->type==CONSTRAINT_SUBJECT_SUBJECT_TAG_REQUIRE_EQUIPMENTS){
                  ConstraintSubjectSubjectTagRequireEquipments* c=(ConstraintSubjectSubjectTagRequireEquipments*)ctr;
                  if(c->subjectTagName == initialSubjectTagName)
                        c->subjectTagName=finalSubjectTagName;
            }

      //rename the subject tag in the list
      int t=0;
      for(SubjectTag* sbt=this->subjectTagsList.first(); sbt; sbt=this->subjectTagsList.next())
            if(sbt->name==initialSubjectTagName){
                  t++;
                  sbt->name=finalSubjectTagName;
            }
      assert(t<=1);

      this->internalStructureComputed=false;

      return true;
}


Generated by  Doxygen 1.6.0   Back to index