Changeset 005e2b7 for src/mvc


Ignore:
Timestamp:
01/22/10 09:30:11 (12 years ago)
Author:
korrco <korrco@…>
Branches:
master, qt5
Children:
8200b03
Parents:
ab6110b
Message:

caching removed

Location:
src/mvc
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/delegate.cpp

    rab6110b r005e2b7  
    179179        // track
    180180        titlePointF.setY(titlePointF.y()+fmSmall.height()-fmSmall.descent());
    181         painter->drawText(titlePointF,"Track: " + Track::getTrackName(event->trackId()));
     181        painter->drawText(titlePointF,"Track: " + Track::retrieveTrackName(event->trackId()));
    182182    }
    183183    else // doesn't have parent - time-groups' elements (top items)
  • src/mvc/event.cpp

    rab6110b r005e2b7  
    6161    query.bindValue(":start", convertToDb(date, QVariant::DateTime));
    6262    query.bindValue(":end", convertToDb(date.addDays(1), QVariant::DateTime));
     63
     64    return load(query);
     65}
     66
     67QList<Event> Event::getByTrack(int trackId)
     68{
     69    QSqlQuery query;
     70    query.prepare(selectQuery() + QString("WHERE xid_track = :trackId ORDER BY start"));
     71    query.bindValue(":trackId", trackId);
    6372
    6473    return load(query);
  • src/mvc/event.h

    rab6110b r005e2b7  
    2626    static QList<Event> getSearchResultByDate(const QDate& date, int conferenceId, QString orderBy);
    2727    static QList<Event> nowEvents(int conferenceId, QString orderBy); // get events scheduled NOW
     28    static QList<Event> getByTrack(int id);
    2829public:
    2930    int id() const { return value("id").toInt(); }
  • src/mvc/eventmodel.cpp

    rab6110b r005e2b7  
    5656    int trackId = mEvents.first().trackId();
    5757
    58     mGroups << EventModel::Group(Track::getTrackName(trackId), 0);
     58    mGroups << EventModel::Group(Track::retrieveTrackName(trackId), 0);
    5959    int nextTrackId = trackId;
    6060
     
    6565        {
    6666            mGroups.last().mChildCount = i - mGroups.last().mFirstEventIndex;
    67             mGroups << EventModel::Group(Track::getTrackName(trackId), i);
     67            mGroups << EventModel::Group(Track::retrieveTrackName(trackId), i);
    6868            nextTrackId = trackId;
    6969        }
     
    7272    }
    7373    mGroups.last().mChildCount = mEvents.count() - mGroups.last().mFirstEventIndex;
     74}
     75
     76void EventModel::createTrackGroupsNew() {
     77    mGroups.clear();
     78    mParents.clear();
     79    if (mEvents.empty())
     80    {
     81        return;
     82    }
     83    QList<Track> trackList = Track::getAll();
     84    QList<Track>::iterator track = trackList.begin();
     85    while (track != trackList.end())
     86    {
     87        QList<Event> eventList = Event::getByTrack(track->id());
     88        QList<Event>::iterator event = eventList.begin();
     89        while (event != eventList.end())
     90        {
     91            //TODO korinpa: pokracuj
     92            event++;
     93        }
     94        track++;
     95    }
    7496}
    7597
  • src/mvc/eventmodel.h

    rab6110b r005e2b7  
    4242    void createTimeGroups();
    4343    void createTrackGroups();
     44    void createTrackGroupsNew();
    4445    void clearModel();
    4546
  • src/mvc/mvc.pro

    rab6110b r005e2b7  
    77
    88# module dependencies
    9 LIBS += -L$$DESTDIR -lorm
     9LIBS += -L$$DESTDIR \
     10    -lorm
    1011INCLUDEPATH += ../orm ../app
    11 DEPENDPATH += . ../orm
     12DEPENDPATH += . \
     13    ../orm
    1214TARGETDEPS += $$DESTDIR/liborm.a
    13 
    1415maemo {
    15     LIBS += -L$$DESTDIR -lqalarm -lalarm
     16    LIBS += -L$$DESTDIR \
     17        -lqalarm \
     18        -lalarm
    1619    INCLUDEPATH += ../alarm
    17     DEPENDPATH +=  ../alarm
     20    DEPENDPATH += ../alarm
    1821    TARGETDEPS += $$DESTDIR/libqalarm.a
    1922}
    20 
    21 HEADERS += event.h \
    22            conference.h \
    23            track.h \
    24            delegate.h \
    25            eventmodel.h \
    26            treeview.h
    27 
    28 SOURCES += event.cpp \
    29            conference.cpp \
    30            track.cpp \
    31            delegate.cpp \
    32            eventmodel.cpp \
    33            treeview.cpp
     23HEADERS += room.h \
     24    event.h \
     25    conference.h \
     26    track.h \
     27    delegate.h \
     28    eventmodel.h \
     29    treeview.h
     30SOURCES += room.cpp \
     31    event.cpp \
     32    conference.cpp \
     33    track.cpp \
     34    delegate.cpp \
     35    eventmodel.cpp \
     36    treeview.cpp
  • src/mvc/track.cpp

    rab6110b r005e2b7  
    1717    << QSqlField(NAME, QVariant::String));
    1818
    19 QMap<int, Track> Track::mIdToTrack;
     19//QMap<int, Track> Track::mIdToTrack;
    2020
    2121class TrackInsertException : OrmSqlException
     
    5757}
    5858
    59 void Track::updateTrackMap()
     59Track Track::retrieve(int id)
    6060{
    61     mIdToTrack.clear();
    62     QList<Track> trackList = Track::getAll();
    63     Track track;
    64     for (int id = 0; id < trackList.count(); ++id) {
    65         track = trackList.at(id);
    66         mIdToTrack.insert(track.id(), track);
    67     }
     61    QSqlQuery query;
     62    query.prepare(selectQuery()
     63            + QString("WHERE %1.id = :id").arg(sTableName));
     64    query.bindValue(":id", id);
     65    return loadOne(query);
    6866}
    6967
    70 QString Track::getTrackName(int id)
     68QString Track::retrieveTrackName(int id)
    7169{
    72     QString name = mIdToTrack.value(id).name();
    73     if (name == "") {
    74         qDebug() << QString("Error: undefined activity name for id %1").arg(id);
    75     }
    76     return name;
     70    Track track = retrieve(id);
     71    return track.name();
    7772}
  • src/mvc/track.h

    rab6110b r005e2b7  
    2828    void setName(const QString & type) { setValue("name", type); }
    2929public:
    30     //static void
    3130    static QList<Track> getAll();
     31    static Track retrieve(int id);
     32    static QString retrieveTrackName(int id);
    3233    static Track retrieveByName(QString name);
    33     static void updateTrackMap();
    34     static QString getTrackName(int id);
    3534};
    3635
Note: See TracChangeset for help on using the changeset viewer.