[ca90cb1] | 1 | /* |
---|
| 2 | * Copyright (C) 2010 Ixonos Plc. |
---|
| 3 | * |
---|
[6df32f2] | 4 | * This file is part of ConfClerk. |
---|
[ca90cb1] | 5 | * |
---|
[6df32f2] | 6 | * ConfClerk is free software: you can redistribute it and/or modify it |
---|
[ca90cb1] | 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 | * |
---|
[6df32f2] | 11 | * ConfClerk is distributed in the hope that it will be useful, but |
---|
[ca90cb1] | 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 |
---|
[6df32f2] | 17 | * ConfClerk. If not, see <http://www.gnu.org/licenses/>. |
---|
[ca90cb1] | 18 | */ |
---|
[69393c0] | 19 | #include "conference.h" |
---|
[d97bcab] | 20 | #include "../sql/sqlengine.h" |
---|
[69393c0] | 21 | |
---|
| 22 | QSqlRecord const Conference::sColumns = Conference::toRecord(QList<QSqlField>() |
---|
| 23 | << QSqlField("id", QVariant::Int) |
---|
| 24 | << QSqlField("title", QVariant::String) |
---|
| 25 | << QSqlField("subtitle", QVariant::String) |
---|
| 26 | << QSqlField("venue", QVariant::String) |
---|
| 27 | << QSqlField("city", QVariant::String) |
---|
| 28 | << QSqlField("start", QVariant::DateTime) |
---|
| 29 | << QSqlField("end", QVariant::DateTime) |
---|
| 30 | << QSqlField("days", QVariant::Int) |
---|
| 31 | << QSqlField("day_change", QVariant::Int) |
---|
[0bb39f5] | 32 | << QSqlField("timeslot_duration", QVariant::Int) |
---|
[d06ae27] | 33 | << QSqlField("active", QVariant::Bool) |
---|
[cec47c6] | 34 | << QSqlField("url", QVariant::String) |
---|
| 35 | << QSqlField("map", QVariant::String) |
---|
| 36 | ); |
---|
[69393c0] | 37 | |
---|
| 38 | QString const Conference::sTableName = QString("conference"); |
---|
| 39 | |
---|
| 40 | Conference Conference::getById(int id) |
---|
| 41 | { |
---|
| 42 | QSqlQuery query; |
---|
| 43 | query.prepare(selectQuery() + "WHERE id = :id"); |
---|
| 44 | query.bindValue(":id", id); |
---|
| 45 | return loadOne(query); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | QList<Conference> Conference::getAll() |
---|
| 49 | { |
---|
| 50 | QSqlQuery query; |
---|
| 51 | query.prepare(selectQuery()); |
---|
| 52 | return load(query); |
---|
| 53 | } |
---|
| 54 | |
---|
[0bb39f5] | 55 | int Conference::activeConference() |
---|
| 56 | { |
---|
[d97bcab] | 57 | { |
---|
| 58 | QSqlQuery query("SELECT id FROM conference WHERE active = 1"); |
---|
| 59 | query.exec(); |
---|
[0bb39f5] | 60 | |
---|
[d97bcab] | 61 | // TODO: change it so that it will select somw existing ID |
---|
[0bb39f5] | 62 | |
---|
[d97bcab] | 63 | if (query.next()) { |
---|
| 64 | return query.record().value("id").toInt(); |
---|
| 65 | } |
---|
| 66 | } |
---|
[d06ae27] | 67 | |
---|
[d97bcab] | 68 | QSqlQuery query2("SELECT id FROM conference ORDER BY id"); |
---|
| 69 | if (query2.next()) { |
---|
| 70 | return query2.record().value("id").toInt(); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | return -1; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | void Conference::deleteConference(int id) |
---|
| 77 | { |
---|
| 78 | SqlEngine::deleteConference(id); |
---|
[0bb39f5] | 79 | } |
---|
| 80 | |
---|