1 | #ifndef EVENT_H |
---|
2 | #define EVENT_H |
---|
3 | |
---|
4 | #include <QDateTime> |
---|
5 | #include <QVector> |
---|
6 | #include <QStringList> |
---|
7 | |
---|
8 | #include <ormrecord.h> |
---|
9 | |
---|
10 | /** |
---|
11 | NoSuchEventException is thrown when required event does not exist. |
---|
12 | */ |
---|
13 | class NoSuchEventException |
---|
14 | { |
---|
15 | }; |
---|
16 | |
---|
17 | class Event : public OrmRecord<Event> |
---|
18 | { |
---|
19 | public: |
---|
20 | static const QSqlRecord sColumns; |
---|
21 | //static QString const sTableName; |
---|
22 | static const QString sTable1Name; |
---|
23 | static const QString sTable2Name; |
---|
24 | static const int sTable1ColCount; |
---|
25 | static const int sTable2ColCount; |
---|
26 | static const QString XID_ACTIVITY; |
---|
27 | static const QString START; |
---|
28 | public: |
---|
29 | static Event getById(int id, int conferenceId); |
---|
30 | static QList<Event> getByDate(const QDate & date, int conferenceId, QString orderBy); |
---|
31 | static QList<Event> getFavByDate(const QDate & date, int conferenceId); // get Favourities by Date |
---|
32 | public: |
---|
33 | // Table 1 |
---|
34 | int id() const |
---|
35 | { |
---|
36 | return value("id").toInt(); |
---|
37 | } |
---|
38 | |
---|
39 | int conferenceId() const |
---|
40 | { |
---|
41 | return value("xid_conference").toInt(); |
---|
42 | } |
---|
43 | |
---|
44 | QDateTime start() const |
---|
45 | { |
---|
46 | return value(START).toDateTime(); |
---|
47 | } |
---|
48 | |
---|
49 | int duration() const |
---|
50 | { |
---|
51 | return value("duration").toInt(); |
---|
52 | } |
---|
53 | |
---|
54 | int activityId() const |
---|
55 | { |
---|
56 | return value(XID_ACTIVITY).toInt(); |
---|
57 | } |
---|
58 | |
---|
59 | QString type() const |
---|
60 | { |
---|
61 | return value("type").toString(); |
---|
62 | } |
---|
63 | |
---|
64 | QString language() const |
---|
65 | { |
---|
66 | return value("language").toString(); |
---|
67 | } |
---|
68 | |
---|
69 | bool isFavourite() const |
---|
70 | { |
---|
71 | return value("favourite").toBool(); |
---|
72 | } |
---|
73 | |
---|
74 | bool hasAlarm() const |
---|
75 | { |
---|
76 | return value("alarm").toBool(); |
---|
77 | } |
---|
78 | |
---|
79 | // Table 2 : virtual table for FTS (Full Text Search) |
---|
80 | QString tag() const |
---|
81 | { |
---|
82 | return value("tag").toString(); |
---|
83 | } |
---|
84 | |
---|
85 | QString title() const |
---|
86 | { |
---|
87 | return value("title").toString(); |
---|
88 | } |
---|
89 | |
---|
90 | QString subtitle() const |
---|
91 | { |
---|
92 | return value("subtitle").toString(); |
---|
93 | } |
---|
94 | |
---|
95 | QString abstract() const |
---|
96 | { |
---|
97 | return value("abstract").toString(); |
---|
98 | } |
---|
99 | |
---|
100 | QString description() const |
---|
101 | { |
---|
102 | return value("description").toString(); |
---|
103 | } |
---|
104 | |
---|
105 | // Table 1 |
---|
106 | void setId(int id) |
---|
107 | { |
---|
108 | setValue("id", id); |
---|
109 | } |
---|
110 | |
---|
111 | void setConferenceId(int conferenceId) |
---|
112 | { |
---|
113 | setValue("xid_conference", conferenceId); |
---|
114 | } |
---|
115 | |
---|
116 | void setStart(const QDateTime & start) |
---|
117 | { |
---|
118 | setValue(START, start); |
---|
119 | } |
---|
120 | |
---|
121 | void setDuration(int duration) |
---|
122 | { |
---|
123 | setValue("duration", duration); |
---|
124 | } |
---|
125 | |
---|
126 | void setActivityId(int activityId) |
---|
127 | { |
---|
128 | setValue(XID_ACTIVITY, activityId); |
---|
129 | } |
---|
130 | |
---|
131 | void setType(const QString & type) |
---|
132 | { |
---|
133 | setValue("type", type); |
---|
134 | } |
---|
135 | |
---|
136 | void setLanguage(const QString & language) |
---|
137 | { |
---|
138 | setValue("language", language); |
---|
139 | } |
---|
140 | |
---|
141 | void setFavourite(bool favourite) |
---|
142 | { |
---|
143 | setValue("favourite", (int)((favourite))); |
---|
144 | } |
---|
145 | |
---|
146 | void setHasAlarm(bool alarm) |
---|
147 | { |
---|
148 | setValue("alarm", (int)((alarm))); } |
---|
149 | // Table 2 : virtual table for FTS (Full Text Search) |
---|
150 | void setTag(const QString& tag) { setValue("tag", tag); } |
---|
151 | void setTitle(const QString& title) { setValue("title", title); } |
---|
152 | void setSubtitle(const QString& subtitle) { setValue("subtitle", subtitle); } |
---|
153 | void setAbstract(const QString& abstract) { setValue("abstract", abstract); } |
---|
154 | void setDescription(const QString& description) { setValue("description", description); } |
---|
155 | |
---|
156 | friend class EventTest; |
---|
157 | }; |
---|
158 | |
---|
159 | #endif // EVENT_H |
---|
160 | |
---|