1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-02-17 16:20:48 +01:00

Compare commits

..

No commits in common. "d750715bed060ae1346016933c39b92090f6429a" and "69951fe2488eabc405648971a55bf17ed9b6e88c" have entirely different histories.

12 changed files with 58 additions and 108 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
stores under a non-GPL licence open. In the future, code pull requests under a

View File

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

View File

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

View File

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

View File

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

View File

@ -17,14 +17,6 @@
#include "flowlayout.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
{
@ -171,7 +163,8 @@ bool PopupFrame::eventFilter(QObject *o, QEvent *ev)
break;
case QEvent::MouseMove: {
QRectF r(geometry().adjusted(-5, -20, 5, 20));
if (!r.contains(mousePos(ev)))
QPointF p(static_cast<QMouseEvent*>(ev)->globalPos());
if (!r.contains(p))
deleteAfterTimer();
break;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -4,15 +4,9 @@
#include "tileloader.h"
#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)
{