1 | /* |
---|
2 | * Copyright (C) 2010 Ixonos Plc. |
---|
3 | * Copyright (C) 2011-2013 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 | #include "conference.h" |
---|
21 | #include "../sql/sqlengine.h" |
---|
22 | |
---|
23 | QSqlRecord const Conference::sColumns = Conference::toRecord(QList<QSqlField>() |
---|
24 | << QSqlField("id", QVariant::Int) |
---|
25 | << QSqlField("title", QVariant::String) |
---|
26 | << QSqlField("subtitle", QVariant::String) |
---|
27 | << QSqlField("venue", QVariant::String) |
---|
28 | << QSqlField("city", QVariant::String) |
---|
29 | << QSqlField("start", QVariant::DateTime) |
---|
30 | << QSqlField("end", QVariant::DateTime) |
---|
31 | << QSqlField("day_change", QVariant::Int) |
---|
32 | << QSqlField("timeslot_duration", QVariant::Int) |
---|
33 | << QSqlField("active", QVariant::Bool) |
---|
34 | << QSqlField("url", QVariant::String) |
---|
35 | ); |
---|
36 | |
---|
37 | QString const Conference::sTableName = QString("conference"); |
---|
38 | |
---|
39 | Conference Conference::getById(int id) |
---|
40 | { |
---|
41 | QSqlQuery query; |
---|
42 | query.prepare(selectQuery() + "WHERE id = :id"); |
---|
43 | query.bindValue(":id", id); |
---|
44 | return loadOne(query); |
---|
45 | } |
---|
46 | |
---|
47 | QList<Conference> Conference::getAll() |
---|
48 | { |
---|
49 | QSqlQuery query; |
---|
50 | query.prepare(selectQuery()); |
---|
51 | return load(query); |
---|
52 | } |
---|
53 | |
---|
54 | int Conference::activeConference() { |
---|
55 | QSqlQuery query("SELECT id FROM conference ORDER BY active DESC, id LIMIT 1"); |
---|
56 | if (!query.exec() || !query.first()) return -1; |
---|
57 | return query.record().value("id").toInt(); |
---|
58 | } |
---|
59 | |
---|
60 | |
---|