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

ProgItem.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 "ProgItem.h"
00023 #include "ModuItem.h"
00024 
00025 ProgItem::ProgItem(Programme * ProgObj, RootItem *parent, int cc, int sem)
00026 :RootItem(parent, cc)
00027 {
00028         RTTI = PROG_ITEM;
00029         itemData = ProgObj;
00030         semester = sem;
00031         setColumnOrder(2,COL_NAME, COL_ABBREV);
00032         GUIPref * pref = GUIPref::Instance();
00033         setTextColour(2
00034                      ,pref->getColour(GUIPref::CT_PROGRAMME_TEXT,0)
00035                      ,pref->getColour(GUIPref::CT_PROGRAMME_TEXT,1));
00036         setBGColour(2
00037                    ,pref->getColour(GUIPref::CT_PROGRAMME_BG,0)
00038                    ,pref->getColour(GUIPref::CT_PROGRAMME_BG,1));
00039 }
00040 
00041 ProgItem::ProgItem(ProgItem & pi)
00042 :RootItem(pi)
00043 {
00044         semester = pi.semester;
00045         setColumnOrder(2,COL_NAME, COL_ABBREV);
00046         GUIPref * pref = GUIPref::Instance();
00047         setTextColour(2
00048                      ,pref->getColour(GUIPref::CT_PROGRAMME_TEXT,0)
00049                      ,pref->getColour(GUIPref::CT_PROGRAMME_TEXT,1));
00050         setBGColour(2
00051                    ,pref->getColour(GUIPref::CT_PROGRAMME_BG,0)
00052                    ,pref->getColour(GUIPref::CT_PROGRAMME_BG,1));
00053 }
00054 
00055 QVariant ProgItem::data(int column) const
00056 {
00057         if (column >= columnCount())
00058                 return "";
00059         switch ((Columns)(col_order[column]))
00060         {
00061                 case COL_NAME:
00062                         return getProgName();
00063                 case COL_ABBREV:
00064                         return getProgAbbrev();
00065                 case COL_SEMESTER:
00066                         return "Sem " + QString::number(semester);
00067                 case COL_INSTITUTE:
00068                         return getInstName();
00069         }
00070         return "";
00071 }
00072 
00073 bool ProgItem::setData(int column, const QVariant & value)
00074 {
00075         if (column >= columnCount())
00076                 return false;
00077         switch ((Columns)(col_order[column]))
00078         {
00079                 case COL_NAME:
00080                         return setProgName(value.toString());
00081                 case COL_ABBREV:
00082                         return setProgAbbrev(value.toString());
00083                 default:
00084                         return false;
00085         }
00086 }
00087 
00088 

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