void MainWindow::displayMap(const QModelIndex &aIndex)
{
- QPixmap map(":/maps/rooms/janson.png");
+ Event *event = static_cast<Event*>(aIndex.internalPointer());
+ QString mapPath = QString(":/maps/rooms/%1.png").arg(event->room());
+ QPixmap map(mapPath);
MapWindow window(map,this);
window.exec();
}
return load(query);
}
+QString Event::room() const
+{
+ QSqlQuery query;
+ query.prepare("SELECT name FROM room WHERE id = (SELECT xid_room FROM event_room WHERE xid_event = :id)");
+ query.bindValue(":id", id());
+ query.exec();
+ // TODO: handle qeury error
+ //qDebug() << query.lastError();
+ if(query.next())
+ {
+ QString map = query.record().value("name").toString();
+ map=map.toLower(); // room names are stored in lower-case format
+ map=map.remove("."); // room names are stored without dots in the name, eg. "aw.1124.png" -> "aw1124.png"
+ return map;
+ }
+ else
+ return QString("not-available");
+}
+
+void Event::setRoom(const QString &room)
+{
+ qWarning("WARINING: setRoom() is NOT IMPLEMENTED YET");
+ // TODO: implement
+}
QString subtitle() const { return value("subtitle").toString(); }
QString abstract() const { return value("abstract").toString(); }
QString description() const { return value("description").toString(); }
+ // records from other tables associated with 'id'
+ QString room() const;
// Table 1
void setId(int id) { setValue("id", id); }
void setSubtitle(const QString& subtitle) { setValue("subtitle", subtitle); }
void setAbstract(const QString& abstract) { setValue("abstract", abstract); }
void setDescription(const QString& description) { setValue("description", description); }
+ // records from other tables associated with 'id'
+ void setRoom(const QString& room);
friend class EventTest;
};