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 __DEPARTMENT_ITEM_H 00021 #define __DEPARTMENT_ITEM_H 00022 00023 #include "RootItem.h" 00024 00025 #include "Department.h" 00026 00027 class DeptItem : public RootItem 00028 { 00029 public: // Enums 00030 enum Columns {COL_NAME =0, COL_ABBREV, COL_FACULTY, COL_INSTITUTE}; 00031 public: // Constructor 00032 DeptItem(Department * DeptObj, RootItem *parent = 0, int cc =0); 00033 DeptItem(DeptItem & di); 00034 // Get Methods 00035 inline virtual Department * getItemData()const {return static_cast<Department * >(itemData);} 00036 inline Department * getDepartment() {return getItemData();} 00037 inline Faculty * getFaculty() {return getItemData()->getFaculty();} 00038 inline Institute * getInstitute() {return getItemData()->getInstitute();} 00039 inline QString getDescription()const{return getItemData()->getDescription();} 00040 inline QString getInstName()const {return getItemData()->getInstName();} 00041 inline QString getFacName()const {return getItemData()->getFacName();} 00042 inline QString getDeptName()const {return getItemData()->getName();} 00043 inline QString getDeptAbbrev()const {return getItemData()->getAbbrev();} 00044 QVariant data(int column) const; 00045 // Set Methods 00046 inline bool setDeptName(QString name) {return getItemData()->setName(name);} 00047 inline bool setDeptAbbrev(QString abbrev){return getItemData()->setAbbrev(abbrev);} 00048 bool setData(int column, const QVariant & value); 00049 // database manipulation 00050 inline void dbSave(); 00051 inline void dbDelete(); 00052 }; 00053 00054 00055 void DeptItem::dbSave() 00056 { 00057 getItemData()->save(Department::insertSQL, Department::updateSQL, Department::errorSQL); 00058 } 00059 00060 void DeptItem::dbDelete() 00061 { 00062 getItemData()->remove(Department::deleteSQL, Department::errorSQL); 00063 } 00064 00065 #endif