2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Sami Rämö - sami.ramo@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,
25 #include <QMouseEvent>
28 #include <QAbstractKineticScroller>
29 #endif // Q_WS_MAEMO_5
34 MapView::MapView(QWidget *parent) : QGraphicsView(parent)
36 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
37 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
40 qDebug() << __PRETTY_FUNCTION__ << "QAbstractKineticScroller built in";
42 QAbstractKineticScroller *scroller = this->property("kineticScroller")
43 .value<QAbstractKineticScroller *>();
46 scroller->setEnabled(true);
47 #endif // Q_WS_MAEMO_5
50 void MapView::setZoomLevel(int zoomLevel)
52 double scaleFactor = pow(2, zoomLevel - MAX_ZOOM_LEVEL);
54 transform.scale(scaleFactor, scaleFactor);
55 setTransform(transform);
58 void MapView::mouseMoveEvent(QMouseEvent *event)
60 m_scenePosition += m_mousePosition - mapToScene(event->pos());
62 emit viewScrolled(m_scenePosition);
63 //qDebug() << __PRETTY_FUNCTION__ << "m_scenePosition" << m_scenePosition;
65 m_mousePosition = mapToScene(event->pos());
68 void MapView::mousePressEvent(QMouseEvent *event)
70 m_mousePosition = mapToScene(event->pos());
71 m_scenePosition = mapToScene(width() / 2 - 1, height() / 2 - 1);
75 void MapView::centerToSceneCoordinates(QPointF sceneCoordinate)
77 //qDebug() << __PRETTY_FUNCTION__ << "sceneCoordinate" << sceneCoordinate;
78 centerOn(sceneCoordinate);
81 void MapView::resizeEvent(QResizeEvent *event)
83 qDebug() << "Resize event: " << event->size();
84 emit viewResized(event->size());