"Fossies" - the Fresh Open Source Software Archive

Member "fet-5.41.0/src/interface/activitiesroomsstatisticsform.cpp" (16 Jul 2018, 12080 Bytes) of package /linux/privat/fet-5.41.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 "activitiesroomsstatisticsform.cpp" see the Fossies "Dox" file reference documentation.

    1 /***************************************************************************
    2                           activitiesroomsstatisticform.cpp  -  description
    3                              -------------------
    4     begin                : October 6, 2011
    5     copyright            : (C) 2011 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 "activitiesroomsstatisticsform.h"
   19 
   20 #include "timetable_defs.h"
   21 #include "timetable.h"
   22 
   23 #include "fet.h"
   24 
   25 #include <QString>
   26 #include <QStringList>
   27 
   28 #include <QSet>
   29 #include <QList>
   30 #include <QStringList>
   31 
   32 ActivitiesRoomsStatisticsForm::ActivitiesRoomsStatisticsForm(QWidget* parent): QDialog(parent)
   33 {
   34     setupUi(this);
   35     
   36     closeButton->setDefault(true);
   37 
   38     connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
   39     
   40     centerWidgetOnScreen(this);
   41     restoreFETDialogGeometry(this);
   42 
   43     possiblyPlainTextEdit->setReadOnly(true);
   44     certainlyPlainTextEdit->setReadOnly(true);
   45     
   46     QSet<int> activitiesWith100;
   47     QSet<int> activitiesWithUnder100;
   48     
   49     for(Activity* act : qAsConst(gt.rules.activitiesList)){
   50         if(!act->active)
   51             continue;
   52     
   53         QSet<QString> currentActivityTagsSet=act->activityTagsNames.toSet();
   54     
   55         for(SpaceConstraint* genericConstraint : qAsConst(gt.rules.spaceConstraintsList)){
   56             if(!genericConstraint->active)
   57                 continue;
   58         
   59             if(genericConstraint->type==CONSTRAINT_STUDENTS_SET_HOME_ROOM){
   60                 ConstraintStudentsSetHomeRoom* ctr=(ConstraintStudentsSetHomeRoom*)genericConstraint;
   61                 
   62                 if(act->studentsNames.count()==1){
   63                     if(act->studentsNames.at(0)==ctr->studentsName){
   64                         if(ctr->weightPercentage==100.0){
   65                             if(!activitiesWith100.contains(act->id)){
   66                                 activitiesWith100.insert(act->id);
   67                             }
   68                         }
   69                         else if(ctr->weightPercentage>=0.0 && ctr->weightPercentage<100.0){
   70                             if(!activitiesWithUnder100.contains(act->id)){
   71                                 activitiesWithUnder100.insert(act->id);
   72                             }
   73                         }
   74                     }
   75                 }
   76             }
   77 
   78             else if(genericConstraint->type==CONSTRAINT_STUDENTS_SET_HOME_ROOMS){
   79                 ConstraintStudentsSetHomeRooms* ctr=(ConstraintStudentsSetHomeRooms*)genericConstraint;
   80                 
   81                 if(act->studentsNames.count()==1){
   82                     if(act->studentsNames.at(0)==ctr->studentsName){
   83                         if(ctr->weightPercentage==100.0){
   84                             if(!activitiesWith100.contains(act->id)){
   85                                 activitiesWith100.insert(act->id);
   86                             }
   87                         }
   88                         else if(ctr->weightPercentage>=0.0 && ctr->weightPercentage<100.0){
   89                             if(!activitiesWithUnder100.contains(act->id)){
   90                                 activitiesWithUnder100.insert(act->id);
   91                             }
   92                         }
   93                     }
   94                 }
   95             }
   96 
   97             else if(genericConstraint->type==CONSTRAINT_TEACHER_HOME_ROOM){
   98                 ConstraintTeacherHomeRoom* ctr=(ConstraintTeacherHomeRoom*)genericConstraint;
   99                 
  100                 if(act->teachersNames.count()==1){
  101                     if(act->teachersNames.at(0)==ctr->teacherName){
  102                         if(ctr->weightPercentage==100.0){
  103                             if(!activitiesWith100.contains(act->id)){
  104                                 activitiesWith100.insert(act->id);
  105                             }
  106                         }
  107                         else if(ctr->weightPercentage>=0.0 && ctr->weightPercentage<100.0){
  108                             if(!activitiesWithUnder100.contains(act->id)){
  109                                 activitiesWithUnder100.insert(act->id);
  110                             }
  111                         }
  112                     }
  113                 }
  114             }
  115 
  116             else if(genericConstraint->type==CONSTRAINT_TEACHER_HOME_ROOMS){
  117                 ConstraintTeacherHomeRooms* ctr=(ConstraintTeacherHomeRooms*)genericConstraint;
  118                 
  119                 if(act->teachersNames.count()==1){
  120                     if(act->teachersNames.at(0)==ctr->teacherName){
  121                         if(ctr->weightPercentage==100.0){
  122                             if(!activitiesWith100.contains(act->id)){
  123                                 activitiesWith100.insert(act->id);
  124                             }
  125                         }
  126                         else if(ctr->weightPercentage>=0.0 && ctr->weightPercentage<100.0){
  127                             if(!activitiesWithUnder100.contains(act->id)){
  128                                 activitiesWithUnder100.insert(act->id);
  129                             }
  130                         }
  131                     }
  132                 }
  133             }
  134 
  135             else if(genericConstraint->type==CONSTRAINT_SUBJECT_PREFERRED_ROOM){
  136                 ConstraintSubjectPreferredRoom* ctr=(ConstraintSubjectPreferredRoom*)genericConstraint;
  137                 
  138                 if(act->subjectName==ctr->subjectName){
  139                     if(ctr->weightPercentage==100.0){
  140                         if(!activitiesWith100.contains(act->id)){
  141                             activitiesWith100.insert(act->id);
  142                         }
  143                     }
  144                     else if(ctr->weightPercentage>=0.0 && ctr->weightPercentage<100.0){
  145                         if(!activitiesWithUnder100.contains(act->id)){
  146                             activitiesWithUnder100.insert(act->id);
  147                         }
  148                     }
  149                 }
  150             }
  151 
  152             else if(genericConstraint->type==CONSTRAINT_SUBJECT_PREFERRED_ROOMS){
  153                 ConstraintSubjectPreferredRooms* ctr=(ConstraintSubjectPreferredRooms*)genericConstraint;
  154                 
  155                 if(act->subjectName==ctr->subjectName){
  156                     if(ctr->weightPercentage==100.0){
  157                         if(!activitiesWith100.contains(act->id)){
  158                             activitiesWith100.insert(act->id);
  159                         }
  160                     }
  161                     else if(ctr->weightPercentage>=0.0 && ctr->weightPercentage<100.0){
  162                         if(!activitiesWithUnder100.contains(act->id)){
  163                             activitiesWithUnder100.insert(act->id);
  164                         }
  165                     }
  166                 }
  167             }
  168 
  169             else if(genericConstraint->type==CONSTRAINT_SUBJECT_ACTIVITY_TAG_PREFERRED_ROOM){
  170                 ConstraintSubjectActivityTagPreferredRoom* ctr=(ConstraintSubjectActivityTagPreferredRoom*)genericConstraint;
  171                 
  172                 if(act->subjectName==ctr->subjectName && currentActivityTagsSet.contains(ctr->activityTagName)){
  173                     if(ctr->weightPercentage==100.0){
  174                         if(!activitiesWith100.contains(act->id)){
  175                             activitiesWith100.insert(act->id);
  176                         }
  177                     }
  178                     else if(ctr->weightPercentage>=0.0 && ctr->weightPercentage<100.0){
  179                         if(!activitiesWithUnder100.contains(act->id)){
  180                             activitiesWithUnder100.insert(act->id);
  181                         }
  182                     }
  183                 }
  184             }
  185 
  186             else if(genericConstraint->type==CONSTRAINT_SUBJECT_ACTIVITY_TAG_PREFERRED_ROOMS){
  187                 ConstraintSubjectActivityTagPreferredRooms* ctr=(ConstraintSubjectActivityTagPreferredRooms*)genericConstraint;
  188                 
  189                 if(act->subjectName==ctr->subjectName && currentActivityTagsSet.contains(ctr->activityTagName)){
  190                     if(ctr->weightPercentage==100.0){
  191                         if(!activitiesWith100.contains(act->id)){
  192                             activitiesWith100.insert(act->id);
  193                         }
  194                     }
  195                     else if(ctr->weightPercentage>=0.0 && ctr->weightPercentage<100.0){
  196                         if(!activitiesWithUnder100.contains(act->id)){
  197                             activitiesWithUnder100.insert(act->id);
  198                         }
  199                     }
  200                 }
  201             }
  202 
  203             else if(genericConstraint->type==CONSTRAINT_ACTIVITY_TAG_PREFERRED_ROOM){
  204                 ConstraintActivityTagPreferredRoom* ctr=(ConstraintActivityTagPreferredRoom*)genericConstraint;
  205                 
  206                 if(currentActivityTagsSet.contains(ctr->activityTagName)){
  207                     if(ctr->weightPercentage==100.0){
  208                         if(!activitiesWith100.contains(act->id)){
  209                             activitiesWith100.insert(act->id);
  210                         }
  211                     }
  212                     else if(ctr->weightPercentage>=0.0 && ctr->weightPercentage<100.0){
  213                         if(!activitiesWithUnder100.contains(act->id)){
  214                             activitiesWithUnder100.insert(act->id);
  215                         }
  216                     }
  217                 }
  218             }
  219 
  220             else if(genericConstraint->type==CONSTRAINT_ACTIVITY_TAG_PREFERRED_ROOMS){
  221                 ConstraintActivityTagPreferredRooms* ctr=(ConstraintActivityTagPreferredRooms*)genericConstraint;
  222                 
  223                 if(currentActivityTagsSet.contains(ctr->activityTagName)){
  224                     if(ctr->weightPercentage==100.0){
  225                         if(!activitiesWith100.contains(act->id)){
  226                             activitiesWith100.insert(act->id);
  227                         }
  228                     }
  229                     else if(ctr->weightPercentage>=0.0 && ctr->weightPercentage<100.0){
  230                         if(!activitiesWithUnder100.contains(act->id)){
  231                             activitiesWithUnder100.insert(act->id);
  232                         }
  233                     }
  234                 }
  235             }
  236 
  237             else if(genericConstraint->type==CONSTRAINT_ACTIVITY_PREFERRED_ROOM){
  238                 ConstraintActivityPreferredRoom* ctr=(ConstraintActivityPreferredRoom*)genericConstraint;
  239                 
  240                 if(act->id==ctr->activityId){
  241                     if(ctr->weightPercentage==100.0){
  242                         if(!activitiesWith100.contains(act->id)){
  243                             activitiesWith100.insert(act->id);
  244                         }
  245                     }
  246                     else if(ctr->weightPercentage>=0.0 && ctr->weightPercentage<100.0){
  247                         if(!activitiesWithUnder100.contains(act->id)){
  248                             activitiesWithUnder100.insert(act->id);
  249                         }
  250                     }
  251                 }
  252             }
  253 
  254             else if(genericConstraint->type==CONSTRAINT_ACTIVITY_PREFERRED_ROOMS){
  255                 ConstraintActivityPreferredRooms* ctr=(ConstraintActivityPreferredRooms*)genericConstraint;
  256                 
  257                 if(act->id==ctr->activityId){
  258                     if(ctr->weightPercentage==100.0){
  259                         if(!activitiesWith100.contains(act->id)){
  260                             activitiesWith100.insert(act->id);
  261                         }
  262                     }
  263                     else if(ctr->weightPercentage>=0.0 && ctr->weightPercentage<100.0){
  264                         if(!activitiesWithUnder100.contains(act->id)){
  265                             activitiesWithUnder100.insert(act->id);
  266                         }
  267                     }
  268                 }
  269             }
  270         }
  271     }
  272     
  273     activitiesWithUnder100.subtract(activitiesWith100);
  274     
  275     QList<int> certainlyWithUnspecifiedRoom;
  276     QList<int> possiblyWithUnspecifiedRoom;
  277     
  278     for(Activity* act : qAsConst(gt.rules.activitiesList)){
  279         if(!act->active)
  280             continue;
  281 
  282         if(!activitiesWith100.contains(act->id)){
  283             if(activitiesWithUnder100.contains(act->id)){
  284                 possiblyWithUnspecifiedRoom.append(act->id);
  285             }
  286             else{
  287                 certainlyWithUnspecifiedRoom.append(act->id);
  288             }
  289         }
  290     }
  291     
  292     QString strPossiblyWithoutRoom;
  293     if(possiblyWithUnspecifiedRoom.count()>0){
  294         strPossiblyWithoutRoom=tr("You have %1 activities which might end up in an unspecified room"
  295          " (not considering those which will certainly end up in an unspecified room). They are listed below:",
  296          "Instructions for translators: take care, it is 'might', so it is only a possibility.")
  297          .arg(possiblyWithUnspecifiedRoom.count());
  298         strPossiblyWithoutRoom+=QString("\n\n");
  299         
  300         for(int i=0; i<possiblyWithUnspecifiedRoom.count(); i++){
  301             int id=possiblyWithUnspecifiedRoom.at(i);
  302             strPossiblyWithoutRoom+=tr("No: %1, Id: %2 (%3)", "%1 is the current number, %2 is the activity id, %3 is the detailed activity description")
  303              .arg(i+1).arg(id).arg(getActivityDetailedDescription(gt.rules, id));
  304             strPossiblyWithoutRoom+=QString("\n");
  305         }
  306     }
  307     else{
  308         strPossiblyWithoutRoom=tr("You do not have activities which might end up in an unspecified room"
  309         " (not considering those which will certainly end up in an unspecified room).",
  310          "Instructions for translators: take care, it is 'might', so it is only a possibility.");
  311         strPossiblyWithoutRoom+=QString("\n");
  312     }
  313 
  314     QString strCertainlyWithoutRoom;
  315     if(certainlyWithUnspecifiedRoom.count()>0){
  316         strCertainlyWithoutRoom=tr("You have %1 activities which will certainly end up in an unspecified room. They are listed below:",
  317          "Instructions for translators: take care, it is 'certainly'.")
  318          .arg(certainlyWithUnspecifiedRoom.count());
  319         strCertainlyWithoutRoom+=QString("\n\n");
  320         
  321         for(int i=0; i<certainlyWithUnspecifiedRoom.count(); i++){
  322             int id=certainlyWithUnspecifiedRoom.at(i);
  323             strCertainlyWithoutRoom+=tr("No: %1, Id: %2 (%3)", "%1 is the current number, %2 is the activity id, %3 is the detailed activity description")
  324              .arg(i+1).arg(id).arg(getActivityDetailedDescription(gt.rules, id));
  325             strCertainlyWithoutRoom+=QString("\n");
  326         }
  327     }
  328     else{
  329         strCertainlyWithoutRoom=tr("You do not have activities which will certainly end up in an unspecified room.",
  330          "Instructions for translators: take care, it is 'certainly'.");
  331         strCertainlyWithoutRoom+=QString("\n");
  332     }
  333     
  334     possiblyPlainTextEdit->setPlainText(strPossiblyWithoutRoom);
  335     certainlyPlainTextEdit->setPlainText(strCertainlyWithoutRoom);
  336 }
  337 
  338 ActivitiesRoomsStatisticsForm::~ActivitiesRoomsStatisticsForm()
  339 {
  340     saveFETDialogGeometry(this);
  341 }