Back to index

fet  5.18.0
modifyroomform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           modifyroomform.cpp  -  description
00003                              -------------------
00004     begin                : Feb 12, 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 "modifyroomform.h"
00019 
00020 #include <QMessageBox>
00021 
00022 ModifyRoomForm::ModifyRoomForm(QWidget* parent, const QString& initialRoomName, const QString& initialRoomBuilding, int initialRoomCapacity): QDialog(parent)
00023 {
00024        setupUi(this);
00025        
00026        okPushButton->setDefault(true);
00027 
00028        connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
00029        connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
00030 
00031        centerWidgetOnScreen(this);
00032        restoreFETDialogGeometry(this);
00033 
00034        QSize tmp5=buildingsComboBox->minimumSizeHint();
00035        Q_UNUSED(tmp5);
00036        
00037        capacitySpinBox->setMinimum(1);
00038        capacitySpinBox->setMaximum(MAX_ROOM_CAPACITY);
00039        capacitySpinBox->setValue(MAX_ROOM_CAPACITY);
00040 
00041        this->_initialRoomName=initialRoomName;
00042        this->_initialRoomBuilding=initialRoomBuilding;
00043        this->_initialRoomCapacity=initialRoomCapacity;
00044        capacitySpinBox->setValue(initialRoomCapacity);
00045 
00046        nameLineEdit->setText(initialRoomName);
00047        nameLineEdit->selectAll();
00048        nameLineEdit->setFocus();
00049        
00050        int i=0;
00051        int j=-1;
00052        buildingsComboBox->clear();
00053        buildingsComboBox->addItem("");
00054        if(initialRoomBuilding=="")
00055               j=i;
00056        i++;
00057        for(int k=0; k<gt.rules.buildingsList.size(); k++, i++){
00058               buildingsComboBox->addItem(gt.rules.buildingsList.at(k)->name);
00059               if(gt.rules.buildingsList.at(k)->name==initialRoomBuilding)
00060                      j=i;
00061        }
00062        assert(j>=0);
00063        buildingsComboBox->setCurrentIndex(j);
00064 }
00065 
00066 ModifyRoomForm::~ModifyRoomForm()
00067 {
00068        saveFETDialogGeometry(this);
00069 }
00070 
00071 void ModifyRoomForm::cancel()
00072 {
00073        this->close();
00074 }
00075 
00076 void ModifyRoomForm::ok()
00077 {
00078        if(nameLineEdit->text().isEmpty()){
00079               QMessageBox::information(this, tr("FET information"), tr("Incorrect name"));
00080               return;
00081        }
00082        if(buildingsComboBox->currentIndex()<0){
00083               QMessageBox::information(this, tr("FET information"), tr("Incorrect building"));
00084               return;
00085        }
00086        if(this->_initialRoomName!=nameLineEdit->text() && gt.rules.searchRoom(nameLineEdit->text())>=0){
00087               QMessageBox::information(this, tr("FET information"), tr("Name existing - please choose another"));
00088               return;
00089        }
00090        
00091        bool t=gt.rules.modifyRoom(this->_initialRoomName, nameLineEdit->text()/*, typesComboBox->currentText()*/, buildingsComboBox->currentText(), capacitySpinBox->value());
00092        assert(t);
00093        
00094        this->close();
00095 }