1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-30 10:24:24 +02:00

Compare commits

..

10 Commits

Author SHA1 Message Date
3e6ad20c05 Code cleanup 2024-06-06 18:51:24 +02:00
98704ef44b Handle some more stuff obsolete in Qt6 2024-06-06 01:10:43 +02:00
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
69951fe248 Fixed error handling 2024-06-04 23:25:30 +02:00
74cf139b01 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (479 of 479 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/zh_Hans/
2024-05-31 19:50:23 +02:00
d2dd916d1b Translated using Weblate (Norwegian Bokmål)
Currently translated at 99.5% (477 of 479 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/nb_NO/
2024-05-31 19:50:23 +02:00
849fbac5ba Translated using Weblate (Hungarian)
Currently translated at 100.0% (479 of 479 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/hu/
2024-05-31 19:50:23 +02:00
5fb1feaf88 Version++ 2024-05-31 19:49:49 +02:00
24 changed files with 211 additions and 159 deletions

View File

@ -1,4 +1,4 @@
version: 13.21.{build}
version: 13.22.{build}
configuration:
- Release

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

@ -3,7 +3,7 @@ unix:!macx:!android {
} else {
TARGET = GPXSee
}
VERSION = 13.21
VERSION = 13.22
QT += core \
@ -128,9 +128,9 @@ HEADERS += src/common/config.h \
src/map/ENC/objects.h \
src/map/ENC/rastertile.h \
src/map/ENC/style.h \
src/map/IMG/dem.h \
src/map/IMG/demfile.h \
src/map/IMG/demtile.h \
src/map/IMG/demtree.h \
src/map/IMG/jls.h \
src/map/IMG/section.h \
src/map/IMG/zoom.h \
@ -142,6 +142,7 @@ 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 \
@ -350,8 +351,8 @@ SOURCES += src/main.cpp \
src/map/ENC/mapdata.cpp \
src/map/ENC/rastertile.cpp \
src/map/ENC/style.cpp \
src/map/IMG/dem.cpp \
src/map/IMG/demfile.cpp \
src/map/IMG/demtree.cpp \
src/map/IMG/jls.cpp \
src/map/conversion.cpp \
src/map/encatlas.cpp \
@ -474,8 +475,7 @@ SOURCES += src/main.cpp \
src/data/smlparser.cpp \
src/data/geojsonparser.cpp
DEFINES += APP_VERSION=\\\"$$VERSION\\\" \
QT_NO_DEPRECATED_WARNINGS
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
RESOURCES += gpxsee.qrc
TRANSLATIONS = lang/gpxsee_en.ts \

View File

@ -1749,7 +1749,7 @@
<location filename="../src/GUI/optionsdialog.cpp" line="265"/>
<location filename="../src/GUI/optionsdialog.cpp" line="626"/>
<source>px</source>
<translation type="unfinished">pont</translation>
<translation>pont</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="301"/>

View File

@ -1835,27 +1835,27 @@
<location filename="../src/GUI/optionsdialog.cpp" line="306"/>
<location filename="../src/GUI/optionsdialog.cpp" line="642"/>
<source>Opacity:</source>
<translation type="unfinished"></translation>
<translation>Ugjennomsiktighet:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="643"/>
<source>Blur radius:</source>
<translation type="unfinished"></translation>
<translation>Sløreradius:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="645"/>
<source>Azimuth:</source>
<translation type="unfinished"></translation>
<translation>Asimut:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="646"/>
<source>Altitude:</source>
<translation type="unfinished"></translation>
<translation>Høyde:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="647"/>
<source>Z Factor:</source>
<translation type="unfinished"></translation>
<translation>Z-faktor:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="652"/>
@ -1866,7 +1866,7 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="653"/>
<source>Hillshading</source>
<translation type="unfinished"></translation>
<translation>Relieffskygge</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="673"/>

View File

@ -790,7 +790,7 @@
<location filename="../src/GUI/gui.cpp" line="883"/>
<location filename="../src/GUI/gui.cpp" line="892"/>
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at %1.</source>
<translation>GPXSee GNU 3GPXSee 访 %1 </translation>
<translation>GPXSee GNU v3.0 GPXSee 访 %1 </translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="915"/>
@ -1396,12 +1396,12 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="83"/>
<source>Non-HiDPI maps are loaded as HiDPI maps. The map is sharp but map objects are small/hard to read.</source>
<translation>HiDPI地图将作为HiDPI地图加载/</translation>
<translation>HiDPI地图将作为HiDPI地图加载</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="85"/>
<source>Non-HiDPI maps are loaded such as they are. Map objects have the expected size but the map is blurry.</source>
<translation>HiDPI地图按原样加载</translation>
<translation>HiDPI地图按原样加载</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="95"/>
@ -1442,7 +1442,7 @@
<location filename="../src/GUI/optionsdialog.cpp" line="265"/>
<location filename="../src/GUI/optionsdialog.cpp" line="626"/>
<source>px</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="163"/>
@ -1598,7 +1598,7 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="308"/>
<source>Info color:</source>
<translation>:</translation>
<translation></translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="318"/>
@ -1840,27 +1840,27 @@
<location filename="../src/GUI/optionsdialog.cpp" line="306"/>
<location filename="../src/GUI/optionsdialog.cpp" line="642"/>
<source>Opacity:</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="643"/>
<source>Blur radius:</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="645"/>
<source>Azimuth:</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="646"/>
<source>Altitude:</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="647"/>
<source>Z Factor:</source>
<translation type="unfinished"></translation>
<translation>Z </translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="652"/>
@ -1871,7 +1871,7 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="653"/>
<source>Hillshading</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="673"/>

View File

@ -37,7 +37,7 @@ Unicode true
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "13.21"
!define VERSION "13.22"
; The file to write
OutFile "GPXSee-${VERSION}_x64.exe"

View File

@ -43,8 +43,13 @@ App::App(int &argc, char **argv) : QApplication(argc, argv)
#if defined(Q_OS_WIN32) || defined(Q_OS_MAC)
if (qt->load(QLocale::system(), "qt", "_", ProgramPaths::translationsDir()))
#else // Q_OS_WIN32 || Q_OS_MAC
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (qt->load(QLocale::system(), "qt", "_", QLibraryInfo::location(
QLibraryInfo::TranslationsPath)))
#else // QT 6
if (qt->load(QLocale::system(), "qt", "_", QLibraryInfo::path(
QLibraryInfo::TranslationsPath)))
#endif // QT 6
#endif // Q_OS_WIN32 || Q_OS_MAC
installTranslator(qt);

View File

@ -20,12 +20,29 @@
#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)
{
@ -77,6 +94,9 @@ GraphView::GraphView(QWidget *parent)
_xLabel = tr("Distance");
_zoom = 1.0;
_angleDelta = 0;
_dragStart = 0;
}
GraphView::~GraphView()
@ -345,25 +365,33 @@ void GraphView::resizeEvent(QResizeEvent *e)
void GraphView::mousePressEvent(QMouseEvent *e)
{
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);
}
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)
{
static int deg8 = 0;
deg8 += e->angleDelta().y();
if (qAbs(deg8) < (15 * 8))
_angleDelta += e->angleDelta().y();
if (qAbs(_angleDelta) < (15 * 8))
return;
deg8 = deg8 % (15 * 8);
_angleDelta = _angleDelta % (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
QPointF pos = mapToScene(POS(e));
QRectF gr(_grid->boundingRect());
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(),
r.y() * ngr.height())));
QScrollBar *sb = horizontalScrollBar();
#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
sb->setSliderPosition(sb->sliderPosition() + npos.x() - POS(e).x());
QGraphicsView::wheelEvent(e);
}

View File

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

View File

@ -1,44 +0,0 @@
#ifndef IMG_DEM_H
#define IMG_DEM_H
#include "common/rtree.h"
#include "mapdata.h"
namespace IMG {
class DEM {
public:
typedef RTree<const MapData::Elevation*, double, 2> DEMTRee;
static void buildTree(const QList<MapData::Elevation> &tiles, DEMTRee &tree);
static void searchTree(const DEMTRee &tree, const Coordinates &c,
double &ele);
private:
struct ElevationCTX {
ElevationCTX(const DEMTRee &tree, const Coordinates &c, double &ele)
: tree(tree), c(c), ele(ele) {}
const DEMTRee &tree;
const Coordinates &c;
double &ele;
};
struct EdgeCTX {
EdgeCTX(const Coordinates &c, double &ele) : c(c), ele(ele) {}
const Coordinates &c;
double &ele;
};
static double edge(const DEMTRee &tree, const Coordinates &c);
static double elevation(const DEMTRee &tree, const MapData::Elevation *e,
const Coordinates &c);
static bool elevationCb(const MapData::Elevation *e, void *context);
static bool edgeCb(const MapData::Elevation *e, void *context);
};
}
#endif // IMG_DEM_H

View File

@ -1,4 +1,4 @@
#include "dem.h"
#include "demtree.h"
using namespace IMG;
@ -17,7 +17,15 @@ static double val(const Matrix<qint16> &m, int row, int col)
return (v == -32768) ? NAN : (double)v;
}
bool DEM::edgeCb(const MapData::Elevation *e, void *context)
bool DEMTree::elevationCb(const MapData::Elevation *e, void *context)
{
ElevationCTX *ctx = (ElevationCTX*)context;
ctx->ele = elevation(ctx->tree, e, ctx->c);
return std::isnan(ctx->ele);
}
bool DEMTree::edgeCb(const MapData::Elevation *e, void *context)
{
EdgeCTX *ctx = (EdgeCTX*)context;
@ -31,10 +39,10 @@ bool DEM::edgeCb(const MapData::Elevation *e, void *context)
return std::isnan(ctx->ele);
}
double DEM::edge(const DEMTRee &tree, const Coordinates &c)
double DEMTree::edge(const Tree &tree, const Coordinates &c)
{
double min[2], max[2];
double ele = NAN;
double min[2], max[2];
EdgeCTX ctx(c, ele);
min[0] = c.lon();
@ -47,7 +55,7 @@ double DEM::edge(const DEMTRee &tree, const Coordinates &c)
return ele;
}
double DEM::elevation(const DEMTRee &tree, const MapData::Elevation *e,
double DEMTree::elevation(const Tree &tree, const MapData::Elevation *e,
const Coordinates &c)
{
double x = (c.lon() - e->rect.left()) / e->xr;
@ -72,7 +80,7 @@ double DEM::elevation(const DEMTRee &tree, const MapData::Elevation *e,
return interpolate(x - col, y - row, p0, p1, p2, p3);
}
void DEM::buildTree(const QList<MapData::Elevation> &tiles, DEMTRee &tree)
DEMTree::DEMTree(const QList<MapData::Elevation> &tiles)
{
double min[2], max[2];
@ -84,29 +92,22 @@ void DEM::buildTree(const QList<MapData::Elevation> &tiles, DEMTRee &tree)
max[0] = e.rect.right();
max[1] = e.rect.top();
tree.Insert(min, max, &e);
_tree.Insert(min, max, &e);
}
}
bool DEM::elevationCb(const MapData::Elevation *e, void *context)
{
ElevationCTX *ctx = (ElevationCTX*)context;
ctx->ele = elevation(ctx->tree, e, ctx->c);
return std::isnan(ctx->ele);
}
void DEM::searchTree(const DEMTRee &tree, const Coordinates &c,
double &ele)
double DEMTree::elevation(const Coordinates &c) const
{
double ele = NAN;
double min[2], max[2];
ElevationCTX ctx(tree, c, ele);
ElevationCTX ctx(_tree, c, ele);
min[0] = c.lon();
min[1] = c.lat();
max[0] = c.lon();
max[1] = c.lat();
ele = NAN;
tree.Search(min, max, elevationCb, &ctx);
_tree.Search(min, max, elevationCb, &ctx);
return ele;
}

45
src/map/IMG/demtree.h Normal file
View File

@ -0,0 +1,45 @@
#ifndef IMG_DEMTREE_H
#define IMG_DEMTREE_H
#include "common/rtree.h"
#include "mapdata.h"
namespace IMG {
class DEMTree {
public:
DEMTree(const QList<MapData::Elevation> &tiles);
double elevation(const Coordinates &c) const;
private:
typedef RTree<const MapData::Elevation*, double, 2> Tree;
struct ElevationCTX {
ElevationCTX(const Tree &tree, const Coordinates &c, double &ele)
: tree(tree), c(c), ele(ele) {}
const Tree &tree;
const Coordinates &c;
double &ele;
};
struct EdgeCTX {
EdgeCTX(const Coordinates &c, double &ele) : c(c), ele(ele) {}
const Coordinates &c;
double &ele;
};
static double edge(const Tree &tree, const Coordinates &c);
static double elevation(const Tree &tree, const MapData::Elevation *e,
const Coordinates &c);
static bool elevationCb(const MapData::Elevation *e, void *context);
static bool edgeCb(const MapData::Elevation *e, void *context);
Tree _tree;
};
}
#endif // IMG_DEMTREE_H

View File

@ -53,7 +53,7 @@ bool JLS::processRunMode(BitStream &bs, quint16 col, quint16 &samples)
if (cnt >= col) {
if (!bs.read(i + 1))
return 3;
return false;
samples = col;
return true;

View File

@ -10,7 +10,7 @@
#include "map/filter.h"
#include "style.h"
#include "lblfile.h"
#include "dem.h"
#include "demtree.h"
#include "rastertile.h"
using namespace IMG;
@ -470,7 +470,6 @@ MatrixD RasterTile::elevation(int extend) const
if (_data->hasDEM()) {
RectC rect;
QList<MapData::Elevation> tiles;
DEMTRee tree;
for (int i = 0; i < ll.size(); i++)
rect = rect.united(ll.at(i));
@ -480,14 +479,14 @@ MatrixD RasterTile::elevation(int extend) const
_data->elevations(rect.adjusted(0, 0, rect.width() / factor,
-rect.height() / factor), _zoom, &tiles);
DEM::buildTree(tiles, tree);
DEMTree tree(tiles);
for (int i = 0; i < ll.size(); i++)
DEM::searchTree(tree, ll.at(i), m.at(i));
m.at(i) = tree.elevation(ll.at(i));
} else {
::DEM::lock();
DEM::lock();
for (int i = 0; i < ll.size(); i++)
m.at(i) = ::DEM::elevation(ll.at(i));
::DEM::unlock();
m.at(i) = DEM::elevation(ll.at(i));
DEM::unlock();
}
return m;

View File

@ -8,7 +8,7 @@
#include "IMG/imgdata.h"
#include "IMG/gmapdata.h"
#include "IMG/rastertile.h"
#include "IMG/dem.h"
#include "IMG/demtree.h"
#include "osm.h"
#include "pcs.h"
#include "rectd.h"
@ -273,16 +273,12 @@ double IMGMap::elevation(const Coordinates &c)
if (d->hasDEM()) {
QList<MapData::Elevation> tiles;
DEM::DEMTRee tree;
double ele = NAN;
d->elevations(RectC(Coordinates(c), Coordinates(c)), d->zooms().max(),
&tiles);
DEMTree tree(tiles);
DEM::buildTree(tiles, tree);
DEM::searchTree(tree, c, ele);
return ele;
return tree.elevation(c);
} else
return Map::elevation(c);
}

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"
|| META_TYPE(r.field(0).type()) != QMetaType::Int
|| METATYPE(r.field(0)) != QMetaType::Int
|| 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"
|| META_TYPE(r.field(2).type()) != QMetaType::Int
|| METATYPE(r.field(2)) != QMetaType::Int
|| r.field(3).name() != "tile_data"
|| META_TYPE(r.field(3).type()) != QMetaType::QByteArray) {
|| METATYPE(r.field(3)) != QMetaType::QByteArray) {
_errorString = "Invalid table format";
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 "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)
{
@ -431,14 +430,11 @@ OruxMap::OruxMap(const QString &fileName, QObject *parent)
QSqlRecord r = _db.record("tiles");
if (r.isEmpty()
|| 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(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(3).name() != "image"
|| META_TYPE(r.field(3).type()) != QMetaType::QByteArray) {
|| METATYPE(r.field(3)) != QMetaType::QByteArray) {
_errorString = "Invalid table format";
return;
}

View File

@ -9,11 +9,10 @@
#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)
{
@ -34,11 +33,11 @@ OsmdroidMap::OsmdroidMap(const QString &fileName, QObject *parent)
QSqlRecord rcrd = _db.record("tiles");
if (rcrd.isEmpty()
|| rcrd.field(0).name() != "key"
|| META_TYPE(rcrd.field(0).type()) != QMetaType::Int
|| METATYPE(rcrd.field(0)) != QMetaType::Int
|| rcrd.field(1).name() != "provider"
|| META_TYPE(rcrd.field(1).type()) != QMetaType::QString
|| METATYPE(rcrd.field(1)) != QMetaType::QString
|| rcrd.field(2).name() != "tile"
|| META_TYPE(rcrd.field(2).type()) != QMetaType::QByteArray) {
|| METATYPE(rcrd.field(2)) != QMetaType::QByteArray) {
_errorString = "Invalid table format";
return;
}

View File

@ -9,11 +9,10 @@
#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)
{
@ -32,13 +31,13 @@ SqliteMap::SqliteMap(const QString &fileName, QObject *parent)
QSqlRecord r = _db.record("tiles");
if (r.isEmpty()
|| r.field(0).name() != "x"
|| META_TYPE(r.field(0).type()) != QMetaType::Int
|| METATYPE(r.field(0)) != QMetaType::Int
|| r.field(1).name() != "y"
|| META_TYPE(r.field(1).type()) != QMetaType::Int
|| METATYPE(r.field(1)) != QMetaType::Int
|| r.field(2).name() != "z"
|| META_TYPE(r.field(2).type()) != QMetaType::Int
|| METATYPE(r.field(2)) != QMetaType::Int
|| r.field(4).name() != "image"
|| META_TYPE(r.field(4).type()) != QMetaType::QByteArray) {
|| METATYPE(r.field(4)) != QMetaType::QByteArray) {
_errorString = "Invalid table format";
return;
}

View File

@ -4,9 +4,15 @@
#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)
{