Back to index

fet  5.18.0
Public Slots | Public Member Functions
AddConstraintStudentsSetNotAvailableTimesForm Class Reference

#include <addconstraintstudentssetnotavailabletimesform.h>

List of all members.

Public Slots

void addCurrentConstraint ()
void itemClicked (QTableWidgetItem *item)
void horizontalHeaderClicked (int col)
void verticalHeaderClicked (int row)
void help ()
void setAllAvailable ()
void setAllNotAvailable ()

Public Member Functions

 AddConstraintStudentsSetNotAvailableTimesForm (QWidget *parent)
 ~AddConstraintStudentsSetNotAvailableTimesForm ()
void updateStudentsSetComboBox ()
void colorItem (QTableWidgetItem *item)

Detailed Description

Definition at line 26 of file addconstraintstudentssetnotavailabletimesform.h.


Constructor & Destructor Documentation

Definition at line 37 of file addconstraintstudentssetnotavailabletimesform.cpp.

                                                                                                           : QDialog(parent)
{
       setupUi(this);

       addConstraintPushButton->setDefault(true);

       connect(addConstraintPushButton, SIGNAL(clicked()), this, SLOT(addCurrentConstraint()));
       connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
       connect(notAllowedTimesTable, SIGNAL(itemClicked(QTableWidgetItem*)), this, SLOT(itemClicked(QTableWidgetItem*)));
       connect(pushButton8, SIGNAL(clicked()), this, SLOT(help()));
       connect(setAllAvailablePushButton, SIGNAL(clicked()), this, SLOT(setAllAvailable()));
       connect(setAllNotAvailablePushButton, SIGNAL(clicked()), this, SLOT(setAllNotAvailable()));

       centerWidgetOnScreen(this);
       restoreFETDialogGeometry(this);

       QSize tmp2=studentsComboBox->minimumSizeHint();
       Q_UNUSED(tmp2);
       
       updateStudentsSetComboBox();

       notAllowedTimesTable->setRowCount(gt.rules.nHoursPerDay);
       notAllowedTimesTable->setColumnCount(gt.rules.nDaysPerWeek);

       for(int j=0; j<gt.rules.nDaysPerWeek; j++){
              QTableWidgetItem* item=new QTableWidgetItem(gt.rules.daysOfTheWeek[j]);
              notAllowedTimesTable->setHorizontalHeaderItem(j, item);
       }
       for(int i=0; i<gt.rules.nHoursPerDay; i++){
              QTableWidgetItem* item=new QTableWidgetItem(gt.rules.hoursOfTheDay[i]);
              notAllowedTimesTable->setVerticalHeaderItem(i, item);
       }

       for(int i=0; i<gt.rules.nHoursPerDay; i++)
              for(int j=0; j<gt.rules.nDaysPerWeek; j++){
                     QTableWidgetItem* item=new QTableWidgetItem(NO);
                     item->setTextAlignment(Qt::AlignCenter);
                     item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
                     colorItem(item);
                     notAllowedTimesTable->setItem(i, j, item);
              }
              
       notAllowedTimesTable->resizeRowsToContents();

       connect(notAllowedTimesTable->horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(horizontalHeaderClicked(int)));
       connect(notAllowedTimesTable->verticalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(verticalHeaderClicked(int)));

       notAllowedTimesTable->setSelectionMode(QAbstractItemView::NoSelection);

       tableWidgetUpdateBug(notAllowedTimesTable);
       
       setStretchAvailabilityTableNicely(notAllowedTimesTable);
}

Here is the call graph for this function:

Definition at line 91 of file addconstraintstudentssetnotavailabletimesform.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 196 of file addconstraintstudentssetnotavailabletimesform.cpp.

{
       TimeConstraint *ctr=NULL;

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

       QString students_name=studentsComboBox->currentText();
       StudentsSet* s=gt.rules.searchStudentsSet(students_name);
       if(s==NULL){
              QMessageBox::warning(this, tr("FET information"),
                     tr("Invalid students set"));
              return;
       }

       QList<int> days;
       QList<int> hours;
       for(int j=0; j<gt.rules.nDaysPerWeek; j++)
              for(int i=0; i<gt.rules.nHoursPerDay; i++)
                     if(notAllowedTimesTable->item(i, j)->text()==YES){
                            days.append(j);
                            hours.append(i);
                     }

       ctr=new ConstraintStudentsSetNotAvailableTimes(weight, students_name, days, hours);

       bool tmp2=gt.rules.addTimeConstraint(ctr);
       if(tmp2)
              LongTextMessageBox::information(this, tr("FET information"),
                     tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules));
       else{
              QMessageBox::warning(this, tr("FET information"),
                     tr("Constraint NOT added - there must be another constraint of this "
                       "type referring to the same students set. Please edit that one"));
              delete ctr;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 96 of file addconstraintstudentssetnotavailabletimesform.cpp.

{
       if(USE_GUI_COLORS){
              if(item->text()==NO)
                     item->setBackground(QBrush(Qt::darkGreen));
              else
                     item->setBackground(QBrush(Qt::darkRed));
              item->setForeground(QBrush(Qt::lightGray));
       }
}

Here is the caller graph for this function:

Definition at line 240 of file addconstraintstudentssetnotavailabletimesform.cpp.

{
       QString s;
       
       s=tr("This constraint does not induce gaps (or early gaps) for students. If a student set has lessons"
        " before and after a not available period, gaps will not be counted.");
        
       s+="\n\n";
        
       s+=tr("If you really need to use weight under 100%, you can use activities preferred times with"
        " only the students set specified, but this might generate problems, as possible gaps will be"
        " counted and you may obtain an impossible timetable");

       QMessageBox::information(this, tr("FET help"), s);
}

Here is the caller graph for this function:

Definition at line 107 of file addconstraintstudentssetnotavailabletimesform.cpp.

{
       if(col>=0 && col<gt.rules.nDaysPerWeek){
              QString s=notAllowedTimesTable->item(0, col)->text();
              if(s==YES)
                     s=NO;
              else{
                     assert(s==NO);
                     s=YES;
              }

              for(int row=0; row<gt.rules.nHoursPerDay; row++){
                     notAllowedTimesTable->item(row, col)->setText(s);
                     colorItem(notAllowedTimesTable->item(row,col));
              }
              tableWidgetUpdateBug(notAllowedTimesTable);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AddConstraintStudentsSetNotAvailableTimesForm::itemClicked ( QTableWidgetItem *  item) [slot]

Definition at line 182 of file addconstraintstudentssetnotavailabletimesform.cpp.

{
       QString s=item->text();
       if(s==YES)
              s=NO;
       else{
              assert(s==NO);
              s=YES;
       }
       item->setText(s);
       colorItem(item);
       tableWidgetUpdateBug(notAllowedTimesTable);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 145 of file addconstraintstudentssetnotavailabletimesform.cpp.

{
       for(int i=0; i<gt.rules.nHoursPerDay; i++)
              for(int j=0; j<gt.rules.nDaysPerWeek; j++){
                     notAllowedTimesTable->item(i, j)->setText(NO);
                     colorItem(notAllowedTimesTable->item(i,j));
              }
       tableWidgetUpdateBug(notAllowedTimesTable);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 155 of file addconstraintstudentssetnotavailabletimesform.cpp.

{
       for(int i=0; i<gt.rules.nHoursPerDay; i++)
              for(int j=0; j<gt.rules.nDaysPerWeek; j++){
                     notAllowedTimesTable->item(i, j)->setText(YES);
                     colorItem(notAllowedTimesTable->item(i,j));
              }
       tableWidgetUpdateBug(notAllowedTimesTable);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 165 of file addconstraintstudentssetnotavailabletimesform.cpp.

{
       studentsComboBox->clear();  
       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);
                     }
              }
       }
}

Here is the caller graph for this function:

Definition at line 126 of file addconstraintstudentssetnotavailabletimesform.cpp.

{
       if(row>=0 && row<gt.rules.nHoursPerDay){
              QString s=notAllowedTimesTable->item(row, 0)->text();
              if(s==YES)
                     s=NO;
              else{
                     assert(s==NO);
                     s=YES;
              }
       
              for(int col=0; col<gt.rules.nDaysPerWeek; col++){
                     notAllowedTimesTable->item(row, col)->setText(s);
                     colorItem(notAllowedTimesTable->item(row,col));
              }
              tableWidgetUpdateBug(notAllowedTimesTable);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


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