File tree Expand file tree Collapse file tree 3 files changed +46
-4
lines changed Expand file tree Collapse file tree 3 files changed +46
-4
lines changed Original file line number Diff line number Diff line change 56
56
#include < QtCore/QDebug>
57
57
#include < QtCore/QFile>
58
58
#include < QtCore/QFileInfo>
59
- #include < QtCore/QTextCodec>
59
+ #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
60
+ # include < QtCore/QTextCodec>
61
+ #endif
60
62
#include < QtCore/QTextStream>
61
63
#include < QtCore/QVariant>
62
64
@@ -402,7 +404,10 @@ bool AbstractMetaBuilder::build()
402
404
return false ;
403
405
404
406
QTextStream stream (&file);
405
- stream.setCodec (QTextCodec::codecForName (" UTF-8" ));
407
+ # if QT_VERSION < QT_VERSION_CHECK(6,0,0)
408
+ stream.setCodec (QTextCodec::codecForName (" UTF-8" ));
409
+ /* Note required in Qt6: see the same call in asttoxml.cpp */
410
+ # endif
406
411
QByteArray contents = stream.readAll ().toUtf8 ();
407
412
file.close ();
408
413
Original file line number Diff line number Diff line change 47
47
48
48
#include < QXmlStreamWriter>
49
49
#include < QTextStream>
50
- #include < QTextCodec>
50
+ #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
51
+ # include < QTextCodec>
52
+ #endif
51
53
#include < QFile>
52
54
53
55
void astToXML (QString name) {
@@ -57,7 +59,18 @@ void astToXML(QString name) {
57
59
return ;
58
60
59
61
QTextStream stream (&file);
62
+ #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
60
63
stream.setCodec (QTextCodec::codecForName (" UTF-8" ));
64
+ #else
65
+ /* NOTE, for Qt6:
66
+ *
67
+ * stream.setEncoding(QStringConverter::Utf8)
68
+ *
69
+ * is the default but will be overridden if the UTF-16 BOM is seen. This
70
+ * is almost certainly the correct behavior because the BOM isn't valid in
71
+ * a text stream otherwise.
72
+ */
73
+ #endif
61
74
QByteArray contents = stream.readAll ().toUtf8 ();
62
75
file.close ();
63
76
@@ -164,7 +177,7 @@ void writeOutClass(QXmlStreamWriter &s, ClassModelItem &item) {
164
177
writeOutEnum (s, enumItem);
165
178
}
166
179
167
- QHash <QString, FunctionModelItem> functionMap = item->functionMap ();
180
+ QMultiHash <QString, FunctionModelItem> functionMap = item->functionMap ();
168
181
for (FunctionModelItem funcItem : functionMap.values ()) {
169
182
writeOutFunction (s, funcItem);
170
183
}
Original file line number Diff line number Diff line change 48
48
#include < QtCore/QMap>
49
49
#include < QDebug>
50
50
51
+ /* BEGIN: Qt6 compatibility. The following can removed when versions of Qt
52
+ * prior to 5.14 are no longer supported.
53
+ */
51
54
/* QString::SkipEmptyParts was replicated in Qt::SplitBehavior in 15.4 and the
52
55
* QString original deprecated then it was removed in Qt6. This provides
53
56
* forward compatibility with Qt6 for versions of Qt prior to 15.4:
58
61
};
59
62
#endif
60
63
64
+ /* Global endl (::endl) is used extensively in the generator .cpp files. This
65
+ * was supported by Qt until Qt6. In Qt5.14 Qt::endl was added in anticipation
66
+ * of the Qt6 change and the use of global endl could be avoided (it does not
67
+ * seem to have been explicitly deprecated). This gives backward compatibility
68
+ * for global endl in Qt6 (not Qt5, where global endl was still available).
69
+ *
70
+ * Note that 'constexpr' is available in Qt6 because Qt6 requires C++17;
71
+ * constexpr was introduced in C++11. Likewise for decltype. Qt::endl is a
72
+ * function so ::endl is a pointer to the function and the implicit conversion
73
+ * is used; this is to cause an compiler error in the future if the base type
74
+ * of Qt::endl changes.
75
+ *
76
+ * When versions of Qt older than 5.14 are no longer supported this can be
77
+ * removed however all the 'endl' references in the code will need to be
78
+ * changed to Qt::endl.
79
+ */
80
+ #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
81
+ static const constexpr decltype (Qt::endl) *endl = Qt::endl;
82
+ #endif
83
+ /* END: Qt compatibility. */
84
+
61
85
class Indentor ;
62
86
63
87
class AbstractMetaType ;
You can’t perform that action at this time.
0 commit comments