Back to index

fet  5.18.0
Public Slots | Public Member Functions
AddConstraintSubactivitiesPreferredStartingTimesForm Class Reference

#include <addconstraintsubactivitiespreferredstartingtimesform.h>

List of all members.

Public Slots

void addConstraint ()
void itemClicked (QTableWidgetItem *item)
void horizontalHeaderClicked (int col)
void verticalHeaderClicked (int row)
void setAllSlotsAllowed ()
void setAllSlotsNotAllowed ()

Public Member Functions

 AddConstraintSubactivitiesPreferredStartingTimesForm (QWidget *parent)
 ~AddConstraintSubactivitiesPreferredStartingTimesForm ()
void updateTeachersComboBox ()
void updateStudentsComboBox ()
void updateSubjectsComboBox ()
void updateActivityTagsComboBox ()
void colorItem (QTableWidgetItem *item)

Detailed Description

Definition at line 26 of file addconstraintsubactivitiespreferredstartingtimesform.h.


Constructor & Destructor Documentation

Definition at line 37 of file addconstraintsubactivitiespreferredstartingtimesform.cpp.

                                                                                                                         : QDialog(parent)
{
       setupUi(this);

       addConstraintPushButton->setDefault(true);

       connect(preferredTimesTable, SIGNAL(itemClicked(QTableWidgetItem*)), this, SLOT(itemClicked(QTableWidgetItem*)));
       connect(addConstraintPushButton, SIGNAL(clicked()), this, SLOT(addConstraint()));
       connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
       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);
       
       updateTeachersComboBox();
       updateStudentsComboBox();
       updateSubjectsComboBox();
       updateActivityTagsComboBox();

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

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

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

       preferredTimesTable->setSelectionMode(QAbstractItemView::NoSelection);
                     
       componentNumberSpinBox->setMinimum(1);
       componentNumberSpinBox->setMaximum(MAX_SPLIT_OF_AN_ACTIVITY);
       componentNumberSpinBox->setValue(1);

       tableWidgetUpdateBug(preferredTimesTable);
       
       setStretchAvailabilityTableNicely(preferredTimesTable);
}

Here is the call graph for this function:

Definition at line 103 of file addconstraintsubactivitiespreferredstartingtimesform.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 235 of file addconstraintsubactivitiespreferredstartingtimesform.cpp.

{
       TimeConstraint *ctr=NULL;

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

       ctr=new ConstraintSubactivitiesPreferredStartingTimes(weight, componentNumberSpinBox->value(),/*compulsory,*/ teacher, students, subject, activityTag, n, days_L, hours_L);

       bool tmp2=gt.rules.addTimeConstraint(ctr);
       if(tmp2){
              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 - duplicate?"));
              delete ctr;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 108 of file addconstraintsubactivitiespreferredstartingtimesform.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 119 of file addconstraintsubactivitiespreferredstartingtimesform.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 177 of file addconstraintsubactivitiespreferredstartingtimesform.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 157 of file addconstraintsubactivitiespreferredstartingtimesform.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 167 of file addconstraintsubactivitiespreferredstartingtimesform.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 226 of file addconstraintsubactivitiespreferredstartingtimesform.cpp.

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

Here is the caller graph for this function:

Definition at line 200 of file addconstraintsubactivitiespreferredstartingtimesform.cpp.

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

Here is the caller graph for this function:

Definition at line 217 of file addconstraintsubactivitiespreferredstartingtimesform.cpp.

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

Here is the caller graph for this function:

Definition at line 191 of file addconstraintsubactivitiespreferredstartingtimesform.cpp.

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

Here is the caller graph for this function:

Definition at line 138 of file addconstraintsubactivitiespreferredstartingtimesform.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:


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