Back to index

fet  5.18.0
modifyconstraintteachermaxbuildingchangesperweekform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           modifyconstraintteachermaxbuildingchangesperweekform.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 "modifyconstraintteachermaxbuildingchangesperweekform.h"
00021 #include "spaceconstraint.h"
00022 
00023 ModifyConstraintTeacherMaxBuildingChangesPerWeekForm::ModifyConstraintTeacherMaxBuildingChangesPerWeekForm(QWidget* parent, ConstraintTeacherMaxBuildingChangesPerWeek* 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 tmp1=teachersComboBox->minimumSizeHint();
00036        Q_UNUSED(tmp1);
00037               
00038        this->_ctr=ctr;
00039        
00040        weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));
00041        
00042        updateTeachersComboBox();
00043 
00044        maxChangesSpinBox->setMinimum(0);
00045        maxChangesSpinBox->setMaximum(gt.rules.nDaysPerWeek*gt.rules.nHoursPerDay);
00046        maxChangesSpinBox->setValue(ctr->maxBuildingChangesPerWeek);   
00047               
00048        constraintChanged();
00049 }
00050 
00051 ModifyConstraintTeacherMaxBuildingChangesPerWeekForm::~ModifyConstraintTeacherMaxBuildingChangesPerWeekForm()
00052 {
00053        saveFETDialogGeometry(this);
00054 }
00055 
00056 void ModifyConstraintTeacherMaxBuildingChangesPerWeekForm::updateTeachersComboBox()
00057 {
00058        teachersComboBox->clear();
00059        int i=0, j=-1;
00060        for(int k=0; k<gt.rules.teachersList.size(); k++, i++){
00061               Teacher* tch=gt.rules.teachersList[k];
00062               teachersComboBox->addItem(tch->name);
00063               if(tch->name==this->_ctr->teacherName)
00064                      j=i;
00065        }
00066        assert(j>=0);
00067        teachersComboBox->setCurrentIndex(j);
00068 
00069        constraintChanged();
00070 }
00071 
00072 void ModifyConstraintTeacherMaxBuildingChangesPerWeekForm::constraintChanged()
00073 {
00074 }
00075 
00076 void ModifyConstraintTeacherMaxBuildingChangesPerWeekForm::ok()
00077 {
00078        double weight;
00079        QString tmp=weightLineEdit->text();
00080        weight_sscanf(tmp, "%lf", &weight);
00081        if(weight<100.0 || weight>100.0){
00082               QMessageBox::warning(this, tr("FET information"),
00083                      tr("Invalid weight (percentage). It has to be 100"));
00084               return;
00085        }
00086 
00087        QString teacher_name=teachersComboBox->currentText();
00088        int t=gt.rules.searchTeacher(teacher_name);
00089        if(t==-1){
00090               QMessageBox::warning(this, tr("FET information"),
00091                      tr("Invalid teacher"));
00092               return;
00093        }
00094 
00095        this->_ctr->weightPercentage=weight;
00096        this->_ctr->teacherName=teacher_name;
00097        this->_ctr->maxBuildingChangesPerWeek=maxChangesSpinBox->value();
00098 
00099        gt.rules.internalStructureComputed=false;
00100        setRulesModifiedAndOtherThings(&gt.rules);
00101        
00102        this->close();
00103 }
00104 
00105 void ModifyConstraintTeacherMaxBuildingChangesPerWeekForm::cancel()
00106 {
00107        this->close();
00108 }