1 /***************************************************************************
2                           modifyconstraintbasiccompulsoryspaceform.cpp  -  description
3                              -------------------
4     begin                : Feb 10, 2005
5     copyright            : (C) 2005 by Lalescu Liviu
6     email                : Please see https://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address)
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software: you can redistribute it and/or modify  *
12  *   it under the terms of the GNU Affero General Public License as        *
13  *   published by the Free Software Foundation, either version 3 of the    *
14  *   License, or (at your option) any later version.                       *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #include <QMessageBox>
19 
20 #include "modifyconstraintbasiccompulsoryspaceform.h"
21 #include "timeconstraint.h"
22 
ModifyConstraintBasicCompulsorySpaceForm(QWidget * parent,ConstraintBasicCompulsorySpace * ctr)23 ModifyConstraintBasicCompulsorySpaceForm::ModifyConstraintBasicCompulsorySpaceForm(QWidget* parent, ConstraintBasicCompulsorySpace* ctr): QDialog(parent)
24 {
25 	setupUi(this);
26 
27 	okPushButton->setDefault(true);
28 
29 	connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
30 	connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
31 
32 	centerWidgetOnScreen(this);
33 	restoreFETDialogGeometry(this);
34 
35 	this->_ctr=ctr;
36 
37 	weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));
38 }
39 
~ModifyConstraintBasicCompulsorySpaceForm()40 ModifyConstraintBasicCompulsorySpaceForm::~ModifyConstraintBasicCompulsorySpaceForm()
41 {
42 	saveFETDialogGeometry(this);
43 }
44 
ok()45 void ModifyConstraintBasicCompulsorySpaceForm::ok()
46 {
47 	double weight;
48 	QString tmp=weightLineEdit->text();
49 	weight_sscanf(tmp, "%lf", &weight);
50 	if(weight<0.0 || weight>100){
51 		QMessageBox::warning(this, tr("FET information"),
52 			tr("Invalid weight"));
53 		return;
54 	}
55 
56 	if(weight!=100.0){
57 		QMessageBox::warning(this, tr("FET information"),
58 			tr("Invalid weight (percentage) - it has to be 100%"));
59 		return;
60 	}
61 
62 	this->_ctr->weightPercentage=weight;
63 
64 	gt.rules.internalStructureComputed=false;
65 	setRulesModifiedAndOtherThings(&gt.rules);
66 
67 	this->close();
68 }
69 
cancel()70 void ModifyConstraintBasicCompulsorySpaceForm::cancel()
71 {
72 	this->close();
73 }
74