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 00021 #ifndef __FACULTY_DLG_H 00022 #define __FACULTY_DLG_H 00023 00024 #include <QtGui> 00025 #include "Root_dlg.h" 00026 00027 #include "Name_wdgt.h" 00028 #include "Name_Abbrev_wdgt.h" 00029 00030 //#include "ui_Faculty_dlg.h" 00031 00032 #include "InstItem.h" 00033 #include "FacItem.h" 00034 00035 class FacultyDlg : public RootDlg 00036 { 00037 Q_OBJECT 00038 00039 public: // Methods 00040 FacultyDlg(int btnAction, RootItem * programme, RootItem * institute, QMainWindow *parent = 0); 00041 00042 inline bool setFaculty (RootItem * faculty); 00043 inline FacItem * getFacultyItem(){return static_cast<FacItem *>(dataItem);} 00044 inline void setInstitute (InstItem * inst) {parentItem = inst;} 00045 inline InstItem * getInstItem(){return static_cast<InstItem *>(parentItem);} 00046 00047 inline QString getInstName (); 00048 inline void setInstName (QString instName) {in_wdgt->setName(instName);} 00049 inline QString getName () {return fna_wdgt->getName();} 00050 inline void setName (QString name) {fna_wdgt->setName(name);} 00051 inline QString getAbbrev () {return fna_wdgt->getAbbrev();} 00052 inline void setAbbrev (QString name) {fna_wdgt->setAbbrev(name);} 00053 00054 inline QString getNameOnDB(); 00055 inline QString getAbbrevOnDB(); 00056 00057 private: // Properties 00058 // Ui::Faculty_dlg ui; 00059 NameWidget * in_wdgt; // Institute Name Widget 00060 NameAbbrevWidget * fna_wdgt; // Faculty Name & Abbreviation Widget 00061 00062 private: // Methods 00063 void createWidgets(); 00064 void createActions(); 00065 void initialise (int btnAction); 00066 00067 private slots: 00068 void enableBtn(); 00069 void okPressed(); 00070 }; 00071 00072 inline bool FacultyDlg::setFaculty (RootItem * faculty) 00073 { 00074 if (faculty != 0) 00075 if (faculty->rtti() == RootItem::FACULTY_ITEM) 00076 { 00077 dataItem = dynamic_cast<FacItem*>(faculty); 00078 return true; 00079 } 00080 return false; 00081 } 00082 00083 inline QString FacultyDlg::getInstName () 00084 { 00085 if (getInstItem() != 0) 00086 return getInstItem()->getInstName(); 00087 else 00088 return QString(); 00089 } 00090 00091 inline QString FacultyDlg::getNameOnDB() 00092 { 00093 if (dataItem == 0) 00094 return ""; 00095 else 00096 return getFacultyItem()->getFacName(); 00097 } 00098 00099 inline QString FacultyDlg::getAbbrevOnDB() 00100 { 00101 if (dataItem == 0) 00102 return ""; 00103 else 00104 return getFacultyItem()->getFacAbbrev(); 00105 } 00106 00107 #endif