Changeset 0d995ed


Ignore:
Timestamp:
05/05/10 15:57:37 (12 years ago)
Author:
kirilma <kirilma@…>
Branches:
master, qt5
Children:
508de33
Parents:
58eb7cc
Message:

refactor: cache whole Room object in Event

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/gui/tabcontainer.cpp

    r58eb7cc r0d995ed  
    8686    Event *event = static_cast<Event*>(aIndex.internalPointer());
    8787
    88     Room room = Room::retrieve(event->roomId());
    89     QVariant mapPathV = room.map();
     88    QVariant mapPathV = event->room()->map();
    9089    QString mapPath;
    9190    if (!mapPathV.isValid()) {
     
    101100
    102101    QPixmap map(mapPath);
    103     MapWindow window(map, room.name(),this);
     102    MapWindow window(map, event->room()->name(),this);
    104103    window.exec();
    105104}
  • src/mvc/delegate.cpp

    r58eb7cc r0d995ed  
    154154        QTime start = event->start().time();
    155155        painter->setFont(fontBig);
    156         painter->drawText(titlePointF,start.toString("hh:mm") + "-" + start.addSecs(event->duration()).toString("hh:mm") + ", " + event->room());
     156        painter->drawText(titlePointF,start.toString("hh:mm") + "-" + start.addSecs(event->duration()).toString("hh:mm") + ", " + event->roomName());
    157157        // title
    158158        titlePointF.setY(titlePointF.y()+fmBig.height()-fmBig.descent());
  • src/mvc/event.cpp

    r58eb7cc r0d995ed  
    3939
    4040Event::Event() :
    41     mRoomId( 0 )
     41    room_(NULL)
    4242{
    4343}
     
    120120}
    121121
    122 QString Event::room()
    123 {
    124     if ( mRoomName.isEmpty() )
    125     {
    126         QSqlQuery query;
    127         // TODO: conference ID isn't used here
    128         query.prepare("SELECT name FROM room WHERE id = :roomId");
    129         query.bindValue(":roomId", roomId());
    130         query.exec();
    131         // TODO: handle qeury error
    132         //qDebug() << query.lastError();
    133         if(query.next())
    134             mRoomName = query.record().value("name").toString();
    135         else
    136             mRoomName = QString("not-available");
    137     }
    138     return mRoomName;
    139 }
    140 
    141 int Event::roomId()
    142 {
    143     if ( mRoomId == 0 )
     122Room* Event::room()
     123{
     124    if (room_ == NULL)
    144125    {
    145126        QSqlQuery query;
     
    155136            throw OrmNoObjectException();
    156137        }
    157         mRoomId = query.record().value("xid_room").toInt();
    158     }
    159     return mRoomId;
     138        int id = query.record().value("xid_room").toInt();
     139        room_ = new Room(Room::retrieve(id));
     140    }
     141    return room_;
     142}
     143
     144QString Event::roomName()
     145{
     146    return room()->name();
     147}
     148
     149int Event::roomId()
     150{
     151    return room()->id();
    160152}
    161153
  • src/mvc/event.h

    r58eb7cc r0d995ed  
    2525
    2626#include <ormrecord.h>
     27
     28class Room;
    2729
    2830/**
     
    6567    QString description() const { return value("description").toString(); }
    6668    // records from other tables associated with 'id'
    67     QString room();
     69    Room* room();
     70    QString roomName();
    6871    int roomId();
    6972    QStringList persons();
     
    9699    int mRoomId;
    97100    QString mRoomName;
     101    Room* room_;
    98102};
    99103
Note: See TracChangeset for help on using the changeset viewer.