diff --git a/gpxsee.pro b/gpxsee.pro index b59722c1..b1a5179e 100644 --- a/gpxsee.pro +++ b/gpxsee.pro @@ -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 diff --git a/src/common/textcodec.cpp b/src/common/textcodec.cpp index 36b66ff5..46f9709d 100644 --- a/src/common/textcodec.cpp +++ b/src/common/textcodec.cpp @@ -1,6 +1,7 @@ -#include #include "textcodec.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) + static QTextCodec *codec(int mib) { QTextCodec *c = QTextCodec::codecForMib(mib); @@ -10,6 +11,10 @@ static QTextCodec *codec(int mib) return c; } +TextCodec::TextCodec() : _codec(0) +{ +} + TextCodec::TextCodec(int codepage) { switch (codepage) { @@ -64,7 +69,30 @@ TextCodec::TextCodec(int codepage) } } -QString TextCodec::toString(const QByteArray &ba) const +QString TextCodec::toString(const QByteArray &ba) { return _codec ? _codec->toUnicode(ba) : QString::fromUtf8(ba); } + +#else // QT 6.5 + +TextCodec::TextCodec() +{ +} + +TextCodec::TextCodec(int codepage) +{ + if (codepage != 65001) { + QByteArray cp(QByteArray("CP") + QByteArray::number(codepage)); + _decoder = QStringDecoder(cp.constData()); + + if (!_decoder.isValid()) + qWarning("%d: Unknown codepage, using UTF-8", codepage); + } +} + +QString TextCodec::toString(const QByteArray &ba) +{ + return _decoder.isValid() ? _decoder.decode(ba) : QString::fromUtf8(ba); +} +#endif // QT 6.5 diff --git a/src/common/textcodec.h b/src/common/textcodec.h index 9cb68067..7dd9cb25 100644 --- a/src/common/textcodec.h +++ b/src/common/textcodec.h @@ -3,19 +3,26 @@ #include #include - -class QTextCodec; +#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) +#include +#else // QT 6.5 +#include +#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 diff --git a/src/map/IMG/lblfile.cpp b/src/map/IMG/lblfile.cpp index 9f29e394..0975a792 100644 --- a/src/map/IMG/lblfile.cpp +++ b/src/map/IMG/lblfile.cpp @@ -138,7 +138,7 @@ void LBLFile::clear() } Label LBLFile::str2label(const QVector &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 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 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: diff --git a/src/map/IMG/lblfile.h b/src/map/IMG/lblfile.h index e3a01201..0203257a 100644 --- a/src/map/IMG/lblfile.h +++ b/src/map/IMG/lblfile.h @@ -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 &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); diff --git a/src/map/IMG/netfile.cpp b/src/map/IMG/netfile.cpp index 9d5a603a..e37b27fe 100644 --- a/src/map/IMG/netfile.cpp +++ b/src/map/IMG/netfile.cpp @@ -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 *lines) const { diff --git a/src/map/IMG/netfile.h b/src/map/IMG/netfile.h index a1fb4735..bf63a0de 100644 --- a/src/map/IMG/netfile.h +++ b/src/map/IMG/netfile.h @@ -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 *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, diff --git a/src/map/IMG/rgnfile.cpp b/src/map/IMG/rgnfile.cpp index ae7a7f81..0de976ba 100644 --- a/src/map/IMG/rgnfile.cpp +++ b/src/map/IMG/rgnfile.cpp @@ -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 *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 *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 *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 *points) const + LBLFile *lbl, Handle &lblHdl, QList *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 *lines) const { quint32 size, blockIndexId; diff --git a/src/map/IMG/rgnfile.h b/src/map/IMG/rgnfile.h index 87836dbb..528e94a0 100644 --- a/src/map/IMG/rgnfile.h +++ b/src/map/IMG/rgnfile.h @@ -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 *polys) const; bool pointObjects(Handle &hdl, const SubDiv *subdiv, SegmentType segmentType, - const LBLFile *lbl, Handle &lblHdl, QList *points) const; + LBLFile *lbl, Handle &lblHdl, QList *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 *polys) const; - bool extPointObjects(Handle &hdl, const SubDiv *subdiv, const LBLFile *lbl, + bool extPointObjects(Handle &hdl, const SubDiv *subdiv, LBLFile *lbl, Handle &lblHdl, QList *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 *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;