summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2019-11-07 17:26:55 +0100
committerSona Kurazyan <sona.kurazyan@qt.io>2020-01-06 18:13:01 +0100
commit82d02b7b95908dec16e41c5af1c63579729c589b (patch)
tree6f78be54709ea918c63e265c61d236be88fbb1f0
parent844ef184e8021237280a45ead04a3ab39cefa657 (diff)
Deprecate SAX classes in Qt XML
Deprecated the SAX classes and disabled or replaced their uses in tests if applicable. Removed the saxbookmarks example, no point in keeping examples for the deprecated code. [ChangeLog][QtXml] SAX classes are now deprecated. Use QXmlStreamReader, QXmlStreamWriter in QtCore instead. Task-number: QTBUG-76177 Change-Id: Ic171d62fa0527b0f36f94cf09a69586092269957 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
-rw-r--r--examples/xml/saxbookmarks/doc/images/saxbookmarks-example.pngbin26219 -> 0 bytes
-rw-r--r--examples/xml/saxbookmarks/doc/src/saxbookmarks.qdoc41
-rw-r--r--examples/xml/saxbookmarks/jennifer.xbel69
-rw-r--r--examples/xml/saxbookmarks/main.cpp62
-rw-r--r--examples/xml/saxbookmarks/mainwindow.cpp177
-rw-r--r--examples/xml/saxbookmarks/mainwindow.h80
-rw-r--r--examples/xml/saxbookmarks/saxbookmarks.pro15
-rw-r--r--examples/xml/saxbookmarks/xbelgenerator.cpp124
-rw-r--r--examples/xml/saxbookmarks/xbelgenerator.h78
-rw-r--r--examples/xml/saxbookmarks/xbelhandler.cpp160
-rw-r--r--examples/xml/saxbookmarks/xbelhandler.h88
-rw-r--r--examples/xml/xml.pro1
-rw-r--r--src/xml/dom/qdom.cpp37
-rw-r--r--src/xml/dom/qdom.h12
-rw-r--r--src/xml/dom/qdom_p.h5
-rw-r--r--src/xml/dom/qdomhelpers.cpp22
-rw-r--r--src/xml/dom/qdomhelpers_p.h23
-rw-r--r--src/xml/sax/qxml.cpp38
-rw-r--r--src/xml/sax/qxml.h70
-rw-r--r--src/xml/sax/qxml_p.h9
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp69
-rw-r--r--tests/auto/xml/dom/qdom/tst_qdom.cpp36
-rw-r--r--tests/auto/xml/sax/qxml/tst_qxml.cpp7
-rw-r--r--tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp8
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp10
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/parser/parser.h6
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp9
27 files changed, 293 insertions, 963 deletions
diff --git a/examples/xml/saxbookmarks/doc/images/saxbookmarks-example.png b/examples/xml/saxbookmarks/doc/images/saxbookmarks-example.png
deleted file mode 100644
index 54d793be56..0000000000
--- a/examples/xml/saxbookmarks/doc/images/saxbookmarks-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/xml/saxbookmarks/doc/src/saxbookmarks.qdoc b/examples/xml/saxbookmarks/doc/src/saxbookmarks.qdoc
deleted file mode 100644
index 0cd89e641e..0000000000
--- a/examples/xml/saxbookmarks/doc/src/saxbookmarks.qdoc
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example saxbookmarks
- \title SAX Bookmarks Example
- \brief Demonstrates how to read XBEL files.
- \ingroup xml-examples
-
- This example uses Qt's SAX API to read and parse the files. The DOM Bookmarks
- example provides an alternative way to read this type of file.
-
- \image saxbookmarks-example.png
-
- See the \l{XML Bookmark Exchange Language Resource Page} for more
- information about XBEL files.
-*/
diff --git a/examples/xml/saxbookmarks/jennifer.xbel b/examples/xml/saxbookmarks/jennifer.xbel
deleted file mode 100644
index 2501c118af..0000000000
--- a/examples/xml/saxbookmarks/jennifer.xbel
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE xbel>
-<xbel version="1.0">
- <folder folded="no">
- <title>Qt Resources</title>
- <bookmark href="http://qt.io/">
- <title>Qt home page</title>
- </bookmark>
- <bookmark href="https://www.qt.io/partners/">
- <title>Qt Partners</title>
- </bookmark>
- <bookmark href="https://www.qt.io/qt-training/">
- <title>Training</title>
- </bookmark>
- <bookmark href="http://doc.qt.io/">
- <title>Qt 5 documentation</title>
- </bookmark>
- <bookmark href="http://qt-project.org/faq/">
- <title>Frequently Asked Questions</title>
- </bookmark>
- <folder folded="yes">
- <title>Community Resources</title>
- <bookmark href="http://www.qtcentre.org/content/">
- <title>Qt Centre</title>
- </bookmark>
- <bookmark href="http://www.qtforum.org/">
- <title>QtForum.org</title>
- </bookmark>
- <bookmark href="http://digitalfanatics.org/projects/qt_tutorial/">
- <title>The Independent Qt Tutorial</title>
- </bookmark>
- <bookmark href="http://www.qtforum.de/">
- <title>German Qt Forum</title>
- </bookmark>
- <bookmark href="http://www.korone.net/">
- <title>Korean Qt Community Site</title>
- </bookmark>
- <bookmark href="http://prog.org.ru/">
- <title>Russian Qt Forum</title>
- </bookmark>
- </folder>
- </folder>
- <folder folded="no">
- <title>Online Dictionaries</title>
- <bookmark href="http://www.dictionary.com/">
- <title>Dictionary.com</title>
- </bookmark>
- <bookmark href="http://www.m-w.com/">
- <title>Merriam-Webster Online</title>
- </bookmark>
- <bookmark href="http://dictionary.cambridge.org/">
- <title>Cambridge Dictionaries Online</title>
- </bookmark>
- <bookmark href="http://www.onelook.com/">
- <title>OneLook Dictionary Search</title>
- </bookmark>
- <separator/>
- <bookmark href="http://dict.tu-chemnitz.de/">
- <title>TU Chemnitz German-English Dictionary</title>
- </bookmark>
- <separator/>
- <bookmark href="http://atilf.atilf.fr/tlf.htm">
- <title>Trésor de la Langue Française informatisé</title>
- </bookmark>
- <bookmark href="http://dictionnaires.atilf.fr/dictionnaires/ACADEMIE/">
- <title>Dictionnaire de l'Académie Française</title>
- </bookmark>
- </folder>
-</xbel>
diff --git a/examples/xml/saxbookmarks/main.cpp b/examples/xml/saxbookmarks/main.cpp
deleted file mode 100644
index 8e577ca700..0000000000
--- a/examples/xml/saxbookmarks/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- MainWindow mainWin;
- mainWin.show();
- mainWin.open();
- return app.exec();
-}
diff --git a/examples/xml/saxbookmarks/mainwindow.cpp b/examples/xml/saxbookmarks/mainwindow.cpp
deleted file mode 100644
index 8b7733081f..0000000000
--- a/examples/xml/saxbookmarks/mainwindow.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "mainwindow.h"
-#include "xbelgenerator.h"
-#include "xbelhandler.h"
-
-MainWindow::MainWindow()
-{
- QStringList labels;
- labels << tr("Title") << tr("Location");
-
- treeWidget = new QTreeWidget;
- treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch);
- treeWidget->setHeaderLabels(labels);
-#if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_CLIPBOARD)
- treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(treeWidget, &QWidget::customContextMenuRequested,
- this, &MainWindow::onCustomContextMenuRequested);
-#endif
- setCentralWidget(treeWidget);
-
- createMenus();
-
- statusBar()->showMessage(tr("Ready"));
-
- setWindowTitle(tr("SAX Bookmarks"));
- const QSize availableSize = screen()->availableGeometry().size();
- resize(availableSize.width() / 2, availableSize.height() / 3);
-}
-
-#if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_CLIPBOARD)
-void MainWindow::onCustomContextMenuRequested(const QPoint &pos)
-{
- const QTreeWidgetItem *item = treeWidget->itemAt(pos);
- if (!item)
- return;
- const QString url = item->text(1);
- QMenu contextMenu;
- QAction *copyAction = contextMenu.addAction(tr("Copy Link to Clipboard"));
- QAction *openAction = contextMenu.addAction(tr("Open"));
- QAction *action = contextMenu.exec(treeWidget->viewport()->mapToGlobal(pos));
- if (action == copyAction)
- QGuiApplication::clipboard()->setText(url);
- else if (action == openAction)
- QDesktopServices::openUrl(QUrl(url));
-}
-#endif // !QT_NO_CONTEXTMENU && !QT_NO_CLIPBOARD
-
-void MainWindow::open()
-{
- QString fileName =
- QFileDialog::getOpenFileName(this, tr("Open Bookmark File"),
- QDir::currentPath(),
- tr("XBEL Files (*.xbel *.xml)"));
- if (fileName.isEmpty())
- return;
-
- treeWidget->clear();
-
- XbelHandler handler(treeWidget);
- QXmlSimpleReader reader;
- reader.setContentHandler(&handler);
- reader.setErrorHandler(&handler);
-
- QFile file(fileName);
- if (!file.open(QFile::ReadOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("SAX Bookmarks"),
- tr("Cannot read file %1:\n%2.")
- .arg(QDir::toNativeSeparators(fileName),
- file.errorString()));
- return;
- }
-
- QXmlInputSource xmlInputSource(&file);
- if (reader.parse(xmlInputSource))
- statusBar()->showMessage(tr("File loaded"), 2000);
-}
-
-void MainWindow::saveAs()
-{
- QString fileName =
- QFileDialog::getSaveFileName(this, tr("Save Bookmark File"),
- QDir::currentPath(),
- tr("XBEL Files (*.xbel *.xml)"));
- if (fileName.isEmpty())
- return;
-
- QFile file(fileName);
- if (!file.open(QFile::WriteOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("SAX Bookmarks"),
- tr("Cannot write file %1:\n%2.")
- .arg(QDir::toNativeSeparators(fileName),
- file.errorString()));
- return;
- }
-
- XbelGenerator generator(treeWidget);
- if (generator.write(&file))
- statusBar()->showMessage(tr("File saved"), 2000);
-}
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About SAX Bookmarks"),
- tr("The <b>SAX Bookmarks</b> example demonstrates how to use Qt's "
- "SAX classes to read XML documents and how to generate XML by "
- "hand."));
-}
-
-void MainWindow::createMenus()
-{
- QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
- QAction *openAct = fileMenu->addAction(tr("&Open..."), this, &MainWindow::open);
- openAct->setShortcuts(QKeySequence::Open);
-
- QAction *saveAsAct = fileMenu->addAction(tr("&Save As..."), this, &MainWindow::saveAs);
- saveAsAct->setShortcuts(QKeySequence::SaveAs);
-
- QAction *exitAct = fileMenu->addAction(tr("E&xit"), this, &QWidget::close);
- exitAct->setShortcuts(QKeySequence::Quit);
-
- menuBar()->addSeparator();
-
- QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(tr("&About"), this, &MainWindow::about);
- helpMenu->addAction(tr("About &Qt"), qApp, &QCoreApplication::quit);
-}
diff --git a/examples/xml/saxbookmarks/mainwindow.h b/examples/xml/saxbookmarks/mainwindow.h
deleted file mode 100644
index 20a11bb202..0000000000
--- a/examples/xml/saxbookmarks/mainwindow.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QTreeWidget;
-QT_END_NAMESPACE
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
-public slots:
- void open();
- void saveAs();
- void about();
-#if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_CLIPBOARD)
- void onCustomContextMenuRequested(const QPoint &pos);
-#endif
-private:
- void createMenus();
-
- QTreeWidget *treeWidget;
-};
-
-#endif
diff --git a/examples/xml/saxbookmarks/saxbookmarks.pro b/examples/xml/saxbookmarks/saxbookmarks.pro
deleted file mode 100644
index af2a124a13..0000000000
--- a/examples/xml/saxbookmarks/saxbookmarks.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-HEADERS = mainwindow.h \
- xbelgenerator.h \
- xbelhandler.h
-SOURCES = main.cpp \
- mainwindow.cpp \
- xbelgenerator.cpp \
- xbelhandler.cpp
-QT += xml widgets
-requires(qtConfig(filedialog))
-
-EXAMPLE_FILES = frank.xbel jennifer.xbel
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/xml/saxbookmarks
-INSTALLS += target
diff --git a/examples/xml/saxbookmarks/xbelgenerator.cpp b/examples/xml/saxbookmarks/xbelgenerator.cpp
deleted file mode 100644
index 77cb6748fe..0000000000
--- a/examples/xml/saxbookmarks/xbelgenerator.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "xbelgenerator.h"
-
-XbelGenerator::XbelGenerator(const QTreeWidget *treeWidget)
- : treeWidget(treeWidget)
-{
-}
-
-bool XbelGenerator::write(QIODevice *device)
-{
- out.setDevice(device);
- out.setCodec("UTF-8");
- out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- << "<!DOCTYPE xbel>\n"
- << "<xbel version=\"1.0\">\n";
-
- for (int i = 0; i < treeWidget->topLevelItemCount(); ++i)
- generateItem(treeWidget->topLevelItem(i), 1);
-
- out << "</xbel>\n";
- return true;
-}
-
-QString XbelGenerator::indent(int depth)
-{
- const int IndentSize = 4;
- return QString(IndentSize * depth, ' ');
-}
-
-QString XbelGenerator::escapedText(const QString &str)
-{
- QString result = str;
- result.replace('&', "&amp;");
- result.replace('<', "&lt;");
- result.replace('>', "&gt;");
- return result;
-}
-
-QString XbelGenerator::escapedAttribute(const QString &str)
-{
- QString result = escapedText(str);
- result.replace(QLatin1Char('"'), "&quot;");
- result.prepend(QLatin1Char('"'));
- result.append(QLatin1Char('"'));
- return result;
-}
-
-void XbelGenerator::generateItem(const QTreeWidgetItem *item, int depth)
-{
- QString tagName = item->data(0, Qt::UserRole).toString();
- if (tagName == QLatin1String("folder")) {
- bool folded = !item->isExpanded();
- out << indent(depth) << "<folder folded=\"" << (folded ? "yes" : "no")
- << "\">\n"
- << indent(depth + 1) << "<title>" << escapedText(item->text(0))
- << "</title>\n";
-
- for (int i = 0; i < item->childCount(); ++i)
- generateItem(item->child(i), depth + 1);
-
- out << indent(depth) << "</folder>\n";
- } else if (tagName == QLatin1String("bookmark")) {
- out << indent(depth) << "<bookmark";
- if (!item->text(1).isEmpty())
- out << " href=" << escapedAttribute(item->text(1));
- out << ">\n"
- << indent(depth + 1) << "<title>" << escapedText(item->text(0))
- << "</title>\n"
- << indent(depth) << "</bookmark>\n";
- } else if (tagName == QLatin1String("separator")) {
- out << indent(depth) << "<separator/>\n";
- }
-}
diff --git a/examples/xml/saxbookmarks/xbelgenerator.h b/examples/xml/saxbookmarks/xbelgenerator.h
deleted file mode 100644
index abfabfd75c..0000000000
--- a/examples/xml/saxbookmarks/xbelgenerator.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef XBELGENERATOR_H
-#define XBELGENERATOR_H
-
-#include <QTextStream>
-
-QT_BEGIN_NAMESPACE
-class QTreeWidget;
-class QTreeWidgetItem;
-QT_END_NAMESPACE
-
-class XbelGenerator
-{
-public:
- explicit XbelGenerator(const QTreeWidget *treeWidget);
-
- bool write(QIODevice *device);
-
-private:
- static QString indent(int indentLevel);
- static QString escapedText(const QString &str);
- static QString escapedAttribute(const QString &str);
- void generateItem(const QTreeWidgetItem *item, int depth);
-
- const QTreeWidget *treeWidget;
- QTextStream out;
-};
-
-#endif
diff --git a/examples/xml/saxbookmarks/xbelhandler.cpp b/examples/xml/saxbookmarks/xbelhandler.cpp
deleted file mode 100644
index 62dfbf9482..0000000000
--- a/examples/xml/saxbookmarks/xbelhandler.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "xbelhandler.h"
-
-static inline QString versionAttribute() { return QStringLiteral("version"); }
-static inline QString hrefAttribute() { return QStringLiteral("href"); }
-static inline QString foldedAttribute() { return QStringLiteral("folded"); }
-
-XbelHandler::XbelHandler(QTreeWidget *treeWidget)
- : treeWidget(treeWidget)
-{
- item = 0;
- metXbelTag = false;
-
- QStyle *style = treeWidget->style();
-
- folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon),
- QIcon::Normal, QIcon::Off);
- folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon),
- QIcon::Normal, QIcon::On);
- bookmarkIcon.addPixmap(style->standardPixmap(QStyle::SP_FileIcon));
-}
-
-bool XbelHandler::startElement(const QString & /* namespaceURI */,
- const QString & /* localName */,
- const QString &qName,
- const QXmlAttributes &attributes)
-{
- if (!metXbelTag && qName != QLatin1String("xbel")) {
- errorStr = QObject::tr("The file is not an XBEL file.");
- return false;
- }
-
- if (qName == QLatin1String("xbel")) {
- QString version = attributes.value(versionAttribute());
- if (!version.isEmpty() && version != QLatin1String("1.0")) {
- errorStr = QObject::tr("The file is not an XBEL version 1.0 file.");
- return false;
- }
- metXbelTag = true;
- } else if (qName == QLatin1String("folder")) {
- item = createChildItem(qName);
- item->setFlags(item->flags() | Qt::ItemIsEditable);
- item->setIcon(0, folderIcon);
- item->setText(0, QObject::tr("Folder"));
- bool folded = (attributes.value(foldedAttribute()) != QLatin1String("no"));
- item->setExpanded(!folded);
- } else if (qName == QLatin1String("bookmark")) {
- item = createChildItem(qName);
- item->setFlags(item->flags() | Qt::ItemIsEditable);
- item->setIcon(0, bookmarkIcon);
- item->setText(0, QObject::tr("Unknown title"));
- item->setText(1, attributes.value(hrefAttribute()));
- } else if (qName == QLatin1String("separator")) {
- item = createChildItem(qName);
- item->setFlags(item->flags() & ~Qt::ItemIsSelectable);
- item->setText(0, QString(30, 0xB7));
- }
-
- currentText.clear();
- return true;
-}
-
-bool XbelHandler::endElement(const QString & /* namespaceURI */,
- const QString & /* localName */,
- const QString &qName)
-{
- if (qName == QLatin1String("title")) {
- if (item)
- item->setText(0, currentText);
- } else if (qName == QLatin1String("folder") || qName == QLatin1String("bookmark")
- || qName == QLatin1String("separator")) {
- item = item->parent();
- }
- return true;
-}
-
-bool XbelHandler::characters(const QString &str)
-{
- currentText += str;
- return true;
-}
-
-bool XbelHandler::fatalError(const QXmlParseException &exception)
-{
- QMessageBox::information(treeWidget->window(), QObject::tr("SAX Bookmarks"),
- QObject::tr("Parse error at line %1, column %2:\n"
- "%3")
- .arg(exception.lineNumber())
- .arg(exception.columnNumber())
- .arg(exception.message()));
- return false;
-}
-
-QString XbelHandler::errorString() const
-{
- return errorStr;
-}
-
-QTreeWidgetItem *XbelHandler::createChildItem(const QString &tagName)
-{
- QTreeWidgetItem *childItem;
- if (item) {
- childItem = new QTreeWidgetItem(item);
- } else {
- childItem = new QTreeWidgetItem(treeWidget);
- }
- childItem->setData(0, Qt::UserRole, tagName);
- return childItem;
-}
diff --git a/examples/xml/saxbookmarks/xbelhandler.h b/examples/xml/saxbookmarks/xbelhandler.h
deleted file mode 100644
index 3f4cb109e9..0000000000
--- a/examples/xml/saxbookmarks/xbelhandler.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef XBELHANDLER_H
-#define XBELHANDLER_H
-
-#include <QIcon>
-#include <QXmlDefaultHandler>
-
-QT_BEGIN_NAMESPACE
-class QTreeWidget;
-class QTreeWidgetItem;
-QT_END_NAMESPACE
-
-class XbelHandler : public QXmlDefaultHandler
-{
-public:
- XbelHandler(QTreeWidget *treeWidget);
-
- bool startElement(const QString &namespaceURI, const QString &localName,
- const QString &qName, const QXmlAttributes &attributes) override;
- bool endElement(const QString &namespaceURI, const QString &localName,
- const QString &qName) override;
- bool characters(const QString &str) override;
- bool fatalError(const QXmlParseException &exception) override;
- QString errorString() const override;
-
-private:
- QTreeWidgetItem *createChildItem(const QString &tagName);
-
- QTreeWidget *treeWidget;
- QTreeWidgetItem *item;
- QString currentText;
- QString errorStr;
- bool metXbelTag;
-
- QIcon folderIcon;
- QIcon bookmarkIcon;
-};
-
-#endif
diff --git a/examples/xml/xml.pro b/examples/xml/xml.pro
index 72bf95b2ea..b0750574f4 100644
--- a/examples/xml/xml.pro
+++ b/examples/xml/xml.pro
@@ -4,7 +4,6 @@ SUBDIRS = htmlinfo \
qtHaveModule(widgets) {
SUBDIRS += dombookmarks \
- saxbookmarks \
streambookmarks
qtHaveModule(network): SUBDIRS += \
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index cb753ed573..bbc877eead 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -5691,6 +5691,10 @@ void QDomDocumentPrivate::clear()
QDomNodePrivate::clear();
}
+#if QT_DEPRECATED_SINCE(5, 15)
+
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
static void initializeReader(QXmlSimpleReader &reader, bool namespaceProcessing)
{
reader.setFeature(QLatin1String("http://xml.org/sax/features/namespaces"), namespaceProcessing);
@@ -5734,6 +5738,9 @@ bool QDomDocumentPrivate::setContent(QXmlInputSource *source, QXmlReader *reader
return true;
}
+QT_WARNING_POP
+
+#endif // QT_DEPRECATED_SINCE(5, 15)
bool QDomDocumentPrivate::setContent(QXmlStreamReader *reader, bool namespaceProcessing,
QString *errorMsg, int *errorLine, int *errorColumn)
@@ -6183,8 +6190,11 @@ bool QDomDocument::setContent(const QString& text, bool namespaceProcessing, QSt
if (!impl)
impl = new QDomDocumentPrivate();
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QXmlInputSource source;
+QT_WARNING_POP
source.setData(text);
return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);
#else
@@ -6252,10 +6262,13 @@ bool QDomDocument::setContent(const QByteArray &data, bool namespaceProcessing,
if (!impl)
impl = new QDomDocumentPrivate();
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
QBuffer buf;
buf.setData(data);
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QXmlInputSource source(&buf);
+QT_WARNING_POP
return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);
#else
QXmlStreamReader streamReader(data);
@@ -6275,8 +6288,11 @@ bool QDomDocument::setContent(QIODevice* dev, bool namespaceProcessing, QString
if (!impl)
impl = new QDomDocumentPrivate();
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QXmlInputSource source(dev);
+QT_WARNING_POP
return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);
#else
QXmlStreamReader streamReader(dev);
@@ -6285,14 +6301,18 @@ bool QDomDocument::setContent(QIODevice* dev, bool namespaceProcessing, QString
#endif
}
+#if QT_DEPRECATED_SINCE(5, 15)
/*!
\overload
+ \obsolete
\since 4.5
This function reads the XML document from the QXmlInputSource \a source,
returning true if the content was successfully parsed; otherwise returns \c false.
*/
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
bool QDomDocument::setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn )
{
if (!impl)
@@ -6301,6 +6321,9 @@ bool QDomDocument::setContent(QXmlInputSource *source, bool namespaceProcessing,
initializeReader(reader, namespaceProcessing);
return IMPL->setContent(source, &reader, &reader, errorMsg, errorLine, errorColumn);
}
+QT_WARNING_POP
+
+#endif
/*!
\overload
@@ -6333,6 +6356,7 @@ bool QDomDocument::setContent(const QByteArray& buffer, QString *errorMsg, int *
/*!
\overload
+ \obsolete
This function reads the XML document from the IO device \a dev, returning
true if the content was successfully parsed; otherwise returns \c false.
@@ -6344,8 +6368,10 @@ bool QDomDocument::setContent(QIODevice* dev, QString *errorMsg, int *errorLine,
return setContent(dev, false, errorMsg, errorLine, errorColumn);
}
+#if QT_DEPRECATED_SINCE(5, 15)
/*!
\overload
+ \obsolete
This function reads the XML document from the QXmlInputSource \a source and
parses it with the QXmlReader \a reader, returning true if the content was
@@ -6357,12 +6383,17 @@ bool QDomDocument::setContent(QIODevice* dev, QString *errorMsg, int *errorLine,
\sa QXmlSimpleReader
*/
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
bool QDomDocument::setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn )
{
if (!impl)
impl = new QDomDocumentPrivate();
return IMPL->setContent(source, reader, nullptr, errorMsg, errorLine, errorColumn);
}
+QT_WARNING_POP
+
+#endif
/*!
\overload
diff --git a/src/xml/dom/qdom.h b/src/xml/dom/qdom.h
index 1b00a14179..d50c5e8394 100644
--- a/src/xml/dom/qdom.h
+++ b/src/xml/dom/qdom.h
@@ -339,11 +339,23 @@ public:
bool setContent(const QByteArray& text, bool namespaceProcessing, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
bool setContent(const QString& text, bool namespaceProcessing, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
bool setContent(QIODevice* dev, bool namespaceProcessing, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+ QT_DEPRECATED_X("Use other overloads instead")
bool setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
+QT_WARNING_POP
+#endif
bool setContent(const QByteArray& text, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
bool setContent(const QString& text, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
bool setContent(QIODevice* dev, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+ QT_DEPRECATED_X("Use other overloads instead")
bool setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
+QT_WARNING_POP
+#endif
bool setContent(QXmlStreamReader *reader, bool namespaceProcessing, QString *errorMsg = nullptr,
int *errorLine = nullptr, int *errorColumn = nullptr);
diff --git a/src/xml/dom/qdom_p.h b/src/xml/dom/qdom_p.h
index b66c756af0..a9399d9901 100644
--- a/src/xml/dom/qdom_p.h
+++ b/src/xml/dom/qdom_p.h
@@ -461,10 +461,15 @@ public:
QDomDocumentPrivate(QDomDocumentPrivate *n, bool deep);
~QDomDocumentPrivate();
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
bool setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg,
int *errorLine, int *errorColumn);
bool setContent(QXmlInputSource *source, QXmlReader *reader, QXmlSimpleReader *simpleReader,
QString *errorMsg, int *errorLine, int *errorColumn);
+QT_WARNING_POP
+#endif
bool setContent(QXmlStreamReader *reader, bool namespaceProcessing, QString *errorMsg,
int *errorLine, int *errorColumn);
diff --git a/src/xml/dom/qdomhelpers.cpp b/src/xml/dom/qdomhelpers.cpp
index 9399ad3b9b..10e37f7c0f 100644
--- a/src/xml/dom/qdomhelpers.cpp
+++ b/src/xml/dom/qdomhelpers.cpp
@@ -44,12 +44,15 @@
QT_BEGIN_NAMESPACE
+#if QT_DEPRECATED_SINCE(5, 15)
+
/**************************************************************
*
* QDomHandler
*
**************************************************************/
-
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QDomHandler::QDomHandler(QDomDocumentPrivate *adoc, QXmlSimpleReader *areader,
bool namespaceProcessing)
: cdata(false), reader(areader), domBuilder(adoc, &locator, namespaceProcessing)
@@ -160,6 +163,9 @@ QDomBuilder::ErrorInfo QDomHandler::errorInfo() const
{
return domBuilder.error();
}
+QT_WARNING_POP
+
+#endif // QT_DEPRECATED_SINCE(5, 15)
/**************************************************************
*
@@ -179,10 +185,15 @@ int QDomDocumentLocator::line() const
return static_cast<int>(reader->lineNumber());
}
+#if QT_DEPRECATED_SINCE(5, 15)
+
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
void QSAXDocumentLocator::setLocator(QXmlLocator *l)
{
locator = l;
}
+QT_WARNING_POP
int QSAXDocumentLocator::column() const
{
@@ -200,6 +211,8 @@ int QSAXDocumentLocator::line() const
return static_cast<int>(locator->lineNumber());
}
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
/**************************************************************
*
* QDomBuilder
@@ -234,6 +247,10 @@ bool QDomBuilder::startDTD(const QString &name, const QString &publicId, const Q
return true;
}
+#if QT_DEPRECATED_SINCE(5, 15)
+
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
bool QDomBuilder::startElement(const QString &nsURI, const QString &qName,
const QXmlAttributes &atts)
{
@@ -264,6 +281,9 @@ bool QDomBuilder::startElement(const QString &nsURI, const QString &qName,
return true;
}
+QT_WARNING_POP
+
+#endif // QT_DEPRECATED_SINCE(5, 15)
inline QString stringRefToString(const QStringRef &stringRef)
{
diff --git a/src/xml/dom/qdomhelpers_p.h b/src/xml/dom/qdomhelpers_p.h
index f5efd8a42d..4de18f7d4d 100644
--- a/src/xml/dom/qdomhelpers_p.h
+++ b/src/xml/dom/qdomhelpers_p.h
@@ -93,6 +93,11 @@ private:
QXmlStreamReader *reader;
};
+#if QT_DEPRECATED_SINCE(5, 15)
+
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+
class QSAXDocumentLocator : public QXmlDocumentLocator
{
public:
@@ -107,6 +112,10 @@ private:
QXmlLocator *locator = nullptr;
};
+QT_WARNING_POP
+
+#endif
+
/**************************************************************
*
* QDomBuilder
@@ -120,7 +129,12 @@ public:
~QDomBuilder();
bool endDocument();
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
bool startElement(const QString &nsURI, const QString &qName, const QXmlAttributes &atts);
+QT_WARNING_POP
+#endif
bool startElement(const QString &nsURI, const QString &qName, const QXmlStreamAttributes &atts);
bool endElement();
bool characters(const QString &characters, bool cdata = false);
@@ -152,12 +166,17 @@ private:
bool nsProcessing;
};
+#if QT_DEPRECATED_SINCE(5, 15)
+
/**************************************************************
*
* QDomHandler
*
**************************************************************/
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+
class QDomHandler : public QXmlDefaultHandler
{
public:
@@ -205,6 +224,10 @@ private:
QDomBuilder domBuilder;
};
+QT_WARNING_POP
+
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
/**************************************************************
*
* QDomParser
diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp
index 1993073cce..0033d042d4 100644
--- a/src/xml/sax/qxml.cpp
+++ b/src/xml/sax/qxml.cpp
@@ -51,6 +51,7 @@
#include "qstack.h"
#include <qdebug.h>
+#if QT_DEPRECATED_SINCE(5, 15)
#ifdef Q_CC_BOR // borland 6 finds bogus warnings when building this file in uic3
# pragma warn -8080
@@ -284,6 +285,7 @@ class QXmlDefaultHandlerPrivate
/*!
\class QXmlParseException
+ \obsolete
\reentrant
\brief The QXmlParseException class is used to report errors with
the QXmlErrorHandler interface.
@@ -403,6 +405,7 @@ QString QXmlParseException::systemId() const
/*!
\class QXmlLocator
+ \obsolete
\reentrant
\brief The QXmlLocator class provides the XML handler classes with
information about the parsing position within a file.
@@ -445,6 +448,9 @@ QXmlLocator::~QXmlLocator()
number available.
*/
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+
class QXmlSimpleReaderLocator : public QXmlLocator
{
public:
@@ -497,6 +503,7 @@ public:
/*!
\class QXmlNamespaceSupport
+ \obsolete
\since 4.4
\reentrant
\brief The QXmlNamespaceSupport class is a helper class for XML
@@ -745,6 +752,7 @@ void QXmlNamespaceSupport::reset()
/*!
\class QXmlAttributes
+ \obsolete
\reentrant
\brief The QXmlAttributes class provides XML attributes.
@@ -1028,6 +1036,7 @@ void QXmlAttributes::append(const QString &qName, const QString &uri, const QStr
/*!
\class QXmlInputSource
+ \obsolete
\reentrant
\brief The QXmlInputSource class provides the input data for the
QXmlReader subclasses.
@@ -1446,6 +1455,7 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning)
/*!
\class QXmlContentHandler
+ \obsolete
\reentrant
\brief The QXmlContentHandler class provides an interface to
report the logical content of XML data.
@@ -1688,6 +1698,7 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning)
/*!
\class QXmlErrorHandler
+ \obsolete
\reentrant
\brief The QXmlErrorHandler class provides an interface to report
errors in XML data.
@@ -1763,6 +1774,7 @@ events are reported.
/*!
\class QXmlDTDHandler
+ \obsolete
\reentrant
\brief The QXmlDTDHandler class provides an interface to report
DTD content of XML data.
@@ -1830,6 +1842,7 @@ events are reported.
/*!
\class QXmlEntityResolver
+ \obsolete
\reentrant
\brief The QXmlEntityResolver class provides an interface to
resolve external entities contained in XML data.
@@ -1886,6 +1899,7 @@ events are reported.
/*!
\class QXmlLexicalHandler
+ \obsolete
\reentrant
\brief The QXmlLexicalHandler class provides an interface to
report the lexical content of XML data.
@@ -2037,6 +2051,7 @@ events are reported.
/*!
\class QXmlDeclHandler
+ \obsolete
\reentrant
\brief The QXmlDeclHandler class provides an interface to report declaration
content of XML data.
@@ -2124,6 +2139,7 @@ events are reported.
/*!
\class QXmlDefaultHandler
+ \obsolete
\reentrant
\brief The QXmlDefaultHandler class provides a default implementation of all
the XML handler classes.
@@ -2558,6 +2574,7 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing()
/*!
\class QXmlReader
+ \obsolete
\reentrant
\brief The QXmlReader class provides an interface for XML readers (i.e.
parsers).
@@ -2597,6 +2614,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing()
setDeclHandler(). The parse itself is started with a call to
parse().
+ Note that this class is now deprecated, please use QXmlStreamReader or
+ QDomDocument for reading XML files.
+
\sa QXmlSimpleReader
*/
@@ -2783,6 +2803,7 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing()
/*!
\class QXmlSimpleReader
+ \obsolete
\nonreentrant
\brief The QXmlSimpleReader class provides an implementation of a
simple XML parser.
@@ -2845,6 +2866,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing()
QXmlSimpleReader is not reentrant. If you want to use the class
in threaded code, lock the code using QXmlSimpleReader with a
locking mechanism, such as a QMutex.
+
+ Note that this class is now deprecated, please use QXmlStreamReader or
+ QDomDocument for reading XML files.
*/
static inline bool is_S(QChar ch)
@@ -5255,7 +5279,10 @@ bool QXmlSimpleReaderPrivate::parsePEReference()
} else if (entityRes) {
QMap<QString,QXmlSimpleReaderPrivate::ExternParameterEntity>::Iterator it2;
it2 = externParameterEntities.find(ref());
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QXmlInputSource *ret = nullptr;
+QT_WARNING_POP
if (it2 != externParameterEntities.end()) {
if (!entityRes->resolveEntity((*it2).publicId, (*it2).systemId, ret)) {
delete ret;
@@ -7610,7 +7637,10 @@ bool QXmlSimpleReaderPrivate::processReference()
// Included if validating
bool skipIt = true;
if (entityRes) {
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QXmlInputSource *ret = nullptr;
+QT_WARNING_POP
if (!entityRes->resolveEntity((*itExtern).publicId, (*itExtern).systemId, ret)) {
delete ret;
reportParseError(entityRes->errorString());
@@ -7850,6 +7880,8 @@ bool QXmlSimpleReaderPrivate::next_eat_ws()
This private function initializes the reader. \a i is the input source to
read the data from.
*/
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
void QXmlSimpleReaderPrivate::init(const QXmlInputSource *i)
{
lineNr = 0;
@@ -7870,6 +7902,7 @@ void QXmlSimpleReaderPrivate::init(const QXmlInputSource *i)
standalone = QXmlSimpleReaderPrivate::Unknown;
error.clear();
}
+QT_WARNING_POP
/*
This private function initializes the XML data related variables. Especially,
@@ -7898,6 +7931,8 @@ bool QXmlSimpleReaderPrivate::entityExist(const QString& e) const
}
}
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
void QXmlSimpleReaderPrivate::reportParseError(const QString& error)
{
this->error = error;
@@ -7913,6 +7948,7 @@ void QXmlSimpleReaderPrivate::reportParseError(const QString& error)
}
}
}
+QT_WARNING_POP
/*
This private function is called when a parsing function encounters an
@@ -8006,3 +8042,5 @@ void QXmlSimpleReaderPrivate::refAddC(QChar ch)
refArray[refArrayPos++] = ch;
}
QT_END_NAMESPACE
+
+#endif // QT_DEPRECATED_SINCE(5, 15)
diff --git a/src/xml/sax/qxml.h b/src/xml/sax/qxml.h
index 9be14bd7a9..e19a398ca7 100644
--- a/src/xml/sax/qxml.h
+++ b/src/xml/sax/qxml.h
@@ -40,6 +40,26 @@
#ifndef QXML_H
#define QXML_H
+#if 0
+// This is needed because of QTBUG-80347
+#pragma qt_class(QXmlNamespaceSupport)
+#pragma qt_class(QXmlAttributes)
+#pragma qt_class(QXmlInputSource)
+#pragma qt_class(QXmlParseException)
+#pragma qt_class(QXmlReader)
+#pragma qt_class(QXmlSimpleReader)
+#pragma qt_class(QXmlLocator)
+#pragma qt_class(QXmlContentHandler)
+#pragma qt_class(QXmlErrorHandler)
+#pragma qt_class(QXmlDTDHandler)
+#pragma qt_class(QXmlEntityResolver)
+#pragma qt_class(QXmlLexicalHandler)
+#pragma qt_class(QXmlDeclHandler)
+#pragma qt_class(QXmlDefaultHandler)
+#endif
+
+#include <QtCore/qglobal.h>
+
#include <QtXml/qtxmlglobal.h>
#include <QtCore/qtextstream.h>
#include <QtCore/qfile.h>
@@ -48,8 +68,12 @@
#include <QtCore/qlist.h>
#include <QtCore/qscopedpointer.h>
+#if QT_DEPRECATED_SINCE(5, 15)
+
QT_BEGIN_NAMESPACE
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
class QXmlNamespaceSupport;
class QXmlAttributes;
@@ -76,12 +100,11 @@ class QXmlParseExceptionPrivate;
class QXmlLocatorPrivate;
class QXmlDefaultHandlerPrivate;
-
//
// SAX Namespace Support
//
-class Q_XML_EXPORT QXmlNamespaceSupport
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlNamespaceSupport
{
public:
QXmlNamespaceSupport();
@@ -112,10 +135,15 @@ private:
// SAX Attributes
//
+// Although deprecated warnings are disabled, the intel icc 18 compiler
+// still complains during the instantiation of the templated qSwap() call below
+// (with the parameter QXmlAttributes::AttributeList) when QXmlAttributes is
+// deprecated. This makes the build fail when warnings are treated as errors.
+// To workaround this, deprecated only the constructor.
class Q_XML_EXPORT QXmlAttributes
{
public:
- QXmlAttributes();
+ QT_DEPRECATED_VERSION(5, 15) QXmlAttributes();
QXmlAttributes(const QXmlAttributes &) = default;
QXmlAttributes(QXmlAttributes &&) noexcept = default;
QXmlAttributes &operator=(const QXmlAttributes &) = default;
@@ -158,6 +186,7 @@ private:
QXmlAttributesPrivate *d;
};
+
Q_DECLARE_TYPEINFO(QXmlAttributes::Attribute, Q_MOVABLE_TYPE);
Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QXmlAttributes)
@@ -165,7 +194,7 @@ Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QXmlAttributes)
// SAX Input Source
//
-class Q_XML_EXPORT QXmlInputSource
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlInputSource
{
public:
QXmlInputSource();
@@ -194,7 +223,7 @@ private:
// SAX Exception Classes
//
-class Q_XML_EXPORT QXmlParseException
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlParseException
{
public:
explicit QXmlParseException(const QString &name = QString(), int c = -1, int l = -1,
@@ -217,7 +246,7 @@ private:
// XML Reader
//
-class Q_XML_EXPORT QXmlReader
+class QT_DEPRECATED_VERSION_X(5, 15, "Use QXmlStreamReader") Q_XML_EXPORT QXmlReader
{
public:
virtual ~QXmlReader() {}
@@ -243,7 +272,8 @@ public:
virtual bool parse(const QXmlInputSource* input) = 0;
};
-class Q_XML_EXPORT QXmlSimpleReader : public QXmlReader
+class QT_DEPRECATED_VERSION_X(5, 15, "Use QXmlStreamReader") Q_XML_EXPORT QXmlSimpleReader
+ : public QXmlReader
{
public:
QXmlSimpleReader();
@@ -288,7 +318,7 @@ private:
// SAX Locator
//
-class Q_XML_EXPORT QXmlLocator
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlLocator
{
public:
QXmlLocator();
@@ -304,7 +334,7 @@ public:
// SAX handler classes
//
-class Q_XML_EXPORT QXmlContentHandler
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlContentHandler
{
public:
virtual ~QXmlContentHandler() {}
@@ -322,7 +352,7 @@ public:
virtual QString errorString() const = 0;
};
-class Q_XML_EXPORT QXmlErrorHandler
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlErrorHandler
{
public:
virtual ~QXmlErrorHandler() {}
@@ -332,7 +362,7 @@ public:
virtual QString errorString() const = 0;
};
-class Q_XML_EXPORT QXmlDTDHandler
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlDTDHandler
{
public:
virtual ~QXmlDTDHandler() {}
@@ -341,7 +371,7 @@ public:
virtual QString errorString() const = 0;
};
-class Q_XML_EXPORT QXmlEntityResolver
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlEntityResolver
{
public:
virtual ~QXmlEntityResolver() {}
@@ -349,7 +379,7 @@ public:
virtual QString errorString() const = 0;
};
-class Q_XML_EXPORT QXmlLexicalHandler
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlLexicalHandler
{
public:
virtual ~QXmlLexicalHandler() {}
@@ -363,7 +393,7 @@ public:
virtual QString errorString() const = 0;
};
-class Q_XML_EXPORT QXmlDeclHandler
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlDeclHandler
{
public:
virtual ~QXmlDeclHandler() {}
@@ -374,8 +404,12 @@ public:
// ### Conform to SAX by adding elementDecl
};
-
-class Q_XML_EXPORT QXmlDefaultHandler : public QXmlContentHandler, public QXmlErrorHandler, public QXmlDTDHandler, public QXmlEntityResolver, public QXmlLexicalHandler, public QXmlDeclHandler
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlDefaultHandler : public QXmlContentHandler,
+ public QXmlErrorHandler,
+ public QXmlDTDHandler,
+ public QXmlEntityResolver,
+ public QXmlLexicalHandler,
+ public QXmlDeclHandler
{
public:
QXmlDefaultHandler();
@@ -426,6 +460,10 @@ private:
inline int QXmlAttributes::count() const
{ return length(); }
+QT_WARNING_POP
+
QT_END_NAMESPACE
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
#endif // QXML_H
diff --git a/src/xml/sax/qxml_p.h b/src/xml/sax/qxml_p.h
index eb6135db04..1b614dd886 100644
--- a/src/xml/sax/qxml_p.h
+++ b/src/xml/sax/qxml_p.h
@@ -46,6 +46,8 @@
#include <stack>
+#if QT_DEPRECATED_SINCE(5, 15)
+
QT_BEGIN_NAMESPACE
//
@@ -59,6 +61,9 @@ QT_BEGIN_NAMESPACE
// We mean it.
//
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+
class QXmlSimpleReaderPrivate
{
public:
@@ -313,6 +318,10 @@ Q_DECLARE_TYPEINFO(QXmlSimpleReaderPrivate::XmlRef, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QXmlSimpleReaderPrivate::ExternParameterEntity, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QXmlSimpleReaderPrivate::ExternEntity, Q_MOVABLE_TYPE);
+QT_WARNING_POP
+
QT_END_NAMESPACE
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
#endif // QXML_P_H
diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
index 92a0d8bbfa..12279133a2 100644
--- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
+++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
@@ -221,7 +221,7 @@ static QString documentElement(const QByteArray &document)
*
* See \l {http://www.w3.org/XML/Test/} {Extensible Markup Language (XML) Conformance Test Suites}
*/
-class TestSuiteHandler : public QXmlDefaultHandler
+class TestSuiteHandler
{
public:
/**
@@ -286,29 +286,33 @@ public:
m_baseURI.push(baseURI);
}
- virtual bool characters(const QString &chars)
+ bool runTests(QFile *file)
{
- m_ch = chars;
- return true;
+ QXmlStreamReader reader(file);
+ while (!reader.atEnd() && !reader.hasError()) {
+ reader.readNext();
+
+ if (reader.isStartElement() && !startElement(reader.attributes()))
+ return false;
+
+ if (reader.isEndElement() && !endElement(reader.name().toString()))
+ return false;
+ }
+ return !reader.hasError();
}
- virtual bool startElement(const QString &,
- const QString &,
- const QString &,
- const QXmlAttributes &atts)
+ bool startElement(const QXmlStreamAttributes &atts)
{
m_atts.push(atts);
- const int i = atts.index(QLatin1String("xml:base"));
- if(i != -1)
- m_baseURI.push(m_baseURI.top().resolved(atts.value(i)));
+ const auto attr = atts.value(QLatin1String("xml:base"));
+ if (!attr.isEmpty())
+ m_baseURI.push(m_baseURI.top().resolved(attr.toString()));
return true;
}
- virtual bool endElement(const QString &,
- const QString &localName,
- const QString &)
+ bool endElement(const QString &localName)
{
if(localName == QLatin1String("TEST"))
{
@@ -329,19 +333,19 @@ public:
return true;
}
- const QString inputFilePath(m_baseURI.top().resolved(m_atts.top().value(QString(), QLatin1String("URI")))
- .toLocalFile());
- const QString id(m_atts.top().value(QString(), QLatin1String("ID")));
- const QString type(m_atts.top().value(QString(), QLatin1String("TYPE")));
+ const QString inputFilePath(
+ m_baseURI.top()
+ .resolved(
+ m_atts.top().value(QString(), QLatin1String("URI")).toString())
+ .toLocalFile());
+ const QString id(m_atts.top().value(QString(), QLatin1String("ID")).toString());
+ const QString type(m_atts.top().value(QString(), QLatin1String("TYPE")).toString());
QString expectedFilePath;
- const int index = m_atts.top().index(QString(), QLatin1String("OUTPUT"));
- if(index != -1)
- {
- expectedFilePath = m_baseURI.top().resolved(m_atts.top().value(QString(),
- QLatin1String("OUTPUT"))).toLocalFile();
- }
+ const auto attr = m_atts.top().value(QString(), QLatin1String("OUTPUT"));
+ if (!attr.isEmpty())
+ expectedFilePath = m_baseURI.top().resolved(attr.toString()).toLocalFile();
/* testcases.dtd: 'No parser should accept a "not-wf" testcase
* unless it's a nonvalidating parser and the test contains
@@ -349,7 +353,7 @@ public:
*
* We also let this apply to "valid", "invalid" and "error" tests, although
* I'm not fully sure this is correct. */
- const QString ents(m_atts.top().value(QString(), QLatin1String("ENTITIES")));
+ const QString ents(m_atts.top().value(QString(), QLatin1String("ENTITIES")).toString());
m_atts.pop();
if(ents == QLatin1String("both") ||
@@ -455,8 +459,8 @@ public:
qFatal("The input catalog is invalid.");
return false;
}
- }
- else if(localName == QLatin1String("TESTCASES") && m_atts.top().index(QLatin1String("xml:base")) != -1)
+ } else if (localName == QLatin1String("TESTCASES")
+ && m_atts.top().hasAttribute(QLatin1String("xml:base")))
m_baseURI.pop();
m_atts.pop();
@@ -516,9 +520,8 @@ public:
}
private:
- QStack<QXmlAttributes> m_atts;
- QString m_ch;
- QStack<QUrl> m_baseURI;
+ QStack<QXmlStreamAttributes> m_atts;
+ QStack<QUrl> m_baseURI;
};
QT_BEGIN_NAMESPACE
Q_DECLARE_SHARED(TestSuiteHandler::MissedBaseline)
@@ -592,11 +595,7 @@ void tst_QXmlStream::initTestCase()
QVERIFY2(file.open(QIODevice::ReadOnly),
qPrintable(QString::fromLatin1("Failed to open the test suite catalog; %1").arg(file.fileName())));
- QXmlInputSource source(&file);
- QXmlSimpleReader reader;
- reader.setContentHandler(&m_handler);
-
- QVERIFY(reader.parse(&source, false));
+ QVERIFY(m_handler.runTests(&file));
}
void tst_QXmlStream::cleanupTestCase()
diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp
index ab62307704..a2a5b22cad 100644
--- a/tests/auto/xml/dom/qdom/tst_qdom.cpp
+++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp
@@ -173,7 +173,7 @@ void tst_QDom::setContent_data()
" </b3>\n"
"</a1>\n");
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
// These configurations cannot be supported by the QXmlStreamReader-based implementation
QTest::newRow( "02" ) << doc01
<< QString("http://trolltech.com/xml/features/report-whitespace-only-CharData").split(' ')
@@ -246,7 +246,9 @@ void tst_QDom::setContent()
QFETCH( QString, doc );
QDomDocument domDoc;
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QXmlInputSource source;
source.setData( doc );
@@ -264,6 +266,7 @@ void tst_QDom::setContent()
}
QVERIFY( domDoc.setContent( &source, &reader ) );
+QT_WARNING_POP
#else
QXmlStreamReader reader(doc);
QVERIFY(domDoc.setContent(&reader, true));
@@ -1483,7 +1486,7 @@ void tst_QDom::normalizeAttributes() const
QDomDocument doc;
QVERIFY(doc.setContent(&buffer, true));
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
QEXPECT_FAIL("", "The parser doesn't perform Attribute Value Normalization. Fixing that would change behavior.", Continue);
#endif
QCOMPARE(doc.documentElement().attribute(QLatin1String("attribute")), QString::fromLatin1("a a"));
@@ -1528,7 +1531,10 @@ void tst_QDom::serializeNamespaces() const
QDomDocument doc;
QByteArray ba(input);
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+
QBuffer buffer(&ba);
QVERIFY(buffer.open(QIODevice::ReadOnly));
@@ -1538,6 +1544,7 @@ void tst_QDom::serializeNamespaces() const
reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
QVERIFY(doc.setContent(&source, &reader));
+QT_WARNING_POP
#else
QXmlStreamReader streamReader(input);
QVERIFY(doc.setContent(&streamReader, true));
@@ -1565,7 +1572,7 @@ void tst_QDom::flagInvalidNamespaces() const
QDomDocument doc;
QVERIFY(!doc.setContent(QString::fromLatin1(input, true)));
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
QEXPECT_FAIL("", "The parser doesn't flag identical qualified attribute names. Fixing this would change behavior.", Continue);
#endif
QVERIFY(!doc.setContent(QString::fromLatin1(input)));
@@ -1580,7 +1587,9 @@ void tst_QDom::flagUndeclaredNamespace() const
QDomDocument doc;
QByteArray ba(input);
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QBuffer buffer(&ba);
QVERIFY(buffer.open(QIODevice::ReadOnly));
@@ -1592,6 +1601,7 @@ void tst_QDom::flagUndeclaredNamespace() const
QEXPECT_FAIL("", "The parser doesn't flag not declared prefixes. Fixing this would change behavior.", Continue);
QVERIFY(!doc.setContent(&source, &reader));
+QT_WARNING_POP
#else
QXmlStreamReader streamReader(ba);
QVERIFY(!doc.setContent(&streamReader, true));
@@ -1662,7 +1672,7 @@ void tst_QDom::reportDuplicateAttributes() const
QDomDocument dd;
bool isSuccess = dd.setContent(QLatin1String("<test x=\"1\" x=\"2\"/>"));
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
QEXPECT_FAIL("", "The parser doesn't flag duplicate attributes. Fixing this would change behavior.", Continue);
#endif
QVERIFY2(!isSuccess, "Duplicate attributes are well-formedness errors, and should be reported as such.");
@@ -1864,11 +1874,14 @@ void tst_QDom::doubleNamespaceDeclarations() const
QFile file(testFile);
QVERIFY(file.open(QIODevice::ReadOnly));
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QXmlSimpleReader reader;
QXmlInputSource source(&file);
QVERIFY(doc.setContent(&source, &reader));
+QT_WARNING_POP
#else
QXmlStreamReader streamReader(&file);
QVERIFY(doc.setContent(&streamReader, true));
@@ -1889,11 +1902,14 @@ void tst_QDom::setContentQXmlReaderOverload() const
{
QDomDocument doc;
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QXmlSimpleReader reader;
QXmlInputSource data;
data.setData(QByteArray("<e/>"));
doc.setContent(&data, true);
+QT_WARNING_POP
#else
QXmlStreamReader streamReader(QByteArray("<e/>"));
doc.setContent(&streamReader, true);
@@ -1995,7 +2011,7 @@ void tst_QDom::taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() co
// QXmlStreamReader fails to read XML documents with unknown encoding. It
// needs to be modified if we want to support this case with the QXmlStreamReader-based
// implementation.
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
QString xmlWithUnknownEncoding("<?xml version='1.0' encoding='unknown-encoding'?>"
"<foo>"
" <bar>How will this sentence be handled?</bar>"
diff --git a/tests/auto/xml/sax/qxml/tst_qxml.cpp b/tests/auto/xml/sax/qxml/tst_qxml.cpp
index 1cdb9701fa..db6584edda 100644
--- a/tests/auto/xml/sax/qxml/tst_qxml.cpp
+++ b/tests/auto/xml/sax/qxml/tst_qxml.cpp
@@ -26,7 +26,6 @@
**
****************************************************************************/
-
#include <QtTest/QtTest>
#include <qcoreapplication.h>
@@ -38,13 +37,17 @@ class tst_QXml : public QObject
Q_OBJECT
private slots:
+#if QT_DEPRECATED_SINCE(5, 15)
void getSetCheck();
void interpretedAs0D() const;
#ifndef QT_NO_EXCEPTIONS
void exception();
#endif
+#endif // QT_DEPRECATED_SINCE(5, 15)
};
+#if QT_DEPRECATED_SINCE(5, 15)
+
class MyXmlEntityResolver : public QXmlEntityResolver
{
public:
@@ -225,5 +228,7 @@ void tst_QXml::exception()
}
#endif
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
QTEST_MAIN(tst_QXml)
#include "tst_qxml.moc"
diff --git a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp
index d40c8c2fd6..afdcc825d8 100644
--- a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp
+++ b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp
@@ -45,13 +45,18 @@ class tst_QXmlInputSource : public QObject
{
Q_OBJECT
+#if QT_DEPRECATED_SINCE(5, 15)
private slots:
void reset() const;
void resetSimplified() const;
void waitForReadyIODevice() const;
void inputFromSlowDevice() const;
+#endif // QT_DEPRECATED_SINCE(5, 15)
};
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
/*!
\internal
\since 4.4
@@ -292,5 +297,8 @@ void tst_QXmlInputSource::inputFromSlowDevice() const
QCOMPARE(data, expectedData);
}
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
QTEST_MAIN(tst_QXmlInputSource)
#include "tst_qxmlinputsource.moc"
diff --git a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp
index 556603a681..44f8101955 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp
+++ b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp
@@ -26,12 +26,15 @@
**
****************************************************************************/
+#include "parser.h"
+
+#if QT_DEPRECATED_SINCE(5, 15)
#include <qxml.h>
#include <qregularexpression.h>
-#include "parser.h"
-
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
class ContentHandler : public QXmlDefaultHandler
{
public:
@@ -440,3 +443,6 @@ QString Parser::errorMsg() const
{
return handler->errorMsg();
}
+
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(5, 15)
diff --git a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.h b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.h
index 604678f06b..9c51cdf095 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.h
+++ b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.h
@@ -28,6 +28,10 @@
#ifndef PARSER_H
#define PARSER_H
+#include <qglobal.h>
+
+#if QT_DEPRECATED_SINCE(5, 15)
+
#include <qfile.h>
#include <qstring.h>
#include <qxml.h>
@@ -48,4 +52,6 @@ private:
ContentHandler *handler;
};
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
#endif
diff --git a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
index 8c4c6c7179..cea4e3c8b8 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
+++ b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
@@ -127,6 +127,7 @@ class tst_QXmlSimpleReader : public QObject
{
Q_OBJECT
+#if QT_DEPRECATED_SINCE(5, 15)
public:
tst_QXmlSimpleReader();
~tst_QXmlSimpleReader();
@@ -157,8 +158,13 @@ class tst_QXmlSimpleReader : public QObject
static QDomDocument fromByteArray(const QString &title, const QByteArray &ba, bool *ok);
XmlServer *server;
QString prefix;
+#endif // QT_DEPRECATED_SINCE(5, 15)
};
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+
tst_QXmlSimpleReader::tst_QXmlSimpleReader() : server(new XmlServer(this))
{
server->start();
@@ -820,5 +826,8 @@ void tst_QXmlSimpleReader::dtdRecursionLimit()
}
}
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
QTEST_MAIN(tst_QXmlSimpleReader)
#include "tst_qxmlsimplereader.moc"