1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Compare commits

...

3 Commits

Author SHA1 Message Date
d750715bed Get rid of QT_NO_DEPRECATED_WARNINGS 2024-06-05 10:01:16 +02:00
592b552721
Update CONTRIBUTING.md
Highlight the pull requests policy
2024-06-05 08:39:45 +02:00
173f618d0b Added graph scrolling using the mouse 2024-06-05 08:35:10 +02:00
12 changed files with 107 additions and 57 deletions

View File

@ -1,4 +1,4 @@
Only localization contributions are accepted at the moment, code pull requests will be rejected. __Only localization contributions are accepted at the moment, code pull requests will be rejected.__
The rationale is, that I want leave the possibility to distribute GPXsee builds in the OS X/Windows The rationale is, that I want leave the possibility to distribute GPXsee builds in the OS X/Windows
stores under a non-GPL licence open. In the future, code pull requests under a stores under a non-GPL licence open. In the future, code pull requests under a

View File

@ -142,6 +142,7 @@ HEADERS += src/common/config.h \
src/map/filter.h \ src/map/filter.h \
src/map/gemfmap.h \ src/map/gemfmap.h \
src/map/gmifile.h \ src/map/gmifile.h \
src/map/metatype.h \
src/map/oruxmap.h \ src/map/oruxmap.h \
src/map/osmdroidmap.h \ src/map/osmdroidmap.h \
src/map/proj/polyconic.h \ src/map/proj/polyconic.h \
@ -474,8 +475,7 @@ SOURCES += src/main.cpp \
src/data/smlparser.cpp \ src/data/smlparser.cpp \
src/data/geojsonparser.cpp src/data/geojsonparser.cpp
DEFINES += APP_VERSION=\\\"$$VERSION\\\" \ DEFINES += APP_VERSION=\\\"$$VERSION\\\"
QT_NO_DEPRECATED_WARNINGS
RESOURCES += gpxsee.qrc RESOURCES += gpxsee.qrc
TRANSLATIONS = lang/gpxsee_en.ts \ TRANSLATIONS = lang/gpxsee_en.ts \

View File

@ -20,12 +20,29 @@
#include "graphicsscene.h" #include "graphicsscene.h"
#include "graphview.h" #include "graphview.h"
#define MARGIN 10.0 #define MARGIN 10.0
#define IW(item) ((item)->boundingRect().width()) #define IW(item) ((item)->boundingRect().width())
#define IH(item) ((item)->boundingRect().height()) #define IH(item) ((item)->boundingRect().height())
static inline QPoint POS(QWheelEvent *e)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
return e->pos();
#else // QT 5.15
return e->position().toPoint();
#endif // QT 5.15
}
static inline QPoint POS(QMouseEvent *e)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return e->pos();
#else // QT 6
return e->position().toPoint();
#endif // QT 6
}
GraphView::GraphView(QWidget *parent) GraphView::GraphView(QWidget *parent)
: QGraphicsView(parent) : QGraphicsView(parent)
{ {
@ -77,6 +94,9 @@ GraphView::GraphView(QWidget *parent)
_xLabel = tr("Distance"); _xLabel = tr("Distance");
_zoom = 1.0; _zoom = 1.0;
_angleDelta = 0;
_dragStart = 0;
} }
GraphView::~GraphView() GraphView::~GraphView()
@ -345,25 +365,33 @@ void GraphView::resizeEvent(QResizeEvent *e)
void GraphView::mousePressEvent(QMouseEvent *e) void GraphView::mousePressEvent(QMouseEvent *e)
{ {
if (e->button() == Qt::LeftButton) if (e->button() == Qt::LeftButton)
newSliderPosition(mapToScene(e->pos())); newSliderPosition(mapToScene(POS(e)));
else if (e->button() == Qt::RightButton)
_dragStart = POS(e).x();
QGraphicsView::mousePressEvent(e); QGraphicsView::mousePressEvent(e);
} }
void GraphView::mouseMoveEvent(QMouseEvent *e)
{
if (e->buttons() & Qt::RightButton) {
QScrollBar *sb = horizontalScrollBar();
int x = POS(e).x();
sb->setSliderPosition(sb->sliderPosition() - (x - _dragStart));
_dragStart = x;
}
QGraphicsView::mouseMoveEvent(e);
}
void GraphView::wheelEvent(QWheelEvent *e) void GraphView::wheelEvent(QWheelEvent *e)
{ {
static int deg8 = 0; _angleDelta += e->angleDelta().y();
if (qAbs(_angleDelta) < (15 * 8))
deg8 += e->angleDelta().y();
if (qAbs(deg8) < (15 * 8))
return; return;
deg8 = deg8 % (15 * 8); _angleDelta = _angleDelta % (15 * 8);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) QPointF pos = mapToScene(POS(e));
QPointF pos = mapToScene(e->pos());
#else // QT 5.15
QPointF pos = mapToScene(e->position().toPoint());
#endif // QT 5.15
QRectF gr(_grid->boundingRect()); QRectF gr(_grid->boundingRect());
QPointF r(pos.x() / gr.width(), pos.y() / gr.height()); QPointF r(pos.x() / gr.width(), pos.y() / gr.height());
@ -374,11 +402,7 @@ void GraphView::wheelEvent(QWheelEvent *e)
QPointF npos(mapFromScene(QPointF(r.x() * ngr.width(), QPointF npos(mapFromScene(QPointF(r.x() * ngr.width(),
r.y() * ngr.height()))); r.y() * ngr.height())));
QScrollBar *sb = horizontalScrollBar(); QScrollBar *sb = horizontalScrollBar();
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) sb->setSliderPosition(sb->sliderPosition() + npos.x() - POS(e).x());
sb->setSliderPosition(sb->sliderPosition() + npos.x() - e->pos().x());
#else // QT 5.15
sb->setSliderPosition(sb->sliderPosition() + npos.x() - e->position().x());
#endif // QT 5.15
QGraphicsView::wheelEvent(e); QGraphicsView::wheelEvent(e);
} }

View File

@ -58,6 +58,7 @@ protected:
void resizeEvent(QResizeEvent *e); void resizeEvent(QResizeEvent *e);
void mousePressEvent(QMouseEvent *e); void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void wheelEvent(QWheelEvent *e); void wheelEvent(QWheelEvent *e);
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
void paintEvent(QPaintEvent *e); void paintEvent(QPaintEvent *e);
@ -122,6 +123,9 @@ private:
qreal _minYRange; qreal _minYRange;
qreal _zoom; qreal _zoom;
int _angleDelta;
int _dragStart;
}; };
#endif // GRAPHVIEW_H #endif // GRAPHVIEW_H

View File

@ -20,16 +20,16 @@
#define OPEN_SHORTCUT QKeySequence(QKeySequence::Open) #define OPEN_SHORTCUT QKeySequence(QKeySequence::Open)
#define CLOSE_SHORTCUT QKeySequence(QKeySequence::Close) #define CLOSE_SHORTCUT QKeySequence(QKeySequence::Close)
#define RELOAD_SHORTCUT QKeySequence(QKeySequence::Refresh) #define RELOAD_SHORTCUT QKeySequence(QKeySequence::Refresh)
#define PDF_EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_E) #define PDF_EXPORT_SHORTCUT QKeySequence(Qt::CTRL | Qt::Key_E)
#define PNG_EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_X) #define PNG_EXPORT_SHORTCUT QKeySequence(Qt::CTRL | Qt::Key_X)
#define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P) #define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL | Qt::Key_P)
#define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M) #define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL | Qt::Key_M)
#define NEXT_MAP_SHORTCUT QKeySequence(QKeySequence::Forward) #define NEXT_MAP_SHORTCUT QKeySequence(QKeySequence::Forward)
#define PREV_MAP_SHORTCUT QKeySequence(QKeySequence::Back) #define PREV_MAP_SHORTCUT QKeySequence(QKeySequence::Back)
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G) #define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL | Qt::Key_G)
#define STATISTICS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_S) #define STATISTICS_SHORTCUT QKeySequence(Qt::CTRL | Qt::Key_S)
#define DOWNLOAD_DEM_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_D) #define DOWNLOAD_DEM_SHORTCUT QKeySequence(Qt::CTRL | Qt::Key_D)
#define SHOW_TRACKS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_T) #define SHOW_TRACKS_SHORTCUT QKeySequence(Qt::CTRL | Qt::Key_T)
#define FULLSCREEN_SHORTCUT (QKeySequence(QKeySequence::FullScreen).isEmpty() \ #define FULLSCREEN_SHORTCUT (QKeySequence(QKeySequence::FullScreen).isEmpty() \
? QKeySequence(Qt::Key_F11) \ ? QKeySequence(Qt::Key_F11) \
: QKeySequence(QKeySequence::FullScreen)) : QKeySequence(QKeySequence::FullScreen))

View File

@ -17,6 +17,14 @@
#include "flowlayout.h" #include "flowlayout.h"
#include "popup.h" #include "popup.h"
static inline QPointF mousePos(QEvent *ev)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return static_cast<QMouseEvent*>(ev)->globalPos();
#else // QT 6
return static_cast<QMouseEvent*>(ev)->globalPosition();
#endif // QT 6
}
class PopupFrame : public QFrame class PopupFrame : public QFrame
{ {
@ -163,8 +171,7 @@ bool PopupFrame::eventFilter(QObject *o, QEvent *ev)
break; break;
case QEvent::MouseMove: { case QEvent::MouseMove: {
QRectF r(geometry().adjusted(-5, -20, 5, 20)); QRectF r(geometry().adjusted(-5, -20, 5, 20));
QPointF p(static_cast<QMouseEvent*>(ev)->globalPos()); if (!r.contains(mousePos(ev)))
if (!r.contains(p))
deleteAfterTimer(); deleteAfterTimer();
break; break;
} }

View File

@ -7,10 +7,10 @@
#include <QtConcurrent> #include <QtConcurrent>
#include "common/util.h" #include "common/util.h"
#include "osm.h" #include "osm.h"
#include "metatype.h"
#include "mbtilesmap.h" #include "mbtilesmap.h"
#define MAX_TILE_SIZE 4096 #define MAX_TILE_SIZE 4096
#define META_TYPE(type) static_cast<QMetaType::Type>(type)
static RectC str2bounds(const QString &str) static RectC str2bounds(const QString &str)
{ {
@ -201,13 +201,13 @@ MBTilesMap::MBTilesMap(const QString &fileName, QObject *parent)
QSqlRecord r = _db.record("tiles"); QSqlRecord r = _db.record("tiles");
if (r.isEmpty() if (r.isEmpty()
|| r.field(0).name() != "zoom_level" || r.field(0).name() != "zoom_level"
|| META_TYPE(r.field(0).type()) != QMetaType::Int || METATYPE(r.field(0)) != QMetaType::Int
|| r.field(1).name() != "tile_column" || r.field(1).name() != "tile_column"
|| META_TYPE(r.field(1).type()) != QMetaType::Int || METATYPE(r.field(1)) != QMetaType::Int
|| r.field(2).name() != "tile_row" || r.field(2).name() != "tile_row"
|| META_TYPE(r.field(2).type()) != QMetaType::Int || METATYPE(r.field(2)) != QMetaType::Int
|| r.field(3).name() != "tile_data" || r.field(3).name() != "tile_data"
|| META_TYPE(r.field(3).type()) != QMetaType::QByteArray) { || METATYPE(r.field(3)) != QMetaType::QByteArray) {
_errorString = "Invalid table format"; _errorString = "Invalid table format";
return; return;
} }

15
src/map/metatype.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef METATYPE_H
#define METATYPE_H
#include <QSqlField>
static inline QMetaType::Type METATYPE(const QSqlField &f)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return static_cast<QMetaType::Type>(f.type());
#else // QT 6
return static_cast<QMetaType::Type>(f.metaType().id());
#endif // QT 6
}
#endif // METATYPE_H

View File

@ -9,11 +9,10 @@
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include "pcs.h" #include "pcs.h"
#include "utm.h" #include "utm.h"
#include "metatype.h"
#include "oruxmap.h" #include "oruxmap.h"
#define META_TYPE(type) static_cast<QMetaType::Type>(type)
static bool intAttr(QXmlStreamReader &reader, const QXmlStreamAttributes &attr, static bool intAttr(QXmlStreamReader &reader, const QXmlStreamAttributes &attr,
const QString &name, int &val) const QString &name, int &val)
{ {
@ -431,14 +430,11 @@ OruxMap::OruxMap(const QString &fileName, QObject *parent)
QSqlRecord r = _db.record("tiles"); QSqlRecord r = _db.record("tiles");
if (r.isEmpty() if (r.isEmpty()
|| r.field(0).name() != "x" || r.field(0).name() != "x" || METATYPE(r.field(0)) != QMetaType::Int
|| META_TYPE(r.field(0).type()) != QMetaType::Int || r.field(1).name() != "y" || METATYPE(r.field(1)) != QMetaType::Int
|| r.field(1).name() != "y" || r.field(2).name() != "z" || METATYPE(r.field(2)) != QMetaType::Int
|| META_TYPE(r.field(1).type()) != QMetaType::Int
|| r.field(2).name() != "z"
|| META_TYPE(r.field(2).type()) != QMetaType::Int
|| r.field(3).name() != "image" || r.field(3).name() != "image"
|| META_TYPE(r.field(3).type()) != QMetaType::QByteArray) { || METATYPE(r.field(3)) != QMetaType::QByteArray) {
_errorString = "Invalid table format"; _errorString = "Invalid table format";
return; return;
} }

View File

@ -9,11 +9,10 @@
#include <QtConcurrent> #include <QtConcurrent>
#include "osm.h" #include "osm.h"
#include "tile.h" #include "tile.h"
#include "metatype.h"
#include "osmdroidmap.h" #include "osmdroidmap.h"
#define META_TYPE(type) static_cast<QMetaType::Type>(type)
OsmdroidMap::OsmdroidMap(const QString &fileName, QObject *parent) OsmdroidMap::OsmdroidMap(const QString &fileName, QObject *parent)
: Map(fileName, parent), _mapRatio(1.0), _valid(false) : Map(fileName, parent), _mapRatio(1.0), _valid(false)
{ {
@ -34,11 +33,11 @@ OsmdroidMap::OsmdroidMap(const QString &fileName, QObject *parent)
QSqlRecord rcrd = _db.record("tiles"); QSqlRecord rcrd = _db.record("tiles");
if (rcrd.isEmpty() if (rcrd.isEmpty()
|| rcrd.field(0).name() != "key" || rcrd.field(0).name() != "key"
|| META_TYPE(rcrd.field(0).type()) != QMetaType::Int || METATYPE(rcrd.field(0)) != QMetaType::Int
|| rcrd.field(1).name() != "provider" || rcrd.field(1).name() != "provider"
|| META_TYPE(rcrd.field(1).type()) != QMetaType::QString || METATYPE(rcrd.field(1)) != QMetaType::QString
|| rcrd.field(2).name() != "tile" || rcrd.field(2).name() != "tile"
|| META_TYPE(rcrd.field(2).type()) != QMetaType::QByteArray) { || METATYPE(rcrd.field(2)) != QMetaType::QByteArray) {
_errorString = "Invalid table format"; _errorString = "Invalid table format";
return; return;
} }

View File

@ -9,11 +9,10 @@
#include <QtConcurrent> #include <QtConcurrent>
#include "osm.h" #include "osm.h"
#include "tile.h" #include "tile.h"
#include "metatype.h"
#include "sqlitemap.h" #include "sqlitemap.h"
#define META_TYPE(type) static_cast<QMetaType::Type>(type)
SqliteMap::SqliteMap(const QString &fileName, QObject *parent) SqliteMap::SqliteMap(const QString &fileName, QObject *parent)
: Map(fileName, parent), _mapRatio(1.0), _valid(false) : Map(fileName, parent), _mapRatio(1.0), _valid(false)
{ {
@ -32,13 +31,13 @@ SqliteMap::SqliteMap(const QString &fileName, QObject *parent)
QSqlRecord r = _db.record("tiles"); QSqlRecord r = _db.record("tiles");
if (r.isEmpty() if (r.isEmpty()
|| r.field(0).name() != "x" || r.field(0).name() != "x"
|| META_TYPE(r.field(0).type()) != QMetaType::Int || METATYPE(r.field(0)) != QMetaType::Int
|| r.field(1).name() != "y" || r.field(1).name() != "y"
|| META_TYPE(r.field(1).type()) != QMetaType::Int || METATYPE(r.field(1)) != QMetaType::Int
|| r.field(2).name() != "z" || r.field(2).name() != "z"
|| META_TYPE(r.field(2).type()) != QMetaType::Int || METATYPE(r.field(2)) != QMetaType::Int
|| r.field(4).name() != "image" || r.field(4).name() != "image"
|| META_TYPE(r.field(4).type()) != QMetaType::QByteArray) { || METATYPE(r.field(4)) != QMetaType::QByteArray) {
_errorString = "Invalid table format"; _errorString = "Invalid table format";
return; return;
} }

View File

@ -4,9 +4,15 @@
#include "tileloader.h" #include "tileloader.h"
#define SUBSTITUTE_CHAR '$' #define SUBSTITUTE_CHAR '$'
#define IS_INT(zoom) \
((QMetaType::Type)((zoom).type()) == QMetaType::Int)
static bool inline IS_INT(const QVariant &v)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return (static_cast<QMetaType::Type>(v.type()) == QMetaType::Int);
#else // QT 6
return (static_cast<QMetaType::Type>((v.typeId()) == QMetaType::Int));
#endif // QT 6
}
static QString fsSafeStr(const QString &str) static QString fsSafeStr(const QString &str)
{ {