Back to index

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