[e5bc908] | 1 | #include "mainwindow.h" |
---|
| 2 | |
---|
[d0d0a66] | 3 | #include <QTreeView> |
---|
[05afe5f] | 4 | #include <QFile> |
---|
[d0d0a66] | 5 | |
---|
[72f6fe4] | 6 | #include <sqlengine.h> |
---|
| 7 | |
---|
[4693fa6] | 8 | #include <track.h> |
---|
[d0d0a66] | 9 | #include <eventmodel.h> |
---|
[66327a0] | 10 | #include <delegate.h> |
---|
[d0d0a66] | 11 | |
---|
[969a840] | 12 | #include <conference.h> |
---|
| 13 | |
---|
[c2d66b2] | 14 | #include <QDialog> |
---|
[3f3e22d] | 15 | #include <QMessageBox> |
---|
[c2d66b2] | 16 | #include "ui_about.h" |
---|
[05afe5f] | 17 | #include <eventdialog.h> |
---|
[969a840] | 18 | #include "daynavigatorwidget.h" |
---|
[c15be10] | 19 | #include "importschedulewidget.h" |
---|
[59c6cfe] | 20 | #include "mapwindow.h" |
---|
[72f6fe4] | 21 | |
---|
[05afe5f] | 22 | #include <tabcontainer.h> |
---|
| 23 | |
---|
[d4a8bbf] | 24 | MainWindow::MainWindow(int aEventId, QWidget *aParent) |
---|
| 25 | : QMainWindow(aParent) |
---|
[e5bc908] | 26 | { |
---|
[9bbb44e] | 27 | setupUi(this); |
---|
[72f6fe4] | 28 | |
---|
[0bb39f5] | 29 | int confId = Conference::activeConference(); |
---|
| 30 | |
---|
[b128673] | 31 | QList<Conference> confs = Conference::getAll(); |
---|
[0bb39f5] | 32 | if(confs.count()) |
---|
[b128673] | 33 | { |
---|
[b86d4aa] | 34 | setWindowTitle(confs[0].title()); |
---|
[b128673] | 35 | } |
---|
| 36 | |
---|
[c15be10] | 37 | connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int))); |
---|
| 38 | |
---|
[c718a77] | 39 | // event details have changed |
---|
[05afe5f] | 40 | connect(dayTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); |
---|
| 41 | connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); |
---|
[21d7cc0] | 42 | connect(tracksTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); |
---|
[05afe5f] | 43 | connect(roomsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); |
---|
| 44 | connect(nowTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); |
---|
[001c8cf] | 45 | connect(searchTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); |
---|
[05afe5f] | 46 | |
---|
| 47 | |
---|
[e7340e1] | 48 | // event conference map button clicked |
---|
| 49 | connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked())); |
---|
[001c8cf] | 50 | |
---|
[85340ae] | 51 | connect(tabWidget, SIGNAL(infoIconClicked()), SLOT(aboutApp())); |
---|
[969a840] | 52 | |
---|
[05afe5f] | 53 | if(Conference::getAll().count()) // no conference(s) in the DB |
---|
[969a840] | 54 | { |
---|
[0bb39f5] | 55 | QDate startDate = Conference::getById(confId).start(); |
---|
| 56 | QDate endDate = Conference::getById(confId).end(); |
---|
[05afe5f] | 57 | // |
---|
[001c8cf] | 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); |
---|
[30e2bdf] | 63 | // |
---|
[0bb39f5] | 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()); |
---|
[30e2bdf] | 67 | conferenceWhen->setText( |
---|
[0bb39f5] | 68 | Conference::getById(confId).start().toString("dd-MM-yyyy") |
---|
[30e2bdf] | 69 | + ", " + |
---|
[0bb39f5] | 70 | Conference::getById(confId).end().toString("dd-MM-yyyy")); |
---|
[969a840] | 71 | } |
---|
[c5324ca] | 72 | |
---|
[d4a8bbf] | 73 | // open dialog for given Event ID |
---|
| 74 | // this is used in case Alarm Dialog request application to start |
---|
| 75 | if(aEventId) |
---|
| 76 | { |
---|
[95596f6] | 77 | try |
---|
| 78 | { |
---|
| 79 | EventDialog dialog(aEventId,this); |
---|
| 80 | dialog.exec(); |
---|
| 81 | } |
---|
[806b992] | 82 | catch(OrmNoObjectException&) {} // just start application |
---|
[95596f6] | 83 | catch(...) {} // just start application |
---|
[d4a8bbf] | 84 | } |
---|
[e5bc908] | 85 | } |
---|
[66327a0] | 86 | |
---|
[c15be10] | 87 | void MainWindow::scheduleImported(int aConfId) |
---|
[72f6fe4] | 88 | { |
---|
[c15be10] | 89 | Q_UNUSED(aConfId); |
---|
[49c5ad3] | 90 | |
---|
| 91 | QList<Conference> confs = Conference::getAll(); |
---|
[0bb39f5] | 92 | if(confs.count()) |
---|
[49c5ad3] | 93 | { |
---|
[969a840] | 94 | // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates |
---|
[0bb39f5] | 95 | QDate startDate = Conference::getById(Conference::activeConference()).start(); |
---|
| 96 | QDate endDate = Conference::getById(Conference::activeConference()).end(); |
---|
[05afe5f] | 97 | dayTabContainer->setDates(startDate, endDate); |
---|
| 98 | tracksTabContainer->setDates(startDate, endDate); |
---|
| 99 | roomsTabContainer->setDates(startDate, endDate); |
---|
| 100 | favsTabContainer->setDates(startDate, endDate); |
---|
[969a840] | 101 | } |
---|
[72f6fe4] | 102 | } |
---|
| 103 | |
---|
[c2d66b2] | 104 | void MainWindow::aboutApp() |
---|
| 105 | { |
---|
| 106 | QDialog dialog(this); |
---|
| 107 | Ui::AboutDialog ui; |
---|
| 108 | ui.setupUi(&dialog); |
---|
| 109 | dialog.exec(); |
---|
| 110 | } |
---|
| 111 | |
---|
[e7340e1] | 112 | void MainWindow::conferenceMapClicked() |
---|
| 113 | { |
---|
| 114 | QString mapPath = QString(":/maps/campus.png"); |
---|
| 115 | if(!QFile::exists(mapPath)) |
---|
| 116 | mapPath = QString(":/maps/rooms/not-available.png"); |
---|
| 117 | |
---|
| 118 | QString roomName; |
---|
| 119 | |
---|
| 120 | QPixmap map(mapPath); |
---|
| 121 | MapWindow window(map,roomName,this); |
---|
| 122 | window.exec(); |
---|
| 123 | } |
---|
| 124 | |
---|
[c718a77] | 125 | void MainWindow::eventHasChanged(int aEventId) |
---|
| 126 | { |
---|
[05afe5f] | 127 | dayTabContainer->updateTreeViewModel(aEventId); |
---|
| 128 | favsTabContainer->updateTreeViewModel(aEventId); |
---|
| 129 | tracksTabContainer->updateTreeViewModel(aEventId); |
---|
| 130 | nowTabContainer->updateTreeViewModel(aEventId); |
---|
| 131 | roomsTabContainer->updateTreeViewModel(aEventId); |
---|
[001c8cf] | 132 | searchTabContainer->updateTreeViewModel(aEventId); |
---|
[c718a77] | 133 | } |
---|
| 134 | |
---|