Back to index

fet  5.18.0
modifystudentsgroupform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           modifystudentsgroupform.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 "modifystudentsgroupform.h"
00019 
00020 #include <QMessageBox>
00021 
00022 ModifyStudentsGroupForm::ModifyStudentsGroupForm(QWidget* parent, const QString& yearName, const QString& initialGroupName, 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->_yearName=yearName;
00039        this->_initialGroupName=initialGroupName;
00040        this->_initialNumberOfStudents=initialNumberOfStudents;
00041        numberSpinBox->setValue(initialNumberOfStudents);
00042        yearNameLineEdit->setText(yearName);
00043        nameLineEdit->setText(initialGroupName);
00044        nameLineEdit->selectAll();
00045        nameLineEdit->setFocus();
00046 }
00047 
00048 ModifyStudentsGroupForm::~ModifyStudentsGroupForm()
00049 {
00050        saveFETDialogGeometry(this);
00051 }
00052 
00053 void ModifyStudentsGroupForm::cancel()
00054 {
00055        this->close();
00056 }
00057 
00058 void ModifyStudentsGroupForm::ok()
00059 {
00060        if(nameLineEdit->text().isEmpty()){
00061               QMessageBox::information(this, tr("FET information"), tr("Incorrect name"));
00062               return;
00063        }
00064        QString yearName=yearNameLineEdit->text();
00065        QString groupName=nameLineEdit->text();
00066        
00067        if(this->_initialGroupName!=groupName && gt.rules.searchStudentsSet(groupName)!=NULL){
00068               QMessageBox::information(this, tr("FET information"), 
00069                tr("Name exists. If you would like to make more years to contain a group (overlapping years),"
00070                " please remove current group (FET will unfortunately remove all related activities and constraints)"
00071                " and add a new group with desired name in current year."
00072                " I know this is a not an elegant procedure, I'll try to fix that in the future."));
00073               return;
00074        }
00075        
00076        bool t=gt.rules.modifyGroup(this->_yearName, this->_initialGroupName, groupName, numberSpinBox->value());       
00077        assert(t);
00078        
00079        this->close();
00080 }