diff options
Diffstat (limited to 'navit/graphics/qt5/QNavitWidget.cpp')
-rw-r--r-- | navit/graphics/qt5/QNavitWidget.cpp | 65 |
1 files changed, 31 insertions, 34 deletions
diff --git a/navit/graphics/qt5/QNavitWidget.cpp b/navit/graphics/qt5/QNavitWidget.cpp index df051b557..9c2b96505 100644 --- a/navit/graphics/qt5/QNavitWidget.cpp +++ b/navit/graphics/qt5/QNavitWidget.cpp @@ -46,23 +46,20 @@ extern "C" { #include "graphics_qt5.h" QNavitWidget::QNavitWidget(struct graphics_priv* my_graphics_priv, - QWidget* parent, - Qt::WindowFlags flags) - : QWidget(parent, flags) -{ + QWidget* parent, + Qt::WindowFlags flags) + : QWidget(parent, flags) { graphics_priv = my_graphics_priv; } -bool QNavitWidget::event(QEvent* event) -{ +bool QNavitWidget::event(QEvent* event) { if (event->type() == QEvent::Gesture) dbg(lvl_debug, "Gesture event caught"); //return gestureEvent(static_cast<QGestureEvent*>(event)); return QWidget::event(event); } -static void paintOverlays(QPainter* painter, struct graphics_priv* gp, QPaintEvent* event) -{ +static void paintOverlays(QPainter* painter, struct graphics_priv* gp, QPaintEvent* event) { GHashTableIter iter; struct graphics_priv *key, *value; g_hash_table_iter_init(&iter, gp->overlays); @@ -70,7 +67,8 @@ static void paintOverlays(QPainter* painter, struct graphics_priv* gp, QPaintEve if (!value->disable) { QRect rr(value->x, value->y, value->pixmap->width(), value->pixmap->height()); if (event->rect().intersects(rr)) { - dbg(lvl_debug, "draw overlay (%d, %d, %d, %d)", value->x + value->scroll_x, value->y + value->scroll_y, value->pixmap->width(), value->pixmap->height()); + dbg(lvl_debug, "draw overlay (%d, %d, %d, %d)", value->x + value->scroll_x, value->y + value->scroll_y, + value->pixmap->width(), value->pixmap->height()); painter->drawPixmap(value->x + value->scroll_x, value->y + value->scroll_y, *value->pixmap); /* draw overlays of overlay if any by recursive calling */ paintOverlays(painter, value, event); @@ -79,9 +77,9 @@ static void paintOverlays(QPainter* painter, struct graphics_priv* gp, QPaintEve } } -void QNavitWidget::paintEvent(QPaintEvent* event) -{ - dbg(lvl_debug, "enter (%d, %d, %d, %d)", event->rect().x(), event->rect().y(), event->rect().width(), event->rect().height()); +void QNavitWidget::paintEvent(QPaintEvent* event) { + dbg(lvl_debug, "enter (%d, %d, %d, %d)", event->rect().x(), event->rect().y(), event->rect().width(), + event->rect().height()); QPainter painter(this); /* color background if any */ if (graphics_priv->background_graphics_gc_priv != NULL) { @@ -89,13 +87,12 @@ void QNavitWidget::paintEvent(QPaintEvent* event) painter.fillRect(event->rect(), *graphics_priv->background_graphics_gc_priv->brush); } painter.drawPixmap(event->rect().x(), event->rect().y(), *graphics_priv->pixmap, - event->rect().x() - graphics_priv->scroll_x, event->rect().y() - graphics_priv->scroll_y, - event->rect().width(), event->rect().height()); + event->rect().x() - graphics_priv->scroll_x, event->rect().y() - graphics_priv->scroll_y, + event->rect().width(), event->rect().height()); paintOverlays(&painter, graphics_priv, event); } -void QNavitWidget::resizeEvent(QResizeEvent* event) -{ +void QNavitWidget::resizeEvent(QResizeEvent* event) { QPainter* painter = NULL; if (graphics_priv->pixmap != NULL) { delete graphics_priv->pixmap; @@ -110,35 +107,37 @@ void QNavitWidget::resizeEvent(QResizeEvent* event) delete painter; } dbg(lvl_debug, "size %dx%d", width(), height()); - dbg(lvl_debug, "pixmap %p %dx%d", graphics_priv->pixmap, graphics_priv->pixmap->width(), graphics_priv->pixmap->height()); + dbg(lvl_debug, "pixmap %p %dx%d", graphics_priv->pixmap, graphics_priv->pixmap->width(), + graphics_priv->pixmap->height()); /* if the root window got resized, tell navit about it */ if (graphics_priv->root) resize_callback(graphics_priv, width(), height()); } -void QNavitWidget::mouseEvent(int pressed, QMouseEvent* event) -{ +void QNavitWidget::mouseEvent(int pressed, QMouseEvent* event) { struct point p; // dbg(lvl_debug,"enter"); p.x = event->x(); p.y = event->y(); switch (event->button()) { case Qt::LeftButton: - callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(1), GINT_TO_POINTER(&p)); + callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(1), + GINT_TO_POINTER(&p)); break; case Qt::MidButton: - callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(2), GINT_TO_POINTER(&p)); + callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(2), + GINT_TO_POINTER(&p)); break; case Qt::RightButton: - callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(3), GINT_TO_POINTER(&p)); + callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(3), + GINT_TO_POINTER(&p)); break; default: break; } } -void QNavitWidget::keyPressEvent(QKeyEvent* event) -{ +void QNavitWidget::keyPressEvent(QKeyEvent* event) { dbg(lvl_debug, "enter"); char key[2]; int keycode; @@ -202,20 +201,17 @@ void QNavitWidget::keyPressEvent(QKeyEvent* event) dbg(lvl_debug, "keyval 0x%x", keycode); } -void QNavitWidget::mousePressEvent(QMouseEvent* event) -{ +void QNavitWidget::mousePressEvent(QMouseEvent* event) { // dbg(lvl_debug,"enter"); mouseEvent(1, event); } -void QNavitWidget::mouseReleaseEvent(QMouseEvent* event) -{ +void QNavitWidget::mouseReleaseEvent(QMouseEvent* event) { // dbg(lvl_debug,"enter"); mouseEvent(0, event); } -void QNavitWidget::mouseMoveEvent(QMouseEvent* event) -{ +void QNavitWidget::mouseMoveEvent(QMouseEvent* event) { struct point p; // dbg(lvl_debug,"enter"); p.x = event->x(); @@ -223,8 +219,7 @@ void QNavitWidget::mouseMoveEvent(QMouseEvent* event) callback_list_call_attr_1(graphics_priv->callbacks, attr_motion, (void*)&p); } -void QNavitWidget::wheelEvent(QWheelEvent* event) -{ +void QNavitWidget::wheelEvent(QWheelEvent* event) { struct point p; int button; dbg(lvl_debug, "enter"); @@ -239,8 +234,10 @@ void QNavitWidget::wheelEvent(QWheelEvent* event) button = -1; if (button != -1) { - callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(button), GINT_TO_POINTER(&p)); - callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(button), GINT_TO_POINTER(&p)); + callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(button), + GINT_TO_POINTER(&p)); + callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(button), + GINT_TO_POINTER(&p)); } event->accept(); |