source: src/mvc/event.h @ a1755df

qt5
Last change on this file since a1755df was a1755df, checked in by timkoma <timkoma@…>, 12 years ago

performance improvement for Events

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * Copyright (C) 2010 Ixonos Plc.
3 *
4 * This file is part of fosdem-schedule.
5 *
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)
9 * any later version.
10 *
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
14 * more details.
15 *
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/>.
18 */
19#ifndef EVENT_H
20#define EVENT_H
21
22#include <QDateTime>
23#include <QVector>
24#include <QStringList>
25
26#include <ormrecord.h>
27
28/**
29  NoSuchEventException is thrown when required event does not exist.
30*/
31class NoSuchEventException
32{
33};
34
35class Event : public OrmRecord<Event>
36{
37public:
38    Event();
39    static const QSqlRecord sColumns;
40    static QString const sTableName;
41public:
42    static Event getById(int id, int conferenceId);
43    static QList<Event> getByDate(const QDate & date, int conferenceId, QString orderBy);
44    static QList<Event> getFavByDate(const QDate & date, int conferenceId); // get Favourities by Date
45    static QList<Event> getSearchResultByDate(const QDate& date, int conferenceId, QString orderBy);
46    static QList<Event> nowEvents(int conferenceId, QString orderBy); // get events scheduled NOW
47    static QList<Event> getByTrack(int id);
48    static QList<Event> getByDateAndRoom(const QDate& date, int conferenceId);
49    static QList<Event> conflictEvents(int aEventId, int conferenceId);
50public:
51    int id() const { return value("id").toInt(); }
52    int conferenceId() const { return value("xid_conference").toInt(); }
53    QDateTime start() const { return value("start").toDateTime(); }
54    int duration() const { return value("duration").toInt(); }
55    int trackId() const { return value("xid_track").toInt(); }
56    QString type() const { return value("type").toString(); }
57    QString language() const { return value("language").toString(); }
58    bool isFavourite() const { return value("favourite").toBool(); }
59    bool hasAlarm() const { return value("alarm").toBool(); }
60    bool hasTimeConflict() const;
61    QString tag() const { return value("tag").toString(); }
62    QString title() const { return value("title").toString(); }
63    QString subtitle() const { return value("subtitle").toString(); }
64    QString abstract() const { return value("abstract").toString(); }
65    QString description() const { return value("description").toString(); }
66    // records from other tables associated with 'id'
67    QString room();
68    int roomId();
69    QStringList persons();
70    QMap<QString,QString> links();
71
72    void setId(int id) { setValue("id", id); }
73    void setConferenceId(int conferenceId) { setValue("xid_conference", conferenceId); }
74    void setStart(const QDateTime & start) { setValue("start", start); }
75    void setDuration(int duration) { setValue("duration", duration); }
76    void setTrackId(int trackId) { setValue("xid_track", trackId); }
77    void setType(const QString & type) { setValue("type", type); }
78    void setLanguage(const QString & language) { setValue("language", language); }
79    void setFavourite(bool favourite) { setValue("favourite", (int)((favourite))); }
80    void setHasAlarm(bool alarm) { setValue("alarm", (int)((alarm))); }
81    void setTag(const QString& tag) { setValue("tag", tag); }
82    void setTitle(const QString& title) { setValue("title", title); }
83    void setSubtitle(const QString& subtitle) { setValue("subtitle", subtitle); }
84    void setAbstract(const QString& abstract) { setValue("abstract", abstract); }
85    void setDescription(const QString& description) { setValue("description", description); }
86    // records from other tables associated with 'id'
87    void setRoom(const QString& room);
88    void setPersons(const QStringList &persons);
89    void setLinks(const QMap<QString,QString> &aLinks);
90
91friend class EventTest;
92
93private:
94    QStringList mPersonsList;
95    QMap<QString,QString> mLinksList;
96    int mRoomId;
97    QString mRoomName;
98};
99
100#endif // EVENT_H
101
Note: See TracBrowser for help on using the repository browser.