1 #include "mainwindow.h"
5 #include <QNetworkProxy>
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>
24 #include <appsettings.h>
26 const QString PROXY_USERNAME;
27 const QString PROXY_PASSWD;
29 MainWindow::MainWindow(int aEventId, QWidget *aParent)
30 : QMainWindow(aParent)
34 qDebug() << "Setting-up proxy: " << AppSettings::proxyAddress() << ":" << AppSettings::proxyPort();
36 AppSettings::isDirectConnection() ? QNetworkProxy::NoProxy : QNetworkProxy::HttpProxy,
37 AppSettings::proxyAddress(),
38 AppSettings::proxyPort(),
41 QNetworkProxy::setApplicationProxy(proxy);
43 int confId = Conference::activeConference();
45 connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int)));
47 // event details have changed
48 connect(dayTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool)));
49 connect(favsTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool)));
50 connect(tracksTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool)));
51 connect(roomsTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool)));
52 connect(nowTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool)));
53 connect(searchTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool)));
55 // event conference map button clicked
56 connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked()));
58 connect(tabWidget, SIGNAL(infoIconClicked()), SLOT(aboutApp()));
60 selectConference->setDuplicatesEnabled(false);
61 int confCount = Conference::getAll().count();
65 fillAndShowConferenceHeader();
66 setWindowTitle(Conference::getById(confId).title());
68 if(confCount==1) // don't have to show 'selectConference' widget, if there is only one conference in the DB
69 selectConferenceWidget->hide();
72 // have to fill comboBox with available conferences
73 QList<Conference> confs = Conference::getAll();
74 QListIterator<Conference> i(confs);
77 Conference conf = i.next();
78 selectConference->addItem(conf.title(),conf.id());
80 int idx = selectConference->findText(Conference::getById(Conference::activeConference()).title());
81 selectConference->setCurrentIndex(idx);
83 connect(selectConference, SIGNAL(currentIndexChanged(int)), SLOT(conferenceChanged(int)));
87 conferenceHeader->hide();
88 selectConferenceWidget->hide();
89 // go to the 'conferenceTab', so the user can import the schedule
90 tabWidget->setCurrentIndex(6); // 6 - conference tab
93 // open dialog for given Event ID
94 // this is used in case Alarm Dialog request application to start
99 EventDialog dialog(aEventId,this);
102 catch(OrmNoObjectException&) {} // just start application
103 catch(...) {} // just start application
107 void MainWindow::scheduleImported(int aConfId)
111 Conference conf = Conference::getById(aConfId);
112 if( selectConference->findText(conf.title()) < 0 ) // item doesn't exist
114 disconnect(selectConference, SIGNAL(currentIndexChanged(int)), this, SLOT(conferenceChanged(int)));
115 selectConference->addItem(conf.title(),conf.id());
116 connect(selectConference, SIGNAL(currentIndexChanged(int)), SLOT(conferenceChanged(int)));
118 int confCount = Conference::getAll().count();
121 int idx = selectConference->findText(conf.title());
122 selectConference->setCurrentIndex(idx);
125 selectConferenceWidget->show();
127 conferenceChanged(idx);
131 void MainWindow::aboutApp()
133 QDialog dialog(this);
139 void MainWindow::conferenceMapClicked()
141 QString mapPath = QString(":/maps/campus.png");
142 if(!QFile::exists(mapPath))
143 mapPath = QString(":/maps/rooms/not-available.png");
147 QPixmap map(mapPath);
148 MapWindow window(map,roomName,this);
152 void MainWindow::eventHasChanged(int aEventId, bool aReloadModel)
154 dayTabContainer->updateTreeViewModel(aEventId);
155 favsTabContainer->updateTreeViewModel(aEventId,aReloadModel);
156 tracksTabContainer->updateTreeViewModel(aEventId);
157 nowTabContainer->updateTreeViewModel(aEventId);
158 roomsTabContainer->updateTreeViewModel(aEventId);
159 searchTabContainer->updateTreeViewModel(aEventId);
162 void MainWindow::fillAndShowConferenceHeader()
164 int confId = Conference::activeConference();
165 conferenceTitle->setText(Conference::getById(confId).title());
166 conferenceSubtitle->setText(Conference::getById(confId).subtitle());
167 conferenceWhere->setText(Conference::getById(confId).city() + ", " + Conference::getById(confId).venue());
168 conferenceWhen->setText(
169 Conference::getById(confId).start().toString("dd-MM-yyyy")
171 Conference::getById(confId).end().toString("dd-MM-yyyy"));
172 conferenceHeader->show();
175 void MainWindow::initTabs()
177 int confId = Conference::activeConference();
178 QDate startDate = Conference::getById(confId).start();
179 QDate endDate = Conference::getById(confId).end();
181 // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
182 dayTabContainer->setDates(startDate, endDate);
183 tracksTabContainer->setDates(startDate, endDate);
184 roomsTabContainer->setDates(startDate, endDate);
185 favsTabContainer->setDates(startDate, endDate);
186 searchTabContainer->setDates(startDate, endDate);
187 searchTabContainer->searchAgainClicked();
188 nowTabContainer->updateTreeView(QDate::currentDate());
191 void MainWindow::conferenceChanged(int aIndex)
193 Conference::getById(Conference::activeConference()).update("active",0);
194 Conference::getById(selectConference->itemData(aIndex).toInt()).update("active",1);
197 fillAndShowConferenceHeader();
198 setWindowTitle(Conference::getById(Conference::activeConference()).title());