- Timestamp:
- 01/21/10 20:48:46 (13 years ago)
- Branches:
- master, qt5
- Children:
- c718a77
- Parents:
- 30e2bdf
- Location:
- src/sql
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sql/schedulexmlparser.cpp
r30e2bdf r1735f55 24 24 if (!scheduleElement.isNull()) 25 25 { 26 // TODO: assign conferenceID based on eg. title 27 int conferenceID = 1; // HARD-WIRED for now to '1' - only one Conference 28 26 int confId = 0; 29 27 QDomElement conferenceElement = scheduleElement.firstChildElement("conference"); 30 28 if (!conferenceElement.isNull()) 31 29 { 32 30 QHash<QString,QString> conference; 33 conference["id"] = QString::number( conferenceID,10);31 conference["id"] = QString::number(0); // conference ID is assigned automatically, or obtained from the DB 34 32 conference["title"] = conferenceElement.firstChildElement("title").text(); 35 33 conference["subtitle"] = conferenceElement.firstChildElement("subtitle").text(); … … 42 40 conference["timeslot_duration"] = conferenceElement.firstChildElement("timeslot_duration").text(); // time 43 41 aDBEngine->addConferenceToDB(conference); 42 confId = conference["id"].toInt(); 44 43 } 45 44 … … 76 75 room["name"] = roomElement.attribute("name"); 77 76 room["event_id"] = eventElement.attribute("id"); 78 room["conference_id"] = QString::number(conf erenceID,10);77 room["conference_id"] = QString::number(confId,10); 79 78 room["picture"] = "NOT DEFINED YET"; // TODO: implement some mapping to assign correct picture to specified room_name 80 79 aDBEngine->addRoomToDB(room); … … 83 82 QHash<QString,QString> event; 84 83 event["id"] = eventElement.attribute("id");; 85 event["conference_id"] = QString::number(conf erenceID, 10);84 event["conference_id"] = QString::number(confId, 10); 86 85 event["start"] = eventElement.firstChildElement("start").text(); // time eg. 10:00 87 86 event["date"] = dayElement.attribute("date"); // date eg. 2009-02-07 … … 106 105 person["name"] = personList.at(i).toElement().text(); 107 106 person["event_id"] = eventElement.attribute("id"); 108 person["conference_id"] = QString::number(conf erenceID, 10);107 person["conference_id"] = QString::number(confId, 10); 109 108 //qDebug() << "adding Person: " << person["name"]; 110 109 aDBEngine->addPersonToDB(person); … … 118 117 link["url"] = linkList.at(i).toElement().attribute("href"); 119 118 link["event_id"] = eventElement.attribute("id"); 120 link["conference_id"] = QString::number(conf erenceID, 10);119 link["conference_id"] = QString::number(confId, 10); 121 120 aDBEngine->addLinkToDB(link); 122 121 } -
src/sql/sql.pro
r30e2bdf r1735f55 8 8 # module dependencies 9 9 LIBS += -L$$DESTDIR -lmvc -lorm 10 INCLUDEPATH += ../mvc ../orm 10 INCLUDEPATH += ../mvc ../orm ../app 11 11 DEPENDPATH += . 12 12 -
src/sql/sqlengine.cpp
r30e2bdf r1735f55 7 7 8 8 #include <QDir> 9 #include <appsettings.h> 9 10 #include "sqlengine.h" 10 11 #include <track.h> 12 #include <conference.h> 11 13 12 14 #include <QDebug> … … 64 66 if (db.isValid() && db.isOpen()) 65 67 { 66 QString values = QString("'%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8', '%9', '%10'") \ 67 .arg(aConference["id"]) \ 68 .arg(aConference["title"]) \ 69 .arg(aConference["subtitle"]) \ 70 .arg(aConference["venue"]) \ 71 .arg(aConference["city"]) \ 72 .arg(QDateTime(QDate::fromString(aConference["start"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t()) \ 73 .arg(QDateTime(QDate::fromString(aConference["end"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t()) \ 74 .arg(aConference["days"]) \ 75 .arg(-QTime::fromString(aConference["day_change"],TIME_FORMAT).secsTo(QTime(0,0))) \ 76 .arg(-QTime::fromString(aConference["timeslot_duration"],TIME_FORMAT).secsTo(QTime(0,0))); 77 78 QString query = QString("INSERT INTO CONFERENCE (id,title,subtitle,venue,city,start,end,days,day_change,timeslot_duration) VALUES (%1)").arg(values); 79 QSqlQuery result (query, db); 80 //LOG_AUTOTEST(query); 68 int confId = 0; 69 QList<Conference> confsList = Conference::getAll(); 70 if(confsList.count()) 71 { 72 QListIterator<Conference> i(confsList); 73 while (i.hasNext()) 74 { 75 Conference conf = i.next(); 76 if( aConference["title"] == conf.title() ) 77 { 78 confId = conf.id(); 79 aConference["id"] = QString::number(confId); 80 break; 81 } 82 } 83 } 84 85 if(!confId) // conference 'aConference' isn't in the table => insert 86 { 87 QString values = QString("'%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8', '%9'") \ 88 .arg(aConference["title"]) \ 89 .arg(aConference["subtitle"]) \ 90 .arg(aConference["venue"]) \ 91 .arg(aConference["city"]) \ 92 .arg(QDateTime(QDate::fromString(aConference["start"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t()) \ 93 .arg(QDateTime(QDate::fromString(aConference["end"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t()) \ 94 .arg(aConference["days"]) \ 95 .arg(-QTime::fromString(aConference["day_change"],TIME_FORMAT).secsTo(QTime(0,0))) \ 96 .arg(-QTime::fromString(aConference["timeslot_duration"],TIME_FORMAT).secsTo(QTime(0,0))); 97 98 QString query = QString("INSERT INTO CONFERENCE (title,subtitle,venue,city,start,end,days,day_change,timeslot_duration) VALUES (%1)").arg(values); 99 QSqlQuery result (query, db); 100 aConference["id"] = result.lastInsertId().toString(); // 'id' is assigned automatically 101 102 if(!AppSettings::confId()) // default conf Id isn't set yet => set it up 103 AppSettings::setConfId(confId); 104 } 81 105 } 82 106 }
Note: See TracChangeset
for help on using the changeset viewer.