From ad13a5b0cf2a3d8fd66b06556a79de6a3df3074d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 4 Jan 2025 00:18:27 +0100 Subject: [PATCH 1/4] qPrintable() -> qUtf8Printable() --- src/GUI/gui.cpp | 3 ++- src/data/data.cpp | 12 +++++----- src/data/igcparser.cpp | 2 +- src/data/onmoveparsers.cpp | 14 ++++++----- src/data/poi.cpp | 4 ++-- src/data/slfparser.cpp | 2 +- src/data/tcxparser.cpp | 2 +- src/data/track.cpp | 11 ++++----- src/data/waypoint.cpp | 2 +- src/map/IMG/gmapdata.cpp | 4 ++-- src/map/IMG/imgdata.cpp | 4 ++-- src/map/IMG/rastertile.cpp | 4 ++-- src/map/IMG/style.cpp | 12 +++++----- src/map/IMG/subfile.h | 4 ++-- src/map/aqmmap.cpp | 4 ++-- src/map/atlas.cpp | 7 +++--- src/map/conversion.cpp | 25 +++++++++---------- src/map/dem.cpp | 4 ++-- src/map/demloader.cpp | 2 +- src/map/downloader.cpp | 6 ++--- src/map/ellipsoid.cpp | 13 +++++----- src/map/encatlas.cpp | 4 ++-- src/map/gcs.cpp | 41 ++++++++++++++++---------------- src/map/gemfmap.cpp | 4 ++-- src/map/imgmap.cpp | 4 ++-- src/map/jnxmap.cpp | 4 ++-- src/map/maplist.cpp | 4 ++-- src/map/mapsforge/mapdata.cpp | 4 ++-- src/map/mapsforge/rastertile.cpp | 4 ++-- src/map/mapsforge/style.cpp | 6 ++--- src/map/mbtilesmap.cpp | 10 ++++---- src/map/oruxmap.cpp | 8 +++---- src/map/ozf.cpp | 2 +- src/map/ozimap.cpp | 14 +++++------ src/map/pcs.cpp | 17 ++++++------- src/map/prjfile.cpp | 4 ++-- src/map/qctmap.cpp | 6 ++--- src/map/rmap.cpp | 6 ++--- src/map/tar.cpp | 2 +- src/map/tileloader.cpp | 3 ++- 40 files changed, 148 insertions(+), 140 deletions(-) diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index 77b12b30..5102305e 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -164,7 +164,8 @@ void GUI::mapInitialized() _showMapAction->setEnabled(true); _clearMapCacheAction->setEnabled(true); } else { - qWarning("%s: %s", qPrintable(map->path()), qPrintable(map->errorString())); + qWarning("%s: %s", qUtf8Printable(map->path()), + qUtf8Printable(map->errorString())); action->deleteLater(); } } diff --git a/src/data/data.cpp b/src/data/data.cpp index 660dcb25..e9b7a888 100644 --- a/src/data/data.cpp +++ b/src/data/data.cpp @@ -127,11 +127,11 @@ Data::Data(const QString &fileName, bool tryUnknown) ++it; } - qWarning("%s:", qPrintable(fileName)); + qWarning("%s:", qUtf8Printable(fileName)); for (it = _parsers.find(suffix); it != _parsers.end() && it.key() == suffix; it++) - qWarning(" %s: line %d: %s", qPrintable(it.key()), - it.value()->errorLine(), qPrintable(it.value()->errorString())); + qWarning(" %s: line %d: %s", qUtf8Printable(it.key()), + it.value()->errorLine(), qUtf8Printable(it.value()->errorString())); } else if (tryUnknown) { for (it = _parsers.begin(); it != _parsers.end(); it++) { @@ -144,10 +144,10 @@ Data::Data(const QString &fileName, bool tryUnknown) file.reset(); } - qWarning("%s:", qPrintable(fileName)); + qWarning("%s:", qUtf8Printable(fileName)); for (it = _parsers.begin(); it != _parsers.end(); it++) - qWarning(" %s: line %d: %s", qPrintable(it.key()), - it.value()->errorLine(), qPrintable(it.value()->errorString())); + qWarning(" %s: line %d: %s", qUtf8Printable(it.key()), + it.value()->errorLine(), qUtf8Printable(it.value()->errorString())); _errorLine = 0; _errorString = "Unknown format"; diff --git a/src/data/igcparser.cpp b/src/data/igcparser.cpp index 253bd0b1..f00b7ab3 100644 --- a/src/data/igcparser.cpp +++ b/src/data/igcparser.cpp @@ -245,7 +245,7 @@ bool IGCParser::parse(QFile *file, QList &tracks, /* The date H header is mandatory, but XCSOAR generates files without it, so add a dummy date in such case */ qWarning("%s: Missing date header", - qPrintable(file->fileName())); + qUtf8Printable(file->fileName())); ctx.date = QDate(1970, 1, 1); } if (!track) { diff --git a/src/data/onmoveparsers.cpp b/src/data/onmoveparsers.cpp index 7f65be5c..4aa6c21b 100644 --- a/src/data/onmoveparsers.cpp +++ b/src/data/onmoveparsers.cpp @@ -28,11 +28,12 @@ bool OMDParser::readHeaderFile(const QString &omdPath, Header &hdr) char buffer[60]; if (!file.open(QIODevice::ReadOnly)) { - qWarning("%s: %s", qPrintable(path), qPrintable(file.errorString())); + qWarning("%s: %s", qUtf8Printable(path), + qUtf8Printable(file.errorString())); return false; } if (file.read(buffer, sizeof(buffer)) != sizeof(buffer)) { - qWarning("%s: invalid OMH file", qPrintable(path)); + qWarning("%s: invalid OMH file", qUtf8Printable(path)); return false; } @@ -48,7 +49,7 @@ bool OMDParser::readHeaderFile(const QString &omdPath, Header &hdr) QDateTime date(QDate(Y + 2000, M, D), QTime(h, m), QTimeZone::utc()); if (!date.isValid()) { - qWarning("%s: invalid date", qPrintable(path)); + qWarning("%s: invalid date", qUtf8Printable(path)); return false; } @@ -183,11 +184,12 @@ bool GHPParser::readHeaderFile(const QString &ghpPath, Header &hdr) char buffer[96]; if (!file.open(QIODevice::ReadOnly)) { - qWarning("%s: %s", qPrintable(path), qPrintable(file.errorString())); + qWarning("%s: %s", qUtf8Printable(path), + qUtf8Printable(file.errorString())); return false; } if (file.read(buffer, sizeof(buffer)) != sizeof(buffer)) { - qWarning("%s: invalid GHT file", qPrintable(path)); + qWarning("%s: invalid GHT file", qUtf8Printable(path)); return false; } @@ -202,7 +204,7 @@ bool GHPParser::readHeaderFile(const QString &ghpPath, Header &hdr) QDateTime date(QDate(Y + 2000, M, D), QTime(h, m, s), QTimeZone::utc()); if (!date.isValid()) { - qWarning("%s: invalid date", qPrintable(path)); + qWarning("%s: invalid date", qUtf8Printable(path)); return false; } diff --git a/src/data/poi.cpp b/src/data/poi.cpp index 268eaf66..1e46222e 100644 --- a/src/data/poi.cpp +++ b/src/data/poi.cpp @@ -108,8 +108,8 @@ TreeNode POI::loadDir(const QString &path) if (loadFile(fi.absoluteFilePath())) tree.addItem(fi.absoluteFilePath()); else - qWarning("%s: %s", qPrintable(fi.absoluteFilePath()), - qPrintable(_errorString)); + qWarning("%s: %s", qUtf8Printable(fi.absoluteFilePath()), + qUtf8Printable(_errorString)); } } diff --git a/src/data/slfparser.cpp b/src/data/slfparser.cpp index 14e57655..34ccd96b 100644 --- a/src/data/slfparser.cpp +++ b/src/data/slfparser.cpp @@ -3,7 +3,7 @@ void SLFParser::warning(const char *text) const { const QFile *file = static_cast(_reader.device()); - qWarning("%s:%lld: %s", qPrintable(file->fileName()), + qWarning("%s:%lld: %s", qUtf8Printable(file->fileName()), _reader.lineNumber(), text); } diff --git a/src/data/tcxparser.cpp b/src/data/tcxparser.cpp index 25970c87..c0c08377 100644 --- a/src/data/tcxparser.cpp +++ b/src/data/tcxparser.cpp @@ -4,7 +4,7 @@ void TCXParser::warning(const char *text) const { const QFile *file = static_cast(_reader.device()); - qWarning("%s:%lld: %s", qPrintable(file->fileName()), + qWarning("%s:%lld: %s", qUtf8Printable(file->fileName()), _reader.lineNumber(), text); } diff --git a/src/data/track.cpp b/src/data/track.cpp index 852e528f..bb04e4d0 100644 --- a/src/data/track.cpp +++ b/src/data/track.cpp @@ -140,8 +140,7 @@ Track::Track(const TrackData &data) : _pause(0) bool hasTime = !std::isnan(seg.time.first()); for (int j = 1; j < sd.size(); j++) { - ds = sd.at(j).coordinates().distanceTo( - sd.at(j-1).coordinates()); + ds = sd.at(j).coordinates().distanceTo(sd.at(j-1).coordinates()); seg.distance.append(seg.distance.last() + ds); if (hasTime && sd.at(j).timestamp().isValid()) { @@ -149,16 +148,16 @@ Track::Track(const TrackData &data) : _pause(0) dt = sd.at(j-1).timestamp().msecsTo( sd.at(j).timestamp()) / 1000.0; else { - qWarning("%s: %s: time skew detected", qPrintable( - _data.name()), qPrintable(sd.at(j).timestamp().toString( - Qt::ISODate))); + qWarning("%s: %s: time skew detected", + qUtf8Printable(_data.name()), + qUtf8Printable(sd.at(j).timestamp().toString(Qt::ISODate))); dt = 0; } } else { dt = NAN; if (hasTime) { qWarning("%s: missing timestamp(s), time graphs disabled", - qPrintable(_data.name())); + qUtf8Printable(_data.name())); hasTime = false; for (int i = 0; i < seg.time.size(); i++) seg.time[i] = NAN; diff --git a/src/data/waypoint.cpp b/src/data/waypoint.cpp index f747f795..0c61bdb3 100644 --- a/src/data/waypoint.cpp +++ b/src/data/waypoint.cpp @@ -37,7 +37,7 @@ void Waypoint::loadSymbolIcons(const QString &dir) QPixmap pm(files.at(i).absoluteFilePath()); if (pm.isNull()) qWarning("%s: error loading image", - qPrintable(files.at(i).absoluteFilePath())); + qUtf8Printable(files.at(i).absoluteFilePath())); else _symbolIcons.insert(files.at(i).baseName(), pm); } diff --git a/src/map/IMG/gmapdata.cpp b/src/map/IMG/gmapdata.cpp index f5239dd7..81f3d0ae 100644 --- a/src/map/IMG/gmapdata.cpp +++ b/src/map/IMG/gmapdata.cpp @@ -89,7 +89,7 @@ bool GMAPData::loadTile(const QDir &dir) if (VectorTile::isTileFile(tt)) { if (!tile->addFile(fi.absoluteFilePath(), tt)) { qWarning("%s: Invalid map tile structure", - qPrintable(dir.path())); + qUtf8Printable(dir.path())); delete tile; return false; } @@ -97,7 +97,7 @@ bool GMAPData::loadTile(const QDir &dir) } if (!tile->init()) { - qWarning("%s: Invalid map tile", qPrintable(dir.path())); + qWarning("%s: Invalid map tile", qUtf8Printable(dir.path())); delete tile; return false; } diff --git a/src/map/IMG/imgdata.cpp b/src/map/IMG/imgdata.cpp index a14cebad..9c572cf6 100644 --- a/src/map/IMG/imgdata.cpp +++ b/src/map/IMG/imgdata.cpp @@ -146,8 +146,8 @@ bool IMGData::createTileTree(QFile *file, const TileMap &tileMap) VectorTile *tile = it.value(); if (!tile->init(file)) { - qWarning("%s: %s: Invalid map tile", qPrintable(_fileName), - qPrintable(it.key())); + qWarning("%s: %s: Invalid map tile", qUtf8Printable(_fileName), + qUtf8Printable(it.key())); delete tile; continue; } diff --git a/src/map/IMG/rastertile.cpp b/src/map/IMG/rastertile.cpp index 9fa0ab41..af8d51a3 100644 --- a/src/map/IMG/rastertile.cpp +++ b/src/map/IMG/rastertile.cpp @@ -446,8 +446,8 @@ void RasterTile::fetchData(QList &polygons, if (dynamic_cast(_data)) { _file = new QFile(_data->fileName()); if (!_file->open(QIODevice::ReadOnly | QIODevice::Unbuffered)) { - qWarning("%s: %s", qPrintable(_file->fileName()), - qPrintable(_file->errorString())); + qWarning("%s: %s", qUtf8Printable(_file->fileName()), + qUtf8Printable(_file->errorString())); return; } } diff --git a/src/map/IMG/style.cpp b/src/map/IMG/style.cpp index 02a19acd..7014d2e6 100644 --- a/src/map/IMG/style.cpp +++ b/src/map/IMG/style.cpp @@ -1177,7 +1177,7 @@ bool Style::parsePolygons(SubFile *file, SubFile::Handle &hdl, if (!parsePolygon(file, hdl, section, info, type)) qWarning("%s: %x: broken polygon style", - qPrintable(file->fileName()), type); + qUtf8Printable(file->fileName()), type); } return true; @@ -1201,8 +1201,8 @@ bool Style::parseLines(SubFile *file, SubFile::Handle &hdl, ? 0x10000 | (info.type << 8) | info.subtype : (info.type << 8); if (!parseLine(file, hdl, section, info, type)) - qWarning("%s: %x: broken line style", qPrintable(file->fileName()), - type); + qWarning("%s: %x: broken line style", + qUtf8Printable(file->fileName()), type); } return true; @@ -1227,8 +1227,8 @@ bool Style::parsePoints(SubFile *file, SubFile::Handle &hdl, : (info.type << 8) | info.subtype; if (!parsePoint(file, hdl, section, info, type)) - qWarning("%s: %x: broken point style", qPrintable(file->fileName()), - type); + qWarning("%s: %x: broken point style", + qUtf8Printable(file->fileName()), type); } return true; @@ -1304,7 +1304,7 @@ bool Style::parseTYPFile(SubFile *typ) && parsePolygons(typ, hdl, polygons) && parseDrawOrder(typ, hdl, order))) { qWarning("%s: Invalid TYP file, using default style", - qPrintable(typ->fileName())); + qUtf8Printable(typ->fileName())); return false; } diff --git a/src/map/IMG/subfile.h b/src/map/IMG/subfile.h index ea868492..bc2fb723 100644 --- a/src/map/IMG/subfile.h +++ b/src/map/IMG/subfile.h @@ -27,8 +27,8 @@ public: if (!_file) { _file = new QFile(subFile->fileName()); if (!_file->open(QIODevice::ReadOnly | QIODevice::Unbuffered)) - qWarning("%s: %s", qPrintable(_file->fileName()), - qPrintable(_file->errorString())); + qWarning("%s: %s", qUtf8Printable(_file->fileName()), + qUtf8Printable(_file->errorString())); _delete = true; } _data.resize(subFile->blockSize()); diff --git a/src/map/aqmmap.cpp b/src/map/aqmmap.cpp index e2052923..ee829065 100644 --- a/src/map/aqmmap.cpp +++ b/src/map/aqmmap.cpp @@ -259,8 +259,8 @@ void AQMMap::load(const Projection &in, const Projection &out, _mapRatio = hidpi ? deviceRatio : 1.0; if (!_file.open(QIODevice::ReadOnly)) - qWarning("%s: %s", qPrintable(_file.fileName()), - qPrintable(_file.errorString())); + qWarning("%s: %s", qUtf8Printable(_file.fileName()), + qUtf8Printable(_file.errorString())); } void AQMMap::unload() diff --git a/src/map/atlas.cpp b/src/map/atlas.cpp index a9f9ef1e..74fe2baa 100644 --- a/src/map/atlas.cpp +++ b/src/map/atlas.cpp @@ -156,7 +156,8 @@ Atlas::Atlas(const QString &fileName, bool TAR, const Projection &proj, OziMap::CalibrationType type; QString cf(calibrationFile(path, type)); if (cf.isNull()) { - qWarning("%s: no calibration file found", qPrintable(path)); + qWarning("%s: no calibration file found", + qUtf8Printable(path)); continue; } map = new OziMap(cf, type, proj, this); @@ -165,8 +166,8 @@ Atlas::Atlas(const QString &fileName, bool TAR, const Projection &proj, if (map->isValid()) _maps.append(map); else { - qWarning("%s: %s", qPrintable(map->path()), - qPrintable(map->errorString())); + qWarning("%s: %s", qUtf8Printable(map->path()), + qUtf8Printable(map->errorString())); delete map; } } diff --git a/src/map/conversion.cpp b/src/map/conversion.cpp index 5e441531..f046712b 100644 --- a/src/map/conversion.cpp +++ b/src/map/conversion.cpp @@ -141,17 +141,18 @@ bool Conversion::loadList(const QString &path) bool res; if (!file.open(QFile::ReadOnly)) { - qWarning("%s: %s", qPrintable(path), qPrintable(file.errorString())); + qWarning("%s: %s", qUtf8Printable(path), + qUtf8Printable(file.errorString())); return false; } while (!csv.atEnd()) { if (!csv.readEntry(entry)) { - qWarning("%s:%d: Parse error", qPrintable(path), csv.line()); + qWarning("%s:%d: Parse error", qUtf8Printable(path), csv.line()); return false; } if (entry.size() < 26) { - qWarning("%s:%d: Invalid column count", qPrintable(path), + qWarning("%s:%d: Invalid column count", qUtf8Printable(path), csv.line() - 1); return false; } @@ -159,42 +160,42 @@ bool Conversion::loadList(const QString &path) QString name(entry.at(0)); int proj = entry.at(1).toInt(&res); if (!res) { - qWarning("%s:%d: Invalid projection code", qPrintable(path), + qWarning("%s:%d: Invalid projection code", qUtf8Printable(path), csv.line() - 1); continue; } int units = entry.at(2).toInt(&res); if (!res) { - qWarning("%s:%d: Invalid linear units code", qPrintable(path), + qWarning("%s:%d: Invalid linear units code", qUtf8Printable(path), csv.line() - 1); continue; } int transform = entry.at(3).toInt(&res); if (!res) { qWarning("%s:%d: Invalid coordinate transformation code", - qPrintable(path), csv.line() - 1); + qUtf8Printable(path), csv.line() - 1); continue; } int cs = entry.at(4).toInt(&res); if (!res) { qWarning("%s:%d: Invalid coordinate system code", - qPrintable(path), csv.line() - 1); + qUtf8Printable(path), csv.line() - 1); continue; } if (!LinearUnits(units).isValid()) { - qWarning("%s:%d: Unknown linear units code", qPrintable(path), + qWarning("%s:%d: Unknown linear units code", qUtf8Printable(path), csv.line() - 1); continue; } if (!Method(transform).isValid()) { qWarning("%s:%d: Unknown coordinate transformation code", - qPrintable(path), csv.line() - 1); + qUtf8Printable(path), csv.line() - 1); continue; } if (!CoordinateSystem(cs).isValid()) { - qWarning("%s:%d: Unknown coordinate system code", qPrintable(path), - csv.line() - 1); + qWarning("%s:%d: Unknown coordinate system code", + qUtf8Printable(path), csv.line() - 1); continue; } @@ -202,7 +203,7 @@ bool Conversion::loadList(const QString &path) int pn = projectionSetup(entry, setup); if (pn) { qWarning("%s: %d: Invalid projection parameter #%d", - qPrintable(path), csv.line(), pn); + qUtf8Printable(path), csv.line(), pn); continue; } diff --git a/src/map/dem.cpp b/src/map/dem.cpp index 0f8f0beb..844c20a7 100644 --- a/src/map/dem.cpp +++ b/src/map/dem.cpp @@ -131,8 +131,8 @@ DEM::Entry *DEM::loadTile(const Tile &tile) } else { QFile file(path); if (!file.open(QIODevice::ReadOnly)) { - qWarning("%s: %s", qPrintable(file.fileName()), - qPrintable(file.errorString())); + qWarning("%s: %s", qUtf8Printable(file.fileName()), + qUtf8Printable(file.errorString())); return new Entry(); } else return new Entry(file.readAll()); diff --git a/src/map/demloader.cpp b/src/map/demloader.cpp index a460a736..7b17898c 100644 --- a/src/map/demloader.cpp +++ b/src/map/demloader.cpp @@ -57,7 +57,7 @@ bool DEMLoader::loadTiles(const RectC &rect) /* Create the user DEM dir only when a download is requested as it will override the global DEM dir. */ if (!_dir.mkpath(_dir.absolutePath())) { - qWarning("%s: %s", qPrintable(_dir.canonicalPath()), + qWarning("%s: %s", qUtf8Printable(_dir.canonicalPath()), "Error creating DEM directory"); return false; } diff --git a/src/map/downloader.cpp b/src/map/downloader.cpp index a4f3c45e..64c13415 100644 --- a/src/map/downloader.cpp +++ b/src/map/downloader.cpp @@ -165,7 +165,7 @@ bool Downloader::doDownload(const Download &dl, const QList &headers if (!url.isValid() || !(url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("https"))) { - qWarning("%s: Invalid URL", qPrintable(url.toString())); + qWarning("%s: Invalid URL", qUtf8Printable(url.toString())); return false; } @@ -195,8 +195,8 @@ bool Downloader::doDownload(const Download &dl, const QList &headers QFile *file = new QFile(tmpName(dl.file())); if (!file->open(QIODevice::WriteOnly)) { - qWarning("%s: %s", qPrintable(file->fileName()), - qPrintable(file->errorString())); + qWarning("%s: %s", qUtf8Printable(file->fileName()), + qUtf8Printable(file->errorString())); delete file; _errorDownloads.insert(url, RETRIES); return false; diff --git a/src/map/ellipsoid.cpp b/src/map/ellipsoid.cpp index b5fa7c77..f903f252 100644 --- a/src/map/ellipsoid.cpp +++ b/src/map/ellipsoid.cpp @@ -38,36 +38,37 @@ bool Ellipsoid::loadList(const QString &path) bool res; if (!file.open(QFile::ReadOnly)) { - qWarning("%s: %s", qPrintable(path), qPrintable(file.errorString())); + qWarning("%s: %s", qUtf8Printable(path), + qUtf8Printable(file.errorString())); return false; } while (!csv.atEnd()) { if (!csv.readEntry(entry)) { - qWarning("%s:%d: Parse error", qPrintable(path), csv.line()); + qWarning("%s:%d: Parse error", qUtf8Printable(path), csv.line()); return false; } if (entry.size() < 4) { - qWarning("%s:%d: Invalid column count", qPrintable(path), + qWarning("%s:%d: Invalid column count", qUtf8Printable(path), csv.line() - 1); return false; } int id = entry.at(1).toInt(&res); if (!res) { - qWarning("%s:%d: Invalid ellipsoid code", qPrintable(path), + qWarning("%s:%d: Invalid ellipsoid code", qUtf8Printable(path), csv.line() - 1); continue; } double radius = entry.at(2).toDouble(&res); if (!res) { - qWarning("%s:%d: Invalid radius", qPrintable(path), + qWarning("%s:%d: Invalid radius", qUtf8Printable(path), csv.line() - 1); continue; } double flattening = entry.at(3).toDouble(&res); if (!res) { - qWarning("%s:%d: Invalid flattening", qPrintable(path), + qWarning("%s:%d: Invalid flattening", qUtf8Printable(path), csv.line() - 1); continue; } diff --git a/src/map/encatlas.cpp b/src/map/encatlas.cpp index 68aae8e7..fe7eea86 100644 --- a/src/map/encatlas.cpp +++ b/src/map/encatlas.cpp @@ -102,11 +102,11 @@ void ENCAtlas::addMap(const QDir &dir, const QByteArray &file, { QString path(dir.absoluteFilePath(file)); if (!QFileInfo::exists(path)) { - qWarning("%s: No such map file", qPrintable(path)); + qWarning("%s: No such map file", qUtf8Printable(path)); return; } if (!bounds.isValid()) { - qWarning("%s: Invalid map bounds", qPrintable(path)); + qWarning("%s: Invalid map bounds", qUtf8Printable(path)); return; } diff --git a/src/map/gcs.cpp b/src/map/gcs.cpp index 6593c4bc..e2a80346 100644 --- a/src/map/gcs.cpp +++ b/src/map/gcs.cpp @@ -102,96 +102,97 @@ bool GCS::loadList(const QString &path) bool res; if (!file.open(QFile::ReadOnly)) { - qWarning("%s: %s", qPrintable(path), qPrintable(file.errorString())); + qWarning("%s: %s", qUtf8Printable(path), + qUtf8Printable(file.errorString())); return false; } while (!csv.atEnd()) { if (!csv.readEntry(entry)) { - qWarning("%s:%d: Parse error", qPrintable(path), csv.line()); + qWarning("%s:%d: Parse error", qUtf8Printable(path), csv.line()); return false; } if (entry.size() < 14) { - qWarning("%s:%d: Invalid column count", qPrintable(path), + qWarning("%s:%d: Invalid column count", qUtf8Printable(path), csv.line() - 1); return false; } int id = parameter(entry.at(1), &res); if (!res) { - qWarning("%s:%d: Invalid GCS code", qPrintable(path), + qWarning("%s:%d: Invalid GCS code", qUtf8Printable(path), csv.line() - 1); continue; } int gd = parameter(entry.at(2), &res); if (!res) { - qWarning("%s:%d: Invalid geodetic datum code", qPrintable(path), + qWarning("%s:%d: Invalid geodetic datum code", qUtf8Printable(path), csv.line() - 1); continue; } int au = entry.at(3).toInt(&res); if (!res) { - qWarning("%s:%d: Invalid angular units code", qPrintable(path), + qWarning("%s:%d: Invalid angular units code", qUtf8Printable(path), csv.line() - 1); continue; } int el = entry.at(4).toInt(&res); if (!res) { - qWarning("%s:%d: Invalid ellipsoid code", qPrintable(path), + qWarning("%s:%d: Invalid ellipsoid code", qUtf8Printable(path), csv.line() - 1); continue; } int pm = entry.at(5).toInt(&res); if (!res) { - qWarning("%s:%d: Invalid prime meridian code", qPrintable(path), + qWarning("%s:%d: Invalid prime meridian code", qUtf8Printable(path), csv.line() - 1); continue; } int ct = entry.at(6).toInt(&res); if (!res) { qWarning("%s:%d: Invalid coordinates transformation code", - qPrintable(path), csv.line() - 1); + qUtf8Printable(path), csv.line() - 1); continue; } double dx = entry.at(7).toDouble(&res); if (!res) { - qWarning("%s:%d: Invalid dx", qPrintable(path), csv.line() - 1); + qWarning("%s:%d: Invalid dx", qUtf8Printable(path), csv.line() - 1); continue; } double dy = entry.at(8).toDouble(&res); if (!res) { - qWarning("%s:%d: Invalid dy", qPrintable(path), csv.line() - 1); + qWarning("%s:%d: Invalid dy", qUtf8Printable(path), csv.line() - 1); continue; } double dz = entry.at(9).toDouble(&res); if (!res) { - qWarning("%s:%d: Invalid dz", qPrintable(path), csv.line() - 1); + qWarning("%s:%d: Invalid dz", qUtf8Printable(path), csv.line() - 1); continue; } double rx = parameterd(entry.at(10), &res); if (!res) { - qWarning("%s:%d: Invalid rx", qPrintable(path), csv.line() - 1); + qWarning("%s:%d: Invalid rx", qUtf8Printable(path), csv.line() - 1); continue; } double ry = parameterd(entry.at(11), &res); if (!res) { - qWarning("%s:%d: Invalid ry", qPrintable(path), csv.line() - 1); + qWarning("%s:%d: Invalid ry", qUtf8Printable(path), csv.line() - 1); continue; } double rz = parameterd(entry.at(12), &res); if (!res) { - qWarning("%s:%d: Invalid rz", qPrintable(path), csv.line() - 1); + qWarning("%s:%d: Invalid rz", qUtf8Printable(path), csv.line() - 1); continue; } double ds = parameterd(entry.at(13), &res); if (!res) { - qWarning("%s:%d: Invalid ds", qPrintable(path), csv.line() - 1); + qWarning("%s:%d: Invalid ds", qUtf8Printable(path), csv.line() - 1); continue; } const Ellipsoid &e = Ellipsoid::ellipsoid(el); if (e.isNull()) { - qWarning("%s:%d: Unknown ellipsoid code", qPrintable(path), + qWarning("%s:%d: Unknown ellipsoid code", qUtf8Printable(path), csv.line() - 1); continue; } @@ -209,12 +210,12 @@ bool GCS::loadList(const QString &path) break; default: qWarning("%s:%d: Unknown coordinates transformation method", - qPrintable(path), csv.line() - 1); + qUtf8Printable(path), csv.line() - 1); continue; } if (!datum.isValid()) { qWarning("%s:%d: Invalid coordinates transformation parameters", - qPrintable(path), csv.line() - 1); + qUtf8Printable(path), csv.line() - 1); continue; } @@ -223,7 +224,7 @@ bool GCS::loadList(const QString &path) _gcss.append(Entry(id, gd, entry.at(0), gcs)); else qWarning("%s:%d: Unknown prime meridian/angular units code", - qPrintable(path), csv.line() - 1); + qUtf8Printable(path), csv.line() - 1); } std::sort(_gcss.begin(), _gcss.end()); diff --git a/src/map/gemfmap.cpp b/src/map/gemfmap.cpp index 1ad68d0b..729e94b9 100644 --- a/src/map/gemfmap.cpp +++ b/src/map/gemfmap.cpp @@ -190,8 +190,8 @@ void GEMFMap::load(const Projection &in, const Projection &out, _mapRatio = hidpi ? deviceRatio : 1.0; if (!_file.open(QIODevice::ReadOnly)) - qWarning("%s: %s", qPrintable(_file.fileName()), - qPrintable(_file.errorString())); + qWarning("%s: %s", qUtf8Printable(_file.fileName()), + qUtf8Printable(_file.errorString())); } void GEMFMap::unload() diff --git a/src/map/imgmap.cpp b/src/map/imgmap.cpp index 9410d555..b1c433ce 100644 --- a/src/map/imgmap.cpp +++ b/src/map/imgmap.cpp @@ -46,8 +46,8 @@ static QList overlays(const QString &fileName) if (data->isValid()) list.append(data); else { - qWarning("%s: %s", qPrintable(data->fileName()), - qPrintable(data->errorString())); + qWarning("%s: %s", qUtf8Printable(data->fileName()), + qUtf8Printable(data->errorString())); delete data; } } else diff --git a/src/map/jnxmap.cpp b/src/map/jnxmap.cpp index bfad6f50..6c232904 100644 --- a/src/map/jnxmap.cpp +++ b/src/map/jnxmap.cpp @@ -163,8 +163,8 @@ void JNXMap::load(const Projection &in, const Projection &out, _mapRatio = hidpi ? deviceRatio : 1.0; if (!_file.open(QIODevice::ReadOnly)) - qWarning("%s: %s", qPrintable(_file.fileName()), - qPrintable(_file.errorString())); + qWarning("%s: %s", qUtf8Printable(_file.fileName()), + qUtf8Printable(_file.errorString())); else readTiles(); } diff --git a/src/map/maplist.cpp b/src/map/maplist.cpp index d19f8010..bcc1dac2 100644 --- a/src/map/maplist.cpp +++ b/src/map/maplist.cpp @@ -96,9 +96,9 @@ Map *MapList::loadFile(const QString &path, const Projection &proj, bool *isDir) } } - qWarning("%s:", qPrintable(path)); + qWarning("%s:", qUtf8Printable(path)); for (int i = 0; i < errors.size(); i++) - qWarning(" %s", qPrintable(errors.at(i))); + qWarning(" %s", qUtf8Printable(errors.at(i))); return map ? map : new InvalidMap(path, "Unknown file format"); } diff --git a/src/map/mapsforge/mapdata.cpp b/src/map/mapsforge/mapdata.cpp index bae0e91a..34ee6fb1 100644 --- a/src/map/mapsforge/mapdata.cpp +++ b/src/map/mapsforge/mapdata.cpp @@ -461,8 +461,8 @@ void MapData::load() QFile file(_fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) - qWarning("%s: %s", qPrintable(file.fileName()), - qPrintable(file.errorString())); + qWarning("%s: %s", qUtf8Printable(file.fileName()), + qUtf8Printable(file.errorString())); else readSubFiles(file); } diff --git a/src/map/mapsforge/rastertile.cpp b/src/map/mapsforge/rastertile.cpp index ee42efa9..5ed23625 100644 --- a/src/map/mapsforge/rastertile.cpp +++ b/src/map/mapsforge/rastertile.cpp @@ -411,8 +411,8 @@ void RasterTile::fetchData(QList &paths, QFile file(_data->fileName()); if (!file.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) { - qWarning("%s: %s", qPrintable(file.fileName()), - qPrintable(file.errorString())); + qWarning("%s: %s", qUtf8Printable(file.fileName()), + qUtf8Printable(file.errorString())); return; } diff --git a/src/map/mapsforge/style.cpp b/src/map/mapsforge/style.cpp index bfd3ac25..f3803b73 100644 --- a/src/map/mapsforge/style.cpp +++ b/src/map/mapsforge/style.cpp @@ -85,7 +85,7 @@ const Style::Menu::Layer *Style::Menu::findLayer(const QString &id) const if (_layers.at(i).id() == id) return &_layers.at(i); - qWarning("%s: layer not found", qPrintable(id)); + qWarning("%s: layer not found", qUtf8Printable(id)); return 0; } @@ -792,8 +792,8 @@ bool Style::loadXml(const QString &path, const MapData &data, qreal ratio) } if (reader.error()) - qWarning("%s:%lld %s", qPrintable(path), reader.lineNumber(), - qPrintable(reader.errorString())); + qWarning("%s:%lld %s", qUtf8Printable(path), reader.lineNumber(), + qUtf8Printable(reader.errorString())); return !reader.error(); } diff --git a/src/map/mbtilesmap.cpp b/src/map/mbtilesmap.cpp index 1f57e24a..eb40e454 100644 --- a/src/map/mbtilesmap.cpp +++ b/src/map/mbtilesmap.cpp @@ -41,7 +41,7 @@ bool MBTilesMap::getMinZoom(int &zoom) return false; } } else { - qWarning("%s: missing minzoom metadata", qPrintable(path())); + qWarning("%s: missing minzoom metadata", qUtf8Printable(path())); zoom = OSM::ZOOMS.min(); } @@ -60,7 +60,7 @@ bool MBTilesMap::getMaxZoom(int &zoom) return false; } } else { - qWarning("%s: missing maxzoom metadata", qPrintable(path())); + qWarning("%s: missing maxzoom metadata", qUtf8Printable(path())); zoom = OSM::ZOOMS.max(); } @@ -103,7 +103,7 @@ bool MBTilesMap::getBounds() } _bounds = b; } else { - qWarning("%s: missing bounds metadata", qPrintable(path())); + qWarning("%s: missing bounds metadata", qUtf8Printable(path())); int z = _zoomsBase.first().z; QString sql = QString("SELECT min(tile_column), min(tile_row), " @@ -156,7 +156,7 @@ void MBTilesMap::getTileFormat() if (query.value(0).toString() == "pbf") _scalable = true; } else - qWarning("%s: missing tiles format metadata", qPrintable(path())); + qWarning("%s: missing tiles format metadata", qUtf8Printable(path())); } void MBTilesMap::getTilePixelRatio() @@ -177,7 +177,7 @@ void MBTilesMap::getName() if (query.first()) _name = query.value(0).toString(); else { - qWarning("%s: missing map name", qPrintable(path())); + qWarning("%s: missing map name", qUtf8Printable(path())); _name = Util::file2name(path()); } } diff --git a/src/map/oruxmap.cpp b/src/map/oruxmap.cpp index 4155f103..37ba5ec4 100644 --- a/src/map/oruxmap.cpp +++ b/src/map/oruxmap.cpp @@ -514,8 +514,8 @@ QPixmap OruxMap::tile(const Zoom &z, int x, int y) const query.exec(); if (!query.first()) { - qWarning("%s: SQL %d-%d-%d: not found", qPrintable(name()), z.zoom, - x, y); + qWarning("%s: SQL %d-%d-%d: not found", qUtf8Printable(name()), + z.zoom, x, y); return QPixmap(); } else { QImage img(QImage::fromData(query.value(0).toByteArray())); @@ -526,8 +526,8 @@ QPixmap OruxMap::tile(const Zoom &z, int x, int y) const + QString::number(y) + ".omc2"); QString path(z.set.absoluteFilePath(fileName)); if (!QFileInfo::exists(path)) { - qWarning("%s: %s: not found", qPrintable(name()), - qPrintable(fileName)); + qWarning("%s: %s: not found", qUtf8Printable(name()), + qUtf8Printable(fileName)); return QPixmap(); } else { QImage img(path); diff --git a/src/map/ozf.cpp b/src/map/ozf.cpp index 9cfef190..4d7225d1 100644 --- a/src/map/ozf.cpp +++ b/src/map/ozf.cpp @@ -117,7 +117,7 @@ bool OZF::readHeaders() if (!initOZF3()) return false; } else { - qWarning("%s: not a OZF2/OZF3 file", qPrintable(_file.fileName())); + qWarning("%s: not a OZF2/OZF3 file", qUtf8Printable(_file.fileName())); return false; } diff --git a/src/map/ozimap.cpp b/src/map/ozimap.cpp index d4206f11..b65531bd 100644 --- a/src/map/ozimap.cpp +++ b/src/map/ozimap.cpp @@ -288,7 +288,7 @@ bool OziMap::setTileInfo(const QStringList &tiles, const QString &path) if (_tile.size.isValid()) return true; else - qWarning("%s: error reading tile image", qPrintable(tile)); + qWarning("%s: error reading tile image", qUtf8Printable(tile)); } } @@ -310,16 +310,16 @@ void OziMap::load(const Projection &in, const Projection &out, if (_tar) { Q_ASSERT(!_tar->isOpen()); if (!_tar->open()) { - qWarning("%s: %s", qPrintable(_tar->fileName()), - qPrintable(_tar->errorString())); + qWarning("%s: %s", qUtf8Printable(_tar->fileName()), + qUtf8Printable(_tar->errorString())); return; } } if (_ozf) { Q_ASSERT(!_ozf->isOpen()); if (!_ozf->open()) { - qWarning("%s: %s", qPrintable(_ozf->fileName()), - qPrintable(_ozf->errorString())); + qWarning("%s: %s", qUtf8Printable(_ozf->fileName()), + qUtf8Printable(_ozf->errorString())); return; } } @@ -370,7 +370,7 @@ void OziMap::drawTiled(QPainter *painter, const QRectF &rect) const pixmap = QPixmap(tileName); if (pixmap.isNull()) - qWarning("%s: error loading tile image", qPrintable(tileName)); + qWarning("%s: error loading tile image", qUtf8Printable(tileName)); else { pixmap.setDevicePixelRatio(_mapRatio); QPointF tp(tl.x() + i * ts.width(), tl.y() + j * ts.height()); @@ -404,7 +404,7 @@ void OziMap::drawOZF(QPainter *painter, const QRectF &rect) const } if (pixmap.isNull()) - qWarning("%s: error loading tile image", qPrintable(key)); + qWarning("%s: error loading tile image", qUtf8Printable(key)); else { pixmap.setDevicePixelRatio(_mapRatio); QPointF tp(tl.x() + i * ts.width(), tl.y() + j * ts.height()); diff --git a/src/map/pcs.cpp b/src/map/pcs.cpp index bebe36ce..083a9c75 100644 --- a/src/map/pcs.cpp +++ b/src/map/pcs.cpp @@ -31,17 +31,18 @@ bool PCS::loadList(const QString &path) bool res; if (!file.open(QFile::ReadOnly)) { - qWarning("%s: %s", qPrintable(path), qPrintable(file.errorString())); + qWarning("%s: %s", qUtf8Printable(path), + qUtf8Printable(file.errorString())); return false; } while (!csv.atEnd()) { if (!csv.readEntry(entry)) { - qWarning("%s:%d: Parse error", qPrintable(path), csv.line()); + qWarning("%s:%d: Parse error", qUtf8Printable(path), csv.line()); return false; } if (entry.size() < 4) { - qWarning("%s:%d: Invalid column count", qPrintable(path), + qWarning("%s:%d: Invalid column count", qUtf8Printable(path), csv.line() - 1); return false; } @@ -49,30 +50,30 @@ bool PCS::loadList(const QString &path) QString name(entry.at(0)); int id = entry.at(1).toInt(&res); if (!res) { - qWarning("%s:%d: Invalid PCS code", qPrintable(path), + qWarning("%s:%d: Invalid PCS code", qUtf8Printable(path), csv.line() - 1); continue; } int gcs = entry.at(2).toInt(&res); if (!res) { - qWarning("%s:%d: Invalid GCS code", qPrintable(path), + qWarning("%s:%d: Invalid GCS code", qUtf8Printable(path), csv.line() - 1); continue; } int proj = entry.at(3).toInt(&res); if (!res) { - qWarning("%s:%d: Invalid projection code", qPrintable(path), + qWarning("%s:%d: Invalid projection code", qUtf8Printable(path), csv.line() - 1); continue; } if (GCS::gcs(gcs).isNull()) { - qWarning("%s:%d: Unknown GCS code", qPrintable(path), + qWarning("%s:%d: Unknown GCS code", qUtf8Printable(path), csv.line() - 1); continue; } if (Conversion::conversion(proj).isNull()) { - qWarning("%s:%d: Unknown projection code", qPrintable(path), + qWarning("%s:%d: Unknown projection code", qUtf8Printable(path), csv.line() - 1); continue; } diff --git a/src/map/prjfile.cpp b/src/map/prjfile.cpp index 4b7b380c..e085b724 100644 --- a/src/map/prjfile.cpp +++ b/src/map/prjfile.cpp @@ -28,7 +28,7 @@ static Conversion::Method projectionMethod(const QString &name) if (!name.compare(methods[i].name, Qt::CaseInsensitive)) return methods[i].id; - qWarning("%s: unknown projection", qPrintable(name)); + qWarning("%s: unknown projection", qUtf8Printable(name)); return Conversion::Method(); } @@ -66,7 +66,7 @@ static void setParameter(Conversion::Setup *setup, const QString &name, else if (!name.compare("azimuth", Qt::CaseInsensitive)) setup->setStandardParallel2(val); else - qWarning("%s: unknown projection parameter", qPrintable(name)); + qWarning("%s: unknown projection parameter", qUtf8Printable(name)); } PRJFile::Token PRJFile::keyword(CTX &ctx) diff --git a/src/map/qctmap.cpp b/src/map/qctmap.cpp index 4373b1be..2901c00a 100644 --- a/src/map/qctmap.cpp +++ b/src/map/qctmap.cpp @@ -362,8 +362,8 @@ void QCTMap::load(const Projection &in, const Projection &out, _mapRatio = hidpi ? deviceRatio : 1.0; if (!_file.open(QIODevice::ReadOnly)) - qWarning("%s: %s", qPrintable(_file.fileName()), - qPrintable(_file.errorString())); + qWarning("%s: %s", qUtf8Printable(_file.fileName()), + qUtf8Printable(_file.errorString())); } void QCTMap::unload() @@ -483,7 +483,7 @@ void QCTMap::draw(QPainter *painter, const QRectF &rect, Flags flags) } if (pixmap.isNull()) - qWarning("%s: error loading tile image", qPrintable(key)); + qWarning("%s: error loading tile image", qUtf8Printable(key)); else { pixmap.setDevicePixelRatio(_mapRatio); QPointF tp(tl.x() + i * ts.width(), tl.y() + j * ts.height()); diff --git a/src/map/rmap.cpp b/src/map/rmap.cpp index ef1ac79f..85e60d22 100644 --- a/src/map/rmap.cpp +++ b/src/map/rmap.cpp @@ -366,8 +366,8 @@ void RMap::load(const Projection &in, const Projection &out, qreal deviceRatio, _mapRatio = hidpi ? deviceRatio : 1.0; if (!_file.open(QIODevice::ReadOnly)) - qWarning("%s: %s", qPrintable(_file.fileName()), - qPrintable(_file.errorString())); + qWarning("%s: %s", qUtf8Printable(_file.fileName()), + qUtf8Printable(_file.errorString())); } void RMap::unload() @@ -455,7 +455,7 @@ void RMap::draw(QPainter *painter, const QRectF &rect, Flags flags) } if (pixmap.isNull()) - qWarning("%s: error loading tile image", qPrintable(key)); + qWarning("%s: error loading tile image", qUtf8Printable(key)); else { pixmap.setDevicePixelRatio(_mapRatio); QPointF tp(tl.x() + i * ts.width(), tl.y() + j * ts.height()); diff --git a/src/map/tar.cpp b/src/map/tar.cpp index 1fcb8a52..7e8dd54d 100644 --- a/src/map/tar.cpp +++ b/src/map/tar.cpp @@ -103,7 +103,7 @@ bool Tar::loadTmi(const QString &path) 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); + qWarning("%s:%d: syntax error", qUtf8Printable(path), ln); _index.clear(); return false; } diff --git a/src/map/tileloader.cpp b/src/map/tileloader.cpp index 4872689c..65b9257f 100644 --- a/src/map/tileloader.cpp +++ b/src/map/tileloader.cpp @@ -56,7 +56,8 @@ TileLoader::TileLoader(const QString &dir, QObject *parent) : QObject(parent), _urlType(XYZ), _dir(dir) { if (!QDir().mkpath(_dir)) - qWarning("%s: %s", qPrintable(_dir), "Error creating tiles directory"); + qWarning("%s: %s", qUtf8Printable(_dir), + "Error creating tiles directory"); _downloader = new Downloader(this); connect(_downloader, &Downloader::finished, this, &TileLoader::finished); From e2764b623225f845c114937636d18afe9d059531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 4 Jan 2025 12:00:57 +0100 Subject: [PATCH 2/4] Use a smaller block size for filesystem reads --- src/map/IMG/subfile.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/map/IMG/subfile.h b/src/map/IMG/subfile.h index bc2fb723..167fee74 100644 --- a/src/map/IMG/subfile.h +++ b/src/map/IMG/subfile.h @@ -5,8 +5,7 @@ #include #include "imgdata.h" - -#define BLOCK_BITS 12 /* 4096 bytes */ +#define BLOCK_BITS 9 /* 512 bytes */ namespace IMG { From c678866c2296ddbf5a0f3a148a98da2962b83b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 4 Jan 2025 16:43:20 +0100 Subject: [PATCH 3/4] Do the special number transformation only when the label ends with a number --- src/map/IMG/lblfile.cpp | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/map/IMG/lblfile.cpp b/src/map/IMG/lblfile.cpp index 6f39cc70..ec58c081 100644 --- a/src/map/IMG/lblfile.cpp +++ b/src/map/IMG/lblfile.cpp @@ -40,11 +40,10 @@ static QString capitalized(const QString &str) return ret; } -static QByteArray ft2m(const QByteArray &str) +static QByteArray ft2m(const QByteArray &str, bool *ok) { - bool ok; - double number = str.toDouble(&ok); - return ok ? QByteArray::number(qRound(number * 0.3048)) : str; + double number = str.toDouble(ok); + return *ok ? QByteArray::number(qRound(number * 0.3048)) : str; } @@ -123,6 +122,7 @@ Label LBLFile::str2label(const QVector &str, bool capitalize, QByteArray label, shieldLabel; QByteArray *bap = &label; int split = -1; + bool ok; for (int i = 0; i < str.size(); i++) { const quint8 &c = str.at(i); @@ -137,7 +137,7 @@ Label LBLFile::str2label(const QVector &str, bool capitalize, bap = &label; else { if (!bap->isEmpty()) - bap->append('\n'); + bap->append(' '); if (c == 0x1f && split < 0) split = bap->size(); } @@ -150,10 +150,14 @@ Label LBLFile::str2label(const QVector &str, bool capitalize, bap->append(c); } - if (split >= 0) - label = label.left(split) + ft2m(label.mid(split)); - else if (convert) - label = ft2m(label); + if (split >= 0) { + QByteArray num(ft2m(label.mid(split), &ok)); + if (ok) { + QByteArray name(label.left(split - 1)); + label = name.isEmpty() ? num : name + "\n" + num; + } + } else if (convert) + label = ft2m(label, &ok); QString text(_codec.toString(label)); return Label(capitalize && isAllUpperCase(text) ? capitalized(text) : text, Shield(shieldType, _codec.toString(shieldLabel))); @@ -193,6 +197,7 @@ Label LBLFile::label6b(const SubFile *file, Handle &fileHdl, quint32 size, Charset charset = Normal; quint8 b1, b2, b3; int split = -1; + bool ok; for (quint32 i = 0; i < size; i = i + 3) { if (!(file->readByte(fileHdl, &b1) && file->readByte(fileHdl, &b2) @@ -203,10 +208,14 @@ Label LBLFile::label6b(const SubFile *file, Handle &fileHdl, quint32 size, for (int cpt = 0; cpt < 4; cpt++) { if (c[cpt] > 0x2f || (charset == Normal && c[cpt] == 0x1d)) { - if (split >= 0) - label = label.left(split) + ft2m(label.mid(split)); - else if (convert) - label = ft2m(label); + if (split >= 0) { + QByteArray num(ft2m(label.mid(split), &ok)); + if (ok) { + QByteArray name(label.left(split - 1)); + label = name.isEmpty() ? num : name + "\n" + num; + } + } else if (convert) + label = ft2m(label, &ok); QString text(QString::fromLatin1(label)); return Label(capitalize && isAllUpperCase(text) ? capitalized(text) : text, Shield(shieldType, shieldLabel)); @@ -222,7 +231,7 @@ Label LBLFile::label6b(const SubFile *file, Handle &fileHdl, quint32 size, bap = &label; else { if (!bap->isEmpty()) - bap->append('\n'); + bap->append(' '); if (c[cpt] == 0x1f && split < 0) split = bap->size(); } From b3fd46a225b2fd5349095b5f8daaaa8468ac3d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 4 Jan 2025 17:40:15 +0100 Subject: [PATCH 4/4] Only do the units conversion on specific point types --- src/map/IMG/lblfile.cpp | 4 ++-- src/map/IMG/rgnfile.cpp | 3 ++- src/map/IMG/style.h | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/map/IMG/lblfile.cpp b/src/map/IMG/lblfile.cpp index ec58c081..6b4d1640 100644 --- a/src/map/IMG/lblfile.cpp +++ b/src/map/IMG/lblfile.cpp @@ -150,7 +150,7 @@ Label LBLFile::str2label(const QVector &str, bool capitalize, bap->append(c); } - if (split >= 0) { + if (convert && split >= 0) { QByteArray num(ft2m(label.mid(split), &ok)); if (ok) { QByteArray name(label.left(split - 1)); @@ -208,7 +208,7 @@ Label LBLFile::label6b(const SubFile *file, Handle &fileHdl, quint32 size, for (int cpt = 0; cpt < 4; cpt++) { if (c[cpt] > 0x2f || (charset == Normal && c[cpt] == 0x1d)) { - if (split >= 0) { + if (convert && split >= 0) { QByteArray num(ft2m(label.mid(split), &ok)); if (ok) { QByteArray name(label.left(split - 1)); diff --git a/src/map/IMG/rgnfile.cpp b/src/map/IMG/rgnfile.cpp index 62815046..ef629710 100644 --- a/src/map/IMG/rgnfile.cpp +++ b/src/map/IMG/rgnfile.cpp @@ -516,7 +516,8 @@ bool RGNFile::pointObjects(Handle &hdl, const SubDiv *subdiv, if (lbl && (labelPtr & 0x3FFFFF)) point.label = lbl->label(lblHdl, labelPtr & 0x3FFFFF, labelPtr & 0x400000, !(Style::isCountry(point.type) - || Style::isState(point.type)), Style::isSpot(point.type)); + || Style::isState(point.type)), Style::isSpot(point.type) + || Style::isSummit(point.type)); point.id = pointId(pos, point.type, point.label.text()); points->append(point); diff --git a/src/map/IMG/style.h b/src/map/IMG/style.h index d08c70c1..88fae052 100644 --- a/src/map/IMG/style.h +++ b/src/map/IMG/style.h @@ -134,6 +134,8 @@ public: {return (type == TYPE(0x16) || type == 0x10a03);} static bool isSpot(quint32 type) {return (type == TYPE(0x62) || type == TYPE(0x63));} + static bool isSummit(quint32 type) + {return (type == 0x6616);} static bool isMajorRoad(quint32 type) {return (type <= TYPE(0x04));} static bool isCountry(quint32 type)