From: pavelpa Date: Fri, 22 Jan 2010 07:36:35 +0000 (+0000) Subject: sanity check for consitency of confId in AppSettings and the DB X-Git-Tag: 0.5.0~216 X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/commitdiff_plain/b128673c9b7bc785ecca89ce3ad8fe0e509cba84 sanity check for consitency of confId in AppSettings and the DB --- diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 7323a42..f49c36b 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -25,16 +25,30 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent) { setupUi(this); - // connect Menu actions - connect(actionImportSchedule, SIGNAL(triggered()), SLOT(importSchedule())); - connect(actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); - connect(actionAboutApplication, SIGNAL(triggered()), SLOT(aboutApp())); - // create "SQLITE" DB instance/connection // opens DB connection (needed for EventModel) mSqlEngine = new SqlEngine(this); mSqlEngine->initialize(); + // Sanity check for existence of any Conference in the DB + // it AppSettings::confId() is 0, but there are any Conference(s) in the DB + // set the confId in the AppSettings for the ID of the first conference in the DB + QList confs = Conference::getAll(); + if(!confs.count()) // no conference(s) in the DB + { + AppSettings::setConfId(0); // no conference in the DB + } + else + { + if(AppSettings::confId() == 0) + AppSettings::setConfId(confs[0].id()); + } + + // connect Menu actions + connect(actionImportSchedule, SIGNAL(triggered()), SLOT(importSchedule())); + connect(actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + connect(actionAboutApplication, SIGNAL(triggered()), SLOT(aboutApp())); + //update track map Track::updateTrackMap();