Back to index

fet  5.18.0
Public Slots | Public Member Functions | Public Attributes
ModifyConstraintTeacherNotAvailableTimesForm Class Reference

#include <modifyconstraintteachernotavailabletimesform.h>

Collaboration diagram for ModifyConstraintTeacherNotAvailableTimesForm:
Collaboration graph
[legend]

List of all members.

Public Slots

void ok ()
void cancel ()
void itemClicked (QTableWidgetItem *item)
void horizontalHeaderClicked (int col)
void verticalHeaderClicked (int row)
void setAllAvailable ()
void setAllNotAvailable ()

Public Member Functions

 ModifyConstraintTeacherNotAvailableTimesForm (QWidget *parent, ConstraintTeacherNotAvailableTimes *ctr)
 ~ModifyConstraintTeacherNotAvailableTimesForm ()
void updateTeachersComboBox ()
void colorItem (QTableWidgetItem *item)

Public Attributes

ConstraintTeacherNotAvailableTimes_ctr

Detailed Description

Definition at line 26 of file modifyconstraintteachernotavailabletimesform.h.


Constructor & Destructor Documentation

Definition at line 35 of file modifyconstraintteachernotavailabletimesform.cpp.

                                                                                                                                                  : QDialog(parent)
{
       setupUi(this);

       okPushButton->setDefault(true);

       connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
       connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
       connect(notAllowedTimesTable, SIGNAL(itemClicked(QTableWidgetItem*)), this, SLOT(itemClicked(QTableWidgetItem*)));
       connect(setAllAvailablePushButton, SIGNAL(clicked()), this, SLOT(setAllAvailable()));
       connect(setAllNotAvailablePushButton, SIGNAL(clicked()), this, SLOT(setAllNotAvailable()));

       centerWidgetOnScreen(this);
       restoreFETDialogGeometry(this);

       QSize tmp1=teachersComboBox->minimumSizeHint();
       Q_UNUSED(tmp1);
       
       this->_ctr=ctr;
       
       weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));
       
       updateTeachersComboBox();

       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);
       }

       //bool currentMatrix[MAX_HOURS_PER_DAY][MAX_DAYS_PER_WEEK];
       Matrix2D<bool> currentMatrix;
       currentMatrix.resize(gt.rules.nHoursPerDay, gt.rules.nDaysPerWeek);

       for(int i=0; i<gt.rules.nHoursPerDay; i++)
              for(int j=0; j<gt.rules.nDaysPerWeek; j++)
                     currentMatrix[i][j]=false;                
       assert(ctr->days.count()==ctr->hours.count());   
       for(int k=0; k<ctr->days.count(); k++){
              if(ctr->hours.at(k)==-1 || ctr->days.at(k)==-1)
                     assert(0);
              int i=ctr->hours.at(k);
              int j=ctr->days.at(k);
              if(i>=0 && i<gt.rules.nHoursPerDay && j>=0 && j<gt.rules.nDaysPerWeek)
                     currentMatrix[i][j]=true;
       }

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

                     if(!currentMatrix[i][j])
                            item->setText(NO);
                     else
                            item->setText(YES);
                            
                     colorItem(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 115 of file modifyconstraintteachernotavailabletimesform.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 267 of file modifyconstraintteachernotavailabletimesform.cpp.

{
       this->close();
}

Here is the caller graph for this function:

Definition at line 120 of file modifyconstraintteachernotavailabletimesform.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 131 of file modifyconstraintteachernotavailabletimesform.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 ModifyConstraintTeacherNotAvailableTimesForm::itemClicked ( QTableWidgetItem *  item) [slot]

Definition at line 202 of file modifyconstraintteachernotavailabletimesform.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 217 of file modifyconstraintteachernotavailabletimesform.cpp.

{
       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 teacher_name=teachersComboBox->currentText();
       int teacher_ID=gt.rules.searchTeacher(teacher_name);
       if(teacher_ID<0){
              QMessageBox::warning(this, tr("FET information"),
                     tr("Invalid teacher"));
              return;
       }

       foreach(TimeConstraint* c, gt.rules.timeConstraintsList)
              if(c!=this->_ctr && c->type==CONSTRAINT_TEACHER_NOT_AVAILABLE_TIMES){
                     ConstraintTeacherNotAvailableTimes* cc=(ConstraintTeacherNotAvailableTimes*)c;
                     if(cc->teacher==teacher_name){
                            QMessageBox::warning(this, tr("FET information"),
                                   tr("A constraint of this type exists for the same teacher - cannot proceed"));
                            return;
                     }
              }                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                 
       this->_ctr->weightPercentage=weight;
       this->_ctr->teacher=teacher_name;

       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);
                     }

       this->_ctr->days=days;
       this->_ctr->hours=hours;

       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 169 of file modifyconstraintteachernotavailabletimesform.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 179 of file modifyconstraintteachernotavailabletimesform.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 189 of file modifyconstraintteachernotavailabletimesform.cpp.

                                                                         {
       teachersComboBox->clear();
       int i=0, j=-1;
       for(int k=0; k<gt.rules.teachersList.size(); k++, i++){
              Teacher* tch=gt.rules.teachersList[k];
              teachersComboBox->addItem(tch->name);
              if(tch->name==this->_ctr->teacher)
                     j=i;
       }
       assert(j>=0);
       teachersComboBox->setCurrentIndex(j);
}

Here is the caller graph for this function:

Definition at line 150 of file modifyconstraintteachernotavailabletimesform.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:


Member Data Documentation


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