00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "RoomPage_wdgt.h"
00021
00022 void RoomPageWidget::init()
00023 {
00024 selectedItem = 0;
00025 RoomModel *model = new RoomModel(dataLists);
00026 dataLists->registerModel(model
00027 ,dbListManager::regInstitute
00028 +dbListManager::regRoom
00029 );
00030 wdgt.treeView->setModel(model);
00031 wdgt.treeView->resizeColumnToContents(0);
00032 initTabBtns(0);
00033 wdgt.treeView->installEventFilter(this);
00034 }
00035
00036 void RoomPageWidget::btnAddClicked()
00037 {
00038 int rtti = RootItem::ABSTRACT_ITEM;
00039 selectedItem = getSelectedItem();
00040 if (selectedItem != 0)
00041 rtti = selectedItem->rtti();
00042
00043 switch (rtti)
00044 {
00045 case RootItem::ROOM_ITEM:
00046 {
00047 InstItem * ii = getInstituteItem(selectedItem);
00048 RoomDlg *dlg = new RoomDlg(BTN_ADD,0,ii,mainWindow);
00049 displayCRUDDialog(dlg
00050 ,BTN_ADD
00051 ,dataLists->FacultyList()
00052 ,tr("Now adding the room: ")
00053 ,wdgt.treeView
00054 );
00055 break;
00056 }
00057 case RootItem::INST_ITEM:
00058 default:
00059 {
00060 InstituteDlg *dlg = new InstituteDlg(BTN_ADD,0,0,mainWindow);
00061 displayCRUDDialog(dlg
00062 ,BTN_ADD
00063 ,dataLists->InstituteList()
00064 ,tr("Now adding the institute: ")
00065 ,wdgt.treeView
00066 );
00067 break;
00068 }
00069 }
00070 }
00071
00072 void RoomPageWidget::btnNewClicked()
00073 {
00074 int rtti = RootItem::ABSTRACT_ITEM;
00075 selectedItem = getSelectedItem();
00076 if (selectedItem != 0)
00077 rtti = selectedItem->rtti();
00078
00079 switch (rtti)
00080 {
00081 case RootItem::INST_ITEM:
00082 {
00083 InstItem * ii = getInstituteItem(selectedItem);
00084 RoomDlg *dlg = new RoomDlg(BTN_ADD,0,ii,mainWindow);
00085 displayCRUDDialog(dlg
00086 ,BTN_ADD
00087 ,dataLists->FacultyList()
00088 ,tr("Now adding the room: ")
00089 ,wdgt.treeView
00090 );
00091 break;
00092 }
00093 default:
00094 {
00095 InstituteDlg *dlg = new InstituteDlg(BTN_ADD,0,0,mainWindow);
00096 displayCRUDDialog(dlg
00097 ,BTN_ADD
00098 ,dataLists->InstituteList()
00099 ,tr("Now adding the institute: ")
00100 ,wdgt.treeView
00101 );
00102 break;
00103 }
00104 }
00105 }
00106
00107 void RoomPageWidget::btnModClicked()
00108 {
00109 int rtti = RootItem::ABSTRACT_ITEM;
00110 selectedItem = getSelectedItem();
00111 if (selectedItem != 0)
00112 rtti = selectedItem->rtti();
00113
00114 switch (rtti)
00115 {
00116 case RootItem::ROOM_ITEM:
00117 {
00118 InstItem * ii = getInstituteItem(selectedItem);
00119 RoomDlg *dlg = new RoomDlg(BTN_MODIFY,selectedItem,ii,mainWindow);
00120 displayCRUDDialog(dlg
00121 ,BTN_MODIFY
00122 ,dataLists->FacultyList()
00123 ,tr("Now modifying the room: ")
00124 ,wdgt.treeView
00125 );
00126 break;
00127 }
00128 case RootItem::INST_ITEM:
00129 default:
00130 {
00131 InstituteDlg *dlg = new InstituteDlg(BTN_MODIFY,selectedItem,0,mainWindow);
00132 displayCRUDDialog(dlg
00133 ,BTN_MODIFY
00134 ,dataLists->InstituteList()
00135 ,tr("Now modifying the institute: ")
00136 ,wdgt.treeView
00137 );
00138 break;
00139 }
00140 }
00141 }
00142
00143 void RoomPageWidget::btnDelClicked()
00144 {
00145 int rtti = RootItem::ABSTRACT_ITEM;
00146 selectedItem = getSelectedItem();
00147 if (selectedItem != 0)
00148 rtti = selectedItem->rtti();
00149
00150 switch (rtti)
00151 {
00152 case RootItem::ROOM_ITEM:
00153 {
00154 InstItem * ii = getInstituteItem(selectedItem);
00155 RoomDlg *dlg = new RoomDlg(BTN_DELETE,selectedItem,ii,mainWindow);
00156 displayCRUDDialog(dlg
00157 ,BTN_DELETE
00158 ,dataLists->FacultyList()
00159 ,tr("Now deleting the room: ")
00160 ,wdgt.treeView
00161 );
00162 break;
00163 }
00164 case RootItem::INST_ITEM:
00165 default:
00166 {
00167 InstituteDlg *dlg = new InstituteDlg(BTN_DELETE,selectedItem,0,mainWindow);
00168 displayCRUDDialog(dlg
00169 ,BTN_DELETE
00170 ,dataLists->InstituteList()
00171 ,tr("Now deleting the institute: ")
00172 ,wdgt.treeView
00173 );
00174 break;
00175 }
00176 }
00177 }