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 // QVBoxLayout *mapControlLayout = new QVBoxLayout;
68 // QWidget *mapControl = new QWidget(this);
69 // mapControl->setLayout(mapControlLayout);
70 // search = new QPushButton("Search", this);
71 // zoomOut = new QPushButton("-", this);
72 // zoomIn = new QPushButton("+", this);
73 // mapControlLayout->addWidget(&latLine);
74 // mapControlLayout->addWidget(&lonLine);
75 // mapControlLayout->addWidget(search);
76 // mapControlLayout->addWidget(zoomIn);
77 // mapControlLayout->addWidget(zoomOut);
78 // mapViewLayout->addWidget(mapControl);
79 // connect(search, SIGNAL(clicked()), this, SLOT(searchMap()));
80 // connect(zoomIn, SIGNAL(clicked()), mapEngine, SLOT(zoomIn()));
81 // connect(zoomOut, SIGNAL(clicked()), mapEngine, SLOT(zoomOut()));
84 osmLicense = new QLabel(this);
85 osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
86 osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
87 osmLicense->setText("<font color='black'>"+OSM_LICENSE+"</font>");
88 osmLicense->setFont(QFont("Nokia Sans", 9));
89 osmLicense->resize(osmLicense->fontMetrics().width(OSM_LICENSE),
90 osmLicense->fontMetrics().height());
92 userPanel->stackUnder(friendsListPanel);
93 osmLicense->stackUnder(userPanel);
94 mapView->stackUnder(osmLicense);
96 mapViewLayout->addWidget(mapView);
97 setLayout(mapViewLayout);
99 mapViewLayout->setMargin(0);
103 setObjectName("Map view");
106 void MapViewScreen::searchMap()
108 qreal lat = latLine.text().toFloat();
109 qreal lon = lonLine.text().toFloat();
111 qDebug() << lat << "," << lon;
113 mapEngine->setViewLocation(QPointF(lon, lat));
116 void MapViewScreen::userLocationReady(User *user)
118 qDebug() << __PRETTY_FUNCTION__;
119 mapEngine->receiveOwnLocation(user);
122 void MapViewScreen::friendsLocationsReady(QList<User *> &friendsList)
124 qDebug() << __PRETTY_FUNCTION__;
125 mapEngine->receiveFriendLocations(friendsList);
128 void MapViewScreen::drawOsmLicense(int width, int height)
130 qWarning() << __PRETTY_FUNCTION__ << width << "x" << height;
131 osmLicense->move(width-osmLicense->fontMetrics().width(OSM_LICENSE),
132 height-osmLicense->fontMetrics().height());