Back to index

fet  5.18.0
modifyconstraintteachersminhoursdailyform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           modifyconstraintteachersminhoursdailyform.cpp  -  description
00003                              -------------------
00004     begin                : Sept 21, 2007
00005     copyright            : (C) 2007 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 "modifyconstraintteachersminhoursdailyform.h"
00021 #include "timeconstraint.h"
00022 
00023 ModifyConstraintTeachersMinHoursDailyForm::ModifyConstraintTeachersMinHoursDailyForm(QWidget* parent, ConstraintTeachersMinHoursDaily* 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        allowEmptyDaysCheckBox->setChecked(ctr->allowEmptyDays);
00040        
00041        connect(allowEmptyDaysCheckBox, SIGNAL(toggled(bool)), this, SLOT(allowEmptyDaysCheckBoxToggled())); //after setChecked(...)
00042        
00043        updateMinHoursSpinBox();
00044        
00045        minHoursSpinBox->setValue(ctr->minHoursDaily);
00046 }
00047 
00048 ModifyConstraintTeachersMinHoursDailyForm::~ModifyConstraintTeachersMinHoursDailyForm()
00049 {
00050        saveFETDialogGeometry(this);
00051 }
00052 
00053 void ModifyConstraintTeachersMinHoursDailyForm::updateMinHoursSpinBox(){
00054        minHoursSpinBox->setMinimum(2);
00055        minHoursSpinBox->setMaximum(gt.rules.nHoursPerDay);     
00056 }
00057 
00058 void ModifyConstraintTeachersMinHoursDailyForm::constraintChanged()
00059 {
00060 }
00061 
00062 void ModifyConstraintTeachersMinHoursDailyForm::ok()
00063 {
00064        double weight;
00065        QString tmp=weightLineEdit->text();
00066        weight_sscanf(tmp, "%lf", &weight);
00067        if(weight<0.0 || weight>100.0){
00068               QMessageBox::warning(this, tr("FET information"),
00069                      tr("Invalid weight (percentage)"));
00070               return;
00071        }
00072        if(weight!=100.0){
00073               QMessageBox::warning(this, tr("FET information"),
00074                      tr("Invalid weight (percentage) - must be 100%"));
00075               return;
00076        }
00077 
00078        if(!allowEmptyDaysCheckBox->isChecked()){
00079               QMessageBox::warning(this, tr("FET information"), tr("Allow empty days check box must be checked. If you need to not allow empty days for the teachers, "
00080                      "please use the constraint teachers min days per week"));
00081               return;
00082        }
00083 
00084        int min_hours=minHoursSpinBox->value();
00085 
00086        this->_ctr->weightPercentage=weight;
00087        this->_ctr->minHoursDaily=min_hours;
00088        
00089        this->_ctr->allowEmptyDays=allowEmptyDaysCheckBox->isChecked();
00090 
00091        gt.rules.internalStructureComputed=false;
00092        setRulesModifiedAndOtherThings(&gt.rules);
00093        
00094        this->close();
00095 }
00096 
00097 void ModifyConstraintTeachersMinHoursDailyForm::cancel()
00098 {
00099        this->close();
00100 }
00101 
00102 void ModifyConstraintTeachersMinHoursDailyForm::allowEmptyDaysCheckBoxToggled()
00103 {
00104        bool k=allowEmptyDaysCheckBox->isChecked();
00105 
00106        if(!k){
00107               allowEmptyDaysCheckBox->setChecked(true);
00108               QMessageBox::information(this, tr("FET information"), tr("This check box must remain checked. If you really need to not allow empty days for the teachers,"
00109                      " please use constraint teachers min days per week"));
00110        }
00111 }