00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "RoomModel.h"
00021
00022 RoomModel::RoomModel(dbListManager * dataLists, QObject *parent)
00023 : RootModel(parent)
00024 {
00025 QList<QVariant> rootData;
00026 Institute * rootObj;
00027 rootObj = new Institute (0,tr("Institute Name"), tr("Abbreviation"));
00028 rootItem = new InstItem(rootObj);
00029 setupInstData(*dataLists,rootItem);
00030 }
00031
00032
00033
00034
00035
00036 int RoomModel::columnCount(const QModelIndex &) const
00037 {
00038 return 3;
00039 }
00040
00041 QVariant RoomModel::headerData(int section, Qt::Orientation orientation,
00042 int role) const
00043 {
00044 if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
00045 switch (section)
00046 {
00047 case 0:
00048 return tr("Name");
00049 case 1:
00050 return tr("Code");
00051 case 2:
00052 return tr("Capacity");
00053 default:
00054 return "";
00055 }
00056 return QVariant();
00057 }
00058
00059
00060
00061
00062 void RoomModel::setupInstData(dbListManager &dataLists, RootItem * parent)
00063 {
00064 Institute * instObj;
00065 InstItem * iiObj;
00066 QList<Institute * > * instList = dataLists.getInstituteList();
00067
00068 for (int iCnt = 0; iCnt < instList->size(); ++iCnt)
00069 {
00070 instObj = instList->at(iCnt);
00071 iiObj = new InstItem(instObj, parent);
00072 parent->insertChild(iiObj);
00073 setupRoomData(dataLists, iiObj);
00074 }
00075 }
00076
00077 void RoomModel::setupRoomData(dbListManager &dataLists, InstItem * parent)
00078 {
00079 Room * roomObj;
00080 RoomItem * riObj;
00081 QList<Room * > * roomList;
00082
00083 roomList = dataLists.getRoomList(parent->getItemData());
00084 for (int rCnt = 0; rCnt < roomList->size(); ++rCnt)
00085 {
00086 roomObj = roomList->at(rCnt);
00087 riObj = new RoomItem(roomObj, parent);
00088 parent->insertChild(riObj);
00089 }
00090 }