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

ModuItem.h

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 #ifndef __MODULE_ITEM_H
00021 #define __MODULE_ITEM_H
00022 
00023 
00024 #include "RootItem.h"
00025 #include "Module.h"
00026 
00027 class ModuleItem : public RootItem
00028 {
00029         public: // Enums
00030                 enum Columns {COL_NAME =0, COL_NOMENCLATURE, COL_SEMESTER, COL_WEEKS
00031                              ,COL_HOURS,  COL_INSTITUTE, COL_PROGRAMME};
00032         public: // Constructor
00033                 ModuleItem(Module * ModuleObj, RootItem *parent = 0, int cc =0);
00034                 ModuleItem(ModuleItem & mi);
00035                 ~ModuleItem(){};
00036         // Get Methods
00037                 inline virtual Module * getItemData()const {return static_cast<Module * >(itemData);}
00038                 inline Institute * getInstitute()      {return  getItemData()->getInst();}
00039                 inline Programme * getProgramme()      {return getItemData()->getProg();}
00040                 inline Module    * getModule()         {return getItemData();}
00041                 inline QString getDescription()const   {return itemData->getDescription();}
00042                 inline QString getInstName()const      {return getItemData()->getInstName();}
00043                 inline QString getProgName()const      {return getItemData()->getName();}
00044                 inline QString getModuName()const      {return getItemData()->getName();}
00045                 inline QString getModuNomenclature()const    {return getItemData()->getNomenclature();}
00046                 inline int getModuDuration()const      {return getItemData()->getDuration();}
00047                 inline int getModuWeeklyPeriods()const {return getItemData()->getWeeklyPeriods();}
00048                 inline int getModuSemester()const      {return getItemData()->getSemester();}
00049                 QVariant data(int column) const;
00050         // Set Methods
00051                 inline bool setModuName(QString name){return getItemData()->setName(name);}
00052                 inline bool setModuNomencatlure(QString n) {return getItemData()->setNomenclature(n);}
00053                 inline bool setModuDuration(int duration)  {return getItemData()->setDuration(duration);}
00054                 inline bool setModuWeeklyPeriods(int p)    {return getItemData()->setWeeklyPeriods(p);}
00055                 inline bool setModuSemester(int s)         {return getItemData()->setSemester(s);}
00056                 bool setData(int column, const QVariant & value);
00057         // Data Display Methods
00058                 inline virtual QColor textColour(){return txtColour[(getModuSemester()-1)/2];}
00059                 inline virtual QColor bgColour()  {return backgroundColour[(getModuSemester()-1)/2];}
00060         // database manipulation
00061                 inline void dbSave();
00062                 inline void dbDelete();
00063 };
00064 
00065 inline void ModuleItem::dbSave()
00066 {
00067         getItemData()->save(Module::insertSQL, Module::updateSQL, Module::errorSQL);
00068 }
00069 
00070 inline void ModuleItem::dbDelete()
00071 {
00072         getItemData()->remove(Module::deleteSQL, Module::errorSQL);
00073 }
00074 
00075 #endif

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