Back to index

fet  5.18.0
advancedlockunlockform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                                 FET
00003                           -------------------
00004    copyright            : (C) by Lalescu Liviu
00005     email                : Please see http://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address)
00006  ***************************************************************************
00007                           advancedlockunlockform.cpp  -  description
00008                              -------------------
00009     begin                : Dec 2008
00010     copyright            : (C) by Liviu Lalescu (http://lalescu.ro/liviu/) and Volker Dirr (http://www.timetabling.de/)
00011  ***************************************************************************
00012  *                                                                         *
00013  *   FET program is free software; you can redistribute it and/or modify  *
00014  *   it under the terms of the GNU General Public License as published by  *
00015  *   the Free Software Foundation; either version 2 of the License, or     *
00016  *   (at your option) any later version.                                   *
00017  *                                                                         *
00018  ***************************************************************************/
00019 
00020 #include <QtGui>
00021 
00022 #include <QMessageBox>
00023 
00024 #include "lockunlock.h"
00025 #include "advancedlockunlockform.h"
00026 #include "fetmainform.h"
00027 #include "timetable_defs.h"
00028 #include "timetable.h"
00029 #include "solution.h"
00030 
00031 #include "fet.h"
00032 
00033 extern bool students_schedule_ready;
00034 extern bool teachers_schedule_ready;
00035 extern bool rooms_schedule_ready;
00036 
00037 extern Solution best_solution;
00038 
00039 extern Timetable gt;
00040 
00041 extern QSet<int> idsOfLockedTime;
00042 extern QSet<int> idsOfLockedSpace;
00043 extern QSet<int> idsOfPermanentlyLockedTime;
00044 extern QSet<int> idsOfPermanentlyLockedSpace;
00045 
00046 const int MIN_WIDTH=400;
00047 const int MIN_HEIGHT=200;
00048 
00049 const QString lockDaySettingsString=QString("AdvancedLockUnlockFormLockDay");
00050 const QString unlockDaySettingsString=QString("AdvancedLockUnlockFormUnlockDay");
00051 const QString lockAllSettingsString=QString("AdvancedLockUnlockFormLockAll");
00052 const QString unlockAllSettingsString=QString("AdvancedLockUnlockFormUnlockAll");
00053 const QString lockEndStudentsDaySettingsString=QString("AdvancedLockUnlockFormLockEndStudentsDay");
00054 const QString unlockEndStudentsDaySettingsString=QString("AdvancedLockUnlockFormUnlockEndStudentsDay");
00055 
00056 const QString lockDayConfirmationSettingsString=QString("AdvancedLockUnlockFormLockDayConfirmation");
00057 const QString unlockDayConfirmationSettingsString=QString("AdvancedLockUnlockFormUnlockDayConfirmation");
00058 const QString lockAllConfirmationSettingsString=QString("AdvancedLockUnlockFormLockAllConfirmation");
00059 const QString unlockAllConfirmationSettingsString=QString("AdvancedLockUnlockFormUnlockAllConfirmation");
00060 const QString lockEndStudentsDayConfirmationSettingsString=QString("AdvancedLockUnlockFormLockEndStudentsDayConfirmation");
00061 const QString unlockEndStudentsDayConfirmationSettingsString=QString("AdvancedLockUnlockFormUnlockEndStudentsDayConfirmation");
00062 
00063 void AdvancedLockUnlockForm::lockDay(QWidget* parent)
00064 {
00065        if(!students_schedule_ready || !teachers_schedule_ready || !rooms_schedule_ready){
00066               return;
00067        }
00068        
00069        QStringList days;
00070        for(int j=0; j<gt.rules.nDaysPerWeek; j++)
00071               days<<gt.rules.daysOfTheWeek[j];
00072        assert(days.size()!=0);
00073 
00074        //New Dialog
00075        QDialog taDialog(parent);
00076        taDialog.setWindowTitle(tr("FET - Lock activities of a day"));
00077 
00078        QVBoxLayout* taMainLayout=new QVBoxLayout(&taDialog);
00079 
00080        QLabel* taLabel=new QLabel();
00081        taLabel->setWordWrap(true);
00082        taLabel->setText(tr("All activities of the selected day will be locked")+"\n\n"+tr("Please select the day to lock:"));
00083        taLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00084 
00085        QComboBox* taLW=new QComboBox();
00086        
00087        QSize tmp=taLW->minimumSizeHint();
00088        Q_UNUSED(tmp);
00089        
00090        taLW->addItems(days);
00091        taLW->setCurrentIndex(0);
00092 
00093        QPushButton* tapb1=new QPushButton(tr("Cancel"));
00094        QPushButton* tapb2=new QPushButton(tr("OK"));
00095        
00096        QHBoxLayout* buttons=new QHBoxLayout();
00097        buttons->addStretch();
00098        buttons->addWidget(tapb1);
00099        buttons->addWidget(tapb2);
00100        
00102        QGroupBox* selectorsGroupBox=new QGroupBox();
00103        selectorsGroupBox->setTitle("Lock");
00104        
00105        QHBoxLayout* groupLayout=new QHBoxLayout(selectorsGroupBox);
00106        
00107        QCheckBox* timeCheckBox=new QCheckBox();
00108        timeCheckBox->setChecked(true);
00109        timeCheckBox->setText("Time");
00110        QCheckBox* spaceCheckBox=new QCheckBox();
00111        spaceCheckBox->setChecked(true);
00112        spaceCheckBox->setText("Space");
00113 
00114        groupLayout->addWidget(timeCheckBox);
00115        groupLayout->addWidget(spaceCheckBox);
00116        groupLayout->addStretch();
00118        
00119        taMainLayout->addWidget(taLabel);
00120        taMainLayout->addWidget(taLW);
00121        taMainLayout->addStretch();
00122        taMainLayout->addWidget(selectorsGroupBox);
00123        taMainLayout->addStretch();
00124        taMainLayout->addLayout(buttons);
00125 
00126        QObject::connect(tapb2, SIGNAL(clicked()), &taDialog, SLOT(accept()));
00127        QObject::connect(tapb1, SIGNAL(clicked()), &taDialog, SLOT(reject()));
00128 
00129        tapb2->setDefault(true);
00130        tapb2->setFocus();
00131        
00132        int w=taDialog.sizeHint().width();
00133        int h=taDialog.sizeHint().height();
00134        if(w<MIN_WIDTH)
00135               w=MIN_WIDTH;
00136        if(h<MIN_HEIGHT)
00137               h=MIN_HEIGHT;
00138        taDialog.resize(w,h);
00139        centerWidgetOnScreen(&taDialog);
00140        restoreFETDialogGeometry(&taDialog, lockDaySettingsString);
00141        bool ok=taDialog.exec();
00142        saveFETDialogGeometry(&taDialog, lockDaySettingsString);
00143        if(!ok)
00144               return;
00145               
00146        bool lockTime=timeCheckBox->isChecked();
00147        bool lockSpace=spaceCheckBox->isChecked();
00148 
00149        int selectedDayInt=taLW->currentIndex();
00150        assert(selectedDayInt>=0 && selectedDayInt<gt.rules.nDaysPerWeek);
00151 
00152        QString addedTimeConstraintsString;
00153        QString notAddedTimeConstraintsString;
00154        
00155        QList<ConstraintActivityPreferredStartingTime*> addedTimeConstraints;
00156        QList<ConstraintActivityPreferredStartingTime*> notAddedTimeConstraints;
00157        
00158        QString addedSpaceConstraintsString;
00159        QString notAddedSpaceConstraintsString;
00160        
00161        QList<ConstraintActivityPreferredRoom*> addedSpaceConstraints;
00162        QList<ConstraintActivityPreferredRoom*> notAddedSpaceConstraints;
00163        
00164        int addedTime=0, notAddedTime=0;
00165        int addedSpace=0, notAddedSpace=0;
00166 
00167        for(int i=0; i<gt.rules.nInternalActivities; i++){
00168               if(best_solution.times[i]!=UNALLOCATED_TIME){
00169                      assert(best_solution.times[i]>=0 && best_solution.times[i]<gt.rules.nHoursPerWeek);
00170                      int d=best_solution.times[i]%gt.rules.nDaysPerWeek;
00171                      int h=best_solution.times[i]/gt.rules.nDaysPerWeek;
00172                      
00173                      ConstraintActivityPreferredStartingTime* newTimeCtr=NULL;
00174                      
00175                      ConstraintActivityPreferredRoom* newSpaceCtr=NULL;
00176                      
00177                      if(d==selectedDayInt && lockTime){
00178                             newTimeCtr=new ConstraintActivityPreferredStartingTime(100.0, gt.rules.internalActivitiesList[i].id, d, h, false);
00179                      }
00180                      
00181                      if(d==selectedDayInt && lockSpace){
00182                             if(best_solution.rooms[i]!=UNALLOCATED_SPACE && best_solution.rooms[i]!=UNSPECIFIED_ROOM){
00183                                    newSpaceCtr=new ConstraintActivityPreferredRoom(100.0, gt.rules.internalActivitiesList[i].id, gt.rules.internalRoomsList[best_solution.rooms[i]]->name, false);
00184                             }
00185                      }
00186                      
00187                      if(newTimeCtr!=NULL){
00188                             bool add=true;
00189                             foreach(TimeConstraint* tc, gt.rules.timeConstraintsList){
00190                                    if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME){
00191                                           if((*((ConstraintActivityPreferredStartingTime*)tc)) == (*newTimeCtr)){
00192                                                  add=false;
00193                                                  break;
00194                                           }
00195                                    }
00196                             }
00197                             
00198                             if(add){
00199                                    addedTimeConstraintsString+=newTimeCtr->getDetailedDescription(gt.rules)+"\n";
00200                                    addedTimeConstraints.append(newTimeCtr);
00201                                    
00202                                    addedTime++;
00203                             }
00204                             else{
00205                                    notAddedTimeConstraintsString+=newTimeCtr->getDetailedDescription(gt.rules)+"\n";
00206                                    notAddedTimeConstraints.append(newTimeCtr);
00207                                    
00208                                    notAddedTime++;
00209                             }
00210                      }
00211 
00212                      if(newSpaceCtr!=NULL){
00213                             bool add=true;
00214                             foreach(SpaceConstraint* tc, gt.rules.spaceConstraintsList){
00215                                    if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_ROOM){
00216                                           if((*((ConstraintActivityPreferredRoom*)tc)) == (*newSpaceCtr)){
00217                                                  add=false;
00218                                                  break;
00219                                           }
00220                                    }
00221                             }
00222                             
00223                             if(add){
00224                                    addedSpaceConstraintsString+=newSpaceCtr->getDetailedDescription(gt.rules)+"\n";
00225                                    addedSpaceConstraints.append(newSpaceCtr);
00226                                    
00227                                    addedSpace++;
00228                             }
00229                             else{
00230                                    notAddedSpaceConstraintsString+=newSpaceCtr->getDetailedDescription(gt.rules)+"\n";
00231                                    notAddedSpaceConstraints.append(newSpaceCtr);
00232                                    
00233                                    notAddedSpace++;
00234                             }
00235                      }
00236               }
00237        }
00238        
00240        //last confirmation dialog
00241        QDialog lastConfirmationDialog(&taDialog);
00242        lastConfirmationDialog.setWindowTitle(tr("Last confirmation needed"));
00243 
00244        QVBoxLayout* lastMainLayout=new QVBoxLayout(&lastConfirmationDialog);
00245 
00246        QPushButton* lastpb1=new QPushButton(tr("Cancel"));
00247        QPushButton* lastpb2=new QPushButton(tr("OK"));
00248        QHBoxLayout* lastButtons=new QHBoxLayout();
00249        lastButtons->addStretch();
00250        lastButtons->addWidget(lastpb1);
00251        lastButtons->addWidget(lastpb2);
00252        
00254        QVBoxLayout* left=new QVBoxLayout();
00255        QVBoxLayout* right=new QVBoxLayout();
00256        QHBoxLayout* all=new QHBoxLayout();
00257        all->addLayout(left);
00258        all->addLayout(right);
00259        
00260        QPlainTextEdit* addTim=new QPlainTextEdit();
00261        addTim->setReadOnly(true);
00262        addTim->setPlainText(addedTimeConstraintsString);
00263        QLabel* labAddTim=new QLabel(tr("These time constraints will be added"));
00264        labAddTim->setWordWrap(true);
00265        labAddTim->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00266        left->addWidget(labAddTim);
00267        left->addWidget(addTim);
00268 
00269        QPlainTextEdit* notAddTim=new QPlainTextEdit();
00270        notAddTim->setReadOnly(true);
00271        notAddTim->setPlainText(notAddedTimeConstraintsString);
00272        QLabel* labNotAddTim=new QLabel(tr("These time constraints will NOT be added"));
00273        labNotAddTim->setWordWrap(true);
00274        labNotAddTim->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00275        left->addWidget(labNotAddTim);
00276        left->addWidget(notAddTim);
00277 
00278        QPlainTextEdit* addSpa=new QPlainTextEdit();
00279        addSpa->setReadOnly(true);
00280        addSpa->setPlainText(addedSpaceConstraintsString);
00281        QLabel* labAddSpa=new QLabel(tr("These space constraints will be added"));
00282        labAddSpa->setWordWrap(true);
00283        labAddSpa->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00284        right->addWidget(labAddSpa);
00285        right->addWidget(addSpa);
00286        
00287        QPlainTextEdit* notAddSpa=new QPlainTextEdit();
00288        notAddSpa->setReadOnly(true);
00289        notAddSpa->setPlainText(notAddedSpaceConstraintsString);
00290        QLabel* labNotAddSpa=new QLabel(tr("These space constraints will NOT be added"));
00291        labNotAddSpa->setWordWrap(true);
00292        labNotAddSpa->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00293        right->addWidget(labNotAddSpa);
00294        right->addWidget(notAddSpa);
00296        
00298        lastMainLayout->addLayout(all);
00299        //lastMainLayout->addStretch();
00300        lastMainLayout->addLayout(lastButtons);
00301 
00302        QObject::connect(lastpb2, SIGNAL(clicked()), &lastConfirmationDialog, SLOT(accept()));
00303        QObject::connect(lastpb1, SIGNAL(clicked()), &lastConfirmationDialog, SLOT(reject()));
00304 
00305        lastpb2->setDefault(true);
00306        lastpb2->setFocus();
00307        
00308        int lw=lastConfirmationDialog.sizeHint().width();
00309        int lh=lastConfirmationDialog.sizeHint().height();
00310        lastConfirmationDialog.resize(lw,lh);
00311        centerWidgetOnScreen(&lastConfirmationDialog);
00312        restoreFETDialogGeometry(&lastConfirmationDialog, lockDayConfirmationSettingsString);
00313        ok=lastConfirmationDialog.exec();
00314        saveFETDialogGeometry(&lastConfirmationDialog, lockDayConfirmationSettingsString);
00315        if(!ok)
00316               return;
00318        
00319        foreach(TimeConstraint* tc, addedTimeConstraints){
00320               bool t=gt.rules.addTimeConstraint(tc);
00321               assert(t);
00322        }
00323        addedTimeConstraints.clear();
00324        foreach(TimeConstraint* tc, notAddedTimeConstraints){
00325               delete tc;
00326        }
00327        notAddedTimeConstraints.clear();
00328        
00329        foreach(SpaceConstraint* sc, addedSpaceConstraints){
00330               bool t=gt.rules.addSpaceConstraint(sc);
00331               assert(t);
00332        }
00333        addedSpaceConstraints.clear();
00334        foreach(SpaceConstraint* sc, notAddedSpaceConstraints){
00335               delete sc;
00336        }
00337        notAddedSpaceConstraints.clear();
00338        
00339        QMessageBox::information(&lastConfirmationDialog, tr("FET information"), tr("There were added %1 locking time constraints and"
00340               " %2 locking space constraints. There were not added %3 locking time constraints and %4 locking space constraints, because"
00341               " these activities were already locked").arg(addedTime).arg(addedSpace).arg(notAddedTime).arg(notAddedSpace));
00342        
00343        LockUnlock::computeLockedUnlockedActivitiesTimeSpace();
00344        LockUnlock::increaseCommunicationSpinBox();
00345 }
00346 
00347 void AdvancedLockUnlockForm::unlockDay(QWidget* parent)
00348 {
00349        if(!students_schedule_ready || !teachers_schedule_ready || !rooms_schedule_ready){
00350               return;
00351        }
00352        
00353        QStringList days;
00354        for(int j=0; j<gt.rules.nDaysPerWeek; j++)
00355               days<<gt.rules.daysOfTheWeek[j];
00356        assert(days.size()!=0);
00357 
00358        //New Dialog
00359        QDialog taDialog(parent);
00360        taDialog.setWindowTitle(tr("FET - Unlock activities of a day"));
00361 
00362        QVBoxLayout* taMainLayout=new QVBoxLayout(&taDialog);
00363 
00364        QLabel* taLabel=new QLabel();
00365        taLabel->setWordWrap(true);
00366        taLabel->setText(tr("All activities of the selected day will be unlocked (those which are not permanently locked)")+"\n\n"+tr("Please select the day to unlock:"));
00367        taLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00368 
00369        QComboBox* taLW=new QComboBox();
00370        
00371        QSize tmp2=taLW->minimumSizeHint();
00372        Q_UNUSED(tmp2);
00373        
00374        taLW->addItems(days);
00375        taLW->setCurrentIndex(0);
00376 
00377        QPushButton* tapb1=new QPushButton(tr("Cancel"));
00378        QPushButton* tapb2=new QPushButton(tr("OK"));
00379        
00380        QHBoxLayout* buttons=new QHBoxLayout();
00381        buttons->addStretch();
00382        buttons->addWidget(tapb1);
00383        buttons->addWidget(tapb2);
00384        
00386        QGroupBox* selectorsGroupBox=new QGroupBox();
00387        selectorsGroupBox->setTitle("Unlock");
00388        
00389        QHBoxLayout* groupLayout=new QHBoxLayout(selectorsGroupBox);
00390        
00391        QCheckBox* timeCheckBox=new QCheckBox();
00392        timeCheckBox->setChecked(true);
00393        timeCheckBox->setText("Time");
00394        QCheckBox* spaceCheckBox=new QCheckBox();
00395        spaceCheckBox->setChecked(true);
00396        spaceCheckBox->setText("Space");
00397 
00398        groupLayout->addWidget(timeCheckBox);
00399        groupLayout->addWidget(spaceCheckBox);
00400        groupLayout->addStretch();
00402        
00403        taMainLayout->addWidget(taLabel);
00404        taMainLayout->addWidget(taLW);
00405        taMainLayout->addStretch();
00406        taMainLayout->addWidget(selectorsGroupBox);
00407        taMainLayout->addStretch();
00408        taMainLayout->addLayout(buttons);
00409 
00410        QObject::connect(tapb2, SIGNAL(clicked()), &taDialog, SLOT(accept()));
00411        QObject::connect(tapb1, SIGNAL(clicked()), &taDialog, SLOT(reject()));
00412 
00413        tapb2->setDefault(true);
00414        tapb2->setFocus();
00415        
00416        int w=taDialog.sizeHint().width();
00417        int h=taDialog.sizeHint().height();
00418        if(w<MIN_WIDTH)
00419               w=MIN_WIDTH;
00420        if(h<MIN_HEIGHT)
00421               h=MIN_HEIGHT;
00422        taDialog.resize(w,h);
00423        centerWidgetOnScreen(&taDialog);
00424        restoreFETDialogGeometry(&taDialog, unlockDaySettingsString);
00425        bool ok=taDialog.exec();
00426        saveFETDialogGeometry(&taDialog, unlockDaySettingsString);
00427        if(!ok)
00428               return;
00429               
00430        bool unlockTime=timeCheckBox->isChecked();
00431        bool unlockSpace=spaceCheckBox->isChecked();
00432 
00433        int selectedDayInt=taLW->currentIndex();
00434        assert(selectedDayInt>=0 && selectedDayInt<gt.rules.nDaysPerWeek);
00435 
00436        int removedTime=0, notRemovedTime=0;
00437        int removedSpace=0, notRemovedSpace=0;
00438        
00439        QSet<int> lockedActivitiesIds;
00440 
00441        for(int i=0; i<gt.rules.nInternalActivities; i++){
00442               if(best_solution.times[i]!=UNALLOCATED_TIME){
00443                      assert(best_solution.times[i]>=0 && best_solution.times[i]<gt.rules.nHoursPerWeek);
00444                      int d=best_solution.times[i]%gt.rules.nDaysPerWeek;
00445                      //int h=best_solution.times[i]/gt.rules.nDaysPerWeek;
00446                      
00447                      if(d==selectedDayInt){
00448                             lockedActivitiesIds.insert(gt.rules.internalActivitiesList[i].id);
00449                      }
00450               }
00451        }
00452 
00453        QString removedTimeConstraintsString;
00454        QString notRemovedTimeConstraintsString;
00455 
00456        QList<ConstraintActivityPreferredStartingTime*> removedTimeConstraints;
00457        QList<ConstraintActivityPreferredStartingTime*> notRemovedTimeConstraints;
00458        
00459        QString removedSpaceConstraintsString;
00460        QString notRemovedSpaceConstraintsString;
00461 
00462        QList<ConstraintActivityPreferredRoom*> removedSpaceConstraints;
00463        QList<ConstraintActivityPreferredRoom*> notRemovedSpaceConstraints;
00464        
00465        if(unlockTime){
00466               foreach(TimeConstraint* tc, gt.rules.timeConstraintsList){
00467                      if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME){
00468                             ConstraintActivityPreferredStartingTime* c=(ConstraintActivityPreferredStartingTime*)tc;
00469                             if(c->weightPercentage==100.0 && c->day>=0 && c->hour>=0 && lockedActivitiesIds.contains(c->activityId)){
00470                                    if(c->day!=selectedDayInt){
00471                                           //QMessageBox::warning(&taDialog, tr("FET warning"), tr("Incorrect data - time constraint is incorrect - please regenerate the timetable. Please report possible bug."));
00472                                           //above test is no good???
00473                                    }
00474                                    //assert(c->day==selectedDayInt);
00475                                    
00476                                    if(!c->permanentlyLocked){
00477                                           removedTimeConstraints.append(c);
00478                                           removedTimeConstraintsString+=c->getDetailedDescription(gt.rules)+"\n";
00479                                           removedTime++;
00480                                    }
00481                                    else{
00482                                           notRemovedTimeConstraints.append(c);
00483                                           notRemovedTimeConstraintsString+=c->getDetailedDescription(gt.rules)+"\n";
00484                                           notRemovedTime++;
00485                                    }
00486                             }
00487                      }
00488               }
00489        }
00490 
00491        if(unlockSpace){
00492               foreach(SpaceConstraint* tc, gt.rules.spaceConstraintsList){
00493                      if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_ROOM){
00494                             ConstraintActivityPreferredRoom* c=(ConstraintActivityPreferredRoom*)tc;
00495                             if(c->weightPercentage==100.0 && lockedActivitiesIds.contains(c->activityId)){
00496                                    if(!c->permanentlyLocked){
00497                                           removedSpaceConstraints.append(c);
00498                                           removedSpaceConstraintsString+=c->getDetailedDescription(gt.rules)+"\n";
00499                                           removedSpace++;
00500                                    }
00501                                    else{
00502                                           notRemovedSpaceConstraints.append(c);
00503                                           notRemovedSpaceConstraintsString+=c->getDetailedDescription(gt.rules)+"\n";
00504                                           notRemovedSpace++;
00505                                    }
00506                             }
00507                      }
00508               }
00509        }
00510 
00512        //last confirmation dialog
00513        QDialog lastConfirmationDialog(&taDialog);
00514        lastConfirmationDialog.setWindowTitle(tr("Last confirmation needed"));
00515 
00516        QVBoxLayout* lastMainLayout=new QVBoxLayout(&lastConfirmationDialog);
00517 
00518        QPushButton* lastpb1=new QPushButton(tr("Cancel"));
00519        QPushButton* lastpb2=new QPushButton(tr("OK"));
00520        QHBoxLayout* lastButtons=new QHBoxLayout();
00521        lastButtons->addStretch();
00522        lastButtons->addWidget(lastpb1);
00523        lastButtons->addWidget(lastpb2);
00524        
00526        QVBoxLayout* left=new QVBoxLayout();
00527        QVBoxLayout* right=new QVBoxLayout();
00528        QHBoxLayout* all=new QHBoxLayout();
00529        all->addLayout(left);
00530        all->addLayout(right);
00531        
00532        QPlainTextEdit* remTim=new QPlainTextEdit();
00533        remTim->setReadOnly(true);
00534        remTim->setPlainText(removedTimeConstraintsString);
00535        QLabel* labRemTim=new QLabel(tr("These time constraints will be removed"));
00536        labRemTim->setWordWrap(true);
00537        labRemTim->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00538        left->addWidget(labRemTim);
00539        left->addWidget(remTim);
00540 
00541        QPlainTextEdit* notRemTim=new QPlainTextEdit();
00542        notRemTim->setReadOnly(true);
00543        notRemTim->setPlainText(notRemovedTimeConstraintsString);
00544        QLabel* labNotRemTim=new QLabel(tr("These time constraints will NOT be removed"));
00545        labNotRemTim->setWordWrap(true);
00546        labNotRemTim->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00547        left->addWidget(labNotRemTim);
00548        left->addWidget(notRemTim);
00549 
00550        QPlainTextEdit* remSpa=new QPlainTextEdit();
00551        remSpa->setReadOnly(true);
00552        remSpa->setPlainText(removedSpaceConstraintsString);
00553        QLabel* labRemSpa=new QLabel(tr("These space constraints will be removed"));
00554        labRemSpa->setWordWrap(true);
00555        labRemSpa->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00556        right->addWidget(labRemSpa);
00557        right->addWidget(remSpa);
00558        
00559        QPlainTextEdit* notRemSpa=new QPlainTextEdit();
00560        notRemSpa->setReadOnly(true);
00561        notRemSpa->setPlainText(notRemovedSpaceConstraintsString);
00562        QLabel* labNotRemSpa=new QLabel(tr("These space constraints will NOT be removed"));
00563        labNotRemSpa->setWordWrap(true);
00564        labNotRemSpa->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00565        right->addWidget(labNotRemSpa);
00566        right->addWidget(notRemSpa);
00568        
00570        lastMainLayout->addLayout(all);
00571        //lastMainLayout->addStretch();
00572        lastMainLayout->addLayout(lastButtons);
00573 
00574        QObject::connect(lastpb2, SIGNAL(clicked()), &lastConfirmationDialog, SLOT(accept()));
00575        QObject::connect(lastpb1, SIGNAL(clicked()), &lastConfirmationDialog, SLOT(reject()));
00576 
00577        lastpb2->setDefault(true);
00578        lastpb2->setFocus();
00579        
00580        int lw=lastConfirmationDialog.sizeHint().width();
00581        int lh=lastConfirmationDialog.sizeHint().height();
00582        lastConfirmationDialog.resize(lw,lh);
00583        centerWidgetOnScreen(&lastConfirmationDialog);
00584        restoreFETDialogGeometry(&lastConfirmationDialog, unlockDayConfirmationSettingsString);
00585        ok=lastConfirmationDialog.exec();
00586        saveFETDialogGeometry(&lastConfirmationDialog, unlockDayConfirmationSettingsString);
00587        if(!ok)
00588               return;
00590        
00591        foreach(TimeConstraint* tc, removedTimeConstraints)
00592               gt.rules.removeTimeConstraint(tc);
00593        removedTimeConstraints.clear();
00594        notRemovedTimeConstraints.clear();
00595 
00596        foreach(SpaceConstraint* sc, removedSpaceConstraints)
00597               gt.rules.removeSpaceConstraint(sc);
00598        removedSpaceConstraints.clear();
00599        notRemovedSpaceConstraints.clear();
00600 
00601        QMessageBox::information(&lastConfirmationDialog, tr("FET information"), tr("There were removed %1 locking time constraints and"
00602               " %2 locking space constraints. There were not removed %3 locking time constraints and %4 locking space constraints, because"
00603               " these activities were permanently locked").arg(removedTime).arg(removedSpace).arg(notRemovedTime).arg(notRemovedSpace));
00604        
00605        LockUnlock::computeLockedUnlockedActivitiesTimeSpace();
00606        LockUnlock::increaseCommunicationSpinBox();
00607 }
00608 
00609 void AdvancedLockUnlockForm::lockEndStudentsDay(QWidget* parent)
00610 {
00611        if(!students_schedule_ready || !teachers_schedule_ready || !rooms_schedule_ready){
00612               return;
00613        }
00614        
00615        //New Dialog
00616        QDialog taDialog(parent);
00617        taDialog.setWindowTitle(tr("FET - Lock all activities which end each students set's day"));
00618 
00619        QVBoxLayout* taMainLayout=new QVBoxLayout(&taDialog);
00620 
00621        QLabel* taLabel=new QLabel();
00622        taLabel->setWordWrap(true);
00623        taLabel->setText(tr("All activities which end each students set's day will be locked"));
00624        taLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00625 
00626        QPushButton* tapb1=new QPushButton(tr("Cancel"));
00627        QPushButton* tapb2=new QPushButton(tr("OK"));
00628        
00629        QHBoxLayout* buttons=new QHBoxLayout();
00630        buttons->addStretch();
00631        buttons->addWidget(tapb1);
00632        buttons->addWidget(tapb2);
00633        
00635        QGroupBox* selectorsGroupBox=new QGroupBox();
00636        selectorsGroupBox->setTitle("Lock");
00637        
00638        QHBoxLayout* groupLayout=new QHBoxLayout(selectorsGroupBox);
00639        
00640        QCheckBox* timeCheckBox=new QCheckBox();
00641        timeCheckBox->setChecked(true);
00642        timeCheckBox->setText("Time");
00643        QCheckBox* spaceCheckBox=new QCheckBox();
00644        spaceCheckBox->setChecked(true);
00645        spaceCheckBox->setText("Space");
00646 
00647        groupLayout->addWidget(timeCheckBox);
00648        groupLayout->addWidget(spaceCheckBox);
00649        groupLayout->addStretch();
00651        
00652        taMainLayout->addWidget(taLabel);
00653        taMainLayout->addStretch();
00654        taMainLayout->addWidget(selectorsGroupBox);
00655        taMainLayout->addStretch();
00656        taMainLayout->addLayout(buttons);
00657 
00658        QObject::connect(tapb2, SIGNAL(clicked()), &taDialog, SLOT(accept()));
00659        QObject::connect(tapb1, SIGNAL(clicked()), &taDialog, SLOT(reject()));
00660 
00661        tapb2->setDefault(true);
00662        tapb2->setFocus();
00663        
00664        int w=taDialog.sizeHint().width();
00665        int h=taDialog.sizeHint().height();
00666        if(w<MIN_WIDTH)
00667               w=MIN_WIDTH;
00668        if(h<MIN_HEIGHT)
00669               h=MIN_HEIGHT;
00670        taDialog.resize(w,h);
00671        centerWidgetOnScreen(&taDialog);
00672        restoreFETDialogGeometry(&taDialog, lockEndStudentsDaySettingsString);
00673        bool ok=taDialog.exec();
00674        saveFETDialogGeometry(&taDialog, lockEndStudentsDaySettingsString);
00675        if(!ok)
00676               return;
00677               
00678        bool lockTime=timeCheckBox->isChecked();
00679        bool lockSpace=spaceCheckBox->isChecked();
00680 
00681        QString addedTimeConstraintsString;
00682        QString notAddedTimeConstraintsString;
00683        
00684        QList<ConstraintActivityPreferredStartingTime*> addedTimeConstraints;
00685        QList<ConstraintActivityPreferredStartingTime*> notAddedTimeConstraints;
00686        
00687        QString addedSpaceConstraintsString;
00688        QString notAddedSpaceConstraintsString;
00689        
00690        QList<ConstraintActivityPreferredRoom*> addedSpaceConstraints;
00691        QList<ConstraintActivityPreferredRoom*> notAddedSpaceConstraints;
00692        
00693        int addedTime=0, notAddedTime=0;
00694        int addedSpace=0, notAddedSpace=0;
00695        
00696        QList<int> activitiesIdsList;
00697        QList<int> activitiesIndexList;
00698        QSet<int> activitiesIdsSet;
00699        for(int sg=0; sg<gt.rules.nInternalSubgroups; sg++){
00700               for(int d=0; d<gt.rules.nDaysPerWeek; d++){
00701                      for(int h=gt.rules.nHoursPerDay-1; h>=0; h--){
00702                             int ai=students_timetable_weekly[sg][d][h];
00703                             
00704                             if(ai!=UNALLOCATED_ACTIVITY){
00705                                    Activity* act=&gt.rules.internalActivitiesList[ai];
00706                                    
00707                                    if(!activitiesIdsSet.contains(act->id)){
00708                                           activitiesIdsList.append(act->id);
00709                                           activitiesIdsSet.insert(act->id);
00710                                           activitiesIndexList.append(ai);
00711                                    }
00712                             
00713                                    break;
00714                             }
00715                      }
00716               }
00717        }
00718 
00719        assert(activitiesIdsList.count()==activitiesIndexList.count());
00720        for(int q=0; q<activitiesIdsList.count(); q++){
00721               int id=activitiesIdsList.at(q);
00722               int ai=activitiesIndexList.at(q);
00723               assert(gt.rules.internalActivitiesList[ai].id==id);
00724 
00725               assert(best_solution.times[ai]!=UNALLOCATED_TIME);
00726               if(best_solution.times[ai]!=UNALLOCATED_TIME){
00727                      assert(best_solution.times[ai]>=0 && best_solution.times[ai]<gt.rules.nHoursPerWeek);
00728                      int d=best_solution.times[ai]%gt.rules.nDaysPerWeek;
00729                      int h=best_solution.times[ai]/gt.rules.nDaysPerWeek;
00730                      
00731                      ConstraintActivityPreferredStartingTime* newTimeCtr=NULL;
00732                      
00733                      ConstraintActivityPreferredRoom* newSpaceCtr=NULL;
00734                      
00735                      if(lockTime){
00736                             newTimeCtr=new ConstraintActivityPreferredStartingTime(100.0, id, d, h, false);
00737                      }
00738                      
00739                      if(lockSpace){
00740                             if(best_solution.rooms[ai]!=UNALLOCATED_SPACE && best_solution.rooms[ai]!=UNSPECIFIED_ROOM){
00741                                    newSpaceCtr=new ConstraintActivityPreferredRoom(100.0, id, gt.rules.internalRoomsList[best_solution.rooms[ai]]->name, false);
00742                             }
00743                      }
00744                      
00745                      if(newTimeCtr!=NULL){
00746                             bool add=true;
00747                             foreach(TimeConstraint* tc, gt.rules.timeConstraintsList){
00748                                    if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME){
00749                                           if((*((ConstraintActivityPreferredStartingTime*)tc)) == (*newTimeCtr)){
00750                                                  add=false;
00751                                                  break;
00752                                           }
00753                                    }
00754                             }
00755                             
00756                             if(add){
00757                                    addedTimeConstraintsString+=newTimeCtr->getDetailedDescription(gt.rules)+"\n";
00758                                    addedTimeConstraints.append(newTimeCtr);
00759                                    
00760                                    addedTime++;
00761                             }
00762                             else{
00763                                    notAddedTimeConstraintsString+=newTimeCtr->getDetailedDescription(gt.rules)+"\n";
00764                                    notAddedTimeConstraints.append(newTimeCtr);
00765                                    
00766                                    notAddedTime++;
00767                             }
00768                      }
00769 
00770                      if(newSpaceCtr!=NULL){
00771                             bool add=true;
00772                             foreach(SpaceConstraint* tc, gt.rules.spaceConstraintsList){
00773                                    if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_ROOM){
00774                                           if((*((ConstraintActivityPreferredRoom*)tc)) == (*newSpaceCtr)){
00775                                                  add=false;
00776                                                  break;
00777                                           }
00778                                    }
00779                             }
00780                             
00781                             if(add){
00782                                    addedSpaceConstraintsString+=newSpaceCtr->getDetailedDescription(gt.rules)+"\n";
00783                                    addedSpaceConstraints.append(newSpaceCtr);
00784                                    
00785                                    addedSpace++;
00786                             }
00787                             else{
00788                                    notAddedSpaceConstraintsString+=newSpaceCtr->getDetailedDescription(gt.rules)+"\n";
00789                                    notAddedSpaceConstraints.append(newSpaceCtr);
00790                                    
00791                                    notAddedSpace++;
00792                             }
00793                      }
00794               }
00795        }
00796        
00798        //last confirmation dialog
00799        QDialog lastConfirmationDialog(&taDialog);
00800        lastConfirmationDialog.setWindowTitle(tr("Last confirmation needed"));
00801 
00802        QVBoxLayout* lastMainLayout=new QVBoxLayout(&lastConfirmationDialog);
00803 
00804        QPushButton* lastpb1=new QPushButton(tr("Cancel"));
00805        QPushButton* lastpb2=new QPushButton(tr("OK"));
00806        QHBoxLayout* lastButtons=new QHBoxLayout();
00807        lastButtons->addStretch();
00808        lastButtons->addWidget(lastpb1);
00809        lastButtons->addWidget(lastpb2);
00810        
00812        QVBoxLayout* left=new QVBoxLayout();
00813        QVBoxLayout* right=new QVBoxLayout();
00814        QHBoxLayout* all=new QHBoxLayout();
00815        all->addLayout(left);
00816        all->addLayout(right);
00817        
00818        QPlainTextEdit* addTim=new QPlainTextEdit();
00819        addTim->setReadOnly(true);
00820        addTim->setPlainText(addedTimeConstraintsString);
00821        QLabel* labAddTim=new QLabel(tr("These time constraints will be added"));
00822        labAddTim->setWordWrap(true);
00823        labAddTim->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00824        left->addWidget(labAddTim);
00825        left->addWidget(addTim);
00826 
00827        QPlainTextEdit* notAddTim=new QPlainTextEdit();
00828        notAddTim->setReadOnly(true);
00829        notAddTim->setPlainText(notAddedTimeConstraintsString);
00830        QLabel* labNotAddTim=new QLabel(tr("These time constraints will NOT be added"));
00831        labNotAddTim->setWordWrap(true);
00832        labNotAddTim->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00833        left->addWidget(labNotAddTim);
00834        left->addWidget(notAddTim);
00835 
00836        QPlainTextEdit* addSpa=new QPlainTextEdit();
00837        addSpa->setReadOnly(true);
00838        addSpa->setPlainText(addedSpaceConstraintsString);
00839        QLabel* labAddSpa=new QLabel(tr("These space constraints will be added"));
00840        labAddSpa->setWordWrap(true);
00841        labAddSpa->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00842        right->addWidget(labAddSpa);
00843        right->addWidget(addSpa);
00844        
00845        QPlainTextEdit* notAddSpa=new QPlainTextEdit();
00846        notAddSpa->setReadOnly(true);
00847        notAddSpa->setPlainText(notAddedSpaceConstraintsString);
00848        QLabel* labNotAddSpa=new QLabel(tr("These space constraints will NOT be added"));
00849        labNotAddSpa->setWordWrap(true);
00850        labNotAddSpa->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00851        right->addWidget(labNotAddSpa);
00852        right->addWidget(notAddSpa);
00854        
00856        lastMainLayout->addLayout(all);
00857        //lastMainLayout->addStretch();
00858        lastMainLayout->addLayout(lastButtons);
00859 
00860        QObject::connect(lastpb2, SIGNAL(clicked()), &lastConfirmationDialog, SLOT(accept()));
00861        QObject::connect(lastpb1, SIGNAL(clicked()), &lastConfirmationDialog, SLOT(reject()));
00862 
00863        lastpb2->setDefault(true);
00864        lastpb2->setFocus();
00865        
00866        int lw=lastConfirmationDialog.sizeHint().width();
00867        int lh=lastConfirmationDialog.sizeHint().height();
00868        lastConfirmationDialog.resize(lw,lh);
00869        centerWidgetOnScreen(&lastConfirmationDialog);
00870        restoreFETDialogGeometry(&lastConfirmationDialog, lockEndStudentsDayConfirmationSettingsString);
00871        ok=lastConfirmationDialog.exec();
00872        saveFETDialogGeometry(&lastConfirmationDialog, lockEndStudentsDayConfirmationSettingsString);
00873        if(!ok)
00874               return;
00876        
00877        foreach(TimeConstraint* tc, addedTimeConstraints){
00878               bool t=gt.rules.addTimeConstraint(tc);
00879               assert(t);
00880        }
00881        addedTimeConstraints.clear();
00882        foreach(TimeConstraint* tc, notAddedTimeConstraints){
00883               delete tc;
00884        }
00885        notAddedTimeConstraints.clear();
00886        
00887        foreach(SpaceConstraint* sc, addedSpaceConstraints){
00888               bool t=gt.rules.addSpaceConstraint(sc);
00889               assert(t);
00890        }
00891        addedSpaceConstraints.clear();
00892        foreach(SpaceConstraint* sc, notAddedSpaceConstraints){
00893               delete sc;
00894        }
00895        notAddedSpaceConstraints.clear();
00896        
00897        QMessageBox::information(&lastConfirmationDialog, tr("FET information"), tr("There were added %1 locking time constraints and"
00898               " %2 locking space constraints. There were not added %3 locking time constraints and %4 locking space constraints, because"
00899               " these activities were already locked").arg(addedTime).arg(addedSpace).arg(notAddedTime).arg(notAddedSpace));
00900        
00901        LockUnlock::computeLockedUnlockedActivitiesTimeSpace();
00902        LockUnlock::increaseCommunicationSpinBox();
00903 }
00904 
00905 void AdvancedLockUnlockForm::unlockEndStudentsDay(QWidget* parent)
00906 {
00907        if(!students_schedule_ready || !teachers_schedule_ready || !rooms_schedule_ready){
00908               return;
00909        }
00910        
00911        //New Dialog
00912        QDialog taDialog(parent);
00913        taDialog.setWindowTitle(tr("FET - Unlock all activities which end each students set's day"));
00914 
00915        QVBoxLayout* taMainLayout=new QVBoxLayout(&taDialog);
00916 
00917        QLabel* taLabel=new QLabel();
00918        taLabel->setWordWrap(true);
00919        taLabel->setText(tr("All activities which end each students set's day will be unlocked"));
00920        taLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00921 
00922        QPushButton* tapb1=new QPushButton(tr("Cancel"));
00923        QPushButton* tapb2=new QPushButton(tr("OK"));
00924        
00925        QHBoxLayout* buttons=new QHBoxLayout();
00926        buttons->addStretch();
00927        buttons->addWidget(tapb1);
00928        buttons->addWidget(tapb2);
00929        
00931        QGroupBox* selectorsGroupBox=new QGroupBox();
00932        selectorsGroupBox->setTitle("Unlock");
00933        
00934        QHBoxLayout* groupLayout=new QHBoxLayout(selectorsGroupBox);
00935        
00936        QCheckBox* timeCheckBox=new QCheckBox();
00937        timeCheckBox->setChecked(true);
00938        timeCheckBox->setText("Time");
00939        QCheckBox* spaceCheckBox=new QCheckBox();
00940        spaceCheckBox->setChecked(true);
00941        spaceCheckBox->setText("Space");
00942 
00943        groupLayout->addWidget(timeCheckBox);
00944        groupLayout->addWidget(spaceCheckBox);
00945        groupLayout->addStretch();
00947        
00948        taMainLayout->addWidget(taLabel);
00949        taMainLayout->addStretch();
00950        taMainLayout->addWidget(selectorsGroupBox);
00951        taMainLayout->addStretch();
00952        taMainLayout->addLayout(buttons);
00953 
00954        QObject::connect(tapb2, SIGNAL(clicked()), &taDialog, SLOT(accept()));
00955        QObject::connect(tapb1, SIGNAL(clicked()), &taDialog, SLOT(reject()));
00956 
00957        tapb2->setDefault(true);
00958        tapb2->setFocus();
00959        
00960        int w=taDialog.sizeHint().width();
00961        int h=taDialog.sizeHint().height();
00962        if(w<MIN_WIDTH)
00963               w=MIN_WIDTH;
00964        if(h<MIN_HEIGHT)
00965               h=MIN_HEIGHT;
00966        taDialog.resize(w,h);
00967        centerWidgetOnScreen(&taDialog);
00968        restoreFETDialogGeometry(&taDialog, unlockEndStudentsDaySettingsString);
00969        bool ok=taDialog.exec();
00970        saveFETDialogGeometry(&taDialog, unlockEndStudentsDaySettingsString);
00971        if(!ok)
00972               return;
00973               
00974        bool unlockTime=timeCheckBox->isChecked();
00975        bool unlockSpace=spaceCheckBox->isChecked();
00976 
00977        int removedTime=0, notRemovedTime=0;
00978        int removedSpace=0, notRemovedSpace=0;
00979        
00980 
00981        QSet<int> activitiesIdsSet;
00982        for(int sg=0; sg<gt.rules.nInternalSubgroups; sg++){
00983               for(int d=0; d<gt.rules.nDaysPerWeek; d++){
00984                      for(int h=gt.rules.nHoursPerDay-1; h>=0; h--){
00985                             int ai=students_timetable_weekly[sg][d][h];
00986                             
00987                             if(ai!=UNALLOCATED_ACTIVITY){
00988                                    Activity* act=&gt.rules.internalActivitiesList[ai];
00989                                    
00990                                    if(!activitiesIdsSet.contains(act->id)){
00991                                           activitiesIdsSet.insert(act->id);
00992                                    }
00993                             
00994                                    break;
00995                             }
00996                      }
00997               }
00998        }
00999 
01000        QString removedTimeConstraintsString;
01001        QString notRemovedTimeConstraintsString;
01002 
01003        QList<ConstraintActivityPreferredStartingTime*> removedTimeConstraints;
01004        QList<ConstraintActivityPreferredStartingTime*> notRemovedTimeConstraints;
01005        
01006        QString removedSpaceConstraintsString;
01007        QString notRemovedSpaceConstraintsString;
01008 
01009        QList<ConstraintActivityPreferredRoom*> removedSpaceConstraints;
01010        QList<ConstraintActivityPreferredRoom*> notRemovedSpaceConstraints;
01011        
01012        if(unlockTime){
01013               foreach(TimeConstraint* tc, gt.rules.timeConstraintsList){
01014                      if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME){
01015                             ConstraintActivityPreferredStartingTime* c=(ConstraintActivityPreferredStartingTime*)tc;
01016                             if(c->weightPercentage==100.0 && c->day>=0 && c->hour>=0 && activitiesIdsSet.contains(c->activityId)){
01017                                    if(!c->permanentlyLocked){
01018                                           removedTimeConstraints.append(c);
01019                                           removedTimeConstraintsString+=c->getDetailedDescription(gt.rules)+"\n";
01020                                           removedTime++;
01021                                    }
01022                                    else{
01023                                           notRemovedTimeConstraints.append(c);
01024                                           notRemovedTimeConstraintsString+=c->getDetailedDescription(gt.rules)+"\n";
01025                                           notRemovedTime++;
01026                                    }
01027                             }
01028                      }
01029               }
01030        }
01031 
01032        if(unlockSpace){
01033               foreach(SpaceConstraint* tc, gt.rules.spaceConstraintsList){
01034                      if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_ROOM){
01035                             ConstraintActivityPreferredRoom* c=(ConstraintActivityPreferredRoom*)tc;
01036                             if(c->weightPercentage==100.0 && activitiesIdsSet.contains(c->activityId)){
01037                                    if(!c->permanentlyLocked){
01038                                           removedSpaceConstraints.append(c);
01039                                           removedSpaceConstraintsString+=c->getDetailedDescription(gt.rules)+"\n";
01040                                           removedSpace++;
01041                                    }
01042                                    else{
01043                                           notRemovedSpaceConstraints.append(c);
01044                                           notRemovedSpaceConstraintsString+=c->getDetailedDescription(gt.rules)+"\n";
01045                                           notRemovedSpace++;
01046                                    }
01047                             }
01048                      }
01049               }
01050        }
01051 
01053        //last confirmation dialog
01054        QDialog lastConfirmationDialog(&taDialog);
01055        lastConfirmationDialog.setWindowTitle(tr("Last confirmation needed"));
01056 
01057        QVBoxLayout* lastMainLayout=new QVBoxLayout(&lastConfirmationDialog);
01058 
01059        QPushButton* lastpb1=new QPushButton(tr("Cancel"));
01060        QPushButton* lastpb2=new QPushButton(tr("OK"));
01061        QHBoxLayout* lastButtons=new QHBoxLayout();
01062        lastButtons->addStretch();
01063        lastButtons->addWidget(lastpb1);
01064        lastButtons->addWidget(lastpb2);
01065        
01067        QVBoxLayout* left=new QVBoxLayout();
01068        QVBoxLayout* right=new QVBoxLayout();
01069        QHBoxLayout* all=new QHBoxLayout();
01070        all->addLayout(left);
01071        all->addLayout(right);
01072        
01073        QPlainTextEdit* remTim=new QPlainTextEdit();
01074        remTim->setReadOnly(true);
01075        remTim->setPlainText(removedTimeConstraintsString);
01076        QLabel* labRemTim=new QLabel(tr("These time constraints will be removed"));
01077        labRemTim->setWordWrap(true);
01078        labRemTim->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01079        left->addWidget(labRemTim);
01080        left->addWidget(remTim);
01081 
01082        QPlainTextEdit* notRemTim=new QPlainTextEdit();
01083        notRemTim->setReadOnly(true);
01084        notRemTim->setPlainText(notRemovedTimeConstraintsString);
01085        QLabel* labNotRemTim=new QLabel(tr("These time constraints will NOT be removed"));
01086        labNotRemTim->setWordWrap(true);
01087        labNotRemTim->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01088        left->addWidget(labNotRemTim);
01089        left->addWidget(notRemTim);
01090 
01091        QPlainTextEdit* remSpa=new QPlainTextEdit();
01092        remSpa->setReadOnly(true);
01093        remSpa->setPlainText(removedSpaceConstraintsString);
01094        QLabel* labRemSpa=new QLabel(tr("These space constraints will be removed"));
01095        labRemSpa->setWordWrap(true);
01096        labRemSpa->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01097        right->addWidget(labRemSpa);
01098        right->addWidget(remSpa);
01099        
01100        QPlainTextEdit* notRemSpa=new QPlainTextEdit();
01101        notRemSpa->setReadOnly(true);
01102        notRemSpa->setPlainText(notRemovedSpaceConstraintsString);
01103        QLabel* labNotRemSpa=new QLabel(tr("These space constraints will NOT be removed"));
01104        labNotRemSpa->setWordWrap(true);
01105        labNotRemSpa->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01106        right->addWidget(labNotRemSpa);
01107        right->addWidget(notRemSpa);
01109        
01111        lastMainLayout->addLayout(all);
01112        //lastMainLayout->addStretch();
01113        lastMainLayout->addLayout(lastButtons);
01114 
01115        QObject::connect(lastpb2, SIGNAL(clicked()), &lastConfirmationDialog, SLOT(accept()));
01116        QObject::connect(lastpb1, SIGNAL(clicked()), &lastConfirmationDialog, SLOT(reject()));
01117 
01118        lastpb2->setDefault(true);
01119        lastpb2->setFocus();
01120        
01121        int lw=lastConfirmationDialog.sizeHint().width();
01122        int lh=lastConfirmationDialog.sizeHint().height();
01123        lastConfirmationDialog.resize(lw,lh);
01124        centerWidgetOnScreen(&lastConfirmationDialog);
01125        restoreFETDialogGeometry(&lastConfirmationDialog, unlockEndStudentsDayConfirmationSettingsString);
01126        ok=lastConfirmationDialog.exec();
01127        saveFETDialogGeometry(&lastConfirmationDialog, unlockEndStudentsDayConfirmationSettingsString);
01128        if(!ok)
01129               return;
01131        
01132        foreach(TimeConstraint* tc, removedTimeConstraints)
01133               gt.rules.removeTimeConstraint(tc);
01134        removedTimeConstraints.clear();
01135        notRemovedTimeConstraints.clear();
01136 
01137        foreach(SpaceConstraint* sc, removedSpaceConstraints)
01138               gt.rules.removeSpaceConstraint(sc);
01139        removedSpaceConstraints.clear();
01140        notRemovedSpaceConstraints.clear();
01141 
01142        QMessageBox::information(&lastConfirmationDialog, tr("FET information"), tr("There were removed %1 locking time constraints and"
01143               " %2 locking space constraints. There were not removed %3 locking time constraints and %4 locking space constraints, because"
01144               " these activities were permanently locked").arg(removedTime).arg(removedSpace).arg(notRemovedTime).arg(notRemovedSpace));
01145        
01146        LockUnlock::computeLockedUnlockedActivitiesTimeSpace();
01147        LockUnlock::increaseCommunicationSpinBox();
01148 }
01149 
01150 void AdvancedLockUnlockForm::lockAll(QWidget* parent)
01151 {
01152        if(!students_schedule_ready || !teachers_schedule_ready || !rooms_schedule_ready){
01153               return;
01154        }
01155        
01156        //New Dialog
01157        QDialog taDialog(parent);
01158        taDialog.setWindowTitle(tr("FET - Lock all activities in the timetable"));
01159 
01160        QVBoxLayout* taMainLayout=new QVBoxLayout(&taDialog);
01161 
01162        QLabel* taLabel=new QLabel();
01163        taLabel->setWordWrap(true);
01164        taLabel->setText(tr("All activities in the current timetable will be locked"));
01165        taLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01166 
01167        QPushButton* tapb1=new QPushButton(tr("Cancel"));
01168        QPushButton* tapb2=new QPushButton(tr("OK"));
01169        
01170        QHBoxLayout* buttons=new QHBoxLayout();
01171        buttons->addStretch();
01172        buttons->addWidget(tapb1);
01173        buttons->addWidget(tapb2);
01174        
01176        QGroupBox* selectorsGroupBox=new QGroupBox();
01177        selectorsGroupBox->setTitle("Lock");
01178        
01179        QHBoxLayout* groupLayout=new QHBoxLayout(selectorsGroupBox);
01180        
01181        QCheckBox* timeCheckBox=new QCheckBox();
01182        timeCheckBox->setChecked(true);
01183        timeCheckBox->setText("Time");
01184        QCheckBox* spaceCheckBox=new QCheckBox();
01185        spaceCheckBox->setChecked(true);
01186        spaceCheckBox->setText("Space");
01187 
01188        groupLayout->addWidget(timeCheckBox);
01189        groupLayout->addWidget(spaceCheckBox);
01190        groupLayout->addStretch();
01192        
01193        taMainLayout->addWidget(taLabel);
01194        taMainLayout->addStretch();
01195        taMainLayout->addWidget(selectorsGroupBox);
01196        taMainLayout->addStretch();
01197        taMainLayout->addLayout(buttons);
01198 
01199        QObject::connect(tapb2, SIGNAL(clicked()), &taDialog, SLOT(accept()));
01200        QObject::connect(tapb1, SIGNAL(clicked()), &taDialog, SLOT(reject()));
01201 
01202        tapb2->setDefault(true);
01203        tapb2->setFocus();
01204        
01205        int w=taDialog.sizeHint().width();
01206        int h=taDialog.sizeHint().height();
01207        if(w<MIN_WIDTH)
01208               w=MIN_WIDTH;
01209        if(h<MIN_HEIGHT)
01210               h=MIN_HEIGHT;
01211        taDialog.resize(w,h);
01212        centerWidgetOnScreen(&taDialog);
01213        restoreFETDialogGeometry(&taDialog, lockAllSettingsString);
01214        bool ok=taDialog.exec();
01215        saveFETDialogGeometry(&taDialog, lockAllSettingsString);
01216        if(!ok)
01217               return;
01218               
01219        bool lockTime=timeCheckBox->isChecked();
01220        bool lockSpace=spaceCheckBox->isChecked();
01221 
01222        QString addedTimeConstraintsString;
01223        QString notAddedTimeConstraintsString;
01224        
01225        QList<ConstraintActivityPreferredStartingTime*> addedTimeConstraints;
01226        QList<ConstraintActivityPreferredStartingTime*> notAddedTimeConstraints;
01227        
01228        QString addedSpaceConstraintsString;
01229        QString notAddedSpaceConstraintsString;
01230        
01231        QList<ConstraintActivityPreferredRoom*> addedSpaceConstraints;
01232        QList<ConstraintActivityPreferredRoom*> notAddedSpaceConstraints;
01233        
01234        int addedTime=0, notAddedTime=0;
01235        int addedSpace=0, notAddedSpace=0;
01236 
01237        for(int i=0; i<gt.rules.nInternalActivities; i++){
01238               if(best_solution.times[i]!=UNALLOCATED_TIME){
01239                      assert(best_solution.times[i]>=0 && best_solution.times[i]<gt.rules.nHoursPerWeek);
01240                      int d=best_solution.times[i]%gt.rules.nDaysPerWeek;
01241                      int h=best_solution.times[i]/gt.rules.nDaysPerWeek;
01242                      
01243                      ConstraintActivityPreferredStartingTime* newTimeCtr=NULL;
01244                      
01245                      ConstraintActivityPreferredRoom* newSpaceCtr=NULL;
01246                      
01247                      if(lockTime){
01248                             newTimeCtr=new ConstraintActivityPreferredStartingTime(100.0, gt.rules.internalActivitiesList[i].id, d, h, false);
01249                      }
01250                      
01251                      if(lockSpace){
01252                             if(best_solution.rooms[i]!=UNALLOCATED_SPACE && best_solution.rooms[i]!=UNSPECIFIED_ROOM){
01253                                    newSpaceCtr=new ConstraintActivityPreferredRoom(100.0, gt.rules.internalActivitiesList[i].id, gt.rules.internalRoomsList[best_solution.rooms[i]]->name, false);
01254                             }
01255                      }
01256                      
01257                      if(newTimeCtr!=NULL){
01258                             bool add=true;
01259                             foreach(TimeConstraint* tc, gt.rules.timeConstraintsList){
01260                                    if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME){
01261                                           if((*((ConstraintActivityPreferredStartingTime*)tc)) == (*newTimeCtr)){
01262                                                  add=false;
01263                                                  break;
01264                                           }
01265                                    }
01266                             }
01267                             
01268                             if(add){
01269                                    addedTimeConstraintsString+=newTimeCtr->getDetailedDescription(gt.rules)+"\n";
01270                                    addedTimeConstraints.append(newTimeCtr);
01271                                    
01272                                    addedTime++;
01273                             }
01274                             else{
01275                                    notAddedTimeConstraintsString+=newTimeCtr->getDetailedDescription(gt.rules)+"\n";
01276                                    notAddedTimeConstraints.append(newTimeCtr);
01277                                    
01278                                    notAddedTime++;
01279                             }
01280                      }
01281 
01282                      if(newSpaceCtr!=NULL){
01283                             bool add=true;
01284                             foreach(SpaceConstraint* tc, gt.rules.spaceConstraintsList){
01285                                    if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_ROOM){
01286                                           if((*((ConstraintActivityPreferredRoom*)tc)) == (*newSpaceCtr)){
01287                                                  add=false;
01288                                                  break;
01289                                           }
01290                                    }
01291                             }
01292                             
01293                             if(add){
01294                                    addedSpaceConstraintsString+=newSpaceCtr->getDetailedDescription(gt.rules)+"\n";
01295                                    addedSpaceConstraints.append(newSpaceCtr);
01296                                    
01297                                    addedSpace++;
01298                             }
01299                             else{
01300                                    notAddedSpaceConstraintsString+=newSpaceCtr->getDetailedDescription(gt.rules)+"\n";
01301                                    notAddedSpaceConstraints.append(newSpaceCtr);
01302                                    
01303                                    notAddedSpace++;
01304                             }
01305                      }
01306               }
01307        }
01308        
01310        //last confirmation dialog
01311        QDialog lastConfirmationDialog(&taDialog);
01312        lastConfirmationDialog.setWindowTitle(tr("Last confirmation needed"));
01313 
01314        QVBoxLayout* lastMainLayout=new QVBoxLayout(&lastConfirmationDialog);
01315 
01316        QPushButton* lastpb1=new QPushButton(tr("Cancel"));
01317        QPushButton* lastpb2=new QPushButton(tr("OK"));
01318        QHBoxLayout* lastButtons=new QHBoxLayout();
01319        lastButtons->addStretch();
01320        lastButtons->addWidget(lastpb1);
01321        lastButtons->addWidget(lastpb2);
01322        
01324        QVBoxLayout* left=new QVBoxLayout();
01325        QVBoxLayout* right=new QVBoxLayout();
01326        QHBoxLayout* all=new QHBoxLayout();
01327        all->addLayout(left);
01328        all->addLayout(right);
01329        
01330        QPlainTextEdit* addTim=new QPlainTextEdit();
01331        addTim->setReadOnly(true);
01332        addTim->setPlainText(addedTimeConstraintsString);
01333        QLabel* labAddTim=new QLabel(tr("These time constraints will be added"));
01334        labAddTim->setWordWrap(true);
01335        labAddTim->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01336        left->addWidget(labAddTim);
01337        left->addWidget(addTim);
01338 
01339        QPlainTextEdit* notAddTim=new QPlainTextEdit();
01340        notAddTim->setReadOnly(true);
01341        notAddTim->setPlainText(notAddedTimeConstraintsString);
01342        QLabel* labNotAddTim=new QLabel(tr("These time constraints will NOT be added"));
01343        labNotAddTim->setWordWrap(true);
01344        labNotAddTim->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01345        left->addWidget(labNotAddTim);
01346        left->addWidget(notAddTim);
01347 
01348        QPlainTextEdit* addSpa=new QPlainTextEdit();
01349        addSpa->setReadOnly(true);
01350        addSpa->setPlainText(addedSpaceConstraintsString);
01351        QLabel* labAddSpa=new QLabel(tr("These space constraints will be added"));
01352        labAddSpa->setWordWrap(true);
01353        labAddSpa->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01354        right->addWidget(labAddSpa);
01355        right->addWidget(addSpa);
01356        
01357        QPlainTextEdit* notAddSpa=new QPlainTextEdit();
01358        notAddSpa->setReadOnly(true);
01359        notAddSpa->setPlainText(notAddedSpaceConstraintsString);
01360        QLabel* labNotAddSpa=new QLabel(tr("These space constraints will NOT be added"));
01361        labNotAddSpa->setWordWrap(true);
01362        labNotAddSpa->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01363        right->addWidget(labNotAddSpa);
01364        right->addWidget(notAddSpa);
01366        
01368        lastMainLayout->addLayout(all);
01369        //lastMainLayout->addStretch();
01370        lastMainLayout->addLayout(lastButtons);
01371 
01372        QObject::connect(lastpb2, SIGNAL(clicked()), &lastConfirmationDialog, SLOT(accept()));
01373        QObject::connect(lastpb1, SIGNAL(clicked()), &lastConfirmationDialog, SLOT(reject()));
01374 
01375        lastpb2->setDefault(true);
01376        lastpb2->setFocus();
01377        
01378        int lw=lastConfirmationDialog.sizeHint().width();
01379        int lh=lastConfirmationDialog.sizeHint().height();
01380        lastConfirmationDialog.resize(lw,lh);
01381        centerWidgetOnScreen(&lastConfirmationDialog);
01382        restoreFETDialogGeometry(&lastConfirmationDialog, lockAllConfirmationSettingsString);
01383        ok=lastConfirmationDialog.exec();
01384        saveFETDialogGeometry(&lastConfirmationDialog, lockAllConfirmationSettingsString);
01385        if(!ok)
01386               return;
01388        
01389        foreach(TimeConstraint* tc, addedTimeConstraints){
01390               bool t=gt.rules.addTimeConstraint(tc);
01391               assert(t);
01392        }
01393        addedTimeConstraints.clear();
01394        foreach(TimeConstraint* tc, notAddedTimeConstraints){
01395               delete tc;
01396        }
01397        notAddedTimeConstraints.clear();
01398        
01399        foreach(SpaceConstraint* sc, addedSpaceConstraints){
01400               bool t=gt.rules.addSpaceConstraint(sc);
01401               assert(t);
01402        }
01403        addedSpaceConstraints.clear();
01404        foreach(SpaceConstraint* sc, notAddedSpaceConstraints){
01405               delete sc;
01406        }
01407        notAddedSpaceConstraints.clear();
01408        
01409        QMessageBox::information(&lastConfirmationDialog, tr("FET information"), tr("There were added %1 locking time constraints and"
01410               " %2 locking space constraints. There were not added %3 locking time constraints and %4 locking space constraints, because"
01411               " these activities were already locked").arg(addedTime).arg(addedSpace).arg(notAddedTime).arg(notAddedSpace));
01412        
01413        LockUnlock::computeLockedUnlockedActivitiesTimeSpace();
01414        LockUnlock::increaseCommunicationSpinBox();
01415 
01416        //cout<<"isc=="<<gt.rules.internalStructureComputed<<endl;
01417 }
01418 
01419 void AdvancedLockUnlockForm::unlockAll(QWidget* parent)
01420 {
01421        if(!students_schedule_ready || !teachers_schedule_ready || !rooms_schedule_ready){
01422               return;
01423        }
01424        
01425        //New Dialog
01426        QDialog taDialog(parent);
01427        taDialog.setWindowTitle(tr("FET - Unlock all activities of the current timetable"));
01428 
01429        QVBoxLayout* taMainLayout=new QVBoxLayout(&taDialog);
01430 
01431        QLabel* taLabel=new QLabel();
01432        taLabel->setWordWrap(true);
01433        taLabel->setText(tr("All activities of the current timetable will be unlocked (those which are not permanently locked)"));
01434        taLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01435 
01436        QPushButton* tapb1=new QPushButton(tr("Cancel"));
01437        QPushButton* tapb2=new QPushButton(tr("OK"));
01438        
01439        QHBoxLayout* buttons=new QHBoxLayout();
01440        buttons->addStretch();
01441        buttons->addWidget(tapb1);
01442        buttons->addWidget(tapb2);
01443        
01445        QGroupBox* selectorsGroupBox=new QGroupBox();
01446        selectorsGroupBox->setTitle("Unlock");
01447        
01448        QHBoxLayout* groupLayout=new QHBoxLayout(selectorsGroupBox);
01449        
01450        QCheckBox* timeCheckBox=new QCheckBox();
01451        timeCheckBox->setChecked(true);
01452        timeCheckBox->setText("Time");
01453        QCheckBox* spaceCheckBox=new QCheckBox();
01454        spaceCheckBox->setChecked(true);
01455        spaceCheckBox->setText("Space");
01456 
01457        groupLayout->addWidget(timeCheckBox);
01458        groupLayout->addWidget(spaceCheckBox);
01459        groupLayout->addStretch();
01461        
01462        taMainLayout->addWidget(taLabel);
01463        taMainLayout->addStretch();
01464        taMainLayout->addWidget(selectorsGroupBox);
01465        taMainLayout->addStretch();
01466        taMainLayout->addLayout(buttons);
01467 
01468        QObject::connect(tapb2, SIGNAL(clicked()), &taDialog, SLOT(accept()));
01469        QObject::connect(tapb1, SIGNAL(clicked()), &taDialog, SLOT(reject()));
01470 
01471        tapb2->setDefault(true);
01472        tapb2->setFocus();
01473        
01474        int w=taDialog.sizeHint().width();
01475        int h=taDialog.sizeHint().height();
01476        if(w<MIN_WIDTH)
01477               w=MIN_WIDTH;
01478        if(h<MIN_HEIGHT)
01479               h=MIN_HEIGHT;
01480        taDialog.resize(w,h);
01481        centerWidgetOnScreen(&taDialog);
01482        restoreFETDialogGeometry(&taDialog, unlockAllSettingsString);
01483        bool ok=taDialog.exec();
01484        saveFETDialogGeometry(&taDialog, unlockAllSettingsString);
01485        if(!ok)
01486               return;
01487               
01488        bool unlockTime=timeCheckBox->isChecked();
01489        bool unlockSpace=spaceCheckBox->isChecked();
01490 
01491        int removedTime=0, notRemovedTime=0;
01492        int removedSpace=0, notRemovedSpace=0;
01493        
01494        QSet<int> lockedActivitiesIds;
01495 
01496        for(int i=0; i<gt.rules.nInternalActivities; i++){
01497               if(best_solution.times[i]!=UNALLOCATED_TIME){
01498                      assert(best_solution.times[i]>=0 && best_solution.times[i]<gt.rules.nHoursPerWeek);
01499                      lockedActivitiesIds.insert(gt.rules.internalActivitiesList[i].id);
01500               }
01501        }
01502 
01503        QString removedTimeConstraintsString;
01504        QString notRemovedTimeConstraintsString;
01505 
01506        QList<ConstraintActivityPreferredStartingTime*> removedTimeConstraints;
01507        QList<ConstraintActivityPreferredStartingTime*> notRemovedTimeConstraints;
01508        
01509        QString removedSpaceConstraintsString;
01510        QString notRemovedSpaceConstraintsString;
01511 
01512        QList<ConstraintActivityPreferredRoom*> removedSpaceConstraints;
01513        QList<ConstraintActivityPreferredRoom*> notRemovedSpaceConstraints;
01514        
01515        if(unlockTime){
01516               foreach(TimeConstraint* tc, gt.rules.timeConstraintsList){
01517                      if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME){
01518                             ConstraintActivityPreferredStartingTime* c=(ConstraintActivityPreferredStartingTime*)tc;
01519                             if(c->weightPercentage==100.0 && c->day>=0 && c->hour>=0 && lockedActivitiesIds.contains(c->activityId)){
01520                                    if(!c->permanentlyLocked){
01521                                           removedTimeConstraints.append(c);
01522                                           removedTimeConstraintsString+=c->getDetailedDescription(gt.rules)+"\n";
01523                                           removedTime++;
01524                                    }
01525                                    else{
01526                                           notRemovedTimeConstraints.append(c);
01527                                           notRemovedTimeConstraintsString+=c->getDetailedDescription(gt.rules)+"\n";
01528                                           notRemovedTime++;
01529                                    }
01530                             }
01531                      }
01532               }
01533        }
01534 
01535        if(unlockSpace){
01536               foreach(SpaceConstraint* tc, gt.rules.spaceConstraintsList){
01537                      if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_ROOM){
01538                             ConstraintActivityPreferredRoom* c=(ConstraintActivityPreferredRoom*)tc;
01539                             if(c->weightPercentage==100.0 && lockedActivitiesIds.contains(c->activityId)){
01540                                    if(!c->permanentlyLocked){
01541                                           removedSpaceConstraints.append(c);
01542                                           removedSpaceConstraintsString+=c->getDetailedDescription(gt.rules)+"\n";
01543                                           removedSpace++;
01544                                    }
01545                                    else{
01546                                           notRemovedSpaceConstraints.append(c);
01547                                           notRemovedSpaceConstraintsString+=c->getDetailedDescription(gt.rules)+"\n";
01548                                           notRemovedSpace++;
01549                                    }
01550                             }
01551                      }
01552               }
01553        }
01554 
01556        //last confirmation dialog
01557        QDialog lastConfirmationDialog(&taDialog);
01558        lastConfirmationDialog.setWindowTitle(tr("Last confirmation needed"));
01559 
01560        QVBoxLayout* lastMainLayout=new QVBoxLayout(&lastConfirmationDialog);
01561 
01562        QPushButton* lastpb1=new QPushButton(tr("Cancel"));
01563        QPushButton* lastpb2=new QPushButton(tr("OK"));
01564        QHBoxLayout* lastButtons=new QHBoxLayout();
01565        lastButtons->addStretch();
01566        lastButtons->addWidget(lastpb1);
01567        lastButtons->addWidget(lastpb2);
01568        
01570        QVBoxLayout* left=new QVBoxLayout();
01571        QVBoxLayout* right=new QVBoxLayout();
01572        QHBoxLayout* all=new QHBoxLayout();
01573        all->addLayout(left);
01574        all->addLayout(right);
01575        
01576        QPlainTextEdit* remTim=new QPlainTextEdit();
01577        remTim->setReadOnly(true);
01578        remTim->setPlainText(removedTimeConstraintsString);
01579        QLabel* labRemTim=new QLabel(tr("These time constraints will be removed"));
01580        labRemTim->setWordWrap(true);
01581        labRemTim->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01582        left->addWidget(labRemTim);
01583        left->addWidget(remTim);
01584 
01585        QPlainTextEdit* notRemTim=new QPlainTextEdit();
01586        notRemTim->setReadOnly(true);
01587        notRemTim->setPlainText(notRemovedTimeConstraintsString);
01588        QLabel* labNotRemTim=new QLabel(tr("These time constraints will NOT be removed"));
01589        labNotRemTim->setWordWrap(true);
01590        labNotRemTim->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01591        left->addWidget(labNotRemTim);
01592        left->addWidget(notRemTim);
01593 
01594        QPlainTextEdit* remSpa=new QPlainTextEdit();
01595        remSpa->setReadOnly(true);
01596        remSpa->setPlainText(removedSpaceConstraintsString);
01597        QLabel* labRemSpa=new QLabel(tr("These space constraints will be removed"));
01598        labRemSpa->setWordWrap(true);
01599        labRemSpa->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01600        right->addWidget(labRemSpa);
01601        right->addWidget(remSpa);
01602        
01603        QPlainTextEdit* notRemSpa=new QPlainTextEdit();
01604        notRemSpa->setReadOnly(true);
01605        notRemSpa->setPlainText(notRemovedSpaceConstraintsString);
01606        QLabel* labNotRemSpa=new QLabel(tr("These space constraints will NOT be removed"));
01607        labNotRemSpa->setWordWrap(true);
01608        labNotRemSpa->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
01609        right->addWidget(labNotRemSpa);
01610        right->addWidget(notRemSpa);
01612        
01614        lastMainLayout->addLayout(all);
01615        //lastMainLayout->addStretch();
01616        lastMainLayout->addLayout(lastButtons);
01617 
01618        QObject::connect(lastpb2, SIGNAL(clicked()), &lastConfirmationDialog, SLOT(accept()));
01619        QObject::connect(lastpb1, SIGNAL(clicked()), &lastConfirmationDialog, SLOT(reject()));
01620 
01621        lastpb2->setDefault(true);
01622        lastpb2->setFocus();
01623        
01624        int lw=lastConfirmationDialog.sizeHint().width();
01625        int lh=lastConfirmationDialog.sizeHint().height();
01626        lastConfirmationDialog.resize(lw,lh);
01627        centerWidgetOnScreen(&lastConfirmationDialog);
01628        restoreFETDialogGeometry(&lastConfirmationDialog, unlockAllConfirmationSettingsString);
01629        ok=lastConfirmationDialog.exec();
01630        saveFETDialogGeometry(&lastConfirmationDialog, unlockAllConfirmationSettingsString);
01631        if(!ok)
01632               return;
01634        
01635        foreach(TimeConstraint* tc, removedTimeConstraints)
01636               gt.rules.removeTimeConstraint(tc);
01637        removedTimeConstraints.clear();
01638        notRemovedTimeConstraints.clear();
01639 
01640        foreach(SpaceConstraint* sc, removedSpaceConstraints)
01641               gt.rules.removeSpaceConstraint(sc);
01642        removedSpaceConstraints.clear();
01643        notRemovedSpaceConstraints.clear();
01644 
01645        QMessageBox::information(&lastConfirmationDialog, tr("FET information"), tr("There were removed %1 locking time constraints and"
01646               " %2 locking space constraints. There were not removed %3 locking time constraints and %4 locking space constraints, because"
01647               " these activities were permanently locked").arg(removedTime).arg(removedSpace).arg(notRemovedTime).arg(notRemovedSpace));
01648        
01649        LockUnlock::computeLockedUnlockedActivitiesTimeSpace();
01650        LockUnlock::increaseCommunicationSpinBox();
01651        
01652        //cout<<"isc=="<<gt.rules.internalStructureComputed<<endl;
01653 }