source: src/mvc/conference.cpp @ a790a90

qt5
Last change on this file since a790a90 was 0bb39f5, checked in by pavelpa <pavelpa@…>, 12 years ago

removed appsettings

  • created 'active' column in 'conference' table
  • Property mode set to 100644
File size: 1.4 KB
Line 
1#include "conference.h"
2
3QSqlRecord const Conference::sColumns = Conference::toRecord(QList<QSqlField>()
4    << QSqlField("id", QVariant::Int)
5    << QSqlField("title", QVariant::String)
6    << QSqlField("subtitle", QVariant::String)
7    << QSqlField("venue", QVariant::String)
8    << QSqlField("city", QVariant::String)
9    << QSqlField("start", QVariant::DateTime)
10    << QSqlField("end", QVariant::DateTime)
11    << QSqlField("days", QVariant::Int)
12    << QSqlField("day_change", QVariant::Int)
13    << QSqlField("timeslot_duration", QVariant::Int)
14    << QSqlField("active", QVariant::Bool));
15
16QString const Conference::sTableName = QString("conference");
17
18Conference Conference::getById(int id)
19{
20    QSqlQuery query;
21    query.prepare(selectQuery() + "WHERE id = :id");
22    query.bindValue(":id", id);
23    return loadOne(query);
24}
25
26QList<Conference> Conference::getAll()
27{
28    QSqlQuery query;
29    query.prepare(selectQuery());
30    return load(query);
31}
32
33int Conference::activeConference()
34{
35    QSqlQuery query("SELECT id FROM conference WHERE active = 1");
36    query.exec();
37
38    QList<int> activeConfs;
39    while(query.next())
40        activeConfs.append(query.record().value("id").toInt());
41
42    if(activeConfs.count()==0) // no active DB
43        return 1;
44    else // even if there are more active confs, the first from the list is confidered active
45        return activeConfs[0];
46}
47
Note: See TracBrowser for help on using the repository browser.