ffc805ad803302cb9d454b6be829dba647fbaad2
[toast/confclerk.git] / src / mvc / event.cpp
1 #include "event.h"
2
3 QSqlRecord 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));
11
12 QString const Event::sTableName = QString("event");
13
14 Event Event::getById(int id, int conferenceId)
15 {
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
23 QList<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));
30
31     return load(query);
32 }