1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00

Compare commits

...

3 Commits

Author SHA1 Message Date
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
10 changed files with 78 additions and 38 deletions

View File

@ -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,6 +512,7 @@ macx {
}
win32 {
CONFIG += no_batch
RESOURCES += theme-color.qrc
QMAKE_TARGET_DESCRIPTION = GPXSee

View File

@ -2026,11 +2026,13 @@ void GUI::updateWindowTitle()
#ifndef Q_OS_ANDROID
void GUI::updateRecentFiles(const QString &fileName)
{
QFileInfo fi(fileName);
QString canonicalFileName(fi.canonicalFilePath());
QAction *a = 0;
QList<QAction *> actions(_recentFilesActionGroup->actions());
for (int i = 0; i < actions.size(); i++) {
if (actions.at(i)->text() == fileName) {
if (actions.at(i)->text() == canonicalFileName) {
a = actions.at(i);
break;
}
@ -2044,7 +2046,7 @@ void GUI::updateRecentFiles(const QString &fileName)
actions = _recentFilesActionGroup->actions();
QAction *before = actions.size() ? actions.last() : _recentFilesEnd;
_recentFilesMenu->insertAction(before,
new QAction(fileName, _recentFilesActionGroup));
new QAction(canonicalFileName, _recentFilesActionGroup));
_recentFilesMenu->setEnabled(true);
}

View File

@ -1,6 +1,7 @@
#include <QTextCodec>
#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

View File

@ -3,19 +3,26 @@
#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

@ -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;