diff options
| author | Øystein Heskestad <oystein.heskestad@qt.io> | 2023-03-01 12:30:34 +0100 |
|---|---|---|
| committer | Øystein Heskestad <oystein.heskestad@qt.io> | 2023-03-02 12:20:17 +0100 |
| commit | 56b3123689be7c408d9b6c8c48648a15f0e46658 (patch) | |
| tree | 8bd42a993e2b2b050b4dcb78e80a720d94c5cd49 /examples/xml/htmlinfo/main.cpp | |
| parent | 3c104c279911419f3d0a9e6f3ac050e6f3968e7e (diff) | |
| download | qtbase-56b3123689be7c408d9b6c8c48648a15f0e46658.tar.gz | |
Remove htmlinfo example
This example is removed because what it does is already covered by the
other XML examples.
Task-number: QTBUG-110647
Pick-to: 6.5
Change-Id: If33e3fc55dcd9c7c10cfdfa86405f8bcf5cb6187
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'examples/xml/htmlinfo/main.cpp')
| -rw-r--r-- | examples/xml/htmlinfo/main.cpp | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/examples/xml/htmlinfo/main.cpp b/examples/xml/htmlinfo/main.cpp deleted file mode 100644 index d01421ff84..0000000000 --- a/examples/xml/htmlinfo/main.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include <QtCore> - -void parseHtmlFile(QTextStream &out, const QString &fileName) -{ - QFile file(fileName); - - out << "Analysis of HTML file: " << fileName << Qt::endl; - - if (!file.open(QIODevice::ReadOnly)) { - out << " Couldn't open the file." << Qt::endl << Qt::endl << Qt::endl; - return; - } - -//! [0] - QXmlStreamReader reader(&file); -//! [0] - -//! [1] - int paragraphCount = 0; - QStringList links; - QString title; - while (!reader.atEnd()) { - reader.readNext(); - if (reader.isStartElement()) { - if (reader.name() == QLatin1String("title")) - title = reader.readElementText(); - else if (reader.name() == QLatin1String("a")) - links.append(reader.attributes().value(QLatin1String("href")).toString()); - else if (reader.name() == QLatin1String("p")) - ++paragraphCount; - } - } -//! [1] - -//! [2] - if (reader.hasError()) { - out << " The HTML file isn't well-formed: " << reader.errorString() - << Qt::endl << Qt::endl << Qt::endl; - return; - } -//! [2] - - out << " Title: \"" << title << '"' << Qt::endl - << " Number of paragraphs: " << paragraphCount << Qt::endl - << " Number of links: " << links.size() << Qt::endl - << " Showing first few links:" << Qt::endl; - - while (links.size() > 5) - links.removeLast(); - - for (const QString &link : std::as_const(links)) - out << " " << link << Qt::endl; - out << Qt::endl << Qt::endl; -} - -int main(int argc, char **argv) -{ - // initialize Qt Core application - QCoreApplication app(argc, argv); - - // get a list of all html files in the current directory - const QStringList filter = { QStringLiteral("*.htm"), - QStringLiteral("*.html") }; - - const QStringList htmlFiles = QDir(QStringLiteral(":/")).entryList(filter, QDir::Files); - - QTextStream out(stdout); - - if (htmlFiles.isEmpty()) { - out << "No html files available."; - return 1; - } - - // parse each html file and write the result to file/stream - for (const QString &file : htmlFiles) - parseHtmlFile(out, QStringLiteral(":/") + file); - - return 0; -} |
