2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Kaj Wallin - kaj.wallin@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 #include "mapviewscreen.h"
23 #include "map/mapview.h"
24 #include "panelcommon.h"
25 #include "panelsidebar.h"
27 MapViewScreen::MapViewScreen(QWidget *parent)
30 MapView *mapView = new MapView(this);
31 m_mapEngine = new MapEngine(this);
32 mapView->setScene(m_mapEngine->scene());
34 m_friendsListPanel = new FriendListPanel(this);
35 m_userPanel = new UserInfoPanel(this);
36 PanelSideBar *userPanelSidebar = new PanelSideBar(this, LEFT);
37 PanelSideBar *friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
39 m_zoomButtonPanel = new ZoomButtonPanel(this, ZOOM_BUTTON_PANEL_POSITION_X,
40 ZOOM_BUTTON_PANEL_POSITION_Y);
42 connect(mapView, SIGNAL(viewScrolled(QPoint)),
43 m_mapEngine, SLOT(setLocation(QPoint)));
44 connect(m_mapEngine, SIGNAL(locationChanged(QPoint)),
45 mapView, SLOT(centerToSceneCoordinates(QPoint)));
46 connect(m_mapEngine, SIGNAL(zoomLevelChanged(int)),
47 mapView, SLOT(setZoomLevel(int)));
48 connect(mapView, SIGNAL(viewResized(QSize)),
49 m_mapEngine, SLOT(viewResized(QSize)));
50 connect(mapView, SIGNAL(viewZoomFinished()),
51 m_mapEngine, SLOT(viewZoomFinished()));
53 connect(this, SIGNAL(zoomInKeyPressed()),
54 m_mapEngine, SLOT(zoomIn()));
55 connect(this, SIGNAL(zoomOutKeyPressed()),
56 m_mapEngine, SLOT(zoomOut()));
58 connect(mapView, SIGNAL(viewResizedNewSize(int, int)),
59 this, SLOT(drawOsmLicense(int, int)));
60 connect(mapView, SIGNAL(viewResizedNewSize(int, int)),
61 m_friendsListPanel, SLOT(reDrawFriendsPanel(int, int)));
62 connect(mapView, SIGNAL(viewResizedNewSize(int, int)),
63 m_userPanel, SLOT(reDrawUserPanel(int, int)));
64 connect(mapView, SIGNAL(viewResizedNewSize(int, int)),
65 friendsListPanelSidebar, SLOT(reDrawSidebar(int, int)));
67 connect(m_zoomButtonPanel->m_zoomInBtn, SIGNAL(clicked()),
68 m_mapEngine, SLOT(zoomIn()));
69 connect(m_zoomButtonPanel->m_zoomOutBtn, SIGNAL(clicked()),
70 m_mapEngine, SLOT(zoomOut()));
72 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
73 m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
74 connect(m_friendsListPanel, SIGNAL(findFriend(QPointF)),
75 m_mapEngine, SLOT(setViewLocation(QPointF)));
77 connect(this, SIGNAL(userLocationReady(User*)),
78 m_mapEngine, SLOT(receiveOwnLocation(User*)));
79 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
80 m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
82 connect(m_mapEngine, SIGNAL(mapScrolledManually()),
83 this, SIGNAL(mapLocationChanged()));
85 connect(this, SIGNAL(positionReceived(QPointF,qreal)),
86 m_mapEngine, SLOT(gpsPositionUpdate(QPointF,qreal)));
87 connect(this, SIGNAL(enableAutoCentering(bool)),
88 m_mapEngine, SLOT(setAutoCentering(bool)));
89 connect(this, SIGNAL(gpsEnabled(bool)),
90 m_mapEngine, SLOT(gpsEnabled(bool)));
92 QHBoxLayout *mapViewLayout = new QHBoxLayout;
94 m_osmLicense = new QLabel(this);
95 m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
96 m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
97 m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
98 m_osmLicense->setFont(QFont("Nokia Sans", 9));
99 m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
100 m_osmLicense->fontMetrics().height());
102 m_friendsListPanel->stackUnder(friendsListPanelSidebar);
103 userPanelSidebar->stackUnder(m_friendsListPanel);
104 m_userPanel->stackUnder(userPanelSidebar);
105 m_zoomButtonPanel->stackUnder(m_userPanel);
106 m_osmLicense->stackUnder(m_zoomButtonPanel);
107 mapView->stackUnder(m_osmLicense);
109 mapViewLayout->addWidget(mapView);
110 setLayout(mapViewLayout);
112 mapViewLayout->setMargin(0);
116 setObjectName("Map view");
119 void MapViewScreen::drawOsmLicense(int width, int height)
121 qDebug() << __PRETTY_FUNCTION__ << width << "x" << height;
122 m_osmLicense->move(width - m_osmLicense->fontMetrics().width(OSM_LICENSE) - PANEL_PEEK_AMOUNT,
123 height - m_osmLicense->fontMetrics().height());