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

Faculty_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 "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  * Private Methods
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 }

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