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 connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int)));
33 // event details have changed
34 connect(dayTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool)));
35 connect(favsTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool)));
36 connect(tracksTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool)));
37 connect(roomsTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool)));
38 connect(nowTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool)));
39 connect(searchTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool)));
41 // event conference map button clicked
42 connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked()));
44 connect(tabWidget, SIGNAL(infoIconClicked()), SLOT(aboutApp()));
46 if(Conference::getAll().count())
49 fillAndShowConferenceHeader();
50 setWindowTitle(Conference::getById(confId).title());
54 conferenceHeader->hide();
55 // go to the 'conferenceTab', so the user can import the schedule
56 tabWidget->setCurrentIndex(6); // 6 - conference tab
59 // open dialog for given Event ID
60 // this is used in case Alarm Dialog request application to start
65 EventDialog dialog(aEventId,this);
68 catch(OrmNoObjectException&) {} // just start application
69 catch(...) {} // just start application
73 void MainWindow::scheduleImported(int aConfId)
77 QList<Conference> confs = Conference::getAll();
81 fillAndShowConferenceHeader();
82 setWindowTitle(Conference::getById(Conference::activeConference()).title());
86 void MainWindow::aboutApp()
94 void MainWindow::conferenceMapClicked()
96 QString mapPath = QString(":/maps/campus.png");
97 if(!QFile::exists(mapPath))
98 mapPath = QString(":/maps/rooms/not-available.png");
102 QPixmap map(mapPath);
103 MapWindow window(map,roomName,this);
107 void MainWindow::eventHasChanged(int aEventId, bool aReloadModel)
109 dayTabContainer->updateTreeViewModel(aEventId);
110 favsTabContainer->updateTreeViewModel(aEventId,aReloadModel);
111 tracksTabContainer->updateTreeViewModel(aEventId);
112 nowTabContainer->updateTreeViewModel(aEventId);
113 roomsTabContainer->updateTreeViewModel(aEventId);
114 searchTabContainer->updateTreeViewModel(aEventId);
117 void MainWindow::fillAndShowConferenceHeader()
119 int confId = Conference::activeConference();
120 conferenceTitle->setText(Conference::getById(confId).title());
121 conferenceSubtitle->setText(Conference::getById(confId).subtitle());
122 conferenceWhere->setText(Conference::getById(confId).city() + ", " + Conference::getById(confId).venue());
123 conferenceWhen->setText(
124 Conference::getById(confId).start().toString("dd-MM-yyyy")
126 Conference::getById(confId).end().toString("dd-MM-yyyy"));
127 conferenceHeader->show();
130 void MainWindow::initTabs()
132 int confId = Conference::activeConference();
133 QDate startDate = Conference::getById(confId).start();
134 QDate endDate = Conference::getById(confId).end();
136 // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
137 dayTabContainer->setDates(startDate, endDate);
138 tracksTabContainer->setDates(startDate, endDate);
139 roomsTabContainer->setDates(startDate, endDate);
140 favsTabContainer->setDates(startDate, endDate);
141 searchTabContainer->setDates(startDate, endDate);
142 searchTabContainer->searchAgainClicked();
143 nowTabContainer->updateTreeView(QDate::currentDate());