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 __ROOM_DLG_H 00022 #define __ROOM_DLG_H 00023 00024 #include <QtGui> 00025 00026 //#include "ui_Room_wdgt.h" 00027 00028 #include "Root_dlg.h" 00029 00030 #include "Name_wdgt.h" 00031 #include "Name_Abbrev_wdgt.h" 00032 #include "Number_wdgt.h" 00033 00034 #include "InstItem.h" 00035 #include "RoomItem.h" 00036 00037 #include "control_panel.h" 00038 00039 class RoomDlg : public RootDlg 00040 { 00041 Q_OBJECT 00042 00043 public: // methods 00044 RoomDlg(int btnAction, RootItem * room, RootItem * institute, QMainWindow *parent = 0); 00045 00046 inline QString getInstName (); 00047 inline void setInstName (QString instName) {in_wdgt->setName(instName);} 00048 00049 inline QString getRoomName() {return rna_wdgt->getName();} 00050 inline QString getRoomCode() {return rna_wdgt->getAbbrev();} 00051 inline int getRoomCapacity(){return cno_wdgt->getNumber();} 00052 inline void setRoomName(QString name){rna_wdgt->setName(name);} 00053 inline void setRoomCode(QString code){rna_wdgt->setAbbrev(code);} 00054 inline void setRoomCapacity(int capacity){cno_wdgt->setNumber(capacity);} 00055 00056 inline QString getNameOnDB(); 00057 inline QString getCodeOnDB(); 00058 00059 inline InstItem * getInstItem(){return static_cast<InstItem *>(parentItem);} 00060 inline RoomItem * getRoomItem(){return static_cast<RoomItem *>(dataItem);} 00061 00062 protected: // Properties 00063 NameWidget * in_wdgt; // Institute Name Widget 00064 NameAbbrevWidget * rna_wdgt; // Room Name & Abbreviation Widget 00065 NumberWidget * cno_wdgt; // Capacity Number Widget 00066 00067 private: // Methods 00068 void createWidgets(); 00069 void createActions(); 00070 void initialise (int btnAction); 00071 00072 private slots: 00073 void enableBtn(); 00074 void okPressed(); 00075 00076 private: // Properties 00077 // InstItem * instItem; 00078 // RoomItem * roomItem; 00079 00080 }; 00081 00082 inline QString RoomDlg::getInstName () 00083 { 00084 if (getInstItem() != 0) 00085 return getInstItem()->getInstName(); 00086 else 00087 return QString(); 00088 } 00089 00090 inline QString RoomDlg::getNameOnDB() 00091 { 00092 if (getRoomItem() == 0) 00093 return ""; 00094 else 00095 return getRoomItem()->getRoomName(); 00096 } 00097 00098 inline QString RoomDlg::getCodeOnDB() 00099 { 00100 if (getRoomItem() == 0) 00101 return ""; 00102 else 00103 return getRoomItem()->getRoomCode(); 00104 } 00105 00106 #endif