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

dbListManager Class Reference

class that will manage all the dbList objects More...

#include <dbListManager.h>

Collaboration diagram for dbListManager:

Collaboration graph
[legend]
List of all members.

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.
dbListInstituteList ()
 Method to return the Institutes as a dbList container.
dbListProgrammeList ()
 Method to return the Programmes as a dbList container.
dbListModuleList ()
 Method to return the Modules as a dbList container.
dbListFacultyList ()
 Method to return the Faculties as a dbList container.
dbListDepartmentList ()
 Method to return the Department as a dbList container.
dbListStaffList ()
 Method to return the Staff Members as a dbList container.
dbListRoomList ()
 Method to return the Rooms as a dbList container.
dbListMLAllocList ()
 Method to return the Allocated Modules as a dbList container.
dbListTimeSlotList ()
 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)
InstitutegetInstituteFromID (int id)
ProgrammegetProgrammeFromID (int id)
ModulegetModuleFromID (int id)
FacultygetFacultyFromID (int id)
DepartmentgetDepartmentFromID (int id)
StaffgetStaffFromID (int id)
RoomgetRoomFromID (int id)
ModLecAllocgetMLAllocFromID (int id)
InstitutegetInstFromName (QString &InstName)
ProgrammegetProgFromName (Institute *instObj, QString &ProgName)
DepartmentgetDeptFromName (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 dbListManagerInstance ()
 Method to get the singleton instance.

Classes

class  registeredModels
 class that keep track of all the models that are interested in a dbList More...

Detailed Description

class that will manage all the dbList objects

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

See also:
dbList, registeredModels

Definition at line 53 of file dbListManager.h.


Member Enumeration Documentation

enum dbListManager::registeredLists
 

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 dataLists->registerModel(model ,dbListManager::regInstitute +dbListManagerregProgramme +dbListManagerregModule );

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                         };


Member Function Documentation

void dbListManager::dump bool  details = false  ) 
 

Method used to dump basic information to stdout

Parameters:
details Display detals about each list that is being managed

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 }

Department* dbListManager::getDepartmentFromID int  id  )  [inline]
 

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

Parameters:
id The id which corresponds to the value on the database
Returns:
a pointer to the Department object or 0 if none exists

Definition at line 311 of file dbListManager.h.

00311 {return getObjFromID<Department *>(pDepartmentList,id);}

QList<Department * >* dbListManager::getDepartmentList Institute inst  )  [inline]
 

Method to return all the Department objects that belong to the given Institute

Parameters:
inst a pointer to the parent Institute
Returns:
All the departments in a QList

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));}

QList<Department * >* dbListManager::getDepartmentList Faculty faculty  )  [inline]
 

Method to return all the Department objects that belong to the given Faculty

Parameters:
faculty a pointer to the parent Faculty
Returns:
All the departments in a QList

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));}

QList<Department * >* dbListManager::getDepartmentList  )  [inline]
 

Method to return all the Department objects

Returns:
All the departments in a QList

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());}

Department* dbListManager::getDeptFromName Institute instObj,
QString &  deptName
[inline]
 

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.

Parameters:
inst The Institute for which the Department being searched for belongs to.
name The Department name which is being searched for
Returns:
a pointer to the Department object or 0 if none exists

Definition at line 360 of file dbListManager.h.

References getDepartmentList().

00360 {return getObjFromName(getDepartmentList(instObj),deptName);}

Faculty* dbListManager::getFacultyFromID int  id  )  [inline]
 

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

Parameters:
id The id which corresponds to the value on the database
Returns:
a pointer to the Faculty object or 0 if none exists

Definition at line 304 of file dbListManager.h.

00304 {return getObjFromID<Faculty *>(pFacultyList,id);}

QList<Faculty * >* dbListManager::getFacultyList Institute inst  )  [inline]
 

Method to return all the Faculty objects that belong to the given Institute

Parameters:
inst a pointer to the parent Institute
Returns:
All the faculties in a QList

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));}

QList<Faculty * >* dbListManager::getFacultyList  )  [inline]
 

Method to return all the Faculty objects

Returns:
All the Faculties in a QList

Definition at line 174 of file dbListManager.h.

References dbList::list().

Referenced by getFacultyList().

00175                         {return List<Faculty *>(pFacultyList->list());}

Institute* dbListManager::getInstFromName QString &  InstName  )  [inline]
 

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.

Parameters:
name The Institute name which is being searched for
Returns:
a pointer to the Institute object or 0 if none exists

Definition at line 340 of file dbListManager.h.

References getInstituteList().

Referenced by gf_ProgComboBox::init(), and gf_DeptComboBox::init().

00340 {return getObjFromName(getInstituteList(),InstName);}

Institute* dbListManager::getInstituteFromID int  id  )  [inline]
 

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

Parameters:
id The id which corresponds to the value on the database
Returns:
a pointer to the Institute object or 0 if none exists

Definition at line 283 of file dbListManager.h.

00283 {return getObjFromID<Institute *>(pInstituteList,id);}

QList<Institute * >* dbListManager::getInstituteList  )  [inline]
 

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());}

ModLecAlloc* dbListManager::getMLAllocFromID int  id  )  [inline]
 

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

Parameters:
id The id which corresponds to the value on the database
Returns:
a pointer to the ModLecAlloc object or 0 if none exists

Definition at line 332 of file dbListManager.h.

00332 {return getObjFromID<ModLecAlloc *>(pMLAllocList,id);}

QList<ModLecAlloc * >* dbListManager::getMLAllocList Institute inst  )  [inline]
 

Method to return all the Modules that have been Allocated to a Lecturer that belong to the given Institute

Parameters:
inst a pointer to the parent Institute
Returns:
All the ModLecAlloc objects in a QList

Definition at line 259 of file dbListManager.h.

References dbList::allChildren().

00260                         {return List<ModLecAlloc*>(pMLAllocList->allChildren(inst, true));}

QList<ModLecAlloc * >* dbListManager::getMLAllocList Programme prog  )  [inline]
 

Method to return all the Modules that have been Allocated to a Lecturer for a given Programme

Parameters:
prog a pointer to the parent Programme
Returns:
All the ModLecAlloc objects in a QList

Definition at line 252 of file dbListManager.h.

References dbList::allChildren().

00253                         {return List<ModLecAlloc*>(pMLAllocList->allChildren(prog));}

QList<ModLecAlloc * >* dbListManager::getMLAllocList  )  [inline]
 

Method to return all the Modules that have been Allocated to a Lecturer

Returns:
All the ModLecAlloc objects in a QList

Definition at line 245 of file dbListManager.h.

References dbList::list().

00246                         {return List<ModLecAlloc*>(pMLAllocList->list());}

Module* dbListManager::getModuleFromID int  id  )  [inline]
 

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

Parameters:
id The id which corresponds to the value on the database
Returns:
a pointer to the Module object or 0 if none exists

Definition at line 297 of file dbListManager.h.

00297 {return getObjFromID<Module *>(pModuleList,id);}

QList<Module * >* dbListManager::getModuleList Programme prog  )  [inline]
 

Method to return all the Modules objects that belong to the given Programme

Parameters:
prog a pointer to the parent Programme
Returns:
All the modules in a QList

Definition at line 168 of file dbListManager.h.

References dbList::allChildren().

00169                         {return List<Module *>(pModuleList->allChildren(prog));}

QList<Module * >* dbListManager::getModuleList  )  [inline]
 

Method to return all the Module objects

Returns:
All the modules in a QList

Definition at line 161 of file dbListManager.h.

References dbList::list().

Referenced by InstModel::setupModuleData().

00162                         {return List<Module *>(pModuleList->list());}

Programme* dbListManager::getProgFromName Institute instObj,
QString &  ProgName
[inline]
 

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.

Parameters:
inst The Institute for which the programme being searched for belongs to.
name The Programme name which is being searched for
Returns:
a pointer to the Programme object or 0 if none exists

Definition at line 350 of file dbListManager.h.

References getProgrammeList().

00350 {return getObjFromName(getProgrammeList(instObj),ProgName);}

Programme* dbListManager::getProgrammeFromID int  id  )  [inline]
 

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

Parameters:
id The id which corresponds to the value on the database
Returns:
a pointer to the Programme object or 0 if none exists

Definition at line 290 of file dbListManager.h.

00290 {return getObjFromID<Programme *>(pProgrammeList,id);}

QList<Programme * >* dbListManager::getProgrammeList Institute inst  )  [inline]
 

Method to return all the Programme objects that belong to the given Institute

Parameters:
inst a pointer to the parent Institute
Returns:
All the programmes in a QList

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));}

QList<Programme * >* dbListManager::getProgrammeList  )  [inline]
 

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());}

Room* dbListManager::getRoomFromID int  id  )  [inline]
 

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

Parameters:
id The id which corresponds to the value on the database
Returns:
a pointer to the Room object or 0 if none exists

Definition at line 325 of file dbListManager.h.

00325 {return getObjFromID<Room *>(pRoomList,id);}

QList<Room * >* dbListManager::getRoomList Institute inst  )  [inline]
 

Method to return all the Room objects that belong to the given Institute

Parameters:
inst a pointer to the parent Institute
Returns:
All the rooms in a QList

Definition at line 239 of file dbListManager.h.

References dbList::allChildren().

00240                         {return List<Room *>(pRoomList->allChildren(inst));}

QList<Room * >* dbListManager::getRoomList  )  [inline]
 

Method to return all the Room objects

Returns:
All the rooms in a QList

Definition at line 232 of file dbListManager.h.

References dbList::list().

00233                         {return List<Room *>(pRoomList->list());}

Staff* dbListManager::getStaffFromID int  id  )  [inline]
 

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

Parameters:
id The id which corresponds to the value on the database
Returns:
a pointer to the Staff object or 0 if none exists

Definition at line 318 of file dbListManager.h.

00318 {return getObjFromID<Staff *>(pStaffList,id);}

QList<Staff * >* dbListManager::getStaffList Institute inst  )  [inline]
 

Method to return all the Staff objects that belong to the given Institute

Parameters:
inst a pointer to the parent Institute
Returns:
All the staff members in a QList

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));}

QList<Staff * >* dbListManager::getStaffList Department dept  )  [inline]
 

Method to return all the Staff objects that belong to the given Department

Parameters:
dept a pointer to the parent Department
Returns:
All the staff members in a QList

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));}

QList<Staff * >* dbListManager::getStaffList  )  [inline]
 

Method to return all the staff objects

Returns:
All the staff members in a QList

Definition at line 210 of file dbListManager.h.

References dbList::list().

Referenced by getStaffList().

00211                         {return List<Staff*>(pStaffList->list());}

QList<TimeSlot * >* dbListManager::getTimeSlotList Institute inst  )  [inline]
 

Method to return all the TimeSlot objects that belong to the given Institute

Parameters:
inst a pointer to the parent Institute
Returns:
All the timeslots in a QList

Definition at line 273 of file dbListManager.h.

References dbList::allChildren().

00274                         {return List<TimeSlot *>(pTimeSlotList->allChildren(inst));}

QList<TimeSlot * >* dbListManager::getTimeSlotList  )  [inline]
 

Method to return all the TimeSlot objects

Returns:
All the timeslots in a QList

Definition at line 266 of file dbListManager.h.

References dbList::list().

00267                         {return List<TimeSlot *>(pTimeSlotList->list());}

void dbListManager::insert RootItem item,
dbList list,
QModelIndex &  index,
CompareDC  lessThan
 

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.

Parameters:
item The object being inserted
list The list the object belongs to
index This is either the index for which this item will belong to, that is the index of the parent object, or the index of this object. The first instance will occur when the parent is selected and the new button is pushed. The latter will occur when a sibling of the object is selected and the add button is pushed.

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 }

void dbListManager::remove RootItem item,
dbList list,
bool  cascade = true
 

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.

Parameters:
item The object being removed
list The list the object belongs to
compare member function to compare two items

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 }

void dbListManager::update RootItem item,
dbList list,
CompareRI  compare
 

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.

Parameters:
item The object being updated
list The list the object belongs to
lessThan member function to determine if item is less than another item

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 }


The documentation for this class was generated from the following files:
Generated on Thu Apr 6 16:27:18 2006 for time-table by  doxygen 1.4.4