summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWildemann Stefan <stefan.wildemann@corpuls.com>2019-01-29 10:55:50 +0100
committerWildemann Stefan <stefan.wildemann@corpuls.com>2019-01-29 10:55:50 +0100
commit02aa1898a263b901ebd85b33efda6e272df7aef5 (patch)
treea5741b41cadd588240f5d2a7399855537306edb5
parent1cc47990b8027e797fc2fcd8785203883e5fee8c (diff)
downloadnavit-02aa1898a263b901ebd85b33efda6e272df7aef5.tar.gz
Fix:graphics_qt5: stlye with astyle to comply with style
Use astyle --indent=spaces=4 --style=attach -n --max-code-length=120 -xf -xh to obey styling rules. Btw. a big hurdle for newbies to just fix !one line" if one needs to restyle a whole module for ci...
-rw-r--r--navit/graphics/qt5/QNavitQuick.cpp1
-rw-r--r--navit/graphics/qt5/QNavitQuick.h4
-rw-r--r--navit/graphics/qt5/QNavitWidget.cpp271
-rw-r--r--navit/graphics/qt5/QNavitWidget.h8
-rw-r--r--navit/graphics/qt5/event_qt5.cpp1
-rw-r--r--navit/graphics/qt5/event_qt5.h4
-rw-r--r--navit/graphics/qt5/graphics_qt5.cpp25
-rw-r--r--navit/graphics/qt5/graphics_qt5.h4
8 files changed, 157 insertions, 161 deletions
diff --git a/navit/graphics/qt5/QNavitQuick.cpp b/navit/graphics/qt5/QNavitQuick.cpp
index 801827ebc..4884e6f27 100644
--- a/navit/graphics/qt5/QNavitQuick.cpp
+++ b/navit/graphics/qt5/QNavitQuick.cpp
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-//Style with: clang-format -style=WebKit -i
#include <glib.h>
#ifdef HAVE_UNISTD_H
diff --git a/navit/graphics/qt5/QNavitQuick.h b/navit/graphics/qt5/QNavitQuick.h
index 3679e8127..39ddfed1d 100644
--- a/navit/graphics/qt5/QNavitQuick.h
+++ b/navit/graphics/qt5/QNavitQuick.h
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#ifndef QNAVITQUICK_H
#define QNAVITQUICK_H
@@ -28,8 +27,7 @@ class QNavitQuick;
class QNavitQuick : public QQuickPaintedItem {
Q_OBJECT
-public:
- QNavitQuick(QQuickItem* parent = 0);
+public: QNavitQuick(QQuickItem* parent = 0);
void paint(QPainter* painter);
diff --git a/navit/graphics/qt5/QNavitWidget.cpp b/navit/graphics/qt5/QNavitWidget.cpp
index 6fcc8084a..cebaed9a1 100644
--- a/navit/graphics/qt5/QNavitWidget.cpp
+++ b/navit/graphics/qt5/QNavitWidget.cpp
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#include <glib.h>
#ifdef HAVE_UNISTD_H
@@ -98,149 +97,149 @@ void QNavitWidget::resizeEvent(QResizeEvent* event) {
if((width() != graphics_priv->pixmap->width()) || (height() != graphics_priv->pixmap->height())) {
delete graphics_priv->pixmap;
graphics_priv->pixmap = NULL;
+ }
+ if (graphics_priv->pixmap == NULL) {
+ graphics_priv->pixmap = new QPixmap(size());
+ }
+ painter = new QPainter(graphics_priv->pixmap);
+ if (painter != NULL) {
+ QBrush brush;
+ painter->fillRect(0, 0, width(), height(), brush);
+ 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());
+ /* if the root window got resized, tell navit about it */
+ if (graphics_priv->root)
+ resize_callback(graphics_priv, width(), height());
}
- if (graphics_priv->pixmap == NULL) {
- graphics_priv->pixmap = new QPixmap(size());
- }
- painter = new QPainter(graphics_priv->pixmap);
- if (painter != NULL) {
- QBrush brush;
- painter->fillRect(0, 0, width(), height(), brush);
- 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());
- /* 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) {
- 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));
- 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));
- 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));
- break;
- default:
- break;
+ 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));
+ 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));
+ 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));
+ break;
+ default:
+ break;
+ }
}
-}
-void QNavitWidget::keyPressEvent(QKeyEvent* event) {
- dbg(lvl_debug, "enter");
- char key[2];
- int keycode;
- char* text = NULL;
-
- keycode = event->key();
- key[0] = '\0';
- key[1] = '\0';
- switch (keycode) {
- case Qt::Key_Up:
- key[0] = NAVIT_KEY_UP;
- break;
- case Qt::Key_Down:
- key[0] = NAVIT_KEY_DOWN;
- break;
- case Qt::Key_Left:
- key[0] = NAVIT_KEY_LEFT;
- break;
- case Qt::Key_Right:
- key[0] = NAVIT_KEY_RIGHT;
- break;
- case Qt::Key_Backspace:
- key[0] = NAVIT_KEY_BACKSPACE;
- break;
- case Qt::Key_Tab:
- key[0] = NAVIT_KEY_TAB;
- break;
- case Qt::Key_Delete:
- key[0] = NAVIT_KEY_DELETE;
- break;
- case Qt::Key_Escape:
- key[0] = NAVIT_KEY_BACK;
- break;
- case Qt::Key_Return:
- case Qt::Key_Enter:
- key[0] = NAVIT_KEY_RETURN;
- break;
- case Qt::Key_ZoomIn:
- key[0] = NAVIT_KEY_ZOOM_IN;
- break;
- case Qt::Key_ZoomOut:
- key[0] = NAVIT_KEY_ZOOM_OUT;
- break;
- case Qt::Key_PageUp:
- key[0] = NAVIT_KEY_PAGE_UP;
- break;
- case Qt::Key_PageDown:
- key[0] = NAVIT_KEY_PAGE_DOWN;
- break;
- default:
- QString str = event->text();
- if ((str != NULL) && (str.size() != 0)) {
- text = str.toUtf8().data();
+ void QNavitWidget::keyPressEvent(QKeyEvent* event) {
+ dbg(lvl_debug, "enter");
+ char key[2];
+ int keycode;
+ char* text = NULL;
+
+ keycode = event->key();
+ key[0] = '\0';
+ key[1] = '\0';
+ switch (keycode) {
+ case Qt::Key_Up:
+ key[0] = NAVIT_KEY_UP;
+ break;
+ case Qt::Key_Down:
+ key[0] = NAVIT_KEY_DOWN;
+ break;
+ case Qt::Key_Left:
+ key[0] = NAVIT_KEY_LEFT;
+ break;
+ case Qt::Key_Right:
+ key[0] = NAVIT_KEY_RIGHT;
+ break;
+ case Qt::Key_Backspace:
+ key[0] = NAVIT_KEY_BACKSPACE;
+ break;
+ case Qt::Key_Tab:
+ key[0] = NAVIT_KEY_TAB;
+ break;
+ case Qt::Key_Delete:
+ key[0] = NAVIT_KEY_DELETE;
+ break;
+ case Qt::Key_Escape:
+ key[0] = NAVIT_KEY_BACK;
+ break;
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ key[0] = NAVIT_KEY_RETURN;
+ break;
+ case Qt::Key_ZoomIn:
+ key[0] = NAVIT_KEY_ZOOM_IN;
+ break;
+ case Qt::Key_ZoomOut:
+ key[0] = NAVIT_KEY_ZOOM_OUT;
+ break;
+ case Qt::Key_PageUp:
+ key[0] = NAVIT_KEY_PAGE_UP;
+ break;
+ case Qt::Key_PageDown:
+ key[0] = NAVIT_KEY_PAGE_DOWN;
+ break;
+ default:
+ QString str = event->text();
+ if ((str != NULL) && (str.size() != 0)) {
+ text = str.toUtf8().data();
+ }
}
+ if (text != NULL)
+ callback_list_call_attr_1(graphics_priv->callbacks, attr_keypress, (void*)text);
+ else if (key[0])
+ callback_list_call_attr_1(graphics_priv->callbacks, attr_keypress, (void*)key);
+ else
+ dbg(lvl_debug, "keyval 0x%x", keycode);
}
- if (text != NULL)
- callback_list_call_attr_1(graphics_priv->callbacks, attr_keypress, (void*)text);
- else if (key[0])
- callback_list_call_attr_1(graphics_priv->callbacks, attr_keypress, (void*)key);
- else
- dbg(lvl_debug, "keyval 0x%x", keycode);
-}
-void QNavitWidget::mousePressEvent(QMouseEvent* event) {
- // dbg(lvl_debug,"enter");
- mouseEvent(1, event);
-}
-
-void QNavitWidget::mouseReleaseEvent(QMouseEvent* event) {
- // dbg(lvl_debug,"enter");
- mouseEvent(0, event);
-}
+ void QNavitWidget::mousePressEvent(QMouseEvent* event) {
+ // dbg(lvl_debug,"enter");
+ mouseEvent(1, event);
+ }
-void QNavitWidget::mouseMoveEvent(QMouseEvent* event) {
- struct point p;
- // dbg(lvl_debug,"enter");
- p.x = event->x();
- p.y = event->y();
- callback_list_call_attr_1(graphics_priv->callbacks, attr_motion, (void*)&p);
-}
+ void QNavitWidget::mouseReleaseEvent(QMouseEvent* event) {
+ // dbg(lvl_debug,"enter");
+ mouseEvent(0, event);
+ }
-void QNavitWidget::wheelEvent(QWheelEvent* event) {
- struct point p;
- int button;
- dbg(lvl_debug, "enter");
- p.x = event->x(); // xy-coordinates of the mouse pointer
- p.y = event->y();
-
- if (event->delta() > 0) // wheel movement away from the person
- button = 4;
- else if (event->delta() < 0) // wheel movement towards the person
- button = 5;
- else
- 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));
+ void QNavitWidget::mouseMoveEvent(QMouseEvent* event) {
+ struct point p;
+ // dbg(lvl_debug,"enter");
+ p.x = event->x();
+ p.y = event->y();
+ callback_list_call_attr_1(graphics_priv->callbacks, attr_motion, (void*)&p);
}
- event->accept();
-}
+ void QNavitWidget::wheelEvent(QWheelEvent* event) {
+ struct point p;
+ int button;
+ dbg(lvl_debug, "enter");
+ p.x = event->x(); // xy-coordinates of the mouse pointer
+ p.y = event->y();
+
+ if (event->delta() > 0) // wheel movement away from the person
+ button = 4;
+ else if (event->delta() < 0) // wheel movement towards the person
+ button = 5;
+ else
+ 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));
+ }
+
+ event->accept();
+ }
diff --git a/navit/graphics/qt5/QNavitWidget.h b/navit/graphics/qt5/QNavitWidget.h
index 674b69390..40fb88b19 100644
--- a/navit/graphics/qt5/QNavitWidget.h
+++ b/navit/graphics/qt5/QNavitWidget.h
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#ifndef __QNavitWidget_h
#define __QNavitWidget_h
@@ -30,10 +29,9 @@ class QNavitWidget;
class QNavitWidget : public QWidget {
Q_OBJECT
-public:
- QNavitWidget(struct graphics_priv* my_graphics_priv,
- QWidget* parent,
- Qt::WindowFlags flags);
+public: QNavitWidget(struct graphics_priv* my_graphics_priv,
+ QWidget* parent,
+ Qt::WindowFlags flags);
protected:
virtual bool event(QEvent* event);
diff --git a/navit/graphics/qt5/event_qt5.cpp b/navit/graphics/qt5/event_qt5.cpp
index 5c7c3ca27..7186534fe 100644
--- a/navit/graphics/qt5/event_qt5.cpp
+++ b/navit/graphics/qt5/event_qt5.cpp
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#include <glib.h>
#include <stdio.h>
diff --git a/navit/graphics/qt5/event_qt5.h b/navit/graphics/qt5/event_qt5.h
index 892e8fca8..7fe184cd1 100644
--- a/navit/graphics/qt5/event_qt5.h
+++ b/navit/graphics/qt5/event_qt5.h
@@ -16,15 +16,13 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#include <QObject>
#include <glib.h>
class qt5_navit_timer : public QObject {
Q_OBJECT
-public:
- qt5_navit_timer(QObject* parent = 0);
+public: qt5_navit_timer(QObject* parent = 0);
GHashTable* timer_type;
GHashTable* timer_callback;
GHashTable* watches;
diff --git a/navit/graphics/qt5/graphics_qt5.cpp b/navit/graphics/qt5/graphics_qt5.cpp
index c71b951a5..6a17bd68e 100644
--- a/navit/graphics/qt5/graphics_qt5.cpp
+++ b/navit/graphics/qt5/graphics_qt5.cpp
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#include <glib.h>
#ifdef HAVE_UNISTD_H
@@ -180,7 +179,8 @@ static const char* fontfamilies[] = {
*
* Allocates a font handle and returnes filled interface stucture
*/
-static struct graphics_font_priv* font_new(struct graphics_priv* gr, struct graphics_font_methods* meth, char* font, int size, int flags) {
+static struct graphics_font_priv* font_new(struct graphics_priv* gr, struct graphics_font_methods* meth, char* font,
+ int size, int flags) {
int a = 0;
struct graphics_font_priv* font_priv;
dbg(lvl_debug, "enter (font %s, %d, 0x%x)", font, size, flags);
@@ -295,7 +295,8 @@ struct graphics_image_methods image_methods = {
image_destroy
};
-static struct graphics_image_priv* image_new(struct graphics_priv* gr, struct graphics_image_methods* meth, char* path, int* w, int* h, struct point* hot, int rotation) {
+static struct graphics_image_priv* image_new(struct graphics_priv* gr, struct graphics_image_methods* meth, char* path,
+ int* w, int* h, struct point* hot, int rotation) {
struct graphics_image_priv* image_priv;
// dbg(lvl_debug,"enter %s, %d %d", path, *w, *h);
if (path[0] == 0) {
@@ -448,7 +449,8 @@ static void draw_circle(struct graphics_priv* gr, struct graphics_gc_priv* gc, s
*
* Renders given text on gr surface. Draws nice contrast outline around text.
*/
-static void draw_text(struct graphics_priv* gr, struct graphics_gc_priv* fg, struct graphics_gc_priv* bg, struct graphics_font_priv* font, char* text, struct point* p, int dx, int dy) {
+static void draw_text(struct graphics_priv* gr, struct graphics_gc_priv* fg, struct graphics_gc_priv* bg,
+ struct graphics_font_priv* font, char* text, struct point* p, int dx, int dy) {
dbg(lvl_debug, "enter gc=%p, fg=%p, bg=%p pos(%d,%d) d(%d, %d) %s", gr, fg, bg, p->x, p->y, dx, dy, text);
QPainter* painter = gr->painter;
if (painter == NULL)
@@ -539,7 +541,8 @@ static void draw_text(struct graphics_priv* gr, struct graphics_gc_priv* fg, str
#endif
}
-static void draw_image(struct graphics_priv* gr, struct graphics_gc_priv* fg, struct point* p, struct graphics_image_priv* img) {
+static void draw_image(struct graphics_priv* gr, struct graphics_gc_priv* fg, struct point* p,
+ struct graphics_image_priv* img) {
// dbg(lvl_debug,"enter");
if (gr->painter != NULL)
gr->painter->drawPixmap(p->x, p->y, *img->pixmap);
@@ -639,7 +642,8 @@ static void draw_mode(struct graphics_priv* gr, enum draw_mode_num mode) {
}
}
-static struct graphics_priv* overlay_new(struct graphics_priv* gr, struct graphics_methods* meth, struct point* p, int w, int h, int wraparound);
+static struct graphics_priv* overlay_new(struct graphics_priv* gr, struct graphics_methods* meth, struct point* p,
+ int w, int h, int wraparound);
void resize_callback(struct graphics_priv* gr, int w, int h) {
// dbg(lvl_debug,"enter (%d, %d)", w, h);
@@ -729,7 +733,8 @@ static void image_free(struct graphics_priv* gr, struct graphics_image_priv* pri
*
* Calculates the bounding box around the given text.
*/
-static void get_text_bbox(struct graphics_priv* gr, struct graphics_font_priv* font, char* text, int dx, int dy, struct point* ret, int estimate) {
+static void get_text_bbox(struct graphics_priv* gr, struct graphics_font_priv* font, char* text, int dx, int dy,
+ struct point* ret, int estimate) {
int i;
struct point pt;
QString tmp = QString::fromUtf8(text);
@@ -815,7 +820,8 @@ static struct graphics_methods graphics_methods = {
};
/* create new graphics context on given context */
-static struct graphics_priv* overlay_new(struct graphics_priv* gr, struct graphics_methods* meth, struct point* p, int w, int h, int wraparound) {
+static struct graphics_priv* overlay_new(struct graphics_priv* gr, struct graphics_methods* meth, struct point* p,
+ int w, int h, int wraparound) {
struct graphics_priv* graphics_priv = NULL;
graphics_priv = g_new0(struct graphics_priv, 1);
*meth = graphics_methods;
@@ -859,7 +865,8 @@ static struct graphics_priv* overlay_new(struct graphics_priv* gr, struct graphi
}
/* create application and initial graphics context */
-static struct graphics_priv* graphics_qt5_new(struct navit* nav, struct graphics_methods* meth, struct attr** attrs, struct callback_list* cbl) {
+static struct graphics_priv* graphics_qt5_new(struct navit* nav, struct graphics_methods* meth, struct attr** attrs,
+ struct callback_list* cbl) {
struct graphics_priv* graphics_priv = NULL;
struct attr* event_loop_system = NULL;
struct attr* platform = NULL;
diff --git a/navit/graphics/qt5/graphics_qt5.h b/navit/graphics/qt5/graphics_qt5.h
index f9d19616b..0eed89510 100644
--- a/navit/graphics/qt5/graphics_qt5.h
+++ b/navit/graphics/qt5/graphics_qt5.h
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#ifndef __graphics_qt_h
#define __graphics_qt_h
@@ -62,8 +61,7 @@ struct graphics_priv;
#if USE_QML
class GraphicsPriv : public QObject {
Q_OBJECT
-public:
- GraphicsPriv(struct graphics_priv* gp);
+public: GraphicsPriv(struct graphics_priv* gp);
~GraphicsPriv();
void emit_update();