Back to index

fet  5.18.0
modifyconstraintactivitiesendstudentsdayform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           modifyconstraintactivitiesendstudentsdayform.cpp  -  description
00003                              -------------------
00004     begin                : 2008
00005     copyright            : (C) 2008 by Lalescu Liviu
00006     email                : Please see http://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address)
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include <QMessageBox>
00019 
00020 
00021 
00022 #include "modifyconstraintactivitiesendstudentsdayform.h"
00023 #include "timeconstraint.h"
00024 
00025 ModifyConstraintActivitiesEndStudentsDayForm::ModifyConstraintActivitiesEndStudentsDayForm(QWidget* parent, ConstraintActivitiesEndStudentsDay* ctr): QDialog(parent)
00026 {
00027        setupUi(this);
00028 
00029        okPushButton->setDefault(true);
00030 
00031        connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
00032        connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
00033 
00034        centerWidgetOnScreen(this);
00035        restoreFETDialogGeometry(this);
00036 
00037        QSize tmp1=teachersComboBox->minimumSizeHint();
00038        Q_UNUSED(tmp1);
00039        QSize tmp2=studentsComboBox->minimumSizeHint();
00040        Q_UNUSED(tmp2);
00041        QSize tmp3=subjectsComboBox->minimumSizeHint();
00042        Q_UNUSED(tmp3);
00043        QSize tmp4=activityTagsComboBox->minimumSizeHint();
00044        Q_UNUSED(tmp4);
00045        
00046        this->_ctr=ctr;
00047 
00048        updateTeachersComboBox();
00049        updateStudentsComboBox();
00050        updateSubjectsComboBox();
00051        updateActivityTagsComboBox();
00052 
00053        weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));
00054 }
00055 
00056 ModifyConstraintActivitiesEndStudentsDayForm::~ModifyConstraintActivitiesEndStudentsDayForm()
00057 {
00058        saveFETDialogGeometry(this);
00059 }
00060 
00061 void ModifyConstraintActivitiesEndStudentsDayForm::updateTeachersComboBox(){
00062        int i=0, j=-1;
00063        teachersComboBox->clear();
00064        teachersComboBox->addItem("");
00065        if(this->_ctr->teacherName=="")
00066               j=i;
00067        i++;
00068        for(int k=0; k<gt.rules.teachersList.size(); k++){
00069               Teacher* t=gt.rules.teachersList[k];
00070               teachersComboBox->addItem(t->name);
00071               if(t->name==this->_ctr->teacherName)
00072                      j=i;
00073               i++;
00074        }
00075        assert(j>=0);
00076        teachersComboBox->setCurrentIndex(j);
00077 }
00078 
00079 void ModifyConstraintActivitiesEndStudentsDayForm::updateStudentsComboBox(){
00080        int i=0, j=-1;
00081        studentsComboBox->clear();
00082        studentsComboBox->addItem("");
00083        if(this->_ctr->studentsName=="")
00084               j=i;
00085        i++;
00086        for(int m=0; m<gt.rules.yearsList.size(); m++){
00087               StudentsYear* sty=gt.rules.yearsList[m];
00088               studentsComboBox->addItem(sty->name);
00089               if(sty->name==this->_ctr->studentsName)
00090                      j=i;
00091               i++;
00092               for(int n=0; n<sty->groupsList.size(); n++){
00093                      StudentsGroup* stg=sty->groupsList[n];
00094                      studentsComboBox->addItem(stg->name);
00095                      if(stg->name==this->_ctr->studentsName)
00096                             j=i;
00097                      i++;
00098                      for(int p=0; p<stg->subgroupsList.size(); p++){
00099                             StudentsSubgroup* sts=stg->subgroupsList[p];
00100                             studentsComboBox->addItem(sts->name);
00101                             if(sts->name==this->_ctr->studentsName)
00102                                    j=i;
00103                             i++;
00104                      }
00105               }
00106        }
00107        assert(j>=0);
00108        studentsComboBox->setCurrentIndex(j);
00109 }
00110 
00111 void ModifyConstraintActivitiesEndStudentsDayForm::updateSubjectsComboBox(){
00112        int i=0, j=-1;
00113        subjectsComboBox->clear();
00114        subjectsComboBox->addItem("");
00115        if(this->_ctr->subjectName=="")
00116               j=i;
00117        i++;
00118        for(int k=0; k<gt.rules.subjectsList.size(); k++){
00119               Subject* s=gt.rules.subjectsList[k];
00120               subjectsComboBox->addItem(s->name);
00121               if(s->name==this->_ctr->subjectName)
00122                      j=i;
00123               i++;
00124        }
00125        assert(j>=0);
00126        subjectsComboBox->setCurrentIndex(j);
00127 }
00128 
00129 void ModifyConstraintActivitiesEndStudentsDayForm::updateActivityTagsComboBox(){
00130        int i=0, j=-1;
00131        activityTagsComboBox->clear();
00132        activityTagsComboBox->addItem("");
00133        if(this->_ctr->activityTagName=="")
00134               j=i;
00135        i++;
00136        for(int k=0; k<gt.rules.activityTagsList.size(); k++){
00137               ActivityTag* s=gt.rules.activityTagsList[k];
00138               activityTagsComboBox->addItem(s->name);
00139               if(s->name==this->_ctr->activityTagName)
00140                      j=i;
00141               i++;
00142        }
00143        assert(j>=0);
00144        activityTagsComboBox->setCurrentIndex(j);
00145 }
00146 
00147 void ModifyConstraintActivitiesEndStudentsDayForm::ok()
00148 {
00149        double weight;
00150        QString tmp=weightLineEdit->text();
00151        weight_sscanf(tmp, "%lf", &weight);
00152        if(weight<0.0 || weight>100.0){
00153               QMessageBox::warning(this, tr("FET information"),
00154                      tr("Invalid weight (percentage)"));
00155               return;
00156        }
00157        if(weight!=100.0){
00158               QMessageBox::warning(this, tr("FET information"),
00159                      tr("Invalid weight (percentage) - it must be 100%"));
00160               return;
00161        }
00162 
00163        QString teacher=teachersComboBox->currentText();
00164        if(teacher!="")
00165               assert(gt.rules.searchTeacher(teacher)>=0);
00166 
00167        QString students=studentsComboBox->currentText();
00168        if(students!="")
00169               assert(gt.rules.searchStudentsSet(students)!=NULL);
00170 
00171        QString subject=subjectsComboBox->currentText();
00172        if(subject!="")
00173               assert(gt.rules.searchSubject(subject)>=0);
00174               
00175        QString activityTag=activityTagsComboBox->currentText();
00176        if(activityTag!="")
00177               assert(gt.rules.searchActivityTag(activityTag)>=0);
00178               
00179        this->_ctr->weightPercentage=weight;
00180        this->_ctr->teacherName=teacher;
00181        this->_ctr->studentsName=students;
00182        this->_ctr->subjectName=subject;
00183        this->_ctr->activityTagName=activityTag;
00184 
00185        gt.rules.internalStructureComputed=false;
00186        setRulesModifiedAndOtherThings(&gt.rules);
00187        
00188        this->close();
00189 }
00190 
00191 void ModifyConstraintActivitiesEndStudentsDayForm::cancel()
00192 {
00193        this->close();
00194 }