Back to index

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