source: src/mvc/event.h @ c790268

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

implemented JOINing two tables

  • modified 'ormrecord' to support JOINing two tables
  • modified 'event' accordingly, since its items/columns are splitted into two separate tables
  • Property mode set to 100644
File size: 2.6 KB
Line 
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*/
13class NoSuchEventException
14{
15};
16
17class Event : public OrmRecord<Event>
18{
19public:
20    static QSqlRecord const sColumns;
21    //static QString const sTableName;
22    static QString const sTable1Name;
23    static QString const sTable2Name;
24    static int const sTable1ColCount;
25    static int const sTable2ColCount;
26
27public:
28    static Event getById(int id, int conferenceId);
29    static QList<Event> getByDate(const QDate& date, int conferenceId);
30
31public:
32    // Table 1
33    int id() const { return value("id").toInt(); }
34    int conferenceId() const { return value("xid_conference").toInt(); }
35    QDateTime start() const { return value("start").toDateTime(); }
36    int duration() const { return value("duration").toInt(); }
37    int activityId() const { return value("xid_activity").toInt(); }
38    QString type() const { return value("type").toString(); }
39    QString language() const { return value("language").toString(); }
40    bool isFavourite() const { return value("favourite").toBool(); }
41    // Table 2 : virtual table for FTS (Full Text Search)
42    QString tag() const { return value("tag").toString(); }
43    QString title() const { return value("title").toString(); }
44    QString subtitle() const { return value("subtitle").toString(); }
45    QString abstract() const { return value("abstract").toString(); }
46    QString description() const { return value("description").toString(); }
47
48    // Table 1
49    void setId(int id) { setValue("id", id); }
50    void setConferenceId(int conferenceId) { setValue("xid_conference", conferenceId); }
51    void setStart(const QDateTime& start) { setValue("start", start); }
52    void setDuration(int duration) { setValue("duration", duration); }
53    void setActivityId(int activityId) { setValue("xid_activity", activityId); }
54    void setType(const QString& type) { setValue("type", type); }
55    void setLanguage(const QString& language) { setValue("language", language); }
56    void setFavourite(bool favourite) { setValue("favourite", favourite); }
57    // Table 2 : virtual table for FTS (Full Text Search)
58    void setTag(const QString& tag) { setValue("tag", tag); }
59    void setTitle(const QString& title) { setValue("title", title); }
60    void setSubtitle(const QString& subtitle) { setValue("subtitle", subtitle); }
61    void setAbstract(const QString& abstract) { setValue("abstract", abstract); }
62    void setDescription(const QString& description) { setValue("description", description); }
63
64friend class EventTest;
65};
66
67#endif // EVENT_H
68
Note: See TracBrowser for help on using the repository browser.