Changeset 69393c0


Ignore:
Timestamp:
01/13/10 14:27:33 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
969a840
Parents:
c2d66b2
Message:

implemented 'conference' record for accessing info about the conference

  • events are loaded from the first day of the conference
Location:
src
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • src/gui/mainwindow.cpp

    rc2d66b2 r69393c0  
    6565    QByteArray data = file.readAll();
    6666    mXmlParser->parseData(data,mSqlEngine);
    67     static_cast<EventModel*>(treeView->model())->reload();
     67    static_cast<EventModel*>(treeView->model())->loadEvents();
    6868    treeView->reset();
    6969}
  • src/model/eventmodel.cpp

    rc2d66b2 r69393c0  
    11#include "eventmodel.h"
     2#include <conference.h>
    23
    3 EventModel::EventModel() :
    4     mEvents(Event::getByDate(QDate(2009, 2, 7), 1))
     4EventModel::EventModel()
    55{
    6     createTimeGroups();
     6
     7    loadEvents();
    78}
    89
     
    118119}
    119120
    120 void EventModel::reload()
     121void EventModel::loadEvents()
    121122{
    122123    mEvents.clear();
    123     mEvents=Event::getByDate(QDate(2009, 2, 7), 1);
     124
     125    mConfId = 1; // current conference selected: we have only one DB so far
     126    // check for existence of conference in the DB
     127    if(Conference::getAll().count())
     128    {
     129        mCurrentDate = Conference::getById(mConfId).start();
     130        qDebug() << "Loading Conference Data: [" << Conference::getById(mConfId).title() << "] " << mCurrentDate;
     131        mEvents = Event::getByDate(QDate(mCurrentDate.year(), mCurrentDate.month(), mCurrentDate.day()), mConfId);
     132    }
     133    mEvents = Event::getByDate(QDate(mCurrentDate.year(), mCurrentDate.month(), mCurrentDate.day()), mConfId);
    124134    createTimeGroups();
    125135}
  • src/model/eventmodel.h

    rc2d66b2 r69393c0  
    1515    int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
    1616    int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
    17     void reload(); // reloads Events from the DB
     17    void loadEvents(); // loads Events from the DB
    1818
    1919private:
     
    4040    QList<Group> mGroups;
    4141    QHash<int, int> mParents;
     42    QDate mCurrentDate;
     43    int mConfId;
    4244};
    4345
    4446#endif // EVENTMODEL_H
     47
  • src/model/model.pro

    rc2d66b2 r69393c0  
    1313HEADERS += \
    1414    event.h \
     15    conference.h \
    1516    delegate.h \
    1617    eventmodel.h \
     
    1819SOURCES += \
    1920    event.cpp \
     21    conference.cpp \
    2022    delegate.cpp \
    2123    eventmodel.cpp \
  • src/sql/sqlengine.cpp

    rc2d66b2 r69393c0  
    6868                         .arg(aConference["venue"]) \
    6969                         .arg(aConference["city"]) \
    70                          .arg(aConference["start"]) \
    71                          .arg(aConference["end"]) \
     70                         .arg(QDateTime(QDate::fromString(aConference["start"],DATE_FORMAT)).toTime_t()) \
     71                         .arg(QDateTime(QDate::fromString(aConference["end"],DATE_FORMAT)).toTime_t()) \
    7272                         .arg(aConference["days"]) \
    73                          .arg(aConference["day_change"]) \
    74                          .arg(aConference["timeslot_duration"]);
     73                         .arg(-QTime::fromString(aConference["day_change"],TIME_FORMAT).secsTo(QTime(0,0))) \
     74                         .arg(-QTime::fromString(aConference["timeslot_duration"],TIME_FORMAT).secsTo(QTime(0,0)));
    7575
    7676        QString query = QString("INSERT INTO CONFERENCE (id,title,subtitle,venue,city,start,end,days,day_change,timeslot_duration) VALUES (%1)").arg(values);
     
    9090        // The items of the Event are divided into the two tables EVENT and VIRTUAL_EVENT
    9191        // VIRTUAL_EVENT is for Full-Text-Serach Support
    92         QTime duration = QTime::fromString(aEvent["duration"],TIME_FORMAT);
    9392        QDateTime startDateTime = QDateTime(QDate::fromString(aEvent["date"],DATE_FORMAT),QTime::fromString(aEvent["start"],TIME_FORMAT));
    9493        QString values = QString("'%1', '%2', '%3', '%4', '%5', '%6', '%7'") \
     
    9695                         .arg(aEvent["id"]) \
    9796                         .arg(QString::number(startDateTime.toTime_t())) \
    98                          .arg(QString::number(duration.hour()*3600 + duration.minute()*60 + duration.second())) \
     97                         .arg(-QTime::fromString(aEvent["duration"],TIME_FORMAT).secsTo(QTime(0,0))) \
    9998                         .arg("123456") \
    10099                         .arg(aEvent["type"]) \
     
    201200            venue VARCHAR, \
    202201            city VARCHAR NOT NULL , \
    203             start DATETIME NOT NULL , \
    204             end DATETIME NOT NULL , \
     202            start INTEGER NOT NULL , \
     203            end INTEGER NOT NULL , \
    205204            days INTEGER, \
    206             day_change DATETIME, \
    207             timeslot_duration DATETIME)");
     205            day_change INTEGER, \
     206            timeslot_duration INTEGER)");
    208207
    209208        query.exec("CREATE TABLE ACTIVITY ( \
Note: See TracChangeset for help on using the changeset viewer.