Back to index

fet  5.18.0
modifyconstraintteachersmindaysperweekform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           modifyconstraintteachersmindaysperweekform.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 
00019 
00020 #include "modifyconstraintteachersmindaysperweekform.h"
00021 #include "timeconstraint.h"
00022 
00023 #include <QMessageBox>
00024 
00025 ModifyConstraintTeachersMinDaysPerWeekForm::ModifyConstraintTeachersMinDaysPerWeekForm(QWidget* parent, ConstraintTeachersMinDaysPerWeek* ctr): QDialog(parent)
00026 {
00027        setupUi(this);
00028 
00029        okPushButton->setDefault(true);
00030 
00031        connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
00032        connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
00033 
00034        centerWidgetOnScreen(this);
00035        restoreFETDialogGeometry(this);
00036        
00037        this->_ctr=ctr;
00038        
00039        weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));
00040        
00041        updateMinDaysSpinBox();
00042        
00043        minDaysSpinBox->setValue(ctr->minDaysPerWeek);
00044 }
00045 
00046 ModifyConstraintTeachersMinDaysPerWeekForm::~ModifyConstraintTeachersMinDaysPerWeekForm()
00047 {
00048        saveFETDialogGeometry(this);
00049 }
00050 
00051 void ModifyConstraintTeachersMinDaysPerWeekForm::updateMinDaysSpinBox(){
00052        minDaysSpinBox->setMinimum(1);
00053        minDaysSpinBox->setMaximum(gt.rules.nDaysPerWeek);      
00054 }
00055 
00056 void ModifyConstraintTeachersMinDaysPerWeekForm::ok()
00057 {
00058        double weight;
00059        QString tmp=weightLineEdit->text();
00060        weight_sscanf(tmp, "%lf", &weight);
00061        if(weight<0.0 || weight>100.0){
00062               QMessageBox::warning(this, tr("FET information"),
00063                      tr("Invalid weight (percentage)"));
00064               return;
00065        }
00066        if(weight!=100.0){
00067               QMessageBox::warning(this, tr("FET information"),
00068                      tr("Invalid weight (percentage) - it has to be 100%"));
00069               return;
00070        }
00071 
00072        int min_days=minDaysSpinBox->value();
00073 
00074        this->_ctr->weightPercentage=weight;
00075        this->_ctr->minDaysPerWeek=min_days;
00076 
00077        gt.rules.internalStructureComputed=false;
00078        setRulesModifiedAndOtherThings(&gt.rules);
00079        
00080        this->close();
00081 }
00082 
00083 void ModifyConstraintTeachersMinDaysPerWeekForm::cancel()
00084 {
00085        this->close();
00086 }