Back to index

fet  5.18.0
addconstraintbasiccompulsorytimeform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           addconstraintbasiccompulsorytimeform.cpp  -  description
00003                              -------------------
00004     begin                : Feb 10, 2005
00005     copyright            : (C) 2005 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 "addconstraintbasiccompulsorytimeform.h"
00023 #include "timeconstraint.h"
00024 
00025 AddConstraintBasicCompulsoryTimeForm::AddConstraintBasicCompulsoryTimeForm(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 
00038 AddConstraintBasicCompulsoryTimeForm::~AddConstraintBasicCompulsoryTimeForm()
00039 {
00040        saveFETDialogGeometry(this);
00041 }
00042 
00043 void AddConstraintBasicCompulsoryTimeForm::constraintChanged()
00044 {
00045 }
00046 
00047 void AddConstraintBasicCompulsoryTimeForm::addCurrentConstraint()
00048 {
00049        TimeConstraint *ctr=NULL;
00050 
00051        double weight;
00052        QString tmp=weightLineEdit->text();
00053        weight_sscanf(tmp, "%lf", &weight);
00054        if(weight<0.0 || weight>100.0){
00055               QMessageBox::warning(this, tr("FET information"),
00056                      tr("Invalid weight (percentage)"));
00057               return;
00058        }
00059 
00060        if(weight!=100.0){
00061               QMessageBox::warning(this, tr("FET information"),
00062                      tr("Invalid weight (percentage) - it has to be 100%"));
00063               return;
00064        }
00065 
00066        ctr=new ConstraintBasicCompulsoryTime(weight);
00067 
00068        bool tmp2=gt.rules.addTimeConstraint(ctr);
00069        if(tmp2)
00070               LongTextMessageBox::information(this, tr("FET information"),
00071                      tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules));
00072        else{
00073               QMessageBox::warning(this, tr("FET information"),
00074                      tr("Constraint NOT added - there must be another constraint of this "
00075                        "type. Please edit that one"));
00076               delete ctr;
00077        }
00078 }