2 * Copyright (C) 2010 Ixonos Plc.
4 * This file is part of fosdem-schedule.
6 * fosdem-schedule is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 2 of the License, or (at your option)
11 * fosdem-schedule is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * fosdem-schedule. If not, see <http://www.gnu.org/licenses/>.
19 #include "conference.h"
21 QSqlRecord const Conference::sColumns = Conference::toRecord(QList<QSqlField>()
22 << QSqlField("id", QVariant::Int)
23 << QSqlField("title", QVariant::String)
24 << QSqlField("subtitle", QVariant::String)
25 << QSqlField("venue", QVariant::String)
26 << QSqlField("city", QVariant::String)
27 << QSqlField("start", QVariant::DateTime)
28 << QSqlField("end", QVariant::DateTime)
29 << QSqlField("days", QVariant::Int)
30 << QSqlField("day_change", QVariant::Int)
31 << QSqlField("timeslot_duration", QVariant::Int)
32 << QSqlField("active", QVariant::Bool)
33 << QSqlField("url", QVariant::String));
35 QString const Conference::sTableName = QString("conference");
37 Conference Conference::getById(int id)
40 query.prepare(selectQuery() + "WHERE id = :id");
41 query.bindValue(":id", id);
42 return loadOne(query);
45 QList<Conference> Conference::getAll()
48 query.prepare(selectQuery());
52 int Conference::activeConference()
54 QSqlQuery query("SELECT id FROM conference WHERE active = 1");
57 QList<int> activeConfs;
59 activeConfs.append(query.record().value("id").toInt());
61 qDebug() << __PRETTY_FUNCTION__
62 << "activeConfs.count()" << activeConfs.count()
65 if(activeConfs.count()==0) // no active DB
67 else // even if there are more active confs, the first from the list is confidered active
68 return activeConfs[0];