Back to index

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

#include <modifyconstraintactivitypreferredstartingtimesform.h>

Collaboration diagram for ModifyConstraintActivityPreferredStartingTimesForm:
Collaboration graph
[legend]

List of all members.

Public Slots

void filterChanged ()
void ok ()
void cancel ()
void itemClicked (QTableWidgetItem *item)
void horizontalHeaderClicked (int col)
void verticalHeaderClicked (int row)
void setAllSlotsAllowed ()
void setAllSlotsNotAllowed ()

Public Member Functions

 ModifyConstraintActivityPreferredStartingTimesForm (QWidget *parent, ConstraintActivityPreferredStartingTimes *ctr)
 ~ModifyConstraintActivityPreferredStartingTimesForm ()
void updateActivitiesComboBox ()
bool filterOk (Activity *a)
void colorItem (QTableWidgetItem *item)

Private Attributes

ConstraintActivityPreferredStartingTimes_ctr
QList< int > activitiesList

Detailed Description

Definition at line 26 of file modifyconstraintactivitypreferredstartingtimesform.h.


Constructor & Destructor Documentation

Definition at line 35 of file modifyconstraintactivitypreferredstartingtimesform.cpp.

                                                                                                                                                                    : QDialog(parent)
{
       setupUi(this);

       okPushButton->setDefault(true);

       connect(preferredTimesTable, SIGNAL(itemClicked(QTableWidgetItem*)), this, SLOT(itemClicked(QTableWidgetItem*)));
       connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
       connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
       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(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);

       QSize tmp5=activitiesComboBox->minimumSizeHint();
       Q_UNUSED(tmp5);
       
       activitiesComboBox->setMaximumWidth(maxRecommendedWidth(this));
       
       this->_ctr=ctr;
       
       weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));

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

       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->days_L[k]==-1 || ctr->hours_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();

       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 164 of file modifyconstraintactivitypreferredstartingtimesform.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 320 of file modifyconstraintactivitypreferredstartingtimesform.cpp.

{
       this->close();
}

Here is the caller graph for this function:

Definition at line 169 of file modifyconstraintactivitypreferredstartingtimesform.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 281 of file modifyconstraintactivitypreferredstartingtimesform.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 238 of file modifyconstraintactivitypreferredstartingtimesform.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 call graph for this function:

Here is the caller graph for this function:

Definition at line 180 of file modifyconstraintactivitypreferredstartingtimesform.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:

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

Definition at line 286 of file modifyconstraintactivitypreferredstartingtimesform.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 325 of file modifyconstraintactivitypreferredstartingtimesform.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;
       }

       int i=activitiesComboBox->currentIndex();
       assert(i<activitiesList.size());
       if(i<0 || activitiesComboBox->count()<=0){
              QMessageBox::warning(this, tr("FET information"),
                     tr("Invalid activity"));
              return;
       }
       int id=activitiesList.at(i);
       
       QList<int> days_L;
       QList<int> hours_L;
       //int days[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES];
       //int hours[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES];
       int n=0;
       for(int j=0; j<gt.rules.nDaysPerWeek; j++)
              for(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->activityId=id;
       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 218 of file modifyconstraintactivitypreferredstartingtimesform.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 228 of file modifyconstraintactivitypreferredstartingtimesform.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 301 of file modifyconstraintactivitypreferredstartingtimesform.cpp.

                                                                                 {
       int i=0, j=-1;
       activitiesComboBox->clear();
       activitiesList.clear();
       for(int k=0; k<gt.rules.activitiesList.size(); k++){
              Activity* act=gt.rules.activitiesList[k];
              if(filterOk(act)){
                     activitiesComboBox->addItem(act->getDescription(gt.rules));
                     this->activitiesList.append(act->id);
                     if(act->id==this->_ctr->activityId)
                            j=i;
              
                     i++;
              }
       }
       //assert(j>=0); only first time
       activitiesComboBox->setCurrentIndex(j);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 199 of file modifyconstraintactivitypreferredstartingtimesform.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: