Back to index

fet  5.18.0
modifyconstraintstudentssetmingapsbetweenbuildingchangesform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           modifyconstraintstudentssetmingapsbetweenbuildingchangesform.cpp  -  description
00003                              -------------------
00004     begin                : Feb 10, 2005
00005     copyright            : (C) 2005 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 #include "modifyconstraintstudentssetmingapsbetweenbuildingchangesform.h"
00021 #include "spaceconstraint.h"
00022 
00023 ModifyConstraintStudentsSetMinGapsBetweenBuildingChangesForm::ModifyConstraintStudentsSetMinGapsBetweenBuildingChangesForm(QWidget* parent, ConstraintStudentsSetMinGapsBetweenBuildingChanges* ctr): QDialog(parent)
00024 {
00025        setupUi(this);
00026 
00027        okPushButton->setDefault(true);
00028 
00029        connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
00030        connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
00031 
00032        centerWidgetOnScreen(this);
00033        restoreFETDialogGeometry(this);
00034 
00035        QSize tmp2=studentsComboBox->minimumSizeHint();
00036        Q_UNUSED(tmp2);
00037               
00038        this->_ctr=ctr;
00039        
00040        weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));
00041        
00042        updateStudentsComboBox();
00043 
00044        minGapsSpinBox->setMinimum(1);
00045        minGapsSpinBox->setMaximum(gt.rules.nHoursPerDay);
00046        minGapsSpinBox->setValue(ctr->minGapsBetweenBuildingChanges);  
00047               
00048        constraintChanged();
00049 }
00050 
00051 ModifyConstraintStudentsSetMinGapsBetweenBuildingChangesForm::~ModifyConstraintStudentsSetMinGapsBetweenBuildingChangesForm()
00052 {
00053        saveFETDialogGeometry(this);
00054 }
00055 
00056 void ModifyConstraintStudentsSetMinGapsBetweenBuildingChangesForm::updateStudentsComboBox(){
00057        studentsComboBox->clear();
00058        int i=0, j=-1;
00059        for(int m=0; m<gt.rules.yearsList.size(); m++){
00060               StudentsYear* sty=gt.rules.yearsList[m];
00061               studentsComboBox->addItem(sty->name);
00062               if(sty->name==this->_ctr->studentsName)
00063                      j=i;
00064               i++;
00065               for(int n=0; n<sty->groupsList.size(); n++){
00066                      StudentsGroup* stg=sty->groupsList[n];
00067                      studentsComboBox->addItem(stg->name);
00068                      if(stg->name==this->_ctr->studentsName)
00069                             j=i;
00070                      i++;
00071                      for(int p=0; p<stg->subgroupsList.size(); p++){
00072                             StudentsSubgroup* sts=stg->subgroupsList[p];
00073                             studentsComboBox->addItem(sts->name);
00074                             if(sts->name==this->_ctr->studentsName)
00075                                    j=i;
00076                             i++;
00077                      }
00078               }
00079        }
00080        assert(j>=0);
00081        studentsComboBox->setCurrentIndex(j);                                                                                                              
00082 
00083        constraintChanged();
00084 }
00085 
00086 void ModifyConstraintStudentsSetMinGapsBetweenBuildingChangesForm::constraintChanged()
00087 {
00088 }
00089 
00090 void ModifyConstraintStudentsSetMinGapsBetweenBuildingChangesForm::ok()
00091 {
00092        double weight;
00093        QString tmp=weightLineEdit->text();
00094        weight_sscanf(tmp, "%lf", &weight);
00095        if(weight<100.0 || weight>100.0){
00096               QMessageBox::warning(this, tr("FET information"),
00097                      tr("Invalid weight (percentage). It has to be 100"));
00098               return;
00099        }
00100 
00101        QString students_name=studentsComboBox->currentText();
00102        StudentsSet* s=gt.rules.searchStudentsSet(students_name);
00103        if(s==NULL){
00104               QMessageBox::warning(this, tr("FET information"),
00105                      tr("Invalid students set"));
00106               return;
00107        }
00108 
00109        this->_ctr->weightPercentage=weight;
00110        this->_ctr->studentsName=students_name;
00111        this->_ctr->minGapsBetweenBuildingChanges=minGapsSpinBox->value();
00112 
00113        gt.rules.internalStructureComputed=false;
00114        setRulesModifiedAndOtherThings(&gt.rules);
00115        
00116        this->close();
00117 }
00118 
00119 void ModifyConstraintStudentsSetMinGapsBetweenBuildingChangesForm::cancel()
00120 {
00121        this->close();
00122 }