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);
63 nowTabContainer->updateTreeView(QDate::currentDate());
65 conferenceTitle->setText(Conference::getById(confId).title());
66 conferenceSubtitle->setText(Conference::getById(confId).subtitle());
67 conferenceWhere->setText(Conference::getById(confId).city() + ", " + Conference::getById(confId).venue());
68 conferenceWhen->setText(
69 Conference::getById(confId).start().toString("dd-MM-yyyy")
71 Conference::getById(confId).end().toString("dd-MM-yyyy"));
74 // open dialog for given Event ID
75 // this is used in case Alarm Dialog request application to start
80 EventDialog dialog(aEventId,this);
83 catch(OrmNoObjectException&) {} // just start application
84 catch(...) {} // just start application
88 void MainWindow::scheduleImported(int aConfId)
92 QList<Conference> confs = Conference::getAll();
95 // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
96 QDate startDate = Conference::getById(Conference::activeConference()).start();
97 QDate endDate = Conference::getById(Conference::activeConference()).end();
98 dayTabContainer->setDates(startDate, endDate);
99 tracksTabContainer->setDates(startDate, endDate);
100 roomsTabContainer->setDates(startDate, endDate);
101 favsTabContainer->setDates(startDate, endDate);
105 void MainWindow::aboutApp()
107 QDialog dialog(this);
113 void MainWindow::conferenceMapClicked()
115 QString mapPath = QString(":/maps/campus.png");
116 if(!QFile::exists(mapPath))
117 mapPath = QString(":/maps/rooms/not-available.png");
121 QPixmap map(mapPath);
122 MapWindow window(map,roomName,this);
126 void MainWindow::eventHasChanged(int aEventId)
128 dayTabContainer->updateTreeViewModel(aEventId);
129 favsTabContainer->updateTreeViewModel(aEventId);
130 tracksTabContainer->updateTreeViewModel(aEventId);
131 nowTabContainer->updateTreeViewModel(aEventId);
132 roomsTabContainer->updateTreeViewModel(aEventId);
133 searchTabContainer->updateTreeViewModel(aEventId);