Back to index

fet  5.18.0
alltimeconstraintsform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           alltimeconstraintsform.cpp  -  description
00003                              -------------------
00004     begin                : Feb 10, 2005
00005     copyright            : (C) 2005 by Lalescu Liviu
00006     email                : Please see http://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address)
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "longtextmessagebox.h"
00019 
00020 #include "alltimeconstraintsform.h"
00021 
00022 #include "modifyconstraintbreaktimesform.h"
00023 #include "modifyconstraintbasiccompulsorytimeform.h"
00024 
00025 #include "modifyconstraintactivitypreferredtimeslotsform.h"
00026 #include "modifyconstraintactivitypreferredstartingtimesform.h"
00027 #include "modifyconstrainttwoactivitiesconsecutiveform.h"
00028 #include "modifyconstrainttwoactivitiesgroupedform.h"
00029 #include "modifyconstraintthreeactivitiesgroupedform.h"
00030 #include "modifyconstrainttwoactivitiesorderedform.h"
00031 
00032 #include "modifyconstraintactivitiespreferredtimeslotsform.h"
00033 #include "modifyconstraintactivitiespreferredstartingtimesform.h"
00034 
00035 #include "modifyconstraintsubactivitiespreferredtimeslotsform.h"
00036 #include "modifyconstraintsubactivitiespreferredstartingtimesform.h"
00037 
00038 #include "modifyconstraintactivitiessamestartingtimeform.h"
00039 #include "modifyconstraintactivitiessamestartinghourform.h"
00040 #include "modifyconstraintactivitiessamestartingdayform.h"
00041 #include "modifyconstraintactivitypreferredstartingtimeform.h"
00042 #include "modifyconstraintactivitiesnotoverlappingform.h"
00043 #include "modifyconstraintmindaysbetweenactivitiesform.h"
00044 #include "modifyconstraintmaxdaysbetweenactivitiesform.h"
00045 #include "modifyconstraintmingapsbetweenactivitiesform.h"
00046 #include "modifyconstraintactivityendsstudentsdayform.h"
00047 
00048 #include "modifyconstraintactivitiesendstudentsdayform.h"
00049 
00050 #include "modifyconstraintteachernotavailabletimesform.h"
00051 #include "modifyconstraintteachersmaxgapsperweekform.h"
00052 #include "modifyconstraintteachermaxgapsperweekform.h"
00053 #include "modifyconstraintteachersmaxgapsperdayform.h"
00054 #include "modifyconstraintteachermaxgapsperdayform.h"
00055 #include "modifyconstraintteachermaxdaysperweekform.h"
00056 #include "modifyconstraintteachersmaxdaysperweekform.h"
00057 #include "modifyconstraintteachersmaxhoursdailyform.h"
00058 #include "modifyconstraintteachermaxhoursdailyform.h"
00059 #include "modifyconstraintteachersmaxhourscontinuouslyform.h"
00060 #include "modifyconstraintteachermaxhourscontinuouslyform.h"
00061 #include "modifyconstraintteachersminhoursdailyform.h"
00062 #include "modifyconstraintteacherminhoursdailyform.h"
00063 
00064 #include "modifyconstraintteachermindaysperweekform.h"
00065 #include "modifyconstraintteachersmindaysperweekform.h"
00066 
00067 #include "modifyconstraintteachersactivitytagmaxhourscontinuouslyform.h"
00068 #include "modifyconstraintteacheractivitytagmaxhourscontinuouslyform.h"
00069 
00070 #include "modifyconstraintteachersactivitytagmaxhoursdailyform.h"
00071 #include "modifyconstraintteacheractivitytagmaxhoursdailyform.h"
00072 
00073 #include "modifyconstraintstudentssetnotavailabletimesform.h"
00074 #include "modifyconstraintstudentssetmaxgapsperweekform.h"
00075 #include "modifyconstraintstudentsmaxgapsperweekform.h"
00076 
00077 #include "modifyconstraintstudentssetmaxgapsperdayform.h"
00078 #include "modifyconstraintstudentsmaxgapsperdayform.h"
00079 
00080 #include "modifyconstraintstudentsearlymaxbeginningsatsecondhourform.h"
00081 #include "modifyconstraintstudentssetearlymaxbeginningsatsecondhourform.h"
00082 #include "modifyconstraintstudentssetmaxhoursdailyform.h"
00083 #include "modifyconstraintstudentsmaxhoursdailyform.h"
00084 #include "modifyconstraintstudentssetmaxhourscontinuouslyform.h"
00085 #include "modifyconstraintstudentsmaxhourscontinuouslyform.h"
00086 #include "modifyconstraintstudentssetminhoursdailyform.h"
00087 #include "modifyconstraintstudentsminhoursdailyform.h"
00088 
00089 #include "modifyconstraintstudentssetactivitytagmaxhourscontinuouslyform.h"
00090 #include "modifyconstraintstudentsactivitytagmaxhourscontinuouslyform.h"
00091 
00092 #include "modifyconstraintstudentssetactivitytagmaxhoursdailyform.h"
00093 #include "modifyconstraintstudentsactivitytagmaxhoursdailyform.h"
00094 
00095 #include "modifyconstraintteacherintervalmaxdaysperweekform.h"
00096 #include "modifyconstraintteachersintervalmaxdaysperweekform.h"
00097 
00098 #include "modifyconstraintstudentssetintervalmaxdaysperweekform.h"
00099 #include "modifyconstraintstudentsintervalmaxdaysperweekform.h"
00100 
00101 #include "modifyconstraintactivitiesoccupymaxtimeslotsfromselectionform.h"
00102 #include "modifyconstraintactivitiesmaxsimultaneousinselectedtimeslotsform.h"
00103 
00104 #include "lockunlock.h"
00105 
00106 #include "advancedfilterform.h"
00107 
00108 #include <QMessageBox>
00109 
00110 #include <QPlainTextEdit>
00111 
00112 #include <QRegExp>
00113 
00114 #include <QListWidget>
00115 #include <QScrollBar>
00116 #include <QAbstractItemView>
00117 
00118 #include <QSplitter>
00119 #include <QSettings>
00120 #include <QObject>
00121 #include <QMetaObject>
00122 
00123 #include <QBrush>
00124 #include <QPalette>
00125 
00126 #include <QtAlgorithms>
00127 
00128 extern const QString COMPANY;
00129 extern const QString PROGRAM;
00130 
00131 const int DESCRIPTION=0;
00132 const int DETDESCRIPTION=1;
00133 
00134 const int CONTAINS=0;
00135 const int DOESNOTCONTAIN=1;
00136 const int REGEXP=2;
00137 const int NOTREGEXP=3;
00138 
00139 AllTimeConstraintsForm::AllTimeConstraintsForm(QWidget* parent): QDialog(parent)
00140 {
00141        setupUi(this);
00142        
00143        currentConstraintTextEdit->setReadOnly(true);
00144        
00145        modifyConstraintPushButton->setDefault(true);
00146        
00147        constraintsListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
00148 
00149        connect(constraintsListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(constraintChanged()));
00150        connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
00151        connect(removeConstraintPushButton, SIGNAL(clicked()), this, SLOT(removeConstraint()));
00152        connect(modifyConstraintPushButton, SIGNAL(clicked()), this, SLOT(modifyConstraint()));
00153        connect(constraintsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(modifyConstraint()));
00154        connect(filterCheckBox, SIGNAL(toggled(bool)), this, SLOT(filter(bool)));
00155        connect(activatePushButton, SIGNAL(clicked()), this, SLOT(activateConstraint()));
00156        connect(deactivatePushButton, SIGNAL(clicked()), this, SLOT(deactivateConstraint()));
00157        connect(sortByCommentsPushButton, SIGNAL(clicked()), this, SLOT(sortConstraintsByComments()));
00158        connect(commentsPushButton, SIGNAL(clicked()), this, SLOT(constraintComments()));
00159 
00160        centerWidgetOnScreen(this);
00161        restoreFETDialogGeometry(this);
00162        //restore splitter state
00163        QSettings settings(COMPANY, PROGRAM);
00164        if(settings.contains(this->metaObject()->className()+QString("/splitter-state")))
00165               splitter->restoreState(settings.value(this->metaObject()->className()+QString("/splitter-state")).toByteArray());
00166               
00167        QString settingsName="AllTimeConstraintsAdvancedFilterForm";
00168        
00169        all=settings.value(settingsName+"/all-conditions", "true").toBool();
00170        
00171        descrDetDescr.clear();
00172        int n=settings.value(settingsName+"/number-of-descriptions", "1").toInt();
00173        for(int i=0; i<n; i++)
00174               descrDetDescr.append(settings.value(settingsName+"/description/"+CustomFETString::number(i+1), CustomFETString::number(DESCRIPTION)).toInt());
00175        
00176        contains.clear();
00177        n=settings.value(settingsName+"/number-of-contains", "1").toInt();
00178        for(int i=0; i<n; i++)
00179               contains.append(settings.value(settingsName+"/contains/"+CustomFETString::number(i+1), CustomFETString::number(CONTAINS)).toInt());
00180        
00181        text.clear();
00182        n=settings.value(settingsName+"/number-of-texts", "1").toInt();
00183        for(int i=0; i<n; i++)
00184               text.append(settings.value(settingsName+"/text/"+CustomFETString::number(i+1), QString("")).toString());
00185 
00186        caseSensitive=settings.value(settingsName+"/case-sensitive", "false").toBool();
00187        
00188        useFilter=false;
00189        
00190        assert(filterCheckBox->isChecked()==false);
00191        
00192        filterChanged();
00193 }
00194 
00195 AllTimeConstraintsForm::~AllTimeConstraintsForm()
00196 {
00197        saveFETDialogGeometry(this);
00198        //save splitter state
00199        QSettings settings(COMPANY, PROGRAM);
00200        settings.setValue(this->metaObject()->className()+QString("/splitter-state"), splitter->saveState());
00201 
00202        QString settingsName="AllTimeConstraintsAdvancedFilterForm";
00203        
00204        settings.setValue(settingsName+"/all-conditions", all);
00205        
00206        settings.setValue(settingsName+"/number-of-descriptions", descrDetDescr.count());
00207        settings.remove(settingsName+"/description");
00208        for(int i=0; i<descrDetDescr.count(); i++)
00209               settings.setValue(settingsName+"/description/"+CustomFETString::number(i+1), descrDetDescr.at(i));
00210        
00211        settings.setValue(settingsName+"/number-of-contains", contains.count());
00212        settings.remove(settingsName+"/contains");
00213        for(int i=0; i<contains.count(); i++)
00214               settings.setValue(settingsName+"/contains/"+CustomFETString::number(i+1), contains.at(i));
00215        
00216        settings.setValue(settingsName+"/number-of-texts", text.count());
00217        settings.remove(settingsName+"/text");
00218        for(int i=0; i<text.count(); i++)
00219               settings.setValue(settingsName+"/text/"+CustomFETString::number(i+1), text.at(i));
00220        
00221        settings.setValue(settingsName+"/case-sensitive", caseSensitive);
00222 }
00223 
00224 bool AllTimeConstraintsForm::filterOk(TimeConstraint* ctr)
00225 {
00226        if(!useFilter)
00227               return true;
00228 
00229        assert(descrDetDescr.count()==contains.count());
00230        assert(contains.count()==text.count());
00231        
00232        Qt::CaseSensitivity csens=Qt::CaseSensitive;
00233        if(!caseSensitive)
00234               csens=Qt::CaseInsensitive;
00235        
00236        QList<bool> okPartial;
00237        
00238        for(int i=0; i<descrDetDescr.count(); i++){
00239               QString s;
00240               if(descrDetDescr.at(i)==DESCRIPTION)
00241                      s=ctr->getDescription(gt.rules);
00242               else
00243                      s=ctr->getDetailedDescription(gt.rules);
00244                      
00245               QString t=text.at(i);
00246               if(contains.at(i)==CONTAINS){
00247                      okPartial.append(s.contains(t, csens));
00248               }
00249               else if(contains.at(i)==DOESNOTCONTAIN){
00250                      okPartial.append(!(s.contains(t, csens)));
00251               }
00252               else if(contains.at(i)==REGEXP){
00253                      QRegExp regExp(t);
00254                      regExp.setCaseSensitivity(csens);
00255                      okPartial.append(regExp.indexIn(s)>=0);
00256               }
00257               else if(contains.at(i)==NOTREGEXP){
00258                      QRegExp regExp(t);
00259                      regExp.setCaseSensitivity(csens);
00260                      okPartial.append(regExp.indexIn(s)<0);
00261               }
00262               else
00263                      assert(0);
00264        }
00265        
00266        if(all){
00267               bool ok=true;
00268               foreach(bool b, okPartial)
00269                      ok = ok && b;
00270                      
00271               return ok;
00272        }
00273        else{ //any
00274               bool ok=false;
00275               foreach(bool b, okPartial)
00276                      ok = ok || b;
00277                      
00278               return ok;
00279        }
00280 }
00281 
00282 void AllTimeConstraintsForm::filterChanged()
00283 {
00284        visibleTimeConstraintsList.clear();
00285        constraintsListWidget->clear();
00286        int n_active=0;
00287        foreach(TimeConstraint* ctr, gt.rules.timeConstraintsList)
00288               if(filterOk(ctr)){
00289                      visibleTimeConstraintsList.append(ctr);
00290                      constraintsListWidget->addItem(ctr->getDescription(gt.rules));
00291                      
00292                      if(USE_GUI_COLORS && !ctr->active)
00293                             constraintsListWidget->item(constraintsListWidget->count()-1)->setBackground(constraintsListWidget->palette().alternateBase());
00294                             
00295                      if(ctr->active)
00296                             n_active++;
00297               }
00298               
00299        if(constraintsListWidget->count()<=0)
00300               currentConstraintTextEdit->setPlainText("");
00301        else
00302               constraintsListWidget->setCurrentRow(0);
00303        
00304        constraintsTextLabel->setText(tr("%1 / %2 time constraints",
00305         "%1 represents the number of visible active time constraints, %2 represents the total number of visible time constraints")
00306         .arg(n_active).arg(visibleTimeConstraintsList.count()));
00307 }
00308 
00309 void AllTimeConstraintsForm::constraintChanged()
00310 {
00311        int index=constraintsListWidget->currentRow();
00312 
00313        if(index<0)
00314               return;
00315               
00316        assert(index<visibleTimeConstraintsList.count());
00317        TimeConstraint* ctr=visibleTimeConstraintsList.at(index);
00318        assert(ctr!=NULL);
00319        QString s=ctr->getDetailedDescription(gt.rules);
00320        currentConstraintTextEdit->setPlainText(s);
00321 }
00322 
00323 void AllTimeConstraintsForm::modifyConstraint()
00324 {
00325        int i=constraintsListWidget->currentRow();
00326        if(i<0){
00327               QMessageBox::information(this, tr("FET information"), tr("Invalid selected constraint"));
00328               return;
00329        }
00330        
00331        int valv=constraintsListWidget->verticalScrollBar()->value();
00332        int valh=constraintsListWidget->horizontalScrollBar()->value();
00333        
00334        assert(i<visibleTimeConstraintsList.count());
00335        TimeConstraint* ctr=visibleTimeConstraintsList.at(i);
00336        
00337        //1
00338        if(ctr->type==CONSTRAINT_BASIC_COMPULSORY_TIME){
00339               ModifyConstraintBasicCompulsoryTimeForm form(this, (ConstraintBasicCompulsoryTime*)ctr);
00340               setParentAndOtherThings(&form, this);
00341               form.exec();
00342        }
00343        //2
00344        else if(ctr->type==CONSTRAINT_TWO_ACTIVITIES_CONSECUTIVE){
00345               ModifyConstraintTwoActivitiesConsecutiveForm form(this, (ConstraintTwoActivitiesConsecutive*)ctr);
00346               setParentAndOtherThings(&form, this);
00347               form.exec();
00348        }
00349        //3
00350        else if(ctr->type==CONSTRAINT_TWO_ACTIVITIES_ORDERED){
00351               ModifyConstraintTwoActivitiesOrderedForm form(this, (ConstraintTwoActivitiesOrdered*)ctr);
00352               setParentAndOtherThings(&form, this);
00353               form.exec();
00354        }
00355        //4
00356        else if(ctr->type==CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS){
00357               ModifyConstraintActivityPreferredTimeSlotsForm form(this, (ConstraintActivityPreferredTimeSlots*)ctr);
00358               setParentAndOtherThings(&form, this);
00359               form.exec();
00360        }
00361        //5
00362        else if(ctr->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES){
00363               ModifyConstraintActivityPreferredStartingTimesForm form(this, (ConstraintActivityPreferredStartingTimes*)ctr);
00364               setParentAndOtherThings(&form, this);
00365               form.exec();
00366        }
00367        //6
00368        else if(ctr->type==CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS){
00369               ModifyConstraintActivitiesPreferredTimeSlotsForm form(this, (ConstraintActivitiesPreferredTimeSlots*)ctr);
00370               setParentAndOtherThings(&form, this);
00371               form.exec();
00372        }
00373        //7
00374        else if(ctr->type==CONSTRAINT_ACTIVITIES_PREFERRED_STARTING_TIMES){
00375               ModifyConstraintActivitiesPreferredStartingTimesForm form(this, (ConstraintActivitiesPreferredStartingTimes*)ctr);
00376               setParentAndOtherThings(&form, this);
00377               form.exec();
00378        }
00379        //8
00380        else if(ctr->type==CONSTRAINT_SUBACTIVITIES_PREFERRED_TIME_SLOTS){
00381               ModifyConstraintSubactivitiesPreferredTimeSlotsForm form(this, (ConstraintSubactivitiesPreferredTimeSlots*)ctr);
00382               setParentAndOtherThings(&form, this);
00383               form.exec();
00384        }
00385        //9
00386        else if(ctr->type==CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES){
00387               ModifyConstraintSubactivitiesPreferredStartingTimesForm form(this, (ConstraintSubactivitiesPreferredStartingTimes*)ctr);
00388               setParentAndOtherThings(&form, this);
00389               form.exec();
00390        }
00391        //10
00392        else if(ctr->type==CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME){
00393               ModifyConstraintActivitiesSameStartingTimeForm form(this, (ConstraintActivitiesSameStartingTime*)ctr);
00394               setParentAndOtherThings(&form, this);
00395               form.exec();
00396        }
00397        //11
00398        else if(ctr->type==CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR){
00399               ModifyConstraintActivitiesSameStartingHourForm form(this, (ConstraintActivitiesSameStartingHour*)ctr);
00400               setParentAndOtherThings(&form, this);
00401               form.exec();
00402        }
00403        //12
00404        else if(ctr->type==CONSTRAINT_ACTIVITIES_SAME_STARTING_DAY){
00405               ModifyConstraintActivitiesSameStartingDayForm form(this, (ConstraintActivitiesSameStartingDay*)ctr);
00406               setParentAndOtherThings(&form, this);
00407               form.exec();
00408        }
00409        //13
00410        else if(ctr->type==CONSTRAINT_TEACHER_NOT_AVAILABLE_TIMES){
00411               ModifyConstraintTeacherNotAvailableTimesForm form(this, (ConstraintTeacherNotAvailableTimes*)ctr);
00412               setParentAndOtherThings(&form, this);
00413               form.exec();
00414        }
00415        //14
00416        else if(ctr->type==CONSTRAINT_STUDENTS_SET_NOT_AVAILABLE_TIMES){
00417               ModifyConstraintStudentsSetNotAvailableTimesForm form(this, (ConstraintStudentsSetNotAvailableTimes*)ctr);
00418               setParentAndOtherThings(&form, this);
00419               form.exec();
00420        }
00421        //15
00422        else if(ctr->type==CONSTRAINT_BREAK_TIMES){
00423               ModifyConstraintBreakTimesForm form(this, (ConstraintBreakTimes*)ctr);
00424               setParentAndOtherThings(&form, this);
00425               form.exec();
00426        }
00427        //16
00428        else if(ctr->type==CONSTRAINT_TEACHER_MAX_DAYS_PER_WEEK){
00429               ModifyConstraintTeacherMaxDaysPerWeekForm form(this, (ConstraintTeacherMaxDaysPerWeek*)ctr);
00430               setParentAndOtherThings(&form, this);
00431               form.exec();
00432        }
00433        //17
00434        else if(ctr->type==CONSTRAINT_TEACHERS_MAX_HOURS_DAILY){
00435               ModifyConstraintTeachersMaxHoursDailyForm form(this, (ConstraintTeachersMaxHoursDaily*)ctr);
00436               setParentAndOtherThings(&form, this);
00437               form.exec();
00438        }
00439        //18
00440        else if(ctr->type==CONSTRAINT_TEACHER_MAX_HOURS_DAILY){
00441               ModifyConstraintTeacherMaxHoursDailyForm form(this, (ConstraintTeacherMaxHoursDaily*)ctr);
00442               setParentAndOtherThings(&form, this);
00443               form.exec();
00444        }
00445        //19
00446        else if(ctr->type==CONSTRAINT_TEACHERS_MAX_HOURS_CONTINUOUSLY){
00447               ModifyConstraintTeachersMaxHoursContinuouslyForm form(this, (ConstraintTeachersMaxHoursContinuously*)ctr);
00448               setParentAndOtherThings(&form, this);
00449               form.exec();
00450        }
00451        //20
00452        else if(ctr->type==CONSTRAINT_TEACHER_MAX_HOURS_CONTINUOUSLY){
00453               ModifyConstraintTeacherMaxHoursContinuouslyForm form(this, (ConstraintTeacherMaxHoursContinuously*)ctr);
00454               setParentAndOtherThings(&form, this);
00455               form.exec();
00456        }
00457        //21
00458        else if(ctr->type==CONSTRAINT_TEACHERS_MIN_HOURS_DAILY){
00459               ModifyConstraintTeachersMinHoursDailyForm form(this, (ConstraintTeachersMinHoursDaily*)ctr);
00460               setParentAndOtherThings(&form, this);
00461               form.exec();
00462        }
00463        //22
00464        else if(ctr->type==CONSTRAINT_TEACHER_MIN_HOURS_DAILY){
00465               ModifyConstraintTeacherMinHoursDailyForm form(this, (ConstraintTeacherMinHoursDaily*)ctr);
00466               setParentAndOtherThings(&form, this);
00467               form.exec();
00468        }
00469        //23
00470        else if(ctr->type==CONSTRAINT_TEACHERS_MAX_GAPS_PER_WEEK){
00471               ModifyConstraintTeachersMaxGapsPerWeekForm form(this, (ConstraintTeachersMaxGapsPerWeek*)ctr);
00472               setParentAndOtherThings(&form, this);
00473               form.exec();
00474        }
00475        //24
00476        else if(ctr->type==CONSTRAINT_TEACHER_MAX_GAPS_PER_WEEK){
00477               ModifyConstraintTeacherMaxGapsPerWeekForm form(this, (ConstraintTeacherMaxGapsPerWeek*)ctr);
00478               setParentAndOtherThings(&form, this);
00479               form.exec();
00480        }
00481        //25
00482        else if(ctr->type==CONSTRAINT_TEACHERS_MAX_GAPS_PER_DAY){
00483               ModifyConstraintTeachersMaxGapsPerDayForm form(this, (ConstraintTeachersMaxGapsPerDay*)ctr);
00484               setParentAndOtherThings(&form, this);
00485               form.exec();
00486        }
00487        //26
00488        else if(ctr->type==CONSTRAINT_TEACHER_MAX_GAPS_PER_DAY){
00489               ModifyConstraintTeacherMaxGapsPerDayForm form(this, (ConstraintTeacherMaxGapsPerDay*)ctr);
00490               setParentAndOtherThings(&form, this);
00491               form.exec();
00492        }
00493        //27
00494        else if(ctr->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME){
00495               ModifyConstraintActivityPreferredStartingTimeForm form(this, (ConstraintActivityPreferredStartingTime*)ctr);
00496               setParentAndOtherThings(&form, this);
00497               form.exec();
00498        }
00499        //28
00500        else if(ctr->type==CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_WEEK){
00501               ModifyConstraintStudentsSetMaxGapsPerWeekForm form(this, (ConstraintStudentsSetMaxGapsPerWeek*)ctr);
00502               setParentAndOtherThings(&form, this);
00503               form.exec();
00504        }
00505        //29
00506        else if(ctr->type==CONSTRAINT_STUDENTS_MAX_GAPS_PER_WEEK){
00507               ModifyConstraintStudentsMaxGapsPerWeekForm form(this, (ConstraintStudentsMaxGapsPerWeek*)ctr);
00508               setParentAndOtherThings(&form, this);
00509               form.exec();
00510        }
00511        //30
00512        else if(ctr->type==CONSTRAINT_STUDENTS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR){
00513               ModifyConstraintStudentsEarlyMaxBeginningsAtSecondHourForm form(this, (ConstraintStudentsEarlyMaxBeginningsAtSecondHour*)ctr);
00514               setParentAndOtherThings(&form, this);
00515               form.exec();
00516        }
00517        //31
00518        else if(ctr->type==CONSTRAINT_STUDENTS_SET_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR){
00519               ModifyConstraintStudentsSetEarlyMaxBeginningsAtSecondHourForm form(this, (ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour*)ctr);
00520               setParentAndOtherThings(&form, this);
00521               form.exec();
00522        }
00523        //32
00524        else if(ctr->type==CONSTRAINT_STUDENTS_SET_MAX_HOURS_DAILY){
00525               ModifyConstraintStudentsSetMaxHoursDailyForm form(this, (ConstraintStudentsSetMaxHoursDaily*)ctr);
00526               setParentAndOtherThings(&form, this);
00527               form.exec();
00528        }
00529        //33
00530        else if(ctr->type==CONSTRAINT_STUDENTS_MAX_HOURS_DAILY){
00531               ModifyConstraintStudentsMaxHoursDailyForm form(this, (ConstraintStudentsMaxHoursDaily*)ctr);
00532               setParentAndOtherThings(&form, this);
00533               form.exec();
00534        }
00535        //34
00536        else if(ctr->type==CONSTRAINT_STUDENTS_SET_MAX_HOURS_CONTINUOUSLY){
00537               ModifyConstraintStudentsSetMaxHoursContinuouslyForm form(this, (ConstraintStudentsSetMaxHoursContinuously*)ctr);
00538               setParentAndOtherThings(&form, this);
00539               form.exec();
00540        }
00541        //35
00542        else if(ctr->type==CONSTRAINT_STUDENTS_MAX_HOURS_CONTINUOUSLY){
00543               ModifyConstraintStudentsMaxHoursContinuouslyForm form(this, (ConstraintStudentsMaxHoursContinuously*)ctr);
00544               setParentAndOtherThings(&form, this);
00545               form.exec();
00546        }
00547        //36
00548        else if(ctr->type==CONSTRAINT_STUDENTS_SET_MIN_HOURS_DAILY){
00549               ModifyConstraintStudentsSetMinHoursDailyForm form(this, (ConstraintStudentsSetMinHoursDaily*)ctr);
00550               setParentAndOtherThings(&form, this);
00551               form.exec();
00552        }
00553        //37
00554        else if(ctr->type==CONSTRAINT_STUDENTS_MIN_HOURS_DAILY){
00555               ModifyConstraintStudentsMinHoursDailyForm form(this, (ConstraintStudentsMinHoursDaily*)ctr);
00556               setParentAndOtherThings(&form, this);
00557               form.exec();
00558        }
00559        //38
00560        else if(ctr->type==CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING){
00561               ModifyConstraintActivitiesNotOverlappingForm form(this, (ConstraintActivitiesNotOverlapping*)ctr);
00562               setParentAndOtherThings(&form, this);
00563               form.exec();
00564        }
00565        //39
00566        else if(ctr->type==CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES){
00567               ModifyConstraintMinDaysBetweenActivitiesForm form(this, (ConstraintMinDaysBetweenActivities*)ctr);
00568               setParentAndOtherThings(&form, this);
00569               form.exec();
00570        }
00571        //40
00572        else if(ctr->type==CONSTRAINT_MIN_GAPS_BETWEEN_ACTIVITIES){
00573               ModifyConstraintMinGapsBetweenActivitiesForm form(this, (ConstraintMinGapsBetweenActivities*)ctr);
00574               setParentAndOtherThings(&form, this);
00575               form.exec();
00576        }
00577        //41
00578        else if(ctr->type==CONSTRAINT_ACTIVITY_ENDS_STUDENTS_DAY){
00579               ModifyConstraintActivityEndsStudentsDayForm form(this, (ConstraintActivityEndsStudentsDay*)ctr);
00580               setParentAndOtherThings(&form, this);
00581               form.exec();
00582        }
00583        //42
00584        else if(ctr->type==CONSTRAINT_TEACHER_INTERVAL_MAX_DAYS_PER_WEEK){
00585               ModifyConstraintTeacherIntervalMaxDaysPerWeekForm form(this, (ConstraintTeacherIntervalMaxDaysPerWeek*)ctr);
00586               setParentAndOtherThings(&form, this);
00587               form.exec();
00588        }
00589        //43
00590        else if(ctr->type==CONSTRAINT_TEACHERS_INTERVAL_MAX_DAYS_PER_WEEK){
00591               ModifyConstraintTeachersIntervalMaxDaysPerWeekForm form(this, (ConstraintTeachersIntervalMaxDaysPerWeek*)ctr);
00592               setParentAndOtherThings(&form, this);
00593               form.exec();
00594        }
00595        //44
00596        else if(ctr->type==CONSTRAINT_STUDENTS_SET_INTERVAL_MAX_DAYS_PER_WEEK){
00597               ModifyConstraintStudentsSetIntervalMaxDaysPerWeekForm form(this, (ConstraintStudentsSetIntervalMaxDaysPerWeek*)ctr);
00598               setParentAndOtherThings(&form, this);
00599               form.exec();
00600        }
00601        //45
00602        else if(ctr->type==CONSTRAINT_STUDENTS_INTERVAL_MAX_DAYS_PER_WEEK){
00603               ModifyConstraintStudentsIntervalMaxDaysPerWeekForm form(this, (ConstraintStudentsIntervalMaxDaysPerWeek*)ctr);
00604               setParentAndOtherThings(&form, this);
00605               form.exec();
00606        }
00607        //46
00608        else if(ctr->type==CONSTRAINT_ACTIVITIES_END_STUDENTS_DAY){
00609               ModifyConstraintActivitiesEndStudentsDayForm form(this, (ConstraintActivitiesEndStudentsDay*)ctr);
00610               setParentAndOtherThings(&form, this);
00611               form.exec();
00612        }
00613        //47
00614        else if(ctr->type==CONSTRAINT_TWO_ACTIVITIES_GROUPED){
00615               ModifyConstraintTwoActivitiesGroupedForm form(this, (ConstraintTwoActivitiesGrouped*)ctr);
00616               setParentAndOtherThings(&form, this);
00617               form.exec();
00618        }
00619        //48
00620        else if(ctr->type==CONSTRAINT_TEACHERS_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY){
00621               ModifyConstraintTeachersActivityTagMaxHoursContinuouslyForm form(this, (ConstraintTeachersActivityTagMaxHoursContinuously*)ctr);
00622               setParentAndOtherThings(&form, this);
00623               form.exec();
00624        }
00625        //49
00626        else if(ctr->type==CONSTRAINT_TEACHER_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY){
00627               ModifyConstraintTeacherActivityTagMaxHoursContinuouslyForm form(this, (ConstraintTeacherActivityTagMaxHoursContinuously*)ctr);
00628               setParentAndOtherThings(&form, this);
00629               form.exec();
00630        }
00631        //50
00632        else if(ctr->type==CONSTRAINT_STUDENTS_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY){
00633               ModifyConstraintStudentsActivityTagMaxHoursContinuouslyForm form(this, (ConstraintStudentsActivityTagMaxHoursContinuously*)ctr);
00634               setParentAndOtherThings(&form, this);
00635               form.exec();
00636        }
00637        //51
00638        else if(ctr->type==CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY){
00639               ModifyConstraintStudentsSetActivityTagMaxHoursContinuouslyForm form(this, (ConstraintStudentsSetActivityTagMaxHoursContinuously*)ctr);
00640               setParentAndOtherThings(&form, this);
00641               form.exec();
00642        }
00643        //52
00644        else if(ctr->type==CONSTRAINT_TEACHERS_MAX_DAYS_PER_WEEK){
00645               ModifyConstraintTeachersMaxDaysPerWeekForm form(this, (ConstraintTeachersMaxDaysPerWeek*)ctr);
00646               setParentAndOtherThings(&form, this);
00647               form.exec();
00648        }
00649        //53
00650        else if(ctr->type==CONSTRAINT_THREE_ACTIVITIES_GROUPED){
00651               ModifyConstraintThreeActivitiesGroupedForm form(this, (ConstraintThreeActivitiesGrouped*)ctr);
00652               setParentAndOtherThings(&form, this);
00653               form.exec();
00654        }
00655        //54
00656        else if(ctr->type==CONSTRAINT_MAX_DAYS_BETWEEN_ACTIVITIES){
00657               ModifyConstraintMaxDaysBetweenActivitiesForm form(this, (ConstraintMaxDaysBetweenActivities*)ctr);
00658               setParentAndOtherThings(&form, this);
00659               form.exec();
00660        }
00661        //55
00662        else if(ctr->type==CONSTRAINT_TEACHERS_MIN_DAYS_PER_WEEK){
00663               ModifyConstraintTeachersMinDaysPerWeekForm form(this, (ConstraintTeachersMinDaysPerWeek*)ctr);
00664               setParentAndOtherThings(&form, this);
00665               form.exec();
00666        }
00667        //56
00668        else if(ctr->type==CONSTRAINT_TEACHER_MIN_DAYS_PER_WEEK){
00669               ModifyConstraintTeacherMinDaysPerWeekForm form(this, (ConstraintTeacherMinDaysPerWeek*)ctr);
00670               setParentAndOtherThings(&form, this);
00671               form.exec();
00672        }
00673        //57
00674        else if(ctr->type==CONSTRAINT_TEACHERS_ACTIVITY_TAG_MAX_HOURS_DAILY){
00675               ModifyConstraintTeachersActivityTagMaxHoursDailyForm form(this, (ConstraintTeachersActivityTagMaxHoursDaily*)ctr);
00676               setParentAndOtherThings(&form, this);
00677               form.exec();
00678        }
00679        //58
00680        else if(ctr->type==CONSTRAINT_TEACHER_ACTIVITY_TAG_MAX_HOURS_DAILY){
00681               ModifyConstraintTeacherActivityTagMaxHoursDailyForm form(this, (ConstraintTeacherActivityTagMaxHoursDaily*)ctr);
00682               setParentAndOtherThings(&form, this);
00683               form.exec();
00684        }
00685        //59
00686        else if(ctr->type==CONSTRAINT_STUDENTS_ACTIVITY_TAG_MAX_HOURS_DAILY){
00687               ModifyConstraintStudentsActivityTagMaxHoursDailyForm form(this, (ConstraintStudentsActivityTagMaxHoursDaily*)ctr);
00688               setParentAndOtherThings(&form, this);
00689               form.exec();
00690        }
00691        //60
00692        else if(ctr->type==CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MAX_HOURS_DAILY){
00693               ModifyConstraintStudentsSetActivityTagMaxHoursDailyForm form(this, (ConstraintStudentsSetActivityTagMaxHoursDaily*)ctr);
00694               setParentAndOtherThings(&form, this);
00695               form.exec();
00696        }
00697 
00698        //61
00699        else if(ctr->type==CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_DAY){
00700               ModifyConstraintStudentsSetMaxGapsPerDayForm form(this, (ConstraintStudentsSetMaxGapsPerDay*)ctr);
00701               setParentAndOtherThings(&form, this);
00702               form.exec();
00703        }
00704        //62
00705        else if(ctr->type==CONSTRAINT_STUDENTS_MAX_GAPS_PER_DAY){
00706               ModifyConstraintStudentsMaxGapsPerDayForm form(this, (ConstraintStudentsMaxGapsPerDay*)ctr);
00707               setParentAndOtherThings(&form, this);
00708               form.exec();
00709        }
00710        //63
00711        else if(ctr->type==CONSTRAINT_ACTIVITIES_OCCUPY_MAX_TIME_SLOTS_FROM_SELECTION){
00712               ModifyConstraintActivitiesOccupyMaxTimeSlotsFromSelectionForm form(this, (ConstraintActivitiesOccupyMaxTimeSlotsFromSelection*)ctr);
00713               setParentAndOtherThings(&form, this);
00714               form.exec();
00715        }
00716        //64
00717        else if(ctr->type==CONSTRAINT_ACTIVITIES_MAX_SIMULTANEOUS_IN_SELECTED_TIME_SLOTS){
00718               ModifyConstraintActivitiesMaxSimultaneousInSelectedTimeSlotsForm form(this, (ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots*)ctr);
00719               setParentAndOtherThings(&form, this);
00720               form.exec();
00721        }
00722 
00723        else{
00724               QMessageBox::critical(this, tr("FET critical"), tr("You have found a bug in FET. Please report it. This kind of constraint"
00725                " is not correctly recognized in all time constraints dialog. FET will skip this error, so that you can continue work."
00726                ". Probably the constraint can be modified from the specific constraint dialog."));
00727               //assert(0);
00728               //exit(1);
00729        }
00730        
00731        filterChanged();
00732        
00733        constraintsListWidget->verticalScrollBar()->setValue(valv);
00734        constraintsListWidget->horizontalScrollBar()->setValue(valh);
00735 
00736        if(i>=constraintsListWidget->count())
00737               i=constraintsListWidget->count()-1;
00738 
00739        if(i>=0)
00740               constraintsListWidget->setCurrentRow(i);
00741 }
00742 
00743 void AllTimeConstraintsForm::removeConstraint()
00744 {
00745        int i=constraintsListWidget->currentRow();
00746        if(i<0){
00747               QMessageBox::information(this, tr("FET information"), tr("Invalid selected constraint"));
00748               return;
00749        }
00750        
00751        assert(i<visibleTimeConstraintsList.count());
00752        TimeConstraint* ctr=visibleTimeConstraintsList.at(i);
00753 
00754        QString s;
00755        s=tr("Remove constraint?");
00756        s+="\n\n";
00757        s+=ctr->getDetailedDescription(gt.rules);
00758        
00759        bool t;
00760        
00761        bool recompute;
00762        
00763        QListWidgetItem* item;
00764        
00765        int lres=LongTextMessageBox::confirmation( this, tr("FET confirmation"),
00766               s, tr("Yes"), tr("No"), 0, 0, 1 );
00767               
00768        if(lres==0){
00769               //The user clicked the OK button or pressed Enter
00770               
00771               QMessageBox::StandardButton wr=QMessageBox::Yes;
00772               
00773               if(ctr->type==CONSTRAINT_BASIC_COMPULSORY_TIME){ //additional confirmation for this one
00774                      QString s=tr("Do you really want to remove the basic compulsory time constraint?");
00775                      s+=" ";
00776                      s+=tr("You cannot generate a timetable without this constraint.");
00777                      s+="\n\n";
00778                      s+=tr("Note: you can add again a constraint of this type from the menu Data -> Time constraints -> "
00779                             "Miscellaneous -> Basic compulsory time constraints.");
00780                             
00781                      wr=QMessageBox::warning(this, tr("FET warning"), s,
00782                             QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
00783               }
00784               
00785               if(wr==QMessageBox::Yes){
00786                      if(ctr->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME){
00787                             recompute=true;
00788                      }
00789                      else{
00790                             recompute=false;
00791                      }
00792               
00793                      t=gt.rules.removeTimeConstraint(ctr);
00794                      assert(t);
00795                      visibleTimeConstraintsList.removeAt(i);
00796                      constraintsListWidget->setCurrentRow(-1);
00797                      item=constraintsListWidget->takeItem(i);
00798                      delete item;
00799               
00800                      constraintsTextLabel->setText(tr("%1 Time Constraints", "%1 represents the number of constraints").arg(visibleTimeConstraintsList.count()));
00801               
00802                      if(recompute){
00803                             LockUnlock::computeLockedUnlockedActivitiesOnlyTime();
00804                             LockUnlock::increaseCommunicationSpinBox();
00805                      }
00806               }
00807        }
00808        //else if(lres==1){
00809               //The user clicked the Cancel button or pressed Escape
00810        //}
00811 
00812        if(i>=constraintsListWidget->count())
00813               i=constraintsListWidget->count()-1;
00814        if(i>=0)
00815               constraintsListWidget->setCurrentRow(i);
00816        else
00817               currentConstraintTextEdit->setPlainText(QString(""));
00818 }
00819 
00820 void AllTimeConstraintsForm::filter(bool active)
00821 {
00822        if(!active){
00823               assert(useFilter==true);
00824               useFilter=false;
00825               
00826               filterChanged();
00827        
00828               return;
00829        }
00830        
00831        assert(active);
00832        
00833        filterForm=new AdvancedFilterForm(this, all, descrDetDescr, contains, text, caseSensitive, "AllTimeConstraintsAdvancedFilterForm");
00834 
00835        int t=filterForm->exec();
00836        
00837        if(t==QDialog::Accepted){
00838               assert(useFilter==false);
00839               useFilter=true;
00840        
00841               if(filterForm->allRadio->isChecked())
00842                      all=true;
00843               else if(filterForm->anyRadio->isChecked())
00844                      all=false;
00845               else
00846                      assert(0);
00847                      
00848               caseSensitive=filterForm->caseSensitiveCheckBox->isChecked();
00849                      
00850               descrDetDescr.clear();
00851               contains.clear();
00852               text.clear();
00853                      
00854               assert(filterForm->descrDetDescrComboBoxList.count()==filterForm->contNContReNReComboBoxList.count());
00855               assert(filterForm->descrDetDescrComboBoxList.count()==filterForm->textLineEditList.count());
00856               for(int i=0; i<filterForm->rows; i++){
00857                      QComboBox* cb1=filterForm->descrDetDescrComboBoxList.at(i);
00858                      QComboBox* cb2=filterForm->contNContReNReComboBoxList.at(i);
00859                      QLineEdit* tl=filterForm->textLineEditList.at(i);
00860                      
00861                      descrDetDescr.append(cb1->currentIndex());
00862                      contains.append(cb2->currentIndex());
00863                      text.append(tl->text());
00864               }
00865               
00866               filterChanged();
00867        }
00868        else{
00869               assert(useFilter==false);
00870               useFilter=false;
00871        
00872               disconnect(filterCheckBox, SIGNAL(toggled(bool)), this, SLOT(filter(bool)));
00873               filterCheckBox->setChecked(false);
00874               connect(filterCheckBox, SIGNAL(toggled(bool)), this, SLOT(filter(bool)));
00875        }
00876        
00877        delete filterForm;
00878 }
00879 
00880 void AllTimeConstraintsForm::activateConstraint()
00881 {
00882        int i=constraintsListWidget->currentRow();
00883        if(i<0){
00884               QMessageBox::information(this, tr("FET information"), tr("Invalid selected constraint"));
00885               return;
00886        }
00887        
00888        assert(i<visibleTimeConstraintsList.count());
00889        TimeConstraint* ctr=visibleTimeConstraintsList.at(i);
00890        
00891        if(!ctr->active){
00892               ctr->active=true;
00893               
00894               gt.rules.internalStructureComputed=false;
00895               setRulesModifiedAndOtherThings(&gt.rules);
00896 
00897               constraintsListWidget->currentItem()->setText(ctr->getDescription(gt.rules));
00898               if(USE_GUI_COLORS)
00899                      constraintsListWidget->currentItem()->setBackground(constraintsListWidget->palette().base());
00900               constraintChanged();
00901               
00902               if(ctr->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME){
00903                      LockUnlock::computeLockedUnlockedActivitiesOnlyTime();
00904                      LockUnlock::increaseCommunicationSpinBox();
00905               }
00906        }
00907        
00908        int n_active=0;
00909        foreach(TimeConstraint* ctr, gt.rules.timeConstraintsList)
00910               if(filterOk(ctr)){
00911                      if(ctr->active)
00912                             n_active++;
00913               }
00914        
00915        constraintsTextLabel->setText(tr("%1 / %2 time constraints",
00916         "%1 represents the number of visible active time constraints, %2 represents the total number of visible time constraints")
00917         .arg(n_active).arg(visibleTimeConstraintsList.count()));
00918 }
00919 
00920 void AllTimeConstraintsForm::deactivateConstraint()
00921 {
00922        int i=constraintsListWidget->currentRow();
00923        if(i<0){
00924               QMessageBox::information(this, tr("FET information"), tr("Invalid selected constraint"));
00925               return;
00926        }
00927        
00928        assert(i<visibleTimeConstraintsList.count());
00929        TimeConstraint* ctr=visibleTimeConstraintsList.at(i);
00930        
00931        if(ctr->active){
00932               if(ctr->type==CONSTRAINT_BASIC_COMPULSORY_TIME){
00933                      QMessageBox::warning(this, tr("FET warning"), tr("You are not allowed to deactivate the basic compulsory time constraints"));
00934                      return;
00935               }
00936        
00937               ctr->active=false;
00938               
00939               gt.rules.internalStructureComputed=false;
00940               setRulesModifiedAndOtherThings(&gt.rules);
00941 
00942               constraintsListWidget->currentItem()->setText(ctr->getDescription(gt.rules));
00943               if(USE_GUI_COLORS)
00944                      constraintsListWidget->currentItem()->setBackground(constraintsListWidget->palette().alternateBase());
00945               constraintChanged();
00946               
00947               if(ctr->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME){
00948                      LockUnlock::computeLockedUnlockedActivitiesOnlyTime();
00949                      LockUnlock::increaseCommunicationSpinBox();
00950               }
00951        }
00952 
00953        int n_active=0;
00954        foreach(TimeConstraint* ctr, gt.rules.timeConstraintsList)
00955               if(filterOk(ctr)){
00956                      if(ctr->active)
00957                             n_active++;
00958               }
00959        
00960        constraintsTextLabel->setText(tr("%1 / %2 time constraints",
00961         "%1 represents the number of visible active time constraints, %2 represents the total number of visible time constraints")
00962         .arg(n_active).arg(visibleTimeConstraintsList.count()));
00963 }
00964 
00965 static int timeConstraintsAscendingByComments(const TimeConstraint* t1, const TimeConstraint* t2)
00966 {
00967        return t1->comments < t2->comments;
00968 }
00969 
00970 void AllTimeConstraintsForm::sortConstraintsByComments()
00971 {
00972        QMessageBox::StandardButton t=QMessageBox::question(this, tr("Sort constraints?"),
00973         tr("This will sort the time constraints list ascending according to their comments. You can obtain "
00974         "a custom ordering by adding comments to some or all time constraints, for example 'rank #1 ... other comments', "
00975         "'rank #2 ... other different comments'.")
00976         +" "+tr("Are you sure you want to continue?"),
00977         QMessageBox::Yes|QMessageBox::Cancel);
00978        
00979        if(t==QMessageBox::Cancel)
00980               return;
00981        
00982        qStableSort(gt.rules.timeConstraintsList.begin(), gt.rules.timeConstraintsList.end(), timeConstraintsAscendingByComments);
00983 
00984        gt.rules.internalStructureComputed=false;
00985        setRulesModifiedAndOtherThings(&gt.rules);
00986        
00987        filterChanged();
00988 }
00989 
00990 void AllTimeConstraintsForm::constraintComments()
00991 {
00992        int i=constraintsListWidget->currentRow();
00993        if(i<0){
00994               QMessageBox::information(this, tr("FET information"), tr("Invalid selected constraint"));
00995               return;
00996        }
00997        
00998        assert(i<visibleTimeConstraintsList.count());
00999        TimeConstraint* ctr=visibleTimeConstraintsList.at(i);
01000 
01001        QDialog getCommentsDialog(this);
01002        
01003        getCommentsDialog.setWindowTitle(tr("Constraint comments"));
01004        
01005        QPushButton* okPB=new QPushButton(tr("OK"));
01006        okPB->setDefault(true);
01007        QPushButton* cancelPB=new QPushButton(tr("Cancel"));
01008        
01009        connect(okPB, SIGNAL(clicked()), &getCommentsDialog, SLOT(accept()));
01010        connect(cancelPB, SIGNAL(clicked()), &getCommentsDialog, SLOT(reject()));
01011 
01012        QHBoxLayout* hl=new QHBoxLayout();
01013        hl->addStretch();
01014        hl->addWidget(okPB);
01015        hl->addWidget(cancelPB);
01016        
01017        QVBoxLayout* vl=new QVBoxLayout();
01018        
01019        QPlainTextEdit* commentsPT=new QPlainTextEdit();
01020        commentsPT->setPlainText(ctr->comments);
01021        commentsPT->selectAll();
01022        commentsPT->setFocus();
01023        
01024        vl->addWidget(commentsPT);
01025        vl->addLayout(hl);
01026        
01027        getCommentsDialog.setLayout(vl);
01028        
01029        const QString settingsName=QString("TimeConstraintCommentsDialog");
01030        
01031        getCommentsDialog.resize(500, 320);
01032        centerWidgetOnScreen(&getCommentsDialog);
01033        restoreFETDialogGeometry(&getCommentsDialog, settingsName);
01034        
01035        int t=getCommentsDialog.exec();
01036        saveFETDialogGeometry(&getCommentsDialog, settingsName);
01037        
01038        if(t==QDialog::Accepted){
01039               ctr->comments=commentsPT->toPlainText();
01040        
01041               gt.rules.internalStructureComputed=false;
01042               setRulesModifiedAndOtherThings(&gt.rules);
01043 
01044               constraintsListWidget->currentItem()->setText(ctr->getDescription(gt.rules));
01045               constraintChanged();
01046        }
01047 }