source: src/mvc/conference.h

Last change on this file was ffb6be7, checked in by gregor herrmann <gregor@…>, 4 months ago

Bump copyright years.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 * Copyright (C) 2010 Ixonos Plc.
3 * Copyright (C) 2011-2021 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 CONFERENCE_H
21#define CONFERENCE_H
22
23#include <QDateTime>
24#include <QVector>
25#include <QStringList>
26
27#include "ormrecord.h"
28
29class Conference : public OrmRecord<Conference>
30{
31public:
32    static QSqlRecord const sColumns;
33    static QString const sTableName;
34
35public:
36    static Conference getById(int id);
37    static QList<Conference> getAll();
38
39    /// Returns the active conference. If no active conference can be found, it returns the conference with the lowest id.
40    /// If no conference exists or database errors occur, it returns -1.
41    static int activeConference();
42
43public:
44    int id() const { return value("id").toInt(); }
45    QString title() const { return value("title").toString(); }
46    QString subtitle() const { return value("subtitle").toString(); }
47    QString venue() const { return value("venue").toString(); }
48    QString city() const { return value("city").toString(); }
49    QDate start() const { return value("start").toDate(); }
50    QDate end() const { return value("end").toDate(); }
51    int dayChange() const { return value("day_change").toInt(); } // in seconds from 00:00
52    QTime dayChangeTime() const {QTime dayChangeTime(0, 0); return dayChangeTime.addSecs(dayChange());}
53    int timeslotDuration() const { return value("timeslot_duration").toInt(); } // in seconds
54    bool hasUtcOffset() const {return !value("utc_offset").isNull();}
55    int utcOffset() const {return value("utc_offset").toInt();}
56    bool hasDisplayTimeShift() const {return !value("display_time_shift").isNull();}
57    int displayTimeShift() const {return value("display_time_shift").toInt();}
58    void setDisplayTimeShift(int newValue) {setValue("display_time_shift", newValue); update("display_time_shift");}
59
60    bool isActive() const { return value("active").toBool(); }
61    QString url() const { return stringFromNullable(value("url")); }
62
63    void setUrl(const QString& url)
64    {
65        setValue("url", url.isNull() ? QVariant() : url);
66        update("url");
67    }
68
69    /// Returns a QTime that is shifted by displayTimeShift minutes
70    QTime shiftTime(const QTime& value) const;
71
72private:
73    static QString stringFromNullable(const QVariant& v)
74    {
75        if (v.isValid()) {
76            return v.toString();
77        } else {
78            return QString();
79        }
80    }
81};
82
83#endif /* CONFERENCE_H */
84
Note: See TracBrowser for help on using the repository browser.