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

ModulePage_wdgt.cpp

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 - Swdgtte 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #include "ModulePage_wdgt.h"
00021 
00022 void ModulePageWidget::init()
00023 {
00024         selectedItem = 0;
00025         InstModel *model = new InstModel(* dataLists);
00026         dataLists->registerModel(model
00027                                 ,dbListManager::regInstitute
00028                                 +dbListManager::regProgramme
00029                                 +dbListManager::regModule
00030                                 );
00031         wdgt.treeView->setModel(model);
00032         wdgt.treeView->resizeColumnToContents(0);
00033         initTabBtns(0);
00034         wdgt.treeView->installEventFilter(this);
00035 }
00036 
00037 void ModulePageWidget::btnAddClicked()
00038 {
00039         int rtti = RootItem::ABSTRACT_ITEM;
00040         QString msg;
00041         selectedItem = getSelectedItem();
00042         if (selectedItem != 0)
00043                 rtti = selectedItem->rtti();
00044                 
00045         switch (rtti)
00046         {
00047                 case RootItem::MODULE_ITEM:
00048                 {
00049                         ProgItem * pi = getProgrammeItem(selectedItem);
00050                         ModuleDlg *dlg = new ModuleDlg(BTN_ADD,0,pi,mainWindow);
00051                         displayCRUDDialog(dlg
00052                                                                         ,BTN_ADD
00053                                                                         ,dataLists->ModuleList()
00054                                                                         ,tr("Now adding the module: ")
00055                                                                         ,wdgt.treeView
00056                                                                         );
00057                         break;
00058                 }
00059                 case RootItem::PROG_ITEM:
00060                 {
00061                         InstItem * ii = getInstituteItem(selectedItem);
00062                         ProgrammeDlg *dlg = new ProgrammeDlg(BTN_ADD,0,ii,mainWindow);
00063                         displayCRUDDialog(dlg
00064                                                                         ,BTN_ADD
00065                                                                         ,dataLists->ProgrammeList()
00066                                                                         ,tr("Now adding the programme: ")
00067                                                                         ,wdgt.treeView
00068                                                                         );
00069                         break;
00070                 }
00071                 case RootItem::INST_ITEM:
00072                 default:
00073                 {
00074                         InstituteDlg *dlg = new InstituteDlg(BTN_ADD,0,0,mainWindow);
00075                         displayCRUDDialog(dlg
00076                                                                         ,BTN_ADD
00077                                                                         ,dataLists->InstituteList()
00078                                                                         ,tr("Now adding the institute: ")
00079                                                                         ,wdgt.treeView
00080                                                                         );
00081                         break;
00082                 }
00083         }
00084 }
00085 
00086 void ModulePageWidget::btnNewClicked()
00087 {
00088         int rtti = RootItem::ABSTRACT_ITEM;
00089         selectedItem = getSelectedItem();
00090         if (selectedItem != 0)
00091                 rtti = selectedItem->rtti();
00092                 
00093         switch (rtti)
00094         {
00095                 case RootItem::PROG_ITEM:
00096                 {
00097                         ProgItem * pi = getProgrammeItem(selectedItem);
00098                         ModuleDlg *dlg = new ModuleDlg(BTN_ADD,0,pi,mainWindow);
00099                         displayCRUDDialog(dlg
00100                                                                         ,BTN_ADD
00101                                                                         ,dataLists->ModuleList()
00102                                                                         ,tr("Now adding the module: ")
00103                                                                         ,wdgt.treeView
00104                                                                         );
00105                         break;
00106                 }
00107                 case RootItem::INST_ITEM:
00108                 {
00109                         InstItem * ii = getInstituteItem(selectedItem);
00110                         ProgrammeDlg *dlg = new ProgrammeDlg(BTN_ADD,0,ii,mainWindow);
00111                         displayCRUDDialog(dlg
00112                                                                         ,BTN_ADD
00113                                                                         ,dataLists->ProgrammeList()
00114                                                                         ,tr("Now adding the programme: ")
00115                                                                         ,wdgt.treeView
00116                                                                         );
00117                         break;
00118                 }
00119                 default:
00120                 {
00121                         InstituteDlg *dlg = new InstituteDlg(BTN_ADD,0,0,mainWindow);
00122                         displayCRUDDialog(dlg
00123                                                                         ,BTN_ADD
00124                                                                         ,dataLists->InstituteList()
00125                                                                         ,tr("Now adding the institute: ")
00126                                                                         ,wdgt.treeView
00127                                                                         );
00128                         break;
00129                 }
00130         }
00131 }
00132 
00133 void ModulePageWidget::btnModClicked()
00134 {
00135         int rtti = RootItem::ABSTRACT_ITEM;
00136         selectedItem = getSelectedItem();
00137         if (selectedItem != 0)
00138                 rtti = selectedItem->rtti();
00139                 
00140         switch (rtti)
00141         {
00142                 case RootItem::MODULE_ITEM:
00143                 {
00144                         ProgItem * pi = getProgrammeItem(selectedItem);
00145                         ModuleDlg *dlg = new ModuleDlg(BTN_MODIFY,selectedItem,pi,mainWindow);
00146                         displayCRUDDialog(dlg
00147                                                                         ,BTN_MODIFY
00148                                                                         ,dataLists->ModuleList()
00149                                                                         ,tr("Now modifying the module: ")
00150                                                                         ,wdgt.treeView
00151                                                                         );
00152                         break;
00153                 }
00154                 case RootItem::PROG_ITEM:
00155                 {
00156                         InstItem * ii = getInstituteItem(selectedItem);
00157                         ProgrammeDlg *dlg = new ProgrammeDlg(BTN_MODIFY,selectedItem,ii,mainWindow);
00158                         displayCRUDDialog(dlg
00159                                                                         ,BTN_MODIFY
00160                                                                         ,dataLists->ProgrammeList()
00161                                                                         ,tr("Now modifying the programme: ")
00162                                                                         ,wdgt.treeView
00163                                                                         );
00164                         break;
00165                 }
00166                 case RootItem::INST_ITEM:
00167                 default:
00168                 {
00169                         InstituteDlg *dlg = new InstituteDlg(BTN_MODIFY,selectedItem,0,mainWindow);
00170                         displayCRUDDialog(dlg
00171                                                                         ,BTN_MODIFY
00172                                                                         ,dataLists->InstituteList()
00173                                                                         ,tr("Now modifying the institute: ")
00174                                                                         ,wdgt.treeView
00175                                                                         );
00176                 }
00177         }
00178 }
00179 
00180 void ModulePageWidget::btnDelClicked()
00181 {
00182         int rtti = RootItem::ABSTRACT_ITEM;
00183         selectedItem = getSelectedItem();
00184         if (selectedItem != 0)
00185                 rtti = selectedItem->rtti();
00186                 
00187         switch (rtti)
00188         {
00189                 case RootItem::MODULE_ITEM:
00190                 {
00191                         ProgItem * pi = getProgrammeItem(selectedItem);
00192                         ModuleDlg *dlg = new ModuleDlg(BTN_DELETE,selectedItem,pi,mainWindow);
00193                         displayCRUDDialog(dlg
00194                                                                         ,BTN_DELETE
00195                                                                         ,dataLists->ModuleList()
00196                                                                         ,tr("Now deleting the module: ")
00197                                                                         ,wdgt.treeView
00198                                                                         );
00199                         break;
00200                 }
00201                 case RootItem::PROG_ITEM:
00202                 {
00203                         InstItem * ii = getInstituteItem(selectedItem);
00204                         ProgrammeDlg *dlg = new ProgrammeDlg(BTN_DELETE,selectedItem,ii,mainWindow);
00205                         displayCRUDDialog(dlg
00206                                                                         ,BTN_DELETE
00207                                                                         ,dataLists->ProgrammeList()
00208                                                                         ,tr("Now deleting the programme: ")
00209                                                                         ,wdgt.treeView
00210                                                                         );
00211                         break;
00212                 }
00213                 case RootItem::INST_ITEM:
00214                 default:
00215                 {
00216                         InstituteDlg *dlg = new InstituteDlg(BTN_DELETE,selectedItem,0,mainWindow);
00217                         displayCRUDDialog(dlg
00218                                                                         ,BTN_DELETE
00219                                                                         ,dataLists->InstituteList()
00220                                                                         ,tr("Now deleting the institute: ")
00221                                                                         ,wdgt.treeView
00222                                                                         );
00223                 }
00224         }
00225 }

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