"Fossies" - the Fresh Open Source Software Archive

Member "fet-5.48.0/src/interface/modifyconstraintstudentssetmingapsbetweenorderedpairofactivitytagsform.cpp" (12 Feb 2020, 5651 Bytes) of package /linux/privat/fet-5.48.0.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 "modifyconstraintstudentssetmingapsbetweenorderedpairofactivitytagsform.cpp" see the Fossies "Dox" file reference documentation.

    1 /***************************************************************************
    2                           modifyconstraintstudentssetmingapsbetweenorderedpairofactivitytagsform.cpp  -  description
    3                              -------------------
    4     begin                : 2019
    5     copyright            : (C) 2019 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 "modifyconstraintstudentssetmingapsbetweenorderedpairofactivitytagsform.h"
   21 #include "timeconstraint.h"
   22 
   23 ModifyConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTagsForm::ModifyConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTagsForm
   24  (QWidget* parent, ConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTags* ctr): QDialog(parent)
   25 {
   26     setupUi(this);
   27 
   28     okPushButton->setDefault(true);
   29 
   30     connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
   31     connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
   32 
   33     centerWidgetOnScreen(this);
   34     restoreFETDialogGeometry(this);
   35 
   36     QSize tmp2=studentsComboBox->minimumSizeHint();
   37     Q_UNUSED(tmp2);
   38     QSize tmp4=firstActivityTagComboBox->minimumSizeHint();
   39     Q_UNUSED(tmp4);
   40     QSize tmp5=secondActivityTagComboBox->minimumSizeHint();
   41     Q_UNUSED(tmp5);
   42     
   43     this->_ctr=ctr;
   44     
   45     weightLineEdit->setText(CustomFETString::number(ctr->weightPercentage));
   46     
   47     updateStudentsComboBox(parent);
   48     updateFirstActivityTagComboBox();
   49     updateSecondActivityTagComboBox();
   50 
   51     minGapsSpinBox->setMinimum(1);
   52     minGapsSpinBox->setMaximum(gt.rules.nHoursPerDay);
   53     minGapsSpinBox->setValue(ctr->minGaps);
   54 }
   55 
   56 ModifyConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTagsForm::~ModifyConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTagsForm()
   57 {
   58     saveFETDialogGeometry(this);
   59 }
   60 
   61 void ModifyConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTagsForm::updateStudentsComboBox(QWidget* parent){
   62     int j=populateStudentsComboBox(studentsComboBox, this->_ctr->students);
   63     if(j<0)
   64         showWarningForInvisibleSubgroupConstraint(parent, this->_ctr->students);
   65     else
   66         assert(j>=0);
   67     studentsComboBox->setCurrentIndex(j);
   68 }
   69 
   70 void ModifyConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTagsForm::updateFirstActivityTagComboBox()
   71 {
   72     firstActivityTagComboBox->clear();
   73     int j=-1;
   74     for(int i=0; i<gt.rules.activityTagsList.count(); i++){
   75         ActivityTag* at=gt.rules.activityTagsList.at(i);
   76         firstActivityTagComboBox->addItem(at->name);
   77         if(at->name==this->_ctr->firstActivityTag)
   78             j=i;
   79     }
   80     assert(j>=0);
   81     firstActivityTagComboBox->setCurrentIndex(j);
   82 }
   83 
   84 void ModifyConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTagsForm::updateSecondActivityTagComboBox()
   85 {
   86     secondActivityTagComboBox->clear();
   87     int j=-1;
   88     for(int i=0; i<gt.rules.activityTagsList.count(); i++){
   89         ActivityTag* at=gt.rules.activityTagsList.at(i);
   90         secondActivityTagComboBox->addItem(at->name);
   91         if(at->name==this->_ctr->secondActivityTag)
   92             j=i;
   93     }
   94     assert(j>=0);
   95     secondActivityTagComboBox->setCurrentIndex(j);
   96 }
   97 
   98 void ModifyConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTagsForm::ok()
   99 {
  100     if(studentsComboBox->currentIndex()<0){
  101         showWarningCannotModifyConstraintInvisibleSubgroupConstraint(this, this->_ctr->students);
  102         return;
  103     }
  104 
  105     double weight;
  106     QString tmp=weightLineEdit->text();
  107     weight_sscanf(tmp, "%lf", &weight);
  108     if(weight<0.0 || weight>100.0){
  109         QMessageBox::warning(this, tr("FET warning"),
  110             tr("Invalid weight (percentage)"));
  111         return;
  112     }
  113     if(weight!=100.0){
  114         QMessageBox::warning(this, tr("FET information"),
  115             tr("Invalid weight (percentage) - must be 100%"));
  116         return;
  117     }
  118 
  119     QString students_name=studentsComboBox->currentText();
  120     StudentsSet* s=gt.rules.searchStudentsSet(students_name);
  121     if(s==NULL){
  122         QMessageBox::warning(this, tr("FET warning"),
  123             tr("Invalid students set"));
  124         return;
  125     }
  126     
  127     QString firstActivityTagName=firstActivityTagComboBox->currentText();
  128     int fati=gt.rules.searchActivityTag(firstActivityTagName);
  129     if(fati<0){
  130         QMessageBox::warning(this, tr("FET warning"), tr("Invalid activity tag"));
  131         return;
  132     }
  133 
  134     QString secondActivityTagName=secondActivityTagComboBox->currentText();
  135     int sati=gt.rules.searchActivityTag(secondActivityTagName);
  136     if(sati<0){
  137         QMessageBox::warning(this, tr("FET warning"), tr("Invalid activity tag"));
  138         return;
  139     }
  140     
  141     if(firstActivityTagName==secondActivityTagName){
  142         QMessageBox::warning(this, tr("FET warning"), tr("The two activity tags cannot be the same"));
  143         return;
  144     }
  145 
  146     this->_ctr->weightPercentage=weight;
  147     this->_ctr->students=students_name;
  148     this->_ctr->firstActivityTag=firstActivityTagName;
  149     this->_ctr->secondActivityTag=secondActivityTagName;
  150     this->_ctr->minGaps=minGapsSpinBox->value();
  151 
  152     gt.rules.internalStructureComputed=false;
  153     setRulesModifiedAndOtherThings(&gt.rules);
  154     
  155     this->close();
  156 }
  157 
  158 void ModifyConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTagsForm::cancel()
  159 {
  160     this->close();
  161 }