Back to index

fet  5.18.0
addstudentsyearform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           addstudentsyearform.cpp  -  description
00003                              -------------------
00004     begin                : Sat Jan 24 2004
00005     copyright            : (C) 2004 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 "addstudentsyearform.h"
00019 
00020 #include <QMessageBox>
00021 
00022 AddStudentsYearForm::AddStudentsYearForm(QWidget* parent): QDialog(parent)
00023 {
00024        setupUi(this);
00025        
00026        addStudentsYearPushButton->setDefault(true);
00027 
00028        connect(addStudentsYearPushButton, SIGNAL(clicked()), this, SLOT(addStudentsYear()));
00029        connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
00030 
00031        centerWidgetOnScreen(this);
00032        restoreFETDialogGeometry(this);
00033        
00034        nameLineEdit->selectAll();
00035        nameLineEdit->setFocus();
00036 
00037        numberSpinBox->setMaximum(MAX_ROOM_CAPACITY);
00038        numberSpinBox->setMinimum(0);
00039        numberSpinBox->setValue(0);
00040 }
00041 
00042 AddStudentsYearForm::~AddStudentsYearForm()
00043 {
00044        saveFETDialogGeometry(this);
00045 }
00046 
00047 void AddStudentsYearForm::addStudentsYear()
00048 {
00049        if(nameLineEdit->text().isEmpty()){
00050               QMessageBox::information(this, tr("FET information"), tr("Incorrect name"));
00051               return;
00052        }
00053 
00054        StudentsSet* ss=gt.rules.searchStudentsSet(nameLineEdit->text());
00055        if(ss!=NULL){
00056               if(ss->type==STUDENTS_SUBGROUP){
00057                      QMessageBox::information( this, tr("Year insertion dialog"),
00058                             tr("This name is taken for a subgroup - please consider another name"));
00059                      return;
00060               }
00061               else if(ss->type==STUDENTS_GROUP){
00062                      QMessageBox::information( this, tr("Year insertion dialog"),
00063                             tr("This name is taken for a group - please consider another name"));
00064                      return;
00065               }
00066               else if(ss->type==STUDENTS_YEAR){
00067                      QMessageBox::information( this, tr("Year insertion dialog"),
00068                             tr("This name is taken for a year - please consider another name"));
00069                      return;
00070               }
00071               else
00072                      assert(0);
00073        }
00074 
00075        StudentsYear* sy=new StudentsYear();
00076        sy->name=nameLineEdit->text();
00077        sy->numberOfStudents=numberSpinBox->value();
00078        
00079        if(gt.rules.searchYear(sy->name) >=0 ){
00080               QMessageBox::information( this, tr("Year insertion dialog"),
00081               tr("Could not insert item. Must be a duplicate"));
00082               delete sy;
00083        }
00084        else{
00085               bool tmp=gt.rules.addYear(sy);
00086               assert(tmp);
00087 
00088               QMessageBox::information(this, tr("Year insertion dialog"),
00089                      tr("Year added. You might want to divide it into sections - this is done in the years "
00090                      "dialog - button 'Divide year ...', or by manually adding groups and subgroups in the groups or subgroups menus\n\n"
00091                      " Important note: if you plan to use option 'divide', please try to use it only once for each year at the beginning, because"
00092                      " a second use of option 'divide' for the same year will remove all activities and constraints referring to old groups and subgroups"
00093                      " from this year."
00094                      ));
00095        }
00096 
00097        nameLineEdit->selectAll();
00098        nameLineEdit->setFocus();
00099 }