Changeset 7d7659d for src/mvc


Ignore:
Timestamp:
01/21/10 14:24:08 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
06570e9
Parents:
d8d5bd2
Message:

combined EVENT and VIRTUAL_EVENT => 'EVENT' now

  • Maemo sqlite doesn't support Full-Text-Search
Location:
src/mvc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/event.cpp

    rd8d5bd2 r7d7659d  
    11#include "event.h"
    22
    3 // 'event' record is splitted into two separate tables 'event' and 'virtual_event'
    4 // for the FTS (Full-Text-Search) support and so, it is necessary to provide/use
    5 // two table names + corresponding parameters/methods, see bellow
    6 QString const Event::sTable1Name = QString("event");
    7 QString const Event::sTable2Name = QString("virtual_event");
    8 int const Event::sTable1ColCount = 9; // see 'toRecord()' for more details
    9 int const Event::sTable2ColCount = 5; // see 'toRecord()' for more details
     3QString const Event::sTableName = QString("event");
    104
    115QSqlRecord const Event::sColumns = Event::toRecord(QList<QSqlField>()
    12     /* 'columns from Table 1 */
    136    << QSqlField("id", QVariant::Int)
    147    << QSqlField("xid_conference", QVariant::Int)
     
    2013    << QSqlField("favourite", QVariant::Bool)
    2114    << QSqlField("alarm", QVariant::Bool)
    22     /* 'columns' from Table2 */
    2315    << QSqlField("tag", QVariant::String)
    2416    << QSqlField("title", QVariant::String)
     
    3022Event Event::getById(int id, int conferenceId)
    3123{
     24
    3225    QSqlQuery query;
    33     query.prepare(
    34             selectQueryJoin2T("id")
    35             + QString("WHERE %1.id = :id AND %1.xid_conference = :conf").arg(sTable1Name));
     26    query.prepare(selectQuery() + "WHERE id = :id AND xid_conference = :conf");
    3627    query.bindValue(":id", id);
    3728    query.bindValue(":conf", conferenceId);
    38 
    3929    return loadOne(query);
    4030}
     
    4333{
    4434    QSqlQuery query;
    45     query.prepare(
    46             selectQueryJoin2T("id")
    47             + QString("WHERE %1.xid_conference = :conf AND %1.start >= :start AND %1.start < :end ORDER BY %1.%2").arg(sTable1Name).arg(orderBy));
     35    query.prepare(selectQuery() + QString("WHERE xid_conference = :conf AND start >= :start AND start < :end ORDER BY %1").arg(orderBy));
    4836    query.bindValue(":conf", conferenceId);
    4937    query.bindValue(":start", convertToDb(date, QVariant::DateTime));
     
    5644{
    5745    QSqlQuery query;
    58     query.prepare(
    59             selectQueryJoin2T("id")
    60             + QString("WHERE %1.xid_conference = :conf AND %1.start >= :start AND %1.start < :end AND %1.favourite = 1 ORDER BY %1.start").arg(sTable1Name));
     46    query.prepare(selectQuery() + QString("WHERE xid_conference = :conf AND start >= :start AND start < :end AND favourite = 1 ORDER BY start"));
    6147    query.bindValue(":conf", conferenceId);
    6248    query.bindValue(":start", convertToDb(date, QVariant::DateTime));
     
    117103{
    118104
    119     QString strQuery = QString("SELECT %1 FROM EVENT INNER JOIN VIRTUAL_EVENT USING (xid_conference, id) "
    120         "INNER JOIN SEARCH_EVENT USING (xid_conference, id) ").arg( columnsForSelectJoin2T() );
    121     strQuery += QString(
    122         "WHERE %1.xid_conference = :conf AND %1.start >= :start AND %1.start < :end ORDER BY %1.%2").arg(sTable1Name, orderBy);
     105    QString strQuery = QString("SELECT %1 FROM EVENT INNER JOIN SEARCH_EVENT USING (xid_conference, id) ").arg(columnsForSelect());
     106    strQuery += QString("WHERE xid_conference = :conf AND start >= :start AND start < :end ORDER BY %1").arg(orderBy);
    123107    qDebug() << strQuery;
    124108    QSqlQuery query;
  • src/mvc/event.h

    rd8d5bd2 r7d7659d  
    1919public:
    2020    static const QSqlRecord sColumns;
    21     //static QString const sTableName;
    22     static const QString sTable1Name;
    23     static const QString sTable2Name;
    24     static const int sTable1ColCount;
    25     static const int sTable2ColCount;
     21    static QString const sTableName;
    2622public:
    2723    static Event getById(int id, int conferenceId);
     
    3026    static QList<Event> getSearchResultByDate(const QDate& date, int conferenceId, QString orderBy);
    3127public:
    32     // Table 1
    3328    int id() const { return value("id").toInt(); }
    3429    int conferenceId() const { return value("xid_conference").toInt(); }
     
    4136    bool hasAlarm() const { return value("alarm").toBool(); }
    4237    bool hasTimeConflict() const { return true; /*return value("warning").toBool()*/; } //TODO
    43     // Table 2 : virtual table for FTS (Full Text Search)
    4438    QString tag() const { return value("tag").toString(); }
    4539    QString title() const { return value("title").toString(); }
     
    5145    QStringList persons() const;
    5246
    53     // Table 1
    5447    void setId(int id) { setValue("id", id); }
    5548    void setConferenceId(int conferenceId) { setValue("xid_conference", conferenceId); }
     
    6154    void setFavourite(bool favourite) { setValue("favourite", (int)((favourite))); }
    6255    void setHasAlarm(bool alarm) { setValue("alarm", (int)((alarm))); }
    63     // Table 2 : virtual table for FTS (Full Text Search)
    6456    void setTag(const QString& tag) { setValue("tag", tag); }
    6557    void setTitle(const QString& title) { setValue("title", title); }
Note: See TracChangeset for help on using the changeset viewer.