"Fossies" - the Fresh Open Source Software Archive

Member "fet-5.48.0/src/interface/addconstraintsubjectactivitytagpreferredroomform.cpp" (9 Oct 2017, 4323 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 "addconstraintsubjectactivitytagpreferredroomform.cpp" see the Fossies "Dox" file reference documentation.

    1 /***************************************************************************
    2                           addconstraintsubjectactivitytagpreferredroomform.cpp  -  description
    3                              -------------------
    4     begin                : 18 Aug 2007
    5     copyright            : (C) 2007 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 "addconstraintsubjectactivitytagpreferredroomform.h"
   23 #include "spaceconstraint.h"
   24 
   25 AddConstraintSubjectActivityTagPreferredRoomForm::AddConstraintSubjectActivityTagPreferredRoomForm(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 tmp3=subjectsComboBox->minimumSizeHint();
   38     Q_UNUSED(tmp3);
   39     QSize tmp4=activityTagsComboBox->minimumSizeHint();
   40     Q_UNUSED(tmp4);
   41     
   42     QSize tmp5=roomsComboBox->minimumSizeHint();
   43     Q_UNUSED(tmp5);
   44     
   45     updateSubjectsComboBox();
   46     updateActivityTagsComboBox();
   47     updateRoomsComboBox();
   48 }
   49 
   50 AddConstraintSubjectActivityTagPreferredRoomForm::~AddConstraintSubjectActivityTagPreferredRoomForm()
   51 {
   52     saveFETDialogGeometry(this);
   53 }
   54 
   55 void AddConstraintSubjectActivityTagPreferredRoomForm::updateSubjectsComboBox()
   56 {
   57     subjectsComboBox->clear();
   58     for(int i=0; i<gt.rules.subjectsList.size(); i++){
   59         Subject* sb=gt.rules.subjectsList[i];
   60         subjectsComboBox->addItem(sb->name);
   61     }
   62 }
   63 
   64 void AddConstraintSubjectActivityTagPreferredRoomForm::updateActivityTagsComboBox()
   65 {
   66     activityTagsComboBox->clear();
   67     for(int i=0; i<gt.rules.activityTagsList.size(); i++){
   68         ActivityTag* sb=gt.rules.activityTagsList[i];
   69         activityTagsComboBox->addItem(sb->name);
   70     }
   71 }
   72 
   73 void AddConstraintSubjectActivityTagPreferredRoomForm::updateRoomsComboBox()
   74 {
   75     roomsComboBox->clear();
   76     for(int i=0; i<gt.rules.roomsList.size(); i++){
   77         Room* rm=gt.rules.roomsList[i];
   78         roomsComboBox->addItem(rm->name);
   79     }
   80 }
   81 
   82 void AddConstraintSubjectActivityTagPreferredRoomForm::addConstraint()
   83 {
   84     SpaceConstraint *ctr=NULL;
   85 
   86     double weight;
   87     QString tmp=weightLineEdit->text();
   88     weight_sscanf(tmp, "%lf", &weight);
   89     if(weight<0.0 || weight>100){
   90         QMessageBox::warning(this, tr("FET information"),
   91             tr("Invalid weight"));
   92         return;
   93     }
   94 
   95     int i=subjectsComboBox->currentIndex();
   96     if(i<0 || subjectsComboBox->count()<=0){
   97         QMessageBox::warning(this, tr("FET information"),
   98             tr("Invalid subject"));
   99         return;
  100     }
  101     QString subject=subjectsComboBox->currentText();
  102 
  103     i=activityTagsComboBox->currentIndex();
  104     if(i<0 || activityTagsComboBox->count()<=0){
  105         QMessageBox::warning(this, tr("FET information"),
  106             tr("Invalid activity tag"));
  107         return;
  108     }
  109     QString activityTag=activityTagsComboBox->currentText();
  110 
  111     i=roomsComboBox->currentIndex();
  112     if(i<0 || roomsComboBox->count()<=0){
  113         QMessageBox::warning(this, tr("FET information"),
  114             tr("Invalid room"));
  115         return;
  116     }
  117     QString room=roomsComboBox->currentText();
  118 
  119     ctr=new ConstraintSubjectActivityTagPreferredRoom(weight, subject, activityTag, room);
  120 
  121     bool tmp2=gt.rules.addSpaceConstraint(ctr);
  122     if(tmp2){
  123         QString s=tr("Constraint added:");
  124         s+="\n\n";
  125         s+=ctr->getDetailedDescription(gt.rules);
  126         LongTextMessageBox::information(this, tr("FET information"), s);
  127     }
  128     else{
  129         QMessageBox::warning(this, tr("FET information"),
  130             tr("Constraint NOT added - error ?"));
  131         delete ctr;
  132     }
  133 }