From b85a9d0ee16e3bdc817eb1e8a8f85026e631b401 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 31 Mar 2023 13:38:07 +0200 Subject: [PATCH] Move QZipReader/Writer from QtGui to QtCore These classes depend only on Core, not Gui. This allows dropping the dependency of tst_qxmlstream and tst_qzip on QtGui, and prevents a tst_qxmlstream FTBFS when building with QT_NO_TEXTODFWRITER. Symbols move from QtGui to QtCore, but the classes are private API, so not under BC constraints. The classes are not used outside qtbase, so no other in-tree users need porting. Task-number: QTBUG-3897 Change-Id: Ifa148f43ec139d7f9ac1f3893e2fcf4640e3c60c Reviewed-by: Qt CI Bot Reviewed-by: Thiago Macieira --- src/corelib/CMakeLists.txt | 1 + src/{gui/text => corelib/io}/qzip.cpp | 7 +------ src/{gui/text => corelib/io}/qzipreader_p.h | 8 ++------ src/{gui/text => corelib/io}/qzipwriter_p.h | 8 ++------ src/gui/CMakeLists.txt | 3 --- src/gui/text/qtextodfwriter.cpp | 3 ++- tests/auto/corelib/io/CMakeLists.txt | 3 +++ tests/auto/{gui/text => corelib/io}/qzip/.gitignore | 0 .../{gui/text => corelib/io}/qzip/CMakeLists.txt | 3 +-- .../text => corelib/io}/qzip/testdata/symlink.zip | Bin .../{gui/text => corelib/io}/qzip/testdata/test.zip | Bin .../auto/{gui/text => corelib/io}/qzip/tst_qzip.cpp | 0 .../corelib/serialization/qxmlstream/CMakeLists.txt | 2 +- .../serialization/qxmlstream/tst_qxmlstream.cpp | 2 +- tests/auto/gui/text/CMakeLists.txt | 1 - 15 files changed, 14 insertions(+), 27 deletions(-) rename src/{gui/text => corelib/io}/qzip.cpp (99%) rename src/{gui/text => corelib/io}/qzipreader_p.h (92%) rename src/{gui/text => corelib/io}/qzipwriter_p.h (92%) rename tests/auto/{gui/text => corelib/io}/qzip/.gitignore (100%) rename tests/auto/{gui/text => corelib/io}/qzip/CMakeLists.txt (92%) rename tests/auto/{gui/text => corelib/io}/qzip/testdata/symlink.zip (100%) rename tests/auto/{gui/text => corelib/io}/qzip/testdata/test.zip (100%) rename tests/auto/{gui/text => corelib/io}/qzip/tst_qzip.cpp (100%) diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index a1cb450627a..489647d1a4c 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -145,6 +145,7 @@ qt_internal_add_module(Core io/qurlidna.cpp io/qurlquery.cpp io/qurlquery.h io/qurlrecode.cpp + io/qzipreader_p.h io/qzipwriter_p.h io/qzip.cpp kernel/qabstracteventdispatcher.cpp kernel/qabstracteventdispatcher.h kernel/qabstracteventdispatcher_p.h kernel/qabstractnativeeventfilter.cpp kernel/qabstractnativeeventfilter.h kernel/qapplicationstatic.h diff --git a/src/gui/text/qzip.cpp b/src/corelib/io/qzip.cpp similarity index 99% rename from src/gui/text/qzip.cpp rename to src/corelib/io/qzip.cpp index 7fd96363df3..d4976691c99 100644 --- a/src/gui/text/qzip.cpp +++ b/src/corelib/io/qzip.cpp @@ -1,12 +1,9 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#include - -#ifndef QT_NO_TEXTODFWRITER - #include "qzipreader_p.h" #include "qzipwriter_p.h" + #include #include #include @@ -1348,5 +1345,3 @@ void QZipWriter::close() } QT_END_NAMESPACE - -#endif // QT_NO_TEXTODFWRITER diff --git a/src/gui/text/qzipreader_p.h b/src/corelib/io/qzipreader_p.h similarity index 92% rename from src/gui/text/qzipreader_p.h rename to src/corelib/io/qzipreader_p.h index 2e8d6bc951f..e6ddd0dc996 100644 --- a/src/gui/text/qzipreader_p.h +++ b/src/corelib/io/qzipreader_p.h @@ -4,10 +4,7 @@ #ifndef QZIPREADER_H #define QZIPREADER_H -#include -#include - -#ifndef QT_NO_TEXTODFWRITER +#include // // W A R N I N G @@ -28,7 +25,7 @@ QT_BEGIN_NAMESPACE class QZipReaderPrivate; -class Q_GUI_EXPORT QZipReader +class Q_CORE_EXPORT QZipReader { public: explicit QZipReader(const QString &fileName, QIODevice::OpenMode mode = QIODevice::ReadOnly ); @@ -87,5 +84,4 @@ Q_DECLARE_TYPEINFO(QZipReader::Status, Q_PRIMITIVE_TYPE); QT_END_NAMESPACE -#endif // QT_NO_TEXTODFWRITER #endif // QZIPREADER_H diff --git a/src/gui/text/qzipwriter_p.h b/src/corelib/io/qzipwriter_p.h similarity index 92% rename from src/gui/text/qzipwriter_p.h rename to src/corelib/io/qzipwriter_p.h index 6c1ef5d848a..770e6118b60 100644 --- a/src/gui/text/qzipwriter_p.h +++ b/src/corelib/io/qzipwriter_p.h @@ -3,9 +3,7 @@ #ifndef QZIPWRITER_H #define QZIPWRITER_H -#include - -#ifndef QT_NO_TEXTODFWRITER +#include // // W A R N I N G @@ -25,8 +23,7 @@ QT_BEGIN_NAMESPACE class QZipWriterPrivate; - -class Q_GUI_EXPORT QZipWriter +class Q_CORE_EXPORT QZipWriter { public: explicit QZipWriter(const QString &fileName, QIODevice::OpenMode mode = (QIODevice::WriteOnly | QIODevice::Truncate) ); @@ -77,5 +74,4 @@ private: QT_END_NAMESPACE -#endif // QT_NO_TEXTODFWRITER #endif // QZIPWRITER_H diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index a8ddd7f93cc..714a7ee058c 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -646,9 +646,6 @@ qt_internal_extend_target(Gui CONDITION QT_FEATURE_harfbuzz AND UIKIT qt_internal_extend_target(Gui CONDITION QT_FEATURE_textodfwriter SOURCES text/qtextodfwriter.cpp text/qtextodfwriter_p.h - text/qzip.cpp - text/qzipreader_p.h - text/qzipwriter_p.h ) qt_internal_extend_target(Gui CONDITION QT_FEATURE_textmarkdownreader diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 546859037c4..b50771c12f0 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -18,9 +18,10 @@ #include "qtexttable.h" #include "qtextcursor.h" #include "qtextimagehandler_p.h" -#include "qzipwriter_p.h" #include +#include + QT_BEGIN_NAMESPACE diff --git a/tests/auto/corelib/io/CMakeLists.txt b/tests/auto/corelib/io/CMakeLists.txt index 4100ce17d56..22eb2148f8c 100644 --- a/tests/auto/corelib/io/CMakeLists.txt +++ b/tests/auto/corelib/io/CMakeLists.txt @@ -64,3 +64,6 @@ endif() if(QT_FEATURE_settings AND TARGET Qt::Gui) add_subdirectory(qsettings) endif() +if(QT_FEATURE_private_tests) + add_subdirectory(qzip) +endif() diff --git a/tests/auto/gui/text/qzip/.gitignore b/tests/auto/corelib/io/qzip/.gitignore similarity index 100% rename from tests/auto/gui/text/qzip/.gitignore rename to tests/auto/corelib/io/qzip/.gitignore diff --git a/tests/auto/gui/text/qzip/CMakeLists.txt b/tests/auto/corelib/io/qzip/CMakeLists.txt similarity index 92% rename from tests/auto/gui/text/qzip/CMakeLists.txt rename to tests/auto/corelib/io/qzip/CMakeLists.txt index 73bf0fda7fa..615e6355843 100644 --- a/tests/auto/gui/text/qzip/CMakeLists.txt +++ b/tests/auto/corelib/io/qzip/CMakeLists.txt @@ -15,7 +15,6 @@ qt_internal_add_test(tst_qzip SOURCES tst_qzip.cpp LIBRARIES - Qt::Gui - Qt::GuiPrivate + Qt::CorePrivate TESTDATA ${test_data} ) diff --git a/tests/auto/gui/text/qzip/testdata/symlink.zip b/tests/auto/corelib/io/qzip/testdata/symlink.zip similarity index 100% rename from tests/auto/gui/text/qzip/testdata/symlink.zip rename to tests/auto/corelib/io/qzip/testdata/symlink.zip diff --git a/tests/auto/gui/text/qzip/testdata/test.zip b/tests/auto/corelib/io/qzip/testdata/test.zip similarity index 100% rename from tests/auto/gui/text/qzip/testdata/test.zip rename to tests/auto/corelib/io/qzip/testdata/test.zip diff --git a/tests/auto/gui/text/qzip/tst_qzip.cpp b/tests/auto/corelib/io/qzip/tst_qzip.cpp similarity index 100% rename from tests/auto/gui/text/qzip/tst_qzip.cpp rename to tests/auto/corelib/io/qzip/tst_qzip.cpp diff --git a/tests/auto/corelib/serialization/qxmlstream/CMakeLists.txt b/tests/auto/corelib/serialization/qxmlstream/CMakeLists.txt index 3304097d4b7..e7dd05944ea 100644 --- a/tests/auto/corelib/serialization/qxmlstream/CMakeLists.txt +++ b/tests/auto/corelib/serialization/qxmlstream/CMakeLists.txt @@ -15,6 +15,6 @@ qt_internal_add_test(tst_qxmlstream tst_qxmlstream.cpp LIBRARIES Qt::Network - Qt::GuiPrivate + Qt::CorePrivate TESTDATA ${test_data} ) diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp index ea538ca79dd..5e8533abef1 100644 --- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include "qc14n.h" diff --git a/tests/auto/gui/text/CMakeLists.txt b/tests/auto/gui/text/CMakeLists.txt index 2ba0a96774a..bad13de7dc6 100644 --- a/tests/auto/gui/text/CMakeLists.txt +++ b/tests/auto/gui/text/CMakeLists.txt @@ -26,7 +26,6 @@ endif() if(QT_FEATURE_private_tests) add_subdirectory(qfontcache) add_subdirectory(qtextlayout) - add_subdirectory(qzip) add_subdirectory(qtextodfwriter) endif() if(TARGET Qt::Xml)