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

Department_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 DepartmentDlg::DepartmentDlg(int btnAction
00025                                                                          ,RootItem * dept
00026                                                                          ,RootItem * faculty
00027                                                                          ,QMainWindow *parent)
00028 : RootDlg(parent)
00029 {
00030         statusBar = parent->statusBar();
00031         dataItem = dynamic_cast<DeptItem *>(dept);
00032         parentItem = dynamic_cast<FacItem *>(faculty);
00033 
00034         createWidgets();
00035         createActions();
00036         initialise (btnAction);
00037 }
00038 
00039 
00040 void DepartmentDlg::enableBtn()
00041 {
00042         QString name = getNameOnDB();
00043         QString abbrev = getAbbrevOnDB();
00044 
00045         NameAbbrevRootDlg::enableBtn(name
00046                                     ,getName()
00047                                     ,abbrev
00048                                     ,getAbbrev()
00049                                     ,getFacItem()->getID()
00050                                     ,getDeptItem()
00051                                     ,Department::uniqueName
00052                                     ,Department::uniqueAbbrev
00053                                     ,this
00054                                     );
00055 }
00056 
00057 
00058 
00059 void DepartmentDlg::okPressed()
00060 {
00061         if (getDeptItem() == 0)
00062         {
00063                 Department * deptObj = new Department(Department::NOT_ON_DB,getName(), getAbbrev(), getFacItem()->getFaculty());
00064                 dataItem = new DeptItem(deptObj,getFacItem());
00065         }
00066         else
00067         {
00068                 getDeptItem()->setDeptName(getName());
00069                 getDeptItem()->setDeptAbbrev(getAbbrev());
00070         }
00071         accept();
00072 }
00073 
00074 /******************************************************************************
00075  * Private Methods
00076  ******************************************************************************/
00077 
00078 void DepartmentDlg::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         dna_wdgt = new NameAbbrevWidget(80, tr("Dept. Name:")
00085                                        ,12, tr("Abbreviation")
00086                                        ,ui.frame, ui.vboxLayout2, this);
00087 
00088 }
00089 
00090 void DepartmentDlg::createActions()
00091 {
00092         QObject::connect(dna_wdgt->getNameWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00093         QObject::connect(dna_wdgt->getAbbrevWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00094         QObject::connect(ui.okButton, SIGNAL(clicked()), this, SLOT(okPressed()));
00095 }
00096 
00097 void DepartmentDlg::initialise (int btnAction)
00098 {
00099         QString name = "";
00100         QString abbrev = "";
00101         if (getDeptItem() != 0)
00102         {
00103                 name = getDeptItem()->getDeptName();
00104                 abbrev = getDeptItem()->getDeptAbbrev();
00105         }
00106         if (getFacItem() != 0)
00107         {
00108                 setInstName(getInstName());
00109                 setFacName(getFacName());
00110         }
00111         
00112         setName(name);
00113         setAbbrev(abbrev);
00114         
00115         RootDlg::initialise(btnAction, tr("Department"), name);
00116         getStatusBar()->showMessage(windowTitle());
00117 
00118         if (btnAction == ControlPanel::BTN_DELETE)
00119         {
00120                 dna_wdgt->disableControls();
00121                 
00122                 ui.okButton->setEnabled(true);
00123         }
00124 }
00125 

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