X-Git-Url: http://git.toastfreeware.priv.at/toast/confclerk.git/blobdiff_plain/a790a909d8e4b7439464960cf45e90c80973fb83..cf6b93c17a5a023fbd9c6801a21be221ccd479b5:/src/mvc/track.cpp diff --git a/src/mvc/track.cpp b/src/mvc/track.cpp index 512e822..6dddaee 100644 --- a/src/mvc/track.cpp +++ b/src/mvc/track.cpp @@ -1,12 +1,33 @@ +/* + * Copyright (C) 2010 Ixonos Plc. + * Copyright (C) 2011 Philipp Spitzer, gregor herrmann + * + * This file is part of ConfClerk. + * + * ConfClerk is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 2 of the License, or (at your option) + * any later version. + * + * ConfClerk is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * ConfClerk. If not, see . + */ #include "track.h" QString const Track::sTableName = QString("track"); -int const Track::sTableColCount = 2; +int const Track::sTableColCount = 3; +const QString Track::CONFERENCEID = "xid_conference"; const QString Track::NAME = "name"; QSqlRecord const Track::sColumns = Track::toRecord(QList() << QSqlField("id", QVariant::Int) + << QSqlField(CONFERENCEID, QVariant::Int) << QSqlField(NAME, QVariant::String)); class TrackInsertException : OrmSqlException @@ -18,7 +39,7 @@ public: int Track::insert() { QSqlQuery query; - query.prepare("INSERT INTO " + sTableName + " (" + NAME + ")" + " VALUES " + "(\"" + name() + "\")"); + query.prepare("INSERT INTO " + sTableName + " (" + CONFERENCEID + "," + NAME + ")" + " VALUES " + "(\"" + QString::number(conferenceid()) + "\",\"" + name() + "\")"); if (!query.exec()) { throw TrackInsertException("Exec Error"); @@ -30,12 +51,13 @@ int Track::insert() throw TrackInsertException("Last Insert Id Error"); } -Track Track::retrieveByName(QString name) +Track Track::retrieveByName(int conferenceid, QString name) { QSqlQuery query; query.prepare( selectQuery() - + QString("WHERE %1.name = :name").arg(sTableName)); + + QString("WHERE %1.xid_conference = :xid_conference and %1.name = :name").arg(sTableName)); + query.bindValue(":xid_conference", conferenceid); query.bindValue(":name", name); return loadOne(query); }