+
+}
+
+void MainWindow::buildFriendListPanel()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_friendsListPanel = new FriendListPanel(this);
+ m_friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
+
+ m_friendsListPanel->stackUnder(m_friendsListPanelSidebar);
+
+ connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
+ m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
+
+ connect(m_friendsListPanel, SIGNAL(findFriend(QPointF)),
+ this, SIGNAL(findFriend(QPointF)));
+
+ connect(m_mapView, SIGNAL(viewResized(QSize)),
+ m_friendsListPanel, SLOT(screenResized(QSize)));
+
+ connect(this, SIGNAL(locationItemClicked(QList<QString>)),
+ m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
+
+ connect(m_mapView, SIGNAL(viewResizedNewSize(int, int)),
+ m_friendsListPanelSidebar, SLOT(reDrawSidebar(int, int)));
+}
+
+void MainWindow::buildManualLocationCrosshair()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_ownLocationCrosshair = new QLabel(this);
+ QPixmap crosshairImage(":/res/images/sight.png");
+ m_ownLocationCrosshair->setPixmap(crosshairImage);
+ m_ownLocationCrosshair->setFixedSize(crosshairImage.size());
+ m_ownLocationCrosshair->hide();
+ m_ownLocationCrosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true);
+
+ connect(m_mapView, SIGNAL(viewResizedNewSize(int, int)),
+ this, SLOT(drawOwnLocationCrosshair(int, int)));
+}
+
+void MainWindow::buildMap()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_mapView = new MapView(this);
+
+ buildZoomButtonPanel();
+ buildOsmLicense();
+ buildManualLocationCrosshair();
+ buildFullScreenButton();
+
+ connect(m_mapView, SIGNAL(viewScrolled(QPoint)),
+ this, SIGNAL(mapViewScrolled(QPoint)));
+
+ connect(this, SIGNAL(centerToSceneCoordinates(QPoint)),
+ m_mapView, SLOT(centerToSceneCoordinates(QPoint)));
+
+ connect(m_mapView, SIGNAL(viewResized(QSize)),
+ this, SIGNAL(mapViewResized(QSize)));
+
+ connect(m_mapView, SIGNAL(viewResized(QSize)),
+ this, SLOT(drawFullScreenButton(QSize)));
+
+ connect(m_mapView, SIGNAL(viewResizedNewSize(int, int)),
+ this, SLOT(setViewPortSize(int, int)));
+
+ connect(this, SIGNAL(zoomLevelChanged(int)),
+ m_mapView, SLOT(setZoomLevel(int)));
+
+ connect(m_mapView, SIGNAL(viewZoomFinished()),
+ this, SIGNAL(viewZoomFinished()));
+}
+
+void MainWindow::buildOsmLicense()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_osmLicense = new QLabel(this);
+ m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
+ m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
+ m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
+ m_osmLicense->setFont(QFont("Nokia Sans", 9));
+ m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
+ m_osmLicense->fontMetrics().height());
+
+ connect(m_mapView, SIGNAL(viewResized(QSize)),
+ this, SLOT(drawOsmLicense(QSize)));
+}
+
+void MainWindow::buildUserInfoPanel()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_userPanel = new UserInfoPanel(this);
+ m_userPanelSidebar = new PanelSideBar(this, LEFT);
+
+ m_userPanelSidebar->stackUnder(m_friendsListPanel);
+ m_userPanel->stackUnder(m_userPanelSidebar);
+
+ connect(m_userPanel, SIGNAL(findUser(QPointF)),
+ this, SIGNAL(findUser(QPointF)));
+
+ connect(this, SIGNAL(userLocationReady(User*)),
+ m_userPanel, SLOT(userDataReceived(User*)));
+
+ connect(m_userPanel, SIGNAL(requestReverseGeo()),
+ this, SIGNAL(requestReverseGeo()));
+
+ connect(this, SIGNAL(reverseGeoReady(QString)),
+ m_userPanel, SIGNAL(reverseGeoReady(QString)));
+
+ connect(m_userPanel, SIGNAL(statusUpdate(QString,bool)),
+ this, SIGNAL(statusUpdate(QString,bool)));
+
+ connect(m_userPanel, SIGNAL(refreshUserData()),
+ this, SIGNAL(refreshUserData()));
+
+ connect(m_mapView, SIGNAL(viewResized(QSize)),
+ m_userPanel, SLOT(screenResized(QSize)));
+
+ connect(this, SIGNAL(updateWasSuccessful()),
+ m_userPanel, SIGNAL(updateWasSuccessful()));
+
+ connect(this, SIGNAL(messageSendingFailed(QString)),
+ m_userPanel, SIGNAL(messageSendingFailed(QString)));
+
+ connect(m_userPanel, SIGNAL(notificateUpdateFailing(QString)),
+ this, SIGNAL(notificateUpdateFailing(QString)));
+}
+
+void MainWindow::buildWebView()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if(!m_webView) {
+ m_webView = new QWebView;
+
+ connect(m_webView, SIGNAL(urlChanged(const QUrl &)),
+ this, SIGNAL(updateCredentials(QUrl)));
+ connect(m_webView, SIGNAL(loadFinished(bool)),
+ this, SLOT(loadDone(bool)));
+
+ m_webView->hide();
+ }
+}
+
+void MainWindow::buildZoomButtonPanel()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_zoomButtonPanel = new ZoomButtonPanel(this);
+
+ connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
+ this, SIGNAL(zoomIn()));
+
+ connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
+ this, SIGNAL(zoomOut()));
+
+ connect(this, SIGNAL(zoomLevelChanged(int)),
+ m_zoomButtonPanel, SLOT(resetButtons()));
+
+ connect(this, SIGNAL(maxZoomLevelReached()),
+ m_zoomButtonPanel, SLOT(disableZoomInButton()));
+
+ connect(this, SIGNAL(minZoomLevelReached()),
+ m_zoomButtonPanel, SLOT(disableZoomOutButton()));
+
+ connect(m_mapView, SIGNAL(viewResized(QSize)),
+ m_zoomButtonPanel, SLOT(screenResized(QSize)));
+}
+
+void MainWindow::clearCookieJar()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ buildWebView();
+
+ if(!m_cookieJar) {
+ m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
+ }
+ QList<QNetworkCookie> emptyList;
+ emptyList.clear();
+
+ m_cookieJar->setAllCookies(emptyList);
+ m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);