Back to index

fet  5.18.0
modifybuildingform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           modifybuildingform.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 "modifybuildingform.h"
00019 
00020 #include <QMessageBox>
00021 
00022 ModifyBuildingForm::ModifyBuildingForm(QWidget* parent, const QString& initialBuildingName): 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        this->_initialBuildingName=initialBuildingName;
00035 
00036        nameLineEdit->setText(initialBuildingName);
00037        nameLineEdit->selectAll();
00038        nameLineEdit->setFocus();
00039 }
00040 
00041 ModifyBuildingForm::~ModifyBuildingForm()
00042 {
00043        saveFETDialogGeometry(this);
00044 }
00045 
00046 void ModifyBuildingForm::cancel()
00047 {
00048        this->close();
00049 }
00050 
00051 void ModifyBuildingForm::ok()
00052 {
00053        if(nameLineEdit->text().isEmpty()){
00054               QMessageBox::information(this, tr("FET information"), tr("Incorrect name"));
00055               return;
00056        }
00057        if(this->_initialBuildingName!=nameLineEdit->text() && gt.rules.searchBuilding(nameLineEdit->text())>=0){
00058               QMessageBox::information(this, tr("FET information"), tr("Name existing - please choose another"));
00059               return;
00060        }
00061        
00062        bool t=gt.rules.modifyBuilding(this->_initialBuildingName, nameLineEdit->text());
00063        assert(t);
00064        
00065        this->close();
00066 }