24c14ee40a3d8fae7a8143eeb990676b8ea31765
[situare] / src / map / mapview.cpp
1  /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Sami Rämö - sami.ramo@ixonos.com
6
7     Situare is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     as published by the Free Software Foundation; either version 2
10     of the License, or (at your option) any later version.
11
12     Situare is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with Situare; if not, write to the Free Software
19     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20     USA.
21  */
22
23 #include <math.h>
24
25 #include <QDebug>
26 #include <QMouseEvent>
27
28 #include "mapview.h"
29 #include "mapengine.h"
30
31 MapView::MapView(QWidget *parent) : QGraphicsView(parent)
32 {
33     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
34     setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
35 }
36
37 void MapView::setZoomLevel(int zoomLevel)
38 {
39     double scaleFactor = pow(2, zoomLevel - MapEngine::MAX_ZOOM_LEVEL);
40     scale(scaleFactor, scaleFactor);
41 }
42
43 void MapView::mousePressEvent(QMouseEvent *event)
44 {
45     qDebug() << __PRETTY_FUNCTION__ << "scene coordinate:" << mapToScene(event->pos());
46 }