Back to index

fet  5.18.0
addbuildingform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           addbuildingform.cpp  -  description
00003                              -------------------
00004     begin                : Feb 11 2008
00005     copyright            : (C) 2008 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 "addbuildingform.h"
00019 
00020 #include <QMessageBox>
00021 
00022 AddBuildingForm::AddBuildingForm(QWidget* parent): QDialog(parent)
00023 {
00024        setupUi(this);
00025        
00026        addBuildingPushButton->setDefault(true);
00027 
00028        connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
00029        connect(addBuildingPushButton, SIGNAL(clicked()), this, SLOT(addBuilding()));
00030 
00031        centerWidgetOnScreen(this);
00032        restoreFETDialogGeometry(this);
00033 }
00034 
00035 AddBuildingForm::~AddBuildingForm()
00036 {
00037        saveFETDialogGeometry(this);
00038 }
00039 
00040 void AddBuildingForm::addBuilding()
00041 {
00042        if(nameLineEdit->text().isEmpty()){
00043               QMessageBox::information(this, tr("FET information"), tr("Incorrect name"));
00044               return;
00045        }
00046        Building* bu=new Building();
00047        bu->name=nameLineEdit->text();
00048        if(!gt.rules.addBuilding(bu)){
00049               QMessageBox::information(this, tr("Room insertion dialog"),
00050                      tr("Could not insert item. Must be a duplicate"));
00051               delete bu;
00052        }
00053        else{
00054               QMessageBox::information(this, tr("Building insertion dialog"),
00055                      tr("Building added"));
00056        }
00057 
00058        nameLineEdit->selectAll();
00059        nameLineEdit->setFocus();
00060 }