source: src/mvc/event.h @ 3cd9fe6

qt5
Last change on this file since 3cd9fe6 was 3cd9fe6, checked in by Philipp Spitzer <philipp@…>, 6 years ago

favourite is now tristate instead of bool.

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/*
2 * Copyright (C) 2010 Ixonos Plc.
3 * Copyright (C) 2011-2015 Philipp Spitzer, gregor herrmann, Stefan Stahl
4 *
5 * This file is part of ConfClerk.
6 *
7 * ConfClerk is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation, either version 2 of the License, or (at your option)
10 * any later version.
11 *
12 * ConfClerk is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * ConfClerk.  If not, see <http://www.gnu.org/licenses/>.
19 */
20#ifndef EVENT_H
21#define EVENT_H
22
23#include <QDateTime>
24#include <QVector>
25#include <QStringList>
26
27#include "ormrecord.h"
28
29class Room;
30
31/**
32  NoSuchEventException is thrown when required event does not exist.
33*/
34class NoSuchEventException
35{
36};
37
38
39enum Favourite {Favourite_no=0, Favourite_weak=2, Favourite_strong=1};
40
41
42class Event : public OrmRecord<Event>
43{
44public:
45    Event();
46    static const QSqlRecord sColumns;
47    static QString const sTableName;
48public:
49    static Event getById(int id, int conferenceId);
50    static QList<Event> getByDate(const QDate & date, int conferenceId, QString orderBy);
51    static QList<Event> getFavByDate(const QDate & date, int conferenceId); // get Favourities by Date
52    static QList<Event> getSearchResultByDate(const QDate& date, int conferenceId, QString orderBy);
53    static QList<Event> getByTrack(int id);
54    static QList<Event> getByDateAndRoom(const QDate& date, int conferenceId);
55    static QList<Event> conflictEvents(int aEventId, int conferenceId);
56    static QList<Event> getImminentAlarmEvents(int maxSecToAlarm, int conferenceId);
57public:
58    int id() const { return value("id").toInt(); }
59    int conferenceId() const { return value("xid_conference").toInt(); }
60    QDateTime start() const { return value("start").toDateTime(); }
61    /// duration of the event in seconds
62    int duration() const { return value("duration").toInt(); }
63    int trackId() const { return value("xid_track").toInt(); }
64    QString type() const { return value("type").toString(); }
65    QString language() const { return value("language").toString(); }
66    Favourite favourite() const { return static_cast<Favourite>(value("favourite").toInt()); }
67    bool isFavourite() const { return favourite() > 0; } // deprecated
68    bool hasAlarm() const { return value("alarm").toBool(); }
69    bool hasTimeConflict() const;
70    QString tag() const { return value("tag").toString(); }
71    QString title() const { return value("title").toString(); }
72    QString subtitle() const { return value("subtitle").toString(); }
73    QString abstract() const { return value("abstract").toString(); }
74    QString description() const { return value("description").toString(); }
75    // records from other tables associated with 'id'
76    Room* room();
77    QString roomName();
78    int roomId();
79    QStringList persons();
80    QMap<QString,QString> links();
81
82    void setId(int id) { setValue("id", id); }
83    void setConferenceId(int conferenceId) { setValue("xid_conference", conferenceId); }
84    void setStart(const QDateTime & start) { setValue("start", start); }
85    void setDuration(int duration) { setValue("duration", duration); }
86    void setTrackId(int trackId) { setValue("xid_track", trackId); }
87    void setType(const QString & type) { setValue("type", type); }
88    void setLanguage(const QString & language) { setValue("language", language); }
89    void setFavourite(Favourite favourite) { setValue("favourite", (int) favourite); }
90    void setFavourite(bool favourite) { setFavourite(favourite ? Favourite_strong : Favourite_no); } // deprecated
91    void setHasAlarm(bool alarm) { setValue("alarm", (int)((alarm))); }
92    void setTag(const QString& tag) { setValue("tag", tag); }
93    void setTitle(const QString& title) { setValue("title", title); }
94    void setSubtitle(const QString& subtitle) { setValue("subtitle", subtitle); }
95    void setAbstract(const QString& abstract) { setValue("abstract", abstract); }
96    void setDescription(const QString& description) { setValue("description", description); }
97    // records from other tables associated with 'id'
98    void setRoom(const QString& room);
99    void setPersons(const QStringList &persons);
100    void setLinks(const QMap<QString,QString> &aLinks);
101
102friend class EventTest;
103
104private:
105    QStringList mPersonsList;
106    QMap<QString,QString> mLinksList;
107    int mRoomId;
108    QString mRoomName;
109    Room* room_;
110};
111
112#endif // EVENT_H
113
Note: See TracBrowser for help on using the repository browser.