Back to index

fet  5.18.0
modifystudentsyearform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           modifystudentsyearform.cpp  -  description
00003                              -------------------
00004     begin                : Feb 8, 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 "modifystudentsyearform.h"
00019 
00020 #include <QMessageBox>
00021 
00022 ModifyStudentsYearForm::ModifyStudentsYearForm(QWidget* parent, const QString& initialYearName, int initialNumberOfStudents): 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        numberSpinBox->setMaximum(MAX_ROOM_CAPACITY);
00035        numberSpinBox->setMinimum(0);
00036        numberSpinBox->setValue(0);
00037 
00038        this->_initialYearName=initialYearName;
00039        this->_initialNumberOfStudents=initialNumberOfStudents;
00040        numberSpinBox->setValue(initialNumberOfStudents);
00041        nameLineEdit->setText(initialYearName);
00042        nameLineEdit->selectAll();
00043        nameLineEdit->setFocus();
00044 }
00045 
00046 ModifyStudentsYearForm::~ModifyStudentsYearForm()
00047 {
00048        saveFETDialogGeometry(this);
00049 }
00050 
00051 void ModifyStudentsYearForm::cancel()
00052 {
00053        this->close();
00054 }
00055 
00056 void ModifyStudentsYearForm::ok()
00057 {
00058        if(nameLineEdit->text().isEmpty()){
00059               QMessageBox::information(this, tr("FET information"), tr("Incorrect name"));
00060               return;
00061        }
00062        if(this->_initialYearName!=nameLineEdit->text() && gt.rules.searchStudentsSet(nameLineEdit->text())!=NULL){
00063               QMessageBox::information(this, tr("FET information"), tr("Name existing - please choose another"));
00064               return;
00065        }
00066        bool t=gt.rules.modifyYear(this->_initialYearName, nameLineEdit->text(), numberSpinBox->value());
00067        assert(t);
00068 
00069        this->close();
00070 }