Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions QGumboParser/qgumbonode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,32 @@ QGumboNodes QGumboNode::getElementsByClassName(const QString& name) const
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
const QVector<QStringRef> parts =
value.splitRef(QChar(' '), QString::SkipEmptyParts, Qt::CaseInsensitive);
#else
for (const QStringRef& part: parts) {
if (part.compare(name, Qt::CaseInsensitive) == 0) {
nodes.emplace_back(QGumboNode(node));
break;
}
}
#elif QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QVector<QStringRef> parts =
value.splitRef(QChar(' '), Qt::SkipEmptyParts, Qt::CaseInsensitive);
#endif

for (const QStringRef& part: parts) {
if (part.compare(name, Qt::CaseInsensitive) == 0) {
nodes.emplace_back(QGumboNode(node));
break;
}
}
#else
// Qt6 use QStringView instead of QStringRef
// More info about this on https://doc-snapshots.qt.io/qt6-dev/qtcore-changes-qt6.html#qstringref
const QList<QStringView> parts = QStringView { value }.split(u8' ');
for (const QStringView &part : parts) {
if (part.compare(name, Qt::CaseInsensitive) == 0) {
nodes.emplace_back(QGumboNode(node));
break;
}
}
#endif
}
return false;
};
Expand Down
3 changes: 3 additions & 0 deletions QGumboParser/qgumbonode.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef QGUMBONODE_H
#define QGUMBONODE_H

#include <QtCore/QtGlobal>
#include <vector>
#include <functional>
#include "gumbo-parser/src/gumbo.h"
Expand All @@ -10,7 +11,9 @@ class QString;
class QGumboNode;
class QGumboAttribute;
class QGumboDocument;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
class QStringList;
#endif

typedef std::vector<QGumboNode> QGumboNodes;
typedef std::vector<QGumboAttribute> QGumboAttributes;
Expand Down