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

RoomItem.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 <QStringList>
00021 
00022 #include "RoomItem.h"
00023 
00024 RoomItem::RoomItem(Room * RoomObj, RootItem *parent, int cc)
00025 :RootItem(parent, cc)
00026 {
00027         RTTI = ROOM_ITEM;
00028         parentItem = parent;
00029         itemData = RoomObj;
00030         setColumnOrder(3, COL_NAME, COL_CODE, COL_CAPACITY);
00031         GUIPref * pref = GUIPref::Instance();
00032         setTextColour(2
00033                      ,pref->getColour(GUIPref::CT_ROOM_TEXT,0)
00034                      ,pref->getColour(GUIPref::CT_ROOM_TEXT,1));
00035         setBGColour(2
00036                    ,pref->getColour(GUIPref::CT_ROOM_BG,0)
00037                    ,pref->getColour(GUIPref::CT_ROOM_BG,1));
00038 }
00039 
00040 RoomItem::RoomItem(RoomItem & ri)
00041 :RootItem(ri)
00042 {
00043         setColumnOrder(3, COL_NAME, COL_CODE, COL_CAPACITY);
00044         GUIPref * pref = GUIPref::Instance();
00045         setTextColour(2
00046                      ,pref->getColour(GUIPref::CT_ROOM_TEXT,0)
00047                      ,pref->getColour(GUIPref::CT_ROOM_TEXT,1));
00048         setBGColour(2
00049                    ,pref->getColour(GUIPref::CT_ROOM_BG,0)
00050                    ,pref->getColour(GUIPref::CT_ROOM_BG,1));
00051 }
00052 
00053 QVariant RoomItem::data(int column) const
00054 {
00055         if (column >= columnCount())
00056                 return "";
00057         switch (Columns(col_order[column]))
00058         {
00059                 case COL_NAME:
00060                         return getRoomName();
00061                 case COL_CODE:
00062                         return getRoomCode();
00063                 case COL_CAPACITY:
00064                         return getRoomCapacity();
00065                 case COL_INSTITUTE:
00066                         return getInstName();
00067         }
00068         return "";
00069 }
00070 
00071 bool RoomItem::setData(int column, const QVariant & value)
00072 {
00073         if (column >= columnCount())
00074                 return false;
00075         switch (Columns(col_order[column]))
00076         {
00077                 case COL_NAME:
00078                         return setRoomName(value.toString());
00079                 case COL_CODE:
00080                         return setRoomCode(value.toString());
00081                 case COL_CAPACITY:
00082                         return setRoomCapacity(value.toInt());
00083                 default:
00084                         return false;
00085         }
00086 }
00087 

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