Back to index

fet  5.18.0
addroomform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           addroomform.cpp  -  description
00003                              -------------------
00004     begin                : Sun Jan 1 2004
00005     copyright            : (C) 2004 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 "addroomform.h"
00019 
00020 #include "longtextmessagebox.h"
00021 
00022 #include <QMessageBox>
00023 
00024 AddRoomForm::AddRoomForm(QWidget* parent): QDialog(parent)
00025 {
00026        setupUi(this);
00027        
00028        addRoomPushButton->setDefault(true);
00029 
00030        connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
00031        connect(helpPushButton, SIGNAL(clicked()), this, SLOT(help()));
00032        connect(addRoomPushButton, SIGNAL(clicked()), this, SLOT(addRoom()));
00033 
00034        centerWidgetOnScreen(this);
00035        restoreFETDialogGeometry(this);
00036 
00037        QSize tmp5=buildingsComboBox->minimumSizeHint();
00038        Q_UNUSED(tmp5);
00039        
00040        buildingsComboBox->clear();
00041        buildingsComboBox->addItem("");
00042        for(int i=0; i<gt.rules.buildingsList.size(); i++)
00043               buildingsComboBox->addItem(gt.rules.buildingsList.at(i)->name);
00044               
00045        capacitySpinBox->setMinimum(1);
00046        capacitySpinBox->setMaximum(MAX_ROOM_CAPACITY);
00047        capacitySpinBox->setValue(MAX_ROOM_CAPACITY);
00048 }
00049 
00050 AddRoomForm::~AddRoomForm()
00051 {
00052        saveFETDialogGeometry(this);
00053 }
00054 
00055 void AddRoomForm::addRoom()
00056 {
00057        if(nameLineEdit->text().isEmpty()){
00058               QMessageBox::information(this, tr("FET information"), tr("Incorrect name"));
00059               return;
00060        }
00061        if(buildingsComboBox->currentIndex()<0){
00062               QMessageBox::information(this, tr("FET information"), tr("Incorrect building"));
00063               return;
00064        }
00065        Room* rm=new Room();
00066        rm->name=nameLineEdit->text();
00067        rm->building=buildingsComboBox->currentText();
00068        rm->capacity=capacitySpinBox->value();
00069        if(!gt.rules.addRoom(rm)){
00070               QMessageBox::information(this, tr("Room insertion dialog"),
00071                      tr("Could not insert item. Must be a duplicate"));
00072               delete rm;
00073        }
00074        else{
00075               QMessageBox::information(this, tr("Room insertion dialog"),
00076                      tr("Room added"));
00077        }
00078 
00079        nameLineEdit->selectAll();
00080        nameLineEdit->setFocus();
00081 }
00082 
00083 void AddRoomForm::help()
00084 {
00085        QString s;
00086        
00087        s=tr("It is advisable to generate the timetable without the rooms (or without rooms' constraints), then, if a solution is possible, to add rooms or rooms' constraints");
00088         
00089        s+="\n\n";
00090        
00091        s+=tr("Please note that each room can hold a single activity at a specified period. If you"
00092         " have a very large room, which can hold more activities at one time, please add more rooms,"
00093         " representing this larger room");
00094         
00095        LongTextMessageBox::largeInformation(this, tr("FET - help on adding room(s)"), s);
00096 }