Back to index

fet  5.18.0
Public Slots | Public Member Functions
TeachersForm Class Reference

#include <teachersform.h>

List of all members.

Public Slots

void addTeacher ()
void removeTeacher ()
void renameTeacher ()
void sortTeachers ()
void teacherChanged (int index)
void activateTeacher ()
void deactivateTeacher ()

Public Member Functions

 TeachersForm (QWidget *parent)
 ~TeachersForm ()

Detailed Description

Definition at line 23 of file teachersform.h.


Constructor & Destructor Documentation

TeachersForm::TeachersForm ( QWidget *  parent)

Definition at line 39 of file teachersform.cpp.

                                         : QDialog(parent)
{
       setupUi(this);
       
       currentTeacherTextEdit->setReadOnly(true);

       renameTeacherPushButton->setDefault(true);

       teachersListWidget->setSelectionMode(QAbstractItemView::SingleSelection);

       connect(renameTeacherPushButton, SIGNAL(clicked()), this, SLOT(renameTeacher()));
       connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
       connect(addTeacherPushButton, SIGNAL(clicked()), this, SLOT(addTeacher()));
       connect(sortTeachersPushButton, SIGNAL(clicked()), this, SLOT(sortTeachers()));
       connect(removeTeacherPushButton, SIGNAL(clicked()), this, SLOT(removeTeacher()));
       connect(teachersListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(teacherChanged(int)));
       connect(activateTeacherPushButton, SIGNAL(clicked()), this, SLOT(activateTeacher()));
       connect(deactivateTeacherPushButton, SIGNAL(clicked()), this, SLOT(deactivateTeacher()));
       connect(teachersListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(renameTeacher()));

       centerWidgetOnScreen(this);
       restoreFETDialogGeometry(this);
       //restore splitter state
       QSettings settings(COMPANY, PROGRAM);
       if(settings.contains(this->metaObject()->className()+QString("/splitter-state")))
              splitter->restoreState(settings.value(this->metaObject()->className()+QString("/splitter-state")).toByteArray());
       
       teachersListWidget->clear();
       for(int i=0; i<gt.rules.teachersList.size(); i++){
              Teacher* tch=gt.rules.teachersList[i];
              teachersListWidget->addItem(tch->name);
       }
       
       if(teachersListWidget->count()>0)
              teachersListWidget->setCurrentRow(0);
}

Here is the call graph for this function:

Definition at line 77 of file teachersform.cpp.

{
       saveFETDialogGeometry(this);
       //save splitter state
       QSettings settings(COMPANY, PROGRAM);
       settings.setValue(this->metaObject()->className()+QString("/splitter-state"), splitter->saveState());
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 209 of file teachersform.cpp.

{
       if(teachersListWidget->currentRow()<0){
              QMessageBox::information(this, tr("FET information"), tr("Invalid selected teacher"));
              return;
       }

       QString teacherName=teachersListWidget->currentItem()->text();
       int count=gt.rules.activateTeacher(teacherName);
       QMessageBox::information(this, tr("FET information"), tr("Activated a number of %1 activities").arg(count));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TeachersForm::addTeacher ( ) [slot]

Definition at line 85 of file teachersform.cpp.

{
       bool ok = FALSE;
       Teacher* tch=new Teacher();
       tch->name = QInputDialog::getText( this, tr("Add teacher"), tr("Please enter teacher's name") ,
        QLineEdit::Normal, QString(), &ok );

       if ( ok && !((tch->name).isEmpty()) ){
              // user entered something and pressed OK
              if(!gt.rules.addTeacher(tch)){
                     QMessageBox::information( this, tr("Teacher insertion dialog"),
                            tr("Could not insert item. Must be a duplicate"));
                     delete tch;
              }
              else{
                     teachersListWidget->addItem(tch->name);
                     teachersListWidget->setCurrentRow(teachersListWidget->count()-1);
              }
       }
       else{
              if(ok){ //the user entered nothing
                     QMessageBox::information(this, tr("FET information"), tr("Incorrect name"));
              }
              delete tch;// user entered nothing or pressed Cancel
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 221 of file teachersform.cpp.

{
       if(teachersListWidget->currentRow()<0){
              QMessageBox::information(this, tr("FET information"), tr("Invalid selected teacher"));
              return;
       }

       QString teacherName=teachersListWidget->currentItem()->text();
       int count=gt.rules.deactivateTeacher(teacherName);
       QMessageBox::information(this, tr("FET information"), tr("De-activated a number of %1 activities").arg(count));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TeachersForm::removeTeacher ( ) [slot]

Definition at line 112 of file teachersform.cpp.

{
       int i=teachersListWidget->currentRow();
       if(teachersListWidget->currentRow()<0){
              QMessageBox::information(this, tr("FET information"), tr("Invalid selected teacher"));
              return;
       }

       QString text=teachersListWidget->currentItem()->text();
       int teacher_ID=gt.rules.searchTeacher(text);
       if(teacher_ID<0){
              QMessageBox::information(this, tr("FET information"), tr("Invalid selected teacher"));
              return;
       }

       if(QMessageBox::warning( this, tr("FET"),
              tr("Are you sure you want to delete this teacher and all related activities and constraints?"),
              tr("Yes"), tr("No"), 0, 0, 1 ) == 1)
              return;

       int tmp=gt.rules.removeTeacher(text);
       if(tmp){
              teachersListWidget->setCurrentRow(-1);
              QListWidgetItem* item;
              item=teachersListWidget->takeItem(i);
              delete item;

              if(i>=teachersListWidget->count())
                     i=teachersListWidget->count()-1;
              if(i>=0)
                     teachersListWidget->setCurrentRow(i);
              else
                     currentTeacherTextEdit->setPlainText(QString(""));
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TeachersForm::renameTeacher ( ) [slot]

Definition at line 148 of file teachersform.cpp.

{
       int i=teachersListWidget->currentRow();
       if(teachersListWidget->currentRow()<0){
              QMessageBox::information(this, tr("FET information"), tr("Invalid selected teacher"));
              return;
       }

       QString initialTeacherName=teachersListWidget->currentItem()->text();
       int teacher_ID=gt.rules.searchTeacher(initialTeacherName);
       if(teacher_ID<0){
              QMessageBox::information(this, tr("FET information"), tr("Invalid selected teacher"));
              return;
       }

       bool ok = FALSE;
       QString finalTeacherName;
       finalTeacherName = QInputDialog::getText( this, tr("Modify teacher"), tr("Please enter new teacher's name") ,
        QLineEdit::Normal, initialTeacherName, &ok);

       if ( ok && !(finalTeacherName.isEmpty())){
              // user entered something and pressed OK
              if(gt.rules.searchTeacher(finalTeacherName)>=0){
                     QMessageBox::information( this, tr("Teacher modification dialog"),
                            tr("Could not modify item. New name must be a duplicate"));
              }
              else{
                     gt.rules.modifyTeacher(initialTeacherName, finalTeacherName);
                     teachersListWidget->item(i)->setText(finalTeacherName);
                     teacherChanged(teachersListWidget->currentRow());
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TeachersForm::sortTeachers ( ) [slot]

Definition at line 182 of file teachersform.cpp.

{
       gt.rules.sortTeachersAlphabetically();

       teachersListWidget->clear();
       for(int i=0; i<gt.rules.teachersList.size(); i++){
              Teacher* tch=gt.rules.teachersList[i];
              teachersListWidget->addItem(tch->name);
       }
       
       if(teachersListWidget->count()>0)
              teachersListWidget->setCurrentRow(0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TeachersForm::teacherChanged ( int  index) [slot]

Definition at line 196 of file teachersform.cpp.

{
       if(index<0){
              currentTeacherTextEdit->setPlainText("");
              return;
       }
       
       Teacher* t=gt.rules.teachersList.at(index);
       assert(t);
       QString s=t->getDetailedDescriptionWithConstraints(gt.rules);
       currentTeacherTextEdit->setPlainText(s);
}

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: