Changeset 3a8dc71 for src


Ignore:
Timestamp:
01/26/10 20:30:45 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
336fa33
Parents:
05afe5f
Message:

SqlEngine? made STATIC

Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/app/main.cpp

    r05afe5f r3a8dc71  
    1616    QApplication::setWindowIcon(QIcon(":/icons/fosdem.png"));
    1717
    18     SqlEngine::initialize(); // creates DB connection
     18    SqlEngine::initialize(); // creates "SQLITE" DB connection
    1919
    2020    QWidget *window;
  • src/gui/importschedulewidget.cpp

    r05afe5f r3a8dc71  
    22
    33#include <schedulexmlparser.h>
    4 #include <sqlengine.h>
    54
    65#include <QDir>
     
    1110ImportScheduleWidget::ImportScheduleWidget(QWidget *aParent)
    1211    : QWidget(aParent)
    13     , mSqlEngine(NULL)
    1412{
    1513    setupUi(this);
     
    3230}
    3331
    34 void ImportScheduleWidget::setSqlEngine(SqlEngine *aSqlEngine)
    35 {
    36     Q_ASSERT(aSqlEngine != NULL);
    37 
    38     mSqlEngine = aSqlEngine;
    39 }
    40 
    4132void ImportScheduleWidget::parsingSchedule(const QString &aTitle)
    4233{
     
    5142void ImportScheduleWidget::browseSchedule()
    5243{
    53     Q_ASSERT(mSqlEngine != NULL);
    54 
    5544    QString scheduleFileName = QFileDialog::getOpenFileName(this, tr("Select Conference Schedule"), QDir::homePath(), tr("Schedule Files (*.xml)"));
    5645    if(QFile::exists(scheduleFileName))
     
    6655        browse->hide();
    6756        progressBar->show();
    68         int confId = mXmlParser->parseData(data,mSqlEngine);
     57        int confId = mXmlParser->parseData(data);
    6958
    7059        progressBar->hide();
  • src/gui/importschedulewidget.h

    r05afe5f r3a8dc71  
    66
    77class ScheduleXmlParser;
    8 class SqlEngine;
    98
    109class ImportScheduleWidget : public QWidget, Ui::ImportScheduleWidget
     
    1211    Q_OBJECT
    1312    public:
    14         ImportScheduleWidget(QWidget *aParent = NULL); // don't forget to use setSqlEngine()
     13        ImportScheduleWidget(QWidget *aParent = NULL);
    1514        ~ImportScheduleWidget();
    16         void setSqlEngine(SqlEngine *aSqlEngine);
    1715    private slots:
    1816        void browseSchedule();
     
    2321    private:
    2422        ScheduleXmlParser *mXmlParser;
    25         SqlEngine *mSqlEngine; // uses it
    2623};
    2724
  • src/gui/mainwindow.cpp

    r05afe5f r3a8dc71  
    2727{
    2828    setupUi(this);
    29 
    30     // create "SQLITE" DB instance/connection
    31     // opens DB connection (needed for EventModel)
    32     mSqlEngine = new SqlEngine(this);
    33     //mSqlEngine->initialize();
    34     importScheduleWidget->setSqlEngine(mSqlEngine);
    3529
    3630    // Sanity check for existence of any Conference in the DB
     
    127121}
    128122
    129 MainWindow::~MainWindow()
    130 {
    131     if(mSqlEngine)
    132     {
    133         delete mSqlEngine;
    134         mSqlEngine = NULL;
    135     }
    136 }
    137 
    138123void MainWindow::scheduleImported(int aConfId)
    139124{
     
    204189    QString keyword = searchEdit->text().replace( QString("%"), QString("\\%") );
    205190    qDebug() << "\nKeyword to search: " << keyword;
    206     mSqlEngine->searchEvent( AppSettings::confId(), columns, keyword );
     191    SqlEngine::searchEvent( AppSettings::confId(), columns, keyword );
    207192
    208193    QDate aStartDate = Conference::getById(AppSettings::confId()).start();
  • src/gui/mainwindow.h

    r05afe5f r3a8dc71  
    55
    66#include <ui_mainwindow.h>
    7 
    8 class SqlEngine;
    97
    108class MainWindow : public QMainWindow, private Ui::MainWindow
     
    1513    // Event dialog for given Event ID
    1614    MainWindow(int aEventId = 0, QWidget *aParent = NULL);
    17     ~MainWindow();
     15    ~MainWindow() {}
    1816private slots:
    1917    void scheduleImported(int aConfId);
     
    2422    void conferenceMapClicked();
    2523    void eventHasChanged(int aEventId);
    26 private:
    27     SqlEngine *mSqlEngine;
    2824};
    2925
  • src/sql/schedulexmlparser.cpp

    r05afe5f r3a8dc71  
    1313}
    1414
    15 int ScheduleXmlParser::parseData(const QByteArray &aData, SqlEngine *aDBEngine)
     15int ScheduleXmlParser::parseData(const QByteArray &aData)
    1616{
    17     Q_ASSERT(NULL != aDBEngine);
    18 
    1917    QDomDocument document;
    2018    document.setContent (aData, false);
     
    3937            conference["day_change"] = conferenceElement.firstChildElement("day_change").text(); // time
    4038            conference["timeslot_duration"] = conferenceElement.firstChildElement("timeslot_duration").text(); // time
    41             aDBEngine->addConferenceToDB(conference);
     39            SqlEngine::addConferenceToDB(conference);
    4240            confId = conference["id"].toInt();
    4341            emit(parsingSchedule(conference["title"]));
     
    7876                        room["conference_id"] = QString::number(confId,10);
    7977                        room["picture"] = "NOT DEFINED YET"; // TODO: implement some mapping to assign correct picture to specified room_name
    80                         aDBEngine->addRoomToDB(room);
     78                        SqlEngine::addRoomToDB(room);
    8179
    8280                        // process event's nodes
     
    9694                        event["abstract"] = eventElement.firstChildElement("abstract").text(); // string
    9795                        event["description"] = eventElement.firstChildElement("description").text(); // string
    98                         aDBEngine->addEventToDB(event);
     96                        SqlEngine::addEventToDB(event);
    9997                        // process persons' nodes
    10098                        QList<QString> persons;
     
    108106                            person["conference_id"] = QString::number(confId, 10);
    109107                            //qDebug() << "adding Person: " << person["name"];
    110                             aDBEngine->addPersonToDB(person);
     108                            SqlEngine::addPersonToDB(person);
    111109                        }
    112110                        // process links' nodes
     
    119117                            link["event_id"] = eventElement.attribute("id");
    120118                            link["conference_id"] = QString::number(confId, 10);
    121                             aDBEngine->addLinkToDB(link);
     119                            SqlEngine::addLinkToDB(link);
    122120                        }
    123121                        // emit signal to inform the user about the current status (how many events are parsed so far - expressed in %)
  • src/sql/schedulexmlparser.h

    r05afe5f r3a8dc71  
    33
    44#include <QObject>
    5 
    6 class SqlEngine;
    75
    86class ScheduleXmlParser : public QObject
     
    1311
    1412    public slots:
    15         int parseData(const QByteArray &aData, SqlEngine *aDBEngine); // returns 'confId' of parsed conference schedule
     13        int parseData(const QByteArray &aData); // returns 'confId' of parsed conference schedule
    1614
    1715    signals:
  • src/sql/sqlengine.h

    r05afe5f r3a8dc71  
    1414        ~SqlEngine();
    1515        static void initialize();
    16         void addConferenceToDB(QHash<QString,QString> &aConference);
    17         void addEventToDB(QHash<QString,QString> &aEvent);
    18         void addPersonToDB(QHash<QString,QString> &aPerson);
    19         void addLinkToDB(QHash<QString,QString> &aLink);
    20         void addRoomToDB(QHash<QString,QString> &aRoom);
     16        static void addConferenceToDB(QHash<QString,QString> &aConference);
     17        static void addEventToDB(QHash<QString,QString> &aEvent);
     18        static void addPersonToDB(QHash<QString,QString> &aPerson);
     19        static void addLinkToDB(QHash<QString,QString> &aLink);
     20        static void addRoomToDB(QHash<QString,QString> &aRoom);
    2121
    2222        // search Events for ....
    23         int searchEvent(int conferenceId, const QHash<QString,QString> &columns, const QString &keyword);
     23        static int searchEvent(int conferenceId, const QHash<QString,QString> &columns, const QString &keyword);
    2424    private:
    2525        static QString login(const QString &aDatabaseType, const QString &aDatabaseName);
    2626        static bool createTables(QSqlDatabase &aDatabase);
    27         bool execQuery(QSqlDatabase &aDatabase, const QString &aQuery);
     27        static bool execQuery(QSqlDatabase &aDatabase, const QString &aQuery);
    2828};
    2929
Note: See TracChangeset for help on using the changeset viewer.