"Fossies" - the Fresh Open Source Software Archive

Member "fet-5.47.1/src/interface/modifyconstraintstudentssetmaxgapsperdayform.cpp" (12 Feb 2020, 3563 Bytes) of package /linux/privat/fet-5.47.1.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "modifyconstraintstudentssetmaxgapsperdayform.cpp" see the Fossies "Dox" file reference documentation.

    1 /***************************************************************************
    2                           modifyconstraintstudentssetmaxgapsperdayform.cpp  -  description
    3                              -------------------
    4     begin                : 2009
    5     copyright            : (C) 2009 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 "modifyconstraintstudentssetmaxgapsperdayform.h"
   21 #include "timeconstraint.h"
   22 
   23 ModifyConstraintStudentsSetMaxGapsPerDayForm::ModifyConstraintStudentsSetMaxGapsPerDayForm(QWidget* parent, ConstraintStudentsSetMaxGapsPerDay* 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     QSize tmp2=studentsComboBox->minimumSizeHint();
   36     Q_UNUSED(tmp2);
   37     
   38     this->_ctr=ctr;
   39     
   40     weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));
   41 
   42     maxGapsSpinBox->setMinimum(0);
   43     maxGapsSpinBox->setMaximum(gt.rules.nHoursPerDay);
   44     maxGapsSpinBox->setValue(ctr->maxGaps);
   45     
   46     updateStudentsComboBox(parent);
   47 }
   48 
   49 ModifyConstraintStudentsSetMaxGapsPerDayForm::~ModifyConstraintStudentsSetMaxGapsPerDayForm()
   50 {
   51     saveFETDialogGeometry(this);
   52 }
   53 
   54 void ModifyConstraintStudentsSetMaxGapsPerDayForm::updateStudentsComboBox(QWidget* parent){
   55     int j=populateStudentsComboBox(studentsComboBox, this->_ctr->students);
   56     if(j<0)
   57         showWarningForInvisibleSubgroupConstraint(parent, this->_ctr->students);
   58     else
   59         assert(j>=0);
   60     studentsComboBox->setCurrentIndex(j);
   61 }
   62 
   63 void ModifyConstraintStudentsSetMaxGapsPerDayForm::ok()
   64 {
   65     if(studentsComboBox->currentIndex()<0){
   66         showWarningCannotModifyConstraintInvisibleSubgroupConstraint(this, this->_ctr->students);
   67         return;
   68     }
   69 
   70     double weight;
   71     QString tmp=weightLineEdit->text();
   72     weight_sscanf(tmp, "%lf", &weight);
   73     if(weight<0.0 || weight>100.0){
   74         QMessageBox::warning(this, tr("FET information"),
   75             tr("Invalid weight (percentage)"));
   76         return;
   77     }
   78     if(weight!=100.0){
   79         QMessageBox::warning(this, tr("FET information"),
   80             tr("Invalid weight (percentage) - it must be 100%"));
   81         return;
   82     }
   83 
   84     QString students_name=studentsComboBox->currentText();
   85     StudentsSet* s=gt.rules.searchStudentsSet(students_name);
   86     if(s==NULL){
   87         QMessageBox::warning(this, tr("FET information"),
   88             tr("Invalid students set"));
   89         return;
   90     }
   91 
   92     this->_ctr->weightPercentage=weight;
   93     this->_ctr->maxGaps=maxGapsSpinBox->value();
   94     this->_ctr->students=students_name;
   95 
   96     gt.rules.internalStructureComputed=false;
   97     setRulesModifiedAndOtherThings(&gt.rules);
   98     
   99     this->close();
  100 }
  101 
  102 void ModifyConstraintStudentsSetMaxGapsPerDayForm::cancel()
  103 {
  104     this->close();
  105 }