Back to index

fet  5.18.0
Public Slots | Public Member Functions
SubjectsForm Class Reference

#include <subjectsform.h>

List of all members.

Public Slots

void addSubject ()
void removeSubject ()
void renameSubject ()
void sortSubjects ()
void subjectChanged (int index)
void activateSubject ()
void deactivateSubject ()

Public Member Functions

 SubjectsForm (QWidget *parent)
 ~SubjectsForm ()

Detailed Description

Definition at line 23 of file subjectsform.h.


Constructor & Destructor Documentation

SubjectsForm::SubjectsForm ( QWidget *  parent)

Definition at line 41 of file subjectsform.cpp.

                                         : QDialog(parent)
{
       setupUi(this);
       
       currentSubjectTextEdit->setReadOnly(true);
       
       renameSubjectPushButton->setDefault(true);

       subjectsListWidget->setSelectionMode(QAbstractItemView::SingleSelection);

       connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
       connect(addSubjectPushButton, SIGNAL(clicked()), this, SLOT(addSubject()));
       connect(removeSubjectPushButton, SIGNAL(clicked()), this, SLOT(removeSubject()));
       connect(renameSubjectPushButton, SIGNAL(clicked()), this, SLOT(renameSubject()));
       connect(sortSubjectsPushButton, SIGNAL(clicked()), this, SLOT(sortSubjects()));
       connect(subjectsListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(subjectChanged(int)));
       connect(activateSubjectPushButton, SIGNAL(clicked()), this, SLOT(activateSubject()));
       connect(deactivateSubjectPushButton, SIGNAL(clicked()), this, SLOT(deactivateSubject()));
       connect(subjectsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(renameSubject()));

       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());
       
       subjectsListWidget->clear();
       for(int i=0; i<gt.rules.subjectsList.size(); i++){
              Subject* sbj=gt.rules.subjectsList[i];
              subjectsListWidget->addItem(sbj->name);
       }
       
       if(subjectsListWidget->count()>0)
              subjectsListWidget->setCurrentRow(0);
}

Here is the call graph for this function:

Definition at line 79 of file subjectsform.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 212 of file subjectsform.cpp.

{
       if(subjectsListWidget->currentRow()<0){
              QMessageBox::information(this, tr("FET information"), tr("Invalid selected subject"));
              return;
       }
       
       QString subjectName=subjectsListWidget->currentItem()->text();
       
       int count=gt.rules.activateSubject(subjectName);
       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 SubjectsForm::addSubject ( ) [slot]

Definition at line 87 of file subjectsform.cpp.

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

       if ( ok && !((sbj->name).isEmpty()) ){
              // user entered something and pressed OK
              if(!gt.rules.addSubject(sbj)){
                     QMessageBox::information( this, tr("Subject insertion dialog"),
                            tr("Could not insert item. Must be a duplicate"));
                     delete sbj;
              }
              else{
                     subjectsListWidget->addItem(sbj->name);
                     subjectsListWidget->setCurrentRow(subjectsListWidget->count()-1);
              }
       }
       else{
              if(ok){ //the user entered nothing
                     QMessageBox::information(this, tr("FET information"), tr("Incorrect name"));
              }
              delete sbj;// 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 225 of file subjectsform.cpp.

{
       if(subjectsListWidget->currentRow()<0){
              QMessageBox::information(this, tr("FET information"), tr("Invalid selected subject"));
              return;
       }
       
       QString subjectName=subjectsListWidget->currentItem()->text();
       
       int count=gt.rules.deactivateSubject(subjectName);
       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 SubjectsForm::removeSubject ( ) [slot]

Definition at line 114 of file subjectsform.cpp.

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

       QString text=subjectsListWidget->currentItem()->text();
       int subject_ID=gt.rules.searchSubject(text);
       if(subject_ID<0){
              QMessageBox::information(this, tr("FET information"), tr("Invalid selected subject"));
              return;
       }

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

void SubjectsForm::renameSubject ( ) [slot]

Definition at line 150 of file subjectsform.cpp.

{
       int i=subjectsListWidget->currentRow();
       if(subjectsListWidget->currentRow()<0){
              QMessageBox::information(this, tr("FET information"), tr("Invalid selected subject"));
              return;
       }
       
       QString initialSubjectName=subjectsListWidget->currentItem()->text();

       int subject_ID=gt.rules.searchSubject(initialSubjectName);
       if(subject_ID<0){
              QMessageBox::information(this, tr("FET information"), tr("Invalid selected subject"));
              return;
       }

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

       if ( ok && !(finalSubjectName.isEmpty()) ){
              // user entered something and pressed OK
              if(gt.rules.searchSubject(finalSubjectName)>=0){
                     QMessageBox::information( this, tr("Subject insertion dialog"),
                            tr("Could not modify item. New name must be a duplicate"));
              }
              else{
                     gt.rules.modifySubject(initialSubjectName, finalSubjectName);
                     subjectsListWidget->item(i)->setText(finalSubjectName);
                     subjectChanged(subjectsListWidget->currentRow());
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SubjectsForm::sortSubjects ( ) [slot]

Definition at line 185 of file subjectsform.cpp.

{
       gt.rules.sortSubjectsAlphabetically();
       
       subjectsListWidget->clear();
       for(int i=0; i<gt.rules.subjectsList.size(); i++){
              Subject* sbj=gt.rules.subjectsList[i];
              subjectsListWidget->addItem(sbj->name);
       }
       
       if(subjectsListWidget->count()>0)
              subjectsListWidget->setCurrentRow(0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SubjectsForm::subjectChanged ( int  index) [slot]

Definition at line 199 of file subjectsform.cpp.

{
       if(index<0){
              currentSubjectTextEdit->setPlainText(QString(""));
              return;
       }
       
       Subject* sb=gt.rules.subjectsList.at(index);
       assert(sb);
       QString s=sb->getDetailedDescriptionWithConstraints(gt.rules);
       currentSubjectTextEdit->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: