source: src/mvc/conference.cpp @ 3329d39

qt5
Last change on this file since 3329d39 was d97bcab, checked in by kirilma <kirilma@…>, 12 years ago

implement deleting a conference

pass event about it to mainwindow to update select control
fix Conference::activeConference() to work when first conference is removed

  • Property mode set to 100644
File size: 2.3 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#include "../sql/sqlengine.h"
21
22QSqlRecord 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)
32    << QSqlField("timeslot_duration", QVariant::Int)
33    << QSqlField("active", QVariant::Bool)
34    << QSqlField("url", QVariant::String));
35
36QString const Conference::sTableName = QString("conference");
37
38Conference Conference::getById(int id)
39{
40    QSqlQuery query;
41    query.prepare(selectQuery() + "WHERE id = :id");
42    query.bindValue(":id", id);
43    return loadOne(query);
44}
45
46QList<Conference> Conference::getAll()
47{
48    QSqlQuery query;
49    query.prepare(selectQuery());
50    return load(query);
51}
52
53int Conference::activeConference()
54{
55    {
56        QSqlQuery query("SELECT id FROM conference WHERE active = 1");
57        query.exec();
58
59        // TODO: change it so that it will select somw existing ID
60
61        if (query.next()) {
62            return query.record().value("id").toInt();
63        }
64    }
65
66    QSqlQuery query2("SELECT id FROM conference ORDER BY id");
67    if (query2.next()) {
68        return query2.record().value("id").toInt();
69    }
70
71    return -1;
72}
73
74void Conference::deleteConference(int id)
75{
76    SqlEngine::deleteConference(id);
77}
78
Note: See TracBrowser for help on using the repository browser.