From 8b8fc42f2c6b08097bcd04038ed7f12667a90875 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 31 Oct 2023 16:26:04 +0100 Subject: [PATCH] Move Converter class, in eponymous example, to a file of its own There's more details coming and it's good hygiene anyway. Pick-to: 6.6 6.5 Task-number: QTBUG-111228 Change-Id: Ief3acf6e508bc93eaa8490f6c49300b25c1d3556 Reviewed-by: Juha Vuolle Reviewed-by: Thiago Macieira --- .../serialization/convert/CMakeLists.txt | 2 +- .../corelib/serialization/convert/convert.pro | 1 + .../serialization/convert/converter.cpp | 25 +++++++++++++++++++ .../corelib/serialization/convert/main.cpp | 21 ---------------- 4 files changed, 27 insertions(+), 22 deletions(-) create mode 100644 examples/corelib/serialization/convert/converter.cpp diff --git a/examples/corelib/serialization/convert/CMakeLists.txt b/examples/corelib/serialization/convert/CMakeLists.txt index d948d76ace..1d20fb07bd 100644 --- a/examples/corelib/serialization/convert/CMakeLists.txt +++ b/examples/corelib/serialization/convert/CMakeLists.txt @@ -20,7 +20,7 @@ qt_standard_project_setup() qt_add_executable(convert cborconverter.cpp cborconverter.h - converter.h + converter.cpp converter.h datastreamconverter.cpp datastreamconverter.h debugtextdumper.cpp debugtextdumper.h jsonconverter.cpp jsonconverter.h diff --git a/examples/corelib/serialization/convert/convert.pro b/examples/corelib/serialization/convert/convert.pro index c4c6e6722a..7592de7a22 100644 --- a/examples/corelib/serialization/convert/convert.pro +++ b/examples/corelib/serialization/convert/convert.pro @@ -11,6 +11,7 @@ target.path = $$[QT_INSTALL_EXAMPLES]/corelib/serialization/convert INSTALLS += target SOURCES += main.cpp \ + converter.cpp \ cborconverter.cpp \ datastreamconverter.cpp \ debugtextdumper.cpp \ diff --git a/examples/corelib/serialization/convert/converter.cpp b/examples/corelib/serialization/convert/converter.cpp new file mode 100644 index 0000000000..7ecd4134e9 --- /dev/null +++ b/examples/corelib/serialization/convert/converter.cpp @@ -0,0 +1,25 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "converter.h" + +Converter::Converter() +{ + converters().append(this); +} + +Converter::~Converter() +{ + converters().removeAll(this); +} + +QList &Converter::converters() +{ + Q_CONSTINIT static QList store; + return store; +} + +const QList &Converter::allConverters() +{ + return converters(); +} diff --git a/examples/corelib/serialization/convert/main.cpp b/examples/corelib/serialization/convert/main.cpp index a5b2c78f65..8f58043ad4 100644 --- a/examples/corelib/serialization/convert/main.cpp +++ b/examples/corelib/serialization/convert/main.cpp @@ -14,27 +14,6 @@ using namespace Qt::StringLiterals; -Converter::Converter() -{ - converters().append(this); -} - -Converter::~Converter() -{ - converters().removeAll(this); -} - -QList &Converter::converters() -{ - Q_CONSTINIT static QList store; - return store; -} - -const QList &Converter::allConverters() -{ - return converters(); -} - static const Converter *prepareConverter(QString format, Converter::Direction direction, QFile *stream) {