📄 addconstraint2activitiesconsecutiveform.cpp
字号:
/*************************************************************************** addconstraint2activitiesconsecutiveform.cpp - description ------------------- begin : 15 May 2004 copyright : (C) 2004 by Lalescu Liviu email : liviu@lalescu.ro ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#include "addconstraint2activitiesconsecutiveform.h"#include "timeconstraint.h"#include <qradiobutton.h>#include <qlabel.h>#include <qlineedit.h>#define yesNo(x) ((x)==0?QObject::tr("no"):QObject::tr("yes"))AddConstraint2ActivitiesConsecutiveForm::AddConstraint2ActivitiesConsecutiveForm(){}AddConstraint2ActivitiesConsecutiveForm::~AddConstraint2ActivitiesConsecutiveForm(){}void AddConstraint2ActivitiesConsecutiveForm::constraintChanged(){ QString s; s+=QObject::tr("Current constraint"); s+=":\n"; double weight; QString tmp=weightLineEdit->text(); sscanf(tmp, "%lf", &weight); s+=QObject::tr("Weight=%1").arg(weight); s+="\n"; bool compulsory=false; if(compulsoryCheckBox->isChecked()) compulsory=true; s+=QObject::tr("Compulsory=%1").arg(yesNo(compulsory)); s+="\n"; s+=QObject::tr("The activities with id's: %1 must be scheduled consecutively (order is important)").arg(activitiesIdsLineEdit->text()); s+="\n"; currentConstraintTextEdit->setText(s);}void AddConstraint2ActivitiesConsecutiveForm::addCurrentConstraint(){ TimeConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); sscanf(tmp, "%lf", &weight); if(weight<0.0){ QMessageBox::warning(this, QObject::tr("FET information"), QObject::tr("Invalid weight")); return; } bool compulsory=false; if(compulsoryCheckBox->isChecked()) compulsory=true; int act_id[2]; int n_act=sscanf(activitiesIdsLineEdit->text(), "%d,%d", act_id, act_id+1); if(n_act!=2){ QMessageBox::warning(this, QObject::tr("FET information"), QObject::tr("Please input 2 activities (in order) separated by commas")); return; } ctr=new Constraint2ActivitiesConsecutive(weight, compulsory, act_id[0], act_id[1]); bool tmp2=gt.rules.addTimeConstraint(ctr); if(tmp2) QMessageBox::information(this, QObject::tr("FET information"), QObject::tr("Constraint added")); else{ QMessageBox::warning(this, QObject::tr("FET information"), QObject::tr("Constraint NOT added - please report error")); delete ctr; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -