Changeset 41c4ceb in confclerk_git for src/mvc/event.cpp


Ignore:
Timestamp:
04/30/13 23:42:38 (9 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master, qt5
Children:
5130dc7
Parents:
83481c6
Message:

Now the dayChange time is taken into account. This fixes #43.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/event.cpp

    r83481c6 r41c4ceb  
    1818 * ConfClerk.  If not, see <http://www.gnu.org/licenses/>.
    1919 */
     20#include "conference.h"
    2021#include "event.h"
    2122#include "room.h"
     
    5455
    5556QList<Event> Event::getByDate(const QDate& date, int conferenceId, QString orderBy) {
     57    Q_ASSERT(conferenceId > 0);
     58    Conference conference = Conference::getById(conferenceId);
     59    QDateTime dayStart(date, conference.dayChangeTime(), Qt::UTC);
    5660    QSqlQuery query;
    5761    query.prepare(selectQuery() + QString("WHERE xid_conference = :conf AND start >= :start AND start < :end ORDER BY %1").arg(orderBy));
    5862    query.bindValue(":conf", conferenceId);
    59     query.bindValue(":start", convertToDb(date, QVariant::DateTime));
    60     query.bindValue(":end", convertToDb(date.addDays(1), QVariant::DateTime));
    61     return load(query);
    62 }
    63 
    64 QList<Event> Event::getByDateAndRoom(const QDate& date, int conferenceId)
    65 {
     63    query.bindValue(":start", dayStart.toTime_t());
     64    query.bindValue(":end", dayStart.addDays(1).toTime_t());
     65    return load(query);
     66}
     67
     68
     69QList<Event> Event::getByDateAndRoom(const QDate& date, int conferenceId) {
     70    Q_ASSERT(conferenceId > 0);
     71    Conference conference = Conference::getById(conferenceId);
     72    QDateTime dayStart(date, conference.dayChangeTime(), Qt::UTC);
    6673    QSqlQuery query;
    6774    QString aliasEvent("E");
     
    7077                    columnsForSelect(aliasEvent), Event::sTableName, aliasEvent, "EVENT_ROOM", aliasEventRoom));
    7178    query.bindValue(":conf", conferenceId);
    72     query.bindValue(":start", convertToDb(date, QVariant::DateTime));
    73     query.bindValue(":end", convertToDb(date.addDays(1), QVariant::DateTime));
     79    query.bindValue(":start", dayStart.toTime_t());
     80    query.bindValue(":end", dayStart.addDays(1).toTime_t());
    7481
    7582    return load(query);
     
    104111
    105112
    106 QList<Event> Event::getFavByDate(const QDate& date, int conferenceId)
    107 {
     113QList<Event> Event::getFavByDate(const QDate& date, int conferenceId) {
     114    Q_ASSERT(conferenceId > 0);
     115    Conference conference = Conference::getById(conferenceId);
     116    QDateTime dayStart(date, conference.dayChangeTime(), Qt::UTC);
    108117    QSqlQuery query;
    109118    query.prepare(selectQuery() + QString("WHERE xid_conference = :conf AND start >= :start AND start < :end AND favourite = 1 ORDER BY start, duration"));
    110119    query.bindValue(":conf", conferenceId);
    111     query.bindValue(":start", convertToDb(date, QVariant::DateTime));
    112     query.bindValue(":end", convertToDb(date.addDays(1), QVariant::DateTime));
     120    query.bindValue(":start", dayStart.toTime_t());
     121    query.bindValue(":end", dayStart.addDays(1).toTime_t());
    113122
    114123    return load(query);
     
    237246        }
    238247
     248        Q_ASSERT(conferenceId > 0);
     249        Conference conference = Conference::getById(conferenceId);
     250        QDateTime dayStart(date, conference.dayChangeTime(), Qt::UTC);
     251
    239252        query.bindValue(":conf", conferenceId);
    240         query.bindValue(":start", convertToDb(date, QVariant::DateTime));
    241         query.bindValue(":end", convertToDb(date.addDays(1), QVariant::DateTime));
     253        query.bindValue(":start", dayStart.toTime_t());
     254        query.bindValue(":end", dayStart.addDays(1).toTime_t());
    242255
    243256        list = load(query);
Note: See TracChangeset for help on using the changeset viewer.