00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "InstModel.h"
00021
00022 InstModel::InstModel(dbListManager &dataLists, QObject *parent)
00023 : RootModel(parent)
00024 {
00025 Institute * rootObj;
00026 rootObj = new Institute (0,tr("Institute Name"), tr("Abbreviation"));
00027 rootItem = new InstItem(rootObj);
00028 setupInstData(dataLists,rootItem);
00029 }
00030
00031
00032
00033
00034 QVariant InstModel::headerData(int section, Qt::Orientation orientation,
00035 int role) const
00036 {
00037 if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
00038 switch (section)
00039 {
00040 case 0:
00041 return tr("Name");
00042 case 1:
00043 return tr("Abbrev");
00044 case 2:
00045 return tr("Duration");
00046 case 3:
00047 return tr("WeeklyPeriods");
00048 default:
00049 return "";
00050 }
00051 return QVariant();
00052 }
00053
00054
00055
00056
00057 void InstModel::setupInstData(dbListManager &dataLists, RootItem * parent)
00058 {
00059 Institute * instObj;
00060 InstItem * iiObj;
00061 QList<Institute * > * instList = dataLists.getInstituteList();
00062
00063 for (int iCnt = 0; iCnt < instList->size(); ++iCnt)
00064 {
00065 instObj = instList->at(iCnt);
00066 iiObj = new InstItem(instObj, parent);
00067 parent->insertChild(iiObj);
00068 setupProgData(dataLists, iiObj);
00069 }
00070 }
00071
00072 void InstModel::setupProgData(dbListManager &dataLists, InstItem * parent)
00073 {
00074 Programme * progObj;
00075 ProgItem * piObj;
00076 QList<Programme * > * selectedProgList;
00077
00078 selectedProgList = dataLists.getProgrammeList(parent->getItemData());
00079 for (int pCnt = 0; pCnt < selectedProgList->size(); ++pCnt)
00080 {
00081 progObj = selectedProgList->at(pCnt);
00082 piObj = new ProgItem(progObj, parent,2);
00083 parent->insertChild(piObj);
00084 setupModuleData(dataLists, piObj);
00085 }
00086 }
00087
00088 void InstModel::setupModuleData(dbListManager &dataLists, ProgItem * parent)
00089 {
00090 Module * moduleObj;
00091 ModuleItem * miObj;
00092 QList<Module * > * selectedModuleList;
00093
00094 selectedModuleList = dataLists.getModuleList(parent->getItemData());
00095 for (int mCnt = 0; mCnt < selectedModuleList->size(); ++mCnt)
00096 {
00097 moduleObj = selectedModuleList->at(mCnt);
00098 miObj = new ModuleItem(moduleObj, parent);
00099 parent->insertChild(miObj);
00100 }
00101 }