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 MODULE_DLG_H 00022 #define MODULE_DLG_H 00023 00024 #include <QtGui> 00025 #include "Root_dlg.h" 00026 00027 #include "Name_wdgt.h" 00028 #include "Name_Abbrev_wdgt.h" 00029 #include "Number_wdgt.h" 00030 00031 //#include "ui_Module_dlg.h" 00032 00033 #include "InstItem.h" 00034 #include "ProgItem.h" 00035 #include "ModuItem.h" 00036 00037 class ModuleDlg : public RootDlg 00038 { 00039 Q_OBJECT 00040 00041 public: // Methods 00042 ModuleDlg(int btnAction, RootItem * module, RootItem * programme, QMainWindow *parent = 0); 00043 00044 inline bool setProgramme (RootItem * programme); 00045 inline ModuleItem * getModuleItem(){return dynamic_cast<ModuleItem*>(dataItem);} 00046 inline void setInstitute (InstItem * inst) {parentItem = inst;} 00047 inline ProgItem * getProgItem(){return dynamic_cast<ProgItem*>(parentItem);} 00048 inline InstItem * getInstItem(){return static_cast<InstItem*>(getProgItem()->parent());} 00049 00050 inline QString getInstName (); 00051 inline void setInstName (QString instName) {in_wdgt->setName(instName);} 00052 00053 inline QString getProgName(); 00054 inline void setProgName(QString progName) {pn_wdgt->setName(progName);} 00055 00056 inline QString getName () {return mna_wdgt->getName();} 00057 inline void setName (QString name) {mna_wdgt->setName(name);} 00058 inline QString getNameOnDB(); 00059 inline QString getAbbrevOnDB(); 00060 inline QString getAbbrev () {return mna_wdgt->getAbbrev();} 00061 inline void setAbbrev (QString name) {mna_wdgt->setAbbrev(name);} 00062 inline int getDuration () {return dno_wdgt->getNumber();} 00063 inline void setDuration (int number){dno_wdgt->setNumber(number);} 00064 inline int getWeeklyPeriods () {return pno_wdgt->getNumber();} 00065 inline void setWeeklyPeriods(int number){pno_wdgt->setNumber(number);} 00066 inline short getSemester() {return sno_wdgt->getNumber();} 00067 inline void setSemester(short number){sno_wdgt->setNumber(number);} 00068 00069 private: // Properties 00070 NameWidget * in_wdgt; // Institute Name Widget 00071 NameWidget * pn_wdgt; // Programme Name Widget 00072 NameAbbrevWidget * mna_wdgt; // Module Name & Abbreviation Widget 00073 NumberWidget * dno_wdgt; // Duration Number Widget 00074 NumberWidget * pno_wdgt; // Weekly Periods Number Widget 00075 NumberWidget * sno_wdgt; // Semester Number Widget 00076 00077 // InstItem * instItem; 00078 // ProgItem * progItem; 00079 // ModuleItem * moduleItem; 00080 00081 private: // Methods 00082 void createWidgets(); 00083 void createActions(); 00084 void initialise (int btnAction); 00085 00086 private slots: 00087 void enableBtn(); 00088 void okPressed(); 00089 }; 00090 00091 inline bool ModuleDlg::setProgramme (RootItem * programme) 00092 { 00093 if (programme != 0) 00094 if (programme->rtti() == RootItem::PROG_ITEM) 00095 { 00096 parentItem = dynamic_cast<ProgItem*>(programme); 00097 return true; 00098 } 00099 return false; 00100 } 00101 00102 inline QString ModuleDlg::getInstName () 00103 { 00104 if (getInstItem() != 0) 00105 return getInstItem()->getInstName(); 00106 else 00107 return QString(); 00108 } 00109 00110 inline QString ModuleDlg::getProgName() 00111 { 00112 if (getProgItem() != 0) 00113 return getProgItem()->getProgName(); 00114 else 00115 return QString(); 00116 } 00117 00118 inline QString ModuleDlg::getNameOnDB() 00119 { 00120 if (getModuleItem() == 0) 00121 return QString(); 00122 else 00123 return getModuleItem()->getModuName(); 00124 } 00125 00126 inline QString ModuleDlg::getAbbrevOnDB() 00127 { 00128 if (getModuleItem() == 0) 00129 return QString(); 00130 else 00131 return getModuleItem()->getModuNomenclature(); 00132 } 00133 00134 #endif