summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/sqlite.pri2
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp4
-rw-r--r--src/corelib/configure.json14
-rw-r--r--src/corelib/doc/snippets/resource-system/mainwindow.cpp8
-rw-r--r--src/corelib/global/qfloat16.h2
-rw-r--r--src/corelib/global/qglobal.cpp41
-rw-r--r--src/corelib/global/qglobal.h20
-rw-r--r--src/corelib/global/qglobal_p.h10
-rw-r--r--src/corelib/global/qnamespace.h6
-rw-r--r--src/corelib/io/qbuffer.cpp4
-rw-r--r--src/corelib/io/qdir.cpp6
-rw-r--r--src/corelib/io/qfiledevice.h2
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice_p.h12
-rw-r--r--src/corelib/io/qprocess.h2
-rw-r--r--src/corelib/io/qresource.cpp6
-rw-r--r--src/corelib/io/qresource_p.h56
-rw-r--r--src/corelib/itemmodels/itemmodels.pri17
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h6
-rw-r--r--src/corelib/itemmodels/qabstractproxymodel.cpp12
-rw-r--r--src/corelib/itemmodels/qabstractproxymodel.h3
-rw-r--r--src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp750
-rw-r--r--src/corelib/itemmodels/qconcatenatetablesproxymodel.h100
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp2
-rw-r--r--src/corelib/itemmodels/qstringlistmodel.cpp87
-rw-r--r--src/corelib/itemmodels/qstringlistmodel.h7
-rw-r--r--src/corelib/itemmodels/qtransposeproxymodel.cpp446
-rw-r--r--src/corelib/itemmodels/qtransposeproxymodel.h83
-rw-r--r--src/corelib/itemmodels/qtransposeproxymodel_p.h73
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp15
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib.cpp5
-rw-r--r--src/corelib/kernel/qmetatype.cpp617
-rw-r--r--src/corelib/kernel/qmetatype.h10
-rw-r--r--src/corelib/kernel/qobject.cpp3
-rw-r--r--src/corelib/kernel/qobject_p.h4
-rw-r--r--src/corelib/kernel/qsystemerror.cpp5
-rw-r--r--src/corelib/kernel/qtimer.cpp23
-rw-r--r--src/corelib/kernel/qtimer.h2
-rw-r--r--src/corelib/kernel/qvariant.h4
-rw-r--r--src/corelib/mimetypes/qmimedatabase.cpp62
-rw-r--r--src/corelib/mimetypes/qmimedatabase_p.h7
-rw-r--r--src/corelib/mimetypes/qmimeprovider_p.h16
-rw-r--r--src/corelib/plugin/qfactoryinterface.h3
-rw-r--r--src/corelib/plugin/qplugin.h26
-rw-r--r--src/corelib/serialization/qcborarray.cpp20
-rw-r--r--src/corelib/serialization/qcborarray.h7
-rw-r--r--src/corelib/serialization/qcborcommon.h5
-rw-r--r--src/corelib/serialization/qcbormap.cpp19
-rw-r--r--src/corelib/serialization/qcbormap.h12
-rw-r--r--src/corelib/serialization/qcborstream.cpp16
-rw-r--r--src/corelib/serialization/qcborvalue.cpp526
-rw-r--r--src/corelib/serialization/qcborvalue.h28
-rw-r--r--src/corelib/serialization/qdatastream.cpp1
-rw-r--r--src/corelib/serialization/qdatastream.h5
-rw-r--r--src/corelib/serialization/qjsonarray.cpp17
-rw-r--r--src/corelib/serialization/qjsonarray.h5
-rw-r--r--src/corelib/serialization/qjsondocument.cpp20
-rw-r--r--src/corelib/serialization/qjsondocument.h5
-rw-r--r--src/corelib/serialization/qjsonobject.cpp17
-rw-r--r--src/corelib/serialization/qjsonobject.h5
-rw-r--r--src/corelib/serialization/qjsonvalue.cpp75
-rw-r--r--src/corelib/serialization/qjsonvalue.h8
-rw-r--r--src/corelib/statemachine/qsignaltransition_p.h2
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp4
-rw-r--r--src/corelib/thread/qresultstore.cpp15
-rw-r--r--src/corelib/thread/qresultstore.h2
-rw-r--r--src/corelib/tools/qbytearray.cpp8
-rw-r--r--src/corelib/tools/qbytearraylist.cpp22
-rw-r--r--src/corelib/tools/qbytearraylist.h10
-rw-r--r--src/corelib/tools/qdatetime.cpp22
-rw-r--r--src/corelib/tools/qlocale.cpp43
-rw-r--r--src/corelib/tools/qlocale.h11
-rw-r--r--src/corelib/tools/qlocale.qdoc627
-rw-r--r--src/corelib/tools/qlocale_data_p.h172
-rw-r--r--src/corelib/tools/qlocale_p.h8
-rw-r--r--src/corelib/tools/qmakearray_p.h4
-rw-r--r--src/corelib/tools/qoffsetstringarray_p.h200
-rw-r--r--src/corelib/tools/qstring.cpp30
-rw-r--r--src/corelib/tools/qstring.h6
-rw-r--r--src/corelib/tools/tools.pri1
-rw-r--r--src/dbus/dbus.pro5
-rw-r--r--src/dbus/doc/qtdbus.qdocconf2
-rw-r--r--src/dbus/qdbusargument.cpp2
-rw-r--r--src/dbus/qdbusargument.h12
-rw-r--r--src/dbus/qdbusconnection.h2
-rw-r--r--src/dbus/qdbusconnection_p.h20
-rw-r--r--src/dbus/qdbuserror.cpp145
-rw-r--r--src/dbus/qdbusintegrator.cpp89
-rw-r--r--src/dbus/qdbuspendingcall.cpp12
-rw-r--r--src/dbus/qdbuspendingcall.h2
-rw-r--r--src/dbus/qdbuspendingreply.cpp29
-rw-r--r--src/dbus/qdbuspendingreply.h3
-rw-r--r--src/dbus/qdbusreply.cpp2
-rw-r--r--src/dbus/qdbusreply.h4
-rw-r--r--src/dbus/qdbusservicewatcher.cpp11
-rw-r--r--src/dbus/qdbusutil.cpp30
-rw-r--r--src/gui/accessible/qaccessible.h2
-rw-r--r--src/gui/accessible/qaccessibleobject.h2
-rw-r--r--src/gui/doc/snippets/code/src_gui_kernel_qguiapplication_x11.cpp4
-rw-r--r--src/gui/doc/src/richtext.qdoc3
-rw-r--r--src/gui/image/qicon.cpp7
-rw-r--r--src/gui/image/qimageiohandler.h2
-rw-r--r--src/gui/image/qppmhandler.cpp14
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.cpp6
-rw-r--r--src/gui/itemmodels/qstandarditemmodel_p.h2
-rw-r--r--src/gui/kernel/qguiapplication.h2
-rw-r--r--src/gui/kernel/qoffscreensurface.h2
-rw-r--r--src/gui/kernel/qopenglcontext_p.h2
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp12
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h3
-rw-r--r--src/gui/kernel/qplatformgraphicsbuffer.h2
-rw-r--r--src/gui/kernel/qplatforminputcontext.h2
-rw-r--r--src/gui/kernel/qsessionmanager_p.h2
-rw-r--r--src/gui/kernel/qsimpledrag_p.h2
-rw-r--r--src/gui/kernel/qwindow.cpp27
-rw-r--r--src/gui/kernel/qwindow.h5
-rw-r--r--src/gui/kernel/qwindow_p.h2
-rw-r--r--src/gui/opengl/qopengl.cpp11
-rw-r--r--src/gui/opengl/qopenglfunctions.h18
-rw-r--r--src/gui/opengl/qopenglpaintdevice.h2
-rw-r--r--src/gui/opengl/qopenglshaderprogram.h11
-rw-r--r--src/gui/opengl/qopenglversionfunctions.h1
-rw-r--r--src/gui/painting/qblendfunctions.cpp18
-rw-r--r--src/gui/painting/qcolor.cpp23
-rw-r--r--src/gui/painting/qcolor.h6
-rw-r--r--src/gui/painting/qcompositionfunctions.cpp88
-rw-r--r--src/gui/painting/qdrawhelper.cpp6
-rw-r--r--src/gui/painting/qdrawhelper_neon.cpp30
-rw-r--r--src/gui/painting/qdrawhelper_p.h53
-rw-r--r--src/gui/painting/qdrawhelper_sse2.cpp16
-rw-r--r--src/gui/painting/qmemrotate.cpp14
-rw-r--r--src/gui/painting/qpaintengineex.cpp3
-rw-r--r--src/gui/painting/qpainter.cpp7
-rw-r--r--src/gui/painting/qpainter.h3
-rw-r--r--src/gui/painting/qpdf.cpp15
-rw-r--r--src/gui/painting/qpdf_p.h2
-rw-r--r--src/gui/painting/qpdfwriter.cpp2
-rw-r--r--src/gui/painting/qstroker.cpp5
-rw-r--r--src/gui/painting/qstroker_p.h5
-rw-r--r--src/gui/painting/qvectorpath_p.h6
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.h2
-rw-r--r--src/gui/text/qcssparser.cpp62
-rw-r--r--src/gui/text/qcssparser_p.h1
-rw-r--r--src/gui/text/qcssscanner.cpp847
-rw-r--r--src/gui/text/qfont.cpp132
-rw-r--r--src/gui/text/qfont.h12
-rw-r--r--src/gui/text/qfont_p.h4
-rw-r--r--src/gui/text/qfontdatabase.cpp54
-rw-r--r--src/gui/text/qfontengine.cpp2
-rw-r--r--src/gui/text/qsyntaxhighlighter.h2
-rw-r--r--src/gui/text/qtextformat.cpp23
-rw-r--r--src/gui/text/qtextformat.h6
-rw-r--r--src/gui/text/qtexthtmlparser.cpp3
-rw-r--r--src/gui/text/qtextodfwriter.cpp2
-rw-r--r--src/gui/util/qlayoutpolicy_p.h1
-rw-r--r--src/network/access/qnetworkcookiejar.cpp21
-rw-r--r--src/network/kernel/qauthenticator.cpp15
-rw-r--r--src/network/kernel/qauthenticator_p.h2
-rw-r--r--src/network/kernel/qhostinfo.cpp29
-rw-r--r--src/network/kernel/qhostinfo.h7
-rw-r--r--src/network/ssl/qdtls.h2
-rw-r--r--src/network/ssl/qsslsocket_mac.cpp263
-rw-r--r--src/network/ssl/qsslsocket_p.h5
-rw-r--r--src/network/ssl/qsslsocket_qt.cpp309
-rw-r--r--src/network/ssl/ssl.pri1
-rw-r--r--src/opengl/doc/qtopengl.qdocconf2
-rw-r--r--src/opengl/qgl.cpp29
-rw-r--r--src/opengl/qgl.h16
-rw-r--r--src/opengl/qglshaderprogram.h11
-rw-r--r--src/platformheaders/doc/qtplatformheaders.qdocconf2
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp18
-rw-r--r--src/platformsupport/glxconvenience/qglxconvenience.cpp15
-rw-r--r--src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp3
-rw-r--r--src/platformsupport/themes/genericunix/dbustray/qstatusnotifieritemadaptor.cpp3
-rw-r--r--src/platformsupport/themes/genericunix/dbustray/qxdgnotificationproxy_p.h1
-rw-r--r--src/plugins/bearer/qnetworksession_impl.cpp4
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm1
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp5
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.cpp88
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.h4
-rw-r--r--src/printsupport/kernel/qplatformprintdevice.cpp16
-rw-r--r--src/printsupport/kernel/qprinterinfo.cpp29
-rw-r--r--src/printsupport/kernel/qprinterinfo.h3
-rw-r--r--src/sql/models/qsqltablemodel.cpp10
-rw-r--r--src/sql/models/qsqltablemodel.h3
-rw-r--r--src/testlib/qabstractitemmodeltester.h4
-rw-r--r--src/testlib/qtest.h25
-rw-r--r--src/testlib/qtestblacklist.cpp42
-rw-r--r--src/testlib/qtestblacklist_p.h1
-rw-r--r--src/testlib/qtestcase.cpp119
-rw-r--r--src/testlib/qtestcorelist_p.h17
-rw-r--r--src/tools/moc/generator.cpp8
-rw-r--r--src/tools/moc/moc.cpp2
-rw-r--r--src/tools/qfloat16-tables/gen_qfloat16_tables.cpp2
-rw-r--r--src/tools/tracegen/helpers.cpp2
-rw-r--r--src/widgets/dialogs/qdialog.cpp19
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp2
-rw-r--r--src/widgets/dialogs/qmessagebox.h4
-rw-r--r--src/widgets/dialogs/qsidebar.cpp2
-rw-r--r--src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc16
-rw-r--r--src/widgets/doc/snippets/qtreewidget-using/mainwindow.cpp4
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc18
-rw-r--r--src/widgets/effects/qpixmapfilter.cpp5
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.h2
-rw-r--r--src/widgets/graphicsview/qgraphicslayout.h2
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutitem.h2
-rw-r--r--src/widgets/itemviews/qheaderview.cpp29
-rw-r--r--src/widgets/itemviews/qitemdelegate.cpp6
-rw-r--r--src/widgets/itemviews/qlistview.cpp35
-rw-r--r--src/widgets/itemviews/qlistview_p.h8
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp93
-rw-r--r--src/widgets/itemviews/qlistwidget.h24
-rw-r--r--src/widgets/itemviews/qlistwidget_p.h4
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.cpp4
-rw-r--r--src/widgets/itemviews/qtableview.cpp41
-rw-r--r--src/widgets/itemviews/qtableview.h6
-rw-r--r--src/widgets/itemviews/qtableview_p.h1
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp122
-rw-r--r--src/widgets/itemviews/qtablewidget.h33
-rw-r--r--src/widgets/itemviews/qtablewidget_p.h3
-rw-r--r--src/widgets/itemviews/qtreeview.cpp99
-rw-r--r--src/widgets/itemviews/qtreeview.h6
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp215
-rw-r--r--src/widgets/itemviews/qtreewidget.h53
-rw-r--r--src/widgets/itemviews/qtreewidget_p.h4
-rw-r--r--src/widgets/kernel/qapplication.cpp3
-rw-r--r--src/widgets/kernel/qapplication.h8
-rw-r--r--src/widgets/kernel/qwhatsthis.cpp6
-rw-r--r--src/widgets/kernel/qwidget.cpp35
-rw-r--r--src/widgets/kernel/qwidget.h5
-rw-r--r--src/widgets/kernel/qwidget_p.h1
-rw-r--r--src/widgets/styles/qcommonstyle.cpp41
-rw-r--r--src/widgets/styles/qstyle.h4
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp32
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp6
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp4
-rw-r--r--src/widgets/widgets/qcombobox.cpp5
-rw-r--r--src/widgets/widgets/qcommandlinkbutton.h6
-rw-r--r--src/widgets/widgets/qlabel.cpp2
-rw-r--r--src/widgets/widgets/qmainwindow.cpp6
-rw-r--r--src/widgets/widgets/qmainwindow.h6
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp2
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h2
-rw-r--r--src/widgets/widgets/qmenu.cpp42
-rw-r--r--src/widgets/widgets/qmenu.h4
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp24
-rw-r--r--src/widgets/widgets/qplaintextedit.h4
-rw-r--r--src/widgets/widgets/qtextbrowser.cpp6
-rw-r--r--src/widgets/widgets/qtextedit.cpp29
-rw-r--r--src/widgets/widgets/qtextedit.h4
-rw-r--r--src/widgets/widgets/qtoolbar.cpp38
-rw-r--r--src/widgets/widgets/qtoolbar.h8
-rw-r--r--src/widgets/widgets/qtoolbararealayout.cpp2
-rw-r--r--src/widgets/widgets/qtoolbararealayout_p.h2
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp31
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p.h4
255 files changed, 5952 insertions, 2955 deletions
diff --git a/src/3rdparty/sqlite.pri b/src/3rdparty/sqlite.pri
index cb8b888a6a..068764c726 100644
--- a/src/3rdparty/sqlite.pri
+++ b/src/3rdparty/sqlite.pri
@@ -1,5 +1,5 @@
CONFIG(release, debug|release):DEFINES *= NDEBUG
-DEFINES += SQLITE_ENABLE_COLUMN_METADATA SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE SQLITE_ENABLE_FTS3 SQLITE_ENABLE_FTS3_PARENTHESIS SQLITE_ENABLE_FTS5 SQLITE_ENABLE_RTREE
+DEFINES += SQLITE_ENABLE_COLUMN_METADATA SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE SQLITE_ENABLE_FTS3 SQLITE_ENABLE_FTS3_PARENTHESIS SQLITE_ENABLE_FTS5 SQLITE_ENABLE_RTREE SQLITE_ENABLE_JSON1
!contains(CONFIG, largefile):DEFINES += SQLITE_DISABLE_LFS
qtConfig(posix_fallocate): DEFINES += HAVE_POSIX_FALLOCATE=1
winrt {
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index 28c03553c5..271be248ec 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -303,6 +303,6 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State newState,
}
}
-#include "moc_qpropertyanimation.cpp"
-
QT_END_NAMESPACE
+
+#include "moc_qpropertyanimation.cpp"
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index 183eb3a13e..f18e79f1aa 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -793,6 +793,20 @@
"condition": "features.proxymodel",
"output": [ "publicFeature", "feature" ]
},
+ "transposeproxymodel": {
+ "label": "QTransposeProxyModel",
+ "purpose": "Provides a proxy to swap rows and columns of a model.",
+ "section": "ItemViews",
+ "condition": "features.proxymodel",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "concatenatetablesproxymodel": {
+ "label": "QConcatenateTablesProxyModel",
+ "purpose": "Supports concatenating source models.",
+ "section": "ItemViews",
+ "condition": "features.proxymodel",
+ "output": [ "publicFeature", "feature" ]
+ },
"stringlistmodel": {
"label": "QStringListModel",
"purpose": "Provides a model that supplies strings to views.",
diff --git a/src/corelib/doc/snippets/resource-system/mainwindow.cpp b/src/corelib/doc/snippets/resource-system/mainwindow.cpp
index 6fcf52e588..0ab0034d5e 100644
--- a/src/corelib/doc/snippets/resource-system/mainwindow.cpp
+++ b/src/corelib/doc/snippets/resource-system/mainwindow.cpp
@@ -338,11 +338,11 @@ void MainWindow::loadFile(const QString &fileName)
QTextStream in(&file);
#ifndef QT_NO_CURSOR
- QApplication::setOverrideCursor(Qt::WaitCursor);
+ QGuiApplication::setOverrideCursor(Qt::WaitCursor);
#endif
textEdit->setPlainText(in.readAll());
#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
+ QGuiApplication::restoreOverrideCursor();
#endif
setCurrentFile(fileName);
@@ -365,11 +365,11 @@ bool MainWindow::saveFile(const QString &fileName)
QTextStream out(&file);
#ifndef QT_NO_CURSOR
- QApplication::setOverrideCursor(Qt::WaitCursor);
+ QGuiApplication::setOverrideCursor(Qt::WaitCursor);
#endif
out << textEdit->toPlainText();
#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
+ QGuiApplication::restoreOverrideCursor();
#endif
setCurrentFile(fileName);
diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h
index a8befd7adb..766ab319a4 100644
--- a/src/corelib/global/qfloat16.h
+++ b/src/corelib/global/qfloat16.h
@@ -67,11 +67,9 @@ QT_BEGIN_NAMESPACE
class qfloat16
{
public:
-#ifndef Q_QDOC
Q_DECL_CONSTEXPR inline qfloat16() Q_DECL_NOTHROW : b16(0) { }
inline qfloat16(float f) Q_DECL_NOTHROW;
inline operator float() const Q_DECL_NOTHROW;
-#endif
private:
quint16 b16;
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 5c1665fa00..14fb4e77da 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2142,11 +2142,20 @@ struct QUnixOSVersion
static QString unquote(const char *begin, const char *end)
{
+ // man os-release says:
+ // Variable assignment values must be enclosed in double
+ // or single quotes if they include spaces, semicolons or
+ // other special characters outside of A–Z, a–z, 0–9. Shell
+ // special characters ("$", quotes, backslash, backtick)
+ // must be escaped with backslashes, following shell style.
+ // All strings should be in UTF-8 format, and non-printable
+ // characters should not be used. It is not supported to
+ // concatenate multiple individually quoted strings.
if (*begin == '"') {
Q_ASSERT(end[-1] == '"');
- return QString::fromLatin1(begin + 1, end - begin - 2);
+ return QString::fromUtf8(begin + 1, end - begin - 2);
}
- return QString::fromLatin1(begin, end - begin);
+ return QString::fromUtf8(begin, end - begin);
}
static QByteArray getEtcFileContent(const char *filename)
{
@@ -3243,6 +3252,34 @@ void *qMemSet(void *dest, int c, size_t n) { return memset(dest, c, n); }
// add thread-safety for the Qt wrappers.
static QBasicMutex environmentMutex;
+/*
+ Wraps tzset(), which accesses the environment, so should only be called while
+ we hold the lock on the environment mutex.
+*/
+void qTzSet()
+{
+ QMutexLocker locker(&environmentMutex);
+#if defined(Q_OS_WIN)
+ _tzset();
+#else
+ tzset();
+#endif // Q_OS_WIN
+}
+
+/*
+ Wrap mktime(), which is specified to behave as if it called tzset(), hence
+ shares its implicit environment-dependence.
+*/
+time_t qMkTime(struct tm *when)
+{
+ QMutexLocker locker(&environmentMutex);
+ return mktime(when);
+}
+
+// Also specified to behave as if they call tzset():
+// localtime() -- but not localtime_r(), which we use when threaded
+// strftime() -- not used (except in tests)
+
/*!
\relates <QtGlobal>
\threadsafe
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index b608489576..8680742c94 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -591,11 +591,11 @@ Q_DECL_CONSTEXPR inline qint64 qRound64(float d)
{ return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - float(qint64(d-1)) + 0.5f) + qint64(d-1); }
template <typename T>
-Q_DECL_CONSTEXPR inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
+constexpr inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
template <typename T>
-Q_DECL_CONSTEXPR inline const T &qMax(const T &a, const T &b) { return (a < b) ? b : a; }
+constexpr inline const T &qMax(const T &a, const T &b) { return (a < b) ? b : a; }
template <typename T>
-Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max)
+constexpr inline const T &qBound(const T &min, const T &val, const T &max)
{ return qMax(min, qMin(max, val)); }
#ifndef Q_FORWARD_DECLARE_OBJC_CLASS
@@ -1005,6 +1005,15 @@ QForeachContainer<typename std::decay<T>::type> qMakeForeachContainer(T &&t)
}
}
+
+#if __cplusplus >= 201703L
+// Use C++17 if statement with initializer. User's code ends up in a else so
+// scoping of different ifs is not broken
+#define Q_FOREACH(variable, container) \
+for (auto _container_ = QtPrivate::qMakeForeachContainer(container); \
+ _container_.i != _container_.e; ++_container_.i) \
+ if (variable = *_container_.i; false) {} else
+#else
// Explanation of the control word:
// - it's initialized to 1
// - that means both the inner and outer loops start
@@ -1019,7 +1028,7 @@ for (auto _container_ = QtPrivate::qMakeForeachContainer(container); \
_container_.control && _container_.i != _container_.e; \
++_container_.i, _container_.control ^= 1) \
for (variable = *_container_.i; _container_.control; _container_.control = 0)
-
+#endif
#endif // QT_NO_FOREACH
#define Q_FOREVER for(;;)
@@ -1186,9 +1195,6 @@ namespace QtPrivate {
//like std::enable_if
template <bool B, typename T = void> struct QEnableIf;
template <typename T> struct QEnableIf<true, T> { typedef T Type; };
-
-template <bool B, typename T, typename F> struct QConditional { typedef T Type; };
-template <typename T, typename F> struct QConditional<false, T, F> { typedef F Type; };
}
QT_END_NAMESPACE
diff --git a/src/corelib/global/qglobal_p.h b/src/corelib/global/qglobal_p.h
index 0f092e9006..d52f6268e4 100644
--- a/src/corelib/global/qglobal_p.h
+++ b/src/corelib/global/qglobal_p.h
@@ -61,6 +61,16 @@
#endif
#if defined(__cplusplus)
+#include <time.h>
+
+QT_BEGIN_NAMESPACE
+
+// These behave as if they consult the environment, so need to share its locking:
+Q_CORE_EXPORT void qTzSet();
+Q_CORE_EXPORT time_t qMkTime(struct tm *when);
+
+QT_END_NAMESPACE
+
#if !QT_HAS_BUILTIN(__builtin_available)
#include <initializer_list>
#include <QtCore/qoperatingsystemversion.h>
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index dec2c44637..41b94bf15a 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -516,7 +516,7 @@ public:
AA_SetPalette = 19,
AA_EnableHighDpiScaling = 20,
AA_DisableHighDpiScaling = 21,
- AA_UseStyleSheetPropagationInWidgetStyles = 22, // ### Qt 6: remove me
+ AA_UseStyleSheetPropagationInWidgetStyles = 22,
AA_DontUseNativeDialogs = 23,
AA_SynthesizeMouseForUnhandledTabletEvents = 24,
AA_CompressHighFrequencyEvents = 25,
@@ -1504,9 +1504,11 @@ public:
// Metadata
FontRole = 6,
TextAlignmentRole = 7,
+#if QT_DEPRECATED_SINCE(5, 13)
BackgroundColorRole = 8,
- BackgroundRole = 8,
TextColorRole = 9,
+#endif
+ BackgroundRole = 8,
ForegroundRole = 9,
CheckStateRole = 10,
// Accessibility
diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp
index e0b9c41323..7b3fa2ccad 100644
--- a/src/corelib/io/qbuffer.cpp
+++ b/src/corelib/io/qbuffer.cpp
@@ -60,8 +60,8 @@ public:
QByteArray *buf;
QByteArray defaultBuf;
- virtual qint64 peek(char *data, qint64 maxSize) override;
- virtual QByteArray peek(qint64 maxSize) override;
+ qint64 peek(char *data, qint64 maxSize) override;
+ QByteArray peek(qint64 maxSize) override;
#ifndef QT_NO_QOBJECT
// private slots
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 75fd0f8e0a..0998d7ffd1 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -1040,7 +1040,7 @@ QStringList QDir::nameFilters() const
list of filters specified by \a nameFilters.
Each name filter is a wildcard (globbing) filter that understands
- \c{*} and \c{?} wildcards. (See \l{QRegularExpression wildcard matching}.)
+ \c{*} and \c{?} wildcards. (See \l{Wildcard matching}.)
For example, the following code sets three name filters on a QDir
to ensure that only files with extensions typically used for C++
@@ -2120,7 +2120,7 @@ QString QDir::rootPath()
patterns in the list of \a filters; otherwise returns \c false. The
matching is case insensitive.
- \sa {QRegularExpression Wildcard matching}, QRegularExpression::wildcardToRegularExpression(),
+ \sa {Wildcard matching}, QRegularExpression::wildcardToRegularExpression(),
entryList(), entryInfoList()
*/
bool QDir::match(const QStringList &filters, const QString &fileName)
@@ -2143,7 +2143,7 @@ bool QDir::match(const QStringList &filters, const QString &fileName)
contain multiple patterns separated by spaces or semicolons.
The matching is case insensitive.
- \sa {QRegularExpression wildcard matching}, QRegularExpression::wildcardToRegularExpression,
+ \sa {Wildcard matching}, QRegularExpression::wildcardToRegularExpression,
entryList(), entryInfoList()
*/
bool QDir::match(const QString &filter, const QString &fileName)
diff --git a/src/corelib/io/qfiledevice.h b/src/corelib/io/qfiledevice.h
index af41bec2f6..2d524193c5 100644
--- a/src/corelib/io/qfiledevice.h
+++ b/src/corelib/io/qfiledevice.h
@@ -100,7 +100,7 @@ public:
FileError error() const;
void unsetError();
- virtual void close() override;
+ void close() override;
bool isSequential() const override;
diff --git a/src/corelib/io/qnoncontiguousbytedevice_p.h b/src/corelib/io/qnoncontiguousbytedevice_p.h
index ebed1120db..bbc4ea5ae2 100644
--- a/src/corelib/io/qnoncontiguousbytedevice_p.h
+++ b/src/corelib/io/qnoncontiguousbytedevice_p.h
@@ -179,13 +179,13 @@ class QByteDeviceWrappingIoDevice : public QIODevice
public:
QByteDeviceWrappingIoDevice (QNonContiguousByteDevice *bd);
~QByteDeviceWrappingIoDevice ();
- virtual bool isSequential () const override;
- virtual bool atEnd () const override;
- virtual bool reset () override;
- virtual qint64 size () const override;
+ bool isSequential() const override;
+ bool atEnd() const override;
+ bool reset() override;
+ qint64 size() const override;
protected:
- virtual qint64 readData ( char * data, qint64 maxSize ) override;
- virtual qint64 writeData ( const char * data, qint64 maxSize ) override;
+ qint64 readData(char *data, qint64 maxSize) override;
+ qint64 writeData(const char *data, qint64 maxSize) override;
QNonContiguousByteDevice *byteDevice;
};
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index 474fc87de8..5e022e3a52 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
class QProcessPrivate;
-#if !defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
+#if !defined(Q_OS_WIN)
typedef qint64 Q_PID;
#else
QT_END_NAMESPACE
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index b85bca8590..8a0d2e0200 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -906,8 +906,8 @@ public:
inline QDynamicBufferResourceRoot(const QString &_root) : root(_root), buffer(0) { }
inline ~QDynamicBufferResourceRoot() { }
inline const uchar *mappingBuffer() const { return buffer; }
- virtual QString mappingRoot() const override { return root; }
- virtual ResourceRootType type() const override { return Resource_Buffer; }
+ QString mappingRoot() const override { return root; }
+ ResourceRootType type() const override { return Resource_Buffer; }
// size == -1 means "unknown"
bool registerSelf(const uchar *b, int size)
@@ -989,7 +989,7 @@ public:
}
}
QString mappingFile() const { return fileName; }
- virtual ResourceRootType type() const override { return Resource_File; }
+ ResourceRootType type() const override { return Resource_File; }
bool registerSelf(const QString &f) {
bool fromMM = false;
diff --git a/src/corelib/io/qresource_p.h b/src/corelib/io/qresource_p.h
index dcfe46704c..7451de8809 100644
--- a/src/corelib/io/qresource_p.h
+++ b/src/corelib/io/qresource_p.h
@@ -64,49 +64,49 @@ public:
explicit QResourceFileEngine(const QString &path);
~QResourceFileEngine();
- virtual void setFileName(const QString &file) override;
+ void setFileName(const QString &file) override;
- virtual bool open(QIODevice::OpenMode flags) override ;
- virtual bool close() override;
- virtual bool flush() override;
- virtual qint64 size() const override;
- virtual qint64 pos() const override;
+ bool open(QIODevice::OpenMode flags) override;
+ bool close() override;
+ bool flush() override;
+ qint64 size() const override;
+ qint64 pos() const override;
virtual bool atEnd() const;
- virtual bool seek(qint64) override;
- virtual qint64 read(char *data, qint64 maxlen) override;
- virtual qint64 write(const char *data, qint64 len) override;
+ bool seek(qint64) override;
+ qint64 read(char *data, qint64 maxlen) override;
+ qint64 write(const char *data, qint64 len) override;
- virtual bool remove() override;
- virtual bool copy(const QString &newName) override;
- virtual bool rename(const QString &newName) override;
- virtual bool link(const QString &newName) override;
+ bool remove() override;
+ bool copy(const QString &newName) override;
+ bool rename(const QString &newName) override;
+ bool link(const QString &newName) override;
- virtual bool isSequential() const override;
+ bool isSequential() const override;
- virtual bool isRelativePath() const override;
+ bool isRelativePath() const override;
- virtual bool mkdir(const QString &dirName, bool createParentDirectories) const override;
- virtual bool rmdir(const QString &dirName, bool recurseParentDirectories) const override;
+ bool mkdir(const QString &dirName, bool createParentDirectories) const override;
+ bool rmdir(const QString &dirName, bool recurseParentDirectories) const override;
- virtual bool setSize(qint64 size) override;
+ bool setSize(qint64 size) override;
- virtual QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const override;
+ QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const override;
- virtual bool caseSensitive() const override;
+ bool caseSensitive() const override;
- virtual FileFlags fileFlags(FileFlags type) const override;
+ FileFlags fileFlags(FileFlags type) const override;
- virtual bool setPermissions(uint perms) override;
+ bool setPermissions(uint perms) override;
- virtual QString fileName(QAbstractFileEngine::FileName file) const override;
+ QString fileName(QAbstractFileEngine::FileName file) const override;
- virtual uint ownerId(FileOwner) const override;
- virtual QString owner(FileOwner) const override;
+ uint ownerId(FileOwner) const override;
+ QString owner(FileOwner) const override;
- virtual QDateTime fileTime(FileTime time) const override;
+ QDateTime fileTime(FileTime time) const override;
- virtual Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) override;
- virtual Iterator *endEntryList() override;
+ Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) override;
+ Iterator *endEntryList() override;
bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0) override;
bool supportsExtension(Extension extension) const override;
diff --git a/src/corelib/itemmodels/itemmodels.pri b/src/corelib/itemmodels/itemmodels.pri
index 068a8c4b3a..ebeac6e211 100644
--- a/src/corelib/itemmodels/itemmodels.pri
+++ b/src/corelib/itemmodels/itemmodels.pri
@@ -20,6 +20,14 @@ qtConfig(proxymodel) {
SOURCES += \
itemmodels/qabstractproxymodel.cpp
+ qtConfig(concatenatetablesproxymodel) {
+ HEADERS += \
+ itemmodels/qconcatenatetablesproxymodel.h
+
+ SOURCES += \
+ itemmodels/qconcatenatetablesproxymodel.cpp
+ }
+
qtConfig(identityproxymodel) {
HEADERS += \
itemmodels/qidentityproxymodel.h
@@ -35,6 +43,15 @@ qtConfig(proxymodel) {
SOURCES += \
itemmodels/qsortfilterproxymodel.cpp
}
+
+ qtConfig(transposeproxymodel) {
+ HEADERS += \
+ itemmodels/qtransposeproxymodel.h \
+ itemmodels/qtransposeproxymodel_p.h
+
+ SOURCES += \
+ itemmodels/qtransposeproxymodel.cpp
+ }
}
qtConfig(stringlistmodel) {
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index bec71b0606..c34876d1d6 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -163,6 +163,7 @@ typedef QList<QModelIndex> QModelIndexList;
class QMimeData;
class QAbstractItemModelPrivate;
+class QTransposeProxyModelPrivate;
template <class Key, class T> class QMap;
@@ -173,6 +174,7 @@ class Q_CORE_EXPORT QAbstractItemModel : public QObject
friend class QPersistentModelIndexData;
friend class QAbstractItemViewPrivate;
friend class QIdentityProxyModel;
+ friend class QTransposeProxyModelPrivate;
public:
explicit QAbstractItemModel(QObject *parent = nullptr);
@@ -300,7 +302,9 @@ public Q_SLOTS:
virtual void revert();
protected Q_SLOTS:
- // Qt 6: Make virtual
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ virtual
+#endif
void resetInternalData();
protected:
diff --git a/src/corelib/itemmodels/qabstractproxymodel.cpp b/src/corelib/itemmodels/qabstractproxymodel.cpp
index b7c49a53e4..118e808a3c 100644
--- a/src/corelib/itemmodels/qabstractproxymodel.cpp
+++ b/src/corelib/itemmodels/qabstractproxymodel.cpp
@@ -313,6 +313,18 @@ bool QAbstractProxyModel::setHeaderData(int section, Qt::Orientation orientation
return d->model->setHeaderData(sourceSection, orientation, value, role);
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+/*!
+ \reimp
+ \since 6.0
+ */
+bool QAbstractProxyModel::clearItemData(const QModelIndex &index)
+{
+ Q_D(QAbstractProxyModel);
+ return d->model->clearItemData(mapToSource(index));
+}
+#endif
+
/*!
\reimp
*/
diff --git a/src/corelib/itemmodels/qabstractproxymodel.h b/src/corelib/itemmodels/qabstractproxymodel.h
index c4e5d67908..6d9daee75a 100644
--- a/src/corelib/itemmodels/qabstractproxymodel.h
+++ b/src/corelib/itemmodels/qabstractproxymodel.h
@@ -78,6 +78,9 @@ public:
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
bool setItemData(const QModelIndex& index, const QMap<int, QVariant> &roles) override;
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ bool clearItemData(const QModelIndex &index) override;
+#endif
QModelIndex buddy(const QModelIndex &index) const override;
bool canFetchMore(const QModelIndex &parent) const override;
diff --git a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp
new file mode 100644
index 0000000000..bbfe2dce16
--- /dev/null
+++ b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp
@@ -0,0 +1,750 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qconcatenatetablesproxymodel.h"
+#include <private/qabstractitemmodel_p.h>
+#include "qsize.h"
+#include "qdebug.h"
+
+QT_BEGIN_NAMESPACE
+
+class QConcatenateTablesProxyModelPrivate : public QAbstractItemModelPrivate
+{
+ Q_DECLARE_PUBLIC(QConcatenateTablesProxyModel);
+
+public:
+ QConcatenateTablesProxyModelPrivate();
+
+ int computeRowsPrior(const QAbstractItemModel *sourceModel) const;
+
+ struct SourceModelForRowResult
+ {
+ SourceModelForRowResult() : sourceModel(Q_NULLPTR), sourceRow(-1) {}
+ QAbstractItemModel *sourceModel;
+ int sourceRow;
+ };
+ SourceModelForRowResult sourceModelForRow(int row) const;
+
+ void _q_slotRowsAboutToBeInserted(const QModelIndex &, int start, int end);
+ void _q_slotRowsInserted(const QModelIndex &, int start, int end);
+ void _q_slotRowsAboutToBeRemoved(const QModelIndex &, int start, int end);
+ void _q_slotRowsRemoved(const QModelIndex &, int start, int end);
+ void _q_slotColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end);
+ void _q_slotColumnsInserted(const QModelIndex &parent, int, int);
+ void _q_slotColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+ void _q_slotColumnsRemoved(const QModelIndex &parent, int, int);
+ void _q_slotDataChanged(const QModelIndex &from, const QModelIndex &to, const QVector<int> &roles);
+ void _q_slotSourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint);
+ void _q_slotSourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint);
+ void _q_slotModelAboutToBeReset();
+ void _q_slotModelReset();
+ int columnCountAfterChange(const QAbstractItemModel *model, int newCount) const;
+ int calculatedColumnCount() const;
+ void updateColumnCount();
+ bool mapDropCoordinatesToSource(int row, int column, const QModelIndex &parent,
+ int *sourceRow, int *sourceColumn, QModelIndex *sourceParent, QAbstractItemModel **sourceModel) const;
+
+ QVector<QAbstractItemModel *> m_models;
+ int m_rowCount; // have to maintain it here since we can't compute during model destruction
+ int m_columnCount;
+
+ // for columns{AboutToBe,}{Inserted,Removed}
+ int m_newColumnCount;
+
+ // for layoutAboutToBeChanged/layoutChanged
+ QVector<QPersistentModelIndex> layoutChangePersistentIndexes;
+ QVector<QModelIndex> layoutChangeProxyIndexes;
+};
+
+QConcatenateTablesProxyModelPrivate::QConcatenateTablesProxyModelPrivate()
+ : m_rowCount(0),
+ m_columnCount(0),
+ m_newColumnCount(0)
+{
+}
+
+/*!
+ \since 5.13
+ \class QConcatenateTablesProxyModel
+ \inmodule QtCore
+ \brief The QConcatenateTablesProxyModel class proxies multiple source models, concatenating their rows
+
+ \ingroup model-view
+
+ QConcatenateTablesProxyModel takes multiple source models and concatenates their rows.
+
+ In other words, the proxy will have all rows of the first source model,
+ followed by all rows of the second source model, and so on.
+
+ If the source models don't have the same number of columns, the proxy will only
+ have as many columns as the source model with the smallest number of columns.
+ Additional columns in other source models will simply be ignored.
+
+ Source models can be added and removed at runtime, and the column count is adjusted accordingly.
+
+ This proxy does not inherit from QAbstractProxyModel because it uses multiple source
+ models, rather than a single one.
+
+ Only flat models (lists and tables) are supported, tree models are not.
+
+ \sa QAbstractProxyModel, {Model/View Programming}, QIdentityProxyModel, QAbstractItemModel
+ */
+
+
+/*!
+ Constructs a concatenate-rows proxy model with the given \a parent.
+*/
+QConcatenateTablesProxyModel::QConcatenateTablesProxyModel(QObject *parent)
+ : QAbstractItemModel(*new QConcatenateTablesProxyModelPrivate, parent)
+{
+}
+
+/*!
+ Destroys this proxy model.
+*/
+QConcatenateTablesProxyModel::~QConcatenateTablesProxyModel()
+{
+}
+
+/*!
+ Returns the proxy index for a given \a sourceIndex, which can be from any of the source models.
+*/
+QModelIndex QConcatenateTablesProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
+{
+ Q_D(const QConcatenateTablesProxyModel);
+ if (!sourceIndex.isValid())
+ return QModelIndex();
+ const QAbstractItemModel *sourceModel = sourceIndex.model();
+ if (!d->m_models.contains(const_cast<QAbstractItemModel *>(sourceModel))) {
+ qWarning("QConcatenateTablesProxyModel: index from wrong model passed to mapFromSource");
+ Q_ASSERT(!"QConcatenateTablesProxyModel: index from wrong model passed to mapFromSource");
+ return QModelIndex();
+ }
+ if (sourceIndex.column() >= d->m_columnCount)
+ return QModelIndex();
+ int rowsPrior = d_func()->computeRowsPrior(sourceModel);
+ return createIndex(rowsPrior + sourceIndex.row(), sourceIndex.column(), sourceIndex.internalPointer());
+}
+
+/*!
+ Returns the source index for a given proxy index.
+*/
+QModelIndex QConcatenateTablesProxyModel::mapToSource(const QModelIndex &proxyIndex) const
+{
+ Q_D(const QConcatenateTablesProxyModel);
+ Q_ASSERT(checkIndex(proxyIndex));
+ if (!proxyIndex.isValid())
+ return QModelIndex();
+ if (proxyIndex.model() != this) {
+ qWarning("QConcatenateTablesProxyModel: index from wrong model passed to mapToSource");
+ Q_ASSERT(!"QConcatenateTablesProxyModel: index from wrong model passed to mapToSource");
+ return QModelIndex();
+ }
+ const int row = proxyIndex.row();
+ const auto result = d->sourceModelForRow(row);
+ if (!result.sourceModel)
+ return QModelIndex();
+ return result.sourceModel->index(result.sourceRow, proxyIndex.column());
+}
+
+/*!
+ \reimp
+*/
+QVariant QConcatenateTablesProxyModel::data(const QModelIndex &index, int role) const
+{
+ const QModelIndex sourceIndex = mapToSource(index);
+ Q_ASSERT(checkIndex(index, CheckIndexOption::IndexIsValid));
+ if (!sourceIndex.isValid())
+ return QVariant();
+ return sourceIndex.data(role);
+}
+
+/*!
+ \reimp
+*/
+bool QConcatenateTablesProxyModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ Q_ASSERT(checkIndex(index, CheckIndexOption::IndexIsValid));
+ const QModelIndex sourceIndex = mapToSource(index);
+ Q_ASSERT(sourceIndex.isValid());
+ const auto sourceModel = const_cast<QAbstractItemModel *>(sourceIndex.model());
+ return sourceModel->setData(sourceIndex, value, role);
+}
+
+/*!
+ \reimp
+*/
+QMap<int, QVariant> QConcatenateTablesProxyModel::itemData(const QModelIndex &proxyIndex) const
+{
+ Q_ASSERT(checkIndex(proxyIndex));
+ const QModelIndex sourceIndex = mapToSource(proxyIndex);
+ Q_ASSERT(sourceIndex.isValid());
+ return sourceIndex.model()->itemData(sourceIndex);
+}
+
+/*!
+ \reimp
+*/
+bool QConcatenateTablesProxyModel::setItemData(const QModelIndex &proxyIndex, const QMap<int, QVariant> &roles)
+{
+ Q_ASSERT(checkIndex(proxyIndex));
+ const QModelIndex sourceIndex = mapToSource(proxyIndex);
+ Q_ASSERT(sourceIndex.isValid());
+ const auto sourceModel = const_cast<QAbstractItemModel *>(sourceIndex.model());
+ return sourceModel->setItemData(sourceIndex, roles);
+}
+
+/*!
+ Returns the flags for the given index.
+ If the index is valid, the flags come from the source model for this index.
+ If the index is invalid (as used to determine if dropping onto an empty area
+ in the view is allowed, for instance), the flags from the first model are returned.
+*/
+Qt::ItemFlags QConcatenateTablesProxyModel::flags(const QModelIndex &index) const
+{
+ Q_D(const QConcatenateTablesProxyModel);
+ if (d->m_models.isEmpty())
+ return Qt::NoItemFlags;
+ Q_ASSERT(checkIndex(index));
+ if (!index.isValid())
+ return d->m_models.at(0)->flags(index);
+ const QModelIndex sourceIndex = mapToSource(index);
+ Q_ASSERT(sourceIndex.isValid());
+ return sourceIndex.model()->flags(sourceIndex);
+}
+
+/*!
+ This method returns the horizontal header data for the first source model,
+ and the vertical header data for the source model corresponding to each row.
+ \reimp
+*/
+QVariant QConcatenateTablesProxyModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ Q_D(const QConcatenateTablesProxyModel);
+ if (d->m_models.isEmpty())
+ return QVariant();
+ switch (orientation) {
+ case Qt::Horizontal:
+ return d->m_models.at(0)->headerData(section, orientation, role);
+ case Qt::Vertical: {
+ const auto result = d->sourceModelForRow(section);
+ Q_ASSERT(result.sourceModel);
+ return result.sourceModel->headerData(result.sourceRow, orientation, role);
+ }
+ }
+ return QVariant();
+}
+
+/*!
+ This method returns the column count of the source model with the smallest number of columns.
+ \reimp
+*/
+int QConcatenateTablesProxyModel::columnCount(const QModelIndex &parent) const
+{
+ Q_D(const QConcatenateTablesProxyModel);
+ if (parent.isValid())
+ return 0; // flat model
+ return d->m_columnCount;
+}
+
+/*!
+ \reimp
+*/
+QModelIndex QConcatenateTablesProxyModel::index(int row, int column, const QModelIndex &parent) const
+{
+ Q_D(const QConcatenateTablesProxyModel);
+ Q_ASSERT(hasIndex(row, column, parent));
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
+ Q_ASSERT(checkIndex(parent, QAbstractItemModel::CheckIndexOption::ParentIsInvalid)); // flat model
+ const auto result = d->sourceModelForRow(row);
+ Q_ASSERT(result.sourceModel);
+ return mapFromSource(result.sourceModel->index(result.sourceRow, column));
+}
+
+/*!
+ \reimp
+*/
+QModelIndex QConcatenateTablesProxyModel::parent(const QModelIndex &index) const
+{
+ Q_UNUSED(index);
+ return QModelIndex(); // flat model, no hierarchy
+}
+
+/*!
+ \reimp
+*/
+int QConcatenateTablesProxyModel::rowCount(const QModelIndex &parent) const
+{
+ Q_D(const QConcatenateTablesProxyModel);
+ Q_ASSERT(checkIndex(parent, QAbstractItemModel::CheckIndexOption::ParentIsInvalid)); // flat model
+ Q_UNUSED(parent);
+ return d->m_rowCount;
+}
+
+/*!
+ This method returns the mime types for the first source model.
+ \reimp
+*/
+QStringList QConcatenateTablesProxyModel::mimeTypes() const
+{
+ Q_D(const QConcatenateTablesProxyModel);
+ if (d->m_models.isEmpty())
+ return QStringList();
+ return d->m_models.at(0)->mimeTypes();
+}
+
+/*!
+ The call is forwarded to the source model of the first index in the list of \a indexes.
+
+ Important: please note that this proxy only supports dragging a single row.
+ It will assert if called with indexes from multiple rows, because dragging rows that
+ might come from different source models cannot be implemented generically by this proxy model.
+ Each piece of data in the QMimeData needs to be merged, which is data-type-specific.
+ Reimplement this method in a subclass if you want to support dragging multiple rows.
+
+ \reimp
+*/
+QMimeData *QConcatenateTablesProxyModel::mimeData(const QModelIndexList &indexes) const
+{
+ Q_D(const QConcatenateTablesProxyModel);
+ if (indexes.isEmpty())
+ return nullptr;
+ const QModelIndex firstIndex = indexes.first();
+ Q_ASSERT(checkIndex(firstIndex, CheckIndexOption::IndexIsValid));
+ const auto result = d->sourceModelForRow(firstIndex.row());
+ QModelIndexList sourceIndexes;
+ sourceIndexes.reserve(indexes.count());
+ for (const QModelIndex &index : indexes) {
+ const QModelIndex sourceIndex = mapToSource(index);
+ Q_ASSERT(sourceIndex.model() == result.sourceModel); // see documentation above
+ sourceIndexes.append(sourceIndex);
+ }
+ return result.sourceModel->mimeData(sourceIndexes);
+}
+
+
+bool QConcatenateTablesProxyModelPrivate::mapDropCoordinatesToSource(int row, int column, const QModelIndex &parent,
+ int *sourceRow, int *sourceColumn, QModelIndex *sourceParent, QAbstractItemModel **sourceModel) const
+{
+ Q_Q(const QConcatenateTablesProxyModel);
+ *sourceColumn = column;
+ if (!parent.isValid()) {
+ // Drop after the last item
+ if (row == -1 || row == m_rowCount) {
+ *sourceRow = -1;
+ *sourceModel = m_models.constLast();
+ return true;
+ }
+ // Drop between toplevel items
+ const auto result = sourceModelForRow(row);
+ Q_ASSERT(result.sourceModel);
+ *sourceRow = result.sourceRow;
+ *sourceModel = result.sourceModel;
+ return true;
+ } else {
+ if (row > -1)
+ return false; // flat model, no dropping as new children of items
+ // Drop onto item
+ const int targetRow = parent.row();
+ const auto result = sourceModelForRow(targetRow);
+ Q_ASSERT(result.sourceModel);
+ const QModelIndex sourceIndex = q->mapToSource(parent);
+ *sourceRow = -1;
+ *sourceParent = sourceIndex;
+ *sourceModel = result.sourceModel;
+ return true;
+ }
+}
+
+/*!
+ \reimp
+*/
+bool QConcatenateTablesProxyModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
+{
+ Q_D(const QConcatenateTablesProxyModel);
+ if (d->m_models.isEmpty())
+ return false;
+
+ int sourceRow, sourceColumn;
+ QModelIndex sourceParent;
+ QAbstractItemModel *sourceModel;
+ if (!d->mapDropCoordinatesToSource(row, column, parent, &sourceRow, &sourceColumn, &sourceParent, &sourceModel))
+ return false;
+ return sourceModel->canDropMimeData(data, action, sourceRow, sourceColumn, sourceParent);
+}
+
+/*!
+ QConcatenateTablesProxyModel handles dropping onto an item, between items, and after the last item.
+ In all cases the call is forwarded to the underlying source model.
+ When dropping onto an item, the source model for this item is called.
+ When dropping between items, the source model immediately below the drop position is called.
+ When dropping after the last item, the last source model is called.
+
+ \reimp
+*/
+bool QConcatenateTablesProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
+{
+ Q_D(const QConcatenateTablesProxyModel);
+ if (d->m_models.isEmpty())
+ return false;
+ int sourceRow, sourceColumn;
+ QModelIndex sourceParent;
+ QAbstractItemModel *sourceModel;
+ if (!d->mapDropCoordinatesToSource(row, column, parent, &sourceRow, &sourceColumn, &sourceParent, &sourceModel))
+ return false;
+
+ return sourceModel->dropMimeData(data, action, sourceRow, sourceColumn, sourceParent);
+}
+
+/*!
+ \reimp
+*/
+QSize QConcatenateTablesProxyModel::span(const QModelIndex &index) const
+{
+ Q_D(const QConcatenateTablesProxyModel);
+ Q_ASSERT(checkIndex(index));
+ if (d->m_models.isEmpty() || !index.isValid())
+ return QSize();
+ const QModelIndex sourceIndex = mapToSource(index);
+ Q_ASSERT(sourceIndex.isValid());
+ return sourceIndex.model()->span(sourceIndex);
+}
+
+/*!
+ Adds a source model \a sourceModel, below all previously added source models.
+
+ The ownership of \a sourceModel is not affected by this.
+
+ The same source model cannot be added more than once.
+ */
+void QConcatenateTablesProxyModel::addSourceModel(QAbstractItemModel *sourceModel)
+{
+ Q_D(QConcatenateTablesProxyModel);
+ Q_ASSERT(sourceModel);
+ Q_ASSERT(!d->m_models.contains(sourceModel));
+ connect(sourceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)), this, SLOT(_q_slotDataChanged(QModelIndex,QModelIndex,QVector<int>)));
+ connect(sourceModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(_q_slotRowsInserted(QModelIndex,int,int)));
+ connect(sourceModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(_q_slotRowsRemoved(QModelIndex,int,int)));
+ connect(sourceModel, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(_q_slotRowsAboutToBeInserted(QModelIndex,int,int)));
+ connect(sourceModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(_q_slotRowsAboutToBeRemoved(QModelIndex,int,int)));
+
+ connect(sourceModel, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(_q_slotColumnsInserted(QModelIndex,int,int)));
+ connect(sourceModel, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(_q_slotColumnsRemoved(QModelIndex,int,int)));
+ connect(sourceModel, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(_q_slotColumnsAboutToBeInserted(QModelIndex,int,int)));
+ connect(sourceModel, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(_q_slotColumnsAboutToBeRemoved(QModelIndex,int,int)));
+
+ connect(sourceModel, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>, QAbstractItemModel::LayoutChangeHint)),
+ this, SLOT(_q_slotSourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>, QAbstractItemModel::LayoutChangeHint)));
+ connect(sourceModel, SIGNAL(layoutChanged(QList<QPersistentModelIndex>, QAbstractItemModel::LayoutChangeHint)),
+ this, SLOT(_q_slotSourceLayoutChanged(QList<QPersistentModelIndex>, QAbstractItemModel::LayoutChangeHint)));
+ connect(sourceModel, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_slotModelAboutToBeReset()));
+ connect(sourceModel, SIGNAL(modelReset()), this, SLOT(_q_slotModelReset()));
+
+ const int newRows = sourceModel->rowCount();
+ if (newRows > 0)
+ beginInsertRows(QModelIndex(), d->m_rowCount, d->m_rowCount + newRows - 1);
+ d->m_rowCount += newRows;
+ d->m_models.append(sourceModel);
+ if (newRows > 0)
+ endInsertRows();
+
+ d->updateColumnCount();
+}
+
+/*!
+ Removes the source model \a sourceModel, which was previously added to this proxy.
+
+ The ownership of \a sourceModel is not affected by this.
+*/
+void QConcatenateTablesProxyModel::removeSourceModel(QAbstractItemModel *sourceModel)
+{
+ Q_D(QConcatenateTablesProxyModel);
+ Q_ASSERT(d->m_models.contains(sourceModel));
+ disconnect(sourceModel, 0, this, 0);
+
+ const int rowsRemoved = sourceModel->rowCount();
+ const int rowsPrior = d->computeRowsPrior(sourceModel); // location of removed section
+
+ if (rowsRemoved > 0)
+ beginRemoveRows(QModelIndex(), rowsPrior, rowsPrior + rowsRemoved - 1);
+ d->m_models.removeOne(sourceModel);
+ d->m_rowCount -= rowsRemoved;
+ if (rowsRemoved > 0)
+ endRemoveRows();
+
+ d->updateColumnCount();
+}
+
+void QConcatenateTablesProxyModelPrivate::_q_slotRowsAboutToBeInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_Q(QConcatenateTablesProxyModel);
+ if (parent.isValid()) // not supported, the proxy is a flat model
+ return;
+ const QAbstractItemModel * const model = static_cast<QAbstractItemModel *>(q->sender());
+ const int rowsPrior = computeRowsPrior(model);
+ q->beginInsertRows(QModelIndex(), rowsPrior + start, rowsPrior + end);
+}
+
+void QConcatenateTablesProxyModelPrivate::_q_slotRowsInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_Q(QConcatenateTablesProxyModel);
+ if (parent.isValid()) // flat model
+ return;
+ m_rowCount += end - start + 1;
+ q->endInsertRows();
+}
+
+void QConcatenateTablesProxyModelPrivate::_q_slotRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
+{
+ Q_Q(QConcatenateTablesProxyModel);
+ if (parent.isValid()) // flat model
+ return;
+ const QAbstractItemModel * const model = static_cast<QAbstractItemModel *>(q->sender());
+ const int rowsPrior = computeRowsPrior(model);
+ q->beginRemoveRows(QModelIndex(), rowsPrior + start, rowsPrior + end);
+}
+
+void QConcatenateTablesProxyModelPrivate::_q_slotRowsRemoved(const QModelIndex &parent, int start, int end)
+{
+ Q_Q(QConcatenateTablesProxyModel);
+ if (parent.isValid()) // flat model
+ return;
+ m_rowCount -= end - start + 1;
+ q->endRemoveRows();
+}
+
+void QConcatenateTablesProxyModelPrivate::_q_slotColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_Q(QConcatenateTablesProxyModel);
+ if (parent.isValid()) // flat model
+ return;
+ const QAbstractItemModel * const model = static_cast<QAbstractItemModel *>(q->sender());
+ const int oldColCount = model->columnCount();
+ const int newColCount = columnCountAfterChange(model, oldColCount + end - start + 1);
+ Q_ASSERT(newColCount >= oldColCount);
+ if (newColCount > oldColCount)
+ // If the underlying models have a different number of columns (example: 2 and 3), inserting 2 columns in
+ // the first model leads to inserting only one column in the proxy, since qMin(2+2,3) == 3.
+ q->beginInsertColumns(QModelIndex(), start, qMin(end, start + newColCount - oldColCount - 1));
+ m_newColumnCount = newColCount;
+}
+
+void QConcatenateTablesProxyModelPrivate::_q_slotColumnsInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_UNUSED(start);
+ Q_UNUSED(end);
+ Q_Q(QConcatenateTablesProxyModel);
+ if (parent.isValid()) // flat model
+ return;
+ if (m_newColumnCount != m_columnCount) {
+ m_columnCount = m_newColumnCount;
+ q->endInsertColumns();
+ }
+}
+
+void QConcatenateTablesProxyModelPrivate::_q_slotColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
+{
+ Q_Q(QConcatenateTablesProxyModel);
+ if (parent.isValid()) // flat model
+ return;
+ const QAbstractItemModel * const model = static_cast<QAbstractItemModel *>(q->sender());
+ const int oldColCount = model->columnCount();
+ const int newColCount = columnCountAfterChange(model, oldColCount - (end - start + 1));
+ Q_ASSERT(newColCount <= oldColCount);
+ if (newColCount < oldColCount)
+ q->beginRemoveColumns(QModelIndex(), start, qMax(end, start + oldColCount - newColCount - 1));
+ m_newColumnCount = newColCount;
+}
+
+void QConcatenateTablesProxyModelPrivate::_q_slotColumnsRemoved(const QModelIndex &parent, int start, int end)
+{
+ Q_Q(QConcatenateTablesProxyModel);
+ Q_UNUSED(start);
+ Q_UNUSED(end);
+ if (parent.isValid()) // flat model
+ return;
+ if (m_newColumnCount != m_columnCount) {
+ m_columnCount = m_newColumnCount;
+ q->endRemoveColumns();
+ }
+}
+
+void QConcatenateTablesProxyModelPrivate::_q_slotDataChanged(const QModelIndex &from, const QModelIndex &to, const QVector<int> &roles)
+{
+ Q_Q(QConcatenateTablesProxyModel);
+ Q_ASSERT(from.isValid());
+ Q_ASSERT(to.isValid());
+ const QModelIndex myFrom = q->mapFromSource(from);
+ Q_ASSERT(q->checkIndex(myFrom, QAbstractItemModel::CheckIndexOption::IndexIsValid));
+ const QModelIndex myTo = q->mapFromSource(to);
+ Q_ASSERT(q->checkIndex(myTo, QAbstractItemModel::CheckIndexOption::IndexIsValid));
+ emit q->dataChanged(myFrom, myTo, roles);
+}
+
+void QConcatenateTablesProxyModelPrivate::_q_slotSourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
+{
+ Q_Q(QConcatenateTablesProxyModel);
+
+ if (!sourceParents.isEmpty() && !sourceParents.contains(QModelIndex()))
+ return;
+
+ emit q->layoutAboutToBeChanged({}, hint);
+
+ const QModelIndexList persistentIndexList = q->persistentIndexList();
+ layoutChangePersistentIndexes.reserve(persistentIndexList.size());
+ layoutChangeProxyIndexes.reserve(persistentIndexList.size());
+
+ for (const QPersistentModelIndex &proxyPersistentIndex : persistentIndexList) {
+ layoutChangeProxyIndexes.append(proxyPersistentIndex);
+ Q_ASSERT(proxyPersistentIndex.isValid());
+ const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
+ Q_ASSERT(srcPersistentIndex.isValid());
+ layoutChangePersistentIndexes << srcPersistentIndex;
+ }
+}
+
+void QConcatenateTablesProxyModelPrivate::_q_slotSourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
+{
+ Q_Q(QConcatenateTablesProxyModel);
+ if (!sourceParents.isEmpty() && !sourceParents.contains(QModelIndex()))
+ return;
+ for (int i = 0; i < layoutChangeProxyIndexes.size(); ++i) {
+ const QModelIndex proxyIdx = layoutChangeProxyIndexes.at(i);
+ const QModelIndex newProxyIdx = q->mapFromSource(layoutChangePersistentIndexes.at(i));
+ q->changePersistentIndex(proxyIdx, newProxyIdx);
+ }
+
+ layoutChangePersistentIndexes.clear();
+ layoutChangeProxyIndexes.clear();
+
+ emit q->layoutChanged({}, hint);
+}
+
+void QConcatenateTablesProxyModelPrivate::_q_slotModelAboutToBeReset()
+{
+ Q_Q(QConcatenateTablesProxyModel);
+ Q_ASSERT(m_models.contains(const_cast<QAbstractItemModel *>(static_cast<const QAbstractItemModel *>(q->sender()))));
+ q->beginResetModel();
+ // A reset might reduce both rowCount and columnCount, and we can't notify of both at the same time,
+ // and notifying of one after the other leaves an intermediary invalid situation.
+ // So the only safe choice is to forward it as a full reset.
+}
+
+void QConcatenateTablesProxyModelPrivate::_q_slotModelReset()
+{
+ Q_Q(QConcatenateTablesProxyModel);
+ Q_ASSERT(m_models.contains(const_cast<QAbstractItemModel *>(static_cast<const QAbstractItemModel *>(q->sender()))));
+ m_columnCount = calculatedColumnCount();
+ m_rowCount = computeRowsPrior(nullptr);
+ q->endResetModel();
+}
+
+int QConcatenateTablesProxyModelPrivate::calculatedColumnCount() const
+{
+ if (m_models.isEmpty())
+ return 0;
+
+ const auto it = std::min_element(m_models.begin(), m_models.end(), [](const QAbstractItemModel* model1, const QAbstractItemModel* model2) {
+ return model1->columnCount() < model2->columnCount();
+ });
+ return (*it)->columnCount();
+}
+
+void QConcatenateTablesProxyModelPrivate::updateColumnCount()
+{
+ Q_Q(QConcatenateTablesProxyModel);
+ const int newColumnCount = calculatedColumnCount();
+ const int columnDiff = newColumnCount - m_columnCount;
+ if (columnDiff > 0) {
+ q->beginInsertColumns(QModelIndex(), m_columnCount, m_columnCount + columnDiff - 1);
+ m_columnCount = newColumnCount;
+ q->endInsertColumns();
+ } else if (columnDiff < 0) {
+ const int lastColumn = m_columnCount - 1;
+ q->beginRemoveColumns(QModelIndex(), lastColumn + columnDiff + 1, lastColumn);
+ m_columnCount = newColumnCount;
+ q->endRemoveColumns();
+ }
+}
+
+int QConcatenateTablesProxyModelPrivate::columnCountAfterChange(const QAbstractItemModel *model, int newCount) const
+{
+ int newColumnCount = 0;
+ for (int i = 0; i < m_models.count(); ++i) {
+ const QAbstractItemModel *mod = m_models.at(i);
+ const int colCount = mod == model ? newCount : mod->columnCount();
+ if (i == 0)
+ newColumnCount = colCount;
+ else
+ newColumnCount = qMin(colCount, newColumnCount);
+ }
+ return newColumnCount;
+}
+
+int QConcatenateTablesProxyModelPrivate::computeRowsPrior(const QAbstractItemModel *sourceModel) const
+{
+ int rowsPrior = 0;
+ for (const QAbstractItemModel *model : m_models) {
+ if (model == sourceModel)
+ break;
+ rowsPrior += model->rowCount();
+ }
+ return rowsPrior;
+}
+
+QConcatenateTablesProxyModelPrivate::SourceModelForRowResult QConcatenateTablesProxyModelPrivate::sourceModelForRow(int row) const
+{
+ QConcatenateTablesProxyModelPrivate::SourceModelForRowResult result;
+ int rowCount = 0;
+ for (QAbstractItemModel *model : m_models) {
+ const int subRowCount = model->rowCount();
+ if (rowCount + subRowCount > row) {
+ result.sourceModel = model;
+ break;
+ }
+ rowCount += subRowCount;
+ }
+ result.sourceRow = row - rowCount;
+ return result;
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qconcatenatetablesproxymodel.cpp"
diff --git a/src/corelib/itemmodels/qconcatenatetablesproxymodel.h b/src/corelib/itemmodels/qconcatenatetablesproxymodel.h
new file mode 100644
index 0000000000..85fc6a9c72
--- /dev/null
+++ b/src/corelib/itemmodels/qconcatenatetablesproxymodel.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCONCATENATEROWSPROXYMODEL_H
+#define QCONCATENATEROWSPROXYMODEL_H
+
+#include <QtCore/qabstractitemmodel.h>
+
+QT_BEGIN_NAMESPACE
+
+class QConcatenateTablesProxyModelPrivate;
+
+class Q_CORE_EXPORT QConcatenateTablesProxyModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ explicit QConcatenateTablesProxyModel(QObject *parent = nullptr);
+ ~QConcatenateTablesProxyModel();
+
+ Q_SCRIPTABLE void addSourceModel(QAbstractItemModel *sourceModel);
+ Q_SCRIPTABLE void removeSourceModel(QAbstractItemModel *sourceModel);
+
+ QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
+ QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
+ QMap<int, QVariant> itemData(const QModelIndex &proxyIndex) const override;
+ bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) override;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
+ QModelIndex parent(const QModelIndex &index) const override;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QStringList mimeTypes() const override;
+ QMimeData *mimeData(const QModelIndexList &indexes) const override;
+ bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
+ bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
+ QSize span(const QModelIndex &index) const override;
+
+private:
+ Q_DECLARE_PRIVATE(QConcatenateTablesProxyModel)
+ Q_DISABLE_COPY(QConcatenateTablesProxyModel)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_slotRowsAboutToBeInserted(const QModelIndex &, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_slotRowsInserted(const QModelIndex &, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_slotRowsAboutToBeRemoved(const QModelIndex &, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_slotRowsRemoved(const QModelIndex &, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_slotColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_slotColumnsInserted(const QModelIndex &parent, int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_slotColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_slotColumnsRemoved(const QModelIndex &parent, int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_slotDataChanged(const QModelIndex &from, const QModelIndex &to, const QVector<int> &roles))
+ Q_PRIVATE_SLOT(d_func(), void _q_slotSourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>, QAbstractItemModel::LayoutChangeHint))
+ Q_PRIVATE_SLOT(d_func(), void _q_slotSourceLayoutChanged(const QList<QPersistentModelIndex> &, QAbstractItemModel::LayoutChangeHint))
+ Q_PRIVATE_SLOT(d_func(), void _q_slotModelAboutToBeReset())
+ Q_PRIVATE_SLOT(d_func(), void _q_slotModelReset())
+};
+
+QT_END_NAMESPACE
+
+#endif // QCONCATENATEROWSPROXYMODEL_H
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
index 21fbf83382..2ae4e4d5ee 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -424,7 +424,7 @@ public:
void updateChildrenMapping(const QModelIndex &source_parent, Mapping *parent_mapping,
Qt::Orientation orient, int start, int end, int delta_item_count, bool remove);
- virtual void _q_sourceModelDestroyed() override;
+ void _q_sourceModelDestroyed() override;
bool needsReorder(const QVector<int> &source_rows, const QModelIndex &source_parent) const;
diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp
index 567e6fa35e..cc7a885641 100644
--- a/src/corelib/itemmodels/qstringlistmodel.cpp
+++ b/src/corelib/itemmodels/qstringlistmodel.cpp
@@ -136,6 +136,42 @@ QModelIndex QStringListModel::sibling(int row, int column, const QModelIndex &id
}
/*!
+ \reimp
+ \since 5.13
+*/
+QMap<int, QVariant> QStringListModel::itemData(const QModelIndex &index) const
+{
+ if (!checkIndex(index, CheckIndexOption::IndexIsValid | CheckIndexOption::ParentIsInvalid))
+ return QMap<int, QVariant>{};
+ const QVariant displayData = lst.at(index.row());
+ return QMap<int, QVariant>{{
+ std::make_pair<int>(Qt::DisplayRole, displayData),
+ std::make_pair<int>(Qt::EditRole, displayData)
+ }};
+}
+
+/*!
+ \reimp
+ \since 5.13
+ If \a roles contains both Qt::DisplayRole and Qt::EditRole, the latter will take precedence
+*/
+bool QStringListModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles)
+{
+ if (roles.isEmpty())
+ return false;
+ if (std::any_of(roles.keyBegin(), roles.keyEnd(), [](int role) -> bool {
+ return role != Qt::DisplayRole && role != Qt::EditRole;
+ })) {
+ return false;
+ }
+ auto roleIter = roles.constFind(Qt::EditRole);
+ if (roleIter == roles.constEnd())
+ roleIter = roles.constFind(Qt::DisplayRole);
+ Q_ASSERT(roleIter != roles.constEnd());
+ return setData(index, roleIter.value(), roleIter.key());
+}
+
+/*!
Returns data for the specified \a role, from the item with the
given \a index.
@@ -185,18 +221,23 @@ bool QStringListModel::setData(const QModelIndex &index, const QVariant &value,
if (index.row() >= 0 && index.row() < lst.size()
&& (role == Qt::EditRole || role == Qt::DisplayRole)) {
lst.replace(index.row(), value.toString());
- QVector<int> roles;
- roles.reserve(2);
- roles.append(Qt::DisplayRole);
- roles.append(Qt::EditRole);
- emit dataChanged(index, index, roles);
- // once Q_COMPILER_UNIFORM_INIT can be used, change to:
- // emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole});
+ emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole});
return true;
}
return false;
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+/*!
+ \reimp
+ \since 6.0
+ */
+bool QStringListModel::clearItemData(const QModelIndex &index)
+{
+ return setData(index, QVariant(), Qt::EditRole);
+}
+#endif
+
/*!
Inserts \a count rows into the model, beginning at the given \a row.
@@ -249,6 +290,38 @@ bool QStringListModel::removeRows(int row, int count, const QModelIndex &parent)
return true;
}
+/*!
+ \since 5.13
+ \reimp
+*/
+bool QStringListModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
+{
+ if (sourceRow < 0
+ || sourceRow + count - 1 >= rowCount(sourceParent)
+ || destinationChild <= 0
+ || destinationChild > rowCount(destinationParent)
+ || sourceRow == destinationChild - 1
+ || count <= 0) {
+ return false;
+ }
+ if (!beginMoveRows(QModelIndex(), sourceRow, sourceRow + count - 1, QModelIndex(), destinationChild))
+ return false;
+ /*
+ QList::move assumes that the second argument is the index where the item will end up to
+ i.e. the valid range for that argument is from 0 to QList::size()-1
+ QAbstractItemModel::moveRows when source and destinations have the same parent assumes that
+ the item will end up being in the row BEFORE the one indicated by destinationChild
+ i.e. the valid range for that argument is from 1 to QList::size()
+ For this reason we remove 1 from destinationChild when using it inside QList
+ */
+ destinationChild--;
+ const int fromRow = destinationChild < sourceRow ? (sourceRow + count - 1) : sourceRow;
+ while (count--)
+ lst.move(fromRow, destinationChild);
+ endMoveRows();
+ return true;
+}
+
static bool ascendingLessThan(const QPair<QString, int> &s1, const QPair<QString, int> &s2)
{
return s1.first < s2.first;
diff --git a/src/corelib/itemmodels/qstringlistmodel.h b/src/corelib/itemmodels/qstringlistmodel.h
index a40c13ae40..6c83917054 100644
--- a/src/corelib/itemmodels/qstringlistmodel.h
+++ b/src/corelib/itemmodels/qstringlistmodel.h
@@ -59,11 +59,18 @@ public:
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ bool clearItemData(const QModelIndex &index) override;
+#endif
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
+ bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
+
+ QMap<int, QVariant> itemData(const QModelIndex &index) const override;
+ bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) override;
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
diff --git a/src/corelib/itemmodels/qtransposeproxymodel.cpp b/src/corelib/itemmodels/qtransposeproxymodel.cpp
new file mode 100644
index 0000000000..dd84b97118
--- /dev/null
+++ b/src/corelib/itemmodels/qtransposeproxymodel.cpp
@@ -0,0 +1,446 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Luca Beldi <v.ronin@yahoo.it>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtransposeproxymodel.h"
+#include <private/qtransposeproxymodel_p.h>
+#include <QtCore/qvector.h>
+#include <QtCore/qmetaobject.h>
+#include <QtCore/qsize.h>
+
+QT_BEGIN_NAMESPACE
+
+QModelIndex QTransposeProxyModelPrivate::uncheckedMapToSource(const QModelIndex &proxyIndex) const
+{
+ if (!model || !proxyIndex.isValid())
+ return QModelIndex();
+ if (proxyIndex.internalPointer())
+ return model->createIndex(proxyIndex.column(), proxyIndex.row(), proxyIndex.internalPointer());
+ return model->index(proxyIndex.column(), proxyIndex.row());
+}
+
+QModelIndex QTransposeProxyModelPrivate::uncheckedMapFromSource(const QModelIndex &sourceIndex) const
+{
+ if (!model || !sourceIndex.isValid())
+ return QModelIndex();
+ Q_Q(const QTransposeProxyModel);
+ return q->createIndex(sourceIndex.column(), sourceIndex.row(), sourceIndex.internalPointer());
+}
+
+void QTransposeProxyModelPrivate::onLayoutChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint)
+{
+ Q_Q(QTransposeProxyModel);
+ QModelIndexList toList;
+ toList.reserve(layoutChangePersistentIndexes.size());
+ for (const QPersistentModelIndex &persistIdx : qAsConst(layoutChangePersistentIndexes))
+ toList << q->mapFromSource(persistIdx);
+ q->changePersistentIndexList(layoutChangeProxyIndexes, toList);
+ layoutChangeProxyIndexes.clear();
+ layoutChangePersistentIndexes.clear();
+ QList<QPersistentModelIndex> proxyParents;
+ proxyParents.reserve(parents.size());
+ for (const QPersistentModelIndex &srcParent : parents)
+ proxyParents << q->mapFromSource(srcParent);
+ QAbstractItemModel::LayoutChangeHint proxyHint = QAbstractItemModel::NoLayoutChangeHint;
+ if (hint == QAbstractItemModel::VerticalSortHint)
+ proxyHint = QAbstractItemModel::HorizontalSortHint;
+ else if (hint == QAbstractItemModel::HorizontalSortHint)
+ proxyHint = QAbstractItemModel::VerticalSortHint;
+ q->layoutChanged(proxyParents, proxyHint);
+}
+
+void QTransposeProxyModelPrivate::onLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint)
+{
+ Q_Q(QTransposeProxyModel);
+ const QModelIndexList proxyPersistentIndexes = q->persistentIndexList();
+ layoutChangeProxyIndexes.clear();
+ layoutChangePersistentIndexes.clear();
+ layoutChangeProxyIndexes.reserve(proxyPersistentIndexes.size());
+ layoutChangePersistentIndexes.reserve(proxyPersistentIndexes.size());
+ for (const QPersistentModelIndex &proxyPersistentIndex : proxyPersistentIndexes) {
+ layoutChangeProxyIndexes << proxyPersistentIndex;
+ Q_ASSERT(proxyPersistentIndex.isValid());
+ const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
+ Q_ASSERT(srcPersistentIndex.isValid());
+ layoutChangePersistentIndexes << srcPersistentIndex;
+ }
+ QList<QPersistentModelIndex> proxyParents;
+ proxyParents.reserve(parents.size());
+ for (auto& srcParent : parents)
+ proxyParents << q->mapFromSource(srcParent);
+ QAbstractItemModel::LayoutChangeHint proxyHint = QAbstractItemModel::NoLayoutChangeHint;
+ if (hint == QAbstractItemModel::VerticalSortHint)
+ proxyHint = QAbstractItemModel::HorizontalSortHint;
+ else if (hint == QAbstractItemModel::HorizontalSortHint)
+ proxyHint = QAbstractItemModel::VerticalSortHint;
+ q->layoutAboutToBeChanged(proxyParents, proxyHint);
+}
+
+void QTransposeProxyModelPrivate::onDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles)
+{
+ Q_Q(QTransposeProxyModel);
+ q->dataChanged(q->mapFromSource(topLeft), q->mapFromSource(bottomRight), roles);
+}
+
+void QTransposeProxyModelPrivate::onHeaderDataChanged(Qt::Orientation orientation, int first, int last)
+{
+ Q_Q(QTransposeProxyModel);
+ q->headerDataChanged(orientation == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal, first, last);
+}
+
+void QTransposeProxyModelPrivate::onColumnsAboutToBeInserted(const QModelIndex &parent, int first, int last)
+{
+ Q_Q(QTransposeProxyModel);
+ q->beginInsertRows(q->mapFromSource(parent), first, last);
+}
+
+void QTransposeProxyModelPrivate::onColumnsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
+{
+ Q_Q(QTransposeProxyModel);
+ q->beginRemoveRows(q->mapFromSource(parent), first, last);
+}
+
+void QTransposeProxyModelPrivate::onColumnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
+{
+ Q_Q(QTransposeProxyModel);
+ q->beginMoveRows(q->mapFromSource(sourceParent), sourceStart, sourceEnd, q->mapFromSource(destinationParent), destinationColumn);
+}
+
+void QTransposeProxyModelPrivate::onRowsAboutToBeInserted(const QModelIndex &parent, int first, int last)
+{
+ Q_Q(QTransposeProxyModel);
+ q->beginInsertColumns(q->mapFromSource(parent), first, last);
+}
+
+void QTransposeProxyModelPrivate::onRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
+{
+ Q_Q(QTransposeProxyModel);
+ q->beginRemoveColumns(q->mapFromSource(parent), first, last);
+}
+
+void QTransposeProxyModelPrivate::onRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
+{
+ Q_Q(QTransposeProxyModel);
+ q->beginMoveColumns(q->mapFromSource(sourceParent), sourceStart, sourceEnd, q->mapFromSource(destinationParent), destinationRow);
+}
+
+/*!
+ \since 5.13
+ \class QTransposeProxyModel
+ \brief This proxy transposes the source model
+ \details This model will make the rows of the source model become columns of the proxy model and vice-versa.
+
+ If the model is a tree, the parents will be transposed as well. For example, if an index in the source model had parent `index(2,0)`, it will have parent `index(0,2)` in the proxy.
+*/
+
+/*!
+ Constructs a new proxy model with the given \a parent.
+*/
+QTransposeProxyModel::QTransposeProxyModel(QObject* parent)
+ : QAbstractProxyModel(*new QTransposeProxyModelPrivate, parent)
+{}
+
+/*!
+ Destructs the proxy model.
+*/
+QTransposeProxyModel::~QTransposeProxyModel() = default;
+
+/*!
+ \internal
+*/
+QTransposeProxyModel::QTransposeProxyModel(QTransposeProxyModelPrivate &dd, QObject *parent)
+ : QAbstractProxyModel(dd, parent)
+{}
+
+/*!
+ \reimp
+*/
+void QTransposeProxyModel::setSourceModel(QAbstractItemModel* newSourceModel)
+{
+ Q_D(QTransposeProxyModel);
+ if (newSourceModel == d->model)
+ return;
+ beginResetModel();
+ if (d->model) {
+ for (const QMetaObject::Connection& discIter : qAsConst(d->sourceConnections))
+ disconnect(discIter);
+ }
+ d->sourceConnections.clear();
+ QAbstractProxyModel::setSourceModel(newSourceModel);
+ if (d->model) {
+ using namespace std::placeholders;
+ d->sourceConnections = QVector<QMetaObject::Connection>{
+ connect(d->model, &QAbstractItemModel::modelAboutToBeReset, this, &QTransposeProxyModel::beginResetModel),
+ connect(d->model, &QAbstractItemModel::modelReset, this, &QTransposeProxyModel::endResetModel),
+ connect(d->model, &QAbstractItemModel::dataChanged, this, std::bind(&QTransposeProxyModelPrivate::onDataChanged, d, _1, _2, _3)),
+ connect(d->model, &QAbstractItemModel::headerDataChanged, this, std::bind(&QTransposeProxyModelPrivate::onHeaderDataChanged, d, _1, _2, _3)),
+ connect(d->model, &QAbstractItemModel::columnsAboutToBeInserted, this, std::bind(&QTransposeProxyModelPrivate::onColumnsAboutToBeInserted, d, _1, _2, _3)),
+ connect(d->model, &QAbstractItemModel::columnsAboutToBeMoved, this, std::bind(&QTransposeProxyModelPrivate::onColumnsAboutToBeMoved, d, _1, _2, _3, _4, _5)),
+ connect(d->model, &QAbstractItemModel::columnsAboutToBeRemoved, this, std::bind(&QTransposeProxyModelPrivate::onColumnsAboutToBeRemoved, d, _1, _2, _3)),
+ connect(d->model, &QAbstractItemModel::columnsInserted, this, &QTransposeProxyModel::endInsertRows),
+ connect(d->model, &QAbstractItemModel::columnsRemoved, this, &QTransposeProxyModel::endRemoveRows),
+ connect(d->model, &QAbstractItemModel::columnsMoved, this, &QTransposeProxyModel::endMoveRows),
+ connect(d->model, &QAbstractItemModel::rowsAboutToBeInserted, this, std::bind(&QTransposeProxyModelPrivate::onRowsAboutToBeInserted, d, _1, _2, _3)),
+ connect(d->model, &QAbstractItemModel::rowsAboutToBeMoved, this, std::bind(&QTransposeProxyModelPrivate::onRowsAboutToBeMoved, d, _1, _2, _3, _4, _5)),
+ connect(d->model, &QAbstractItemModel::rowsAboutToBeRemoved, this, std::bind(&QTransposeProxyModelPrivate::onRowsAboutToBeRemoved, d, _1, _2, _3)),
+ connect(d->model, &QAbstractItemModel::rowsInserted, this, &QTransposeProxyModel::endInsertColumns),
+ connect(d->model, &QAbstractItemModel::rowsRemoved, this, &QTransposeProxyModel::endRemoveColumns),
+ connect(d->model, &QAbstractItemModel::rowsMoved, this, &QTransposeProxyModel::endMoveColumns),
+ connect(d->model, &QAbstractItemModel::layoutAboutToBeChanged, this, std::bind(&QTransposeProxyModelPrivate::onLayoutAboutToBeChanged, d, _1, _2)),
+ connect(d->model, &QAbstractItemModel::layoutChanged, this, std::bind(&QTransposeProxyModelPrivate::onLayoutChanged, d, _1, _2))
+ };
+ }
+ endResetModel();
+}
+
+/*!
+ \reimp
+*/
+int QTransposeProxyModel::rowCount(const QModelIndex &parent) const
+{
+ Q_D(const QTransposeProxyModel);
+ if (!d->model)
+ return 0;
+ Q_ASSERT(checkIndex(parent));
+ return d->model->columnCount(mapToSource(parent));
+}
+
+/*!
+ \reimp
+*/
+int QTransposeProxyModel::columnCount(const QModelIndex &parent) const
+{
+ Q_D(const QTransposeProxyModel);
+ if (!d->model)
+ return 0;
+ Q_ASSERT(checkIndex(parent));
+ return d->model->rowCount(mapToSource(parent));
+}
+
+/*!
+ \reimp
+*/
+QVariant QTransposeProxyModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ Q_D(const QTransposeProxyModel);
+ if (!d->model)
+ return QVariant();
+ return d->model->headerData(section, orientation == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal, role);
+}
+
+/*!
+ \reimp
+*/
+bool QTransposeProxyModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role)
+{
+ Q_D(QTransposeProxyModel);
+ if (!d->model)
+ return false;
+ return d->model->setHeaderData(section, orientation == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal, value, role);
+}
+
+/*!
+ \reimp
+*/
+bool QTransposeProxyModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles)
+{
+ Q_D(QTransposeProxyModel);
+ Q_ASSERT(checkIndex(index));
+ if (!d->model || !index.isValid())
+ return false;
+ return d->model->setItemData(mapToSource(index), roles);
+}
+
+/*!
+ \reimp
+*/
+QSize QTransposeProxyModel::span(const QModelIndex &index) const
+{
+ Q_D(const QTransposeProxyModel);
+ Q_ASSERT(checkIndex(index));
+ if (!d->model || !index.isValid())
+ return QSize();
+ return d->model->span(mapToSource(index)).transposed();
+}
+
+/*!
+ \reimp
+*/
+QMap<int, QVariant> QTransposeProxyModel::itemData(const QModelIndex &index) const
+{
+ Q_D(const QTransposeProxyModel);
+ if (!d->model)
+ return QMap<int, QVariant>();
+ Q_ASSERT(checkIndex(index));
+ return d->model->itemData(mapToSource(index));
+}
+
+/*!
+ \reimp
+*/
+QModelIndex QTransposeProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
+{
+ Q_D(const QTransposeProxyModel);
+ if (!d->model || !sourceIndex.isValid())
+ return QModelIndex();
+ Q_ASSERT(d->model->checkIndex(sourceIndex));
+ return d->uncheckedMapFromSource(sourceIndex);
+}
+
+/*!
+ \reimp
+*/
+QModelIndex QTransposeProxyModel::mapToSource(const QModelIndex &proxyIndex) const
+{
+ Q_D(const QTransposeProxyModel);
+ Q_ASSERT(checkIndex(proxyIndex));
+ if (!d->model || !proxyIndex.isValid())
+ return QModelIndex();
+ return d->uncheckedMapToSource(proxyIndex);
+}
+
+/*!
+ \reimp
+*/
+QModelIndex QTransposeProxyModel::parent(const QModelIndex &index) const
+{
+ Q_D(const QTransposeProxyModel);
+ Q_ASSERT(checkIndex(index, CheckIndexOption::DoNotUseParent));
+ if (!d->model || !index.isValid())
+ return QModelIndex();
+ return d->uncheckedMapFromSource(d->uncheckedMapToSource(index).parent());
+}
+
+/*!
+ \reimp
+*/
+QModelIndex QTransposeProxyModel::index(int row, int column, const QModelIndex &parent) const
+{
+ Q_D(const QTransposeProxyModel);
+ Q_ASSERT(checkIndex(parent));
+ if (!d->model)
+ return QModelIndex();
+ return mapFromSource(d->model->index(column, row, mapToSource(parent)));
+}
+
+/*!
+ \reimp
+*/
+bool QTransposeProxyModel::insertRows(int row, int count, const QModelIndex &parent)
+{
+ Q_D(QTransposeProxyModel);
+ Q_ASSERT(checkIndex(parent));
+ if (!d->model)
+ return false;
+ return d->model->insertColumns(row, count, mapToSource(parent));
+}
+
+/*!
+ \reimp
+*/
+bool QTransposeProxyModel::removeRows(int row, int count, const QModelIndex &parent)
+{
+ Q_D(QTransposeProxyModel);
+ Q_ASSERT(checkIndex(parent));
+ if (!d->model)
+ return false;
+ return d->model->removeColumns(row, count, mapToSource(parent));
+}
+
+/*!
+ \reimp
+*/
+bool QTransposeProxyModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
+{
+ Q_D(QTransposeProxyModel);
+ Q_ASSERT(checkIndex(sourceParent));
+ Q_ASSERT(checkIndex(destinationParent));
+ if (!d->model)
+ return false;
+ return d->model->moveColumns(mapToSource(sourceParent), sourceRow, count, mapToSource(destinationParent), destinationChild);
+}
+
+/*!
+ \reimp
+*/
+bool QTransposeProxyModel::insertColumns(int column, int count, const QModelIndex &parent)
+{
+ Q_D(QTransposeProxyModel);
+ Q_ASSERT(checkIndex(parent));
+ if (!d->model)
+ return false;
+ return d->model->insertRows(column, count, mapToSource(parent));
+}
+
+/*!
+ \reimp
+*/
+bool QTransposeProxyModel::removeColumns(int column, int count, const QModelIndex &parent)
+{
+ Q_D(QTransposeProxyModel);
+ Q_ASSERT(checkIndex(parent));
+ if (!d->model)
+ return false;
+ return d->model->removeRows(column, count, mapToSource(parent));
+}
+
+/*!
+ \reimp
+*/
+bool QTransposeProxyModel::moveColumns(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
+{
+ Q_D(QTransposeProxyModel);
+ Q_ASSERT(checkIndex(sourceParent));
+ Q_ASSERT(checkIndex(destinationParent));
+ if (!d->model)
+ return false;
+ return d->model->moveRows(mapToSource(sourceParent), sourceRow, count, mapToSource(destinationParent), destinationChild);
+}
+
+/*!
+ \reimp
+ This method will perform no action. Use a QSortFilterProxyModel on top of this one if you require sorting.
+*/
+void QTransposeProxyModel::sort(int column, Qt::SortOrder order)
+{
+ Q_UNUSED(column)
+ Q_UNUSED(order)
+ return;
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/itemmodels/qtransposeproxymodel.h b/src/corelib/itemmodels/qtransposeproxymodel.h
new file mode 100644
index 0000000000..879266d931
--- /dev/null
+++ b/src/corelib/itemmodels/qtransposeproxymodel.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Luca Beldi <v.ronin@yahoo.it>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTRANSPOSEPROXYMODEL_H
+#define QTRANSPOSEPROXYMODEL_H
+
+#include <QtCore/qabstractproxymodel.h>
+#include <QtCore/qscopedpointer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QTransposeProxyModelPrivate;
+
+class Q_CORE_EXPORT QTransposeProxyModel : public QAbstractProxyModel
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(QTransposeProxyModel)
+ Q_DECLARE_PRIVATE(QTransposeProxyModel)
+public:
+ explicit QTransposeProxyModel(QObject* parent = nullptr);
+ ~QTransposeProxyModel();
+ void setSourceModel(QAbstractItemModel* newSourceModel) override;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
+ bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
+ bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) override;
+ QSize span(const QModelIndex &index) const override;
+ QMap<int, QVariant> itemData(const QModelIndex &index) const override;
+ QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
+ QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
+ QModelIndex parent(const QModelIndex &index) const override;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
+ bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
+ bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
+ bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
+ bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
+ bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
+ bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) override;
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
+protected:
+ QTransposeProxyModel(QTransposeProxyModelPrivate &, QObject *parent);
+};
+
+QT_END_NAMESPACE
+
+#endif // QTRANSPOSEPROXYMODEL_H
diff --git a/src/corelib/itemmodels/qtransposeproxymodel_p.h b/src/corelib/itemmodels/qtransposeproxymodel_p.h
new file mode 100644
index 0000000000..240fc4ccae
--- /dev/null
+++ b/src/corelib/itemmodels/qtransposeproxymodel_p.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Luca Beldi <v.ronin@yahoo.it>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTRANSPOSEPROXYMODEL_P_H
+#define QTRANSPOSEPROXYMODEL_P_H
+
+#include "qtransposeproxymodel.h"
+#include <private/qabstractproxymodel_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QTransposeProxyModelPrivate : public QAbstractProxyModelPrivate
+{
+ Q_DECLARE_PUBLIC(QTransposeProxyModel)
+ Q_DISABLE_COPY(QTransposeProxyModelPrivate)
+private:
+ QTransposeProxyModelPrivate() = default;
+ QVector<QMetaObject::Connection> sourceConnections;
+ QVector<QPersistentModelIndex> layoutChangePersistentIndexes;
+ QModelIndexList layoutChangeProxyIndexes;
+ QModelIndex uncheckedMapToSource(const QModelIndex &proxyIndex) const;
+ QModelIndex uncheckedMapFromSource(const QModelIndex &sourceIndex) const;
+ void onLayoutChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint);
+ void onLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint);
+ void onDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles);
+ void onHeaderDataChanged(Qt::Orientation orientation, int first, int last);
+ void onColumnsAboutToBeInserted(const QModelIndex &parent, int first, int last);
+ void onColumnsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
+ void onColumnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn);
+ void onRowsAboutToBeInserted(const QModelIndex &parent, int first, int last);
+ void onRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
+ void onRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow);
+};
+
+QT_END_NAMESPACE
+
+#endif //QTRANSPOSEPROXYMODEL_P_H
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 3c8b0f947c..e100ec8186 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1265,7 +1265,11 @@ bool QCoreApplication::closingDown()
\l{QCoreApplication::sendPostedEvents()}{sendPostedEvents()} from
within that local loop.
- Calling this function processes events only for the calling thread.
+ Calling this function processes events only for the calling thread,
+ and returns after all available events have been processed. Available
+ events are events queued before the function call. This means that
+ events that are posted while the function runs will be queued until
+ a later round of event processing.
\threadsafe
@@ -1282,7 +1286,7 @@ void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags)
/*!
\overload processEvents()
- Processes pending events for the calling thread for \a maxtime
+ Processes pending events for the calling thread for \a ms
milliseconds or until there are no more events to process,
whichever is shorter.
@@ -1291,11 +1295,14 @@ void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags)
Calling this function processes events only for the calling thread.
+ \note Unlike the \l{QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags)}{processEvents()}
+ overload, this function also processes events that are posted while the function runs.
+
\threadsafe
\sa exec(), QTimer, QEventLoop::processEvents()
*/
-void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags, int maxtime)
+void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags, int ms)
{
// ### Qt 6: consider splitting this method into a public and a private
// one, so that a user-invoked processEvents can be detected
@@ -1306,7 +1313,7 @@ void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags, int m
QElapsedTimer start;
start.start();
while (data->eventDispatcher.load()->processEvents(flags & ~QEventLoop::WaitForMoreEvents)) {
- if (start.elapsed() > maxtime)
+ if (start.elapsed() > ms)
break;
}
}
diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp
index 45c6e29e4b..34c2dde6a8 100644
--- a/src/corelib/kernel/qeventdispatcher_glib.cpp
+++ b/src/corelib/kernel/qeventdispatcher_glib.cpp
@@ -86,9 +86,10 @@ static gboolean socketNotifierSourceCheck(GSource *source)
p->pollfd.fd, t[int(p->socketNotifier->type())]);
// ### note, modifies src->pollfds!
p->socketNotifier->setEnabled(false);
+ i--;
+ } else {
+ pending = pending || ((p->pollfd.revents & p->pollfd.events) != 0);
}
-
- pending = ((p->pollfd.revents & p->pollfd.events) != 0);
}
return pending;
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index eb67544f21..1ba5f3979c 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -290,6 +290,10 @@ struct DefinedTypesFilter {
\value QJsonObject QJsonObject
\value QJsonArray QJsonArray
\value QJsonDocument QJsonDocument
+ \value QCborValue QCborValue
+ \value QCborArray QCborArray
+ \value QCborMap QCborMap
+ \value QCborSimpleType QCborSimpleType
\value QModelIndex QModelIndex
\value QPersistentModelIndex QPersistentModelIndex (since 5.5)
\value QUuid QUuid
@@ -373,6 +377,13 @@ struct DefinedTypesFilter {
*/
/*!
+ \fn int QMetaType::id() const
+ \since 5.13
+
+ Returns id type hold by this QMetatype instance.
+*/
+
+/*!
\fn bool QMetaType::sizeOf() const
\since 5.0
@@ -1374,236 +1385,197 @@ int QMetaType::type(const QT_PREPEND_NAMESPACE(QByteArray) &typeName)
}
#ifndef QT_NO_DATASTREAM
-/*!
- Writes the object pointed to by \a data with the ID \a type to
- the given \a stream. Returns \c true if the object is saved
- successfully; otherwise returns \c false.
- The type must have been registered with qRegisterMetaType() and
- qRegisterMetaTypeStreamOperators() beforehand.
+namespace
+{
- Normally, you should not need to call this function directly.
- Instead, use QVariant's \c operator<<(), which relies on save()
- to stream custom types.
+template<typename T>
+class HasStreamOperator
+{
+ struct Yes { char unused[1]; };
+ struct No { char unused[2]; };
+ Q_STATIC_ASSERT(sizeof(Yes) != sizeof(No));
+
+ template<class C> static decltype(std::declval<QDataStream&>().operator>>(std::declval<C&>()), Yes()) load(int);
+ template<class C> static decltype(operator>>(std::declval<QDataStream&>(), std::declval<C&>()), Yes()) load(int);
+ template<class C> static No load(...);
+ template<class C> static decltype(operator<<(std::declval<QDataStream&>(), std::declval<const C&>()), Yes()) saveFunction(int);
+ template<class C> static decltype(std::declval<QDataStream&>().operator<<(std::declval<const C&>()), Yes()) saveMethod(int);
+ template<class C> static No saveMethod(...);
+ template<class C> static No saveFunction(...);
+ static constexpr bool LoadValue = QtMetaTypePrivate::TypeDefinition<T>::IsAvailable && (sizeof(load<T>(0)) == sizeof(Yes));
+ static constexpr bool SaveValue = QtMetaTypePrivate::TypeDefinition<T>::IsAvailable &&
+ ((sizeof(saveMethod<T>(0)) == sizeof(Yes)) || (sizeof(saveFunction<T>(0)) == sizeof(Yes)));
+public:
+ static constexpr bool Value = LoadValue && SaveValue;
+};
- \sa load(), qRegisterMetaTypeStreamOperators()
-*/
-bool QMetaType::save(QDataStream &stream, int type, const void *data)
+// Quick sanity checks
+Q_STATIC_ASSERT(HasStreamOperator<NS(QJsonDocument)>::Value);
+Q_STATIC_ASSERT(!HasStreamOperator<void*>::Value);
+Q_STATIC_ASSERT(HasStreamOperator<qint8>::Value);
+
+template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted && HasStreamOperator<T>::Value>
+struct FilteredOperatorSwitch
+{
+ static bool load(QDataStream &stream, T *data, int)
+ {
+ stream >> *data;
+ return true;
+ }
+ static bool save(QDataStream &stream, const T *data, int)
+ {
+ stream << *data;
+ return true;
+ }
+};
+template<typename T>
+struct FilteredOperatorSwitch<T, /* IsAcceptedType = */ false>
{
- if (!data || !isRegistered(type))
+ static const QMetaTypeInterface* getMetaTypeInterface(int type)
+ {
+ if (QModulesPrivate::QTypeModuleInfo<T>::IsGui && qMetaTypeGuiHelper)
+ return &qMetaTypeGuiHelper[type - QMetaType::FirstGuiType];
+ else if (QModulesPrivate::QTypeModuleInfo<T>::IsWidget && qMetaTypeWidgetsHelper)
+ return &qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType];
+ return nullptr;
+ }
+ static bool save(QDataStream &stream, const T *data, int type)
+ {
+ if (auto interface = getMetaTypeInterface(type)) {
+ interface->saveOp(stream, data);
+ return true;
+ }
return false;
-
- switch(type) {
- case QMetaType::UnknownType:
- case QMetaType::Void:
- case QMetaType::VoidStar:
- case QMetaType::QObjectStar:
-#if QT_CONFIG(itemmodel)
- case QMetaType::QModelIndex:
- case QMetaType::QPersistentModelIndex:
-#endif
- case QMetaType::QJsonValue:
- case QMetaType::QJsonObject:
- case QMetaType::QJsonArray:
- case QMetaType::QJsonDocument:
- case QMetaType::QCborValue:
- case QMetaType::QCborArray:
- case QMetaType::QCborMap:
+ }
+ static bool load(QDataStream &stream, T *data, int type)
+ {
+ if (auto interface = getMetaTypeInterface(type)) {
+ interface->loadOp(stream, data);
+ return true;
+ }
return false;
- case QMetaType::Nullptr:
- stream << *static_cast<const std::nullptr_t *>(data);
- return true;
- case QMetaType::Long:
- stream << qlonglong(*static_cast<const long *>(data));
- break;
- case QMetaType::Int:
- stream << *static_cast<const int *>(data);
- break;
- case QMetaType::Short:
- stream << *static_cast<const short *>(data);
- break;
- case QMetaType::Char:
+ }
+};
+
+class SaveOperatorSwitch
+{
+public:
+ QDataStream &stream;
+ int m_type;
+
+ template<typename T>
+ bool delegate(const T *data)
+ {
+ return FilteredOperatorSwitch<T>::save(stream, data, m_type);
+ }
+ bool delegate(const char *data)
+ {
// force a char to be signed
- stream << *static_cast<const signed char *>(data);
- break;
- case QMetaType::ULong:
- stream << qulonglong(*static_cast<const ulong *>(data));
- break;
- case QMetaType::UInt:
- stream << *static_cast<const uint *>(data);
- break;
- case QMetaType::LongLong:
- stream << *static_cast<const qlonglong *>(data);
- break;
- case QMetaType::ULongLong:
- stream << *static_cast<const qulonglong *>(data);
- break;
- case QMetaType::UShort:
- stream << *static_cast<const ushort *>(data);
- break;
- case QMetaType::SChar:
- stream << *static_cast<const signed char *>(data);
- break;
- case QMetaType::UChar:
- stream << *static_cast<const uchar *>(data);
- break;
- case QMetaType::Bool:
- stream << qint8(*static_cast<const bool *>(data));
- break;
- case QMetaType::Float:
- stream << *static_cast<const float *>(data);
- break;
- case QMetaType::Double:
- stream << *static_cast<const double *>(data);
- break;
- case QMetaType::QChar:
- stream << *static_cast<const NS(QChar) *>(data);
- break;
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QVariantMap:
- stream << *static_cast<const NS(QVariantMap)*>(data);
- break;
- case QMetaType::QVariantHash:
- stream << *static_cast<const NS(QVariantHash)*>(data);
- break;
- case QMetaType::QVariantList:
- stream << *static_cast<const NS(QVariantList)*>(data);
- break;
- case QMetaType::QVariant:
- stream << *static_cast<const NS(QVariant)*>(data);
- break;
- case QMetaType::QByteArrayList:
- stream << *static_cast<const NS(QByteArrayList)*>(data);
- break;
-#endif
- case QMetaType::QByteArray:
- stream << *static_cast<const NS(QByteArray)*>(data);
- break;
- case QMetaType::QString:
- stream << *static_cast<const NS(QString)*>(data);
- break;
- case QMetaType::QStringList:
- stream << *static_cast<const NS(QStringList)*>(data);
- break;
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QBitArray:
- stream << *static_cast<const NS(QBitArray)*>(data);
- break;
-#endif
- case QMetaType::QDate:
- stream << *static_cast<const NS(QDate)*>(data);
- break;
- case QMetaType::QTime:
- stream << *static_cast<const NS(QTime)*>(data);
- break;
- case QMetaType::QDateTime:
- stream << *static_cast<const NS(QDateTime)*>(data);
- break;
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QUrl:
- stream << *static_cast<const NS(QUrl)*>(data);
- break;
-#endif
- case QMetaType::QLocale:
- stream << *static_cast<const NS(QLocale)*>(data);
- break;
-#ifndef QT_NO_GEOM_VARIANT
- case QMetaType::QRect:
- stream << *static_cast<const NS(QRect)*>(data);
- break;
- case QMetaType::QRectF:
- stream << *static_cast<const NS(QRectF)*>(data);
- break;
- case QMetaType::QSize:
- stream << *static_cast<const NS(QSize)*>(data);
- break;
- case QMetaType::QSizeF:
- stream << *static_cast<const NS(QSizeF)*>(data);
- break;
- case QMetaType::QLine:
- stream << *static_cast<const NS(QLine)*>(data);
- break;
- case QMetaType::QLineF:
- stream << *static_cast<const NS(QLineF)*>(data);
- break;
- case QMetaType::QPoint:
- stream << *static_cast<const NS(QPoint)*>(data);
- break;
- case QMetaType::QPointF:
- stream << *static_cast<const NS(QPointF)*>(data);
- break;
-#endif
-#ifndef QT_NO_REGEXP
- case QMetaType::QRegExp:
- stream << *static_cast<const NS(QRegExp)*>(data);
- break;
-#endif
-#if QT_CONFIG(regularexpression)
- case QMetaType::QRegularExpression:
- stream << *static_cast<const NS(QRegularExpression)*>(data);
- break;
-#endif // QT_CONFIG(regularexpression)
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QEasingCurve:
- stream << *static_cast<const NS(QEasingCurve)*>(data);
- break;
- case QMetaType::QCborSimpleType:
- stream << *static_cast<const quint8 *>(data);
- break;
-#endif // QT_BOOTSTRAPPED
- case QMetaType::QFont:
- case QMetaType::QPixmap:
- case QMetaType::QBrush:
- case QMetaType::QColor:
- case QMetaType::QPalette:
- case QMetaType::QImage:
- case QMetaType::QPolygon:
- case QMetaType::QPolygonF:
- case QMetaType::QRegion:
- case QMetaType::QBitmap:
- case QMetaType::QCursor:
- case QMetaType::QKeySequence:
- case QMetaType::QPen:
- case QMetaType::QTextLength:
- case QMetaType::QTextFormat:
- case QMetaType::QMatrix:
- case QMetaType::QTransform:
- case QMetaType::QMatrix4x4:
- case QMetaType::QVector2D:
- case QMetaType::QVector3D:
- case QMetaType::QVector4D:
- case QMetaType::QQuaternion:
- case QMetaType::QIcon:
- if (!qMetaTypeGuiHelper)
- return false;
- qMetaTypeGuiHelper[type - FirstGuiType].saveOp(stream, data);
- break;
- case QMetaType::QSizePolicy:
- if (!qMetaTypeWidgetsHelper)
- return false;
- qMetaTypeWidgetsHelper[type - FirstWidgetsType].saveOp(stream, data);
- break;
- case QMetaType::QUuid:
- stream << *static_cast<const NS(QUuid)*>(data);
- break;
- default: {
+ stream << qint8(*data);
+ return true;
+ }
+ bool delegate(const long *data)
+ {
+ stream << qlonglong(*data);
+ return true;
+ }
+ bool delegate(const unsigned long *data)
+ {
+ stream << qulonglong(*data);
+ return true;
+ }
+ bool delegate(const QMetaTypeSwitcher::NotBuiltinType *data)
+ {
const QVector<QCustomTypeInfo> * const ct = customTypes();
if (!ct)
return false;
-
- SaveOperator saveOp = 0;
+ QMetaType::SaveOperator saveOp = nullptr;
{
QReadLocker locker(customTypesLock());
- saveOp = ct->at(type - User).saveOp;
+ saveOp = ct->at(m_type - QMetaType::User).saveOp;
}
-
if (!saveOp)
return false;
saveOp(stream, data);
- break; }
+ return true;
}
+ bool delegate(const void*) { return false; }
+ bool delegate(const QMetaTypeSwitcher::UnknownType*) { return false; }
+};
+class LoadOperatorSwitch
+{
+public:
+ QDataStream &stream;
+ int m_type;
- return true;
+ template<typename T>
+ bool delegate(const T *data)
+ {
+ return FilteredOperatorSwitch<T>::load(stream, const_cast<T*>(data), m_type);
+ }
+ bool delegate(const char *data)
+ {
+ // force a char to be signed
+ qint8 c;
+ stream >> c;
+ *const_cast<char*>(data) = c;
+ return true;
+ }
+ bool delegate(const long *data)
+ {
+ qlonglong l;
+ stream >> l;
+ *const_cast<long*>(data) = l;
+ return true;
+ }
+ bool delegate(const unsigned long *data)
+ {
+ qlonglong l;
+ stream >> l;
+ *const_cast<unsigned long*>(data) = l;
+ return true;
+ }
+ bool delegate(const QMetaTypeSwitcher::NotBuiltinType *data)
+ {
+ const QVector<QCustomTypeInfo> * const ct = customTypes();
+ if (!ct)
+ return false;
+ QMetaType::LoadOperator loadOp = nullptr;
+ {
+ QReadLocker locker(customTypesLock());
+ loadOp = ct->at(m_type - QMetaType::User).loadOp;
+ }
+ if (!loadOp)
+ return false;
+ loadOp(stream, const_cast<QMetaTypeSwitcher::NotBuiltinType*>(data));
+ return true;
+ }
+ bool delegate(const void*) { return false; }
+ bool delegate(const QMetaTypeSwitcher::UnknownType*) { return false; }
+};
+} // namespace
+
+/*!
+ Writes the object pointed to by \a data with the ID \a type to
+ the given \a stream. Returns \c true if the object is saved
+ successfully; otherwise returns \c false.
+
+ The type must have been registered with qRegisterMetaType() and
+ qRegisterMetaTypeStreamOperators() beforehand.
+
+ Normally, you should not need to call this function directly.
+ Instead, use QVariant's \c operator<<(), which relies on save()
+ to stream custom types.
+
+ \sa load(), qRegisterMetaTypeStreamOperators()
+*/
+bool QMetaType::save(QDataStream &stream, int type, const void *data)
+{
+ if (!data)
+ return false;
+ SaveOperatorSwitch saveOp{stream, type};
+ return QMetaTypeSwitcher::switcher<bool>(saveOp, type, data);
}
/*!
@@ -1622,225 +1594,10 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
*/
bool QMetaType::load(QDataStream &stream, int type, void *data)
{
- if (!data || !isRegistered(type))
- return false;
-
- switch(type) {
- case QMetaType::UnknownType:
- case QMetaType::Void:
- case QMetaType::VoidStar:
- case QMetaType::QObjectStar:
-#if QT_CONFIG(itemmodel)
- case QMetaType::QModelIndex:
- case QMetaType::QPersistentModelIndex:
-#endif
- case QMetaType::QJsonValue:
- case QMetaType::QJsonObject:
- case QMetaType::QJsonArray:
- case QMetaType::QJsonDocument:
- case QMetaType::QCborValue:
- case QMetaType::QCborArray:
- case QMetaType::QCborMap:
+ if (!data)
return false;
- case QMetaType::Nullptr:
- stream >> *static_cast<std::nullptr_t *>(data);
- return true;
- case QMetaType::Long: {
- qlonglong l;
- stream >> l;
- *static_cast<long *>(data) = long(l);
- break; }
- case QMetaType::Int:
- stream >> *static_cast<int *>(data);
- break;
- case QMetaType::Short:
- stream >> *static_cast<short *>(data);
- break;
- case QMetaType::Char:
- // force a char to be signed
- stream >> *static_cast<signed char *>(data);
- break;
- case QMetaType::ULong: {
- qulonglong ul;
- stream >> ul;
- *static_cast<ulong *>(data) = ulong(ul);
- break; }
- case QMetaType::UInt:
- stream >> *static_cast<uint *>(data);
- break;
- case QMetaType::LongLong:
- stream >> *static_cast<qlonglong *>(data);
- break;
- case QMetaType::ULongLong:
- stream >> *static_cast<qulonglong *>(data);
- break;
- case QMetaType::UShort:
- stream >> *static_cast<ushort *>(data);
- break;
- case QMetaType::SChar:
- stream >> *static_cast<signed char *>(data);
- break;
- case QMetaType::UChar:
- stream >> *static_cast<uchar *>(data);
- break;
- case QMetaType::Bool: {
- qint8 b;
- stream >> b;
- *static_cast<bool *>(data) = b;
- break; }
- case QMetaType::Float:
- stream >> *static_cast<float *>(data);
- break;
- case QMetaType::Double:
- stream >> *static_cast<double *>(data);
- break;
- case QMetaType::QChar:
- stream >> *static_cast< NS(QChar)*>(data);
- break;
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QVariantMap:
- stream >> *static_cast< NS(QVariantMap)*>(data);
- break;
- case QMetaType::QVariantHash:
- stream >> *static_cast< NS(QVariantHash)*>(data);
- break;
- case QMetaType::QVariantList:
- stream >> *static_cast< NS(QVariantList)*>(data);
- break;
- case QMetaType::QVariant:
- stream >> *static_cast< NS(QVariant)*>(data);
- break;
- case QMetaType::QByteArrayList:
- stream >> *static_cast< NS(QByteArrayList)*>(data);
- break;
-#endif
- case QMetaType::QByteArray:
- stream >> *static_cast< NS(QByteArray)*>(data);
- break;
- case QMetaType::QString:
- stream >> *static_cast< NS(QString)*>(data);
- break;
- case QMetaType::QStringList:
- stream >> *static_cast< NS(QStringList)*>(data);
- break;
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QBitArray:
- stream >> *static_cast< NS(QBitArray)*>(data);
- break;
-#endif
- case QMetaType::QDate:
- stream >> *static_cast< NS(QDate)*>(data);
- break;
- case QMetaType::QTime:
- stream >> *static_cast< NS(QTime)*>(data);
- break;
- case QMetaType::QDateTime:
- stream >> *static_cast< NS(QDateTime)*>(data);
- break;
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QUrl:
- stream >> *static_cast< NS(QUrl)*>(data);
- break;
-#endif
- case QMetaType::QLocale:
- stream >> *static_cast< NS(QLocale)*>(data);
- break;
-#ifndef QT_NO_GEOM_VARIANT
- case QMetaType::QRect:
- stream >> *static_cast< NS(QRect)*>(data);
- break;
- case QMetaType::QRectF:
- stream >> *static_cast< NS(QRectF)*>(data);
- break;
- case QMetaType::QSize:
- stream >> *static_cast< NS(QSize)*>(data);
- break;
- case QMetaType::QSizeF:
- stream >> *static_cast< NS(QSizeF)*>(data);
- break;
- case QMetaType::QLine:
- stream >> *static_cast< NS(QLine)*>(data);
- break;
- case QMetaType::QLineF:
- stream >> *static_cast< NS(QLineF)*>(data);
- break;
- case QMetaType::QPoint:
- stream >> *static_cast< NS(QPoint)*>(data);
- break;
- case QMetaType::QPointF:
- stream >> *static_cast< NS(QPointF)*>(data);
- break;
-#endif
-#ifndef QT_NO_REGEXP
- case QMetaType::QRegExp:
- stream >> *static_cast< NS(QRegExp)*>(data);
- break;
-#endif
-#if QT_CONFIG(regularexpression)
- case QMetaType::QRegularExpression:
- stream >> *static_cast< NS(QRegularExpression)*>(data);
- break;
-#endif // QT_CONFIG(regularexpression)
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QEasingCurve:
- stream >> *static_cast< NS(QEasingCurve)*>(data);
- break;
- case QMetaType::QCborSimpleType:
- stream >> *static_cast<quint8 *>(data);
- break;
-#endif // QT_BOOTSTRAPPED
- case QMetaType::QFont:
- case QMetaType::QPixmap:
- case QMetaType::QBrush:
- case QMetaType::QColor:
- case QMetaType::QPalette:
- case QMetaType::QImage:
- case QMetaType::QPolygon:
- case QMetaType::QPolygonF:
- case QMetaType::QRegion:
- case QMetaType::QBitmap:
- case QMetaType::QCursor:
- case QMetaType::QKeySequence:
- case QMetaType::QPen:
- case QMetaType::QTextLength:
- case QMetaType::QTextFormat:
- case QMetaType::QMatrix:
- case QMetaType::QTransform:
- case QMetaType::QMatrix4x4:
- case QMetaType::QVector2D:
- case QMetaType::QVector3D:
- case QMetaType::QVector4D:
- case QMetaType::QQuaternion:
- case QMetaType::QIcon:
- if (!qMetaTypeGuiHelper)
- return false;
- qMetaTypeGuiHelper[type - FirstGuiType].loadOp(stream, data);
- break;
- case QMetaType::QSizePolicy:
- if (!qMetaTypeWidgetsHelper)
- return false;
- qMetaTypeWidgetsHelper[type - FirstWidgetsType].loadOp(stream, data);
- break;
- case QMetaType::QUuid:
- stream >> *static_cast< NS(QUuid)*>(data);
- break;
- default: {
- const QVector<QCustomTypeInfo> * const ct = customTypes();
- if (!ct)
- return false;
-
- LoadOperator loadOp = 0;
- {
- QReadLocker locker(customTypesLock());
- loadOp = ct->at(type - User).loadOp;
- }
-
- if (!loadOp)
- return false;
- loadOp(stream, data);
- break; }
- }
- return true;
+ LoadOperatorSwitch loadOp{stream, type};
+ return QMetaTypeSwitcher::switcher<bool>(loadOp, type, data);
}
#endif // QT_NO_DATASTREAM
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index ed7feee775..a47fbfe28d 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -570,6 +570,7 @@ public:
inline bool isValid() const;
inline bool isRegistered() const;
+ inline int id() const;
inline int sizeOf() const;
inline TypeFlags flags() const;
inline const QMetaObject *metaObject() const;
@@ -1976,7 +1977,9 @@ QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_FORWARD_DECLARE_STATIC_TYPES_ITER)
typedef QList<QVariant> QVariantList;
typedef QMap<QString, QVariant> QVariantMap;
typedef QHash<QString, QVariant> QVariantHash;
-#ifndef Q_CLANG_QDOC
+#ifdef Q_CLANG_QDOC
+class QByteArrayList;
+#else
typedef QList<QByteArray> QByteArrayList;
#endif
@@ -2221,6 +2224,11 @@ inline bool QMetaType::isRegistered() const
return isValid();
}
+inline int QMetaType::id() const
+{
+ return m_typeId;
+}
+
inline void *QMetaType::create(const void *copy) const
{
// ### TODO Qt6 remove the extension
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 14af9ac8ef..d2a3d957e9 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -2144,7 +2144,8 @@ void QObject::removeEventFilter(QObject *obj)
\fn void QObject::destroyed(QObject *obj)
This signal is emitted immediately before the object \a obj is
- destroyed, and can not be blocked.
+ destroyed, after any instances of QPointer have been notified,
+ and can not be blocked.
All the objects's children are destroyed immediately after this
signal is emitted.
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 6aea40cf4a..c4e1c69883 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -432,9 +432,9 @@ struct Q_CORE_EXPORT QAbstractDynamicMetaObject : public QDynamicMetaObjectData,
{
~QAbstractDynamicMetaObject();
- virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) override { return this; }
+ QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) override { return this; }
virtual int createProperty(const char *, const char *) { return -1; }
- virtual int metaCall(QObject *, QMetaObject::Call c, int _id, void **a) override
+ int metaCall(QObject *, QMetaObject::Call c, int _id, void **a) override
{ return metaCall(c, _id, a); }
virtual int metaCall(QMetaObject::Call, int _id, void **) { return _id; } // Compat overload
};
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index 53c3136857..9d0394e4a5 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -152,10 +152,7 @@ QString QSystemError::string(ErrorScope errorScope, int errorCode)
case NativeError:
#if defined (Q_OS_WIN)
return windowsErrorString(errorCode);
-#else
- //unix: fall through as native and standard library are the same
- Q_FALLTHROUGH();
-#endif
+#endif // else unix: native and standard library are the same
case StandardLibraryError:
return standardLibraryErrorString(errorCode);
default:
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index 90f29aa630..2059aae3eb 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -585,29 +585,16 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
*/
/*!
- \fn template<typename Functor> QMetaObject::Connection callOnTimeout(QObject *context, Functor functor, Qt::ConnectionType connectionType = Qt::AutoConnection)
+ \fn template<typename Functor> QMetaObject::Connection callOnTimeout(QObject *context, Functor function, Qt::ConnectionType connectionType = Qt::AutoConnection)
\since 5.12
\overload callOnTimeout()
- Creates a connection from the timeout() signal to \a functor to be placed in a specific
- event loop of \a context, and returns a handle to the connection.
+ Creates a connection from the timeout() signal to \a function, which could be a pointer
+ to a member function of \a context, or it could be a functor to be placed in a specific
+ event loop of \a context. It returns a handle to the connection.
This method is provided for convenience. It's equivalent to calling
- \c {QObject::connect(timer, &QTimer::timeout, context, functor, connectionType)}.
-
- \sa QObject::connect(), timeout()
-*/
-
-/*!
- \fn template<typename PointerToMemberFunction> QMetaObject::Connection callOnTimeout(QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType connectionType = Qt::AutoConnection)
- \since 5.12
- \overload callOnTimeout()
-
- Creates a connection from the timeout() signal to the \a method in the \a receiver object. Returns
- a handle to the connection.
-
- This method is provided for convenience. It's equivalent to calling
- \c {QObject::connect(timer, &QTimer::timeout, receiver, method, connectionType)}.
+ \c {QObject::connect(timer, &QTimer::timeout, context, function, connectionType)}.
\sa QObject::connect(), timeout()
*/
diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h
index 66f317c567..9ff340854f 100644
--- a/src/corelib/kernel/qtimer.h
+++ b/src/corelib/kernel/qtimer.h
@@ -100,8 +100,6 @@ public:
QMetaObject::Connection callOnTimeout(Functor slot, Qt::ConnectionType connectionType = Qt::AutoConnection);
template <typename Functor>
QMetaObject::Connection callOnTimeout(const QObject *context, Functor slot, Qt::ConnectionType connectionType = Qt::AutoConnection);
- template <typename PointerToMemberFunction>
- QMetaObject::Connection callOnTimeout(const QObject *receiver, PointerToMemberFunction slot, Qt::ConnectionType connectionType = Qt::AutoConnection);
#else
// singleShot to a QObject slot
template <typename Duration, typename Func1>
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index ff73c27b6e..f95502e75f 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -55,6 +55,8 @@
#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L
#include <variant>
+#elif defined(Q_CLANG_QDOC)
+namespace std { template<typename...> struct variant; }
#endif
QT_BEGIN_NAMESPACE
@@ -365,7 +367,7 @@ class Q_CORE_EXPORT QVariant
static inline QVariant fromValue(const T &value)
{ return qVariantFromValue(value); }
-#if defined(Q_CLANG_QDOC) || (QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L)
+#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L
template<typename... Types>
static inline QVariant fromStdVariant(const std::variant<Types...> &value)
{
diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp
index bfe9be559a..50b30a1832 100644
--- a/src/corelib/mimetypes/qmimedatabase.cpp
+++ b/src/corelib/mimetypes/qmimedatabase.cpp
@@ -74,7 +74,6 @@ QMimeDatabasePrivate::QMimeDatabasePrivate()
QMimeDatabasePrivate::~QMimeDatabasePrivate()
{
- qDeleteAll(m_providers);
}
#ifdef QT_BUILD_INTERNAL
@@ -107,52 +106,52 @@ void QMimeDatabasePrivate::loadProviders()
mimeDirs.prepend(QLatin1String(":/qt-project.org/qmime"));
//qDebug() << "mime dirs:" << mimeDirs;
- QVector<QMimeProviderBase *> currentProviders = m_providers;
- m_providers.clear();
+ Providers currentProviders;
+ std::swap(m_providers, currentProviders);
m_providers.reserve(mimeDirs.size());
for (const QString &mimeDir : qAsConst(mimeDirs)) {
const QString cacheFile = mimeDir + QStringLiteral("/mime.cache");
QFileInfo fileInfo(cacheFile);
// Check if we already have a provider for this dir
- const auto it = std::find_if(currentProviders.begin(), currentProviders.end(), [mimeDir](QMimeProviderBase *prov) { return prov->directory() == mimeDir; });
+ const auto predicate = [mimeDir](const std::unique_ptr<QMimeProviderBase> &prov)
+ {
+ return prov && prov->directory() == mimeDir;
+ };
+ const auto it = std::find_if(currentProviders.begin(), currentProviders.end(), predicate);
if (it == currentProviders.end()) {
- QMimeProviderBase *provider = nullptr;
+ std::unique_ptr<QMimeProviderBase> provider;
#if defined(QT_USE_MMAP)
if (qEnvironmentVariableIsEmpty("QT_NO_MIME_CACHE") && fileInfo.exists()) {
- provider = new QMimeBinaryProvider(this, mimeDir);
+ provider.reset(new QMimeBinaryProvider(this, mimeDir));
//qDebug() << "Created binary provider for" << mimeDir;
if (!provider->isValid()) {
- delete provider;
- provider = nullptr;
+ provider.reset();
}
}
#endif
if (!provider) {
- provider = new QMimeXMLProvider(this, mimeDir);
+ provider.reset(new QMimeXMLProvider(this, mimeDir));
//qDebug() << "Created XML provider for" << mimeDir;
}
- m_providers.append(provider);
+ m_providers.push_back(std::move(provider));
} else {
- QMimeProviderBase *provider = *it;
- currentProviders.erase(it);
+ auto provider = std::move(*it); // take provider out of the vector
provider->ensureLoaded();
if (!provider->isValid()) {
- delete provider;
- provider = new QMimeXMLProvider(this, mimeDir);
+ provider.reset(new QMimeXMLProvider(this, mimeDir));
//qDebug() << "Created XML provider to replace binary provider for" << mimeDir;
}
- m_providers.append(provider);
+ m_providers.push_back(std::move(provider));
}
}
- qDeleteAll(currentProviders);
}
-QVector<QMimeProviderBase *> QMimeDatabasePrivate::providers()
+const QMimeDatabasePrivate::Providers &QMimeDatabasePrivate::providers()
{
#ifndef Q_OS_WASM // stub implementation always returns true
Q_ASSERT(!mutex.tryLock()); // caller should have locked mutex
#endif
- if (m_providers.isEmpty()) {
+ if (m_providers.empty()) {
loadProviders();
m_lastCheck.start();
} else {
@@ -164,8 +163,7 @@ QVector<QMimeProviderBase *> QMimeDatabasePrivate::providers()
QString QMimeDatabasePrivate::resolveAlias(const QString &nameOrAlias)
{
- const auto allProviders = providers();
- for (QMimeProviderBase *provider : allProviders) {
+ for (const auto &provider : providers()) {
const QString ret = provider->resolveAlias(nameOrAlias);
if (!ret.isEmpty())
return ret;
@@ -179,9 +177,8 @@ QString QMimeDatabasePrivate::resolveAlias(const QString &nameOrAlias)
*/
QMimeType QMimeDatabasePrivate::mimeTypeForName(const QString &nameOrAlias)
{
- const auto allProviders = providers();
const QString mimeName = resolveAlias(nameOrAlias);
- for (QMimeProviderBase *provider : allProviders) {
+ for (const auto &provider : providers()) {
const QMimeType mime = provider->mimeTypeForName(mimeName);
if (mime.isValid())
return mime;
@@ -205,8 +202,7 @@ QMimeGlobMatchResult QMimeDatabasePrivate::findByFileName(const QString &fileNam
{
QMimeGlobMatchResult result;
// TODO this parses in the order (local, global). Check that it handles "NOGLOBS" correctly.
- const auto allProviders = providers();
- for (QMimeProviderBase *provider : allProviders)
+ for (const auto &provider : providers())
provider->addFileNameMatches(fileName, result);
return result;
}
@@ -227,8 +223,7 @@ void QMimeDatabasePrivate::loadGenericIcon(QMimeTypePrivate &mimePrivate)
QMutexLocker locker(&mutex);
if (mimePrivate.fromCache) {
mimePrivate.genericIconName.clear();
- const auto allProviders = providers();
- for (QMimeProviderBase *provider : allProviders) {
+ for (const auto &provider : providers()) {
provider->loadGenericIcon(mimePrivate);
if (!mimePrivate.genericIconName.isEmpty())
break;
@@ -241,8 +236,7 @@ void QMimeDatabasePrivate::loadIcon(QMimeTypePrivate &mimePrivate)
QMutexLocker locker(&mutex);
if (mimePrivate.fromCache) {
mimePrivate.iconName.clear();
- const auto allProviders = providers();
- for (QMimeProviderBase *provider : allProviders) {
+ for (const auto &provider : providers()) {
provider->loadIcon(mimePrivate);
if (!mimePrivate.iconName.isEmpty())
break;
@@ -276,8 +270,7 @@ QStringList QMimeDatabasePrivate::parents(const QString &mimeName)
{
Q_ASSERT(!mutex.tryLock());
QStringList result;
- const auto allProviders = providers();
- for (QMimeProviderBase *provider : allProviders)
+ for (const auto &provider : providers())
provider->addParents(mimeName, result);
if (result.isEmpty()) {
const QString parent = fallbackParent(mimeName);
@@ -291,8 +284,7 @@ QStringList QMimeDatabasePrivate::listAliases(const QString &mimeName)
{
QMutexLocker locker(&mutex);
QStringList result;
- const auto allProviders = providers();
- for (QMimeProviderBase *provider : allProviders)
+ for (const auto &provider : providers())
provider->addAliases(mimeName, result);
return result;
}
@@ -331,8 +323,7 @@ QMimeType QMimeDatabasePrivate::findByData(const QByteArray &data, int *accuracy
*accuracyPtr = 0;
QMimeType candidate;
- const auto allProviders = providers();
- for (QMimeProviderBase *provider : allProviders)
+ for (const auto &provider : providers())
provider->findByMagic(data, accuracyPtr, candidate);
if (candidate.isValid())
@@ -414,8 +405,7 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
QList<QMimeType> QMimeDatabasePrivate::allMimeTypes()
{
QList<QMimeType> result;
- const auto allProviders = providers();
- for (QMimeProviderBase *provider : allProviders)
+ for (const auto &provider : providers())
provider->addAllMimeTypes(result);
return result;
}
diff --git a/src/corelib/mimetypes/qmimedatabase_p.h b/src/corelib/mimetypes/qmimedatabase_p.h
index 1e605d9a24..7bc1d41c4d 100644
--- a/src/corelib/mimetypes/qmimedatabase_p.h
+++ b/src/corelib/mimetypes/qmimedatabase_p.h
@@ -63,6 +63,8 @@ QT_REQUIRE_CONFIG(mimetype);
#include <QtCore/qmutex.h>
#include <QtCore/qvector.h>
+#include <memory>
+
QT_BEGIN_NAMESPACE
class QIODevice;
@@ -102,11 +104,12 @@ public:
bool mimeInherits(const QString &mime, const QString &parent);
private:
- QVector<QMimeProviderBase *> providers();
+ using Providers = std::vector<std::unique_ptr<QMimeProviderBase>>;
+ const Providers &providers();
bool shouldCheck();
void loadProviders();
- mutable QVector<QMimeProviderBase *> m_providers;
+ mutable Providers m_providers;
QElapsedTimer m_lastCheck;
public:
diff --git a/src/corelib/mimetypes/qmimeprovider_p.h b/src/corelib/mimetypes/qmimeprovider_p.h
index 875ff9e0eb..b6268210c0 100644
--- a/src/corelib/mimetypes/qmimeprovider_p.h
+++ b/src/corelib/mimetypes/qmimeprovider_p.h
@@ -97,17 +97,17 @@ public:
QMimeBinaryProvider(QMimeDatabasePrivate *db, const QString &directory);
virtual ~QMimeBinaryProvider();
- virtual bool isValid() override;
- virtual QMimeType mimeTypeForName(const QString &name) override;
+ bool isValid() override;
+ QMimeType mimeTypeForName(const QString &name) override;
void addFileNameMatches(const QString &fileName, QMimeGlobMatchResult &result) override;
void addParents(const QString &mime, QStringList &result) override;
- virtual QString resolveAlias(const QString &name) override;
+ QString resolveAlias(const QString &name) override;
void addAliases(const QString &name, QStringList &result) override;
void findByMagic(const QByteArray &data, int *accuracyPtr, QMimeType &candidate) override;
void addAllMimeTypes(QList<QMimeType> &result) override;
static void loadMimeTypePrivate(QMimeTypePrivate &);
- virtual void loadIcon(QMimeTypePrivate &) override;
- virtual void loadGenericIcon(QMimeTypePrivate &) override;
+ void loadIcon(QMimeTypePrivate &) override;
+ void loadGenericIcon(QMimeTypePrivate &) override;
void ensureLoaded() override;
private:
@@ -135,11 +135,11 @@ public:
QMimeXMLProvider(QMimeDatabasePrivate *db, const QString &directory);
~QMimeXMLProvider();
- virtual bool isValid() override;
- virtual QMimeType mimeTypeForName(const QString &name) override;
+ bool isValid() override;
+ QMimeType mimeTypeForName(const QString &name) override;
void addFileNameMatches(const QString &fileName, QMimeGlobMatchResult &result) override;
void addParents(const QString &mime, QStringList &result) override;
- virtual QString resolveAlias(const QString &name) override;
+ QString resolveAlias(const QString &name) override;
void addAliases(const QString &name, QStringList &result) override;
void findByMagic(const QByteArray &data, int *accuracyPtr, QMimeType &candidate) override;
void addAllMimeTypes(QList<QMimeType> &result) override;
diff --git a/src/corelib/plugin/qfactoryinterface.h b/src/corelib/plugin/qfactoryinterface.h
index f306460690..3aec4ddd55 100644
--- a/src/corelib/plugin/qfactoryinterface.h
+++ b/src/corelib/plugin/qfactoryinterface.h
@@ -52,8 +52,9 @@ struct Q_CORE_EXPORT QFactoryInterface
virtual QStringList keys() const = 0;
};
-
+#ifndef Q_CLANG_QDOC
Q_DECLARE_INTERFACE(QFactoryInterface, "org.qt-project.Qt.QFactoryInterface")
+#endif
QT_END_NAMESPACE
diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h
index 5aca22497a..676b5047d6 100644
--- a/src/corelib/plugin/qplugin.h
+++ b/src/corelib/plugin/qplugin.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -71,13 +72,27 @@ inline constexpr unsigned char qPluginArchRequirements()
}
typedef QObject *(*QtPluginInstanceFunction)();
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
typedef const char *(*QtPluginMetaDataFunction)();
+#else
+typedef QPair<const uchar *, size_t> (*QtPluginMetaDataFunction)();
+#endif
+
struct Q_CORE_EXPORT QStaticPlugin
{
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+public:
+ constexpr QStaticPlugin(QtPluginInstanceFunction i, QtPluginMetaDataFunction m)
+ : instance(i), rawMetaData(m().first), rawMetaDataSize(m().second)
+ QtPluginInstanceFunction instance;
+private:
+ // ### Qt 6: revise, as this is not standard-layout
+ const void *rawMetaData;
+ qsizetype rawMetaDataSize
+#elif !defined(Q_QDOC)
// Note: This struct is initialized using an initializer list.
// As such, it cannot have any new constructors or variables.
-#ifndef Q_QDOC
QtPluginInstanceFunction instance;
QtPluginMetaDataFunction rawMetaData;
#else
@@ -148,6 +163,15 @@ void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin);
return plugin; \
}
+#elif QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+
+# define QT_MOC_EXPORT_PLUGIN(PLUGINCLASS, PLUGINCLASSNAME) \
+ Q_EXTERN_C Q_DECL_EXPORT \
+ auto qt_plugin_query_metadata() \
+ { return qMakePair<const void *, size_t>(qt_pluginMetaData, sizeof qt_pluginMetaData); } \
+ Q_EXTERN_C Q_DECL_EXPORT QT_PREPEND_NAMESPACE(QObject) *qt_plugin_instance() \
+ Q_PLUGIN_INSTANCE(PLUGINCLASS)
+
#else
# define QT_MOC_EXPORT_PLUGIN(PLUGINCLASS, PLUGINCLASSNAME) \
diff --git a/src/corelib/serialization/qcborarray.cpp b/src/corelib/serialization/qcborarray.cpp
index c56536cdb1..28ae40f3df 100644
--- a/src/corelib/serialization/qcborarray.cpp
+++ b/src/corelib/serialization/qcborarray.cpp
@@ -39,6 +39,7 @@
#include "qcborarray.h"
#include "qcborvalue_p.h"
+#include "qdatastream.h"
QT_BEGIN_NAMESPACE
@@ -1218,4 +1219,23 @@ QDebug operator<<(QDebug dbg, const QCborArray &a)
}
#endif
+#ifndef QT_NO_DATASTREAM
+QDataStream &operator<<(QDataStream &stream, const QCborArray &value)
+{
+ stream << value.toCborValue().toCbor();
+ return stream;
+}
+
+QDataStream &operator>>(QDataStream &stream, QCborArray &value)
+{
+ QByteArray buffer;
+ stream >> buffer;
+ QCborParserError parseError{};
+ value = QCborValue::fromCbor(buffer, &parseError).toArray();
+ if (parseError.error)
+ stream.setStatus(QDataStream::ReadCorruptData);
+ return stream;
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/corelib/serialization/qcborarray.h b/src/corelib/serialization/qcborarray.h
index ed0f4912ba..e06544f245 100644
--- a/src/corelib/serialization/qcborarray.h
+++ b/src/corelib/serialization/qcborarray.h
@@ -47,6 +47,7 @@
QT_BEGIN_NAMESPACE
class QJsonArray;
+class QDataStream;
class QCborContainerPrivate;
class Q_CORE_EXPORT QCborArray
@@ -271,6 +272,7 @@ private:
void detach(qsizetype reserve = 0);
friend QCborValue;
+ friend QCborValueRef;
explicit QCborArray(QCborContainerPrivate &dd) noexcept;
QExplicitlySharedDataPointer<QCborContainerPrivate> d;
};
@@ -298,6 +300,11 @@ Q_CORE_EXPORT uint qHash(const QCborArray &array, uint seed = 0);
Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborArray &a);
#endif
+#ifndef QT_NO_DATASTREAM
+Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QCborArray &);
+Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QCborArray &);
+#endif
+
QT_END_NAMESPACE
#endif // QCBORARRAY_H
diff --git a/src/corelib/serialization/qcborcommon.h b/src/corelib/serialization/qcborcommon.h
index f8278f1649..3dfe50cd09 100644
--- a/src/corelib/serialization/qcborcommon.h
+++ b/src/corelib/serialization/qcborcommon.h
@@ -133,6 +133,11 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, QCborKnownTags tg);
Q_CORE_EXPORT QDebug operator<<(QDebug, QCborTag tg);
#endif
+#if !defined(QT_NO_DEBUG_STREAM)
+QDataStream &operator<<(QDataStream &ds, QCborSimpleType st);
+QDataStream &operator>>(QDataStream &ds, QCborSimpleType &st);
+#endif
+
inline uint qHash(QCborSimpleType tag, uint seed = 0)
{
return qHash(quint8(tag), seed);
diff --git a/src/corelib/serialization/qcbormap.cpp b/src/corelib/serialization/qcbormap.cpp
index 33f9249993..4b28ca4a2e 100644
--- a/src/corelib/serialization/qcbormap.cpp
+++ b/src/corelib/serialization/qcbormap.cpp
@@ -1763,4 +1763,23 @@ QDebug operator<<(QDebug dbg, const QCborMap &m)
}
#endif
+#ifndef QT_NO_DATASTREAM
+QDataStream &operator<<(QDataStream &stream, const QCborMap &value)
+{
+ stream << value.toCborValue().toCbor();
+ return stream;
+}
+
+QDataStream &operator>>(QDataStream &stream, QCborMap &value)
+{
+ QByteArray buffer;
+ stream >> buffer;
+ QCborParserError parseError{};
+ value = QCborValue::fromCbor(buffer, &parseError).toMap();
+ if (parseError.error)
+ stream.setStatus(QDataStream::ReadCorruptData);
+ return stream;
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/corelib/serialization/qcbormap.h b/src/corelib/serialization/qcbormap.h
index 3eb2107691..15a3bcdcef 100644
--- a/src/corelib/serialization/qcbormap.h
+++ b/src/corelib/serialization/qcbormap.h
@@ -52,6 +52,7 @@ typedef QMap<QString, QVariant> QVariantMap;
template <class Key, class T> class QHash;
typedef QHash<QString, QVariant> QVariantHash;
class QJsonObject;
+class QDataStream;
class QCborContainerPrivate;
class Q_CORE_EXPORT QCborMap
@@ -117,6 +118,8 @@ public:
QCborValueRef item; // points to the value
friend class Iterator;
friend class QCborMap;
+ friend class QCborValue;
+ friend class QCborValueRef;
ConstIterator(QCborContainerPrivate *dd, qsizetype ii) : item(dd, ii) {}
public:
typedef std::random_access_iterator_tag iterator_category;
@@ -322,9 +325,10 @@ public:
QJsonObject toJsonObject() const;
private:
+ friend class QCborValue;
+ friend class QCborValueRef;
void detach(qsizetype reserve = 0);
- friend QCborValue;
explicit QCborMap(QCborContainerPrivate &dd) noexcept;
QExplicitlySharedDataPointer<QCborContainerPrivate> d;
};
@@ -352,6 +356,12 @@ Q_CORE_EXPORT uint qHash(const QCborMap &map, uint seed = 0);
Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborMap &m);
#endif
+#ifndef QT_NO_DATASTREAM
+Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QCborMap &);
+Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QCborMap &);
+#endif
+
+
QT_END_NAMESPACE
#endif // QCBORMAP_H
diff --git a/src/corelib/serialization/qcborstream.cpp b/src/corelib/serialization/qcborstream.cpp
index fc5610e341..39f9e2e70a 100644
--- a/src/corelib/serialization/qcborstream.cpp
+++ b/src/corelib/serialization/qcborstream.cpp
@@ -44,6 +44,7 @@
#include <qbuffer.h>
#include <qdebug.h>
#include <qstack.h>
+#include <qdatastream.h>
QT_BEGIN_NAMESPACE
@@ -170,6 +171,21 @@ Q_CORE_EXPORT const char *qt_cbor_simpletype_id(QCborSimpleType st)
return nullptr;
}
+#if !defined(QT_NO_DATASTREAM)
+QDataStream &operator<<(QDataStream &ds, QCborSimpleType st)
+{
+ return ds << quint8(st);
+}
+
+QDataStream &operator>>(QDataStream &ds, QCborSimpleType &st)
+{
+ quint8 v;
+ ds >> v;
+ st = QCborSimpleType(v);
+ return ds;
+}
+#endif
+
#if !defined(QT_NO_DEBUG_STREAM)
QDebug operator<<(QDebug dbg, QCborSimpleType st)
{
diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp
index 5d97a6a06a..2e2bac3f65 100644
--- a/src/corelib/serialization/qcborvalue.cpp
+++ b/src/corelib/serialization/qcborvalue.cpp
@@ -39,7 +39,7 @@
#include "qcborvalue.h"
#include "qcborvalue_p.h"
-
+#include "qdatastream.h"
#include "qcborarray.h"
#include "qcbormap.h"
#include "qcborstream.h"
@@ -128,10 +128,11 @@ QT_BEGIN_NAMESPACE
Such values are completely valid and may appear in CBOR streams, unlike
JSON content and QJsonValue's undefined bit. But like QJsonValue's
- Undefined, it is returned by QCborArray::value() when out of range or
- QCborMap::operator[] when the key is not found in the container. It is not
- possible to tell such a case apart from the value of Undefined, so if that
- is required, check the QCborArray size and use the QCborMap iterator API.
+ Undefined, it is returned by a CBOR container's value() or read-only
+ operator[] for invalid look-ups (index out of range for QCborArray, or key
+ not found for QCborMap). It is not possible to tell such a case apart from
+ the value of Undefined, so if that is required, check the QCborArray size
+ and use the QCborMap iterator API.
\section1 Simple types
@@ -457,7 +458,7 @@ QT_BEGIN_NAMESPACE
\fn QCborValue::QCborValue(QCborValue &&other)
\overload
- Moves the contents of the \a other CBorValue object into this one and frees
+ Moves the contents of the \a other QCborValue object into this one and frees
the resources of this one.
*/
@@ -465,7 +466,7 @@ QT_BEGIN_NAMESPACE
\fn QCborValue &&QCborValue::operator=(QCborValue &&other)
\overload
- Moves the contents of the \a other CBorValue object into this one and frees
+ Moves the contents of the \a other QCborValue object into this one and frees
the resources of this one. Returns a reference to this object.
*/
@@ -1982,12 +1983,24 @@ QUuid QCborValue::toUuid(const QUuid &defaultValue) const
return QUuid::fromRfc4122(byteData->asByteArrayView());
}
-QCborArray QCborValue::toArray() const
-{
- return toArray(QCborArray());
-}
+/*!
+ \fn QCborArray QCborValue::toArray() const
+ \fn QCborArray QCborValue::toArray(const QCborArray &defaultValue) const
+
+ Returns the array value stored in this QCborValue, if it is of the array
+ type. Otherwise, it returns \a defaultValue.
+
+ Note that this function performs no conversion from other types to
+ QCborArray.
+
+ \sa isArray(), isByteArray(), isMap(), isContainer(), toMap()
+ */
/*!
+ \fn QCborArray QCborValueRef::toArray() const
+ \fn QCborArray QCborValueRef::toArray(const QCborArray &defaultValue) const
+ \internal
+
Returns the array value stored in this QCborValue, if it is of the array
type. Otherwise, it returns \a defaultValue.
@@ -1996,6 +2009,11 @@ QCborArray QCborValue::toArray() const
\sa isArray(), isByteArray(), isMap(), isContainer(), toMap()
*/
+QCborArray QCborValue::toArray() const
+{
+ return toArray(QCborArray());
+}
+
QCborArray QCborValue::toArray(const QCborArray &defaultValue) const
{
if (!isArray())
@@ -2007,12 +2025,24 @@ QCborArray QCborValue::toArray(const QCborArray &defaultValue) const
return dd ? QCborArray(*dd) : defaultValue;
}
-QCborMap QCborValue::toMap() const
-{
- return toMap(QCborMap());
-}
+/*!
+ \fn QCborMap QCborValue::toMap() const
+ \fn QCborMap QCborValue::toMap(const QCborMap &defaultValue) const
+
+ Returns the map value stored in this QCborValue, if it is of the map type.
+ Otherwise, it returns \a defaultValue.
+
+ Note that this function performs no conversion from other types to
+ QCborMap.
+
+ \sa isMap(), isArray(), isContainer(), toArray()
+ */
/*!
+ \fn QCborMap QCborValueRef::toMap() const
+ \fn QCborMap QCborValueRef::toMap(const QCborMap &defaultValue) const
+ \internal
+
Returns the map value stored in this QCborValue, if it is of the map type.
Otherwise, it returns \a defaultValue.
@@ -2021,6 +2051,11 @@ QCborMap QCborValue::toMap() const
\sa isMap(), isArray(), isContainer(), toArray()
*/
+QCborMap QCborValue::toMap() const
+{
+ return toMap(QCborMap());
+}
+
QCborMap QCborValue::toMap(const QCborMap &defaultValue) const
{
if (!isMap())
@@ -2073,15 +2108,16 @@ const QCborValue QCborValue::operator[](QLatin1String key) const
}
/*!
+ \overload
+
If this QCborValue is a QCborMap, searches elements for the value whose key
- matches \a key. If this is an array, returns the element whose index is \a
- key. If there's no matching value in the array or map, or if this
+ matches \a key. If this is a QCborArray, returns the element whose index is
+ \a key. If there's no matching value in the array or map, or if this
QCborValue object is not an array or map, returns the undefined value.
\sa operator[], QCborMap::operator[], QCborMap::value(),
QCborMap::find(), QCborArray::operator[], QCborArray::at()
*/
-
const QCborValue QCborValue::operator[](qint64 key) const
{
if (isMap())
@@ -2092,6 +2128,191 @@ const QCborValue QCborValue::operator[](qint64 key) const
}
/*!
+ \internal
+ */
+static Q_DECL_COLD_FUNCTION QCborMap arrayAsMap(const QCborArray &array)
+{
+ if (array.size())
+ qWarning("Using CBOR array as map forced conversion");
+ QCborMap map;
+ for (qsizetype i = array.size(); i-- > 0; ) {
+ QCborValue entry = array.at(i);
+ // Ignore padding entries that may have been added to grow the array
+ // when inserting past its end:
+ if (!entry.isInvalid())
+ map[i] = entry;
+ }
+ return map;
+}
+
+/*!
+ \internal
+ */
+static QCborContainerPrivate *maybeDetach(QCborContainerPrivate *container, qsizetype size)
+{
+ auto replace = QCborContainerPrivate::detach(container, size);
+ Q_ASSERT(replace);
+ if (replace != container) {
+ if (container)
+ container->deref();
+ replace->ref.ref();
+ }
+ return replace;
+}
+
+/*!
+ \internal
+ */
+static QCborContainerPrivate *maybeGrow(QCborContainerPrivate *container, qsizetype index)
+{
+ auto replace = QCborContainerPrivate::grow(container, index);
+ Q_ASSERT(replace);
+ if (replace != container) {
+ if (container)
+ container->deref();
+ replace->ref.ref();
+ }
+ if (replace->elements.size() == index)
+ replace->append(Undefined());
+ else
+ Q_ASSERT(replace->elements.size() > index);
+ return replace;
+}
+
+/*!
+ Returns a QCborValueRef that can be used to read or modify the entry in
+ this, as a map, with the given \a key. When this QCborValue is a QCborMap,
+ this function is equivalent to the matching operator[] on that map.
+
+ Before returning the reference: if this QCborValue was an array, it is first
+ converted to a map (so that \c{map[i]} is \c{array[i]} for each index, \c i,
+ with valid \c{array[i]}); otherwise, if it was not a map it will be
+ over-written with an empty map.
+
+ \sa operator[](qint64), QCborMap::operator[], QCborMap::value(),
+ QCborMap::find()
+ */
+QCborValueRef QCborValue::operator[](const QString &key)
+{
+ if (!isMap())
+ *this = QCborValue(isArray() ? arrayAsMap(toArray()) : QCborMap());
+
+ const qsizetype size = container ? container->elements.size() : 0;
+ qsizetype index = size + 1;
+ bool found = false;
+ if (container) {
+ QCborMap proxy(*container);
+ auto it = proxy.constFind(key);
+ if (it < proxy.constEnd()) {
+ found = true;
+ index = it.item.i;
+ }
+ }
+
+ container = maybeDetach(container, size + (found ? 0 : 2));
+ Q_ASSERT(container);
+ if (!found) {
+ container->append(key);
+ container->append(QCborValue());
+ }
+ Q_ASSERT(index & 1 && !(container->elements.size() & 1));
+ Q_ASSERT(index < container->elements.size());
+ return { container, index };
+}
+
+/*!
+ \overload
+
+ Returns a QCborValueRef that can be used to read or modify the entry in
+ this, as a map, with the given \a key. When this QCborValue is a QCborMap,
+ this function is equivalent to the matching operator[] on that map.
+
+ Before returning the reference: if this QCborValue was an array, it is first
+ converted to a map (so that \c{map[i]} is \c{array[i]} for each index, \c i,
+ with valid \c{array[i]}); otherwise, if it was not a map it will be
+ over-written with an empty map.
+
+ \sa operator[](qint64), QCborMap::operator[], QCborMap::value(),
+ QCborMap::find()
+ */
+QCborValueRef QCborValue::operator[](QLatin1String key)
+{
+ if (!isMap())
+ *this = QCborValue(isArray() ? arrayAsMap(toArray()) : QCborMap());
+
+ const qsizetype size = container ? container->elements.size() : 0;
+ qsizetype index = size + 1;
+ bool found = false;
+ if (container) {
+ QCborMap proxy(*container);
+ auto it = proxy.constFind(key);
+ if (it < proxy.constEnd()) {
+ found = true;
+ index = it.item.i;
+ }
+ }
+
+ container = maybeDetach(container, size + (found ? 0 : 2));
+ Q_ASSERT(container);
+ if (!found) {
+ container->append(key);
+ container->append(QCborValue());
+ }
+ Q_ASSERT(index & 1 && !(container->elements.size() & 1));
+ Q_ASSERT(index < container->elements.size());
+ return { container, index };
+}
+
+/*!
+ \overload
+
+ Returns a QCborValueRef that can be used to read or modify the entry in
+ this, as a map or array, with the given \a key. When this QCborValue is a
+ QCborMap or, for 0 <= key < 0x10000, a QCborArray, this function is
+ equivalent to the matching operator[] on that map or array.
+
+ Before returning the reference: if this QCborValue was an array but the key
+ is out of range, the array is first converted to a map (so that \c{map[i]}
+ is \c{array[i]} for each index, \c i, with valid \c{array[i]}); otherwise,
+ if it was not a map it will be over-written with an empty map.
+
+ \sa operator[], QCborMap::operator[], QCborMap::value(),
+ QCborMap::find(), QCborArray::operator[], QCborArray::at()
+ */
+QCborValueRef QCborValue::operator[](qint64 key)
+{
+ if (isArray() && key >= 0 && key < 0x10000) {
+ container = maybeGrow(container, key);
+ return { container, qsizetype(key) };
+ }
+ if (!isMap())
+ *this = QCborValue(isArray() ? arrayAsMap(toArray()) : QCborMap());
+
+ const qsizetype size = container ? container->elements.size() : 0;
+ Q_ASSERT(!(size & 1));
+ qsizetype index = size + 1;
+ bool found = false;
+ if (container) {
+ QCborMap proxy(*container);
+ auto it = proxy.constFind(key);
+ if (it < proxy.constEnd()) {
+ found = true;
+ index = it.item.i;
+ }
+ }
+
+ container = maybeDetach(container, size + (found ? 0 : 2));
+ Q_ASSERT(container);
+ if (!found) {
+ container->append(key);
+ container->append(QCborValue());
+ }
+ Q_ASSERT(index & 1 && !(container->elements.size() & 1));
+ Q_ASSERT(index < container->elements.size());
+ return { container, index };
+}
+
+/*!
Decodes one item from the CBOR stream found in \a reader and returns the
equivalent representation. This function is recursive: if the item is a map
or array, it will decode all items found in that map or array, until the
@@ -2355,6 +2576,255 @@ QCborValue::Type QCborValueRef::concreteType(QCborValueRef self) noexcept
return self.d->elements.at(self.i).type;
}
+/*!
+ If this QCborValueRef refers to a QCborMap, searches elements for the value
+ whose key matches \a key. If there's no key matching \a key in the map or if
+ this QCborValueRef object is not a map, returns the undefined value.
+
+ This function is equivalent to:
+
+ \code
+ value.toMap().value(key);
+ \endcode
+
+ \sa operator[](qint64), QCborMap::operator[], QCborMap::value(),
+ QCborMap::find()
+ */
+const QCborValue QCborValueRef::operator[](const QString &key) const
+{
+ const QCborValue item = d->valueAt(i);
+ return item[key];
+}
+
+/*!
+ \overload
+
+ If this QCborValueRef refers to a QCborMap, searches elements for the value
+ whose key matches \a key. If there's no key matching \a key in the map or if
+ this QCborValueRef object is not a map, returns the undefined value.
+
+ This function is equivalent to:
+
+ \code
+ value.toMap().value(key);
+ \endcode
+
+ \sa operator[](qint64), QCborMap::operator[], QCborMap::value(),
+ QCborMap::find()
+ */
+const QCborValue QCborValueRef::operator[](QLatin1String key) const
+{
+ const QCborValue item = d->valueAt(i);
+ return item[key];
+}
+
+/*!
+ \overload
+
+ If this QCborValueRef refers to a QCborMap, searches elements for the value
+ whose key matches \a key. If this is a QCborArray, returns the element whose
+ index is \a key. If there's no matching value in the array or map, or if
+ this QCborValueRef object is not an array or map, returns the undefined
+ value.
+
+ \sa operator[], QCborMap::operator[], QCborMap::value(),
+ QCborMap::find(), QCborArray::operator[], QCborArray::at()
+ */
+const QCborValue QCborValueRef::operator[](qint64 key) const
+{
+ const QCborValue item = d->valueAt(i);
+ return item[key];
+}
+
+/*!
+ Returns a QCborValueRef that can be used to read or modify the entry in
+ this, as a map, with the given \a key. When this QCborValueRef refers to a
+ QCborMap, this function is equivalent to the matching operator[] on that
+ map.
+
+ Before returning the reference: if the QCborValue referenced was an array,
+ it is first converted to a map (so that \c{map[i]} is \c{array[i]} for each
+ index, \c i, with valid \c{array[i]}); otherwise, if it was not a map it
+ will be over-written with an empty map.
+
+ \sa operator[](qint64), QCborMap::operator[], QCborMap::value(),
+ QCborMap::find()
+ */
+QCborValueRef QCborValueRef::operator[](const QString &key)
+{
+ auto &e = d->elements[i];
+ qsizetype size = 0;
+ if (e.flags & QtCbor::Element::IsContainer) {
+ if (e.container) {
+ if (e.type == QCborValue::Array) {
+ QCborValue repack = QCborValue(arrayAsMap(QCborArray(*e.container)));
+ qSwap(e.container, repack.container);
+ } else if (e.type != QCborValue::Map) {
+ e.container->deref();
+ e.container = nullptr;
+ }
+ }
+ e.type = QCborValue::Map;
+ if (e.container)
+ size = e.container->elements.size();
+ } else {
+ // Stomp any prior e.value, replace with a map (that we'll grow)
+ e.container = nullptr;
+ e.type = QCborValue::Map;
+ e.flags = QtCbor::Element::IsContainer;
+ }
+
+ qsizetype index = size + 1;
+ bool found = false;
+ if (e.container) {
+ QCborMap proxy(*e.container);
+ auto it = proxy.constFind(key);
+ if (it < proxy.constEnd()) {
+ found = true;
+ index = it.item.i;
+ }
+ }
+
+ e.container = maybeDetach(e.container, size + (found ? 0 : 2));
+ Q_ASSERT(e.container);
+ if (!found) {
+ e.container->append(key);
+ e.container->append(QCborValue());
+ }
+ Q_ASSERT(index & 1 && !(e.container->elements.size() & 1));
+ Q_ASSERT(index < e.container->elements.size());
+ return { e.container, index };
+}
+
+/*!
+ \overload
+
+ Returns a QCborValueRef that can be used to read or modify the entry in
+ this, as a map, with the given \a key. When this QCborValue is a QCborMap,
+ this function is equivalent to the matching operator[] on that map.
+
+ Before returning the reference: if the QCborValue referenced was an array,
+ it is first converted to a map (so that \c{map[i]} is \c{array[i]} for each
+ index, \c i, with valid \c{array[i]}); otherwise, if it was not a map it
+ will be over-written with an empty map.
+
+ \sa operator[](qint64), QCborMap::operator[], QCborMap::value(),
+ QCborMap::find()
+ */
+QCborValueRef QCborValueRef::operator[](QLatin1String key)
+{
+ auto &e = d->elements[i];
+ qsizetype size = 0;
+ if (e.flags & QtCbor::Element::IsContainer) {
+ if (e.container) {
+ if (e.type == QCborValue::Array) {
+ QCborValue repack = QCborValue(arrayAsMap(QCborArray(*e.container)));
+ qSwap(e.container, repack.container);
+ } else if (e.type != QCborValue::Map) {
+ e.container->deref();
+ e.container = nullptr;
+ }
+ }
+ e.type = QCborValue::Map;
+ if (e.container)
+ size = e.container->elements.size();
+ } else {
+ // Stomp any prior e.value, replace with a map (that we'll grow)
+ e.container = nullptr;
+ e.type = QCborValue::Map;
+ e.flags = QtCbor::Element::IsContainer;
+ }
+
+ qsizetype index = size + 1;
+ bool found = false;
+ if (e.container) {
+ QCborMap proxy(*e.container);
+ auto it = proxy.constFind(key);
+ if (it < proxy.constEnd()) {
+ found = true;
+ index = it.item.i;
+ }
+ }
+
+ e.container = maybeDetach(e.container, size + (found ? 0 : 2));
+ Q_ASSERT(e.container);
+ if (!found) {
+ e.container->append(key);
+ e.container->append(QCborValue());
+ }
+ Q_ASSERT(index & 1 && !(e.container->elements.size() & 1));
+ Q_ASSERT(index < e.container->elements.size());
+ return { e.container, index };
+}
+
+/*!
+ \overload
+
+ Returns a QCborValueRef that can be used to read or modify the entry in
+ this, as a map or array, with the given \a key. When this QCborValue is a
+ QCborMap or, for 0 <= key < 0x10000, a QCborArray, this function is
+ equivalent to the matching operator[] on that map or array.
+
+ Before returning the reference: if the QCborValue referenced was an array
+ but the key is out of range, the array is first converted to a map (so that
+ \c{map[i]} is \c{array[i]} for each index, \c i, with valid \c{array[i]});
+ otherwise, if it was not a map it will be over-written with an empty map.
+
+ \sa operator[], QCborMap::operator[], QCborMap::value(),
+ QCborMap::find(), QCborArray::operator[], QCborArray::at()
+ */
+QCborValueRef QCborValueRef::operator[](qint64 key)
+{
+ auto &e = d->elements[i];
+ if (e.type == QCborValue::Array && key >= 0 && key < 0x10000) {
+ e.container = maybeGrow(e.container, key);
+ return { e.container, qsizetype(key) };
+ }
+ qsizetype size = 0;
+ if (e.flags & QtCbor::Element::IsContainer) {
+ if (e.container) {
+ if (e.type == QCborValue::Array) {
+ QCborValue repack = QCborValue(arrayAsMap(QCborArray(*e.container)));
+ qSwap(e.container, repack.container);
+ } else if (e.type != QCborValue::Map) {
+ e.container->deref();
+ e.container = nullptr;
+ }
+ }
+ e.type = QCborValue::Map;
+ if (e.container)
+ size = e.container->elements.size();
+ } else {
+ // Stomp any prior e.value, replace with a map (that we'll grow)
+ e.container = nullptr;
+ e.type = QCborValue::Map;
+ e.flags = QtCbor::Element::IsContainer;
+ }
+ Q_ASSERT(!(size & 1));
+
+ qsizetype index = size + 1;
+ bool found = false;
+ if (e.container) {
+ QCborMap proxy(*e.container);
+ auto it = proxy.constFind(key);
+ if (it < proxy.constEnd()) {
+ found = true;
+ index = it.item.i;
+ }
+ }
+
+ e.container = maybeDetach(e.container, size + (found ? 0 : 2));
+ Q_ASSERT(e.container);
+ if (!found) {
+ e.container->append(key);
+ e.container->append(QCborValue());
+ }
+ Q_ASSERT(index & 1 && !(e.container->elements.size() & 1));
+ Q_ASSERT(index < e.container->elements.size());
+ return { e.container, index };
+}
+
+
inline QCborArray::QCborArray(QCborContainerPrivate &dd) noexcept
: d(&dd)
{
@@ -2469,6 +2939,26 @@ QDebug operator<<(QDebug dbg, const QCborValue &v)
}
#endif
+#ifndef QT_NO_DATASTREAM
+QDataStream &operator<<(QDataStream &stream, const QCborValue &value)
+{
+ stream << QCborValue(value).toCbor();
+ return stream;
+}
+
+QDataStream &operator>>(QDataStream &stream, QCborValue &value)
+{
+ QByteArray buffer;
+ stream >> buffer;
+ QCborParserError parseError{};
+ value = QCborValue::fromCbor(buffer, &parseError);
+ if (parseError.error)
+ stream.setStatus(QDataStream::ReadCorruptData);
+ return stream;
+}
+#endif
+
+
QT_END_NAMESPACE
#include "qcborarray.cpp"
diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h
index 105af1ba73..e6e73e1fb6 100644
--- a/src/corelib/serialization/qcborvalue.h
+++ b/src/corelib/serialization/qcborvalue.h
@@ -67,6 +67,7 @@ class QCborArray;
class QCborMap;
class QCborStreamReader;
class QCborStreamWriter;
+class QDataStream;
struct QCborParserError
{
@@ -76,6 +77,7 @@ struct QCborParserError
QString errorString() const { return error.toString(); }
};
+class QCborValueRef;
class QCborContainerPrivate;
class Q_CORE_EXPORT QCborValue
{
@@ -236,20 +238,18 @@ public:
QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const;
QUuid toUuid(const QUuid &defaultValue = {}) const;
-#ifdef Q_QDOC
- QCborArray toArray(const QCborArray &a = {}) const;
- QCborMap toMap(const QCborMap &m = {}) const;
-#else
// only forward-declared, need split functions
QCborArray toArray() const;
QCborArray toArray(const QCborArray &defaultValue) const;
QCborMap toMap() const;
QCborMap toMap(const QCborMap &defaultValue) const;
-#endif
const QCborValue operator[](const QString &key) const;
const QCborValue operator[](QLatin1String key) const;
const QCborValue operator[](qint64 key) const;
+ QCborValueRef operator[](qint64 key);
+ QCborValueRef operator[](QLatin1String key);
+ QCborValueRef operator[](const QString & key);
int compare(const QCborValue &other) const;
#if 0 && QT_HAS_INCLUDE(<compare>)
@@ -385,16 +385,18 @@ public:
QUuid toUuid(const QUuid &defaultValue = {}) const
{ return concrete().toUuid(defaultValue); }
-#ifdef Q_QDOC
- QCborArray toArray(const QCborArray &a = {}) const;
- QCborMap toMap(const QCborMap &m = {}) const;
-#else
// only forward-declared, need split functions. Implemented in qcbor{array,map}.h
QCborArray toArray() const;
QCborArray toArray(const QCborArray &a) const;
QCborMap toMap() const;
QCborMap toMap(const QCborMap &m) const;
-#endif
+
+ const QCborValue operator[](const QString &key) const;
+ const QCborValue operator[](QLatin1String key) const;
+ const QCborValue operator[](qint64 key) const;
+ QCborValueRef operator[](qint64 key);
+ QCborValueRef operator[](QLatin1String key);
+ QCborValueRef operator[](const QString & key);
int compare(const QCborValue &other) const
{ return concrete().compare(other); }
@@ -426,6 +428,7 @@ public:
{ return concrete().toDiagnosticNotation(opt); }
private:
+ friend class QCborValue;
friend class QCborArray;
friend class QCborMap;
friend class QCborContainerPrivate;
@@ -457,6 +460,11 @@ Q_CORE_EXPORT uint qHash(const QCborValue &value, uint seed = 0);
Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborValue &v);
#endif
+#ifndef QT_NO_DATASTREAM
+Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QCborValue &);
+Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QCborValue &);
+#endif
+
QT_END_NAMESPACE
#if defined(QT_X11_DEFINES_FOUND)
diff --git a/src/corelib/serialization/qdatastream.cpp b/src/corelib/serialization/qdatastream.cpp
index 951f6c9736..01808ebce6 100644
--- a/src/corelib/serialization/qdatastream.cpp
+++ b/src/corelib/serialization/qdatastream.cpp
@@ -559,6 +559,7 @@ void QDataStream::setByteOrder(ByteOrder bo)
\value Qt_5_10 Same as Qt_5_6
\value Qt_5_11 Same as Qt_5_6
\value Qt_5_12 Version 18 (Qt 5.12)
+ \value Qt_5_13 Version 19 (Qt 5.13)
\omitvalue Qt_DefaultCompiledVersion
\sa setVersion(), version()
diff --git a/src/corelib/serialization/qdatastream.h b/src/corelib/serialization/qdatastream.h
index eae0146553..2c874700e4 100644
--- a/src/corelib/serialization/qdatastream.h
+++ b/src/corelib/serialization/qdatastream.h
@@ -99,10 +99,11 @@ public:
Qt_5_10 = Qt_5_9,
Qt_5_11 = Qt_5_10,
Qt_5_12 = 18,
-#if QT_VERSION >= 0x050d00
+ Qt_5_13 = 19,
+#if QT_VERSION >= 0x050e00
#error Add the datastream version for this Qt version and update Qt_DefaultCompiledVersion
#endif
- Qt_DefaultCompiledVersion = Qt_5_12
+ Qt_DefaultCompiledVersion = Qt_5_13
};
enum ByteOrder {
diff --git a/src/corelib/serialization/qjsonarray.cpp b/src/corelib/serialization/qjsonarray.cpp
index 1187bb03a3..5ba83c41b9 100644
--- a/src/corelib/serialization/qjsonarray.cpp
+++ b/src/corelib/serialization/qjsonarray.cpp
@@ -1259,5 +1259,22 @@ QDebug operator<<(QDebug dbg, const QJsonArray &a)
}
#endif
+#ifndef QT_NO_DATASTREAM
+QDataStream &operator<<(QDataStream &stream, const QJsonArray &array)
+{
+ QJsonDocument doc{array};
+ stream << doc.toJson(QJsonDocument::Compact);
+ return stream;
+}
+
+QDataStream &operator>>(QDataStream &stream, QJsonArray &array)
+{
+ QJsonDocument doc;
+ stream >> doc;
+ array = doc.array();
+ return stream;
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/corelib/serialization/qjsonarray.h b/src/corelib/serialization/qjsonarray.h
index 5dff4a0aa9..0a17951fb7 100644
--- a/src/corelib/serialization/qjsonarray.h
+++ b/src/corelib/serialization/qjsonarray.h
@@ -271,6 +271,11 @@ Q_CORE_EXPORT uint qHash(const QJsonArray &array, uint seed = 0);
Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonArray &);
#endif
+#ifndef QT_NO_DATASTREAM
+Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QJsonArray &);
+Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QJsonArray &);
+#endif
+
QT_END_NAMESPACE
#endif // QJSONARRAY_H
diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp
index 0cd86d3ded..179a87c699 100644
--- a/src/corelib/serialization/qjsondocument.cpp
+++ b/src/corelib/serialization/qjsondocument.cpp
@@ -47,6 +47,7 @@
#include "qjsonwriter_p.h"
#include "qjsonparser_p.h"
#include "qjson_p.h"
+#include "qdatastream.h"
QT_BEGIN_NAMESPACE
@@ -657,4 +658,23 @@ QDebug operator<<(QDebug dbg, const QJsonDocument &o)
}
#endif
+#ifndef QT_NO_DATASTREAM
+QDataStream &operator<<(QDataStream &stream, const QJsonDocument &doc)
+{
+ stream << doc.toJson(QJsonDocument::Compact);
+ return stream;
+}
+
+QDataStream &operator>>(QDataStream &stream, QJsonDocument &doc)
+{
+ QByteArray buffer;
+ stream >> buffer;
+ QJsonParseError parseError{};
+ doc = QJsonDocument::fromJson(buffer, &parseError);
+ if (parseError.error && !buffer.isEmpty())
+ stream.setStatus(QDataStream::ReadCorruptData);
+ return stream;
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/corelib/serialization/qjsondocument.h b/src/corelib/serialization/qjsondocument.h
index b784890c54..a749439b7d 100644
--- a/src/corelib/serialization/qjsondocument.h
+++ b/src/corelib/serialization/qjsondocument.h
@@ -172,6 +172,11 @@ Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QJsonDocument)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonDocument &);
#endif
+#ifndef QT_NO_DATASTREAM
+Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QJsonDocument &);
+Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QJsonDocument &);
+#endif
+
QT_END_NAMESPACE
#endif // QJSONDOCUMENT_H
diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp
index 950bec535b..a9f25a119c 100644
--- a/src/corelib/serialization/qjsonobject.cpp
+++ b/src/corelib/serialization/qjsonobject.cpp
@@ -1320,4 +1320,21 @@ QDebug operator<<(QDebug dbg, const QJsonObject &o)
}
#endif
+#ifndef QT_NO_DATASTREAM
+QDataStream &operator<<(QDataStream &stream, const QJsonObject &object)
+{
+ QJsonDocument doc{object};
+ stream << doc.toJson(QJsonDocument::Compact);
+ return stream;
+}
+
+QDataStream &operator>>(QDataStream &stream, QJsonObject &object)
+{
+ QJsonDocument doc;
+ stream >> doc;
+ object = doc.object();
+ return stream;
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/corelib/serialization/qjsonobject.h b/src/corelib/serialization/qjsonobject.h
index be42d3747a..80fe6b2f3f 100644
--- a/src/corelib/serialization/qjsonobject.h
+++ b/src/corelib/serialization/qjsonobject.h
@@ -268,6 +268,11 @@ Q_CORE_EXPORT uint qHash(const QJsonObject &object, uint seed = 0);
Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonObject &);
#endif
+#ifndef QT_NO_DATASTREAM
+Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QJsonObject &);
+Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QJsonObject &);
+#endif
+
QT_END_NAMESPACE
#endif // QJSONOBJECT_H
diff --git a/src/corelib/serialization/qjsonvalue.cpp b/src/corelib/serialization/qjsonvalue.cpp
index 2c04da4885..1fc610d7c7 100644
--- a/src/corelib/serialization/qjsonvalue.cpp
+++ b/src/corelib/serialization/qjsonvalue.cpp
@@ -45,6 +45,7 @@
#include <qvariant.h>
#include <qstringlist.h>
#include <qdebug.h>
+#include "qdatastream.h"
#ifndef QT_BOOTSTRAPPED
# include <qcborarray.h>
@@ -933,4 +934,78 @@ QDebug operator<<(QDebug dbg, const QJsonValue &o)
}
#endif
+#ifndef QT_NO_DATASTREAM
+QDataStream &operator<<(QDataStream &stream, const QJsonValue &v)
+{
+ quint8 type = v.t;
+ stream << type;
+ switch (type) {
+ case QJsonValue::Undefined:
+ case QJsonValue::Null:
+ break;
+ case QJsonValue::Bool:
+ stream << v.toBool();
+ break;
+ case QJsonValue::Double:
+ stream << v.toDouble();
+ break;
+ case QJsonValue::String:
+ stream << v.toString();
+ break;
+ case QJsonValue::Array:
+ stream << v.toArray();
+ break;
+ case QJsonValue::Object:
+ stream << v.toObject();
+ break;
+ }
+ return stream;
+}
+
+QDataStream &operator>>(QDataStream &stream, QJsonValue &v)
+{
+ quint8 type;
+ stream >> type;
+ switch (type) {
+ case QJsonValue::Undefined:
+ case QJsonValue::Null:
+ v = QJsonValue{QJsonValue::Type(type)};
+ break;
+ case QJsonValue::Bool: {
+ bool b;
+ stream >> b;
+ v = QJsonValue(b);
+ break;
+ } case QJsonValue::Double: {
+ double d;
+ stream >> d;
+ v = QJsonValue{d};
+ break;
+ } case QJsonValue::String: {
+ QString s;
+ stream >> s;
+ v = QJsonValue{s};
+ break;
+ }
+ case QJsonValue::Array: {
+ QJsonArray a;
+ stream >> a;
+ v = QJsonValue{a};
+ break;
+ }
+ case QJsonValue::Object: {
+ QJsonObject o;
+ stream >> o;
+ v = QJsonValue{o};
+ break;
+ }
+ default: {
+ stream.setStatus(QDataStream::ReadCorruptData);
+ v = QJsonValue{QJsonValue::Undefined};
+ }
+ }
+ return stream;
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/corelib/serialization/qjsonvalue.h b/src/corelib/serialization/qjsonvalue.h
index d8e121524d..0339eb59f7 100644
--- a/src/corelib/serialization/qjsonvalue.h
+++ b/src/corelib/serialization/qjsonvalue.h
@@ -152,6 +152,7 @@ private:
friend class QJsonObject;
friend class QCborValue;
friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonValue &);
+ friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QJsonValue &);
QJsonValue(QJsonPrivate::Data *d, QJsonPrivate::Base *b, const QJsonPrivate::Value& v);
void stringDataFromQStringHelper(const QString &string);
@@ -218,7 +219,6 @@ private:
uint index : 31;
};
-#ifndef Q_QDOC
// ### Qt 6: Get rid of these fake pointer classes
class QJsonValuePtr
{
@@ -243,7 +243,6 @@ public:
QJsonValueRef& operator*() { return valueRef; }
QJsonValueRef* operator->() { return &valueRef; }
};
-#endif
Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QJsonValue)
@@ -253,6 +252,11 @@ Q_CORE_EXPORT uint qHash(const QJsonValue &value, uint seed = 0);
Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonValue &);
#endif
+#ifndef QT_NO_DATASTREAM
+Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QJsonValue &);
+Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QJsonValue &);
+#endif
+
QT_END_NAMESPACE
#endif // QJSONVALUE_H
diff --git a/src/corelib/statemachine/qsignaltransition_p.h b/src/corelib/statemachine/qsignaltransition_p.h
index 0666e600a4..b3de334677 100644
--- a/src/corelib/statemachine/qsignaltransition_p.h
+++ b/src/corelib/statemachine/qsignaltransition_p.h
@@ -70,7 +70,7 @@ public:
void unregister();
void maybeRegister();
- virtual void callOnTransition(QEvent *e) override;
+ void callOnTransition(QEvent *e) override;
const QObject *sender;
QByteArray signal;
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 7388d496d9..ee3f7be279 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -1721,8 +1721,8 @@ QAbstractTransition *QStateMachinePrivate::createInitialTransition() const
: QAbstractTransition()
{ setTargetStates(targets); }
protected:
- virtual bool eventTest(QEvent *) override { return true; }
- virtual void onTransition(QEvent *) override {}
+ bool eventTest(QEvent *) override { return true; }
+ void onTransition(QEvent *) override {}
};
QState *root = rootState();
diff --git a/src/corelib/thread/qresultstore.cpp b/src/corelib/thread/qresultstore.cpp
index e0ce1b4b78..1b3bc20eca 100644
--- a/src/corelib/thread/qresultstore.cpp
+++ b/src/corelib/thread/qresultstore.cpp
@@ -43,6 +43,21 @@ QT_BEGIN_NAMESPACE
namespace QtPrivate {
+/*!
+ \class QtPrivate::ResultItem
+ \internal
+ */
+
+/*!
+ \class QtPrivate::ResultIteratorBase
+ \internal
+ */
+
+/*!
+ \class QtPrivate::ResultStoreBase
+ \internal
+ */
+
ResultIteratorBase::ResultIteratorBase()
: mapIterator(QMap<int, ResultItem>::const_iterator()), m_vectorIndex(0) { }
ResultIteratorBase::ResultIteratorBase(QMap<int, ResultItem>::const_iterator _mapIterator, int _vectorIndex)
diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h
index 39f0a6d1bb..1f29e8d187 100644
--- a/src/corelib/thread/qresultstore.h
+++ b/src/corelib/thread/qresultstore.h
@@ -56,7 +56,6 @@ QT_BEGIN_NAMESPACE
either individually or in batches.
*/
-#ifndef Q_QDOC
namespace QtPrivate {
@@ -196,7 +195,6 @@ public:
Q_DECLARE_TYPEINFO(QtPrivate::ResultItem, Q_PRIMITIVE_TYPE);
-#endif //Q_QDOC
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 8f2ad8c012..1d8621ad5a 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -3076,7 +3076,7 @@ bool QByteArray::endsWith(const char *str) const
return qstrncmp(d->data() + d->size - len, str, len) == 0;
}
-/*!
+/*
Returns true if \a c is an uppercase Latin1 letter.
\note The multiplication sign 0xD7 and the sz ligature 0xDF are not
treated as uppercase Latin1.
@@ -3112,7 +3112,7 @@ bool QByteArray::isUpper() const
return true;
}
-/*!
+/*
Returns true if \a c is an lowercase Latin1 letter.
\note The division sign 0xF7 is not treated as lowercase Latin1,
but the small y dieresis 0xFF is.
@@ -3882,9 +3882,7 @@ static qulonglong toIntegral_helper(const char *data, bool *ok, int base, qulong
template <typename T> static inline
T toIntegral_helper(const char *data, bool *ok, int base)
{
- // ### Qt6: use std::conditional<std::is_unsigned<T>::value, qulonglong, qlonglong>::type
- const bool isUnsigned = T(0) < T(-1);
- typedef typename QtPrivate::QConditional<isUnsigned, qulonglong, qlonglong>::Type Int64;
+ using Int64 = typename std::conditional<std::is_unsigned<T>::value, qulonglong, qlonglong>::type;
#if defined(QT_CHECK_RANGE)
if (base != 0 && (base < 2 || base > 36)) {
diff --git a/src/corelib/tools/qbytearraylist.cpp b/src/corelib/tools/qbytearraylist.cpp
index c815e766ab..d04555ed4d 100644
--- a/src/corelib/tools/qbytearraylist.cpp
+++ b/src/corelib/tools/qbytearraylist.cpp
@@ -150,4 +150,26 @@ QByteArray QtPrivate::QByteArrayList_join(const QByteArrayList *that, const char
return res;
}
+/*!
+ \fn int QByteArrayList::indexOf(const char *needle, int from) const
+
+ Returns the index position of the first occurrence of \a needle in
+ the list, searching forward from index position \a from. Returns
+ -1 if no item matched.
+
+ \a needle must be NUL-terminated.
+
+ This overload doesn't require creating a QByteArray, thus saving a
+ memory allocation and some CPU time.
+
+ \since 5.13
+ \overload
+*/
+
+int QtPrivate::QByteArrayList_indexOf(const QByteArrayList *that, const char *needle, int from)
+{
+ const auto it = std::find_if(that->begin() + from, that->end(), [needle](const QByteArray &item) { return item == needle; });
+ return it == that->end() ? -1 : int(std::distance(that->begin(), it));
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qbytearraylist.h b/src/corelib/tools/qbytearraylist.h
index ed014dd157..d69e8bb54b 100644
--- a/src/corelib/tools/qbytearraylist.h
+++ b/src/corelib/tools/qbytearraylist.h
@@ -50,21 +50,22 @@ QT_BEGIN_NAMESPACE
typedef QListIterator<QByteArray> QByteArrayListIterator;
typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator;
-#ifndef Q_QDOC
+#ifndef Q_CLANG_QDOC
typedef QList<QByteArray> QByteArrayList;
namespace QtPrivate {
QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength);
+ int Q_CORE_EXPORT QByteArrayList_indexOf(const QByteArrayList *that, const char *needle, int from);
}
#endif
-#ifdef Q_QDOC
+#ifdef Q_CLANG_QDOC
class QByteArrayList : public QList<QByteArray>
#else
template <> struct QListSpecialMethods<QByteArray>
#endif
{
-#ifndef Q_QDOC
+#ifndef Q_CLANG_QDOC
protected:
~QListSpecialMethods() {}
#endif
@@ -76,6 +77,9 @@ public:
inline QByteArray join(char sep) const
{ return QtPrivate::QByteArrayList_join(self(), &sep, 1); }
+ inline int indexOf(const char *needle, int from = 0) const
+ { return QtPrivate::QByteArrayList_indexOf(self(), needle, from); }
+
private:
typedef QList<QByteArray> Self;
Self *self() { return static_cast<Self *>(this); }
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 816bd974eb..600bd1e0e5 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -2171,16 +2171,6 @@ int QTime::elapsed() const
typedef QDateTimePrivate::QDateTimeShortData ShortData;
typedef QDateTimePrivate::QDateTimeData QDateTimeData;
-// Calls the platform variant of tzset
-static void qt_tzset()
-{
-#if defined(Q_OS_WIN)
- _tzset();
-#else
- tzset();
-#endif // Q_OS_WIN
-}
-
// Returns the platform variant of timezone, i.e. the standard time offset
// The timezone external variable is documented as always holding the
// Standard Time offset as seconds west of Greenwich, i.e. UTC+01:00 is -3600
@@ -2278,7 +2268,7 @@ static qint64 qt_mktime(QDate *date, QTime *time, QDateTimePrivate::DaylightStat
#if defined(Q_OS_WIN)
int hh = local.tm_hour;
#endif // Q_OS_WIN
- time_t secsSinceEpoch = mktime(&local);
+ time_t secsSinceEpoch = qMkTime(&local);
if (secsSinceEpoch != time_t(-1)) {
*date = QDate(local.tm_year + 1900, local.tm_mon + 1, local.tm_mday);
*time = QTime(local.tm_hour, local.tm_min, local.tm_sec, msec);
@@ -2337,10 +2327,10 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT
tm local;
bool valid = false;
- // localtime() is required to work as if tzset() was called before it.
- // localtime_r() does not have this requirement, so make an explicit call.
+ // localtime() is specified to work as if it called tzset().
+ // localtime_r() does not have this constraint, so make an explicit call.
// The explicit call should also request the timezone info be re-parsed.
- qt_tzset();
+ qTzSet();
#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
// Use the reentrant version of localtime() where available
// as is thread-safe and doesn't use a shared static data area
@@ -2422,7 +2412,7 @@ static bool epochMSecsToLocalTime(qint64 msecs, QDate *localDate, QTime *localTi
if (msecs < 0) {
// Docs state any LocalTime before 1970-01-01 will *not* have any Daylight Time applied
// Instead just use the standard offset from UTC to convert to UTC time
- qt_tzset();
+ qTzSet();
msecsToTime(msecs - qt_timezone() * 1000, localDate, localTime);
if (daylightStatus)
*daylightStatus = QDateTimePrivate::StandardTime;
@@ -2485,7 +2475,7 @@ static qint64 localMSecsToEpochMSecs(qint64 localMsecs,
}
} else {
// If we don't call mktime then need to call tzset to get offset
- qt_tzset();
+ qTzSet();
}
// Time is clearly before 1970-01-01 so just use standard offset to convert
qint64 utcMsecs = localMsecs + qt_timezone() * 1000;
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index ddc973cb37..4d5924a03e 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -620,13 +620,18 @@ static QLocalePrivate *c_private()
*/
/*!
- Constructs a QSystemLocale object. The constructor will automatically
- install this object as the system locale and remove any earlier installed
- system locales.
+ Constructs a QSystemLocale object.
+
+ The constructor will automatically install this object as the system locale,
+ if there's not one active. It also resets the flag that'll prompt
+ QLocale::system() to re-initialize its data, so that instantiating a
+ QSystemLocale transiently (doesn't install the transient as system locale if
+ there was one already and) triggers an update to the system locale's data.
*/
QSystemLocale::QSystemLocale()
{
- _systemLocale = this;
+ if (!_systemLocale)
+ _systemLocale = this;
globalLocaleData.m_language_id = 0;
}
@@ -656,15 +661,17 @@ static const QSystemLocale *systemLocale()
return QSystemLocale_globalSystemLocale();
}
-void QLocalePrivate::updateSystemPrivate()
+static void updateSystemPrivate()
{
- // this function is NOT thread-safe!
+ // This function is NOT thread-safe!
+ // It *should not* be called by anything but systemData()
const QSystemLocale *sys_locale = systemLocale();
// tell the object that the system locale has changed.
sys_locale->query(QSystemLocale::LocaleChanged, QVariant());
- globalLocaleData = *sys_locale->fallbackUiLocale().d->m_data;
+ // Populate global with fallback as basis:
+ globalLocaleData = *sys_locale->fallbackUiLocaleData();
QVariant res = sys_locale->query(QSystemLocale::LanguageId, QVariant());
if (!res.isNull()) {
@@ -715,7 +722,7 @@ static const QLocaleData *systemData()
static QBasicMutex systemDataMutex;
systemDataMutex.lock();
if (globalLocaleData.m_language_id == 0)
- QLocalePrivate::updateSystemPrivate();
+ updateSystemPrivate();
systemDataMutex.unlock();
}
@@ -1180,9 +1187,7 @@ static qulonglong toIntegral_helper(const QLocaleData *d, QStringView str, bool
template <typename T> static inline
T toIntegral_helper(const QLocalePrivate *d, QStringView str, bool *ok)
{
- // ### Qt6: use std::conditional<std::is_unsigned<T>::value, qulonglong, qlonglong>::type
- const bool isUnsigned = T(0) < T(-1);
- typedef typename QtPrivate::QConditional<isUnsigned, qulonglong, qlonglong>::Type Int64;
+ using Int64 = typename std::conditional<std::is_unsigned<T>::value, qulonglong, qlonglong>::type;
// we select the right overload by the last, unused parameter
Int64 val = toIntegral_helper(d->m_data, str, ok, d->m_numberOptions, Int64());
@@ -2353,7 +2358,6 @@ QString QLocale::toString(double i, char f, int prec) const
QLocale QLocale::system()
{
- // this function is NOT thread-safe!
QT_PREPEND_NAMESPACE(systemData)(); // trigger updating of the system data if necessary
return QLocale(*systemLocalePrivate->data());
}
@@ -3877,6 +3881,19 @@ QString QLocale::toCurrencyString(double value, const QString &symbol, int preci
\sa formattedDataSize()
*/
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+/*!
+ \obsolete
+
+ Use the const version instead.
+*/
+QString QLocale::formattedDataSize(qint64 bytes, int precision, DataSizeFormats format)
+{
+ const auto *that = this;
+ return that->formattedDataSize(bytes, precision, format);
+}
+#endif
+
/*!
\since 5.10
@@ -3893,7 +3910,7 @@ QString QLocale::toCurrencyString(double value, const QString &symbol, int preci
whereas \c DataSizeSIFormat uses the older SI quantifiers k, M, etc., and
\c DataSizeTraditionalFormat abuses them.
*/
-QString QLocale::formattedDataSize(qint64 bytes, int precision, DataSizeFormats format)
+QString QLocale::formattedDataSize(qint64 bytes, int precision, DataSizeFormats format) const
{
int power, base = 1000;
if (!bytes) {
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h
index f3afb8c406..1fbd96c6d5 100644
--- a/src/corelib/tools/qlocale.h
+++ b/src/corelib/tools/qlocale.h
@@ -436,6 +436,11 @@ public:
Cantonese = 357,
Osage = 358,
Tangut = 359,
+ Ido = 360,
+ Lojban = 361,
+ Sicilian = 362,
+ SouthernKurdish = 363,
+ WesternBalochi = 364,
Afan = Oromo,
Bhutani = Dzongkha,
@@ -452,7 +457,7 @@ public:
Twi = Akan,
Uigur = Uighur,
- LastLanguage = Tangut
+ LastLanguage = WesternBalochi
};
enum Script {
@@ -1061,7 +1066,10 @@ public:
{ return toCurrencyString(double(i), symbol, precision); }
#endif
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QString formattedDataSize(qint64 bytes, int precision = 2, DataSizeFormats format = DataSizeIecFormat);
+#endif
+ QString formattedDataSize(qint64 bytes, int precision = 2, DataSizeFormats format = DataSizeIecFormat) const;
QStringList uiLanguages() const;
@@ -1091,6 +1099,7 @@ public:
private:
QLocale(QLocalePrivate &dd);
friend class QLocalePrivate;
+ friend class QSystemLocale;
friend Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed) Q_DECL_NOTHROW;
QSharedDataPointer<QLocalePrivate> d;
diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc
index 76ca909d83..b852c10b8d 100644
--- a/src/corelib/tools/qlocale.qdoc
+++ b/src/corelib/tools/qlocale.qdoc
@@ -105,42 +105,80 @@
\value AnyLanguage
\value C The "C" locale is identical in behavior to English/UnitedStates.
+
\value Abkhazian
- \value Oromo
\value Afan Obsolete, please use Oromo
\value Afar
\value Afrikaans
+ \value Aghem
+ \value Ahom Since Qt 5.7
+ \value Akan
+ \value Akkadian Since Qt 5.1
\value Akoose Since Qt 5.3
\value Albanian
+ \value AmericanSignLanguage Since Qt 5.7
\value Amharic
+ \value AncientEgyptian Since Qt 5.1
+ \value AncientGreek Since Qt 5.1
+ \value AncientNorthArabian Since Qt 5.5
\value Arabic
+ \value Aragonese Since Qt 5.1
+ \value Aramaic Since Qt 5.1
+ \value ArdhamagadhiPrakrit Since Qt 5.7
\value Armenian
\value Assamese
+ \value Asturian
+ \value Asu
+ \value Atsam
\value Avaric
+ \value Avestan
\value Aymara
\value Azerbaijani
+ \value Bafia
+ \value Balinese Since Qt 5.1
+ \value Bambara
+ \value Bamun Since Qt 5.1
+ \value Basaa
\value Bashkir
\value Basque
+ \value Bassa Since Qt 5.5
+ \value BatakToba Since Qt 5.1
+ \value Belarusian
+ \value Bemba
+ \value Bena
\value Bengali
- \value Dzongkha
+ \value Bhojpuri Since Qt 5.7
\value Bhutani Obsolete, please use Dzongkha
\value Bihari
\value Bislama
- \value Bosnian
+ \value Blin
\value Bodo
+ \value Bosnian
\value Breton
+ \value Buginese Since Qt 5.1
+ \value Buhid Since Qt 5.1
\value Bulgarian
\value Burmese
- \value Belarusian
\value Byelorussian Obsolete, please use Belarusian
- \value Khmer
\value Cambodian Obsolete, please use Khmer
+ \value Cantonese Since Qt 5.7
+ \value Carian Since Qt 5.1
\value Catalan
+ \value CentralKurdish Since Qt 5.5
+ \value CentralMoroccoTamazight
+ \value Chakma Since Qt 5.1
\value Chamorro
\value Chechen
+ \value Cherokee
+ \value Chewa Obsolete, please use Nyanja
+ \value Chiga
\value Chinese
\value Church
\value Chuvash
+ \value ClassicalMandaic Since Qt 5.1
+ \value Colognian
+ \value CongoSwahili
+ \value Coptic Since Qt 5.1
\value Cornish
\value Corsican
\value Cree
@@ -148,33 +186,58 @@
\value Czech
\value Danish
\value Divehi
+ \value Dogri Since Qt 5.1
+ \value Duala
\value Dutch
+ \value Dzongkha
+ \value EasternCham Since Qt 5.1
+ \value EasternKayah Since Qt 5.1
+ \value Embu
\value English
\value Esperanto
\value Estonian
+ \value Etruscan Since Qt 5.1
+ \value Ewe
+ \value Ewondo
\value Faroese
\value Fijian
+ \value Filipino
\value Finnish
\value French
- \value WesternFrisian same as Frisian
\value Frisian same as WesternFrisian
+ \value Friulian
+ \value Fulah
+ \value Ga
\value Gaelic
\value Galician
+ \value Ganda
+ \value Geez
\value Georgian
\value German
+ \value Gothic Since Qt 5.1
\value Greek
\value Greenlandic
\value Guarani
\value Gujarati
+ \value Gusii
\value Haitian
+ \value Hanunoo Since Qt 5.1
\value Hausa
+ \value Hawaiian
\value Hebrew
\value Herero
+ \value HieroglyphicLuwian Since Qt 5.7
\value Hindi
\value HiriMotu
+ \value HmongNjua Since Qt 5.5
+ \value Ho Since Qt 5.5
\value Hungarian
\value Icelandic
+ \value Ido Since Qt 5.12
+ \value Igbo
+ \value InariSami Since Qt 5.5
\value Indonesian
+ \value Ingush Since Qt 5.1
\value Interlingua
\value Interlingue
\value Inuktitut
@@ -183,306 +246,244 @@
\value Italian
\value Japanese
\value Javanese
+ \value Jju
+ \value JolaFonyi
+ \value Kabuverdianu
+ \value Kabyle
+ \value Kako
+ \value Kalenjin
+ \value Kamba
\value Kannada
\value Kanuri
\value Kashmiri
\value Kazakh
+ \value Kenyang Since Qt 5.5
+ \value Khmer
+ \value Kiche Since Qt 5.5
+ \value Kikuyu
\value Kinyarwanda
\value Kirghiz
\value Komi
\value Kongo
+ \value Konkani
\value Korean
+ \value Koro
+ \value KoyraboroSenni
+ \value KoyraChiini
+ \value Kpelle
\value Kurdish
- \value Rundi
\value Kurundi Obsolete, please use Rundi
\value Kwanyama
+ \value Kwasio
\value Lakota Since Qt 5.3
+ \value Langi
\value Lao
+ \value LargeFloweryMiao Since Qt 5.1
\value Latin
\value Latvian
+ \value Lepcha Since Qt 5.1
+ \value Lezghian Since Qt 5.5
\value Limburgish
+ \value Limbu Since Qt 5.1
+ \value LinearA Since Qt 5.5
\value Lingala
+ \value Lisu Since Qt 5.1
+ \value LiteraryChinese Since Qt 5.7
\value Lithuanian
+ \value Lojban Since Qt 5.12
+ \value LowerSorbian Since Qt 5.5
+ \value LowGerman
\value LubaKatanga
+ \value LuleSami Since Qt 5.5
+ \value Luo
+ \value Lu Since Qt 5.1
\value Luxembourgish
- \value Marshallese
+ \value Luyia
+ \value Lycian Since Qt 5.1
+ \value Lydian Since Qt 5.1
\value Macedonian
+ \value Machame
+ \value Maithili Since Qt 5.5
+ \value MakhuwaMeetto
+ \value Makonde
\value Malagasy
\value Malay
\value Malayalam
\value Maltese
+ \value Mandingo Since Qt 5.1
+ \value ManichaeanMiddlePersian Since Qt 5.5
+ \value Manipuri Since Qt 5.1
\value Manx
\value Maori
+ \value Mapuche Since Qt 5.5
\value Marathi
+ \value Marshallese
+ \value Masai
+ \value Mazanderani Since Qt 5.7
+ \value Mende Since Qt 5.5
+ \value Meroitic Since Qt 5.1
+ \value Meru
+ \value Meta
+ \value Mohawk Since Qt 5.5
\value Moldavian Obsolete, please use Romanian
\value Mongolian
+ \value Mono Since Qt 5.5
+ \value Morisyen
+ \value Mru Since Qt 5.7
+ \value Mundang
+ \value Nama
\value NauruLanguage
\value Navaho
\value Ndonga
\value Nepali
- \value Norwegian same as NorwegianBokmal
+ \value Newari Since Qt 5.7
+ \value Ngiemboon
+ \value Ngomba
+ \value Nko Since Qt 5.5
+ \value NorthernLuri Since Qt 5.7
+ \value NorthernSami
+ \value NorthernSotho
+ \value NorthernThai Since Qt 5.1
+ \value NorthNdebele
\value NorwegianBokmal same as Norwegian
\value NorwegianNynorsk
+ \value Norwegian same as NorwegianBokmal
+ \value Nuer
+ \value Nyanja
+ \value Nyankole
\value Occitan
\value Ojibwa
+ \value OldIrish Since Qt 5.1
+ \value OldNorse Since Qt 5.1
+ \value OldPersian Since Qt 5.1
+ \value OldTurkish Since Qt 5.1
\value Oriya
+ \value Oromo
+ \value Osage Since Qt 5.7
\value Ossetic
+ \value Pahlavi Since Qt 5.1
+ \value Palauan Since Qt 5.7
\value Pali
+ \value Papiamento Since Qt 5.7
+ \value Parthian Since Qt 5.1
\value Pashto
\value Persian
+ \value Phoenician Since Qt 5.1
\value Polish
\value Portuguese
+ \value PrakritLanguage Since Qt 5.1
+ \value Prussian Since Qt 5.5
\value Punjabi
\value Quechua
- \value Romansh
+ \value Rejang Since Qt 5.1
\value RhaetoRomance Obsolete, please use Romansh
\value Romanian
+ \value Romansh
+ \value Rombo
+ \value Rundi
\value Russian
+ \value Rwa
+ \value Sabaean Since Qt 5.1
+ \value Saho
+ \value Sakha
+ \value Samaritan Since Qt 5.1
+ \value Samburu
\value Samoan
\value Sango
+ \value Sangu
\value Sanskrit
+ \value Santali Since Qt 5.1
+ \value Saraiki Since Qt 5.7
\value Sardinian
+ \value Saurashtra Since Qt 5.1
+ \value Sena
\value Serbian
\value SerboCroatian Obsolete, please use Serbian
- \value SouthernSotho
- \value Tswana
+ \value Shambala
\value Shona
+ \value SichuanYi
+ \value Sicilian Since Qt 5.12
+ \value Sidamo
\value Sindhi
\value Sinhala
- \value Swati
+ \value SkoltSami Since Qt 5.5
\value Slovak
\value Slovenian
+ \value Soga
\value Somali
+ \value Sora Since Qt 5.1
+ \value SouthernKurdish Since Qt 5.12
+ \value SouthernSami Since Qt 5.5
+ \value SouthernSotho
+ \value SouthNdebele
\value Spanish
\value StandardMoroccanTamazight Since Qt 5.3
\value Sundanese
\value Swahili
+ \value Swati
\value Swedish
+ \value SwissGerman
+ \value Sylheti Since Qt 5.1
+ \value Syriac
+ \value Tachelhit
\value Tagalog Obsolete, please use Filipino
+ \value Tagbanwa Since Qt 5.1
\value Tahitian
+ \value TaiDam Since Qt 5.1
+ \value TaiNua Since Qt 5.1
+ \value Taita
\value Tajik
\value Tamil
+ \value Tangut Since Qt 5.7
+ \value Taroko
+ \value Tasawaq
\value Tatar
+ \value TedimChin Since Qt 5.5
\value Telugu
+ \value Teso
\value Thai
\value Tibetan
+ \value Tigre
\value Tigrinya
+ \value TokelauLanguage Since Qt 5.7
+ \value TokPisin Since Qt 5.7
\value Tongan
\value Tsonga
+ \value Tswana
\value Turkish
\value Turkmen
+ \value TuvaluLanguage Since Qt 5.7
\value Twi Obsolete, please use Akan
+ \value Tyap
+ \value Ugaritic Since Qt 5.1
\value Uighur
\value Uigur Obsolete, please use Uighur
\value Ukrainian
+ \value UncodedLanguages Since Qt 5.7
+ \value UpperSorbian Since Qt 5.5
\value Urdu
\value Uzbek
+ \value Vai
+ \value Venda
\value Vietnamese
\value Volapuk
+ \value Vunjo
+ \value Walamo
\value Walloon
+ \value Walser
+ \value Warlpiri Since Qt 5.5
\value Welsh
+ \value WesternBalochi Since Qt 5.12
+ \value WesternFrisian same as Frisian
\value Wolof
\value Xhosa
+ \value Yangben
\value Yiddish
\value Yoruba
+ \value Zarma
\value Zhuang
\value Zulu
- \value Bosnian
- \value Divehi
- \value Manx
- \value Cornish
- \value Akan
- \value Konkani
- \value Ga
- \value Igbo
- \value Kamba
- \value Syriac
- \value Blin
- \value Geez
- \value Koro
- \value Sidamo
- \value Atsam
- \value Tigre
- \value Jju
- \value Friulian
- \value Venda
- \value Ewe
- \value Walamo
- \value Hawaiian
- \value Tyap
- \value Nyanja
- \value Chewa Obsolete, please use Nyanja
- \value Filipino
- \value SwissGerman
- \value SichuanYi
- \value Kpelle
- \value LowGerman
- \value SouthNdebele
- \value NorthernSotho
- \value NorthernSami
- \value Taroko
- \value Gusii
- \value Taita
- \value Fulah
- \value Kikuyu
- \value Samburu
- \value Sena
- \value NorthNdebele
- \value Rombo
- \value Tachelhit
- \value Kabyle
- \value Nyankole
- \value Bena
- \value Vunjo
- \value Bambara
- \value Embu
- \value Cherokee
- \value Morisyen
- \value Makonde
- \value Langi
- \value Ganda
- \value Bemba
- \value Kabuverdianu
- \value Meru
- \value Kalenjin
- \value Nama
- \value Machame
- \value Colognian
- \value Masai
- \value Soga
- \value Luyia
- \value Asu
- \value Teso
- \value Saho
- \value KoyraChiini
- \value Rwa
- \value Luo
- \value Chiga
- \value CentralMoroccoTamazight
- \value KoyraboroSenni
- \value Shambala
- \value Aghem
- \value Basaa
- \value Zarma
- \value Duala
- \value JolaFonyi
- \value Ewondo
- \value Bafia
- \value MakhuwaMeetto
- \value Mundang
- \value Kwasio
- \value Nuer
- \value Sakha
- \value Sangu
- \value CongoSwahili
- \value Tasawaq
- \value Vai
- \value Walser
- \value Yangben
- \value Avestan
- \value Asturian
- \value Ngomba
- \value Kako
- \value Meta
- \value Ngiemboon
- \value Aragonese
- \value Akkadian
- \value AncientEgyptian
- \value AncientGreek
- \value Aramaic
- \value Balinese
- \value Bamun
- \value BatakToba
- \value Buginese
- \value Buhid
- \value Carian
- \value Chakma
- \value ClassicalMandaic
- \value Coptic
- \value Dogri
- \value EasternCham
- \value EasternKayah
- \value Etruscan
- \value Gothic
- \value Hanunoo
- \value Ingush
- \value LargeFloweryMiao
- \value Lepcha
- \value Limbu
- \value Lisu
- \value Lu
- \value Lycian
- \value Lydian
- \value Mandingo
- \value Manipuri
- \value Meroitic
- \value NorthernThai
- \value OldIrish
- \value OldNorse
- \value OldPersian
- \value OldTurkish
- \value Pahlavi
- \value Parthian
- \value Phoenician
- \value PrakritLanguage
- \value Rejang
- \value Sabaean
- \value Samaritan
- \value Santali
- \value Saurashtra
- \value Sora
- \value Sylheti
- \value Tagbanwa
- \value TaiDam
- \value TaiNua
- \value Ugaritic
- \value Mapuche Since Qt 5.5
- \value CentralKurdish Since Qt 5.5
- \value LowerSorbian Since Qt 5.5
- \value UpperSorbian Since Qt 5.5
- \value Kenyang Since Qt 5.5
- \value Mohawk Since Qt 5.5
- \value Nko Since Qt 5.5
- \value Prussian Since Qt 5.5
- \value Kiche Since Qt 5.5
- \value SouthernSami Since Qt 5.5
- \value LuleSami Since Qt 5.5
- \value InariSami Since Qt 5.5
- \value SkoltSami Since Qt 5.5
- \value Warlpiri Since Qt 5.5
- \value ManichaeanMiddlePersian Since Qt 5.5
- \value Mende Since Qt 5.5
- \value AncientNorthArabian Since Qt 5.5
- \value LinearA Since Qt 5.5
- \value HmongNjua Since Qt 5.5
- \value Ho Since Qt 5.5
- \value Lezghian Since Qt 5.5
- \value Bassa Since Qt 5.5
- \value Mono Since Qt 5.5
- \value TedimChin Since Qt 5.5
- \value Maithili Since Qt 5.5
- \value LowerSorbian Since Qt 5.5
- \value UpperSorbian Since Qt 5.5
- \value Ahom Since Qt 5.7
- \value AmericanSignLanguage Since Qt 5.7
- \value ArdhamagadhiPrakrit Since Qt 5.7
- \value Bhojpuri Since Qt 5.7
- \value Cantonese Since Qt 5.7
- \value HieroglyphicLuwian Since Qt 5.7
- \value LiteraryChinese Since Qt 5.7
- \value Mazanderani Since Qt 5.7
- \value Mru Since Qt 5.7
- \value Newari Since Qt 5.7
- \value NorthernLuri Since Qt 5.7
- \value Osage Since Qt 5.7
- \value Palauan Since Qt 5.7
- \value Papiamento Since Qt 5.7
- \value Saraiki Since Qt 5.7
- \value Tangut Since Qt 5.7
- \value TokelauLanguage Since Qt 5.7
- \value TokPisin Since Qt 5.7
- \value TuvaluLanguage Since Qt 5.7
- \value UncodedLanguages Since Qt 5.7
+
\omitvalue LastLanguage
\sa language(), languageToString()
@@ -494,7 +495,9 @@
This enumerated type is used to specify a country.
\value AnyCountry
+
\value Afghanistan
+ \value AlandIslands
\value Albania
\value Algeria
\value AmericanSamoa
@@ -506,6 +509,7 @@
\value Argentina
\value Armenia
\value Aruba
+ \value AscensionIsland
\value Australia
\value Austria
\value Azerbaijan
@@ -520,11 +524,13 @@
\value Bermuda
\value Bhutan
\value Bolivia
+ \value Bonaire
\value BosniaAndHerzegowina
\value Botswana
\value BouvetIsland
\value Brazil
\value BritishIndianOceanTerritory
+ \value BritishVirginIslands
\value Brunei
\value Bulgaria
\value BurkinaFaso
@@ -536,6 +542,7 @@
\value CapeVerde
\value CaymanIslands
\value CentralAfricanRepublic
+ \value CeutaAndMelilla
\value Chad
\value Chile
\value China
@@ -544,18 +551,19 @@
\value CocosIslands
\value Colombia
\value Comoros
- \value CongoKinshasa
\value CongoBrazzaville
- \value DemocraticRepublicOfCongo Obsolete, please use CongoKinshasa
- \value PeoplesRepublicOfCongo Obsolete, please use CongoBrazzaville
+ \value CongoKinshasa
\value CookIslands
\value CostaRica
- \value IvoryCoast
\value Croatia
\value Cuba
+ \value CuraSao
\value Cyprus
\value CzechRepublic
+ \value DemocraticRepublicOfCongo Obsolete, please use CongoKinshasa
+ \value DemocraticRepublicOfKorea Obsolete, please use NorthKorea
\value Denmark
+ \value DiegoGarcia
\value Djibouti
\value Dominica
\value DominicanRepublic
@@ -604,19 +612,18 @@
\value Iran
\value Iraq
\value Ireland
+ \value IsleOfMan
\value Israel
\value Italy
+ \value IvoryCoast
\value Jamaica
\value Japan
+ \value Jersey
\value Jordan
\value Kazakhstan
\value Kenya
\value Kiribati
- \value NorthKorea
- \value SouthKorea
- \value DemocraticRepublicOfKorea Obsolete, please use NorthKorea
- \value RepublicOfKorea Obsolete, please use SouthKorea
- \value Kosovo
+ \value Kosovo Since Qt 5.2
\value Kuwait
\value Kyrgyzstan
\value Laos
@@ -648,6 +655,7 @@
\value Moldova
\value Monaco
\value Mongolia
+ \value Montenegro
\value Montserrat
\value Morocco
\value Mozambique
@@ -664,6 +672,7 @@
\value Niue
\value NorfolkIsland
\value NorthernMarianaIslands
+ \value NorthKorea
\value Norway
\value Oman
\value OutlyingOceania Since Qt 5.7
@@ -673,6 +682,7 @@
\value Panama
\value PapuaNewGuinea
\value Paraguay
+ \value PeoplesRepublicOfCongo Obsolete, please use CongoBrazzaville
\value Peru
\value Philippines
\value Pitcairn
@@ -680,32 +690,39 @@
\value Portugal
\value PuertoRico
\value Qatar
+ \value RepublicOfKorea Obsolete, please use SouthKorea
\value Reunion
\value Romania
- \value Russia same as RussianFederation
\value RussianFederation same as Russia
+ \value Russia same as RussianFederation
\value Rwanda
+ \value SaintBarthelemy
+ \value SaintHelena
\value SaintKittsAndNevis
\value SaintLucia
+ \value SaintMartin
+ \value SaintPierreAndMiquelon
\value SaintVincentAndTheGrenadines
\value Samoa
\value SanMarino
\value SaoTomeAndPrincipe
\value SaudiArabia
\value Senegal
+ \value Serbia
\value Seychelles
\value SierraLeone
\value Singapore
+ \value SintMaarten
\value Slovakia
\value Slovenia
\value SolomonIslands
\value Somalia
\value SouthAfrica
\value SouthGeorgiaAndTheSouthSandwichIslands
+ \value SouthKorea
+ \value SouthSudan
\value Spain
\value SriLanka
- \value SaintHelena
- \value SaintPierreAndMiquelon
\value Sudan
\value Suriname
\value SvalbardAndJanMayenIslands
@@ -723,6 +740,7 @@
\value Tokelau Obsolete, please use TokelauCountry
\value Tonga
\value TrinidadAndTobago
+ \value TristanDaCunha
\value Tunisia
\value Turkey
\value Turkmenistan
@@ -735,35 +753,20 @@
\value UnitedKingdom
\value UnitedStates
\value UnitedStatesMinorOutlyingIslands
+ \value UnitedStatesVirginIslands
\value Uruguay
\value Uzbekistan
\value Vanuatu
\value VaticanCityState
\value Venezuela
\value Vietnam
- \value BritishVirginIslands
- \value UnitedStatesVirginIslands
\value WallisAndFutunaIslands
\value WesternSahara
\value World Since Qt 5.12
\value Yemen
\value Zambia
\value Zimbabwe
- \value Montenegro
- \value Serbia
- \value SaintBarthelemy
- \value SaintMartin
- \value AscensionIsland
- \value AlandIslands
- \value DiegoGarcia
- \value CeutaAndMelilla
- \value IsleOfMan
- \value Jersey
- \value TristanDaCunha
- \value SouthSudan
- \value CuraSao
- \value Bonaire
- \value SintMaarten
+
\omitvalue LastCountry
\sa country(), countryToString()
@@ -775,135 +778,136 @@
This enumerated type is used to specify a script.
\value AnyScript
+
\value AdlamScript Since Qt 5.7
\value AhomScript Since Qt 5.7
\value AnatolianHieroglyphsScript Since Qt 5.7
\value ArabicScript
\value ArmenianScript
- \value AvestanScript
- \value BalineseScript
- \value BamumScript
+ \value AvestanScript Since Qt 5.1
+ \value BalineseScript Since Qt 5.1
+ \value BamumScript Since Qt 5.1
\value BassaVahScript Since Qt 5.5
- \value BatakScript
+ \value BatakScript Since Qt 5.1
\value BengaliScript
\value BhaiksukiScript Since Qt 5.7
- \value BopomofoScript
- \value BrahmiScript
- \value BrailleScript
- \value BugineseScript
- \value BuhidScript
- \value CanadianAboriginalScript
- \value CarianScript
+ \value BopomofoScript Since Qt 5.1
+ \value BrahmiScript Since Qt 5.1
+ \value BrailleScript Since Qt 5.1
+ \value BugineseScript Since Qt 5.1
+ \value BuhidScript Since Qt 5.1
+ \value CanadianAboriginalScript Since Qt 5.1
+ \value CarianScript Since Qt 5.1
\value CaucasianAlbanianScript Since Qt 5.5
- \value ChakmaScript
- \value ChamScript
+ \value ChakmaScript Since Qt 5.1
+ \value ChamScript Since Qt 5.1
\value CherokeeScript
- \value CopticScript
- \value CypriotScript
+ \value CopticScript Since Qt 5.1
+ \value CuneiformScript Since Qt 5.1
+ \value CypriotScript Since Qt 5.1
\value CyrillicScript
- \value DeseretScript
+ \value DeseretScript Since Qt 5.1
\value DevanagariScript
\value DuployanScript Since Qt 5.5
- \value EgyptianHieroglyphsScript
+ \value EgyptianHieroglyphsScript Since Qt 5.1
\value ElbasanScript Since Qt 5.5
\value EthiopicScript
- \value FraserScript
+ \value FraserScript Since Qt 5.1
\value GeorgianScript
- \value GlagoliticScript
- \value GothicScript
+ \value GlagoliticScript Since Qt 5.1
+ \value GothicScript Since Qt 5.1
\value GranthaScript Since Qt 5.5
\value GreekScript
\value GujaratiScript
\value GurmukhiScript
- \value HanScript
- \value HangulScript
- \value HanunooScript
+ \value HangulScript Since Qt 5.1
+ \value HanScript Since Qt 5.1
+ \value HanunooScript Since Qt 5.1
\value HanWithBopomofoScript Since Qt 5.7
\value HatranScript Since Qt 5.7
\value HebrewScript
- \value HiraganaScript
- \value ImperialAramaicScript
- \value InscriptionalPahlaviScript
- \value InscriptionalParthianScript
+ \value HiraganaScript Since Qt 5.1
+ \value ImperialAramaicScript Since Qt 5.1
+ \value InscriptionalPahlaviScript Since Qt 5.1
+ \value InscriptionalParthianScript Since Qt 5.1
\value JamoScript Since Qt 5.7
\value JapaneseScript
- \value JavaneseScript
- \value KaithiScript
+ \value JavaneseScript Since Qt 5.1
+ \value KaithiScript Since Qt 5.1
\value KannadaScript
- \value KatakanaScript
- \value KayahLiScript
- \value KharoshthiScript
- \value KhmerScript
+ \value KatakanaScript Since Qt 5.1
+ \value KayahLiScript Since Qt 5.1
+ \value KharoshthiScript Since Qt 5.1
+ \value KhmerScript Since Qt 5.1
\value KhojkiScript Since Qt 5.5
\value KhudawadiScript Since Qt 5.5
\value KoreanScript
- \value LannaScript
+ \value LannaScript Since Qt 5.1
\value LaoScript
\value LatinScript
- \value LepchaScript
- \value LimbuScript
+ \value LepchaScript Since Qt 5.1
+ \value LimbuScript Since Qt 5.1
\value LinearAScript Since Qt 5.5
- \value LinearBScript
- \value LycianScript
- \value LydianScript
+ \value LinearBScript Since Qt 5.1
+ \value LycianScript Since Qt 5.1
+ \value LydianScript Since Qt 5.1
\value MahajaniScript Since Qt 5.5
\value MalayalamScript
- \value MandaeanScript
+ \value MandaeanScript Since Qt 5.1
\value ManichaeanScript Since Qt 5.5
\value MarchenScript Since Qt 5.7
- \value MeiteiMayekScript
+ \value MeiteiMayekScript Since Qt 5.1
\value MendeKikakuiScript Since Qt 5.5
- \value MeroiticScript
- \value MeroiticCursiveScript
+ \value MeroiticCursiveScript Since Qt 5.1
+ \value MeroiticScript Since Qt 5.1
\value ModiScript Since Qt 5.5
\value MongolianScript
\value MroScript Since Qt 5.5
\value MultaniScript Since Qt 5.7
\value MyanmarScript
\value NabataeanScript Since Qt 5.5
- \value NkoScript
\value NewaScript Since Qt 5.7
- \value NewTaiLueScript
- \value OghamScript
- \value OlChikiScript
- \value OldItalicScript
+ \value NewTaiLueScript Since Qt 5.1
+ \value NkoScript Since Qt 5.1
+ \value OghamScript Since Qt 5.1
+ \value OlChikiScript Since Qt 5.1
\value OldHungarianScript Since Qt 5.7
+ \value OldItalicScript Since Qt 5.1
\value OldNorthArabianScript Since Qt 5.5
\value OldPermicScript Since Qt 5.5
- \value OldPersianScript
- \value OldSouthArabianScript
+ \value OldPersianScript Since Qt 5.1
+ \value OldSouthArabianScript Since Qt 5.1
\value OriyaScript
- \value OrkhonScript
+ \value OrkhonScript Since Qt 5.1
\value OsageScript Since Qt 5.7
- \value OsmanyaScript
+ \value OsmanyaScript Since Qt 5.1
\value PahawhHmongScript Since Qt 5.5
\value PalmyreneScript Since Qt 5.5
\value PauCinHauScript Since Qt 5.5
- \value PhagsPaScript
- \value PhoenicianScript
- \value PollardPhoneticScript
+ \value PhagsPaScript Since Qt 5.1
+ \value PhoenicianScript Since Qt 5.1
+ \value PollardPhoneticScript Since Qt 5.1
\value PsalterPahlaviScript Since Qt 5.5
- \value RejangScript
- \value RunicScript
- \value SamaritanScript
- \value SaurashtraScript
- \value SharadaScript
- \value ShavianScript
+ \value RejangScript Since Qt 5.1
+ \value RunicScript Since Qt 5.1
+ \value SamaritanScript Since Qt 5.1
+ \value SaurashtraScript Since Qt 5.1
+ \value SharadaScript Since Qt 5.1
+ \value ShavianScript Since Qt 5.1
\value SiddhamScript Since Qt 5.5
\value SignWritingScript Since Qt 5.7
- \value SimplifiedHanScript same as SimplifiedChineseScript
\value SimplifiedChineseScript same as SimplifiedHanScript
+ \value SimplifiedHanScript same as SimplifiedChineseScript
\value SinhalaScript
- \value SoraSompengScript
- \value CuneiformScript
- \value SundaneseScript
- \value SylotiNagriScript
+ \value SoraSompengScript Since Qt 5.1
+ \value SundaneseScript Since Qt 5.1
+ \value SylotiNagriScript Since Qt 5.1
\value SyriacScript
- \value TagalogScript
- \value TagbanwaScript
- \value TaiLeScript
- \value TaiVietScript
- \value TakriScript
+ \value TagalogScript Since Qt 5.1
+ \value TagbanwaScript Since Qt 5.1
+ \value TaiLeScript Since Qt 5.1
+ \value TaiVietScript Since Qt 5.1
+ \value TakriScript Since Qt 5.1
\value TamilScript
\value TangutScript Since Qt 5.7
\value TeluguScript
@@ -912,12 +916,13 @@
\value TibetanScript
\value TifinaghScript
\value TirhutaScript Since Qt 5.5
- \value TraditionalHanScript same as TraditionalChineseScript
\value TraditionalChineseScript same as TraditionalHanScript
- \value UgariticScript
+ \value TraditionalHanScript same as TraditionalChineseScript
+ \value UgariticScript Since Qt 5.1
\value VaiScript
\value VarangKshitiScript Since Qt 5.5
\value YiScript
+
\omitvalue LastScript
\sa script(), scriptToString(), languageToString()
diff --git a/src/corelib/tools/qlocale_data_p.h b/src/corelib/tools/qlocale_data_p.h
index 507afdcecd..58e71e1dcc 100644
--- a/src/corelib/tools/qlocale_data_p.h
+++ b/src/corelib/tools/qlocale_data_p.h
@@ -77,7 +77,7 @@ static const int ImperialMeasurementSystemsCount =
// GENERATED PART STARTS HERE
/*
- This part of the file was generated on 2018-10-19 from the
+ This part of the file was generated on 2018-11-08 from the
Common Locale Data Repository v34
http://www.unicode.org/cldr/
@@ -122,6 +122,7 @@ static const QLocaleId likely_subtags[] = {
{ 195, 0, 0 }, { 195, 7, 239 }, // bem -> bem_Latn_ZM
{ 186, 0, 0 }, { 186, 7, 210 }, // bez -> bez_Latn_TZ
{ 20, 0, 0 }, { 20, 2, 33 }, // bg -> bg_Cyrl_BG
+ { 364, 0, 0 }, { 364, 1, 163 }, // bgn -> bgn_Arab_PK
{ 343, 0, 0 }, { 343, 13, 100 }, // bho -> bho_Deva_IN
{ 18, 0, 0 }, { 18, 7, 229 }, // bi -> bi_Latn_VU
{ 270, 0, 0 }, { 270, 7, 170 }, // bku -> bku_Latn_PH
@@ -224,10 +225,12 @@ static const QLocaleId likely_subtags[] = {
{ 168, 0, 0 }, { 168, 34, 44 }, // ii -> ii_Yiii_CN
{ 56, 0, 0 }, { 56, 7, 225 }, // ik -> ik_Latn_US
{ 281, 0, 0 }, { 281, 2, 178 }, // inh -> inh_Cyrl_RU
+ { 360, 0, 0 }, { 360, 7, 260 }, // io -> io_Latn_001
{ 51, 0, 0 }, { 51, 7, 99 }, // is -> is_Latn_IS
{ 58, 0, 0 }, { 58, 7, 106 }, // it -> it_Latn_IT
{ 55, 0, 0 }, { 55, 44, 38 }, // iu -> iu_Cans_CA
{ 59, 0, 0 }, { 59, 19, 108 }, // ja -> ja_Jpan_JP
+ { 361, 0, 0 }, { 361, 7, 260 }, // jbo -> jbo_Latn_001
{ 257, 0, 0 }, { 257, 7, 37 }, // jgo -> jgo_Latn_CM
{ 200, 0, 0 }, { 200, 7, 210 }, // jmc -> jmc_Latn_TZ
{ 60, 0, 0 }, { 60, 7, 101 }, // jv -> jv_Latn_ID
@@ -385,10 +388,12 @@ static const QLocaleId likely_subtags[] = {
{ 305, 0, 0 }, { 305, 90, 100 }, // saz -> saz_Saur_IN
{ 249, 0, 0 }, { 249, 7, 210 }, // sbp -> sbp_Latn_TZ
{ 115, 0, 0 }, { 115, 7, 106 }, // sc -> sc_Latn_IT
+ { 362, 0, 0 }, { 362, 7, 106 }, // scn -> scn_Latn_IT
{ 105, 0, 0 }, { 105, 1, 163 }, // sd -> sd_Arab_PK
{ 105, 13, 0 }, { 105, 13, 100 }, // sd_Deva -> sd_Deva_IN
{ 105, 111, 0 }, { 105, 111, 100 }, // sd_Khoj -> sd_Khoj_IN
{ 105, 125, 0 }, { 105, 125, 100 }, // sd_Sind -> sd_Sind_IN
+ { 363, 0, 0 }, { 363, 1, 102 }, // sdh -> sdh_Arab_IR
{ 173, 0, 0 }, { 173, 7, 161 }, // se -> se_Latn_NO
{ 180, 0, 0 }, { 180, 7, 146 }, // seh -> seh_Latn_MZ
{ 213, 0, 0 }, { 213, 7, 132 }, // ses -> ses_Latn_ML
@@ -1252,6 +1257,11 @@ static const quint16 locale_index[] = {
574, // Cantonese
0, // Osage
0, // Tangut
+ 576, // Ido
+ 577, // Lojban
+ 578, // Sicilian
+ 579, // Southern Kurdish
+ 580, // Western Balochi
0 // trailing 0
};
@@ -1592,13 +1602,13 @@ static const QLocaleData locale_data[] = {
{ 98, 7, 41, 44, 46, 59, 37, 48, 45, 43, 101, 171, 187, 8220, 8221, 0,6 , 0,6 , 0,6 , 0,6 , 415,8 , 97,16 , 37,5 , 8,10 , 16581,48 , 16629,91 , 16720,24 , 16581,48 , 16629,91 , 16720,24 , 8692,28 , 8720,66 , 8786,14 , 8692,28 , 8720,66 , 8786,14 , 226,2 , 216,2 , 45,4 , 5,17 , 22,23 , {88,65,70}, 32,4 , 11499,25 , 4,4 , 36,5 , 3506,5 , 3511,22 , 0, 0, 1, 6, 7 }, // Sango/Latin/Central African Republic
{ 99, 13, 100, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 0,6 , 0,6 , 53,10 , 63,17 , 37,5 , 8,10 , 368,48 , 368,48 , 158,27 , 368,48 , 368,48 , 158,27 , 0,28 , 0,28 , 85,14 , 0,28 , 0,28 , 85,14 , 0,2 , 0,2 , 45,4 , 5,17 , 22,23 , {73,78,82}, 121,1 , 0,7 , 8,5 , 4,0 , 0,0 , 0,0 , 2, 1, 7, 7, 7 }, // Sanskrit/Devanagari/India
{ 100, 2, 243, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 116,7 , 116,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 16744,48 , 16792,81 , 12698,24 , 16744,48 , 16792,81 , 12698,24 , 8800,28 , 8828,52 , 8880,14 , 8800,28 , 8828,52 , 8880,14 , 228,9 , 218,8 , 803,7 , 5,17 , 22,23 , {82,83,68}, 288,3 , 11524,58 , 13,5 , 4,0 , 3533,6 , 3539,6 , 0, 0, 1, 6, 7 }, // Serbian/Cyrillic/Serbia
- { 100, 2, 27, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 116,7 , 116,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 16873,50 , 16792,81 , 12698,24 , 16744,48 , 16792,81 , 12698,24 , 8894,26 , 8920,55 , 8880,14 , 8894,26 , 8920,55 , 8880,14 , 237,11 , 218,8 , 803,7 , 5,17 , 22,23 , {66,65,77}, 291,2 , 11582,174 , 13,5 , 4,0 , 3533,6 , 3545,19 , 2, 1, 1, 6, 7 }, // Serbian/Cyrillic/Bosnia And Herzegowina
- { 100, 2, 242, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 116,7 , 116,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 16923,58 , 16792,81 , 12698,24 , 16923,58 , 16792,81 , 12698,24 , 8975,33 , 8920,55 , 8880,14 , 8975,33 , 8920,55 , 8880,14 , 237,11 , 218,8 , 803,7 , 5,17 , 22,23 , {69,85,82}, 14,1 , 11756,23 , 13,5 , 4,0 , 3533,6 , 3564,9 , 2, 1, 1, 6, 7 }, // Serbian/Cyrillic/Montenegro
- { 100, 2, 257, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 116,7 , 116,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 16923,58 , 16792,81 , 12698,24 , 16923,58 , 16792,81 , 12698,24 , 8975,33 , 8828,52 , 8880,14 , 8975,33 , 8828,52 , 8880,14 , 228,9 , 218,8 , 803,7 , 5,17 , 22,23 , {69,85,82}, 14,1 , 11756,23 , 13,5 , 4,0 , 3533,6 , 3573,6 , 2, 1, 1, 6, 7 }, // Serbian/Cyrillic/Kosovo
- { 100, 7, 27, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 163,7 , 163,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 16981,50 , 17031,81 , 9742,24 , 17112,48 , 17031,81 , 9742,24 , 9008,26 , 9034,57 , 2102,14 , 9008,26 , 9034,57 , 2102,14 , 248,11 , 226,8 , 296,7 , 5,17 , 22,23 , {66,65,77}, 144,2 , 11779,174 , 13,5 , 4,0 , 3579,6 , 620,19 , 2, 1, 1, 6, 7 }, // Serbian/Latin/Bosnia And Herzegowina
- { 100, 7, 242, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 163,7 , 163,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 17160,58 , 17031,81 , 9742,24 , 17160,58 , 17031,81 , 9742,24 , 9091,33 , 9034,57 , 2102,14 , 9091,33 , 9034,57 , 2102,14 , 248,11 , 226,8 , 296,7 , 5,17 , 22,23 , {69,85,82}, 14,1 , 11953,23 , 13,5 , 4,0 , 3579,6 , 3585,9 , 2, 1, 1, 6, 7 }, // Serbian/Latin/Montenegro
- { 100, 7, 243, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 163,7 , 163,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 17112,48 , 17031,81 , 9742,24 , 17112,48 , 17031,81 , 9742,24 , 9124,28 , 9152,54 , 2102,14 , 9124,28 , 9152,54 , 2102,14 , 259,9 , 226,8 , 296,7 , 5,17 , 22,23 , {82,83,68}, 288,3 , 11976,58 , 13,5 , 4,0 , 3579,6 , 3594,6 , 0, 0, 1, 6, 7 }, // Serbian/Latin/Serbia
- { 100, 7, 257, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 163,7 , 163,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 17160,58 , 17031,81 , 9742,24 , 17160,58 , 17031,81 , 9742,24 , 9091,33 , 9152,54 , 2102,14 , 9091,33 , 9152,54 , 2102,14 , 259,9 , 226,8 , 296,7 , 5,17 , 22,23 , {69,85,82}, 14,1 , 11953,23 , 13,5 , 4,0 , 3579,6 , 3600,6 , 2, 1, 1, 6, 7 }, // Serbian/Latin/Kosovo
+ { 100, 7, 27, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 163,7 , 163,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 16873,50 , 16923,81 , 9742,24 , 17004,48 , 16923,81 , 9742,24 , 8894,26 , 8920,57 , 2102,14 , 8894,26 , 8920,57 , 2102,14 , 237,11 , 226,8 , 296,7 , 5,17 , 22,23 , {66,65,77}, 144,2 , 11582,174 , 13,5 , 4,0 , 3545,6 , 620,19 , 2, 1, 1, 6, 7 }, // Serbian/Latin/Bosnia And Herzegowina
+ { 100, 7, 242, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 163,7 , 163,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 17052,58 , 16923,81 , 9742,24 , 17052,58 , 16923,81 , 9742,24 , 8977,33 , 8920,57 , 2102,14 , 8977,33 , 8920,57 , 2102,14 , 237,11 , 226,8 , 296,7 , 5,17 , 22,23 , {69,85,82}, 14,1 , 11756,23 , 13,5 , 4,0 , 3545,6 , 3551,9 , 2, 1, 1, 6, 7 }, // Serbian/Latin/Montenegro
+ { 100, 7, 243, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 163,7 , 163,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 17004,48 , 16923,81 , 9742,24 , 17004,48 , 16923,81 , 9742,24 , 9010,28 , 9038,54 , 2102,14 , 9010,28 , 9038,54 , 2102,14 , 248,9 , 226,8 , 296,7 , 5,17 , 22,23 , {82,83,68}, 288,3 , 11779,58 , 13,5 , 4,0 , 3545,6 , 3560,6 , 0, 0, 1, 6, 7 }, // Serbian/Latin/Serbia
+ { 100, 2, 27, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 116,7 , 116,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 17110,50 , 16792,81 , 12698,24 , 16744,48 , 16792,81 , 12698,24 , 9092,26 , 9118,55 , 8880,14 , 9092,26 , 9118,55 , 8880,14 , 257,11 , 218,8 , 803,7 , 5,17 , 22,23 , {66,65,77}, 291,2 , 11837,174 , 13,5 , 4,0 , 3533,6 , 3566,19 , 2, 1, 1, 6, 7 }, // Serbian/Cyrillic/Bosnia And Herzegowina
+ { 100, 2, 242, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 116,7 , 116,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 17160,58 , 16792,81 , 12698,24 , 17160,58 , 16792,81 , 12698,24 , 9173,33 , 9118,55 , 8880,14 , 9173,33 , 9118,55 , 8880,14 , 257,11 , 218,8 , 803,7 , 5,17 , 22,23 , {69,85,82}, 14,1 , 12011,23 , 13,5 , 4,0 , 3533,6 , 3585,9 , 2, 1, 1, 6, 7 }, // Serbian/Cyrillic/Montenegro
+ { 100, 2, 257, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 116,7 , 116,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 17160,58 , 16792,81 , 12698,24 , 17160,58 , 16792,81 , 12698,24 , 9173,33 , 8828,52 , 8880,14 , 9173,33 , 8828,52 , 8880,14 , 228,9 , 218,8 , 803,7 , 5,17 , 22,23 , {69,85,82}, 14,1 , 12011,23 , 13,5 , 4,0 , 3533,6 , 3594,6 , 2, 1, 1, 6, 7 }, // Serbian/Cyrillic/Kosovo
+ { 100, 7, 257, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8216, 8216, 0,6 , 0,6 , 163,7 , 163,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 17052,58 , 16923,81 , 9742,24 , 17052,58 , 16923,81 , 9742,24 , 8977,33 , 9038,54 , 2102,14 , 8977,33 , 9038,54 , 2102,14 , 248,9 , 226,8 , 296,7 , 5,17 , 22,23 , {69,85,82}, 14,1 , 11756,23 , 13,5 , 4,0 , 3545,6 , 3600,6 , 2, 1, 1, 6, 7 }, // Serbian/Latin/Kosovo
{ 101, 2, 81, 44, 160, 59, 37, 48, 45, 43, 101, 171, 187, 8222, 8220, 0,6 , 0,6 , 610,9 , 610,9 , 156,8 , 1094,23 , 37,5 , 8,10 , 17218,63 , 17281,82 , 11058,24 , 17363,60 , 17423,86 , 11058,24 , 9206,28 , 9234,61 , 9295,14 , 9309,28 , 9337,61 , 9295,14 , 268,15 , 234,15 , 45,4 , 5,17 , 22,23 , {71,69,76}, 228,1 , 12034,17 , 8,5 , 4,0 , 3606,4 , 3610,11 , 2, 1, 1, 6, 7 }, // Ossetic/Cyrillic/Georgia
{ 101, 2, 178, 44, 160, 59, 37, 48, 45, 43, 101, 171, 187, 8222, 8220, 0,6 , 0,6 , 610,9 , 610,9 , 156,8 , 1094,23 , 37,5 , 8,10 , 17218,63 , 17281,82 , 11058,24 , 17363,60 , 17423,86 , 11058,24 , 9206,28 , 9234,61 , 9295,14 , 9309,28 , 9337,61 , 9295,14 , 268,15 , 234,15 , 45,4 , 5,17 , 22,23 , {82,85,66}, 123,1 , 12051,17 , 8,5 , 4,0 , 3606,4 , 3621,6 , 2, 1, 1, 6, 7 }, // Ossetic/Cyrillic/Russia
{ 102, 7, 195, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 0,6 , 0,6 , 53,10 , 63,17 , 37,5 , 8,10 , 368,48 , 368,48 , 158,27 , 368,48 , 368,48 , 158,27 , 0,28 , 0,28 , 85,14 , 0,28 , 0,28 , 85,14 , 0,2 , 0,2 , 45,4 , 5,17 , 22,23 , {90,65,82}, 5,1 , 0,7 , 8,5 , 4,0 , 0,0 , 0,0 , 2, 1, 7, 6, 7 }, // Southern Sotho/Latin/South Africa
@@ -1684,7 +1694,7 @@ static const QLocaleData locale_data[] = {
{ 140, 7, 195, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 842,9 , 851,8 , 547,6 , 35,18 , 37,5 , 8,10 , 23839,48 , 23887,91 , 134,24 , 23839,48 , 23887,91 , 23978,24 , 12558,28 , 12586,74 , 12660,14 , 12558,28 , 12586,74 , 12660,14 , 0,2 , 0,2 , 0,5 , 5,17 , 22,23 , {90,65,82}, 5,1 , 14929,67 , 4,4 , 4,0 , 4446,7 , 4453,17 , 2, 1, 7, 6, 7 }, // Zulu/Latin/South Africa
{ 141, 7, 161, 44, 160, 59, 37, 48, 8722, 43, 101, 171, 187, 8216, 8217, 0,6 , 0,6 , 192,8 , 192,8 , 495,10 , 478,17 , 37,5 , 441,16 , 5656,48 , 14503,83 , 134,24 , 24002,59 , 14503,83 , 134,24 , 12674,28 , 12702,51 , 2293,14 , 12753,28 , 12702,51 , 2293,14 , 414,9 , 380,11 , 45,4 , 5,17 , 22,23 , {78,79,75}, 190,2 , 9840,44 , 13,5 , 4,0 , 4470,7 , 4477,5 , 2, 0, 1, 6, 7 }, // Norwegian Nynorsk/Latin/Norway
{ 142, 7, 27, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8221, 8216, 8217, 0,6 , 0,6 , 163,7 , 163,7 , 1507,11 , 450,19 , 37,5 , 8,10 , 8336,48 , 24061,83 , 9742,24 , 8336,48 , 24061,83 , 9742,24 , 2016,28 , 2044,58 , 2102,14 , 2016,28 , 2044,58 , 2116,14 , 423,10 , 391,7 , 296,7 , 5,17 , 22,23 , {66,65,77}, 144,2 , 14996,170 , 13,5 , 4,0 , 4482,8 , 620,19 , 2, 1, 1, 6, 7 }, // Bosnian/Latin/Bosnia And Herzegowina
- { 142, 2, 27, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8218, 8216, 0,6 , 0,6 , 116,7 , 116,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 24144,48 , 24192,83 , 12698,24 , 24144,48 , 24192,83 , 12698,24 , 12781,28 , 12809,56 , 8880,14 , 12781,28 , 12809,56 , 8880,14 , 228,9 , 398,7 , 45,4 , 5,17 , 22,23 , {66,65,77}, 291,2 , 15166,151 , 13,5 , 4,0 , 4490,8 , 3545,19 , 2, 1, 1, 6, 7 }, // Bosnian/Cyrillic/Bosnia And Herzegowina
+ { 142, 2, 27, 44, 46, 59, 37, 48, 45, 43, 101, 8222, 8220, 8218, 8216, 0,6 , 0,6 , 116,7 , 116,7 , 1067,7 , 1074,20 , 37,5 , 8,10 , 24144,48 , 24192,83 , 12698,24 , 24144,48 , 24192,83 , 12698,24 , 12781,28 , 12809,56 , 8880,14 , 12781,28 , 12809,56 , 8880,14 , 228,9 , 398,7 , 45,4 , 5,17 , 22,23 , {66,65,77}, 291,2 , 15166,151 , 13,5 , 4,0 , 4490,8 , 3566,19 , 2, 1, 1, 6, 7 }, // Bosnian/Cyrillic/Bosnia And Herzegowina
{ 143, 29, 131, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 0,6 , 0,6 , 53,10 , 63,17 , 37,5 , 8,10 , 368,48 , 368,48 , 158,27 , 368,48 , 368,48 , 158,27 , 0,28 , 0,28 , 85,14 , 0,28 , 0,28 , 85,14 , 0,2 , 0,2 , 45,4 , 5,17 , 22,23 , {77,86,82}, 0,0 , 0,7 , 8,5 , 4,0 , 0,0 , 0,0 , 2, 1, 5, 6, 7 }, // Divehi/Thaana/Maldives
{ 144, 7, 251, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 0,6 , 0,6 , 27,8 , 80,17 , 37,5 , 8,10 , 24275,102 , 24377,140 , 158,27 , 24275,102 , 24377,140 , 158,27 , 12865,30 , 12895,57 , 85,14 , 12865,30 , 12895,57 , 85,14 , 64,4 , 61,4 , 45,4 , 5,17 , 22,23 , {71,66,80}, 119,1 , 0,7 , 4,4 , 4,0 , 4498,5 , 4503,12 , 2, 1, 1, 6, 7 }, // Manx/Latin/Isle Of Man
{ 145, 7, 224, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 0,6 , 0,6 , 119,10 , 97,16 , 37,5 , 8,10 , 24517,46 , 24563,130 , 158,27 , 24517,46 , 24563,130 , 158,27 , 12952,28 , 12980,61 , 85,14 , 12952,28 , 12980,61 , 85,14 , 64,4 , 61,4 , 45,4 , 5,17 , 22,23 , {71,66,80}, 119,1 , 0,7 , 4,4 , 4,0 , 4515,8 , 4523,14 , 2, 1, 1, 6, 7 }, // Cornish/Latin/United Kingdom
@@ -1833,6 +1843,11 @@ static const QLocaleData locale_data[] = {
{ 349, 1, 103, 1643, 1644, 1563, 1642, 1776, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 0,6 , 0,6 , 53,10 , 63,17 , 18,7 , 25,12 , 39219,77 , 39219,77 , 158,27 , 39219,77 , 39219,77 , 158,27 , 0,28 , 0,28 , 85,14 , 0,28 , 0,28 , 85,14 , 0,2 , 0,2 , 45,4 , 5,17 , 22,23 , {73,81,68}, 44,5 , 0,7 , 8,5 , 4,0 , 5865,11 , 0,0 , 0, 0, 6, 5, 6 }, // Northern Luri/Arabic/Iraq
{ 357, 6, 97, 46, 44, 59, 37, 48, 45, 43, 101, 12300, 12301, 12302, 12303, 170,5 , 170,5 , 1010,5 , 1010,5 , 394,8 , 423,14 , 198,6 , 215,13 , 4423,39 , 4423,39 , 158,27 , 4423,39 , 4423,39 , 158,27 , 1953,28 , 1953,28 , 1981,14 , 1953,28 , 1953,28 , 1981,14 , 58,2 , 55,2 , 45,4 , 5,17 , 22,23 , {72,75,68}, 134,3 , 17327,11 , 4,4 , 4,0 , 5876,2 , 5878,14 , 2, 1, 7, 6, 7 }, // Cantonese/Traditional Han/Hong Kong
{ 357, 5, 44, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 170,5 , 170,5 , 1010,5 , 1010,5 , 394,8 , 402,13 , 198,6 , 204,11 , 4423,39 , 4462,38 , 158,27 , 4423,39 , 4462,38 , 158,27 , 1932,21 , 1953,28 , 1981,14 , 1932,21 , 1953,28 , 1981,14 , 58,2 , 55,2 , 45,4 , 5,17 , 22,23 , {67,78,89}, 133,1 , 3122,13 , 4,4 , 4,0 , 5892,2 , 5894,7 , 2, 1, 7, 6, 7 }, // Cantonese/Simplified Han/China
+ { 360, 7, 260, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 0,6 , 0,6 , 53,10 , 63,17 , 37,5 , 8,10 , 368,48 , 368,48 , 158,27 , 368,48 , 368,48 , 158,27 , 0,28 , 0,28 , 85,14 , 0,28 , 0,28 , 85,14 , 0,2 , 0,2 , 45,4 , 5,17 , 22,23 , {0,0,0}, 0,0 , 2586,0 , 8,5 , 4,0 , 0,0 , 0,0 , 2, 1, 1, 6, 7 }, // Ido/Latin/World
+ { 361, 7, 260, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 0,6 , 0,6 , 53,10 , 63,17 , 37,5 , 8,10 , 368,48 , 368,48 , 158,27 , 368,48 , 368,48 , 158,27 , 0,28 , 0,28 , 85,14 , 0,28 , 0,28 , 85,14 , 0,2 , 0,2 , 45,4 , 5,17 , 22,23 , {0,0,0}, 0,0 , 2586,0 , 8,5 , 4,0 , 0,0 , 0,0 , 2, 1, 1, 6, 7 }, // Lojban/Latin/World
+ { 362, 7, 106, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 0,6 , 0,6 , 53,10 , 63,17 , 37,5 , 8,10 , 368,48 , 368,48 , 158,27 , 368,48 , 368,48 , 158,27 , 0,28 , 0,28 , 85,14 , 0,28 , 0,28 , 85,14 , 0,2 , 0,2 , 45,4 , 5,17 , 22,23 , {69,85,82}, 14,1 , 0,7 , 8,5 , 4,0 , 0,0 , 0,0 , 2, 1, 1, 6, 7 }, // Sicilian/Latin/Italy
+ { 363, 1, 102, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 0,6 , 0,6 , 53,10 , 63,17 , 37,5 , 8,10 , 368,48 , 368,48 , 158,27 , 368,48 , 368,48 , 158,27 , 0,28 , 0,28 , 85,14 , 0,28 , 0,28 , 85,14 , 0,2 , 0,2 , 45,4 , 5,17 , 22,23 , {73,82,82}, 0,0 , 0,7 , 8,5 , 4,0 , 0,0 , 0,0 , 0, 0, 6, 5, 5 }, // Southern Kurdish/Arabic/Iran
+ { 364, 1, 163, 46, 44, 59, 37, 48, 45, 43, 101, 8220, 8221, 8216, 8217, 0,6 , 0,6 , 0,6 , 0,6 , 53,10 , 63,17 , 37,5 , 8,10 , 368,48 , 368,48 , 158,27 , 368,48 , 368,48 , 158,27 , 0,28 , 0,28 , 85,14 , 0,28 , 0,28 , 85,14 , 0,2 , 0,2 , 45,4 , 5,17 , 22,23 , {80,75,82}, 176,2 , 0,7 , 8,5 , 4,0 , 0,0 , 0,0 , 2, 0, 7, 6, 7 }, // Western Balochi/Arabic/Pakistan
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, {0,0,0}, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0, 0, 0, 0, 0 } // trailing 0s
};
@@ -2860,24 +2875,24 @@ static const ushort months_data[] = {
0x435, 0x431, 0x440, 0x443, 0x430, 0x440, 0x3b, 0x43c, 0x430, 0x440, 0x442, 0x3b, 0x430, 0x43f, 0x440, 0x438, 0x43b, 0x3b, 0x43c, 0x430,
0x458, 0x3b, 0x458, 0x443, 0x43d, 0x3b, 0x458, 0x443, 0x43b, 0x3b, 0x430, 0x432, 0x433, 0x443, 0x441, 0x442, 0x3b, 0x441, 0x435, 0x43f,
0x442, 0x435, 0x43c, 0x431, 0x430, 0x440, 0x3b, 0x43e, 0x43a, 0x442, 0x43e, 0x431, 0x430, 0x440, 0x3b, 0x43d, 0x43e, 0x432, 0x435, 0x43c,
-0x431, 0x430, 0x440, 0x3b, 0x434, 0x435, 0x446, 0x435, 0x43c, 0x431, 0x430, 0x440, 0x3b, 0x458, 0x430, 0x43d, 0x3b, 0x444, 0x435, 0x431,
-0x3b, 0x43c, 0x430, 0x440, 0x442, 0x3b, 0x430, 0x43f, 0x440, 0x3b, 0x43c, 0x430, 0x458, 0x3b, 0x458, 0x443, 0x43d, 0x3b, 0x458, 0x443,
-0x43b, 0x3b, 0x430, 0x432, 0x433, 0x3b, 0x441, 0x435, 0x43f, 0x442, 0x3b, 0x43e, 0x43a, 0x442, 0x3b, 0x43d, 0x43e, 0x432, 0x3b, 0x434,
-0x435, 0x446, 0x3b, 0x458, 0x430, 0x43d, 0x2e, 0x3b, 0x444, 0x435, 0x431, 0x2e, 0x3b, 0x43c, 0x430, 0x440, 0x442, 0x3b, 0x430, 0x43f,
-0x440, 0x2e, 0x3b, 0x43c, 0x430, 0x458, 0x3b, 0x458, 0x443, 0x43d, 0x3b, 0x458, 0x443, 0x43b, 0x3b, 0x430, 0x432, 0x433, 0x2e, 0x3b,
-0x441, 0x435, 0x43f, 0x442, 0x2e, 0x3b, 0x43e, 0x43a, 0x442, 0x2e, 0x3b, 0x43d, 0x43e, 0x432, 0x2e, 0x3b, 0x434, 0x435, 0x446, 0x2e,
-0x3b, 0x6a, 0x61, 0x6e, 0x3b, 0x66, 0x65, 0x62, 0x3b, 0x6d, 0x61, 0x72, 0x74, 0x3b, 0x61, 0x70, 0x72, 0x3b, 0x6d, 0x61,
-0x6a, 0x3b, 0x6a, 0x75, 0x6e, 0x3b, 0x6a, 0x75, 0x6c, 0x3b, 0x61, 0x76, 0x67, 0x3b, 0x73, 0x65, 0x70, 0x74, 0x3b, 0x6f,
-0x6b, 0x74, 0x3b, 0x6e, 0x6f, 0x76, 0x3b, 0x64, 0x65, 0x63, 0x3b, 0x6a, 0x61, 0x6e, 0x75, 0x61, 0x72, 0x3b, 0x66, 0x65,
-0x62, 0x72, 0x75, 0x61, 0x72, 0x3b, 0x6d, 0x61, 0x72, 0x74, 0x3b, 0x61, 0x70, 0x72, 0x69, 0x6c, 0x3b, 0x6d, 0x61, 0x6a,
-0x3b, 0x6a, 0x75, 0x6e, 0x3b, 0x6a, 0x75, 0x6c, 0x3b, 0x61, 0x76, 0x67, 0x75, 0x73, 0x74, 0x3b, 0x73, 0x65, 0x70, 0x74,
-0x65, 0x6d, 0x62, 0x61, 0x72, 0x3b, 0x6f, 0x6b, 0x74, 0x6f, 0x62, 0x61, 0x72, 0x3b, 0x6e, 0x6f, 0x76, 0x65, 0x6d, 0x62,
-0x61, 0x72, 0x3b, 0x64, 0x65, 0x63, 0x65, 0x6d, 0x62, 0x61, 0x72, 0x3b, 0x6a, 0x61, 0x6e, 0x3b, 0x66, 0x65, 0x62, 0x3b,
-0x6d, 0x61, 0x72, 0x3b, 0x61, 0x70, 0x72, 0x3b, 0x6d, 0x61, 0x6a, 0x3b, 0x6a, 0x75, 0x6e, 0x3b, 0x6a, 0x75, 0x6c, 0x3b,
-0x61, 0x76, 0x67, 0x3b, 0x73, 0x65, 0x70, 0x3b, 0x6f, 0x6b, 0x74, 0x3b, 0x6e, 0x6f, 0x76, 0x3b, 0x64, 0x65, 0x63, 0x3b,
-0x6a, 0x61, 0x6e, 0x2e, 0x3b, 0x66, 0x65, 0x62, 0x2e, 0x3b, 0x6d, 0x61, 0x72, 0x74, 0x3b, 0x61, 0x70, 0x72, 0x2e, 0x3b,
-0x6d, 0x61, 0x6a, 0x3b, 0x6a, 0x75, 0x6e, 0x3b, 0x6a, 0x75, 0x6c, 0x3b, 0x61, 0x76, 0x67, 0x2e, 0x3b, 0x73, 0x65, 0x70,
-0x74, 0x2e, 0x3b, 0x6f, 0x6b, 0x74, 0x2e, 0x3b, 0x6e, 0x6f, 0x76, 0x2e, 0x3b, 0x64, 0x65, 0x63, 0x2e, 0x3b, 0x42f, 0x43d,
+0x431, 0x430, 0x440, 0x3b, 0x434, 0x435, 0x446, 0x435, 0x43c, 0x431, 0x430, 0x440, 0x3b, 0x6a, 0x61, 0x6e, 0x3b, 0x66, 0x65, 0x62,
+0x3b, 0x6d, 0x61, 0x72, 0x74, 0x3b, 0x61, 0x70, 0x72, 0x3b, 0x6d, 0x61, 0x6a, 0x3b, 0x6a, 0x75, 0x6e, 0x3b, 0x6a, 0x75,
+0x6c, 0x3b, 0x61, 0x76, 0x67, 0x3b, 0x73, 0x65, 0x70, 0x74, 0x3b, 0x6f, 0x6b, 0x74, 0x3b, 0x6e, 0x6f, 0x76, 0x3b, 0x64,
+0x65, 0x63, 0x3b, 0x6a, 0x61, 0x6e, 0x75, 0x61, 0x72, 0x3b, 0x66, 0x65, 0x62, 0x72, 0x75, 0x61, 0x72, 0x3b, 0x6d, 0x61,
+0x72, 0x74, 0x3b, 0x61, 0x70, 0x72, 0x69, 0x6c, 0x3b, 0x6d, 0x61, 0x6a, 0x3b, 0x6a, 0x75, 0x6e, 0x3b, 0x6a, 0x75, 0x6c,
+0x3b, 0x61, 0x76, 0x67, 0x75, 0x73, 0x74, 0x3b, 0x73, 0x65, 0x70, 0x74, 0x65, 0x6d, 0x62, 0x61, 0x72, 0x3b, 0x6f, 0x6b,
+0x74, 0x6f, 0x62, 0x61, 0x72, 0x3b, 0x6e, 0x6f, 0x76, 0x65, 0x6d, 0x62, 0x61, 0x72, 0x3b, 0x64, 0x65, 0x63, 0x65, 0x6d,
+0x62, 0x61, 0x72, 0x3b, 0x6a, 0x61, 0x6e, 0x3b, 0x66, 0x65, 0x62, 0x3b, 0x6d, 0x61, 0x72, 0x3b, 0x61, 0x70, 0x72, 0x3b,
+0x6d, 0x61, 0x6a, 0x3b, 0x6a, 0x75, 0x6e, 0x3b, 0x6a, 0x75, 0x6c, 0x3b, 0x61, 0x76, 0x67, 0x3b, 0x73, 0x65, 0x70, 0x3b,
+0x6f, 0x6b, 0x74, 0x3b, 0x6e, 0x6f, 0x76, 0x3b, 0x64, 0x65, 0x63, 0x3b, 0x6a, 0x61, 0x6e, 0x2e, 0x3b, 0x66, 0x65, 0x62,
+0x2e, 0x3b, 0x6d, 0x61, 0x72, 0x74, 0x3b, 0x61, 0x70, 0x72, 0x2e, 0x3b, 0x6d, 0x61, 0x6a, 0x3b, 0x6a, 0x75, 0x6e, 0x3b,
+0x6a, 0x75, 0x6c, 0x3b, 0x61, 0x76, 0x67, 0x2e, 0x3b, 0x73, 0x65, 0x70, 0x74, 0x2e, 0x3b, 0x6f, 0x6b, 0x74, 0x2e, 0x3b,
+0x6e, 0x6f, 0x76, 0x2e, 0x3b, 0x64, 0x65, 0x63, 0x2e, 0x3b, 0x458, 0x430, 0x43d, 0x3b, 0x444, 0x435, 0x431, 0x3b, 0x43c, 0x430,
+0x440, 0x442, 0x3b, 0x430, 0x43f, 0x440, 0x3b, 0x43c, 0x430, 0x458, 0x3b, 0x458, 0x443, 0x43d, 0x3b, 0x458, 0x443, 0x43b, 0x3b, 0x430,
+0x432, 0x433, 0x3b, 0x441, 0x435, 0x43f, 0x442, 0x3b, 0x43e, 0x43a, 0x442, 0x3b, 0x43d, 0x43e, 0x432, 0x3b, 0x434, 0x435, 0x446, 0x3b,
+0x458, 0x430, 0x43d, 0x2e, 0x3b, 0x444, 0x435, 0x431, 0x2e, 0x3b, 0x43c, 0x430, 0x440, 0x442, 0x3b, 0x430, 0x43f, 0x440, 0x2e, 0x3b,
+0x43c, 0x430, 0x458, 0x3b, 0x458, 0x443, 0x43d, 0x3b, 0x458, 0x443, 0x43b, 0x3b, 0x430, 0x432, 0x433, 0x2e, 0x3b, 0x441, 0x435, 0x43f,
+0x442, 0x2e, 0x3b, 0x43e, 0x43a, 0x442, 0x2e, 0x3b, 0x43d, 0x43e, 0x432, 0x2e, 0x3b, 0x434, 0x435, 0x446, 0x2e, 0x3b, 0x42f, 0x43d,
0x432, 0x2e, 0x3b, 0x424, 0x435, 0x432, 0x440, 0x2e, 0x3b, 0x41c, 0x430, 0x440, 0x442, 0x2e, 0x3b, 0x410, 0x43f, 0x440, 0x2e, 0x3b,
0x41c, 0x430, 0x439, 0x3b, 0x418, 0x44e, 0x43d, 0x44c, 0x3b, 0x418, 0x44e, 0x43b, 0x44c, 0x3b, 0x410, 0x432, 0x433, 0x2e, 0x3b, 0x421,
0x435, 0x43d, 0x442, 0x2e, 0x3b, 0x41e, 0x43a, 0x442, 0x2e, 0x3b, 0x41d, 0x43e, 0x44f, 0x431, 0x2e, 0x3b, 0x414, 0x435, 0x43a, 0x2e,
@@ -4429,23 +4444,23 @@ static const ushort days_data[] = {
0x43f, 0x435, 0x442, 0x3b, 0x441, 0x443, 0x431, 0x3b, 0x43d, 0x435, 0x434, 0x435, 0x459, 0x430, 0x3b, 0x43f, 0x43e, 0x43d, 0x435, 0x434,
0x435, 0x459, 0x430, 0x43a, 0x3b, 0x443, 0x442, 0x43e, 0x440, 0x430, 0x43a, 0x3b, 0x441, 0x440, 0x435, 0x434, 0x430, 0x3b, 0x447, 0x435,
0x442, 0x432, 0x440, 0x442, 0x430, 0x43a, 0x3b, 0x43f, 0x435, 0x442, 0x430, 0x43a, 0x3b, 0x441, 0x443, 0x431, 0x43e, 0x442, 0x430, 0x3b,
-0x43d, 0x3b, 0x43f, 0x3b, 0x443, 0x3b, 0x441, 0x3b, 0x447, 0x3b, 0x43f, 0x3b, 0x441, 0x3b, 0x43d, 0x435, 0x434, 0x3b, 0x43f, 0x43e,
-0x43d, 0x3b, 0x443, 0x442, 0x3b, 0x441, 0x440, 0x3b, 0x447, 0x435, 0x442, 0x3b, 0x43f, 0x435, 0x442, 0x3b, 0x441, 0x443, 0x431, 0x3b,
-0x43d, 0x435, 0x434, 0x458, 0x435, 0x459, 0x430, 0x3b, 0x43f, 0x43e, 0x43d, 0x435, 0x434, 0x435, 0x459, 0x430, 0x43a, 0x3b, 0x443, 0x442,
-0x43e, 0x440, 0x430, 0x43a, 0x3b, 0x441, 0x440, 0x438, 0x458, 0x435, 0x434, 0x430, 0x3b, 0x447, 0x435, 0x442, 0x432, 0x440, 0x442, 0x430,
-0x43a, 0x3b, 0x43f, 0x435, 0x442, 0x430, 0x43a, 0x3b, 0x441, 0x443, 0x431, 0x43e, 0x442, 0x430, 0x3b, 0x43d, 0x435, 0x434, 0x2e, 0x3b,
-0x43f, 0x43e, 0x43d, 0x2e, 0x3b, 0x443, 0x442, 0x2e, 0x3b, 0x441, 0x440, 0x2e, 0x3b, 0x447, 0x435, 0x442, 0x2e, 0x3b, 0x43f, 0x435,
-0x442, 0x2e, 0x3b, 0x441, 0x443, 0x431, 0x2e, 0x3b, 0x6e, 0x65, 0x64, 0x3b, 0x70, 0x6f, 0x6e, 0x3b, 0x75, 0x74, 0x3b, 0x73,
-0x72, 0x3b, 0x10d, 0x65, 0x74, 0x3b, 0x70, 0x65, 0x74, 0x3b, 0x73, 0x75, 0x62, 0x3b, 0x6e, 0x65, 0x64, 0x6a, 0x65, 0x6c,
-0x6a, 0x61, 0x3b, 0x70, 0x6f, 0x6e, 0x65, 0x64, 0x65, 0x6c, 0x6a, 0x61, 0x6b, 0x3b, 0x75, 0x74, 0x6f, 0x72, 0x61, 0x6b,
-0x3b, 0x73, 0x72, 0x69, 0x6a, 0x65, 0x64, 0x61, 0x3b, 0x10d, 0x65, 0x74, 0x76, 0x72, 0x74, 0x61, 0x6b, 0x3b, 0x70, 0x65,
-0x74, 0x61, 0x6b, 0x3b, 0x73, 0x75, 0x62, 0x6f, 0x74, 0x61, 0x3b, 0x6e, 0x65, 0x64, 0x2e, 0x3b, 0x70, 0x6f, 0x6e, 0x2e,
-0x3b, 0x75, 0x74, 0x2e, 0x3b, 0x73, 0x72, 0x2e, 0x3b, 0x10d, 0x65, 0x74, 0x2e, 0x3b, 0x70, 0x65, 0x74, 0x2e, 0x3b, 0x73,
-0x75, 0x62, 0x2e, 0x3b, 0x6e, 0x65, 0x64, 0x3b, 0x70, 0x6f, 0x6e, 0x3b, 0x75, 0x74, 0x6f, 0x3b, 0x73, 0x72, 0x65, 0x3b,
-0x10d, 0x65, 0x74, 0x3b, 0x70, 0x65, 0x74, 0x3b, 0x73, 0x75, 0x62, 0x3b, 0x6e, 0x65, 0x64, 0x65, 0x6c, 0x6a, 0x61, 0x3b,
-0x70, 0x6f, 0x6e, 0x65, 0x64, 0x65, 0x6c, 0x6a, 0x61, 0x6b, 0x3b, 0x75, 0x74, 0x6f, 0x72, 0x61, 0x6b, 0x3b, 0x73, 0x72,
-0x65, 0x64, 0x61, 0x3b, 0x10d, 0x65, 0x74, 0x76, 0x72, 0x74, 0x61, 0x6b, 0x3b, 0x70, 0x65, 0x74, 0x61, 0x6b, 0x3b, 0x73,
-0x75, 0x62, 0x6f, 0x74, 0x61, 0x3b, 0x425, 0x446, 0x431, 0x3b, 0x41a, 0x440, 0x441, 0x3b, 0x414, 0x446, 0x433, 0x3b, 0x4d4, 0x440,
+0x43d, 0x3b, 0x43f, 0x3b, 0x443, 0x3b, 0x441, 0x3b, 0x447, 0x3b, 0x43f, 0x3b, 0x441, 0x3b, 0x6e, 0x65, 0x64, 0x3b, 0x70, 0x6f,
+0x6e, 0x3b, 0x75, 0x74, 0x3b, 0x73, 0x72, 0x3b, 0x10d, 0x65, 0x74, 0x3b, 0x70, 0x65, 0x74, 0x3b, 0x73, 0x75, 0x62, 0x3b,
+0x6e, 0x65, 0x64, 0x6a, 0x65, 0x6c, 0x6a, 0x61, 0x3b, 0x70, 0x6f, 0x6e, 0x65, 0x64, 0x65, 0x6c, 0x6a, 0x61, 0x6b, 0x3b,
+0x75, 0x74, 0x6f, 0x72, 0x61, 0x6b, 0x3b, 0x73, 0x72, 0x69, 0x6a, 0x65, 0x64, 0x61, 0x3b, 0x10d, 0x65, 0x74, 0x76, 0x72,
+0x74, 0x61, 0x6b, 0x3b, 0x70, 0x65, 0x74, 0x61, 0x6b, 0x3b, 0x73, 0x75, 0x62, 0x6f, 0x74, 0x61, 0x3b, 0x6e, 0x65, 0x64,
+0x2e, 0x3b, 0x70, 0x6f, 0x6e, 0x2e, 0x3b, 0x75, 0x74, 0x2e, 0x3b, 0x73, 0x72, 0x2e, 0x3b, 0x10d, 0x65, 0x74, 0x2e, 0x3b,
+0x70, 0x65, 0x74, 0x2e, 0x3b, 0x73, 0x75, 0x62, 0x2e, 0x3b, 0x6e, 0x65, 0x64, 0x3b, 0x70, 0x6f, 0x6e, 0x3b, 0x75, 0x74,
+0x6f, 0x3b, 0x73, 0x72, 0x65, 0x3b, 0x10d, 0x65, 0x74, 0x3b, 0x70, 0x65, 0x74, 0x3b, 0x73, 0x75, 0x62, 0x3b, 0x6e, 0x65,
+0x64, 0x65, 0x6c, 0x6a, 0x61, 0x3b, 0x70, 0x6f, 0x6e, 0x65, 0x64, 0x65, 0x6c, 0x6a, 0x61, 0x6b, 0x3b, 0x75, 0x74, 0x6f,
+0x72, 0x61, 0x6b, 0x3b, 0x73, 0x72, 0x65, 0x64, 0x61, 0x3b, 0x10d, 0x65, 0x74, 0x76, 0x72, 0x74, 0x61, 0x6b, 0x3b, 0x70,
+0x65, 0x74, 0x61, 0x6b, 0x3b, 0x73, 0x75, 0x62, 0x6f, 0x74, 0x61, 0x3b, 0x43d, 0x435, 0x434, 0x3b, 0x43f, 0x43e, 0x43d, 0x3b,
+0x443, 0x442, 0x3b, 0x441, 0x440, 0x3b, 0x447, 0x435, 0x442, 0x3b, 0x43f, 0x435, 0x442, 0x3b, 0x441, 0x443, 0x431, 0x3b, 0x43d, 0x435,
+0x434, 0x458, 0x435, 0x459, 0x430, 0x3b, 0x43f, 0x43e, 0x43d, 0x435, 0x434, 0x435, 0x459, 0x430, 0x43a, 0x3b, 0x443, 0x442, 0x43e, 0x440,
+0x430, 0x43a, 0x3b, 0x441, 0x440, 0x438, 0x458, 0x435, 0x434, 0x430, 0x3b, 0x447, 0x435, 0x442, 0x432, 0x440, 0x442, 0x430, 0x43a, 0x3b,
+0x43f, 0x435, 0x442, 0x430, 0x43a, 0x3b, 0x441, 0x443, 0x431, 0x43e, 0x442, 0x430, 0x3b, 0x43d, 0x435, 0x434, 0x2e, 0x3b, 0x43f, 0x43e,
+0x43d, 0x2e, 0x3b, 0x443, 0x442, 0x2e, 0x3b, 0x441, 0x440, 0x2e, 0x3b, 0x447, 0x435, 0x442, 0x2e, 0x3b, 0x43f, 0x435, 0x442, 0x2e,
+0x3b, 0x441, 0x443, 0x431, 0x2e, 0x3b, 0x425, 0x446, 0x431, 0x3b, 0x41a, 0x440, 0x441, 0x3b, 0x414, 0x446, 0x433, 0x3b, 0x4d4, 0x440,
0x442, 0x3b, 0x426, 0x43f, 0x440, 0x3b, 0x41c, 0x440, 0x431, 0x3b, 0x421, 0x431, 0x442, 0x3b, 0x425, 0x443, 0x44b, 0x446, 0x430, 0x443,
0x431, 0x43e, 0x43d, 0x3b, 0x41a, 0x44a, 0x443, 0x44b, 0x440, 0x438, 0x441, 0x4d5, 0x440, 0x3b, 0x414, 0x44b, 0x446, 0x446, 0x4d5, 0x433,
0x3b, 0x4d4, 0x440, 0x442, 0x44b, 0x446, 0x446, 0x4d5, 0x433, 0x3b, 0x426, 0x44b, 0x43f, 0x43f, 0x4d5, 0x440, 0x4d5, 0x43c, 0x3b, 0x41c,
@@ -5138,9 +5153,9 @@ static const ushort am_data[] = {
0x101, 0x6e, 0x74, 0x254, 0x301, 0x6e, 0x67, 0x254, 0x301, 0x70, 0x72, 0x69, 0x65, 0x161, 0x70, 0x69, 0x65, 0x74, 0x43f, 0x440,
0x435, 0x442, 0x43f, 0x43b, 0x430, 0x434, 0x43d, 0x435, 0x50, 0x47, 0x92e, 0x2e, 0x92a, 0x942, 0x2e, 0x4af, 0x2e, 0x4e9, 0x2e, 0x63a,
0x2e, 0x645, 0x2e, 0x642, 0x628, 0x644, 0x200c, 0x627, 0x632, 0x638, 0x647, 0x631, 0x64, 0x61, 0x20, 0x6d, 0x61, 0x6e, 0x68, 0xe3,
-0xa2a, 0xa42, 0x2e, 0xa26, 0xa41, 0x2e, 0x4e, 0x44, 0x43f, 0x440, 0x435, 0x20, 0x43f, 0x43e, 0x434, 0x43d, 0x435, 0x43f, 0x440, 0x438,
-0x458, 0x435, 0x20, 0x43f, 0x43e, 0x434, 0x43d, 0x435, 0x70, 0x72, 0x69, 0x6a, 0x65, 0x20, 0x70, 0x6f, 0x64, 0x6e, 0x65, 0x70,
-0x72, 0x65, 0x20, 0x70, 0x6f, 0x64, 0x6e, 0x65, 0x4d5, 0x43c, 0x431, 0x438, 0x441, 0x431, 0x43e, 0x43d, 0x44b, 0x20, 0x440, 0x430,
+0xa2a, 0xa42, 0x2e, 0xa26, 0xa41, 0x2e, 0x4e, 0x44, 0x43f, 0x440, 0x435, 0x20, 0x43f, 0x43e, 0x434, 0x43d, 0x435, 0x70, 0x72, 0x69,
+0x6a, 0x65, 0x20, 0x70, 0x6f, 0x64, 0x6e, 0x65, 0x70, 0x72, 0x65, 0x20, 0x70, 0x6f, 0x64, 0x6e, 0x65, 0x43f, 0x440, 0x438,
+0x458, 0x435, 0x20, 0x43f, 0x43e, 0x434, 0x43d, 0x435, 0x4d5, 0x43c, 0x431, 0x438, 0x441, 0x431, 0x43e, 0x43d, 0x44b, 0x20, 0x440, 0x430,
0x437, 0x43c, 0x4d5, 0x635, 0x628, 0x62d, 0x60c, 0x20, 0x645, 0x646, 0x62c, 0x647, 0x646, 0x62f, 0xdb4, 0xdd9, 0x2e, 0xdc0, 0x2e, 0x73,
0x6e, 0x2e, 0x66, 0x6d, 0x43f, 0x435, 0x2e, 0x20, 0x447, 0x43e, 0x2e, 0xbae, 0xbc1, 0xbb1, 0xbcd, 0xbaa, 0xb95, 0xbb2, 0xbcd, 0xe01,
0xe48, 0xe2d, 0xe19, 0xe40, 0xe17, 0xe35, 0xe48, 0xe22, 0xe07, 0xf66, 0xf94, 0xf0b, 0xf51, 0xfb2, 0xf7c, 0xf0b, 0x1295, 0x1309, 0x1206, 0x20,
@@ -5814,29 +5829,29 @@ static const ushort currency_display_name_data[] = {
0x3b, 0x3b, 0x3b, 0x3b, 0x421, 0x440, 0x43f, 0x441, 0x43a, 0x438, 0x20, 0x434, 0x438, 0x43d, 0x430, 0x440, 0x3b, 0x3b, 0x441, 0x440,
0x43f, 0x441, 0x43a, 0x438, 0x20, 0x434, 0x438, 0x43d, 0x430, 0x440, 0x3b, 0x3b, 0x441, 0x440, 0x43f, 0x441, 0x43a, 0x430, 0x20, 0x434,
0x438, 0x43d, 0x430, 0x440, 0x430, 0x3b, 0x3b, 0x441, 0x440, 0x43f, 0x441, 0x43a, 0x438, 0x445, 0x20, 0x434, 0x438, 0x43d, 0x430, 0x440,
-0x430, 0x3b, 0x411, 0x43e, 0x441, 0x430, 0x43d, 0x441, 0x43a, 0x43e, 0x2d, 0x445, 0x435, 0x440, 0x446, 0x435, 0x433, 0x43e, 0x432, 0x430,
-0x447, 0x43a, 0x430, 0x20, 0x43a, 0x43e, 0x43d, 0x432, 0x435, 0x440, 0x442, 0x438, 0x431, 0x438, 0x43b, 0x43d, 0x430, 0x20, 0x43c, 0x430,
-0x440, 0x43a, 0x430, 0x3b, 0x3b, 0x431, 0x43e, 0x441, 0x430, 0x43d, 0x441, 0x43a, 0x43e, 0x2d, 0x445, 0x435, 0x440, 0x446, 0x435, 0x433,
-0x43e, 0x432, 0x430, 0x447, 0x43a, 0x430, 0x20, 0x43a, 0x43e, 0x43d, 0x432, 0x435, 0x440, 0x442, 0x438, 0x431, 0x438, 0x43b, 0x43d, 0x430,
-0x20, 0x43c, 0x430, 0x440, 0x43a, 0x430, 0x3b, 0x3b, 0x431, 0x43e, 0x441, 0x430, 0x43d, 0x441, 0x43a, 0x43e, 0x2d, 0x445, 0x435, 0x440,
-0x446, 0x435, 0x433, 0x43e, 0x432, 0x430, 0x447, 0x43a, 0x435, 0x20, 0x43a, 0x43e, 0x43d, 0x432, 0x435, 0x440, 0x442, 0x438, 0x431, 0x438,
-0x43b, 0x43d, 0x435, 0x20, 0x43c, 0x430, 0x440, 0x43a, 0x65, 0x3b, 0x3b, 0x431, 0x43e, 0x441, 0x430, 0x43d, 0x441, 0x43a, 0x43e, 0x2d,
-0x445, 0x435, 0x440, 0x446, 0x435, 0x433, 0x43e, 0x432, 0x430, 0x447, 0x43a, 0x438, 0x445, 0x20, 0x43a, 0x43e, 0x43d, 0x432, 0x435, 0x440,
-0x442, 0x438, 0x431, 0x438, 0x43b, 0x43d, 0x438, 0x445, 0x20, 0x43c, 0x430, 0x440, 0x430, 0x43a, 0x430, 0x3b, 0x415, 0x432, 0x440, 0x43e,
-0x3b, 0x3b, 0x435, 0x432, 0x440, 0x43e, 0x3b, 0x3b, 0x435, 0x432, 0x440, 0x430, 0x3b, 0x3b, 0x435, 0x432, 0x440, 0x430, 0x3b, 0x42,
-0x6f, 0x73, 0x61, 0x6e, 0x73, 0x6b, 0x6f, 0x2d, 0x68, 0x65, 0x72, 0x63, 0x65, 0x67, 0x6f, 0x76, 0x61, 0x10d, 0x6b, 0x61,
-0x20, 0x6b, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x69, 0x62, 0x69, 0x6c, 0x6e, 0x61, 0x20, 0x6d, 0x61, 0x72, 0x6b, 0x61,
-0x3b, 0x3b, 0x62, 0x6f, 0x73, 0x61, 0x6e, 0x73, 0x6b, 0x6f, 0x2d, 0x68, 0x65, 0x72, 0x63, 0x65, 0x67, 0x6f, 0x76, 0x61,
+0x430, 0x3b, 0x42, 0x6f, 0x73, 0x61, 0x6e, 0x73, 0x6b, 0x6f, 0x2d, 0x68, 0x65, 0x72, 0x63, 0x65, 0x67, 0x6f, 0x76, 0x61,
0x10d, 0x6b, 0x61, 0x20, 0x6b, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x69, 0x62, 0x69, 0x6c, 0x6e, 0x61, 0x20, 0x6d, 0x61,
0x72, 0x6b, 0x61, 0x3b, 0x3b, 0x62, 0x6f, 0x73, 0x61, 0x6e, 0x73, 0x6b, 0x6f, 0x2d, 0x68, 0x65, 0x72, 0x63, 0x65, 0x67,
-0x6f, 0x76, 0x61, 0x10d, 0x6b, 0x65, 0x20, 0x6b, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x69, 0x62, 0x69, 0x6c, 0x6e, 0x65,
-0x20, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x3b, 0x3b, 0x62, 0x6f, 0x73, 0x61, 0x6e, 0x73, 0x6b, 0x6f, 0x2d, 0x68, 0x65, 0x72,
-0x63, 0x65, 0x67, 0x6f, 0x76, 0x61, 0x10d, 0x6b, 0x69, 0x68, 0x20, 0x6b, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x69, 0x62,
-0x69, 0x6c, 0x6e, 0x69, 0x68, 0x20, 0x6d, 0x61, 0x72, 0x61, 0x6b, 0x61, 0x3b, 0x45, 0x76, 0x72, 0x6f, 0x3b, 0x3b, 0x65,
-0x76, 0x72, 0x6f, 0x3b, 0x3b, 0x65, 0x76, 0x72, 0x61, 0x3b, 0x3b, 0x65, 0x76, 0x72, 0x61, 0x3b, 0x53, 0x72, 0x70, 0x73,
-0x6b, 0x69, 0x20, 0x64, 0x69, 0x6e, 0x61, 0x72, 0x3b, 0x3b, 0x73, 0x72, 0x70, 0x73, 0x6b, 0x69, 0x20, 0x64, 0x69, 0x6e,
-0x61, 0x72, 0x3b, 0x3b, 0x73, 0x72, 0x70, 0x73, 0x6b, 0x61, 0x20, 0x64, 0x69, 0x6e, 0x61, 0x72, 0x61, 0x3b, 0x3b, 0x73,
-0x72, 0x70, 0x73, 0x6b, 0x69, 0x68, 0x20, 0x64, 0x69, 0x6e, 0x61, 0x72, 0x61, 0x3b, 0x41b, 0x430, 0x440, 0x3b, 0x3b, 0x43b,
+0x6f, 0x76, 0x61, 0x10d, 0x6b, 0x61, 0x20, 0x6b, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x69, 0x62, 0x69, 0x6c, 0x6e, 0x61,
+0x20, 0x6d, 0x61, 0x72, 0x6b, 0x61, 0x3b, 0x3b, 0x62, 0x6f, 0x73, 0x61, 0x6e, 0x73, 0x6b, 0x6f, 0x2d, 0x68, 0x65, 0x72,
+0x63, 0x65, 0x67, 0x6f, 0x76, 0x61, 0x10d, 0x6b, 0x65, 0x20, 0x6b, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x69, 0x62, 0x69,
+0x6c, 0x6e, 0x65, 0x20, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x3b, 0x3b, 0x62, 0x6f, 0x73, 0x61, 0x6e, 0x73, 0x6b, 0x6f, 0x2d,
+0x68, 0x65, 0x72, 0x63, 0x65, 0x67, 0x6f, 0x76, 0x61, 0x10d, 0x6b, 0x69, 0x68, 0x20, 0x6b, 0x6f, 0x6e, 0x76, 0x65, 0x72,
+0x74, 0x69, 0x62, 0x69, 0x6c, 0x6e, 0x69, 0x68, 0x20, 0x6d, 0x61, 0x72, 0x61, 0x6b, 0x61, 0x3b, 0x45, 0x76, 0x72, 0x6f,
+0x3b, 0x3b, 0x65, 0x76, 0x72, 0x6f, 0x3b, 0x3b, 0x65, 0x76, 0x72, 0x61, 0x3b, 0x3b, 0x65, 0x76, 0x72, 0x61, 0x3b, 0x53,
+0x72, 0x70, 0x73, 0x6b, 0x69, 0x20, 0x64, 0x69, 0x6e, 0x61, 0x72, 0x3b, 0x3b, 0x73, 0x72, 0x70, 0x73, 0x6b, 0x69, 0x20,
+0x64, 0x69, 0x6e, 0x61, 0x72, 0x3b, 0x3b, 0x73, 0x72, 0x70, 0x73, 0x6b, 0x61, 0x20, 0x64, 0x69, 0x6e, 0x61, 0x72, 0x61,
+0x3b, 0x3b, 0x73, 0x72, 0x70, 0x73, 0x6b, 0x69, 0x68, 0x20, 0x64, 0x69, 0x6e, 0x61, 0x72, 0x61, 0x3b, 0x411, 0x43e, 0x441,
+0x430, 0x43d, 0x441, 0x43a, 0x43e, 0x2d, 0x445, 0x435, 0x440, 0x446, 0x435, 0x433, 0x43e, 0x432, 0x430, 0x447, 0x43a, 0x430, 0x20, 0x43a,
+0x43e, 0x43d, 0x432, 0x435, 0x440, 0x442, 0x438, 0x431, 0x438, 0x43b, 0x43d, 0x430, 0x20, 0x43c, 0x430, 0x440, 0x43a, 0x430, 0x3b, 0x3b,
+0x431, 0x43e, 0x441, 0x430, 0x43d, 0x441, 0x43a, 0x43e, 0x2d, 0x445, 0x435, 0x440, 0x446, 0x435, 0x433, 0x43e, 0x432, 0x430, 0x447, 0x43a,
+0x430, 0x20, 0x43a, 0x43e, 0x43d, 0x432, 0x435, 0x440, 0x442, 0x438, 0x431, 0x438, 0x43b, 0x43d, 0x430, 0x20, 0x43c, 0x430, 0x440, 0x43a,
+0x430, 0x3b, 0x3b, 0x431, 0x43e, 0x441, 0x430, 0x43d, 0x441, 0x43a, 0x43e, 0x2d, 0x445, 0x435, 0x440, 0x446, 0x435, 0x433, 0x43e, 0x432,
+0x430, 0x447, 0x43a, 0x435, 0x20, 0x43a, 0x43e, 0x43d, 0x432, 0x435, 0x440, 0x442, 0x438, 0x431, 0x438, 0x43b, 0x43d, 0x435, 0x20, 0x43c,
+0x430, 0x440, 0x43a, 0x65, 0x3b, 0x3b, 0x431, 0x43e, 0x441, 0x430, 0x43d, 0x441, 0x43a, 0x43e, 0x2d, 0x445, 0x435, 0x440, 0x446, 0x435,
+0x433, 0x43e, 0x432, 0x430, 0x447, 0x43a, 0x438, 0x445, 0x20, 0x43a, 0x43e, 0x43d, 0x432, 0x435, 0x440, 0x442, 0x438, 0x431, 0x438, 0x43b,
+0x43d, 0x438, 0x445, 0x20, 0x43c, 0x430, 0x440, 0x430, 0x43a, 0x430, 0x3b, 0x415, 0x432, 0x440, 0x43e, 0x3b, 0x3b, 0x435, 0x432, 0x440,
+0x43e, 0x3b, 0x3b, 0x435, 0x432, 0x440, 0x430, 0x3b, 0x3b, 0x435, 0x432, 0x440, 0x430, 0x3b, 0x41b, 0x430, 0x440, 0x3b, 0x3b, 0x43b,
0x430, 0x440, 0x3b, 0x3b, 0x3b, 0x3b, 0x43b, 0x430, 0x440, 0x44b, 0x3b, 0x421, 0x43e, 0x43c, 0x3b, 0x3b, 0x441, 0x43e, 0x43c, 0x3b,
0x3b, 0x3b, 0x3b, 0x441, 0x43e, 0x43c, 0x44b, 0x3b, 0x44, 0x6f, 0x72, 0x61, 0x20, 0x72, 0x65, 0x20, 0x41, 0x6d, 0x65, 0x72,
0x69, 0x6b, 0x61, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x67e, 0x627, 0x6aa, 0x633, 0x62a, 0x627, 0x646, 0x64a, 0x20, 0x631,
@@ -6291,9 +6306,9 @@ static const ushort endonyms_data[] = {
0x441, 0x442, 0x430, 0x43d, 0x41a, 0x438, 0x440, 0x433, 0x438, 0x437, 0x438, 0x44f, 0x41c, 0x43e, 0x43b, 0x434, 0x43e, 0x432, 0x430, 0x423,
0x43a, 0x440, 0x430, 0x438, 0x43d, 0x430, 0x53, 0xe4, 0x6e, 0x67, 0xf6, 0x4b, 0xf6, 0x64, 0xf6, 0x72, 0xf6, 0x73, 0xea, 0x73,
0x65, 0x20, 0x74, 0xee, 0x20, 0x42, 0xea, 0x61, 0x66, 0x72, 0xee, 0x6b, 0x61, 0x441, 0x440, 0x43f, 0x441, 0x43a, 0x438, 0x421,
-0x440, 0x431, 0x438, 0x458, 0x430, 0x411, 0x43e, 0x441, 0x43d, 0x430, 0x20, 0x438, 0x20, 0x425, 0x435, 0x440, 0x446, 0x435, 0x433, 0x43e,
-0x432, 0x438, 0x43d, 0x430, 0x426, 0x440, 0x43d, 0x430, 0x20, 0x413, 0x43e, 0x440, 0x430, 0x41a, 0x43e, 0x441, 0x43e, 0x432, 0x43e, 0x73,
-0x72, 0x70, 0x73, 0x6b, 0x69, 0x43, 0x72, 0x6e, 0x61, 0x20, 0x47, 0x6f, 0x72, 0x61, 0x53, 0x72, 0x62, 0x69, 0x6a, 0x61,
+0x440, 0x431, 0x438, 0x458, 0x430, 0x73, 0x72, 0x70, 0x73, 0x6b, 0x69, 0x43, 0x72, 0x6e, 0x61, 0x20, 0x47, 0x6f, 0x72, 0x61,
+0x53, 0x72, 0x62, 0x69, 0x6a, 0x61, 0x411, 0x43e, 0x441, 0x43d, 0x430, 0x20, 0x438, 0x20, 0x425, 0x435, 0x440, 0x446, 0x435, 0x433,
+0x43e, 0x432, 0x438, 0x43d, 0x430, 0x426, 0x440, 0x43d, 0x430, 0x20, 0x413, 0x43e, 0x440, 0x430, 0x41a, 0x43e, 0x441, 0x43e, 0x432, 0x43e,
0x4b, 0x6f, 0x73, 0x6f, 0x76, 0x6f, 0x438, 0x440, 0x43e, 0x43d, 0x413, 0x443, 0x44b, 0x440, 0x434, 0x437, 0x44b, 0x441, 0x442, 0x43e,
0x43d, 0x423, 0x4d5, 0x440, 0x4d5, 0x441, 0x435, 0x63, 0x68, 0x69, 0x53, 0x68, 0x6f, 0x6e, 0x61, 0x633, 0x646, 0x68c, 0x64a, 0x67e,
0x627, 0x6aa, 0x633, 0x62a, 0x627, 0x646, 0xdc3, 0xdd2, 0xd82, 0xdc4, 0xdbd, 0xdc1, 0xdca, 0x200d, 0xdbb, 0xdd3, 0x20, 0xdbd, 0xd82, 0xd9a,
@@ -6773,6 +6788,11 @@ static const char language_name_list[] =
"Cantonese\0"
"Osage\0"
"Tangut\0"
+"Ido\0"
+"Lojban\0"
+"Sicilian\0"
+"Southern Kurdish\0"
+"Western Balochi\0"
;
static const quint16 language_name_index[] = {
@@ -7136,6 +7156,11 @@ static const quint16 language_name_index[] = {
3050, // Cantonese
3060, // Osage
3066, // Tangut
+ 3073, // Ido
+ 3077, // Lojban
+ 3084, // Sicilian
+ 3093, // Southern Kurdish
+ 3110, // Western Balochi
};
static const char script_name_list[] =
@@ -8319,6 +8344,11 @@ static const unsigned char language_code_list[] =
"yue" // Cantonese
"osa" // Osage
"txg" // Tangut
+"io\0" // Ido
+"jbo" // Lojban
+"scn" // Sicilian
+"sdh" // Southern Kurdish
+"bgn" // Western Balochi
;
static const unsigned char script_code_list[] =
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index a9c23aed61..9f5811990b 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -66,6 +66,7 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_SYSTEMLOCALE
+struct QLocaleData;
class Q_CORE_EXPORT QSystemLocale
{
public:
@@ -126,6 +127,7 @@ public:
virtual QVariant query(QueryType type, QVariant in) const;
virtual QLocale fallbackUiLocale() const;
+ inline const QLocaleData *fallbackUiLocaleData() const;
private:
QSystemLocale(bool);
friend class QSystemLocaleSingleton;
@@ -364,8 +366,6 @@ public:
QLocale::MeasurementSystem measurementSystem() const;
- static void updateSystemPrivate();
-
QString dateTimeToString(QStringView format, const QDateTime &datetime,
const QDate &dateOnly, const QTime &timeOnly,
const QLocale *q) const;
@@ -375,6 +375,10 @@ public:
QLocale::NumberOptions m_numberOptions;
};
+#ifndef QT_NO_SYSTEMLOCALE
+const QLocaleData *QSystemLocale::fallbackUiLocaleData() const { return fallbackUiLocale().d->m_data; }
+#endif
+
template <>
inline QLocalePrivate *QSharedDataPointer<QLocalePrivate>::clone()
{
diff --git a/src/corelib/tools/qmakearray_p.h b/src/corelib/tools/qmakearray_p.h
index ae4d7f07c6..71441c2c27 100644
--- a/src/corelib/tools/qmakearray_p.h
+++ b/src/corelib/tools/qmakearray_p.h
@@ -111,10 +111,10 @@ struct QuickSortFilter<Predicate, QuickSortData<Head, Tail...>>
using TailFilteredData = typename QuickSortFilter<
Predicate, QuickSortData<Tail...>>::Type;
- using Type = typename QConditional<
+ using Type = typename std::conditional<
Predicate<Head>::value,
decltype(quickSortConcat(QuickSortData<Head> {}, TailFilteredData{})),
- TailFilteredData>::Type;
+ TailFilteredData>::type;
};
template <template <typename> class Predicate>
diff --git a/src/corelib/tools/qoffsetstringarray_p.h b/src/corelib/tools/qoffsetstringarray_p.h
new file mode 100644
index 0000000000..5ca2200091
--- /dev/null
+++ b/src/corelib/tools/qoffsetstringarray_p.h
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOFFSETSTRINGARRAY_P_H
+#define QOFFSETSTRINGARRAY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qglobal_p.h"
+
+#include <tuple>
+#include <array>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtPrivate {
+template<int N, int O, int I, int ... Idx>
+struct OffsetSequenceHelper : OffsetSequenceHelper<N - 1, O + I, Idx..., O> { };
+
+template<int Last, int I, int S, int ... Idx>
+struct OffsetSequenceHelper<1, Last, I, S, Idx...> : IndexesList<Last + I, Idx..., Last>
+{
+ static const constexpr auto Length = Last + I;
+ using Type = typename std::conditional<
+ Last <= std::numeric_limits<quint8>::max(),
+ quint8,
+ typename std::conditional<
+ Last <= std::numeric_limits<quint16>::max(),
+ quint16,
+ int>::type
+ >::type;
+};
+
+template<int ... Idx>
+struct OffsetSequence : OffsetSequenceHelper<sizeof ... (Idx), 0, Idx..., 0> { };
+
+template<int N>
+struct StaticString
+{
+ const char data[N];
+
+ constexpr StaticString(const StaticString<N> &other) noexcept = default;
+};
+
+
+template<>
+struct StaticString<0>
+{
+ static constexpr int size() noexcept
+ {
+ return 0;
+ }
+};
+
+template<typename, typename>
+struct StaticStringBuilder;
+
+template<int ... I1, int ... I2>
+struct StaticStringBuilder<IndexesList<I1...>, IndexesList<I2...>>
+{
+
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_MSVC(4100) // The formal parameter is not referenced in the body of the function.
+ // The unreferenced parameter is ignored.
+ // It happens when 'rs' is StaticString<0>
+ template<int N1, int N2>
+ static constexpr StaticString<N1 + N2> concatenate(
+ const char (&ls)[N1], const StaticString<N2> &rs) noexcept
+ {
+ return StaticString<N1 + N2>{{ls[I1]..., rs.data[I2]...}};
+ }
+QT_WARNING_POP
+};
+
+template<int Sum>
+constexpr StaticString<0> staticString() noexcept
+{
+ return StaticString<0>{};
+}
+
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_MSVC(4503)
+template<int Sum, int I, int ... Ix>
+constexpr StaticString<Sum> staticString(const char (&s)[I], const char (&...sx)[Ix]) noexcept
+{
+ return StaticStringBuilder<
+ makeIndexSequence<I>,
+ makeIndexSequence<Sum - I>>::concatenate(s, staticString<Sum - I>(sx...));
+}
+QT_WARNING_POP
+} // namespace QtPrivate
+
+template<typename T, int SizeString, int SizeOffsets>
+class QOffsetStringArray
+{
+public:
+ using Type = T;
+
+ template<int ... Ox>
+ constexpr QOffsetStringArray(const QtPrivate::StaticString<SizeString> &str,
+ QtPrivate::IndexesList<SizeString, Ox...>) noexcept
+ : m_string(str),
+ m_offsets{Ox...}
+ { }
+
+ constexpr inline const char *operator[](const int index) const noexcept
+ {
+ return m_string.data + m_offsets[qBound(int(0), index, SizeOffsets - 1)];
+ }
+
+ constexpr inline const char *at(const int index) const noexcept
+ {
+ return m_string.data + m_offsets[index];
+ }
+
+ constexpr inline const char *str() const { return m_string.data; }
+ constexpr inline const T *offsets() const { return m_offsets; }
+ constexpr inline int count() const { return SizeOffsets; };
+
+ static constexpr const auto sizeString = SizeString;
+ static constexpr const auto sizeOffsets = SizeOffsets;
+
+private:
+ QtPrivate::StaticString<SizeString> m_string;
+ const T m_offsets[SizeOffsets];
+};
+
+template<typename T, int N, int ... Ox>
+constexpr QOffsetStringArray<T, N, sizeof ... (Ox)> qOffsetStringArray(
+ const QtPrivate::StaticString<N> &string,
+ QtPrivate::IndexesList<N, Ox...> offsets) noexcept
+{
+ return QOffsetStringArray<T, N, sizeof ... (Ox)>(
+ string,
+ offsets);
+}
+
+template<int ... Nx>
+struct QOffsetStringArrayRet
+{
+ using Offsets = QtPrivate::OffsetSequence<Nx...>;
+ using Type = QOffsetStringArray<typename Offsets::Type, Offsets::Length, sizeof ... (Nx)>;
+};
+
+template<int ... Nx>
+constexpr auto qOffsetStringArray(const char (&...strings)[Nx]) noexcept -> typename QOffsetStringArrayRet<Nx...>::Type
+{
+ using Offsets = QtPrivate::OffsetSequence<Nx...>;
+ return qOffsetStringArray<typename Offsets::Type>(
+ QtPrivate::staticString<Offsets::Length>(strings...), Offsets{});
+}
+
+QT_END_NAMESPACE
+
+#endif // QOFFSETSTRINGARRAY_P_H
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index e52171fcec..560453de84 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -120,7 +120,7 @@ QT_BEGIN_NAMESPACE
* Whenever multiple alternatives are equivalent or near so, we prefer the one
* using instructions from SSE2, since SSE2 is guaranteed to be enabled for all
* 64-bit builds and we enable it for 32-bit builds by default. Use of higher
- * SSE versions should be done when there's a clear performance benefit and
+ * SSE versions should be done when there is a clear performance benefit and
* requires fallback code to SSE2, if it exists.
*
* Performance measurement in the past shows that most strings are short in
@@ -1505,7 +1505,7 @@ const QString::Null QString::null = { };
functions. The former searches forward starting from a given index
position, the latter searches backward. Both return the index
position of the character or substring if they find it; otherwise,
- they return -1. For example, here's a typical loop that finds all
+ they return -1. For example, here is a typical loop that finds all
occurrences of a particular substring:
\snippet qstring/main.cpp 6
@@ -6620,7 +6620,7 @@ namespace QUnicodeTables {
this function requires to be a valid, empty string) and \c{s} contains the
only copy of the string, without reallocation (thus, \a it is still valid).
- There's one pathological case left: when the in-place conversion needs to
+ There is one pathological case left: when the in-place conversion needs to
reallocate memory to grow the buffer. In that case, we need to adjust the \a
it pointer.
*/
@@ -6778,7 +6778,7 @@ QString &QString::sprintf(const char *cformat, ...)
\warning We do not recommend using QString::asprintf() in new Qt
code. Instead, consider using QTextStream or arg(), both of
which support Unicode strings seamlessly and are type-safe.
- Here's an example that uses QTextStream:
+ Here is an example that uses QTextStream:
\snippet qstring/main.cpp 64
@@ -7743,7 +7743,7 @@ QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseS
the result.
\note All references are valid as long this string is alive. Destroying this
- string will cause all references be dangling pointers.
+ string will cause all references to be dangling pointers.
\since 5.4
\sa QStringRef split()
@@ -7777,7 +7777,7 @@ QVector<QStringRef> QString::splitRef(QChar sep, SplitBehavior behavior, Qt::Cas
the result.
\note All references are valid as long this string is alive. Destroying this
- string will cause all references be dangling pointers.
+ string will cause all references to be dangling pointers.
\since 5.4
*/
@@ -7826,17 +7826,17 @@ static ResultList splitString(const QString &source, MidMethod mid, const QRegEx
does not match anywhere in the string, split() returns a
single-element list containing this string.
- Here's an example where we extract the words in a sentence
+ Here is an example where we extract the words in a sentence
using one or more whitespace characters as the separator:
\snippet qstring/main.cpp 59
- Here's a similar example, but this time we use any sequence of
+ Here is a similar example, but this time we use any sequence of
non-word characters as the separator:
\snippet qstring/main.cpp 60
- Here's a third example where we use a zero-length assertion,
+ Here is a third example where we use a zero-length assertion,
\b{\\b} (word boundary), to split the string into an
alternating sequence of non-word and word tokens:
@@ -7859,7 +7859,7 @@ QStringList QString::split(const QRegExp &rx, SplitBehavior behavior) const
single-element vector containing this string reference.
\note All references are valid as long this string is alive. Destroying this
- string will cause all references be dangling pointers.
+ string will cause all references to be dangling pointers.
\sa QStringRef split()
*/
@@ -7908,17 +7908,17 @@ static ResultList splitString(const QString &source, MidMethod mid, const QRegul
does not match anywhere in the string, split() returns a
single-element list containing this string.
- Here's an example where we extract the words in a sentence
+ Here is an example where we extract the words in a sentence
using one or more whitespace characters as the separator:
\snippet qstring/main.cpp 90
- Here's a similar example, but this time we use any sequence of
+ Here is a similar example, but this time we use any sequence of
non-word characters as the separator:
\snippet qstring/main.cpp 91
- Here's a third example where we use a zero-length assertion,
+ Here is a third example where we use a zero-length assertion,
\b{\\b} (word boundary), to split the string into an
alternating sequence of non-word and word tokens:
@@ -7941,7 +7941,7 @@ QStringList QString::split(const QRegularExpression &re, SplitBehavior behavior)
single-element vector containing this string reference.
\note All references are valid as long this string is alive. Destroying this
- string will cause all references be dangling pointers.
+ string will cause all references to be dangling pointers.
\sa split() QStringRef
*/
@@ -9078,7 +9078,7 @@ bool QString::isRightToLeft() const
to create a deep copy of the data, ensuring that the raw data
isn't modified.
- Here's an example of how we can use a QRegularExpression on raw data in
+ Here is an example of how we can use a QRegularExpression on raw data in
memory without requiring to copy the data into a QString:
\snippet qstring/main.cpp 22
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 6be3dcdbe1..da76601e88 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -899,10 +899,8 @@ private:
template <typename T> static
T toIntegral_helper(const QChar *data, int len, bool *ok, int base)
{
- // ### Qt6: use std::conditional<std::is_unsigned<T>::value, qulonglong, qlonglong>::type
- const bool isUnsigned = T(0) < T(-1);
- typedef typename QtPrivate::QConditional<isUnsigned, qulonglong, qlonglong>::Type Int64;
- typedef typename QtPrivate::QConditional<isUnsigned, uint, int>::Type Int32;
+ using Int64 = typename std::conditional<std::is_unsigned<T>::value, qulonglong, qlonglong>::type;
+ using Int32 = typename std::conditional<std::is_unsigned<T>::value, uint, int>::type;
// we select the right overload by casting size() to int or uint
Int64 val = toIntegral_helper(data, Int32(len), ok, base);
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index dc28e0e0a2..995bab694e 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -39,6 +39,7 @@ HEADERS += \
tools/qmargins.h \
tools/qmessageauthenticationcode.h \
tools/qcontiguouscache.h \
+ tools/qoffsetstringarray_p.h \
tools/qpair.h \
tools/qpoint.h \
tools/qqueue.h \
diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro
index ce799e0951..920a04315d 100644
--- a/src/dbus/dbus.pro
+++ b/src/dbus/dbus.pro
@@ -20,7 +20,7 @@ DEFINES += QT_NO_FOREACH
QMAKE_DOCS = $$PWD/doc/qtdbus.qdocconf
-PUB_HEADERS = qtdbusglobal.h \
+HEADERS += qtdbusglobal.h \
qdbusargument.h \
qdbusconnectioninterface.h \
qdbuserror.h \
@@ -38,8 +38,7 @@ PUB_HEADERS = qtdbusglobal.h \
qdbuscontext.h \
qdbusvirtualobject.h \
qdbusservicewatcher.h \
- qdbusunixfiledescriptor.h
-HEADERS += $$PUB_HEADERS \
+ qdbusunixfiledescriptor.h \
qtdbusglobal_p.h \
qdbusconnection_p.h \
qdbusconnectionmanager_p.h \
diff --git a/src/dbus/doc/qtdbus.qdocconf b/src/dbus/doc/qtdbus.qdocconf
index 69eaa0eec3..4ff7242b25 100644
--- a/src/dbus/doc/qtdbus.qdocconf
+++ b/src/dbus/doc/qtdbus.qdocconf
@@ -21,6 +21,8 @@ excludedirs += ../../../examples/widgets/doc
examplesinstallpath = dbus
+tagfile = qtdbus.tags
+
depends += qtdoc qtcore
# The following parameters are for creating a qhp file, the qhelpgenerator
diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp
index a33c4f8363..2d1373006d 100644
--- a/src/dbus/qdbusargument.cpp
+++ b/src/dbus/qdbusargument.cpp
@@ -267,7 +267,7 @@ bool QDBusArgumentPrivate::checkReadAndDetach(QDBusArgumentPrivate *&d)
*/
/*!
- \fn qdbus_cast(const QDBusArgument &arg)
+ \fn template<typename T> T qdbus_cast(const QDBusArgument &arg, T*)
\relates QDBusArgument
\since 4.2
diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h
index a6d4e9cd25..ac650d5f62 100644
--- a/src/dbus/qdbusargument.h
+++ b/src/dbus/qdbusargument.h
@@ -158,22 +158,14 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QDBusArgument)
QT_BEGIN_NAMESPACE
-template<typename T> inline T qdbus_cast(const QDBusArgument &arg
-#ifndef Q_QDOC
-, T * = nullptr
-#endif
- )
+template<typename T> inline T qdbus_cast(const QDBusArgument &arg, T * = nullptr)
{
T item;
arg >> item;
return item;
}
-template<typename T> inline T qdbus_cast(const QVariant &v
-#ifndef Q_QDOC
-, T * = nullptr
-#endif
- )
+template<typename T> inline T qdbus_cast(const QVariant &v, T * = nullptr)
{
int id = v.userType();
if (id == qMetaTypeId<QDBusArgument>())
diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h
index ca7adfaaeb..3711981f78 100644
--- a/src/dbus/qdbusconnection.h
+++ b/src/dbus/qdbusconnection.h
@@ -122,9 +122,7 @@ public:
SubPath = 0x1
// Reserved = 0xff000000
};
-#ifndef Q_QDOC
Q_DECLARE_FLAGS(VirtualObjectRegisterOptions, VirtualObjectRegisterOption)
-#endif
enum ConnectionCapability {
UnixFileDescriptorPassing = 0x0001
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h
index 444d4727fd..84ce21092a 100644
--- a/src/dbus/qdbusconnection_p.h
+++ b/src/dbus/qdbusconnection_p.h
@@ -121,6 +121,15 @@ public:
QSocketNotifier *write;
};
+ struct ArgMatchRules {
+ QStringList args;
+ QString arg0namespace;
+ bool operator==(const ArgMatchRules &other) const {
+ return args == other.args &&
+ arg0namespace == other.arg0namespace;
+ }
+ };
+
struct SignalHook
{
inline SignalHook() : obj(0), midx(-1) { }
@@ -128,7 +137,7 @@ public:
QObject* obj;
int midx;
QVector<int> params;
- QStringList argumentMatch;
+ ArgMatchRules argumentMatch;
QByteArray matchRule;
};
@@ -207,12 +216,19 @@ public:
QDBusMessage sendWithReplyLocal(const QDBusMessage &message);
QDBusPendingCallPrivate *sendWithReplyAsync(const QDBusMessage &message, QObject *receiver,
const char *returnMethod, const char *errorMethod,int timeout = -1);
+
bool connectSignal(const QString &service, const QString &path, const QString& interface,
const QString &name, const QStringList &argumentMatch, const QString &signature,
QObject *receiver, const char *slot);
bool disconnectSignal(const QString &service, const QString &path, const QString& interface,
const QString &name, const QStringList &argumentMatch, const QString &signature,
QObject *receiver, const char *slot);
+ bool connectSignal(const QString &service, const QString &path, const QString& interface,
+ const QString &name, const ArgMatchRules &argumentMatch, const QString &signature,
+ QObject *receiver, const char *slot);
+ bool disconnectSignal(const QString &service, const QString &path, const QString& interface,
+ const QString &name, const ArgMatchRules &argumentMatch, const QString &signature,
+ QObject *receiver, const char *slot);
void registerObject(const ObjectTreeNode *node);
void unregisterObject(const QString &path, QDBusConnection::UnregisterMode mode);
void connectRelay(const QString &service,
@@ -332,7 +348,7 @@ public:
static bool prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key,
const QString &service,
const QString &path, const QString &interface, const QString &name,
- const QStringList &argMatch,
+ const ArgMatchRules &argMatch,
QObject *receiver, const char *signal, int minMIdx,
bool buildSignature);
static DBusHandlerResult messageFilter(DBusConnection *, DBusMessage *, void *);
diff --git a/src/dbus/qdbuserror.cpp b/src/dbus/qdbuserror.cpp
index e966f9dcde..decd345ece 100644
--- a/src/dbus/qdbuserror.cpp
+++ b/src/dbus/qdbuserror.cpp
@@ -41,6 +41,7 @@
#include <qdebug.h>
#include <qvarlengtharray.h>
+#include <private/qoffsetstringarray_p.h>
#ifndef QT_BOOTSTRAPPED
#include "qdbus_symbols_p.h"
@@ -52,110 +53,46 @@
QT_BEGIN_NAMESPACE
-/*
- * Use the following Perl script to generate the error string index list:
-===== PERL SCRIPT ====
-print "static const char errorMessages_string[] =\n";
-$counter = 0;
-$i = 0;
-while (<STDIN>) {
- chomp;
- print " \"$_\\0\"\n";
- $sizes[$i++] = $counter;
- $counter += 1 + length $_;
-}
-print " \"\\0\";\n\nstatic const int errorMessages_indices[] = {\n ";
-for ($j = 0; $j < $i; ++$j) {
- printf "$sizes[$j], ";
-}
-print "0\n};\n";
-===== PERL SCRIPT ====
-
- * The input data is as follows:
-other
-org.freedesktop.DBus.Error.Failed
-org.freedesktop.DBus.Error.NoMemory
-org.freedesktop.DBus.Error.ServiceUnknown
-org.freedesktop.DBus.Error.NoReply
-org.freedesktop.DBus.Error.BadAddress
-org.freedesktop.DBus.Error.NotSupported
-org.freedesktop.DBus.Error.LimitsExceeded
-org.freedesktop.DBus.Error.AccessDenied
-org.freedesktop.DBus.Error.NoServer
-org.freedesktop.DBus.Error.Timeout
-org.freedesktop.DBus.Error.NoNetwork
-org.freedesktop.DBus.Error.AddressInUse
-org.freedesktop.DBus.Error.Disconnected
-org.freedesktop.DBus.Error.InvalidArgs
-org.freedesktop.DBus.Error.UnknownMethod
-org.freedesktop.DBus.Error.TimedOut
-org.freedesktop.DBus.Error.InvalidSignature
-org.freedesktop.DBus.Error.UnknownInterface
-org.freedesktop.DBus.Error.UnknownObject
-org.freedesktop.DBus.Error.UnknownProperty
-org.freedesktop.DBus.Error.PropertyReadOnly
-org.qtproject.QtDBus.Error.InternalError
-org.qtproject.QtDBus.Error.InvalidService
-org.qtproject.QtDBus.Error.InvalidObjectPath
-org.qtproject.QtDBus.Error.InvalidInterface
-org.qtproject.QtDBus.Error.InvalidMember
-*/
-
-// in the same order as KnownErrors!
-static const char errorMessages_string[] =
- "other\0"
- "org.freedesktop.DBus.Error.Failed\0"
- "org.freedesktop.DBus.Error.NoMemory\0"
- "org.freedesktop.DBus.Error.ServiceUnknown\0"
- "org.freedesktop.DBus.Error.NoReply\0"
- "org.freedesktop.DBus.Error.BadAddress\0"
- "org.freedesktop.DBus.Error.NotSupported\0"
- "org.freedesktop.DBus.Error.LimitsExceeded\0"
- "org.freedesktop.DBus.Error.AccessDenied\0"
- "org.freedesktop.DBus.Error.NoServer\0"
- "org.freedesktop.DBus.Error.Timeout\0"
- "org.freedesktop.DBus.Error.NoNetwork\0"
- "org.freedesktop.DBus.Error.AddressInUse\0"
- "org.freedesktop.DBus.Error.Disconnected\0"
- "org.freedesktop.DBus.Error.InvalidArgs\0"
- "org.freedesktop.DBus.Error.UnknownMethod\0"
- "org.freedesktop.DBus.Error.TimedOut\0"
- "org.freedesktop.DBus.Error.InvalidSignature\0"
- "org.freedesktop.DBus.Error.UnknownInterface\0"
- "org.freedesktop.DBus.Error.UnknownObject\0"
- "org.freedesktop.DBus.Error.UnknownProperty\0"
- "org.freedesktop.DBus.Error.PropertyReadOnly\0"
- "org.qtproject.QtDBus.Error.InternalError\0"
- "org.qtproject.QtDBus.Error.InvalidService\0"
- "org.qtproject.QtDBus.Error.InvalidObjectPath\0"
- "org.qtproject.QtDBus.Error.InvalidInterface\0"
- "org.qtproject.QtDBus.Error.InvalidMember\0"
- "\0";
-
-static const int errorMessages_indices[] = {
- 0, 6, 40, 76, 118, 153, 191, 231,
- 273, 313, 349, 384, 421, 461, 501, 540,
- 581, 617, 661, 705, 746, 789, 833, 874,
- 916, 961, 1005
-};
-
-static const int errorMessages_count = sizeof errorMessages_indices /
- sizeof errorMessages_indices[0];
-
-static inline const char *get(QDBusError::ErrorType code)
-{
- int intcode = qBound(0, int(code) - int(QDBusError::Other), errorMessages_count);
- return errorMessages_string + errorMessages_indices[intcode];
-}
+static constexpr const auto errorMessages = qOffsetStringArray(
+ "NoError",
+ "other",
+ "org.freedesktop.DBus.Error.Failed",
+ "org.freedesktop.DBus.Error.NoMemory",
+ "org.freedesktop.DBus.Error.ServiceUnknown",
+ "org.freedesktop.DBus.Error.NoReply",
+ "org.freedesktop.DBus.Error.BadAddress",
+ "org.freedesktop.DBus.Error.NotSupported",
+ "org.freedesktop.DBus.Error.LimitsExceeded",
+ "org.freedesktop.DBus.Error.AccessDenied",
+ "org.freedesktop.DBus.Error.NoServer",
+ "org.freedesktop.DBus.Error.Timeout",
+ "org.freedesktop.DBus.Error.NoNetwork",
+ "org.freedesktop.DBus.Error.AddressInUse",
+ "org.freedesktop.DBus.Error.Disconnected",
+ "org.freedesktop.DBus.Error.InvalidArgs",
+ "org.freedesktop.DBus.Error.UnknownMethod",
+ "org.freedesktop.DBus.Error.TimedOut",
+ "org.freedesktop.DBus.Error.InvalidSignature",
+ "org.freedesktop.DBus.Error.UnknownInterface",
+ "org.freedesktop.DBus.Error.UnknownObject",
+ "org.freedesktop.DBus.Error.UnknownProperty",
+ "org.freedesktop.DBus.Error.PropertyReadOnly",
+ "org.qtproject.QtDBus.Error.InternalError",
+ "org.qtproject.QtDBus.Error.InvalidService",
+ "org.qtproject.QtDBus.Error.InvalidObjectPath",
+ "org.qtproject.QtDBus.Error.InvalidInterface",
+ "org.qtproject.QtDBus.Error.InvalidMember",
+ ""
+);
#ifndef QT_BOOTSTRAPPED
static inline QDBusError::ErrorType get(const char *name)
{
if (!name || !*name)
return QDBusError::NoError;
- for (int i = 0; i < errorMessages_count; ++i)
- if (strcmp(name, errorMessages_string + errorMessages_indices[i]) == 0)
- return QDBusError::ErrorType(i + int(QDBusError::Other));
+ for (int i = 0; i < errorMessages.count(); ++i)
+ if (strcmp(name, errorMessages.at(i)) == 0)
+ return QDBusError::ErrorType(i);
return QDBusError::Other;
}
#endif
@@ -301,7 +238,7 @@ QDBusError::QDBusError(const QDBusMessage &qdmsg)
QDBusError::QDBusError(ErrorType error, const QString &mess)
: code(error)
{
- nm = QLatin1String(::get(error));
+ nm = QLatin1String(errorMessages[error]);
msg = mess;
}
@@ -397,7 +334,7 @@ bool QDBusError::isValid() const
*/
QString QDBusError::errorString(ErrorType error)
{
- return QLatin1String(::get(error));
+ return QLatin1String(errorMessages[error]);
}
#ifndef QT_NO_DEBUG_STREAM
@@ -418,3 +355,11 @@ QDebug operator<<(QDebug dbg, const QDBusError &msg)
QT_END_NAMESPACE
#endif // QT_NO_DBUS
+
+/*
+MSVC2015 has the warning C4503 at the end of the file:
+QtPrivate::StaticStringBuilder<QtPrivate::IndexesList<...> - decorated name length exceeded, name was truncated
+It is used by qOffsetStringArray in a constexpr evaulation and this code does not exist in the object file,
+but we still have the warning or even error with -WX flag
+*/
+QT_WARNING_DISABLE_MSVC(4503)
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 03de5b0091..cee5c821c8 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -338,7 +338,7 @@ void QDBusConnectionPrivate::_q_newConnection(QDBusConnectionPrivate *newConnect
static QByteArray buildMatchRule(const QString &service,
const QString &objectPath, const QString &interface,
- const QString &member, const QStringList &argMatch, const QString & /*signature*/)
+ const QString &member, const QDBusConnectionPrivate::ArgMatchRules &argMatch, const QString & /*signature*/)
{
QString result = QLatin1String("type='signal',");
QString keyValue = QLatin1String("%1='%2',");
@@ -353,11 +353,14 @@ static QByteArray buildMatchRule(const QString &service,
result += keyValue.arg(QLatin1String("member"), member);
// add the argument string-matching now
- if (!argMatch.isEmpty()) {
+ if (!argMatch.args.isEmpty()) {
keyValue = QLatin1String("arg%1='%2',");
- for (int i = 0; i < argMatch.count(); ++i)
- if (!argMatch.at(i).isNull())
- result += keyValue.arg(i).arg(argMatch.at(i));
+ for (int i = 0; i < argMatch.args.count(); ++i)
+ if (!argMatch.args.at(i).isNull())
+ result += keyValue.arg(i).arg(argMatch.args.at(i));
+ }
+ if (!argMatch.arg0namespace.isEmpty()) {
+ result += QStringLiteral("arg0namespace='%1',").arg(argMatch.arg0namespace);
}
result.chop(1); // remove ending comma
@@ -456,21 +459,26 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro
return 0;
}
-static QStringList matchArgsForService(const QString &service, QDBusServiceWatcher::WatchMode mode)
+static QDBusConnectionPrivate::ArgMatchRules matchArgsForService(const QString &service, QDBusServiceWatcher::WatchMode mode)
{
- QStringList matchArgs;
- matchArgs << service;
+ QDBusConnectionPrivate::ArgMatchRules matchArgs;
+ if (service.endsWith(QLatin1Char('*'))) {
+ matchArgs.arg0namespace = service.chopped(1);
+ matchArgs.args << QString();
+ }
+ else
+ matchArgs.args << service;
switch (mode) {
case QDBusServiceWatcher::WatchForOwnerChange:
break;
case QDBusServiceWatcher::WatchForRegistration:
- matchArgs << QString::fromLatin1("", 0);
+ matchArgs.args << QString::fromLatin1("", 0);
break;
case QDBusServiceWatcher::WatchForUnregistration:
- matchArgs << QString() << QString::fromLatin1("", 0);
+ matchArgs.args << QString() << QString::fromLatin1("", 0);
break;
}
return matchArgs;
@@ -1310,7 +1318,7 @@ int QDBusConnectionPrivate::findSlot(QObject* obj, const QByteArray &normalizedN
bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key,
const QString &service,
const QString &path, const QString &interface, const QString &name,
- const QStringList &argMatch,
+ const ArgMatchRules &argMatch,
QObject *receiver, const char *signal, int minMIdx,
bool buildSignature)
{
@@ -1620,14 +1628,14 @@ void QDBusConnectionPrivate::handleSignal(const QString &key, const QDBusMessage
continue;
if (hook.signature.isEmpty() && !hook.signature.isNull() && !msg.signature().isEmpty())
continue;
- if (!hook.argumentMatch.isEmpty()) {
+ if (!hook.argumentMatch.args.isEmpty()) {
const QVariantList arguments = msg.arguments();
- if (hook.argumentMatch.size() > arguments.size())
+ if (hook.argumentMatch.args.size() > arguments.size())
continue;
bool matched = true;
- for (int i = 0; i < hook.argumentMatch.size(); ++i) {
- const QString &param = hook.argumentMatch.at(i);
+ for (int i = 0; i < hook.argumentMatch.args.size(); ++i) {
+ const QString &param = hook.argumentMatch.args.at(i);
if (param.isNull())
continue; // don't try to match against this
if (param == arguments.at(i).toString())
@@ -1638,7 +1646,15 @@ void QDBusConnectionPrivate::handleSignal(const QString &key, const QDBusMessage
if (!matched)
continue;
}
-
+ if (!hook.argumentMatch.arg0namespace.isEmpty()) {
+ const QVariantList arguments = msg.arguments();
+ if (arguments.size() < 1)
+ continue;
+ const QString param = arguments.at(0).toString();
+ if (param != hook.argumentMatch.arg0namespace
+ && !param.startsWith(hook.argumentMatch.arg0namespace + QLatin1Char('.')))
+ continue;
+ }
activateSignal(hook, msg);
}
}
@@ -2180,11 +2196,22 @@ void QDBusConnectionPrivate::sendInternal(QDBusPendingCallPrivate *pcall, void *
}
}
+
bool QDBusConnectionPrivate::connectSignal(const QString &service,
const QString &path, const QString &interface, const QString &name,
const QStringList &argumentMatch, const QString &signature,
QObject *receiver, const char *slot)
{
+ ArgMatchRules rules;
+ rules.args = argumentMatch;
+ return connectSignal(service, path, interface, name, rules, signature, receiver, slot);
+}
+
+bool QDBusConnectionPrivate::connectSignal(const QString &service,
+ const QString &path, const QString &interface, const QString &name,
+ const ArgMatchRules &argumentMatch, const QString &signature,
+ QObject *receiver, const char *slot)
+{
// check the slot
QDBusConnectionPrivate::SignalHook hook;
QString key;
@@ -2241,9 +2268,11 @@ bool QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook
WatchedServicesHash::mapped_type &data = watchedServices[hook.service];
if (++data.refcount == 1) {
// we need to watch for this service changing
+ ArgMatchRules rules;
+ rules.args << hook.service;
q_dbus_bus_add_match(connection,
buildMatchRule(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(),
- QDBusUtil::nameOwnerChanged(), QStringList() << hook.service, QString()),
+ QDBusUtil::nameOwnerChanged(), rules, QString()),
NULL);
data.owner = getNameOwnerNoCache(hook.service);
qDBusDebug() << this << "Watching service" << hook.service << "for owner changes (current owner:"
@@ -2256,8 +2285,18 @@ bool QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook
}
bool QDBusConnectionPrivate::disconnectSignal(const QString &service,
+ const QString &path, const QString &interface, const QString &name,
+ const QStringList &argumentMatch, const QString &signature,
+ QObject *receiver, const char *slot)
+{
+ ArgMatchRules rules;
+ rules.args = argumentMatch;
+ return disconnectSignal(service, path, interface, name, rules, signature, receiver, slot);
+}
+
+bool QDBusConnectionPrivate::disconnectSignal(const QString &service,
const QString &path, const QString &interface, const QString &name,
- const QStringList &argumentMatch, const QString &signature,
+ const ArgMatchRules &argumentMatch, const QString &signature,
QObject *receiver, const char *slot)
{
// check the slot
@@ -2288,7 +2327,7 @@ bool QDBusConnectionPrivate::removeSignalHook(const QString &key, const SignalHo
entry.signature == hook.signature &&
entry.obj == hook.obj &&
entry.midx == hook.midx &&
- entry.argumentMatch == hook.argumentMatch) {
+ entry.argumentMatch.args == hook.argumentMatch.args) {
// no need to compare the parameters if it's the same slot
removeSignalHookNoLock(it);
return true; // it was there
@@ -2330,9 +2369,11 @@ QDBusConnectionPrivate::removeSignalHookNoLock(SignalHookHash::Iterator it)
if (sit != watchedServices.end()) {
if (--sit.value().refcount == 0) {
watchedServices.erase(sit);
+ ArgMatchRules rules;
+ rules.args << hook.service;
q_dbus_bus_remove_match(connection,
buildMatchRule(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(),
- QDBusUtil::nameOwnerChanged(), QStringList() << hook.service, QString()),
+ QDBusUtil::nameOwnerChanged(), rules, QString()),
NULL);
}
}
@@ -2393,7 +2434,7 @@ void QDBusConnectionPrivate::connectRelay(const QString &service,
QByteArray sig;
sig.append(QSIGNAL_CODE + '0');
sig.append(signal.methodSignature());
- if (!prepareHook(hook, key, service, path, interface, QString(), QStringList(), receiver, sig,
+ if (!prepareHook(hook, key, service, path, interface, QString(), ArgMatchRules(), receiver, sig,
QDBusAbstractInterface::staticMetaObject.methodCount(), true))
return; // don't connect
@@ -2414,7 +2455,7 @@ void QDBusConnectionPrivate::disconnectRelay(const QString &service,
QByteArray sig;
sig.append(QSIGNAL_CODE + '0');
sig.append(signal.methodSignature());
- if (!prepareHook(hook, key, service, path, interface, QString(), QStringList(), receiver, sig,
+ if (!prepareHook(hook, key, service, path, interface, QString(), ArgMatchRules(), receiver, sig,
QDBusAbstractInterface::staticMetaObject.methodCount(), true))
return; // don't disconnect
@@ -2447,7 +2488,7 @@ bool QDBusConnectionPrivate::shouldWatchService(const QString &service)
*/
void QDBusConnectionPrivate::watchService(const QString &service, QDBusServiceWatcher::WatchMode mode, QObject *obj, const char *member)
{
- QStringList matchArgs = matchArgsForService(service, mode);
+ ArgMatchRules matchArgs = matchArgsForService(service, mode);
connectSignal(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), QDBusUtil::nameOwnerChanged(),
matchArgs, QString(), obj, member);
}
@@ -2462,7 +2503,7 @@ void QDBusConnectionPrivate::watchService(const QString &service, QDBusServiceWa
*/
void QDBusConnectionPrivate::unwatchService(const QString &service, QDBusServiceWatcher::WatchMode mode, QObject *obj, const char *member)
{
- QStringList matchArgs = matchArgsForService(service, mode);
+ ArgMatchRules matchArgs = matchArgsForService(service, mode);
disconnectSignal(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), QDBusUtil::nameOwnerChanged(),
matchArgs, QString(), obj, member);
}
diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp
index 2a31dd950a..4d0131afff 100644
--- a/src/dbus/qdbuspendingcall.cpp
+++ b/src/dbus/qdbuspendingcall.cpp
@@ -311,7 +311,7 @@ QDBusPendingCall &QDBusPendingCall::operator=(const QDBusPendingCall &other)
\sa QDBusPendingReply::isFinished()
*/
/*!
- \fn bool QDBusPendingReply::isFinished() const
+ \fn template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> bool QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::isFinished() const
Returns \c true if the pending call has finished processing and the
reply has been received. If this function returns \c true, the
@@ -340,7 +340,7 @@ void QDBusPendingCall::waitForFinished()
}
/*!
- \fn bool QDBusPendingReply::isValid() const
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> bool QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::isValid() const
Returns \c true if the reply contains a normal reply message, false
if it contains anything else.
@@ -357,7 +357,7 @@ bool QDBusPendingCall::isValid() const
}
/*!
- \fn bool QDBusPendingReply::isError() const
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> bool QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::isError() const
Returns \c true if the reply contains an error message, false if it
contains a normal method reply.
@@ -374,7 +374,7 @@ bool QDBusPendingCall::isError() const
}
/*!
- \fn QDBusError QDBusPendingReply::error() const
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> QDBusError QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::error() const
Retrieves the error content of the reply message, if it has
finished processing. If the reply message has not finished
@@ -395,7 +395,7 @@ QDBusError QDBusPendingCall::error() const
}
/*!
- \fn QDBusMessage QDBusPendingReply::reply() const
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> QDBusMessage QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::reply() const
Retrieves the reply message received for the asynchronous call
that was sent, if it has finished processing. If the pending call
@@ -445,7 +445,7 @@ bool QDBusPendingCall::setReplyCallback(QObject *target, const char *member)
\since 4.6
Creates a QDBusPendingCall object based on the error condition
\a error. The resulting pending call object will be in the
- "finished" state and QDBusPendingReply::isError() will return true.
+ "finished" state and QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::isError() will return true.
\sa fromCompletedCall()
*/
diff --git a/src/dbus/qdbuspendingcall.h b/src/dbus/qdbuspendingcall.h
index ec8ba6c541..24b1d6a7ca 100644
--- a/src/dbus/qdbuspendingcall.h
+++ b/src/dbus/qdbuspendingcall.h
@@ -67,7 +67,7 @@ public:
void swap(QDBusPendingCall &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
-#ifndef Q_QDOC
+#ifndef Q_CLANG_QDOC
// pretend that they aren't here
bool isFinished() const;
void waitForFinished();
diff --git a/src/dbus/qdbuspendingreply.cpp b/src/dbus/qdbuspendingreply.cpp
index fef6f36432..6aec571563 100644
--- a/src/dbus/qdbuspendingreply.cpp
+++ b/src/dbus/qdbuspendingreply.cpp
@@ -94,7 +94,7 @@
*/
/*!
- \fn QDBusPendingReply::QDBusPendingReply()
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::QDBusPendingReply()
Creates an empty QDBusPendingReply object. Without assigning a
QDBusPendingCall object to this reply, QDBusPendingReply cannot do
@@ -102,7 +102,7 @@
*/
/*!
- \fn QDBusPendingReply::QDBusPendingReply(const QDBusPendingReply &other)
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::QDBusPendingReply(const QDBusPendingReply &other)
Creates a copy of the \a other QDBusPendingReply object. Just like
QDBusPendingCall and QDBusPendingCallWatcher, this QDBusPendingReply
@@ -111,7 +111,7 @@
*/
/*!
- \fn QDBusPendingReply::QDBusPendingReply(const QDBusPendingCall &call)
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::QDBusPendingReply(const QDBusPendingCall &call)
Creates a QDBusPendingReply object that will take its contents from
the \a call pending asynchronous call. This QDBusPendingReply object
@@ -119,7 +119,7 @@
*/
/*!
- \fn QDBusPendingReply::QDBusPendingReply(const QDBusMessage &message)
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::QDBusPendingReply(const QDBusMessage &message)
Creates a QDBusPendingReply object that will take its contents from
the message \a message. In this case, this object will be already
@@ -129,7 +129,7 @@
*/
/*!
- \fn QDBusPendingReply &QDBusPendingReply::operator=(const QDBusPendingReply &other)
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> QDBusPendingReply &QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::operator=(const QDBusPendingReply &other)
Makes a copy of \a other and drops the reference to the current
pending call. If the current reference is to an unfinished pending
@@ -139,7 +139,7 @@
*/
/*!
- \fn QDBusPendingReply &QDBusPendingReply::operator=(const QDBusPendingCall &call)
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> QDBusPendingReply &QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::operator=(const QDBusPendingCall &call)
Makes this object take its contents from the \a call pending call
and drops the reference to the current pending call. If the
@@ -149,7 +149,7 @@
*/
/*!
- \fn QDBusPendingReply &QDBusPendingReply::operator=(const QDBusMessage &message)
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> QDBusPendingReply &QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::operator=(const QDBusMessage &message)
Makes this object take its contents from the \a message message
and drops the reference to the current pending call. If the
@@ -171,7 +171,7 @@
*/
/*!
- \fn int QDBusPendingReply::count() const
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> int QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::count() const
Return the number of arguments the reply is supposed to have. This
number matches the number of non-void template parameters in this
@@ -183,7 +183,7 @@
*/
/*!
- \fn QVariant QDBusPendingReply::argumentAt(int index) const
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> QVariant QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::argumentAt(int index) const
Returns the argument at position \a index in the reply's
contents. If the reply doesn't have that many elements, this
@@ -198,12 +198,7 @@
*/
/*!
- \typedef QDBusPendingReply::T1
- \internal
- */
-
-/*!
- \fn T1 QDBusPendingReply::value() const
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> T1 QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::value() const
Returns the first argument in this reply, cast to type \c T1 (the
first template parameter of this class). This is equivalent to
@@ -221,7 +216,7 @@
*/
/*!
- \fn QDBusPendingReply::operator T1() const
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::operator T1() const
Returns the first argument in this reply, cast to type \c T1 (the
first template parameter of this class). This is equivalent to
@@ -239,7 +234,7 @@
*/
/*!
- \fn void QDBusPendingReply::waitForFinished()
+ \fn template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> void QDBusPendingReply<T1, T2, T3, T4, T5, T6, T7, T8>::waitForFinished()
Suspends the execution of the calling thread until the reply is
received and processed. After this function returns, isFinished()
diff --git a/src/dbus/qdbuspendingreply.h b/src/dbus/qdbuspendingreply.h
index 4d2c3a7c5a..bc5cd92c84 100644
--- a/src/dbus/qdbuspendingreply.h
+++ b/src/dbus/qdbuspendingreply.h
@@ -108,10 +108,8 @@ namespace QDBusPendingReplyTypes {
template <> struct NotVoid<void> { typedef TypeIsVoid Type; };
} // namespace QDBusPendingReplyTypes
-#ifndef Q_CLANG_QDOC
template<typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
-#endif
class QDBusPendingReply:
#ifdef Q_CLANG_QDOC
public QDBusPendingCall
@@ -171,7 +169,6 @@ public:
QDBusError error() const;
QDBusMessage reply() const;
- typedef QVariant T1;
inline T1 value() const;
inline operator T1() const;
#else
diff --git a/src/dbus/qdbusreply.cpp b/src/dbus/qdbusreply.cpp
index ab361f1674..6abfaf174c 100644
--- a/src/dbus/qdbusreply.cpp
+++ b/src/dbus/qdbusreply.cpp
@@ -81,7 +81,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn template<typename T> QDBusReply<T>::QDBusReply(const QDBusPendingReply &reply)
+ \fn template<typename T> QDBusReply<T>::QDBusReply(const QDBusPendingReply<T> &reply)
Constructs a QDBusReply object from the pending reply message, \a reply.
*/
diff --git a/src/dbus/qdbusreply.h b/src/dbus/qdbusreply.h
index 177b6c6e89..869687ac85 100644
--- a/src/dbus/qdbusreply.h
+++ b/src/dbus/qdbusreply.h
@@ -82,14 +82,10 @@ public:
other.waitForFinished();
return *this = other.reply();
}
-#if defined(Q_CLANG_QDOC)
- inline QDBusReply(const QDBusPendingReply &reply) { }
-#else
inline QDBusReply(const QDBusPendingReply<T> &reply)
{
*this = static_cast<QDBusPendingCall>(reply);
}
-#endif
inline QDBusReply(const QDBusError &dbusError = QDBusError())
: m_error(dbusError), m_data(Type())
diff --git a/src/dbus/qdbusservicewatcher.cpp b/src/dbus/qdbusservicewatcher.cpp
index 0c2fb9118f..b0bfe7254d 100644
--- a/src/dbus/qdbusservicewatcher.cpp
+++ b/src/dbus/qdbusservicewatcher.cpp
@@ -139,6 +139,17 @@ void QDBusServiceWatcherPrivate::removeService(const QString &service)
QDBusConnectionInterface::serviceOwnerChanged() signal because it allows
one to receive only the signals for which the class is interested in.
+ Ending a service name with the character '*' will match all service names
+ within the specified namespace.
+
+ For example "com.example.backend1*" will match
+ \list
+ \li com.example.backend1
+ \li com.example.backend1.foo
+ \li com.example.backend1.foo.bar
+ \endlist
+ Substrings in the same domain will not be matched, i.e "com.example.backend12".
+
\sa QDBusConnection
*/
diff --git a/src/dbus/qdbusutil.cpp b/src/dbus/qdbusutil.cpp
index 28341a71a8..dc94897ac4 100644
--- a/src/dbus/qdbusutil.cpp
+++ b/src/dbus/qdbusutil.cpp
@@ -331,8 +331,8 @@ namespace QDBusUtil
/*!
\internal
- \fn bool QDBusUtil::isValidPartOfObjectPath(const QStringRef &part)
- See QDBusUtil::isValidObjectPath
+ \fn bool isValidPartOfObjectPath(const QStringRef &part)
+ See isValidObjectPath
*/
bool isValidPartOfObjectPath(const QStringRef &part)
{
@@ -349,13 +349,13 @@ namespace QDBusUtil
/*!
\internal
- \fn bool QDBusUtil::isValidPartOfObjectPath(const QString &part)
+ \fn bool isValidPartOfObjectPath(const QString &part)
\overload
*/
/*!
- \fn bool QDBusUtil::isValidInterfaceName(const QString &ifaceName)
+ \fn bool isValidInterfaceName(const QString &ifaceName)
Returns \c true if this is \a ifaceName is a valid interface name.
Valid interface names must:
@@ -384,7 +384,7 @@ namespace QDBusUtil
}
/*!
- \fn bool QDBusUtil::isValidUniqueConnectionName(const QStringRef &connName)
+ \fn bool isValidUniqueConnectionName(const QStringRef &connName)
Returns \c true if \a connName is a valid unique connection name.
Unique connection names start with a colon (":") and are followed by a list of dot-separated
@@ -414,13 +414,13 @@ namespace QDBusUtil
}
/*!
- \fn bool QDBusUtil::isValidUniqueConnectionName(const QString &connName)
+ \fn bool isValidUniqueConnectionName(const QString &connName)
\overload
*/
/*!
- \fn bool QDBusUtil::isValidBusName(const QString &busName)
+ \fn bool isValidBusName(const QString &busName)
Returns \c true if \a busName is a valid bus name.
A valid bus name is either a valid unique connection name or follows the rules:
@@ -462,7 +462,7 @@ namespace QDBusUtil
}
/*!
- \fn bool QDBusUtil::isValidMemberName(const QStringRef &memberName)
+ \fn bool isValidMemberName(const QStringRef &memberName)
Returns \c true if \a memberName is a valid member name. A valid member name does not exceed
255 characters in length, is not empty, is composed only of ASCII letters, digits and
underscores, but does not start with a digit.
@@ -482,13 +482,13 @@ namespace QDBusUtil
}
/*!
- \fn bool QDBusUtil::isValidMemberName(const QString &memberName)
+ \fn bool isValidMemberName(const QString &memberName)
\overload
*/
/*!
- \fn bool QDBusUtil::isValidErrorName(const QString &errorName)
+ \fn bool isValidErrorName(const QString &errorName)
Returns \c true if \a errorName is a valid error name. Valid error names are valid interface
names and vice-versa, so this function is actually an alias for isValidInterfaceName.
*/
@@ -498,7 +498,7 @@ namespace QDBusUtil
}
/*!
- \fn bool QDBusUtil::isValidObjectPath(const QString &path)
+ \fn bool isValidObjectPath(const QString &path)
Returns \c true if \a path is valid object path.
Valid object paths follow the rules:
@@ -529,7 +529,7 @@ namespace QDBusUtil
}
/*!
- \fn bool QDBusUtil::isValidBasicType(int type)
+ \fn bool isValidBasicType(int type)
Returns \c true if \a c is a valid, basic D-Bus type.
*/
bool isValidBasicType(int c)
@@ -538,7 +538,7 @@ namespace QDBusUtil
}
/*!
- \fn bool QDBusUtil::isValidFixedType(int type)
+ \fn bool isValidFixedType(int type)
Returns \c true if \a c is a valid, fixed D-Bus type.
*/
bool isValidFixedType(int c)
@@ -548,7 +548,7 @@ namespace QDBusUtil
/*!
- \fn bool QDBusUtil::isValidSignature(const QString &signature)
+ \fn bool isValidSignature(const QString &signature)
Returns \c true if \a signature is a valid D-Bus type signature for one or more types.
This function returns \c true if it can all of \a signature into valid, individual types and no
characters remain in \a signature.
@@ -569,7 +569,7 @@ namespace QDBusUtil
}
/*!
- \fn bool QDBusUtil::isValidSingleSignature(const QString &signature)
+ \fn bool isValidSingleSignature(const QString &signature)
Returns \c true if \a signature is a valid D-Bus type signature for exactly one full type. This
function tries to convert the type signature into a D-Bus type and, if it succeeds and no
characters remain in the signature, it returns \c true.
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h
index 1309f17efd..e2163b06d0 100644
--- a/src/gui/accessible/qaccessible.h
+++ b/src/gui/accessible/qaccessible.h
@@ -966,8 +966,10 @@ protected:
int m_lastColumn;
};
+#ifndef Q_CLANG_QDOC
#define QAccessibleInterface_iid "org.qt-project.Qt.QAccessibleInterface"
Q_DECLARE_INTERFACE(QAccessibleInterface, QAccessibleInterface_iid)
+#endif
Q_GUI_EXPORT const char *qAccessibleRoleString(QAccessible::Role role);
Q_GUI_EXPORT const char *qAccessibleEventString(QAccessible::Event event);
diff --git a/src/gui/accessible/qaccessibleobject.h b/src/gui/accessible/qaccessibleobject.h
index 81479c32ab..fd07d33a18 100644
--- a/src/gui/accessible/qaccessibleobject.h
+++ b/src/gui/accessible/qaccessibleobject.h
@@ -65,7 +65,7 @@ public:
QAccessibleInterface *childAt(int x, int y) const override;
protected:
- virtual ~QAccessibleObject();
+ ~QAccessibleObject();
private:
QAccessibleObjectPrivate *d;
diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication_x11.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication_x11.cpp
index e91aa3d548..961ecd6cde 100644
--- a/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication_x11.cpp
+++ b/src/gui/doc/snippets/code/src_gui_kernel_qguiapplication_x11.cpp
@@ -49,7 +49,7 @@
****************************************************************************/
//! [0]
-QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
calculateHugeMandelbrot(); // lunch time...
-QApplication::restoreOverrideCursor();
+QGuiApplication::restoreOverrideCursor();
//! [0]
diff --git a/src/gui/doc/src/richtext.qdoc b/src/gui/doc/src/richtext.qdoc
index a0f739d418..a8ba076e3d 100644
--- a/src/gui/doc/src/richtext.qdoc
+++ b/src/gui/doc/src/richtext.qdoc
@@ -1197,6 +1197,9 @@
\row \li \c text-transform
\li [ uppercase | lowercase ]
\li Select the transformation that will be performed on the text prior to displaying it.
+ \row \li \c font-kerning
+ \li [ normal | none ]
+ \li Enables or disables kerning between text characters.
\row \li \c font-variant
\li small-caps
\li Perform the smallcaps transformation on the text prior to displaying it.
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index c362d0dc3f..285cdf790a 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1080,11 +1080,12 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
if (!d) {
QFileInfo info(fileName);
- QIconEngine *engine = iconEngineFromSuffix(fileName, info.suffix());
+ QString suffix = info.suffix();
#if QT_CONFIG(mimetype)
- if (!engine)
- engine = iconEngineFromSuffix(fileName, QMimeDatabase().mimeTypeForFile(info).preferredSuffix());
+ if (suffix.isEmpty())
+ suffix = QMimeDatabase().mimeTypeForFile(info).preferredSuffix(); // determination from contents
#endif // mimetype
+ QIconEngine *engine = iconEngineFromSuffix(fileName, suffix);
d = new QIconPrivate(engine ? engine : new QPixmapIconEngine);
}
diff --git a/src/gui/image/qimageiohandler.h b/src/gui/image/qimageiohandler.h
index 35984dd6a5..990df96534 100644
--- a/src/gui/image/qimageiohandler.h
+++ b/src/gui/image/qimageiohandler.h
@@ -141,7 +141,7 @@ class Q_GUI_EXPORT QImageIOPlugin : public QObject
Q_OBJECT
public:
explicit QImageIOPlugin(QObject *parent = nullptr);
- virtual ~QImageIOPlugin();
+ ~QImageIOPlugin();
enum Capability {
CanRead = 0x1,
diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp
index 53e3fa293d..bfde0aa76e 100644
--- a/src/gui/image/qppmhandler.cpp
+++ b/src/gui/image/qppmhandler.cpp
@@ -68,13 +68,19 @@ static int read_pbm_int(QIODevice *d)
char c;
int val = -1;
bool digit;
+ bool hasOverflow = false;
for (;;) {
if (!d->getChar(&c)) // end of file
break;
digit = isdigit((uchar) c);
if (val != -1) {
if (digit) {
- val = 10*val + c - '0';
+ const int cValue = c - '0';
+ if (val <= (INT_MAX - cValue) / 10) {
+ val = 10*val + cValue;
+ } else {
+ hasOverflow = true;
+ }
continue;
} else {
if (c == '#') // comment
@@ -91,7 +97,7 @@ static int read_pbm_int(QIODevice *d)
else
break;
}
- return val;
+ return hasOverflow ? -1 : val;
}
static bool read_pbm_header(QIODevice *device, char& type, int& w, int& h, int& mcc)
@@ -123,7 +129,7 @@ static bool read_pbm_header(QIODevice *device, char& type, int& w, int& h, int&
static inline QRgb scale_pbm_color(quint16 mx, quint16 rv, quint16 gv, quint16 bv)
{
- return QRgba64::fromRgba64((rv * 0xffff) / mx, (gv * 0xffff) / mx, (bv * 0xffff) / mx, 0xffff).toArgb32();
+ return QRgba64::fromRgba64((rv * 0xffffu) / mx, (gv * 0xffffu) / mx, (bv * 0xffffu) / mx, 0xffff).toArgb32();
}
static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, QImage *outImage)
@@ -252,7 +258,7 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
}
} else {
while (n--) {
- *p++ = read_pbm_int(device) * 255 / mcc;
+ *p++ = (read_pbm_int(device) & 0xffff) * 255 / mcc;
}
}
} else { // 32 bits
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp
index 8ec88ebc60..aa640f4d7e 100644
--- a/src/gui/itemmodels/qstandarditemmodel.cpp
+++ b/src/gui/itemmodels/qstandarditemmodel.cpp
@@ -3010,11 +3010,17 @@ bool QStandardItemModel::setData(const QModelIndex &index, const QVariant &value
return true;
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+/*!
+ \reimp
+ */
+#else
/*!
\since 5.12
Removes the data stored in all the roles for the given \a index.
\sa setData(), data()
*/
+#endif
bool QStandardItemModel::clearItemData(const QModelIndex &index)
{
if (!checkIndex(index, CheckIndexOption::IndexIsValid))
diff --git a/src/gui/itemmodels/qstandarditemmodel_p.h b/src/gui/itemmodels/qstandarditemmodel_p.h
index 00e83f7b08..23d2938bc4 100644
--- a/src/gui/itemmodels/qstandarditemmodel_p.h
+++ b/src/gui/itemmodels/qstandarditemmodel_p.h
@@ -207,7 +207,7 @@ class QStandardItemModelPrivate : public QAbstractItemModelPrivate
public:
QStandardItemModelPrivate();
- virtual ~QStandardItemModelPrivate();
+ ~QStandardItemModelPrivate();
void init();
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index 02dffef0fe..5ea72fa0f6 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -86,7 +86,7 @@ public:
#else
QGuiApplication(int &argc, char **argv, int = ApplicationFlags);
#endif
- virtual ~QGuiApplication();
+ ~QGuiApplication();
static void setApplicationDisplayName(const QString &name);
static QString applicationDisplayName();
diff --git a/src/gui/kernel/qoffscreensurface.h b/src/gui/kernel/qoffscreensurface.h
index 9d4839cb25..1b9e7c00ca 100644
--- a/src/gui/kernel/qoffscreensurface.h
+++ b/src/gui/kernel/qoffscreensurface.h
@@ -60,7 +60,7 @@ public:
// ### Qt 6: merge overloads
explicit QOffscreenSurface(QScreen *screen, QObject *parent);
explicit QOffscreenSurface(QScreen *screen = nullptr);
- virtual ~QOffscreenSurface();
+ ~QOffscreenSurface();
SurfaceType surfaceType() const override;
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index 4f2f951d61..1cb7390687 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -219,7 +219,7 @@ public:
requestedFormat = QSurfaceFormat::defaultFormat();
}
- virtual ~QOpenGLContextPrivate()
+ ~QOpenGLContextPrivate()
{
//do not delete the QOpenGLContext handle here as it is deleted in
//QWidgetPrivate::deleteTLSysExtra()
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index b787629f6a..6a0adca9ca 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -61,6 +61,18 @@ QT_BEGIN_NAMESPACE
*/
+/*!
+ \enum QPlatformDialogHelper::StyleHint
+
+ This enum type specifies platform-specific style hints.
+
+ \value DialogIsQtWindow Indicates that a platform-specific dialog is implemented
+ as in-process Qt window. It allows to prevent blocking the
+ dialog by an invisible proxy Qt dialog.
+
+ \sa styleHint()
+*/
+
static const int buttonRoleLayouts[2][6][14] =
{
// Qt::Horizontal
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
index bfcb658172..0832e19dc3 100644
--- a/src/gui/kernel/qplatformdialoghelper.h
+++ b/src/gui/kernel/qplatformdialoghelper.h
@@ -80,6 +80,7 @@ class Q_GUI_EXPORT QPlatformDialogHelper : public QObject
Q_OBJECT
public:
enum StyleHint {
+ DialogIsQtWindow
};
enum DialogCode { Rejected, Accepted };
@@ -153,7 +154,7 @@ public:
Q_ENUM(ButtonLayout)
QPlatformDialogHelper();
- virtual ~QPlatformDialogHelper();
+ ~QPlatformDialogHelper();
virtual QVariant styleHint(StyleHint hint) const;
diff --git a/src/gui/kernel/qplatformgraphicsbuffer.h b/src/gui/kernel/qplatformgraphicsbuffer.h
index 0aeef946e6..65c24bebc9 100644
--- a/src/gui/kernel/qplatformgraphicsbuffer.h
+++ b/src/gui/kernel/qplatformgraphicsbuffer.h
@@ -78,7 +78,7 @@ public:
OriginTopLeft
};
- virtual ~QPlatformGraphicsBuffer();
+ ~QPlatformGraphicsBuffer();
AccessTypes isLocked() const { return m_lock_access; }
bool lock(AccessTypes access, const QRect &rect = QRect());
diff --git a/src/gui/kernel/qplatforminputcontext.h b/src/gui/kernel/qplatforminputcontext.h
index 26d40cd2c6..ad0e5bcf35 100644
--- a/src/gui/kernel/qplatforminputcontext.h
+++ b/src/gui/kernel/qplatforminputcontext.h
@@ -67,7 +67,7 @@ public:
};
QPlatformInputContext();
- virtual ~QPlatformInputContext();
+ ~QPlatformInputContext();
virtual bool isValid() const;
virtual bool hasCapability(Capability capability) const;
diff --git a/src/gui/kernel/qsessionmanager_p.h b/src/gui/kernel/qsessionmanager_p.h
index 954443430e..d07d9b5eb8 100644
--- a/src/gui/kernel/qsessionmanager_p.h
+++ b/src/gui/kernel/qsessionmanager_p.h
@@ -69,7 +69,7 @@ public:
QSessionManagerPrivate(const QString &id,
const QString &key);
- virtual ~QSessionManagerPrivate();
+ ~QSessionManagerPrivate();
QPlatformSessionManager *platformSessionManager;
};
diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h
index f9e8a83a39..8638b05155 100644
--- a/src/gui/kernel/qsimpledrag_p.h
+++ b/src/gui/kernel/qsimpledrag_p.h
@@ -71,7 +71,7 @@ class QScreen;
class Q_GUI_EXPORT QBasicDrag : public QPlatformDrag, public QObject
{
public:
- virtual ~QBasicDrag();
+ ~QBasicDrag();
virtual Qt::DropAction drag(QDrag *drag) override;
void cancelDrag() override;
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index bc2d6e6a17..944e7d6139 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -1331,16 +1331,18 @@ Qt::WindowStates QWindow::windowStates() const
*/
/*!
- Sets the transient \a parent
+ \property QWindow::transientParent
+ \brief the window for which this window is a transient pop-up
+ \since 5.13
This is a hint to the window manager that this window is a dialog or pop-up
- on behalf of the given window.
+ on behalf of the transient parent.
In order to cause the window to be centered above its transient parent by
default, depending on the window manager, it may also be necessary to call
setFlags() with a suitable \l Qt::WindowType (such as \c Qt::Dialog).
- \sa transientParent(), parent()
+ \sa parent()
*/
void QWindow::setTransientParent(QWindow *parent)
{
@@ -1357,19 +1359,28 @@ void QWindow::setTransientParent(QWindow *parent)
d->transientParent = parent;
QGuiApplicationPrivate::updateBlockedStatus(this);
+ emit transientParentChanged(parent);
}
-/*!
- Returns the transient parent of the window.
-
- \sa setTransientParent(), parent()
-*/
QWindow *QWindow::transientParent() const
{
Q_D(const QWindow);
return d->transientParent.data();
}
+/*
+ The setter for the QWindow::transientParent property.
+ The only reason this exists is to set the transientParentPropertySet flag
+ so that Qt Quick knows whether it was set programmatically (because of
+ Window declaration context) or because the user set the property.
+*/
+void QWindowPrivate::setTransientParent(QWindow *parent)
+{
+ Q_Q(QWindow);
+ q->setTransientParent(parent);
+ transientParentPropertySet = true;
+}
+
/*!
\enum QWindow::AncestorMode
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 439e62d0bd..1be3c845fe 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -123,6 +123,7 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface
Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged REVISION 1)
Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged)
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged REVISION 1)
+ Q_PRIVATE_PROPERTY(QWindow::d_func(), QWindow* transientParent MEMBER transientParent WRITE setTransientParent NOTIFY transientParentChanged REVISION 13)
public:
enum Visibility {
@@ -143,7 +144,7 @@ public:
explicit QWindow(QScreen *screen = nullptr);
explicit QWindow(QWindow *parent);
- virtual ~QWindow();
+ ~QWindow();
void setSurfaceType(SurfaceType surfaceType);
SurfaceType surfaceType() const override;
@@ -336,6 +337,8 @@ Q_SIGNALS:
Q_REVISION(1) void opacityChanged(qreal opacity);
+ Q_REVISION(13) void transientParentChanged(QWindow *transientParent);
+
protected:
virtual void exposeEvent(QExposeEvent *);
virtual void resizeEvent(QResizeEvent *);
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index bf5e645114..25f9a8a9b2 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -148,6 +148,7 @@ public:
void disconnectFromScreen();
void emitScreenChangedRecursion(QScreen *newScreen);
QScreen *screenForGeometry(const QRect &rect);
+ void setTransientParent(QWindow *parent);
virtual void clearFocusObject();
virtual QRectF closestAcceptableGeometry(const QRectF &rect) const;
@@ -191,6 +192,7 @@ public:
bool blockedByModalWindow;
bool updateRequestPending;
+ bool transientParentPropertySet = false;
QPointer<QWindow> transientParent;
QPointer<QScreen> topLevelScreen;
diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp
index 3a476978e7..e961c42a25 100644
--- a/src/gui/opengl/qopengl.cpp
+++ b/src/gui/opengl/qopengl.cpp
@@ -54,8 +54,6 @@
#include <QtCore/QFile>
#include <QtCore/QDir>
-#include <set>
-
QT_BEGIN_NAMESPACE
#if defined(QT_OPENGL_3)
@@ -527,13 +525,4 @@ QOpenGLConfig::Gpu QOpenGLConfig::Gpu::fromContext()
return gpu;
}
-Q_GUI_EXPORT std::set<QByteArray> *qgpu_features(const QString &filename)
-{
- const QSet<QString> features = QOpenGLConfig::gpuFeatures(QOpenGLConfig::Gpu::fromContext(), filename);
- std::set<QByteArray> *result = new std::set<QByteArray>;
- for (const QString &feature : features)
- result->insert(feature.toUtf8());
- return result;
-}
-
QT_END_NAMESPACE
diff --git a/src/gui/opengl/qopenglfunctions.h b/src/gui/opengl/qopenglfunctions.h
index 00287b0665..4554291bbd 100644
--- a/src/gui/opengl/qopenglfunctions.h
+++ b/src/gui/opengl/qopenglfunctions.h
@@ -228,26 +228,8 @@ struct QOpenGLFunctionsPrivate;
#undef glTexLevelParameteriv
#if defined(Q_CLANG_QDOC)
-#undef GLint
-typedef int GLint;
-#undef GLsizei
-typedef int GLsizei;
-#undef GLuint
-typedef unsigned int GLuint;
-#undef GLubyte
-typedef unsigned int GLubyte;
-#undef GLenum
-typedef unsigned int GLenum;
#undef GLbitfield
typedef unsigned int GLbitfield;
-#undef GLfloat
-typedef float GLfloat;
-#undef GLclampf
-typedef float GLclampf;
-#undef GLboolean
-typedef bool GLboolean;
-#undef GLvoid
-typedef void GLvoid;
#undef GLchar
typedef char GLchar;
#endif
diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h
index 300002a9c1..54118f2926 100644
--- a/src/gui/opengl/qopenglpaintdevice.h
+++ b/src/gui/opengl/qopenglpaintdevice.h
@@ -59,7 +59,7 @@ public:
QOpenGLPaintDevice();
explicit QOpenGLPaintDevice(const QSize &size);
QOpenGLPaintDevice(int width, int height);
- virtual ~QOpenGLPaintDevice();
+ ~QOpenGLPaintDevice();
int devType() const override { return QInternal::OpenGL; }
QPaintEngine *paintEngine() const override;
diff --git a/src/gui/opengl/qopenglshaderprogram.h b/src/gui/opengl/qopenglshaderprogram.h
index 84eb8d6956..c79101fd4d 100644
--- a/src/gui/opengl/qopenglshaderprogram.h
+++ b/src/gui/opengl/qopenglshaderprogram.h
@@ -50,13 +50,6 @@
#include <QtGui/qvector4d.h>
#include <QtGui/qmatrix4x4.h>
-#if defined(Q_CLANG_QDOC)
-#undef GLint
-typedef int GLint;
-#undef GLfloat
-typedef double GLfloat;
-#endif
-
QT_BEGIN_NAMESPACE
@@ -80,7 +73,7 @@ public:
Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)
explicit QOpenGLShader(QOpenGLShader::ShaderType type, QObject *parent = nullptr);
- virtual ~QOpenGLShader();
+ ~QOpenGLShader();
QOpenGLShader::ShaderType shaderType() const;
@@ -115,7 +108,7 @@ class Q_GUI_EXPORT QOpenGLShaderProgram : public QObject
Q_OBJECT
public:
explicit QOpenGLShaderProgram(QObject *parent = nullptr);
- virtual ~QOpenGLShaderProgram();
+ ~QOpenGLShaderProgram();
bool addShader(QOpenGLShader *shader);
void removeShader(QOpenGLShader *shader);
diff --git a/src/gui/opengl/qopenglversionfunctions.h b/src/gui/opengl/qopenglversionfunctions.h
index 3af1ed0466..f828e5668b 100644
--- a/src/gui/opengl/qopenglversionfunctions.h
+++ b/src/gui/opengl/qopenglversionfunctions.h
@@ -214,6 +214,7 @@ public:
virtual bool initializeOpenGLFunctions();
+ Q_DISABLE_COPY(QAbstractOpenGLFunctions)
Q_DECLARE_PRIVATE(QAbstractOpenGLFunctions)
protected:
diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp
index 2dd5144e40..348eceb47f 100644
--- a/src/gui/painting/qblendfunctions.cpp
+++ b/src/gui/painting/qblendfunctions.cpp
@@ -187,19 +187,11 @@ void qt_blend_rgb16_on_rgb16(uchar *dst, int dbpl,
#endif
if (const_alpha == 256) {
- if (w <= 64) {
- while (h--) {
- QT_MEMCPY_USHORT(dst, src, w);
- dst += dbpl;
- src += sbpl;
- }
- } else {
- int length = w << 1;
- while (h--) {
- memcpy(dst, src, length);
- dst += dbpl;
- src += sbpl;
- }
+ int length = w << 1;
+ while (h--) {
+ memcpy(dst, src, length);
+ dst += dbpl;
+ src += sbpl;
}
} else if (const_alpha != 0) {
quint16 *d = (quint16 *) dst;
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 1d7375d1df..ef3296a6d4 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -2487,6 +2487,15 @@ QColor QColor::fromHslF(qreal h, qreal s, qreal l, qreal a)
return color;
}
+/*!
+ \obsolete
+
+ Use the \c const overload instead.
+*/
+void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a)
+{
+ const_cast<const QColor *>(this)->getCmyk(c, m, y, k, a);
+}
/*!
Sets the contents pointed to by \a c, \a m, \a y, \a k, and \a a, to the
@@ -2498,7 +2507,7 @@ QColor QColor::fromHslF(qreal h, qreal s, qreal l, qreal a)
\sa setCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model}
*/
-void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a)
+void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a) const
{
if (!c || !m || !y || !k)
return;
@@ -2518,6 +2527,16 @@ void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a)
}
/*!
+ \obsolete
+
+ Use the \c const overload instead.
+*/
+void QColor::getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a)
+{
+ const_cast<const QColor *>(this)->getCmykF(c, m, y, k, a);
+}
+
+/*!
Sets the contents pointed to by \a c, \a m, \a y, \a k, and \a a, to the
cyan, magenta, yellow, black, and alpha-channel (transparency) components
of the color's CMYK value.
@@ -2527,7 +2546,7 @@ void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a)
\sa setCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model}
*/
-void QColor::getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a)
+void QColor::getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a) const
{
if (!c || !m || !y || !k)
return;
diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h
index f7a9e9db59..a9b05ae7e3 100644
--- a/src/gui/painting/qcolor.h
+++ b/src/gui/painting/qcolor.h
@@ -172,10 +172,12 @@ public:
qreal yellowF() const Q_DECL_NOTHROW;
qreal blackF() const Q_DECL_NOTHROW;
- void getCmyk(int *c, int *m, int *y, int *k, int *a = nullptr);
+ void getCmyk(int *c, int *m, int *y, int *k, int *a = nullptr); // ### Qt 6: remove
+ void getCmyk(int *c, int *m, int *y, int *k, int *a = nullptr) const;
void setCmyk(int c, int m, int y, int k, int a = 255);
- void getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a = nullptr);
+ void getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a = nullptr); // ### Qt 6: remove
+ void getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a = nullptr) const;
void setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a = 1.0);
int hslHue() const Q_DECL_NOTHROW; // 0 <= hue < 360
diff --git a/src/gui/painting/qcompositionfunctions.cpp b/src/gui/painting/qcompositionfunctions.cpp
index 027bf23115..5c1afe8425 100644
--- a/src/gui/painting/qcompositionfunctions.cpp
+++ b/src/gui/painting/qcompositionfunctions.cpp
@@ -1107,7 +1107,7 @@ static inline uint multiply_op_rgb64(uint dst, uint src, uint da, uint sa)
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Multiply_impl(uint *dest, int length, uint color, const T &coverage)
+static inline void comp_func_solid_Multiply_impl(uint *dest, int length, uint color, const T &coverage)
{
int sa = qAlpha(color);
int sr = qRed(color);
@@ -1130,7 +1130,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Multiply_impl(uint *dest,
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Multiply_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
+static inline void comp_func_solid_Multiply_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
{
uint sa = color.alpha();
uint sr = color.red();
@@ -1169,7 +1169,7 @@ void QT_FASTCALL comp_func_solid_Multiply_rgb64(QRgba64 *dest, int length, QRgba
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Multiply_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Multiply_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
uint d = dest[i];
@@ -1190,7 +1190,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Multiply_impl(uint *Q_DECL_REST
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Multiply_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Multiply_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
QRgba64 d = dest[i];
@@ -1231,7 +1231,7 @@ void QT_FASTCALL comp_func_Multiply_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const Q
= Sca + Dca - Sca.Dca
*/
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Screen_impl(uint *dest, int length, uint color, const T &coverage)
+static inline void comp_func_solid_Screen_impl(uint *dest, int length, uint color, const T &coverage)
{
int sa = qAlpha(color);
int sr = qRed(color);
@@ -1254,7 +1254,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Screen_impl(uint *dest, i
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Screen_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
+static inline void comp_func_solid_Screen_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
{
uint sa = color.alpha();
uint sr = color.red();
@@ -1293,7 +1293,7 @@ void QT_FASTCALL comp_func_solid_Screen_rgb64(QRgba64 *dest, int length, QRgba64
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Screen_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Screen_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
uint d = dest[i];
@@ -1314,7 +1314,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Screen_impl(uint *Q_DECL_RESTRI
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Screen_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Screen_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
QRgba64 d = dest[i];
@@ -1375,7 +1375,7 @@ static inline uint overlay_op_rgb64(uint dst, uint src, uint da, uint sa)
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Overlay_impl(uint *dest, int length, uint color, const T &coverage)
+static inline void comp_func_solid_Overlay_impl(uint *dest, int length, uint color, const T &coverage)
{
int sa = qAlpha(color);
int sr = qRed(color);
@@ -1398,7 +1398,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Overlay_impl(uint *dest,
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Overlay_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
+static inline void comp_func_solid_Overlay_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
{
uint sa = color.alpha();
uint sr = color.red();
@@ -1437,7 +1437,7 @@ void QT_FASTCALL comp_func_solid_Overlay_rgb64(QRgba64 *dest, int length, QRgba6
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Overlay_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Overlay_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
uint d = dest[i];
@@ -1458,7 +1458,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Overlay_impl(uint *Q_DECL_RESTR
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Overlay_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Overlay_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
QRgba64 d = dest[i];
@@ -1509,7 +1509,7 @@ static inline uint darken_op_rgb64(uint dst, uint src, uint da, uint sa)
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Darken_impl(uint *dest, int length, uint color, const T &coverage)
+static inline void comp_func_solid_Darken_impl(uint *dest, int length, uint color, const T &coverage)
{
int sa = qAlpha(color);
int sr = qRed(color);
@@ -1532,7 +1532,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Darken_impl(uint *dest, i
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Darken_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
+static inline void comp_func_solid_Darken_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
{
uint sa = color.alpha();
uint sr = color.red();
@@ -1571,7 +1571,7 @@ void QT_FASTCALL comp_func_solid_Darken_rgb64(QRgba64 *dest, int length, QRgba64
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Darken_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Darken_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
uint d = dest[i];
@@ -1592,7 +1592,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Darken_impl(uint *Q_DECL_RESTRI
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Darken_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Darken_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
QRgba64 d = dest[i];
@@ -1643,7 +1643,7 @@ static inline uint lighten_op_rgb64(uint dst, uint src, uint da, uint sa)
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Lighten_impl(uint *dest, int length, uint color, const T &coverage)
+static inline void comp_func_solid_Lighten_impl(uint *dest, int length, uint color, const T &coverage)
{
int sa = qAlpha(color);
int sr = qRed(color);
@@ -1666,7 +1666,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Lighten_impl(uint *dest,
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Lighten_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
+static inline void comp_func_solid_Lighten_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
{
uint sa = color.alpha();
uint sr = color.red();
@@ -1705,7 +1705,7 @@ void QT_FASTCALL comp_func_solid_Lighten_rgb64(QRgba64 *dest, int length, QRgba6
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Lighten_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Lighten_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
uint d = dest[i];
@@ -1726,7 +1726,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Lighten_impl(uint *Q_DECL_RESTR
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Lighten_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Lighten_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
QRgba64 d = dest[i];
@@ -1795,7 +1795,7 @@ static inline uint color_dodge_op_rgb64(qint64 dst, qint64 src, qint64 da, qint6
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorDodge_impl(uint *dest, int length, uint color, const T &coverage)
+static inline void comp_func_solid_ColorDodge_impl(uint *dest, int length, uint color, const T &coverage)
{
int sa = qAlpha(color);
int sr = qRed(color);
@@ -1818,7 +1818,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorDodge_impl(uint *des
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorDodge_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
+static inline void comp_func_solid_ColorDodge_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
{
uint sa = color.alpha();
uint sr = color.red();
@@ -1857,7 +1857,7 @@ void QT_FASTCALL comp_func_solid_ColorDodge_rgb64(QRgba64 *dest, int length, QRg
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorDodge_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_ColorDodge_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
uint d = dest[i];
@@ -1878,7 +1878,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorDodge_impl(uint *Q_DECL_RE
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorDodge_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_ColorDodge_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
QRgba64 d = dest[i];
@@ -1947,7 +1947,7 @@ static inline uint color_burn_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorBurn_impl(uint *dest, int length, uint color, const T &coverage)
+static inline void comp_func_solid_ColorBurn_impl(uint *dest, int length, uint color, const T &coverage)
{
int sa = qAlpha(color);
int sr = qRed(color);
@@ -1970,7 +1970,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorBurn_impl(uint *dest
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorBurn_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
+static inline void comp_func_solid_ColorBurn_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
{
uint sa = color.alpha();
uint sr = color.red();
@@ -2009,7 +2009,7 @@ void QT_FASTCALL comp_func_solid_ColorBurn_rgb64(QRgba64 *dest, int length, QRgb
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorBurn_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_ColorBurn_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
uint d = dest[i];
@@ -2030,7 +2030,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorBurn_impl(uint *Q_DECL_RES
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorBurn_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_ColorBurn_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
QRgba64 d = dest[i];
@@ -2093,7 +2093,7 @@ static inline uint hardlight_op_rgb64(uint dst, uint src, uint da, uint sa)
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_HardLight_impl(uint *dest, int length, uint color, const T &coverage)
+static inline void comp_func_solid_HardLight_impl(uint *dest, int length, uint color, const T &coverage)
{
int sa = qAlpha(color);
int sr = qRed(color);
@@ -2116,7 +2116,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_HardLight_impl(uint *dest
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_HardLight_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
+static inline void comp_func_solid_HardLight_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
{
uint sa = color.alpha();
uint sr = color.red();
@@ -2155,7 +2155,7 @@ void QT_FASTCALL comp_func_solid_HardLight_rgb64(QRgba64 *dest, int length, QRgb
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_HardLight_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_HardLight_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
uint d = dest[i];
@@ -2176,7 +2176,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_HardLight_impl(uint *Q_DECL_RES
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_HardLight_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_HardLight_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
QRgba64 d = dest[i];
@@ -2252,7 +2252,7 @@ static inline uint soft_light_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_SoftLight_impl(uint *dest, int length, uint color, const T &coverage)
+static inline void comp_func_solid_SoftLight_impl(uint *dest, int length, uint color, const T &coverage)
{
int sa = qAlpha(color);
int sr = qRed(color);
@@ -2275,7 +2275,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_SoftLight_impl(uint *dest
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_SoftLight_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
+static inline void comp_func_solid_SoftLight_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
{
uint sa = color.alpha();
uint sr = color.red();
@@ -2314,7 +2314,7 @@ void QT_FASTCALL comp_func_solid_SoftLight_rgb64(QRgba64 *dest, int length, QRgb
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_SoftLight_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_SoftLight_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
uint d = dest[i];
@@ -2335,7 +2335,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_SoftLight_impl(uint *Q_DECL_RES
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_SoftLight_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_SoftLight_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
QRgba64 d = dest[i];
@@ -2386,7 +2386,7 @@ static inline uint difference_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Difference_impl(uint *dest, int length, uint color, const T &coverage)
+static inline void comp_func_solid_Difference_impl(uint *dest, int length, uint color, const T &coverage)
{
int sa = qAlpha(color);
int sr = qRed(color);
@@ -2409,7 +2409,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Difference_impl(uint *des
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Difference_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
+static inline void comp_func_solid_Difference_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
{
uint sa = color.alpha();
uint sr = color.red();
@@ -2448,7 +2448,7 @@ void QT_FASTCALL comp_func_solid_Difference_rgb64(QRgba64 *dest, int length, QRg
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Difference_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Difference_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
uint d = dest[i];
@@ -2469,7 +2469,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Difference_impl(uint *Q_DECL_RE
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Difference_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Difference_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
QRgba64 d = dest[i];
@@ -2509,7 +2509,7 @@ void QT_FASTCALL comp_func_Difference_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const
Dca' = (Sca.Da + Dca.Sa - 2.Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa)
*/
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void QT_FASTCALL comp_func_solid_Exclusion_impl(uint *dest, int length, uint color, const T &coverage)
+static inline void QT_FASTCALL comp_func_solid_Exclusion_impl(uint *dest, int length, uint color, const T &coverage)
{
int sa = qAlpha(color);
int sr = qRed(color);
@@ -2532,7 +2532,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void QT_FASTCALL comp_func_solid_Exclusion_imp
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void QT_FASTCALL comp_func_solid_Exclusion_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
+static inline void QT_FASTCALL comp_func_solid_Exclusion_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
{
uint sa = color.alpha();
uint sr = color.red();
@@ -2572,7 +2572,7 @@ void QT_FASTCALL comp_func_solid_Exclusion_rgb64(QRgba64 *dest, int length, QRgb
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Exclusion_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Exclusion_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
uint d = dest[i];
@@ -2593,7 +2593,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Exclusion_impl(uint *Q_DECL_RES
}
template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Exclusion_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
+static inline void comp_func_Exclusion_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage)
{
for (int i = 0; i < length; ++i) {
QRgba64 d = dest[i];
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index bbeb9fd9ea..c0320f5a70 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -4343,7 +4343,7 @@ static void blend_color_argb(int count, const QSpan *spans, void *userData)
while (count--) {
uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x;
if (spans->coverage == 255) {
- QT_MEMFILL_UINT(target, spans->len, color);
+ qt_memfill(target, color, spans->len);
} else {
uint c = BYTE_MUL(color, spans->coverage);
int ialpha = 255 - spans->coverage;
@@ -4422,7 +4422,7 @@ static void blend_color_rgb16(int count, const QSpan *spans, void *userData)
while (count--) {
ushort *target = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + spans->x;
if (spans->coverage == 255) {
- QT_MEMFILL_USHORT(target, spans->len, c);
+ qt_memfill(target, c, spans->len);
} else {
ushort color = BYTE_MUL_RGB16(c, spans->coverage);
int ialpha = 255 - spans->coverage;
@@ -5228,7 +5228,7 @@ void qBlendTexture(int count, const QSpan *spans, void *userData)
proc(count, spans, userData);
}
-template <class DST> Q_STATIC_TEMPLATE_FUNCTION
+template <class DST> static
inline void qt_bitmapblit_template(QRasterBuffer *rasterBuffer,
int x, int y, DST color,
const uchar *map,
diff --git a/src/gui/painting/qdrawhelper_neon.cpp b/src/gui/painting/qdrawhelper_neon.cpp
index 629dfe2358..c33a1e7fc5 100644
--- a/src/gui/painting/qdrawhelper_neon.cpp
+++ b/src/gui/painting/qdrawhelper_neon.cpp
@@ -84,20 +84,20 @@ void qt_memfill32(quint32 *dest, quint32 value, int count)
switch (epilogueSize)
{
- case 15: *dest++ = value;
- case 14: *dest++ = value;
- case 13: *dest++ = value;
- case 12: *dest++ = value;
- case 11: *dest++ = value;
- case 10: *dest++ = value;
- case 9: *dest++ = value;
- case 8: *dest++ = value;
- case 7: *dest++ = value;
- case 6: *dest++ = value;
- case 5: *dest++ = value;
- case 4: *dest++ = value;
- case 3: *dest++ = value;
- case 2: *dest++ = value;
+ case 15: *dest++ = value; Q_FALLTHROUGH();
+ case 14: *dest++ = value; Q_FALLTHROUGH();
+ case 13: *dest++ = value; Q_FALLTHROUGH();
+ case 12: *dest++ = value; Q_FALLTHROUGH();
+ case 11: *dest++ = value; Q_FALLTHROUGH();
+ case 10: *dest++ = value; Q_FALLTHROUGH();
+ case 9: *dest++ = value; Q_FALLTHROUGH();
+ case 8: *dest++ = value; Q_FALLTHROUGH();
+ case 7: *dest++ = value; Q_FALLTHROUGH();
+ case 6: *dest++ = value; Q_FALLTHROUGH();
+ case 5: *dest++ = value; Q_FALLTHROUGH();
+ case 4: *dest++ = value; Q_FALLTHROUGH();
+ case 3: *dest++ = value; Q_FALLTHROUGH();
+ case 2: *dest++ = value; Q_FALLTHROUGH();
case 1: *dest++ = value;
}
}
@@ -791,7 +791,7 @@ void QT_FASTCALL qt_destStoreRGB16_neon(QRasterBuffer *rasterBuffer, int x, int
void QT_FASTCALL comp_func_solid_SourceOver_neon(uint *destPixels, int length, uint color, uint const_alpha)
{
if ((const_alpha & qAlpha(color)) == 255) {
- QT_MEMFILL_UINT(destPixels, length, color);
+ qt_memfill32(destPixels, color, length);
} else {
if (const_alpha != 255)
color = BYTE_MUL(color, const_alpha);
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index fb08261205..23520ad64b 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -69,13 +69,10 @@
QT_BEGIN_NAMESPACE
#if defined(Q_CC_GNU)
-# define Q_STATIC_TEMPLATE_FUNCTION static
# define Q_DECL_RESTRICT __restrict__
#elif defined(Q_CC_MSVC)
-# define Q_STATIC_TEMPLATE_FUNCTION static
# define Q_DECL_RESTRICT __restrict
#else
-# define Q_STATIC_TEMPLATE_FUNCTION static
# define Q_DECL_RESTRICT
#endif
@@ -887,7 +884,7 @@ inline quint24::operator uint() const
return data[2] | (data[1] << 8) | (data[0] << 16);
}
-template <class T> Q_STATIC_TEMPLATE_FUNCTION
+template <class T> static
void qt_memfill(T *dest, T value, int count);
template<> inline void qt_memfill(quint64 *dest, quint64 color, int count)
@@ -931,7 +928,7 @@ inline void qt_memfill(T *dest, T value, int count)
}
}
-template <class T> Q_STATIC_TEMPLATE_FUNCTION
+template <class T> static
inline void qt_rectfill(T *dest, T value,
int x, int y, int width, int height, qsizetype stride)
{
@@ -947,52 +944,6 @@ inline void qt_rectfill(T *dest, T value,
}
}
-#define QT_MEMFILL_UINT(dest, length, color) \
- qt_memfill<quint32>(dest, color, length);
-
-#define QT_MEMFILL_USHORT(dest, length, color) \
- qt_memfill<quint16>(dest, color, length);
-
-#define QT_MEMCPY_REV_UINT(dest, src, length) \
-do { \
- /* Duff's device */ \
- uint *_d = (uint*)(dest) + length; \
- const uint *_s = (uint*)(src) + length; \
- int n = ((length) + 7) / 8; \
- switch ((length) & 0x07) \
- { \
- case 0: do { *--_d = *--_s; Q_FALLTHROUGH(); \
- case 7: *--_d = *--_s; Q_FALLTHROUGH(); \
- case 6: *--_d = *--_s; Q_FALLTHROUGH(); \
- case 5: *--_d = *--_s; Q_FALLTHROUGH(); \
- case 4: *--_d = *--_s; Q_FALLTHROUGH(); \
- case 3: *--_d = *--_s; Q_FALLTHROUGH(); \
- case 2: *--_d = *--_s; Q_FALLTHROUGH(); \
- case 1: *--_d = *--_s; \
- } while (--n > 0); \
- } \
-} while (false)
-
-#define QT_MEMCPY_USHORT(dest, src, length) \
-do { \
- /* Duff's device */ \
- ushort *_d = (ushort*)(dest); \
- const ushort *_s = (const ushort*)(src); \
- int n = ((length) + 7) / 8; \
- switch ((length) & 0x07) \
- { \
- case 0: do { *_d++ = *_s++; Q_FALLTHROUGH(); \
- case 7: *_d++ = *_s++; Q_FALLTHROUGH(); \
- case 6: *_d++ = *_s++; Q_FALLTHROUGH(); \
- case 5: *_d++ = *_s++; Q_FALLTHROUGH(); \
- case 4: *_d++ = *_s++; Q_FALLTHROUGH(); \
- case 3: *_d++ = *_s++; Q_FALLTHROUGH(); \
- case 2: *_d++ = *_s++; Q_FALLTHROUGH(); \
- case 1: *_d++ = *_s++; \
- } while (--n > 0); \
- } \
-} while (false)
-
inline ushort qConvertRgb32To16(uint c)
{
return (((c) >> 3) & 0x001f)
diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp
index 3212ffdd2d..1673b27922 100644
--- a/src/gui/painting/qdrawhelper_sse2.cpp
+++ b/src/gui/painting/qdrawhelper_sse2.cpp
@@ -266,20 +266,20 @@ void qt_memfill32(quint32 *dest, quint32 value, int count)
int count128 = count / 4;
__m128i *dst128 = reinterpret_cast<__m128i*>(dest);
__m128i *end128 = dst128 + count128;
- const __m128i value128 = _mm_set_epi32(value, value, value, value);
+ const __m128i value128 = _mm_set1_epi32(value);
while (dst128 + 3 < end128) {
- _mm_stream_si128(dst128 + 0, value128);
- _mm_stream_si128(dst128 + 1, value128);
- _mm_stream_si128(dst128 + 2, value128);
- _mm_stream_si128(dst128 + 3, value128);
+ _mm_store_si128(dst128 + 0, value128);
+ _mm_store_si128(dst128 + 1, value128);
+ _mm_store_si128(dst128 + 2, value128);
+ _mm_store_si128(dst128 + 3, value128);
dst128 += 4;
}
switch (count128 & 0x3) {
- case 3: _mm_stream_si128(dst128++, value128); Q_FALLTHROUGH();
- case 2: _mm_stream_si128(dst128++, value128); Q_FALLTHROUGH();
- case 1: _mm_stream_si128(dst128++, value128);
+ case 3: _mm_store_si128(dst128++, value128); Q_FALLTHROUGH();
+ case 2: _mm_store_si128(dst128++, value128); Q_FALLTHROUGH();
+ case 1: _mm_store_si128(dst128++, value128);
}
}
diff --git a/src/gui/painting/qmemrotate.cpp b/src/gui/painting/qmemrotate.cpp
index 43aeff3268..9cb787fb2c 100644
--- a/src/gui/painting/qmemrotate.cpp
+++ b/src/gui/painting/qmemrotate.cpp
@@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE
static const int tileSize = 32;
template <class T>
-Q_STATIC_TEMPLATE_FUNCTION
+static
inline void qt_memrotate90_tiled(const T *src, int w, int h, int sstride, T *dest, int dstride)
{
sstride /= sizeof(T);
@@ -103,7 +103,7 @@ inline void qt_memrotate90_tiled(const T *src, int w, int h, int sstride, T *des
}
template <class T>
-Q_STATIC_TEMPLATE_FUNCTION
+static
inline void qt_memrotate90_tiled_unpacked(const T *src, int w, int h, int sstride, T *dest,
int dstride)
{
@@ -131,7 +131,7 @@ inline void qt_memrotate90_tiled_unpacked(const T *src, int w, int h, int sstrid
}
template <class T>
-Q_STATIC_TEMPLATE_FUNCTION
+static
inline void qt_memrotate270_tiled(const T *src, int w, int h, int sstride, T *dest, int dstride)
{
sstride /= sizeof(T);
@@ -190,7 +190,7 @@ inline void qt_memrotate270_tiled(const T *src, int w, int h, int sstride, T *de
}
template <class T>
-Q_STATIC_TEMPLATE_FUNCTION
+static
inline void qt_memrotate270_tiled_unpacked(const T *src, int w, int h, int sstride, T *dest,
int dstride)
{
@@ -219,7 +219,7 @@ inline void qt_memrotate270_tiled_unpacked(const T *src, int w, int h, int sstri
template <class T>
-Q_STATIC_TEMPLATE_FUNCTION
+static
inline void qt_memrotate90_template(const T *src, int srcWidth, int srcHeight, int srcStride,
T *dest, int dstStride)
{
@@ -246,7 +246,7 @@ inline void qt_memrotate90_template<quint64>(const quint64 *src, int w, int h, i
}
template <class T>
-Q_STATIC_TEMPLATE_FUNCTION
+static
inline void qt_memrotate180_template(const T *src, int w, int h, int sstride, T *dest, int dstride)
{
const char *s = (const char*)(src) + (h - 1) * sstride;
@@ -261,7 +261,7 @@ inline void qt_memrotate180_template(const T *src, int w, int h, int sstride, T
}
template <class T>
-Q_STATIC_TEMPLATE_FUNCTION
+static
inline void qt_memrotate270_template(const T *src, int srcWidth, int srcHeight, int srcStride,
T *dest, int dstStride)
{
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 9f07af92e4..81ce5c60c5 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -439,6 +439,9 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
}
}
+ if (d->activeStroker == &d->stroker)
+ d->stroker.setForceOpen(path.hasExplicitOpen());
+
const QPainterPath::ElementType *types = path.elements();
const qreal *points = path.points();
int pointCount = path.elementCount();
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index b70b29e54e..df2f5e11d3 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -1437,6 +1437,13 @@ void QPainterPrivate::updateState(QPainterState *newState)
by slightly less than half a pixel. Also will treat default constructed pens
as cosmetic. Potentially useful when porting a Qt 4 application to Qt 5.
+ \value LosslessImageRendering Use a lossless image rendering, whenever possible.
+ Currently, this hint is only used when QPainter is employed to output a PDF
+ file through QPrinter or QPdfWriter, where drawImage()/drawPixmap() calls
+ will encode images using a lossless compression algorithm instead of lossy
+ JPEG compression.
+ This value was added in Qt 5.13.
+
\sa renderHints(), setRenderHint(), {QPainter#Rendering
Quality}{Rendering Quality}, {Concentric Circles Example}
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index 482f5fb63d..87c4899f0b 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -91,7 +91,8 @@ public:
SmoothPixmapTransform = 0x04,
HighQualityAntialiasing = 0x08,
NonCosmeticDefaultPen = 0x10,
- Qt4CompatiblePainting = 0x20
+ Qt4CompatiblePainting = 0x20,
+ LosslessImageRendering = 0x40,
};
Q_FLAG(RenderHint)
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index e69726b617..0811dd9918 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -949,7 +949,8 @@ void QPdfEngine::drawPixmap (const QRectF &rectangle, const QPixmap &pixmap, con
QPixmap pm = sourceRect != pixmap.rect() ? pixmap.copy(sourceRect) : pixmap;
QImage image = pm.toImage();
bool bitmap = true;
- const int object = d->addImage(image, &bitmap, pm.cacheKey());
+ const bool lossless = painter()->testRenderHint(QPainter::LosslessImageRendering);
+ const int object = d->addImage(image, &bitmap, lossless, pm.cacheKey());
if (object < 0)
return;
@@ -988,7 +989,8 @@ void QPdfEngine::drawImage(const QRectF &rectangle, const QImage &image, const Q
QRect sourceRect = sr.toRect();
QImage im = sourceRect != image.rect() ? image.copy(sourceRect) : image;
bool bitmap = true;
- const int object = d->addImage(im, &bitmap, im.cacheKey());
+ const bool lossless = painter()->testRenderHint(QPainter::LosslessImageRendering);
+ const int object = d->addImage(im, &bitmap, lossless, im.cacheKey());
if (object < 0)
return;
@@ -2632,6 +2634,8 @@ int QPdfEnginePrivate::addConstantAlphaObject(int brushAlpha, int penAlpha)
int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor, int *gStateObject)
{
+ Q_Q(QPdfEngine);
+
int paintType = 2; // Uncolored tiling
int w = 8;
int h = 8;
@@ -2661,7 +2665,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
return 0;
QImage image = brush.textureImage();
bool bitmap = true;
- imageObject = addImage(image, &bitmap, image.cacheKey());
+ const bool lossless = q->painter()->testRenderHint(QPainter::LosslessImageRendering);
+ imageObject = addImage(image, &bitmap, lossless, image.cacheKey());
if (imageObject != -1) {
QImage::Format f = image.format();
if (f != QImage::Format_MonoLSB && f != QImage::Format_Mono) {
@@ -2723,7 +2728,7 @@ static inline bool is_monochrome(const QVector<QRgb> &colorTable)
/*!
* Adds an image to the pdf and return the pdf-object id. Returns -1 if adding the image failed.
*/
-int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_no)
+int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, bool lossless, qint64 serial_no)
{
if (img.isNull())
return -1;
@@ -2784,7 +2789,7 @@ int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_n
bool hasAlpha = false;
bool hasMask = false;
- if (QImageWriter::supportedImageFormats().contains("jpeg") && !grayscale) {
+ if (QImageWriter::supportedImageFormats().contains("jpeg") && !grayscale && !lossless) {
QBuffer buffer(&imageData);
QImageWriter writer(&buffer, "jpeg");
writer.setQuality(94);
diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h
index e2526de67d..e337c61f64 100644
--- a/src/gui/painting/qpdf_p.h
+++ b/src/gui/painting/qpdf_p.h
@@ -242,7 +242,7 @@ public:
void writeHeader();
void writeTail();
- int addImage(const QImage &image, bool *bitmap, qint64 serial_no);
+ int addImage(const QImage &image, bool *bitmap, bool lossless, qint64 serial_no);
int addConstantAlphaObject(int brushAlpha, int penAlpha = 255);
int addBrushPattern(const QTransform &matrix, bool *specifyColor, int *gStateObject);
diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp
index 6c85d65538..258939a763 100644
--- a/src/gui/painting/qpdfwriter.cpp
+++ b/src/gui/painting/qpdfwriter.cpp
@@ -76,7 +76,7 @@ public:
: QPagedPaintDevicePrivate(), pd(d)
{}
- virtual ~QPdfPagedPaintDevicePrivate()
+ ~QPdfPagedPaintDevicePrivate()
{}
bool setPageLayout(const QPageLayout &newPageLayout) override
diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp
index 4776545be6..0a3d802b21 100644
--- a/src/gui/painting/qstroker.cpp
+++ b/src/gui/painting/qstroker.cpp
@@ -369,7 +369,8 @@ void QStrokerOps::strokeEllipse(const QRectF &rect, void *data, const QTransform
QStroker::QStroker()
: m_capStyle(SquareJoin), m_joinStyle(FlatJoin),
m_back1X(0), m_back1Y(0),
- m_back2X(0), m_back2Y(0)
+ m_back2X(0), m_back2Y(0),
+ m_forceOpen(false)
{
m_strokeWidth = qt_real_to_fixed(1);
m_miterLimit = qt_real_to_fixed(2);
@@ -748,7 +749,7 @@ template <class Iterator> bool qt_stroke_side(Iterator *it,
}
}
- if (start == prev) {
+ if (start == prev && !stroker->forceOpen()) {
// closed subpath, join first and last point
#ifdef QPP_STROKE_DEBUG
qDebug("\n ---> (side) closed subpath");
diff --git a/src/gui/painting/qstroker_p.h b/src/gui/painting/qstroker_p.h
index 1a7c184e1a..722a0904f3 100644
--- a/src/gui/painting/qstroker_p.h
+++ b/src/gui/painting/qstroker_p.h
@@ -222,6 +222,9 @@ public:
void setMiterLimit(qfixed length) { m_miterLimit = length; }
qfixed miterLimit() const { return m_miterLimit; }
+ void setForceOpen(bool state) { m_forceOpen = state; }
+ bool forceOpen() { return m_forceOpen; }
+
void joinPoints(qfixed x, qfixed y, const QLineF &nextLine, LineJoinMode join);
inline void emitMoveTo(qfixed x, qfixed y);
inline void emitLineTo(qfixed x, qfixed y);
@@ -247,6 +250,8 @@ protected:
qfixed m_back2X;
qfixed m_back2Y;
+
+ bool m_forceOpen;
};
class Q_GUI_EXPORT QDashStroker : public QStrokerOps
diff --git a/src/gui/painting/qvectorpath_p.h b/src/gui/painting/qvectorpath_p.h
index d1b08ed423..8580598784 100644
--- a/src/gui/painting/qvectorpath_p.h
+++ b/src/gui/painting/qvectorpath_p.h
@@ -99,7 +99,8 @@ public:
// Shape rendering specifiers...
OddEvenFill = 0x1000,
WindingFill = 0x2000,
- ImplicitClose = 0x4000
+ ImplicitClose = 0x4000,
+ ExplicitOpen = 0x8000
};
// ### Falcon: introduca a struct XY for points so lars is not so confused...
@@ -124,6 +125,7 @@ public:
inline bool isCacheable() const { return m_hints & ShouldUseCacheHint; }
inline bool hasImplicitClose() const { return m_hints & ImplicitClose; }
+ inline bool hasExplicitOpen() const { return m_hints & ExplicitOpen; }
inline bool hasWindingFill() const { return m_hints & WindingFill; }
inline void makeCacheable() const { m_hints |= ShouldUseCacheHint; m_cache = 0; }
@@ -142,7 +144,7 @@ public:
case QPaintEngine::ConvexMode: return ConvexPolygonHint | ImplicitClose;
case QPaintEngine::OddEvenMode: return PolygonHint | OddEvenFill | ImplicitClose;
case QPaintEngine::WindingMode: return PolygonHint | WindingFill | ImplicitClose;
- case QPaintEngine::PolylineMode: return PolygonHint;
+ case QPaintEngine::PolylineMode: return PolygonHint | ExplicitOpen;
default: return 0;
}
}
diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h
index 8fea27f772..3371401420 100644
--- a/src/gui/text/qabstracttextdocumentlayout.h
+++ b/src/gui/text/qabstracttextdocumentlayout.h
@@ -143,7 +143,9 @@ public:
virtual void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) = 0;
};
+#ifndef Q_CLANG_QDOC
Q_DECLARE_INTERFACE(QTextObjectInterface, "org.qt-project.Qt.QTextObjectInterface")
+#endif
QT_END_NAMESPACE
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 325fd26a31..91fa40eddf 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -115,6 +115,7 @@ static const QCssKnownValue properties[NumProperties - 1] = {
{ "float", Float },
{ "font", Font },
{ "font-family", FontFamily },
+ { "font-kerning", FontKerning },
{ "font-size", FontSize },
{ "font-style", FontStyle },
{ "font-variant", FontVariant },
@@ -368,6 +369,7 @@ static inline bool isInheritable(Property propertyId)
{
switch (propertyId) {
case Font:
+ case FontKerning:
case FontFamily:
case FontSize:
case FontStyle:
@@ -721,7 +723,8 @@ static ColorData parseColorValue(QCss::Value v)
if (lst.count() != 2)
return ColorData();
- if ((lst.at(0).compare(QLatin1String("palette"), Qt::CaseInsensitive)) == 0) {
+ const QString &identifier = lst.at(0);
+ if ((identifier.compare(QLatin1String("palette"), Qt::CaseInsensitive)) == 0) {
int role = findKnownValue(lst.at(1).trimmed(), values, NumKnownValues);
if (role >= Value_FirstColorRole && role <= Value_LastColorRole)
return (QPalette::ColorRole)(role-Value_FirstColorRole);
@@ -729,8 +732,16 @@ static ColorData parseColorValue(QCss::Value v)
return ColorData();
}
- bool rgb = lst.at(0).startsWith(QLatin1String("rgb"));
- bool rgba = lst.at(0).startsWith(QLatin1String("rgba"));
+ const bool rgb = identifier.startsWith(QLatin1String("rgb"));
+ const bool hsv = !rgb && identifier.startsWith(QLatin1String("hsv"));
+ const bool hsl = !rgb && !hsv && identifier.startsWith(QLatin1String("hsl"));
+
+ if (!rgb && !hsv && !hsl)
+ return ColorData();
+
+ const bool hasAlpha = identifier.size() == 4 && identifier.at(3) == QLatin1Char('a');
+ if (identifier.size() > 3 && !hasAlpha)
+ return ColorData();
Parser p(lst.at(1));
if (!p.testExpr())
@@ -743,7 +754,8 @@ static ColorData parseColorValue(QCss::Value v)
for (int i = 0; i < qMin(tokenCount, 7); i += 2) {
if (colorDigits.at(i).type == Value::Percentage) {
- colorDigits[i].variant = colorDigits.at(i).variant.toReal() * (255. / 100.);
+ const qreal maxRange = (rgb || i != 0) ? 255. : 359.;
+ colorDigits[i].variant = colorDigits.at(i).variant.toReal() * (maxRange / 100.);
colorDigits[i].type = Value::Number;
} else if (colorDigits.at(i).type != Value::Number) {
return ColorData();
@@ -754,20 +766,29 @@ static ColorData parseColorValue(QCss::Value v)
if (tokenCount < 5)
return ColorData();
+ // ### Qt6: replace this with a check and return invalid color when token count does not match
+ if (hasAlpha && tokenCount != 7)
+ qWarning("QCssParser::parseColorValue: Specified color with alpha value but no alpha given: '%s'", qPrintable(lst.join(QLatin1Char(' '))));
+ if (!hasAlpha && tokenCount != 5)
+ qWarning("QCssParser::parseColorValue: Specified color without alpha value but alpha given: '%s'", qPrintable(lst.join(QLatin1Char(' '))));
+
int v1 = colorDigits.at(0).variant.toInt();
int v2 = colorDigits.at(2).variant.toInt();
int v3 = colorDigits.at(4).variant.toInt();
int alpha = 255;
- if (tokenCount >= 7) {
+ if (tokenCount == 7) {
int alphaValue = colorDigits.at(6).variant.toInt();
- if (rgba && alphaValue <= 1)
+ if (alphaValue <= 1)
alpha = colorDigits.at(6).variant.toReal() * 255.;
else
alpha = alphaValue;
}
- return rgb ? QColor::fromRgb(v1, v2, v3, alpha)
- : QColor::fromHsv(v1, v2, v3, alpha);
+ if (rgb)
+ return QColor::fromRgb(v1, v2, v3, alpha);
+ if (hsv)
+ return QColor::fromHsv(v1, v2, v3, alpha);
+ return QColor::fromHsl(v1, v2, v3, alpha);
}
static QColor colorFromData(const ColorData& c, const QPalette &pal)
@@ -1142,6 +1163,19 @@ static bool setFontStyleFromValue(const QCss::Value &value, QFont *font)
return false;
}
+static bool setFontKerningFromValue(const QCss::Value &value, QFont *font)
+{
+ if (value.type != Value::KnownIdentifier)
+ return false ;
+ switch (value.variant.toInt()) {
+ case Value_Normal: font->setKerning(true); return true;
+ case Value_None: font->setKerning(false); return true;
+ case Value_Auto: return true;
+ default: break;
+ }
+ return false;
+}
+
static bool setFontWeightFromValue(const QCss::Value &value, QFont *font)
{
if (value.type == Value::KnownIdentifier) {
@@ -1166,11 +1200,13 @@ static bool setFontWeightFromValue(const QCss::Value &value, QFont *font)
static bool setFontFamilyFromValues(const QVector<QCss::Value> &values, QFont *font, int start = 0)
{
QString family;
+ QStringList families;
bool shouldAddSpace = false;
for (int i = start; i < values.count(); ++i) {
const QCss::Value &v = values.at(i);
if (v.type == Value::TermOperatorComma) {
- family += QLatin1Char(',');
+ families << family;
+ family.clear();
shouldAddSpace = false;
continue;
}
@@ -1182,9 +1218,12 @@ static bool setFontFamilyFromValues(const QVector<QCss::Value> &values, QFont *f
family += str;
shouldAddSpace = true;
}
- if (family.isEmpty())
+ if (!family.isEmpty())
+ families << family;
+ if (families.isEmpty())
return false;
- font->setFamily(family);
+ font->setFamily(families.at(0));
+ font->setFamilies(families);
return true;
}
@@ -1274,6 +1313,7 @@ bool ValueExtractor::extractFont(QFont *font, int *fontSizeAdjustment)
case FontStyle: setFontStyleFromValue(val, font); break;
case FontWeight: setFontWeightFromValue(val, font); break;
case FontFamily: setFontFamilyFromValues(decl.d->values, font); break;
+ case FontKerning: setFontKerningFromValue(val, font); break;
case TextDecoration: setTextDecorationFromValues(decl.d->values, font); break;
case Font: parseShorthandFontProperty(decl.d->values, font, fontSizeAdjustment); break;
case FontVariant: setFontVariantFromValue(val, font); break;
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index c1594531ea..8f992f8c59 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -195,6 +195,7 @@ enum Property {
QtListNumberSuffix,
LineHeight,
QtLineHeightType,
+ FontKerning,
NumProperties
};
diff --git a/src/gui/text/qcssscanner.cpp b/src/gui/text/qcssscanner.cpp
index 33dc01c8bc..d48cbb71d7 100644
--- a/src/gui/text/qcssscanner.cpp
+++ b/src/gui/text/qcssscanner.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -37,7 +37,7 @@
**
****************************************************************************/
-// auto generated. DO NOT EDIT.
+// auto generated by qtbase/util/lexgen/. DO NOT EDIT.
class QCssScanner_Generated
{
public:
@@ -75,23 +75,23 @@ int QCssScanner_Generated::lex()
// initial state
ch = next();
if (ch.unicode() >= 9 && ch.unicode() <= 10)
- goto state_1;
+ goto state_4;
if (ch.unicode() >= 12 && ch.unicode() <= 13)
- goto state_1;
+ goto state_4;
if (ch.unicode() == 32)
- goto state_1;
+ goto state_4;
if (ch.unicode() == 33) {
token = QCss::EXCLAMATION_SYM;
goto found;
}
if (ch.unicode() == 34)
- goto state_3;
+ goto state_2;
if (ch.unicode() == 35)
- goto state_4;
+ goto state_1;
if (ch.unicode() == 36)
- goto state_5;
- if (ch.unicode() == 39)
goto state_6;
+ if (ch.unicode() == 39)
+ goto state_5;
if (ch.unicode() == 40) {
token = QCss::LPAREN;
goto found;
@@ -101,17 +101,17 @@ int QCssScanner_Generated::lex()
goto found;
}
if (ch.unicode() == 42)
- goto state_9;
+ goto state_8;
if (ch.unicode() == 43)
- goto state_10;
+ goto state_7;
if (ch.unicode() == 44)
- goto state_11;
+ goto state_14;
if (ch.unicode() == 45)
- goto state_12;
- if (ch.unicode() == 46)
goto state_13;
+ if (ch.unicode() == 46)
+ goto state_12;
if (ch.unicode() == 47)
- goto state_14;
+ goto state_11;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
goto state_15;
if (ch.unicode() == 58) {
@@ -123,64 +123,56 @@ int QCssScanner_Generated::lex()
goto found;
}
if (ch.unicode() == 60)
- goto state_18;
+ goto state_20;
if (ch.unicode() == 61) {
token = QCss::EQUAL;
goto found;
}
if (ch.unicode() == 62)
- goto state_20;
+ goto state_18;
if (ch.unicode() == 64)
- goto state_21;
+ goto state_26;
if (ch.unicode() == 91) {
token = QCss::LBRACKET;
goto found;
}
if (ch.unicode() == 92)
- goto state_23;
+ goto state_30;
if (ch.unicode() == 93) {
token = QCss::RBRACKET;
goto found;
}
if (ch.unicode() == 94)
- goto state_25;
+ goto state_28;
if (ch.unicode() == 95)
- goto state_26;
+ goto state_21;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_26;
+ goto state_21;
if (ch.unicode() == 123)
- goto state_27;
+ goto state_22;
if (ch.unicode() == 124)
- goto state_28;
+ goto state_25;
if (ch.unicode() == 125) {
token = QCss::RBRACE;
goto found;
}
if (ch.unicode() == 126)
- goto state_30;
+ goto state_23;
goto out;
state_1:
- lastAcceptingPos = pos;
- token = QCss::S;
ch = next();
- if (ch.unicode() >= 9 && ch.unicode() <= 10)
- goto state_31;
- if (ch.unicode() >= 12 && ch.unicode() <= 13)
+ if (ch.unicode() == 45)
goto state_31;
- if (ch.unicode() == 32)
+ if (ch.unicode() >= 48 && ch.unicode() <= 57)
goto state_31;
- if (ch.unicode() == 43)
- goto state_10;
- if (ch.unicode() == 44)
- goto state_11;
- if (ch.unicode() == 62)
- goto state_20;
- if (ch.unicode() == 123)
- goto state_27;
- if (ch.unicode() == 126)
+ if (ch.unicode() == 92)
goto state_32;
+ if (ch.unicode() == 95)
+ goto state_31;
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
+ goto state_31;
goto out;
- state_3:
+ state_2:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
@@ -204,93 +196,101 @@ int QCssScanner_Generated::lex()
goto state_33;
goto out;
state_4:
+ lastAcceptingPos = pos;
+ token = QCss::S;
ch = next();
- if (ch.unicode() == 45)
- goto state_36;
- if (ch.unicode() >= 48 && ch.unicode() <= 57)
+ if (ch.unicode() >= 9 && ch.unicode() <= 10)
goto state_36;
- if (ch.unicode() == 92)
- goto state_37;
- if (ch.unicode() == 95)
+ if (ch.unicode() >= 12 && ch.unicode() <= 13)
goto state_36;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
+ if (ch.unicode() == 32)
goto state_36;
+ if (ch.unicode() == 43)
+ goto state_7;
+ if (ch.unicode() == 44)
+ goto state_14;
+ if (ch.unicode() == 62)
+ goto state_18;
+ if (ch.unicode() == 123)
+ goto state_22;
+ if (ch.unicode() == 126)
+ goto state_37;
goto out;
state_5:
- ch = next();
- if (ch.unicode() == 61) {
- token = QCss::ENDSWITH;
- goto found;
- }
- goto out;
- state_6:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_39;
+ goto state_38;
if (ch.unicode() == 11)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_39;
+ goto state_38;
if (ch.unicode() == 39)
- goto state_40;
- if (ch.unicode() >= 40 && ch.unicode() <= 91)
goto state_39;
+ if (ch.unicode() >= 40 && ch.unicode() <= 91)
+ goto state_38;
if (ch.unicode() == 92)
- goto state_41;
+ goto state_40;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_39;
+ goto state_38;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 123)
- goto state_39;
+ goto state_38;
goto out;
- state_9:
- lastAcceptingPos = pos;
- token = QCss::STAR;
+ state_6:
ch = next();
if (ch.unicode() == 61) {
- token = QCss::CONTAINS;
+ token = QCss::ENDSWITH;
goto found;
}
goto out;
- state_10:
+ state_7:
lastAcceptingPos = pos;
token = QCss::PLUS;
goto out;
+ state_8:
+ lastAcceptingPos = pos;
+ token = QCss::STAR;
+ ch = next();
+ if (ch.unicode() == 61) {
+ token = QCss::CONTAINS;
+ goto found;
+ }
+ goto out;
state_11:
lastAcceptingPos = pos;
- token = QCss::COMMA;
+ token = QCss::SLASH;
+ ch = next();
+ if (ch.unicode() == 42) {
+ token = handleCommentStart();
+ goto found;
+ }
goto out;
state_12:
lastAcceptingPos = pos;
+ token = QCss::DOT;
+ ch = next();
+ if (ch.unicode() >= 48 && ch.unicode() <= 57)
+ goto state_44;
+ goto out;
+ state_13:
+ lastAcceptingPos = pos;
token = QCss::MINUS;
ch = next();
if (ch.unicode() == 45)
- goto state_43;
+ goto state_45;
if (ch.unicode() == 92)
- goto state_23;
+ goto state_30;
if (ch.unicode() == 95)
- goto state_26;
+ goto state_21;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_26;
- goto out;
- state_13:
- lastAcceptingPos = pos;
- token = QCss::DOT;
- ch = next();
- if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_44;
+ goto state_21;
goto out;
state_14:
lastAcceptingPos = pos;
- token = QCss::SLASH;
- ch = next();
- if (ch.unicode() == 42) {
- token = handleCommentStart();
- goto found;
- }
+ token = QCss::COMMA;
goto out;
state_15:
lastAcceptingPos = pos;
@@ -299,68 +299,70 @@ int QCssScanner_Generated::lex()
if (ch.unicode() == 37)
goto state_46;
if (ch.unicode() == 45)
- goto state_47;
- if (ch.unicode() == 46)
goto state_48;
+ if (ch.unicode() == 46)
+ goto state_47;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
goto state_49;
if (ch.unicode() == 92)
- goto state_50;
- if (ch.unicode() == 95)
goto state_51;
+ if (ch.unicode() == 95)
+ goto state_50;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_51;
+ goto state_50;
goto out;
state_18:
+ lastAcceptingPos = pos;
+ token = QCss::GREATER;
+ goto out;
+ state_20:
ch = next();
if (ch.unicode() == 33)
goto state_52;
goto out;
- state_20:
- lastAcceptingPos = pos;
- token = QCss::GREATER;
- goto out;
state_21:
+ lastAcceptingPos = pos;
+ token = QCss::IDENT;
ch = next();
- if (ch.unicode() == 45)
+ if (ch.unicode() == 40)
goto state_53;
- if (ch.unicode() == 92)
+ if (ch.unicode() == 45)
goto state_54;
- if (ch.unicode() == 95)
+ if (ch.unicode() >= 48 && ch.unicode() <= 57)
+ goto state_54;
+ if (ch.unicode() == 92)
goto state_55;
+ if (ch.unicode() == 95)
+ goto state_54;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_55;
+ goto state_54;
+ goto out;
+ state_22:
+ lastAcceptingPos = pos;
+ token = QCss::LBRACE;
goto out;
state_23:
+ lastAcceptingPos = pos;
+ token = QCss::TILDE;
ch = next();
- if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_56;
- if (ch.unicode() == 11)
- goto state_56;
- if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_56;
- if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_56;
- if (ch.unicode() >= 103)
- goto state_56;
+ if (ch.unicode() == 61) {
+ token = QCss::INCLUDES;
+ goto found;
+ }
goto out;
state_25:
+ lastAcceptingPos = pos;
+ token = QCss::OR;
ch = next();
if (ch.unicode() == 61) {
- token = QCss::BEGINSWITH;
+ token = QCss::DASHMATCH;
goto found;
}
goto out;
state_26:
- lastAcceptingPos = pos;
- token = QCss::IDENT;
ch = next();
- if (ch.unicode() == 40)
- goto state_58;
if (ch.unicode() == 45)
- goto state_59;
- if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_59;
+ goto state_58;
if (ch.unicode() == 92)
goto state_60;
if (ch.unicode() == 95)
@@ -368,52 +370,53 @@ int QCssScanner_Generated::lex()
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_59;
goto out;
- state_27:
- lastAcceptingPos = pos;
- token = QCss::LBRACE;
- goto out;
state_28:
- lastAcceptingPos = pos;
- token = QCss::OR;
ch = next();
if (ch.unicode() == 61) {
- token = QCss::DASHMATCH;
+ token = QCss::BEGINSWITH;
goto found;
}
goto out;
state_30:
- lastAcceptingPos = pos;
- token = QCss::TILDE;
ch = next();
- if (ch.unicode() == 61) {
- token = QCss::INCLUDES;
- goto found;
- }
+ if (ch.unicode() >= 1 && ch.unicode() <= 9)
+ goto state_62;
+ if (ch.unicode() == 11)
+ goto state_62;
+ if (ch.unicode() >= 14 && ch.unicode() <= 47)
+ goto state_62;
+ if (ch.unicode() >= 58 && ch.unicode() <= 96)
+ goto state_62;
+ if (ch.unicode() >= 103)
+ goto state_62;
goto out;
state_31:
lastAcceptingPos = pos;
- token = QCss::S;
+ token = QCss::HASH;
ch = next();
- if (ch.unicode() >= 9 && ch.unicode() <= 10)
- goto state_31;
- if (ch.unicode() >= 12 && ch.unicode() <= 13)
- goto state_31;
- if (ch.unicode() == 32)
- goto state_31;
- if (ch.unicode() == 43)
- goto state_10;
- if (ch.unicode() == 44)
- goto state_11;
- if (ch.unicode() == 62)
- goto state_20;
- if (ch.unicode() == 123)
- goto state_27;
- if (ch.unicode() == 126)
- goto state_32;
+ if (ch.unicode() == 45)
+ goto state_63;
+ if (ch.unicode() >= 48 && ch.unicode() <= 57)
+ goto state_63;
+ if (ch.unicode() == 92)
+ goto state_64;
+ if (ch.unicode() == 95)
+ goto state_63;
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
+ goto state_63;
goto out;
state_32:
- lastAcceptingPos = pos;
- token = QCss::TILDE;
+ ch = next();
+ if (ch.unicode() >= 1 && ch.unicode() <= 9)
+ goto state_65;
+ if (ch.unicode() == 11)
+ goto state_65;
+ if (ch.unicode() >= 14 && ch.unicode() <= 47)
+ goto state_65;
+ if (ch.unicode() >= 58 && ch.unicode() <= 96)
+ goto state_65;
+ if (ch.unicode() >= 103)
+ goto state_65;
goto out;
state_33:
lastAcceptingPos = pos;
@@ -445,78 +448,75 @@ int QCssScanner_Generated::lex()
state_35:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_63;
+ goto state_66;
if (ch.unicode() == 10)
- goto state_64;
+ goto state_67;
if (ch.unicode() == 11)
- goto state_63;
+ goto state_66;
if (ch.unicode() == 12)
- goto state_65;
+ goto state_69;
if (ch.unicode() == 13)
- goto state_66;
+ goto state_68;
if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_63;
+ goto state_66;
if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_63;
+ goto state_66;
if (ch.unicode() >= 103)
- goto state_63;
+ goto state_66;
goto out;
state_36:
lastAcceptingPos = pos;
- token = QCss::HASH;
+ token = QCss::S;
ch = next();
- if (ch.unicode() == 45)
- goto state_67;
- if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_67;
- if (ch.unicode() == 92)
- goto state_68;
- if (ch.unicode() == 95)
- goto state_67;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_67;
+ if (ch.unicode() >= 9 && ch.unicode() <= 10)
+ goto state_36;
+ if (ch.unicode() >= 12 && ch.unicode() <= 13)
+ goto state_36;
+ if (ch.unicode() == 32)
+ goto state_36;
+ if (ch.unicode() == 43)
+ goto state_7;
+ if (ch.unicode() == 44)
+ goto state_14;
+ if (ch.unicode() == 62)
+ goto state_18;
+ if (ch.unicode() == 123)
+ goto state_22;
+ if (ch.unicode() == 126)
+ goto state_37;
goto out;
state_37:
- ch = next();
- if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_69;
- if (ch.unicode() == 11)
- goto state_69;
- if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_69;
- if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_69;
- if (ch.unicode() >= 103)
- goto state_69;
+ lastAcceptingPos = pos;
+ token = QCss::TILDE;
goto out;
- state_39:
+ state_38:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_39;
+ goto state_38;
if (ch.unicode() == 11)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_39;
+ goto state_38;
if (ch.unicode() == 39)
- goto state_40;
- if (ch.unicode() >= 40 && ch.unicode() <= 91)
goto state_39;
+ if (ch.unicode() >= 40 && ch.unicode() <= 91)
+ goto state_38;
if (ch.unicode() == 92)
- goto state_41;
+ goto state_40;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_39;
+ goto state_38;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 123)
- goto state_39;
+ goto state_38;
goto out;
- state_40:
+ state_39:
lastAcceptingPos = pos;
token = QCss::STRING;
goto out;
- state_41:
+ state_40:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
goto state_70;
@@ -525,9 +525,9 @@ int QCssScanner_Generated::lex()
if (ch.unicode() == 11)
goto state_70;
if (ch.unicode() == 12)
- goto state_72;
- if (ch.unicode() == 13)
goto state_73;
+ if (ch.unicode() == 13)
+ goto state_72;
if (ch.unicode() >= 14 && ch.unicode() <= 47)
goto state_70;
if (ch.unicode() >= 58 && ch.unicode() <= 96)
@@ -535,13 +535,6 @@ int QCssScanner_Generated::lex()
if (ch.unicode() >= 103)
goto state_70;
goto out;
- state_43:
- ch = next();
- if (ch.unicode() == 62) {
- token = QCss::CDC;
- goto found;
- }
- goto out;
state_44:
lastAcceptingPos = pos;
token = QCss::NUMBER;
@@ -549,15 +542,22 @@ int QCssScanner_Generated::lex()
if (ch.unicode() == 37)
goto state_46;
if (ch.unicode() == 45)
- goto state_47;
+ goto state_48;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_75;
+ goto state_74;
if (ch.unicode() == 92)
- goto state_50;
- if (ch.unicode() == 95)
goto state_51;
+ if (ch.unicode() == 95)
+ goto state_50;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_51;
+ goto state_50;
+ goto out;
+ state_45:
+ ch = next();
+ if (ch.unicode() == 62) {
+ token = QCss::CDC;
+ goto found;
+ }
goto out;
state_46:
lastAcceptingPos = pos;
@@ -565,17 +565,17 @@ int QCssScanner_Generated::lex()
goto out;
state_47:
ch = next();
- if (ch.unicode() == 92)
- goto state_50;
- if (ch.unicode() == 95)
- goto state_51;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_51;
+ if (ch.unicode() >= 48 && ch.unicode() <= 57)
+ goto state_44;
goto out;
state_48:
ch = next();
- if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_44;
+ if (ch.unicode() == 92)
+ goto state_51;
+ if (ch.unicode() == 95)
+ goto state_50;
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
+ goto state_50;
goto out;
state_49:
lastAcceptingPos = pos;
@@ -584,45 +584,45 @@ int QCssScanner_Generated::lex()
if (ch.unicode() == 37)
goto state_46;
if (ch.unicode() == 45)
- goto state_47;
- if (ch.unicode() == 46)
goto state_48;
+ if (ch.unicode() == 46)
+ goto state_47;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
goto state_49;
if (ch.unicode() == 92)
- goto state_50;
- if (ch.unicode() == 95)
goto state_51;
+ if (ch.unicode() == 95)
+ goto state_50;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_51;
+ goto state_50;
goto out;
state_50:
+ lastAcceptingPos = pos;
+ token = QCss::LENGTH;
ch = next();
- if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_76;
- if (ch.unicode() == 11)
+ if (ch.unicode() == 45)
goto state_76;
- if (ch.unicode() >= 14 && ch.unicode() <= 47)
+ if (ch.unicode() >= 48 && ch.unicode() <= 57)
goto state_76;
- if (ch.unicode() >= 58 && ch.unicode() <= 96)
+ if (ch.unicode() == 92)
+ goto state_77;
+ if (ch.unicode() == 95)
goto state_76;
- if (ch.unicode() >= 103)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_76;
goto out;
state_51:
- lastAcceptingPos = pos;
- token = QCss::LENGTH;
ch = next();
- if (ch.unicode() == 45)
- goto state_77;
- if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_77;
- if (ch.unicode() == 92)
+ if (ch.unicode() >= 1 && ch.unicode() <= 9)
+ goto state_78;
+ if (ch.unicode() == 11)
+ goto state_78;
+ if (ch.unicode() >= 14 && ch.unicode() <= 47)
+ goto state_78;
+ if (ch.unicode() >= 58 && ch.unicode() <= 96)
+ goto state_78;
+ if (ch.unicode() >= 103)
goto state_78;
- if (ch.unicode() == 95)
- goto state_77;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_77;
goto out;
state_52:
ch = next();
@@ -630,15 +630,27 @@ int QCssScanner_Generated::lex()
goto state_79;
goto out;
state_53:
+ lastAcceptingPos = pos;
+ token = QCss::FUNCTION;
+ goto out;
+ state_54:
+ lastAcceptingPos = pos;
+ token = QCss::IDENT;
ch = next();
- if (ch.unicode() == 92)
+ if (ch.unicode() == 40)
+ goto state_53;
+ if (ch.unicode() == 45)
goto state_54;
- if (ch.unicode() == 95)
+ if (ch.unicode() >= 48 && ch.unicode() <= 57)
+ goto state_54;
+ if (ch.unicode() == 92)
goto state_55;
+ if (ch.unicode() == 95)
+ goto state_54;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_55;
+ goto state_54;
goto out;
- state_54:
+ state_55:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
goto state_80;
@@ -651,7 +663,16 @@ int QCssScanner_Generated::lex()
if (ch.unicode() >= 103)
goto state_80;
goto out;
- state_55:
+ state_58:
+ ch = next();
+ if (ch.unicode() == 92)
+ goto state_60;
+ if (ch.unicode() == 95)
+ goto state_59;
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
+ goto state_59;
+ goto out;
+ state_59:
lastAcceptingPos = pos;
token = QCss::ATKEYWORD_SYM;
ch = next();
@@ -666,58 +687,80 @@ int QCssScanner_Generated::lex()
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_81;
goto out;
- state_56:
+ state_60:
+ ch = next();
+ if (ch.unicode() >= 1 && ch.unicode() <= 9)
+ goto state_83;
+ if (ch.unicode() == 11)
+ goto state_83;
+ if (ch.unicode() >= 14 && ch.unicode() <= 47)
+ goto state_83;
+ if (ch.unicode() >= 58 && ch.unicode() <= 96)
+ goto state_83;
+ if (ch.unicode() >= 103)
+ goto state_83;
+ goto out;
+ state_62:
lastAcceptingPos = pos;
token = QCss::IDENT;
ch = next();
if (ch.unicode() == 40)
- goto state_58;
+ goto state_53;
if (ch.unicode() == 45)
- goto state_59;
+ goto state_54;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_59;
+ goto state_54;
if (ch.unicode() == 92)
- goto state_60;
+ goto state_55;
if (ch.unicode() == 95)
- goto state_59;
+ goto state_54;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_59;
- goto out;
- state_58:
- lastAcceptingPos = pos;
- token = QCss::FUNCTION;
+ goto state_54;
goto out;
- state_59:
+ state_63:
lastAcceptingPos = pos;
- token = QCss::IDENT;
+ token = QCss::HASH;
ch = next();
- if (ch.unicode() == 40)
- goto state_58;
if (ch.unicode() == 45)
- goto state_59;
+ goto state_63;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_59;
+ goto state_63;
if (ch.unicode() == 92)
- goto state_60;
+ goto state_64;
if (ch.unicode() == 95)
- goto state_59;
+ goto state_63;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_59;
+ goto state_63;
goto out;
- state_60:
+ state_64:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_83;
+ goto state_84;
if (ch.unicode() == 11)
- goto state_83;
+ goto state_84;
if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_83;
+ goto state_84;
if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_83;
+ goto state_84;
if (ch.unicode() >= 103)
- goto state_83;
+ goto state_84;
goto out;
- state_63:
+ state_65:
+ lastAcceptingPos = pos;
+ token = QCss::HASH;
+ ch = next();
+ if (ch.unicode() == 45)
+ goto state_63;
+ if (ch.unicode() >= 48 && ch.unicode() <= 57)
+ goto state_63;
+ if (ch.unicode() == 92)
+ goto state_64;
+ if (ch.unicode() == 95)
+ goto state_63;
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
+ goto state_63;
+ goto out;
+ state_66:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
@@ -740,7 +783,7 @@ int QCssScanner_Generated::lex()
if (ch.unicode() >= 123)
goto state_33;
goto out;
- state_64:
+ state_67:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
@@ -763,12 +806,14 @@ int QCssScanner_Generated::lex()
if (ch.unicode() >= 123)
goto state_33;
goto out;
- state_65:
+ state_68:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
goto state_33;
+ if (ch.unicode() == 10)
+ goto state_85;
if (ch.unicode() == 11)
goto state_33;
if (ch.unicode() >= 14 && ch.unicode() <= 33)
@@ -786,14 +831,12 @@ int QCssScanner_Generated::lex()
if (ch.unicode() >= 123)
goto state_33;
goto out;
- state_66:
+ state_69:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
goto state_33;
- if (ch.unicode() == 10)
- goto state_84;
if (ch.unicode() == 11)
goto state_33;
if (ch.unicode() >= 14 && ch.unicode() <= 33)
@@ -811,191 +854,133 @@ int QCssScanner_Generated::lex()
if (ch.unicode() >= 123)
goto state_33;
goto out;
- state_67:
- lastAcceptingPos = pos;
- token = QCss::HASH;
- ch = next();
- if (ch.unicode() == 45)
- goto state_67;
- if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_67;
- if (ch.unicode() == 92)
- goto state_68;
- if (ch.unicode() == 95)
- goto state_67;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_67;
- goto out;
- state_68:
- ch = next();
- if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_85;
- if (ch.unicode() == 11)
- goto state_85;
- if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_85;
- if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_85;
- if (ch.unicode() >= 103)
- goto state_85;
- goto out;
- state_69:
- lastAcceptingPos = pos;
- token = QCss::HASH;
- ch = next();
- if (ch.unicode() == 45)
- goto state_67;
- if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_67;
- if (ch.unicode() == 92)
- goto state_68;
- if (ch.unicode() == 95)
- goto state_67;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_67;
- goto out;
state_70:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_39;
+ goto state_38;
if (ch.unicode() == 11)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_39;
+ goto state_38;
if (ch.unicode() == 39)
- goto state_40;
- if (ch.unicode() >= 40 && ch.unicode() <= 91)
goto state_39;
+ if (ch.unicode() >= 40 && ch.unicode() <= 91)
+ goto state_38;
if (ch.unicode() == 92)
- goto state_41;
+ goto state_40;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_39;
+ goto state_38;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 123)
- goto state_39;
+ goto state_38;
goto out;
state_71:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_39;
+ goto state_38;
if (ch.unicode() == 11)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_39;
+ goto state_38;
if (ch.unicode() == 39)
- goto state_40;
- if (ch.unicode() >= 40 && ch.unicode() <= 91)
goto state_39;
+ if (ch.unicode() >= 40 && ch.unicode() <= 91)
+ goto state_38;
if (ch.unicode() == 92)
- goto state_41;
+ goto state_40;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_39;
+ goto state_38;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 123)
- goto state_39;
+ goto state_38;
goto out;
state_72:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_39;
+ goto state_38;
+ if (ch.unicode() == 10)
+ goto state_86;
if (ch.unicode() == 11)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_39;
+ goto state_38;
if (ch.unicode() == 39)
- goto state_40;
- if (ch.unicode() >= 40 && ch.unicode() <= 91)
goto state_39;
+ if (ch.unicode() >= 40 && ch.unicode() <= 91)
+ goto state_38;
if (ch.unicode() == 92)
- goto state_41;
+ goto state_40;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_39;
+ goto state_38;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 123)
- goto state_39;
+ goto state_38;
goto out;
state_73:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_39;
- if (ch.unicode() == 10)
- goto state_86;
+ goto state_38;
if (ch.unicode() == 11)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_39;
+ goto state_38;
if (ch.unicode() == 39)
- goto state_40;
- if (ch.unicode() >= 40 && ch.unicode() <= 91)
goto state_39;
+ if (ch.unicode() >= 40 && ch.unicode() <= 91)
+ goto state_38;
if (ch.unicode() == 92)
- goto state_41;
+ goto state_40;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_39;
+ goto state_38;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 123)
- goto state_39;
+ goto state_38;
goto out;
- state_75:
+ state_74:
lastAcceptingPos = pos;
token = QCss::NUMBER;
ch = next();
if (ch.unicode() == 37)
goto state_46;
if (ch.unicode() == 45)
- goto state_47;
+ goto state_48;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_75;
+ goto state_74;
if (ch.unicode() == 92)
- goto state_50;
- if (ch.unicode() == 95)
goto state_51;
+ if (ch.unicode() == 95)
+ goto state_50;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_51;
+ goto state_50;
goto out;
state_76:
lastAcceptingPos = pos;
token = QCss::LENGTH;
ch = next();
if (ch.unicode() == 45)
- goto state_77;
+ goto state_76;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_77;
+ goto state_76;
if (ch.unicode() == 92)
- goto state_78;
- if (ch.unicode() == 95)
- goto state_77;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_77;
- goto out;
- state_77:
- lastAcceptingPos = pos;
- token = QCss::LENGTH;
- ch = next();
- if (ch.unicode() == 45)
goto state_77;
- if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_77;
- if (ch.unicode() == 92)
- goto state_78;
if (ch.unicode() == 95)
- goto state_77;
+ goto state_76;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_77;
+ goto state_76;
goto out;
- state_78:
+ state_77:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
goto state_87;
@@ -1008,6 +993,21 @@ int QCssScanner_Generated::lex()
if (ch.unicode() >= 103)
goto state_87;
goto out;
+ state_78:
+ lastAcceptingPos = pos;
+ token = QCss::LENGTH;
+ ch = next();
+ if (ch.unicode() == 45)
+ goto state_76;
+ if (ch.unicode() >= 48 && ch.unicode() <= 57)
+ goto state_76;
+ if (ch.unicode() == 92)
+ goto state_77;
+ if (ch.unicode() == 95)
+ goto state_76;
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
+ goto state_76;
+ goto out;
state_79:
ch = next();
if (ch.unicode() == 45) {
@@ -1017,18 +1017,20 @@ int QCssScanner_Generated::lex()
goto out;
state_80:
lastAcceptingPos = pos;
- token = QCss::ATKEYWORD_SYM;
+ token = QCss::IDENT;
ch = next();
+ if (ch.unicode() == 40)
+ goto state_53;
if (ch.unicode() == 45)
- goto state_81;
+ goto state_54;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_81;
+ goto state_54;
if (ch.unicode() == 92)
- goto state_82;
+ goto state_55;
if (ch.unicode() == 95)
- goto state_81;
+ goto state_54;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_81;
+ goto state_54;
goto out;
state_81:
lastAcceptingPos = pos;
@@ -1060,23 +1062,36 @@ int QCssScanner_Generated::lex()
goto out;
state_83:
lastAcceptingPos = pos;
- token = QCss::IDENT;
+ token = QCss::ATKEYWORD_SYM;
ch = next();
- if (ch.unicode() == 40)
- goto state_58;
if (ch.unicode() == 45)
- goto state_59;
+ goto state_81;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_59;
+ goto state_81;
if (ch.unicode() == 92)
- goto state_60;
+ goto state_82;
if (ch.unicode() == 95)
- goto state_59;
+ goto state_81;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_59;
+ goto state_81;
goto out;
state_84:
lastAcceptingPos = pos;
+ token = QCss::HASH;
+ ch = next();
+ if (ch.unicode() == 45)
+ goto state_63;
+ if (ch.unicode() >= 48 && ch.unicode() <= 57)
+ goto state_63;
+ if (ch.unicode() == 92)
+ goto state_64;
+ if (ch.unicode() == 95)
+ goto state_63;
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
+ goto state_63;
+ goto out;
+ state_85:
+ lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
@@ -1098,58 +1113,43 @@ int QCssScanner_Generated::lex()
if (ch.unicode() >= 123)
goto state_33;
goto out;
- state_85:
- lastAcceptingPos = pos;
- token = QCss::HASH;
- ch = next();
- if (ch.unicode() == 45)
- goto state_67;
- if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_67;
- if (ch.unicode() == 92)
- goto state_68;
- if (ch.unicode() == 95)
- goto state_67;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_67;
- goto out;
state_86:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_39;
+ goto state_38;
if (ch.unicode() == 11)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_39;
+ goto state_38;
if (ch.unicode() == 39)
- goto state_40;
- if (ch.unicode() >= 40 && ch.unicode() <= 91)
goto state_39;
+ if (ch.unicode() >= 40 && ch.unicode() <= 91)
+ goto state_38;
if (ch.unicode() == 92)
- goto state_41;
+ goto state_40;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_39;
+ goto state_38;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_39;
+ goto state_38;
if (ch.unicode() >= 123)
- goto state_39;
+ goto state_38;
goto out;
state_87:
lastAcceptingPos = pos;
token = QCss::LENGTH;
ch = next();
if (ch.unicode() == 45)
- goto state_77;
+ goto state_76;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_77;
+ goto state_76;
if (ch.unicode() == 92)
- goto state_78;
- if (ch.unicode() == 95)
goto state_77;
+ if (ch.unicode() == 95)
+ goto state_76;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_77;
+ goto state_76;
goto out;
state_89:
lastAcceptingPos = pos;
@@ -1176,4 +1176,3 @@ int QCssScanner_Generated::lex()
}
return token;
}
-
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 580a09427c..258a9ba675 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -116,7 +116,17 @@ bool QFontDef::exactMatch(const QFontDef &other) const
if (stretch != 0 && other.stretch != 0 && stretch != other.stretch)
return false;
+ if (families.size() != other.families.size())
+ return false;
+
QString this_family, this_foundry, other_family, other_foundry;
+ for (int i = 0; i < families.size(); ++i) {
+ QFontDatabase::parseFontName(families.at(i), this_foundry, this_family);
+ QFontDatabase::parseFontName(other.families.at(i), other_foundry, other_family);
+ if (this_family != other_family || this_foundry != other_foundry)
+ return false;
+ }
+
QFontDatabase::parseFontName(family, this_foundry, this_family);
QFontDatabase::parseFontName(other.family, other_foundry, other_family);
@@ -261,6 +271,9 @@ void QFontPrivate::resolve(uint mask, const QFontPrivate *other)
if (! (mask & QFont::FamilyResolved))
request.family = other->request.family;
+ if (!(mask & QFont::FamiliesResolved))
+ request.families = other->request.families;
+
if (! (mask & QFont::StyleNameResolved))
request.styleName = other->request.styleName;
@@ -340,7 +353,7 @@ QFontEngineData::~QFontEngineData()
\class QFont
\reentrant
- \brief The QFont class specifies a font used for drawing text.
+ \brief The QFont class specifies a query for a font used for drawing text.
\ingroup painting
\ingroup appearance
@@ -348,6 +361,7 @@ QFontEngineData::~QFontEngineData()
\ingroup richtext-processing
\inmodule QtGui
+ QFont can be regarded as a query for one or more fonts on the system.
When you create a QFont object you specify various attributes that
you want the font to have. Qt will use the font with the specified
@@ -355,9 +369,15 @@ QFontEngineData::~QFontEngineData()
matching installed font. The attributes of the font that is
actually used are retrievable from a QFontInfo object. If the
window system provides an exact match exactMatch() returns \c true.
- Use QFontMetrics to get measurements, e.g. the pixel length of a
+ Use QFontMetricsF to get measurements, e.g. the pixel length of a
string using QFontMetrics::width().
+ Attributes which are not specifically set will not affect the font
+ selection algorithm, and default values will be preferred instead.
+
+ To load a specific physical font, typically represented by a single file,
+ use QRawFont instead.
+
Note that a QGuiApplication instance must exist before a QFont can be
used. You can set the application's default font with
QGuiApplication::setFont().
@@ -390,8 +410,6 @@ QFontEngineData::~QFontEngineData()
setStyleHint(). The default family (corresponding to the current
style hint) is returned by defaultFamily().
- The font-matching algorithm has a lastResortFamily() and
- lastResortFont() in cases where a suitable match cannot be found.
You can provide substitutions for font family names using
insertSubstitution() and insertSubstitutions(). Substitutions can
be removed with removeSubstitutions(). Use substitute() to retrieve
@@ -419,18 +437,21 @@ QFontEngineData::~QFontEngineData()
\target fontmatching
The font matching algorithm works as follows:
\list 1
- \li The specified font family is searched for.
- \li If not found, the styleHint() is used to select a replacement
- family.
- \li Each replacement font family is searched for.
- \li If none of these are found or there was no styleHint(), "helvetica"
- will be searched for.
- \li If "helvetica" isn't found Qt will try the lastResortFamily().
- \li If the lastResortFamily() isn't found Qt will try the
- lastResortFont() which will always return a name of some kind.
+ \li The specified font families (set by setFamilies()) are searched for.
+ \li If not found, then if set the specified font family exists and can be used to represent
+ the writing system in use, it will be selected.
+ \li If not, a replacement font that supports the writing system is
+ selected. The font matching algorithm will try to find the
+ best match for all the properties set in the QFont. How this is
+ done varies from platform to platform.
+ \li If no font exists on the system that can support the text,
+ then special "missing character" boxes will be shown in its place.
\endlist
- Note that the actual font matching algorithm varies from platform to platform.
+ \note If the selected font, though supporting the writing system in general,
+ is missing glyphs for one or more specific characters, then Qt will try to
+ find a fallback font for this or these particular characters. This feature
+ can be disabled using QFont::NoFontMerging style strategy.
In Windows a request for the "Courier" font is automatically changed to
"Courier New", an improved version of Courier that allows for smooth scaling.
@@ -499,6 +520,7 @@ QFontEngineData::~QFontEngineData()
individually and then considered resolved.
\value FamilyResolved
+ \value FamiliesResolved
\value SizeResolved
\value StyleHintResolved
\value StyleStrategyResolved
@@ -1684,6 +1706,7 @@ bool QFont::operator<(const QFont &f) const
if (r1.stretch != r2.stretch) return r1.stretch < r2.stretch;
if (r1.styleHint != r2.styleHint) return r1.styleHint < r2.styleHint;
if (r1.styleStrategy != r2.styleStrategy) return r1.styleStrategy < r2.styleStrategy;
+ if (r1.families != r2.families) return r1.families < r2.families;
if (r1.family != r2.family) return r1.family < r2.family;
if (f.d->capital != d->capital) return f.d->capital < d->capital;
@@ -2133,14 +2156,14 @@ void QFont::cacheStatistics()
{
}
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
\fn QString QFont::lastResortFamily() const
- Returns the "last resort" font family name.
+ \obsolete
- The current implementation tries a wide variety of common fonts,
- returning the first one it finds. Is is possible that no family is
- found in which case an empty string is returned.
+ This function is deprecated and is not in use by the font
+ selection algorithm in Qt 5. It always returns "helvetica".
\sa lastResortFont()
*/
@@ -2148,6 +2171,7 @@ QString QFont::lastResortFamily() const
{
return QString::fromLatin1("helvetica");
}
+#endif
extern QStringList qt_fallbacksForFamily(const QString &family, QFont::Style style,
QFont::StyleHint styleHint, QChar::Script script);
@@ -2169,34 +2193,63 @@ QString QFont::defaultFamily() const
return QString();
}
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
\fn QString QFont::lastResortFont() const
- Returns a "last resort" font name for the font matching algorithm.
- This is used if the last resort family is not available. It will
- always return a name, if necessary returning something like
- "fixed" or "system".
+ \obsolete
+
+ Deprecated function. Since Qt 5.0, this is not used by the font selection algorithm. For
+ compatibility it remains in the API, but will always return the same value as lastResortFamily().
+*/
+QString QFont::lastResortFont() const
+{
+ return lastResortFamily();
+}
+#endif
- The current implementation tries a wide variety of common fonts,
- returning the first one it finds. The implementation may change
- at any time, but this function will always return a string
- containing something.
+/*!
+ \since 5.13
- It is theoretically possible that there really isn't a
- lastResortFont() in which case Qt will abort with an error
- message. We have not been able to identify a case where this
- happens. Please \l{bughowto.html}{report it as a bug} if
- it does, preferably with a list of the fonts you have installed.
+ Returns the requested font family names, i.e. the names set in the last
+ setFamilies() call or via the constructor. Otherwise it returns an
+ empty list.
- \sa lastResortFamily()
+ \sa setFamily(), setFamilies(), family(), substitutes(), substitute()
*/
-QString QFont::lastResortFont() const
+
+QStringList QFont::families() const
{
- qFatal("QFont::lastResortFont: Cannot find any reasonable font");
- // Shut compiler up
- return QString();
+ return d->request.families;
}
+/*!
+ \since 5.13
+
+ Sets the list of family names for the font. The names are case
+ insensitive and may include a foundry name. The first family in
+ \a families will be set as the main family for the font.
+
+ Each family name entry in \a families may optionally also include a
+ foundry name, e.g. "Helvetica [Cronyx]". If the family is
+ available from more than one foundry and the foundry isn't
+ specified, an arbitrary foundry is chosen. If the family isn't
+ available a family will be set using the \l{QFont}{font matching}
+ algorithm.
+
+ \sa family(), families(), setFamily(), setStyleHint(), QFontInfo
+*/
+
+void QFont::setFamilies(const QStringList &families)
+{
+ if ((resolve_mask & QFont::FamiliesResolved) && d->request.families == families)
+ return;
+ detach();
+ d->request.families = families;
+ resolve_mask |= QFont::FamiliesResolved;
+}
+
+
/*****************************************************************************
QFont stream functions
*****************************************************************************/
@@ -2261,6 +2314,8 @@ QDataStream &operator<<(QDataStream &s, const QFont &font)
s << (quint8)font.d->request.hintingPreference;
if (s.version() >= QDataStream::Qt_5_6)
s << (quint8)font.d->capital;
+ if (s.version() >= QDataStream::Qt_5_13)
+ s << font.d->request.families;
return s;
}
@@ -2356,6 +2411,11 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
s >> value;
font.d->capital = QFont::Capitalization(value);
}
+ if (s.version() >= QDataStream::Qt_5_13) {
+ QStringList value;
+ s >> value;
+ font.d->request.families = value;
+ }
return s;
}
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index 9c250c82c3..1fe450e002 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -164,7 +164,8 @@ public:
WordSpacingResolved = 0x4000,
HintingPreferenceResolved = 0x8000,
StyleNameResolved = 0x10000,
- AllPropertiesResolved = 0x1ffff
+ FamiliesResolved = 0x20000,
+ AllPropertiesResolved = 0x3ffff
};
QFont();
@@ -179,6 +180,9 @@ public:
QString family() const;
void setFamily(const QString &);
+ QStringList families() const;
+ void setFamilies(const QStringList &);
+
QString styleName() const;
void setStyleName(const QString &);
@@ -282,8 +286,10 @@ public:
static void cacheStatistics();
QString defaultFamily() const;
- QString lastResortFamily() const;
- QString lastResortFont() const;
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED QString lastResortFamily() const;
+ QT_DEPRECATED QString lastResortFont() const;
+#endif
QFont resolve(const QFont &) const;
inline uint resolve() const { return resolve_mask; }
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index 350ba7ce3c..09c18de5a6 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -78,6 +78,7 @@ struct QFontDef
}
QString family;
+ QStringList families;
QString styleName;
QStringList fallBackFamilies;
@@ -109,6 +110,7 @@ struct QFontDef
&& styleStrategy == other.styleStrategy
&& ignorePitch == other.ignorePitch && fixedPitch == other.fixedPitch
&& family == other.family
+ && families == other.families
&& styleName == other.styleName
&& hintingPreference == other.hintingPreference
;
@@ -122,6 +124,7 @@ struct QFontDef
if (styleHint != other.styleHint) return styleHint < other.styleHint;
if (styleStrategy != other.styleStrategy) return styleStrategy < other.styleStrategy;
if (family != other.family) return family < other.family;
+ if (families != other.families) return families < other.families;
if (styleName != other.styleName)
return styleName < other.styleName;
if (hintingPreference != other.hintingPreference) return hintingPreference < other.hintingPreference;
@@ -144,6 +147,7 @@ inline uint qHash(const QFontDef &fd, uint seed = 0) Q_DECL_NOTHROW
^ qHash(fd.ignorePitch)
^ qHash(fd.fixedPitch)
^ qHash(fd.family, seed)
+ ^ qHash(fd.families, seed)
^ qHash(fd.styleName)
^ qHash(fd.hintingPreference)
;
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 196eebb353..42e7871214 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -696,20 +696,20 @@ static QStringList familyList(const QFontDef &req)
{
// list of families to try
QStringList family_list;
- if (req.family.isEmpty())
- return family_list;
- const auto list = req.family.splitRef(QLatin1Char(','));
- const int numFamilies = list.size();
- family_list.reserve(numFamilies);
- for (int i = 0; i < numFamilies; ++i) {
- QStringRef str = list.at(i).trimmed();
- if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"')))
- || (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\''))))
- str = str.mid(1, str.length() - 2);
- family_list << str.toString();
+ family_list << req.families;
+ if (!req.family.isEmpty()) {
+ const auto list = req.family.splitRef(QLatin1Char(','));
+ const int numFamilies = list.size();
+ family_list.reserve(numFamilies);
+ for (int i = 0; i < numFamilies; ++i) {
+ QStringRef str = list.at(i).trimmed();
+ if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"')))
+ || (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\''))))
+ str = str.mid(1, str.length() - 2);
+ family_list << str.toString();
+ }
}
-
// append the substitute list for each family in family_list
for (int i = 0, size = family_list.size(); i < size; ++i)
family_list += QFont::substitutes(family_list.at(i));
@@ -2688,9 +2688,8 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
}
QString family_name, foundry_name;
-
- parseFontName(request.family, foundry_name, family_name);
-
+ const QString requestFamily = request.families.size() > 0 ? request.families.at(0) : request.family;
+ parseFontName(requestFamily, foundry_name, family_name);
QtFontDesc desc;
QList<int> blackListed;
int index = match(multi ? QChar::Script_Common : script, request, family_name, foundry_name, &desc, blackListed);
@@ -2703,8 +2702,8 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
// Don't pass empty family names to the platform font database, since it will then invoke its own matching
// and we will be out of sync with the matched font.
- if (fontDef.family.isEmpty())
- fontDef.family = desc.family->name;
+ if (fontDef.families.isEmpty() && fontDef.family.isEmpty())
+ fontDef.families = QStringList(desc.family->name);
engine = loadEngine(script, fontDef, desc.family, desc.foundry, desc.style, desc.size);
@@ -2717,13 +2716,13 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
}
if (!engine) {
- if (!request.family.isEmpty()) {
+ if (!requestFamily.isEmpty()) {
QFont::StyleHint styleHint = QFont::StyleHint(request.styleHint);
if (styleHint == QFont::AnyStyle && request.fixedPitch)
styleHint = QFont::TypeWriter;
QStringList fallbacks = request.fallBackFamilies
- + fallbacksForFamily(request.family,
+ + fallbacksForFamily(requestFamily,
QFont::Style(request.style),
styleHint,
QChar::Script(script));
@@ -2741,7 +2740,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
index = match(multi ? QChar::Script_Common : script, def, def.family, QLatin1String(""), &desc, blackListed);
if (index >= 0) {
QFontDef loadDef = def;
- if (loadDef.family.isEmpty())
+ if (loadDef.families.isEmpty() && loadDef.family.isEmpty())
loadDef.family = desc.family->name;
engine = loadEngine(script, loadDef, desc.family, desc.foundry, desc.style, desc.size);
if (engine)
@@ -2782,7 +2781,10 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
// look for the requested font in the engine data cache
// note: fallBackFamilies are not respected in the EngineData cache key;
// join them with the primary selection family to avoid cache misses
- req.family = fallBackFamilies.join(QLatin1Char(','));
+ if (!d->request.family.isEmpty())
+ req.family = fallBackFamilies.join(QLatin1Char(','));
+ if (!d->request.families.isEmpty())
+ req.families = fallBackFamilies;
d->engineData = fontCache->findEngineData(req);
if (!d->engineData) {
@@ -2803,14 +2805,14 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
req.fallBackFamilies = fallBackFamilies;
if (!req.fallBackFamilies.isEmpty())
- req.family = req.fallBackFamilies.takeFirst();
+ req.families = QStringList(req.fallBackFamilies.takeFirst());
// list of families to try
QStringList family_list;
- if (!req.family.isEmpty()) {
+ if (!req.families.isEmpty()) {
// Add primary selection
- family_list << req.family;
+ family_list << req.families.at(0);
// add the default family
QString defaultFamily = QGuiApplication::font().family();
@@ -2824,11 +2826,11 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd();
for (; !fe && it != end; ++it) {
- req.family = *it;
+ req.families = QStringList(*it);
fe = QFontDatabase::findFont(req, script);
if (fe) {
- if (fe->type() == QFontEngine::Box && !req.family.isEmpty()) {
+ if (fe->type() == QFontEngine::Box && !req.families.isEmpty()) {
if (fe->ref.load() == 0)
delete fe;
fe = 0;
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 9b0b0ec0d5..b06b64ca63 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1842,7 +1842,7 @@ QFontEngine *QFontEngineMulti::loadEngine(int at)
{
QFontDef request(fontDef);
request.styleStrategy |= QFont::NoFontMerging;
- request.family = fallbackFamilyAt(at - 1);
+ request.families = QStringList(fallbackFamilyAt(at - 1));
// At this point, the main script of the text has already been considered
// when fetching the list of fallback families from the database, and the
diff --git a/src/gui/text/qsyntaxhighlighter.h b/src/gui/text/qsyntaxhighlighter.h
index d87f89f0fd..ad0d50a4c0 100644
--- a/src/gui/text/qsyntaxhighlighter.h
+++ b/src/gui/text/qsyntaxhighlighter.h
@@ -64,7 +64,7 @@ class Q_GUI_EXPORT QSyntaxHighlighter : public QObject
public:
explicit QSyntaxHighlighter(QObject *parent);
explicit QSyntaxHighlighter(QTextDocument *parent);
- virtual ~QSyntaxHighlighter();
+ ~QSyntaxHighlighter();
void setDocument(QTextDocument *doc);
QTextDocument *document() const;
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 4957da1908..18de8408b5 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -361,6 +361,9 @@ void QTextFormatPrivate::recalcFont() const
case QTextFormat::FontFamily:
f.setFamily(props.at(i).value.toString());
break;
+ case QTextFormat::FontFamilies:
+ f.setFamilies(props.at(i).value.toStringList());
+ break;
case QTextFormat::FontPointSize:
f.setPointSizeF(props.at(i).value.toReal());
break;
@@ -562,6 +565,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
Character properties
\value FontFamily
+ \value FontFamilies
\value FontPointSize
\value FontPixelSize
\value FontSizeAdjustment Specifies the change in size given to the fontsize already set using
@@ -1390,7 +1394,23 @@ QTextCharFormat::QTextCharFormat(const QTextFormat &fmt)
\sa font()
*/
+/*!
+ \fn void QTextCharFormat::setFontFamilies(const QStringList &families)
+ \since 5.13
+
+ Sets the text format's font \a families.
+
+ \sa setFont()
+*/
+
+/*!
+ \fn QStringList QTextCharFormat::fontFamilies() const
+ \since 5.13
+
+ Returns the text format's font families.
+ \sa font()
+*/
/*!
\fn void QTextCharFormat::setFontPointSize(qreal size)
@@ -1919,6 +1939,9 @@ void QTextCharFormat::setFont(const QFont &font, FontPropertiesInheritanceBehavi
if (mask & QFont::FamilyResolved)
setFontFamily(font.family());
+ if (mask & QFont::FamiliesResolved)
+ setFontFamilies(font.families());
+
if (mask & QFont::SizeResolved) {
const qreal pointSize = font.pointSizeF();
if (pointSize > 0) {
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index a8e573d5a4..d27d2e7f17 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -188,6 +188,7 @@ public:
FontStyleStrategy = 0x1FE4,
FontKerning = 0x1FE5,
FontHintingPreference = 0x1FE6,
+ FontFamilies = 0x1FE7,
FontFamily = 0x2000,
FontPointSize = 0x2001,
FontSizeAdjustment = 0x2002,
@@ -428,6 +429,11 @@ public:
inline QString fontFamily() const
{ return stringProperty(FontFamily); }
+ inline void setFontFamilies(const QStringList &families)
+ { setProperty(FontFamilies, QVariant(families)); }
+ inline QVariant fontFamilies() const
+ { return property(FontFamilies); }
+
inline void setFontPointSize(qreal size)
{ setProperty(FontPointSize, size); }
inline qreal fontPointSize() const
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index c9a2a33e5a..04300a4d22 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -861,7 +861,8 @@ QString QTextHtmlParser::parseWord()
++pos;
while (pos < len) {
QChar c = txt.at(pos++);
- if (c == QLatin1Char('\''))
+ // Allow for escaped single quotes as they may be part of the string
+ if (c == QLatin1Char('\'') && (txt.length() > 1 && txt.at(pos - 2) != QLatin1Char('\\')))
break;
else
word += c;
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index 103e0a8222..f5d73affab 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -89,7 +89,7 @@ public:
contentStream = device;
}
- virtual ~QXmlStreamStrategy()
+ ~QXmlStreamStrategy()
{
if (contentStream)
contentStream->close();
diff --git a/src/gui/util/qlayoutpolicy_p.h b/src/gui/util/qlayoutpolicy_p.h
index a729a57e8b..993bf71472 100644
--- a/src/gui/util/qlayoutpolicy_p.h
+++ b/src/gui/util/qlayoutpolicy_p.h
@@ -66,6 +66,7 @@ class QVariant;
class Q_GUI_EXPORT QLayoutPolicy
{
+ Q_GADGET
Q_ENUMS(Policy)
public:
diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp
index 072a7f249d..af5b126953 100644
--- a/src/network/access/qnetworkcookiejar.cpp
+++ b/src/network/access/qnetworkcookiejar.cpp
@@ -45,6 +45,14 @@
#include "QtCore/qdatetime.h"
#if QT_CONFIG(topleveldomain)
#include "private/qtldurl_p.h"
+#else
+QT_BEGIN_NAMESPACE
+static bool qIsEffectiveTLD(QString domain)
+{
+ // provide minimal checking by not accepting cookies on real TLDs
+ return !domain.contains(QLatin1Char('.'));
+}
+QT_END_NAMESPACE
#endif
QT_BEGIN_NAMESPACE
@@ -356,19 +364,12 @@ bool QNetworkCookieJar::validateCookie(const QNetworkCookie &cookie, const QUrl
// https://tools.ietf.org/html/rfc6265#section-5.3 step 5
if (host == domain)
return true;
-#if QT_CONFIG(topleveldomain)
// the check for effective TLDs makes the "embedded dot" rule from RFC 2109 section 4.3.2
// redundant; the "leading dot" rule has been relaxed anyway, see QNetworkCookie::normalize()
// we remove the leading dot for this check if it's present
- if (qIsEffectiveTLD(domain))
- return false; // not accepted
-#else
- // provide minimal checking by not accepting cookies on real TLDs
- if (!domain.contains(QLatin1Char('.')))
- return false;
-#endif
-
- return true;
+ // Normally defined in qtldurl_p.h, but uses fall-back in this file when topleveldomain isn't
+ // configured:
+ return !qIsEffectiveTLD(domain);
}
QT_END_NAMESPACE
diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp
index 34db5b4b31..47ce9ab0c6 100644
--- a/src/network/kernel/qauthenticator.cpp
+++ b/src/network/kernel/qauthenticator.cpp
@@ -465,27 +465,12 @@ QByteArray QAuthenticatorPrivate::calculateResponse(const QByteArray &requestMet
methodString = "";
phase = Done;
break;
- case QAuthenticatorPrivate::Plain:
- response = '\0' + user.toUtf8() + '\0' + password.toUtf8();
- phase = Done;
- break;
case QAuthenticatorPrivate::Basic:
methodString = "Basic ";
response = user.toLatin1() + ':' + password.toLatin1();
response = response.toBase64();
phase = Done;
break;
- case QAuthenticatorPrivate::Login:
- if (challenge.contains("VXNlciBOYW1lAA==")) {
- response = user.toUtf8().toBase64();
- phase = Phase2;
- } else if (challenge.contains("UGFzc3dvcmQA")) {
- response = password.toUtf8().toBase64();
- phase = Done;
- }
- break;
- case QAuthenticatorPrivate::CramMd5:
- break;
case QAuthenticatorPrivate::DigestMd5:
methodString = "Digest ";
response = digestMd5Response(challenge, requestMethod, path);
diff --git a/src/network/kernel/qauthenticator_p.h b/src/network/kernel/qauthenticator_p.h
index 8a1ee0ebe6..265cb7afe2 100644
--- a/src/network/kernel/qauthenticator_p.h
+++ b/src/network/kernel/qauthenticator_p.h
@@ -68,7 +68,7 @@ class QNtlmWindowsHandles;
class Q_AUTOTEST_EXPORT QAuthenticatorPrivate
{
public:
- enum Method { None, Basic, Plain, Login, Ntlm, CramMd5, DigestMd5 };
+ enum Method { None, Basic, Ntlm, DigestMd5 };
QAuthenticatorPrivate();
~QAuthenticatorPrivate();
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp
index 0973d0dd52..1c7a8da06d 100644
--- a/src/network/kernel/qhostinfo.cpp
+++ b/src/network/kernel/qhostinfo.cpp
@@ -300,25 +300,6 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver,
*/
/*!
- \fn template<typename PointerToMemberFunction> int QHostInfo::lookupHost(const QString &name, const QObject *receiver, PointerToMemberFunction function)
-
- \since 5.9
-
- \overload
-
- Looks up the IP address(es) associated with host name \a name, and
- returns an ID for the lookup. When the result of the lookup is
- ready, the slot or signal \a function in \a receiver is called with
- a QHostInfo argument. The QHostInfo object can then be inspected
- to get the results of the lookup.
-
- \note There is no guarantee on the order the signals will be emitted
- if you start multiple requests with lookupHost().
-
- \sa abortHostLookup(), addresses(), error(), fromName()
-*/
-
-/*!
\fn template<typename Functor> int QHostInfo::lookupHost(const QString &name, Functor functor)
\since 5.9
@@ -354,6 +335,16 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver,
thread of \a context. The context's thread must have a running Qt
event loop.
+ Here is an alternative signature for the function:
+ \code
+ lookupHost(const QString &name, const QObject *receiver, PointerToMemberFunction function)
+ \endcode
+
+ In this case, when the result of the lookup is ready, the slot or
+ signal \c{function} in \c{receiver} is called with a QHostInfo
+ argument. The QHostInfo object can then be inspected to get the
+ results of the lookup.
+
\note There is no guarantee on the order the signals will be emitted
if you start multiple requests with lookupHost().
diff --git a/src/network/kernel/qhostinfo.h b/src/network/kernel/qhostinfo.h
index 75917a02a3..49871ad470 100644
--- a/src/network/kernel/qhostinfo.h
+++ b/src/network/kernel/qhostinfo.h
@@ -91,13 +91,10 @@ public:
static QString localDomainName();
#ifdef Q_CLANG_QDOC
- template<typename PointerToMemberFunction>
- static int QHostInfo::lookupHost(const QString &name, const QObject *receiver,
- PointerToMemberFunction function);
template<typename Functor>
- static int QHostInfo::lookupHost(const QString &name, Functor functor);
+ static int lookupHost(const QString &name, Functor functor);
template<typename Functor>
- static int QHostInfo::lookupHost(const QString &name, const QObject *context, Functor functor);
+ static int lookupHost(const QString &name, const QObject *context, Functor functor);
#else
// lookupHost to a QObject slot
template <typename Func>
diff --git a/src/network/ssl/qdtls.h b/src/network/ssl/qdtls.h
index 8505b00d5e..d057eadf19 100644
--- a/src/network/ssl/qdtls.h
+++ b/src/network/ssl/qdtls.h
@@ -48,7 +48,9 @@
#include <QtCore/qcryptographichash.h>
#include <QtCore/qobject.h>
+#ifndef Q_CLANG_QDOC
QT_REQUIRE_CONFIG(dtls);
+#endif
QT_BEGIN_NAMESPACE
diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp
index 9166e0ac29..aa4fb4fe8e 100644
--- a/src/network/ssl/qsslsocket_mac.cpp
+++ b/src/network/ssl/qsslsocket_mac.cpp
@@ -993,9 +993,6 @@ void QSslSocketBackendPrivate::destroySslContext()
context.reset(nullptr);
}
-static QByteArray _q_makePkcs12(const QList<QSslCertificate> &certs, const QSslKey &key, const QString &passPhrase);
-
-
bool QSslSocketBackendPrivate::setSessionCertificate(QString &errorDescription, QAbstractSocket::SocketError &errorCode)
{
Q_ASSERT_X(context, Q_FUNC_INFO, "invalid SSL context (null)");
@@ -1499,264 +1496,4 @@ bool QSslSocketBackendPrivate::startHandshake()
}
}
-/*
- PKCS12 helpers.
-*/
-
-static QAsn1Element wrap(quint8 type, const QAsn1Element &child)
-{
- QByteArray value;
- QDataStream stream(&value, QIODevice::WriteOnly);
- child.write(stream);
- return QAsn1Element(type, value);
-}
-
-static QAsn1Element _q_PKCS7_data(const QByteArray &data)
-{
- QVector<QAsn1Element> items;
- items << QAsn1Element::fromObjectId("1.2.840.113549.1.7.1");
- items << wrap(QAsn1Element::Context0Type,
- QAsn1Element(QAsn1Element::OctetStringType, data));
- return QAsn1Element::fromVector(items);
-}
-
-/*!
- PKCS #12 key derivation.
-
- Some test vectors:
- http://www.drh-consultancy.demon.co.uk/test.txt
-*/
-static QByteArray _q_PKCS12_keygen(char id, const QByteArray &salt, const QString &passPhrase, int n, int r)
-{
- const int u = 20;
- const int v = 64;
-
- // password formatting
- QByteArray passUnicode(passPhrase.size() * 2 + 2, '\0');
- char *p = passUnicode.data();
- for (int i = 0; i < passPhrase.size(); ++i) {
- quint16 ch = passPhrase[i].unicode();
- *(p++) = (ch & 0xff00) >> 8;
- *(p++) = (ch & 0xff);
- }
-
- // prepare I
- QByteArray D(64, id);
- QByteArray S, P;
- const int sSize = v * ((salt.size() + v - 1) / v);
- S.resize(sSize);
- for (int i = 0; i < sSize; ++i) {
- S[i] = salt[i % salt.size()];
- }
- const int pSize = v * ((passUnicode.size() + v - 1) / v);
- P.resize(pSize);
- for (int i = 0; i < pSize; ++i) {
- P[i] = passUnicode[i % passUnicode.size()];
- }
- QByteArray I = S + P;
-
- // apply hashing
- const int c = (n + u - 1) / u;
- QByteArray A;
- QByteArray B;
- B.resize(v);
- QCryptographicHash hash(QCryptographicHash::Sha1);
- for (int i = 0; i < c; ++i) {
- // hash r iterations
- QByteArray Ai = D + I;
- for (int j = 0; j < r; ++j) {
- hash.reset();
- hash.addData(Ai);
- Ai = hash.result();
- }
-
- for (int j = 0; j < v; ++j) {
- B[j] = Ai[j % u];
- }
-
- // modify I as Ij = (Ij + B + 1) modulo 2^v
- for (int p = 0; p < I.size(); p += v) {
- quint8 carry = 1;
- for (int j = v - 1; j >= 0; --j) {
- quint16 v = quint8(I[p+j]) + quint8(B[j]) + carry;
- I[p+j] = v & 0xff;
- carry = (v & 0xff00) >> 8;
- }
- }
- A += Ai;
- }
- return A.left(n);
-}
-
-static QByteArray _q_PKCS12_salt()
-{
- QByteArray salt;
- salt.resize(8);
- for (int i = 0; i < salt.size(); ++i) {
- salt[i] = (qrand() & 0xff);
- }
- return salt;
-}
-
-static QByteArray _q_PKCS12_certBag(const QSslCertificate &cert)
-{
- QVector<QAsn1Element> items;
- items << QAsn1Element::fromObjectId("1.2.840.113549.1.12.10.1.3");
-
- // certificate
- QVector<QAsn1Element> certItems;
- certItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.22.1");
- certItems << wrap(QAsn1Element::Context0Type,
- QAsn1Element(QAsn1Element::OctetStringType, cert.toDer()));
- items << wrap(QAsn1Element::Context0Type,
- QAsn1Element::fromVector(certItems));
-
- // local key id
- const QByteArray localKeyId = cert.digest(QCryptographicHash::Sha1);
- QVector<QAsn1Element> idItems;
- idItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.21");
- idItems << wrap(QAsn1Element::SetType,
- QAsn1Element(QAsn1Element::OctetStringType, localKeyId));
- items << wrap(QAsn1Element::SetType, QAsn1Element::fromVector(idItems));
-
- // dump
- QAsn1Element root = wrap(QAsn1Element::SequenceType, QAsn1Element::fromVector(items));
- QByteArray ba;
- QDataStream stream(&ba, QIODevice::WriteOnly);
- root.write(stream);
- return ba;
-}
-
-static QAsn1Element _q_PKCS12_key(const QSslKey &key)
-{
- Q_ASSERT(key.algorithm() == QSsl::Rsa || key.algorithm() == QSsl::Dsa);
-
- QVector<QAsn1Element> keyItems;
- keyItems << QAsn1Element::fromInteger(0);
- QVector<QAsn1Element> algoItems;
- if (key.algorithm() == QSsl::Rsa)
- algoItems << QAsn1Element::fromObjectId(RSA_ENCRYPTION_OID);
- else if (key.algorithm() == QSsl::Dsa)
- algoItems << QAsn1Element::fromObjectId(DSA_ENCRYPTION_OID);
- algoItems << QAsn1Element(QAsn1Element::NullType);
- keyItems << QAsn1Element::fromVector(algoItems);
- keyItems << QAsn1Element(QAsn1Element::OctetStringType, key.toDer());
- return QAsn1Element::fromVector(keyItems);
-}
-
-static QByteArray _q_PKCS12_shroudedKeyBag(const QSslKey &key, const QString &passPhrase, const QByteArray &localKeyId)
-{
- const int iterations = 2048;
- QByteArray salt = _q_PKCS12_salt();
- QByteArray cKey = _q_PKCS12_keygen(1, salt, passPhrase, 24, iterations);
- QByteArray cIv = _q_PKCS12_keygen(2, salt, passPhrase, 8, iterations);
-
- // prepare and encrypt data
- QByteArray plain;
- QDataStream plainStream(&plain, QIODevice::WriteOnly);
- _q_PKCS12_key(key).write(plainStream);
- QByteArray crypted = QSslKeyPrivate::encrypt(QSslKeyPrivate::DesEde3Cbc,
- plain, cKey, cIv);
-
- QVector<QAsn1Element> items;
- items << QAsn1Element::fromObjectId("1.2.840.113549.1.12.10.1.2");
-
- // key
- QVector<QAsn1Element> keyItems;
- QVector<QAsn1Element> algoItems;
- algoItems << QAsn1Element::fromObjectId("1.2.840.113549.1.12.1.3");
- QVector<QAsn1Element> paramItems;
- paramItems << QAsn1Element(QAsn1Element::OctetStringType, salt);
- paramItems << QAsn1Element::fromInteger(iterations);
- algoItems << QAsn1Element::fromVector(paramItems);
- keyItems << QAsn1Element::fromVector(algoItems);
- keyItems << QAsn1Element(QAsn1Element::OctetStringType, crypted);
- items << wrap(QAsn1Element::Context0Type,
- QAsn1Element::fromVector(keyItems));
-
- // local key id
- QVector<QAsn1Element> idItems;
- idItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.21");
- idItems << wrap(QAsn1Element::SetType,
- QAsn1Element(QAsn1Element::OctetStringType, localKeyId));
- items << wrap(QAsn1Element::SetType,
- QAsn1Element::fromVector(idItems));
-
- // dump
- QAsn1Element root = wrap(QAsn1Element::SequenceType, QAsn1Element::fromVector(items));
- QByteArray ba;
- QDataStream stream(&ba, QIODevice::WriteOnly);
- root.write(stream);
- return ba;
-}
-
-static QByteArray _q_PKCS12_bag(const QList<QSslCertificate> &certs, const QSslKey &key, const QString &passPhrase)
-{
- QVector<QAsn1Element> items;
-
- // certs
- for (int i = 0; i < certs.size(); ++i)
- items << _q_PKCS7_data(_q_PKCS12_certBag(certs[i]));
-
- // key
- const QByteArray localKeyId = certs.first().digest(QCryptographicHash::Sha1);
- items << _q_PKCS7_data(_q_PKCS12_shroudedKeyBag(key, passPhrase, localKeyId));
-
- // dump
- QAsn1Element root = QAsn1Element::fromVector(items);
- QByteArray ba;
- QDataStream stream(&ba, QIODevice::WriteOnly);
- root.write(stream);
- return ba;
-}
-
-static QAsn1Element _q_PKCS12_mac(const QByteArray &data, const QString &passPhrase)
-{
- const int iterations = 2048;
-
- // salt generation
- QByteArray macSalt = _q_PKCS12_salt();
- QByteArray key = _q_PKCS12_keygen(3, macSalt, passPhrase, 20, iterations);
-
- // HMAC calculation
- QMessageAuthenticationCode hmac(QCryptographicHash::Sha1, key);
- hmac.addData(data);
-
- QVector<QAsn1Element> algoItems;
- algoItems << QAsn1Element::fromObjectId("1.3.14.3.2.26");
- algoItems << QAsn1Element(QAsn1Element::NullType);
-
- QVector<QAsn1Element> digestItems;
- digestItems << QAsn1Element::fromVector(algoItems);
- digestItems << QAsn1Element(QAsn1Element::OctetStringType, hmac.result());
-
- QVector<QAsn1Element> macItems;
- macItems << QAsn1Element::fromVector(digestItems);
- macItems << QAsn1Element(QAsn1Element::OctetStringType, macSalt);
- macItems << QAsn1Element::fromInteger(iterations);
- return QAsn1Element::fromVector(macItems);
-}
-
-QByteArray _q_makePkcs12(const QList<QSslCertificate> &certs, const QSslKey &key, const QString &passPhrase)
-{
- QVector<QAsn1Element> items;
-
- // version
- items << QAsn1Element::fromInteger(3);
-
- // auth safe
- const QByteArray data = _q_PKCS12_bag(certs, key, passPhrase);
- items << _q_PKCS7_data(data);
-
- // HMAC
- items << _q_PKCS12_mac(data, passPhrase);
-
- // dump
- QAsn1Element root = QAsn1Element::fromVector(items);
- QByteArray ba;
- QDataStream stream(&ba, QIODevice::WriteOnly);
- root.write(stream);
- return ba;
-}
-
QT_END_NAMESPACE
diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h
index 6f34c6c888..c27496ec02 100644
--- a/src/network/ssl/qsslsocket_p.h
+++ b/src/network/ssl/qsslsocket_p.h
@@ -222,6 +222,11 @@ protected:
bool flushTriggered;
};
+#if QT_CONFIG(securetransport)
+// Implemented in qsslsocket_qt.cpp
+QByteArray _q_makePkcs12(const QList<QSslCertificate> &certs, const QSslKey &key, const QString &passPhrase);
+#endif
+
QT_END_NAMESPACE
#endif
diff --git a/src/network/ssl/qsslsocket_qt.cpp b/src/network/ssl/qsslsocket_qt.cpp
new file mode 100644
index 0000000000..2c78f0f4e7
--- /dev/null
+++ b/src/network/ssl/qsslsocket_qt.cpp
@@ -0,0 +1,309 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jeremy Lainé <jeremy.laine@m4x.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore/qbytearray.h>
+#include <QtCore/qdatastream.h>
+#include <QtCore/qmessageauthenticationcode.h>
+
+#include "qsslsocket_p.h"
+#include "qasn1element_p.h"
+#include "qsslkey_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*
+ PKCS12 helpers.
+*/
+
+static QAsn1Element wrap(quint8 type, const QAsn1Element &child)
+{
+ QByteArray value;
+ QDataStream stream(&value, QIODevice::WriteOnly);
+ child.write(stream);
+ return QAsn1Element(type, value);
+}
+
+static QAsn1Element _q_PKCS7_data(const QByteArray &data)
+{
+ QVector<QAsn1Element> items;
+ items << QAsn1Element::fromObjectId("1.2.840.113549.1.7.1");
+ items << wrap(QAsn1Element::Context0Type,
+ QAsn1Element(QAsn1Element::OctetStringType, data));
+ return QAsn1Element::fromVector(items);
+}
+
+/*!
+ PKCS #12 key derivation.
+
+ Some test vectors:
+ http://www.drh-consultancy.demon.co.uk/test.txt
+*/
+static QByteArray _q_PKCS12_keygen(char id, const QByteArray &salt, const QString &passPhrase, int n, int r)
+{
+ const int u = 20;
+ const int v = 64;
+
+ // password formatting
+ QByteArray passUnicode(passPhrase.size() * 2 + 2, '\0');
+ char *p = passUnicode.data();
+ for (int i = 0; i < passPhrase.size(); ++i) {
+ quint16 ch = passPhrase[i].unicode();
+ *(p++) = (ch & 0xff00) >> 8;
+ *(p++) = (ch & 0xff);
+ }
+
+ // prepare I
+ QByteArray D(64, id);
+ QByteArray S, P;
+ const int sSize = v * ((salt.size() + v - 1) / v);
+ S.resize(sSize);
+ for (int i = 0; i < sSize; ++i) {
+ S[i] = salt[i % salt.size()];
+ }
+ const int pSize = v * ((passUnicode.size() + v - 1) / v);
+ P.resize(pSize);
+ for (int i = 0; i < pSize; ++i) {
+ P[i] = passUnicode[i % passUnicode.size()];
+ }
+ QByteArray I = S + P;
+
+ // apply hashing
+ const int c = (n + u - 1) / u;
+ QByteArray A;
+ QByteArray B;
+ B.resize(v);
+ QCryptographicHash hash(QCryptographicHash::Sha1);
+ for (int i = 0; i < c; ++i) {
+ // hash r iterations
+ QByteArray Ai = D + I;
+ for (int j = 0; j < r; ++j) {
+ hash.reset();
+ hash.addData(Ai);
+ Ai = hash.result();
+ }
+
+ for (int j = 0; j < v; ++j) {
+ B[j] = Ai[j % u];
+ }
+
+ // modify I as Ij = (Ij + B + 1) modulo 2^v
+ for (int p = 0; p < I.size(); p += v) {
+ quint8 carry = 1;
+ for (int j = v - 1; j >= 0; --j) {
+ quint16 v = quint8(I[p+j]) + quint8(B[j]) + carry;
+ I[p+j] = v & 0xff;
+ carry = (v & 0xff00) >> 8;
+ }
+ }
+ A += Ai;
+ }
+ return A.left(n);
+}
+
+static QByteArray _q_PKCS12_salt()
+{
+ QByteArray salt;
+ salt.resize(8);
+ for (int i = 0; i < salt.size(); ++i) {
+ salt[i] = (qrand() & 0xff);
+ }
+ return salt;
+}
+
+static QByteArray _q_PKCS12_certBag(const QSslCertificate &cert)
+{
+ QVector<QAsn1Element> items;
+ items << QAsn1Element::fromObjectId("1.2.840.113549.1.12.10.1.3");
+
+ // certificate
+ QVector<QAsn1Element> certItems;
+ certItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.22.1");
+ certItems << wrap(QAsn1Element::Context0Type,
+ QAsn1Element(QAsn1Element::OctetStringType, cert.toDer()));
+ items << wrap(QAsn1Element::Context0Type,
+ QAsn1Element::fromVector(certItems));
+
+ // local key id
+ const QByteArray localKeyId = cert.digest(QCryptographicHash::Sha1);
+ QVector<QAsn1Element> idItems;
+ idItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.21");
+ idItems << wrap(QAsn1Element::SetType,
+ QAsn1Element(QAsn1Element::OctetStringType, localKeyId));
+ items << wrap(QAsn1Element::SetType, QAsn1Element::fromVector(idItems));
+
+ // dump
+ QAsn1Element root = wrap(QAsn1Element::SequenceType, QAsn1Element::fromVector(items));
+ QByteArray ba;
+ QDataStream stream(&ba, QIODevice::WriteOnly);
+ root.write(stream);
+ return ba;
+}
+
+static QAsn1Element _q_PKCS12_key(const QSslKey &key)
+{
+ Q_ASSERT(key.algorithm() == QSsl::Rsa || key.algorithm() == QSsl::Dsa);
+
+ QVector<QAsn1Element> keyItems;
+ keyItems << QAsn1Element::fromInteger(0);
+ QVector<QAsn1Element> algoItems;
+ if (key.algorithm() == QSsl::Rsa)
+ algoItems << QAsn1Element::fromObjectId(RSA_ENCRYPTION_OID);
+ else if (key.algorithm() == QSsl::Dsa)
+ algoItems << QAsn1Element::fromObjectId(DSA_ENCRYPTION_OID);
+ algoItems << QAsn1Element(QAsn1Element::NullType);
+ keyItems << QAsn1Element::fromVector(algoItems);
+ keyItems << QAsn1Element(QAsn1Element::OctetStringType, key.toDer());
+ return QAsn1Element::fromVector(keyItems);
+}
+
+static QByteArray _q_PKCS12_shroudedKeyBag(const QSslKey &key, const QString &passPhrase, const QByteArray &localKeyId)
+{
+ const int iterations = 2048;
+ QByteArray salt = _q_PKCS12_salt();
+ QByteArray cKey = _q_PKCS12_keygen(1, salt, passPhrase, 24, iterations);
+ QByteArray cIv = _q_PKCS12_keygen(2, salt, passPhrase, 8, iterations);
+
+ // prepare and encrypt data
+ QByteArray plain;
+ QDataStream plainStream(&plain, QIODevice::WriteOnly);
+ _q_PKCS12_key(key).write(plainStream);
+ QByteArray crypted = QSslKeyPrivate::encrypt(QSslKeyPrivate::DesEde3Cbc,
+ plain, cKey, cIv);
+
+ QVector<QAsn1Element> items;
+ items << QAsn1Element::fromObjectId("1.2.840.113549.1.12.10.1.2");
+
+ // key
+ QVector<QAsn1Element> keyItems;
+ QVector<QAsn1Element> algoItems;
+ algoItems << QAsn1Element::fromObjectId("1.2.840.113549.1.12.1.3");
+ QVector<QAsn1Element> paramItems;
+ paramItems << QAsn1Element(QAsn1Element::OctetStringType, salt);
+ paramItems << QAsn1Element::fromInteger(iterations);
+ algoItems << QAsn1Element::fromVector(paramItems);
+ keyItems << QAsn1Element::fromVector(algoItems);
+ keyItems << QAsn1Element(QAsn1Element::OctetStringType, crypted);
+ items << wrap(QAsn1Element::Context0Type,
+ QAsn1Element::fromVector(keyItems));
+
+ // local key id
+ QVector<QAsn1Element> idItems;
+ idItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.21");
+ idItems << wrap(QAsn1Element::SetType,
+ QAsn1Element(QAsn1Element::OctetStringType, localKeyId));
+ items << wrap(QAsn1Element::SetType,
+ QAsn1Element::fromVector(idItems));
+
+ // dump
+ QAsn1Element root = wrap(QAsn1Element::SequenceType, QAsn1Element::fromVector(items));
+ QByteArray ba;
+ QDataStream stream(&ba, QIODevice::WriteOnly);
+ root.write(stream);
+ return ba;
+}
+
+static QByteArray _q_PKCS12_bag(const QList<QSslCertificate> &certs, const QSslKey &key, const QString &passPhrase)
+{
+ QVector<QAsn1Element> items;
+
+ // certs
+ for (int i = 0; i < certs.size(); ++i)
+ items << _q_PKCS7_data(_q_PKCS12_certBag(certs[i]));
+
+ // key
+ const QByteArray localKeyId = certs.first().digest(QCryptographicHash::Sha1);
+ items << _q_PKCS7_data(_q_PKCS12_shroudedKeyBag(key, passPhrase, localKeyId));
+
+ // dump
+ QAsn1Element root = QAsn1Element::fromVector(items);
+ QByteArray ba;
+ QDataStream stream(&ba, QIODevice::WriteOnly);
+ root.write(stream);
+ return ba;
+}
+
+static QAsn1Element _q_PKCS12_mac(const QByteArray &data, const QString &passPhrase)
+{
+ const int iterations = 2048;
+
+ // salt generation
+ QByteArray macSalt = _q_PKCS12_salt();
+ QByteArray key = _q_PKCS12_keygen(3, macSalt, passPhrase, 20, iterations);
+
+ // HMAC calculation
+ QMessageAuthenticationCode hmac(QCryptographicHash::Sha1, key);
+ hmac.addData(data);
+
+ QVector<QAsn1Element> algoItems;
+ algoItems << QAsn1Element::fromObjectId("1.3.14.3.2.26");
+ algoItems << QAsn1Element(QAsn1Element::NullType);
+
+ QVector<QAsn1Element> digestItems;
+ digestItems << QAsn1Element::fromVector(algoItems);
+ digestItems << QAsn1Element(QAsn1Element::OctetStringType, hmac.result());
+
+ QVector<QAsn1Element> macItems;
+ macItems << QAsn1Element::fromVector(digestItems);
+ macItems << QAsn1Element(QAsn1Element::OctetStringType, macSalt);
+ macItems << QAsn1Element::fromInteger(iterations);
+ return QAsn1Element::fromVector(macItems);
+}
+
+QByteArray _q_makePkcs12(const QList<QSslCertificate> &certs, const QSslKey &key, const QString &passPhrase)
+{
+ QVector<QAsn1Element> items;
+
+ // version
+ items << QAsn1Element::fromInteger(3);
+
+ // auth safe
+ const QByteArray data = _q_PKCS12_bag(certs, key, passPhrase);
+ items << _q_PKCS7_data(data);
+
+ // HMAC
+ items << _q_PKCS12_mac(data, passPhrase);
+
+ // dump
+ QAsn1Element root = QAsn1Element::fromVector(items);
+ QByteArray ba;
+ QDataStream stream(&ba, QIODevice::WriteOnly);
+ root.write(stream);
+ return ba;
+}
+
+QT_END_NAMESPACE
diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri
index 6975264038..b5603c1258 100644
--- a/src/network/ssl/ssl.pri
+++ b/src/network/ssl/ssl.pri
@@ -56,6 +56,7 @@ qtConfig(ssl) {
ssl/qsslkey_mac.cpp \
ssl/qsslsocket_mac_shared.cpp \
ssl/qsslsocket_mac.cpp \
+ ssl/qsslsocket_qt.cpp \
ssl/qsslellipticcurve_dummy.cpp
}
diff --git a/src/opengl/doc/qtopengl.qdocconf b/src/opengl/doc/qtopengl.qdocconf
index 6ff6cae2cb..2d38a5d2af 100644
--- a/src/opengl/doc/qtopengl.qdocconf
+++ b/src/opengl/doc/qtopengl.qdocconf
@@ -23,6 +23,8 @@ depends += qtdoc qtcore qtgui qtwidgets qmake
examplesinstallpath = opengl
+tagfile = qtopengl.tags
+
# The following parameters are for creating a qhp file, the qhelpgenerator
# program can convert the qhp file into a qch file which can be opened in
# Qt Assistant and/or Qt Creator.
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index e136ddcff2..666cc19bbe 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -3880,12 +3880,9 @@ void QGLContext::doneCurrent()
*/
QGLWidget::QGLWidget(QWidget *parent, const QGLWidget* shareWidget, Qt::WindowFlags f)
- : QWidget(*(new QGLWidgetPrivate), parent, f | Qt::MSWindowsOwnDC)
+ : QWidget(*(new QGLWidgetPrivate), parent, f)
{
Q_D(QGLWidget);
- setAttribute(Qt::WA_PaintOnScreen);
- setAttribute(Qt::WA_NoSystemBackground);
- setAutoFillBackground(true); // for compatibility
d->init(new QGLContext(QGLFormat::defaultFormat(), this), shareWidget);
}
@@ -3893,12 +3890,9 @@ QGLWidget::QGLWidget(QWidget *parent, const QGLWidget* shareWidget, Qt::WindowFl
\internal
*/
QGLWidget::QGLWidget(QGLWidgetPrivate &dd, const QGLFormat &format, QWidget *parent, const QGLWidget *shareWidget, Qt::WindowFlags f)
- : QWidget(dd, parent, f | Qt::MSWindowsOwnDC)
+ : QWidget(dd, parent, f)
{
Q_D(QGLWidget);
- setAttribute(Qt::WA_PaintOnScreen);
- setAttribute(Qt::WA_NoSystemBackground);
- setAutoFillBackground(true); // for compatibility
d->init(new QGLContext(format, this), shareWidget);
}
@@ -3935,12 +3929,9 @@ QGLWidget::QGLWidget(QGLWidgetPrivate &dd, const QGLFormat &format, QWidget *par
QGLWidget::QGLWidget(const QGLFormat &format, QWidget *parent, const QGLWidget* shareWidget,
Qt::WindowFlags f)
- : QWidget(*(new QGLWidgetPrivate), parent, f | Qt::MSWindowsOwnDC)
+ : QWidget(*(new QGLWidgetPrivate), parent, f)
{
Q_D(QGLWidget);
- setAttribute(Qt::WA_PaintOnScreen);
- setAttribute(Qt::WA_NoSystemBackground);
- setAutoFillBackground(true); // for compatibility
d->init(new QGLContext(format, this), shareWidget);
}
@@ -3971,12 +3962,9 @@ QGLWidget::QGLWidget(const QGLFormat &format, QWidget *parent, const QGLWidget*
*/
QGLWidget::QGLWidget(QGLContext *context, QWidget *parent, const QGLWidget *shareWidget,
Qt::WindowFlags f)
- : QWidget(*(new QGLWidgetPrivate), parent, f | Qt::MSWindowsOwnDC)
+ : QWidget(*(new QGLWidgetPrivate), parent, f)
{
Q_D(QGLWidget);
- setAttribute(Qt::WA_PaintOnScreen);
- setAttribute(Qt::WA_NoSystemBackground);
- setAutoFillBackground(true); // for compatibility
d->init(context, shareWidget);
}
@@ -5169,6 +5157,15 @@ QPaintEngine *QGLWidget::paintEngine() const
void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget)
{
+ Q_Q(QGLWidget);
+ q->setAttribute(Qt::WA_PaintOnScreen);
+ q->setAttribute(Qt::WA_NoSystemBackground);
+ q->setAutoFillBackground(true); // for compatibility
+
+ mustHaveWindowHandle = 1;
+ q->setAttribute(Qt::WA_NativeWindow);
+ q->setWindowFlag(Qt::MSWindowsOwnDC);
+
initContext(context, shareWidget);
}
diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h
index a1ba0485e0..f5accbeb3c 100644
--- a/src/opengl/qgl.h
+++ b/src/opengl/qgl.h
@@ -51,22 +51,6 @@
#include <QtGui/QSurfaceFormat>
-#if defined(Q_CLANG_QDOC)
-#undef GLint
-typedef int GLint;
-#undef GLuint
-typedef unsigned int GLuint;
-#undef GLenum
-typedef unsigned int GLenum;
-#undef GLclampf
-typedef float GLclampf;
-#undef GLsizei
-typedef int GLsizei;
-#undef GLboolean
-typedef bool GLboolean;
-#endif
-
-
QT_BEGIN_NAMESPACE
diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h
index dfdef44b54..3ce88197d2 100644
--- a/src/opengl/qglshaderprogram.h
+++ b/src/opengl/qglshaderprogram.h
@@ -46,17 +46,6 @@
#include <QtGui/qvector4d.h>
#include <QtGui/qmatrix4x4.h>
-#if defined(Q_CLANG_QDOC)
-#undef GLfloat
-typedef double GLfloat;
-#undef GLint
-typedef int GLint;
-#undef GLuint
-typedef unsigned int GLuint;
-#undef GLenum
-typedef unsigned int GLenum;
-#endif
-
QT_BEGIN_NAMESPACE
diff --git a/src/platformheaders/doc/qtplatformheaders.qdocconf b/src/platformheaders/doc/qtplatformheaders.qdocconf
index 1ff6fe7a21..9a034e7671 100644
--- a/src/platformheaders/doc/qtplatformheaders.qdocconf
+++ b/src/platformheaders/doc/qtplatformheaders.qdocconf
@@ -35,5 +35,7 @@ sourcedirs += ..
exampledirs += snippets
imagedirs += images
+tagfile = qtplatformheaders.tags
+
navigation.landingpage = "Qt Platform Headers"
navigation.cppclassespage = "Qt Platform Headers C++ Classes"
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
index c70d507b99..00a0643dd1 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
@@ -1930,13 +1930,13 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const Q
} else {
HGDIOBJ oldFont = SelectObject(data->hdc, hfont);
+ const QFont::HintingPreference hintingPreference =
+ static_cast<QFont::HintingPreference>(request.hintingPreference);
+ bool useDw = useDirectWrite(hintingPreference, fam);
+
IDWriteFontFace *directWriteFontFace = NULL;
HRESULT hr = data->directWriteGdiInterop->CreateFontFaceFromHdc(data->hdc, &directWriteFontFace);
- if (FAILED(hr)) {
- const QString errorString = qt_error_string(int(hr));
- qWarning().noquote().nospace() << "DirectWrite: CreateFontFaceFromHDC() failed ("
- << errorString << ") for " << request << ' ' << lf << " dpi=" << dpi;
- } else {
+ if (SUCCEEDED(hr)) {
bool isColorFont = false;
#if defined(QT_USE_DIRECTWRITE2)
IDWriteFontFace2 *directWriteFontFace2 = nullptr;
@@ -1946,9 +1946,7 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const Q
isColorFont = directWriteFontFace2->GetPaletteEntryCount() > 0;
}
#endif
- const QFont::HintingPreference hintingPreference =
- static_cast<QFont::HintingPreference>(request.hintingPreference);
- const bool useDw = useDirectWrite(hintingPreference, fam, isColorFont);
+ useDw = useDw || useDirectWrite(hintingPreference, fam, isColorFont);
qCDebug(lcQpaFonts) << __FUNCTION__ << request.family << request.pointSize
<< "pt" << "hintingPreference=" << hintingPreference << "color=" << isColorFont
<< dpi << "dpi" << "useDirectWrite=" << useDw;
@@ -1970,6 +1968,10 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const Q
} else {
directWriteFontFace->Release();
}
+ } else if (useDw) {
+ const QString errorString = qt_error_string(int(hr));
+ qWarning().noquote().nospace() << "DirectWrite: CreateFontFaceFromHDC() failed ("
+ << errorString << ") for " << request << ' ' << lf << " dpi=" << dpi;
}
SelectObject(data->hdc, oldFont);
diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp
index d7cc36627a..99ae2671dd 100644
--- a/src/platformsupport/glxconvenience/qglxconvenience.cpp
+++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp
@@ -223,14 +223,15 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format
continue;
}
- QXlibPointer<XVisualInfo> visual(glXGetVisualFromFBConfig(display, candidate));
- if (visual.isNull())
- continue;
+ int actualRed;
+ int actualGreen;
+ int actualBlue;
+ int actualAlpha;
+ glXGetFBConfigAttrib(display, candidate, GLX_RED_SIZE, &actualRed);
+ glXGetFBConfigAttrib(display, candidate, GLX_GREEN_SIZE, &actualGreen);
+ glXGetFBConfigAttrib(display, candidate, GLX_BLUE_SIZE, &actualBlue);
+ glXGetFBConfigAttrib(display, candidate, GLX_ALPHA_SIZE, &actualAlpha);
- const int actualRed = qPopulationCount(visual->red_mask);
- const int actualGreen = qPopulationCount(visual->green_mask);
- const int actualBlue = qPopulationCount(visual->blue_mask);
- const int actualAlpha = visual->depth - actualRed - actualGreen - actualBlue;
if (requestedRed && actualRed < requestedRed)
continue;
diff --git a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
index e81d272d4f..ca740f967e 100644
--- a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+++ b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
@@ -52,6 +52,9 @@
#include <qdebug.h>
#include <qrect.h>
#include <qloggingcategory.h>
+#include <qstandardpaths.h>
+#include <qdir.h>
+#include <qmetaobject.h>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformservices.h>
#include <qdbusconnectioninterface.h>
diff --git a/src/platformsupport/themes/genericunix/dbustray/qstatusnotifieritemadaptor.cpp b/src/platformsupport/themes/genericunix/dbustray/qstatusnotifieritemadaptor.cpp
index d3c5454f01..ef2d330959 100644
--- a/src/platformsupport/themes/genericunix/dbustray/qstatusnotifieritemadaptor.cpp
+++ b/src/platformsupport/themes/genericunix/dbustray/qstatusnotifieritemadaptor.cpp
@@ -52,6 +52,9 @@
#ifndef QT_NO_SYSTEMTRAYICON
+#include <QtCore/QLoggingCategory>
+#include <QtCore/QCoreApplication>
+
#include "qdbustrayicon_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/platformsupport/themes/genericunix/dbustray/qxdgnotificationproxy_p.h b/src/platformsupport/themes/genericunix/dbustray/qxdgnotificationproxy_p.h
index 03899723ab..352b4aa5d6 100644
--- a/src/platformsupport/themes/genericunix/dbustray/qxdgnotificationproxy_p.h
+++ b/src/platformsupport/themes/genericunix/dbustray/qxdgnotificationproxy_p.h
@@ -65,6 +65,7 @@
#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
+#include <QtCore/QLoggingCategory>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp
index 847479047f..a09ae72cb5 100644
--- a/src/plugins/bearer/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/qnetworksession_impl.cpp
@@ -82,8 +82,6 @@ Q_SIGNALS:
void forcedSessionClose(const QNetworkConfiguration &config);
};
-#include "qnetworksession_impl.moc"
-
Q_GLOBAL_STATIC(QNetworkSessionManagerPrivate, sessionManager);
void QNetworkSessionPrivateImpl::syncStateWithInterface()
@@ -432,3 +430,5 @@ void QNetworkSessionPrivateImpl::decrementTimeout()
}
QT_END_NAMESPACE
+
+#include "qnetworksession_impl.moc"
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 1ce671941d..3143abf182 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -218,6 +218,7 @@ QCocoaWindow::~QCocoaWindow()
}
[m_view release];
+ [m_nsWindow close];
[m_nsWindow release];
}
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
index e4843cb438..f29e11489b 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
@@ -381,6 +381,8 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event)
if (m_lastGlobalMousePoint != globalPoint ||
m_lastLocalMousePoint != localPoint ||
m_lastButtonState != buttons) {
+ if (m_lastButtonState != 0 && buttons == 0)
+ (static_cast<QQnxWindow *>(w->handle()))->handleActivationEvent();
QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons);
qScreenEventDebug() << "Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << static_cast<int>(buttons);
}
@@ -457,6 +459,9 @@ void QQnxScreenEventHandler::handleTouchEvent(screen_event_t event, int qnxType)
m_lastMouseWindow = qnxWindow;
if (w) {
+ if (qnxType == SCREEN_EVENT_MTOUCH_RELEASE)
+ (static_cast<QQnxWindow *>(w->handle()))->handleActivationEvent();
+
// get size of screen which contains window
QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(w);
QSizeF screenSize = platformScreen->geometry().size();
diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp
index 2096bc789e..7644e28b44 100644
--- a/src/plugins/platforms/qnx/qqnxwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxwindow.cpp
@@ -156,7 +156,8 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context, bool needRootW
m_visible(false),
m_exposed(true),
m_windowState(Qt::WindowNoState),
- m_mmRendererWindow(0)
+ m_mmRendererWindow(0),
+ m_firstActivateHandled(false)
{
qWindowDebug() << "window =" << window << ", size =" << window->size();
@@ -341,6 +342,14 @@ void QQnxWindow::setVisible(bool visible)
if (visible) {
applyWindowState();
} else {
+ if (showWithoutActivating() && focusable() && m_firstActivateHandled) {
+ m_firstActivateHandled = false;
+ int val = SCREEN_SENSITIVITY_NO_FOCUS;
+ Q_SCREEN_CHECKERROR(
+ screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SENSITIVITY, &val),
+ "Failed to set window sensitivity");
+ }
+
// Flush the context, otherwise it won't disappear immediately
screen_flush_context(m_screenContext, 0);
}
@@ -618,13 +627,56 @@ void QQnxWindow::requestActivateWindow()
void QQnxWindow::setFocus(screen_window_t newFocusWindow)
{
+ screen_window_t temporaryFocusWindow = nullptr;
+
screen_group_t screenGroup = 0;
- screen_get_window_property_pv(nativeHandle(), SCREEN_PROPERTY_GROUP,
- reinterpret_cast<void**>(&screenGroup));
- if (screenGroup) {
- screen_set_group_property_pv(screenGroup, SCREEN_PROPERTY_FOCUS,
- reinterpret_cast<void**>(&newFocusWindow));
+ Q_SCREEN_CHECKERROR(screen_get_window_property_pv(nativeHandle(), SCREEN_PROPERTY_GROUP,
+ reinterpret_cast<void **>(&screenGroup)),
+ "Failed to retrieve window group");
+
+ if (showWithoutActivating() && focusable() && !m_firstActivateHandled) {
+ m_firstActivateHandled = true;
+ int val = SCREEN_SENSITIVITY_TEST;
+ Q_SCREEN_CHECKERROR(
+ screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SENSITIVITY, &val),
+ "Failed to set window sensitivity");
+
+#if _SCREEN_VERSION < _SCREEN_MAKE_VERSION(1, 0, 0)
+ // For older versions of screen, the window may still have group
+ // focus even though it was marked NO_FOCUS when it was hidden.
+ // In that situation, focus has to be given to another window
+ // so that this window can take focus back from it.
+ screen_window_t oldFocusWindow = nullptr;
+ Q_SCREEN_CHECKERROR(
+ screen_get_group_property_pv(screenGroup, SCREEN_PROPERTY_FOCUS,
+ reinterpret_cast<void **>(&oldFocusWindow)),
+ "Failed to retrieve group focus");
+ if (newFocusWindow == oldFocusWindow) {
+ char groupName[256];
+ memset(groupName, 0, sizeof(groupName));
+ Q_SCREEN_CHECKERROR(screen_get_group_property_cv(screenGroup, SCREEN_PROPERTY_NAME,
+ sizeof(groupName) - 1, groupName),
+ "Failed to retrieve group name");
+
+ Q_SCREEN_CHECKERROR(screen_create_window_type(&temporaryFocusWindow,
+ m_screenContext, SCREEN_CHILD_WINDOW),
+ "Failed to create temporary focus window");
+ Q_SCREEN_CHECKERROR(screen_join_window_group(temporaryFocusWindow, groupName),
+ "Temporary focus window failed to join window group");
+ Q_SCREEN_CHECKERROR(
+ screen_set_group_property_pv(screenGroup, SCREEN_PROPERTY_FOCUS,
+ reinterpret_cast<void **>(&temporaryFocusWindow)),
+ "Temporary focus window failed to take focus");
+ screen_flush_context(m_screenContext, 0);
+ }
+#endif
}
+
+ Q_SCREEN_CHECKERROR(screen_set_group_property_pv(screenGroup, SCREEN_PROPERTY_FOCUS,
+ reinterpret_cast<void **>(&newFocusWindow)),
+ "Failed to set group focus");
+
+ screen_destroy_window(temporaryFocusWindow);
}
void QQnxWindow::setWindowState(Qt::WindowStates state)
@@ -711,7 +763,11 @@ void QQnxWindow::initWindow()
screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SWAP_INTERVAL, &val),
"Failed to set swap interval");
- if (window()->flags() & Qt::WindowDoesNotAcceptFocus) {
+ if (showWithoutActivating() || !focusable()) {
+ // NO_FOCUS is temporary for showWithoutActivating (and pop-up) windows.
+ // Using NO_FOCUS ensures that screen doesn't activate the window because
+ // it was just created. Sensitivity will be changed to TEST when the
+ // window is clicked or touched.
val = SCREEN_SENSITIVITY_NO_FOCUS;
Q_SCREEN_CHECKERROR(
screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SENSITIVITY, &val),
@@ -825,4 +881,22 @@ bool QQnxWindow::shouldMakeFullScreen() const
&& (QQnxIntegration::instance()->options() & QQnxIntegration::FullScreenApplication));
}
+
+void QQnxWindow::handleActivationEvent()
+{
+ if (showWithoutActivating() && focusable() && !m_firstActivateHandled)
+ requestActivateWindow();
+}
+
+bool QQnxWindow::showWithoutActivating() const
+{
+ return (window()->flags() & Qt::Popup) == Qt::Popup
+ || window()->property("_q_showWithoutActivating").toBool();
+}
+
+bool QQnxWindow::focusable() const
+{
+ return (window()->flags() & Qt::WindowDoesNotAcceptFocus) != Qt::WindowDoesNotAcceptFocus;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qnx/qqnxwindow.h b/src/plugins/platforms/qnx/qqnxwindow.h
index 2895a547b1..20c38cb4b7 100644
--- a/src/plugins/platforms/qnx/qqnxwindow.h
+++ b/src/plugins/platforms/qnx/qqnxwindow.h
@@ -113,6 +113,7 @@ public:
bool shouldMakeFullScreen() const;
void windowPosted();
+ void handleActivationEvent();
protected:
virtual int pixelFormat() const = 0;
@@ -131,6 +132,8 @@ private:
void updateZorder(screen_window_t window, int &zOrder);
void applyWindowState();
void setFocus(screen_window_t newFocusWindow);
+ bool showWithoutActivating() const;
+ bool focusable() const;
screen_window_t m_window;
QSize m_bufferSize;
@@ -152,6 +155,7 @@ private:
QByteArray m_parentGroupName;
bool m_isTopLevel;
+ bool m_firstActivateHandled;
};
QT_END_NAMESPACE
diff --git a/src/printsupport/kernel/qplatformprintdevice.cpp b/src/printsupport/kernel/qplatformprintdevice.cpp
index 69d984cb0c..f778de8e71 100644
--- a/src/printsupport/kernel/qplatformprintdevice.cpp
+++ b/src/printsupport/kernel/qplatformprintdevice.cpp
@@ -40,10 +40,8 @@
#include "qplatformprintdevice.h"
#include "qprintdevice_p.h"
-#if QT_CONFIG(printdialog)
-#include "qprintdialog.h"
-#endif
+#include <QtCore/qcoreapplication.h>
#include <QtGui/qpagelayout.h>
QT_BEGIN_NAMESPACE
@@ -291,11 +289,7 @@ QPrint::InputSlot QPlatformPrintDevice::defaultInputSlot() const
{
QPrint::InputSlot input;
input.key = QByteArrayLiteral("Auto");
-#if QT_CONFIG(printdialog)
- input.name = QPrintDialog::tr("Automatic");
-#else
- input.name = QString::fromLatin1("Automatic");
-#endif
+ input.name = QCoreApplication::translate("Print Device Input Slot", "Automatic");
input.id = QPrint::Auto;
return input;
}
@@ -315,11 +309,7 @@ QPrint::OutputBin QPlatformPrintDevice::defaultOutputBin() const
{
QPrint::OutputBin output;
output.key = QByteArrayLiteral("Auto");
-#if QT_CONFIG(printdialog)
- output.name = QPrintDialog::tr("Automatic");
-#else
- output.name = QString::fromLatin1("Automatic");
-#endif
+ output.name = QCoreApplication::translate("Print Device Output Bin", "Automatic");
output.id = QPrint::AutoOutputBin;
return output;
}
diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp
index 49a0c9ece4..2eec95d254 100644
--- a/src/printsupport/kernel/qprinterinfo.cpp
+++ b/src/printsupport/kernel/qprinterinfo.cpp
@@ -388,6 +388,35 @@ QList<QPrinter::DuplexMode> QPrinterInfo::supportedDuplexModes() const
}
/*!
+ Returns the default color mode of this printer.
+
+ \since 5.13
+*/
+
+QPrinter::ColorMode QPrinterInfo::defaultColorMode() const
+{
+ Q_D(const QPrinterInfo);
+ return QPrinter::ColorMode(d->m_printDevice.defaultColorMode());
+}
+
+/*!
+ Returns the supported color modes of this printer.
+
+ \since 5.13
+*/
+
+QList<QPrinter::ColorMode> QPrinterInfo::supportedColorModes() const
+{
+ Q_D(const QPrinterInfo);
+ QList<QPrinter::ColorMode> list;
+ const auto supportedColorModes = d->m_printDevice.supportedColorModes();
+ list.reserve(supportedColorModes.size());
+ for (QPrint::ColorMode mode : supportedColorModes)
+ list << QPrinter::ColorMode(mode);
+ return list;
+}
+
+/*!
Returns a list of all the available Printer Names on this system.
It is recommended to use this instead of availablePrinters() as
diff --git a/src/printsupport/kernel/qprinterinfo.h b/src/printsupport/kernel/qprinterinfo.h
index 8bac395ab3..7195cb76b5 100644
--- a/src/printsupport/kernel/qprinterinfo.h
+++ b/src/printsupport/kernel/qprinterinfo.h
@@ -93,6 +93,9 @@ public:
QPrinter::DuplexMode defaultDuplexMode() const;
QList<QPrinter::DuplexMode> supportedDuplexModes() const;
+ QPrinter::ColorMode defaultColorMode() const;
+ QList<QPrinter::ColorMode> supportedColorModes() const;
+
static QStringList availablePrinterNames();
static QList<QPrinterInfo> availablePrinters();
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index a33f76838f..98d6ddf882 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -607,6 +607,16 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in
return true;
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+/*!
+ \reimp
+ */
+bool QStringListModel::clearItemData(const QModelIndex &index)
+{
+ return setData(index, QVariant(), Qt::EditRole);
+}
+#endif
+
/*!
This function simply calls QSqlQueryModel::setQuery(\a query).
You should normally not call it on a QSqlTableModel. Instead, use
diff --git a/src/sql/models/qsqltablemodel.h b/src/sql/models/qsqltablemodel.h
index 7acc7dc94d..eba27e60ec 100644
--- a/src/sql/models/qsqltablemodel.h
+++ b/src/sql/models/qsqltablemodel.h
@@ -74,6 +74,9 @@ public:
QSqlRecord record(int row) const;
QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ bool clearItemData(const QModelIndex &index) override;
+#endif
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
diff --git a/src/testlib/qabstractitemmodeltester.h b/src/testlib/qabstractitemmodeltester.h
index 757074c6ae..57b8f283bc 100644
--- a/src/testlib/qabstractitemmodeltester.h
+++ b/src/testlib/qabstractitemmodeltester.h
@@ -123,11 +123,11 @@ do { \
MODELTESTER_VERIFY(variant.canConvert<QFont>());
// General Purpose roles that should return a QColor or a QBrush
- variant = model->data(model->index(0, 0), Qt::BackgroundColorRole);
+ variant = model->data(model->index(0, 0), Qt::BackgroundRole);
if (variant.isValid())
MODELTESTER_VERIFY(variant.canConvert<QColor>() || variant.canConvert<QBrush>());
- variant = model->data(model->index(0, 0), Qt::TextColorRole);
+ variant = model->data(model->index(0, 0), Qt::ForegroundRole);
if (variant.isValid())
MODELTESTER_VERIFY(variant.canConvert<QColor>() || variant.canConvert<QBrush>());
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 2578037946..82078ad7a8 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -368,18 +368,11 @@ int main(int argc, char *argv[]) \
}
#include <QtTest/qtestsystem.h>
-#include <set>
-
-#ifndef QT_NO_OPENGL
-# define QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \
- extern Q_TESTLIB_EXPORT std::set<QByteArray> *(*qgpu_features_ptr)(const QString &); \
- extern Q_GUI_EXPORT std::set<QByteArray> *qgpu_features(const QString &);
-# define QTEST_ADD_GPU_BLACKLIST_SUPPORT \
- qgpu_features_ptr = qgpu_features;
-#else
-# define QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS
-# define QTEST_ADD_GPU_BLACKLIST_SUPPORT
-#endif
+
+// Two backwards-compatibility defines for an obsolete feature:
+#define QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS
+#define QTEST_ADD_GPU_BLACKLIST_SUPPORT
+// ### Qt 6: fully remove these.
#if defined(QT_NETWORK_LIB)
# include <QtTest/qtest_network.h>
@@ -396,15 +389,11 @@ int main(int argc, char *argv[]) \
#endif
#define QTEST_MAIN(TestObject) \
-QT_BEGIN_NAMESPACE \
-QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \
-QT_END_NAMESPACE \
int main(int argc, char *argv[]) \
{ \
QApplication app(argc, argv); \
app.setAttribute(Qt::AA_Use96Dpi, true); \
QTEST_DISABLE_KEYPAD_NAVIGATION \
- QTEST_ADD_GPU_BLACKLIST_SUPPORT \
TestObject tc; \
QTEST_SET_MAIN_SOURCE_PATH \
return QTest::qExec(&tc, argc, argv); \
@@ -415,14 +404,10 @@ int main(int argc, char *argv[]) \
#include <QtTest/qtest_gui.h>
#define QTEST_MAIN(TestObject) \
-QT_BEGIN_NAMESPACE \
-QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \
-QT_END_NAMESPACE \
int main(int argc, char *argv[]) \
{ \
QGuiApplication app(argc, argv); \
app.setAttribute(Qt::AA_Use96Dpi, true); \
- QTEST_ADD_GPU_BLACKLIST_SUPPORT \
TestObject tc; \
QTEST_SET_MAIN_SOURCE_PATH \
return QTest::qExec(&tc, argc, argv); \
diff --git a/src/testlib/qtestblacklist.cpp b/src/testlib/qtestblacklist.cpp
index f430294142..84a99c10f3 100644
--- a/src/testlib/qtestblacklist.cpp
+++ b/src/testlib/qtestblacklist.cpp
@@ -220,22 +220,6 @@ static bool checkCondition(const QByteArray &condition)
static bool ignoreAll = false;
static std::set<QByteArray> *ignoredTests = 0;
-static std::set<QByteArray> *gpuFeatures = 0;
-
-Q_TESTLIB_EXPORT std::set<QByteArray> *(*qgpu_features_ptr)(const QString &) = 0;
-
-static bool isGPUTestBlacklisted(const char *slot, const char *data = 0)
-{
- const QByteArray disableKey = QByteArrayLiteral("disable_") + QByteArray(slot);
- if (gpuFeatures->find(disableKey) != gpuFeatures->end()) {
- QByteArray msg = QByteArrayLiteral("Skipped due to GPU blacklist: ") + disableKey;
- if (data)
- msg += ':' + QByteArray(data);
- QTest::qSkip(msg.constData(), __FILE__, __LINE__);
- return true;
- }
- return false;
-}
namespace QTestPrivate {
@@ -275,17 +259,6 @@ void parseBlackList()
}
}
-void parseGpuBlackList()
-{
- if (!qgpu_features_ptr)
- return;
- QString filename = QTest::qFindTestData(QStringLiteral("GPU_BLACKLIST"));
- if (filename.isEmpty())
- return;
- if (!gpuFeatures)
- gpuFeatures = qgpu_features_ptr(filename);
-}
-
void checkBlackLists(const char *slot, const char *data)
{
bool ignore = ignoreAll;
@@ -301,21 +274,8 @@ void checkBlackLists(const char *slot, const char *data)
}
QTestResult::setBlacklistCurrentTest(ignore);
-
- // Tests blacklisted in GPU_BLACKLIST are to be skipped. Just ignoring the result is
- // not sufficient since these are expected to crash or behave in undefined ways.
- if (!ignore && gpuFeatures) {
- QByteArray s_gpu = slot;
- ignore = isGPUTestBlacklisted(s_gpu, data);
- if (!ignore && data) {
- s_gpu += ':';
- s_gpu += data;
- isGPUTestBlacklisted(s_gpu);
- }
- }
-}
-
}
+} // QTestPrivate
QT_END_NAMESPACE
diff --git a/src/testlib/qtestblacklist_p.h b/src/testlib/qtestblacklist_p.h
index 08ce052231..4522c64992 100644
--- a/src/testlib/qtestblacklist_p.h
+++ b/src/testlib/qtestblacklist_p.h
@@ -58,7 +58,6 @@ QT_BEGIN_NAMESPACE
namespace QTestPrivate {
// Export functions so they can also be used by QQuickTest
Q_TESTLIB_EXPORT void parseBlackList();
- Q_TESTLIB_EXPORT void parseGpuBlackList();
Q_TESTLIB_EXPORT void checkBlackLists(const char *slot, const char *data);
}
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 32facaf12b..1c3292ead9 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -282,74 +282,74 @@ namespace QTestPrivate
namespace QTest
{
- class WatchDog;
+class WatchDog;
- static QObject *currentTestObject = 0;
- static QString mainSourcePath;
+static QObject *currentTestObject = 0;
+static QString mainSourcePath;
#if defined(Q_OS_MACOS)
- bool macNeedsActivate = false;
- IOPMAssertionID powerID;
+bool macNeedsActivate = false;
+IOPMAssertionID powerID;
#endif
- class TestMethods {
- Q_DISABLE_COPY(TestMethods)
+class TestMethods {
+ Q_DISABLE_COPY(TestMethods)
public:
- typedef std::vector<QMetaMethod> MetaMethods;
+ typedef std::vector<QMetaMethod> MetaMethods;
- explicit TestMethods(const QObject *o, const MetaMethods &m = MetaMethods());
+ explicit TestMethods(const QObject *o, const MetaMethods &m = MetaMethods());
- void invokeTests(QObject *testObject) const;
+ void invokeTests(QObject *testObject) const;
- static QMetaMethod findMethod(const QObject *obj, const char *signature);
+ static QMetaMethod findMethod(const QObject *obj, const char *signature);
- private:
- bool invokeTest(int index, const char *data, WatchDog *watchDog) const;
- void invokeTestOnData(int index) const;
+private:
+ bool invokeTest(int index, const char *data, WatchDog *watchDog) const;
+ void invokeTestOnData(int index) const;
- QMetaMethod m_initTestCaseMethod; // might not exist, check isValid().
- QMetaMethod m_initTestCaseDataMethod;
- QMetaMethod m_cleanupTestCaseMethod;
- QMetaMethod m_initMethod;
- QMetaMethod m_cleanupMethod;
+ QMetaMethod m_initTestCaseMethod; // might not exist, check isValid().
+ QMetaMethod m_initTestCaseDataMethod;
+ QMetaMethod m_cleanupTestCaseMethod;
+ QMetaMethod m_initMethod;
+ QMetaMethod m_cleanupMethod;
- MetaMethods m_methods;
- };
+ MetaMethods m_methods;
+};
- TestMethods::TestMethods(const QObject *o, const MetaMethods &m)
- : m_initTestCaseMethod(TestMethods::findMethod(o, "initTestCase()"))
- , m_initTestCaseDataMethod(TestMethods::findMethod(o, "initTestCase_data()"))
- , m_cleanupTestCaseMethod(TestMethods::findMethod(o, "cleanupTestCase()"))
- , m_initMethod(TestMethods::findMethod(o, "init()"))
- , m_cleanupMethod(TestMethods::findMethod(o, "cleanup()"))
- , m_methods(m)
- {
- if (m.empty()) {
- const QMetaObject *metaObject = o->metaObject();
- const int count = metaObject->methodCount();
- m_methods.reserve(count);
- for (int i = 0; i < count; ++i) {
- const QMetaMethod me = metaObject->method(i);
- if (isValidSlot(me))
- m_methods.push_back(me);
- }
+TestMethods::TestMethods(const QObject *o, const MetaMethods &m)
+ : m_initTestCaseMethod(TestMethods::findMethod(o, "initTestCase()"))
+ , m_initTestCaseDataMethod(TestMethods::findMethod(o, "initTestCase_data()"))
+ , m_cleanupTestCaseMethod(TestMethods::findMethod(o, "cleanupTestCase()"))
+ , m_initMethod(TestMethods::findMethod(o, "init()"))
+ , m_cleanupMethod(TestMethods::findMethod(o, "cleanup()"))
+ , m_methods(m)
+{
+ if (m.empty()) {
+ const QMetaObject *metaObject = o->metaObject();
+ const int count = metaObject->methodCount();
+ m_methods.reserve(count);
+ for (int i = 0; i < count; ++i) {
+ const QMetaMethod me = metaObject->method(i);
+ if (isValidSlot(me))
+ m_methods.push_back(me);
}
}
+}
- QMetaMethod TestMethods::findMethod(const QObject *obj, const char *signature)
- {
- const QMetaObject *metaObject = obj->metaObject();
- const int funcIndex = metaObject->indexOfMethod(signature);
- return funcIndex >= 0 ? metaObject->method(funcIndex) : QMetaMethod();
- }
+QMetaMethod TestMethods::findMethod(const QObject *obj, const char *signature)
+{
+ const QMetaObject *metaObject = obj->metaObject();
+ const int funcIndex = metaObject->indexOfMethod(signature);
+ return funcIndex >= 0 ? metaObject->method(funcIndex) : QMetaMethod();
+}
- static int keyDelay = -1;
- static int mouseDelay = -1;
- static int eventDelay = -1;
+static int keyDelay = -1;
+static int mouseDelay = -1;
+static int eventDelay = -1;
#if QT_CONFIG(thread)
- static int timeout = -1;
+static int timeout = -1;
#endif
- static bool noCrashHandler = false;
+static bool noCrashHandler = false;
/*! \internal
Invoke a method of the object without generating warning if the method does not exist
@@ -496,7 +496,7 @@ static void qPrintDataTags(FILE *stream)
}
}
-static int qToInt(char *str)
+static int qToInt(const char *str)
{
char *pEnd;
int l = (int)strtol(str, &pEnd, 10);
@@ -507,7 +507,7 @@ static int qToInt(char *str)
return l;
}
-Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
+Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool qml)
{
QTestLog::LogMode logFormat = QTestLog::Plain;
const char *logFilename = 0;
@@ -811,9 +811,9 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
// we load the QML files. So just store the data for now.
int colon = -1;
int offset;
- for (offset = 0; *(argv[i]+offset); ++offset) {
- if (*(argv[i]+offset) == ':') {
- if (*(argv[i]+offset+1) == ':') {
+ for (offset = 0; argv[i][offset]; ++offset) {
+ if (argv[i][offset] == ':') {
+ if (argv[i][offset + 1] == ':') {
// "::" is used as a test name separator.
// e.g. "ClickTests::test_click:row1".
++offset;
@@ -845,6 +845,11 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
QTestLog::addLogger(logFormat, logFilename);
}
+// Temporary, backwards compatibility, until qtdeclarative's use of it is converted
+Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) {
+ qtest_qParseArgs(argc, const_cast<const char *const *>(argv), qml);
+}
+
QBenchmarkResult qMedian(const QVector<QBenchmarkResult> &container)
{
const int count = container.count();
@@ -1195,7 +1200,9 @@ char *formatString(const char *prefix, const char *suffix, size_t numArguments,
Returns a pointer to a string that is the string \a ba represented
as a space-separated sequence of hex characters. If the input is
considered too long, it is truncated. A trucation is indicated in
- the returned string as an ellipsis at the end.
+ the returned string as an ellipsis at the end. The caller has
+ ownership of the returned pointer and must ensure it is later passed
+ to operator delete[].
\a length is the length of the string \a ba.
*/
@@ -1813,8 +1820,6 @@ void QTest::qInit(QObject *testObject, int argc, char **argv)
#endif
QTestPrivate::parseBlackList();
- QTestPrivate::parseGpuBlackList();
-
QTestResult::reset();
QTEST_ASSERT(testObject);
diff --git a/src/testlib/qtestcorelist_p.h b/src/testlib/qtestcorelist_p.h
index 5943695876..4d080f6758 100644
--- a/src/testlib/qtestcorelist_p.h
+++ b/src/testlib/qtestcorelist_p.h
@@ -66,9 +66,6 @@ class QTestCoreList
void addToList(T **list);
T *nextElement();
T *previousElement();
- int count(T *list);
- int count();
-
private:
T *next;
T *prev;
@@ -121,20 +118,6 @@ T *QTestCoreList<T>::previousElement()
return prev;
}
-template <class T>
-int QTestCoreList<T>::count()
-{
- int numOfElements = 0;
- T *it = next;
-
- while (it) {
- ++numOfElements;
- it = it->nextElement();
- }
-
- return numOfElements;
-}
-
QT_END_NAMESPACE
#endif
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index fd76646f4c..e5f1c61e3c 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -1549,16 +1549,16 @@ void Generator::generateSignal(FunctionDef *def,int index)
fprintf(out, "nullptr");
} else {
if (def->returnTypeIsVolatile)
- fprintf(out, "const_cast<void*>(reinterpret_cast<const volatile void*>(&_t0))");
+ fprintf(out, "const_cast<void*>(reinterpret_cast<const volatile void*>(std::addressof(_t0)))");
else
- fprintf(out, "const_cast<void*>(reinterpret_cast<const void*>(&_t0))");
+ fprintf(out, "const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t0)))");
}
int i;
for (i = 1; i < offset; ++i)
if (i <= def->arguments.count() && def->arguments.at(i - 1).type.isVolatile)
- fprintf(out, ", const_cast<void*>(reinterpret_cast<const volatile void*>(&_t%d))", i);
+ fprintf(out, ", const_cast<void*>(reinterpret_cast<const volatile void*>(std::addressof(_t%d)))", i);
else
- fprintf(out, ", const_cast<void*>(reinterpret_cast<const void*>(&_t%d))", i);
+ fprintf(out, ", const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t%d)))", i);
fprintf(out, " };\n");
fprintf(out, " QMetaObject::activate(%s, &staticMetaObject, %d, _a);\n", thisPtr.constData(), index);
if (def->normalizedType != "void")
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 61a5542c83..76816960ff 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -992,7 +992,7 @@ void Moc::generate(FILE *out)
fprintf(out, "** WARNING! All changes made in this file will be lost!\n"
"*****************************************************************************/\n\n");
-
+ fprintf(out, "#include <memory>\n"); // For std::addressof
if (!noInclude) {
if (includePath.size() && !includePath.endsWith('/'))
includePath += '/';
diff --git a/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp b/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp
index f5051e25fc..a9bf7e86e4 100644
--- a/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp
+++ b/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp
@@ -68,7 +68,7 @@ qint32 main(qint32 argc, char **argv)
return -1;
}
- QFile fid(argv[1]);
+ QFile fid(QFile::decodeName(argv[1]));
if (!fid.open(QIODevice::WriteOnly | QIODevice::Text)) {
qWarning() << "Abort: Failed to open/create file" << fid.fileName();
return -1;
diff --git a/src/tools/tracegen/helpers.cpp b/src/tools/tracegen/helpers.cpp
index f0ac7ed47f..a5526065d6 100644
--- a/src/tools/tracegen/helpers.cpp
+++ b/src/tools/tracegen/helpers.cpp
@@ -46,7 +46,7 @@ QString includeGuard(const QString &filename)
for (int i = 0; i < guard.size(); ++i) {
if (!guard.at(i).isLetterOrNumber())
- guard[i] = QChar('_');
+ guard[i] = QLatin1Char('_');
}
return guard;
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index 06f0393b4c..cadd7ef031 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -731,6 +731,20 @@ void QDialog::setVisible(bool visible)
if (!testAttribute(Qt::WA_DontShowOnScreen) && d->canBeNativeDialog() && d->setNativeDialogVisible(visible))
return;
+ // We should not block windows by the invisible modal dialog
+ // if a platform-specific dialog is implemented as an in-process
+ // Qt window, because in this case it will also be blocked.
+ const bool dontBlockWindows = testAttribute(Qt::WA_DontShowOnScreen)
+ && d->styleHint(QPlatformDialogHelper::DialogIsQtWindow).toBool();
+ Qt::WindowModality oldModality;
+ bool wasModalitySet;
+
+ if (dontBlockWindows) {
+ oldModality = windowModality();
+ wasModalitySet = testAttribute(Qt::WA_SetWindowModality);
+ setWindowModality(Qt::NonModal);
+ }
+
if (visible) {
if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
return;
@@ -797,6 +811,11 @@ void QDialog::setVisible(bool visible)
d->eventLoop->exit();
}
+ if (dontBlockWindows) {
+ setWindowModality(oldModality);
+ setAttribute(Qt::WA_SetWindowModality, wasModalitySet);
+ }
+
#if QT_CONFIG(pushbutton)
const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme();
if (d->mainDef && isActiveWindow()
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index 477c6bd540..2b81180ecb 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -534,7 +534,7 @@ void QFontDialogPrivate::updateFamilies()
//and try some fall backs
match_t type = MATCH_NONE;
- if (bestFamilyType <= MATCH_NONE && familyName2 == f.lastResortFamily())
+ if (bestFamilyType <= MATCH_NONE && familyName2 == QStringLiteral("helvetica"))
type = MATCH_LAST_RESORT;
if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.family())
type = MATCH_APP;
diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h
index 4b993a9e65..0a2edb1eee 100644
--- a/src/widgets/dialogs/qmessagebox.h
+++ b/src/widgets/dialogs/qmessagebox.h
@@ -284,9 +284,9 @@ public:
Q_SIGNALS:
void buttonClicked(QAbstractButton *button);
-#ifdef Q_QDOC
+#ifdef Q_CLANG_QDOC
public Q_SLOTS:
- int exec();
+ int exec() override;
#endif
protected:
diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp
index d52f18b406..2c8c66e1e2 100644
--- a/src/widgets/dialogs/qsidebar.cpp
+++ b/src/widgets/dialogs/qsidebar.cpp
@@ -381,8 +381,6 @@ QSidebar::QSidebar(QWidget *parent) : QListView(parent)
void QSidebar::setModelAndUrls(QFileSystemModel *model, const QList<QUrl> &newUrls)
{
- // ### TODO make icon size dynamic
- setIconSize(QSize(24,24));
setUniformItemSizes(true);
urlModel = new QUrlModel(this);
urlModel->setFileSystemModel(model);
diff --git a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
index 9af04f6b4c..098eaf4717 100644
--- a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
+++ b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
@@ -514,13 +514,15 @@ QLabel { border-width: 1px 2px 3px 4px } /* 1px 2px 3px 4px */
//! [84]
-QLabel { border-color: red } /* opaque red */
-QLabel { border-color: #FF0000 } /* opaque red */
-QLabel { border-color: rgba(255, 0, 0, 75%) } /* 75% opaque red */
-QLabel { border-color: rgb(255, 0, 0) } /* opaque red */
-QLabel { border-color: rgb(100%, 0%, 0%) } /* opaque red */
-QLabel { border-color: hsv(60, 255, 255) } /* opaque yellow */
-QLabel { border-color: hsva(240, 255, 255, 75%) } /* 75% blue */
+QLabel { border-color: red } /* opaque red */
+QLabel { border-color: #FF0000 } /* opaque red */
+QLabel { border-color: rgba(255, 0, 0, 75%) } /* 75% opaque red */
+QLabel { border-color: rgb(255, 0, 0) } /* opaque red */
+QLabel { border-color: rgb(100%, 0%, 0%) } /* opaque red */
+QLabel { border-color: hsv(60, 100%, 100%) } /* opaque yellow */
+QLabel { border-color: hsva(240, 255, 255, 75%) } /* 75% blue */
+QLabel { border-color: hsl(60, 100%, 50%) } /* opaque yellow */
+QLabel { border-color: hsla(240, 255, 50%, 75%) } /* 75% blue */
//! [84]
diff --git a/src/widgets/doc/snippets/qtreewidget-using/mainwindow.cpp b/src/widgets/doc/snippets/qtreewidget-using/mainwindow.cpp
index ee7e028a13..7c8d3f936e 100644
--- a/src/widgets/doc/snippets/qtreewidget-using/mainwindow.cpp
+++ b/src/widgets/doc/snippets/qtreewidget-using/mainwindow.cpp
@@ -154,14 +154,14 @@ void MainWindow::findItems()
QTreeWidgetItem *item;
//! [6]
foreach (item, treeWidget->selectedItems())
- treeWidget->setItemSelected(item, false);
+ item->setSelected(false);
//! [7]
QList<QTreeWidgetItem *> found = treeWidget->findItems(
itemText, Qt::MatchWildcard);
foreach (item, found) {
- treeWidget->setItemSelected(item, true);
+ item->setSelected(true);
// Show the item->text(0) for each item.
}
//! [7]
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
index 43f9dda49a..00323eace6 100644
--- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
@@ -2881,14 +2881,20 @@
| \tt{rgba(\e{r}, \e{g}, \e{b}, \e{a})} \br
| \tt{hsv(\e{h}, \e{s}, \e{v})} \br
| \tt{hsva(\e{h}, \e{s}, \e{v}, \e{a})} \br
+ | \tt{hsl(\e{h}, \e{s}, \e{l})} \br
+ | \tt{hsla(\e{h}, \e{s}, \e{l}, \e{a})} \br
| \tt{#\e{rrggbb}} \br
| \l{QColor::setNamedColor()}{Color Name} \br
- \li Specifies a color as RGB (red, green, blue) or RGBA
- (red, green, blue, alpha) or HSV (hue, saturation, value) or HSVA
- (hue, saturation, value, alpha) or a named color. The \c rgb() or \c rgba()
- syntax can be used with integer values between 0 and 255, or with
- percentages. The value of s, v, and a in \c hsv() or \c hsva() must all
- be in the range 0-255; the value of h must be in the range 0-359.
+ \li Specifies a color as RGB (red, green, blue), RGBA (red,
+ green, blue, alpha), HSV (hue, saturation, value), HSVA
+ (hue, saturation, value, alpha), HSL (hue, saturation,
+ lightness), HSLA (hue, saturation, lightness, alpha) or a
+ named color. The \c rgb() or \c rgba() syntax can be used
+ with integer values between 0 and 255, or with percentages.
+ The value of s, v, l and a in \c hsv(), \c hsva() \c hsl()
+ or \c hsla() must all be in the range 0-255 or with
+ percentages, the value of h must be in the range 0-359.
+ The support for HSL(A) is available since 5.13.
Examples:
diff --git a/src/widgets/effects/qpixmapfilter.cpp b/src/widgets/effects/qpixmapfilter.cpp
index 211c09ee71..b330afebed 100644
--- a/src/widgets/effects/qpixmapfilter.cpp
+++ b/src/widgets/effects/qpixmapfilter.cpp
@@ -54,6 +54,8 @@
#include "private/qmemrotate_p.h"
#include "private/qdrawhelper_p.h"
+#include <memory>
+
QT_BEGIN_NAMESPACE
class QPixmapFilterPrivate : public QObjectPrivate
@@ -319,7 +321,7 @@ static void convolute(
const QImage processImage = (srcImage.format() != QImage::Format_ARGB32_Premultiplied ) ? srcImage.convertToFormat(QImage::Format_ARGB32_Premultiplied) : srcImage;
// TODO: support also other formats directly without copying
- int *fixedKernel = new int[kernelWidth*kernelHeight];
+ std::unique_ptr<int[]> fixedKernel(new int[kernelWidth * kernelHeight]);
for(int i = 0; i < kernelWidth*kernelHeight; i++)
{
fixedKernel[i] = (int)(65536 * kernel[i]);
@@ -403,7 +405,6 @@ static void convolute(
}
yk++;
}
- delete[] fixedKernel;
}
/*!
diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h
index c228e765d8..729176530d 100644
--- a/src/widgets/graphicsview/qgraphicsitem.h
+++ b/src/widgets/graphicsview/qgraphicsitem.h
@@ -487,7 +487,9 @@ private:
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsItem::GraphicsItemFlags)
+#ifndef Q_CLANG_QDOC
Q_DECLARE_INTERFACE(QGraphicsItem, "org.qt-project.Qt.QGraphicsItem")
+#endif
inline void QGraphicsItem::setPos(qreal ax, qreal ay)
{ setPos(QPointF(ax, ay)); }
diff --git a/src/widgets/graphicsview/qgraphicslayout.h b/src/widgets/graphicsview/qgraphicslayout.h
index 28b335ceaa..efcafa5e6a 100644
--- a/src/widgets/graphicsview/qgraphicslayout.h
+++ b/src/widgets/graphicsview/qgraphicslayout.h
@@ -83,7 +83,9 @@ private:
friend class QGraphicsWidget;
};
+#ifndef Q_CLANG_QDOC
Q_DECLARE_INTERFACE(QGraphicsLayout, "org.qt-project.Qt.QGraphicsLayout")
+#endif
QT_END_NAMESPACE
diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.h b/src/widgets/graphicsview/qgraphicslayoutitem.h
index 44f430034b..86a0a87361 100644
--- a/src/widgets/graphicsview/qgraphicslayoutitem.h
+++ b/src/widgets/graphicsview/qgraphicslayoutitem.h
@@ -116,7 +116,9 @@ private:
friend class QGraphicsLayout;
};
+#ifndef Q_CLANG_QDOC
Q_DECLARE_INTERFACE(QGraphicsLayoutItem, "org.qt-project.Qt.QGraphicsLayoutItem")
+#endif
inline void QGraphicsLayoutItem::setMinimumSize(qreal aw, qreal ah)
{ setMinimumSize(QSizeF(aw, ah)); }
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index 7bfa51337d..62abf56751 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -2321,9 +2321,10 @@ void QHeaderView::initializeSections()
if (stretchLastSection()) // we've already gotten the size hint
d->maybeRestorePrevLastSectionAndStretchLast();
- //make sure we update the hidden sections
+ // make sure we update the hidden sections
+ // simulate remove from newCount to oldCount
if (newCount < oldCount)
- d->updateHiddenSections(0, newCount-1);
+ d->updateHiddenSections(newCount, oldCount);
}
}
@@ -3116,9 +3117,25 @@ void QHeaderView::scrollContentsBy(int dx, int dy)
\reimp
\internal
*/
-void QHeaderView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &)
+void QHeaderView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
{
Q_D(QHeaderView);
+ if (!roles.isEmpty()) {
+ const auto doesRoleAffectSize = [](int role) -> bool {
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::DecorationRole:
+ case Qt::SizeHintRole:
+ case Qt::FontRole:
+ return true;
+ default:
+ // who knows what a subclass or custom style might do
+ return role >= Qt::UserRole;
+ }
+ };
+ if (std::none_of(roles.begin(), roles.end(), doesRoleAffectSize))
+ return;
+ }
d->invalidateCachedSizeHint();
if (d->hasAutoResizeSections()) {
bool resizeRequired = d->globalResizeMode == ResizeToContents;
@@ -3874,9 +3891,9 @@ void QHeaderViewPrivate::updateDefaultSectionSizeFromStyle()
void QHeaderViewPrivate::recalcSectionStartPos() const // linear (but fast)
{
int pixelpos = 0;
- for (QVector<SectionItem>::const_iterator i = sectionItems.constBegin(); i != sectionItems.constEnd(); ++i) {
- i->calculated_startpos = pixelpos; // write into const mutable
- pixelpos += i->size;
+ for (const SectionItem &i : sectionItems) {
+ i.calculated_startpos = pixelpos; // write into const mutable
+ pixelpos += i.size;
}
sectionStartposRecalc = false;
}
diff --git a/src/widgets/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp
index dff4cc4593..16d4a21f50 100644
--- a/src/widgets/itemviews/qitemdelegate.cpp
+++ b/src/widgets/itemviews/qitemdelegate.cpp
@@ -266,7 +266,7 @@ QSizeF QItemDelegatePrivate::doTextLayout(int lineWidth) const
\row \li \l Qt::AccessibleDescriptionRole \li QString
\row \li \l Qt::AccessibleTextRole \li QString
\endomit
- \row \li \l Qt::BackgroundRole \li QBrush
+ \row \li \l Qt::BackgroundRole \li QBrush (\since 4.2)
\row \li \l Qt::BackgroundColorRole \li QColor (obsolete; use Qt::BackgroundRole instead)
\row \li \l Qt::CheckStateRole \li Qt::CheckState
\row \li \l Qt::DecorationRole \li QIcon, QPixmap and QColor
@@ -278,7 +278,7 @@ QSizeF QItemDelegatePrivate::doTextLayout(int lineWidth) const
\row \li \l Qt::StatusTipRole \li
\endomit
\row \li \l Qt::TextAlignmentRole \li Qt::Alignment
- \row \li \l Qt::ForegroundRole \li QBrush
+ \row \li \l Qt::ForegroundRole \li QBrush (\since 4.2)
\row \li \l Qt::TextColorRole \li QColor (obsolete; use Qt::ForegroundRole instead)
\omit
\row \li \l Qt::ToolTipRole
@@ -1089,7 +1089,7 @@ QRect QItemDelegate::doCheck(const QStyleOptionViewItem &option,
opt.rect = bounding;
const QWidget *widget = d->widget(option); // cast
QStyle *style = widget ? widget->style() : QApplication::style();
- return style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, widget);
+ return style->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &opt, widget);
}
return QRect();
}
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index e5769940d4..fdac332367 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -2246,8 +2246,8 @@ int QListModeViewBase::verticalScrollToValue(int index, QListView::ScrollHint hi
} else {
int scrollBarValue = verticalScrollBar()->value();
int numHidden = 0;
- for (int i = 0; i < flowPositions.count() - 1 && i <= scrollBarValue; ++i)
- if (isHidden(i))
+ for (const auto &idx : qAsConst(dd->hiddenRows))
+ if (idx.row() <= scrollBarValue)
++numHidden;
value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()) - numHidden, flowPositions.count() - 1);
}
@@ -2687,21 +2687,24 @@ int QListModeViewBase::perItemScrollToValue(int index, int scrollValue, int view
return scrollValue;
itemExtent += spacing();
- QVector<int> visibleFlowPositions;
- visibleFlowPositions.reserve(flowPositions.count() - 1);
- for (int i = 0; i < flowPositions.count() - 1; i++) { // flowPositions count is +1 larger than actual row count
- if (!isHidden(i))
- visibleFlowPositions.append(flowPositions.at(i));
- }
-
+ QVector<int> hiddenRows = dd->hiddenRowIds();
+ std::sort(hiddenRows.begin(), hiddenRows.end());
+ int hiddenRowsBefore = 0;
+ for (int i = 0; i < hiddenRows.size() - 1; ++i)
+ if (hiddenRows.at(i) > index + hiddenRowsBefore)
+ break;
+ else
+ ++hiddenRowsBefore;
if (!wrap) {
int topIndex = index;
const int bottomIndex = topIndex;
- const int bottomCoordinate = visibleFlowPositions.at(index);
-
+ const int bottomCoordinate = flowPositions.at(index + hiddenRowsBefore);
while (topIndex > 0 &&
- (bottomCoordinate - visibleFlowPositions.at(topIndex - 1) + itemExtent) <= (viewportSize)) {
+ (bottomCoordinate - flowPositions.at(topIndex + hiddenRowsBefore - 1) + itemExtent) <= (viewportSize)) {
topIndex--;
+ // will the next one be a hidden row -> skip
+ while (hiddenRowsBefore > 0 && hiddenRows.at(hiddenRowsBefore - 1) >= topIndex + hiddenRowsBefore - 1)
+ hiddenRowsBefore--;
}
const int itemCount = bottomIndex - topIndex + 1;
@@ -2720,7 +2723,7 @@ int QListModeViewBase::perItemScrollToValue(int index, int scrollValue, int view
? Qt::Horizontal : Qt::Vertical);
if (flowOrientation == orientation) { // scrolling in the "flow" direction
// ### wrapped scrolling in the flow direction
- return visibleFlowPositions.at(index); // ### always pixel based for now
+ return flowPositions.at(index + hiddenRowsBefore); // ### always pixel based for now
} else if (!segmentStartRows.isEmpty()) { // we are scrolling in the "segment" direction
int segment = qBinarySearch<int>(segmentStartRows, index, 0, segmentStartRows.count() - 1);
int leftSegment = segment;
@@ -3354,9 +3357,9 @@ int QListView::visualIndex(const QModelIndex &index) const
d->executePostedLayout();
QListViewItem itm = d->indexToListViewItem(index);
int visualIndex = d->commonListView->itemIndex(itm);
- for (int row = 0; row <= index.row() && visualIndex >= 0; row++) {
- if (d->isHidden(row))
- visualIndex--;
+ for (const auto &idx : qAsConst(d->hiddenRows)) {
+ if (idx.row() <= index.row())
+ --visualIndex;
}
return visualIndex;
}
diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h
index 181386d4d0..3f997ef7e3 100644
--- a/src/widgets/itemviews/qlistview_p.h
+++ b/src/widgets/itemviews/qlistview_p.h
@@ -377,6 +377,14 @@ public:
QModelIndex idx = model->index(row, 0, root);
return isPersistent(idx) && hiddenRows.contains(idx);
}
+ // helper to avoid checking for isPersistent and creating persistent indexes as above in isHidden
+ QVector<int> hiddenRowIds() const {
+ QVector<int> rowIds;
+ rowIds.reserve(hiddenRows.size());
+ for (const auto &idx : hiddenRows)
+ rowIds += idx.row();
+ return rowIds;
+ }
inline bool isHiddenOrDisabled(int row) const { return isHidden(row) || !isIndexEnabled(modelIndex(row)); }
void removeCurrentAndDisabled(QVector<QModelIndex> *indexes, const QModelIndex &current) const;
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index 72e0a67a64..6e0bdb3f22 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -227,6 +227,22 @@ bool QListModel::setData(const QModelIndex &index, const QVariant &value, int ro
return true;
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+bool QListModel::clearItemData(const QModelIndex &index)
+{
+ if (!checkIndex(index, CheckIndexOption::IndexIsValid))
+ return false;
+ QListWidgetItem *item = items.at(index.row());
+ const auto beginIter = item->d->values.cbegin();
+ const auto endIter = item->d->values.cend();
+ if (std::all_of(beginIter, endIter, [](const QWidgetItemData& data) -> bool { return !data.value.isValid(); }))
+ return true; //it's already cleared
+ item->d->values.clear();
+ emit dataChanged(index, index, QVector<int>{});
+ return true;
+}
+#endif
+
QMap<int, QVariant> QListModel::itemData(const QModelIndex &index) const
{
QMap<int, QVariant> roles;
@@ -277,6 +293,30 @@ bool QListModel::removeRows(int row, int count, const QModelIndex &parent)
return true;
}
+/*!
+ \since 5.13
+ \reimp
+*/
+bool QListModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
+{
+ if (sourceRow < 0
+ || sourceRow + count - 1 >= rowCount(sourceParent)
+ || destinationChild <= 0
+ || destinationChild > rowCount(destinationParent)
+ || sourceRow == destinationChild - 1
+ || count <= 0) {
+ return false;
+ }
+ if (!beginMoveRows(QModelIndex(), sourceRow, sourceRow + count - 1, QModelIndex(), destinationChild))
+ return false;
+ destinationChild--;
+ const int fromRow = destinationChild < sourceRow ? (sourceRow + count - 1) : sourceRow;
+ while (count--)
+ items.move(fromRow, destinationChild);
+ endMoveRows();
+ return true;
+}
+
Qt::ItemFlags QListModel::flags(const QModelIndex &index) const
{
if (!index.isValid() || index.row() >= items.count() || index.model() != this)
@@ -289,7 +329,7 @@ void QListModel::sort(int column, Qt::SortOrder order)
if (column != 0)
return;
- emit layoutAboutToBeChanged();
+ emit layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint);
QVector < QPair<QListWidgetItem*,int> > sorting(items.count());
for (int i = 0; i < items.count(); ++i) {
@@ -313,7 +353,7 @@ void QListModel::sort(int column, Qt::SortOrder order)
}
changePersistentIndexList(fromIndexes, toIndexes);
- emit layoutChanged();
+ emit layoutChanged({}, QAbstractItemModel::VerticalSortHint);
}
/**
@@ -594,14 +634,14 @@ Qt::DropActions QListModel::supportedDropActions() const
\sa type()
*/
-QListWidgetItem::QListWidgetItem(QListWidget *view, int type)
- : rtti(type), view(view), d(new QListWidgetItemPrivate(this)),
+QListWidgetItem::QListWidgetItem(QListWidget *listview, int type)
+ : rtti(type), view(listview), d(new QListWidgetItemPrivate(this)),
itemFlags(Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
|Qt::ItemIsEnabled
|Qt::ItemIsDragEnabled)
{
- if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0))
+ if (QListModel *model = listModel())
model->insert(model->rowCount(), this);
}
@@ -621,16 +661,18 @@ QListWidgetItem::QListWidgetItem(QListWidget *view, int type)
\sa type()
*/
-QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *view, int type)
- : rtti(type), view(0), d(new QListWidgetItemPrivate(this)),
+QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *listview, int type)
+ : rtti(type), view(listview), d(new QListWidgetItemPrivate(this)),
itemFlags(Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
|Qt::ItemIsEnabled
|Qt::ItemIsDragEnabled)
{
- setData(Qt::DisplayRole, text);
- this->view = view;
- if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0))
+ {
+ QSignalBlocker b(view);
+ setData(Qt::DisplayRole, text);
+ }
+ if (QListModel *model = listModel())
model->insert(model->rowCount(), this);
}
@@ -652,17 +694,19 @@ QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *view, int typ
\sa type()
*/
QListWidgetItem::QListWidgetItem(const QIcon &icon,const QString &text,
- QListWidget *view, int type)
- : rtti(type), view(0), d(new QListWidgetItemPrivate(this)),
+ QListWidget *listview, int type)
+ : rtti(type), view(listview), d(new QListWidgetItemPrivate(this)),
itemFlags(Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
|Qt::ItemIsEnabled
|Qt::ItemIsDragEnabled)
{
- setData(Qt::DisplayRole, text);
- setData(Qt::DecorationRole, icon);
- this->view = view;
- if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0))
+ {
+ QSignalBlocker b(view);
+ setData(Qt::DisplayRole, text);
+ setData(Qt::DecorationRole, icon);
+ }
+ if (QListModel *model = listModel())
model->insert(model->rowCount(), this);
}
@@ -671,7 +715,7 @@ QListWidgetItem::QListWidgetItem(const QIcon &icon,const QString &text,
*/
QListWidgetItem::~QListWidgetItem()
{
- if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0))
+ if (QListModel *model = listModel())
model->remove(this);
delete d;
}
@@ -708,7 +752,7 @@ void QListWidgetItem::setData(int role, const QVariant &value)
}
if (!found)
d->values.append(QWidgetItemData(role, value));
- if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : nullptr)) {
+ if (QListModel *model = listModel()) {
const QVector<int> roles((role == Qt::DisplayRole) ?
QVector<int>({Qt::DisplayRole, Qt::EditRole}) :
QVector<int>({role}));
@@ -775,7 +819,7 @@ void QListWidgetItem::write(QDataStream &out) const
\sa data(), flags()
*/
QListWidgetItem::QListWidgetItem(const QListWidgetItem &other)
- : rtti(Type), view(0),
+ : rtti(Type), view(nullptr),
d(new QListWidgetItemPrivate(this)),
itemFlags(other.itemFlags)
{
@@ -797,6 +841,15 @@ QListWidgetItem &QListWidgetItem::operator=(const QListWidgetItem &other)
return *this;
}
+/*!
+ \internal
+ returns the QListModel if a view is set
+ */
+QListModel *QListWidgetItem::listModel() const
+{
+ return (view ? qobject_cast<QListModel*>(view->model()) : nullptr);
+}
+
#ifndef QT_NO_DATASTREAM
/*!
@@ -958,7 +1011,7 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item)
void QListWidgetItem::setFlags(Qt::ItemFlags aflags)
{
itemFlags = aflags;
- if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0))
+ if (QListModel *model = listModel())
model->itemChanged(this);
}
diff --git a/src/widgets/itemviews/qlistwidget.h b/src/widgets/itemviews/qlistwidget.h
index 947fdb1a2f..e96f639502 100644
--- a/src/widgets/itemviews/qlistwidget.h
+++ b/src/widgets/itemviews/qlistwidget.h
@@ -61,10 +61,10 @@ class Q_WIDGETS_EXPORT QListWidgetItem
friend class QListWidget;
public:
enum ItemType { Type = 0, UserType = 1000 };
- explicit QListWidgetItem(QListWidget *view = nullptr, int type = Type);
- explicit QListWidgetItem(const QString &text, QListWidget *view = nullptr, int type = Type);
+ explicit QListWidgetItem(QListWidget *listview = nullptr, int type = Type);
+ explicit QListWidgetItem(const QString &text, QListWidget *listview = nullptr, int type = Type);
explicit QListWidgetItem(const QIcon &icon, const QString &text,
- QListWidget *view = nullptr, int type = Type);
+ QListWidget *listview = nullptr, int type = Type);
QListWidgetItem(const QListWidgetItem &other);
virtual ~QListWidgetItem();
@@ -114,20 +114,28 @@ public:
inline void setTextAlignment(int alignment)
{ setData(Qt::TextAlignmentRole, alignment); }
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X ("Use QListWidgetItem::background() instead")
inline QColor backgroundColor() const
- { return qvariant_cast<QColor>(data(Qt::BackgroundColorRole)); }
+ { return qvariant_cast<QColor>(data(Qt::BackgroundRole)); }
+ QT_DEPRECATED_X ("Use QListWidgetItem::setBackground() instead")
virtual void setBackgroundColor(const QColor &color)
- { setData(Qt::BackgroundColorRole, color); }
+ { setData(Qt::BackgroundRole, color); }
+#endif
inline QBrush background() const
{ return qvariant_cast<QBrush>(data(Qt::BackgroundRole)); }
inline void setBackground(const QBrush &brush)
{ setData(Qt::BackgroundRole, brush); }
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X ("Use QListWidgetItem::foreground() instead")
inline QColor textColor() const
- { return qvariant_cast<QColor>(data(Qt::TextColorRole)); }
+ { return qvariant_cast<QColor>(data(Qt::ForegroundRole)); }
+ QT_DEPRECATED_X ("Use QListWidgetItem::setForeground() instead")
inline void setTextColor(const QColor &color)
- { setData(Qt::TextColorRole, color); }
+ { setData(Qt::ForegroundRole, color); }
+#endif
inline QBrush foreground() const
{ return qvariant_cast<QBrush>(data(Qt::ForegroundRole)); }
@@ -158,6 +166,8 @@ public:
inline int type() const { return rtti; }
private:
+ QListModel *listModel() const;
+private:
int rtti;
QVector<void *> dummy;
QListWidget *view;
diff --git a/src/widgets/itemviews/qlistwidget_p.h b/src/widgets/itemviews/qlistwidget_p.h
index 9cb3d5966b..65a7124322 100644
--- a/src/widgets/itemviews/qlistwidget_p.h
+++ b/src/widgets/itemviews/qlistwidget_p.h
@@ -100,11 +100,15 @@ public:
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ bool clearItemData(const QModelIndex &index) override;
+#endif
QMap<int, QVariant> itemData(const QModelIndex &index) const override;
bool insertRows(int row, int count = 1, const QModelIndex &parent = QModelIndex()) override;
bool removeRows(int row, int count = 1, const QModelIndex &parent = QModelIndex()) override;
+ bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp
index 0f7566e8ec..22067851cb 100644
--- a/src/widgets/itemviews/qstyleditemdelegate.cpp
+++ b/src/widgets/itemviews/qstyleditemdelegate.cpp
@@ -139,7 +139,7 @@ public:
\row \li \l Qt::AccessibleDescriptionRole \li QString
\row \li \l Qt::AccessibleTextRole \li QString
\endomit
- \row \li \l Qt::BackgroundRole \li QBrush
+ \row \li \l Qt::BackgroundRole \li QBrush (\since 4.2)
\row \li \l Qt::BackgroundColorRole \li QColor (obsolete; use Qt::BackgroundRole instead)
\row \li \l Qt::CheckStateRole \li Qt::CheckState
\row \li \l Qt::DecorationRole \li QIcon, QPixmap, QImage and QColor
@@ -151,7 +151,7 @@ public:
\row \li \l Qt::StatusTipRole \li
\endomit
\row \li \l Qt::TextAlignmentRole \li Qt::Alignment
- \row \li \l Qt::ForegroundRole \li QBrush
+ \row \li \l Qt::ForegroundRole \li QBrush (\since 4.2)
\row \li \l Qt::TextColorRole \li QColor (obsolete; use Qt::ForegroundRole instead)
\omit
\row \li \l Qt::ToolTipRole
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index 9725a768de..dac8174a2a 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -904,6 +904,15 @@ void QTableViewPrivate::_q_updateSpanRemovedColumns(const QModelIndex &parent, i
/*!
\internal
+ Sort the model when the header sort indicator changed
+*/
+void QTableViewPrivate::_q_sortIndicatorChanged(int column, Qt::SortOrder order)
+{
+ model->sort(column, order);
+}
+
+/*!
+ \internal
Draws a table cell.
*/
void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)
@@ -1111,8 +1120,6 @@ QSize QTableView::viewportSizeHint() const
Q_D(const QTableView);
QSize result( (d->verticalHeader->isHidden() ? 0 : d->verticalHeader->width()) + d->horizontalHeader->length(),
(d->horizontalHeader->isHidden() ? 0 : d->horizontalHeader->height()) + d->verticalHeader->length());
- result += QSize(verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0,
- horizontalScrollBar()->isVisible() ? horizontalScrollBar()->height() : 0);
return result;
}
@@ -1383,12 +1390,12 @@ void QTableView::paintEvent(QPaintEvent *event)
//firstVisualRow is the visual index of the first visible row. lastVisualRow is the visual index of the last visible Row.
//same goes for ...VisualColumn
int firstVisualRow = qMax(verticalHeader->visualIndexAt(0),0);
- int lastVisualRow = verticalHeader->visualIndexAt(verticalHeader->viewport()->height());
+ int lastVisualRow = verticalHeader->visualIndexAt(verticalHeader->height());
if (lastVisualRow == -1)
lastVisualRow = d->model->rowCount(d->root) - 1;
int firstVisualColumn = horizontalHeader->visualIndexAt(0);
- int lastVisualColumn = horizontalHeader->visualIndexAt(horizontalHeader->viewport()->width());
+ int lastVisualColumn = horizontalHeader->visualIndexAt(horizontalHeader->width());
if (rightToLeft)
qSwap(firstVisualColumn, lastVisualColumn);
if (firstVisualColumn == -1)
@@ -2575,25 +2582,27 @@ void QTableView::setColumnHidden(int column, bool hide)
void QTableView::setSortingEnabled(bool enable)
{
Q_D(QTableView);
- d->sortingEnabled = enable;
horizontalHeader()->setSortIndicatorShown(enable);
if (enable) {
disconnect(d->horizontalHeader, SIGNAL(sectionEntered(int)),
this, SLOT(_q_selectColumn(int)));
disconnect(horizontalHeader(), SIGNAL(sectionPressed(int)),
this, SLOT(selectColumn(int)));
- connect(horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
- this, SLOT(sortByColumn(int)), Qt::UniqueConnection);
+ //sortByColumn has to be called before we connect or set the sortingEnabled flag
+ // because otherwise it will not call sort on the model.
sortByColumn(horizontalHeader()->sortIndicatorSection(),
horizontalHeader()->sortIndicatorOrder());
+ connect(horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
+ this, SLOT(_q_sortIndicatorChanged(int,Qt::SortOrder)), Qt::UniqueConnection);
} else {
connect(d->horizontalHeader, SIGNAL(sectionEntered(int)),
this, SLOT(_q_selectColumn(int)), Qt::UniqueConnection);
connect(horizontalHeader(), SIGNAL(sectionPressed(int)),
this, SLOT(selectColumn(int)), Qt::UniqueConnection);
disconnect(horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
- this, SLOT(sortByColumn(int)));
+ this, SLOT(_q_sortIndicatorChanged(int,Qt::SortOrder)));
}
+ d->sortingEnabled = enable;
}
bool QTableView::isSortingEnabled() const
@@ -3122,19 +3131,21 @@ void QTableView::resizeColumnsToContents()
d->horizontalHeader->resizeSections(QHeaderView::ResizeToContents);
}
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
\obsolete
\overload
+ This function is deprecated. Use
+ sortByColumn(int column, Qt::SortOrder order) instead.
Sorts the model by the values in the given \a column.
*/
void QTableView::sortByColumn(int column)
{
Q_D(QTableView);
- if (column == -1)
- return;
- d->model->sort(column, d->horizontalHeader->sortIndicatorOrder());
+ sortByColumn(column, d->horizontalHeader->sortIndicatorOrder());
}
+#endif
/*!
\since 4.2
@@ -3146,8 +3157,14 @@ void QTableView::sortByColumn(int column)
void QTableView::sortByColumn(int column, Qt::SortOrder order)
{
Q_D(QTableView);
+ if (column < 0)
+ return;
+ // If sorting is enabled it will emit a signal connected to
+ // _q_sortIndicatorChanged, which then actually sorts
d->horizontalHeader->setSortIndicator(column, order);
- sortByColumn(column);
+ // If sorting is not enabled, force to sort now
+ if (!d->sortingEnabled)
+ d->model->sort(column, order);
}
/*!
diff --git a/src/widgets/itemviews/qtableview.h b/src/widgets/itemviews/qtableview.h
index 60c2f34103..3275c09f88 100644
--- a/src/widgets/itemviews/qtableview.h
+++ b/src/widgets/itemviews/qtableview.h
@@ -118,7 +118,6 @@ public:
int columnSpan(int row, int column) const;
void clearSpans();
- void sortByColumn(int column, Qt::SortOrder order);
public Q_SLOTS:
void selectRow(int row);
@@ -131,7 +130,11 @@ public Q_SLOTS:
void resizeRowsToContents();
void resizeColumnToContents(int column);
void resizeColumnsToContents();
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X ("Use QTableView::sortByColumn(int column, Qt::SortOrder order) instead")
void sortByColumn(int column);
+#endif
+ void sortByColumn(int column, Qt::SortOrder order);
void setShowGrid(bool show);
protected Q_SLOTS:
@@ -188,6 +191,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_updateSpanInsertedColumns(QModelIndex,int,int))
Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedRows(QModelIndex,int,int))
Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedColumns(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sortIndicatorChanged(int column, Qt::SortOrder order))
};
QT_END_NAMESPACE
diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h
index 805787597c..520fd9a3af 100644
--- a/src/widgets/itemviews/qtableview_p.h
+++ b/src/widgets/itemviews/qtableview_p.h
@@ -257,6 +257,7 @@ public:
void _q_updateSpanInsertedColumns(const QModelIndex &parent, int start, int end);
void _q_updateSpanRemovedRows(const QModelIndex &parent, int start, int end);
void _q_updateSpanRemovedColumns(const QModelIndex &parent, int start, int end);
+ void _q_sortIndicatorChanged(int column, Qt::SortOrder order);
};
QT_END_NAMESPACE
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 2d539e10ba..0916079cfc 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -189,7 +189,7 @@ void QTableModel::setItem(int row, int column, QTableWidgetItem *item)
sortedRow = qMax((int)(it - colItems.begin()), 0);
}
if (sortedRow != row) {
- emit layoutAboutToBeChanged();
+ emit layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint);
// move the items @ row to sortedRow
int cc = columnCount();
QVector<QTableWidgetItem*> rowItems(cc);
@@ -209,7 +209,7 @@ void QTableModel::setItem(int row, int column, QTableWidgetItem *item)
changePersistentIndexList(oldPersistentIndexes,
newPersistentIndexes);
- emit layoutChanged();
+ emit layoutChanged({}, QAbstractItemModel::VerticalSortHint);
return;
}
}
@@ -480,6 +480,24 @@ bool QTableModel::setItemData(const QModelIndex &index, const QMap<int, QVariant
return true;
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+bool QTableModel::clearItemData(const QModelIndex &index)
+{
+ if (!checkIndex(index, CheckIndexOption::IndexIsValid))
+ return false;
+ QTableWidgetItem *itm = item(index);
+ if (!itm)
+ return false;
+ const auto beginIter = itm->values.cbegin();
+ const auto endIter = itm->values.cend();
+ if (std::all_of(beginIter, endIter, [](const QWidgetItemData& data) -> bool { return !data.value.isValid(); }))
+ return true; //it's already cleared
+ itm->values.clear();
+ emit dataChanged(index, index, QVector<int>{});
+ return true;
+}
+#endif
+
Qt::ItemFlags QTableModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
@@ -530,12 +548,12 @@ void QTableModel::sort(int column, Qt::SortOrder order)
}
}
- emit layoutAboutToBeChanged();
+ emit layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint);
tableItems = sorted_table;
changePersistentIndexList(from, to); // ### slow
- emit layoutChanged();
+ emit layoutChanged({}, QAbstractItemModel::VerticalSortHint);
}
/*
@@ -580,7 +598,7 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order,
vit = colItems.insert(vit, item);
if (newRow != oldRow) {
if (!changed) {
- emit layoutAboutToBeChanged();
+ emit layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint);
oldPersistentIndexes = persistentIndexList();
newPersistentIndexes = oldPersistentIndexes;
changed = true;
@@ -615,7 +633,7 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order,
verticalHeaderItems = newVertical;
changePersistentIndexList(oldPersistentIndexes,
newPersistentIndexes);
- emit layoutChanged();
+ emit layoutChanged({}, QAbstractItemModel::VerticalSortHint);
}
}
@@ -1037,24 +1055,6 @@ QTableWidgetSelectionRange::~QTableWidgetSelectionRange()
*/
/*!
- \fn void QTableWidgetItem::setSelected(bool select)
- \since 4.2
-
- Sets the selected state of the item to \a select.
-
- \sa isSelected()
-*/
-
-/*!
- \fn bool QTableWidgetItem::isSelected() const
- \since 4.2
-
- Returns \c true if the item is selected, otherwise returns \c false.
-
- \sa setSelected()
-*/
-
-/*!
\fn QSize QTableWidgetItem::sizeHint() const
\since 4.1
@@ -1091,6 +1091,44 @@ QTableWidgetSelectionRange::~QTableWidgetSelectionRange()
*/
/*!
+ \fn bool QTableWidgetItem::isSelected() const
+ \since 4.2
+
+ Returns \c true if the item is selected, otherwise returns \c false.
+
+ \sa setSelected()
+*/
+bool QTableWidgetItem::isSelected() const
+{
+ if (!view || !view->selectionModel())
+ return false;
+ const QTableModel *model = qobject_cast<const QTableModel*>(view->model());
+ if (!model)
+ return false;
+ const QModelIndex index = model->index(this);
+ return view->selectionModel()->isSelected(index);
+}
+
+/*!
+ \fn void QTableWidgetItem::setSelected(bool select)
+ \since 4.2
+
+ Sets the selected state of the item to \a select.
+
+ \sa isSelected()
+*/
+void QTableWidgetItem::setSelected(bool select)
+{
+ if (!view || !view->selectionModel())
+ return;
+ const QTableModel *model = qobject_cast<const QTableModel*>(view->model());
+ if (!model)
+ return;
+ const QModelIndex index = model->index(this);
+ view->selectionModel()->select(index, select ? QItemSelectionModel::Select : QItemSelectionModel::Deselect);
+}
+
+/*!
\fn Qt::ItemFlags QTableWidgetItem::flags() const
Returns the flags used to describe the item. These determine whether
@@ -1110,7 +1148,7 @@ QTableWidgetSelectionRange::~QTableWidgetSelectionRange()
void QTableWidgetItem::setFlags(Qt::ItemFlags aflags)
{
itemFlags = aflags;
- if (QTableModel *model = (view ? qobject_cast<QTableModel*>(view->model()) : 0))
+ if (QTableModel *model = tableModel())
model->itemChanged(this);
}
@@ -1301,7 +1339,7 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags)
\sa type()
*/
QTableWidgetItem::QTableWidgetItem(int type)
- : rtti(type), view(0), d(new QTableWidgetItemPrivate(this)),
+ : rtti(type), view(nullptr), d(new QTableWidgetItemPrivate(this)),
itemFlags(Qt::ItemIsEditable
|Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
@@ -1317,7 +1355,7 @@ QTableWidgetItem::QTableWidgetItem(int type)
\sa type()
*/
QTableWidgetItem::QTableWidgetItem(const QString &text, int type)
- : rtti(type), view(0), d(new QTableWidgetItemPrivate(this)),
+ : rtti(type), view(nullptr), d(new QTableWidgetItemPrivate(this)),
itemFlags(Qt::ItemIsEditable
|Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
@@ -1334,7 +1372,7 @@ QTableWidgetItem::QTableWidgetItem(const QString &text, int type)
\sa type()
*/
QTableWidgetItem::QTableWidgetItem(const QIcon &icon, const QString &text, int type)
- : rtti(type), view(0), d(new QTableWidgetItemPrivate(this)),
+ : rtti(type), view(nullptr), d(new QTableWidgetItemPrivate(this)),
itemFlags(Qt::ItemIsEditable
|Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
@@ -1351,9 +1389,8 @@ QTableWidgetItem::QTableWidgetItem(const QIcon &icon, const QString &text, int t
*/
QTableWidgetItem::~QTableWidgetItem()
{
- if (QTableModel *model = (view ? qobject_cast<QTableModel*>(view->model()) : 0))
+ if (QTableModel *model = tableModel())
model->removeItem(this);
- view = 0;
delete d;
}
@@ -1389,7 +1426,7 @@ void QTableWidgetItem::setData(int role, const QVariant &value)
}
if (!found)
values.append(QWidgetItemData(role, value));
- if (QTableModel *model = (view ? qobject_cast<QTableModel*>(view->model()) : nullptr))
+ if (QTableModel *model = tableModel())
{
const QVector<int> roles((role == Qt::DisplayRole) ?
QVector<int>({Qt::DisplayRole, Qt::EditRole}) :
@@ -1444,6 +1481,16 @@ void QTableWidgetItem::write(QDataStream &out) const
}
/*!
+ \internal
+ returns the QTableModel if a view is set
+*/
+QTableModel *QTableWidgetItem::tableModel() const
+{
+ return (view ? qobject_cast<QTableModel*>(view->model()) : nullptr);
+}
+
+
+/*!
\relates QTableWidgetItem
Reads a table widget item from stream \a in into \a item.
@@ -1486,7 +1533,7 @@ QDataStream &operator<<(QDataStream &out, const QTableWidgetItem &item)
\sa data(), flags()
*/
QTableWidgetItem::QTableWidgetItem(const QTableWidgetItem &other)
- : rtti(Type), values(other.values), view(0),
+ : rtti(Type), values(other.values), view(nullptr),
d(new QTableWidgetItemPrivate(this)),
itemFlags(other.itemFlags)
{
@@ -2305,6 +2352,7 @@ void QTableWidget::setCellWidget(int row, int column, QWidget *widget)
QAbstractItemView::setIndexWidget(index, widget);
}
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
Returns \c true if the \a item is selected, otherwise returns \c false.
@@ -2315,9 +2363,7 @@ void QTableWidget::setCellWidget(int row, int column, QWidget *widget)
bool QTableWidget::isItemSelected(const QTableWidgetItem *item) const
{
- Q_D(const QTableWidget);
- QModelIndex index = d->tableModel()->index(item);
- return selectionModel()->isSelected(index);
+ return ((item && item->tableWidget() == this) ? item->isSelected() : false);
}
/*!
@@ -2329,10 +2375,10 @@ bool QTableWidget::isItemSelected(const QTableWidgetItem *item) const
*/
void QTableWidget::setItemSelected(const QTableWidgetItem *item, bool select)
{
- Q_D(QTableWidget);
- QModelIndex index = d->tableModel()->index(item);
- selectionModel()->select(index, select ? QItemSelectionModel::Select : QItemSelectionModel::Deselect);
+ if (item && item->tableWidget() == this)
+ const_cast<QTableWidgetItem*>(item)->setSelected(select);
}
+#endif
/*!
Selects or deselects the \a range depending on \a select.
diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h
index 9de27d164f..d93032f3f0 100644
--- a/src/widgets/itemviews/qtablewidget.h
+++ b/src/widgets/itemviews/qtablewidget.h
@@ -92,8 +92,8 @@ public:
inline int row() const;
inline int column() const;
- inline void setSelected(bool select);
- inline bool isSelected() const;
+ void setSelected(bool select);
+ bool isSelected() const;
inline Qt::ItemFlags flags() const { return itemFlags; }
void setFlags(Qt::ItemFlags flags);
@@ -131,20 +131,28 @@ public:
inline void setTextAlignment(int alignment)
{ setData(Qt::TextAlignmentRole, alignment); }
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X ("Use QTableWidgetItem::background() instead")
inline QColor backgroundColor() const
- { return qvariant_cast<QColor>(data(Qt::BackgroundColorRole)); }
+ { return qvariant_cast<QColor>(data(Qt::BackgroundRole)); }
+ QT_DEPRECATED_X ("Use QTableWidgetItem::setBackground() instead")
inline void setBackgroundColor(const QColor &color)
- { setData(Qt::BackgroundColorRole, color); }
+ { setData(Qt::BackgroundRole, color); }
+#endif
inline QBrush background() const
{ return qvariant_cast<QBrush>(data(Qt::BackgroundRole)); }
inline void setBackground(const QBrush &brush)
{ setData(Qt::BackgroundRole, brush); }
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X ("Use QTableWidgetItem::foreground() instead")
inline QColor textColor() const
- { return qvariant_cast<QColor>(data(Qt::TextColorRole)); }
+ { return qvariant_cast<QColor>(data(Qt::ForegroundRole)); }
+ QT_DEPRECATED_X ("Use QTableWidgetItem::setForeground() instead")
inline void setTextColor(const QColor &color)
- { setData(Qt::TextColorRole, color); }
+ { setData(Qt::ForegroundRole, color); }
+#endif
inline QBrush foreground() const
{ return qvariant_cast<QBrush>(data(Qt::ForegroundRole)); }
@@ -175,6 +183,9 @@ public:
inline int type() const { return rtti; }
private:
+ QTableModel *tableModel() const;
+
+private:
int rtti;
QVector<QWidgetItemData> values;
QTableWidget *view;
@@ -268,8 +279,12 @@ public:
void setCellWidget(int row, int column, QWidget *widget);
inline void removeCellWidget(int row, int column);
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X ("Use QTableWidgetItem::isSelected() instead")
bool isItemSelected(const QTableWidgetItem *item) const;
+ QT_DEPRECATED_X ("Use QTableWidgetItem::setSelected() instead")
void setItemSelected(const QTableWidgetItem *item, bool select);
+#endif
void setRangeSelected(const QTableWidgetSelectionRange &range, bool select);
QList<QTableWidgetSelectionRange> selectedRanges() const;
@@ -375,12 +390,6 @@ inline int QTableWidgetItem::row() const
inline int QTableWidgetItem::column() const
{ return (view ? view->column(this) : -1); }
-inline void QTableWidgetItem::setSelected(bool aselect)
-{ if (view) view->setItemSelected(this, aselect); }
-
-inline bool QTableWidgetItem::isSelected() const
-{ return (view ? view->isItemSelected(this) : false); }
-
QT_END_NAMESPACE
#endif // QTABLEWIDGET_H
diff --git a/src/widgets/itemviews/qtablewidget_p.h b/src/widgets/itemviews/qtablewidget_p.h
index 9899272fce..d88326f129 100644
--- a/src/widgets/itemviews/qtablewidget_p.h
+++ b/src/widgets/itemviews/qtablewidget_p.h
@@ -129,6 +129,9 @@ public:
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) override;
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ bool clearItemData(const QModelIndex &index) override;
+#endif
QMap<int, QVariant> itemData(const QModelIndex &index) const override;
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index f3647f656a..e7196c9d5d 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -1089,15 +1089,8 @@ void QTreeView::keyboardSearch(const QString &search)
if (start.column() > 0)
index = index.sibling(index.row(), start.column());
- if (index.isValid()) {
- QItemSelectionModel::SelectionFlags flags = (d->selectionMode == SingleSelection
- ? QItemSelectionModel::SelectionFlags(
- QItemSelectionModel::ClearAndSelect
- |d->selectionBehaviorFlags())
- : QItemSelectionModel::SelectionFlags(
- QItemSelectionModel::NoUpdate));
- selectionModel()->setCurrentIndex(index, flags);
- }
+ if (index.isValid())
+ setCurrentIndex(index);
}
/*!
@@ -1992,21 +1985,7 @@ void QTreeView::keyPressEvent(QKeyEvent *event)
if (d->isIndexValid(current) && d->model && d->itemsExpandable) {
switch (event->key()) {
case Qt::Key_Asterisk: {
- // do layouting only once after expanding is done
- d->doDelayedItemsLayout();
- QStack<QModelIndex> parents;
- parents.push(current);
- while (!parents.isEmpty()) {
- QModelIndex parent = parents.pop();
- for (int row = 0; row < d->model->rowCount(parent); ++row) {
- QModelIndex child = d->model->index(row, 0, parent);
- if (!d->isIndexValid(child))
- break;
- parents.push(child);
- expand(child);
- }
- }
- expand(current);
+ expandRecursively(current);
break; }
case Qt::Key_Plus:
expand(current);
@@ -2160,12 +2139,10 @@ int QTreeView::verticalOffset() const
// ### find a faster way to do this
d->executePostedLayout();
int offset = 0;
- for (int i = 0; i < d->viewItems.count(); ++i) {
- if (i == verticalScrollBar()->value())
- return offset;
+ const int cnt = std::min(d->viewItems.count(), verticalScrollBar()->value());
+ for (int i = 0; i < cnt; ++i)
offset += d->itemHeight(i);
- }
- return 0;
+ return offset;
}
// scroll per pixel
return verticalScrollBar()->value();
@@ -2621,10 +2598,13 @@ void QTreeView::resizeColumnToContents(int column)
d->header->resizeSection(column, qMax(contents, header));
}
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
\obsolete
\overload
+ This function is deprecated. Use
+ sortByColumn(int column, Qt::SortOrder order) instead.
Sorts the model by the values in the given \a column.
*/
void QTreeView::sortByColumn(int column)
@@ -2632,6 +2612,7 @@ void QTreeView::sortByColumn(int column)
Q_D(QTreeView);
sortByColumn(column, d->header->sortIndicatorOrder());
}
+#endif
/*!
\since 4.2
@@ -2647,10 +2628,12 @@ void QTreeView::sortByColumn(int column)
void QTreeView::sortByColumn(int column, Qt::SortOrder order)
{
Q_D(QTreeView);
-
- //If sorting is enabled will emit a signal connected to _q_sortIndicatorChanged, which then actually sorts
+ if (column < 0)
+ return;
+ // If sorting is enabled it will emit a signal connected to
+ // _q_sortIndicatorChanged, which then actually sorts
d->header->setSortIndicator(column, order);
- //If sorting is not enabled, force to sort now.
+ // If sorting is not enabled, force to sort now
if (!d->sortingEnabled)
d->model->sort(column, order);
}
@@ -2694,11 +2677,7 @@ QSize QTreeView::viewportSizeHint() const
QSize result = QSize(d->header->length(), deepestRect.bottom() + 1);
// add size for header
- result += QSize(0, d->header->isVisible() ? d->header->height() : 0);
-
- // add size for scrollbars
- result += QSize(verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0,
- horizontalScrollBar()->isVisible() ? horizontalScrollBar()->height() : 0);
+ result += QSize(0, d->header->isHidden() ? 0 : d->header->height());
return result;
}
@@ -2707,7 +2686,7 @@ QSize QTreeView::viewportSizeHint() const
\since 4.2
Expands all expandable items.
- Warning: if the model contains a large number of items,
+ \warning: if the model contains a large number of items,
this function will take some time to execute.
\sa collapseAll(), expand(), collapse(), setExpanded()
@@ -2723,6 +2702,50 @@ void QTreeView::expandAll()
}
/*!
+ \since 5.13
+ Expands the item at the given \a index and all its children to the
+ given \a depth. The \a depth is relative to the given \a index.
+ A \a depth of -1 will expand all children, a \a depth of 0 will
+ only expand the given \a index.
+
+ \warning: if the model contains a large number of items,
+ this function will take some time to execute.
+
+ \sa expandAll()
+*/
+void QTreeView::expandRecursively(const QModelIndex &index, int depth)
+{
+ Q_D(QTreeView);
+
+ if (depth < -1)
+ return;
+ // do layouting only once after expanding is done
+ d->doDelayedItemsLayout();
+ expand(index);
+ if (depth == 0)
+ return;
+ QStack<QPair<QModelIndex, int>> parents;
+ parents.push({index, 0});
+ while (!parents.isEmpty()) {
+ const QPair<QModelIndex, int> elem = parents.pop();
+ const QModelIndex &parent = elem.first;
+ const int curDepth = elem.second;
+ const int rowCount = d->model->rowCount(parent);
+ for (int row = 0; row < rowCount; ++row) {
+ const QModelIndex child = d->model->index(row, 0, parent);
+ if (!d->isIndexValid(child))
+ break;
+ if (depth == -1 || curDepth + 1 < depth)
+ parents.push({child, curDepth + 1});
+ if (d->isIndexExpanded(child))
+ continue;
+ if (d->storeExpanded(child))
+ emit expanded(child);
+ }
+ }
+}
+
+/*!
\since 4.2
Collapses all expanded items.
diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h
index 33dbf1c1ce..e9cc1beedb 100644
--- a/src/widgets/itemviews/qtreeview.h
+++ b/src/widgets/itemviews/qtreeview.h
@@ -143,7 +143,6 @@ public:
void doItemsLayout() override;
void reset() override;
- void sortByColumn(int column, Qt::SortOrder order);
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override;
void selectAll() override;
@@ -158,8 +157,13 @@ public Q_SLOTS:
void expand(const QModelIndex &index);
void collapse(const QModelIndex &index);
void resizeColumnToContents(int column);
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X ("Use QTreeeView::sortByColumn(int column, Qt::SortOrder order) instead")
void sortByColumn(int column);
+#endif
+ void sortByColumn(int column, Qt::SortOrder order);
void expandAll();
+ void expandRecursively(const QModelIndex &index, int depth = -1);
void collapseAll();
void expandToDepth(int depth);
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index a0af27115d..acd6ad6e41 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -390,6 +390,27 @@ bool QTreeModel::setData(const QModelIndex &index, const QVariant &value, int ro
return false;
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+bool QTreeModel::clearItemData(const QModelIndex &index)
+{
+ if (!checkIndex(index, CheckIndexOption::IndexIsValid))
+ return false;
+ QTreeWidgetItem *itm = item(index);
+ if (!itm)
+ return false;
+ const auto beginIter = itm->values.at(index.column()).cbegin();
+ const auto endIter = itm->values.at(index.column()).cend();
+ if (std::all_of(beginIter, endIter, [](const QWidgetItemData& data) -> bool { return !data.value.isValid(); })
+ && !itm->d->display.at(index.column()).isValid()) {
+ return true; //it's already cleared
+ }
+ itm->d->display[index.column()] = QVariant();
+ itm->values[index.column()].clear();
+ emit dataChanged(index, index, QVector<int>{});
+ return true;
+}
+#endif
+
QMap<int, QVariant> QTreeModel::itemData(const QModelIndex &index) const
{
QMap<int, QVariant> roles;
@@ -635,7 +656,7 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order,
// we are going to change the persistent indexes, so we need to prepare
if (!changed) { // this will only happen once
changed = true;
- emit layoutAboutToBeChanged(); // the selection model needs to know
+ emit layoutAboutToBeChanged({parent}, QAbstractItemModel::VerticalSortHint); // the selection model needs to know
oldPersistentIndexes = persistentIndexList();
newPersistentIndexes = oldPersistentIndexes;
}
@@ -668,7 +689,7 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order,
if (changed) {
itm->children = lst;
changePersistentIndexList(oldPersistentIndexes, newPersistentIndexes);
- emit layoutChanged();
+ emit layoutChanged({parent}, QAbstractItemModel::VerticalSortHint);
}
}
@@ -988,8 +1009,18 @@ void QTreeModel::timerEvent(QTimerEvent *ev)
Sets the selected state of the item to \a select.
\sa isSelected()
-
*/
+void QTreeWidgetItem::setSelected(bool select)
+{
+ const QTreeModel *model = treeModel();
+ if (!model || !view->selectionModel())
+ return;
+ const QModelIndex index = model->index(this, 0);
+ view->selectionModel()->select(index, (select ? QItemSelectionModel::Select
+ : QItemSelectionModel::Deselect)
+ | QItemSelectionModel::Rows);
+ d->selected = select;
+}
/*!
\fn bool QTreeWidgetItem::isSelected() const
@@ -999,6 +1030,10 @@ void QTreeModel::timerEvent(QTimerEvent *ev)
\sa setSelected()
*/
+bool QTreeWidgetItem::isSelected() const
+{
+ return d->selected;
+}
/*!
\fn void QTreeWidgetItem::setHidden(bool hide)
@@ -1012,12 +1047,18 @@ void QTreeModel::timerEvent(QTimerEvent *ev)
\sa isHidden()
*/
-void QTreeWidgetItem::setHidden(bool ahide)
+void QTreeWidgetItem::setHidden(bool hide)
{
- if (view) {
- view->setItemHidden(this, ahide);
- d->hidden = ahide;
+ const QTreeModel *model = treeModel();
+ if (!model)
+ return;
+ if (this == model->headerItem) {
+ view->header()->setHidden(hide);
+ } else {
+ const QModelIndex index = view->d_func()->index(this);
+ view->setRowHidden(index.row(), index.parent(), hide);
}
+ d->hidden = hide;
}
/*!
@@ -1031,7 +1072,15 @@ void QTreeWidgetItem::setHidden(bool ahide)
bool QTreeWidgetItem::isHidden() const
{
- return (view ? d->hidden : false);
+ const QTreeModel *model = treeModel();
+ if (!model)
+ return false;
+ if (this == model->headerItem)
+ return view->header()->isHidden();
+ if (view->d_func()->hiddenIndexes.isEmpty())
+ return false;
+ QTreeModel::SkipSorting skipSorting(model);
+ return view->d_func()->isRowHidden(view->d_func()->index(this));
}
/*!
@@ -1043,6 +1092,14 @@ bool QTreeWidgetItem::isHidden() const
\sa isExpanded()
*/
+void QTreeWidgetItem::setExpanded(bool expand)
+{
+ const QTreeModel *model = treeModel();
+ if (!model)
+ return;
+ QTreeModel::SkipSorting skipSorting(model);
+ view->setExpanded(view->d_func()->index(this), expand);
+}
/*!
\fn bool QTreeWidgetItem::isExpanded() const
@@ -1052,6 +1109,14 @@ bool QTreeWidgetItem::isHidden() const
\sa setExpanded()
*/
+bool QTreeWidgetItem::isExpanded() const
+{
+ const QTreeModel *model = treeModel();
+ if (!model)
+ return false;
+ QTreeModel::SkipSorting skipSorting(model);
+ return view->isExpanded(view->d_func()->index(this));
+}
/*!
\fn void QTreeWidgetItem::setFirstColumnSpanned(bool span)
@@ -1325,7 +1390,7 @@ bool QTreeWidgetItem::isHidden() const
\sa type()
*/
QTreeWidgetItem::QTreeWidgetItem(int type)
- : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0),
+ : rtti(type), view(nullptr), d(new QTreeWidgetItemPrivate(this)), par(nullptr),
itemFlags(Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
|Qt::ItemIsEnabled
@@ -1344,7 +1409,7 @@ QTreeWidgetItem::QTreeWidgetItem(int type)
\sa type()
*/
QTreeWidgetItem::QTreeWidgetItem(const QStringList &strings, int type)
- : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0),
+ : rtti(type), view(nullptr), d(new QTreeWidgetItemPrivate(this)), par(nullptr),
itemFlags(Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
|Qt::ItemIsEnabled
@@ -1364,16 +1429,16 @@ QTreeWidgetItem::QTreeWidgetItem(const QStringList &strings, int type)
\sa type()
*/
-QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *view, int type)
- : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0),
+QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *treeview, int type)
+ : rtti(type), view(nullptr), d(new QTreeWidgetItemPrivate(this)), par(nullptr),
itemFlags(Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
|Qt::ItemIsEnabled
|Qt::ItemIsDragEnabled
|Qt::ItemIsDropEnabled)
{
- if (view && view->model()) {
- QTreeModel *model = qobject_cast<QTreeModel*>(view->model());
+ // do not set this->view here otherwise insertChild() will fail
+ if (QTreeModel *model = treeModel(treeview)) {
model->rootItem->addChild(this);
values.reserve(model->headerItem->columnCount());
}
@@ -1389,8 +1454,8 @@ QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *view, int type)
\sa type()
*/
-QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *view, const QStringList &strings, int type)
- : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0),
+QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *treeview, const QStringList &strings, int type)
+ : rtti(type), view(nullptr), d(new QTreeWidgetItemPrivate(this)), par(nullptr),
itemFlags(Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
|Qt::ItemIsEnabled
@@ -1399,8 +1464,8 @@ QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *view, const QStringList &strings,
{
for (int i = 0; i < strings.count(); ++i)
setText(i, strings.at(i));
- if (view && view->model()) {
- QTreeModel *model = qobject_cast<QTreeModel*>(view->model());
+ // do not set this->view here otherwise insertChild() will fail
+ if (QTreeModel *model = treeModel(treeview)) {
model->rootItem->addChild(this);
values.reserve(model->headerItem->columnCount());
}
@@ -1414,21 +1479,19 @@ QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *view, const QStringList &strings,
\sa type()
*/
-QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *view, QTreeWidgetItem *after, int type)
- : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0),
+QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *treeview, QTreeWidgetItem *after, int type)
+ : rtti(type), view(nullptr), d(new QTreeWidgetItemPrivate(this)), par(nullptr),
itemFlags(Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
|Qt::ItemIsEnabled
|Qt::ItemIsDragEnabled
|Qt::ItemIsDropEnabled)
{
- if (view) {
- QTreeModel *model = qobject_cast<QTreeModel*>(view->model());
- if (model) {
- int i = model->rootItem->children.indexOf(after) + 1;
- model->rootItem->insertChild(i, this);
- values.reserve(model->headerItem->columnCount());
- }
+ // do not set this->view here otherwise insertChild() will fail
+ if (QTreeModel *model = treeModel(treeview)) {
+ int i = model->rootItem->children.indexOf(after) + 1;
+ model->rootItem->insertChild(i, this);
+ values.reserve(model->headerItem->columnCount());
}
}
@@ -1438,7 +1501,7 @@ QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *view, QTreeWidgetItem *after, int
\sa type()
*/
QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, int type)
- : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0),
+ : rtti(type), view(nullptr), d(new QTreeWidgetItemPrivate(this)), par(nullptr),
itemFlags(Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
|Qt::ItemIsEnabled
@@ -1456,7 +1519,7 @@ QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, int type)
\sa type()
*/
QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, const QStringList &strings, int type)
- : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0),
+ : rtti(type), view(nullptr), d(new QTreeWidgetItemPrivate(this)), par(nullptr),
itemFlags(Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
|Qt::ItemIsEnabled
@@ -1478,7 +1541,7 @@ QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, const QStringList &str
\sa type()
*/
QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, QTreeWidgetItem *after, int type)
- : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0),
+ : rtti(type), view(nullptr), d(new QTreeWidgetItemPrivate(this)), par(nullptr),
itemFlags(Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
|Qt::ItemIsEnabled
@@ -1501,7 +1564,7 @@ QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, QTreeWidgetItem *after
QTreeWidgetItem::~QTreeWidgetItem()
{
- QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0);
+ QTreeModel *model = treeModel();
bool wasSkipSort = false;
if (model) {
wasSkipSort = model->skipPendingSort;
@@ -1663,16 +1726,17 @@ void QTreeWidgetItem::setFlags(Qt::ItemFlags flags)
void QTreeWidgetItemPrivate::updateHiddenStatus(QTreeWidgetItem *item, bool inserting)
{
- QTreeModel *model = (item->view ? qobject_cast<QTreeModel*>(item->view->model()) : 0);
+ QTreeModel *model = item->treeModel();
if (!model)
return;
QStack<QTreeWidgetItem *> parents;
parents.push(item);
while (!parents.isEmpty()) {
QTreeWidgetItem *parent = parents.pop();
- QModelIndex index = model->index(parent, 0);
- if (parent->d->hidden)
+ if (parent->d->hidden) {
+ const QModelIndex index = model->index(parent, 0);
item->view->setRowHidden(index.row(), index.parent(), inserting);
+ }
for (int i = 0; i < parent->children.count(); ++i) {
QTreeWidgetItem *child = parent->children.at(i);
parents.push(child);
@@ -1737,7 +1801,7 @@ void QTreeWidgetItem::setData(int column, int role, const QVariant &value)
if (column < 0)
return;
- QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0);
+ QTreeModel *model = treeModel();
switch (role) {
case Qt::EditRole:
case Qt::DisplayRole: {
@@ -1945,7 +2009,7 @@ void QTreeWidgetItem::insertChild(int index, QTreeWidgetItem *child)
if (index < 0 || index > children.count() || child == 0 || child->view != 0 || child->par != 0)
return;
- if (QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0)) {
+ if (QTreeModel *model = treeModel()) {
const bool wasSkipSort = model->skipPendingSort;
model->skipPendingSort = true;
if (model->rootItem == this)
@@ -1996,7 +2060,7 @@ QTreeWidgetItem *QTreeWidgetItem::takeChild(int index)
{
// we move this outside the check of the index to allow executing
// pending sorts from inline functions, using this function (hack)
- QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0);
+ QTreeModel *model = treeModel();
if (model) {
// This will trigger a layoutChanged signal, thus we might want to optimize
// this function by not emitting the rowsRemoved signal etc to the view.
@@ -2054,7 +2118,7 @@ void QTreeWidgetItem::insertChildren(int index, const QList<QTreeWidgetItem*> &c
insertChild(index, children.at(n));
return;
}
- QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0);
+ QTreeModel *model = treeModel();
QStack<QTreeWidgetItem*> stack;
QList<QTreeWidgetItem*> itemsToInsert;
for (int n = 0; n < children.count(); ++n) {
@@ -2101,7 +2165,7 @@ QList<QTreeWidgetItem*> QTreeWidgetItem::takeChildren()
{
QList<QTreeWidgetItem*> removed;
if (children.count() > 0) {
- QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0);
+ QTreeModel *model = treeModel();
if (model) {
// This will trigger a layoutChanged signal, thus we might want to optimize
// this function by not emitting the rowsRemoved signal etc to the view.
@@ -2133,7 +2197,7 @@ QList<QTreeWidgetItem*> QTreeWidgetItem::takeChildren()
void QTreeWidgetItemPrivate::sortChildren(int column, Qt::SortOrder order, bool climb)
{
- QTreeModel *model = (q->view ? qobject_cast<QTreeModel*>(q->view->model()) : 0);
+ QTreeModel *model = q->treeModel();
if (!model)
return;
model->sortItems(&q->children, column, order);
@@ -2156,7 +2220,7 @@ void QTreeWidgetItemPrivate::sortChildren(int column, Qt::SortOrder order, bool
*/
void QTreeWidgetItem::sortChildren(int column, Qt::SortOrder order, bool climb)
{
- QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0);
+ QTreeModel *model = treeModel();
if (!model)
return;
if (model->isChanging())
@@ -2164,9 +2228,9 @@ void QTreeWidgetItem::sortChildren(int column, Qt::SortOrder order, bool climb)
QTreeModel::SkipSorting skipSorting(model);
int oldSortColumn = view->d_func()->explicitSortColumn;
view->d_func()->explicitSortColumn = column;
- emit model->layoutAboutToBeChanged();
+ emit model->layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint);
d->sortChildren(column, order, climb);
- emit model->layoutChanged();
+ emit model->layoutChanged({}, QAbstractItemModel::VerticalSortHint);
view->d_func()->explicitSortColumn = oldSortColumn;
}
@@ -2236,7 +2300,7 @@ void QTreeWidgetItem::emitDataChanged()
*/
void QTreeWidgetItem::itemChanged()
{
- if (QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0))
+ if (QTreeModel *model = treeModel())
model->itemChanged(this);
}
@@ -2245,10 +2309,21 @@ void QTreeWidgetItem::itemChanged()
*/
void QTreeWidgetItem::executePendingSort() const
{
- if (QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0))
+ if (QTreeModel *model = treeModel())
model->executePendingSort();
}
+/*!
+ \internal
+ returns the QTreeModel if a view is set
+*/
+QTreeModel *QTreeWidgetItem::treeModel(QTreeWidget *v) const
+{
+ if (!v)
+ v = view;
+ return (v ? qobject_cast<QTreeModel*>(v->model()) : nullptr);
+}
+
#ifndef QT_NO_DATASTREAM
/*!
@@ -3027,6 +3102,7 @@ void QTreeWidget::setItemWidget(QTreeWidgetItem *item, int column, QWidget *widg
QAbstractItemView::setIndexWidget(d->index(item, column), widget);
}
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
Returns \c true if the \a item is selected; otherwise returns \c false.
@@ -3038,9 +3114,7 @@ void QTreeWidget::setItemWidget(QTreeWidgetItem *item, int column, QWidget *widg
*/
bool QTreeWidget::isItemSelected(const QTreeWidgetItem *item) const
{
- if (!item)
- return false;
- return item->d->selected;
+ return ((item && item->treeWidget() == this) ? item->isSelected() : false);
}
/*!
@@ -3055,16 +3129,10 @@ bool QTreeWidget::isItemSelected(const QTreeWidgetItem *item) const
*/
void QTreeWidget::setItemSelected(const QTreeWidgetItem *item, bool select)
{
- Q_D(QTreeWidget);
-
- if (!item)
- return;
-
- selectionModel()->select(d->index(item), (select ? QItemSelectionModel::Select
- : QItemSelectionModel::Deselect)
- |QItemSelectionModel::Rows);
- item->d->selected = select;
+ if (item && item->treeWidget() == this)
+ const_cast<QTreeWidgetItem*>(item)->setSelected(select);
}
+#endif
/*!
Returns a list of all selected non-hidden items.
@@ -3081,7 +3149,7 @@ QList<QTreeWidgetItem*> QTreeWidget::selectedItems() const
seen.reserve(indexes.count());
for (const auto &index : indexes) {
QTreeWidgetItem *item = d->item(index);
- if (isItemHidden(item) || seen.contains(item))
+ if (item->isHidden() || seen.contains(item))
continue;
seen.insert(item);
items.append(item);
@@ -3105,6 +3173,7 @@ QList<QTreeWidgetItem*> QTreeWidget::findItems(const QString &text, Qt::MatchFla
return items;
}
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
Returns \c true if the \a item is explicitly hidden, otherwise returns \c false.
@@ -3114,13 +3183,7 @@ QList<QTreeWidgetItem*> QTreeWidget::findItems(const QString &text, Qt::MatchFla
*/
bool QTreeWidget::isItemHidden(const QTreeWidgetItem *item) const
{
- Q_D(const QTreeWidget);
- if (item == d->treeModel()->headerItem)
- return header()->isHidden();
- if (d->hiddenIndexes.isEmpty())
- return false;
- QTreeModel::SkipSorting skipSorting(d->treeModel());
- return d->isRowHidden(d->index(item));
+ return ((item && item->treeWidget() == this) ? item->isHidden() : false);
}
/*!
@@ -3134,16 +3197,8 @@ bool QTreeWidget::isItemHidden(const QTreeWidgetItem *item) const
*/
void QTreeWidget::setItemHidden(const QTreeWidgetItem *item, bool hide)
{
- if (!item)
- return;
- Q_D(QTreeWidget);
- if (item == d->treeModel()->headerItem) {
- header()->setHidden(hide);
- } else {
- const QModelIndex index = d->index(item);
- setRowHidden(index.row(), index.parent(), hide);
- }
- item->d->hidden = hide;
+ if (item && item->treeWidget() == this)
+ const_cast<QTreeWidgetItem*>(item)->setHidden(hide);
}
/*!
@@ -3157,9 +3212,7 @@ void QTreeWidget::setItemHidden(const QTreeWidgetItem *item, bool hide)
*/
bool QTreeWidget::isItemExpanded(const QTreeWidgetItem *item) const
{
- Q_D(const QTreeWidget);
- QTreeModel::SkipSorting skipSorting(d->treeModel());
- return isExpanded(d->index(item));
+ return ((item && item->treeWidget() == this) ? item->isExpanded() : false);
}
/*!
@@ -3174,10 +3227,10 @@ bool QTreeWidget::isItemExpanded(const QTreeWidgetItem *item) const
*/
void QTreeWidget::setItemExpanded(const QTreeWidgetItem *item, bool expand)
{
- Q_D(QTreeWidget);
- QTreeModel::SkipSorting skipSorting(d->treeModel());
- setExpanded(d->index(item), expand);
+ if (item && item->treeWidget() == this)
+ const_cast<QTreeWidgetItem*>(item)->setExpanded(expand);
}
+#endif
/*!
\since 4.3
diff --git a/src/widgets/itemviews/qtreewidget.h b/src/widgets/itemviews/qtreewidget.h
index 975f208702..145b61ff9d 100644
--- a/src/widgets/itemviews/qtreewidget.h
+++ b/src/widgets/itemviews/qtreewidget.h
@@ -66,9 +66,9 @@ public:
enum ItemType { Type = 0, UserType = 1000 };
explicit QTreeWidgetItem(int type = Type);
explicit QTreeWidgetItem(const QStringList &strings, int type = Type);
- explicit QTreeWidgetItem(QTreeWidget *view, int type = Type);
- QTreeWidgetItem(QTreeWidget *view, const QStringList &strings, int type = Type);
- QTreeWidgetItem(QTreeWidget *view, QTreeWidgetItem *after, int type = Type);
+ explicit QTreeWidgetItem(QTreeWidget *treeview, int type = Type);
+ QTreeWidgetItem(QTreeWidget *treeview, const QStringList &strings, int type = Type);
+ QTreeWidgetItem(QTreeWidget *treeview, QTreeWidgetItem *after, int type = Type);
explicit QTreeWidgetItem(QTreeWidgetItem *parent, int type = Type);
QTreeWidgetItem(QTreeWidgetItem *parent, const QStringList &strings, int type = Type);
QTreeWidgetItem(QTreeWidgetItem *parent, QTreeWidgetItem *after, int type = Type);
@@ -79,14 +79,14 @@ public:
inline QTreeWidget *treeWidget() const { return view; }
- inline void setSelected(bool select);
- inline bool isSelected() const;
+ void setSelected(bool select);
+ bool isSelected() const;
void setHidden(bool hide);
bool isHidden() const;
- inline void setExpanded(bool expand);
- inline bool isExpanded() const;
+ void setExpanded(bool expand);
+ bool isExpanded() const;
inline void setFirstColumnSpanned(bool span);
inline bool isFirstColumnSpanned() const;
@@ -134,20 +134,28 @@ public:
inline void setTextAlignment(int column, int alignment)
{ setData(column, Qt::TextAlignmentRole, alignment); }
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X ("Use QTreeWidgetItem::background() instead")
inline QColor backgroundColor(int column) const
- { return qvariant_cast<QColor>(data(column, Qt::BackgroundColorRole)); }
+ { return qvariant_cast<QColor>(data(column, Qt::BackgroundRole)); }
+ QT_DEPRECATED_X ("Use QTreeWidgetItem::setBackground() instead")
inline void setBackgroundColor(int column, const QColor &color)
- { setData(column, Qt::BackgroundColorRole, color); }
+ { setData(column, Qt::BackgroundRole, color); }
+#endif
inline QBrush background(int column) const
{ return qvariant_cast<QBrush>(data(column, Qt::BackgroundRole)); }
inline void setBackground(int column, const QBrush &brush)
{ setData(column, Qt::BackgroundRole, brush); }
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X ("Use QTreeWidgetItem::foreground() instead")
inline QColor textColor(int column) const
- { return qvariant_cast<QColor>(data(column, Qt::TextColorRole)); }
+ { return qvariant_cast<QColor>(data(column, Qt::ForegroundRole)); }
+ QT_DEPRECATED_X ("Use QTreeWidgetItem::setForeground() instead")
inline void setTextColor(int column, const QColor &color)
- { setData(column, Qt::TextColorRole, color); }
+ { setData(column, Qt::ForegroundRole, color); }
+#endif
inline QBrush foreground(int column) const
{ return qvariant_cast<QBrush>(data(column, Qt::ForegroundRole)); }
@@ -207,6 +215,7 @@ private:
QVariant childrenCheckState(int column) const;
void itemChanged();
void executePendingSort() const;
+ QTreeModel *treeModel(QTreeWidget *v = nullptr) const;
int rtti;
// One item has a vector of column entries. Each column has a vector of (role, value) pairs.
@@ -306,17 +315,27 @@ public:
void setItemWidget(QTreeWidgetItem *item, int column, QWidget *widget);
inline void removeItemWidget(QTreeWidgetItem *item, int column);
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X ("Use QTreeWidgetItem::isSelected() instead")
bool isItemSelected(const QTreeWidgetItem *item) const;
+ QT_DEPRECATED_X ("Use QTreeWidgetItem::setSelected() instead")
void setItemSelected(const QTreeWidgetItem *item, bool select);
+#endif
QList<QTreeWidgetItem*> selectedItems() const;
QList<QTreeWidgetItem*> findItems(const QString &text, Qt::MatchFlags flags,
int column = 0) const;
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X ("Use QTreeWidgetItem::isHidden() instead")
bool isItemHidden(const QTreeWidgetItem *item) const;
+ QT_DEPRECATED_X ("Use QTreeWidgetItem::setHidden() instead")
void setItemHidden(const QTreeWidgetItem *item, bool hide);
+ QT_DEPRECATED_X ("Use QTreeWidgetItem::isExpanded() instead")
bool isItemExpanded(const QTreeWidgetItem *item) const;
+ QT_DEPRECATED_X ("Use QTreeWidgetItem::setExpanded() instead")
void setItemExpanded(const QTreeWidgetItem *item, bool expand);
+#endif
bool isFirstItemColumnSpanned(const QTreeWidgetItem *item) const;
void setFirstItemColumnSpanned(const QTreeWidgetItem *item, bool span);
@@ -404,18 +423,6 @@ inline QTreeWidgetItem *QTreeWidget::itemAt(int ax, int ay) const
inline void QTreeWidget::setHeaderLabel(const QString &alabel)
{ setHeaderLabels(QStringList(alabel)); }
-inline void QTreeWidgetItem::setSelected(bool aselect)
-{ if (view) view->setItemSelected(this, aselect); }
-
-inline bool QTreeWidgetItem::isSelected() const
-{ return (view ? view->isItemSelected(this) : false); }
-
-inline void QTreeWidgetItem::setExpanded(bool aexpand)
-{ if (view) view->setItemExpanded(this, aexpand); }
-
-inline bool QTreeWidgetItem::isExpanded() const
-{ return (view ? view->isItemExpanded(this) : false); }
-
inline void QTreeWidgetItem::setFirstColumnSpanned(bool aspan)
{ if (view) view->setFirstItemColumnSpanned(this, aspan); }
diff --git a/src/widgets/itemviews/qtreewidget_p.h b/src/widgets/itemviews/qtreewidget_p.h
index adc2c2c421..ee4a633468 100644
--- a/src/widgets/itemviews/qtreewidget_p.h
+++ b/src/widgets/itemviews/qtreewidget_p.h
@@ -99,7 +99,9 @@ public:
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
-
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ bool clearItemData(const QModelIndex &index) override;
+#endif
QMap<int, QVariant> itemData(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 2410daf047..40b0af359c 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -1443,6 +1443,7 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char*
else
*QApplicationPrivate::set_pal = palette;
QCoreApplication::setAttribute(Qt::AA_SetPalette);
+ emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal);
}
}
@@ -3906,6 +3907,7 @@ Qt::NavigationMode QApplication::navigationMode()
return QApplicationPrivate::navigationMode;
}
+# if QT_DEPRECATED_SINCE(5, 13)
/*!
Sets whether Qt should use focus navigation suitable for use with a
minimal keypad.
@@ -3948,6 +3950,7 @@ bool QApplication::keypadNavigationEnabled()
return QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadTabOrder ||
QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadDirectional;
}
+# endif
#endif
/*!
diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h
index 7a5d7ba1a9..27e743a28d 100644
--- a/src/widgets/kernel/qapplication.h
+++ b/src/widgets/kernel/qapplication.h
@@ -180,8 +180,12 @@ public:
bool notify(QObject *, QEvent *) override;
#ifdef QT_KEYPAD_NAVIGATION
- static Q_DECL_DEPRECATED void setKeypadNavigationEnabled(bool);
- static bool keypadNavigationEnabled();
+# if QT_DEPRECATED_SINCE(5, 13)
+ static QT_DEPRECATED_X ("Use QApplication::setNavigationMode() instead")
+ void setKeypadNavigationEnabled(bool);
+ static QT_DEPRECATED_X ("Use QApplication::navigationMode() instead")
+ bool keypadNavigationEnabled();
+# endif
static void setNavigationMode(Qt::NavigationMode mode);
static Qt::NavigationMode navigationMode();
#endif
diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp
index 1fa83d3238..4a798a7490 100644
--- a/src/widgets/kernel/qwhatsthis.cpp
+++ b/src/widgets/kernel/qwhatsthis.cpp
@@ -398,10 +398,10 @@ QWhatsThisPrivate::QWhatsThisPrivate()
#ifdef QT_NO_CURSOR
Q_UNUSED(sentEvent);
#else
- QApplication::setOverrideCursor((!sentEvent || !e.isAccepted())?
+ QGuiApplication::setOverrideCursor((!sentEvent || !e.isAccepted())?
Qt::ForbiddenCursor:Qt::WhatsThisCursor);
} else {
- QApplication::setOverrideCursor(Qt::WhatsThisCursor);
+ QGuiApplication::setOverrideCursor(Qt::WhatsThisCursor);
#endif
}
#ifndef QT_NO_ACCESSIBILITY
@@ -417,7 +417,7 @@ QWhatsThisPrivate::~QWhatsThisPrivate()
action->setChecked(false);
#endif // QT_CONFIG(action)
#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
+ QGuiApplication::restoreOverrideCursor();
#endif
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(this, QAccessible::ContextHelpEnd);
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index da0d530990..85a89b717e 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -2413,29 +2413,34 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrus
}
}
-void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int flags) const
+bool QWidgetPrivate::updateBrushOrigin(QPainter *painter, const QBrush &brush) const
{
- Q_Q(const QWidget);
-
#if QT_CONFIG(scrollarea)
- bool resetBrushOrigin = false;
- QPointF oldBrushOrigin;
+ Q_Q(const QWidget);
//If we are painting the viewport of a scrollarea, we must apply an offset to the brush in case we are drawing a texture
+ if (brush.style() == Qt::NoBrush || brush.style() == Qt::SolidPattern)
+ return false;
QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent);
if (scrollArea && scrollArea->viewport() == q) {
QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr.data();
QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate);
- oldBrushOrigin = painter->brushOrigin();
- resetBrushOrigin = true;
painter->setBrushOrigin(-priv->contentsOffset());
-
}
#endif // QT_CONFIG(scrollarea)
+ return true;
+}
+void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int flags) const
+{
+ Q_Q(const QWidget);
+
+ bool brushOriginSet = false;
const QBrush autoFillBrush = q->palette().brush(q->backgroundRole());
if ((flags & DrawAsRoot) && !(q->autoFillBackground() && autoFillBrush.isOpaque())) {
const QBrush bg = q->palette().brush(QPalette::Window);
+ if (!brushOriginSet)
+ brushOriginSet = updateBrushOrigin(painter, bg);
if (!(flags & DontSetCompositionMode)) {
//copy alpha straight in
QPainter::CompositionMode oldMode = painter->compositionMode();
@@ -2447,8 +2452,11 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int
}
}
- if (q->autoFillBackground())
+ if (q->autoFillBackground()) {
+ if (!brushOriginSet)
+ brushOriginSet = updateBrushOrigin(painter, autoFillBrush);
fillRegion(painter, rgn, autoFillBrush);
+ }
if (q->testAttribute(Qt::WA_StyledBackground)) {
painter->setClipRegion(rgn);
@@ -2456,11 +2464,6 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int
opt.initFrom(q);
q->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, q);
}
-
-#if QT_CONFIG(scrollarea)
- if (resetBrushOrigin)
- painter->setBrushOrigin(oldBrushOrigin);
-#endif // QT_CONFIG(scrollarea)
}
/*
@@ -4917,9 +4920,9 @@ void QWidget::unsetLayoutDirection()
Some underlying window implementations will reset the cursor if it
leaves a widget even if the mouse is grabbed. If you want to have
a cursor set for all widgets, even when outside the window, consider
- QApplication::setOverrideCursor().
+ QGuiApplication::setOverrideCursor().
- \sa QApplication::setOverrideCursor()
+ \sa QGuiApplication::setOverrideCursor()
*/
#ifndef QT_NO_CURSOR
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
index 9d5fe89c70..4e5ef5a111 100644
--- a/src/widgets/kernel/qwidget.h
+++ b/src/widgets/kernel/qwidget.h
@@ -235,7 +235,10 @@ public:
bool isEnabled() const;
bool isEnabledTo(const QWidget *) const;
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X ("Use isEnabled() instead")
bool isEnabledToTLW() const;
+#endif
public Q_SLOTS:
void setEnabled(bool);
@@ -769,8 +772,10 @@ inline bool QWidget::isEnabled() const
inline bool QWidget::isModal() const
{ return data->window_modality != Qt::NonModal; }
+#if QT_DEPRECATED_SINCE(5, 13)
inline bool QWidget::isEnabledToTLW() const
{ return isEnabled(); }
+#endif
inline int QWidget::minimumWidth() const
{ return minimumSize().width(); }
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index c2fc27a9ad..0c7a5b1944 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -400,6 +400,7 @@ public:
void setUpdatesEnabled_helper(bool );
+ bool updateBrushOrigin(QPainter *, const QBrush &brush) const;
void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const;
bool isAboutToShow() const;
QRegion prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags);
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 66f5f4876e..0821c6af59 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -100,6 +100,9 @@
#if QT_CONFIG(wizard)
#include <qwizard.h>
#endif
+#if QT_CONFIG(filedialog)
+#include <qsidebar_p.h>
+#endif
#include <qfileinfo.h>
#include <qdir.h>
#include <qsettings.h>
@@ -3069,7 +3072,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
}
d->cachedOption = new QStyleOptionViewItem(*vopt);
}
- if (sr == SE_ViewItemCheckIndicator)
+ if (sr == SE_ItemViewItemCheckIndicator)
r = d->checkRect;
else if (sr == SE_ItemViewItemDecoration)
r = d->decorationRect;
@@ -4291,8 +4294,10 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
int topMargin = 0;
int topHeight = 0;
int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget);
- if (groupBox->text.size() || (groupBox->subControls & QStyle::SC_GroupBoxCheckBox)) {
- topHeight = groupBox->fontMetrics.height();
+ bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
+ if (groupBox->text.size() || hasCheckBox) {
+ int checkBoxHeight = hasCheckBox ? proxy()->pixelMetric(PM_IndicatorHeight, groupBox, widget) : 0;
+ topHeight = qMax(groupBox->fontMetrics.height(), checkBoxHeight);
if (verticalAlignment & Qt::AlignVCenter)
topMargin = topHeight / 2;
else if (verticalAlignment & Qt::AlignTop)
@@ -4317,20 +4322,24 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
case SC_GroupBoxCheckBox:
case SC_GroupBoxLabel: {
QFontMetrics fontMetrics = groupBox->fontMetrics;
- int h = fontMetrics.height();
+ int th = fontMetrics.height();
int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width();
int marg = (groupBox->features & QStyleOptionFrame::Flat) ? 0 : 8;
ret = groupBox->rect.adjusted(marg, 0, -marg, 0);
- ret.setHeight(h);
int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, opt, widget);
+ int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget);
int indicatorSpace = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt, widget) - 1;
bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
- int checkBoxSize = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0;
+ int checkBoxWidth = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0;
+ int checkBoxHeight = hasCheckBox ? indicatorHeight : 0;
+
+ int h = qMax(th, checkBoxHeight);
+ ret.setHeight(h);
// Adjusted rect for label + indicatorWidth + indicatorSpace
QRect totalRect = alignedRect(groupBox->direction, groupBox->textAlignment,
- QSize(tw + checkBoxSize, h), ret);
+ QSize(tw + checkBoxWidth, h), ret);
// Adjust totalRect if checkbox is set
if (hasCheckBox) {
@@ -4338,15 +4347,14 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
int left = 0;
// Adjust for check box
if (sc == SC_GroupBoxCheckBox) {
- int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget);
left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth);
- int top = totalRect.top() + qMax(0, fontMetrics.height() - indicatorHeight) / 2;
+ int top = totalRect.top() + (h - checkBoxHeight) / 2;
totalRect.setRect(left, top, indicatorWidth, indicatorHeight);
// Adjust for label
} else {
- left = ltr ? (totalRect.left() + checkBoxSize - 2) : totalRect.left();
- totalRect.setRect(left, totalRect.top(),
- totalRect.width() - checkBoxSize, totalRect.height());
+ left = ltr ? (totalRect.left() + checkBoxWidth - 2) : totalRect.left();
+ int top = totalRect.top() + (h - th) / 2;
+ totalRect.setRect(left, top, totalRect.width() - checkBoxWidth, th);
}
}
ret = totalRect;
@@ -4722,9 +4730,16 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
break;
case PM_TabBarIconSize:
- case PM_ListViewIconSize:
ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
break;
+ case PM_ListViewIconSize:
+#if QT_CONFIG(filedialog)
+ if (qobject_cast<const QSidebar *>(widget))
+ ret = int(QStyleHelper::dpiScaled(24.));
+ else
+#endif
+ ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
+ break;
case PM_ButtonIconSize:
case PM_SmallIconSize:
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
index 9192dae864..8256f908db 100644
--- a/src/widgets/styles/qstyle.h
+++ b/src/widgets/styles/qstyle.h
@@ -308,8 +308,8 @@ public:
SE_TabWidgetLeftCorner,
SE_TabWidgetRightCorner,
- SE_ViewItemCheckIndicator, // ### Qt 6: remove
- SE_ItemViewItemCheckIndicator = SE_ViewItemCheckIndicator,
+ SE_ItemViewItemCheckIndicator,
+ SE_ViewItemCheckIndicator = SE_ItemViewItemCheckIndicator, // ### Qt 6: remove
SE_TabBarTearIndicator,
SE_TabBarTearIndicatorLeft = SE_TabBarTearIndicator,
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index fe6a4d0e40..3e397c9e04 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -44,6 +44,7 @@
#include "private/qcssutil_p.h"
#include <qdebug.h>
+#include <qdir.h>
#include <qapplication.h>
#if QT_CONFIG(menu)
#include <qmenu.h>
@@ -957,8 +958,10 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject
origin = Origin_Padding;
Origin clip = Origin_Border;
if (v.extractBackground(&brush, &uri, &repeat, &alignment, &origin, &attachment, &clip)) {
- bg = new QStyleSheetBackgroundData(brush, QStyleSheetStyle::loadPixmap(uri, object),
- repeat, alignment, origin, attachment, clip);
+ QPixmap pixmap = QStyleSheetStyle::loadPixmap(uri, object);
+ if (!uri.isEmpty() && pixmap.isNull())
+ qWarning("Could not create pixmap from %s", qPrintable(QDir::toNativeSeparators(uri)));
+ bg = new QStyleSheetBackgroundData(brush, pixmap, repeat, alignment, origin, attachment, clip);
}
QBrush sfg, fg;
@@ -5079,21 +5082,27 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
QRenderRule subRule = renderRule(w, opt, pe);
if ((pe == PseudoElement_MenuSeparator) && subRule.hasContentsSize()) {
return QSize(sz.width(), subRule.size().height());
- } else if ((pe == PseudoElement_Item) && (subRule.hasBox() || subRule.hasBorder())) {
- int width = csz.width();
+ }
+ if ((pe == PseudoElement_Item) && (subRule.hasBox() || subRule.hasBorder() || subRule.hasFont)) {
+ QSize sz(csz);
if (mi->text.contains(QLatin1Char('\t')))
- width += 12; //as in QCommonStyle
+ sz.rwidth() += 12; //as in QCommonStyle
bool checkable = mi->checkType != QStyleOptionMenuItem::NotCheckable;
if (checkable) {
QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
QRect checkmarkRect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction);
- width += checkmarkRect.width();
+ sz.rwidth() += checkmarkRect.width();
}
if (!mi->icon.isNull()) {
QPixmap pixmap = mi->icon.pixmap(pixelMetric(PM_SmallIconSize));
- width += pixmap.width();
+ sz.rwidth() += pixmap.width();
+ }
+ if (subRule.hasFont) {
+ QFontMetrics fm(subRule.font);
+ const QRect r = fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, mi->text);
+ sz = sz.expandedTo(r.size());
}
- return subRule.boxSize(subRule.adjustSize(QSize(width, csz.height())));
+ return subRule.boxSize(subRule.adjustSize(sz));
}
}
break;
@@ -5768,11 +5777,10 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
case SE_PushButtonContents:
case SE_PushButtonFocusRect:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- QStyleOptionButton btnOpt(*btn);
if (rule.hasBox() || !rule.hasNativeBorder())
return visualRect(opt->direction, opt->rect, rule.contentsRect(opt->rect));
- return rule.baseStyleCanDraw() ? baseStyle()->subElementRect(se, &btnOpt, w)
- : QWindowsStyle::subElementRect(se, &btnOpt, w);
+ return rule.baseStyleCanDraw() ? baseStyle()->subElementRect(se, btn, w)
+ : QWindowsStyle::subElementRect(se, btn, w);
}
break;
@@ -5827,7 +5835,7 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
return ParentStyle::subElementRect(se, opt, w);
#if QT_CONFIG(itemviews)
- case SE_ViewItemCheckIndicator:
+ case SE_ItemViewItemCheckIndicator:
if (!qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
return subElementRect(SE_CheckBoxIndicator, opt, w);
}
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index 598d173144..fd5d7d8069 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -1604,8 +1604,10 @@ QSize QAbstractScrollArea::sizeHint() const
if (!d->sizeHint.isValid() || d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents) {
const int f = 2 * d->frameWidth;
const QSize frame( f, f );
- const QSize scrollbars(d->vbarpolicy == Qt::ScrollBarAlwaysOn ? d->vbar->sizeHint().width() : 0,
- d->hbarpolicy == Qt::ScrollBarAlwaysOn ? d->hbar->sizeHint().height() : 0);
+ const bool vbarHidden = d->vbar->isHidden() || d->vbarpolicy == Qt::ScrollBarAlwaysOff;
+ const bool hbarHidden = d->hbar->isHidden() || d->hbarpolicy == Qt::ScrollBarAlwaysOff;
+ const QSize scrollbars(vbarHidden ? 0 : d->vbar->sizeHint().width(),
+ hbarHidden ? 0 : d->hbar->sizeHint().height());
d->sizeHint = frame + scrollbars + viewportSizeHint();
}
return d->sizeHint;
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index 4946969360..0553972591 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -1178,9 +1178,9 @@ QVariant QCalendarModel::data(const QModelIndex &index, int role) const
}
QTextCharFormat fmt = formatForCell(row, column);
- if (role == Qt::BackgroundColorRole)
+ if (role == Qt::BackgroundRole)
return fmt.background().color();
- if (role == Qt::TextColorRole)
+ if (role == Qt::ForegroundRole)
return fmt.foreground().color();
if (role == Qt::FontRole)
return fmt.font();
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index e20a0892b4..645b1a8c9e 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -1941,12 +1941,15 @@ const QValidator *QComboBox::validator() const
performs case insensitive inline completion is automatically created.
\note The completer is removed when the \l editable property becomes \c false.
+ Setting a completer on a QComboBox that is not editable will be ignored.
*/
void QComboBox::setCompleter(QCompleter *c)
{
Q_D(QComboBox);
- if (!d->lineEdit)
+ if (!d->lineEdit) {
+ qWarning("Setting a QCompleter on non-editable QComboBox is not allowed.");
return;
+ }
d->lineEdit->setCompleter(c);
if (c) {
connect(c, SIGNAL(activated(QModelIndex)), this, SLOT(_q_completerActivated(QModelIndex)));
diff --git a/src/widgets/widgets/qcommandlinkbutton.h b/src/widgets/widgets/qcommandlinkbutton.h
index 2d01d63df8..3d2dd5784d 100644
--- a/src/widgets/widgets/qcommandlinkbutton.h
+++ b/src/widgets/widgets/qcommandlinkbutton.h
@@ -66,10 +66,16 @@ public:
QString description() const;
void setDescription(const QString &description);
+ // QTBUG-68722
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
protected:
+#else
+public:
+#endif
QSize sizeHint() const override;
int heightForWidth(int) const override;
QSize minimumSizeHint() const override;
+protected:
bool event(QEvent *e) override;
void paintEvent(QPaintEvent *) override;
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 60f88df9af..a840bf4ee6 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -1098,7 +1098,7 @@ void QLabel::paintEvent(QPaintEvent *)
QImage scaledImage =
d->cachedimage->scaled(scaledSize,
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- d->scaledpixmap = new QPixmap(QPixmap::fromImage(scaledImage));
+ d->scaledpixmap = new QPixmap(QPixmap::fromImage(std::move(scaledImage)));
d->scaledpixmap->setDevicePixelRatio(devicePixelRatioF());
}
pix = *d->scaledpixmap;
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 411b482c11..fae3aebba4 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -851,7 +851,11 @@ void QMainWindow::removeToolBar(QToolBar *toolbar)
\sa addToolBar(), addToolBarBreak(), Qt::ToolBarArea
*/
-Qt::ToolBarArea QMainWindow::toolBarArea(QToolBar *toolbar) const
+Qt::ToolBarArea QMainWindow::toolBarArea(
+#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
+ const
+#endif
+ QToolBar *toolbar) const
{ return d_func()->layout->toolBarArea(toolbar); }
/*!
diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h
index 8f2a192446..85e3f87d77 100644
--- a/src/widgets/widgets/qmainwindow.h
+++ b/src/widgets/widgets/qmainwindow.h
@@ -158,7 +158,11 @@ public:
bool unifiedTitleAndToolBarOnMac() const;
- Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const;
+ Qt::ToolBarArea toolBarArea(
+#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
+ const
+#endif
+ QToolBar *toolbar) const;
bool toolBarBreak(QToolBar *toolbar) const;
#endif
#if QT_CONFIG(dockwidget)
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 053bfbf024..ed054c7e9a 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -1388,7 +1388,7 @@ void QMainWindowLayout::insertToolBar(QToolBar *before, QToolBar *toolbar)
invalidate();
}
-Qt::ToolBarArea QMainWindowLayout::toolBarArea(QToolBar *toolbar) const
+Qt::ToolBarArea QMainWindowLayout::toolBarArea(const QToolBar *toolbar) const
{
QInternal::DockPosition pos = layoutState.toolBarAreaLayout.findToolBar(toolbar);
switch (pos) {
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
index 72cbec2350..a375d856bb 100644
--- a/src/widgets/widgets/qmainwindowlayout_p.h
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -475,7 +475,7 @@ public:
void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar, bool needAddChildWidget = true);
void insertToolBar(QToolBar *before, QToolBar *toolbar);
- Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const;
+ Qt::ToolBarArea toolBarArea(const QToolBar *toolbar) const;
bool toolBarBreak(QToolBar *toolBar) const;
void getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar *toolBar) const;
void removeToolBar(QToolBar *toolbar);
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index c79e88f094..bf1102434c 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -1800,21 +1800,6 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
return action;
}
-/*!\fn template<typename PointerToMemberFunction> QAction *QMenu::addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0)
-
- \since 5.6
-
- \overload
-
- This convenience function creates a new action with the text \a
- text and an optional shortcut \a shortcut. The action's
- \l{QAction::triggered()}{triggered()} signal is connected to the
- \a method of the \a receiver. The function adds the newly created
- action to the menu's list of actions and returns it.
-
- QMenu takes ownership of the returned QAction.
-*/
-
/*!\fn template<typename Functor> QAction *QMenu::addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0)
\since 5.6
@@ -1839,25 +1824,11 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
This convenience function creates a new action with the text \a
text and an optional shortcut \a shortcut. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
- \a functor. The function adds the newly created
- action to the menu's list of actions and returns it.
+ \a functor. The functor can be a pointer to a member function of
+ the \a context object. The newly created action is added to the
+ menu's list of actions and a pointer to it is returned.
- If \a context is destroyed, the functor will not be called.
-
- QMenu takes ownership of the returned QAction.
-*/
-
-/*!\fn template<typename PointerToMemberFunction> QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0)
-
- \since 5.6
-
- \overload
-
- This convenience function creates a new action with an \a icon
- and some \a text and an optional shortcut \a shortcut. The action's
- \l{QAction::triggered()}{triggered()} signal is connected to the
- \a method of the \a receiver. The function adds the newly created
- action to the menu's list of actions and returns it.
+ If the \a context object is destroyed, the functor will not be called.
QMenu takes ownership of the returned QAction.
*/
@@ -1886,8 +1857,9 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
This convenience function creates a new action with an \a icon
and some \a text and an optional shortcut \a shortcut. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
- \a functor. The function adds the newly created
- action to the menu's list of actions and returns it.
+ \a functor. The \a functor can be a pointer to a member function
+ of the \a context object. The newly created action is added to the
+ menu's list of actions and a pointer to it is returned.
If \a context is destroyed, the functor will not be called.
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h
index 628f818b5e..84ab9e027a 100644
--- a/src/widgets/widgets/qmenu.h
+++ b/src/widgets/widgets/qmenu.h
@@ -82,14 +82,10 @@ public:
QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
#ifdef Q_CLANG_QDOC
- template<typename PointerToMemberFunction>
- QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0);
template<typename Functor>
QAction *addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0);
template<typename Functor>
QAction *addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0);
- template<typename PointerToMemberFunction>
- QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0);
template<typename Functor>
QAction *addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0);
template<typename Functor>
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index d6f6a364a8..b498d5fe7a 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -1614,7 +1614,7 @@ void QPlainTextEdit::timerEvent(QTimerEvent *e)
const QPoint globalPos = QCursor::pos();
pos = d->viewport->mapFromGlobal(globalPos);
QMouseEvent ev(QEvent::MouseMove, pos, d->viewport->mapTo(d->viewport->topLevelWidget(), pos), globalPos,
- Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
+ Qt::LeftButton, Qt::LeftButton, QGuiApplication::keyboardModifiers());
mouseMoveEvent(&ev);
}
int deltaY = qMax(pos.y() - visible.top(), visible.bottom() - pos.y()) - visible.height();
@@ -2891,6 +2891,7 @@ void QPlainTextEdit::setCenterOnScroll(bool enabled)
if (enabled == d->centerOnScroll)
return;
d->centerOnScroll = enabled;
+ d->_q_adjustScrollbars();
}
@@ -2928,6 +2929,27 @@ bool QPlainTextEdit::find(const QRegExp &exp, QTextDocument::FindFlags options)
#endif
/*!
+ \fn bool QTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options)
+
+ \since 5.13
+ \overload
+
+ Finds the next occurrence, matching the regular expression, \a exp, using the given
+ \a options. The QTextDocument::FindCaseSensitively option is ignored for this overload,
+ use QRegularExpression::CaseInsensitiveOption instead.
+
+ Returns \c true if a match was found and changes the cursor to select the match;
+ otherwise returns \c false.
+*/
+#if QT_CONFIG(regularexpression)
+bool QPlainTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options)
+{
+ Q_D(QPlainTextEdit);
+ return d->control->find(exp, options);
+}
+#endif
+
+/*!
\fn void QPlainTextEdit::copyAvailable(bool yes)
This signal is emitted when text is selected or de-selected in the
diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h
index e5ac4c82b8..a5945d649a 100644
--- a/src/widgets/widgets/qplaintextedit.h
+++ b/src/widgets/widgets/qplaintextedit.h
@@ -60,6 +60,7 @@ class QMenu;
class QPlainTextEditPrivate;
class QMimeData;
class QPagedPaintDevice;
+class QRegularExpression;
class Q_WIDGETS_EXPORT QPlainTextEdit : public QAbstractScrollArea
{
@@ -149,6 +150,9 @@ public:
#ifndef QT_NO_REGEXP
bool find(const QRegExp &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#endif
+#if QT_CONFIG(regularexpression)
+ bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
+#endif
inline QString toPlainText() const
{ return document()->toPlainText(); }
diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp
index 09541bb53b..bb9a4fed91 100644
--- a/src/widgets/widgets/qtextbrowser.cpp
+++ b/src/widgets/widgets/qtextbrowser.cpp
@@ -276,7 +276,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url)
Q_Q(QTextBrowser);
#ifndef QT_NO_CURSOR
if (q->isVisible())
- QApplication::setOverrideCursor(Qt::WaitCursor);
+ QGuiApplication::setOverrideCursor(Qt::WaitCursor);
#endif
textOrSourceChanged = true;
@@ -310,7 +310,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url)
const QStringRef firstTag = txt.leftRef(txt.indexOf(QLatin1Char('>')) + 1);
if (firstTag.startsWith(QLatin1String("<qt")) && firstTag.contains(QLatin1String("type")) && firstTag.contains(QLatin1String("detail"))) {
#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
+ QGuiApplication::restoreOverrideCursor();
#endif
#if QT_CONFIG(whatsthis)
QWhatsThis::showText(QCursor::pos(), txt, q);
@@ -355,7 +355,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url)
#ifndef QT_NO_CURSOR
if (q->isVisible())
- QApplication::restoreOverrideCursor();
+ QGuiApplication::restoreOverrideCursor();
#endif
emit q->sourceChanged(url);
}
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index e3a45680ef..920133d493 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -105,6 +105,14 @@ public:
else
ed->insertFromMimeData(source);
}
+ QVariant loadResource(int type, const QUrl &name) override {
+ auto *ed = qobject_cast<QTextEdit *>(parent());
+ if (!ed)
+ return QWidgetTextControl::loadResource(type, name);
+
+ QUrl resolvedName = ed->d_func()->resolveUrl(name);
+ return ed->loadResource(type, resolvedName);
+ }
};
QTextEditPrivate::QTextEditPrivate()
@@ -2534,6 +2542,27 @@ bool QTextEdit::find(const QRegExp &exp, QTextDocument::FindFlags options)
#endif
/*!
+ \fn bool QTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options)
+
+ \since 5.13
+ \overload
+
+ Finds the next occurrence, matching the regular expression, \a exp, using the given
+ \a options. The QTextDocument::FindCaseSensitively option is ignored for this overload,
+ use QRegularExpression::CaseInsensitiveOption instead.
+
+ Returns \c true if a match was found and changes the cursor to select the match;
+ otherwise returns \c false.
+*/
+#if QT_CONFIG(regularexpression)
+bool QTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options)
+{
+ Q_D(QTextEdit);
+ return d->control->find(exp, options);
+}
+#endif
+
+/*!
\fn void QTextEdit::copyAvailable(bool yes)
This signal is emitted when text is selected or de-selected in the
diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h
index 51d6c2ccba..3aa23aaace 100644
--- a/src/widgets/widgets/qtextedit.h
+++ b/src/widgets/widgets/qtextedit.h
@@ -57,6 +57,7 @@ class QMenu;
class QTextEditPrivate;
class QMimeData;
class QPagedPaintDevice;
+class QRegularExpression;
class Q_WIDGETS_EXPORT QTextEdit : public QAbstractScrollArea
{
@@ -165,6 +166,9 @@ public:
#ifndef QT_NO_REGEXP
bool find(const QRegExp &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#endif
+#if QT_CONFIG(regularexpression)
+ bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
+#endif
QString toPlainText() const;
#ifndef QT_NO_TEXTHTMLPARSER
diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index 4af71c126e..1cd30e4d0d 100644
--- a/src/widgets/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
@@ -799,18 +799,6 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
return action;
}
-/*!\fn template<typename PointerToMemberFunction> QAction *QToolBar::addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method)
-
- \since 5.6
-
- \overload
-
- Creates a new action with the given \a text. This action is added to
- the end of the toolbar. The action's
- \l{QAction::triggered()}{triggered()} signal is connected to the
- \a method of the \a receiver.
-*/
-
/*!\fn template<typename Functor> QAction *QToolBar::addAction(const QString &text, Functor functor)
\since 5.6
@@ -829,24 +817,13 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
\overload
- Creates a new action with the given \a text. This action is added to
- the end of the toolbar. The action's
+ Creates a new action with the given \a text. This action is added
+ to the end of the toolbar. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
- \a functor.
-
- If \a context is destroyed, the functor will not be called.
-*/
-
-/*!\fn template<typename PointerToMemberFunction> QAction *QToolBar::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method)
-
- \since 5.6
+ \a functor. The \a functor can be a pointer to a member function
+ in the \a context object.
- \overload
-
- Creates a new action with the given \a icon and \a text. This
- action is added to the end of the toolbar. The action's
- \l{QAction::triggered()}{triggered()} signal is connected to the
- \a method of the \a receiver.
+ If the \a context object is destroyed, the \a functor will not be called.
*/
/*!\fn template<typename Functor> QAction *QToolBar::addAction(const QIcon &icon, const QString &text, Functor functor)
@@ -870,9 +847,10 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
Creates a new action with the given \a icon and \a text. This
action is added to the end of the toolbar. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
- \a functor.
+ \a functor. The \a functor can be a pointer to a member function
+ of the \a context object.
- If \a context is destroyed, the functor will not be called.
+ If the \a context object is destroyed, the \a functor will not be called.
*/
/*!
diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h
index 4ae83190d1..0c434e8d1d 100644
--- a/src/widgets/widgets/qtoolbar.h
+++ b/src/widgets/widgets/qtoolbar.h
@@ -99,15 +99,11 @@ public:
QAction *addAction(const QString &text, const QObject *receiver, const char* member);
QAction *addAction(const QIcon &icon, const QString &text,
const QObject *receiver, const char* member);
-#ifdef Q_QDOC
- template<typename PointerToMemberFunction>
- QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method);
+#ifdef Q_CLANG_QDOC
template<typename Functor>
QAction *addAction(const QString &text, Functor functor);
template<typename Functor>
QAction *addAction(const QString &text, const QObject *context, Functor functor);
- template<typename PointerToMemberFunction>
- QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method);
template<typename Functor>
QAction *addAction(const QIcon &icon, const QString &text, Functor functor);
template<typename Functor>
@@ -149,7 +145,7 @@ public:
connect(result, &QAction::triggered, slot);
return result;
}
-#endif // !Q_QDOC
+#endif // !Q_CLANG_QDOC
QAction *addSeparator();
QAction *insertSeparator(QAction *before);
diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp
index edf497111b..884eface3c 100644
--- a/src/widgets/widgets/qtoolbararealayout.cpp
+++ b/src/widgets/widgets/qtoolbararealayout.cpp
@@ -789,7 +789,7 @@ void QToolBarAreaLayout::deleteAllLayoutItems()
}
}
-QInternal::DockPosition QToolBarAreaLayout::findToolBar(QToolBar *toolBar) const
+QInternal::DockPosition QToolBarAreaLayout::findToolBar(const QToolBar *toolBar) const
{
for (int i = 0; i < QInternal::DockCount; ++i) {
const QToolBarAreaLayoutInfo &dock = docks[i];
diff --git a/src/widgets/widgets/qtoolbararealayout_p.h b/src/widgets/widgets/qtoolbararealayout_p.h
index dffbab1f21..17747ef29b 100644
--- a/src/widgets/widgets/qtoolbararealayout_p.h
+++ b/src/widgets/widgets/qtoolbararealayout_p.h
@@ -196,7 +196,7 @@ public:
void insertItem(QInternal::DockPosition pos, QLayoutItem *item);
void insertItem(QToolBar *before, QLayoutItem *item);
- QInternal::DockPosition findToolBar(QToolBar *toolBar) const;
+ QInternal::DockPosition findToolBar(const QToolBar *toolBar) const;
bool toolBarBreak(QToolBar *toolBar) const;
void getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar *toolBar) const;
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index e179ea3b40..711c4bfd2a 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -57,9 +57,6 @@
#include <qtimer.h>
#include "private/qtextdocumentlayout_p.h"
#include "private/qabstracttextdocumentlayout_p.h"
-#if QT_CONFIG(textedit)
-#include "private/qtextedit_p.h"
-#endif
#include "qtextdocument.h"
#include "private/qtextdocument_p.h"
#include "qtextlist.h"
@@ -218,6 +215,14 @@ bool QWidgetTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
else if (e == QKeySequence::SelectPreviousLine) {
op = QTextCursor::Up;
mode = QTextCursor::KeepAnchor;
+ {
+ QTextBlock block = cursor.block();
+ QTextLine line = currentTextLine(cursor);
+ if (!block.previous().isValid()
+ && line.isValid()
+ && line.lineNumber() == 0)
+ op = QTextCursor::Start;
+ }
}
else if (e == QKeySequence::SelectNextLine) {
op = QTextCursor::Down;
@@ -1357,15 +1362,8 @@ process:
QVariant QWidgetTextControl::loadResource(int type, const QUrl &name)
{
-#if !QT_CONFIG(textedit)
Q_UNUSED(type);
Q_UNUSED(name);
-#else
- if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(parent())) {
- QUrl resolvedName = textEdit->d_func()->resolveUrl(name);
- return textEdit->loadResource(type, resolvedName);
- }
-#endif
return QVariant();
}
@@ -3094,6 +3092,19 @@ bool QWidgetTextControl::find(const QRegExp &exp, QTextDocument::FindFlags optio
}
#endif
+#if QT_CONFIG(regularexpression)
+bool QWidgetTextControl::find(const QRegularExpression &exp, QTextDocument::FindFlags options)
+{
+ Q_D(QWidgetTextControl);
+ QTextCursor search = d->doc->find(exp, d->cursor, options);
+ if (search.isNull())
+ return false;
+
+ setTextCursor(search);
+ return true;
+}
+#endif
+
QString QWidgetTextControl::toPlainText() const
{
return document()->toPlainText();
diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h
index 4b2acbd934..5431298387 100644
--- a/src/widgets/widgets/qwidgettextcontrol_p.h
+++ b/src/widgets/widgets/qwidgettextcontrol_p.h
@@ -80,6 +80,7 @@ class QMenu;
class QWidgetTextControlPrivate;
class QAbstractScrollArea;
class QEvent;
+class QRegularExpression;
class QTimerEvent;
class Q_WIDGETS_EXPORT QWidgetTextControl : public QInputControl
@@ -119,6 +120,9 @@ public:
#ifndef QT_NO_REGEXP
bool find(const QRegExp &exp, QTextDocument::FindFlags options = 0);
#endif
+#if QT_CONFIG(regularexpression)
+ bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = 0);
+#endif
QString toPlainText() const;
#ifndef QT_NO_TEXTHTMLPARSER