2 * Copyright (C) 2010 Ixonos Plc.
4 * This file is part of fosdem-schedule.
6 * fosdem-schedule is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 2 of the License, or (at your option)
11 * fosdem-schedule is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * fosdem-schedule. If not, see <http://www.gnu.org/licenses/>.
24 #include <QStringList>
26 #include <ormrecord.h>
31 NoSuchEventException is thrown when required event does not exist.
33 class NoSuchEventException
37 class Event : public OrmRecord<Event>
41 static const QSqlRecord sColumns;
42 static QString const sTableName;
44 static Event getById(int id, int conferenceId);
45 static QList<Event> getByDate(const QDate & date, int conferenceId, QString orderBy);
46 static QList<Event> getFavByDate(const QDate & date, int conferenceId); // get Favourities by Date
47 static QList<Event> getSearchResultByDate(const QDate& date, int conferenceId, QString orderBy);
48 static QList<Event> nowEvents(int conferenceId, QString orderBy); // get events scheduled NOW
49 static QList<Event> getByTrack(int id);
50 static QList<Event> getByDateAndRoom(const QDate& date, int conferenceId);
51 static QList<Event> conflictEvents(int aEventId, int conferenceId);
53 int id() const { return value("id").toInt(); }
54 int conferenceId() const { return value("xid_conference").toInt(); }
55 QDateTime start() const { return value("start").toDateTime(); }
56 int duration() const { return value("duration").toInt(); }
57 int trackId() const { return value("xid_track").toInt(); }
58 QString type() const { return value("type").toString(); }
59 QString language() const { return value("language").toString(); }
60 bool isFavourite() const { return value("favourite").toBool(); }
61 bool hasAlarm() const { return value("alarm").toBool(); }
62 bool hasTimeConflict() const;
63 QString tag() const { return value("tag").toString(); }
64 QString title() const { return value("title").toString(); }
65 QString subtitle() const { return value("subtitle").toString(); }
66 QString abstract() const { return value("abstract").toString(); }
67 QString description() const { return value("description").toString(); }
68 // records from other tables associated with 'id'
72 QStringList persons();
73 QMap<QString,QString> links();
75 void setId(int id) { setValue("id", id); }
76 void setConferenceId(int conferenceId) { setValue("xid_conference", conferenceId); }
77 void setStart(const QDateTime & start) { setValue("start", start); }
78 void setDuration(int duration) { setValue("duration", duration); }
79 void setTrackId(int trackId) { setValue("xid_track", trackId); }
80 void setType(const QString & type) { setValue("type", type); }
81 void setLanguage(const QString & language) { setValue("language", language); }
82 void setFavourite(bool favourite) { setValue("favourite", (int)((favourite))); }
83 void setHasAlarm(bool alarm) { setValue("alarm", (int)((alarm))); }
84 void setTag(const QString& tag) { setValue("tag", tag); }
85 void setTitle(const QString& title) { setValue("title", title); }
86 void setSubtitle(const QString& subtitle) { setValue("subtitle", subtitle); }
87 void setAbstract(const QString& abstract) { setValue("abstract", abstract); }
88 void setDescription(const QString& description) { setValue("description", description); }
89 // records from other tables associated with 'id'
90 void setRoom(const QString& room);
91 void setPersons(const QStringList &persons);
92 void setLinks(const QMap<QString,QString> &aLinks);
94 friend class EventTest;
97 QStringList mPersonsList;
98 QMap<QString,QString> mLinksList;