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 dayTabContainer->setType(TabContainer::EContainerTypeDay);
47 favsTabContainer->setType(TabContainer::EContainerTypeFavs);
48 tracksTabContainer->setType(TabContainer::EContainerTypeTracks);
49 nowTabContainer->setType(TabContainer::EContainerTypeNow);
50 roomsTabContainer->setType(TabContainer::EContainerTypeRooms);
51 searchTabContainer->setType(TabContainer::EContainerTypeSearch);
53 connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int)));
55 // event details have changed
56 connect(dayTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
57 connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
58 connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
59 connect(roomsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
60 connect(nowTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
61 connect(searchTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
64 // event conference map button clicked
65 connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked()));
67 connect(tabWidget, SIGNAL(infoIconClicked()), SLOT(aboutApp()));
69 if(Conference::getAll().count()) // no conference(s) in the DB
71 QDate startDate = Conference::getById(AppSettings::confId()).start();
72 QDate endDate = Conference::getById(AppSettings::confId()).end();
74 dayTabContainer->setDates(startDate, endDate);
75 tracksTabContainer->setDates(startDate, endDate);
76 roomsTabContainer->setDates(startDate, endDate);
77 favsTabContainer->setDates(startDate, endDate);
78 searchTabContainer->setDates(startDate, endDate);
80 conferenceTitle->setText(Conference::getById(AppSettings::confId()).title());
81 conferenceSubtitle->setText(Conference::getById(AppSettings::confId()).subtitle());
82 conferenceWhere->setText(Conference::getById(AppSettings::confId()).city() + ", " + Conference::getById(AppSettings::confId()).venue());
83 conferenceWhen->setText(
84 Conference::getById(AppSettings::confId()).start().toString("dd-MM-yyyy")
86 Conference::getById(AppSettings::confId()).end().toString("dd-MM-yyyy"));
89 // open dialog for given Event ID
90 // this is used in case Alarm Dialog request application to start
95 EventDialog dialog(aEventId,this);
98 catch(OrmNoObjectException&) {} // just start application
99 catch(...) {} // just start application
103 void MainWindow::scheduleImported(int aConfId)
107 QList<Conference> confs = Conference::getAll();
108 if(!confs.count()) // no conference(s) in the DB
110 AppSettings::setConfId(0); // no conference in the DB
114 if(AppSettings::confId() == 0)
115 AppSettings::setConfId(confs[0].id());
117 // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
118 QDate startDate = Conference::getById(AppSettings::confId()).start();
119 QDate endDate = Conference::getById(AppSettings::confId()).end();
120 dayTabContainer->setDates(startDate, endDate);
121 tracksTabContainer->setDates(startDate, endDate);
122 roomsTabContainer->setDates(startDate, endDate);
123 favsTabContainer->setDates(startDate, endDate);
127 void MainWindow::aboutApp()
129 QDialog dialog(this);
135 void MainWindow::conferenceMapClicked()
137 QString mapPath = QString(":/maps/campus.png");
138 if(!QFile::exists(mapPath))
139 mapPath = QString(":/maps/rooms/not-available.png");
143 QPixmap map(mapPath);
144 MapWindow window(map,roomName,this);
148 void MainWindow::eventHasChanged(int aEventId)
150 dayTabContainer->updateTreeViewModel(aEventId);
151 favsTabContainer->updateTreeViewModel(aEventId);
152 tracksTabContainer->updateTreeViewModel(aEventId);
153 nowTabContainer->updateTreeViewModel(aEventId);
154 roomsTabContainer->updateTreeViewModel(aEventId);
155 searchTabContainer->updateTreeViewModel(aEventId);