- Timestamp:
- 04/15/10 14:01:48 (13 years ago)
- Branches:
- master, qt5
- Children:
- f5b68a4
- Parents:
- be9b645
- Location:
- src/sql
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sql/schedulexmlparser.cpp
rbe9b645 rd06ae27 31 31 } 32 32 33 int ScheduleXmlParser::parseData(const QByteArray &aData )33 int ScheduleXmlParser::parseData(const QByteArray &aData, const QString& url) 34 34 { 35 35 QDomDocument document; … … 57 57 conference["day_change"] = conferenceElement.firstChildElement("day_change").text(); // time 58 58 conference["timeslot_duration"] = conferenceElement.firstChildElement("timeslot_duration").text(); // time 59 conference["url"] = url; 59 60 SqlEngine::addConferenceToDB(conference); 60 61 confId = conference["id"].toInt(); -
src/sql/schedulexmlparser.h
rbe9b645 rd06ae27 29 29 30 30 public slots: 31 int parseData(const QByteArray &aData ); // returns 'confId' of parsed conference schedule31 int parseData(const QByteArray &aData, const QString& url); // returns 'confId' of parsed conference schedule 32 32 33 33 signals: -
src/sql/sqlengine.cpp
rbe9b645 rd06ae27 102 102 if(!confId) // conference 'aConference' isn't in the table => insert 103 103 { 104 QS tring 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 automatically104 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 119 119 } 120 120 }
Note: See TracChangeset
for help on using the changeset viewer.