#include <dbListManager.h>
Collaboration diagram for dbListManager:
Public Types | |
enum | registeredLists { regInstitute = 1, regProgramme = 2, regModule = 4, regFaculty = 8, regDepartment = 16, regStaff = 32, regRoom = 64, regMLAlloc = 128, regTimeSlot = 256 } |
Public Member Functions | |
void | registerModel (RootModel *model, int lists) |
Method to create a Registered model. | |
dbList * | InstituteList () |
Method to return the Institutes as a dbList container. | |
dbList * | ProgrammeList () |
Method to return the Programmes as a dbList container. | |
dbList * | ModuleList () |
Method to return the Modules as a dbList container. | |
dbList * | FacultyList () |
Method to return the Faculties as a dbList container. | |
dbList * | DepartmentList () |
Method to return the Department as a dbList container. | |
dbList * | StaffList () |
Method to return the Staff Members as a dbList container. | |
dbList * | RoomList () |
Method to return the Rooms as a dbList container. | |
dbList * | MLAllocList () |
Method to return the Allocated Modules as a dbList container. | |
dbList * | TimeSlotList () |
Method to return the TimeSlots as a dbList container. | |
QList< Institute * > * | getInstituteList () |
QList< Programme * > * | getProgrammeList () |
QList< Programme * > * | getProgrammeList (Institute *inst) |
QList< Module * > * | getModuleList () |
QList< Module * > * | getModuleList (Programme *prog) |
QList< Faculty * > * | getFacultyList () |
QList< Faculty * > * | getFacultyList (Institute *inst) |
QList< Department * > * | getDepartmentList () |
QList< Department * > * | getDepartmentList (Faculty *faculty) |
QList< Department * > * | getDepartmentList (Institute *inst) |
QList< Staff * > * | getStaffList () |
QList< Staff * > * | getStaffList (Department *dept) |
QList< Staff * > * | getStaffList (Institute *inst) |
QList< Room * > * | getRoomList () |
QList< Room * > * | getRoomList (Institute *inst) |
QList< ModLecAlloc * > * | getMLAllocList () |
QList< ModLecAlloc * > * | getMLAllocList (Programme *prog) |
QList< ModLecAlloc * > * | getMLAllocList (Institute *inst) |
QList< TimeSlot * > * | getTimeSlotList () |
QList< TimeSlot * > * | getTimeSlotList (Institute *inst) |
Institute * | getInstituteFromID (int id) |
Programme * | getProgrammeFromID (int id) |
Module * | getModuleFromID (int id) |
Faculty * | getFacultyFromID (int id) |
Department * | getDepartmentFromID (int id) |
Staff * | getStaffFromID (int id) |
Room * | getRoomFromID (int id) |
ModLecAlloc * | getMLAllocFromID (int id) |
Institute * | getInstFromName (QString &InstName) |
Programme * | getProgFromName (Institute *instObj, QString &ProgName) |
Department * | getDeptFromName (Institute *instObj, QString &deptName) |
void | insert (RootItem *item, dbList *list, QModelIndex &index, CompareDC lessThan) |
void | update (RootItem *item, dbList *list, CompareRI compare) |
void | remove (RootItem *item, dbList *list, bool cascade=true) |
void | dump (bool details=false) |
Static Public Member Functions | |
static dbListManager * | Instance () |
Method to get the singleton instance. | |
Classes | |
class | registeredModels |
class that keep track of all the models that are interested in a dbList More... |
This is a manager class that will ensure that all the dbList objects are synchronised with the dataabse.
For each table that exists on the database they will normally be a dbList object. It is the responsibility of the dbListManager class to ensure that these lists are created.
This class will also ensure that model that register an interest with a dbList are updated whenever the list changes. This is done through the nested class registeredModels
Definition at line 53 of file dbListManager.h.
|
The registeredLists enumeration provides a convienent way to allow a GUI to register individual lists. They can be added together to allow the same widget to register multiple classes. The following example is taken from ModulePage_wdgt.cpp Definition at line 63 of file dbListManager.h. 00064 {regInstitute = 1 00065 ,regProgramme = 2 00066 ,regModule = 4 00067 ,regFaculty = 8 00068 ,regDepartment = 16 00069 ,regStaff = 32 00070 ,regRoom = 64 00071 ,regMLAlloc = 128 00072 ,regTimeSlot = 256 00073 };
|
|
Method used to dump basic information to stdout
Definition at line 439 of file dbListManager.cpp. References dbList::at(), DataClass::getDescription(), and dbList::size(). 00440 { 00441 std::cout << "dbListManager\n"; 00442 std::cout << " pInstituteList [" << pInstituteList->size()<< "] - "; 00443 for (int i = 0; i < pInstituteList->size(); i++) 00444 { 00445 std::cout << " ("; 00446 std::cout << getProgrammeList(static_cast<Institute*>(pInstituteList->at(i)))->size(); 00447 std::cout << ")"; 00448 } 00449 std::cout << "\n"; 00450 if (details) 00451 for (int i = 0; i < pInstituteList->size(); i++) 00452 { 00453 std::cout << " " << pInstituteList->at(i)->getDescription().toStdString(); 00454 std::cout << getProgrammeList(static_cast<Institute*>(pInstituteList->at(i)))->size(); 00455 std::cout << "\n"; 00456 } 00457 std::cout << " pProgrammeList [" << pProgrammeList->size()<< "]\n"; 00458 if (details) 00459 for (int i = 0; i < pProgrammeList->size(); i++) 00460 { 00461 std::cout << " " << pProgrammeList->at(i)->getDescription().toStdString() <<"\n"; 00462 } 00463 std::cout << " pModuleList [" << pModuleList->size()<< "]\n"; 00464 if (details) 00465 for (int i = 0; i < pModuleList->size(); i++) 00466 { 00467 std::cout << " " << pModuleList->at(i)->getDescription().toStdString() <<"\n"; 00468 } 00469 std::cout << " pFacultyList [" << pFacultyList->size()<< "]\n"; 00470 if (details) 00471 for (int i = 0; i < pFacultyList->size(); i++) 00472 { 00473 std::cout << " " << pFacultyList->at(i)->getDescription().toStdString() <<"\n"; 00474 } 00475 std::cout << " pDepartmentList [" << pDepartmentList->size()<< "]\n"; 00476 if (details) 00477 for (int i = 0; i < pDepartmentList->size(); i++) 00478 { 00479 std::cout << " " << pDepartmentList->at(i)->getDescription().toStdString() <<"\n"; 00480 } 00481 std::cout << " pStaffList [" << pStaffList->size()<< "]\n"; 00482 if (details) 00483 for (int i = 0; i < pStaffList->size(); i++) 00484 { 00485 std::cout << " " << pStaffList->at(i)->getDescription().toStdString() <<"\n"; 00486 } 00487 std::cout << " pRoomList [" << pRoomList->size()<< "]\n"; 00488 if (details) 00489 for (int i = 0; i < pRoomList->size(); i++) 00490 { 00491 std::cout << " " << pRoomList->at(i)->getDescription().toStdString() <<"\n"; 00492 } 00493 std::cout << "RegisteredModels [" << pRegisteredModels.size()<< "]\n"; 00494 if (details) 00495 for (int i = 0; i < pRegisteredModels.size(); i++) 00496 { 00497 pRegisteredModels.at(i)->dump(); 00498 } 00499 }
|
|
Method to return the Department object from the id this will be the id that is used as the primary key on the database if the ID doesn't exist then zero is returned
Definition at line 311 of file dbListManager.h.
|
|
Method to return all the Department objects that belong to the given Institute
Definition at line 203 of file dbListManager.h. References dbList::allChildren(), and getDepartmentList(). 00204 {if (inst == 0) return getDepartmentList(); 00205 else return List<Department*>(pDepartmentList->allChildren(inst,true));}
|
|
Method to return all the Department objects that belong to the given Faculty
Definition at line 195 of file dbListManager.h. References dbList::allChildren(), and getDepartmentList(). 00196 {if (faculty == 0) return getDepartmentList(); 00197 else return List<Department*>(pDepartmentList->allChildren(faculty));}
|
|
Method to return all the Department objects
Definition at line 188 of file dbListManager.h. References dbList::list(). Referenced by getDepartmentList(), getDeptFromName(), and gf_DeptComboBox::init(). 00189 {return List<Department*>(pDepartmentList->list());}
|
|
Method to return the Department object that matches with the name passed in. If a valid Institute object is passed in as the first parameter then the search will be restricted to Departments within that Institute. If more than one Department exists with that name the first will be returned.
Definition at line 360 of file dbListManager.h. References getDepartmentList(). 00360 {return getObjFromName(getDepartmentList(instObj),deptName);}
|
|
Method to return the Faculty object from the id this will be the id that is used as the primary key on the database if the ID doesn't exist then zero is returned
Definition at line 304 of file dbListManager.h.
|
|
Method to return all the Faculty objects that belong to the given Institute
Definition at line 181 of file dbListManager.h. References dbList::allChildren(), and getFacultyList(). 00182 {if (inst == 0) return getFacultyList(); 00183 else return List<Faculty *>(pFacultyList->allChildren(inst));}
|
|
Method to return all the Faculty objects
Definition at line 174 of file dbListManager.h. References dbList::list(). Referenced by getFacultyList(). 00175 {return List<Faculty *>(pFacultyList->list());}
|
|
Method to return the Institute object that matches with the name passed in. If more than one Institite exists with that name the first will be returned.
Definition at line 340 of file dbListManager.h. References getInstituteList(). Referenced by gf_ProgComboBox::init(), and gf_DeptComboBox::init(). 00340 {return getObjFromName(getInstituteList(),InstName);}
|
|
Method to return the Institute object from the id this will be the id that is used as the primary key on the database if the ID doesn't exist then zero is returned
Definition at line 283 of file dbListManager.h.
|
|
Method to return the Institute objects in a QList Definition at line 143 of file dbListManager.h. References dbList::list(). Referenced by getInstFromName(), gf_InstComboBox::init(), and InstModel::setupInstData(). 00144 {return List<Institute *>(pInstituteList->list());}
|
|
Method to return the ModLecAlloc object from the id this will be the id that is used as the primary key on the database if the ID doesn't exist then zero is returned
Definition at line 332 of file dbListManager.h.
|
|
Method to return all the Modules that have been Allocated to a Lecturer that belong to the given Institute
Definition at line 259 of file dbListManager.h. References dbList::allChildren(). 00260 {return List<ModLecAlloc*>(pMLAllocList->allChildren(inst, true));}
|
|
Method to return all the Modules that have been Allocated to a Lecturer for a given Programme
Definition at line 252 of file dbListManager.h. References dbList::allChildren(). 00253 {return List<ModLecAlloc*>(pMLAllocList->allChildren(prog));}
|
|
Method to return all the Modules that have been Allocated to a Lecturer
Definition at line 245 of file dbListManager.h. References dbList::list(). 00246 {return List<ModLecAlloc*>(pMLAllocList->list());}
|
|
Method to return the Module object from the id this will be the id that is used as the primary key on the database if the ID doesn't exist then zero is returned
Definition at line 297 of file dbListManager.h.
|
|
Method to return all the Modules objects that belong to the given Programme
Definition at line 168 of file dbListManager.h. References dbList::allChildren(). 00169 {return List<Module *>(pModuleList->allChildren(prog));}
|
|
Method to return all the Module objects
Definition at line 161 of file dbListManager.h. References dbList::list(). Referenced by InstModel::setupModuleData(). 00162 {return List<Module *>(pModuleList->list());}
|
|
Method to return the Programme object that matches with the name passed in. If a valid Institute object is passed in as the first parameter then the search will be restricted to Programmes within that Institute. If more than one Programme exists with that name the first will be returned.
Definition at line 350 of file dbListManager.h. References getProgrammeList(). 00350 {return getObjFromName(getProgrammeList(instObj),ProgName);}
|
|
Method to return the Programme object from the id this will be the id that is used as the primary key on the database if the ID doesn't exist then zero is returned
Definition at line 290 of file dbListManager.h.
|
|
Method to return all the Programme objects that belong to the given Institute
Definition at line 154 of file dbListManager.h. References dbList::allChildren(), and getProgrammeList(). 00155 {if (inst == 0) return getProgrammeList(); 00156 else return List<Programme *>(pProgrammeList->allChildren(inst));}
|
|
Method to return the Programme objects in a QList Definition at line 147 of file dbListManager.h. References dbList::list(). Referenced by getProgFromName(), getProgrammeList(), gf_ProgComboBox::init(), and InstModel::setupProgData(). 00148 {return List<Programme *>(pProgrammeList->list());}
|
|
Method to return the Room object from the id this will be the id that is used as the primary key on the database if the ID doesn't exist then zero is returned
Definition at line 325 of file dbListManager.h.
|
|
Method to return all the Room objects that belong to the given Institute
Definition at line 239 of file dbListManager.h. References dbList::allChildren(). 00240 {return List<Room *>(pRoomList->allChildren(inst));}
|
|
Method to return all the Room objects
Definition at line 232 of file dbListManager.h. References dbList::list(). 00233 {return List<Room *>(pRoomList->list());}
|
|
Method to return the Staff object from the id this will be the id that is used as the primary key on the database if the ID doesn't exist then zero is returned
Definition at line 318 of file dbListManager.h.
|
|
Method to return all the Staff objects that belong to the given Institute
Definition at line 225 of file dbListManager.h. References dbList::allChildren(), and getStaffList(). 00226 {if (inst == 0) return getStaffList(); 00227 else return List<Staff*>(pStaffList->allChildren(inst,true));}
|
|
Method to return all the Staff objects that belong to the given Department
Definition at line 217 of file dbListManager.h. References dbList::allChildren(), and getStaffList(). 00218 {if (dept == 0) return getStaffList(); 00219 else return List<Staff*>(pStaffList->allChildren(dept,true));}
|
|
Method to return all the staff objects
Definition at line 210 of file dbListManager.h. References dbList::list(). Referenced by getStaffList(). 00211 {return List<Staff*>(pStaffList->list());}
|
|
Method to return all the TimeSlot objects that belong to the given Institute
Definition at line 273 of file dbListManager.h. References dbList::allChildren(). 00274 {return List<TimeSlot *>(pTimeSlotList->allChildren(inst));}
|
|
Method to return all the TimeSlot objects
Definition at line 266 of file dbListManager.h. References dbList::list(). 00267 {return List<TimeSlot *>(pTimeSlotList->list());}
|
|
Method used to insert an object into a given list, and then onto the database. This method will use the updateRMInsert() function to ensure that this insert is reflected in all registered widgets.
Definition at line 357 of file dbListManager.cpp. References dbList::at(), RootItem::dbSave(), RootItem::getItemData(), dbList::insert(), and dbList::size(). Referenced by RootPageWidget::displayCRUDDialog(). 00358 { 00359 DataClass * dataObj = item->getItemData(); 00360 int posn = 0; 00361 int i = 0; 00362 while (i < list->size()) 00363 { 00364 if (lessThan(list->at(i),dataObj)) 00365 break; 00366 posn = i; 00367 i++; 00368 } 00369 if (i == list->size()) 00370 posn = i; 00371 list->insert(posn,dataObj); 00372 updateRMInsert(list, item, index, posn); 00373 // Now save the item on the database 00374 item->dbSave(); 00375 }
|
|
Method used to remove an object that currently on a list, and then reflect these changes on the database. This method will use the updateRMDelete() function to ensure that this deletion is reflected in all registered widgets.
Definition at line 387 of file dbListManager.cpp. References dbList::at(), RootItem::dbDelete(), RootItem::getItemData(), and dbList::remove(). Referenced by RootPageWidget::displayCRUDDialog(). 00388 { 00389 DataClass * dataObj = item->getItemData(); 00390 int posn = 0; 00391 while (posn < list->size()) 00392 { 00393 if (list->at(posn) == dataObj) 00394 { 00395 list->remove(posn); 00396 break; 00397 } 00398 posn++; 00399 } 00400 // Cascade delete on the dbLists 00401 if (cascade) 00402 removeAllChilden(dataObj); 00403 // Delete from the Models (cascade delete is inherent in the data structure) 00404 updateRMDelete(list, dataObj); 00405 // Now remove the item from the database (cascade delete is on the database) 00406 item->dbDelete(); 00407 }
|
|
Method used to update an object that is already on a given list, and then reflect these changes on the database. This method will use the updateRMUpdate() function to ensure that this update is reflected in all registered widgets.
Definition at line 378 of file dbListManager.cpp. References RootItem::dbSave(), DataClass::dcCompareCI(), RootItem::getItemData(), and dbList::resort(). Referenced by RootPageWidget::displayCRUDDialog(). 00379 { 00380 DataClass * dataObj = item->getItemData(); 00381 list->resort(DataClass::dcCompareCI); 00382 updateRMUpdate(list, dataObj, compare); 00383 // Now save the item on the database 00384 item->dbSave(); 00385 }
|