1 #include "mainwindow.h"
2 #include <appsettings.h>
10 #include <eventmodel.h>
13 #include <conference.h>
16 #include <QMessageBox>
18 #include <eventdialog.h>
19 #include "daynavigatorwidget.h"
20 #include "importschedulewidget.h"
21 #include "mapwindow.h"
23 #include <tabcontainer.h>
25 MainWindow::MainWindow(int aEventId, QWidget *aParent)
26 : QMainWindow(aParent)
30 // Sanity check for existence of any Conference in the DB
31 // it AppSettings::confId() is 0, but there are any Conference(s) in the DB
32 // set the confId in the AppSettings for the ID of the first conference in the DB
33 QList<Conference> confs = Conference::getAll();
34 if(!confs.count()) // no conference(s) in the DB
36 AppSettings::setConfId(0); // no conference in the DB
40 if(AppSettings::confId() == 0)
41 AppSettings::setConfId(confs[0].id());
43 setWindowTitle(confs[0].title());
46 connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int)));
48 // event details have changed
49 connect(dayTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
50 connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
51 connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
52 connect(roomsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
53 connect(nowTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
54 connect(searchTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
57 // event conference map button clicked
58 connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked()));
60 connect(tabWidget, SIGNAL(infoIconClicked()), SLOT(aboutApp()));
62 if(Conference::getAll().count()) // no conference(s) in the DB
64 QDate startDate = Conference::getById(AppSettings::confId()).start();
65 QDate endDate = Conference::getById(AppSettings::confId()).end();
67 dayTabContainer->setDates(startDate, endDate);
68 tracksTabContainer->setDates(startDate, endDate);
69 roomsTabContainer->setDates(startDate, endDate);
70 favsTabContainer->setDates(startDate, endDate);
71 searchTabContainer->setDates(startDate, endDate);
73 conferenceTitle->setText(Conference::getById(AppSettings::confId()).title());
74 conferenceSubtitle->setText(Conference::getById(AppSettings::confId()).subtitle());
75 conferenceWhere->setText(Conference::getById(AppSettings::confId()).city() + ", " + Conference::getById(AppSettings::confId()).venue());
76 conferenceWhen->setText(
77 Conference::getById(AppSettings::confId()).start().toString("dd-MM-yyyy")
79 Conference::getById(AppSettings::confId()).end().toString("dd-MM-yyyy"));
82 // open dialog for given Event ID
83 // this is used in case Alarm Dialog request application to start
88 EventDialog dialog(aEventId,this);
91 catch(OrmNoObjectException&) {} // just start application
92 catch(...) {} // just start application
96 void MainWindow::scheduleImported(int aConfId)
100 QList<Conference> confs = Conference::getAll();
101 if(!confs.count()) // no conference(s) in the DB
103 AppSettings::setConfId(0); // no conference in the DB
107 if(AppSettings::confId() == 0)
108 AppSettings::setConfId(confs[0].id());
110 // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
111 QDate startDate = Conference::getById(AppSettings::confId()).start();
112 QDate endDate = Conference::getById(AppSettings::confId()).end();
113 dayTabContainer->setDates(startDate, endDate);
114 tracksTabContainer->setDates(startDate, endDate);
115 roomsTabContainer->setDates(startDate, endDate);
116 favsTabContainer->setDates(startDate, endDate);
120 void MainWindow::aboutApp()
122 QDialog dialog(this);
128 void MainWindow::conferenceMapClicked()
130 QString mapPath = QString(":/maps/campus.png");
131 if(!QFile::exists(mapPath))
132 mapPath = QString(":/maps/rooms/not-available.png");
136 QPixmap map(mapPath);
137 MapWindow window(map,roomName,this);
141 void MainWindow::eventHasChanged(int aEventId)
143 dayTabContainer->updateTreeViewModel(aEventId);
144 favsTabContainer->updateTreeViewModel(aEventId);
145 tracksTabContainer->updateTreeViewModel(aEventId);
146 nowTabContainer->updateTreeViewModel(aEventId);
147 roomsTabContainer->updateTreeViewModel(aEventId);
148 searchTabContainer->updateTreeViewModel(aEventId);