Changeset 78e3575 for src/mvc


Ignore:
Timestamp:
02/03/10 14:19:18 (12 years ago)
Author:
timkoma <timkoma@…>
Branches:
master, qt5
Children:
a1755df
Parents:
e296dc6
Message:

performance improvement for load persons

Location:
src/mvc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/event.cpp

    re296dc6 r78e3575  
    144144}
    145145
    146 QStringList Event::persons() const
    147 {
    148     QSqlQuery query;
    149     // TODO: conference ID isn't used here
    150     query.prepare("SELECT person.name FROM person INNER JOIN event_person ON person.id = event_person.xid_person AND event_person.xid_event = :id");
    151     query.bindValue(":id", id());
    152     query.exec();
    153     // TODO: handle qeury error
    154     //qDebug() << query.lastError();
    155 
    156     QStringList persons;
    157     while(query.next())
    158         persons.append(query.record().value("name").toString());
    159 
    160     return persons;
     146QStringList Event::persons()
     147{
     148    if( personsList.isEmpty() )
     149    {
     150        QSqlQuery query;
     151        // TODO: conference ID isn't used here
     152        query.prepare("SELECT person.name FROM person INNER JOIN event_person ON person.id = event_person.xid_person AND event_person.xid_event = :id");
     153        query.bindValue(":id", id());
     154        query.exec();
     155        // TODO: handle qeury error
     156        //qDebug() << query.lastError();
     157
     158        while(query.next())
     159            personsList.append(query.record().value("name").toString());
     160    }
     161
     162    return personsList;
    161163}
    162164
  • src/mvc/event.h

    re296dc6 r78e3575  
    6666    QString room() const;
    6767    int roomId() const;
    68     QStringList persons() const;
     68    QStringList persons();
    6969    QMap<QString,QString> links() const;
    7070
     
    8989
    9090friend class EventTest;
     91
     92private:
     93    QStringList personsList;
    9194};
    9295
Note: See TracChangeset for help on using the changeset viewer.