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"
30 MapViewScreen::MapViewScreen(QWidget *parent)
33 MapView *mapView = new MapView(this);
34 mapEngine = new MapEngine(this);
35 mapView->setScene(mapEngine->scene());
37 FriendListPanel *friendsListPanel = new FriendListPanel(this);
38 UserInfoPanel *userPanel = new UserInfoPanel(this);
40 connect(mapView, SIGNAL(viewScrolled(QPoint)),
41 mapEngine, SLOT(setLocation(QPoint)));
42 connect(mapEngine, SIGNAL(locationChanged(QPoint)),
43 mapView, SLOT(centerToSceneCoordinates(QPoint)));
44 connect(mapEngine, SIGNAL(zoomLevelChanged(int)),
45 mapView, SLOT(setZoomLevel(int)));
46 connect(mapView, SIGNAL(viewResized(QSize)),
47 mapEngine, SLOT(viewResized(QSize)));
48 connect(mapView, SIGNAL(viewContentChanged(QPoint)),
49 mapEngine, SLOT(alignImmovableItems(QPoint)));
50 connect(mapView, SIGNAL(viewZoomFinished()),
51 mapEngine, SLOT(viewZoomFinished()));
53 connect(mapView, SIGNAL(viewResizedNewSize(int,int)),
54 this, SLOT(drawOsmLicense(int, int)));
56 connect(mapView, SIGNAL(viewResizedNewSize(int,int)),
57 friendsListPanel, SLOT(reDrawFriendsPanel(int,int)));
58 connect(mapView, SIGNAL(viewResizedNewSize(int,int)),
59 userPanel, SLOT(reDrawUserPanel(int,int)));
61 connect(this, SIGNAL(SIG_friendsLocationsReady(QList<User*>&)),
62 friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
65 QHBoxLayout *mapViewLayout = new QHBoxLayout;
67 osmLicense = new QLabel(this);
68 osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
69 osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
70 osmLicense->setText("<font color='black'>"+OSM_LICENSE+"</font>");
71 osmLicense->setFont(QFont("Nokia Sans", 9));
72 osmLicense->resize(osmLicense->fontMetrics().width(OSM_LICENSE),
73 osmLicense->fontMetrics().height());
75 userPanel->stackUnder(friendsListPanel);
76 osmLicense->stackUnder(userPanel);
77 mapView->stackUnder(osmLicense);
79 mapViewLayout->addWidget(mapView);
80 setLayout(mapViewLayout);
82 mapViewLayout->setMargin(0);
86 setObjectName("Map view");
89 void MapViewScreen::searchMap()
91 qreal lat = latLine.text().toFloat();
92 qreal lon = lonLine.text().toFloat();
94 qDebug() << lat << "," << lon;
96 mapEngine->setViewLocation(QPointF(lon, lat));
99 void MapViewScreen::userLocationReady(User *user)
101 qDebug() << __PRETTY_FUNCTION__;
102 mapEngine->receiveOwnLocation(user);
105 void MapViewScreen::friendsLocationsReady(QList<User *> &friendsList)
107 qDebug() << __PRETTY_FUNCTION__;
108 mapEngine->receiveFriendLocations(friendsList);
111 void MapViewScreen::drawOsmLicense(int width, int height)
113 qWarning() << __PRETTY_FUNCTION__ << width << "x" << height;
114 osmLicense->move(width-osmLicense->fontMetrics().width(OSM_LICENSE),
115 height-osmLicense->fontMetrics().height());