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 __ROOT_PAGE_WDGT_H 00022 #define __ROOT_PAGE_WDGT_H 00023 00024 #include <QtGui> 00025 #include "Root_dlg.h" 00026 00027 #include "dbListManager.h" 00028 00029 #include "InstItem.h" 00030 #include "ProgItem.h" 00031 #include "FacItem.h" 00032 #include "DeptItem.h" 00033 00034 class ControlPanel; 00035 00036 class RootPageWidget : public QWidget 00037 { 00038 Q_OBJECT 00039 00040 public: // Data types 00041 enum DialogBtnAction {BTN_ADD = 0, BTN_MODIFY, BTN_DELETE}; 00042 public: // methods 00043 RootPageWidget(ControlPanel * window 00044 ,QWidget * widgetParent 00045 ,QBoxLayout * layoutParent 00046 ,dbListManager * pDataLists); 00047 void displayCRUDDialog(RootDlg * dlg 00048 ,DialogBtnAction btnAction 00049 ,dbList * list 00050 ,QString statusMsg 00051 ,QAbstractItemView * wdgt 00052 ); 00053 00054 00055 protected: // Properties 00056 QVBoxLayout * vboxLayout; 00057 dbListManager * dataLists; 00058 ControlPanel * mainWindow; 00059 00060 protected: // Methods 00061 inline InstItem * getInstituteItem(RootItem * item); 00062 inline ProgItem * getProgrammeItem(RootItem * item); 00063 inline FacItem * getFacultyItem(RootItem * item); 00064 inline DeptItem * getDepartmentItem(RootItem * item); 00065 00066 private slots: 00067 00068 }; 00069 00070 inline InstItem * RootPageWidget::getInstituteItem(RootItem * item) 00071 { 00072 if (item == 0) 00073 return 0; 00074 InstItem * ii = 0; 00075 if (item->rtti() == RootItem::INST_ITEM) 00076 ii = static_cast<InstItem*>(item); 00077 else 00078 return getInstituteItem(item->parent()); 00079 return ii; 00080 } 00081 00082 inline ProgItem * RootPageWidget::getProgrammeItem(RootItem * item) 00083 { 00084 if (item == 0) 00085 return 0; 00086 ProgItem * ii = 0; 00087 if (item->rtti() == RootItem::PROG_ITEM) 00088 ii = static_cast<ProgItem*>(item); 00089 else 00090 return getProgrammeItem(item->parent()); 00091 return ii; 00092 } 00093 00094 inline FacItem * RootPageWidget::getFacultyItem(RootItem * item) 00095 { 00096 if (item == 0) 00097 return 0; 00098 FacItem * ii = 0; 00099 if (item->rtti() == RootItem::FACULTY_ITEM) 00100 ii = static_cast<FacItem*>(item); 00101 else 00102 return getFacultyItem(item->parent()); 00103 return ii; 00104 } 00105 00106 inline DeptItem * RootPageWidget::getDepartmentItem(RootItem * item) 00107 { 00108 if (item == 0) 00109 return 0; 00110 DeptItem * ii = 0; 00111 if (item->rtti() == RootItem::DEPT_ITEM) 00112 ii = static_cast<DeptItem*>(item); 00113 else 00114 return getDepartmentItem(item->parent()); 00115 return ii; 00116 } 00117 00118 #endif