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 ProgrammeDlg::ProgrammeDlg(int btnAction
00025 ,RootItem * programme
00026 ,RootItem * institute
00027 ,QMainWindow *parent)
00028 : NameRootDlg(60, tr("Institute Name:"), parent)
00029 , NameAbbrevRootDlg(80, tr("Prog. Name:"), 12, tr("Abbreviation:"), parent)
00030 {
00031 dataItem = dynamic_cast<ProgItem *>(programme);
00032 parentItem = dynamic_cast<InstItem *>(institute);
00033
00034 if (parentItem != 0)
00035 setInstName(getInstName());
00036
00037 createActions();
00038 initialise (btnAction);
00039 }
00040
00041
00042 void ProgrammeDlg::enableBtn()
00043 {
00044 QString name = getNameOnDB();
00045 QString abbrev = getAbbrevOnDB();
00046 NameAbbrevRootDlg::enableBtn(name
00047 ,abbrev
00048 ,parentItem->getID()
00049 ,getProgItem()
00050 ,Programme::uniqueName
00051 ,Programme::uniqueAbbrev);
00052 }
00053
00054
00055
00056 void ProgrammeDlg::okPressed()
00057 {
00058 if (dataItem == 0)
00059 {
00060 Programme * progObj = new Programme(Programme::NOT_ON_DB
00061 ,NameAbbrevRootDlg::getName()
00062 ,getAbbrev()
00063 ,getInstItem()->getInstitute()
00064 );
00065 dataItem = new ProgItem(progObj,getInstItem());
00066 }
00067 else
00068 {
00069 getProgItem()->setProgName(NameAbbrevRootDlg::getName());
00070 getProgItem()->setProgAbbrev(getAbbrev());
00071 }
00072 accept();
00073 }
00074
00075
00076
00077
00078
00079 void ProgrammeDlg::createActions()
00080 {
00081 QObject::connect(na_wdgt->getNameWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00082 QObject::connect(na_wdgt->getAbbrevWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00083 QObject::connect(ui.okButton, SIGNAL(clicked()), this, SLOT(okPressed()));
00084 }
00085
00086 void ProgrammeDlg::initialise (int btnAction)
00087 {
00088 QString name = "";
00089 QString abbrev = "";
00090 if (dataItem != 0)
00091 {
00092 name = getProgItem()->getProgName();
00093 abbrev = getProgItem()->getProgAbbrev();
00094 }
00095 n_wdgt->disableName();
00096
00097 na_wdgt->setName(name);
00098 na_wdgt->setAbbrev(abbrev);
00099
00100 RootDlg::initialise(btnAction, tr("programme"), name);
00101
00102 getStatusBar()->showMessage(windowTitle());
00103
00104 if (btnAction == ControlPanel::BTN_DELETE)
00105 {
00106 NameAbbrevRootDlg::disableControls();
00107 ui.okButton->setEnabled(true);
00108 }
00109 }