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

Compare commits

..

38 Commits

Author SHA1 Message Date
436cf0d14c Qt5 compatability module is not needed anymore 2024-01-21 18:44:42 +01:00
0e83bd89d1 Use Qt 6.6.1 for the Mac OS Qt6 CI build 2024-01-21 18:26:11 +01:00
536d12469a Use the canonical file name also for the "already open" check 2024-01-21 17:50:56 +01:00
c9f44506e7 Fixed minimal Windows version check for Qt6 builds 2024-01-21 16:04:59 +01:00
bc4bffdfe7 Fixed NSIS command line parameters 2024-01-21 12:26:04 +01:00
eda35b6762 Made the Windows installer more modular
Enable separately selecting the Qt6, OpenSSL or ANGLE options.
Added ICU option for Qt builds with ICU enabled/required.
2024-01-21 12:01:27 +01:00
b05e7b15fe Use ISO-8859-1 as the fallback encoding rather than UTF-8 2024-01-19 09:56:56 +01:00
ed2fc0c627 Fixed missing sdkmanager in path 2024-01-18 22:39:56 +01:00
60f58592b2 Try to use older cmdline-tools 2024-01-18 22:37:08 +01:00
80abb6f604 Trying to fix the android CI build... 2024-01-18 22:27:57 +01:00
19c4aa1c34 Try another Java 11 version instead of the now broken azul build 2024-01-18 22:15:48 +01:00
578045108f Removed now unused Qt5 compatability module 2024-01-18 22:13:54 +01:00
796c2e7eaf Removed unused header include 2024-01-18 22:13:05 +01:00
c08d3b7159 Fixed indent 2024-01-18 22:12:23 +01:00
7f7de87e99 Drop Qt5Compat dependency
Use QStringConverter instead of QTextCodec on Qt > 6.5.
Qt6 builds now require Qt build with ICU support for the non-UTF encodings to
work!
2024-01-18 10:04:38 +01:00
9cacf1906e Do not duplicate the same paths in the "open recent" menu 2024-01-18 09:53:50 +01:00
cedca8725b Supress windows build warnings 2024-01-18 09:52:22 +01:00
c493f8cf16 Make the popup layout more resistant to broken HTML content 2024-01-17 08:57:08 +01:00
866b2c27ca Consistently initialize all stuff in constructor 2024-01-05 00:20:05 +01:00
07614a8f74 Added missing header includes 2024-01-04 18:53:43 +01:00
bc7d965a49 Version++ 2024-01-02 22:05:56 +01:00
e383a35c65 Year++ in copyright notices 2024-01-02 22:04:30 +01:00
6b4990a204 Fixed error handling 2024-01-02 19:11:04 +01:00
7a7a331b58 The codec is always set when reading the GPI header 2024-01-02 09:48:13 +01:00
a1e10c395a Some more code cleanup 2024-01-01 13:02:42 +01:00
c97561add4 Code cleanup 2024-01-01 10:58:23 +01:00
d994fae4ce Fixed the change that has broken non-TAR maps
Do not fail on the first image read error - there may be files with a "_%u_%u."
file name match that are not image tiles.
2024-01-01 10:48:16 +01:00
789606cf86 Silenced some more clazy warnings 2023-12-31 13:57:43 +01:00
542b3e920e Fixed read error check 2023-12-31 13:24:36 +01:00
0248ecb254 Improved tile file check 2023-12-31 13:20:04 +01:00
acc9d07a22 Properly associate .gmi files 2023-12-31 10:48:26 +01:00
7860ce8acc Use the info we already have for calibration file type distinction 2023-12-31 10:05:02 +01:00
2541797e7d Improved error reporting 2023-12-31 01:12:46 +01:00
e13d6dfc4b Fixed broken image dimensions checks 2023-12-29 18:01:28 +01:00
9e1e960c93 Use a file name that allows QFileInfo::completeSuffix() to match 2023-12-27 22:41:56 +01:00
d18537733f Added mtbmap.cz as replacement for 4Umaps
While having a much lower topographic quality than 4Umaps, there is apparently
no other freely accessible map with the same MTB/hiking info out there. So let's
provide at least what we have...
2023-12-27 22:17:35 +01:00
c6a37594ae Code cleanup 2023-12-27 15:26:39 +01:00
bcfd51276f Use QNetworkRequest::setTransferTimeout where available 2023-12-27 15:12:53 +01:00
45 changed files with 364 additions and 174 deletions

View File

@ -1,4 +1,4 @@
version: 13.14.{build}
version: 13.15.{build}
configuration:
- Release
@ -11,11 +11,10 @@ environment:
matrix:
- QTDIR: C:\Qt\5.15\msvc2019_64
OPENSSLDIR: C:\OpenSSL-v111-Win64\bin
OPENSSLVERSION: 1_1
NSISDEF: /DOPENSSL /DANGLE
- QTDIR: C:\Qt\6.5\msvc2019_64
OPENSSLDIR: C:\OpenSSL-v30-Win64\bin
OPENSSLVERSION: 3
NSISDEF: /DQT6
NSISDEF: /DQT6 /DOPENSSL
install:
- cmd: |-
@ -37,8 +36,8 @@ build_script:
xcopy lang\*.qm installer\translations\ /sy
xcopy icons\symbols installer\symbols /i
copy licence.txt installer
copy %OPENSSLDIR%\libcrypto-%OPENSSLVERSION%-x64.dll installer
copy %OPENSSLDIR%\libssl-%OPENSSLVERSION%-x64.dll installer
copy %OPENSSLDIR%\libcrypto-*-x64.dll installer
copy %OPENSSLDIR%\libssl-*-x64.dll installer
makensis.exe %NSISDEF% installer\gpxsee64.nsi

View File

@ -15,14 +15,14 @@ jobs:
- name: set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
distribution: 'temurin'
java-version: '11'
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Run sdkmanager update
run: ${ANDROID_HOME}/tools/bin/sdkmanager --update
- name: Install android platform, platform-tools, build-tools and ndk
run: ${ANDROID_HOME}/tools/bin/sdkmanager --install "cmdline-tools;latest" "platform-tools" "platforms;android-33" "build-tools;33.0.0" "ndk;23.1.7779620"
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: 9862592
- name: Install android platform, build-tools and ndk
run: ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-33" "build-tools;33.0.0" "ndk;23.1.7779620"
- name: Setup NDK path
run: echo "ANDROID_NDK_ROOT=${ANDROID_HOME}/ndk/23.1.7779620/" >> $GITHUB_ENV
- name: Install Qt (Desktop)

View File

@ -39,8 +39,8 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: '6.5.1'
modules: qtpositioning qt5compat qtserialport
version: '6.6.1'
modules: qtpositioning qtserialport
- name: Create localization
run: lrelease gpxsee.pro
- name: Configure build

6
data/maps/mtbmap-cz.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<map xmlns="http://www.gpxsee.org/map/1.4">
<name>mtbmap.cz</name>
<url>https://tile.mtbmap.cz/mtbmap_tiles/$z/$x/$y.png</url>
<copyright>Map data: OpenStreetMap, USGS | Rendering: Martin Tesař</copyright>
</map>

View File

@ -3,7 +3,7 @@ unix:!macx:!android {
} else {
TARGET = GPXSee
}
VERSION = 13.14
VERSION = 13.15
QT += core \
@ -18,8 +18,10 @@ QT += core \
svg \
serialport
greaterThan(QT_MAJOR_VERSION, 5) {
QT += openglwidgets \
core5compat
QT += openglwidgets
lessThan(QT_MINOR_VERSION, 5) {
QT += core5compat
}
}
CONFIG += object_parallel_to_source
@ -510,10 +512,11 @@ macx {
}
win32 {
CONFIG += no_batch
RESOURCES += theme-color.qrc
QMAKE_TARGET_DESCRIPTION = GPXSee
QMAKE_TARGET_COPYRIGHT = Copyright (c) 2023 Martin Tuma
QMAKE_TARGET_COPYRIGHT = Copyright (c) 2015-2024 Martin Tuma
RC_ICONS = icons/app/gpxsee.ico \
icons/formats/gpx.ico \
icons/formats/tcx.ico \

View File

@ -111,5 +111,6 @@
<mimetype>application/vnd.iho.s57-data</mimetype>
<mimetype>application/vnd.iho.s57-catalogue</mimetype>
<mimetype>application/vnd.gpsdump.wpt</mimetype>
<mimetype>application/vnd.gpstuner.gmi</mimetype>
</mimetypes>
</component>

View File

@ -16,4 +16,4 @@ Icon=gpxsee
Terminal=false
Type=Application
Categories=Graphics;Viewer;Education;Geography;Maps;Sports;Qt
MimeType=application/gpx+xml;application/vnd.garmin.tcx+xml;application/vnd.ant.fit;application/vnd.google-earth.kml+xml;application/vnd.fai.igc;application/vnd.nmea.nmea;application/vnd.oziexplorer.plt;application/vnd.oziexplorer.rte;application/vnd.oziexplorer.wpt;application/vnd.groundspeak.loc+xml;application/vnd.sigma.slf+xml;application/geo+json;application/vnd.naviter.seeyou.cup;application/vnd.garmin.gpi;application/vnd.suunto.sml+xml;image/jpeg;text/csv;application/vnd.garmin.img;application/vnd.garmin.jnx;application/vnd.garmin.gmap+xml;image/vnd.maptech.kap;application/vnd.oziexplorer.map;application/vnd.mapbox.mbtiles;application/vnd.twonav.rmap;application/vnd.trekbuddy.tba;application/vnd.gpxsee.map+xml;application/x-tar;image/tiff;application/vnd.google-earth.kmz;application/vnd.alpinequest.aqm;application/vnd.cgtk.gemf;application/vnd.rmaps.sqlite;application/vnd.osmdroid.sqlite;application/vnd.mapsforge.map;application/vnd.tomtom.ov2;application/vnd.tomtom.itn;application/vnd.esri.wld;application/vnd.onmove.omd;application/vnd.onmove.ghp;application/vnd.memory-map.qct;application/vnd.twonav.trk;application/vnd.twonav.rte;application/vnd.twonav.wpt;application/vnd.orux.map+xml;application/vnd.iho.s57-data;application/vnd.iho.s57-catalogue;application/vnd.gpsdump.wpt
MimeType=application/gpx+xml;application/vnd.garmin.tcx+xml;application/vnd.ant.fit;application/vnd.google-earth.kml+xml;application/vnd.fai.igc;application/vnd.nmea.nmea;application/vnd.oziexplorer.plt;application/vnd.oziexplorer.rte;application/vnd.oziexplorer.wpt;application/vnd.groundspeak.loc+xml;application/vnd.sigma.slf+xml;application/geo+json;application/vnd.naviter.seeyou.cup;application/vnd.garmin.gpi;application/vnd.suunto.sml+xml;image/jpeg;text/csv;application/vnd.garmin.img;application/vnd.garmin.jnx;application/vnd.garmin.gmap+xml;image/vnd.maptech.kap;application/vnd.oziexplorer.map;application/vnd.mapbox.mbtiles;application/vnd.twonav.rmap;application/vnd.trekbuddy.tba;application/vnd.gpxsee.map+xml;application/x-tar;image/tiff;application/vnd.google-earth.kmz;application/vnd.alpinequest.aqm;application/vnd.cgtk.gemf;application/vnd.rmaps.sqlite;application/vnd.osmdroid.sqlite;application/vnd.mapsforge.map;application/vnd.tomtom.ov2;application/vnd.tomtom.itn;application/vnd.esri.wld;application/vnd.onmove.omd;application/vnd.onmove.ghp;application/vnd.memory-map.qct;application/vnd.twonav.trk;application/vnd.twonav.rte;application/vnd.twonav.wpt;application/vnd.orux.map+xml;application/vnd.iho.s57-data;application/vnd.iho.s57-catalogue;application/vnd.gpsdump.wpt;application/vnd.gpstuner.gmi

View File

@ -363,4 +363,14 @@
<glob pattern="*.031"/>
</mime-type>
<mime-type type="application/vnd.gpstuner.gmi">
<comment>GPS Tuner Map Calibration File</comment>
<sub-class-of type="text/plain"/>
<generic-icon name="text/plain"/>
<magic>
<match type="string" offset="0" value="Map Calibration data file"/>
</magic>
<glob pattern="*.gmi"/>
</mime-type>
</mime-info>

View File

@ -417,6 +417,22 @@
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>gmi</string>
</array>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/vnd.gpstuner.gmi</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>icons/map.icns</string>
<key>CFBundleTypeName</key>
<string>GPS Tuner Map Calibration File</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
@ -1252,6 +1268,29 @@
<string>application/vnd.oziexplorer.map</string>
</dict>
</dict>
<dict>
<key>UTTypeIdentifier</key>
<string>com.gpstuner.gmi</string>
<key>UTTypeReferenceURL</key>
<string>https://github.com/tumic0/GPXSee/blob/master/src/map/gmifile.cpp</string>
<key>UTTypeDescription</key>
<string>GPS Tuner Map Calibration File</string>
<key>UTTypeIconFile</key>
<string>icons/map.icns</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>gmi</string>
</array>
<key>public.mime-type</key>
<string>application/vnd.gpstuner.gmi</string>
</dict>
</dict>
<dict>
<key>UTTypeIdentifier</key>
<string>com.mapbox.mbtiles</string>

View File

@ -37,7 +37,7 @@ Unicode true
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "13.14"
!define VERSION "13.15"
; The file to write
OutFile "GPXSee-${VERSION}_x64.exe"
@ -58,7 +58,7 @@ VIProductVersion "${VERSION}.0.0"
VIAddVersionKey "ProductVersion" ${VERSION}
VIAddVersionKey "FileVersion" "${VERSION}.0.0"
VIAddVersionKey "ProductName" "GPXSee"
VIAddVersionKey "LegalCopyright" "Copyright (c) 2023 Martin Tůma"
VIAddVersionKey "LegalCopyright" "Copyright (c) 2015-2024 Martin Tůma"
VIAddVersionKey "FileDescription" "GPXSee installer (x64)"
; Registry key to check for directory (so if you install again, it will
@ -95,10 +95,17 @@ Var StartMenuFolder
!insertmacro MUI_LANGUAGE "English"
Function .onInit
!ifdef QT6
${IfNot} ${AtLeastWin10}
MessageBox MB_OK "GPXSee can only be installed on Windows 10 or later."
Abort
${EndIf}
!else
${IfNot} ${AtLeastWin7}
MessageBox MB_OK "GPXSee can only be installed on Windows 7 or later."
Abort
${EndIf}
!endif
${If} ${RunningX64}
SetRegView 64
@ -163,6 +170,7 @@ Section "GPXSee" SEC_APP
!insertmacro FILE_ASSOCIATION_ADD "kap" "BSB Nautical Chart" 10
!insertmacro FILE_ASSOCIATION_ADD "gpx" "GPS Exchange Format" 11
!insertmacro FILE_ASSOCIATION_ADD "map" "OziExplorer Map File" 12
!insertmacro FILE_ASSOCIATION_ADD "gmi" "GPS Tuner Map Calibration File" 12
!insertmacro FILE_ASSOCIATION_ADD "mbtiles" "MBTiles Map File" 13
!insertmacro FILE_ASSOCIATION_ADD "rmap" "TwoNav Raster Map File" 14
!insertmacro FILE_ASSOCIATION_ADD "tba" "TrekBuddy Atlas" 15
@ -218,6 +226,7 @@ Section "GPXSee" SEC_APP
WriteRegStr HKCR ".jnx\OpenWithList" "GPXSee.exe" ""
WriteRegStr HKCR ".kap\OpenWithList" "GPXSee.exe" ""
WriteRegStr HKCR ".map\OpenWithList" "GPXSee.exe" ""
WriteRegStr HKCR ".gmi\OpenWithList" "GPXSee.exe" ""
WriteRegStr HKCR ".mbtiles\OpenWithList" "GPXSee.exe" ""
WriteRegStr HKCR ".rmap\OpenWithList" "GPXSee.exe" ""
WriteRegStr HKCR ".rtmap\OpenWithList" "GPXSee.exe" ""
@ -247,7 +256,7 @@ Section "GPXSee" SEC_APP
SectionEnd
Section "QT framework" SEC_QT
Section "Qt framework" SEC_QT
SectionIn RO
@ -262,7 +271,6 @@ Section "QT framework" SEC_QT
File "Qt6Sql.dll"
File "Qt6Svg.dll"
File "Qt6Widgets.dll"
File "Qt6Core5Compat.dll"
File "Qt6Positioning.dll"
File "Qt6SerialPort.dll"
File /r "tls"
@ -280,6 +288,7 @@ Section "QT framework" SEC_QT
File /r "printsupport"
!endif
File /r "platforms"
File /r "iconengines"
File /r "imageformats"
File /r "styles"
File /r "sqldrivers"
@ -298,21 +307,30 @@ Section "MSVC runtime" SEC_MSVC
SectionEnd
!ifdef ICU
Section "ICU" SEC_ICU
SectionIn RO
File "icudt*.dll"
File "icuin*.dll"
File "icuuc*.dll"
SectionEnd
!endif
!ifdef OPENSSL
Section "OpenSSL" SEC_OPENSSL
SectionIn RO
!ifdef QT6
File "libcrypto-3-x64.dll"
File "libssl-3-x64.dll"
!else
File "libcrypto-1_1-x64.dll"
File "libssl-1_1-x64.dll"
!endif
File "libcrypto-*-x64.dll"
File "libssl-*-x64.dll"
SectionEnd
!endif
!ifndef QT6
!ifdef ANGLE
Section "ANGLE" SEC_ANGLE
File "libGLESv2.dll"
@ -384,6 +402,7 @@ Section "Uninstall"
!insertmacro FILE_ASSOCIATION_REMOVE "jnx"
!insertmacro FILE_ASSOCIATION_REMOVE "kap"
!insertmacro FILE_ASSOCIATION_REMOVE "map"
!insertmacro FILE_ASSOCIATION_REMOVE "gmi"
!insertmacro FILE_ASSOCIATION_REMOVE "mbtiles"
!insertmacro FILE_ASSOCIATION_REMOVE "rmap"
!insertmacro FILE_ASSOCIATION_REMOVE "tba"
@ -431,6 +450,7 @@ Section "Uninstall"
DeleteRegValue HKCR ".jnx\OpenWithList" "GPXSee.exe"
DeleteRegValue HKCR ".kap\OpenWithList" "GPXSee.exe"
DeleteRegValue HKCR ".map\OpenWithList" "GPXSee.exe"
DeleteRegValue HKCR ".gmi\OpenWithList" "GPXSee.exe"
DeleteRegValue HKCR ".mbtiles\OpenWithList" "GPXSee.exe"
DeleteRegValue HKCR ".rmap\OpenWithList" "GPXSee.exe"
DeleteRegValue HKCR ".rtmap\OpenWithList" "GPXSee.exe"
@ -466,13 +486,24 @@ SectionEnd
; Descriptions
; Language strings
!ifdef QT6
LangString DESC_QT ${LANG_ENGLISH} \
"QT cross-platform application framework."
"Qt6 cross-platform application framework."
!else
LangString DESC_QT ${LANG_ENGLISH} \
"Qt5 cross-platform application framework."
!endif
LangString DESC_MSVC ${LANG_ENGLISH} \
"Microsoft Visual C++ 2019 runtime. If already installed, will be skipped."
"Microsoft Visual C++ runtime. If already installed, will be skipped."
!ifdef ICU
LangString DESC_ICU ${LANG_ENGLISH} \
"ICU library. Required for character set/encoding conversions."
!endif
!ifdef OPENSSL
LangString DESC_OPENSSL ${LANG_ENGLISH} \
"OpenSSL library. Required for HTTPS to work."
!ifndef QT6
"OpenSSL library. Qt SSL/TLS backend for HTTPS."
!endif
!ifdef ANGLE
LangString DESC_ANGLE ${LANG_ENGLISH} \
"ANGLE (OpenGL via Direct3D). Enables OpenGL on systems without native OpenGL drivers."
!endif
@ -484,8 +515,13 @@ LangString DESC_LOCALIZATION ${LANG_ENGLISH} \
; Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
!ifdef ICU
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_ICU} $(DESC_ICU)
!endif
!ifdef OPENSSL
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_OPENSSL} $(DESC_OPENSSL)
!ifndef QT6
!endif
!ifdef ANGLE
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_ANGLE} $(DESC_ANGLE)
!endif
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)

View File

@ -4,6 +4,7 @@
#include <QGraphicsItem>
#include <QVector>
#include <QLocale>
#include <QFont>
#include "common/range.h"
class AxisItem : public QGraphicsItem

View File

@ -1028,13 +1028,16 @@ void GUI::openDir()
bool GUI::openFile(const QString &fileName, bool tryUnknown, int &showError)
{
if (_files.contains(fileName))
QFileInfo fi(fileName);
QString canonicalFileName(fi.canonicalFilePath());
if (_files.contains(canonicalFileName))
return true;
if (!loadFile(fileName, tryUnknown, showError))
return false;
_files.append(fileName);
_files.append(canonicalFileName);
#ifndef Q_OS_ANDROID
_browser->setCurrent(fileName);
#endif // Q_OS_ANDROID
@ -1047,7 +1050,7 @@ bool GUI::openFile(const QString &fileName, bool tryUnknown, int &showError)
updateStatusBarInfo();
updateWindowTitle();
#ifndef Q_OS_ANDROID
updateRecentFiles(fileName);
updateRecentFiles(canonicalFileName);
#endif // Q_OS_ANDROID
return true;

View File

@ -3,6 +3,7 @@
#include <QGraphicsItem>
#include <QList>
#include <QFont>
#include "common/kv.h"
class InfoItem : public QGraphicsItem

View File

@ -2,6 +2,7 @@
#define MOTIONINFOITEM_H
#include <QGraphicsItem>
#include <QFont>
#include "units.h"
class MotionInfoItem : public QGraphicsItem

View File

@ -3,6 +3,7 @@
#include <QFont>
#include <QGraphicsItem>
#include <QtMath>
#include "graphicsscene.h"
class PathTickItem : public GraphicsItem
@ -16,7 +17,7 @@ public:
void setPos(const QPointF &pos);
void setColor(const QColor &color) {_brush = QBrush(color);}
void setDigitalZoom(int zoom) {setScale(pow(2, -zoom));}
void setDigitalZoom(int zoom) {setScale(qPow(2, -zoom));}
int type() const {return parentItem()->type();}
ToolTip info() const

View File

@ -7,6 +7,7 @@
#include <QBasicTimer>
#include <QScreen>
#include <QVBoxLayout>
#include <QFormLayout>
#include <QApplication>
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
#include <QDesktopWidget>
@ -93,21 +94,29 @@ void PopupFrame::createLayout(const ToolTip &content)
}
if (!content.list().isEmpty()) {
QString html = "<table>";
for (int i = 0; i < content.list().count(); i++)
html += "<tr><td align=\"right\"><b>" + content.list().at(i).key()
+ ":&nbsp;</b></td><td>" + content.list().at(i).value()
+ "</td></tr>";
html += "</table>";
QFormLayout *textLayout = new QFormLayout();
textLayout->setLabelAlignment(Qt::AlignRight);
textLayout->setHorizontalSpacing(5);
textLayout->setVerticalSpacing(2);
QLabel *label = new QLabel(html);
label->setAlignment(Qt::AlignLeft);
label->setIndent(1);
label->setTextInteractionFlags(Qt::TextBrowserInteraction);
label->setOpenExternalLinks(true);
label->setWordWrap(true);
for (int i = 0; i < content.list().count(); i++) {
QLabel *key = new QLabel(content.list().at(i).key() + ":");
key->setTextFormat(Qt::PlainText);
key->setAlignment(Qt::AlignTop);
key->setStyleSheet("font-weight: bold");
QLabel *value = new QLabel(content.list().at(i).value());
value->setSizePolicy(QSizePolicy::MinimumExpanding,
QSizePolicy::Preferred);
value->setTextFormat(Qt::RichText);
value->setAlignment(Qt::AlignTop);
value->setTextInteractionFlags(Qt::TextBrowserInteraction);
value->setOpenExternalLinks(true);
value->setWordWrap(true);
layout->addWidget(label);
textLayout->addRow(key, value);
}
layout->addLayout(textLayout);
}
setLayout(layout);

View File

@ -2,6 +2,7 @@
#define SCALEITEM_H
#include <QGraphicsItem>
#include <QFont>
#include "units.h"
class ScaleItem : public QGraphicsItem

View File

@ -2,6 +2,7 @@
#define SLIDERINFOITEM_H
#include <QGraphicsItem>
#include <QFont>
class SliderInfoItem : public QGraphicsItem
{

View File

@ -1,5 +1,4 @@
#include <QFile>
#include <QFileInfo>
#include <QNetworkRequest>
#include <QDir>
#include <QTimerEvent>
@ -56,6 +55,7 @@ Authorization::Authorization(const QString &username, const QString &password)
_header = HTTPHeader("Authorization", "Basic " + data);
}
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
NetworkTimeout::NetworkTimeout(int timeout, QNetworkReply *reply)
: QObject(reply), _timeout(timeout)
{
@ -77,6 +77,7 @@ void NetworkTimeout::timerEvent(QTimerEvent *ev)
reply->abort();
_timer.stop();
}
#endif // QT 5.15
QNetworkAccessManager *Downloader::_manager = 0;
@ -104,11 +105,15 @@ bool Downloader::doDownload(const Download &dl, const QList<HTTPHeader> &headers
request.setAttribute(ATTR_REDIRECT_POLICY,
QNetworkRequest::NoLessSafeRedirectPolicy);
request.setAttribute(ATTR_HTTP2_ALLOWED, QVariant(_http2));
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
request.setTransferTimeout(_timeout * 1000);
#endif // QT 5.15
for (int i = 0; i < headers.size(); i++) {
const HTTPHeader &hdr = headers.at(i);
request.setRawHeader(hdr.key(), hdr.value());
if (hdr.key() == "User-Agent")
// QByteArray::compare() not available in Qt < 5.12
if (!QString(hdr.key()).compare("User-Agent", Qt::CaseInsensitive))
userAgent = true;
}
if (!userAgent)
@ -128,9 +133,9 @@ bool Downloader::doDownload(const Download &dl, const QList<HTTPHeader> &headers
_currentDownloads.insert(url, file);
if (reply->isRunning()) {
/* Starting with Qt 5.15 this can be replaced by
QNetworkRequest::setTransferTimeout() */
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
new NetworkTimeout(_timeout, reply);
#endif // QT 5.15
connect(reply, &QIODevice::readyRead, this, &Downloader::emitReadReady);
connect(reply, &QNetworkReply::finished, this, &Downloader::emitFinished);
} else {

View File

@ -3,7 +3,9 @@
#include <QNetworkAccessManager>
#include <QNetworkReply>
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
#include <QBasicTimer>
#endif // QT 5.15
#include <QUrl>
#include <QList>
#include <QHash>
@ -39,6 +41,7 @@ private:
HTTPHeader _header;
};
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
class NetworkTimeout : public QObject
{
Q_OBJECT
@ -55,6 +58,7 @@ private:
QBasicTimer _timer;
int _timeout;
};
#endif // QT 5.15
class Downloader : public QObject
{
@ -79,8 +83,6 @@ private slots:
void emitReadReady();
private:
class ReplyTimeout;
void insertError(const QUrl &url, QNetworkReply::NetworkError error);
bool doDownload(const Download &dl, const QList<HTTPHeader> &headers);
void downloadFinished(QNetworkReply *reply);

View File

@ -2,9 +2,12 @@
#define HASH_H
#include <QtGlobal>
#include <QPoint>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QPoint>
#include <QPair>
#include <QHash>
#define HASH_T uint
inline uint qHash(const QPoint &p)

View File

@ -1,15 +1,20 @@
#include <QTextCodec>
#include "textcodec.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
static QTextCodec *codec(int mib)
{
QTextCodec *c = QTextCodec::codecForMib(mib);
if (!c)
qWarning("MIB-%d: No such QTextCodec, using UTF-8", mib);
qWarning("MIB-%d: No such QTextCodec, using ISO-8859-1", mib);
return c;
}
TextCodec::TextCodec() : _codec(0)
{
}
TextCodec::TextCodec(int codepage)
{
switch (codepage) {
@ -56,15 +61,40 @@ TextCodec::TextCodec(int codepage)
_codec = codec(2258);
break;
case 65001:
_codec = 0;
_codec = codec(106);
break;
default:
qWarning("%d: Unknown codepage, using UTF-8", codepage);
qWarning("%d: Unknown codepage, using ISO-8859-1", codepage);
_codec = 0;
}
}
QString TextCodec::toString(const QByteArray &ba) const
QString TextCodec::toString(const QByteArray &ba)
{
return _codec ? _codec->toUnicode(ba) : QString::fromUtf8(ba);
return _codec ? _codec->toUnicode(ba) : QString::fromLatin1(ba);
}
#else // QT 6.5
TextCodec::TextCodec()
{
}
TextCodec::TextCodec(int codepage)
{
if (codepage == 65001)
_decoder = QStringDecoder(QStringDecoder::Utf8);
else {
QByteArray cp(QByteArray("CP") + QByteArray::number(codepage));
_decoder = QStringDecoder(cp.constData());
if (!_decoder.isValid())
qWarning("%d: Unknown codepage, using ISO-8859-1", codepage);
}
}
QString TextCodec::toString(const QByteArray &ba)
{
return _decoder.isValid() ? _decoder.decode(ba) : QString::fromLatin1(ba);
}
#endif // QT 6.5

View File

@ -2,20 +2,26 @@
#define TEXTCODEC_H
#include <QString>
#include <QMap>
class QTextCodec;
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
#include <QTextCodec>
#else // QT 6.5
#include <QStringDecoder>
#endif // QT 6.5
class TextCodec
{
public:
TextCodec() : _codec(0) {}
TextCodec();
TextCodec(int codepage);
QString toString(const QByteArray &ba) const;
QString toString(const QByteArray &ba);
private:
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
QTextCodec *_codec;
#else // QT 6.5
QStringDecoder _decoder;
#endif // QT 6.5
};
#endif // TEXTCODEC_H

View File

@ -148,9 +148,9 @@ qreal DEM::elevation(const Coordinates &c)
QList<Area> DEM::tiles()
{
static const QRegularExpression re("([NS])([0-9]{2})([EW])([0-9]{3})");
QDir dir(_dir);
QFileInfoList files(dir.entryInfoList(QDir::Files | QDir::Readable));
QRegularExpression re("([NS])([0-9]{2})([EW])([0-9]{3})");
QLocale l(QLocale::system());
QList<Area> list;

View File

@ -128,7 +128,7 @@ qint64 CryptDevice::readData(char *data, qint64 maxSize)
class DataStream : public QDataStream
{
public:
DataStream(QIODevice *d) : QDataStream(d), _codec(1252) {}
DataStream(QIODevice *d) : QDataStream(d) {}
void setCodepage(quint16 codepage) {_codec = TextCodec(codepage);}

View File

@ -88,6 +88,7 @@ static Coordinates parseUTM(const QString &zone, const QString &easting,
bool GPSDumpParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Area> &polygons, QVector<Waypoint> &waypoints)
{
static const QRegularExpression dm("[ ]{2,}");
Q_UNUSED(tracks);
Q_UNUSED(routes);
Q_UNUSED(polygons);
@ -95,7 +96,6 @@ bool GPSDumpParser::parse(QFile *file, QList<TrackData> &tracks,
_errorLine = 1;
_errorString.clear();
Type type = Unknown;
QRegularExpression dm("[ ]{2,}");
while (!file->atEnd()) {
QByteArray ba(file->readLine(4096).trimmed());

View File

@ -52,8 +52,10 @@ bool GMAPData::readXML(const QString &path, QString &dataDir, QString &typFile)
{
QFile file(path);
if (!file.open(QFile::ReadOnly | QFile::Text))
if (!file.open(QFile::ReadOnly | QFile::Text)) {
_errorString = file.errorString();
return false;
}
QXmlStreamReader reader(&file);
if (reader.readNextStartElement()) {

View File

@ -138,7 +138,7 @@ void LBLFile::clear()
}
Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize,
bool convert) const
bool convert)
{
Shield::Type shieldType = Shield::None;
QByteArray label, shieldLabel;
@ -247,7 +247,7 @@ Label LBLFile::label6b(const SubFile *file, Handle &fileHdl, quint32 size,
}
Label LBLFile::label8b(const SubFile *file, Handle &fileHdl, quint32 size,
bool capitalize, bool convert) const
bool capitalize, bool convert)
{
QVector<quint8> str;
quint8 c;
@ -264,7 +264,7 @@ Label LBLFile::label8b(const SubFile *file, Handle &fileHdl, quint32 size,
}
Label LBLFile::labelHuffman(Handle &hdl, const SubFile *file, Handle &fileHdl,
quint32 size, bool capitalize, bool convert) const
quint32 size, bool capitalize, bool convert)
{
QVector<quint8> str;
@ -305,7 +305,7 @@ Label LBLFile::labelHuffman(Handle &hdl, const SubFile *file, Handle &fileHdl,
}
Label LBLFile::label(Handle &hdl, quint32 offset, bool poi, bool capitalize,
bool convert) const
bool convert)
{
quint32 labelOffset;
if (poi) {
@ -328,7 +328,7 @@ Label LBLFile::label(Handle &hdl, quint32 offset, bool poi, bool capitalize,
}
Label LBLFile::label(Handle &hdl, const SubFile *file, Handle &fileHdl,
quint32 size, bool capitalize, bool convert) const
quint32 size, bool capitalize, bool convert)
{
switch (_encoding) {
case 6:

View File

@ -30,9 +30,9 @@ public:
void clear();
Label label(Handle &hdl, quint32 offset, bool poi = false,
bool capitalize = true, bool convert = false) const;
bool capitalize = true, bool convert = false);
Label label(Handle &hdl, const SubFile *file, Handle &fileHdl,
quint32 size, bool capitalize = true, bool convert = false) const;
quint32 size, bool capitalize = true, bool convert = false);
quint8 imageIdSize() const {return _imgIdSize;}
QPixmap image(Handle &hdl, quint32 id) const;
@ -44,13 +44,13 @@ private:
};
Label str2label(const QVector<quint8> &str, bool capitalize,
bool convert) const;
bool convert);
Label label6b(const SubFile *file, Handle &fileHdl, quint32 size,
bool capitalize, bool convert) const;
Label label8b(const SubFile *file, Handle &fileHdl, quint32 size,
bool capitalize, bool convert) const;
bool capitalize, bool convert);
Label labelHuffman(Handle &hdl, const SubFile *file, Handle &fileHdl,
quint32 size, bool capitalize, bool convert) const;
quint32 size, bool capitalize, bool convert);
bool loadRasterTable(Handle &hdl, quint32 offset, quint32 size,
quint32 recordSize);

View File

@ -329,7 +329,7 @@ bool NETFile::readShape(const NODFile *nod, SubFile::Handle &nodHdl,
}
bool NETFile::linkLabel(Handle &hdl, quint32 offset,
const LBLFile *lbl, Handle &lblHdl, Label &label) const
LBLFile *lbl, Handle &lblHdl, Label &label) const
{
if (!seek(hdl, offset))
return false;
@ -392,7 +392,7 @@ NETFile::~NETFile()
}
bool NETFile::link(const SubDiv *subdiv, quint32 shift, Handle &hdl,
const NODFile *nod, Handle &nodHdl2, Handle &nodHdl, const LBLFile *lbl,
const NODFile *nod, Handle &nodHdl2, Handle &nodHdl, LBLFile *lbl,
Handle &lblHdl, const NODFile::BlockInfo &blockInfo, quint8 linkId,
quint8 lineId, QList<MapData::Poly> *lines) const
{

View File

@ -30,13 +30,13 @@ public:
bool lblOffset(Handle &hdl, quint32 netOffset, quint32 &lblOffset) const;
bool link(const SubDiv *subdiv, quint32 shift, Handle &hdl,
const NODFile *nod, Handle &nodHdl2, Handle &nodHdl, const LBLFile *lbl,
const NODFile *nod, Handle &nodHdl2, Handle &nodHdl, LBLFile *lbl,
Handle &lblHdl, const NODFile::BlockInfo &blockInfo, quint8 linkId,
quint8 lineId, QList<MapData::Poly> *lines) const;
bool hasLinks() const {return (_links.size > 0);}
private:
bool linkLabel(Handle &hdl, quint32 offset, const LBLFile *lbl,
bool linkLabel(Handle &hdl, quint32 offset, LBLFile *lbl,
Handle &lblHdl, Label &label) const;
bool readShape(const NODFile *nod, SubFile::Handle &nodHdl,
NODFile::AdjacencyInfo &adj, BitStream4R &bs, const SubDiv *subdiv,

View File

@ -107,7 +107,7 @@ bool RGNFile::readObstructionInfo(Handle &hdl, quint8 flags, quint32 size,
return true;
}
bool RGNFile::readLabel(Handle &hdl, const LBLFile *lbl, Handle &lblHdl,
bool RGNFile::readLabel(Handle &hdl, LBLFile *lbl, Handle &lblHdl,
quint8 flags, quint32 size, MapData::Point *point) const
{
if (!(flags & 1))
@ -122,7 +122,7 @@ bool RGNFile::readLabel(Handle &hdl, const LBLFile *lbl, Handle &lblHdl,
}
bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType,
void *object, const LBLFile *lbl, Handle &lblHdl) const
void *object, LBLFile *lbl, Handle &lblHdl) const
{
quint8 flags;
quint32 rs = 0;
@ -257,7 +257,7 @@ void RGNFile::clear()
}
bool RGNFile::polyObjects(Handle &hdl, const SubDiv *subdiv,
SegmentType segmentType, const LBLFile *lbl, Handle &lblHdl, NETFile *net,
SegmentType segmentType, LBLFile *lbl, Handle &lblHdl, NETFile *net,
Handle &netHdl, QList<MapData::Poly> *polys) const
{
const SubDiv::Segment &segment = (segmentType == Line)
@ -340,7 +340,7 @@ bool RGNFile::polyObjects(Handle &hdl, const SubDiv *subdiv,
}
bool RGNFile::extPolyObjects(Handle &hdl, const SubDiv *subdiv, quint32 shift,
SegmentType segmentType, const LBLFile *lbl, Handle &lblHdl,
SegmentType segmentType, LBLFile *lbl, Handle &lblHdl,
QList<MapData::Poly> *polys) const
{
quint32 labelPtr, len;
@ -457,7 +457,7 @@ bool RGNFile::extPolyObjects(Handle &hdl, const SubDiv *subdiv, quint32 shift,
}
bool RGNFile::pointObjects(Handle &hdl, const SubDiv *subdiv,
SegmentType segmentType, const LBLFile *lbl, Handle &lblHdl,
SegmentType segmentType, LBLFile *lbl, Handle &lblHdl,
QList<MapData::Point> *points) const
{
const SubDiv::Segment &segment = (segmentType == IndexedPoint)
@ -502,7 +502,7 @@ bool RGNFile::pointObjects(Handle &hdl, const SubDiv *subdiv,
}
bool RGNFile::extPointObjects(Handle &hdl, const SubDiv *subdiv,
const LBLFile *lbl, Handle &lblHdl, QList<MapData::Point> *points) const
LBLFile *lbl, Handle &lblHdl, QList<MapData::Point> *points) const
{
const SubDiv::Segment &segment = subdiv->extPoints();
@ -554,7 +554,7 @@ bool RGNFile::extPointObjects(Handle &hdl, const SubDiv *subdiv,
bool RGNFile::links(Handle &hdl, const SubDiv *subdiv, quint32 shift,
const NETFile *net, Handle &netHdl, const NODFile *nod, Handle &nodHdl,
Handle &nodHdl2, const LBLFile *lbl, Handle &lblHdl,
Handle &nodHdl2, LBLFile *lbl, Handle &lblHdl,
QList<MapData::Poly> *lines) const
{
quint32 size, blockIndexId;

View File

@ -33,18 +33,18 @@ public:
bool load(Handle &hdl);
bool polyObjects(Handle &hdl, const SubDiv *subdiv, SegmentType segmentType,
const LBLFile *lbl, Handle &lblHdl, NETFile *net, Handle &netHdl,
LBLFile *lbl, Handle &lblHdl, NETFile *net, Handle &netHdl,
QList<MapData::Poly> *polys) const;
bool pointObjects(Handle &hdl, const SubDiv *subdiv, SegmentType segmentType,
const LBLFile *lbl, Handle &lblHdl, QList<MapData::Point> *points) const;
LBLFile *lbl, Handle &lblHdl, QList<MapData::Point> *points) const;
bool extPolyObjects(Handle &hdl, const SubDiv *subdiv, quint32 shift,
SegmentType segmentType, const LBLFile *lbl, Handle &lblHdl,
SegmentType segmentType, LBLFile *lbl, Handle &lblHdl,
QList<MapData::Poly> *polys) const;
bool extPointObjects(Handle &hdl, const SubDiv *subdiv, const LBLFile *lbl,
bool extPointObjects(Handle &hdl, const SubDiv *subdiv, LBLFile *lbl,
Handle &lblHdl, QList<MapData::Point> *points) const;
bool links(Handle &hdl, const SubDiv *subdiv, quint32 shift,
const NETFile *net, Handle &netHdl, const NODFile *nod, Handle &nodHdl,
Handle &nodHdl2, const LBLFile *lbl, Handle &lblHdl,
Handle &nodHdl2, LBLFile *lbl, Handle &lblHdl,
QList<MapData::Poly> *lines) const;
bool subdivInit(Handle &hdl, SubDiv *subdiv) const;
@ -55,7 +55,7 @@ public:
private:
bool segments(Handle &hdl, SubDiv *subdiv, SubDiv::Segment seg[5]) const;
bool readClassFields(Handle &hdl, SegmentType segmentType, void *object,
const LBLFile *lbl, Handle &lblHdl) const;
LBLFile *lbl, Handle &lblHdl) const;
bool skipLclFields(Handle &hdl, const quint32 flags[3]) const;
bool skipGblFields(Handle &hdl, quint32 flags) const;
bool readRasterInfo(Handle &hdl, const LBLFile *lbl, quint32 size,
@ -64,7 +64,7 @@ private:
MapData::Point *point) const;
bool readObstructionInfo(Handle &hdl, quint8 flags, quint32 size,
MapData::Point *point) const;
bool readLabel(Handle &hdl, const LBLFile *lbl, Handle &lblHdl,
bool readLabel(Handle &hdl, LBLFile *lbl, Handle &lblHdl,
quint8 flags, quint32 size, MapData::Point *point) const;
HuffmanTable *_huffmanTable;

View File

@ -2,6 +2,7 @@
#define IMG_SHIELD_H
#include <QString>
#include <QDebug>
#include "common/hash.h"
#define FIRST_SHIELD Shield::USInterstate

View File

@ -27,19 +27,25 @@ static bool yCmp(OziMap *m1, OziMap *m2)
return TL(m1).y() > TL(m2).y();
}
static QString calibrationFile(const QString &path)
static QString calibrationFile(const QString &path, OziMap::CalibrationType &type)
{
QDir dir(path);
QFileInfoList files = dir.entryInfoList(QDir::Files);
QFileInfoList files(dir.entryInfoList(QDir::Files));
for (int i = 0; i < files.size(); i++) {
const QFileInfo &fi = files.at(i);
QString suffix(fi.suffix().toLower());
if (suffix == "map" || suffix == "gmi")
if (suffix == "map") {
type = OziMap::MAP;
return fi.absoluteFilePath();
} else if (suffix == "gmi") {
type = OziMap::GMI;
return fi.absoluteFilePath();
}
}
type = OziMap::Unknown;
return QString();
}
@ -141,16 +147,19 @@ Atlas::Atlas(const QString &fileName, bool TAR, const Projection &proj,
QFileInfoList maps = zdir.entryInfoList(QDir::Dirs
| QDir::NoDotAndDotDot);
for (int i = 0; i < maps.count(); i++) {
QString path(maps.at(i).absoluteFilePath());
OziMap *map;
if (TAR)
map = new OziMap(maps.at(i).absoluteFilePath(), tar, proj, this);
map = new OziMap(path, tar, proj, this);
else {
QString cf(calibrationFile(maps.at(i).absoluteFilePath()));
OziMap::CalibrationType type;
QString cf(calibrationFile(path, type));
if (cf.isNull()) {
_errorString = "No calibration file found";
return;
qWarning("%s: no calibration file found", qPrintable(path));
continue;
}
map = new OziMap(cf, proj, this);
map = new OziMap(cf, type, proj, this);
}
if (map->isValid())

View File

@ -395,7 +395,7 @@ BSBMap::BSBMap(const QString &fileName, QObject *parent)
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
_errorString = fileName + ": " + file.errorString();
_errorString = file.errorString();
return;
}

View File

@ -9,7 +9,8 @@
class Ellipsoid
{
public:
Ellipsoid() : _radius(NAN), _flattening(NAN), _es(NAN), _b(NAN) {}
Ellipsoid()
: _radius(NAN), _flattening(NAN), _es(NAN), _e2s(NAN), _b(NAN) {}
Ellipsoid(double radius, double flattening);
double radius() const {return _radius;}

View File

@ -24,11 +24,6 @@ bool GmiFile::parse(QIODevice &device)
int width, height;
bool ok;
if (!device.open(QIODevice::ReadOnly)) {
_errorString = device.errorString();
return false;
}
while (!device.atEnd()) {
QByteArray line = device.readLine(4096);
@ -41,14 +36,14 @@ bool GmiFile::parse(QIODevice &device)
_image = line.trimmed();
else if (ln == 3) {
width = line.toInt(&ok);
if (!ok || ok <= 0) {
_errorString = "Invalid image width";
if (!ok || width <= 0) {
_errorString = line + ": invalid image width";
return false;
}
} else if (ln == 4) {
height = line.toInt(&ok);
if (!ok || ok <= 0) {
_errorString = "Invalid image height";
if (!ok || height <= 0) {
_errorString = line + ": invalid image height";
return false;
}
_size = QSize(width, height);
@ -56,19 +51,34 @@ bool GmiFile::parse(QIODevice &device)
CalibrationPoint cp(calibrationPoint(line));
if (cp.isValid())
_points.append(cp);
else
break;
else {
if (_points.size() < 2) {
_errorString = line + ": invalid calibration point";
return false;
} else
break;
}
}
ln++;
}
device.close();
if (ln < 6) {
_errorString = "Unexpected EOF";
return false;
}
return (_points.size() >= 2);
return true;
}
GmiFile::GmiFile(QIODevice &file)
GmiFile::GmiFile(QIODevice &file) : _valid(false)
{
if (!file.open(QIODevice::ReadOnly)) {
_errorString = file.errorString();
return;
}
_valid = parse(file);
file.close();
}

View File

@ -43,7 +43,7 @@ MapList::ParserMap MapList::parsers()
map.insert("rtmap", &RMap::create);
map.insert("map", &MapsforgeMap::create);
map.insert("map", &OziMap::createMAP);
map.insert("gmi", &OziMap::createMAP);
map.insert("gmi", &OziMap::createGMI);
map.insert("kap", &BSBMap::create);
map.insert("kmz", &KMZMap::create);
map.insert("aqm", &AQMMap::create);

View File

@ -366,8 +366,10 @@ bool OruxMap::readXML(const QString &path, const QString &dir)
{
QFile file(path);
if (!file.open(QFile::ReadOnly | QFile::Text))
if (!file.open(QFile::ReadOnly | QFile::Text)) {
_errorString = file.errorString();
return false;
}
QXmlStreamReader reader(&file);
if (reader.readNextStartElement()) {

View File

@ -54,19 +54,15 @@ QString OziMap::calibrationFile(const QStringList &files, const QString path,
return QString();
}
OziMap::OziMap(const QString &fileName, const Projection &proj, QObject *parent)
: Map(fileName, parent), _img(0), _tar(0), _ozf(0), _zoom(0), _mapRatio(1.0),
_valid(false)
OziMap::OziMap(const QString &fileName, CalibrationType type,
const Projection &proj, QObject *parent) : Map(fileName, parent), _img(0),
_tar(0), _ozf(0), _zoom(0), _mapRatio(1.0), _valid(false)
{
QFileInfo fi(fileName);
QString suffix(fi.suffix().toLower());
if (suffix == "tar") {
CalibrationType type;
// TAR maps
if (type == Unknown) {
_tar = new Tar(fileName);
if (!_tar->open()) {
_errorString = "Error reading tar file: " + _tar->errorString();
_errorString = _tar->errorString();
return;
}
QStringList files(_tar->files());
@ -110,10 +106,12 @@ OziMap::OziMap(const QString &fileName, const Projection &proj, QObject *parent)
return;
_tar->close();
// regular MAP or GMI maps
} else {
QFile file(fileName);
if (suffix == "map") {
if (type == MAP) {
MapFile mf(file);
if (!mf.isValid()) {
_errorString = mf.errorString();
@ -125,7 +123,7 @@ OziMap::OziMap(const QString &fileName, const Projection &proj, QObject *parent)
_projection = mf.projection();
_transform = mf.transform();
}
} else if (suffix == "gmi") {
} else if (type == GMI) {
GmiFile gmi(file);
if (!gmi.isValid()) {
_errorString = gmi.errorString();
@ -138,11 +136,9 @@ OziMap::OziMap(const QString &fileName, const Projection &proj, QObject *parent)
_projection = proj;
computeTransform();
}
} else {
_errorString = "Unknown file type";
return;
}
QFileInfo fi(fileName);
QDir set(fi.absolutePath() + "/" + "set");
if (set.exists()) {
if (!setTileInfo(set.entryList(), set.absolutePath()))
@ -266,32 +262,33 @@ bool OziMap::setImageInfo(const QString &path)
bool OziMap::setTileInfo(const QStringList &tiles, const QString &path)
{
static const QRegularExpression rx("_[0-9]+_[0-9]+\\.");
if (!_map.size.isValid()) {
_errorString = "Missing total image size (IWH)";
return false;
}
QRegularExpression rx("_[0-9]+_[0-9]+\\.");
for (int i = 0; i < tiles.size(); i++) {
if (tiles.at(i).contains(rx)) {
_tile.path = QString(tiles.at(i)).replace(rx, "_%1_%2.");
const QString &tile = tiles.at(i);
if (tile.contains(rx)) {
QString pattern(QString(tile).replace(rx, "_%1_%2."));
if (_tar) {
QByteArray ba = _tar->file(tiles.at(i));
QByteArray ba(_tar->file(tile));
QBuffer buffer(&ba);
_tile.path = pattern;
_tile.size = QImageReader(&buffer).size();
} else {
_tile.path = path + "/" + _tile.path;
_tile.size = QImageReader(path + "/" + tiles.at(i)).size();
}
if (!_tile.size.isValid()) {
_errorString = QString("Error retrieving tile size: "
"%1: Invalid image").arg(QFileInfo(tiles.at(i)).fileName());
return false;
_tile.path = path + "/" + pattern;
_tile.size = QImageReader(path + "/" + tile).size();
}
_map.path = QString();
return true;
if (_tile.size.isValid())
return true;
else
qWarning("%s: error reading tile image", qPrintable(tile));
}
}
@ -373,8 +370,7 @@ void OziMap::drawTiled(QPainter *painter, const QRectF &rect) const
pixmap = QPixmap(tileName);
if (pixmap.isNull())
qWarning("%s: error loading tile image", qPrintable(
_tile.path.arg(QString::number(x), QString::number(y))));
qWarning("%s: error loading tile image", qPrintable(tileName));
else {
pixmap.setDevicePixelRatio(_mapRatio);
QPointF tp(tl.x() + i * ts.width(), tl.y() + j * ts.height());
@ -398,8 +394,9 @@ void OziMap::drawOZF(QPainter *painter, const QRectF &rect) const
int y = round(tl.y() * _mapRatio + j * _ozf->tileSize().height());
QPixmap pixmap;
QString key = _ozf->fileName() + "/" + QString::number(_zoom) + "_"
+ QString::number(x) + "_" + QString::number(y);
QString key(_ozf->fileName() + "/" + QString::number(_zoom) + "_"
+ QString::number(x) + "_" + QString::number(y));
if (!QPixmapCache::find(key, &pixmap)) {
pixmap = _ozf->tile(_zoom, x, y);
if (!pixmap.isNull())
@ -512,7 +509,7 @@ Map *OziMap::createTAR(const QString &path, const Projection &proj, bool *isDir)
if (isDir)
*isDir = false;
return new OziMap(path, proj);
return new OziMap(path, Unknown, proj);
}
Map *OziMap::createMAP(const QString &path, const Projection &proj, bool *isDir)
@ -520,5 +517,13 @@ Map *OziMap::createMAP(const QString &path, const Projection &proj, bool *isDir)
if (isDir)
*isDir = false;
return new OziMap(path, proj);
return new OziMap(path, MAP, proj);
}
Map *OziMap::createGMI(const QString &path, const Projection &proj, bool *isDir)
{
if (isDir)
*isDir = false;
return new OziMap(path, GMI, proj);
}

View File

@ -15,7 +15,11 @@ class OziMap : public Map
Q_OBJECT
public:
OziMap(const QString &fileName, const Projection &proj,
enum CalibrationType {
Unknown, MAP, GMI
};
OziMap(const QString &fileName, CalibrationType type, const Projection &proj,
QObject *parent = 0);
OziMap(const QString &dirName, Tar &tar, const Projection &proj,
QObject *parent = 0);
@ -54,12 +58,10 @@ public:
bool *isDir);
static Map *createMAP(const QString &path, const Projection &proj,
bool *isDir);
static Map *createGMI(const QString &path, const Projection &proj,
bool *isDir);
private:
enum CalibrationType {
Unknown, MAP, GMI
};
struct ImageInfo {
QSize size;
QString path;

View File

@ -327,7 +327,7 @@ QCTMap::QCTMap(const QString &fileName, QObject *parent)
_mapRatio(1.0), _valid(false)
{
if (!_file.open(QIODevice::ReadOnly)) {
_errorString = fileName + ": " + _file.errorString();
_errorString = _file.errorString();
return;
}

View File

@ -97,10 +97,10 @@ static Projection parseProjection(const QString &str, const GCS &gcs)
bool RMap::parseIMP(const QByteArray &data)
{
QStringList lines = QString(data).split("\r\n");
static const QRegularExpression re("^P[0-9]+=");
QStringList lines(QString(data).split("\r\n"));
QVector<CalibrationPoint> calibrationPoints;
QString projection, datum;
QRegularExpression re("^P[0-9]+=");
for (int i = 0; i < lines.count(); i++) {
const QString &line = lines.at(i);

View File

@ -70,11 +70,11 @@ bool Tar::loadTar()
quint64 size;
qint64 ret;
while ((ret = _file.read(buffer, BLOCKSIZE)) > 0) {
while ((ret = _file.read(buffer, BLOCKSIZE))) {
if (ret < BLOCKSIZE) {
_file.close();
_index.clear();
_errorString = "Error reading header block";
_errorString = "Error reading TAR header block";
return false;
}
size = number(hdr->size, sizeof(hdr->size));
@ -100,7 +100,7 @@ bool Tar::loadTmi(const QString &path)
return false;
while (!file.atEnd()) {
QByteArray line = file.readLine(4096);
QByteArray line(file.readLine(4096));
int pos = line.indexOf(':');
if (line.size() < 10 || pos < 7 || !line.startsWith("block")) {
qWarning("%s:%d: syntax error", qPrintable(path), ln);