00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "MLEnrolModel.h"
00021
00022 MLEnrolModel::MLEnrolModel(dbListManager * dataLists, Institute* inst, QObject *parent)
00023 : RootModel(parent)
00024 {
00025 rootItem = new InstItem(inst);
00026 setupData(*dataLists, rootItem);
00027 }
00028
00029
00030
00031
00032 int MLEnrolModel::columnCount(const QModelIndex &) const
00033 {
00034 return 7;
00035 }
00036
00037 QVariant MLEnrolModel::headerData(int section, Qt::Orientation orientation,
00038 int role) const
00039 {
00040 if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
00041 switch (section)
00042 {
00043 case 0:
00044 return tr("Module");
00045 case 1:
00046 return tr("Lecturer");
00047 case 2:
00048 return tr("Hours");
00049 case 3:
00050 return tr("Size");
00051 case 4:
00052 return tr("Groups");
00053 case 5:
00054 return tr("Labs");
00055 case 6:
00056 return tr("Lab Size");
00057 default:
00058 return "";
00059 }
00060 return QVariant();
00061 }
00062
00063
00064
00065
00066 void MLEnrolModel::setupData(dbListManager &dataLists, RootItem* parent)
00067 {
00071 ModLecAlloc * enrolObj;
00072 MLAllocItem * eiObj;
00073 ProgItem* parentObj;
00074 QList<ModLecAlloc *> * enrolList;
00075 Institute* inst = static_cast<InstItem*>(parent)->getInstitute();
00076 Programme* prog = NULL;
00077 int sem =0;
00078
00079 enrolList = dataLists.getMLAllocList(static_cast<InstItem*>(parent)->getItemData());
00080 for (int Cnt = 0; Cnt < enrolList->size(); ++Cnt)
00081 {
00082 enrolObj = enrolList->at(Cnt);
00083 if (enrolObj->getProg() != prog || enrolObj->getSem() != sem)
00084 {
00085 prog = enrolObj->getProg();
00086 sem = enrolObj->getSem();
00087 parentObj = new ProgItem(prog,parent,2,sem);
00088 parentObj->setColumnOrder(2
00089 ,ProgItem::COL_ABBREV
00090 ,ProgItem::COL_SEMESTER
00091 );
00092 parent->appendChild(parentObj);
00093 }
00094
00095 eiObj = new MLAllocItem(enrolObj, parentObj);
00096 eiObj->setColumnOrder(7
00097 ,MLAllocItem::COL_MODULE
00098 ,MLAllocItem::COL_LECTURER
00099 ,MLAllocItem::COL_HOURS
00100 ,MLAllocItem::COL_CLASS_SIZE
00101 ,MLAllocItem::COL_GROUPS
00102 ,MLAllocItem::COL_LAB_HOURS
00103 ,MLAllocItem::COL_LAB_GROUPS
00104 );
00105 parentObj->appendChild(eiObj);
00106 }
00107 }
00108
00109 QString MLEnrolModel::dump()
00110 {
00111 QString msg;
00112 msg = "MLEnrolModel: \n";
00113 return msg;
00114 }
00115
00116 Module * MLEnrolModel::getModuleAt(int i)
00117 {
00118 RootItem * ritem = rootItem->child(i);
00119 MLAllocItem* MLEitem = dynamic_cast<MLAllocItem*>(ritem);
00120 return MLEitem->getModule();
00121 }