source: src/mvc/conference.cpp @ ca90cb1

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

A header with the proper copyright/lincence statement was added into each source/header file.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 * Copyright (C) 2010 Ixonos Plc.
3 *
4 * This file is part of fosdem-schedule.
5 *
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)
9 * any later version.
10 *
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
14 * more details.
15 *
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/>.
18 */
19#include "conference.h"
20
21QSqlRecord 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
34QString const Conference::sTableName = QString("conference");
35
36Conference Conference::getById(int id)
37{
38    QSqlQuery query;
39    query.prepare(selectQuery() + "WHERE id = :id");
40    query.bindValue(":id", id);
41    return loadOne(query);
42}
43
44QList<Conference> Conference::getAll()
45{
46    QSqlQuery query;
47    query.prepare(selectQuery());
48    return load(query);
49}
50
51int Conference::activeConference()
52{
53    QSqlQuery query("SELECT id FROM conference WHERE active = 1");
54    query.exec();
55
56    QList<int> activeConfs;
57    while(query.next())
58        activeConfs.append(query.record().value("id").toInt());
59
60    if(activeConfs.count()==0) // no active DB
61        return 1;
62    else // even if there are more active confs, the first from the list is confidered active
63        return activeConfs[0];
64}
65
Note: See TracBrowser for help on using the repository browser.