]> ToastFreeware Gitweb - toast/confclerk.git/blobdiff - src/mvc/event.cpp
search fixed
[toast/confclerk.git] / src / mvc / event.cpp
index a65bb4ba1709eedf6db1b85a175c5ce9372225c7..d3c69209d8bc4150169e3dc066a7e063436eee41 100644 (file)
@@ -56,8 +56,8 @@ QList<Event> Event::getByDateAndRoom(const QDate& date, int conferenceId)
 
 QList<Event> Event::nowEvents(int conferenceId, QString orderBy)
 {
-    //uint curTime_t =  QDateTime(QDate::currentDate(),QTime::currentTime(),Qt::UTC).toTime_t();
-    uint curTime_t = 1265457610; // for testing
+    uint curTime_t =  QDateTime(QDate::currentDate(),QTime::currentTime(),Qt::UTC).toTime_t();
+    //uint curTime_t = 1265457610; // for testing
 
     QSqlQuery query;
     query.prepare(selectQuery() + QString("WHERE xid_conference = :conf AND start <= :now1 AND ( start + duration ) > :now2 ORDER BY %1").arg(orderBy));
@@ -73,16 +73,14 @@ QList<Event> Event::conflictEvents(int aEventId, int conferenceId)
     QSqlQuery query;
     Event event = Event::getById(aEventId,conferenceId);
     query.prepare(selectQuery() + "WHERE xid_conference = :conf AND ( \
-           ( start < :start1 AND ( start + duration ) > :start2 ) \
-        OR ( start > :start3 AND ( start + duration ) < :end1 ) \
-        OR ( start < :end2  AND ( start + duration ) > :end3 ) ) AND favourite = 1 AND NOT id = :id ORDER BY start");
+           ( start >= :s1 AND ( start + duration ) < :e1 ) \
+        OR ( ( start + duration ) > :s2 AND start < :e2 ) ) \
+        AND favourite = 1 AND NOT id = :id ORDER BY start");
     query.bindValue(":conf", event.conferenceId());
-    query.bindValue(":start1", convertToDb(event.start(), QVariant::DateTime));
-    query.bindValue(":start2", convertToDb(event.start(), QVariant::DateTime));
-    query.bindValue(":start3", convertToDb(event.start(), QVariant::DateTime));
-    query.bindValue(":end1", convertToDb(event.start().toTime_t()+event.duration(), QVariant::DateTime));
-    query.bindValue(":end2", convertToDb(event.start().toTime_t()+event.duration(), QVariant::DateTime));
-    query.bindValue(":end3", convertToDb(event.start().toTime_t()+event.duration(), QVariant::DateTime));
+    query.bindValue(":s1", convertToDb(event.start(), QVariant::DateTime));
+    query.bindValue(":e1", convertToDb(event.start().toTime_t()+event.duration(), QVariant::DateTime));
+    query.bindValue(":s2", convertToDb(event.start(), QVariant::DateTime));
+    query.bindValue(":e2", convertToDb(event.start().toTime_t()+event.duration(), QVariant::DateTime));
     query.bindValue(":id", event.id());
 
     return load(query);
@@ -195,10 +193,9 @@ void Event::setLinks(const QMap<QString,QString> &aLinks)
 
 QList<Event> Event::getSearchResultByDate(const QDate& date, int conferenceId, QString orderBy)
 {
-
     QString strQuery = QString("SELECT %1 FROM EVENT INNER JOIN SEARCH_EVENT USING (xid_conference, id) ").arg(columnsForSelect());
     strQuery += QString("WHERE xid_conference = :conf AND start >= :start AND start < :end ORDER BY %1").arg(orderBy);
-    qDebug() << strQuery;
+    //qDebug() << strQuery;
     QList<Event> list;
     QSqlQuery query;
     try{