Back to index

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

#include <modifyconstraintsubactivitiespreferredstartingtimesform.h>

Collaboration diagram for ModifyConstraintSubactivitiesPreferredStartingTimesForm:
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 setAllSlotsAllowed ()
void setAllSlotsNotAllowed ()

Public Member Functions

 ModifyConstraintSubactivitiesPreferredStartingTimesForm (QWidget *parent, ConstraintSubactivitiesPreferredStartingTimes *ctr)
 ~ModifyConstraintSubactivitiesPreferredStartingTimesForm ()
void updateTeachersComboBox ()
void updateStudentsComboBox ()
void updateSubjectsComboBox ()
void updateActivityTagsComboBox ()
void colorItem (QTableWidgetItem *item)

Public Attributes

ConstraintSubactivitiesPreferredStartingTimes_ctr

Detailed Description

Definition at line 26 of file modifyconstraintsubactivitiespreferredstartingtimesform.h.


Constructor & Destructor Documentation

Definition at line 35 of file modifyconstraintsubactivitiespreferredstartingtimesform.cpp.

                                                                                                                                                                                   : QDialog(parent)
{
       setupUi(this);

       okPushButton->setDefault(true);

       connect(preferredTimesTable, SIGNAL(itemClicked(QTableWidgetItem*)), this, SLOT(itemClicked(QTableWidgetItem*)));
       connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
       connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
       connect(setAllAllowedPushButton, SIGNAL(clicked()), this, SLOT(setAllSlotsAllowed()));
       connect(setAllNotAllowedPushButton, SIGNAL(clicked()), this, SLOT(setAllSlotsNotAllowed()));

       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;

       updateTeachersComboBox();
       updateStudentsComboBox();
       updateSubjectsComboBox();
       updateActivityTagsComboBox();
       
       componentNumberSpinBox->setMinimum(1);
       componentNumberSpinBox->setMaximum(MAX_SPLIT_OF_AN_ACTIVITY);
       componentNumberSpinBox->setValue(this->_ctr->componentNumber);

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

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

       Matrix2D<bool> currentMatrix;
       currentMatrix.resize(gt.rules.nHoursPerDay, gt.rules.nDaysPerWeek);
       //bool currentMatrix[MAX_HOURS_PER_DAY][MAX_DAYS_PER_WEEK];
       for(int i=0; i<gt.rules.nHoursPerDay; i++)
              for(int j=0; j<gt.rules.nDaysPerWeek; j++)
                     currentMatrix[i][j]=false;
       for(int k=0; k<ctr->nPreferredStartingTimes_L; k++){
              if(ctr->hours_L[k]==-1 || ctr->days_L[k]==-1)
                     assert(0);
              int i=ctr->hours_L[k];
              int j=ctr->days_L[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);
                     preferredTimesTable->setItem(i, j, item);

                     if(!currentMatrix[i][j])
                            item->setText(NO);
                     else
                            item->setText(YES);
                            
                     colorItem(item);
              }
              
       preferredTimesTable->resizeRowsToContents();
                            
       weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));

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

       preferredTimesTable->setSelectionMode(QAbstractItemView::NoSelection);
       
       tableWidgetUpdateBug(preferredTimesTable);
       
       setStretchAvailabilityTableNicely(preferredTimesTable);
}

Here is the call graph for this function:

Definition at line 126 of file modifyconstraintsubactivitiespreferredstartingtimesform.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 368 of file modifyconstraintsubactivitiespreferredstartingtimesform.cpp.

{
       this->close();
}

Here is the caller graph for this function:

Definition at line 131 of file modifyconstraintsubactivitiespreferredstartingtimesform.cpp.

{
       if(USE_GUI_COLORS){
              if(item->text()==YES)
                     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 142 of file modifyconstraintsubactivitiespreferredstartingtimesform.cpp.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 200 of file modifyconstraintsubactivitiespreferredstartingtimesform.cpp.

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

       tableWidgetUpdateBug(preferredTimesTable);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 301 of file modifyconstraintsubactivitiespreferredstartingtimesform.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;
       }

       QString teacher=teachersComboBox->currentText();
       if(teacher!="")
              assert(gt.rules.searchTeacher(teacher)>=0);

       QString students=studentsComboBox->currentText();
       if(students!="")
              assert(gt.rules.searchStudentsSet(students)!=NULL);

       QString subject=subjectsComboBox->currentText();
       if(subject!="")
              assert(gt.rules.searchSubject(subject)>=0);
              
       QString activityTag=activityTagsComboBox->currentText();
       if(activityTag!="")
              assert(gt.rules.searchActivityTag(activityTag)>=0);
              
       QList<int> days_L;
       QList<int> hours_L;
       //int days[MAX_N_CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES];
       //int hours[MAX_N_CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES];
       int n=0;
       for(int j=0; j<gt.rules.nDaysPerWeek; j++)
              for(int i=0; i<gt.rules.nHoursPerDay; i++)
                     if(preferredTimesTable->item(i, j)->text()==YES){
                            days_L.append(j);
                            hours_L.append(i);
                            n++;
                     }

       if(n<=0){
              int t=QMessageBox::question(this, tr("FET question"),
               tr("Warning: 0 slots selected. Are you sure?"),
               QMessageBox::Yes, QMessageBox::Cancel);
                                           
              if(t==QMessageBox::Cancel)
                            return;
       }

       this->_ctr->weightPercentage=weight;

       this->_ctr->componentNumber=componentNumberSpinBox->value();
       
       this->_ctr->teacherName=teacher;
       this->_ctr->studentsName=students;
       this->_ctr->subjectName=subject;
       this->_ctr->activityTagName=activityTag;
       this->_ctr->nPreferredStartingTimes_L=n;
       this->_ctr->days_L=days_L;
       this->_ctr->hours_L=hours_L;

       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 180 of file modifyconstraintsubactivitiespreferredstartingtimesform.cpp.

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

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 190 of file modifyconstraintsubactivitiespreferredstartingtimesform.cpp.

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

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 283 of file modifyconstraintsubactivitiespreferredstartingtimesform.cpp.

                                                                                        {
       int i=0, j=-1;
       activityTagsComboBox->clear();
       activityTagsComboBox->addItem("");
       if(this->_ctr->activityTagName=="")
              j=i;
       i++;
       for(int k=0; k<gt.rules.activityTagsList.size(); k++){
              ActivityTag* s=gt.rules.activityTagsList[k];
              activityTagsComboBox->addItem(s->name);
              if(s->name==this->_ctr->activityTagName)
                     j=i;
              i++;
       }
       assert(j>=0);
       activityTagsComboBox->setCurrentIndex(j);
}

Here is the caller graph for this function:

Definition at line 233 of file modifyconstraintsubactivitiespreferredstartingtimesform.cpp.

                                                                                    {
       int i=0, j=-1;
       studentsComboBox->clear();
       studentsComboBox->addItem("");
       if(this->_ctr->studentsName=="")
              j=i;
       i++;
       for(int m=0; m<gt.rules.yearsList.size(); m++){
              StudentsYear* sty=gt.rules.yearsList[m];
              studentsComboBox->addItem(sty->name);
              if(sty->name==this->_ctr->studentsName)
                     j=i;
              i++;
              for(int n=0; n<sty->groupsList.size(); n++){
                     StudentsGroup* stg=sty->groupsList[n];
                     studentsComboBox->addItem(stg->name);
                     if(stg->name==this->_ctr->studentsName)
                            j=i;
                     i++;
                     for(int p=0; p<stg->subgroupsList.size(); p++){
                            StudentsSubgroup* sts=stg->subgroupsList[p];
                            studentsComboBox->addItem(sts->name);
                            if(sts->name==this->_ctr->studentsName)
                                   j=i;
                            i++;
                     }
              }
       }
       assert(j>=0);
       studentsComboBox->setCurrentIndex(j);
}

Here is the caller graph for this function:

Definition at line 265 of file modifyconstraintsubactivitiespreferredstartingtimesform.cpp.

                                                                                    {
       int i=0, j=-1;
       subjectsComboBox->clear();
       subjectsComboBox->addItem("");
       if(this->_ctr->subjectName=="")
              j=i;
       i++;
       for(int k=0; k<gt.rules.subjectsList.size(); k++){
              Subject* s=gt.rules.subjectsList[k];
              subjectsComboBox->addItem(s->name);
              if(s->name==this->_ctr->subjectName)
                     j=i;
              i++;
       }
       assert(j>=0);
       subjectsComboBox->setCurrentIndex(j);
}

Here is the caller graph for this function:

Definition at line 215 of file modifyconstraintsubactivitiespreferredstartingtimesform.cpp.

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

Here is the caller graph for this function:

Definition at line 161 of file modifyconstraintsubactivitiespreferredstartingtimesform.cpp.

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

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: