Changeset 8bd618c for src/mvc


Ignore:
Timestamp:
10/17/12 20:49:16 (10 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master, qt5
Children:
908b4ce
Parents:
95257a6
Message:

We added the conferenceId to some alarm related methods (ticket #41).

Location:
src/mvc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/conference.cpp

    r95257a6 r8bd618c  
    5252}
    5353
    54 int Conference::activeConference()
    55 {
    56     {
    57         QSqlQuery query("SELECT id FROM conference WHERE active = 1");
    58         query.exec();
    59 
    60         // TODO: change it so that it will select somw existing ID
    61 
    62         if (query.next()) {
    63             return query.record().value("id").toInt();
    64         }
    65     }
    66 
    67     QSqlQuery query2("SELECT id FROM conference ORDER BY id");
    68     if (query2.next()) {
    69         return query2.record().value("id").toInt();
    70     }
    71 
    72     return -1;
     54int Conference::activeConference() {
     55    QSqlQuery query("SELECT id FROM conference ORDER BY active DESC, id LIMIT 1");
     56    if (!query.exec() || !query.first()) return -1;
     57    return query.record().value("id").toInt();
    7358}
    7459
  • src/mvc/conference.h

    r95257a6 r8bd618c  
    3636    static Conference getById(int id);
    3737    static QList<Conference> getAll();
    38     static int activeConference(); ///< returns -1 if no conference is active
     38
     39    /// Returns the active conference. If no active conference can be found, it returns the conference with the lowest id.
     40    /// If no conference exists or database errors occur, it returns -1.
     41    static int activeConference();
    3942
    4043public:
Note: See TracChangeset for help on using the changeset viewer.