1
/***************************************************************************
2
constraintstudentsmaxhourscontinuouslyform.cpp - description
5
copyright : (C) 2007 by Lalescu Liviu
6
email : Please see http://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address)
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
16
***************************************************************************/
18
#include "constraintstudentsmaxhourscontinuouslyform.h"
19
#include "addconstraintstudentsmaxhourscontinuouslyform.h"
20
#include "modifyconstraintstudentsmaxhourscontinuouslyform.h"
22
#include <QDesktopWidget>
24
ConstraintStudentsMaxHoursContinuouslyForm::ConstraintStudentsMaxHoursContinuouslyForm()
26
//setWindowFlags(Qt::Window);
27
setWindowFlags(windowFlags() | Qt::WindowMinMaxButtonsHint);
28
QDesktopWidget* desktop=QApplication::desktop();
29
int xx=desktop->width()/2 - frameGeometry().width()/2;
30
int yy=desktop->height()/2 - frameGeometry().height()/2;
33
this->filterChanged();
36
ConstraintStudentsMaxHoursContinuouslyForm::~ConstraintStudentsMaxHoursContinuouslyForm()
40
bool ConstraintStudentsMaxHoursContinuouslyForm::filterOk(TimeConstraint* ctr)
42
if(ctr->type==CONSTRAINT_STUDENTS_MAX_HOURS_CONTINUOUSLY)
48
void ConstraintStudentsMaxHoursContinuouslyForm::filterChanged()
50
this->visibleConstraintsList.clear();
51
constraintsListBox->clear();
52
for(int i=0; i<gt.rules.timeConstraintsList.size(); i++){
53
TimeConstraint* ctr=gt.rules.timeConstraintsList[i];
55
visibleConstraintsList.append(ctr);
56
constraintsListBox->insertItem(ctr->getDescription(gt.rules));
61
void ConstraintStudentsMaxHoursContinuouslyForm::constraintChanged(int index)
65
assert(index<this->visibleConstraintsList.size());
66
TimeConstraint* ctr=this->visibleConstraintsList.at(index);
68
currentConstraintTextEdit->setText(ctr->getDetailedDescription(gt.rules));
71
void ConstraintStudentsMaxHoursContinuouslyForm::addConstraint()
73
AddConstraintStudentsMaxHoursContinuouslyForm *form=new AddConstraintStudentsMaxHoursContinuouslyForm();
78
constraintsListBox->setCurrentItem(constraintsListBox->count()-1);
81
void ConstraintStudentsMaxHoursContinuouslyForm::modifyConstraint()
83
int i=constraintsListBox->currentItem();
85
QMessageBox::information(this, QObject::tr("FET information"), QObject::tr("Invalid selected constraint"));
88
TimeConstraint* ctr=this->visibleConstraintsList.at(i);
90
ModifyConstraintStudentsMaxHoursContinuouslyForm *form
91
= new ModifyConstraintStudentsMaxHoursContinuouslyForm((ConstraintStudentsMaxHoursContinuously*)ctr);
95
constraintsListBox->setCurrentItem(i);
98
void ConstraintStudentsMaxHoursContinuouslyForm::removeConstraint()
100
int i=constraintsListBox->currentItem();
102
QMessageBox::information(this, QObject::tr("FET information"), QObject::tr("Invalid selected constraint"));
105
TimeConstraint* ctr=this->visibleConstraintsList.at(i);
107
s=QObject::tr("Removing constraint:\n");
108
s+=ctr->getDetailedDescription(gt.rules);
109
s+=QObject::tr("\nAre you sure?");
111
switch( QMessageBox::warning( this, QObject::tr("FET warning"),
112
s, QObject::tr("OK"), QObject::tr("Cancel"), 0, 0, 1 ) ){
113
case 0: // The user clicked the OK again button or pressed Enter
114
gt.rules.removeTimeConstraint(ctr);
117
case 1: // The user clicked the Cancel or pressed Escape
121
if((uint)(i) >= constraintsListBox->count())
122
i=constraintsListBox->count()-1;
123
constraintsListBox->setCurrentItem(i);