Back to index

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

#include <addconstraintactivitypreferredroomsform.h>

List of all members.

Public Slots

void addRoom ()
void removeRoom ()
void addConstraint ()
void filterChanged ()
void clear ()

Public Member Functions

 AddConstraintActivityPreferredRoomsForm (QWidget *parent)
 ~AddConstraintActivityPreferredRoomsForm ()
void updateRoomsListWidget ()
void updateActivitiesComboBox ()
bool filterOk (Activity *a)

Private Attributes

QList< int > activitiesList

Detailed Description

Definition at line 26 of file addconstraintactivitypreferredroomsform.h.


Constructor & Destructor Documentation

Definition at line 30 of file addconstraintactivitypreferredroomsform.cpp.

                                                                                               : QDialog(parent)
{
       setupUi(this);

       addConstraintPushButton->setDefault(true);
       
       roomsListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
       selectedRoomsListWidget->setSelectionMode(QAbstractItemView::SingleSelection);

       connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
       connect(addConstraintPushButton, SIGNAL(clicked()), this, SLOT(addConstraint()));
       connect(roomsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(addRoom()));
       connect(selectedRoomsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(removeRoom()));
       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);
       
       QSize tmp5=activitiesComboBox->minimumSizeHint();
       Q_UNUSED(tmp5);

       activitiesComboBox->setMaximumWidth(maxRecommendedWidth(this));
       
       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);
       
       updateActivitiesComboBox();

       updateRoomsListWidget();
}

Here is the call graph for this function:

Definition at line 107 of file addconstraintactivitypreferredroomsform.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 185 of file addconstraintactivitypreferredroomsform.cpp.

{
       SpaceConstraint *ctr=NULL;

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

       if(selectedRoomsListWidget->count()==0){
              QMessageBox::warning(this, tr("FET information"),
                     tr("Empty list of selected rooms"));
              return;
       }
       if(selectedRoomsListWidget->count()==1){
              QMessageBox::warning(this, tr("FET information"),
                     tr("Only one selected room - please use constraint activity preferred room if you want a single room"));
              return;
       }

       int id;
       int tmp2=activitiesComboBox->currentIndex();
       if(tmp2<0 || tmp2>=gt.rules.activitiesList.size() || tmp2>=activitiesList.size()){
              QMessageBox::warning(this, tr("FET information"),
                     tr("Invalid activity"));
              return;
       }
       else
              id=activitiesList.at(tmp2);
       
       QStringList roomsList;
       for(int i=0; i<selectedRoomsListWidget->count(); i++)
              roomsList.append(selectedRoomsListWidget->item(i)->text());
       
       ctr=new ConstraintActivityPreferredRooms(weight, id, roomsList);
       bool tmp3=gt.rules.addSpaceConstraint(ctr);
       
       if(tmp3){
              QString s=tr("Constraint added:");
              s+="\n\n";
              s+=ctr->getDetailedDescription(gt.rules);
              LongTextMessageBox::information(this, tr("FET information"), s);
       }
       else{
              QMessageBox::warning(this, tr("FET information"),
                     tr("Constraint NOT added - please report error"));
              delete ctr;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 239 of file addconstraintactivitypreferredroomsform.cpp.

{
       if(roomsListWidget->currentRow()<0)
              return;
       QString rmName=roomsListWidget->currentItem()->text();
       assert(rmName!="");
       int i;
       //duplicate?
       for(i=0; i<selectedRoomsListWidget->count(); i++)
              if(rmName==selectedRoomsListWidget->item(i)->text())
                     break;
       if(i<selectedRoomsListWidget->count())
              return;
       selectedRoomsListWidget->addItem(rmName);
       selectedRoomsListWidget->setCurrentRow(selectedRoomsListWidget->count()-1);
}

Here is the caller graph for this function:

Definition at line 271 of file addconstraintactivitypreferredroomsform.cpp.

{
       selectedRoomsListWidget->clear();
}

Here is the caller graph for this function:

Definition at line 169 of file addconstraintactivitypreferredroomsform.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 112 of file addconstraintactivitypreferredroomsform.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 caller graph for this function:

Definition at line 256 of file addconstraintactivitypreferredroomsform.cpp.

{
       if(selectedRoomsListWidget->currentRow()<0 || selectedRoomsListWidget->count()<=0)
              return;
       int tmp=selectedRoomsListWidget->currentRow();
       
       selectedRoomsListWidget->setCurrentRow(-1);
       QListWidgetItem* item=selectedRoomsListWidget->takeItem(tmp);
       delete item;
       if(tmp<selectedRoomsListWidget->count())
              selectedRoomsListWidget->setCurrentRow(tmp);
       else
              selectedRoomsListWidget->setCurrentRow(selectedRoomsListWidget->count()-1);
}

Here is the caller graph for this function:

Definition at line 155 of file addconstraintactivitypreferredroomsform.cpp.

                                                                      {
       activitiesComboBox->clear();
       activitiesList.clear();
       
       for(int i=0; i<gt.rules.activitiesList.size(); i++){
              Activity* act=gt.rules.activitiesList[i];
              
              if(filterOk(act)){
                     activitiesComboBox->addItem(act->getDescription(gt.rules));
                     this->activitiesList.append(act->id);
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 174 of file addconstraintactivitypreferredroomsform.cpp.

{
       roomsListWidget->clear();
       selectedRoomsListWidget->clear();

       for(int i=0; i<gt.rules.roomsList.size(); i++){
              Room* rm= gt.rules.roomsList[i];
              roomsListWidget->addItem(rm->name);
       }
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 49 of file addconstraintactivitypreferredroomsform.h.


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