Back to index

fet  5.18.0
modifyconstraintteachersmaxdaysperweekform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           modifyconstraintteachersmaxdaysperweekform.cpp  -  description
00003                              -------------------
00004     begin                : 2009
00005     copyright            : (C) 2009 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 "modifyconstraintteachersmaxdaysperweekform.h"
00021 #include "timeconstraint.h"
00022 
00023 ModifyConstraintTeachersMaxDaysPerWeekForm::ModifyConstraintTeachersMaxDaysPerWeekForm(QWidget* parent, ConstraintTeachersMaxDaysPerWeek* 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        this->_ctr=ctr;
00036        
00037        weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));
00038        
00039        updateMaxDaysSpinBox();
00040        
00041        maxDaysSpinBox->setValue(ctr->maxDaysPerWeek);
00042 
00043        constraintChanged();
00044 }
00045 
00046 ModifyConstraintTeachersMaxDaysPerWeekForm::~ModifyConstraintTeachersMaxDaysPerWeekForm()
00047 {
00048        saveFETDialogGeometry(this);
00049 }
00050 
00051 void ModifyConstraintTeachersMaxDaysPerWeekForm::updateMaxDaysSpinBox(){
00052        maxDaysSpinBox->setMinimum(1);
00053        maxDaysSpinBox->setMaximum(gt.rules.nDaysPerWeek);
00054 }
00055 
00056 void ModifyConstraintTeachersMaxDaysPerWeekForm::constraintChanged()
00057 {
00058 }
00059 
00060 void ModifyConstraintTeachersMaxDaysPerWeekForm::ok()
00061 {
00062        double weight;
00063        QString tmp=weightLineEdit->text();
00064        weight_sscanf(tmp, "%lf", &weight);
00065        if(weight<0.0 || weight>100.0){
00066               QMessageBox::warning(this, tr("FET information"),
00067                      tr("Invalid weight (percentage)"));
00068               return;
00069        }
00070        if(weight!=100.0){
00071               QMessageBox::warning(this, tr("FET information"),
00072                      tr("Invalid weight (percentage) - it has to be 100%"));
00073               return;
00074        }
00075 
00076        int max_days=maxDaysSpinBox->value();
00077 
00078        this->_ctr->weightPercentage=weight;
00079        this->_ctr->maxDaysPerWeek=max_days;
00080 
00081        gt.rules.internalStructureComputed=false;
00082        setRulesModifiedAndOtherThings(&gt.rules);
00083        
00084        this->close();
00085 }
00086 
00087 void ModifyConstraintTeachersMaxDaysPerWeekForm::cancel()
00088 {
00089        this->close();
00090 }