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

MLEnrolModel.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 - Suite 330, Boston, MA  02111-1307, USA.             *
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  * Inherited from RootModel
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  * Private Methods
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                 //eiObj = new MLEnrolItem(enrolObj, parentObj);
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         } // end loop for each allocated object
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 }

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