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

MLAllocModel.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 "MLAllocModel.h"
00021 
00022 MLAllocModel::MLAllocModel(dbListManager * dataLists, Programme* prog, QObject *parent)
00023         : RootModel(parent)
00024 {
00025         rootItem = new ProgItem(prog);
00026         setupData(*dataLists, rootItem);
00027 }
00028 
00029 
00030 /******************************************************************************
00031  * Inherited from RootModel
00032  ******************************************************************************/
00033 int MLAllocModel::columnCount(const QModelIndex &) const
00034 {
00035         return 1;
00036 }
00037 
00038 
00039 QVariant MLAllocModel::headerData(int section, Qt::Orientation orientation,
00040                                                                                  int role) const
00041 {
00042         if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
00043                 switch (section)
00044                 {
00045                         case 0:
00046                                 return tr("Details");
00047                         default:
00048                                 return "";
00049                 }
00050         return QVariant();
00051 }
00052 
00053 /******************************************************************************
00054  * Private Methods
00055  ******************************************************************************/
00056 void MLAllocModel::setupData(dbListManager &dataLists, RootItem * parent)
00057 {
00058         ModLecAlloc * allocObj;
00059         MLAllocItem * aiObj;
00060         QList<ModLecAlloc *> * allocList;
00061         
00062         allocList = dataLists.getMLAllocList(static_cast<ProgItem*>(parent)->getItemData());
00063         for (int Cnt = 0; Cnt < allocList->size(); ++Cnt)
00064         {
00065                 allocObj = allocList->at(Cnt);
00066                 aiObj = new MLAllocItem(allocObj, parent);
00067                 parent->insertChild(aiObj);
00068         } // end loop for each allocated object
00069 }
00070 
00071 QString MLAllocModel::dump()
00072 {
00073         QString msg;
00074         msg = "MLAllocModel: \n";
00075         return msg;
00076 }
00077 
00078 Module * MLAllocModel::getModuleAt(int i)
00079 {
00080         RootItem * ritem = rootItem->child(i);
00081         MLAllocItem* MLAitem = dynamic_cast<MLAllocItem*>(ritem);
00082         return MLAitem->getModule();
00083 }

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