Ignore:
Timestamp:
04/15/10 14:49:59 (12 years ago)
Author:
kirilma <kirilma@…>
Branches:
master, qt5
Children:
04acaf9
Parents:
f5b68a4
Message:

implement deleting a conference

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/conference.cpp

    rf5b68a4 rd97bcab  
    1818 */
    1919#include "conference.h"
     20#include "../sql/sqlengine.h"
    2021
    2122QSqlRecord const Conference::sColumns = Conference::toRecord(QList<QSqlField>()
     
    5253int Conference::activeConference()
    5354{
    54     QSqlQuery query("SELECT id FROM conference WHERE active = 1");
    55     query.exec();
     55    {
     56        QSqlQuery query("SELECT id FROM conference WHERE active = 1");
     57        query.exec();
    5658
    57     QList<int> activeConfs;
    58     while(query.next())
    59         activeConfs.append(query.record().value("id").toInt());
     59        // TODO: change it so that it will select somw existing ID
    6060
    61     qDebug() << __PRETTY_FUNCTION__
    62         << "activeConfs.count()" << activeConfs.count()
    63         ;
     61        if (query.next()) {
     62            return query.record().value("id").toInt();
     63        }
     64    }
    6465
    65     if(activeConfs.count()==0) // no active DB
    66         return 1;
    67     else // even if there are more active confs, the first from the list is confidered active
    68         return activeConfs[0];
     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;
    6972}
    7073
     74void Conference::deleteConference(int id)
     75{
     76    SqlEngine::deleteConference(id);
     77}
     78
Note: See TracChangeset for help on using the changeset viewer.