Back to index

fet  5.18.0
Public Slots | Public Member Functions | Private Attributes
ModifyConstraintMinDaysBetweenActivitiesForm Class Reference

#include <modifyconstraintmindaysbetweenactivitiesform.h>

Collaboration diagram for ModifyConstraintMinDaysBetweenActivitiesForm:
Collaboration graph
[legend]

List of all members.

Public Slots

void addActivity ()
void addAllActivities ()
void removeActivity ()
void ok ()
void cancel ()
void clear ()
void filterChanged ()

Public Member Functions

 ModifyConstraintMinDaysBetweenActivitiesForm (QWidget *parent, ConstraintMinDaysBetweenActivities *ctr)
 ~ModifyConstraintMinDaysBetweenActivitiesForm ()
bool filterOk (Activity *ac)

Private Attributes

ConstraintMinDaysBetweenActivities_ctr
QList< int > activitiesList
QList< int > selectedActivitiesList

Detailed Description

Definition at line 28 of file modifyconstraintmindaysbetweenactivitiesform.h.


Constructor & Destructor Documentation

Definition at line 29 of file modifyconstraintmindaysbetweenactivitiesform.cpp.

                                                                                                                                                  : QDialog(parent)
{
       setupUi(this);

       okPushButton->setDefault(true);
       
       activitiesListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
       selectedActivitiesListWidget->setSelectionMode(QAbstractItemView::SingleSelection);

       connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
       connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
       connect(activitiesListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(addActivity()));
       connect(addAllActivitiesPushButton, SIGNAL(clicked()), this, SLOT(addAllActivities()));
       connect(selectedActivitiesListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(removeActivity()));
       connect(teachersComboBox, SIGNAL(activated(QString)), this, SLOT(filterChanged()));
       connect(studentsComboBox, SIGNAL(activated(QString)), this, SLOT(filterChanged()));
       connect(subjectsComboBox, SIGNAL(activated(QString)), this, SLOT(filterChanged()));
       connect(activityTagsComboBox, SIGNAL(activated(QString)), this, SLOT(filterChanged()));

       connect(clearPushButton, SIGNAL(clicked()), this, SLOT(clear()));

       centerWidgetOnScreen(this);
       restoreFETDialogGeometry(this);

       QSize tmp1=teachersComboBox->minimumSizeHint();
       Q_UNUSED(tmp1);
       QSize tmp2=studentsComboBox->minimumSizeHint();
       Q_UNUSED(tmp2);
       QSize tmp3=subjectsComboBox->minimumSizeHint();
       Q_UNUSED(tmp3);
       QSize tmp4=activityTagsComboBox->minimumSizeHint();
       Q_UNUSED(tmp4);
       
       this->_ctr=ctr;

       selectedActivitiesList.clear();
       selectedActivitiesListWidget->clear();
       for(int i=0; i<ctr->n_activities; i++){
              int actId=ctr->activitiesId[i];
              this->selectedActivitiesList.append(actId);
              Activity* act=NULL;
              for(int k=0; k<gt.rules.activitiesList.size(); k++){
                     act=gt.rules.activitiesList[k];
                     if(act->id==actId)
                            break;
              }
              assert(act);
              this->selectedActivitiesListWidget->addItem(act->getDescription(gt.rules));
       }
       
       minDaysSpinBox->setMinimum(1);
       minDaysSpinBox->setMaximum(gt.rules.nDaysPerWeek-1);
       minDaysSpinBox->setValue(ctr->minDays);

       consecutiveIfSameDayCheckBox->setChecked(ctr->consecutiveIfSameDay);
       weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));

       teachersComboBox->addItem("");
       for(int i=0; i<gt.rules.teachersList.size(); i++){
              Teacher* tch=gt.rules.teachersList[i];
              teachersComboBox->addItem(tch->name);
       }
       teachersComboBox->setCurrentIndex(0);

       subjectsComboBox->addItem("");
       for(int i=0; i<gt.rules.subjectsList.size(); i++){
              Subject* sb=gt.rules.subjectsList[i];
              subjectsComboBox->addItem(sb->name);
       }
       subjectsComboBox->setCurrentIndex(0);

       activityTagsComboBox->addItem("");
       for(int i=0; i<gt.rules.activityTagsList.size(); i++){
              ActivityTag* st=gt.rules.activityTagsList[i];
              activityTagsComboBox->addItem(st->name);
       }
       activityTagsComboBox->setCurrentIndex(0);

       studentsComboBox->addItem("");
       for(int i=0; i<gt.rules.yearsList.size(); i++){
              StudentsYear* sty=gt.rules.yearsList[i];
              studentsComboBox->addItem(sty->name);
              for(int j=0; j<sty->groupsList.size(); j++){
                     StudentsGroup* stg=sty->groupsList[j];
                     studentsComboBox->addItem(stg->name);
                     for(int k=0; k<stg->subgroupsList.size(); k++){
                            StudentsSubgroup* sts=stg->subgroupsList[k];
                            studentsComboBox->addItem(sts->name);
                     }
              }
       }
       studentsComboBox->setCurrentIndex(0);

       filterChanged();
}

Here is the call graph for this function:

Definition at line 126 of file modifyconstraintmindaysbetweenactivitiesform.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 296 of file modifyconstraintmindaysbetweenactivitiesform.cpp.

{
       if(activitiesListWidget->currentRow()<0)
              return;
       int tmp=activitiesListWidget->currentRow();
       int _id=this->activitiesList.at(tmp);
       
       QString actName=activitiesListWidget->currentItem()->text();
       assert(actName!="");
       int i;
       //duplicate?
       for(i=0; i<selectedActivitiesListWidget->count(); i++)
              if(actName==selectedActivitiesListWidget->item(i)->text())
                     break;
       if(i<selectedActivitiesListWidget->count())
              return;
       selectedActivitiesListWidget->addItem(actName);
       selectedActivitiesListWidget->setCurrentRow(selectedActivitiesListWidget->count()-1);
       
       this->selectedActivitiesList.append(_id);
}

Here is the caller graph for this function:

Definition at line 318 of file modifyconstraintmindaysbetweenactivitiesform.cpp.

{
       for(int tmp=0; tmp<activitiesListWidget->count(); tmp++){
              int _id=this->activitiesList.at(tmp);
       
              QString actName=activitiesListWidget->item(tmp)->text();
              assert(actName!="");
              int i;
              //duplicate?
              for(i=0; i<selectedActivitiesList.count(); i++)
                     if(selectedActivitiesList.at(i)==_id)
                            break;
              if(i<selectedActivitiesList.count())
                     continue;
                     
              selectedActivitiesListWidget->addItem(actName);
              this->selectedActivitiesList.append(_id);
       }
       
       selectedActivitiesListWidget->setCurrentRow(selectedActivitiesListWidget->count()-1);
}

Here is the caller graph for this function:

Definition at line 291 of file modifyconstraintmindaysbetweenactivitiesform.cpp.

{
       this->close();
}

Here is the caller graph for this function:

Definition at line 357 of file modifyconstraintmindaysbetweenactivitiesform.cpp.

{
       selectedActivitiesListWidget->clear();
       selectedActivitiesList.clear();
}

Here is the caller graph for this function:

Definition at line 131 of file modifyconstraintmindaysbetweenactivitiesform.cpp.

{
       activitiesListWidget->clear();
       this->activitiesList.clear();

       for(int i=0; i<gt.rules.activitiesList.size(); i++){
              Activity* ac=gt.rules.activitiesList[i];
              if(filterOk(ac)){
                     activitiesListWidget->addItem(ac->getDescription(gt.rules));
                     this->activitiesList.append(ac->id);
              }
       }
       
       int q=activitiesListWidget->verticalScrollBar()->minimum();
       activitiesListWidget->verticalScrollBar()->setValue(q);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 148 of file modifyconstraintmindaysbetweenactivitiesform.cpp.

{
       QString tn=teachersComboBox->currentText();
       QString stn=studentsComboBox->currentText();
       QString sbn=subjectsComboBox->currentText();
       QString sbtn=activityTagsComboBox->currentText();
       int ok=true;

       //teacher
       if(tn!=""){
              bool ok2=false;
              for(QStringList::Iterator it=act->teachersNames.begin(); it!=act->teachersNames.end(); it++)
                     if(*it == tn){
                            ok2=true;
                            break;
                     }
              if(!ok2)
                     ok=false;
       }

       //subject
       if(sbn!="" && sbn!=act->subjectName)
              ok=false;
              
       //activity tag
       if(sbtn!="" && !act->activityTagsNames.contains(sbtn))
              ok=false;
              
       //students
       if(stn!=""){
              bool ok2=false;
              for(QStringList::Iterator it=act->studentsNames.begin(); it!=act->studentsNames.end(); it++)
                     if(*it == stn){
                            ok2=true;
                            break;
                     }
              if(!ok2)
                     ok=false;
       }
       
       return ok;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 191 of file modifyconstraintmindaysbetweenactivitiesform.cpp.

{
       double weight;
       QString tmp=weightLineEdit->text();
       weight_sscanf(tmp, "%lf", &weight);
       if(weight<0.0 || weight>100.0){
              QMessageBox::warning(this, tr("FET information"),
                     tr("Invalid weight (percentage)"));
              return;
       }

       if(this->selectedActivitiesList.size()==0){
              QMessageBox::warning(this, tr("FET information"),
                     tr("Empty list of selected activities"));
              return;
       }
       if(this->selectedActivitiesList.size()==1){
              QMessageBox::warning(this, tr("FET information"),
                     tr("Only one selected activity"));
              return;
       }

#if 0
       if(0 && this->selectedActivitiesList.size()>gt.rules.nDaysPerWeek){
              QString s=tr("You want to add a constraint min days between activities for more activities than the number of days per week."
                " This is a very bad practice from the way the algorithm of generation works (it slows down the generation and makes it harder to find a solution).")+
               "\n\n"+
               tr("The best way to add the activities would be:")+
               "\n\n"+

               tr("1. If you add 'force consecutive if same day', then couple extra activities in pairs to obtain a number of activities equal to the number of days per week"
                ". Example: 7 activities with duration 1 in a 5 days week, then transform into 5 activities with durations: 2,2,1,1,1 and add a single container activity with these 5 components"
                " (possibly raising the weight of added constraint min days between activities up to 100%)")+

                "\n\n"+

               tr("2. If you don't add 'force consecutive if same day', then add a larger activity splitted into a number of"
                " activities equal with the number of days per week and the remaining components into other larger splitted activity."
                " For example, suppose you need to add 7 activities with duration 1 in a 5 days week. Add 2 larger container activities,"
                " first one splitted into 5 activities with duration 1 and second one splitted into 2 activities with duration 1"
                " (possibly raising the weight of added constraints min days between activities for each of the 2 containers up to 100%)")+

               "\n\n"+
               tr("Do you want to add current constraint as it is now (not recommended) or cancel and edit as instructed?");
       
              int t=QMessageBox::warning(this, tr("FET warning"),     s,
               QMessageBox::Yes, QMessageBox::Cancel);
              if(t==QMessageBox::Cancel)
                     return;
       }
#endif

       if(1){
              ConstraintMinDaysBetweenActivities adc;

              int i;
              QList<int>::iterator it;
              adc.activitiesId.clear();
              for(i=0, it=this->selectedActivitiesList.begin(); it!=this->selectedActivitiesList.end(); it++, i++){
                     adc.activitiesId.append(*it);
              }
              adc.n_activities=i;
              
              adc.weightPercentage=weight;
              adc.consecutiveIfSameDay=consecutiveIfSameDayCheckBox->isChecked();
              adc.minDays=minDaysSpinBox->value();
              
              bool duplicate=false;
              
              foreach(TimeConstraint* tc, gt.rules.timeConstraintsList)
                     if(tc!=this->_ctr && tc->type==CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES)
                            if( ( *((ConstraintMinDaysBetweenActivities*)tc) ) == adc){
                                   duplicate=true;
                                   break;
                            }
                            
              if(duplicate){
                     QMessageBox::warning(this, tr("FET information"), tr("Cannot proceed, current constraint is equal to another one (it is duplicated)"));
                     return;
              }
       }
       
       int i;
       QList<int>::iterator it;
       this->_ctr->activitiesId.clear();
       for(i=0, it=this->selectedActivitiesList.begin(); it!=this->selectedActivitiesList.end(); it++, i++){
              this->_ctr->activitiesId.append(*it);
       }
       this->_ctr->n_activities=i;
              
       this->_ctr->weightPercentage=weight;
       this->_ctr->consecutiveIfSameDay=consecutiveIfSameDayCheckBox->isChecked();
       this->_ctr->minDays=minDaysSpinBox->value();
       
       gt.rules.internalStructureComputed=false;
       setRulesModifiedAndOtherThings(&gt.rules);
       
       this->close();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 340 of file modifyconstraintmindaysbetweenactivitiesform.cpp.

{
       if(selectedActivitiesListWidget->currentRow()<0 || selectedActivitiesListWidget->count()<=0)
              return;
       int tmp=selectedActivitiesListWidget->currentRow();
       
       this->selectedActivitiesList.removeAt(tmp);

       selectedActivitiesListWidget->setCurrentRow(-1);
       QListWidgetItem* item=selectedActivitiesListWidget->takeItem(tmp);
       delete item;
       if(tmp<selectedActivitiesListWidget->count())
              selectedActivitiesListWidget->setCurrentRow(tmp);
       else
              selectedActivitiesListWidget->setCurrentRow(selectedActivitiesListWidget->count()-1);
}

Here is the caller graph for this function:


Member Data Documentation


The documentation for this class was generated from the following files: