Changeset f9db452 for src


Ignore:
Timestamp:
01/19/10 08:44:40 (13 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
b1fc17a
Parents:
446bce4
Message:

map-name to map-path implemented

  • correct map is displayed
Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/gui/mainwindow.cpp

    r446bce4 rf9db452  
    199199void MainWindow::displayMap(const QModelIndex &aIndex)
    200200{
    201     QPixmap map(":/maps/rooms/janson.png");
     201    Event *event = static_cast<Event*>(aIndex.internalPointer());
     202    QString mapPath = QString(":/maps/rooms/%1.png").arg(event->room());
     203    QPixmap map(mapPath);
    202204    MapWindow window(map,this);
    203205    window.exec();
  • src/mvc/event.cpp

    r446bce4 rf9db452  
    7070}
    7171
     72QString Event::room() const
     73{
     74    QSqlQuery query;
     75    query.prepare("SELECT name FROM room WHERE id = (SELECT xid_room FROM event_room WHERE xid_event = :id)");
     76    query.bindValue(":id", id());
     77    query.exec();
     78    // TODO: handle qeury error
     79    //qDebug() << query.lastError();
     80    if(query.next())
     81    {
     82        QString map = query.record().value("name").toString();
     83        map=map.toLower(); // room names are stored in lower-case format
     84        map=map.remove("."); // room names are stored without dots in the name, eg. "aw.1124.png" -> "aw1124.png"
     85        return map;
     86    }
     87    else
     88        return QString("not-available");
     89}
    7290
     91void Event::setRoom(const QString &room)
     92{
     93    qWarning("WARINING: setRoom() is NOT IMPLEMENTED YET");
     94    // TODO: implement
     95}
     96
  • src/mvc/event.h

    r446bce4 rf9db452  
    4747    QString abstract() const { return value("abstract").toString(); }
    4848    QString description() const { return value("description").toString(); }
     49    // records from other tables associated with 'id'
     50    QString room() const;
    4951
    5052    // Table 1
     
    6466    void setAbstract(const QString& abstract) { setValue("abstract", abstract); }
    6567    void setDescription(const QString& description) { setValue("description", description); }
     68    // records from other tables associated with 'id'
     69    void setRoom(const QString& room);
    6670
    6771friend class EventTest;
Note: See TracChangeset for help on using the changeset viewer.