source: src/model/event.cpp @ 9bbb44e

qt5
Last change on this file since 9bbb44e was d0d0a66, checked in by komarma <komarma@…>, 13 years ago

Creating EventModel? class

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[e5bc908]1#include "event.h"
2
[20a6010]3QSqlRecord const Event::sColumns = Event::toRecord(QList<QSqlField>()
4    << QSqlField("id", QVariant::Int)
5    << QSqlField("xid_conference", QVariant::Int)
6    << QSqlField("start", QVariant::DateTime)
7    << QSqlField("duration", QVariant::Int)
8    << QSqlField("xid_activity", QVariant::Int)
9    << QSqlField("type", QVariant::String)
10    << QSqlField("language", QVariant::String));
[5a73d27]11
12QString const Event::sTableName = QString("event");
[20a6010]13
14Event Event::getById(int id, int conferenceId)
15{
[d0d0a66]16    QSqlQuery query;
17    query.prepare(selectQuery() + "WHERE id = :id AND xid_conference = :conf");
18    query.bindValue(":id", id);
19    query.bindValue(":conf", conferenceId);
20    return loadOne(query);
21}
22
23QList<Event> Event::getByDate(const QDate& date, int conferenceId)
24{
25    QSqlQuery query;
26    query.prepare(selectQuery() + "WHERE xid_conference = :conf AND start >= :start AND start < :end ORDER BY start");
27    query.bindValue(":conf", conferenceId);
28    query.bindValue(":start", convertToDb(date, QVariant::DateTime));
29    query.bindValue(":end", convertToDb(date.addDays(1), QVariant::DateTime));
[20a6010]30
[d0d0a66]31    return load(query);
[20a6010]32}
Note: See TracBrowser for help on using the repository browser.