1 #include "mainwindow.h"
9 #include <eventmodel.h>
12 #include <conference.h>
15 #include <QMessageBox>
17 #include <eventdialog.h>
18 #include "daynavigatorwidget.h"
19 #include "importschedulewidget.h"
20 #include "mapwindow.h"
22 #include <tabcontainer.h>
24 MainWindow::MainWindow(int aEventId, QWidget *aParent)
25 : QMainWindow(aParent)
29 int confId = Conference::activeConference();
31 QList<Conference> confs = Conference::getAll();
34 setWindowTitle(confs[0].title());
37 connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int)));
39 // event details have changed
40 connect(dayTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
41 connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
42 connect(tracksTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
43 connect(roomsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
44 connect(nowTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
45 connect(searchTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
48 // event conference map button clicked
49 connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked()));
51 connect(tabWidget, SIGNAL(infoIconClicked()), SLOT(aboutApp()));
53 if(Conference::getAll().count()) // no conference(s) in the DB
55 QDate startDate = Conference::getById(confId).start();
56 QDate endDate = Conference::getById(confId).end();
58 dayTabContainer->setDates(startDate, endDate);
59 tracksTabContainer->setDates(startDate, endDate);
60 roomsTabContainer->setDates(startDate, endDate);
61 favsTabContainer->setDates(startDate, endDate);
62 searchTabContainer->setDates(startDate, endDate);
64 conferenceTitle->setText(Conference::getById(confId).title());
65 conferenceSubtitle->setText(Conference::getById(confId).subtitle());
66 conferenceWhere->setText(Conference::getById(confId).city() + ", " + Conference::getById(confId).venue());
67 conferenceWhen->setText(
68 Conference::getById(confId).start().toString("dd-MM-yyyy")
70 Conference::getById(confId).end().toString("dd-MM-yyyy"));
73 // open dialog for given Event ID
74 // this is used in case Alarm Dialog request application to start
79 EventDialog dialog(aEventId,this);
82 catch(OrmNoObjectException&) {} // just start application
83 catch(...) {} // just start application
87 void MainWindow::scheduleImported(int aConfId)
91 QList<Conference> confs = Conference::getAll();
94 // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
95 QDate startDate = Conference::getById(Conference::activeConference()).start();
96 QDate endDate = Conference::getById(Conference::activeConference()).end();
97 dayTabContainer->setDates(startDate, endDate);
98 tracksTabContainer->setDates(startDate, endDate);
99 roomsTabContainer->setDates(startDate, endDate);
100 favsTabContainer->setDates(startDate, endDate);
104 void MainWindow::aboutApp()
106 QDialog dialog(this);
112 void MainWindow::conferenceMapClicked()
114 QString mapPath = QString(":/maps/campus.png");
115 if(!QFile::exists(mapPath))
116 mapPath = QString(":/maps/rooms/not-available.png");
120 QPixmap map(mapPath);
121 MapWindow window(map,roomName,this);
125 void MainWindow::eventHasChanged(int aEventId)
127 dayTabContainer->updateTreeViewModel(aEventId);
128 favsTabContainer->updateTreeViewModel(aEventId);
129 tracksTabContainer->updateTreeViewModel(aEventId);
130 nowTabContainer->updateTreeViewModel(aEventId);
131 roomsTabContainer->updateTreeViewModel(aEventId);
132 searchTabContainer->updateTreeViewModel(aEventId);