"Fossies" - the Fresh Open Source Software Archive

Member "fet-5.48.0/src/interface/addconstraintstudentssethomeroomform.cpp" (12 Feb 2020, 3340 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 "addconstraintstudentssethomeroomform.cpp" see the Fossies "Dox" file reference documentation.

    1 /***************************************************************************
    2                           addconstraintstudentssethomeroomform.cpp  -  description
    3                              -------------------
    4     begin                : 8 Apr 2005
    5     copyright            : (C) 2005 by Liviu Lalescu
    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 "longtextmessagebox.h"
   21 
   22 #include "addconstraintstudentssethomeroomform.h"
   23 #include "spaceconstraint.h"
   24 
   25 AddConstraintStudentsSetHomeRoomForm::AddConstraintStudentsSetHomeRoomForm(QWidget* parent): QDialog(parent)
   26 {
   27     setupUi(this);
   28 
   29     addConstraintPushButton->setDefault(true);
   30 
   31     connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
   32     connect(addConstraintPushButton, SIGNAL(clicked()), this, SLOT(addConstraint()));
   33 
   34     centerWidgetOnScreen(this);
   35     restoreFETDialogGeometry(this);
   36     
   37     QSize tmp2=studentsComboBox->minimumSizeHint();
   38     Q_UNUSED(tmp2);
   39     
   40     QSize tmp5=roomsComboBox->minimumSizeHint();
   41     Q_UNUSED(tmp5);
   42 
   43     updateStudentsComboBox();
   44     updateRoomsComboBox();
   45 }
   46 
   47 AddConstraintStudentsSetHomeRoomForm::~AddConstraintStudentsSetHomeRoomForm()
   48 {
   49     saveFETDialogGeometry(this);
   50 }
   51 
   52 void AddConstraintStudentsSetHomeRoomForm::updateStudentsComboBox(){
   53     populateStudentsComboBox(studentsComboBox);
   54 }
   55 
   56 void AddConstraintStudentsSetHomeRoomForm::updateRoomsComboBox()
   57 {
   58     roomsComboBox->clear();
   59     for(int i=0; i<gt.rules.roomsList.size(); i++){
   60         Room* rm=gt.rules.roomsList[i];
   61         roomsComboBox->addItem(rm->name);
   62     }
   63 }
   64 
   65 void AddConstraintStudentsSetHomeRoomForm::addConstraint()
   66 {
   67     SpaceConstraint *ctr=NULL;
   68 
   69     double weight;
   70     QString tmp=weightLineEdit->text();
   71     weight_sscanf(tmp, "%lf", &weight);
   72     if(weight<0.0 || weight>100){
   73         QMessageBox::warning(this, tr("FET information"),
   74             tr("Invalid weight"));
   75         return;
   76     }
   77 
   78     QString students=studentsComboBox->currentText();
   79     assert(gt.rules.searchStudentsSet(students)!=NULL);
   80 
   81     int i=roomsComboBox->currentIndex();
   82     if(i<0 || roomsComboBox->count()<=0){
   83         QMessageBox::warning(this, tr("FET information"),
   84             tr("Invalid room"));
   85         return;
   86     }
   87     QString room=roomsComboBox->currentText();
   88 
   89     ctr=new ConstraintStudentsSetHomeRoom(weight, students, room);
   90 
   91     bool tmp2=gt.rules.addSpaceConstraint(ctr);
   92     if(tmp2){
   93         QString s=tr("Constraint added:");
   94         s+="\n\n";
   95         s+=ctr->getDetailedDescription(gt.rules);
   96         LongTextMessageBox::information(this, tr("FET information"), s);
   97     }
   98     else{
   99         QMessageBox::warning(this, tr("FET information"),
  100             tr("Constraint NOT added - error ?"));
  101         delete ctr;
  102     }
  103 }