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

control_panel.h

00001 
00018 /***************************************************************************
00019  *   Copyright (C) 2006 by Graeme Foster                                   *
00020  *   email    foster.graeme@gmail.com                                      *
00021  *                                                                         *
00022  *   This program is free software; you can redistribute it and/or modify  *
00023  *   it under the terms of the GNU General Public License as published by  *
00024  *   the Free Software Foundation; either version 2 of the License, or     *
00025  *   (at your option) any later version.                                   *
00026  *                                                                         *
00027  *   This program is distributed in the hope that it will be useful,       *
00028  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00029  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00030  *   GNU General Public License for more details.                          *
00031  *                                                                         *
00032  *   You should have received a copy of the GNU General Public License     *
00033  *   along with this program; if not, write to the                         *
00034  *   Free Software Foundation, Inc.,                                       *
00035  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00036  ***************************************************************************/
00037 
00038 #ifndef CONTROL_PANEL_H
00039 #define CONTROL_PANEL_H
00040 
00041 #include "ui_control_panel.h"
00042 
00043 #include "institute_dlg.h"
00044 #include "Programme_dlg.h"
00045 #include "Module_dlg.h"
00046 #include "Faculty_dlg.h"
00047 #include "Department_dlg.h"
00048 #include "Staff_dlg.h"
00049 #include "Room_dlg.h"
00050 
00051 #include "GUIPref.h"
00052 #include "dbListManager.h"
00053 
00054 #include "InstModel.h"
00055 #include "StaffModel.h"
00056 #include "RoomModel.h"
00057 #include "ModuleModel.h"
00058 #include "MLAllocModel.h"
00059 #include "MLEnrolModel.h"
00060 
00061 
00062 #include "RootItem.h"
00063 #include "InstItem.h"
00064 
00065 #include "sql.h"
00066 
00067 class ModulePageWidget;
00068 class StaffPageWidget;
00069 class RoomPageWidget;
00070 class ModuleAllocPageWidget;
00071 class ModuleEnrolPageWidget;
00072 class TimeSlotPageWidget;
00073 
00074 class ControlPanel : public QMainWindow
00075 {
00076     Q_OBJECT
00077 
00078 public: // Methods
00079         ControlPanel(dbListManager *pDataLists, QMainWindow *parent = 0);
00080 private: // Data types
00081         enum TabPage {MODULE_TAB =0, STAFF_TAB, ROOM_TAB, ALLOCATION_TAB, ENROL_TAB};
00082         typedef  void (dbListManager::*MemFn)(RootItem * dataItem);
00083 
00084 public: // Data types
00085         enum DialogBtnAction {BTN_ADD = 0, BTN_MODIFY, BTN_DELETE};
00086         
00087 private:        // Properties
00088         Ui::ControlPanel ui;
00089         ModulePageWidget      *   module_wdgt;
00090         StaffPageWidget       *   staff_wdgt;
00091         RoomPageWidget        *   room_wdgt;
00092         ModuleAllocPageWidget *   modAlloc_wdgt;
00093         ModuleEnrolPageWidget *   modEnrol_wdgt;
00094         TimeSlotPageWidget    *   timeslot_wdgt;
00095         
00096         dbListManager * dataLists;
00097         
00098         // Selected Items
00099         RootItem * selectedItem;
00100         // Menu properties
00101         QMenu * fileMenu;
00102         QMenu * editMenu;
00103         QMenu * actionMenu;
00104         QMenu * helpMenu;
00105         
00106         // Menu items (or actions)
00107         // File Menu
00108         QAction * saveAsAct;
00109         QAction * printAct;
00110         QAction * exitAct;
00111         // Edit Menu
00112         QAction * cutAct;
00113         QAction * copyAct;
00114         QAction * pasteAct;
00115         QAction * rollbackAct;
00116         QAction * preferencesAct;
00117         // Action Menu
00118         QAction * moduleAct;
00119         QAction * staffAct;
00120         // Help Menu
00121         QAction * timetableHelpAct;
00122         QAction * timetableAboutAct;
00123         
00124         QVBoxLayout * addVLayout(QWidget *wdgt);
00125 private slots:
00126         void fileSaveAs();
00127         void filePrint();
00128         void fileExit();
00129         void editCut();
00130         void editCopy();
00131         void editPaste();
00132         void editRollback();
00133         void editPreferences();
00134         void actionModule();
00135         void actionStaff();
00136         void helpTimetableHelp();
00137         void helpTimetableAbout();
00138         
00139 private:        // methods
00140         void createMenu();
00141         void createActions();
00142         void readSettings();
00143         void writeSettings();
00144         
00145         void initModuleTab();
00146         void initStaffTab();
00147         void initRoomTab();
00148         void initRoomTabBtns(RootItem * obj);
00149         void initModAllocTab();
00150         void initEnrolTab();
00151         void initTimeSlotTab();
00152         
00153         // Get parent Items
00154         inline InstItem *  getInstituteItem(RootItem * item);
00155         inline ProgItem *  getProgrammeItem(RootItem * item);
00156         inline FacItem  *  getFacultyItem(RootItem * item);
00157         inline DeptItem *  getDepartmentItem(RootItem * item);
00158 
00159         void hideModuleRow(Module * mod);
00160         void showModuleRow(Module * mod);
00161         inline int getModuleRow(Module * mod, ModuleModel * model){return model->findModule(mod);}
00162 protected: // event methods
00163         TabPage getTab(QWidget * page);
00164         void closeEvent(QCloseEvent *event);
00165 };
00166 
00167 inline InstItem *  ControlPanel::getInstituteItem(RootItem * item)
00168 {
00169         if (item == 0)
00170                 return 0;
00171         InstItem * ii = 0;
00172         if (item->rtti() == RootItem::INST_ITEM)
00173                 ii = static_cast<InstItem*>(item);
00174         else 
00175                 return getInstituteItem(item->parent());
00176         return ii;
00177 }
00178 
00179 inline ProgItem *  ControlPanel::getProgrammeItem(RootItem * item)
00180 {
00181         if (item == 0)
00182                 return 0;
00183         ProgItem * ii = 0;
00184         if (item->rtti() == RootItem::PROG_ITEM)
00185                 ii = static_cast<ProgItem*>(item);
00186         else 
00187                 return getProgrammeItem(item->parent());
00188         return ii;
00189 }
00190 
00191 inline FacItem  *  ControlPanel::getFacultyItem(RootItem * item)
00192 {
00193         if (item == 0)
00194                 return 0;
00195         FacItem * ii = 0;
00196         if (item->rtti() == RootItem::FACULTY_ITEM)
00197                 ii = static_cast<FacItem*>(item);
00198         else 
00199                 return getFacultyItem(item->parent());
00200         return ii;
00201 }
00202 
00203 inline DeptItem *  ControlPanel::getDepartmentItem(RootItem * item)
00204 {
00205         if (item == 0)
00206                 return 0;
00207         DeptItem * ii = 0;
00208         if (item->rtti() == RootItem::DEPT_ITEM)
00209                 ii = static_cast<DeptItem*>(item);
00210         else 
00211                 return getDepartmentItem(item->parent());
00212         return ii;
00213 }
00214 
00215 #include "ModulePage_wdgt.h"
00216 #include "StaffPage_wdgt.h"
00217 #include "RoomPage_wdgt.h"
00218 #include "ModuleAllocPage_wdgt.h"
00219 #include "ModuleEnrolPage_wdgt.h"
00220 #include "TimeSlotPage_wdgt.h"
00221 
00222 #endif

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