diff options
author | Juha Vuolle <juha.vuolle@qt.io> | 2023-03-09 09:15:05 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-03-18 17:08:48 +0000 |
commit | e94e68167b4cd5776e67250559b8c2301e34b862 (patch) | |
tree | 395bf57e1d87ad5262983e09f03c9634984d32cc | |
parent | 496ec8193f9d413f1279b7173931c92aaf07ebd6 (diff) |
Revamp scxml ftpclient example
Task-number: QTBUG-111323
Change-Id: Ie6b75b2712ecd16defc216d00ab39b7e9f8045cd
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 3cb2fa15fc9b73453ada4b36577322bbea86c52c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | examples/scxml/ftpclient/CMakeLists.txt | 8 | ||||
-rw-r--r-- | examples/scxml/ftpclient/doc/src/ftpclient.qdoc | 2 | ||||
-rw-r--r-- | examples/scxml/ftpclient/ftpcontrolchannel.cpp | 5 | ||||
-rw-r--r-- | examples/scxml/ftpclient/ftpcontrolchannel.h | 8 | ||||
-rw-r--r-- | examples/scxml/ftpclient/ftpdatachannel.cpp | 4 | ||||
-rw-r--r-- | examples/scxml/ftpclient/ftpdatachannel.h | 13 | ||||
-rw-r--r-- | examples/scxml/ftpclient/main.cpp | 6 | ||||
-rw-r--r-- | examples/scxml/ftpclient/simpleftp.scxml | 2 |
8 files changed, 25 insertions, 23 deletions
diff --git a/examples/scxml/ftpclient/CMakeLists.txt b/examples/scxml/ftpclient/CMakeLists.txt index bac0db7..d93e1e9 100644 --- a/examples/scxml/ftpclient/CMakeLists.txt +++ b/examples/scxml/ftpclient/CMakeLists.txt @@ -1,11 +1,9 @@ -# Copyright (C) 2022 The Qt Company Ltd. +# Copyright (C) 2023 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(ftpclient LANGUAGES CXX) -set(CMAKE_AUTOMOC ON) - if(NOT DEFINED INSTALL_EXAMPLESDIR) set(INSTALL_EXAMPLESDIR "examples") endif() @@ -14,6 +12,8 @@ set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/ftpclient") find_package(Qt6 REQUIRED COMPONENTS Core Network Scxml) +qt_standard_project_setup() + qt_add_executable(ftpclient ftpcontrolchannel.cpp ftpcontrolchannel.h ftpdatachannel.cpp ftpdatachannel.h @@ -25,7 +25,7 @@ set_target_properties(ftpclient PROPERTIES MACOSX_BUNDLE TRUE ) -target_link_libraries(ftpclient PUBLIC +target_link_libraries(ftpclient PRIVATE Qt6::Core Qt6::Network Qt6::Scxml diff --git a/examples/scxml/ftpclient/doc/src/ftpclient.qdoc b/examples/scxml/ftpclient/doc/src/ftpclient.qdoc index 7248c27..5f2cc07 100644 --- a/examples/scxml/ftpclient/doc/src/ftpclient.qdoc +++ b/examples/scxml/ftpclient/doc/src/ftpclient.qdoc @@ -1,4 +1,4 @@ -// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! diff --git a/examples/scxml/ftpclient/ftpcontrolchannel.cpp b/examples/scxml/ftpclient/ftpcontrolchannel.cpp index 3d89520..d52a1e3 100644 --- a/examples/scxml/ftpclient/ftpcontrolchannel.cpp +++ b/examples/scxml/ftpclient/ftpcontrolchannel.cpp @@ -1,8 +1,9 @@ -// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "ftpcontrolchannel.h" -#include <QCoreApplication> + +#include <QtCore/qcoreapplication.h> FtpControlChannel::FtpControlChannel(QObject *parent) : QObject(parent) { diff --git a/examples/scxml/ftpclient/ftpcontrolchannel.h b/examples/scxml/ftpclient/ftpcontrolchannel.h index 46dc2e8..b577dd0 100644 --- a/examples/scxml/ftpclient/ftpcontrolchannel.h +++ b/examples/scxml/ftpclient/ftpcontrolchannel.h @@ -1,12 +1,12 @@ -// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef FTPCONTROLCHANNEL_H #define FTPCONTROLCHANNEL_H -#include <QHostAddress> -#include <QObject> -#include <QTcpSocket> +#include <QtNetwork/qhostaddress.h> +#include <QtNetwork/qtcpsocket.h> +#include <QtCore/qobject.h> class FtpControlChannel : public QObject { diff --git a/examples/scxml/ftpclient/ftpdatachannel.cpp b/examples/scxml/ftpclient/ftpdatachannel.cpp index ad7b234..83ef872 100644 --- a/examples/scxml/ftpclient/ftpdatachannel.cpp +++ b/examples/scxml/ftpclient/ftpdatachannel.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "ftpdatachannel.h" @@ -7,7 +7,7 @@ FtpDataChannel::FtpDataChannel(QObject *parent) : QObject(parent) { connect(&m_server, &QTcpServer::newConnection, this, [this]() { m_socket.reset(m_server.nextPendingConnection()); - connect(m_socket.data(), &QTcpSocket::readyRead, [this]() { + connect(m_socket.get(), &QTcpSocket::readyRead, this, [this]() { emit dataReceived(m_socket->readAll()); }); }); diff --git a/examples/scxml/ftpclient/ftpdatachannel.h b/examples/scxml/ftpclient/ftpdatachannel.h index acda77b..da356a8 100644 --- a/examples/scxml/ftpclient/ftpdatachannel.h +++ b/examples/scxml/ftpclient/ftpdatachannel.h @@ -1,13 +1,14 @@ -// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef FTPDATACHANNEL_H #define FTPDATACHANNEL_H -#include <QObject> -#include <QScopedPointer> -#include <QTcpServer> -#include <QTcpSocket> +#include <QtCore/qobject.h> +#include <QtNetwork/qtcpserver.h> +#include <QtNetwork/qtcpsocket.h> + +#include <memory> class FtpDataChannel : public QObject { @@ -39,7 +40,7 @@ signals: private: QTcpServer m_server; - QScopedPointer<QTcpSocket> m_socket; + std::unique_ptr<QTcpSocket> m_socket; }; #endif // FTPDATACHANNEL_H diff --git a/examples/scxml/ftpclient/main.cpp b/examples/scxml/ftpclient/main.cpp index 88e390b..9159c2b 100644 --- a/examples/scxml/ftpclient/main.cpp +++ b/examples/scxml/ftpclient/main.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "ftpcontrolchannel.h" #include "ftpdatachannel.h" #include "simpleftp.h" -#include <QCoreApplication> +#include <QtCore/qcoreapplication.h> #include <iostream> @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) // Connect to our own local FTP server controlChannel.connectToServer(server); - QObject::connect(&controlChannel, &FtpControlChannel::opened, + QObject::connect(&controlChannel, &FtpControlChannel::opened, &dataChannel, [&](const QHostAddress &address, int) { dataChannel.listen(address); commands[1].args = dataChannel.portspec(); diff --git a/examples/scxml/ftpclient/simpleftp.scxml b/examples/scxml/ftpclient/simpleftp.scxml index dd00703..0e788bc 100644 --- a/examples/scxml/ftpclient/simpleftp.scxml +++ b/examples/scxml/ftpclient/simpleftp.scxml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- -// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause --> <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="FtpClient" |