Back to index

fet  5.18.0
addconstraintstudentsmaxhoursdailyform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           addconstraintstudentsmaxhoursdailyform.cpp  -  description
00003                              -------------------
00004     begin                : July 19, 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 "longtextmessagebox.h"
00021 
00022 #include "addconstraintstudentsmaxhoursdailyform.h"
00023 #include "timeconstraint.h"
00024 
00025 AddConstraintStudentsMaxHoursDailyForm::AddConstraintStudentsMaxHoursDailyForm(QWidget* parent): QDialog(parent)
00026 {
00027        setupUi(this);
00028 
00029        addConstraintPushButton->setDefault(true);
00030 
00031        connect(addConstraintPushButton, SIGNAL(clicked()), this, SLOT(addCurrentConstraint()));
00032        connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
00033 
00034        centerWidgetOnScreen(this);
00035        restoreFETDialogGeometry(this);
00036        
00037        maxHoursSpinBox->setMinimum(1);
00038        maxHoursSpinBox->setMaximum(gt.rules.nHoursPerDay);
00039        maxHoursSpinBox->setValue(gt.rules.nHoursPerDay);
00040 }
00041 
00042 AddConstraintStudentsMaxHoursDailyForm::~AddConstraintStudentsMaxHoursDailyForm()
00043 {
00044        saveFETDialogGeometry(this);
00045 }
00046 
00047 void AddConstraintStudentsMaxHoursDailyForm::constraintChanged()
00048 {
00049 
00050 }
00051 
00052 void AddConstraintStudentsMaxHoursDailyForm::addCurrentConstraint()
00053 {
00054        TimeConstraint *ctr=NULL;
00055 
00056        double weight;
00057        QString tmp=weightLineEdit->text();
00058        weight_sscanf(tmp, "%lf", &weight);
00059        if(weight<0.0 || weight>100.0){
00060               QMessageBox::warning(this, tr("FET information"),
00061                      tr("Invalid weight (percentage)"));
00062               return;
00063        }
00064 
00065        int maxHours=maxHoursSpinBox->value();
00066 
00067        ctr=new ConstraintStudentsMaxHoursDaily(weight, maxHours);
00068 
00069        bool tmp2=gt.rules.addTimeConstraint(ctr);
00070        if(tmp2)
00071               LongTextMessageBox::information(this, tr("FET information"),
00072                      tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules));
00073        else{
00074               QMessageBox::warning(this, tr("FET information"),
00075                      tr("Constraint NOT added - please report error"));
00076               delete ctr;
00077        }
00078 }