Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

Staff_dlg.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Graeme Foster                                   *
00003  *   email    foster.graeme@gmail.com                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #include "Staff_dlg.h"
00021 
00022 #include "control_panel.h"
00023 
00024 StaffDlg::StaffDlg(int btnAction
00025                                                 ,RootItem * staff
00026                                                 ,RootItem * dept
00027                                                 ,QMainWindow *parent)
00028 : RootDlg(parent)
00029 {
00030         statusBar = parent->statusBar();
00031         setStaff(staff);
00032         parentItem = dynamic_cast<DeptItem *>(dept);
00033         
00034         createWidgets();
00035         createActions();
00036         initialise (btnAction);
00037 }
00038 
00039 void StaffDlg::enableBtn()
00040 {
00041         QString fName = getFNameOnDB();
00042         QString lName = getLNameOnDB();
00043 
00044         NameAbbrevRootDlg::enableBtn(fName
00045                                     ,getFName()
00046                                     ,lName
00047                                     ,getLName()
00048                                     ,getDeptItem()->getID()
00049                                     ,getStaffItem()
00050                                     ,Staff::uniqueTrue
00051                                     ,Staff::uniqueTrue
00052                                     ,this
00053                                     );
00054 
00055 }
00056 
00057 
00058 
00059 void StaffDlg::okPressed()
00060 {
00061         if (getStaffItem() == 0)
00062         {
00063                 Staff * staffObj = new Staff(Staff::NOT_ON_DB,getFName(), getLName(), getDeptItem()->getDepartment());
00064                 dataItem = new StaffItem(staffObj,getDeptItem());
00065         }
00066         else
00067         {
00068                 getStaffItem()->setStaffFName(getFName());
00069                 getStaffItem()->setStaffLName(getLName());
00070         }
00071         accept();
00072 }
00073 
00074 /******************************************************************************
00075  * Private Methods
00076  ******************************************************************************/
00077 
00078 void StaffDlg::createWidgets()
00079 {
00080         in_wdgt  = new NameWidget(60, tr("Institute:"), ui.frame, ui.vboxLayout2, this);
00081         in_wdgt->disableName();
00082         fn_wdgt  = new NameWidget(80, tr("Faculty:"), ui.frame, ui.vboxLayout2, this);
00083         fn_wdgt->disableName();
00084         dn_wdgt  = new NameWidget(80, tr("Department:"), ui.frame, ui.vboxLayout2, this);
00085         dn_wdgt->disableName();
00086         sna_wdgt = new NameAbbrevWidget(60, tr("First Name:")
00087                                        ,60, tr("Last Name:")
00088                                        ,ui.frame, ui.vboxLayout2, this);
00089 
00090 }
00091 
00092 void StaffDlg::createActions()
00093 {
00094         QObject::connect(sna_wdgt->getNameWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00095         QObject::connect(sna_wdgt->getAbbrevWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00096         QObject::connect(ui.okButton, SIGNAL(clicked()), this, SLOT(okPressed()));
00097 }
00098 
00099 void StaffDlg::initialise (int btnAction)
00100 {
00101         QString fName = "";
00102         QString lName = "";
00103         QString name;
00104 
00105         if (getDeptItem() != 0)
00106         {
00107                 setInstName(getInstName());
00108                 setFacName(getFacName());
00109                 setDeptName(getDeptName());
00110         }
00111 
00112         if (getStaffItem() != 0)
00113         {
00114                 fName = getStaffItem()->getStaffFName();
00115                 lName = getStaffItem()->getStaffLName();
00116                 name = getStaffItem()->getDescription();
00117         }
00118         
00119         setFName(fName);
00120         setLName(lName);
00121 
00122         RootDlg::initialise(btnAction, tr("Staff"), name);
00123         getStatusBar()->showMessage(windowTitle());
00124 
00125         if (btnAction == ControlPanel::BTN_DELETE)
00126         {
00127                 sna_wdgt->disableControls();
00128                 ui.okButton->setEnabled(true);
00129         }
00130 }
00131 

Generated on Thu Apr 6 16:27:17 2006 for time-table by  doxygen 1.4.4