caching removed
authorkorrco <korrco@localhost>
Fri, 22 Jan 2010 08:30:11 +0000 (08:30 +0000)
committerkorrco <korrco@localhost>
Fri, 22 Jan 2010 08:30:11 +0000 (08:30 +0000)
src/mvc/delegate.cpp
src/mvc/event.cpp
src/mvc/event.h
src/mvc/eventmodel.cpp
src/mvc/eventmodel.h
src/mvc/mvc.pro
src/mvc/track.cpp
src/mvc/track.h
src/sql/sqlengine.cpp

index 4edde0e..406e490 100644 (file)
@@ -178,7 +178,7 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, cons
         painter->drawText(titlePointF,"Presenter(s): " + event->persons().join(" and "));
         // track
         titlePointF.setY(titlePointF.y()+fmSmall.height()-fmSmall.descent());
-        painter->drawText(titlePointF,"Track: " + Track::getTrackName(event->trackId()));
+        painter->drawText(titlePointF,"Track: " + Track::retrieveTrackName(event->trackId()));
     }
     else // doesn't have parent - time-groups' elements (top items)
     {
index 821ccaf..9a60576 100644 (file)
@@ -64,6 +64,15 @@ QList<Event> Event::getFavByDate(const QDate& date, int conferenceId)
     return load(query);
 }
 
+QList<Event> Event::getByTrack(int trackId)
+{
+    QSqlQuery query;
+    query.prepare(selectQuery() + QString("WHERE xid_track = :trackId ORDER BY start"));
+    query.bindValue(":trackId", trackId);
+
+    return load(query);
+}
+
 QString Event::room() const
 {
     QSqlQuery query;
index 9e3b7e8..8eaedc1 100644 (file)
@@ -25,6 +25,7 @@ public:
     static QList<Event> getFavByDate(const QDate & date, int conferenceId); // get Favourities by Date
     static QList<Event> getSearchResultByDate(const QDate& date, int conferenceId, QString orderBy);
     static QList<Event> nowEvents(int conferenceId, QString orderBy); // get events scheduled NOW
+    static QList<Event> getByTrack(int id);
 public:
     int id() const { return value("id").toInt(); }
     int conferenceId() const { return value("xid_conference").toInt(); }
index db09178..cdcacac 100644 (file)
@@ -55,7 +55,7 @@ void EventModel::createTrackGroups() {
     }
     int trackId = mEvents.first().trackId();
 
-    mGroups << EventModel::Group(Track::getTrackName(trackId), 0);
+    mGroups << EventModel::Group(Track::retrieveTrackName(trackId), 0);
     int nextTrackId = trackId;
 
     for (int i=0; i<mEvents.count(); i++)
@@ -64,7 +64,7 @@ void EventModel::createTrackGroups() {
         if (nextTrackId != trackId)
         {
             mGroups.last().mChildCount = i - mGroups.last().mFirstEventIndex;
-            mGroups << EventModel::Group(Track::getTrackName(trackId), i);
+            mGroups << EventModel::Group(Track::retrieveTrackName(trackId), i);
             nextTrackId = trackId;
         }
         // add parent-child relation
@@ -73,6 +73,28 @@ void EventModel::createTrackGroups() {
     mGroups.last().mChildCount = mEvents.count() - mGroups.last().mFirstEventIndex;
 }
 
+void EventModel::createTrackGroupsNew() {
+    mGroups.clear();
+    mParents.clear();
+    if (mEvents.empty())
+    {
+        return;
+    }
+    QList<Track> trackList = Track::getAll();
+    QList<Track>::iterator track = trackList.begin();
+    while (track != trackList.end())
+    {
+        QList<Event> eventList = Event::getByTrack(track->id());
+        QList<Event>::iterator event = eventList.begin();
+        while (event != eventList.end())
+        {
+            //TODO korinpa: pokracuj
+            event++;
+        }
+        track++;
+    }
+}
+
 QVariant EventModel::data(const QModelIndex& index, int role) const
 {
     if (index.isValid() && role == Qt::DisplayRole)
index 9764ee0..44ad43c 100644 (file)
@@ -41,6 +41,7 @@ private:
 private:
     void createTimeGroups();
     void createTrackGroups();
+    void createTrackGroupsNew();
     void clearModel();
 
 public slots:
index 7c2aec9..e9c9d63 100644 (file)
@@ -6,28 +6,31 @@ CONFIG += static
 QT += sql
 
 # module dependencies
-LIBS += -L$$DESTDIR -lorm
+LIBS += -L$$DESTDIR \
+    -lorm
 INCLUDEPATH += ../orm ../app
-DEPENDPATH += . ../orm
+DEPENDPATH += . \
+    ../orm
 TARGETDEPS += $$DESTDIR/liborm.a
-
 maemo { 
-    LIBS += -L$$DESTDIR -lqalarm -lalarm
+    LIBS += -L$$DESTDIR \
+        -lqalarm \
+        -lalarm
     INCLUDEPATH += ../alarm
-    DEPENDPATH +=  ../alarm
+    DEPENDPATH += ../alarm
     TARGETDEPS += $$DESTDIR/libqalarm.a
 }
-
-HEADERS += event.h \
-           conference.h \
-           track.h \
-           delegate.h \
-           eventmodel.h \
-           treeview.h
-
-SOURCES += event.cpp \
-           conference.cpp \
-           track.cpp \
-           delegate.cpp \
-           eventmodel.cpp \
-           treeview.cpp
+HEADERS += room.h \
+    event.h \
+    conference.h \
+    track.h \
+    delegate.h \
+    eventmodel.h \
+    treeview.h
+SOURCES += room.cpp \
+    event.cpp \
+    conference.cpp \
+    track.cpp \
+    delegate.cpp \
+    eventmodel.cpp \
+    treeview.cpp
index 3ba78e5..d0d8c12 100644 (file)
@@ -16,7 +16,7 @@ QSqlRecord const Track::sColumns = Track::toRecord(QList<QSqlField>()
     << QSqlField("id", QVariant::Int)
     << QSqlField(NAME, QVariant::String));
 
-QMap<int, Track> Track::mIdToTrack;
+//QMap<int, Track> Track::mIdToTrack;
 
 class TrackInsertException : OrmSqlException
 {
@@ -56,22 +56,17 @@ QList<Track> Track::getAll()
     return load(query);
 }
 
-void Track::updateTrackMap()
+Track Track::retrieve(int id)
 {
-    mIdToTrack.clear();
-    QList<Track> trackList = Track::getAll();
-    Track track;
-    for (int id = 0; id < trackList.count(); ++id) {
-        track = trackList.at(id);
-        mIdToTrack.insert(track.id(), track);
-    }
+    QSqlQuery query;
+    query.prepare(selectQuery()
+            + QString("WHERE %1.id = :id").arg(sTableName));
+    query.bindValue(":id", id);
+    return loadOne(query);
 }
 
-QString Track::getTrackName(int id)
+QString Track::retrieveTrackName(int id)
 {
-    QString name = mIdToTrack.value(id).name();
-    if (name == "") {
-        qDebug() << QString("Error: undefined activity name for id %1").arg(id);
-    }
-    return name;
+    Track track = retrieve(id);
+    return track.name();
 }
index b8a3243..425af6c 100644 (file)
@@ -27,11 +27,10 @@ public:
     QString name() const { return value("name").toString(); }
     void setName(const QString & type) { setValue("name", type); }
 public:
-    //static void
     static QList<Track> getAll();
+    static Track retrieve(int id);
+    static QString retrieveTrackName(int id);
     static Track retrieveByName(QString name);
-    static void updateTrackMap();
-    static QString getTrackName(int id);
 };
 
 #endif /* TRACK_H_ */
index aa5b2d7..335359a 100644 (file)
@@ -113,7 +113,7 @@ void SqlEngine::addEventToDB(QHash<QString,QString> &aEvent)
 
     if (db.isValid() && db.isOpen())
     {
-        //insert event track to table
+        //insert event track to table and get track id
         QString name = aEvent["track"];
         Track track;
         int trackId;