00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "Programme_dlg.h"
00021
00022 #include "control_panel.h"
00023
00024 FacultyDlg::FacultyDlg(int btnAction
00025 ,RootItem * faculty
00026 ,RootItem * institute
00027 ,QMainWindow *parent)
00028 : RootDlg(parent)
00029 {
00030 statusBar = parent->statusBar();
00031 dataItem = dynamic_cast<FacItem *>(faculty);
00032 parentItem = dynamic_cast<InstItem *>(institute);
00033
00034 createWidgets();
00035 createActions();
00036 initialise (btnAction);
00037 }
00038
00039 void FacultyDlg::enableBtn()
00040 {
00041 QString name = getNameOnDB();
00042 QString abbrev = getAbbrevOnDB();
00043
00044 NameAbbrevRootDlg::enableBtn(name
00045 ,getName()
00046 ,abbrev
00047 ,getAbbrev()
00048 ,getInstItem()->getID()
00049 ,getFacultyItem()
00050 ,Faculty::uniqueName
00051 ,Faculty::uniqueAbbrev
00052 ,this
00053 );
00054 }
00055
00056
00057
00058 void FacultyDlg::okPressed()
00059 {
00060 if (getFacultyItem() == 0)
00061 {
00062 Faculty * facObj = new Faculty(Faculty::NOT_ON_DB,getName(), getAbbrev(), getInstItem()->getInstitute());
00063 dataItem = new FacItem(facObj,getInstItem());
00064 }
00065 else
00066 {
00067 getFacultyItem()->setFacName(getName());
00068 getFacultyItem()->setFacAbbrev(getAbbrev());
00069 }
00070 accept();
00071 }
00072
00073
00074
00075
00076 void FacultyDlg::createWidgets()
00077 {
00078 in_wdgt = new NameWidget(60, tr("Institute:"), ui.frame, ui.vboxLayout2, this);
00079 in_wdgt->disableName();
00080 fna_wdgt = new NameAbbrevWidget(80, tr("Faculty Name:")
00081 ,12, tr("Abbreviation")
00082 ,ui.frame, ui.vboxLayout2, this);
00083 }
00084
00085 void FacultyDlg::createActions()
00086 {
00087 QObject::connect(fna_wdgt->getNameWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00088 QObject::connect(fna_wdgt->getAbbrevWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00089 QObject::connect(ui.okButton, SIGNAL(clicked()), this, SLOT(okPressed()));
00090 }
00091
00092 void FacultyDlg::initialise (int btnAction)
00093 {
00094 QString name = "";
00095 QString abbrev = "";
00096
00097 if (getInstItem() != 0)
00098 setInstName(getInstName());
00099
00100 if (getFacultyItem() != 0)
00101 {
00102 name = getFacultyItem()->getFacName();
00103 abbrev = getFacultyItem()->getFacAbbrev();
00104 }
00105
00106 setName(name);
00107 setAbbrev(abbrev);
00108 RootDlg::initialise(btnAction, tr("Faculty"), name);
00109 getStatusBar()->showMessage(windowTitle());
00110 if (btnAction == ControlPanel::BTN_DELETE)
00111 {
00112 fna_wdgt->disableControls();
00113 ui.okButton->setEnabled(true);
00114 }
00115 }