#include <QGLWidget>
#endif // Q_WS_MAEMO_5
-#include "common.h"
+#include "mapcommon.h"
#include "mapview.h"
MapView::MapView(QWidget *parent) : QGraphicsView(parent)
{
+/**
+ * Use OpenGL for desktop to gain some performance in map view.
+ * OpenGL can't be used in scratchbox.
+ */
#ifndef Q_WS_MAEMO_5
- // use opengl for desktop to gain some performance in map view
- // opengl can't be used in scrathbox
- setViewport(new QGLWidget);
- this->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
-#endif // Q_WS_MAEMO_5
+ //setViewport(new QGLWidget);
+#endif // !Q_WS_MAEMO_5
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
void MapView::mouseMoveEvent(QMouseEvent *event)
{
- m_scenePosition += m_mousePosition - mapToScene(event->pos());
+ m_scenePosition += m_mousePosition - mapToScene(event->pos()).toPoint();
emit viewScrolled(m_scenePosition);
//qDebug() << __PRETTY_FUNCTION__ << "m_scenePosition" << m_scenePosition;
- m_mousePosition = mapToScene(event->pos());
+ m_mousePosition = mapToScene(event->pos()).toPoint();
}
void MapView::mousePressEvent(QMouseEvent *event)
{
- m_mousePosition = mapToScene(event->pos());
- m_scenePosition = mapToScene(width() / 2 - 1, height() / 2 - 1);
+ m_mousePosition = mapToScene(event->pos()).toPoint();
+ m_scenePosition = mapToScene(width() / 2 - 1, height() / 2 - 1).toPoint();
}
-void MapView::centerToSceneCoordinates(QPointF sceneCoordinate)
+void MapView::centerToSceneCoordinates(QPoint sceneCoordinate)
{
- //qDebug() << __PRETTY_FUNCTION__ << "sceneCoordinate" << sceneCoordinate;
+// qDebug() << __PRETTY_FUNCTION__ << "sceneCoordinate" << sceneCoordinate;
centerOn(sceneCoordinate);
}
void MapView::resizeEvent(QResizeEvent *event)
{
- qDebug() << "Resize event: " << event->size();
+ //qDebug() << "Resize event: " << event->size();
emit viewResized(event->size());
}