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"
24 #include "../map/mapview.h"
25 #include "../map/mapengine.h"
27 #include "friendlistpanel.h"
28 #include "userpanel.h"
29 #include "panelcommon.h"
31 #include "panelsidebar.h"
33 MapViewScreen::MapViewScreen(QWidget *parent)
35 m_autoCenteringEnabled(false)
37 MapView *mapView = new MapView(this);
38 mapEngine = new MapEngine(this);
39 mapView->setScene(mapEngine->scene());
41 FriendListPanel *friendsListPanel = new FriendListPanel(this);
42 UserInfoPanel *userPanel = new UserInfoPanel(this);
43 PanelSideBar *userPanelSidebar = new PanelSideBar(this, LEFT);
44 PanelSideBar *friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
46 connect(mapView, SIGNAL(viewScrolled(QPoint)),
47 mapEngine, SLOT(setLocation(QPoint)));
48 connect(mapEngine, SIGNAL(locationChanged(QPoint)),
49 mapView, SLOT(centerToSceneCoordinates(QPoint)));
50 connect(mapEngine, SIGNAL(zoomLevelChanged(int)),
51 mapView, SLOT(setZoomLevel(int)));
52 connect(mapView, SIGNAL(viewResized(QSize)),
53 mapEngine, SLOT(viewResized(QSize)));
54 connect(mapView, SIGNAL(viewContentChanged(QPoint)),
55 mapEngine, SLOT(alignImmovableItems(QPoint)));
56 connect(mapView, SIGNAL(viewZoomFinished()),
57 mapEngine, SLOT(viewZoomFinished()));
59 connect(mapView, SIGNAL(viewResizedNewSize(int,int)),
60 this, SLOT(drawOsmLicense(int, int)));
62 connect(mapView, SIGNAL(viewResizedNewSize(int,int)),
63 friendsListPanel, SLOT(reDrawFriendsPanel(int,int)));
64 connect(mapView, SIGNAL(viewResizedNewSize(int,int)),
65 userPanel, SLOT(reDrawUserPanel(int,int)));
66 connect(mapView, SIGNAL(viewResizedNewSize(int,int)),
67 friendsListPanelSidebar, SLOT(reDrawSidebar(int,int)));
69 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
70 friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
72 connect(this, SIGNAL(userLocationReady(User*)),
73 mapEngine, SLOT(receiveOwnLocation(User*)));
74 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
75 mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
77 QHBoxLayout *mapViewLayout = new QHBoxLayout;
79 osmLicense = new QLabel(this);
80 osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
81 osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
82 osmLicense->setText("<font color='black'>"+OSM_LICENSE+"</font>");
83 osmLicense->setFont(QFont("Nokia Sans", 9));
84 osmLicense->resize(osmLicense->fontMetrics().width(OSM_LICENSE),
85 osmLicense->fontMetrics().height());
87 friendsListPanel->stackUnder(friendsListPanelSidebar);
88 userPanelSidebar->stackUnder(friendsListPanel);
89 userPanel->stackUnder(userPanelSidebar);
90 osmLicense->stackUnder(userPanel);
91 mapView->stackUnder(osmLicense);
93 mapViewLayout->addWidget(mapView);
94 setLayout(mapViewLayout);
96 mapViewLayout->setMargin(0);
100 setObjectName("Map view");
103 void MapViewScreen::drawOsmLicense(int width, int height)
105 qDebug() << __PRETTY_FUNCTION__ << width << "x" << height;
106 osmLicense->move(width - osmLicense->fontMetrics().width(OSM_LICENSE) - PANEL_PEEK_AMOUNT,
107 height - osmLicense->fontMetrics().height());
110 void MapViewScreen::positionReceived(QPointF position)
112 qDebug() << __PRETTY_FUNCTION__;
114 if (m_autoCenteringEnabled)
115 mapEngine->setViewLocation(position);
118 void MapViewScreen::enableAutoCentering(bool enabled)
120 qDebug() << __PRETTY_FUNCTION__;
122 m_autoCenteringEnabled = enabled;