Changeset cec47c6


Ignore:
Timestamp:
05/05/10 15:56:14 (12 years ago)
Author:
kirilma <kirilma@…>
Branches:
master, qt5
Children:
58eb7cc
Parents:
3cdaf7d
Message:

store path to conference map in database

path stored as additional field in conference table
if it's null or empty, "Show map" button is not shown
if existing database does not have the field, it will be automatically added

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/fosdem.sql

    r3cdaf7d rcec47c6  
    1111    , timeslot_duration INTEGER
    1212    , active INTEGER DEFAULT 0
    13     , url VARCHAR UNIQUE);
    14 INSERT INTO "CONFERENCE" VALUES(1,'FOSDEM 2010','Free and Opensource Software Developers European Meeting','ULB (Campus Solbosch)','Brussels',1265414400,1265500800,2,28800,900,1,"http://fosdem.org/2010/schedule/xml");
     13    , url VARCHAR UNIQUE
     14    , map VARCHAR);
     15INSERT INTO "CONFERENCE" VALUES(1,'FOSDEM 2010','Free and Opensource Software Developers European Meeting','ULB (Campus Solbosch)','Brussels',1265414400,1265500800,2,28800,900,1,"http://fosdem.org/2010/schedule/xml", ":/maps/campus.png");
    1516CREATE TABLE TRACK ( id INTEGER  PRIMARY KEY AUTOINCREMENT  NOT NULL
    1617    , name VARCHAR UNIQUE NOT NULL );
  • src/gui/conferenceeditor.cpp

    r3cdaf7d rcec47c6  
    2222#include "urlinputdialog.h"
    2323#include "mapwindow.h"
     24#include "errormessage.h"
    2425
    2526#include <QInputDialog>
     
    9596                + ", " +
    9697                conf.end().toString("dd-MM-yyyy"));
     98
     99        QString map = conf.map();
     100        if (map.isEmpty()) {
     101            showMapButton->hide();
     102        } else {
     103            showMapButton->show();
     104        }
     105
    97106        conferenceInfo->setCurrentIndex(0);
    98107        removeBtn->show();
     
    213222void ConferenceEditor::conferenceMapClicked()
    214223{
    215     QString mapPath = QString(":/maps/campus.png");
    216     if(!QFile::exists(mapPath))
    217         mapPath = QString(":/maps/rooms/not-available.png");
     224    Conference conf = Conference::getById(selected_id);
     225    QString mapPath = conf.map();
     226    if(mapPath.isEmpty() or !QFile::exists(mapPath)) {
     227        error_message("Map is not available");
     228        return;
     229    }
    218230
    219231    QString roomName;
  • src/mvc/conference.cpp

    r3cdaf7d rcec47c6  
    3232    << QSqlField("timeslot_duration", QVariant::Int)
    3333    << QSqlField("active", QVariant::Bool)
    34     << QSqlField("url", QVariant::String));
     34    << QSqlField("url", QVariant::String)
     35    << QSqlField("map", QVariant::String)
     36    );
    3537
    3638QString const Conference::sTableName = QString("conference");
  • src/mvc/conference.h

    r3cdaf7d rcec47c6  
    5050    int timeslotDuration() const { return value("timeslot_duration").toInt(); } // in seconds
    5151    bool isActive() const { return value("active").toBool(); }
    52     QString url() const
    53     {
    54         QVariant val = value("url");
    55         qDebug() << __PRETTY_FUNCTION__ << val;
    56         if (val.isValid()) {
    57             return val.toString();
    58         } else {
    59             return QString();
    60         }
    61     }
     52    QString url() const { return stringFromNullable(value("url")); }
     53    QString map() const { return stringFromNullable(value("map")); }
    6254
    6355    #if 0
     
    7971        update("url");
    8072    }
     73
     74private:
     75    static QString stringFromNullable(const QVariant& v)
     76    {
     77        if (v.isValid()) {
     78            return v.toString();
     79        } else {
     80            return QString();
     81        }
     82    }
    8183};
    8284
  • src/sql/sqlengine.cpp

    r3cdaf7d rcec47c6  
    6262        database.open();
    6363    }
     64
     65    checkConferenceMap(database);
    6466
    6567    //LOG_INFO(QString("Opening '%1' database '%2'").arg(aDatabaseType).arg(aDatabaseName));
     
    378380}
    379381
     382void SqlEngine::checkConferenceMap(QSqlDatabase &aDatabase)
     383{
     384    QSqlQuery sqlQuery(aDatabase);
     385    sqlQuery.prepare("SELECT map FROM conference");
     386    if (!sqlQuery.exec()) {
     387        qWarning() << "column conference.map is missing; adding";
     388        execQuery(aDatabase, "ALTER TABLE conference ADD COLUMN map VARCHAR")
     389         and execQuery(aDatabase, "UPDATE conference SET map = ':/maps/campus.png' WHERE title = 'FOSDEM 2010'");
     390    }
     391}
  • src/sql/sqlengine.h

    r3cdaf7d rcec47c6  
    4848        static bool execQuery(QSqlDatabase &aDatabase, const QString &aQuery);
    4949        static bool execQueryWithParameter(QSqlDatabase &aDatabase, const QString &aQuery, const QHash<QString, QVariant>& params);
     50
     51        static void checkConferenceMap(QSqlDatabase &aDatabase);
    5052};
    5153
Note: See TracChangeset for help on using the changeset viewer.