Back to index

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

#include <addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.h>

List of all members.

Public Slots

void addActivity ()
void addAllActivities ()
void removeActivity ()
void filterChanged ()
void clear ()
void addCurrentConstraint ()
void itemClicked (QTableWidgetItem *item)
void horizontalHeaderClicked (int col)
void verticalHeaderClicked (int row)
void setAllUnselected ()
void setAllSelected ()

Public Member Functions

 AddConstraintActivitiesMaxSimultaneousInSelectedTimeSlotsForm (QWidget *parent)
 ~AddConstraintActivitiesMaxSimultaneousInSelectedTimeSlotsForm ()
void colorItem (QTableWidgetItem *item)
void updateActivitiesListWidget ()
bool filterOk (Activity *act)

Private Attributes

QList< int > activitiesList
QList< int > selectedActivitiesList

Detailed Description

Definition at line 28 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.h.


Constructor & Destructor Documentation

Definition at line 41 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.cpp.

                                                                                                                                           : QDialog(parent)
{
       setupUi(this);

       addConstraintPushButton->setDefault(true);
       
       allActivitiesListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
       selectedActivitiesListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
       
       connect(addConstraintPushButton, SIGNAL(clicked()), this, SLOT(addCurrentConstraint()));
       connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
       connect(selectedTimesTable, SIGNAL(itemClicked(QTableWidgetItem*)), this, SLOT(itemClicked(QTableWidgetItem*)));
       connect(setAllUnselectedPushButton, SIGNAL(clicked()), this, SLOT(setAllUnselected()));
       connect(setAllSelectedPushButton, SIGNAL(clicked()), this, SLOT(setAllSelected()));
       connect(allActivitiesListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(addActivity()));
       connect(addAllActivitiesPushButton, SIGNAL(clicked()), this, SLOT(addAllActivities()));
       connect(selectedActivitiesListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(removeActivity()));
       connect(clearPushButton, SIGNAL(clicked()), this, SLOT(clear()));
       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()));
       
       centerWidgetOnScreen(this);
       restoreFETDialogGeometry(this);
                                                 
       tabWidget->setCurrentIndex(0);

       maxSimultaneousSpinBox->setMinimum(0);
       maxSimultaneousSpinBox->setMaximum(MAX_ACTIVITIES);
       maxSimultaneousSpinBox->setValue(0);

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

       for(int j=0; j<gt.rules.nDaysPerWeek; j++){
              QTableWidgetItem* item=new QTableWidgetItem(gt.rules.daysOfTheWeek[j]);
              selectedTimesTable->setHorizontalHeaderItem(j, item);
       }
       for(int i=0; i<gt.rules.nHoursPerDay; i++){
              QTableWidgetItem* item=new QTableWidgetItem(gt.rules.hoursOfTheDay[i]);
              selectedTimesTable->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);
                     selectedTimesTable->setItem(i, j, item);
              }
              
       selectedTimesTable->resizeRowsToContents();
       //selectedTimesTable->resizeColumnsToContents();

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

       selectedTimesTable->setSelectionMode(QAbstractItemView::NoSelection);
       
       tableWidgetUpdateBug(selectedTimesTable);
       
       setStretchAvailabilityTableNicely(selectedTimesTable);
       
       //activities
       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);

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

       selectedActivitiesListWidget->clear();
       selectedActivitiesList.clear();

       filterChanged();
}

Here is the call graph for this function:

Definition at line 158 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 369 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.cpp.

{
       if(allActivitiesListWidget->currentRow()<0)
              return;
       int tmp=allActivitiesListWidget->currentRow();
       int _id=this->activitiesList.at(tmp);
       
       QString actName=allActivitiesListWidget->currentItem()->text();
       assert(actName!="");
       int i;
       //duplicate?
       for(i=0; i<selectedActivitiesListWidget->count(); i++)
              if(actName==selectedActivitiesListWidget->item(i)->text())
                     break;
       if(i<selectedActivitiesListWidget->count())
              return;
       selectedActivitiesListWidget->addItem(actName);
       selectedActivitiesListWidget->setCurrentRow(selectedActivitiesListWidget->count()-1);
       
       this->selectedActivitiesList.append(_id);
}

Here is the caller graph for this function:

Definition at line 391 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.cpp.

{
       for(int tmp=0; tmp<allActivitiesListWidget->count(); tmp++){
              //int tmp=allActivitiesListWidget->currentRow();
              int _id=this->activitiesList.at(tmp);
       
              QString actName=allActivitiesListWidget->item(tmp)->text();
              assert(actName!="");
              int i;
              //duplicate?
              for(i=0; i<selectedActivitiesList.count(); i++)
                     if(selectedActivitiesList.at(i)==_id)
                            break;
              if(i<selectedActivitiesList.count())
                     continue;
              
              /*for(i=0; i<selectedActivitiesListWidget->count(); i++)
                     if(actName==selectedActivitiesListWidget->item(i)->text())
                            break;
              if(i<selectedActivitiesListWidget->count())
                     continue;*/
                     
              selectedActivitiesListWidget->addItem(actName);
              this->selectedActivitiesList.append(_id);
       }
       
       selectedActivitiesListWidget->setCurrentRow(selectedActivitiesListWidget->count()-1);
}

Here is the caller graph for this function:

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

       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(selectedTimesTable->item(i, j)->text()==YES){
                            days.append(j);
                            hours.append(i);
                     }
                     
       int maxSimultaneous=maxSimultaneousSpinBox->value();
       
       if(maxSimultaneous==0){
              QMessageBox::warning(this, tr("FET information"), tr("You specified max simultaneous activities to be 0. This is "
               "not perfect from efficiency point of view, because you can use instead constraint activity(ies) preferred time slots, "
               "and help FET to find a timetable easier and faster, with an equivalent result. Please correct."));
              return;
       }
       
       if(this->selectedActivitiesList.count()==0){
              QMessageBox::warning(this, tr("FET information"),
               tr("Empty list of activities"));
              return;
       }
       //we allow even only one activity
       /*if(this->selectedActivitiesList.count()==1){
              QMessageBox::warning(this, tr("FET information"),
               tr("Only one selected activity"));
              return;
       }*/

       ctr=new ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots(weight, selectedActivitiesList, days, hours, maxSimultaneous);

       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 - please report error"));
              delete ctr;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 437 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.cpp.

{
       selectedActivitiesListWidget->clear();
       selectedActivitiesList.clear();
}

Here is the caller graph for this function:

Definition at line 163 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.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 347 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 304 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.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 caller graph for this function:

Definition at line 174 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.cpp.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 232 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.cpp.

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

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 420 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.cpp.

{
       if(selectedActivitiesListWidget->currentRow()<0 || selectedActivitiesListWidget->count()<=0)
              return;
       int tmp=selectedActivitiesListWidget->currentRow();
       
       selectedActivitiesList.removeAt(tmp);

       selectedActivitiesListWidget->setCurrentRow(-1);
       QListWidgetItem* item=selectedActivitiesListWidget->takeItem(tmp);
       delete item;
       if(tmp<selectedActivitiesListWidget->count())
              selectedActivitiesListWidget->setCurrentRow(tmp);
       else
              selectedActivitiesListWidget->setCurrentRow(selectedActivitiesListWidget->count()-1);
}

Here is the caller graph for this function:

Definition at line 222 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.cpp.

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

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 212 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.cpp.

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

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 352 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.cpp.

{
       allActivitiesListWidget->clear();
       this->activitiesList.clear();
       
       for(int i=0; i<gt.rules.activitiesList.size(); i++){
              Activity* ac=gt.rules.activitiesList[i];
              if(filterOk(ac)){
                     allActivitiesListWidget->addItem(ac->getDescription(gt.rules));
                     this->activitiesList.append(ac->id);
              }
       }
       
       int q=allActivitiesListWidget->verticalScrollBar()->minimum();
       allActivitiesListWidget->verticalScrollBar()->setValue(q);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 193 of file addconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.cpp.

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

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: