Commit ffd772d7 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix some qt6 compile error

parent 78f939cd
Pipeline #160730 passed with stages
in 12 minutes and 38 seconds
......@@ -9,7 +9,6 @@
#include <KPublicTransport/Location>
#include <QJsonArray>
#include <QJsonObject>
#include <QMetaEnum>
......
......@@ -12,6 +12,7 @@
#include <KPublicTransport/Line>
#include <unordered_map>
#include <QJsonArray>
namespace KPublicTransport {
......
......@@ -502,7 +502,7 @@ static std::vector<Path> parsePaths(const QJsonArray &polyL, const std::vector<L
// crdEncF: 1-dimensional, always 0?
std::vector<PathSection> sections;
sections.reserve(std::max(0, ppLocRefL.size() - 1));
sections.reserve(std::max<int>(0, ppLocRefL.size() - 1));
int prevPpIdx = 0;
QPointF prevCoord;
for (const auto &ppLocRefV : ppLocRefL) {
......@@ -803,10 +803,14 @@ QDateTime HafasMgateParser::parseDateTime(const QString &date, const QJsonValue
int dayOffset = 0;
if (timeStr.size() > 6) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
dayOffset = timeStr.leftRef(timeStr.size() - 6).toInt();
#else
dayOffset = QStringView(timeStr).left(timeStr.size() - 6).toInt();
#endif
}
auto dt = QDateTime::fromString(date + timeStr.rightRef(6), QStringLiteral("yyyyMMddhhmmss"));
auto dt = QDateTime::fromString(date + QStringView(timeStr).right(6), QStringLiteral("yyyyMMddhhmmss"));
dt = dt.addDays(dayOffset);
if (!tzOffset.isNull() && !tzOffset.isUndefined()) {
dt.setOffsetFromUtc(tzOffset.toInt() * 60);
......
......@@ -110,11 +110,19 @@ QXmlStreamAttributes ScopedXmlStreamReader::attributes() const
return m_reader.attributes();
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QStringRef ScopedXmlStreamReader::name() const
{
Q_ASSERT_X(!m_subReaderLock, "ScopedXmlStreamReader", "Operations while a sub-reader is active are forbidden!");
return m_reader.name();
}
#else
QStringView ScopedXmlStreamReader::name() const
{
Q_ASSERT_X(!m_subReaderLock, "ScopedXmlStreamReader", "Operations while a sub-reader is active are forbidden!");
return m_reader.name();
}
#endif
QString ScopedXmlStreamReader::readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
{
......
......@@ -52,7 +52,11 @@ public:
/** Same as QXmlStreamReader::attributes. */
QXmlStreamAttributes attributes() const;
/** Same as QXmlStreamReader::name. */
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QStringRef name() const;
#else
QStringView name() const;
#endif
/** Same as QXmlStreamReader::readElementText. */
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour = QXmlStreamReader::ErrorOnUnexpectedElement);
......
......@@ -8,9 +8,9 @@
#define KPUBLICTRANSPORT_COVERAGEAREA_H
#include "datatypes.h"
#include <QStringList>
class QJsonObject;
class QStringList;
namespace KPublicTransport {
......
......@@ -8,6 +8,7 @@
#define KPUBLICTRANSPORT_LOCATION_H
#include "datatypes.h"
#include <QVariant>
class QJsonArray;
class QJsonObject;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment