00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "StaffPage_wdgt.h"
00021
00022 void StaffPageWidget::init()
00023 {
00024 selectedItem = 0;
00025 StaffModel *model = new StaffModel(dataLists);
00026 dataLists->registerModel(model
00027 ,dbListManager::regInstitute
00028 +dbListManager::regFaculty
00029 +dbListManager::regDepartment
00030 +dbListManager::regStaff
00031 );
00032 wdgt.treeView->setModel(model);
00033 wdgt.treeView->resizeColumnToContents(0);
00034 initTabBtns(0);
00035 wdgt.treeView->installEventFilter(this);
00036 }
00037
00038 void StaffPageWidget::btnAddClicked()
00039 {
00040 int rtti = RootItem::ABSTRACT_ITEM;
00041 selectedItem = getSelectedItem();
00042 if (selectedItem != 0)
00043 rtti = selectedItem->rtti();
00044
00045 switch (rtti)
00046 {
00047 case RootItem::STAFF_ITEM:
00048 {
00049 DeptItem * di = getDepartmentItem(selectedItem);
00050 StaffDlg *dlg = new StaffDlg(BTN_ADD,0,di,mainWindow);
00051 displayCRUDDialog(dlg
00052 ,BTN_ADD
00053 ,dataLists->StaffList()
00054 ,tr("Now adding the staff member: ")
00055 ,wdgt.treeView
00056 );
00057 break;
00058 }
00059 case RootItem::DEPT_ITEM:
00060 {
00061 FacItem * fi = getFacultyItem(selectedItem);
00062 DepartmentDlg *dlg = new DepartmentDlg(BTN_ADD,0,fi,mainWindow);
00063 displayCRUDDialog(dlg
00064 ,BTN_ADD
00065 ,dataLists->DepartmentList()
00066 ,tr("Now adding the department: ")
00067 ,wdgt.treeView
00068 );
00069 break;
00070 }
00071 case RootItem::FACULTY_ITEM:
00072 {
00073 InstItem * ii = getInstituteItem(selectedItem);
00074 FacultyDlg *dlg = new FacultyDlg(BTN_ADD,0,ii,mainWindow);
00075 displayCRUDDialog(dlg
00076 ,BTN_ADD
00077 ,dataLists->FacultyList()
00078 ,tr("Now adding the faculty: ")
00079 ,wdgt.treeView
00080 );
00081 break;
00082 }
00083 case RootItem::INST_ITEM:
00084 default:
00085 {
00086 InstituteDlg *dlg = new InstituteDlg(BTN_ADD,0,0,mainWindow);
00087 displayCRUDDialog(dlg
00088 ,BTN_ADD
00089 ,dataLists->InstituteList()
00090 ,tr("Now adding the institute: ")
00091 ,wdgt.treeView
00092 );
00093 break;
00094 }
00095 }
00096 }
00097
00098 void StaffPageWidget::btnNewClicked()
00099 {
00100 int rtti = RootItem::ABSTRACT_ITEM;
00101 selectedItem = getSelectedItem();
00102 if (selectedItem != 0)
00103 rtti = selectedItem->rtti();
00104
00105 switch (rtti)
00106 {
00107 case RootItem::DEPT_ITEM:
00108 {
00109 DeptItem * di = getDepartmentItem(selectedItem);
00110 StaffDlg *dlg = new StaffDlg(BTN_ADD,0,di,mainWindow);
00111 displayCRUDDialog(dlg
00112 ,BTN_ADD
00113 ,dataLists->StaffList()
00114 ,tr("Now adding the staff member: ")
00115 ,wdgt.treeView
00116 );
00117 break;
00118 }
00119 case RootItem::FACULTY_ITEM:
00120 {
00121 FacItem * fi = getFacultyItem(selectedItem);
00122 DepartmentDlg *dlg = new DepartmentDlg(BTN_ADD,0,fi,mainWindow);
00123 displayCRUDDialog(dlg
00124 ,BTN_ADD
00125 ,dataLists->DepartmentList()
00126 ,tr("Now adding the department: ")
00127 ,wdgt.treeView
00128 );
00129 break;
00130 }
00131 case RootItem::INST_ITEM:
00132 {
00133 InstItem * ii = getInstituteItem(selectedItem);
00134 FacultyDlg *dlg = new FacultyDlg(BTN_ADD,0,ii,mainWindow);
00135 displayCRUDDialog(dlg
00136 ,BTN_ADD
00137 ,dataLists->FacultyList()
00138 ,tr("Now adding the faculty: ")
00139 ,wdgt.treeView
00140 );
00141 break;
00142 }
00143 default:
00144 {
00145 InstituteDlg *dlg = new InstituteDlg(BTN_ADD,0,0,mainWindow);
00146 displayCRUDDialog(dlg
00147 ,BTN_ADD
00148 ,dataLists->InstituteList()
00149 ,tr("Now adding the institute: ")
00150 ,wdgt.treeView
00151 );
00152 break;
00153 }
00154 }
00155 }
00156
00157 void StaffPageWidget::btnModClicked()
00158 {
00159 int rtti = RootItem::ABSTRACT_ITEM;
00160 selectedItem = getSelectedItem();
00161 if (selectedItem != 0)
00162 rtti = selectedItem->rtti();
00163
00164 switch (rtti)
00165 {
00166 case RootItem::STAFF_ITEM:
00167 {
00168 DeptItem * di = getDepartmentItem(selectedItem);
00169 StaffDlg *dlg = new StaffDlg(BTN_MODIFY,selectedItem,di,mainWindow);
00170 displayCRUDDialog(dlg
00171 ,BTN_MODIFY
00172 ,dataLists->StaffList()
00173 ,tr("Now modifying the staff member: ")
00174 ,wdgt.treeView
00175 );
00176 break;
00177 }
00178 case RootItem::DEPT_ITEM:
00179 {
00180 FacItem * fi = getFacultyItem(selectedItem);
00181 DepartmentDlg *dlg = new DepartmentDlg(BTN_MODIFY,selectedItem,fi,mainWindow);
00182 displayCRUDDialog(dlg
00183 ,BTN_MODIFY
00184 ,dataLists->DepartmentList()
00185 ,tr("Now modifying the department: ")
00186 ,wdgt.treeView
00187 );
00188 break;
00189 }
00190 case RootItem::FACULTY_ITEM:
00191 {
00192 InstItem * ii = getInstituteItem(selectedItem);
00193 FacultyDlg *dlg = new FacultyDlg(BTN_MODIFY,selectedItem,ii,mainWindow);
00194 displayCRUDDialog(dlg
00195 ,BTN_MODIFY
00196 ,dataLists->FacultyList()
00197 ,tr("Now modifying the faculty: ")
00198 ,wdgt.treeView
00199 );
00200 break;
00201 }
00202 case RootItem::INST_ITEM:
00203 default:
00204 {
00205 InstituteDlg *dlg = new InstituteDlg(BTN_MODIFY,selectedItem,0,mainWindow);
00206 displayCRUDDialog(dlg
00207 ,BTN_MODIFY
00208 ,dataLists->InstituteList()
00209 ,tr("Now modifying the institute: ")
00210 ,wdgt.treeView
00211 );
00212 break;
00213 }
00214 }
00215 }
00216
00217 void StaffPageWidget::btnDelClicked()
00218 {
00219 int rtti = RootItem::ABSTRACT_ITEM;
00220 selectedItem = getSelectedItem();
00221 if (selectedItem != 0)
00222 rtti = selectedItem->rtti();
00223
00224 switch (rtti)
00225 {
00226 case RootItem::STAFF_ITEM:
00227 {
00228 DeptItem * di = getDepartmentItem(selectedItem);
00229 StaffDlg *dlg = new StaffDlg(BTN_DELETE,selectedItem,di,mainWindow);
00230 displayCRUDDialog(dlg
00231 ,BTN_DELETE
00232 ,dataLists->StaffList()
00233 ,tr("Now deleting the staff member: ")
00234 ,wdgt.treeView
00235 );
00236 break;
00237 }
00238 case RootItem::DEPT_ITEM:
00239 {
00240 FacItem * fi = getFacultyItem(selectedItem);
00241 DepartmentDlg *dlg = new DepartmentDlg(BTN_DELETE,selectedItem,fi,mainWindow);
00242 displayCRUDDialog(dlg
00243 ,BTN_DELETE
00244 ,dataLists->DepartmentList()
00245 ,tr("Now deleting the department: ")
00246 ,wdgt.treeView
00247 );
00248 break;
00249 }
00250 case RootItem::FACULTY_ITEM:
00251 {
00252 InstItem * ii = getInstituteItem(selectedItem);
00253 FacultyDlg *dlg = new FacultyDlg(BTN_DELETE,selectedItem,ii,mainWindow);
00254 displayCRUDDialog(dlg
00255 ,BTN_DELETE
00256 ,dataLists->FacultyList()
00257 ,tr("Now deleting the faculty: ")
00258 ,wdgt.treeView
00259 );
00260 break;
00261 }
00262 case RootItem::INST_ITEM:
00263 default:
00264 {
00265 InstituteDlg *dlg = new InstituteDlg(BTN_DELETE,selectedItem,0,mainWindow);
00266 displayCRUDDialog(dlg
00267 ,BTN_DELETE
00268 ,dataLists->InstituteList()
00269 ,tr("Now deleting the institute: ")
00270 ,wdgt.treeView
00271 );
00272 break;
00273 }
00274 }
00275 }