00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "institute_dlg.h"
00021
00022 InstituteDlg::InstituteDlg(int btnAction, RootItem * inst, RootItem *, QMainWindow *parent)
00023 : NameAbbrevRootDlg(60, tr("Institute Name:"), 10, tr("Abbreviation:"), parent)
00024 {
00025 statusBar = parent->statusBar();
00026 setInstitute(inst);
00027
00028 createActions();
00029 initialise (btnAction);
00030 }
00031
00032 void InstituteDlg::enableBtn()
00033 {
00034 QString name = getNameOnDB();
00035 QString abbrev = getAbbrevOnDB();
00036
00037 NameAbbrevRootDlg::enableBtn(name
00038 ,abbrev
00039 ,0
00040 ,dataItem
00041 ,Institute::uniqueName
00042 ,Institute::uniqueAbbrev);
00043 }
00044
00045 void InstituteDlg::okPressed()
00046 {
00047 if (dataItem == 0)
00048 {
00052 Institute * instObj = new Institute(Institute::NOT_ON_DB,getName(), getAbbrev());
00053 dataItem = new InstItem(instObj,0);
00054 }
00055 else
00056 {
00057 getInstItem()->setData(0,getName());
00058 getInstItem()->setData(1,getAbbrev());
00059 }
00060 accept();
00061 }
00062
00063
00064
00065
00066 void InstituteDlg::createActions()
00067 {
00068 QObject::connect(na_wdgt->getNameWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00069 QObject::connect(na_wdgt->getAbbrevWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00070 QObject::connect(ui.okButton, SIGNAL(clicked()), this, SLOT(okPressed()));
00071 }
00072
00073 void InstituteDlg::initialise (int btnAction)
00074 {
00075 QString name = "";
00076 QString abbrev = "";
00077 if (dataItem != 0)
00078 {
00079 name = getInstItem()->getInstName();
00080 abbrev = getInstItem()->getInstAbbrev();
00081 }
00082 setName(name);
00083 setAbbrev(abbrev);
00084
00085 RootDlg::initialise(btnAction, tr("institute"), name);
00086 if (btnAction == ControlPanel::BTN_DELETE)
00087 {
00088 disableControls();
00089 ui.okButton->setEnabled(true);
00090 }
00091
00092 }