Changeset d06ae27 for src/sql


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

store URL's for conferences

  • use it at update
  • let user update the url before request
Location:
src/sql
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/sql/schedulexmlparser.cpp

    rbe9b645 rd06ae27  
    3131}
    3232
    33 int ScheduleXmlParser::parseData(const QByteArray &aData)
     33int ScheduleXmlParser::parseData(const QByteArray &aData, const QString& url)
    3434{
    3535    QDomDocument document;
     
    5757            conference["day_change"] = conferenceElement.firstChildElement("day_change").text(); // time
    5858            conference["timeslot_duration"] = conferenceElement.firstChildElement("timeslot_duration").text(); // time
     59            conference["url"] = url;
    5960            SqlEngine::addConferenceToDB(conference);
    6061            confId = conference["id"].toInt();
  • src/sql/schedulexmlparser.h

    rbe9b645 rd06ae27  
    2929
    3030    public slots:
    31         int parseData(const QByteArray &aData); // returns 'confId' of parsed conference schedule
     31        int parseData(const QByteArray &aData, const QString& url); // returns 'confId' of parsed conference schedule
    3232
    3333    signals:
  • src/sql/sqlengine.cpp

    rbe9b645 rd06ae27  
    102102        if(!confId) // conference 'aConference' isn't in the table => insert
    103103        {
    104             QString values = QString("'%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8', '%9'") \
    105                              .arg(aConference["title"]) \
    106                              .arg(aConference["subtitle"]) \
    107                              .arg(aConference["venue"]) \
    108                              .arg(aConference["city"]) \
    109                              .arg(QDateTime(QDate::fromString(aConference["start"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t()) \
    110                              .arg(QDateTime(QDate::fromString(aConference["end"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t()) \
    111                              .arg(aConference["days"]) \
    112                              .arg(-QTime::fromString(aConference["day_change"],TIME_FORMAT).secsTo(QTime(0,0))) \
    113                              .arg(-QTime::fromString(aConference["timeslot_duration"],TIME_FORMAT).secsTo(QTime(0,0)));
    114                              values.append(QString(", '%1'").arg(confsList.count()>0?"0":"1"));
    115 
    116             QString query = QString("INSERT INTO CONFERENCE (title,subtitle,venue,city,start,end,days,day_change,timeslot_duration,active) VALUES (%1)").arg(values);
    117             QSqlQuery result (query, db);
    118             aConference["id"] = result.lastInsertId().toString(); // 'id' is assigned automatically
     104            QSqlQuery query(db);
     105            query.prepare("INSERT INTO CONFERENCE (title,url,subtitle,venue,city,start,end,days,"
     106                                                    "day_change,timeslot_duration,active) "
     107                            " VALUES (:title,:url,:subtitle,:venue,:city,:start,:end,:days,"
     108                                                    ":day_change,:timeslot_duration,:active)");
     109            foreach (QString prop_name, (QList<QString>() << "title" << "url" << "subtitle" << "venue" << "city" << "days")) {
     110                query.bindValue(QString(":") + prop_name, aConference[prop_name]);
     111            }
     112            query.bindValue(":start", QDateTime(QDate::fromString(aConference["start"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t());
     113            query.bindValue(":end", QDateTime(QDate::fromString(aConference["end"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t());
     114            query.bindValue(":day_change", -QTime::fromString(aConference["day_change"],TIME_FORMAT).secsTo(QTime(0,0)));
     115            query.bindValue(":day_change", -QTime::fromString(aConference["timeslot_duration"],TIME_FORMAT).secsTo(QTime(0,0)));
     116            query.bindValue(":active", confsList.count() > 0 ? 0 : 1);
     117            query.exec();
     118            aConference["id"] = query.lastInsertId().toString(); // 'id' is assigned automatically
    119119        }
    120120    }
Note: See TracChangeset for help on using the changeset viewer.