From 6d778d84fd2faac6a899a1c70f2dcb9bd4e0b164 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Wed, 17 Mar 2021 18:54:34 +0100 Subject: Fix build with Qt 5.7 We only test 5.9 with the CI... :/ --- src/base/QXmppGlobal.h.in | 4 ++++ src/base/QXmppUtils.cpp | 11 ++++++++--- .../tst_qxmppbitsofbinarycontentid.cpp | 2 ++ tests/qxmppmessage/tst_qxmppmessage.cpp | 2 +- tests/qxmppstreaminitiationiq/tst_qxmppstreaminitiationiq.cpp | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/base/QXmppGlobal.h.in b/src/base/QXmppGlobal.h.in index 7982f3b9..5f94196d 100644 --- a/src/base/QXmppGlobal.h.in +++ b/src/base/QXmppGlobal.h.in @@ -73,5 +73,9 @@ inline QLatin1String QXmppVersion() #define Q_DECL_ENUMERATOR_DEPRECATED_X(msg) #endif +#ifndef QT_WARNING_DISABLE_DEPRECATED +#define QT_WARNING_DISABLE_DEPRECATED +#endif + #endif // QXMPPGLOBAL_H diff --git a/src/base/QXmppUtils.cpp b/src/base/QXmppUtils.cpp index e17f95ec..3a858a30 100644 --- a/src/base/QXmppUtils.cpp +++ b/src/base/QXmppUtils.cpp @@ -126,8 +126,13 @@ QDateTime QXmppUtils::datetimeFromString(const QString &str) /// QString QXmppUtils::datetimeToString(const QDateTime &dt) { - if (dt.time().msec()) + if (dt.time().msec()) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) return dt.toUTC().toString(Qt::ISODateWithMs); +#else + return dt.toUTC().toString("yyyy-MM-ddTHH:mm:ss.zzzZ"); +#endif + } return dt.toUTC().toString(Qt::ISODate); } @@ -144,14 +149,14 @@ int QXmppUtils::timezoneOffsetFromString(const QString &str) return 0; // No offset from UTC - if (match.captured(1) == u'Z') + if (match.captured(1) == QChar(u'Z')) return 0; // Calculate offset const int offset = match.captured(3).toInt() * 3600 + match.captured(4).toInt() * 60; - if (match.captured(2) == u'-') + if (match.captured(2) == QChar(u'-')) return -offset; return offset; } diff --git a/tests/qxmppbitsofbinarycontentid/tst_qxmppbitsofbinarycontentid.cpp b/tests/qxmppbitsofbinarycontentid/tst_qxmppbitsofbinarycontentid.cpp index 37223ba8..5205d7ea 100644 --- a/tests/qxmppbitsofbinarycontentid/tst_qxmppbitsofbinarycontentid.cpp +++ b/tests/qxmppbitsofbinarycontentid/tst_qxmppbitsofbinarycontentid.cpp @@ -26,6 +26,8 @@ #include "util.h" #include +Q_DECLARE_METATYPE(QCryptographicHash::Algorithm) + class tst_QXmppBitsOfBinaryContentId : public QObject { Q_OBJECT diff --git a/tests/qxmppmessage/tst_qxmppmessage.cpp b/tests/qxmppmessage/tst_qxmppmessage.cpp index 5e75a116..42255c57 100644 --- a/tests/qxmppmessage/tst_qxmppmessage.cpp +++ b/tests/qxmppmessage/tst_qxmppmessage.cpp @@ -1096,7 +1096,7 @@ void tst_QXmppMessage::testMixInvitation() QXmppMessage message; parsePacket(message, xml); - QVERIFY(message.mixInvitation()); + QVERIFY(message.mixInvitation().has_value()); serializePacket(message, xml); } diff --git a/tests/qxmppstreaminitiationiq/tst_qxmppstreaminitiationiq.cpp b/tests/qxmppstreaminitiationiq/tst_qxmppstreaminitiationiq.cpp index 79b4292c..c755e3b3 100644 --- a/tests/qxmppstreaminitiationiq/tst_qxmppstreaminitiationiq.cpp +++ b/tests/qxmppstreaminitiationiq/tst_qxmppstreaminitiationiq.cpp @@ -49,7 +49,7 @@ void tst_QXmppStreamInitiationIq::testFileInfo_data() QTest::newRow("normal") << QByteArray("") - << QDateTime() + << QDateTime().toUTC() << QString() << QByteArray() << QString("test.txt") -- cgit v1.2.3