From a982cd02ec3e1ff37c248ea0d3c36e79f3a45ad5 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Sat, 10 Oct 2020 19:56:52 +0200 Subject: Disable foreach also in examples and tests --- CMakeLists.txt | 6 +++++- examples/example_7_archiveHandling/example_7_archiveHandling.cpp | 9 ++++++--- src/CMakeLists.txt | 3 --- tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54665ec8..ccdeab65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,11 @@ option(BUILD_EXAMPLES "Build examples." ON) option(WITH_GSTREAMER "Build with GStreamer support for Jingle" OFF) -add_definitions(-DQURL_NO_CAST_FROM_STRING -DQT_NO_CAST_TO_ASCII) +add_definitions( + -DQURL_NO_CAST_FROM_STRING + -DQT_NO_CAST_TO_ASCII + -DQT_NO_FOREACH +) add_subdirectory(src) diff --git a/examples/example_7_archiveHandling/example_7_archiveHandling.cpp b/examples/example_7_archiveHandling/example_7_archiveHandling.cpp index 282ec0df..d3968fb4 100644 --- a/examples/example_7_archiveHandling/example_7_archiveHandling.cpp +++ b/examples/example_7_archiveHandling/example_7_archiveHandling.cpp @@ -104,7 +104,7 @@ void xmppClient::archiveListReceived(const QList &chats, const logEnd("no items"); } else { logEnd(QString("items %1 to %2 of %3").arg(QString::number(rsmReply.index()), QString::number(rsmReply.index() + chats.size() - 1), QString::number(rsmReply.count()))); - foreach (const QXmppArchiveChat &chat, chats) { + for (const auto &chat : chats) { qDebug("chat start %s", qPrintable(chat.start().toString())); // NOTE: to actually retrieve conversations, uncomment this //archiveManager->retrieveCollection(chat.with(), chat.start()); @@ -127,8 +127,11 @@ void xmppClient::archiveListReceived(const QList &chats, const void xmppClient::archiveChatReceived(const QXmppArchiveChat &chat, const QXmppResultSetReply &rsmReply) { - logEnd(QString("chat received, RSM count %1").arg(QString::number(rsmReply.count()))); - foreach (const QXmppArchiveMessage &msg, chat.messages()) { + logEnd(QString("chat received, RSM count %1") + .arg(QString::number(rsmReply.count()))); + + const auto messages = chat.messages(); + for (const auto &msg : messages) { qDebug("example_7_archiveHandling : %s", qPrintable(msg.body())); } } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fd50d39d..e35e2c57 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,9 +2,6 @@ option(BUILD_SHARED "Build SHARED library" ON) add_definitions(-DQXMPP_BUILD) -# disable Q_FOREACH() -add_definitions(-DQT_NO_FOREACH) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/base) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/client) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/server) diff --git a/tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp b/tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp index 497560f7..34cd3ff5 100644 --- a/tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp +++ b/tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp @@ -510,7 +510,7 @@ void tst_QXmppRegistrationManager::sendStreamFeaturesToManager(bool registration // hacky hack to include stream namespace QByteArray manipulatedXml = buffer.data(); manipulatedXml.replace("stream:", QByteArray()); - manipulatedXml.insert(9, QStringLiteral(" xmlns=\"%1\"").arg("http://etherx.jabber.org/streams")); + manipulatedXml.insert(9, QByteArrayLiteral(" xmlns=\"http://etherx.jabber.org/streams\"")); QDomDocument doc; doc.setContent(manipulatedXml, true); @@ -522,7 +522,7 @@ void tst_QXmppRegistrationManager::sendStreamFeaturesToManager(bool registration void tst_QXmppRegistrationManager::setManagerConfig(const QString &username, const QString &server, const QString &password) { - client.connectToServer(username + QStringLiteral("@") + server, password); + client.connectToServer(username + u'@' + server, password); client.disconnectFromServer(); } -- cgit v1.2.3