summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/harfbuzz-ng/src/hb-private.hh9
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-32-rvk.macros0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-32.macros0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-64.macros0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-int-set.h0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-interface.h0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-opt32-settings.h0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-opt32.c0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-opt64-settings.h0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-unrolling.macros0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakNISTInterface.c0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakNISTInterface.h0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakSponge.c0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakSponge.h0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/brg_endian.h0
-rw-r--r--src/3rdparty/sqlite/sqlite3.c2
-rw-r--r--src/3rdparty/zlib/0001-Fix-WEC2013-build-of-zlib.patch26
-rw-r--r--src/3rdparty/zlib/zutil.h2
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtNative.java64
-rw-r--r--src/corelib/animation/qabstractanimation.h8
-rw-r--r--src/corelib/animation/qanimationgroup.h2
-rw-r--r--src/corelib/animation/qparallelanimationgroup.h2
-rw-r--r--src/corelib/animation/qpauseanimation.h4
-rw-r--r--src/corelib/animation/qpropertyanimation.h4
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.h2
-rw-r--r--src/corelib/animation/qvariantanimation.h4
-rw-r--r--src/corelib/codecs/qtextcodec.h6
-rw-r--r--src/corelib/doc/src/objectmodel/properties.qdoc9
-rw-r--r--src/corelib/global/qflags.h2
-rw-r--r--src/corelib/global/qglobal.cpp24
-rw-r--r--src/corelib/global/qglobal.h72
-rw-r--r--src/corelib/global/qlogging.h3
-rw-r--r--src/corelib/global/qnamespace.h21
-rw-r--r--src/corelib/global/qnamespace.qdoc53
-rw-r--r--src/corelib/global/qsysinfo.h26
-rw-r--r--src/corelib/io/qbuffer.h4
-rw-r--r--src/corelib/io/qdatastream.h5
-rw-r--r--src/corelib/io/qdebug.cpp27
-rw-r--r--src/corelib/io/qdebug.h25
-rw-r--r--src/corelib/io/qdir.cpp12
-rw-r--r--src/corelib/io/qdir.h16
-rw-r--r--src/corelib/io/qfile.h2
-rw-r--r--src/corelib/io/qfiledevice.cpp2
-rw-r--r--src/corelib/io/qfiledevice.h2
-rw-r--r--src/corelib/io/qfileinfo.h5
-rw-r--r--src/corelib/io/qfileselector.h2
-rw-r--r--src/corelib/io/qfilesystemwatcher.h4
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents.mm31
-rw-r--r--src/corelib/io/qiodevice.cpp53
-rw-r--r--src/corelib/io/qiodevice.h2
-rw-r--r--src/corelib/io/qprocess.cpp77
-rw-r--r--src/corelib/io/qprocess.h20
-rw-r--r--src/corelib/io/qprocess_p.h2
-rw-r--r--src/corelib/io/qprocess_unix.cpp42
-rw-r--r--src/corelib/io/qprocess_win.cpp44
-rw-r--r--src/corelib/io/qprocess_wince.cpp9
-rw-r--r--src/corelib/io/qresource.cpp2
-rw-r--r--src/corelib/io/qsavefile.h2
-rw-r--r--src/corelib/io/qsettings.cpp26
-rw-r--r--src/corelib/io/qsettings.h10
-rw-r--r--src/corelib/io/qsettings_mac.cpp9
-rw-r--r--src/corelib/io/qsettings_p.h2
-rw-r--r--src/corelib/io/qstandardpaths.cpp8
-rw-r--r--src/corelib/io/qstorageinfo.h5
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp9
-rw-r--r--src/corelib/io/qtemporaryfile.cpp4
-rw-r--r--src/corelib/io/qtemporaryfile_p.h2
-rw-r--r--src/corelib/io/qtldurl.cpp1
-rw-r--r--src/corelib/io/qurlquery.cpp22
-rw-r--r--src/corelib/io/qurlquery.h8
-rw-r--r--src/corelib/io/qwindowspipereader.cpp6
-rw-r--r--src/corelib/io/qwindowspipereader_p.h2
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp6
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h16
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel_p.h2
-rw-r--r--src/corelib/itemmodels/qabstractproxymodel.cpp1
-rw-r--r--src/corelib/itemmodels/qabstractproxymodel.h2
-rw-r--r--src/corelib/itemmodels/qidentityproxymodel.cpp3
-rw-r--r--src/corelib/itemmodels/qidentityproxymodel.h2
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.h2
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp33
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.h2
-rw-r--r--src/corelib/itemmodels/qstringlistmodel.cpp4
-rw-r--r--src/corelib/itemmodels/qstringlistmodel.h4
-rw-r--r--src/corelib/json/qjsonarray.cpp1
-rw-r--r--src/corelib/json/qjsonarray.h4
-rw-r--r--src/corelib/json/qjsondocument.h2
-rw-r--r--src/corelib/json/qjsonobject.cpp2
-rw-r--r--src/corelib/json/qjsonobject.h4
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.h4
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm17
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp1
-rw-r--r--src/corelib/kernel/qcoreapplication.h8
-rw-r--r--src/corelib/kernel/qcoreevent.cpp2
-rw-r--r--src/corelib/kernel/qcoreevent.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib.cpp1
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp4
-rw-r--r--src/corelib/kernel/qeventloop.h2
-rw-r--r--src/corelib/kernel/qjni.cpp10
-rw-r--r--src/corelib/kernel/qjni_p.h8
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp39
-rw-r--r--src/corelib/kernel/qjnihelpers_p.h13
-rw-r--r--src/corelib/kernel/qmath.h10
-rw-r--r--src/corelib/kernel/qmetaobject.cpp1
-rw-r--r--src/corelib/kernel/qmetaobject.h36
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder.cpp20
-rw-r--r--src/corelib/kernel/qmetatype.h86
-rw-r--r--src/corelib/kernel/qmimedata.cpp4
-rw-r--r--src/corelib/kernel/qobject.cpp11
-rw-r--r--src/corelib/kernel/qobject.h46
-rw-r--r--src/corelib/kernel/qobject_impl.h10
-rw-r--r--src/corelib/kernel/qobject_p.h4
-rw-r--r--src/corelib/kernel/qobjectdefs.h24
-rw-r--r--src/corelib/kernel/qpointer.cpp8
-rw-r--r--src/corelib/kernel/qpointer.h5
-rw-r--r--src/corelib/kernel/qsharedmemory.h4
-rw-r--r--src/corelib/kernel/qsignalmapper.h2
-rw-r--r--src/corelib/kernel/qsocketnotifier.h2
-rw-r--r--src/corelib/kernel/qsystemerror.cpp2
-rw-r--r--src/corelib/kernel/qsystemerror_p.h10
-rw-r--r--src/corelib/kernel/qsystemsemaphore_win.cpp2
-rw-r--r--src/corelib/kernel/qtimer.h2
-rw-r--r--src/corelib/kernel/qtranslator.cpp1
-rw-r--r--src/corelib/kernel/qtranslator.h4
-rw-r--r--src/corelib/kernel/qvariant.h16
-rw-r--r--src/corelib/mimetypes/qmimedatabase.cpp1
-rw-r--r--src/corelib/mimetypes/qmimedatabase_p.h1
-rw-r--r--src/corelib/mimetypes/qmimeprovider.cpp1
-rw-r--r--src/corelib/mimetypes/qmimetype.cpp13
-rw-r--r--src/corelib/mimetypes/qmimetype.h12
-rw-r--r--src/corelib/plugin/plugin.pri1
-rw-r--r--src/corelib/plugin/qfactoryinterface.cpp (renamed from src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm)13
-rw-r--r--src/corelib/plugin/qfactoryinterface.h2
-rw-r--r--src/corelib/plugin/qlibrary.h8
-rw-r--r--src/corelib/plugin/qpluginloader.cpp30
-rw-r--r--src/corelib/plugin/qpluginloader.h4
-rw-r--r--src/corelib/statemachine/qabstractstate.h2
-rw-r--r--src/corelib/statemachine/qabstracttransition.cpp2
-rw-r--r--src/corelib/statemachine/qabstracttransition.h2
-rw-r--r--src/corelib/statemachine/qabstracttransition_p.h3
-rw-r--r--src/corelib/statemachine/qeventtransition.cpp4
-rw-r--r--src/corelib/statemachine/qeventtransition.h4
-rw-r--r--src/corelib/statemachine/qeventtransition_p.h1
-rw-r--r--src/corelib/statemachine/qfinalstate.h2
-rw-r--r--src/corelib/statemachine/qhistorystate.h4
-rw-r--r--src/corelib/statemachine/qsignaltransition.h4
-rw-r--r--src/corelib/statemachine/qstate.cpp2
-rw-r--r--src/corelib/statemachine/qstate.h4
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp40
-rw-r--r--src/corelib/statemachine/qstatemachine.h4
-rw-r--r--src/corelib/thread/qexception.cpp20
-rw-r--r--src/corelib/thread/qexception.h16
-rw-r--r--src/corelib/thread/qfutureinterface.h2
-rw-r--r--src/corelib/thread/qfuturewatcher.h4
-rw-r--r--src/corelib/thread/qmutex.h8
-rw-r--r--src/corelib/thread/qmutex_win.cpp6
-rw-r--r--src/corelib/thread/qresultstore.h4
-rw-r--r--src/corelib/thread/qrunnable.cpp11
-rw-r--r--src/corelib/thread/qrunnable.h9
-rw-r--r--src/corelib/thread/qthread.cpp1
-rw-r--r--src/corelib/thread/qthread.h4
-rw-r--r--src/corelib/thread/qthreadpool.h2
-rw-r--r--src/corelib/thread/qwaitcondition_win.cpp6
-rwxr-xr-x[-rw-r--r--]src/corelib/tools/qalgorithms.h125
-rwxr-xr-x[-rw-r--r--]src/corelib/tools/qalgorithms.qdoc70
-rw-r--r--src/corelib/tools/qarraydata.h4
-rw-r--r--src/corelib/tools/qbytearray.cpp16
-rw-r--r--src/corelib/tools/qbytearray.h23
-rw-r--r--src/corelib/tools/qbytearray_p.h61
-rw-r--r--src/corelib/tools/qbytearraylist.h2
-rw-r--r--src/corelib/tools/qchar.cpp60
-rw-r--r--src/corelib/tools/qchar.h269
-rw-r--r--src/corelib/tools/qcollator.h2
-rw-r--r--src/corelib/tools/qcommandlineoption.cpp109
-rw-r--r--src/corelib/tools/qcommandlineoption.h8
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp49
-rw-r--r--src/corelib/tools/qcommandlineparser.h6
-rw-r--r--src/corelib/tools/qdatetime.h7
-rw-r--r--src/corelib/tools/qeasingcurve.cpp1
-rw-r--r--src/corelib/tools/qeasingcurve.h2
-rw-r--r--src/corelib/tools/qharfbuzz.cpp3
-rw-r--r--src/corelib/tools/qhash.h131
-rw-r--r--src/corelib/tools/qhashfunctions.h156
-rw-r--r--src/corelib/tools/qlist.cpp161
-rw-r--r--src/corelib/tools/qlist.h56
-rw-r--r--src/corelib/tools/qlocale.cpp18
-rw-r--r--src/corelib/tools/qlocale.h39
-rw-r--r--src/corelib/tools/qlocale_mac.mm14
-rw-r--r--src/corelib/tools/qmap.cpp6
-rw-r--r--src/corelib/tools/qmap.h110
-rw-r--r--src/corelib/tools/qregexp.cpp30
-rw-r--r--src/corelib/tools/qregexp.h5
-rw-r--r--src/corelib/tools/qregularexpression.cpp19
-rw-r--r--src/corelib/tools/qregularexpression.h4
-rw-r--r--src/corelib/tools/qringbuffer.cpp310
-rw-r--r--src/corelib/tools/qringbuffer_p.h246
-rw-r--r--src/corelib/tools/qset.h30
-rw-r--r--src/corelib/tools/qset.qdoc12
-rw-r--r--src/corelib/tools/qshareddata.h3
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h10
-rw-r--r--src/corelib/tools/qsimd.cpp4
-rw-r--r--src/corelib/tools/qstring.cpp281
-rw-r--r--src/corelib/tools/qstring.h92
-rw-r--r--src/corelib/tools/qtextboundaryfinder.h2
-rw-r--r--src/corelib/tools/qtimeline.h2
-rw-r--r--src/corelib/tools/qtimezone.cpp1
-rw-r--r--src/corelib/tools/qtimezoneprivate.cpp1
-rw-r--r--src/corelib/tools/qtimezoneprivate_tz.cpp1
-rw-r--r--src/corelib/tools/qvarlengtharray.h39
-rw-r--r--src/corelib/tools/qvarlengtharray.qdoc108
-rw-r--r--src/corelib/tools/qvector.cpp169
-rw-r--r--src/corelib/tools/qvector.h69
-rw-r--r--src/corelib/tools/tools.pri3
-rw-r--r--src/dbus/qdbus_symbols.cpp10
-rw-r--r--src/dbus/qdbusabstractadaptor.cpp4
-rw-r--r--src/dbus/qdbusabstractadaptor_p.h1
-rw-r--r--src/dbus/qdbusextratypes.h3
-rw-r--r--src/dbus/qdbusintegrator.cpp14
-rw-r--r--src/dbus/qdbusintegrator_p.h1
-rw-r--r--src/dbus/qdbusinterface.cpp1
-rw-r--r--src/dbus/qdbusmacros.h2
-rw-r--r--src/dbus/qdbusmessage.cpp30
-rw-r--r--src/dbus/qdbusmessage.h2
-rw-r--r--src/dbus/qdbuspendingcall.h5
-rw-r--r--src/dbus/qdbusunixfiledescriptor.h10
-rw-r--r--src/gui/accessible/qaccessible.cpp126
-rw-r--r--src/gui/accessible/qaccessible.h38
-rw-r--r--src/gui/image/qicon.cpp4
-rw-r--r--src/gui/image/qiconloader.cpp1
-rw-r--r--src/gui/image/qimage.cpp117
-rw-r--r--src/gui/image/qimage.h13
-rw-r--r--src/gui/image/qimagereader.cpp33
-rw-r--r--src/gui/image/qimagereader.h3
-rw-r--r--src/gui/image/qpaintengine_pic.cpp1
-rw-r--r--src/gui/image/qpicture.cpp4
-rw-r--r--src/gui/image/qpicture_p.h5
-rw-r--r--src/gui/image/qpixmapcache.cpp38
-rw-r--r--src/gui/image/qpixmapcache.h11
-rw-r--r--src/gui/image/qpnghandler.cpp22
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.cpp82
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.h16
-rw-r--r--src/gui/kernel/qdnd.cpp8
-rw-r--r--src/gui/kernel/qevent.cpp35
-rw-r--r--src/gui/kernel/qevent.h5
-rw-r--r--src/gui/kernel/qguiapplication.cpp21
-rw-r--r--src/gui/kernel/qkeymapper_p.h1
-rw-r--r--src/gui/kernel/qkeysequence.cpp29
-rw-r--r--src/gui/kernel/qkeysequence.h12
-rw-r--r--src/gui/kernel/qopenglcontext.cpp10
-rw-r--r--src/gui/kernel/qopenglcontext.h3
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp1
-rw-r--r--src/gui/kernel/qplatformintegrationfactory.cpp7
-rw-r--r--src/gui/kernel/qplatformthemefactory.cpp4
-rw-r--r--src/gui/kernel/qscreen.cpp39
-rw-r--r--src/gui/kernel/qscreen.h7
-rw-r--r--src/gui/kernel/qtouchdevice.cpp14
-rw-r--r--src/gui/kernel/qtouchdevice_p.h5
-rw-r--r--src/gui/kernel/qwindow.cpp39
-rw-r--r--src/gui/kernel/qwindow.h7
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp118
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h2
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h15
-rw-r--r--src/gui/opengl/qopengl.cpp120
-rw-r--r--src/gui/opengl/qopengl_p.h10
-rw-r--r--src/gui/opengl/qopengldebug.h8
-rw-r--r--src/gui/opengl/qopenglextensions_p.h6
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp16
-rw-r--r--src/gui/opengl/qopenglgradientcache.cpp78
-rw-r--r--src/gui/opengl/qopenglgradientcache_p.h4
-rw-r--r--src/gui/opengl/qopenglpaintdevice.cpp4
-rw-r--r--src/gui/opengl/qopenglpaintdevice_p.h2
-rw-r--r--src/gui/opengl/qopenglpixeltransferoptions.h9
-rw-r--r--src/gui/opengl/qopenglversionfunctions.h3
-rw-r--r--src/gui/painting/painting.pri3
-rw-r--r--src/gui/painting/qbrush.cpp1
-rw-r--r--src/gui/painting/qcolor.cpp88
-rw-r--r--src/gui/painting/qcolor.h8
-rw-r--r--src/gui/painting/qcompositionfunctions.cpp2197
-rw-r--r--src/gui/painting/qcosmeticstroker.cpp3
-rw-r--r--src/gui/painting/qdrawhelper.cpp3546
-rw-r--r--src/gui/painting/qdrawhelper_neon.cpp7
-rw-r--r--src/gui/painting/qdrawhelper_neon_p.h2
-rw-r--r--src/gui/painting/qdrawhelper_p.h214
-rw-r--r--src/gui/painting/qdrawhelper_sse2.cpp103
-rw-r--r--src/gui/painting/qdrawhelper_x86_p.h6
-rw-r--r--src/gui/painting/qimagescale.cpp152
-rw-r--r--src/gui/painting/qimagescale_sse4.cpp42
-rw-r--r--src/gui/painting/qmatrix.cpp24
-rw-r--r--src/gui/painting/qmatrix.h2
-rw-r--r--src/gui/painting/qpagedpaintdevice.cpp4
-rw-r--r--src/gui/painting/qpagedpaintdevice_p.h4
-rw-r--r--src/gui/painting/qpagelayout.h11
-rw-r--r--src/gui/painting/qpagesize.h10
-rw-r--r--src/gui/painting/qpaintengine.cpp4
-rw-r--r--src/gui/painting/qpaintengine_p.h3
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp108
-rw-r--r--src/gui/painting/qpainter.cpp5
-rw-r--r--src/gui/painting/qpainter_p.h1
-rw-r--r--src/gui/painting/qpathclipper.cpp6
-rw-r--r--src/gui/painting/qpdf.cpp4
-rw-r--r--src/gui/painting/qpdf_p.h2
-rw-r--r--src/gui/painting/qpen.cpp1
-rw-r--r--src/gui/painting/qplatformbackingstore.cpp4
-rw-r--r--src/gui/painting/qpolygon.h10
-rw-r--r--src/gui/painting/qrgba64.h208
-rw-r--r--src/gui/painting/qrgba64.qdoc241
-rw-r--r--src/gui/painting/qrgba64_p.h120
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp29
-rw-r--r--src/gui/painting/qtextureglyphcache_p.h4
-rw-r--r--src/gui/painting/qtransform.cpp28
-rw-r--r--src/gui/painting/qtransform.h2
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.cpp9
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.h2
-rw-r--r--src/gui/text/qabstracttextdocumentlayout_p.h3
-rw-r--r--src/gui/text/qcssparser.cpp1
-rw-r--r--src/gui/text/qfont.cpp7
-rw-r--r--src/gui/text/qfontdatabase.cpp24
-rw-r--r--src/gui/text/qfontengineglyphcache.cpp (renamed from src/plugins/platforms/cocoa/qcocoaautoreleasepool.h)22
-rw-r--r--src/gui/text/qfontengineglyphcache_p.h4
-rw-r--r--src/gui/text/qfontsubset.cpp41
-rw-r--r--src/gui/text/qfontsubset_p.h2
-rw-r--r--src/gui/text/qglyphrun.cpp1
-rw-r--r--src/gui/text/qglyphrun.h8
-rw-r--r--src/gui/text/qplatformfontdatabase.h2
-rw-r--r--src/gui/text/qrawfont.cpp1
-rw-r--r--src/gui/text/qrawfont.h10
-rw-r--r--src/gui/text/qstatictext.cpp5
-rw-r--r--src/gui/text/qstatictext.h7
-rw-r--r--src/gui/text/qstatictext_p.h5
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp8
-rw-r--r--src/gui/text/qtextcursor.h5
-rw-r--r--src/gui/text/qtextdocument.cpp2
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp6
-rw-r--r--src/gui/text/qtextengine.cpp11
-rw-r--r--src/gui/text/qtextengine_p.h8
-rw-r--r--src/gui/text/qtextformat.cpp8
-rw-r--r--src/gui/text/qtextformat_p.h1
-rw-r--r--src/gui/text/qtextlayout.cpp44
-rw-r--r--src/gui/text/qtextlayout.h8
-rw-r--r--src/gui/text/qtextoption.cpp6
-rw-r--r--src/gui/text/qzip.cpp12
-rw-r--r--src/gui/text/qzipreader_p.h2
-rw-r--r--src/gui/text/text.pri2
-rw-r--r--src/network/access/qabstractnetworkcache.h5
-rw-r--r--src/network/access/qftp.cpp1
-rw-r--r--src/network/access/qhttpmultipart.h5
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp55
-rw-r--r--src/network/access/qhttpnetworkconnection_p.h1
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp14
-rw-r--r--src/network/access/qhttpnetworkheader.cpp12
-rw-r--r--src/network/access/qhttpnetworkreply.cpp30
-rw-r--r--src/network/access/qhttpnetworkreply_p.h10
-rw-r--r--src/network/access/qhttpnetworkrequest.cpp24
-rw-r--r--src/network/access/qhttpnetworkrequest_p.h8
-rw-r--r--src/network/access/qhttpthreaddelegate.cpp3
-rw-r--r--src/network/access/qhttpthreaddelegate_p.h2
-rw-r--r--src/network/access/qnetworkaccessauthenticationmanager_p.h2
-rw-r--r--src/network/access/qnetworkaccessbackend.cpp1
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp2
-rw-r--r--src/network/access/qnetworkcookie.h5
-rw-r--r--src/network/access/qnetworkreply.cpp32
-rw-r--r--src/network/access/qnetworkreply.h3
-rw-r--r--src/network/access/qnetworkreply_p.h1
-rw-r--r--src/network/access/qnetworkreplyfileimpl.cpp7
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp193
-rw-r--r--src/network/access/qnetworkreplyhttpimpl_p.h13
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp15
-rw-r--r--src/network/access/qnetworkrequest.cpp45
-rw-r--r--src/network/access/qnetworkrequest.h10
-rw-r--r--src/network/access/qspdyprotocolhandler.cpp19
-rw-r--r--src/network/bearer/qnetworkconfiguration.h5
-rw-r--r--src/network/kernel/qdnslookup.h40
-rw-r--r--src/network/kernel/qhostaddress.h7
-rw-r--r--src/network/kernel/qnetworkinterface.cpp2
-rw-r--r--src/network/kernel/qnetworkinterface.h10
-rw-r--r--src/network/kernel/qnetworkproxy.cpp1
-rw-r--r--src/network/kernel/qnetworkproxy.h14
-rw-r--r--src/network/socket/qabstractsocket.cpp17
-rw-r--r--src/network/socket/qabstractsocket_p.h2
-rw-r--r--src/network/socket/qnet_unix_p.h26
-rw-r--r--src/network/socket/qtcpserver.cpp38
-rw-r--r--src/network/socket/qtcpserver_p.h2
-rw-r--r--src/network/socket/qtcpsocket.cpp9
-rw-r--r--src/network/socket/qtcpsocket.h2
-rw-r--r--src/network/ssl/qssl.cpp4
-rw-r--r--src/network/ssl/qssl.h3
-rw-r--r--src/network/ssl/qsslcertificate.h5
-rw-r--r--src/network/ssl/qsslcertificate_openssl.cpp3
-rw-r--r--src/network/ssl/qsslcertificateextension.h8
-rw-r--r--src/network/ssl/qsslcipher.h7
-rw-r--r--src/network/ssl/qsslconfiguration.h5
-rw-r--r--src/network/ssl/qsslellipticcurve.h3
-rw-r--r--src/network/ssl/qsslerror.h5
-rw-r--r--src/network/ssl/qsslkey.h7
-rw-r--r--src/network/ssl/qsslpresharedkeyauthenticator.h8
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp44
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp7
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols_p.h16
-rw-r--r--src/opengl/gl2paintengineex/qglcustomshaderstage.cpp1
-rw-r--r--src/opengl/qgl_p.h2
-rw-r--r--src/platformheaders/cocoafunctions/cocoafunctions.pri1
-rw-r--r--src/platformheaders/cocoafunctions/qcocoawindowfunctions.h57
-rw-r--r--src/platformheaders/cocoafunctions/qcocoawindowfunctions.qdoc58
-rw-r--r--src/platformheaders/helper/helper.pri2
-rw-r--r--src/platformheaders/helper/qplatformheaderhelper.h87
-rw-r--r--src/platformheaders/platformheaders.pro2
-rw-r--r--src/platformheaders/xcbfunctions/qxcbintegrationfunctions.h (renamed from src/plugins/platforms/xcb/qxlibconvenience.cpp)35
-rw-r--r--src/platformheaders/xcbfunctions/qxcbwindowfunctions.h36
-rw-r--r--src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc133
-rw-r--r--src/platformheaders/xcbfunctions/xcbfunctions.pri4
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenutypes.cpp1
-rw-r--r--src/platformsupport/dbustray/qdbustraytypes.cpp2
-rw-r--r--src/platformsupport/fbconvenience/qfbscreen.cpp5
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm14
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp10
-rw-r--r--src/platformsupport/linuxaccessibility/atspiadaptor.cpp8
-rw-r--r--src/platformsupport/linuxaccessibility/dbusconnection.cpp26
-rw-r--r--src/platformsupport/linuxaccessibility/dbusconnection_p.h1
-rw-r--r--src/plugins/bearer/connman/main.cpp2
-rw-r--r--src/plugins/bearer/connman/qconnmanengine.cpp6
-rw-r--r--src/plugins/bearer/connman/qconnmanengine.h2
-rw-r--r--src/plugins/bearer/connman/qconnmanservice_linux.cpp3
-rw-r--r--src/plugins/bearer/connman/qconnmanservice_linux_p.h2
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.mm30
-rw-r--r--src/plugins/bearer/generic/main.cpp4
-rw-r--r--src/plugins/bearer/generic/qgenericengine.cpp4
-rw-r--r--src/plugins/bearer/generic/qgenericengine.h4
-rw-r--r--src/plugins/bearer/linux_common/qofonoservice_linux.cpp2
-rw-r--r--src/plugins/bearer/linux_common/qofonoservice_linux_p.h2
-rw-r--r--src/plugins/bearer/networkmanager/main.cpp2
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp2
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.h2
-rw-r--r--src/plugins/bearer/qbearerengine_impl.h4
-rw-r--r--src/plugins/bearer/qnetworksession_impl.cpp4
-rw-r--r--src/plugins/bearer/qnetworksession_impl.h4
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler.cpp1
-rw-r--r--src/plugins/imageformats/gif/main.cpp4
-rw-r--r--src/plugins/imageformats/gif/main.h4
-rw-r--r--src/plugins/imageformats/ico/main.cpp4
-rw-r--r--src/plugins/imageformats/ico/main.h4
-rw-r--r--src/plugins/imageformats/ico/qicohandler.cpp16
-rw-r--r--src/plugins/imageformats/jpeg/main.cpp4
-rw-r--r--src/plugins/imageformats/jpeg/main.h4
-rw-r--r--src/plugins/platforminputcontexts/compose/compose.pro2
-rw-r--r--src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp235
-rw-r--r--src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h4
-rw-r--r--src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp2
-rw-r--r--src/plugins/platforminputcontexts/ibus/qibustypes.cpp6
-rw-r--r--src/plugins/platforms/android/androidjniinput.cpp47
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp5
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro2
-rw-r--r--src/plugins/platforms/cocoa/main.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm5
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.mm1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm12
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm7
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm5
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoainputcontext.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm7
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm19
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm27
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.mm5
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm12
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemsettings.mm3
-rw-r--r--[-rwxr-xr-x]src/plugins/platforms/cocoa/qcocoasystemtrayicon.h0
-rw-r--r--[-rwxr-xr-x]src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm0
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h6
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm61
-rw-r--r--src/plugins/platforms/cocoa/qmacclipboard.mm3
-rw-r--r--src/plugins/platforms/cocoa/qmultitouch_mac.mm2
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm11
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac.mm3
-rw-r--r--src/plugins/platforms/cocoa/qt_mac_p.h11
-rw-r--r--src/plugins/platforms/directfb/qdirectfbconvenience.cpp2
-rw-r--r--[-rwxr-xr-x]src/plugins/platforms/eglfs/cursor-atlas.pngbin2236 -> 2236 bytes
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp1
-rw-r--r--src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp4
-rw-r--r--src/plugins/platforms/haiku/qhaikuclipboard.cpp45
-rw-r--r--src/plugins/platforms/haiku/qhaikuclipboard.h4
-rw-r--r--src/plugins/platforms/haiku/qhaikuwindow.cpp17
-rw-r--r--src/plugins/platforms/ios/qiosapplicationstate.mm12
-rw-r--r--src/plugins/platforms/ios/qiosclipboard.mm4
-rw-r--r--src/plugins/platforms/ios/qioseventdispatcher.mm23
-rw-r--r--src/plugins/platforms/ios/qiosglobal.h2
-rw-r--r--src/plugins/platforms/ios/qiosglobal.mm4
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm2
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm4
-rw-r--r--src/plugins/platforms/ios/qiosmenu.mm4
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm8
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm49
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.mm6
-rw-r--r--src/plugins/platforms/ios/quiaccessibilityelement.h4
-rw-r--r--src/plugins/platforms/ios/quiaccessibilityelement.mm26
-rw-r--r--src/plugins/platforms/ios/quiview.mm4
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp1
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.cpp10
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp4
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp12
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp21
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.cpp10
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp1
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp12
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp119
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h7
-rw-r--r--src/plugins/platforms/xcb/qxcbsessionmanager.cpp1
-rw-r--r--src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp45
-rw-r--r--src/plugins/platforms/xcb/qxcbsystemtraytracker.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp67
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h11
-rw-r--r--src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h5
-rw-r--r--src/plugins/plugins.pro13
-rw-r--r--src/plugins/printsupport/cocoa/main.cpp4
-rw-r--r--src/plugins/printsupport/cups/main.cpp4
-rw-r--r--src/plugins/printsupport/cups/qcupsprintengine.cpp8
-rw-r--r--src/plugins/printsupport/cups/qcupsprintengine_p.h4
-rw-r--r--src/plugins/printsupport/cups/qcupsprintersupport.cpp5
-rw-r--r--src/plugins/printsupport/cups/qcupsprintersupport_p.h3
-rw-r--r--src/plugins/printsupport/cups/qppdprintdevice.cpp7
-rw-r--r--src/plugins/printsupport/cups/qppdprintdevice.h5
-rw-r--r--src/plugins/printsupport/printsupport.pro5
-rw-r--r--src/plugins/printsupport/windows/qwindowsprintdevice.cpp4
-rw-r--r--src/plugins/printsupport/windows/qwindowsprintdevice.h3
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/button/core_button_inactive.pngbin2428 -> 2428 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/button/core_button_pressed.pngbin3221 -> 3221 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.pngbin2776 -> 2776 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.pngbin1315 -> 1315 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.pngbin394 -> 394 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/listitem/core_listitem_active.pngbin164 -> 164 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.pngbin135 -> 135 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.pngbin1802 -> 1802 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.pngbin4245 -> 4245 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.pngbin5460 -> 5460 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.pngbin1242 -> 1242 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.pngbin6577 -> 6577 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/button/core_button_inactive.pngbin2262 -> 2262 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/button/core_button_pressed.pngbin2853 -> 2853 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.pngbin2478 -> 2478 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.pngbin1315 -> 1315 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.pngbin394 -> 394 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/listitem/core_listitem_active.pngbin164 -> 164 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.pngbin136 -> 136 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.pngbin1724 -> 1724 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.pngbin3968 -> 3968 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.pngbin4777 -> 4777 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.pngbin1245 -> 1245 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.pngbin6593 -> 6593 bytes
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_mac.mm3
-rw-r--r--src/printsupport/dialogs/qprintdialog_mac.mm4
-rw-r--r--src/printsupport/kernel/qcups.cpp16
-rw-r--r--src/printsupport/kernel/qcups_p.h1
-rw-r--r--src/printsupport/kernel/qpaintengine_alpha.cpp3
-rw-r--r--src/printsupport/kernel/qplatformprintplugin.cpp4
-rw-r--r--src/printsupport/kernel/qprinter.cpp6
-rw-r--r--src/printsupport/kernel/qprinterinfo.cpp16
-rw-r--r--src/printsupport/widgets/qcupsjobwidget.cpp4
-rw-r--r--src/printsupport/widgets/qcupsjobwidget_p.h4
-rw-r--r--src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase.cpp2
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.cpp97
-rw-r--r--src/sql/kernel/qsqldatabase.cpp6
-rw-r--r--src/sql/kernel/qsqlindex.cpp3
-rw-r--r--src/sql/kernel/qsqlindex.h5
-rw-r--r--src/src.pro2
-rw-r--r--src/testlib/qbenchmark_p.h2
-rw-r--r--src/testlib/qtestblacklist.cpp94
-rw-r--r--src/testlib/qtestblacklist_p.h7
-rw-r--r--src/testlib/qtestcase.cpp112
-rw-r--r--src/testlib/qtestcase.h21
-rw-r--r--src/testlib/qtestmouse.cpp (renamed from src/plugins/platforms/xcb/qxlibconvenience.h)20
-rw-r--r--src/testlib/qtestmouse.h78
-rw-r--r--src/testlib/testlib.pro1
-rw-r--r--src/tools/bootstrap/bootstrap.pro1
-rw-r--r--src/tools/qdoc/atom.cpp24
-rw-r--r--src/tools/qdoc/atom.h26
-rw-r--r--src/tools/qdoc/codemarker.cpp7
-rw-r--r--src/tools/qdoc/codemarker.h12
-rw-r--r--src/tools/qdoc/codeparser.cpp27
-rw-r--r--src/tools/qdoc/config.cpp10
-rw-r--r--src/tools/qdoc/cppcodemarker.cpp26
-rw-r--r--src/tools/qdoc/cppcodemarker.h4
-rw-r--r--src/tools/qdoc/cppcodeparser.cpp134
-rw-r--r--src/tools/qdoc/cppcodeparser.h35
-rw-r--r--src/tools/qdoc/doc.cpp59
-rw-r--r--src/tools/qdoc/doc/qdoc-manual-cmdindex.qdoc1
-rw-r--r--src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc73
-rw-r--r--src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc14
-rw-r--r--src/tools/qdoc/generator.cpp222
-rw-r--r--src/tools/qdoc/generator.h19
-rw-r--r--src/tools/qdoc/helpprojectwriter.cpp76
-rw-r--r--src/tools/qdoc/helpprojectwriter.h4
-rw-r--r--src/tools/qdoc/htmlgenerator.cpp128
-rw-r--r--src/tools/qdoc/htmlgenerator.h19
-rw-r--r--src/tools/qdoc/jscodemarker.cpp6
-rw-r--r--src/tools/qdoc/jscodemarker.h2
-rw-r--r--src/tools/qdoc/location.cpp21
-rw-r--r--src/tools/qdoc/location.h4
-rw-r--r--src/tools/qdoc/main.cpp7
-rw-r--r--src/tools/qdoc/node.cpp624
-rw-r--r--src/tools/qdoc/node.h375
-rw-r--r--src/tools/qdoc/plaincodemarker.cpp4
-rw-r--r--src/tools/qdoc/plaincodemarker.h4
-rw-r--r--src/tools/qdoc/puredocparser.cpp8
-rw-r--r--src/tools/qdoc/qdocdatabase.cpp53
-rw-r--r--src/tools/qdoc/qdocdatabase.h30
-rw-r--r--src/tools/qdoc/qdocindexfiles.cpp75
-rw-r--r--src/tools/qdoc/qdoctagfiles.cpp14
-rw-r--r--src/tools/qdoc/qdoctagfiles.h6
-rw-r--r--src/tools/qdoc/qmlcodemarker.cpp8
-rw-r--r--src/tools/qdoc/qmlcodemarker.h4
-rw-r--r--src/tools/qdoc/qmlcodeparser.cpp2
-rw-r--r--src/tools/qdoc/qmlmarkupvisitor.cpp15
-rw-r--r--src/tools/qdoc/qmlmarkupvisitor.h4
-rw-r--r--src/tools/qdoc/qmlparser/qqmljsastfwd_p.h45
-rw-r--r--src/tools/qdoc/qmlparser/qqmljsengine_p.cpp3
-rw-r--r--src/tools/qdoc/qmlparser/qqmljsengine_p.h6
-rw-r--r--src/tools/qdoc/qmlvisitor.cpp17
-rw-r--r--src/tools/qdoc/qmlvisitor.h2
-rw-r--r--src/tools/qdoc/text.cpp4
-rw-r--r--src/tools/qdoc/text.h4
-rw-r--r--src/tools/qdoc/tree.cpp73
-rw-r--r--src/tools/qdoc/tree.h18
-rw-r--r--src/tools/uic/cpp/cppwriteincludes.h1
-rw-r--r--src/tools/uic/uic.h1
-rw-r--r--src/widgets/accessible/itemviews.cpp19
-rw-r--r--src/widgets/accessible/qaccessiblewidgets.cpp3
-rw-r--r--src/widgets/dialogs/dialogs.pri1
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp132
-rw-r--r--src/widgets/dialogs/qcolordialog.h1
-rw-r--r--src/widgets/dialogs/qcolordialog_p.h179
-rw-r--r--src/widgets/dialogs/qerrormessage.cpp81
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp38
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp18
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp1
-rw-r--r--src/widgets/dialogs/qinputdialog.cpp1
-rw-r--r--src/widgets/dialogs/qsidebar.cpp16
-rw-r--r--src/widgets/dialogs/qwizard.cpp1
-rw-r--r--[-rwxr-xr-x]src/widgets/doc/images/listview.pngbin9695 -> 9695 bytes
-rw-r--r--[-rwxr-xr-x]src/widgets/doc/images/modelview-combobox.pngbin5022 -> 5022 bytes
-rw-r--r--[-rwxr-xr-x]src/widgets/doc/images/tableview.pngbin10102 -> 10102 bytes
-rw-r--r--[-rwxr-xr-x]src/widgets/doc/snippets/macmainwindow.mm0
-rw-r--r--src/widgets/effects/qgraphicseffect.cpp4
-rw-r--r--src/widgets/effects/qgraphicseffect_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp6
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsitemanimation.cpp62
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp3
-rw-r--r--src/widgets/graphicsview/qgraphicssceneevent.h2
-rw-r--r--src/widgets/graphicsview/qgraphicssceneindex.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicstransform.cpp5
-rw-r--r--src/widgets/graphicsview/qgraphicstransform_p.h4
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp10
-rw-r--r--src/widgets/graphicsview/qgraphicsview_p.h1
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp9
-rw-r--r--src/widgets/itemviews/qcolumnview.cpp12
-rw-r--r--src/widgets/itemviews/qdatawidgetmapper.cpp2
-rw-r--r--src/widgets/itemviews/qfileiconprovider.cpp1
-rw-r--r--src/widgets/itemviews/qlistview.cpp31
-rw-r--r--src/widgets/itemviews/qlistview.h3
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp22
-rw-r--r--src/widgets/itemviews/qtableview.cpp4
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp25
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp16
-rw-r--r--src/widgets/kernel/qapplication.cpp5
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp13
-rw-r--r--src/widgets/kernel/qlayout.cpp3
-rw-r--r--src/widgets/kernel/qsizepolicy.cpp9
-rw-r--r--src/widgets/kernel/qsizepolicy.h6
-rw-r--r--src/widgets/kernel/qtooltip.cpp1
-rw-r--r--src/widgets/kernel/qwhatsthis.cpp1
-rw-r--r--src/widgets/kernel/qwidget.cpp96
-rw-r--r--src/widgets/kernel/qwidget.h9
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp17
-rw-r--r--src/widgets/styles/qfusionstyle.cpp1
-rw-r--r--src/widgets/styles/qgtk2painter.cpp2
-rw-r--r--src/widgets/styles/qgtkstyle_p.cpp4
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm33
-rw-r--r--src/widgets/styles/qmacstyle_mac_p_p.h4
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp7
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp2
-rw-r--r--src/widgets/styles/qwindowsstyle_p_p.h1
-rw-r--r--src/widgets/util/qflickgesture.cpp14
-rw-r--r--src/widgets/util/qscroller_mac.mm3
-rw-r--r--src/widgets/util/qsystemtrayicon_x11.cpp32
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp13
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp6
-rw-r--r--src/widgets/widgets/qabstractscrollarea_p.h3
-rw-r--r--src/widgets/widgets/qcombobox.cpp1
-rw-r--r--src/widgets/widgets/qcombobox_p.h1
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp106
-rw-r--r--src/widgets/widgets/qdockarealayout_p.h7
-rw-r--r--src/widgets/widgets/qdockwidget.cpp153
-rw-r--r--src/widgets/widgets/qdockwidget_p.h3
-rw-r--r--src/widgets/widgets/qframe.cpp6
-rw-r--r--src/widgets/widgets/qframe_p.h4
-rw-r--r--src/widgets/widgets/qlabel.cpp4
-rw-r--r--src/widgets/widgets/qlabel_p.h1
-rw-r--r--src/widgets/widgets/qmainwindow.cpp9
-rw-r--r--src/widgets/widgets/qmainwindow.h3
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp529
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h25
-rw-r--r--src/widgets/widgets/qmdiarea_p.h4
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp4
-rw-r--r--src/widgets/widgets/qmenu.cpp97
-rw-r--r--src/widgets/widgets/qmenu.h66
-rw-r--r--src/widgets/widgets/qmenubar.cpp4
-rw-r--r--src/widgets/widgets/qsplitter.cpp13
-rw-r--r--src/widgets/widgets/qsplitter_p.h1
-rw-r--r--src/widgets/widgets/qtoolbar.cpp76
-rw-r--r--src/widgets/widgets/qtoolbar.h46
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp7
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp21
719 files changed, 14372 insertions, 6557 deletions
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-private.hh b/src/3rdparty/harfbuzz-ng/src/hb-private.hh
index 06b24a80f8..06d7f228a7 100644
--- a/src/3rdparty/harfbuzz-ng/src/hb-private.hh
+++ b/src/3rdparty/harfbuzz-ng/src/hb-private.hh
@@ -121,16 +121,17 @@
# if defined(_WIN32_WCE)
/* Some things not defined on Windows CE. */
+# define strdup _strdup
# define getenv(Name) NULL
-# define setlocale(Category, Locale) "C"
+# if _WIN32_WCE < 0x800
+# define setlocale(Category, Locale) "C"
static int errno = 0; /* Use something better? */
+# endif
# elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP)
# define getenv(Name) NULL
# endif
-# if (defined(__WIN32__) && !defined(__WINE__)) || defined(_MSC_VER)
+# if defined(_MSC_VER) && _MSC_VER < 1900
# define snprintf _snprintf
- /* Windows CE only has _strdup, while rest of Windows has both. */
-# define strdup _strdup
# endif
#endif
diff --git a/src/3rdparty/sha3/KeccakF-1600-32-rvk.macros b/src/3rdparty/sha3/KeccakF-1600-32-rvk.macros
index c0c9029873..c0c9029873 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-32-rvk.macros
+++ b/src/3rdparty/sha3/KeccakF-1600-32-rvk.macros
diff --git a/src/3rdparty/sha3/KeccakF-1600-32.macros b/src/3rdparty/sha3/KeccakF-1600-32.macros
index 9ade600067..9ade600067 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-32.macros
+++ b/src/3rdparty/sha3/KeccakF-1600-32.macros
diff --git a/src/3rdparty/sha3/KeccakF-1600-64.macros b/src/3rdparty/sha3/KeccakF-1600-64.macros
index 0c20bca40f..0c20bca40f 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-64.macros
+++ b/src/3rdparty/sha3/KeccakF-1600-64.macros
diff --git a/src/3rdparty/sha3/KeccakF-1600-int-set.h b/src/3rdparty/sha3/KeccakF-1600-int-set.h
index 0ed1d802e3..0ed1d802e3 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-int-set.h
+++ b/src/3rdparty/sha3/KeccakF-1600-int-set.h
diff --git a/src/3rdparty/sha3/KeccakF-1600-interface.h b/src/3rdparty/sha3/KeccakF-1600-interface.h
index ce2710eeb2..ce2710eeb2 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-interface.h
+++ b/src/3rdparty/sha3/KeccakF-1600-interface.h
diff --git a/src/3rdparty/sha3/KeccakF-1600-opt32-settings.h b/src/3rdparty/sha3/KeccakF-1600-opt32-settings.h
index b135918ca9..b135918ca9 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-opt32-settings.h
+++ b/src/3rdparty/sha3/KeccakF-1600-opt32-settings.h
diff --git a/src/3rdparty/sha3/KeccakF-1600-opt32.c b/src/3rdparty/sha3/KeccakF-1600-opt32.c
index 4e32dca9cb..4e32dca9cb 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-opt32.c
+++ b/src/3rdparty/sha3/KeccakF-1600-opt32.c
diff --git a/src/3rdparty/sha3/KeccakF-1600-opt64-settings.h b/src/3rdparty/sha3/KeccakF-1600-opt64-settings.h
index 8f16ada636..8f16ada636 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-opt64-settings.h
+++ b/src/3rdparty/sha3/KeccakF-1600-opt64-settings.h
diff --git a/src/3rdparty/sha3/KeccakF-1600-unrolling.macros b/src/3rdparty/sha3/KeccakF-1600-unrolling.macros
index 83c694ca48..83c694ca48 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-unrolling.macros
+++ b/src/3rdparty/sha3/KeccakF-1600-unrolling.macros
diff --git a/src/3rdparty/sha3/KeccakNISTInterface.c b/src/3rdparty/sha3/KeccakNISTInterface.c
index e530a11db5..e530a11db5 100755..100644
--- a/src/3rdparty/sha3/KeccakNISTInterface.c
+++ b/src/3rdparty/sha3/KeccakNISTInterface.c
diff --git a/src/3rdparty/sha3/KeccakNISTInterface.h b/src/3rdparty/sha3/KeccakNISTInterface.h
index cd85f24aa7..cd85f24aa7 100755..100644
--- a/src/3rdparty/sha3/KeccakNISTInterface.h
+++ b/src/3rdparty/sha3/KeccakNISTInterface.h
diff --git a/src/3rdparty/sha3/KeccakSponge.c b/src/3rdparty/sha3/KeccakSponge.c
index 6f3da95dbb..6f3da95dbb 100755..100644
--- a/src/3rdparty/sha3/KeccakSponge.c
+++ b/src/3rdparty/sha3/KeccakSponge.c
diff --git a/src/3rdparty/sha3/KeccakSponge.h b/src/3rdparty/sha3/KeccakSponge.h
index 8bb11a8a1d..8bb11a8a1d 100755..100644
--- a/src/3rdparty/sha3/KeccakSponge.h
+++ b/src/3rdparty/sha3/KeccakSponge.h
diff --git a/src/3rdparty/sha3/brg_endian.h b/src/3rdparty/sha3/brg_endian.h
index 7226eb3bec..7226eb3bec 100755..100644
--- a/src/3rdparty/sha3/brg_endian.h
+++ b/src/3rdparty/sha3/brg_endian.h
diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c
index ff78701615..06f6d154f1 100644
--- a/src/3rdparty/sqlite/sqlite3.c
+++ b/src/3rdparty/sqlite/sqlite3.c
@@ -35209,6 +35209,7 @@ static void winLogIoerr(int nRetry, int lineno){
** create a substitute.
*/
/* #include <time.h> */
+# if _WIN32_WCE < 0x800
struct tm *__cdecl localtime(const time_t *t)
{
static struct tm y;
@@ -35230,6 +35231,7 @@ struct tm *__cdecl localtime(const time_t *t)
y.tm_sec = pTm.wSecond;
return &y;
}
+# endif
#endif
#define HANDLE_TO_WINFILE(a) (winFile*)&((char*)a)[-(int)offsetof(winFile,h)]
diff --git a/src/3rdparty/zlib/0001-Fix-WEC2013-build-of-zlib.patch b/src/3rdparty/zlib/0001-Fix-WEC2013-build-of-zlib.patch
new file mode 100644
index 0000000000..ef6fb33eed
--- /dev/null
+++ b/src/3rdparty/zlib/0001-Fix-WEC2013-build-of-zlib.patch
@@ -0,0 +1,26 @@
+From f2652cfd83f34ec3e70a936e5ea9f8623b66bd95 Mon Sep 17 00:00:00 2001
+From: Bjoern Breitmeyer <bjoern.breitmeyer@kdab.com>
+Date: Fri, 27 Mar 2015 15:46:59 +0100
+Subject: [PATCH] Fix WEC2013 build of zlib.
+
+Change-Id: I4d1908f1175ed39e2df8717fb0b5a17befe88744
+---
+ src/3rdparty/zlib/zutil.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/3rdparty/zlib/zutil.h b/src/3rdparty/zlib/zutil.h
+index 8e535ac..4d367a9 100644
+--- a/src/3rdparty/zlib/zutil.h
++++ b/src/3rdparty/zlib/zutil.h
+@@ -143,7 +143,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
+ #endif
+
+ #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
+-# if defined(_WIN32_WCE)
++# if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
+ # define fdopen(fd,mode) NULL /* No fdopen() */
+ # ifndef _PTRDIFF_T_DEFINED
+ typedef int ptrdiff_t;
+--
+1.8.1.msysgit.1
+
diff --git a/src/3rdparty/zlib/zutil.h b/src/3rdparty/zlib/zutil.h
index 8e535acf40..4d367a92db 100644
--- a/src/3rdparty/zlib/zutil.h
+++ b/src/3rdparty/zlib/zutil.h
@@ -143,7 +143,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
-# if defined(_WIN32_WCE)
+# if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
# define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef _PTRDIFF_T_DEFINED
typedef int ptrdiff_t;
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
index 040eba5e42..5d7918ea54 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
@@ -43,6 +43,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.ClipboardManager;
+import android.os.Build;
import android.util.Log;
import android.view.ContextMenu;
import android.view.Menu;
@@ -301,32 +302,49 @@ public class QtNative
static public void sendTouchEvent(MotionEvent event, int id)
{
- //@ANDROID-5
- touchBegin(id);
- for (int i=0;i<event.getPointerCount();i++) {
- touchAdd(id,
- event.getPointerId(i),
- getAction(i, event),
- i == 0,
- (int)event.getX(i),
- (int)event.getY(i),
- event.getSize(i),
- event.getPressure(i));
- }
+ int pointerType = 0;
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- touchEnd(id,0);
+ if (Build.VERSION.SDK_INT >= 14) {
+ switch (event.getToolType(0)) {
+ case MotionEvent.TOOL_TYPE_STYLUS:
+ pointerType = 1; // QTabletEvent::Pen
break;
-
- case MotionEvent.ACTION_UP:
- touchEnd(id,2);
+ case MotionEvent.TOOL_TYPE_ERASER:
+ pointerType = 3; // QTabletEvent::Eraser
break;
+ // TODO TOOL_TYPE_MOUSE
+ }
+ }
- default:
- touchEnd(id,1);
+ if (pointerType != 0) {
+ tabletEvent(id, event.getDeviceId(), event.getEventTime(), event.getAction(), pointerType,
+ event.getButtonState(), event.getX(), event.getY(), event.getPressure());
+ } else {
+ touchBegin(id);
+ for (int i = 0; i < event.getPointerCount(); ++i) {
+ touchAdd(id,
+ event.getPointerId(i),
+ getAction(i, event),
+ i == 0,
+ (int)event.getX(i),
+ (int)event.getY(i),
+ event.getSize(i),
+ event.getPressure(i));
+ }
+
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ touchEnd(id, 0);
+ break;
+
+ case MotionEvent.ACTION_UP:
+ touchEnd(id, 2);
+ break;
+
+ default:
+ touchEnd(id, 1);
+ }
}
- //@ANDROID-5
}
static public void sendTrackballEvent(MotionEvent event, int id)
@@ -602,6 +620,10 @@ public class QtNative
public static native void longPress(int winId, int x, int y);
// pointer methods
+ // tablet methods
+ public static native void tabletEvent(int winId, int deviceId, long time, int action, int pointerType, int buttonState, float x, float y, float pressure);
+ // tablet methods
+
// keyboard methods
public static native void keyDown(int key, int unicode, int modifier, boolean autoRepeat);
public static native void keyUp(int key, int unicode, int modifier, boolean autoRepeat);
diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h
index da78341d90..7085a9fc5e 100644
--- a/src/corelib/animation/qabstractanimation.h
+++ b/src/corelib/animation/qabstractanimation.h
@@ -76,7 +76,7 @@ public:
DeleteWhenStopped
};
- QAbstractAnimation(QObject *parent = 0);
+ QAbstractAnimation(QObject *parent = Q_NULLPTR);
virtual ~QAbstractAnimation();
State state() const;
@@ -111,7 +111,7 @@ public Q_SLOTS:
void setCurrentTime(int msecs);
protected:
- QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent = 0);
+ QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent = Q_NULLPTR);
bool event(QEvent *event) Q_DECL_OVERRIDE;
virtual void updateCurrentTime(int currentTime) = 0;
@@ -130,7 +130,7 @@ class Q_CORE_EXPORT QAnimationDriver : public QObject
Q_DECLARE_PRIVATE(QAnimationDriver)
public:
- QAnimationDriver(QObject *parent = 0);
+ QAnimationDriver(QObject *parent = Q_NULLPTR);
~QAnimationDriver();
virtual void advance();
@@ -156,7 +156,7 @@ protected:
virtual void start();
virtual void stop();
- QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent = 0);
+ QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent = Q_NULLPTR);
private:
friend class QUnifiedTimer;
diff --git a/src/corelib/animation/qanimationgroup.h b/src/corelib/animation/qanimationgroup.h
index 9b180b1704..b668b503b4 100644
--- a/src/corelib/animation/qanimationgroup.h
+++ b/src/corelib/animation/qanimationgroup.h
@@ -47,7 +47,7 @@ class Q_CORE_EXPORT QAnimationGroup : public QAbstractAnimation
Q_OBJECT
public:
- QAnimationGroup(QObject *parent = 0);
+ QAnimationGroup(QObject *parent = Q_NULLPTR);
~QAnimationGroup();
QAbstractAnimation *animationAt(int index) const;
diff --git a/src/corelib/animation/qparallelanimationgroup.h b/src/corelib/animation/qparallelanimationgroup.h
index 52a61dafcd..7ce05d6344 100644
--- a/src/corelib/animation/qparallelanimationgroup.h
+++ b/src/corelib/animation/qparallelanimationgroup.h
@@ -47,7 +47,7 @@ class Q_CORE_EXPORT QParallelAnimationGroup : public QAnimationGroup
Q_OBJECT
public:
- QParallelAnimationGroup(QObject *parent = 0);
+ QParallelAnimationGroup(QObject *parent = Q_NULLPTR);
~QParallelAnimationGroup();
int duration() const Q_DECL_OVERRIDE;
diff --git a/src/corelib/animation/qpauseanimation.h b/src/corelib/animation/qpauseanimation.h
index 159d82f969..5207472623 100644
--- a/src/corelib/animation/qpauseanimation.h
+++ b/src/corelib/animation/qpauseanimation.h
@@ -48,8 +48,8 @@ class Q_CORE_EXPORT QPauseAnimation : public QAbstractAnimation
Q_OBJECT
Q_PROPERTY(int duration READ duration WRITE setDuration)
public:
- QPauseAnimation(QObject *parent = 0);
- QPauseAnimation(int msecs, QObject *parent = 0);
+ QPauseAnimation(QObject *parent = Q_NULLPTR);
+ QPauseAnimation(int msecs, QObject *parent = Q_NULLPTR);
~QPauseAnimation();
int duration() const Q_DECL_OVERRIDE;
diff --git a/src/corelib/animation/qpropertyanimation.h b/src/corelib/animation/qpropertyanimation.h
index 8d06a9f354..c0d30ba0fd 100644
--- a/src/corelib/animation/qpropertyanimation.h
+++ b/src/corelib/animation/qpropertyanimation.h
@@ -49,8 +49,8 @@ class Q_CORE_EXPORT QPropertyAnimation : public QVariantAnimation
Q_PROPERTY(QObject* targetObject READ targetObject WRITE setTargetObject)
public:
- QPropertyAnimation(QObject *parent = 0);
- QPropertyAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = 0);
+ QPropertyAnimation(QObject *parent = Q_NULLPTR);
+ QPropertyAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = Q_NULLPTR);
~QPropertyAnimation();
QObject *targetObject() const;
diff --git a/src/corelib/animation/qsequentialanimationgroup.h b/src/corelib/animation/qsequentialanimationgroup.h
index 1a4ead90d4..c8a84a1220 100644
--- a/src/corelib/animation/qsequentialanimationgroup.h
+++ b/src/corelib/animation/qsequentialanimationgroup.h
@@ -50,7 +50,7 @@ class Q_CORE_EXPORT QSequentialAnimationGroup : public QAnimationGroup
Q_PROPERTY(QAbstractAnimation* currentAnimation READ currentAnimation NOTIFY currentAnimationChanged)
public:
- QSequentialAnimationGroup(QObject *parent = 0);
+ QSequentialAnimationGroup(QObject *parent = Q_NULLPTR);
~QSequentialAnimationGroup();
QPauseAnimation *addPause(int msecs);
diff --git a/src/corelib/animation/qvariantanimation.h b/src/corelib/animation/qvariantanimation.h
index 8a6524a594..4340a187a2 100644
--- a/src/corelib/animation/qvariantanimation.h
+++ b/src/corelib/animation/qvariantanimation.h
@@ -59,7 +59,7 @@ public:
typedef QPair<qreal, QVariant> KeyValue;
typedef QVector<KeyValue> KeyValues;
- QVariantAnimation(QObject *parent = 0);
+ QVariantAnimation(QObject *parent = Q_NULLPTR);
~QVariantAnimation();
QVariant startValue() const;
@@ -88,7 +88,7 @@ Q_SIGNALS:
void valueChanged(const QVariant &value);
protected:
- QVariantAnimation(QVariantAnimationPrivate &dd, QObject *parent = 0);
+ QVariantAnimation(QVariantAnimationPrivate &dd, QObject *parent = Q_NULLPTR);
bool event(QEvent *event) Q_DECL_OVERRIDE;
void updateCurrentTime(int) Q_DECL_OVERRIDE;
diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h
index 1d5e25efcc..3e73872d64 100644
--- a/src/corelib/codecs/qtextcodec.h
+++ b/src/corelib/codecs/qtextcodec.h
@@ -88,7 +88,7 @@ public:
struct Q_CORE_EXPORT ConverterState {
ConverterState(ConversionFlags f = DefaultConversion)
- : flags(f), remainingChars(0), invalidChars(0), d(0) { state_data[0] = state_data[1] = state_data[2] = 0; }
+ : flags(f), remainingChars(0), invalidChars(0), d(Q_NULLPTR) { state_data[0] = state_data[1] = state_data[2] = 0; }
~ConverterState();
ConversionFlags flags;
int remainingChars;
@@ -99,9 +99,9 @@ public:
Q_DISABLE_COPY(ConverterState)
};
- QString toUnicode(const char *in, int length, ConverterState *state = 0) const
+ QString toUnicode(const char *in, int length, ConverterState *state = Q_NULLPTR) const
{ return convertToUnicode(in, length, state); }
- QByteArray fromUnicode(const QChar *in, int length, ConverterState *state = 0) const
+ QByteArray fromUnicode(const QChar *in, int length, ConverterState *state = Q_NULLPTR) const
{ return convertFromUnicode(in, length, state); }
QTextDecoder* makeDecoder(ConversionFlags flags = DefaultConversion) const;
diff --git a/src/corelib/doc/src/objectmodel/properties.qdoc b/src/corelib/doc/src/objectmodel/properties.qdoc
index abb0720fe9..55622dd56b 100644
--- a/src/corelib/doc/src/objectmodel/properties.qdoc
+++ b/src/corelib/doc/src/objectmodel/properties.qdoc
@@ -160,13 +160,8 @@
Because QDate is user-defined, you must include the \c{<QDate>}
header file with the property declaration.
- For QMap, QList, and QValueList properties, the property value is
- a QVariant whose value is the entire list or map. Note that the
- Q_PROPERTY string cannot contain commas, because commas separate
- macro arguments. Therefore, you must use \c QMap as the property
- type instead of \c QMap<QString,QVariant>. For consistency, also
- use \c QList and \c QValueList instead of \c QList<QVariant> and
- \c QValueList<QVariant>.
+ For historical reasons, \a QMap and \a QList as property types
+ are synonym of \a QVariantMap and \a QVariantList.
\section1 Reading and Writing Properties with the Meta-Object System
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index d3b9c3f5a7..f434e87c85 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -109,7 +109,7 @@ public:
inline QFlags &operator=(const QFlags &other);
#endif
Q_DECL_CONSTEXPR inline QFlags(Enum f) Q_DECL_NOTHROW : i(Int(f)) {}
- Q_DECL_CONSTEXPR inline QFlags(Zero = 0) Q_DECL_NOTHROW : i(0) {}
+ Q_DECL_CONSTEXPR inline QFlags(Zero = Q_NULLPTR) Q_DECL_NOTHROW : i(0) {}
Q_DECL_CONSTEXPR inline QFlags(QFlag f) Q_DECL_NOTHROW : i(f) {}
#ifdef Q_COMPILER_INITIALIZER_LISTS
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 9e19dd7f0f..85d97c7b06 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -42,6 +42,7 @@
#include <private/qlocale_tools_p.h>
#include <private/qsystemlibrary_p.h>
+#include <qmutex.h>
#ifndef QT_NO_QOBJECT
#include <private/qthread_p.h>
@@ -2886,12 +2887,15 @@ QString QSysInfo::prettyProductName()
\macro void Q_CHECK_PTR(void *pointer)
\relates <QtGlobal>
- If \a pointer is 0, prints a warning message containing the source
+ If \a pointer is 0, prints a message containing the source
code's file name and line number, saying that the program ran out
- of memory.
+ of memory and aborts program execution. It throws \c std::bad_alloc instead
+ if exceptions are enabled.
- Q_CHECK_PTR does nothing if \c QT_NO_DEBUG was defined during
- compilation.
+ Q_CHECK_PTR does nothing if \c QT_NO_DEBUG and \c QT_NO_EXCEPTIONS were
+ defined during compilation. Therefore you must not use Q_CHECK_PTR to check
+ for successful memory allocations because the check will be disabled in
+ some cases.
Example:
@@ -3021,7 +3025,7 @@ namespace {
// depending on the return type
static inline Q_DECL_UNUSED QString fromstrerror_helper(int, const QByteArray &buf)
{
- return QString::fromLocal8Bit(buf);
+ return QString::fromLocal8Bit(buf.constData());
}
static inline Q_DECL_UNUSED QString fromstrerror_helper(const char *str, const QByteArray &)
{
@@ -3099,6 +3103,10 @@ QString qt_error_string(int errorCode)
return ret.trimmed();
}
+// In the C runtime on all platforms access to the environment is not thread-safe. We
+// add thread-safety for the Qt wrappers.
+static QBasicMutex environmentMutex;
+
// getenv is declared as deprecated in VS2005. This function
// makes use of the new secure getenv function.
/*!
@@ -3116,6 +3124,7 @@ QString qt_error_string(int errorCode)
*/
QByteArray qgetenv(const char *varName)
{
+ QMutexLocker locker(&environmentMutex);
#if defined(_MSC_VER) && _MSC_VER >= 1400
size_t requiredSize = 0;
QByteArray buffer;
@@ -3149,6 +3158,7 @@ QByteArray qgetenv(const char *varName)
*/
bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT
{
+ QMutexLocker locker(&environmentMutex);
#if defined(_MSC_VER) && _MSC_VER >= 1400
// we provide a buffer that can only hold the empty string, so
// when the env.var isn't empty, we'll get an ERANGE error (buffer
@@ -3180,6 +3190,7 @@ bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT
*/
int qEnvironmentVariableIntValue(const char *varName, bool *ok) Q_DECL_NOEXCEPT
{
+ QMutexLocker locker(&environmentMutex);
#if defined(_MSC_VER) && _MSC_VER >= 1400
// we provide a buffer that can hold any int value:
static const int NumBinaryDigitsPerOctalDigit = 3;
@@ -3228,6 +3239,7 @@ int qEnvironmentVariableIntValue(const char *varName, bool *ok) Q_DECL_NOEXCEPT
*/
bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT
{
+ QMutexLocker locker(&environmentMutex);
#if defined(_MSC_VER) && _MSC_VER >= 1400
size_t requiredSize = 0;
(void)getenv_s(&requiredSize, 0, 0, varName);
@@ -3257,6 +3269,7 @@ bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT
*/
bool qputenv(const char *varName, const QByteArray& value)
{
+ QMutexLocker locker(&environmentMutex);
#if defined(_MSC_VER) && _MSC_VER >= 1400
return _putenv_s(varName, value.constData()) == 0;
#elif (defined(_POSIX_VERSION) && (_POSIX_VERSION-0) >= 200112L) || defined(Q_OS_HAIKU)
@@ -3287,6 +3300,7 @@ bool qputenv(const char *varName, const QByteArray& value)
*/
bool qunsetenv(const char *varName)
{
+ QMutexLocker locker(&environmentMutex);
#if defined(_MSC_VER) && _MSC_VER >= 1400
return _putenv_s(varName, "") == 0;
#elif (defined(_POSIX_VERSION) && (_POSIX_VERSION-0) >= 200112L) || defined(Q_OS_BSD4) || defined(Q_OS_HAIKU)
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 97c5f37cab..51dd64c7cc 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -41,11 +41,11 @@
#include <stddef.h>
-#define QT_VERSION_STR "5.5.1"
+#define QT_VERSION_STR "5.6.0"
/*
QT_VERSION is (major << 16) + (minor << 8) + patch.
*/
-#define QT_VERSION 0x050501
+#define QT_VERSION 0x050600
/*
can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
*/
@@ -322,6 +322,15 @@ typedef double qreal;
#endif
/*
+ Some classes do not permit copies to be made of an object. These
+ classes contains a private copy constructor and assignment
+ operator to disable copying (the compiler gives an error message).
+*/
+#define Q_DISABLE_COPY(Class) \
+ Class(const Class &) Q_DECL_EQ_DELETE;\
+ Class &operator=(const Class &) Q_DECL_EQ_DELETE;
+
+/*
No, this is not an evil backdoor. QT_BUILD_INTERNAL just exports more symbols
for Qt's internal unit tests. If you want slower loading times and more
symbols that can vanish from version to version, feel free to define QT_BUILD_INTERNAL.
@@ -543,7 +552,21 @@ template <typename T>
Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max)
{ return qMax(min, qMin(max, val)); }
-#ifdef Q_OS_DARWIN
+#ifndef Q_FORWARD_DECLARE_OBJC_CLASS
+# ifdef __OBJC__
+# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) @class classname
+# else
+# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) typedef struct objc_object classname
+# endif
+#endif
+#ifndef Q_FORWARD_DECLARE_CF_TYPE
+# define Q_FORWARD_DECLARE_CF_TYPE(type) typedef const struct __ ## type * type ## Ref
+#endif
+#ifndef Q_FORWARD_DECLARE_MUTABLE_CF_TYPE
+# define Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) typedef struct __ ## type * type ## Ref
+#endif
+
+#ifdef Q_OS_MAC
# define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) \
((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && osx != __MAC_NA && __MAC_OS_X_VERSION_MAX_ALLOWED >= osx) || \
(defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios))
@@ -561,7 +584,23 @@ Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max
QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_NA, ios)
# define QT_OSX_DEPLOYMENT_TARGET_BELOW(osx) \
QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, __IPHONE_NA)
-#endif
+
+QT_END_NAMESPACE
+Q_FORWARD_DECLARE_OBJC_CLASS(NSAutoreleasePool);
+QT_BEGIN_NAMESPACE
+
+// Implemented in qcore_mac_objc.mm
+class Q_CORE_EXPORT QMacAutoReleasePool
+{
+public:
+ QMacAutoReleasePool();
+ ~QMacAutoReleasePool();
+private:
+ Q_DISABLE_COPY(QMacAutoReleasePool);
+ NSAutoreleasePool *pool;
+};
+
+#endif // Q_OS_MAC
/*
Data stream functions are provided by many classes (defined in qdatastream.h)
@@ -1033,15 +1072,6 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
{ return T::dynamic_cast_will_always_fail_because_rtti_is_disabled; }
#endif
-/*
- Some classes do not permit copies to be made of an object. These
- classes contains a private copy constructor and assignment
- operator to disable copying (the compiler gives an error message).
-*/
-#define Q_DISABLE_COPY(Class) \
- Class(const Class &) Q_DECL_EQ_DELETE;\
- Class &operator=(const Class &) Q_DECL_EQ_DELETE;
-
class QByteArray;
Q_CORE_EXPORT QByteArray qgetenv(const char *varName);
Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value);
@@ -1049,7 +1079,7 @@ Q_CORE_EXPORT bool qunsetenv(const char *varName);
Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT;
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT;
-Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=0) Q_DECL_NOEXCEPT;
+Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=Q_NULLPTR) Q_DECL_NOEXCEPT;
inline int qIntCast(double f) { return int(f); }
inline int qIntCast(float f) { return int(f); }
@@ -1077,20 +1107,6 @@ 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; };
}
-#ifndef Q_FORWARD_DECLARE_OBJC_CLASS
-# ifdef __OBJC__
-# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) @class classname
-# else
-# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) typedef struct objc_object classname
-# endif
-#endif
-#ifndef Q_FORWARD_DECLARE_CF_TYPE
-# define Q_FORWARD_DECLARE_CF_TYPE(type) typedef const struct __ ## type * type ## Ref
-#endif
-#ifndef Q_FORWARD_DECLARE_MUTABLE_CF_TYPE
-# define Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) typedef struct __ ## type * type ## Ref
-#endif
-
QT_END_NAMESPACE
// We need to keep QTypeInfo, QSysInfo, QFlags, qDebug & family in qglobal.h for compatibility with Qt 4.
diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h
index 679afddb20..c63346086a 100644
--- a/src/corelib/global/qlogging.h
+++ b/src/corelib/global/qlogging.h
@@ -57,7 +57,8 @@ class QMessageLogContext
{
Q_DISABLE_COPY(QMessageLogContext)
public:
- Q_DECL_CONSTEXPR QMessageLogContext() : version(2), line(0), file(0), function(0), category(0) {}
+ Q_DECL_CONSTEXPR QMessageLogContext()
+ : version(2), line(0), file(Q_NULLPTR), function(Q_NULLPTR), category(Q_NULLPTR) {}
Q_DECL_CONSTEXPR QMessageLogContext(const char *fileName, int lineNumber, const char *functionName, const char *categoryName)
: version(2), line(lineNumber), file(fileName), function(functionName), category(categoryName) {}
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 82b383e69c..1ceedf4605 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1326,6 +1326,7 @@ public:
ImAbsolutePosition = 0x400,
ImTextBeforeCursor = 0x800,
ImTextAfterCursor = 0x1000,
+ ImEnterKeyType = 0x2000,
ImPlatformData = 0x80000000,
ImQueryInput = ImCursorRectangle | ImCursorPosition | ImSurroundingText |
@@ -1365,6 +1366,17 @@ public:
};
Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)
+ enum EnterKeyType {
+ EnterKeyDefault,
+ EnterKeyReturn,
+ EnterKeyDone,
+ EnterKeyGo,
+ EnterKeySend,
+ EnterKeySearch,
+ EnterKeyNext,
+ EnterKeyPrevious
+ };
+
enum ToolButtonStyle {
ToolButtonIconOnly,
ToolButtonTextOnly,
@@ -1449,7 +1461,10 @@ public:
ItemIsDropEnabled = 8,
ItemIsUserCheckable = 16,
ItemIsEnabled = 32,
- ItemIsTristate = 64,
+ ItemIsAutoTristate = 64,
+#if QT_DEPRECATED_SINCE(5, 6)
+ ItemIsTristate = ItemIsAutoTristate,
+#endif
ItemNeverHasChildren = 128,
ItemIsUserTristate = 256
};
@@ -1610,7 +1625,8 @@ public:
enum MouseEventSource {
MouseEventNotSynthesized,
MouseEventSynthesizedBySystem,
- MouseEventSynthesizedByQt
+ MouseEventSynthesizedByQt,
+ MouseEventSynthesizedByApplication
};
enum MouseEventFlag {
@@ -1685,6 +1701,7 @@ public:
QT_Q_ENUM(InputMethodHint)
QT_Q_ENUM(InputMethodQuery)
QT_Q_FLAG(InputMethodHints)
+ QT_Q_ENUM(EnterKeyType)
QT_Q_FLAG(InputMethodQueries)
QT_Q_FLAG(TouchPointStates)
QT_Q_ENUM(ScreenOrientation)
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 38ee8edb49..19ce266146 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -1670,6 +1670,16 @@
\value Key_Blue
\value Key_ChannelUp
\value Key_ChannelDown
+ \value Key_Guide
+ \value Key_Info
+ \value Key_Settings
+ \value Key_MicVolumeUp
+ \value Key_MicVolumeDown
+ \value Key_New
+ \value Key_Open
+ \value Key_Find
+ \value Key_Undo
+ \value Key_Redo
\value Key_MediaLast
\value Key_unknown
@@ -1694,6 +1704,7 @@
\value Key_Play
\value Key_Sleep
\value Key_Zoom
+ \value Key_Exit
\value Key_Cancel
\sa QKeyEvent::key()
@@ -2516,6 +2527,7 @@
but \b{must} not return an empty string unless the cursor is at the start of the document.
\value ImTextAfterCursor The plain text after the cursor. The widget can decide how much text to return,
but \b{must} not return an empty string unless the cursor is at the end of the document.
+ \value ImEnterKeyType The Enter key type.
Masks:
@@ -2526,6 +2538,37 @@
*/
/*!
+ \enum Qt::EnterKeyType
+
+ This can be used to alter the appearance of the Return key on an on screen keyboard.
+
+ \note Not all of these values are supported on all platforms.
+ For unsuppoted values the default key will be used instead.
+
+ \value EnterKeyDefault The default Enter key.
+ This can either be a button closing the keyboard, or a Return button
+ causing a new line in case of a multi-line input field.
+ \value EnterKeyReturn Show a Return button that inserts a new line.
+ The keyboard will not close when this button is pressed.
+ \value EnterKeyDone Show a "Done" button.
+ The keyboard will close when this button is pressed.
+ \value EnterKeyGo Show a "Go" button.
+ Typically used in an address bar when entering a URL; the keyboard
+ will close when this button is pressed.
+ \value EnterKeySend Show a "Send" button.
+ The keyboard will close when this button is pressed.
+ \value EnterKeySearch Show a "Search" button.
+ The keyboard will close when this button is pressed.
+ \value EnterKeyNext Show a "Next" button.
+ Typically used in a form to allow navigating to the next input field;
+ the keyboard will not close when this button is pressed.
+ \value EnterKeyPrevious Show a "Previous" button.
+ The keyboard will not close when this button is pressed.
+
+ \since 5.6
+*/
+
+/*!
\enum Qt::ItemDataRole
Each item in the model has a set of data elements associated with
@@ -2600,10 +2643,12 @@
\value ItemIsDropEnabled It can be used as a drop target.
\value ItemIsUserCheckable It can be checked or unchecked by the user.
\value ItemIsEnabled The user can interact with the item.
- \value ItemIsTristate The item can show three separate states.
+ \value ItemIsAutoTristate The item's state depends on the state of its children.
This enables automatic management of the state of parent items in QTreeWidget
(checked if all children are checked, unchecked if all children are unchecked,
or partially checked if only some children are checked).
+ \value ItemIsTristate \e{This enum value is deprecated.} Use Qt::ItemIsAutoTristate
+ instead.
\value ItemNeverHasChildren The item never has child items.
\value ItemIsUserTristate The user can cycle through three separate states.
This value has been added in Qt 5.5.
@@ -3023,6 +3068,12 @@
\value MouseEventSynthesizedByQt Indicates that the mouse event was
synthesized from an unhandled touch event by Qt.
+ \value MouseEventSynthesizedByApplication Indicates that the mouse
+ event was synthesized by the application. This allows
+ distinguishing application-generated mouse events from the ones
+ that are coming from the system or are synthesized by Qt. This
+ value was introduced in Qt 5.6
+
\sa Qt::AA_SynthesizeMouseForUnhandledTouchEvents
*/
diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h
index 625b366cc6..d40e6659c7 100644
--- a/src/corelib/global/qsysinfo.h
+++ b/src/corelib/global/qsysinfo.h
@@ -125,19 +125,19 @@ public:
MV_Unknown = 0x0000,
/* version */
- MV_9 = 0x0001,
- MV_10_0 = 0x0002,
- MV_10_1 = 0x0003,
- MV_10_2 = 0x0004,
- MV_10_3 = 0x0005,
- MV_10_4 = 0x0006,
- MV_10_5 = 0x0007,
- MV_10_6 = 0x0008,
- MV_10_7 = 0x0009,
- MV_10_8 = 0x000A,
- MV_10_9 = 0x000B,
- MV_10_10 = 0x000C,
- MV_10_11 = 0x000D,
+ MV_9 = Q_MV_OSX(9, 0),
+ MV_10_0 = Q_MV_OSX(10, 0),
+ MV_10_1 = Q_MV_OSX(10, 1),
+ MV_10_2 = Q_MV_OSX(10, 2),
+ MV_10_3 = Q_MV_OSX(10, 3),
+ MV_10_4 = Q_MV_OSX(10, 4),
+ MV_10_5 = Q_MV_OSX(10, 5),
+ MV_10_6 = Q_MV_OSX(10, 6),
+ MV_10_7 = Q_MV_OSX(10, 7),
+ MV_10_8 = Q_MV_OSX(10, 8),
+ MV_10_9 = Q_MV_OSX(10, 9),
+ MV_10_10 = Q_MV_OSX(10, 10),
+ MV_10_11 = Q_MV_OSX(10, 11),
/* codenames */
MV_CHEETAH = MV_10_0,
diff --git a/src/corelib/io/qbuffer.h b/src/corelib/io/qbuffer.h
index 1b2758d040..233c702213 100644
--- a/src/corelib/io/qbuffer.h
+++ b/src/corelib/io/qbuffer.h
@@ -51,8 +51,8 @@ class Q_CORE_EXPORT QBuffer : public QIODevice
public:
#ifndef QT_NO_QOBJECT
- explicit QBuffer(QObject *parent = 0);
- QBuffer(QByteArray *buf, QObject *parent = 0);
+ explicit QBuffer(QObject *parent = Q_NULLPTR);
+ QBuffer(QByteArray *buf, QObject *parent = Q_NULLPTR);
#else
QBuffer();
explicit QBuffer(QByteArray *buf);
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index 436bf8dd57..b87dbe4784 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -83,10 +83,11 @@ public:
Qt_5_3 = Qt_5_2,
Qt_5_4 = 16,
Qt_5_5 = Qt_5_4,
-#if QT_VERSION >= 0x050600
+ Qt_5_6 = Qt_5_5,
+#if QT_VERSION >= 0x050700
#error Add the datastream version for this Qt version and update Qt_DefaultCompiledVersion
#endif
- Qt_DefaultCompiledVersion = Qt_5_5
+ Qt_DefaultCompiledVersion = Qt_5_6
};
enum ByteOrder {
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp
index 357d63137c..8676fe0259 100644
--- a/src/corelib/io/qdebug.cpp
+++ b/src/corelib/io/qdebug.cpp
@@ -334,6 +334,7 @@ QDebug &QDebug::resetFormat()
stream->space = true;
if (stream->context.version > 1)
stream->flags = 0;
+ stream->setVerbosity(Stream::defaultVerbosity);
return *this;
}
@@ -424,6 +425,32 @@ QDebug &QDebug::resetFormat()
*/
/*!
+ \fn int QDebug::verbosity() const
+ \since 5.6
+
+ Returns the verbosity of the debug stream.
+
+ Streaming operators can check the value to decide whether
+ verbose output is desired and print more information depending on the
+ level. Higher values indicate that more information is desired.
+
+ The allowed range is from 0 to 7. The default value is 2.
+
+ \sa setVerbosity()
+*/
+
+/*!
+ \fn void QDebug::setVerbosity(int verbosityLevel)
+ \since 5.6
+
+ Sets the verbosity of the stream to \a verbosityLevel.
+
+ The allowed range is from 0 to 7. The default value is 2.
+
+ \sa verbosity()
+*/
+
+/*!
\fn QDebug &QDebug::operator<<(QChar t)
Writes the character, \a t, to the stream and returns a reference to the
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index 59bd32e9a4..9391799624 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -53,9 +53,14 @@ class Q_CORE_EXPORT QDebug
friend class QMessageLogger;
friend class QDebugStateSaverPrivate;
struct Stream {
- Stream(QIODevice *device) : ts(device), ref(1), type(QtDebugMsg), space(true), message_output(false), flags(0) {}
- Stream(QString *string) : ts(string, QIODevice::WriteOnly), ref(1), type(QtDebugMsg), space(true), message_output(false), flags(0) {}
- Stream(QtMsgType t) : ts(&buffer, QIODevice::WriteOnly), ref(1), type(t), space(true), message_output(true), flags(0) {}
+ enum { defaultVerbosity = 2, verbosityShift = 29, verbosityMask = 0x7 };
+
+ Stream(QIODevice *device) : ts(device), ref(1), type(QtDebugMsg),
+ space(true), message_output(false), flags(defaultVerbosity << verbosityShift) {}
+ Stream(QString *string) : ts(string, QIODevice::WriteOnly), ref(1), type(QtDebugMsg),
+ space(true), message_output(false), flags(defaultVerbosity << verbosityShift) {}
+ Stream(QtMsgType t) : ts(&buffer, QIODevice::WriteOnly), ref(1), type(t),
+ space(true), message_output(true), flags(defaultVerbosity << verbosityShift) {}
QTextStream ts;
QString buffer;
int ref;
@@ -64,7 +69,7 @@ class Q_CORE_EXPORT QDebug
bool message_output;
QMessageLogContext context;
- enum FormatFlag {
+ enum FormatFlag { // Note: Bits 29..31 are reserved for the verbose level introduced in 5.6.
NoQuotes = 0x1
};
@@ -72,7 +77,15 @@ class Q_CORE_EXPORT QDebug
bool testFlag(FormatFlag flag) const { return (context.version > 1) ? (flags & flag) : false; }
void setFlag(FormatFlag flag) { if (context.version > 1) { flags |= flag; } }
void unsetFlag(FormatFlag flag) { if (context.version > 1) { flags &= ~flag; } }
-
+ int verbosity() const
+ { return context.version > 1 ? (flags >> verbosityShift) & verbosityMask : int(Stream::defaultVerbosity); }
+ void setVerbosity(int v)
+ {
+ if (context.version > 1) {
+ flags &= ~(verbosityMask << verbosityShift);
+ flags |= (v & verbosityMask) << verbosityShift;
+ }
+ }
// added in 5.4
int flags;
} *stream;
@@ -96,6 +109,8 @@ public:
inline QDebug &space() { stream->space = true; stream->ts << ' '; return *this; }
inline QDebug &nospace() { stream->space = false; return *this; }
inline QDebug &maybeSpace() { if (stream->space) stream->ts << ' '; return *this; }
+ int verbosity() const { return stream->verbosity(); }
+ void setVerbosity(int verbosityLevel) { stream->setVerbosity(verbosityLevel); }
bool autoInsertSpaces() const { return stream->space; }
void setAutoInsertSpaces(bool b) { stream->space = b; }
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 6687ff846c..2ae865a534 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -1828,6 +1828,8 @@ QFileInfoList QDir::drives()
underlying operating system. If you want to display paths to the
user using their operating system's separator use
toNativeSeparators().
+
+ \sa listSeparator()
*/
QChar QDir::separator()
{
@@ -1839,6 +1841,16 @@ QChar QDir::separator()
}
/*!
+ \fn QDir::listSeparator()
+ \since 5.6
+
+ Returns the native path list separator: ':' under Unix
+ and ';' under Windows.
+
+ \sa separator()
+*/
+
+/*!
Sets the application's current working directory to \a path.
Returns \c true if the directory was successfully changed; otherwise
returns \c false.
diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h
index e622011f98..ab3a331229 100644
--- a/src/corelib/io/qdir.h
+++ b/src/corelib/io/qdir.h
@@ -101,11 +101,10 @@ public:
QDir &operator=(const QDir &);
QDir &operator=(const QString &path);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QDir &operator=(QDir &&other)
- { qSwap(d_ptr, other.d_ptr); return *this; }
+ QDir &operator=(QDir &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- inline void swap(QDir &other)
+ void swap(QDir &other) Q_DECL_NOTHROW
{ qSwap(d_ptr, other.d_ptr); }
void setPath(const QString &path);
@@ -177,7 +176,16 @@ public:
static QFileInfoList drives();
- static QChar separator();
+ Q_DECL_CONSTEXPR static inline QChar listSeparator() Q_DECL_NOTHROW
+ {
+#if defined(Q_OS_WIN)
+ return QLatin1Char(';');
+#else
+ return QLatin1Char(':');
+#endif
+ }
+
+ static QChar separator(); // ### Qt6: Make it inline
static bool setCurrent(const QString &path);
static inline QDir current() { return QDir(currentPath()); }
diff --git a/src/corelib/io/qfile.h b/src/corelib/io/qfile.h
index 35a73680af..4eac710d4c 100644
--- a/src/corelib/io/qfile.h
+++ b/src/corelib/io/qfile.h
@@ -134,7 +134,7 @@ protected:
#ifdef QT_NO_QOBJECT
QFile(QFilePrivate &dd);
#else
- QFile(QFilePrivate &dd, QObject *parent = 0);
+ QFile(QFilePrivate &dd, QObject *parent = Q_NULLPTR);
#endif
private:
diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp
index 3ee0e33573..4c5ed0aef6 100644
--- a/src/corelib/io/qfiledevice.cpp
+++ b/src/corelib/io/qfiledevice.cpp
@@ -481,7 +481,7 @@ bool QFileDevicePrivate::putCharHelper(char c)
#else
// Cutoff for code that doesn't only touch the buffer.
- int writeBufferSize = writeBuffer.size();
+ qint64 writeBufferSize = writeBuffer.size();
if ((openMode & QIODevice::Unbuffered) || writeBufferSize + 1 >= QFILE_WRITEBUFFER_SIZE
#ifdef Q_OS_WIN
|| ((openMode & QIODevice::Text) && c == '\n' && writeBufferSize + 2 >= QFILE_WRITEBUFFER_SIZE)
diff --git a/src/corelib/io/qfiledevice.h b/src/corelib/io/qfiledevice.h
index e9320d8d31..afa42bd86b 100644
--- a/src/corelib/io/qfiledevice.h
+++ b/src/corelib/io/qfiledevice.h
@@ -119,7 +119,7 @@ protected:
QFileDevice(QFileDevicePrivate &dd);
#else
explicit QFileDevice(QObject *parent);
- QFileDevice(QFileDevicePrivate &dd, QObject *parent = 0);
+ QFileDevice(QFileDevicePrivate &dd, QObject *parent = Q_NULLPTR);
#endif
qint64 readData(char *data, qint64 maxlen) Q_DECL_OVERRIDE;
diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h
index 58cf9a5c0f..59d12c3883 100644
--- a/src/corelib/io/qfileinfo.h
+++ b/src/corelib/io/qfileinfo.h
@@ -62,11 +62,10 @@ public:
QFileInfo &operator=(const QFileInfo &fileinfo);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QFileInfo&operator=(QFileInfo &&other)
- { qSwap(d_ptr, other.d_ptr); return *this; }
+ QFileInfo &operator=(QFileInfo &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- inline void swap(QFileInfo &other)
+ void swap(QFileInfo &other) Q_DECL_NOTHROW
{ qSwap(d_ptr, other.d_ptr); }
bool operator==(const QFileInfo &fileinfo) const;
diff --git a/src/corelib/io/qfileselector.h b/src/corelib/io/qfileselector.h
index 967d5eee75..9ee3588780 100644
--- a/src/corelib/io/qfileselector.h
+++ b/src/corelib/io/qfileselector.h
@@ -44,7 +44,7 @@ class Q_CORE_EXPORT QFileSelector : public QObject
{
Q_OBJECT
public:
- explicit QFileSelector(QObject *parent = 0);
+ explicit QFileSelector(QObject *parent = Q_NULLPTR);
~QFileSelector();
QString select(const QString &filePath) const;
diff --git a/src/corelib/io/qfilesystemwatcher.h b/src/corelib/io/qfilesystemwatcher.h
index 13d1782913..095b50d1e5 100644
--- a/src/corelib/io/qfilesystemwatcher.h
+++ b/src/corelib/io/qfilesystemwatcher.h
@@ -49,8 +49,8 @@ class Q_CORE_EXPORT QFileSystemWatcher : public QObject
Q_DECLARE_PRIVATE(QFileSystemWatcher)
public:
- QFileSystemWatcher(QObject *parent = 0);
- QFileSystemWatcher(const QStringList &paths, QObject *parent = 0);
+ QFileSystemWatcher(QObject *parent = Q_NULLPTR);
+ QFileSystemWatcher(const QStringList &paths, QObject *parent = Q_NULLPTR);
~QFileSystemWatcher();
bool addPath(const QString &file);
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm
index 8a028c91e1..7656530a46 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents.mm
+++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm
@@ -56,25 +56,6 @@
QT_BEGIN_NAMESPACE
-namespace {
-class RaiiAutoreleasePool
-{
- Q_DISABLE_COPY(RaiiAutoreleasePool)
-
-public:
- RaiiAutoreleasePool()
- : pool([[NSAutoreleasePool alloc] init])
- {}
-
- ~RaiiAutoreleasePool()
- { [pool release]; }
-
-private:
- NSAutoreleasePool *pool;
-};
-#define Q_AUTORELEASE_POOL(pool) RaiiAutoreleasePool pool; Q_UNUSED(pool);
-}
-
static void callBackFunction(ConstFSEventStreamRef streamRef,
void *clientCallBackInfo,
size_t numEvents,
@@ -82,7 +63,7 @@ static void callBackFunction(ConstFSEventStreamRef streamRef,
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[])
{
- Q_AUTORELEASE_POOL(pool)
+ QMacAutoReleasePool pool;
char **paths = static_cast<char **>(eventPaths);
QFseventsFileSystemWatcherEngine *engine = static_cast<QFseventsFileSystemWatcherEngine *>(clientCallBackInfo);
@@ -297,7 +278,7 @@ void QFseventsFileSystemWatcherEngine::doEmitDirectoryChanged(const QString &pat
void QFseventsFileSystemWatcherEngine::restartStream()
{
- Q_AUTORELEASE_POOL(pool)
+ QMacAutoReleasePool pool;
QMutexLocker locker(&lock);
stopStream();
startStream();
@@ -328,7 +309,7 @@ QFseventsFileSystemWatcherEngine::QFseventsFileSystemWatcherEngine(QObject *pare
QFseventsFileSystemWatcherEngine::~QFseventsFileSystemWatcherEngine()
{
- Q_AUTORELEASE_POOL(pool)
+ QMacAutoReleasePool pool;
if (stream)
FSEventStreamStop(stream);
@@ -344,7 +325,7 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths,
QStringList *files,
QStringList *directories)
{
- Q_AUTORELEASE_POOL(pool)
+ QMacAutoReleasePool pool;
if (stream) {
DEBUG("Flushing, last id is %llu", FSEventStreamGetLatestEventId(stream));
@@ -432,7 +413,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat
QStringList *files,
QStringList *directories)
{
- Q_AUTORELEASE_POOL(pool)
+ QMacAutoReleasePool pool;
QMutexLocker locker(&lock);
@@ -489,7 +470,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat
bool QFseventsFileSystemWatcherEngine::startStream()
{
Q_ASSERT(stream == 0);
- Q_AUTORELEASE_POOL(pool)
+ QMacAutoReleasePool pool;
if (stream) // This shouldn't happen, but let's be nice and handle it.
stopStream();
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index b908ae3145..f0d3250cd2 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -39,6 +39,7 @@
#include "qfile.h"
#include "qstringlist.h"
#include "qdir.h"
+#include "private/qbytearray_p.h"
#include <algorithm>
@@ -692,12 +693,13 @@ bool QIODevice::seek(qint64 pos)
bool QIODevice::atEnd() const
{
Q_D(const QIODevice);
+ const bool result = (d->openMode == NotOpen || (d->buffer.isEmpty()
+ && bytesAvailable() == 0));
#if defined QIODEVICE_DEBUG
printf("%p QIODevice::atEnd() returns %s, d->openMode == %d, d->pos == %lld\n", this,
- (d->openMode == NotOpen || d->pos == size()) ? "true" : "false", int(d->openMode),
- d->pos);
+ result ? "true" : "false", int(d->openMode), d->pos);
#endif
- return d->openMode == NotOpen || (d->buffer.isEmpty() && bytesAvailable() == 0);
+ return result;
}
/*!
@@ -941,9 +943,9 @@ QByteArray QIODevice::read(qint64 maxSize)
Q_UNUSED(d);
#endif
- if (quint64(maxSize) >= QByteArray::MaxSize) {
+ if (maxSize >= MaxByteArraySize) {
checkWarnMessage(this, "read", "maxSize argument exceeds QByteArray size limit");
- maxSize = QByteArray::MaxSize - 1;
+ maxSize = MaxByteArraySize - 1;
}
qint64 readBytes = 0;
@@ -990,40 +992,31 @@ QByteArray QIODevice::readAll()
#endif
QByteArray result;
- qint64 readBytes = 0;
- const bool sequential = d->isSequential();
-
- // flush internal read buffer
- if (!(d->openMode & Text) && !d->buffer.isEmpty()) {
- if (quint64(d->buffer.size()) >= QByteArray::MaxSize)
- return QByteArray();
- result = d->buffer.readAll();
- readBytes = result.size();
- if (!sequential)
- d->pos += readBytes;
- }
-
- qint64 theSize;
- if (sequential || (theSize = size()) == 0) {
+ qint64 readBytes = (d->isSequential() ? Q_INT64_C(0) : size());
+ if (readBytes == 0) {
// Size is unknown, read incrementally.
+ qint64 readChunkSize = qMax(d->buffer.size(), QIODEVICE_BUFFERSIZE);
qint64 readResult;
do {
- if (quint64(readBytes) + QIODEVICE_BUFFERSIZE > QByteArray::MaxSize) {
+ if (readBytes + readChunkSize >= MaxByteArraySize) {
// If resize would fail, don't read more, return what we have.
break;
}
- result.resize(readBytes + QIODEVICE_BUFFERSIZE);
- readResult = read(result.data() + readBytes, QIODEVICE_BUFFERSIZE);
- if (readResult > 0 || readBytes == 0)
+ result.resize(readBytes + readChunkSize);
+ readResult = read(result.data() + readBytes, readChunkSize);
+ if (readResult > 0 || readBytes == 0) {
readBytes += readResult;
+ readChunkSize = QIODEVICE_BUFFERSIZE;
+ }
} while (readResult > 0);
} else {
// Read it all in one go.
// If resize fails, don't read anything.
- if (quint64(readBytes + theSize - d->pos) > QByteArray::MaxSize)
+ readBytes -= d->pos;
+ if (readBytes >= MaxByteArraySize)
return QByteArray();
- result.resize(int(readBytes + theSize - d->pos));
- readBytes += read(result.data() + readBytes, result.size() - readBytes);
+ result.resize(readBytes);
+ readBytes = read(result.data(), readBytes);
}
if (readBytes <= 0)
@@ -1178,9 +1171,9 @@ QByteArray QIODevice::readLine(qint64 maxSize)
Q_UNUSED(d);
#endif
- if (quint64(maxSize) >= QByteArray::MaxSize) {
+ if (maxSize >= MaxByteArraySize) {
qWarning("QIODevice::read: maxSize argument exceeds QByteArray size limit");
- maxSize = QByteArray::MaxSize - 1;
+ maxSize = MaxByteArraySize - 1;
}
result.resize(int(maxSize));
@@ -1188,7 +1181,7 @@ QByteArray QIODevice::readLine(qint64 maxSize)
if (!result.size()) {
// If resize fails or maxSize == 0, read incrementally
if (maxSize == 0)
- maxSize = QByteArray::MaxSize - 1;
+ maxSize = MaxByteArraySize - 1;
// The first iteration needs to leave an extra byte for the terminating null
result.resize(1);
diff --git a/src/corelib/io/qiodevice.h b/src/corelib/io/qiodevice.h
index 4f45805fca..b62c8d266c 100644
--- a/src/corelib/io/qiodevice.h
+++ b/src/corelib/io/qiodevice.h
@@ -140,7 +140,7 @@ protected:
#ifdef QT_NO_QOBJECT
QIODevice(QIODevicePrivate &dd);
#else
- QIODevice(QIODevicePrivate &dd, QObject *parent = 0);
+ QIODevice(QIODevicePrivate &dd, QObject *parent = Q_NULLPTR);
#endif
virtual qint64 readData(char *data, qint64 maxlen) = 0;
virtual qint64 readLineData(char *data, qint64 maxlen);
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 1842541644..218e8b959c 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -110,7 +110,6 @@ QT_BEGIN_NAMESPACE
\ingroup io
\ingroup misc
\ingroup shared
- \mainclass
\reentrant
\since 4.6
@@ -898,6 +897,49 @@ void QProcessPrivate::cleanup()
/*!
\internal
+*/
+void QProcessPrivate::setError(QProcess::ProcessError error, const QString &description)
+{
+ processError = error;
+ if (description.isEmpty()) {
+ switch (error) {
+ case QProcess::FailedToStart:
+ errorString = QProcess::tr("Process failed to start");
+ break;
+ case QProcess::Crashed:
+ errorString = QProcess::tr("Process crashed");
+ break;
+ case QProcess::Timedout:
+ errorString = QProcess::tr("Process operation timed out");
+ break;
+ case QProcess::ReadError:
+ errorString = QProcess::tr("Error reading from process");
+ break;
+ case QProcess::WriteError:
+ errorString = QProcess::tr("Error writing to process");
+ break;
+ case QProcess::UnknownError:
+ errorString.clear();
+ break;
+ }
+ } else {
+ errorString = description;
+ }
+}
+
+/*!
+ \internal
+*/
+void QProcessPrivate::setErrorAndEmit(QProcess::ProcessError error, const QString &description)
+{
+ Q_Q(QProcess);
+ Q_ASSERT(error != QProcess::UnknownError);
+ setError(error, description);
+ emit q->error(processError);
+}
+
+/*!
+ \internal
Returns true if we emitted readyRead().
*/
bool QProcessPrivate::tryReadFromChannel(Channel *channel)
@@ -919,9 +961,7 @@ bool QProcessPrivate::tryReadFromChannel(Channel *channel)
return false;
}
if (readBytes == -1) {
- processError = QProcess::ReadError;
- q->setErrorString(QProcess::tr("Error reading from process"));
- emit q->error(processError);
+ setErrorAndEmit(QProcess::ReadError);
#if defined QPROCESS_DEBUG
qDebug("QProcessPrivate::tryReadFromChannel(%d), failed to read from the process", channel - &stdinChannel);
#endif
@@ -1005,9 +1045,7 @@ bool QProcessPrivate::_q_canWrite()
stdinChannel.buffer.nextDataBlockSize());
if (written < 0) {
closeChannel(&stdinChannel);
- processError = QProcess::WriteError;
- q->setErrorString(QProcess::tr("Error writing to process"));
- emit q->error(processError);
+ setErrorAndEmit(QProcess::WriteError);
return false;
}
@@ -1076,9 +1114,7 @@ bool QProcessPrivate::_q_processDied()
if (crashed) {
exitStatus = QProcess::CrashExit;
- processError = QProcess::Crashed;
- q->setErrorString(QProcess::tr("Process crashed"));
- emit q->error(processError);
+ setErrorAndEmit(QProcess::Crashed);
} else {
#ifdef QPROCESS_USE_SPAWN
// if we're using posix_spawn, waitForStarted always succeeds.
@@ -1086,8 +1122,8 @@ bool QProcessPrivate::_q_processDied()
// 127 if anything prevents the target program from starting.
// http://pubs.opengroup.org/onlinepubs/009695399/functions/posix_spawn.html
if (exitStatus == QProcess::NormalExit && exitCode == 127) {
- processError = QProcess::FailedToStart;
- q->setErrorString(QProcess::tr("Process failed to start (spawned process exited with code 127)"));
+ setError(QProcess::FailedToStart,
+ QProcess::tr("Process failed to start (spawned process exited with code 127)"));
}
#endif
}
@@ -1131,8 +1167,7 @@ bool QProcessPrivate::_q_startupNotification()
}
q->setProcessState(QProcess::NotRunning);
- processError = QProcess::FailedToStart;
- emit q->error(processError);
+ setErrorAndEmit(QProcess::FailedToStart);
#ifdef Q_OS_UNIX
// make sure the process manager removes this entry
waitForDeadChild();
@@ -1911,12 +1946,12 @@ qint64 QProcess::readData(char *data, qint64 maxlen)
return 1;
}
- qint64 bytesToRead = qint64(qMin(readBuffer->size(), (int)maxlen));
+ qint64 bytesToRead = qMin(readBuffer->size(), maxlen);
qint64 readSoFar = 0;
while (readSoFar < bytesToRead) {
const char *ptr = readBuffer->readPointer();
- int bytesToReadFromThisBlock = qMin<qint64>(bytesToRead - readSoFar,
- readBuffer->nextDataBlockSize());
+ qint64 bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar,
+ readBuffer->nextDataBlockSize());
memcpy(data + readSoFar, ptr, bytesToReadFromThisBlock);
readSoFar += bytesToReadFromThisBlock;
readBuffer->free(bytesToReadFromThisBlock);
@@ -1940,9 +1975,7 @@ qint64 QProcess::writeData(const char *data, qint64 len)
#if defined(Q_OS_WINCE)
Q_UNUSED(data);
Q_UNUSED(len);
- d->processError = QProcess::WriteError;
- setErrorString(tr("Error writing to process"));
- emit error(d->processError);
+ d->setErrorAndEmit(QProcess::WriteError);
return -1;
#endif
@@ -2221,9 +2254,7 @@ void QProcess::start(const QString &command, OpenMode mode)
QStringList args = parseCombinedArgString(command);
if (args.isEmpty()) {
Q_D(QProcess);
- d->processError = QProcess::FailedToStart;
- setErrorString(tr("No program defined"));
- emit error(d->processError);
+ d->setErrorAndEmit(QProcess::FailedToStart, tr("No program defined"));
return;
}
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index 078217ea0b..81b3ac81d0 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -60,9 +60,12 @@ public:
QProcessEnvironment();
QProcessEnvironment(const QProcessEnvironment &other);
~QProcessEnvironment();
+#ifdef Q_COMPILER_RVALUE_REFS
+ QProcessEnvironment &operator=(QProcessEnvironment && other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QProcessEnvironment &operator=(const QProcessEnvironment &other);
- inline void swap(QProcessEnvironment &other) { qSwap(d, other.d); }
+ void swap(QProcessEnvironment &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool operator==(const QProcessEnvironment &other) const;
inline bool operator!=(const QProcessEnvironment &other) const
@@ -104,15 +107,21 @@ public:
WriteError,
UnknownError
};
+ Q_ENUM(ProcessError)
+
enum ProcessState {
NotRunning,
Starting,
Running
};
+ Q_ENUM(ProcessState)
+
enum ProcessChannel {
StandardOutput,
StandardError
};
+ Q_ENUM(ProcessChannel)
+
enum ProcessChannelMode {
SeparateChannels,
MergedChannels,
@@ -120,16 +129,21 @@ public:
ForwardedOutputChannel,
ForwardedErrorChannel
};
+ Q_ENUM(ProcessChannelMode)
+
enum InputChannelMode {
ManagedInputChannel,
ForwardedInputChannel
};
+ Q_ENUM(InputChannelMode)
+
enum ExitStatus {
NormalExit,
CrashExit
};
+ Q_ENUM(ExitStatus)
- explicit QProcess(QObject *parent = 0);
+ explicit QProcess(QObject *parent = Q_NULLPTR);
virtual ~QProcess();
void start(const QString &program, const QStringList &arguments, OpenMode mode = ReadWrite);
@@ -208,7 +222,7 @@ public:
#if defined(Q_QDOC)
= QString()
#endif
- , qint64 *pid = 0);
+ , qint64 *pid = Q_NULLPTR);
#if !defined(Q_QDOC)
static bool startDetached(const QString &program, const QStringList &arguments); // ### Qt6: merge overloads
#endif
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index f6bd64fb87..fc6b5345d1 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -383,6 +383,8 @@ public:
qint64 writeToStdin(const char *data, qint64 maxlen);
void cleanup();
+ void setError(QProcess::ProcessError error, const QString &description = QString());
+ void setErrorAndEmit(QProcess::ProcessError error, const QString &description = QString());
#ifdef Q_OS_BLACKBERRY
QList<QSocketNotifier *> defaultNotifiers() const;
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 0fc9464f52..0d6ef9e60f 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -93,7 +93,6 @@ QT_END_NAMESPACE
#include <qfile.h>
#include <qfileinfo.h>
#include <qlist.h>
-#include <qhash.h>
#include <qmutex.h>
#include <qsemaphore.h>
#include <qsocketnotifier.h>
@@ -204,8 +203,8 @@ bool QProcessPrivate::openChannel(Channel &channel)
channel.pipe[1] = -1;
if ( (channel.pipe[0] = qt_safe_open(fname, O_RDONLY)) != -1)
return true; // success
-
- q->setErrorString(QProcess::tr("Could not open input redirection for reading"));
+ setErrorAndEmit(QProcess::FailedToStart,
+ QProcess::tr("Could not open input redirection for reading"));
} else {
int mode = O_WRONLY | O_CREAT;
if (channel.append)
@@ -217,12 +216,9 @@ bool QProcessPrivate::openChannel(Channel &channel)
if ( (channel.pipe[1] = qt_safe_open(fname, mode, 0666)) != -1)
return true; // success
- q->setErrorString(QProcess::tr("Could not open output redirection for writing"));
+ setErrorAndEmit(QProcess::FailedToStart,
+ QProcess::tr("Could not open input redirection for reading"));
}
-
- // could not open file
- processError = QProcess::FailedToStart;
- emit q->error(processError);
cleanup();
return false;
} else {
@@ -331,9 +327,7 @@ void QProcessPrivate::startProcess()
!openChannel(stdoutChannel) ||
!openChannel(stderrChannel) ||
qt_create_pipe(childStartedPipe) != 0) {
- processError = QProcess::FailedToStart;
- q->setErrorString(qt_error_string(errno));
- emit q->error(processError);
+ setErrorAndEmit(QProcess::FailedToStart, qt_error_string(errno));
cleanup();
return;
}
@@ -406,7 +400,7 @@ void QProcessPrivate::startProcess()
char **path = 0;
int pathc = 0;
if (!program.contains(QLatin1Char('/'))) {
- const QString pathEnv = QString::fromLocal8Bit(::getenv("PATH"));
+ const QString pathEnv = QString::fromLocal8Bit(qgetenv("PATH"));
if (!pathEnv.isEmpty()) {
QStringList pathEntries = pathEnv.split(QLatin1Char(':'), QString::SkipEmptyParts);
if (!pathEntries.isEmpty()) {
@@ -459,9 +453,8 @@ void QProcessPrivate::startProcess()
qDebug("fork failed: %s", qPrintable(qt_error_string(lastForkErrno)));
#endif
q->setProcessState(QProcess::NotRunning);
- processError = QProcess::FailedToStart;
- q->setErrorString(QProcess::tr("Resource error (fork failure): %1").arg(qt_error_string(lastForkErrno)));
- emit q->error(processError);
+ setErrorAndEmit(QProcess::FailedToStart,
+ QProcess::tr("Resource error (fork failure): %1").arg(qt_error_string(lastForkErrno)));
cleanup();
return;
}
@@ -809,8 +802,6 @@ void QProcessPrivate::killProcess()
bool QProcessPrivate::waitForStarted(int msecs)
{
- Q_Q(QProcess);
-
#if defined (QPROCESS_DEBUG)
qDebug("QProcessPrivate::waitForStarted(%d) waiting for child to start (fd = %d)", msecs,
childStartedPipe[0]);
@@ -820,8 +811,7 @@ bool QProcessPrivate::waitForStarted(int msecs)
FD_ZERO(&fds);
FD_SET(childStartedPipe[0], &fds);
if (qt_select_msecs(childStartedPipe[0] + 1, &fds, 0, msecs) == 0) {
- processError = QProcess::Timedout;
- q->setErrorString(QProcess::tr("Process operation timed out"));
+ setError(QProcess::Timedout);
#if defined (QPROCESS_DEBUG)
qDebug("QProcessPrivate::waitForStarted(%d) == false (timed out)", msecs);
#endif
@@ -848,7 +838,6 @@ QList<QSocketNotifier *> QProcessPrivate::defaultNotifiers() const
bool QProcessPrivate::waitForReadyRead(int msecs)
{
- Q_Q(QProcess);
#if defined (QPROCESS_DEBUG)
qDebug("QProcessPrivate::waitForReadyRead(%d)", msecs);
#endif
@@ -891,8 +880,7 @@ bool QProcessPrivate::waitForReadyRead(int msecs)
break;
}
if (ret == 0) {
- processError = QProcess::Timedout;
- q->setErrorString(QProcess::tr("Process operation timed out"));
+ setError(QProcess::Timedout);
return false;
}
@@ -928,7 +916,6 @@ bool QProcessPrivate::waitForReadyRead(int msecs)
bool QProcessPrivate::waitForBytesWritten(int msecs)
{
- Q_Q(QProcess);
#if defined (QPROCESS_DEBUG)
qDebug("QProcessPrivate::waitForBytesWritten(%d)", msecs);
#endif
@@ -973,8 +960,7 @@ bool QProcessPrivate::waitForBytesWritten(int msecs)
}
if (ret == 0) {
- processError = QProcess::Timedout;
- q->setErrorString(QProcess::tr("Process operation timed out"));
+ setError(QProcess::Timedout);
return false;
}
@@ -1003,7 +989,6 @@ bool QProcessPrivate::waitForBytesWritten(int msecs)
bool QProcessPrivate::waitForFinished(int msecs)
{
- Q_Q(QProcess);
#if defined (QPROCESS_DEBUG)
qDebug("QProcessPrivate::waitForFinished(%d)", msecs);
#endif
@@ -1047,8 +1032,7 @@ bool QProcessPrivate::waitForFinished(int msecs)
break;
}
if (ret == 0) {
- processError = QProcess::Timedout;
- q->setErrorString(QProcess::tr("Process operation timed out"));
+ setError(QProcess::Timedout);
return false;
}
@@ -1191,7 +1175,7 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
argv[arguments.size() + 1] = 0;
if (!program.contains(QLatin1Char('/'))) {
- const QString path = QString::fromLocal8Bit(::getenv("PATH"));
+ const QString path = QString::fromLocal8Bit(qgetenv("PATH"));
if (!path.isEmpty()) {
QStringList pathEntries = path.split(QLatin1Char(':'));
for (int k = 0; k < pathEntries.size(); ++k) {
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index cef961ecbd..5c9db05eff 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -217,7 +217,8 @@ bool QProcessPrivate::openChannel(Channel &channel)
if (channel.pipe[0] != INVALID_Q_PIPE)
return true;
- q->setErrorString(QProcess::tr("Could not open input redirection for reading"));
+ setErrorAndEmit(QProcess::FailedToStart,
+ QProcess::tr("Could not open input redirection for reading"));
} else {
// open in write mode
channel.pipe[0] = INVALID_Q_PIPE;
@@ -237,12 +238,9 @@ bool QProcessPrivate::openChannel(Channel &channel)
return true;
}
- q->setErrorString(QProcess::tr("Could not open output redirection for writing"));
+ setErrorAndEmit(QProcess::FailedToStart,
+ QProcess::tr("Could not open output redirection for writing"));
}
-
- // could not open file
- processError = QProcess::FailedToStart;
- emit q->error(processError);
cleanup();
return false;
} else {
@@ -504,9 +502,10 @@ void QProcessPrivate::startProcess()
environment.isEmpty() ? 0 : envlist.data(),
workingDirectory.isEmpty() ? 0 : (wchar_t*)QDir::toNativeSeparators(workingDirectory).utf16(),
&startupInfo, pid);
+ QString errorString;
if (!success) {
// Capture the error string before we do CloseHandle below
- q->setErrorString(QProcess::tr("Process failed to start: %1").arg(qt_error_string()));
+ errorString = QProcess::tr("Process failed to start: %1").arg(qt_error_string());
}
if (stdinChannel.pipe[0] != INVALID_Q_PIPE) {
@@ -524,8 +523,7 @@ void QProcessPrivate::startProcess()
if (!success) {
cleanup();
- processError = QProcess::FailedToStart;
- emit q->error(processError);
+ setErrorAndEmit(QProcess::FailedToStart, errorString);
q->setProcessState(QProcess::NotRunning);
return;
}
@@ -595,16 +593,13 @@ void QProcessPrivate::killProcess()
bool QProcessPrivate::waitForStarted(int)
{
- Q_Q(QProcess);
-
if (processStarted())
return true;
if (processError == QProcess::FailedToStart)
return false;
- processError = QProcess::Timedout;
- q->setErrorString(QProcess::tr("Process operation timed out"));
+ setError(QProcess::Timedout);
return false;
}
@@ -636,8 +631,6 @@ bool QProcessPrivate::drainOutputPipes()
bool QProcessPrivate::waitForReadyRead(int msecs)
{
- Q_Q(QProcess);
-
QIncrementalSleepTimer timer(msecs);
forever {
@@ -652,7 +645,7 @@ bool QProcessPrivate::waitForReadyRead(int msecs)
if (!pid)
return false;
- if (WaitForSingleObject(pid->hProcess, 0) == WAIT_OBJECT_0) {
+ if (WaitForSingleObjectEx(pid->hProcess, 0, false) == WAIT_OBJECT_0) {
bool readyReadEmitted = drainOutputPipes();
_q_processDied();
return readyReadEmitted;
@@ -663,15 +656,12 @@ bool QProcessPrivate::waitForReadyRead(int msecs)
break;
}
- processError = QProcess::Timedout;
- q->setErrorString(QProcess::tr("Process operation timed out"));
+ setError(QProcess::Timedout);
return false;
}
bool QProcessPrivate::waitForBytesWritten(int msecs)
{
- Q_Q(QProcess);
-
QIncrementalSleepTimer timer(msecs);
forever {
@@ -721,7 +711,7 @@ bool QProcessPrivate::waitForBytesWritten(int msecs)
// Wait for the process to signal any change in its state,
// such as incoming data, or if the process died.
- if (WaitForSingleObject(pid->hProcess, 0) == WAIT_OBJECT_0) {
+ if (WaitForSingleObjectEx(pid->hProcess, 0, false) == WAIT_OBJECT_0) {
_q_processDied();
return false;
}
@@ -731,14 +721,12 @@ bool QProcessPrivate::waitForBytesWritten(int msecs)
break;
}
- processError = QProcess::Timedout;
- q->setErrorString(QProcess::tr("Process operation timed out"));
+ setError(QProcess::Timedout);
return false;
}
bool QProcessPrivate::waitForFinished(int msecs)
{
- Q_Q(QProcess);
#if defined QPROCESS_DEBUG
qDebug("QProcessPrivate::waitForFinished(%d)", msecs);
#endif
@@ -770,8 +758,7 @@ bool QProcessPrivate::waitForFinished(int msecs)
break;
}
- processError = QProcess::Timedout;
- q->setErrorString(QProcess::tr("Process operation timed out"));
+ setError(QProcess::Timedout);
return false;
}
@@ -814,13 +801,10 @@ qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen)
bool QProcessPrivate::waitForWrite(int msecs)
{
- Q_Q(QProcess);
-
if (!stdinChannel.writer || stdinChannel.writer->waitForWrite(msecs))
return true;
- processError = QProcess::Timedout;
- q->setErrorString(QProcess::tr("Process operation timed out"));
+ setError(QProcess::Timedout);
return false;
}
diff --git a/src/corelib/io/qprocess_wince.cpp b/src/corelib/io/qprocess_wince.cpp
index 53767758c2..807472b7b2 100644
--- a/src/corelib/io/qprocess_wince.cpp
+++ b/src/corelib/io/qprocess_wince.cpp
@@ -138,8 +138,7 @@ void QProcessPrivate::startProcess()
if (!success) {
cleanup();
- processError = QProcess::FailedToStart;
- emit q->error(processError);
+ setErrorAndEmit(QProcess::FailedToStart);
q->setProcessState(QProcess::NotRunning);
return;
}
@@ -210,8 +209,7 @@ bool QProcessPrivate::waitForStarted(int)
if (processError == QProcess::FailedToStart)
return false;
- processError = QProcess::Timedout;
- q->setErrorString(QProcess::tr("Process operation timed out"));
+ setError(QProcess::Timedout);
return false;
}
@@ -251,8 +249,7 @@ bool QProcessPrivate::waitForFinished(int msecs)
if (timer.hasTimedOut())
break;
}
- processError = QProcess::Timedout;
- q->setErrorString(QProcess::tr("Process operation timed out"));
+ setError(QProcess::Timedout);
return false;
}
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 4b85645a90..345f0bd65d 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -35,7 +35,6 @@
#include "qresource_p.h"
#include "qresource_iterator_p.h"
#include "qset.h"
-#include "qhash.h"
#include "qmutex.h"
#include "qdebug.h"
#include "qlocale.h"
@@ -791,6 +790,7 @@ QStringList QResourceRoot::children(int node) const
offset += 4;
const int child_off = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
(tree[offset+2] << 8) + (tree[offset+3] << 0);
+ ret.reserve(child_count);
for(int i = child_off; i < child_off+child_count; ++i)
ret << name(i);
}
diff --git a/src/corelib/io/qsavefile.h b/src/corelib/io/qsavefile.h
index 3f5f09bf5c..085378ed4e 100644
--- a/src/corelib/io/qsavefile.h
+++ b/src/corelib/io/qsavefile.h
@@ -58,7 +58,7 @@ class Q_CORE_EXPORT QSaveFile : public QFileDevice
public:
explicit QSaveFile(const QString &name);
- explicit QSaveFile(QObject *parent = 0);
+ explicit QSaveFile(QObject *parent = Q_NULLPTR);
explicit QSaveFile(const QString &name, QObject *parent);
~QSaveFile();
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 413f5693f0..b61cba7f7d 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -299,7 +299,7 @@ QSettingsPrivate *QSettingsPrivate::create(const QString &fileName, QSettings::F
}
#endif
-void QSettingsPrivate::processChild(QString key, ChildSpec spec, QMap<QString, QString> &result)
+void QSettingsPrivate::processChild(QStringRef key, ChildSpec spec, QStringList &result)
{
if (spec != AllKeys) {
int slashPos = key.indexOf(QLatin1Char('/'));
@@ -312,7 +312,7 @@ void QSettingsPrivate::processChild(QString key, ChildSpec spec, QMap<QString, Q
key.truncate(slashPos);
}
}
- result.insert(key, QString());
+ result.append(key.toString());
}
void QSettingsPrivate::beginGroupOrArray(const QSettingsGroup &group)
@@ -357,6 +357,7 @@ void QSettingsPrivate::requestUpdate()
QStringList QSettingsPrivate::variantListToStringList(const QVariantList &l)
{
QStringList result;
+ result.reserve(l.count());
QVariantList::const_iterator it = l.constBegin();
for (; it != l.constEnd(); ++it)
result.append(variantToString(*it));
@@ -374,7 +375,9 @@ QVariant QSettingsPrivate::stringListToVariantList(const QStringList &l)
outStringList[i].remove(0, 1);
} else {
QVariantList variantList;
- for (int j = 0; j < l.count(); ++j)
+ const int stringCount = l.count();
+ variantList.reserve(stringCount);
+ for (int j = 0; j < stringCount; ++j)
variantList.append(stringToVariant(l.at(j)));
return variantList;
}
@@ -1052,12 +1055,12 @@ static void initDefaultPaths(QMutexLocker *locker)
// Non XDG platforms (OS X, iOS, Blackberry, Android...) have used this code path erroneously
// for some time now. Moving away from that would require migrating existing settings.
QString userPath;
- char *env = getenv("XDG_CONFIG_HOME");
- if (env == 0) {
+ QByteArray env = qgetenv("XDG_CONFIG_HOME");
+ if (env.isEmpty()) {
userPath = QDir::homePath();
userPath += QLatin1Char('/');
userPath += QLatin1String(".config");
- } else if (*env == '/') {
+ } else if (env.startsWith('/')) {
userPath = QFile::decodeName(env);
} else {
userPath = QDir::homePath();
@@ -1269,7 +1272,7 @@ bool QConfFileSettingsPrivate::get(const QString &key, QVariant *value) const
QStringList QConfFileSettingsPrivate::children(const QString &prefix, ChildSpec spec) const
{
- QMap<QString, QString> result;
+ QStringList result;
ParsedSettingsMap::const_iterator j;
QSettingsKey thePrefix(prefix, caseSensitivity);
@@ -1289,14 +1292,14 @@ QStringList QConfFileSettingsPrivate::children(const QString &prefix, ChildSpec
&confFile->originalKeys)->lowerBound( thePrefix);
while (j != confFile->originalKeys.constEnd() && j.key().startsWith(thePrefix)) {
if (!confFile->removedKeys.contains(j.key()))
- processChild(j.key().originalCaseKey().mid(startPos), spec, result);
+ processChild(j.key().originalCaseKey().midRef(startPos), spec, result);
++j;
}
j = const_cast<const ParsedSettingsMap *>(
&confFile->addedKeys)->lowerBound(thePrefix);
while (j != confFile->addedKeys.constEnd() && j.key().startsWith(thePrefix)) {
- processChild(j.key().originalCaseKey().mid(startPos), spec, result);
+ processChild(j.key().originalCaseKey().midRef(startPos), spec, result);
++j;
}
@@ -1304,7 +1307,10 @@ QStringList QConfFileSettingsPrivate::children(const QString &prefix, ChildSpec
break;
}
}
- return result.keys();
+ std::sort(result.begin(), result.end());
+ result.erase(std::unique(result.begin(), result.end()),
+ result.end());
+ return result;
}
void QConfFileSettingsPrivate::clear()
diff --git a/src/corelib/io/qsettings.h b/src/corelib/io/qsettings.h
index f7a7bdbb19..8f41273ffa 100644
--- a/src/corelib/io/qsettings.h
+++ b/src/corelib/io/qsettings.h
@@ -105,13 +105,13 @@ public:
#ifndef QT_NO_QOBJECT
explicit QSettings(const QString &organization,
- const QString &application = QString(), QObject *parent = 0);
+ const QString &application = QString(), QObject *parent = Q_NULLPTR);
QSettings(Scope scope, const QString &organization,
- const QString &application = QString(), QObject *parent = 0);
+ const QString &application = QString(), QObject *parent = Q_NULLPTR);
QSettings(Format format, Scope scope, const QString &organization,
- const QString &application = QString(), QObject *parent = 0);
- QSettings(const QString &fileName, Format format, QObject *parent = 0);
- explicit QSettings(QObject *parent = 0);
+ const QString &application = QString(), QObject *parent = Q_NULLPTR);
+ QSettings(const QString &fileName, Format format, QObject *parent = Q_NULLPTR);
+ explicit QSettings(QObject *parent = Q_NULLPTR);
#else
explicit QSettings(const QString &organization,
const QString &application = QString());
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index 51321c49e7..1ad198b990 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -491,7 +491,7 @@ bool QMacSettingsPrivate::get(const QString &key, QVariant *value) const
QStringList QMacSettingsPrivate::children(const QString &prefix, ChildSpec spec) const
{
- QMap<QString, QString> result;
+ QStringList result;
int startPos = prefix.size();
for (int i = 0; i < numDomains; ++i) {
@@ -505,7 +505,7 @@ QStringList QMacSettingsPrivate::children(const QString &prefix, ChildSpec spec)
QString currentKey =
qtKey(static_cast<CFStringRef>(CFArrayGetValueAtIndex(cfarray, k)));
if (currentKey.startsWith(prefix))
- processChild(currentKey.mid(startPos), spec, result);
+ processChild(currentKey.midRef(startPos), spec, result);
}
}
}
@@ -513,7 +513,10 @@ QStringList QMacSettingsPrivate::children(const QString &prefix, ChildSpec spec)
if (!fallbacks)
break;
}
- return result.keys();
+ std::sort(result.begin(), result.end());
+ result.erase(std::unique(result.begin(), result.end()),
+ result.end());
+ return result;
}
void QMacSettingsPrivate::clear()
diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h
index 93d63fd411..534527ed5a 100644
--- a/src/corelib/io/qsettings_p.h
+++ b/src/corelib/io/qsettings_p.h
@@ -211,7 +211,7 @@ public:
const QString &organization, const QString &application);
static QSettingsPrivate *create(const QString &fileName, QSettings::Format format);
- static void processChild(QString key, ChildSpec spec, QMap<QString, QString> &result);
+ static void processChild(QStringRef key, ChildSpec spec, QStringList &result);
// Variant streaming functions
static QStringList variantListToStringList(const QVariantList &l);
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index 74252d1f0a..04848a38e5 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -35,7 +35,6 @@
#include <qdir.h>
#include <qfileinfo.h>
-#include <qhash.h>
#ifndef QT_BOOTSTRAPPED
#include <qobject.h>
@@ -523,13 +522,8 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr
QStringList searchPaths = paths;
if (paths.isEmpty()) {
QByteArray pEnv = qgetenv("PATH");
-#if defined(Q_OS_WIN)
- const QLatin1Char pathSep(';');
-#else
- const QLatin1Char pathSep(':');
-#endif
// Remove trailing slashes, which occur on Windows.
- const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(pathSep, QString::SkipEmptyParts);
+ const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(QDir::listSeparator(), QString::SkipEmptyParts);
searchPaths.reserve(rawPaths.size());
foreach (const QString &rawPath, rawPaths) {
QString cleanPath = QDir::cleanPath(rawPath);
diff --git a/src/corelib/io/qstorageinfo.h b/src/corelib/io/qstorageinfo.h
index 848278e69f..b9d694cb14 100644
--- a/src/corelib/io/qstorageinfo.h
+++ b/src/corelib/io/qstorageinfo.h
@@ -55,11 +55,10 @@ public:
QStorageInfo &operator=(const QStorageInfo &other);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QStorageInfo &operator=(QStorageInfo &&other)
- { qSwap(d, other.d); return *this; }
+ QStorageInfo &operator=(QStorageInfo &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- inline void swap(QStorageInfo &other)
+ inline void swap(QStorageInfo &other) Q_DECL_NOTHROW
{ qSwap(d, other.d); }
void setPath(const QString &path);
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index d170e7c0c0..f82d0ff0a1 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -49,7 +49,7 @@
# include <sys/mount.h>
# include <sys/vfs.h>
# include <mntent.h>
-#elif defined(Q_OS_LINUX)
+#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD)
# include <mntent.h>
# include <sys/statvfs.h>
#elif defined(Q_OS_SOLARIS)
@@ -145,7 +145,7 @@ private:
QByteArray m_rootPath;
QByteArray m_fileSystemType;
QByteArray m_device;
-#elif defined(Q_OS_LINUX)
+#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD)
FILE *fp;
mntent mnt;
QByteArray buffer;
@@ -287,10 +287,11 @@ inline QByteArray QStorageIterator::device() const
return m_device;
}
-#elif defined(Q_OS_LINUX)
+#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD)
static const char pathMounted[] = "/etc/mtab";
-static const int bufferSize = 3*PATH_MAX; // 2 paths (mount point+device) and metainfo
+static const int bufferSize = 1024; // 2 paths (mount point+device) and metainfo;
+ // should be enough
inline QStorageIterator::QStorageIterator() :
buffer(QByteArray(bufferSize, 0))
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 556bc6e760..bdf4392275 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -236,9 +236,9 @@ QTemporaryFileEngine::~QTemporaryFileEngine()
QFSFileEngine::close();
}
-bool QTemporaryFileEngine::isReallyOpen()
+bool QTemporaryFileEngine::isReallyOpen() const
{
- Q_D(QFSFileEngine);
+ Q_D(const QFSFileEngine);
if (!((0 == d->fh) && (-1 == d->fd)
#if defined Q_OS_WIN
diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h
index 475298f264..341ae9bd3f 100644
--- a/src/corelib/io/qtemporaryfile_p.h
+++ b/src/corelib/io/qtemporaryfile_p.h
@@ -95,7 +95,7 @@ public:
~QTemporaryFileEngine();
- bool isReallyOpen();
+ bool isReallyOpen() const;
void setFileName(const QString &file);
void setFileTemplate(const QString &fileTemplate);
diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp
index 2e787a1bc5..d68d0ddf46 100644
--- a/src/corelib/io/qtldurl.cpp
+++ b/src/corelib/io/qtldurl.cpp
@@ -37,7 +37,6 @@
#include "private/qtldurl_p.h"
#include "QtCore/qstring.h"
#include "QtCore/qvector.h"
-#include "QtCore/qhash.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/io/qurlquery.cpp b/src/corelib/io/qurlquery.cpp
index 77d1ab3e24..2b695a4f7b 100644
--- a/src/corelib/io/qurlquery.cpp
+++ b/src/corelib/io/qurlquery.cpp
@@ -34,6 +34,7 @@
#include "qurlquery.h"
#include "qurl_p.h"
+#include <QtCore/qhashfunctions.h>
#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
@@ -407,6 +408,7 @@ bool QUrlQuery::operator ==(const QUrlQuery &other) const
if (d == other.d)
return true;
if (d && other.d)
+ // keep in sync with qHash(QUrlQuery):
return d->valueDelimiter == other.d->valueDelimiter &&
d->pairDelimiter == other.d->pairDelimiter &&
d->itemList == other.d->itemList;
@@ -414,6 +416,25 @@ bool QUrlQuery::operator ==(const QUrlQuery &other) const
}
/*!
+ \since 5.6
+ \relates QUrlQuery
+
+ Returns the hash value for \a key,
+ using \a seed to seed the calculation.
+*/
+uint qHash(const QUrlQuery &key, uint seed) Q_DECL_NOTHROW
+{
+ if (const QUrlQueryPrivate *d = key.d) {
+ QtPrivate::QHashCombine hash;
+ // keep in sync with operator==:
+ seed = hash(seed, d->valueDelimiter);
+ seed = hash(seed, d->pairDelimiter);
+ seed = hash(seed, d->itemList);
+ }
+ return seed;
+}
+
+/*!
Returns \c true if this QUrlQuery object contains no key-value pairs, such as
after being default-constructed or after parsing an empty query string.
@@ -621,6 +642,7 @@ QList<QPair<QString, QString> > QUrlQuery::queryItems(QUrl::ComponentFormattingO
QList<QPair<QString, QString> > result;
Map::const_iterator it = d->itemList.constBegin();
Map::const_iterator end = d->itemList.constEnd();
+ result.reserve(d->itemList.count());
for ( ; it != end; ++it)
result << qMakePair(d->recodeToUser(it->first, encoding),
d->recodeToUser(it->second, encoding));
diff --git a/src/corelib/io/qurlquery.h b/src/corelib/io/qurlquery.h
index 77a0b4a82d..ae3a79c119 100644
--- a/src/corelib/io/qurlquery.h
+++ b/src/corelib/io/qurlquery.h
@@ -44,6 +44,8 @@
QT_BEGIN_NAMESPACE
+Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed = 0) Q_DECL_NOTHROW;
+
class QUrlQueryPrivate;
class Q_CORE_EXPORT QUrlQuery
{
@@ -54,8 +56,7 @@ public:
QUrlQuery(const QUrlQuery &other);
QUrlQuery &operator=(const QUrlQuery &other);
#ifdef Q_COMPILER_RVALUE_REFS
- QUrlQuery &operator=(QUrlQuery &&other)
- { qSwap(d, other.d); return *this; }
+ QUrlQuery &operator=(QUrlQuery &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
~QUrlQuery();
@@ -63,7 +64,7 @@ public:
bool operator!=(const QUrlQuery &other) const
{ return !(*this == other); }
- void swap(QUrlQuery &other) { qSwap(d, other.d); }
+ void swap(QUrlQuery &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool isEmpty() const;
bool isDetached() const;
@@ -95,6 +96,7 @@ public:
private:
friend class QUrl;
+ friend Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed) Q_DECL_NOTHROW;
QSharedDataPointer<QUrlQueryPrivate> d;
public:
typedef QSharedDataPointer<QUrlQueryPrivate> DataPtr;
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
index 14aad0e193..2cc5741250 100644
--- a/src/corelib/io/qwindowspipereader.cpp
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -136,12 +136,12 @@ qint64 QWindowsPipeReader::read(char *data, qint64 maxlen)
actualReadBufferSize--;
readSoFar = 1;
} else {
- qint64 bytesToRead = qMin(qint64(actualReadBufferSize), maxlen);
+ qint64 bytesToRead = qMin(actualReadBufferSize, maxlen);
readSoFar = 0;
while (readSoFar < bytesToRead) {
const char *ptr = readBuffer.readPointer();
- int bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar,
- qint64(readBuffer.nextDataBlockSize()));
+ qint64 bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar,
+ readBuffer.nextDataBlockSize());
memcpy(data + readSoFar, ptr, bytesToReadFromThisBlock);
readSoFar += bytesToReadFromThisBlock;
readBuffer.free(bytesToReadFromThisBlock);
diff --git a/src/corelib/io/qwindowspipereader_p.h b/src/corelib/io/qwindowspipereader_p.h
index 2c32eeb9ce..c8a66d9511 100644
--- a/src/corelib/io/qwindowspipereader_p.h
+++ b/src/corelib/io/qwindowspipereader_p.h
@@ -96,7 +96,7 @@ private:
QWinOverlappedIoNotifier *dataReadNotifier;
qint64 readBufferMaxSize;
QRingBuffer readBuffer;
- int actualReadBufferSize;
+ qint64 actualReadBufferSize;
bool stopped;
bool readSequenceStarted;
bool pipeBroken;
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 60ac75133c..90297b9115 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -479,6 +479,11 @@ public:
Q_GLOBAL_STATIC(QEmptyItemModel, qEmptyModel)
+
+QAbstractItemModelPrivate::~QAbstractItemModelPrivate()
+{
+}
+
QAbstractItemModel *QAbstractItemModelPrivate::staticEmptyModel()
{
return qEmptyModel();
@@ -3217,6 +3222,7 @@ QModelIndexList QAbstractItemModel::persistentIndexList() const
{
Q_D(const QAbstractItemModel);
QModelIndexList result;
+ result.reserve(d->persistent.indexes.count());
for (QHash<QModelIndex, QPersistentModelIndexData *>::const_iterator it = d->persistent.indexes.constBegin();
it != d->persistent.indexes.constEnd(); ++it) {
QPersistentModelIndexData *data = *it;
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index 5ca7bd0123..096e67c513 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -49,7 +49,7 @@ class Q_CORE_EXPORT QModelIndex
{
friend class QAbstractItemModel;
public:
- Q_DECL_CONSTEXPR inline QModelIndex() Q_DECL_NOTHROW : r(-1), c(-1), i(0), m(0) {}
+ Q_DECL_CONSTEXPR inline QModelIndex() Q_DECL_NOTHROW : r(-1), c(-1), i(0), m(Q_NULLPTR) {}
// compiler-generated copy/move ctors/assignment operators are fine!
Q_DECL_CONSTEXPR inline int row() const Q_DECL_NOTHROW { return r; }
Q_DECL_CONSTEXPR inline int column() const Q_DECL_NOTHROW { return c; }
@@ -61,7 +61,7 @@ public:
inline QVariant data(int role = Qt::DisplayRole) const;
inline Qt::ItemFlags flags() const;
Q_DECL_CONSTEXPR inline const QAbstractItemModel *model() const Q_DECL_NOTHROW { return m; }
- Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW { return (r >= 0) && (c >= 0) && (m != 0); }
+ Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW { return (r >= 0) && (c >= 0) && (m != Q_NULLPTR); }
Q_DECL_CONSTEXPR inline bool operator==(const QModelIndex &other) const Q_DECL_NOTHROW
{ return (other.r == r) && (other.i == i) && (other.c == c) && (other.m == m); }
Q_DECL_CONSTEXPR inline bool operator!=(const QModelIndex &other) const Q_DECL_NOTHROW
@@ -161,7 +161,7 @@ class Q_CORE_EXPORT QAbstractItemModel : public QObject
friend class QIdentityProxyModel;
public:
- explicit QAbstractItemModel(QObject *parent = 0);
+ explicit QAbstractItemModel(QObject *parent = Q_NULLPTR);
virtual ~QAbstractItemModel();
Q_INVOKABLE bool hasIndex(int row, int column, const QModelIndex &parent = QModelIndex()) const;
@@ -276,9 +276,9 @@ protected Q_SLOTS:
void resetInternalData();
protected:
- QAbstractItemModel(QAbstractItemModelPrivate &dd, QObject *parent = 0);
+ QAbstractItemModel(QAbstractItemModelPrivate &dd, QObject *parent = Q_NULLPTR);
- inline QModelIndex createIndex(int row, int column, void *data = 0) const;
+ inline QModelIndex createIndex(int row, int column, void *data = Q_NULLPTR) const;
inline QModelIndex createIndex(int row, int column, quintptr id) const;
void encodeData(const QModelIndexList &indexes, QDataStream &stream) const;
@@ -357,7 +357,7 @@ class Q_CORE_EXPORT QAbstractTableModel : public QAbstractItemModel
Q_OBJECT
public:
- explicit QAbstractTableModel(QObject *parent = 0);
+ explicit QAbstractTableModel(QObject *parent = Q_NULLPTR);
~QAbstractTableModel();
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
@@ -383,7 +383,7 @@ class Q_CORE_EXPORT QAbstractListModel : public QAbstractItemModel
Q_OBJECT
public:
- explicit QAbstractListModel(QObject *parent = 0);
+ explicit QAbstractListModel(QObject *parent = Q_NULLPTR);
~QAbstractListModel();
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
@@ -420,7 +420,7 @@ inline QVariant QModelIndex::data(int arole) const
{ return m ? m->data(*this, arole) : QVariant(); }
inline Qt::ItemFlags QModelIndex::flags() const
-{ return m ? m->flags(*this) : Qt::ItemFlags(0); }
+{ return m ? m->flags(*this) : Qt::ItemFlags(); }
inline uint qHash(const QModelIndex &index) Q_DECL_NOTHROW
{ return uint((index.row() << 4) + index.column() + index.internalId()); }
diff --git a/src/corelib/itemmodels/qabstractitemmodel_p.h b/src/corelib/itemmodels/qabstractitemmodel_p.h
index 075e6a9018..acf376eff1 100644
--- a/src/corelib/itemmodels/qabstractitemmodel_p.h
+++ b/src/corelib/itemmodels/qabstractitemmodel_p.h
@@ -71,6 +71,8 @@ class Q_CORE_EXPORT QAbstractItemModelPrivate : public QObjectPrivate
public:
QAbstractItemModelPrivate() : QObjectPrivate(), supportedDragActions(-1), roleNames(defaultRoleNames()) {}
+ ~QAbstractItemModelPrivate();
+
void removePersistentIndexData(QPersistentModelIndexData *data);
void movePersistentIndexes(const QVector<QPersistentModelIndexData *> &indexes, int change, const QModelIndex &parent, Qt::Orientation orientation);
void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last);
diff --git a/src/corelib/itemmodels/qabstractproxymodel.cpp b/src/corelib/itemmodels/qabstractproxymodel.cpp
index 4d08306d28..dbbbbb8ff4 100644
--- a/src/corelib/itemmodels/qabstractproxymodel.cpp
+++ b/src/corelib/itemmodels/qabstractproxymodel.cpp
@@ -379,6 +379,7 @@ QMimeData* QAbstractProxyModel::mimeData(const QModelIndexList &indexes) const
{
Q_D(const QAbstractProxyModel);
QModelIndexList list;
+ list.reserve(indexes.count());
foreach(const QModelIndex &index, indexes)
list << mapToSource(index);
return d->model->mimeData(list);
diff --git a/src/corelib/itemmodels/qabstractproxymodel.h b/src/corelib/itemmodels/qabstractproxymodel.h
index dc8d2d4dc8..a4cb74830b 100644
--- a/src/corelib/itemmodels/qabstractproxymodel.h
+++ b/src/corelib/itemmodels/qabstractproxymodel.h
@@ -50,7 +50,7 @@ class Q_CORE_EXPORT QAbstractProxyModel : public QAbstractItemModel
Q_PROPERTY(QAbstractItemModel* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged)
public:
- explicit QAbstractProxyModel(QObject *parent = 0);
+ explicit QAbstractProxyModel(QObject *parent = Q_NULLPTR);
~QAbstractProxyModel();
virtual void setSourceModel(QAbstractItemModel *sourceModel);
diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp
index f773219aeb..f46fd135ca 100644
--- a/src/corelib/itemmodels/qidentityproxymodel.cpp
+++ b/src/corelib/itemmodels/qidentityproxymodel.cpp
@@ -212,6 +212,7 @@ QItemSelection QIdentityProxyModel::mapSelectionFromSource(const QItemSelection&
QItemSelection::const_iterator it = selection.constBegin();
const QItemSelection::const_iterator end = selection.constEnd();
+ proxySelection.reserve(selection.count());
for ( ; it != end; ++it) {
Q_ASSERT(it->model() == d->model);
const QItemSelectionRange range(mapFromSource(it->topLeft()), mapFromSource(it->bottomRight()));
@@ -234,6 +235,7 @@ QItemSelection QIdentityProxyModel::mapSelectionToSource(const QItemSelection& s
QItemSelection::const_iterator it = selection.constBegin();
const QItemSelection::const_iterator end = selection.constEnd();
+ sourceSelection.reserve(selection.count());
for ( ; it != end; ++it) {
Q_ASSERT(it->model() == this);
const QItemSelectionRange range(mapToSource(it->topLeft()), mapToSource(it->bottomRight()));
@@ -269,6 +271,7 @@ QModelIndexList QIdentityProxyModel::match(const QModelIndex& start, int role, c
QModelIndexList::const_iterator it = sourceList.constBegin();
const QModelIndexList::const_iterator end = sourceList.constEnd();
QModelIndexList proxyList;
+ proxyList.reserve(sourceList.count());
for ( ; it != end; ++it)
proxyList.append(mapFromSource(*it));
return proxyList;
diff --git a/src/corelib/itemmodels/qidentityproxymodel.h b/src/corelib/itemmodels/qidentityproxymodel.h
index e4587cb386..7578f8d380 100644
--- a/src/corelib/itemmodels/qidentityproxymodel.h
+++ b/src/corelib/itemmodels/qidentityproxymodel.h
@@ -48,7 +48,7 @@ class Q_CORE_EXPORT QIdentityProxyModel : public QAbstractProxyModel
{
Q_OBJECT
public:
- explicit QIdentityProxyModel(QObject* parent = 0);
+ explicit QIdentityProxyModel(QObject* parent = Q_NULLPTR);
~QIdentityProxyModel();
int columnCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h
index 4fe836c098..1d98110a4e 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.h
+++ b/src/corelib/itemmodels/qitemselectionmodel.h
@@ -170,7 +170,7 @@ public:
Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)
Q_FLAG(SelectionFlags)
- explicit QItemSelectionModel(QAbstractItemModel *model = 0);
+ explicit QItemSelectionModel(QAbstractItemModel *model = Q_NULLPTR);
explicit QItemSelectionModel(QAbstractItemModel *model, QObject *parent);
virtual ~QItemSelectionModel();
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
index 38f8dfa788..4ee37defae 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -272,6 +272,7 @@ public:
QModelIndexPairList store_persistent_indexes();
void update_persistent_indexes(const QModelIndexPairList &source_indexes);
+ void filter_about_to_be_changed(const QModelIndex &source_parent = QModelIndex());
void filter_changed(const QModelIndex &source_parent = QModelIndex());
QSet<int> handle_filter_changed(
QVector<int> &source_to_proxy, QVector<int> &proxy_to_source,
@@ -1011,6 +1012,7 @@ QModelIndexPairList QSortFilterProxyModelPrivate::store_persistent_indexes()
{
Q_Q(QSortFilterProxyModel);
QModelIndexPairList source_indexes;
+ source_indexes.reserve(persistent.indexes.count());
foreach (QPersistentModelIndexData *data, persistent.indexes) {
QModelIndex proxy_index = data->index;
QModelIndex source_index = q->mapToSource(proxy_index);
@@ -1030,7 +1032,10 @@ void QSortFilterProxyModelPrivate::update_persistent_indexes(
{
Q_Q(QSortFilterProxyModel);
QModelIndexList from, to;
- for (int i = 0; i < source_indexes.count(); ++i) {
+ const int numSourceIndexes = source_indexes.count();
+ from.reserve(numSourceIndexes);
+ to.reserve(numSourceIndexes);
+ for (int i = 0; i < numSourceIndexes; ++i) {
QModelIndex source_index = source_indexes.at(i).second;
QModelIndex old_proxy_index = source_indexes.at(i).first;
create_mapping(source_index.parent());
@@ -1041,6 +1046,19 @@ void QSortFilterProxyModelPrivate::update_persistent_indexes(
q->changePersistentIndexList(from, to);
}
+/*!
+ \internal
+
+ Updates the source_index mapping in case it's invalid and we
+ need it because we have a valid filter
+*/
+void QSortFilterProxyModelPrivate::filter_about_to_be_changed(const QModelIndex &source_parent)
+{
+ if (!filter_regexp.pattern().isEmpty() &&
+ source_index_mapping.constFind(source_parent) == source_index_mapping.constEnd())
+ create_mapping(source_parent);
+}
+
/*!
\internal
@@ -2013,7 +2031,9 @@ QMimeData *QSortFilterProxyModel::mimeData(const QModelIndexList &indexes) const
{
Q_D(const QSortFilterProxyModel);
QModelIndexList source_indexes;
- for (int i = 0; i < indexes.count(); ++i)
+ const int numIndexes = indexes.count();
+ source_indexes.reserve(numIndexes);
+ for (int i = 0; i < numIndexes; ++i)
source_indexes << mapToSource(indexes.at(i));
return d->model->mimeData(source_indexes);
}
@@ -2108,6 +2128,7 @@ bool QSortFilterProxyModel::removeRows(int row, int count, const QModelIndex &pa
// remove corresponding source intervals
// ### if this proves to be slow, we can switch to single-row removal
QVector<int> rows;
+ rows.reserve(count);
for (int i = row; i < row + count; ++i)
rows.append(m->source_rows.at(i));
std::sort(rows.begin(), rows.end());
@@ -2147,6 +2168,7 @@ bool QSortFilterProxyModel::removeColumns(int column, int count, const QModelInd
}
// remove corresponding source intervals
QVector<int> columns;
+ columns.reserve(count);
for (int i = column; i < column + count; ++i)
columns.append(m->source_columns.at(i));
@@ -2298,6 +2320,7 @@ QRegExp QSortFilterProxyModel::filterRegExp() const
void QSortFilterProxyModel::setFilterRegExp(const QRegExp &regExp)
{
Q_D(QSortFilterProxyModel);
+ d->filter_about_to_be_changed();
d->filter_regexp = regExp;
d->filter_changed();
}
@@ -2319,6 +2342,7 @@ int QSortFilterProxyModel::filterKeyColumn() const
void QSortFilterProxyModel::setFilterKeyColumn(int column)
{
Q_D(QSortFilterProxyModel);
+ d->filter_about_to_be_changed();
d->filter_column = column;
d->filter_changed();
}
@@ -2344,6 +2368,7 @@ void QSortFilterProxyModel::setFilterCaseSensitivity(Qt::CaseSensitivity cs)
Q_D(QSortFilterProxyModel);
if (cs == d->filter_regexp.caseSensitivity())
return;
+ d->filter_about_to_be_changed();
d->filter_regexp.setCaseSensitivity(cs);
d->filter_changed();
}
@@ -2409,6 +2434,7 @@ void QSortFilterProxyModel::setSortLocaleAware(bool on)
void QSortFilterProxyModel::setFilterRegExp(const QString &pattern)
{
Q_D(QSortFilterProxyModel);
+ d->filter_about_to_be_changed();
d->filter_regexp.setPatternSyntax(QRegExp::RegExp);
d->filter_regexp.setPattern(pattern);
d->filter_changed();
@@ -2423,6 +2449,7 @@ void QSortFilterProxyModel::setFilterRegExp(const QString &pattern)
void QSortFilterProxyModel::setFilterWildcard(const QString &pattern)
{
Q_D(QSortFilterProxyModel);
+ d->filter_about_to_be_changed();
d->filter_regexp.setPatternSyntax(QRegExp::Wildcard);
d->filter_regexp.setPattern(pattern);
d->filter_changed();
@@ -2437,6 +2464,7 @@ void QSortFilterProxyModel::setFilterWildcard(const QString &pattern)
void QSortFilterProxyModel::setFilterFixedString(const QString &pattern)
{
Q_D(QSortFilterProxyModel);
+ d->filter_about_to_be_changed();
d->filter_regexp.setPatternSyntax(QRegExp::FixedString);
d->filter_regexp.setPattern(pattern);
d->filter_changed();
@@ -2516,6 +2544,7 @@ void QSortFilterProxyModel::setFilterRole(int role)
Q_D(QSortFilterProxyModel);
if (d->filter_role == role)
return;
+ d->filter_about_to_be_changed();
d->filter_role = role;
d->filter_changed();
}
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.h b/src/corelib/itemmodels/qsortfilterproxymodel.h
index a08d7c6416..4be5aedd48 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.h
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.h
@@ -63,7 +63,7 @@ class Q_CORE_EXPORT QSortFilterProxyModel : public QAbstractProxyModel
Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole)
public:
- explicit QSortFilterProxyModel(QObject *parent = 0);
+ explicit QSortFilterProxyModel(QObject *parent = Q_NULLPTR);
~QSortFilterProxyModel();
void setSourceModel(QAbstractItemModel *sourceModel) Q_DECL_OVERRIDE;
diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp
index 2853be3fda..dad736b445 100644
--- a/src/corelib/itemmodels/qstringlistmodel.cpp
+++ b/src/corelib/itemmodels/qstringlistmodel.cpp
@@ -257,7 +257,9 @@ void QStringListModel::sort(int, Qt::SortOrder order)
emit layoutAboutToBeChanged(QList<QPersistentModelIndex>(), VerticalSortHint);
QList<QPair<QString, int> > list;
- for (int i = 0; i < lst.count(); ++i)
+ const int lstCount = lst.count();
+ list.reserve(lstCount);
+ for (int i = 0; i < lstCount; ++i)
list.append(QPair<QString, int>(lst.at(i), i));
if (order == Qt::AscendingOrder)
diff --git a/src/corelib/itemmodels/qstringlistmodel.h b/src/corelib/itemmodels/qstringlistmodel.h
index 973007995b..a1cb923dbb 100644
--- a/src/corelib/itemmodels/qstringlistmodel.h
+++ b/src/corelib/itemmodels/qstringlistmodel.h
@@ -46,8 +46,8 @@ class Q_CORE_EXPORT QStringListModel : public QAbstractListModel
{
Q_OBJECT
public:
- explicit QStringListModel(QObject *parent = 0);
- explicit QStringListModel(const QStringList &strings, QObject *parent = 0);
+ explicit QStringListModel(QObject *parent = Q_NULLPTR);
+ explicit QStringListModel(const QStringList &strings, QObject *parent = Q_NULLPTR);
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
QModelIndex sibling(int row, int column, const QModelIndex &idx) const Q_DECL_OVERRIDE;
diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp
index 77a3d0a2b8..dd27603d6d 100644
--- a/src/corelib/json/qjsonarray.cpp
+++ b/src/corelib/json/qjsonarray.cpp
@@ -271,6 +271,7 @@ QVariantList QJsonArray::toVariantList() const
QVariantList list;
if (a) {
+ list.reserve(a->length);
for (int i = 0; i < (int)a->length; ++i)
list.append(QJsonValue(d, a, a->at(i)).toVariant());
}
diff --git a/src/corelib/json/qjsonarray.h b/src/corelib/json/qjsonarray.h
index 6148642106..311753d977 100644
--- a/src/corelib/json/qjsonarray.h
+++ b/src/corelib/json/qjsonarray.h
@@ -107,7 +107,7 @@ public:
typedef QJsonValueRef reference;
typedef QJsonValueRefPtr pointer;
- inline iterator() : a(0), i(0) { }
+ inline iterator() : a(Q_NULLPTR), i(0) { }
explicit inline iterator(QJsonArray *array, int index) : a(array), i(index) { }
inline QJsonValueRef operator*() const { return QJsonValueRef(a, i); }
@@ -152,7 +152,7 @@ public:
typedef QJsonValue reference;
typedef QJsonValuePtr pointer;
- inline const_iterator() : a(0), i(0) { }
+ inline const_iterator() : a(Q_NULLPTR), i(0) { }
explicit inline const_iterator(const QJsonArray *array, int index) : a(array), i(index) { }
inline const_iterator(const const_iterator &o) : a(o.a), i(o.i) {}
inline const_iterator(const iterator &o) : a(o.a), i(o.i) {}
diff --git a/src/corelib/json/qjsondocument.h b/src/corelib/json/qjsondocument.h
index 285b42c6c8..d7a88b2f15 100644
--- a/src/corelib/json/qjsondocument.h
+++ b/src/corelib/json/qjsondocument.h
@@ -106,7 +106,7 @@ public:
Compact
};
- static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = 0);
+ static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = Q_NULLPTR);
#ifdef Q_QDOC
QByteArray toJson(JsonFormat format = Indented) const;
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp
index ae44cd9ff9..b7dfe88434 100644
--- a/src/corelib/json/qjsonobject.cpp
+++ b/src/corelib/json/qjsonobject.cpp
@@ -274,7 +274,7 @@ QStringList QJsonObject::keys() const
return QStringList();
QStringList keys;
-
+ keys.reserve(o->length);
for (uint i = 0; i < o->length; ++i) {
QJsonPrivate::Entry *e = o->entryAt(i);
keys.append(e->key());
diff --git a/src/corelib/json/qjsonobject.h b/src/corelib/json/qjsonobject.h
index 5f24ac3ac8..19c938fd83 100644
--- a/src/corelib/json/qjsonobject.h
+++ b/src/corelib/json/qjsonobject.h
@@ -105,7 +105,7 @@ public:
typedef QJsonValue value_type;
typedef QJsonValueRef reference;
- Q_DECL_CONSTEXPR inline iterator() : o(0), i(0) {}
+ Q_DECL_CONSTEXPR inline iterator() : o(Q_NULLPTR), i(0) {}
Q_DECL_CONSTEXPR inline iterator(QJsonObject *obj, int index) : o(obj), i(index) {}
inline QString key() const { return o->keyAt(i); }
@@ -147,7 +147,7 @@ public:
typedef QJsonValue value_type;
typedef QJsonValue reference;
- Q_DECL_CONSTEXPR inline const_iterator() : o(0), i(0) {}
+ Q_DECL_CONSTEXPR inline const_iterator() : o(Q_NULLPTR), i(0) {}
Q_DECL_CONSTEXPR inline const_iterator(const QJsonObject *obj, int index)
: o(obj), i(index) {}
inline const_iterator(const iterator &other)
diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h
index c80f7d3d08..eb357cefe5 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.h
+++ b/src/corelib/kernel/qabstracteventdispatcher.h
@@ -64,10 +64,10 @@ public:
{ }
};
- explicit QAbstractEventDispatcher(QObject *parent = 0);
+ explicit QAbstractEventDispatcher(QObject *parent = Q_NULLPTR);
~QAbstractEventDispatcher();
- static QAbstractEventDispatcher *instance(QThread *thread = 0);
+ static QAbstractEventDispatcher *instance(QThread *thread = Q_NULLPTR);
virtual bool processEvents(QEventLoop::ProcessEventsFlags flags) = 0;
virtual bool hasPendingEvents() = 0; // ### Qt6: remove, mark final or make protected
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index a215557aed..14c0f803b9 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -131,5 +131,22 @@ QAppleOperatingSystemVersion qt_apple_os_version()
return v;
}
+// -------------------------------------------------------------------------
+
+QMacAutoReleasePool::QMacAutoReleasePool()
+ : pool([[NSAutoreleasePool alloc] init])
+{
+}
+
+QMacAutoReleasePool::~QMacAutoReleasePool()
+{
+ // Drain behaves the same as release, with the advantage that
+ // if we're ever used in a garbage-collected environment, the
+ // drain acts as a hint to the garbage collector to collect.
+ [pool drain];
+}
+
+// -------------------------------------------------------------------------
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 8489afe5a7..66481d4c87 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -45,7 +45,6 @@
#include <qdir.h>
#include <qfile.h>
#include <qfileinfo.h>
-#include <qhash.h>
#include <qmutex.h>
#include <private/qloggingregistry_p.h>
#include <qstandardpaths.h>
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index 1cd835daae..1009fe8439 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -117,7 +117,7 @@ public:
static bool sendEvent(QObject *receiver, QEvent *event);
static void postEvent(QObject *receiver, QEvent *event, int priority = Qt::NormalEventPriority);
- static void sendPostedEvents(QObject *receiver = 0, int event_type = 0);
+ static void sendPostedEvents(QObject *receiver = Q_NULLPTR, int event_type = 0);
static void removePostedEvents(QObject *receiver, int eventType = 0);
#if QT_DEPRECATED_SINCE(5, 3)
QT_DEPRECATED static bool hasPendingEvents();
@@ -149,7 +149,7 @@ public:
static QString translate(const char * context,
const char * key,
- const char * disambiguation = 0,
+ const char * disambiguation = Q_NULLPTR,
int n = -1);
#if QT_DEPRECATED_SINCE(5, 0)
enum Encoding { UnicodeUTF8, Latin1, DefaultCodec = UnicodeUTF8, CodecForTr = UnicodeUTF8 };
@@ -231,13 +231,13 @@ inline bool QCoreApplication::sendSpontaneousEvent(QObject *receiver, QEvent *ev
# define QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context)
#else
# define QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) \
- QT_DEPRECATED static inline QString trUtf8(const char *sourceText, const char *disambiguation = 0, int n = -1) \
+ QT_DEPRECATED static inline QString trUtf8(const char *sourceText, const char *disambiguation = Q_NULLPTR, int n = -1) \
{ return QCoreApplication::translate(#context, sourceText, disambiguation, n); }
#endif
#define Q_DECLARE_TR_FUNCTIONS(context) \
public: \
- static inline QString tr(const char *sourceText, const char *disambiguation = 0, int n = -1) \
+ static inline QString tr(const char *sourceText, const char *disambiguation = Q_NULLPTR, int n = -1) \
{ return QCoreApplication::translate(#context, sourceText, disambiguation, n); } \
QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) \
private:
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index e9ae355d70..98514c56af 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -150,7 +150,7 @@ QT_BEGIN_NAMESPACE
\value HoverLeave The mouse cursor leaves a hover widget (QHoverEvent).
\value HoverMove The mouse cursor moves inside a hover widget (QHoverEvent).
\value IconDrag The main icon of a window has been dragged away (QIconDragEvent).
- \value IconTextChange Widget's icon text has been changed.
+ \value IconTextChange Widget's icon text has been changed. (Deprecated)
\value InputMethod An input method is being used (QInputMethodEvent).
\value InputMethodQuery A input method query event (QInputMethodQueryEvent)
\value KeyboardLayoutChange The keyboard layout has changed.
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index c208eb1180..53da4a849b 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -133,7 +133,7 @@ public:
EnabledChange = 98, // enabled state has changed
ActivationChange = 99, // window activation has changed
StyleChange = 100, // style has changed
- IconTextChange = 101, // icon text has changed
+ IconTextChange = 101, // icon text has changed. Deprecated.
ModifiedChange = 102, // modified state has changed
MouseTrackingChange = 109, // mouse tracking state has changed
diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp
index 876825b5f0..d9bbd4d5f2 100644
--- a/src/corelib/kernel/qeventdispatcher_glib.cpp
+++ b/src/corelib/kernel/qeventdispatcher_glib.cpp
@@ -39,7 +39,6 @@
#include "qcoreapplication.h"
#include "qsocketnotifier.h"
-#include <QtCore/qhash.h>
#include <QtCore/qlist.h>
#include <QtCore/qpair.h>
diff --git a/src/corelib/kernel/qeventdispatcher_glib_p.h b/src/corelib/kernel/qeventdispatcher_glib_p.h
index afdb6b9317..2cb919df07 100644
--- a/src/corelib/kernel/qeventdispatcher_glib_p.h
+++ b/src/corelib/kernel/qeventdispatcher_glib_p.h
@@ -48,8 +48,6 @@
#include "qabstracteventdispatcher.h"
#include "qabstracteventdispatcher_p.h"
-#include <QtCore/qhash.h>
-
typedef struct _GMainContext GMainContext;
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index b55679f3d5..ccb8341d0a 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -34,7 +34,6 @@
#include "qeventdispatcher_win_p.h"
#include "qcoreapplication.h"
-#include "qhash.h"
#include <private/qsystemlibrary_p.h>
#include "qpair.h"
#include "qset.h"
@@ -1076,11 +1075,10 @@ void QEventDispatcherWin32::activateEventNotifiers()
for (int i=0; i<d->winEventNotifierList.count(); i++) {
#if !defined(Q_OS_WINCE)
if (WaitForSingleObjectEx(d->winEventNotifierList.at(i)->handle(), 0, TRUE) == WAIT_OBJECT_0)
- d->activateEventNotifier(d->winEventNotifierList.at(i));
#else
if (WaitForSingleObject(d->winEventNotifierList.at(i)->handle(), 0) == WAIT_OBJECT_0)
- d->activateEventNotifier(d->winEventNotifierList.at(i));
#endif
+ d->activateEventNotifier(d->winEventNotifierList.at(i));
}
}
diff --git a/src/corelib/kernel/qeventloop.h b/src/corelib/kernel/qeventloop.h
index 99c0cd50ff..375a63abdd 100644
--- a/src/corelib/kernel/qeventloop.h
+++ b/src/corelib/kernel/qeventloop.h
@@ -47,7 +47,7 @@ class Q_CORE_EXPORT QEventLoop : public QObject
Q_DECLARE_PRIVATE(QEventLoop)
public:
- explicit QEventLoop(QObject *parent = 0);
+ explicit QEventLoop(QObject *parent = Q_NULLPTR);
~QEventLoop();
enum ProcessEventsFlag {
diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp
index 2640ecaaaf..108a01aab7 100644
--- a/src/corelib/kernel/qjni.cpp
+++ b/src/corelib/kernel/qjni.cpp
@@ -225,6 +225,15 @@ static jfieldID getCachedFieldID(JNIEnv *env,
}
}
+void QJNILocalRefDeleter::cleanup(jobject obj)
+{
+ if (obj == 0)
+ return;
+
+ QJNIEnvironmentPrivate env;
+ env->DeleteLocalRef(obj);
+}
+
class QJNIEnvironmentPrivateTLS
{
public:
@@ -2371,4 +2380,3 @@ bool QJNIObjectPrivate::isSameObject(const QJNIObjectPrivate &other) const
}
QT_END_NAMESPACE
-
diff --git a/src/corelib/kernel/qjni_p.h b/src/corelib/kernel/qjni_p.h
index a32d656ebf..1c23f2ab76 100644
--- a/src/corelib/kernel/qjni_p.h
+++ b/src/corelib/kernel/qjni_p.h
@@ -51,6 +51,14 @@
QT_BEGIN_NAMESPACE
+struct Q_CORE_EXPORT QJNILocalRefDeleter
+{
+ static void cleanup(jobject obj);
+};
+
+// To simplify this we only define it for jobjects.
+typedef QScopedPointer<_jobject, QJNILocalRefDeleter> QJNIScopedLocalRef;
+
class Q_CORE_EXPORT QJNIEnvironmentPrivate
{
public:
diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp
index dad2d5dc1e..f77fc4220c 100644
--- a/src/corelib/kernel/qjnihelpers.cpp
+++ b/src/corelib/kernel/qjnihelpers.cpp
@@ -122,6 +122,45 @@ void QtAndroidPrivate::handleNewIntent(JNIEnv *env, jobject intent)
}
}
+namespace {
+ class ResumePauseListeners
+ {
+ public:
+ QMutex mutex;
+ QList<QtAndroidPrivate::ResumePauseListener *> listeners;
+ };
+}
+
+Q_GLOBAL_STATIC(ResumePauseListeners, g_resumePauseListeners)
+
+void QtAndroidPrivate::registerResumePauseListener(ResumePauseListener *listener)
+{
+ QMutexLocker locker(&g_resumePauseListeners()->mutex);
+ g_resumePauseListeners()->listeners.append(listener);
+}
+
+void QtAndroidPrivate::unregisterResumePauseListener(ResumePauseListener *listener)
+{
+ QMutexLocker locker(&g_resumePauseListeners()->mutex);
+ g_resumePauseListeners()->listeners.removeAll(listener);
+}
+
+void QtAndroidPrivate::handlePause()
+{
+ QMutexLocker locker(&g_resumePauseListeners()->mutex);
+ const QList<QtAndroidPrivate::ResumePauseListener *> &listeners = g_resumePauseListeners()->listeners;
+ for (int i=0; i<listeners.size(); ++i)
+ listeners.at(i)->handlePause();
+}
+
+void QtAndroidPrivate::handleResume()
+{
+ QMutexLocker locker(&g_resumePauseListeners()->mutex);
+ const QList<QtAndroidPrivate::ResumePauseListener *> &listeners = g_resumePauseListeners()->listeners;
+ for (int i=0; i<listeners.size(); ++i)
+ listeners.at(i)->handleResume();
+}
+
static inline bool exceptionCheck(JNIEnv *env)
{
if (env->ExceptionCheck()) {
diff --git a/src/corelib/kernel/qjnihelpers_p.h b/src/corelib/kernel/qjnihelpers_p.h
index 3ed8338b18..883b08ef60 100644
--- a/src/corelib/kernel/qjnihelpers_p.h
+++ b/src/corelib/kernel/qjnihelpers_p.h
@@ -68,6 +68,14 @@ namespace QtAndroidPrivate
virtual bool handleNewIntent(JNIEnv *env, jobject intent) = 0;
};
+ class Q_CORE_EXPORT ResumePauseListener
+ {
+ public:
+ virtual ~ResumePauseListener() {}
+ virtual void handlePause() {};
+ virtual void handleResume() {};
+ };
+
Q_CORE_EXPORT jobject activity();
Q_CORE_EXPORT JavaVM *javaVM();
Q_CORE_EXPORT jint initJNI(JavaVM *vm, JNIEnv *env);
@@ -82,6 +90,11 @@ namespace QtAndroidPrivate
Q_CORE_EXPORT void handleNewIntent(JNIEnv *env, jobject intent);
Q_CORE_EXPORT void registerNewIntentListener(NewIntentListener *listener);
Q_CORE_EXPORT void unregisterNewIntentListener(NewIntentListener *listener);
+
+ Q_CORE_EXPORT void handlePause();
+ Q_CORE_EXPORT void handleResume();
+ Q_CORE_EXPORT void registerResumePauseListener(ResumePauseListener *listener);
+ Q_CORE_EXPORT void unregisterResumePauseListener(ResumePauseListener *listener);
}
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h
index 5cc3ec586e..e60561c05f 100644
--- a/src/corelib/kernel/qmath.h
+++ b/src/corelib/kernel/qmath.h
@@ -40,8 +40,18 @@
#include <QtCore/qglobal.h>
+#ifndef _USE_MATH_DEFINES
+# define _USE_MATH_DEFINES
+# define undef_USE_MATH_DEFINES
+#endif
+
#include <cmath>
+#ifdef undef_USE_MATH_DEFINES
+# undef _USE_MATH_DEFINES
+# undef undef_USE_MATH_DEFINES
+#endif
+
QT_BEGIN_NAMESPACE
#define QT_SINE_TABLE_SIZE 256
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index e89b914227..60cd3ab94a 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -43,7 +43,6 @@
#include <qstringlist.h>
#include <qthread.h>
#include <qvariant.h>
-#include <qhash.h>
#include <qdebug.h>
#include <qsemaphore.h>
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index b522a211bb..1a282d3261 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -48,7 +48,7 @@ template <typename T> class QList;
class Q_CORE_EXPORT QMetaMethod
{
public:
- Q_DECL_CONSTEXPR inline QMetaMethod() : mobj(0),handle(0) {}
+ Q_DECL_CONSTEXPR inline QMetaMethod() : mobj(Q_NULLPTR), handle(0) {}
QByteArray methodSignature() const;
QByteArray name() const;
@@ -74,7 +74,7 @@ public:
bool invoke(QObject *object,
Qt::ConnectionType connectionType,
QGenericReturnArgument returnValue,
- QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -86,7 +86,7 @@ public:
QGenericArgument val9 = QGenericArgument()) const;
inline bool invoke(QObject *object,
QGenericReturnArgument returnValue,
- QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -102,7 +102,7 @@ public:
}
inline bool invoke(QObject *object,
Qt::ConnectionType connectionType,
- QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -117,7 +117,7 @@ public:
val0, val1, val2, val3, val4, val5, val6, val7, val8, val9);
}
inline bool invoke(QObject *object,
- QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -134,7 +134,7 @@ public:
bool invokeOnGadget(void *gadget,
QGenericReturnArgument returnValue,
- QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -145,7 +145,7 @@ public:
QGenericArgument val8 = QGenericArgument(),
QGenericArgument val9 = QGenericArgument()) const;
inline bool invokeOnGadget(void *gadget,
- QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -160,7 +160,7 @@ public:
val0, val1, val2, val3, val4, val5, val6, val7, val8, val9);
}
- inline bool isValid() const { return mobj != 0; }
+ inline bool isValid() const { return mobj != Q_NULLPTR; }
#ifdef Q_QDOC
static QMetaMethod fromSignal(PointerToMemberFunction signal);
@@ -204,7 +204,7 @@ inline bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2)
class Q_CORE_EXPORT QMetaEnum
{
public:
- Q_DECL_CONSTEXPR inline QMetaEnum() : mobj(0),handle(0) {}
+ Q_DECL_CONSTEXPR inline QMetaEnum() : mobj(Q_NULLPTR), handle(0) {}
const char *name() const;
bool isFlag() const;
@@ -215,14 +215,14 @@ public:
const char *scope() const;
- int keyToValue(const char *key, bool *ok = 0) const;
+ int keyToValue(const char *key, bool *ok = Q_NULLPTR) const;
const char* valueToKey(int value) const;
- int keysToValue(const char * keys, bool *ok = 0) const;
+ int keysToValue(const char * keys, bool *ok = Q_NULLPTR) const;
QByteArray valueToKeys(int value) const;
inline const QMetaObject *enclosingMetaObject() const { return mobj; }
- inline bool isValid() const { return name() != 0; }
+ inline bool isValid() const { return name() != Q_NULLPTR; }
template<typename T> static QMetaEnum fromType() {
Q_STATIC_ASSERT_X(QtPrivate::IsQEnumHelper<T>::Value,
@@ -253,11 +253,11 @@ public:
bool isReadable() const;
bool isWritable() const;
bool isResettable() const;
- bool isDesignable(const QObject *obj = 0) const;
- bool isScriptable(const QObject *obj = 0) const;
- bool isStored(const QObject *obj = 0) const;
- bool isEditable(const QObject *obj = 0) const;
- bool isUser(const QObject *obj = 0) const;
+ bool isDesignable(const QObject *obj = Q_NULLPTR) const;
+ bool isScriptable(const QObject *obj = Q_NULLPTR) const;
+ bool isStored(const QObject *obj = Q_NULLPTR) const;
+ bool isEditable(const QObject *obj = Q_NULLPTR) const;
+ bool isUser(const QObject *obj = Q_NULLPTR) const;
bool isConstant() const;
bool isFinal() const;
@@ -297,7 +297,7 @@ private:
class Q_CORE_EXPORT QMetaClassInfo
{
public:
- Q_DECL_CONSTEXPR inline QMetaClassInfo() : mobj(0),handle(0) {}
+ Q_DECL_CONSTEXPR inline QMetaClassInfo() : mobj(Q_NULLPTR), handle(0) {}
const char *name() const;
const char *value() const;
inline const QMetaObject *enclosingMetaObject() const { return mobj; }
diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp
index a1b8125121..021e137273 100644
--- a/src/corelib/kernel/qmetaobjectbuilder.cpp
+++ b/src/corelib/kernel/qmetaobjectbuilder.cpp
@@ -88,6 +88,7 @@ static inline Q_DECL_UNUSED const QMetaObjectPrivate *priv(const uint* data)
class QMetaMethodBuilderPrivate
{
public:
+ QMetaMethodBuilderPrivate() {} // for QVector, don't use
QMetaMethodBuilderPrivate
(QMetaMethod::MethodType _methodType,
const QByteArray& _signature,
@@ -139,10 +140,12 @@ public:
return signature.left(qMax(signature.indexOf('('), 0));
}
};
+Q_DECLARE_TYPEINFO(QMetaMethodBuilderPrivate, Q_MOVABLE_TYPE);
class QMetaPropertyBuilderPrivate
{
public:
+ QMetaPropertyBuilderPrivate() {} // for QVector, don't use
QMetaPropertyBuilderPrivate
(const QByteArray& _name, const QByteArray& _type, int notifierIdx=-1,
int _revision = 0)
@@ -176,10 +179,12 @@ public:
flags &= ~f;
}
};
+Q_DECLARE_TYPEINFO(QMetaPropertyBuilderPrivate, Q_MOVABLE_TYPE);
class QMetaEnumBuilderPrivate
{
public:
+ QMetaEnumBuilderPrivate() {} // for QVector, don't use
QMetaEnumBuilderPrivate(const QByteArray& _name)
: name(_name), isFlag(false)
{
@@ -188,8 +193,9 @@ public:
QByteArray name;
bool isFlag;
QList<QByteArray> keys;
- QList<int> values;
+ QVector<int> values;
};
+Q_DECLARE_TYPEINFO(QMetaEnumBuilderPrivate, Q_MOVABLE_TYPE);
class QMetaObjectBuilderPrivate
{
@@ -207,12 +213,12 @@ public:
QByteArray className;
const QMetaObject *superClass;
QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction;
- QList<QMetaMethodBuilderPrivate> methods;
- QList<QMetaMethodBuilderPrivate> constructors;
- QList<QMetaPropertyBuilderPrivate> properties;
+ QVector<QMetaMethodBuilderPrivate> methods;
+ QVector<QMetaMethodBuilderPrivate> constructors;
+ QVector<QMetaPropertyBuilderPrivate> properties;
QList<QByteArray> classInfoNames;
QList<QByteArray> classInfoValues;
- QList<QMetaEnumBuilderPrivate> enumerators;
+ QVector<QMetaEnumBuilderPrivate> enumerators;
QList<const QMetaObject *> relatedMetaObjects;
int flags;
};
@@ -1149,7 +1155,7 @@ void QMetaStringTable::writeBlob(char *out) const
// Returns the sum of all parameters (including return type) for the given
// \a methods. This is needed for calculating the size of the methods'
// parameter type/name meta-data.
-static int aggregateParameterCount(const QList<QMetaMethodBuilderPrivate> &methods)
+static int aggregateParameterCount(const QVector<QMetaMethodBuilderPrivate> &methods)
{
int sum = 0;
for (int i = 0; i < methods.size(); ++i)
@@ -1330,7 +1336,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
Q_ASSERT(!buf || dataIndex == pmeta->methodData + d->methods.size() * 5
+ (hasRevisionedMethods ? d->methods.size() : 0));
for (int x = 0; x < 2; ++x) {
- QList<QMetaMethodBuilderPrivate> &methods = (x == 0) ? d->methods : d->constructors;
+ QVector<QMetaMethodBuilderPrivate> &methods = (x == 0) ? d->methods : d->constructors;
for (index = 0; index < methods.size(); ++index) {
QMetaMethodBuilderPrivate *method = &(methods[index]);
QList<QByteArray> paramTypeNames = method->parameterTypes();
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 1b214e9f74..988630d90f 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -229,7 +229,7 @@ struct AbstractDebugStreamFunction
{
typedef void (*Stream)(const AbstractDebugStreamFunction *, QDebug&, const void *);
typedef void (*Destroy)(AbstractDebugStreamFunction *);
- explicit AbstractDebugStreamFunction(Stream s = 0, Destroy d = 0)
+ explicit AbstractDebugStreamFunction(Stream s = Q_NULLPTR, Destroy d = Q_NULLPTR)
: stream(s), destroy(d) {}
Q_DISABLE_COPY(AbstractDebugStreamFunction)
Stream stream;
@@ -259,7 +259,7 @@ struct AbstractComparatorFunction
typedef bool (*LessThan)(const AbstractComparatorFunction *, const void *, const void *);
typedef bool (*Equals)(const AbstractComparatorFunction *, const void *, const void *);
typedef void (*Destroy)(AbstractComparatorFunction *);
- explicit AbstractComparatorFunction(LessThan lt = 0, Equals e = 0, Destroy d = 0)
+ explicit AbstractComparatorFunction(LessThan lt = Q_NULLPTR, Equals e = Q_NULLPTR, Destroy d = Q_NULLPTR)
: lessThan(lt), equals(e), destroy(d) {}
Q_DISABLE_COPY(AbstractComparatorFunction)
LessThan lessThan;
@@ -296,7 +296,7 @@ template<typename T>
struct BuiltInEqualsComparatorFunction : public AbstractComparatorFunction
{
BuiltInEqualsComparatorFunction()
- : AbstractComparatorFunction(0, equals, destroy) {}
+ : AbstractComparatorFunction(Q_NULLPTR, equals, destroy) {}
static bool equals(const AbstractComparatorFunction *, const void *l, const void *r)
{
const T *lhs = static_cast<const T *>(l);
@@ -313,7 +313,7 @@ struct BuiltInEqualsComparatorFunction : public AbstractComparatorFunction
struct AbstractConverterFunction
{
typedef bool (*Converter)(const AbstractConverterFunction *, const void *, void*);
- explicit AbstractConverterFunction(Converter c = 0)
+ explicit AbstractConverterFunction(Converter c = Q_NULLPTR)
: convert(c) {}
Q_DISABLE_COPY(AbstractConverterFunction)
Converter convert;
@@ -510,9 +510,9 @@ public:
static TypeFlags typeFlags(int type);
static const QMetaObject *metaObjectForType(int type);
static bool isRegistered(int type);
- static void *create(int type, const void *copy = 0);
+ static void *create(int type, const void *copy = Q_NULLPTR);
#if QT_DEPRECATED_SINCE(5, 0)
- QT_DEPRECATED static void *construct(int type, const void *copy = 0)
+ QT_DEPRECATED static void *construct(int type, const void *copy = Q_NULLPTR)
{ return create(type, copy); }
#endif
static void destroy(int type, void *data);
@@ -533,9 +533,9 @@ public:
inline TypeFlags flags() const;
inline const QMetaObject *metaObject() const;
- inline void *create(const void *copy = 0) const;
+ inline void *create(const void *copy = Q_NULLPTR) const;
inline void destroy(void *data) const;
- inline void *construct(void *where, const void *copy = 0) const;
+ inline void *construct(void *where, const void *copy = Q_NULLPTR) const;
inline void destruct(void *data) const;
public:
@@ -611,7 +611,7 @@ public:
return registerConverterFunction(&f, fromTypeId, toTypeId);
}
- // member function as in "double QString::toDouble(bool *ok = 0) const"
+ // member function as in "double QString::toDouble(bool *ok = Q_NULLPTR) const"
template<typename From, typename To>
static bool registerConverter(To(From::*function)(bool*) const)
{
@@ -674,9 +674,9 @@ private:
uint sizeExtended() const;
QMetaType::TypeFlags flagsExtended() const;
const QMetaObject *metaObjectExtended() const;
- void *createExtended(const void *copy = 0) const;
+ void *createExtended(const void *copy = Q_NULLPTR) const;
void destroyExtended(void *data) const;
- void *constructExtended(void *where, const void *copy = 0) const;
+ void *constructExtended(void *where, const void *copy = Q_NULLPTR) const;
void destructExtended(void *data) const;
static bool registerComparatorFunction(const QtPrivate::AbstractComparatorFunction *f, int type);
@@ -771,7 +771,7 @@ struct QMetaTypeFunctionHelper {
template <typename T>
struct QMetaTypeFunctionHelper<T, /* Accepted */ false> {
static void Destruct(void *) {}
- static void *Construct(void *, const void *) { return 0; }
+ static void *Construct(void *, const void *) { return Q_NULLPTR; }
#ifndef QT_NO_DATASTREAM
static void Save(QDataStream &, const void *) {}
static void Load(QDataStream &, void *) {}
@@ -1009,7 +1009,7 @@ public:
public:
template<class T> QSequentialIterableImpl(const T*p)
: _iterable(p)
- , _iterator(0)
+ , _iterator(Q_NULLPTR)
, _metaType_id(qMetaTypeId<typename T::value_type>())
, _metaType_flags(QTypeInfo<typename T::value_type>::isPointer)
, _iteratorCapabilities(ContainerAPI<T>::IteratorCapabilities)
@@ -1026,20 +1026,20 @@ public:
}
QSequentialIterableImpl()
- : _iterable(0)
- , _iterator(0)
+ : _iterable(Q_NULLPTR)
+ , _iterator(Q_NULLPTR)
, _metaType_id(QMetaType::UnknownType)
, _metaType_flags(0)
, _iteratorCapabilities(0)
- , _size(0)
- , _at(0)
- , _moveToBegin(0)
- , _moveToEnd(0)
- , _advance(0)
- , _get(0)
- , _destroyIter(0)
- , _equalIter(0)
- , _copyIter(0)
+ , _size(Q_NULLPTR)
+ , _at(Q_NULLPTR)
+ , _moveToBegin(Q_NULLPTR)
+ , _moveToEnd(Q_NULLPTR)
+ , _advance(Q_NULLPTR)
+ , _get(Q_NULLPTR)
+ , _destroyIter(Q_NULLPTR)
+ , _equalIter(Q_NULLPTR)
+ , _copyIter(Q_NULLPTR)
{
}
@@ -1195,21 +1195,21 @@ public:
}
QAssociativeIterableImpl()
- : _iterable(0)
+ : _iterable(Q_NULLPTR)
, _metaType_id_key(QMetaType::UnknownType)
, _metaType_flags_key(0)
, _metaType_id_value(QMetaType::UnknownType)
, _metaType_flags_value(0)
- , _size(0)
- , _find(0)
- , _begin(0)
- , _end(0)
- , _advance(0)
- , _getKey(0)
- , _getValue(0)
- , _destroyIter(0)
- , _equalIter(0)
- , _copyIter(0)
+ , _size(Q_NULLPTR)
+ , _find(Q_NULLPTR)
+ , _begin(Q_NULLPTR)
+ , _end(Q_NULLPTR)
+ , _advance(Q_NULLPTR)
+ , _getKey(Q_NULLPTR)
+ , _getValue(Q_NULLPTR)
+ , _destroyIter(Q_NULLPTR)
+ , _equalIter(Q_NULLPTR)
+ , _copyIter(Q_NULLPTR)
{
}
@@ -1277,9 +1277,9 @@ public:
}
QPairVariantInterfaceImpl()
- : _pair(0)
- , _getFirst(0)
- , _getSecond(0)
+ : _pair(Q_NULLPTR)
+ , _getFirst(Q_NULLPTR)
+ , _getSecond(Q_NULLPTR)
{
}
@@ -1354,7 +1354,7 @@ namespace QtPrivate
#endif
static no_type checkType(...);
Q_STATIC_ASSERT_X(sizeof(T), "Type argument of Q_DECLARE_METATYPE(T*) must be fully defined");
- enum { Value = sizeof(checkType(static_cast<T*>(0))) == sizeof(yes_type) };
+ enum { Value = sizeof(checkType(static_cast<T*>(Q_NULLPTR))) == sizeof(yes_type) };
};
template<typename T, typename Enable = void>
@@ -1391,7 +1391,7 @@ QT_WARNING_POP
template<typename T, typename Enable = void>
struct MetaObjectForType
{
- static inline const QMetaObject *value() { return 0; }
+ static inline const QMetaObject *value() { return Q_NULLPTR; }
};
template<>
struct MetaObjectForType<void>
@@ -1692,7 +1692,7 @@ int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normaliz
template <typename T>
int qRegisterMetaType(const char *typeName
#ifndef Q_QDOC
- , T * dummy = 0
+ , T * dummy = Q_NULLPTR
, typename QtPrivate::MetaTypeDefinedHelper<T, QMetaTypeId2<T>::Defined && !QMetaTypeId2<T>::IsBuiltIn>::DefinedType defined = QtPrivate::MetaTypeDefinedHelper<T, QMetaTypeId2<T>::Defined && !QMetaTypeId2<T>::IsBuiltIn>::Defined
#endif
)
@@ -1709,7 +1709,7 @@ int qRegisterMetaType(const char *typeName
template <typename T>
void qRegisterMetaTypeStreamOperators(const char *typeName
#ifndef Q_QDOC
- , T * /* dummy */ = 0
+ , T * /* dummy */ = Q_NULLPTR
#endif
)
{
@@ -2095,7 +2095,7 @@ inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeI
, m_loadOp(loadOp)
, m_constructor(constructor)
, m_destructor(destructor)
- , m_extension(0)
+ , m_extension(Q_NULLPTR)
, m_size(size)
, m_typeFlags(theTypeFlags)
, m_extensionFlags(extensionFlags)
diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp
index 3e9cdac966..93788afeae 100644
--- a/src/corelib/kernel/qmimedata.cpp
+++ b/src/corelib/kernel/qmimedata.cpp
@@ -354,7 +354,9 @@ void QMimeData::setUrls(const QList<QUrl> &urls)
{
Q_D(QMimeData);
QList<QVariant> list;
- for (int i = 0; i < urls.size(); ++i)
+ const int numUrls = urls.size();
+ list.reserve(numUrls);
+ for (int i = 0; i < numUrls; ++i)
list.append(urls.at(i));
d->setData(QLatin1String("text/uri-list"), list);
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 676a529dfe..c63dd79f02 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -47,7 +47,6 @@
#include <qthread.h>
#include <private/qthread_p.h>
#include <qdebug.h>
-#include <qhash.h>
#include <qpair.h>
#include <qvarlengtharray.h>
#include <qset.h>
@@ -66,6 +65,16 @@ QT_BEGIN_NAMESPACE
static int DIRECT_CONNECTION_ONLY = 0;
+
+QDynamicMetaObjectData::~QDynamicMetaObjectData()
+{
+}
+
+QAbstractDynamicMetaObject::~QAbstractDynamicMetaObject()
+{
+}
+
+
struct QSlotObjectBaseDeleter { // for use with QScopedPointer<QSlotObjectBase,...>
static void cleanup(QtPrivate::QSlotObjectBase *slot) {
if (slot) slot->destroyIfLastRef();
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 5f61dd984f..64c5b58fd4 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -110,23 +110,23 @@ class Q_CORE_EXPORT QObject
Q_DECLARE_PRIVATE(QObject)
public:
- Q_INVOKABLE explicit QObject(QObject *parent=0);
+ Q_INVOKABLE explicit QObject(QObject *parent=Q_NULLPTR);
virtual ~QObject();
virtual bool event(QEvent *);
virtual bool eventFilter(QObject *, QEvent *);
#ifdef Q_QDOC
- static QString tr(const char *sourceText, const char *comment = 0, int n = -1);
- static QString trUtf8(const char *sourceText, const char *comment = 0, int n = -1);
+ static QString tr(const char *sourceText, const char *comment = Q_NULLPTR, int n = -1);
+ static QString trUtf8(const char *sourceText, const char *comment = Q_NULLPTR, int n = -1);
virtual const QMetaObject *metaObject() const;
static const QMetaObject staticMetaObject;
#endif
#ifdef QT_NO_TRANSLATION
- static QString tr(const char *sourceText, const char * = 0, int = -1)
+ static QString tr(const char *sourceText, const char * = Q_NULLPTR, int = -1)
{ return QString::fromUtf8(sourceText); }
#if QT_DEPRECATED_SINCE(5, 0)
- QT_DEPRECATED static QString trUtf8(const char *sourceText, const char * = 0, int = -1)
+ QT_DEPRECATED static QString trUtf8(const char *sourceText, const char * = Q_NULLPTR, int = -1)
{ return QString::fromUtf8(sourceText); }
#endif
#endif //QT_NO_TRANSLATION
@@ -228,7 +228,7 @@ public:
Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
"Return type of the slot is not compatible with the return type of the signal.");
- const int *types = 0;
+ const int *types = Q_NULLPTR;
if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types();
@@ -268,11 +268,11 @@ public:
Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
"Return type of the slot is not compatible with the return type of the signal.");
- const int *types = 0;
+ const int *types = Q_NULLPTR;
if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types();
- return connectImpl(sender, reinterpret_cast<void **>(&signal), context, 0,
+ return connectImpl(sender, reinterpret_cast<void **>(&signal), context, Q_NULLPTR,
new QtPrivate::QStaticSlotObject<Func2,
typename QtPrivate::List_Left<typename SignalType::Arguments, SlotType::ArgumentCount>::Value,
typename SignalType::ReturnType>(slot),
@@ -338,11 +338,11 @@ public:
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
"No Q_OBJECT in the class with the signal");
- const int *types = 0;
+ const int *types = Q_NULLPTR;
if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types();
- return connectImpl(sender, reinterpret_cast<void **>(&signal), context, 0,
+ return connectImpl(sender, reinterpret_cast<void **>(&signal), context, Q_NULLPTR,
new QtPrivate::QFunctorSlotObject<Func2, SlotArgumentCount,
typename QtPrivate::List_Left<typename SignalType::Arguments, SlotArgumentCount>::Value,
typename SignalType::ReturnType>(slot),
@@ -354,11 +354,11 @@ public:
const QObject *receiver, const char *member);
static bool disconnect(const QObject *sender, const QMetaMethod &signal,
const QObject *receiver, const QMetaMethod &member);
- inline bool disconnect(const char *signal = 0,
- const QObject *receiver = 0, const char *member = 0) const
+ inline bool disconnect(const char *signal = Q_NULLPTR,
+ const QObject *receiver = Q_NULLPTR, const char *member = Q_NULLPTR) const
{ return disconnect(this, signal, receiver, member); }
- inline bool disconnect(const QObject *receiver, const char *member = 0) const
- { return disconnect(this, 0, receiver, member); }
+ inline bool disconnect(const QObject *receiver, const char *member = Q_NULLPTR) const
+ { return disconnect(this, Q_NULLPTR, receiver, member); }
static bool disconnect(const QMetaObject::Connection &);
#ifdef Q_QDOC
@@ -385,7 +385,7 @@ public:
static inline bool disconnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
const QObject *receiver, void **zero)
{
- // This is the overload for when one wish to disconnect a signal from any slot. (slot=0)
+ // This is the overload for when one wish to disconnect a signal from any slot. (slot=Q_NULLPTR)
// Since the function template parameter cannot be deduced from '0', we use a
// dummy void ** parameter that must be equal to 0
Q_ASSERT(!zero);
@@ -412,14 +412,14 @@ public:
#endif // QT_NO_USERDATA
Q_SIGNALS:
- void destroyed(QObject * = 0);
+ void destroyed(QObject * = Q_NULLPTR);
void objectNameChanged(const QString &objectName, QPrivateSignal);
public:
inline QObject *parent() const { return d_ptr->parent; }
inline bool inherits(const char *classname) const
- { return const_cast<QObject *>(this)->qt_metacast(classname) != 0; }
+ { return const_cast<QObject *>(this)->qt_metacast(classname) != Q_NULLPTR; }
public Q_SLOTS:
void deleteLater();
@@ -438,7 +438,7 @@ protected:
virtual void disconnectNotify(const QMetaMethod &signal);
protected:
- QObject(QObjectPrivate &dd, QObject *parent = 0);
+ QObject(QObjectPrivate &dd, QObject *parent = Q_NULLPTR);
protected:
QScopedPointer<QObjectData> d_ptr;
@@ -529,16 +529,16 @@ inline T qobject_cast(const QObject *object)
template <class T> inline const char * qobject_interface_iid()
-{ return 0; }
+{ return Q_NULLPTR; }
#ifndef Q_MOC_RUN
# define Q_DECLARE_INTERFACE(IFace, IId) \
template <> inline const char *qobject_interface_iid<IFace *>() \
{ return IId; } \
template <> inline IFace *qobject_cast<IFace *>(QObject *object) \
- { return reinterpret_cast<IFace *>((object ? object->qt_metacast(IId) : 0)); } \
+ { return reinterpret_cast<IFace *>((object ? object->qt_metacast(IId) : Q_NULLPTR)); } \
template <> inline IFace *qobject_cast<IFace *>(const QObject *object) \
- { return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : 0)); }
+ { return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : Q_NULLPTR)); }
#endif // Q_MOC_RUN
#ifndef QT_NO_DEBUG_STREAM
@@ -584,7 +584,7 @@ QSignalBlocker::QSignalBlocker(QSignalBlocker &&other) Q_DECL_NOTHROW
m_blocked(other.m_blocked),
m_inhibited(other.m_inhibited)
{
- other.m_o = 0;
+ other.m_o = Q_NULLPTR;
}
QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) Q_DECL_NOTHROW
@@ -598,7 +598,7 @@ QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) Q_DECL_NOTHROW
m_blocked = other.m_blocked;
m_inhibited = other.m_inhibited;
// disable other:
- other.m_o = 0;
+ other.m_o = Q_NULLPTR;
}
return *this;
}
diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h
index 4d9e42ba76..09d52584c4 100644
--- a/src/corelib/kernel/qobject_impl.h
+++ b/src/corelib/kernel/qobject_impl.h
@@ -90,9 +90,9 @@ namespace QtPrivate {
{ enum { Value = QMetaTypeId2<Arg>::Defined && TypesAreDeclaredMetaType<List<Tail...>>::Value }; };
template <typename ArgList, bool Declared = TypesAreDeclaredMetaType<ArgList>::Value > struct ConnectionTypes
- { static const int *types() { return 0; } };
+ { static const int *types() { return Q_NULLPTR; } };
template <> struct ConnectionTypes<List<>, true>
- { static const int *types() { return 0; } };
+ { static const int *types() { return Q_NULLPTR; } };
template <typename... Args> struct ConnectionTypes<List<Args...>, true>
{ static const int *types() { static const int t[sizeof...(Args) + 1] = { (QtPrivate::QMetaTypeIdHelper<Args>::qt_metatype_id())..., 0 }; return t; } };
#endif
@@ -118,10 +118,10 @@ namespace QtPrivate {
inline int ref() Q_DECL_NOTHROW { return m_ref.ref(); }
inline void destroyIfLastRef() Q_DECL_NOTHROW
- { if (!m_ref.deref()) m_impl(Destroy, this, 0, 0, 0); }
+ { if (!m_ref.deref()) m_impl(Destroy, this, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR); }
- inline bool compare(void **a) { bool ret; m_impl(Compare, this, 0, a, &ret); return ret; }
- inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, 0); }
+ inline bool compare(void **a) { bool ret; m_impl(Compare, this, Q_NULLPTR, a, &ret); return ret; }
+ inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, Q_NULLPTR); }
protected:
~QSlotObjectBase() {}
private:
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 1b64103e40..bd5ee006bf 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -406,7 +406,7 @@ void Q_CORE_EXPORT qDeleteInEventHandler(QObject *o);
struct QAbstractDynamicMetaObject;
struct Q_CORE_EXPORT QDynamicMetaObjectData
{
- virtual ~QDynamicMetaObjectData() {}
+ virtual ~QDynamicMetaObjectData();
virtual void objectDestroyed(QObject *) { delete this; }
virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) = 0;
@@ -415,6 +415,8 @@ struct Q_CORE_EXPORT QDynamicMetaObjectData
struct Q_CORE_EXPORT QAbstractDynamicMetaObject : public QDynamicMetaObjectData, public QMetaObject
{
+ ~QAbstractDynamicMetaObject();
+
virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) Q_DECL_OVERRIDE { return this; }
virtual int createProperty(const char *, const char *) { return -1; }
virtual int metaCall(QObject *, QMetaObject::Call c, int _id, void **a) Q_DECL_OVERRIDE
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 6484507a12..b1ed971eba 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -78,7 +78,11 @@ class QString;
#define Q_CLASSINFO(name, value)
#define Q_PLUGIN_METADATA(x)
#define Q_INTERFACES(x)
+#ifdef Q_COMPILER_VARIADIC_MACROS
+#define Q_PROPERTY(...)
+#else
#define Q_PROPERTY(text)
+#endif
#define Q_PRIVATE_PROPERTY(d, text)
#define Q_REVISION(v)
#define Q_OVERRIDE(text)
@@ -254,7 +258,7 @@ class QMetaClassInfo;
class Q_CORE_EXPORT QGenericArgument
{
public:
- inline QGenericArgument(const char *aName = 0, const void *aData = 0)
+ inline QGenericArgument(const char *aName = Q_NULLPTR, const void *aData = Q_NULLPTR)
: _data(aData), _name(aName) {}
inline void *data() const { return const_cast<void *>(_data); }
inline const char *name() const { return _name; }
@@ -267,7 +271,7 @@ private:
class Q_CORE_EXPORT QGenericReturnArgument: public QGenericArgument
{
public:
- inline QGenericReturnArgument(const char *aName = 0, void *aData = 0)
+ inline QGenericReturnArgument(const char *aName = Q_NULLPTR, void *aData = Q_NULLPTR)
: QGenericArgument(aName, aData)
{}
};
@@ -347,7 +351,7 @@ struct Q_CORE_EXPORT QMetaObject
// internal index-based connect
static Connection connect(const QObject *sender, int signal_index,
const QObject *receiver, int method_index,
- int type = 0, int *types = 0);
+ int type = 0, int *types = Q_NULLPTR);
// internal index-based disconnect
static bool disconnect(const QObject *sender, int signal_index,
const QObject *receiver, int method_index);
@@ -364,7 +368,7 @@ struct Q_CORE_EXPORT QMetaObject
static bool invokeMethod(QObject *obj, const char *member,
Qt::ConnectionType,
QGenericReturnArgument ret,
- QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -377,7 +381,7 @@ struct Q_CORE_EXPORT QMetaObject
static inline bool invokeMethod(QObject *obj, const char *member,
QGenericReturnArgument ret,
- QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -394,7 +398,7 @@ struct Q_CORE_EXPORT QMetaObject
static inline bool invokeMethod(QObject *obj, const char *member,
Qt::ConnectionType type,
- QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -410,7 +414,7 @@ struct Q_CORE_EXPORT QMetaObject
}
static inline bool invokeMethod(QObject *obj, const char *member,
- QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -425,7 +429,7 @@ struct Q_CORE_EXPORT QMetaObject
val1, val2, val3, val4, val5, val6, val7, val8, val9);
}
- QObject *newInstance(QGenericArgument val0 = QGenericArgument(0),
+ QObject *newInstance(QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -482,11 +486,11 @@ public:
operator bool() const;
#else
typedef void *Connection::*RestrictedBool;
- operator RestrictedBool() const { return d_ptr && isConnected_helper() ? &Connection::d_ptr : 0; }
+ operator RestrictedBool() const { return d_ptr && isConnected_helper() ? &Connection::d_ptr : Q_NULLPTR; }
#endif
#ifdef Q_COMPILER_RVALUE_REFS
- inline Connection(Connection &&o) : d_ptr(o.d_ptr) { o.d_ptr = 0; }
+ inline Connection(Connection &&o) : d_ptr(o.d_ptr) { o.d_ptr = Q_NULLPTR; }
inline Connection &operator=(Connection &&other)
{ qSwap(d_ptr, other.d_ptr); return *this; }
#endif
diff --git a/src/corelib/kernel/qpointer.cpp b/src/corelib/kernel/qpointer.cpp
index 2c872716d1..39cc17f7dd 100644
--- a/src/corelib/kernel/qpointer.cpp
+++ b/src/corelib/kernel/qpointer.cpp
@@ -128,6 +128,14 @@
*/
/*!
+ \fn void QPointer::swap(QPointer<T> &other)
+ \since 5.6
+
+ Swaps the contents of this QPointer with the contents of \a other.
+ This operation is very fast and never fails.
+*/
+
+/*!
\fn QPointer<T> & QPointer::operator=(T* p)
Assignment operator. This guarded pointer will now point to the
diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h
index af7c11e4d7..a3e922ccc9 100644
--- a/src/corelib/kernel/qpointer.h
+++ b/src/corelib/kernel/qpointer.h
@@ -35,6 +35,7 @@
#define QPOINTER_H
#include <QtCore/qsharedpointer.h>
+#include <QtCore/qtypeinfo.h>
#ifndef QT_NO_QOBJECT
@@ -45,6 +46,8 @@ class QVariant;
template <class T>
class QPointer
{
+ Q_STATIC_ASSERT_X(!QtPrivate::is_pointer<T>::value, "QPointer's template type must not be a pointer type");
+
template<typename U>
struct TypeSelector
{
@@ -63,6 +66,8 @@ public:
// compiler-generated copy/move ctor/assignment operators are fine!
inline ~QPointer() { }
+ inline void swap(QPointer &other) { wp.swap(other.wp); }
+
inline QPointer<T> &operator=(T* p)
{ wp.assign(static_cast<QObjectType*>(p)); return *this; }
diff --git a/src/corelib/kernel/qsharedmemory.h b/src/corelib/kernel/qsharedmemory.h
index c192910dc7..67558e3348 100644
--- a/src/corelib/kernel/qsharedmemory.h
+++ b/src/corelib/kernel/qsharedmemory.h
@@ -68,8 +68,8 @@ public:
UnknownError
};
- QSharedMemory(QObject *parent = 0);
- QSharedMemory(const QString &key, QObject *parent = 0);
+ QSharedMemory(QObject *parent = Q_NULLPTR);
+ QSharedMemory(const QString &key, QObject *parent = Q_NULLPTR);
~QSharedMemory();
void setKey(const QString &key);
diff --git a/src/corelib/kernel/qsignalmapper.h b/src/corelib/kernel/qsignalmapper.h
index df2a0a52ea..7aaef6affc 100644
--- a/src/corelib/kernel/qsignalmapper.h
+++ b/src/corelib/kernel/qsignalmapper.h
@@ -45,7 +45,7 @@ class Q_CORE_EXPORT QSignalMapper : public QObject
Q_OBJECT
Q_DECLARE_PRIVATE(QSignalMapper)
public:
- explicit QSignalMapper(QObject *parent = 0);
+ explicit QSignalMapper(QObject *parent = Q_NULLPTR);
~QSignalMapper();
void setMapping(QObject *sender, int id);
diff --git a/src/corelib/kernel/qsocketnotifier.h b/src/corelib/kernel/qsocketnotifier.h
index 4bafbfa69f..8a7af6ebbc 100644
--- a/src/corelib/kernel/qsocketnotifier.h
+++ b/src/corelib/kernel/qsocketnotifier.h
@@ -47,7 +47,7 @@ class Q_CORE_EXPORT QSocketNotifier : public QObject
public:
enum Type { Read, Write, Exception };
- QSocketNotifier(qintptr socket, Type, QObject *parent = 0);
+ QSocketNotifier(qintptr socket, Type, QObject *parent = Q_NULLPTR);
~QSocketNotifier();
qintptr socket() const;
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index 19d84c2b3e..e333104add 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -145,7 +145,7 @@ static QString standardLibraryErrorString(int errorCode)
return ret.trimmed();
}
-QString QSystemError::toString()
+QString QSystemError::toString() const
{
switch(errorScope) {
case NativeError:
diff --git a/src/corelib/kernel/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h
index e7efb9bbf3..29e9e440e4 100644
--- a/src/corelib/kernel/qsystemerror_p.h
+++ b/src/corelib/kernel/qsystemerror_p.h
@@ -62,9 +62,9 @@ public:
inline QSystemError(int error, ErrorScope scope);
inline QSystemError();
- QString toString();
- inline ErrorScope scope();
- inline int error();
+ QString toString() const;
+ inline ErrorScope scope() const;
+ inline int error() const;
//data members
int errorCode;
@@ -83,12 +83,12 @@ QSystemError::QSystemError()
}
-QSystemError::ErrorScope QSystemError::scope()
+QSystemError::ErrorScope QSystemError::scope() const
{
return errorScope;
}
-int QSystemError::error()
+int QSystemError::error() const
{
return errorCode;
}
diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp
index ca55025c2a..89b8a87f2a 100644
--- a/src/corelib/kernel/qsystemsemaphore_win.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_win.cpp
@@ -115,7 +115,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
return false;
}
} else {
-#if defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINCE)
if (WAIT_OBJECT_0 != WaitForSingleObjectEx(semaphore, INFINITE, FALSE)) {
#else
if (WAIT_OBJECT_0 != WaitForSingleObject(semaphore, INFINITE)) {
diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h
index 163ef75291..56f8a1a177 100644
--- a/src/corelib/kernel/qtimer.h
+++ b/src/corelib/kernel/qtimer.h
@@ -53,7 +53,7 @@ class Q_CORE_EXPORT QTimer : public QObject
Q_PROPERTY(Qt::TimerType timerType READ timerType WRITE setTimerType)
Q_PROPERTY(bool active READ isActive)
public:
- explicit QTimer(QObject *parent = 0);
+ explicit QTimer(QObject *parent = Q_NULLPTR);
~QTimer();
inline bool isActive() const { return id >= 0; }
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index a405df567f..ef74b4bdd1 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -46,7 +46,6 @@
#include "qfile.h"
#include "qmap.h"
#include "qalgorithms.h"
-#include "qhash.h"
#include "qtranslator_p.h"
#include "qlocale.h"
#include "qendian.h"
diff --git a/src/corelib/kernel/qtranslator.h b/src/corelib/kernel/qtranslator.h
index 1552bbde35..78f714c5c6 100644
--- a/src/corelib/kernel/qtranslator.h
+++ b/src/corelib/kernel/qtranslator.h
@@ -49,11 +49,11 @@ class Q_CORE_EXPORT QTranslator : public QObject
{
Q_OBJECT
public:
- explicit QTranslator(QObject *parent = 0);
+ explicit QTranslator(QObject *parent = Q_NULLPTR);
~QTranslator();
virtual QString translate(const char *context, const char *sourceText,
- const char *disambiguation = 0, int n = -1) const;
+ const char *disambiguation = Q_NULLPTR, int n = -1) const;
virtual bool isEmpty() const;
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 58dfc3aab0..bb996af121 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -278,14 +278,14 @@ class Q_CORE_EXPORT QVariant
void detach();
inline bool isDetached() const;
- int toInt(bool *ok = 0) const;
- uint toUInt(bool *ok = 0) const;
- qlonglong toLongLong(bool *ok = 0) const;
- qulonglong toULongLong(bool *ok = 0) const;
+ int toInt(bool *ok = Q_NULLPTR) const;
+ uint toUInt(bool *ok = Q_NULLPTR) const;
+ qlonglong toLongLong(bool *ok = Q_NULLPTR) const;
+ qulonglong toULongLong(bool *ok = Q_NULLPTR) const;
bool toBool() const;
- double toDouble(bool *ok = 0) const;
- float toFloat(bool *ok = 0) const;
- qreal toReal(bool *ok = 0) const;
+ double toDouble(bool *ok = Q_NULLPTR) const;
+ float toFloat(bool *ok = Q_NULLPTR) const;
+ qreal toReal(bool *ok = Q_NULLPTR) const;
QByteArray toByteArray() const;
QBitArray toBitArray() const;
QString toString() const;
@@ -364,7 +364,7 @@ class Q_CORE_EXPORT QVariant
struct Private
{
inline Private() Q_DECL_NOTHROW : type(Invalid), is_shared(false), is_null(true)
- { data.ptr = 0; }
+ { data.ptr = Q_NULLPTR; }
// Internal constructor for initialized variants.
explicit inline Private(uint variantType) Q_DECL_NOTHROW
diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp
index bec7a79e8f..133933f9af 100644
--- a/src/corelib/mimetypes/qmimedatabase.cpp
+++ b/src/corelib/mimetypes/qmimedatabase.cpp
@@ -434,6 +434,7 @@ QList<QMimeType> QMimeDatabase::mimeTypesForFileName(const QString &fileName) co
QStringList matches = d->mimeTypeForFileName(fileName);
QList<QMimeType> mimes;
matches.sort(); // Make it deterministic
+ mimes.reserve(matches.count());
foreach (const QString &mime, matches)
mimes.append(d->mimeTypeForName(mime));
return mimes;
diff --git a/src/corelib/mimetypes/qmimedatabase_p.h b/src/corelib/mimetypes/qmimedatabase_p.h
index e3cfe3443f..1308907b9b 100644
--- a/src/corelib/mimetypes/qmimedatabase_p.h
+++ b/src/corelib/mimetypes/qmimedatabase_p.h
@@ -52,7 +52,6 @@
#include "qmimetype_p.h"
#include "qmimeglobpattern_p.h"
-#include <QtCore/qhash.h>
#include <QtCore/qmutex.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp
index 7342a5cd77..dd8f385c82 100644
--- a/src/corelib/mimetypes/qmimeprovider.cpp
+++ b/src/corelib/mimetypes/qmimeprovider.cpp
@@ -541,6 +541,7 @@ QList<QMimeType> QMimeBinaryProvider::allMimeTypes()
{
QList<QMimeType> result;
loadMimeTypeList();
+ result.reserve(m_mimetypeNames.count());
for (QSet<QString>::const_iterator it = m_mimetypeNames.constBegin();
it != m_mimetypeNames.constEnd(); ++it)
diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp
index a5f9cb70d5..3206ff66e3 100644
--- a/src/corelib/mimetypes/qmimetype.cpp
+++ b/src/corelib/mimetypes/qmimetype.cpp
@@ -43,6 +43,7 @@
#include <QtCore/QDebug>
#include <QtCore/QLocale>
+#include <QtCore/QHashFunctions>
#include <memory>
@@ -181,6 +182,18 @@ bool QMimeType::operator==(const QMimeType &other) const
}
/*!
+ \since 5.6
+ \relates QMimeType
+
+ Returns the hash value for \a key, using
+ \a seed to seed the calculation.
+ */
+uint qHash(const QMimeType &key, uint seed) Q_DECL_NOTHROW
+{
+ return qHash(key.d->name, seed);
+}
+
+/*!
\fn bool QMimeType::operator!=(const QMimeType &other) const;
Returns \c true if \a other does not equal this QMimeType object, otherwise returns \c false.
*/
diff --git a/src/corelib/mimetypes/qmimetype.h b/src/corelib/mimetypes/qmimetype.h
index 4ba3c53470..3c153da21d 100644
--- a/src/corelib/mimetypes/qmimetype.h
+++ b/src/corelib/mimetypes/qmimetype.h
@@ -46,6 +46,9 @@ QT_BEGIN_NAMESPACE
class QMimeTypePrivate;
class QFileinfo;
class QStringList;
+class QMimeType;
+
+Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed = 0) Q_DECL_NOTHROW;
class Q_CORE_EXPORT QMimeType
{
@@ -54,13 +57,9 @@ public:
QMimeType(const QMimeType &other);
QMimeType &operator=(const QMimeType &other);
#ifdef Q_COMPILER_RVALUE_REFS
- QMimeType &operator=(QMimeType &&other)
- {
- qSwap(d, other.d);
- return *this;
- }
+ QMimeType &operator=(QMimeType &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- void swap(QMimeType &other)
+ void swap(QMimeType &other) Q_DECL_NOTHROW
{
qSwap(d, other.d);
}
@@ -100,6 +99,7 @@ protected:
friend class QMimeXMLProvider;
friend class QMimeBinaryProvider;
friend class QMimeTypePrivate;
+ friend Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed) Q_DECL_NOTHROW;
QExplicitlySharedDataPointer<QMimeTypePrivate> d;
};
diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri
index 338b3d0972..8b64f93467 100644
--- a/src/corelib/plugin/plugin.pri
+++ b/src/corelib/plugin/plugin.pri
@@ -13,6 +13,7 @@ HEADERS += \
plugin/qmachparser_p.h
SOURCES += \
+ plugin/qfactoryinterface.cpp \
plugin/qpluginloader.cpp \
plugin/qfactoryloader.cpp \
plugin/quuid.cpp \
diff --git a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm b/src/corelib/plugin/qfactoryinterface.cpp
index 8f30365186..0307d58315 100644
--- a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm
+++ b/src/corelib/plugin/qfactoryinterface.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
@@ -31,18 +31,13 @@
**
****************************************************************************/
-#include "qcocoaautoreleasepool.h"
+#include "qfactoryinterface.h"
QT_BEGIN_NAMESPACE
-QCocoaAutoReleasePool::QCocoaAutoReleasePool()
+QFactoryInterface::~QFactoryInterface()
{
- pool = [[NSAutoreleasePool alloc] init];
-}
-
-QCocoaAutoReleasePool::~QCocoaAutoReleasePool()
-{
- [pool release];
+ // must be empty until ### Qt 6
}
QT_END_NAMESPACE
diff --git a/src/corelib/plugin/qfactoryinterface.h b/src/corelib/plugin/qfactoryinterface.h
index e20864cd31..86a46fabfa 100644
--- a/src/corelib/plugin/qfactoryinterface.h
+++ b/src/corelib/plugin/qfactoryinterface.h
@@ -42,7 +42,7 @@ QT_BEGIN_NAMESPACE
struct Q_CORE_EXPORT QFactoryInterface
{
- virtual ~QFactoryInterface() {}
+ virtual ~QFactoryInterface();
virtual QStringList keys() const = 0;
};
diff --git a/src/corelib/plugin/qlibrary.h b/src/corelib/plugin/qlibrary.h
index 16bdf79206..77ad107c6f 100644
--- a/src/corelib/plugin/qlibrary.h
+++ b/src/corelib/plugin/qlibrary.h
@@ -59,10 +59,10 @@ public:
Q_FLAG(LoadHint)
Q_FLAG(LoadHints)
- explicit QLibrary(QObject *parent = 0);
- explicit QLibrary(const QString& fileName, QObject *parent = 0);
- explicit QLibrary(const QString& fileName, int verNum, QObject *parent = 0);
- explicit QLibrary(const QString& fileName, const QString &version, QObject *parent = 0);
+ explicit QLibrary(QObject *parent = Q_NULLPTR);
+ explicit QLibrary(const QString& fileName, QObject *parent = Q_NULLPTR);
+ explicit QLibrary(const QString& fileName, int verNum, QObject *parent = Q_NULLPTR);
+ explicit QLibrary(const QString& fileName, const QString &version, QObject *parent = Q_NULLPTR);
~QLibrary();
QFunctionPointer resolve(const char *symbol);
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index 988dad1d94..292ad30525 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -273,6 +273,13 @@ bool QPluginLoader::isLoaded() const
#if defined(QT_SHARED)
static QString locatePlugin(const QString& fileName)
{
+ const bool isAbsolute = QDir::isAbsolutePath(fileName);
+ if (isAbsolute) {
+ QFileInfo fi(fileName);
+ if (fi.isFile()) {
+ return fi.canonicalFilePath();
+ }
+ }
QStringList prefixes = QLibraryPrivate::prefixes_sys();
prefixes.prepend(QString());
QStringList suffixes = QLibraryPrivate::suffixes_sys(QString());
@@ -281,12 +288,18 @@ static QString locatePlugin(const QString& fileName)
// Split up "subdir/filename"
const int slash = fileName.lastIndexOf('/');
const QString baseName = fileName.mid(slash + 1);
- const QString basePath = fileName.left(slash + 1); // keep the '/'
+ const QString basePath = isAbsolute ? QString() : fileName.left(slash + 1); // keep the '/'
const bool debug = qt_debug_component();
- QStringList paths = QCoreApplication::libraryPaths();
- paths.prepend(QStringLiteral("./")); // search in current dir first
+ QStringList paths;
+ if (isAbsolute) {
+ paths.append(fileName.left(slash)); // don't include the '/'
+ } else {
+ paths = QCoreApplication::libraryPaths();
+ paths.prepend(QStringLiteral(".")); // search in current dir first
+ }
+
foreach (const QString &path, paths) {
foreach (const QString &prefix, prefixes) {
foreach (const QString &suffix, suffixes) {
@@ -337,12 +350,7 @@ void QPluginLoader::setFileName(const QString &fileName)
did_load = false;
}
- QFileInfo fi(fileName);
- QString fn;
- if (fi.isAbsolute())
- fn = fi.canonicalFilePath();
- else
- fn = locatePlugin(fileName);
+ const QString fn = locatePlugin(fileName);
d = QLibraryPrivate::findOrCreate(fn, QString(), lh);
if (!fn.isEmpty())
@@ -427,7 +435,9 @@ QObjectList QPluginLoader::staticInstances()
QObjectList instances;
const StaticPluginList *plugins = staticPluginList();
if (plugins) {
- for (int i = 0; i < plugins->size(); ++i)
+ const int numPlugins = plugins->size();
+ instances.reserve(numPlugins);
+ for (int i = 0; i < numPlugins; ++i)
instances += plugins->at(i).instance();
}
return instances;
diff --git a/src/corelib/plugin/qpluginloader.h b/src/corelib/plugin/qpluginloader.h
index b947e6ed9e..0ab25bbb07 100644
--- a/src/corelib/plugin/qpluginloader.h
+++ b/src/corelib/plugin/qpluginloader.h
@@ -50,8 +50,8 @@ class Q_CORE_EXPORT QPluginLoader : public QObject
Q_PROPERTY(QString fileName READ fileName WRITE setFileName)
Q_PROPERTY(QLibrary::LoadHints loadHints READ loadHints WRITE setLoadHints)
public:
- explicit QPluginLoader(QObject *parent = 0);
- explicit QPluginLoader(const QString &fileName, QObject *parent = 0);
+ explicit QPluginLoader(QObject *parent = Q_NULLPTR);
+ explicit QPluginLoader(const QString &fileName, QObject *parent = Q_NULLPTR);
~QPluginLoader();
QObject *instance();
diff --git a/src/corelib/statemachine/qabstractstate.h b/src/corelib/statemachine/qabstractstate.h
index 592c841c18..3aa4b2fabb 100644
--- a/src/corelib/statemachine/qabstractstate.h
+++ b/src/corelib/statemachine/qabstractstate.h
@@ -63,7 +63,7 @@ Q_SIGNALS:
void activeChanged(bool active);
protected:
- QAbstractState(QState *parent = 0);
+ QAbstractState(QState *parent = Q_NULLPTR);
virtual void onEntry(QEvent *event) = 0;
virtual void onExit(QEvent *event) = 0;
diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp
index 81b38ea4c4..7f04160a8f 100644
--- a/src/corelib/statemachine/qabstracttransition.cpp
+++ b/src/corelib/statemachine/qabstracttransition.cpp
@@ -254,7 +254,7 @@ QList<QAbstractState*> QAbstractTransition::targetStates() const
void QAbstractTransition::setTargetStates(const QList<QAbstractState*> &targets)
{
Q_D(QAbstractTransition);
- QList<QPointer<QAbstractState> > copy(d->targetStates);
+ QVector<QPointer<QAbstractState> > copy(d->targetStates);
bool sameList = true;
for (int i = 0; i < targets.size(); ++i) {
QAbstractState *target = targets.at(i);
diff --git a/src/corelib/statemachine/qabstracttransition.h b/src/corelib/statemachine/qabstracttransition.h
index 475a4dedfc..4398c41ca2 100644
--- a/src/corelib/statemachine/qabstracttransition.h
+++ b/src/corelib/statemachine/qabstracttransition.h
@@ -67,7 +67,7 @@ public:
};
Q_ENUM(TransitionType)
- QAbstractTransition(QState *sourceState = 0);
+ QAbstractTransition(QState *sourceState = Q_NULLPTR);
virtual ~QAbstractTransition();
QState *sourceState() const;
diff --git a/src/corelib/statemachine/qabstracttransition_p.h b/src/corelib/statemachine/qabstracttransition_p.h
index 4b0644acd9..1a28e5a73e 100644
--- a/src/corelib/statemachine/qabstracttransition_p.h
+++ b/src/corelib/statemachine/qabstracttransition_p.h
@@ -48,6 +48,7 @@
#include <private/qobject_p.h>
#include <QtCore/qlist.h>
+#include <QtCore/qvector.h>
#include <QtCore/qsharedpointer.h>
QT_BEGIN_NAMESPACE
@@ -72,7 +73,7 @@ public:
QStateMachine *machine() const;
void emitTriggered();
- QList<QPointer<QAbstractState> > targetStates;
+ QVector<QPointer<QAbstractState> > targetStates;
QAbstractTransition::TransitionType transitionType;
#ifndef QT_NO_ANIMATION
diff --git a/src/corelib/statemachine/qeventtransition.cpp b/src/corelib/statemachine/qeventtransition.cpp
index 096d667bc3..c10127fa68 100644
--- a/src/corelib/statemachine/qeventtransition.cpp
+++ b/src/corelib/statemachine/qeventtransition.cpp
@@ -102,6 +102,10 @@ QEventTransitionPrivate::QEventTransitionPrivate()
registered = false;
}
+QEventTransitionPrivate::~QEventTransitionPrivate()
+{
+}
+
QEventTransitionPrivate *QEventTransitionPrivate::get(QEventTransition *q)
{
return q->d_func();
diff --git a/src/corelib/statemachine/qeventtransition.h b/src/corelib/statemachine/qeventtransition.h
index 6909e855b1..5ec3b7bb26 100644
--- a/src/corelib/statemachine/qeventtransition.h
+++ b/src/corelib/statemachine/qeventtransition.h
@@ -49,8 +49,8 @@ class Q_CORE_EXPORT QEventTransition : public QAbstractTransition
Q_PROPERTY(QObject* eventSource READ eventSource WRITE setEventSource)
Q_PROPERTY(QEvent::Type eventType READ eventType WRITE setEventType)
public:
- QEventTransition(QState *sourceState = 0);
- QEventTransition(QObject *object, QEvent::Type type, QState *sourceState = 0);
+ QEventTransition(QState *sourceState = Q_NULLPTR);
+ QEventTransition(QObject *object, QEvent::Type type, QState *sourceState = Q_NULLPTR);
~QEventTransition();
QObject *eventSource() const;
diff --git a/src/corelib/statemachine/qeventtransition_p.h b/src/corelib/statemachine/qeventtransition_p.h
index 59b0fcb30f..3e430d86a9 100644
--- a/src/corelib/statemachine/qeventtransition_p.h
+++ b/src/corelib/statemachine/qeventtransition_p.h
@@ -55,6 +55,7 @@ class Q_CORE_EXPORT QEventTransitionPrivate : public QAbstractTransitionPrivate
Q_DECLARE_PUBLIC(QEventTransition)
public:
QEventTransitionPrivate();
+ ~QEventTransitionPrivate();
static QEventTransitionPrivate *get(QEventTransition *q);
diff --git a/src/corelib/statemachine/qfinalstate.h b/src/corelib/statemachine/qfinalstate.h
index 51c97b1545..2c76e7b6e6 100644
--- a/src/corelib/statemachine/qfinalstate.h
+++ b/src/corelib/statemachine/qfinalstate.h
@@ -46,7 +46,7 @@ class Q_CORE_EXPORT QFinalState : public QAbstractState
{
Q_OBJECT
public:
- QFinalState(QState *parent = 0);
+ QFinalState(QState *parent = Q_NULLPTR);
~QFinalState();
protected:
diff --git a/src/corelib/statemachine/qhistorystate.h b/src/corelib/statemachine/qhistorystate.h
index 549be15ab0..97ac376688 100644
--- a/src/corelib/statemachine/qhistorystate.h
+++ b/src/corelib/statemachine/qhistorystate.h
@@ -54,8 +54,8 @@ public:
};
Q_ENUM(HistoryType)
- QHistoryState(QState *parent = 0);
- QHistoryState(HistoryType type, QState *parent = 0);
+ QHistoryState(QState *parent = Q_NULLPTR);
+ QHistoryState(HistoryType type, QState *parent = Q_NULLPTR);
~QHistoryState();
QAbstractState *defaultState() const;
diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h
index bc56f4e9b7..c388323ec4 100644
--- a/src/corelib/statemachine/qsignaltransition.h
+++ b/src/corelib/statemachine/qsignaltransition.h
@@ -49,9 +49,9 @@ class Q_CORE_EXPORT QSignalTransition : public QAbstractTransition
Q_PROPERTY(QByteArray signal READ signal WRITE setSignal NOTIFY signalChanged)
public:
- QSignalTransition(QState *sourceState = 0);
+ QSignalTransition(QState *sourceState = Q_NULLPTR);
QSignalTransition(const QObject *sender, const char *signal,
- QState *sourceState = 0);
+ QState *sourceState = Q_NULLPTR);
~QSignalTransition();
QObject *senderObject() const;
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index 6e9fb63554..5abbbfd9ad 100644
--- a/src/corelib/statemachine/qstate.cpp
+++ b/src/corelib/statemachine/qstate.cpp
@@ -320,7 +320,7 @@ void QState::addTransition(QAbstractTransition *transition)
}
transition->setParent(this);
- const QList<QPointer<QAbstractState> > &targets = QAbstractTransitionPrivate::get(transition)->targetStates;
+ const QVector<QPointer<QAbstractState> > &targets = QAbstractTransitionPrivate::get(transition)->targetStates;
for (int i = 0; i < targets.size(); ++i) {
QAbstractState *t = targets.at(i).data();
if (!t) {
diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h
index a74c782027..0300a9ef2d 100644
--- a/src/corelib/statemachine/qstate.h
+++ b/src/corelib/statemachine/qstate.h
@@ -66,8 +66,8 @@ public:
};
Q_ENUM(RestorePolicy)
- QState(QState *parent = 0);
- QState(ChildMode childMode, QState *parent = 0);
+ QState(QState *parent = Q_NULLPTR);
+ QState(ChildMode childMode, QState *parent = Q_NULLPTR);
~QState();
QAbstractState *errorState() const;
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index e5d019dc8b..3e513459ff 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -383,10 +383,6 @@ static QList<QAbstractState *> getEffectiveTargetStates(QAbstractTransition *tra
return targetsList;
}
-template <class T>
-static uint qHash(const QPointer<T> &p)
-{ return qHash(p.data()); }
-
QStateMachinePrivate::QStateMachinePrivate()
{
isMachine = true;
@@ -2097,23 +2093,6 @@ void QStateMachinePrivate::cancelAllDelayedEvents()
delayedEvents.clear();
}
-void QStateMachinePrivate::emitStateFinished(QState *forState, QFinalState *guiltyState)
-{
- Q_UNUSED(guiltyState);
- Q_ASSERT(guiltyState);
-
-#ifdef QSTATEMACHINE_DEBUG
- Q_Q(QStateMachine);
- qDebug() << q << ": emitting finished signal for" << forState;
-#endif
-
- QStatePrivate::get(forState)->emitFinished();
-}
-
-void QStateMachinePrivate::startupHook()
-{
-}
-
/*
This function is called when the state machine is performing no
microstep because no transition is enabled (i.e. an event is ignored).
@@ -2154,6 +2133,24 @@ void QStateMachinePrivate::endMacrostep(bool didChange)
Q_UNUSED(didChange);
}
+
+void QStateMachinePrivate::emitStateFinished(QState *forState, QFinalState *guiltyState)
+{
+ Q_UNUSED(guiltyState);
+ Q_ASSERT(guiltyState);
+
+#ifdef QSTATEMACHINE_DEBUG
+ Q_Q(QStateMachine);
+ qDebug() << q << ": emitting finished signal for" << forState;
+#endif
+
+ QStatePrivate::get(forState)->emitFinished();
+}
+
+void QStateMachinePrivate::startupHook()
+{
+}
+
namespace _QStateMachine_Internal{
class GoToStateTransition : public QAbstractTransition
@@ -2453,6 +2450,7 @@ void QStateMachinePrivate::handleTransitionSignal(QObject *sender, int signalInd
QMetaMethod method = meta->method(signalIndex);
int argc = method.parameterCount();
QList<QVariant> vargs;
+ vargs.reserve(argc);
for (int i = 0; i < argc; ++i) {
int type = method.parameterType(i);
vargs.append(QVariant(type, argv[i+1]));
diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h
index d6c3b7bfa7..5fca034386 100644
--- a/src/corelib/statemachine/qstatemachine.h
+++ b/src/corelib/statemachine/qstatemachine.h
@@ -104,8 +104,8 @@ public:
NoCommonAncestorForTransitionError
};
- explicit QStateMachine(QObject *parent = 0);
- explicit QStateMachine(QState::ChildMode childMode, QObject *parent = 0);
+ explicit QStateMachine(QObject *parent = Q_NULLPTR);
+ explicit QStateMachine(QState::ChildMode childMode, QObject *parent = Q_NULLPTR);
~QStateMachine();
void addState(QAbstractState *state);
diff --git a/src/corelib/thread/qexception.cpp b/src/corelib/thread/qexception.cpp
index acc3663936..04a03b8623 100644
--- a/src/corelib/thread/qexception.cpp
+++ b/src/corelib/thread/qexception.cpp
@@ -107,6 +107,16 @@ QT_BEGIN_NAMESPACE
\internal
*/
+QException::~QException()
+#ifdef Q_COMPILER_NOEXCEPT
+ noexcept
+#else
+ throw()
+#endif
+{
+ // must stay empty until ### Qt 6
+}
+
void QException::raise() const
{
QException e = *this;
@@ -118,6 +128,16 @@ QException *QException::clone() const
return new QException(*this);
}
+QUnhandledException::~QUnhandledException()
+#ifdef Q_COMPILER_NOEXCEPT
+ noexcept
+#else
+ throw()
+#endif
+{
+ // must stay empty until ### Qt 6
+}
+
void QUnhandledException::raise() const
{
QUnhandledException e = *this;
diff --git a/src/corelib/thread/qexception.h b/src/corelib/thread/qexception.h
index 55fc441020..b15ae5095a 100644
--- a/src/corelib/thread/qexception.h
+++ b/src/corelib/thread/qexception.h
@@ -53,6 +53,13 @@ QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QException : public std::exception
{
public:
+ ~QException()
+#ifdef Q_COMPILER_NOEXCEPT
+ noexcept
+#else
+ throw()
+#endif
+ ;
virtual void raise() const;
virtual QException *clone() const;
};
@@ -60,6 +67,13 @@ public:
class Q_CORE_EXPORT QUnhandledException : public QException
{
public:
+ ~QUnhandledException()
+#ifdef Q_COMPILER_NOEXCEPT
+ noexcept
+#else
+ throw()
+#endif
+ ;
void raise() const Q_DECL_OVERRIDE;
QUnhandledException *clone() const Q_DECL_OVERRIDE;
};
@@ -70,7 +84,7 @@ class Base;
class Q_CORE_EXPORT ExceptionHolder
{
public:
- ExceptionHolder(QException *exception = 0);
+ ExceptionHolder(QException *exception = Q_NULLPTR);
ExceptionHolder(const ExceptionHolder &other);
void operator=(const ExceptionHolder &other);
~ExceptionHolder();
diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h
index 01eb043a5e..8c1f7e7d82 100644
--- a/src/corelib/thread/qfutureinterface.h
+++ b/src/corelib/thread/qfutureinterface.h
@@ -299,7 +299,7 @@ public:
void reportResult(const void *, int) { }
void reportResults(const QVector<void> &, int) { }
- void reportFinished(const void * = 0) { QFutureInterfaceBase::reportFinished(); }
+ void reportFinished(const void * = Q_NULLPTR) { QFutureInterfaceBase::reportFinished(); }
};
QT_END_NAMESPACE
diff --git a/src/corelib/thread/qfuturewatcher.h b/src/corelib/thread/qfuturewatcher.h
index 63558d4a0f..42a22d9063 100644
--- a/src/corelib/thread/qfuturewatcher.h
+++ b/src/corelib/thread/qfuturewatcher.h
@@ -52,7 +52,7 @@ class Q_CORE_EXPORT QFutureWatcherBase : public QObject
Q_DECLARE_PRIVATE(QFutureWatcherBase)
public:
- explicit QFutureWatcherBase(QObject *parent = 0);
+ explicit QFutureWatcherBase(QObject *parent = Q_NULLPTR);
// de-inline dtor
int progressValue() const;
@@ -179,7 +179,7 @@ template <>
class QFutureWatcher<void> : public QFutureWatcherBase
{
public:
- explicit QFutureWatcher(QObject *_parent = 0)
+ explicit QFutureWatcher(QObject *_parent = Q_NULLPTR)
: QFutureWatcherBase(_parent)
{ }
~QFutureWatcher()
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 63c488747f..0c5a73b4df 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -73,16 +73,16 @@ public:
private:
inline bool fastTryLock() Q_DECL_NOTHROW {
- return d_ptr.testAndSetAcquire(0, dummyLocked());
+ return d_ptr.testAndSetAcquire(Q_NULLPTR, dummyLocked());
}
inline bool fastTryUnlock() Q_DECL_NOTHROW {
- return d_ptr.testAndSetRelease(dummyLocked(), 0);
+ return d_ptr.testAndSetRelease(dummyLocked(), Q_NULLPTR);
}
inline bool fastTryLock(QMutexData *&current) Q_DECL_NOTHROW {
- return d_ptr.testAndSetAcquire(0, dummyLocked(), current);
+ return d_ptr.testAndSetAcquire(Q_NULLPTR, dummyLocked(), current);
}
inline bool fastTryUnlock(QMutexData *&current) Q_DECL_NOTHROW {
- return d_ptr.testAndSetRelease(dummyLocked(), 0, current);
+ return d_ptr.testAndSetRelease(dummyLocked(), Q_NULLPTR, current);
}
void lockInternal() QT_MUTEX_LOCK_NOEXCEPT;
diff --git a/src/corelib/thread/qmutex_win.cpp b/src/corelib/thread/qmutex_win.cpp
index c4130fdba5..c24ea58868 100644
--- a/src/corelib/thread/qmutex_win.cpp
+++ b/src/corelib/thread/qmutex_win.cpp
@@ -55,10 +55,10 @@ QMutexPrivate::~QMutexPrivate()
bool QMutexPrivate::wait(int timeout)
{
-#ifndef Q_OS_WINRT
- return (WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0);
-#else
+#ifndef Q_OS_WINCE
return (WaitForSingleObjectEx(event, timeout < 0 ? INFINITE : timeout, FALSE) == WAIT_OBJECT_0);
+#else
+ return (WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0);
#endif
}
diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h
index fbcb8ad3cd..7ecaa231b2 100644
--- a/src/corelib/thread/qresultstore.h
+++ b/src/corelib/thread/qresultstore.h
@@ -61,8 +61,8 @@ class ResultItem
public:
ResultItem(const void *_result, int _count) : m_count(_count), result(_result) { } // contruct with vector of results
ResultItem(const void *_result) : m_count(0), result(_result) { } // construct with result
- ResultItem() : m_count(0), result(0) { }
- bool isValid() const { return result != 0; }
+ ResultItem() : m_count(0), result(Q_NULLPTR) { }
+ bool isValid() const { return result != Q_NULLPTR; }
bool isVector() const { return m_count != 0; }
int count() const { return (m_count == 0) ? 1 : m_count; }
int m_count; // result is either a pointer to a result or to a vector of results,
diff --git a/src/corelib/thread/qrunnable.cpp b/src/corelib/thread/qrunnable.cpp
index 64a2613d27..04aa39a81e 100644
--- a/src/corelib/thread/qrunnable.cpp
+++ b/src/corelib/thread/qrunnable.cpp
@@ -31,6 +31,15 @@
**
****************************************************************************/
+#include "qrunnable.h"
+
+QT_BEGIN_NAMESPACE
+
+QRunnable::~QRunnable()
+{
+ // Must be empty until ### Qt 6
+}
+
/*!
\class QRunnable
\inmodule QtCore
@@ -98,3 +107,5 @@
\sa autoDelete(), QThreadPool
*/
+
+QT_END_NAMESPACE
diff --git a/src/corelib/thread/qrunnable.h b/src/corelib/thread/qrunnable.h
index f00c58d51d..28d14a46c0 100644
--- a/src/corelib/thread/qrunnable.h
+++ b/src/corelib/thread/qrunnable.h
@@ -38,20 +38,21 @@
QT_BEGIN_NAMESPACE
-
-class QRunnable
+class Q_CORE_EXPORT QRunnable
{
int ref;
friend class QThreadPool;
friend class QThreadPoolPrivate;
friend class QThreadPoolThread;
-
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ Q_DISABLE_COPY(QRunnable)
+#endif
public:
virtual void run() = 0;
QRunnable() : ref(0) { }
- virtual ~QRunnable() { }
+ virtual ~QRunnable();
bool autoDelete() const { return ref != -1; }
void setAutoDelete(bool _autoDelete) { ref = _autoDelete ? 0 : -1; }
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index dc231a00f8..0c009db930 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -38,7 +38,6 @@
#include "qabstracteventdispatcher.h"
#include <qeventloop.h>
-#include <qhash.h>
#include "qthread_p.h"
#include "private/qcoreapplication_p.h"
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index bfc469583d..d333980bf4 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -55,7 +55,7 @@ public:
static int idealThreadCount() Q_DECL_NOTHROW;
static void yieldCurrentThread();
- explicit QThread(QObject *parent = 0);
+ explicit QThread(QObject *parent = Q_NULLPTR);
~QThread();
enum Priority {
@@ -116,7 +116,7 @@ protected:
static void setTerminationEnabled(bool enabled = true);
protected:
- QThread(QThreadPrivate &dd, QObject *parent = 0);
+ QThread(QThreadPrivate &dd, QObject *parent = Q_NULLPTR);
private:
Q_DECLARE_PRIVATE(QThread)
diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h
index b1ca808a99..95b41a0417 100644
--- a/src/corelib/thread/qthreadpool.h
+++ b/src/corelib/thread/qthreadpool.h
@@ -55,7 +55,7 @@ class Q_CORE_EXPORT QThreadPool : public QObject
friend class QFutureInterfaceBase;
public:
- QThreadPool(QObject *parent = 0);
+ QThreadPool(QObject *parent = Q_NULLPTR);
~QThreadPool();
static QThreadPool *globalInstance();
diff --git a/src/corelib/thread/qwaitcondition_win.cpp b/src/corelib/thread/qwaitcondition_win.cpp
index ef8330570e..3ea34461d3 100644
--- a/src/corelib/thread/qwaitcondition_win.cpp
+++ b/src/corelib/thread/qwaitcondition_win.cpp
@@ -109,10 +109,10 @@ bool QWaitConditionPrivate::wait(QWaitConditionEvent *wce, unsigned long time)
{
// wait for the event
bool ret = false;
-#ifndef Q_OS_WINRT
- switch (WaitForSingleObject(wce->event, time)) {
-#else
+#ifndef Q_OS_WINCE
switch (WaitForSingleObjectEx(wce->event, time, FALSE)) {
+#else
+ switch (WaitForSingleObject(wce->event, time)) {
#endif
default: break;
diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h
index ff4d5a3ebd..57fbdf0eba 100644..100755
--- a/src/corelib/tools/qalgorithms.h
+++ b/src/corelib/tools/qalgorithms.h
@@ -584,6 +584,131 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(long unsigne
#undef QALGORITHMS_USE_BUILTIN_POPCOUNT
#endif
+Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) Q_DECL_NOTHROW
+{
+#if defined(Q_CC_GNU)
+ return v ? __builtin_ctz(v) : 32U;
+#else
+ // see http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightParallel
+ unsigned int c = 32; // c will be the number of zero bits on the right
+ v &= -signed(v);
+ if (v) c--;
+ if (v & 0x0000FFFF) c -= 16;
+ if (v & 0x00FF00FF) c -= 8;
+ if (v & 0x0F0F0F0F) c -= 4;
+ if (v & 0x33333333) c -= 2;
+ if (v & 0x55555555) c -= 1;
+ return c;
+#endif
+}
+
+Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) Q_DECL_NOTHROW
+{
+#if defined(Q_CC_GNU)
+ return v ? __builtin_ctz(v) : 8U;
+#else
+ unsigned int c = 8; // c will be the number of zero bits on the right
+ v &= -signed(v);
+ if (v) c--;
+ if (v & 0x0000000F) c -= 4;
+ if (v & 0x00000033) c -= 2;
+ if (v & 0x00000055) c -= 1;
+ return c;
+#endif
+}
+
+Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) Q_DECL_NOTHROW
+{
+#if defined(Q_CC_GNU)
+ return v ? __builtin_ctz(v) : 16U;
+#else
+ unsigned int c = 16; // c will be the number of zero bits on the right
+ v &= -signed(v);
+ if (v) c--;
+ if (v & 0x000000FF) c -= 8;
+ if (v & 0x00000F0F) c -= 4;
+ if (v & 0x00003333) c -= 2;
+ if (v & 0x00005555) c -= 1;
+ return c;
+#endif
+}
+
+Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint64 v) Q_DECL_NOTHROW
+{
+#if defined(Q_CC_GNU)
+ return v ? __builtin_ctzll(v) : 64;
+#else
+ quint32 x = static_cast<quint32>(v);
+ return x ? qCountTrailingZeroBits(x)
+ : 32 + qCountTrailingZeroBits(static_cast<quint32>(v >> 32));
+#endif
+}
+
+Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(unsigned long v) Q_DECL_NOTHROW
+{
+ return qCountTrailingZeroBits(QIntegerForSizeof<long>::Unsigned(v));
+}
+
+Q_DECL_CONSTEXPR inline uint qCountLeadingZeroBits(quint32 v) Q_DECL_NOTHROW
+{
+#if defined(Q_CC_GNU)
+ return v ? __builtin_clz(v) : 32U;
+#else
+ // Hacker's Delight, 2nd ed. Fig 5-16, p. 102
+ v = v | (v >> 1);
+ v = v | (v >> 2);
+ v = v | (v >> 4);
+ v = v | (v >> 8);
+ v = v | (v >> 16);
+ return qPopulationCount(~v);
+#endif
+}
+
+Q_DECL_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) Q_DECL_NOTHROW
+{
+#if defined(Q_CC_GNU)
+ return v ? __builtin_clz(v)-24U : 8U;
+#else
+ v = v | (v >> 1);
+ v = v | (v >> 2);
+ v = v | (v >> 4);
+ return qPopulationCount(static_cast<quint8>(~v));
+#endif
+}
+
+Q_DECL_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) Q_DECL_NOTHROW
+{
+#if defined(Q_CC_GNU)
+ return v ? __builtin_clz(v)-16U : 16U;
+#else
+ v = v | (v >> 1);
+ v = v | (v >> 2);
+ v = v | (v >> 4);
+ v = v | (v >> 8);
+ return qPopulationCount(static_cast<quint16>(~v));
+#endif
+}
+
+Q_DECL_CONSTEXPR inline uint qCountLeadingZeroBits(quint64 v) Q_DECL_NOTHROW
+{
+#if defined(Q_CC_GNU)
+ return v ? __builtin_clzll(v) : 64U;
+#else
+ v = v | (v >> 1);
+ v = v | (v >> 2);
+ v = v | (v >> 4);
+ v = v | (v >> 8);
+ v = v | (v >> 16);
+ v = v | (v >> 32);
+ return qPopulationCount(~v);
+#endif
+}
+
+Q_DECL_CONSTEXPR inline uint qCountLeadingZeroBits(unsigned long v) Q_DECL_NOTHROW
+{
+ return qCountLeadingZeroBits(QIntegerForSizeof<long>::Unsigned(v));
+}
+
QT_WARNING_POP
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc
index 193042e017..dac353fa70 100644..100755
--- a/src/corelib/tools/qalgorithms.qdoc
+++ b/src/corelib/tools/qalgorithms.qdoc
@@ -785,3 +785,73 @@
\since 5.2
\overload
*/
+
+/*!
+ \fn uint qCountTrailingZeroBits(quint8 v)
+ \relates <QtAlgorithms>
+ \since 5.6
+
+ Returns the number of consecutive zero bits in \a v, when searching from the LSB.
+ For example, qCountTrailingZeroBits(1) returns 0 and qCountTrailingZeroBits(8) returns 3.
+ */
+
+/*!
+ \fn uint qCountTrailingZeroBits(quint16 v)
+ \relates <QtAlgorithms>
+ \since 5.6
+ \overload
+ */
+
+/*!
+ \fn uint qCountTrailingZeroBits(quint32 v)
+ \relates <QtAlgorithms>
+ \since 5.6
+ \overload
+ */
+
+/*!
+ \fn uint qCountTrailingZeroBits(quint64 v)
+ \relates <QtAlgorithms>
+ \since 5.6
+ \overload
+ */
+
+/*!
+ \fn uint qCountLeadingZeroBits(quint8 v)
+ \relates <QtAlgorithms>
+ \since 5.6
+
+ Returns the number of consecutive zero bits in \a v, when searching from the MSB.
+ For example, qCountLeadingZeroBits(quint8(1)) returns 7 and
+ qCountLeadingZeroBits(quint8(8)) returns 4.
+ */
+
+/*!
+ \fn uint qCountLeadingZeroBits(quint16 v)
+ \relates <QtAlgorithms>
+ \since 5.6
+
+ Returns the number of consecutive zero bits in \a v, when searching from the MSB.
+ For example, qCountLeadingZeroBits(quint16(1)) returns 15 and
+ qCountLeadingZeroBits(quint16(8)) returns 12.
+ */
+
+/*!
+ \fn uint qCountLeadingZeroBits(quint32 v)
+ \relates <QtAlgorithms>
+ \since 5.6
+
+ Returns the number of consecutive zero bits in \a v, when searching from the MSB.
+ For example, qCountLeadingZeroBits(quint32(1)) returns 31 and
+ qCountLeadingZeroBits(quint32(8)) returns 28.
+ */
+
+/*!
+ \fn uint qCountLeadingZeroBits(quint64 v)
+ \relates <QtAlgorithms>
+ \since 5.6
+
+ Returns the number of consecutive zero bits in \a v, when searching from the MSB.
+ For example, qCountLeadingZeroBits(quint64(1)) returns 63 and
+ qCountLeadingZeroBits(quint64(8)) returns 60.
+ */
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index df35a1cb62..95c1d5f22e 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -132,7 +132,7 @@ struct QTypedArrayData
typedef T *pointer;
typedef T &reference;
- inline iterator() : i(0) {}
+ inline iterator() : i(Q_NULLPTR) {}
inline iterator(T *n) : i(n) {}
inline iterator(const iterator &o): i(o.i){} // #### Qt 6: remove, the implicit version is fine
inline T &operator*() const { return *i; }
@@ -166,7 +166,7 @@ struct QTypedArrayData
typedef const T *pointer;
typedef const T &reference;
- inline const_iterator() : i(0) {}
+ inline const_iterator() : i(Q_NULLPTR) {}
inline const_iterator(const T *n) : i(n) {}
inline const_iterator(const const_iterator &o): i(o.i) {} // #### Qt 6: remove, the default version is fine
inline explicit const_iterator(const iterator &o): i(o.i) {}
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index da5d00311a..0ed701f4fa 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -41,6 +41,7 @@
#include "qlocale_p.h"
#include "qstringalgorithms_p.h"
#include "qscopedpointer.h"
+#include "qbytearray_p.h"
#include <qdatastream.h>
#include <qmath.h>
@@ -123,8 +124,8 @@ int qFindByteArray(
int qAllocMore(int alloc, int extra) Q_DECL_NOTHROW
{
- Q_ASSERT(alloc >= 0 && extra >= 0);
- Q_ASSERT_X(uint(alloc) < QByteArray::MaxSize, "qAllocMore", "Requested size is too large!");
+ Q_ASSERT(alloc >= 0 && extra >= 0 && extra <= MaxAllocSize);
+ Q_ASSERT_X(alloc <= MaxAllocSize - extra, "qAllocMore", "Requested size is too large!");
unsigned nalloc = qNextPowerOfTwo(alloc + extra);
@@ -838,15 +839,6 @@ static inline char qToLower(char c)
*/
/*!
- \variable QByteArray::MaxSize
- \internal
- \since 5.4
-
- The maximum size of a QByteArray, in bytes. Also applies to a the maximum
- storage size of QString and QVector, though not the number of elements.
-*/
-
-/*!
\enum QByteArray::Base64Option
\since 5.2
@@ -1574,7 +1566,7 @@ void QByteArray::reallocData(uint alloc, Data::AllocationOptions options)
d = x;
} else {
if (options & Data::Grow) {
- if (alloc > uint(MaxAllocSize) - uint(sizeof(Data)))
+ if (alloc > MaxByteArraySize)
qBadAlloc();
alloc = qAllocMore(alloc, sizeof(Data));
}
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 6d14cd5131..7388c4eee5 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -162,9 +162,6 @@ private:
typedef QTypedArrayData<char> Data;
public:
- // undocumented:
- static const quint64 MaxSize = (1 << 30) - sizeof(Data);
-
enum Base64Option {
Base64Encoding = 0,
Base64UrlEncoding = 1,
@@ -338,16 +335,16 @@ public:
inline QT_ASCII_CAST_WARN bool operator>=(const QString &s2) const;
#endif
- short toShort(bool *ok = 0, int base = 10) const;
- ushort toUShort(bool *ok = 0, int base = 10) const;
- int toInt(bool *ok = 0, int base = 10) const;
- uint toUInt(bool *ok = 0, int base = 10) const;
- long toLong(bool *ok = 0, int base = 10) const;
- ulong toULong(bool *ok = 0, int base = 10) const;
- qlonglong toLongLong(bool *ok = 0, int base = 10) const;
- qulonglong toULongLong(bool *ok = 0, int base = 10) const;
- float toFloat(bool *ok = 0) const;
- double toDouble(bool *ok = 0) const;
+ short toShort(bool *ok = Q_NULLPTR, int base = 10) const;
+ ushort toUShort(bool *ok = Q_NULLPTR, int base = 10) const;
+ int toInt(bool *ok = Q_NULLPTR, int base = 10) const;
+ uint toUInt(bool *ok = Q_NULLPTR, int base = 10) const;
+ long toLong(bool *ok = Q_NULLPTR, int base = 10) const;
+ ulong toULong(bool *ok = Q_NULLPTR, int base = 10) const;
+ qlonglong toLongLong(bool *ok = Q_NULLPTR, int base = 10) const;
+ qulonglong toULongLong(bool *ok = Q_NULLPTR, int base = 10) const;
+ float toFloat(bool *ok = Q_NULLPTR) const;
+ double toDouble(bool *ok = Q_NULLPTR) const;
QByteArray toBase64(Base64Options options) const;
QByteArray toBase64() const; // ### Qt6 merge with previous
QByteArray toHex() const;
diff --git a/src/corelib/tools/qbytearray_p.h b/src/corelib/tools/qbytearray_p.h
new file mode 100644
index 0000000000..78c667aa90
--- /dev/null
+++ b/src/corelib/tools/qbytearray_p.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBYTEARRAY_P_H
+#define QBYTEARRAY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qtypetraits.h>
+#include "qtools_p.h"
+
+QT_BEGIN_NAMESPACE
+
+enum {
+ // Define as enum to force inlining. Don't expose MaxAllocSize in a public header.
+ MaxByteArraySize = MaxAllocSize - sizeof(QtPrivate::remove_pointer<QByteArray::DataPtr>::type)
+};
+
+QT_END_NAMESPACE
+
+#endif // QBYTEARRAY_P_H
diff --git a/src/corelib/tools/qbytearraylist.h b/src/corelib/tools/qbytearraylist.h
index f8539ca07a..8b832b7760 100644
--- a/src/corelib/tools/qbytearraylist.h
+++ b/src/corelib/tools/qbytearraylist.h
@@ -61,7 +61,7 @@ protected:
#endif
public:
inline QByteArray join() const
- { return QtPrivate::QByteArrayList_join(self(), 0, 0); }
+ { return QtPrivate::QByteArrayList_join(self(), Q_NULLPTR, 0); }
inline QByteArray join(const QByteArray &sep) const
{ return QtPrivate::QByteArrayList_join(self(), sep.constData(), sep.size()); }
inline QByteArray join(char sep) const
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index 5c094772b8..56904c91d7 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -681,7 +681,7 @@ QT_BEGIN_NAMESPACE
Note that this gives no indication of whether the character is
available in a particular font.
*/
-bool QChar::isPrint(uint ucs4)
+bool QChar::isPrint(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -714,7 +714,7 @@ bool QChar::isPrint(uint ucs4)
/*!
\internal
*/
-bool QT_FASTCALL QChar::isSpace_helper(uint ucs4)
+bool QT_FASTCALL QChar::isSpace_helper(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -740,7 +740,7 @@ bool QT_FASTCALL QChar::isSpace_helper(uint ucs4)
Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
a mark (Mark_* categories); otherwise returns \c false.
*/
-bool QChar::isMark(uint ucs4)
+bool QChar::isMark(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -764,7 +764,7 @@ bool QChar::isMark(uint ucs4)
Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
a punctuation mark (Punctuation_* categories); otherwise returns \c false.
*/
-bool QChar::isPunct(uint ucs4)
+bool QChar::isPunct(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -792,7 +792,7 @@ bool QChar::isPunct(uint ucs4)
Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
a symbol (Symbol_* categories); otherwise returns \c false.
*/
-bool QChar::isSymbol(uint ucs4)
+bool QChar::isSymbol(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -822,7 +822,7 @@ bool QChar::isSymbol(uint ucs4)
/*!
\internal
*/
-bool QT_FASTCALL QChar::isLetter_helper(uint ucs4)
+bool QT_FASTCALL QChar::isLetter_helper(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -857,7 +857,7 @@ bool QT_FASTCALL QChar::isLetter_helper(uint ucs4)
/*!
\internal
*/
-bool QT_FASTCALL QChar::isNumber_helper(uint ucs4)
+bool QT_FASTCALL QChar::isNumber_helper(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -886,7 +886,7 @@ bool QT_FASTCALL QChar::isNumber_helper(uint ucs4)
/*!
\internal
*/
-bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4)
+bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -1049,7 +1049,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4)
Returns the numeric value of the digit specified by the UCS-4-encoded
character, \a ucs4, or -1 if the character is not a digit.
*/
-int QChar::digitValue(uint ucs4)
+int QChar::digitValue(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return -1;
@@ -1066,7 +1066,7 @@ int QChar::digitValue(uint ucs4)
\overload
Returns the category of the UCS-4-encoded character specified by \a ucs4.
*/
-QChar::Category QChar::category(uint ucs4)
+QChar::Category QChar::category(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return QChar::Other_NotAssigned;
@@ -1083,7 +1083,7 @@ QChar::Category QChar::category(uint ucs4)
\overload
Returns the direction of the UCS-4-encoded character specified by \a ucs4.
*/
-QChar::Direction QChar::direction(uint ucs4)
+QChar::Direction QChar::direction(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return QChar::DirL;
@@ -1106,7 +1106,7 @@ QChar::Direction QChar::direction(uint ucs4)
character specified by \a ucs4
(needed for certain languages such as Arabic or Syriac).
*/
-QChar::JoiningType QChar::joiningType(uint ucs4)
+QChar::JoiningType QChar::joiningType(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return QChar::Joining_None;
@@ -1129,7 +1129,7 @@ QChar::JoiningType QChar::joiningType(uint ucs4)
Returns information about the joining properties of the UCS-4-encoded
character specified by \a ucs4 (needed for certain languages such as Arabic).
*/
-QChar::Joining QChar::joining(uint ucs4)
+QChar::Joining QChar::joining(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return QChar::OtherJoining;
@@ -1165,7 +1165,7 @@ QChar::Joining QChar::joining(uint ucs4)
\sa mirroredChar()
*/
-bool QChar::hasMirrored(uint ucs4)
+bool QChar::hasMirrored(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -1247,7 +1247,7 @@ bool QChar::hasMirrored(uint ucs4)
\sa hasMirrored()
*/
-uint QChar::mirroredChar(uint ucs4)
+uint QChar::mirroredChar(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
@@ -1331,7 +1331,7 @@ QString QChar::decomposition(uint ucs4)
Returns the tag defining the composition of the UCS-4-encoded character
specified by \a ucs4. Returns QChar::NoDecomposition if no decomposition exists.
*/
-QChar::Decomposition QChar::decompositionTag(uint ucs4)
+QChar::Decomposition QChar::decompositionTag(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount)
return QChar::Canonical;
@@ -1357,7 +1357,7 @@ QChar::Decomposition QChar::decompositionTag(uint ucs4)
Returns the combining class for the UCS-4-encoded character specified by
\a ucs4, as defined in the Unicode standard.
*/
-unsigned char QChar::combiningClass(uint ucs4)
+unsigned char QChar::combiningClass(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return 0;
@@ -1378,7 +1378,7 @@ unsigned char QChar::combiningClass(uint ucs4)
Returns the Unicode script property value for the character specified in
its UCS-4-encoded form as \a ucs4.
*/
-QChar::Script QChar::script(uint ucs4)
+QChar::Script QChar::script(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return QChar::Script_Unknown;
@@ -1396,7 +1396,7 @@ QChar::Script QChar::script(uint ucs4)
Returns the Unicode version that introduced the character specified in
its UCS-4-encoded form as \a ucs4.
*/
-QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4)
+QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return QChar::Unicode_Unassigned;
@@ -1406,14 +1406,14 @@ QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4)
/*!
Returns the most recent supported Unicode version.
*/
-QChar::UnicodeVersion QChar::currentUnicodeVersion()
+QChar::UnicodeVersion QChar::currentUnicodeVersion() Q_DECL_NOTHROW
{
return UNICODE_DATA_VERSION;
}
template <typename T>
-Q_DECL_CONST_FUNCTION static inline T toLowerCase_helper(T uc)
+Q_DECL_CONST_FUNCTION static inline T toLowerCase_helper(T uc) Q_DECL_NOTHROW
{
const QUnicodeTables::Properties *p = qGetProp(uc);
if (p->lowerCaseSpecial) {
@@ -1424,7 +1424,7 @@ Q_DECL_CONST_FUNCTION static inline T toLowerCase_helper(T uc)
}
template <typename T>
-Q_DECL_CONST_FUNCTION static inline T toUpperCase_helper(T uc)
+Q_DECL_CONST_FUNCTION static inline T toUpperCase_helper(T uc) Q_DECL_NOTHROW
{
const QUnicodeTables::Properties *p = qGetProp(uc);
if (p->upperCaseSpecial) {
@@ -1435,7 +1435,7 @@ Q_DECL_CONST_FUNCTION static inline T toUpperCase_helper(T uc)
}
template <typename T>
-Q_DECL_CONST_FUNCTION static inline T toTitleCase_helper(T uc)
+Q_DECL_CONST_FUNCTION static inline T toTitleCase_helper(T uc) Q_DECL_NOTHROW
{
const QUnicodeTables::Properties *p = qGetProp(uc);
if (p->titleCaseSpecial) {
@@ -1446,7 +1446,7 @@ Q_DECL_CONST_FUNCTION static inline T toTitleCase_helper(T uc)
}
template <typename T>
-Q_DECL_CONST_FUNCTION static inline T toCaseFolded_helper(T uc)
+Q_DECL_CONST_FUNCTION static inline T toCaseFolded_helper(T uc) Q_DECL_NOTHROW
{
const QUnicodeTables::Properties *p = qGetProp(uc);
if (p->caseFoldSpecial) {
@@ -1469,7 +1469,7 @@ Q_DECL_CONST_FUNCTION static inline T toCaseFolded_helper(T uc)
by \a ucs4 if the character is uppercase or titlecase; otherwise returns
the character itself.
*/
-uint QChar::toLower(uint ucs4)
+uint QChar::toLower(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
@@ -1489,7 +1489,7 @@ uint QChar::toLower(uint ucs4)
by \a ucs4 if the character is lowercase or titlecase; otherwise returns
the character itself.
*/
-uint QChar::toUpper(uint ucs4)
+uint QChar::toUpper(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
@@ -1509,7 +1509,7 @@ uint QChar::toUpper(uint ucs4)
by \a ucs4 if the character is lowercase or uppercase; otherwise returns
the character itself.
*/
-uint QChar::toTitleCase(uint ucs4)
+uint QChar::toTitleCase(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
@@ -1524,7 +1524,7 @@ static inline uint foldCase(const ushort *ch, const ushort *start)
return toCaseFolded_helper<uint>(c);
}
-static inline uint foldCase(uint ch, uint &last)
+static inline uint foldCase(uint ch, uint &last) Q_DECL_NOTHROW
{
uint c = ch;
if (QChar(c).isLowSurrogate() && QChar(last).isHighSurrogate())
@@ -1533,7 +1533,7 @@ static inline uint foldCase(uint ch, uint &last)
return toCaseFolded_helper<uint>(c);
}
-static inline ushort foldCase(ushort ch)
+static inline ushort foldCase(ushort ch) Q_DECL_NOTHROW
{
return toCaseFolded_helper<ushort>(ch);
}
@@ -1550,7 +1550,7 @@ static inline ushort foldCase(ushort ch)
Returns the case folded equivalent of the UCS-4-encoded character specified
by \a ucs4. For most Unicode characters this is the same as toLower().
*/
-uint QChar::toCaseFolded(uint ucs4)
+uint QChar::toCaseFolded(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h
index 97e2aa7088..fc1fc7bc16 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/tools/qchar.h
@@ -44,9 +44,9 @@ class QString;
struct QLatin1Char
{
public:
- Q_DECL_CONSTEXPR inline explicit QLatin1Char(char c) : ch(c) {}
- Q_DECL_CONSTEXPR inline char toLatin1() const { return ch; }
- Q_DECL_CONSTEXPR inline ushort unicode() const { return ushort(uchar(ch)); }
+ Q_DECL_CONSTEXPR inline explicit QLatin1Char(char c) Q_DECL_NOTHROW : ch(c) {}
+ Q_DECL_CONSTEXPR inline char toLatin1() const Q_DECL_NOTHROW { return ch; }
+ Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ushort(uchar(ch)); }
private:
char ch;
@@ -72,19 +72,19 @@ public:
LastValidCodePoint = 0x10ffff
};
- Q_DECL_CONSTEXPR QChar() : ucs(0) {}
- Q_DECL_CONSTEXPR QChar(ushort rc) : ucs(rc){} // implicit
- Q_DECL_CONSTEXPR QChar(uchar c, uchar r) : ucs(ushort((r << 8) | c)){}
- Q_DECL_CONSTEXPR QChar(short rc) : ucs(ushort(rc)){} // implicit
- Q_DECL_CONSTEXPR QChar(uint rc) : ucs(ushort(rc & 0xffff)){}
- Q_DECL_CONSTEXPR QChar(int rc) : ucs(ushort(rc & 0xffff)){}
- Q_DECL_CONSTEXPR QChar(SpecialCharacter s) : ucs(ushort(s)) {} // implicit
- Q_DECL_CONSTEXPR QChar(QLatin1Char ch) : ucs(ch.unicode()) {} // implicit
+ Q_DECL_CONSTEXPR QChar() Q_DECL_NOTHROW : ucs(0) {}
+ Q_DECL_CONSTEXPR QChar(ushort rc) Q_DECL_NOTHROW : ucs(rc) {} // implicit
+ Q_DECL_CONSTEXPR QChar(uchar c, uchar r) Q_DECL_NOTHROW : ucs(ushort((r << 8) | c)) {}
+ Q_DECL_CONSTEXPR QChar(short rc) Q_DECL_NOTHROW : ucs(ushort(rc)) {} // implicit
+ Q_DECL_CONSTEXPR QChar(uint rc) Q_DECL_NOTHROW : ucs(ushort(rc & 0xffff)) {}
+ Q_DECL_CONSTEXPR QChar(int rc) Q_DECL_NOTHROW : ucs(ushort(rc & 0xffff)) {}
+ Q_DECL_CONSTEXPR QChar(SpecialCharacter s) Q_DECL_NOTHROW : ucs(ushort(s)) {} // implicit
+ Q_DECL_CONSTEXPR QChar(QLatin1Char ch) Q_DECL_NOTHROW : ucs(ch.unicode()) {} // implicit
#ifndef QT_NO_CAST_FROM_ASCII
- QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(char c) : ucs(uchar(c)) { }
+ QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(char c) Q_DECL_NOTHROW : ucs(uchar(c)) { }
#ifndef QT_RESTRICTED_CAST_FROM_ASCII
- QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(uchar c) : ucs(c) { }
+ QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(uchar c) Q_DECL_NOTHROW : ucs(c) { }
#endif
#endif
// Unicode information
@@ -369,11 +369,11 @@ public:
};
// ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO QCharRef TOO
- inline Category category() const { return QChar::category(ucs); }
- inline Direction direction() const { return QChar::direction(ucs); }
- inline JoiningType joiningType() const { return QChar::joiningType(ucs); }
+ inline Category category() const Q_DECL_NOTHROW { return QChar::category(ucs); }
+ inline Direction direction() const Q_DECL_NOTHROW { return QChar::direction(ucs); }
+ inline JoiningType joiningType() const Q_DECL_NOTHROW { return QChar::joiningType(ucs); }
#if QT_DEPRECATED_SINCE(5, 3)
- QT_DEPRECATED inline Joining joining() const
+ QT_DEPRECATED inline Joining joining() const Q_DECL_NOTHROW
{
switch (QChar::joiningType(ucs)) {
case QChar::Joining_Causing: return QChar::Center;
@@ -386,194 +386,177 @@ public:
}
}
#endif
- inline unsigned char combiningClass() const { return QChar::combiningClass(ucs); }
+ inline unsigned char combiningClass() const Q_DECL_NOTHROW { return QChar::combiningClass(ucs); }
- inline QChar mirroredChar() const { return QChar::mirroredChar(ucs); }
- inline bool hasMirrored() const { return QChar::hasMirrored(ucs); }
+ inline QChar mirroredChar() const Q_DECL_NOTHROW { return QChar::mirroredChar(ucs); }
+ inline bool hasMirrored() const Q_DECL_NOTHROW { return QChar::hasMirrored(ucs); }
QString decomposition() const;
- inline Decomposition decompositionTag() const { return QChar::decompositionTag(ucs); }
+ inline Decomposition decompositionTag() const Q_DECL_NOTHROW { return QChar::decompositionTag(ucs); }
- inline int digitValue() const { return QChar::digitValue(ucs); }
- inline QChar toLower() const { return QChar::toLower(ucs); }
- inline QChar toUpper() const { return QChar::toUpper(ucs); }
- inline QChar toTitleCase() const { return QChar::toTitleCase(ucs); }
- inline QChar toCaseFolded() const { return QChar::toCaseFolded(ucs); }
+ inline int digitValue() const Q_DECL_NOTHROW { return QChar::digitValue(ucs); }
+ inline QChar toLower() const Q_DECL_NOTHROW { return QChar::toLower(ucs); }
+ inline QChar toUpper() const Q_DECL_NOTHROW { return QChar::toUpper(ucs); }
+ inline QChar toTitleCase() const Q_DECL_NOTHROW { return QChar::toTitleCase(ucs); }
+ inline QChar toCaseFolded() const Q_DECL_NOTHROW { return QChar::toCaseFolded(ucs); }
- inline Script script() const { return QChar::script(ucs); }
+ inline Script script() const Q_DECL_NOTHROW { return QChar::script(ucs); }
- inline UnicodeVersion unicodeVersion() const { return QChar::unicodeVersion(ucs); }
+ inline UnicodeVersion unicodeVersion() const Q_DECL_NOTHROW { return QChar::unicodeVersion(ucs); }
#if QT_DEPRECATED_SINCE(5, 0)
- QT_DEPRECATED Q_DECL_CONSTEXPR inline char toAscii() const { return toLatin1(); }
+ QT_DEPRECATED Q_DECL_CONSTEXPR inline char toAscii() const Q_DECL_NOTHROW { return toLatin1(); }
#endif
- Q_DECL_CONSTEXPR inline char toLatin1() const;
- Q_DECL_CONSTEXPR inline ushort unicode() const { return ucs; }
- inline ushort &unicode() { return ucs; }
+ Q_DECL_CONSTEXPR inline char toLatin1() const Q_DECL_NOTHROW { return ucs > 0xff ? '\0' : char(ucs); }
+ Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ucs; }
+ Q_DECL_RELAXED_CONSTEXPR inline ushort &unicode() Q_DECL_NOTHROW { return ucs; }
#if QT_DEPRECATED_SINCE(5, 0)
- QT_DEPRECATED static Q_DECL_CONSTEXPR inline QChar fromAscii(char c)
+ QT_DEPRECATED static Q_DECL_CONSTEXPR inline QChar fromAscii(char c) Q_DECL_NOTHROW
{ return fromLatin1(c); }
#endif
- Q_DECL_CONSTEXPR static inline QChar fromLatin1(char c);
-
- Q_DECL_CONSTEXPR inline bool isNull() const { return ucs == 0; }
-
- inline bool isPrint() const { return QChar::isPrint(ucs); }
- Q_DECL_CONSTEXPR inline bool isSpace() const { return QChar::isSpace(ucs); }
- inline bool isMark() const { return QChar::isMark(ucs); }
- inline bool isPunct() const { return QChar::isPunct(ucs); }
- inline bool isSymbol() const { return QChar::isSymbol(ucs); }
- Q_DECL_CONSTEXPR inline bool isLetter() const { return QChar::isLetter(ucs); }
- Q_DECL_CONSTEXPR inline bool isNumber() const { return QChar::isNumber(ucs); }
- Q_DECL_CONSTEXPR inline bool isLetterOrNumber() const { return QChar::isLetterOrNumber(ucs); }
- Q_DECL_CONSTEXPR inline bool isDigit() const { return QChar::isDigit(ucs); }
- Q_DECL_CONSTEXPR inline bool isLower() const { return QChar::isLower(ucs); }
- Q_DECL_CONSTEXPR inline bool isUpper() const { return QChar::isUpper(ucs); }
- Q_DECL_CONSTEXPR inline bool isTitleCase() const { return QChar::isTitleCase(ucs); }
-
- Q_DECL_CONSTEXPR inline bool isNonCharacter() const { return QChar::isNonCharacter(ucs); }
- Q_DECL_CONSTEXPR inline bool isHighSurrogate() const { return QChar::isHighSurrogate(ucs); }
- Q_DECL_CONSTEXPR inline bool isLowSurrogate() const { return QChar::isLowSurrogate(ucs); }
- Q_DECL_CONSTEXPR inline bool isSurrogate() const { return QChar::isSurrogate(ucs); }
-
- Q_DECL_CONSTEXPR inline uchar cell() const { return uchar(ucs & 0xff); }
- Q_DECL_CONSTEXPR inline uchar row() const { return uchar((ucs>>8)&0xff); }
- inline void setCell(uchar cell);
- inline void setRow(uchar row);
-
- static Q_DECL_CONSTEXPR inline bool isNonCharacter(uint ucs4)
+ static Q_DECL_CONSTEXPR inline QChar fromLatin1(char c) Q_DECL_NOTHROW { return QChar(ushort(uchar(c))); }
+
+ Q_DECL_CONSTEXPR inline bool isNull() const Q_DECL_NOTHROW { return ucs == 0; }
+
+ inline bool isPrint() const Q_DECL_NOTHROW { return QChar::isPrint(ucs); }
+ Q_DECL_CONSTEXPR inline bool isSpace() const Q_DECL_NOTHROW { return QChar::isSpace(ucs); }
+ inline bool isMark() const Q_DECL_NOTHROW { return QChar::isMark(ucs); }
+ inline bool isPunct() const Q_DECL_NOTHROW { return QChar::isPunct(ucs); }
+ inline bool isSymbol() const Q_DECL_NOTHROW { return QChar::isSymbol(ucs); }
+ Q_DECL_CONSTEXPR inline bool isLetter() const Q_DECL_NOTHROW { return QChar::isLetter(ucs); }
+ Q_DECL_CONSTEXPR inline bool isNumber() const Q_DECL_NOTHROW { return QChar::isNumber(ucs); }
+ Q_DECL_CONSTEXPR inline bool isLetterOrNumber() const Q_DECL_NOTHROW { return QChar::isLetterOrNumber(ucs); }
+ Q_DECL_CONSTEXPR inline bool isDigit() const Q_DECL_NOTHROW { return QChar::isDigit(ucs); }
+ Q_DECL_CONSTEXPR inline bool isLower() const Q_DECL_NOTHROW { return QChar::isLower(ucs); }
+ Q_DECL_CONSTEXPR inline bool isUpper() const Q_DECL_NOTHROW { return QChar::isUpper(ucs); }
+ Q_DECL_CONSTEXPR inline bool isTitleCase() const Q_DECL_NOTHROW { return QChar::isTitleCase(ucs); }
+
+ Q_DECL_CONSTEXPR inline bool isNonCharacter() const Q_DECL_NOTHROW { return QChar::isNonCharacter(ucs); }
+ Q_DECL_CONSTEXPR inline bool isHighSurrogate() const Q_DECL_NOTHROW { return QChar::isHighSurrogate(ucs); }
+ Q_DECL_CONSTEXPR inline bool isLowSurrogate() const Q_DECL_NOTHROW { return QChar::isLowSurrogate(ucs); }
+ Q_DECL_CONSTEXPR inline bool isSurrogate() const Q_DECL_NOTHROW { return QChar::isSurrogate(ucs); }
+
+ Q_DECL_CONSTEXPR inline uchar cell() const Q_DECL_NOTHROW { return uchar(ucs & 0xff); }
+ Q_DECL_CONSTEXPR inline uchar row() const Q_DECL_NOTHROW { return uchar((ucs>>8)&0xff); }
+ Q_DECL_RELAXED_CONSTEXPR inline void setCell(uchar acell) Q_DECL_NOTHROW { ucs = ushort((ucs & 0xff00) + acell); }
+ Q_DECL_RELAXED_CONSTEXPR inline void setRow(uchar arow) Q_DECL_NOTHROW { ucs = ushort((ushort(arow)<<8) + (ucs&0xff)); }
+
+ static Q_DECL_CONSTEXPR inline bool isNonCharacter(uint ucs4) Q_DECL_NOTHROW
{
return ucs4 >= 0xfdd0 && (ucs4 <= 0xfdef || (ucs4 & 0xfffe) == 0xfffe);
}
- static Q_DECL_CONSTEXPR inline bool isHighSurrogate(uint ucs4)
+ static Q_DECL_CONSTEXPR inline bool isHighSurrogate(uint ucs4) Q_DECL_NOTHROW
{
return ((ucs4 & 0xfffffc00) == 0xd800);
}
- static Q_DECL_CONSTEXPR inline bool isLowSurrogate(uint ucs4)
+ static Q_DECL_CONSTEXPR inline bool isLowSurrogate(uint ucs4) Q_DECL_NOTHROW
{
return ((ucs4 & 0xfffffc00) == 0xdc00);
}
- static Q_DECL_CONSTEXPR inline bool isSurrogate(uint ucs4)
+ static Q_DECL_CONSTEXPR inline bool isSurrogate(uint ucs4) Q_DECL_NOTHROW
{
return (ucs4 - 0xd800u < 2048u);
}
- static Q_DECL_CONSTEXPR inline bool requiresSurrogates(uint ucs4)
+ static Q_DECL_CONSTEXPR inline bool requiresSurrogates(uint ucs4) Q_DECL_NOTHROW
{
return (ucs4 >= 0x10000);
}
- static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(ushort high, ushort low)
+ static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(ushort high, ushort low) Q_DECL_NOTHROW
{
return (uint(high)<<10) + low - 0x35fdc00;
}
- static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(QChar high, QChar low)
+ static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(QChar high, QChar low) Q_DECL_NOTHROW
{
return surrogateToUcs4(high.ucs, low.ucs);
}
- static Q_DECL_CONSTEXPR inline ushort highSurrogate(uint ucs4)
+ static Q_DECL_CONSTEXPR inline ushort highSurrogate(uint ucs4) Q_DECL_NOTHROW
{
return ushort((ucs4>>10) + 0xd7c0);
}
- static Q_DECL_CONSTEXPR inline ushort lowSurrogate(uint ucs4)
+ static Q_DECL_CONSTEXPR inline ushort lowSurrogate(uint ucs4) Q_DECL_NOTHROW
{
return ushort(ucs4%0x400 + 0xdc00);
}
- static Category QT_FASTCALL category(uint ucs4) Q_DECL_CONST_FUNCTION;
- static Direction QT_FASTCALL direction(uint ucs4) Q_DECL_CONST_FUNCTION;
- static JoiningType QT_FASTCALL joiningType(uint ucs4) Q_DECL_CONST_FUNCTION;
+ static Category QT_FASTCALL category(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static Direction QT_FASTCALL direction(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static JoiningType QT_FASTCALL joiningType(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
#if QT_DEPRECATED_SINCE(5, 3)
- QT_DEPRECATED static Joining QT_FASTCALL joining(uint ucs4) Q_DECL_CONST_FUNCTION;
+ QT_DEPRECATED static Joining QT_FASTCALL joining(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
#endif
- static unsigned char QT_FASTCALL combiningClass(uint ucs4) Q_DECL_CONST_FUNCTION;
+ static unsigned char QT_FASTCALL combiningClass(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
- static uint QT_FASTCALL mirroredChar(uint ucs4) Q_DECL_CONST_FUNCTION;
- static bool QT_FASTCALL hasMirrored(uint ucs4) Q_DECL_CONST_FUNCTION;
+ static uint QT_FASTCALL mirroredChar(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static bool QT_FASTCALL hasMirrored(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
static QString QT_FASTCALL decomposition(uint ucs4);
- static Decomposition QT_FASTCALL decompositionTag(uint ucs4) Q_DECL_CONST_FUNCTION;
+ static Decomposition QT_FASTCALL decompositionTag(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
- static int QT_FASTCALL digitValue(uint ucs4) Q_DECL_CONST_FUNCTION;
- static uint QT_FASTCALL toLower(uint ucs4) Q_DECL_CONST_FUNCTION;
- static uint QT_FASTCALL toUpper(uint ucs4) Q_DECL_CONST_FUNCTION;
- static uint QT_FASTCALL toTitleCase(uint ucs4) Q_DECL_CONST_FUNCTION;
- static uint QT_FASTCALL toCaseFolded(uint ucs4) Q_DECL_CONST_FUNCTION;
+ static int QT_FASTCALL digitValue(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static uint QT_FASTCALL toLower(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static uint QT_FASTCALL toUpper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static uint QT_FASTCALL toTitleCase(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static uint QT_FASTCALL toCaseFolded(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
- static Script QT_FASTCALL script(uint ucs4) Q_DECL_CONST_FUNCTION;
+ static Script QT_FASTCALL script(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
- static UnicodeVersion QT_FASTCALL unicodeVersion(uint ucs4) Q_DECL_CONST_FUNCTION;
+ static UnicodeVersion QT_FASTCALL unicodeVersion(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
- static UnicodeVersion QT_FASTCALL currentUnicodeVersion() Q_DECL_CONST_FUNCTION;
+ static UnicodeVersion QT_FASTCALL currentUnicodeVersion() Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
- static bool QT_FASTCALL isPrint(uint ucs4) Q_DECL_CONST_FUNCTION;
- static Q_DECL_CONSTEXPR inline bool isSpace(uint ucs4) Q_DECL_CONST_FUNCTION;
- static bool QT_FASTCALL isMark(uint ucs4) Q_DECL_CONST_FUNCTION;
- static bool QT_FASTCALL isPunct(uint ucs4) Q_DECL_CONST_FUNCTION;
- static bool QT_FASTCALL isSymbol(uint ucs4) Q_DECL_CONST_FUNCTION;
- static Q_DECL_CONSTEXPR inline bool isLetter(uint ucs4) Q_DECL_CONST_FUNCTION;
- static Q_DECL_CONSTEXPR inline bool isNumber(uint ucs4) Q_DECL_CONST_FUNCTION;
- static Q_DECL_CONSTEXPR inline bool isLetterOrNumber(uint ucs4) Q_DECL_CONST_FUNCTION;
- static Q_DECL_CONSTEXPR inline bool isDigit(uint ucs4) Q_DECL_CONST_FUNCTION;
- static Q_DECL_CONSTEXPR inline bool isLower(uint ucs4) Q_DECL_CONST_FUNCTION;
- static Q_DECL_CONSTEXPR inline bool isUpper(uint ucs4) Q_DECL_CONST_FUNCTION;
- static Q_DECL_CONSTEXPR inline bool isTitleCase(uint ucs4) Q_DECL_CONST_FUNCTION;
+ static bool QT_FASTCALL isPrint(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static Q_DECL_CONSTEXPR inline bool isSpace(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
+ {
+ // note that [0x09..0x0d] + 0x85 are exceptional Cc-s and must be handled explicitly
+ return ucs4 == 0x20 || (ucs4 <= 0x0d && ucs4 >= 0x09)
+ || (ucs4 > 127 && (ucs4 == 0x85 || ucs4 == 0xa0 || QChar::isSpace_helper(ucs4)));
+ }
+ static bool QT_FASTCALL isMark(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static bool QT_FASTCALL isPunct(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static bool QT_FASTCALL isSymbol(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static Q_DECL_CONSTEXPR inline bool isLetter(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
+ {
+ return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z'))
+ || (ucs4 > 127 && QChar::isLetter_helper(ucs4));
+ }
+ static Q_DECL_CONSTEXPR inline bool isNumber(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
+ { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::isNumber_helper(ucs4)); }
+ static Q_DECL_CONSTEXPR inline bool isLetterOrNumber(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
+ {
+ return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z'))
+ || (ucs4 >= '0' && ucs4 <= '9')
+ || (ucs4 > 127 && QChar::isLetterOrNumber_helper(ucs4));
+ }
+ static Q_DECL_CONSTEXPR inline bool isDigit(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
+ { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::category(ucs4) == Number_DecimalDigit); }
+ static Q_DECL_CONSTEXPR inline bool isLower(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
+ { return (ucs4 <= 'z' && ucs4 >= 'a') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Lowercase); }
+ static Q_DECL_CONSTEXPR inline bool isUpper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
+ { return (ucs4 <= 'Z' && ucs4 >= 'A') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Uppercase); }
+ static Q_DECL_CONSTEXPR inline bool isTitleCase(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
+ { return ucs4 > 127 && QChar::category(ucs4) == Letter_Titlecase; }
private:
- static bool QT_FASTCALL isSpace_helper(uint ucs4) Q_DECL_CONST_FUNCTION;
- static bool QT_FASTCALL isLetter_helper(uint ucs4) Q_DECL_CONST_FUNCTION;
- static bool QT_FASTCALL isNumber_helper(uint ucs4) Q_DECL_CONST_FUNCTION;
- static bool QT_FASTCALL isLetterOrNumber_helper(uint ucs4) Q_DECL_CONST_FUNCTION;
+ static bool QT_FASTCALL isSpace_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static bool QT_FASTCALL isLetter_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static bool QT_FASTCALL isNumber_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+ static bool QT_FASTCALL isLetterOrNumber_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
#ifdef QT_NO_CAST_FROM_ASCII
- QChar(char c);
- QChar(uchar c);
+ QChar(char c) Q_DECL_NOTHROW;
+ QChar(uchar c) Q_DECL_NOTHROW;
#endif
- friend Q_DECL_CONSTEXPR bool operator==(QChar, QChar);
- friend Q_DECL_CONSTEXPR bool operator< (QChar, QChar);
+ friend Q_DECL_CONSTEXPR bool operator==(QChar, QChar) Q_DECL_NOTHROW;
+ friend Q_DECL_CONSTEXPR bool operator< (QChar, QChar) Q_DECL_NOTHROW;
ushort ucs;
};
Q_DECLARE_TYPEINFO(QChar, Q_MOVABLE_TYPE);
-Q_DECL_CONSTEXPR inline char QChar::toLatin1() const { return ucs > 0xff ? '\0' : char(ucs); }
-Q_DECL_CONSTEXPR inline QChar QChar::fromLatin1(char c) { return QChar(ushort(uchar(c))); }
-
-inline void QChar::setCell(uchar acell)
-{ ucs = ushort((ucs & 0xff00) + acell); }
-inline void QChar::setRow(uchar arow)
-{ ucs = ushort((ushort(arow)<<8) + (ucs&0xff)); }
-
-Q_DECL_CONSTEXPR inline bool QChar::isSpace(uint ucs4)
-{
- // note that [0x09..0x0d] + 0x85 are exceptional Cc-s and must be handled explicitly
- return ucs4 == 0x20 || (ucs4 <= 0x0d && ucs4 >= 0x09)
- || (ucs4 > 127 && (ucs4 == 0x85 || ucs4 == 0xa0 || QChar::isSpace_helper(ucs4)));
-}
-Q_DECL_CONSTEXPR inline bool QChar::isLetter(uint ucs4)
-{
- return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z'))
- || (ucs4 > 127 && QChar::isLetter_helper(ucs4));
-}
-Q_DECL_CONSTEXPR inline bool QChar::isNumber(uint ucs4)
-{ return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::isNumber_helper(ucs4)); }
-Q_DECL_CONSTEXPR inline bool QChar::isLetterOrNumber(uint ucs4)
-{
- return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z'))
- || (ucs4 >= '0' && ucs4 <= '9')
- || (ucs4 > 127 && QChar::isLetterOrNumber_helper(ucs4));
-}
-Q_DECL_CONSTEXPR inline bool QChar::isDigit(uint ucs4)
-{ return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::category(ucs4) == Number_DecimalDigit); }
-Q_DECL_CONSTEXPR inline bool QChar::isLower(uint ucs4)
-{ return (ucs4 <= 'z' && ucs4 >= 'a') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Lowercase); }
-Q_DECL_CONSTEXPR inline bool QChar::isUpper(uint ucs4)
-{ return (ucs4 <= 'Z' && ucs4 >= 'A') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Uppercase); }
-Q_DECL_CONSTEXPR inline bool QChar::isTitleCase(uint ucs4)
-{ return ucs4 > 127 && QChar::category(ucs4) == Letter_Titlecase; }
-
-Q_DECL_CONSTEXPR inline bool operator==(QChar c1, QChar c2) { return c1.ucs == c2.ucs; }
-Q_DECL_CONSTEXPR inline bool operator< (QChar c1, QChar c2) { return c1.ucs < c2.ucs; }
+Q_DECL_CONSTEXPR inline bool operator==(QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs == c2.ucs; }
+Q_DECL_CONSTEXPR inline bool operator< (QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs < c2.ucs; }
Q_DECL_CONSTEXPR inline bool operator!=(QChar c1, QChar c2) { return !operator==(c1, c2); }
Q_DECL_CONSTEXPR inline bool operator>=(QChar c1, QChar c2) { return !operator< (c1, c2); }
diff --git a/src/corelib/tools/qcollator.h b/src/corelib/tools/qcollator.h
index e1fa161257..57133165c4 100644
--- a/src/corelib/tools/qcollator.h
+++ b/src/corelib/tools/qcollator.h
@@ -83,7 +83,7 @@ public:
QCollator &operator=(const QCollator &);
#ifdef Q_COMPILER_RVALUE_REFS
QCollator(QCollator &&other) Q_DECL_NOTHROW
- : d(other.d) { other.d = 0; }
+ : d(other.d) { other.d = Q_NULLPTR; }
QCollator &operator=(QCollator &&other) Q_DECL_NOTHROW
{ swap(other); return *this; }
#endif
diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp
index 7f898f68a8..8ab98741f5 100644
--- a/src/corelib/tools/qcommandlineoption.cpp
+++ b/src/corelib/tools/qcommandlineoption.cpp
@@ -41,10 +41,19 @@ QT_BEGIN_NAMESPACE
class QCommandLineOptionPrivate : public QSharedData
{
public:
- inline QCommandLineOptionPrivate()
+ Q_NEVER_INLINE
+ explicit QCommandLineOptionPrivate(const QString &name)
+ : names(removeInvalidNames(QStringList(name))),
+ hidden(false)
{ }
- void setNames(const QStringList &nameList);
+ Q_NEVER_INLINE
+ explicit QCommandLineOptionPrivate(const QStringList &names)
+ : names(removeInvalidNames(names)),
+ hidden(false)
+ { }
+
+ static QStringList removeInvalidNames(QStringList nameList);
//! The list of names used for this option.
QStringList names;
@@ -58,6 +67,9 @@ public:
//! The list of default values used for this option.
QStringList defaultValues;
+
+ //! Show or hide in --help
+ bool hidden;
};
/*!
@@ -98,9 +110,8 @@ public:
\sa setDescription(), setValueName(), setDefaultValues()
*/
QCommandLineOption::QCommandLineOption(const QString &name)
- : d(new QCommandLineOptionPrivate)
+ : d(new QCommandLineOptionPrivate(name))
{
- d->setNames(QStringList(name));
}
/*!
@@ -117,9 +128,8 @@ QCommandLineOption::QCommandLineOption(const QString &name)
\sa setDescription(), setValueName(), setDefaultValues()
*/
QCommandLineOption::QCommandLineOption(const QStringList &names)
- : d(new QCommandLineOptionPrivate)
+ : d(new QCommandLineOptionPrivate(names))
{
- d->setNames(names);
}
/*!
@@ -148,9 +158,8 @@ QCommandLineOption::QCommandLineOption(const QStringList &names)
QCommandLineOption::QCommandLineOption(const QString &name, const QString &description,
const QString &valueName,
const QString &defaultValue)
- : d(new QCommandLineOptionPrivate)
+ : d(new QCommandLineOptionPrivate(name))
{
- d->setNames(QStringList(name));
setValueName(valueName);
setDescription(description);
setDefaultValue(defaultValue);
@@ -185,9 +194,8 @@ QCommandLineOption::QCommandLineOption(const QString &name, const QString &descr
QCommandLineOption::QCommandLineOption(const QStringList &names, const QString &description,
const QString &valueName,
const QString &defaultValue)
- : d(new QCommandLineOptionPrivate)
+ : d(new QCommandLineOptionPrivate(names))
{
- d->setNames(names);
setValueName(valueName);
setDescription(description);
setDefaultValue(defaultValue);
@@ -236,29 +244,44 @@ QStringList QCommandLineOption::names() const
return d->names;
}
-void QCommandLineOptionPrivate::setNames(const QStringList &nameList)
+namespace {
+ struct IsInvalidName
+ {
+ typedef bool result_type;
+ typedef QString argument_type;
+
+ result_type operator()(const QString &name) const Q_DECL_NOEXCEPT
+ {
+ if (name.isEmpty()) {
+ qWarning("QCommandLineOption: Option names cannot be empty");
+ return true;
+ } else {
+ const QChar c = name.at(0);
+ if (c == QLatin1Char('-')) {
+ qWarning("QCommandLineOption: Option names cannot start with a '-'");
+ return true;
+ } else if (c == QLatin1Char('/')) {
+ qWarning("QCommandLineOption: Option names cannot start with a '/'");
+ return true;
+ } else if (name.contains(QLatin1Char('='))) {
+ qWarning("QCommandLineOption: Option names cannot contain a '='");
+ return true;
+ }
+ }
+ return false;
+ }
+ };
+} // unnamed namespace
+
+// static
+QStringList QCommandLineOptionPrivate::removeInvalidNames(QStringList nameList)
{
- QStringList newNames;
- newNames.reserve(nameList.size());
if (nameList.isEmpty())
qWarning("QCommandLineOption: Options must have at least one name");
- foreach (const QString &name, nameList) {
- if (name.isEmpty()) {
- qWarning("QCommandLineOption: Option names cannot be empty");
- } else {
- const QChar c = name.at(0);
- if (c == QLatin1Char('-'))
- qWarning("QCommandLineOption: Option names cannot start with a '-'");
- else if (c == QLatin1Char('/'))
- qWarning("QCommandLineOption: Option names cannot start with a '/'");
- else if (name.contains(QLatin1Char('=')))
- qWarning("QCommandLineOption: Option names cannot contain a '='");
- else
- newNames.append(name);
- }
- }
- // commit
- names.swap(newNames);
+ else
+ nameList.erase(std::remove_if(nameList.begin(), nameList.end(), IsInvalidName()),
+ nameList.end());
+ return qMove(nameList);
}
/*!
@@ -362,4 +385,30 @@ QStringList QCommandLineOption::defaultValues() const
return d->defaultValues;
}
+/*!
+ Sets whether to hide this option in the user-visible help output.
+
+ All options are visible by default. Setting \a hidden to true for
+ a particular option makes it internal, i.e. not listed in the help output.
+
+ \since 5.6
+ \sa isHidden
+ */
+void QCommandLineOption::setHidden(bool hide)
+{
+ d->hidden = hide;
+}
+
+/*!
+ Returns true if this option is omitted from the help output,
+ false if the option is listed.
+
+ \since 5.6
+ \sa setHidden()
+ */
+bool QCommandLineOption::isHidden() const
+{
+ return d->hidden;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qcommandlineoption.h b/src/corelib/tools/qcommandlineoption.h
index cf4160ecd2..828522cbc5 100644
--- a/src/corelib/tools/qcommandlineoption.h
+++ b/src/corelib/tools/qcommandlineoption.h
@@ -58,11 +58,10 @@ public:
QCommandLineOption &operator=(const QCommandLineOption &other);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QCommandLineOption &operator=(QCommandLineOption &&other)
- { qSwap(d, other.d); return *this; }
+ QCommandLineOption &operator=(QCommandLineOption &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- inline void swap(QCommandLineOption &other)
+ void swap(QCommandLineOption &other) Q_DECL_NOTHROW
{ qSwap(d, other.d); }
QStringList names() const;
@@ -77,6 +76,9 @@ public:
void setDefaultValues(const QStringList &defaultValues);
QStringList defaultValues() const;
+ void setHidden(bool hidden);
+ bool isHidden() const;
+
private:
QSharedDataPointer<QCommandLineOptionPrivate> d;
};
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index 0814921a58..4cc3a2c293 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -53,6 +53,7 @@ class QCommandLineParserPrivate
public:
inline QCommandLineParserPrivate()
: singleDashWordOptionMode(QCommandLineParser::ParseAsCompactedShortOptions),
+ optionsAfterPositionalArgumentsMode(QCommandLineParser::ParseAsOptions),
builtinVersionOption(false),
builtinHelpOption(false),
needsParsing(true)
@@ -103,6 +104,9 @@ public:
//! The parsing mode for "-abc"
QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode;
+ //! How to parse "arg -option"
+ QCommandLineParser::OptionsAfterPositionalArgumentsMode optionsAfterPositionalArgumentsMode;
+
//! Whether addVersionOption was called
bool builtinVersionOption;
@@ -299,6 +303,41 @@ void QCommandLineParser::setSingleDashWordOptionMode(QCommandLineParser::SingleD
}
/*!
+ \enum QCommandLineParser::OptionsAfterPositionalArgumentsMode
+
+ This enum describes the way the parser interprets options that
+ occur after positional arguments.
+
+ \value ParseAsOptions \c{application argument --opt -t} is interpreted as setting
+ the options \c{opt} and \c{t}, just like \c{application --opt -t argument} would do.
+ This is the default parsing mode. In order to specify that \c{--opt} and \c{-t}
+ are positional arguments instead, the user can use \c{--}, as in
+ \c{application argument -- --opt -t}.
+
+ \value ParseAsPositionalArguments \c{application argument --opt} is interpreted as
+ having two positional arguments, \c{argument} and \c{--opt}.
+ This mode is useful for executables that aim to launch other executables
+ (e.g. wrappers, debugging tools, etc.) or that support internal commands
+ followed by options for the command. \c{argument} is the name of the command,
+ and all options occurring after it can be collected and parsed by another
+ command line parser, possibly in another executable.
+
+ \sa setOptionsAfterPositionalArgumentsMode()
+
+ \since 5.5
+*/
+
+/*!
+ Sets the parsing mode to \a parsingMode.
+ This must be called before process() or parse().
+ \since 5.5
+*/
+void QCommandLineParser::setOptionsAfterPositionalArgumentsMode(QCommandLineParser::OptionsAfterPositionalArgumentsMode parsingMode)
+{
+ d->optionsAfterPositionalArgumentsMode = parsingMode;
+}
+
+/*!
Adds the option \a option to look for while parsing.
Returns \c true if adding the option was successful; otherwise returns \c false.
@@ -640,7 +679,7 @@ bool QCommandLineParserPrivate::parse(const QStringList &args)
const QLatin1Char dashChar('-');
const QLatin1Char assignChar('=');
- bool doubleDashFound = false;
+ bool forcePositional = false;
errorText.clear();
positionalArgumentList.clear();
optionNames.clear();
@@ -658,7 +697,7 @@ bool QCommandLineParserPrivate::parse(const QStringList &args)
for (; argumentIterator != args.end() ; ++argumentIterator) {
QString argument = *argumentIterator;
- if (doubleDashFound) {
+ if (forcePositional) {
positionalArgumentList.append(argument);
} else if (argument.startsWith(doubleDashString)) {
if (argument.length() > 2) {
@@ -670,7 +709,7 @@ bool QCommandLineParserPrivate::parse(const QStringList &args)
error = true;
}
} else {
- doubleDashFound = true;
+ forcePositional = true;
}
} else if (argument.startsWith(dashChar)) {
if (argument.size() == 1) { // single dash ("stdin")
@@ -722,6 +761,8 @@ bool QCommandLineParserPrivate::parse(const QStringList &args)
}
} else {
positionalArgumentList.append(argument);
+ if (optionsAfterPositionalArgumentsMode == QCommandLineParser::ParseAsPositionalArguments)
+ forcePositional = true;
}
if (argumentIterator == args.end())
break;
@@ -1062,6 +1103,8 @@ QString QCommandLineParserPrivate::helpText() const
++longestOptionNameString;
for (int i = 0; i < commandLineOptionList.count(); ++i) {
const QCommandLineOption &option = commandLineOptionList.at(i);
+ if (option.isHidden())
+ continue;
text += wrapText(optionNameList.at(i), longestOptionNameString, option.description());
}
if (!positionalArgumentDefinitions.isEmpty()) {
diff --git a/src/corelib/tools/qcommandlineparser.h b/src/corelib/tools/qcommandlineparser.h
index 91a799b4d5..8c528ba69e 100644
--- a/src/corelib/tools/qcommandlineparser.h
+++ b/src/corelib/tools/qcommandlineparser.h
@@ -57,6 +57,12 @@ public:
};
void setSingleDashWordOptionMode(SingleDashWordOptionMode parsingMode);
+ enum OptionsAfterPositionalArgumentsMode {
+ ParseAsOptions,
+ ParseAsPositionalArguments
+ };
+ void setOptionsAfterPositionalArgumentsMode(OptionsAfterPositionalArgumentsMode mode);
+
bool addOption(const QCommandLineOption &commandLineOption);
bool addOptions(const QList<QCommandLineOption> &options);
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index 6651efdc13..c44f7f8fee 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -74,7 +74,7 @@ public:
int dayOfYear() const;
int daysInMonth() const;
int daysInYear() const;
- int weekNumber(int *yearNum = 0) const;
+ int weekNumber(int *yearNum = Q_NULLPTR) const;
#ifndef QT_NO_TEXTDATE
static QString shortMonthName(int month, MonthNameType type = DateFormat);
@@ -222,9 +222,12 @@ public:
QDateTime(const QDateTime &other);
~QDateTime();
+#ifdef Q_COMPILER_RVALUE_REFS
+ QDateTime &operator=(QDateTime &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QDateTime &operator=(const QDateTime &other);
- inline void swap(QDateTime &other) { qSwap(d, other.d); }
+ void swap(QDateTime &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool isNull() const;
bool isValid() const;
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index 1bd9c5ebb9..58ccd32c5e 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -1219,6 +1219,7 @@ QVector<QPointF> static inline tcbToBezier(const TCBPoints &tcbPoints)
{
const int count = tcbPoints.count();
QVector<QPointF> bezierPoints;
+ bezierPoints.reserve(3 * (count - 1));
for (int i = 1; i < count; i++) {
const qreal t_0 = tcbPoints.at(i - 1)._t;
diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h
index 4065de1366..d04d5ef30a 100644
--- a/src/corelib/tools/qeasingcurve.h
+++ b/src/corelib/tools/qeasingcurve.h
@@ -75,7 +75,7 @@ public:
QEasingCurve &operator=(const QEasingCurve &other)
{ if ( this != &other ) { QEasingCurve copy(other); swap(copy); } return *this; }
#ifdef Q_COMPILER_RVALUE_REFS
- QEasingCurve(QEasingCurve &&other) : d_ptr(other.d_ptr) { other.d_ptr = 0; }
+ QEasingCurve(QEasingCurve &&other) : d_ptr(other.d_ptr) { other.d_ptr = Q_NULLPTR; }
QEasingCurve &operator=(QEasingCurve &&other)
{ qSwap(d_ptr, other.d_ptr); return *this; }
#endif
diff --git a/src/corelib/tools/qharfbuzz.cpp b/src/corelib/tools/qharfbuzz.cpp
index afc8b23473..fa279949ea 100644
--- a/src/corelib/tools/qharfbuzz.cpp
+++ b/src/corelib/tools/qharfbuzz.cpp
@@ -65,6 +65,9 @@ HB_UChar16 HB_GetMirroredChar(HB_UChar16 ch)
void (*HB_Library_Resolve(const char *library, int version, const char *symbol))()
{
#ifdef QT_NO_LIBRARY
+ Q_UNUSED(library);
+ Q_UNUSED(version);
+ Q_UNUSED(symbol);
return 0;
#else
return QLibrary::resolve(QLatin1String(library), version, symbol);
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index a9ece12670..c83dcaabe1 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -38,10 +38,9 @@
#include <QtCore/qchar.h>
#include <QtCore/qiterator.h>
#include <QtCore/qlist.h>
-#include <QtCore/qpair.h>
#include <QtCore/qrefcount.h>
+#include <QtCore/qhashfunctions.h>
-#include <numeric> // for std::accumulate
#ifdef Q_COMPILER_INITIALIZER_LISTS
#include <initializer_list>
#endif
@@ -54,101 +53,6 @@
QT_BEGIN_NAMESPACE
-class QBitArray;
-class QByteArray;
-class QString;
-class QStringRef;
-class QLatin1String;
-
-Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHashBits(const void *p, size_t size, uint seed = 0) Q_DECL_NOTHROW;
-
-Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(char key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
-Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uchar key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
-Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(signed char key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
-Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ushort key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
-Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(short key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
-Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uint key, uint seed = 0) Q_DECL_NOTHROW { return key ^ seed; }
-Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(int key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
-Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ulong key, uint seed = 0) Q_DECL_NOTHROW
-{
- return (sizeof(ulong) > sizeof(uint))
- ? (uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U)) ^ seed)
- : (uint(key & (~0U)) ^ seed);
-}
-Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(long key, uint seed = 0) Q_DECL_NOTHROW { return qHash(ulong(key), seed); }
-Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(quint64 key, uint seed = 0) Q_DECL_NOTHROW
-{
- return uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U)) ^ seed;
-}
-Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(qint64 key, uint seed = 0) Q_DECL_NOTHROW { return qHash(quint64(key), seed); }
-Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(float key, uint seed = 0) Q_DECL_NOTHROW;
-Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(double key, uint seed = 0) Q_DECL_NOTHROW;
-#ifndef Q_OS_DARWIN
-Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(long double key, uint seed = 0) Q_DECL_NOTHROW;
-#endif
-Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(const QChar key, uint seed = 0) Q_DECL_NOTHROW { return qHash(key.unicode(), seed); }
-Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QByteArray &key, uint seed = 0) Q_DECL_NOTHROW;
-Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QString &key, uint seed = 0) Q_DECL_NOTHROW;
-Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QStringRef &key, uint seed = 0) Q_DECL_NOTHROW;
-Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QBitArray &key, uint seed = 0) Q_DECL_NOTHROW;
-Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(QLatin1String key, uint seed = 0) Q_DECL_NOTHROW;
-Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(const QString &key) Q_DECL_NOTHROW;
-Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(const QStringRef &key) Q_DECL_NOTHROW;
-
-template <class T> inline uint qHash(const T *key, uint seed = 0) Q_DECL_NOTHROW
-{
- return qHash(reinterpret_cast<quintptr>(key), seed);
-}
-template<typename T> inline uint qHash(const T &t, uint seed)
- Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t)))
-{ return (qHash(t) ^ seed); }
-
-namespace QtPrivate {
-
-struct QHashCombine {
- typedef uint result_type;
- template <typename T>
- Q_DECL_CONSTEXPR result_type operator()(uint seed, const T &t) const Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t)))
- // combiner taken from N3876 / boost::hash_combine
- { return seed ^ (qHash(t) + 0x9e3779b9 + (seed << 6) + (seed >> 2)) ; }
-};
-
-struct QHashCombineCommutative {
- // QHashCombine is a good hash combiner, but is not commutative,
- // ie. it depends on the order of the input elements. That is
- // usually what we want: {0,1,3} should hash differently than
- // {1,3,0}. Except when it isn't (e.g. for QSet and
- // QHash). Therefore, provide a commutative combiner, too.
- typedef uint result_type;
- template <typename T>
- Q_DECL_CONSTEXPR result_type operator()(uint seed, const T &t) const Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t)))
- { return seed + qHash(t); } // don't use xor!
-};
-
-} // namespace QtPrivate
-
-template <typename InputIterator>
-inline uint qHashRange(InputIterator first, InputIterator last, uint seed = 0)
- Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(*first))) // assume iterator operations don't throw
-{
- return std::accumulate(first, last, seed, QtPrivate::QHashCombine());
-}
-
-template <typename InputIterator>
-inline uint qHashRangeCommutative(InputIterator first, InputIterator last, uint seed = 0)
- Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(*first))) // assume iterator operations don't throw
-{
- return std::accumulate(first, last, seed, QtPrivate::QHashCombineCommutative());
-}
-
-template <typename T1, typename T2> inline uint qHash(const QPair<T1, T2> &key, uint seed = 0)
- Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed)))
-{
- uint h1 = qHash(key.first, seed);
- uint h2 = qHash(key.second, seed);
- return ((h1 << 16) | (h1 >> 16)) ^ h2 ^ seed;
-}
-
struct Q_CORE_EXPORT QHashData
{
struct Node {
@@ -402,7 +306,7 @@ public:
typedef T *pointer;
typedef T &reference;
- inline iterator() : i(0) { }
+ inline iterator() : i(Q_NULLPTR) { }
explicit inline iterator(void *node) : i(reinterpret_cast<QHashData::Node *>(node)) { }
inline const Key &key() const { return concrete(i)->key; }
@@ -449,6 +353,7 @@ public:
class const_iterator
{
friend class iterator;
+ friend class QSet<Key>;
QHashData::Node *i;
public:
@@ -458,7 +363,7 @@ public:
typedef const T *pointer;
typedef const T &reference;
- inline const_iterator() : i(0) { }
+ inline const_iterator() : i(Q_NULLPTR) { }
explicit inline const_iterator(void *node)
: i(reinterpret_cast<QHashData::Node *>(node)) { }
#ifdef QT_STRICT_ITERATORS
@@ -546,7 +451,8 @@ public:
private:
void detach_helper();
void freeData(QHashData *d);
- Node **findNode(const Key &key, uint *hp = 0) const;
+ Node **findNode(const Key &key, uint *hp = Q_NULLPTR) const;
+ Node **findNode(const Key &key, uint h) const;
Node *createNode(uint h, const Key &key, const T &value, Node **nextNode);
void deleteNode(Node *node);
static void deleteNode2(QHashData::Node *node);
@@ -590,7 +496,7 @@ template <class Key, class T>
Q_INLINE_TEMPLATE void QHash<Key, T>::duplicateNode(QHashData::Node *node, void *newNode)
{
Node *concreteNode = concrete(node);
- new (newNode) Node(concreteNode->key, concreteNode->value, concreteNode->h, 0);
+ new (newNode) Node(concreteNode->key, concreteNode->value, concreteNode->h, Q_NULLPTR);
}
template <class Key, class T>
@@ -942,17 +848,10 @@ Q_INLINE_TEMPLATE bool QHash<Key, T>::contains(const Key &akey) const
}
template <class Key, class T>
-Q_OUTOFLINE_TEMPLATE typename QHash<Key, T>::Node **QHash<Key, T>::findNode(const Key &akey,
- uint *ahp) const
+Q_OUTOFLINE_TEMPLATE typename QHash<Key, T>::Node **QHash<Key, T>::findNode(const Key &akey, uint h) const
{
Node **node;
- uint h = 0;
- if (d->numBuckets || ahp) {
- h = qHash(akey, d->seed);
- if (ahp)
- *ahp = h;
- }
if (d->numBuckets) {
node = reinterpret_cast<Node **>(&d->buckets[h % d->numBuckets]);
Q_ASSERT(*node == e || (*node)->next);
@@ -965,6 +864,20 @@ Q_OUTOFLINE_TEMPLATE typename QHash<Key, T>::Node **QHash<Key, T>::findNode(cons
}
template <class Key, class T>
+Q_OUTOFLINE_TEMPLATE typename QHash<Key, T>::Node **QHash<Key, T>::findNode(const Key &akey,
+ uint *ahp) const
+{
+ uint h = 0;
+
+ if (d->numBuckets || ahp) {
+ h = qHash(akey, d->seed);
+ if (ahp)
+ *ahp = h;
+ }
+ return findNode(akey, h);
+}
+
+template <class Key, class T>
Q_OUTOFLINE_TEMPLATE bool QHash<Key, T>::operator==(const QHash &other) const
{
if (size() != other.size())
diff --git a/src/corelib/tools/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h
new file mode 100644
index 0000000000..e15fbb07ac
--- /dev/null
+++ b/src/corelib/tools/qhashfunctions.h
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QHASHFUNCTIONS_H
+#define QHASHFUNCTIONS_H
+
+#include <QtCore/qchar.h>
+#include <QtCore/qpair.h>
+
+#include <numeric> // for std::accumulate
+
+#if 0
+#pragma qt_class(QHashFunctions)
+#endif
+
+#if defined(Q_CC_MSVC)
+#pragma warning( push )
+#pragma warning( disable : 4311 ) // disable pointer truncation warning
+#pragma warning( disable : 4127 ) // conditional expression is constant
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QBitArray;
+class QByteArray;
+class QString;
+class QStringRef;
+class QLatin1String;
+
+Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHashBits(const void *p, size_t size, uint seed = 0) Q_DECL_NOTHROW;
+
+Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(char key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
+Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uchar key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
+Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(signed char key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
+Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ushort key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
+Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(short key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
+Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uint key, uint seed = 0) Q_DECL_NOTHROW { return key ^ seed; }
+Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(int key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
+Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ulong key, uint seed = 0) Q_DECL_NOTHROW
+{
+ return (sizeof(ulong) > sizeof(uint))
+ ? (uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U)) ^ seed)
+ : (uint(key & (~0U)) ^ seed);
+}
+Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(long key, uint seed = 0) Q_DECL_NOTHROW { return qHash(ulong(key), seed); }
+Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(quint64 key, uint seed = 0) Q_DECL_NOTHROW
+{
+ return uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U)) ^ seed;
+}
+Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(qint64 key, uint seed = 0) Q_DECL_NOTHROW { return qHash(quint64(key), seed); }
+Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(float key, uint seed = 0) Q_DECL_NOTHROW;
+Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(double key, uint seed = 0) Q_DECL_NOTHROW;
+#ifndef Q_OS_DARWIN
+Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(long double key, uint seed = 0) Q_DECL_NOTHROW;
+#endif
+Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(const QChar key, uint seed = 0) Q_DECL_NOTHROW { return qHash(key.unicode(), seed); }
+Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QByteArray &key, uint seed = 0) Q_DECL_NOTHROW;
+Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QString &key, uint seed = 0) Q_DECL_NOTHROW;
+Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QStringRef &key, uint seed = 0) Q_DECL_NOTHROW;
+Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QBitArray &key, uint seed = 0) Q_DECL_NOTHROW;
+Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(QLatin1String key, uint seed = 0) Q_DECL_NOTHROW;
+Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(const QString &key) Q_DECL_NOTHROW;
+Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(const QStringRef &key) Q_DECL_NOTHROW;
+
+template <class T> inline uint qHash(const T *key, uint seed = 0) Q_DECL_NOTHROW
+{
+ return qHash(reinterpret_cast<quintptr>(key), seed);
+}
+template<typename T> inline uint qHash(const T &t, uint seed)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t)))
+{ return qHash(t) ^ seed; }
+
+namespace QtPrivate {
+
+struct QHashCombine {
+ typedef uint result_type;
+ template <typename T>
+ Q_DECL_CONSTEXPR result_type operator()(uint seed, const T &t) const Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t)))
+ // combiner taken from N3876 / boost::hash_combine
+ { return seed ^ (qHash(t) + 0x9e3779b9 + (seed << 6) + (seed >> 2)) ; }
+};
+
+struct QHashCombineCommutative {
+ // QHashCombine is a good hash combiner, but is not commutative,
+ // ie. it depends on the order of the input elements. That is
+ // usually what we want: {0,1,3} should hash differently than
+ // {1,3,0}. Except when it isn't (e.g. for QSet and
+ // QHash). Therefore, provide a commutative combiner, too.
+ typedef uint result_type;
+ template <typename T>
+ Q_DECL_CONSTEXPR result_type operator()(uint seed, const T &t) const Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t)))
+ { return seed + qHash(t); } // don't use xor!
+};
+
+} // namespace QtPrivate
+
+template <typename InputIterator>
+inline uint qHashRange(InputIterator first, InputIterator last, uint seed = 0)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(*first))) // assume iterator operations don't throw
+{
+ return std::accumulate(first, last, seed, QtPrivate::QHashCombine());
+}
+
+template <typename InputIterator>
+inline uint qHashRangeCommutative(InputIterator first, InputIterator last, uint seed = 0)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(*first))) // assume iterator operations don't throw
+{
+ return std::accumulate(first, last, seed, QtPrivate::QHashCombineCommutative());
+}
+
+template <typename T1, typename T2> inline uint qHash(const QPair<T1, T2> &key, uint seed = 0)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed)))
+{
+ uint h1 = qHash(key.first, seed);
+ uint h2 = qHash(key.second, seed);
+ return ((h1 << 16) | (h1 >> 16)) ^ h2 ^ seed;
+}
+
+QT_END_NAMESPACE
+
+#if defined(Q_CC_MSVC)
+#pragma warning( pop )
+#endif
+
+#endif // QHASHFUNCTIONS_H
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp
index db00dcb458..d774548d3a 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -584,6 +584,65 @@ void **QListData::erase(void **xi)
\sa operator==()
*/
+/*! \fn bool operator<(const QList<T> &lhs, const QList<T> &rhs)
+ \since 5.6
+ \relates QList
+
+ Returns \c true if list \a lhs is
+ \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
+ {lexicographically less than} \a rhs; otherwise returns \c false.
+
+ This function requires the value type to have an implementation
+ of \c operator<().
+*/
+
+/*! \fn bool operator<=(const QList<T> &lhs, const QList<T> &rhs)
+ \since 5.6
+ \relates QList
+
+ Returns \c true if list \a lhs is
+ \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
+ {lexicographically less than or equal to} \a rhs; otherwise returns \c false.
+
+ This function requires the value type to have an implementation
+ of \c operator<().
+*/
+
+/*! \fn bool operator>(const QList<T> &lhs, const QList<T> &rhs)
+ \since 5.6
+ \relates QList
+
+ Returns \c true if list \a lhs is
+ \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
+ {lexicographically greater than} \a rhs; otherwise returns \c false.
+
+ This function requires the value type to have an implementation
+ of \c operator<().
+*/
+
+/*! \fn bool operator>=(const QList<T> &lhs, const QList<T> &rhs)
+ \since 5.6
+ \relates QList
+
+ Returns \c true if list \a lhs is
+ \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
+ {lexicographically greater than or equal to} \a rhs; otherwise returns \c false.
+
+ This function requires the value type to have an implementation
+ of \c operator<().
+*/
+
+/*!
+ \fn uint qHash(const QList<T> &key, uint seed = 0)
+ \since 5.6
+ \relates QList
+
+ Returns the hash value for \a key,
+ using \a seed to seed the calculation.
+
+ This function requires qHash() to be overloaded for the value type \c T.
+*/
+
/*!
\fn int QList::size() const
@@ -1000,6 +1059,52 @@ void **QListData::erase(void **xi)
\sa constBegin(), end()
*/
+/*! \fn QList::reverse_iterator QList::rbegin()
+ \since 5.6
+
+ Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
+ item in the list, in reverse order.
+
+ \sa begin(), crbegin(), rend()
+*/
+
+/*! \fn QList::const_reverse_iterator QList::rbegin() const
+ \since 5.6
+ \overload
+*/
+
+/*! \fn QList::const_reverse_iterator QList::crbegin() const
+ \since 5.6
+
+ Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
+ item in the list, in reverse order.
+
+ \sa begin(), rbegin(), rend()
+*/
+
+/*! \fn QList::reverse_iterator QList::rend()
+ \since 5.6
+
+ Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past
+ the last item in the list, in reverse order.
+
+ \sa end(), crend(), rbegin()
+*/
+
+/*! \fn QList::const_reverse_iterator QList::rend() const
+ \since 5.6
+ \overload
+*/
+
+/*! \fn QList::const_reverse_iterator QList::crend() const
+ \since 5.6
+
+ Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one
+ past the last item in the list, in reverse order.
+
+ \sa end(), rend(), rbegin()
+*/
+
/*! \fn QList::iterator QList::erase(iterator pos)
Removes the item associated with the iterator \a pos from the
@@ -1070,6 +1175,38 @@ void **QListData::erase(void **xi)
Typedef for const T &. Provided for STL compatibility.
*/
+/*! \typedef QList::reverse_iterator
+ \since 5.6
+
+ The QList::reverse_iterator typedef provides an STL-style non-const
+ reverse iterator for QList.
+
+ It is simply a typedef for \c{std::reverse_iterator<iterator>}.
+
+ \warning Iterators on implicitly shared containers do not work
+ exactly like STL-iterators. You should avoid copying a container
+ while iterators are active on that container. For more information,
+ read \l{Implicit sharing iterator problem}.
+
+ \sa QList::rbegin(), QList::rend(), QList::const_reverse_iterator, QList::iterator
+*/
+
+/*! \typedef QList::const_reverse_iterator
+ \since 5.6
+
+ The QList::const_reverse_iterator typedef provides an STL-style const
+ reverse iterator for QList.
+
+ It is simply a typedef for \c{std::reverse_iterator<const_iterator>}.
+
+ \warning Iterators on implicitly shared containers do not work
+ exactly like STL-iterators. You should avoid copying a container
+ while iterators are active on that container. For more information,
+ read \l{Implicit sharing iterator problem}.
+
+ \sa QList::rbegin(), QList::rend(), QList::reverse_iterator, QList::const_iterator
+*/
+
/*! \fn int QList::count() const
Returns the number of items in the list. This is effectively the
@@ -1090,7 +1227,7 @@ void **QListData::erase(void **xi)
not be empty. If the list can be empty, call isEmpty() before
calling this function.
- \sa last(), isEmpty()
+ \sa constFirst(), last(), isEmpty()
*/
/*! \fn const T& QList::first() const
@@ -1098,13 +1235,23 @@ void **QListData::erase(void **xi)
\overload
*/
+/*! \fn const T& QList::constFirst() const
+ \since 5.6
+
+ Returns a const reference to the first item in the list. The list must
+ not be empty. If the list can be empty, call isEmpty() before
+ calling this function.
+
+ \sa constLast(), isEmpty(), first()
+*/
+
/*! \fn T& QList::last()
Returns a reference to the last item in the list. The list must
not be empty. If the list can be empty, call isEmpty() before
calling this function.
- \sa first(), isEmpty()
+ \sa constLast(), first(), isEmpty()
*/
/*! \fn const T& QList::last() const
@@ -1112,6 +1259,16 @@ void **QListData::erase(void **xi)
\overload
*/
+/*! \fn const T& QList::constLast() const
+ \since 5.6
+
+ Returns a reference to the last item in the list. The list must
+ not be empty. If the list can be empty, call isEmpty() before
+ calling this function.
+
+ \sa constFirst(), isEmpty(), last()
+*/
+
/*! \fn void QList::removeFirst()
Removes the first item in the list. Calling this function is
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index f5ff952f97..ac46dc3244 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -38,6 +38,7 @@
#include <QtCore/qiterator.h>
#include <QtCore/qrefcount.h>
#include <QtCore/qarraydata.h>
+#include <QtCore/qhashfunctions.h>
#include <iterator>
#include <list>
@@ -220,7 +221,11 @@ public:
inline iterator() : i(0) {}
inline iterator(Node *n) : i(n) {}
+#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
+ // can't remove it in Qt 5, since doing so would make the type trivial,
+ // which changes the way it's passed to functions by value.
inline iterator(const iterator &o): i(o.i){}
+#endif
inline T &operator*() const { return i->t(); }
inline T *operator->() const { return &i->t(); }
inline T &operator[](difference_type j) const { return i[j].t(); }
@@ -268,7 +273,11 @@ public:
inline const_iterator() : i(0) {}
inline const_iterator(Node *n) : i(n) {}
+#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
+ // can't remove it in Qt 5, since doing so would make the type trivial,
+ // which changes the way it's passed to functions by value.
inline const_iterator(const const_iterator &o): i(o.i) {}
+#endif
#ifdef QT_STRICT_ITERATORS
inline explicit const_iterator(const iterator &o): i(o.i) {}
#else
@@ -296,6 +305,8 @@ public:
friend class const_iterator;
// stl style
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
inline iterator begin() { detach(); return reinterpret_cast<Node *>(p.begin()); }
inline const_iterator begin() const { return reinterpret_cast<Node *>(p.begin()); }
inline const_iterator cbegin() const { return reinterpret_cast<Node *>(p.begin()); }
@@ -304,6 +315,12 @@ public:
inline const_iterator end() const { return reinterpret_cast<Node *>(p.end()); }
inline const_iterator cend() const { return reinterpret_cast<Node *>(p.end()); }
inline const_iterator constEnd() const { return reinterpret_cast<Node *>(p.end()); }
+ reverse_iterator rbegin() { return reverse_iterator(end()); }
+ reverse_iterator rend() { return reverse_iterator(begin()); }
+ const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
+ const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
+ const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); }
+ const_reverse_iterator crend() const { return const_reverse_iterator(begin()); }
iterator insert(iterator before, const T &t);
iterator erase(iterator pos);
iterator erase(iterator first, iterator last);
@@ -314,9 +331,11 @@ public:
inline int count() const { return p.size(); }
inline int length() const { return p.size(); } // Same as count()
inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); }
+ inline const T& constFirst() const { return first(); }
inline const T& first() const { Q_ASSERT(!isEmpty()); return at(0); }
T& last() { Q_ASSERT(!isEmpty()); return *(--end()); }
const T& last() const { Q_ASSERT(!isEmpty()); return at(count() - 1); }
+ inline const T& constLast() const { return last(); }
inline void removeFirst() { Q_ASSERT(!isEmpty()); erase(begin()); }
inline void removeLast() { Q_ASSERT(!isEmpty()); erase(--end()); }
inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; }
@@ -1020,6 +1039,43 @@ inline int QList<T>::count_impl(const T &t, QListData::ArrayCompatibleLayout) co
Q_DECLARE_SEQUENTIAL_ITERATOR(List)
Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(List)
+template <typename T>
+uint qHash(const QList<T> &key, uint seed = 0)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHashRange(key.cbegin(), key.cend(), seed)))
+{
+ return qHashRange(key.cbegin(), key.cend(), seed);
+}
+
+template <typename T>
+bool operator<(const QList<T> &lhs, const QList<T> &rhs)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(),
+ rhs.begin(), rhs.end())))
+{
+ return std::lexicographical_compare(lhs.begin(), lhs.end(),
+ rhs.begin(), rhs.end());
+}
+
+template <typename T>
+inline bool operator>(const QList<T> &lhs, const QList<T> &rhs)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs))
+{
+ return rhs < lhs;
+}
+
+template <typename T>
+inline bool operator<=(const QList<T> &lhs, const QList<T> &rhs)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs))
+{
+ return !(lhs > rhs);
+}
+
+template <typename T>
+inline bool operator>=(const QList<T> &lhs, const QList<T> &rhs)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs))
+{
+ return !(lhs < rhs);
+}
+
QT_END_NAMESPACE
#include <QtCore/qbytearraylist.h>
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 824b70c3fd..703341cc36 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -42,6 +42,7 @@
#include "qdatastream.h"
#include "qdebug.h"
+#include "qhashfunctions.h"
#include "qstring.h"
#include "qlocale.h"
#include "qlocale_p.h"
@@ -420,7 +421,7 @@ bool qt_splitLocaleName(const QString &name, QString &lang, QString &script, QSt
state = ScriptState;
break;
case ScriptState: {
- QString scripts = QString::fromLatin1((const char *)script_code_list, sizeof(script_code_list));
+ QString scripts = QString::fromLatin1((const char *)script_code_list, sizeof(script_code_list) - 1);
if (value.length() == 4 && scripts.indexOf(value) % 4 == 0) {
// script name is always 4 characters
script = value;
@@ -866,6 +867,21 @@ bool QLocale::operator!=(const QLocale &other) const
}
/*!
+ \since 5.6
+ \relates QLocale
+
+ Returns the hash value for \a key, using
+ \a seed to seed the calculation.
+*/
+uint qHash(const QLocale &key, uint seed) Q_DECL_NOTHROW
+{
+ QtPrivate::QHashCombine hash;
+ seed = hash(seed, key.d->m_data);
+ seed = hash(seed, key.d->m_numberOptions);
+ return seed;
+}
+
+/*!
\since 4.2
Sets the \a options related to number conversions for this
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h
index 61574ba44f..0cbfa6710c 100644
--- a/src/corelib/tools/qlocale.h
+++ b/src/corelib/tools/qlocale.h
@@ -45,6 +45,7 @@ QT_BEGIN_NAMESPACE
class QDataStream;
class QDate;
class QDateTime;
+class QLocale;
class QTime;
class QVariant;
class QTextStream;
@@ -52,6 +53,8 @@ class QTextStreamPrivate;
class QLocalePrivate;
+Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed = 0) Q_DECL_NOTHROW;
+
class Q_CORE_EXPORT QLocale
{
Q_GADGET
@@ -868,23 +871,23 @@ public:
QString nativeLanguageName() const;
QString nativeCountryName() const;
- short toShort(const QString &s, bool *ok = 0) const;
- ushort toUShort(const QString &s, bool *ok = 0) const;
- int toInt(const QString &s, bool *ok = 0) const;
- uint toUInt(const QString &s, bool *ok = 0) const;
- qlonglong toLongLong(const QString &s, bool *ok = 0) const;
- qulonglong toULongLong(const QString &s, bool *ok = 0) const;
- float toFloat(const QString &s, bool *ok = 0) const;
- double toDouble(const QString &s, bool *ok = 0) const;
-
- short toShort(const QStringRef &s, bool *ok = 0) const;
- ushort toUShort(const QStringRef &s, bool *ok = 0) const;
- int toInt(const QStringRef &s, bool *ok = 0) const;
- uint toUInt(const QStringRef &s, bool *ok = 0) const;
- qlonglong toLongLong(const QStringRef &s, bool *ok = 0) const;
- qulonglong toULongLong(const QStringRef &s, bool *ok = 0) const;
- float toFloat(const QStringRef &s, bool *ok = 0) const;
- double toDouble(const QStringRef &s, bool *ok = 0) const;
+ short toShort(const QString &s, bool *ok = Q_NULLPTR) const;
+ ushort toUShort(const QString &s, bool *ok = Q_NULLPTR) const;
+ int toInt(const QString &s, bool *ok = Q_NULLPTR) const;
+ uint toUInt(const QString &s, bool *ok = Q_NULLPTR) const;
+ qlonglong toLongLong(const QString &s, bool *ok = Q_NULLPTR) const;
+ qulonglong toULongLong(const QString &s, bool *ok = Q_NULLPTR) const;
+ float toFloat(const QString &s, bool *ok = Q_NULLPTR) const;
+ double toDouble(const QString &s, bool *ok = Q_NULLPTR) const;
+
+ short toShort(const QStringRef &s, bool *ok = Q_NULLPTR) const;
+ ushort toUShort(const QStringRef &s, bool *ok = Q_NULLPTR) const;
+ int toInt(const QStringRef &s, bool *ok = Q_NULLPTR) const;
+ uint toUInt(const QStringRef &s, bool *ok = Q_NULLPTR) const;
+ qlonglong toLongLong(const QStringRef &s, bool *ok = Q_NULLPTR) const;
+ qulonglong toULongLong(const QStringRef &s, bool *ok = Q_NULLPTR) const;
+ float toFloat(const QStringRef &s, bool *ok = Q_NULLPTR) const;
+ double toDouble(const QStringRef &s, bool *ok = Q_NULLPTR) const;
QString toString(qlonglong i) const;
QString toString(qulonglong i) const;
@@ -979,6 +982,8 @@ public:
private:
QLocale(QLocalePrivate &dd);
friend class QLocalePrivate;
+ friend Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed) Q_DECL_NOTHROW;
+
QSharedDataPointer<QLocalePrivate> d;
};
Q_DECLARE_TYPEINFO(QLocale, Q_MOVABLE_TYPE);
diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm
index 37a63a2ca4..c0818f07d7 100644
--- a/src/corelib/tools/qlocale_mac.mm
+++ b/src/corelib/tools/qlocale_mac.mm
@@ -44,18 +44,6 @@
QT_BEGIN_NAMESPACE
-namespace {
-class AutoReleasePool
-{
-public:
- AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
- ~AutoReleasePool() { [pool release]; }
-
-private:
- NSAutoreleasePool *pool;
-};
-}
-
/******************************************************************************
** Wrappers for Mac locale system functions
*/
@@ -426,7 +414,7 @@ QLocale QSystemLocale::fallbackUiLocale() const
QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
{
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
switch(type) {
// case Name:
// return getMacLocaleName();
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index 1b7a8007cd..61e19252b3 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -1161,6 +1161,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
are stored under \a key.
*/
+/*!
+ \fn QPair<const_iterator, const_iterator> QMap::equal_range(const Key &key) const
+ \overload
+ \since 5.6
+*/
+
/*! \class QMap::iterator
\inmodule QtCore
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index 1f80e8f0f4..bf0a36aa88 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -38,6 +38,7 @@
#include <QtCore/qlist.h>
#include <QtCore/qrefcount.h>
#include <QtCore/qpair.h>
+#include <QtCore/qtypetraits.h>
#ifdef Q_MAP_DEBUG
#include <QtCore/qdebug.h>
@@ -94,6 +95,13 @@ struct Q_CORE_EXPORT QMapNodeBase
void setColor(Color c) { if (c == Black) p |= Black; else p &= ~Black; }
QMapNodeBase *parent() const { return reinterpret_cast<QMapNodeBase *>(p & ~Mask); }
void setParent(QMapNodeBase *pp) { p = (p & Mask) | quintptr(pp); }
+
+ template <typename T>
+ static typename QtPrivate::QEnableIf<QTypeInfo<T>::isComplex>::Type
+ callDestructorIfNecessary(T &t) Q_DECL_NOTHROW { Q_UNUSED(t); t.~T(); } // Q_UNUSED: silence MSVC unused 't' warning
+ template <typename T>
+ static typename QtPrivate::QEnableIf<!QTypeInfo<T>::isComplex>::Type
+ callDestructorIfNecessary(T &) Q_DECL_NOTHROW {}
};
template <class Key, class T>
@@ -112,12 +120,26 @@ struct QMapNode : public QMapNodeBase
QMapNode<Key, T> *copy(QMapData<Key, T> *d) const;
- void destroySubTree();
+ void destroySubTree()
+ {
+ callDestructorIfNecessary(key);
+ callDestructorIfNecessary(value);
+ doDestroySubTree(QtPrivate::integral_constant<bool, QTypeInfo<T>::isComplex || QTypeInfo<Key>::isComplex>());
+ }
QMapNode<Key, T> *lowerBound(const Key &key);
QMapNode<Key, T> *upperBound(const Key &key);
private:
+ void doDestroySubTree(QtPrivate::false_type) {}
+ void doDestroySubTree(QtPrivate::true_type)
+ {
+ if (left)
+ leftNode()->destroySubTree();
+ if (right)
+ rightNode()->destroySubTree();
+ }
+
QMapNode() Q_DECL_EQ_DELETE;
Q_DISABLE_COPY(QMapNode)
};
@@ -126,7 +148,7 @@ template <class Key, class T>
inline QMapNode<Key, T> *QMapNode<Key, T>::lowerBound(const Key &akey)
{
QMapNode<Key, T> *n = this;
- QMapNode<Key, T> *lastNode = 0;
+ QMapNode<Key, T> *lastNode = Q_NULLPTR;
while (n) {
if (!qMapLessThanKey(n->key, akey)) {
lastNode = n;
@@ -142,7 +164,7 @@ template <class Key, class T>
inline QMapNode<Key, T> *QMapNode<Key, T>::upperBound(const Key &akey)
{
QMapNode<Key, T> *n = this;
- QMapNode<Key, T> *lastNode = 0;
+ QMapNode<Key, T> *lastNode = Q_NULLPTR;
while (n) {
if (qMapLessThanKey(akey, n->key)) {
lastNode = n;
@@ -194,7 +216,7 @@ struct QMapData : public QMapDataBase
Node *findNode(const Key &akey) const;
void nodeRange(const Key &akey, Node **firstNode, Node **lastNode);
- Node *createNode(const Key &k, const T &v, Node *parent = 0, bool left = false)
+ Node *createNode(const Key &k, const T &v, Node *parent = Q_NULLPTR, bool left = false)
{
Node *n = static_cast<Node *>(QMapDataBase::createNode(sizeof(Node), Q_ALIGNOF(Node),
parent, left));
@@ -235,48 +257,22 @@ QMapNode<Key, T> *QMapNode<Key, T>::copy(QMapData<Key, T> *d) const
n->left = leftNode()->copy(d);
n->left->setParent(n);
} else {
- n->left = 0;
+ n->left = Q_NULLPTR;
}
if (right) {
n->right = rightNode()->copy(d);
n->right->setParent(n);
} else {
- n->right = 0;
+ n->right = Q_NULLPTR;
}
return n;
}
-#if defined(Q_CC_MSVC)
-#pragma warning( push )
-#pragma warning( disable : 4127 ) // conditional expression is constant
-#endif
-
-template <class Key, class T>
-void QMapNode<Key, T>::destroySubTree()
-{
- if (QTypeInfo<Key>::isComplex)
- key.~Key();
- if (QTypeInfo<T>::isComplex)
- value.~T();
- if (QTypeInfo<Key>::isComplex || QTypeInfo<T>::isComplex) {
- if (left)
- leftNode()->destroySubTree();
- if (right)
- rightNode()->destroySubTree();
- }
-}
-
-#if defined(Q_CC_MSVC)
-#pragma warning( pop )
-#endif
-
template <class Key, class T>
void QMapData<Key, T>::deleteNode(QMapNode<Key, T> *z)
{
- if (QTypeInfo<Key>::isComplex)
- z->key.~Key();
- if (QTypeInfo<T>::isComplex)
- z->value.~T();
+ QMapNodeBase::callDestructorIfNecessary(z->key);
+ QMapNodeBase::callDestructorIfNecessary(z->value);
freeNodeAndRebalance(z);
}
@@ -288,7 +284,7 @@ QMapNode<Key, T> *QMapData<Key, T>::findNode(const Key &akey) const
if (lb && !qMapLessThanKey(akey, lb->key))
return lb;
}
- return 0;
+ return Q_NULLPTR;
}
@@ -304,10 +300,10 @@ void QMapData<Key, T>::nodeRange(const Key &akey, QMapNode<Key, T> **firstNode,
} else if (qMapLessThanKey(n->key, akey)) {
n = n->rightNode();
} else {
- *firstNode = n->leftNode() ? n->leftNode()->lowerBound(akey) : 0;
+ *firstNode = n->leftNode() ? n->leftNode()->lowerBound(akey) : Q_NULLPTR;
if (!*firstNode)
*firstNode = n;
- *lastNode = n->rightNode() ? n->rightNode()->upperBound(akey) : 0;
+ *lastNode = n->rightNode() ? n->rightNode()->upperBound(akey) : Q_NULLPTR;
if (!*lastNode)
*lastNode = l;
return;
@@ -416,7 +412,7 @@ public:
typedef T *pointer;
typedef T &reference;
- inline iterator() : i(0) { }
+ inline iterator() : i(Q_NULLPTR) { }
inline iterator(Node *node) : i(node) { }
inline const Key &key() const { return i->key; }
@@ -473,7 +469,7 @@ public:
typedef const T *pointer;
typedef const T &reference;
- inline const_iterator() : i(0) { }
+ inline const_iterator() : i(Q_NULLPTR) { }
inline const_iterator(const Node *node) : i(node) { }
#ifdef QT_STRICT_ITERATORS
explicit inline const_iterator(const iterator &o)
@@ -557,6 +553,7 @@ public:
typedef int size_type;
inline bool empty() const { return isEmpty(); }
QPair<iterator, iterator> equal_range(const Key &akey);
+ QPair<const_iterator, const_iterator> equal_range(const Key &akey) const;
#ifdef Q_MAP_DEBUG
void dump() const;
@@ -653,7 +650,7 @@ Q_INLINE_TEMPLATE int QMap<Key, T>::count(const Key &akey) const
template <class Key, class T>
Q_INLINE_TEMPLATE bool QMap<Key, T>::contains(const Key &akey) const
{
- return d->findNode(akey) != 0;
+ return d->findNode(akey) != Q_NULLPTR;
}
template <class Key, class T>
@@ -662,7 +659,7 @@ Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::insert(const Key
detach();
Node *n = d->root();
Node *y = d->end();
- Node *lastNode = 0;
+ Node *lastNode = Q_NULLPTR;
bool left = true;
while (n) {
y = n;
@@ -737,15 +734,15 @@ typename QMap<Key, T>::iterator QMap<Key, T>::insert(const_iterator pos, const K
}
// we need to insert (not overwrite)
- if (prev->right == 0) {
+ if (prev->right == Q_NULLPTR) {
Node *z = d->createNode(akey, avalue, prev, false);
return iterator(z);
}
- if (next->left == 0) {
+ if (next->left == Q_NULLPTR) {
Node *z = d->createNode(akey, avalue, next, true);
return iterator(z);
}
- Q_ASSERT(false); // We should have prev->right == 0 or next->left == 0.
+ Q_ASSERT(false); // We should have prev->right == Q_NULLPTR or next->left == Q_NULLPTR.
return this->insert(akey, avalue);
}
}
@@ -759,7 +756,7 @@ Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::insertMulti(cons
Node* y = d->end();
Node* x = static_cast<Node *>(d->root());
bool left = true;
- while (x != 0) {
+ while (x != Q_NULLPTR) {
left = !qMapLessThanKey(x->key, akey);
y = x;
x = left ? x->leftNode() : x->rightNode();
@@ -806,15 +803,15 @@ typename QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const_iterator pos, co
return this->insertMulti(akey, avalue); // ignore hint
// Hint is ok - do insert
- if (prev->right == 0) {
+ if (prev->right == Q_NULLPTR) {
Node *z = d->createNode(akey, avalue, prev, false);
return iterator(z);
}
- if (next->left == 0) {
+ if (next->left == Q_NULLPTR) {
Node *z = d->createNode(akey, avalue, next, true);
return iterator(z);
}
- Q_ASSERT(false); // We should have prev->right == 0 or next->left == 0.
+ Q_ASSERT(false); // We should have prev->right == Q_NULLPTR or next->left == Q_NULLPTR.
return this->insertMulti(akey, avalue);
}
}
@@ -864,6 +861,15 @@ QPair<typename QMap<Key, T>::iterator, typename QMap<Key, T>::iterator> QMap<Key
return QPair<iterator, iterator>(iterator(firstNode), iterator(lastNode));
}
+template <class Key, class T>
+QPair<typename QMap<Key, T>::const_iterator, typename QMap<Key, T>::const_iterator>
+QMap<Key, T>::equal_range(const Key &akey) const
+{
+ Node *firstNode, *lastNode;
+ d->nodeRange(akey, &firstNode, &lastNode);
+ return qMakePair(const_iterator(firstNode), const_iterator(lastNode));
+}
+
#ifdef Q_MAP_DEBUG
template <class Key, class T>
void QMap<Key, T>::dump() const
@@ -1051,7 +1057,7 @@ Q_OUTOFLINE_TEMPLATE QList<T> QMap<Key, T>::values(const Key &akey) const
template <class Key, class T>
Q_INLINE_TEMPLATE typename QMap<Key, T>::const_iterator QMap<Key, T>::lowerBound(const Key &akey) const
{
- Node *lb = d->root() ? d->root()->lowerBound(akey) : 0;
+ Node *lb = d->root() ? d->root()->lowerBound(akey) : Q_NULLPTR;
if (!lb)
lb = d->end();
return const_iterator(lb);
@@ -1061,7 +1067,7 @@ template <class Key, class T>
Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::lowerBound(const Key &akey)
{
detach();
- Node *lb = d->root() ? d->root()->lowerBound(akey) : 0;
+ Node *lb = d->root() ? d->root()->lowerBound(akey) : Q_NULLPTR;
if (!lb)
lb = d->end();
return iterator(lb);
@@ -1071,7 +1077,7 @@ template <class Key, class T>
Q_INLINE_TEMPLATE typename QMap<Key, T>::const_iterator
QMap<Key, T>::upperBound(const Key &akey) const
{
- Node *ub = d->root() ? d->root()->upperBound(akey) : 0;
+ Node *ub = d->root() ? d->root()->upperBound(akey) : Q_NULLPTR;
if (!ub)
ub = d->end();
return const_iterator(ub);
@@ -1081,7 +1087,7 @@ template <class Key, class T>
Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::upperBound(const Key &akey)
{
detach();
- Node *ub = d->root() ? d->root()->upperBound(akey) : 0;
+ Node *ub = d->root() ? d->root()->upperBound(akey) : Q_NULLPTR;
if (!ub)
ub = d->end();
return iterator(ub);
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index cd8c393d51..5aa9d54843 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -38,6 +38,7 @@
#include "qcache.h"
#include "qdatastream.h"
#include "qdebug.h"
+#include "qhashfunctions.h"
#include "qlist.h"
#include "qmap.h"
#include "qmutex.h"
@@ -882,6 +883,15 @@ static bool operator==(const QRegExpEngineKey &key1, const QRegExpEngineKey &key
&& key1.cs == key2.cs;
}
+static uint qHash(const QRegExpEngineKey &key, uint seed = 0) Q_DECL_NOTHROW
+{
+ QtPrivate::QHashCombine hash;
+ seed = hash(seed, key.pattern);
+ seed = hash(seed, key.patternSyntax);
+ seed = hash(seed, key.cs);
+ return seed;
+}
+
class QRegExpEngine;
//Q_DECLARE_TYPEINFO(QVector<int>, Q_MOVABLE_TYPE);
@@ -3807,11 +3817,6 @@ struct QRegExpPrivate
};
#if !defined(QT_NO_REGEXP_OPTIM)
-uint qHash(const QRegExpEngineKey &key, uint seed = 0) Q_DECL_NOTHROW
-{
- return qHash(key.pattern, seed);
-}
-
typedef QCache<QRegExpEngineKey, QRegExpEngine> EngineCache;
Q_GLOBAL_STATIC(EngineCache, globalEngineCache)
static QBasicMutex globalEngineCacheMutex;
@@ -4033,6 +4038,21 @@ bool QRegExp::operator==(const QRegExp &rx) const
}
/*!
+ \since 5.6
+ \relates QRegExp
+
+ Returns the hash value for \a key, using
+ \a seed to seed the calculation.
+*/
+uint qHash(const QRegExp &key, uint seed) Q_DECL_NOTHROW
+{
+ QtPrivate::QHashCombine hash;
+ seed = hash(seed, key.priv->engineKey);
+ seed = hash(seed, key.priv->minimal);
+ return seed;
+}
+
+/*!
\fn bool QRegExp::operator!=(const QRegExp &rx) const
Returns \c true if this regular expression is not equal to \a rx;
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index b08a8bd282..f384e6c51f 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -45,6 +45,9 @@ QT_BEGIN_NAMESPACE
struct QRegExpPrivate;
class QStringList;
+class QRegExp;
+
+Q_CORE_EXPORT uint qHash(const QRegExp &key, uint seed = 0) Q_DECL_NOTHROW;
class Q_CORE_EXPORT QRegExp
{
@@ -104,6 +107,8 @@ public:
static QString escape(const QString &str);
+ friend Q_CORE_EXPORT uint qHash(const QRegExp &key, uint seed) Q_DECL_NOTHROW;
+
private:
QRegExpPrivate *priv;
};
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 2e3c2ca79f..88a048d826 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -38,6 +38,7 @@
#ifndef QT_NO_REGULAREXPRESSION
#include <QtCore/qcoreapplication.h>
+#include <QtCore/qhashfunctions.h>
#include <QtCore/qmutex.h>
#include <QtCore/qvector.h>
#include <QtCore/qstringlist.h>
@@ -1845,6 +1846,21 @@ bool QRegularExpression::operator==(const QRegularExpression &re) const
*/
/*!
+ \since 5.6
+ \relates QRegularExpression
+
+ Returns the hash value for \a key, using
+ \a seed to seed the calculation.
+*/
+uint qHash(const QRegularExpression &key, uint seed) Q_DECL_NOTHROW
+{
+ QtPrivate::QHashCombine hash;
+ seed = hash(seed, key.d->pattern);
+ seed = hash(seed, key.d->patternOptions);
+ return seed;
+}
+
+/*!
Escapes all characters of \a str so that they no longer have any special
meaning when used as a regular expression pattern string, and returns
the escaped string. For instance:
@@ -2112,7 +2128,8 @@ QStringRef QRegularExpressionMatch::capturedRef(const QString &name) const
QStringList QRegularExpressionMatch::capturedTexts() const
{
QStringList texts;
- for (int i = 0; i <= lastCapturedIndex(); ++i)
+ texts.reserve(d->capturedCount);
+ for (int i = 0; i < d->capturedCount; ++i)
texts << captured(i);
return texts;
}
diff --git a/src/corelib/tools/qregularexpression.h b/src/corelib/tools/qregularexpression.h
index d2abfc7701..2bca6a211b 100644
--- a/src/corelib/tools/qregularexpression.h
+++ b/src/corelib/tools/qregularexpression.h
@@ -49,6 +49,9 @@ QT_BEGIN_NAMESPACE
class QRegularExpressionMatch;
class QRegularExpressionMatchIterator;
struct QRegularExpressionPrivate;
+class QRegularExpression;
+
+Q_CORE_EXPORT uint qHash(const QRegularExpression &key, uint seed = 0) Q_DECL_NOTHROW;
class Q_CORE_EXPORT QRegularExpression
{
@@ -139,6 +142,7 @@ private:
friend class QRegularExpressionMatch;
friend struct QRegularExpressionMatchPrivate;
friend class QRegularExpressionMatchIterator;
+ friend Q_CORE_EXPORT uint qHash(const QRegularExpression &key, uint seed) Q_DECL_NOTHROW;
QRegularExpression(QRegularExpressionPrivate &dd);
QExplicitlySharedDataPointer<QRegularExpressionPrivate> d;
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp
new file mode 100644
index 0000000000..658267a521
--- /dev/null
+++ b/src/corelib/tools/qringbuffer.cpp
@@ -0,0 +1,310 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Alex Trotsenko <alex1973tr@gmail.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "private/qringbuffer_p.h"
+#include "private/qbytearray_p.h"
+#include <string.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \internal
+
+ Access the bytes at a specified position the out-variable length will
+ contain the amount of bytes readable from there, e.g. the amount still
+ the same QByteArray
+*/
+const char *QRingBuffer::readPointerAtPosition(qint64 pos, qint64 &length) const
+{
+ if (pos >= 0) {
+ pos += head;
+ for (int i = 0; i < buffers.size(); ++i) {
+ length = (i == tailBuffer ? tail : buffers[i].size());
+ if (length > pos) {
+ length -= pos;
+ return buffers[i].constData() + pos;
+ }
+ pos -= length;
+ }
+ }
+
+ length = 0;
+ return 0;
+}
+
+void QRingBuffer::free(qint64 bytes)
+{
+ while (bytes > 0) {
+ const qint64 blockSize = buffers.first().size() - head;
+
+ if (tailBuffer == 0 || blockSize > bytes) {
+ // keep a single block around if it does not exceed
+ // the basic block size, to avoid repeated allocations
+ // between uses of the buffer
+ if (bufferSize <= bytes) {
+ if (buffers.first().size() <= basicBlockSize) {
+ bufferSize = 0;
+ head = tail = 0;
+ } else {
+ clear(); // try to minify/squeeze us
+ }
+ } else {
+ Q_ASSERT(bytes < MaxByteArraySize);
+ head += int(bytes);
+ bufferSize -= bytes;
+ }
+ return;
+ }
+
+ bufferSize -= blockSize;
+ bytes -= blockSize;
+ buffers.removeFirst();
+ --tailBuffer;
+ head = 0;
+ }
+}
+
+char *QRingBuffer::reserve(qint64 bytes)
+{
+ if (bytes <= 0 || bytes >= MaxByteArraySize)
+ return 0;
+
+ const qint64 newSize = bytes + tail;
+ // if need buffer reallocation
+ if (newSize > buffers.last().size()) {
+ if (newSize > buffers.last().capacity() && (tail >= basicBlockSize
+ || newSize >= MaxByteArraySize)) {
+ // shrink this buffer to its current size
+ buffers.last().resize(tail);
+
+ // create a new QByteArray
+ buffers.append(QByteArray());
+ ++tailBuffer;
+ tail = 0;
+ }
+ buffers.last().resize(qMax(basicBlockSize, tail + int(bytes)));
+ }
+
+ char *writePtr = buffers.last().data() + tail;
+ bufferSize += bytes;
+ Q_ASSERT(bytes < MaxByteArraySize);
+ tail += int(bytes);
+ return writePtr;
+}
+
+/*!
+ \internal
+
+ Allocate data at buffer head
+*/
+char *QRingBuffer::reserveFront(qint64 bytes)
+{
+ if (bytes <= 0 || bytes >= MaxByteArraySize)
+ return 0;
+
+ if (head < bytes) {
+ buffers.first().remove(0, head);
+ if (tailBuffer == 0)
+ tail -= head;
+
+ buffers.prepend(QByteArray());
+ head = qMax(basicBlockSize, int(bytes));
+ buffers.first().resize(head);
+ ++tailBuffer;
+ }
+
+ head -= int(bytes);
+ bufferSize += bytes;
+ return buffers.first().data() + head;
+}
+
+void QRingBuffer::chop(qint64 bytes)
+{
+ while (bytes > 0) {
+ if (tailBuffer == 0 || tail > bytes) {
+ // keep a single block around if it does not exceed
+ // the basic block size, to avoid repeated allocations
+ // between uses of the buffer
+ if (bufferSize <= bytes) {
+ if (buffers.first().size() <= basicBlockSize) {
+ bufferSize = 0;
+ head = tail = 0;
+ } else {
+ clear(); // try to minify/squeeze us
+ }
+ } else {
+ Q_ASSERT(bytes < MaxByteArraySize);
+ tail -= int(bytes);
+ bufferSize -= bytes;
+ }
+ return;
+ }
+
+ bufferSize -= tail;
+ bytes -= tail;
+ buffers.removeLast();
+ --tailBuffer;
+ tail = buffers.last().size();
+ }
+}
+
+void QRingBuffer::clear()
+{
+ buffers.erase(buffers.begin() + 1, buffers.end());
+ buffers.first().clear();
+
+ head = tail = 0;
+ tailBuffer = 0;
+ bufferSize = 0;
+}
+
+qint64 QRingBuffer::indexOf(char c, qint64 maxLength) const
+{
+ qint64 index = 0;
+ qint64 j = head;
+ for (int i = 0; index < maxLength && i < buffers.size(); ++i) {
+ const char *ptr = buffers[i].constData() + j;
+ j = qMin(index + (i == tailBuffer ? tail : buffers[i].size()) - j, maxLength);
+
+ while (index < j) {
+ if (*ptr++ == c)
+ return index;
+ ++index;
+ }
+ j = 0;
+ }
+ return -1;
+}
+
+qint64 QRingBuffer::read(char *data, qint64 maxLength)
+{
+ const qint64 bytesToRead = qMin(size(), maxLength);
+ qint64 readSoFar = 0;
+ while (readSoFar < bytesToRead) {
+ const qint64 bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar,
+ nextDataBlockSize());
+ if (data)
+ memcpy(data + readSoFar, readPointer(), bytesToReadFromThisBlock);
+ readSoFar += bytesToReadFromThisBlock;
+ free(bytesToReadFromThisBlock);
+ }
+ return readSoFar;
+}
+
+/*!
+ \internal
+
+ Read an unspecified amount (will read the first buffer)
+*/
+QByteArray QRingBuffer::read()
+{
+ if (bufferSize == 0)
+ return QByteArray();
+
+ QByteArray qba(buffers.takeFirst());
+
+ qba.reserve(0); // avoid that resizing needlessly reallocates
+ if (tailBuffer == 0) {
+ qba.resize(tail);
+ tail = 0;
+ buffers.append(QByteArray());
+ } else {
+ --tailBuffer;
+ }
+ qba.remove(0, head); // does nothing if head is 0
+ head = 0;
+ bufferSize -= qba.size();
+ return qba;
+}
+
+/*!
+ \internal
+
+ Peek the bytes from a specified position
+*/
+qint64 QRingBuffer::peek(char *data, qint64 maxLength, qint64 pos) const
+{
+ qint64 readSoFar = 0;
+
+ if (pos >= 0) {
+ pos += head;
+ for (int i = 0; readSoFar < maxLength && i < buffers.size(); ++i) {
+ qint64 blockLength = (i == tailBuffer ? tail : buffers[i].size());
+
+ if (pos < blockLength) {
+ blockLength = qMin(blockLength - pos, maxLength - readSoFar);
+ memcpy(data + readSoFar, buffers[i].constData() + pos, blockLength);
+ readSoFar += blockLength;
+ pos = 0;
+ } else {
+ pos -= blockLength;
+ }
+ }
+ }
+
+ return readSoFar;
+}
+
+/*!
+ \internal
+
+ Append a new buffer to the end
+*/
+void QRingBuffer::append(const QByteArray &qba)
+{
+ if (tail == 0) {
+ buffers.last() = qba;
+ } else {
+ buffers.last().resize(tail);
+ buffers.append(qba);
+ ++tailBuffer;
+ }
+ tail = qba.size();
+ bufferSize += tail;
+}
+
+qint64 QRingBuffer::readLine(char *data, qint64 maxLength)
+{
+ if (!data || --maxLength <= 0)
+ return -1;
+
+ qint64 i = indexOf('\n', maxLength);
+ i = read(data, i >= 0 ? (i + 1) : maxLength);
+
+ // Terminate it.
+ data[i] = '\0';
+ return i;
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index ead85e9da0..68509a6a80 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -58,7 +58,7 @@ public:
buffers.append(QByteArray());
}
- inline int nextDataBlockSize() const {
+ inline qint64 nextDataBlockSize() const {
return (tailBuffer == 0 ? tail : buffers.first().size()) - head;
}
@@ -66,112 +66,17 @@ public:
return bufferSize == 0 ? Q_NULLPTR : (buffers.first().constData() + head);
}
- // access the bytes at a specified position
- // the out-variable length will contain the amount of bytes readable
- // from there, e.g. the amount still the same QByteArray
- inline const char *readPointerAtPosition(qint64 pos, qint64 &length) const {
- if (pos >= 0) {
- pos += head;
- for (int i = 0; i < buffers.size(); ++i) {
- length = (i == tailBuffer ? tail : buffers[i].size());
- if (length > pos) {
- length -= pos;
- return buffers[i].constData() + pos;
- }
- pos -= length;
- }
- }
-
- length = 0;
- return 0;
- }
-
- inline void free(int bytes) {
- while (bytes > 0) {
- int blockSize = buffers.first().size() - head;
-
- if (tailBuffer == 0 || blockSize > bytes) {
- // keep a single block around if it does not exceed
- // the basic block size, to avoid repeated allocations
- // between uses of the buffer
- if (bufferSize <= bytes) {
- if (buffers.first().size() <= basicBlockSize) {
- bufferSize = 0;
- head = tail = 0;
- } else {
- clear(); // try to minify/squeeze us
- }
- } else {
- head += bytes;
- bufferSize -= bytes;
- }
- return;
- }
-
- bufferSize -= blockSize;
- bytes -= blockSize;
- buffers.removeFirst();
- --tailBuffer;
- head = 0;
- }
- }
-
- inline char *reserve(int bytes) {
- if (bytes <= 0)
- return 0;
-
- // if need buffer reallocation
- if (tail + bytes > buffers.last().size()) {
- if (tail + bytes > buffers.last().capacity() && tail >= basicBlockSize) {
- // shrink this buffer to its current size
- buffers.last().resize(tail);
-
- // create a new QByteArray
- buffers.append(QByteArray());
- ++tailBuffer;
- tail = 0;
- }
- buffers.last().resize(qMax(basicBlockSize, tail + bytes));
- }
+ Q_CORE_EXPORT const char *readPointerAtPosition(qint64 pos, qint64 &length) const;
+ Q_CORE_EXPORT void free(qint64 bytes);
+ Q_CORE_EXPORT char *reserve(qint64 bytes);
+ Q_CORE_EXPORT char *reserveFront(qint64 bytes);
- char *writePtr = buffers.last().data() + tail;
- bufferSize += bytes;
- tail += bytes;
- return writePtr;
- }
-
- inline void truncate(int pos) {
+ inline void truncate(qint64 pos) {
if (pos < size())
chop(size() - pos);
}
- inline void chop(int bytes) {
- while (bytes > 0) {
- if (tailBuffer == 0 || tail > bytes) {
- // keep a single block around if it does not exceed
- // the basic block size, to avoid repeated allocations
- // between uses of the buffer
- if (bufferSize <= bytes) {
- if (buffers.first().size() <= basicBlockSize) {
- bufferSize = 0;
- head = tail = 0;
- } else {
- clear(); // try to minify/squeeze us
- }
- } else {
- tail -= bytes;
- bufferSize -= bytes;
- }
- return;
- }
-
- bufferSize -= tail;
- bytes -= tail;
- buffers.removeLast();
- --tailBuffer;
- tail = buffers.last().size();
- }
- }
+ Q_CORE_EXPORT void chop(qint64 bytes);
inline bool isEmpty() const {
return bufferSize == 0;
@@ -190,131 +95,36 @@ public:
*ptr = c;
}
- inline void ungetChar(char c) {
- --head;
- if (head < 0) {
- if (bufferSize != 0) {
- buffers.prepend(QByteArray());
- ++tailBuffer;
- } else {
- tail = basicBlockSize;
- }
- buffers.first().resize(basicBlockSize);
- head = basicBlockSize - 1;
- }
- buffers.first()[head] = c;
- ++bufferSize;
- }
-
- inline int size() const {
- return bufferSize;
- }
-
- inline void clear() {
- buffers.erase(buffers.begin() + 1, buffers.end());
- buffers.first().clear();
-
- head = tail = 0;
- tailBuffer = 0;
- bufferSize = 0;
- }
-
- inline int indexOf(char c) const {
- int index = 0;
- int j = head;
- for (int i = 0; i < buffers.size(); ++i) {
- const char *ptr = buffers[i].constData() + j;
- j = index + (i == tailBuffer ? tail : buffers[i].size()) - j;
-
- while (index < j) {
- if (*ptr++ == c)
- return index;
- ++index;
- }
- j = 0;
- }
- return -1;
- }
-
- inline int indexOf(char c, int maxLength) const {
- int index = 0;
- int j = head;
- for (int i = 0; index < maxLength && i < buffers.size(); ++i) {
- const char *ptr = buffers[i].constData() + j;
- j = qMin(index + (i == tailBuffer ? tail : buffers[i].size()) - j, maxLength);
-
- while (index < j) {
- if (*ptr++ == c)
- return index;
- ++index;
- }
- j = 0;
- }
- return -1;
- }
-
- inline int read(char *data, int maxLength) {
- int bytesToRead = qMin(size(), maxLength);
- int readSoFar = 0;
- while (readSoFar < bytesToRead) {
- int bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar, nextDataBlockSize());
- if (data)
- memcpy(data + readSoFar, readPointer(), bytesToReadFromThisBlock);
- readSoFar += bytesToReadFromThisBlock;
- free(bytesToReadFromThisBlock);
+ void ungetChar(char c)
+ {
+ if (head > 0) {
+ --head;
+ buffers.first()[head] = c;
+ ++bufferSize;
+ } else {
+ char *ptr = reserveFront(1);
+ *ptr = c;
}
- return readSoFar;
}
- // read an unspecified amount (will read the first buffer)
- inline QByteArray read() {
- if (bufferSize == 0)
- return QByteArray();
- QByteArray qba(buffers.takeFirst());
-
- qba.reserve(0); // avoid that resizing needlessly reallocates
- if (tailBuffer == 0) {
- qba.resize(tail);
- tail = 0;
- buffers.append(QByteArray());
- } else {
- --tailBuffer;
- }
- qba.remove(0, head); // does nothing if head is 0
- head = 0;
- bufferSize -= qba.size();
- return qba;
+ inline qint64 size() const {
+ return bufferSize;
}
- // append a new buffer to the end
- inline void append(const QByteArray &qba) {
- if (tail == 0) {
- buffers.last() = qba;
- } else {
- buffers.last().resize(tail);
- buffers.append(qba);
- ++tailBuffer;
- }
- tail = qba.size();
- bufferSize += tail;
- }
+ Q_CORE_EXPORT void clear();
+ inline qint64 indexOf(char c) const { return indexOf(c, size()); }
+ Q_CORE_EXPORT qint64 indexOf(char c, qint64 maxLength) const;
+ Q_CORE_EXPORT qint64 read(char *data, qint64 maxLength);
+ Q_CORE_EXPORT QByteArray read();
+ Q_CORE_EXPORT qint64 peek(char *data, qint64 maxLength, qint64 pos = 0) const;
+ Q_CORE_EXPORT void append(const QByteArray &qba);
- inline int skip(int length) {
+ inline qint64 skip(qint64 length) {
return read(0, length);
}
- inline int readLine(char *data, int maxLength) {
- if (!data || --maxLength <= 0)
- return -1;
-
- int i = indexOf('\n', maxLength);
- i = read(data, i >= 0 ? (i + 1) : maxLength);
-
- // Terminate it.
- data[i] = '\0';
- return i;
- }
+ Q_CORE_EXPORT qint64 readLine(char *data, qint64 maxLength);
inline bool canReadLine() const {
return indexOf('\n') >= 0;
@@ -325,7 +135,7 @@ private:
int head, tail;
int tailBuffer; // always buffers.size() - 1
const int basicBlockSize;
- int bufferSize;
+ qint64 bufferSize;
};
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index e4688711d6..5a9c75fe07 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -137,6 +137,7 @@ public:
typedef QHash<T, QHashDummyValue> Hash;
typename Hash::const_iterator i;
friend class iterator;
+ friend class QSet<T>;
public:
typedef std::bidirectional_iterator_tag iterator_category;
@@ -191,6 +192,7 @@ public:
inline const_iterator constFind(const T &value) const { return find(value); }
QSet<T> &unite(const QSet<T> &other);
QSet<T> &intersect(const QSet<T> &other);
+ bool intersects(const QSet<T> &other) const;
QSet<T> &subtract(const QSet<T> &other);
// STL compatibility
@@ -284,6 +286,34 @@ Q_INLINE_TEMPLATE QSet<T> &QSet<T>::intersect(const QSet<T> &other)
}
template <class T>
+Q_INLINE_TEMPLATE bool QSet<T>::intersects(const QSet<T> &other) const
+{
+ const bool otherIsBigger = other.size() > size();
+ const QSet &smallestSet = otherIsBigger ? *this : other;
+ const QSet &biggestSet = otherIsBigger ? other : *this;
+ const bool equalSeeds = q_hash.d->seed == other.q_hash.d->seed;
+ typename QSet::const_iterator i = smallestSet.cbegin();
+ typename QSet::const_iterator e = smallestSet.cend();
+
+ if (Q_LIKELY(equalSeeds)) {
+ // If seeds are equal we take the fast path so no hash is recalculated.
+ while (i != e) {
+ if (*biggestSet.q_hash.findNode(*i, i.i.i->h) != biggestSet.q_hash.e)
+ return true;
+ ++i;
+ }
+ } else {
+ while (i != e) {
+ if (biggestSet.contains(*i))
+ return true;
+ ++i;
+ }
+ }
+
+ return false;
+}
+
+template <class T>
Q_INLINE_TEMPLATE QSet<T> &QSet<T>::subtract(const QSet<T> &other)
{
QSet<T> copy1(*this);
diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc
index c38fe858fb..495329b90d 100644
--- a/src/corelib/tools/qset.qdoc
+++ b/src/corelib/tools/qset.qdoc
@@ -503,7 +503,17 @@
Removes all items from this set that are not contained in the
\a other set. A reference to this set is returned.
- \sa operator&=(), unite(), subtract()
+ \sa intersects(), operator&=(), unite(), subtract()
+*/
+
+/*!
+ \fn bool QSet::intersects(const QSet<T> &other) const
+ \since 5.6
+
+ Returns \c true if this set has at least one item in common with
+ \a other.
+
+ \sa contains(), intersect()
*/
/*!
diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h
index 9dd8fff9cb..a9f71c7b57 100644
--- a/src/corelib/tools/qshareddata.h
+++ b/src/corelib/tools/qshareddata.h
@@ -36,7 +36,10 @@
#include <QtCore/qglobal.h>
#include <QtCore/qatomic.h>
+#if QT_DEPRECATED_SINCE(5, 5)
#include <QtCore/qhash.h>
+#endif
+#include <QtCore/qhashfunctions.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 9e6b48a97d..3be10d9d87 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -55,7 +55,10 @@ QT_END_NAMESPACE
#include <new>
#include <QtCore/qatomic.h>
#include <QtCore/qobject.h> // for qobject_cast
-#include <QtCore/qhash.h> // for qHash
+#if QT_DEPRECATED_SINCE(5, 5)
+#include <QtCore/qhash.h>
+#endif
+#include <QtCore/qhashfunctions.h>
#if defined(Q_COMPILER_RVALUE_REFS) && defined(Q_COMPILER_VARIADIC_TEMPLATES)
# include <utility> // for std::forward
@@ -329,7 +332,8 @@ public:
}
inline QSharedPointer &operator=(QSharedPointer &&other)
{
- swap(other);
+ QSharedPointer moved(std::move(other));
+ swap(moved);
return *this;
}
#endif
@@ -587,7 +591,7 @@ public:
inline bool operator !() const { return isNull(); }
inline T *data() const { return d == 0 || d->strongref.load() == 0 ? 0 : value; }
- Q_DECL_CONSTEXPR inline QWeakPointer() : d(0), value(0) { }
+ inline QWeakPointer() : d(0), value(0) { }
inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; }
#ifndef QT_NO_QOBJECT
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index 52ffc161bf..d572dd209c 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -39,7 +39,9 @@
#if defined(Q_OS_WIN)
# if defined(Q_OS_WINCE)
# include <qt_windows.h>
-# include <cmnintrin.h>
+# if _WIN32_WCE < 0x800
+# include <cmnintrin.h>
+# endif
# endif
# if !defined(Q_CC_GNU)
# ifndef Q_OS_WINCE
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index bbb5647eea..07ca62145b 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -50,7 +50,6 @@
#include "qstringmatcher.h"
#include "qvarlengtharray.h"
#include "qtools_p.h"
-#include "qhash.h"
#include "qdebug.h"
#include "qendian.h"
#include "qcollator.h"
@@ -1828,6 +1827,51 @@ QString &QString::operator=(QChar ch)
/*!
+ \fn QString& QString::insert(int position, const QStringRef &str)
+ \since 5.5
+ \overload insert()
+
+ Inserts the string reference \a str at the given index \a position and
+ returns a reference to this string.
+
+ If the given \a position is greater than size(), the array is
+ first extended using resize().
+*/
+
+
+/*!
+ \fn QString& QString::insert(int position, const char *str)
+ \since 5.5
+ \overload insert()
+
+ Inserts the C string \a str at the given index \a position and
+ returns a reference to this string.
+
+ If the given \a position is greater than size(), the array is
+ first extended using resize().
+
+ This function is not available when QT_NO_CAST_FROM_ASCII is
+ defined.
+*/
+
+
+/*!
+ \fn QString& QString::insert(int position, const QByteArray &str)
+ \since 5.5
+ \overload insert()
+
+ Inserts the byte array \a str at the given index \a position and
+ returns a reference to this string.
+
+ If the given \a position is greater than size(), the array is
+ first extended using resize().
+
+ This function is not available when QT_NO_CAST_FROM_ASCII is
+ defined.
+*/
+
+
+/*!
\fn QString &QString::insert(int position, QLatin1String str)
\overload insert()
@@ -2027,6 +2071,22 @@ QString &QString::append(QChar ch)
Prepends the Latin-1 string \a str to this string.
*/
+/*! \fn QString &QString::prepend(const QChar *str, int len)
+ \since 5.5
+ \overload prepend()
+
+ Prepends \a len characters from the QChar array \a str to this string and
+ returns a reference to this string.
+*/
+
+/*! \fn QString &QString::prepend(const QStringRef &str)
+ \since 5.5
+ \overload prepend()
+
+ Prepends the string reference \a str to the beginning of this string and
+ returns a reference to this string.
+*/
+
/*! \fn QString &QString::prepend(const QByteArray &ba)
\overload prepend()
@@ -2659,9 +2719,9 @@ bool QString::operator<(QLatin1String other) const
go through QObject::tr(), for example.
*/
-/*! \fn bool QString::operator<=(const QString &s1, const QString &s2)
+/*! \fn bool operator<=(const QString &s1, const QString &s2)
- \relates Qstring
+ \relates QString
Returns \c true if string \a s1 is lexically less than or equal to
string \a s2; otherwise returns \c false.
@@ -2707,7 +2767,7 @@ bool QString::operator<(QLatin1String other) const
go through QObject::tr(), for example.
*/
-/*! \fn bool QString::operator>(const QString &s1, const QString &s2)
+/*! \fn bool operator>(const QString &s1, const QString &s2)
\relates QString
Returns \c true if string \a s1 is lexically greater than string \a s2;
@@ -3939,10 +3999,9 @@ int QString::count(const QRegularExpression &re) const
QString QString::section(const QString &sep, int start, int end, SectionFlags flags) const
{
- QStringList sections = split(sep, KeepEmptyParts,
- (flags & SectionCaseInsensitiveSeps) ? Qt::CaseInsensitive : Qt::CaseSensitive);
+ const QVector<QStringRef> sections = splitRef(sep, KeepEmptyParts,
+ (flags & SectionCaseInsensitiveSeps) ? Qt::CaseInsensitive : Qt::CaseSensitive);
const int sectionsSize = sections.size();
-
if (!(flags & SectionSkipEmpty)) {
if (start < 0)
start += sectionsSize;
@@ -3962,11 +4021,10 @@ QString QString::section(const QString &sep, int start, int end, SectionFlags fl
if (start >= sectionsSize || end < 0 || start > end)
return QString();
- int x = 0;
QString ret;
int first_i = start, last_i = end;
- for (int i = 0; x <= end && i < sectionsSize; ++i) {
- QString section = sections.at(i);
+ for (int x = 0, i = 0; x <= end && i < sectionsSize; ++i) {
+ const QStringRef &section = sections.at(i);
const bool empty = section.isEmpty();
if (x >= start) {
if(x == start)
@@ -3991,9 +4049,9 @@ QString QString::section(const QString &sep, int start, int end, SectionFlags fl
class qt_section_chunk {
public:
qt_section_chunk() {}
- qt_section_chunk(int l, QString s) : length(l), string(qMove(s)) {}
+ qt_section_chunk(int l, QStringRef s) : length(l), string(qMove(s)) {}
int length;
- QString string;
+ QStringRef string;
};
Q_DECLARE_TYPEINFO(qt_section_chunk, Q_MOVABLE_TYPE);
@@ -4086,12 +4144,12 @@ QString QString::section(const QRegExp &reg, int start, int end, SectionFlags fl
QVector<qt_section_chunk> sections;
int n = length(), m = 0, last_m = 0, last_len = 0;
while ((m = sep.indexIn(*this, m)) != -1) {
- sections.append(qt_section_chunk(last_len, QString(uc + last_m, m - last_m)));
+ sections.append(qt_section_chunk(last_len, QStringRef(this, last_m, m - last_m)));
last_m = m;
last_len = sep.matchedLength();
m += qMax(sep.matchedLength(), 1);
}
- sections.append(qt_section_chunk(last_len, QString(uc + last_m, n - last_m)));
+ sections.append(qt_section_chunk(last_len, QStringRef(this, last_m, n - last_m)));
return extractSections(sections, start, end, flags);
}
@@ -4134,11 +4192,11 @@ QString QString::section(const QRegularExpression &re, int start, int end, Secti
while (iterator.hasNext()) {
QRegularExpressionMatch match = iterator.next();
m = match.capturedStart();
- sections.append(qt_section_chunk(last_len, QString(uc + last_m, m - last_m)));
+ sections.append(qt_section_chunk(last_len, QStringRef(this, last_m, m - last_m)));
last_m = m;
last_len = match.capturedLength();
}
- sections.append(qt_section_chunk(last_len, QString(uc + last_m, n - last_m)));
+ sections.append(qt_section_chunk(last_len, QStringRef(this, last_m, n - last_m)));
return extractSections(sections, start, end, flags);
}
@@ -4822,7 +4880,7 @@ modifiable reference.
If \a position is negative, it is equivalent to passing zero.
- \sa chop(), resize(), left()
+ \sa chop(), resize(), left(), QStringRef::truncate()
*/
void QString::truncate(int pos)
@@ -7622,86 +7680,155 @@ static int getEscape(const QChar *uc, int *pos, int len, int maxNumber = 999)
return -1;
}
+/*
+ Algorithm for multiArg:
+
+ 1. Parse the string as a sequence of verbatim text and placeholders (%L?\d{,3}).
+ The L is parsed and accepted for compatibility with non-multi-arg, but since
+ multiArg only accepts strings as replacements, the localization request can
+ be safely ignored.
+ 2. The result of step (1) is a list of (string-ref,int)-tuples. The string-ref
+ either points at text to be copied verbatim (in which case the int is -1),
+ or, initially, at the textual representation of the placeholder. In that case,
+ the int contains the numerical number as parsed from the placeholder.
+ 3. Next, collect all the non-negative ints found, sort them in ascending order and
+ remove duplicates.
+ 3a. If the result has more entires than multiArg() was given replacement strings,
+ we have found placeholders we can't satisfy with replacement strings. That is
+ fine (there could be another .arg() call coming after this one), so just
+ truncate the result to the number of actual multiArg() replacement strings.
+ 3b. If the result has less entries than multiArg() was given replacement strings,
+ the string is missing placeholders. This is an error that the user should be
+ warned about.
+ 4. The result of step (3) is a mapping from the index of any replacement string to
+ placeholder number. This is the wrong way around, but since placeholder
+ numbers could get as large as 999, while we typically don't have more than 9
+ replacement strings, we trade 4K of sparsely-used memory for doing a reverse lookup
+ each time we need to map a placeholder number to a replacement string index
+ (that's a linear search; but still *much* faster than using an associative container).
+ 5. Next, for each of the tuples found in step (1), do the following:
+ 5a. If the int is negative, do nothing.
+ 5b. Otherwise, if the int is found in the result of step (3) at index I, replace
+ the string-ref with a string-ref for the (complete) I'th replacement string.
+ 5c. Otherwise, do nothing.
+ 6. Concatenate all string refs into a single result string.
+*/
+
namespace {
-class ArgMapper {
- QVarLengthArray<int, 16> argPosToNumberMap; // maps from argument position to number
-public:
- void found(int n) { argPosToNumberMap.push_back(n); }
+struct Part
+{
+ Part() : stringRef(), number(0) {}
+ Part(const QString &s, int pos, int len, int num = -1) Q_DECL_NOTHROW
+ : stringRef(&s, pos, len), number(num) {}
- struct AssignmentResult {
- int numArgs;
- int lastNumber;
- };
+ QStringRef stringRef;
+ int number;
+};
+} // unnamed namespace
- AssignmentResult assignArgumentNumberToEachOfTheNs(int numArgs)
- {
- std::sort(argPosToNumberMap.begin(), argPosToNumberMap.end());
- argPosToNumberMap.erase(std::unique(argPosToNumberMap.begin(), argPosToNumberMap.end()),
- argPosToNumberMap.end());
+template <>
+class QTypeInfo<Part> : public QTypeInfoMerger<Part, QStringRef, int> {}; // Q_DECLARE_METATYPE
- if (argPosToNumberMap.size() > numArgs)
- argPosToNumberMap.resize(numArgs);
- int lastNumber = argPosToNumberMap.empty() ? -1 : argPosToNumberMap.back();
- int arg = argPosToNumberMap.size();
+namespace {
- const AssignmentResult result = {arg, lastNumber};
- return result;
- }
+enum { ExpectedParts = 32 };
- int numberToArgsIndex(int number) const
- {
- if (number != -1) {
- const int * const it = std::find(argPosToNumberMap.begin(), argPosToNumberMap.end(), number);
- return it == argPosToNumberMap.end() ? -1 : it - argPosToNumberMap.begin();
- } else {
- return -1;
- }
- }
-};
-} // unnamed namespace
+typedef QVarLengthArray<Part, ExpectedParts> ParseResult;
+typedef QVarLengthArray<int, ExpectedParts/2> ArgIndexToPlaceholderMap;
-QString QString::multiArg(int numArgs, const QString **args) const
+static ParseResult parseMultiArgFormatString(const QString &s)
{
- QString result;
- ArgMapper mapper;
- const QChar *uc = (const QChar *) d->data();
- const int len = d->size;
+ ParseResult result;
+
+ const QChar *uc = s.constData();
+ const int len = s.size();
const int end = len - 1;
int i = 0;
+ int last = 0;
- // populate the arg-mapper with the %n's that actually occur in the string
while (i < end) {
if (uc[i] == QLatin1Char('%')) {
+ int percent = i;
int number = getEscape(uc, &i, len);
if (number != -1) {
- mapper.found(number);
+ if (last != percent)
+ result.push_back(Part(s, last, percent - last)); // literal text (incl. failed placeholders)
+ result.push_back(Part(s, percent, i - percent, number)); // parsed placeholder
+ last = i;
continue;
}
}
++i;
}
- const ArgMapper::AssignmentResult r = mapper.assignArgumentNumberToEachOfTheNs(numArgs);
+ if (last < len)
+ result.push_back(Part(s, last, len - last)); // trailing literal text
- // sanity
- if (numArgs > r.numArgs) {
- qWarning("QString::arg: %d argument(s) missing in %s", numArgs - r.numArgs, toLocal8Bit().data());
- numArgs = r.numArgs;
+ return result;
+}
+
+static ArgIndexToPlaceholderMap makeArgIndexToPlaceholderMap(const ParseResult &parts)
+{
+ ArgIndexToPlaceholderMap result;
+
+ for (ParseResult::const_iterator it = parts.begin(), end = parts.end(); it != end; ++it) {
+ if (it->number >= 0)
+ result.push_back(it->number);
}
- i = 0;
- while (i < len) {
- if (uc[i] == QLatin1Char('%') && i != end) {
- int number = getEscape(uc, &i, len, r.lastNumber);
- int arg = mapper.numberToArgsIndex(number);
- if (number != -1 && arg != -1) {
- result += *args[arg];
- continue;
- }
+ std::sort(result.begin(), result.end());
+ result.erase(std::unique(result.begin(), result.end()),
+ result.end());
+
+ return result;
+}
+
+static int resolveStringRefsAndReturnTotalSize(ParseResult &parts, const ArgIndexToPlaceholderMap &argIndexToPlaceholderMap, const QString *args[])
+{
+ int totalSize = 0;
+ for (ParseResult::iterator pit = parts.begin(), end = parts.end(); pit != end; ++pit) {
+ if (pit->number != -1) {
+ const ArgIndexToPlaceholderMap::const_iterator ait
+ = std::find(argIndexToPlaceholderMap.begin(), argIndexToPlaceholderMap.end(), pit->number);
+ if (ait != argIndexToPlaceholderMap.end())
+ pit->stringRef = QStringRef(args[ait - argIndexToPlaceholderMap.begin()]);
}
- result += uc[i++];
+ totalSize += pit->stringRef.size();
}
+ return totalSize;
+}
+
+} // unnamed namespace
+
+QString QString::multiArg(int numArgs, const QString **args) const
+{
+ // Step 1-2 above
+ ParseResult parts = parseMultiArgFormatString(*this);
+
+ // 3-4
+ ArgIndexToPlaceholderMap argIndexToPlaceholderMap = makeArgIndexToPlaceholderMap(parts);
+
+ if (argIndexToPlaceholderMap.size() > numArgs) // 3a
+ argIndexToPlaceholderMap.resize(numArgs);
+ else if (argIndexToPlaceholderMap.size() < numArgs) // 3b
+ qWarning("QString::arg: %d argument(s) missing in %s",
+ numArgs - argIndexToPlaceholderMap.size(), toLocal8Bit().data());
+
+ // 5
+ const int totalSize = resolveStringRefsAndReturnTotalSize(parts, argIndexToPlaceholderMap, args);
+
+ // 6:
+ QString result(totalSize, Qt::Uninitialized);
+ QChar *out = result.data();
+
+ for (ParseResult::const_iterator it = parts.begin(), end = parts.end(); it != end; ++it) {
+ if (const int sz = it->stringRef.size()) {
+ memcpy(out, it->stringRef.constData(), sz * sizeof(QChar));
+ out += sz;
+ }
+ }
+
return result;
}
@@ -9268,6 +9395,20 @@ QStringRef QString::midRef(int position, int n) const
}
/*!
+ \fn void QStringRef::truncate(int position)
+ \since 5.6
+
+ Truncates the string at the given \a position index.
+
+ If the specified \a position index is beyond the end of the
+ string, nothing happens.
+
+ If \a position is negative, it is equivalent to passing zero.
+
+ \sa QString::truncate()
+*/
+
+/*!
\since 4.8
Returns the index position of the first occurrence of the string \a
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 63107ff688..c084433d51 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -84,7 +84,7 @@ class QLatin1String
public:
Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) : m_size(s ? int(strlen(s)) : 0), m_data(s) {}
Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s, int sz) : m_size(sz), m_data(s) {}
- inline explicit QLatin1String(const QByteArray &s) : m_size(int(qstrnlen(s.constData(), s.size()))), m_data(s.constData()) {}
+ inline explicit QLatin1String(const QByteArray &s) : m_size(s.size()), m_data(s.constData()) {}
inline const char *latin1() const { return m_data; }
inline int size() const { return m_size; }
@@ -420,6 +420,7 @@ public:
QString &insert(int i, QChar c);
QString &insert(int i, const QChar *uc, int len);
inline QString &insert(int i, const QString &s) { return insert(i, s.constData(), s.length()); }
+ inline QString &insert(int i, const QStringRef &s);
QString &insert(int i, QLatin1String s);
QString &append(QChar c);
QString &append(const QChar *uc, int len);
@@ -427,7 +428,9 @@ public:
QString &append(const QStringRef &s);
QString &append(QLatin1String s);
inline QString &prepend(QChar c) { return insert(0, c); }
+ inline QString &prepend(const QChar *uc, int len) { return insert(0, uc, len); }
inline QString &prepend(const QString &s) { return insert(0, s); }
+ inline QString &prepend(const QStringRef &s) { return insert(0, s); }
inline QString &prepend(QLatin1String s) { return insert(0, s); }
inline QString &operator+=(QChar c) {
@@ -534,11 +537,11 @@ public:
return fromLocal8Bit_helper(str, (str && size == -1) ? int(strlen(str)) : size);
}
static inline QString fromLatin1(const QByteArray &str)
- { return fromLatin1(str.data(), qstrnlen(str.constData(), str.size())); }
+ { return str.isNull() ? QString() : fromLatin1(str.data(), str.size()); }
static inline QString fromUtf8(const QByteArray &str)
- { return fromUtf8(str.data(), qstrnlen(str.constData(), str.size())); }
+ { return str.isNull() ? QString() : fromUtf8(str.data(), str.size()); }
static inline QString fromLocal8Bit(const QByteArray &str)
- { return fromLocal8Bit(str.data(), qstrnlen(str.constData(), str.size())); }
+ { return str.isNull() ? QString() : fromLocal8Bit(str.data(), str.size()); }
static QString fromUtf16(const ushort *, int size = -1);
static QString fromUcs4(const uint *, int size = -1);
static QString fromRawData(const QChar *, int size);
@@ -591,16 +594,16 @@ public:
static int localeAwareCompare(const QString& s1, const QStringRef& s2);
// ### Qt6: make inline except for the long long versions
- short toShort(bool *ok=0, int base=10) const;
- ushort toUShort(bool *ok=0, int base=10) const;
- int toInt(bool *ok=0, int base=10) const;
- uint toUInt(bool *ok=0, int base=10) const;
- long toLong(bool *ok=0, int base=10) const;
- ulong toULong(bool *ok=0, int base=10) const;
- qlonglong toLongLong(bool *ok=0, int base=10) const;
- qulonglong toULongLong(bool *ok=0, int base=10) const;
- float toFloat(bool *ok=0) const;
- double toDouble(bool *ok=0) const;
+ short toShort(bool *ok=Q_NULLPTR, int base=10) const;
+ ushort toUShort(bool *ok=Q_NULLPTR, int base=10) const;
+ int toInt(bool *ok=Q_NULLPTR, int base=10) const;
+ uint toUInt(bool *ok=Q_NULLPTR, int base=10) const;
+ long toLong(bool *ok=Q_NULLPTR, int base=10) const;
+ ulong toULong(bool *ok=Q_NULLPTR, int base=10) const;
+ qlonglong toLongLong(bool *ok=Q_NULLPTR, int base=10) const;
+ qulonglong toULongLong(bool *ok=Q_NULLPTR, int base=10) const;
+ float toFloat(bool *ok=Q_NULLPTR) const;
+ double toDouble(bool *ok=Q_NULLPTR) const;
QString &setNum(short, int base=10);
QString &setNum(ushort, int base=10);
@@ -650,7 +653,7 @@ public:
: d(fromAscii_helper(ch, ch ? int(strlen(ch)) : -1))
{}
inline QT_ASCII_CAST_WARN QString(const QByteArray &a)
- : d(fromAscii_helper(a.constData(), qstrnlen(a.constData(), a.size())))
+ : d(fromAscii_helper(a.constData(), a.size()))
{}
inline QT_ASCII_CAST_WARN QString &operator=(const char *ch)
{ return (*this = fromUtf8(ch)); }
@@ -668,6 +671,10 @@ public:
{ return append(QString::fromUtf8(s)); }
inline QT_ASCII_CAST_WARN QString &append(const QByteArray &s)
{ return append(QString::fromUtf8(s)); }
+ inline QT_ASCII_CAST_WARN QString &insert(int i, const char *s)
+ { return insert(i, QString::fromUtf8(s)); }
+ inline QT_ASCII_CAST_WARN QString &insert(int i, const QByteArray &s)
+ { return insert(i, QString::fromUtf8(s)); }
inline QT_ASCII_CAST_WARN QString &operator+=(const char *s)
{ return append(QString::fromUtf8(s)); }
inline QT_ASCII_CAST_WARN QString &operator+=(const QByteArray &s)
@@ -1211,30 +1218,30 @@ inline QT_ASCII_CAST_WARN bool QLatin1String::operator>=(const QByteArray &s) co
{ return QString::fromUtf8(s) <= *this; }
inline QT_ASCII_CAST_WARN bool QString::operator==(const QByteArray &s) const
-{ return QString::compare_helper(constData(), size(), s.constData(), qstrnlen(s.constData(), s.size())) == 0; }
+{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) == 0; }
inline QT_ASCII_CAST_WARN bool QString::operator!=(const QByteArray &s) const
-{ return QString::compare_helper(constData(), size(), s.constData(), qstrnlen(s.constData(), s.size())) != 0; }
+{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) != 0; }
inline QT_ASCII_CAST_WARN bool QString::operator<(const QByteArray &s) const
-{ return QString::compare_helper(constData(), size(), s.constData(), qstrnlen(s.constData(), s.size())) < 0; }
+{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) < 0; }
inline QT_ASCII_CAST_WARN bool QString::operator>(const QByteArray &s) const
-{ return QString::compare_helper(constData(), size(), s.constData(), qstrnlen(s.constData(), s.size())) > 0; }
+{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) > 0; }
inline QT_ASCII_CAST_WARN bool QString::operator<=(const QByteArray &s) const
-{ return QString::compare_helper(constData(), size(), s.constData(), qstrnlen(s.constData(), s.size())) <= 0; }
+{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) <= 0; }
inline QT_ASCII_CAST_WARN bool QString::operator>=(const QByteArray &s) const
-{ return QString::compare_helper(constData(), size(), s.constData(), qstrnlen(s.constData(), s.size())) >= 0; }
+{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) >= 0; }
inline bool QByteArray::operator==(const QString &s) const
-{ return QString::compare_helper(s.constData(), s.size(), constData(), qstrnlen(constData(), size())) == 0; }
+{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) == 0; }
inline bool QByteArray::operator!=(const QString &s) const
-{ return QString::compare_helper(s.constData(), s.size(), constData(), qstrnlen(constData(), size())) != 0; }
+{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) != 0; }
inline bool QByteArray::operator<(const QString &s) const
-{ return QString::compare_helper(s.constData(), s.size(), constData(), qstrnlen(constData(), size())) < 0; }
+{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) < 0; }
inline bool QByteArray::operator>(const QString &s) const
-{ return QString::compare_helper(s.constData(), s.size(), constData(), qstrnlen(constData(), size())) > 0; }
+{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) > 0; }
inline bool QByteArray::operator<=(const QString &s) const
-{ return QString::compare_helper(s.constData(), s.size(), constData(), qstrnlen(constData(), size())) <= 0; }
+{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) <= 0; }
inline bool QByteArray::operator>=(const QString &s) const
-{ return QString::compare_helper(s.constData(), s.size(), constData(), qstrnlen(constData(), size())) >= 0; }
+{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) >= 0; }
#endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
#ifndef QT_NO_CAST_TO_ASCII
@@ -1343,7 +1350,7 @@ public:
typedef QString::const_reference const_reference;
// ### Qt 6: make this constructor constexpr, after the destructor is made trivial
- inline QStringRef():m_string(0), m_position(0), m_size(0){}
+ inline QStringRef() : m_string(Q_NULLPTR), m_position(0), m_size(0) {}
inline QStringRef(const QString *string, int position, int size);
inline QStringRef(const QString *string);
@@ -1392,6 +1399,8 @@ public:
QStringRef right(int n) const Q_REQUIRED_RESULT;
QStringRef mid(int pos, int n = -1) const Q_REQUIRED_RESULT;
+ void truncate(int pos) Q_DECL_NOTHROW { m_size = qBound(0, pos, m_size); }
+
bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@@ -1425,10 +1434,10 @@ public:
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT;
QVector<uint> toUcs4() const Q_REQUIRED_RESULT;
- inline void clear() { m_string = 0; m_position = m_size = 0; }
+ inline void clear() { m_string = Q_NULLPTR; m_position = m_size = 0; }
QString toString() const;
inline bool isEmpty() const { return m_size == 0; }
- inline bool isNull() const { return m_string == 0 || m_string->isNull(); }
+ inline bool isNull() const { return m_string == Q_NULLPTR || m_string->isNull(); }
QStringRef appendTo(QString *string) const;
@@ -1461,16 +1470,16 @@ public:
static int localeAwareCompare(const QStringRef &s1, const QStringRef &s2);
QStringRef trimmed() const Q_REQUIRED_RESULT;
- short toShort(bool *ok = 0, int base = 10) const;
- ushort toUShort(bool *ok = 0, int base = 10) const;
- int toInt(bool *ok = 0, int base = 10) const;
- uint toUInt(bool *ok = 0, int base = 10) const;
- long toLong(bool *ok = 0, int base = 10) const;
- ulong toULong(bool *ok = 0, int base = 10) const;
- qlonglong toLongLong(bool *ok = 0, int base = 10) const;
- qulonglong toULongLong(bool *ok = 0, int base = 10) const;
- float toFloat(bool *ok = 0) const;
- double toDouble(bool *ok = 0) const;
+ short toShort(bool *ok = Q_NULLPTR, int base = 10) const;
+ ushort toUShort(bool *ok = Q_NULLPTR, int base = 10) const;
+ int toInt(bool *ok = Q_NULLPTR, int base = 10) const;
+ uint toUInt(bool *ok = Q_NULLPTR, int base = 10) const;
+ long toLong(bool *ok = Q_NULLPTR, int base = 10) const;
+ ulong toULong(bool *ok = Q_NULLPTR, int base = 10) const;
+ qlonglong toLongLong(bool *ok = Q_NULLPTR, int base = 10) const;
+ qulonglong toULongLong(bool *ok = Q_NULLPTR, int base = 10) const;
+ float toFloat(bool *ok = Q_NULLPTR) const;
+ double toDouble(bool *ok = Q_NULLPTR) const;
};
Q_DECLARE_TYPEINFO(QStringRef, Q_PRIMITIVE_TYPE);
@@ -1576,6 +1585,9 @@ inline bool QStringRef::contains(QChar c, Qt::CaseSensitivity cs) const
inline bool QStringRef::contains(const QStringRef &s, Qt::CaseSensitivity cs) const
{ return indexOf(s, 0, cs) != -1; }
+inline QString &QString::insert(int i, const QStringRef &s)
+{ return insert(i, s.constData(), s.length()); }
+
namespace Qt {
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED inline QString escape(const QString &plain) {
diff --git a/src/corelib/tools/qtextboundaryfinder.h b/src/corelib/tools/qtextboundaryfinder.h
index beec5de607..a79fb50dad 100644
--- a/src/corelib/tools/qtextboundaryfinder.h
+++ b/src/corelib/tools/qtextboundaryfinder.h
@@ -68,7 +68,7 @@ public:
Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )
QTextBoundaryFinder(BoundaryType type, const QString &string);
- QTextBoundaryFinder(BoundaryType type, const QChar *chars, int length, unsigned char *buffer = 0, int bufferSize = 0);
+ QTextBoundaryFinder(BoundaryType type, const QChar *chars, int length, unsigned char *buffer = Q_NULLPTR, int bufferSize = 0);
inline bool isValid() const { return d; }
diff --git a/src/corelib/tools/qtimeline.h b/src/corelib/tools/qtimeline.h
index 21139b37a8..94e60dce45 100644
--- a/src/corelib/tools/qtimeline.h
+++ b/src/corelib/tools/qtimeline.h
@@ -70,7 +70,7 @@ public:
CosineCurve
};
- explicit QTimeLine(int duration = 1000, QObject *parent = 0);
+ explicit QTimeLine(int duration = 1000, QObject *parent = Q_NULLPTR);
virtual ~QTimeLine();
State state() const;
diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/tools/qtimezone.cpp
index 3627045a40..5cd594455c 100644
--- a/src/corelib/tools/qtimezone.cpp
+++ b/src/corelib/tools/qtimezone.cpp
@@ -764,6 +764,7 @@ QTimeZone::OffsetDataList QTimeZone::transitions(const QDateTime &fromDateTime,
if (hasTransitions()) {
QTimeZonePrivate::DataList plist = d->transitions(fromDateTime.toMSecsSinceEpoch(),
toDateTime.toMSecsSinceEpoch());
+ list.reserve(plist.count());
foreach (const QTimeZonePrivate::Data &pdata, plist)
list.append(d->toOffsetData(pdata));
}
diff --git a/src/corelib/tools/qtimezoneprivate.cpp b/src/corelib/tools/qtimezoneprivate.cpp
index 8e6a0a0578..5bc3610af0 100644
--- a/src/corelib/tools/qtimezoneprivate.cpp
+++ b/src/corelib/tools/qtimezoneprivate.cpp
@@ -700,6 +700,7 @@ QByteArray QUtcTimeZonePrivate::systemTimeZoneId() const
QList<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds() const
{
QList<QByteArray> result;
+ result.reserve(utcDataTableSize);
for (int i = 0; i < utcDataTableSize; ++i)
result << utcId(utcData(i));
std::sort(result.begin(), result.end()); // ### or already sorted??
diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp
index 29f0e17012..7c5e5bd2cf 100644
--- a/src/corelib/tools/qtimezoneprivate_tz.cpp
+++ b/src/corelib/tools/qtimezoneprivate_tz.cpp
@@ -630,6 +630,7 @@ void QTzTimeZonePrivate::init(const QByteArray &ianaId)
}
// Now for each transition time calculate our rule and save them
+ m_tranTimes.reserve(tranList.count());
foreach (const QTzTransition &tz_tran, tranList) {
QTzTransitionTime tran;
QTzTransitionRule rule;
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 90b54b7297..bb15d66439 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -45,6 +45,7 @@
#ifdef Q_COMPILER_INITIALIZER_LISTS
#include <initializer_list>
#endif
+#include <iterator>
QT_BEGIN_NAMESPACE
@@ -174,6 +175,8 @@ public:
typedef T* iterator;
typedef const T* const_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
inline iterator begin() { return ptr; }
inline const_iterator begin() const { return ptr; }
@@ -183,6 +186,12 @@ public:
inline const_iterator end() const { return ptr + s; }
inline const_iterator cend() const { return ptr + s; }
inline const_iterator constEnd() const { return ptr + s; }
+ reverse_iterator rbegin() { return reverse_iterator(end()); }
+ reverse_iterator rend() { return reverse_iterator(begin()); }
+ const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
+ const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
+ const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); }
+ const_reverse_iterator crend() const { return const_reverse_iterator(begin()); }
iterator insert(const_iterator before, int n, const T &x);
inline iterator insert(const_iterator before, const T &x) { return insert(before, 1, x); }
iterator erase(const_iterator begin, const_iterator end);
@@ -489,6 +498,36 @@ bool operator!=(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T,
return !(l == r);
}
+template <typename T, int Prealloc1, int Prealloc2>
+bool operator<(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(),
+ rhs.begin(), rhs.end())))
+{
+ return std::lexicographical_compare(lhs.begin(), lhs.end(),
+ rhs.begin(), rhs.end());
+}
+
+template <typename T, int Prealloc1, int Prealloc2>
+inline bool operator>(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs))
+{
+ return rhs < lhs;
+}
+
+template <typename T, int Prealloc1, int Prealloc2>
+inline bool operator<=(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs))
+{
+ return !(lhs > rhs);
+}
+
+template <typename T, int Prealloc1, int Prealloc2>
+inline bool operator>=(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs))
+{
+ return !(lhs < rhs);
+}
+
QT_END_NAMESPACE
#endif // QVARLENGTHARRAY_H
diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc
index a2d4c55f7a..2b7f9c5241 100644
--- a/src/corelib/tools/qvarlengtharray.qdoc
+++ b/src/corelib/tools/qvarlengtharray.qdoc
@@ -468,6 +468,20 @@
Typedef for T *. Provided for STL compatibility.
*/
+/*!
+ \typedef QVarLengthArray::const_reverse_iterator
+ \since 5.6
+
+ Typedef for \c{std::reverse_iterator<const T*>}. Provided for STL compatibility.
+*/
+
+/*!
+ \typedef QVarLengthArray::reverse_iterator
+ \since 5.6
+
+ Typedef for \c{std::reverse_iterator<T*>}. Provided for STL compatibility.
+*/
+
/*! \fn void QVarLengthArray::prepend(const T &value)
\since 4.8
@@ -582,6 +596,52 @@
\sa constBegin(), end()
*/
+/*! \fn QVarLengthArray::reverse_iterator QVarLengthArray::rbegin()
+ \since 5.6
+
+ Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
+ item in the variable length array, in reverse order.
+
+ \sa begin(), crbegin(), rend()
+*/
+
+/*! \fn QVarLengthArray::const_reverse_iterator QVarLengthArray::rbegin() const
+ \since 5.6
+ \overload
+*/
+
+/*! \fn QVarLengthArray::const_reverse_iterator QVarLengthArray::crbegin() const
+ \since 5.6
+
+ Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
+ item in the variable length array, in reverse order.
+
+ \sa begin(), rbegin(), rend()
+*/
+
+/*! \fn QVarLengthArray::reverse_iterator QVarLengthArray::rend()
+ \since 5.6
+
+ Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past
+ the last item in the variable length array, in reverse order.
+
+ \sa end(), crend(), rbegin()
+*/
+
+/*! \fn QVarLengthArray::const_reverse_iterator QVarLengthArray::rend() const
+ \since 5.6
+ \overload
+*/
+
+/*! \fn QVarLengthArray::const_reverse_iterator QVarLengthArray::crend() const
+ \since 5.6
+
+ Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one
+ past the last item in the variable length array, in reverse order.
+
+ \sa end(), rend(), rbegin()
+*/
+
/*! \fn QVarLengthArray::iterator QVarLengthArray::erase(const_iterator pos)
\since 4.8
@@ -676,6 +736,54 @@
\sa operator==()
*/
+/*! \fn bool operator<(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs)
+ \since 5.6
+ \relates QVarLengthArray
+
+ Returns \c true if variable length array \a lhs is
+ \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
+ {lexicographically less than} \a rhs; otherwise returns \c false.
+
+ This function requires the value type to have an implementation
+ of \c operator<().
+*/
+
+/*! \fn bool operator<=(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs)
+ \since 5.6
+ \relates QVarLengthArray
+
+ Returns \c true if variable length array \a lhs is
+ \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
+ {lexicographically less than or equal to} \a rhs; otherwise returns \c false.
+
+ This function requires the value type to have an implementation
+ of \c operator<().
+*/
+
+/*! \fn bool operator>(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs)
+ \since 5.6
+ \relates QVarLengthArray
+
+ Returns \c true if variable length array \a lhs is
+ \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
+ {lexicographically greater than} \a rhs; otherwise returns \c false.
+
+ This function requires the value type to have an implementation
+ of \c operator<().
+*/
+
+/*! \fn bool operator>=(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs)
+ \since 5.6
+ \relates QVarLengthArray
+
+ Returns \c true if variable length array \a lhs is
+ \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
+ {lexicographically greater than or equal to} \a rhs; otherwise returns \c false.
+
+ This function requires the value type to have an implementation
+ of \c operator<().
+*/
+
/*! \fn QVarLengthArray &QVarLengthArray::operator<<(const T &value)
\since 4.8
diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp
index d10f82fbb4..77afe9d00e 100644
--- a/src/corelib/tools/qvector.cpp
+++ b/src/corelib/tools/qvector.cpp
@@ -290,6 +290,65 @@
\sa operator==()
*/
+/*! \fn bool operator<(const QVector<T> &lhs, const QVector<T> &rhs)
+ \since 5.6
+ \relates QVector
+
+ Returns \c true if vector \a lhs is
+ \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
+ {lexicographically less than} \a rhs; otherwise returns \c false.
+
+ This function requires the value type to have an implementation
+ of \c operator<().
+*/
+
+/*! \fn bool operator<=(const QVector<T> &lhs, const QVector<T> &rhs)
+ \since 5.6
+ \relates QVector
+
+ Returns \c true if vector \a lhs is
+ \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
+ {lexicographically less than or equal to} \a rhs; otherwise returns \c false.
+
+ This function requires the value type to have an implementation
+ of \c operator<().
+*/
+
+/*! \fn bool operator>(const QVector<T> &lhs, const QVector<T> &rhs)
+ \since 5.6
+ \relates QVector
+
+ Returns \c true if vector \a lhs is
+ \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
+ {lexicographically greater than} \a rhs; otherwise returns \c false.
+
+ This function requires the value type to have an implementation
+ of \c operator<().
+*/
+
+/*! \fn bool operator>=(const QVector<T> &lhs, const QVector<T> &rhs)
+ \since 5.6
+ \relates QVector
+
+ Returns \c true if vector \a lhs is
+ \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
+ {lexicographically greater than or equal to} \a rhs; otherwise returns \c false.
+
+ This function requires the value type to have an implementation
+ of \c operator<().
+*/
+
+/*!
+ \fn uint qHash(const QVector<T> &key, uint seed = 0)
+ \since 5.6
+ \relates QVector
+
+ Returns the hash value for \a key,
+ using \a seed to seed the calculation.
+
+ This function requires qHash() to be overloaded for the value type \c T.
+*/
+
/*! \fn int QVector::size() const
Returns the number of items in the vector.
@@ -629,6 +688,16 @@
\sa takeFirst(), takeLast(), QList::takeAt()
*/
+/*! \fn void QVector::move(int from, int to)
+ \since 5.6
+
+ Moves the item at index position \a from to index position \a to.
+
+ Provided for compatibility with QList.
+
+ \sa QList::move()
+*/
+
/*! \fn void QVector::removeFirst()
\since 5.1
Removes the first item in the vector. Calling this function is
@@ -823,6 +892,52 @@
\sa constBegin(), end()
*/
+/*! \fn QVector::reverse_iterator QVector::rbegin()
+ \since 5.6
+
+ Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
+ item in the vector, in reverse order.
+
+ \sa begin(), crbegin(), rend()
+*/
+
+/*! \fn QVector::const_reverse_iterator QVector::rbegin() const
+ \since 5.6
+ \overload
+*/
+
+/*! \fn QVector::const_reverse_iterator QVector::crbegin() const
+ \since 5.6
+
+ Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
+ item in the vector, in reverse order.
+
+ \sa begin(), rbegin(), rend()
+*/
+
+/*! \fn QVector::reverse_iterator QVector::rend()
+ \since 5.6
+
+ Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past
+ the last item in the vector, in reverse order.
+
+ \sa end(), crend(), rbegin()
+*/
+
+/*! \fn QVector::const_reverse_iterator QVector::rend() const
+ \since 5.6
+ \overload
+*/
+
+/*! \fn QVector::const_reverse_iterator QVector::crend() const
+ \since 5.6
+
+ Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one
+ past the last item in the vector, in reverse order.
+
+ \sa end(), rend(), rbegin()
+*/
+
/*! \fn QVector::iterator QVector::erase(iterator pos)
Removes the item pointed to by the iterator \a pos from the
@@ -846,7 +961,7 @@
Returns a reference to the first item in the vector. This
function assumes that the vector isn't empty.
- \sa last(), isEmpty()
+ \sa last(), isEmpty(), constFirst()
*/
/*! \fn const T& QVector::first() const
@@ -854,12 +969,21 @@
\overload
*/
+/*! \fn const T& QVector::constFirst() const
+ \since 5.6
+
+ Returns a const reference to the first item in the vector. This
+ function assumes that the vector isn't empty.
+
+ \sa constLast(), isEmpty(), first()
+*/
+
/*! \fn T& QVector::last()
Returns a reference to the last item in the vector. This function
assumes that the vector isn't empty.
- \sa first(), isEmpty()
+ \sa first(), isEmpty(), constLast()
*/
/*! \fn const T& QVector::last() const
@@ -867,6 +991,15 @@
\overload
*/
+/*! \fn const T& QVector::constLast() const
+ \since 5.6
+
+ Returns a const reference to the last item in the vector. This function
+ assumes that the vector isn't empty.
+
+ \sa constFirst(), isEmpty(), last()
+*/
+
/*! \fn T QVector::value(int i) const
Returns the value at index position \a i in the vector.
@@ -1013,6 +1146,38 @@
\sa QVector::constBegin(), QVector::constEnd(), QVector::iterator, QVectorIterator
*/
+/*! \typedef QVector::reverse_iterator
+ \since 5.6
+
+ The QVector::reverse_iterator typedef provides an STL-style non-const
+ reverse iterator for QVector.
+
+ It is simply a typedef for \c{std::reverse_iterator<T*>}.
+
+ \warning Iterators on implicitly shared containers do not work
+ exactly like STL-iterators. You should avoid copying a container
+ while iterators are active on that container. For more information,
+ read \l{Implicit sharing iterator problem}.
+
+ \sa QVector::rbegin(), QVector::rend(), QVector::const_reverse_iterator, QVector::iterator
+*/
+
+/*! \typedef QVector::const_reverse_iterator
+ \since 5.6
+
+ The QVector::const_reverse_iterator typedef provides an STL-style const
+ reverse iterator for QVector.
+
+ It is simply a typedef for \c{std::reverse_iterator<const T*>}.
+
+ \warning Iterators on implicitly shared containers do not work
+ exactly like STL-iterators. You should avoid copying a container
+ while iterators are active on that container. For more information,
+ read \l{Implicit sharing iterator problem}.
+
+ \sa QVector::rbegin(), QVector::rend(), QVector::reverse_iterator, QVector::const_iterator
+*/
+
/*! \typedef QVector::Iterator
Qt-style synonym for QVector::iterator.
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index eed5d17cad..821fc9b68a 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -39,6 +39,7 @@
#include <QtCore/qlist.h>
#include <QtCore/qrefcount.h>
#include <QtCore/qarraydata.h>
+#include <QtCore/qhashfunctions.h>
#include <iterator>
#include <vector>
@@ -68,11 +69,10 @@ public:
inline ~QVector() { if (!d->ref.deref()) freeData(d); }
QVector<T> &operator=(const QVector<T> &v);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QVector(QVector<T> &&other) : d(other.d) { other.d = Data::sharedNull(); }
- inline QVector<T> operator=(QVector<T> &&other)
- { qSwap(d, other.d); return *this; }
+ QVector(QVector<T> &&other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); }
+ QVector<T> operator=(QVector<T> &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- inline void swap(QVector<T> &other) { qSwap(d, other.d); }
+ void swap(QVector<T> &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
#ifdef Q_COMPILER_INITIALIZER_LISTS
inline QVector(std::initializer_list<T> args);
#endif
@@ -171,10 +171,25 @@ public:
}
int length() const { return size(); }
T takeAt(int i) { T t = at(i); remove(i); return t; }
+ void move(int from, int to)
+ {
+ Q_ASSERT_X(from >= 0 && from < size(), "QVector::move(int,int)", "'from' is out-of-range");
+ Q_ASSERT_X(to >= 0 && to < size(), "QVector::move(int,int)", "'to' is out-of-range");
+ if (from == to) // don't detach when no-op
+ return;
+ detach();
+ T * const b = d->begin();
+ if (from < to)
+ std::rotate(b + from, b + from + 1, b + to + 1);
+ else
+ std::rotate(b + to, b + from, b + from + 1);
+ }
// STL-style
typedef typename Data::iterator iterator;
typedef typename Data::const_iterator const_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
#if !defined(QT_STRICT_ITERATORS) || defined(Q_QDOC)
inline iterator begin() { detach(); return d->begin(); }
inline const_iterator begin() const { return d->constBegin(); }
@@ -194,6 +209,12 @@ public:
inline const_iterator cend(const_iterator = const_iterator()) const { return d->constEnd(); }
inline const_iterator constEnd(const_iterator = const_iterator()) const { return d->constEnd(); }
#endif
+ reverse_iterator rbegin() { return reverse_iterator(end()); }
+ reverse_iterator rend() { return reverse_iterator(begin()); }
+ const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
+ const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
+ const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); }
+ const_reverse_iterator crend() const { return const_reverse_iterator(begin()); }
iterator insert(iterator before, int n, const T &x);
inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); }
iterator erase(iterator begin, iterator end);
@@ -203,8 +224,10 @@ public:
inline int count() const { return d->size; }
inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); }
inline const T &first() const { Q_ASSERT(!isEmpty()); return *begin(); }
+ inline const T &constFirst() const { Q_ASSERT(!isEmpty()); return *begin(); }
inline T& last() { Q_ASSERT(!isEmpty()); return *(end()-1); }
inline const T &last() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
+ inline const T &constLast() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; }
inline bool endsWith(const T &t) const { return !isEmpty() && last() == t; }
QVector<T> mid(int pos, int len = -1) const;
@@ -265,7 +288,6 @@ private:
{
return (i <= d->end()) && (d->begin() <= i);
}
- iterator c2m(const_iterator it) { return begin() + (it - cbegin()); }
class AlignmentDummy { Data header; T array[1]; };
};
@@ -873,6 +895,43 @@ QList<T> QList<T>::fromVector(const QVector<T> &vector)
Q_DECLARE_SEQUENTIAL_ITERATOR(Vector)
Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(Vector)
+template <typename T>
+uint qHash(const QVector<T> &key, uint seed = 0)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHashRange(key.cbegin(), key.cend(), seed)))
+{
+ return qHashRange(key.cbegin(), key.cend(), seed);
+}
+
+template <typename T>
+bool operator<(const QVector<T> &lhs, const QVector<T> &rhs)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(),
+ rhs.begin(), rhs.end())))
+{
+ return std::lexicographical_compare(lhs.begin(), lhs.end(),
+ rhs.begin(), rhs.end());
+}
+
+template <typename T>
+inline bool operator>(const QVector<T> &lhs, const QVector<T> &rhs)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs))
+{
+ return rhs < lhs;
+}
+
+template <typename T>
+inline bool operator<=(const QVector<T> &lhs, const QVector<T> &rhs)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs))
+{
+ return !(lhs > rhs);
+}
+
+template <typename T>
+inline bool operator>=(const QVector<T> &lhs, const QVector<T> &rhs)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs))
+{
+ return !(lhs < rhs);
+}
+
/*
### Qt 5:
### This needs to be removed for next releases of Qt. It is a workaround for vc++ because
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 5de0c09a4d..60b53a3d8a 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -9,6 +9,7 @@ HEADERS += \
tools/qarraydatapointer.h \
tools/qbitarray.h \
tools/qbytearray.h \
+ tools/qbytearray_p.h \
tools/qbytearraylist.h \
tools/qbytearraymatcher.h \
tools/qbytedata_p.h \
@@ -26,6 +27,7 @@ HEADERS += \
tools/qeasingcurve.h \
tools/qfreelist_p.h \
tools/qhash.h \
+ tools/qhashfunctions.h \
tools/qiterator.h \
tools/qline.h \
tools/qlinkedlist.h \
@@ -105,6 +107,7 @@ SOURCES += \
tools/qrect.cpp \
tools/qregexp.cpp \
tools/qrefcount.cpp \
+ tools/qringbuffer.cpp \
tools/qshareddata.cpp \
tools/qsharedpointer.cpp \
tools/qsimd.cpp \
diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp
index b82d92b561..d178a37353 100644
--- a/src/dbus/qdbus_symbols.cpp
+++ b/src/dbus/qdbus_symbols.cpp
@@ -48,7 +48,7 @@ void (*qdbus_resolve_me(const char *name))();
#if !defined QT_LINKED_LIBDBUS
-#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_LIBRARY
static QLibrary *qdbus_libdbus = 0;
void qdbus_unloadLibDBus()
@@ -65,7 +65,7 @@ void qdbus_unloadLibDBus()
bool qdbus_loadLibDBus()
{
-#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_LIBRARY
#ifdef QT_BUILD_INTERNAL
// this is to simulate a library load failure for our autotest suite.
if (!qEnvironmentVariableIsEmpty("QT_SIMULATE_DBUS_LIBFAIL"))
@@ -118,7 +118,7 @@ bool qdbus_loadLibDBus()
#endif
}
-#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_LIBRARY
void (*qdbus_resolve_conditionally(const char *name))()
{
if (qdbus_loadLibDBus())
@@ -129,7 +129,7 @@ void (*qdbus_resolve_conditionally(const char *name))()
void (*qdbus_resolve_me(const char *name))()
{
-#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_LIBRARY
if (!qdbus_loadLibDBus())
qFatal("Cannot find libdbus-1 in your system to resolve symbol '%s'.", name);
@@ -153,7 +153,7 @@ static void qdbus_unloadLibDBus()
#endif // !QT_LINKED_LIBDBUS
-#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_LIBRARY
Q_DESTRUCTOR_FUNCTION(qdbus_unloadLibDBus)
#endif
diff --git a/src/dbus/qdbusabstractadaptor.cpp b/src/dbus/qdbusabstractadaptor.cpp
index e7529f794e..2864e076e9 100644
--- a/src/dbus/qdbusabstractadaptor.cpp
+++ b/src/dbus/qdbusabstractadaptor.cpp
@@ -317,7 +317,9 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **
}
QVariantList args;
- for (int i = 1; i < types.count(); ++i)
+ const int numTypes = types.count();
+ args.reserve(numTypes - 1);
+ for (int i = 1; i < numTypes; ++i)
args << QVariant(types.at(i), argv[i]);
// now emit the signal with all the information
diff --git a/src/dbus/qdbusabstractadaptor_p.h b/src/dbus/qdbusabstractadaptor_p.h
index 9e9375cefc..8fd158614f 100644
--- a/src/dbus/qdbusabstractadaptor_p.h
+++ b/src/dbus/qdbusabstractadaptor_p.h
@@ -50,7 +50,6 @@
#include <QtCore/qobject.h>
#include <QtCore/qmap.h>
-#include <QtCore/qhash.h>
#include <QtCore/qreadwritelock.h>
#include <QtCore/qvariant.h>
#include <QtCore/qvector.h>
diff --git a/src/dbus/qdbusextratypes.h b/src/dbus/qdbusextratypes.h
index 390ff6c91c..5032db08d0 100644
--- a/src/dbus/qdbusextratypes.h
+++ b/src/dbus/qdbusextratypes.h
@@ -39,7 +39,10 @@
#include <QtCore/qvariant.h>
#include <QtCore/qstring.h>
#include <QtDBus/qdbusmacros.h>
+#if QT_DEPRECATED_SINCE(5, 5)
#include <QtCore/qhash.h>
+#endif
+#include <QtCore/qhashfunctions.h>
#ifndef QT_NO_DBUS
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index cce8b9c28d..22c1a3e363 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -160,7 +160,7 @@ static dbus_bool_t qDBusAddTimeout(DBusTimeout *timeout, void *data)
static bool qDBusRealAddTimeout(QDBusConnectionPrivate *d, DBusTimeout *timeout, int ms)
{
- Q_ASSERT(d->timeouts.keys(timeout).isEmpty());
+ Q_ASSERT(d->timeouts.key(timeout, 0) == 0);
int timerId = d->startTimer(ms);
if (!timerId)
@@ -952,14 +952,19 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
}
// output arguments
+ const int numMetaTypes = metaTypes.count();
QVariantList outputArgs;
void *null = 0;
if (metaTypes[0] != QMetaType::Void && metaTypes[0] != QMetaType::UnknownType) {
+ outputArgs.reserve(numMetaTypes - i + 1);
QVariant arg(metaTypes[0], null);
outputArgs.append( arg );
params[0] = const_cast<void*>(outputArgs.at( outputArgs.count() - 1 ).constData());
+ } else {
+ outputArgs.reserve(numMetaTypes - i);
}
- for ( ; i < metaTypes.count(); ++i) {
+
+ for ( ; i < numMetaTypes; ++i) {
QVariant arg(metaTypes[i], null);
outputArgs.append( arg );
params.append(const_cast<void*>(outputArgs.at( outputArgs.count() - 1 ).constData()));
@@ -1730,7 +1735,7 @@ static QDBusConnection::ConnectionCapabilities connectionCapabilies(DBusConnecti
# if DBUS_VERSION-0 >= 0x010400
can_send_type = dbus_connection_can_send_type;
# endif
-#else
+#elif !defined(QT_NO_LIBRARY)
// run-time check if the next functions are available
can_send_type = (can_send_type_t)qdbus_resolve_conditionally("dbus_connection_can_send_type");
#endif
@@ -1898,7 +1903,8 @@ int QDBusConnectionPrivate::send(const QDBusMessage& message)
qPrintable(message.interface()), qPrintable(message.member()),
qPrintable(error.message()));
else if (message.type() == QDBusMessage::SignalMessage)
- qWarning("QDBusConnection: error: could not send signal path \"%s\" interface \"%s\" member \"%s\": %s",
+ qWarning("QDBusConnection: error: could not send signal to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s",
+ qPrintable(message.service()),
qPrintable(message.path()), qPrintable(message.interface()),
qPrintable(message.member()),
qPrintable(error.message()));
diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h
index 3e4f79c43c..cd358569df 100644
--- a/src/dbus/qdbusintegrator_p.h
+++ b/src/dbus/qdbusintegrator_p.h
@@ -50,7 +50,6 @@
#include "qcoreevent.h"
#include "qeventloop.h"
-#include "qhash.h"
#include "qobject.h"
#include "private/qobject_p.h"
#include "qlist.h"
diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp
index 1fc313d8cc..421fc0bdb6 100644
--- a/src/dbus/qdbusinterface.cpp
+++ b/src/dbus/qdbusinterface.cpp
@@ -278,6 +278,7 @@ int QDBusInterfacePrivate::metacall(QMetaObject::Call c, int id, void **argv)
// we will assume that the input arguments were passed correctly
QVariantList args;
+ args.reserve(inputTypesCount);
int i = 1;
for ( ; i <= inputTypesCount; ++i)
args << QVariant(inputTypes[i], argv[i]);
diff --git a/src/dbus/qdbusmacros.h b/src/dbus/qdbusmacros.h
index 1f774b0f08..2a1d0a22d7 100644
--- a/src/dbus/qdbusmacros.h
+++ b/src/dbus/qdbusmacros.h
@@ -45,7 +45,9 @@
#ifdef Q_CC_MSVC
#include <QtCore/qlist.h>
#include <QtCore/qset.h>
+#if QT_DEPRECATED_SINCE(5, 5)
#include <QtCore/qhash.h>
+#endif
#include <QtCore/qvector.h>
#endif
diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp
index b92e7f5cd7..302d94696d 100644
--- a/src/dbus/qdbusmessage.cpp
+++ b/src/dbus/qdbusmessage.cpp
@@ -153,8 +153,10 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB
}
break;
case QDBusMessage::SignalMessage:
- // nothing can be empty here
+ // only the service name can be empty here
if (!d_ptr->parametersValidated) {
+ if (!QDBusUtil::checkBusName(d_ptr->service, QDBusUtil::EmptyAllowed, error))
+ return 0;
if (!QDBusUtil::checkObjectPath(d_ptr->path, QDBusUtil::EmptyNotAllowed, error))
return 0;
if (!QDBusUtil::checkInterfaceName(d_ptr->interface, QDBusUtil::EmptyAllowed, error))
@@ -165,6 +167,7 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB
msg = q_dbus_message_new_signal(d_ptr->path.toUtf8(), d_ptr->interface.toUtf8(),
d_ptr->name.toUtf8());
+ q_dbus_message_set_destination(msg, data(d_ptr->service.toUtf8()));
break;
}
@@ -372,6 +375,31 @@ QDBusMessage QDBusMessage::createSignal(const QString &path, const QString &inte
}
/*!
+ \since 5.6
+
+ Constructs a new DBus message with the given \a path, \a interface
+ and \a name, representing a signal emission to \a destination.
+
+ A DBus signal is emitted from one application and is received only by
+ the application owning the destination service name.
+
+ The QDBusMessage object that is returned can be sent using the
+ QDBusConnection::send() function.
+*/
+QDBusMessage QDBusMessage::createTargetedSignal(const QString &service, const QString &path,
+ const QString &interface, const QString &name)
+{
+ QDBusMessage message;
+ message.d_ptr->type = SignalMessage;
+ message.d_ptr->service = service;
+ message.d_ptr->path = path;
+ message.d_ptr->interface = interface;
+ message.d_ptr->name = name;
+
+ return message;
+}
+
+/*!
Constructs a new DBus message representing a method call.
A method call always informs its destination address
(\a service, \a path, \a interface and \a method).
diff --git a/src/dbus/qdbusmessage.h b/src/dbus/qdbusmessage.h
index 77f34ec5e2..640226e77a 100644
--- a/src/dbus/qdbusmessage.h
+++ b/src/dbus/qdbusmessage.h
@@ -67,6 +67,8 @@ public:
static QDBusMessage createSignal(const QString &path, const QString &interface,
const QString &name);
+ static QDBusMessage createTargetedSignal(const QString &service, const QString &path,
+ const QString &interface, const QString &name);
static QDBusMessage createMethodCall(const QString &destination, const QString &path,
const QString &interface, const QString &method);
static QDBusMessage createError(const QString &name, const QString &msg);
diff --git a/src/dbus/qdbuspendingcall.h b/src/dbus/qdbuspendingcall.h
index 99d261d05b..8bca64cd9a 100644
--- a/src/dbus/qdbuspendingcall.h
+++ b/src/dbus/qdbuspendingcall.h
@@ -56,9 +56,12 @@ class Q_DBUS_EXPORT QDBusPendingCall
public:
QDBusPendingCall(const QDBusPendingCall &other);
~QDBusPendingCall();
+#ifdef Q_COMPILER_RVALUE_REFS
+ QDBusPendingCall &operator=(QDBusPendingCall &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QDBusPendingCall &operator=(const QDBusPendingCall &other);
- void swap(QDBusPendingCall &other) { qSwap(d, other.d); }
+ void swap(QDBusPendingCall &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
#ifndef Q_QDOC
// pretend that they aren't here
diff --git a/src/dbus/qdbusunixfiledescriptor.h b/src/dbus/qdbusunixfiledescriptor.h
index 35e9d87cf3..9fb6eb44c7 100644
--- a/src/dbus/qdbusunixfiledescriptor.h
+++ b/src/dbus/qdbusunixfiledescriptor.h
@@ -55,10 +55,13 @@ public:
QDBusUnixFileDescriptor();
explicit QDBusUnixFileDescriptor(int fileDescriptor);
QDBusUnixFileDescriptor(const QDBusUnixFileDescriptor &other);
+#if defined(Q_COMPILER_RVALUE_REFS)
+ QDBusUnixFileDescriptor &operator=(QDBusUnixFileDescriptor &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QDBusUnixFileDescriptor &operator=(const QDBusUnixFileDescriptor &other);
~QDBusUnixFileDescriptor();
- void swap(QDBusUnixFileDescriptor &other)
+ void swap(QDBusUnixFileDescriptor &other) Q_DECL_NOTHROW
{ qSwap(d, other.d); }
bool isValid() const;
@@ -71,11 +74,6 @@ public:
static bool isSupported();
-#if defined(Q_COMPILER_RVALUE_REFS)
- inline QDBusUnixFileDescriptor &operator=(QDBusUnixFileDescriptor &&other)
- { d.swap(other.d); return *this; }
-#endif
-
protected:
typedef QExplicitlySharedDataPointer<QDBusUnixFileDescriptorPrivate> Data;
Data d;
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index fce92b9511..dc6933f9ff 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -443,10 +443,11 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QAccessibleInterface::~QAccessibleInterface()
-
- Destroys the object.
+ Destroys the QAccessibleInterface.
*/
+QAccessibleInterface::~QAccessibleInterface()
+{
+}
/*!
\typedef QAccessible::Id
@@ -461,12 +462,12 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QAccessibleFactoryInterface_iid, QLatin1String("/accessible")))
+typedef QHash<QString, QAccessiblePlugin*> QAccessiblePluginsHash;
+Q_GLOBAL_STATIC(QAccessiblePluginsHash, qAccessiblePlugins)
#endif
// FIXME turn this into one global static struct
Q_GLOBAL_STATIC(QList<QAccessible::InterfaceFactory>, qAccessibleFactories)
-typedef QHash<QString, QAccessiblePlugin*> QAccessiblePluginsHash;
-Q_GLOBAL_STATIC(QAccessiblePluginsHash, qAccessiblePlugins)
Q_GLOBAL_STATIC(QList<QAccessible::ActivationObserver *>, qAccessibleActivationObservers)
QAccessible::UpdateHandler QAccessible::updateHandler = 0;
@@ -608,6 +609,11 @@ QAccessible::RootObjectHandler QAccessible::installRootObjectHandler(RootObjectH
\sa installActivationObserver()
*/
+QAccessible::ActivationObserver::~ActivationObserver()
+{
+ // must be empty until ### Qt 6
+}
+
/*!
\internal
@@ -1254,10 +1260,6 @@ QColor QAccessibleInterface::backgroundColor() const
return QColor();
}
-QAccessibleInterface::~QAccessibleInterface()
-{
-}
-
/*!
\fn QAccessibleTextInterface *QAccessibleInterface::textInterface()
*/
@@ -1329,9 +1331,13 @@ QAccessibleInterface::~QAccessibleInterface()
the overload taking a \l QObject parameter as it might be cheaper.
*/
-/*! \fn QAccessibleEvent::~QAccessibleEvent()
+/*!
Destroys the event.
*/
+QAccessibleEvent::~QAccessibleEvent()
+{
+ // must be empty until ### Qt 6
+}
/*! \fn QAccessible::Event QAccessibleEvent::type() const
Returns the event type.
@@ -1392,6 +1398,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
Returns the new value of the accessible object of this event.
*/
+/*!
+ \internal
+*/
+QAccessibleValueChangeEvent::~QAccessibleValueChangeEvent()
+{
+ // must be empty until ### Qt 6
+}
/*!
\class QAccessibleStateChangeEvent
@@ -1427,7 +1440,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
other hand tells about the change and has focused set to \c true since
the focus state is changed from \c true to \c false.
*/
-
+/*!
+ \internal
+*/
+QAccessibleStateChangeEvent::~QAccessibleStateChangeEvent()
+{
+ // must be empty until ### Qt 6
+}
/*!
\class QAccessibleTableModelChangeEvent
@@ -1484,6 +1503,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
/*! \fn void QAccessibleTableModelChangeEvent::setModelChangeType(ModelChangeType changeType)
Sets the type of change to \a changeType.
*/
+/*!
+ \internal
+*/
+QAccessibleTableModelChangeEvent::~QAccessibleTableModelChangeEvent()
+{
+ // must be empty until ### Qt 6
+}
/*!
@@ -1505,6 +1531,14 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
/*! \fn void QAccessibleTextCursorEvent::setCursorPosition(int position)
Sets the cursor \a position for this event.
*/
+/*!
+ \internal
+*/
+QAccessibleTextCursorEvent::~QAccessibleTextCursorEvent()
+{
+ // must be empty until ### Qt 6
+}
+
/*!
\class QAccessibleTextInsertEvent
@@ -1528,6 +1562,14 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
/*! \fn QString QAccessibleTextInsertEvent::textInserted() const
Returns the text that has been inserted.
*/
+/*!
+ \internal
+*/
+QAccessibleTextInsertEvent::~QAccessibleTextInsertEvent()
+{
+ // must be empty until ### Qt 6
+}
+
/*!
\class QAccessibleTextRemoveEvent
@@ -1552,6 +1594,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
/*! \fn QString QAccessibleTextRemoveEvent::textRemoved() const
Returns the text that has been removed.
*/
+/*!
+ \internal
+*/
+QAccessibleTextRemoveEvent::~QAccessibleTextRemoveEvent()
+{
+ // must be empty until ### Qt 6
+}
/*!
\class QAccessibleTextUpdateEvent
@@ -1578,6 +1627,14 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
/*! \fn QString QAccessibleTextUpdateEvent::textRemoved() const
Returns the removed text.
*/
+/*!
+ \internal
+*/
+QAccessibleTextUpdateEvent::~QAccessibleTextUpdateEvent()
+{
+ // must be empty until ### Qt 6
+}
+
/*!
\class QAccessibleTextSelectionEvent
@@ -1601,6 +1658,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
/*! \fn void QAccessibleTextSelectionEvent::setSelection(int start, int end)
Sets the selection for this event from position \a start to \a end.
*/
+/*!
+ \internal
+*/
+QAccessibleTextSelectionEvent::~QAccessibleTextSelectionEvent()
+{
+ // must be empty until ### Qt 6
+}
@@ -1839,9 +1903,12 @@ QDebug operator<<(QDebug d, const QAccessibleEvent &ev)
*/
/*!
- \fn QAccessibleTextInterface::~QAccessibleTextInterface()
Destroys the QAccessibleTextInterface.
*/
+QAccessibleTextInterface::~QAccessibleTextInterface()
+{
+ // must be empty until ### Qt 6
+}
/*!
\fn void QAccessibleTextInterface::addSelection(int startOffset, int endOffset)
@@ -2221,9 +2288,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun
*/
/*!
- \fn QAccessibleEditableTextInterface::~QAccessibleEditableTextInterface()
Destroys the QAccessibleEditableTextInterface.
*/
+QAccessibleEditableTextInterface::~QAccessibleEditableTextInterface()
+{
+ // must be empty until ### Qt 6
+}
/*!
\fn void QAccessibleEditableTextInterface::deleteText(int startOffset, int endOffset)
@@ -2262,9 +2332,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun
*/
/*!
- \fn QAccessibleValueInterface::~QAccessibleValueInterface()
- Destructor.
+ Destroys the QAccessibleValueInterface.
*/
+QAccessibleValueInterface::~QAccessibleValueInterface()
+{
+ // must be empty until ### Qt 6
+}
/*!
\fn QVariant QAccessibleValueInterface::currentValue() const
@@ -2323,6 +2396,14 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun
*/
/*!
+ Destroys the QAccessibleImageInterface.
+*/
+QAccessibleImageInterface::~QAccessibleImageInterface()
+{
+ // must be empty until ### Qt 6
+}
+
+/*!
\class QAccessibleTableCellInterface
\inmodule QtGui
\ingroup accessibility
@@ -2334,9 +2415,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun
*/
/*!
- \fn virtual QAccessibleTableCellInterface::~QAccessibleTableCellInterface()
Destroys the QAccessibleTableCellInterface.
*/
+QAccessibleTableCellInterface::~QAccessibleTableCellInterface()
+{
+ // must be empty until ### Qt 6
+}
/*!
\fn virtual int QAccessibleTableCellInterface::columnExtent() const
@@ -2390,9 +2474,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun
*/
/*!
- \fn virtual QAccessibleTableInterface::~QAccessibleTableInterface()
Destroys the QAccessibleTableInterface.
*/
+QAccessibleTableInterface::~QAccessibleTableInterface()
+{
+ // must be empty until ### Qt 6
+}
/*!
\fn virtual QAccessibleInterface *QAccessibleTableInterface::cellAt(int row, int column) const
@@ -2543,9 +2630,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun
*/
/*!
- \fn QAccessibleActionInterface::~QAccessibleActionInterface()
Destroys the QAccessibleActionInterface.
*/
+QAccessibleActionInterface::~QAccessibleActionInterface()
+{
+ // must be empty until ### Qt 6
+}
/*!
\fn QStringList QAccessibleActionInterface::actionNames() const
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h
index bfe1e6c542..a40d7209c3 100644
--- a/src/gui/accessible/qaccessible.h
+++ b/src/gui/accessible/qaccessible.h
@@ -396,10 +396,10 @@ public:
static UpdateHandler installUpdateHandler(UpdateHandler);
static RootObjectHandler installRootObjectHandler(RootObjectHandler);
- class ActivationObserver
+ class Q_GUI_EXPORT ActivationObserver
{
public:
- virtual ~ActivationObserver() {}
+ virtual ~ActivationObserver();
virtual void accessibilityActiveChanged(bool active) = 0;
};
static void installActivationObserver(ActivationObserver *);
@@ -514,7 +514,7 @@ protected:
class Q_GUI_EXPORT QAccessibleTextInterface
{
public:
- virtual ~QAccessibleTextInterface() {}
+ virtual ~QAccessibleTextInterface();
// selection
virtual void selection(int selectionIndex, int *startOffset, int *endOffset) const = 0;
virtual int selectionCount() const = 0;
@@ -547,7 +547,7 @@ public:
class Q_GUI_EXPORT QAccessibleEditableTextInterface
{
public:
- virtual ~QAccessibleEditableTextInterface() {}
+ virtual ~QAccessibleEditableTextInterface();
virtual void deleteText(int startOffset, int endOffset) = 0;
virtual void insertText(int offset, const QString &text) = 0;
@@ -557,8 +557,7 @@ public:
class Q_GUI_EXPORT QAccessibleValueInterface
{
public:
-
- virtual ~QAccessibleValueInterface() {}
+ virtual ~QAccessibleValueInterface();
virtual QVariant currentValue() const = 0;
virtual void setCurrentValue(const QVariant &value) = 0;
@@ -570,7 +569,7 @@ public:
class Q_GUI_EXPORT QAccessibleTableCellInterface
{
public:
- virtual ~QAccessibleTableCellInterface() {}
+ virtual ~QAccessibleTableCellInterface();
virtual bool isSelected() const = 0;
@@ -587,7 +586,7 @@ public:
class Q_GUI_EXPORT QAccessibleTableInterface
{
public:
- virtual ~QAccessibleTableInterface() {}
+ virtual ~QAccessibleTableInterface();
virtual QAccessibleInterface *caption() const = 0;
virtual QAccessibleInterface *summary() const = 0;
@@ -622,7 +621,7 @@ class Q_GUI_EXPORT QAccessibleActionInterface
{
Q_DECLARE_TR_FUNCTIONS(QAccessibleActionInterface)
public:
- virtual ~QAccessibleActionInterface() {}
+ virtual ~QAccessibleActionInterface();
virtual QStringList actionNames() const = 0;
virtual QString localizedActionName(const QString &name) const;
@@ -647,7 +646,7 @@ public:
class Q_GUI_EXPORT QAccessibleImageInterface
{
public:
- virtual ~QAccessibleImageInterface() {}
+ virtual ~QAccessibleImageInterface();
virtual QString imageDescription() const = 0;
virtual QSize imageSize() const = 0;
@@ -691,8 +690,7 @@ public:
m_uniqueId = QAccessible::uniqueId(iface);
}
- virtual ~QAccessibleEvent()
- {}
+ virtual ~QAccessibleEvent();
QAccessible::Event type() const { return m_type; }
QObject *object() const { return m_object; }
@@ -726,6 +724,7 @@ public:
{
m_type = QAccessible::StateChanged;
}
+ ~QAccessibleStateChangeEvent();
QAccessible::State changedStates() const {
return m_changedStates;
@@ -752,6 +751,8 @@ public:
m_type = QAccessible::TextCaretMoved;
}
+ ~QAccessibleTextCursorEvent();
+
void setCursorPosition(int position) { m_cursorPosition = position; }
int cursorPosition() const { return m_cursorPosition; }
@@ -776,6 +777,8 @@ public:
m_type = QAccessible::TextSelectionChanged;
}
+ ~QAccessibleTextSelectionEvent();
+
void setSelection(int start, int end) {
m_selectionStart = start;
m_selectionEnd = end;
@@ -805,6 +808,8 @@ public:
m_type = QAccessible::TextInserted;
}
+ ~QAccessibleTextInsertEvent();
+
QString textInserted() const {
return m_text;
}
@@ -833,6 +838,8 @@ public:
m_type = QAccessible::TextRemoved;
}
+ ~QAccessibleTextRemoveEvent();
+
QString textRemoved() const {
return m_text;
}
@@ -860,6 +867,9 @@ public:
{
m_type = QAccessible::TextUpdated;
}
+
+ ~QAccessibleTextUpdateEvent();
+
QString textRemoved() const {
return m_oldText;
}
@@ -892,6 +902,8 @@ public:
m_type = QAccessible::ValueChanged;
}
+ ~QAccessibleValueChangeEvent();
+
void setValue(const QVariant & val) { m_value= val; }
QVariant value() const { return m_value; }
@@ -926,6 +938,8 @@ public:
m_type = QAccessible::TableModelChanged;
}
+ ~QAccessibleTableModelChangeEvent();
+
void setModelChangeType(ModelChangeType changeType) { m_modelChangeType = changeType; }
ModelChangeType modelChangeType() const { return m_modelChangeType; }
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index cafc966fbb..f115707500 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -362,7 +362,7 @@ static inline int origIcoDepth(const QImage &image)
return s.isEmpty() ? 32 : s.toInt();
}
-static inline int findBySize(const QList<QImage> &images, const QSize &size)
+static inline int findBySize(const QVector<QImage> &images, const QSize &size)
{
for (int i = 0; i < images.size(); ++i) {
if (images.at(i).size() == size)
@@ -426,7 +426,7 @@ void QPixmapIconEngine::addFile(const QString &fileName, const QSize &size, QIco
// these files may contain low-resolution images. As this information is lost,
// ICOReader sets the original format as an image text key value. Read all matching
// images into a list trying to find the highest quality per size.
- QList<QImage> icoImages;
+ QVector<QImage> icoImages;
while (imageReader.read(&image)) {
if (ignoreSize || image.size() == size) {
const int position = findBySize(icoImages, image.size());
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index fa14c84e83..d3553f28be 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -42,7 +42,6 @@
#include <QtGui/QIconEngine>
#include <QtGui/QPalette>
#include <QtCore/QList>
-#include <QtCore/QHash>
#include <QtCore/QDir>
#include <QtCore/QSettings>
#include <QtGui/QPainter>
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index cd0cbf7f49..3c192a237e 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -476,6 +476,10 @@ bool QImageData::checkForAlphaPixels() const
\snippet code/src_gui_image_qimage.cpp 1
\endtable
+ For images with more than 8-bit per color-channel. The methods
+ setPixelColor() and pixelColor() can be used to set and get
+ with QColor values.
+
QImage also provide the scanLine() function which returns a
pointer to the pixel data at the scanline with the given index,
and the bits() function which returns a pointer to the first pixel
@@ -1769,11 +1773,11 @@ void QImage::fill(const QColor &color)
break;
case QImage::Format_BGR30:
case QImage::Format_A2BGR30_Premultiplied:
- fill(qConvertArgb32ToA2rgb30<PixelOrderBGR>(color.rgba()));
+ fill(qConvertRgb64ToRgb30<PixelOrderBGR>(color.rgba64()));
break;
case QImage::Format_RGB30:
case QImage::Format_A2RGB30_Premultiplied:
- fill(qConvertArgb32ToA2rgb30<PixelOrderRGB>(color.rgba()));
+ fill(qConvertRgb64ToRgb30<PixelOrderRGB>(color.rgba64()));
break;
case QImage::Format_RGB16:
fill((uint) qConvertRgb32To16(color.rgba()));
@@ -2190,9 +2194,10 @@ int QImage::pixelIndex(int x, int y) const
If the \a position is not valid, the results are undefined.
\warning This function is expensive when used for massive pixel
- manipulations.
+ manipulations. Use constBits() or constScanLine() when many
+ pixels needs to be read.
- \sa setPixel(), valid(), {QImage#Pixel Manipulation}{Pixel
+ \sa setPixel(), valid(), constBits(), constScanLine(), {QImage#Pixel Manipulation}{Pixel
Manipulation}
*/
@@ -2242,25 +2247,23 @@ QRgb QImage::pixel(int x, int y) const
return *layout->convertToARGB32PM(&result, ptr, 1, layout, 0);
}
-
/*!
\fn void QImage::setPixel(const QPoint &position, uint index_or_rgb)
Sets the pixel index or color at the given \a position to \a
index_or_rgb.
- If the image's format is either monochrome or 8-bit, the given \a
+ If the image's format is either monochrome or paletted, the given \a
index_or_rgb value must be an index in the image's color table,
otherwise the parameter must be a QRgb value.
If \a position is not a valid coordinate pair in the image, or if
\a index_or_rgb >= colorCount() in the case of monochrome and
- 8-bit images, the result is undefined.
+ paletted images, the result is undefined.
\warning This function is expensive due to the call of the internal
\c{detach()} function called within; if performance is a concern, we
- recommend the use of \l{QImage::}{scanLine()} to access pixel data
- directly.
+ recommend the use of scanLine() or bits() to access pixel data directly.
\sa pixel(), {QImage#Pixel Manipulation}{Pixel Manipulation}
*/
@@ -2348,6 +2351,102 @@ void QImage::setPixel(int x, int y, uint index_or_rgb)
}
/*!
+ \fn QColor QImage::pixelColor(const QPoint &position) const
+ \since 5.6
+
+ Returns the color of the pixel at the given \a position as a QColor.
+
+ If the \a position is not valid, an invalid QColor is returned.
+
+ \warning This function is expensive when used for massive pixel
+ manipulations. Use constBits() or constScanLine() when many
+ pixels needs to be read.
+
+ \sa setPixel(), valid(), constBits(), constScanLine(), {QImage#Pixel Manipulation}{Pixel
+ Manipulation}
+*/
+
+/*!
+ \overload
+ \since 5.6
+
+ Returns the color of the pixel at coordinates (\a x, \a y) as a QColor.
+*/
+QColor QImage::pixelColor(int x, int y) const
+{
+ if (!d || x < 0 || x >= d->width || y < 0 || y >= height()) {
+ qWarning("QImage::pixelColor: coordinate (%d,%d) out of range", x, y);
+ return QColor();
+ }
+
+ const uchar * s = constScanLine(y);
+ switch (d->format) {
+ case Format_BGR30:
+ case Format_A2BGR30_Premultiplied:
+ return QColor(qConvertA2rgb30ToRgb64<PixelOrderBGR>(reinterpret_cast<const quint32 *>(s)[x]));
+ case Format_RGB30:
+ case Format_A2RGB30_Premultiplied:
+ return QColor(qConvertA2rgb30ToRgb64<PixelOrderRGB>(reinterpret_cast<const quint32 *>(s)[x]));
+ default:
+ return QColor(pixel(x, y));
+ }
+}
+
+/*!
+ \fn void QImage::setPixelColor(const QPoint &position, const QColor &color)
+ \since 5.6
+
+ Sets the color at the given \a position to \a color.
+
+ If \a position is not a valid coordinate pair in the image, or
+ the image's format is either monochrome or paletted, the result is undefined.
+
+ \warning This function is expensive due to the call of the internal
+ \c{detach()} function called within; if performance is a concern, we
+ recommend the use of scanLine() or bits() to access pixel data directly.
+
+ \sa pixel(), bits(), scanLine(), {QImage#Pixel Manipulation}{Pixel Manipulation}
+*/
+
+/*!
+ \overload
+ \since 5.6
+
+ Sets the pixel color at (\a x, \a y) to \a color.
+*/
+void QImage::setPixelColor(int x, int y, const QColor &color)
+{
+ if (!d || x < 0 || x >= width() || y < 0 || y >= height() || !color.isValid()) {
+ qWarning("QImage::setPixelColor: coordinate (%d,%d) out of range", x, y);
+ return;
+ }
+ // detach is called from within scanLine
+ uchar * s = scanLine(y);
+ switch (d->format) {
+ case Format_Mono:
+ case Format_MonoLSB:
+ case Format_Indexed8:
+ qWarning("QImage::setPixelColor: called on monochrome or indexed format");
+ return;
+ case Format_BGR30:
+ ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderBGR>(color.rgba64()) | 0xc0000000;
+ return;
+ case Format_A2BGR30_Premultiplied:
+ ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderBGR>(color.rgba64());
+ return;
+ case Format_RGB30:
+ ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderRGB>(color.rgba64()) | 0xc0000000;
+ return;
+ case Format_A2RGB30_Premultiplied:
+ ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderRGB>(color.rgba64());
+ return;
+ default:
+ setPixel(x, y, color.rgba());
+ return;
+ }
+}
+
+/*!
Returns \c true if all the colors in the image are shades of gray
(i.e. their red, green and blue components are equal); otherwise
false.
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 26057f366c..26707021ea 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -34,10 +34,11 @@
#ifndef QIMAGE_H
#define QIMAGE_H
-#include <QtGui/qtransform.h>
-#include <QtGui/qpaintdevice.h>
+#include <QtGui/qcolor.h>
#include <QtGui/qrgb.h>
+#include <QtGui/qpaintdevice.h>
#include <QtGui/qpixelformat.h>
+#include <QtGui/qtransform.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qrect.h>
#include <QtCore/qstring.h>
@@ -220,6 +221,12 @@ public:
void setPixel(int x, int y, uint index_or_rgb);
void setPixel(const QPoint &pt, uint index_or_rgb);
+ QColor pixelColor(int x, int y) const;
+ QColor pixelColor(const QPoint &pt) const;
+
+ void setPixelColor(int x, int y, const QColor &c);
+ void setPixelColor(const QPoint &pt, const QColor &c);
+
QVector<QRgb> colorTable() const;
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
void setColorTable(const QVector<QRgb> &colors);
@@ -352,6 +359,8 @@ inline bool QImage::valid(const QPoint &pt) const { return valid(pt.x(), pt.y())
inline int QImage::pixelIndex(const QPoint &pt) const { return pixelIndex(pt.x(), pt.y());}
inline QRgb QImage::pixel(const QPoint &pt) const { return pixel(pt.x(), pt.y()); }
inline void QImage::setPixel(const QPoint &pt, uint index_or_rgb) { setPixel(pt.x(), pt.y(), index_or_rgb); }
+inline QColor QImage::pixelColor(const QPoint &pt) const { return pixelColor(pt.x(), pt.y()); }
+inline void QImage::setPixelColor(const QPoint &pt, const QColor &c) { setPixelColor(pt.x(), pt.y(), c); }
#if QT_DEPRECATED_SINCE(5, 0)
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index ba79bf40e5..83ec91bb40 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -1203,6 +1203,39 @@ bool QImageReader::autoTransform() const
}
/*!
+ \since 5.6
+
+ This is an image format specific function that forces images with
+ gamma information to be gamma corrected to \a gamma. For image formats
+ that do not support gamma correction, this value is ignored.
+
+ To gamma correct to a standard PC color-space, set gamma to \c 1/2.2.
+
+ \sa gamma()
+*/
+void QImageReader::setGamma(float gamma)
+{
+ if (d->initHandler() && d->handler->supportsOption(QImageIOHandler::Gamma))
+ d->handler->setOption(QImageIOHandler::Gamma, gamma);
+}
+
+/*!
+ \since 5.6
+
+ Returns the gamma level of the decoded image. If setGamma() has been
+ called and gamma correction is supported it will return the gamma set.
+ If gamma level is not supported by the image format, \c 0.0 is returned.
+
+ \sa setGamma()
+*/
+float QImageReader::gamma() const
+{
+ if (d->initHandler() && d->handler->supportsOption(QImageIOHandler::Gamma))
+ return d->handler->option(QImageIOHandler::Gamma).toFloat();
+ return 0.0;
+}
+
+/*!
Returns \c true if an image can be read for the device (i.e., the
image format is supported, and the device seems to contain valid
data); otherwise returns \c false.
diff --git a/src/gui/image/qimagereader.h b/src/gui/image/qimagereader.h
index 27a29bed49..6745c55b97 100644
--- a/src/gui/image/qimagereader.h
+++ b/src/gui/image/qimagereader.h
@@ -110,6 +110,9 @@ public:
void setAutoTransform(bool enabled);
bool autoTransform() const;
+ void setGamma(float gamma);
+ float gamma() const;
+
QByteArray subType() const;
QList<QByteArray> supportedSubTypes() const;
diff --git a/src/gui/image/qpaintengine_pic.cpp b/src/gui/image/qpaintengine_pic.cpp
index 9ab1e2c30b..47480ebbae 100644
--- a/src/gui/image/qpaintengine_pic.cpp
+++ b/src/gui/image/qpaintengine_pic.cpp
@@ -398,6 +398,7 @@ void QPicturePaintEngine::drawPolygon(const QPointF *points, int numPoints, Poly
int pos;
QPolygonF polygon;
+ polygon.reserve(numPoints);
for (int i=0; i<numPoints; ++i)
polygon << points[i];
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index b63be19153..4a1e65b20a 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -1216,7 +1216,9 @@ QList<QByteArray> QPicture::inputFormats()
static QStringList qToStringList(const QList<QByteArray> &arr)
{
QStringList list;
- for (int i = 0; i < arr.count(); ++i)
+ const int count = arr.count();
+ list.reserve(count);
+ for (int i = 0; i < count; ++i)
list.append(QString::fromLatin1(arr.at(i)));
return list;
}
diff --git a/src/gui/image/qpicture_p.h b/src/gui/image/qpicture_p.h
index 56e6e1249c..a414a122f1 100644
--- a/src/gui/image/qpicture_p.h
+++ b/src/gui/image/qpicture_p.h
@@ -48,6 +48,7 @@
#include "QtCore/qatomic.h"
#include "QtCore/qbuffer.h"
#include "QtCore/qobjectdefs.h"
+#include "QtCore/qvector.h"
#include "QtGui/qpicture.h"
#include "QtGui/qpixmap.h"
#include "QtGui/qpen.h"
@@ -150,8 +151,8 @@ public:
QRect override_rect;
QScopedPointer<QPaintEngine> paintEngine;
bool in_memory_only;
- QList<QImage> image_list;
- QList<QPixmap> pixmap_list;
+ QVector<QImage> image_list;
+ QVector<QPixmap> pixmap_list;
QList<QBrush> brush_list;
QList<QPen> pen_list;
};
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp
index f9c362e194..0fefa1f7ea 100644
--- a/src/gui/image/qpixmapcache.cpp
+++ b/src/gui/image/qpixmapcache.cpp
@@ -138,6 +138,24 @@ bool QPixmapCache::Key::operator ==(const Key &key) const
*/
/*!
+ \fn QPixmapCache::Key::Key(Key &&)
+ \internal
+ \since 5.6
+*/
+
+/*!
+ \fn QPixmapCache::Key &QPixmapCache::Key::operator=(Key &&)
+ \internal
+ \since 5.6
+*/
+
+/*!
+ \fn void QPixmapCache::Key::swap(Key &)
+ \internal
+ \since 5.6
+*/
+
+/*!
\internal
*/
QPixmapCache::Key &QPixmapCache::Key::operator =(const Key &other)
@@ -179,7 +197,6 @@ public:
static QPixmapCache::KeyData* getKeyData(QPixmapCache::Key *key);
- QList< QPair<QString,QPixmap> > allPixmaps() const;
bool flushDetachedPixmaps(bool nt);
private:
@@ -423,20 +440,6 @@ QPixmapCache::KeyData* QPMCache::getKeyData(QPixmapCache::Key *key)
return key->d;
}
-QList< QPair<QString,QPixmap> > QPMCache::allPixmaps() const
-{
- QList< QPair<QString,QPixmap> > r;
- QHash<QString, QPixmapCache::Key>::const_iterator it = cacheKeys.begin();
- while (it != cacheKeys.end()) {
- QPixmap *ptr = QCache<QPixmapCache::Key, QPixmapCacheEntry>::object(it.value());
- if (ptr)
- r.append(QPair<QString,QPixmap>(it.key(),*ptr));
- ++it;
- }
- return r;
-}
-
-
Q_GLOBAL_STATIC(QPMCache, pm_cache)
int Q_AUTOTEST_EXPORT q_QPixmapCache_keyHashSize()
@@ -656,9 +659,4 @@ int QPixmapCache::totalUsed()
return (pm_cache()->totalCost()+1023) / 1024;
}
-QList< QPair<QString,QPixmap> > QPixmapCache::allPixmaps()
-{
- return pm_cache()->allPixmaps();
-}
-
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h
index 345389e987..03311345a2 100644
--- a/src/gui/image/qpixmapcache.h
+++ b/src/gui/image/qpixmapcache.h
@@ -36,10 +36,6 @@
#include <QtGui/qpixmap.h>
-#ifdef Q_TEST_QPIXMAPCACHE
-#include <QtCore/qpair.h>
-#endif
-
QT_BEGIN_NAMESPACE
@@ -52,12 +48,18 @@ public:
public:
Key();
Key(const Key &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ Key(Key &&other) Q_DECL_NOTHROW : d(other.d) { other.d = Q_NULLPTR; }
+ Key &operator =(Key &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
~Key();
bool operator ==(const Key &key) const;
inline bool operator !=(const Key &key) const
{ return !operator==(key); }
Key &operator =(const Key &other);
+ void swap(Key &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
+
private:
KeyData *d;
friend class QPMCache;
@@ -80,7 +82,6 @@ public:
#ifdef Q_TEST_QPIXMAPCACHE
static void flushDetachedPixmaps();
static int totalUsed();
- static QList< QPair<QString,QPixmap> > allPixmaps();
#endif
};
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index 7fbd24787e..776a61d8fe 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -108,10 +108,11 @@ public:
};
QPngHandlerPrivate(QPngHandler *qq)
- : gamma(0.0), quality(2), png_ptr(0), info_ptr(0), end_info(0), state(Ready), q(qq)
+ : gamma(0.0), fileGamma(0.0), quality(2), png_ptr(0), info_ptr(0), end_info(0), state(Ready), q(qq)
{ }
float gamma;
+ float fileGamma;
int quality;
QString description;
QSize scaledSize;
@@ -234,13 +235,10 @@ void CALLBACK_CALL_TYPE qpiw_flush_fn(png_structp /* png_ptr */)
}
static
-void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scaledSize, bool *doScaledRead, float screen_gamma=0.0)
+void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scaledSize, bool *doScaledRead, float screen_gamma=0.0, float file_gamma=0.0)
{
- if (screen_gamma != 0.0 && png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA)) {
- double file_gamma;
- png_get_gAMA(png_ptr, info_ptr, &file_gamma);
- png_set_gamma(png_ptr, screen_gamma, file_gamma);
- }
+ if (screen_gamma != 0.0 && file_gamma != 0.0)
+ png_set_gamma(png_ptr, 1.0f / screen_gamma, file_gamma);
png_uint_32 width;
png_uint_32 height;
@@ -557,6 +555,12 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngHeader()
readPngTexts(info_ptr);
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA)) {
+ double file_gamma = 0.0;
+ png_get_gAMA(png_ptr, info_ptr, &file_gamma);
+ fileGamma = file_gamma;
+ }
+
state = ReadHeader;
return true;
}
@@ -580,7 +584,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngImage(QImage *outImage)
}
bool doScaledRead = false;
- setup_qt(*outImage, png_ptr, info_ptr, scaledSize, &doScaledRead, gamma);
+ setup_qt(*outImage, png_ptr, info_ptr, scaledSize, &doScaledRead, gamma, fileGamma);
if (outImage->isNull()) {
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
@@ -1063,7 +1067,7 @@ QVariant QPngHandler::option(ImageOption option) const
return QVariant();
if (option == Gamma)
- return d->gamma;
+ return d->gamma == 0.0 ? d->fileGamma : d->gamma;
else if (option == Quality)
return d->quality;
else if (option == Description)
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp
index 8d848b662f..c5006d88ed 100644
--- a/src/gui/itemmodels/qstandarditemmodel.cpp
+++ b/src/gui/itemmodels/qstandarditemmodel.cpp
@@ -1224,7 +1224,7 @@ void QStandardItem::setSelectable(bool selectable)
The item delegate will render a checkable item with a check box next to the
item's text.
- \sa isCheckable(), setCheckState(), setTristate()
+ \sa isCheckable(), setCheckState(), setUserTristate(), setAutoTristate()
*/
void QStandardItem::setCheckable(bool checkable)
{
@@ -1244,34 +1244,87 @@ void QStandardItem::setCheckable(bool checkable)
The default value is false.
- \sa setCheckable(), checkState(), isTristate()
+ \sa setCheckable(), checkState(), isUserTristate(), isAutoTristate()
*/
/*!
- Sets whether the item is tristate. If \a tristate is true, the
- item is checkable with three separate states; otherwise, the item
- is checkable with two states. (Note that this also requires that
- the item is checkable; see isCheckable().)
+ \fn void QStandardItem::setTristate(bool tristate)
+ \obsolete
- \sa isTristate(), setCheckable(), setCheckState()
+ Use QStandardItem::setAutoTristate(bool tristate) instead.
+ For a tristate checkbox that the user can change between all three
+ states, use QStandardItem::setUserTristate(bool tristate) instead.
*/
-void QStandardItem::setTristate(bool tristate)
+
+/*!
+ \fn void QStandardItem::isTristate() const
+ \obsolete
+
+ Use QStandardItem::isAutoTristate() instead.
+ For a tristate checkbox that the user can change between all three
+ states, use QStandardItem::isUserTristate() instead.
+*/
+
+/*!
+ Sets whether the item is tristate and controlled by QTreeWidget.
+ This enables automatic management of the state of parent items in QTreeWidget
+ (checked if all children are checked, unchecked if all children are unchecked,
+ or partially checked if only some children are checked).
+
+ \since 5.6
+ \sa isAutoTristate(), setCheckable(), setCheckState()
+*/
+void QStandardItem::setAutoTristate(bool tristate)
{
Q_D(QStandardItem);
- d->changeFlags(tristate, Qt::ItemIsTristate);
+ d->changeFlags(tristate, Qt::ItemIsAutoTristate);
}
/*!
- \fn bool QStandardItem::isTristate() const
+ \fn bool QStandardItem::isAutoTristate() const
+
+ Returns whether the item is tristate and is controlled by QTreeWidget.
+
+ The default value is false.
+
+ \since 5.6
+ \sa setAutoTristate(), isCheckable(), checkState()
+*/
+
+/*!
+ Sets whether the item is tristate and controlled by the user.
+ If \a tristate is true, the user can cycle through three separate states;
+ otherwise, the item is checkable with two states.
+ (Note that this also requires that the item is checkable; see isCheckable().)
+
+ \since 5.6
+ \sa isUserTristate(), setCheckable(), setCheckState()
+*/
+void QStandardItem::setUserTristate(bool tristate)
+{
+ Q_D(QStandardItem);
+ d->changeFlags(tristate, Qt::ItemIsUserTristate);
+}
+
+/*!
+ \fn bool QStandardItem::isUserTristate() const
+ \since 5.6
Returns whether the item is tristate; that is, if it's checkable with three
- separate states.
+ separate states and the user can cycle through all three states.
The default value is false.
- \sa setTristate(), isCheckable(), checkState()
+ \sa setUserTristate(), isCheckable(), checkState()
*/
+#if QT_DEPRECATED_SINCE(5, 6)
+void QStandardItem::setTristate(bool tristate)
+{
+ setAutoTristate(tristate);
+}
+#endif
+
#ifndef QT_NO_DRAGANDDROP
/*!
@@ -1750,6 +1803,7 @@ QList<QStandardItem*> QStandardItem::takeRow(int row)
int index = d->childIndex(row, 0); // Will return -1 if there are no columns
if (index != -1) {
int col_count = d->columnCount();
+ items.reserve(col_count);
for (int column = 0; column < col_count; ++column) {
QStandardItem *ch = d->children.at(index + column);
if (ch)
@@ -2467,7 +2521,9 @@ QList<QStandardItem*> QStandardItemModel::findItems(const QString &text,
QModelIndexList indexes = match(index(0, column, QModelIndex()),
Qt::DisplayRole, text, -1, flags);
QList<QStandardItem*> items;
- for (int i = 0; i < indexes.size(); ++i)
+ const int numIndexes = indexes.size();
+ items.reserve(numIndexes);
+ for (int i = 0; i < numIndexes; ++i)
items.append(itemFromIndex(indexes.at(i)));
return items;
}
diff --git a/src/gui/itemmodels/qstandarditemmodel.h b/src/gui/itemmodels/qstandarditemmodel.h
index 3dd613f907..44156d1907 100644
--- a/src/gui/itemmodels/qstandarditemmodel.h
+++ b/src/gui/itemmodels/qstandarditemmodel.h
@@ -158,10 +158,20 @@ public:
}
void setCheckable(bool checkable);
- inline bool isTristate() const {
- return (flags() & Qt::ItemIsTristate) != 0;
+ inline bool isAutoTristate() const {
+ return (flags() & Qt::ItemIsAutoTristate) != 0;
}
- void setTristate(bool tristate);
+ void setAutoTristate(bool tristate);
+
+ inline bool isUserTristate() const {
+ return (flags() & Qt::ItemIsUserTristate) != 0;
+ }
+ void setUserTristate(bool tristate);
+
+#if QT_DEPRECATED_SINCE(5, 6)
+ QT_DEPRECATED bool isTristate() const { return isAutoTristate(); }
+ QT_DEPRECATED void setTristate(bool tristate);
+#endif
#ifndef QT_NO_DRAGANDDROP
inline bool isDragEnabled() const {
diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp
index 3ce8ab95ec..b05da1bfd0 100644
--- a/src/gui/kernel/qdnd.cpp
+++ b/src/gui/kernel/qdnd.cpp
@@ -147,7 +147,9 @@ static QStringList imageReadMimeFormats()
{
QStringList formats;
QList<QByteArray> imageFormats = QImageReader::supportedImageFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
+ const int numImageFormats = imageFormats.size();
+ formats.reserve(numImageFormats);
+ for (int i = 0; i < numImageFormats; ++i) {
QString format = QLatin1String("image/");
format += QString::fromLatin1(imageFormats.at(i).toLower());
formats.append(format);
@@ -166,7 +168,9 @@ static QStringList imageWriteMimeFormats()
{
QStringList formats;
QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
+ const int numImageFormats = imageFormats.size();
+ formats.reserve(numImageFormats);
+ for (int i = 0; i < numImageFormats; ++i) {
QString format = QLatin1String("image/");
format += QString::fromLatin1(imageFormats.at(i).toLower());
formats.append(format);
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 98fb0f1f20..adbaa5ff86 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -263,6 +263,36 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &wind
{}
/*!
+ \since 5.6
+
+ Constructs a mouse event object.
+
+ The \a type parameter must be QEvent::MouseButtonPress,
+ QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
+ or QEvent::MouseMove.
+
+ The points \a localPos, \a windowPos and \a screenPos specify the
+ mouse cursor's position relative to the receiving widget or item,
+ window, and screen, respectively.
+
+ The \a button that caused the event is given as a value from the
+ \l Qt::MouseButton enum. If the event \a type is \l MouseMove,
+ the appropriate button for this event is Qt::NoButton. \a buttons
+ is the state of all buttons at the time of the event, \a modifiers
+ is the state of all keyboard modifiers.
+
+ The source of the event is specified by \a source.
+
+*/
+QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
+ : QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons), caps(0)
+{
+ QGuiApplicationPrivate::setMouseEventSource(this, source);
+}
+
+/*!
\internal
*/
QMouseEvent::~QMouseEvent()
@@ -1941,6 +1971,11 @@ QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
{
}
+QInputMethodEvent::~QInputMethodEvent()
+{
+ // must be empty until ### Qt 6
+}
+
/*!
Sets the commit string to \a commitString.
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index a1f32026ac..dd7b35e2bb 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -106,6 +106,9 @@ public:
QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers);
+ QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source);
~QMouseEvent();
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
@@ -528,6 +531,8 @@ public:
};
QInputMethodEvent();
QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes);
+ ~QInputMethodEvent();
+
void setCommitString(const QString &commitString, int replaceFrom = 0, int replaceLength = 0);
inline const QList<Attribute> &attributes() const { return attrs; }
inline const QString &preeditString() const { return preedit; }
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 6aa1d26c66..b56a9da255 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1329,6 +1329,9 @@ void QGuiApplicationPrivate::init()
#endif
#ifndef QT_NO_LIBRARY
+ if (qEnvironmentVariableIntValue("QT_LOAD_TESTABILITY") > 0)
+ loadTestability = true;
+
if (loadTestability) {
QLibrary testLib(QStringLiteral("qttestability"));
if (testLib.load()) {
@@ -1343,6 +1346,8 @@ void QGuiApplicationPrivate::init()
qCritical() << "Library qttestability load failed:" << testLib.errorString();
}
}
+#else
+ Q_UNUSED(loadTestability);
#endif // QT_NO_LIBRARY
}
@@ -1692,12 +1697,14 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
// A mouse event should not change both position and buttons at the same time. Instead we
// should first send a move event followed by a button changed event. Since this is not the case
// with the current event, we split it in two.
- QWindowSystemInterfacePrivate::MouseEvent *mouseButtonEvent = new QWindowSystemInterfacePrivate::MouseEvent(
+ QWindowSystemInterfacePrivate::MouseEvent mouseButtonEvent(
e->window.data(), e->timestamp, e->type, e->localPos, e->globalPos, e->buttons, e->modifiers);
if (e->flags & QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic)
- mouseButtonEvent->flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic;
- QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(mouseButtonEvent);
- stateChange = Qt::NoButton;
+ mouseButtonEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic;
+ e->buttons = buttons;
+ processMouseEvent(e);
+ processMouseEvent(&mouseButtonEvent);
+ return;
}
QWindow *window = e->window.data();
@@ -1766,9 +1773,8 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
if (!window)
return;
- QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, buttons, e->modifiers);
+ QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, buttons, e->modifiers, e->source);
ev.setTimestamp(e->timestamp);
- setMouseEventSource(&ev, e->source);
#ifndef QT_NO_CURSOR
if (!e->synthetic()) {
if (const QScreen *screen = window->screen())
@@ -1827,9 +1833,8 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
if (!e->window.isNull() || e->nullWindow()) { // QTBUG-36364, check if window closed in response to press
const QEvent::Type doubleClickType = frameStrut ? QEvent::NonClientAreaMouseButtonDblClick : QEvent::MouseButtonDblClick;
QMouseEvent dblClickEvent(doubleClickType, localPoint, localPoint, globalPoint,
- button, buttons, e->modifiers);
+ button, buttons, e->modifiers, e->source);
dblClickEvent.setTimestamp(e->timestamp);
- setMouseEventSource(&dblClickEvent, e->source);
QGuiApplication::sendSpontaneousEvent(window, &dblClickEvent);
}
}
diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h
index 20dcbbc139..34003cdf41 100644
--- a/src/gui/kernel/qkeymapper_p.h
+++ b/src/gui/kernel/qkeymapper_p.h
@@ -50,7 +50,6 @@
#include <qlist.h>
#include <qlocale.h>
#include <qevent.h>
-#include <qhash.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 5bf22b9394..9dc06138a6 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -39,6 +39,7 @@
#ifndef QT_NO_SHORTCUT
#include "qdebug.h"
+#include <QtCore/qhashfunctions.h>
#ifndef QT_NO_REGEXP
# include "qregexp.h"
#endif
@@ -1100,7 +1101,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
int i = 0;
int lastI = 0;
while ((i = sl.indexOf(QLatin1Char('+'), i + 1)) != -1) {
- const QString sub = sl.mid(lastI, i - lastI + 1);
+ const QStringRef sub = sl.midRef(lastI, i - lastI + 1);
// If we get here the shortcuts contains at least one '+'. We break up
// along the following strategy:
// Meta+Ctrl++ ( "Meta+", "Ctrl+", "+" )
@@ -1409,6 +1410,16 @@ bool QKeySequence::operator==(const QKeySequence &other) const
d->key[3] == other.d->key[3]);
}
+/*!
+ \since 5.6
+
+ Calculates the hash value of \a key, using
+ \a seed to seed the calculation.
+*/
+uint qHash(const QKeySequence &key, uint seed) Q_DECL_NOTHROW
+{
+ return qHashRange(key.d->key, key.d->key + QKeySequencePrivate::MaxKeyCount, seed);
+}
/*!
Provides an arbitrary comparison of this key sequence and
@@ -1523,6 +1534,7 @@ QList<QKeySequence> QKeySequence::listFromString(const QString &str, SequenceFor
QList<QKeySequence> result;
QStringList strings = str.split(QLatin1String("; "));
+ result.reserve(strings.count());
foreach (const QString &string, strings) {
result << fromString(string, format);
}
@@ -1565,15 +1577,14 @@ QString QKeySequence::listToString(const QList<QKeySequence> &list, SequenceForm
*/
QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence)
{
- QList<quint32> list;
- list << keysequence.d->key[0];
-
- if (s.version() >= 5 && keysequence.count() > 1) {
- list << keysequence.d->key[1];
- list << keysequence.d->key[2];
- list << keysequence.d->key[3];
+ Q_STATIC_ASSERT_X(QKeySequencePrivate::MaxKeyCount == 4, "Forgot to adapt QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence) to new QKeySequence::MaxKeyCount");
+ const bool extended = s.version() >= 5 && keysequence.count() > 1;
+ s << quint32(extended ? 4 : 1) << quint32(keysequence.d->key[0]);
+ if (extended) {
+ s << quint32(keysequence.d->key[1])
+ << quint32(keysequence.d->key[2])
+ << quint32(keysequence.d->key[3]);
}
- s << list;
return s;
}
diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h
index cd7af5718f..d6171c86f2 100644
--- a/src/gui/kernel/qkeysequence.h
+++ b/src/gui/kernel/qkeysequence.h
@@ -43,11 +43,12 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_SHORTCUT
+class QKeySequence;
+
/*****************************************************************************
QKeySequence stream functions
*****************************************************************************/
#ifndef QT_NO_DATASTREAM
-class QKeySequence;
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &out, QKeySequence &ks);
#endif
@@ -59,6 +60,8 @@ void qt_set_sequence_auto_mnemonic(bool b);
class QVariant;
class QKeySequencePrivate;
+Q_GUI_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QKeySequence &key, uint seed = 0) Q_DECL_NOTHROW;
+
class Q_GUI_EXPORT QKeySequence
{
Q_GADGET
@@ -177,10 +180,10 @@ public:
int operator[](uint i) const;
QKeySequence &operator=(const QKeySequence &other);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QKeySequence &operator=(QKeySequence &&other)
- { qSwap(d, other.d); return *this; }
+ QKeySequence &operator=(QKeySequence &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- inline void swap(QKeySequence &other) { qSwap(d, other.d); }
+ void swap(QKeySequence &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
+
bool operator==(const QKeySequence &other) const;
inline bool operator!= (const QKeySequence &other) const
{ return !(*this == other); }
@@ -204,6 +207,7 @@ private:
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks);
+ friend Q_GUI_EXPORT uint qHash(const QKeySequence &key, uint seed) Q_DECL_NOTHROW;
friend class QShortcutMap;
friend class QShortcut;
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 56a3729a4a..7ca1786019 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -226,7 +226,7 @@ public:
QOpenGLContext *context;
};
-static QThreadStorage<QGuiGLThreadContext *> qwindow_context_storage;
+Q_GLOBAL_STATIC(QThreadStorage<QGuiGLThreadContext *>, qwindow_context_storage);
static QOpenGLContext *global_share_context = 0;
#ifndef QT_NO_DEBUG
@@ -336,14 +336,14 @@ QOpenGLContext *qt_gl_global_share_context()
*/
QOpenGLContext *QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context)
{
- QGuiGLThreadContext *threadContext = qwindow_context_storage.localData();
+ QGuiGLThreadContext *threadContext = qwindow_context_storage()->localData();
if (!threadContext) {
if (!QThread::currentThread()) {
qWarning("No QTLS available. currentContext won't work");
return 0;
}
threadContext = new QGuiGLThreadContext;
- qwindow_context_storage.setLocalData(threadContext);
+ qwindow_context_storage()->setLocalData(threadContext);
}
QOpenGLContext *previous = threadContext->context;
threadContext->context = context;
@@ -412,8 +412,8 @@ int QOpenGLContextPrivate::maxTextureSize()
*/
QOpenGLContext* QOpenGLContext::currentContext()
{
- QGuiGLThreadContext *threadContext = qwindow_context_storage.localData();
- if(threadContext) {
+ QGuiGLThreadContext *threadContext = qwindow_context_storage()->localData();
+ if (threadContext) {
return threadContext->context;
}
return 0;
diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h
index a529957ad6..89c24b66bf 100644
--- a/src/gui/kernel/qopenglcontext.h
+++ b/src/gui/kernel/qopenglcontext.h
@@ -54,7 +54,10 @@
#include <QtGui/qopengl.h>
#include <QtGui/qopenglversionfunctions.h>
+#if QT_DEPRECATED_SINCE(5, 5)
#include <QtCore/qhash.h>
+#endif
+#include <QtCore/qhashfunctions.h>
#include <QtCore/qpair.h>
#include <QtCore/qvariant.h>
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index 3d37088182..2d0458f705 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -36,7 +36,6 @@
#include <QtCore/QVariant>
#include <QtCore/QSharedData>
#include <QtCore/QSettings>
-#include <QtCore/QHash>
#include <QtCore/QUrl>
#include <QtGui/QColor>
diff --git a/src/gui/kernel/qplatformintegrationfactory.cpp b/src/gui/kernel/qplatformintegrationfactory.cpp
index d58ac3a33f..5a1fb3ca83 100644
--- a/src/gui/kernel/qplatformintegrationfactory.cpp
+++ b/src/gui/kernel/qplatformintegrationfactory.cpp
@@ -72,6 +72,12 @@ QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platfor
}
if (QPlatformIntegration *ret = loadIntegration(loader(), platform, paramList, argc, argv))
return ret;
+#else
+ Q_UNUSED(platform);
+ Q_UNUSED(paramList);
+ Q_UNUSED(argc);
+ Q_UNUSED(argv);
+ Q_UNUSED(platformPluginPath);
#endif
return 0;
}
@@ -102,6 +108,7 @@ QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath)
list.append(loader()->keyMap().values());
return list;
#else
+ Q_UNUSED(platformPluginPath);
return QStringList();
#endif
}
diff --git a/src/gui/kernel/qplatformthemefactory.cpp b/src/gui/kernel/qplatformthemefactory.cpp
index d4902ac163..bcc37dad06 100644
--- a/src/gui/kernel/qplatformthemefactory.cpp
+++ b/src/gui/kernel/qplatformthemefactory.cpp
@@ -63,6 +63,9 @@ QPlatformTheme *QPlatformThemeFactory::create(const QString& key, const QString
}
if (QPlatformTheme *ret = qLoadPlugin1<QPlatformTheme, QPlatformThemePlugin>(loader(), platform, paramList))
return ret;
+#else
+ Q_UNUSED(key);
+ Q_UNUSED(platformPluginPath);
#endif
return 0;
}
@@ -93,6 +96,7 @@ QStringList QPlatformThemeFactory::keys(const QString &platformPluginPath)
list += loader()->keyMap().values();
return list;
#else
+ Q_UNUSED(platformPluginPath);
return QStringList();
#endif
}
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index 038be09dc7..1e0d4f766a 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -37,6 +37,7 @@
#include "qguiapplication_p.h"
#include <qpa/qplatformscreen.h>
+#include <QtCore/QDebug>
#include <QtCore/private/qobject_p.h>
QT_BEGIN_NAMESPACE
@@ -328,6 +329,7 @@ QList<QScreen *> QScreen::virtualSiblings() const
Q_D(const QScreen);
QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings();
QList<QScreen *> screens;
+ screens.reserve(platformScreens.count());
foreach (QPlatformScreen *platformScreen, platformScreens)
screens << platformScreen->screen();
return screens;
@@ -654,4 +656,41 @@ QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height)
return platformScreen->grabWindow(window, x, y, width, height);
}
+#ifndef QT_NO_DEBUG_STREAM
+
+static inline void formatRect(QDebug &debug, const QRect r)
+{
+ debug << r.width() << 'x' << r.height()
+ << forcesign << r.x() << r.y() << noforcesign;
+}
+
+Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QScreen *screen)
+{
+ const QDebugStateSaver saver(debug);
+ debug.nospace();
+ debug << "QScreen(" << (void *)screen;
+ if (screen) {
+ debug << ", name=" << screen->name();
+ if (debug.verbosity() > 2) {
+ if (screen == QGuiApplication::primaryScreen())
+ debug << ", primary";
+ debug << ", geometry=";
+ formatRect(debug, screen->geometry());
+ debug << ", available=";
+ formatRect(debug, screen->availableGeometry());
+ debug << ", logical DPI=" << screen->logicalDotsPerInchX()
+ << ',' << screen->logicalDotsPerInchY()
+ << ", physical DPI=" << screen->physicalDotsPerInchX()
+ << ',' << screen->physicalDotsPerInchY()
+ << ", devicePixelRatio=" << screen->devicePixelRatio()
+ << ", orientation=" << screen->orientation()
+ << ", physical size=" << screen->physicalSize().width()
+ << 'x' << screen->physicalSize().height() << "mm";
+ }
+ }
+ debug << ')';
+ return debug;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h
index 255e735baf..f60fafcf63 100644
--- a/src/gui/kernel/qscreen.h
+++ b/src/gui/kernel/qscreen.h
@@ -52,6 +52,9 @@ class QScreenPrivate;
class QWindow;
class QRect;
class QPixmap;
+#ifndef QT_NO_DEBUG_STREAM
+class QDebug;
+#endif
class Q_GUI_EXPORT QScreen : public QObject
{
@@ -153,6 +156,10 @@ private:
friend class QPlatformScreen;
};
+#ifndef QT_NO_DEBUG_STREAM
+Q_GUI_EXPORT QDebug operator<<(QDebug, const QScreen *);
+#endif
+
QT_END_NAMESPACE
#endif // QSCREEN_H
diff --git a/src/gui/kernel/qtouchdevice.cpp b/src/gui/kernel/qtouchdevice.cpp
index 1a6e9deba8..9d19fa4b92 100644
--- a/src/gui/kernel/qtouchdevice.cpp
+++ b/src/gui/kernel/qtouchdevice.cpp
@@ -195,7 +195,7 @@ void QTouchDevice::setName(const QString &name)
d->name = name;
}
-typedef QList<QTouchDevice *> TouchDevices;
+typedef QList<const QTouchDevice *> TouchDevices;
Q_GLOBAL_STATIC(TouchDevices, deviceList)
static QBasicMutex devicesMutex;
@@ -214,26 +214,22 @@ static void cleanupDevicesList()
QList<const QTouchDevice *> QTouchDevice::devices()
{
QMutexLocker lock(&devicesMutex);
- QList<QTouchDevice *> *devList = deviceList();
- QList<const QTouchDevice *> constDevList;
- for (int i = 0, count = devList->count(); i != count; ++i)
- constDevList.append(devList->at(i));
- return constDevList;
+ return *deviceList();
}
/*!
\internal
*/
-bool QTouchDevicePrivate::isRegistered(QTouchDevice *dev)
+bool QTouchDevicePrivate::isRegistered(const QTouchDevice *dev)
{
- QMutexLocker lock(&devicesMutex);
+ QMutexLocker locker(&devicesMutex);
return deviceList()->contains(dev);
}
/*!
\internal
*/
-void QTouchDevicePrivate::registerDevice(QTouchDevice *dev)
+void QTouchDevicePrivate::registerDevice(const QTouchDevice *dev)
{
QMutexLocker lock(&devicesMutex);
if (deviceList()->isEmpty())
diff --git a/src/gui/kernel/qtouchdevice_p.h b/src/gui/kernel/qtouchdevice_p.h
index 9c0bcf3414..4aff8f2f33 100644
--- a/src/gui/kernel/qtouchdevice_p.h
+++ b/src/gui/kernel/qtouchdevice_p.h
@@ -45,7 +45,6 @@
// We mean it.
//
-#include <QtCore/qobject.h>
#include <QtGui/qtouchdevice.h>
QT_BEGIN_NAMESPACE
@@ -65,8 +64,8 @@ public:
QString name;
int maxTouchPoints;
- static void registerDevice(QTouchDevice *dev);
- static bool isRegistered(QTouchDevice *dev);
+ static void registerDevice(const QTouchDevice *dev);
+ static bool isRegistered(const QTouchDevice *dev);
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index b54e85a1d3..81e00c8d95 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -2471,6 +2471,45 @@ void QWindowPrivate::applyCursor()
}
#endif // QT_NO_CURSOR
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug debug, const QWindow *window)
+{
+ QDebugStateSaver saver(debug);
+ debug.nospace();
+ if (window) {
+ debug << window->metaObject()->className() << '(' << (void *)window;
+ if (!window->objectName().isEmpty())
+ debug << ", name=" << window->objectName();
+ if (debug.verbosity() > 2) {
+ const QRect geometry = window->geometry();
+ if (window->isVisible())
+ debug << ", visible";
+ if (window->isExposed())
+ debug << ", exposed";
+ debug << ", state=" << window->windowState()
+ << ", type=" << window->type() << ", flags=" << window->flags()
+ << ", surface type=" << window->surfaceType();
+ if (window->isTopLevel())
+ debug << ", toplevel";
+ debug << ", " << geometry.width() << 'x' << geometry.height()
+ << forcesign << geometry.x() << geometry.y() << noforcesign;
+ const QMargins margins = window->frameMargins();
+ if (!margins.isNull())
+ debug << ", margins=" << margins;
+ debug << ", devicePixelRatio=" << window->devicePixelRatio();
+ if (const QPlatformWindow *platformWindow = window->handle())
+ debug << ", winId=0x" << hex << platformWindow->winId() << dec;
+ if (const QScreen *screen = window->screen())
+ debug << ", on " << screen->name();
+ }
+ debug << ')';
+ } else {
+ debug << "QWindow(0x0)";
+ }
+ return debug;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
QT_END_NAMESPACE
#include "moc_qwindow.cpp"
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index f9fe37718c..67585ce963 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -78,6 +78,9 @@ class QBackingStore;
class QScreen;
class QAccessibleInterface;
class QWindowContainer;
+#ifndef QT_NO_DEBUG_STREAM
+class QDebug;
+#endif
class Q_GUI_EXPORT QWindow : public QObject, public QSurface
{
@@ -367,6 +370,10 @@ template <> inline const QWindow *qobject_cast<const QWindow*>(const QObject *o)
}
#endif // !Q_QDOC
+#ifndef QT_NO_DEBUG_STREAM
+Q_GUI_EXPORT QDebug operator<<(QDebug, const QWindow *);
+#endif
+
QT_END_NAMESPACE
#endif // QWINDOW_H
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index b17978cb7d..17bce6c70f 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -45,9 +45,10 @@ QT_BEGIN_NAMESPACE
QElapsedTimer QWindowSystemInterfacePrivate::eventTime;
-bool QWindowSystemInterfacePrivate::synchronousWindowsSystemEvents = false;
+bool QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = false;
QWaitCondition QWindowSystemInterfacePrivate::eventsFlushed;
QMutex QWindowSystemInterfacePrivate::flushEventMutex;
+QWindowSystemEventHandler *QWindowSystemInterfacePrivate::eventHandler;
//------------------------------------------------------------
//
@@ -93,14 +94,14 @@ void QWindowSystemInterface::handleLeaveEvent(QWindow *tlw)
*/
void QWindowSystemInterface::handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local, const QPointF& global)
{
- bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowsSystemEvents;
+ bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents;
if (wasSynchronous)
- setSynchronousWindowsSystemEvents(false);
+ setSynchronousWindowSystemEvents(false);
handleLeaveEvent(leave);
handleEnterEvent(enter, local, global);
if (wasSynchronous) {
flushWindowSystemEvents();
- setSynchronousWindowsSystemEvents(true);
+ setSynchronousWindowSystemEvents(true);
}
}
@@ -425,8 +426,9 @@ void QWindowSystemInterfacePrivate::removeWindowSystemEvent(WindowSystemEvent *e
void QWindowSystemInterfacePrivate::handleWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
{
- if (synchronousWindowsSystemEvents) {
+ if (synchronousWindowSystemEvents) {
QGuiApplicationPrivate::processWindowSystemEvent(ev);
+ delete ev;
} else {
windowSystemEventQueue.append(ev);
QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::qt_qpa_core_dispatcher();
@@ -453,6 +455,7 @@ QList<QTouchEvent::TouchPoint> QWindowSystemInterfacePrivate::convertTouchPoints
Qt::TouchPointStates states;
QTouchEvent::TouchPoint p;
+ touchPoints.reserve(points.count());
QList<QWindowSystemInterface::TouchPoint>::const_iterator point = points.constBegin();
QList<QWindowSystemInterface::TouchPoint>::const_iterator end = points.constEnd();
while (point != end) {
@@ -604,17 +607,35 @@ bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFla
QWindowSystemInterfacePrivate::getWindowSystemEvent();
if (!event)
break;
- nevents++;
- QGuiApplicationPrivate::processWindowSystemEvent(event);
+
+ if (QWindowSystemInterfacePrivate::eventHandler) {
+ if (QWindowSystemInterfacePrivate::eventHandler->sendEvent(event))
+ nevents++;
+ } else {
+ nevents++;
+ QGuiApplicationPrivate::processWindowSystemEvent(event);
+ }
delete event;
}
return (nevents > 0);
}
-void QWindowSystemInterface::setSynchronousWindowsSystemEvents(bool enable)
+void QWindowSystemInterfacePrivate::installWindowSystemEventHandler(QWindowSystemEventHandler *handler)
+{
+ if (!eventHandler)
+ eventHandler = handler;
+}
+
+void QWindowSystemInterfacePrivate::removeWindowSystemEventhandler(QWindowSystemEventHandler *handler)
+{
+ if (eventHandler == handler)
+ eventHandler = 0;
+}
+
+void QWindowSystemInterface::setSynchronousWindowSystemEvents(bool enable)
{
- QWindowSystemInterfacePrivate::synchronousWindowsSystemEvents = enable;
+ QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = enable;
}
int QWindowSystemInterface::windowSystemEventsQueued()
@@ -790,13 +811,26 @@ Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPo
}
#endif
-Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier) {
- QWindowSystemInterface::handleMouseEvent(w, local, global, b, mods);
+Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods, int timestamp)
+{
+ QWindowSystemInterfacePrivate::MouseEvent e(w, timestamp, local, global, b, mods, Qt::MouseEventNotSynthesized);
+ QGuiApplicationPrivate::processWindowSystemEvent(&e);
}
Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
{
- QWindowSystemInterface::handleKeyEvent(w, t, k, mods, text, autorep, count);
+ unsigned long timestamp = QWindowSystemInterfacePrivate::eventTime.elapsed();
+
+ // This is special handling needed for OS X which eventually will call sendEvent(), on other platforms
+ // this might not be safe, e.g., on Android. See: QGuiApplicationPrivate::processKeyEvent() for
+ // shortcut overriding on other platforms.
+#if defined(Q_OS_OSX)
+ if (t == QEvent::KeyPress && QWindowSystemInterface::tryHandleShortcutEvent(w, timestamp, k, mods, text))
+ return;
+#endif // Q_OS_OSX
+
+ QWindowSystemInterfacePrivate::KeyEvent e(w, timestamp, t, k, mods, text, autorep, count);
+ QGuiApplicationPrivate::processWindowSystemEvent(&e);
}
Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1)
@@ -804,35 +838,49 @@ Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int
return QWindowSystemInterface::tryHandleShortcutEventToObject(o, timestamp, k, mods, text, autorep, count);
}
-static QWindowSystemInterface::TouchPoint touchPoint(const QTouchEvent::TouchPoint& pt)
-{
- QWindowSystemInterface::TouchPoint p;
- p.id = pt.id();
- p.flags = pt.flags();
- p.normalPosition = pt.normalizedPos();
- p.area = pt.screenRect();
- p.pressure = pt.pressure();
- p.state = pt.state();
- p.velocity = pt.velocity();
- p.rawPositions = pt.rawScreenPositions();
- return p;
-}
-static QList<struct QWindowSystemInterface::TouchPoint> touchPointList(const QList<QTouchEvent::TouchPoint>& pointList)
+
+Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device,
+ const QList<QTouchEvent::TouchPoint> &points,
+ Qt::KeyboardModifiers mods = Qt::NoModifier)
{
- QList<struct QWindowSystemInterface::TouchPoint> newList;
+ unsigned long timestamp = QWindowSystemInterfacePrivate::eventTime.elapsed();
+
+ if (!points.size()) // Touch events must have at least one point
+ return;
+
+ if (!QTouchDevicePrivate::isRegistered(device)) // Disallow passing bogus, non-registered devices.
+ return;
+
+ QEvent::Type type;
+ Qt::TouchPointStates states;
- Q_FOREACH (QTouchEvent::TouchPoint p, pointList)
- {
- newList.append(touchPoint(p));
+ QList<QTouchEvent::TouchPoint>::const_iterator point = points.constBegin();
+ QList<QTouchEvent::TouchPoint>::const_iterator end = points.constEnd();
+ while (point != end) {
+ states |= point->state();
+ ++point;
}
- return newList;
+
+ // Determine the event type based on the combined point states.
+ type = QEvent::TouchUpdate;
+ if (states == Qt::TouchPointPressed)
+ type = QEvent::TouchBegin;
+ else if (states == Qt::TouchPointReleased)
+ type = QEvent::TouchEnd;
+
+ QWindowSystemInterfacePrivate::TouchEvent e(w, timestamp, type, device, points, mods);
+ QGuiApplicationPrivate::processWindowSystemEvent(&e);
}
-Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device,
- const QList<QTouchEvent::TouchPoint> &points,
- Qt::KeyboardModifiers mods = Qt::NoModifier)
+QWindowSystemEventHandler::~QWindowSystemEventHandler()
+{
+ QWindowSystemInterfacePrivate::removeWindowSystemEventhandler(this);
+}
+
+bool QWindowSystemEventHandler::sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
{
- QWindowSystemInterface::handleTouchEvent(w, device, touchPointList(points), mods);
+ QGuiApplicationPrivate::processWindowSystemEvent(e);
+ return true;
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index c004fc6ef2..7ad491cdac 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -210,7 +210,7 @@ public:
// For event dispatcher implementations
static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
- static void setSynchronousWindowsSystemEvents(bool enable);
+ static void setSynchronousWindowSystemEvents(bool enable);
static void flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
static void deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
static int windowSystemEventsQueued();
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index 2ec402a1e9..7160971305 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -54,6 +54,8 @@
QT_BEGIN_NAMESPACE
+class QWindowSystemEventHandler;
+
class Q_GUI_EXPORT QWindowSystemInterfacePrivate {
public:
enum EventType {
@@ -481,12 +483,23 @@ public:
static void handleWindowSystemEvent(WindowSystemEvent *ev);
static QElapsedTimer eventTime;
- static bool synchronousWindowsSystemEvents;
+ static bool synchronousWindowSystemEvents;
static QWaitCondition eventsFlushed;
static QMutex flushEventMutex;
static QList<QTouchEvent::TouchPoint> convertTouchPoints(const QList<QWindowSystemInterface::TouchPoint> &points, QEvent::Type *type);
+
+ static void installWindowSystemEventHandler(QWindowSystemEventHandler *handler);
+ static void removeWindowSystemEventhandler(QWindowSystemEventHandler *handler);
+ static QWindowSystemEventHandler *eventHandler;
+};
+
+class Q_GUI_EXPORT QWindowSystemEventHandler
+{
+public:
+ virtual ~QWindowSystemEventHandler();
+ virtual bool sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *event);
};
QT_END_NAMESPACE
diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp
index 1c008ccb42..68cd8a82b4 100644
--- a/src/gui/opengl/qopengl.cpp
+++ b/src/gui/opengl/qopengl.cpp
@@ -135,20 +135,42 @@ static const char operators[][3] = {"!=", "<", "<=", "=", ">", ">="};
static inline QString valueKey() { return QStringLiteral("value"); }
static inline QString opKey() { return QStringLiteral("op"); }
static inline QString versionKey() { return QStringLiteral("version"); }
+static inline QString releaseKey() { return QStringLiteral("release"); }
static inline QString typeKey() { return QStringLiteral("type"); }
static inline QString osKey() { return QStringLiteral("os"); }
static inline QString vendorIdKey() { return QStringLiteral("vendor_id"); }
static inline QString glVendorKey() { return QStringLiteral("gl_vendor"); }
static inline QString deviceIdKey() { return QStringLiteral("device_id"); }
static inline QString driverVersionKey() { return QStringLiteral("driver_version"); }
+static inline QString driverDescriptionKey() { return QStringLiteral("driver_description"); }
static inline QString featuresKey() { return QStringLiteral("features"); }
static inline QString idKey() { return QStringLiteral("id"); }
static inline QString descriptionKey() { return QStringLiteral("description"); }
static inline QString exceptionsKey() { return QStringLiteral("exceptions"); }
+typedef QJsonArray::ConstIterator JsonArrayConstIt;
+
+static inline bool contains(const QJsonArray &haystack, unsigned needle)
+{
+ for (JsonArrayConstIt it = haystack.constBegin(), cend = haystack.constEnd(); it != cend; ++it) {
+ if (needle == it->toString().toUInt(Q_NULLPTR, /* base */ 0))
+ return true;
+ }
+ return false;
+}
+
+static inline bool contains(const QJsonArray &haystack, const QString &needle)
+{
+ for (JsonArrayConstIt it = haystack.constBegin(), cend = haystack.constEnd(); it != cend; ++it) {
+ if (needle == it->toString())
+ return true;
+ }
+ return false;
+}
+
namespace {
// VersionTerm describing a version term consisting of number and operator
-// found in "os", "driver_version", "gl_version".
+// found in os.version and driver_version.
struct VersionTerm {
VersionTerm() : op(NotEqual) {}
static VersionTerm fromJson(const QJsonValue &v);
@@ -206,9 +228,38 @@ struct OsTypeTerm
static OsTypeTerm fromJson(const QJsonValue &v);
static QString hostOs();
static QVersionNumber hostKernelVersion() { return QVersionNumber::fromString(QSysInfo::kernelVersion()); }
+ static QString hostOsRelease() {
+ QString ver;
+#ifdef Q_OS_WIN
+ switch (QSysInfo::windowsVersion()) {
+ case QSysInfo::WV_XP:
+ case QSysInfo::WV_2003:
+ ver = QStringLiteral("xp");
+ break;
+ case QSysInfo::WV_VISTA:
+ ver = QStringLiteral("vista");
+ break;
+ case QSysInfo::WV_WINDOWS7:
+ ver = QStringLiteral("7");
+ break;
+ case QSysInfo::WV_WINDOWS8:
+ ver = QStringLiteral("8");
+ break;
+ case QSysInfo::WV_WINDOWS8_1:
+ ver = QStringLiteral("8.1");
+ break;
+ case QSysInfo::WV_WINDOWS10:
+ ver = QStringLiteral("10");
+ break;
+ default:
+ break;
+ }
+#endif
+ return ver;
+ }
bool isNull() const { return type.isEmpty(); }
- bool matches(const QString &osName, const QVersionNumber &kernelVersion) const
+ bool matches(const QString &osName, const QVersionNumber &kernelVersion, const QString &osRelease) const
{
if (isNull() || osName.isEmpty() || kernelVersion.isNull()) {
qWarning() << Q_FUNC_INFO << "called with invalid parameters";
@@ -216,11 +267,17 @@ struct OsTypeTerm
}
if (type != osName)
return false;
- return versionTerm.isNull() || versionTerm.matches(kernelVersion);
+ if (!versionTerm.isNull() && !versionTerm.matches(kernelVersion))
+ return false;
+ // release is a list of Windows versions where the rule should match
+ if (!release.isEmpty() && !contains(release, osRelease))
+ return false;
+ return true;
}
QString type;
VersionTerm versionTerm;
+ QJsonArray release;
};
OsTypeTerm OsTypeTerm::fromJson(const QJsonValue &v)
@@ -231,6 +288,7 @@ OsTypeTerm OsTypeTerm::fromJson(const QJsonValue &v)
const QJsonObject o = v.toObject();
result.type = o.value(typeKey()).toString();
result.versionTerm = VersionTerm::fromJson(o.value(versionKey()));
+ result.release = o.value(releaseKey()).toArray();
return result;
}
@@ -251,17 +309,6 @@ QString OsTypeTerm::hostOs()
}
} // anonymous namespace
-typedef QJsonArray::ConstIterator JsonArrayConstIt;
-
-static inline bool contains(const QJsonArray &a, unsigned needle)
-{
- for (JsonArrayConstIt it = a.constBegin(), cend = a.constEnd(); it != cend; ++it) {
- if (needle == it->toString().toUInt(Q_NULLPTR, /* base */ 0))
- return true;
- }
- return false;
-}
-
static QString msgSyntaxWarning(const QJsonObject &object, const QString &what)
{
QString result;
@@ -277,17 +324,18 @@ static QString msgSyntaxWarning(const QJsonObject &object, const QString &what)
static bool matches(const QJsonObject &object,
const QString &osName,
const QVersionNumber &kernelVersion,
+ const QString &osRelease,
const QOpenGLConfig::Gpu &gpu)
{
const OsTypeTerm os = OsTypeTerm::fromJson(object.value(osKey()));
- if (!os.isNull() && !os.matches(osName, kernelVersion))
+ if (!os.isNull() && !os.matches(osName, kernelVersion, osRelease))
return false;
const QJsonValue exceptionsV = object.value(exceptionsKey());
if (exceptionsV.isArray()) {
const QJsonArray exceptionsA = exceptionsV.toArray();
for (JsonArrayConstIt it = exceptionsA.constBegin(), cend = exceptionsA.constEnd(); it != cend; ++it) {
- if (matches(it->toObject(), osName, kernelVersion, gpu))
+ if (matches(it->toObject(), osName, kernelVersion, osRelease, gpu))
return false;
}
}
@@ -336,12 +384,22 @@ static bool matches(const QJsonObject &object,
QLatin1String("Driver version must be of type object."));
}
}
+
+ if (!gpu.driverDescription.isEmpty()) {
+ const QJsonValue driverDescriptionV = object.value(driverDescriptionKey());
+ if (driverDescriptionV.isString()) {
+ if (!gpu.driverDescription.contains(driverDescriptionV.toString().toUtf8()))
+ return false;
+ }
+ }
+
return true;
}
static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu,
const QString &osName,
const QVersionNumber &kernelVersion,
+ const QString &osRelease,
const QJsonDocument &doc,
QSet<QString> *result,
QString *errorMessage)
@@ -358,7 +416,7 @@ static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu,
for (JsonArrayConstIt eit = entriesA.constBegin(), ecend = entriesA.constEnd(); eit != ecend; ++eit) {
if (eit->isObject()) {
const QJsonObject object = eit->toObject();
- if (matches(object, osName, kernelVersion, gpu)) {
+ if (matches(object, osName, kernelVersion, osRelease, gpu)) {
const QJsonValue featuresListV = object.value(featuresKey());
if (featuresListV.isArray()) {
const QJsonArray featuresListA = featuresListV.toArray();
@@ -374,6 +432,7 @@ static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu,
static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu,
const QString &osName,
const QVersionNumber &kernelVersion,
+ const QString &osRelease,
const QByteArray &jsonAsciiData,
QSet<QString> *result, QString *errorMessage)
{
@@ -389,12 +448,13 @@ static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu,
<< error.offset << ").";
return false;
}
- return readGpuFeatures(gpu, osName, kernelVersion, document, result, errorMessage);
+ return readGpuFeatures(gpu, osName, kernelVersion, osRelease, document, result, errorMessage);
}
static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu,
const QString &osName,
const QVersionNumber &kernelVersion,
+ const QString &osRelease,
const QString &fileName,
QSet<QString> *result, QString *errorMessage)
{
@@ -407,7 +467,7 @@ static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu,
<< file.errorString();
return false;
}
- const bool success = readGpuFeatures(gpu, osName, kernelVersion, file.readAll(), result, errorMessage);
+ const bool success = readGpuFeatures(gpu, osName, kernelVersion, osRelease, file.readAll(), result, errorMessage);
if (!success) {
errorMessage->prepend(QLatin1String("Error reading \"")
+ QDir::toNativeSeparators(fileName)
@@ -417,37 +477,39 @@ static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu,
}
QSet<QString> QOpenGLConfig::gpuFeatures(const QOpenGLConfig::Gpu &gpu,
- const QString &osName,
- const QVersionNumber &kernelVersion,
- const QJsonDocument &doc)
+ const QString &osName,
+ const QVersionNumber &kernelVersion,
+ const QString &osRelease,
+ const QJsonDocument &doc)
{
QSet<QString> result;
QString errorMessage;
- if (!readGpuFeatures(gpu, osName, kernelVersion, doc, &result, &errorMessage))
+ if (!readGpuFeatures(gpu, osName, kernelVersion, osRelease, doc, &result, &errorMessage))
qWarning().noquote() << errorMessage;
return result;
}
QSet<QString> QOpenGLConfig::gpuFeatures(const QOpenGLConfig::Gpu &gpu,
- const QString &osName,
- const QVersionNumber &kernelVersion,
- const QString &fileName)
+ const QString &osName,
+ const QVersionNumber &kernelVersion,
+ const QString &osRelease,
+ const QString &fileName)
{
QSet<QString> result;
QString errorMessage;
- if (!readGpuFeatures(gpu, osName, kernelVersion, fileName, &result, &errorMessage))
+ if (!readGpuFeatures(gpu, osName, kernelVersion, osRelease, fileName, &result, &errorMessage))
qWarning().noquote() << errorMessage;
return result;
}
QSet<QString> QOpenGLConfig::gpuFeatures(const Gpu &gpu, const QJsonDocument &doc)
{
- return gpuFeatures(gpu, OsTypeTerm::hostOs(), OsTypeTerm::hostKernelVersion(), doc);
+ return gpuFeatures(gpu, OsTypeTerm::hostOs(), OsTypeTerm::hostKernelVersion(), OsTypeTerm::hostOsRelease(), doc);
}
QSet<QString> QOpenGLConfig::gpuFeatures(const Gpu &gpu, const QString &fileName)
{
- return gpuFeatures(gpu, OsTypeTerm::hostOs(), OsTypeTerm::hostKernelVersion(), fileName);
+ return gpuFeatures(gpu, OsTypeTerm::hostOs(), OsTypeTerm::hostKernelVersion(), OsTypeTerm::hostOsRelease(), fileName);
}
QOpenGLConfig::Gpu QOpenGLConfig::Gpu::fromContext()
diff --git a/src/gui/opengl/qopengl_p.h b/src/gui/opengl/qopengl_p.h
index 980e02aea6..31a083d96f 100644
--- a/src/gui/opengl/qopengl_p.h
+++ b/src/gui/opengl/qopengl_p.h
@@ -79,19 +79,21 @@ public:
bool isValid() const { return deviceId || !glVendor.isEmpty(); }
bool equals(const Gpu &other) const {
return vendorId == other.vendorId && deviceId == other.deviceId && driverVersion == other.driverVersion
- && glVendor == other.glVendor;
+ && driverDescription == other.driverDescription && glVendor == other.glVendor;
}
uint vendorId;
uint deviceId;
QVersionNumber driverVersion;
+ QByteArray driverDescription;
QByteArray glVendor;
- static Gpu fromDevice(uint vendorId, uint deviceId, QVersionNumber driverVersion) {
+ static Gpu fromDevice(uint vendorId, uint deviceId, QVersionNumber driverVersion, const QByteArray &driverDescription) {
Gpu gpu;
gpu.vendorId = vendorId;
gpu.deviceId = deviceId;
gpu.driverVersion = driverVersion;
+ gpu.driverDescription = driverDescription;
return gpu;
}
@@ -105,10 +107,10 @@ public:
};
static QSet<QString> gpuFeatures(const Gpu &gpu,
- const QString &osName, const QVersionNumber &kernelVersion,
+ const QString &osName, const QVersionNumber &kernelVersion, const QString &osVersion,
const QJsonDocument &doc);
static QSet<QString> gpuFeatures(const Gpu &gpu,
- const QString &osName, const QVersionNumber &kernelVersion,
+ const QString &osName, const QVersionNumber &kernelVersion, const QString &osVersion,
const QString &fileName);
static QSet<QString> gpuFeatures(const Gpu &gpu, const QJsonDocument &doc);
static QSet<QString> gpuFeatures(const Gpu &gpu, const QString &fileName);
diff --git a/src/gui/opengl/qopengldebug.h b/src/gui/opengl/qopengldebug.h
index 425ab78d7a..d24940cb3c 100644
--- a/src/gui/opengl/qopengldebug.h
+++ b/src/gui/opengl/qopengldebug.h
@@ -97,14 +97,14 @@ public:
QOpenGLDebugMessage();
QOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage);
- ~QOpenGLDebugMessage();
QOpenGLDebugMessage &operator=(const QOpenGLDebugMessage &debugMessage);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QOpenGLDebugMessage &operator=(QOpenGLDebugMessage &&debugMessage)
- { d.swap(debugMessage.d); return *this; }
+ QOpenGLDebugMessage &operator=(QOpenGLDebugMessage &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- inline void swap(QOpenGLDebugMessage &debugMessage) { d.swap(debugMessage.d); }
+ ~QOpenGLDebugMessage();
+
+ void swap(QOpenGLDebugMessage &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
Source source() const;
Type type() const;
diff --git a/src/gui/opengl/qopenglextensions_p.h b/src/gui/opengl/qopenglextensions_p.h
index 7def687f49..e50ca1a94c 100644
--- a/src/gui/opengl/qopenglextensions_p.h
+++ b/src/gui/opengl/qopenglextensions_p.h
@@ -78,8 +78,9 @@ public:
private:
bool init();
QFunctionPointer resolve(const char *name);
-
+#ifndef QT_NO_LIBRARY
QLibrary m_gl;
+#endif
};
class Q_GUI_EXPORT QOpenGLExtensions : public QOpenGLFunctions
@@ -113,7 +114,8 @@ public:
GeometryShaders = 0x00080000,
MapBufferRange = 0x00100000,
Sized8Formats = 0x00200000,
- DiscardFramebuffer = 0x00400000
+ DiscardFramebuffer = 0x00400000,
+ Sized16Formats = 0x00800000
};
Q_DECLARE_FLAGS(OpenGLExtensions, OpenGLExtension)
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index 8ddb693e73..2b8488ab0e 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -423,11 +423,14 @@ static int qt_gl_resolve_extensions()
// We don't match GL_APPLE_texture_format_BGRA8888 here because it has different semantics.
if (extensionMatcher.match("GL_IMG_texture_format_BGRA8888") || extensionMatcher.match("GL_EXT_texture_format_BGRA8888"))
extensions |= QOpenGLExtensions::BGRATextureFormat;
-
if (extensionMatcher.match("GL_EXT_discard_framebuffer"))
extensions |= QOpenGLExtensions::DiscardFramebuffer;
+ if (extensionMatcher.match("GL_EXT_texture_norm16"))
+ extensions |= QOpenGLExtensions::Sized16Formats;
} else {
- extensions |= QOpenGLExtensions::ElementIndexUint | QOpenGLExtensions::MapBuffer;
+ extensions |= QOpenGLExtensions::ElementIndexUint
+ | QOpenGLExtensions::MapBuffer
+ | QOpenGLExtensions::Sized16Formats;
if (format.version() >= qMakePair(1, 2))
extensions |= QOpenGLExtensions::BGRATextureFormat;
@@ -3212,7 +3215,9 @@ Q_GLOBAL_STATIC(QOpenGLES3Helper, qgles3Helper)
bool QOpenGLES3Helper::init()
{
-#ifndef Q_OS_IOS
+#ifdef QT_NO_LIBRARY
+ return false;
+#elif !defined(Q_OS_IOS)
# ifdef Q_OS_WIN
# ifndef QT_DEBUG
m_gl.setFileName(QStringLiteral("libGLESv2"));
@@ -3236,8 +3241,11 @@ QFunctionPointer QOpenGLES3Helper::resolve(const char *name)
{
#ifdef Q_OS_IOS
return QFunctionPointer(dlsym(RTLD_DEFAULT, name));
-#else
+#elif !defined(QT_NO_LIBRARY)
return m_gl.resolve(name);
+#else
+ Q_UNUSED(name);
+ return 0;
#endif
}
diff --git a/src/gui/opengl/qopenglgradientcache.cpp b/src/gui/opengl/qopenglgradientcache.cpp
index ab493fa85c..13bad9aabb 100644
--- a/src/gui/opengl/qopenglgradientcache.cpp
+++ b/src/gui/opengl/qopenglgradientcache.cpp
@@ -34,8 +34,14 @@
#include "qopenglgradientcache_p.h"
#include <private/qdrawhelper_p.h>
#include <private/qopenglcontext_p.h>
+#include <private/qrgba64_p.h>
#include <QtCore/qmutex.h>
-#include <QtGui/qopenglfunctions.h>
+#include "qopenglfunctions.h"
+#include "qopenglextensions_p.h"
+
+#ifndef GL_RGBA16
+#define GL_RGBA16 0x805B
+#endif
QT_BEGIN_NAMESPACE
@@ -137,17 +143,79 @@ GLuint QOpenGL2GradientCache::addCacheElement(quint64 hash_val, const QGradient
}
CacheInfo cache_entry(gradient.stops(), opacity, gradient.interpolationMode());
- uint buffer[1024];
- generateGradientColorTable(gradient, buffer, paletteSize(), opacity);
funcs->glGenTextures(1, &cache_entry.texId);
funcs->glBindTexture(GL_TEXTURE_2D, cache_entry.texId);
- funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, paletteSize(), 1,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+ if (static_cast<QOpenGLExtensions *>(funcs)->hasOpenGLExtension(QOpenGLExtensions::Sized16Formats)) {
+ QRgba64 buffer[1024];
+ generateGradientColorTable(gradient, buffer, paletteSize(), opacity);
+ funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, paletteSize(), 1,
+ 0, GL_RGBA, GL_UNSIGNED_SHORT, buffer);
+ } else {
+ uint buffer[1024];
+ generateGradientColorTable(gradient, buffer, paletteSize(), opacity);
+ funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, paletteSize(), 1,
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+ }
return cache.insert(hash_val, cache_entry).value().texId;
}
//TODO: Let GL generate the texture using an FBO
+void QOpenGL2GradientCache::generateGradientColorTable(const QGradient& gradient, QRgba64 *colorTable, int size, qreal opacity) const
+{
+ int pos = 0;
+ QGradientStops s = gradient.stops();
+ QVector<QRgba64> colors(s.size());
+
+ for (int i = 0; i < s.size(); ++i)
+ colors[i] = s[i].second.rgba64();
+
+ bool colorInterpolation = (gradient.interpolationMode() == QGradient::ColorInterpolation);
+
+ uint alpha = qRound(opacity * 256);
+ QRgba64 current_color = combineAlpha256(colors[0], alpha);
+ qreal incr = 1.0 / qreal(size);
+ qreal fpos = 1.5 * incr;
+ colorTable[pos++] = qPremultiply(current_color);
+
+ while (fpos <= s.first().first) {
+ colorTable[pos] = colorTable[pos - 1];
+ pos++;
+ fpos += incr;
+ }
+
+ if (colorInterpolation)
+ current_color = qPremultiply(current_color);
+
+ for (int i = 0; i < s.size() - 1; ++i) {
+ qreal delta = 1/(s[i+1].first - s[i].first);
+ QRgba64 next_color = combineAlpha256(colors[i+1], alpha);
+ if (colorInterpolation)
+ next_color = qPremultiply(next_color);
+
+ while (fpos < s[i+1].first && pos < size) {
+ int dist = int(256 * ((fpos - s[i].first) * delta));
+ int idist = 256 - dist;
+ if (colorInterpolation)
+ colorTable[pos] = interpolate256(current_color, idist, next_color, dist);
+ else
+ colorTable[pos] = qPremultiply(interpolate256(current_color, idist, next_color, dist));
+ ++pos;
+ fpos += incr;
+ }
+ current_color = next_color;
+ }
+
+ Q_ASSERT(s.size() > 0);
+
+ QRgba64 last_color = qPremultiply(combineAlpha256(colors[s.size() - 1], alpha));
+ for (;pos < size; ++pos)
+ colorTable[pos] = last_color;
+
+ // Make sure the last color stop is represented at the end of the table
+ colorTable[size-1] = last_color;
+}
+
void QOpenGL2GradientCache::generateGradientColorTable(const QGradient& gradient, uint *colorTable, int size, qreal opacity) const
{
int pos = 0;
diff --git a/src/gui/opengl/qopenglgradientcache_p.h b/src/gui/opengl/qopenglgradientcache_p.h
index bcdf3f4fcf..61949d5b7c 100644
--- a/src/gui/opengl/qopenglgradientcache_p.h
+++ b/src/gui/opengl/qopenglgradientcache_p.h
@@ -50,6 +50,7 @@
#include <private/qopenglcontext_p.h>
#include <QtCore/qmutex.h>
#include <QGradient>
+#include <qrgba64.h>
QT_BEGIN_NAMESPACE
@@ -83,6 +84,9 @@ public:
private:
inline int maxCacheSize() const { return 60; }
inline void generateGradientColorTable(const QGradient& gradient,
+ QRgba64 *colorTable,
+ int size, qreal opacity) const;
+ inline void generateGradientColorTable(const QGradient& gradient,
uint *colorTable,
int size, qreal opacity) const;
GLuint addCacheElement(quint64 hash_val, const QGradient &gradient, qreal opacity);
diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp
index c0657feaa0..e509b26a95 100644
--- a/src/gui/opengl/qopenglpaintdevice.cpp
+++ b/src/gui/opengl/qopenglpaintdevice.cpp
@@ -169,6 +169,10 @@ QOpenGLPaintDevicePrivate::QOpenGLPaintDevicePrivate(const QSize &sz)
{
}
+QOpenGLPaintDevicePrivate::~QOpenGLPaintDevicePrivate()
+{
+}
+
class QOpenGLEngineThreadStorage
{
public:
diff --git a/src/gui/opengl/qopenglpaintdevice_p.h b/src/gui/opengl/qopenglpaintdevice_p.h
index 57d93ee80a..54ea09240d 100644
--- a/src/gui/opengl/qopenglpaintdevice_p.h
+++ b/src/gui/opengl/qopenglpaintdevice_p.h
@@ -56,7 +56,7 @@ class Q_GUI_EXPORT QOpenGLPaintDevicePrivate
{
public:
QOpenGLPaintDevicePrivate(const QSize &size);
- virtual ~QOpenGLPaintDevicePrivate() { }
+ virtual ~QOpenGLPaintDevicePrivate();
static QOpenGLPaintDevicePrivate *get(QOpenGLPaintDevice *dev) { return dev->d_func(); }
diff --git a/src/gui/opengl/qopenglpixeltransferoptions.h b/src/gui/opengl/qopenglpixeltransferoptions.h
index bf726813bd..cb4697ec7c 100644
--- a/src/gui/opengl/qopenglpixeltransferoptions.h
+++ b/src/gui/opengl/qopenglpixeltransferoptions.h
@@ -49,15 +49,14 @@ class Q_GUI_EXPORT QOpenGLPixelTransferOptions
public:
QOpenGLPixelTransferOptions();
QOpenGLPixelTransferOptions(const QOpenGLPixelTransferOptions &);
- QOpenGLPixelTransferOptions &operator=(const QOpenGLPixelTransferOptions &);
- ~QOpenGLPixelTransferOptions();
-
#ifdef Q_COMPILER_RVALUE_REFS
- QOpenGLPixelTransferOptions &operator=(QOpenGLPixelTransferOptions &&other)
+ QOpenGLPixelTransferOptions &operator=(QOpenGLPixelTransferOptions &&other) Q_DECL_NOTHROW
{ swap(other); return *this; }
#endif
+ QOpenGLPixelTransferOptions &operator=(const QOpenGLPixelTransferOptions &);
+ ~QOpenGLPixelTransferOptions();
- void swap(QOpenGLPixelTransferOptions &other)
+ void swap(QOpenGLPixelTransferOptions &other) Q_DECL_NOTHROW
{ data.swap(other.data); }
void setAlignment(int alignment);
diff --git a/src/gui/opengl/qopenglversionfunctions.h b/src/gui/opengl/qopenglversionfunctions.h
index fcf665f97e..2fd3b9dab9 100644
--- a/src/gui/opengl/qopenglversionfunctions.h
+++ b/src/gui/opengl/qopenglversionfunctions.h
@@ -47,7 +47,10 @@
#ifndef QT_NO_OPENGL
+#if QT_DEPRECATED_SINCE(5, 5)
#include <QtCore/qhash.h>
+#endif
+#include <QtCore/qhashfunctions.h>
#include <QtCore/qpair.h>
#include <QtGui/qopengl.h>
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index a861516821..791b5f1a9a 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -43,6 +43,8 @@ HEADERS += \
painting/qrasterizer_p.h \
painting/qregion.h \
painting/qrgb.h \
+ painting/qrgba64.h \
+ painting/qrgba64_p.h \
painting/qstroker_p.h \
painting/qtextureglyphcache_p.h \
painting/qtransform.h \
@@ -58,6 +60,7 @@ SOURCES += \
painting/qbrush.cpp \
painting/qcolor.cpp \
painting/qcolor_p.cpp \
+ painting/qcompositionfunctions.cpp \
painting/qcosmeticstroker.cpp \
painting/qcssutil.cpp \
painting/qdrawhelper.cpp \
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 670717c5f1..d6eb8d8a48 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -1163,6 +1163,7 @@ QDataStream &operator>>(QDataStream &s, QBrush &b)
QColor c;
s >> numStops;
+ stops.reserve(numStops);
for (quint32 i = 0; i < numStops; ++i) {
s >> n >> c;
stops << QPair<qreal, QColor>(n, c);
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index d50c42f1ee..f1ceb464c8 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -416,6 +416,18 @@ QColor::QColor(QRgb color)
ct.argb.pad = 0;
}
+/*!
+ \since 5.6
+
+ Constructs a color with the value \a rgba64.
+
+ \sa fromRgba64()
+*/
+
+QColor::QColor(QRgba64 rgba64)
+{
+ setRgba64(rgba64);
+}
/*!
\internal
@@ -941,7 +953,7 @@ void QColor::setRgb(int r, int g, int b, int a)
For an invalid color, the alpha value of the returned color is unspecified.
- \sa setRgba(), rgb()
+ \sa setRgba(), rgb(), rgba64()
*/
QRgb QColor::rgba() const
@@ -954,7 +966,7 @@ QRgb QColor::rgba() const
/*!
Sets the RGB value to \a rgba, including its alpha.
- \sa rgba(), rgb()
+ \sa rgba(), rgb(), setRgba64()
*/
void QColor::setRgba(QRgb rgba)
{
@@ -967,6 +979,40 @@ void QColor::setRgba(QRgb rgba)
}
/*!
+ \since 5.6
+
+ Returns the RGB64 value of the color, including its alpha.
+
+ For an invalid color, the alpha value of the returned color is unspecified.
+
+ \sa setRgba64(), rgba(), rgb()
+*/
+
+QRgba64 QColor::rgba64() const
+{
+ if (cspec != Invalid && cspec != Rgb)
+ return toRgb().rgba64();
+ return qRgba64(ct.argb.red, ct.argb.green, ct.argb.blue, ct.argb.alpha);
+}
+
+/*!
+ \since 5.6
+
+ Sets the RGB64 value to \a rgba, including its alpha.
+
+ \sa \setRgba(), rgba64()
+*/
+void QColor::setRgba64(QRgba64 rgba)
+{
+ cspec = Rgb;
+ ct.argb.alpha = rgba.alpha();
+ ct.argb.red = rgba.red();
+ ct.argb.green = rgba.green();
+ ct.argb.blue = rgba.blue();
+ ct.argb.pad = 0;
+}
+
+/*!
\fn QRgb QColor::rgb() const
Returns the RGB value of the color. The alpha value is opaque.
@@ -1850,7 +1896,7 @@ QColor QColor::fromRgb(QRgb rgb)
Unlike the fromRgb() function, the alpha-channel specified by the given
QRgb value is included.
- \sa fromRgb(), isValid()
+ \sa fromRgb(), fromRgba64(), isValid()
*/
QColor QColor::fromRgba(QRgb rgba)
@@ -1865,7 +1911,7 @@ QColor QColor::fromRgba(QRgb rgba)
All the values must be in the range 0-255.
- \sa toRgb(), fromRgbF(), isValid()
+ \sa toRgb(), fromRgba64(), fromRgbF(), isValid()
*/
QColor QColor::fromRgb(int r, int g, int b, int a)
{
@@ -1894,7 +1940,7 @@ QColor QColor::fromRgb(int r, int g, int b, int a)
All the values must be in the range 0.0-1.0.
- \sa fromRgb(), toRgb(), isValid()
+ \sa fromRgb(), fromRgba64(), toRgb(), isValid()
*/
QColor QColor::fromRgbF(qreal r, qreal g, qreal b, qreal a)
{
@@ -1916,6 +1962,38 @@ QColor QColor::fromRgbF(qreal r, qreal g, qreal b, qreal a)
return color;
}
+
+/*!
+ \since 5.6
+
+ Static convenience function that returns a QColor constructed from the RGBA64
+ color values, \a r (red), \a g (green), \a b (blue), and \a a
+ (alpha-channel, i.e. transparency).
+
+ \sa fromRgb(), fromRgbF(), toRgb(), isValid()
+*/
+QColor QColor::fromRgba64(ushort r, ushort g, ushort b, ushort a)
+{
+ QColor color;
+ color.setRgba64(qRgba64(r, g, b, a));
+ return color;
+}
+
+/*!
+ \since 5.6
+
+ Static convenience function that returns a QColor constructed from the
+ given QRgba64 value \a rgba64.
+
+ \sa fromRgb(), fromRgbF(), toRgb(), isValid()
+*/
+QColor QColor::fromRgba64(QRgba64 rgba64)
+{
+ QColor color;
+ color.setRgba64(rgba64);
+ return color;
+}
+
/*!
Static convenience function that returns a QColor constructed from the HSV
color values, \a h (hue), \a s (saturation), \a v (value), and \a a
diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h
index 06c218365b..9175875310 100644
--- a/src/gui/painting/qcolor.h
+++ b/src/gui/painting/qcolor.h
@@ -37,6 +37,7 @@
#include <QtGui/qrgb.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qstringlist.h>
+#include <QtGui/qrgba64.h>
QT_BEGIN_NAMESPACE
@@ -63,6 +64,7 @@ public:
QColor(Qt::GlobalColor color);
QColor(int r, int g, int b, int a = 255);
QColor(QRgb rgb);
+ QColor(QRgba64 rgba64);
QColor(const QString& name);
QColor(const char *name);
QColor(const QColor &color); // ### Qt 6: remove, the trivial one is fine.
@@ -109,6 +111,9 @@ public:
QRgb rgba() const;
void setRgba(QRgb rgba);
+ QRgba64 rgba64() const;
+ void setRgba64(QRgba64 rgba);
+
QRgb rgb() const;
void setRgb(QRgb rgb);
@@ -173,6 +178,9 @@ public:
static QColor fromRgb(int r, int g, int b, int a = 255);
static QColor fromRgbF(qreal r, qreal g, qreal b, qreal a = 1.0);
+ static QColor fromRgba64(ushort r, ushort g, ushort b, ushort a = USHRT_MAX);
+ static QColor fromRgba64(QRgba64 rgba);
+
static QColor fromHsv(int h, int s, int v, int a = 255);
static QColor fromHsvF(qreal h, qreal s, qreal v, qreal a = 1.0);
diff --git a/src/gui/painting/qcompositionfunctions.cpp b/src/gui/painting/qcompositionfunctions.cpp
new file mode 100644
index 0000000000..ba428a7938
--- /dev/null
+++ b/src/gui/painting/qcompositionfunctions.cpp
@@ -0,0 +1,2197 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qglobal.h>
+#include <private/qdrawhelper_p.h>
+#include <private/qrgba64_p.h>
+
+QT_BEGIN_NAMESPACE
+
+# define PRELOAD_INIT(x)
+# define PRELOAD_INIT2(x,y)
+# define PRELOAD_COND(x)
+# define PRELOAD_COND2(x,y)
+
+/* The constant alpha factor describes an alpha factor that gets applied
+ to the result of the composition operation combining it with the destination.
+
+ The intent is that if const_alpha == 0. we get back dest, and if const_alpha == 1.
+ we get the unmodified operation
+
+ result = src op dest
+ dest = result * const_alpha + dest * (1. - const_alpha)
+
+ This means that in the comments below, the first line is the const_alpha==255 case, the
+ second line the general one.
+
+ In the lines below:
+ s == src, sa == alpha(src), sia = 1 - alpha(src)
+ d == dest, da == alpha(dest), dia = 1 - alpha(dest)
+ ca = const_alpha, cia = 1 - const_alpha
+
+ The methods exist in two variants. One where we have a constant source, the other
+ where the source is an array of pixels.
+*/
+
+/*
+ result = 0
+ d = d * cia
+*/
+#define comp_func_Clear_impl(dest, length, const_alpha)\
+{\
+ if (const_alpha == 255) {\
+ QT_MEMFILL_UINT(dest, length, 0);\
+ } else {\
+ int ialpha = 255 - const_alpha;\
+ PRELOAD_INIT(dest)\
+ for (int i = 0; i < length; ++i) {\
+ PRELOAD_COND(dest)\
+ dest[i] = BYTE_MUL(dest[i], ialpha);\
+ }\
+ }\
+}
+
+void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha)
+{
+ comp_func_Clear_impl(dest, length, const_alpha);
+}
+
+void QT_FASTCALL comp_func_solid_Clear_rgb64(QRgba64 *dest, int length, QRgba64, uint const_alpha)
+{
+ if (const_alpha == 255)
+ qt_memfill64((quint64*)dest, 0, length);
+ else {
+ int ialpha = 255 - const_alpha;
+ for (int i = 0; i < length; ++i) {
+ dest[i] = multiplyAlpha255(dest[i], ialpha);
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha)
+{
+ comp_func_Clear_impl(dest, length, const_alpha);
+}
+
+void QT_FASTCALL comp_func_Clear_rgb64(QRgba64 *dest, const QRgba64 *, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ qt_memfill64((quint64*)dest, 0, length);
+ else {
+ int ialpha = 255 - const_alpha;
+ for (int i = 0; i < length; ++i) {
+ dest[i] = multiplyAlpha255(dest[i], ialpha);
+ }
+ }
+}
+
+/*
+ result = s
+ dest = s * ca + d * cia
+*/
+void QT_FASTCALL comp_func_solid_Source(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ QT_MEMFILL_UINT(dest, length, color);
+ } else {
+ int ialpha = 255 - const_alpha;
+ color = BYTE_MUL(color, const_alpha);
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ dest[i] = color + BYTE_MUL(dest[i], ialpha);
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_solid_Source_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha)
+{
+ if (const_alpha == 255)
+ qt_memfill64((quint64*)dest, color, length);
+ else {
+ int ialpha = 255 - const_alpha;
+ color = multiplyAlpha255(color, const_alpha);
+ for (int i = 0; i < length; ++i) {
+ dest[i] = color + multiplyAlpha255(dest[i], ialpha);
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_Source(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ ::memcpy(dest, src, length * sizeof(uint));
+ } else {
+ int ialpha = 255 - const_alpha;
+ PRELOAD_INIT2(dest, src)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ dest[i] = INTERPOLATE_PIXEL_255(src[i], const_alpha, dest[i], ialpha);
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_Source_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ ::memcpy(dest, src, length * sizeof(quint64));
+ else {
+ int ialpha = 255 - const_alpha;
+ for (int i = 0; i < length; ++i) {
+ dest[i] = interpolate255(src[i], const_alpha, dest[i], ialpha);
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_solid_Destination(uint *, int, uint, uint)
+{
+}
+
+void QT_FASTCALL comp_func_solid_Destination_rgb64(QRgba64 *, int, QRgba64, uint)
+{
+}
+
+void QT_FASTCALL comp_func_Destination(uint *, const uint *, int, uint)
+{
+}
+
+void QT_FASTCALL comp_func_Destination_rgb64(QRgba64 *, const QRgba64 *, int, uint)
+{
+}
+
+/*
+ result = s + d * sia
+ dest = (s + d * sia) * ca + d * cia
+ = s * ca + d * (sia * ca + cia)
+ = s * ca + d * (1 - sa*ca)
+*/
+void QT_FASTCALL comp_func_solid_SourceOver(uint *dest, int length, uint color, uint const_alpha)
+{
+ if ((const_alpha & qAlpha(color)) == 255) {
+ QT_MEMFILL_UINT(dest, length, color);
+ } else {
+ if (const_alpha != 255)
+ color = BYTE_MUL(color, const_alpha);
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ dest[i] = color + BYTE_MUL(dest[i], qAlpha(~color));
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_solid_SourceOver_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha)
+{
+ if (const_alpha == 255 && color.isOpaque()) {
+ qt_memfill64((quint64*)dest, color, length);
+ } else {
+ if (const_alpha != 255)
+ color = multiplyAlpha255(color, const_alpha);
+ for (int i = 0; i < length; ++i) {
+ dest[i] = color + multiplyAlpha65535(dest[i], 65535 - color.alpha());
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_SourceOver(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ PRELOAD_INIT2(dest, src)
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint s = src[i];
+ if (s >= 0xff000000)
+ dest[i] = s;
+ else if (s != 0)
+ dest[i] = s + BYTE_MUL(dest[i], qAlpha(~s));
+ }
+ } else {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint s = BYTE_MUL(src[i], const_alpha);
+ dest[i] = s + BYTE_MUL(dest[i], qAlpha(~s));
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_SourceOver_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ QRgba64 s = src[i];
+ if (s.isOpaque())
+ dest[i] = s;
+ else if (!s.isTransparent())
+ dest[i] = s + multiplyAlpha65535(dest[i], 65535 - s.alpha());
+ }
+ } else {
+ for (int i = 0; i < length; ++i) {
+ QRgba64 s = multiplyAlpha255(src[i], const_alpha);
+ dest[i] = s + multiplyAlpha65535(dest[i], 65535 - s.alpha());
+ }
+ }
+}
+
+/*
+ result = d + s * dia
+ dest = (d + s * dia) * ca + d * cia
+ = d + s * dia * ca
+*/
+void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha != 255)
+ color = BYTE_MUL(color, const_alpha);
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ dest[i] = d + BYTE_MUL(color, qAlpha(~d));
+ }
+}
+
+void QT_FASTCALL comp_func_solid_DestinationOver_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha)
+{
+ if (const_alpha != 255)
+ color = multiplyAlpha255(color, const_alpha);
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = dest[i];
+ dest[i] = d + multiplyAlpha65535(color, 65535 - d.alpha());
+ }
+}
+
+void QT_FASTCALL comp_func_DestinationOver(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ PRELOAD_INIT2(dest, src)
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ dest[i] = d + BYTE_MUL(src[i], qAlpha(~d));
+ }
+ } else {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = BYTE_MUL(src[i], const_alpha);
+ dest[i] = d + BYTE_MUL(s, qAlpha(~d));
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_DestinationOver_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = dest[i];
+ dest[i] = d + multiplyAlpha65535(src[i], 65535 - d.alpha());
+ }
+ } else {
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = dest[i];
+ QRgba64 s = multiplyAlpha255(src[i], const_alpha);
+ dest[i] = d + multiplyAlpha65535(s, 65535 - d.alpha());
+ }
+ }
+}
+
+/*
+ result = s * da
+ dest = s * da * ca + d * cia
+*/
+void QT_FASTCALL comp_func_solid_SourceIn(uint *dest, int length, uint color, uint const_alpha)
+{
+ PRELOAD_INIT(dest)
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ dest[i] = BYTE_MUL(color, qAlpha(dest[i]));
+ }
+ } else {
+ color = BYTE_MUL(color, const_alpha);
+ uint cia = 255 - const_alpha;
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(d), d, cia);
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_solid_SourceIn_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ dest[i] = multiplyAlpha65535(color, dest[i].alpha());
+ }
+ } else {
+ uint ca = const_alpha * 257;
+ uint cia = 65535 - ca;
+ color = multiplyAlpha65535(color, ca);
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = dest[i];
+ dest[i] = interpolate65535(color, d.alpha(), d, cia);
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_SourceIn(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ PRELOAD_INIT2(dest, src)
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ dest[i] = BYTE_MUL(src[i], qAlpha(dest[i]));
+ }
+ } else {
+ uint cia = 255 - const_alpha;
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = BYTE_MUL(src[i], const_alpha);
+ dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, cia);
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_SourceIn_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ dest[i] = multiplyAlpha65535(src[i], dest[i].alpha());
+ }
+ } else {
+ uint ca = const_alpha * 257;
+ uint cia = 65535 - ca;
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = dest[i];
+ QRgba64 s = multiplyAlpha65535(src[i], ca);
+ dest[i] = interpolate65535(s, d.alpha(), d, cia);
+ }
+ }
+}
+
+/*
+ result = d * sa
+ dest = d * sa * ca + d * cia
+ = d * (sa * ca + cia)
+*/
+void QT_FASTCALL comp_func_solid_DestinationIn(uint *dest, int length, uint color, uint const_alpha)
+{
+ uint a = qAlpha(color);
+ if (const_alpha != 255) {
+ a = BYTE_MUL(a, const_alpha) + 255 - const_alpha;
+ }
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ dest[i] = BYTE_MUL(dest[i], a);
+ }
+}
+
+void QT_FASTCALL comp_func_solid_DestinationIn_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha)
+{
+ uint a = color.alpha();
+ uint ca64k = const_alpha * 257;
+ if (const_alpha != 255)
+ a = qt_div_65535(a * ca64k) + 65535 - ca64k;
+ for (int i = 0; i < length; ++i) {
+ dest[i] = multiplyAlpha65535(dest[i], a);
+ }
+}
+
+void QT_FASTCALL comp_func_DestinationIn(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ PRELOAD_INIT2(dest, src)
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ dest[i] = BYTE_MUL(dest[i], qAlpha(src[i]));
+ }
+ } else {
+ int cia = 255 - const_alpha;
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint a = BYTE_MUL(qAlpha(src[i]), const_alpha) + cia;
+ dest[i] = BYTE_MUL(dest[i], a);
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_DestinationIn_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ dest[i] = multiplyAlpha65535(dest[i], src[i].alpha());
+ }
+ } else {
+ uint ca = const_alpha * 257;
+ uint cia = 65535 - ca;
+ for (int i = 0; i < length; ++i) {
+ uint a = qt_div_65535(src[i].alpha() * ca) + cia;
+ dest[i] = multiplyAlpha65535(dest[i], a);
+ }
+ }
+}
+
+/*
+ result = s * dia
+ dest = s * dia * ca + d * cia
+*/
+
+void QT_FASTCALL comp_func_solid_SourceOut(uint *dest, int length, uint color, uint const_alpha)
+{
+ PRELOAD_INIT(dest)
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ dest[i] = BYTE_MUL(color, qAlpha(~dest[i]));
+ }
+ } else {
+ color = BYTE_MUL(color, const_alpha);
+ int cia = 255 - const_alpha;
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(~d), d, cia);
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_solid_SourceOut_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ dest[i] = multiplyAlpha65535(color, 65535 - dest[i].alpha());
+ }
+ } else {
+ uint ca = const_alpha * 257;
+ uint cia = 65535 - ca;
+ color = multiplyAlpha65535(color, ca);
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = dest[i];
+ dest[i] = interpolate65535(color, 65535 - d.alpha(), d, cia);
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_SourceOut(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ PRELOAD_INIT2(dest, src)
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ dest[i] = BYTE_MUL(src[i], qAlpha(~dest[i]));
+ }
+ } else {
+ int cia = 255 - const_alpha;
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint s = BYTE_MUL(src[i], const_alpha);
+ uint d = dest[i];
+ dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, cia);
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_SourceOut_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ dest[i] = multiplyAlpha65535(src[i], 65535 - dest[i].alpha());
+ }
+ } else {
+ uint ca = const_alpha * 257;
+ uint cia = 65535 - ca;
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = dest[i];
+ QRgba64 s = multiplyAlpha65535(src[i], ca);
+ dest[i] = interpolate65535(s, 65535 - d.alpha(), d, cia);
+ }
+ }
+}
+
+/*
+ result = d * sia
+ dest = d * sia * ca + d * cia
+ = d * (sia * ca + cia)
+*/
+void QT_FASTCALL comp_func_solid_DestinationOut(uint *dest, int length, uint color, uint const_alpha)
+{
+ uint a = qAlpha(~color);
+ if (const_alpha != 255)
+ a = BYTE_MUL(a, const_alpha) + 255 - const_alpha;
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ dest[i] = BYTE_MUL(dest[i], a);
+ }
+}
+
+void QT_FASTCALL comp_func_solid_DestinationOut_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha)
+{
+ uint a = 65535 - color.alpha();
+ uint ca64k = const_alpha * 257;
+ if (const_alpha != 255)
+ a = qt_div_65535(a * ca64k) + 65535 - ca64k;
+ for (int i = 0; i < length; ++i) {
+ dest[i] = multiplyAlpha65535(dest[i], a);
+ }
+}
+
+void QT_FASTCALL comp_func_DestinationOut(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ PRELOAD_INIT2(dest, src)
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ dest[i] = BYTE_MUL(dest[i], qAlpha(~src[i]));
+ }
+ } else {
+ int cia = 255 - const_alpha;
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint sia = BYTE_MUL(qAlpha(~src[i]), const_alpha) + cia;
+ dest[i] = BYTE_MUL(dest[i], sia);
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_DestinationOut_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ dest[i] = multiplyAlpha65535(dest[i], 65535 - src[i].alpha());
+ }
+ } else {
+ uint ca = const_alpha * 257;
+ uint cia = 65535 - ca;
+ for (int i = 0; i < length; ++i) {
+ uint a = qt_div_65535((65535 - src[i].alpha()) * ca) + cia;
+ dest[i] = multiplyAlpha65535(dest[i], a);
+ }
+ }
+}
+
+/*
+ result = s*da + d*sia
+ dest = s*da*ca + d*sia*ca + d *cia
+ = s*ca * da + d * (sia*ca + cia)
+ = s*ca * da + d * (1 - sa*ca)
+*/
+void QT_FASTCALL comp_func_solid_SourceAtop(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha != 255) {
+ color = BYTE_MUL(color, const_alpha);
+ }
+ uint sia = qAlpha(~color);
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(dest[i]), dest[i], sia);
+ }
+}
+
+void QT_FASTCALL comp_func_solid_SourceAtop_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha)
+{
+ if (const_alpha != 255)
+ color = multiplyAlpha255(color, const_alpha);
+ uint sia = 65535 - color.alpha();
+ for (int i = 0; i < length; ++i) {
+ dest[i] = interpolate65535(color, dest[i].alpha(), dest[i], sia);
+ }
+}
+
+void QT_FASTCALL comp_func_SourceAtop(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ PRELOAD_INIT2(dest, src)
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint s = src[i];
+ uint d = dest[i];
+ dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, qAlpha(~s));
+ }
+ } else {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint s = BYTE_MUL(src[i], const_alpha);
+ uint d = dest[i];
+ dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, qAlpha(~s));
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_SourceAtop_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ QRgba64 s = src[i];
+ QRgba64 d = dest[i];
+ dest[i] = interpolate65535(s, d.alpha(), d, 65535 - s.alpha());
+ }
+ } else {
+ for (int i = 0; i < length; ++i) {
+ QRgba64 s = multiplyAlpha255(src[i], const_alpha);
+ QRgba64 d = dest[i];
+ dest[i] = interpolate65535(s, d.alpha(), d, 65535 - s.alpha());
+ }
+ }
+}
+
+/*
+ result = d*sa + s*dia
+ dest = d*sa*ca + s*dia*ca + d *cia
+ = s*ca * dia + d * (sa*ca + cia)
+*/
+void QT_FASTCALL comp_func_solid_DestinationAtop(uint *dest, int length, uint color, uint const_alpha)
+{
+ uint a = qAlpha(color);
+ if (const_alpha != 255) {
+ color = BYTE_MUL(color, const_alpha);
+ a = qAlpha(color) + 255 - const_alpha;
+ }
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ dest[i] = INTERPOLATE_PIXEL_255(d, a, color, qAlpha(~d));
+ }
+}
+
+void QT_FASTCALL comp_func_solid_DestinationAtop_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha)
+{
+ uint a = color.alpha();
+ if (const_alpha != 255) {
+ color = multiplyAlpha255(color, const_alpha);
+ a = color.alpha() + 65535 - (const_alpha * 257);
+ }
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = dest[i];
+ dest[i] = interpolate65535(d, a, color, 65535 - d.alpha());
+ }
+}
+
+void QT_FASTCALL comp_func_DestinationAtop(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ PRELOAD_INIT2(dest, src)
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint s = src[i];
+ uint d = dest[i];
+ dest[i] = INTERPOLATE_PIXEL_255(d, qAlpha(s), s, qAlpha(~d));
+ }
+ } else {
+ int cia = 255 - const_alpha;
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint s = BYTE_MUL(src[i], const_alpha);
+ uint d = dest[i];
+ uint a = qAlpha(s) + cia;
+ dest[i] = INTERPOLATE_PIXEL_255(d, a, s, qAlpha(~d));
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_DestinationAtop_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ QRgba64 s = src[i];
+ QRgba64 d = dest[i];
+ dest[i] = interpolate65535(d, s.alpha(), s, 65535 - d.alpha());
+ }
+ } else {
+ int ca = const_alpha * 257;
+ int cia = 65535 - ca;
+ for (int i = 0; i < length; ++i) {
+ QRgba64 s = multiplyAlpha65535(src[i], ca);
+ QRgba64 d = dest[i];
+ uint a = s.alpha() + cia;
+ dest[i] = interpolate65535(d, a, s, 65535 - d.alpha());
+ }
+ }
+}
+
+/*
+ result = d*sia + s*dia
+ dest = d*sia*ca + s*dia*ca + d *cia
+ = s*ca * dia + d * (sia*ca + cia)
+ = s*ca * dia + d * (1 - sa*ca)
+*/
+void QT_FASTCALL comp_func_solid_XOR(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha != 255)
+ color = BYTE_MUL(color, const_alpha);
+ uint sia = qAlpha(~color);
+
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(~d), d, sia);
+ }
+}
+
+void QT_FASTCALL comp_func_solid_XOR_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha)
+{
+ if (const_alpha != 255)
+ color = multiplyAlpha255(color, const_alpha);
+ uint sia = 65535 - color.alpha();
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = dest[i];
+ dest[i] = interpolate65535(color, 65535 - d.alpha(), d, sia);
+ }
+}
+
+void QT_FASTCALL comp_func_XOR(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ PRELOAD_INIT2(dest, src)
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = src[i];
+ dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, qAlpha(~s));
+ }
+ } else {
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = BYTE_MUL(src[i], const_alpha);
+ dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, qAlpha(~s));
+ }
+ }
+}
+
+void QT_FASTCALL comp_func_XOR_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = dest[i];
+ QRgba64 s = src[i];
+ dest[i] = interpolate65535(s, 65535 - d.alpha(), d, 65535 - s.alpha());
+ }
+ } else {
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = dest[i];
+ QRgba64 s = multiplyAlpha255(src[i], const_alpha);
+ dest[i] = interpolate65535(s, 65535 - d.alpha(), d, 65535 - s.alpha());
+ }
+ }
+}
+
+struct QFullCoverage {
+ inline void store(uint *dest, const uint src) const
+ {
+ *dest = src;
+ }
+};
+
+struct QPartialCoverage {
+ inline QPartialCoverage(uint const_alpha)
+ : ca(const_alpha)
+ , ica(255 - const_alpha)
+ {
+ }
+
+ inline void store(uint *dest, const uint src) const
+ {
+ *dest = INTERPOLATE_PIXEL_255(src, ca, *dest, ica);
+ }
+
+private:
+ const uint ca;
+ const uint ica;
+};
+
+static inline int mix_alpha(int da, int sa)
+{
+ return 255 - ((255 - sa) * (255 - da) >> 8);
+}
+
+/*
+ Dca' = Sca.Da + Dca.Sa + Sca.(1 - Da) + Dca.(1 - Sa)
+ = Sca + Dca
+*/
+template <typename T>
+Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Plus_impl(uint *dest, int length, uint color, const T &coverage)
+{
+ uint s = color;
+
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ d = comp_func_Plus_one_pixel(d, s);
+ coverage.store(&dest[i], d);
+ }
+}
+
+template <typename T>
+Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Plus_impl_rgb64(QRgba64 *dest, int length, QRgba64 color, const T &coverage)
+{
+ QRgba64 s = color;
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = dest[i];
+ d = comp_func_Plus_one_pixel(d, s);
+ coverage.store(&dest[i], d);
+ }
+}
+
+void QT_FASTCALL comp_func_solid_Plus(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_solid_Plus_impl(dest, length, color, QFullCoverage());
+ else
+ comp_func_solid_Plus_impl(dest, length, color, QPartialCoverage(const_alpha));
+}
+
+void QT_FASTCALL comp_func_solid_Plus_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ dest[i] = addWithSaturation(dest[i], color);
+ }
+ } else {
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = addWithSaturation(dest[i], color);
+ dest[i] = interpolate255(d, const_alpha, dest[i], 255 - const_alpha);
+ }
+ }
+}
+
+template <typename T>
+Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Plus_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
+{
+ PRELOAD_INIT2(dest, src)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = src[i];
+
+ d = comp_func_Plus_one_pixel(d, s);
+
+ coverage.store(&dest[i], d);
+ }
+}
+
+void QT_FASTCALL comp_func_Plus(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_Plus_impl(dest, src, length, QFullCoverage());
+ else
+ comp_func_Plus_impl(dest, src, length, QPartialCoverage(const_alpha));
+}
+
+void QT_FASTCALL comp_func_Plus_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255) {
+ for (int i = 0; i < length; ++i) {
+ dest[i] = addWithSaturation(dest[i], src[i]);
+ }
+ } else {
+ for (int i = 0; i < length; ++i) {
+ QRgba64 d = addWithSaturation(dest[i], src[i]);
+ dest[i] = interpolate255(d, const_alpha, dest[i], 255 - const_alpha);
+ }
+ }
+}
+
+/*
+ Dca' = Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa)
+*/
+static inline int multiply_op(int dst, int src, int da, int sa)
+{
+ return qt_div_255(src * dst + src * (255 - da) + dst * (255 - sa));
+}
+
+template <typename T>
+Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Multiply_impl(uint *dest, int length, uint color, const T &coverage)
+{
+ int sa = qAlpha(color);
+ int sr = qRed(color);
+ int sg = qGreen(color);
+ int sb = qBlue(color);
+
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ int da = qAlpha(d);
+
+#define OP(a, b) multiply_op(a, b, da, sa)
+ int r = OP( qRed(d), sr);
+ int b = OP( qBlue(d), sb);
+ int g = OP(qGreen(d), sg);
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_solid_Multiply(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_solid_Multiply_impl(dest, length, color, QFullCoverage());
+ else
+ comp_func_solid_Multiply_impl(dest, length, color, QPartialCoverage(const_alpha));
+}
+
+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)
+{
+ PRELOAD_INIT2(dest, src)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = src[i];
+
+ int da = qAlpha(d);
+ int sa = qAlpha(s);
+
+#define OP(a, b) multiply_op(a, b, da, sa)
+ int r = OP( qRed(d), qRed(s));
+ int b = OP( qBlue(d), qBlue(s));
+ int g = OP(qGreen(d), qGreen(s));
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_Multiply(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_Multiply_impl(dest, src, length, QFullCoverage());
+ else
+ comp_func_Multiply_impl(dest, src, length, QPartialCoverage(const_alpha));
+}
+
+/*
+ Dca' = (Sca.Da + Dca.Sa - Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa)
+ = 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)
+{
+ int sa = qAlpha(color);
+ int sr = qRed(color);
+ int sg = qGreen(color);
+ int sb = qBlue(color);
+
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ int da = qAlpha(d);
+
+#define OP(a, b) 255 - qt_div_255((255-a) * (255-b))
+ int r = OP( qRed(d), sr);
+ int b = OP( qBlue(d), sb);
+ int g = OP(qGreen(d), sg);
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_solid_Screen(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_solid_Screen_impl(dest, length, color, QFullCoverage());
+ else
+ comp_func_solid_Screen_impl(dest, length, color, QPartialCoverage(const_alpha));
+}
+
+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)
+{
+ PRELOAD_INIT2(dest, src)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = src[i];
+
+ int da = qAlpha(d);
+ int sa = qAlpha(s);
+
+#define OP(a, b) 255 - (((255-a) * (255-b)) >> 8)
+ int r = OP( qRed(d), qRed(s));
+ int b = OP( qBlue(d), qBlue(s));
+ int g = OP(qGreen(d), qGreen(s));
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_Screen(uint *dest, const uint *src, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_Screen_impl(dest, src, length, QFullCoverage());
+ else
+ comp_func_Screen_impl(dest, src, length, QPartialCoverage(const_alpha));
+}
+
+/*
+ if 2.Dca < Da
+ Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa)
+ otherwise
+ Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa)
+*/
+static inline int overlay_op(int dst, int src, int da, int sa)
+{
+ const int temp = src * (255 - da) + dst * (255 - sa);
+ if (2 * dst < da)
+ return qt_div_255(2 * src * dst + temp);
+ else
+ return qt_div_255(sa * da - 2 * (da - dst) * (sa - src) + temp);
+}
+
+template <typename T>
+Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Overlay_impl(uint *dest, int length, uint color, const T &coverage)
+{
+ int sa = qAlpha(color);
+ int sr = qRed(color);
+ int sg = qGreen(color);
+ int sb = qBlue(color);
+
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ int da = qAlpha(d);
+
+#define OP(a, b) overlay_op(a, b, da, sa)
+ int r = OP( qRed(d), sr);
+ int b = OP( qBlue(d), sb);
+ int g = OP(qGreen(d), sg);
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_solid_Overlay(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_solid_Overlay_impl(dest, length, color, QFullCoverage());
+ else
+ comp_func_solid_Overlay_impl(dest, length, color, QPartialCoverage(const_alpha));
+}
+
+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)
+{
+ PRELOAD_INIT2(dest, src)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = src[i];
+
+ int da = qAlpha(d);
+ int sa = qAlpha(s);
+
+#define OP(a, b) overlay_op(a, b, da, sa)
+ int r = OP( qRed(d), qRed(s));
+ int b = OP( qBlue(d), qBlue(s));
+ int g = OP(qGreen(d), qGreen(s));
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_Overlay(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_Overlay_impl(dest, src, length, QFullCoverage());
+ else
+ comp_func_Overlay_impl(dest, src, length, QPartialCoverage(const_alpha));
+}
+
+/*
+ Dca' = min(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa)
+ Da' = Sa + Da - Sa.Da
+*/
+static inline int darken_op(int dst, int src, int da, int sa)
+{
+ return qt_div_255(qMin(src * da, dst * sa) + src * (255 - da) + dst * (255 - sa));
+}
+
+template <typename T>
+Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Darken_impl(uint *dest, int length, uint color, const T &coverage)
+{
+ int sa = qAlpha(color);
+ int sr = qRed(color);
+ int sg = qGreen(color);
+ int sb = qBlue(color);
+
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ int da = qAlpha(d);
+
+#define OP(a, b) darken_op(a, b, da, sa)
+ int r = OP( qRed(d), sr);
+ int b = OP( qBlue(d), sb);
+ int g = OP(qGreen(d), sg);
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_solid_Darken(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_solid_Darken_impl(dest, length, color, QFullCoverage());
+ else
+ comp_func_solid_Darken_impl(dest, length, color, QPartialCoverage(const_alpha));
+}
+
+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)
+{
+ PRELOAD_INIT2(dest, src)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = src[i];
+
+ int da = qAlpha(d);
+ int sa = qAlpha(s);
+
+#define OP(a, b) darken_op(a, b, da, sa)
+ int r = OP( qRed(d), qRed(s));
+ int b = OP( qBlue(d), qBlue(s));
+ int g = OP(qGreen(d), qGreen(s));
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_Darken(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_Darken_impl(dest, src, length, QFullCoverage());
+ else
+ comp_func_Darken_impl(dest, src, length, QPartialCoverage(const_alpha));
+}
+
+/*
+ Dca' = max(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa)
+ Da' = Sa + Da - Sa.Da
+*/
+static inline int lighten_op(int dst, int src, int da, int sa)
+{
+ return qt_div_255(qMax(src * da, dst * sa) + src * (255 - da) + dst * (255 - sa));
+}
+
+template <typename T>
+Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Lighten_impl(uint *dest, int length, uint color, const T &coverage)
+{
+ int sa = qAlpha(color);
+ int sr = qRed(color);
+ int sg = qGreen(color);
+ int sb = qBlue(color);
+
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ int da = qAlpha(d);
+
+#define OP(a, b) lighten_op(a, b, da, sa)
+ int r = OP( qRed(d), sr);
+ int b = OP( qBlue(d), sb);
+ int g = OP(qGreen(d), sg);
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_solid_Lighten(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_solid_Lighten_impl(dest, length, color, QFullCoverage());
+ else
+ comp_func_solid_Lighten_impl(dest, length, color, QPartialCoverage(const_alpha));
+}
+
+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)
+{
+ PRELOAD_INIT2(dest, src)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = src[i];
+
+ int da = qAlpha(d);
+ int sa = qAlpha(s);
+
+#define OP(a, b) lighten_op(a, b, da, sa)
+ int r = OP( qRed(d), qRed(s));
+ int b = OP( qBlue(d), qBlue(s));
+ int g = OP(qGreen(d), qGreen(s));
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_Lighten(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_Lighten_impl(dest, src, length, QFullCoverage());
+ else
+ comp_func_Lighten_impl(dest, src, length, QPartialCoverage(const_alpha));
+}
+
+/*
+ if Sca.Da + Dca.Sa >= Sa.Da
+ Dca' = Sa.Da + Sca.(1 - Da) + Dca.(1 - Sa)
+ otherwise
+ Dca' = Dca.Sa/(1-Sca/Sa) + Sca.(1 - Da) + Dca.(1 - Sa)
+*/
+static inline int color_dodge_op(int dst, int src, int da, int sa)
+{
+ const int sa_da = sa * da;
+ const int dst_sa = dst * sa;
+ const int src_da = src * da;
+
+ const int temp = src * (255 - da) + dst * (255 - sa);
+ if (src_da + dst_sa >= sa_da)
+ return qt_div_255(sa_da + temp);
+ else
+ return qt_div_255(255 * dst_sa / (255 - 255 * src / sa) + temp);
+}
+
+template <typename T>
+Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorDodge_impl(uint *dest, int length, uint color, const T &coverage)
+{
+ int sa = qAlpha(color);
+ int sr = qRed(color);
+ int sg = qGreen(color);
+ int sb = qBlue(color);
+
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ int da = qAlpha(d);
+
+#define OP(a,b) color_dodge_op(a, b, da, sa)
+ int r = OP( qRed(d), sr);
+ int b = OP( qBlue(d), sb);
+ int g = OP(qGreen(d), sg);
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_solid_ColorDodge(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_solid_ColorDodge_impl(dest, length, color, QFullCoverage());
+ else
+ comp_func_solid_ColorDodge_impl(dest, length, color, QPartialCoverage(const_alpha));
+}
+
+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)
+{
+ PRELOAD_INIT2(dest, src)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = src[i];
+
+ int da = qAlpha(d);
+ int sa = qAlpha(s);
+
+#define OP(a, b) color_dodge_op(a, b, da, sa)
+ int r = OP( qRed(d), qRed(s));
+ int b = OP( qBlue(d), qBlue(s));
+ int g = OP(qGreen(d), qGreen(s));
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_ColorDodge(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_ColorDodge_impl(dest, src, length, QFullCoverage());
+ else
+ comp_func_ColorDodge_impl(dest, src, length, QPartialCoverage(const_alpha));
+}
+
+/*
+ if Sca.Da + Dca.Sa <= Sa.Da
+ Dca' = Sca.(1 - Da) + Dca.(1 - Sa)
+ otherwise
+ Dca' = Sa.(Sca.Da + Dca.Sa - Sa.Da)/Sca + Sca.(1 - Da) + Dca.(1 - Sa)
+*/
+static inline int color_burn_op(int dst, int src, int da, int sa)
+{
+ const int src_da = src * da;
+ const int dst_sa = dst * sa;
+ const int sa_da = sa * da;
+
+ const int temp = src * (255 - da) + dst * (255 - sa);
+
+ if (src == 0 || src_da + dst_sa <= sa_da)
+ return qt_div_255(temp);
+ return qt_div_255(sa * (src_da + dst_sa - sa_da) / src + temp);
+}
+
+template <typename T>
+Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorBurn_impl(uint *dest, int length, uint color, const T &coverage)
+{
+ int sa = qAlpha(color);
+ int sr = qRed(color);
+ int sg = qGreen(color);
+ int sb = qBlue(color);
+
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ int da = qAlpha(d);
+
+#define OP(a, b) color_burn_op(a, b, da, sa)
+ int r = OP( qRed(d), sr);
+ int b = OP( qBlue(d), sb);
+ int g = OP(qGreen(d), sg);
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_solid_ColorBurn(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_solid_ColorBurn_impl(dest, length, color, QFullCoverage());
+ else
+ comp_func_solid_ColorBurn_impl(dest, length, color, QPartialCoverage(const_alpha));
+}
+
+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)
+{
+ PRELOAD_INIT2(dest, src)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = src[i];
+
+ int da = qAlpha(d);
+ int sa = qAlpha(s);
+
+#define OP(a, b) color_burn_op(a, b, da, sa)
+ int r = OP( qRed(d), qRed(s));
+ int b = OP( qBlue(d), qBlue(s));
+ int g = OP(qGreen(d), qGreen(s));
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_ColorBurn(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_ColorBurn_impl(dest, src, length, QFullCoverage());
+ else
+ comp_func_ColorBurn_impl(dest, src, length, QPartialCoverage(const_alpha));
+}
+
+/*
+ if 2.Sca < Sa
+ Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa)
+ otherwise
+ Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa)
+*/
+static inline uint hardlight_op(int dst, int src, int da, int sa)
+{
+ const uint temp = src * (255 - da) + dst * (255 - sa);
+
+ if (2 * src < sa)
+ return qt_div_255(2 * src * dst + temp);
+ else
+ return qt_div_255(sa * da - 2 * (da - dst) * (sa - src) + temp);
+}
+
+template <typename T>
+Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_HardLight_impl(uint *dest, int length, uint color, const T &coverage)
+{
+ int sa = qAlpha(color);
+ int sr = qRed(color);
+ int sg = qGreen(color);
+ int sb = qBlue(color);
+
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ int da = qAlpha(d);
+
+#define OP(a, b) hardlight_op(a, b, da, sa)
+ int r = OP( qRed(d), sr);
+ int b = OP( qBlue(d), sb);
+ int g = OP(qGreen(d), sg);
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_solid_HardLight(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_solid_HardLight_impl(dest, length, color, QFullCoverage());
+ else
+ comp_func_solid_HardLight_impl(dest, length, color, QPartialCoverage(const_alpha));
+}
+
+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)
+{
+ PRELOAD_INIT2(dest, src)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = src[i];
+
+ int da = qAlpha(d);
+ int sa = qAlpha(s);
+
+#define OP(a, b) hardlight_op(a, b, da, sa)
+ int r = OP( qRed(d), qRed(s));
+ int b = OP( qBlue(d), qBlue(s));
+ int g = OP(qGreen(d), qGreen(s));
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_HardLight(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_HardLight_impl(dest, src, length, QFullCoverage());
+ else
+ comp_func_HardLight_impl(dest, src, length, QPartialCoverage(const_alpha));
+}
+
+/*
+ if 2.Sca <= Sa
+ Dca' = Dca.(Sa + (2.Sca - Sa).(1 - Dca/Da)) + Sca.(1 - Da) + Dca.(1 - Sa)
+ otherwise if 2.Sca > Sa and 4.Dca <= Da
+ Dca' = Dca.Sa + Da.(2.Sca - Sa).(4.Dca/Da.(4.Dca/Da + 1).(Dca/Da - 1) + 7.Dca/Da) + Sca.(1 - Da) + Dca.(1 - Sa)
+ otherwise if 2.Sca > Sa and 4.Dca > Da
+ Dca' = Dca.Sa + Da.(2.Sca - Sa).((Dca/Da)^0.5 - Dca/Da) + Sca.(1 - Da) + Dca.(1 - Sa)
+*/
+static inline int soft_light_op(int dst, int src, int da, int sa)
+{
+ const int src2 = src << 1;
+ const int dst_np = da != 0 ? (255 * dst) / da : 0;
+ const int temp = (src * (255 - da) + dst * (255 - sa)) * 255;
+
+ if (src2 < sa)
+ return (dst * (sa * 255 + (src2 - sa) * (255 - dst_np)) + temp) / 65025;
+ else if (4 * dst <= da)
+ return (dst * sa * 255 + da * (src2 - sa) * ((((16 * dst_np - 12 * 255) * dst_np + 3 * 65025) * dst_np) / 65025) + temp) / 65025;
+ else {
+ return (dst * sa * 255 + da * (src2 - sa) * (int(qSqrt(qreal(dst_np * 255))) - dst_np) + temp) / 65025;
+ }
+}
+
+template <typename T>
+Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_SoftLight_impl(uint *dest, int length, uint color, const T &coverage)
+{
+ int sa = qAlpha(color);
+ int sr = qRed(color);
+ int sg = qGreen(color);
+ int sb = qBlue(color);
+
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ int da = qAlpha(d);
+
+#define OP(a, b) soft_light_op(a, b, da, sa)
+ int r = OP( qRed(d), sr);
+ int b = OP( qBlue(d), sb);
+ int g = OP(qGreen(d), sg);
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_solid_SoftLight(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_solid_SoftLight_impl(dest, length, color, QFullCoverage());
+ else
+ comp_func_solid_SoftLight_impl(dest, length, color, QPartialCoverage(const_alpha));
+}
+
+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)
+{
+ PRELOAD_INIT2(dest, src)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = src[i];
+
+ int da = qAlpha(d);
+ int sa = qAlpha(s);
+
+#define OP(a, b) soft_light_op(a, b, da, sa)
+ int r = OP( qRed(d), qRed(s));
+ int b = OP( qBlue(d), qBlue(s));
+ int g = OP(qGreen(d), qGreen(s));
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_SoftLight(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_SoftLight_impl(dest, src, length, QFullCoverage());
+ else
+ comp_func_SoftLight_impl(dest, src, length, QPartialCoverage(const_alpha));
+}
+
+/*
+ Dca' = abs(Dca.Sa - Sca.Da) + Sca.(1 - Da) + Dca.(1 - Sa)
+ = Sca + Dca - 2.min(Sca.Da, Dca.Sa)
+*/
+static inline int difference_op(int dst, int src, int da, int sa)
+{
+ return src + dst - qt_div_255(2 * qMin(src * da, dst * sa));
+}
+
+template <typename T>
+Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Difference_impl(uint *dest, int length, uint color, const T &coverage)
+{
+ int sa = qAlpha(color);
+ int sr = qRed(color);
+ int sg = qGreen(color);
+ int sb = qBlue(color);
+
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ int da = qAlpha(d);
+
+#define OP(a, b) difference_op(a, b, da, sa)
+ int r = OP( qRed(d), sr);
+ int b = OP( qBlue(d), sb);
+ int g = OP(qGreen(d), sg);
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_solid_Difference(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_solid_Difference_impl(dest, length, color, QFullCoverage());
+ else
+ comp_func_solid_Difference_impl(dest, length, color, QPartialCoverage(const_alpha));
+}
+
+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)
+{
+ PRELOAD_INIT2(dest, src)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = src[i];
+
+ int da = qAlpha(d);
+ int sa = qAlpha(s);
+
+#define OP(a, b) difference_op(a, b, da, sa)
+ int r = OP( qRed(d), qRed(s));
+ int b = OP( qBlue(d), qBlue(s));
+ int g = OP(qGreen(d), qGreen(s));
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_Difference(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_Difference_impl(dest, src, length, QFullCoverage());
+ else
+ comp_func_Difference_impl(dest, src, length, QPartialCoverage(const_alpha));
+}
+
+/*
+ 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)
+{
+ int sa = qAlpha(color);
+ int sr = qRed(color);
+ int sg = qGreen(color);
+ int sb = qBlue(color);
+
+ PRELOAD_INIT(dest)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND(dest)
+ uint d = dest[i];
+ int da = qAlpha(d);
+
+#define OP(a, b) (a + b - qt_div_255(2*(a*b)))
+ int r = OP( qRed(d), sr);
+ int b = OP( qBlue(d), sb);
+ int g = OP(qGreen(d), sg);
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_solid_Exclusion(uint *dest, int length, uint color, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_solid_Exclusion_impl(dest, length, color, QFullCoverage());
+ else
+ comp_func_solid_Exclusion_impl(dest, length, color, QPartialCoverage(const_alpha));
+}
+
+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)
+{
+ PRELOAD_INIT2(dest, src)
+ for (int i = 0; i < length; ++i) {
+ PRELOAD_COND2(dest, src)
+ uint d = dest[i];
+ uint s = src[i];
+
+ int da = qAlpha(d);
+ int sa = qAlpha(s);
+
+#define OP(a, b) (a + b - ((a*b) >> 7))
+ int r = OP( qRed(d), qRed(s));
+ int b = OP( qBlue(d), qBlue(s));
+ int g = OP(qGreen(d), qGreen(s));
+ int a = mix_alpha(da, sa);
+#undef OP
+
+ coverage.store(&dest[i], qRgba(r, g, b, a));
+ }
+}
+
+void QT_FASTCALL comp_func_Exclusion(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
+{
+ if (const_alpha == 255)
+ comp_func_Exclusion_impl(dest, src, length, QFullCoverage());
+ else
+ comp_func_Exclusion_impl(dest, src, length, QPartialCoverage(const_alpha));
+}
+
+void QT_FASTCALL rasterop_solid_SourceOrDestination(uint *dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--)
+ *dest++ |= color;
+}
+
+void QT_FASTCALL rasterop_SourceOrDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--)
+ *dest++ |= *src++;
+}
+
+void QT_FASTCALL rasterop_solid_SourceAndDestination(uint *dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ color |= 0xff000000;
+ while (length--)
+ *dest++ &= color;
+}
+
+void QT_FASTCALL rasterop_SourceAndDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = (*src & *dest) | 0xff000000;
+ ++dest; ++src;
+ }
+}
+
+void QT_FASTCALL rasterop_solid_SourceXorDestination(uint *dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ color &= 0x00ffffff;
+ while (length--)
+ *dest++ ^= color;
+}
+
+void QT_FASTCALL rasterop_SourceXorDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = (*src ^ *dest) | 0xff000000;
+ ++dest; ++src;
+ }
+}
+
+void QT_FASTCALL rasterop_solid_NotSourceAndNotDestination(uint *dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ color = ~color;
+ while (length--) {
+ *dest = (color & ~(*dest)) | 0xff000000;
+ ++dest;
+ }
+}
+
+void QT_FASTCALL rasterop_NotSourceAndNotDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = (~(*src) & ~(*dest)) | 0xff000000;
+ ++dest; ++src;
+ }
+}
+
+void QT_FASTCALL rasterop_solid_NotSourceOrNotDestination(uint *dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ color = ~color | 0xff000000;
+ while (length--) {
+ *dest = color | ~(*dest);
+ ++dest;
+ }
+}
+
+void QT_FASTCALL rasterop_NotSourceOrNotDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = ~(*src) | ~(*dest) | 0xff000000;
+ ++dest; ++src;
+ }
+}
+
+void QT_FASTCALL rasterop_solid_NotSourceXorDestination(uint *dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ color = ~color & 0x00ffffff;
+ while (length--) {
+ *dest = color ^ (*dest);
+ ++dest;
+ }
+}
+
+void QT_FASTCALL rasterop_NotSourceXorDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = ((~(*src)) ^ (*dest)) | 0xff000000;
+ ++dest; ++src;
+ }
+}
+
+void QT_FASTCALL rasterop_solid_NotSource(uint *dest, int length,
+ uint color, uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ qt_memfill(dest, ~color | 0xff000000, length);
+}
+
+void QT_FASTCALL rasterop_NotSource(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src,
+ int length, uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--)
+ *dest++ = ~(*src++) | 0xff000000;
+}
+
+void QT_FASTCALL rasterop_solid_NotSourceAndDestination(uint *dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ color = ~color | 0xff000000;
+ while (length--) {
+ *dest = color & *dest;
+ ++dest;
+ }
+}
+
+void QT_FASTCALL rasterop_NotSourceAndDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = (~(*src) & *dest) | 0xff000000;
+ ++dest; ++src;
+ }
+}
+
+void QT_FASTCALL rasterop_solid_SourceAndNotDestination(uint *dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = (color & ~(*dest)) | 0xff000000;
+ ++dest;
+ }
+}
+
+void QT_FASTCALL rasterop_SourceAndNotDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = (*src & ~(*dest)) | 0xff000000;
+ ++dest; ++src;
+ }
+}
+
+void QT_FASTCALL rasterop_NotSourceOrDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = (~(*src) | *dest) | 0xff000000;
+ ++dest; ++src;
+ }
+}
+
+void QT_FASTCALL rasterop_solid_NotSourceOrDestination(uint *Q_DECL_RESTRICT dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ color = ~color | 0xff000000;
+ while (length--)
+ *dest++ |= color;
+}
+
+void QT_FASTCALL rasterop_SourceOrNotDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = (*src | ~(*dest)) | 0xff000000;
+ ++dest; ++src;
+ }
+}
+
+void QT_FASTCALL rasterop_solid_SourceOrNotDestination(uint *Q_DECL_RESTRICT dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = (color | ~(*dest)) | 0xff000000;
+ ++dest;
+ }
+}
+
+void QT_FASTCALL rasterop_ClearDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(src);
+ comp_func_solid_SourceOver (dest, length, 0xff000000, const_alpha);
+}
+
+void QT_FASTCALL rasterop_solid_ClearDestination(uint *Q_DECL_RESTRICT dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(color);
+ comp_func_solid_SourceOver (dest, length, 0xff000000, const_alpha);
+}
+
+void QT_FASTCALL rasterop_SetDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(src);
+ comp_func_solid_SourceOver (dest, length, 0xffffffff, const_alpha);
+}
+
+void QT_FASTCALL rasterop_solid_SetDestination(uint *Q_DECL_RESTRICT dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(color);
+ comp_func_solid_SourceOver (dest, length, 0xffffffff, const_alpha);
+}
+
+void QT_FASTCALL rasterop_NotDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(src);
+ rasterop_solid_SourceXorDestination (dest, length, 0x00ffffff, const_alpha);
+}
+
+void QT_FASTCALL rasterop_solid_NotDestination(uint *Q_DECL_RESTRICT dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(color);
+ rasterop_solid_SourceXorDestination (dest, length, 0x00ffffff, const_alpha);
+}
+
+CompositionFunctionSolid qt_functionForModeSolid_C[] = {
+ comp_func_solid_SourceOver,
+ comp_func_solid_DestinationOver,
+ comp_func_solid_Clear,
+ comp_func_solid_Source,
+ comp_func_solid_Destination,
+ comp_func_solid_SourceIn,
+ comp_func_solid_DestinationIn,
+ comp_func_solid_SourceOut,
+ comp_func_solid_DestinationOut,
+ comp_func_solid_SourceAtop,
+ comp_func_solid_DestinationAtop,
+ comp_func_solid_XOR,
+ comp_func_solid_Plus,
+ comp_func_solid_Multiply,
+ comp_func_solid_Screen,
+ comp_func_solid_Overlay,
+ comp_func_solid_Darken,
+ comp_func_solid_Lighten,
+ comp_func_solid_ColorDodge,
+ comp_func_solid_ColorBurn,
+ comp_func_solid_HardLight,
+ comp_func_solid_SoftLight,
+ comp_func_solid_Difference,
+ comp_func_solid_Exclusion,
+ rasterop_solid_SourceOrDestination,
+ rasterop_solid_SourceAndDestination,
+ rasterop_solid_SourceXorDestination,
+ rasterop_solid_NotSourceAndNotDestination,
+ rasterop_solid_NotSourceOrNotDestination,
+ rasterop_solid_NotSourceXorDestination,
+ rasterop_solid_NotSource,
+ rasterop_solid_NotSourceAndDestination,
+ rasterop_solid_SourceAndNotDestination,
+ rasterop_solid_NotSourceOrDestination,
+ rasterop_solid_SourceOrNotDestination,
+ rasterop_solid_ClearDestination,
+ rasterop_solid_SetDestination,
+ rasterop_solid_NotDestination
+};
+
+CompositionFunctionSolid64 qt_functionForModeSolid64_C[] = {
+ comp_func_solid_SourceOver_rgb64,
+ comp_func_solid_DestinationOver_rgb64,
+ comp_func_solid_Clear_rgb64,
+ comp_func_solid_Source_rgb64,
+ comp_func_solid_Destination_rgb64,
+ comp_func_solid_SourceIn_rgb64,
+ comp_func_solid_DestinationIn_rgb64,
+ comp_func_solid_SourceOut_rgb64,
+ comp_func_solid_DestinationOut_rgb64,
+ comp_func_solid_SourceAtop_rgb64,
+ comp_func_solid_DestinationAtop_rgb64,
+ comp_func_solid_XOR_rgb64,
+ comp_func_solid_Plus_rgb64,
+ 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
+};
+
+CompositionFunction qt_functionForMode_C[] = {
+ comp_func_SourceOver,
+ comp_func_DestinationOver,
+ comp_func_Clear,
+ comp_func_Source,
+ comp_func_Destination,
+ comp_func_SourceIn,
+ comp_func_DestinationIn,
+ comp_func_SourceOut,
+ comp_func_DestinationOut,
+ comp_func_SourceAtop,
+ comp_func_DestinationAtop,
+ comp_func_XOR,
+ comp_func_Plus,
+ comp_func_Multiply,
+ comp_func_Screen,
+ comp_func_Overlay,
+ comp_func_Darken,
+ comp_func_Lighten,
+ comp_func_ColorDodge,
+ comp_func_ColorBurn,
+ comp_func_HardLight,
+ comp_func_SoftLight,
+ comp_func_Difference,
+ comp_func_Exclusion,
+ rasterop_SourceOrDestination,
+ rasterop_SourceAndDestination,
+ rasterop_SourceXorDestination,
+ rasterop_NotSourceAndNotDestination,
+ rasterop_NotSourceOrNotDestination,
+ rasterop_NotSourceXorDestination,
+ rasterop_NotSource,
+ rasterop_NotSourceAndDestination,
+ rasterop_SourceAndNotDestination,
+ rasterop_NotSourceOrDestination,
+ rasterop_SourceOrNotDestination,
+ rasterop_ClearDestination,
+ rasterop_SetDestination,
+ rasterop_NotDestination
+};
+
+CompositionFunction64 qt_functionForMode64_C[] = {
+ comp_func_SourceOver_rgb64,
+ comp_func_DestinationOver_rgb64,
+ comp_func_Clear_rgb64,
+ comp_func_Source_rgb64,
+ comp_func_Destination_rgb64,
+ comp_func_SourceIn_rgb64,
+ comp_func_DestinationIn_rgb64,
+ comp_func_SourceOut_rgb64,
+ comp_func_DestinationOut_rgb64,
+ comp_func_SourceAtop_rgb64,
+ comp_func_DestinationAtop_rgb64,
+ comp_func_XOR_rgb64,
+ comp_func_Plus_rgb64,
+ 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
+};
+
+QT_END_NAMESPACE
diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp
index 8fb5f4fd3f..61d57ca3f8 100644
--- a/src/gui/painting/qcosmeticstroker.cpp
+++ b/src/gui/painting/qcosmeticstroker.cpp
@@ -33,6 +33,7 @@
#include "qcosmeticstroker_p.h"
#include "private/qpainterpath_p.h"
+#include "private/qrgba64_p.h"
#include <qdebug.h>
QT_BEGIN_NAMESPACE
@@ -280,7 +281,7 @@ void QCosmeticStroker::setup()
drawCaps = state->lastPen.capStyle() != Qt::FlatCap;
if (strokeSelection & FastDraw) {
- color = INTERPOLATE_PIXEL_256(state->penData.solid.color, opacity, 0, 0);
+ color = multiplyAlpha256(state->penData.solid.color, opacity).toArgb32();
QRasterBuffer *buffer = state->penData.rasterBuffer;
pixels = (uint *)buffer->buffer();
ppl = buffer->bytesPerLine()>>2;
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index d74b48a3ca..07e5a3d19b 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -51,6 +51,7 @@
#include <private/qdrawhelper_mips_dsp_p.h>
#endif
#include <private/qguiapplication_p.h>
+#include <private/qrgba64_p.h>
#include <qmath.h>
QT_BEGIN_NAMESPACE
@@ -184,6 +185,36 @@ static const uint *QT_FASTCALL convertToRGB32(uint *buffer, const uint *src, int
}
template<QImage::Format Format>
+static const QRgba64 *QT_FASTCALL convertToRGB64(QRgba64 *buffer, const uint *src, int count,
+ const QPixelLayout *, const QRgb *)
+{
+ Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1);
+ Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1);
+ Q_CONSTEXPR uint blueMask = ((1 << blueWidth<Format>()) - 1);
+
+ Q_CONSTEXPR uchar redLeftShift = 8 - redWidth<Format>();
+ Q_CONSTEXPR uchar greenLeftShift = 8 - greenWidth<Format>();
+ Q_CONSTEXPR uchar blueLeftShift = 8 - blueWidth<Format>();
+
+ Q_CONSTEXPR uchar redRightShift = 2 * redWidth<Format>() - 8;
+ Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth<Format>() - 8;
+ Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth<Format>() - 8;
+
+ for (int i = 0; i < count; ++i) {
+ uint red = (src[i] >> redShift<Format>()) & redMask;
+ uint green = (src[i] >> greenShift<Format>()) & greenMask;
+ uint blue = (src[i] >> blueShift<Format>()) & blueMask;
+
+ red = ((red << redLeftShift) | (red >> redRightShift)) << 16;
+ green = ((green << greenLeftShift) | (green >> greenRightShift)) << 8;
+ blue = (blue << blueLeftShift) | (blue >> blueRightShift);
+ buffer[i] = QRgba64::fromRgba(red, green, blue, 255);
+ }
+
+ return buffer;
+}
+
+template<QImage::Format Format>
static const uint *QT_FASTCALL convertARGBPMToARGB32PM(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
{
@@ -219,6 +250,41 @@ static const uint *QT_FASTCALL convertARGBPMToARGB32PM(uint *buffer, const uint
}
template<QImage::Format Format>
+static const QRgba64 *QT_FASTCALL convertARGBPMToARGB64PM(QRgba64 *buffer, const uint *src, int count,
+ const QPixelLayout *, const QRgb *)
+{
+ Q_CONSTEXPR uint alphaMask = ((1 << alphaWidth<Format>()) - 1);
+ Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1);
+ Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1);
+ Q_CONSTEXPR uint blueMask = ((1 << blueWidth<Format>()) - 1);
+
+ Q_CONSTEXPR uchar alphaLeftShift = 8 - alphaWidth<Format>();
+ Q_CONSTEXPR uchar redLeftShift = 8 - redWidth<Format>();
+ Q_CONSTEXPR uchar greenLeftShift = 8 - greenWidth<Format>();
+ Q_CONSTEXPR uchar blueLeftShift = 8 - blueWidth<Format>();
+
+ Q_CONSTEXPR uchar alphaRightShift = 2 * alphaWidth<Format>() - 8;
+ Q_CONSTEXPR uchar redRightShift = 2 * redWidth<Format>() - 8;
+ Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth<Format>() - 8;
+ Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth<Format>() - 8;
+
+ for (int i = 0; i < count; ++i) {
+ uint alpha = (src[i] >> alphaShift<Format>()) & alphaMask;
+ uint red = (src[i] >> redShift<Format>()) & redMask;
+ uint green = (src[i] >> greenShift<Format>()) & greenMask;
+ uint blue = (src[i] >> blueShift<Format>()) & blueMask;
+
+ alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift);
+ red = qMin(alpha, (red << redLeftShift) | (red >> redRightShift));
+ green = qMin(alpha, (green << greenLeftShift) | (green >> greenRightShift));
+ blue = qMin(alpha, (blue << blueLeftShift) | (blue >> blueRightShift));
+ buffer[i] = QRgba64::fromRgba(red, green, blue, alpha);
+ }
+
+ return buffer;
+}
+
+template<QImage::Format Format>
static const uint *QT_FASTCALL convertRGBFromARGB32PM(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
{
@@ -320,7 +386,8 @@ template<QImage::Format Format> Q_DECL_CONSTEXPR static inline QPixelLayout pixe
false, bitsPerPixel<Format>(),
convertToRGB32<Format>,
convertRGBFromARGB32PM<Format>,
- convertRGBFromRGB32<Format>
+ convertRGBFromRGB32<Format>,
+ convertToRGB64<Format>
};
}
@@ -334,7 +401,8 @@ template<QImage::Format Format> Q_DECL_CONSTEXPR static inline QPixelLayout pixe
true, bitsPerPixel<Format>(),
convertARGBPMToARGB32PM<Format>,
convertARGBPMFromARGB32PM<Format>,
- convertARGBPMFromRGB32<Format>
+ convertARGBPMFromRGB32<Format>,
+ convertARGBPMToARGB64PM<Format>
};
}
@@ -349,6 +417,14 @@ static const uint *QT_FASTCALL convertIndexedToARGB32PM(uint *buffer, const uint
return buffer;
}
+static const QRgba64 *QT_FASTCALL convertIndexedToARGB64PM(QRgba64 *buffer, const uint *src, int count,
+ const QPixelLayout *, const QRgb *clut)
+{
+ for (int i = 0; i < count; ++i)
+ buffer[i] = QRgba64::fromArgb32(clut[src[i]]).premultiplied();
+ return buffer;
+}
+
static const uint *QT_FASTCALL convertPassThrough(uint *, const uint *src, int,
const QPixelLayout *, const QRgb *)
{
@@ -391,6 +467,22 @@ static const uint *QT_FASTCALL convertGrayscale8ToRGB32(uint *buffer, const uint
return buffer;
}
+static const QRgba64 *QT_FASTCALL convertAlpha8ToRGB64(QRgba64 *buffer, const uint *src, int count,
+ const QPixelLayout *, const QRgb *)
+{
+ for (int i = 0; i < count; ++i)
+ buffer[i] = QRgba64::fromRgba(0, 0, 0, src[i]);
+ return buffer;
+}
+
+static const QRgba64 *QT_FASTCALL convertGrayscale8ToRGB64(QRgba64 *buffer, const uint *src, int count,
+ const QPixelLayout *, const QRgb *)
+{
+ for (int i = 0; i < count; ++i)
+ buffer[i] = QRgba64::fromRgba(src[i], src[i], src[i], 255);
+ return buffer;
+}
+
static const uint *QT_FASTCALL convertARGB32FromARGB32PM(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
{
@@ -407,6 +499,111 @@ static const uint *QT_FASTCALL convertRGBA8888PMFromARGB32PM(uint *buffer, const
return buffer;
}
+#ifdef __SSE2__
+template<bool RGBA, bool maskAlpha>
+static inline void qConvertARGB32PMToARGB64PM_sse2(QRgba64 *buffer, const uint *src, int count)
+{
+ const __m128i amask = _mm_set1_epi32(0xff000000);
+ int i = 0;
+ if (((uintptr_t)buffer & 0xf) && count > 0) {
+ uint s = *src++;
+ if (RGBA)
+ s = RGBA2ARGB(s);
+ *buffer++ = QRgba64::fromArgb32(s);
+ i++;
+ }
+ for (; i < count-3; i += 4) {
+ __m128i vs = _mm_loadu_si128((const __m128i*)src);
+ if (maskAlpha)
+ vs = _mm_or_si128(vs, amask);
+ src += 4;
+ __m128i v1 = _mm_unpacklo_epi8(vs, vs);
+ __m128i v2 = _mm_unpackhi_epi8(vs, vs);
+ if (!RGBA) {
+ v1 = _mm_shufflelo_epi16(v1, _MM_SHUFFLE(3, 0, 1, 2));
+ v2 = _mm_shufflelo_epi16(v2, _MM_SHUFFLE(3, 0, 1, 2));
+ v1 = _mm_shufflehi_epi16(v1, _MM_SHUFFLE(3, 0, 1, 2));
+ v2 = _mm_shufflehi_epi16(v2, _MM_SHUFFLE(3, 0, 1, 2));
+ }
+ _mm_store_si128((__m128i*)(buffer), v1);
+ buffer += 2;
+ _mm_store_si128((__m128i*)(buffer), v2);
+ buffer += 2;
+ }
+
+ for (; i < count; ++i) {
+ uint s = *src++;
+ if (RGBA)
+ s = RGBA2ARGB(s);
+ *buffer++ = QRgba64::fromArgb32(s);
+ }
+}
+#endif
+
+static const QRgba64 *QT_FASTCALL convertRGB32ToRGB64(QRgba64 *buffer, const uint *src, int count,
+ const QPixelLayout *, const QRgb *)
+{
+#ifdef __SSE2__
+ qConvertARGB32PMToARGB64PM_sse2<false, true>(buffer, src, count);
+#else
+ for (int i = 0; i < count; ++i)
+ buffer[i] = QRgba64::fromArgb32(0xff000000 | src[i]);
+#endif
+ return buffer;
+}
+
+static const QRgba64 *QT_FASTCALL convertARGB32ToARGB64PM(QRgba64 *buffer, const uint *src, int count,
+ const QPixelLayout *, const QRgb *)
+{
+#ifdef __SSE2__
+ qConvertARGB32PMToARGB64PM_sse2<false, false>(buffer, src, count);
+ for (int i = 0; i < count; ++i)
+ buffer[i] = buffer[i].premultiplied();
+#else
+ for (int i = 0; i < count; ++i)
+ buffer[i] = QRgba64::fromArgb32(src[i]).premultiplied();
+#endif
+ return buffer;
+}
+
+static const QRgba64 *QT_FASTCALL convertARGB32PMToARGB64PM(QRgba64 *buffer, const uint *src, int count,
+ const QPixelLayout *, const QRgb *)
+{
+#ifdef __SSE2__
+ qConvertARGB32PMToARGB64PM_sse2<false, false>(buffer, src, count);
+#else
+ for (int i = 0; i < count; ++i)
+ buffer[i] = QRgba64::fromArgb32(src[i]);
+#endif
+ return buffer;
+}
+
+static const QRgba64 *QT_FASTCALL convertRGBA8888ToARGB64PM(QRgba64 *buffer, const uint *src, int count,
+ const QPixelLayout *, const QRgb *)
+{
+#ifdef __SSE2__
+ qConvertARGB32PMToARGB64PM_sse2<true, false>(buffer, src, count);
+ for (int i = 0; i < count; ++i)
+ buffer[i] = buffer[i].premultiplied();
+#else
+ for (int i = 0; i < count; ++i)
+ buffer[i] = QRgba64::fromArgb32(RGBA2ARGB(src[i])).premultiplied();
+#endif
+ return buffer;
+}
+
+static const QRgba64 *QT_FASTCALL convertRGBA8888PMToARGB64PM(QRgba64 *buffer, const uint *src, int count,
+ const QPixelLayout *, const QRgb *)
+{
+#ifdef __SSE2__
+ qConvertARGB32PMToARGB64PM_sse2<true, false>(buffer, src, count);
+#else
+ for (int i = 0; i < count; ++i)
+ buffer[i] = QRgba64::fromArgb32(RGBA2ARGB(src[i]));
+#endif
+ return buffer;
+}
+
static const uint *QT_FASTCALL convertRGBA8888FromARGB32PM(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
{
@@ -440,6 +637,60 @@ static const uint *QT_FASTCALL convertA2RGB30PMToARGB32PM(uint *buffer, const ui
return buffer;
}
+#ifdef __SSE2__
+template<QtPixelOrder PixelOrder>
+static inline void qConvertA2RGB30PMToARGB64PM_sse2(QRgba64 *buffer, const uint *src, int count)
+{
+ const __m128i rmask = _mm_set1_epi32(0x3ff00000);
+ const __m128i gmask = _mm_set1_epi32(0x000ffc00);
+ const __m128i bmask = _mm_set1_epi32(0x000003ff);
+ const __m128i afactor = _mm_set1_epi16(0x5555);
+ int i = 0;
+ if (((uintptr_t)buffer & 0xf) && count > 0) {
+ *buffer++ = qConvertA2rgb30ToRgb64<PixelOrder>(*src++);
+ i++;
+ }
+ for (; i < count-3; i += 4) {
+ __m128i vs = _mm_loadu_si128((const __m128i*)src);
+ src += 4;
+ __m128i va = _mm_srli_epi32(vs, 30);
+ __m128i vr = _mm_and_si128(vs, rmask);
+ __m128i vb = _mm_and_si128(vs, bmask);
+ __m128i vg = _mm_and_si128(vs, gmask);
+ va = _mm_mullo_epi16(va, afactor);
+ vr = _mm_or_si128(_mm_srli_epi32(vr, 14), _mm_srli_epi32(vr, 24));
+ vg = _mm_or_si128(_mm_srli_epi32(vg, 4), _mm_srli_epi32(vg, 14));
+ vb = _mm_or_si128(_mm_slli_epi32(vb, 6), _mm_srli_epi32(vb, 4));
+ __m128i vrb;
+ if (PixelOrder == PixelOrderRGB)
+ vrb = _mm_or_si128(vr, _mm_slli_si128(vb, 2));
+ else
+ vrb = _mm_or_si128(vb, _mm_slli_si128(vr, 2));
+ __m128i vga = _mm_or_si128(vg, _mm_slli_si128(va, 2));
+ _mm_store_si128((__m128i*)(buffer), _mm_unpacklo_epi16(vrb, vga));
+ buffer += 2;
+ _mm_store_si128((__m128i*)(buffer), _mm_unpackhi_epi16(vrb, vga));
+ buffer += 2;
+ }
+
+ for (; i < count; ++i)
+ *buffer++ = qConvertA2rgb30ToRgb64<PixelOrder>(*src++);
+}
+#endif
+
+template<QtPixelOrder PixelOrder>
+static const QRgba64 *QT_FASTCALL convertA2RGB30PMToARGB64PM(QRgba64 *buffer, const uint *src, int count,
+ const QPixelLayout *, const QRgb *)
+{
+#ifdef __SSE2__
+ qConvertA2RGB30PMToARGB64PM_sse2<PixelOrder>(buffer, src, count);
+#else
+ for (int i = 0; i < count; ++i)
+ buffer[i] = qConvertA2rgb30ToRgb64<PixelOrder>(src[i]);
+#endif
+ return buffer;
+}
+
template<QtPixelOrder PixelOrder>
static const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
@@ -601,15 +852,15 @@ inline void QT_FASTCALL storePixels<QPixelLayout::BPP32>(uchar *dest, const uint
// convertFromArgb32() assumes that no color channel is more than 8 bits.
// QImage::rgbSwapped() assumes that the red and blue color channels have the same number of bits.
QPixelLayout qPixelLayouts[QImage::NImageFormats] = {
- { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPPNone, 0, 0, 0 }, // Format_Invalid
- { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP1MSB, convertIndexedToARGB32PM, 0, 0 }, // Format_Mono
- { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP1LSB, convertIndexedToARGB32PM, 0, 0 }, // Format_MonoLSB
- { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP8, convertIndexedToARGB32PM, 0, 0 }, // Format_Indexed8
+ { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPPNone, 0, 0, 0, 0 }, // Format_Invalid
+ { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP1MSB, convertIndexedToARGB32PM, 0, 0, convertIndexedToARGB64PM }, // Format_Mono
+ { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP1LSB, convertIndexedToARGB32PM, 0, 0, convertIndexedToARGB64PM }, // Format_MonoLSB
+ { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP8, convertIndexedToARGB32PM, 0, 0, convertIndexedToARGB64PM }, // Format_Indexed8
// Technically using convertPassThrough to convert from ARGB32PM to RGB32 is wrong,
// but everywhere this generic conversion would be wrong is currently overloaded.
- { 8, 16, 8, 8, 8, 0, 0, 0, false, QPixelLayout::BPP32, convertPassThrough, convertPassThrough, convertPassThrough }, // Format_RGB32
- { 8, 16, 8, 8, 8, 0, 8, 24, false, QPixelLayout::BPP32, convertARGB32ToARGB32PM, convertARGB32FromARGB32PM, convertPassThrough }, // Format_ARGB32
- { 8, 16, 8, 8, 8, 0, 8, 24, true, QPixelLayout::BPP32, convertPassThrough, convertPassThrough, convertPassThrough }, // Format_ARGB32_Premultiplied
+ { 8, 16, 8, 8, 8, 0, 0, 0, false, QPixelLayout::BPP32, convertPassThrough, convertPassThrough, convertPassThrough, convertRGB32ToRGB64 }, // Format_RGB32
+ { 8, 16, 8, 8, 8, 0, 8, 24, false, QPixelLayout::BPP32, convertARGB32ToARGB32PM, convertARGB32FromARGB32PM, convertPassThrough, convertARGB32ToARGB64PM }, // Format_ARGB32
+ { 8, 16, 8, 8, 8, 0, 8, 24, true, QPixelLayout::BPP32, convertPassThrough, convertPassThrough, convertPassThrough, convertARGB32PMToARGB64PM }, // Format_ARGB32_Premultiplied
#ifdef Q_COMPILER_CONSTEXPR
pixelLayoutRGB<QImage::Format_RGB16>(),
pixelLayoutARGBPM<QImage::Format_ARGB8565_Premultiplied>(),
@@ -624,55 +875,73 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = {
{ 5, 11, 6, 5, 5, 0, 0, 0, false, QPixelLayout::BPP16,
convertToRGB32<QImage::Format_RGB16>,
convertRGBFromARGB32PM<QImage::Format_RGB16>,
- convertRGBFromRGB32<QImage::Format_RGB16>},
+ convertRGBFromRGB32<QImage::Format_RGB16>,
+ convertToRGB64<QImage::Format_RGB16>,
+ },
{ 5, 19, 6, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24,
convertARGBPMToARGB32PM<QImage::Format_ARGB8565_Premultiplied>,
convertARGBPMFromARGB32PM<QImage::Format_ARGB8565_Premultiplied>,
- convertARGBPMFromRGB32<QImage::Format_ARGB8565_Premultiplied>},
+ convertARGBPMFromRGB32<QImage::Format_ARGB8565_Premultiplied>,
+ convertARGBPMToARGB64PM<QImage::Format_ARGB8565_Premultiplied>,
+ },
{ 6, 12, 6, 6, 6, 0, 0, 0, false, QPixelLayout::BPP24,
convertToRGB32<QImage::Format_RGB666>,
convertRGBFromARGB32PM<QImage::Format_RGB666>,
- convertRGBFromRGB32<QImage::Format_RGB666>},
+ convertRGBFromRGB32<QImage::Format_RGB666>,
+ convertToRGB64<QImage::Format_RGB666>,
+ },
{ 6, 12, 6, 6, 6, 0, 6, 18, true, QPixelLayout::BPP24,
convertARGBPMToARGB32PM<QImage::Format_ARGB6666_Premultiplied>,
convertARGBPMFromARGB32PM<QImage::Format_ARGB6666_Premultiplied>,
- convertARGBPMFromRGB32<QImage::Format_ARGB6666_Premultiplied>},
+ convertARGBPMFromRGB32<QImage::Format_ARGB6666_Premultiplied>,
+ convertARGBPMToARGB64PM<QImage::Format_ARGB6666_Premultiplied>,
+ },
{ 5, 10, 5, 5, 5, 0, 0, 0, false, QPixelLayout::BPP16,
convertToRGB32<QImage::Format_RGB555>,
convertRGBFromARGB32PM<QImage::Format_RGB555>,
- convertRGBFromRGB32<QImage::Format_RGB555> },
+ convertRGBFromRGB32<QImage::Format_RGB555>,
+ convertToRGB64<QImage::Format_RGB555>,
+ },
{ 5, 18, 5, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24,
convertARGBPMToARGB32PM<QImage::Format_ARGB8555_Premultiplied>,
convertARGBPMFromARGB32PM<QImage::Format_ARGB8555_Premultiplied>,
- convertARGBPMFromRGB32<QImage::Format_ARGB8555_Premultiplied>},
+ convertARGBPMFromRGB32<QImage::Format_ARGB8555_Premultiplied>,
+ convertARGBPMToARGB64PM<QImage::Format_ARGB8555_Premultiplied>,
+ },
{ 8, 16, 8, 8, 8, 0, 0, 0, false, QPixelLayout::BPP24,
convertToRGB32<QImage::Format_RGB888>,
convertRGBFromARGB32PM<QImage::Format_RGB888>,
- convertRGBFromRGB32<QImage::Format_RGB888>},
+ convertRGBFromRGB32<QImage::Format_RGB888>,
+ convertToRGB64<QImage::Format_RGB888>,
+ },
{ 4, 8, 4, 4, 4, 0, 0, 0, false, QPixelLayout::BPP16,
convertToRGB32<QImage::Format_RGB444>,
convertRGBFromARGB32PM<QImage::Format_RGB444>,
- convertRGBFromRGB32<QImage::Format_RGB444>},
+ convertRGBFromRGB32<QImage::Format_RGB444>,
+ convertToRGB64<QImage::Format_RGB444>,
+ },
{ 4, 8, 4, 4, 4, 0, 4, 12, true, QPixelLayout::BPP16,
convertARGBPMToARGB32PM<QImage::Format_ARGB4444_Premultiplied>,
convertARGBPMFromARGB32PM<QImage::Format_ARGB4444_Premultiplied>,
- convertARGBPMFromRGB32<QImage::Format_ARGB4444_Premultiplied>},
+ convertARGBPMFromRGB32<QImage::Format_ARGB4444_Premultiplied>,
+ convertARGBPMToARGB64PM<QImage::Format_ARGB4444_Premultiplied>,
+ },
#endif
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- { 8, 24, 8, 16, 8, 8, 0, 0, false, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBXFromARGB32PM, convertRGBXFromRGB32 }, // Format_RGBX8888
- { 8, 24, 8, 16, 8, 8, 8, 0, false, QPixelLayout::BPP32, convertRGBA8888ToARGB32PM, convertRGBA8888FromARGB32PM, convertRGBXFromRGB32 }, // Format_RGBA8888
- { 8, 24, 8, 16, 8, 8, 8, 0, true, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBA8888PMFromARGB32PM, convertRGBXFromRGB32}, // Format_RGBA8888_Premultiplied
+ { 8, 24, 8, 16, 8, 8, 0, 0, false, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBXFromARGB32PM, convertRGBXFromRGB32, convertRGBA8888PMToARGB64PM }, // Format_RGBX8888
+ { 8, 24, 8, 16, 8, 8, 8, 0, false, QPixelLayout::BPP32, convertRGBA8888ToARGB32PM, convertRGBA8888FromARGB32PM, convertRGBXFromRGB32, convertRGBA8888ToARGB64PM }, // Format_RGBA8888
+ { 8, 24, 8, 16, 8, 8, 8, 0, true, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBA8888PMFromARGB32PM, convertRGBXFromRGB32, convertRGBA8888PMToARGB64PM}, // Format_RGBA8888_Premultiplied
#else
- { 8, 0, 8, 8, 8, 16, 0, 24, false, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBXFromARGB32PM, convertRGBXFromRGB32 }, // Format_RGBX8888
- { 8, 0, 8, 8, 8, 16, 8, 24, false, QPixelLayout::BPP32, convertRGBA8888ToARGB32PM, convertRGBA8888FromARGB32PM, convertRGBXFromRGB32 }, // Format_RGBA8888 (ABGR32)
- { 8, 0, 8, 8, 8, 16, 8, 24, true, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBA8888PMFromARGB32PM, convertRGBXFromRGB32 }, // Format_RGBA8888_Premultiplied
+ { 8, 0, 8, 8, 8, 16, 0, 24, false, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBXFromARGB32PM, convertRGBXFromRGB32, convertRGBA8888PMToARGB64PM }, // Format_RGBX8888
+ { 8, 0, 8, 8, 8, 16, 8, 24, false, QPixelLayout::BPP32, convertRGBA8888ToARGB32PM, convertRGBA8888FromARGB32PM, convertRGBXFromRGB32, convertRGBA8888ToARGB64PM }, // Format_RGBA8888 (ABGR32)
+ { 8, 0, 8, 8, 8, 16, 8, 24, true, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBA8888PMFromARGB32PM, convertRGBXFromRGB32, convertRGBA8888PMToARGB64PM }, // Format_RGBA8888_Premultiplied
#endif
- { 10, 20, 10, 10, 10, 0, 0, 30, false, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderBGR>, convertRGB30FromARGB32PM<PixelOrderBGR>, convertRGB30FromRGB32<PixelOrderBGR> }, // Format_BGR30
- { 10, 20, 10, 10, 10, 0, 2, 30, true, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderBGR>, convertA2RGB30PMFromARGB32PM<PixelOrderBGR>, convertRGB30FromRGB32<PixelOrderBGR> }, // Format_A2BGR30_Premultiplied
- { 10, 0, 10, 10, 10, 20, 0, 30, false, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderRGB>, convertRGB30FromARGB32PM<PixelOrderRGB>, convertRGB30FromRGB32<PixelOrderRGB> }, // Format_RGB30
- { 10, 0, 10, 10, 10, 20, 2, 30, true, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderRGB>, convertA2RGB30PMFromARGB32PM<PixelOrderRGB>, convertRGB30FromRGB32<PixelOrderRGB> }, // Format_A2RGB30_Premultiplied
- { 0, 0, 0, 0, 0, 0, 8, 0, false, QPixelLayout::BPP8, convertAlpha8ToRGB32, convertAlpha8FromARGB32PM, 0 }, // Format_Alpha8
- { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP8, convertGrayscale8ToRGB32, convertGrayscale8FromARGB32PM, convertGrayscale8FromRGB32 } // Format_Grayscale8
+ { 10, 20, 10, 10, 10, 0, 0, 30, false, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderBGR>, convertRGB30FromARGB32PM<PixelOrderBGR>, convertRGB30FromRGB32<PixelOrderBGR>, convertA2RGB30PMToARGB64PM<PixelOrderBGR> }, // Format_BGR30
+ { 10, 20, 10, 10, 10, 0, 2, 30, true, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderBGR>, convertA2RGB30PMFromARGB32PM<PixelOrderBGR>, convertRGB30FromRGB32<PixelOrderBGR>, convertA2RGB30PMToARGB64PM<PixelOrderBGR> }, // Format_A2BGR30_Premultiplied
+ { 10, 0, 10, 10, 10, 20, 0, 30, false, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderRGB>, convertRGB30FromARGB32PM<PixelOrderRGB>, convertRGB30FromRGB32<PixelOrderRGB>, convertA2RGB30PMToARGB64PM<PixelOrderRGB> }, // Format_RGB30
+ { 10, 0, 10, 10, 10, 20, 2, 30, true, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderRGB>, convertA2RGB30PMFromARGB32PM<PixelOrderRGB>, convertRGB30FromRGB32<PixelOrderRGB>, convertA2RGB30PMToARGB64PM<PixelOrderRGB> }, // Format_A2RGB30_Premultiplied
+ { 0, 0, 0, 0, 0, 0, 8, 0, false, QPixelLayout::BPP8, convertAlpha8ToRGB32, convertAlpha8FromARGB32PM, 0, convertAlpha8ToRGB64 }, // Format_Alpha8
+ { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP8, convertGrayscale8ToRGB32, convertGrayscale8FromARGB32PM, convertGrayscale8FromRGB32, convertGrayscale8ToRGB64 } // Format_Grayscale8
};
const FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount] = {
@@ -758,6 +1027,20 @@ static uint *QT_FASTCALL destFetch(uint *buffer, QRasterBuffer *rasterBuffer, in
return const_cast<uint *>(layout->convertToARGB32PM(buffer, ptr, length, layout, 0));
}
+static QRgba64 *QT_FASTCALL destFetch64(QRgba64 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length)
+{
+ const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format];
+ uint buffer32[buffer_size];
+ const uint *ptr = qFetchPixels[layout->bpp](buffer32, rasterBuffer->scanLine(y), x, length);
+ return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, ptr, length, layout, 0));
+}
+
+static QRgba64 *QT_FASTCALL destFetch64uint32(QRgba64 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length)
+{
+ const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format];
+ const uint *src = ((const uint *)rasterBuffer->scanLine(y)) + x;
+ return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, src, length, layout, 0));
+}
static DestFetchProc destFetchProc[QImage::NImageFormats] =
{
@@ -788,6 +1071,35 @@ static DestFetchProc destFetchProc[QImage::NImageFormats] =
destFetch, // Format_Grayscale8
};
+static DestFetchProc64 destFetchProc64[QImage::NImageFormats] =
+{
+ 0, // Format_Invalid
+ destFetch64, // Format_Mono,
+ destFetch64, // Format_MonoLSB
+ 0, // Format_Indexed8
+ destFetch64uint32, // Format_RGB32
+ destFetch64uint32, // Format_ARGB32,
+ destFetch64uint32, // Format_ARGB32_Premultiplied
+ destFetch64, // Format_RGB16
+ destFetch64, // Format_ARGB8565_Premultiplied
+ destFetch64, // Format_RGB666
+ destFetch64, // Format_ARGB6666_Premultiplied
+ destFetch64, // Format_RGB555
+ destFetch64, // Format_ARGB8555_Premultiplied
+ destFetch64, // Format_RGB888
+ destFetch64, // Format_RGB444
+ destFetch64, // Format_ARGB4444_Premultiplied
+ destFetch64uint32, // Format_RGBX8888
+ destFetch64uint32, // Format_RGBA8888
+ destFetch64uint32, // Format_RGBA8888_Premultiplied
+ destFetch64uint32, // Format_BGR30
+ destFetch64uint32, // Format_A2BGR30_Premultiplied
+ destFetch64uint32, // Format_RGB30
+ destFetch64uint32, // Format_A2RGB30_Premultiplied
+ destFetch64, // Format_Alpha8
+ destFetch64, // Format_Grayscale8
+};
+
/*
Returns the color in the mono destination color table
that is the "nearest" to /color/.
@@ -904,6 +1216,97 @@ static void QT_FASTCALL destStore(QRasterBuffer *rasterBuffer, int x, int y, con
}
}
+static void QT_FASTCALL convertFromRgb64(uint *dest, const QRgba64 *src, int length)
+{
+ for (int i = 0; i < length; ++i) {
+ dest[i] = src[i].toArgb32();
+ }
+}
+
+static void QT_FASTCALL destStore64(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length)
+{
+ uint buf[buffer_size];
+ const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format];
+ StorePixelsFunc store = qStorePixels[layout->bpp];
+ uchar *dest = rasterBuffer->scanLine(y);
+ while (length) {
+ int l = qMin(length, buffer_size);
+ const uint *ptr = 0;
+ convertFromRgb64(buf, buffer, l);
+ if (!layout->premultiplied && !layout->alphaWidth)
+ ptr = layout->convertFromRGB32(buf, buf, l, layout, 0);
+ else
+ ptr = layout->convertFromARGB32PM(buf, buf, l, layout, 0);
+ store(dest, ptr, x, l);
+ length -= l;
+ buffer += l;
+ x += l;
+ }
+}
+
+#ifdef __SSE2__
+template<QtPixelOrder PixelOrder>
+static inline void qConvertARGB64PMToA2RGB30PM_sse2(uint *dest, const QRgba64 *buffer, int count)
+{
+ const __m128i gmask = _mm_set1_epi32(0x000ffc00);
+ const __m128i cmask = _mm_set1_epi32(0x000003ff);
+ int i = 0;
+ __m128i vr, vg, vb, va;
+ for (; i < count-1; i += 2) {
+ __m128i vs = _mm_loadu_si128((const __m128i*)buffer);
+ buffer += 2;
+ vr = _mm_srli_epi64(vs, 6);
+ vg = _mm_srli_epi64(vs, 16 + 6 - 10);
+ vb = _mm_srli_epi64(vs, 32 + 6);
+ vr = _mm_and_si128(vr, cmask);
+ vg = _mm_and_si128(vg, gmask);
+ vb = _mm_and_si128(vb, cmask);
+ va = _mm_srli_epi64(vs, 48 + 14);
+ if (PixelOrder == PixelOrderRGB)
+ vr = _mm_slli_epi32(vr, 20);
+ else
+ vb = _mm_slli_epi32(vb, 20);
+ va = _mm_slli_epi32(va, 30);
+ __m128i vd = _mm_or_si128(_mm_or_si128(vr, vg), _mm_or_si128(vb, va));
+ vd = _mm_shuffle_epi32(vd, _MM_SHUFFLE(3, 1, 2, 0));
+ _mm_storel_epi64((__m128i*)dest, vd);
+ dest += 2;
+ }
+
+ for (; i < count; ++i)
+ *dest++ = qConvertRgb64ToRgb30<PixelOrder>(*buffer++);
+}
+#endif
+
+static void QT_FASTCALL destStore64ARGB32(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length)
+{
+ uint *dest = (uint*)rasterBuffer->scanLine(y) + x;
+ for (int i = 0; i < length; ++i) {
+ dest[i] = buffer[i].unpremultiplied().toArgb32();
+ }
+}
+
+static void QT_FASTCALL destStore64RGBA8888(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length)
+{
+ uint *dest = (uint*)rasterBuffer->scanLine(y) + x;
+ for (int i = 0; i < length; ++i) {
+ dest[i] = ARGB2RGBA(buffer[i].unpremultiplied().toArgb32());
+ }
+}
+
+template<QtPixelOrder PixelOrder>
+static void QT_FASTCALL destStore64RGB30(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length)
+{
+ uint *dest = (uint*)rasterBuffer->scanLine(y) + x;
+#ifdef __SSE2__
+ qConvertARGB64PMToA2RGB30PM_sse2<PixelOrder>(dest, buffer, length);
+#else
+ for (int i = 0; i < length; ++i) {
+ dest[i] = qConvertRgb64ToRgb30<PixelOrder>(buffer[i]);
+ }
+#endif
+}
+
static DestStoreProc destStoreProc[QImage::NImageFormats] =
{
0, // Format_Invalid
@@ -933,6 +1336,35 @@ static DestStoreProc destStoreProc[QImage::NImageFormats] =
destStore, // Format_Grayscale8
};
+static DestStoreProc64 destStoreProc64[QImage::NImageFormats] =
+{
+ 0, // Format_Invalid
+ destStore64, // Format_Mono,
+ destStore64, // Format_MonoLSB
+ 0, // Format_Indexed8
+ destStore64, // Format_RGB32
+ destStore64ARGB32, // Format_ARGB32,
+ destStore64, // Format_ARGB32_Premultiplied
+ destStore64, // Format_RGB16
+ destStore64, // Format_ARGB8565_Premultiplied
+ destStore64, // Format_RGB666
+ destStore64, // Format_ARGB6666_Premultiplied
+ destStore64, // Format_RGB555
+ destStore64, // Format_ARGB8555_Premultiplied
+ destStore64, // Format_RGB888
+ destStore64, // Format_RGB444
+ destStore64, // Format_ARGB4444_Premultiplied
+ destStore64, // Format_RGBX8888
+ destStore64RGBA8888, // Format_RGBA8888
+ destStore64, // Format_RGBA8888_Premultiplied
+ destStore64RGB30<PixelOrderBGR>, // Format_BGR30
+ destStore64RGB30<PixelOrderBGR>, // Format_A2BGR30_Premultiplied
+ destStore64RGB30<PixelOrderRGB>, // Format_RGB30
+ destStore64RGB30<PixelOrderRGB>, // Format_A2RGB30_Premultiplied
+ destStore64, // Format_Alpha8
+ destStore64, // Format_Grayscale8
+};
+
/*
Source fetches
@@ -988,6 +1420,21 @@ static const uint *QT_FASTCALL fetchUntransformedRGB16(uint *buffer, const Opera
return buffer;
}
+static const QRgba64 *QT_FASTCALL fetchUntransformed64(QRgba64 *buffer, const Operator *,
+ const QSpanData *data, int y, int x, int length)
+{
+ const QPixelLayout *layout = &qPixelLayouts[data->texture.format];
+ const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0;
+ if (layout->bpp != QPixelLayout::BPP32) {
+ uint buffer32[buffer_size];
+ const uint *ptr = qFetchPixels[layout->bpp](buffer32, data->texture.scanLine(y), x, length);
+ return layout->convertToARGB64PM(buffer, ptr, length, layout, clut);
+ } else {
+ const uint *src = (const uint *)data->texture.scanLine(y) + x;
+ return layout->convertToARGB64PM(buffer, src, length, layout, clut);
+ }
+}
+
// blendType is either BlendTransformed or BlendTransformedTiled
template<TextureBlendType blendType>
static const uint *QT_FASTCALL fetchTransformedARGB32PM(uint *buffer, const Operator *, const QSpanData *data,
@@ -1155,6 +1602,111 @@ static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *,
return layout->convertToARGB32PM(buffer, buffer, length, layout, clut);
}
+template<TextureBlendType blendType> /* either BlendTransformed or BlendTransformedTiled */
+static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Operator *, const QSpanData *data,
+ int y, int x, int length)
+{
+ int image_width = data->texture.width;
+ int image_height = data->texture.height;
+
+ const qreal cx = x + qreal(0.5);
+ const qreal cy = y + qreal(0.5);
+
+ const QPixelLayout *layout = &qPixelLayouts[data->texture.format];
+ FetchPixelFunc fetch = qFetchPixel[layout->bpp];
+ const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0;
+
+ uint buffer32[buffer_size];
+ QRgba64 *b = buffer;
+ if (data->fast_matrix) {
+ // The increment pr x in the scanline
+ int fdx = (int)(data->m11 * fixed_scale);
+ int fdy = (int)(data->m12 * fixed_scale);
+
+ int fx = int((data->m21 * cy
+ + data->m11 * cx + data->dx) * fixed_scale);
+ int fy = int((data->m22 * cy
+ + data->m12 * cx + data->dy) * fixed_scale);
+
+ int i = 0, j = 0;
+ while (i < length) {
+ if (j == buffer_size) {
+ layout->convertToARGB64PM(b, buffer32, buffer_size, layout, clut);
+ b += buffer_size;
+ j = 0;
+ }
+ int px = fx >> 16;
+ int py = fy >> 16;
+
+ if (blendType == BlendTransformedTiled) {
+ px %= image_width;
+ py %= image_height;
+ if (px < 0) px += image_width;
+ if (py < 0) py += image_height;
+ } else {
+ px = qBound(0, px, image_width - 1);
+ py = qBound(0, py, image_height - 1);
+ }
+ buffer32[j] = fetch(data->texture.scanLine(py), px);
+
+ fx += fdx;
+ fy += fdy;
+ ++i; ++j;
+ }
+ if (j > 0) {
+ layout->convertToARGB64PM(b, buffer32, j, layout, clut);
+ b += j;
+ }
+ } else {
+ const qreal fdx = data->m11;
+ const qreal fdy = data->m12;
+ const qreal fdw = data->m13;
+
+ qreal fx = data->m21 * cy + data->m11 * cx + data->dx;
+ qreal fy = data->m22 * cy + data->m12 * cx + data->dy;
+ qreal fw = data->m23 * cy + data->m13 * cx + data->m33;
+
+ int i = 0, j = 0;
+ while (i < length) {
+ if (j == buffer_size) {
+ layout->convertToARGB64PM(b, buffer32, buffer_size, layout, clut);
+ b += buffer_size;
+ j = 0;
+ }
+ const qreal iw = fw == 0 ? 1 : 1 / fw;
+ const qreal tx = fx * iw;
+ const qreal ty = fy * iw;
+ int px = int(tx) - (tx < 0);
+ int py = int(ty) - (ty < 0);
+
+ if (blendType == BlendTransformedTiled) {
+ px %= image_width;
+ py %= image_height;
+ if (px < 0) px += image_width;
+ if (py < 0) py += image_height;
+ } else {
+ px = qBound(0, px, image_width - 1);
+ py = qBound(0, py, image_height - 1);
+ }
+ buffer32[j] = fetch(data->texture.scanLine(py), px);
+
+ fx += fdx;
+ fy += fdy;
+ fw += fdw;
+ //force increment to avoid /0
+ if (!fw) {
+ fw += fdw;
+ }
+ ++i; ++j;
+ }
+ if (j > 0) {
+ layout->convertToARGB64PM(b, buffer32, j, layout, clut);
+ b += j;
+ }
+ }
+ return buffer;
+}
+
/** \internal
interpolate 4 argb pixels with the distx and disty factor.
distx and disty bust be between 0 and 16
@@ -1245,6 +1797,42 @@ static inline uint interpolate_4_pixels_16(uint tl, uint tr, uint bl, uint br, i
}
#endif
+#if defined(__SSE2__)
+static inline QRgba64 interpolate_4_pixels_rgb64(QRgba64 t[], QRgba64 b[], uint distx, uint disty)
+{
+ const __m128i vdistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(distx), _MM_SHUFFLE(0, 0, 0, 0));
+ const __m128i vidistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(0x10000 - distx), _MM_SHUFFLE(0, 0, 0, 0));
+
+ __m128i vt = _mm_loadu_si128((const __m128i*)t);
+ if (disty) {
+ __m128i vb = _mm_loadu_si128((const __m128i*)b);
+ vt = _mm_mulhi_epu16(vt, _mm_set1_epi16(0x10000 - disty));
+ vb = _mm_mulhi_epu16(vb, _mm_set1_epi16(disty));
+ vt = _mm_add_epi16(vt, vb);
+ }
+ vt = _mm_mulhi_epu16(vt, _mm_unpacklo_epi64(vidistx, vdistx));
+ vt = _mm_add_epi16(vt, _mm_srli_si128(vt, 8));
+#ifdef Q_PROCESSOR_X86_64
+ return QRgba64::fromRgba64(_mm_cvtsi128_si64(vt));
+#else
+ QRgba64 out;
+ _mm_storel_epi64((__m128i*)&out, vt);
+ return out;
+#endif
+}
+#else
+static inline QRgba64 interpolate_4_pixels_rgb64(QRgba64 t[], QRgba64 b[], uint distx, uint disty)
+{
+ const uint dx = distx>>8;
+ const uint dy = disty>>8;
+ const uint idx = 256 - dx;
+ const uint idy = 256 - dy;
+ QRgba64 xtop = interpolate256(t[0], idx, t[1], dx);
+ QRgba64 xbot = interpolate256(b[0], idx, b[1], dx);
+ return interpolate256(xtop, idy, xbot, dy);
+}
+#endif
+
template<TextureBlendType blendType>
void fetchTransformedBilinear_pixelBounds(int max, int l1, int l2, int &v1, int &v2);
@@ -2130,6 +2718,349 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
return buffer;
}
+template<TextureBlendType blendType>
+static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, const Operator *,
+ const QSpanData *data, int y, int x, int length)
+{
+ const QPixelLayout *layout = &qPixelLayouts[data->texture.format];
+ const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0;
+
+ int image_width = data->texture.width;
+ int image_height = data->texture.height;
+
+ int image_x1 = data->texture.x1;
+ int image_y1 = data->texture.y1;
+ int image_x2 = data->texture.x2 - 1;
+ int image_y2 = data->texture.y2 - 1;
+
+ const qreal cx = x + qreal(0.5);
+ const qreal cy = y + qreal(0.5);
+
+ const qreal fdx = data->m11;
+ const qreal fdy = data->m12;
+ const qreal fdw = data->m13;
+
+ if (data->fast_matrix) {
+ // The increment pr x in the scanline
+ int fdx = (int)(data->m11 * fixed_scale);
+ int fdy = (int)(data->m12 * fixed_scale);
+
+ int fx = int((data->m21 * cy + data->m11 * cx + data->dx) * fixed_scale);
+ int fy = int((data->m22 * cy + data->m12 * cx + data->dy) * fixed_scale);
+
+ fx -= half_point;
+ fy -= half_point;
+
+ if (fdy == 0) { //simple scale, no rotation
+ int y1 = (fy >> 16);
+ int y2;
+ fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2);
+ const uchar *s1 = data->texture.scanLine(y1);
+ const uchar *s2 = data->texture.scanLine(y2);
+
+ FetchPixelFunc fetch = qFetchPixel[layout->bpp];
+ uint sbuf1[buffer_size];
+ uint sbuf2[buffer_size];
+ QRgba64 buf1[buffer_size];
+ QRgba64 buf2[buffer_size];
+ QRgba64 *b = buffer;
+ while (length) {
+ int len = qMin(length, buffer_size / 2);
+ int fracX = fx;
+ int i = 0;
+ int disty = (fy & 0x0000ffff);
+#if defined(__SSE2__)
+ const __m128i vdy = _mm_set1_epi16(disty);
+ const __m128i vidy = _mm_set1_epi16(0x10000 - disty);
+ if (blendType != BlendTransformedBilinearTiled && layout->bpp == QPixelLayout::BPP32) {
+ for (; i < len; ++i) {
+ int x1 = (fx >> 16);
+ int x2;
+ fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2);
+ if (x1 != x2)
+ break;
+ sbuf1[i * 2 + 0] = ((const uint*)s1)[x1];
+ sbuf1[i * 2 + 1] = ((const uint*)s1)[x2];
+ sbuf2[i * 2 + 0] = ((const uint*)s2)[x1];
+ sbuf2[i * 2 + 1] = ((const uint*)s2)[x2];
+ fx += fdx;
+ }
+
+ const __m128i v_fdx = _mm_set1_epi32(fdx*4);
+ __m128i v_fx = _mm_setr_epi32(fx, fx + fdx, fx + fdx + fdx, fx + fdx + fdx + fdx);
+ for (; i < len-3; i+=4) {
+ int offset = _mm_extract_epi16(v_fx, 1);
+ sbuf1[i * 2 + 0] = ((const uint*)s1)[offset];
+ sbuf1[i * 2 + 1] = ((const uint*)s1)[offset + 1];
+ sbuf2[i * 2 + 0] = ((const uint*)s2)[offset];
+ sbuf2[i * 2 + 1] = ((const uint*)s2)[offset + 1];
+ offset = _mm_extract_epi16(v_fx, 3);
+ sbuf1[i * 2 + 2] = ((const uint*)s1)[offset];
+ sbuf1[i * 2 + 3] = ((const uint*)s1)[offset + 1];
+ sbuf2[i * 2 + 2] = ((const uint*)s2)[offset];
+ sbuf2[i * 2 + 3] = ((const uint*)s2)[offset + 1];
+ offset = _mm_extract_epi16(v_fx, 5);
+ sbuf1[i * 2 + 4] = ((const uint*)s1)[offset];
+ sbuf1[i * 2 + 5] = ((const uint*)s1)[offset + 1];
+ sbuf2[i * 2 + 4] = ((const uint*)s2)[offset];
+ sbuf2[i * 2 + 5] = ((const uint*)s2)[offset + 1];
+ offset = _mm_extract_epi16(v_fx, 7);
+ sbuf1[i * 2 + 6] = ((const uint*)s1)[offset];
+ sbuf1[i * 2 + 7] = ((const uint*)s1)[offset + 1];
+ sbuf2[i * 2 + 6] = ((const uint*)s2)[offset];
+ sbuf2[i * 2 + 7] = ((const uint*)s2)[offset + 1];
+ v_fx = _mm_add_epi32(v_fx, v_fdx);
+ }
+ fx = _mm_cvtsi128_si32(v_fx);
+ }
+#endif
+ for (; i < len; ++i) {
+ int x1 = (fx >> 16);
+ int x2;
+ fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2);
+
+ if (layout->bpp == QPixelLayout::BPP32) {
+ sbuf1[i * 2 + 0] = ((const uint*)s1)[x1];
+ sbuf1[i * 2 + 1] = ((const uint*)s1)[x2];
+ sbuf2[i * 2 + 0] = ((const uint*)s2)[x1];
+ sbuf2[i * 2 + 1] = ((const uint*)s2)[x2];
+
+ } else {
+ sbuf1[i * 2 + 0] = fetch(s1, x1);
+ sbuf1[i * 2 + 1] = fetch(s1, x2);
+ sbuf2[i * 2 + 0] = fetch(s2, x1);
+ sbuf2[i * 2 + 1] = fetch(s2, x2);
+ }
+
+ fx += fdx;
+ }
+ layout->convertToARGB64PM(buf1, sbuf1, len * 2, layout, clut);
+ if (disty)
+ layout->convertToARGB64PM(buf2, sbuf2, len * 2, layout, clut);
+
+ for (int i = 0; i < len; ++i) {
+ int distx = (fracX & 0x0000ffff);
+#if defined(__SSE2__)
+ const __m128i vdistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(distx), _MM_SHUFFLE(0, 0, 0, 0));
+ const __m128i vidistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(0x10000 - distx), _MM_SHUFFLE(0, 0, 0, 0));
+ __m128i vt = _mm_loadu_si128((const __m128i*)(buf1 + i*2));
+ if (disty) {
+ __m128i vb = _mm_loadu_si128((const __m128i*)(buf2 + i*2));
+ vt = _mm_mulhi_epu16(vt, vidy);
+ vb = _mm_mulhi_epu16(vb, vdy);
+ vt = _mm_add_epi16(vt, vb);
+ }
+ vt = _mm_mulhi_epu16(vt, _mm_unpacklo_epi64(vidistx, vdistx));
+ vt = _mm_add_epi16(vt, _mm_srli_si128(vt, 8));
+ _mm_storel_epi64((__m128i*)(b+i), vt);
+#else
+ b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty);
+#endif
+ fracX += fdx;
+ }
+ length -= len;
+ b += len;
+ }
+ } else { //rotation
+ FetchPixelFunc fetch = qFetchPixel[layout->bpp];
+ uint sbuf1[buffer_size];
+ uint sbuf2[buffer_size];
+ QRgba64 buf1[buffer_size];
+ QRgba64 buf2[buffer_size];
+ QRgba64 *end = buffer + length;
+ QRgba64 *b = buffer;
+
+ while (b < end) {
+ int len = qMin(length, buffer_size / 2);
+ int fracX = fx;
+ int fracY = fy;
+ int i = 0;
+#if defined(__SSE2__)
+ if (blendType != BlendTransformedBilinearTiled && layout->bpp == QPixelLayout::BPP32) {
+ for (; i < len; ++i) {
+ int x1 = (fx >> 16);
+ int x2;
+ int y1 = (fy >> 16);
+ int y2;
+ fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2);
+ fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2);
+ if (x1 != x2 && y1 != y2)
+ break;
+ const uchar *s1 = data->texture.scanLine(y1);
+ const uchar *s2 = data->texture.scanLine(y2);
+ sbuf1[i * 2 + 0] = ((const uint*)s1)[x1];
+ sbuf1[i * 2 + 1] = ((const uint*)s1)[x2];
+ sbuf2[i * 2 + 0] = ((const uint*)s2)[x1];
+ sbuf2[i * 2 + 1] = ((const uint*)s2)[x2];
+ fx += fdx;
+ fy += fdy;
+ }
+
+ const __m128i v_fdx = _mm_set1_epi32(fdx*4);
+ const __m128i v_fdy = _mm_set1_epi32(fdy*4);
+ __m128i v_fx = _mm_setr_epi32(fx, fx + fdx, fx + fdx + fdx, fx + fdx + fdx + fdx);
+ __m128i v_fy = _mm_setr_epi32(fy, fy + fdy, fy + fdy + fdy, fy + fdy + fdy + fdy);
+ const int bytesPerLine = data->texture.bytesPerLine;
+ const uchar *s1 = data->texture.imageData;
+ const uchar *s2 = s1 + bytesPerLine;
+ const __m128i vbpl = _mm_shufflelo_epi16(_mm_cvtsi32_si128(bytesPerLine/4), _MM_SHUFFLE(0, 0, 0, 0));
+ for (; i < len-3; i+=4) {
+ if (fdx > 0 && (short)_mm_extract_epi16(v_fx, 7) >= image_x2)
+ break;
+ if (fdx < 0 && (short)_mm_extract_epi16(v_fx, 7) < image_x1)
+ break;
+ if (fdy > 0 && (short)_mm_extract_epi16(v_fy, 7) >= image_y2)
+ break;
+ if (fdy < 0 && (short)_mm_extract_epi16(v_fy, 7) < image_y1)
+ break;
+ const __m128i vy = _mm_packs_epi32(_mm_srai_epi32(v_fy, 16), _mm_setzero_si128());
+ __m128i voffset = _mm_unpacklo_epi16(_mm_mullo_epi16(vy, vbpl), _mm_mulhi_epu16(vy, vbpl));
+ voffset = _mm_add_epi32(voffset, _mm_srli_epi32(v_fx, 16));
+
+ int offset = _mm_cvtsi128_si32(voffset); voffset = _mm_srli_si128(voffset, 4);
+ sbuf1[i * 2 + 0] = ((const uint*)s1)[offset];
+ sbuf1[i * 2 + 1] = ((const uint*)s1)[offset + 1];
+ sbuf2[i * 2 + 0] = ((const uint*)s2)[offset];
+ sbuf2[i * 2 + 1] = ((const uint*)s2)[offset + 1];
+ offset = _mm_cvtsi128_si32(voffset); voffset = _mm_srli_si128(voffset, 4);
+ sbuf1[i * 2 + 2] = ((const uint*)s1)[offset];
+ sbuf1[i * 2 + 3] = ((const uint*)s1)[offset + 1];
+ sbuf2[i * 2 + 2] = ((const uint*)s2)[offset];
+ sbuf2[i * 2 + 3] = ((const uint*)s2)[offset + 1];
+ offset = _mm_cvtsi128_si32(voffset); voffset = _mm_srli_si128(voffset, 4);
+ sbuf1[i * 2 + 4] = ((const uint*)s1)[offset];
+ sbuf1[i * 2 + 5] = ((const uint*)s1)[offset + 1];
+ sbuf2[i * 2 + 4] = ((const uint*)s2)[offset];
+ sbuf2[i * 2 + 5] = ((const uint*)s2)[offset + 1];
+ offset = _mm_cvtsi128_si32(voffset);
+ sbuf1[i * 2 + 6] = ((const uint*)s1)[offset];
+ sbuf1[i * 2 + 7] = ((const uint*)s1)[offset + 1];
+ sbuf2[i * 2 + 6] = ((const uint*)s2)[offset];
+ sbuf2[i * 2 + 7] = ((const uint*)s2)[offset + 1];
+
+ v_fx = _mm_add_epi32(v_fx, v_fdx);
+ v_fy = _mm_add_epi32(v_fy, v_fdy);
+ }
+ fx = _mm_cvtsi128_si32(v_fx);
+ fy = _mm_cvtsi128_si32(v_fy);
+ }
+#endif
+ for (; i < len; ++i) {
+ int x1 = (fx >> 16);
+ int x2;
+ int y1 = (fy >> 16);
+ int y2;
+ fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2);
+ fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2);
+
+ const uchar *s1 = data->texture.scanLine(y1);
+ const uchar *s2 = data->texture.scanLine(y2);
+
+ if (layout->bpp == QPixelLayout::BPP32) {
+ sbuf1[i * 2 + 0] = ((const uint*)s1)[x1];
+ sbuf1[i * 2 + 1] = ((const uint*)s1)[x2];
+ sbuf2[i * 2 + 0] = ((const uint*)s2)[x1];
+ sbuf2[i * 2 + 1] = ((const uint*)s2)[x2];
+
+ } else {
+ sbuf1[i * 2 + 0] = fetch(s1, x1);
+ sbuf1[i * 2 + 1] = fetch(s1, x2);
+ sbuf2[i * 2 + 0] = fetch(s2, x1);
+ sbuf2[i * 2 + 1] = fetch(s2, x2);
+ }
+
+ fx += fdx;
+ fy += fdy;
+ }
+ layout->convertToARGB64PM(buf1, sbuf1, len * 2, layout, clut);
+ layout->convertToARGB64PM(buf2, sbuf2, len * 2, layout, clut);
+
+ for (int i = 0; i < len; ++i) {
+ int distx = (fracX & 0x0000ffff);
+ int disty = (fracY & 0x0000ffff);
+ b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty);
+ fracX += fdx;
+ fracY += fdy;
+ }
+
+ length -= len;
+ b += len;
+ }
+ }
+ } else {
+ qreal fx = data->m21 * cy + data->m11 * cx + data->dx;
+ qreal fy = data->m22 * cy + data->m12 * cx + data->dy;
+ qreal fw = data->m23 * cy + data->m13 * cx + data->m33;
+
+ FetchPixelFunc fetch = qFetchPixel[layout->bpp];
+ uint sbuf1[buffer_size];
+ uint sbuf2[buffer_size];
+ QRgba64 buf1[buffer_size];
+ QRgba64 buf2[buffer_size];
+ QRgba64 *b = buffer;
+
+ int distxs[buffer_size / 2];
+ int distys[buffer_size / 2];
+
+ while (length) {
+ int len = qMin(length, buffer_size / 2);
+ for (int i = 0; i < len; ++i) {
+ const qreal iw = fw == 0 ? 1 : 1 / fw;
+ const qreal px = fx * iw - qreal(0.5);
+ const qreal py = fy * iw - qreal(0.5);
+
+ int x1 = int(px) - (px < 0);
+ int x2;
+ int y1 = int(py) - (py < 0);
+ int y2;
+
+ distxs[i] = int((px - x1) * (1<<16));
+ distys[i] = int((py - y1) * (1<<16));
+
+ fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2);
+ fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2);
+
+ const uchar *s1 = data->texture.scanLine(y1);
+ const uchar *s2 = data->texture.scanLine(y2);
+
+ if (layout->bpp == QPixelLayout::BPP32) {
+ sbuf1[i * 2 + 0] = ((const uint*)s1)[x1];
+ sbuf1[i * 2 + 1] = ((const uint*)s1)[x2];
+ sbuf2[i * 2 + 0] = ((const uint*)s2)[x1];
+ sbuf2[i * 2 + 1] = ((const uint*)s2)[x2];
+
+ } else {
+ sbuf1[i * 2 + 0] = fetch(s1, x1);
+ sbuf1[i * 2 + 1] = fetch(s1, x2);
+ sbuf2[i * 2 + 0] = fetch(s2, x1);
+ sbuf2[i * 2 + 1] = fetch(s2, x2);
+ }
+
+ fx += fdx;
+ fy += fdy;
+ fw += fdw;
+ //force increment to avoid /0
+ if (!fw)
+ fw += fdw;
+ }
+
+ layout->convertToARGB64PM(buf1, sbuf1, len * 2, layout, clut);
+ layout->convertToARGB64PM(buf2, sbuf2, len * 2, layout, clut);
+
+ for (int i = 0; i < len; ++i) {
+ int distx = distxs[i];
+ int disty = distys[i];
+ b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty);
+ }
+
+ length -= len;
+ b += len;
+ }
+ }
+
+ return buffer;
+}
+
static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
// Untransformed
{
@@ -2298,12 +3229,186 @@ static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
},
};
+static SourceFetchProc64 sourceFetch64[NBlendTypes][QImage::NImageFormats] = {
+ // Untransformed
+ {
+ 0, // Invalid
+ fetchUntransformed64, // Mono
+ fetchUntransformed64, // MonoLsb
+ fetchUntransformed64, // Indexed8
+ fetchUntransformed64, // RGB32
+ fetchUntransformed64, // ARGB32
+ fetchUntransformed64, // ARGB32_Premultiplied
+ fetchUntransformed64, // RGB16
+ fetchUntransformed64, // ARGB8565_Premultiplied
+ fetchUntransformed64, // RGB666
+ fetchUntransformed64, // ARGB6666_Premultiplied
+ fetchUntransformed64, // RGB555
+ fetchUntransformed64, // ARGB8555_Premultiplied
+ fetchUntransformed64, // RGB888
+ fetchUntransformed64, // RGB444
+ fetchUntransformed64, // ARGB4444_Premultiplied
+ fetchUntransformed64, // RGBX8888
+ fetchUntransformed64, // RGBA8888
+ fetchUntransformed64, // RGBA8888_Premultiplied
+ fetchUntransformed64, // Format_BGR30
+ fetchUntransformed64, // Format_A2BGR30_Premultiplied
+ fetchUntransformed64, // Format_RGB30
+ fetchUntransformed64, // Format_A2RGB30_Premultiplied
+ fetchUntransformed64, // Alpha8
+ fetchUntransformed64, // Grayscale8
+ },
+ // Tiled
+ {
+ 0, // Invalid
+ fetchUntransformed64, // Mono
+ fetchUntransformed64, // MonoLsb
+ fetchUntransformed64, // Indexed8
+ fetchUntransformed64, // RGB32
+ fetchUntransformed64, // ARGB32
+ fetchUntransformed64, // ARGB32_Premultiplied
+ fetchUntransformed64, // RGB16
+ fetchUntransformed64, // ARGB8565_Premultiplied
+ fetchUntransformed64, // RGB666
+ fetchUntransformed64, // ARGB6666_Premultiplied
+ fetchUntransformed64, // RGB555
+ fetchUntransformed64, // ARGB8555_Premultiplied
+ fetchUntransformed64, // RGB888
+ fetchUntransformed64, // RGB444
+ fetchUntransformed64, // ARGB4444_Premultiplied
+ fetchUntransformed64, // RGBX8888
+ fetchUntransformed64, // RGBA8888
+ fetchUntransformed64, // RGBA8888_Premultiplied
+ fetchUntransformed64, // BGR30
+ fetchUntransformed64, // A2BGR30_Premultiplied
+ fetchUntransformed64, // RGB30
+ fetchUntransformed64, // A2RGB30_Premultiplied
+ fetchUntransformed64, // Alpha8
+ fetchUntransformed64, // Grayscale8
+ },
+ // Transformed
+ {
+ 0, // Invalid
+ fetchTransformed64<BlendTransformed>, // Mono
+ fetchTransformed64<BlendTransformed>, // MonoLsb
+ fetchTransformed64<BlendTransformed>, // Indexed8
+ fetchTransformed64<BlendTransformed>, // RGB32
+ fetchTransformed64<BlendTransformed>, // ARGB32
+ fetchTransformed64<BlendTransformed>, // ARGB32_Premultiplied
+ fetchTransformed64<BlendTransformed>, // RGB16
+ fetchTransformed64<BlendTransformed>, // ARGB8565_Premultiplied
+ fetchTransformed64<BlendTransformed>, // RGB666
+ fetchTransformed64<BlendTransformed>, // ARGB6666_Premultiplied
+ fetchTransformed64<BlendTransformed>, // RGB555
+ fetchTransformed64<BlendTransformed>, // ARGB8555_Premultiplied
+ fetchTransformed64<BlendTransformed>, // RGB888
+ fetchTransformed64<BlendTransformed>, // RGB444
+ fetchTransformed64<BlendTransformed>, // ARGB4444_Premultiplied
+ fetchTransformed64<BlendTransformed>, // RGBX8888
+ fetchTransformed64<BlendTransformed>, // RGBA8888
+ fetchTransformed64<BlendTransformed>, // RGBA8888_Premultiplied
+ fetchTransformed64<BlendTransformed>, // BGR30
+ fetchTransformed64<BlendTransformed>, // A2BGR30_Premultiplied
+ fetchTransformed64<BlendTransformed>, // RGB30
+ fetchTransformed64<BlendTransformed>, // A2RGB30_Premultiplied
+ fetchTransformed64<BlendTransformed>, // Alpah8
+ fetchTransformed64<BlendTransformed>, // Grayscale8
+ },
+ {
+ 0, // TransformedTiled
+ fetchTransformed64<BlendTransformedTiled>, // Mono
+ fetchTransformed64<BlendTransformedTiled>, // MonoLsb
+ fetchTransformed64<BlendTransformedTiled>, // Indexed8
+ fetchTransformed64<BlendTransformedTiled>, // RGB32
+ fetchTransformed64<BlendTransformedTiled>, // ARGB32
+ fetchTransformed64<BlendTransformedTiled>, // ARGB32_Premultiplied
+ fetchTransformed64<BlendTransformedTiled>, // RGB16
+ fetchTransformed64<BlendTransformedTiled>, // ARGB8565_Premultiplied
+ fetchTransformed64<BlendTransformedTiled>, // RGB666
+ fetchTransformed64<BlendTransformedTiled>, // ARGB6666_Premultiplied
+ fetchTransformed64<BlendTransformedTiled>, // RGB555
+ fetchTransformed64<BlendTransformedTiled>, // ARGB8555_Premultiplied
+ fetchTransformed64<BlendTransformedTiled>, // RGB888
+ fetchTransformed64<BlendTransformedTiled>, // RGB444
+ fetchTransformed64<BlendTransformedTiled>, // ARGB4444_Premultiplied
+ fetchTransformed64<BlendTransformedTiled>, // RGBX8888
+ fetchTransformed64<BlendTransformedTiled>, // RGBA8888
+ fetchTransformed64<BlendTransformedTiled>, // RGBA8888_Premultiplied
+ fetchTransformed64<BlendTransformedTiled>, // BGR30
+ fetchTransformed64<BlendTransformedTiled>, // A2BGR30_Premultiplied
+ fetchTransformed64<BlendTransformedTiled>, // RGB30
+ fetchTransformed64<BlendTransformedTiled>, // A2RGB30_Premultiplied
+ fetchTransformed64<BlendTransformedTiled>, // Alpha8
+ fetchTransformed64<BlendTransformedTiled>, // Grayscale8
+ },
+ {
+ 0, // Bilinear
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // Mono
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // MonoLsb
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // Indexed8
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // RGB32
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // ARGB32
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // ARGB32_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // RGB16
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // ARGB8565_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // RGB666
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // ARGB6666_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // RGB555
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // ARGB8555_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // RGB888
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // RGB444
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // ARGB4444_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // RGBX8888
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // RGBA8888
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // RGBA8888_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // BGR30
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // A2BGR30_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // RGB30
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // A2RGB30_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // Alpha8
+ fetchTransformedBilinear64<BlendTransformedBilinear>, // Grayscale8
+ },
+ {
+ 0, // BilinearTiled
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // Mono
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // MonoLsb
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // Indexed8
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // RGB32
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // ARGB32
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // ARGB32_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // RGB16
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // ARGB8565_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // RGB666
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // ARGB6666_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // RGB555
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // ARGB8555_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // RGB888
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // RGB444
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // ARGB4444_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // RGBX8888
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // RGBA8888
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // RGBA8888_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // BGR30
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // A2BGR30_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // RGB30
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // A2RGB30_Premultiplied
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // Alpha8
+ fetchTransformedBilinear64<BlendTransformedBilinearTiled>, // Grayscale8
+ },
+};
+
#define FIXPT_BITS 8
#define FIXPT_SIZE (1<<FIXPT_BITS)
static uint qt_gradient_pixel_fixed(const QGradientData *data, int fixed_pos)
{
int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS;
+ return data->colorTable[qt_gradient_clamp(data, ipos)].toArgb32();
+}
+
+static const QRgba64& qt_gradient_pixel64_fixed(const QGradientData *data, int fixed_pos)
+{
+ int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS;
return data->colorTable[qt_gradient_clamp(data, ipos)];
}
@@ -2320,10 +3425,50 @@ static void QT_FASTCALL getLinearGradientValues(LinearGradientValues *v, const Q
}
}
-static const uint * QT_FASTCALL qt_fetch_linear_gradient(uint *buffer, const Operator *op, const QSpanData *data,
- int y, int x, int length)
+class GradientBase32
{
- const uint *b = buffer;
+public:
+ typedef uint Type;
+ static Type null() { return 0; }
+ static Type fetchSingle(const QGradientData& gradient, qreal v)
+ {
+ return qt_gradient_pixel(&gradient, v);
+ }
+ static Type fetchSingle(const QGradientData& gradient, int v)
+ {
+ return qt_gradient_pixel_fixed(&gradient, v);
+ }
+ static void memfill(Type *buffer, Type fill, int length)
+ {
+ qt_memfill32(buffer, fill, length);
+ }
+};
+
+class GradientBase64
+{
+public:
+ typedef QRgba64 Type;
+ static Type null() { return QRgba64::fromRgba64(0); }
+ static Type fetchSingle(const QGradientData& gradient, qreal v)
+ {
+ return qt_gradient_pixel64(&gradient, v);
+ }
+ static Type fetchSingle(const QGradientData& gradient, int v)
+ {
+ return qt_gradient_pixel64_fixed(&gradient, v);
+ }
+ static void memfill(Type *buffer, Type fill, int length)
+ {
+ qt_memfill64((quint64*)buffer, fill, length);
+ }
+};
+
+template<class GradientBase, typename BlendType>
+static inline const BlendType * QT_FASTCALL qt_fetch_linear_gradient_template(
+ BlendType *buffer, const Operator *op, const QSpanData *data,
+ int y, int x, int length)
+{
+ const BlendType *b = buffer;
qreal t, inc;
bool affine = true;
@@ -2343,10 +3488,10 @@ static const uint * QT_FASTCALL qt_fetch_linear_gradient(uint *buffer, const Ope
}
}
- const uint *end = buffer + length;
+ const BlendType *end = buffer + length;
if (affine) {
if (inc > qreal(-1e-5) && inc < qreal(1e-5)) {
- QT_MEMFILL_UINT(buffer, length, qt_gradient_pixel_fixed(&data->gradient, int(t * FIXPT_SIZE)));
+ GradientBase::memfill(buffer, GradientBase::fetchSingle(data->gradient, int(t * FIXPT_SIZE)), length);
} else {
if (t+inc*length < qreal(INT_MAX >> (FIXPT_BITS + 1)) &&
t+inc*length > qreal(INT_MIN >> (FIXPT_BITS + 1))) {
@@ -2354,14 +3499,14 @@ static const uint * QT_FASTCALL qt_fetch_linear_gradient(uint *buffer, const Ope
int t_fixed = int(t * FIXPT_SIZE);
int inc_fixed = int(inc * FIXPT_SIZE);
while (buffer < end) {
- *buffer = qt_gradient_pixel_fixed(&data->gradient, t_fixed);
+ *buffer = GradientBase::fetchSingle(data->gradient, t_fixed);
t_fixed += inc_fixed;
++buffer;
}
} else {
// we have to fall back to float math
while (buffer < end) {
- *buffer = qt_gradient_pixel(&data->gradient, t/GRADIENT_STOPTABLE_SIZE);
+ *buffer = GradientBase::fetchSingle(data->gradient, t/GRADIENT_STOPTABLE_SIZE);
t += inc;
++buffer;
}
@@ -2374,7 +3519,7 @@ static const uint * QT_FASTCALL qt_fetch_linear_gradient(uint *buffer, const Ope
qreal y = ry/rw;
t = (op->linear.dx*x + op->linear.dy *y) + op->linear.off;
- *buffer = qt_gradient_pixel(&data->gradient, t);
+ *buffer = GradientBase::fetchSingle(data->gradient, t);
rx += data->m11;
ry += data->m12;
rw += data->m13;
@@ -2388,6 +3533,18 @@ static const uint * QT_FASTCALL qt_fetch_linear_gradient(uint *buffer, const Ope
return b;
}
+static const uint * QT_FASTCALL qt_fetch_linear_gradient(uint *buffer, const Operator *op, const QSpanData *data,
+ int y, int x, int length)
+{
+ return qt_fetch_linear_gradient_template<GradientBase32, uint>(buffer, op, data, y, x, length);
+}
+
+static const QRgba64 * QT_FASTCALL qt_fetch_linear_gradient_rgb64(QRgba64 *buffer, const Operator *op, const QSpanData *data,
+ int y, int x, int length)
+{
+ return qt_fetch_linear_gradient_template<GradientBase64, QRgba64>(buffer, op, data, y, x, length);
+}
+
static void QT_FASTCALL getRadialGradientValues(RadialGradientValues *v, const QSpanData *data)
{
v->dx = data->gradient.radial.center.x - data->gradient.radial.focal.x;
@@ -2402,19 +3559,22 @@ static void QT_FASTCALL getRadialGradientValues(RadialGradientValues *v, const Q
v->extended = !qFuzzyIsNull(data->gradient.radial.focal.radius) || v->a <= 0;
}
-class RadialFetchPlain
+template <class GradientBase>
+class RadialFetchPlain : public GradientBase
{
public:
- static inline void fetch(uint *buffer, uint *end, const Operator *op, const QSpanData *data, qreal det,
- qreal delta_det, qreal delta_delta_det, qreal b, qreal delta_b)
+ typedef typename GradientBase::Type BlendType;
+ static void fetch(BlendType *buffer, BlendType *end,
+ const Operator *op, const QSpanData *data, qreal det,
+ qreal delta_det, qreal delta_delta_det, qreal b, qreal delta_b)
{
if (op->radial.extended) {
while (buffer < end) {
- quint32 result = 0;
+ BlendType result = GradientBase::null();
if (det >= 0) {
qreal w = qSqrt(det) - b;
if (data->gradient.radial.focal.radius + op->radial.dr * w >= 0)
- result = qt_gradient_pixel(&data->gradient, w);
+ result = GradientBase::fetchSingle(data->gradient, w);
}
*buffer = result;
@@ -2427,7 +3587,7 @@ public:
}
} else {
while (buffer < end) {
- *buffer++ = qt_gradient_pixel(&data->gradient, qSqrt(det) - b);
+ *buffer++ = GradientBase::fetchSingle(data->gradient, qSqrt(det) - b);
det += delta_det;
delta_det += delta_delta_det;
@@ -2440,15 +3600,23 @@ public:
const uint * QT_FASTCALL qt_fetch_radial_gradient_plain(uint *buffer, const Operator *op, const QSpanData *data,
int y, int x, int length)
{
- return qt_fetch_radial_gradient_template<RadialFetchPlain>(buffer, op, data, y, x, length);
+ return qt_fetch_radial_gradient_template<RadialFetchPlain<GradientBase32>, uint>(buffer, op, data, y, x, length);
}
static SourceFetchProc qt_fetch_radial_gradient = qt_fetch_radial_gradient_plain;
-static const uint * QT_FASTCALL qt_fetch_conical_gradient(uint *buffer, const Operator *, const QSpanData *data,
- int y, int x, int length)
+const QRgba64 * QT_FASTCALL qt_fetch_radial_gradient_rgb64(QRgba64 *buffer, const Operator *op, const QSpanData *data,
+ int y, int x, int length)
+{
+ return qt_fetch_radial_gradient_template<RadialFetchPlain<GradientBase64>, QRgba64>(buffer, op, data, y, x, length);
+}
+
+template <class GradientBase, typename BlendType>
+static inline const BlendType * QT_FASTCALL qt_fetch_conical_gradient_template(
+ BlendType *buffer, const QSpanData *data,
+ int y, int x, int length)
{
- const uint *b = buffer;
+ const BlendType *b = buffer;
qreal rx = data->m21 * (y + qreal(0.5))
+ data->dx + data->m11 * (x + qreal(0.5));
qreal ry = data->m22 * (y + qreal(0.5))
@@ -2457,14 +3625,14 @@ static const uint * QT_FASTCALL qt_fetch_conical_gradient(uint *buffer, const Op
const qreal inv2pi = M_1_PI / 2.0;
- const uint *end = buffer + length;
+ const BlendType *end = buffer + length;
if (affine) {
rx -= data->gradient.conical.center.x;
ry -= data->gradient.conical.center.y;
while (buffer < end) {
qreal angle = qAtan2(ry, rx) + data->gradient.conical.angle;
- *buffer = qt_gradient_pixel(&data->gradient, 1 - angle * inv2pi);
+ *buffer = GradientBase::fetchSingle(data->gradient, 1 - angle * inv2pi);
rx += data->m11;
ry += data->m12;
@@ -2480,7 +3648,7 @@ static const uint * QT_FASTCALL qt_fetch_conical_gradient(uint *buffer, const Op
rx/rw - data->gradient.conical.center.y)
+ data->gradient.conical.angle;
- *buffer = qt_gradient_pixel(&data->gradient, 1 - angle * inv2pi);
+ *buffer = GradientBase::fetchSingle(data->gradient, 1 - angle * inv2pi);
rx += data->m11;
ry += data->m12;
@@ -2494,1763 +3662,29 @@ static const uint * QT_FASTCALL qt_fetch_conical_gradient(uint *buffer, const Op
return b;
}
-# define PRELOAD_INIT(x)
-# define PRELOAD_INIT2(x,y)
-# define PRELOAD_COND(x)
-# define PRELOAD_COND2(x,y)
-
-/* The constant alpha factor describes an alpha factor that gets applied
- to the result of the composition operation combining it with the destination.
-
- The intent is that if const_alpha == 0. we get back dest, and if const_alpha == 1.
- we get the unmodified operation
-
- result = src op dest
- dest = result * const_alpha + dest * (1. - const_alpha)
-
- This means that in the comments below, the first line is the const_alpha==255 case, the
- second line the general one.
-
- In the lines below:
- s == src, sa == alpha(src), sia = 1 - alpha(src)
- d == dest, da == alpha(dest), dia = 1 - alpha(dest)
- ca = const_alpha, cia = 1 - const_alpha
-
- The methods exist in two variants. One where we have a constant source, the other
- where the source is an array of pixels.
-*/
-
-/*
- result = 0
- d = d * cia
-*/
-#define comp_func_Clear_impl(dest, length, const_alpha)\
-{\
- if (const_alpha == 255) {\
- QT_MEMFILL_UINT(dest, length, 0);\
- } else {\
- int ialpha = 255 - const_alpha;\
- PRELOAD_INIT(dest)\
- for (int i = 0; i < length; ++i) {\
- PRELOAD_COND(dest)\
- dest[i] = BYTE_MUL(dest[i], ialpha);\
- }\
- }\
-}
-
-void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha)
-{
- comp_func_Clear_impl(dest, length, const_alpha);
-}
-
-void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha)
-{
- comp_func_Clear_impl(dest, length, const_alpha);
-}
-
-/*
- result = s
- dest = s * ca + d * cia
-*/
-void QT_FASTCALL comp_func_solid_Source(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha == 255) {
- QT_MEMFILL_UINT(dest, length, color);
- } else {
- int ialpha = 255 - const_alpha;
- color = BYTE_MUL(color, const_alpha);
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- dest[i] = color + BYTE_MUL(dest[i], ialpha);
- }
- }
-}
-
-void QT_FASTCALL comp_func_Source(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- if (const_alpha == 255) {
- ::memcpy(dest, src, length * sizeof(uint));
- } else {
- int ialpha = 255 - const_alpha;
- PRELOAD_INIT2(dest, src)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- dest[i] = INTERPOLATE_PIXEL_255(src[i], const_alpha, dest[i], ialpha);
- }
- }
-}
-
-void QT_FASTCALL comp_func_solid_Destination(uint *, int, uint, uint)
-{
-}
-
-void QT_FASTCALL comp_func_Destination(uint *, const uint *, int, uint)
-{
-}
-
-/*
- result = s + d * sia
- dest = (s + d * sia) * ca + d * cia
- = s * ca + d * (sia * ca + cia)
- = s * ca + d * (1 - sa*ca)
-*/
-void QT_FASTCALL comp_func_solid_SourceOver(uint *dest, int length, uint color, uint const_alpha)
-{
- if ((const_alpha & qAlpha(color)) == 255) {
- QT_MEMFILL_UINT(dest, length, color);
- } else {
- if (const_alpha != 255)
- color = BYTE_MUL(color, const_alpha);
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- dest[i] = color + BYTE_MUL(dest[i], qAlpha(~color));
- }
- }
-}
-
-void QT_FASTCALL comp_func_SourceOver(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- PRELOAD_INIT2(dest, src)
- if (const_alpha == 255) {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint s = src[i];
- if (s >= 0xff000000)
- dest[i] = s;
- else if (s != 0)
- dest[i] = s + BYTE_MUL(dest[i], qAlpha(~s));
- }
- } else {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint s = BYTE_MUL(src[i], const_alpha);
- dest[i] = s + BYTE_MUL(dest[i], qAlpha(~s));
- }
- }
-}
-
-/*
- result = d + s * dia
- dest = (d + s * dia) * ca + d * cia
- = d + s * dia * ca
-*/
-void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha != 255)
- color = BYTE_MUL(color, const_alpha);
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- dest[i] = d + BYTE_MUL(color, qAlpha(~d));
- }
-}
-
-void QT_FASTCALL comp_func_DestinationOver(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- PRELOAD_INIT2(dest, src)
- if (const_alpha == 255) {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- dest[i] = d + BYTE_MUL(src[i], qAlpha(~d));
- }
- } else {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = BYTE_MUL(src[i], const_alpha);
- dest[i] = d + BYTE_MUL(s, qAlpha(~d));
- }
- }
-}
-
-/*
- result = s * da
- dest = s * da * ca + d * cia
-*/
-void QT_FASTCALL comp_func_solid_SourceIn(uint *dest, int length, uint color, uint const_alpha)
-{
- PRELOAD_INIT(dest)
- if (const_alpha == 255) {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- dest[i] = BYTE_MUL(color, qAlpha(dest[i]));
- }
- } else {
- color = BYTE_MUL(color, const_alpha);
- uint cia = 255 - const_alpha;
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(d), d, cia);
- }
- }
-}
-
-void QT_FASTCALL comp_func_SourceIn(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- PRELOAD_INIT2(dest, src)
- if (const_alpha == 255) {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- dest[i] = BYTE_MUL(src[i], qAlpha(dest[i]));
- }
- } else {
- uint cia = 255 - const_alpha;
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = BYTE_MUL(src[i], const_alpha);
- dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, cia);
- }
- }
-}
-
-/*
- result = d * sa
- dest = d * sa * ca + d * cia
- = d * (sa * ca + cia)
-*/
-void QT_FASTCALL comp_func_solid_DestinationIn(uint *dest, int length, uint color, uint const_alpha)
-{
- uint a = qAlpha(color);
- if (const_alpha != 255) {
- a = BYTE_MUL(a, const_alpha) + 255 - const_alpha;
- }
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- dest[i] = BYTE_MUL(dest[i], a);
- }
-}
-
-void QT_FASTCALL comp_func_DestinationIn(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- PRELOAD_INIT2(dest, src)
- if (const_alpha == 255) {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- dest[i] = BYTE_MUL(dest[i], qAlpha(src[i]));
- }
- } else {
- int cia = 255 - const_alpha;
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint a = BYTE_MUL(qAlpha(src[i]), const_alpha) + cia;
- dest[i] = BYTE_MUL(dest[i], a);
- }
- }
-}
-
-/*
- result = s * dia
- dest = s * dia * ca + d * cia
-*/
-
-void QT_FASTCALL comp_func_solid_SourceOut(uint *dest, int length, uint color, uint const_alpha)
-{
- PRELOAD_INIT(dest)
- if (const_alpha == 255) {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- dest[i] = BYTE_MUL(color, qAlpha(~dest[i]));
- }
- } else {
- color = BYTE_MUL(color, const_alpha);
- int cia = 255 - const_alpha;
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(~d), d, cia);
- }
- }
-}
-
-void QT_FASTCALL comp_func_SourceOut(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- PRELOAD_INIT2(dest, src)
- if (const_alpha == 255) {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- dest[i] = BYTE_MUL(src[i], qAlpha(~dest[i]));
- }
- } else {
- int cia = 255 - const_alpha;
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint s = BYTE_MUL(src[i], const_alpha);
- uint d = dest[i];
- dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, cia);
- }
- }
-}
-
-/*
- result = d * sia
- dest = d * sia * ca + d * cia
- = d * (sia * ca + cia)
-*/
-void QT_FASTCALL comp_func_solid_DestinationOut(uint *dest, int length, uint color, uint const_alpha)
-{
- uint a = qAlpha(~color);
- if (const_alpha != 255)
- a = BYTE_MUL(a, const_alpha) + 255 - const_alpha;
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- dest[i] = BYTE_MUL(dest[i], a);
- }
-}
-
-void QT_FASTCALL comp_func_DestinationOut(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- PRELOAD_INIT2(dest, src)
- if (const_alpha == 255) {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- dest[i] = BYTE_MUL(dest[i], qAlpha(~src[i]));
- }
- } else {
- int cia = 255 - const_alpha;
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint sia = BYTE_MUL(qAlpha(~src[i]), const_alpha) + cia;
- dest[i] = BYTE_MUL(dest[i], sia);
- }
- }
-}
-
-/*
- result = s*da + d*sia
- dest = s*da*ca + d*sia*ca + d *cia
- = s*ca * da + d * (sia*ca + cia)
- = s*ca * da + d * (1 - sa*ca)
-*/
-void QT_FASTCALL comp_func_solid_SourceAtop(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha != 255) {
- color = BYTE_MUL(color, const_alpha);
- }
- uint sia = qAlpha(~color);
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(dest[i]), dest[i], sia);
- }
-}
-
-void QT_FASTCALL comp_func_SourceAtop(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- PRELOAD_INIT2(dest, src)
- if (const_alpha == 255) {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint s = src[i];
- uint d = dest[i];
- dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, qAlpha(~s));
- }
- } else {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint s = BYTE_MUL(src[i], const_alpha);
- uint d = dest[i];
- dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, qAlpha(~s));
- }
- }
-}
-
-/*
- result = d*sa + s*dia
- dest = d*sa*ca + s*dia*ca + d *cia
- = s*ca * dia + d * (sa*ca + cia)
-*/
-void QT_FASTCALL comp_func_solid_DestinationAtop(uint *dest, int length, uint color, uint const_alpha)
-{
- uint a = qAlpha(color);
- if (const_alpha != 255) {
- color = BYTE_MUL(color, const_alpha);
- a = qAlpha(color) + 255 - const_alpha;
- }
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- dest[i] = INTERPOLATE_PIXEL_255(d, a, color, qAlpha(~d));
- }
-}
-
-void QT_FASTCALL comp_func_DestinationAtop(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- PRELOAD_INIT2(dest, src)
- if (const_alpha == 255) {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint s = src[i];
- uint d = dest[i];
- dest[i] = INTERPOLATE_PIXEL_255(d, qAlpha(s), s, qAlpha(~d));
- }
- } else {
- int cia = 255 - const_alpha;
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint s = BYTE_MUL(src[i], const_alpha);
- uint d = dest[i];
- uint a = qAlpha(s) + cia;
- dest[i] = INTERPOLATE_PIXEL_255(d, a, s, qAlpha(~d));
- }
- }
-}
-
-/*
- result = d*sia + s*dia
- dest = d*sia*ca + s*dia*ca + d *cia
- = s*ca * dia + d * (sia*ca + cia)
- = s*ca * dia + d * (1 - sa*ca)
-*/
-void QT_FASTCALL comp_func_solid_XOR(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha != 255)
- color = BYTE_MUL(color, const_alpha);
- uint sia = qAlpha(~color);
-
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(~d), d, sia);
- }
-}
-
-void QT_FASTCALL comp_func_XOR(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- PRELOAD_INIT2(dest, src)
- if (const_alpha == 255) {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = src[i];
- dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, qAlpha(~s));
- }
- } else {
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = BYTE_MUL(src[i], const_alpha);
- dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, qAlpha(~s));
- }
- }
-}
-
-struct QFullCoverage {
- inline void store(uint *dest, const uint src) const
- {
- *dest = src;
- }
-};
-
-struct QPartialCoverage {
- inline QPartialCoverage(uint const_alpha)
- : ca(const_alpha)
- , ica(255 - const_alpha)
- {
- }
-
- inline void store(uint *dest, const uint src) const
- {
- *dest = INTERPOLATE_PIXEL_255(src, ca, *dest, ica);
- }
-
-private:
- const uint ca;
- const uint ica;
-};
-
-static inline int mix_alpha(int da, int sa)
-{
- return 255 - ((255 - sa) * (255 - da) >> 8);
-}
-
-/*
- Dca' = Sca.Da + Dca.Sa + Sca.(1 - Da) + Dca.(1 - Sa)
- = Sca + Dca
-*/
-template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Plus_impl(uint *dest, int length, uint color, const T &coverage)
-{
- uint s = color;
-
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- d = comp_func_Plus_one_pixel(d, s);
- coverage.store(&dest[i], d);
- }
-}
-
-void QT_FASTCALL comp_func_solid_Plus(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_solid_Plus_impl(dest, length, color, QFullCoverage());
- else
- comp_func_solid_Plus_impl(dest, length, color, QPartialCoverage(const_alpha));
-}
-
-template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Plus_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage)
-{
- PRELOAD_INIT2(dest, src)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = src[i];
-
- d = comp_func_Plus_one_pixel(d, s);
-
- coverage.store(&dest[i], d);
- }
-}
-
-void QT_FASTCALL comp_func_Plus(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_Plus_impl(dest, src, length, QFullCoverage());
- else
- comp_func_Plus_impl(dest, src, length, QPartialCoverage(const_alpha));
-}
-
-/*
- Dca' = Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa)
-*/
-static inline int multiply_op(int dst, int src, int da, int sa)
-{
- return qt_div_255(src * dst + src * (255 - da) + dst * (255 - sa));
-}
-
-template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Multiply_impl(uint *dest, int length, uint color, const T &coverage)
-{
- int sa = qAlpha(color);
- int sr = qRed(color);
- int sg = qGreen(color);
- int sb = qBlue(color);
-
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- int da = qAlpha(d);
-
-#define OP(a, b) multiply_op(a, b, da, sa)
- int r = OP( qRed(d), sr);
- int b = OP( qBlue(d), sb);
- int g = OP(qGreen(d), sg);
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_solid_Multiply(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_solid_Multiply_impl(dest, length, color, QFullCoverage());
- else
- comp_func_solid_Multiply_impl(dest, length, color, QPartialCoverage(const_alpha));
-}
-
-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)
-{
- PRELOAD_INIT2(dest, src)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = src[i];
-
- int da = qAlpha(d);
- int sa = qAlpha(s);
-
-#define OP(a, b) multiply_op(a, b, da, sa)
- int r = OP( qRed(d), qRed(s));
- int b = OP( qBlue(d), qBlue(s));
- int g = OP(qGreen(d), qGreen(s));
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_Multiply(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_Multiply_impl(dest, src, length, QFullCoverage());
- else
- comp_func_Multiply_impl(dest, src, length, QPartialCoverage(const_alpha));
-}
-
-/*
- Dca' = (Sca.Da + Dca.Sa - Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa)
- = 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)
-{
- int sa = qAlpha(color);
- int sr = qRed(color);
- int sg = qGreen(color);
- int sb = qBlue(color);
-
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- int da = qAlpha(d);
-
-#define OP(a, b) 255 - qt_div_255((255-a) * (255-b))
- int r = OP( qRed(d), sr);
- int b = OP( qBlue(d), sb);
- int g = OP(qGreen(d), sg);
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_solid_Screen(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_solid_Screen_impl(dest, length, color, QFullCoverage());
- else
- comp_func_solid_Screen_impl(dest, length, color, QPartialCoverage(const_alpha));
-}
-
-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)
-{
- PRELOAD_INIT2(dest, src)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = src[i];
-
- int da = qAlpha(d);
- int sa = qAlpha(s);
-
-#define OP(a, b) 255 - (((255-a) * (255-b)) >> 8)
- int r = OP( qRed(d), qRed(s));
- int b = OP( qBlue(d), qBlue(s));
- int g = OP(qGreen(d), qGreen(s));
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_Screen(uint *dest, const uint *src, int length, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_Screen_impl(dest, src, length, QFullCoverage());
- else
- comp_func_Screen_impl(dest, src, length, QPartialCoverage(const_alpha));
-}
-
-/*
- if 2.Dca < Da
- Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa)
- otherwise
- Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa)
-*/
-static inline int overlay_op(int dst, int src, int da, int sa)
-{
- const int temp = src * (255 - da) + dst * (255 - sa);
- if (2 * dst < da)
- return qt_div_255(2 * src * dst + temp);
- else
- return qt_div_255(sa * da - 2 * (da - dst) * (sa - src) + temp);
-}
-
-template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Overlay_impl(uint *dest, int length, uint color, const T &coverage)
-{
- int sa = qAlpha(color);
- int sr = qRed(color);
- int sg = qGreen(color);
- int sb = qBlue(color);
-
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- int da = qAlpha(d);
-
-#define OP(a, b) overlay_op(a, b, da, sa)
- int r = OP( qRed(d), sr);
- int b = OP( qBlue(d), sb);
- int g = OP(qGreen(d), sg);
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_solid_Overlay(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_solid_Overlay_impl(dest, length, color, QFullCoverage());
- else
- comp_func_solid_Overlay_impl(dest, length, color, QPartialCoverage(const_alpha));
-}
-
-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)
-{
- PRELOAD_INIT2(dest, src)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = src[i];
-
- int da = qAlpha(d);
- int sa = qAlpha(s);
-
-#define OP(a, b) overlay_op(a, b, da, sa)
- int r = OP( qRed(d), qRed(s));
- int b = OP( qBlue(d), qBlue(s));
- int g = OP(qGreen(d), qGreen(s));
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_Overlay(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_Overlay_impl(dest, src, length, QFullCoverage());
- else
- comp_func_Overlay_impl(dest, src, length, QPartialCoverage(const_alpha));
-}
-
-/*
- Dca' = min(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa)
- Da' = Sa + Da - Sa.Da
-*/
-static inline int darken_op(int dst, int src, int da, int sa)
-{
- return qt_div_255(qMin(src * da, dst * sa) + src * (255 - da) + dst * (255 - sa));
-}
-
-template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Darken_impl(uint *dest, int length, uint color, const T &coverage)
-{
- int sa = qAlpha(color);
- int sr = qRed(color);
- int sg = qGreen(color);
- int sb = qBlue(color);
-
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- int da = qAlpha(d);
-
-#define OP(a, b) darken_op(a, b, da, sa)
- int r = OP( qRed(d), sr);
- int b = OP( qBlue(d), sb);
- int g = OP(qGreen(d), sg);
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_solid_Darken(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_solid_Darken_impl(dest, length, color, QFullCoverage());
- else
- comp_func_solid_Darken_impl(dest, length, color, QPartialCoverage(const_alpha));
-}
-
-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)
-{
- PRELOAD_INIT2(dest, src)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = src[i];
-
- int da = qAlpha(d);
- int sa = qAlpha(s);
-
-#define OP(a, b) darken_op(a, b, da, sa)
- int r = OP( qRed(d), qRed(s));
- int b = OP( qBlue(d), qBlue(s));
- int g = OP(qGreen(d), qGreen(s));
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_Darken(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_Darken_impl(dest, src, length, QFullCoverage());
- else
- comp_func_Darken_impl(dest, src, length, QPartialCoverage(const_alpha));
-}
-
-/*
- Dca' = max(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa)
- Da' = Sa + Da - Sa.Da
-*/
-static inline int lighten_op(int dst, int src, int da, int sa)
-{
- return qt_div_255(qMax(src * da, dst * sa) + src * (255 - da) + dst * (255 - sa));
-}
-
-template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Lighten_impl(uint *dest, int length, uint color, const T &coverage)
-{
- int sa = qAlpha(color);
- int sr = qRed(color);
- int sg = qGreen(color);
- int sb = qBlue(color);
-
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- int da = qAlpha(d);
-
-#define OP(a, b) lighten_op(a, b, da, sa)
- int r = OP( qRed(d), sr);
- int b = OP( qBlue(d), sb);
- int g = OP(qGreen(d), sg);
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_solid_Lighten(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_solid_Lighten_impl(dest, length, color, QFullCoverage());
- else
- comp_func_solid_Lighten_impl(dest, length, color, QPartialCoverage(const_alpha));
-}
-
-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)
-{
- PRELOAD_INIT2(dest, src)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = src[i];
-
- int da = qAlpha(d);
- int sa = qAlpha(s);
-
-#define OP(a, b) lighten_op(a, b, da, sa)
- int r = OP( qRed(d), qRed(s));
- int b = OP( qBlue(d), qBlue(s));
- int g = OP(qGreen(d), qGreen(s));
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_Lighten(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_Lighten_impl(dest, src, length, QFullCoverage());
- else
- comp_func_Lighten_impl(dest, src, length, QPartialCoverage(const_alpha));
-}
-
-/*
- if Sca.Da + Dca.Sa >= Sa.Da
- Dca' = Sa.Da + Sca.(1 - Da) + Dca.(1 - Sa)
- otherwise
- Dca' = Dca.Sa/(1-Sca/Sa) + Sca.(1 - Da) + Dca.(1 - Sa)
-*/
-static inline int color_dodge_op(int dst, int src, int da, int sa)
-{
- const int sa_da = sa * da;
- const int dst_sa = dst * sa;
- const int src_da = src * da;
-
- const int temp = src * (255 - da) + dst * (255 - sa);
- if (src_da + dst_sa >= sa_da)
- return qt_div_255(sa_da + temp);
- else
- return qt_div_255(255 * dst_sa / (255 - 255 * src / sa) + temp);
-}
-
-template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorDodge_impl(uint *dest, int length, uint color, const T &coverage)
-{
- int sa = qAlpha(color);
- int sr = qRed(color);
- int sg = qGreen(color);
- int sb = qBlue(color);
-
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- int da = qAlpha(d);
-
-#define OP(a,b) color_dodge_op(a, b, da, sa)
- int r = OP( qRed(d), sr);
- int b = OP( qBlue(d), sb);
- int g = OP(qGreen(d), sg);
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_solid_ColorDodge(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_solid_ColorDodge_impl(dest, length, color, QFullCoverage());
- else
- comp_func_solid_ColorDodge_impl(dest, length, color, QPartialCoverage(const_alpha));
-}
-
-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)
-{
- PRELOAD_INIT2(dest, src)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = src[i];
-
- int da = qAlpha(d);
- int sa = qAlpha(s);
-
-#define OP(a, b) color_dodge_op(a, b, da, sa)
- int r = OP( qRed(d), qRed(s));
- int b = OP( qBlue(d), qBlue(s));
- int g = OP(qGreen(d), qGreen(s));
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_ColorDodge(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_ColorDodge_impl(dest, src, length, QFullCoverage());
- else
- comp_func_ColorDodge_impl(dest, src, length, QPartialCoverage(const_alpha));
-}
-
-/*
- if Sca.Da + Dca.Sa <= Sa.Da
- Dca' = Sca.(1 - Da) + Dca.(1 - Sa)
- otherwise
- Dca' = Sa.(Sca.Da + Dca.Sa - Sa.Da)/Sca + Sca.(1 - Da) + Dca.(1 - Sa)
-*/
-static inline int color_burn_op(int dst, int src, int da, int sa)
-{
- const int src_da = src * da;
- const int dst_sa = dst * sa;
- const int sa_da = sa * da;
-
- const int temp = src * (255 - da) + dst * (255 - sa);
-
- if (src == 0 || src_da + dst_sa <= sa_da)
- return qt_div_255(temp);
- return qt_div_255(sa * (src_da + dst_sa - sa_da) / src + temp);
-}
-
-template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorBurn_impl(uint *dest, int length, uint color, const T &coverage)
-{
- int sa = qAlpha(color);
- int sr = qRed(color);
- int sg = qGreen(color);
- int sb = qBlue(color);
-
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- int da = qAlpha(d);
-
-#define OP(a, b) color_burn_op(a, b, da, sa)
- int r = OP( qRed(d), sr);
- int b = OP( qBlue(d), sb);
- int g = OP(qGreen(d), sg);
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_solid_ColorBurn(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_solid_ColorBurn_impl(dest, length, color, QFullCoverage());
- else
- comp_func_solid_ColorBurn_impl(dest, length, color, QPartialCoverage(const_alpha));
-}
-
-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)
-{
- PRELOAD_INIT2(dest, src)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = src[i];
-
- int da = qAlpha(d);
- int sa = qAlpha(s);
-
-#define OP(a, b) color_burn_op(a, b, da, sa)
- int r = OP( qRed(d), qRed(s));
- int b = OP( qBlue(d), qBlue(s));
- int g = OP(qGreen(d), qGreen(s));
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_ColorBurn(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_ColorBurn_impl(dest, src, length, QFullCoverage());
- else
- comp_func_ColorBurn_impl(dest, src, length, QPartialCoverage(const_alpha));
-}
-
-/*
- if 2.Sca < Sa
- Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa)
- otherwise
- Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa)
-*/
-static inline uint hardlight_op(int dst, int src, int da, int sa)
-{
- const uint temp = src * (255 - da) + dst * (255 - sa);
-
- if (2 * src < sa)
- return qt_div_255(2 * src * dst + temp);
- else
- return qt_div_255(sa * da - 2 * (da - dst) * (sa - src) + temp);
-}
-
-template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_HardLight_impl(uint *dest, int length, uint color, const T &coverage)
-{
- int sa = qAlpha(color);
- int sr = qRed(color);
- int sg = qGreen(color);
- int sb = qBlue(color);
-
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- int da = qAlpha(d);
-
-#define OP(a, b) hardlight_op(a, b, da, sa)
- int r = OP( qRed(d), sr);
- int b = OP( qBlue(d), sb);
- int g = OP(qGreen(d), sg);
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_solid_HardLight(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_solid_HardLight_impl(dest, length, color, QFullCoverage());
- else
- comp_func_solid_HardLight_impl(dest, length, color, QPartialCoverage(const_alpha));
-}
-
-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)
-{
- PRELOAD_INIT2(dest, src)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = src[i];
-
- int da = qAlpha(d);
- int sa = qAlpha(s);
-
-#define OP(a, b) hardlight_op(a, b, da, sa)
- int r = OP( qRed(d), qRed(s));
- int b = OP( qBlue(d), qBlue(s));
- int g = OP(qGreen(d), qGreen(s));
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_HardLight(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_HardLight_impl(dest, src, length, QFullCoverage());
- else
- comp_func_HardLight_impl(dest, src, length, QPartialCoverage(const_alpha));
-}
-
-/*
- if 2.Sca <= Sa
- Dca' = Dca.(Sa + (2.Sca - Sa).(1 - Dca/Da)) + Sca.(1 - Da) + Dca.(1 - Sa)
- otherwise if 2.Sca > Sa and 4.Dca <= Da
- Dca' = Dca.Sa + Da.(2.Sca - Sa).(4.Dca/Da.(4.Dca/Da + 1).(Dca/Da - 1) + 7.Dca/Da) + Sca.(1 - Da) + Dca.(1 - Sa)
- otherwise if 2.Sca > Sa and 4.Dca > Da
- Dca' = Dca.Sa + Da.(2.Sca - Sa).((Dca/Da)^0.5 - Dca/Da) + Sca.(1 - Da) + Dca.(1 - Sa)
-*/
-static inline int soft_light_op(int dst, int src, int da, int sa)
-{
- const int src2 = src << 1;
- const int dst_np = da != 0 ? (255 * dst) / da : 0;
- const int temp = (src * (255 - da) + dst * (255 - sa)) * 255;
-
- if (src2 < sa)
- return (dst * (sa * 255 + (src2 - sa) * (255 - dst_np)) + temp) / 65025;
- else if (4 * dst <= da)
- return (dst * sa * 255 + da * (src2 - sa) * ((((16 * dst_np - 12 * 255) * dst_np + 3 * 65025) * dst_np) / 65025) + temp) / 65025;
- else {
- return (dst * sa * 255 + da * (src2 - sa) * (int(qSqrt(qreal(dst_np * 255))) - dst_np) + temp) / 65025;
- }
-}
-
-template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_SoftLight_impl(uint *dest, int length, uint color, const T &coverage)
-{
- int sa = qAlpha(color);
- int sr = qRed(color);
- int sg = qGreen(color);
- int sb = qBlue(color);
-
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- int da = qAlpha(d);
-
-#define OP(a, b) soft_light_op(a, b, da, sa)
- int r = OP( qRed(d), sr);
- int b = OP( qBlue(d), sb);
- int g = OP(qGreen(d), sg);
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_solid_SoftLight(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_solid_SoftLight_impl(dest, length, color, QFullCoverage());
- else
- comp_func_solid_SoftLight_impl(dest, length, color, QPartialCoverage(const_alpha));
-}
-
-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)
-{
- PRELOAD_INIT2(dest, src)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = src[i];
-
- int da = qAlpha(d);
- int sa = qAlpha(s);
-
-#define OP(a, b) soft_light_op(a, b, da, sa)
- int r = OP( qRed(d), qRed(s));
- int b = OP( qBlue(d), qBlue(s));
- int g = OP(qGreen(d), qGreen(s));
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_SoftLight(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_SoftLight_impl(dest, src, length, QFullCoverage());
- else
- comp_func_SoftLight_impl(dest, src, length, QPartialCoverage(const_alpha));
-}
-
-/*
- Dca' = abs(Dca.Sa - Sca.Da) + Sca.(1 - Da) + Dca.(1 - Sa)
- = Sca + Dca - 2.min(Sca.Da, Dca.Sa)
-*/
-static inline int difference_op(int dst, int src, int da, int sa)
-{
- return src + dst - qt_div_255(2 * qMin(src * da, dst * sa));
-}
-
-template <typename T>
-Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Difference_impl(uint *dest, int length, uint color, const T &coverage)
-{
- int sa = qAlpha(color);
- int sr = qRed(color);
- int sg = qGreen(color);
- int sb = qBlue(color);
-
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- int da = qAlpha(d);
-
-#define OP(a, b) difference_op(a, b, da, sa)
- int r = OP( qRed(d), sr);
- int b = OP( qBlue(d), sb);
- int g = OP(qGreen(d), sg);
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_solid_Difference(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_solid_Difference_impl(dest, length, color, QFullCoverage());
- else
- comp_func_solid_Difference_impl(dest, length, color, QPartialCoverage(const_alpha));
-}
-
-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)
-{
- PRELOAD_INIT2(dest, src)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = src[i];
-
- int da = qAlpha(d);
- int sa = qAlpha(s);
-
-#define OP(a, b) difference_op(a, b, da, sa)
- int r = OP( qRed(d), qRed(s));
- int b = OP( qBlue(d), qBlue(s));
- int g = OP(qGreen(d), qGreen(s));
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_Difference(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_Difference_impl(dest, src, length, QFullCoverage());
- else
- comp_func_Difference_impl(dest, src, length, QPartialCoverage(const_alpha));
-}
-
-/*
- 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)
-{
- int sa = qAlpha(color);
- int sr = qRed(color);
- int sg = qGreen(color);
- int sb = qBlue(color);
-
- PRELOAD_INIT(dest)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND(dest)
- uint d = dest[i];
- int da = qAlpha(d);
-
-#define OP(a, b) (a + b - qt_div_255(2*(a*b)))
- int r = OP( qRed(d), sr);
- int b = OP( qBlue(d), sb);
- int g = OP(qGreen(d), sg);
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_solid_Exclusion(uint *dest, int length, uint color, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_solid_Exclusion_impl(dest, length, color, QFullCoverage());
- else
- comp_func_solid_Exclusion_impl(dest, length, color, QPartialCoverage(const_alpha));
-}
-
-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)
-{
- PRELOAD_INIT2(dest, src)
- for (int i = 0; i < length; ++i) {
- PRELOAD_COND2(dest, src)
- uint d = dest[i];
- uint s = src[i];
-
- int da = qAlpha(d);
- int sa = qAlpha(s);
-
-#define OP(a, b) (a + b - ((a*b) >> 7))
- int r = OP( qRed(d), qRed(s));
- int b = OP( qBlue(d), qBlue(s));
- int g = OP(qGreen(d), qGreen(s));
- int a = mix_alpha(da, sa);
-#undef OP
-
- coverage.store(&dest[i], qRgba(r, g, b, a));
- }
-}
-
-void QT_FASTCALL comp_func_Exclusion(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
-{
- if (const_alpha == 255)
- comp_func_Exclusion_impl(dest, src, length, QFullCoverage());
- else
- comp_func_Exclusion_impl(dest, src, length, QPartialCoverage(const_alpha));
-}
-
-void QT_FASTCALL rasterop_solid_SourceOrDestination(uint *dest,
- int length,
- uint color,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- while (length--)
- *dest++ |= color;
-}
-
-void QT_FASTCALL rasterop_SourceOrDestination(uint *Q_DECL_RESTRICT dest,
- const uint *Q_DECL_RESTRICT src,
- int length,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- while (length--)
- *dest++ |= *src++;
-}
-
-void QT_FASTCALL rasterop_solid_SourceAndDestination(uint *dest,
- int length,
- uint color,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- color |= 0xff000000;
- while (length--)
- *dest++ &= color;
-}
-
-void QT_FASTCALL rasterop_SourceAndDestination(uint *Q_DECL_RESTRICT dest,
- const uint *Q_DECL_RESTRICT src,
- int length,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- while (length--) {
- *dest = (*src & *dest) | 0xff000000;
- ++dest; ++src;
- }
-}
-
-void QT_FASTCALL rasterop_solid_SourceXorDestination(uint *dest,
- int length,
- uint color,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- color &= 0x00ffffff;
- while (length--)
- *dest++ ^= color;
-}
-
-void QT_FASTCALL rasterop_SourceXorDestination(uint *Q_DECL_RESTRICT dest,
- const uint *Q_DECL_RESTRICT src,
- int length,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- while (length--) {
- *dest = (*src ^ *dest) | 0xff000000;
- ++dest; ++src;
- }
-}
-
-void QT_FASTCALL rasterop_solid_NotSourceAndNotDestination(uint *dest,
- int length,
- uint color,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- color = ~color;
- while (length--) {
- *dest = (color & ~(*dest)) | 0xff000000;
- ++dest;
- }
-}
-
-void QT_FASTCALL rasterop_NotSourceAndNotDestination(uint *Q_DECL_RESTRICT dest,
- const uint *Q_DECL_RESTRICT src,
- int length,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- while (length--) {
- *dest = (~(*src) & ~(*dest)) | 0xff000000;
- ++dest; ++src;
- }
-}
-
-void QT_FASTCALL rasterop_solid_NotSourceOrNotDestination(uint *dest,
- int length,
- uint color,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- color = ~color | 0xff000000;
- while (length--) {
- *dest = color | ~(*dest);
- ++dest;
- }
-}
-
-void QT_FASTCALL rasterop_NotSourceOrNotDestination(uint *Q_DECL_RESTRICT dest,
- const uint *Q_DECL_RESTRICT src,
- int length,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- while (length--) {
- *dest = ~(*src) | ~(*dest) | 0xff000000;
- ++dest; ++src;
- }
-}
-
-void QT_FASTCALL rasterop_solid_NotSourceXorDestination(uint *dest,
- int length,
- uint color,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- color = ~color & 0x00ffffff;
- while (length--) {
- *dest = color ^ (*dest);
- ++dest;
- }
-}
-
-void QT_FASTCALL rasterop_NotSourceXorDestination(uint *Q_DECL_RESTRICT dest,
- const uint *Q_DECL_RESTRICT src,
- int length,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- while (length--) {
- *dest = ((~(*src)) ^ (*dest)) | 0xff000000;
- ++dest; ++src;
- }
-}
-
-void QT_FASTCALL rasterop_solid_NotSource(uint *dest, int length,
- uint color, uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- qt_memfill(dest, ~color | 0xff000000, length);
-}
-
-void QT_FASTCALL rasterop_NotSource(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src,
- int length, uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- while (length--)
- *dest++ = ~(*src++) | 0xff000000;
-}
-
-void QT_FASTCALL rasterop_solid_NotSourceAndDestination(uint *dest,
- int length,
- uint color,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- color = ~color | 0xff000000;
- while (length--) {
- *dest = color & *dest;
- ++dest;
- }
-}
-
-void QT_FASTCALL rasterop_NotSourceAndDestination(uint *Q_DECL_RESTRICT dest,
- const uint *Q_DECL_RESTRICT src,
- int length,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- while (length--) {
- *dest = (~(*src) & *dest) | 0xff000000;
- ++dest; ++src;
- }
-}
-
-void QT_FASTCALL rasterop_solid_SourceAndNotDestination(uint *dest,
- int length,
- uint color,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- while (length--) {
- *dest = (color & ~(*dest)) | 0xff000000;
- ++dest;
- }
-}
-
-void QT_FASTCALL rasterop_SourceAndNotDestination(uint *Q_DECL_RESTRICT dest,
- const uint *Q_DECL_RESTRICT src,
- int length,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- while (length--) {
- *dest = (*src & ~(*dest)) | 0xff000000;
- ++dest; ++src;
- }
-}
-
-void QT_FASTCALL rasterop_NotSourceOrDestination(uint *Q_DECL_RESTRICT dest,
- const uint *Q_DECL_RESTRICT src,
- int length,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- while (length--) {
- *dest = (~(*src) | *dest) | 0xff000000;
- ++dest; ++src;
- }
-}
-
-void QT_FASTCALL rasterop_solid_NotSourceOrDestination(uint *Q_DECL_RESTRICT dest,
- int length,
- uint color,
- uint const_alpha)
+static const uint * QT_FASTCALL qt_fetch_conical_gradient(uint *buffer, const Operator *, const QSpanData *data,
+ int y, int x, int length)
{
- Q_UNUSED(const_alpha);
- color = ~color | 0xff000000;
- while (length--)
- *dest++ |= color;
+ return qt_fetch_conical_gradient_template<GradientBase32, uint>(buffer, data, y, x, length);
}
-void QT_FASTCALL rasterop_SourceOrNotDestination(uint *Q_DECL_RESTRICT dest,
- const uint *Q_DECL_RESTRICT src,
- int length,
- uint const_alpha)
+static const QRgba64 * QT_FASTCALL qt_fetch_conical_gradient_rgb64(QRgba64 *buffer, const Operator *, const QSpanData *data,
+ int y, int x, int length)
{
- Q_UNUSED(const_alpha);
- while (length--) {
- *dest = (*src | ~(*dest)) | 0xff000000;
- ++dest; ++src;
- }
+ return qt_fetch_conical_gradient_template<GradientBase64, QRgba64>(buffer, data, y, x, length);
}
-void QT_FASTCALL rasterop_solid_SourceOrNotDestination(uint *Q_DECL_RESTRICT dest,
- int length,
- uint color,
- uint const_alpha)
-{
- Q_UNUSED(const_alpha);
- while (length--) {
- *dest = (color | ~(*dest)) | 0xff000000;
- ++dest;
- }
-}
+extern CompositionFunctionSolid qt_functionForModeSolid_C[];
+extern CompositionFunctionSolid64 qt_functionForModeSolid64_C[];
-void QT_FASTCALL rasterop_ClearDestination(uint *Q_DECL_RESTRICT dest,
- const uint *Q_DECL_RESTRICT src,
- int length,
- uint const_alpha)
-{
- Q_UNUSED(src);
- comp_func_solid_SourceOver (dest, length, 0xff000000, const_alpha);
-}
-
-void QT_FASTCALL rasterop_solid_ClearDestination(uint *Q_DECL_RESTRICT dest,
- int length,
- uint color,
- uint const_alpha)
-{
- Q_UNUSED(color);
- comp_func_solid_SourceOver (dest, length, 0xff000000, const_alpha);
-}
-
-void QT_FASTCALL rasterop_SetDestination(uint *Q_DECL_RESTRICT dest,
- const uint *Q_DECL_RESTRICT src,
- int length,
- uint const_alpha)
-{
- Q_UNUSED(src);
- comp_func_solid_SourceOver (dest, length, 0xffffffff, const_alpha);
-}
-
-void QT_FASTCALL rasterop_solid_SetDestination(uint *Q_DECL_RESTRICT dest,
- int length,
- uint color,
- uint const_alpha)
-{
- Q_UNUSED(color);
- comp_func_solid_SourceOver (dest, length, 0xffffffff, const_alpha);
-}
-
-void QT_FASTCALL rasterop_NotDestination(uint *Q_DECL_RESTRICT dest,
- const uint *Q_DECL_RESTRICT src,
- int length,
- uint const_alpha)
-{
- Q_UNUSED(src);
- rasterop_solid_SourceXorDestination (dest, length, 0x00ffffff, const_alpha);
-}
-
-void QT_FASTCALL rasterop_solid_NotDestination(uint *Q_DECL_RESTRICT dest,
- int length,
- uint color,
- uint const_alpha)
-{
- Q_UNUSED(color);
- rasterop_solid_SourceXorDestination (dest, length, 0x00ffffff, const_alpha);
-}
-
-static CompositionFunctionSolid functionForModeSolid_C[] = {
- comp_func_solid_SourceOver,
- comp_func_solid_DestinationOver,
- comp_func_solid_Clear,
- comp_func_solid_Source,
- comp_func_solid_Destination,
- comp_func_solid_SourceIn,
- comp_func_solid_DestinationIn,
- comp_func_solid_SourceOut,
- comp_func_solid_DestinationOut,
- comp_func_solid_SourceAtop,
- comp_func_solid_DestinationAtop,
- comp_func_solid_XOR,
- comp_func_solid_Plus,
- comp_func_solid_Multiply,
- comp_func_solid_Screen,
- comp_func_solid_Overlay,
- comp_func_solid_Darken,
- comp_func_solid_Lighten,
- comp_func_solid_ColorDodge,
- comp_func_solid_ColorBurn,
- comp_func_solid_HardLight,
- comp_func_solid_SoftLight,
- comp_func_solid_Difference,
- comp_func_solid_Exclusion,
- rasterop_solid_SourceOrDestination,
- rasterop_solid_SourceAndDestination,
- rasterop_solid_SourceXorDestination,
- rasterop_solid_NotSourceAndNotDestination,
- rasterop_solid_NotSourceOrNotDestination,
- rasterop_solid_NotSourceXorDestination,
- rasterop_solid_NotSource,
- rasterop_solid_NotSourceAndDestination,
- rasterop_solid_SourceAndNotDestination,
- rasterop_solid_NotSourceOrDestination,
- rasterop_solid_SourceOrNotDestination,
- rasterop_solid_ClearDestination,
- rasterop_solid_SetDestination,
- rasterop_solid_NotDestination
-};
+static const CompositionFunctionSolid *functionForModeSolid = qt_functionForModeSolid_C;
+static const CompositionFunctionSolid64 *functionForModeSolid64 = qt_functionForModeSolid64_C;
-static const CompositionFunctionSolid *functionForModeSolid = functionForModeSolid_C;
-
-static CompositionFunction functionForMode_C[] = {
- comp_func_SourceOver,
- comp_func_DestinationOver,
- comp_func_Clear,
- comp_func_Source,
- comp_func_Destination,
- comp_func_SourceIn,
- comp_func_DestinationIn,
- comp_func_SourceOut,
- comp_func_DestinationOut,
- comp_func_SourceAtop,
- comp_func_DestinationAtop,
- comp_func_XOR,
- comp_func_Plus,
- comp_func_Multiply,
- comp_func_Screen,
- comp_func_Overlay,
- comp_func_Darken,
- comp_func_Lighten,
- comp_func_ColorDodge,
- comp_func_ColorBurn,
- comp_func_HardLight,
- comp_func_SoftLight,
- comp_func_Difference,
- comp_func_Exclusion,
- rasterop_SourceOrDestination,
- rasterop_SourceAndDestination,
- rasterop_SourceXorDestination,
- rasterop_NotSourceAndNotDestination,
- rasterop_NotSourceOrNotDestination,
- rasterop_NotSourceXorDestination,
- rasterop_NotSource,
- rasterop_NotSourceAndDestination,
- rasterop_SourceAndNotDestination,
- rasterop_NotSourceOrDestination,
- rasterop_SourceOrNotDestination,
- rasterop_ClearDestination,
- rasterop_SetDestination,
- rasterop_NotDestination
-};
+extern CompositionFunction qt_functionForMode_C[];
+extern CompositionFunction64 qt_functionForMode64_C[];
-static const CompositionFunction *functionForMode = functionForMode_C;
+static const CompositionFunction *functionForMode = qt_functionForMode_C;
+static const CompositionFunction64 *functionForMode64 = qt_functionForMode64_C;
static TextureBlendType getBlendType(const QSpanData *data)
{
@@ -4280,26 +3714,34 @@ static inline Operator getOperator(const QSpanData *data, const QSpan *spans, in
switch(data->type) {
case QSpanData::Solid:
- solidSource = (qAlpha(data->solid.color) == 255);
+ solidSource = data->solid.color.isOpaque();
+ op.srcFetch = 0;
+ op.srcFetch64 = 0;
break;
case QSpanData::LinearGradient:
solidSource = !data->gradient.alphaColor;
getLinearGradientValues(&op.linear, data);
- op.src_fetch = qt_fetch_linear_gradient;
+ op.srcFetch = qt_fetch_linear_gradient;
+ op.srcFetch64 = qt_fetch_linear_gradient_rgb64;
break;
case QSpanData::RadialGradient:
solidSource = !data->gradient.alphaColor;
getRadialGradientValues(&op.radial, data);
- op.src_fetch = qt_fetch_radial_gradient;
+ op.srcFetch = qt_fetch_radial_gradient;
+ op.srcFetch64 = qt_fetch_radial_gradient_rgb64;
break;
case QSpanData::ConicalGradient:
solidSource = !data->gradient.alphaColor;
- op.src_fetch = qt_fetch_conical_gradient;
+ op.srcFetch = qt_fetch_conical_gradient;
+ op.srcFetch64 = qt_fetch_conical_gradient_rgb64;
break;
case QSpanData::Texture:
- op.src_fetch = sourceFetch[getBlendType(data)][data->texture.format];
solidSource = !data->texture.hasAlpha;
+ op.srcFetch = sourceFetch[getBlendType(data)][data->texture.format];
+ op.srcFetch64 = sourceFetch64[getBlendType(data)][data->texture.format];
+ break;
default:
+ Q_UNREACHABLE();
break;
}
@@ -4307,12 +3749,13 @@ static inline Operator getOperator(const QSpanData *data, const QSpan *spans, in
if (op.mode == QPainter::CompositionMode_SourceOver && solidSource)
op.mode = QPainter::CompositionMode_Source;
- op.dest_fetch = destFetchProc[data->rasterBuffer->format];
+ op.destFetch = destFetchProc[data->rasterBuffer->format];
+ op.destFetch64 = destFetchProc64[data->rasterBuffer->format];
if (op.mode == QPainter::CompositionMode_Source) {
switch (data->rasterBuffer->format) {
case QImage::Format_RGB32:
case QImage::Format_ARGB32_Premultiplied:
- // don't clear dest_fetch as it sets up the pointer correctly to save one copy
+ // don't clear destFetch as it sets up the pointer correctly to save one copy
break;
default: {
if (data->type == QSpanData::Texture && data->texture.const_alpha != 256)
@@ -4327,15 +3770,18 @@ static inline Operator getOperator(const QSpanData *data, const QSpan *spans, in
++spans;
}
if (!alphaSpans)
- op.dest_fetch = 0;
+ op.destFetch = 0;
}
}
}
- op.dest_store = destStoreProc[data->rasterBuffer->format];
+ op.destStore = destStoreProc[data->rasterBuffer->format];
+ op.destStore64 = destStoreProc64[data->rasterBuffer->format];
op.funcSolid = functionForModeSolid[op.mode];
+ op.funcSolid64 = functionForModeSolid64[op.mode];
op.func = functionForMode[op.mode];
+ op.func64 = functionForMode64[op.mode];
return op;
}
@@ -4352,16 +3798,17 @@ void blend_color_generic(int count, const QSpan *spans, void *userData)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
uint buffer[buffer_size];
Operator op = getOperator(data, spans, count);
+ const uint color = data->solid.color.toArgb32();
while (count--) {
int x = spans->x;
int length = spans->len;
while (length) {
int l = qMin(buffer_size, length);
- uint *dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer;
- op.funcSolid(dest, l, data->solid.color, spans->coverage);
- if (op.dest_store)
- op.dest_store(data->rasterBuffer, x, spans->y, dest, l);
+ uint *dest = op.destFetch ? op.destFetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer;
+ op.funcSolid(dest, l, color, spans->coverage);
+ if (op.destStore)
+ op.destStore(data->rasterBuffer, x, spans->y, dest, l);
length -= l;
x += l;
}
@@ -4374,15 +3821,16 @@ static void blend_color_argb(int count, const QSpan *spans, void *userData)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
Operator op = getOperator(data, spans, count);
+ const uint color = data->solid.color.toArgb32();
if (op.mode == QPainter::CompositionMode_Source) {
// inline for performance
while (count--) {
uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x;
if (spans->coverage == 255) {
- QT_MEMFILL_UINT(target, spans->len, data->solid.color);
+ QT_MEMFILL_UINT(target, spans->len, color);
} else {
- uint c = BYTE_MUL(data->solid.color, spans->coverage);
+ uint c = BYTE_MUL(color, spans->coverage);
int ialpha = 255 - spans->coverage;
for (int i = 0; i < spans->len; ++i)
target[i] = c + BYTE_MUL(target[i], ialpha);
@@ -4394,7 +3842,34 @@ static void blend_color_argb(int count, const QSpan *spans, void *userData)
while (count--) {
uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x;
- op.funcSolid(target, spans->len, data->solid.color, spans->coverage);
+ op.funcSolid(target, spans->len, color, spans->coverage);
+ ++spans;
+ }
+}
+
+void blend_color_generic_rgb64(int count, const QSpan *spans, void *userData)
+{
+ QSpanData *data = reinterpret_cast<QSpanData *>(userData);
+ Operator op = getOperator(data, spans, count);
+ if (!op.funcSolid64) {
+ qDebug() << Q_FUNC_INFO << "unsupported 64bit blend attempted";
+ return blend_color_generic(count, spans, userData);
+ }
+
+ QRgba64 buffer[buffer_size];
+ const QRgba64 color = data->solid.color;
+
+ while (count--) {
+ int x = spans->x;
+ int length = spans->len;
+ while (length) {
+ int l = qMin(buffer_size, length);
+ QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l);
+ op.funcSolid64(dest, l, color, spans->coverage);
+ op.destStore64(data->rasterBuffer, x, spans->y, dest, l);
+ length -= l;
+ x += l;
+ }
++spans;
}
}
@@ -4409,13 +3884,12 @@ static void blend_color_rgb16(int count, const QSpan *spans, void *userData)
from qt_gradient_quint16 with minimal overhead.
*/
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode;
- if (mode == QPainter::CompositionMode_SourceOver &&
- qAlpha(data->solid.color) == 255)
+ if (mode == QPainter::CompositionMode_SourceOver && data->solid.color.isOpaque())
mode = QPainter::CompositionMode_Source;
if (mode == QPainter::CompositionMode_Source) {
// inline for performance
- ushort c = qConvertRgb32To16(data->solid.color);
+ ushort c = data->solid.color.toRgb16();
while (count--) {
ushort *target = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + spans->x;
if (spans->coverage == 255) {
@@ -4436,7 +3910,7 @@ static void blend_color_rgb16(int count, const QSpan *spans, void *userData)
if (mode == QPainter::CompositionMode_SourceOver) {
while (count--) {
- uint color = BYTE_MUL(data->solid.color, spans->coverage);
+ uint color = BYTE_MUL(data->solid.color.toArgb32(), spans->coverage);
int ialpha = qAlpha(~color);
ushort c = qConvertRgb32To16(color);
ushort *target = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + spans->x;
@@ -4500,7 +3974,7 @@ void handleSpans(int count, const QSpan *spans, const QSpanData *data, T &handle
int process_length = l;
int process_x = x;
- const uint *src = handler.fetch(process_x, y, process_length);
+ const typename T::BlendType *src = handler.fetch(process_x, y, process_length);
int offset = 0;
while (l > 0) {
if (x == spans->x) // new span?
@@ -4525,8 +3999,10 @@ void handleSpans(int count, const QSpan *spans, const QSpanData *data, T &handle
}
}
+template<typename T>
struct QBlendBase
{
+ typedef T BlendType;
QBlendBase(QSpanData *d, Operator o)
: data(d)
, op(o)
@@ -4537,24 +4013,24 @@ struct QBlendBase
QSpanData *data;
Operator op;
- uint *dest;
+ BlendType *dest;
- uint buffer[buffer_size];
- uint src_buffer[buffer_size];
+ BlendType buffer[buffer_size];
+ BlendType src_buffer[buffer_size];
};
-class BlendSrcGeneric : public QBlendBase
+class BlendSrcGeneric : public QBlendBase<uint>
{
public:
BlendSrcGeneric(QSpanData *d, Operator o)
- : QBlendBase(d, o)
+ : QBlendBase<uint>(d, o)
{
}
const uint *fetch(int x, int y, int len)
{
- dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, y, len) : buffer;
- return op.src_fetch(src_buffer, &op, data, y, x, len);
+ dest = op.destFetch ? op.destFetch(buffer, data->rasterBuffer, x, y, len) : buffer;
+ return op.srcFetch(src_buffer, &op, data, y, x, len);
}
void process(int, int, int len, int coverage, const uint *src, int offset)
@@ -4564,8 +4040,38 @@ public:
void store(int x, int y, int len)
{
- if (op.dest_store)
- op.dest_store(data->rasterBuffer, x, y, dest, len);
+ if (op.destStore)
+ op.destStore(data->rasterBuffer, x, y, dest, len);
+ }
+};
+
+class BlendSrcGenericRGB64 : public QBlendBase<QRgba64>
+{
+public:
+ BlendSrcGenericRGB64(QSpanData *d, Operator o)
+ : QBlendBase<QRgba64>(d, o)
+ {
+ }
+
+ bool isSupported() const
+ {
+ return op.func64 && op.destFetch64 && op.destStore64;
+ }
+
+ const QRgba64 *fetch(int x, int y, int len)
+ {
+ dest = op.destFetch64(buffer, data->rasterBuffer, x, y, len);
+ return op.srcFetch64(src_buffer, &op, data, y, x, len);
+ }
+
+ void process(int, int, int len, int coverage, const QRgba64 *src, int offset)
+ {
+ op.func64(dest + offset, src + offset, len, coverage);
+ }
+
+ void store(int x, int y, int len)
+ {
+ op.destStore64(data->rasterBuffer, x, y, dest, len);
}
};
@@ -4576,6 +4082,20 @@ static void blend_src_generic(int count, const QSpan *spans, void *userData)
handleSpans(count, spans, data, blend);
}
+static void blend_src_generic_rgb64(int count, const QSpan *spans, void *userData)
+{
+ QSpanData *data = reinterpret_cast<QSpanData *>(userData);
+ Operator op = getOperator(data, spans, count);
+ BlendSrcGenericRGB64 blend64(data, op);
+ if (blend64.isSupported())
+ handleSpans(count, spans, data, blend64);
+ else {
+ qDebug("blend_src_generic_rgb64: unsupported 64-bit blend attempted");
+ BlendSrcGeneric blend32(data, op);
+ handleSpans(count, spans, data, blend32);
+ }
+}
+
static void blend_untransformed_generic(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
@@ -4606,11 +4126,59 @@ static void blend_untransformed_generic(int count, const QSpan *spans, void *use
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8;
while (length) {
int l = qMin(buffer_size, length);
- const uint *src = op.src_fetch(src_buffer, &op, data, sy, sx, l);
- uint *dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer;
+ const uint *src = op.srcFetch(src_buffer, &op, data, sy, sx, l);
+ uint *dest = op.destFetch ? op.destFetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer;
op.func(dest, src, l, coverage);
- if (op.dest_store)
- op.dest_store(data->rasterBuffer, x, spans->y, dest, l);
+ if (op.destStore)
+ op.destStore(data->rasterBuffer, x, spans->y, dest, l);
+ x += l;
+ sx += l;
+ length -= l;
+ }
+ }
+ }
+ ++spans;
+ }
+}
+
+static void blend_untransformed_generic_rgb64(int count, const QSpan *spans, void *userData)
+{
+ QSpanData *data = reinterpret_cast<QSpanData *>(userData);
+
+ Operator op = getOperator(data, spans, count);
+ if (!op.func64) {
+ qWarning() << Q_FUNC_INFO << "Unsupported blend";
+ return blend_untransformed_generic(count, spans, userData);
+ }
+ QRgba64 buffer[buffer_size];
+ QRgba64 src_buffer[buffer_size];
+
+ const int image_width = data->texture.width;
+ const int image_height = data->texture.height;
+ int xoff = -qRound(-data->dx);
+ int yoff = -qRound(-data->dy);
+
+ while (count--) {
+ int x = spans->x;
+ int length = spans->len;
+ int sx = xoff + x;
+ int sy = yoff + spans->y;
+ if (sy >= 0 && sy < image_height && sx < image_width) {
+ if (sx < 0) {
+ x -= sx;
+ length += sx;
+ sx = 0;
+ }
+ if (sx + length > image_width)
+ length = image_width - sx;
+ if (length > 0) {
+ const int coverage = (spans->coverage * data->texture.const_alpha) >> 8;
+ while (length) {
+ int l = qMin(buffer_size, length);
+ const QRgba64 *src = op.srcFetch64(src_buffer, &op, data, sy, sx, l);
+ QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l);
+ op.func64(dest, src, l, coverage);
+ op.destStore64(data->rasterBuffer, x, spans->y, dest, l);
x += l;
sx += l;
length -= l;
@@ -4799,11 +4367,62 @@ static void blend_tiled_generic(int count, const QSpan *spans, void *userData)
int l = qMin(image_width - sx, length);
if (buffer_size < l)
l = buffer_size;
- const uint *src = op.src_fetch(src_buffer, &op, data, sy, sx, l);
- uint *dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer;
+ const uint *src = op.srcFetch(src_buffer, &op, data, sy, sx, l);
+ uint *dest = op.destFetch ? op.destFetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer;
op.func(dest, src, l, coverage);
- if (op.dest_store)
- op.dest_store(data->rasterBuffer, x, spans->y, dest, l);
+ if (op.destStore)
+ op.destStore(data->rasterBuffer, x, spans->y, dest, l);
+ x += l;
+ sx += l;
+ length -= l;
+ if (sx >= image_width)
+ sx = 0;
+ }
+ ++spans;
+ }
+}
+
+static void blend_tiled_generic_rgb64(int count, const QSpan *spans, void *userData)
+{
+ QSpanData *data = reinterpret_cast<QSpanData *>(userData);
+
+ Operator op = getOperator(data, spans, count);
+ if (!op.func64) {
+ qDebug("unsupported rgb64 blend");
+ return blend_tiled_generic(count, spans, userData);
+ }
+ QRgba64 buffer[buffer_size];
+ QRgba64 src_buffer[buffer_size];
+
+ const int image_width = data->texture.width;
+ const int image_height = data->texture.height;
+ int xoff = -qRound(-data->dx) % image_width;
+ int yoff = -qRound(-data->dy) % image_height;
+
+ if (xoff < 0)
+ xoff += image_width;
+ if (yoff < 0)
+ yoff += image_height;
+
+ while (count--) {
+ int x = spans->x;
+ int length = spans->len;
+ int sx = (xoff + spans->x) % image_width;
+ int sy = (spans->y + yoff) % image_height;
+ if (sx < 0)
+ sx += image_width;
+ if (sy < 0)
+ sy += image_height;
+
+ const int coverage = (spans->coverage * data->texture.const_alpha) >> 8;
+ while (length) {
+ int l = qMin(image_width - sx, length);
+ if (buffer_size < l)
+ l = buffer_size;
+ const QRgba64 *src = op.srcFetch64(src_buffer, &op, data, sy, sx, l);
+ QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l);
+ op.func64(dest, src, l, coverage);
+ op.destStore64(data->rasterBuffer, x, spans->y, dest, l);
x += l;
sx += l;
length -= l;
@@ -5684,10 +5303,10 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_untransformed_generic,
blend_untransformed_generic,
blend_untransformed_generic,
- blend_untransformed_generic,
- blend_untransformed_generic,
- blend_untransformed_generic,
- blend_untransformed_generic,
+ blend_untransformed_generic_rgb64,
+ blend_untransformed_generic_rgb64,
+ blend_untransformed_generic_rgb64,
+ blend_untransformed_generic_rgb64,
blend_untransformed_generic,
blend_untransformed_generic,
},
@@ -5712,10 +5331,10 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_tiled_generic,
blend_tiled_generic,
blend_tiled_generic,
- blend_tiled_generic,
- blend_tiled_generic,
- blend_tiled_generic,
- blend_tiled_generic,
+ blend_tiled_generic_rgb64,
+ blend_tiled_generic_rgb64,
+ blend_tiled_generic_rgb64,
+ blend_tiled_generic_rgb64,
blend_tiled_generic,
blend_tiled_generic,
},
@@ -5740,10 +5359,10 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_src_generic,
blend_src_generic,
blend_src_generic,
- blend_src_generic,
- blend_src_generic,
- blend_src_generic,
- blend_src_generic,
+ blend_src_generic_rgb64,
+ blend_src_generic_rgb64,
+ blend_src_generic_rgb64,
+ blend_src_generic_rgb64,
blend_src_generic,
blend_src_generic,
},
@@ -5767,12 +5386,12 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_src_generic,
blend_src_generic,
blend_src_generic,
+ blend_src_generic_rgb64,
+ blend_src_generic_rgb64,
+ blend_src_generic_rgb64,
+ blend_src_generic_rgb64,
blend_src_generic,
blend_src_generic,
- blend_src_generic,
- blend_src_generic,
- blend_src_generic,
- blend_src_generic
},
// Bilinear
{
@@ -5795,10 +5414,10 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_src_generic,
blend_src_generic,
blend_src_generic,
- blend_src_generic,
- blend_src_generic,
- blend_src_generic,
- blend_src_generic,
+ blend_src_generic_rgb64,
+ blend_src_generic_rgb64,
+ blend_src_generic_rgb64,
+ blend_src_generic_rgb64,
blend_src_generic,
blend_src_generic,
},
@@ -5823,10 +5442,10 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_src_generic, // RGBX8888
blend_src_generic, // RGBA8888
blend_src_generic, // RGBA8888_Premultiplied
- blend_src_generic, // BGR30
- blend_src_generic, // A2BGR30_Premultiplied
- blend_src_generic, // RGB30
- blend_src_generic, // A2RGB30_Premultiplied
+ blend_src_generic_rgb64, // BGR30
+ blend_src_generic_rgb64, // A2BGR30_Premultiplied
+ blend_src_generic_rgb64, // RGB30
+ blend_src_generic_rgb64, // A2RGB30_Premultiplied
blend_src_generic, // Alpha8
blend_src_generic, // Grayscale8
}
@@ -5982,13 +5601,11 @@ static void qt_gradient_quint16(int count, const QSpan *spans, void *userData)
int yinc = int((linear.dy * data->m22 * gss) * FIXPT_SIZE);
int off = int((((linear.dy * (data->m22 * qreal(0.5) + data->dy) + linear.off) * gss) * FIXPT_SIZE));
- uint oldColor = data->solid.color;
+ QRgba64 oldColor = data->solid.color;
while (count--) {
int y = spans->y;
- quint32 color = qt_gradient_pixel_fixed(&data->gradient, yinc * y + off);
-
- data->solid.color = color;
+ data->solid.color = QRgba64::fromArgb32(qt_gradient_pixel_fixed(&data->gradient, yinc * y + off));
blend_color_rgb16(1, spans, userData);
++spans;
}
@@ -6000,39 +5617,49 @@ static void qt_gradient_quint16(int count, const QSpan *spans, void *userData)
}
inline static void qt_bitmapblit_argb32(QRasterBuffer *rasterBuffer,
- int x, int y, quint32 color,
+ int x, int y, const QRgba64 &color,
const uchar *map,
int mapWidth, int mapHeight, int mapStride)
{
- qt_bitmapblit_template<quint32>(rasterBuffer, x, y, color,
+ qt_bitmapblit_template<quint32>(rasterBuffer, x, y, color.toArgb32(),
map, mapWidth, mapHeight, mapStride);
}
inline static void qt_bitmapblit_rgba8888(QRasterBuffer *rasterBuffer,
- int x, int y, quint32 color,
+ int x, int y, const QRgba64 &color,
const uchar *map,
int mapWidth, int mapHeight, int mapStride)
{
- qt_bitmapblit_template<quint32>(rasterBuffer, x, y, ARGB2RGBA(color),
+ qt_bitmapblit_template<quint32>(rasterBuffer, x, y, ARGB2RGBA(color.toArgb32()),
+ map, mapWidth, mapHeight, mapStride);
+}
+
+template<QtPixelOrder PixelOrder>
+inline static void qt_bitmapblit_rgb30(QRasterBuffer *rasterBuffer,
+ int x, int y, const QRgba64 &color,
+ const uchar *map,
+ int mapWidth, int mapHeight, int mapStride)
+{
+ qt_bitmapblit_template<quint32>(rasterBuffer, x, y, qConvertRgb64ToRgb30<PixelOrder>(color),
map, mapWidth, mapHeight, mapStride);
}
inline static void qt_bitmapblit_quint16(QRasterBuffer *rasterBuffer,
- int x, int y, quint32 color,
+ int x, int y, const QRgba64 &color,
const uchar *map,
int mapWidth, int mapHeight, int mapStride)
{
- qt_bitmapblit_template<quint16>(rasterBuffer, x, y, qConvertRgb32To16(color),
+ qt_bitmapblit_template<quint16>(rasterBuffer, x, y, color.toRgb16(),
map, mapWidth, mapHeight, mapStride);
}
static void qt_alphamapblit_quint16(QRasterBuffer *rasterBuffer,
- int x, int y, quint32 color,
+ int x, int y, const QRgba64 &color,
const uchar *map,
int mapWidth, int mapHeight, int mapStride,
const QClipData *)
{
- const quint16 c = qConvertRgb32To16(color);
+ const quint16 c = color.toRgb16();
quint16 *dest = reinterpret_cast<quint16*>(rasterBuffer->scanLine(y)) + x;
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint16);
@@ -6130,7 +5757,7 @@ static inline void grayBlendPixel(quint32 *dst, int coverage, int sr, int sg, in
}
#endif
-static void qt_alphamapblit_argb32(QRasterBuffer *rasterBuffer,
+static void qt_alphamapblit_uint32(QRasterBuffer *rasterBuffer,
int x, int y, quint32 color,
const uchar *map,
int mapWidth, int mapHeight, int mapStride,
@@ -6226,28 +5853,38 @@ static void qt_alphamapblit_argb32(QRasterBuffer *rasterBuffer,
}
}
+
+static void qt_alphamapblit_argb32(QRasterBuffer *rasterBuffer,
+ int x, int y, const QRgba64 &color,
+ const uchar *map,
+ int mapWidth, int mapHeight, int mapStride,
+ const QClipData *clip)
+{
+ qt_alphamapblit_uint32(rasterBuffer, x, y, color.toArgb32(), map, mapWidth, mapHeight, mapStride, clip);
+}
+
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
static void qt_alphamapblit_rgba8888(QRasterBuffer *rasterBuffer,
- int x, int y, quint32 color,
+ int x, int y, const QRgba64 &color,
const uchar *map,
int mapWidth, int mapHeight, int mapStride,
const QClipData *clip)
{
- qt_alphamapblit_argb32(rasterBuffer, x, y, ARGB2RGBA(color), map, mapWidth, mapHeight, mapStride, clip);
+ qt_alphamapblit_uint32(rasterBuffer, x, y, ARGB2RGBA(color.toArgb32()), map, mapWidth, mapHeight, mapStride, clip);
}
#endif
static void qt_alphargbblit_argb32(QRasterBuffer *rasterBuffer,
- int x, int y, quint32 color,
+ int x, int y, const QRgba64 &color,
const uint *src, int mapWidth, int mapHeight, int srcStride,
const QClipData *clip)
{
- const quint32 c = color;
+ const quint32 c = color.toArgb32();
- int sr = qRed(color);
- int sg = qGreen(color);
- int sb = qBlue(color);
- int sa = qAlpha(color);
+ int sr = qRed(c);
+ int sg = qGreen(c);
+ int sb = qBlue(c);
+ int sa = qAlpha(c);
const QDrawHelperGammaTables *tables = QGuiApplicationPrivate::instance()->gammaTables();
if (!tables)
@@ -6314,58 +5951,67 @@ static void qt_alphargbblit_argb32(QRasterBuffer *rasterBuffer,
static void qt_rectfill_argb32(QRasterBuffer *rasterBuffer,
int x, int y, int width, int height,
- quint32 color)
+ const QRgba64 &color)
{
qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()),
- color, x, y, width, height, rasterBuffer->bytesPerLine());
+ color.toArgb32(), x, y, width, height, rasterBuffer->bytesPerLine());
}
static void qt_rectfill_quint16(QRasterBuffer *rasterBuffer,
int x, int y, int width, int height,
- quint32 color)
+ const QRgba64 &color)
{
qt_rectfill<quint16>(reinterpret_cast<quint16 *>(rasterBuffer->buffer()),
- qConvertRgb32To16(color), x, y, width, height, rasterBuffer->bytesPerLine());
+ color.toRgb16(), x, y, width, height, rasterBuffer->bytesPerLine());
}
static void qt_rectfill_nonpremul_argb32(QRasterBuffer *rasterBuffer,
int x, int y, int width, int height,
- quint32 color)
+ const QRgba64 &color)
{
qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()),
- qUnpremultiply(color), x, y, width, height, rasterBuffer->bytesPerLine());
+ color.unpremultiplied().toArgb32(), x, y, width, height, rasterBuffer->bytesPerLine());
}
static void qt_rectfill_rgba(QRasterBuffer *rasterBuffer,
int x, int y, int width, int height,
- quint32 color)
+ const QRgba64 &color)
{
qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()),
- ARGB2RGBA(color), x, y, width, height, rasterBuffer->bytesPerLine());
+ ARGB2RGBA(color.toArgb32()), x, y, width, height, rasterBuffer->bytesPerLine());
}
static void qt_rectfill_nonpremul_rgba(QRasterBuffer *rasterBuffer,
int x, int y, int width, int height,
- quint32 color)
+ const QRgba64 &color)
+{
+ qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()),
+ ARGB2RGBA(color.unpremultiplied().toArgb32()), x, y, width, height, rasterBuffer->bytesPerLine());
+}
+
+template<QtPixelOrder PixelOrder>
+static void qt_rectfill_rgb30(QRasterBuffer *rasterBuffer,
+ int x, int y, int width, int height,
+ const QRgba64 &color)
{
qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()),
- ARGB2RGBA(qUnpremultiply(color)), x, y, width, height, rasterBuffer->bytesPerLine());
+ qConvertRgb64ToRgb30<PixelOrder>(color), x, y, width, height, rasterBuffer->bytesPerLine());
}
static void qt_rectfill_alpha(QRasterBuffer *rasterBuffer,
int x, int y, int width, int height,
- quint32 color)
+ const QRgba64 &color)
{
qt_rectfill<quint8>(reinterpret_cast<quint8 *>(rasterBuffer->buffer()),
- qAlpha(color), x, y, width, height, rasterBuffer->bytesPerLine());
+ color.alpha() >> 8, x, y, width, height, rasterBuffer->bytesPerLine());
}
static void qt_rectfill_gray(QRasterBuffer *rasterBuffer,
int x, int y, int width, int height,
- quint32 color)
+ const QRgba64 &color)
{
qt_rectfill<quint8>(reinterpret_cast<quint8 *>(rasterBuffer->buffer()),
- qGray(color), x, y, width, height, rasterBuffer->bytesPerLine());
+ qGray(color.toArgb32()), x, y, width, height, rasterBuffer->bytesPerLine());
}
// Map table for destination image format. Contains function pointers
@@ -6518,39 +6164,39 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
},
// Format_BGR30
{
- blend_color_generic,
- blend_src_generic,
- 0,
+ blend_color_generic_rgb64,
+ blend_src_generic_rgb64,
+ qt_bitmapblit_rgb30<PixelOrderBGR>,
0,
0,
- 0
+ qt_rectfill_rgb30<PixelOrderBGR>
},
// Format_A2BGR30_Premultiplied
{
- blend_color_generic,
- blend_src_generic,
- 0,
+ blend_color_generic_rgb64,
+ blend_src_generic_rgb64,
+ qt_bitmapblit_rgb30<PixelOrderBGR>,
0,
0,
- 0
+ qt_rectfill_rgb30<PixelOrderBGR>
},
// Format_RGB30
{
- blend_color_generic,
- blend_src_generic,
- 0,
+ blend_color_generic_rgb64,
+ blend_src_generic_rgb64,
+ qt_bitmapblit_rgb30<PixelOrderRGB>,
0,
0,
- 0
+ qt_rectfill_rgb30<PixelOrderRGB>
},
// Format_A2RGB30_Premultiplied
{
- blend_color_generic,
- blend_src_generic,
- 0,
+ blend_color_generic_rgb64,
+ blend_src_generic_rgb64,
+ qt_bitmapblit_rgb30<PixelOrderRGB>,
0,
0,
- 0
+ qt_rectfill_rgb30<PixelOrderRGB>
},
// Format_Alpha8
{
@@ -6619,6 +6265,11 @@ inline void qt_memfill_template(quint16 *dest, quint16 value, int count)
}
#endif
+void qt_memfill64(quint64 *dest, quint64 color, int count)
+{
+ qt_memfill_template<quint64>(dest, color, count);
+}
+
#if !defined(__SSE2__)
void qt_memfill16(quint16 *dest, quint16 color, int count)
{
@@ -6646,9 +6297,6 @@ template<QtPixelOrder> const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4
void qInitDrawhelperAsm()
{
- CompositionFunction *functionForModeAsm = 0;
- CompositionFunctionSolid *functionForModeSolidAsm = 0;
-
const uint features = qCpuFeatures();
Q_UNUSED(features);
#ifdef __SSE2__
@@ -6735,9 +6383,15 @@ void qInitDrawhelperAsm()
qPixelLayouts[QImage::Format_RGBA8888].convertToARGB32PM = convertRGBA8888ToARGB32PM_avx2;
}
#endif
+ extern void QT_FASTCALL comp_func_SourceOver_sse2(uint *destPixels, const uint *srcPixels, int length, uint const_alpha);
+ extern void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, uint color, uint const_alpha);
+ extern void QT_FASTCALL comp_func_Source_sse2(uint *destPixels, const uint *srcPixels, int length, uint const_alpha);
+ extern void QT_FASTCALL comp_func_Plus_sse2(uint *destPixels, const uint *srcPixels, int length, uint const_alpha);
+ qt_functionForMode_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_sse2;
+ qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_sse2;
+ qt_functionForMode_C[QPainter::CompositionMode_Source] = comp_func_Source_sse2;
+ qt_functionForMode_C[QPainter::CompositionMode_Plus] = comp_func_Plus_sse2;
- functionForModeAsm = qt_functionForMode_SSE2;
- functionForModeSolidAsm = qt_functionForModeSolid_SSE2;
#endif // SSE2
#if defined(__ARM_NEON__) && !defined(Q_OS_IOS)
@@ -6763,9 +6417,9 @@ void qInitDrawhelperAsm()
qDrawHelper[QImage::Format_RGB16].alphamapBlit = qt_alphamapblit_quint16_neon;
- functionForMode_C[QPainter::CompositionMode_SourceOver] = qt_blend_argb32_on_argb32_scanline_neon;
- functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_neon;
- functionForMode_C[QPainter::CompositionMode_Plus] = comp_func_Plus_neon;
+ qt_functionForMode_C[QPainter::CompositionMode_SourceOver] = qt_blend_argb32_on_argb32_scanline_neon;
+ qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_neon;
+ qt_functionForMode_C[QPainter::CompositionMode_Plus] = comp_func_Plus_neon;
destFetchProc[QImage::Format_RGB16] = qt_destFetchRGB16_neon;
destStoreProc[QImage::Format_RGB16] = qt_destStoreRGB16_neon;
@@ -6785,25 +6439,25 @@ void qInitDrawhelperAsm()
#if defined(QT_COMPILER_SUPPORTS_MIPS_DSP) || defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2)
if (features & (DSP | DSPR2)) {
// Composition functions are all DSP r1
- functionForMode_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_asm_mips_dsp;
- functionForMode_C[QPainter::CompositionMode_Source] = comp_func_Source_mips_dsp;
- functionForMode_C[QPainter::CompositionMode_DestinationOver] = comp_func_DestinationOver_mips_dsp;
- functionForMode_C[QPainter::CompositionMode_SourceIn] = comp_func_SourceIn_mips_dsp;
- functionForMode_C[QPainter::CompositionMode_DestinationIn] = comp_func_DestinationIn_mips_dsp;
- functionForMode_C[QPainter::CompositionMode_DestinationOut] = comp_func_DestinationOut_mips_dsp;
- functionForMode_C[QPainter::CompositionMode_SourceAtop] = comp_func_SourceAtop_mips_dsp;
- functionForMode_C[QPainter::CompositionMode_DestinationAtop] = comp_func_DestinationAtop_mips_dsp;
- functionForMode_C[QPainter::CompositionMode_Xor] = comp_func_XOR_mips_dsp;
- functionForMode_C[QPainter::CompositionMode_SourceOut] = comp_func_SourceOut_mips_dsp;
-
- functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_mips_dsp;
- functionForModeSolid_C[QPainter::CompositionMode_DestinationOver] = comp_func_solid_DestinationOver_mips_dsp;
- functionForModeSolid_C[QPainter::CompositionMode_SourceIn] = comp_func_solid_SourceIn_mips_dsp;
- functionForModeSolid_C[QPainter::CompositionMode_DestinationIn] = comp_func_solid_DestinationIn_mips_dsp;
- functionForModeSolid_C[QPainter::CompositionMode_SourceAtop] = comp_func_solid_SourceAtop_mips_dsp;
- functionForModeSolid_C[QPainter::CompositionMode_DestinationAtop] = comp_func_solid_DestinationAtop_mips_dsp;
- functionForModeSolid_C[QPainter::CompositionMode_Xor] = comp_func_solid_XOR_mips_dsp;
- functionForModeSolid_C[QPainter::CompositionMode_SourceOut] = comp_func_solid_SourceOut_mips_dsp;
+ qt_functionForMode_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_asm_mips_dsp;
+ qt_functionForMode_C[QPainter::CompositionMode_Source] = comp_func_Source_mips_dsp;
+ qt_functionForMode_C[QPainter::CompositionMode_DestinationOver] = comp_func_DestinationOver_mips_dsp;
+ qt_functionForMode_C[QPainter::CompositionMode_SourceIn] = comp_func_SourceIn_mips_dsp;
+ qt_functionForMode_C[QPainter::CompositionMode_DestinationIn] = comp_func_DestinationIn_mips_dsp;
+ qt_functionForMode_C[QPainter::CompositionMode_DestinationOut] = comp_func_DestinationOut_mips_dsp;
+ qt_functionForMode_C[QPainter::CompositionMode_SourceAtop] = comp_func_SourceAtop_mips_dsp;
+ qt_functionForMode_C[QPainter::CompositionMode_DestinationAtop] = comp_func_DestinationAtop_mips_dsp;
+ qt_functionForMode_C[QPainter::CompositionMode_Xor] = comp_func_XOR_mips_dsp;
+ qt_functionForMode_C[QPainter::CompositionMode_SourceOut] = comp_func_SourceOut_mips_dsp;
+
+ qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_mips_dsp;
+ qt_functionForModeSolid_C[QPainter::CompositionMode_DestinationOver] = comp_func_solid_DestinationOver_mips_dsp;
+ qt_functionForModeSolid_C[QPainter::CompositionMode_SourceIn] = comp_func_solid_SourceIn_mips_dsp;
+ qt_functionForModeSolid_C[QPainter::CompositionMode_DestinationIn] = comp_func_solid_DestinationIn_mips_dsp;
+ qt_functionForModeSolid_C[QPainter::CompositionMode_SourceAtop] = comp_func_solid_SourceAtop_mips_dsp;
+ qt_functionForModeSolid_C[QPainter::CompositionMode_DestinationAtop] = comp_func_solid_DestinationAtop_mips_dsp;
+ qt_functionForModeSolid_C[QPainter::CompositionMode_Xor] = comp_func_solid_XOR_mips_dsp;
+ qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOut] = comp_func_solid_SourceOut_mips_dsp;
qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_mips_dsp;
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_mips_dsp;
@@ -6830,20 +6484,6 @@ void qInitDrawhelperAsm()
#endif // QT_COMPILER_SUPPORTS_MIPS_DSPR2
}
#endif // QT_COMPILER_SUPPORTS_MIPS_DSP || QT_COMPILER_SUPPORTS_MIPS_DSPR2
-
- if (functionForModeSolidAsm) {
- const int destinationMode = QPainter::CompositionMode_Destination;
- functionForModeSolidAsm[destinationMode] = functionForModeSolid_C[destinationMode];
-
- // use the default qdrawhelper implementation for the
- // extended composition modes
- for (int mode = 12; mode < 24; ++mode)
- functionForModeSolidAsm[mode] = functionForModeSolid_C[mode];
-
- functionForModeSolid = functionForModeSolidAsm;
- }
- if (functionForModeAsm)
- functionForMode = functionForModeAsm;
}
QT_END_NAMESPACE
diff --git a/src/gui/painting/qdrawhelper_neon.cpp b/src/gui/painting/qdrawhelper_neon.cpp
index 7e12e62151..08e564f017 100644
--- a/src/gui/painting/qdrawhelper_neon.cpp
+++ b/src/gui/painting/qdrawhelper_neon.cpp
@@ -466,7 +466,7 @@ void qt_blend_rgb32_on_rgb32_neon(uchar *destPixels, int dbpl,
}
void qt_alphamapblit_quint16_neon(QRasterBuffer *rasterBuffer,
- int x, int y, quint32 color,
+ int x, int y, const QRgba64 &color,
const uchar *bitmap,
int mapWidth, int mapHeight, int mapStride,
const QClipData *)
@@ -475,8 +475,9 @@ void qt_alphamapblit_quint16_neon(QRasterBuffer *rasterBuffer,
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint16);
uchar *mask = const_cast<uchar *>(bitmap);
+ const uint c = color.toArgb32();
- pixman_composite_over_n_8_0565_asm_neon(mapWidth, mapHeight, dest, destStride, color, 0, mask, mapStride);
+ pixman_composite_over_n_8_0565_asm_neon(mapWidth, mapHeight, dest, destStride, c, 0, mask, mapStride);
}
extern "C" void blend_8_pixels_rgb16_on_rgb16_neon(quint16 *dst, const quint16 *src, int const_alpha);
@@ -985,7 +986,7 @@ public:
const uint * QT_FASTCALL qt_fetch_radial_gradient_neon(uint *buffer, const Operator *op, const QSpanData *data,
int y, int x, int length)
{
- return qt_fetch_radial_gradient_template<QRadialFetchSimd<QSimdNeon> >(buffer, op, data, y, x, length);
+ return qt_fetch_radial_gradient_template<QRadialFetchSimd<QSimdNeon>,uint>(buffer, op, data, y, x, length);
}
QT_END_NAMESPACE
diff --git a/src/gui/painting/qdrawhelper_neon_p.h b/src/gui/painting/qdrawhelper_neon_p.h
index bd030a8bf3..37e060f147 100644
--- a/src/gui/painting/qdrawhelper_neon_p.h
+++ b/src/gui/painting/qdrawhelper_neon_p.h
@@ -82,7 +82,7 @@ void qt_blend_rgb16_on_rgb16_neon(uchar *destPixels, int dbpl,
int const_alpha);
void qt_alphamapblit_quint16_neon(QRasterBuffer *rasterBuffer,
- int x, int y, quint32 color,
+ int x, int y, const QRgba64 &color,
const uchar *bitmap,
int mapWidth, int mapHeight, int mapStride,
const QClipData *clip);
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index 73ff21812a..2c222b97c2 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -50,6 +50,7 @@
#include "QtGui/qcolor.h"
#include "QtGui/qpainter.h"
#include "QtGui/qimage.h"
+#include "QtGui/qrgba64.h"
#ifndef QT_FT_BEGIN_HEADER
#define QT_FT_BEGIN_HEADER
#define QT_FT_END_HEADER
@@ -99,25 +100,25 @@ class QRasterPaintEngineState;
typedef QT_FT_SpanFunc ProcessSpans;
typedef void (*BitmapBlitFunc)(QRasterBuffer *rasterBuffer,
- int x, int y, quint32 color,
+ int x, int y, const QRgba64 &color,
const uchar *bitmap,
int mapWidth, int mapHeight, int mapStride);
typedef void (*AlphamapBlitFunc)(QRasterBuffer *rasterBuffer,
- int x, int y, quint32 color,
+ int x, int y, const QRgba64 &color,
const uchar *bitmap,
int mapWidth, int mapHeight, int mapStride,
const QClipData *clip);
typedef void (*AlphaRGBBlitFunc)(QRasterBuffer *rasterBuffer,
- int x, int y, quint32 color,
+ int x, int y, const QRgba64 &color,
const uint *rgbmask,
int mapWidth, int mapHeight, int mapStride,
const QClipData *clip);
typedef void (*RectFillFunc)(QRasterBuffer *rasterBuffer,
int x, int y, int width, int height,
- quint32 color);
+ const QRgba64 &color);
typedef void (*SrcOverBlendFunc)(uchar *destPixels, int dbpl,
const uchar *src, int spbl,
@@ -158,11 +159,14 @@ extern MemRotateFunc qMemRotateFunctions[QImage::NImageFormats][3];
extern DrawHelper qDrawHelper[QImage::NImageFormats];
void qBlendTexture(int count, const QSpan *spans, void *userData);
+extern void qt_memfill64(quint64 *dest, quint64 value, int count);
extern void qt_memfill32(quint32 *dest, quint32 value, int count);
extern void qt_memfill16(quint16 *dest, quint16 value, int count);
typedef void (QT_FASTCALL *CompositionFunction)(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha);
+typedef void (QT_FASTCALL *CompositionFunction64)(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha);
typedef void (QT_FASTCALL *CompositionFunctionSolid)(uint *dest, int length, uint color, uint const_alpha);
+typedef void (QT_FASTCALL *CompositionFunctionSolid64)(QRgba64 *dest, int length, QRgba64 color, uint const_alpha);
struct LinearGradientValues
{
@@ -185,17 +189,27 @@ struct RadialGradientValues
struct Operator;
typedef uint* (QT_FASTCALL *DestFetchProc)(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length);
+typedef QRgba64* (QT_FASTCALL *DestFetchProc64)(QRgba64 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length);
typedef void (QT_FASTCALL *DestStoreProc)(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length);
+typedef void (QT_FASTCALL *DestStoreProc64)(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length);
typedef const uint* (QT_FASTCALL *SourceFetchProc)(uint *buffer, const Operator *o, const QSpanData *data, int y, int x, int length);
+typedef const QRgba64* (QT_FASTCALL *SourceFetchProc64)(QRgba64 *buffer, const Operator *o, const QSpanData *data, int y, int x, int length);
struct Operator
{
QPainter::CompositionMode mode;
- DestFetchProc dest_fetch;
- DestStoreProc dest_store;
- SourceFetchProc src_fetch;
+ DestFetchProc destFetch;
+ DestStoreProc destStore;
+ SourceFetchProc srcFetch;
CompositionFunctionSolid funcSolid;
CompositionFunction func;
+
+ DestFetchProc64 destFetch64;
+ DestStoreProc64 destStore64;
+ SourceFetchProc64 srcFetch64;
+ CompositionFunctionSolid64 funcSolid64;
+ CompositionFunction64 func64;
+
union {
LinearGradientValues linear;
RadialGradientValues radial;
@@ -208,7 +222,7 @@ class QRasterPaintEngine;
struct QSolidData
{
- uint color;
+ QRgba64 color;
};
struct QLinearGradientData
@@ -259,7 +273,7 @@ struct QGradientData
#define GRADIENT_STOPTABLE_SIZE 1024
#define GRADIENT_STOPTABLE_SIZE_SHIFT 10
- uint* colorTable; //[GRADIENT_STOPTABLE_SIZE];
+ QRgba64* colorTable; //[GRADIENT_STOPTABLE_SIZE];
uint alphaColor : 1;
};
@@ -367,6 +381,12 @@ static inline uint qt_gradient_clamp(const QGradientData *data, int ipos)
static inline uint qt_gradient_pixel(const QGradientData *data, qreal pos)
{
int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + qreal(0.5));
+ return data->colorTable[qt_gradient_clamp(data, ipos)].toArgb32();
+}
+
+static inline const QRgba64& qt_gradient_pixel64(const QGradientData *data, qreal pos)
+{
+ int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + qreal(0.5));
return data->colorTable[qt_gradient_clamp(data, ipos)];
}
@@ -375,24 +395,24 @@ static inline qreal qRadialDeterminant(qreal a, qreal b, qreal c)
return (b * b) - (4 * a * c);
}
-template <class RadialFetchFunc> Q_STATIC_TEMPLATE_FUNCTION
-const uint * QT_FASTCALL qt_fetch_radial_gradient_template(uint *buffer, const Operator *op, const QSpanData *data,
- int y, int x, int length)
+template <class RadialFetchFunc, typename BlendType> static
+const BlendType * QT_FASTCALL qt_fetch_radial_gradient_template(BlendType *buffer, const Operator *op,
+ const QSpanData *data, int y, int x, int length)
{
// avoid division by zero
if (qFuzzyIsNull(op->radial.a)) {
- qt_memfill32(buffer, 0, length);
+ RadialFetchFunc::memfill(buffer, RadialFetchFunc::null(), length);
return buffer;
}
- const uint *b = buffer;
+ const BlendType *b = buffer;
qreal rx = data->m21 * (y + qreal(0.5))
+ data->dx + data->m11 * (x + qreal(0.5));
qreal ry = data->m22 * (y + qreal(0.5))
+ data->dy + data->m12 * (x + qreal(0.5));
bool affine = !data->m13 && !data->m23;
- uint *end = buffer + length;
+ BlendType *end = buffer + length;
if (affine) {
rx -= data->gradient.radial.focal.x;
ry -= data->gradient.radial.focal.y;
@@ -439,7 +459,7 @@ const uint * QT_FASTCALL qt_fetch_radial_gradient_template(uint *buffer, const O
qreal b = 2*(op->radial.dr*data->gradient.radial.focal.radius + gx*op->radial.dx + gy*op->radial.dy);
qreal det = qRadialDeterminant(op->radial.a, b, op->radial.sqrfr - (gx*gx + gy*gy));
- quint32 result = 0;
+ BlendType result = RadialFetchFunc::null();
if (det >= 0) {
qreal detSqrt = qSqrt(det);
@@ -449,7 +469,7 @@ const uint * QT_FASTCALL qt_fetch_radial_gradient_template(uint *buffer, const O
qreal s = qMax(s0, s1);
if (data->gradient.radial.focal.radius + op->radial.dr * s >= 0)
- result = qt_gradient_pixel(&data->gradient, s);
+ result = RadialFetchFunc::fetchSingle(data->gradient, s);
}
*buffer = result;
@@ -470,6 +490,15 @@ template <class Simd>
class QRadialFetchSimd
{
public:
+ static uint null() { return 0; }
+ static uint fetchSingle(const QGradientData& gradient, qreal v)
+ {
+ return qt_gradient_pixel(&gradient, v);
+ }
+ static void memfill(uint *buffer, uint fill, int length)
+ {
+ qt_memfill32(buffer, fill, length);
+ }
static void fetch(uint *buffer, uint *end, const Operator *op, const QSpanData *data, qreal det,
qreal delta_det, qreal delta_delta_det, qreal b, qreal delta_b)
{
@@ -526,7 +555,7 @@ public:
delta_det4_vec.v = Simd::v_add(delta_det4_vec.v, v_delta_delta_det16); \
b_vec.v = Simd::v_add(b_vec.v, v_delta_b4); \
for (int i = 0; i < 4; ++i) \
- *buffer++ = (extended_mask | v_buffer_mask.i[i]) & data->gradient.colorTable[index_vec.i[i]]; \
+ *buffer++ = (extended_mask | v_buffer_mask.i[i]) & data->gradient.colorTable[index_vec.i[i]].toArgb32(); \
}
#define FETCH_RADIAL_LOOP(FETCH_RADIAL_LOOP_CLAMP) \
@@ -680,7 +709,8 @@ static Q_ALWAYS_INLINE uint BYTE_MUL_RGB16_32(uint x, uint a) {
return t;
}
-static Q_ALWAYS_INLINE int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; }
+static Q_DECL_CONSTEXPR Q_ALWAYS_INLINE int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; }
+static Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_div_65535(uint x) { return (x + (x>>16) + 0x8000U) >> 16; }
static Q_ALWAYS_INLINE uint BYTE_MUL_RGB30(uint x, uint a) {
uint xa = x >> 30;
@@ -723,6 +753,11 @@ inline quint24::operator uint() const
template <class T> Q_STATIC_TEMPLATE_FUNCTION
void qt_memfill(T *dest, T value, int count);
+template<> inline void qt_memfill(quint64 *dest, quint64 color, int count)
+{
+ qt_memfill64(dest, color, count);
+}
+
template<> inline void qt_memfill(quint32 *dest, quint32 color, int count)
{
qt_memfill32(dest, color, count);
@@ -924,6 +959,64 @@ inline QRgb qConvertA2rgb30ToArgb32<PixelOrderRGB>(uint c)
| ((c >> 2) & 0x000000ff);
}
+template<enum QtPixelOrder> inline QRgba64 qConvertA2rgb30ToRgb64(uint rgb);
+
+template<>
+inline QRgba64 qConvertA2rgb30ToRgb64<PixelOrderBGR>(uint rgb)
+{
+ quint16 alpha = rgb >> 30;
+ quint16 blue = (rgb >> 20) & 0x3ff;
+ quint16 green = (rgb >> 10) & 0x3ff;
+ quint16 red = rgb & 0x3ff;
+ // Expand the range.
+ alpha |= (alpha << 2);
+ alpha |= (alpha << 4);
+ alpha |= (alpha << 8);
+ red = (red << 6) | (red >> 4);
+ green = (green << 6) | (green >> 4);
+ blue = (blue << 6) | (blue >> 4);
+ return qRgba64(red, green, blue, alpha);
+}
+
+template<>
+inline QRgba64 qConvertA2rgb30ToRgb64<PixelOrderRGB>(uint rgb)
+{
+ quint16 alpha = rgb >> 30;
+ quint16 red = (rgb >> 20) & 0x3ff;
+ quint16 green = (rgb >> 10) & 0x3ff;
+ quint16 blue = rgb & 0x3ff;
+ // Expand the range.
+ alpha |= (alpha << 2);
+ alpha |= (alpha << 4);
+ alpha |= (alpha << 8);
+ red = (red << 6) | (red >> 4);
+ green = (green << 6) | (green >> 4);
+ blue = (blue << 6) | (blue >> 4);
+ return qRgba64(red, green, blue, alpha);
+}
+
+template<enum QtPixelOrder> inline unsigned int qConvertRgb64ToRgb30(QRgba64);
+
+template<>
+inline unsigned int qConvertRgb64ToRgb30<PixelOrderBGR>(QRgba64 c)
+{
+ const uint a = c.alpha() >> 14;
+ const uint r = c.red() >> 6;
+ const uint g = c.green() >> 6;
+ const uint b = c.blue() >> 6;
+ return (a << 30) | (b << 20) | (g << 10) | r;
+}
+
+template<>
+inline unsigned int qConvertRgb64ToRgb30<PixelOrderRGB>(QRgba64 c)
+{
+ const uint a = c.alpha() >> 14;
+ const uint r = c.red() >> 6;
+ const uint g = c.green() >> 6;
+ const uint b = c.blue() >> 6;
+ return (a << 30) | (r << 20) | (g << 10) | b;
+}
+
inline uint qRgbSwapRgb30(uint c)
{
const uint ag = c & 0xc00ffc00;
@@ -1025,89 +1118,11 @@ inline int comp_func_Plus_one_pixel(uint d, const uint s)
#undef MIX
#undef AMIX
-// prototypes of all the composition functions
-void QT_FASTCALL comp_func_SourceOver(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_DestinationOver(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha);
-void QT_FASTCALL comp_func_Source(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_Destination(uint *, const uint *, int, uint);
-void QT_FASTCALL comp_func_SourceIn(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_DestinationIn(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_SourceOut(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_DestinationOut(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_SourceAtop(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_DestinationAtop(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_XOR(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_Plus(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_Multiply(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_Screen(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_Overlay(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_Darken(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_Lighten(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_ColorDodge(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_ColorBurn(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_HardLight(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_SoftLight(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_Difference(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL comp_func_Exclusion(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_SourceOrDestination(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_SourceAndDestination(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_SourceXorDestination(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_NotSourceAndNotDestination(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_NotSourceOrNotDestination(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_NotSourceXorDestination(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_NotSource(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_NotSourceAndDestination(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_SourceAndNotDestination(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_NotSourceOrDestination(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_SourceOrNotDestination(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_ClearDestination(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_SetDestination(uint *dest, const uint *src, int length, uint const_alpha);
-void QT_FASTCALL rasterop_NotDestination(uint *dest, const uint *src, int length, uint const_alpha);
-// prototypes of all the solid composition functions
-void QT_FASTCALL comp_func_solid_SourceOver(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_Source(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_Destination(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_SourceIn(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_DestinationIn(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_SourceOut(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_DestinationOut(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_SourceAtop(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_DestinationAtop(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_XOR(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_Plus(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_Multiply(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_Screen(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_Overlay(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_Darken(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_Lighten(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_ColorDodge(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_ColorBurn(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_HardLight(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_SoftLight(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_Difference(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL comp_func_solid_Exclusion(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_SourceOrDestination(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_SourceAndDestination(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_SourceXorDestination(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_NotSourceAndNotDestination(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_NotSourceOrNotDestination(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_NotSourceXorDestination(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_NotSource(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_NotSourceAndDestination(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_SourceAndNotDestination(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_NotSourceOrDestination(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_SourceOrNotDestination(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_ClearDestination(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_SetDestination(uint *dest, int length, uint color, uint const_alpha);
-void QT_FASTCALL rasterop_solid_NotDestination(uint *dest, int length, uint color, uint const_alpha);
-
-
struct QPixelLayout;
typedef const uint *(QT_FASTCALL *ConvertFunc)(uint *buffer, const uint *src, int count,
const QPixelLayout *layout, const QRgb *clut);
+typedef const QRgba64 *(QT_FASTCALL *ConvertFunc64)(QRgba64 *buffer, const uint *src, int count,
+ const QPixelLayout *layout, const QRgb *clut);
struct QPixelLayout
{
@@ -1137,6 +1152,7 @@ struct QPixelLayout
ConvertFunc convertToARGB32PM;
ConvertFunc convertFromARGB32PM;
ConvertFunc convertFromRGB32;
+ ConvertFunc64 convertToARGB64PM;
};
typedef const uint *(QT_FASTCALL *FetchPixelsFunc)(uint *buffer, const uchar *src, int index, int count);
diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp
index 84eb3b7909..d7f3686e54 100644
--- a/src/gui/painting/qdrawhelper_sse2.cpp
+++ b/src/gui/painting/qdrawhelper_sse2.cpp
@@ -311,90 +311,6 @@ void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, u
}
}
-#ifndef QDRAWHELPER_AVX
-CompositionFunctionSolid qt_functionForModeSolid_SSE2[numCompositionFunctions] = {
- comp_func_solid_SourceOver_sse2,
- comp_func_solid_DestinationOver,
- comp_func_solid_Clear,
- comp_func_solid_Source,
- comp_func_solid_Destination,
- comp_func_solid_SourceIn,
- comp_func_solid_DestinationIn,
- comp_func_solid_SourceOut,
- comp_func_solid_DestinationOut,
- comp_func_solid_SourceAtop,
- comp_func_solid_DestinationAtop,
- comp_func_solid_XOR,
- comp_func_solid_Plus,
- comp_func_solid_Multiply,
- comp_func_solid_Screen,
- comp_func_solid_Overlay,
- comp_func_solid_Darken,
- comp_func_solid_Lighten,
- comp_func_solid_ColorDodge,
- comp_func_solid_ColorBurn,
- comp_func_solid_HardLight,
- comp_func_solid_SoftLight,
- comp_func_solid_Difference,
- comp_func_solid_Exclusion,
- rasterop_solid_SourceOrDestination,
- rasterop_solid_SourceAndDestination,
- rasterop_solid_SourceXorDestination,
- rasterop_solid_NotSourceAndNotDestination,
- rasterop_solid_NotSourceOrNotDestination,
- rasterop_solid_NotSourceXorDestination,
- rasterop_solid_NotSource,
- rasterop_solid_NotSourceAndDestination,
- rasterop_solid_SourceAndNotDestination,
- rasterop_solid_NotSourceOrDestination,
- rasterop_solid_SourceOrNotDestination,
- rasterop_solid_ClearDestination,
- rasterop_solid_SetDestination,
- rasterop_solid_NotDestination
-};
-
-CompositionFunction qt_functionForMode_SSE2[numCompositionFunctions] = {
- comp_func_SourceOver_sse2,
- comp_func_DestinationOver,
- comp_func_Clear,
- comp_func_Source_sse2,
- comp_func_Destination,
- comp_func_SourceIn,
- comp_func_DestinationIn,
- comp_func_SourceOut,
- comp_func_DestinationOut,
- comp_func_SourceAtop,
- comp_func_DestinationAtop,
- comp_func_XOR,
- comp_func_Plus_sse2,
- comp_func_Multiply,
- comp_func_Screen,
- comp_func_Overlay,
- comp_func_Darken,
- comp_func_Lighten,
- comp_func_ColorDodge,
- comp_func_ColorBurn,
- comp_func_HardLight,
- comp_func_SoftLight,
- comp_func_Difference,
- comp_func_Exclusion,
- rasterop_SourceOrDestination,
- rasterop_SourceAndDestination,
- rasterop_SourceXorDestination,
- rasterop_NotSourceAndNotDestination,
- rasterop_NotSourceOrNotDestination,
- rasterop_NotSourceXorDestination,
- rasterop_NotSource,
- rasterop_NotSourceAndDestination,
- rasterop_SourceAndNotDestination,
- rasterop_NotSourceOrDestination,
- rasterop_SourceOrNotDestination,
- rasterop_ClearDestination,
- rasterop_SetDestination,
- rasterop_NotDestination
-};
-#endif
-
void qt_memfill16(quint16 *dest, quint16 value, int count)
{
if (count < 3) {
@@ -417,7 +333,7 @@ void qt_memfill16(quint16 *dest, quint16 value, int count)
dest[count - 1] = value;
}
-void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y,
+void qt_bitmapblit32_sse2_base(QRasterBuffer *rasterBuffer, int x, int y,
quint32 color,
const uchar *src, int width, int height, int stride)
{
@@ -468,18 +384,25 @@ void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y,
}
}
+void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y,
+ const QRgba64 &color,
+ const uchar *src, int width, int height, int stride)
+{
+ qt_bitmapblit32_sse2_base(rasterBuffer, x, y, color.toArgb32(), src, width, height, stride);
+}
+
void qt_bitmapblit8888_sse2(QRasterBuffer *rasterBuffer, int x, int y,
- quint32 color,
+ const QRgba64 &color,
const uchar *src, int width, int height, int stride)
{
- qt_bitmapblit32_sse2(rasterBuffer, x, y, ARGB2RGBA(color), src, width, height, stride);
+ qt_bitmapblit32_sse2_base(rasterBuffer, x, y, ARGB2RGBA(color.toArgb32()), src, width, height, stride);
}
void qt_bitmapblit16_sse2(QRasterBuffer *rasterBuffer, int x, int y,
- quint32 color,
+ const QRgba64 &color,
const uchar *src, int width, int height, int stride)
{
- const quint16 c = qConvertRgb32To16(color);
+ const quint16 c = qConvertRgb32To16(color.toArgb32());
quint16 *dest = reinterpret_cast<quint16*>(rasterBuffer->scanLine(y)) + x;
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint16);
@@ -543,7 +466,7 @@ public:
const uint * QT_FASTCALL qt_fetch_radial_gradient_sse2(uint *buffer, const Operator *op, const QSpanData *data,
int y, int x, int length)
{
- return qt_fetch_radial_gradient_template<QRadialFetchSimd<QSimdSse2> >(buffer, op, data, y, x, length);
+ return qt_fetch_radial_gradient_template<QRadialFetchSimd<QSimdSse2>,uint>(buffer, op, data, y, x, length);
}
void qt_scale_image_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
diff --git a/src/gui/painting/qdrawhelper_x86_p.h b/src/gui/painting/qdrawhelper_x86_p.h
index 4d203c4f9d..50ee83aa2c 100644
--- a/src/gui/painting/qdrawhelper_x86_p.h
+++ b/src/gui/painting/qdrawhelper_x86_p.h
@@ -53,13 +53,13 @@ QT_BEGIN_NAMESPACE
void qt_memfill32(quint32 *dest, quint32 value, int count);
void qt_memfill16(quint16 *dest, quint16 value, int count);
void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y,
- quint32 color,
+ const QRgba64 &color,
const uchar *src, int width, int height, int stride);
void qt_bitmapblit8888_sse2(QRasterBuffer *rasterBuffer, int x, int y,
- quint32 color,
+ const QRgba64 &color,
const uchar *src, int width, int height, int stride);
void qt_bitmapblit16_sse2(QRasterBuffer *rasterBuffer, int x, int y,
- quint32 color,
+ const QRgba64 &color,
const uchar *src, int width, int height, int stride);
void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
const uchar *srcPixels, int sbpl,
diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp
index 867c64c5e0..7b6a71737d 100644
--- a/src/gui/painting/qimagescale.cpp
+++ b/src/gui/painting/qimagescale.cpp
@@ -77,8 +77,9 @@ QT_BEGIN_NAMESPACE
*
* Changes include formatting, namespaces and other C++'ings, removal of old
* #ifdef'ed code, and removal of unneeded border calculation code.
- * Later the code has been refactored and an SSE4.1 optimizated path have been
- * added instead of the removed MMX assembler.
+ * Later the code has been refactored, an SSE4.1 optimizated path have been
+ * added instead of the removed MMX assembler, and scaling of clipped area
+ * removed.
*
* Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code
* is by Willem Monsuwe <willem@stack.nl>. All other modifications are
@@ -256,34 +257,27 @@ QImageScaleInfo* QImageScale::qimageCalcScaleInfo(const QImage &img,
static void qt_qimageScaleAARGBA_up_x_down_y(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow);
static void qt_qimageScaleAARGBA_down_x_up_y(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow);
static void qt_qimageScaleAARGBA_down_xy(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow);
+ int dw, int dh, int dow, int sow);
#if defined(QT_COMPILER_SUPPORTS_SSE4_1)
template<bool RGB>
void qt_qimageScaleAARGBA_up_x_down_y_sse4(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow);
template<bool RGB>
void qt_qimageScaleAARGBA_down_x_up_y_sse4(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow);
template<bool RGB>
void qt_qimageScaleAARGBA_down_xy_sse4(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow);
#endif
static void qt_qimageScaleAARGBA_up_xy(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow)
{
const unsigned int **ypoints = isi->ypoints;
@@ -291,15 +285,14 @@ static void qt_qimageScaleAARGBA_up_xy(QImageScaleInfo *isi, unsigned int *dest,
int *xapoints = isi->xapoints;
int *yapoints = isi->yapoints;
- int end = dxx + dw;
/* go through every scanline in the output buffer */
for (int y = 0; y < dh; y++) {
/* calculate the source line we'll scan from */
- const unsigned int *sptr = ypoints[dyy + y];
- unsigned int *dptr = dest + dx + ((y + dy) * dow);
- const int yap = yapoints[dyy + y];
+ const unsigned int *sptr = ypoints[y];
+ unsigned int *dptr = dest + (y * dow);
+ const int yap = yapoints[y];
if (yap > 0) {
- for (int x = dxx; x < end; x++) {
+ for (int x = 0; x < dw; x++) {
const unsigned int *pix = sptr + xpoints[x];
const int xap = xapoints[x];
if (xap > 0)
@@ -309,7 +302,7 @@ static void qt_qimageScaleAARGBA_up_xy(QImageScaleInfo *isi, unsigned int *dest,
dptr++;
}
} else {
- for (int x = dxx; x < end; x++) {
+ for (int x = 0; x < dw; x++) {
const unsigned int *pix = sptr + xpoints[x];
const int xap = xapoints[x];
*dptr = INTERPOLATE_PIXEL_256(pix[0], 256 - xap, pix[1], xap);
@@ -321,39 +314,38 @@ static void qt_qimageScaleAARGBA_up_xy(QImageScaleInfo *isi, unsigned int *dest,
/* scale by area sampling */
static void qt_qimageScaleAARGBA(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow)
+ int dw, int dh, int dow, int sow)
{
/* scaling up both ways */
if (isi->xup_yup == 3) {
- qt_qimageScaleAARGBA_up_xy(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGBA_up_xy(isi, dest, dw, dh, dow, sow);
}
/* if we're scaling down vertically */
else if (isi->xup_yup == 1) {
#ifdef QT_COMPILER_SUPPORTS_SSE4_1
if (qCpuHasFeature(SSE4_1))
- qt_qimageScaleAARGBA_up_x_down_y_sse4<false>(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGBA_up_x_down_y_sse4<false>(isi, dest, dw, dh, dow, sow);
else
#endif
- qt_qimageScaleAARGBA_up_x_down_y(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGBA_up_x_down_y(isi, dest, dw, dh, dow, sow);
}
/* if we're scaling down horizontally */
else if (isi->xup_yup == 2) {
#ifdef QT_COMPILER_SUPPORTS_SSE4_1
if (qCpuHasFeature(SSE4_1))
- qt_qimageScaleAARGBA_down_x_up_y_sse4<false>(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGBA_down_x_up_y_sse4<false>(isi, dest, dw, dh, dow, sow);
else
#endif
- qt_qimageScaleAARGBA_down_x_up_y(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGBA_down_x_up_y(isi, dest, dw, dh, dow, sow);
}
/* if we're scaling down horizontally & vertically */
else {
#ifdef QT_COMPILER_SUPPORTS_SSE4_1
if (qCpuHasFeature(SSE4_1))
- qt_qimageScaleAARGBA_down_xy_sse4<false>(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGBA_down_xy_sse4<false>(isi, dest, dw, dh, dow, sow);
else
#endif
- qt_qimageScaleAARGBA_down_xy(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGBA_down_xy(isi, dest, dw, dh, dow, sow);
}
}
@@ -379,7 +371,6 @@ inline static void qt_qimageScaleAARGBA_helper(const unsigned int *pix, int xyap
}
static void qt_qimageScaleAARGBA_up_x_down_y(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow)
{
const unsigned int **ypoints = isi->ypoints;
@@ -387,16 +378,14 @@ static void qt_qimageScaleAARGBA_up_x_down_y(QImageScaleInfo *isi, unsigned int
int *xapoints = isi->xapoints;
int *yapoints = isi->yapoints;
- int end = dxx + dw;
-
/* go through every scanline in the output buffer */
for (int y = 0; y < dh; y++) {
- int Cy = (yapoints[dyy + y]) >> 16;
- int yap = (yapoints[dyy + y]) & 0xffff;
+ int Cy = yapoints[y] >> 16;
+ int yap = yapoints[y] & 0xffff;
- unsigned int *dptr = dest + dx + ((y + dy) * dow);
- for (int x = dxx; x < end; x++) {
- const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
+ unsigned int *dptr = dest + (y * dow);
+ for (int x = 0; x < dw; x++) {
+ const unsigned int *sptr = ypoints[y] + xpoints[x];
int r, g, b, a;
qt_qimageScaleAARGBA_helper(sptr, yap, Cy, sow, r, g, b, a);
@@ -420,7 +409,6 @@ static void qt_qimageScaleAARGBA_up_x_down_y(QImageScaleInfo *isi, unsigned int
}
static void qt_qimageScaleAARGBA_down_x_up_y(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow)
{
const unsigned int **ypoints = isi->ypoints;
@@ -428,20 +416,18 @@ static void qt_qimageScaleAARGBA_down_x_up_y(QImageScaleInfo *isi, unsigned int
int *xapoints = isi->xapoints;
int *yapoints = isi->yapoints;
- int end = dxx + dw;
-
/* go through every scanline in the output buffer */
for (int y = 0; y < dh; y++) {
- unsigned int *dptr = dest + dx + ((y + dy) * dow);
- for (int x = dxx; x < end; x++) {
+ unsigned int *dptr = dest + (y * dow);
+ for (int x = 0; x < dw; x++) {
int Cx = xapoints[x] >> 16;
int xap = xapoints[x] & 0xffff;
- const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
+ const unsigned int *sptr = ypoints[y] + xpoints[x];
int r, g, b, a;
qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, r, g, b, a);
- int yap = yapoints[dyy + y];
+ int yap = yapoints[y];
if (yap > 0) {
int rr, gg, bb, aa;
qt_qimageScaleAARGBA_helper(sptr + sow, xap, Cx, 1, rr, gg, bb, aa);
@@ -462,26 +448,23 @@ static void qt_qimageScaleAARGBA_down_x_up_y(QImageScaleInfo *isi, unsigned int
}
static void qt_qimageScaleAARGBA_down_xy(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow)
+ int dw, int dh, int dow, int sow)
{
const unsigned int **ypoints = isi->ypoints;
int *xpoints = isi->xpoints;
int *xapoints = isi->xapoints;
int *yapoints = isi->yapoints;
- int end = dxx + dw;
-
for (int y = 0; y < dh; y++) {
- int Cy = (yapoints[dyy + y]) >> 16;
- int yap = (yapoints[dyy + y]) & 0xffff;
+ int Cy = (yapoints[y]) >> 16;
+ int yap = (yapoints[y]) & 0xffff;
- unsigned int *dptr = dest + dx + ((y + dy) * dow);
- for (int x = dxx; x < end; x++) {
+ unsigned int *dptr = dest + (y * dow);
+ for (int x = 0; x < dw; x++) {
int Cx = xapoints[x] >> 16;
int xap = xapoints[x] & 0xffff;
- const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
+ const unsigned int *sptr = ypoints[y] + xpoints[x];
int rx, gx, bx, ax;
qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, rx, gx, bx, ax);
@@ -514,52 +497,48 @@ static void qt_qimageScaleAARGBA_down_xy(QImageScaleInfo *isi, unsigned int *des
}
static void qt_qimageScaleAARGB_up_x_down_y(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow);
+ int dw, int dh, int dow, int sow);
static void qt_qimageScaleAARGB_down_x_up_y(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow);
+ int dw, int dh, int dow, int sow);
static void qt_qimageScaleAARGB_down_xy(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow);
+ int dw, int dh, int dow, int sow);
/* scale by area sampling - IGNORE the ALPHA byte*/
static void qt_qimageScaleAARGB(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow)
{
/* scaling up both ways */
if (isi->xup_yup == 3) {
- qt_qimageScaleAARGBA_up_xy(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGBA_up_xy(isi, dest, dw, dh, dow, sow);
}
/* if we're scaling down vertically */
else if (isi->xup_yup == 1) {
#ifdef QT_COMPILER_SUPPORTS_SSE4_1
if (qCpuHasFeature(SSE4_1))
- qt_qimageScaleAARGBA_up_x_down_y_sse4<true>(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGBA_up_x_down_y_sse4<true>(isi, dest, dw, dh, dow, sow);
else
#endif
- qt_qimageScaleAARGB_up_x_down_y(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGB_up_x_down_y(isi, dest, dw, dh, dow, sow);
}
/* if we're scaling down horizontally */
else if (isi->xup_yup == 2) {
#ifdef QT_COMPILER_SUPPORTS_SSE4_1
if (qCpuHasFeature(SSE4_1))
- qt_qimageScaleAARGBA_down_x_up_y_sse4<true>(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGBA_down_x_up_y_sse4<true>(isi, dest, dw, dh, dow, sow);
else
#endif
- qt_qimageScaleAARGB_down_x_up_y(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGB_down_x_up_y(isi, dest, dw, dh, dow, sow);
}
/* if we're scaling down horizontally & vertically */
else {
#ifdef QT_COMPILER_SUPPORTS_SSE4_1
if (qCpuHasFeature(SSE4_1))
- qt_qimageScaleAARGBA_down_xy_sse4<true>(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGBA_down_xy_sse4<true>(isi, dest, dw, dh, dow, sow);
else
#endif
- qt_qimageScaleAARGB_down_xy(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
+ qt_qimageScaleAARGB_down_xy(isi, dest, dw, dh, dow, sow);
}
}
@@ -583,24 +562,21 @@ inline static void qt_qimageScaleAARGB_helper(const unsigned int *pix, int xyap,
}
static void qt_qimageScaleAARGB_up_x_down_y(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow)
+ int dw, int dh, int dow, int sow)
{
const unsigned int **ypoints = isi->ypoints;
int *xpoints = isi->xpoints;
int *xapoints = isi->xapoints;
int *yapoints = isi->yapoints;
- int end = dxx + dw;
-
/* go through every scanline in the output buffer */
for (int y = 0; y < dh; y++) {
- int Cy = (yapoints[dyy + y]) >> 16;
- int yap = (yapoints[dyy + y]) & 0xffff;
+ int Cy = yapoints[y] >> 16;
+ int yap = yapoints[y] & 0xffff;
- unsigned int *dptr = dest + dx + ((y + dy) * dow);
- for (int x = dxx; x < end; x++) {
- const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
+ unsigned int *dptr = dest + (y * dow);
+ for (int x = 0; x < dw; x++) {
+ const unsigned int *sptr = ypoints[y] + xpoints[x];
int r, g, b;
qt_qimageScaleAARGB_helper(sptr, yap, Cy, sow, r, g, b);
@@ -622,28 +598,25 @@ static void qt_qimageScaleAARGB_up_x_down_y(QImageScaleInfo *isi, unsigned int *
}
static void qt_qimageScaleAARGB_down_x_up_y(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow)
+ int dw, int dh, int dow, int sow)
{
const unsigned int **ypoints = isi->ypoints;
int *xpoints = isi->xpoints;
int *xapoints = isi->xapoints;
int *yapoints = isi->yapoints;
- int end = dxx + dw;
-
/* go through every scanline in the output buffer */
for (int y = 0; y < dh; y++) {
- unsigned int *dptr = dest + dx + ((y + dy) * dow);
- for (int x = dxx; x < end; x++) {
+ unsigned int *dptr = dest + (y * dow);
+ for (int x = 0; x < dw; x++) {
int Cx = xapoints[x] >> 16;
int xap = xapoints[x] & 0xffff;
- const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
+ const unsigned int *sptr = ypoints[y] + xpoints[x];
int r, g, b;
qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, r, g, b);
- int yap = yapoints[dyy + y];
+ int yap = yapoints[y];
if (yap > 0) {
int rr, bb, gg;
qt_qimageScaleAARGB_helper(sptr + sow, xap, Cx, 1, rr, gg, bb);
@@ -661,26 +634,23 @@ static void qt_qimageScaleAARGB_down_x_up_y(QImageScaleInfo *isi, unsigned int *
}
static void qt_qimageScaleAARGB_down_xy(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow)
+ int dw, int dh, int dow, int sow)
{
const unsigned int **ypoints = isi->ypoints;
int *xpoints = isi->xpoints;
int *xapoints = isi->xapoints;
int *yapoints = isi->yapoints;
- int end = dxx + dw;
-
for (int y = 0; y < dh; y++) {
- int Cy = (yapoints[dyy + y]) >> 16;
- int yap = (yapoints[dyy + y]) & 0xffff;
+ int Cy = yapoints[y] >> 16;
+ int yap = yapoints[y] & 0xffff;
- unsigned int *dptr = dest + dx + ((y + dy) * dow);
- for (int x = dxx; x < end; x++) {
+ unsigned int *dptr = dest + (y * dow);
+ for (int x = 0; x < dw; x++) {
int Cx = xapoints[x] >> 16;
int xap = xapoints[x] & 0xffff;
- const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
+ const unsigned int *sptr = ypoints[y] + xpoints[x];
int rx, gx, bx;
qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, rx, gx, bx);
@@ -732,10 +702,10 @@ QImage qSmoothScaleImage(const QImage &src, int dw, int dh)
if (src.hasAlphaChannel())
qt_qimageScaleAARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0),
- 0, 0, 0, 0, dw, dh, dw, src.bytesPerLine() / 4);
+ dw, dh, dw, src.bytesPerLine() / 4);
else
qt_qimageScaleAARGB(scaleinfo, (unsigned int *)buffer.scanLine(0),
- 0, 0, 0, 0, dw, dh, dw, src.bytesPerLine() / 4);
+ dw, dh, dw, src.bytesPerLine() / 4);
qimageFreeScaleInfo(scaleinfo);
return buffer;
diff --git a/src/gui/painting/qimagescale_sse4.cpp b/src/gui/painting/qimagescale_sse4.cpp
index 303e0fd980..8712b5d324 100644
--- a/src/gui/painting/qimagescale_sse4.cpp
+++ b/src/gui/painting/qimagescale_sse4.cpp
@@ -59,7 +59,6 @@ inline static __m128i qt_qimageScaleAARGBA_helper(const unsigned int *pix, int x
template<bool RGB>
void qt_qimageScaleAARGBA_up_x_down_y_sse4(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow)
{
const unsigned int **ypoints = isi->ypoints;
@@ -67,20 +66,18 @@ void qt_qimageScaleAARGBA_up_x_down_y_sse4(QImageScaleInfo *isi, unsigned int *d
int *xapoints = isi->xapoints;
int *yapoints = isi->yapoints;
- int end = dxx + dw;
-
const __m128i v256 = _mm_set1_epi32(256);
/* go through every scanline in the output buffer */
for (int y = 0; y < dh; y++) {
- int Cy = (yapoints[dyy + y]) >> 16;
- int yap = (yapoints[dyy + y]) & 0xffff;
+ int Cy = yapoints[y] >> 16;
+ int yap = yapoints[y] & 0xffff;
const __m128i vCy = _mm_set1_epi32(Cy);
const __m128i vyap = _mm_set1_epi32(yap);
- unsigned int *dptr = dest + dx + ((y + dy) * dow);
- for (int x = dxx; x < end; x++) {
- const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
+ unsigned int *dptr = dest + (y * dow);
+ for (int x = 0; x < dw; x++) {
+ const unsigned int *sptr = ypoints[y] + xpoints[x];
__m128i vx = qt_qimageScaleAARGBA_helper(sptr, yap, Cy, sow, vyap, vCy);
int xap = xapoints[x];
@@ -107,7 +104,6 @@ void qt_qimageScaleAARGBA_up_x_down_y_sse4(QImageScaleInfo *isi, unsigned int *d
template<bool RGB>
void qt_qimageScaleAARGBA_down_x_up_y_sse4(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow)
{
const unsigned int **ypoints = isi->ypoints;
@@ -115,23 +111,21 @@ void qt_qimageScaleAARGBA_down_x_up_y_sse4(QImageScaleInfo *isi, unsigned int *d
int *xapoints = isi->xapoints;
int *yapoints = isi->yapoints;
- int end = dxx + dw;
-
const __m128i v256 = _mm_set1_epi32(256);
/* go through every scanline in the output buffer */
for (int y = 0; y < dh; y++) {
- unsigned int *dptr = dest + dx + ((y + dy) * dow);
- for (int x = dxx; x < end; x++) {
+ unsigned int *dptr = dest + (y * dow);
+ for (int x = 0; x < dw; x++) {
int Cx = xapoints[x] >> 16;
int xap = xapoints[x] & 0xffff;
const __m128i vCx = _mm_set1_epi32(Cx);
const __m128i vxap = _mm_set1_epi32(xap);
- const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
+ const unsigned int *sptr = ypoints[y] + xpoints[x];
__m128i vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);
- int yap = yapoints[dyy + y];
+ int yap = yapoints[y];
if (yap > 0) {
const __m128i vyap = _mm_set1_epi32(yap);
const __m128i vinvyap = _mm_sub_epi32(v256, vyap);
@@ -155,7 +149,6 @@ void qt_qimageScaleAARGBA_down_x_up_y_sse4(QImageScaleInfo *isi, unsigned int *d
template<bool RGB>
void qt_qimageScaleAARGBA_down_xy_sse4(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow)
{
const unsigned int **ypoints = isi->ypoints;
@@ -164,20 +157,19 @@ void qt_qimageScaleAARGBA_down_xy_sse4(QImageScaleInfo *isi, unsigned int *dest,
int *yapoints = isi->yapoints;
for (int y = 0; y < dh; y++) {
- int Cy = (yapoints[dyy + y]) >> 16;
- int yap = (yapoints[dyy + y]) & 0xffff;
+ int Cy = yapoints[y] >> 16;
+ int yap = yapoints[y] & 0xffff;
const __m128i vCy = _mm_set1_epi32(Cy);
const __m128i vyap = _mm_set1_epi32(yap);
- unsigned int *dptr = dest + dx + ((y + dy) * dow);
- int end = dxx + dw;
- for (int x = dxx; x < end; x++) {
+ unsigned int *dptr = dest + (y * dow);
+ for (int x = 0; x < dw; x++) {
const int Cx = xapoints[x] >> 16;
const int xap = xapoints[x] & 0xffff;
const __m128i vCx = _mm_set1_epi32(Cx);
const __m128i vxap = _mm_set1_epi32(xap);
- const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
+ const unsigned int *sptr = ypoints[y] + xpoints[x];
__m128i vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);
__m128i vr = _mm_mullo_epi32(_mm_srli_epi32(vx, 4), vyap);
@@ -203,27 +195,21 @@ void qt_qimageScaleAARGBA_down_xy_sse4(QImageScaleInfo *isi, unsigned int *dest,
}
template void qt_qimageScaleAARGBA_up_x_down_y_sse4<false>(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow);
template void qt_qimageScaleAARGBA_up_x_down_y_sse4<true>(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow);
template void qt_qimageScaleAARGBA_down_x_up_y_sse4<false>(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow);
template void qt_qimageScaleAARGBA_down_x_up_y_sse4<true>(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow);
template void qt_qimageScaleAARGBA_down_xy_sse4<false>(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow);
template void qt_qimageScaleAARGBA_down_xy_sse4<true>(QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy,
int dw, int dh, int dow, int sow);
QT_END_NAMESPACE
diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp
index acedc6a7ba..e4d756c18d 100644
--- a/src/gui/painting/qmatrix.cpp
+++ b/src/gui/painting/qmatrix.cpp
@@ -31,9 +31,11 @@
**
****************************************************************************/
+#include "qmatrix.h"
+
#include "qdatastream.h"
#include "qdebug.h"
-#include "qmatrix.h"
+#include "qhashfunctions.h"
#include "qregion.h"
#include "qpainterpath.h"
#include "qpainterpath_p.h"
@@ -972,6 +974,26 @@ bool QMatrix::operator==(const QMatrix &m) const
_dy == m._dy;
}
+
+/*!
+ \since 5.6
+ \relates QMatrix
+
+ Returns the hash value for \a key, using
+ \a seed to seed the calculation.
+*/
+uint qHash(const QMatrix &key, uint seed) Q_DECL_NOTHROW
+{
+ QtPrivate::QHashCombine hash;
+ seed = hash(key.m11(), seed);
+ seed = hash(key.m12(), seed);
+ seed = hash(key.m21(), seed);
+ seed = hash(key.m22(), seed);
+ seed = hash(key.dx(), seed);
+ seed = hash(key.dy(), seed);
+ return seed;
+}
+
/*!
\fn bool QMatrix::operator!=(const QMatrix &matrix) const
diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h
index ddffa8a8b9..c036e4df93 100644
--- a/src/gui/painting/qmatrix.h
+++ b/src/gui/painting/qmatrix.h
@@ -126,6 +126,8 @@ private:
};
Q_DECLARE_TYPEINFO(QMatrix, Q_MOVABLE_TYPE);
+Q_GUI_EXPORT Q_DECL_CONST_FUNCTION uint qHash(const QMatrix &key, uint seed = 0) Q_DECL_NOTHROW;
+
// mathematical semantics
inline QPoint operator*(const QPoint &p, const QMatrix &m)
{ return m.map(p); }
diff --git a/src/gui/painting/qpagedpaintdevice.cpp b/src/gui/painting/qpagedpaintdevice.cpp
index 3adc5e9411..547cedf51f 100644
--- a/src/gui/painting/qpagedpaintdevice.cpp
+++ b/src/gui/painting/qpagedpaintdevice.cpp
@@ -36,6 +36,10 @@
QT_BEGIN_NAMESPACE
+QPagedPaintDevicePrivate::~QPagedPaintDevicePrivate()
+{
+}
+
/*!
\class QPagedPaintDevice
\inmodule QtGui
diff --git a/src/gui/painting/qpagedpaintdevice_p.h b/src/gui/painting/qpagedpaintdevice_p.h
index 62f69747db..30b1c0a1e6 100644
--- a/src/gui/painting/qpagedpaintdevice_p.h
+++ b/src/gui/painting/qpagedpaintdevice_p.h
@@ -61,9 +61,7 @@ public:
{
}
- virtual ~QPagedPaintDevicePrivate()
- {
- }
+ virtual ~QPagedPaintDevicePrivate();
// ### Qt6 Remove these and make public class methods virtual
virtual bool setPageLayout(const QPageLayout &newPageLayout)
diff --git a/src/gui/painting/qpagelayout.h b/src/gui/painting/qpagelayout.h
index 17e5eeece2..7eac348c43 100644
--- a/src/gui/painting/qpagelayout.h
+++ b/src/gui/painting/qpagelayout.h
@@ -75,14 +75,13 @@ public:
const QMarginsF &margins, Unit units = Point,
const QMarginsF &minMargins = QMarginsF(0, 0, 0, 0));
QPageLayout(const QPageLayout &other);
- ~QPageLayout();
-
- QPageLayout &operator=(const QPageLayout &other);
- #ifdef Q_COMPILER_RVALUE_REFS
- QPageLayout &operator=(QPageLayout &&other) { swap(other); return *this; }
+#ifdef Q_COMPILER_RVALUE_REFS
+ QPageLayout &operator=(QPageLayout &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
+ QPageLayout &operator=(const QPageLayout &other);
+ ~QPageLayout();
- void swap(QPageLayout &other) { d.swap(other.d); }
+ void swap(QPageLayout &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
friend Q_GUI_EXPORT bool operator==(const QPageLayout &lhs, const QPageLayout &rhs);
bool isEquivalentTo(const QPageLayout &other) const;
diff --git a/src/gui/painting/qpagesize.h b/src/gui/painting/qpagesize.h
index 00e22a243f..9119a582ac 100644
--- a/src/gui/painting/qpagesize.h
+++ b/src/gui/painting/qpagesize.h
@@ -229,14 +229,14 @@ public:
const QString &name = QString(),
SizeMatchPolicy matchPolicy = FuzzyMatch);
QPageSize(const QPageSize &other);
- ~QPageSize();
-
- QPageSize &operator=(const QPageSize &other);
#ifdef Q_COMPILER_RVALUE_REFS
- QPageSize &operator=(QPageSize &&other) { swap(other); return *this; }
+ QPageSize &operator=(QPageSize &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
+ QPageSize &operator=(const QPageSize &other);
+ ~QPageSize();
+
- void swap(QPageSize &other) { d.swap(other.d); }
+ void swap(QPageSize &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
friend Q_GUI_EXPORT bool operator==(const QPageSize &lhs, const QPageSize &rhs);
bool isEquivalentTo(const QPageSize &other) const;
diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp
index 6ba26df3b4..ef93094387 100644
--- a/src/gui/painting/qpaintengine.cpp
+++ b/src/gui/painting/qpaintengine.cpp
@@ -968,6 +968,10 @@ QRect QPaintEngine::systemRect() const
return d_func()->systemRect;
}
+QPaintEnginePrivate::~QPaintEnginePrivate()
+{
+}
+
void QPaintEnginePrivate::drawBoxTextItem(const QPointF &p, const QTextItemInt &ti)
{
if (!ti.glyphs.numGlyphs)
diff --git a/src/gui/painting/qpaintengine_p.h b/src/gui/painting/qpaintengine_p.h
index c58662ede4..918c98997b 100644
--- a/src/gui/painting/qpaintengine_p.h
+++ b/src/gui/painting/qpaintengine_p.h
@@ -60,7 +60,8 @@ class Q_GUI_EXPORT QPaintEnginePrivate
public:
QPaintEnginePrivate() : pdev(0), q_ptr(0), currentClipDevice(0), hasSystemTransform(0),
hasSystemViewport(0) {}
- virtual ~QPaintEnginePrivate() { }
+ virtual ~QPaintEnginePrivate();
+
QPaintDevice *pdev;
QPaintEngine *q_ptr;
QRegion systemClip;
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 18522cb6d0..f55dddfb6a 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -42,7 +42,6 @@
#include <qpainterpath.h>
#include <qdebug.h>
-#include <qhash.h>
#include <qbitmap.h>
#include <qmath.h>
@@ -57,6 +56,7 @@
#include <private/qstatictext_p.h>
#include <private/qcosmeticstroker_p.h>
#include "qmemrotate_p.h"
+#include "qrgba64_p.h"
#include "qpaintengine_raster_p.h"
// #include "qbezier_p.h"
@@ -830,7 +830,7 @@ void QRasterPaintEngine::updateRasterState()
&& s->intOpacity == 256
&& (mode == QPainter::CompositionMode_Source
|| (mode == QPainter::CompositionMode_SourceOver
- && qAlpha(s->penData.solid.color) == 255));
+ && s->penData.solid.color.isOpaque()));
}
s->dirty = 0;
@@ -1412,10 +1412,9 @@ static void fillRect_normalized(const QRect &r, QSpanData *data,
if (data->fillRect && (mode == QPainter::CompositionMode_Source
|| (mode == QPainter::CompositionMode_SourceOver
- && qAlpha(data->solid.color) == 255)))
+ && data->solid.color.isOpaque())))
{
- data->fillRect(data->rasterBuffer, x1, y1, width, height,
- data->solid.color);
+ data->fillRect(data->rasterBuffer, x1, y1, width, height, data->solid.color);
return;
}
}
@@ -1773,8 +1772,9 @@ void QRasterPaintEngine::fillRect(const QRectF &r, const QColor &color)
Q_D(QRasterPaintEngine);
QRasterPaintEngineState *s = state();
- d->solid_color_filler.solid.color = qPremultiply(ARGB_COMBINE_ALPHA(color.rgba(), s->intOpacity));
- if ((d->solid_color_filler.solid.color & 0xff000000) == 0
+ d->solid_color_filler.solid.color = qPremultiply(combineAlpha256(color.rgba64(), s->intOpacity));
+
+ if (d->solid_color_filler.solid.color.isTransparent()
&& s->composition_mode == QPainter::CompositionMode_SourceOver) {
return;
}
@@ -2219,19 +2219,15 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
case QImage::Format_A2BGR30_Premultiplied:
case QImage::Format_A2RGB30_Premultiplied:
// Combine premultiplied color with the opacity set on the painter.
- d->solid_color_filler.solid.color =
- ((((color & 0x00ff00ff) * s->intOpacity) >> 8) & 0x00ff00ff)
- | ((((color & 0xff00ff00) >> 8) * s->intOpacity) & 0xff00ff00);
+ d->solid_color_filler.solid.color = multiplyAlpha256(QRgba64::fromArgb32(color), s->intOpacity);
break;
default:
- d->solid_color_filler.solid.color = qPremultiply(ARGB_COMBINE_ALPHA(color, s->intOpacity));
+ d->solid_color_filler.solid.color = qPremultiply(combineAlpha256(QRgba64::fromArgb32(color), s->intOpacity));
break;
}
- if ((d->solid_color_filler.solid.color & 0xff000000) == 0
- && s->composition_mode == QPainter::CompositionMode_SourceOver) {
+ if (d->solid_color_filler.solid.color.isTransparent() && s->composition_mode == QPainter::CompositionMode_SourceOver)
return;
- }
d->solid_color_filler.clip = d->clip();
d->solid_color_filler.adjustSpanMethods();
@@ -2756,12 +2752,12 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
QFixed spp = fontEngine->subPixelPositionForX(positions[i].x);
QPoint offset;
- QImage *alphaMap = fontEngine->lockedAlphaMapForGlyph(glyphs[i], spp, neededFormat, s->matrix,
- &offset);
+ const QImage *alphaMap = fontEngine->lockedAlphaMapForGlyph(glyphs[i], spp, neededFormat, s->matrix,
+ &offset);
if (alphaMap == 0 || alphaMap->isNull())
continue;
- alphaPenBlt(alphaMap->bits(), alphaMap->bytesPerLine(), alphaMap->depth(),
+ alphaPenBlt(alphaMap->constBits(), alphaMap->bytesPerLine(), alphaMap->depth(),
qFloor(positions[i].x) + offset.x(),
qRound(positions[i].y) + offset.y(),
alphaMap->width(), alphaMap->height());
@@ -4137,7 +4133,7 @@ class QGradientCache
{
inline CacheInfo(QGradientStops s, int op, QGradient::InterpolationMode mode) :
stops(s), opacity(op), interpolationMode(mode) {}
- uint buffer[GRADIENT_STOPTABLE_SIZE];
+ QRgba64 buffer[GRADIENT_STOPTABLE_SIZE];
QGradientStops stops;
int opacity;
QGradient::InterpolationMode interpolationMode;
@@ -4146,12 +4142,12 @@ class QGradientCache
typedef QMultiHash<quint64, CacheInfo> QGradientColorTableHash;
public:
- inline const uint *getBuffer(const QGradient &gradient, int opacity) {
+ inline const QRgba64 *getBuffer(const QGradient &gradient, int opacity) {
quint64 hash_val = 0;
QGradientStops stops = gradient.stops();
for (int i = 0; i < stops.size() && i <= 2; i++)
- hash_val += stops[i].second.rgba();
+ hash_val += stops[i].second.rgba64();
QMutexLocker lock(&mutex);
QGradientColorTableHash::const_iterator it = cache.constFind(hash_val);
@@ -4174,9 +4170,9 @@ public:
protected:
inline int maxCacheSize() const { return 60; }
inline void generateGradientColorTable(const QGradient& g,
- uint *colorTable,
+ QRgba64 *colorTable,
int size, int opacity) const;
- uint *addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) {
+ QRgba64 *addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) {
if (cache.size() == maxCacheSize()) {
// may remove more than 1, but OK
cache.erase(cache.begin() + (qrand() % maxCacheSize()));
@@ -4190,7 +4186,7 @@ protected:
QMutex mutex;
};
-void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint *colorTable, int size, int opacity) const
+void QGradientCache::generateGradientColorTable(const QGradient& gradient, QRgba64 *colorTable, int size, int opacity) const
{
QGradientStops stops = gradient.stops();
int stopCount = stops.count();
@@ -4199,14 +4195,16 @@ void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint
bool colorInterpolation = (gradient.interpolationMode() == QGradient::ColorInterpolation);
if (stopCount == 2) {
- uint first_color = ARGB_COMBINE_ALPHA(stops[0].second.rgba(), opacity);
- uint second_color = ARGB_COMBINE_ALPHA(stops[1].second.rgba(), opacity);
+ QRgba64 first_color = combineAlpha256(stops[0].second.rgba64(), opacity);
+ QRgba64 second_color = combineAlpha256(stops[1].second.rgba64(), opacity);
qreal first_stop = stops[0].first;
qreal second_stop = stops[1].first;
if (second_stop < first_stop) {
- qSwap(first_color, second_color);
+ quint64 tmp = first_color;
+ first_color = second_color;
+ second_color = tmp;
qSwap(first_stop, second_stop);
}
@@ -4218,15 +4216,15 @@ void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint
int first_index = qRound(first_stop * (GRADIENT_STOPTABLE_SIZE-1));
int second_index = qRound(second_stop * (GRADIENT_STOPTABLE_SIZE-1));
- uint red_first = qRed(first_color) << 16;
- uint green_first = qGreen(first_color) << 16;
- uint blue_first = qBlue(first_color) << 16;
- uint alpha_first = qAlpha(first_color) << 16;
+ uint red_first = uint(first_color.red()) << 16;
+ uint green_first = uint(first_color.green()) << 16;
+ uint blue_first = uint(first_color.blue()) << 16;
+ uint alpha_first = uint(first_color.alpha()) << 16;
- uint red_second = qRed(second_color) << 16;
- uint green_second = qGreen(second_color) << 16;
- uint blue_second = qBlue(second_color) << 16;
- uint alpha_second = qAlpha(second_color) << 16;
+ uint red_second = uint(second_color.red()) << 16;
+ uint green_second = uint(second_color.green()) << 16;
+ uint blue_second = uint(second_color.blue()) << 16;
+ uint alpha_second = uint(second_color.alpha()) << 16;
int i = 0;
for (; i <= qMin(GRADIENT_STOPTABLE_SIZE, first_index); ++i) {
@@ -4239,10 +4237,10 @@ void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint
if (i < second_index) {
qreal reciprocal = qreal(1) / (second_index - first_index);
- int red_delta = qRound(int(red_second - red_first) * reciprocal);
- int green_delta = qRound(int(green_second - green_first) * reciprocal);
- int blue_delta = qRound(int(blue_second - blue_first) * reciprocal);
- int alpha_delta = qRound(int(alpha_second - alpha_first) * reciprocal);
+ int red_delta = qRound((qreal(red_second) - red_first) * reciprocal);
+ int green_delta = qRound((qreal(green_second) - green_first) * reciprocal);
+ int blue_delta = qRound((qreal(blue_second) - blue_first) * reciprocal);
+ int alpha_delta = qRound((qreal(alpha_second) - alpha_first) * reciprocal);
// rounding
red_first += 1 << 15;
@@ -4256,8 +4254,7 @@ void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint
blue_first += blue_delta;
alpha_first += alpha_delta;
- const uint color = ((alpha_first << 8) & 0xff000000) | (red_first & 0xff0000)
- | ((green_first >> 8) & 0xff00) | (blue_first >> 16);
+ const QRgba64 color = qRgba64(red_first >> 16, green_first >> 16, blue_first >> 16, alpha_first >> 16);
if (colorInterpolation)
colorTable[i] = color;
@@ -4276,7 +4273,7 @@ void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint
return;
}
- uint current_color = ARGB_COMBINE_ALPHA(stops[0].second.rgba(), opacity);
+ QRgba64 current_color = combineAlpha256(stops[0].second.rgba64(), opacity);
if (stopCount == 1) {
current_color = qPremultiply(current_color);
for (int i = 0; i < size; ++i)
@@ -4289,7 +4286,7 @@ void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint
qreal end_pos = stops[stopCount-1].first;
int pos = 0; // The position in the color table.
- uint next_color;
+ QRgba64 next_color;
qreal incr = 1 / qreal(size); // the double increment.
qreal dpos = 1.5 * incr; // current position in gradient stop list (0 to 1)
@@ -4313,8 +4310,8 @@ void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint
++current_stop;
if (current_stop != 0)
- current_color = ARGB_COMBINE_ALPHA(stops[current_stop].second.rgba(), opacity);
- next_color = ARGB_COMBINE_ALPHA(stops[current_stop+1].second.rgba(), opacity);
+ current_color = combineAlpha256(stops[current_stop].second.rgba64(), opacity);
+ next_color = combineAlpha256(stops[current_stop+1].second.rgba64(), opacity);
if (colorInterpolation) {
current_color = qPremultiply(current_color);
@@ -4333,9 +4330,9 @@ void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint
int idist = 256 - dist;
if (colorInterpolation)
- colorTable[pos] = INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist);
+ colorTable[pos] = interpolate256(current_color, idist, next_color, dist);
else
- colorTable[pos] = qPremultiply(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist));
+ colorTable[pos] = qPremultiply(interpolate256(current_color, idist, next_color, dist));
++pos;
dpos += incr;
@@ -4354,8 +4351,8 @@ void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint
if (skip == 1)
current_color = next_color;
else
- current_color = ARGB_COMBINE_ALPHA(stops[current_stop].second.rgba(), opacity);
- next_color = ARGB_COMBINE_ALPHA(stops[current_stop+1].second.rgba(), opacity);
+ current_color = combineAlpha256(stops[current_stop].second.rgba64(), opacity);
+ next_color = combineAlpha256(stops[current_stop+1].second.rgba64(), opacity);
if (colorInterpolation) {
if (skip != 1)
@@ -4372,7 +4369,7 @@ void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint
}
// After last point
- current_color = qPremultiply(ARGB_COMBINE_ALPHA(stops[stopCount - 1].second.rgba(), opacity));
+ current_color = qPremultiply(combineAlpha256(stops[stopCount - 1].second.rgba64(), opacity));
while (pos < size - 1) {
colorTable[pos] = current_color;
++pos;
@@ -4405,12 +4402,9 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
case Qt::SolidPattern: {
type = Solid;
QColor c = qbrush_color(brush);
- QRgb rgba = c.rgba();
- solid.color = qPremultiply(ARGB_COMBINE_ALPHA(rgba, alpha));
- if ((solid.color & 0xff000000) == 0
- && compositionMode == QPainter::CompositionMode_SourceOver) {
+ solid.color = qPremultiply(combineAlpha256(c.rgba64(), alpha));
+ if (solid.color.isTransparent() && compositionMode == QPainter::CompositionMode_SourceOver)
type = None;
- }
break;
}
@@ -4419,7 +4413,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
type = LinearGradient;
const QLinearGradient *g = static_cast<const QLinearGradient *>(brush.gradient());
gradient.alphaColor = !brush.isOpaque() || alpha != 256;
- gradient.colorTable = const_cast<uint*>(qt_gradient_cache()->getBuffer(*g, alpha));
+ gradient.colorTable = const_cast<QRgba64*>(qt_gradient_cache()->getBuffer(*g, alpha));
gradient.spread = g->spread();
QLinearGradientData &linearData = gradient.linear;
@@ -4436,7 +4430,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
type = RadialGradient;
const QRadialGradient *g = static_cast<const QRadialGradient *>(brush.gradient());
gradient.alphaColor = !brush.isOpaque() || alpha != 256;
- gradient.colorTable = const_cast<uint*>(qt_gradient_cache()->getBuffer(*g, alpha));
+ gradient.colorTable = const_cast<QRgba64*>(qt_gradient_cache()->getBuffer(*g, alpha));
gradient.spread = g->spread();
QRadialGradientData &radialData = gradient.radial;
@@ -4457,7 +4451,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
type = ConicalGradient;
const QConicalGradient *g = static_cast<const QConicalGradient *>(brush.gradient());
gradient.alphaColor = !brush.isOpaque() || alpha != 256;
- gradient.colorTable = const_cast<uint*>(qt_gradient_cache()->getBuffer(*g, alpha));
+ gradient.colorTable = const_cast<QRgba64*>(qt_gradient_cache()->getBuffer(*g, alpha));
gradient.spread = QGradient::RepeatSpread;
QConicalGradientData &conicalData = gradient.conical;
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 20608e5aee..1726bbe71f 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -7470,7 +7470,7 @@ start_lengthVariant:
}
}
- QList<QTextLayout::FormatRange> underlineFormats;
+ QVector<QTextLayout::FormatRange> underlineFormats;
int length = offset - old_offset;
if ((hidemnmemonic || showmnemonic) && maxUnderlines > 0) {
QChar *cout = text.data() + old_offset;
@@ -7526,6 +7526,7 @@ start_lengthVariant:
if (engine.option.tabs().isEmpty() && ta) {
QList<qreal> tabs;
+ tabs.reserve(tabarraylen);
for (int i = 0; i < tabarraylen; i++)
tabs.append(qreal(ta[i]));
engine.option.setTabArray(tabs);
@@ -7544,7 +7545,7 @@ start_lengthVariant:
engine.forceJustification = true;
QTextLayout textLayout(&engine);
textLayout.setCacheEnabled(true);
- textLayout.setAdditionalFormats(underlineFormats);
+ textLayout.setFormats(underlineFormats);
if (finalText.isEmpty()) {
height = fm.height();
diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h
index 7c32dc1694..3ea4e35b8d 100644
--- a/src/gui/painting/qpainter_p.h
+++ b/src/gui/painting/qpainter_p.h
@@ -53,7 +53,6 @@
#include "QtGui/qpainter.h"
#include "QtGui/qpainterpath.h"
#include "QtGui/qpaintengine.h"
-#include <QtCore/qhash.h>
#include <private/qpen_p.h>
diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp
index 0798418c17..513fdfa2b6 100644
--- a/src/gui/painting/qpathclipper.cpp
+++ b/src/gui/painting/qpathclipper.cpp
@@ -1889,10 +1889,10 @@ bool QPathClipper::handleCrossingEdges(QWingedEdge &list, qreal y, ClipperMode m
namespace {
-QList<QPainterPath> toSubpaths(const QPainterPath &path)
+QVector<QPainterPath> toSubpaths(const QPainterPath &path)
{
- QList<QPainterPath> subpaths;
+ QVector<QPainterPath> subpaths;
if (path.isEmpty())
return subpaths;
@@ -2092,7 +2092,7 @@ QPainterPath clip(const QPainterPath &path, qreal t)
QPainterPath intersectPath(const QPainterPath &path, const QRectF &rect)
{
- QList<QPainterPath> subpaths = toSubpaths(path);
+ QVector<QPainterPath> subpaths = toSubpaths(path);
QPainterPath result;
result.setFillRule(path.fillRule());
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index 6ea0800538..1389112462 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1952,7 +1952,9 @@ int QPdfEnginePrivate::createShadingFunction(const QGradient *gradient, int from
stops.append(QGradientStop(1, stops.at(stops.size() - 1).second));
QVector<int> functions;
- for (int i = 0; i < stops.size() - 1; ++i) {
+ const int numStops = stops.size();
+ functions.reserve(numStops - 1);
+ for (int i = 0; i < numStops - 1; ++i) {
int f = addXrefEntry(-1);
QByteArray data;
QPdf::ByteStream s(&data);
diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h
index 94e74f30b9..2b50cdc6f7 100644
--- a/src/gui/painting/qpdf_p.h
+++ b/src/gui/painting/qpdf_p.h
@@ -243,7 +243,7 @@ public:
QPointF brushOrigin;
QBrush brush;
QPen pen;
- QList<QPainterPath> clips;
+ QVector<QPainterPath> clips;
bool clipEnabled;
bool allClipped;
bool hasPen;
diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp
index 6263d18b01..073d254b49 100644
--- a/src/gui/painting/qpen.cpp
+++ b/src/gui/painting/qpen.cpp
@@ -980,6 +980,7 @@ QDataStream &operator>>(QDataStream &s, QPen &p)
quint32 numDashes;
s >> numDashes;
double dash;
+ dashPattern.reserve(numDashes);
for (quint32 i = 0; i < numDashes; ++i) {
s >> dash;
dashPattern << dash;
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp
index 62492980de..c1737e7746 100644
--- a/src/gui/painting/qplatformbackingstore.cpp
+++ b/src/gui/painting/qplatformbackingstore.cpp
@@ -220,7 +220,9 @@ static QRegion deviceRegion(const QRegion &region, QWindow *window)
return region;
QVector<QRect> rects;
- foreach (QRect rect, region.rects())
+ const QVector<QRect> regionRects = region.rects();
+ rects.reserve(regionRects.count());
+ foreach (const QRect &rect, regionRects)
rects.append(deviceRect(rect, window));
QRegion deviceRegion;
diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h
index 1549ebe2b5..3890715f32 100644
--- a/src/gui/painting/qpolygon.h
+++ b/src/gui/painting/qpolygon.h
@@ -56,7 +56,11 @@ public:
inline /*implicit*/ QPolygon(const QVector<QPoint> &v) : QVector<QPoint>(v) {}
QPolygon(const QRect &r, bool closed=false);
QPolygon(int nPoints, const int *points);
- inline void swap(QPolygon &other) { QVector<QPoint>::swap(other); } // prevent QVector<QPoint><->QPolygon swaps
+#ifdef Q_COMPILER_RVALUE_REFS
+ QPolygon &operator=(QPolygon &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
+ QPolygon &operator=(const QPolygon &other) { QVector<QPoint>::operator=(other); return *this; }
+ void swap(QPolygon &other) Q_DECL_NOTHROW { QVector<QPoint>::swap(other); } // prevent QVector<QPoint><->QPolygon swaps
operator QVariant() const;
@@ -130,6 +134,10 @@ public:
inline /*implicit*/ QPolygonF(const QVector<QPointF> &v) : QVector<QPointF>(v) {}
QPolygonF(const QRectF &r);
/*implicit*/ QPolygonF(const QPolygon &a);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QPolygonF &operator=(QPolygonF &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
+ QPolygonF &operator=(const QPolygonF &other) { QVector<QPointF>::operator=(other); return *this; }
inline void swap(QPolygonF &other) { QVector<QPointF>::swap(other); } // prevent QVector<QPointF><->QPolygonF swaps
operator QVariant() const;
diff --git a/src/gui/painting/qrgba64.h b/src/gui/painting/qrgba64.h
new file mode 100644
index 0000000000..290501047d
--- /dev/null
+++ b/src/gui/painting/qrgba64.h
@@ -0,0 +1,208 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QRGBA64_H
+#define QRGBA64_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qprocessordetection.h>
+
+QT_BEGIN_NAMESPACE
+
+class QRgba64 {
+ struct qrgba_t {
+ quint16 red;
+ quint16 green;
+ quint16 blue;
+ quint16 alpha;
+ };
+
+ union {
+ struct qrgba_t c;
+ quint64 rgba;
+ };
+public:
+ // No constructors are allowed, since this needs to be usable in a union in no-c++11 mode.
+ // When c++11 is mandatory, we can add all but a copy constructor.
+ Q_DECL_RELAXED_CONSTEXPR static QRgba64 fromRgba64(quint16 red, quint16 green, quint16 blue, quint16 alpha)
+ {
+ QRgba64 rgba64
+#ifdef Q_COMPILER_UNIFORM_INIT
+ = {}
+#endif
+ ;
+
+ rgba64.c.red = red;
+ rgba64.c.green = green;
+ rgba64.c.blue = blue;
+ rgba64.c.alpha = alpha;
+ return rgba64;
+ }
+ Q_DECL_RELAXED_CONSTEXPR static QRgba64 fromRgba64(quint64 c)
+ {
+ QRgba64 rgba64
+#ifdef Q_COMPILER_UNIFORM_INIT
+ = {}
+#endif
+ ;
+ rgba64.rgba = c;
+ return rgba64;
+ }
+ Q_DECL_RELAXED_CONSTEXPR static QRgba64 fromRgba(quint8 red, quint8 green, quint8 blue, quint8 alpha)
+ {
+ QRgba64 rgb64 = fromRgba64(red, green, blue, alpha);
+ // Expand the range so that 0x00 maps to 0x0000 and 0xff maps to 0xffff.
+ rgb64.rgba |= rgb64.rgba << 8;
+ return rgb64;
+ }
+ Q_DECL_RELAXED_CONSTEXPR static QRgba64 fromArgb32(uint rgb)
+ {
+ return fromRgba(rgb >> 16, rgb >> 8, rgb, rgb >> 24);
+ }
+
+ Q_DECL_CONSTEXPR bool isOpaque() const { return c.alpha == 0xffff; }
+ Q_DECL_CONSTEXPR bool isTransparent() const { return c.alpha == 0; }
+
+ Q_DECL_CONSTEXPR quint16 red() const { return c.red; }
+ Q_DECL_CONSTEXPR quint16 green() const { return c.green; }
+ Q_DECL_CONSTEXPR quint16 blue() const { return c.blue; }
+ Q_DECL_CONSTEXPR quint16 alpha() const { return c.alpha; }
+ void setRed(quint16 _red) { c.red = _red; }
+ void setGreen(quint16 _green) { c.green = _green; }
+ void setBlue(quint16 _blue) { c.blue = _blue; }
+ void setAlpha(quint16 _alpha) { c.alpha = _alpha; }
+
+ Q_DECL_CONSTEXPR quint8 red8() const { return div_257(c.red); }
+ Q_DECL_CONSTEXPR quint8 green8() const { return div_257(c.green); }
+ Q_DECL_CONSTEXPR quint8 blue8() const { return div_257(c.blue); }
+ Q_DECL_CONSTEXPR quint8 alpha8() const { return div_257(c.alpha); }
+ Q_DECL_CONSTEXPR uint toArgb32() const
+ {
+ return (alpha8() << 24) | (red8() << 16) | (green8() << 8) | blue8();
+ }
+ Q_DECL_CONSTEXPR ushort toRgb16() const
+ {
+ return (c.red & 0xf800) | ((c.green >> 10) << 5) | (c.blue >> 11);
+ }
+
+ Q_DECL_RELAXED_CONSTEXPR QRgba64 premultiplied() const
+ {
+ const quint32 a = c.alpha;
+ const quint16 r = div_65535(c.red * a);
+ const quint16 g = div_65535(c.green * a);
+ const quint16 b = div_65535(c.blue * a);
+ return fromRgba64(r, g, b, a);
+ }
+
+ Q_DECL_RELAXED_CONSTEXPR QRgba64 unpremultiplied() const
+ {
+#if Q_PROCESSOR_WORDSIZE < 8
+ return unpremultiplied_32bit();
+#else
+ return unpremultiplied_64bit();
+#endif
+ }
+
+ Q_DECL_CONSTEXPR operator quint64() const
+ {
+ return rgba;
+ }
+
+ QRgba64 operator=(quint64 _rgba)
+ {
+ rgba = _rgba;
+ return *this;
+ }
+
+private:
+ static Q_DECL_CONSTEXPR uint div_257_floor(uint x) { return (x - (x >> 8)) >> 8; }
+ static Q_DECL_CONSTEXPR uint div_257(uint x) { return div_257_floor(x + 128); }
+ static Q_DECL_CONSTEXPR uint div_65535(uint x) { return (x + (x>>16) + 0x8000U) >> 16; }
+ Q_DECL_RELAXED_CONSTEXPR QRgba64 unpremultiplied_32bit() const
+ {
+ if (c.alpha == 0xffff || c.alpha == 0)
+ return *this;
+ const quint16 r = (quint32(c.red) * 0xffff + c.alpha/2) / c.alpha;
+ const quint16 g = (quint32(c.green) * 0xffff + c.alpha/2) / c.alpha;
+ const quint16 b = (quint32(c.blue) * 0xffff + c.alpha/2) / c.alpha;
+ return fromRgba64(r, g, b, c.alpha);
+ }
+ Q_DECL_RELAXED_CONSTEXPR QRgba64 unpremultiplied_64bit() const
+ {
+ if (c.alpha == 0xffff || c.alpha == 0)
+ return *this;
+ const quint64 fa = (Q_UINT64_C(0xffff00008000) + c.alpha/2) / c.alpha;
+ const quint16 r = (c.red * fa + 0x80000000) >> 32;
+ const quint16 g = (c.green * fa + 0x80000000) >> 32;
+ const quint16 b = (c.blue * fa + 0x80000000) >> 32;
+ return fromRgba64(r, g, b, c.alpha);
+ }
+};
+
+Q_DECLARE_TYPEINFO(QRgba64, Q_PRIMITIVE_TYPE);
+
+Q_DECL_RELAXED_CONSTEXPR inline QRgba64 qRgba64(quint16 r, quint16 g, quint16 b, quint16 a)
+{
+ return QRgba64::fromRgba64(r, g, b, a);
+}
+
+Q_DECL_RELAXED_CONSTEXPR inline QRgba64 qRgba64(quint64 c)
+{
+ return QRgba64::fromRgba64(c);
+}
+
+Q_DECL_RELAXED_CONSTEXPR inline QRgba64 qPremultiply(QRgba64 c)
+{
+ return c.premultiplied();
+}
+
+Q_DECL_RELAXED_CONSTEXPR inline QRgba64 qUnpremultiply(QRgba64 c)
+{
+ return c.unpremultiplied();
+}
+
+inline Q_DECL_CONSTEXPR uint qRed(QRgba64 rgb)
+{ return rgb.red8(); }
+
+inline Q_DECL_CONSTEXPR uint qGreen(QRgba64 rgb)
+{ return rgb.green8(); }
+
+inline Q_DECL_CONSTEXPR uint qBlue(QRgba64 rgb)
+{ return rgb.blue8(); }
+
+inline Q_DECL_CONSTEXPR uint qAlpha(QRgba64 rgb)
+{ return rgb.alpha8(); }
+
+QT_END_NAMESPACE
+
+#endif // QRGBA64_H
diff --git a/src/gui/painting/qrgba64.qdoc b/src/gui/painting/qrgba64.qdoc
new file mode 100644
index 0000000000..29da0aa390
--- /dev/null
+++ b/src/gui/painting/qrgba64.qdoc
@@ -0,0 +1,241 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class QRgba64
+ \brief The QRgba64 struct contains a 64-bit RGB color.
+ \since 5.6
+
+ \ingroup painting
+ \inmodule QtGui
+
+ QRgba64 is a 64-bit data-structure containing four 16-bit color channels: Red, green, blue and alpha.
+
+ QRgba64 can be used a replacement for QRgb when higher precision is needed. In particular a
+ premultiplied QRgba64 can operate on unpremultipled QRgb without loss of precision except
+ for alpha 0.
+
+ \sa QRgb, QColor
+*/
+
+/*!
+ \fn static QRgba64 QRgba64::fromRgba64(quint16 r, quint16 g, quint16 b, quint16 a)
+
+ Returns the QRgba64 quadruplet (\a{r}, \a{g}, \a{b}, \a{a}).
+
+ \sa fromRgba()
+*/
+
+/*!
+ \fn static QRgba64 QRgba64::fromRgba64(quint64 c)
+
+ Returns \a c as a QRgba64 struct.
+
+ \sa fromArgb32()
+*/
+
+/*!
+ \fn static QRgba64 QRgba64::fromRgba(quint8 red, quint8 green, quint8 blue, quint8 alpha)
+
+ Constructs a QRgba64 value from the four 8-bit color channels \a red, \a green, \a blue and \a alpha.
+
+ \sa fromArgb32()
+*/
+
+/*!
+ \fn static QRgba64 QRgba64::fromArgb32(uint rgb)
+
+ Constructs a QRgba64 value from the 32bit ARGB value \a rgb.
+
+ \sa fromRgba()
+*/
+
+/*!
+ \fn quint16 QRgba64::red() const
+
+ Returns the 16-bit red color component.
+*/
+
+/*!
+ \fn quint16 QRgba64::green() const
+
+ Returns the 16-bit green color component.
+*/
+
+/*!
+ \fn quint16 QRgba64::blue() const
+
+ Returns the 16-bit blue color component.
+*/
+
+/*!
+ \fn quint16 QRgba64::alpha() const
+
+ Returns the 16-bit alpha channel.
+*/
+
+/*!
+ \fn quint8 QRgba64::red8() const
+
+ Returns the red color component as an 8-bit.
+*/
+
+/*!
+ \fn quint8 QRgba64::green8() const
+
+ Returns the green color component as an 8-bit.
+*/
+
+/*!
+ \fn quint8 QRgba64::blue8() const
+
+ Returns the blue color component as an 8-bit.
+*/
+
+/*!
+ \fn quint8 QRgba64::alpha8() const
+
+ Returns the alpha channel as an 8-bit.
+*/
+
+/*!
+ \fn uint QRgba64::toArgb32() const
+
+ Returns the color as a 32-bit ARGB value.
+
+ \sa fromArgb32()
+*/
+
+/*!
+ \fn ushort QRgba64::toRgb16() const
+
+ Returns the color as a 16-bit RGB value.
+
+ \sa toArgb32()
+*/
+
+/*!
+ \fn QRgba64 QRgba64::premultiplied() const
+
+ Returns the color with the alpha premultiplied.
+
+ \sa unpremultiplied()
+*/
+
+/*!
+ \fn QRgba64 QRgba64::unpremultiplied() const
+
+ Returns the color with the alpha unpremultiplied.
+
+ \sa premultiplied()
+*/
+
+/*!
+ \fn QRgba64::operator quint64() const
+
+ Returns the color as a 64bit unsigned integer
+*/
+
+/*!
+ \fn QRgba64 qRgba64(quint16 r, quint16 g, quint16 b, quint16 a)
+ \relates QColor
+ \since 5.6
+
+ Returns the QRgba64 quadruplet (\a{r}, \a{g}, \a{b}, \a{a}).
+
+ \sa qRgba()
+*/
+
+/*!
+ \fn QRgba64 qRgba64(quint64 c)
+ \relates QColor
+ \since 5.6
+
+ Returns \a c as a QRgba64 struct.
+
+ \sa qRgba()
+*/
+
+/*!
+ \fn QRgba64 qPremultiply(QRgba64 rgba64)
+ \since 5.6
+ \relates QColor
+
+ Converts an unpremultiplied QRgba64 quadruplet \a rgba64 into a premultiplied QRgba64 quadruplet.
+
+ \sa QRgba64::premultiplied(), qUnpremultiply()
+*/
+
+/*!
+ \fn QRgba64 qUnpremultiply(QRgba64 rgba64)
+ \since 5.6
+ \relates QColor
+
+ Converts a premultiplied QRgba64 quadruplet \a rgba64 into an unpremultiplied QRgba64 quadruplet.
+
+ \sa QRgba64::unpremultiplied(), qPremultiply()
+*/
+
+/*!
+ \fn uint qRed(QRgba64 rgba64)
+ \since 5.6
+ \relates QColor
+
+ Returns the red component of \a rgba64 as an 8-bit value.
+
+ \sa QRgba64::red8(), QColor::red()
+*/
+
+/*!
+ \fn uint qGreen(QRgba64 rgba64)
+ \since 5.6
+ \relates QColor
+
+ Returns the green component of \a rgba64 as an 8-bit value.
+
+ \sa QRgba64::green8(), QColor::green()
+*/
+
+/*!
+ \fn uint qBlue(QRgba64 rgba64)
+ \since 5.6
+ \relates QColor
+
+ Returns the blue component of \a rgba64 as an 8-bit value.
+
+ \sa QRgba64::blue8(), QColor::blue()
+*/
+
+/*!
+ \fn uint qAlpha(QRgba64 rgba64)
+ \since 5.6
+ \relates QColor
+
+ Returns the alpha component of \a rgba64 as an 8-bit value.
+
+ \sa QRgba64::alpha8(), QColor::alpha()
+*/
diff --git a/src/gui/painting/qrgba64_p.h b/src/gui/painting/qrgba64_p.h
new file mode 100644
index 0000000000..c6cbe666ac
--- /dev/null
+++ b/src/gui/painting/qrgba64_p.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QRGBA64_P_H
+#define QRGBA64_P_H
+
+#include <QtGui/qrgba64.h>
+#include <QtGui/private/qdrawhelper_p.h>
+#include <private/qsimd_p.h>
+
+QT_BEGIN_NAMESPACE
+
+inline QRgba64 combineAlpha256(QRgba64 rgba64, uint alpha256)
+{
+ return QRgba64::fromRgba64(rgba64.red(), rgba64.green(), rgba64.blue(), (rgba64.alpha() * alpha256) >> 8);
+}
+
+inline QRgba64 multiplyAlpha256(QRgba64 rgba64, uint alpha256)
+{
+ return QRgba64::fromRgba64((rgba64.red() * alpha256) >> 8,
+ (rgba64.green() * alpha256) >> 8,
+ (rgba64.blue() * alpha256) >> 8,
+ (rgba64.alpha() * alpha256) >> 8);
+}
+
+inline QRgba64 multiplyAlpha65535(QRgba64 rgba64, uint alpha65535)
+{
+#ifdef __SSE2__
+ const __m128i va = _mm_shufflelo_epi16(_mm_cvtsi32_si128(alpha65535), _MM_SHUFFLE(0, 0, 0, 0));
+ __m128i vs = _mm_loadl_epi64((__m128i*)&rgba64);
+ vs = _mm_unpacklo_epi16(_mm_mullo_epi16(vs, va), _mm_mulhi_epu16(vs, va));
+ vs = _mm_add_epi32(vs, _mm_srli_epi32(vs, 16));
+ vs = _mm_add_epi32(vs, _mm_set1_epi32(0x8000));
+ vs = _mm_srai_epi32(vs, 16);
+ vs = _mm_packs_epi32(vs, _mm_setzero_si128());
+ _mm_storel_epi64((__m128i*)&rgba64, vs);
+ return rgba64;
+#else
+ return QRgba64::fromRgba64(qt_div_65535(rgba64.red() * alpha65535),
+ qt_div_65535(rgba64.green() * alpha65535),
+ qt_div_65535(rgba64.blue() * alpha65535),
+ qt_div_65535(rgba64.alpha() * alpha65535));
+#endif
+}
+
+inline QRgba64 multiplyAlpha255(QRgba64 rgba64, uint alpha255)
+{
+#ifdef __SSE2__
+ return multiplyAlpha65535(rgba64, alpha255 * 257);
+#else
+ return QRgba64::fromRgba64(qt_div_255(rgba64.red() * alpha255),
+ qt_div_255(rgba64.green() * alpha255),
+ qt_div_255(rgba64.blue() * alpha255),
+ qt_div_255(rgba64.alpha() * alpha255));
+#endif
+}
+
+inline QRgba64 interpolate256(QRgba64 x, uint alpha1, QRgba64 y, uint alpha2)
+{
+ return QRgba64::fromRgba64(multiplyAlpha256(x, alpha1) + multiplyAlpha256(y, alpha2));
+}
+
+inline QRgba64 interpolate255(QRgba64 x, uint alpha1, QRgba64 y, uint alpha2)
+{
+ return QRgba64::fromRgba64(multiplyAlpha255(x, alpha1) + multiplyAlpha255(y, alpha2));
+}
+
+inline QRgba64 interpolate65535(QRgba64 x, uint alpha1, QRgba64 y, uint alpha2)
+{
+ return QRgba64::fromRgba64(multiplyAlpha65535(x, alpha1) + multiplyAlpha65535(y, alpha2));
+}
+
+inline QRgba64 addWithSaturation(QRgba64 a, QRgba64 b)
+{
+#if defined(__SSE2__) && defined(Q_PROCESSOR_X86_64)
+ __m128i va = _mm_cvtsi64_si128((quint64)a);
+ __m128i vb = _mm_cvtsi64_si128((quint64)b);
+ va = _mm_adds_epu16(va, vb);
+ return QRgba64::fromRgba64(_mm_cvtsi128_si64(va));
+#else
+ return QRgba64::fromRgba64(qMin(a.red() + b.red(), 65535),
+ qMin(a.green() + b.green(), 65535),
+ qMin(a.blue() + b.blue(), 65535),
+ qMin(a.alpha() + b.alpha(), 65535));
+#endif
+}
+
+QT_END_NAMESPACE
+
+#endif // QRGBA64_P_H
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index 4c879cf05d..44e14f656d 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -42,16 +42,24 @@ QT_BEGIN_NAMESPACE
// #define CACHE_DEBUG
+// out-of-line to avoid vtable duplication, breaking e.g. RTTI
+QTextureGlyphCache::~QTextureGlyphCache()
+{
+}
+
int QTextureGlyphCache::calculateSubPixelPositionCount(glyph_t glyph) const
{
// Test 12 different subpixel positions since it factors into 3*4 so it gives
// the coverage we need.
- QList<QImage> images;
- for (int i=0; i<12; ++i) {
+ const int NumSubpixelPositions = 12;
+
+ QImage images[NumSubpixelPositions];
+ int numImages = 0;
+ for (int i = 0; i < NumSubpixelPositions; ++i) {
QImage img = textureMapForGlyph(glyph, QFixed::fromReal(i / 12.0));
- if (images.isEmpty()) {
+ if (numImages == 0) {
QPainterPath path;
QFixedPoint point;
m_current_fontengine->addGlyphsToPath(&glyph, &point, 1, &path, QTextItem::RenderFlags());
@@ -60,21 +68,21 @@ int QTextureGlyphCache::calculateSubPixelPositionCount(glyph_t glyph) const
if (path.isEmpty())
break;
- images.append(img);
+ images[numImages++] = qMove(img);
} else {
bool found = false;
- for (int j=0; j<images.size(); ++j) {
- if (images.at(j) == img) {
+ for (int j = 0; j < numImages; ++j) {
+ if (images[j] == img) {
found = true;
break;
}
}
if (!found)
- images.append(img);
+ images[numImages++] = qMove(img);
}
}
- return images.size();
+ return numImages;
}
bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const glyph_t *glyphs,
@@ -262,6 +270,11 @@ QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g, QFixed subPixelPosition
* QImageTextureGlyphCache
*/
+// out-of-line to avoid vtable duplication, breaking e.g. RTTI
+QImageTextureGlyphCache::~QImageTextureGlyphCache()
+{
+}
+
void QImageTextureGlyphCache::resizeTextureData(int width, int height)
{
m_image = m_image.copy(0, 0, width, height);
diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h
index c9e7060b0d..7dd8277a45 100644
--- a/src/gui/painting/qtextureglyphcache_p.h
+++ b/src/gui/painting/qtextureglyphcache_p.h
@@ -72,7 +72,7 @@ public:
m_w(0), m_h(0), m_cx(0), m_cy(0), m_currentRowHeight(0)
{ }
- virtual ~QTextureGlyphCache() { }
+ ~QTextureGlyphCache();
struct GlyphAndSubPixelPosition
{
@@ -158,6 +158,8 @@ class Q_GUI_EXPORT QImageTextureGlyphCache : public QTextureGlyphCache
public:
QImageTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix)
: QTextureGlyphCache(format, matrix) { }
+ ~QImageTextureGlyphCache();
+
virtual void createTextureData(int width, int height) Q_DECL_OVERRIDE;
virtual void resizeTextureData(int width, int height) Q_DECL_OVERRIDE;
virtual void fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition) Q_DECL_OVERRIDE;
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index a3e9db2057..a23aabe559 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -34,6 +34,7 @@
#include "qdatastream.h"
#include "qdebug.h"
+#include "qhashfunctions.h"
#include "qmatrix.h"
#include "qregion.h"
#include "qpainterpath.h"
@@ -776,6 +777,29 @@ bool QTransform::operator==(const QTransform &o) const
}
/*!
+ \since 5.6
+ \relates QTransform
+
+ Returns the hash value for \a key, using
+ \a seed to seed the calculation.
+*/
+uint qHash(const QTransform &key, uint seed) Q_DECL_NOTHROW
+{
+ QtPrivate::QHashCombine hash;
+ seed = hash(key.m11(), seed);
+ seed = hash(key.m12(), seed);
+ seed = hash(key.m21(), seed);
+ seed = hash(key.m22(), seed);
+ seed = hash(key.dx(), seed);
+ seed = hash(key.dy(), seed);
+ seed = hash(key.m13(), seed);
+ seed = hash(key.m23(), seed);
+ seed = hash(key.m33(), seed);
+ return seed;
+}
+
+
+/*!
\fn bool QTransform::operator!=(const QTransform &matrix) const
Returns \c true if this matrix is not equal to the given \a matrix,
otherwise returns \c false.
@@ -1357,7 +1381,9 @@ static QPolygonF mapProjective(const QTransform &transform, const QPolygonF &pol
path = transform.map(path);
QPolygonF result;
- for (int i = 0; i < path.elementCount(); ++i)
+ const int elementCount = path.elementCount();
+ result.reserve(elementCount);
+ for (int i = 0; i < elementCount; ++i)
result << path.elementAt(i);
return result;
}
diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h
index cf8d4d1970..65f543144d 100644
--- a/src/gui/painting/qtransform.h
+++ b/src/gui/painting/qtransform.h
@@ -180,6 +180,8 @@ private:
};
Q_DECLARE_TYPEINFO(QTransform, Q_MOVABLE_TYPE);
+Q_GUI_EXPORT Q_DECL_CONST_FUNCTION uint qHash(const QTransform &key, uint seed = 0) Q_DECL_NOTHROW;
+
/******* inlines *****/
inline QTransform::TransformationType QTransform::inline_type() const
{
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp
index 70be92535d..7735fd6b46 100644
--- a/src/gui/text/qabstracttextdocumentlayout.cpp
+++ b/src/gui/text/qabstracttextdocumentlayout.cpp
@@ -40,6 +40,15 @@
QT_BEGIN_NAMESPACE
+QAbstractTextDocumentLayoutPrivate::~QAbstractTextDocumentLayoutPrivate()
+{
+}
+
+QTextObjectInterface::~QTextObjectInterface()
+{
+ // must be empty until ### Qt 6
+}
+
/*!
\class QAbstractTextDocumentLayout
\reentrant
diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h
index 27135b0476..68e7a0e4e9 100644
--- a/src/gui/text/qabstracttextdocumentlayout.h
+++ b/src/gui/text/qabstracttextdocumentlayout.h
@@ -126,7 +126,7 @@ private:
class Q_GUI_EXPORT QTextObjectInterface
{
public:
- virtual ~QTextObjectInterface() {}
+ virtual ~QTextObjectInterface();
virtual QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) = 0;
virtual void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) = 0;
};
diff --git a/src/gui/text/qabstracttextdocumentlayout_p.h b/src/gui/text/qabstracttextdocumentlayout_p.h
index 505135fa4b..a7f28ebf96 100644
--- a/src/gui/text/qabstracttextdocumentlayout_p.h
+++ b/src/gui/text/qabstracttextdocumentlayout_p.h
@@ -58,13 +58,14 @@ struct QTextObjectHandler
};
typedef QHash<int, QTextObjectHandler> HandlerHash;
-class QAbstractTextDocumentLayoutPrivate : public QObjectPrivate
+class Q_GUI_EXPORT QAbstractTextDocumentLayoutPrivate : public QObjectPrivate
{
public:
Q_DECLARE_PUBLIC(QAbstractTextDocumentLayout)
inline QAbstractTextDocumentLayoutPrivate()
: paintDevice(0) {}
+ ~QAbstractTextDocumentLayoutPrivate();
inline void setDocument(QTextDocument *doc) {
document = doc;
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 3c98cb568d..adbb3df3bf 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -461,6 +461,7 @@ void ValueExtractor::lengthValues(const Declaration &decl, int *m)
}
QList<QVariant> v;
+ v.reserve(4);
for (i = 0; i < 4; i++) {
v += QVariant::fromValue<LengthData>(datas[i]);
m[i] = lengthValueFromData(datas[i], f);
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 3c6709e685..796f223797 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -1860,14 +1860,9 @@ void QFont::removeSubstitutions(const QString &familyName)
*/
QStringList QFont::substitutions()
{
- typedef QFontSubst::const_iterator QFontSubstConstIterator;
-
QFontSubst *fontSubst = globalFontSubst();
Q_ASSERT(fontSubst != 0);
- QStringList ret;
- const QFontSubstConstIterator cend = fontSubst->constEnd();
- for (QFontSubstConstIterator it = fontSubst->constBegin(); it != cend; ++it)
- ret.append(it.key());
+ QStringList ret = fontSubst->keys();
ret.sort();
return ret;
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 6b7a9837cb..0b0940855d 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -1369,22 +1369,30 @@ QList<QFontDatabase::WritingSystem> QFontDatabase::writingSystems() const
QT_PREPEND_NAMESPACE(load)();
- QList<WritingSystem> list;
+ quint64 writingSystemsFound = 0;
+ Q_STATIC_ASSERT(WritingSystemsCount < 64);
+
for (int i = 0; i < d->count; ++i) {
QtFontFamily *family = d->families[i];
family->ensurePopulated();
if (family->count == 0)
continue;
- for (int x = Latin; x < WritingSystemsCount; ++x) {
- const WritingSystem writingSystem = WritingSystem(x);
- if (!(family->writingSystems[writingSystem] & QtFontFamily::Supported))
- continue;
- if (!list.contains(writingSystem))
- list.append(writingSystem);
+ for (uint x = Latin; x < uint(WritingSystemsCount); ++x) {
+ if (family->writingSystems[x] & QtFontFamily::Supported)
+ writingSystemsFound |= quint64(1) << x;
}
}
- std::sort(list.begin(), list.end());
+
+ // mutex protection no longer needed - just working on local data now:
+ locker.unlock();
+
+ QList<WritingSystem> list;
+ list.reserve(qPopulationCount(writingSystemsFound));
+ for (uint x = Latin ; x < uint(WritingSystemsCount); ++x) {
+ if (writingSystemsFound & (quint64(1) << x))
+ list.push_back(WritingSystem(x));
+ }
return list;
}
diff --git a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h b/src/gui/text/qfontengineglyphcache.cpp
index 8b2a9f3788..f6fdfa3ce3 100644
--- a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h
+++ b/src/gui/text/qfontengineglyphcache.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
@@ -31,23 +31,13 @@
**
****************************************************************************/
-#ifndef QCOCOAAUTORELEASEPOOL_H
-#define QCOCOAAUTORELEASEPOOL_H
-
-#undef slots
-#include <qglobal.h>
-#include <Cocoa/Cocoa.h>
+#include <private/qfontengineglyphcache_p.h>
QT_BEGIN_NAMESPACE
-class QCocoaAutoReleasePool
+
+// out-of-line to avoid vtable duplication, breaking e.g. RTTI
+QFontEngineGlyphCache::~QFontEngineGlyphCache()
{
-public:
- QCocoaAutoReleasePool();
- ~QCocoaAutoReleasePool();
+}
-private:
- NSAutoreleasePool *pool;
-};
QT_END_NAMESPACE
-
-#endif // QCOCOAAUTORELEASEPOOL_H
diff --git a/src/gui/text/qfontengineglyphcache_p.h b/src/gui/text/qfontengineglyphcache_p.h
index 6cf4d2f1ba..def42c22a3 100644
--- a/src/gui/text/qfontengineglyphcache_p.h
+++ b/src/gui/text/qfontengineglyphcache_p.h
@@ -56,7 +56,7 @@
QT_BEGIN_NAMESPACE
-class QFontEngineGlyphCache: public QSharedData
+class Q_GUI_EXPORT QFontEngineGlyphCache: public QSharedData
{
public:
QFontEngineGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix) : m_format(format), m_transform(matrix)
@@ -64,7 +64,7 @@ public:
Q_ASSERT(m_format != QFontEngine::Format_None);
}
- virtual ~QFontEngineGlyphCache() { }
+ virtual ~QFontEngineGlyphCache();
QFontEngine::GlyphFormat glyphFormat() const { return m_format; }
const QTransform &transform() const { return m_transform; }
diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp
index 9f652084be..dc32405f36 100644
--- a/src/gui/text/qfontsubset.cpp
+++ b/src/gui/text/qfontsubset.cpp
@@ -350,6 +350,7 @@ struct qttf_head_table {
quint16 macStyle;
qint16 indexToLocFormat;
};
+Q_DECLARE_TYPEINFO(qttf_head_table, Q_PRIMITIVE_TYPE);
struct qttf_hhea_table {
@@ -362,6 +363,7 @@ struct qttf_hhea_table {
qint16 xMaxExtent;
quint16 numberOfHMetrics;
};
+Q_DECLARE_TYPEINFO(qttf_hhea_table, Q_PRIMITIVE_TYPE);
struct qttf_maxp_table {
@@ -373,6 +375,7 @@ struct qttf_maxp_table {
quint16 maxComponentElements;
quint16 maxComponentDepth;
};
+Q_DECLARE_TYPEINFO(qttf_maxp_table, Q_PRIMITIVE_TYPE);
struct qttf_name_table {
QString copyright;
@@ -380,6 +383,7 @@ struct qttf_name_table {
QString subfamily;
QString postscript_name;
};
+Q_DECLARE_TYPEINFO(qttf_name_table, Q_MOVABLE_TYPE);
static QTtfTable generateHead(const qttf_head_table &head);
@@ -411,9 +415,9 @@ Q_DECLARE_TYPEINFO(QTtfGlyph, Q_MOVABLE_TYPE);
static QTtfGlyph generateGlyph(int index, const QPainterPath &path, qreal advance, qreal lsb, qreal ppem);
// generates glyf, loca and hmtx
-static QList<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QList<QTtfGlyph> &_glyphs);
+static QVector<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QVector<QTtfGlyph> &_glyphs);
-static QByteArray bindFont(const QList<QTtfTable>& _tables);
+static QByteArray bindFont(const QVector<QTtfTable>& _tables);
static quint32 checksum(const QByteArray &table)
@@ -607,12 +611,13 @@ struct QTtfNameRecord {
quint16 nameId;
QString value;
};
+Q_DECLARE_TYPEINFO(QTtfNameRecord, Q_MOVABLE_TYPE);
-static QTtfTable generateName(const QList<QTtfNameRecord> &name);
+static QTtfTable generateName(const QVector<QTtfNameRecord> &name);
static QTtfTable generateName(const qttf_name_table &name)
{
- QList<QTtfNameRecord> list;
+ QVector<QTtfNameRecord> list;
QTtfNameRecord rec;
rec.nameId = 0;
rec.value = name.copyright;
@@ -636,7 +641,7 @@ static QTtfTable generateName(const qttf_name_table &name)
}
// ####### should probably generate Macintosh/Roman name entries as well
-static QTtfTable generateName(const QList<QTtfNameRecord> &name)
+static QTtfTable generateName(const QVector<QTtfNameRecord> &name)
{
const int char_size = 2;
@@ -707,7 +712,7 @@ struct TTF_POINT {
};
Q_DECLARE_TYPEINFO(TTF_POINT, Q_PRIMITIVE_TYPE);
-static void convertPath(const QPainterPath &path, QList<TTF_POINT> *points, QList<int> *endPoints, qreal ppem)
+static void convertPath(const QPainterPath &path, QVector<TTF_POINT> *points, QVector<int> *endPoints, qreal ppem)
{
int numElements = path.elementCount();
for (int i = 0; i < numElements - 1; ++i) {
@@ -829,7 +834,7 @@ static void convertPath(const QPainterPath &path, QList<TTF_POINT> *points, QLis
endPoints->append(points->size() - 1);
}
-static void getBounds(const QList<TTF_POINT> &points, qint16 *xmin, qint16 *xmax, qint16 *ymin, qint16 *ymax)
+static void getBounds(const QVector<TTF_POINT> &points, qint16 *xmin, qint16 *xmax, qint16 *ymin, qint16 *ymax)
{
*xmin = points.at(0).x;
*xmax = *xmin;
@@ -844,7 +849,7 @@ static void getBounds(const QList<TTF_POINT> &points, qint16 *xmin, qint16 *xmax
}
}
-static int convertToRelative(QList<TTF_POINT> *points)
+static int convertToRelative(QVector<TTF_POINT> *points)
{
// convert points to relative and setup flags
// qDebug() << "relative points:";
@@ -897,7 +902,7 @@ static int convertToRelative(QList<TTF_POINT> *points)
return point_array_size;
}
-static void getGlyphData(QTtfGlyph *glyph, const QList<TTF_POINT> &points, const QList<int> &endPoints, int point_array_size)
+static void getGlyphData(QTtfGlyph *glyph, const QVector<TTF_POINT> &points, const QVector<int> &endPoints, int point_array_size)
{
const int max_size = 5*sizeof(qint16) // header
+ endPoints.size()*sizeof(quint16) // end points of contours
@@ -947,8 +952,8 @@ static void getGlyphData(QTtfGlyph *glyph, const QList<TTF_POINT> &points, const
static QTtfGlyph generateGlyph(int index, const QPainterPath &path, qreal advance, qreal lsb, qreal ppem)
{
- QList<TTF_POINT> points;
- QList<int> endPoints;
+ QVector<TTF_POINT> points;
+ QVector<int> endPoints;
QTtfGlyph glyph;
glyph.index = index;
glyph.advanceWidth = qRound(advance * 2048. / ppem);
@@ -983,10 +988,10 @@ static bool operator <(const QTtfGlyph &g1, const QTtfGlyph &g2)
return g1.index < g2.index;
}
-static QList<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QList<QTtfGlyph> &_glyphs)
+static QVector<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QVector<QTtfGlyph> &_glyphs)
{
const int max_size_small = 65536*2;
- QList<QTtfGlyph> glyphs = _glyphs;
+ QVector<QTtfGlyph> glyphs = _glyphs;
std::sort(glyphs.begin(), glyphs.end());
Q_ASSERT(tables.maxp.numGlyphs == glyphs.at(glyphs.size()-1).index + 1);
@@ -1049,7 +1054,7 @@ static QList<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QLis
Q_ASSERT(loca.data.size() == ls.offset());
Q_ASSERT(hmtx.data.size() == hs.offset());
- QList<QTtfTable> list;
+ QVector<QTtfTable> list;
list.append(glyf);
list.append(loca);
list.append(hmtx);
@@ -1061,9 +1066,9 @@ static bool operator <(const QTtfTable &t1, const QTtfTable &t2)
return t1.tag < t2.tag;
}
-static QByteArray bindFont(const QList<QTtfTable>& _tables)
+static QByteArray bindFont(const QVector<QTtfTable>& _tables)
{
- QList<QTtfTable> tables = _tables;
+ QVector<QTtfTable> tables = _tables;
std::sort(tables.begin(), tables.end());
@@ -1154,7 +1159,7 @@ QByteArray QFontSubset::toTruetype() const
qreal ppem = fontEngine->fontDef.pixelSize;
#define TO_TTF(x) qRound(x * 2048. / ppem)
- QList<QTtfGlyph> glyphs;
+ QVector<QTtfGlyph> glyphs;
QFontEngine::Properties properties = fontEngine->properties();
// initialize some stuff needed in createWidthArray
@@ -1225,7 +1230,7 @@ QByteArray QFontSubset::toTruetype() const
}
- QList<QTtfTable> tables = generateGlyphTables(font, glyphs);
+ QVector<QTtfTable> tables = generateGlyphTables(font, glyphs);
tables.append(generateHead(font.head));
tables.append(generateHhea(font.hhea));
tables.append(generateMaxp(font.maxp));
diff --git a/src/gui/text/qfontsubset_p.h b/src/gui/text/qfontsubset_p.h
index da8589de3f..4abdb48c0d 100644
--- a/src/gui/text/qfontsubset_p.h
+++ b/src/gui/text/qfontsubset_p.h
@@ -79,7 +79,7 @@ public:
const int object_id;
bool noEmbed;
QFontEngine *fontEngine;
- QList<int> glyph_indices;
+ QVector<int> glyph_indices;
mutable int downloaded_glyphs;
mutable bool standard_font;
int nGlyphs() const { return glyph_indices.size(); }
diff --git a/src/gui/text/qglyphrun.cpp b/src/gui/text/qglyphrun.cpp
index e6d6863134..642313d340 100644
--- a/src/gui/text/qglyphrun.cpp
+++ b/src/gui/text/qglyphrun.cpp
@@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE
\ingroup text
\ingroup shared
- \mainclass
When Qt displays a string of text encoded in Unicode, it will first convert the Unicode points
into a list of glyph indexes and a list of positions based on one or more fonts. The Unicode
diff --git a/src/gui/text/qglyphrun.h b/src/gui/text/qglyphrun.h
index d3034b7546..9f51a49a6d 100644
--- a/src/gui/text/qglyphrun.h
+++ b/src/gui/text/qglyphrun.h
@@ -59,9 +59,13 @@ public:
QGlyphRun();
QGlyphRun(const QGlyphRun &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QGlyphRun &operator=(QGlyphRun &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
+ QGlyphRun &operator=(const QGlyphRun &other);
~QGlyphRun();
- void swap(QGlyphRun &other) { qSwap(d, other.d); }
+ void swap(QGlyphRun &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
QRawFont rawFont() const;
void setRawFont(const QRawFont &rawFont);
@@ -78,8 +82,6 @@ public:
void clear();
- QGlyphRun &operator=(const QGlyphRun &other);
-
bool operator==(const QGlyphRun &other) const;
inline bool operator!=(const QGlyphRun &other) const
{ return !operator==(other); }
diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h
index 0615df65d6..3331d96f8b 100644
--- a/src/gui/text/qplatformfontdatabase.h
+++ b/src/gui/text/qplatformfontdatabase.h
@@ -47,7 +47,9 @@
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QList>
+#if QT_DEPRECATED_SINCE(5, 5)
#include <QtCore/QHash>
+#endif
#include <QtGui/QFontDatabase>
#include <QtGui/private/qfontengine_p.h>
#include <QtGui/private/qfont_p.h>
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index fedf58872b..0fd5f510c7 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -55,7 +55,6 @@ QT_BEGIN_NAMESPACE
\ingroup text
\ingroup shared
- \mainclass
\note QRawFont is a low level class. For most purposes QFont is a more appropriate class.
diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h
index 3798555de5..d710658a9b 100644
--- a/src/gui/text/qrawfont.h
+++ b/src/gui/text/qrawfont.h
@@ -72,13 +72,15 @@ public:
qreal pixelSize,
QFont::HintingPreference hintingPreference = QFont::PreferDefaultHinting);
QRawFont(const QRawFont &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QRawFont &operator=(QRawFont &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
+ QRawFont &operator=(const QRawFont &other);
~QRawFont();
- bool isValid() const;
+ void swap(QRawFont &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
- QRawFont &operator=(const QRawFont &other);
-
- void swap(QRawFont &other) { qSwap(d, other.d); }
+ bool isValid() const;
bool operator==(const QRawFont &other) const;
inline bool operator!=(const QRawFont &other) const
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index fc95a859e7..5d31ab9711 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -39,6 +39,10 @@
QT_BEGIN_NAMESPACE
+QStaticTextUserData::~QStaticTextUserData()
+{
+}
+
/*!
\class QStaticText
\brief The QStaticText class enables optimized drawing of text when the text and its layout
@@ -49,7 +53,6 @@ QT_BEGIN_NAMESPACE
\ingroup multimedia
\ingroup text
\ingroup shared
- \mainclass
QStaticText provides a way to cache layout data for a block of text so that it can be drawn
more efficiently than by using QPainter::drawText() in which the layout information is
diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h
index d2825e73ac..0a1d9429b4 100644
--- a/src/gui/text/qstatictext.h
+++ b/src/gui/text/qstatictext.h
@@ -57,9 +57,13 @@ public:
QStaticText();
QStaticText(const QString &text);
QStaticText(const QStaticText &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QStaticText &operator=(QStaticText &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
+ QStaticText &operator=(const QStaticText &);
~QStaticText();
- void swap(QStaticText &other) { qSwap(data, other.data); }
+ void swap(QStaticText &other) Q_DECL_NOTHROW { qSwap(data, other.data); }
void setText(const QString &text);
QString text() const;
@@ -80,7 +84,6 @@ public:
void setPerformanceHint(PerformanceHint performanceHint);
PerformanceHint performanceHint() const;
- QStaticText &operator=(const QStaticText &);
bool operator==(const QStaticText &) const;
bool operator!=(const QStaticText &) const;
diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h
index 088e49e2fc..49ca24d51c 100644
--- a/src/gui/text/qstatictext_p.h
+++ b/src/gui/text/qstatictext_p.h
@@ -52,7 +52,8 @@
QT_BEGIN_NAMESPACE
-class QStaticTextUserData
+// ### Qt 6: Unexport again, if QOpenGLStaticTextUserData (the one from QtOpenGL) is gone by then
+class Q_GUI_EXPORT QStaticTextUserData
{
public:
enum Type {
@@ -61,7 +62,7 @@ public:
};
QStaticTextUserData(Type t) : ref(0), type(t) {}
- virtual ~QStaticTextUserData() {}
+ virtual ~QStaticTextUserData();
QAtomicInt ref;
Type type;
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index 162c646a98..f180a839b7 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -90,13 +90,13 @@ void QSyntaxHighlighterPrivate::applyFormatChanges()
QTextLayout *layout = currentBlock.layout();
- QList<QTextLayout::FormatRange> ranges = layout->additionalFormats();
+ QVector<QTextLayout::FormatRange> ranges = layout->formats();
const int preeditAreaStart = layout->preeditAreaPosition();
const int preeditAreaLength = layout->preeditAreaText().length();
if (preeditAreaLength != 0) {
- QList<QTextLayout::FormatRange>::Iterator it = ranges.begin();
+ QVector<QTextLayout::FormatRange>::Iterator it = ranges.begin();
while (it != ranges.end()) {
if (it->start >= preeditAreaStart
&& it->start + it->length <= preeditAreaStart + preeditAreaLength) {
@@ -142,7 +142,7 @@ void QSyntaxHighlighterPrivate::applyFormatChanges()
}
if (formatsChanged) {
- layout->setAdditionalFormats(ranges);
+ layout->setFormats(ranges);
doc->markContentsDirty(currentBlock.position(), currentBlock.length());
}
}
@@ -329,7 +329,7 @@ void QSyntaxHighlighter::setDocument(QTextDocument *doc)
QTextCursor cursor(d->doc);
cursor.beginEditBlock();
for (QTextBlock blk = d->doc->begin(); blk.isValid(); blk = blk.next())
- blk.layout()->clearAdditionalFormats();
+ blk.layout()->clearFormats();
cursor.endEditBlock();
}
d->doc = doc;
diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h
index f04055603c..350f38cd02 100644
--- a/src/gui/text/qtextcursor.h
+++ b/src/gui/text/qtextcursor.h
@@ -66,10 +66,13 @@ public:
explicit QTextCursor(const QTextBlock &block);
explicit QTextCursor(QTextCursorPrivate *d);
QTextCursor(const QTextCursor &cursor);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QTextCursor &operator=(QTextCursor &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QTextCursor &operator=(const QTextCursor &other);
~QTextCursor();
- void swap(QTextCursor &other) { qSwap(d, other.d); }
+ void swap(QTextCursor &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool isNull() const;
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index d3b70aaf26..3d248f4afc 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -1949,7 +1949,7 @@ void QTextDocument::print(QPagedPaintDevice *printer) const
for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock();
srcBlock.isValid() && dstBlock.isValid();
srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) {
- dstBlock.layout()->setAdditionalFormats(srcBlock.layout()->additionalFormats());
+ dstBlock.layout()->setFormats(srcBlock.layout()->formats());
}
QAbstractTextDocumentLayout *layout = doc->documentLayout();
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index 5864ca0b1a..7d75e649b0 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -106,7 +106,7 @@ public:
bool sizeDirty;
bool layoutDirty;
- QList<QPointer<QTextFrame> > floats;
+ QVector<QPointer<QTextFrame> > floats;
};
QTextFrameData::QTextFrameData()
@@ -1071,7 +1071,9 @@ void QTextDocumentLayoutPrivate::drawFrame(const QPointF &offset, QPainter *pain
it = frameIteratorForYPosition(QFixed::fromReal(context.clip.top()));
QList<QTextFrame *> floats;
- for (int i = 0; i < fd->floats.count(); ++i)
+ const int numFloats = fd->floats.count();
+ floats.reserve(numFloats);
+ for (int i = 0; i < numFloats; ++i)
floats.append(fd->floats.at(i));
drawFlow(off, painter, context, it, floats, &cursorBlockNeedingRepaint);
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 67a19804a3..e87711ef99 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -2571,7 +2571,7 @@ void QTextEngine::setPreeditArea(int position, const QString &preeditText)
clearLineData();
}
-void QTextEngine::setFormats(const QList<QTextLayout::FormatRange> &formats)
+void QTextEngine::setFormats(const QVector<QTextLayout::FormatRange> &formats)
{
if (formats.isEmpty()) {
if (!specialData)
@@ -2863,6 +2863,7 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const
if (!tabArray.isEmpty()) {
if (isRightToLeft()) { // rebase the tabArray positions.
QList<QTextOption::Tab> newTabs;
+ newTabs.reserve(tabArray.count());
QList<QTextOption::Tab>::Iterator iter = tabArray.begin();
while(iter != tabArray.end()) {
QTextOption::Tab tab = *iter;
@@ -2946,17 +2947,17 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const
namespace {
class FormatRangeComparatorByStart {
- const QList<QTextLayout::FormatRange> &list;
+ const QVector<QTextLayout::FormatRange> &list;
public:
- FormatRangeComparatorByStart(const QList<QTextLayout::FormatRange> &list) : list(list) { }
+ FormatRangeComparatorByStart(const QVector<QTextLayout::FormatRange> &list) : list(list) { }
bool operator()(int a, int b) {
return list.at(a).start < list.at(b).start;
}
};
class FormatRangeComparatorByEnd {
- const QList<QTextLayout::FormatRange> &list;
+ const QVector<QTextLayout::FormatRange> &list;
public:
- FormatRangeComparatorByEnd(const QList<QTextLayout::FormatRange> &list) : list(list) { }
+ FormatRangeComparatorByEnd(const QVector<QTextLayout::FormatRange> &list) : list(list) { }
bool operator()(int a, int b) {
return list.at(a).start + list.at(a).length < list.at(b).start + list.at(b).length;
}
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 39b9e0cb5a..3590c6da07 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -570,9 +570,9 @@ public:
inline bool hasFormats() const
{ return block.docHandle() || (specialData && !specialData->formats.isEmpty()); }
- inline QList<QTextLayout::FormatRange> formats() const
- { return specialData ? specialData->formats : QList<QTextLayout::FormatRange>(); }
- void setFormats(const QList<QTextLayout::FormatRange> &formats);
+ inline QVector<QTextLayout::FormatRange> formats() const
+ { return specialData ? specialData->formats : QVector<QTextLayout::FormatRange>(); }
+ void setFormats(const QVector<QTextLayout::FormatRange> &formats);
private:
static void init(QTextEngine *e);
@@ -580,7 +580,7 @@ private:
struct SpecialData {
int preeditPosition;
QString preeditText;
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
QVector<QTextCharFormat> resolvedFormats;
// only used when no docHandle is available
QScopedPointer<QTextFormatCollection> formatCollection;
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index ba4bdcc5ad..7dcd060ba1 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -38,7 +38,7 @@
#include <qdatastream.h>
#include <qdebug.h>
#include <qmap.h>
-#include <qhash.h>
+#include <qhashfunctions.h>
QT_BEGIN_NAMESPACE
@@ -1115,7 +1115,9 @@ void QTextFormat::setProperty(int propertyId, const QVector<QTextLength> &value)
if (!d)
d = new QTextFormatPrivate;
QVariantList list;
- for (int i=0; i<value.size(); ++i)
+ const int numValues = value.size();
+ list.reserve(numValues);
+ for (int i = 0; i < numValues; ++i)
list << value.at(i);
d->insertProperty(propertyId, list);
}
@@ -2041,6 +2043,7 @@ QTextBlockFormat::QTextBlockFormat(const QTextFormat &fmt)
void QTextBlockFormat::setTabPositions(const QList<QTextOption::Tab> &tabs)
{
QList<QVariant> list;
+ list.reserve(tabs.count());
QList<QTextOption::Tab>::ConstIterator iter = tabs.constBegin();
while (iter != tabs.constEnd()) {
QVariant v;
@@ -2065,6 +2068,7 @@ QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const
QList<QTextOption::Tab> answer;
QList<QVariant> variantsList = qvariant_cast<QList<QVariant> >(variant);
QList<QVariant>::Iterator iter = variantsList.begin();
+ answer.reserve(variantsList.count());
while(iter != variantsList.end()) {
answer.append( qvariant_cast<QTextOption::Tab>(*iter));
++iter;
diff --git a/src/gui/text/qtextformat_p.h b/src/gui/text/qtextformat_p.h
index 29656bbafe..928cef6488 100644
--- a/src/gui/text/qtextformat_p.h
+++ b/src/gui/text/qtextformat_p.h
@@ -47,7 +47,6 @@
#include "QtGui/qtextformat.h"
#include "QtCore/qvector.h"
-#include "QtCore/qhash.h"
QT_BEGIN_NAMESPACE
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 7da3e84041..c42054c07c 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE
for a specified area in the text layout's content.
\inmodule QtGui
- \sa QTextLayout::setAdditionalFormats(), QTextLayout::draw()
+ \sa QTextLayout::setFormats(), QTextLayout::draw()
*/
/*!
@@ -485,7 +485,6 @@ QString QTextLayout::preeditAreaText() const
return d->preeditAreaText();
}
-
/*!
Sets the additional formats supported by the text layout to \a formatList.
The formats are applied with preedit area text in place.
@@ -494,7 +493,20 @@ QString QTextLayout::preeditAreaText() const
*/
void QTextLayout::setAdditionalFormats(const QList<FormatRange> &formatList)
{
- d->setFormats(formatList);
+ setFormats(formatList.toVector());
+}
+
+/*!
+ \since 5.6
+
+ Sets the additional formats supported by the text layout to \a formats.
+ The formats are applied with preedit area text in place.
+
+ \sa formats(), clearFormats()
+*/
+void QTextLayout::setFormats(const QVector<FormatRange> &formats)
+{
+ d->setFormats(formats);
if (d->block.docHandle())
d->block.docHandle()->documentChange(d->block.position(), d->block.length());
@@ -507,6 +519,18 @@ void QTextLayout::setAdditionalFormats(const QList<FormatRange> &formatList)
*/
QList<QTextLayout::FormatRange> QTextLayout::additionalFormats() const
{
+ return formats().toList();
+}
+
+/*!
+ \since 5.6
+
+ Returns the list of additional formats supported by the text layout.
+
+ \sa setFormats(), clearFormats()
+*/
+QVector<QTextLayout::FormatRange> QTextLayout::formats() const
+{
return d->formats();
}
@@ -517,7 +541,19 @@ QList<QTextLayout::FormatRange> QTextLayout::additionalFormats() const
*/
void QTextLayout::clearAdditionalFormats()
{
- setAdditionalFormats(QList<FormatRange>());
+ clearFormats();
+}
+
+/*!
+ \since 5.6
+
+ Clears the list of additional formats supported by the text layout.
+
+ \sa formats(), setFormats()
+*/
+void QTextLayout::clearFormats()
+{
+ setFormats(QVector<FormatRange>());
}
/*!
diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
index 47dcd388e2..9709af4fd1 100644
--- a/src/gui/text/qtextlayout.h
+++ b/src/gui/text/qtextlayout.h
@@ -125,10 +125,18 @@ public:
int start;
int length;
QTextCharFormat format;
+
+ friend bool operator==(const FormatRange &lhs, const FormatRange &rhs)
+ { return lhs.start == rhs.start && lhs.length == rhs.length && lhs.format == rhs.format; }
+ friend bool operator!=(const FormatRange &lhs, const FormatRange &rhs)
+ { return !operator==(lhs, rhs); }
};
void setAdditionalFormats(const QList<FormatRange> &overrides);
QList<FormatRange> additionalFormats() const;
void clearAdditionalFormats();
+ void setFormats(const QVector<FormatRange> &overrides);
+ QVector<FormatRange> formats() const;
+ void clearFormats();
void setCacheEnabled(bool enable);
bool cacheEnabled() const;
diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp
index dbafcfd58e..5a4f6b7954 100644
--- a/src/gui/text/qtextoption.cpp
+++ b/src/gui/text/qtextoption.cpp
@@ -146,6 +146,7 @@ void QTextOption::setTabArray(const QList<qreal> &tabStops)
d = new QTextOptionPrivate;
QList<QTextOption::Tab> tabs;
QTextOption::Tab tab;
+ tabs.reserve(tabStops.count());
foreach (qreal pos, tabStops) {
tab.position = pos;
tabs.append(tab);
@@ -174,10 +175,11 @@ void QTextOption::setTabs(const QList<QTextOption::Tab> &tabStops)
*/
QList<qreal> QTextOption::tabArray() const
{
+ QList<qreal> answer;
if (!d)
- return QList<qreal>();
+ return answer;
- QList<qreal> answer;
+ answer.reserve(d->tabStops.count());
QList<QTextOption::Tab>::ConstIterator iter = d->tabStops.constBegin();
while(iter != d->tabStops.constEnd()) {
answer.append( (*iter).position);
diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp
index 1d621db0e6..40088d573a 100644
--- a/src/gui/text/qzip.cpp
+++ b/src/gui/text/qzip.cpp
@@ -303,6 +303,7 @@ enum HostOS {
HostOS400 = 18,
HostOSX = 19
};
+Q_DECLARE_TYPEINFO(HostOS, Q_PRIMITIVE_TYPE);
enum GeneralPurposeFlag {
Encrypted = 0x01,
@@ -314,6 +315,7 @@ enum GeneralPurposeFlag {
Utf8Names = 0x0800,
CentralDirectoryEncrypted = 0x2000
};
+Q_DECLARE_TYPEINFO(GeneralPurposeFlag, Q_PRIMITIVE_TYPE);
enum CompressionMethod {
CompressionMethodStored = 0,
@@ -340,6 +342,7 @@ enum CompressionMethod {
CompressionMethodPPMd = 98,
CompressionMethodWzAES = 99
};
+Q_DECLARE_TYPEINFO(CompressionMethod, Q_PRIMITIVE_TYPE);
struct LocalFileHeader
{
@@ -354,6 +357,7 @@ struct LocalFileHeader
uchar file_name_length[2];
uchar extra_field_length[2];
};
+Q_DECLARE_TYPEINFO(LocalFileHeader, Q_PRIMITIVE_TYPE);
struct DataDescriptor
{
@@ -361,6 +365,7 @@ struct DataDescriptor
uchar compressed_size[4];
uchar uncompressed_size[4];
};
+Q_DECLARE_TYPEINFO(DataDescriptor, Q_PRIMITIVE_TYPE);
struct CentralFileHeader
{
@@ -382,6 +387,7 @@ struct CentralFileHeader
uchar offset_local_header[4];
LocalFileHeader toLocalHeader() const;
};
+Q_DECLARE_TYPEINFO(CentralFileHeader, Q_PRIMITIVE_TYPE);
struct EndOfDirectory
{
@@ -394,6 +400,7 @@ struct EndOfDirectory
uchar dir_start_offset[4];
uchar comment_length[2];
};
+Q_DECLARE_TYPEINFO(EndOfDirectory, Q_PRIMITIVE_TYPE);
struct FileHeader
{
@@ -402,6 +409,7 @@ struct FileHeader
QByteArray extra_field;
QByteArray file_comment;
};
+Q_DECLARE_TYPEINFO(FileHeader, Q_MOVABLE_TYPE);
QZipReader::FileInfo::FileInfo()
: isDir(false), isFile(false), isSymLink(false), crc(0), size(0)
@@ -917,7 +925,9 @@ QList<QZipReader::FileInfo> QZipReader::fileInfoList() const
{
d->scanFiles();
QList<QZipReader::FileInfo> files;
- for (int i = 0; i < d->fileHeaders.size(); ++i) {
+ const int numFileHeaders = d->fileHeaders.size();
+ files.reserve(numFileHeaders);
+ for (int i = 0; i < numFileHeaders; ++i) {
QZipReader::FileInfo fi;
d->fillFileInfo(i, fi);
files.append(fi);
diff --git a/src/gui/text/qzipreader_p.h b/src/gui/text/qzipreader_p.h
index df7e2d26e9..7a18dc7340 100644
--- a/src/gui/text/qzipreader_p.h
+++ b/src/gui/text/qzipreader_p.h
@@ -111,6 +111,8 @@ private:
QZipReaderPrivate *d;
Q_DISABLE_COPY(QZipReader)
};
+Q_DECLARE_TYPEINFO(QZipReader::FileInfo, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QZipReader::Status, Q_PRIMITIVE_TYPE);
QT_END_NAMESPACE
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index 61e239f678..be60ba72cc 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -21,6 +21,7 @@ HEADERS += \
text/qtextdocument_p.h \
text/qtexthtmlparser_p.h \
text/qabstracttextdocumentlayout.h \
+ text/qabstracttextdocumentlayout_p.h \
text/qtextdocumentlayout_p.h \
text/qtextcursor.h \
text/qtextcursor_p.h \
@@ -47,6 +48,7 @@ HEADERS += \
SOURCES += \
text/qfont.cpp \
text/qfontengine.cpp \
+ text/qfontengineglyphcache.cpp \
text/qfontsubset.cpp \
text/qfontmetrics.cpp \
text/qfontdatabase.cpp \
diff --git a/src/network/access/qabstractnetworkcache.h b/src/network/access/qabstractnetworkcache.h
index 352daa9700..73f05176d4 100644
--- a/src/network/access/qabstractnetworkcache.h
+++ b/src/network/access/qabstractnetworkcache.h
@@ -60,9 +60,12 @@ public:
QNetworkCacheMetaData(const QNetworkCacheMetaData &other);
~QNetworkCacheMetaData();
+#ifdef Q_COMPILER_RVALUE_REFS
+ QNetworkCacheMetaData &operator=(QNetworkCacheMetaData &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QNetworkCacheMetaData &operator=(const QNetworkCacheMetaData &other);
- void swap(QNetworkCacheMetaData &other)
+ void swap(QNetworkCacheMetaData &other) Q_DECL_NOTHROW
{ qSwap(d, other.d); }
bool operator==(const QNetworkCacheMetaData &other) const;
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp
index a83d56f31f..74c95ecd5e 100644
--- a/src/network/access/qftp.cpp
+++ b/src/network/access/qftp.cpp
@@ -46,7 +46,6 @@
#include "qregexp.h"
#include "qtimer.h"
#include "qfileinfo.h"
-#include "qhash.h"
#include "qtcpserver.h"
#include "qlocale.h"
diff --git a/src/network/access/qhttpmultipart.h b/src/network/access/qhttpmultipart.h
index 2e08a3d6f8..dd8b733426 100644
--- a/src/network/access/qhttpmultipart.h
+++ b/src/network/access/qhttpmultipart.h
@@ -51,9 +51,12 @@ public:
QHttpPart();
QHttpPart(const QHttpPart &other);
~QHttpPart();
+#ifdef Q_COMPILER_RVALUE_REFS
+ QHttpPart &operator=(QHttpPart &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QHttpPart &operator=(const QHttpPart &other);
- void swap(QHttpPart &other) { qSwap(d, other.d); }
+ void swap(QHttpPart &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool operator==(const QHttpPart &other) const;
inline bool operator!=(const QHttpPart &other) const
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 7a848dcfcd..16ed67fbc0 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -506,6 +506,53 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket
return false;
}
+QUrl QHttpNetworkConnectionPrivate::parseRedirectResponse(QAbstractSocket *socket, QHttpNetworkReply *reply)
+{
+ if (!reply->request().isFollowRedirects())
+ return QUrl();
+
+ QUrl rUrl;
+ QList<QPair<QByteArray, QByteArray> > fields = reply->header();
+ foreach (const QNetworkReply::RawHeaderPair &header, fields) {
+ if (header.first.toLower() == "location") {
+ rUrl = QUrl::fromEncoded(header.second);
+ break;
+ }
+ }
+
+ // If the location url is invalid/empty, we emit ProtocolUnknownError
+ if (!rUrl.isValid()) {
+ emitReplyError(socket, reply, QNetworkReply::ProtocolUnknownError);
+ return QUrl();
+ }
+
+ // Check if we have exceeded max redirects allowed
+ if (reply->request().redirectCount() <= 0) {
+ emitReplyError(socket, reply, QNetworkReply::TooManyRedirectsError);
+ return QUrl();
+ }
+
+ // Resolve the URL if it's relative
+ if (rUrl.isRelative())
+ rUrl = reply->request().url().resolved(rUrl);
+
+ // Check redirect url protocol
+ QString scheme = rUrl.scheme();
+ if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) {
+ QString previousUrlScheme = reply->request().url().scheme();
+ // Check if we're doing an unsecure redirect (https -> http)
+ if (previousUrlScheme == QLatin1String("https")
+ && scheme == QLatin1String("http")) {
+ emitReplyError(socket, reply, QNetworkReply::InsecureRedirectError);
+ return QUrl();
+ }
+ } else {
+ emitReplyError(socket, reply, QNetworkReply::ProtocolUnknownError);
+ return QUrl();
+ }
+ return rUrl;
+}
+
void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket, QHttpNetworkRequest &request)
{
Q_ASSERT(socket);
@@ -802,6 +849,12 @@ QString QHttpNetworkConnectionPrivate::errorDetail(QNetworkReply::NetworkError e
case QNetworkReply::SslHandshakeFailedError:
errorString = QCoreApplication::translate("QHttp", "SSL handshake failed");
break;
+ case QNetworkReply::TooManyRedirectsError:
+ errorString = QCoreApplication::translate("QHttp", "Too many redirects");
+ break;
+ case QNetworkReply::InsecureRedirectError:
+ errorString = QCoreApplication::translate("QHttp", "Insecure redirect");
+ break;
default:
// all other errors are treated as QNetworkReply::UnknownNetworkError
errorString = extraDetail;
@@ -1390,7 +1443,7 @@ void QHttpNetworkConnectionPrivate::emitProxyAuthenticationRequired(const QHttpN
// but that does not matter because the signal will ultimately be emitted
// by the QNetworkAccessManager.
Q_ASSERT(chan->spdyRequestsToSend.count() > 0);
- reply = chan->spdyRequestsToSend.values().first().second;
+ reply = chan->spdyRequestsToSend.cbegin().value().second;
} else { // HTTP
#endif // QT_NO_SSL
reply = chan->reply;
diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h
index 115eef581e..9af39d416a 100644
--- a/src/network/access/qhttpnetworkconnection_p.h
+++ b/src/network/access/qhttpnetworkconnection_p.h
@@ -250,6 +250,7 @@ public:
void emitReplyError(QAbstractSocket *socket, QHttpNetworkReply *reply, QNetworkReply::NetworkError errorCode);
bool handleAuthenticateChallenge(QAbstractSocket *socket, QHttpNetworkReply *reply, bool isProxy, bool &resend);
+ QUrl parseRedirectResponse(QAbstractSocket *socket, QHttpNetworkReply *reply);
#ifndef QT_NO_NETWORKPROXY
QNetworkProxy networkProxy;
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index ef40d8cb2a..98247b7df0 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -507,6 +507,20 @@ void QHttpNetworkConnectionChannel::handleStatus()
bool resend = false;
switch (statusCode) {
+ case 301:
+ case 302:
+ case 303:
+ case 305:
+ case 307: {
+ // Parse the response headers and get the "location" url
+ QUrl redirectUrl = connection->d_func()->parseRedirectResponse(socket, reply);
+ if (redirectUrl.isValid())
+ reply->setRedirectUrl(redirectUrl);
+
+ if (qobject_cast<QHttpNetworkConnection *>(connection))
+ QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
+ break;
+ }
case 401: // auth required
case 407: // proxy auth required
if (connection->d_func()->handleAuthenticateChallenge(socket, reply, (statusCode == 407), resend)) {
diff --git a/src/network/access/qhttpnetworkheader.cpp b/src/network/access/qhttpnetworkheader.cpp
index af9f38cdec..cf8259294d 100644
--- a/src/network/access/qhttpnetworkheader.cpp
+++ b/src/network/access/qhttpnetworkheader.cpp
@@ -79,16 +79,8 @@ QByteArray QHttpNetworkHeaderPrivate::headerField(const QByteArray &name, const
QList<QByteArray> allValues = headerFieldValues(name);
if (allValues.isEmpty())
return defaultValue;
-
- QByteArray result;
- bool first = true;
- foreach (const QByteArray &value, allValues) {
- if (!first)
- result += ", ";
- first = false;
- result += value;
- }
- return result;
+ else
+ return allValues.join(", ");
}
QList<QByteArray> QHttpNetworkHeaderPrivate::headerFieldValues(const QByteArray &name) const
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
index 2063ca6bd0..172d4dab5b 100644
--- a/src/network/access/qhttpnetworkreply.cpp
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -78,6 +78,23 @@ void QHttpNetworkReply::setUrl(const QUrl &url)
d->url = url;
}
+QUrl QHttpNetworkReply::redirectUrl() const
+{
+ return d_func()->redirectUrl;
+}
+
+void QHttpNetworkReply::setRedirectUrl(const QUrl &url)
+{
+ Q_D(QHttpNetworkReply);
+ d->redirectUrl = url;
+}
+
+bool QHttpNetworkReply::isHttpRedirect(int statusCode)
+{
+ return (statusCode == 301 || statusCode == 302 || statusCode == 303
+ || statusCode == 305 || statusCode == 307);
+}
+
qint64 QHttpNetworkReply::contentLength() const
{
return d_func()->contentLength();
@@ -267,6 +284,11 @@ void QHttpNetworkReply::setSpdyWasUsed(bool spdy)
d_func()->spdyUsed = spdy;
}
+bool QHttpNetworkReply::isRedirecting() const
+{
+ return d_func()->isRedirecting();
+}
+
QHttpNetworkConnection* QHttpNetworkReply::connection()
{
return d_func()->connection;
@@ -910,6 +932,14 @@ qint64 QHttpNetworkReplyPrivate::getChunkSize(QAbstractSocket *socket, qint64 *c
return bytes;
}
+bool QHttpNetworkReplyPrivate::isRedirecting() const
+{
+ // We're in the process of redirecting - if the HTTP status code says so and
+ // followRedirect is switched on
+ return (QHttpNetworkReply::isHttpRedirect(statusCode)
+ && request.isFollowRedirects());
+}
+
bool QHttpNetworkReplyPrivate::shouldEmitSignals()
{
// for 401 & 407 don't emit the data signals. Content along with these
diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h
index 0fe298da27..6e81663500 100644
--- a/src/network/access/qhttpnetworkreply_p.h
+++ b/src/network/access/qhttpnetworkreply_p.h
@@ -127,8 +127,15 @@ public:
bool isSpdyUsed() const;
void setSpdyWasUsed(bool spdy);
+ bool isRedirecting() const;
+
QHttpNetworkConnection* connection();
+ QUrl redirectUrl() const;
+ void setRedirectUrl(const QUrl &url);
+
+ static bool isHttpRedirect(int statusCode);
+
#ifndef QT_NO_SSL
QSslConfiguration sslConfiguration() const;
void setSslConfiguration(const QSslConfiguration &config);
@@ -153,6 +160,7 @@ Q_SIGNALS:
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
#endif
void authenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *authenticator);
+ void redirected(const QUrl &url, int httpStatus, int maxRedirectsRemaining);
private:
Q_DECLARE_PRIVATE(QHttpNetworkReply)
friend class QHttpSocketEngine;
@@ -185,6 +193,7 @@ public:
qint64 readReplyBodyChunked(QAbstractSocket *in, QByteDataBuffer *out);
qint64 getChunkSize(QAbstractSocket *in, qint64 *chunkSize);
+ bool isRedirecting() const;
bool shouldEmitSignals();
bool expectContent();
void eraseData();
@@ -245,6 +254,7 @@ public:
bool downstreamLimited;
char* userProvidedDownloadBuffer;
+ QUrl redirectUrl;
#ifndef QT_NO_COMPRESS
z_stream_s *inflateStrm;
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp
index ea1cd3d591..64172fc4fd 100644
--- a/src/network/access/qhttpnetworkrequest.cpp
+++ b/src/network/access/qhttpnetworkrequest.cpp
@@ -42,7 +42,7 @@ QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(QHttpNetworkRequest::Oper
QHttpNetworkRequest::Priority pri, const QUrl &newUrl)
: QHttpNetworkHeaderPrivate(newUrl), operation(op), priority(pri), uploadByteDevice(0),
autoDecompress(false), pipeliningAllowed(false), spdyAllowed(false),
- withCredentials(true), preConnect(false)
+ withCredentials(true), preConnect(false), followRedirect(false), redirectCount(0)
{
}
@@ -59,6 +59,8 @@ QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(const QHttpNetworkRequest
withCredentials = other.withCredentials;
ssl = other.ssl;
preConnect = other.preConnect;
+ followRedirect = other.followRedirect;
+ redirectCount = other.redirectCount;
}
QHttpNetworkRequestPrivate::~QHttpNetworkRequestPrivate()
@@ -217,6 +219,26 @@ void QHttpNetworkRequest::setPreConnect(bool preConnect)
d->preConnect = preConnect;
}
+bool QHttpNetworkRequest::isFollowRedirects() const
+{
+ return d->followRedirect;
+}
+
+void QHttpNetworkRequest::setFollowRedirects(bool followRedirect)
+{
+ d->followRedirect = followRedirect;
+}
+
+int QHttpNetworkRequest::redirectCount() const
+{
+ return d->redirectCount;
+}
+
+void QHttpNetworkRequest::setRedirectCount(int count)
+{
+ d->redirectCount = count;
+}
+
qint64 QHttpNetworkRequest::contentLength() const
{
return d->contentLength();
diff --git a/src/network/access/qhttpnetworkrequest_p.h b/src/network/access/qhttpnetworkrequest_p.h
index d136f22b7d..1add3c6150 100644
--- a/src/network/access/qhttpnetworkrequest_p.h
+++ b/src/network/access/qhttpnetworkrequest_p.h
@@ -118,6 +118,12 @@ public:
bool isPreConnect() const;
void setPreConnect(bool preConnect);
+ bool isFollowRedirects() const;
+ void setFollowRedirects(bool followRedirect);
+
+ int redirectCount() const;
+ void setRedirectCount(int count);
+
void setUploadByteDevice(QNonContiguousByteDevice *bd);
QNonContiguousByteDevice* uploadByteDevice() const;
@@ -154,6 +160,8 @@ public:
bool withCredentials;
bool ssl;
bool preConnect;
+ bool followRedirect;
+ int redirectCount;
};
diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp
index be6fa01098..3fc4fa9dee 100644
--- a/src/network/access/qhttpthreaddelegate.cpp
+++ b/src/network/access/qhttpthreaddelegate.cpp
@@ -496,6 +496,9 @@ void QHttpThreadDelegate::finishedSlot()
emit error(statusCodeFromHttp(httpReply->statusCode(), httpRequest.url()), msg);
}
+ if (httpRequest.isFollowRedirects() && httpReply->isRedirecting())
+ emit redirected(httpReply->redirectUrl(), httpReply->statusCode(), httpReply->request().redirectCount() - 1);
+
emit downloadFinished();
QMetaObject::invokeMethod(httpReply, "deleteLater", Qt::QueuedConnection);
diff --git a/src/network/access/qhttpthreaddelegate_p.h b/src/network/access/qhttpthreaddelegate_p.h
index 9573d500ea..784e9c14b8 100644
--- a/src/network/access/qhttpthreaddelegate_p.h
+++ b/src/network/access/qhttpthreaddelegate_p.h
@@ -139,6 +139,8 @@ signals:
void downloadData(QByteArray);
void error(QNetworkReply::NetworkError, const QString);
void downloadFinished();
+ void redirected(const QUrl &url, int httpStatus, int maxRedirectsRemainig);
+
public slots:
// This are called via QueuedConnection from user thread
void startRequest();
diff --git a/src/network/access/qnetworkaccessauthenticationmanager_p.h b/src/network/access/qnetworkaccessauthenticationmanager_p.h
index 8f06ecb6b7..462827d7fc 100644
--- a/src/network/access/qnetworkaccessauthenticationmanager_p.h
+++ b/src/network/access/qnetworkaccessauthenticationmanager_p.h
@@ -64,7 +64,7 @@ public:
QString domain;
QString user;
QString password;
- bool isNull() {
+ bool isNull() const {
return domain.isNull() && user.isNull() && password.isNull();
}
};
diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp
index 692af1b2fc..321352e045 100644
--- a/src/network/access/qnetworkaccessbackend.cpp
+++ b/src/network/access/qnetworkaccessbackend.cpp
@@ -37,7 +37,6 @@
#include "qnetworkrequest.h"
#include "qnetworkreply.h"
#include "qnetworkreply_p.h"
-#include "QtCore/qhash.h"
#include "QtCore/qmutex.h"
#include "QtCore/qstringlist.h"
#include "QtNetwork/private/qnetworksession_p.h"
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index e878feb2bf..bcd82d1433 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -447,7 +447,6 @@ static void ensureInitialized()
QNetworkAccessManager::QNetworkAccessManager(QObject *parent)
: QObject(*new QNetworkAccessManagerPrivate, parent)
{
- Q_D(QNetworkAccessManager);
ensureInitialized();
qRegisterMetaType<QNetworkReply::NetworkError>();
@@ -467,6 +466,7 @@ QNetworkAccessManager::QNetworkAccessManager(QObject *parent)
qRegisterMetaType<QSharedPointer<char> >();
#ifndef QT_NO_BEARERMANAGEMENT
+ Q_D(QNetworkAccessManager);
if (!d->networkSessionRequired) {
// if a session is required, we track online state through
// the QNetworkSession's signals
diff --git a/src/network/access/qnetworkcookie.h b/src/network/access/qnetworkcookie.h
index 2da86d3f81..27925c8201 100644
--- a/src/network/access/qnetworkcookie.h
+++ b/src/network/access/qnetworkcookie.h
@@ -59,9 +59,12 @@ public:
explicit QNetworkCookie(const QByteArray &name = QByteArray(), const QByteArray &value = QByteArray());
QNetworkCookie(const QNetworkCookie &other);
~QNetworkCookie();
+#ifdef Q_COMPILER_RVALUE_REFS
+ QNetworkCookie &operator=(QNetworkCookie &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QNetworkCookie &operator=(const QNetworkCookie &other);
- void swap(QNetworkCookie &other) { qSwap(d, other.d); }
+ void swap(QNetworkCookie &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool operator==(const QNetworkCookie &other) const;
inline bool operator!=(const QNetworkCookie &other) const
diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp
index 3e77e1b874..26f7034c09 100644
--- a/src/network/access/qnetworkreply.cpp
+++ b/src/network/access/qnetworkreply.cpp
@@ -132,6 +132,14 @@ QNetworkReplyPrivate::QNetworkReplyPrivate()
\value BackgroundRequestNotAllowedError the background request
is not currently allowed due to platform policy.
+ \value TooManyRedirectsError while following redirects, the maximum
+ limit was reached. The limit is by default set to 50 or as set by
+ QNetworkRequest::setMaxRedirectsAllowed().
+
+ \value InsecureRedirectError while following redirects, the network
+ access API detected a redirect from a encrypted protocol (https) to an
+ unencrypted one (http).
+
\value ProxyConnectionRefusedError the connection to the proxy
server was refused (the proxy server is not accepting requests)
@@ -276,6 +284,19 @@ QNetworkReplyPrivate::QNetworkReplyPrivate()
*/
/*!
+ \fn void QNetworkReply::redirected(const QUrl &url)
+ \since 5.6
+
+ This signal is emitted if the QNetworkRequest::FollowRedirectsAttribute was
+ set in the request and the server responded with a 3xx status (specifically
+ 301, 302, 303, 305 or 307 status code) with a valid url in the location
+ header, indicating a HTTP redirect. The \a url parameter contains the new
+ redirect url as returned by the server in the location header.
+
+ \sa QNetworkRequest::FollowRedirectsAttribute
+*/
+
+/*!
\fn void QNetworkReply::metaDataChanged()
\omit FIXME: Update name? \endomit
@@ -498,7 +519,7 @@ QNetworkAccessManager *QNetworkReply::manager() const
*/
QNetworkRequest QNetworkReply::request() const
{
- return d_func()->request;
+ return d_func()->originalRequest;
}
/*!
@@ -549,9 +570,12 @@ bool QNetworkReply::isRunning() const
/*!
Returns the URL of the content downloaded or uploaded. Note that
- the URL may be different from that of the original request.
+ the URL may be different from that of the original request. If the
+ QNetworkRequest::FollowRedirectsAttribute was set in the request, then this
+ function returns the current url that the network API is accessing, i.e the
+ url emitted in the QNetworkReply::redirected signal.
- \sa request(), setUrl(), QNetworkRequest::url()
+ \sa request(), setUrl(), QNetworkRequest::url(), redirected()
*/
QUrl QNetworkReply::url() const
{
@@ -794,7 +818,7 @@ void QNetworkReply::setOperation(QNetworkAccessManager::Operation operation)
void QNetworkReply::setRequest(const QNetworkRequest &request)
{
Q_D(QNetworkReply);
- d->request = request;
+ d->originalRequest = request;
}
/*!
diff --git a/src/network/access/qnetworkreply.h b/src/network/access/qnetworkreply.h
index 91c9e77d8d..672a69e12b 100644
--- a/src/network/access/qnetworkreply.h
+++ b/src/network/access/qnetworkreply.h
@@ -69,6 +69,8 @@ public:
TemporaryNetworkFailureError,
NetworkSessionFailedError,
BackgroundRequestNotAllowedError,
+ TooManyRedirectsError,
+ InsecureRedirectError,
UnknownNetworkError = 99,
// proxy errors (101-199):
@@ -153,6 +155,7 @@ Q_SIGNALS:
void sslErrors(const QList<QSslError> &errors);
void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator);
#endif
+ void redirected(const QUrl &url);
void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
diff --git a/src/network/access/qnetworkreply_p.h b/src/network/access/qnetworkreply_p.h
index f5fe7bd844..2a3a2e4297 100644
--- a/src/network/access/qnetworkreply_p.h
+++ b/src/network/access/qnetworkreply_p.h
@@ -69,6 +69,7 @@ public:
QNetworkReplyPrivate();
QNetworkRequest request;
+ QNetworkRequest originalRequest;
QUrl url;
QPointer<QNetworkAccessManager> manager;
qint64 readBufferMaxSize;
diff --git a/src/network/access/qnetworkreplyfileimpl.cpp b/src/network/access/qnetworkreplyfileimpl.cpp
index 8f51b2ca3b..1e5608bc90 100644
--- a/src/network/access/qnetworkreplyfileimpl.cpp
+++ b/src/network/access/qnetworkreplyfileimpl.cpp
@@ -36,7 +36,6 @@
#include "QtCore/qdatetime.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QFileInfo>
-#include <QDebug>
QT_BEGIN_NAMESPACE
@@ -136,6 +135,7 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QObject *parent, const QNetworkRequ
QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection);
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
}
+
void QNetworkReplyFileImpl::close()
{
Q_D(QNetworkReplyFileImpl);
@@ -182,8 +182,11 @@ qint64 QNetworkReplyFileImpl::readData(char *data, qint64 maxlen)
d->realFile.close();
if (ret == 0 && bytesAvailable() == 0)
return -1;
- else
+ else {
+ setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 200);
+ setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, QLatin1String("OK"));
return ret;
+ }
}
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index c445677792..c08648c47b 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -166,6 +166,7 @@ QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(QNetworkAccessManager* const manage
d->manager = manager;
d->managerPrivate = manager->d_func();
d->request = request;
+ d->originalRequest = request;
d->operation = operation;
d->outgoingData = outgoingData;
d->url = request.url();
@@ -483,7 +484,7 @@ bool QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(QHttpNetworkRequest &h
if (!nc)
return false; // no local cache
- QNetworkCacheMetaData metaData = nc->metaData(request.url());
+ QNetworkCacheMetaData metaData = nc->metaData(httpRequest.url());
if (!metaData.isValid())
return false; // not in cache
@@ -597,7 +598,7 @@ QHttpNetworkRequest::Priority QNetworkReplyHttpImplPrivate::convert(const QNetwo
}
}
-void QNetworkReplyHttpImplPrivate::postRequest()
+void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpRequest)
{
Q_Q(QNetworkReplyHttpImpl);
@@ -621,8 +622,9 @@ void QNetworkReplyHttpImplPrivate::postRequest()
thread = managerPrivate->httpThread;
}
- QUrl url = request.url();
+ QUrl url = newHttpRequest.url();
httpRequest.setUrl(url);
+ httpRequest.setRedirectCount(newHttpRequest.maximumRedirectsAllowed());
QString scheme = url.scheme().toLower();
bool ssl = (scheme == QLatin1String("https")
@@ -638,7 +640,7 @@ void QNetworkReplyHttpImplPrivate::postRequest()
QNetworkProxy transparentProxy, cacheProxy;
// FIXME the proxy stuff should be done in the HTTP thread
- foreach (const QNetworkProxy &p, managerPrivate->queryProxy(QNetworkProxyQuery(request.url()))) {
+ foreach (const QNetworkProxy &p, managerPrivate->queryProxy(QNetworkProxyQuery(newHttpRequest.url()))) {
// use the first proxy that works
// for non-encrypted connections, any transparent or HTTP proxy
// for encrypted, only transparent proxies
@@ -669,9 +671,11 @@ void QNetworkReplyHttpImplPrivate::postRequest()
}
#endif
+ if (newHttpRequest.attribute(QNetworkRequest::FollowRedirectsAttribute).toBool())
+ httpRequest.setFollowRedirects(true);
bool loadedFromCache = false;
- httpRequest.setPriority(convert(request.priority()));
+ httpRequest.setPriority(convert(newHttpRequest.priority()));
switch (operation) {
case QNetworkAccessManager::GetOperation:
@@ -705,7 +709,7 @@ void QNetworkReplyHttpImplPrivate::postRequest()
invalidateCache(); // for safety reasons, we don't know what the operation does
httpRequest.setOperation(QHttpNetworkRequest::Custom);
createUploadByteDevice();
- httpRequest.setCustomVerb(request.attribute(
+ httpRequest.setCustomVerb(newHttpRequest.attribute(
QNetworkRequest::CustomVerbAttribute).toByteArray());
break;
@@ -717,7 +721,7 @@ void QNetworkReplyHttpImplPrivate::postRequest()
return; // no need to send the request! :)
}
- QList<QByteArray> headers = request.rawHeaderList();
+ QList<QByteArray> headers = newHttpRequest.rawHeaderList();
if (resumeOffset != 0) {
if (headers.contains("Range")) {
// Need to adjust resume offset for user specified range
@@ -725,7 +729,7 @@ void QNetworkReplyHttpImplPrivate::postRequest()
headers.removeOne("Range");
// We've already verified that requestRange starts with "bytes=", see canResume.
- QByteArray requestRange = request.rawHeader("Range").mid(6);
+ QByteArray requestRange = newHttpRequest.rawHeader("Range").mid(6);
int index = requestRange.indexOf('-');
@@ -742,16 +746,16 @@ void QNetworkReplyHttpImplPrivate::postRequest()
}
foreach (const QByteArray &header, headers)
- httpRequest.setHeaderField(header, request.rawHeader(header));
+ httpRequest.setHeaderField(header, newHttpRequest.rawHeader(header));
- if (request.attribute(QNetworkRequest::HttpPipeliningAllowedAttribute).toBool() == true)
+ if (newHttpRequest.attribute(QNetworkRequest::HttpPipeliningAllowedAttribute).toBool() == true)
httpRequest.setPipeliningAllowed(true);
if (request.attribute(QNetworkRequest::SpdyAllowedAttribute).toBool() == true)
httpRequest.setSPDYAllowed(true);
if (static_cast<QNetworkRequest::LoadControl>
- (request.attribute(QNetworkRequest::AuthenticationReuseAttribute,
+ (newHttpRequest.attribute(QNetworkRequest::AuthenticationReuseAttribute,
QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Manual)
httpRequest.setWithCredentials(false);
@@ -778,7 +782,7 @@ void QNetworkReplyHttpImplPrivate::postRequest()
delegate->ssl = ssl;
#ifndef QT_NO_SSL
if (ssl)
- delegate->incomingSslConfiguration = request.sslConfiguration();
+ delegate->incomingSslConfiguration = newHttpRequest.sslConfiguration();
#endif
// Do we use synchronous HTTP?
@@ -790,7 +794,7 @@ void QNetworkReplyHttpImplPrivate::postRequest()
if (!synchronous) {
// Tell our zerocopy policy to the delegate
- QVariant downloadBufferMaximumSizeAttribute = request.attribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute);
+ QVariant downloadBufferMaximumSizeAttribute = newHttpRequest.attribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute);
if (downloadBufferMaximumSizeAttribute.isValid()) {
delegate->downloadBufferMaximumSize = downloadBufferMaximumSizeAttribute.toLongLong();
} else {
@@ -825,6 +829,9 @@ void QNetworkReplyHttpImplPrivate::postRequest()
QObject::connect(delegate, SIGNAL(error(QNetworkReply::NetworkError,QString)),
q, SLOT(httpError(QNetworkReply::NetworkError,QString)),
Qt::QueuedConnection);
+ QObject::connect(delegate, SIGNAL(redirected(QUrl,int,int)),
+ q, SLOT(onRedirected(QUrl,int,int)),
+ Qt::QueuedConnection);
#ifndef QT_NO_SSL
QObject::connect(delegate, SIGNAL(sslConfigurationChanged(QSslConfiguration)),
q, SLOT(replySslConfigurationChanged(QSslConfiguration)),
@@ -951,7 +958,7 @@ void QNetworkReplyHttpImplPrivate::invalidateCache()
{
QAbstractNetworkCache *nc = managerPrivate->networkCache;
if (nc)
- nc->remove(request.url());
+ nc->remove(httpRequest.url());
}
void QNetworkReplyHttpImplPrivate::initCacheSaveDevice()
@@ -1031,21 +1038,30 @@ void QNetworkReplyHttpImplPrivate::replyDownloadData(QByteArray d)
for (int i = 0; i < pendingDownloadDataCopy.bufferCount(); i++) {
QByteArray const &item = pendingDownloadDataCopy[i];
+ // This is going to look a little strange. When downloading data while a
+ // HTTP redirect is happening (and enabled), we write the redirect
+ // response to the cache. However, we do not append it to our internal
+ // buffer as that will contain the response data only for the final
+ // response
if (cacheSaveDevice)
cacheSaveDevice->write(item.constData(), item.size());
- downloadMultiBuffer.append(item);
+
+ if (!isHttpRedirectResponse())
+ downloadMultiBuffer.append(item);
bytesWritten += item.size();
}
pendingDownloadDataCopy.clear();
- bytesDownloaded += bytesWritten;
-
-
QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
if (preMigrationDownloaded != Q_INT64_C(-1))
totalSize = totalSize.toLongLong() + preMigrationDownloaded;
+ if (isHttpRedirectResponse())
+ return;
+
+ bytesDownloaded += bytesWritten;
+
emit q->readyRead();
// emit readyRead before downloadProgress incase this will cause events to be
// processed and we get into a recursive call (as in QProgressDialog).
@@ -1067,6 +1083,64 @@ void QNetworkReplyHttpImplPrivate::replyFinished()
finished();
}
+QNetworkAccessManager::Operation QNetworkReplyHttpImplPrivate::getRedirectOperation(QNetworkAccessManager::Operation currentOp, int httpStatus)
+{
+ // HTTP status code can be used to decide if we can redirect with a GET
+ // operation or not. See http://www.ietf.org/rfc/rfc2616.txt [Sec 10.3] for
+ // more details
+ Q_UNUSED(httpStatus);
+
+ switch (currentOp) {
+ case QNetworkAccessManager::HeadOperation:
+ return QNetworkAccessManager::HeadOperation;
+ default:
+ break;
+ }
+ // For now, we're always returning GET for anything other than HEAD
+ return QNetworkAccessManager::GetOperation;
+}
+
+bool QNetworkReplyHttpImplPrivate::isHttpRedirectResponse() const
+{
+ return httpRequest.isFollowRedirects() && QHttpNetworkReply::isHttpRedirect(statusCode);
+}
+
+QNetworkRequest QNetworkReplyHttpImplPrivate::createRedirectRequest(const QNetworkRequest &originalRequest,
+ const QUrl &url,
+ int maxRedirectsRemaining)
+{
+ QNetworkRequest newRequest(originalRequest);
+ newRequest.setUrl(url);
+ newRequest.setMaximumRedirectsAllowed(maxRedirectsRemaining);
+
+ return newRequest;
+}
+
+void QNetworkReplyHttpImplPrivate::onRedirected(const QUrl &redirectUrl, int httpStatus, int maxRedirectsRemaining)
+{
+ Q_Q(QNetworkReplyHttpImpl);
+
+ if (isFinished)
+ return;
+
+ if (httpRequest.isFollowRedirects()) // update the reply's url as it could've changed
+ url = redirectUrl;
+
+ QNetworkRequest redirectRequest = createRedirectRequest(originalRequest, redirectUrl, maxRedirectsRemaining);
+ operation = getRedirectOperation(operation, httpStatus);
+
+ cookedHeaders.clear();
+
+ if (managerPrivate->httpThread)
+ managerPrivate->httpThread->disconnect();
+
+ // Recurse
+ QMetaObject::invokeMethod(q, "start", Qt::QueuedConnection,
+ Q_ARG(QNetworkRequest, redirectRequest));
+
+ emit q->redirected(redirectUrl);
+}
+
void QNetworkReplyHttpImplPrivate::checkForRedirect(const int statusCode)
{
Q_Q(QNetworkReplyHttpImpl);
@@ -1115,7 +1189,16 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData
end = headerMap.constEnd();
for (; it != end; ++it) {
QByteArray value = q->rawHeader(it->first);
+
+ // Reset any previous "location" header set in the reply. In case of
+ // redirects, we don't want to 'append' multiple location header values,
+ // rather we keep only the latest one
+ if (it->first.toLower() == "location")
+ value.clear();
+
if (!value.isEmpty()) {
+ // Why are we appending values for headers which are already
+ // present?
if (qstricmp(it->first.constData(), "set-cookie") == 0)
value += '\n';
else
@@ -1129,12 +1212,13 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData
q->setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, reasonPhrase);
// is it a redirection?
- checkForRedirect(statusCode);
+ if (!isHttpRedirectResponse())
+ checkForRedirect(statusCode);
if (statusCode >= 500 && statusCode < 600) {
QAbstractNetworkCache *nc = managerPrivate->networkCache;
if (nc) {
- QNetworkCacheMetaData metaData = nc->metaData(request.url());
+ QNetworkCacheMetaData metaData = nc->metaData(httpRequest.url());
QNetworkHeadersPrivate cacheHeaders;
cacheHeaders.setAllRawHeaders(metaData.rawHeaders());
QNetworkHeadersPrivate::RawHeadersList::ConstIterator it;
@@ -1156,7 +1240,7 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData
#endif
QAbstractNetworkCache *nc = managerPrivate->networkCache;
if (nc) {
- QNetworkCacheMetaData oldMetaData = nc->metaData(request.url());
+ QNetworkCacheMetaData oldMetaData = nc->metaData(httpRequest.url());
QNetworkCacheMetaData metaData = fetchCacheMetaData(oldMetaData);
if (oldMetaData != metaData)
nc->updateMetaData(metaData);
@@ -1203,6 +1287,9 @@ void QNetworkReplyHttpImplPrivate::replyDownloadProgressSlot(qint64 bytesReceive
// FIXME where is it closed?
}
+ if (isHttpRedirectResponse())
+ return;
+
bytesDownloaded = bytesReceived;
downloadBufferCurrentSize = bytesReceived;
@@ -1361,6 +1448,8 @@ bool QNetworkReplyHttpImplPrivate::sendCacheContents(const QNetworkCacheMetaData
if (status < 100)
status = 200; // fake it
+ statusCode = status;
+
q->setAttribute(QNetworkRequest::HttpStatusCodeAttribute, status);
q->setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, attributes.value(QNetworkRequest::HttpReasonPhraseAttribute));
q->setAttribute(QNetworkRequest::SourceIsFromCacheAttribute, true);
@@ -1368,10 +1457,16 @@ bool QNetworkReplyHttpImplPrivate::sendCacheContents(const QNetworkCacheMetaData
QNetworkCacheMetaData::RawHeaderList rawHeaders = metaData.rawHeaders();
QNetworkCacheMetaData::RawHeaderList::ConstIterator it = rawHeaders.constBegin(),
end = rawHeaders.constEnd();
- for ( ; it != end; ++it)
+ QUrl redirectUrl;
+ for ( ; it != end; ++it) {
+ if (httpRequest.isFollowRedirects() &&
+ !qstricmp(it->first.toLower().constData(), "location"))
+ redirectUrl = QUrl::fromEncoded(it->second);
setRawHeader(it->first, it->second);
+ }
- checkForRedirect(status);
+ if (!isHttpRedirectResponse())
+ checkForRedirect(status);
cacheLoadDevice = contents;
q->connect(cacheLoadDevice, SIGNAL(readyRead()), SLOT(_q_cacheLoadReadyRead()));
@@ -1388,6 +1483,14 @@ bool QNetworkReplyHttpImplPrivate::sendCacheContents(const QNetworkCacheMetaData
qDebug() << "Successfully sent cache:" << url << contents->size() << "bytes";
#endif
+ // Do redirect processing
+ if (httpRequest.isFollowRedirects() && QHttpNetworkReply::isHttpRedirect(status)) {
+ QMetaObject::invokeMethod(q, "onRedirected", Qt::QueuedConnection,
+ Q_ARG(QUrl, redirectUrl),
+ Q_ARG(int, status),
+ Q_ARG(int, httpRequest.redirectCount() - 1));
+ }
+
// Set the following flag so we can ignore some signals from HTTP thread
// that would still come
loadingFromCache = true;
@@ -1583,13 +1686,13 @@ void QNetworkReplyHttpImplPrivate::setResumeOffset(quint64 offset)
could not be started due to an unopened or roaming session. The caller should recall this
function once the session has been opened or the roaming process has finished.
*/
-bool QNetworkReplyHttpImplPrivate::start()
+bool QNetworkReplyHttpImplPrivate::start(const QNetworkRequest &newHttpRequest)
{
#ifndef QT_NO_BEARERMANAGEMENT
QSharedPointer<QNetworkSession> networkSession(managerPrivate->getNetworkSession());
if (!networkSession) {
#endif
- postRequest();
+ postRequest(newHttpRequest);
return true;
#ifndef QT_NO_BEARERMANAGEMENT
}
@@ -1599,7 +1702,7 @@ bool QNetworkReplyHttpImplPrivate::start()
if (host == QLatin1String("localhost") ||
QHostAddress(host).isLoopback()) {
// Don't need an open session for localhost access.
- postRequest();
+ postRequest(newHttpRequest);
return true;
}
@@ -1608,13 +1711,13 @@ bool QNetworkReplyHttpImplPrivate::start()
Q_Q(QNetworkReplyHttpImpl);
QObject::connect(networkSession.data(), SIGNAL(usagePoliciesChanged(QNetworkSession::UsagePolicies)),
q, SLOT(_q_networkSessionUsagePoliciesChanged(QNetworkSession::UsagePolicies)));
- postRequest();
+ postRequest(newHttpRequest);
return true;
} else if (synchronous) {
// Command line applications using the synchronous path such as xmlpatterns may need an extra push.
networkSession->open();
if (networkSession->waitForOpened()) {
- postRequest();
+ postRequest(newHttpRequest);
return true;
}
}
@@ -1646,7 +1749,7 @@ void QNetworkReplyHttpImplPrivate::_q_startOperation()
}
#endif
- if (!start()) {
+ if (!start(request)) {
#ifndef QT_NO_BEARERMANAGEMENT
// backend failed to start because the session state is not Connected.
// QNetworkAccessManager will call reply->backend->start() again for us when the session
@@ -1708,18 +1811,20 @@ void QNetworkReplyHttpImplPrivate::_q_cacheLoadReadyRead()
// emit readyRead before downloadProgress incase this will cause events to be
// processed and we get into a recursive call (as in QProgressDialog).
- // This readyRead() goes to the user. The user then may or may not read() anything.
- emit q->readyRead();
- if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) {
- downloadProgressSignalChoke.restart();
- emit q->downloadProgress(bytesDownloaded,
- totalSize.isNull() ? Q_INT64_C(-1) : totalSize.toLongLong());
- }
+ if (!(isHttpRedirectResponse())) {
+ // This readyRead() goes to the user. The user then may or may not read() anything.
+ emit q->readyRead();
+ if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) {
+ downloadProgressSignalChoke.restart();
+ emit q->downloadProgress(bytesDownloaded,
+ totalSize.isNull() ? Q_INT64_C(-1) : totalSize.toLongLong());
+ }
+ }
// If there are still bytes available in the cacheLoadDevice then the user did not read
// in response to the readyRead() signal. This means we have to load from the cacheLoadDevice
// and buffer that stuff. This is needed to be able to properly emit finished() later.
- while (cacheLoadDevice->bytesAvailable()) {
+ while (cacheLoadDevice->bytesAvailable() && !isHttpRedirectResponse()) {
downloadMultiBuffer.append(cacheLoadDevice->readAll());
}
@@ -1742,7 +1847,6 @@ void QNetworkReplyHttpImplPrivate::_q_cacheLoadReadyRead()
cacheLoadDevice = 0;
QMetaObject::invokeMethod(q, "_q_finished", Qt::QueuedConnection);
}
-
}
@@ -1962,6 +2066,15 @@ void QNetworkReplyHttpImplPrivate::finished()
#endif
}
+ // if we don't know the total size of or we received everything save the cache
+ if (totalSize.isNull() || totalSize == -1 || bytesDownloaded == totalSize)
+ completeCacheSave();
+
+ // We check for errorCode too as in case of SSL handshake failure, we still
+ // get the HTTP redirect status code (301, 303 etc)
+ if (isHttpRedirectResponse() && errorCode == QNetworkReply::NoError)
+ return;
+
state = Finished;
q->setFinished(true);
@@ -1974,10 +2087,6 @@ void QNetworkReplyHttpImplPrivate::finished()
if (bytesUploaded == -1 && (outgoingData || outgoingDataBuffer))
emit q->uploadProgress(0, 0);
- // if we don't know the total size of or we received everything save the cache
- if (totalSize.isNull() || totalSize == -1 || bytesDownloaded == totalSize)
- completeCacheSave();
-
emit q->readChannelFinished();
emit q->finished();
}
diff --git a/src/network/access/qnetworkreplyhttpimpl_p.h b/src/network/access/qnetworkreplyhttpimpl_p.h
index b009092196..fff88f8f2d 100644
--- a/src/network/access/qnetworkreplyhttpimpl_p.h
+++ b/src/network/access/qnetworkreplyhttpimpl_p.h
@@ -89,6 +89,7 @@ public:
Q_DECLARE_PRIVATE(QNetworkReplyHttpImpl)
Q_PRIVATE_SLOT(d_func(), void _q_startOperation())
+ Q_PRIVATE_SLOT(d_func(), bool start(const QNetworkRequest &))
Q_PRIVATE_SLOT(d_func(), void _q_cacheLoadReadyRead())
Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingData())
Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingDataFinished())
@@ -126,7 +127,7 @@ public:
Q_PRIVATE_SLOT(d_func(), void emitReplyUploadProgress(qint64, qint64))
Q_PRIVATE_SLOT(d_func(), void _q_cacheSaveDeviceAboutToClose())
Q_PRIVATE_SLOT(d_func(), void _q_metaDataChanged())
-
+ Q_PRIVATE_SLOT(d_func(), void onRedirected(const QUrl &, int, int))
#ifndef QT_NO_SSL
protected:
@@ -157,7 +158,7 @@ public:
QNetworkReplyHttpImplPrivate();
~QNetworkReplyHttpImplPrivate();
- bool start();
+ bool start(const QNetworkRequest &newHttpRequest);
void _q_startOperation();
void _q_cacheLoadReadyRead();
@@ -201,6 +202,7 @@ public:
QIODevice *outgoingData;
QSharedPointer<QRingBuffer> outgoingDataBuffer;
void emitReplyUploadProgress(qint64 bytesSent, qint64 bytesTotal); // dup?
+ void onRedirected(const QUrl &redirectUrl, int httpStatus, int maxRedirectsRemainig);
qint64 bytesUploaded;
@@ -260,9 +262,10 @@ public:
QNetworkCacheMetaData fetchCacheMetaData(const QNetworkCacheMetaData &metaData) const;
- void postRequest();
-
-
+ void postRequest(const QNetworkRequest& newHttpRequest);
+ QNetworkAccessManager::Operation getRedirectOperation(QNetworkAccessManager::Operation currentOp, int httpStatus);
+ QNetworkRequest createRedirectRequest(const QNetworkRequest &originalRequests, const QUrl &url, int maxRedirectsRemainig);
+ bool isHttpRedirectResponse() const;
public:
// From HTTP thread:
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index f235adaee8..a73e0ea75e 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -65,8 +65,6 @@ inline QNetworkReplyImplPrivate::QNetworkReplyImplPrivate()
void QNetworkReplyImplPrivate::_q_startOperation()
{
- Q_Q(QNetworkReplyImpl);
-
// ensure this function is only being called once
if (state == Working || state == Finished) {
qDebug("QNetworkReplyImpl::_q_startOperation was called more than once");
@@ -85,6 +83,7 @@ void QNetworkReplyImplPrivate::_q_startOperation()
}
#ifndef QT_NO_BEARERMANAGEMENT
+ Q_Q(QNetworkReplyImpl);
// Do not start background requests if they are not allowed by session policy
QSharedPointer<QNetworkSession> session(manager->d_func()->getNetworkSession());
QVariant isBackground = backend->request().attribute(QNetworkRequest::BackgroundRequestAttribute, QVariant::fromValue(false));
@@ -915,13 +914,11 @@ void QNetworkReplyImpl::abort()
QNetworkReply::close();
- if (d->state != QNetworkReplyPrivate::Finished) {
- // call finished which will emit signals
- d->error(OperationCanceledError, tr("Operation canceled"));
- if (d->state == QNetworkReplyPrivate::WaitingForSession)
- d->state = QNetworkReplyPrivate::Working;
- d->finished();
- }
+ // call finished which will emit signals
+ d->error(OperationCanceledError, tr("Operation canceled"));
+ if (d->state == QNetworkReplyPrivate::WaitingForSession)
+ d->state = QNetworkReplyPrivate::Working;
+ d->finished();
d->state = QNetworkReplyPrivate::Aborted;
// finished may access the backend
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index c7cb16c71c..558e015ae4 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -140,7 +140,9 @@ QT_BEGIN_NAMESPACE
request to a different URL. The Network Access API does not by
default follow redirections: it's up to the application to
determine if the requested redirection should be allowed,
- according to its security policies.
+ according to its security policies. However, if
+ QNetworkRequest::FollowRedirectsAttribute is set, then this attribute
+ will not be present in the reply.
The returned URL might be relative. Use QUrl::resolved()
to create an absolute URL out of it.
@@ -256,6 +258,12 @@ QT_BEGIN_NAMESPACE
in 100 millisecond intervals.
(This value was introduced in 5.5.)
+ \value FollowRedirectsAttribute
+ Requests only, type: QMetaType::Bool (default: false)
+ Indicates whether the Network Access API should automatically follow a
+ HTTP redirect response or not. Currently redirects that are insecure,
+ that is redirecting from "https" to "http" protocol, are not allowed.
+
\value User
Special type. Additional information can be passed in
QVariants with types ranging from User to UserMax. The default
@@ -306,11 +314,13 @@ QT_BEGIN_NAMESPACE
class QNetworkRequestPrivate: public QSharedData, public QNetworkHeadersPrivate
{
public:
+ static const int maxRedirectCount = 50;
inline QNetworkRequestPrivate()
: priority(QNetworkRequest::NormalPriority)
#ifndef QT_NO_SSL
, sslConfiguration(0)
#endif
+ , maxRedirectsAllowed(maxRedirectCount)
{ qRegisterMetaType<QNetworkRequest>(); }
~QNetworkRequestPrivate()
{
@@ -325,7 +335,7 @@ public:
{
url = other.url;
priority = other.priority;
-
+ maxRedirectsAllowed = other.maxRedirectsAllowed;
#ifndef QT_NO_SSL
sslConfiguration = 0;
if (other.sslConfiguration)
@@ -338,7 +348,8 @@ public:
return url == other.url &&
priority == other.priority &&
rawHeaders == other.rawHeaders &&
- attributes == other.attributes;
+ attributes == other.attributes &&
+ maxRedirectsAllowed == other.maxRedirectsAllowed;
// don't compare cookedHeaders
}
@@ -347,6 +358,7 @@ public:
#ifndef QT_NO_SSL
mutable QSslConfiguration *sslConfiguration;
#endif
+ int maxRedirectsAllowed;
};
/*!
@@ -657,6 +669,32 @@ void QNetworkRequest::setPriority(Priority priority)
d->priority = priority;
}
+/*!
+ \since 5.6
+
+ Returns the maximum number of redirects allowed to be followed for this
+ request.
+
+ \sa setMaximumRedirectsAllowed()
+*/
+int QNetworkRequest::maximumRedirectsAllowed() const
+{
+ return d->maxRedirectsAllowed;
+}
+
+/*!
+ \since 5.6
+
+ Sets the maximum number of redirects allowed to be followed for this
+ request to \a maxRedirectsAllowed.
+
+ \sa maximumRedirectsAllowed()
+*/
+void QNetworkRequest::setMaximumRedirectsAllowed(int maxRedirectsAllowed)
+{
+ d->maxRedirectsAllowed = maxRedirectsAllowed;
+}
+
static QByteArray headerName(QNetworkRequest::KnownHeaders header)
{
switch (header) {
@@ -881,6 +919,7 @@ QNetworkHeadersPrivate::RawHeadersList QNetworkHeadersPrivate::allRawHeaders() c
QList<QByteArray> QNetworkHeadersPrivate::rawHeadersKeys() const
{
QList<QByteArray> result;
+ result.reserve(rawHeaders.size());
RawHeadersList::ConstIterator it = rawHeaders.constBegin(),
end = rawHeaders.constEnd();
for ( ; it != end; ++it)
diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h
index d6d907bdc4..eb343c97df 100644
--- a/src/network/access/qnetworkrequest.h
+++ b/src/network/access/qnetworkrequest.h
@@ -81,6 +81,7 @@ public:
SpdyAllowedAttribute,
SpdyWasUsedAttribute,
EmitAllUploadProgressSignalsAttribute,
+ FollowRedirectsAttribute,
User = 1000,
UserMax = 32767
@@ -105,9 +106,12 @@ public:
explicit QNetworkRequest(const QUrl &url = QUrl());
QNetworkRequest(const QNetworkRequest &other);
~QNetworkRequest();
+#ifdef Q_COMPILER_RVALUE_REFS
+ QNetworkRequest &operator=(QNetworkRequest &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QNetworkRequest &operator=(const QNetworkRequest &other);
- inline void swap(QNetworkRequest &other) { qSwap(d, other.d); }
+ void swap(QNetworkRequest &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool operator==(const QNetworkRequest &other) const;
inline bool operator!=(const QNetworkRequest &other) const
@@ -141,6 +145,10 @@ public:
Priority priority() const;
void setPriority(Priority priority);
+ // HTTP redirect related
+ int maximumRedirectsAllowed() const;
+ void setMaximumRedirectsAllowed(int maximumRedirectsAllowed);
+
private:
QSharedDataPointer<QNetworkRequestPrivate> d;
friend class QNetworkRequestPrivate;
diff --git a/src/network/access/qspdyprotocolhandler.cpp b/src/network/access/qspdyprotocolhandler.cpp
index 7430ca029d..7d2c0dfef2 100644
--- a/src/network/access/qspdyprotocolhandler.cpp
+++ b/src/network/access/qspdyprotocolhandler.cpp
@@ -288,16 +288,14 @@ bool QSpdyProtocolHandler::sendRequest()
m_channel->state = QHttpNetworkConnectionChannel::WritingState;
- // requests will be ordered by priority (see QMultiMap doc)
- QList<HttpMessagePair> requests = m_channel->spdyRequestsToSend.values();
- QList<int> priorities = m_channel->spdyRequestsToSend.keys();
-
- int requestsToSend = qMin(requests.count(), maxPossibleRequests);
+ int requestsToSend = qMin(m_channel->spdyRequestsToSend.size(), maxPossibleRequests);
+ QMultiMap<int, HttpMessagePair>::iterator it = m_channel->spdyRequestsToSend.begin();
+ // requests will be ordered by priority (see QMultiMap doc)
for (int a = 0; a < requestsToSend; ++a) {
- HttpMessagePair currentPair = requests.at(a);
- QHttpNetworkRequest currentRequest = requests.at(a).first;
- QHttpNetworkReply *currentReply = requests.at(a).second;
+ HttpMessagePair currentPair = *it;
+ QHttpNetworkRequest currentRequest = currentPair.first;
+ QHttpNetworkReply *currentReply = currentPair.second;
currentReply->setSpdyWasUsed(true);
qint32 streamID = generateNextStreamID();
@@ -310,10 +308,7 @@ bool QSpdyProtocolHandler::sendRequest()
connect(currentReply, SIGNAL(destroyed(QObject*)), this, SLOT(_q_replyDestroyed(QObject*)));
sendSYN_STREAM(currentPair, streamID, /* associatedToStreamID = */ 0);
- int requestsRemoved = m_channel->spdyRequestsToSend.remove(
- priorities.at(a), currentPair);
- Q_ASSERT(requestsRemoved == 1);
- Q_UNUSED(requestsRemoved); // silence -Wunused-variable
+ m_channel->spdyRequestsToSend.erase(it++);
}
m_channel->state = QHttpNetworkConnectionChannel::IdleState;
return true;
diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h
index dbef344e69..317c232bea 100644
--- a/src/network/bearer/qnetworkconfiguration.h
+++ b/src/network/bearer/qnetworkconfiguration.h
@@ -49,10 +49,13 @@ class Q_NETWORK_EXPORT QNetworkConfiguration
public:
QNetworkConfiguration();
QNetworkConfiguration(const QNetworkConfiguration& other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QNetworkConfiguration &operator=(QNetworkConfiguration &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QNetworkConfiguration &operator=(const QNetworkConfiguration &other);
~QNetworkConfiguration();
- void swap(QNetworkConfiguration &other) { qSwap(d, other.d); }
+ void swap(QNetworkConfiguration &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool operator==(const QNetworkConfiguration &other) const;
inline bool operator!=(const QNetworkConfiguration &other) const
diff --git a/src/network/kernel/qdnslookup.h b/src/network/kernel/qdnslookup.h
index 01ebbb6535..f13d268db7 100644
--- a/src/network/kernel/qdnslookup.h
+++ b/src/network/kernel/qdnslookup.h
@@ -55,16 +55,18 @@ class Q_NETWORK_EXPORT QDnsDomainNameRecord
public:
QDnsDomainNameRecord();
QDnsDomainNameRecord(const QDnsDomainNameRecord &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QDnsDomainNameRecord &operator=(QDnsDomainNameRecord &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
+ QDnsDomainNameRecord &operator=(const QDnsDomainNameRecord &other);
~QDnsDomainNameRecord();
- void swap(QDnsDomainNameRecord &other) { qSwap(d, other.d); }
+ void swap(QDnsDomainNameRecord &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
QString name() const;
quint32 timeToLive() const;
QString value() const;
- QDnsDomainNameRecord &operator=(const QDnsDomainNameRecord &other);
-
private:
QSharedDataPointer<QDnsDomainNameRecordPrivate> d;
friend class QDnsLookupRunnable;
@@ -77,16 +79,18 @@ class Q_NETWORK_EXPORT QDnsHostAddressRecord
public:
QDnsHostAddressRecord();
QDnsHostAddressRecord(const QDnsHostAddressRecord &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QDnsHostAddressRecord &operator=(QDnsHostAddressRecord &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
+ QDnsHostAddressRecord &operator=(const QDnsHostAddressRecord &other);
~QDnsHostAddressRecord();
- void swap(QDnsHostAddressRecord &other) { qSwap(d, other.d); }
+ void swap(QDnsHostAddressRecord &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
QString name() const;
quint32 timeToLive() const;
QHostAddress value() const;
- QDnsHostAddressRecord &operator=(const QDnsHostAddressRecord &other);
-
private:
QSharedDataPointer<QDnsHostAddressRecordPrivate> d;
friend class QDnsLookupRunnable;
@@ -99,17 +103,19 @@ class Q_NETWORK_EXPORT QDnsMailExchangeRecord
public:
QDnsMailExchangeRecord();
QDnsMailExchangeRecord(const QDnsMailExchangeRecord &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QDnsMailExchangeRecord &operator=(QDnsMailExchangeRecord &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
+ QDnsMailExchangeRecord &operator=(const QDnsMailExchangeRecord &other);
~QDnsMailExchangeRecord();
- void swap(QDnsMailExchangeRecord &other) { qSwap(d, other.d); }
+ void swap(QDnsMailExchangeRecord &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
QString exchange() const;
QString name() const;
quint16 preference() const;
quint32 timeToLive() const;
- QDnsMailExchangeRecord &operator=(const QDnsMailExchangeRecord &other);
-
private:
QSharedDataPointer<QDnsMailExchangeRecordPrivate> d;
friend class QDnsLookupRunnable;
@@ -122,9 +128,13 @@ class Q_NETWORK_EXPORT QDnsServiceRecord
public:
QDnsServiceRecord();
QDnsServiceRecord(const QDnsServiceRecord &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QDnsServiceRecord &operator=(QDnsServiceRecord &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
+ QDnsServiceRecord &operator=(const QDnsServiceRecord &other);
~QDnsServiceRecord();
- void swap(QDnsServiceRecord &other) { qSwap(d, other.d); }
+ void swap(QDnsServiceRecord &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
QString name() const;
quint16 port() const;
@@ -133,8 +143,6 @@ public:
quint32 timeToLive() const;
quint16 weight() const;
- QDnsServiceRecord &operator=(const QDnsServiceRecord &other);
-
private:
QSharedDataPointer<QDnsServiceRecordPrivate> d;
friend class QDnsLookupRunnable;
@@ -147,16 +155,18 @@ class Q_NETWORK_EXPORT QDnsTextRecord
public:
QDnsTextRecord();
QDnsTextRecord(const QDnsTextRecord &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QDnsTextRecord &operator=(QDnsTextRecord &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
+ QDnsTextRecord &operator=(const QDnsTextRecord &other);
~QDnsTextRecord();
- void swap(QDnsTextRecord &other) { qSwap(d, other.d); }
+ void swap(QDnsTextRecord &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
QString name() const;
quint32 timeToLive() const;
QList<QByteArray> values() const;
- QDnsTextRecord &operator=(const QDnsTextRecord &other);
-
private:
QSharedDataPointer<QDnsTextRecordPrivate> d;
friend class QDnsLookupRunnable;
diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h
index 0c2229c334..8478240d28 100644
--- a/src/network/kernel/qhostaddress.h
+++ b/src/network/kernel/qhostaddress.h
@@ -84,9 +84,16 @@ public:
QHostAddress(SpecialAddress address);
~QHostAddress();
+#ifdef Q_COMPILER_RVALUE_REFS
+ QHostAddress &operator=(QHostAddress &&other) Q_DECL_NOTHROW
+ { swap(other); return *this; }
+#endif
+
QHostAddress &operator=(const QHostAddress &other);
QHostAddress &operator=(const QString &address);
+ void swap(QHostAddress &other) Q_DECL_NOTHROW { d.swap(other.d); }
+
void setAddress(quint32 ip4Addr);
void setAddress(quint8 *ip6Addr); // ### Qt 6: remove me
void setAddress(const quint8 *ip6Addr);
diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp
index 8d891733ac..2fbbf56e0f 100644
--- a/src/network/kernel/qnetworkinterface.cpp
+++ b/src/network/kernel/qnetworkinterface.cpp
@@ -108,6 +108,7 @@ QList<QSharedDataPointer<QNetworkInterfacePrivate> > QNetworkInterfaceManager::a
{
QList<QNetworkInterfacePrivate *> list = postProcess(scan());
QList<QSharedDataPointer<QNetworkInterfacePrivate> > result;
+ result.reserve(list.size());
foreach (QNetworkInterfacePrivate *ptr, list)
result << QSharedDataPointer<QNetworkInterfacePrivate>(ptr);
@@ -549,6 +550,7 @@ QList<QNetworkInterface> QNetworkInterface::allInterfaces()
{
QList<QSharedDataPointer<QNetworkInterfacePrivate> > privs = manager()->allInterfaces();
QList<QNetworkInterface> result;
+ result.reserve(privs.size());
foreach (const QSharedDataPointer<QNetworkInterfacePrivate> &p, privs) {
QNetworkInterface item;
item.d = p;
diff --git a/src/network/kernel/qnetworkinterface.h b/src/network/kernel/qnetworkinterface.h
index a4d93156fb..31d3b7b128 100644
--- a/src/network/kernel/qnetworkinterface.h
+++ b/src/network/kernel/qnetworkinterface.h
@@ -51,10 +51,13 @@ class Q_NETWORK_EXPORT QNetworkAddressEntry
public:
QNetworkAddressEntry();
QNetworkAddressEntry(const QNetworkAddressEntry &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QNetworkAddressEntry &operator=(QNetworkAddressEntry &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QNetworkAddressEntry &operator=(const QNetworkAddressEntry &other);
~QNetworkAddressEntry();
- void swap(QNetworkAddressEntry &other) { qSwap(d, other.d); }
+ void swap(QNetworkAddressEntry &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool operator==(const QNetworkAddressEntry &other) const;
inline bool operator!=(const QNetworkAddressEntry &other) const
@@ -93,10 +96,13 @@ public:
QNetworkInterface();
QNetworkInterface(const QNetworkInterface &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QNetworkInterface &operator=(QNetworkInterface &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QNetworkInterface &operator=(const QNetworkInterface &other);
~QNetworkInterface();
- void swap(QNetworkInterface &other) { qSwap(d, other.d); }
+ void swap(QNetworkInterface &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool isValid() const;
diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp
index 53c4410fab..d219d72136 100644
--- a/src/network/kernel/qnetworkproxy.cpp
+++ b/src/network/kernel/qnetworkproxy.cpp
@@ -218,7 +218,6 @@
#include "private/qhttpsocketengine_p.h"
#include "qauthenticator.h"
#include "qdebug.h"
-#include "qhash.h"
#include "qmutex.h"
#include "qstringlist.h"
#include "qurl.h"
diff --git a/src/network/kernel/qnetworkproxy.h b/src/network/kernel/qnetworkproxy.h
index 6b0f4a3937..717c141d60 100644
--- a/src/network/kernel/qnetworkproxy.h
+++ b/src/network/kernel/qnetworkproxy.h
@@ -63,7 +63,6 @@ public:
QueryType queryType = TcpSocket);
explicit QNetworkProxyQuery(quint16 bindPort, const QString &protocolTag = QString(),
QueryType queryType = TcpServer);
- QNetworkProxyQuery(const QNetworkProxyQuery &other);
#ifndef QT_NO_BEARERMANAGEMENT
QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration,
const QUrl &requestUrl, QueryType queryType = UrlRequest);
@@ -74,10 +73,14 @@ public:
quint16 bindPort, const QString &protocolTag = QString(),
QueryType queryType = TcpServer);
#endif
- ~QNetworkProxyQuery();
+ QNetworkProxyQuery(const QNetworkProxyQuery &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QNetworkProxyQuery &operator=(QNetworkProxyQuery &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QNetworkProxyQuery &operator=(const QNetworkProxyQuery &other);
+ ~QNetworkProxyQuery();
- void swap(QNetworkProxyQuery &other) { qSwap(d, other.d); }
+ void swap(QNetworkProxyQuery &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool operator==(const QNetworkProxyQuery &other) const;
inline bool operator!=(const QNetworkProxyQuery &other) const
@@ -139,10 +142,13 @@ public:
QNetworkProxy(ProxyType type, const QString &hostName = QString(), quint16 port = 0,
const QString &user = QString(), const QString &password = QString());
QNetworkProxy(const QNetworkProxy &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QNetworkProxy &operator=(QNetworkProxy &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QNetworkProxy &operator=(const QNetworkProxy &other);
~QNetworkProxy();
- void swap(QNetworkProxy &other) { qSwap(d, other.d); }
+ void swap(QNetworkProxy &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool operator==(const QNetworkProxy &other) const;
inline bool operator!=(const QNetworkProxy &other) const
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index dfce0de865..35b541d739 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -559,7 +559,6 @@ QAbstractSocketPrivate::QAbstractSocketPrivate()
readBufferMaxSize(0),
writeBuffer(QABSTRACTSOCKET_BUFFERSIZE),
isBuffered(false),
- blockingTimeout(30000),
connectTimer(0),
disconnectTimer(0),
connectTimeElapsed(0),
@@ -650,6 +649,8 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc
return false;
}
+ configureCreatedSocket();
+
if (threadData->hasEventDispatcher())
socketEngine->setReceiver(this);
@@ -661,6 +662,12 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc
}
/*! \internal
+*/
+void QAbstractSocketPrivate::configureCreatedSocket()
+{
+}
+
+/*! \internal
Slot connected to the read socket notifier. This slot is called
when new data is available for reading, or when the socket has
@@ -812,7 +819,7 @@ bool QAbstractSocketPrivate::canWriteNotification()
#if defined (QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::canWriteNotification() flushing");
#endif
- int tmp = writeBuffer.size();
+ qint64 tmp = writeBuffer.size();
flush();
if (socketEngine) {
@@ -872,7 +879,7 @@ bool QAbstractSocketPrivate::flush()
return false;
}
- int nextSize = writeBuffer.nextDataBlockSize();
+ qint64 nextSize = writeBuffer.nextDataBlockSize();
const char *ptr = writeBuffer.readPointer();
// Attempt to write it all in one chunk.
@@ -1707,9 +1714,9 @@ qint64 QAbstractSocket::bytesToWrite() const
{
Q_D(const QAbstractSocket);
#if defined(QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocket::bytesToWrite() == %i", d->writeBuffer.size());
+ qDebug("QAbstractSocket::bytesToWrite() == %lld", d->writeBuffer.size());
#endif
- return (qint64)d->writeBuffer.size();
+ return d->writeBuffer.size();
}
/*!
diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h
index 63440b6416..85e82aef47 100644
--- a/src/network/socket/qabstractsocket_p.h
+++ b/src/network/socket/qabstractsocket_p.h
@@ -130,6 +130,7 @@ public:
bool flush();
bool initSocketLayer(QAbstractSocket::NetworkLayerProtocol protocol);
+ virtual void configureCreatedSocket();
void startConnectingByName(const QString &host);
void fetchConnectionParameters();
void setupSocketNotifiers();
@@ -139,7 +140,6 @@ public:
QRingBuffer writeBuffer;
bool isBuffered;
- int blockingTimeout;
QTimer *connectTimer;
QTimer *disconnectTimer;
diff --git a/src/network/socket/qnet_unix_p.h b/src/network/socket/qnet_unix_p.h
index 979afb82ba..cd118afd63 100644
--- a/src/network/socket/qnet_unix_p.h
+++ b/src/network/socket/qnet_unix_p.h
@@ -193,6 +193,32 @@ static inline int qt_safe_sendto(int sockfd, const void *buf, size_t len, int fl
return ret;
}
+static inline int qt_safe_recvmsg(int sockfd, struct msghdr *msg, int flags)
+{
+ int ret;
+
+ EINTR_LOOP(ret, ::recvmsg(sockfd, msg, flags));
+ return ret;
+}
+
+// VxWorks' headers do not specify any const modifiers
+static inline int qt_safe_sendmsg(int sockfd, const struct msghdr *msg, int flags)
+{
+#ifdef MSG_NOSIGNAL
+ flags |= MSG_NOSIGNAL;
+#else
+ qt_ignore_sigpipe();
+#endif
+
+ int ret;
+#ifdef Q_OS_VXWORKS
+ EINTR_LOOP(ret, ::sendmsg(sockfd, (struct msghdr *) msg, flags);
+#else
+ EINTR_LOOP(ret, ::sendmsg(sockfd, msg, flags));
+#endif
+ return ret;
+}
+
QT_END_NAMESPACE
#endif // QNET_UNIX_P_H
diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp
index b41d207947..914c14877e 100644
--- a/src/network/socket/qtcpserver.cpp
+++ b/src/network/socket/qtcpserver.cpp
@@ -160,6 +160,23 @@ QNetworkProxy QTcpServerPrivate::resolveProxy(const QHostAddress &address, quint
/*! \internal
*/
+void QTcpServerPrivate::configureCreatedSocket()
+{
+#if defined(Q_OS_UNIX)
+ // Under Unix, we want to be able to bind to the port, even if a socket on
+ // the same address-port is in TIME_WAIT. Under Windows this is possible
+ // anyway -- furthermore, the meaning of reusable on Windows is different:
+ // it means that you can use the same address-port for multiple listening
+ // sockets.
+ // Don't abort though if we can't set that option. For example the socks
+ // engine doesn't support that option, but that shouldn't prevent us from
+ // trying to bind/listen.
+ socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
+#endif
+}
+
+/*! \internal
+*/
void QTcpServerPrivate::readNotification()
{
Q_Q(QTcpServer);
@@ -205,6 +222,9 @@ void QTcpServerPrivate::readNotification()
QTcpServer::QTcpServer(QObject *parent)
: QObject(*new QTcpServerPrivate, parent)
{
+#if defined(QTCPSERVER_DEBUG)
+ qDebug("QTcpServer::QTcpServer(%p)", parent);
+#endif
}
/*!
@@ -218,6 +238,9 @@ QTcpServer::QTcpServer(QObject *parent)
*/
QTcpServer::~QTcpServer()
{
+#if defined(QTCPSERVER_DEBUG)
+ qDebug("QTcpServer::~QTcpServer()");
+#endif
close();
}
@@ -226,6 +249,9 @@ QTcpServer::~QTcpServer()
QTcpServer::QTcpServer(QTcpServerPrivate &dd, QObject *parent)
: QObject(dd, parent)
{
+#if defined(QTCPSERVER_DEBUG)
+ qDebug("QTcpServer::QTcpServer(QTcpServerPrivate == %p, parent == %p)", &dd, parent);
+#endif
}
/*!
@@ -275,17 +301,7 @@ bool QTcpServer::listen(const QHostAddress &address, quint16 port)
if (addr.protocol() == QAbstractSocket::AnyIPProtocol && proto == QAbstractSocket::IPv4Protocol)
addr = QHostAddress::AnyIPv4;
-#if defined(Q_OS_UNIX)
- // Under Unix, we want to be able to bind to the port, even if a socket on
- // the same address-port is in TIME_WAIT. Under Windows this is possible
- // anyway -- furthermore, the meaning of reusable on Windows is different:
- // it means that you can use the same address-port for multiple listening
- // sockets.
- // Don't abort though if we can't set that option. For example the socks
- // engine doesn't support that option, but that shouldn't prevent us from
- // trying to bind/listen.
- d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
-#endif
+ d->configureCreatedSocket();
if (!d->socketEngine->bind(addr, port)) {
d->serverSocketError = d->socketEngine->error();
diff --git a/src/network/socket/qtcpserver_p.h b/src/network/socket/qtcpserver_p.h
index 415a0e190a..47505e7e91 100644
--- a/src/network/socket/qtcpserver_p.h
+++ b/src/network/socket/qtcpserver_p.h
@@ -80,6 +80,8 @@ public:
QNetworkProxy resolveProxy(const QHostAddress &address, quint16 port);
#endif
+ virtual void configureCreatedSocket();
+
// from QAbstractSocketEngineReceiver
void readNotification() Q_DECL_OVERRIDE;
void closeNotification() Q_DECL_OVERRIDE { readNotification(); }
diff --git a/src/network/socket/qtcpsocket.cpp b/src/network/socket/qtcpsocket.cpp
index b6072b2909..13865fbc9c 100644
--- a/src/network/socket/qtcpsocket.cpp
+++ b/src/network/socket/qtcpsocket.cpp
@@ -103,4 +103,13 @@ QTcpSocket::QTcpSocket(QTcpSocketPrivate &dd, QObject *parent)
d_func()->isBuffered = true;
}
+/*!
+ \internal
+*/
+QTcpSocket::QTcpSocket(QAbstractSocket::SocketType socketType,
+ QTcpSocketPrivate &dd, QObject *parent)
+ : QAbstractSocket(socketType, dd, parent)
+{
+}
+
QT_END_NAMESPACE
diff --git a/src/network/socket/qtcpsocket.h b/src/network/socket/qtcpsocket.h
index 3449beeceb..bf5370c976 100644
--- a/src/network/socket/qtcpsocket.h
+++ b/src/network/socket/qtcpsocket.h
@@ -51,6 +51,8 @@ public:
protected:
QTcpSocket(QTcpSocketPrivate &dd, QObject *parent = 0);
+ QTcpSocket(QAbstractSocket::SocketType socketType, QTcpSocketPrivate &dd,
+ QObject *parent = 0);
private:
Q_DISABLE_COPY(QTcpSocket)
diff --git a/src/network/ssl/qssl.cpp b/src/network/ssl/qssl.cpp
index 26381fcb8e..84aa9d7dca 100644
--- a/src/network/ssl/qssl.cpp
+++ b/src/network/ssl/qssl.cpp
@@ -166,6 +166,10 @@ Q_LOGGING_CATEGORY(lcSsl, "qt.network.ssl");
in ASN.1 format as returned by QSslConfiguration::sessionTicket(). Enabling
this feature adds memory overhead of approximately 1K per used session
ticket.
+ \value SslOptionDisableServerCipherPreference Disables selecting the cipher
+ chosen based on the servers preferences rather than the order ciphers were
+ sent by the client. This option is only relevant to server sockets, and is
+ only honored by the OpenSSL backend.
By default, SslOptionDisableEmptyFragments is turned on since this causes
problems with a large number of servers. SslOptionDisableLegacyRenegotiation
diff --git a/src/network/ssl/qssl.h b/src/network/ssl/qssl.h
index f56c36b219..03497ecf76 100644
--- a/src/network/ssl/qssl.h
+++ b/src/network/ssl/qssl.h
@@ -95,7 +95,8 @@ namespace QSsl {
SslOptionDisableServerNameIndication = 0x08,
SslOptionDisableLegacyRenegotiation = 0x10,
SslOptionDisableSessionSharing = 0x20,
- SslOptionDisableSessionPersistence = 0x40
+ SslOptionDisableSessionPersistence = 0x40,
+ SslOptionDisableServerCipherPreference = 0x80
};
Q_DECLARE_FLAGS(SslOptions, SslOption)
}
diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h
index ef0767ae8f..bd8dcb6c7f 100644
--- a/src/network/ssl/qsslcertificate.h
+++ b/src/network/ssl/qsslcertificate.h
@@ -83,9 +83,12 @@ public:
explicit QSslCertificate(const QByteArray &data = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem);
QSslCertificate(const QSslCertificate &other);
~QSslCertificate();
+#ifdef Q_COMPILER_RVALUE_REFS
+ QSslCertificate &operator=(QSslCertificate &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QSslCertificate &operator=(const QSslCertificate &other);
- inline void swap(QSslCertificate &other)
+ void swap(QSslCertificate &other) Q_DECL_NOTHROW
{ qSwap(d, other.d); }
bool operator==(const QSslCertificate &other) const;
diff --git a/src/network/ssl/qsslcertificate_openssl.cpp b/src/network/ssl/qsslcertificate_openssl.cpp
index ad88ea5d56..3324587821 100644
--- a/src/network/ssl/qsslcertificate_openssl.cpp
+++ b/src/network/ssl/qsslcertificate_openssl.cpp
@@ -464,8 +464,9 @@ QList<QSslCertificateExtension> QSslCertificate::extensions() const
return result;
int count = q_X509_get_ext_count(d->x509);
+ result.reserve(count);
- for (int i=0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
X509_EXTENSION *ext = q_X509_get_ext(d->x509, i);
result << QSslCertificatePrivate::convertExtension(ext);
}
diff --git a/src/network/ssl/qsslcertificateextension.h b/src/network/ssl/qsslcertificateextension.h
index 7c958eff30..8dd0e8eb4b 100644
--- a/src/network/ssl/qsslcertificateextension.h
+++ b/src/network/ssl/qsslcertificateextension.h
@@ -51,11 +51,13 @@ class Q_NETWORK_EXPORT QSslCertificateExtension
public:
QSslCertificateExtension();
QSslCertificateExtension(const QSslCertificateExtension &other);
- ~QSslCertificateExtension();
-
+#ifdef Q_COMPILER_RVALUE_REFS
+ QSslCertificateExtension &operator=(QSslCertificateExtension &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QSslCertificateExtension &operator=(const QSslCertificateExtension &other);
+ ~QSslCertificateExtension();
- void swap(QSslCertificateExtension &other) { qSwap(d, other.d); }
+ void swap(QSslCertificateExtension &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
QString oid() const;
QString name() const;
diff --git a/src/network/ssl/qsslcipher.h b/src/network/ssl/qsslcipher.h
index dc65e32111..64122cdd53 100644
--- a/src/network/ssl/qsslcipher.h
+++ b/src/network/ssl/qsslcipher.h
@@ -52,10 +52,13 @@ public:
explicit QSslCipher(const QString &name);
QSslCipher(const QString &name, QSsl::SslProtocol protocol);
QSslCipher(const QSslCipher &other);
- ~QSslCipher();
+#ifdef Q_COMPILER_RVALUE_REFS
+ QSslCipher &operator=(QSslCipher &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QSslCipher &operator=(const QSslCipher &other);
+ ~QSslCipher();
- inline void swap(QSslCipher &other)
+ void swap(QSslCipher &other) Q_DECL_NOTHROW
{ qSwap(d, other.d); }
bool operator==(const QSslCipher &other) const;
diff --git a/src/network/ssl/qsslconfiguration.h b/src/network/ssl/qsslconfiguration.h
index 960aec60ce..2cbc31b032 100644
--- a/src/network/ssl/qsslconfiguration.h
+++ b/src/network/ssl/qsslconfiguration.h
@@ -71,9 +71,12 @@ public:
QSslConfiguration();
QSslConfiguration(const QSslConfiguration &other);
~QSslConfiguration();
+#ifdef Q_COMPILER_RVALUE_REFS
+ QSslConfiguration &operator=(QSslConfiguration &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QSslConfiguration &operator=(const QSslConfiguration &other);
- inline void swap(QSslConfiguration &other)
+ void swap(QSslConfiguration &other) Q_DECL_NOTHROW
{ qSwap(d, other.d); }
bool operator==(const QSslConfiguration &other) const;
diff --git a/src/network/ssl/qsslellipticcurve.h b/src/network/ssl/qsslellipticcurve.h
index 63ab2f3c37..a4dc4517ff 100644
--- a/src/network/ssl/qsslellipticcurve.h
+++ b/src/network/ssl/qsslellipticcurve.h
@@ -37,7 +37,10 @@
#include <QtCore/QtGlobal>
#include <QtCore/QString>
#include <QtCore/QMetaType>
+#if QT_DEPRECATED_SINCE(5, 5)
#include <QtCore/QHash>
+#endif
+#include <QtCore/qhashfunctions.h>
QT_BEGIN_NAMESPACE
diff --git a/src/network/ssl/qsslerror.h b/src/network/ssl/qsslerror.h
index b149f86d9e..bc2a2d5220 100644
--- a/src/network/ssl/qsslerror.h
+++ b/src/network/ssl/qsslerror.h
@@ -84,10 +84,13 @@ public:
QSslError(const QSslError &other);
- inline void swap(QSslError &other)
+ void swap(QSslError &other) Q_DECL_NOTHROW
{ qSwap(d, other.d); }
~QSslError();
+#ifdef Q_COMPILER_RVALUE_REFS
+ QSslError &operator=(QSslError &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QSslError &operator=(const QSslError &other);
bool operator==(const QSslError &other) const;
inline bool operator!=(const QSslError &other) const
diff --git a/src/network/ssl/qsslkey.h b/src/network/ssl/qsslkey.h
index b89069e4cb..d02c031015 100644
--- a/src/network/ssl/qsslkey.h
+++ b/src/network/ssl/qsslkey.h
@@ -64,10 +64,13 @@ public:
const QByteArray &passPhrase = QByteArray());
explicit QSslKey(Qt::HANDLE handle, QSsl::KeyType type = QSsl::PrivateKey);
QSslKey(const QSslKey &other);
- ~QSslKey();
+#ifdef Q_COMPILER_RVALUE_REFS
+ QSslKey &operator=(QSslKey &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+#endif
QSslKey &operator=(const QSslKey &other);
+ ~QSslKey();
- inline void swap(QSslKey &other) { qSwap(d, other.d); }
+ void swap(QSslKey &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool isNull() const;
void clear();
diff --git a/src/network/ssl/qsslpresharedkeyauthenticator.h b/src/network/ssl/qsslpresharedkeyauthenticator.h
index 159b16d563..34e5d6fd50 100644
--- a/src/network/ssl/qsslpresharedkeyauthenticator.h
+++ b/src/network/ssl/qsslpresharedkeyauthenticator.h
@@ -52,14 +52,10 @@ public:
Q_NETWORK_EXPORT QSslPreSharedKeyAuthenticator &operator=(const QSslPreSharedKeyAuthenticator &authenticator);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QSslPreSharedKeyAuthenticator &operator=(QSslPreSharedKeyAuthenticator &&authenticator)
- { d.swap(authenticator.d); return *this; }
+ QSslPreSharedKeyAuthenticator &operator=(QSslPreSharedKeyAuthenticator &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- void swap(QSslPreSharedKeyAuthenticator &authenticator)
- {
- d.swap(authenticator.d);
- }
+ void swap(QSslPreSharedKeyAuthenticator &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
Q_NETWORK_EXPORT QByteArray identityHint() const;
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index 049666b70b..3bcb8925c1 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -344,6 +344,9 @@ long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, Q
options |= SSL_OP_NO_COMPRESSION;
#endif
+ if (!(sslOptions & QSsl::SslOptionDisableServerCipherPreference))
+ options |= SSL_OP_CIPHER_SERVER_PREFERENCE;
+
return options;
}
@@ -491,30 +494,8 @@ bool QSslSocketPrivate::ensureLibraryLoaded()
// Initialize OpenSSL's random seed.
if (!q_RAND_status()) {
- struct {
- int msec;
- int sec;
- void *stack;
- } randomish;
-
- int attempts = 500;
- do {
- if (attempts < 500) {
-#ifdef Q_OS_UNIX
- struct timespec ts = {0, 33333333};
- nanosleep(&ts, 0);
-#else
- Sleep(3);
-#endif
- randomish.msec = attempts;
- }
- randomish.stack = (void *)&randomish;
- randomish.msec = QTime::currentTime().msec();
- randomish.sec = QTime::currentTime().second();
- q_RAND_seed((const char *)&randomish, sizeof(randomish));
- } while (!q_RAND_status() && --attempts);
- if (!attempts)
- return false;
+ qWarning("Random number generator not seeded, disabling SSL support");
+ return false;
}
}
return true;
@@ -662,8 +643,10 @@ void QSslSocketPrivate::resetDefaultCiphers()
if (SSL_CIPHER *cipher = q_sk_SSL_CIPHER_value(supportedCiphers, i)) {
QSslCipher ciph = QSslSocketBackendPrivate::QSslCipher_from_SSL_CIPHER(cipher);
if (!ciph.isNull()) {
- // Unconditionally exclude ADH ciphers since they offer no MITM protection
- if (!ciph.name().toLower().startsWith(QLatin1String("adh")))
+ // Unconditionally exclude ADH and AECDH ciphers since they offer no MITM protection
+ if (!ciph.name().toLower().startsWith(QLatin1String("adh")) &&
+ !ciph.name().toLower().startsWith(QLatin1String("exp-adh")) &&
+ !ciph.name().toLower().startsWith(QLatin1String("aecdh")))
ciphers << ciph;
if (ciph.usedBits() >= 128)
defaultCiphers << ciph;
@@ -688,6 +671,7 @@ void QSslSocketPrivate::resetDefaultEllipticCurves()
QVarLengthArray<EC_builtin_curve> builtinCurves(static_cast<int>(curveCount));
if (q_EC_get_builtin_curves(builtinCurves.data(), curveCount) == curveCount) {
+ curves.reserve(int(curveCount));
for (size_t i = 0; i < curveCount; ++i) {
QSslEllipticCurve curve;
curve.id = builtinCurves[int(i)].nid;
@@ -1216,7 +1200,9 @@ bool QSslSocketBackendPrivate::startHandshake()
}
// Translate errors from the error list into QSslErrors.
- for (int i = 0; i < errorList.size(); ++i) {
+ const int numErrors = errorList.size();
+ errors.reserve(errors.size() + numErrors);
+ for (int i = 0; i < numErrors; ++i) {
const QPair<int, int> &errorAndDepth = errorList.at(i);
int err = errorAndDepth.first;
int depth = errorAndDepth.second;
@@ -1778,7 +1764,9 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> &
}
// Translate errors from the error list into QSslErrors.
- for (int i = 0; i < errorList.size(); ++i) {
+ const int numErrors = errorList.size();
+ errors.reserve(errors.size() + numErrors);
+ for (int i = 0; i < numErrors; ++i) {
const QPair<int, int> &errorAndDepth = errorList.at(i);
int err = errorAndDepth.first;
int depth = errorAndDepth.second;
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index e2700df3cc..042c593e62 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -119,10 +119,13 @@ void qsslSocketUnresolvedSymbolWarning(const char *functionName)
qCWarning(lcSsl, "QSslSocket: cannot call unresolved function %s", functionName);
}
+#ifndef QT_NO_LIBRARY
void qsslSocketCannotResolveSymbolWarning(const char *functionName)
{
qCWarning(lcSsl, "QSslSocket: cannot resolve %s", functionName);
}
+#endif
+
}
#endif // QT_LINKED_OPENSSL
@@ -309,13 +312,17 @@ DEFINEFUNC(const SSL_METHOD *, TLSv1_1_server_method, DUMMYARG, DUMMYARG, return
DEFINEFUNC(const SSL_METHOD *, TLSv1_2_server_method, DUMMYARG, DUMMYARG, return 0, return)
#endif
#else
+#ifndef OPENSSL_NO_SSL2
DEFINEFUNC(SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return)
+#endif
#ifndef OPENSSL_NO_SSL3_METHOD
DEFINEFUNC(SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return)
#endif
DEFINEFUNC(SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return)
DEFINEFUNC(SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return)
+#ifndef OPENSSL_NO_SSL2
DEFINEFUNC(SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return)
+#endif
#ifndef OPENSSL_NO_SSL3_METHOD
DEFINEFUNC(SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return)
#endif
diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h
index 626c049629..a15bf4b87d 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols_p.h
+++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h
@@ -363,27 +363,43 @@ typedef unsigned int (*q_psk_client_callback_t)(SSL *ssl, const char *hint, char
void q_SSL_set_psk_client_callback(SSL *ssl, q_psk_client_callback_t callback);
#endif // OPENSSL_NO_PSK
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+#ifndef OPENSSL_NO_SSL2
const SSL_METHOD *q_SSLv2_client_method();
+#endif
+#ifndef OPENSSL_NO_SSL3_METHOD
const SSL_METHOD *q_SSLv3_client_method();
+#endif
const SSL_METHOD *q_SSLv23_client_method();
const SSL_METHOD *q_TLSv1_client_method();
const SSL_METHOD *q_TLSv1_1_client_method();
const SSL_METHOD *q_TLSv1_2_client_method();
+#ifndef OPENSSL_NO_SSL2
const SSL_METHOD *q_SSLv2_server_method();
+#endif
+#ifndef OPENSSL_NO_SSL3_METHOD
const SSL_METHOD *q_SSLv3_server_method();
+#endif
const SSL_METHOD *q_SSLv23_server_method();
const SSL_METHOD *q_TLSv1_server_method();
const SSL_METHOD *q_TLSv1_1_server_method();
const SSL_METHOD *q_TLSv1_2_server_method();
#else
+#ifndef OPENSSL_NO_SSL2
SSL_METHOD *q_SSLv2_client_method();
+#endif
+#ifndef OPENSSL_NO_SSL3_METHOD
SSL_METHOD *q_SSLv3_client_method();
+#endif
SSL_METHOD *q_SSLv23_client_method();
SSL_METHOD *q_TLSv1_client_method();
SSL_METHOD *q_TLSv1_1_client_method();
SSL_METHOD *q_TLSv1_2_client_method();
+#ifndef OPENSSL_NO_SSL2
SSL_METHOD *q_SSLv2_server_method();
+#endif
+#ifndef OPENSSL_NO_SSL3_METHOD
SSL_METHOD *q_SSLv3_server_method();
+#endif
SSL_METHOD *q_SSLv23_server_method();
SSL_METHOD *q_TLSv1_server_method();
SSL_METHOD *q_TLSv1_1_server_method();
diff --git a/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp b/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp
index 1551d1c7cb..6bf152b83d 100644
--- a/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp
+++ b/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp
@@ -63,6 +63,7 @@ QGLCustomShaderStage::~QGLCustomShaderStage()
d->m_manager->removeCustomStage();
d->m_manager->sharedShaders->cleanupCustomStage(this);
}
+ delete d_ptr;
}
void QGLCustomShaderStage::setUniformsDirty()
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index fd7f2b328c..ad5386d8bc 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -50,7 +50,7 @@
#include "QtCore/qmap.h"
#include "QtCore/qthread.h"
#include "QtCore/qthreadstorage.h"
-#include "QtCore/qhash.h"
+#include "QtCore/qhashfunctions.h"
#include "QtCore/qatomic.h"
#include "QtWidgets/private/qwidget_p.h"
#include "QtGui/private/qopenglcontext_p.h"
diff --git a/src/platformheaders/cocoafunctions/cocoafunctions.pri b/src/platformheaders/cocoafunctions/cocoafunctions.pri
new file mode 100644
index 0000000000..3987523f9a
--- /dev/null
+++ b/src/platformheaders/cocoafunctions/cocoafunctions.pri
@@ -0,0 +1 @@
+HEADERS += $$PWD/qcocoawindowfunctions.h
diff --git a/src/platformheaders/cocoafunctions/qcocoawindowfunctions.h b/src/platformheaders/cocoafunctions/qcocoawindowfunctions.h
new file mode 100644
index 0000000000..997f440e65
--- /dev/null
+++ b/src/platformheaders/cocoafunctions/qcocoawindowfunctions.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBWINDOWFUNCTIONS_H
+#define QXCBWINDOWFUNCTIONS_H
+
+#include <QtPlatformHeaders/QPlatformHeaderHelper>
+
+QT_BEGIN_NAMESPACE
+
+class QWindow;
+
+class QCocoaWindowFunctions {
+public:
+ typedef QPoint (*BottomLeftClippedByNSWindowOffset)(QWindow *window);
+ static const QByteArray bottomLeftClippedByNSWindowOffsetIdentifier() { return QByteArrayLiteral("CocoaBottomLeftClippedByNSWindowOffset"); }
+
+ static QPoint bottomLeftClippedByNSWindowOffset(QWindow *window)
+ {
+ return QPlatformHeaderHelper::callPlatformFunction<QPoint, BottomLeftClippedByNSWindowOffset>(bottomLeftClippedByNSWindowOffsetIdentifier(),window);
+ }
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QXCBWINDOWFUNCTIONS_H
diff --git a/src/platformheaders/cocoafunctions/qcocoawindowfunctions.qdoc b/src/platformheaders/cocoafunctions/qcocoawindowfunctions.qdoc
new file mode 100644
index 0000000000..e95f92edb5
--- /dev/null
+++ b/src/platformheaders/cocoafunctions/qcocoawindowfunctions.qdoc
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class QCocoaWindowFunctions
+ \inmodule QtPlatformHeaders
+
+ \brief The QCocoaWindowFunctions class is an inline class containing
+ miscellaneous functionality for NSWindow and NSView window specific functionality.
+
+ \note There is no binary compatibility guarantee for this class,
+ meaning that an application using it is only guaranteed to work with the Qt
+ version it was developed against.
+*/
+
+/*!
+ \typedef QCocoaWindowFunctions::BottomLeftClippedByNSWindowOffset
+
+ This is the typedef for the function returned by QGuiApplication::platformFunction when passed clippedByNSWindowIdentifier.
+*/
+
+/*!
+ \fn QByteArray QCocoaWindowFunctions::bottomLeftClippedByNSWindowOffsetIdentifier()
+
+ This function returnes the bytearray that can be used to query
+ QGuiApplication::platformFunction to retrieve the BottomLeftClippedByNSWindowOffset function.
+*/
+
+/*!
+ \fn QPoint QCocoaWindowFunctions::bottomLeftClippedByNSWindowOffset(QWindow *window)
+
+ This is a convenience function that can be used directly instead of resolving the function pointer.
+ \a window will be relayed to the function retrieved by QGuiApplication
+*/
diff --git a/src/platformheaders/helper/helper.pri b/src/platformheaders/helper/helper.pri
new file mode 100644
index 0000000000..2f6e766214
--- /dev/null
+++ b/src/platformheaders/helper/helper.pri
@@ -0,0 +1,2 @@
+HEADERS += \
+ $$PWD/qplatformheaderhelper.h
diff --git a/src/platformheaders/helper/qplatformheaderhelper.h b/src/platformheaders/helper/qplatformheaderhelper.h
new file mode 100644
index 0000000000..52302dbfba
--- /dev/null
+++ b/src/platformheaders/helper/qplatformheaderhelper.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMHEADERHELPER_H
+#define QPLATFORMHEADERHELPER_H
+
+#include <QtCore/QByteArray>
+#include <QtGui/QGuiApplication>
+
+#if 0
+#pragma qt_class(QPlatformHeaderHelper)
+#endif
+
+QT_BEGIN_NAMESPACE
+
+namespace QPlatformHeaderHelper {
+
+template<typename ReturnT, typename FunctionT>
+ReturnT callPlatformFunction(const QByteArray &functionName)
+{
+ FunctionT func = reinterpret_cast<FunctionT>(QGuiApplication::platformFunction(functionName));
+ return func ? func() : ReturnT();
+}
+
+template<typename ReturnT, typename FunctionT, typename Arg1>
+ReturnT callPlatformFunction(const QByteArray &functionName, Arg1 a1)
+{
+ FunctionT func = reinterpret_cast<FunctionT>(QGuiApplication::platformFunction(functionName));
+ return func ? func(a1) : ReturnT();
+}
+
+template<typename ReturnT, typename FunctionT, typename Arg1, typename Arg2>
+ReturnT callPlatformFunction(const QByteArray &functionName, Arg1 a1, Arg2 a2)
+{
+ FunctionT func = reinterpret_cast<FunctionT>(QGuiApplication::platformFunction(functionName));
+ return func ? func(a1, a2) : ReturnT();
+}
+
+template<typename ReturnT, typename FunctionT, typename Arg1, typename Arg2, typename Arg3>
+ReturnT callPlatformFunction(const QByteArray &functionName, Arg1 a1, Arg2 a2, Arg3 a3)
+{
+ FunctionT func = reinterpret_cast<FunctionT>(QGuiApplication::platformFunction(functionName));
+ return func ? func(a1, a2, a3) : ReturnT();
+}
+
+template<typename ReturnT, typename FunctionT, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
+ReturnT callPlatformFunction(const QByteArray &functionName, Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4)
+{
+ FunctionT func = reinterpret_cast<FunctionT>(QGuiApplication::platformFunction(functionName));
+ return func ? func(a1, a2, a3, a4) : ReturnT();
+}
+
+}
+
+QT_END_NAMESPACE
+
+#endif /*QPLATFORMHEADERHELPER_H*/
diff --git a/src/platformheaders/platformheaders.pro b/src/platformheaders/platformheaders.pro
index 5e875f7d2d..1ced4f1c95 100644
--- a/src/platformheaders/platformheaders.pro
+++ b/src/platformheaders/platformheaders.pro
@@ -7,6 +7,8 @@ include(nativecontexts/nativecontexts.pri)
include(xcbfunctions/xcbfunctions.pri)
include(eglfsfunctions/eglfsfunctions.pri)
include(windowsfunctions/windowsfunctions.pri)
+include(helper/helper.pri)
+include(cocoafunctions/cocoafunctions.pri)
QMAKE_DOCS = $$PWD/doc/qtplatformheaders.qdocconf
diff --git a/src/plugins/platforms/xcb/qxlibconvenience.cpp b/src/platformheaders/xcbfunctions/qxcbintegrationfunctions.h
index f3c7d2b24e..66bfb72307 100644
--- a/src/plugins/platforms/xcb/qxlibconvenience.cpp
+++ b/src/platformheaders/xcbfunctions/qxcbintegrationfunctions.h
@@ -31,33 +31,24 @@
**
****************************************************************************/
-#ifdef XCB_USE_XLIB
+#ifndef QXCBINTEGRATIONFUNCTIONS_H
+#define QXCBINTEGRATIONFUNCTIONS_H
-#include "qxlibconvenience.h"
-
-// Some Xlib headers are heavy macro namespace polluters and conflict with Qt types.
-// This unit makes it easier to deal with them by encapsulating these includes in this .cpp.
-#include <X11/Xutil.h>
+#include <QtPlatformHeaders/QPlatformHeaderHelper>
QT_BEGIN_NAMESPACE
-xcb_keysym_t q_XLookupString(void *display, xcb_window_t window, xcb_window_t root, uint state, xcb_keycode_t code, int type, QByteArray *chars)
+class QXcbIntegrationFunctions
{
- KeySym sym = 0;
- chars->resize(512);
- XKeyEvent event;
- memset(&event, 0, sizeof(event));
- event.type = type;
- event.display = static_cast<Display*>(display);
- event.window = window;
- event.root = root;
- event.state = state;
- event.keycode = code;
- int count = XLookupString(&event, chars->data(), chars->size(), &sym, 0);
- chars->resize(count);
- return sym;
-}
+public:
+ typedef bool (*XEmbedSystemTrayVisualHasAlphaChannel)();
+ static const QByteArray xEmbedSystemTrayVisualHasAlphaChannelIdentifier() { return QByteArrayLiteral("XcbXEmbedSystemTrayVisualHasAlphaChannel"); }
+ static bool xEmbedSystemTrayVisualHasAlphaChannel()
+ {
+ return QPlatformHeaderHelper::callPlatformFunction<bool, XEmbedSystemTrayVisualHasAlphaChannel>(xEmbedSystemTrayVisualHasAlphaChannelIdentifier());
+ }
+};
QT_END_NAMESPACE
-#endif
+#endif /*QXCBINTEGRATIONFUNCTIONS_H*/
diff --git a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h
index ae05cf52a9..0db2e2a09d 100644
--- a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h
+++ b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h
@@ -34,8 +34,7 @@
#ifndef QXCBWINDOWFUNCTIONS_H
#define QXCBWINDOWFUNCTIONS_H
-#include <QtCore/QByteArray>
-#include <QtGui/QGuiApplication>
+#include <QtPlatformHeaders/QPlatformHeaderHelper>
QT_BEGIN_NAMESPACE
@@ -65,12 +64,37 @@ public:
typedef void (*SetWmWindowType)(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowType);
static const QByteArray setWmWindowTypeIdentifier() { return QByteArrayLiteral("XcbSetWmWindowType"); }
-
static void setWmWindowType(QWindow *window, WmWindowType type)
{
- SetWmWindowType func = reinterpret_cast<SetWmWindowType>(QGuiApplication::platformFunction(setWmWindowTypeIdentifier()));
- if (func)
- func(window, type);
+ return QPlatformHeaderHelper::callPlatformFunction<void, SetWmWindowType, QWindow *, WmWindowType>(setWmWindowTypeIdentifier(), window, type);
+ }
+
+ typedef void (*SetWmWindowIconText)(QWindow *window, const QString &text);
+ static const QByteArray setWmWindowIconTextIdentifier() { return QByteArrayLiteral("XcbSetWmWindowIconText"); }
+ static void setWmWindowIconText(QWindow *window, const QString &text)
+ {
+ return QPlatformHeaderHelper::callPlatformFunction<void, SetWmWindowIconText, QWindow *, const QString &>(setWmWindowIconTextIdentifier(), window, text);
+ }
+
+ typedef void (*SetParentRelativeBackPixmap)(const QWindow *window);
+ static const QByteArray setParentRelativeBackPixmapIdentifier() { return QByteArrayLiteral("XcbSetParentRelativeBackPixmap"); }
+ static void setParentRelativeBackPixmap(const QWindow *window)
+ {
+ return QPlatformHeaderHelper::callPlatformFunction<void, SetParentRelativeBackPixmap, const QWindow *>(setParentRelativeBackPixmapIdentifier(), window);
+ }
+
+ typedef bool (*RequestSystemTrayWindowDock)(const QWindow *window);
+ static const QByteArray requestSystemTrayWindowDockIdentifier() { return QByteArrayLiteral("XcbRequestSystemTrayWindowDockIdentifier"); }
+ static bool requestSystemTrayWindowDock(const QWindow *window)
+ {
+ return QPlatformHeaderHelper::callPlatformFunction<bool, RequestSystemTrayWindowDock, const QWindow *>(requestSystemTrayWindowDockIdentifier(), window);
+ }
+
+ typedef QRect (*SystemTrayWindowGlobalGeometry)(const QWindow *window);
+ static const QByteArray systemTrayWindowGlobalGeometryIdentifier() { return QByteArrayLiteral("XcbSystemTrayWindowGlobalGeometryIdentifier"); }
+ static QRect systemTrayWindowGlobalGeometry(const QWindow *window)
+ {
+ return QPlatformHeaderHelper::callPlatformFunction<QRect, SystemTrayWindowGlobalGeometry, const QWindow *>(systemTrayWindowGlobalGeometryIdentifier(), window);
}
typedef uint (*VisualId)(QWindow *window);
diff --git a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc
index 414d0795fc..a02f93968d 100644
--- a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc
+++ b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc
@@ -65,7 +65,9 @@
/*!
\typedef QXcbWindowFunctions::SetWmWindowType
- This is the typedef for the function returned by QGuiApplication::platformFunction when passed setWmWindowTypeIdentifier.
+ This is the typedef for the function returned by
+ QGuiApplication::platformFunction when passed the
+ value returned by setWmWindowTypeIdentifier().
*/
/*!
@@ -78,6 +80,131 @@
/*!
\fn void QXcbWindowFunctions::setWmWindowType(QWindow *window, WmWindowType type)
- This is a convenience function that can be used directly instead of resolving the function pointer.
- \a window and \a type will be relayed to the function retrieved by QGuiApplication
+ This is a convenience function that can be used directly instead
+ of resolving the function pointer. \a window and \a type will be
+ relayed to the function retrieved by QGuiApplication.
+*/
+
+/*!
+ \typedef QXcbWindowFunctions::SetWmWindowIconText
+
+ This is the typedef for the function returned by
+ QGuiApplication::platformFunction when passed the
+ value returned by setWmWindowIconTextIdentifier().
+*/
+
+/*!
+ \fn const QByteArray QXcbWindowFunctions::setWmWindowIconTextIdentifier()
+
+ This function returns the byte array that can be used to query
+ QGuiApplication::platformFunction to retrieve the SetWmWindowIconText function.
+*/
+
+/*!
+ \fn void QXcbWindowFunctions::setWmWindowIconText(QWindow *window, const QString& text)
+
+ This is a convenience function that can be used directly instead
+ of resolving the function pointer. \a window and \a text will be
+ relayed to the function retrieved by QGuiApplication.
+*/
+
+/*!
+ \typedef QXcbWindowFunctions::SetParentRelativeBackPixmap
+
+ This is the typedef for the function returned by
+ QGuiApplication::platformFunction when passed the
+ value returned by setParentRelativeBackPixmapIdentifier().
+*/
+
+/*!
+ \fn const QByteArray QXcbWindowFunctions::setParentRelativeBackPixmapIdentifier()
+
+ This function returns the byte array that can be used to query
+ QGuiApplication::platformFunction to retrieve the SetParentRelativeBackPixmap function.
+*/
+
+/*!
+ \fn void QXcbWindowFunctions::setParentRelativeBackPixmap(const QWindow *window)
+
+ This is a convenience function that can be used directly instead
+ of resolving the function pointer. \a window will be
+ relayed to the function retrieved by QGuiApplication.
+*/
+
+/*!
+ \typedef QXcbWindowFunctions::RequestSystemTrayWindowDock
+
+ This is the typedef for the function returned by
+ QGuiApplication::platformFunction when passed the
+ value returned by requestSystemTrayWindowDockIdentifier().
+*/
+
+/*!
+ \fn const QByteArray QXcbWindowFunctions::requestSystemTrayWindowDockIdentifier()
+
+ This function returns the byte array that can be used to query
+ QGuiApplication::platformFunction to retrieve the RequestSystemTrayWindowDock function.
+*/
+
+/*!
+ \fn bool QXcbWindowFunctions::requestSystemTrayWindowDock(const QWindow *window)
+
+ This is a convenience function that can be used directly instead
+ of resolving the function pointer. \a window will be
+ relayed to the function retrieved by QGuiApplication.
+
+ Returns the boolean result of calling the function or false if the
+ function was not found.
+*/
+
+/*!
+ \typedef QXcbWindowFunctions::SystemTrayWindowGlobalGeometry
+
+ This is the typedef for the function returned by
+ QGuiApplication::platformFunction when passed the
+ value returned by systemTrayWindowGlobalGeometryIdentifier().
+*/
+
+/*!
+ \fn const QByteArray QXcbWindowFunctions::systemTrayWindowGlobalGeometryIdentifier()
+
+ This function returns the byte array that can be used to query
+ QGuiApplication::platformFunction to retrieve the SystemTrayWindowGlobalGeometry function.
+*/
+
+/*!
+ \fn QRect QXcbWindowFunctions::systemTrayWindowGlobalGeometry(const QWindow *window)
+
+ This is a convenience function that can be used directly instead
+ of resolving the function pointer. \a window will be
+ relayed to the function retrieved by QGuiApplication.
+
+ Returns the QRect result of calling the function or an empty
+ QRect if the function was not found.
+*/
+
+/*!
+ \typedef QXcbWindowFunctions::VisualId
+
+ This is the typedef for the function returned by
+ QGuiApplication::platformFunction when passed the
+ value returned by visualIdIdentifier().
+*/
+
+/*!
+ \fn const QByteArray QXcbWindowFunctions::visualIdIdentifier()
+
+ This function returns the byte array that can be used to query
+ QGuiApplication::platformFunction to retrieve the VisualId function.
+*/
+
+/*!
+ \fn uint QXcbWindowFunctions::visualId(QWindow *window)
+
+ This is a convenience function that can be used directly instead
+ of resolving the function pointer. \a window will be
+ relayed to the function retrieved by QGuiApplication.
+
+ Returns the unsigned integer result of calling the function or
+ UINT_MAX if the function was not found.
*/
diff --git a/src/platformheaders/xcbfunctions/xcbfunctions.pri b/src/platformheaders/xcbfunctions/xcbfunctions.pri
index 8844913cd1..7f611d80bd 100644
--- a/src/platformheaders/xcbfunctions/xcbfunctions.pri
+++ b/src/platformheaders/xcbfunctions/xcbfunctions.pri
@@ -1 +1,3 @@
-HEADERS += $$PWD/qxcbwindowfunctions.h
+HEADERS += \
+ $$PWD/qxcbwindowfunctions.h \
+ $$PWD/qxcbintegrationfunctions.h
diff --git a/src/platformsupport/dbusmenu/qdbusmenutypes.cpp b/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
index 73957eacfe..94df0f53dd 100644
--- a/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
+++ b/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
@@ -208,6 +208,7 @@ QDBusMenuItemList QDBusMenuItem::items(const QList<int> &ids, const QStringList
Q_UNUSED(propertyNames)
QDBusMenuItemList ret;
QList<const QDBusPlatformMenuItem *> items = QDBusPlatformMenuItem::byIds(ids);
+ ret.reserve(items.size());
Q_FOREACH (const QDBusPlatformMenuItem *item, items)
ret << QDBusMenuItem(item);
return ret;
diff --git a/src/platformsupport/dbustray/qdbustraytypes.cpp b/src/platformsupport/dbustray/qdbustraytypes.cpp
index 7b7d31b7c3..83b5d5da3f 100644
--- a/src/platformsupport/dbustray/qdbustraytypes.cpp
+++ b/src/platformsupport/dbustray/qdbustraytypes.cpp
@@ -82,6 +82,8 @@ QXdgDBusImageVector iconToQXdgDBusImageVector(const QIcon &icon)
sizes.append(QSize(IconNormalSmallSize * dpr, IconNormalSmallSize * dpr));
if (!hasMediumIcon)
sizes.append(QSize(IconNormalMediumSize * dpr, IconNormalMediumSize * dpr));
+
+ ret.reserve(sizes.size());
foreach (QSize size, sizes) {
// Protocol specifies ARGB32 format in network byte order
QImage im = icon.pixmap(size).toImage().convertToFormat(QImage::Format_ARGB32);
diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp
index 566f84c9ea..d00954375d 100644
--- a/src/platformsupport/fbconvenience/qfbscreen.cpp
+++ b/src/platformsupport/fbconvenience/qfbscreen.cpp
@@ -206,10 +206,11 @@ void QFbScreen::generateRects()
}
#endif
}
- foreach (const QRect &rect, remainingScreen.rects())
+ const QVector<QRect> remainingScreenRects = remainingScreen.rects();
+ mCachedRects.reserve(mCachedRects.count() + remainingScreenRects.count());
+ foreach (const QRect &rect, remainingScreenRects)
mCachedRects += QPair<QRect, int>(rect, -1);
mIsUpToDate = true;
- return;
}
QRegion QFbScreen::doRedraw()
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index be70092010..75c4065d66 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -48,18 +48,6 @@
QT_BEGIN_NAMESPACE
-namespace {
-class AutoReleasePool
-{
-public:
- AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
- ~AutoReleasePool() { [pool release]; }
-
-private:
- NSAutoreleasePool *pool;
-};
-}
-
// this could become a list of all languages used for each writing
// system, instead of using the single most common language.
static const char *languageForWritingSystem[] = {
@@ -453,7 +441,7 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
Q_UNUSED(style);
Q_UNUSED(script);
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
static QHash<QString, QStringList> fallbackLists;
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
index 885326e512..1556be5cc1 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
@@ -418,11 +418,11 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data)
m_currentData.y = qBound(hw_range_y_min, data->value, hw_range_y_max);
if (m_singleTouch)
m_contacts[m_currentSlot].y = m_currentData.y;
- if (m_typeB) {
- m_contacts[m_currentSlot].y = m_currentData.y;
- if (m_contacts[m_currentSlot].state == Qt::TouchPointStationary)
- m_contacts[m_currentSlot].state = Qt::TouchPointMoved;
- }
+ if (m_typeB) {
+ m_contacts[m_currentSlot].y = m_currentData.y;
+ if (m_contacts[m_currentSlot].state == Qt::TouchPointStationary)
+ m_contacts[m_currentSlot].state = Qt::TouchPointMoved;
+ }
} else if (data->code == ABS_MT_TRACKING_ID) {
m_currentData.trackingId = data->value;
if (m_typeB) {
diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
index c040dab5e1..47c37ba6dc 100644
--- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
@@ -1431,7 +1431,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
QSpiObjectReference(connection, QDBusObjectPath(QSPI_OBJECT_PATH_ROOT))));
} else if (function == QLatin1String("GetChildren")) {
QSpiObjectReferenceArray children;
- for (int i = 0; i < interface->childCount(); ++i) {
+ const int numChildren = interface->childCount();
+ children.reserve(numChildren);
+ for (int i = 0; i < numChildren; ++i) {
QString childPath = pathForInterface(interface->child(i));
QSpiObjectReference ref(connection, QDBusObjectPath(childPath));
children << ref;
@@ -1747,7 +1749,9 @@ QSpiActionArray AtSpiAdaptor::getActions(QAccessibleInterface *interface) const
{
QAccessibleActionInterface *actionInterface = interface->actionInterface();
QSpiActionArray actions;
- Q_FOREACH (const QString &actionName, QAccessibleBridgeUtils::effectiveActionNames(interface)) {
+ const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface);
+ actions.reserve(actionNames.size());
+ Q_FOREACH (const QString &actionName, actionNames) {
QSpiAction action;
QStringList keyBindings;
diff --git a/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/src/platformsupport/linuxaccessibility/dbusconnection.cpp
index 45729fa065..637b06549a 100644
--- a/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+++ b/src/platformsupport/linuxaccessibility/dbusconnection.cpp
@@ -42,6 +42,9 @@
#include <QDBusConnectionInterface>
#include "bus_interface.h"
+#include <QtGui/qguiapplication.h>
+#include <qplatformnativeinterface.h>
+
QT_BEGIN_NAMESPACE
QString A11Y_SERVICE = QStringLiteral("org.a11y.Bus");
@@ -65,6 +68,29 @@ DBusConnection::DBusConnection(QObject *parent)
// If it is registered already, setup a11y right away
if (c.interface()->isServiceRegistered(A11Y_SERVICE))
serviceRegistered();
+
+ // In addition try if there is an xatom exposing the bus address, this allows applications run as root to work
+ QString address = getAddressFromXCB();
+ if (!address.isEmpty()) {
+ m_enabled = true;
+ connectA11yBus(address);
+ }
+}
+
+QString DBusConnection::getAddressFromXCB()
+{
+ QGuiApplication *app = qobject_cast<QGuiApplication *>(QCoreApplication::instance());
+ if (!app)
+ return QString();
+ QPlatformNativeInterface *platformNativeInterface = app->platformNativeInterface();
+ QByteArray *addressByteArray = reinterpret_cast<QByteArray*>(
+ platformNativeInterface->nativeResourceForIntegration(QByteArrayLiteral("AtspiBus")));
+ if (addressByteArray) {
+ QString address = QString::fromLatin1(*addressByteArray);
+ delete addressByteArray;
+ return address;
+ }
+ return QString();
}
// We have the a11y registry on the session bus.
diff --git a/src/platformsupport/linuxaccessibility/dbusconnection_p.h b/src/platformsupport/linuxaccessibility/dbusconnection_p.h
index a0bd6450bf..30707a3f95 100644
--- a/src/platformsupport/linuxaccessibility/dbusconnection_p.h
+++ b/src/platformsupport/linuxaccessibility/dbusconnection_p.h
@@ -68,6 +68,7 @@ Q_SIGNALS:
void enabledChanged(bool enabled);
private Q_SLOTS:
+ QString getAddressFromXCB();
void serviceRegistered();
void serviceUnregistered();
void connectA11yBus(const QString &address);
diff --git a/src/plugins/bearer/connman/main.cpp b/src/plugins/bearer/connman/main.cpp
index a84121e89b..f1e9d763a7 100644
--- a/src/plugins/bearer/connman/main.cpp
+++ b/src/plugins/bearer/connman/main.cpp
@@ -36,7 +36,6 @@
#include <QtCore/qdebug.h>
-#ifndef QT_NO_BEARERMANAGEMENT
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
@@ -78,4 +77,3 @@ QT_END_NAMESPACE
#include "main.moc"
#endif
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp
index 7911857ff5..b7cc5f949c 100644
--- a/src/plugins/bearer/connman/qconnmanengine.cpp
+++ b/src/plugins/bearer/connman/qconnmanengine.cpp
@@ -46,7 +46,6 @@
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusMessage>
#include <QtDBus/QDBusReply>
-#ifndef QT_NO_BEARERMANAGEMENT
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
@@ -122,8 +121,10 @@ QList<QNetworkConfigurationPrivate *> QConnmanEngine::getConfigurations()
QMutexLocker locker(&mutex);
QList<QNetworkConfigurationPrivate *> fetchedConfigurations;
QNetworkConfigurationPrivate* cpPriv = 0;
+ const int numFoundConfigurations = foundConfigurations.count();
+ fetchedConfigurations.reserve(numFoundConfigurations);
- for (int i = 0; i < foundConfigurations.count(); ++i) {
+ for (int i = 0; i < numFoundConfigurations; ++i) {
QNetworkConfigurationPrivate *config = new QNetworkConfigurationPrivate;
cpPriv = foundConfigurations.at(i);
@@ -556,4 +557,3 @@ void QConnmanEngine::reEvaluateCellular()
QT_END_NAMESPACE
#endif // QT_NO_DBUS
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h
index 2c1f5490e3..8c79b22bf9 100644
--- a/src/plugins/bearer/connman/qconnmanengine.h
+++ b/src/plugins/bearer/connman/qconnmanengine.h
@@ -53,7 +53,6 @@
#include <QMap>
#include <QVariant>
-#ifndef QT_NO_BEARERMANAGEMENT
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
@@ -135,7 +134,6 @@ protected:
QT_END_NAMESPACE
#endif // QT_NO_DBUS
-#endif // QT_NO_BEARERMANAGEMENT
#endif
diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp
index 155e6970fa..d23d6e5f88 100644
--- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp
+++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp
@@ -45,7 +45,6 @@
#include "qconnmanservice_linux_p.h"
-#ifndef QT_NO_BEARERMANAGEMENT
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
@@ -504,5 +503,3 @@ void QConnmanTechnologyInterface::scanReply(QDBusPendingCallWatcher *call)
QT_END_NAMESPACE
#endif // QT_NO_DBUS
-#endif // QT_NO_BEARERMANAGEMENT
-
diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h
index 49ca9f391c..1a10a2260a 100644
--- a/src/plugins/bearer/connman/qconnmanservice_linux_p.h
+++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h
@@ -58,7 +58,6 @@
#include <QtDBus/QDBusContext>
#include <QMap>
-#ifndef QT_NO_BEARERMANAGEMENT
#ifndef QT_NO_DBUS
#ifndef __CONNMAN_DBUS_H
@@ -219,6 +218,5 @@ private:
QT_END_NAMESPACE
#endif // QT_NO_DBUS
-#endif // QT_NO_BEARERMANAGEMENT
#endif //QCONNMANSERVICE_H
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
index eb756db39e..6d16b59d35 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm
@@ -77,12 +77,11 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
- (id) init
{
[locker lock];
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
notificationCenter = [NSNotificationCenter defaultCenter];
currentInterface = [CWInterface interfaceWithName:nil];
[notificationCenter addObserver:self selector:@selector(notificationHandler:) name:CWPowerDidChangeNotification object:nil];
[locker unlock];
- [autoreleasepool release];
return self;
}
@@ -154,7 +153,7 @@ void QScanThread::quit()
void QScanThread::run()
{
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
QStringList found;
mutex.lock();
CWInterface *currentInterface = [CWInterface interfaceWithName: QCFString::toNSString(interfaceName)];
@@ -236,7 +235,6 @@ void QScanThread::run()
}
}
emit networksChanged();
- [autoreleasepool release];
}
QStringList QScanThread::foundNetwork(const QString &id, const QString &name, const QNetworkConfiguration::StateFlags state, const QString &interfaceName, const QNetworkConfiguration::Purpose purpose)
@@ -276,7 +274,7 @@ void QScanThread::getUserConfigurations()
{
QMutexLocker locker(&mutex);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
userProfiles.clear();
NSSet *wifiInterfaces = [CWInterface interfaceNames];
@@ -357,7 +355,6 @@ void QScanThread::getUserConfigurations()
}
}
}
- [autoreleasepool release];
}
QString QScanThread::getSsidFromNetworkName(const QString &name)
@@ -436,7 +433,7 @@ QCoreWlanEngine::~QCoreWlanEngine()
void QCoreWlanEngine::initialize()
{
QMutexLocker locker(&mutex);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
if ([[CWInterface interfaceNames] count] > 0 && !listener) {
listener = [[QT_MANGLE_NAMESPACE(QNSListener) alloc] init];
@@ -448,7 +445,6 @@ void QCoreWlanEngine::initialize()
storeSession = NULL;
startNetworkChangeLoop();
- [autoreleasepool release];
}
@@ -469,7 +465,7 @@ bool QCoreWlanEngine::hasIdentifier(const QString &id)
void QCoreWlanEngine::connectToId(const QString &id)
{
QMutexLocker locker(&mutex);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
QString interfaceString = getInterfaceFromId(id);
CWInterface *wifiInterface =
@@ -541,7 +537,6 @@ void QCoreWlanEngine::connectToId(const QString &id)
locker.unlock();
emit connectionError(id, InterfaceLookupError);
- [autoreleasepool release];
}
void QCoreWlanEngine::disconnectFromId(const QString &id)
@@ -554,7 +549,7 @@ void QCoreWlanEngine::disconnectFromId(const QString &id)
emit connectionError(id, DisconnectionError);
return;
}
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
CWInterface *wifiInterface =
[CWInterface interfaceWithName: QCFString::toNSString(interfaceString)];
@@ -563,14 +558,13 @@ void QCoreWlanEngine::disconnectFromId(const QString &id)
[wifiInterface disassociate];
QTimer::singleShot(1000, this,SLOT(checkDisconnect()));
- [autoreleasepool release];
}
void QCoreWlanEngine::checkDisconnect()
{
QMutexLocker locker(&mutex);
if (!disconnectedInterfaceString.isEmpty()) {
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
CWInterface *wifiInterface =
[CWInterface interfaceWithName: QCFString::toNSString(disconnectedInterfaceString)];
@@ -582,7 +576,6 @@ void QCoreWlanEngine::checkDisconnect()
emit connectionError(id, DisconnectionError);
locker.relock();
}
- [autoreleasepool release];
disconnectedInterfaceString.clear();
}
}
@@ -597,7 +590,7 @@ void QCoreWlanEngine::doRequestUpdate()
{
QMutexLocker locker(&mutex);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
NSSet *wifiInterfaces = [CWInterface interfaceNames];
for (NSString *ifName in wifiInterfaces) {
@@ -607,7 +600,6 @@ void QCoreWlanEngine::doRequestUpdate()
locker.unlock();
if ([wifiInterfaces count] == 0)
networksChanged();
- [autoreleasepool release];
}
bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
@@ -615,12 +607,11 @@ bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
QMutexLocker locker(&mutex);
bool haswifi = false;
if(hasWifi) {
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
CWInterface *defaultInterface = [CWInterface interfaceWithName: QCFString::toNSString(wifiDeviceName)];
if (defaultInterface.powerOn) {
haswifi = true;
}
- [autoreleasepool release];
}
return haswifi;
}
@@ -814,7 +805,7 @@ quint64 QCoreWlanEngine::bytesReceived(const QString &id)
quint64 QCoreWlanEngine::startTime(const QString &identifier)
{
QMutexLocker locker(&mutex);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
quint64 timestamp = 0;
NSString *filePath = @"/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist";
@@ -861,7 +852,6 @@ quint64 QCoreWlanEngine::startTime(const QString &identifier)
}
}
}
- [autoreleasepool release];
return timestamp;
}
diff --git a/src/plugins/bearer/generic/main.cpp b/src/plugins/bearer/generic/main.cpp
index 112c7420e1..4f79807128 100644
--- a/src/plugins/bearer/generic/main.cpp
+++ b/src/plugins/bearer/generic/main.cpp
@@ -37,8 +37,6 @@
#include <QtCore/qdebug.h>
-#ifndef QT_NO_BEARERMANAGEMENT
-
QT_BEGIN_NAMESPACE
class QGenericEnginePlugin : public QBearerEnginePlugin
@@ -72,5 +70,3 @@ QBearerEngine *QGenericEnginePlugin::create(const QString &key) const
QT_END_NAMESPACE
#include "main.moc"
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp
index e1b3d79b38..605e9044c3 100644
--- a/src/plugins/bearer/generic/qgenericengine.cpp
+++ b/src/plugins/bearer/generic/qgenericengine.cpp
@@ -61,8 +61,6 @@ typedef ULONG NDIS_OID, *PNDIS_OID;
#include <unistd.h>
#endif
-#ifndef QT_NO_BEARERMANAGEMENT
-
QT_BEGIN_NAMESPACE
#ifndef QT_NO_NETWORKINTERFACE
@@ -385,5 +383,3 @@ bool QGenericEngine::requiresPolling() const
}
QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/generic/qgenericengine.h b/src/plugins/bearer/generic/qgenericengine.h
index 9acd6c4c2e..4b99c90051 100644
--- a/src/plugins/bearer/generic/qgenericengine.h
+++ b/src/plugins/bearer/generic/qgenericengine.h
@@ -39,8 +39,6 @@
#include <QMap>
#include <QTimer>
-#ifndef QT_NO_BEARERMANAGEMENT
-
QT_BEGIN_NAMESPACE
class QNetworkConfigurationPrivate;
@@ -82,7 +80,5 @@ private:
QT_END_NAMESPACE
-#endif // QT_NO_BEARERMANAGEMENT
-
#endif
diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp
index 6e427544fa..9b83386abb 100644
--- a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp
+++ b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp
@@ -45,7 +45,6 @@
#include "qofonoservice_linux_p.h"
-#ifndef QT_NO_BEARERMANAGEMENT
#ifndef QT_NO_DBUS
QDBusArgument &operator<<(QDBusArgument &argument, const ObjectPathProperties &item)
@@ -382,4 +381,3 @@ QString QOfonoConnectionContextInterface::name()
QT_END_NAMESPACE
#endif // QT_NO_DBUS
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux_p.h b/src/plugins/bearer/linux_common/qofonoservice_linux_p.h
index b051b8feaa..57ea089ec8 100644
--- a/src/plugins/bearer/linux_common/qofonoservice_linux_p.h
+++ b/src/plugins/bearer/linux_common/qofonoservice_linux_p.h
@@ -57,7 +57,6 @@
#include <QtDBus/QDBusContext>
#include <QMap>
-#ifndef QT_NO_BEARERMANAGEMENT
#ifndef QT_NO_DBUS
#define OFONO_SERVICE "org.ofono"
@@ -193,6 +192,5 @@ private slots:
QT_END_NAMESPACE
#endif // QT_NO_DBUS
-#endif // QT_NO_BEARERMANAGEMENT
#endif //QOFONOSERVICE_H
diff --git a/src/plugins/bearer/networkmanager/main.cpp b/src/plugins/bearer/networkmanager/main.cpp
index 8a872cf08f..0d22846c44 100644
--- a/src/plugins/bearer/networkmanager/main.cpp
+++ b/src/plugins/bearer/networkmanager/main.cpp
@@ -37,7 +37,6 @@
#include <QtCore/qdebug.h>
-#ifndef QT_NO_BEARERMANAGEMENT
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
@@ -77,4 +76,3 @@ QT_END_NAMESPACE
#include "main.moc"
#endif // QT_NO_DBUS
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
index e662d5f2d3..7258877eb7 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
@@ -49,7 +49,6 @@
#include <QDBusReply>
#include "../linux_common/qofonoservice_linux_p.h"
-#ifndef QT_NO_BEARERMANAGEMENT
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
@@ -1129,4 +1128,3 @@ void QNetworkManagerEngine::ofonoUnRegistered(const QString &)
QT_END_NAMESPACE
#endif // QT_NO_DBUS
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
index 3d90fcd0e5..1f578890dc 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
@@ -54,7 +54,6 @@
#include <QMap>
#include <QVariant>
-#ifndef QT_NO_BEARERMANAGEMENT
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
@@ -150,7 +149,6 @@ private:
QT_END_NAMESPACE
#endif // QT_NO_DBUS
-#endif // QT_NO_BEARERMANAGEMENT
#endif
diff --git a/src/plugins/bearer/qbearerengine_impl.h b/src/plugins/bearer/qbearerengine_impl.h
index 6db4d8c6b2..a343474f2c 100644
--- a/src/plugins/bearer/qbearerengine_impl.h
+++ b/src/plugins/bearer/qbearerengine_impl.h
@@ -36,8 +36,6 @@
#include <QtNetwork/private/qbearerengine_p.h>
-#ifndef QT_NO_BEARERMANAGEMENT
-
QT_BEGIN_NAMESPACE
class QBearerEngineImpl : public QBearerEngine
@@ -74,6 +72,4 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QBearerEngineImpl::ConnectionError)
-#endif // QT_NO_BEARERMANAGEMENT
-
#endif // QBEARERENGINE_IMPL_H
diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp
index f3f3729504..5e9e5e7015 100644
--- a/src/plugins/bearer/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/qnetworksession_impl.cpp
@@ -42,8 +42,6 @@
#include <QtCore/qmutex.h>
#include <QtCore/qstringlist.h>
-#ifndef QT_NO_BEARERMANAGEMENT
-
QT_BEGIN_NAMESPACE
static QBearerEngineImpl *getEngineFromId(const QString &id)
@@ -423,5 +421,3 @@ void QNetworkSessionPrivateImpl::decrementTimeout()
}
QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/qnetworksession_impl.h b/src/plugins/bearer/qnetworksession_impl.h
index 87a2b29bd4..a26b05ab3b 100644
--- a/src/plugins/bearer/qnetworksession_impl.h
+++ b/src/plugins/bearer/qnetworksession_impl.h
@@ -50,8 +50,6 @@
#include <QtNetwork/private/qnetworkconfigmanager_p.h>
#include <QtNetwork/private/qnetworksession_p.h>
-#ifndef QT_NO_BEARERMANAGEMENT
-
QT_BEGIN_NAMESPACE
class QBearerEngineImpl;
@@ -123,6 +121,4 @@ private:
QT_END_NAMESPACE
-#endif // QT_NO_BEARERMANAGEMENT
-
#endif // QNETWORKSESSION_IMPL_H
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
index 5211ed8381..dd161570e8 100644
--- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp
+++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
@@ -317,6 +317,7 @@ void QTuioHandler::process2DCurFseq(const QOscMessage &message)
return;
QList<QWindowSystemInterface::TouchPoint> tpl;
+ tpl.reserve(m_activeCursors.size() + m_deadCursors.size());
foreach (const QTuioCursor &tc, m_activeCursors) {
QWindowSystemInterface::TouchPoint tp = cursorToTouchPoint(tc, win);
diff --git a/src/plugins/imageformats/gif/main.cpp b/src/plugins/imageformats/gif/main.cpp
index 8181900adb..62c4f4b597 100644
--- a/src/plugins/imageformats/gif/main.cpp
+++ b/src/plugins/imageformats/gif/main.cpp
@@ -34,8 +34,6 @@
#include <qimageiohandler.h>
#include <qstringlist.h>
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-
#include "main.h"
#ifdef QT_NO_IMAGEFORMAT_GIF
@@ -69,6 +67,4 @@ QImageIOHandler *QGifPlugin::create(QIODevice *device, const QByteArray &format)
return handler;
}
-#endif // QT_NO_IMAGEFORMATPLUGIN
-
QT_END_NAMESPACE
diff --git a/src/plugins/imageformats/gif/main.h b/src/plugins/imageformats/gif/main.h
index 1b02d5eaf6..56e0655b1f 100644
--- a/src/plugins/imageformats/gif/main.h
+++ b/src/plugins/imageformats/gif/main.h
@@ -34,8 +34,6 @@
#include <qimageiohandler.h>
#include <qstringlist.h>
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-
#ifdef QT_NO_IMAGEFORMAT_GIF
#undef QT_NO_IMAGEFORMAT_GIF
#endif
@@ -56,5 +54,3 @@ public:
};
QT_END_NAMESPACE
-
-#endif // QT_NO_IMAGEFORMATPLUGIN
diff --git a/src/plugins/imageformats/ico/main.cpp b/src/plugins/imageformats/ico/main.cpp
index 80182fb665..03448d4ae1 100644
--- a/src/plugins/imageformats/ico/main.cpp
+++ b/src/plugins/imageformats/ico/main.cpp
@@ -33,8 +33,6 @@
#include "main.h"
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-
QT_BEGIN_NAMESPACE
QImageIOPlugin::Capabilities QICOPlugin::capabilities(QIODevice *device, const QByteArray &format) const
@@ -63,5 +61,3 @@ QImageIOHandler *QICOPlugin::create(QIODevice *device, const QByteArray &format)
}
QT_END_NAMESPACE
-
-#endif /* QT_NO_IMAGEFORMATPLUGIN */
diff --git a/src/plugins/imageformats/ico/main.h b/src/plugins/imageformats/ico/main.h
index a254a626d1..d17dbe824d 100644
--- a/src/plugins/imageformats/ico/main.h
+++ b/src/plugins/imageformats/ico/main.h
@@ -34,8 +34,6 @@
#include <qimageiohandler.h>
#include <qdebug.h>
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-
#ifdef QT_NO_IMAGEFORMAT_ICO
#undef QT_NO_IMAGEFORMAT_ICO
#endif
@@ -53,5 +51,3 @@ public:
};
QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp
index 4cb5e22bf7..2ddbc4519b 100644
--- a/src/plugins/imageformats/ico/qicohandler.cpp
+++ b/src/plugins/imageformats/ico/qicohandler.cpp
@@ -96,9 +96,9 @@ public:
QImage iconAt(int index);
static bool canRead(QIODevice *iodev);
- static QList<QImage> read(QIODevice * device);
+ static QVector<QImage> read(QIODevice *device);
- static bool write(QIODevice * device, const QList<QImage> & images);
+ static bool write(QIODevice *device, const QVector<QImage> &images);
private:
bool readHeader();
@@ -612,12 +612,14 @@ QImage ICOReader::iconAt(int index)
\sa write()
*/
-QList<QImage> ICOReader::read(QIODevice * device)
+QVector<QImage> ICOReader::read(QIODevice *device)
{
- QList<QImage> images;
+ QVector<QImage> images;
ICOReader reader(device);
- for (int i = 0; i < reader.count(); i++)
+ const int N = reader.count();
+ images.reserve(N);
+ for (int i = 0; i < N; i++)
images += reader.iconAt(i);
return images;
@@ -636,7 +638,7 @@ QList<QImage> ICOReader::read(QIODevice * device)
\sa read()
*/
-bool ICOReader::write(QIODevice * device, const QList<QImage> & images)
+bool ICOReader::write(QIODevice *device, const QVector<QImage> &images)
{
bool retValue = false;
@@ -849,7 +851,7 @@ bool QtIcoHandler::read(QImage *image)
bool QtIcoHandler::write(const QImage &image)
{
QIODevice *device = QImageIOHandler::device();
- QList<QImage> imgs;
+ QVector<QImage> imgs;
imgs.append(image);
return ICOReader::write(device, imgs);
}
diff --git a/src/plugins/imageformats/jpeg/main.cpp b/src/plugins/imageformats/jpeg/main.cpp
index d009707fa0..c8a575cb43 100644
--- a/src/plugins/imageformats/jpeg/main.cpp
+++ b/src/plugins/imageformats/jpeg/main.cpp
@@ -33,8 +33,6 @@
#include "main.h"
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-
#ifdef QT_NO_IMAGEFORMAT_JPEG
#undef QT_NO_IMAGEFORMAT_JPEG
#endif
@@ -68,5 +66,3 @@ QImageIOHandler *QJpegPlugin::create(QIODevice *device, const QByteArray &format
}
QT_END_NAMESPACE
-
-#endif // QT_NO_IMAGEFORMATPLUGIN
diff --git a/src/plugins/imageformats/jpeg/main.h b/src/plugins/imageformats/jpeg/main.h
index 2d79c84666..77ee33faca 100644
--- a/src/plugins/imageformats/jpeg/main.h
+++ b/src/plugins/imageformats/jpeg/main.h
@@ -34,8 +34,6 @@
#include <qimageiohandler.h>
#include <qstringlist.h>
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-
#ifdef QT_NO_IMAGEFORMAT_JPEG
#undef QT_NO_IMAGEFORMAT_JPEG
#endif
@@ -52,5 +50,3 @@ public:
};
QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/platforminputcontexts/compose/compose.pro b/src/plugins/platforminputcontexts/compose/compose.pro
index a9da36c473..a4b5280e64 100644
--- a/src/plugins/platforminputcontexts/compose/compose.pro
+++ b/src/plugins/platforminputcontexts/compose/compose.pro
@@ -5,7 +5,7 @@ PLUGIN_EXTENDS = -
PLUGIN_CLASS_NAME = QComposePlatformInputContextPlugin
load(qt_plugin)
-QT += gui-private
+QT += core-private gui-private
DEFINES += X11_PREFIX='\\"$$QMAKE_X11_PREFIX\\"'
diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
index 65020eb848..ad9877eb25 100644
--- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
@@ -36,8 +36,12 @@
#include <QtCore/QByteArray>
#include <QtCore/QTextCodec>
#include <QtCore/QDebug>
+#include <QtCore/QDir>
#include <QtCore/QStringList>
#include <QtCore/QString>
+#include <QtCore/QSaveFile>
+#include <QtCore/QStandardPaths>
+#include <private/qcore_unix_p.h>
#include <algorithm>
@@ -48,12 +52,191 @@
#include <strings.h> // strncasecmp
#include <clocale> // LC_CTYPE
+static const quint32 SupportedCacheVersion = 1;
+
+/*
+ In short on how and why the "Compose" file is cached:
+
+ The "Compose" file is large, for en_US it's likely located at:
+ /usr/share/X11/locale/en_US.UTF-8/Compose
+ and it has about 6000 string lines.
+ Q(Gui)Applications parse this file each time they're created. On modern CPUs
+ it incurs a 4-10 ms startup penalty of each Qt gui app, on older CPUs -
+ tens of ms or more.
+ Since the "Compose" file (almost) never changes using a pre-parsed
+ cache file instead of the "Compose" file is a good idea to improve Qt5
+ application startup time by about 5+ ms (or tens of ms on older CPUs).
+
+ The cache file contains the contents of the QComposeCacheFileHeader struct at the
+ beginning followed by the pre-parsed contents of the "Compose" file.
+
+ struct QComposeCacheFileHeader stores
+ (a) The cache version - in the unlikely event that some day one might need
+ to break compatibility.
+ (b) The (cache) file size.
+ (c) The lastModified field tracks if anything changed since the last time
+ the cache file was saved.
+ If anything did change then we read the compose file and save (cache) it
+ in binary/pre-parsed format, which should happen extremely rarely if at all.
+*/
+
+struct QComposeCacheFileHeader
+{
+ quint32 cacheVersion;
+ // The compiler will add 4 padding bytes anyway.
+ // Reserve them explicitly to possibly use in the future.
+ quint32 reserved;
+ quint64 fileSize;
+ qint64 lastModified;
+};
+
+// localHostName() copied from qtbase/src/corelib/io/qlockfile_unix.cpp
+static QByteArray localHostName()
+{
+ QByteArray hostName(512, Qt::Uninitialized);
+ if (gethostname(hostName.data(), hostName.size()) == -1)
+ return QByteArray();
+ hostName.truncate(strlen(hostName.data()));
+ return hostName;
+}
+
+/*
+ Reads metadata about the Compose file. Later used to determine if the
+ compose cache should be updated. The fileSize field will be zero on failure.
+*/
+static QComposeCacheFileHeader readFileMetadata(const QString &path)
+{
+ QComposeCacheFileHeader info;
+ info.reserved = 0;
+ info.fileSize = 0;
+ const QByteArray pathBytes = QFile::encodeName(path);
+ QT_STATBUF st;
+ if (QT_STAT(pathBytes.data(), &st) != 0)
+ return info;
+ info.lastModified = st.st_mtime;
+ info.fileSize = st.st_size;
+ return info;
+}
+
+static const QString getCacheFilePath()
+{
+ QFile machineIdFile("/var/lib/dbus/machine-id");
+ QString machineId;
+ if (machineIdFile.exists()) {
+ if (machineIdFile.open(QIODevice::ReadOnly))
+ machineId = QString::fromLatin1(machineIdFile.readAll().trimmed());
+ }
+ if (machineId.isEmpty())
+ machineId = localHostName();
+ const QString dirPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+
+ if (QSysInfo::ByteOrder == QSysInfo::BigEndian)
+ return dirPath + QLatin1String("/qt_compose_cache_big_endian_") + machineId;
+ return dirPath + QLatin1String("/qt_compose_cache_little_endian_") + machineId;
+}
+
+// Returns empty vector on failure
+static QVector<QComposeTableElement> loadCache(const QComposeCacheFileHeader &composeInfo)
+{
+ QVector<QComposeTableElement> vec;
+ const QString cacheFilePath = getCacheFilePath();
+ QFile inputFile(cacheFilePath);
+
+ if (!inputFile.open(QIODevice::ReadOnly))
+ return vec;
+ QComposeCacheFileHeader cacheInfo;
+ // use a "buffer" variable to make the line after this one more readable.
+ char *buffer = reinterpret_cast<char*>(&cacheInfo);
+
+ if (inputFile.read(buffer, sizeof cacheInfo) != sizeof cacheInfo)
+ return vec;
+ if (cacheInfo.fileSize == 0)
+ return vec;
+ // using "!=" just in case someone replaced with a backup that existed before
+ if (cacheInfo.lastModified != composeInfo.lastModified)
+ return vec;
+ if (cacheInfo.cacheVersion != SupportedCacheVersion)
+ return vec;
+ const QByteArray pathBytes = QFile::encodeName(cacheFilePath);
+ QT_STATBUF st;
+ if (QT_STAT(pathBytes.data(), &st) != 0)
+ return vec;
+ const off_t fileSize = st.st_size;
+ if (fileSize > 1024 * 1024 * 5) {
+ // The cache file size is usually about 150KB, so if its size is over
+ // say 5MB then somebody inflated the file, abort.
+ return vec;
+ }
+ const off_t bufferSize = fileSize - (sizeof cacheInfo);
+ const size_t elemSize = sizeof (struct QComposeTableElement);
+ const int elemCount = bufferSize / elemSize;
+ const QByteArray ba = inputFile.read(bufferSize);
+ const char *data = ba.data();
+ // Since we know the number of the (many) elements and their size in
+ // advance calling vector.reserve(..) seems reasonable.
+ vec.reserve(elemCount);
+
+ for (int i = 0; i < elemCount; i++) {
+ const QComposeTableElement *elem =
+ reinterpret_cast<const QComposeTableElement*>(data + (i * elemSize));
+ vec.push_back(*elem);
+ }
+ return vec;
+}
+
+// Returns true on success, false otherwise.
+static bool saveCache(const QComposeCacheFileHeader &info, const QVector<QComposeTableElement> &vec)
+{
+ const QString filePath = getCacheFilePath();
+ QSaveFile outputFile(filePath);
+
+ if (!outputFile.open(QIODevice::WriteOnly))
+ return false;
+ const char *data = reinterpret_cast<const char*>(&info);
+
+ if (outputFile.write(data, sizeof info) != sizeof info)
+ return false;
+ data = reinterpret_cast<const char*>(vec.constData());
+ const qint64 size = vec.size() * (sizeof (struct QComposeTableElement));
+
+ if (outputFile.write(data, size) != size)
+ return false;
+ return outputFile.commit();
+}
+
TableGenerator::TableGenerator() : m_state(NoErrors),
m_systemComposeDir(QString())
{
initPossibleLocations();
- findComposeFile();
- orderComposeTable();
+ QString composeFilePath = findComposeFile();
+#ifdef DEBUG_GENERATOR
+// don't use cache when in debug mode.
+ if (!composeFilePath.isEmpty())
+ qDebug() << "Using Compose file from: " << composeFilePath;
+#else
+ QComposeCacheFileHeader fileInfo = readFileMetadata(composeFilePath);
+ if (fileInfo.fileSize != 0)
+ m_composeTable = loadCache(fileInfo);
+#endif
+ if (m_composeTable.isEmpty() && cleanState()) {
+ if (composeFilePath.isEmpty()) {
+ m_state = MissingComposeFile;
+ } else {
+ QFile composeFile(composeFilePath);
+ composeFile.open(QIODevice::ReadOnly);
+ parseComposeFile(&composeFile);
+ orderComposeTable();
+ if (m_composeTable.isEmpty()) {
+ m_state = EmptyTable;
+#ifndef DEBUG_GENERATOR
+// don't save cache when in debug mode
+ } else {
+ fileInfo.cacheVersion = SupportedCacheVersion;
+ saveCache(fileInfo, m_composeTable);
+#endif
+ }
+ }
+ }
#ifdef DEBUG_GENERATOR
printComposeTable();
#endif
@@ -76,53 +259,39 @@ void TableGenerator::initPossibleLocations()
m_possibleLocations.append(QStringLiteral(X11_PREFIX "/lib/X11/locale"));
}
-void TableGenerator::findComposeFile()
+QString TableGenerator::findComposeFile()
{
- bool found = false;
// check if XCOMPOSEFILE points to a Compose file
if (qEnvironmentVariableIsSet("XCOMPOSEFILE")) {
- QString composeFile(qgetenv("XCOMPOSEFILE"));
- if (composeFile.endsWith(QLatin1String("Compose")))
- found = processFile(composeFile);
+ QString path(qgetenv("XCOMPOSEFILE"));
+ if (path.endsWith(QLatin1String("Compose")))
+ return path;
else
qWarning("Qt Warning: XCOMPOSEFILE doesn't point to a valid Compose file");
-#ifdef DEBUG_GENERATOR
- if (found)
- qDebug() << "Using Compose file from: " << composeFile;
-#endif
}
+
// check if user’s home directory has a file named .XCompose
- if (!found && cleanState()) {
- QString composeFile = qgetenv("HOME") + QStringLiteral("/.XCompose");
- if (QFile(composeFile).exists())
- found = processFile(composeFile);
-#ifdef DEBUG_GENERATOR
- if (found)
- qDebug() << "Using Compose file from: " << composeFile;
-#endif
+ if (cleanState()) {
+ QString path = qgetenv("HOME") + QStringLiteral("/.XCompose");
+ if (QFile(path).exists())
+ return path;
}
+
// check for the system provided compose files
- if (!found && cleanState()) {
+ if (cleanState()) {
QString table = composeTableForLocale();
if (cleanState()) {
if (table.isEmpty())
// no table mappings for the system's locale in the compose.dir
m_state = UnsupportedLocale;
- else
- found = processFile(systemComposeDir() + QLatin1Char('/') + table);
-#ifdef DEBUG_GENERATOR
- if (found)
- qDebug() << "Using Compose file from: " <<
- systemComposeDir() + QLatin1Char('/') + table;
-#endif
+ else {
+ QString path = QDir(systemComposeDir()).filePath(table);
+ if (QFile(path).exists())
+ return path;
+ }
}
}
-
- if (found && m_composeTable.isEmpty())
- m_state = EmptyTable;
-
- if (!found)
- m_state = MissingComposeFile;
+ return QString();
}
QString TableGenerator::composeTableForLocale()
diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h
index 468da4cad1..8ad081bea5 100644
--- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h
+++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h
@@ -43,6 +43,8 @@
//#define DEBUG_GENERATOR
+/* Whenever QComposeTableElement gets modified supportedCacheVersion
+ from qtablegenerator.cpp must be bumped. */
struct QComposeTableElement {
uint keys[QT_KEYSEQUENCE_MAX_LEN];
uint value;
@@ -107,7 +109,7 @@ protected:
void parseKeySequence(char *line);
void parseIncludeInstruction(QString line);
- void findComposeFile();
+ QString findComposeFile();
bool findSystemComposeDir();
QString systemComposeDir();
QString composeTableForLocale();
diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
index 673942b5d9..0b5775bc15 100644
--- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
+++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
@@ -340,7 +340,7 @@ QIBusPlatformInputContextPrivate::QIBusPlatformInputContextPrivate()
QDBusConnection *QIBusPlatformInputContextPrivate::createConnection()
{
- QByteArray display(getenv("DISPLAY"));
+ QByteArray display(qgetenv("DISPLAY"));
QByteArray host = "unix";
QByteArray displayNumber = "0";
diff --git a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp
index d6be6cbb31..f88e5ca5a3 100644
--- a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp
+++ b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp
@@ -225,9 +225,10 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, QIBusAttributeList &at
QList<QInputMethodEvent::Attribute> QIBusAttributeList::imAttributes() const
{
QHash<QPair<int, int>, QTextCharFormat> rangeAttrs;
+ const int numAttributes = attributes.size();
// Merge text fomats for identical ranges into a single QTextFormat.
- for (int i = 0; i < attributes.size(); ++i) {
+ for (int i = 0; i < numAttributes; ++i) {
const QIBusAttribute &attr = attributes.at(i);
const QTextCharFormat &format = attr.format();
@@ -239,8 +240,9 @@ QList<QInputMethodEvent::Attribute> QIBusAttributeList::imAttributes() const
// Assemble list in original attribute order.
QList<QInputMethodEvent::Attribute> imAttrs;
+ imAttrs.reserve(numAttributes);
- for (int i = 0; i < attributes.size(); ++i) {
+ for (int i = 0; i < numAttributes; ++i) {
const QIBusAttribute &attr = attributes.at(i);
const QTextFormat &format = attr.format();
diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp
index 8ee3ff88d1..be5e969d2b 100644
--- a/src/plugins/platforms/android/androidjniinput.cpp
+++ b/src/plugins/platforms/android/androidjniinput.cpp
@@ -238,6 +238,52 @@ namespace QtAndroidInput
QWindowSystemInterface::handleTouchEvent(window, touchDevice, m_touchPoints);
}
+ static void tabletEvent(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint deviceId, jlong time, jint action,
+ jint pointerType, jint buttonState, jfloat x, jfloat y, jfloat pressure)
+ {
+ QPointF globalPosF(x, y);
+ QPoint globalPos((int)x, (int)y);
+ QWindow *tlw = topLevelWindowAt(globalPos);
+ QPointF localPos = tlw ? (globalPosF - tlw->position()) : globalPosF;
+
+ // Galaxy Note with plain Android:
+ // 0 1 0 stylus press
+ // 2 1 0 stylus drag
+ // 1 1 0 stylus release
+ // 0 1 2 stylus press with side-button held
+ // 2 1 2 stylus drag with side-button held
+ // 1 1 2 stylus release with side-button held
+ // Galaxy Note 4 with Samsung firmware:
+ // 0 1 0 stylus press
+ // 2 1 0 stylus drag
+ // 1 1 0 stylus release
+ // 211 1 2 stylus press with side-button held
+ // 213 1 2 stylus drag with side-button held
+ // 212 1 2 stylus release with side-button held
+ // when action == ACTION_UP (1) it's a release; otherwise we say which button is pressed
+ Qt::MouseButtons buttons = Qt::NoButton;
+ switch (action) {
+ case 1: // ACTION_UP
+ case 212: // stylus release while side-button held on Galaxy Note 4
+ buttons = Qt::NoButton;
+ break;
+ default: // action is press or drag
+ if (buttonState == 0)
+ buttons = Qt::LeftButton;
+ else // 2 means RightButton
+ buttons = Qt::MouseButtons(buttonState);
+ break;
+ }
+
+#ifdef QT_DEBUG_ANDROID_STYLUS
+ qDebug() << action << pointerType << buttonState << "@" << x << y << "pressure" << pressure << ": buttons" << buttons;
+#endif
+
+ QWindowSystemInterface::handleTabletEvent(tlw, ulong(time),
+ localPos, globalPosF, QTabletEvent::Stylus, pointerType,
+ buttons, pressure, 0, 0, 0., 0., 0, deviceId, Qt::NoModifier);
+ }
+
static int mapAndroidKey(int key)
{
// 0--9 0x00000007 -- 0x00000010
@@ -702,6 +748,7 @@ namespace QtAndroidInput
{"mouseUp", "(III)V", (void *)mouseUp},
{"mouseMove", "(III)V", (void *)mouseMove},
{"longPress", "(III)V", (void *)longPress},
+ {"tabletEvent", "(IIJIIIFFF)V", (void *)tabletEvent},
{"keyDown", "(IIIZ)V", (void *)keyDown},
{"keyUp", "(IIIZ)V", (void *)keyUp},
{"keyboardVisibilityChanged", "(Z)V", (void *)keyboardVisibilityChanged}
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index cf81f92e47..19ab051162 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -595,6 +595,11 @@ static void updateApplicationState(JNIEnv */*env*/, jobject /*thiz*/, jint state
return;
}
+ if (state == Qt::ApplicationActive)
+ QtAndroidPrivate::handleResume();
+ else if (state == Qt::ApplicationInactive)
+ QtAndroidPrivate::handlePause();
+
if (state <= Qt::ApplicationInactive) {
// NOTE: sometimes we will receive two consecutive suspended notifications,
// In the second suspended notification, QWindowSystemInterface::flushWindowSystemEvents()
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro
index ad6cb3a1fc..ba0e6b001a 100644
--- a/src/plugins/platforms/cocoa/cocoa.pro
+++ b/src/plugins/platforms/cocoa/cocoa.pro
@@ -12,7 +12,6 @@ OBJECTIVE_SOURCES += main.mm \
qcocoawindow.mm \
qnsview.mm \
qnsviewaccessibility.mm \
- qcocoaautoreleasepool.mm \
qnswindowdelegate.mm \
qcocoanativeinterface.mm \
qcocoaeventdispatcher.mm \
@@ -48,7 +47,6 @@ HEADERS += qcocoaintegration.h \
qcocoabackingstore.h \
qcocoawindow.h \
qnsview.h \
- qcocoaautoreleasepool.h \
qnswindowdelegate.h \
qcocoanativeinterface.h \
qcocoaeventdispatcher.h \
diff --git a/src/plugins/platforms/cocoa/main.mm b/src/plugins/platforms/cocoa/main.mm
index b7e8fa1fca..e6c1ed79b2 100644
--- a/src/plugins/platforms/cocoa/main.mm
+++ b/src/plugins/platforms/cocoa/main.mm
@@ -52,7 +52,7 @@ QPlatformIntegration * QCocoaIntegrationPlugin::create(const QString& system, co
{
Q_UNUSED(paramList);
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (system.compare(QLatin1String("cocoa"), Qt::CaseInsensitive) == 0)
return new QCocoaIntegration;
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
index 04e51d5392..abaaba91a5 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
@@ -100,6 +100,7 @@
- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate;
- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
- (void) removeAppleEventHandlers;
+- (bool) inLaunch;
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaApplicationDelegate);
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
index 6c673a4f5d..cac50825af 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
@@ -284,6 +284,11 @@ QT_END_NAMESPACE
[eventManager removeEventHandlerForEventClass:kInternetEventClass andEventID:kAEGetURL];
}
+- (bool) inLaunch
+{
+ return inLaunch;
+}
+
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
Q_UNUSED(aNotification);
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm
index 922809f90d..2098f0dc8c 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.mm
+++ b/src/plugins/platforms/cocoa/qcocoacursor.mm
@@ -34,7 +34,6 @@
#include "qcocoacursor.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
#include <QtGui/QBitmap>
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
index 13a8c89dbb..4a2cb42f87 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
@@ -80,7 +80,6 @@
//
#include <QtCore/qabstracteventdispatcher.h>
-#include <QtCore/qhash.h>
#include <QtCore/qstack.h>
#include <QtGui/qwindowdefs.h>
#include <QtCore/private/qabstracteventdispatcher_p.h>
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index 52b2e23345..1865624d57 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -66,13 +66,11 @@
****************************************************************************/
#include "qcocoaeventdispatcher.h"
-#include "qcocoaautoreleasepool.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"
#include "qguiapplication.h"
#include "qevent.h"
-#include "qhash.h"
#include "qmutex.h"
#include "qsocketnotifier.h"
#include <qpa/qplatformwindow.h>
@@ -365,7 +363,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
if (d->interrupt)
break;
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
NSEvent* event = 0;
// First, send all previously excluded input events, if any:
@@ -623,7 +621,7 @@ NSModalSession QCocoaEventDispatcherPrivate::currentModalSession()
continue;
if (!info.session) {
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(info.window->handle());
NSWindow *nswindow = cocoaWindow->nativeWindow();
if (!nswindow)
@@ -671,7 +669,7 @@ void QCocoaEventDispatcherPrivate::updateChildrenWorksWhenModal()
// Make the dialog children of the window
// active. And make the dialog children of
// the previous modal dialog unactive again:
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
int size = cocoaModalSessionStack.size();
if (size > 0){
if (QWindow *prevModal = cocoaModalSessionStack[size-1].window)
@@ -692,7 +690,7 @@ void QCocoaEventDispatcherPrivate::cleanupModalSessions()
// point they were marked as stopped), is that ending a session
// when no other session runs below it on the stack will make cocoa
// drop some events on the floor.
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
int stackSize = cocoaModalSessionStack.size();
for (int i=stackSize-1; i>=0; --i) {
@@ -927,7 +925,7 @@ void QCocoaEventDispatcherPrivate::cancelWaitForMoreEvents()
{
// In case the event dispatcher is waiting for more
// events somewhere, we post a dummy event to wake it up:
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
[NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint
modifierFlags:0 timestamp:0. windowNumber:0 context:0
subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO];
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index 4ece1b5a22..93ee4e8624 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -53,7 +53,6 @@
#include <qvarlengtharray.h>
#include <stdlib.h>
#include <qabstracteventdispatcher.h>
-#include "qcocoaautoreleasepool.h"
#include <QDir>
#include <qpa/qplatformnativeinterface.h>
@@ -557,7 +556,7 @@ QCocoaFileDialogHelper::~QCocoaFileDialogHelper()
{
if (!mDelegate)
return;
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
[mDelegate release];
mDelegate = 0;
}
@@ -687,7 +686,7 @@ bool QCocoaFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit
void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate()
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
const SharedPointerFileDialogOptions &opts = options();
const QList<QUrl> selectedFiles = opts->initiallySelectedFiles();
@@ -737,7 +736,7 @@ void QCocoaFileDialogHelper::exec()
// QEventLoop has been interrupted, and the second-most event loop has not
// yet been reactivated (regardless if [NSApp run] is still on the stack)),
// showing a native modal dialog will fail.
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if ([mDelegate runApplicationModalPanel])
emit accept();
else
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index a3c72c58b9..1d8a1c5e70 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -33,7 +33,6 @@
#include "qcocoaglcontext.h"
#include "qcocoawindow.h"
-#include "qcocoaautoreleasepool.h"
#include "qcocoahelpers.h"
#include <qdebug.h>
#include <QtCore/private/qcore_mac_p.h>
@@ -145,7 +144,7 @@ QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLCo
if (m_format.renderableType() != QSurfaceFormat::OpenGL)
return;
- QCocoaAutoReleasePool pool; // For the SG Canvas render thread
+ QMacAutoReleasePool pool; // For the SG Canvas render thread
NSOpenGLPixelFormat *pixelFormat = static_cast <NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat(m_format));
m_shareContext = share ? static_cast<QCocoaGLContext *>(share)->nsOpenGLContext() : nil;
@@ -218,7 +217,7 @@ bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
{
Q_ASSERT(surface->surface()->supportsOpenGL());
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QWindow *window = static_cast<QCocoaWindow *>(surface)->window();
setActiveWindow(window);
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index 5f97e2996c..3ecfd1b429 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -33,7 +33,6 @@
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
#include <QtCore>
#include <QtGui>
@@ -630,7 +629,7 @@ QString qt_mac_applicationName()
int qt_mac_mainScreenHeight()
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
// The first screen in the screens array is documented
// to have the (0,0) origin.
NSRect screenFrame = [[[NSScreen screens] firstObject] frame];
diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.mm b/src/plugins/platforms/cocoa/qcocoainputcontext.mm
index c22fe8774b..f072991bdd 100644
--- a/src/plugins/platforms/cocoa/qcocoainputcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoainputcontext.mm
@@ -34,7 +34,6 @@
#include "qnsview.h"
#include "qcocoainputcontext.h"
#include "qcocoanativeinterface.h"
-#include "qcocoaautoreleasepool.h"
#include "qcocoawindow.h"
#include <QtCore/QRect>
@@ -98,7 +97,7 @@ void QCocoaInputContext::reset()
if (!view)
return;
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (NSTextInputContext *ctxt = [NSTextInputContext currentInputContext]) {
[ctxt discardMarkedText];
[view unmarkText];
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index 8b5d78826c..d7dc8e67de 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -36,7 +36,6 @@
#include <Cocoa/Cocoa.h>
-#include "qcocoaautoreleasepool.h"
#include "qcocoacursor.h"
#include "qcocoawindow.h"
#include "qcocoanativeinterface.h"
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index c8f6dd05db..04d5769044 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -33,7 +33,6 @@
#include "qcocoaintegration.h"
-#include "qcocoaautoreleasepool.h"
#include "qcocoawindow.h"
#include "qcocoabackingstore.h"
#include "qcocoanativeinterface.h"
@@ -137,7 +136,7 @@ void QCocoaScreen::updateGeometry()
qreal QCocoaScreen::devicePixelRatio() const
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
NSScreen * screen = osScreen();
return qreal(screen ? [screen backingScaleFactor] : 1.0);
}
@@ -263,7 +262,7 @@ QCocoaIntegration::QCocoaIntegration()
mInstance = this;
initResources();
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
qApp->setAttribute(Qt::AA_DontUseNativeMenuBar, false);
@@ -314,7 +313,7 @@ QCocoaIntegration::~QCocoaIntegration()
qt_resetNSApplicationSendEvent();
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) {
// remove the apple event handlers installed by QCocoaApplicationDelegate
QCocoaApplicationDelegate *delegate = [QCocoaApplicationDelegate sharedDelegate];
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index 6668080725..57739f3a58 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -34,7 +34,6 @@
#include "qcocoamenu.h"
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
#include <QtCore/QtDebug>
#include <QtCore/qmetaobject.h>
@@ -235,7 +234,7 @@ QCocoaMenu::QCocoaMenu() :
m_menuBar(0),
m_containingMenuItem(0)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
m_delegate = [[QCocoaMenuDelegate alloc] initWithMenu:this];
m_nativeItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
@@ -255,7 +254,7 @@ QCocoaMenu::~QCocoaMenu()
if (m_containingMenuItem)
m_containingMenuItem->clearMenu(this);
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
[m_nativeItem setSubmenu:nil];
[m_nativeMenu release];
[m_delegate release];
@@ -264,7 +263,7 @@ QCocoaMenu::~QCocoaMenu()
void QCocoaMenu::setText(const QString &text)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QString stripped = qt_mac_removeAmpersandEscapes(text);
[m_nativeMenu setTitle:QCFString::toNSString(stripped)];
[m_nativeItem setTitle:QCFString::toNSString(stripped)];
@@ -286,7 +285,7 @@ void QCocoaMenu::setFont(const QFont &font)
void QCocoaMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaMenuItem *cocoaItem = static_cast<QCocoaMenuItem *>(menuItem);
QCocoaMenuItem *beforeItem = static_cast<QCocoaMenuItem *>(before);
@@ -340,7 +339,7 @@ void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem)
void QCocoaMenu::removeMenuItem(QPlatformMenuItem *menuItem)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaMenuItem *cocoaItem = static_cast<QCocoaMenuItem *>(menuItem);
if (!m_menuItems.contains(cocoaItem)) {
qWarning() << Q_FUNC_INFO << "Menu does not contain the item to be removed";
@@ -370,7 +369,7 @@ QCocoaMenuItem *QCocoaMenu::itemOrNull(int index) const
void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaMenuItem *cocoaItem = static_cast<QCocoaMenuItem *>(menuItem);
if (!m_menuItems.contains(cocoaItem)) {
qWarning() << Q_FUNC_INFO << "Item does not belong to this menu";
@@ -399,7 +398,7 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem)
void QCocoaMenu::syncSeparatorsCollapsible(bool enable)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (enable) {
bool previousIsSeparator = true; // setting to true kills all the separators placed at the top.
NSMenuItem *previousItem = nil;
@@ -457,7 +456,7 @@ void QCocoaMenu::setVisible(bool visible)
void QCocoaMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QPoint pos = QPoint(targetRect.left(), targetRect.top() + targetRect.height());
QCocoaWindow *cocoaWindow = parentWindow ? static_cast<QCocoaWindow *>(parentWindow->handle()) : 0;
@@ -562,7 +561,7 @@ QList<QCocoaMenuItem *> QCocoaMenu::merged() const
void QCocoaMenu::syncModalState(bool modal)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (!m_enabled)
modal = true;
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
index 764a01370d..7775cdbde6 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
@@ -37,7 +37,7 @@
#include "qcocoawindow.h"
#include "qcocoamenuloader.h"
#include "qcocoaapplication.h" // for custom application category
-#include "qcocoaautoreleasepool.h"
+#include "qcocoaapplicationdelegate.h"
#include <QtGui/QGuiApplication>
#include <QtCore/QDebug>
@@ -83,7 +83,7 @@ QCocoaMenuBar::~QCocoaMenuBar()
void QCocoaMenuBar::insertNativeMenu(QCocoaMenu *menu, QCocoaMenu *beforeMenu)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (beforeMenu) {
NSUInteger nativeIndex = [m_nativeMenu indexOfItem:beforeMenu->nsMenuItem()];
@@ -126,7 +126,7 @@ void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *befor
void QCocoaMenuBar::removeNativeMenu(QCocoaMenu *menu)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (menu->menuBar() == this)
menu->setMenuBar(0);
@@ -147,7 +147,7 @@ void QCocoaMenuBar::removeMenu(QPlatformMenu *platformMenu)
void QCocoaMenuBar::syncMenu(QPlatformMenu *menu)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaMenu *cocoaMenu = static_cast<QCocoaMenu *>(menu);
Q_FOREACH (QCocoaMenuItem *item, cocoaMenu->items())
@@ -260,13 +260,26 @@ void QCocoaMenuBar::resetKnownMenuItemsToQt()
void QCocoaMenuBar::updateMenuBarImmediately()
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaMenuBar *mb = findGlobalMenubar();
QCocoaWindow *cw = findWindowForMenubar();
QWindow *win = cw ? cw->window() : 0;
- if (win && (win->flags() & Qt::Popup) == Qt::Popup)
- return; // context menus, comboboxes, etc. don't need to update the menubar
+ if (win && (win->flags() & Qt::Popup) == Qt::Popup) {
+ // context menus, comboboxes, etc. don't need to update the menubar,
+ // but if an application has only Qt::Tool window(s) on start,
+ // we still have to update the menubar.
+ if ((win->flags() & Qt::WindowType_Mask) != Qt::Tool)
+ return;
+ typedef QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) AppDelegate;
+ NSApplication *app = [NSApplication sharedApplication];
+ if (![app.delegate isKindOfClass:[AppDelegate class]])
+ return;
+ // We apply this logic _only_ during the startup.
+ AppDelegate *appDelegate = app.delegate;
+ if (!appDelegate.inLaunch)
+ return;
+ }
if (cw && cw->menubar())
mb = cw->menubar();
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
index f288ab85c0..942fc8db21 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
@@ -37,7 +37,6 @@
#include "qcocoamenubar.h"
#include "messages.h"
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
#include "qt_mac_p.h"
#include "qcocoaapplication.h" // for custom application category
#include "qcocoamenuloader.h"
@@ -104,7 +103,7 @@ QCocoaMenuItem::QCocoaMenuItem() :
QCocoaMenuItem::~QCocoaMenuItem()
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (m_menu && COCOA_MENU_ANCESTOR(m_menu) == this)
SET_COCOA_MENU_ANCESTOR(m_menu, 0);
@@ -139,7 +138,7 @@ void QCocoaMenuItem::setMenu(QPlatformMenu *menu)
m_menu->setContainingMenuItem(0);
}
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
m_menu = static_cast<QCocoaMenu *>(menu);
if (m_menu) {
SET_COCOA_MENU_ANCESTOR(m_menu, this);
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
index 2250f7c084..d018c05635 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
@@ -67,6 +67,8 @@ public:
static void *nsOpenGLContextForContext(QOpenGLContext* context);
#endif
+ QFunctionPointer platformFunction(const QByteArray &function) const Q_DECL_OVERRIDE;
+
public Q_SLOTS:
void onAppFocusWindowChanged(QWindow *window);
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index 205a49d25a..41ea1fa49c 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -58,6 +58,8 @@
#include <qpa/qplatformprintersupport.h>
#endif
+#include <QtPlatformHeaders/qcocoawindowfunctions.h>
+
#include <Cocoa/Cocoa.h>
QT_BEGIN_NAMESPACE
@@ -217,6 +219,14 @@ void *QCocoaNativeInterface::nsOpenGLContextForContext(QOpenGLContext* context)
}
#endif
+QFunctionPointer QCocoaNativeInterface::platformFunction(const QByteArray &function) const
+{
+ if (function == QCocoaWindowFunctions::bottomLeftClippedByNSWindowOffsetIdentifier())
+ return QFunctionPointer(QCocoaWindowFunctions::BottomLeftClippedByNSWindowOffset(QCocoaWindow::bottomLeftClippedByNSWindowOffsetStatic));
+
+ return Q_NULLPTR;
+}
+
void QCocoaNativeInterface::addToMimeList(void *macPasteboardMime)
{
qt_mac_addToGlobalMimeList(reinterpret_cast<QMacInternalPasteboardMime *>(macPasteboardMime));
@@ -234,7 +244,7 @@ void QCocoaNativeInterface::registerDraggedTypes(const QStringList &types)
void QCocoaNativeInterface::setDockMenu(QPlatformMenu *platformMenu)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaMenu *cocoaPlatformMenu = static_cast<QCocoaMenu *>(platformMenu);
NSMenu *menu = cocoaPlatformMenu->nsMenu();
[NSApp QT_MANGLE_NAMESPACE(qt_setDockMenu): menu];
diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
index 65cc9bc38b..93f8b2ba6f 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
@@ -33,7 +33,6 @@
#include "qcocoasystemsettings.h"
-#include "qcocoaautoreleasepool.h"
#include "qcocoahelpers.h"
#include <QtCore/private/qcore_mac_p.h>
@@ -45,7 +44,7 @@ QT_BEGIN_NAMESPACE
QColor qt_mac_colorForTheme(ThemeBrush brush)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCFType<CGColorRef> cgClr = 0;
HIThemeBrushCreateCGColor(brush, &cgClr);
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
index b5f038094f..b5f038094f 100755..100644
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
index 713758cc7e..713758cc7e 100755..100644
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index 11749e14de..4b73d0af08 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -47,7 +47,6 @@
#include "qcocoamenu.h"
#include "qcocoamenubar.h"
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
#include <QtCore/qfileinfo.h>
#include <QtGui/private/qguiapplication_p.h>
@@ -253,7 +252,7 @@ QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &siz
QPlatformTheme::IconOptions iconOptions) const
{
Q_UNUSED(iconOptions);
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:QCFString::toNSString(fileInfo.canonicalFilePath())];
if (!iconImage)
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 455d4a8580..9f74828f2d 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -227,6 +227,9 @@ public:
void updateExposedGeometry();
QWindow *childWindowAt(QPoint windowPoint);
bool shouldRefuseKeyWindowAndFirstResponder();
+
+ static QPoint bottomLeftClippedByNSWindowOffsetStatic(QWindow *window);
+ QPoint bottomLeftClippedByNSWindowOffset() const;
protected:
void recreateWindow(const QPlatformWindow *parentWindow);
QCocoaNSWindow *createNSWindow();
@@ -245,6 +248,8 @@ public: // for QNSView
friend class QCocoaBackingStore;
friend class QCocoaNativeInterface;
+ void removeMonitor();
+
NSView *m_contentView;
QNSView *m_qtView;
QCocoaNSWindow *m_nsWindow;
@@ -269,6 +274,7 @@ public: // for QNSView
bool m_inConstructor;
bool m_inSetVisible;
bool m_inSetGeometry;
+ bool m_inSetStyleMask;
#ifndef QT_NO_OPENGL
QCocoaGLContext *m_glContext;
#endif
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 3188463dbe..e1d09c0400 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -33,7 +33,6 @@
#include "qcocoawindow.h"
#include "qcocoaintegration.h"
#include "qnswindowdelegate.h"
-#include "qcocoaautoreleasepool.h"
#include "qcocoaeventdispatcher.h"
#ifndef QT_NO_OPENGL
#include "qcocoaglcontext.h"
@@ -350,6 +349,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
, m_inConstructor(true)
, m_inSetVisible(false)
, m_inSetGeometry(false)
+ , m_inSetStyleMask(false)
#ifndef QT_NO_OPENGL
, m_glContext(0)
#endif
@@ -373,7 +373,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
qDebug() << "QCocoaWindow::QCocoaWindow" << this;
#endif
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (tlw->type() == Qt::ForeignWindow) {
NSView *foreignView = (NSView *)WId(tlw->property("_q_foreignWinId").value<WId>());
@@ -409,7 +409,7 @@ QCocoaWindow::~QCocoaWindow()
qDebug() << "QCocoaWindow::~QCocoaWindow" << this;
#endif
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
[m_nsWindow setContentView:nil];
[m_nsWindow.helper detachFromPlatformWindow];
if (m_isNSWindowChild) {
@@ -419,6 +419,8 @@ QCocoaWindow::~QCocoaWindow()
[m_contentView removeFromSuperview];
}
+ removeMonitor();
+
// Make sure to disconnect observer in all case if view is valid
// to avoid notifications received when deleting when using Qt::AA_NativeWindows attribute
if (m_qtView) {
@@ -499,7 +501,7 @@ QRect QCocoaWindow::geometry() const
void QCocoaWindow::setCocoaGeometry(const QRect &rect)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (m_contentViewIsEmbedded) {
QPlatformWindow::setGeometry(rect);
@@ -623,7 +625,7 @@ void QCocoaWindow::setVisible(bool visible)
m_inSetVisible = true;
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaWindow *parentCocoaWindow = 0;
if (window()->transientParent())
parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle());
@@ -696,6 +698,7 @@ void QCocoaWindow::setVisible(bool visible)
&& [m_nsWindow isKindOfClass:[NSPanel class]]) {
[(NSPanel *)m_nsWindow setWorksWhenModal:YES];
if (!(parentCocoaWindow && window()->transientParent()->isActive()) && window()->type() == Qt::Popup) {
+ removeMonitor();
monitor = [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask|NSRightMouseDownMask|NSOtherMouseDownMask|NSMouseMovedMask handler:^(NSEvent *e) {
QPointF localPoint = qt_mac_flipPoint([NSEvent mouseLocation]);
QWindowSystemInterface::handleMouseEvent(window(), window()->mapFromGlobal(localPoint.toPoint()), localPoint,
@@ -744,10 +747,7 @@ void QCocoaWindow::setVisible(bool visible)
} else {
[m_contentView setHidden:YES];
}
- if (monitor && window()->type() == Qt::Popup) {
- [NSEvent removeMonitor:monitor];
- monitor = nil;
- }
+ removeMonitor();
if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
QCocoaIntegration::instance()->popupWindowStack()->removeAll(this);
@@ -875,10 +875,14 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
if (m_nsWindow && !m_isNSWindowChild) {
NSUInteger styleMask = windowStyleMask(flags);
NSInteger level = this->windowLevel(flags);
+ // While setting style mask we can have -updateGeometry calls on a content
+ // view with null geometry, reporting an invalid coordinates as a result.
+ m_inSetStyleMask = true;
[m_nsWindow setStyleMask:styleMask];
+ m_inSetStyleMask = false;
[m_nsWindow setLevel:level];
setWindowShadow(flags);
- if (!(styleMask & NSBorderlessWindowMask)) {
+ if (!(flags & Qt::FramelessWindowHint)) {
setWindowTitle(window()->title());
}
@@ -905,7 +909,7 @@ void QCocoaWindow::setWindowState(Qt::WindowState state)
void QCocoaWindow::setWindowTitle(const QString &title)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (!m_nsWindow)
return;
@@ -916,7 +920,7 @@ void QCocoaWindow::setWindowTitle(const QString &title)
void QCocoaWindow::setWindowFilePath(const QString &filePath)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (!m_nsWindow)
return;
@@ -926,7 +930,7 @@ void QCocoaWindow::setWindowFilePath(const QString &filePath)
void QCocoaWindow::setWindowIcon(const QIcon &icon)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
NSButton *iconButton = [m_nsWindow standardWindowButton:NSWindowDocumentIconButton];
if (iconButton == nil) {
@@ -1044,7 +1048,7 @@ bool QCocoaWindow::isOpaque() const
void QCocoaWindow::propagateSizeHints()
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (!m_nsWindow)
return;
@@ -1387,7 +1391,7 @@ bool QCocoaWindow::shouldUseNSPanel()
QCocoaNSWindow * QCocoaWindow::createNSWindow()
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QRect rect = initialGeometry(window(), window()->geometry(), defaultWindowWidth, defaultWindowHeight);
NSRect frame = qt_mac_flipRect(rect);
@@ -1476,6 +1480,14 @@ void QCocoaWindow::removeChildWindow(QCocoaWindow *child)
[m_nsWindow removeChildWindow:child->m_nsWindow];
}
+void QCocoaWindow::removeMonitor()
+{
+ if (!monitor)
+ return;
+ [NSEvent removeMonitor:monitor];
+ monitor = nil;
+}
+
// Returns the current global screen geometry for the nswindow associated with this window.
QRect QCocoaWindow::windowGeometry() const
{
@@ -1827,6 +1839,25 @@ bool QCocoaWindow::shouldRefuseKeyWindowAndFirstResponder()
return false;
}
+QPoint QCocoaWindow::bottomLeftClippedByNSWindowOffsetStatic(QWindow *window)
+{
+ if (window->handle())
+ return static_cast<QCocoaWindow *>(window->handle())->bottomLeftClippedByNSWindowOffset();
+ return QPoint();
+}
+
+QPoint QCocoaWindow::bottomLeftClippedByNSWindowOffset() const
+{
+ if (!m_contentView)
+ return QPoint();
+ NSPoint origin = [m_contentView isFlipped] ?
+ NSMakePoint(0, [m_contentView frame].size.height) :
+ NSMakePoint(0, 0);
+ NSPoint windowPoint = [m_contentView convertPoint:origin toView:nil];
+
+ return QPoint(-std::min((int)windowPoint.x, 0), -std::min((int)windowPoint.y,0));
+}
+
QMargins QCocoaWindow::frameMargins() const
{
NSRect frameW = [m_nsWindow frame];
diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm
index 3d88a8d5df..f4fd32ffd1 100644
--- a/src/plugins/platforms/cocoa/qmacclipboard.mm
+++ b/src/plugins/platforms/cocoa/qmacclipboard.mm
@@ -43,7 +43,6 @@
#include <stdlib.h>
#include <string.h>
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
QT_BEGIN_NAMESPACE
@@ -555,7 +554,7 @@ QMacPasteboard::sync() const
QString qt_mac_get_pasteboardString(PasteboardRef paste)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
NSPasteboard *pb = nil;
CFStringRef pbname;
if (PasteboardCopyName(paste, &pbname) == noErr) {
diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac.mm b/src/plugins/platforms/cocoa/qmultitouch_mac.mm
index 6e7ebcc37c..13f1cf4612 100644
--- a/src/plugins/platforms/cocoa/qmultitouch_mac.mm
+++ b/src/plugins/platforms/cocoa/qmultitouch_mac.mm
@@ -190,7 +190,7 @@ QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch)
// touch now (and refake a begin for it later, if needed).
if (_updateInternalStateOnly && !wasUpdateInternalStateOnly && !_currentTouches.isEmpty()) {
- QCocoaTouch *qcocoaTouch = _currentTouches.values().first();
+ QCocoaTouch *qcocoaTouch = _currentTouches.cbegin().value();
qcocoaTouch->_touchPoint.state = Qt::TouchPointReleased;
touchPoints.insert(qcocoaTouch->_touchPoint.id, qcocoaTouch->_touchPoint);
// Since this last touch also will end up being the first
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 355704ff37..3caed80e38 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -39,7 +39,6 @@
#include "qnsview.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
#include "qmultitouch_mac_p.h"
#include "qcocoadrag.h"
#include <qpa/qplatformintegration.h>
@@ -347,6 +346,12 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
if (m_platformWindow->m_nsWindow && geometry == m_platformWindow->geometry())
return;
+ // It can happen that self.window is nil (if we are changing
+ // styleMask from/to borderless and content view is being re-parented)
+ // - this results in an invalid coordinates.
+ if (m_platformWindow->m_inSetStyleMask && !self.window)
+ return;
+
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
qDebug() << "QNSView::udpateGeometry" << m_platformWindow << geometry;
#endif
@@ -843,7 +848,7 @@ QT_WARNING_POP
{
[super updateTrackingAreas];
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
// NSTrackingInVisibleRect keeps care of updating once the tracking is set up, so bail out early
if (m_trackingArea && [[self trackingAreas] containsObject:m_trackingArea])
@@ -1780,7 +1785,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
-(void)registerDragTypes
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QStringList customTypes = qt_mac_enabledDraggedTypes();
if (currentCustomDragTypes == 0 || *currentCustomDragTypes != customTypes) {
if (currentCustomDragTypes == 0)
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm
index 9e8fe8f1c8..cb3e6e2cc5 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm
@@ -38,7 +38,6 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdebug.h>
-#include "qcocoaautoreleasepool.h"
#ifndef QT_NO_PRINTER
@@ -230,7 +229,7 @@ void QMacPrintEnginePrivate::initialize()
q->gccaps = paintEngine->gccaps;
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
printInfo = [[NSPrintInfo alloc] initWithDictionary:[NSDictionary dictionary]];
QList<int> resolutions = m_printDevice->supportedResolutions();
diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h
index e210f0221f..576e0f9729 100644
--- a/src/plugins/platforms/cocoa/qt_mac_p.h
+++ b/src/plugins/platforms/cocoa/qt_mac_p.h
@@ -103,17 +103,6 @@ public:
}
};
-class Q_WIDGETS_EXPORT QMacCocoaAutoReleasePool
-{
-private:
- void *pool;
-public:
- QMacCocoaAutoReleasePool();
- ~QMacCocoaAutoReleasePool();
-
- inline void *handle() const { return pool; }
-};
-
QString qt_mac_removeMnemonics(const QString &original); //implemented in qmacstyle_mac.cpp
class Q_WIDGETS_EXPORT QMacWindowChangeEvent
diff --git a/src/plugins/platforms/directfb/qdirectfbconvenience.cpp b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp
index e635d4fd22..e1d97d9628 100644
--- a/src/plugins/platforms/directfb/qdirectfbconvenience.cpp
+++ b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp
@@ -217,7 +217,7 @@ Qt::KeyboardModifiers QDirectFbConvenience::keyboardModifiers(DFBInputDeviceModi
modifiers |= Qt::ControlModifier;
}
if (mask & DIMM_META) {
- modifiers | Qt::MetaModifier;
+ modifiers |= Qt::MetaModifier;
}
return modifiers;
}
diff --git a/src/plugins/platforms/eglfs/cursor-atlas.png b/src/plugins/platforms/eglfs/cursor-atlas.png
index 40c5b6ef4f..40c5b6ef4f 100755..100644
--- a/src/plugins/platforms/eglfs/cursor-atlas.png
+++ b/src/plugins/platforms/eglfs/cursor-atlas.png
Binary files differ
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp
index 18a66e34f5..0fa191ea60 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp
@@ -208,6 +208,7 @@ QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, dr
}
QList<drmModeModeInfo> modes;
+ modes.reserve(connector->count_modes);
qCDebug(qLcEglfsKmsDebug) << connectorName << "mode count:" << connector->count_modes;
for (int i = 0; i < connector->count_modes; i++) {
const drmModeModeInfo &mode = connector->modes[i];
diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp
index 359b90f205..7771c981dd 100644
--- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp
@@ -99,6 +99,7 @@ QStringList QEGLDeviceIntegrationFactory::keys(const QString &pluginPath)
qCDebug(qLcEglDevDebug) << "EGL device integration plugin keys:" << list;
return list;
#else
+ Q_UNUSED(pluginPath);
return QStringList();
#endif
}
@@ -117,6 +118,9 @@ QEGLDeviceIntegration *QEGLDeviceIntegrationFactory::create(const QString &key,
qCDebug(qLcEglDevDebug) << "Using EGL device integration" << key;
else
qCWarning(qLcEglDevDebug) << "Failed to load EGL device integration" << key;
+#else
+ Q_UNUSED(key);
+ Q_UNUSED(pluginPath);
#endif
return integration;
}
diff --git a/src/plugins/platforms/haiku/qhaikuclipboard.cpp b/src/plugins/platforms/haiku/qhaikuclipboard.cpp
index f3aa9dc36e..a2d7e96d71 100644
--- a/src/plugins/platforms/haiku/qhaikuclipboard.cpp
+++ b/src/plugins/platforms/haiku/qhaikuclipboard.cpp
@@ -41,6 +41,8 @@
#include <Clipboard.h>
QHaikuClipboard::QHaikuClipboard()
+ : m_systemMimeData(Q_NULLPTR)
+ , m_userMimeData(Q_NULLPTR)
{
if (be_clipboard)
be_clipboard->StartWatching(BMessenger(this));
@@ -50,17 +52,26 @@ QHaikuClipboard::~QHaikuClipboard()
{
if (be_clipboard)
be_clipboard->StopWatching(BMessenger(this));
+
+ delete m_userMimeData;
+ delete m_systemMimeData;
}
QMimeData *QHaikuClipboard::mimeData(QClipboard::Mode mode)
{
- QMimeData *mimeData = new QMimeData();
-
if (mode != QClipboard::Clipboard)
- return mimeData;
+ return 0;
+
+ if (m_userMimeData)
+ return m_userMimeData;
if (!be_clipboard->Lock())
- return mimeData;
+ return 0;
+
+ if (!m_systemMimeData)
+ m_systemMimeData = new QMimeData();
+ else
+ m_systemMimeData->clear();
const BMessage *clipboard = be_clipboard->Data();
if (clipboard) {
@@ -76,11 +87,11 @@ QMimeData *QHaikuClipboard::mimeData(QClipboard::Mode mode)
if (dataLen && (status == B_OK)) {
const QString format = QString::fromLatin1(name);
if (format == QStringLiteral("text/plain")) {
- mimeData->setText(QString::fromLocal8Bit(reinterpret_cast<const char*>(data), dataLen));
+ m_systemMimeData->setText(QString::fromLocal8Bit(reinterpret_cast<const char*>(data), dataLen));
} else if (format == QStringLiteral("text/html")) {
- mimeData->setHtml(QString::fromLocal8Bit(reinterpret_cast<const char*>(data), dataLen));
+ m_systemMimeData->setHtml(QString::fromLocal8Bit(reinterpret_cast<const char*>(data), dataLen));
} else {
- mimeData->setData(format, QByteArray(reinterpret_cast<const char*>(data), dataLen));
+ m_systemMimeData->setData(format, QByteArray(reinterpret_cast<const char*>(data), dataLen));
}
}
}
@@ -88,7 +99,7 @@ QMimeData *QHaikuClipboard::mimeData(QClipboard::Mode mode)
be_clipboard->Unlock();
- return mimeData;
+ return m_systemMimeData;
}
void QHaikuClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode)
@@ -96,6 +107,14 @@ void QHaikuClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode)
if (mode != QClipboard::Clipboard)
return;
+ if (mimeData) {
+ if (m_systemMimeData == mimeData)
+ return;
+
+ if (m_userMimeData == mimeData)
+ return;
+ }
+
if (!be_clipboard->Lock())
return;
@@ -115,6 +134,10 @@ void QHaikuClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode)
qWarning("Unable to store mime data on clipboard");
be_clipboard->Unlock();
+
+ m_userMimeData = mimeData;
+
+ emitChanged(QClipboard::Clipboard);
}
bool QHaikuClipboard::supportsMode(QClipboard::Mode mode) const
@@ -131,8 +154,12 @@ bool QHaikuClipboard::ownsMode(QClipboard::Mode mode) const
void QHaikuClipboard::MessageReceived(BMessage* message)
{
- if (message->what == B_CLIPBOARD_CHANGED)
+ if (message->what == B_CLIPBOARD_CHANGED) {
+ delete m_userMimeData;
+ m_userMimeData = Q_NULLPTR;
+
emitChanged(QClipboard::Clipboard);
+ }
BHandler::MessageReceived(message);
}
diff --git a/src/plugins/platforms/haiku/qhaikuclipboard.h b/src/plugins/platforms/haiku/qhaikuclipboard.h
index 0dc2bfdd3b..3c1f92c615 100644
--- a/src/plugins/platforms/haiku/qhaikuclipboard.h
+++ b/src/plugins/platforms/haiku/qhaikuclipboard.h
@@ -55,6 +55,10 @@ public:
// override from BHandler to catch change notifications from Haiku clipboard
void MessageReceived(BMessage* message) Q_DECL_OVERRIDE;
+
+private:
+ QMimeData *m_systemMimeData;
+ QMimeData *m_userMimeData;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/haiku/qhaikuwindow.cpp b/src/plugins/platforms/haiku/qhaikuwindow.cpp
index 5768e1cb40..9622d12111 100644
--- a/src/plugins/platforms/haiku/qhaikuwindow.cpp
+++ b/src/plugins/platforms/haiku/qhaikuwindow.cpp
@@ -130,6 +130,7 @@ QHaikuWindow::QHaikuWindow(QWindow *window)
if (!m_window)
qFatal("QHaikuWindow: failed to create window");
+ setGeometry(rect);
setWindowFlags(window->flags());
}
@@ -164,13 +165,13 @@ void QHaikuWindow::setVisible(bool visible)
{
if (visible) {
m_window->Show();
+
+ window()->requestActivate();
+
+ QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), window()->geometry().size()));
} else {
m_window->Hide();
}
-
- window()->requestActivate();
-
- QWindowSystemInterface::handleExposeEvent(window(), window()->geometry());
}
bool QHaikuWindow::isExposed() const
@@ -306,10 +307,8 @@ void QHaikuWindow::haikuWindowMoved(const QPoint &pos)
const QRect newGeometry(pos, geometry().size());
QPlatformWindow::setGeometry(newGeometry);
- QWindowSystemInterface::setSynchronousWindowsSystemEvents(true);
QWindowSystemInterface::handleGeometryChange(window(), newGeometry);
- QWindowSystemInterface::handleExposeEvent(window(), newGeometry);
- QWindowSystemInterface::setSynchronousWindowsSystemEvents(false);
+ QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), newGeometry.size()));
}
void QHaikuWindow::haikuWindowResized(const QSize &size, bool zoomInProgress)
@@ -317,10 +316,8 @@ void QHaikuWindow::haikuWindowResized(const QSize &size, bool zoomInProgress)
const QRect newGeometry(geometry().topLeft(), size);
QPlatformWindow::setGeometry(newGeometry);
- QWindowSystemInterface::setSynchronousWindowsSystemEvents(true);
QWindowSystemInterface::handleGeometryChange(window(), newGeometry);
- QWindowSystemInterface::handleExposeEvent(window(), newGeometry);
- QWindowSystemInterface::setSynchronousWindowsSystemEvents(false);
+ QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), newGeometry.size()));
if ((m_windowState == Qt::WindowMaximized) && !zoomInProgress) {
// the user has resized the window while maximized -> reset maximized flag
diff --git a/src/plugins/platforms/ios/qiosapplicationstate.mm b/src/plugins/platforms/ios/qiosapplicationstate.mm
index 92799f80c1..7a37e213bd 100644
--- a/src/plugins/platforms/ios/qiosapplicationstate.mm
+++ b/src/plugins/platforms/ios/qiosapplicationstate.mm
@@ -43,7 +43,7 @@
@implementation QIOSApplicationStateListener
-- (id) init
+- (id)init
{
self = [super init];
if (self) {
@@ -75,7 +75,7 @@
return self;
}
-- (void) dealloc
+- (void)dealloc
{
[[NSNotificationCenter defaultCenter]
removeObserver:self
@@ -92,12 +92,12 @@
[super dealloc];
}
-- (void) applicationDidBecomeActive
+- (void)applicationDidBecomeActive
{
[self handleApplicationStateChanged:UIApplicationStateActive];
}
-- (void) applicationWillResignActive
+- (void)applicationWillResignActive
{
// Note that UIApplication is still UIApplicationStateActive at this
// point, but since there is no separate notification for the inactive
@@ -105,12 +105,12 @@
[self handleApplicationStateChanged:UIApplicationStateInactive];
}
-- (void) applicationDidEnterBackground
+- (void)applicationDidEnterBackground
{
[self handleApplicationStateChanged:UIApplicationStateBackground];
}
-- (void) handleApplicationStateChanged:(UIApplicationState) uiApplicationState
+- (void)handleApplicationStateChanged:(UIApplicationState)uiApplicationState
{
// We may receive application state changes after QCoreApplication has
// gone down, as the block we schedule on the main queue keeps the
diff --git a/src/plugins/platforms/ios/qiosclipboard.mm b/src/plugins/platforms/ios/qiosclipboard.mm
index 192ee67689..e0c6ec5d72 100644
--- a/src/plugins/platforms/ios/qiosclipboard.mm
+++ b/src/plugins/platforms/ios/qiosclipboard.mm
@@ -62,7 +62,7 @@
@implementation QUIClipboard
--(id)initWithQIOSClipboard:(QIOSClipboard *)qiosClipboard
+- (id)initWithQIOSClipboard:(QIOSClipboard *)qiosClipboard
{
self = [super init];
if (self) {
@@ -87,7 +87,7 @@
return self;
}
--(void)dealloc
+- (void)dealloc
{
[[NSNotificationCenter defaultCenter]
removeObserver:self
diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm
index fc12e83a81..bd4b8778ed 100644
--- a/src/plugins/platforms/ios/qioseventdispatcher.mm
+++ b/src/plugins/platforms/ios/qioseventdispatcher.mm
@@ -198,7 +198,7 @@ namespace
bool debugStackUsage = false;
}
-extern "C" int __attribute__((weak)) main(int argc, char *argv[])
+extern "C" int qt_main_wrapper(int argc, char *argv[])
{
@autoreleasepool {
size_t defaultStackSize = 512 * kBytesPerKiloByte; // Same as secondary threads
@@ -233,18 +233,7 @@ enum SetJumpResult
kJumpedFromUserMainTrampoline,
};
-// We define qtmn so that user_main_trampoline() will not cause
-// missing symbols in the case of hybrid applications that don't
-// use our main wrapper. Since the symbol is weak, it will not
-// get used or cause a clash in the normal Qt application usecase,
-// where we rename main to qtmn before linking.
-extern "C" int __attribute__((weak)) qtmn(int argc, char *argv[])
-{
- Q_UNUSED(argc);
- Q_UNUSED(argv);
-
- Q_UNREACHABLE();
-}
+extern "C" int main(int argc, char *argv[]);
static void __attribute__((noinline, noreturn)) user_main_trampoline()
{
@@ -263,7 +252,7 @@ static void __attribute__((noinline, noreturn)) user_main_trampoline()
qFatal("Could not convert argv[%d] to C string", i);
}
- int exitCode = qtmn(argc, argv);
+ int exitCode = main(argc, argv);
delete[] argv;
qEventDispatcherDebug() << "Returned from main with exit code " << exitCode;
@@ -293,7 +282,7 @@ static bool rootLevelRunLoopIntegration()
@implementation QIOSApplicationStateTracker
-+ (void) load
++ (void)load
{
[[NSNotificationCenter defaultCenter]
addObserver:self
@@ -323,7 +312,7 @@ static bool rootLevelRunLoopIntegration()
# error "Unknown processor family"
#endif
-+ (void) applicationDidFinishLaunching
++ (void)applicationDidFinishLaunching
{
if (!isQtApplication())
return;
@@ -377,7 +366,7 @@ static bool rootLevelRunLoopIntegration()
// four bits of the exit code (exit(3) will only pass on the lower 8 bits).
static const char kApplicationWillTerminateExitCode = SIGTERM | 0x80;
-+ (void) applicationWillTerminate
++ (void)applicationWillTerminate
{
if (!isQtApplication())
return;
diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h
index 86b784618f..544f9e0a42 100644
--- a/src/plugins/platforms/ios/qiosglobal.h
+++ b/src/plugins/platforms/ios/qiosglobal.h
@@ -68,7 +68,7 @@ int infoPlistValue(NSString* key, int defaultValue);
QT_END_NAMESPACE
@interface UIResponder (QtFirstResponder)
-+(id)currentFirstResponder;
++ (id)currentFirstResponder;
@end
class FirstResponderCandidate : public QScopedValueRollback<UIResponder *>
diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm
index ef24abbfd9..f5b971391d 100644
--- a/src/plugins/platforms/ios/qiosglobal.mm
+++ b/src/plugins/platforms/ios/qiosglobal.mm
@@ -133,7 +133,7 @@ int infoPlistValue(NSString* key, int defaultValue)
@end
@implementation QtFirstResponderEvent
-- (void) dealloc
+- (void)dealloc
{
self.firstResponder = 0;
[super dealloc];
@@ -158,7 +158,7 @@ int infoPlistValue(NSString* key, int defaultValue)
@implementation UIResponder (QtFirstResponder)
-+(id)currentFirstResponder
++ (id)currentFirstResponder
{
QtFirstResponderEvent *event = [[[QtFirstResponderEvent alloc] init] autorelease];
[[UIApplication sharedApplication] sendAction:@selector(qt_findFirstResponder:event:) to:nil from:nil forEvent:event];
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index 090df66e0d..d03c589b2a 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -579,7 +579,7 @@ void QIOSInputContext::focusWindowChanged(QWindow *focusWindow)
void QIOSInputContext::update(Qt::InputMethodQueries updatedProperties)
{
// Mask for properties that we are interested in and see if any of them changed
- updatedProperties &= (Qt::ImEnabled | Qt::ImHints | Qt::ImQueryInput | Qt::ImPlatformData);
+ updatedProperties &= (Qt::ImEnabled | Qt::ImHints | Qt::ImQueryInput | Qt::ImEnterKeyType | Qt::ImPlatformData);
qImDebug() << "fw =" << qApp->focusWindow() << "fo =" << qApp->focusObject();
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index 837d0e9143..b4050b8f62 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -219,6 +219,10 @@ QPlatformServices *QIOSIntegration::services() const
QVariant QIOSIntegration::styleHint(StyleHint hint) const
{
switch (hint) {
+ case PasswordMaskDelay:
+ // this number is based on timing the native delay
+ // since there is no API to get it
+ return 2000;
case ShowIsMaximized:
return true;
case SetFocusOnTouchRelease:
diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm
index 08fc8a5e9c..045d39e328 100644
--- a/src/plugins/platforms/ios/qiosmenu.mm
+++ b/src/plugins/platforms/ios/qiosmenu.mm
@@ -165,7 +165,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
[self reloadAllComponents];
}
--(void)listenForKeyboardWillHideNotification:(BOOL)listen
+- (void)listenForKeyboardWillHideNotification:(BOOL)listen
{
if (listen) {
[[NSNotificationCenter defaultCenter]
@@ -179,7 +179,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
}
}
--(void)dealloc
+- (void)dealloc
{
[self listenForKeyboardWillHideNotification:NO];
self.toolbar = 0;
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index 324133074b..3e16efcd22 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -104,12 +104,12 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
@public
QIOSScreen *m_screen;
}
-- (id) initWithQIOSScreen:(QIOSScreen *)screen;
+- (id)initWithQIOSScreen:(QIOSScreen *)screen;
@end
@implementation QIOSOrientationListener
-- (id) initWithQIOSScreen:(QIOSScreen *)screen
+- (id)initWithQIOSScreen:(QIOSScreen *)screen
{
self = [super init];
if (self) {
@@ -123,7 +123,7 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
return self;
}
-- (void) dealloc
+- (void)dealloc
{
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]
@@ -132,7 +132,7 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
[super dealloc];
}
-- (void) orientationChanged:(NSNotification *)notification
+- (void)orientationChanged:(NSNotification *)notification
{
Q_UNUSED(notification);
m_screen->updateProperties();
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index 52336a4e69..d86f545154 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -92,12 +92,12 @@
return [QUITextPosition positionWithIndex:(self.range.location + self.range.length)];
}
-- (NSRange) range
+- (NSRange)range
{
return _range;
}
--(BOOL)isEmpty
+- (BOOL)isEmpty
{
return (self.range.length == 0);
}
@@ -111,7 +111,7 @@
@implementation WrapperView
--(id)initWithView:(UIView *)view
+- (id)initWithView:(UIView *)view
{
if (self = [self init]) {
[self addSubview:view];
@@ -143,7 +143,7 @@
// retained, we ensure that all messages sent to the view during
// its lifetime in a window hierarcy will be able to traverse the
// responder chain.
--(void)willMoveToWindow:(UIWindow *)window
+- (void)willMoveToWindow:(UIWindow *)window
{
if (window)
[[self nextResponder] retain];
@@ -170,9 +170,31 @@
QVariantMap platformData = m_configuredImeState->value(Qt::ImPlatformData).toMap();
Qt::InputMethodHints hints = Qt::InputMethodHints(m_configuredImeState->value(Qt::ImHints).toUInt());
- self.returnKeyType = platformData.value(kImePlatformDataReturnKeyType).isValid() ?
- UIReturnKeyType(platformData.value(kImePlatformDataReturnKeyType).toInt()) :
- (hints & Qt::ImhMultiLine) ? UIReturnKeyDefault : UIReturnKeyDone;
+ Qt::EnterKeyType enterKeyType = Qt::EnterKeyType(m_configuredImeState->value(Qt::ImEnterKeyType).toUInt());
+
+ switch (enterKeyType) {
+ case Qt::EnterKeyReturn:
+ self.returnKeyType = UIReturnKeyDefault;
+ break;
+ case Qt::EnterKeyDone:
+ self.returnKeyType = UIReturnKeyDone;
+ break;
+ case Qt::EnterKeyGo:
+ self.returnKeyType = UIReturnKeyGo;
+ break;
+ case Qt::EnterKeySend:
+ self.returnKeyType = UIReturnKeySend;
+ break;
+ case Qt::EnterKeySearch:
+ self.returnKeyType = UIReturnKeySearch;
+ break;
+ case Qt::EnterKeyNext:
+ self.returnKeyType = UIReturnKeyNext;
+ break;
+ default:
+ self.returnKeyType = (hints & Qt::ImhMultiLine) ? UIReturnKeyDefault : UIReturnKeyDone;
+ break;
+ }
self.secureTextEntry = BOOL(hints & Qt::ImhHiddenText);
self.autocorrectionType = (hints & Qt::ImhNoPredictiveText) ?
@@ -233,7 +255,7 @@
}
// Based on what we set up in initWithInputContext above
- updatedProperties &= (Qt::ImHints | Qt::ImPlatformData);
+ updatedProperties &= (Qt::ImHints | Qt::ImEnterKeyType | Qt::ImPlatformData);
if (!updatedProperties)
return NO;
@@ -361,17 +383,17 @@
return m_inputContext->imeState().currentState.value(query);
}
--(id<UITextInputTokenizer>)tokenizer
+- (id<UITextInputTokenizer>)tokenizer
{
return [[[UITextInputStringTokenizer alloc] initWithTextInput:id<UITextInput>(self)] autorelease];
}
--(UITextPosition *)beginningOfDocument
+- (UITextPosition *)beginningOfDocument
{
return [QUITextPosition positionWithIndex:0];
}
--(UITextPosition *)endOfDocument
+- (UITextPosition *)endOfDocument
{
int endPosition = [self currentImeState:Qt::ImSurroundingText].toString().length();
return [QUITextPosition positionWithIndex:endPosition];
@@ -637,7 +659,7 @@
return [NSDictionary dictionaryWithObject:uifont forKey:UITextInputTextFontKey];
}
--(NSDictionary *)markedTextStyle
+- (NSDictionary *)markedTextStyle
{
return [NSDictionary dictionary];
}
@@ -659,7 +681,8 @@
[self sendEventToFocusObject:press];
[self sendEventToFocusObject:release];
- if (self.returnKeyType == UIReturnKeyDone)
+ if (self.returnKeyType == UIReturnKeyDone || self.returnKeyType == UIReturnKeyGo
+ || self.returnKeyType == UIReturnKeySend || self.returnKeyType == UIReturnKeySearch)
[self resignFirstResponder];
return;
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm
index 6667ec3dd8..4ea5fc7de1 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.mm
+++ b/src/plugins/platforms/ios/qiosviewcontroller.mm
@@ -288,13 +288,13 @@
// -------------------------------------------------------------------------
--(BOOL)shouldAutorotate
+- (BOOL)shouldAutorotate
{
return m_screen && m_screen->uiScreen() == [UIScreen mainScreen] && !self.lockedOrientation;
}
#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_6_0)
--(NSUInteger)supportedInterfaceOrientations
+- (NSUInteger)supportedInterfaceOrientations
{
// As documented by Apple in the iOS 6.0 release notes, setStatusBarOrientation:animated:
// only works if the supportedInterfaceOrientations of the view controller is 0, making
@@ -307,7 +307,7 @@
#endif
#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0)
--(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
Q_UNUSED(interfaceOrientation);
return [self shouldAutorotate];
diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.h b/src/plugins/platforms/ios/quiaccessibilityelement.h
index a690e12c7d..c76e3a6a1e 100644
--- a/src/plugins/platforms/ios/quiaccessibilityelement.h
+++ b/src/plugins/platforms/ios/quiaccessibilityelement.h
@@ -42,8 +42,8 @@
@property (readonly) QAccessible::Id axid;
-- (id) initWithId: (QAccessible::Id) anId withAccessibilityContainer: (id) view;
-+ (QMacAccessibilityElement *) elementWithId: (QAccessible::Id) anId withAccessibilityContainer: (id) view;
+- (id)initWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view;
++ (QMacAccessibilityElement *)elementWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view;
@end
diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.mm b/src/plugins/platforms/ios/quiaccessibilityelement.mm
index 2cecfc1126..3bac1ca88d 100644
--- a/src/plugins/platforms/ios/quiaccessibilityelement.mm
+++ b/src/plugins/platforms/ios/quiaccessibilityelement.mm
@@ -37,7 +37,7 @@
@implementation QMacAccessibilityElement
-- (id) initWithId: (QAccessible::Id) anId withAccessibilityContainer: (id) view
+- (id)initWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view
{
Q_ASSERT((int)anId < 0);
self = [super initWithAccessibilityContainer: view];
@@ -47,7 +47,7 @@
return self;
}
-+ (id) elementWithId: (QAccessible::Id) anId withAccessibilityContainer: (id) view
++ (id)elementWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view
{
Q_ASSERT(anId);
if (!anId)
@@ -64,17 +64,17 @@
return element;
}
-- (void) invalidate
+- (void)invalidate
{
[self release];
}
-- (BOOL) isAccessibilityElement
+- (BOOL)isAccessibilityElement
{
return YES;
}
-- (NSString*) accessibilityLabel
+- (NSString*)accessibilityLabel
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (!iface) {
@@ -85,7 +85,7 @@
return iface->text(QAccessible::Name).toNSString();
}
-- (NSString*) accessibilityHint
+- (NSString*)accessibilityHint
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (!iface) {
@@ -95,7 +95,7 @@
return iface->text(QAccessible::Description).toNSString();
}
-- (NSString*) accessibilityValue
+- (NSString*)accessibilityValue
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (!iface) {
@@ -119,7 +119,7 @@
return [super accessibilityHint];
}
-- (CGRect) accessibilityFrame
+- (CGRect)accessibilityFrame
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (!iface) {
@@ -131,7 +131,7 @@
return CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
}
-- (UIAccessibilityTraits) accessibilityTraits
+- (UIAccessibilityTraits)accessibilityTraits
{
UIAccessibilityTraits traits = UIAccessibilityTraitNone;
@@ -156,7 +156,7 @@
return traits;
}
-- (BOOL) accessibilityActivate
+- (BOOL)accessibilityActivate
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (QAccessibleActionInterface *action = iface->actionInterface()) {
@@ -171,21 +171,21 @@
return NO; // fall back to sending mouse clicks
}
-- (void) accessibilityIncrement
+- (void)accessibilityIncrement
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (QAccessibleActionInterface *action = iface->actionInterface())
action->doAction(QAccessibleActionInterface::increaseAction());
}
-- (void) accessibilityDecrement
+- (void)accessibilityDecrement
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (QAccessibleActionInterface *action = iface->actionInterface())
action->doAction(QAccessibleActionInterface::decreaseAction());
}
-- (BOOL) accessibilityScroll : (UIAccessibilityScrollDirection) direction
+- (BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
QAccessibleActionInterface *action = iface->actionInterface();
diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm
index 87dc3b9dcb..c6ef843b9f 100644
--- a/src/plugins/platforms/ios/quiview.mm
+++ b/src/plugins/platforms/ios/quiview.mm
@@ -50,7 +50,7 @@
return [CAEAGLLayer class];
}
--(id)initWithQIOSWindow:(QIOSWindow *)window
+- (id)initWithQIOSWindow:(QIOSWindow *)window
{
if (self = [self initWithFrame:toCGRect(window->geometry())])
m_qioswindow = window;
@@ -316,7 +316,7 @@
}
}
-- (void) sendTouchEventWithTimestamp:(ulong)timeStamp
+- (void)sendTouchEventWithTimestamp:(ulong)timeStamp
{
// Send touch event synchronously
QIOSIntegration *iosIntegration = QIOSIntegration::instance();
diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp
index 071bab7920..1c825dbbdd 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.cpp
+++ b/src/plugins/platforms/qnx/qqnxintegration.cpp
@@ -95,7 +95,6 @@
#include <private/qsimpledrag_p.h>
#include <QtCore/QDebug>
-#include <QtCore/QHash>
#include <errno.h>
diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp
index 2e6a43f596..244fc72332 100644
--- a/src/plugins/platforms/windows/qwindowsopengltester.cpp
+++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp
@@ -224,7 +224,7 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c
#elif defined(Q_OS_WINCE)
return QWindowsOpenGLTester::Gles;
#else
- QOpenGLConfig::Gpu qgpu = QOpenGLConfig::Gpu::fromDevice(gpu.deviceId, gpu.vendorId, gpu.driverVersion);
+ QOpenGLConfig::Gpu qgpu = QOpenGLConfig::Gpu::fromDevice(gpu.deviceId, gpu.vendorId, gpu.driverVersion, gpu.description);
SupportedRenderersCache *srCache = supportedRenderersCache();
SupportedRenderersCache::const_iterator it = srCache->find(qgpu);
if (it != srCache->cend())
@@ -250,19 +250,19 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c
qCDebug(lcQpaGl) << "GPU features:" << features;
if (features.contains(QStringLiteral("disable_desktopgl"))) { // Qt-specific
- qCWarning(lcQpaGl) << "Disabling Desktop GL: " << gpu;
+ qCDebug(lcQpaGl) << "Disabling Desktop GL: " << gpu;
result &= ~QWindowsOpenGLTester::DesktopGl;
}
if (features.contains(QStringLiteral("disable_angle"))) { // Qt-specific keyword
- qCWarning(lcQpaGl) << "Disabling ANGLE: " << gpu;
+ qCDebug(lcQpaGl) << "Disabling ANGLE: " << gpu;
result &= ~QWindowsOpenGLTester::GlesMask;
} else {
if (features.contains(QStringLiteral("disable_d3d11"))) { // standard keyword
- qCWarning(lcQpaGl) << "Disabling D3D11: " << gpu;
+ qCDebug(lcQpaGl) << "Disabling D3D11: " << gpu;
result &= ~QWindowsOpenGLTester::AngleRendererD3d11;
}
if (features.contains(QStringLiteral("disable_d3d9"))) { // Qt-specific
- qCWarning(lcQpaGl) << "Disabling D3D9: " << gpu;
+ qCDebug(lcQpaGl) << "Disabling D3D9: " << gpu;
result &= ~QWindowsOpenGLTester::AngleRendererD3d9;
}
}
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp
index 10411e72e2..508f5e82e6 100644
--- a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp
@@ -78,6 +78,7 @@ QStringList QXcbGlIntegrationFactory::keys(const QString &pluginPath)
list.append(loader()->keyMap().values());
return list;
#else
+ Q_UNUSED(pluginPath);
return QStringList();
#endif
}
@@ -93,6 +94,9 @@ QXcbGlIntegration *QXcbGlIntegrationFactory::create(const QString &platform, con
}
if (QXcbGlIntegration *ret = loadIntegration(loader(), platform))
return ret;
+#else
+ Q_UNUSED(platform);
+ Q_UNUSED(pluginPath);
#endif
return Q_NULLPTR;
}
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
index 8b14fc7d70..37f01d4eed 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
@@ -188,16 +188,18 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
Window window = 0; // Temporary window used to query OpenGL context
if (config) {
+ const QByteArrayList glxExt = QByteArray(glXQueryExtensionsString(m_display, screen->screenNumber())).split(' ');
+
// Resolve entry point for glXCreateContextAttribsARB
glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;
- glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
+ if (glxExt.contains("GLX_ARB_create_context"))
+ glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
- QList<QByteArray> glxExt = QByteArray(glXQueryExtensionsString(m_display, screen->screenNumber())).split(' ');
- bool supportsProfiles = glxExt.contains("GLX_ARB_create_context_profile");
+ const bool supportsProfiles = glxExt.contains("GLX_ARB_create_context_profile");
// Use glXCreateContextAttribsARB if available
// Also, GL ES context creation requires GLX_EXT_create_context_es2_profile
- if (glxExt.contains("GLX_ARB_create_context") && glXCreateContextAttribsARB != 0
+ if (glXCreateContextAttribsARB != 0
&& (m_format.renderableType() != QSurfaceFormat::OpenGLES || (supportsProfiles && glxExt.contains("GLX_EXT_create_context_es2_profile")))) {
// Try to create an OpenGL context for each known OpenGL version in descending
// order from the requested version.
@@ -561,10 +563,12 @@ void (*QGLXContext::getProcAddress(const QByteArray &procName)) ()
if (!glXGetProcAddressARB)
#endif
{
+#ifndef QT_NO_LIBRARY
extern const QString qt_gl_library_name();
// QLibrary lib(qt_gl_library_name());
QLibrary lib(QLatin1String("GL"));
glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
+#endif
}
}
resolved = true;
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index b8b665157b..f324942c8b 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -1994,10 +1994,11 @@ bool QXcbConnection::xi2PrepareXIGenericDeviceEvent(xcb_ge_event_t *ev, int opCo
}
#endif // defined(XCB_USE_XINPUT2)
-QXcbSystemTrayTracker *QXcbConnection::systemTrayTracker()
+QXcbSystemTrayTracker *QXcbConnection::systemTrayTracker() const
{
if (!m_systemTrayTracker) {
- if ( (m_systemTrayTracker = QXcbSystemTrayTracker::create(this)) ) {
+ QXcbConnection *self = const_cast<QXcbConnection *>(this);
+ if ((self->m_systemTrayTracker = QXcbSystemTrayTracker::create(self))) {
connect(m_systemTrayTracker, SIGNAL(systemTrayWindowChanged(QScreen*)),
QGuiApplication::platformNativeInterface(), SIGNAL(systemTrayWindowChanged(QScreen*)));
}
@@ -2005,6 +2006,22 @@ QXcbSystemTrayTracker *QXcbConnection::systemTrayTracker()
return m_systemTrayTracker;
}
+bool QXcbConnection::xEmbedSystemTrayAvailable()
+{
+ if (!QGuiApplicationPrivate::platformIntegration())
+ return false;
+ QXcbConnection *connection = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration())->defaultConnection();
+ return connection->systemTrayTracker();
+}
+
+bool QXcbConnection::xEmbedSystemTrayVisualHasAlphaChannel()
+{
+ if (!QGuiApplicationPrivate::platformIntegration())
+ return false;
+ QXcbConnection *connection = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration())->defaultConnection();
+ return connection->systemTrayTracker() && connection->systemTrayTracker()->visualHasAlphaChannel();
+}
+
bool QXcbConnection::event(QEvent *e)
{
if (e->type() == QEvent::User + 1) {
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 291193612c..90603ac9bc 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -475,7 +475,9 @@ public:
QXcbNativeInterface *nativeInterface() const { return m_nativeInterface; }
- QXcbSystemTrayTracker *systemTrayTracker();
+ QXcbSystemTrayTracker *systemTrayTracker() const;
+ static bool xEmbedSystemTrayAvailable();
+ static bool xEmbedSystemTrayVisualHasAlphaChannel();
#ifdef XCB_USE_XINPUT2
void handleEnterEvent(const xcb_enter_notify_event_t *);
diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
index e51ab85e30..9d00367b9c 100644
--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
+++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
@@ -52,7 +52,7 @@ typedef char *(*PtrXcursorLibraryGetTheme)(void *);
typedef int (*PtrXcursorLibrarySetTheme)(void *, const char *);
typedef int (*PtrXcursorLibraryGetDefaultSize)(void *);
-#ifdef XCB_USE_XLIB
+#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY)
#include <X11/Xlib.h>
enum {
XCursorShape = CursorShape
@@ -300,7 +300,7 @@ QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen)
const char *cursorStr = "cursor";
xcb_open_font(xcb_connection(), cursorFont, strlen(cursorStr), cursorStr);
-#ifdef XCB_USE_XLIB
+#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY)
static bool function_ptrs_not_initialized = true;
if (function_ptrs_not_initialized) {
QLibrary xcursorLib(QLatin1String("Xcursor"), 1);
@@ -489,7 +489,7 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape)
return cursor;
}
-#ifdef XCB_USE_XLIB
+#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY)
bool updateCursorTheme(void *dpy, const QByteArray &theme) {
if (!ptrXcursorLibraryGetTheme
|| !ptrXcursorLibrarySetTheme)
@@ -533,7 +533,7 @@ static xcb_cursor_t loadCursor(void *dpy, int cshape)
}
return cursor;
}
-#endif //XCB_USE_XLIB
+#endif //XCB_USE_XLIB / QT_NO_LIBRARY
xcb_cursor_t QXcbCursor::createFontCursor(int cshape)
{
@@ -542,7 +542,7 @@ xcb_cursor_t QXcbCursor::createFontCursor(int cshape)
xcb_cursor_t cursor = XCB_NONE;
// Try Xcursor first
-#ifdef XCB_USE_XLIB
+#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY)
if (cshape >= 0 && cshape <= Qt::LastCursor) {
void *dpy = connection()->xlib_display();
// special case for non-standard dnd-* cursors
diff --git a/src/plugins/platforms/xcb/qxcbcursor.h b/src/plugins/platforms/xcb/qxcbcursor.h
index 7e5cdc6870..f4f6e61706 100644
--- a/src/plugins/platforms/xcb/qxcbcursor.h
+++ b/src/plugins/platforms/xcb/qxcbcursor.h
@@ -90,7 +90,7 @@ private:
#ifndef QT_NO_CURSOR
CursorHash m_cursorHash;
#endif
-#ifdef XCB_USE_XLIB
+#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY)
static void cursorThemePropertyChanged(QXcbVirtualDesktop *screen,
const QByteArray &name,
const QVariant &property,
diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
index 1d13adf851..35c6614d4c 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -689,6 +689,7 @@ void QXcbDrag::handleEnter(QWindow *window, const xcb_client_message_event_t *ev
length = xdnd_max_type;
xcb_atom_t *atoms = (xcb_atom_t *)xcb_get_property_value(reply);
+ xdnd_types.reserve(length);
for (int i = 0; i < length; ++i)
xdnd_types.append(atoms[i]);
}
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index ea541e4556..2e088d3ca5 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -1545,11 +1545,13 @@ void QXcbKeyboard::handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type,
QString QXcbKeyboard::lookupString(struct xkb_state *state, xcb_keycode_t code) const
{
- QByteArray chars;
- chars.resize(1 + xkb_state_key_get_utf8(state, code, 0, 0));
- // equivalent of XLookupString
- xkb_state_key_get_utf8(state, code, chars.data(), chars.size());
- return QString::fromUtf8(chars);
+ QVarLengthArray<char, 32> chars(32);
+ const int size = xkb_state_key_get_utf8(state, code, chars.data(), chars.size());
+ if (Q_UNLIKELY(size + 1 > chars.size())) { // +1 for NUL
+ chars.resize(size + 1);
+ xkb_state_key_get_utf8(state, code, chars.data(), chars.size());
+ }
+ return QString::fromUtf8(chars.constData(), size);
}
void QXcbKeyboard::handleKeyPressEvent(const xcb_key_press_event_t *event)
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 8bf9003af7..dfb0a125e2 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -47,6 +47,7 @@
#include <QtGui/qscreen.h>
#include <QtPlatformHeaders/qxcbwindowfunctions.h>
+#include <QtPlatformHeaders/qxcbintegrationfunctions.h>
#ifndef QT_NO_DBUS
#include "QtPlatformSupport/private/qdbusmenuconnection_p.h"
@@ -76,7 +77,8 @@ static int resourceType(const QByteArray &key)
QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"),
QByteArrayLiteral("rootwindow"),
QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingEnabled"),
- QByteArrayLiteral("nofonthinting")
+ QByteArrayLiteral("nofonthinting"),
+ QByteArrayLiteral("atspibus")
};
const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
const QByteArray *result = std::find(names, end, key);
@@ -85,8 +87,7 @@ static int resourceType(const QByteArray &key)
QXcbNativeInterface::QXcbNativeInterface() :
m_genericEventFilterType(QByteArrayLiteral("xcb_generic_event_t")),
- m_sysTraySelectionAtom(XCB_ATOM_NONE),
- m_systrayVisualId(XCB_NONE)
+ m_sysTraySelectionAtom(XCB_ATOM_NONE)
{
}
@@ -117,22 +118,12 @@ bool QXcbNativeInterface::systemTrayAvailable(const QScreen *screen) const
bool QXcbNativeInterface::requestSystemTrayWindowDock(const QWindow *window)
{
- const QPlatformWindow *platformWindow = window->handle();
- if (!platformWindow)
- return false;
- QXcbSystemTrayTracker *trayTracker = systemTrayTracker(window->screen());
- if (!trayTracker)
- return false;
- trayTracker->requestSystemTrayWindowDock(static_cast<const QXcbWindow *>(platformWindow)->xcb_window());
- return true;
+ return QXcbWindow::requestSystemTrayWindowDockStatic(window);
}
QRect QXcbNativeInterface::systemTrayWindowGlobalGeometry(const QWindow *window)
{
- if (const QPlatformWindow *platformWindow = window->handle())
- if (const QXcbSystemTrayTracker *trayTracker = systemTrayTracker(window->screen()))
- return trayTracker->systemTrayWindowGlobalGeometry(static_cast<const QXcbWindow *>(platformWindow)->xcb_window());
- return QRect();
+ return QXcbWindow::systemTrayWindowGlobalGeometryStatic(window);
}
xcb_window_t QXcbNativeInterface::locateSystemTray(xcb_connection_t *conn, const QXcbScreen *screen)
@@ -163,54 +154,14 @@ xcb_window_t QXcbNativeInterface::locateSystemTray(xcb_connection_t *conn, const
return selection_window;
}
-bool QXcbNativeInterface::systrayVisualHasAlphaChannel() {
- const QXcbScreen *screen = static_cast<QXcbScreen *>(QGuiApplication::primaryScreen()->handle());
-
- if (m_systrayVisualId == XCB_NONE) {
- xcb_connection_t *xcb_conn = screen->xcb_connection();
- xcb_atom_t tray_atom = screen->atom(QXcbAtom::_NET_SYSTEM_TRAY_VISUAL);
-
- xcb_window_t systray_window = locateSystemTray(xcb_conn, screen);
- if (systray_window == XCB_WINDOW_NONE)
- return false;
-
- // Get the xcb property for the _NET_SYSTEM_TRAY_VISUAL atom
- xcb_get_property_cookie_t systray_atom_cookie;
- xcb_get_property_reply_t *systray_atom_reply;
-
- systray_atom_cookie = xcb_get_property_unchecked(xcb_conn, false, systray_window,
- tray_atom, XCB_ATOM_VISUALID, 0, 1);
- systray_atom_reply = xcb_get_property_reply(xcb_conn, systray_atom_cookie, 0);
-
- if (!systray_atom_reply)
- return false;
-
- if (systray_atom_reply->value_len > 0 && xcb_get_property_value_length(systray_atom_reply) > 0) {
- xcb_visualid_t * vids = (uint32_t *)xcb_get_property_value(systray_atom_reply);
- m_systrayVisualId = vids[0];
- }
-
- free(systray_atom_reply);
- }
-
- if (m_systrayVisualId != XCB_NONE) {
- quint8 depth = screen->depthOfVisual(m_systrayVisualId);
- return depth == 32;
- } else {
- return false;
- }
+bool QXcbNativeInterface::systrayVisualHasAlphaChannel()
+{
+ return QXcbConnection::xEmbedSystemTrayVisualHasAlphaChannel();
}
-void QXcbNativeInterface::setParentRelativeBackPixmap(const QWindow *qwindow)
+void QXcbNativeInterface::setParentRelativeBackPixmap(QWindow *window)
{
- if (const QPlatformWindow *platformWindow = qwindow->handle()) {
- const QXcbWindow *qxwindow = static_cast<const QXcbWindow *>(platformWindow);
- xcb_connection_t *xcb_conn = qxwindow->xcb_connection();
-
- const quint32 mask = XCB_CW_BACK_PIXMAP;
- const quint32 values[] = { XCB_BACK_PIXMAP_PARENT_RELATIVE };
- Q_XCB_CALL(xcb_change_window_attributes(xcb_conn, qxwindow->xcb_window(), mask, values));
- }
+ QXcbWindow::setParentRelativeBackPixmapStatic(window);
}
void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resourceString)
@@ -233,6 +184,9 @@ void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resour
case Display:
result = display();
break;
+ case AtspiBus:
+ result = atspiBus();
+ break;
case Connection:
result = connection();
break;
@@ -294,6 +248,9 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resourceStr
case NoFontHinting:
result = xcbScreen->noFontHinting() ? this : 0; //qboolptr...
break;
+ case RootWindow:
+ result = reinterpret_cast<void *>(xcbScreen->root());
+ break;
default:
break;
}
@@ -389,9 +346,24 @@ QFunctionPointer QXcbNativeInterface::platformFunction(const QByteArray &functio
return func;
//case sensitive
- if (function == QXcbWindowFunctions::setWmWindowTypeIdentifier()) {
- return QFunctionPointer(QXcbWindow::setWmWindowTypeStatic);
- }
+ if (function == QXcbWindowFunctions::setWmWindowTypeIdentifier())
+ return QFunctionPointer(QXcbWindowFunctions::SetWmWindowType(QXcbWindow::setWmWindowTypeStatic));
+
+ if (function == QXcbWindowFunctions::setWmWindowIconTextIdentifier())
+ return QFunctionPointer(QXcbWindowFunctions::SetWmWindowIconText(QXcbWindow::setWindowIconTextStatic));
+
+ if (function == QXcbWindowFunctions::setParentRelativeBackPixmapIdentifier())
+ return QFunctionPointer(QXcbWindowFunctions::SetParentRelativeBackPixmap(QXcbWindow::setParentRelativeBackPixmapStatic));
+
+ if (function == QXcbWindowFunctions::requestSystemTrayWindowDockIdentifier())
+ return QFunctionPointer(QXcbWindowFunctions::RequestSystemTrayWindowDock(QXcbWindow::requestSystemTrayWindowDockStatic));
+
+ if (function == QXcbWindowFunctions::systemTrayWindowGlobalGeometryIdentifier())
+ return QFunctionPointer(QXcbWindowFunctions::SystemTrayWindowGlobalGeometry(QXcbWindow::systemTrayWindowGlobalGeometryStatic));
+
+ if (function == QXcbIntegrationFunctions::xEmbedSystemTrayVisualHasAlphaChannelIdentifier())
+ return QFunctionPointer(QXcbIntegrationFunctions::XEmbedSystemTrayVisualHasAlphaChannel(QXcbConnection::xEmbedSystemTrayVisualHasAlphaChannel));
+
if (function == QXcbWindowFunctions::visualIdIdentifier()) {
return QFunctionPointer(QXcbWindowFunctions::VisualId(QXcbWindow::visualIdStatic));
}
@@ -466,6 +438,27 @@ void *QXcbNativeInterface::connection()
return integration->defaultConnection()->xcb_connection();
}
+void *QXcbNativeInterface::atspiBus()
+{
+ QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ QXcbConnection *defaultConnection = integration->defaultConnection();
+ if (defaultConnection) {
+ xcb_atom_t atspiBusAtom = defaultConnection->internAtom("AT_SPI_BUS");
+ xcb_get_property_cookie_t cookie = Q_XCB_CALL(xcb_get_property(defaultConnection->xcb_connection(), false,
+ defaultConnection->rootWindow(),
+ atspiBusAtom,
+ XCB_ATOM_STRING, 0, 128));
+ xcb_get_property_reply_t *reply = Q_XCB_CALL(xcb_get_property_reply(defaultConnection->xcb_connection(), cookie, 0));
+ Q_ASSERT(!reply->bytes_after);
+ char *data = (char *)xcb_get_property_value(reply);
+ int length = xcb_get_property_value_length(reply);
+ QByteArray *busAddress = new QByteArray(data, length);
+ free(reply);
+ return busAddress;
+ }
+ return 0;
+}
+
void QXcbNativeInterface::setAppTime(QScreen* screen, xcb_timestamp_t time)
{
if (screen) {
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
index 721c6f4b1d..f88b710864 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -67,7 +67,8 @@ public:
RootWindow,
ScreenSubpixelType,
ScreenAntialiasingEnabled,
- NoFontHinting
+ NoFontHinting,
+ AtspiBus
};
QXcbNativeInterface();
@@ -98,6 +99,7 @@ public:
void *x11Screen();
void *rootWindow();
void *display();
+ void *atspiBus();
void *connection();
static void setStartupId(const char *);
static void setAppTime(QScreen *screen, xcb_timestamp_t time);
@@ -105,7 +107,7 @@ public:
Q_INVOKABLE void beep();
Q_INVOKABLE bool systemTrayAvailable(const QScreen *screen) const;
- Q_INVOKABLE void setParentRelativeBackPixmap(const QWindow *window);
+ Q_INVOKABLE void setParentRelativeBackPixmap(QWindow *window);
Q_INVOKABLE bool systrayVisualHasAlphaChannel();
Q_INVOKABLE bool requestSystemTrayWindowDock(const QWindow *window);
Q_INVOKABLE QRect systemTrayWindowGlobalGeometry(const QWindow *window);
@@ -121,7 +123,6 @@ private:
const QByteArray m_genericEventFilterType;
xcb_atom_t m_sysTraySelectionAtom;
- xcb_visualid_t m_systrayVisualId;
static QXcbScreen *qPlatformScreenForWindow(QWindow *window);
diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
index 328b72234a..c2101a71c1 100644
--- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
+++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
@@ -134,6 +134,7 @@ static void sm_setProperty(const QString &name, const QStringList &value)
SmPropValue *prop = new SmPropValue[value.count()];
int count = 0;
QList<QByteArray> vl;
+ vl.reserve(value.size());
for (QStringList::ConstIterator it = value.begin(); it != value.end(); ++it) {
prop[count].length = (*it).length();
vl.append((*it).toUtf8());
diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
index a4fdd70b79..1f217e8de7 100644
--- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
+++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
@@ -63,14 +63,14 @@ QXcbSystemTrayTracker *QXcbSystemTrayTracker::create(QXcbConnection *connection)
const xcb_atom_t selection = connection->internAtom(netSysTray.constData());
if (!selection)
return 0;
- return new QXcbSystemTrayTracker(connection, trayAtom, selection, connection);
+
+ return new QXcbSystemTrayTracker(connection, trayAtom, selection);
}
QXcbSystemTrayTracker::QXcbSystemTrayTracker(QXcbConnection *connection,
xcb_atom_t trayAtom,
- xcb_atom_t selection,
- QObject *parent)
- : QObject(parent)
+ xcb_atom_t selection)
+ : QObject(connection)
, m_selection(selection)
, m_trayAtom(trayAtom)
, m_connection(connection)
@@ -125,6 +125,7 @@ xcb_window_t QXcbSystemTrayTracker::trayWindow()
// does not work for the QWindow parented on the tray.
QRect QXcbSystemTrayTracker::systemTrayWindowGlobalGeometry(xcb_window_t window) const
{
+
xcb_connection_t *conn = m_connection->xcb_connection();
xcb_get_geometry_reply_t *geomReply =
xcb_get_geometry_reply(conn, xcb_get_geometry(conn, window), 0);
@@ -161,9 +162,43 @@ void QXcbSystemTrayTracker::handleDestroyNotifyEvent(const xcb_destroy_notify_ev
{
if (event->window == m_trayWindow) {
m_connection->removeWindowEventListener(m_trayWindow);
- m_trayWindow = 0;
+ m_trayWindow = XCB_WINDOW_NONE;
emitSystemTrayWindowChanged();
}
}
+bool QXcbSystemTrayTracker::visualHasAlphaChannel()
+{
+ if (m_trayWindow == XCB_WINDOW_NONE)
+ return false;
+
+ xcb_atom_t tray_atom = m_connection->atom(QXcbAtom::_NET_SYSTEM_TRAY_VISUAL);
+
+ // Get the xcb property for the _NET_SYSTEM_TRAY_VISUAL atom
+ xcb_get_property_cookie_t systray_atom_cookie;
+ xcb_get_property_reply_t *systray_atom_reply;
+
+ systray_atom_cookie = xcb_get_property_unchecked(m_connection->xcb_connection(), false, m_trayWindow,
+ tray_atom, XCB_ATOM_VISUALID, 0, 1);
+ systray_atom_reply = xcb_get_property_reply(m_connection->xcb_connection(), systray_atom_cookie, 0);
+
+ if (!systray_atom_reply)
+ return false;
+
+ xcb_visualid_t systrayVisualId = XCB_NONE;
+ if (systray_atom_reply->value_len > 0 && xcb_get_property_value_length(systray_atom_reply) > 0) {
+ xcb_visualid_t * vids = (uint32_t *)xcb_get_property_value(systray_atom_reply);
+ systrayVisualId = vids[0];
+ }
+
+ free(systray_atom_reply);
+
+ if (systrayVisualId != XCB_NONE) {
+ quint8 depth = m_connection->primaryScreen()->depthOfVisual(systrayVisualId);
+ return depth == 32;
+ }
+
+ return false;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.h b/src/plugins/platforms/xcb/qxcbsystemtraytracker.h
index 9c20f1729a..b619afb9c4 100644
--- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.h
+++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.h
@@ -57,14 +57,14 @@ public:
void handleDestroyNotifyEvent(const xcb_destroy_notify_event_t *) Q_DECL_OVERRIDE;
+ bool visualHasAlphaChannel();
signals:
void systemTrayWindowChanged(QScreen *screen);
private:
explicit QXcbSystemTrayTracker(QXcbConnection *connection,
xcb_atom_t trayAtom,
- xcb_atom_t selection,
- QObject *parent = 0);
+ xcb_atom_t selection);
static xcb_window_t locateTrayWindow(const QXcbConnection *connection, xcb_atom_t selection);
void emitSystemTrayWindowChanged();
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 6e021ced23..05d7292430 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -46,6 +46,7 @@
#include "qxcbwmsupport.h"
#include "qxcbimage.h"
#include "qxcbnativeinterface.h"
+#include "qxcbsystemtraytracker.h"
#include <qpa/qplatformintegration.h>
@@ -1506,10 +1507,22 @@ void QXcbWindow::setWindowTitle(const QString &title)
xcb_flush(xcb_connection());
}
+void QXcbWindow::setWindowIconText(const QString &title)
+{
+ const QByteArray ba = title.toUtf8();
+ Q_XCB_CALL(xcb_change_property(xcb_connection(),
+ XCB_PROP_MODE_REPLACE,
+ m_window,
+ atom(QXcbAtom::_NET_WM_ICON_NAME),
+ atom(QXcbAtom::UTF8_STRING),
+ 8,
+ ba.length(),
+ ba.constData()));
+}
+
void QXcbWindow::setWindowIcon(const QIcon &icon)
{
QVector<quint32> icon_data;
-
if (!icon.isNull()) {
QList<QSize> availableSizes = icon.availableSizes();
if (availableSizes.isEmpty()) {
@@ -1674,6 +1687,12 @@ void QXcbWindow::setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmW
static_cast<QXcbWindow *>(window->handle())->setWmWindowType(windowTypes, window->flags());
}
+void QXcbWindow::setWindowIconTextStatic(QWindow *window, const QString &text)
+{
+ if (window->handle())
+ static_cast<QXcbWindow *>(window->handle())->setWindowIconText(text);
+}
+
uint QXcbWindow::visualIdStatic(QWindow *window)
{
if (window && window->handle())
@@ -1839,6 +1858,48 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
xcb_flush(xcb_connection());
}
+void QXcbWindow::setParentRelativeBackPixmapStatic(QWindow *window)
+{
+ if (window->handle())
+ static_cast<QXcbWindow *>(window->handle())->setParentRelativeBackPixmap();
+}
+
+void QXcbWindow::setParentRelativeBackPixmap()
+{
+ const quint32 mask = XCB_CW_BACK_PIXMAP;
+ const quint32 values[] = { XCB_BACK_PIXMAP_PARENT_RELATIVE };
+ Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values));
+}
+
+bool QXcbWindow::requestSystemTrayWindowDockStatic(const QWindow *window)
+{
+ if (window->handle())
+ return static_cast<QXcbWindow *>(window->handle())->requestSystemTrayWindowDock();
+ return false;
+}
+
+bool QXcbWindow::requestSystemTrayWindowDock() const
+{
+ if (!connection()->systemTrayTracker())
+ return false;
+ connection()->systemTrayTracker()->requestSystemTrayWindowDock(m_window);
+ return true;
+}
+
+QRect QXcbWindow::systemTrayWindowGlobalGeometryStatic(const QWindow *window)
+{
+ if (window->handle())
+ return static_cast<QXcbWindow *>(window->handle())->systemTrayWindowGlobalGeometry();
+ return QRect();
+}
+
+QRect QXcbWindow::systemTrayWindowGlobalGeometry() const
+{
+ if (!connection()->systemTrayTracker())
+ return QRect();
+ return connection()->systemTrayTracker()->systemTrayWindowGlobalGeometry(m_window);
+}
+
class ExposeCompressor
{
public:
@@ -2634,7 +2695,9 @@ void QXcbWindow::setMask(const QRegion &region)
} else {
const int dpr = devicePixelRatio();
QVector<xcb_rectangle_t> rects;
- foreach (const QRect &r, region.rects())
+ const QVector<QRect> regionRects = region.rects();
+ rects.reserve(regionRects.count());
+ foreach (const QRect &r, regionRects)
rects.push_back(qRectToXCBRectangle(mapLocalGeometryToNative(r, dpr)));
xcb_shape_rectangles(connection()->xcb_connection(), XCB_SHAPE_SO_SET,
XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index a379a6f9db..43c73180f5 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -86,6 +86,7 @@ public:
QPoint mapFromGlobal(const QPoint &pos) const Q_DECL_OVERRIDE;
void setWindowTitle(const QString &title) Q_DECL_OVERRIDE;
+ void setWindowIconText(const QString &title);
void setWindowIcon(const QIcon &icon) Q_DECL_OVERRIDE;
void raise() Q_DECL_OVERRIDE;
void lower() Q_DECL_OVERRIDE;
@@ -145,6 +146,16 @@ public:
QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const;
void setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::WindowFlags flags);
+ static void setWindowIconTextStatic(QWindow *window, const QString &text);
+
+ static void setParentRelativeBackPixmapStatic(QWindow *window);
+ void setParentRelativeBackPixmap();
+
+ static bool requestSystemTrayWindowDockStatic(const QWindow *window);
+ bool requestSystemTrayWindowDock() const;
+
+ static QRect systemTrayWindowGlobalGeometryStatic(const QWindow *window);
+ QRect systemTrayWindowGlobalGeometry() const;
uint visualId() const;
bool needsSync() const;
diff --git a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h
index 2ac31bf715..141056637e 100644
--- a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h
+++ b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h
@@ -34,7 +34,11 @@
#ifndef QGTK2DIALOGHELPERS_P_H
#define QGTK2DIALOGHELPERS_P_H
+#include <QtCore/qhash.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qurl.h>
#include <QtCore/qscopedpointer.h>
+#include <QtCore/qstring.h>
#include <qpa/qplatformdialoghelper.h>
typedef struct _GtkDialog GtkDialog;
@@ -43,6 +47,7 @@ typedef struct _GtkFileFilter GtkFileFilter;
QT_BEGIN_NAMESPACE
class QGtk2Dialog;
+class QColor;
class QGtk2ColorDialogHelper : public QPlatformColorDialogHelper
{
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index af4f6fc8fe..dd5345e67e 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -1,8 +1,15 @@
TEMPLATE = subdirs
+load(qfeatures)
SUBDIRS *= sqldrivers
-!winrt:qtHaveModule(network): SUBDIRS += bearer
-qtHaveModule(gui): SUBDIRS *= imageformats platforms platforminputcontexts platformthemes generic
+!winrt:qtHaveModule(network):!contains(QT_DISABLED_FEATURES, bearermanagement): SUBDIRS += bearer
+qtHaveModule(gui) {
+ SUBDIRS *= platforms platforminputcontexts platformthemes
+ !contains(QT_DISABLED_FEATURES, imageformatplugin): SUBDIRS *= imageformats
+ !contains(QT_DISABLED_FEATURES, library): SUBDIRS *= generic
+}
qtHaveModule(widgets): SUBDIRS *= styles
-!winrt:!wince:qtHaveModule(widgets): SUBDIRS += printsupport
+!winrt:!wince*:qtHaveModule(widgets):!contains(QT_DISABLED_FEATURES, printer) {
+ SUBDIRS += printsupport
+}
diff --git a/src/plugins/printsupport/cocoa/main.cpp b/src/plugins/printsupport/cocoa/main.cpp
index 2037724719..3db7b49ba4 100644
--- a/src/plugins/printsupport/cocoa/main.cpp
+++ b/src/plugins/printsupport/cocoa/main.cpp
@@ -38,8 +38,6 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_PRINTER
-
class QCocoaPrinterSupportPlugin : public QPlatformPrinterSupportPlugin
{
Q_OBJECT
@@ -67,8 +65,6 @@ QPlatformPrinterSupport *QCocoaPrinterSupportPlugin::create(const QString &key)
return platformPrinterSupport;
}
-#endif
-
QT_END_NAMESPACE
#include "main.moc"
diff --git a/src/plugins/printsupport/cups/main.cpp b/src/plugins/printsupport/cups/main.cpp
index 82485114ab..abd24d411a 100644
--- a/src/plugins/printsupport/cups/main.cpp
+++ b/src/plugins/printsupport/cups/main.cpp
@@ -37,8 +37,6 @@
#include <qpa/qplatformprintplugin.h>
#include <QtCore/QStringList>
-#ifndef QT_NO_PRINTER
-
QT_BEGIN_NAMESPACE
class QCupsPrinterSupportPlugin : public QPlatformPrinterSupportPlugin
@@ -65,6 +63,4 @@ QPlatformPrinterSupport *QCupsPrinterSupportPlugin::create(const QString &key)
QT_END_NAMESPACE
-#endif // QT_NO_PRINTER
-
#include "main.moc"
diff --git a/src/plugins/printsupport/cups/qcupsprintengine.cpp b/src/plugins/printsupport/cups/qcupsprintengine.cpp
index c00d7f302c..7ca81986b4 100644
--- a/src/plugins/printsupport/cups/qcupsprintengine.cpp
+++ b/src/plugins/printsupport/cups/qcupsprintengine.cpp
@@ -33,8 +33,6 @@
#include "qcupsprintengine_p.h"
-#ifndef QT_NO_PRINTER
-
#include <qpa/qplatformprintplugin.h>
#include <qpa/qplatformprintersupport.h>
@@ -226,7 +224,9 @@ void QCupsPrintEnginePrivate::closePrintDevice()
it += 2;
}
- for (int c = 0; c < options.size(); ++c) {
+ const int numOptions = options.size();
+ cupsOptStruct.reserve(numOptions);
+ for (int c = 0; c < numOptions; ++c) {
cups_option_t opt;
opt.name = options[c].first.data();
opt.value = options[c].second.data();
@@ -315,5 +315,3 @@ void QCupsPrintEnginePrivate::setPageSize(const QPageSize &pageSize)
}
QT_END_NAMESPACE
-
-#endif // QT_NO_PRINTER
diff --git a/src/plugins/printsupport/cups/qcupsprintengine_p.h b/src/plugins/printsupport/cups/qcupsprintengine_p.h
index b589d40b6c..a611740e09 100644
--- a/src/plugins/printsupport/cups/qcupsprintengine_p.h
+++ b/src/plugins/printsupport/cups/qcupsprintengine_p.h
@@ -47,8 +47,6 @@
#include "QtPrintSupport/qprintengine.h"
-#ifndef QT_NO_PRINTER
-
#include <QtCore/qstring.h>
#include <QtGui/qpaintengine.h>
@@ -100,6 +98,4 @@ private:
QT_END_NAMESPACE
-#endif // QT_NO_PRINTER
-
#endif // QCUPSPRINTENGINE_P_H
diff --git a/src/plugins/printsupport/cups/qcupsprintersupport.cpp b/src/plugins/printsupport/cups/qcupsprintersupport.cpp
index ea7c116e3c..b257918acf 100644
--- a/src/plugins/printsupport/cups/qcupsprintersupport.cpp
+++ b/src/plugins/printsupport/cups/qcupsprintersupport.cpp
@@ -34,8 +34,6 @@
#include "qcupsprintersupport_p.h"
-#ifndef QT_NO_PRINTER
-
#include "qcupsprintengine_p.h"
#include "qppdprintdevice.h"
#include <private/qprinterinfo_p.h>
@@ -80,6 +78,7 @@ QStringList QCupsPrinterSupport::availablePrintDeviceIds() const
QStringList list;
cups_dest_t *dests;
int count = cupsGetDests(&dests);
+ list.reserve(count);
for (int i = 0; i < count; ++i) {
QString printerId = QString::fromLocal8Bit(dests[i].name);
if (dests[i].instance)
@@ -109,5 +108,3 @@ QString QCupsPrinterSupport::defaultPrintDeviceId() const
}
QT_END_NAMESPACE
-
-#endif // QT_NO_PRINTER
diff --git a/src/plugins/printsupport/cups/qcupsprintersupport_p.h b/src/plugins/printsupport/cups/qcupsprintersupport_p.h
index ea913deeaa..6dcaa4e893 100644
--- a/src/plugins/printsupport/cups/qcupsprintersupport_p.h
+++ b/src/plugins/printsupport/cups/qcupsprintersupport_p.h
@@ -48,8 +48,6 @@
#include <qpa/qplatformprintersupport.h>
-#ifndef QT_NO_PRINTER
-
#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
@@ -73,5 +71,4 @@ private:
QT_END_NAMESPACE
-#endif // QT_NO_PRINTER
#endif // QCUPSPRINTERSUPPORT_H
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index 808424b1ed..1b9ff98fca 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -42,8 +42,6 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_PRINTER
-
QPpdPrintDevice::QPpdPrintDevice()
: QPlatformPrintDevice(),
m_cupsDest(0),
@@ -269,6 +267,7 @@ void QPpdPrintDevice::loadInputSlots() const
if (m_ppd) {
ppd_option_t *inputSlots = ppdFindOption(m_ppd, "InputSlot");
if (inputSlots) {
+ m_inputSlots.reserve(inputSlots->num_choices);
for (int i = 0; i < inputSlots->num_choices; ++i)
m_inputSlots.append(QPrintUtils::ppdChoiceToInputSlot(inputSlots->choices[i]));
}
@@ -309,6 +308,7 @@ void QPpdPrintDevice::loadOutputBins() const
if (m_ppd) {
ppd_option_t *outputBins = ppdFindOption(m_ppd, "OutputBin");
if (outputBins) {
+ m_outputBins.reserve(outputBins->num_choices);
for (int i = 0; i < outputBins->num_choices; ++i)
m_outputBins.append(QPrintUtils::ppdChoiceToOutputBin(outputBins->choices[i]));
}
@@ -350,6 +350,7 @@ void QPpdPrintDevice::loadDuplexModes() const
if (m_ppd) {
ppd_option_t *duplexModes = ppdFindOption(m_ppd, "Duplex");
if (duplexModes) {
+ m_duplexModes.reserve(duplexModes->num_choices);
for (int i = 0; i < duplexModes->num_choices; ++i)
m_duplexModes.append(QPrintUtils::ppdChoiceToDuplexMode(duplexModes->choices[i].choice));
}
@@ -472,6 +473,4 @@ cups_ptype_e QPpdPrintDevice::printerTypeFlags() const
return static_cast<cups_ptype_e>(printerOption("printer-type").toUInt());
}
-#endif // QT_NO_PRINTER
-
QT_END_NAMESPACE
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.h b/src/plugins/printsupport/cups/qppdprintdevice.h
index 5ebcf39566..a28348eb60 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.h
+++ b/src/plugins/printsupport/cups/qppdprintdevice.h
@@ -47,7 +47,9 @@
#include <qpa/qplatformprintdevice.h>
-#ifndef QT_NO_PRINTER
+#include <QtCore/qbytearray.h>
+#include <QtCore/qhash.h>
+#include <QtCore/qmargins.h>
#include <cups/cups.h>
#include <cups/ppd.h>
@@ -107,5 +109,4 @@ private:
QT_END_NAMESPACE
-#endif // QT_NO_PRINTER
#endif // QPPDPRINTDEVICE_H
diff --git a/src/plugins/printsupport/printsupport.pro b/src/plugins/printsupport/printsupport.pro
index ed201f0744..bd6681f53c 100644
--- a/src/plugins/printsupport/printsupport.pro
+++ b/src/plugins/printsupport/printsupport.pro
@@ -2,4 +2,7 @@ TEMPLATE = subdirs
osx: SUBDIRS += cocoa
win32: SUBDIRS += windows
-unix:!mac:contains(QT_CONFIG, cups): SUBDIRS += cups
+unix:!mac:contains(QT_CONFIG, cups) {
+ load(qfeatures)
+ !contains(QT_DISABLED_FEATURES, cups): SUBDIRS += cups
+}
diff --git a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp
index 505f3138ca..d378ff3130 100644
--- a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp
+++ b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp
@@ -41,8 +41,6 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_PRINTER
-
QT_WARNING_DISABLE_GCC("-Wsign-compare")
extern qreal qt_pointMultiplier(QPageLayout::Unit unit);
@@ -471,6 +469,4 @@ QString QWindowsPrintDevice::defaultPrintDeviceId()
return QString::fromWCharArray(name.data());
}
-#endif // QT_NO_PRINTER
-
QT_END_NAMESPACE
diff --git a/src/plugins/printsupport/windows/qwindowsprintdevice.h b/src/plugins/printsupport/windows/qwindowsprintdevice.h
index 8ab487a59c..2c232d22c5 100644
--- a/src/plugins/printsupport/windows/qwindowsprintdevice.h
+++ b/src/plugins/printsupport/windows/qwindowsprintdevice.h
@@ -47,8 +47,6 @@
#include <qpa/qplatformprintdevice.h>
-#ifndef QT_NO_PRINTER
-
#include <QtCore/qt_windows.h>
QT_BEGIN_NAMESPACE
@@ -95,5 +93,4 @@ private:
QT_END_NAMESPACE
-#endif // QT_NO_PRINTER
#endif // QWINDOWSPRINTDEVICE_H
diff --git a/src/plugins/styles/bb10style/bright/button/core_button_inactive.png b/src/plugins/styles/bb10style/bright/button/core_button_inactive.png
index 7769f15e44..7769f15e44 100755..100644
--- a/src/plugins/styles/bb10style/bright/button/core_button_inactive.png
+++ b/src/plugins/styles/bb10style/bright/button/core_button_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/button/core_button_pressed.png b/src/plugins/styles/bb10style/bright/button/core_button_pressed.png
index 59b5bfa7c2..59b5bfa7c2 100755..100644
--- a/src/plugins/styles/bb10style/bright/button/core_button_pressed.png
+++ b/src/plugins/styles/bb10style/bright/button/core_button_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png
index f1c2ee3bed..f1c2ee3bed 100755..100644
--- a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png
+++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png
index 07b8ea21bf..07b8ea21bf 100755..100644
--- a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png
+++ b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png
index 55f8aee066..55f8aee066 100755..100644
--- a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png
+++ b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png b/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png
index 34daccc27e..34daccc27e 100755..100644
--- a/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png
+++ b/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png b/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png
index 7a1e22321d..7a1e22321d 100755..100644
--- a/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png
+++ b/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png
index 3ff930dea7..3ff930dea7 100755..100644
--- a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png
+++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png
index cb4c6a8136..cb4c6a8136 100755..100644
--- a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png
+++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png
index 88fd1344d2..88fd1344d2 100755..100644
--- a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png
+++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png b/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png
index 79154e0568..79154e0568 100755..100644
--- a/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png
+++ b/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png b/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png
index 8cb79118b9..8cb79118b9 100755..100644
--- a/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/button/core_button_inactive.png b/src/plugins/styles/bb10style/dark/button/core_button_inactive.png
index 97842e1ac4..97842e1ac4 100755..100644
--- a/src/plugins/styles/bb10style/dark/button/core_button_inactive.png
+++ b/src/plugins/styles/bb10style/dark/button/core_button_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/button/core_button_pressed.png b/src/plugins/styles/bb10style/dark/button/core_button_pressed.png
index c149b64a26..c149b64a26 100755..100644
--- a/src/plugins/styles/bb10style/dark/button/core_button_pressed.png
+++ b/src/plugins/styles/bb10style/dark/button/core_button_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png
index 507a77b3ea..507a77b3ea 100755..100644
--- a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png
+++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png
index 07b8ea21bf..07b8ea21bf 100755..100644
--- a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png
+++ b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png
index 9b115897e8..9b115897e8 100755..100644
--- a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png
+++ b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png b/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png
index 52aa4e4aa2..52aa4e4aa2 100755..100644
--- a/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png
+++ b/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png b/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png
index 39e3a8a4f5..39e3a8a4f5 100755..100644
--- a/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png
+++ b/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png
index 95fcafb437..95fcafb437 100755..100644
--- a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png
+++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png
index fd61937d65..fd61937d65 100755..100644
--- a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png
+++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png
index 58a1a57b4c..58a1a57b4c 100755..100644
--- a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png
+++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png b/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png
index 384f60758a..384f60758a 100755..100644
--- a/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png
+++ b/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png b/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png
index 803c374015..803c374015 100755..100644
--- a/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png
Binary files differ
diff --git a/src/printsupport/dialogs/qpagesetupdialog_mac.mm b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
index 886cbc0152..b86de31883 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_mac.mm
+++ b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
@@ -201,10 +201,9 @@ int QPageSetupDialog::exec()
QDialog::setVisible(true);
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
static_cast <QMacPageSetupDialogPrivate*>(d)->openCocoaPageLayout(Qt::ApplicationModal);
static_cast <QMacPageSetupDialogPrivate*>(d)->closeCocoaPageLayout();
- [pool release];
QDialog::setVisible(false);
diff --git a/src/printsupport/dialogs/qprintdialog_mac.mm b/src/printsupport/dialogs/qprintdialog_mac.mm
index aec1e3babb..030526954d 100644
--- a/src/printsupport/dialogs/qprintdialog_mac.mm
+++ b/src/printsupport/dialogs/qprintdialog_mac.mm
@@ -36,7 +36,6 @@
#include "qprintdialog.h"
#include "qabstractprintdialog_p.h"
-#include <QtCore/qhash.h>
#include <QtCore/private/qcore_mac_p.h>
#include <QtWidgets/private/qapplication_p.h>
#include <QtPrintSupport/qprinter.h>
@@ -302,10 +301,9 @@ int QPrintDialog::exec()
QDialog::setVisible(true);
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
d->openCocoaPrintPanel(Qt::ApplicationModal);
d->closeCocoaPrintPanel();
- [pool release];
QDialog::setVisible(false);
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp
index 8c67b416a9..2f0f1205ca 100644
--- a/src/printsupport/kernel/qcups.cpp
+++ b/src/printsupport/kernel/qcups.cpp
@@ -59,6 +59,16 @@ void QCUPSSupport::setCupsOption(QStringList &cupsOptions, const QString &option
}
}
+void QCUPSSupport::clearCupsOption(QStringList &cupsOptions, const QString &option)
+{
+ // ### use const_iterator once QList::erase takes them
+ const QStringList::iterator it = std::find(cupsOptions.begin(), cupsOptions.end(), option);
+ if (it != cupsOptions.end()) {
+ Q_ASSERT(it + 1 < cupsOptions.end());
+ cupsOptions.erase(it, it+1);
+ }
+}
+
static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, const QTime holdUntilTime)
{
switch (jobHold) {
@@ -94,14 +104,16 @@ static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold,
void QCUPSSupport::setJobHold(QPrinter *printer, const JobHoldUntil jobHold, const QTime &holdUntilTime)
{
+ QStringList cupsOptions = cupsOptionsList(printer);
const QString jobHoldUntilArgument = jobHoldToString(jobHold, holdUntilTime);
if (!jobHoldUntilArgument.isEmpty()) {
- QStringList cupsOptions = cupsOptionsList(printer);
setCupsOption(cupsOptions,
QStringLiteral("job-hold-until"),
jobHoldUntilArgument);
- setCupsOptions(printer, cupsOptions);
+ } else {
+ clearCupsOption(cupsOptions, QStringLiteral("job-hold-until"));
}
+ setCupsOptions(printer, cupsOptions);
}
void QCUPSSupport::setJobBilling(QPrinter *printer, const QString &jobBilling)
diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h
index afcb2c6f3b..82c2f5116a 100644
--- a/src/printsupport/kernel/qcups_p.h
+++ b/src/printsupport/kernel/qcups_p.h
@@ -117,6 +117,7 @@ public:
static QStringList cupsOptionsList(QPrinter *printer);
static void setCupsOptions(QPrinter *printer, const QStringList &cupsOptions);
static void setCupsOption(QStringList &cupsOptions, const QString &option, const QString &value);
+ static void clearCupsOption(QStringList &cupsOptions, const QString &option);
static void setJobHold(QPrinter *printer, const JobHoldUntil jobHold = NoHold, const QTime &holdUntilTime = QTime());
static void setJobBilling(QPrinter *printer, const QString &jobBilling = QString());
diff --git a/src/printsupport/kernel/qpaintengine_alpha.cpp b/src/printsupport/kernel/qpaintengine_alpha.cpp
index 010a628e4f..710691453a 100644
--- a/src/printsupport/kernel/qpaintengine_alpha.cpp
+++ b/src/printsupport/kernel/qpaintengine_alpha.cpp
@@ -178,7 +178,8 @@ void QAlphaPaintEngine::drawPolygon(const QPointF *points, int pointCount, Polyg
Q_D(QAlphaPaintEngine);
QPolygonF poly;
- for (int i=0; i<pointCount; ++i)
+ poly.reserve(pointCount);
+ for (int i = 0; i < pointCount; ++i)
poly.append(points[i]);
QPainterPath path;
diff --git a/src/printsupport/kernel/qplatformprintplugin.cpp b/src/printsupport/kernel/qplatformprintplugin.cpp
index 091cc6f008..9adf39ffcd 100644
--- a/src/printsupport/kernel/qplatformprintplugin.cpp
+++ b/src/printsupport/kernel/qplatformprintplugin.cpp
@@ -55,6 +55,7 @@ QPlatformPrinterSupportPlugin::~QPlatformPrinterSupportPlugin()
static QPlatformPrinterSupport *printerSupport = 0;
+#ifndef QT_NO_LIBRARY
static void cleanupPrinterSupport()
{
#ifndef QT_NO_PRINTER
@@ -62,6 +63,7 @@ static void cleanupPrinterSupport()
#endif
printerSupport = 0;
}
+#endif // !QT_NO_LIBRARY
/*!
\internal
@@ -73,6 +75,7 @@ static void cleanupPrinterSupport()
*/
QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get()
{
+#ifndef QT_NO_LIBRARY
if (!printerSupport) {
const QMultiMap<int, QString> keyMap = loader()->keyMap();
if (!keyMap.isEmpty())
@@ -80,6 +83,7 @@ QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get()
if (printerSupport)
qAddPostRoutine(cleanupPrinterSupport);
}
+#endif // !QT_NO_LIBRARY
return printerSupport;
}
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index a9dfcc8f09..4f8eaba85a 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -160,7 +160,7 @@ void QPrinterPrivate::changeEngines(QPrinter::OutputFormat format, const QPrinte
initEngines(format, printer);
if (oldPrintEngine) {
- foreach (QPrintEngine::PrintEnginePropertyKey key, m_properties.values()) {
+ foreach (QPrintEngine::PrintEnginePropertyKey key, m_properties) {
QVariant prop;
// PPK_NumberOfCopies need special treatmeant since it in most cases
// will return 1, disregarding the actual value that was set
@@ -1934,7 +1934,9 @@ QList<int> QPrinter::supportedResolutions() const
QList<QVariant> varlist
= d->printEngine->property(QPrintEngine::PPK_SupportedResolutions).toList();
QList<int> intlist;
- for (int i=0; i<varlist.size(); ++i)
+ const int numSupportedResolutions = varlist.size();
+ intlist.reserve(numSupportedResolutions);
+ for (int i = 0; i < numSupportedResolutions; ++i)
intlist << varlist.at(i).toInt();
return intlist;
}
diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp
index ad488a10ed..1be574891b 100644
--- a/src/printsupport/kernel/qprinterinfo.cpp
+++ b/src/printsupport/kernel/qprinterinfo.cpp
@@ -316,7 +316,9 @@ QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
{
Q_D(const QPrinterInfo);
QList<QPrinter::PaperSize> list;
- foreach (const QPageSize &pageSize, d->m_printDevice.supportedPageSizes())
+ const QList<QPageSize> supportedPageSizes = d->m_printDevice.supportedPageSizes();
+ list.reserve(supportedPageSizes.size());
+ foreach (const QPageSize &pageSize, supportedPageSizes)
list.append(QPrinter::PaperSize(pageSize.id()));
return list;
}
@@ -336,7 +338,9 @@ QList<QPair<QString, QSizeF> > QPrinterInfo::supportedSizesWithNames() const
{
Q_D(const QPrinterInfo);
QList<QPair<QString, QSizeF> > list;
- foreach (const QPageSize &pageSize, d->m_printDevice.supportedPageSizes())
+ const QList<QPageSize> supportedPageSizes = d->m_printDevice.supportedPageSizes();
+ list.reserve(supportedPageSizes.size());
+ foreach (const QPageSize &pageSize, supportedPageSizes)
list.append(qMakePair(pageSize.name(), pageSize.size(QPageSize::Millimeter)));
return list;
}
@@ -376,7 +380,9 @@ QList<QPrinter::DuplexMode> QPrinterInfo::supportedDuplexModes() const
{
Q_D(const QPrinterInfo);
QList<QPrinter::DuplexMode> list;
- foreach (QPrint::DuplexMode mode, d->m_printDevice.supportedDuplexModes())
+ const QList<QPrint::DuplexMode> supportedDuplexModes = d->m_printDevice.supportedDuplexModes();
+ list.reserve(supportedDuplexModes.size());
+ foreach (QPrint::DuplexMode mode, supportedDuplexModes)
list << QPrinter::DuplexMode(mode);
return list;
}
@@ -416,7 +422,9 @@ QList<QPrinterInfo> QPrinterInfo::availablePrinters()
QList<QPrinterInfo> list;
QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
if (ps) {
- foreach (const QString &id, ps->availablePrintDeviceIds())
+ const QStringList availablePrintDeviceIds = ps->availablePrintDeviceIds();
+ list.reserve(availablePrintDeviceIds.size());
+ foreach (const QString &id, availablePrintDeviceIds)
list.append(QPrinterInfo(id));
}
return list;
diff --git a/src/printsupport/widgets/qcupsjobwidget.cpp b/src/printsupport/widgets/qcupsjobwidget.cpp
index ce8b0d1ed3..43ec37e119 100644
--- a/src/printsupport/widgets/qcupsjobwidget.cpp
+++ b/src/printsupport/widgets/qcupsjobwidget.cpp
@@ -48,7 +48,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_PRINTER
+#if !defined(QT_NO_PRINTER) && !defined(QT_NO_CUPS)
/*!
\internal
@@ -206,6 +206,6 @@ QCUPSSupport::BannerPage QCupsJobWidget::endBannerPage() const
return m_ui.endBannerPageCombo->itemData(m_ui.endBannerPageCombo->currentIndex()).value<QCUPSSupport::BannerPage>();
}
-#endif // QT_NO_PRINTER
+#endif // QT_NO_PRINTER / QT_NO_CUPS
QT_END_NAMESPACE
diff --git a/src/printsupport/widgets/qcupsjobwidget_p.h b/src/printsupport/widgets/qcupsjobwidget_p.h
index dfd2016130..65fea24d2a 100644
--- a/src/printsupport/widgets/qcupsjobwidget_p.h
+++ b/src/printsupport/widgets/qcupsjobwidget_p.h
@@ -52,7 +52,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_PRINTER
+#if !defined(QT_NO_PRINTER) && !defined(QT_NO_CUPS)
class QString;
class QTime;
@@ -100,7 +100,7 @@ private:
Q_DISABLE_COPY(QCupsJobWidget)
};
-#endif // QT_NO_PRINTER
+#endif // QT_NO_PRINTER / QT_NO_CUPS
QT_END_NAMESPACE
diff --git a/src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase.cpp b/src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase.cpp
index c3b3b8e817..95422c9e7b 100644
--- a/src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase.cpp
+++ b/src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase.cpp
@@ -80,7 +80,7 @@ if (db.open()) {
//! [4]
...
// MySQL connection
-db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1"); // use an SSL connection to the server
+db.setConnectOptions("SSL_KEY=client-key.pem;SSL_CERT=client-cert.pem;SSL_CA=ca-cert.pem;CLIENT_IGNORE_SPACE=1"); // use an SSL connection to the server
if (!db.open()) {
db.setConnectOptions(); // clears the connect option string
...
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp
index d901008e00..086a232746 100644
--- a/src/sql/drivers/mysql/qsql_mysql.cpp
+++ b/src/sql/drivers/mysql/qsql_mysql.cpp
@@ -45,6 +45,7 @@
#include <qstringlist.h>
#include <qtextcodec.h>
#include <qvector.h>
+#include <qfile.h>
#include <qdebug.h>
@@ -1211,7 +1212,7 @@ static void setOptionFlag(uint &optionFlags, const QString &opt)
else if (opt == QLatin1String("CLIENT_ODBC"))
optionFlags |= CLIENT_ODBC;
else if (opt == QLatin1String("CLIENT_SSL"))
- optionFlags |= CLIENT_SSL;
+ qWarning("QMYSQLDriver: SSL_KEY, SSL_CERT and SSL_CA should be used instead of CLIENT_SSL.");
else
qWarning("QMYSQLDriver::open: Unknown connect option '%s'", opt.toLocal8Bit().constData());
}
@@ -1235,6 +1236,11 @@ bool QMYSQLDriver::open(const QString& db,
unsigned int optionFlags = Q_CLIENT_MULTI_STATEMENTS;
const QStringList opts(connOpts.split(QLatin1Char(';'), QString::SkipEmptyParts));
QString unixSocket;
+ QString sslCert;
+ QString sslCA;
+ QString sslKey;
+ QString sslCAPath;
+ QString sslCipher;
#if MYSQL_VERSION_ID >= 50000
my_bool reconnect=false;
uint connectTimeout = 0;
@@ -1263,6 +1269,16 @@ bool QMYSQLDriver::open(const QString& db,
writeTimeout = val.toInt();
}
#endif
+ else if (opt == QLatin1String("SSL_KEY"))
+ sslKey = val;
+ else if (opt == QLatin1String("SSL_CERT"))
+ sslCert = val;
+ else if (opt == QLatin1String("SSL_CA"))
+ sslCA = val;
+ else if (opt == QLatin1String("SSL_CAPATH"))
+ sslCAPath = val;
+ else if (opt == QLatin1String("SSL_CIPHER"))
+ sslCipher = val;
else if (val == QLatin1String("TRUE") || val == QLatin1String("1"))
setOptionFlag(optionFlags, tmp.left(idx).simplified());
else
@@ -1273,39 +1289,60 @@ bool QMYSQLDriver::open(const QString& db,
}
}
- if ((d->mysql = mysql_init((MYSQL*) 0))) {
+ if (!(d->mysql = mysql_init((MYSQL*) 0))) {
+ setLastError(qMakeError(tr("Unable to allocate a MYSQL object"),
+ QSqlError::ConnectionError, d));
+ setOpenError(true);
+ return false;
+ }
+
+ if (!sslKey.isNull() || !sslCert.isNull() || !sslCA.isNull() ||
+ !sslCAPath.isNull() || !sslCipher.isNull()) {
+ mysql_ssl_set(d->mysql,
+ sslKey.isNull() ? static_cast<const char *>(0)
+ : QFile::encodeName(sslKey).constData(),
+ sslCert.isNull() ? static_cast<const char *>(0)
+ : QFile::encodeName(sslCert).constData(),
+ sslCA.isNull() ? static_cast<const char *>(0)
+ : QFile::encodeName(sslCA).constData(),
+ sslCAPath.isNull() ? static_cast<const char *>(0)
+ : QFile::encodeName(sslCAPath).constData(),
+ sslCipher.isNull() ? static_cast<const char *>(0)
+ : sslCipher.toLocal8Bit().constData());
+ }
+
#if MYSQL_VERSION_ID >= 50000
- if (connectTimeout != 0)
- mysql_options(d->mysql, MYSQL_OPT_CONNECT_TIMEOUT, &connectTimeout);
- if (readTimeout != 0)
- mysql_options(d->mysql, MYSQL_OPT_READ_TIMEOUT, &readTimeout);
- if (writeTimeout != 0)
- mysql_options(d->mysql, MYSQL_OPT_WRITE_TIMEOUT, &writeTimeout);
+ if (connectTimeout != 0)
+ mysql_options(d->mysql, MYSQL_OPT_CONNECT_TIMEOUT, &connectTimeout);
+ if (readTimeout != 0)
+ mysql_options(d->mysql, MYSQL_OPT_READ_TIMEOUT, &readTimeout);
+ if (writeTimeout != 0)
+ mysql_options(d->mysql, MYSQL_OPT_WRITE_TIMEOUT, &writeTimeout);
#endif
- if (mysql_real_connect(d->mysql,
- host.isNull() ? static_cast<const char *>(0)
- : host.toLocal8Bit().constData(),
- user.isNull() ? static_cast<const char *>(0)
- : user.toLocal8Bit().constData(),
- password.isNull() ? static_cast<const char *>(0)
- : password.toLocal8Bit().constData(),
- db.isNull() ? static_cast<const char *>(0)
- : db.toLocal8Bit().constData(),
- (port > -1) ? port : 0,
- unixSocket.isNull() ? static_cast<const char *>(0)
- : unixSocket.toLocal8Bit().constData(),
- optionFlags)) {
- if (!db.isEmpty() && mysql_select_db(d->mysql, db.toLocal8Bit().constData())) {
- setLastError(qMakeError(tr("Unable to open database '%1'").arg(db), QSqlError::ConnectionError, d));
- mysql_close(d->mysql);
- setOpenError(true);
- return false;
- }
+ if (mysql_real_connect(d->mysql,
+ host.isNull() ? static_cast<const char *>(0)
+ : host.toLocal8Bit().constData(),
+ user.isNull() ? static_cast<const char *>(0)
+ : user.toLocal8Bit().constData(),
+ password.isNull() ? static_cast<const char *>(0)
+ : password.toLocal8Bit().constData(),
+ db.isNull() ? static_cast<const char *>(0)
+ : db.toLocal8Bit().constData(),
+ (port > -1) ? port : 0,
+ unixSocket.isNull() ? static_cast<const char *>(0)
+ : unixSocket.toLocal8Bit().constData(),
+ optionFlags))
+ {
+ if (!db.isEmpty() && mysql_select_db(d->mysql, db.toLocal8Bit().constData())) {
+ setLastError(qMakeError(tr("Unable to open database '%1'").arg(db), QSqlError::ConnectionError, d));
+ mysql_close(d->mysql);
+ setOpenError(true);
+ return false;
+ }
#if MYSQL_VERSION_ID >= 50000
- if (reconnect)
- mysql_options(d->mysql, MYSQL_OPT_RECONNECT, &reconnect);
+ if (reconnect)
+ mysql_options(d->mysql, MYSQL_OPT_RECONNECT, &reconnect);
#endif
- }
} else {
setLastError(qMakeError(tr("Unable to connect"),
QSqlError::ConnectionError, d));
diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp
index 240e19bf20..90c64d7331 100644
--- a/src/sql/kernel/qsqldatabase.cpp
+++ b/src/sql/kernel/qsqldatabase.cpp
@@ -1218,7 +1218,6 @@ QSqlRecord QSqlDatabase::record(const QString& tablename) const
\li CLIENT_COMPRESS
\li CLIENT_FOUND_ROWS
\li CLIENT_IGNORE_SPACE
- \li CLIENT_SSL
\li CLIENT_ODBC
\li CLIENT_NO_SCHEMA
\li CLIENT_INTERACTIVE
@@ -1227,6 +1226,11 @@ QSqlRecord QSqlDatabase::record(const QString& tablename) const
\li MYSQL_OPT_CONNECT_TIMEOUT
\li MYSQL_OPT_READ_TIMEOUT
\li MYSQL_OPT_WRITE_TIMEOUT
+ \li SSL_KEY
+ \li SSL_CERT
+ \li SSL_CA
+ \li SSL_CAPATH
+ \li SSL_CIPHER
\endlist
\li
diff --git a/src/sql/kernel/qsqlindex.cpp b/src/sql/kernel/qsqlindex.cpp
index 53e13c85e6..bb80cf3e03 100644
--- a/src/sql/kernel/qsqlindex.cpp
+++ b/src/sql/kernel/qsqlindex.cpp
@@ -38,6 +38,9 @@
QT_BEGIN_NAMESPACE
+// ### Qt 6: remove the static assertion, the 'sorts' field was changed from QList to QVector in Qt 5.6
+Q_STATIC_ASSERT((sizeof(QList<bool>) == sizeof(QVector<bool>)));
+
/*!
\class QSqlIndex
\brief The QSqlIndex class provides functions to manipulate and
diff --git a/src/sql/kernel/qsqlindex.h b/src/sql/kernel/qsqlindex.h
index d3d4a7c9aa..4a81d48161 100644
--- a/src/sql/kernel/qsqlindex.h
+++ b/src/sql/kernel/qsqlindex.h
@@ -36,7 +36,10 @@
#include <QtSql/qsqlrecord.h>
#include <QtCore/qstring.h>
+#include <QtCore/qvector.h>
+#if QT_DEPRECATED_SINCE(5,6)
#include <QtCore/qlist.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -63,7 +66,7 @@ private:
QString createField(int i, const QString& prefix, bool verbose) const;
QString cursor;
QString nm;
- QList<bool> sorts;
+ QVector<bool> sorts;
};
QT_END_NAMESPACE
diff --git a/src/src.pro b/src/src.pro
index 61e5ce2d8d..07ace99144 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -110,7 +110,7 @@ src_platformsupport.depends = src_corelib src_gui src_platformheaders
src_widgets.subdir = $$PWD/widgets
src_widgets.target = sub-widgets
-src_widgets.depends = src_corelib src_gui src_tools_uic
+src_widgets.depends = src_corelib src_gui src_tools_uic src_platformheaders
src_opengl.subdir = $$PWD/opengl
src_opengl.target = sub-opengl
diff --git a/src/testlib/qbenchmark_p.h b/src/testlib/qbenchmark_p.h
index d785f3d4b7..6312a34cb8 100644
--- a/src/testlib/qbenchmark_p.h
+++ b/src/testlib/qbenchmark_p.h
@@ -91,6 +91,7 @@ struct QBenchmarkContext
QBenchmarkContext() : checkpointIndex(-1) {}
};
+Q_DECLARE_TYPEINFO(QBenchmarkContext, Q_MOVABLE_TYPE);
class QBenchmarkResult
{
@@ -126,6 +127,7 @@ public:
return (value / iterations) < (other.value / other.iterations);
}
};
+Q_DECLARE_TYPEINFO(QBenchmarkResult, Q_MOVABLE_TYPE);
/*
The QBenchmarkGlobalData class stores global benchmark-related data.
diff --git a/src/testlib/qtestblacklist.cpp b/src/testlib/qtestblacklist.cpp
index 28a2878b32..eb7abdad46 100644
--- a/src/testlib/qtestblacklist.cpp
+++ b/src/testlib/qtestblacklist.cpp
@@ -37,6 +37,9 @@
#include <QtTest/qtest.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qfile.h>
+#include <QtCore/qset.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qvariant.h>
#include <QtCore/QSysInfo>
#include <set>
@@ -61,83 +64,87 @@ QT_BEGIN_NAMESPACE
The known keys are listed below:
*/
-// this table can be extended with new keywords as required
-const char *matchedConditions[] =
+static QSet<QByteArray> keywords()
{
- "*",
+ // this list can be extended with new keywords as required
+ QSet<QByteArray> set = QSet<QByteArray>()
+ << "*"
#ifdef Q_OS_LINUX
- "linux",
+ << "linux"
#endif
#ifdef Q_OS_OSX
- "osx",
+ << "osx"
#endif
#ifdef Q_OS_WIN
- "windows",
+ << "windows"
#endif
#ifdef Q_OS_IOS
- "ios",
+ << "ios"
#endif
#ifdef Q_OS_ANDROID
- "android",
+ << "android"
#endif
#ifdef Q_OS_QNX
- "qnx",
+ << "qnx"
#endif
#ifdef Q_OS_WINRT
- "winrt",
+ << "winrt"
#endif
#ifdef Q_OS_WINCE
- "wince",
+ << "wince"
#endif
#if QT_POINTER_SIZE == 8
- "64bit",
+ << "64bit"
#else
- "32bit",
+ << "32bit"
#endif
#ifdef Q_CC_GNU
- "gcc",
+ << "gcc"
#endif
#ifdef Q_CC_CLANG
- "clang",
+ << "clang"
#endif
#ifdef Q_CC_MSVC
- "msvc",
+ << "msvc"
#ifdef _MSC_VER
#if _MSC_VER == 1800
- "msvc-2013",
+ << "msvc-2013"
#elif _MSC_VER == 1700
- "msvc-2012",
+ << "msvc-2012"
#elif _MSC_VER == 1600
- "msvc-2010",
+ << "msvc-2010"
#endif
#endif
#endif
#ifdef Q_AUTOTEST_EXPORT
- "developer-build",
+ << "developer-build"
#endif
- 0
-};
+ ;
+ QCoreApplication *app = QCoreApplication::instance();
+ if (app) {
+ const QVariant platformName = app->property("platformName");
+ if (platformName.isValid())
+ set << platformName.toByteArray();
+ }
+
+ return set;
+}
static bool checkCondition(const QByteArray &condition)
{
+ static QSet<QByteArray> matchedConditions = keywords();
QList<QByteArray> conds = condition.split(' ');
- std::set<QByteArray> matches;
- const char **m = matchedConditions;
- while (*m) {
- matches.insert(*m);
- ++m;
- }
QByteArray distributionName = QSysInfo::productType().toLower().toUtf8();
QByteArray distributionRelease = QSysInfo::productVersion().toLower().toUtf8();
if (!distributionName.isEmpty()) {
- if (matches.find(distributionName) == matches.end())
- matches.insert(distributionName);
- matches.insert(distributionName + "-" + distributionRelease);
+ if (matchedConditions.find(distributionName) == matchedConditions.end())
+ matchedConditions.insert(distributionName);
+ matchedConditions.insert(distributionName + "-" + distributionRelease);
}
for (int i = 0; i < conds.size(); ++i) {
@@ -146,7 +153,7 @@ static bool checkCondition(const QByteArray &condition)
if (result)
c = c.mid(1);
- result ^= (matches.find(c) != matches.end());
+ result ^= matchedConditions.contains(c);
if (!result)
return false;
}
@@ -159,6 +166,19 @@ 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 += QByteArrayLiteral(":") + QByteArray(data);
+ QTest::qSkip(msg.constData(), __FILE__, __LINE__);
+ return true;
+ }
+ return false;
+}
+
namespace QTestPrivate {
void parseBlackList()
@@ -223,10 +243,12 @@ void checkBlackLists(const char *slot, const char *data)
// 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) {
- const QByteArray disableKey = QByteArrayLiteral("disable_") + QByteArray(slot);
- if (gpuFeatures->find(disableKey) != gpuFeatures->end()) {
- const QByteArray msg = QByteArrayLiteral("Skipped due to GPU blacklist: ") + disableKey;
- QTest::qSkip(msg.constData(), __FILE__, __LINE__);
+ QByteArray s_gpu = slot;
+ ignore = isGPUTestBlacklisted(s_gpu, data);
+ if (!ignore && data) {
+ s_gpu += ':';
+ s_gpu += data;
+ isGPUTestBlacklisted(s_gpu);
}
}
}
diff --git a/src/testlib/qtestblacklist_p.h b/src/testlib/qtestblacklist_p.h
index 0107e5d282..87f4dfdb5e 100644
--- a/src/testlib/qtestblacklist_p.h
+++ b/src/testlib/qtestblacklist_p.h
@@ -50,9 +50,10 @@
QT_BEGIN_NAMESPACE
namespace QTestPrivate {
- void parseBlackList();
- void parseGpuBlackList();
- void checkBlackLists(const char *slot, const char *data);
+ // 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);
}
QT_END_NAMESPACE
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index efc18180db..4790f6f456 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -50,6 +50,9 @@
#include <QtCore/private/qtools_p.h>
#include <QtCore/qdiriterator.h>
#include <QtCore/qtemporarydir.h>
+#include <QtCore/qthread.h>
+#include <QtCore/qwaitcondition.h>
+#include <QtCore/qmutex.h>
#include <QtTest/private/qtestlog_p.h>
#include <QtTest/private/qtesttable_p.h>
@@ -70,6 +73,11 @@
#include <stdio.h>
#include <stdlib.h>
+#if defined(Q_OS_LINUX)
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
#ifdef Q_OS_WIN
#ifndef Q_OS_WINCE
# if !defined(Q_CC_MINGW) || (defined(Q_CC_MINGW) && defined(__MINGW64_VERSION_MAJOR))
@@ -93,6 +101,40 @@ QT_BEGIN_NAMESPACE
using QtMiscUtils::toHexUpper;
using QtMiscUtils::fromHex;
+
+static void stackTrace()
+{
+ bool ok = false;
+ const int disableStackDump = qEnvironmentVariableIntValue("QTEST_DISABLE_STACK_DUMP", &ok);
+ if (ok && disableStackDump == 1)
+ return;
+#ifdef Q_OS_LINUX
+ fprintf(stderr, "\n========= Received signal, dumping stack ==============\n");
+ char cmd[512];
+ qsnprintf(cmd, 512, "gdb --pid %d 2>/dev/null <<EOF\n"
+ "set prompt\n"
+ "thread apply all where full\n"
+ "detach\n"
+ "quit\n"
+ "EOF\n",
+ (int)getpid());
+ if (system(cmd) == -1)
+ fprintf(stderr, "calling gdb failed\n");
+ fprintf(stderr, "========= End of stack trace ==============\n");
+#elif defined(Q_OS_OSX)
+ fprintf(stderr, "\n========= Received signal, dumping stack ==============\n");
+ char cmd[512];
+ qsnprintf(cmd, 512, "lldb -p %d 2>/dev/null <<EOF\n"
+ "bt all\n"
+ "quit\n"
+ "EOF\n",
+ (int)getpid());
+ if (system(cmd) == -1)
+ fprintf(stderr, "calling lldb failed\n");
+ fprintf(stderr, "========= End of stack trace ==============\n");
+#endif
+}
+
/*!
\namespace QTest
\inmodule QtTest
@@ -1883,7 +1925,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
QTestLog::addLogger(logFormat, logFilename);
}
-QBenchmarkResult qMedian(const QList<QBenchmarkResult> &container)
+QBenchmarkResult qMedian(const QVector<QBenchmarkResult> &container)
{
const int count = container.count();
if (count == 0)
@@ -1892,7 +1934,7 @@ QBenchmarkResult qMedian(const QList<QBenchmarkResult> &container)
if (count == 1)
return container.front();
- QList<QBenchmarkResult> containerCopy = container;
+ QVector<QBenchmarkResult> containerCopy = container;
std::sort(containerCopy.begin(), containerCopy.end());
const int middle = count / 2;
@@ -1929,7 +1971,7 @@ static void qInvokeTestMethodDataEntry(char *slot)
bool isBenchmark = false;
int i = (QBenchmarkGlobalData::current->measurer->needsWarmupIteration()) ? -1 : 0;
- QList<QBenchmarkResult> results;
+ QVector<QBenchmarkResult> results;
bool minimumTotalReached = false;
do {
QBenchmarkTestMethodData::current->beginDataRun();
@@ -2011,6 +2053,58 @@ static void qInvokeTestMethodDataEntry(char *slot)
}
}
+class WatchDog : public QThread
+{
+public:
+ WatchDog()
+ {
+ QMutexLocker locker(&mutex);
+ timeout.store(-1);
+ start();
+ waitCondition.wait(&mutex);
+ }
+ ~WatchDog() {
+ {
+ QMutexLocker locker(&mutex);
+ timeout.store(0);
+ waitCondition.wakeAll();
+ }
+ wait();
+ }
+
+ void beginTest() {
+ QMutexLocker locker(&mutex);
+ timeout.store(5*60*1000);
+ waitCondition.wakeAll();
+ }
+
+ void testFinished() {
+ QMutexLocker locker(&mutex);
+ timeout.store(-1);
+ waitCondition.wakeAll();
+ }
+
+ void run() {
+ QMutexLocker locker(&mutex);
+ waitCondition.wakeAll();
+ while (1) {
+ int t = timeout.load();
+ if (!t)
+ break;
+ if (!waitCondition.wait(&mutex, t)) {
+ stackTrace();
+ qFatal("Test function timed out");
+ }
+ }
+ }
+
+private:
+ QBasicAtomicInt timeout;
+ QMutex mutex;
+ QWaitCondition waitCondition;
+};
+
+
/*!
\internal
@@ -2020,7 +2114,7 @@ static void qInvokeTestMethodDataEntry(char *slot)
If the function was successfully called, true is returned, otherwise
false.
*/
-static bool qInvokeTestMethod(const char *slotName, const char *data=0)
+static bool qInvokeTestMethod(const char *slotName, const char *data, WatchDog *watchDog)
{
QTEST_ASSERT(slotName);
@@ -2079,7 +2173,9 @@ static bool qInvokeTestMethod(const char *slotName, const char *data=0)
QTestDataSetter s(curDataIndex >= dataCount ? static_cast<QTestData *>(0)
: table.testData(curDataIndex));
+ watchDog->beginTest();
qInvokeTestMethodDataEntry(slot);
+ watchDog->testFinished();
if (data)
break;
@@ -2360,6 +2456,8 @@ static void qInvokeTestMethods(QObject *testObject)
QTestTable::globalTestTable();
invokeMethod(testObject, "initTestCase_data()");
+ WatchDog watchDog;
+
if (!QTestResult::skipCurrentTest() && !QTest::currentTestFailed()) {
invokeMethod(testObject, "initTestCase()");
@@ -2374,7 +2472,7 @@ static void qInvokeTestMethods(QObject *testObject)
if (QTest::testFuncs) {
for (int i = 0; i != QTest::testFuncCount; i++) {
if (!qInvokeTestMethod(metaObject->method(QTest::testFuncs[i].function()).methodSignature().constData(),
- QTest::testFuncs[i].data())) {
+ QTest::testFuncs[i].data(), &watchDog)) {
break;
}
}
@@ -2387,7 +2485,7 @@ static void qInvokeTestMethods(QObject *testObject)
for (int i = 0; i != methodCount; i++) {
if (!isValidSlot(testMethods[i]))
continue;
- if (!qInvokeTestMethod(testMethods[i].methodSignature().constData()))
+ if (!qInvokeTestMethod(testMethods[i].methodSignature().constData(), 0, &watchDog))
break;
}
delete[] testMethods;
@@ -2423,6 +2521,8 @@ private:
void FatalSignalHandler::signal(int signum)
{
+ if (signum != SIGINT)
+ stackTrace();
qFatal("Received signal %d", signum);
#if defined(Q_OS_INTEGRITY)
{
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index f24283b65e..9f1a65b7d3 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -39,6 +39,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qmetatype.h>
+#include <QtCore/qmetaobject.h>
#include <QtCore/qtypetraits.h>
#include <QtCore/qsharedpointer.h>
#include <QtCore/qtemporarydir.h>
@@ -222,12 +223,28 @@ class QTestData;
namespace QTest
{
- template <typename T>
- inline char *toString(const T &)
+ namespace Internal {
+
+ template<typename T> // Output registered enums
+ inline typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, char*>::Type toString(T e)
+ {
+ QMetaEnum me = QMetaEnum::fromType<T>();
+ return qstrdup(me.key(e));
+ }
+
+ template <typename T> // Fallback
+ inline typename QtPrivate::QEnableIf<!QtPrivate::IsQEnumHelper<T>::Value, char*>::Type toString(const T &)
{
return 0;
}
+ } // namespace Internal
+
+ template<typename T>
+ inline char *toString(const T &t)
+ {
+ return Internal::toString(t);
+ }
Q_TESTLIB_EXPORT char *toHexRepresentation(const char *ba, int length);
Q_TESTLIB_EXPORT char *toPrettyCString(const char *unicode, int length);
diff --git a/src/plugins/platforms/xcb/qxlibconvenience.h b/src/testlib/qtestmouse.cpp
index 0e6e1c37ec..99a75744fa 100644
--- a/src/plugins/platforms/xcb/qxlibconvenience.h
+++ b/src/testlib/qtestmouse.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtTest module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
@@ -31,19 +31,17 @@
**
****************************************************************************/
-#ifndef XLIBUTILS_H
-#define XLIBUTILS_H
+#include <QtCore/QtGlobal>
+#include <QtCore/qnamespace.h>
+#include <QtTest/qtest_global.h>
-#ifdef XCB_USE_XLIB
+QT_BEGIN_NAMESPACE
-#include <xcb/xcb_keysyms.h>
-#include <QByteArray>
+namespace QTest {
-QT_BEGIN_NAMESPACE
+Q_TESTLIB_EXPORT Qt::MouseButton lastMouseButton = Qt::NoButton;
+Q_TESTLIB_EXPORT int lastMouseTimestamp = 0;
-xcb_keysym_t q_XLookupString(void *display, xcb_window_t window, xcb_window_t root, uint state, xcb_keycode_t code, int type, QByteArray *chars);
+} // namespace QTest
QT_END_NAMESPACE
-
-#endif // XCB_USE_XLIB
-#endif
diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h
index ad6671af02..cd3901ae6f 100644
--- a/src/testlib/qtestmouse.h
+++ b/src/testlib/qtestmouse.h
@@ -45,6 +45,7 @@
#include <QtTest/qtestspontaneevent.h>
#include <QtCore/qpoint.h>
#include <QtCore/qstring.h>
+#include <QtCore/qpointer.h>
#include <QtGui/qevent.h>
#include <QtGui/qwindow.h>
@@ -57,12 +58,15 @@
QT_BEGIN_NAMESPACE
-Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier);
+Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods, int timestamp);
namespace QTest
{
enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDClick, MouseMove };
+ extern Q_TESTLIB_EXPORT Qt::MouseButton lastMouseButton;
+ extern Q_TESTLIB_EXPORT int lastMouseTimestamp;
+
static void waitForEvents()
{
#ifdef Q_OS_MAC
@@ -83,52 +87,48 @@ namespace QTest
QTest::qWarn("Mouse event occurs outside of target window.");
}
- static Qt::MouseButton lastButton = Qt::NoButton;
-
if (delay == -1 || delay < defaultMouseDelay())
delay = defaultMouseDelay();
- if (delay > 0)
+ if (delay > 0) {
QTest::qWait(delay);
+ lastMouseTimestamp += delay;
+ }
if (pos.isNull())
pos = window->geometry().center();
- if (action == MouseClick) {
- mouseEvent(MousePress, window, button, stateKey, pos);
- mouseEvent(MouseRelease, window, button, stateKey, pos);
- return;
- }
QTEST_ASSERT(uint(stateKey) == 0 || stateKey & Qt::KeyboardModifierMask);
stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);
+ QPointF global = window->mapToGlobal(pos);
+ QPointer<QWindow> w(window);
switch (action)
{
- case MousePress:
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),button,stateKey);
- lastButton = button;
- break;
- case MouseRelease:
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),Qt::NoButton,stateKey);
- lastButton = Qt::NoButton;
- break;
- case MouseDClick:
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),button,stateKey);
- qWait(10);
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),Qt::NoButton,stateKey);
- qWait(20);
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),button,stateKey);
- qWait(10);
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),Qt::NoButton,stateKey);
- break;
- case MouseMove:
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),lastButton,stateKey);
- // No QCursor::setPos() call here. That could potentially result in mouse events sent by the windowing system
- // which is highly undesired here. Tests must avoid relying on QCursor.
+ case MouseDClick:
+ qt_handleMouseEvent(w, pos, global, button, stateKey, ++lastMouseTimestamp);
+ qt_handleMouseEvent(w, pos, global, Qt::NoButton, stateKey, ++lastMouseTimestamp);
+ // fall through
+ case MousePress:
+ case MouseClick:
+ qt_handleMouseEvent(w, pos, global, button, stateKey, ++lastMouseTimestamp);
+ lastMouseButton = button;
+ if (action == MousePress)
break;
- default:
- QTEST_ASSERT(false);
+ // fall through
+ case MouseRelease:
+ qt_handleMouseEvent(w, pos, global, Qt::NoButton, stateKey, ++lastMouseTimestamp);
+ lastMouseTimestamp += 500; // avoid double clicks being generated
+ lastMouseButton = Qt::NoButton;
+ break;
+ case MouseMove:
+ qt_handleMouseEvent(w, pos, global, lastMouseButton, stateKey, ++lastMouseTimestamp);
+ // No QCursor::setPos() call here. That could potentially result in mouse events sent by the windowing system
+ // which is highly undesired here. Tests must avoid relying on QCursor.
+ break;
+ default:
+ QTEST_ASSERT(false);
}
waitForEvents();
}
@@ -153,6 +153,15 @@ namespace QTest
Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
{
QTEST_ASSERT(widget);
+
+ if (pos.isNull())
+ pos = widget->rect().center();
+
+#ifdef QTEST_QPA_MOUSE_HANDLING
+ QWindow *w = widget->window()->windowHandle();
+ QTEST_ASSERT(w);
+ mouseEvent(action, w, button, stateKey, w->mapFromGlobal(widget->mapToGlobal(pos)), delay);
+#else
extern int Q_TESTLIB_EXPORT defaultMouseDelay();
if (delay == -1 || delay < defaultMouseDelay())
@@ -160,9 +169,6 @@ namespace QTest
if (delay > 0)
QTest::qWait(delay);
- if (pos.isNull())
- pos = widget->rect().center();
-
if (action == MouseClick) {
mouseEvent(MousePress, widget, button, stateKey, pos);
mouseEvent(MouseRelease, widget, button, stateKey, pos);
@@ -203,7 +209,7 @@ namespace QTest
QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving widget");
QTest::qWarn(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toLatin1().data());
}
-
+#endif
}
inline void mousePress(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro
index 52bcdd097b..2d9bae5f31 100644
--- a/src/testlib/testlib.pro
+++ b/src/testlib/testlib.pro
@@ -56,6 +56,7 @@ SOURCES = qtestcase.cpp \
qcsvbenchmarklogger.cpp \
qtestelement.cpp \
qtestelementattribute.cpp \
+ qtestmouse.cpp \
qtestxunitstreamer.cpp \
qxunittestlogger.cpp \
qtestblacklist.cpp
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
index a92e5b8f3d..be6bcadacb 100644
--- a/src/tools/bootstrap/bootstrap.pro
+++ b/src/tools/bootstrap/bootstrap.pro
@@ -97,6 +97,7 @@ SOURCES += \
../../corelib/tools/qlocale_tools.cpp \
../../corelib/tools/qmap.cpp \
../../corelib/tools/qregexp.cpp \
+ ../../corelib/tools/qringbuffer.cpp \
../../corelib/tools/qpoint.cpp \
../../corelib/tools/qrect.cpp \
../../corelib/tools/qsize.cpp \
diff --git a/src/tools/qdoc/atom.cpp b/src/tools/qdoc/atom.cpp
index 745da21b30..f50f401c5b 100644
--- a/src/tools/qdoc/atom.cpp
+++ b/src/tools/qdoc/atom.cpp
@@ -64,10 +64,8 @@ QT_BEGIN_NAMESPACE
\also Text
*/
-/*! \enum Atom::Type
+/*! \enum Atom::AtomType
- \value AbstractLeft
- \value AbstractRight
\value AnnotatedList
\value AutoLink
\value BaseName
@@ -149,8 +147,6 @@ static const struct {
const char *english;
int no;
} atms[] = {
- { "AbstractLeft", Atom::AbstractLeft },
- { "AbstractRight", Atom::AbstractRight },
{ "AnnotatedList", Atom::AnnotatedList },
{ "AutoLink", Atom::AutoLink },
{ "BaseName", Atom::BaseName },
@@ -237,27 +233,27 @@ static const struct {
{ 0, 0 }
};
-/*! \fn Atom::Atom(Type type, const QString& string)
+/*! \fn Atom::Atom(AtomType type, const QString& string)
Constructs an atom of the specified \a type with the single
parameter \a string and does not put the new atom in a list.
*/
-/*! \fn Atom::Atom(Type type, const QString& p1, const QString& p2)
+/*! \fn Atom::Atom(AtomType type, const QString& p1, const QString& p2)
Constructs an atom of the specified \a type with the two
parameters \a p1 and \a p2 and does not put the new atom
in a list.
*/
-/*! \fn Atom(Atom *previous, Type type, const QString& string)
+/*! \fn Atom(Atom *previous, AtomType type, const QString& string)
Constructs an atom of the specified \a type with the single
parameter \a string and inserts the new atom into the list
after the \a previous atom.
*/
-/*! \fn Atom::Atom(Atom* previous, Type type, const QString& p1, const QString& p2)
+/*! \fn Atom::Atom(Atom* previous, AtomType type, const QString& p1, const QString& p2)
Constructs an atom of the specified \a type with the two
parameters \a p1 and \a p2 and inserts the new atom into
@@ -289,19 +285,19 @@ static const struct {
*/
/*!
- Return the next Atom in the list if it is of Type \a t.
+ Return the next Atom in the list if it is of AtomType \a t.
Otherwise return 0.
*/
-const Atom* Atom::next(Type t) const
+const Atom* Atom::next(AtomType t) const
{
return (next_ && (next_->type() == t)) ? next_ : 0;
}
/*!
- Return the next Atom in the list if it is of Type \a t
+ Return the next Atom in the list if it is of AtomType \a t
and its string part is \a s. Otherwise return 0.
*/
-const Atom* Atom::next(Type t, const QString& s) const
+const Atom* Atom::next(AtomType t, const QString& s) const
{
return (next_ && (next_->type() == t) && (next_->string() == s)) ? next_ : 0;
}
@@ -311,7 +307,7 @@ const Atom* Atom::next(Type t, const QString& s) const
\also type(), string()
*/
-/*! \fn Type Atom::type() const
+/*! \fn AtomType Atom::type() const
Return the type of this atom.
\also string(), next()
*/
diff --git a/src/tools/qdoc/atom.h b/src/tools/qdoc/atom.h
index ebbba8917e..86b8ba7b3c 100644
--- a/src/tools/qdoc/atom.h
+++ b/src/tools/qdoc/atom.h
@@ -46,9 +46,7 @@ class LinkAtom;
class Atom
{
public:
- enum Type {
- AbstractLeft,
- AbstractRight,
+ enum AtomType {
AnnotatedList,
AutoLink,
BaseName,
@@ -143,13 +141,13 @@ public:
strs << string;
}
- Atom(Type type, const QString& string = "")
+ Atom(AtomType type, const QString& string = "")
: next_(0), type_(type)
{
strs << string;
}
- Atom(Type type, const QString& p1, const QString& p2)
+ Atom(AtomType type, const QString& p1, const QString& p2)
: next_(0), type_(type)
{
strs << p1;
@@ -157,14 +155,14 @@ public:
strs << p2;
}
- Atom(Atom* previous, Type type, const QString& string = "")
+ Atom(Atom* previous, AtomType type, const QString& string = "")
: next_(previous->next_), type_(type)
{
strs << string;
previous->next_ = this;
}
- Atom(Atom* previous, Type type, const QString& p1, const QString& p2)
+ Atom(Atom* previous, AtomType type, const QString& p1, const QString& p2)
: next_(previous->next_), type_(type)
{
strs << p1;
@@ -183,9 +181,9 @@ public:
void setNext(Atom* newNext) { next_ = newNext; }
const Atom* next() const { return next_; }
- const Atom* next(Type t) const;
- const Atom* next(Type t, const QString& s) const;
- Type type() const { return type_; }
+ const Atom* next(AtomType t) const;
+ const Atom* next(AtomType t, const QString& s) const;
+ AtomType type() const { return type_; }
QString typeString() const;
const QString& string() const { return strs[0]; }
const QString& string(int i) const { return strs[i]; }
@@ -197,14 +195,14 @@ public:
virtual Node::Genus genus() { return Node::DontCare; }
virtual bool specifiesDomain() { return false; }
virtual Tree* domain() { return 0; }
- virtual Node::Type goal() { return Node::NoType; }
+ virtual Node::NodeType goal() { return Node::NoType; }
virtual const QString& error() { return noError_; }
virtual void resolveSquareBracketParams() { }
protected:
static QString noError_;
Atom* next_;
- Type type_;
+ AtomType type_;
QStringList strs;
};
@@ -220,14 +218,14 @@ class LinkAtom : public Atom
virtual Node::Genus genus() Q_DECL_OVERRIDE { resolveSquareBracketParams(); return genus_; }
virtual bool specifiesDomain() Q_DECL_OVERRIDE { resolveSquareBracketParams(); return (domain_ != 0); }
virtual Tree* domain() Q_DECL_OVERRIDE { resolveSquareBracketParams(); return domain_; }
- virtual Node::Type goal() Q_DECL_OVERRIDE { resolveSquareBracketParams(); return goal_; }
+ virtual Node::NodeType goal() Q_DECL_OVERRIDE { resolveSquareBracketParams(); return goal_; }
virtual const QString& error() Q_DECL_OVERRIDE { return error_; }
virtual void resolveSquareBracketParams() Q_DECL_OVERRIDE;
protected:
bool resolved_;
Node::Genus genus_;
- Node::Type goal_;
+ Node::NodeType goal_;
Tree* domain_;
QString error_;
QString squareBracketParams_;
diff --git a/src/tools/qdoc/codemarker.cpp b/src/tools/qdoc/codemarker.cpp
index 2253aca183..56fd3505be 100644
--- a/src/tools/qdoc/codemarker.cpp
+++ b/src/tools/qdoc/codemarker.cpp
@@ -361,8 +361,7 @@ QString CodeMarker::sortName(const Node *node, const QString* name)
else
sortNo = QLatin1String("E");
}
- return sortNo + nodeName + QLatin1Char(' ')
- + QString::number(func->overloadNumber(), 36);
+ return sortNo + nodeName + QLatin1Char(' ') + QString::number(func->overloadNumber(), 36);
}
if (node->type() == Node::Class)
@@ -390,7 +389,7 @@ void CodeMarker::insert(FastSection &fastSection,
bool irrelevant = false;
bool inheritedMember = false;
if (!node->relates()) {
- InnerNode* p = node->parent();
+ Aggregate* p = node->parent();
if (p->isQmlPropertyGroup())
p = p->parent();
if (p != fastSection.parent_) {
@@ -440,7 +439,7 @@ void CodeMarker::insert(FastSection &fastSection,
if (node->parent()->isClass() || node->parent()->isNamespace()) {
if (fastSection.inherited.isEmpty()
|| fastSection.inherited.last().first != node->parent()) {
- QPair<InnerNode *, int> p(node->parent(), 0);
+ QPair<Aggregate *, int> p(node->parent(), 0);
fastSection.inherited.append(p);
}
fastSection.inherited.last().second++;
diff --git a/src/tools/qdoc/codemarker.h b/src/tools/qdoc/codemarker.h
index 7983aa532c..c5226fff04 100644
--- a/src/tools/qdoc/codemarker.h
+++ b/src/tools/qdoc/codemarker.h
@@ -64,7 +64,7 @@ struct Section
QStringList keys;
NodeList members;
NodeList reimpMembers;
- QList<QPair<InnerNode *, int> > inherited;
+ QList<QPair<Aggregate *, int> > inherited;
ClassKeysNodesList classKeysNodesList_;
Section() { }
@@ -83,7 +83,7 @@ struct Section
struct FastSection
{
- const InnerNode *parent_;
+ const Aggregate *parent_;
QString name;
QString divClass;
QString singularMember;
@@ -91,9 +91,9 @@ struct FastSection
QMultiMap<QString, Node *> memberMap;
QMultiMap<QString, Node *> reimpMemberMap;
ClassMapList classMapList_;
- QList<QPair<InnerNode *, int> > inherited;
+ QList<QPair<Aggregate *, int> > inherited;
- FastSection(const InnerNode *parent,
+ FastSection(const Aggregate *parent,
const QString& name0,
const QString& divClass0,
const QString& singularMember0,
@@ -127,7 +127,7 @@ public:
virtual bool recognizeCode(const QString& code) = 0;
virtual bool recognizeExtension(const QString& ext) = 0;
virtual bool recognizeLanguage(const QString& lang) = 0;
- virtual Atom::Type atomType() const = 0;
+ virtual Atom::AtomType atomType() const = 0;
virtual QString markedUpCode(const QString& code,
const Node *relative,
const Location &location) = 0;
@@ -143,7 +143,7 @@ public:
virtual QString markedUpIncludes(const QStringList& includes) = 0;
virtual QString functionBeginRegExp(const QString& funcName) = 0;
virtual QString functionEndRegExp(const QString& funcName) = 0;
- virtual QList<Section> sections(const InnerNode *inner,
+ virtual QList<Section> sections(const Aggregate *inner,
SynopsisStyle style,
Status status) = 0;
virtual QList<Section> qmlSections(QmlTypeNode* qmlTypeNode,
diff --git a/src/tools/qdoc/codeparser.cpp b/src/tools/qdoc/codeparser.cpp
index a99a446cc2..4f80ec80d9 100644
--- a/src/tools/qdoc/codeparser.cpp
+++ b/src/tools/qdoc/codeparser.cpp
@@ -423,33 +423,6 @@ void CodeParser::checkModuleInclusion(Node* n)
.arg(n->name()).arg(Generator::defaultModuleName()));
}
break;
-#if 0
- case Node::Document:
- if (n->access() != Node::Private && !n->doc().isEmpty()) {
- if (n->subType() == Node::HeaderFile) {
-#if 0
- n->doc().location().warning(tr("Header file with title \"%1\" has no \\inmodule command; "
- "using project name by default: %2")
- .arg(n->title()).arg(Generator::defaultModuleName()));
-#endif
- }
- else if (n->subType() == Node::Page) {
-#if 0
- n->doc().location().warning(tr("Page with title \"%1\" has no \\inmodule command; "
- "using project name by default: %2")
- .arg(n->title()).arg(Generator::defaultModuleName()));
-#endif
- }
- else if (n->subType() == Node::Example) {
-#if 0
- n->doc().location().warning(tr("Example with title \"%1\" has no \\inmodule command; "
- "using project name by default: %2")
- .arg(n->title()).arg(Generator::defaultModuleName()));
-#endif
- }
- }
- break;
-#endif
default:
break;
}
diff --git a/src/tools/qdoc/config.cpp b/src/tools/qdoc/config.cpp
index 606bb1c619..13add73322 100644
--- a/src/tools/qdoc/config.cpp
+++ b/src/tools/qdoc/config.cpp
@@ -912,8 +912,10 @@ QStringList Config::loadMaster(const QString& fileName)
*/
void Config::load(Location location, const QString& fileName)
{
- pushWorkingDir(QFileInfo(fileName).path());
- QDir::setCurrent(QFileInfo(fileName).path());
+ QFileInfo fileInfo(fileName);
+ QString path = fileInfo.canonicalPath();
+ pushWorkingDir(path);
+ QDir::setCurrent(path);
QRegExp keySyntax(QLatin1String("\\w+(?:\\.\\w+)*"));
#define SKIP_CHAR() \
@@ -935,7 +937,7 @@ void Config::load(Location location, const QString& fileName)
if (location.depth() > 16)
location.fatal(tr("Too many nested includes"));
- QFile fin(fileName);
+ QFile fin(fileInfo.fileName());
if (!fin.open(QFile::ReadOnly | QFile::Text)) {
if (!Config::installDir.isEmpty()) {
int prefix = location.filePath().length() - location.fileName().length();
@@ -1030,7 +1032,7 @@ void Config::load(Location location, const QString& fileName)
/*
Here is the recursive call.
*/
- load(location, QFileInfo(QFileInfo(fileName).dir(), includeFile).filePath());
+ load(location, QFileInfo(QDir(path), includeFile).filePath());
}
else {
/*
diff --git a/src/tools/qdoc/cppcodemarker.cpp b/src/tools/qdoc/cppcodemarker.cpp
index 4c1e84fe3c..9aec902860 100644
--- a/src/tools/qdoc/cppcodemarker.cpp
+++ b/src/tools/qdoc/cppcodemarker.cpp
@@ -103,7 +103,7 @@ bool CppCodeMarker::recognizeLanguage(const QString &lang)
/*!
Returns the type of atom used to represent C++ code in the documentation.
*/
-Atom::Type CppCodeMarker::atomType() const
+Atom::AtomType CppCodeMarker::atomType() const
{
return Atom::Code;
}
@@ -436,7 +436,7 @@ QString CppCodeMarker::functionEndRegExp(const QString& /* funcName */)
return "^\\}$";
}
-QList<Section> CppCodeMarker::sections(const InnerNode *inner,
+QList<Section> CppCodeMarker::sections(const Aggregate *inner,
SynopsisStyle style,
Status status)
{
@@ -522,10 +522,10 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
++r;
}
- QStack<const InnerNode *> stack;
+ QStack<const Aggregate *> stack;
stack.push(inner);
while (!stack.isEmpty()) {
- const InnerNode* ancestor = stack.pop();
+ const Aggregate* ancestor = stack.pop();
NodeList::ConstIterator c = ancestor->childNodes().constBegin();
while (c != ancestor->childNodes().constEnd()) {
@@ -537,11 +537,9 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
isSlot = (func->metaness() == FunctionNode::Slot);
isSignal = (func->metaness() == FunctionNode::Signal);
isStatic = func->isStatic();
- if (func->associatedProperty()) {
- if (func->associatedProperty()->status() == Node::Obsolete) {
- ++c;
- continue;
- }
+ if (func->hasAssociatedProperties() && !func->hasActiveAssociatedProperty()) {
+ ++c;
+ continue;
}
}
else if ((*c)->type() == Node::Variable) {
@@ -685,7 +683,7 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
}
else if ((*c)->type() == Node::Function) {
FunctionNode *function = static_cast<FunctionNode *>(*c);
- if (!function->associatedProperty())
+ if (!function->hasAssociatedProperties() || !function->doc().isEmpty())
insert(memberFunctions, function, style, status);
}
++c;
@@ -701,11 +699,11 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
else {
FastSection all(inner,QString(),QString(),"member","members");
- QStack<const InnerNode*> stack;
+ QStack<const Aggregate*> stack;
stack.push(inner);
while (!stack.isEmpty()) {
- const InnerNode* ancestor = stack.pop();
+ const Aggregate* ancestor = stack.pop();
NodeList::ConstIterator c = ancestor->childNodes().constBegin();
while (c != ancestor->childNodes().constEnd()) {
if ((*c)->access() != Node::Private && (*c)->type() != Node::Property)
@@ -812,8 +810,8 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
if (!ns->orphans().isEmpty()) {
foreach (Node* n, ns->orphans()) {
// Use inner as a temporary parent when inserting orphans
- InnerNode* p = n->parent();
- n->setParent(const_cast<InnerNode*>(inner));
+ Aggregate* p = n->parent();
+ n->setParent(const_cast<Aggregate*>(inner));
if (n->isClass())
insert(classes, n, style, status);
else if (n->isNamespace())
diff --git a/src/tools/qdoc/cppcodemarker.h b/src/tools/qdoc/cppcodemarker.h
index 509d130a27..aa759f2993 100644
--- a/src/tools/qdoc/cppcodemarker.h
+++ b/src/tools/qdoc/cppcodemarker.h
@@ -53,7 +53,7 @@ public:
virtual bool recognizeCode(const QString& code) Q_DECL_OVERRIDE;
virtual bool recognizeExtension(const QString& ext) Q_DECL_OVERRIDE;
virtual bool recognizeLanguage(const QString& lang) Q_DECL_OVERRIDE;
- virtual Atom::Type atomType() const Q_DECL_OVERRIDE;
+ virtual Atom::AtomType atomType() const Q_DECL_OVERRIDE;
virtual QString markedUpCode(const QString& code,
const Node *relative,
const Location &location) Q_DECL_OVERRIDE;
@@ -67,7 +67,7 @@ public:
virtual QString markedUpIncludes(const QStringList& includes) Q_DECL_OVERRIDE;
virtual QString functionBeginRegExp(const QString& funcName) Q_DECL_OVERRIDE;
virtual QString functionEndRegExp(const QString& funcName) Q_DECL_OVERRIDE;
- virtual QList<Section> sections(const InnerNode *innerNode,
+ virtual QList<Section> sections(const Aggregate *innerNode,
SynopsisStyle style,
Status status) Q_DECL_OVERRIDE;
virtual QList<Section> qmlSections(QmlTypeNode* qmlTypeNode,
diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp
index f12fb70227..ab79f8f320 100644
--- a/src/tools/qdoc/cppcodeparser.cpp
+++ b/src/tools/qdoc/cppcodeparser.cpp
@@ -250,16 +250,11 @@ void CppCodeParser::doneParsingHeaderFiles()
/*!
This is called after all the source files (i.e., not the
- header files) have been parsed. It traverses the tree to
- resolve property links, normalize overload signatures, and
- do other housekeeping of the database.
+ header files) have been parsed. Currently nothing to do.
*/
void CppCodeParser::doneParsingSourceFiles()
{
- qdb_->primaryTreeRoot()->normalizeOverloads();
- qdb_->fixInheritance();
- qdb_->resolveProperties();
- qdb_->primaryTreeRoot()->makeUndocumentedChildrenInternal();
+ // contents moved to QdocDatabase::resolveIssues()
}
static QSet<QString> topicCommands_;
@@ -408,7 +403,7 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc,
this way to allow the writer to refer to the entity
without including the namespace qualifier.
*/
- Node::Type type = nodeTypeMap[command];
+ Node::NodeType type = nodeTypeMap[command];
QStringList paths = arg.first.split(QLatin1Char(' '));
QStringList path = paths[0].split("::");
Node *node = 0;
@@ -422,7 +417,7 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc,
lastPath_ = path;
}
- else if (node->isInnerNode()) {
+ else if (node->isAggregate()) {
if (type == Node::Namespace) {
NamespaceNode* ns = static_cast<NamespaceNode*>(node);
ns->markSeen();
@@ -520,16 +515,6 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc,
else if (t == "ditamap")
ptype = Node::DitaMapPage;
}
-
-#if 0
- const Node* n = qdb_->checkForCollision(args[0]);
- if (n) {
- QString other = n->doc().location().fileName();
- doc.location().warning(tr("Name/title collision detected: '%1' in '\\%2'")
- .arg(args[0]).arg(command),
- tr("Also used here: %1").arg(other));
- }
-#endif
DocumentNode* dn = 0;
if (ptype == Node::DitaMapPage)
dn = new DitaMapNode(qdb_->primaryTreeRoot(), args[0]);
@@ -572,7 +557,7 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc,
QmlTypeNode* qmlType = qdb_->findQmlType(module, qmlTypeName);
if (qmlType) {
bool attached = false;
- Node::Type nodeType = Node::QmlMethod;
+ Node::NodeType nodeType = Node::QmlMethod;
if ((command == COMMAND_QMLSIGNAL) ||
(command == COMMAND_JSSIGNAL))
nodeType = Node::QmlSignal;
@@ -870,7 +855,8 @@ const QSet<QString>& CppCodeParser::otherMetaCommands()
<< COMMAND_QMLINSTANTIATES
<< COMMAND_QMLDEFAULT
<< COMMAND_QMLREADONLY
- << COMMAND_QMLABSTRACT;
+ << COMMAND_QMLABSTRACT
+ << COMMAND_ABSTRACT;
}
return otherMetaCommands_;
}
@@ -887,22 +873,18 @@ void CppCodeParser::processOtherMetaCommand(const Doc& doc,
{
QString arg = argLocPair.first;
if (command == COMMAND_INHEADERFILE) {
- if (node != 0 && node->isInnerNode()) {
- ((InnerNode *) node)->addInclude(arg);
+ if (node != 0 && node->isAggregate()) {
+ ((Aggregate *) node)->addInclude(arg);
}
else {
- doc.location().warning(tr("Ignored '\\%1'")
- .arg(COMMAND_INHEADERFILE));
+ doc.location().warning(tr("Ignored '\\%1'").arg(COMMAND_INHEADERFILE));
}
}
else if (command == COMMAND_OVERLOAD) {
- if (node != 0 && node->type() == Node::Function) {
- ((FunctionNode *) node)->setOverload(true);
- }
- else {
- doc.location().warning(tr("Ignored '\\%1'")
- .arg(COMMAND_OVERLOAD));
- }
+ if (node && node->isFunction())
+ ((FunctionNode *) node)->setOverloadFlag(true);
+ else
+ doc.location().warning(tr("Ignored '\\%1'").arg(COMMAND_OVERLOAD));
}
else if (command == COMMAND_REIMP) {
if (node != 0 && node->parent() && !node->parent()->isInternal()) {
@@ -928,12 +910,10 @@ void CppCodeParser::processOtherMetaCommand(const Doc& doc,
"because its base function is private "
"or internal").arg(COMMAND_REIMP).arg(node->name()));
}
- func->setReimp(true);
+ func->setReimplemented(true);
}
else {
- doc.location().warning(tr("Ignored '\\%1' in %2")
- .arg(COMMAND_REIMP)
- .arg(node->name()));
+ doc.location().warning(tr("Ignored '\\%1' in %2").arg(COMMAND_REIMP).arg(node->name()));
}
}
}
@@ -943,7 +923,7 @@ void CppCodeParser::processOtherMetaCommand(const Doc& doc,
if (!n)
doc.location().warning(tr("Cannot find '%1' in '\\%2'").arg(arg).arg(COMMAND_RELATES));
else
- node->setRelates(static_cast<InnerNode*>(n));
+ node->setRelates(static_cast<Aggregate*>(n));
}
else if (command == COMMAND_CONTENTSPAGE) {
setLink(node, Node::ContentsLink, arg);
@@ -1014,7 +994,7 @@ void CppCodeParser::processOtherMetaCommand(const Doc& doc,
}
}
}
- else if (command == COMMAND_QMLABSTRACT) {
+ else if ((command == COMMAND_QMLABSTRACT) || (command == COMMAND_ABSTRACT)) {
if (node->isQmlType() || node->isJsType())
node->setAbstract(true);
}
@@ -1051,7 +1031,7 @@ void CppCodeParser::reset()
tokenizer = 0;
tok = 0;
access = Node::Public;
- metaness = FunctionNode::Plain;
+ metaness_ = FunctionNode::Plain;
lastPath_.clear();
physicalModuleName.clear();
}
@@ -1353,7 +1333,7 @@ bool CppCodeParser::matchParameter(FunctionNode *func)
return true;
}
-bool CppCodeParser::matchFunctionDecl(InnerNode *parent,
+bool CppCodeParser::matchFunctionDecl(Aggregate *parent,
QStringList *parentPathPtr,
FunctionNode **funcPtr,
const QString &templateStuff,
@@ -1378,7 +1358,7 @@ bool CppCodeParser::matchFunctionDecl(InnerNode *parent,
}
FunctionNode::Virtualness vir = FunctionNode::NonVirtual;
if (match(Tok_virtual)) {
- vir = FunctionNode::ImpureVirtual;
+ vir = FunctionNode::NormalVirtual;
if (matchCompat())
compat = true;
}
@@ -1516,7 +1496,7 @@ bool CppCodeParser::matchFunctionDecl(InnerNode *parent,
if (compat)
func->setStatus(Node::Compat);
- func->setMetaness(metaness);
+ func->setMetaness(metaness_);
if (parent) {
if (name == parent->name()) {
func->setMetaness(FunctionNode::Ctor);
@@ -1616,7 +1596,7 @@ bool CppCodeParser::matchBaseList(ClassNode *classe, bool isClass)
sufficient for Qt because there are no cases of class nesting more
than one level deep.
*/
-bool CppCodeParser::matchClassDecl(InnerNode *parent,
+bool CppCodeParser::matchClassDecl(Aggregate *parent,
const QString &templateStuff)
{
bool isClass = (tok == Tok_class);
@@ -1631,7 +1611,7 @@ bool CppCodeParser::matchClassDecl(InnerNode *parent,
if (tok == Tok_Gulbrandsen) {
Node* n = parent->findChildNode(previousLexeme(),Node::Class);
if (n) {
- parent = static_cast<InnerNode*>(n);
+ parent = static_cast<Aggregate*>(n);
if (parent) {
readToken();
if (tok != Tok_Ident)
@@ -1663,17 +1643,17 @@ bool CppCodeParser::matchClassDecl(InnerNode *parent,
Node::Access outerAccess = access;
access = isClass ? Node::Private : Node::Public;
- FunctionNode::Metaness outerMetaness = metaness;
- metaness = FunctionNode::Plain;
+ FunctionNode::Metaness outerMetaness = metaness_;
+ metaness_ = FunctionNode::Plain;
bool matches = (matchDeclList(classe) && match(Tok_RightBrace) &&
match(Tok_Semicolon));
access = outerAccess;
- metaness = outerMetaness;
+ metaness_ = outerMetaness;
return matches;
}
-bool CppCodeParser::matchNamespaceDecl(InnerNode *parent)
+bool CppCodeParser::matchNamespaceDecl(Aggregate *parent)
{
readToken(); // skip 'namespace'
if (tok != Tok_Ident)
@@ -1712,7 +1692,7 @@ bool CppCodeParser::matchNamespaceDecl(InnerNode *parent)
member function is added to \a parent as an unresolved
\c using clause.
*/
-bool CppCodeParser::matchUsingDecl(InnerNode* parent)
+bool CppCodeParser::matchUsingDecl(Aggregate* parent)
{
bool usingNamespace = false;
readToken(); // skip 'using'
@@ -1774,17 +1754,25 @@ bool CppCodeParser::matchUsingDecl(InnerNode* parent)
return true;
}
-bool CppCodeParser::matchEnumItem(InnerNode *parent, EnumNode *enume)
+bool CppCodeParser::matchEnumItem(Aggregate *parent, EnumNode *enume)
{
if (!match(Tok_Ident))
return false;
QString name = previousLexeme();
CodeChunk val;
+ int parenLevel = 0;
if (match(Tok_Equal)) {
- while (tok != Tok_Comma && tok != Tok_RightBrace &&
- tok != Tok_Eoi) {
+ while (tok != Tok_RightBrace && tok != Tok_Eoi) {
+ if (tok == Tok_LeftParen)
+ parenLevel++;
+ else if (tok == Tok_RightParen)
+ parenLevel--;
+ else if (tok == Tok_Comma) {
+ if (parenLevel <= 0)
+ break;
+ }
val.append(lexeme());
readToken();
}
@@ -1825,7 +1813,7 @@ bool CppCodeParser::matchEnumItem(InnerNode *parent, EnumNode *enume)
return true;
}
-bool CppCodeParser::matchEnumDecl(InnerNode *parent)
+bool CppCodeParser::matchEnumDecl(Aggregate *parent)
{
QString name;
@@ -1856,7 +1844,7 @@ bool CppCodeParser::matchEnumDecl(InnerNode *parent)
return match(Tok_RightBrace) && match(Tok_Semicolon);
}
-bool CppCodeParser::matchTypedefDecl(InnerNode *parent)
+bool CppCodeParser::matchTypedefDecl(Aggregate *parent)
{
CodeChunk dataType;
QString name;
@@ -1876,7 +1864,7 @@ bool CppCodeParser::matchTypedefDecl(InnerNode *parent)
return true;
}
-bool CppCodeParser::matchProperty(InnerNode *parent)
+bool CppCodeParser::matchProperty(Aggregate *parent)
{
int expected_tok = Tok_LeftParen;
if (match(Tok_Q_PRIVATE_PROPERTY)) {
@@ -1989,7 +1977,7 @@ bool CppCodeParser::matchProperty(InnerNode *parent)
/*!
Parse a C++ declaration.
*/
-bool CppCodeParser::matchDeclList(InnerNode *parent)
+bool CppCodeParser::matchDeclList(Aggregate *parent)
{
ExtraFuncData extra;
QString templateStuff;
@@ -2030,28 +2018,28 @@ bool CppCodeParser::matchDeclList(InnerNode *parent)
case Tok_private:
readToken();
access = Node::Private;
- metaness = FunctionNode::Plain;
+ metaness_ = FunctionNode::Plain;
break;
case Tok_protected:
readToken();
access = Node::Protected;
- metaness = FunctionNode::Plain;
+ metaness_ = FunctionNode::Plain;
break;
case Tok_public:
readToken();
access = Node::Public;
- metaness = FunctionNode::Plain;
+ metaness_ = FunctionNode::Plain;
break;
case Tok_signals:
case Tok_Q_SIGNALS:
readToken();
access = Node::Public;
- metaness = FunctionNode::Signal;
+ metaness_ = FunctionNode::Signal;
break;
case Tok_slots:
case Tok_Q_SLOTS:
readToken();
- metaness = FunctionNode::Slot;
+ metaness_ = FunctionNode::Slot;
break;
case Tok_Q_OBJECT:
readToken();
@@ -2069,29 +2057,25 @@ bool CppCodeParser::matchDeclList(InnerNode *parent)
case Tok_Q_DECLARE_SEQUENTIAL_ITERATOR:
readToken();
if (match(Tok_LeftParen) && match(Tok_Ident))
- sequentialIteratorClasses.insert(previousLexeme(),
- location().fileName());
+ sequentialIteratorClasses.insert(previousLexeme(), location().fileName());
match(Tok_RightParen);
break;
case Tok_Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR:
readToken();
if (match(Tok_LeftParen) && match(Tok_Ident))
- mutableSequentialIteratorClasses.insert(previousLexeme(),
- location().fileName());
+ mutableSequentialIteratorClasses.insert(previousLexeme(), location().fileName());
match(Tok_RightParen);
break;
case Tok_Q_DECLARE_ASSOCIATIVE_ITERATOR:
readToken();
if (match(Tok_LeftParen) && match(Tok_Ident))
- associativeIteratorClasses.insert(previousLexeme(),
- location().fileName());
+ associativeIteratorClasses.insert(previousLexeme(), location().fileName());
match(Tok_RightParen);
break;
case Tok_Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR:
readToken();
if (match(Tok_LeftParen) && match(Tok_Ident))
- mutableAssociativeIteratorClasses.insert(previousLexeme(),
- location().fileName());
+ mutableAssociativeIteratorClasses.insert(previousLexeme(), location().fileName());
match(Tok_RightParen);
break;
case Tok_Q_DECLARE_FLAGS:
@@ -2256,15 +2240,15 @@ bool CppCodeParser::matchDocsAndStuff()
processOtherMetaCommands(*d, *n);
(*n)->setDoc(*d);
checkModuleInclusion(*n);
- if ((*n)->isInnerNode() && ((InnerNode *)*n)->includes().isEmpty()) {
- InnerNode *m = static_cast<InnerNode *>(*n);
+ if ((*n)->isAggregate() && ((Aggregate *)*n)->includes().isEmpty()) {
+ Aggregate *m = static_cast<Aggregate *>(*n);
while (m->parent() && m->physicalModuleName().isEmpty()) {
m = m->parent();
}
if (m == *n)
- ((InnerNode *)*n)->addInclude((*n)->name());
+ ((Aggregate *)*n)->addInclude((*n)->name());
else
- ((InnerNode *)*n)->setIncludes(m->includes());
+ ((Aggregate *)*n)->setIncludes(m->includes());
}
++d;
++n;
@@ -2346,8 +2330,8 @@ bool CppCodeParser::makeFunctionNode(const QString& signature,
*/
FunctionNode* CppCodeParser::makeFunctionNode(const Doc& doc,
const QString& sig,
- InnerNode* parent,
- Node::Type type,
+ Aggregate* parent,
+ Node::NodeType type,
bool attached,
QString qdoctag)
{
diff --git a/src/tools/qdoc/cppcodeparser.h b/src/tools/qdoc/cppcodeparser.h
index f9ddcab88c..31964699a2 100644
--- a/src/tools/qdoc/cppcodeparser.h
+++ b/src/tools/qdoc/cppcodeparser.h
@@ -44,7 +44,7 @@ class ClassNode;
class CodeChunk;
class CppCodeParserPrivate;
class FunctionNode;
-class InnerNode;
+class Aggregate;
class Tokenizer;
class CppCodeParser : public CodeParser
@@ -52,12 +52,12 @@ class CppCodeParser : public CodeParser
Q_DECLARE_TR_FUNCTIONS(QDoc::CppCodeParser)
struct ExtraFuncData {
- InnerNode* root; // Used as the parent.
- Node::Type type; // The node type: Function, etc.
+ Aggregate* root; // Used as the parent.
+ Node::NodeType type; // The node type: Function, etc.
bool isAttached; // If true, the method is attached.
bool isMacro; // If true, we are parsing a macro signature.
ExtraFuncData() : root(0), type(Node::Function), isAttached(false), isMacro(false) { }
- ExtraFuncData(InnerNode* r, Node::Type t, bool a)
+ ExtraFuncData(Aggregate* r, Node::NodeType t, bool a)
: root(r), type(t), isAttached(a), isMacro(false) { }
};
@@ -117,22 +117,22 @@ protected:
bool matchTemplateHeader();
bool matchDataType(CodeChunk *type, QString *var = 0);
bool matchParameter(FunctionNode *func);
- bool matchFunctionDecl(InnerNode *parent,
+ bool matchFunctionDecl(Aggregate *parent,
QStringList *parentPathPtr,
FunctionNode **funcPtr,
const QString &templateStuff,
ExtraFuncData& extra);
bool matchBaseSpecifier(ClassNode *classe, bool isClass);
bool matchBaseList(ClassNode *classe, bool isClass);
- bool matchClassDecl(InnerNode *parent,
+ bool matchClassDecl(Aggregate *parent,
const QString &templateStuff = QString());
- bool matchNamespaceDecl(InnerNode *parent);
- bool matchUsingDecl(InnerNode* parent);
- bool matchEnumItem(InnerNode *parent, EnumNode *enume);
- bool matchEnumDecl(InnerNode *parent);
- bool matchTypedefDecl(InnerNode *parent);
- bool matchProperty(InnerNode *parent);
- bool matchDeclList(InnerNode *parent);
+ bool matchNamespaceDecl(Aggregate *parent);
+ bool matchUsingDecl(Aggregate* parent);
+ bool matchEnumItem(Aggregate *parent, EnumNode *enume);
+ bool matchEnumDecl(Aggregate *parent);
+ bool matchTypedefDecl(Aggregate *parent);
+ bool matchProperty(Aggregate *parent);
+ bool matchDeclList(Aggregate *parent);
bool matchDocsAndStuff();
bool makeFunctionNode(const QString &synopsis,
QStringList *parentPathPtr,
@@ -140,8 +140,8 @@ protected:
ExtraFuncData& params);
FunctionNode* makeFunctionNode(const Doc& doc,
const QString& sig,
- InnerNode* parent,
- Node::Type type,
+ Aggregate* parent,
+ Node::NodeType type,
bool attached,
QString qdoctag);
void parseQiteratorDotH(const Location &location, const QString &filePath);
@@ -151,11 +151,11 @@ protected:
void createExampleFileNodes(DocumentNode *dn);
protected:
- QMap<QString, Node::Type> nodeTypeMap;
+ QMap<QString, Node::NodeType> nodeTypeMap;
Tokenizer *tokenizer;
int tok;
Node::Access access;
- FunctionNode::Metaness metaness;
+ FunctionNode::Metaness metaness_;
QString physicalModuleName;
QStringList lastPath_;
QRegExp varComment;
@@ -177,6 +177,7 @@ protected:
QString exampleImageFilter;
};
+#define COMMAND_ABSTRACT Doc::alias("abstract")
#define COMMAND_CLASS Doc::alias("class")
#define COMMAND_CONTENTSPAGE Doc::alias("contentspage")
#define COMMAND_DITAMAP Doc::alias("ditamap")
diff --git a/src/tools/qdoc/doc.cpp b/src/tools/qdoc/doc.cpp
index 92c6d405de..f322bd9360 100644
--- a/src/tools/qdoc/doc.cpp
+++ b/src/tools/qdoc/doc.cpp
@@ -69,7 +69,6 @@ struct Macro
enum {
CMD_A,
- CMD_ABSTRACT,
CMD_ANNOTATEDLIST,
CMD_B,
CMD_BADCODE,
@@ -85,7 +84,6 @@ enum {
CMD_DOTS,
CMD_E,
CMD_ELSE,
- CMD_ENDABSTRACT,
CMD_ENDCHAPTER,
CMD_ENDCODE,
CMD_ENDDIV,
@@ -187,7 +185,6 @@ static struct {
QString *alias;
} cmds[] = {
{ "a", CMD_A, 0 },
- { "abstract", CMD_ABSTRACT, 0 },
{ "annotatedlist", CMD_ANNOTATEDLIST, 0 },
{ "b", CMD_B, 0 },
{ "badcode", CMD_BADCODE, 0 },
@@ -203,7 +200,6 @@ static struct {
{ "dots", CMD_DOTS, 0 },
{ "e", CMD_E, 0 },
{ "else", CMD_ELSE, 0 },
- { "endabstract", CMD_ENDABSTRACT, 0 },
{ "endchapter", CMD_ENDCHAPTER, 0 },
{ "endcode", CMD_ENDCODE, 0 },
{ "enddiv", CMD_ENDDIV, 0 },
@@ -469,16 +465,16 @@ private:
void endSection(int unit, int endCmd);
void parseAlso();
void append(const QString &string);
- void append(Atom::Type type, const QString& string = QString());
- void append(Atom::Type type, const QString& p1, const QString& p2);
+ void append(Atom::AtomType type, const QString& string = QString());
+ void append(Atom::AtomType type, const QString& p1, const QString& p2);
void append(const QString& p1, const QString& p2);
void appendChar(QChar ch);
void appendWord(const QString &word);
void appendToCode(const QString &code);
- void appendToCode(const QString &code, Atom::Type defaultType);
+ void appendToCode(const QString &code, Atom::AtomType defaultType);
void startNewPara();
- void enterPara(Atom::Type leftType = Atom::ParaLeft,
- Atom::Type rightType = Atom::ParaRight,
+ void enterPara(Atom::AtomType leftType = Atom::ParaLeft,
+ Atom::AtomType rightType = Atom::ParaRight,
const QString& string = QString());
void leavePara();
void leaveValue();
@@ -525,8 +521,8 @@ private:
bool inTableRow;
bool inTableItem;
bool indexStartedPara; // ### rename
- Atom::Type pendingParaLeftType;
- Atom::Type pendingParaRightType;
+ Atom::AtomType pendingParaLeftType;
+ Atom::AtomType pendingParaRightType;
QString pendingParaString;
int braceDepth;
@@ -631,12 +627,6 @@ void DocParser::parse(const QString& source,
append(Atom::FormattingRight,ATOM_FORMATTING_PARAMETER);
priv->params.insert(p1);
break;
- case CMD_ABSTRACT:
- if (openCommand(cmd)) {
- leavePara();
- append(Atom::AbstractLeft);
- }
- break;
case CMD_BADCODE:
leavePara();
append(Atom::CodeBad,getCode(CMD_BADCODE, marker));
@@ -748,12 +738,6 @@ void DocParser::parse(const QString& source,
location().warning(tr("Unexpected '\\%1'").arg(cmdName(CMD_ELSE)));
}
break;
- case CMD_ENDABSTRACT:
- if (closeCommand(cmd)) {
- leavePara();
- append(Atom::AbstractRight);
- }
- break;
case CMD_ENDCHAPTER:
endSection(Doc::Chapter, cmd);
break;
@@ -1830,11 +1814,6 @@ bool DocParser::openCommand(int cmd)
if (outer == CMD_LIST) {
ok = (cmd == CMD_FOOTNOTE || cmd == CMD_LIST);
}
- else if (outer == CMD_ABSTRACT) {
- ok = (cmd == CMD_LIST ||
- cmd == CMD_QUOTATION ||
- cmd == CMD_TABLE);
- }
else if (outer == CMD_SIDEBAR) {
ok = (cmd == CMD_LIST ||
cmd == CMD_QUOTATION ||
@@ -1984,9 +1963,9 @@ void DocParser::parseAlso()
}
}
-void DocParser::append(Atom::Type type, const QString &string)
+void DocParser::append(Atom::AtomType type, const QString &string)
{
- Atom::Type lastType = priv->text.lastAtom()->type();
+ Atom::AtomType lastType = priv->text.lastAtom()->type();
if ((lastType == Atom::Code) && priv->text.lastAtom()->string().endsWith(QLatin1String("\n\n")))
priv->text.lastAtom()->chopString();
priv->text << Atom(type, string);
@@ -1994,15 +1973,15 @@ void DocParser::append(Atom::Type type, const QString &string)
void DocParser::append(const QString &string)
{
- Atom::Type lastType = priv->text.lastAtom()->type();
+ Atom::AtomType lastType = priv->text.lastAtom()->type();
if ((lastType == Atom::Code) && priv->text.lastAtom()->string().endsWith(QLatin1String("\n\n")))
priv->text.lastAtom()->chopString();
priv->text << Atom(string); // The Atom type is Link.
}
-void DocParser::append(Atom::Type type, const QString& p1, const QString& p2)
+void DocParser::append(Atom::AtomType type, const QString& p1, const QString& p2)
{
- Atom::Type lastType = priv->text.lastAtom()->type();
+ Atom::AtomType lastType = priv->text.lastAtom()->type();
if ((lastType == Atom::Code) && priv->text.lastAtom()->string().endsWith(QLatin1String("\n\n")))
priv->text.lastAtom()->chopString();
priv->text << Atom(type, p1, p2);
@@ -2010,7 +1989,7 @@ void DocParser::append(Atom::Type type, const QString& p1, const QString& p2)
void DocParser::append(const QString& p1, const QString& p2)
{
- Atom::Type lastType = priv->text.lastAtom()->type();
+ Atom::AtomType lastType = priv->text.lastAtom()->type();
if ((lastType == Atom::Code) && priv->text.lastAtom()->string().endsWith(QLatin1String("\n\n")))
priv->text.lastAtom()->chopString();
if (p2.isEmpty())
@@ -2043,15 +2022,15 @@ void DocParser::appendWord(const QString &word)
void DocParser::appendToCode(const QString& markedCode)
{
- Atom::Type lastType = priv->text.lastAtom()->type();
+ Atom::AtomType lastType = priv->text.lastAtom()->type();
if (lastType != Atom::Qml && lastType != Atom::Code && lastType != Atom::JavaScript)
append(Atom::Qml);
priv->text.lastAtom()->appendString(markedCode);
}
-void DocParser::appendToCode(const QString &markedCode, Atom::Type defaultType)
+void DocParser::appendToCode(const QString &markedCode, Atom::AtomType defaultType)
{
- Atom::Type lastType = priv->text.lastAtom()->type();
+ Atom::AtomType lastType = priv->text.lastAtom()->type();
if (lastType != Atom::Qml && lastType != Atom::Code && lastType != Atom::JavaScript)
append(defaultType, markedCode);
else
@@ -2064,8 +2043,8 @@ void DocParser::startNewPara()
enterPara();
}
-void DocParser::enterPara(Atom::Type leftType,
- Atom::Type rightType,
+void DocParser::enterPara(Atom::AtomType leftType,
+ Atom::AtomType rightType,
const QString& string)
{
if (paraState == OutsideParagraph) {
@@ -2674,8 +2653,6 @@ void DocParser::skipToNextPreprocessorCommand()
int DocParser::endCmdFor(int cmd)
{
switch (cmd) {
- case CMD_ABSTRACT:
- return CMD_ENDABSTRACT;
case CMD_BADCODE:
return CMD_ENDCODE;
case CMD_CHAPTER:
diff --git a/src/tools/qdoc/doc/qdoc-manual-cmdindex.qdoc b/src/tools/qdoc/doc/qdoc-manual-cmdindex.qdoc
index 87416fcd14..63fcee6469 100644
--- a/src/tools/qdoc/doc/qdoc-manual-cmdindex.qdoc
+++ b/src/tools/qdoc/doc/qdoc-manual-cmdindex.qdoc
@@ -106,6 +106,7 @@
\li \l {printto-command} {\\printto}
\li \l {printuntil-command} {\\printuntil}
\li \l {property-command} {\\property}
+ \li \l {qmlabstract-command} {\\qmlabstract}
\li \l {qmlattachedproperty-command} {\\qmlattachedproperty}
\li \l {qmlattachedsignal-command} {\\qmlattachedsignal}
\li \l {qmlbasictype-command} {\\qmlbasictype}
diff --git a/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc b/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc
index 77987d6d95..3bf63214ad 100644
--- a/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc
+++ b/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc
@@ -46,6 +46,7 @@
below the \l {Topic Commands} {topic} command.
\list
+ \li \l {abstract-command} {\\abstract}
\li \l {compat-command}{\\compat},
\li \l {contentspage-command}{\\contentspage},
\li \l {indexpage-command}{\\indexpage},
@@ -59,6 +60,7 @@
\li \l {overload-command}{\\overload},
\li \l {preliminary-command}{\\preliminary},
\li \l {previouspage-command}{\\previouspage},
+ \li \l {qmlabstract-command} {\\qmlabstract}
\li \l {reentrant-command}{\\reentrant},
\li \l {reimp-command}{\\reimp},
\li \l {relates-command}{\\relates},
@@ -199,21 +201,41 @@
index page of the collection.
*/
-
/*!
\page 16-qdoc-commands-status.html
\previouspage Document Navigation
\contentspage QDoc Manual
\nextpage Thread Support
- \title Reporting Status
-
- These commands are for indicating that a documented element is
- still under development, is becoming obsolete, is provided for
- compatibility reasons, or is simply not to be included in the
- public interface. The \l {since-command}{\\since} command is for
- including information about the version when a function or class
- first appeared.
+ \title Status
+
+ These commands are for indicating that a documented element has
+ some special status. The element could be marked as about to be
+ made obsolete, or that it is provided for compatibility with an
+ earlier version, or is simply not to be included in the public
+ interface. The \l {since-command}{\\since} command is for
+ specifying the version number in which a function or class first
+ appeared. The \l {qmlabstract-command} {\\qmlabstract} command is
+ for marking a QML type as an abstract base class.
+
+ \target abstract-command
+ \target qmlabstract-command
+ \section1 \\abstract and \\qmlabstract
+
+ \\abstract is a synonym for the \\qmlabstract command. Add this
+ command to the \l {qmltype-command} {\\qmltype} comment for a QML
+ type when that type is meant to be used \e {only} as an abstract
+ base type. When a QML type is abstract, it means that the QML type
+ that can't be instantiated. Instead, the properties in its public
+ API are included in the public properties list on the reference
+ page for each QML type that inherits the abstract QML type. The
+ properties are documented as if they are properties of the
+ inheriting QML type.
+
+ Normally, when a QML type is marked with \e{\\qmlabstract}, it is
+ also marked with \e{\\internal} so that its reference page is not
+ generated. It the abstract QML type is not marked internal, it
+ will have a reference page in the documentation.
\target compat-command
\section1 \\compat
@@ -412,13 +434,14 @@
/ *!
\preliminary
- Returns information about the joining properties of the
- character (needed for certain languages such as
- Arabic).
+ Returns information about the joining type attributes of the
+ character (needed for certain languages such as Arabic or
+ Syriac).
+
* /
- QChar::Joining QChar::joining() const
+ QChar::JoiningType QChar::joiningType() const
{
- return ::joining(*this);
+ return QChar::joiningType(ucs);
}
\endcode
@@ -427,28 +450,25 @@
\quotation
\raw HTML
<h3>
- <a href="http://doc.qt.io/qt-5/qchar.html#JoiningType-enum">Joining</a>
- QChar::joining () const</h3>
+ <a href="http://doc.qt.io/qt-5/qchar.html#JoiningType-enum">JoiningType</a>
+ QChar::joiningType() const</h3>
\endraw
\b {This function is under development and
subject to change.}
- Returns information about the joining properties of the
- character (needed for certain languages such as
- Arabic).
+ Returns information about the joining type attributes of the
+ character (needed for certain languages such as Arabic or
+ Syriac).
\endquotation
- And the function's entry in QChar's list of functions will be
+ And the function's entry in QChar's list of public functions will be
rendered as:
\quotation
\list
\li ...
- \li Joining
- \l {Joining-enum}
- {joining}()
- const \c (preliminary)
+ \li JoiningType \l {QChar::joiningType()} {joiningType}() const \c (preliminary)
\li ...
\endlist
\endquotation
@@ -791,7 +811,7 @@
</h3>
\endraw
- This function overloads \l {addAction} {addAction()}
+ This function overloads \l {QMenu::addAction()} {addAction()}
This convenience function creates a new action with an
\e icon and some \e text. The function adds the newly
@@ -799,8 +819,7 @@
returns it.
See also
- \l {addAction}
- {QWidget::addAction}().
+ \l {QWidget::addAction()} {QWidget::addAction}().
\endquotation
If you don't include the function name with the \b{\\overload}
diff --git a/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc b/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc
index d764cde89d..fc576157f7 100644
--- a/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc
+++ b/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc
@@ -38,7 +38,6 @@
\list
\li \l {a-command} {\\a}
- \li \l {abstract-command} {\\abstract}
\li \l {annotatedlist-command} {\\annotatedlist}
\li \l {b-command} {\\b} \span {class="newStuff"}
\li \l {b-command} {\\bold} {(deprecated, use \\b)}
@@ -2886,19 +2885,6 @@
parts with a special rendering, conceptual meaning or
function.
- \target abstract-command
- \section1 \\abstract
-
- The \\abstract and \\endabstract commands delimit a
- document's abstract section.
-
- The abstract section is rendered as an indented italicized
- paragraph.
-
- \warning The \b{\\abstract} and \b{\\endabstract} commands
- have not been implemented. The abstract section is rendered as a
- regular HTML paragraph.
-
\target quotation-command
\section1 \\quotation
diff --git a/src/tools/qdoc/generator.cpp b/src/tools/qdoc/generator.cpp
index d22ec507f6..831d975591 100644
--- a/src/tools/qdoc/generator.cpp
+++ b/src/tools/qdoc/generator.cpp
@@ -259,7 +259,7 @@ void Generator::writeOutFileNames()
Attaches a QTextStream to the created file, which is written
to all over the place using out().
*/
-void Generator::beginSubPage(const InnerNode* node, const QString& fileName)
+void Generator::beginSubPage(const Aggregate* node, const QString& fileName)
{
QString path = outputDir() + QLatin1Char('/');
if (Generator::useOutputSubdirs() && !node->outputSubdirectory().isEmpty() &&
@@ -281,7 +281,7 @@ void Generator::beginSubPage(const InnerNode* node, const QString& fileName)
out->setCodec(outputCodec);
#endif
outStreamStack.push(out);
- const_cast<InnerNode*>(node)->setOutputFileName(fileName);
+ const_cast<Aggregate*>(node)->setOutputFileName(fileName);
}
/*!
@@ -300,7 +300,7 @@ QString Generator::fileBase(const Node *node) const
{
if (node->relates())
node = node->relates();
- else if (!node->isInnerNode())
+ else if (!node->isAggregate())
node = node->parent();
if (node->type() == Node::QmlPropertyGroup) {
node = node->parent();
@@ -564,20 +564,19 @@ QString Generator::fullDocumentLocation(const Node *node, bool useSubdir)
break;
case Node::Function:
{
- const FunctionNode *functionNode =
- static_cast<const FunctionNode *>(node);
+ const FunctionNode *fn = static_cast<const FunctionNode *>(node);
- if (functionNode->metaness() == FunctionNode::Dtor)
- anchorRef = "#dtor." + functionNode->name().mid(1);
+ if (fn->metaness() == FunctionNode::Dtor)
+ anchorRef = "#dtor." + fn->name().mid(1);
- else if (functionNode->associatedProperty())
- return fullDocumentLocation(functionNode->associatedProperty());
+ else if (fn->hasOneAssociatedProperty() && fn->doc().isEmpty())
+ return fullDocumentLocation(fn->firstAssociatedProperty());
- else if (functionNode->overloadNumber() > 1)
- anchorRef = QLatin1Char('#') + cleanRef(functionNode->name())
- + QLatin1Char('-') + QString::number(functionNode->overloadNumber());
+ else if (fn->overloadNumber() > 0)
+ anchorRef = QLatin1Char('#') + cleanRef(fn->name())
+ + QLatin1Char('-') + QString::number(fn->overloadNumber());
else
- anchorRef = QLatin1Char('#') + cleanRef(functionNode->name());
+ anchorRef = QLatin1Char('#') + cleanRef(fn->name());
break;
}
/*
@@ -750,12 +749,12 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
if (node->type() == Node::Document) {
const DocumentNode *dn = static_cast<const DocumentNode *>(node);
- if ((dn->subType() == Node::File) || (dn->subType() == Node::Image)) {
+ if ((dn->docSubtype() == Node::File) || (dn->docSubtype() == Node::Image)) {
quiet = true;
}
}
if (node->doc().isEmpty()) {
- if (!node->isWrapper() && !quiet && !node->isReimp()) { // ### might be unnecessary
+ if (!node->isWrapper() && !quiet && !node->isReimplemented()) { // ### might be unnecessary
node->location().warning(tr("No documentation for '%1'").arg(node->plainFullName()));
}
}
@@ -767,7 +766,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
}
if (!generateText(node->doc().body(), node, marker)) {
- if (node->isReimp())
+ if (node->isReimplemented())
return;
}
@@ -840,9 +839,8 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
}
else if (!(*a).isEmpty() && !documentedParams.contains(*a)) {
bool needWarning = (func->status() > Node::Obsolete);
- if (func->overloadNumber() > 1) {
- FunctionNode *primaryFunc =
- func->parent()->findFunctionNode(func->name());
+ if (func->overloadNumber() > 0) {
+ FunctionNode *primaryFunc = func->parent()->findFunctionNode(func->name());
if (primaryFunc) {
foreach (const Parameter &param,
primaryFunc->parameters()) {
@@ -853,7 +851,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
}
}
}
- if (needWarning && !func->isReimp())
+ if (needWarning && !func->isReimplemented())
node->doc().location().warning(
tr("Undocumented parameter '%1' in %2")
.arg(*a).arg(node->plainFullName()));
@@ -879,7 +877,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
if (dn->isExample()) {
generateExampleFiles(dn, marker);
}
- else if (dn->subType() == Node::File) {
+ else if (dn->docSubtype() == Node::File) {
Text text;
Quoter quoter;
Doc::quoteFromFile(dn->doc().location(), quoter, dn->name());
@@ -891,7 +889,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
}
}
-void Generator::generateClassLikeNode(InnerNode* /* classe */, CodeMarker* /* marker */)
+void Generator::generateClassLikeNode(Aggregate* /* classe */, CodeMarker* /* marker */)
{
}
@@ -920,7 +918,7 @@ void Generator::generateCollectionNode(CollectionNode* , CodeMarker* )
*/
void Generator::generateFileList(const DocumentNode* dn,
CodeMarker* marker,
- Node::SubType subtype,
+ Node::DocSubtype subtype,
const QString& tag)
{
int count = 0;
@@ -931,7 +929,7 @@ void Generator::generateFileList(const DocumentNode* dn,
<< Atom(Atom::ListLeft, openedList.styleString());
foreach (const Node* child, dn->childNodes()) {
- if (child->subType() == subtype) {
+ if (child->docSubtype() == subtype) {
++count;
QString file = child->name();
if (subtype == Node::Image) {
@@ -945,16 +943,10 @@ void Generator::generateFileList(const DocumentNode* dn,
exampleImgExts,
userFriendlyFilePath);
userFriendlyFilePath.truncate(userFriendlyFilePath.lastIndexOf('/'));
-
QString imgOutDir = outDir_ + "/images/used-in-examples/" + userFriendlyFilePath;
if (!dirInfo.mkpath(imgOutDir))
- dn->location().fatal(tr("Cannot create output directory '%1'")
- .arg(imgOutDir));
-
- QString imgOutName = Config::copyFile(dn->location(),
- srcPath,
- file,
- imgOutDir);
+ dn->location().fatal(tr("Cannot create output directory '%1'").arg(imgOutDir));
+ Config::copyFile(dn->location(), srcPath, file, imgOutDir);
}
}
@@ -1030,7 +1022,7 @@ void Generator::generateInherits(const ClassNode *classe, CodeMarker *marker)
/*!
Recursive writing of HTML files from the root \a node.
*/
-void Generator::generateInnerNode(InnerNode* node)
+void Generator::generateAggregate(Aggregate* node)
{
if (!node->url().isNull())
return;
@@ -1041,11 +1033,11 @@ void Generator::generateInnerNode(InnerNode* node)
if (node->isDocumentNode()) {
DocumentNode* docNode = static_cast<DocumentNode*>(node);
- if (docNode->subType() == Node::ExternalPage)
+ if (docNode->docSubtype() == Node::ExternalPage)
return;
- if (docNode->subType() == Node::Image)
+ if (docNode->docSubtype() == Node::Image)
return;
- if (docNode->subType() == Node::Page) {
+ if (docNode->docSubtype() == Node::Page) {
if (node->count() > 0)
qDebug("PAGE %s HAS CHILDREN", qPrintable(docNode->title()));
}
@@ -1115,8 +1107,8 @@ void Generator::generateInnerNode(InnerNode* node)
int i = 0;
while (i < node->childNodes().count()) {
Node *c = node->childNodes().at(i);
- if (c->isInnerNode() && c->access() != Node::Private) {
- generateInnerNode((InnerNode*)c);
+ if (c->isAggregate() && c->access() != Node::Private) {
+ generateAggregate((Aggregate*)c);
}
++i;
}
@@ -1125,7 +1117,7 @@ void Generator::generateInnerNode(InnerNode* node)
/*!
Generate a list of maintainers in the output
*/
-void Generator::generateMaintainerList(const InnerNode* node, CodeMarker* marker)
+void Generator::generateMaintainerList(const Aggregate* node, CodeMarker* marker)
{
QStringList sl = getMetadataElements(node,"maintainer");
@@ -1250,7 +1242,8 @@ void Generator::generateStatus(const Node *node, CodeMarker *marker)
Text text;
switch (node->status()) {
- case Node::Commendable:
+ case Node::Active:
+ // Do nothing.
break;
case Node::Preliminary:
text << Atom::ParaLeft
@@ -1263,19 +1256,19 @@ void Generator::generateStatus(const Node *node, CodeMarker *marker)
break;
case Node::Deprecated:
text << Atom::ParaLeft;
- if (node->isInnerNode())
+ if (node->isAggregate())
text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD);
text << "This " << typeString(node) << " is deprecated.";
- if (node->isInnerNode())
+ if (node->isAggregate())
text << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD);
text << Atom::ParaRight;
break;
case Node::Obsolete:
text << Atom::ParaLeft;
- if (node->isInnerNode())
+ if (node->isAggregate())
text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD);
text << "This " << typeString(node) << " is obsolete.";
- if (node->isInnerNode())
+ if (node->isAggregate())
text << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD);
text << " It is provided to keep old source code working. "
<< "We strongly advise against "
@@ -1283,7 +1276,7 @@ void Generator::generateStatus(const Node *node, CodeMarker *marker)
break;
case Node::Compat:
// reimplemented in HtmlGenerator subclass
- if (node->isInnerNode()) {
+ if (node->isAggregate()) {
text << Atom::ParaLeft
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD)
<< "This "
@@ -1382,8 +1375,8 @@ void Generator::generateThreadSafeness(const Node *node, CodeMarker *marker)
<< Atom(Atom::FormattingRight,ATOM_FORMATTING_BOLD)
<< " ";
- if (node->isInnerNode()) {
- const InnerNode* innerNode = static_cast<const InnerNode*>(node);
+ if (node->isAggregate()) {
+ const Aggregate* innerNode = static_cast<const Aggregate*>(node);
text << "All functions in this "
<< typeString(node)
<< " are ";
@@ -1483,11 +1476,80 @@ void Generator::generateThreadSafeness(const Node *node, CodeMarker *marker)
}
/*!
- Traverses the current tree to generate all the documentation.
+ If the node is an overloaded signal, and a node with an example on how to connect to it
+ */
+void Generator::generateOverloadedSignal(const Node* node, CodeMarker* marker)
+{
+ if (node->type() != Node::Function)
+ return;
+ const FunctionNode *func = static_cast<const FunctionNode *>(node);
+ if (func->metaness() != FunctionNode::Signal)
+ return;
+ if (node->parent()->overloads(node->name()).count() <= 1)
+ return;
+
+
+ // Compute a friendly name for the object of that instance.
+ // e.g: "QAbstractSocket" -> "abstractSocket"
+ QString objectName = node->parent()->name();
+ if (objectName.size() >= 2) {
+ if (objectName[0] == 'Q')
+ objectName = objectName.mid(1);
+ objectName[0] = objectName[0].toLower();
+ }
+
+
+ // We have an overloaded signal, show an example
+ QString code = "connect(" + objectName + ", static_cast<" + func->returnType()
+ + "(" + func->parent()->name() + "::*)(";
+ for (int i = 0; i < func->parameters().size(); ++i) {
+ if (i != 0)
+ code += ", ";
+ const Parameter &p = func->parameters().at(i);
+ code += p.leftType() + p.rightType();
+ }
+
+ code += ")";
+ if (func->isConst())
+ code += " const";
+ code += ">(&" + func->parent()->name() + "::" + func->name() + "),\n [=](";
+
+ for (int i = 0; i < func->parameters().size(); ++i) {
+ if (i != 0)
+ code += ", ";
+ const Parameter &p = func->parameters().at(i);
+ code += p.leftType();
+ if (code[code.size()-1].isLetterOrNumber())
+ code += " ";
+ code += p.name() + p.rightType();
+ }
+
+ code += "){ /* ... */ });";
+
+ Text text;
+ text << Atom::ParaLeft
+ << Atom(Atom::FormattingLeft,ATOM_FORMATTING_BOLD)
+ << "Note:"
+ << Atom(Atom::FormattingRight,ATOM_FORMATTING_BOLD)
+ << "Signal "
+ << Atom(Atom::FormattingLeft,ATOM_FORMATTING_ITALIC)
+ << node->name()
+ << Atom(Atom::FormattingRight,ATOM_FORMATTING_ITALIC)
+ << " is overloaded in this class. "
+ "To connect to this one using the function pointer syntax, you must "
+ "specify the signal type in a static cast, as shown in this example:"
+ << Atom(Atom::Code, marker->markedUpCode(code, node, func->location()));
+
+ generateText(text, node, marker);
+}
+
+
+/*!
+ Traverses the database recursivly to generate all the documentation.
*/
void Generator::generateDocs()
{
- generateInnerNode(qdb_->primaryTreeRoot());
+ generateAggregate(qdb_->primaryTreeRoot());
}
Generator *Generator::generatorForFormat(const QString& format)
@@ -1510,7 +1572,7 @@ Generator *Generator::generatorForFormat(const QString& format)
i.e. Once you call this function for a particular \a t,
you consume \a t.
*/
-QString Generator::getMetadataElement(const InnerNode* inner, const QString& t)
+QString Generator::getMetadataElement(const Aggregate* inner, const QString& t)
{
QString s;
QStringMultiMap& metaTagMap = const_cast<QStringMultiMap&>(inner->doc().metaTagMap());
@@ -1531,7 +1593,7 @@ QString Generator::getMetadataElement(const InnerNode* inner, const QString& t)
having the key \a t are erased. i.e. Once you call this
function for a particular \a t, you consume \a t.
*/
-QStringList Generator::getMetadataElements(const InnerNode* inner, const QString& t)
+QStringList Generator::getMetadataElements(const Aggregate* inner, const QString& t)
{
QStringList s;
QStringMultiMap& metaTagMap = const_cast<QStringMultiMap&>(inner->doc().metaTagMap());
@@ -1626,12 +1688,6 @@ void Generator::initialize(const Config &config)
if (!dirInfo.exists(outDir_ + "/images") && !dirInfo.mkdir(outDir_ + "/images"))
config.lastLocation().fatal(tr("Cannot create images directory '%1'").arg(outDir_ + "/images"));
- if (!dirInfo.exists(outDir_ + "/images/used-in-examples") && !dirInfo.mkdir(outDir_ + "/images/used-in-examples"))
- config.lastLocation().fatal(tr("Cannot create images used in examples directory '%1'").arg(outDir_ + "/images/used-in-examples"));
- if (!dirInfo.exists(outDir_ + "/scripts") && !dirInfo.mkdir(outDir_ + "/scripts"))
- config.lastLocation().fatal(tr("Cannot create scripts directory '%1'").arg(outDir_ + "/scripts"));
- if (!dirInfo.exists(outDir_ + "/style") && !dirInfo.mkdir(outDir_ + "/style"))
- config.lastLocation().fatal(tr("Cannot create style directory '%1'").arg(outDir_ + "/style"));
}
imageFiles = config.getCanonicalPathList(CONFIG_IMAGES);
@@ -1670,23 +1726,41 @@ void Generator::initialize(const Config &config)
// Documentation template handling
QStringList scripts = config.getCanonicalPathList((*g)->format()+Config::dot+CONFIG_SCRIPTS, true);
- e = scripts.constBegin();
- while (e != scripts.constEnd()) {
- QString filePath = *e;
- if (!filePath.isEmpty())
- Config::copyFile(config.lastLocation(), filePath, filePath,
- (*g)->outputDir() + "/scripts");
- ++e;
+ if (!scripts.isEmpty()) {
+ QDir dirInfo;
+ if (!dirInfo.exists(outDir_ + "/scripts") && !dirInfo.mkdir(outDir_ + "/scripts")) {
+ config.lastLocation().fatal(tr("Cannot create scripts directory '%1'")
+ .arg(outDir_ + "/scripts"));
+ }
+ else {
+ e = scripts.constBegin();
+ while (e != scripts.constEnd()) {
+ QString filePath = *e;
+ if (!filePath.isEmpty())
+ Config::copyFile(config.lastLocation(), filePath, filePath,
+ (*g)->outputDir() + "/scripts");
+ ++e;
+ }
+ }
}
QStringList styles = config.getCanonicalPathList((*g)->format()+Config::dot+CONFIG_STYLESHEETS, true);
- e = styles.constBegin();
- while (e != styles.constEnd()) {
- QString filePath = *e;
- if (!filePath.isEmpty())
- Config::copyFile(config.lastLocation(), filePath, filePath,
- (*g)->outputDir() + "/style");
- ++e;
+ if (!styles.isEmpty()) {
+ QDir dirInfo;
+ if (!dirInfo.exists(outDir_ + "/style") && !dirInfo.mkdir(outDir_ + "/style")) {
+ config.lastLocation().fatal(tr("Cannot create style directory '%1'")
+ .arg(outDir_ + "/style"));
+ }
+ else {
+ e = styles.constBegin();
+ while (e != styles.constEnd()) {
+ QString filePath = *e;
+ if (!filePath.isEmpty())
+ Config::copyFile(config.lastLocation(), filePath, filePath,
+ (*g)->outputDir() + "/style");
+ ++e;
+ }
+ }
}
}
++g;
@@ -1768,7 +1842,7 @@ void Generator::initializeGenerator(const Config& config)
singleExec_ = config.getBool(CONFIG_SINGLEEXEC);
}
-bool Generator::matchAhead(const Atom *atom, Atom::Type expectedAtomType)
+bool Generator::matchAhead(const Atom *atom, Atom::AtomType expectedAtomType)
{
return atom->next() != 0 && atom->next()->type() == expectedAtomType;
}
@@ -1915,7 +1989,7 @@ void Generator::singularPlural(Text& text, const NodeList& nodes)
text << " are";
}
-int Generator::skipAtoms(const Atom *atom, Atom::Type type) const
+int Generator::skipAtoms(const Atom *atom, Atom::AtomType type) const
{
int skipAhead = 0;
atom = atom->next();
@@ -1945,7 +2019,7 @@ void Generator::supplementAlsoList(const Node *node, QList<Text> &alsoList)
{
if (node->type() == Node::Function) {
const FunctionNode *func = static_cast<const FunctionNode *>(node);
- if (func->overloadNumber() == 1) {
+ if (func->overloadNumber() == 0) {
QString alternateName;
const FunctionNode *alternateFunc = 0;
diff --git a/src/tools/qdoc/generator.h b/src/tools/qdoc/generator.h
index 9a1672dac4..e4bcd29e52 100644
--- a/src/tools/qdoc/generator.h
+++ b/src/tools/qdoc/generator.h
@@ -106,7 +106,7 @@ public:
static QString cleanRef(const QString& ref);
protected:
- virtual void beginSubPage(const InnerNode* node, const QString& fileName);
+ virtual void beginSubPage(const Aggregate* node, const QString& fileName);
virtual void endSubPage();
virtual QString fileBase(const Node* node) const;
virtual QString fileExtension() const = 0;
@@ -114,15 +114,15 @@ protected:
virtual void generateAlsoList(const Node *node, CodeMarker *marker);
virtual int generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker);
virtual void generateBody(const Node *node, CodeMarker *marker);
- virtual void generateClassLikeNode(InnerNode* inner, CodeMarker* marker);
+ virtual void generateClassLikeNode(Aggregate* inner, CodeMarker* marker);
virtual void generateQmlTypePage(QmlTypeNode* , CodeMarker* ) { }
virtual void generateQmlBasicTypePage(QmlBasicTypeNode* , CodeMarker* ) { }
virtual void generateDocumentNode(DocumentNode* dn, CodeMarker* marker);
virtual void generateCollectionNode(CollectionNode* cn, CodeMarker* marker);
virtual void generateInheritedBy(const ClassNode *classe, CodeMarker *marker);
virtual void generateInherits(const ClassNode *classe, CodeMarker *marker);
- virtual void generateInnerNode(InnerNode* node);
- virtual void generateMaintainerList(const InnerNode* node, CodeMarker* marker);
+ virtual void generateAggregate(Aggregate* node);
+ virtual void generateMaintainerList(const Aggregate* node, CodeMarker* marker);
virtual void generateQmlInheritedBy(const QmlTypeNode* qcn, CodeMarker* marker);
virtual void generateQmlInherits(QmlTypeNode* qcn, CodeMarker* marker);
virtual bool generateQmlText(const Text& text,
@@ -131,10 +131,10 @@ protected:
const QString& qmlName);
virtual bool generateText(const Text& text, const Node *relative, CodeMarker *marker);
virtual QString imageFileName(const Node *relative, const QString& fileBase);
- virtual int skipAtoms(const Atom *atom, Atom::Type type) const;
+ virtual int skipAtoms(const Atom *atom, Atom::AtomType type) const;
virtual QString typeString(const Node *node);
- static bool matchAhead(const Atom *atom, Atom::Type expectedAtomType);
+ static bool matchAhead(const Atom *atom, Atom::AtomType expectedAtomType);
static QString outputPrefix(const QString &nodeType);
static void singularPlural(Text& text, const NodeList& nodes);
static void supplementAlsoList(const Node *node, QList<Text> &alsoList);
@@ -153,14 +153,15 @@ protected:
void generateExampleFiles(const DocumentNode *dn, CodeMarker *marker);
void generateFileList(const DocumentNode* dn,
CodeMarker* marker,
- Node::SubType subtype,
+ Node::DocSubtype subtype,
const QString& tag);
void generateSince(const Node *node, CodeMarker *marker);
void generateStatus(const Node *node, CodeMarker *marker);
void generatePrivateSignalNote(const Node* node, CodeMarker* marker);
void generateThreadSafeness(const Node *node, CodeMarker *marker);
- QString getMetadataElement(const InnerNode* inner, const QString& t);
- QStringList getMetadataElements(const InnerNode* inner, const QString& t);
+ QString getMetadataElement(const Aggregate* inner, const QString& t);
+ QStringList getMetadataElements(const Aggregate* inner, const QString& t);
+ void generateOverloadedSignal(const Node *node, CodeMarker *marker);
QString indent(int level, const QString& markedCode);
QTextStream& out();
QString outFileName();
diff --git a/src/tools/qdoc/helpprojectwriter.cpp b/src/tools/qdoc/helpprojectwriter.cpp
index 90b1d9cfe3..e98b2f5cb1 100644
--- a/src/tools/qdoc/helpprojectwriter.cpp
+++ b/src/tools/qdoc/helpprojectwriter.cpp
@@ -107,13 +107,13 @@ void HelpProjectWriter::reset(const Config &config,
subproject.sortPages = config.getBool(subprefix + "sortPages");
subproject.type = config.getString(subprefix + "type");
readSelectors(subproject, config.getStringList(subprefix + "selectors"));
- project.subprojects[name] = subproject;
+ project.subprojects.append(subproject);
}
if (project.subprojects.isEmpty()) {
SubProject subproject;
readSelectors(subproject, config.getStringList(prefix + "selectors"));
- project.subprojects.insert(QString(), subproject);
+ project.subprojects.insert(0, subproject);
}
projects.append(project);
@@ -122,7 +122,7 @@ void HelpProjectWriter::reset(const Config &config,
void HelpProjectWriter::readSelectors(SubProject &subproject, const QStringList &selectors)
{
- QHash<QString, Node::Type> typeHash;
+ QHash<QString, Node::NodeType> typeHash;
typeHash["namespace"] = Node::Namespace;
typeHash["class"] = Node::Class;
typeHash["fake"] = Node::Document;
@@ -142,14 +142,14 @@ void HelpProjectWriter::readSelectors(SubProject &subproject, const QStringList
typeHash["qmlclass"] = Node::QmlType;
typeHash["qmlbasictype"] = Node::QmlBasicType;
- QHash<QString, Node::SubType> subTypeHash;
- subTypeHash["example"] = Node::Example;
- subTypeHash["headerfile"] = Node::HeaderFile;
- subTypeHash["file"] = Node::File;
- subTypeHash["page"] = Node::Page;
- subTypeHash["externalpage"] = Node::ExternalPage;
+ QHash<QString, Node::DocSubtype> docSubtypeHash;
+ docSubtypeHash["example"] = Node::Example;
+ docSubtypeHash["headerfile"] = Node::HeaderFile;
+ docSubtypeHash["file"] = Node::File;
+ docSubtypeHash["page"] = Node::Page;
+ docSubtypeHash["externalpage"] = Node::ExternalPage;
- QSet<Node::SubType> allSubTypes = QSet<Node::SubType>::fromList(subTypeHash.values());
+ QSet<Node::DocSubtype> allSubTypes = QSet<Node::DocSubtype>::fromList(docSubtypeHash.values());
foreach (const QString &selector, selectors) {
QStringList pieces = selector.split(QLatin1Char(':'));
@@ -161,13 +161,13 @@ void HelpProjectWriter::readSelectors(SubProject &subproject, const QStringList
QString lower = pieces[0].toLower();
pieces = pieces[1].split(QLatin1Char(','));
if (typeHash.contains(lower)) {
- QSet<Node::SubType> subTypes;
+ QSet<Node::DocSubtype> docSubtypes;
for (int i = 0; i < pieces.size(); ++i) {
QString lower = pieces[i].toLower();
- if (subTypeHash.contains(lower))
- subTypes.insert(subTypeHash[lower]);
+ if (docSubtypeHash.contains(lower))
+ docSubtypes.insert(docSubtypeHash[lower]);
}
- subproject.selectors[typeHash[lower]] = subTypes;
+ subproject.selectors[typeHash[lower]] = docSubtypes;
}
}
}
@@ -260,25 +260,25 @@ bool HelpProjectWriter::generateSection(HelpProject &project,
// Only add nodes to the set for each subproject if they match a selector.
// Those that match will be listed in the table of contents.
- foreach (const QString &name, project.subprojects.keys()) {
- SubProject subproject = project.subprojects[name];
+ for (int i = 0; i < project.subprojects.length(); i++) {
+ SubProject subproject = project.subprojects[i];
// No selectors: accept all nodes.
if (subproject.selectors.isEmpty()) {
- project.subprojects[name].nodes[objName] = node;
+ project.subprojects[i].nodes[objName] = node;
}
else if (subproject.selectors.contains(node->type())) {
// Accept only the node types in the selectors hash.
if (node->type() != Node::Document)
- project.subprojects[name].nodes[objName] = node;
+ project.subprojects[i].nodes[objName] = node;
else {
// Accept only fake nodes with subtypes contained in the selector's
// mask.
const DocumentNode *docNode = static_cast<const DocumentNode *>(node);
- if (subproject.selectors[node->type()].contains(docNode->subType()) &&
- docNode->subType() != Node::ExternalPage &&
+ if (subproject.selectors[node->type()].contains(docNode->docSubtype()) &&
+ docNode->docSubtype() != Node::ExternalPage &&
!docNode->fullTitle().isEmpty()) {
- project.subprojects[name].nodes[objName] = node;
+ project.subprojects[i].nodes[objName] = node;
}
}
}
@@ -417,11 +417,11 @@ bool HelpProjectWriter::generateSection(HelpProject &project,
// attributes.
case Node::Document: {
const DocumentNode *docNode = static_cast<const DocumentNode*>(node);
- if (docNode->subType() != Node::ExternalPage &&
- docNode->subType() != Node::Image &&
+ if (docNode->docSubtype() != Node::ExternalPage &&
+ docNode->docSubtype() != Node::Image &&
!docNode->fullTitle().isEmpty()) {
- if (docNode->subType() != Node::File) {
+ if (docNode->docSubtype() != Node::File) {
if (docNode->doc().hasKeywords()) {
foreach (const Atom *keyword, docNode->doc().keywords()) {
if (!keyword->string().isEmpty()) {
@@ -467,13 +467,13 @@ void HelpProjectWriter::generateSections(HelpProject &project,
/*
Don't include index nodes in the help file. Or DITA map nodes.
*/
- if (node->isIndexNode() || node->subType() == Node::DitaMap)
+ if (node->isIndexNode() || node->docSubtype() == Node::DitaMap)
return;
if (!generateSection(project, writer, node))
return;
- if (node->isInnerNode()) {
- const InnerNode *inner = static_cast<const InnerNode *>(node);
+ if (node->isAggregate()) {
+ const Aggregate *inner = static_cast<const Aggregate *>(node);
// Ensure that we don't visit nodes more than once.
QMap<QString, const Node*> childMap;
@@ -497,7 +497,7 @@ void HelpProjectWriter::generateSections(HelpProject &project,
because The Qml/Js Property Group is
an actual documented thing.
*/
- const InnerNode* inner = static_cast<const InnerNode*>(childNode);
+ const Aggregate* inner = static_cast<const Aggregate*>(childNode);
foreach (const Node* n, inner->childNodes()) {
if (n->access() == Node::Private)
continue;
@@ -626,7 +626,7 @@ void HelpProjectWriter::writeNode(HelpProject &project, QXmlStreamWriter &writer
writer.writeAttribute("ref", href);
writer.writeAttribute("title", docNode->fullTitle());
- if (docNode->subType() == Node::HeaderFile)
+ if (docNode->docSubtype() == Node::HeaderFile)
addMembers(project, writer, node);
writer.writeEndElement(); // section
@@ -713,8 +713,8 @@ void HelpProjectWriter::generateProject(HelpProject &project)
generateSections(project, writer, rootNode);
- foreach (const QString &name, project.subprojects.keys()) {
- SubProject subproject = project.subprojects[name];
+ for (int i = 0; i < project.subprojects.length(); i++) {
+ SubProject subproject = project.subprojects[i];
if (subproject.type == QLatin1String("manual")) {
@@ -769,13 +769,12 @@ void HelpProjectWriter::generateProject(HelpProject &project)
} else {
- if (!name.isEmpty()) {
- writer.writeStartElement("section");
- QString indexPath = gen_->fullDocumentLocation(qdb_->findNodeForTarget(subproject.indexTitle, 0),
+ writer.writeStartElement("section");
+ QString indexPath = gen_->fullDocumentLocation(qdb_->findNodeForTarget(subproject.indexTitle, 0),
false);
- writer.writeAttribute("ref", indexPath);
- writer.writeAttribute("title", subproject.title);
- }
+ writer.writeAttribute("ref", indexPath);
+ writer.writeAttribute("title", subproject.title);
+
if (subproject.sortPages) {
QStringList titles = subproject.nodes.keys();
titles.sort();
@@ -815,8 +814,7 @@ void HelpProjectWriter::generateProject(HelpProject &project)
}
}
- if (!name.isEmpty())
- writer.writeEndElement(); // section
+ writer.writeEndElement(); // section
}
}
diff --git a/src/tools/qdoc/helpprojectwriter.h b/src/tools/qdoc/helpprojectwriter.h
index efc2596296..7b3e8b1e75 100644
--- a/src/tools/qdoc/helpprojectwriter.h
+++ b/src/tools/qdoc/helpprojectwriter.h
@@ -50,7 +50,7 @@ struct SubProject
{
QString title;
QString indexTitle;
- QHash<Node::Type, QSet<DocumentNode::SubType> > selectors;
+ QHash<Node::NodeType, QSet<DocumentNode::DocSubtype> > selectors;
bool sortPages;
QString type;
QHash<QString, const Node *> nodes;
@@ -70,7 +70,7 @@ struct HelpProject
QSet<QString> filterAttributes;
QHash<QString, QSet<QString> > customFilters;
QSet<QString> excluded;
- QMap<QString, SubProject> subprojects;
+ QList<SubProject> subprojects;
QHash<const Node *, QSet<Node::Status> > memberStatus;
bool includeIndexNodes;
};
diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp
index 10b7242c18..3dbb5a589f 100644
--- a/src/tools/qdoc/htmlgenerator.cpp
+++ b/src/tools/qdoc/htmlgenerator.cpp
@@ -474,14 +474,6 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
static bool in_para = false;
switch (atom->type()) {
- case Atom::AbstractLeft:
- if (relative)
- relative->doc().location().warning(tr("\abstract is not implemented."));
- else
- Location::information(tr("\abstract is not implemented."));
- break;
- case Atom::AbstractRight:
- break;
case Atom::AutoLink:
case Atom::NavAutoLink:
if (!inLink_ && !inContents_ && !inSectionHeading_) {
@@ -1336,7 +1328,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
/*!
Generate a reference page for a C++ class or a C++ namespace.
*/
-void HtmlGenerator::generateClassLikeNode(InnerNode* inner, CodeMarker* marker)
+void HtmlGenerator::generateClassLikeNode(Aggregate* inner, CodeMarker* marker)
{
QList<Section> sections;
QList<Section>::ConstIterator s;
@@ -1485,7 +1477,7 @@ void HtmlGenerator::generateClassLikeNode(InnerNode* inner, CodeMarker* marker)
const FunctionNode *func = reinterpret_cast<const FunctionNode *>(*m);
if (func->metaness() == FunctionNode::Ctor ||
func->metaness() == FunctionNode::Dtor ||
- func->overloadNumber() != 1)
+ func->overloadNumber() != 0)
names.clear();
}
else if ((*m)->type() == Node::Property) {
@@ -1644,7 +1636,7 @@ void HtmlGenerator::generateDocumentNode(DocumentNode* dn, CodeMarker* marker)
is DITA map page, write the node's contents as a dita
map and return without doing anything else.
*/
- if (dn->subType() == Node::Page && dn->pageType() == Node::DitaMapPage) {
+ if (dn->docSubtype() == Node::Page && dn->pageType() == Node::DitaMapPage) {
const DitaMapNode* dmn = static_cast<const DitaMapNode*>(dn);
writeDitaMap(dmn);
return;
@@ -1670,7 +1662,7 @@ void HtmlGenerator::generateDocumentNode(DocumentNode* dn, CodeMarker* marker)
dn,
marker);
- if (dn->subType() == Node::HeaderFile) {
+ if (dn->docSubtype() == Node::HeaderFile) {
// Generate brief text and status for modules.
generateBrief(dn, marker);
generateStatus(dn, marker);
@@ -2087,7 +2079,7 @@ void HtmlGenerator::generateFooter(const Node *node)
Lists the required imports and includes in a table.
The number of rows is known, so this path is simpler than the generateSection() path.
*/
-void HtmlGenerator::generateRequisites(InnerNode *inner, CodeMarker *marker)
+void HtmlGenerator::generateRequisites(Aggregate *inner, CodeMarker *marker)
{
QMap<QString, Text> requisites;
Text text;
@@ -2359,7 +2351,7 @@ void HtmlGenerator::generateBrief(const Node *node, CodeMarker *marker,
}
}
-void HtmlGenerator::generateIncludes(const InnerNode *inner, CodeMarker *marker)
+void HtmlGenerator::generateIncludes(const Aggregate *inner, CodeMarker *marker)
{
if (!inner->includes().isEmpty()) {
out() << "<pre class=\"cpp\">"
@@ -2518,7 +2510,7 @@ void HtmlGenerator::generateSidebar() {
out() << "</div>\n";
}
-QString HtmlGenerator::generateListOfAllMemberFile(const InnerNode *inner,
+QString HtmlGenerator::generateListOfAllMemberFile(const Aggregate *inner,
CodeMarker *marker)
{
QList<Section> sections;
@@ -2613,7 +2605,7 @@ QString HtmlGenerator::generateAllQmlMembersFile(QmlTypeNode* qml_cn, CodeMarker
return fileName;
}
-QString HtmlGenerator::generateLowStatusMemberFile(InnerNode *inner,
+QString HtmlGenerator::generateLowStatusMemberFile(Aggregate *inner,
CodeMarker *marker,
CodeMarker::Status status)
{
@@ -3345,7 +3337,7 @@ void HtmlGenerator::generateSectionList(const Section& section,
void HtmlGenerator::generateSectionInheritedList(const Section& section, const Node *relative)
{
- QList<QPair<InnerNode *, int> >::ConstIterator p = section.inherited.constBegin();
+ QList<QPair<Aggregate *, int> >::ConstIterator p = section.inherited.constBegin();
while (p != section.inherited.constEnd()) {
out() << "<li class=\"fn\">";
out() << (*p).second << ' ';
@@ -3560,7 +3552,8 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode,
bool handled = false;
for (int k = 0; k != 18; ++k) {
const QString & tag = spanTags[2 * k];
- if (tag == QStringRef(&src, i, tag.length())) {
+ if (i + tag.length() <= src.length() &&
+ tag == QStringRef(&src, i, tag.length())) {
html += spanTags[2 * k + 1];
i += tag.length();
handled = true;
@@ -3686,7 +3679,7 @@ QString HtmlGenerator::fileBase(const Node *node) const
result = Generator::fileBase(node);
- if (!node->isInnerNode()) {
+ if (!node->isAggregate()) {
switch (node->status()) {
case Node::Compat:
result += "-compat";
@@ -3704,9 +3697,9 @@ QString HtmlGenerator::fileBase(const Node *node) const
QString HtmlGenerator::fileName(const Node *node)
{
if (node->type() == Node::Document) {
- if (static_cast<const DocumentNode *>(node)->subType() == Node::ExternalPage)
+ if (static_cast<const DocumentNode *>(node)->docSubtype() == Node::ExternalPage)
return node->name();
- if (static_cast<const DocumentNode *>(node)->subType() == Node::Image)
+ if (static_cast<const DocumentNode *>(node)->docSubtype() == Node::Image)
return node->name();
}
return Generator::fileName(node);
@@ -3737,12 +3730,12 @@ QString HtmlGenerator::refForNode(const Node *node)
break;
case Node::Function:
func = static_cast<const FunctionNode *>(node);
- if (func->associatedProperty()) {
- return refForNode(func->associatedProperty());
+ if (func->hasOneAssociatedProperty() && func->doc().isEmpty()) {
+ return refForNode(func->firstAssociatedProperty());
}
else {
ref = func->name();
- if (func->overloadNumber() != 1)
+ if (func->overloadNumber() != 0)
ref += QLatin1Char('-') + QString::number(func->overloadNumber());
}
break;
@@ -3767,7 +3760,7 @@ QString HtmlGenerator::refForNode(const Node *node)
case Node::QmlMethod:
func = static_cast<const FunctionNode *>(node);
ref = func->name() + "-method";
- if (func->overloadNumber() != 1)
+ if (func->overloadNumber() != 0)
ref += QLatin1Char('-') + QString::number(func->overloadNumber());
break;
case Node::Variable:
@@ -3831,7 +3824,7 @@ QString HtmlGenerator::getAutoLink(const Atom *atom, const Node *relative, const
QString link = (*node)->url();
if (link.isEmpty()) {
link = linkForNode(*node, relative);
- if ((*node)->subType() == Node::Image)
+ if ((*node)->docSubtype() == Node::Image)
link = "images/used-in-examples/" + link;
if (!ref.isEmpty())
link += QLatin1Char('#') + ref;
@@ -3872,7 +3865,7 @@ QString HtmlGenerator::linkForNode(const Node *node, const Node *relative)
}
QString link = fn;
- if (!node->isInnerNode() || node->isQmlPropertyGroup() || node->isJsPropertyGroup()) {
+ if (!node->isAggregate() || node->isQmlPropertyGroup() || node->isJsPropertyGroup()) {
QString ref = refForNode(node);
if (relative && fn == fileName(relative) && ref == refForNode(relative))
return QString();
@@ -3923,27 +3916,25 @@ void HtmlGenerator::generateFullName(const Node *apparentNode, const Node *relat
}
void HtmlGenerator::generateDetailedMember(const Node *node,
- const InnerNode *relative,
+ const Aggregate *relative,
CodeMarker *marker)
{
- const EnumNode *enume;
-
+ const EnumNode *etn;
#ifdef GENERATE_MAC_REFS
generateMacRef(node, marker);
#endif
generateExtractionMark(node, MemberMark);
generateKeywordAnchors(node);
QString nodeRef = refForNode(node);
- if (node->type() == Node::Enum
- && (enume = static_cast<const EnumNode *>(node))->flagsType()) {
+ if (node->isEnumType() && (etn = static_cast<const EnumNode *>(node))->flagsType()) {
#ifdef GENERATE_MAC_REFS
- generateMacRef(enume->flagsType(), marker);
+ generateMacRef(etn->flagsType(), marker);
#endif
out() << "<h3 class=\"flags\" id=\"" << nodeRef << "\">";
out() << "<a name=\"" + nodeRef + "\"></a>";
- generateSynopsis(enume, relative, marker, CodeMarker::Detailed);
+ generateSynopsis(etn, relative, marker, CodeMarker::Detailed);
out() << "<br/>";
- generateSynopsis(enume->flagsType(),
+ generateSynopsis(etn->flagsType(),
relative,
marker,
CodeMarker::Detailed);
@@ -3958,10 +3949,11 @@ void HtmlGenerator::generateDetailedMember(const Node *node,
generateStatus(node, marker);
generateBody(node, marker);
+ generateOverloadedSignal(node, marker);
generateThreadSafeness(node, marker);
generateSince(node, marker);
- if (node->type() == Node::Property) {
+ if (node->isProperty()) {
const PropertyNode *property = static_cast<const PropertyNode *>(node);
Section section;
@@ -3987,16 +3979,17 @@ void HtmlGenerator::generateDetailedMember(const Node *node,
const FunctionNode* fn = static_cast<const FunctionNode*>(node);
if (fn->isPrivateSignal())
generatePrivateSignalNote(node, marker);
+ generateAssociatedPropertyNotes(fn);
}
- else if (node->type() == Node::Enum) {
- const EnumNode *enume = static_cast<const EnumNode *>(node);
- if (enume->flagsType()) {
- out() << "<p>The " << protectEnc(enume->flagsType()->name())
+ else if (node->isEnumType()) {
+ const EnumNode *etn = static_cast<const EnumNode *>(node);
+ if (etn->flagsType()) {
+ out() << "<p>The " << protectEnc(etn->flagsType()->name())
<< " type is a typedef for "
<< "<a href=\"" << qflagsHref_ << "\">QFlags</a>&lt;"
- << protectEnc(enume->name())
+ << protectEnc(etn->name())
<< "&gt;. It stores an OR combination of "
- << protectEnc(enume->name())
+ << protectEnc(etn->name())
<< " values.</p>\n";
}
}
@@ -4053,7 +4046,7 @@ void HtmlGenerator::generateStatus(const Node *node, CodeMarker *marker)
switch (node->status()) {
case Node::Obsolete:
- if (node->isInnerNode())
+ if (node->isAggregate())
Generator::generateStatus(node, marker);
break;
case Node::Compat:
@@ -4166,7 +4159,7 @@ void HtmlGenerator::generateQmlSummary(const Section& section,
on a QML element reference page.
*/
void HtmlGenerator::generateDetailedQmlMember(Node *node,
- const InnerNode *relative,
+ const Aggregate *relative,
CodeMarker *marker)
{
QmlPropertyNode* qpn = 0;
@@ -4371,8 +4364,8 @@ void HtmlGenerator::generateExtractionMark(const Node *node, ExtractionMarkType
if (markType == MemberMark) {
if (node->type() == Node::Function) {
const FunctionNode *func = static_cast<const FunctionNode *>(node);
- if (!func->associatedProperty()) {
- if (func->overloadNumber() == 1)
+ if (!func->hasAssociatedProperties()) {
+ if (func->overloadNumber() == 0)
out() << "[overload1]";
out() << "$$$" + func->name() + func->rawParameters().remove(' ');
}
@@ -4481,7 +4474,7 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString
writer.writeAttribute("docUrl", docUrl);
QStringList proFiles;
foreach (const Node* child, en->childNodes()) {
- if (child->subType() == Node::File) {
+ if (child->docSubtype() == Node::File) {
QString file = child->name();
if (file.endsWith(".pro") || file.endsWith(".qmlproject")) {
proFiles << file;
@@ -4608,7 +4601,7 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString
QString ename = en->name().mid(en->name().lastIndexOf('/')+1);
QMap<int, const Node*> filesToOpen;
foreach (const Node* child, en->childNodes()) {
- if (child->subType() == Node::File) {
+ if (child->docSubtype() == Node::File) {
QFileInfo fileInfo(child->name());
QString fileName = fileInfo.fileName().toLower();
// open .qml, .cpp and .h files with a
@@ -4693,7 +4686,7 @@ void HtmlGenerator::readManifestMetaContent(const Config &config)
subtype: QML class
subtype: QML module
*/
-void HtmlGenerator::reportOrphans(const InnerNode* parent)
+void HtmlGenerator::reportOrphans(const Aggregate* parent)
{
const NodeList& children = parent->childNodes();
if (children.size() == 0)
@@ -4729,7 +4722,7 @@ void HtmlGenerator::reportOrphans(const InnerNode* parent)
case Node::QmlModule:
break;
case Node::Document:
- switch (child->subType()) {
+ switch (child->docSubtype()) {
case Node::Example:
break;
case Node::HeaderFile:
@@ -4819,7 +4812,7 @@ QXmlStreamWriter& HtmlGenerator::xmlWriter()
It also ensures that a GUID map is created for the output file.
*/
-void HtmlGenerator::beginDitamapPage(const InnerNode* node, const QString& fileName)
+void HtmlGenerator::beginDitamapPage(const Aggregate* node, const QString& fileName)
{
Generator::beginSubPage(node,fileName);
QXmlStreamWriter* writer = new QXmlStreamWriter(out().device());
@@ -4891,4 +4884,37 @@ void HtmlGenerator::writeDitaRefs(const DitaRefList& ditarefs)
}
}
+/*!
+ Generates bold Note lines that explain how function \a fn
+ is associated with each of its associated properties.
+ */
+void HtmlGenerator::generateAssociatedPropertyNotes(const FunctionNode* fn)
+{
+ if (fn->hasAssociatedProperties()) {
+ out() << "<p><b>Note:</b> ";
+ foreach (const PropertyNode* pn, fn->associatedProperties()) {
+ QString msg;
+ switch (pn->role(fn)) {
+ case PropertyNode::Getter:
+ msg = QStringLiteral("Getter function ");
+ break;
+ case PropertyNode::Setter:
+ msg = QStringLiteral("Setter function ");
+ break;
+ case PropertyNode::Resetter:
+ msg = QStringLiteral("Resetter function ");
+ break;
+ case PropertyNode::Notifier:
+ msg = QStringLiteral("Notifier signal ");
+ break;
+ default:
+ break;
+ }
+ QString link = linkForNode(pn, 0);
+ out() << msg << "for property <a href=\"" << link << "\">" << pn->name() << "</a>. ";
+ }
+ out() << "</p>";
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/tools/qdoc/htmlgenerator.h b/src/tools/qdoc/htmlgenerator.h
index 4a2e158252..6a550c2b39 100644
--- a/src/tools/qdoc/htmlgenerator.h
+++ b/src/tools/qdoc/htmlgenerator.h
@@ -94,7 +94,7 @@ protected:
virtual int generateAtom(const Atom *atom,
const Node *relative,
CodeMarker *marker) Q_DECL_OVERRIDE;
- virtual void generateClassLikeNode(InnerNode* inner, CodeMarker* marker) Q_DECL_OVERRIDE;
+ virtual void generateClassLikeNode(Aggregate* inner, CodeMarker* marker) Q_DECL_OVERRIDE;
virtual void generateQmlTypePage(QmlTypeNode* qcn, CodeMarker* marker) Q_DECL_OVERRIDE;
virtual void generateQmlBasicTypePage(QmlBasicTypeNode* qbtn, CodeMarker* marker) Q_DECL_OVERRIDE;
virtual void generateDocumentNode(DocumentNode* dn, CodeMarker* marker) Q_DECL_OVERRIDE;
@@ -106,6 +106,7 @@ protected:
void generateManifestFile(const QString &manifest, const QString &element);
void readManifestMetaContent(const Config &config);
void generateKeywordAnchors(const Node* node);
+ void generateAssociatedPropertyNotes(const FunctionNode* fn);
private:
enum SubTitleSize { SmallSubTitle, LargeSubTitle };
@@ -136,22 +137,22 @@ private:
const Node *relative,
CodeMarker *marker);
void generateFooter(const Node *node = 0);
- void generateRequisites(InnerNode *inner,
+ void generateRequisites(Aggregate *inner,
CodeMarker *marker);
void generateQmlRequisites(QmlTypeNode *qcn,
CodeMarker *marker);
void generateBrief(const Node *node,
CodeMarker *marker,
const Node *relative = 0);
- void generateIncludes(const InnerNode *inner, CodeMarker *marker);
+ void generateIncludes(const Aggregate *inner, CodeMarker *marker);
void generateTableOfContents(const Node *node,
CodeMarker *marker,
QList<Section>* sections = 0);
void generateSidebar();
- QString generateListOfAllMemberFile(const InnerNode *inner,
+ QString generateListOfAllMemberFile(const Aggregate *inner,
CodeMarker *marker);
QString generateAllQmlMembersFile(QmlTypeNode* qml_cn, CodeMarker* marker);
- QString generateLowStatusMemberFile(InnerNode *inner,
+ QString generateLowStatusMemberFile(Aggregate *inner,
CodeMarker *marker,
CodeMarker::Status status);
QString generateQmlMemberFile(QmlTypeNode* qcn,
@@ -180,7 +181,7 @@ private:
CodeMarker *marker,
bool summary);
void generateDetailedQmlMember(Node *node,
- const InnerNode *relative,
+ const Aggregate *relative,
CodeMarker *marker);
void generateQmlInherits(QmlTypeNode* qcn, CodeMarker* marker) Q_DECL_OVERRIDE;
void generateQmlInstantiates(QmlTypeNode* qcn, CodeMarker* marker);
@@ -204,7 +205,7 @@ private:
void generateFullName(const Node *apparentNode, const Node *relative, const Node *actualNode = 0);
void generateDetailedMember(const Node *node,
- const InnerNode *relative,
+ const Aggregate *relative,
CodeMarker *marker);
void generateLink(const Atom *atom, CodeMarker *marker);
void generateStatus(const Node *node, CodeMarker *marker);
@@ -223,9 +224,9 @@ private:
void beginLink(const QString &link, const Node *node, const Node *relative);
void endLink();
void generateExtractionMark(const Node *node, ExtractionMarkType markType);
- void reportOrphans(const InnerNode* parent);
+ void reportOrphans(const Aggregate* parent);
- void beginDitamapPage(const InnerNode* node, const QString& fileName);
+ void beginDitamapPage(const Aggregate* node, const QString& fileName);
void endDitamapPage();
void writeDitaMap(const DitaMapNode* node);
void writeDitaRefs(const DitaRefList& ditarefs);
diff --git a/src/tools/qdoc/jscodemarker.cpp b/src/tools/qdoc/jscodemarker.cpp
index 2538b46433..f6a2c99179 100644
--- a/src/tools/qdoc/jscodemarker.cpp
+++ b/src/tools/qdoc/jscodemarker.cpp
@@ -68,7 +68,7 @@ bool JsCodeMarker::recognizeCode(const QString &code)
QQmlJS::Parser parser(&engine);
QString newCode = code;
- QList<QQmlJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
+ QVector<QQmlJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
lexer.setCode(newCode, 1);
return parser.parseProgram();
@@ -95,7 +95,7 @@ bool JsCodeMarker::recognizeLanguage(const QString &language)
/*!
Returns the type of atom used to represent JavaScript code in the documentation.
*/
-Atom::Type JsCodeMarker::atomType() const
+Atom::AtomType JsCodeMarker::atomType() const
{
return Atom::JavaScript;
}
@@ -115,7 +115,7 @@ QString JsCodeMarker::addMarkUp(const QString &code,
QQmlJS::Lexer lexer(&engine);
QString newCode = code;
- QList<QQmlJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
+ QVector<QQmlJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
lexer.setCode(newCode, 1);
QQmlJS::Parser parser(&engine);
diff --git a/src/tools/qdoc/jscodemarker.h b/src/tools/qdoc/jscodemarker.h
index d9f6eb5a10..ccba2ca4c7 100644
--- a/src/tools/qdoc/jscodemarker.h
+++ b/src/tools/qdoc/jscodemarker.h
@@ -53,7 +53,7 @@ public:
virtual bool recognizeCode(const QString &code) Q_DECL_OVERRIDE;
virtual bool recognizeExtension(const QString &ext) Q_DECL_OVERRIDE;
virtual bool recognizeLanguage(const QString &language) Q_DECL_OVERRIDE;
- virtual Atom::Type atomType() const Q_DECL_OVERRIDE;
+ virtual Atom::AtomType atomType() const Q_DECL_OVERRIDE;
virtual QString markedUpCode(const QString &code,
const Node *relative,
diff --git a/src/tools/qdoc/location.cpp b/src/tools/qdoc/location.cpp
index 5eba2a69ef..98b63fd035 100644
--- a/src/tools/qdoc/location.cpp
+++ b/src/tools/qdoc/location.cpp
@@ -202,25 +202,34 @@ void Location::pop()
*/
/*! \fn const QString& Location::filePath() const
- Returns the current path and file name.
- Must not be called on an empty Location object.
+ Returns the current path and file name. If the Location is
+ empty, the returned string is null.
\sa lineNo(), columnNo()
*/
/*!
- Returns the file name part of the file path, ie the
- current file. Must not be called on an empty Location
- object.
+ Returns the file name part of the file path, ie the current
+ file. Returns an empty string if the file path is empty.
*/
QString Location::fileName() const
{
QString fp = filePath();
- return fp.mid(fp.lastIndexOf('/') + 1);
+ return (fp.isEmpty() ? fp : fp.mid(fp.lastIndexOf('/') + 1));
}
/*!
+ Returns the suffix of the file name. Returns an empty string
+ if the file path is empty.
+ */
+QString Location::fileSuffix() const
+{
+ QString fp = filePath();
+ return (fp.isEmpty() ? fp : fp.mid(fp.lastIndexOf('.') + 1));
+}
+
+/*!
\brief Returns \a path which is canonicalized and relative to the config file.
QDir::relativeFilePath does not canonicalize the paths, so
diff --git a/src/tools/qdoc/location.h b/src/tools/qdoc/location.h
index 5250e27a47..1cb8e3aec1 100644
--- a/src/tools/qdoc/location.h
+++ b/src/tools/qdoc/location.h
@@ -72,6 +72,7 @@ public:
int depth() const { return stkDepth; }
const QString& filePath() const { return stkTop->filePath; }
QString fileName() const;
+ QString fileSuffix() const;
int lineNo() const { return stkTop->lineNo; }
int columnNo() const { return stkTop->columnNo; }
bool etc() const { return etcetera; }
@@ -104,6 +105,7 @@ private:
int lineNo;
int columnNo;
};
+ friend class QTypeInfo<StackEntry>;
void emitMessage(MessageType type,
const QString& message,
@@ -123,6 +125,8 @@ private:
static QRegExp *spuriousRegExp;
static bool logProgress_;
};
+Q_DECLARE_TYPEINFO(Location::StackEntry, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(Location, Q_COMPLEX_TYPE); // stkTop = &stkBottom
QT_END_NAMESPACE
diff --git a/src/tools/qdoc/main.cpp b/src/tools/qdoc/main.cpp
index 0b156c6bb9..cb1b890cdd 100644
--- a/src/tools/qdoc/main.cpp
+++ b/src/tools/qdoc/main.cpp
@@ -227,6 +227,8 @@ static void processQdocconfFile(const QString &fileName)
config.setStringList(CONFIG_AUTOLINKERRORS, QStringList(autolinkErrors ? "true" : "false"));
config.setStringList(CONFIG_OBSOLETELINKS, QStringList(obsoleteLinks ? "true" : "false"));
+ prevCurrentDir = QDir::currentPath();
+
/*
With the default configuration values in place, load
the qdoc configuration file. Note that the configuration
@@ -236,7 +238,6 @@ static void processQdocconfFile(const QString &fileName)
in the file being processed, mainly for error reporting
purposes.
*/
- currentDir = QFileInfo(fileName).path();
Location::initialize(config);
config.load(fileName);
QString project = config.getString(CONFIG_PROJECT);
@@ -248,7 +249,6 @@ static void processQdocconfFile(const QString &fileName)
config.setStringList(CONFIG_DEFINES,defs);
Location::terminate();
- prevCurrentDir = QDir::currentPath();
currentDir = QFileInfo(fileName).path();
if (!currentDir.isEmpty())
QDir::setCurrent(currentDir);
@@ -480,6 +480,9 @@ static void processQdocconfFile(const QString &fileName)
}
Generator::debug(QString("Parsing done."));
+ /*
+ Currently these doneParsingSourceFiles() calls do nothing.
+ */
foreach (CodeParser *codeParser, usedParsers)
codeParser->doneParsingSourceFiles();
diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp
index 37bc0c5fef..f20020cd15 100644
--- a/src/tools/qdoc/node.cpp
+++ b/src/tools/qdoc/node.cpp
@@ -44,16 +44,16 @@ QT_BEGIN_NAMESPACE
int Node::propertyGroupCount_ = 0;
QStringMap Node::operators_;
-QMap<QString,Node::Type> Node::goals_;
+QMap<QString,Node::NodeType> Node::goals_;
/*!
Initialize the map of search goals. This is called once
by QDocDatabase::initializeDB(). The map key is a string
- representing a value in the enum Node::Type. The map value
+ representing a value in the enum Node::NodeType. The map value
is the enum value.
There should be an entry in the map for each value in the
- Type enum.
+ NodeType enum.
*/
void Node::initialize()
{
@@ -160,8 +160,8 @@ QString Node::fullName(const Node* relative) const
match is found, return false.
\a types is a list of type/subtype pairs, where the first
- value in the pair is a Node::Type, and the second value is
- a Node::SubType. The second value is used in the match if
+ value in the pair is a Node::NodeType, and the second value is
+ a Node::DocSubtype. The second value is used in the match if
this node's type is Node::Document.
*/
bool Node::match(const NodeTypeList& types) const
@@ -169,7 +169,7 @@ bool Node::match(const NodeTypeList& types) const
for (int i=0; i<types.size(); ++i) {
if (type() == types.at(i).first) {
if (type() == Node::Document) {
- if (subType() == types.at(i).second)
+ if (docSubtype() == types.at(i).second)
return true;
}
else
@@ -200,12 +200,12 @@ void Node::setDoc(const Doc& doc, bool replace)
given \a parent and \a name. The new node is added to the
parent's child list.
*/
-Node::Node(Type type, InnerNode *parent, const QString& name)
+Node::Node(NodeType type, Aggregate *parent, const QString& name)
: nodeType_((unsigned char) type),
access_((unsigned char) Public),
safeness_((unsigned char) UnspecifiedSafeness),
pageType_((unsigned char) NoPageType),
- status_((unsigned char) Commendable),
+ status_((unsigned char) Active),
indexNodeFlag_(false),
parent_(parent),
relatesTo_(0),
@@ -320,7 +320,7 @@ QString Node::nodeTypeString() const
*/
QString Node::nodeTypeString(unsigned char t)
{
- switch ((Type)t) {
+ switch ((NodeType)t) {
case Namespace:
return "namespace";
case Class:
@@ -370,7 +370,7 @@ QString Node::nodeTypeString(unsigned char t)
*/
QString Node::nodeSubtypeString() const
{
- return nodeSubtypeString(subType());
+ return nodeSubtypeString(docSubtype());
}
/*!
@@ -380,7 +380,7 @@ QString Node::nodeSubtypeString() const
*/
QString Node::nodeSubtypeString(unsigned char t)
{
- switch ((SubType)t) {
+ switch ((DocSubtype)t) {
case Example:
return "example";
case HeaderFile:
@@ -395,7 +395,7 @@ QString Node::nodeSubtypeString(unsigned char t)
return "external page";
case DitaMap:
return "ditamap";
- case NoSubType:
+ case NoSubtype:
default:
break;
}
@@ -460,7 +460,7 @@ bool Node::fromFlagValue(FlagValue fv, bool defaultValue)
/*!
Sets the pointer to the node that this node relates to.
*/
-void Node::setRelates(InnerNode *pseudoParent)
+void Node::setRelates(Aggregate *pseudoParent)
{
if (relatesTo_) {
relatesTo_->removeRelated(this);
@@ -558,7 +558,7 @@ QString RelatedClass::accessString() const
*/
Node::Status Node::inheritedStatus() const
{
- Status parentStatus = Commendable;
+ Status parentStatus = Active;
if (parent_)
parentStatus = parent_->inheritedStatus();
return (Status)qMin((int)status_, (int)parentStatus);
@@ -606,7 +606,6 @@ QString Node::fileBase() const
base.replace(QLatin1Char(' '), QLatin1Char('-'));
return base.toLower();
}
-#endif
/*!
Returns this node's Universally Unique IDentifier as a
QString. Creates the UUID first, if it has not been created.
@@ -617,6 +616,7 @@ QString Node::guid() const
uuid_ = idForNode();
return uuid_;
}
+#endif
/*!
If this node is a QML or JS type node, return a pointer to
@@ -683,14 +683,32 @@ const Node* Node::root() const
}
/*!
- \class InnerNode
+ Sets the node's declaration location, its definition
+ location, or both, depending on the suffix of the file
+ name from the file path in location \a t.
+ */
+void Node::setLocation(const Location& t)
+{
+ QString suffix = t.fileSuffix();
+ if (suffix == "h")
+ declLocation_ = t;
+ else if (suffix == "cpp")
+ defLocation_ = t;
+ else {
+ declLocation_ = t;
+ defLocation_ = t;
+ }
+}
+
+/*!
+ \class Aggregate
*/
/*!
The inner node destructor deletes the children and removes
this node from its related nodes.
*/
-InnerNode::~InnerNode()
+Aggregate::~Aggregate()
{
deleteChildren();
removeFromRelated();
@@ -706,17 +724,17 @@ InnerNode::~InnerNode()
find all this node's children that have the given \a name,
and return the one that satisfies the \a genus requirement.
*/
-Node *InnerNode::findChildNode(const QString& name, Node::Genus genus) const
+Node *Aggregate::findChildNode(const QString& name, Node::Genus genus) const
{
if (genus == Node::DontCare) {
- Node *node = childMap.value(name);
+ Node *node = childMap_.value(name);
if (node && !node->isQmlPropertyGroup()) // mws asks: Why not property group?
return node;
if (isQmlType() || isJsType()) {
for (int i=0; i<children_.size(); ++i) {
Node* n = children_.at(i);
if (n->isQmlPropertyGroup() || isJsPropertyGroup()) {
- node = static_cast<InnerNode*>(n)->findChildNode(name, genus);
+ node = static_cast<Aggregate*>(n)->findChildNode(name, genus);
if (node)
return node;
}
@@ -724,7 +742,7 @@ Node *InnerNode::findChildNode(const QString& name, Node::Genus genus) const
}
}
else {
- NodeList nodes = childMap.values(name);
+ NodeList nodes = childMap_.values(name);
if (!nodes.isEmpty()) {
for (int i=0; i<nodes.size(); ++i) {
Node* node = nodes.at(i);
@@ -733,20 +751,20 @@ Node *InnerNode::findChildNode(const QString& name, Node::Genus genus) const
}
}
}
- return primaryFunctionMap.value(name);
+ return primaryFunctionMap_.value(name);
}
/*!
Find all the child nodes of this node that are named
\a name and return them in \a nodes.
*/
-void InnerNode::findChildren(const QString& name, NodeList& nodes) const
+void Aggregate::findChildren(const QString& name, NodeList& nodes) const
{
- nodes = childMap.values(name);
- Node* n = primaryFunctionMap.value(name);
+ nodes = childMap_.values(name);
+ Node* n = primaryFunctionMap_.value(name);
if (n) {
nodes.append(n);
- NodeList t = secondaryFunctionMap.value(name);
+ NodeList t = secondaryFunctionMap_.value(name);
if (!t.isEmpty())
nodes.append(t);
}
@@ -756,7 +774,7 @@ void InnerNode::findChildren(const QString& name, NodeList& nodes) const
if (i < 0)
return;
QString qmlPropGroup = name.left(i);
- NodeList t = childMap.values(qmlPropGroup);
+ NodeList t = childMap_.values(qmlPropGroup);
if (t.isEmpty())
return;
foreach (Node* n, t) {
@@ -773,12 +791,12 @@ void InnerNode::findChildren(const QString& name, NodeList& nodes) const
with the specified \a name is found but it is not of the
specified \a type, 0 is returned.
*/
-Node* InnerNode::findChildNode(const QString& name, Type type)
+Node* Aggregate::findChildNode(const QString& name, NodeType type)
{
if (type == Function)
- return primaryFunctionMap.value(name);
+ return primaryFunctionMap_.value(name);
else {
- NodeList nodes = childMap.values(name);
+ NodeList nodes = childMap_.values(name);
for (int i=0; i<nodes.size(); ++i) {
Node* node = nodes.at(i);
if (node->type() == type)
@@ -792,9 +810,9 @@ Node* InnerNode::findChildNode(const QString& name, Type type)
Find a function node that is a child of this nose, such
that the function node has the specified \a name.
*/
-FunctionNode *InnerNode::findFunctionNode(const QString& name) const
+FunctionNode *Aggregate::findFunctionNode(const QString& name) const
{
- return static_cast<FunctionNode *>(primaryFunctionMap.value(name));
+ return static_cast<FunctionNode *>(primaryFunctionMap_.value(name));
}
/*!
@@ -802,15 +820,15 @@ FunctionNode *InnerNode::findFunctionNode(const QString& name) const
that the function has the same name and signature as the
\a clone node.
*/
-FunctionNode *InnerNode::findFunctionNode(const FunctionNode *clone) const
+FunctionNode *Aggregate::findFunctionNode(const FunctionNode *clone) const
{
- QMap<QString,Node*>::ConstIterator c = primaryFunctionMap.constFind(clone->name());
- if (c != primaryFunctionMap.constEnd()) {
+ QMap<QString,Node*>::ConstIterator c = primaryFunctionMap_.constFind(clone->name());
+ if (c != primaryFunctionMap_.constEnd()) {
if (isSameSignature(clone, (FunctionNode *) *c)) {
return (FunctionNode *) *c;
}
- else if (secondaryFunctionMap.contains(clone->name())) {
- const NodeList& secs = secondaryFunctionMap[clone->name()];
+ else if (secondaryFunctionMap_.contains(clone->name())) {
+ const NodeList& secs = secondaryFunctionMap_[clone->name()];
NodeList::ConstIterator s = secs.constBegin();
while (s != secs.constEnd()) {
if (isSameSignature(clone, (FunctionNode *) *s))
@@ -825,11 +843,11 @@ FunctionNode *InnerNode::findFunctionNode(const FunctionNode *clone) const
/*!
Returns the list of keys from the primary function map.
*/
-QStringList InnerNode::primaryKeys()
+QStringList Aggregate::primaryKeys()
{
QStringList t;
- QMap<QString, Node*>::iterator i = primaryFunctionMap.begin();
- while (i != primaryFunctionMap.end()) {
+ QMap<QString, Node*>::iterator i = primaryFunctionMap_.begin();
+ while (i != primaryFunctionMap_.end()) {
t.append(i.key());
++i;
}
@@ -839,11 +857,11 @@ QStringList InnerNode::primaryKeys()
/*!
Returns the list of keys from the secondary function map.
*/
-QStringList InnerNode::secondaryKeys()
+QStringList Aggregate::secondaryKeys()
{
QStringList t;
- QMap<QString, NodeList>::iterator i = secondaryFunctionMap.begin();
- while (i != secondaryFunctionMap.end()) {
+ QMap<QString, NodeList>::iterator i = secondaryFunctionMap_.begin();
+ while (i != secondaryFunctionMap_.end()) {
t.append(i.key());
++i;
}
@@ -851,43 +869,13 @@ QStringList InnerNode::secondaryKeys()
}
/*!
- */
-void InnerNode::setOverload(FunctionNode *func, bool overlode)
-{
- Node *node = (Node *) func;
- Node *&primary = primaryFunctionMap[func->name()];
-
- if (secondaryFunctionMap.contains(func->name())) {
- NodeList& secs = secondaryFunctionMap[func->name()];
- if (overlode) {
- if (primary == node) {
- primary = secs.first();
- secs.erase(secs.begin());
- secs.append(node);
- }
- else {
- secs.removeAll(node);
- secs.append(node);
- }
- }
- else {
- if (primary != node) {
- secs.removeAll(node);
- secs.prepend(primary);
- primary = node;
- }
- }
- }
-}
-
-/*!
Mark all child nodes that have no documentation as having
private access and internal status. qdoc will then ignore
them for documentation purposes. Some nodes have an
Intermediate status, meaning that they should be ignored,
but not their children.
*/
-void InnerNode::makeUndocumentedChildrenInternal()
+void Aggregate::makeUndocumentedChildrenInternal()
{
foreach (Node *child, childNodes()) {
if (child->doc().isEmpty() && child->status() != Node::Intermediate) {
@@ -898,68 +886,109 @@ void InnerNode::makeUndocumentedChildrenInternal()
}
/*!
+ This is where we should set the overload numbers, including
+ the related non-members.
*/
-void InnerNode::normalizeOverloads()
+void Aggregate::normalizeOverloads()
{
- QMap<QString, Node *>::Iterator p1 = primaryFunctionMap.begin();
- while (p1 != primaryFunctionMap.end()) {
+ QMap<QString, Node *>::Iterator p1 = primaryFunctionMap_.begin();
+ while (p1 != primaryFunctionMap_.end()) {
FunctionNode *primaryFunc = (FunctionNode *) *p1;
- if (secondaryFunctionMap.contains(primaryFunc->name()) &&
- (primaryFunc->status() != Commendable ||
- primaryFunc->access() == Private)) {
-
- NodeList& secs = secondaryFunctionMap[primaryFunc->name()];
- NodeList::ConstIterator s = secs.constBegin();
- while (s != secs.constEnd()) {
- FunctionNode *secondaryFunc = (FunctionNode *) *s;
-
- // Any non-obsolete, non-compatibility, non-private functions
- // (i.e, visible functions) are preferable to the primary
- // function.
-
- if (secondaryFunc->status() == Commendable &&
- secondaryFunc->access() != Private) {
-
- *p1 = secondaryFunc;
- int index = secondaryFunctionMap[primaryFunc->name()].indexOf(secondaryFunc);
- secondaryFunctionMap[primaryFunc->name()].replace(index, primaryFunc);
- break;
+ if (primaryFunc->status() != Active || primaryFunc->access() == Private) {
+ if (secondaryFunctionMap_.contains(primaryFunc->name())) {
+ /*
+ Either the primary function is not active or it is private.
+ It therefore can't be the primary function. Search the list
+ of overloads to find one that can be the primary function.
+ */
+ NodeList& overloads = secondaryFunctionMap_[primaryFunc->name()];
+ NodeList::ConstIterator s = overloads.constBegin();
+ while (s != overloads.constEnd()) {
+ FunctionNode *overloadFunc = (FunctionNode *) *s;
+ /*
+ Any non-obsolete, non-private function (i.e., visible function)
+ is preferable to the current primary function. Swap the primary
+ and overload functions.
+ */
+ if (overloadFunc->status() == Active && overloadFunc->access() != Private) {
+ primaryFunc->setOverloadNumber(overloadFunc->overloadNumber());
+ overloads.replace(overloads.indexOf(overloadFunc), primaryFunc);
+ *p1 = overloadFunc;
+ overloadFunc->setOverloadFlag(false);
+ overloadFunc->setOverloadNumber(0);
+ break;
+ }
+ ++s;
}
- ++s;
}
}
++p1;
}
-
- QMap<QString, Node *>::ConstIterator p = primaryFunctionMap.constBegin();
- while (p != primaryFunctionMap.constEnd()) {
+ /*
+ Ensure that none of the primary functions is marked with \overload.
+ */
+ QMap<QString, Node *>::Iterator p = primaryFunctionMap_.begin();
+ while (p != primaryFunctionMap_.end()) {
FunctionNode *primaryFunc = (FunctionNode *) *p;
- if (primaryFunc->isOverload())
- primaryFunc->ove = false;
- if (secondaryFunctionMap.contains(primaryFunc->name())) {
- NodeList& secs = secondaryFunctionMap[primaryFunc->name()];
- NodeList::ConstIterator s = secs.constBegin();
- while (s != secs.constEnd()) {
- FunctionNode *secondaryFunc = (FunctionNode *) *s;
- if (!secondaryFunc->isOverload())
- secondaryFunc->ove = true;
- ++s;
+ if (primaryFunc->isOverload()) {
+ if (secondaryFunctionMap_.contains(primaryFunc->name())) {
+ /*
+ The primary function is marked with \overload. Find an
+ overload in the secondary function map that is not marked
+ with \overload but that is active and not private. Then
+ swap it with the primary function.
+ */
+ NodeList& overloads = secondaryFunctionMap_[primaryFunc->name()];
+ NodeList::ConstIterator s = overloads.constBegin();
+ while (s != overloads.constEnd()) {
+ FunctionNode *overloadFunc = (FunctionNode *) *s;
+ if (!overloadFunc->isOverload()) {
+ if (overloadFunc->status() == Active && overloadFunc->access() != Private) {
+ primaryFunc->setOverloadNumber(overloadFunc->overloadNumber());
+ overloads.replace(overloads.indexOf(overloadFunc), primaryFunc);
+ *p = overloadFunc;
+ overloadFunc->setOverloadFlag(false);
+ overloadFunc->setOverloadNumber(0);
+ break;
+ }
+ }
+ ++s;
+ }
}
}
++p;
}
-
+ /*
+ Add the related non-members here.
+ */
+ if (!related_.isEmpty()) {
+ foreach (Node* n, related_) {
+ if (n->isFunction()) {
+ FunctionNode* fn = static_cast<FunctionNode*>(n);
+ QMap<QString, Node *>::Iterator p = primaryFunctionMap_.find(fn->name());
+ if (p != primaryFunctionMap_.end()) {
+ secondaryFunctionMap_[fn->name()].append(fn);
+ fn->setOverloadNumber(secondaryFunctionMap_[fn->name()].size());
+ }
+ else
+ fn->setOverloadNumber(0);
+ }
+ }
+ }
+ /*
+ Recursive part.
+ */
NodeList::ConstIterator c = childNodes().constBegin();
while (c != childNodes().constEnd()) {
- if ((*c)->isInnerNode())
- ((InnerNode *) *c)->normalizeOverloads();
+ if ((*c)->isAggregate())
+ ((Aggregate *) *c)->normalizeOverloads();
++c;
}
}
/*!
*/
-void InnerNode::removeFromRelated()
+void Aggregate::removeFromRelated()
{
while (!related_.isEmpty()) {
Node *p = static_cast<Node *>(related_.takeFirst());
@@ -971,13 +1000,13 @@ void InnerNode::removeFromRelated()
/*!
Deletes all this node's children.
*/
-void InnerNode::deleteChildren()
+void Aggregate::deleteChildren()
{
NodeList childrenCopy = children_; // `children_` will be changed in ~Node()
qDeleteAll(childrenCopy);
}
-/*! \fn bool InnerNode::isInnerNode() const
+/*! \fn bool Aggregate::isAggregate() const
Returns \c true because this is an inner node.
*/
@@ -997,7 +1026,7 @@ bool Node::isWrapper() const
no enum type node is found that has \a enumValue as one
of its values.
*/
-const EnumNode *InnerNode::findEnumNodeForValue(const QString &enumValue) const
+const EnumNode *Aggregate::findEnumNodeForValue(const QString &enumValue) const
{
foreach (const Node *node, enumChildren_) {
const EnumNode *en = static_cast<const EnumNode *>(node);
@@ -1008,32 +1037,16 @@ const EnumNode *InnerNode::findEnumNodeForValue(const QString &enumValue) const
}
/*!
- Returnds the sequence number of the function node \a func
- in the list of overloaded functions for a class, such that
- all the functions have the same name as the \a func.
- */
-int InnerNode::overloadNumber(const FunctionNode *func) const
-{
- Node *node = const_cast<FunctionNode *>(func);
- if (primaryFunctionMap[func->name()] == node) {
- return 1;
- }
- else {
- return secondaryFunctionMap[func->name()].indexOf(node) + 2;
- }
-}
-
-/*!
Returns a node list containing all the member functions of
some class such that the functions overload the name \a funcName.
*/
-NodeList InnerNode::overloads(const QString &funcName) const
+NodeList Aggregate::overloads(const QString &funcName) const
{
NodeList result;
- Node *primary = primaryFunctionMap.value(funcName);
+ Node *primary = primaryFunctionMap_.value(funcName);
if (primary) {
result << primary;
- result += secondaryFunctionMap[funcName];
+ result += secondaryFunctionMap_[funcName];
}
return result;
}
@@ -1042,7 +1055,7 @@ NodeList InnerNode::overloads(const QString &funcName) const
Construct an inner node (i.e., not a leaf node) of the
given \a type and having the given \a parent and \a name.
*/
-InnerNode::InnerNode(Type type, InnerNode *parent, const QString& name)
+Aggregate::Aggregate(NodeType type, Aggregate *parent, const QString& name)
: Node(type, parent, name)
{
switch (type) {
@@ -1059,7 +1072,7 @@ InnerNode::InnerNode(Type type, InnerNode *parent, const QString& name)
/*!
Appends an \a include file to the list of include files.
*/
-void InnerNode::addInclude(const QString& include)
+void Aggregate::addInclude(const QString& include)
{
includes_.append(include);
}
@@ -1067,7 +1080,7 @@ void InnerNode::addInclude(const QString& include)
/*!
Sets the list of include files to \a includes.
*/
-void InnerNode::setIncludes(const QStringList& includes)
+void Aggregate::setIncludes(const QStringList& includes)
{
includes_ = includes;
}
@@ -1075,7 +1088,7 @@ void InnerNode::setIncludes(const QStringList& includes)
/*!
f1 is always the clone
*/
-bool InnerNode::isSameSignature(const FunctionNode *f1, const FunctionNode *f2)
+bool Aggregate::isSameSignature(const FunctionNode *f1, const FunctionNode *f2)
{
if (f1->parameters().count() != f2->parameters().count())
return false;
@@ -1113,23 +1126,26 @@ bool InnerNode::isSameSignature(const FunctionNode *f1, const FunctionNode *f2)
be necessary to update this node's internal collections and
the child's parent pointer and output subdirectory.
*/
-void InnerNode::addChild(Node *child)
+void Aggregate::addChild(Node *child)
{
children_.append(child);
if ((child->type() == Function) || (child->type() == QmlMethod)) {
- FunctionNode *func = (FunctionNode *) child;
- if (!primaryFunctionMap.contains(func->name())) {
- primaryFunctionMap.insert(func->name(), func);
+ FunctionNode *func = static_cast<FunctionNode*>(child);
+ QString name = func->name();
+ if (!primaryFunctionMap_.contains(name)) {
+ primaryFunctionMap_.insert(name, func);
+ func->setOverloadNumber(0);
}
else {
- NodeList &secs = secondaryFunctionMap[func->name()];
- secs.append(func);
+ NodeList &overloads = secondaryFunctionMap_[name];
+ overloads.append(func);
+ func->setOverloadNumber(overloads.size());
}
}
else {
if (child->type() == Enum)
enumChildren_.append(child);
- childMap.insertMulti(child->name(), child);
+ childMap_.insertMulti(child->name(), child);
}
if (child->parent() == 0) {
child->setParent(this);
@@ -1143,9 +1159,9 @@ void InnerNode::addChild(Node *child)
again, because it is presumed to already be there. We just
want to be able to find the child by its \a title.
*/
-void InnerNode::addChild(Node* child, const QString& title)
+void Aggregate::addChild(Node* child, const QString& title)
{
- childMap.insertMulti(title, child);
+ childMap_.insertMulti(title, child);
}
/*!
@@ -1154,40 +1170,38 @@ void InnerNode::addChild(Node* child, const QString& title)
pointer is set to 0, but its output subdirectory is not
changed.
*/
-void InnerNode::removeChild(Node *child)
+void Aggregate::removeChild(Node *child)
{
children_.removeAll(child);
enumChildren_.removeAll(child);
if (child->type() == Function) {
- QMap<QString, Node *>::Iterator prim =
- primaryFunctionMap.find(child->name());
- NodeList& secs = secondaryFunctionMap[child->name()];
- if (prim != primaryFunctionMap.end() && *prim == child) {
- if (secs.isEmpty()) {
- primaryFunctionMap.remove(child->name());
- }
- else {
- primaryFunctionMap.insert(child->name(), secs.takeFirst());
+ QMap<QString, Node *>::Iterator primary = primaryFunctionMap_.find(child->name());
+ NodeList& overloads = secondaryFunctionMap_[child->name()];
+ if (primary != primaryFunctionMap_.end() && *primary == child) {
+ primaryFunctionMap_.erase(primary);
+ if (!overloads.isEmpty()) {
+ FunctionNode* fn = static_cast<FunctionNode*>(overloads.takeFirst());
+ fn->setOverloadNumber(0);
+ primaryFunctionMap_.insert(child->name(), fn);
}
}
- else {
- secs.removeAll(child);
- }
+ else
+ overloads.removeAll(child);
}
- QMap<QString, Node *>::Iterator ent = childMap.find(child->name());
- while (ent != childMap.end() && ent.key() == child->name()) {
+ QMap<QString, Node *>::Iterator ent = childMap_.find(child->name());
+ while (ent != childMap_.end() && ent.key() == child->name()) {
if (*ent == child) {
- childMap.erase(ent);
+ childMap_.erase(ent);
break;
}
++ent;
}
if (child->title().isEmpty())
return;
- ent = childMap.find(child->title());
- while (ent != childMap.end() && ent.key() == child->title()) {
+ ent = childMap_.find(child->title());
+ while (ent != childMap_.end() && ent.key() == child->title()) {
if (*ent == child) {
- childMap.erase(ent);
+ childMap_.erase(ent);
break;
}
++ent;
@@ -1198,7 +1212,7 @@ void InnerNode::removeChild(Node *child)
/*!
Recursively sets the output subdirectory for children
*/
-void InnerNode::setOutputSubdirectory(const QString &t)
+void Aggregate::setOutputSubdirectory(const QString &t)
{
Node::setOutputSubdirectory(t);
for (int i = 0; i < childNodes().size(); ++i)
@@ -1261,7 +1275,7 @@ QString Node::physicalModuleName() const
/*!
*/
-void InnerNode::removeRelated(Node *pseudoChild)
+void Aggregate::removeRelated(Node *pseudoChild)
{
related_.removeAll(pseudoChild);
}
@@ -1270,7 +1284,7 @@ void InnerNode::removeRelated(Node *pseudoChild)
If this node has a child that is a QML property named \a n,
return the pointer to that child.
*/
-QmlPropertyNode* InnerNode::hasQmlProperty(const QString& n) const
+QmlPropertyNode* Aggregate::hasQmlProperty(const QString& n) const
{
foreach (Node* child, childNodes()) {
if (child->type() == Node::QmlProperty) {
@@ -1291,7 +1305,7 @@ QmlPropertyNode* InnerNode::hasQmlProperty(const QString& n) const
whose type (attached or normal property) matches \a attached,
return the pointer to that child.
*/
-QmlPropertyNode* InnerNode::hasQmlProperty(const QString& n, bool attached) const
+QmlPropertyNode* Aggregate::hasQmlProperty(const QString& n, bool attached) const
{
foreach (Node* child, childNodes()) {
if (child->type() == Node::QmlProperty) {
@@ -1311,7 +1325,7 @@ QmlPropertyNode* InnerNode::hasQmlProperty(const QString& n, bool attached) cons
\class LeafNode
*/
-/*! \fn bool LeafNode::isInnerNode() const
+/*! \fn bool LeafNode::isAggregate() const
Returns \c false because this is a LeafNode.
*/
@@ -1319,7 +1333,7 @@ QmlPropertyNode* InnerNode::hasQmlProperty(const QString& n, bool attached) cons
Constructs a leaf node named \a name of the specified
\a type. The new leaf node becomes a child of \a parent.
*/
-LeafNode::LeafNode(Type type, InnerNode *parent, const QString& name)
+LeafNode::LeafNode(NodeType type, Aggregate *parent, const QString& name)
: Node(type, parent, name)
{
switch (type) {
@@ -1346,7 +1360,7 @@ LeafNode::LeafNode(Type type, InnerNode *parent, const QString& name)
documentation case where a \e{qmlproperty} command is used
to override the QML definition of a QML property.
*/
-LeafNode::LeafNode(InnerNode* parent, Type type, const QString& name)
+LeafNode::LeafNode(Aggregate* parent, NodeType type, const QString& name)
: Node(type, 0, name)
{
setParent(parent);
@@ -1374,8 +1388,8 @@ LeafNode::LeafNode(InnerNode* parent, Type type, const QString& name)
/*!
Constructs a namespace node.
*/
-NamespaceNode::NamespaceNode(InnerNode *parent, const QString& name)
- : InnerNode(Namespace, parent, name), seen_(false), tree_(0)
+NamespaceNode::NamespaceNode(Aggregate *parent, const QString& name)
+ : Aggregate(Namespace, parent, name), seen_(false), tree_(0)
{
setGenus(Node::CPP);
setPageType(ApiPage);
@@ -1389,8 +1403,8 @@ NamespaceNode::NamespaceNode(InnerNode *parent, const QString& name)
/*!
Constructs a class node. A class node will generate an API page.
*/
-ClassNode::ClassNode(InnerNode *parent, const QString& name)
- : InnerNode(Class, parent, name)
+ClassNode::ClassNode(Aggregate *parent, const QString& name)
+ : Aggregate(Class, parent, name)
{
abstract_ = false;
wrapper_ = false;
@@ -1584,8 +1598,8 @@ QmlTypeNode* ClassNode::findQmlBaseNode()
which specifies the type of DocumentNode. The page type for
the page index is set here.
*/
-DocumentNode::DocumentNode(InnerNode* parent, const QString& name, SubType subtype, Node::PageType ptype)
- : InnerNode(Document, parent, name), nodeSubtype_(subtype)
+DocumentNode::DocumentNode(Aggregate* parent, const QString& name, DocSubtype subtype, Node::PageType ptype)
+ : Aggregate(Document, parent, name), nodeSubtype_(subtype)
{
setGenus(Node::DOC);
switch (subtype) {
@@ -1618,7 +1632,7 @@ void DocumentNode::setTitle(const QString &title)
/*!
Returns the document node's full title, which is usually
- just title(), but for some SubType values is different
+ just title(), but for some DocSubtype values is different
from title()
*/
QString DocumentNode::fullTitle() const
@@ -1669,8 +1683,8 @@ QString DocumentNode::subTitle() const
The constructor for the node representing an enum type
has a \a parent class and an enum type \a name.
*/
-EnumNode::EnumNode(InnerNode *parent, const QString& name)
- : LeafNode(Enum, parent, name), ft(0)
+EnumNode::EnumNode(Aggregate *parent, const QString& name)
+ : LeafNode(Enum, parent, name), flagsType_(0)
{
setGenus(Node::CPP);
}
@@ -1680,8 +1694,8 @@ EnumNode::EnumNode(InnerNode *parent, const QString& name)
*/
void EnumNode::addItem(const EnumItem& item)
{
- itms.append(item);
- names.insert(item.name());
+ items_.append(item);
+ names_.insert(item.name());
}
/*!
@@ -1701,7 +1715,7 @@ Node::Access EnumNode::itemAccess(const QString &name) const
*/
QString EnumNode::itemValue(const QString &name) const
{
- foreach (const EnumItem &item, itms) {
+ foreach (const EnumItem &item, items_) {
if (item.name() == name)
return item.value();
}
@@ -1714,8 +1728,8 @@ QString EnumNode::itemValue(const QString &name) const
/*!
*/
-TypedefNode::TypedefNode(InnerNode *parent, const QString& name)
- : LeafNode(Typedef, parent, name), ae(0)
+TypedefNode::TypedefNode(Aggregate *parent, const QString& name)
+ : LeafNode(Typedef, parent, name), associatedEnum_(0)
{
setGenus(Node::CPP);
}
@@ -1724,7 +1738,7 @@ TypedefNode::TypedefNode(InnerNode *parent, const QString& name)
*/
void TypedefNode::setAssociatedEnum(const EnumNode *enume)
{
- ae = enume;
+ associatedEnum_ = enume;
}
/*!
@@ -1745,7 +1759,7 @@ Parameter::Parameter(const QString& leftType,
const QString& rightType,
const QString& name,
const QString& defaultValue)
- : lef(leftType), rig(rightType), nam(name), def(defaultValue)
+ : leftType_(leftType), rightType_(rightType), name_(name), defaultValue_(defaultValue)
{
}
@@ -1753,7 +1767,7 @@ Parameter::Parameter(const QString& leftType,
The standard copy constructor copies the strings from \a p.
*/
Parameter::Parameter(const Parameter& p)
- : lef(p.lef), rig(p.rig), nam(p.nam), def(p.def)
+ : leftType_(p.leftType_), rightType_(p.rightType_), name_(p.name_), defaultValue_(p.defaultValue_)
{
}
@@ -1763,10 +1777,10 @@ Parameter::Parameter(const Parameter& p)
*/
Parameter& Parameter::operator=(const Parameter& p)
{
- lef = p.lef;
- rig = p.rig;
- nam = p.nam;
- def = p.def;
+ leftType_ = p.leftType_;
+ rightType_ = p.rightType_;
+ name_ = p.name_;
+ defaultValue_ = p.defaultValue_;
return *this;
}
@@ -1777,12 +1791,12 @@ Parameter& Parameter::operator=(const Parameter& p)
*/
QString Parameter::reconstruct(bool value) const
{
- QString p = lef + rig;
+ QString p = leftType_ + rightType_;
if (!p.endsWith(QChar('*')) && !p.endsWith(QChar('&')) && !p.endsWith(QChar(' ')))
p += QLatin1Char(' ');
- p += nam;
- if (value && !def.isEmpty())
- p += " = " + def;
+ p += name_;
+ if (value && !defaultValue_.isEmpty())
+ p += " = " + defaultValue_;
return p;
}
@@ -1794,19 +1808,21 @@ QString Parameter::reconstruct(bool value) const
/*!
Construct a function node for a C++ function. It's parent
is \a parent, and it's name is \a name.
+
+ Do not set overloadNumber_ in the initializer list because it
+ is set by addChild() in the Node base class.
*/
-FunctionNode::FunctionNode(InnerNode *parent, const QString& name)
+FunctionNode::FunctionNode(Aggregate *parent, const QString& name)
: LeafNode(Function, parent, name),
- met(Plain),
- vir(NonVirtual),
- con(false),
- sta(false),
- ove(false),
- reimp(false),
+ metaness_(Plain),
+ virtualness_(NonVirtual),
+ const_(false),
+ static_(false),
+ reimplemented_(false),
attached_(false),
privateSignal_(false),
- rf(0),
- ap(0)
+ overload_(false),
+ reimplementedFrom_(0)
{
setGenus(Node::CPP);
}
@@ -1815,19 +1831,21 @@ FunctionNode::FunctionNode(InnerNode *parent, const QString& name)
Construct a function node for a QML method or signal, specified
by \a type. It's parent is \a parent, and it's name is \a name.
If \a attached is true, it is an attached method or signal.
+
+ Do not set overloadNumber_ in the initializer list because it
+ is set by addChild() in the Node base class.
*/
-FunctionNode::FunctionNode(Type type, InnerNode *parent, const QString& name, bool attached)
+FunctionNode::FunctionNode(NodeType type, Aggregate *parent, const QString& name, bool attached)
: LeafNode(type, parent, name),
- met(Plain),
- vir(NonVirtual),
- con(false),
- sta(false),
- ove(false),
- reimp(false),
+ metaness_(Plain),
+ virtualness_(NonVirtual),
+ const_(false),
+ static_(false),
+ reimplemented_(false),
attached_(attached),
privateSignal_(false),
- rf(0),
- ap(0)
+ overload_(false),
+ reimplementedFrom_(0)
{
setGenus(Node::QML);
if (type == QmlMethod || type == QmlSignal) {
@@ -1843,32 +1861,33 @@ FunctionNode::FunctionNode(Type type, InnerNode *parent, const QString& name, bo
is PureVirtual, and if the parent() is a ClassNode, set the parent's
\e abstract flag to true.
*/
-void FunctionNode::setVirtualness(Virtualness virtualness)
+void FunctionNode::setVirtualness(Virtualness v)
{
- vir = virtualness;
- if ((virtualness == PureVirtual) && parent() &&
- (parent()->type() == Node::Class))
+ virtualness_ = v;
+ if ((v == PureVirtual) && parent() && (parent()->type() == Node::Class))
parent()->setAbstract(true);
}
-/*!
+/*! \fn void FunctionNode::setOverloadFlag(bool b)
+ Sets this function node's overload flag to \a b.
+ It does not set the overload number.
+ */
+
+/*! \fn void FunctionNode::setOverloadNumber(unsigned char n)
+ Sets this function node's overload number to \a n.
+ It does not set the overload flag.
*/
-void FunctionNode::setOverload(bool overlode)
-{
- parent()->setOverload(this, overlode);
- ove = overlode;
-}
/*!
- Sets the function node's reimplementation flag to \a r.
- When \a r is true, it is supposed to mean that this function
+ Sets the function node's reimplementation flag to \a b.
+ When \a b is true, it is supposed to mean that this function
is a reimplementation of a virtual function in a base class,
- but it really just means the \e reimp command was seen in the
- qdoc comment.
+ but it really just means the \e {\\reimp} command was seen in
+ the qdoc comment.
*/
-void FunctionNode::setReimp(bool r)
+void FunctionNode::setReimplemented(bool b)
{
- reimp = r;
+ reimplemented_ = b;
}
/*!
@@ -1876,16 +1895,16 @@ void FunctionNode::setReimp(bool r)
*/
void FunctionNode::addParameter(const Parameter& parameter)
{
- params.append(parameter);
+ parameters_.append(parameter);
}
/*!
*/
void FunctionNode::borrowParameterNames(const FunctionNode *source)
{
- QList<Parameter>::Iterator t = params.begin();
- QList<Parameter>::ConstIterator s = source->params.constBegin();
- while (s != source->params.constEnd() && t != params.end()) {
+ QList<Parameter>::Iterator t = parameters_.begin();
+ QList<Parameter>::ConstIterator s = source->parameters_.constBegin();
+ while (s != source->parameters_.constEnd() && t != parameters_.end()) {
if (!(*s).name().isEmpty())
(*t).setName((*s).name());
++s;
@@ -1897,30 +1916,42 @@ void FunctionNode::borrowParameterNames(const FunctionNode *source)
If this function is a reimplementation, \a from points
to the FunctionNode of the function being reimplemented.
*/
-void FunctionNode::setReimplementedFrom(FunctionNode *from)
+void FunctionNode::setReimplementedFrom(FunctionNode *f)
{
- rf = from;
- from->rb.append(this);
+ reimplementedFrom_ = f;
+ f->reimplementedBy_.append(this);
}
/*!
- Sets the "associated" property to \a property. The function
- might be the setter or getter for a property, for example.
+ Adds the "associated" property \a p to this function node.
+ The function might be the setter or getter for a property,
+ for example.
*/
-void FunctionNode::setAssociatedProperty(PropertyNode *property)
+void FunctionNode::addAssociatedProperty(PropertyNode *p)
{
- ap = property;
+ associatedProperties_.append(p);
}
/*!
- Returns the overload number for this function obtained
- from the parent.
+ Returns true if this function has at least one property
+ that is active, i.e. at least one property that is not
+ obsolete.
*/
-int FunctionNode::overloadNumber() const
+bool FunctionNode::hasActiveAssociatedProperty() const
{
- return parent()->overloadNumber(this);
+ if (associatedProperties_.isEmpty())
+ return false;
+ foreach (const PropertyNode* p, associatedProperties_) {
+ if (!p->isObsolete())
+ return true;
+ }
+ return false;
}
+/*! \fn unsigned char FunctionNode::overloadNumber() const
+ Returns the overload number for this function.
+ */
+
/*!
Returns the list of parameter names.
*/
@@ -1957,15 +1988,15 @@ QString FunctionNode::rawParameters(bool names, bool values) const
Returns the list of reconstructed parameters. If \a values
is true, the default values are included, if any are present.
*/
-QStringList FunctionNode::reconstructParams(bool values) const
+QStringList FunctionNode::reconstructParameters(bool values) const
{
- QStringList params;
+ QStringList reconstructedParameters;
QList<Parameter>::ConstIterator p = parameters().constBegin();
while (p != parameters().constEnd()) {
- params << (*p).reconstruct(values);
+ reconstructedParameters << (*p).reconstruct(values);
++p;
}
- return params;
+ return reconstructedParameters;
}
/*!
@@ -1979,11 +2010,11 @@ QString FunctionNode::signature(bool values) const
if (!returnType().isEmpty())
s = returnType() + QLatin1Char(' ');
s += name() + QLatin1Char('(');
- QStringList params = reconstructParams(values);
- int p = params.size();
+ QStringList reconstructedParameters = reconstructParameters(values);
+ int p = reconstructedParameters.size();
if (p > 0) {
for (int i=0; i<p; i++) {
- s += params[i];
+ s += reconstructedParameters[i];
if (i < (p-1))
s += ", ";
}
@@ -1993,12 +2024,25 @@ QString FunctionNode::signature(bool values) const
}
/*!
+ Returns true if function \a fn has role \a r for this
+ property.
+ */
+PropertyNode::FunctionRole PropertyNode::role(const FunctionNode* fn) const
+{
+ for (int i=0; i<4; i++) {
+ if (functions_[i].contains((Node*)fn))
+ return (FunctionRole) i;
+ }
+ return Notifier;
+}
+
+/*!
Print some debugging stuff.
*/
void FunctionNode::debug() const
{
- qDebug("QML METHOD %s rt %s pp %s",
- qPrintable(name()), qPrintable(rt), qPrintable(pp.join(' ')));
+ qDebug("QML METHOD %s returnType_ %s parentPath_ %s",
+ qPrintable(name()), qPrintable(returnType_), qPrintable(parentPath_.join(' ')));
}
/*!
@@ -2011,17 +2055,17 @@ void FunctionNode::debug() const
The constructor sets the \a parent and the \a name, but
everything else is set to default values.
*/
-PropertyNode::PropertyNode(InnerNode *parent, const QString& name)
+PropertyNode::PropertyNode(Aggregate *parent, const QString& name)
: LeafNode(Property, parent, name),
stored_(FlagValueDefault),
designable_(FlagValueDefault),
scriptable_(FlagValueDefault),
writable_(FlagValueDefault),
user_(FlagValueDefault),
- cst(false),
- fnl(false),
- rev(-1),
- overrides(0)
+ const_(false),
+ final_(false),
+ revision_(-1),
+ overrides_(0)
{
setGenus(Node::CPP);
}
@@ -2039,8 +2083,8 @@ PropertyNode::PropertyNode(InnerNode *parent, const QString& name)
void PropertyNode::setOverriddenFrom(const PropertyNode* baseProperty)
{
for (int i = 0; i < NumFunctionRoles; ++i) {
- if (funcs[i].isEmpty())
- funcs[i] = baseProperty->funcs[i];
+ if (functions_[i].isEmpty())
+ functions_[i] = baseProperty->functions_[i];
}
if (stored_ == FlagValueDefault)
stored_ = baseProperty->stored_;
@@ -2052,7 +2096,7 @@ void PropertyNode::setOverriddenFrom(const PropertyNode* baseProperty)
writable_ = baseProperty->writable_;
if (user_ == FlagValueDefault)
user_ = baseProperty->user_;
- overrides = baseProperty;
+ overrides_ = baseProperty;
}
/*!
@@ -2084,8 +2128,8 @@ QMultiMap<QString,Node*> QmlTypeNode::inheritedBy;
Constructs a Qml class node. The new node has the given
\a parent and \a name.
*/
-QmlTypeNode::QmlTypeNode(InnerNode *parent, const QString& name)
- : InnerNode(QmlType, parent, name),
+QmlTypeNode::QmlTypeNode(Aggregate *parent, const QString& name)
+ : Aggregate(QmlType, parent, name),
abstract_(false),
cnodeRequired_(false),
wrapper_(false),
@@ -2199,9 +2243,9 @@ QString QmlTypeNode::logicalModuleIdentifier() const
Constructs a Qml basic type node. The new node has the given
\a parent and \a name.
*/
-QmlBasicTypeNode::QmlBasicTypeNode(InnerNode *parent,
+QmlBasicTypeNode::QmlBasicTypeNode(Aggregate *parent,
const QString& name)
- : InnerNode(QmlBasicType, parent, name)
+ : Aggregate(QmlBasicType, parent, name)
{
setTitle(name);
setGenus(Node::QML);
@@ -2212,7 +2256,7 @@ QmlBasicTypeNode::QmlBasicTypeNode(InnerNode *parent,
always a QmlTypeNode.
*/
QmlPropertyGroupNode::QmlPropertyGroupNode(QmlTypeNode* parent, const QString& name)
- : InnerNode(QmlPropertyGroup, parent, name)
+ : Aggregate(QmlPropertyGroup, parent, name)
{
idNumber_ = -1;
setGenus(Node::QML);
@@ -2235,7 +2279,7 @@ QString QmlPropertyGroupNode::idNumber()
/*!
Constructor for the QML property node.
*/
-QmlPropertyNode::QmlPropertyNode(InnerNode* parent,
+QmlPropertyNode::QmlPropertyNode(Aggregate* parent,
const QString& name,
const QString& type,
bool attached)
@@ -2281,16 +2325,16 @@ bool QmlPropertyNode::isWritable()
if (pn)
return pn->isWritable();
else
- location().warning(tr("No Q_PROPERTY for QML property %1::%2::%3 "
- "in C++ class documented as QML type: "
- "(property not found in the C++ class or its base classes)")
- .arg(logicalModuleName()).arg(qmlTypeName()).arg(name()));
+ defLocation().warning(tr("No Q_PROPERTY for QML property %1::%2::%3 "
+ "in C++ class documented as QML type: "
+ "(property not found in the C++ class or its base classes)")
+ .arg(logicalModuleName()).arg(qmlTypeName()).arg(name()));
}
else
- location().warning(tr("No Q_PROPERTY for QML property %1::%2::%3 "
- "in C++ class documented as QML type: "
- "(C++ class not specified or not found).")
- .arg(logicalModuleName()).arg(qmlTypeName()).arg(name()));
+ defLocation().warning(tr("No Q_PROPERTY for QML property %1::%2::%3 "
+ "in C++ class documented as QML type: "
+ "(C++ class not specified or not found).")
+ .arg(logicalModuleName()).arg(qmlTypeName()).arg(name()));
}
}
return true;
@@ -2477,6 +2521,7 @@ QString Node::cleanId(const QString &str)
return clean;
}
+#if 0
/*!
Creates a string that can be used as a UUID for the node,
depending on the type and subtype of the node. Uniquenss
@@ -2574,14 +2619,14 @@ QString Node::idForNode() const
str = "js-method-" + parent_->name().toLower() + "-" + func->name();
else if (parent_->type() == Document) {
qDebug() << "qdoc internal error: Node subtype not handled:"
- << parent_->subType() << func->name();
+ << parent_->docSubtype() << func->name();
}
else
qDebug() << "qdoc internal error: Node type not handled:"
<< parent_->type() << func->name();
}
- if (func->overloadNumber() != 1)
+ if (func->overloadNumber() != 0)
str += QLatin1Char('-') + QString::number(func->overloadNumber());
}
break;
@@ -2599,7 +2644,7 @@ QString Node::idForNode() const
break;
case Node::Document:
{
- switch (subType()) {
+ switch (docSubtype()) {
case Node::Page:
case Node::HeaderFile:
str = title();
@@ -2620,7 +2665,7 @@ QString Node::idForNode() const
break;
default:
qDebug() << "ERROR: A case was not handled in Node::idForNode():"
- << "subType():" << subType() << "type():" << type();
+ << "docSubtype():" << docSubtype() << "type():" << type();
break;
}
}
@@ -2682,7 +2727,7 @@ QString Node::idForNode() const
else
str = "js-method-";
str += parent_->name().toLower() + "-" + func->name();
- if (func->overloadNumber() != 1)
+ if (func->overloadNumber() != 0)
str += QLatin1Char('-') + QString::number(func->overloadNumber());
break;
case Node::Variable:
@@ -2690,12 +2735,12 @@ QString Node::idForNode() const
break;
default:
qDebug() << "ERROR: A case was not handled in Node::idForNode():"
- << "type():" << type() << "subType():" << subType();
+ << "type():" << type() << "docSubtype():" << docSubtype();
break;
}
if (str.isEmpty()) {
qDebug() << "ERROR: A link text was empty in Node::idForNode():"
- << "type():" << type() << "subType():" << subType()
+ << "type():" << type() << "docSubtype():" << docSubtype()
<< "name():" << name()
<< "title():" << title();
}
@@ -2704,12 +2749,13 @@ QString Node::idForNode() const
}
return str;
}
+#endif
/*!
Prints the inner node's list of children.
For debugging only.
*/
-void InnerNode::printChildren(const QString& title)
+void Aggregate::printChildren(const QString& title)
{
qDebug() << title << name() << children_.size();
if (children_.size() > 0) {
diff --git a/src/tools/qdoc/node.h b/src/tools/qdoc/node.h
index 2ccd97dbd1..f852e480a6 100644
--- a/src/tools/qdoc/node.h
+++ b/src/tools/qdoc/node.h
@@ -48,7 +48,7 @@ class Node;
class Tree;
class EnumNode;
class ClassNode;
-class InnerNode;
+class Aggregate;
class ExampleNode;
class TypedefNode;
class QmlTypeNode;
@@ -59,6 +59,7 @@ class CollectionNode;
class QmlPropertyNode;
typedef QList<Node*> NodeList;
+typedef QList<PropertyNode*> PropNodeList;
typedef QMap<QString, Node*> NodeMap;
typedef QMultiMap<QString, Node*> NodeMultiMap;
typedef QPair<int, int> NodeTypePair;
@@ -71,7 +72,7 @@ class Node
Q_DECLARE_TR_FUNCTIONS(QDoc::Node)
public:
- enum Type {
+ enum NodeType {
NoType,
Namespace,
Class,
@@ -94,8 +95,8 @@ public:
LastType
};
- enum SubType {
- NoSubType,
+ enum DocSubtype {
+ NoSubtype,
Example,
HeaderFile,
File,
@@ -115,7 +116,7 @@ public:
Obsolete,
Deprecated,
Preliminary,
- Commendable,
+ Active,
Internal,
Intermediate
}; // don't reorder this enum
@@ -132,13 +133,7 @@ public:
NextLink,
PreviousLink,
ContentsLink,
- IndexLink /*,
- GlossaryLink,
- CopyrightLink,
- ChapterLink,
- SectionLink,
- SubsectionLink,
- AppendixLink */
+ IndexLink
};
enum PageType {
@@ -172,24 +167,24 @@ public:
Node::Genus genus() const { return (Genus) genus_; }
void setGenus(Genus t) { genus_ = (unsigned char) t; }
- void setAccess(Access access) { access_ = (unsigned char) access; }
- void setLocation(const Location& location) { loc_ = location; }
+ void setAccess(Access t) { access_ = (unsigned char) t; }
+ void setLocation(const Location& t);
void setDoc(const Doc& doc, bool replace = false);
- void setStatus(Status status) {
- if (status_ == (unsigned char) Obsolete && status == Deprecated)
+ void setStatus(Status t) {
+ if (status_ == (unsigned char) Obsolete && t == Deprecated)
return;
- status_ = (unsigned char) status;
+ status_ = (unsigned char) t;
}
- void setThreadSafeness(ThreadSafeness safeness) { safeness_ = (unsigned char) safeness; }
+ void setThreadSafeness(ThreadSafeness t) { safeness_ = (unsigned char) t; }
void setSince(const QString &since);
- void setRelates(InnerNode* pseudoParent);
+ void setRelates(Aggregate* pseudoParent);
void setPhysicalModuleName(const QString &name) { physicalModuleName_ = name; }
void setUrl(const QString& url) { url_ = url; }
- void setTemplateStuff(const QString &templateStuff) { templateStuff_ = templateStuff; }
+ void setTemplateStuff(const QString &t) { templateStuff_ = t; }
void setReconstitutedBrief(const QString &t) { reconstitutedBrief_ = t; }
void setPageType(PageType t) { pageType_ = (unsigned char) t; }
void setPageType(const QString& t);
- void setParent(InnerNode* n) { parent_ = n; }
+ void setParent(Aggregate* n) { parent_ = n; }
void setIndexNodeFlag() { indexNodeFlag_ = true; }
virtual void setOutputFileName(const QString& ) { }
@@ -197,7 +192,7 @@ public:
bool isJsNode() const { return genus() == JS; }
bool isCppNode() const { return genus() == CPP; }
- virtual bool isInnerNode() const = 0;
+ virtual bool isAggregate() const = 0;
virtual bool isCollectionNode() const { return false; }
virtual bool isDocumentNode() const { return false; }
virtual bool isGroup() const { return false; }
@@ -208,11 +203,12 @@ public:
virtual bool isJsType() const { return false; }
virtual bool isQmlBasicType() const { return false; }
virtual bool isJsBasicType() const { return false; }
+ virtual bool isEnumType() const { return false; }
virtual bool isExample() const { return false; }
virtual bool isExampleFile() const { return false; }
virtual bool isHeaderFile() const { return false; }
virtual bool isLeaf() const { return false; }
- virtual bool isReimp() const { return false; }
+ virtual bool isReimplemented() const { return false; }
virtual bool isFunction() const { return false; }
virtual bool isNamespace() const { return false; }
virtual bool isClass() const { return false; }
@@ -253,19 +249,19 @@ public:
virtual bool isInternal() const;
virtual void setDataType(const QString& ) { }
virtual void setReadOnly(bool ) { }
- virtual Node* disambiguate(Type , SubType ) { return this; }
+ virtual Node* disambiguate(NodeType , DocSubtype ) { return this; }
virtual bool wasSeen() const { return false; }
virtual void appendGroupName(const QString& ) { }
virtual QString element() const { return QString(); }
virtual Tree* tree() const;
virtual void findChildren(const QString& , NodeList& nodes) const { nodes.clear(); }
bool isIndexNode() const { return indexNodeFlag_; }
- Type type() const { return (Type) nodeType_; }
- virtual SubType subType() const { return NoSubType; }
+ NodeType type() const { return (NodeType) nodeType_; }
+ virtual DocSubtype docSubtype() const { return NoSubtype; }
bool match(const NodeTypeList& types) const;
- InnerNode* parent() const { return parent_; }
+ Aggregate* parent() const { return parent_; }
const Node* root() const;
- InnerNode* relates() const { return relatesTo_; }
+ Aggregate* relates() const { return relatesTo_; }
const QString& name() const { return name_; }
QString physicalModuleName() const;
QString url() const { return url_; }
@@ -282,7 +278,9 @@ public:
Access access() const { return (Access) access_; }
bool isPrivate() const { return (Access) access_ == Private; }
QString accessString() const;
- const Location& location() const { return loc_; }
+ const Location& declLocation() const { return declLocation_; }
+ const Location& defLocation() const { return defLocation_; }
+ const Location& location() const { return (defLocation_.isEmpty() ? declLocation_ : defLocation_); }
const Doc& doc() const { return doc_; }
bool hasDoc() const { return !doc_.isEmpty(); }
Status status() const { return (Status) status_; }
@@ -301,7 +299,7 @@ public:
void clearRelated() { relatesTo_ = 0; }
- QString guid() const;
+ //QString guid() const;
QString extractClassName(const QString &string) const;
virtual QString qmlTypeName() const { return name_; }
virtual QString qmlFullBaseName() const { return QString(); }
@@ -322,7 +320,7 @@ public:
virtual void setOutputSubdirectory(const QString& t) { outSubDir_ = t; }
QString fullDocumentName() const;
static QString cleanId(const QString &str);
- QString idForNode() const;
+ //QString idForNode() const;
static FlagValue toFlagValue(bool b);
static bool fromFlagValue(FlagValue fv, bool defaultValue);
@@ -333,10 +331,10 @@ public:
static int incPropertyGroupCount();
static void clearPropertyGroupCount();
static void initialize();
- static Type goal(const QString& t) { return goals_.value(t); }
+ static NodeType goal(const QString& t) { return goals_.value(t); }
protected:
- Node(Type type, InnerNode* parent, const QString& name);
+ Node(NodeType type, Aggregate* parent, const QString& name);
private:
@@ -348,10 +346,11 @@ private:
unsigned char status_;
bool indexNodeFlag_;
- InnerNode* parent_;
- InnerNode* relatesTo_;
+ Aggregate* parent_;
+ Aggregate* relatesTo_;
QString name_;
- Location loc_;
+ Location declLocation_;
+ Location defLocation_;
Doc doc_;
QMap<LinkType, QPair<QString, QString> > linkMap_;
QString fileNameBase_;
@@ -360,39 +359,37 @@ private:
QString since_;
QString templateStuff_;
QString reconstitutedBrief_;
- mutable QString uuid_;
+ //mutable QString uuid_;
QString outSubDir_;
static QStringMap operators_;
static int propertyGroupCount_;
- static QMap<QString,Node::Type> goals_;
+ static QMap<QString,Node::NodeType> goals_;
};
-class InnerNode : public Node
+class Aggregate : public Node
{
public:
- virtual ~InnerNode();
+ virtual ~Aggregate();
Node* findChildNode(const QString& name, Node::Genus genus) const;
- Node* findChildNode(const QString& name, Type type);
+ Node* findChildNode(const QString& name, NodeType type);
virtual void findChildren(const QString& name, NodeList& nodes) const Q_DECL_OVERRIDE;
FunctionNode* findFunctionNode(const QString& name) const;
FunctionNode* findFunctionNode(const FunctionNode* clone) const;
void addInclude(const QString &include);
void setIncludes(const QStringList &includes);
- void setOverload(FunctionNode* func, bool overlode);
void normalizeOverloads();
void makeUndocumentedChildrenInternal();
void deleteChildren();
void removeFromRelated();
- virtual bool isInnerNode() const Q_DECL_OVERRIDE { return true; }
+ virtual bool isAggregate() const Q_DECL_OVERRIDE { return true; }
virtual bool isLeaf() const Q_DECL_OVERRIDE { return false; }
const EnumNode* findEnumNodeForValue(const QString &enumValue) const;
const NodeList & childNodes() const { return children_; }
const NodeList & relatedNodes() const { return related_; }
int count() const { return children_.size(); }
- int overloadNumber(const FunctionNode* func) const;
NodeList overloads(const QString &funcName) const;
const QStringList& includes() const { return includes_; }
@@ -411,9 +408,11 @@ public:
void addChild(Node* child);
void removeChild(Node* child);
void setOutputSubdirectory(const QString& t) Q_DECL_OVERRIDE;
+ const NodeMap& primaryFunctionMap() { return primaryFunctionMap_; }
+ const QMap<QString, NodeList>& secondaryFunctionMap() { return secondaryFunctionMap_; }
protected:
- InnerNode(Type type, InnerNode* parent, const QString& name);
+ Aggregate(NodeType type, Aggregate* parent, const QString& name);
private:
friend class Node;
@@ -428,9 +427,9 @@ private:
NodeList children_;
NodeList enumChildren_;
NodeList related_;
- QMap<QString, Node*> childMap;
- QMap<QString, Node*> primaryFunctionMap;
- QMap<QString, NodeList> secondaryFunctionMap;
+ NodeMap childMap_;
+ NodeMap primaryFunctionMap_;
+ QMap<QString, NodeList> secondaryFunctionMap_;
};
class LeafNode : public Node
@@ -439,18 +438,18 @@ public:
LeafNode();
virtual ~LeafNode() { }
- virtual bool isInnerNode() const Q_DECL_OVERRIDE { return false; }
+ virtual bool isAggregate() const Q_DECL_OVERRIDE { return false; }
virtual bool isLeaf() const Q_DECL_OVERRIDE { return true; }
protected:
- LeafNode(Type type, InnerNode* parent, const QString& name);
- LeafNode(InnerNode* parent, Type type, const QString& name);
+ LeafNode(NodeType type, Aggregate* parent, const QString& name);
+ LeafNode(Aggregate* parent, NodeType type, const QString& name);
};
-class NamespaceNode : public InnerNode
+class NamespaceNode : public Aggregate
{
public:
- NamespaceNode(InnerNode* parent, const QString& name);
+ NamespaceNode(Aggregate* parent, const QString& name);
virtual ~NamespaceNode() { }
virtual bool isNamespace() const Q_DECL_OVERRIDE { return true; }
virtual Tree* tree() const Q_DECL_OVERRIDE { return (parent() ? parent()->tree() : tree_); }
@@ -498,10 +497,10 @@ struct UsingClause
QString signature_;
};
-class ClassNode : public InnerNode
+class ClassNode : public Aggregate
{
public:
- ClassNode(InnerNode* parent, const QString& name);
+ ClassNode(Aggregate* parent, const QString& name);
virtual ~ClassNode() { }
virtual bool isClass() const Q_DECL_OVERRIDE { return true; }
virtual bool isWrapper() const Q_DECL_OVERRIDE { return wrapper_; }
@@ -544,13 +543,13 @@ private:
QmlTypeNode* qmlelement;
};
-class DocumentNode : public InnerNode
+class DocumentNode : public Aggregate
{
public:
- DocumentNode(InnerNode* parent,
+ DocumentNode(Aggregate* parent,
const QString& name,
- SubType subType,
+ DocSubtype docSubtype,
PageType ptype);
virtual ~DocumentNode() { }
@@ -558,7 +557,7 @@ public:
virtual void setTitle(const QString &title) Q_DECL_OVERRIDE;
virtual void setSubTitle(const QString &subTitle) Q_DECL_OVERRIDE { subtitle_ = subTitle; }
- SubType subType() const Q_DECL_OVERRIDE { return nodeSubtype_; }
+ DocSubtype docSubtype() const Q_DECL_OVERRIDE { return nodeSubtype_; }
virtual QString title() const Q_DECL_OVERRIDE { return title_; }
virtual QString fullTitle() const Q_DECL_OVERRIDE;
virtual QString subTitle() const Q_DECL_OVERRIDE;
@@ -566,13 +565,13 @@ public:
virtual QString nameForLists() const Q_DECL_OVERRIDE { return title(); }
virtual void setImageFileName(const QString& ) { }
- virtual bool isHeaderFile() const Q_DECL_OVERRIDE { return (subType() == Node::HeaderFile); }
- virtual bool isExample() const Q_DECL_OVERRIDE { return (subType() == Node::Example); }
+ virtual bool isHeaderFile() const Q_DECL_OVERRIDE { return (docSubtype() == Node::HeaderFile); }
+ virtual bool isExample() const Q_DECL_OVERRIDE { return (docSubtype() == Node::Example); }
virtual bool isExampleFile() const Q_DECL_OVERRIDE { return (parent() && parent()->isExample()); }
virtual bool isExternalPage() const Q_DECL_OVERRIDE { return nodeSubtype_ == ExternalPage; }
protected:
- SubType nodeSubtype_;
+ DocSubtype nodeSubtype_;
QString title_;
QString subtitle_;
};
@@ -580,7 +579,7 @@ protected:
class ExampleNode : public DocumentNode
{
public:
- ExampleNode(InnerNode* parent, const QString& name)
+ ExampleNode(Aggregate* parent, const QString& name)
: DocumentNode(parent, name, Node::Example, Node::ExamplePage) { }
virtual ~ExampleNode() { }
virtual QString imageFileName() const Q_DECL_OVERRIDE { return imageFileName_; }
@@ -610,10 +609,10 @@ struct ImportRec {
typedef QList<ImportRec> ImportList;
-class QmlTypeNode : public InnerNode
+class QmlTypeNode : public Aggregate
{
public:
- QmlTypeNode(InnerNode* parent, const QString& name);
+ QmlTypeNode(Aggregate* parent, const QString& name);
virtual ~QmlTypeNode();
virtual bool isQmlType() const Q_DECL_OVERRIDE { return genus() == Node::QML; }
virtual bool isJsType() const Q_DECL_OVERRIDE { return genus() == Node::JS; }
@@ -665,17 +664,17 @@ private:
ImportList importList_;
};
-class QmlBasicTypeNode : public InnerNode
+class QmlBasicTypeNode : public Aggregate
{
public:
- QmlBasicTypeNode(InnerNode* parent,
+ QmlBasicTypeNode(Aggregate* parent,
const QString& name);
virtual ~QmlBasicTypeNode() { }
virtual bool isQmlBasicType() const Q_DECL_OVERRIDE { return (genus() == Node::QML); }
virtual bool isJsBasicType() const Q_DECL_OVERRIDE { return (genus() == Node::JS); }
};
-class QmlPropertyGroupNode : public InnerNode
+class QmlPropertyGroupNode : public Aggregate
{
public:
QmlPropertyGroupNode(QmlTypeNode* parent, const QString& name);
@@ -705,7 +704,7 @@ class QmlPropertyNode : public LeafNode
Q_DECLARE_TR_FUNCTIONS(QDoc::QmlPropertyNode)
public:
- QmlPropertyNode(InnerNode *parent,
+ QmlPropertyNode(Aggregate *parent,
const QString& name,
const QString& type,
bool attached);
@@ -760,57 +759,58 @@ class EnumItem
public:
EnumItem() { }
EnumItem(const QString& name, const QString& value)
- : nam(name), val(value) { }
+ : name_(name), value_(value) { }
- const QString& name() const { return nam; }
- const QString& value() const { return val; }
+ const QString& name() const { return name_; }
+ const QString& value() const { return value_; }
private:
- QString nam;
- QString val;
+ QString name_;
+ QString value_;
};
class EnumNode : public LeafNode
{
public:
- EnumNode(InnerNode* parent, const QString& name);
+ EnumNode(Aggregate* parent, const QString& name);
virtual ~EnumNode() { }
void addItem(const EnumItem& item);
void setFlagsType(TypedefNode* typedeff);
- bool hasItem(const QString &name) const { return names.contains(name); }
+ bool hasItem(const QString &name) const { return names_.contains(name); }
+ virtual bool isEnumType() const Q_DECL_OVERRIDE { return true; }
- const QList<EnumItem>& items() const { return itms; }
+ const QList<EnumItem>& items() const { return items_; }
Access itemAccess(const QString& name) const;
- const TypedefNode* flagsType() const { return ft; }
+ const TypedefNode* flagsType() const { return flagsType_; }
QString itemValue(const QString &name) const;
private:
- QList<EnumItem> itms;
- QSet<QString> names;
- const TypedefNode* ft;
+ QList<EnumItem> items_;
+ QSet<QString> names_;
+ const TypedefNode* flagsType_;
};
class TypedefNode : public LeafNode
{
public:
- TypedefNode(InnerNode* parent, const QString& name);
+ TypedefNode(Aggregate* parent, const QString& name);
virtual ~TypedefNode() { }
- const EnumNode* associatedEnum() const { return ae; }
+ const EnumNode* associatedEnum() const { return associatedEnum_; }
private:
- void setAssociatedEnum(const EnumNode* enume);
+ void setAssociatedEnum(const EnumNode* t);
friend class EnumNode;
- const EnumNode* ae;
+ const EnumNode* associatedEnum_;
};
-inline void EnumNode::setFlagsType(TypedefNode* typedeff)
+inline void EnumNode::setFlagsType(TypedefNode* t)
{
- ft = typedeff;
- typedeff->setAssociatedEnum(this);
+ flagsType_ = t;
+ t->setAssociatedEnum(this);
}
@@ -826,21 +826,21 @@ public:
Parameter& operator=(const Parameter& p);
- void setName(const QString& name) { nam = name; }
+ void setName(const QString& name) { name_ = name; }
- bool hasType() const { return lef.length() + rig.length() > 0; }
- const QString& leftType() const { return lef; }
- const QString& rightType() const { return rig; }
- const QString& name() const { return nam; }
- const QString& defaultValue() const { return def; }
+ bool hasType() const { return leftType_.length() + rightType_.length() > 0; }
+ const QString& leftType() const { return leftType_; }
+ const QString& rightType() const { return rightType_; }
+ const QString& name() const { return name_; }
+ const QString& defaultValue() const { return defaultValue_; }
QString reconstruct(bool value = false) const;
private:
- QString lef;
- QString rig;
- QString nam;
- QString def;
+ QString leftType_;
+ QString rightType_;
+ QString name_;
+ QString defaultValue_;
};
class FunctionNode : public LeafNode
@@ -855,35 +855,37 @@ public:
MacroWithParams,
MacroWithoutParams,
Native };
- enum Virtualness { NonVirtual, ImpureVirtual, PureVirtual };
+ enum Virtualness { NonVirtual, NormalVirtual, PureVirtual };
- FunctionNode(InnerNode* parent, const QString &name);
- FunctionNode(Type type, InnerNode* parent, const QString &name, bool attached);
+ FunctionNode(Aggregate* parent, const QString &name);
+ FunctionNode(NodeType type, Aggregate* parent, const QString &name, bool attached);
virtual ~FunctionNode() { }
- void setReturnType(const QString& returnType) { rt = returnType; }
- void setParentPath(const QStringList& parentPath) { pp = parentPath; }
- void setMetaness(Metaness metaness) { met = metaness; }
- void setVirtualness(Virtualness virtualness);
- void setConst(bool conste) { con = conste; }
- void setStatic(bool statique) { sta = statique; }
- void setOverload(bool overlode);
- void setReimp(bool r);
+ void setReturnType(const QString& t) { returnType_ = t; }
+ void setParentPath(const QStringList& p) { parentPath_ = p; }
+ void setMetaness(Metaness t) { metaness_ = t; }
+ void setVirtualness(Virtualness v);
+ void setConst(bool b) { const_ = b; }
+ void setStatic(bool b) { static_ = b; }
+ unsigned char overloadNumber() const { return overloadNumber_; }
+ void setOverloadFlag(bool b) { overload_ = b; }
+ void setOverloadNumber(unsigned char n) { overloadNumber_ = n; }
+ void setReimplemented(bool b);
void addParameter(const Parameter& parameter);
inline void setParameters(const QList<Parameter>& parameters);
void borrowParameterNames(const FunctionNode* source);
void setReimplementedFrom(FunctionNode* from);
- const QString& returnType() const { return rt; }
- Metaness metaness() const { return met; }
+ const QString& returnType() const { return returnType_; }
+ Metaness metaness() const { return metaness_; }
bool isMacro() const {
- return met == MacroWithParams || met == MacroWithoutParams;
+ return metaness_ == MacroWithParams || metaness_ == MacroWithoutParams;
}
- Virtualness virtualness() const { return vir; }
- bool isConst() const { return con; }
- bool isStatic() const { return sta; }
- bool isOverload() const { return ove; }
- bool isReimp() const Q_DECL_OVERRIDE { return reimp; }
+ Virtualness virtualness() const { return virtualness_; }
+ bool isConst() const { return const_; }
+ bool isStatic() const { return static_; }
+ bool isOverload() const { return overload_; }
+ bool isReimplemented() const Q_DECL_OVERRIDE { return reimplemented_; }
bool isFunction() const Q_DECL_OVERRIDE { return true; }
virtual bool isQmlSignal() const Q_DECL_OVERRIDE {
return (type() == Node::QmlSignal) && (genus() == Node::QML);
@@ -903,17 +905,20 @@ public:
virtual bool isJsMethod() const Q_DECL_OVERRIDE {
return (type() == Node::QmlMethod) && (genus() == Node::JS);
}
- int overloadNumber() const;
- const QList<Parameter>& parameters() const { return params; }
- void clearParams() { params.clear(); }
+ const QList<Parameter>& parameters() const { return parameters_; }
+ void clearParams() { parameters_.clear(); }
QStringList parameterNames() const;
QString rawParameters(bool names = false, bool values = false) const;
- const FunctionNode* reimplementedFrom() const { return rf; }
- const QList<FunctionNode*> &reimplementedBy() const { return rb; }
- const PropertyNode* associatedProperty() const { return ap; }
- const QStringList& parentPath() const { return pp; }
-
- QStringList reconstructParams(bool values = false) const;
+ const FunctionNode* reimplementedFrom() const { return reimplementedFrom_; }
+ const QList<FunctionNode*> &reimplementedBy() const { return reimplementedBy_; }
+ const PropNodeList& associatedProperties() const { return associatedProperties_; }
+ const QStringList& parentPath() const { return parentPath_; }
+ bool hasAssociatedProperties() const { return !associatedProperties_.isEmpty(); }
+ bool hasOneAssociatedProperty() const { return (associatedProperties_.size() == 1); }
+ PropertyNode* firstAssociatedProperty() const { return associatedProperties_[0]; }
+ bool hasActiveAssociatedProperty() const;
+
+ QStringList reconstructParameters(bool values = false) const;
QString signature(bool values = false) const;
virtual QString element() const Q_DECL_OVERRIDE { return parent()->name(); }
virtual bool isAttached() const Q_DECL_OVERRIDE { return attached_; }
@@ -934,25 +939,26 @@ public:
void debug() const;
private:
- void setAssociatedProperty(PropertyNode* property);
+ void addAssociatedProperty(PropertyNode* property);
- friend class InnerNode;
+ friend class Aggregate;
friend class PropertyNode;
- QString rt;
- QStringList pp;
- Metaness met;
- Virtualness vir;
- bool con : 1;
- bool sta : 1;
- bool ove : 1;
- bool reimp: 1;
+ QString returnType_;
+ QStringList parentPath_;
+ Metaness metaness_;
+ Virtualness virtualness_;
+ bool const_ : 1;
+ bool static_ : 1;
+ bool reimplemented_: 1;
bool attached_: 1;
bool privateSignal_: 1;
- QList<Parameter> params;
- const FunctionNode* rf;
- const PropertyNode* ap;
- QList<FunctionNode*> rb;
+ bool overload_ : 1;
+ unsigned char overloadNumber_;
+ QList<Parameter> parameters_;
+ const FunctionNode* reimplementedFrom_;
+ PropNodeList associatedProperties_;
+ QList<FunctionNode*> reimplementedBy_;
};
class PropertyNode : public LeafNode
@@ -961,7 +967,7 @@ public:
enum FunctionRole { Getter, Setter, Resetter, Notifier };
enum { NumFunctionRoles = Notifier + 1 };
- PropertyNode(InnerNode* parent, const QString& name);
+ PropertyNode(Aggregate* parent, const QString& name);
virtual ~PropertyNode() { }
virtual void setDataType(const QString& dataType) Q_DECL_OVERRIDE { type_ = dataType; }
@@ -974,30 +980,31 @@ public:
void setWritable(bool writable) { writable_ = toFlagValue(writable); }
void setUser(bool user) { user_ = toFlagValue(user); }
void setOverriddenFrom(const PropertyNode* baseProperty);
- void setRuntimeDesFunc(const QString& rdf) { runtimeDesFunc = rdf; }
- void setRuntimeScrFunc(const QString& scrf) { runtimeScrFunc = scrf; }
- void setConstant() { cst = true; }
- void setFinal() { fnl = true; }
- void setRevision(int revision) { rev = revision; }
+ void setRuntimeDesFunc(const QString& rdf) { runtimeDesFunc_ = rdf; }
+ void setRuntimeScrFunc(const QString& scrf) { runtimeScrFunc_ = scrf; }
+ void setConstant() { const_ = true; }
+ void setFinal() { final_ = true; }
+ void setRevision(int revision) { revision_ = revision; }
const QString &dataType() const { return type_; }
QString qualifiedDataType() const;
NodeList functions() const;
- NodeList functions(FunctionRole role) const { return funcs[(int)role]; }
+ NodeList functions(FunctionRole role) const { return functions_[(int)role]; }
NodeList getters() const { return functions(Getter); }
NodeList setters() const { return functions(Setter); }
NodeList resetters() const { return functions(Resetter); }
NodeList notifiers() const { return functions(Notifier); }
+ FunctionRole role(const FunctionNode* fn) const;
bool isStored() const { return fromFlagValue(stored_, storedDefault()); }
bool isDesignable() const { return fromFlagValue(designable_, designableDefault()); }
bool isScriptable() const { return fromFlagValue(scriptable_, scriptableDefault()); }
- const QString& runtimeDesignabilityFunction() const { return runtimeDesFunc; }
- const QString& runtimeScriptabilityFunction() const { return runtimeScrFunc; }
+ const QString& runtimeDesignabilityFunction() const { return runtimeDesFunc_; }
+ const QString& runtimeScriptabilityFunction() const { return runtimeScrFunc_; }
bool isWritable() const { return fromFlagValue(writable_, writableDefault()); }
bool isUser() const { return fromFlagValue(user_, userDefault()); }
- bool isConstant() const { return cst; }
- bool isFinal() const { return fnl; }
- const PropertyNode* overriddenFrom() const { return overrides; }
+ bool isConstant() const { return const_; }
+ bool isFinal() const { return final_; }
+ const PropertyNode* overriddenFrom() const { return overrides_; }
bool storedDefault() const { return true; }
bool userDefault() const { return false; }
@@ -1007,68 +1014,68 @@ public:
private:
QString type_;
- QString runtimeDesFunc;
- QString runtimeScrFunc;
- NodeList funcs[NumFunctionRoles];
+ QString runtimeDesFunc_;
+ QString runtimeScrFunc_;
+ NodeList functions_[NumFunctionRoles];
FlagValue stored_;
FlagValue designable_;
FlagValue scriptable_;
FlagValue writable_;
FlagValue user_;
- bool cst;
- bool fnl;
- int rev;
- const PropertyNode* overrides;
+ bool const_;
+ bool final_;
+ int revision_;
+ const PropertyNode* overrides_;
};
-inline void FunctionNode::setParameters(const QList<Parameter> &parameters)
+inline void FunctionNode::setParameters(const QList<Parameter> &p)
{
- params = parameters;
+ parameters_ = p;
}
inline void PropertyNode::addFunction(FunctionNode* function, FunctionRole role)
{
- funcs[(int)role].append(function);
- function->setAssociatedProperty(this);
+ functions_[(int)role].append(function);
+ function->addAssociatedProperty(this);
}
inline void PropertyNode::addSignal(FunctionNode* function, FunctionRole role)
{
- funcs[(int)role].append(function);
- function->setAssociatedProperty(this);
+ functions_[(int)role].append(function);
+ function->addAssociatedProperty(this);
}
inline NodeList PropertyNode::functions() const
{
NodeList list;
for (int i = 0; i < NumFunctionRoles; ++i)
- list += funcs[i];
+ list += functions_[i];
return list;
}
class VariableNode : public LeafNode
{
public:
- VariableNode(InnerNode* parent, const QString &name);
+ VariableNode(Aggregate* parent, const QString &name);
virtual ~VariableNode() { }
- void setLeftType(const QString &leftType) { lt = leftType; }
- void setRightType(const QString &rightType) { rt = rightType; }
- void setStatic(bool statique) { sta = statique; }
+ void setLeftType(const QString &leftType) { lrftType_ = leftType; }
+ void setRightType(const QString &rightType) { rightType_ = rightType; }
+ void setStatic(bool b) { static_ = b; }
- const QString &leftType() const { return lt; }
- const QString &rightType() const { return rt; }
- QString dataType() const { return lt + rt; }
- bool isStatic() const { return sta; }
+ const QString &leftType() const { return lrftType_; }
+ const QString &rightType() const { return rightType_; }
+ QString dataType() const { return lrftType_ + rightType_; }
+ bool isStatic() const { return static_; }
private:
- QString lt;
- QString rt;
- bool sta;
+ QString lrftType_;
+ QString rightType_;
+ bool static_;
};
-inline VariableNode::VariableNode(InnerNode* parent, const QString &name)
- : LeafNode(Variable, parent, name), sta(false)
+inline VariableNode::VariableNode(Aggregate* parent, const QString &name)
+ : LeafNode(Variable, parent, name), static_(false)
{
setGenus(Node::CPP);
}
@@ -1076,20 +1083,20 @@ inline VariableNode::VariableNode(InnerNode* parent, const QString &name)
class DitaMapNode : public DocumentNode
{
public:
- DitaMapNode(InnerNode* parent, const QString& name)
+ DitaMapNode(Aggregate* parent, const QString& name)
: DocumentNode(parent, name, Node::Page, Node::DitaMapPage) { }
virtual ~DitaMapNode() { }
const DitaRefList& map() const { return doc().ditamap(); }
};
-class CollectionNode : public InnerNode
+class CollectionNode : public Aggregate
{
public:
- CollectionNode(Type type,
- InnerNode* parent,
+ CollectionNode(NodeType type,
+ Aggregate* parent,
const QString& name,
- Genus genus) : InnerNode(type, parent, name), seen_(false)
+ Genus genus) : Aggregate(type, parent, name), seen_(false)
{
setPageType(Node::OverviewPage);
setGenus(genus);
diff --git a/src/tools/qdoc/plaincodemarker.cpp b/src/tools/qdoc/plaincodemarker.cpp
index 94561c3f48..bf2a55b2d5 100644
--- a/src/tools/qdoc/plaincodemarker.cpp
+++ b/src/tools/qdoc/plaincodemarker.cpp
@@ -58,7 +58,7 @@ bool PlainCodeMarker::recognizeLanguage( const QString& /* lang */ )
return false;
}
-Atom::Type PlainCodeMarker::atomType() const
+Atom::AtomType PlainCodeMarker::atomType() const
{
return Atom::Code;
}
@@ -109,7 +109,7 @@ QString PlainCodeMarker::functionEndRegExp( const QString& /* funcName */ )
return QString();
}
-QList<Section> PlainCodeMarker::sections(const InnerNode * /* innerNode */,
+QList<Section> PlainCodeMarker::sections(const Aggregate * /* innerNode */,
SynopsisStyle /* style */,
Status /* status */)
{
diff --git a/src/tools/qdoc/plaincodemarker.h b/src/tools/qdoc/plaincodemarker.h
index 6d41b3dd81..b83a3e4697 100644
--- a/src/tools/qdoc/plaincodemarker.h
+++ b/src/tools/qdoc/plaincodemarker.h
@@ -51,7 +51,7 @@ public:
bool recognizeCode( const QString& code ) Q_DECL_OVERRIDE;
bool recognizeExtension( const QString& ext ) Q_DECL_OVERRIDE;
bool recognizeLanguage( const QString& lang ) Q_DECL_OVERRIDE;
- Atom::Type atomType() const Q_DECL_OVERRIDE;
+ Atom::AtomType atomType() const Q_DECL_OVERRIDE;
QString markedUpCode( const QString& code, const Node *relative, const Location &location ) Q_DECL_OVERRIDE;
QString markedUpSynopsis( const Node *node, const Node *relative,
SynopsisStyle style ) Q_DECL_OVERRIDE;
@@ -61,7 +61,7 @@ public:
QString markedUpIncludes( const QStringList& includes ) Q_DECL_OVERRIDE;
QString functionBeginRegExp( const QString& funcName ) Q_DECL_OVERRIDE;
QString functionEndRegExp( const QString& funcName ) Q_DECL_OVERRIDE;
- QList<Section> sections(const InnerNode *innerNode, SynopsisStyle style, Status status) Q_DECL_OVERRIDE;
+ QList<Section> sections(const Aggregate *innerNode, SynopsisStyle style, Status status) Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE
diff --git a/src/tools/qdoc/puredocparser.cpp b/src/tools/qdoc/puredocparser.cpp
index e47460efb2..bfd3925353 100644
--- a/src/tools/qdoc/puredocparser.cpp
+++ b/src/tools/qdoc/puredocparser.cpp
@@ -207,14 +207,14 @@ bool PureDocParser::processQdocComments()
processOtherMetaCommands(*d, *n);
(*n)->setDoc(*d);
checkModuleInclusion(*n);
- if ((*n)->isInnerNode() && ((InnerNode *)*n)->includes().isEmpty()) {
- InnerNode *m = static_cast<InnerNode *>(*n);
+ if ((*n)->isAggregate() && ((Aggregate *)*n)->includes().isEmpty()) {
+ Aggregate *m = static_cast<Aggregate *>(*n);
while (m->parent() && m->parent() != treeRoot)
m = m->parent();
if (m == *n)
- ((InnerNode *)*n)->addInclude((*n)->name());
+ ((Aggregate *)*n)->addInclude((*n)->name());
else
- ((InnerNode *)*n)->setIncludes(m->includes());
+ ((Aggregate *)*n)->setIncludes(m->includes());
}
++d;
++n;
diff --git a/src/tools/qdoc/qdocdatabase.cpp b/src/tools/qdoc/qdocdatabase.cpp
index bf84fa8335..5d815d344f 100644
--- a/src/tools/qdoc/qdocdatabase.cpp
+++ b/src/tools/qdoc/qdocdatabase.cpp
@@ -815,7 +815,7 @@ void QDocDatabase::processForest()
mode, each tree is analyzed in turn, and its classes and
types are added to the appropriate node maps.
*/
-void QDocDatabase::processForest(void (QDocDatabase::*func) (InnerNode*))
+void QDocDatabase::processForest(void (QDocDatabase::*func) (Aggregate*))
{
Tree* t = forest_.firstTree();
while (t) {
@@ -930,7 +930,7 @@ NodeMultiMap& QDocDatabase::getCppClasses()
Finds all the C++ class nodes and QML type nodes and
sorts them into maps.
*/
-void QDocDatabase::findAllClasses(InnerNode* node)
+void QDocDatabase::findAllClasses(Aggregate* node)
{
NodeList::const_iterator c = node->childNodes().constBegin();
while (c != node->childNodes().constEnd()) {
@@ -957,8 +957,8 @@ void QDocDatabase::findAllClasses(InnerNode* node)
if ((*c)->isQmlBasicType() || (*c)->isJsType())
qmlBasicTypes_.insert(qmlTypeName,*c);
}
- else if ((*c)->isInnerNode()) {
- findAllClasses(static_cast<InnerNode*>(*c));
+ else if ((*c)->isAggregate()) {
+ findAllClasses(static_cast<Aggregate*>(*c));
}
}
++c;
@@ -978,13 +978,13 @@ NodeMapMap& QDocDatabase::getFunctionIndex()
/*!
Finds all the function nodes
*/
-void QDocDatabase::findAllFunctions(InnerNode* node)
+void QDocDatabase::findAllFunctions(Aggregate* node)
{
NodeList::ConstIterator c = node->childNodes().constBegin();
while (c != node->childNodes().constEnd()) {
if ((*c)->access() != Node::Private) {
- if ((*c)->isInnerNode()) {
- findAllFunctions(static_cast<InnerNode*>(*c));
+ if ((*c)->isAggregate()) {
+ findAllFunctions(static_cast<Aggregate*>(*c));
}
else if ((*c)->type() == Node::Function) {
const FunctionNode* func = static_cast<const FunctionNode*>(*c);
@@ -1004,15 +1004,15 @@ void QDocDatabase::findAllFunctions(InnerNode* node)
Finds all the nodes containing legalese text and puts them
in a map.
*/
-void QDocDatabase::findAllLegaleseTexts(InnerNode* node)
+void QDocDatabase::findAllLegaleseTexts(Aggregate* node)
{
NodeList::ConstIterator c = node->childNodes().constBegin();
while (c != node->childNodes().constEnd()) {
if ((*c)->access() != Node::Private) {
if (!(*c)->doc().legaleseText().isEmpty())
legaleseTexts_.insertMulti((*c)->doc().legaleseText(), *c);
- if ((*c)->isInnerNode())
- findAllLegaleseTexts(static_cast<InnerNode *>(*c));
+ if ((*c)->isAggregate())
+ findAllLegaleseTexts(static_cast<Aggregate *>(*c));
}
++c;
}
@@ -1021,13 +1021,13 @@ void QDocDatabase::findAllLegaleseTexts(InnerNode* node)
/*!
Finds all the namespace nodes and puts them in an index.
*/
-void QDocDatabase::findAllNamespaces(InnerNode* node)
+void QDocDatabase::findAllNamespaces(Aggregate* node)
{
NodeList::ConstIterator c = node->childNodes().constBegin();
while (c != node->childNodes().constEnd()) {
if ((*c)->access() != Node::Private || (*c)->isNamespace()) {
- if ((*c)->isInnerNode()) {
- findAllNamespaces(static_cast<InnerNode *>(*c));
+ if ((*c)->isAggregate()) {
+ findAllNamespaces(static_cast<Aggregate *>(*c));
if ((*c)->isNamespace()) {
// Ensure that the namespace's name is not empty (the root
// namespace has no name).
@@ -1046,7 +1046,7 @@ void QDocDatabase::findAllNamespaces(InnerNode* node)
maps. They can be C++ classes, QML types, or they can be
functions, enum types, typedefs, methods, etc.
*/
-void QDocDatabase::findAllObsoleteThings(InnerNode* node)
+void QDocDatabase::findAllObsoleteThings(Aggregate* node)
{
NodeList::const_iterator c = node->childNodes().constBegin();
while (c != node->childNodes().constEnd()) {
@@ -1067,7 +1067,7 @@ void QDocDatabase::findAllObsoleteThings(InnerNode* node)
}
}
else if ((*c)->type() == Node::Class) {
- InnerNode* n = static_cast<InnerNode*>(*c);
+ Aggregate* n = static_cast<Aggregate*>(*c);
bool inserted = false;
NodeList::const_iterator p = n->childNodes().constBegin();
while (p != n->childNodes().constEnd()) {
@@ -1096,7 +1096,7 @@ void QDocDatabase::findAllObsoleteThings(InnerNode* node)
}
}
else if ((*c)->isQmlType() || (*c)->isJsType()) {
- InnerNode* n = static_cast<InnerNode*>(*c);
+ Aggregate* n = static_cast<Aggregate*>(*c);
bool inserted = false;
NodeList::const_iterator p = n->childNodes().constBegin();
while (p != n->childNodes().constEnd()) {
@@ -1127,8 +1127,8 @@ void QDocDatabase::findAllObsoleteThings(InnerNode* node)
++p;
}
}
- else if ((*c)->isInnerNode()) {
- findAllObsoleteThings(static_cast<InnerNode*>(*c));
+ else if ((*c)->isAggregate()) {
+ findAllObsoleteThings(static_cast<Aggregate*>(*c));
}
}
++c;
@@ -1143,7 +1143,7 @@ void QDocDatabase::findAllObsoleteThings(InnerNode* node)
This function is used for generating the "New Classes... in x.y"
section on the \e{What's New in Qt x.y} page.
*/
-void QDocDatabase::findAllSince(InnerNode* node)
+void QDocDatabase::findAllSince(Aggregate* node)
{
NodeList::const_iterator child = node->childNodes().constBegin();
while (child != node->childNodes().constEnd()) {
@@ -1206,8 +1206,8 @@ void QDocDatabase::findAllSince(InnerNode* node)
}
}
// Recursively find child nodes with since commands.
- if ((*child)->isInnerNode())
- findAllSince(static_cast<InnerNode *>(*child));
+ if ((*child)->isAggregate())
+ findAllSince(static_cast<Aggregate *>(*child));
++child;
}
@@ -1264,6 +1264,10 @@ const NodeMap& QDocDatabase::getSinceMap(const QString& key)
to generating documentation.
*/
void QDocDatabase::resolveIssues() {
+ primaryTreeRoot()->normalizeOverloads();
+ fixInheritance();
+ resolveProperties();
+ primaryTreeRoot()->makeUndocumentedChildrenInternal();
resolveQmlInheritance(primaryTreeRoot());
primaryTree()->resolveTargets(primaryTreeRoot());
primaryTree()->resolveCppToQmlLinks();
@@ -1277,6 +1281,7 @@ void QDocDatabase::resolveStuff()
primaryTree()->resolveCppToQmlLinks();
primaryTree()->resolveUsingClauses();
resolveNamespaces();
+ primaryTreeRoot()->normalizeOverloads();
}
/*!
@@ -1394,7 +1399,7 @@ const Node* QDocDatabase::findNodeForTarget(const QString& target, const Node* r
base type node. If the node is found in the tree, set the
node's QML base type node pointer.
*/
-void QDocDatabase::resolveQmlInheritance(InnerNode* root)
+void QDocDatabase::resolveQmlInheritance(Aggregate* root)
{
NodeMap previousSearches;
// Do we need recursion?
@@ -1515,7 +1520,7 @@ FunctionNode* QDocDatabase::findNodeInOpenNamespace(const QStringList& parentPat
This function only searches in the current primary tree.
*/
-Node* QDocDatabase::findNodeInOpenNamespace(QStringList& path, Node::Type type)
+Node* QDocDatabase::findNodeInOpenNamespace(QStringList& path, Node::NodeType type)
{
if (path.isEmpty())
return 0;
@@ -1626,7 +1631,7 @@ const Node* QDocDatabase::findNodeForAtom(const Atom* a, const Node* relative, Q
Tree* domain = 0;
Node::Genus genus = Node::DontCare;
// Reserved for future use
- //Node::Type goal = Node::NoType;
+ //Node::NodeType goal = Node::NoType;
if (atom->isLinkAtom()) {
domain = atom->domain();
diff --git a/src/tools/qdoc/qdocdatabase.h b/src/tools/qdoc/qdocdatabase.h
index b8ca8bc32d..6154ec762b 100644
--- a/src/tools/qdoc/qdocdatabase.h
+++ b/src/tools/qdoc/qdocdatabase.h
@@ -103,7 +103,7 @@ class QDocForest
return 0;
}
- Node* findNodeByNameAndType(const QStringList& path, Node::Type type) {
+ Node* findNodeByNameAndType(const QStringList& path, Node::NodeType type) {
foreach (Tree* t, searchOrder()) {
Node* n = t->findNodeByNameAndType(path, type);
if (n)
@@ -130,9 +130,9 @@ class QDocForest
return 0;
}
- InnerNode* findRelatesNode(const QStringList& path) {
+ Aggregate* findRelatesNode(const QStringList& path) {
foreach (Tree* t, searchOrder()) {
- InnerNode* n = t->findRelatesNode(path);
+ Aggregate* n = t->findRelatesNode(path);
if (n)
return n;
}
@@ -260,12 +260,12 @@ class QDocDatabase
QmlTypeNode* findQmlType(const ImportRec& import, const QString& name);
private:
- void findAllClasses(InnerNode *node);
- void findAllFunctions(InnerNode *node);
- void findAllLegaleseTexts(InnerNode *node);
- void findAllNamespaces(InnerNode *node);
- void findAllObsoleteThings(InnerNode* node);
- void findAllSince(InnerNode *node);
+ void findAllClasses(Aggregate *node);
+ void findAllFunctions(Aggregate *node);
+ void findAllLegaleseTexts(Aggregate *node);
+ void findAllNamespaces(Aggregate *node);
+ void findAllObsoleteThings(Aggregate* node);
+ void findAllSince(Aggregate *node);
public:
/*******************************************************************
@@ -289,7 +289,7 @@ class QDocDatabase
Many of these will be either eliminated or replaced.
********************************************************************/
void resolveInheritance() { primaryTree()->resolveInheritance(); }
- void resolveQmlInheritance(InnerNode* root);
+ void resolveQmlInheritance(Aggregate* root);
void resolveIssues();
void resolveStuff();
void fixInheritance() { primaryTree()->fixInheritance(); }
@@ -297,7 +297,7 @@ class QDocDatabase
void insertTarget(const QString& name,
const QString& title,
- TargetRec::Type type,
+ TargetRec::TargetType type,
Node* node,
int priority) {
primaryTree()->insertTarget(name, title, type, node, priority);
@@ -310,7 +310,7 @@ class QDocDatabase
return primaryTree()->findFunctionNode(parentPath, clone);
}
FunctionNode* findNodeInOpenNamespace(const QStringList& parentPath, const FunctionNode* clone);
- Node* findNodeInOpenNamespace(QStringList& path, Node::Type type);
+ Node* findNodeInOpenNamespace(QStringList& path, Node::NodeType type);
const Node* checkForCollision(const QString& name) {
return primaryTree()->checkForCollision(name);
}
@@ -327,7 +327,7 @@ class QDocDatabase
********************************************************************/
ClassNode* findClassNode(const QStringList& path) { return forest_.findClassNode(path); }
Node* findNodeForInclude(const QStringList& path) { return forest_.findNodeForInclude(path); }
- InnerNode* findRelatesNode(const QStringList& path) { return forest_.findRelatesNode(path); }
+ Aggregate* findRelatesNode(const QStringList& path) { return forest_.findRelatesNode(path); }
const Node* findFunctionNode(const QString& target, const Node* relative, Node::Genus genus) {
return forest_.findFunctionNode(target, relative, genus);
}
@@ -336,7 +336,7 @@ class QDocDatabase
const DocumentNode* findDocumentNodeByTitle(const QString& title) {
return forest_.findDocumentNodeByTitle(title);
}
- Node* findNodeByNameAndType(const QStringList& path, Node::Type type) {
+ Node* findNodeByNameAndType(const QStringList& path, Node::NodeType type) {
return forest_.findNodeByNameAndType(path, type);
}
@@ -414,7 +414,7 @@ class QDocDatabase
Node::Genus genus) {
return forest_.findNode(path, relative, findFlags, genus);
}
- void processForest(void (QDocDatabase::*) (InnerNode*));
+ void processForest(void (QDocDatabase::*) (Aggregate*));
bool isLoaded(const QString& t) { return forest_.isLoaded(t); }
static void initializeDB();
diff --git a/src/tools/qdoc/qdocindexfiles.cpp b/src/tools/qdoc/qdocindexfiles.cpp
index 8961ff71ad..74b0b14347 100644
--- a/src/tools/qdoc/qdocindexfiles.cpp
+++ b/src/tools/qdoc/qdocindexfiles.cpp
@@ -172,9 +172,9 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element,
QString href = element.attribute("href");
Node* node;
Location location;
- InnerNode* parent = 0;
- if (current->isInnerNode())
- parent = static_cast<InnerNode*>(current);
+ Aggregate* parent = 0;
+ if (current->isAggregate())
+ parent = static_cast<Aggregate*>(current);
QString filePath;
int lineNo = 0;
@@ -342,7 +342,7 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element,
else if ((element.nodeName() == "qmlmethod") ||
(element.nodeName() == "qmlsignal") ||
(element.nodeName() == "qmlsignalhandler")) {
- Node::Type t = Node::QmlMethod;
+ Node::NodeType t = Node::QmlMethod;
if (element.nodeName() == "qmlsignal")
t = Node::QmlSignal;
else if (element.nodeName() == "qmlsignalhandler")
@@ -354,7 +354,7 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element,
else if ((element.nodeName() == "jsmethod") ||
(element.nodeName() == "jssignal") ||
(element.nodeName() == "jssignalhandler")) {
- Node::Type t = Node::QmlMethod;
+ Node::NodeType t = Node::QmlMethod;
if (element.nodeName() == "jssignal")
t = Node::QmlSignal;
else if (element.nodeName() == "jssignalhandler")
@@ -405,7 +405,7 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element,
node = cn;
}
else if (element.nodeName() == "page") {
- Node::SubType subtype;
+ Node::DocSubtype subtype;
Node::PageType ptype = Node::NoPageType;
QString attr = element.attribute("subtype");
if (attr == "example") {
@@ -486,8 +486,8 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element,
QString t = element.attribute("virtual");
if (t == "non")
virt = FunctionNode::NonVirtual;
- else if (t == "impure")
- virt = FunctionNode::ImpureVirtual;
+ else if (t == "virtual")
+ virt = FunctionNode::NormalVirtual;
else if (t == "pure")
virt = FunctionNode::PureVirtual;
else
@@ -520,8 +520,14 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element,
functionNode->setMetaness(meta);
functionNode->setConst(element.attribute("const") == "true");
functionNode->setStatic(element.attribute("static") == "true");
- functionNode->setOverload(element.attribute("overload") == "true");
-
+ if (element.attribute("overload") == "true") {
+ functionNode->setOverloadFlag(true);
+ functionNode->setOverloadNumber(element.attribute("overload-number").toUInt());
+ }
+ else {
+ functionNode->setOverloadFlag(false);
+ functionNode->setOverloadNumber(0);
+ }
if (element.hasAttribute("relates")
&& element.attribute("relates") != parent->name()) {
relatedList_.append(
@@ -613,12 +619,12 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element,
node->setStatus(Node::Obsolete);
else if (status == "preliminary")
node->setStatus(Node::Preliminary);
- else if (status == "commendable")
- node->setStatus(Node::Commendable);
+ else if (status == "active")
+ node->setStatus(Node::Active);
else if (status == "internal")
node->setStatus(Node::Internal);
else
- node->setStatus(Node::Commendable);
+ node->setStatus(Node::Active);
QString physicalModuleName = element.attribute("module");
if (!physicalModuleName.isEmpty())
@@ -726,7 +732,7 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
/*
Don't include index nodes in a new index file. Or DITA map nodes.
*/
- if (node->isIndexNode() || node->subType() == Node::DitaMap)
+ if (node->isIndexNode() || node->docSubtype() == Node::DitaMap)
return false;
QString nodeName;
@@ -885,8 +891,8 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
case Node::Preliminary:
status = "preliminary";
break;
- case Node::Commendable:
- status = "commendable";
+ case Node::Active:
+ status = "active";
break;
case Node::Internal:
status = "internal";
@@ -937,7 +943,7 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
else
href = node->name();
if (node->isQmlNode() || node->isJsNode()) {
- InnerNode* p = node->parent();
+ Aggregate* p = node->parent();
if (p) {
if (p->isQmlPropertyGroup() || p->isJsPropertyGroup())
p = p->parent();
@@ -954,11 +960,12 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
if (node->isAbstract())
writer.writeAttribute("abstract", "true");
}
- if (!node->location().fileName().isEmpty())
- writer.writeAttribute("location", node->location().fileName());
- if (!node->location().filePath().isEmpty()) {
- writer.writeAttribute("filepath", node->location().filePath());
- writer.writeAttribute("lineno", QString("%1").arg(node->location().lineNo()));
+ const Location& declLocation = node->declLocation();
+ if (!declLocation.fileName().isEmpty())
+ writer.writeAttribute("location", declLocation.fileName());
+ if (!declLocation.filePath().isEmpty()) {
+ writer.writeAttribute("filepath", declLocation.filePath());
+ writer.writeAttribute("lineno", QString("%1").arg(declLocation.lineNo()));
}
if (!node->since().isEmpty()) {
@@ -1019,7 +1026,7 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
*/
bool writeModuleName = false;
const DocumentNode* docNode = static_cast<const DocumentNode*>(node);
- switch (docNode->subType()) {
+ switch (docNode->docSubtype()) {
case Node::Example:
writer.writeAttribute("subtype", "example");
writeModuleName = true;
@@ -1139,8 +1146,8 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
case FunctionNode::NonVirtual:
writer.writeAttribute("virtual", "non");
break;
- case FunctionNode::ImpureVirtual:
- writer.writeAttribute("virtual", "impure");
+ case FunctionNode::NormalVirtual:
+ writer.writeAttribute("virtual", "virtual");
break;
case FunctionNode::PureVirtual:
writer.writeAttribute("virtual", "pure");
@@ -1182,9 +1189,11 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
if (functionNode->relates()) {
writer.writeAttribute("relates", functionNode->relates()->name());
}
- const PropertyNode* propertyNode = functionNode->associatedProperty();
- if (propertyNode)
- writer.writeAttribute("associated-property", propertyNode->name());
+ if (functionNode->hasAssociatedProperties()) {
+ foreach (PropertyNode* pn, functionNode->associatedProperties()) {
+ writer.writeAttribute("associated-property", pn->name());
+ }
+ }
writer.writeAttribute("type", functionNode->returnType());
if (!brief.isEmpty())
writer.writeAttribute("brief", brief);
@@ -1316,7 +1325,7 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
bool external = false;
if (node->type() == Node::Document) {
const DocumentNode* docNode = static_cast<const DocumentNode*>(node);
- if (docNode->subType() == Node::ExternalPage)
+ if (docNode->docSubtype() == Node::ExternalPage)
external = true;
}
foreach (const Atom* target, node->doc().targets()) {
@@ -1349,8 +1358,8 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
// opening tag, create child elements, then add a closing tag for the
// element. Elements for all other nodes are closed in the opening tag.
- if (node->isInnerNode()) {
- const InnerNode* inner = static_cast<const InnerNode*>(node);
+ if (node->isAggregate()) {
+ const Aggregate* inner = static_cast<const Aggregate*>(node);
if (inner->doc().hasTableOfContents()) {
for (int i = 0; i < inner->doc().tableOfContents().size(); ++i) {
@@ -1453,8 +1462,8 @@ void QDocIndexFiles::generateIndexSections(QXmlStreamWriter& writer,
return;
if (generateIndexSection(writer, node, generateInternalNodes)) {
- if (node->isInnerNode()) {
- const InnerNode* inner = static_cast<const InnerNode*>(node);
+ if (node->isAggregate()) {
+ const Aggregate* inner = static_cast<const Aggregate*>(node);
NodeList cnodes = inner->childNodes();
std::sort(cnodes.begin(), cnodes.end(), compareNodes);
diff --git a/src/tools/qdoc/qdoctagfiles.cpp b/src/tools/qdoc/qdoctagfiles.cpp
index 778df33048..7a1902bbca 100644
--- a/src/tools/qdoc/qdoctagfiles.cpp
+++ b/src/tools/qdoc/qdoctagfiles.cpp
@@ -100,7 +100,7 @@ void QDocTagFiles::destroyQDocTagFiles()
specified, returning true if an element was written; otherwise returns
false.
*/
-void QDocTagFiles::generateTagFileCompounds(QXmlStreamWriter& writer, const InnerNode* inner)
+void QDocTagFiles::generateTagFileCompounds(QXmlStreamWriter& writer, const Aggregate* inner)
{
foreach (const Node* node, inner->childNodes()) {
if (!node->url().isEmpty())
@@ -161,22 +161,22 @@ void QDocTagFiles::generateTagFileCompounds(QXmlStreamWriter& writer, const Inne
}
// Recurse to write all members.
- generateTagFileMembers(writer, static_cast<const InnerNode*>(node));
+ generateTagFileMembers(writer, static_cast<const Aggregate*>(node));
writer.writeEndElement();
// Recurse to write all compounds.
- generateTagFileCompounds(writer, static_cast<const InnerNode*>(node));
+ generateTagFileCompounds(writer, static_cast<const Aggregate*>(node));
}
else {
writer.writeTextElement("name", node->fullDocumentName());
writer.writeTextElement("filename", gen_->fullDocumentLocation(node, false));
// Recurse to write all members.
- generateTagFileMembers(writer, static_cast<const InnerNode*>(node));
+ generateTagFileMembers(writer, static_cast<const Aggregate*>(node));
writer.writeEndElement();
// Recurse to write all compounds.
- generateTagFileCompounds(writer, static_cast<const InnerNode*>(node));
+ generateTagFileCompounds(writer, static_cast<const Aggregate*>(node));
}
}
}
@@ -185,7 +185,7 @@ void QDocTagFiles::generateTagFileCompounds(QXmlStreamWriter& writer, const Inne
Writes all the members of the \a inner node with the \a writer.
The node represents a C++ class, namespace, etc.
*/
-void QDocTagFiles::generateTagFileMembers(QXmlStreamWriter& writer, const InnerNode* inner)
+void QDocTagFiles::generateTagFileMembers(QXmlStreamWriter& writer, const Aggregate* inner)
{
foreach (const Node* node, inner->childNodes()) {
if (!node->url().isEmpty())
@@ -268,7 +268,7 @@ void QDocTagFiles::generateTagFileMembers(QXmlStreamWriter& writer, const InnerN
case FunctionNode::NonVirtual:
writer.writeAttribute("virtualness", "non");
break;
- case FunctionNode::ImpureVirtual:
+ case FunctionNode::NormalVirtual:
writer.writeAttribute("virtualness", "virtual");
break;
case FunctionNode::PureVirtual:
diff --git a/src/tools/qdoc/qdoctagfiles.h b/src/tools/qdoc/qdoctagfiles.h
index 94d3450478..ad1d383bfd 100644
--- a/src/tools/qdoc/qdoctagfiles.h
+++ b/src/tools/qdoc/qdoctagfiles.h
@@ -38,7 +38,7 @@
QT_BEGIN_NAMESPACE
-class InnerNode;
+class Aggregate;
class QDocDatabase;
class Generator;
@@ -53,8 +53,8 @@ class QDocTagFiles
QDocTagFiles();
~QDocTagFiles();
- void generateTagFileCompounds(QXmlStreamWriter& writer, const InnerNode* inner);
- void generateTagFileMembers(QXmlStreamWriter& writer, const InnerNode* inner);
+ void generateTagFileCompounds(QXmlStreamWriter& writer, const Aggregate* inner);
+ void generateTagFileMembers(QXmlStreamWriter& writer, const Aggregate* inner);
void generateTagFile(const QString& fileName, Generator* g);
private:
diff --git a/src/tools/qdoc/qmlcodemarker.cpp b/src/tools/qdoc/qmlcodemarker.cpp
index 86fc79be66..cfb5e16b44 100644
--- a/src/tools/qdoc/qmlcodemarker.cpp
+++ b/src/tools/qdoc/qmlcodemarker.cpp
@@ -96,7 +96,7 @@ bool QmlCodeMarker::recognizeLanguage(const QString &language)
/*!
Returns the type of atom used to represent QML code in the documentation.
*/
-Atom::Type QmlCodeMarker::atomType() const
+Atom::AtomType QmlCodeMarker::atomType() const
{
return Atom::Qml;
}
@@ -166,7 +166,7 @@ QString QmlCodeMarker::addMarkUp(const QString &code,
QQmlJS::Lexer lexer(&engine);
QString newCode = code;
- QList<QQmlJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
+ QVector<QQmlJS::AST::SourceLocation> pragmas = extractPragmas(newCode);
lexer.setCode(newCode, 1);
QQmlJS::Parser parser(&engine);
@@ -209,11 +209,11 @@ static void replaceWithSpace(QString &str, int idx, int n)
Searches for ".pragma <value>" or ".import <stuff>" declarations
in \a script. Currently supported pragmas are: library
*/
-QList<QQmlJS::AST::SourceLocation> QmlCodeMarker::extractPragmas(QString &script)
+QVector<QQmlJS::AST::SourceLocation> QmlCodeMarker::extractPragmas(QString &script)
{
const QString pragma(QLatin1String("pragma"));
const QString library(QLatin1String("library"));
- QList<QQmlJS::AST::SourceLocation> removed;
+ QVector<QQmlJS::AST::SourceLocation> removed;
QQmlJS::Lexer l(0);
l.setCode(script, 0);
diff --git a/src/tools/qdoc/qmlcodemarker.h b/src/tools/qdoc/qmlcodemarker.h
index 805229e366..b3ec03965f 100644
--- a/src/tools/qdoc/qmlcodemarker.h
+++ b/src/tools/qdoc/qmlcodemarker.h
@@ -54,7 +54,7 @@ public:
virtual bool recognizeCode(const QString &code) Q_DECL_OVERRIDE;
virtual bool recognizeExtension(const QString &ext) Q_DECL_OVERRIDE;
virtual bool recognizeLanguage(const QString &language) Q_DECL_OVERRIDE;
- virtual Atom::Type atomType() const Q_DECL_OVERRIDE;
+ virtual Atom::AtomType atomType() const Q_DECL_OVERRIDE;
virtual QString markedUpCode(const QString &code,
const Node *relative,
const Location &location) Q_DECL_OVERRIDE;
@@ -66,7 +66,7 @@ public:
virtual QString functionEndRegExp(const QString &funcName) Q_DECL_OVERRIDE;
/* Copied from src/declarative/qml/qdeclarativescriptparser.cpp */
- QList<QQmlJS::AST::SourceLocation> extractPragmas(QString &script);
+ QVector<QQmlJS::AST::SourceLocation> extractPragmas(QString &script);
private:
QString addMarkUp(const QString &code, const Node *relative,
diff --git a/src/tools/qdoc/qmlcodeparser.cpp b/src/tools/qdoc/qmlcodeparser.cpp
index 4f5720a94d..f485255b8e 100644
--- a/src/tools/qdoc/qmlcodeparser.cpp
+++ b/src/tools/qdoc/qmlcodeparser.cpp
@@ -57,6 +57,7 @@ QT_BEGIN_NAMESPACE
#define COMMAND_SINCE Doc::alias("since")
#define COMMAND_WRAPPER Doc::alias("wrapper")
+#define COMMAND_ABSTRACT Doc::alias("abstract")
#define COMMAND_QMLABSTRACT Doc::alias("qmlabstract")
#define COMMAND_QMLCLASS Doc::alias("qmlclass")
#define COMMAND_QMLTYPE Doc::alias("qmltype")
@@ -251,6 +252,7 @@ const QSet<QString>& QmlCodeParser::otherMetaCommands()
<< COMMAND_OBSOLETE
<< COMMAND_PRELIMINARY
<< COMMAND_SINCE
+ << COMMAND_ABSTRACT
<< COMMAND_QMLABSTRACT
<< COMMAND_INQMLMODULE
<< COMMAND_INJSMODULE
diff --git a/src/tools/qdoc/qmlmarkupvisitor.cpp b/src/tools/qdoc/qmlmarkupvisitor.cpp
index ee86b6de32..3a7635778e 100644
--- a/src/tools/qdoc/qmlmarkupvisitor.cpp
+++ b/src/tools/qdoc/qmlmarkupvisitor.cpp
@@ -42,7 +42,7 @@
QT_BEGIN_NAMESPACE
QmlMarkupVisitor::QmlMarkupVisitor(const QString &source,
- const QList<QQmlJS::AST::SourceLocation> &pragmas,
+ const QVector<QQmlJS::AST::SourceLocation> &pragmas,
QQmlJS::Engine *engine)
{
this->source = source;
@@ -54,21 +54,22 @@ QmlMarkupVisitor::QmlMarkupVisitor(const QString &source,
// Merge the lists of locations of pragmas and comments in the source code.
int i = 0;
int j = 0;
- while (i < engine->comments().length() && j < pragmas.length()) {
- if (engine->comments()[i].offset < pragmas[j].offset) {
+ const QVector<QQmlJS::AST::SourceLocation> comments = engine->comments();
+ while (i < comments.size() && j < pragmas.length()) {
+ if (comments[i].offset < pragmas[j].offset) {
extraTypes.append(Comment);
- extraLocations.append(engine->comments()[i]);
+ extraLocations.append(comments[i]);
++i;
} else {
extraTypes.append(Pragma);
- extraLocations.append(engine->comments()[j]);
+ extraLocations.append(comments[j]);
++j;
}
}
- while (i < engine->comments().length()) {
+ while (i < comments.size()) {
extraTypes.append(Comment);
- extraLocations.append(engine->comments()[i]);
+ extraLocations.append(comments[i]);
++i;
}
diff --git a/src/tools/qdoc/qmlmarkupvisitor.h b/src/tools/qdoc/qmlmarkupvisitor.h
index 04d6a57564..34d18d6868 100644
--- a/src/tools/qdoc/qmlmarkupvisitor.h
+++ b/src/tools/qdoc/qmlmarkupvisitor.h
@@ -50,7 +50,7 @@ public:
};
QmlMarkupVisitor(const QString &code,
- const QList<QQmlJS::AST::SourceLocation> &pragmas,
+ const QVector<QQmlJS::AST::SourceLocation> &pragmas,
QQmlJS::Engine *engine);
virtual ~QmlMarkupVisitor();
@@ -158,7 +158,7 @@ private:
QQmlJS::Engine *engine;
QList<ExtraType> extraTypes;
- QList<QQmlJS::AST::SourceLocation> extraLocations;
+ QVector<QQmlJS::AST::SourceLocation> extraLocations;
QString source;
QString output;
quint32 cursor;
diff --git a/src/tools/qdoc/qmlparser/qqmljsastfwd_p.h b/src/tools/qdoc/qmlparser/qqmljsastfwd_p.h
index eae4125ab2..bfaa4401d2 100644
--- a/src/tools/qdoc/qmlparser/qqmljsastfwd_p.h
+++ b/src/tools/qdoc/qmlparser/qqmljsastfwd_p.h
@@ -37,6 +37,7 @@
#include "qqmljsglobal_p.h"
#include <QtCore/qglobal.h>
+#include <QtCore/qtypeinfo.h>
//
// W A R N I N G
@@ -53,27 +54,6 @@ QT_QML_BEGIN_NAMESPACE
namespace QQmlJS { namespace AST {
-class SourceLocation
-{
-public:
- explicit SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
- : offset(offset), length(length),
- startLine(line), startColumn(column)
- { }
-
- bool isValid() const { return length != 0; }
-
- quint32 begin() const { return offset; }
- quint32 end() const { return offset + length; }
-
-// attributes
- // ### encode
- quint32 offset;
- quint32 length;
- quint32 startLine;
- quint32 startColumn;
-};
-
class Visitor;
class Node;
class ExpressionNode;
@@ -176,8 +156,31 @@ class UiQualifiedId;
class UiQualifiedPragmaId;
class UiHeaderItemList;
+class SourceLocation
+{
+public:
+ explicit SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
+ : offset(offset), length(length),
+ startLine(line), startColumn(column)
+ { }
+
+ bool isValid() const { return length != 0; }
+
+ quint32 begin() const { return offset; }
+ quint32 end() const { return offset + length; }
+
+// attributes
+ // ### encode
+ quint32 offset;
+ quint32 length;
+ quint32 startLine;
+ quint32 startColumn;
+};
+
} } // namespace AST
+Q_DECLARE_TYPEINFO(QQmlJS::AST::SourceLocation, Q_PRIMITIVE_TYPE);
+
QT_QML_END_NAMESPACE
#endif
diff --git a/src/tools/qdoc/qmlparser/qqmljsengine_p.cpp b/src/tools/qdoc/qmlparser/qqmljsengine_p.cpp
index 1c0a70a372..2a949b630c 100644
--- a/src/tools/qdoc/qmlparser/qqmljsengine_p.cpp
+++ b/src/tools/qdoc/qmlparser/qqmljsengine_p.cpp
@@ -35,7 +35,6 @@
#include "qqmljsglobal_p.h"
#include <QtCore/qnumeric.h>
-#include <QtCore/qhash.h>
#include <QtCore/qdebug.h>
QT_QML_BEGIN_NAMESPACE
@@ -126,7 +125,7 @@ void Engine::setCode(const QString &code)
void Engine::addComment(int pos, int len, int line, int col)
{ if (len > 0) _comments.append(QQmlJS::AST::SourceLocation(pos, len, line, col)); }
-QList<QQmlJS::AST::SourceLocation> Engine::comments() const
+QVector<QQmlJS::AST::SourceLocation> Engine::comments() const
{ return _comments; }
Lexer *Engine::lexer() const
diff --git a/src/tools/qdoc/qmlparser/qqmljsengine_p.h b/src/tools/qdoc/qmlparser/qqmljsengine_p.h
index fb65d7f028..9ab26f0d0f 100644
--- a/src/tools/qdoc/qmlparser/qqmljsengine_p.h
+++ b/src/tools/qdoc/qmlparser/qqmljsengine_p.h
@@ -50,7 +50,7 @@
#include "qqmljsmemorypool_p.h"
#include <QtCore/qstring.h>
-#include <QtCore/qset.h>
+#include <QtCore/qvector.h>
QT_QML_BEGIN_NAMESPACE
@@ -87,7 +87,7 @@ class QML_PARSER_EXPORT Engine
Lexer *_lexer;
Directives *_directives;
MemoryPool _pool;
- QList<AST::SourceLocation> _comments;
+ QVector<AST::SourceLocation> _comments;
QString _extraCode;
QString _code;
@@ -99,7 +99,7 @@ public:
const QString &code() const { return _code; }
void addComment(int pos, int len, int line, int col);
- QList<AST::SourceLocation> comments() const;
+ QVector<AST::SourceLocation> comments() const;
Lexer *lexer() const;
void setLexer(Lexer *lexer);
diff --git a/src/tools/qdoc/qmlvisitor.cpp b/src/tools/qdoc/qmlvisitor.cpp
index 190c9f0444..1468683052 100644
--- a/src/tools/qdoc/qmlvisitor.cpp
+++ b/src/tools/qdoc/qmlvisitor.cpp
@@ -55,6 +55,7 @@ QT_BEGIN_NAMESPACE
#define COMMAND_SINCE Doc::alias(QLatin1String("since"))
#define COMMAND_WRAPPER Doc::alias(QLatin1String("wrapper"))
+#define COMMAND_ABSTRACT Doc::alias(QLatin1String("abstract"))
#define COMMAND_QMLABSTRACT Doc::alias(QLatin1String("qmlabstract"))
#define COMMAND_QMLCLASS Doc::alias(QLatin1String("qmlclass"))
#define COMMAND_QMLTYPE Doc::alias(QLatin1String("qmltype"))
@@ -118,7 +119,7 @@ QmlDocVisitor::~QmlDocVisitor()
*/
QQmlJS::AST::SourceLocation QmlDocVisitor::precedingComment(quint32 offset) const
{
- QListIterator<QQmlJS::AST::SourceLocation> it(engine->comments());
+ QVectorIterator<QQmlJS::AST::SourceLocation> it(engine->comments());
it.toBack();
while (it.hasPrevious()) {
@@ -196,7 +197,7 @@ bool QmlDocVisitor::applyDocumentation(QQmlJS::AST::SourceLocation location, Nod
const TopicList& topicsUsed = doc.topicsUsed();
NodeList nodes;
Node* nodePassedIn = node;
- InnerNode* parent = nodePassedIn->parent();
+ Aggregate* parent = nodePassedIn->parent();
node->setDoc(doc);
nodes.append(node);
if (topicsUsed.size() > 0) {
@@ -497,7 +498,7 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::AST::SourceLocation,
while (i != metacommands.end()) {
QString command = *i;
ArgList args = doc.metaCommandArgs(command);
- if (command == COMMAND_QMLABSTRACT) {
+ if ((command == COMMAND_QMLABSTRACT) || (command == COMMAND_ABSTRACT)) {
if (node->isQmlType() || node->isJsType()) {
node->setAbstract(true);
}
@@ -751,14 +752,14 @@ bool QmlDocVisitor::visit(QQmlJS::AST::FunctionDeclaration* fd)
if (current->isJsType())
qmlMethod->setGenus(Node::JS);
int overloads = 0;
- NodeList::ConstIterator overloadIterator = current->childNodes().constBegin();
- while (overloadIterator != current->childNodes().constEnd()) {
- if ((*overloadIterator)->name() == name)
+ NodeList::ConstIterator i = current->childNodes().constBegin();
+ while (i != current->childNodes().constEnd()) {
+ if ((*i)->name() == name)
overloads++;
- overloadIterator++;
+ i++;
}
if (overloads > 1)
- qmlMethod->setOverload(true);
+ qmlMethod->setOverloadFlag(true);
QList<Parameter> parameters;
QQmlJS::AST::FormalParameterList* formals = fd->formals;
if (formals) {
diff --git a/src/tools/qdoc/qmlvisitor.h b/src/tools/qdoc/qmlvisitor.h
index cfb167c985..8c5e8c5042 100644
--- a/src/tools/qdoc/qmlvisitor.h
+++ b/src/tools/qdoc/qmlvisitor.h
@@ -111,7 +111,7 @@ private:
QSet<QString> commands_;
QSet<QString> topics_;
QSet<quint32> usedComments;
- InnerNode *current;
+ Aggregate *current;
};
QT_END_NAMESPACE
diff --git a/src/tools/qdoc/text.cpp b/src/tools/qdoc/text.cpp
index b4eebe4c75..fa105a8344 100644
--- a/src/tools/qdoc/text.cpp
+++ b/src/tools/qdoc/text.cpp
@@ -72,7 +72,7 @@ Text& Text::operator=(const Text& text)
return *this;
}
-Text& Text::operator<<(Atom::Type atomType)
+Text& Text::operator<<(Atom::AtomType atomType)
{
return operator<<(Atom(atomType));
}
@@ -177,7 +177,7 @@ QString Text::toString() const
return str;
}
-Text Text::subText(Atom::Type left, Atom::Type right, const Atom* from, bool inclusive) const
+Text Text::subText(Atom::AtomType left, Atom::AtomType right, const Atom* from, bool inclusive) const
{
const Atom* begin = from ? from : firstAtom();
const Atom* end;
diff --git a/src/tools/qdoc/text.h b/src/tools/qdoc/text.h
index 7f4eeb3ec2..40ecf3eddc 100644
--- a/src/tools/qdoc/text.h
+++ b/src/tools/qdoc/text.h
@@ -54,7 +54,7 @@ public:
Atom *firstAtom() { return first; }
Atom *lastAtom() { return last; }
- Text& operator<<(Atom::Type atomType);
+ Text& operator<<(Atom::AtomType atomType);
Text& operator<<(const QString& string);
Text& operator<<(const Atom& atom);
Text& operator<<(const LinkAtom& atom);
@@ -66,7 +66,7 @@ public:
QString toString() const;
const Atom *firstAtom() const { return first; }
const Atom *lastAtom() const { return last; }
- Text subText(Atom::Type left, Atom::Type right, const Atom *from = 0, bool inclusive = false) const;
+ Text subText(Atom::AtomType left, Atom::AtomType right, const Atom *from = 0, bool inclusive = false) const;
void dump() const;
void clear();
diff --git a/src/tools/qdoc/tree.cpp b/src/tools/qdoc/tree.cpp
index 1b0aba1a0c..6c21d730c1 100644
--- a/src/tools/qdoc/tree.cpp
+++ b/src/tools/qdoc/tree.cpp
@@ -181,9 +181,9 @@ FunctionNode* Tree::findFunctionNode(const QStringList& parentPath, const Functi
parent = findClassNode(parentPath, 0);
if (parent == 0)
parent = findNode(parentPath, 0, 0, Node::DontCare);
- if (parent == 0 || !parent->isInnerNode())
+ if (parent == 0 || !parent->isAggregate())
return 0;
- return ((const InnerNode*)parent)->findFunctionNode(clone);
+ return ((const Aggregate*)parent)->findFunctionNode(clone);
}
@@ -249,22 +249,22 @@ const FunctionNode* Tree::findFunctionNode(const QStringList& path,
int i;
for (i = 0; i < path.size(); ++i) {
- if (node == 0 || !node->isInnerNode())
+ if (node == 0 || !node->isAggregate())
break;
const Node* next;
if (i == path.size() - 1)
- next = ((const InnerNode*) node)->findFunctionNode(path.at(i));
+ next = ((const Aggregate*) node)->findFunctionNode(path.at(i));
else
- next = ((const InnerNode*) node)->findChildNode(path.at(i), genus);
+ next = ((const Aggregate*) node)->findChildNode(path.at(i), genus);
if (!next && node->isClass() && (findFlags & SearchBaseClasses)) {
NodeList baseClasses = allBaseClasses(static_cast<const ClassNode*>(node));
foreach (const Node* baseClass, baseClasses) {
if (i == path.size() - 1)
- next = static_cast<const InnerNode*>(baseClass)->findFunctionNode(path.at(i));
+ next = static_cast<const Aggregate*>(baseClass)->findFunctionNode(path.at(i));
else
- next = static_cast<const InnerNode*>(baseClass)->findChildNode(path.at(i), genus);
+ next = static_cast<const Aggregate*>(baseClass)->findChildNode(path.at(i), genus);
if (next)
break;
@@ -301,8 +301,8 @@ static const NodeTypeList& relatesTypes()
{
if (t.isEmpty()) {
t.reserve(3);
- t.append(NodeTypePair(Node::Class, Node::NoSubType));
- t.append(NodeTypePair(Node::Namespace, Node::NoSubType));
+ t.append(NodeTypePair(Node::Class, Node::NoSubtype));
+ t.append(NodeTypePair(Node::Namespace, Node::NoSubtype));
t.append(NodeTypePair(Node::Document, Node::HeaderFile));
}
return t;
@@ -320,13 +320,15 @@ static const NodeTypeList& relatesTypes()
If a matching node is found, a pointer to it is returned.
Otherwise 0 is returned.
*/
-InnerNode* Tree::findRelatesNode(const QStringList& path)
+Aggregate* Tree::findRelatesNode(const QStringList& path)
{
Node* n = findNodeRecursive(path, 0, root(), relatesTypes());
- return ((n && n->isInnerNode()) ? static_cast<InnerNode*>(n) : 0);
+ return ((n && n->isAggregate()) ? static_cast<Aggregate*>(n) : 0);
}
/*!
+ Inserts function name \a funcName and function role \a funcRole into
+ the property function map for the specified \a property.
*/
void Tree::addPropertyFunction(PropertyNode* property,
const QString& funcName,
@@ -344,7 +346,7 @@ void Tree::addPropertyFunction(PropertyNode* property,
This function does not resolve QML inheritance.
*/
-void Tree::resolveInheritance(InnerNode* n)
+void Tree::resolveInheritance(Aggregate* n)
{
if (!n)
n = root();
@@ -399,7 +401,7 @@ void Tree::resolveInheritanceHelper(int pass, ClassNode* cn)
node) using the unqualified base class name.
*/
if (!n) {
- InnerNode* parent = cn->parent();
+ Aggregate* parent = cn->parent();
if (parent)
// Exclude the root namespace
if (parent->isNamespace() && !parent->name().isEmpty())
@@ -422,7 +424,7 @@ void Tree::resolveInheritanceHelper(int pass, ClassNode* cn)
FunctionNode* from = findVirtualFunctionInBaseClasses(cn, func);
if (from != 0) {
if (func->virtualness() == FunctionNode::NonVirtual)
- func->setVirtualness(FunctionNode::ImpureVirtual);
+ func->setVirtualness(FunctionNode::NormalVirtual);
func->setReimplementedFrom(from);
}
}
@@ -442,7 +444,7 @@ void Tree::resolveProperties()
propEntry = unresolvedPropertyMap.constBegin();
while (propEntry != unresolvedPropertyMap.constEnd()) {
PropertyNode* property = propEntry.key();
- InnerNode* parent = property->parent();
+ Aggregate* parent = property->parent();
QString getterName = (*propEntry)[PropertyNode::Getter];
QString setterName = (*propEntry)[PropertyNode::Setter];
QString resetterName = (*propEntry)[PropertyNode::Resetter];
@@ -587,7 +589,7 @@ NodeList Tree::allBaseClasses(const ClassNode* classNode) const
search at the tree root. \a subtype is not used unless
\a type is \c{Document}.
*/
-Node* Tree::findNodeByNameAndType(const QStringList& path, Node::Type type) const
+Node* Tree::findNodeByNameAndType(const QStringList& path, Node::NodeType type) const
{
return findNodeRecursive(path, 0, root(), type);
}
@@ -611,7 +613,7 @@ Node* Tree::findNodeByNameAndType(const QStringList& path, Node::Type type) cons
Node* Tree::findNodeRecursive(const QStringList& path,
int pathIndex,
const Node* start,
- Node::Type type) const
+ Node::NodeType type) const
{
if (!start || path.isEmpty())
return 0; // no place to start, or nothing to search for.
@@ -622,7 +624,7 @@ Node* Tree::findNodeRecursive(const QStringList& path,
return 0; // premature leaf
}
- InnerNode* current = static_cast<InnerNode*>(node);
+ Aggregate* current = static_cast<Aggregate*>(node);
const NodeList& children = current->childNodes();
const QString& name = path.at(pathIndex);
for (int i=0; i<children.size(); ++i) {
@@ -678,7 +680,7 @@ Node* Tree::findNodeRecursive(const QStringList& path,
if (pathIndex >= path.size())
return 0;
- InnerNode* current = static_cast<InnerNode*>(start);
+ Aggregate* current = static_cast<Aggregate*>(start);
const NodeList& children = current->childNodes();
for (int i=0; i<children.size(); ++i) {
Node* n = children.at(i);
@@ -778,7 +780,7 @@ const Node* Tree::findNodeForTarget(const QStringList& path,
}
while (current) {
- if (current->isInnerNode()) {
+ if (current->isAggregate()) {
const Node* node = matchPathAndTarget(path, path_idx, target, current, flags, genus, ref);
if (node)
return node;
@@ -848,8 +850,8 @@ const Node* Tree::matchPathAndTarget(const QStringList& path,
return t;
}
if (target.isEmpty()) {
- if ((idx) == (path.size()-1) && node->isInnerNode() && (flags & SearchEnumValues)) {
- t = static_cast<const InnerNode*>(node)->findEnumNodeForValue(path.at(idx));
+ if ((idx) == (path.size()-1) && node->isAggregate() && (flags & SearchEnumValues)) {
+ t = static_cast<const Aggregate*>(node)->findEnumNodeForValue(path.at(idx));
if (t)
return t;
}
@@ -863,7 +865,7 @@ const Node* Tree::matchPathAndTarget(const QStringList& path,
return t;
if (target.isEmpty()) {
if ((idx) == (path.size()-1) && (flags & SearchEnumValues)) {
- t = static_cast<const InnerNode*>(bc)->findEnumNodeForValue(path.at(idx));
+ t = static_cast<const Aggregate*>(bc)->findEnumNodeForValue(path.at(idx));
if (t)
return t;
}
@@ -915,20 +917,20 @@ const Node* Tree::findNode(const QStringList& path,
}
for (i = start_idx; i < path.size(); ++i) {
- if (node == 0 || !node->isInnerNode())
+ if (node == 0 || !node->isAggregate())
break;
- const Node* next = static_cast<const InnerNode*>(node)->findChildNode(path.at(i), genus);
+ const Node* next = static_cast<const Aggregate*>(node)->findChildNode(path.at(i), genus);
if (!next && (findFlags & SearchEnumValues) && i == path.size()-1) {
- next = static_cast<const InnerNode*>(node)->findEnumNodeForValue(path.at(i));
+ next = static_cast<const Aggregate*>(node)->findEnumNodeForValue(path.at(i));
}
if (!next && ((genus == Node::CPP) || (genus == Node::DontCare)) &&
node->isClass() && (findFlags & SearchBaseClasses)) {
NodeList baseClasses = allBaseClasses(static_cast<const ClassNode*>(node));
foreach (const Node* baseClass, baseClasses) {
- next = static_cast<const InnerNode*>(baseClass)->findChildNode(path.at(i), genus);
+ next = static_cast<const Aggregate*>(baseClass)->findChildNode(path.at(i), genus);
if (!next && (findFlags & SearchEnumValues) && i == path.size() - 1)
- next = static_cast<const InnerNode*>(baseClass)->findEnumNodeForValue(path.at(i));
+ next = static_cast<const Aggregate*>(baseClass)->findEnumNodeForValue(path.at(i));
if (next) {
break;
}
@@ -980,7 +982,7 @@ QString Tree::getRef(const QString& target, const Node* node) const
*/
void Tree::insertTarget(const QString& name,
const QString& title,
- TargetRec::Type type,
+ TargetRec::TargetType type,
Node* node,
int priority)
{
@@ -991,7 +993,7 @@ void Tree::insertTarget(const QString& name,
/*!
*/
-void Tree::resolveTargets(InnerNode* root)
+void Tree::resolveTargets(Aggregate* root)
{
// need recursion
foreach (Node* child, root->childNodes()) {
@@ -1005,7 +1007,7 @@ void Tree::resolveTargets(InnerNode* root)
bool alreadyThere = false;
if (!nodes.empty()) {
for (int i=0; i< nodes.size(); ++i) {
- if (nodes[i]->subType() == Node::ExternalPage) {
+ if (nodes[i]->docSubtype() == Node::ExternalPage) {
if (node->name() == nodes[i]->name()) {
alreadyThere = true;
break;
@@ -1140,18 +1142,15 @@ const DocumentNode* Tree::findDocumentNodeByTitle(const QString& title) const
DocumentNodeMultiMap::const_iterator j = i;
++j;
if (j != docNodesByTitle_.constEnd() && j.key() == i.key()) {
- QList<Location> internalLocations;
while (j != docNodesByTitle_.constEnd()) {
if (j.key() == i.key() && j.value()->url().isEmpty()) {
- internalLocations.append(j.value()->location());
break; // Just report one duplicate for now.
}
++j;
}
- if (internalLocations.size() > 0) {
+ if (j != docNodesByTitle_.cend()) {
i.value()->location().warning("This page title exists in more than one file: " + title);
- foreach (const Location &location, internalLocations)
- location.warning("[It also exists here]");
+ j.value()->location().warning("[It also exists here]");
}
}
return i.value();
@@ -1252,7 +1251,7 @@ CollectionNode* Tree::findCollection(const QString& name, Node::Genus genus)
CNMap::const_iterator i = m->constFind(name);
if (i != m->cend())
return i.value();
- Node::Type t = Node::NoType;
+ Node::NodeType t = Node::NoType;
switch (genus) {
case Node::DOC:
t = Node::Group;
diff --git a/src/tools/qdoc/tree.h b/src/tools/qdoc/tree.h
index 1e9612aeec..0f41c221b6 100644
--- a/src/tools/qdoc/tree.h
+++ b/src/tools/qdoc/tree.h
@@ -49,11 +49,11 @@ class QDocDatabase;
struct TargetRec
{
public:
- enum Type { Unknown, Target, Keyword, Contents, Class, Function, Page, Subtitle };
+ enum TargetType { Unknown, Target, Keyword, Contents, Class, Function, Page, Subtitle };
TargetRec(const QString& name,
const QString& title,
- TargetRec::Type type,
+ TargetRec::TargetType type,
Node* node,
int priority)
: node_(node), ref_(name), title_(title), priority_(priority), type_(type) { }
@@ -64,7 +64,7 @@ struct TargetRec
QString ref_;
QString title_;
int priority_;
- Type type_;
+ TargetType type_;
};
struct TargetLoc
@@ -107,7 +107,7 @@ class Tree
Node* findNodeRecursive(const QStringList& path,
int pathIndex,
const Node* start,
- Node::Type type) const;
+ Node::NodeType type) const;
Node* findNodeRecursive(const QStringList& path,
int pathIndex,
Node* start,
@@ -134,22 +134,22 @@ class Tree
QmlTypeNode* findQmlTypeNode(const QStringList& path);
- Node* findNodeByNameAndType(const QStringList& path, Node::Type type) const;
- InnerNode* findRelatesNode(const QStringList& path);
+ Node* findNodeByNameAndType(const QStringList& path, Node::NodeType type) const;
+ Aggregate* findRelatesNode(const QStringList& path);
QString getRef(const QString& target, const Node* node) const;
void insertTarget(const QString& name,
const QString& title,
- TargetRec::Type type,
+ TargetRec::TargetType type,
Node* node,
int priority);
- void resolveTargets(InnerNode* root);
+ void resolveTargets(Aggregate* root);
const Node* findUnambiguousTarget(const QString& target, QString& ref) const;
const DocumentNode* findDocumentNodeByTitle(const QString& title) const;
void addPropertyFunction(PropertyNode *property,
const QString &funcName,
PropertyNode::FunctionRole funcRole);
- void resolveInheritance(InnerNode* n = 0);
+ void resolveInheritance(Aggregate* n = 0);
void resolveInheritanceHelper(int pass, ClassNode* cn);
void resolveProperties();
void resolveCppToQmlLinks();
diff --git a/src/tools/uic/cpp/cppwriteincludes.h b/src/tools/uic/cpp/cppwriteincludes.h
index 6e7888c62b..e4f1aedb7e 100644
--- a/src/tools/uic/cpp/cppwriteincludes.h
+++ b/src/tools/uic/cpp/cppwriteincludes.h
@@ -36,7 +36,6 @@
#include "treewalker.h"
-#include <qhash.h>
#include <qmap.h>
#include <qset.h>
#include <qstring.h>
diff --git a/src/tools/uic/uic.h b/src/tools/uic/uic.h
index e88326f0da..b65b662473 100644
--- a/src/tools/uic/uic.h
+++ b/src/tools/uic/uic.h
@@ -38,7 +38,6 @@
#include "customwidgetsinfo.h"
#include <qstring.h>
#include <qstringlist.h>
-#include <qhash.h>
#include <qstack.h>
#include <qxmlstream.h>
diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp
index 4f6cb56060..ca2fd62994 100644
--- a/src/widgets/accessible/itemviews.cpp
+++ b/src/widgets/accessible/itemviews.cpp
@@ -198,7 +198,9 @@ QList<QAccessibleInterface *> QAccessibleTable::selectedCells() const
QList<QAccessibleInterface*> cells;
if (!view()->selectionModel())
return cells;
- Q_FOREACH (const QModelIndex &index, view()->selectionModel()->selectedIndexes())
+ const QModelIndexList selectedIndexes = view()->selectionModel()->selectedIndexes();
+ cells.reserve(selectedIndexes.size());
+ Q_FOREACH (const QModelIndex &index, selectedIndexes)
cells.append(child(logicalIndex(index)));
return cells;
}
@@ -208,9 +210,11 @@ QList<int> QAccessibleTable::selectedColumns() const
if (!view()->selectionModel())
return QList<int>();
QList<int> columns;
- Q_FOREACH (const QModelIndex &index, view()->selectionModel()->selectedColumns()) {
+ const QModelIndexList selectedColumns = view()->selectionModel()->selectedColumns();
+ columns.reserve(selectedColumns.size());
+ Q_FOREACH (const QModelIndex &index, selectedColumns)
columns.append(index.column());
- }
+
return columns;
}
@@ -219,9 +223,11 @@ QList<int> QAccessibleTable::selectedRows() const
if (!view()->selectionModel())
return QList<int>();
QList<int> rows;
- Q_FOREACH (const QModelIndex &index, view()->selectionModel()->selectedRows()) {
+ const QModelIndexList selectedRows = view()->selectionModel()->selectedRows();
+ rows.reserve(selectedRows.size());
+ Q_FOREACH (const QModelIndex &index, selectedRows)
rows.append(index.row());
- }
+
return rows;
}
@@ -1010,6 +1016,9 @@ QAccessible::Role QAccessibleTableCell::role() const
QAccessible::State QAccessibleTableCell::state() const
{
QAccessible::State st;
+ if (!view)
+ return st;
+
QRect globalRect = view->rect();
globalRect.translate(view->mapToGlobal(QPoint(0,0)));
if (!globalRect.intersects(rect()))
diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp
index a2bf14b25b..c598a5b4cb 100644
--- a/src/widgets/accessible/qaccessiblewidgets.cpp
+++ b/src/widgets/accessible/qaccessiblewidgets.cpp
@@ -826,6 +826,9 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end
attrs["text-underline-type"] = QStringLiteral("single"); // if underlineStyleValue is set, there is an underline, and Qt does not support other than single ones
} // else both are "none" which is the default - no need to set them
+ if (block.textDirection() == Qt::RightToLeft)
+ attrs["writing-mode"] = QStringLiteral("rl");
+
QTextCharFormat::VerticalAlignment alignment = charFormat.verticalAlignment();
attrs["text-position"] = QString::fromLatin1((alignment == QTextCharFormat::AlignSubScript) ? "sub" : ((alignment == QTextCharFormat::AlignSuperScript) ? "super" : "baseline" ));
diff --git a/src/widgets/dialogs/dialogs.pri b/src/widgets/dialogs/dialogs.pri
index a5b4883db8..4f4a9b1517 100644
--- a/src/widgets/dialogs/dialogs.pri
+++ b/src/widgets/dialogs/dialogs.pri
@@ -2,7 +2,6 @@
HEADERS += \
dialogs/qcolordialog.h \
- dialogs/qcolordialog_p.h \
dialogs/qfscompleter_p.h \
dialogs/qdialog.h \
dialogs/qdialog_p.h \
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 5f3161f39f..914ee8ec9c 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -31,7 +31,7 @@
**
****************************************************************************/
-#include "qcolordialog_p.h"
+#include "qcolordialog.h"
#ifndef QT_NO_COLORDIALOG
@@ -49,6 +49,7 @@
#include "qpixmap.h"
#include "qpushbutton.h"
#include "qsettings.h"
+#include "qsharedpointer.h"
#include "qstyle.h"
#include "qstyleoption.h"
#include "qvalidator.h"
@@ -58,13 +59,132 @@
#include "qscreen.h"
#include "qcursor.h"
#include "qtimer.h"
+#include "qwindow.h"
+
+#include "private/qdialog_p.h"
#include <algorithm>
QT_BEGIN_NAMESPACE
+namespace {
+class QColorLuminancePicker;
+class QColorPicker;
+class QColorShower;
+class QWellArray;
+class QColorPickingEventFilter;
+} // unnamed namespace
+
+class QColorDialogPrivate : public QDialogPrivate
+{
+ Q_DECLARE_PUBLIC(QColorDialog)
+
+public:
+ enum SetColorMode {
+ ShowColor = 0x1,
+ SelectColor = 0x2,
+ SetColorAll = ShowColor | SelectColor
+ };
+
+ QColorDialogPrivate() : options(new QColorDialogOptions)
+#ifdef Q_OS_WIN32
+ , updateTimer(0)
+#endif
+ {}
+
+ QPlatformColorDialogHelper *platformColorDialogHelper() const
+ { return static_cast<QPlatformColorDialogHelper *>(platformHelper()); }
+
+ void init(const QColor &initial);
+ void initWidgets();
+ QRgb currentColor() const;
+ QColor currentQColor() const;
+ void setCurrentColor(const QColor &color, SetColorMode setColorMode = SetColorAll);
+ void setCurrentRgbColor(QRgb rgb);
+ void setCurrentQColor(const QColor &color);
+ bool selectColor(const QColor &color);
+ QColor grabScreenColor(const QPoint &p);
+
+ int currentAlpha() const;
+ void setCurrentAlpha(int a);
+ void showAlpha(bool b);
+ bool isAlphaVisible() const;
+ void retranslateStrings();
+
+ void _q_addCustom();
+
+ void _q_newHsv(int h, int s, int v);
+ void _q_newColorTypedIn(QRgb rgb);
+ void _q_nextCustom(int, int);
+ void _q_newCustom(int, int);
+ void _q_newStandard(int, int);
+ void _q_pickScreenColor();
+ void _q_updateColorPicking();
+ void updateColorLabelText(const QPoint &);
+ void updateColorPicking(const QPoint &pos);
+ void releaseColorPicking();
+ bool handleColorPickingMouseMove(QMouseEvent *e);
+ bool handleColorPickingMouseButtonRelease(QMouseEvent *e);
+ bool handleColorPickingKeyPress(QKeyEvent *e);
+
+ bool canBeNativeDialog() const Q_DECL_OVERRIDE;
+
+ QWellArray *custom;
+ QWellArray *standard;
+
+ QDialogButtonBox *buttons;
+ QVBoxLayout *leftLay;
+ QColorPicker *cp;
+ QColorLuminancePicker *lp;
+ QColorShower *cs;
+ QLabel *lblBasicColors;
+ QLabel *lblCustomColors;
+ QLabel *lblScreenColorInfo;
+ QPushButton *ok;
+ QPushButton *cancel;
+ QPushButton *addCusBt;
+ QPushButton *screenColorPickerButton;
+ QColor selectedQColor;
+ int nextCust;
+ bool smallDisplay;
+ bool screenColorPicking;
+ QColorPickingEventFilter *colorPickingEventFilter;
+ QRgb beforeScreenColorPicking;
+ QSharedPointer<QColorDialogOptions> options;
+
+ QPointer<QObject> receiverToDisconnectOnClose;
+ QByteArray memberToDisconnectOnClose;
+#ifdef Q_OS_WIN32
+ QTimer *updateTimer;
+ QWindow dummyTransparentWindow;
+#endif
+
+#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+ void openCocoaColorPanel(const QColor &initial,
+ QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options);
+ void closeCocoaColorPanel();
+ void releaseCocoaColorPanelDelegate();
+ void setCocoaPanelColor(const QColor &color);
+
+ inline void done(int result) { q_func()->done(result); }
+ inline QColorDialog *colorDialog() { return q_func(); }
+
+ void *delegate;
+
+ static bool sharedColorPanelAvailable;
+
+ void _q_macRunNativeAppModalPanel();
+ void mac_nativeDialogModalHelp();
+#endif
+private:
+ virtual void initHelper(QPlatformDialogHelper *h) Q_DECL_OVERRIDE;
+ virtual void helperPrepareShow(QPlatformDialogHelper *h) Q_DECL_OVERRIDE;
+};
+
//////////// QWellArray BEGIN
+namespace {
+
struct QWellArrayData;
class QWellArray : public QWidget
@@ -446,6 +566,8 @@ private:
QColorDialogPrivate *m_dp;
};
+} // unnamed namespace
+
/*!
Returns the number of custom colors supported by QColorDialog. All
color dialogs share the same custom colors.
@@ -506,6 +628,8 @@ static inline void rgb2hsv(QRgb rgb, int &h, int &s, int &v)
c.getHsv(&h, &s, &v);
}
+namespace {
+
class QColorWell : public QWellArray
{
public:
@@ -975,8 +1099,8 @@ private:
QColorDialog *colorDialog;
QGridLayout *gl;
- friend class QColorDialog;
- friend class QColorDialogPrivate;
+ friend class QT_PREPEND_NAMESPACE(QColorDialog);
+ friend class QT_PREPEND_NAMESPACE(QColorDialogPrivate);
};
class QColorShowLabel : public QFrame
@@ -1265,6 +1389,8 @@ QColorShower::QColorShower(QColorDialog *parent)
retranslateStrings();
}
+} // unnamed namespace
+
inline QRgb QColorDialogPrivate::currentColor() const { return cs->currentColor(); }
inline int QColorDialogPrivate::currentAlpha() const { return cs->currentAlpha(); }
inline void QColorDialogPrivate::setCurrentAlpha(int a) { cs->setCurrentAlpha(a); }
diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h
index 16339f56c4..43c7716ef6 100644
--- a/src/widgets/dialogs/qcolordialog.h
+++ b/src/widgets/dialogs/qcolordialog.h
@@ -113,7 +113,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int))
Q_PRIVATE_SLOT(d_func(), void _q_pickScreenColor())
Q_PRIVATE_SLOT(d_func(), void _q_updateColorPicking())
- friend class QColorShower;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QColorDialog::ColorDialogOptions)
diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h
deleted file mode 100644
index 1a881eae70..0000000000
--- a/src/widgets/dialogs/qcolordialog_p.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** 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 http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://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 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOLORDIALOG_P_H
-#define QCOLORDIALOG_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
-// to version without notice, or even be removed.
-//
-// We mean it.
-//
-//
-
-#include "private/qdialog_p.h"
-#include "qcolordialog.h"
-#include "qsharedpointer.h"
-#include "qwindow.h"
-
-#ifndef QT_NO_COLORDIALOG
-
-QT_BEGIN_NAMESPACE
-
-class QColorLuminancePicker;
-class QColorPicker;
-class QColorShower;
-class QDialogButtonBox;
-class QLabel;
-class QVBoxLayout;
-class QPushButton;
-class QWellArray;
-class QColorPickingEventFilter;
-class QTimer;
-
-class QColorDialogPrivate : public QDialogPrivate
-{
- Q_DECLARE_PUBLIC(QColorDialog)
-
-public:
- enum SetColorMode {
- ShowColor = 0x1,
- SelectColor = 0x2,
- SetColorAll = ShowColor | SelectColor
- };
-
- QColorDialogPrivate() : options(new QColorDialogOptions)
-#ifdef Q_OS_WIN32
- , updateTimer(0)
-#endif
- {}
-
- QPlatformColorDialogHelper *platformColorDialogHelper() const
- { return static_cast<QPlatformColorDialogHelper *>(platformHelper()); }
-
- void init(const QColor &initial);
- void initWidgets();
- QRgb currentColor() const;
- QColor currentQColor() const;
- void setCurrentColor(const QColor &color, SetColorMode setColorMode = SetColorAll);
- void setCurrentRgbColor(QRgb rgb);
- void setCurrentQColor(const QColor &color);
- bool selectColor(const QColor &color);
- QColor grabScreenColor(const QPoint &p);
-
- int currentAlpha() const;
- void setCurrentAlpha(int a);
- void showAlpha(bool b);
- bool isAlphaVisible() const;
- void retranslateStrings();
-
- void _q_addCustom();
-
- void _q_newHsv(int h, int s, int v);
- void _q_newColorTypedIn(QRgb rgb);
- void _q_nextCustom(int, int);
- void _q_newCustom(int, int);
- void _q_newStandard(int, int);
- void _q_pickScreenColor();
- void _q_updateColorPicking();
- void updateColorLabelText(const QPoint &);
- void updateColorPicking(const QPoint &pos);
- void releaseColorPicking();
- bool handleColorPickingMouseMove(QMouseEvent *e);
- bool handleColorPickingMouseButtonRelease(QMouseEvent *e);
- bool handleColorPickingKeyPress(QKeyEvent *e);
-
- bool canBeNativeDialog() const Q_DECL_OVERRIDE;
-
- QWellArray *custom;
- QWellArray *standard;
-
- QDialogButtonBox *buttons;
- QVBoxLayout *leftLay;
- QColorPicker *cp;
- QColorLuminancePicker *lp;
- QColorShower *cs;
- QLabel *lblBasicColors;
- QLabel *lblCustomColors;
- QLabel *lblScreenColorInfo;
- QPushButton *ok;
- QPushButton *cancel;
- QPushButton *addCusBt;
- QPushButton *screenColorPickerButton;
- QColor selectedQColor;
- int nextCust;
- bool smallDisplay;
- bool screenColorPicking;
- QColorPickingEventFilter *colorPickingEventFilter;
- QRgb beforeScreenColorPicking;
- QSharedPointer<QColorDialogOptions> options;
-
- QPointer<QObject> receiverToDisconnectOnClose;
- QByteArray memberToDisconnectOnClose;
-#ifdef Q_OS_WIN32
- QTimer *updateTimer;
- QWindow dummyTransparentWindow;
-#endif
-
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
- void openCocoaColorPanel(const QColor &initial,
- QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options);
- void closeCocoaColorPanel();
- void releaseCocoaColorPanelDelegate();
- void setCocoaPanelColor(const QColor &color);
-
- inline void done(int result) { q_func()->done(result); }
- inline QColorDialog *colorDialog() { return q_func(); }
-
- void *delegate;
-
- static bool sharedColorPanelAvailable;
-
- void _q_macRunNativeAppModalPanel();
- void mac_nativeDialogModalHelp();
-#endif
-private:
- virtual void initHelper(QPlatformDialogHelper *h) Q_DECL_OVERRIDE;
- virtual void helperPrepareShow(QPlatformDialogHelper *h) Q_DECL_OVERRIDE;
-};
-
-#endif // QT_NO_COLORDIALOG
-
-QT_END_NAMESPACE
-
-#endif // QCOLORDIALOG_P_H
diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp
index 4c3a5497d4..855bae3c9f 100644
--- a/src/widgets/dialogs/qerrormessage.cpp
+++ b/src/widgets/dialogs/qerrormessage.cpp
@@ -47,9 +47,10 @@
#include "qpixmap.h"
#include "qmetaobject.h"
#include "qthread.h"
-#include "qqueue.h"
#include "qset.h"
+#include <queue>
+
#include <stdio.h>
#include <stdlib.h>
@@ -68,16 +69,18 @@ public:
QCheckBox * again;
QTextEdit * errors;
QLabel * icon;
- QQueue<QPair<QString, QString> > pending;
+ std::queue<QPair<QString, QString> > pending;
QSet<QString> doNotShow;
QSet<QString> doNotShowType;
QString currentMessage;
QString currentType;
+ bool isMessageToBeShown(const QString &message, const QString &type) const;
bool nextPending();
void retranslateStrings();
};
+namespace {
class QErrorMessageTextView : public QTextEdit
{
public:
@@ -87,6 +90,7 @@ public:
virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE;
virtual QSize sizeHint() const Q_DECL_OVERRIDE;
};
+} // unnamed namespace
QSize QErrorMessageTextView::minimumSizeHint() const
{
@@ -217,29 +221,32 @@ QErrorMessage::QErrorMessage(QWidget * parent)
: QDialog(*new QErrorMessagePrivate, parent)
{
Q_D(QErrorMessage);
- QGridLayout * grid = new QGridLayout(this);
+
d->icon = new QLabel(this);
-#ifndef QT_NO_MESSAGEBOX
- d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information));
- d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
-#endif
- grid->addWidget(d->icon, 0, 0, Qt::AlignTop);
d->errors = new QErrorMessageTextView(this);
- grid->addWidget(d->errors, 0, 1);
d->again = new QCheckBox(this);
- d->again->setChecked(true);
- grid->addWidget(d->again, 1, 1, Qt::AlignTop);
d->ok = new QPushButton(this);
+ QGridLayout * grid = new QGridLayout(this);
+
+ connect(d->ok, SIGNAL(clicked()), this, SLOT(accept()));
+ grid->addWidget(d->icon, 0, 0, Qt::AlignTop);
+ grid->addWidget(d->errors, 0, 1);
+ grid->addWidget(d->again, 1, 1, Qt::AlignTop);
+ grid->addWidget(d->ok, 2, 0, 1, 2, Qt::AlignCenter);
+ grid->setColumnStretch(1, 42);
+ grid->setRowStretch(0, 42);
+#ifndef QT_NO_MESSAGEBOX
+ d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information));
+ d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
+#endif
+ d->again->setChecked(true);
#if defined(Q_OS_WINCE)
d->ok->setFixedSize(0,0);
#endif
- connect(d->ok, SIGNAL(clicked()), this, SLOT(accept()));
d->ok->setFocus();
- grid->addWidget(d->ok, 2, 0, 1, 2, Qt::AlignCenter);
- grid->setColumnStretch(1, 42);
- grid->setRowStretch(0, 42);
+
d->retranslateStrings();
}
@@ -265,11 +272,13 @@ QErrorMessage::~QErrorMessage()
void QErrorMessage::done(int a)
{
Q_D(QErrorMessage);
- if (!d->again->isChecked() && !d->currentMessage.isEmpty() && d->currentType.isEmpty()) {
- d->doNotShow.insert(d->currentMessage);
- }
- if (!d->again->isChecked() && !d->currentType.isEmpty()) {
- d->doNotShowType.insert(d->currentType);
+ if (!d->again->isChecked()) {
+ if (d->currentType.isEmpty()) {
+ if (!d->currentMessage.isEmpty())
+ d->doNotShow.insert(d->currentMessage);
+ } else {
+ d->doNotShowType.insert(d->currentType);
+ }
}
d->currentMessage.clear();
d->currentType.clear();
@@ -301,20 +310,27 @@ QErrorMessage * QErrorMessage::qtHandler()
/*! \internal */
+bool QErrorMessagePrivate::isMessageToBeShown(const QString &message, const QString &type) const
+{
+ return !message.isEmpty()
+ && (type.isEmpty() ? !doNotShow.contains(message) : !doNotShowType.contains(type));
+}
+
bool QErrorMessagePrivate::nextPending()
{
- while (!pending.isEmpty()) {
- QPair<QString,QString> pendingMessage = pending.dequeue();
- QString message = pendingMessage.first;
- QString type = pendingMessage.second;
- if (!message.isEmpty() && ((type.isEmpty() && !doNotShow.contains(message)) || (!type.isEmpty() && !doNotShowType.contains(type)))) {
+ while (!pending.empty()) {
+ QPair<QString,QString> &pendingMessage = pending.front();
+ QString message = qMove(pendingMessage.first);
+ QString type = qMove(pendingMessage.second);
+ pending.pop();
+ if (isMessageToBeShown(message, type)) {
#ifndef QT_NO_TEXTHTMLPARSER
errors->setHtml(message);
#else
errors->setPlainText(message);
#endif
- currentMessage = message;
- currentType = type;
+ currentMessage = qMove(message);
+ currentType = qMove(type);
return true;
}
}
@@ -333,12 +349,7 @@ bool QErrorMessagePrivate::nextPending()
void QErrorMessage::showMessage(const QString &message)
{
- Q_D(QErrorMessage);
- if (d->doNotShow.contains(message))
- return;
- d->pending.enqueue(qMakePair(message,QString()));
- if (!isVisible() && d->nextPending())
- show();
+ showMessage(message, QString());
}
/*!
@@ -358,9 +369,9 @@ void QErrorMessage::showMessage(const QString &message)
void QErrorMessage::showMessage(const QString &message, const QString &type)
{
Q_D(QErrorMessage);
- if (d->doNotShow.contains(message) && d->doNotShowType.contains(type))
+ if (!d->isMessageToBeShown(message, type))
return;
- d->pending.push_back(qMakePair(message,type));
+ d->pending.push(qMakePair(message, type));
if (!isVisible() && d->nextPending())
show();
}
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index d2666026bb..d83f6609b8 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -1189,12 +1189,17 @@ QList<QUrl> QFileDialogPrivate::userSelectedFiles() const
if (!usingWidgets())
return addDefaultSuffixToUrls(selectedFiles_sys());
- foreach (const QModelIndex &index, qFileDialogUi->listView->selectionModel()->selectedRows())
+ const QModelIndexList selectedRows = qFileDialogUi->listView->selectionModel()->selectedRows();
+ files.reserve(selectedRows.size());
+ foreach (const QModelIndex &index, selectedRows)
files.append(QUrl::fromLocalFile(index.data(QFileSystemModel::FilePathRole).toString()));
- if (files.isEmpty() && !lineEdit()->text().isEmpty())
- foreach (const QString &path, typedFiles())
+ if (files.isEmpty() && !lineEdit()->text().isEmpty()) {
+ const QStringList typedFilesList = typedFiles();
+ files.reserve(typedFilesList.size());
+ foreach (const QString &path, typedFilesList)
files.append(QUrl::fromLocalFile(path));
+ }
return files;
}
@@ -1228,7 +1233,9 @@ QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList &files
QList<QUrl> QFileDialogPrivate::addDefaultSuffixToUrls(const QList<QUrl> &urlsToFix) const
{
QList<QUrl> urls;
- for (int i=0; i<urlsToFix.size(); ++i) {
+ const int numUrlsToFix = urlsToFix.size();
+ urls.reserve(numUrlsToFix);
+ for (int i = 0; i < numUrlsToFix; ++i) {
QUrl url = urlsToFix.at(i);
// if the filename has no suffix, add the default suffix
const QString defaultSuffix = options->defaultSuffix();
@@ -1252,7 +1259,9 @@ QStringList QFileDialog::selectedFiles() const
Q_D(const QFileDialog);
QStringList files;
- foreach (const QUrl &file, d->userSelectedFiles())
+ const QList<QUrl> userSelectedFiles = d->userSelectedFiles();
+ files.reserve(userSelectedFiles.size());
+ foreach (const QUrl &file, userSelectedFiles)
files.append(file.toLocalFile());
if (files.isEmpty() && d->usingWidgets()) {
const FileMode fm = fileMode();
@@ -1277,7 +1286,9 @@ QList<QUrl> QFileDialog::selectedUrls() const
return d->userSelectedFiles();
} else {
QList<QUrl> urls;
- foreach (const QString &file, selectedFiles())
+ const QStringList selectedFileList = selectedFiles();
+ urls.reserve(selectedFileList.size());
+ foreach (const QString &file, selectedFileList)
urls.append(QUrl::fromLocalFile(file));
return urls;
}
@@ -1356,7 +1367,9 @@ QStringList qt_strip_filters(const QStringList &filters)
{
QStringList strippedFilters;
QRegExp r(QString::fromLatin1(QPlatformFileDialogHelper::filterRegExp));
- for (int i = 0; i < filters.count(); ++i) {
+ const int numFilters = filters.count();
+ strippedFilters.reserve(numFilters);
+ for (int i = 0; i < numFilters; ++i) {
QString filterName;
int index = r.indexIn(filters[i]);
if (index >= 0)
@@ -1391,7 +1404,9 @@ void QFileDialog::setNameFilters(const QStringList &filters)
Q_D(QFileDialog);
d->defaultFileTypes = (filters == QStringList(QFileDialog::tr("All Files (*)")));
QStringList cleanedFilters;
- for (int i = 0; i < filters.count(); ++i) {
+ const int numFilters = filters.count();
+ cleanedFilters.reserve(numFilters);
+ for (int i = 0; i < numFilters; ++i) {
cleanedFilters << filters[i].simplified();
}
d->options->setNameFilters(cleanedFilters);
@@ -2186,6 +2201,7 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
const QStringList schemes = QStringList(QStringLiteral("file"));
const QList<QUrl> selectedUrls = getOpenFileUrls(parent, caption, QUrl::fromLocalFile(dir), filter, selectedFilter, options, schemes);
QStringList fileNames;
+ fileNames.reserve(selectedUrls.size());
foreach (const QUrl &url, selectedUrls)
fileNames << url.toLocalFile();
return fileNames;
@@ -2662,7 +2678,9 @@ void QFileDialogPrivate::saveSettings()
settings.setValue(QLatin1String("treeViewHeader"), qFileDialogUi->treeView->header()->saveState());
}
QStringList historyUrls;
- foreach (const QString &path, q->history())
+ const QStringList history = q->history();
+ historyUrls.reserve(history.size());
+ foreach (const QString &path, history)
historyUrls << QUrl::fromLocalFile(path).toString();
settings.setValue(QLatin1String("history"), historyUrls);
settings.setValue(QLatin1String("lastVisited"), lastVisitedDir()->toString());
@@ -3774,7 +3792,7 @@ QString QFileDialogPrivate::getEnvironmentVariable(const QString &string)
{
#ifdef Q_OS_UNIX
if (string.size() > 1 && string.startsWith(QLatin1Char('$'))) {
- return QString::fromLocal8Bit(getenv(string.mid(1).toLatin1().constData()));
+ return QString::fromLocal8Bit(qgetenv(string.mid(1).toLatin1().constData()));
}
#else
if (string.size() > 2 && string.startsWith(QLatin1Char('%')) && string.endsWith(QLatin1Char('%'))) {
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 4859231d95..3d767971a4 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -1183,8 +1183,11 @@ void QFileSystemModel::sort(int column, Qt::SortOrder order)
emit layoutAboutToBeChanged();
QModelIndexList oldList = persistentIndexList();
QList<QPair<QFileSystemModelPrivate::QFileSystemNode*, int> > oldNodes;
- for (int i = 0; i < oldList.count(); ++i) {
- QPair<QFileSystemModelPrivate::QFileSystemNode*, int> pair(d->node(oldList.at(i)), oldList.at(i).column());
+ const int nodeCount = oldList.count();
+ oldNodes.reserve(nodeCount);
+ for (int i = 0; i < nodeCount; ++i) {
+ const QModelIndex &oldNode = oldList.at(i);
+ QPair<QFileSystemModelPrivate::QFileSystemNode*, int> pair(d->node(oldNode), oldNode.column());
oldNodes.append(pair);
}
@@ -1197,9 +1200,10 @@ void QFileSystemModel::sort(int column, Qt::SortOrder order)
d->sortOrder = order;
QModelIndexList newList;
- for (int i = 0; i < oldNodes.count(); ++i) {
- QModelIndex idx = d->index(oldNodes.at(i).first);
- idx = idx.sibling(idx.row(), oldNodes.at(i).second);
+ for (int i = 0; i < nodeCount; ++i) {
+ const QPair<QFileSystemModelPrivate::QFileSystemNode*, int> &oldNode = oldNodes.at(i);
+ QModelIndex idx = d->index(oldNode.first);
+ idx = idx.sibling(idx.row(), oldNode.second);
newList.append(idx);
}
changePersistentIndexList(oldList, newList);
@@ -1648,7 +1652,9 @@ QStringList QFileSystemModel::nameFilters() const
Q_D(const QFileSystemModel);
QStringList filters;
#ifndef QT_NO_REGEXP
- for (int i = 0; i < d->nameFilters.size(); ++i) {
+ const int numNameFilters = d->nameFilters.size();
+ filters.reserve(numNameFilters);
+ for (int i = 0; i < numNameFilters; ++i) {
filters << d->nameFilters.at(i).pattern();
}
#endif
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index d47dd3562f..688e8f5c13 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -619,6 +619,7 @@ void QFontDialogPrivate::updateSizes()
int i = 0;
int current = -1;
QStringList str_sizes;
+ str_sizes.reserve(sizes.size());
for(QList<int>::const_iterator it = sizes.constBegin(); it != sizes.constEnd(); ++it) {
str_sizes.append(QString::number(*it));
if (current == -1 && *it == size)
diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp
index 9c78f5e9ac..fb52fa4651 100644
--- a/src/widgets/dialogs/qinputdialog.cpp
+++ b/src/widgets/dialogs/qinputdialog.cpp
@@ -791,6 +791,7 @@ QStringList QInputDialog::comboBoxItems() const
QStringList result;
if (d->comboBox) {
const int count = d->comboBox->count();
+ result.reserve(count);
for (int i = 0; i < count; ++i)
result.append(d->comboBox->itemText(i));
}
diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp
index 6fbcce801d..be3c060ba1 100644
--- a/src/widgets/dialogs/qsidebar.cpp
+++ b/src/widgets/dialogs/qsidebar.cpp
@@ -274,7 +274,9 @@ void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move)
QList<QUrl> QUrlModel::urls() const
{
QList<QUrl> list;
- for (int i = 0; i < rowCount(); ++i)
+ const int numRows = rowCount();
+ list.reserve(numRows);
+ for (int i = 0; i < numRows; ++i)
list.append(data(index(i, 0), UrlRole).toUrl());
return list;
}
@@ -334,10 +336,12 @@ void QUrlModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto
void QUrlModel::layoutChanged()
{
QStringList paths;
- for (int i = 0; i < watching.count(); ++i)
+ const int numPaths = watching.count();
+ paths.reserve(numPaths);
+ for (int i = 0; i < numPaths; ++i)
paths.append(watching.at(i).second);
watching.clear();
- for (int i = 0; i < paths.count(); ++i) {
+ for (int i = 0; i < numPaths; ++i) {
QString path = paths.at(i);
QModelIndex newIndex = fileSystemModel->index(path);
watching.append(QPair<QModelIndex, QString>(newIndex, path));
@@ -453,12 +457,14 @@ void QSidebar::removeEntry()
{
QList<QModelIndex> idxs = selectionModel()->selectedIndexes();
QList<QPersistentModelIndex> indexes;
- for (int i = 0; i < idxs.count(); i++)
+ const int numIndexes = idxs.count();
+ for (int i = 0; i < numIndexes; i++)
indexes.append(idxs.at(i));
- for (int i = 0; i < indexes.count(); ++i)
+ for (int i = 0; i < numIndexes; ++i) {
if (!indexes.at(i).data(QUrlModel::UrlRole).toUrl().path().isEmpty())
model()->removeRow(indexes.at(i).row());
+ }
}
/*!
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index 139fbc3843..680d29443d 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -751,6 +751,7 @@ void QWizardPrivate::init()
updateButtonLayout();
+ defaultPropertyTable.reserve(NFallbackDefaultProperties);
for (uint i = 0; i < NFallbackDefaultProperties; ++i)
defaultPropertyTable.append(QWizardDefaultProperty(fallbackProperties[i].className,
fallbackProperties[i].property,
diff --git a/src/widgets/doc/images/listview.png b/src/widgets/doc/images/listview.png
index fa49c52c62..fa49c52c62 100755..100644
--- a/src/widgets/doc/images/listview.png
+++ b/src/widgets/doc/images/listview.png
Binary files differ
diff --git a/src/widgets/doc/images/modelview-combobox.png b/src/widgets/doc/images/modelview-combobox.png
index d172b413eb..d172b413eb 100755..100644
--- a/src/widgets/doc/images/modelview-combobox.png
+++ b/src/widgets/doc/images/modelview-combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/tableview.png b/src/widgets/doc/images/tableview.png
index 8be1b6ce62..8be1b6ce62 100755..100644
--- a/src/widgets/doc/images/tableview.png
+++ b/src/widgets/doc/images/tableview.png
Binary files differ
diff --git a/src/widgets/doc/snippets/macmainwindow.mm b/src/widgets/doc/snippets/macmainwindow.mm
index d0d74631ab..d0d74631ab 100755..100644
--- a/src/widgets/doc/snippets/macmainwindow.mm
+++ b/src/widgets/doc/snippets/macmainwindow.mm
diff --git a/src/widgets/effects/qgraphicseffect.cpp b/src/widgets/effects/qgraphicseffect.cpp
index f53804e494..5a97be3d96 100644
--- a/src/widgets/effects/qgraphicseffect.cpp
+++ b/src/widgets/effects/qgraphicseffect.cpp
@@ -111,6 +111,10 @@
#ifndef QT_NO_GRAPHICSEFFECT
QT_BEGIN_NAMESPACE
+QGraphicsEffectPrivate::~QGraphicsEffectPrivate()
+{
+}
+
/*!
\internal
\class QGraphicsEffectSource
diff --git a/src/widgets/effects/qgraphicseffect_p.h b/src/widgets/effects/qgraphicseffect_p.h
index 6e990cc52e..35264c0d30 100644
--- a/src/widgets/effects/qgraphicseffect_p.h
+++ b/src/widgets/effects/qgraphicseffect_p.h
@@ -142,6 +142,7 @@ class Q_WIDGETS_EXPORT QGraphicsEffectPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QGraphicsEffect)
public:
QGraphicsEffectPrivate() : source(0), isEnabled(1) {}
+ ~QGraphicsEffectPrivate();
inline void setGraphicsEffectSource(QGraphicsEffectSource *newSource)
{
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
index 8327777217..dac8e61645 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -751,9 +751,12 @@ static AnchorData *createSequence(Graph<AnchorVertex, AnchorData> *graph,
AnchorVertex *prev = before;
QVector<AnchorData *> edges;
+ edges.reserve(vertices.count() + 1);
+ const int numVertices = vertices.count();
+ edges.reserve(numVertices + 1);
// Take from the graph, the edges that will be simplificated
- for (int i = 0; i < vertices.count(); ++i) {
+ for (int i = 0; i < numVertices; ++i) {
AnchorVertex *next = vertices.at(i);
AnchorData *ad = graph->takeEdge(prev, next);
Q_ASSERT(ad);
@@ -2569,6 +2572,7 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation)
if (!remainingConstraints.isEmpty()) {
QList<QSimplexConstraint *> nonTrunkConstraints;
+ nonTrunkConstraints.reserve(remainingConstraints.size());
QLinkedList<QSimplexConstraint *>::iterator it = remainingConstraints.begin();
while (it != remainingConstraints.end()) {
nonTrunkConstraints += *it;
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index cd30410097..1fdbe0fc18 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -10829,9 +10829,7 @@ void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic
range.start = 0;
range.length = layout.text().length();
range.format.setTextOutline(d->pen);
- QList<QTextLayout::FormatRange> formats;
- formats.append(range);
- layout.setAdditionalFormats(formats);
+ layout.setFormats(QVector<QTextLayout::FormatRange>(1, range));
}
setupTextLayout(&layout);
diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
index 0a6fccf559..585539de94 100644
--- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp
+++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
@@ -116,7 +116,6 @@ public:
qreal step;
struct Pair {
- Pair(qreal a, qreal b) : step(a), value(b) {}
bool operator <(const Pair &other) const
{ return step < other.step; }
bool operator==(const Pair &other) const
@@ -124,21 +123,22 @@ public:
qreal step;
qreal value;
};
- QList<Pair> xPosition;
- QList<Pair> yPosition;
- QList<Pair> rotation;
- QList<Pair> verticalScale;
- QList<Pair> horizontalScale;
- QList<Pair> verticalShear;
- QList<Pair> horizontalShear;
- QList<Pair> xTranslation;
- QList<Pair> yTranslation;
-
- qreal linearValueForStep(qreal step, QList<Pair> *source, qreal defaultValue = 0);
- void insertUniquePair(qreal step, qreal value, QList<Pair> *binList, const char* method);
+ QVector<Pair> xPosition;
+ QVector<Pair> yPosition;
+ QVector<Pair> rotation;
+ QVector<Pair> verticalScale;
+ QVector<Pair> horizontalScale;
+ QVector<Pair> verticalShear;
+ QVector<Pair> horizontalShear;
+ QVector<Pair> xTranslation;
+ QVector<Pair> yTranslation;
+
+ qreal linearValueForStep(qreal step, QVector<Pair> *source, qreal defaultValue = 0);
+ void insertUniquePair(qreal step, qreal value, QVector<Pair> *binList, const char* method);
};
+Q_DECLARE_TYPEINFO(QGraphicsItemAnimationPrivate::Pair, Q_PRIMITIVE_TYPE);
-qreal QGraphicsItemAnimationPrivate::linearValueForStep(qreal step, QList<Pair> *source, qreal defaultValue)
+qreal QGraphicsItemAnimationPrivate::linearValueForStep(qreal step, QVector<Pair> *source, qreal defaultValue)
{
if (source->isEmpty())
return defaultValue;
@@ -168,20 +168,18 @@ qreal QGraphicsItemAnimationPrivate::linearValueForStep(qreal step, QList<Pair>
return valueBefore + (valueAfter - valueBefore) * ((step - stepBefore) / (stepAfter - stepBefore));
}
-void QGraphicsItemAnimationPrivate::insertUniquePair(qreal step, qreal value, QList<Pair> *binList, const char* method)
+void QGraphicsItemAnimationPrivate::insertUniquePair(qreal step, qreal value, QVector<Pair> *binList, const char* method)
{
if (!check_step_valid(step, method))
return;
- Pair pair(step, value);
+ const Pair pair = { step, value };
- QList<Pair>::iterator result = std::lower_bound(binList->begin(), binList->end(), pair);
- if ((result != binList->end()) && !(pair < *result))
+ const QVector<Pair>::iterator result = std::lower_bound(binList->begin(), binList->end(), pair);
+ if (result == binList->end() || pair < *result)
+ binList->insert(result, pair);
+ else
result->value = value;
- else {
- *binList << pair;
- std::sort(binList->begin(), binList->end());
- }
}
/*!
@@ -284,7 +282,9 @@ void QGraphicsItemAnimation::setPosAt(qreal step, const QPointF &pos)
QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::posList() const
{
QList<QPair<qreal, QPointF> > list;
- for (int i = 0; i < d->xPosition.size(); ++i)
+ const int xPosCount = d->xPosition.size();
+ list.reserve(xPosCount);
+ for (int i = 0; i < xPosCount; ++i)
list << QPair<qreal, QPointF>(d->xPosition.at(i).step, QPointF(d->xPosition.at(i).value, d->yPosition.at(i).value));
return list;
@@ -338,7 +338,9 @@ void QGraphicsItemAnimation::setRotationAt(qreal step, qreal angle)
QList<QPair<qreal, qreal> > QGraphicsItemAnimation::rotationList() const
{
QList<QPair<qreal, qreal> > list;
- for (int i = 0; i < d->rotation.size(); ++i)
+ const int numRotations = d->rotation.size();
+ list.reserve(numRotations);
+ for (int i = 0; i < numRotations; ++i)
list << QPair<qreal, qreal>(d->rotation.at(i).step, d->rotation.at(i).value);
return list;
@@ -386,7 +388,9 @@ void QGraphicsItemAnimation::setTranslationAt(qreal step, qreal dx, qreal dy)
QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::translationList() const
{
QList<QPair<qreal, QPointF> > list;
- for (int i = 0; i < d->xTranslation.size(); ++i)
+ const int numTranslations = d->xTranslation.size();
+ list.reserve(numTranslations);
+ for (int i = 0; i < numTranslations; ++i)
list << QPair<qreal, QPointF>(d->xTranslation.at(i).step, QPointF(d->xTranslation.at(i).value, d->yTranslation.at(i).value));
return list;
@@ -435,7 +439,9 @@ void QGraphicsItemAnimation::setScaleAt(qreal step, qreal sx, qreal sy)
QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::scaleList() const
{
QList<QPair<qreal, QPointF> > list;
- for (int i = 0; i < d->horizontalScale.size(); ++i)
+ const int numScales = d->horizontalScale.size();
+ list.reserve(numScales);
+ for (int i = 0; i < numScales; ++i)
list << QPair<qreal, QPointF>(d->horizontalScale.at(i).step, QPointF(d->horizontalScale.at(i).value, d->verticalScale.at(i).value));
return list;
@@ -483,7 +489,9 @@ void QGraphicsItemAnimation::setShearAt(qreal step, qreal sh, qreal sv)
QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::shearList() const
{
QList<QPair<qreal, QPointF> > list;
- for (int i = 0; i < d->horizontalShear.size(); ++i)
+ const int numShears = d->horizontalShear.size();
+ list.reserve(numShears);
+ for (int i = 0; i < numShears; ++i)
list << QPair<qreal, QPointF>(d->horizontalShear.at(i).step, QPointF(d->horizontalShear.at(i).value, d->verticalShear.at(i).value));
return list;
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index db4d18299b..08ea1ea0e3 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -269,8 +269,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
// Send mouse event.
QMouseEvent mouseEvent(type, pos, receiver->mapTo(receiver->topLevelWidget(), pos.toPoint()),
receiver->mapToGlobal(pos.toPoint()),
- event->button(), event->buttons(), event->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&mouseEvent, event->source());
+ event->button(), event->buttons(), event->modifiers(), event->source());
QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
QApplicationPrivate::sendMouseEvent(receiver, &mouseEvent, alienWidget, widget,
diff --git a/src/widgets/graphicsview/qgraphicssceneevent.h b/src/widgets/graphicsview/qgraphicssceneevent.h
index 1e3554fa36..ffa708ea23 100644
--- a/src/widgets/graphicsview/qgraphicssceneevent.h
+++ b/src/widgets/graphicsview/qgraphicssceneevent.h
@@ -40,7 +40,9 @@
#include <QtCore/qrect.h>
#include <QtGui/qpolygon.h>
#include <QtCore/qset.h>
+#if QT_DEPRECATED_SINCE(5, 5)
#include <QtCore/qhash.h>
+#endif
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/graphicsview/qgraphicssceneindex.cpp b/src/widgets/graphicsview/qgraphicssceneindex.cpp
index 8662f73d64..a76f6b6565 100644
--- a/src/widgets/graphicsview/qgraphicssceneindex.cpp
+++ b/src/widgets/graphicsview/qgraphicssceneindex.cpp
@@ -520,7 +520,9 @@ QList<QGraphicsItem *> QGraphicsSceneIndex::estimateTopLevelItems(const QRectF &
scened->ensureSortedTopLevelItems();
if (order == Qt::DescendingOrder) {
QList<QGraphicsItem *> sorted;
- for (int i = scened->topLevelItems.size() - 1; i >= 0; --i)
+ const int numTopLevelItems = scened->topLevelItems.size();
+ sorted.reserve(numTopLevelItems);
+ for (int i = numTopLevelItems - 1; i >= 0; --i)
sorted << scened->topLevelItems.at(i);
return sorted;
}
diff --git a/src/widgets/graphicsview/qgraphicstransform.cpp b/src/widgets/graphicsview/qgraphicstransform.cpp
index 67564b5a8b..fe963fbf3c 100644
--- a/src/widgets/graphicsview/qgraphicstransform.cpp
+++ b/src/widgets/graphicsview/qgraphicstransform.cpp
@@ -89,6 +89,11 @@
#ifndef QT_NO_GRAPHICSVIEW
QT_BEGIN_NAMESPACE
+
+QGraphicsTransformPrivate::~QGraphicsTransformPrivate()
+{
+}
+
void QGraphicsTransformPrivate::setItem(QGraphicsItem *i)
{
if (item == i)
diff --git a/src/widgets/graphicsview/qgraphicstransform_p.h b/src/widgets/graphicsview/qgraphicstransform_p.h
index dde085935f..c81a95fd3d 100644
--- a/src/widgets/graphicsview/qgraphicstransform_p.h
+++ b/src/widgets/graphicsview/qgraphicstransform_p.h
@@ -51,12 +51,14 @@ QT_BEGIN_NAMESPACE
class QGraphicsItem;
-class QGraphicsTransformPrivate : public QObjectPrivate {
+// ### Qt 6: unexport again, if QtQuick1's QDeclarativeTranslatePrivate is gone by then
+class Q_WIDGETS_EXPORT QGraphicsTransformPrivate : public QObjectPrivate {
public:
Q_DECLARE_PUBLIC(QGraphicsTransform)
QGraphicsTransformPrivate()
: QObjectPrivate(), item(0) {}
+ ~QGraphicsTransformPrivate();
QGraphicsItem *item;
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index c270c4be88..ac8cd45f9e 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -362,6 +362,10 @@ QGraphicsViewPrivate::QGraphicsViewPrivate()
styleOptions.reserve(QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS);
}
+QGraphicsViewPrivate::~QGraphicsViewPrivate()
+{
+}
+
/*!
\internal
*/
@@ -2460,6 +2464,7 @@ QPolygonF QGraphicsView::mapToScene(const QRect &rect) const
QPolygonF QGraphicsView::mapToScene(const QPolygon &polygon) const
{
QPolygonF poly;
+ poly.reserve(polygon.count());
foreach (const QPoint &point, polygon)
poly << mapToScene(point);
return poly;
@@ -2555,6 +2560,7 @@ QPolygon QGraphicsView::mapFromScene(const QRectF &rect) const
QPolygon QGraphicsView::mapFromScene(const QPolygonF &polygon) const
{
QPolygon poly;
+ poly.reserve(polygon.count());
foreach (const QPointF &point, polygon)
poly << mapFromScene(point);
return poly;
@@ -2669,7 +2675,9 @@ void QGraphicsView::updateScene(const QList<QRectF> &rects)
// Extract and reset dirty scene rect info.
QVector<QRect> dirtyViewportRects;
const QVector<QRect> &dirtyRects = d->dirtyRegion.rects();
- for (int i = 0; i < dirtyRects.size(); ++i)
+ const int dirtyRectsCount = dirtyRects.size();
+ dirtyViewportRects.reserve(dirtyRectsCount + rects.count());
+ for (int i = 0; i < dirtyRectsCount; ++i)
dirtyViewportRects += dirtyRects.at(i);
d->dirtyRegion = QRegion();
d->dirtyBoundingRect = QRect();
diff --git a/src/widgets/graphicsview/qgraphicsview_p.h b/src/widgets/graphicsview/qgraphicsview_p.h
index fec8336695..dcbffb1c39 100644
--- a/src/widgets/graphicsview/qgraphicsview_p.h
+++ b/src/widgets/graphicsview/qgraphicsview_p.h
@@ -63,6 +63,7 @@ class Q_WIDGETS_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
Q_DECLARE_PUBLIC(QGraphicsView)
public:
QGraphicsViewPrivate();
+ ~QGraphicsViewPrivate();
void recalculateContentSize();
void centerView(QGraphicsView::ViewportAnchor anchor);
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 2caf5d1eb3..276e185457 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -1882,8 +1882,7 @@ void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event)
|| (d->pressedIndex != index)) {
QMouseEvent me(QEvent::MouseButtonPress,
event->localPos(), event->windowPos(), event->screenPos(),
- event->button(), event->buttons(), event->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&me, event->source());
+ event->button(), event->buttons(), event->modifiers(), event->source());
mousePressEvent(&me);
return;
}
@@ -3017,9 +3016,8 @@ int QAbstractItemView::sizeHintForRow(int row) const
QStyleOptionViewItem option = d->viewOptionsV1();
int height = 0;
int colCount = d->model->columnCount(d->root);
- QModelIndex index;
for (int c = 0; c < colCount; ++c) {
- index = d->model->index(row, c, d->root);
+ const QModelIndex index = d->model->index(row, c, d->root);
if (QWidget *editor = d->editorForIndex(index).widget.data())
height = qMax(height, editor->height());
int hint = d->delegateForIndex(index)->sizeHint(option, index).height();
@@ -3048,9 +3046,8 @@ int QAbstractItemView::sizeHintForColumn(int column) const
QStyleOptionViewItem option = d->viewOptionsV1();
int width = 0;
int rows = d->model->rowCount(d->root);
- QModelIndex index;
for (int r = 0; r < rows; ++r) {
- index = d->model->index(r, column, d->root);
+ const QModelIndex index = d->model->index(r, column, d->root);
if (QWidget *editor = d->editorForIndex(index).widget.data())
width = qMax(width, editor->sizeHint().width());
int hint = d->delegateForIndex(index)->sizeHint(option, index).width();
diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp
index 5c317bbb0c..92bbdf6b69 100644
--- a/src/widgets/itemviews/qcolumnview.cpp
+++ b/src/widgets/itemviews/qcolumnview.cpp
@@ -861,11 +861,15 @@ void QColumnView::setColumnWidths(const QList<int> &list)
{
Q_D(QColumnView);
int i = 0;
- for (; (i < list.count() && i < d->columns.count()); ++i) {
+ const int listCount = list.count();
+ const int count = qMin(listCount, d->columns.count());
+ for (; i < count; ++i) {
d->columns.at(i)->resize(list.at(i), d->columns.at(i)->height());
d->columnSizes[i] = list.at(i);
}
- for (; i < list.count(); ++i)
+
+ d->columnSizes.reserve(listCount);
+ for (; i < listCount; ++i)
d->columnSizes.append(list.at(i));
}
@@ -878,7 +882,9 @@ QList<int> QColumnView::columnWidths() const
{
Q_D(const QColumnView);
QList<int> list;
- for (int i = 0; i < d->columns.count(); ++i)
+ const int columnCount = d->columns.count();
+ list.reserve(columnCount);
+ for (int i = 0; i < columnCount; ++i)
list.append(d->columnSizes.at(i));
return list;
}
diff --git a/src/widgets/itemviews/qdatawidgetmapper.cpp b/src/widgets/itemviews/qdatawidgetmapper.cpp
index c9fdf9967a..ee7b3613a2 100644
--- a/src/widgets/itemviews/qdatawidgetmapper.cpp
+++ b/src/widgets/itemviews/qdatawidgetmapper.cpp
@@ -756,7 +756,7 @@ void QDataWidgetMapper::clearMapping()
QList<QDataWidgetMapperPrivate::WidgetMapper> copy;
d->widgetMap.swap(copy); // a C++98 move
- for (std::reverse_iterator<QList<QDataWidgetMapperPrivate::WidgetMapper>::const_iterator> it(copy.cend()), end(copy.cbegin()); it != end; ++it) {
+ for (QList<QDataWidgetMapperPrivate::WidgetMapper>::const_reverse_iterator it = copy.crbegin(), end = copy.crend(); it != end; ++it) {
if (it->widget)
it->widget->removeEventFilter(d->delegate);
}
diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp
index 051cb8e7cc..f43bcd5d5a 100644
--- a/src/widgets/itemviews/qfileiconprovider.cpp
+++ b/src/widgets/itemviews/qfileiconprovider.cpp
@@ -117,6 +117,7 @@ public:
if (themeSizes.isEmpty())
return sizes;
+ sizes.reserve(themeSizes.count());
foreach (int size, themeSizes)
sizes << QSize(size, size);
}
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index f3fd3e75a1..9b07564db9 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -53,6 +53,8 @@
QT_BEGIN_NAMESPACE
+extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
+
/*!
\class QListView
@@ -796,6 +798,35 @@ void QListView::mouseReleaseEvent(QMouseEvent *e)
}
}
+#ifndef QT_NO_WHEELEVENT
+/*!
+ \reimp
+*/
+void QListView::wheelEvent(QWheelEvent *e)
+{
+ Q_D(QListView);
+ if (e->orientation() == Qt::Vertical) {
+ if (e->angleDelta().x() == 0
+ && ((d->flow == TopToBottom && d->wrap) || (d->flow == LeftToRight && !d->wrap))
+ && d->vbar->minimum() == 0 && d->vbar->maximum() == 0) {
+ QPoint pixelDelta(e->pixelDelta().y(), e->pixelDelta().x());
+ QPoint angleDelta(e->angleDelta().y(), e->angleDelta().x());
+ QWheelEvent hwe(e->pos(), e->globalPos(), pixelDelta, angleDelta, e->delta(),
+ Qt::Horizontal, e->buttons(), e->modifiers(), e->phase());
+ if (e->spontaneous())
+ qt_sendSpontaneousEvent(d->hbar, &hwe);
+ else
+ QApplication::sendEvent(d->hbar, &hwe);
+ e->setAccepted(hwe.isAccepted());
+ } else {
+ QApplication::sendEvent(d->vbar, e);
+ }
+ } else {
+ QApplication::sendEvent(d->hbar, e);
+ }
+}
+#endif // QT_NO_WHEELEVENT
+
/*!
\reimp
*/
diff --git a/src/widgets/itemviews/qlistview.h b/src/widgets/itemviews/qlistview.h
index f62c96067f..ac65a47d9f 100644
--- a/src/widgets/itemviews/qlistview.h
+++ b/src/widgets/itemviews/qlistview.h
@@ -146,6 +146,9 @@ protected:
void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
+#endif
void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index 66f965aa54..0e1e56e966 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -299,7 +299,10 @@ void QListModel::sort(int column, Qt::SortOrder order)
std::sort(sorting.begin(), sorting.end(), compare);
QModelIndexList fromIndexes;
QModelIndexList toIndexes;
- for (int r = 0; r < sorting.count(); ++r) {
+ const int sortingCount = sorting.count();
+ fromIndexes.reserve(sortingCount);
+ toIndexes.reserve(sortingCount);
+ for (int r = 0; r < sortingCount; ++r) {
QListWidgetItem *item = sorting.at(r).first;
toIndexes.append(createIndex(r, 0, item));
fromIndexes.append(createIndex(sorting.at(r).second, 0, sorting.at(r).first));
@@ -423,7 +426,9 @@ QMimeData *QListModel::internalMimeData() const
QMimeData *QListModel::mimeData(const QModelIndexList &indexes) const
{
QList<QListWidgetItem*> itemlist;
- for (int i = 0; i < indexes.count(); ++i)
+ const int indexesCount = indexes.count();
+ itemlist.reserve(indexesCount);
+ for (int i = 0; i < indexesCount; ++i)
itemlist << at(indexes.at(i).row());
const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent());
@@ -1694,7 +1699,9 @@ QList<QListWidgetItem*> QListWidget::selectedItems() const
Q_D(const QListWidget);
QModelIndexList indexes = selectionModel()->selectedIndexes();
QList<QListWidgetItem*> items;
- for (int i = 0; i < indexes.count(); ++i)
+ const int numIndexes = indexes.count();
+ items.reserve(numIndexes);
+ for (int i = 0; i < numIndexes; ++i)
items.append(d->listModel()->at(indexes.at(i).row()));
return items;
}
@@ -1710,7 +1717,9 @@ QList<QListWidgetItem*> QListWidget::findItems(const QString &text, Qt::MatchFla
QModelIndexList indexes = d->listModel()->match(model()->index(0, 0, QModelIndex()),
Qt::DisplayRole, text, -1, flags);
QList<QListWidgetItem*> items;
- for (int i = 0; i < indexes.size(); ++i)
+ const int indexesSize = indexes.size();
+ items.reserve(indexesSize);
+ for (int i = 0; i < indexesSize; ++i)
items.append(d->listModel()->at(indexes.at(i).row()));
return items;
}
@@ -1795,6 +1804,7 @@ QMimeData *QListWidget::mimeData(const QList<QListWidgetItem*> items) const
// if non empty, it's called from the model's own mimeData
if (cachedIndexes.isEmpty()) {
+ cachedIndexes.reserve(items.count());
foreach (QListWidgetItem *item, items)
cachedIndexes << indexFromItem(item);
@@ -1845,7 +1855,9 @@ void QListWidget::dropEvent(QDropEvent *event) {
if (d->dropOn(event, &row, &col, &topIndex)) {
QList<QModelIndex> selIndexes = selectedIndexes();
QList<QPersistentModelIndex> persIndexes;
- for (int i = 0; i < selIndexes.count(); i++)
+ const int selIndexesCount = selIndexes.count();
+ persIndexes.reserve(selIndexesCount);
+ for (int i = 0; i < selIndexesCount; i++)
persIndexes.append(selIndexes.at(i));
if (persIndexes.contains(topIndex))
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index ae31387faf..238cbf3bcd 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -1884,6 +1884,7 @@ void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionF
break;
}
} while (expanded);
+ selection.reserve((right - left + 1) * (bottom - top + 1));
for (int horizontal = left; horizontal <= right; ++horizontal) {
int column = d->logicalColumn(horizontal);
for (int vertical = top; vertical <= bottom; ++vertical) {
@@ -1897,6 +1898,7 @@ void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionF
int left = d->visualColumn(tl.column());
int bottom = d->visualRow(br.row());
int right = d->visualColumn(br.column());
+ selection.reserve((right - left + 1) * (bottom - top + 1));
for (int horizontal = left; horizontal <= right; ++horizontal) {
int column = d->logicalColumn(horizontal);
for (int vertical = top; vertical <= bottom; ++vertical) {
@@ -1908,6 +1910,7 @@ void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionF
} else if (horizontalMoved) {
int left = d->visualColumn(tl.column());
int right = d->visualColumn(br.column());
+ selection.reserve(right - left + 1);
for (int visual = left; visual <= right; ++visual) {
int column = d->logicalColumn(visual);
QModelIndex topLeft = d->model->index(tl.row(), column, d->root);
@@ -1917,6 +1920,7 @@ void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionF
} else if (verticalMoved) {
int top = d->visualRow(tl.row());
int bottom = d->visualRow(br.row());
+ selection.reserve(bottom - top + 1);
for (int visual = top; visual <= bottom; ++visual) {
int row = d->logicalRow(visual);
QModelIndex topLeft = d->model->index(row, tl.column(), d->root);
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 9ebcbc35a7..f0c7ac0d32 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -507,11 +507,15 @@ void QTableModel::sort(int column, Qt::SortOrder order)
QVector<QTableWidgetItem*> sorted_table(tableItems.count());
QModelIndexList from;
QModelIndexList to;
- for (int i = 0; i < rowCount(); ++i) {
+ const int numRows = rowCount();
+ const int numColumns = columnCount();
+ from.reserve(numRows * numColumns);
+ to.reserve(numRows * numColumns);
+ for (int i = 0; i < numRows; ++i) {
int r = (i < sortable.count()
? sortable.at(i).second
: unsortable.at(i - sortable.count()));
- for (int c = 0; c < columnCount(); ++c) {
+ for (int c = 0; c < numColumns; ++c) {
sorted_table[tableIndex(i, c)] = item(r, c);
from.append(createIndex(r, c));
to.append(createIndex(i, c));
@@ -812,7 +816,9 @@ QMimeData *QTableModel::internalMimeData() const
QMimeData *QTableModel::mimeData(const QModelIndexList &indexes) const
{
QList<QTableWidgetItem*> items;
- for (int i = 0; i < indexes.count(); ++i)
+ const int indexesCount = indexes.count();
+ items.reserve(indexesCount);
+ for (int i = 0; i < indexesCount; ++i)
items << item(indexes.at(i));
const QTableWidget *view = qobject_cast<const QTableWidget*>(QObject::parent());
@@ -2326,7 +2332,9 @@ QList<QTableWidgetSelectionRange> QTableWidget::selectedRanges() const
{
const QList<QItemSelectionRange> ranges = selectionModel()->selection();
QList<QTableWidgetSelectionRange> result;
- for (int i = 0; i < ranges.count(); ++i)
+ const int rangesCount = ranges.count();
+ result.reserve(rangesCount);
+ for (int i = 0; i < rangesCount; ++i)
result.append(QTableWidgetSelectionRange(ranges.at(i).top(),
ranges.at(i).left(),
ranges.at(i).bottom(),
@@ -2372,7 +2380,9 @@ QList<QTableWidgetItem*> QTableWidget::findItems(const QString &text, Qt::MatchF
indexes += d->model->match(model()->index(0, column, QModelIndex()),
Qt::DisplayRole, text, -1, flags);
QList<QTableWidgetItem*> items;
- for (int i = 0; i < indexes.size(); ++i)
+ const int indexCount = indexes.size();
+ items.reserve(indexCount);
+ for (int i = 0; i < indexCount; ++i)
items.append(d->tableModel()->item(indexes.at(i)));
return items;
}
@@ -2565,6 +2575,7 @@ QMimeData *QTableWidget::mimeData(const QList<QTableWidgetItem*> items) const
// if non empty, it's called from the model's own mimeData
if (cachedIndexes.isEmpty()) {
+ cachedIndexes.reserve(items.count());
foreach (QTableWidgetItem *item, items)
cachedIndexes << indexFromItem(item);
@@ -2676,7 +2687,9 @@ void QTableWidget::dropEvent(QDropEvent *event) {
}
QList<QTableWidgetItem *> taken;
- for (int i = 0; i < indexes.count(); ++i)
+ const int indexesCount = indexes.count();
+ taken.reserve(indexesCount);
+ for (int i = 0; i < indexesCount; ++i)
taken.append(takeItem(indexes.at(i).row(), indexes.at(i).column()));
for (int i = 0; i < indexes.count(); ++i) {
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index bf736bc387..5970e94292 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -1720,12 +1720,12 @@ void QTreeWidgetItem::setData(int column, int role, const QVariant &value)
}
} break;
case Qt::CheckStateRole:
- if ((itemFlags & Qt::ItemIsTristate) && value != Qt::PartiallyChecked) {
+ if ((itemFlags & Qt::ItemIsAutoTristate) && value != Qt::PartiallyChecked) {
for (int i = 0; i < children.count(); ++i) {
QTreeWidgetItem *child = children.at(i);
if (child->data(column, role).isValid()) {// has a CheckState
Qt::ItemFlags f = itemFlags; // a little hack to avoid multiple dataChanged signals
- itemFlags &= ~Qt::ItemIsTristate;
+ itemFlags &= ~Qt::ItemIsAutoTristate;
child->setData(column, role, value);
itemFlags = f;
}
@@ -1760,7 +1760,7 @@ void QTreeWidgetItem::setData(int column, int role, const QVariant &value)
model->emitDataChanged(this, column);
if (role == Qt::CheckStateRole) {
QTreeWidgetItem *p;
- for (p = par; p && (p->itemFlags & Qt::ItemIsTristate); p = p->par)
+ for (p = par; p && (p->itemFlags & Qt::ItemIsAutoTristate); p = p->par)
model->emitDataChanged(p, column);
}
}
@@ -1779,7 +1779,7 @@ QVariant QTreeWidgetItem::data(int column, int role) const
break;
case Qt::CheckStateRole:
// special case for check state in tristate
- if (children.count() && (itemFlags & Qt::ItemIsTristate))
+ if (children.count() && (itemFlags & Qt::ItemIsAutoTristate))
return childrenCheckState(column);
// fallthrough intended
default:
@@ -3042,7 +3042,9 @@ QList<QTreeWidgetItem*> QTreeWidget::findItems(const QString &text, Qt::MatchFla
QModelIndexList indexes = d->model->match(model()->index(0, column, QModelIndex()),
Qt::DisplayRole, text, -1, flags);
QList<QTreeWidgetItem*> items;
- for (int i = 0; i < indexes.size(); ++i)
+ const int indexesSize = indexes.size();
+ items.reserve(indexesSize);
+ for (int i = 0; i < indexesSize; ++i)
items.append(d->item(indexes.at(i)));
return items;
}
@@ -3371,7 +3373,9 @@ void QTreeWidget::dropEvent(QDropEvent *event) {
if (d->dropOn(event, &row, &col, &topIndex)) {
QList<QModelIndex> idxs = selectedIndexes();
QList<QPersistentModelIndex> indexes;
- for (int i = 0; i < idxs.count(); i++)
+ const int indexesCount = idxs.count();
+ indexes.reserve(indexesCount);
+ for (int i = 0; i < indexesCount; i++)
indexes.append(idxs.at(i));
if (indexes.contains(topIndex))
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index b9fd6312e7..504932dc53 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3250,12 +3250,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
QPointer<QWidget> pw = w;
while (w) {
- QMouseEvent me(mouse->type(), relpos, mouse->windowPos(), mouse->globalPos(), mouse->button(), mouse->buttons(),
- mouse->modifiers());
+ QMouseEvent me(mouse->type(), relpos, mouse->windowPos(), mouse->globalPos(),
+ mouse->button(), mouse->buttons(), mouse->modifiers(), mouse->source());
me.spont = mouse->spontaneous();
me.setTimestamp(mouse->timestamp());
QGuiApplicationPrivate::setMouseEventFlags(&me, mouse->flags());
- QGuiApplicationPrivate::setMouseEventSource(&me, mouse->source());
// throw away any mouse-tracking-only mouse events
if (!w->hasMouseTracking()
&& mouse->type() == QEvent::MouseMove && mouse->buttons() == 0) {
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index b5d3a56d3f..8cb7c2b560 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -569,18 +569,19 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,
}
// for each gesture type
- foreach (Qt::GestureType type, gestureByTypes.keys()) {
- QHash<QWidget *, QGesture *> gestures = gestureByTypes.value(type);
- foreach (QWidget *widget, gestures.keys()) {
+ for (GestureByTypes::const_iterator git = gestureByTypes.cbegin(), gend = gestureByTypes.cend(); git != gend; ++git) {
+ const QHash<QWidget *, QGesture *> &gestures = git.value();
+ for (QHash<QWidget *, QGesture *>::const_iterator wit = gestures.cbegin(), wend = gestures.cend(); wit != wend; ++wit) {
+ QWidget *widget = wit.key();
QWidget *w = widget->parentWidget();
while (w) {
QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it
- = w->d_func()->gestureContext.constFind(type);
+ = w->d_func()->gestureContext.constFind(git.key());
if (it != w->d_func()->gestureContext.constEnd()) {
// i.e. 'w' listens to gesture 'type'
if (!(it.value() & Qt::DontStartGestureOnChildren) && w != widget) {
// conflicting gesture!
- (*conflicts)[widget].append(gestures[widget]);
+ (*conflicts)[widget].append(wit.value());
break;
}
}
@@ -591,7 +592,7 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,
w = w->parentWidget();
}
if (!w)
- (*normal)[widget].append(gestures[widget]);
+ (*normal)[widget].append(wit.value());
}
}
}
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index d3e5986103..e74f17b6f7 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -1175,13 +1175,12 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt
if (index == -1)
return 0;
+ addChildWidget(to);
QLayoutItem *newitem = new QWidgetItem(to);
newitem->setAlignment(item->alignment());
QLayoutItem *r = d->replaceAt(index, newitem);
if (!r)
delete newitem;
- else
- addChildWidget(to);
return r;
}
diff --git a/src/widgets/kernel/qsizepolicy.cpp b/src/widgets/kernel/qsizepolicy.cpp
index 1476b4c5d7..3c28f5ccf7 100644
--- a/src/widgets/kernel/qsizepolicy.cpp
+++ b/src/widgets/kernel/qsizepolicy.cpp
@@ -332,6 +332,15 @@ void QSizePolicy::setControlType(ControlType type)
*/
/*!
+ \fn uint qHash(QSizePolicy key, uint seed = 0)
+ \since 5.6
+ \relates QSizePolicy
+
+ Returns the hash value for \a key, using
+ \a seed to seed the calculation.
+*/
+
+/*!
\fn int QSizePolicy::horizontalStretch() const
Returns the horizontal stretch factor of the size policy.
diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h
index 6cd511f513..7c9a356973 100644
--- a/src/widgets/kernel/qsizepolicy.h
+++ b/src/widgets/kernel/qsizepolicy.h
@@ -40,6 +40,9 @@ QT_BEGIN_NAMESPACE
class QVariant;
+class QSizePolicy;
+
+Q_DECL_CONST_FUNCTION inline uint qHash(QSizePolicy key, uint seed = 0) Q_DECL_NOTHROW;
class Q_WIDGETS_EXPORT QSizePolicy
{
@@ -112,6 +115,9 @@ public:
bool operator==(const QSizePolicy& s) const { return data == s.data; }
bool operator!=(const QSizePolicy& s) const { return data != s.data; }
+
+ friend Q_DECL_CONST_FUNCTION uint qHash(QSizePolicy key, uint seed) Q_DECL_NOTHROW { return qHash(key.data, seed); }
+
operator QVariant() const;
int horizontalStretch() const { return static_cast<int>(bits.horStretch); }
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 8a800ab9d0..51bf6e4684 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -37,7 +37,6 @@
#include <qapplication.h>
#include <qdesktopwidget.h>
#include <qevent.h>
-#include <qhash.h>
#include <qlabel.h>
#include <qpointer.h>
#include <qstyle.h>
diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp
index 5fb4695687..1e437c4fb7 100644
--- a/src/widgets/kernel/qwhatsthis.cpp
+++ b/src/widgets/kernel/qwhatsthis.cpp
@@ -42,7 +42,6 @@
#include "qscreen.h"
#include "qpainter.h"
#include "qtimer.h"
-#include "qhash.h"
#include "qaction.h"
#include "qcursor.h"
#include "qbitmap.h"
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index bd77e7f616..9ea5fd6018 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -37,7 +37,6 @@
#include "qcursor.h"
#include "qdesktopwidget_p.h"
#include "qevent.h"
-#include "qhash.h"
#include "qlayout.h"
#include "qmenu.h"
#include "qmetaobject.h"
@@ -100,6 +99,7 @@
#include "qwindowcontainer_p.h"
+#include <QtPlatformHeaders/qxcbwindowfunctions.h>
// widget/widget data creation count
//#define QWIDGET_EXTRA_DEBUG
@@ -704,7 +704,7 @@ void QWidget::setAutoFillBackground(bool enabled)
close().
\row \li Top-level windows \li
- \l windowModified, \l windowTitle, \l windowIcon, \l windowIconText,
+ \l windowModified, \l windowTitle, \l windowIcon,
\l isActiveWindow, activateWindow(), \l minimized, showMinimized(),
\l maximized, showMaximized(), \l fullScreen, showFullScreen(),
showNormal().
@@ -5939,7 +5939,7 @@ void QWidget::unsetLocale()
window title, if set. This is done by the QPA plugin, so it is shown to the
user, but isn't part of the windowTitle string.
- \sa windowIcon, windowIconText, windowModified, windowFilePath
+ \sa windowIcon, windowModified, windowFilePath
*/
QString QWidget::windowTitle() const
{
@@ -6034,7 +6034,11 @@ void QWidgetPrivate::setWindowIconText_helper(const QString &title)
void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
{
- Q_UNUSED(iconText);
+ Q_Q(QWidget);
+ // ### The QWidget property is deprecated, but the XCB window function is not.
+ // It should remain available for the rare application that needs it.
+ if (QWindow *window = q->windowHandle())
+ QXcbWindowFunctions::setWmWindowIconText(window, iconText);
}
/*!
@@ -6044,6 +6048,9 @@ void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
new \a iconText as an argument.
\since 5.2
+ \obsolete
+
+ This signal is deprecated.
*/
void QWidget::setWindowIconText(const QString &iconText)
@@ -6094,7 +6101,7 @@ void QWidget::setWindowTitle(const QString &title)
has been set, windowIcon() returns the application icon
(QApplication::windowIcon()).
- \sa windowIconText, windowTitle
+ \sa windowTitle
*/
QIcon QWidget::windowIcon() const
{
@@ -6110,8 +6117,15 @@ QIcon QWidget::windowIcon() const
void QWidgetPrivate::setWindowIcon_helper()
{
+ Q_Q(QWidget);
QEvent e(QEvent::WindowIconChange);
- QApplication::sendEvent(q_func(), &e);
+
+ // Do not send the event if the widget is a top level.
+ // In that case, setWindowIcon_sys does it, and event propagation from
+ // QWidgetWindow to the top level QWidget ensures that the event reaches
+ // the top level anyhow
+ if (!q->windowHandle())
+ QApplication::sendEvent(q, &e);
for (int i = 0; i < children.size(); ++i) {
QWidget *w = qobject_cast<QWidget *>(children.at(i));
if (w && !w->isWindow())
@@ -6154,10 +6168,15 @@ void QWidgetPrivate::setWindowIcon_sys()
/*!
\property QWidget::windowIconText
- \brief the widget's icon text
+ \brief the text to be displayed on the icon of a minimized window
This property only makes sense for windows. If no icon
- text has been set, this functions returns an empty string.
+ text has been set, this accessor returns an empty string.
+ It is only implemented on the X11 platform, and only certain
+ window managers use this window property.
+
+ \obsolete
+ This property is deprecated.
\sa windowIcon, windowTitle
*/
@@ -9711,6 +9730,8 @@ void QWidget::setInputMethodHints(Qt::InputMethodHints hints)
d->imHints = hints;
if (this == QGuiApplication::focusObject())
QGuiApplication::inputMethod()->update(Qt::ImHints);
+#else
+ Q_UNUSED(hints);
#endif //QT_NO_IM
}
@@ -12798,6 +12819,65 @@ void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *new
widget->setParent(static_cast<QWidget*>(newParent));
}
+#ifndef QT_NO_DEBUG_STREAM
+
+static inline void formatWidgetAttributes(QDebug debug, const QWidget *widget)
+{
+ const QMetaObject *qtMo = qt_getEnumMetaObject(Qt::WA_AttributeCount);
+ const QMetaEnum me = qtMo->enumerator(qtMo->indexOfEnumerator("WidgetAttribute"));
+ debug << ", attributes=[";
+ int count = 0;
+ for (int a = 0; a < Qt::WA_AttributeCount; ++a) {
+ if (widget->testAttribute(static_cast<Qt::WidgetAttribute>(a))) {
+ if (count++)
+ debug << ',';
+ debug << me.valueToKey(a);
+ }
+ }
+ debug << ']';
+}
+
+QDebug operator<<(QDebug debug, const QWidget *widget)
+{
+ const QDebugStateSaver saver(debug);
+ debug.nospace();
+ if (widget) {
+ debug << widget->metaObject()->className() << '(' << (void *)widget;
+ if (!widget->objectName().isEmpty())
+ debug << ", name=" << widget->objectName();
+ if (debug.verbosity() > 2) {
+ const QRect geometry = widget->geometry();
+ const QRect frameGeometry = widget->frameGeometry();
+ if (widget->isVisible())
+ debug << ", visible";
+ if (!widget->isEnabled())
+ debug << ", disabled";
+ debug << ", states=" << widget->windowState()
+ << ", type=" << widget->windowType() << ", flags=" << widget->windowFlags();
+ formatWidgetAttributes(debug, widget);
+ if (widget->isWindow())
+ debug << ", window";
+ debug << ", " << geometry.width() << 'x' << geometry.height()
+ << forcesign << geometry.x() << geometry.y() << noforcesign;
+ if (frameGeometry != geometry) {
+ const QMargins margins(geometry.x() - frameGeometry.x(),
+ geometry.y() - frameGeometry.y(),
+ frameGeometry.right() - geometry.right(),
+ frameGeometry.bottom() - geometry.bottom());
+ debug << ", margins=" << margins;
+ }
+ debug << ", devicePixelRatio=" << widget->devicePixelRatio();
+ if (const WId wid = widget->internalWinId())
+ debug << ", winId=0x" << hex << wid << dec;
+ }
+ debug << ')';
+ } else {
+ debug << "QWidget(0x0)";
+ }
+ return debug;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
QT_END_NAMESPACE
#include "moc_qwidget.cpp"
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
index c3913e9d45..782c892a32 100644
--- a/src/widgets/kernel/qwidget.h
+++ b/src/widgets/kernel/qwidget.h
@@ -89,6 +89,9 @@ class QGraphicsEffect;
class QRasterWindowSurface;
class QUnifiedToolbarSurface;
class QPixmap;
+#ifndef QT_NO_DEBUG_STREAM
+class QDebug;
+#endif
class QWidgetData
{
@@ -165,7 +168,7 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops)
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle NOTIFY windowTitleChanged DESIGNABLE isWindow)
Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon NOTIFY windowIconChanged DESIGNABLE isWindow)
- Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged DESIGNABLE isWindow)
+ Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged DESIGNABLE isWindow) // deprecated
Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow)
Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow)
#ifndef QT_NO_TOOLTIP
@@ -858,6 +861,10 @@ inline bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const
#define QWIDGETSIZE_MAX ((1<<24)-1)
+#ifndef QT_NO_DEBUG_STREAM
+Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QWidget *);
+#endif
+
QT_END_NAMESPACE
#endif // QWIDGET_H
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index ba8c16e838..01d6d89857 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -51,7 +51,6 @@ QT_BEGIN_NAMESPACE
Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets();
QWidget *qt_button_down = 0; // widget got last button-down
-static QPointer<QWidget> qt_tablet_target = 0;
// popup control
QWidget *qt_popup_down = 0; // popup that contains the pressed widget
@@ -161,7 +160,7 @@ bool QWidgetWindow::event(QEvent *event)
if (m_widget->testAttribute(Qt::WA_DontShowOnScreen)) {
// \a event is uninteresting for QWidgetWindow, the event was probably
// generated before WA_DontShowOnScreen was set
- return m_widget->event(event);
+ return QCoreApplication::sendEvent(m_widget, event);
}
switch (event->type()) {
@@ -303,7 +302,7 @@ bool QWidgetWindow::event(QEvent *event)
break;
}
- if (m_widget->event(event) && event->type() != QEvent::Timer)
+ if (QCoreApplication::sendEvent(m_widget, event) && event->type() != QEvent::Timer)
return true;
return QWindow::event(event);
@@ -446,8 +445,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (receiver != popup)
widgetPos = receiver->mapFromGlobal(event->globalPos());
QWidget *alien = m_widget->childAt(m_widget->mapFromGlobal(event->globalPos()));
- QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&e, QGuiApplicationPrivate::mouseEventSource(event));
+ QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(),
+ event->button(), event->buttons(), event->modifiers(), event->source());
e.setTimestamp(event->timestamp());
QApplicationPrivate::sendMouseEvent(receiver, &e, alien, m_widget, &qt_button_down, qt_last_mouse_receiver);
qt_last_mouse_receiver = receiver;
@@ -489,9 +488,9 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (globalGeometry.contains(event->globalPos())) {
// Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec()
const QPoint localPos = win->mapFromGlobal(event->globalPos());
- QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
+ QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(),
+ event->button(), event->buttons(), event->modifiers(), event->source());
QCoreApplicationPrivate::setEventSpontaneous(e, true);
- QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event));
e->setTimestamp(event->timestamp());
QCoreApplication::postEvent(win, e);
}
@@ -548,8 +547,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
// The preceding statement excludes MouseButtonPress events which caused
// creation of a MouseButtonDblClick event. QTBUG-25831
QMouseEvent translated(event->type(), mapped, event->windowPos(), event->screenPos(),
- event->button(), event->buttons(), event->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&translated, QGuiApplicationPrivate::mouseEventSource(event));
+ event->button(), event->buttons(), event->modifiers(), event->source());
translated.setTimestamp(event->timestamp());
QApplicationPrivate::sendMouseEvent(receiver, &translated, widget, m_widget,
&qt_button_down, qt_last_mouse_receiver);
@@ -874,6 +872,7 @@ bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long
#ifndef QT_NO_TABLETEVENT
void QWidgetWindow::handleTabletEvent(QTabletEvent *event)
{
+ static QPointer<QWidget> qt_tablet_target = 0;
if (event->type() == QEvent::TabletPress) {
QWidget *widget = m_widget->childAt(event->pos());
if (!widget)
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 6d722c680b..f87542ffa8 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -40,7 +40,6 @@
#include <qpushbutton.h>
#include <qpainter.h>
#include <qdir.h>
-#include <qhash.h>
#include <qstyleoption.h>
#include <qapplication.h>
#include <qmainwindow.h>
diff --git a/src/widgets/styles/qgtk2painter.cpp b/src/widgets/styles/qgtk2painter.cpp
index 489d456617..ea8afbc93c 100644
--- a/src/widgets/styles/qgtk2painter.cpp
+++ b/src/widgets/styles/qgtk2painter.cpp
@@ -93,6 +93,7 @@ namespace QGtk2PainterPrivate {
static void initGtk()
{
+#ifndef QT_NO_LIBRARY
static bool initialized = false;
if (!initialized) {
// enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
@@ -123,6 +124,7 @@ static void initGtk()
initialized = true;
}
+#endif // !QT_NO_LIBRARY
}
// To recover alpha we apply the gtk painting function two times to
diff --git a/src/widgets/styles/qgtkstyle_p.cpp b/src/widgets/styles/qgtkstyle_p.cpp
index 0e119a11ae..00682c1c0f 100644
--- a/src/widgets/styles/qgtkstyle_p.cpp
+++ b/src/widgets/styles/qgtkstyle_p.cpp
@@ -326,6 +326,7 @@ void QGtkStylePrivate::gtkWidgetSetFocus(GtkWidget *widget, bool focus)
*/
void QGtkStylePrivate::resolveGtk() const
{
+#ifndef QT_NO_LIBRARY
// enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
@@ -427,6 +428,7 @@ void QGtkStylePrivate::resolveGtk() const
gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve(QLS("gnomeui-2"), 0, "gnome_icon_lookup_sync");
gnome_vfs_init= (Ptr_gnome_vfs_init)QLibrary::resolve(QLS("gnomevfs-2"), 0, "gnome_vfs_init");
+#endif // !QT_NO_LIBRARY
}
/* \internal
@@ -593,11 +595,13 @@ void QGtkStylePrivate::cleanupGtkWidgets()
static bool resolveGConf()
{
+#ifndef QT_NO_LIBRARY
if (!QGtkStylePrivate::gconf_client_get_default) {
QGtkStylePrivate::gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_default");
QGtkStylePrivate::gconf_client_get_string = (Ptr_gconf_client_get_string)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_string");
QGtkStylePrivate::gconf_client_get_bool = (Ptr_gconf_client_get_bool)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_bool");
}
+#endif // !QT_NO_LIBRARY
return (QGtkStylePrivate::gconf_client_get_default !=0);
}
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index d9238dc9d5..f4686f2810 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -93,18 +93,6 @@
QT_USE_NAMESPACE
-namespace {
-class AutoReleasePool
-{
-public:
- AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
- ~AutoReleasePool() { [pool release]; }
-
-private:
- NSAutoreleasePool *pool;
-};
-}
-
@interface QT_MANGLE_NAMESPACE(NotificationReceiver) : NSObject {
QMacStylePrivate *mPrivate;
}
@@ -126,7 +114,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(NotificationReceiver);
{
Q_UNUSED(notification);
QEvent event(QEvent::StyleChange);
- QMutableSetIterator<QPointer<QObject> > it(QMacStylePrivate::scrollBars);
+ QMutableVectorIterator<QPointer<QObject> > it(QMacStylePrivate::scrollBars);
while (it.hasNext()) {
if (!it.next())
it.remove();
@@ -150,12 +138,7 @@ const int QMacStylePrivate::BevelButtonW = 50;
const int QMacStylePrivate::BevelButtonH = 22;
const int QMacStylePrivate::PushButtonContentPadding = 6;
-QSet<QPointer<QObject> > QMacStylePrivate::scrollBars;
-
-static uint qHash(const QPointer<QObject> &ptr)
-{
- return qHash(ptr.data());
-}
+QVector<QPointer<QObject> > QMacStylePrivate::scrollBars;
// Title bar gradient colors for Lion were determined by inspecting PSDs exported
// using CoreUI's CoreThemeDocument; there is no public API to retrieve them
@@ -1753,7 +1736,7 @@ QMacStylePrivate::QMacStylePrivate()
QMacStylePrivate::~QMacStylePrivate()
{
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
Q_FOREACH (NSView *b, cocoaControls)
[b release];
}
@@ -2135,7 +2118,7 @@ QMacStyle::QMacStyle()
: QCommonStyle(*new QMacStylePrivate)
{
Q_D(QMacStyle);
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
d->receiver = [[NotificationReceiver alloc] initWithPrivate:d];
NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
@@ -2152,7 +2135,7 @@ QMacStyle::QMacStyle()
QMacStyle::~QMacStyle()
{
Q_D(QMacStyle);
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
[reinterpret_cast<NSScroller*>(d->nsscroller) release];
@@ -2169,7 +2152,7 @@ QMacStyle::~QMacStyle()
*/
QPixmap QMacStylePrivate::generateBackgroundPattern() const
{
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
QPixmap px(4, 4);
QMacCGContext cg(&px);
HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationNormal);
@@ -2767,7 +2750,7 @@ QPalette QMacStyle::standardPalette() const
int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w,
QStyleHintReturn *hret) const
{
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
SInt32 ret = 0;
switch (sh) {
@@ -5379,7 +5362,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
// there is not enough space for them.
if (cc == CC_ScrollBar) {
if (opt && opt->styleObject && !QMacStylePrivate::scrollBars.contains(opt->styleObject))
- QMacStylePrivate::scrollBars.insert(QPointer<QObject>(opt->styleObject));
+ QMacStylePrivate::scrollBars.append(QPointer<QObject>(opt->styleObject));
const int scrollBarLength = (slider->orientation == Qt::Horizontal)
? slider->rect.width() : slider->rect.height();
const QMacStyle::WidgetSizePolicy sizePolicy = widgetSizePolicy(widget, opt);
diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h
index b09e81d595..33818568ec 100644
--- a/src/widgets/styles/qmacstyle_mac_p_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p_p.h
@@ -86,7 +86,7 @@
#include <qdatetimeedit.h>
#include <qmath.h>
#include <qpair.h>
-#include <qset.h>
+#include <qvector.h>
#include <QtWidgets/qgraphicsproxywidget.h>
#include <QtWidgets/qgraphicsview.h>
@@ -213,7 +213,7 @@ public:
mutable QPointer<QObject> pressedButton;
mutable QPointer<QObject> defaultButton;
mutable QPointer<QObject> autoDefaultButton;
- static QSet<QPointer<QObject> > scrollBars;
+ static QVector<QPointer<QObject> > scrollBars;
struct ButtonState {
int frame;
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index ae7accf7d0..40b8aaae9a 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -2393,6 +2393,13 @@ static bool unstylable(const QWidget *w)
return true;
}
#endif
+
+#ifndef QT_NO_TABBAR
+ if (w->metaObject() == &QWidget::staticMetaObject
+ && qobject_cast<const QTabBar*>(w->parentWidget()))
+ return true; // The moving tab of a QTabBar
+#endif
+
return false;
}
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 14af5ede39..db8a649931 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -1796,7 +1796,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
QColor left, right;
//Titlebar gradient
- if (widget && widget->isWindow()) {
+ if (opt->state & QStyle::State_Window) {
floating = true;
if (active) {
left = d->activeCaptionColor;
diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h
index f1a4a390e1..3d1206b369 100644
--- a/src/widgets/styles/qwindowsstyle_p_p.h
+++ b/src/widgets/styles/qwindowsstyle_p_p.h
@@ -50,7 +50,6 @@
#ifndef QT_NO_STYLE_WINDOWS
#include <qlist.h>
-#include <qhash.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp
index 0e598717c8..8eadc42625 100644
--- a/src/widgets/util/qflickgesture.cpp
+++ b/src/widgets/util/qflickgesture.cpp
@@ -66,8 +66,8 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
case QEvent::MouseButtonRelease:
case QEvent::MouseMove: {
QMouseEvent *me = static_cast<QMouseEvent *>(e);
- QMouseEvent *cme = new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(cme, me->source());
+ QMouseEvent *cme = new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(),
+ me->button(), me->buttons(), me->modifiers(), me->source());
return cme;
}
#ifndef QT_NO_GRAPHICSVIEW
@@ -78,8 +78,8 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
#if 1
QEvent::Type met = me->type() == QEvent::GraphicsSceneMousePress ? QEvent::MouseButtonPress :
(me->type() == QEvent::GraphicsSceneMouseRelease ? QEvent::MouseButtonRelease : QEvent::MouseMove);
- QMouseEvent *cme = new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(cme, me->source());
+ QMouseEvent *cme = new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(),
+ me->button(), me->buttons(), me->modifiers(), me->source());
return cme;
#else
QGraphicsSceneMouseEvent *copy = new QGraphicsSceneMouseEvent(me->type());
@@ -240,8 +240,7 @@ public:
qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, farFarAway,
mouseButton, QApplication::mouseButtons() & ~mouseButton,
- QApplication::keyboardModifiers());
- QGuiApplicationPrivate::setMouseEventSource(&re, mouseEventSource);
+ QApplication::keyboardModifiers(), mouseEventSource);
sendMouseEvent(&re, RegrabMouseAfterwards);
// don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release!
}
@@ -291,8 +290,7 @@ protected:
if (me) {
QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()),
mouseTarget->topLevelWidget()->mapFromGlobal(me->globalPos()), me->screenPos(),
- me->button(), me->buttons(), me->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&copy, me->source());
+ me->button(), me->buttons(), me->modifiers(), me->source());
qt_sendSpontaneousEvent(mouseTarget, &copy);
}
diff --git a/src/widgets/util/qscroller_mac.mm b/src/widgets/util/qscroller_mac.mm
index 9120c43075..07de07de52 100644
--- a/src/widgets/util/qscroller_mac.mm
+++ b/src/widgets/util/qscroller_mac.mm
@@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE
QPointF QScrollerPrivate::realDpi(int screen)
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
NSArray *nsscreens = [NSScreen screens];
if (screen < 0 || screen >= int([nsscreens count]))
@@ -59,7 +59,6 @@ QPointF QScrollerPrivate::realDpi(int screen)
} else {
return QPointF();
}
- [pool release];
}
QT_END_NAMESPACE
diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp
index 4060655d45..9a69db1bc8 100644
--- a/src/widgets/util/qsystemtrayicon_x11.cpp
+++ b/src/widgets/util/qsystemtrayicon_x11.cpp
@@ -52,6 +52,8 @@
#include <private/qguiapplication_p.h>
#include <qdebug.h>
+#include <QtPlatformHeaders/qxcbwindowfunctions.h>
+#include <QtPlatformHeaders/qxcbintegrationfunctions.h>
#ifndef QT_NO_SYSTEMTRAYICON
QT_BEGIN_NAMESPACE
@@ -112,17 +114,11 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn)
// window to ParentRelative (so that it inherits the background of its X11 parent window), call
// xcb_clear_region before painting (so that the inherited background is visible) and then grab
// the just-drawn background from the X11 server.
- bool hasAlphaChannel = false;
- QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(),
- "systrayVisualHasAlphaChannel", Qt::DirectConnection,
- Q_RETURN_ARG(bool, hasAlphaChannel));
+ bool hasAlphaChannel = QXcbIntegrationFunctions::xEmbedSystemTrayVisualHasAlphaChannel();
setAttribute(Qt::WA_TranslucentBackground, hasAlphaChannel);
if (!hasAlphaChannel) {
createWinId();
- QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(),
- "setParentRelativeBackPixmap", Qt::DirectConnection,
- Q_ARG(const QWindow *, windowHandle())
- );
+ QXcbWindowFunctions::setParentRelativeBackPixmap(windowHandle());
// XXX: This is actually required, but breaks things ("QWidget::paintEngine: Should no
// longer be called"). Why is this needed? When the widget is drawn, we use tricks to grab
@@ -143,15 +139,9 @@ bool QSystemTrayIconSys::addToTray()
createWinId();
setMouseTracking(true);
- bool requestResult = false;
- if (!QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(),
- "requestSystemTrayWindowDock", Qt::DirectConnection,
- Q_RETURN_ARG(bool, requestResult),
- Q_ARG(const QWindow *, windowHandle()))
- || !requestResult) {
- qWarning("requestSystemTrayWindowDock failed.");
+ if (!QXcbWindowFunctions::requestSystemTrayWindowDock(windowHandle()))
return false;
- }
+
if (!background.isNull())
background = QPixmap();
show();
@@ -171,15 +161,7 @@ void QSystemTrayIconSys::systemTrayWindowChanged(QScreen *)
QRect QSystemTrayIconSys::globalGeometry() const
{
- QRect result;
- if (!QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(),
- "systemTrayWindowGlobalGeometry", Qt::DirectConnection,
- Q_RETURN_ARG(QRect, result),
- Q_ARG(const QWindow *, windowHandle()))
- || !result.isValid()) {
- qWarning("systemTrayWindowGlobalGeometry failed.");
- }
- return result;
+ return QXcbWindowFunctions::systemTrayWindowGlobalGeometry(windowHandle());
}
void QSystemTrayIconSys::mousePressEvent(QMouseEvent *ev)
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp
index e413b3b87a..292bbc3325 100644
--- a/src/widgets/widgets/qabstractbutton.cpp
+++ b/src/widgets/widgets/qabstractbutton.cpp
@@ -221,13 +221,12 @@ void QButtonGroup::addButton(QAbstractButton *button, int id)
button->d_func()->group = this;
d->buttonList.append(button);
if (id == -1) {
- QList<int> ids = d->mapping.values();
- if (ids.isEmpty())
- d->mapping[button] = -2;
- else {
- std::sort(ids.begin(), ids.end());
- d->mapping[button] = ids.first()-1;
- }
+ const QHash<QAbstractButton*, int>::const_iterator it
+ = std::min_element(d->mapping.cbegin(), d->mapping.cend());
+ if (it == d->mapping.cend())
+ d->mapping[button] = -2;
+ else
+ d->mapping[button] = *it - 1;
} else {
d->mapping[button] = id;
}
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index 2e1caedde7..65d06eafc5 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -168,6 +168,10 @@ QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate()
{
}
+QAbstractScrollAreaPrivate::~QAbstractScrollAreaPrivate()
+{
+}
+
QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(Qt::Orientation orientation, QWidget *parent)
:QWidget(parent), scrollBar(new QScrollBar(orientation, this)),
layout(new QBoxLayout(orientation == Qt::Horizontal ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom)),
@@ -206,10 +210,12 @@ QWidgetList QAbstractScrollAreaScrollBarContainer::widgets(LogicalPosition posit
QWidgetList list;
const int scrollBarIndex = scrollBarLayoutIndex();
if (position == LogicalLeft) {
+ list.reserve(scrollBarIndex);
for (int i = 0; i < scrollBarIndex; ++i)
list.append(layout->itemAt(i)->widget());
} else if (position == LogicalRight) {
const int layoutItemCount = layout->count();
+ list.reserve(layoutItemCount - (scrollBarIndex + 1));
for (int i = scrollBarIndex + 1; i < layoutItemCount; ++i)
list.append(layout->itemAt(i)->widget());
}
diff --git a/src/widgets/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h
index f770bb69f8..33222573f4 100644
--- a/src/widgets/widgets/qabstractscrollarea_p.h
+++ b/src/widgets/widgets/qabstractscrollarea_p.h
@@ -54,12 +54,15 @@ QT_BEGIN_NAMESPACE
class QScrollBar;
class QAbstractScrollAreaScrollBarContainer;
+
+// ### Qt 6: is the export still needed? If not, unexport QFramePrivate, too.
class Q_WIDGETS_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate
{
Q_DECLARE_PUBLIC(QAbstractScrollArea)
public:
QAbstractScrollAreaPrivate();
+ ~QAbstractScrollAreaPrivate();
void replaceScrollBar(QScrollBar *scrollBar, Qt::Orientation orientation);
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index ba19b63c12..0ecbb8a435 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -2263,6 +2263,7 @@ void QComboBox::insertItems(int index, const QStringList &list)
// construct a QStandardItem, reducing the number of expensive signals from the model
if (QStandardItemModel *m = qobject_cast<QStandardItemModel*>(d->model)) {
QList<QStandardItem *> items;
+ items.reserve(insertCount);
QStandardItem *hiddenRoot = m->invisibleRootItem();
for (int i = 0; i < insertCount; ++i)
items.append(new QStandardItem(list.at(i)));
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
index 3fdfdcc22f..b69b94f3b9 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -57,7 +57,6 @@
#include "QtGui/qpainter.h"
#include "QtWidgets/qstyle.h"
#include "QtWidgets/qstyleoption.h"
-#include "QtCore/qhash.h"
#include "QtCore/qpair.h"
#include "QtCore/qtimer.h"
#include "private/qwidget_p.h"
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index e71b9616fc..c61984a457 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@@ -1017,7 +1018,7 @@ QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path)
index = -index - 1;
if (path.count() > 1) {
- const QDockAreaLayoutItem &item = item_list.at(index);
+ QDockAreaLayoutItem &item = item_list[index];
Q_ASSERT(item.subinfo != 0);
return item.subinfo->plug(path.mid(1));
}
@@ -1063,7 +1064,7 @@ QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path)
const int index = path.first();
if (path.count() > 1) {
- const QDockAreaLayoutItem &item = item_list.at(index);
+ QDockAreaLayoutItem &item = item_list[index];
Q_ASSERT(item.subinfo != 0);
return item.subinfo->unplug(path.mid(1));
}
@@ -1854,20 +1855,6 @@ static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos)
return Qt::NoDockWidgetArea;
}
-static QRect constrainedRect(QRect rect, const QRect &desktop)
-{
- if (desktop.isValid()) {
- rect.setWidth(qMin(rect.width(), desktop.width()));
- rect.setHeight(qMin(rect.height(), desktop.height()));
- rect.moveLeft(qMax(rect.left(), desktop.left()));
- rect.moveTop(qMax(rect.top(), desktop.top()));
- rect.moveRight(qMin(rect.right(), desktop.right()));
- rect.moveBottom(qMin(rect.bottom(), desktop.bottom()));
- }
-
- return rect;
-}
-
bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> &widgets, bool testing)
{
uchar marker;
@@ -1958,11 +1945,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*>
#endif
if (!testing) {
QRect r(x, y, w, h);
- QDesktopWidget *desktop = QApplication::desktop();
- if (desktop->isVirtualDesktop())
- r = constrainedRect(r, desktop->screenGeometry(desktop->screenNumber(r.topLeft())));
- else
- r = constrainedRect(r, desktop->screenGeometry(widget));
+ r = QDockAreaLayout::constrainedRect(r, widget);
widget->move(r.topLeft());
widget->resize(r.size());
}
@@ -2075,6 +2058,36 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const
#endif //QT_NO_TABBAR
#ifndef QT_NO_TABBAR
+/*! \internal
+ reparent all the widgets contained in this layout portion to the
+ specified parent. This is used to reparent dock widgets and tabbars
+ to the floating window or the main window
+ */
+void QDockAreaLayoutInfo::reparentWidgets(QWidget *parent)
+{
+ if (tabBar)
+ tabBar->setParent(parent);
+
+ for (int i = 0; i < item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.flags & QDockAreaLayoutItem::GapItem)
+ continue;
+ if (item.skip())
+ continue;
+ if (item.subinfo)
+ item.subinfo->reparentWidgets(parent);
+ if (item.widgetItem) {
+ QWidget *w = item.widgetItem->widget();
+ if (w->parent() != parent) {
+ bool hidden = w->isHidden();
+ w->setParent(parent);
+ if (!hidden)
+ w->show();
+ }
+ }
+ }
+}
+
//returns whether the tabbar is visible or not
bool QDockAreaLayoutInfo::updateTabBar() const
{
@@ -2198,8 +2211,10 @@ QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const
QSet<QWidget*> QDockAreaLayoutInfo::usedSeparatorWidgets() const
{
QSet<QWidget*> result;
+ const int numSeparatorWidgets = separatorWidgets.count();
+ result.reserve(numSeparatorWidgets);
- for (int i = 0; i < separatorWidgets.count(); ++i)
+ for (int i = 0; i < numSeparatorWidgets; ++i)
result << separatorWidgets.at(i);
for (int i = 0; i < item_list.count(); ++i) {
@@ -2244,6 +2259,22 @@ QRect QDockAreaLayoutInfo::tabContentRect() const
return result;
}
+
+int QDockAreaLayoutInfo::tabIndexToListIndex(int tabIndex) const
+{
+ Q_ASSERT(tabbed && tabBar);
+ quintptr data = qvariant_cast<quintptr>(tabBar->tabData(tabIndex));
+ for (int i = 0; i < item_list.count(); ++i) {
+ if (tabId(item_list.at(i)) == data)
+ return i;
+ }
+ return -1;
+}
+
+void QDockAreaLayoutInfo::moveTab(int from, int to)
+{
+ item_list.move(tabIndexToListIndex(from), tabIndexToListIndex(to));
+}
#endif // QT_NO_TABBAR
/******************************************************************************
@@ -2965,6 +2996,33 @@ QSize QDockAreaLayout::minimumSize() const
return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3));
}
+/*! \internal
+ Try to fit the given rectangle \a rect on the screen which contains
+ the window \a widget.
+ Used to compute the geometry of a dragged a dock widget that should
+ be shown with \a rect, but needs to be visible on the screen
+ */
+QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget)
+{
+ QRect desktop;
+ QDesktopWidget *desktopW = QApplication::desktop();
+ if (desktopW->isVirtualDesktop())
+ desktop = desktopW->screenGeometry(rect.topLeft());
+ else
+ desktop = desktopW->screenGeometry(widget);
+
+ if (desktop.isValid()) {
+ rect.setWidth(qMin(rect.width(), desktop.width()));
+ rect.setHeight(qMin(rect.height(), desktop.height()));
+ rect.moveLeft(qMax(rect.left(), desktop.left()));
+ rect.moveTop(qMax(rect.top(), desktop.top()));
+ rect.moveRight(qMin(rect.right(), desktop.right()));
+ rect.moveBottom(qMin(rect.bottom(), desktop.bottom()));
+ }
+
+ return rect;
+}
+
bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget)
{
QList<int> index = indexOfPlaceHolder(dockWidget->objectName());
@@ -2978,9 +3036,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget)
item.widgetItem = new QDockWidgetItem(dockWidget);
if (placeHolder->window) {
- const QRect screenGeometry =
- QApplication::desktop()->screenGeometry(placeHolder->topLevelRect.center());
- const QRect r = constrainedRect(placeHolder->topLevelRect, screenGeometry);
+ const QRect r = constrainedRect(placeHolder->topLevelRect, dockWidget);
dockWidget->d_func()->setWindowState(true, true, r);
}
dockWidget->setVisible(!placeHolder->hidden);
diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h
index 7c67466c7b..93b005f64f 100644
--- a/src/widgets/widgets/qdockarealayout_p.h
+++ b/src/widgets/widgets/qdockarealayout_p.h
@@ -202,12 +202,16 @@ public:
QTabBar *tabBar;
int tabBarShape;
+ void reparentWidgets(QWidget *p);
bool updateTabBar() const;
void setTabBarShape(int shape);
QSize tabBarMinimumSize() const;
QSize tabBarSizeHint() const;
QSet<QTabBar*> usedTabBars() const;
+
+ int tabIndexToListIndex(int) const;
+ void moveTab(int from, int to);
#endif // QT_NO_TABBAR
};
@@ -229,7 +233,8 @@ public:
bool isValid() const;
- enum { DockWidgetStateMarker = 0xfd };
+ enum { DockWidgetStateMarker = 0xfd, FloatingDockWidgetTabMarker = 0xf9 };
+ static QRect constrainedRect(QRect rect, QWidget *widget);
void saveState(QDataStream &stream) const;
bool restoreState(QDataStream &stream, const QList<QDockWidget*> &widgets, bool testing = false);
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 21b0904cc0..1b7473fbd7 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -65,6 +65,18 @@ extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); /
// qmainwindow.cpp
extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
+static inline QMainWindowLayout *qt_mainwindow_layout_from_dock(const QDockWidget *dock)
+{
+ const QWidget *p = dock->parentWidget();
+ while (p) {
+ const QMainWindow *window = qobject_cast<const QMainWindow*>(p);
+ if (window)
+ return qt_mainwindow_layout(window);
+ p = p->parentWidget();
+ }
+ return Q_NULLPTR;
+}
+
static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
{ return (priv->features & feature) == feature; }
@@ -194,25 +206,40 @@ QDockWidgetLayout::~QDockWidgetLayout()
qDeleteAll(item_list);
}
+/*! \internal
+ Returns true if the dock widget managed by this layout should have a native
+ window decoration or if Qt needs to draw it.
+ */
bool QDockWidgetLayout::nativeWindowDeco() const
{
- return nativeWindowDeco(parentWidget()->isWindow());
+ bool floating = parentWidget()->isWindow();
+ if (!floating && qobject_cast<QDockWidgetGroupWindow*>(parentWidget()->parentWidget()))
+ return wmSupportsNativeWindowDeco();
+ return nativeWindowDeco(floating);
}
-static bool isXcb()
+/*! \internal
+ Returns true if the window manager can draw natively the windows decoration
+ of a dock widget
+ */
+bool QDockWidgetLayout::wmSupportsNativeWindowDeco()
{
+#if defined(Q_OS_WINCE) || defined(Q_OS_ANDROID)
+ return false;
+#else
static const bool xcb = !QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive);
- return xcb;
+ return !xcb;
+#endif
}
+/*! \internal
+ Returns true if the dock widget managed by this layout should have a native
+ window decoration or if Qt needs to draw it. The \a floating parameter
+ overrides the floating current state of the dock widget.
+ */
bool QDockWidgetLayout::nativeWindowDeco(bool floating) const
{
-#if defined(Q_OS_WINCE) || defined(Q_OS_ANDROID)
- Q_UNUSED(floating)
- return false;
-#else
- return !isXcb() && (floating && item_list[QDockWidgetLayout::TitleBar] == 0);
-#endif
+ return wmSupportsNativeWindowDeco() && floating && item_list.at(QDockWidgetLayout::TitleBar) == 0;
}
@@ -611,7 +638,10 @@ void QDockWidget::initStyleOption(QStyleOptionDockWidget *option) const
return;
QDockWidgetLayout *dwlayout = qobject_cast<QDockWidgetLayout*>(layout());
- option->initFrom(this);
+ QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent());
+ // If we are in a floating tab, init from the parent because the attributes and the geometry
+ // of the title bar should be taken from the floating window.
+ option->initFrom(floatingTab && !isFloating() ? parentWidget() : this);
option->rect = dwlayout->titleArea();
option->title = d->fixedWindowTitle;
option->closable = hasFeature(this, QDockWidget::DockWidgetClosable);
@@ -681,14 +711,20 @@ void QDockWidgetPrivate::_q_toggleTopLevel()
q->setFloating(!q->isFloating());
}
+/*! \internal
+ Initialize the drag state structure and remember the position of the click.
+ This is called when the mouse is pressed, but the dock is not yet dragged out.
+
+ \a nca specify that the event comes from NonClientAreaMouseButtonPress
+ */
void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
{
+ Q_Q(QDockWidget);
+
if (state != 0)
return;
- QMainWindow *win = qobject_cast<QMainWindow*>(parent);
- Q_ASSERT(win != 0);
- QMainWindowLayout *layout = qt_mainwindow_layout(win);
+ QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q);
Q_ASSERT(layout != 0);
if (layout->pluggingWidget != 0) // the main window is animating a docking operation
return;
@@ -702,17 +738,23 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
state->ctrlDrag = false;
}
-void QDockWidgetPrivate::startDrag()
+/*! \internal
+ Actually start the drag and detach the dockwidget.
+ The \a group parameter is true when we should potentially drag a group of
+ tabbed widgets, and false if the dock widget should always be dragged
+ alone.
+ */
+void QDockWidgetPrivate::startDrag(bool group)
{
Q_Q(QDockWidget);
if (state == 0 || state->dragging)
return;
- QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q);
Q_ASSERT(layout != 0);
- state->widgetItem = layout->unplug(q);
+ state->widgetItem = layout->unplug(q, group);
if (state->widgetItem == 0) {
/* I have a QMainWindow parent, but I was never inserted with
QMainWindow::addDockWidget, so the QMainWindowLayout has no
@@ -728,6 +770,11 @@ void QDockWidgetPrivate::startDrag()
state->dragging = true;
}
+/*! \internal
+ Ends the drag end drop operation of the QDockWidget.
+ The \a abort parameter specifies that it ends because of programmatic state
+ reset rather than mouse release event.
+ */
void QDockWidgetPrivate::endDrag(bool abort)
{
Q_Q(QDockWidget);
@@ -736,29 +783,31 @@ void QDockWidgetPrivate::endDrag(bool abort)
q->releaseMouse();
if (state->dragging) {
- QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *mwLayout = qt_mainwindow_layout_from_dock(q);
Q_ASSERT(mwLayout != 0);
if (abort || !mwLayout->plug(state->widgetItem)) {
if (hasFeature(this, QDockWidget::DockWidgetFloatable)) {
+ // This QDockWidget will now stay in the floating state.
if (state->ownWidgetItem)
delete state->widgetItem;
mwLayout->restore();
- if (isXcb()) {
+ QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
+ if (!dwLayout->nativeWindowDeco()) {
// get rid of the X11BypassWindowManager window flag and activate the resizer
Qt::WindowFlags flags = q->windowFlags();
flags &= ~Qt::X11BypassWindowManagerHint;
q->setWindowFlags(flags);
- setResizerActive(true);
+ setResizerActive(q->isFloating());
q->show();
} else {
- QDockWidgetLayout *myLayout
- = qobject_cast<QDockWidgetLayout*>(layout);
- setResizerActive(myLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0);
+ setResizerActive(false);
}
undockedGeometry = q->geometry();
q->activateWindow();
} else {
+ // The tab was not plugged back in the QMainWindow but the QDockWidget cannot
+ // stay floating, revert to the previous state.
mwLayout->revert(state->widgetItem);
}
}
@@ -782,11 +831,7 @@ bool QDockWidgetPrivate::isAnimating() const
{
Q_Q(const QDockWidget);
- QMainWindow *mainWin = qobject_cast<QMainWindow*>(parent);
- if (mainWin == 0)
- return false;
-
- QMainWindowLayout *mainWinLayout = qt_mainwindow_layout(mainWin);
+ QMainWindowLayout *mainWinLayout = qt_mainwindow_layout_from_dock(q);
if (mainWinLayout == 0)
return false;
@@ -804,12 +849,14 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
if (!dwLayout->nativeWindowDeco()) {
QRect titleArea = dwLayout->titleArea();
+ QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent);
+
if (event->button() != Qt::LeftButton ||
!titleArea.contains(event->pos()) ||
// check if the tool window is movable... do nothing if it
// is not (but allow moving if the window is floating)
(!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) ||
- qobject_cast<QMainWindow*>(parent) == 0 ||
+ (qobject_cast<QMainWindow*>(parent) == 0 && !floatingTab) ||
isAnimating() || state != 0) {
return false;
}
@@ -853,7 +900,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
QDockWidgetLayout *dwlayout
= qobject_cast<QDockWidgetLayout *>(layout);
- QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q);
if (!dwlayout->nativeWindowDeco()) {
if (!state->dragging
&& mwlayout->pluggingWidget == 0
@@ -871,7 +918,12 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
if (state->dragging && !state->nca) {
QPoint pos = event->globalPos() - state->pressPos;
- q->move(pos);
+
+ QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent);
+ if (floatingTab && !q->isFloating())
+ floatingTab->move(pos);
+ else
+ q->move(pos);
if (state && !state->ctrlDrag)
mwlayout->hover(state->widgetItem, event->globalPos());
@@ -902,8 +954,9 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);
- QRect geo = q->geometry();
- QRect titleRect = q->frameGeometry();
+ QWidget *tl = q->topLevelWidget();
+ QRect geo = tl->geometry();
+ QRect titleRect = tl->frameGeometry();
#ifdef Q_DEAD_CODE_FROM_QT4_MAC
if ((features & QDockWidget::DockWidgetVerticalTitleBar)) {
titleRect.setTop(geo.top());
@@ -924,7 +977,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
break;
if (state != 0)
break;
- if (qobject_cast<QMainWindow*>(parent) == 0)
+ if (qobject_cast<QMainWindow*>(parent) == 0 && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0)
break;
if (isAnimating())
break;
@@ -958,11 +1011,17 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
}
}
+/*! \internal
+ Called when the QDockWidget or the QDockWidgetGroupWindow is moved
+ */
void QDockWidgetPrivate::moveEvent(QMoveEvent *event)
{
Q_Q(QDockWidget);
- if (state == 0 || !state->dragging || !state->nca || !q->isWindow())
+ if (state == 0 || !state->dragging || !state->nca)
+ return;
+
+ if (!q->isWindow() && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0)
return;
// When the native window frame is being dragged, all we get is these mouse
@@ -971,7 +1030,7 @@ void QDockWidgetPrivate::moveEvent(QMoveEvent *event)
if (state->ctrlDrag)
return;
- QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q);
Q_ASSERT(layout != 0);
QPoint globalMousePos = event->pos() + state->pressPos;
@@ -999,8 +1058,9 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
Q_Q(QDockWidget);
if (!floating && parent) {
- QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
- if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
+ QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q);
+ if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea
+ && !qobject_cast<QDockWidgetGroupWindow *>(parent))
return; // this dockwidget can't be redocked
}
@@ -1048,7 +1108,7 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
if (floating != wasFloating) {
emit q->topLevelChanged(floating);
if (!floating && parent) {
- QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q);
if (mwlayout)
emit q->dockLocationChanged(mwlayout->dockWidgetArea(q));
}
@@ -1230,8 +1290,11 @@ void QDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features)
emit featuresChanged(d->features);
update();
if (closableChanged && layout->nativeWindowDeco()) {
- //this ensures the native decoration is drawn
- d->setWindowState(true /*floating*/, true /*unplug*/);
+ QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow *>(parent());
+ if (floatingTab && !isFloating())
+ floatingTab->adjustFlags();
+ else
+ d->setWindowState(true /*floating*/, true /*unplug*/); //this ensures the native decoration is drawn
}
}
@@ -1323,11 +1386,12 @@ void QDockWidget::changeEvent(QEvent *event)
#endif
#ifndef QT_NO_TABBAR
{
- QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
- if (QMainWindowLayout *winLayout = qt_mainwindow_layout(win)) {
+ if (QMainWindowLayout *winLayout = qt_mainwindow_layout_from_dock(this)) {
if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this))
info->updateTabBar();
}
+ if (QDockWidgetGroupWindow *p = qobject_cast<QDockWidgetGroupWindow *>(parent()))
+ p->adjustFlags();
}
#endif // QT_NO_TABBAR
break;
@@ -1380,7 +1444,7 @@ bool QDockWidget::event(QEvent *event)
Q_D(QDockWidget);
QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
- QMainWindowLayout *layout = qt_mainwindow_layout(win);
+ QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(this);
switch (event->type()) {
#ifndef QT_NO_ACTION
@@ -1417,6 +1481,9 @@ bool QDockWidget::event(QEvent *event)
}
if (!isFloating() && layout != 0 && onTop)
layout->raise(this);
+ if (QDockWidgetGroupWindow *p = qobject_cast<QDockWidgetGroupWindow *>(parent()))
+ p->adjustFlags();
+
break;
}
case QEvent::WindowActivate:
diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h
index 752d6519e5..9c68bc5fb1 100644
--- a/src/widgets/widgets/qdockwidget_p.h
+++ b/src/widgets/widgets/qdockwidget_p.h
@@ -108,7 +108,7 @@ public:
void setWindowState(bool floating, bool unplug = false, const QRect &rect = QRect());
void nonClientAreaMouseEvent(QMouseEvent *event);
void initDrag(const QPoint &pos, bool nca);
- void startDrag();
+ void startDrag(bool group = true);
void endDrag(bool abort = false);
void moveEvent(QMoveEvent *event);
@@ -151,6 +151,7 @@ public:
int minimumTitleWidth() const;
int titleHeight() const;
void updateMaxSize();
+ static bool wmSupportsNativeWindowDeco();
bool nativeWindowDeco() const;
bool nativeWindowDeco(bool floating) const;
diff --git a/src/widgets/widgets/qframe.cpp b/src/widgets/widgets/qframe.cpp
index 0861ea70b5..755b03a4ca 100644
--- a/src/widgets/widgets/qframe.cpp
+++ b/src/widgets/widgets/qframe.cpp
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
QFramePrivate::QFramePrivate()
- : frect(QRect(0, 0, 0, 0)),
+ : frect(0, 0, 0, 0),
frameStyle(QFrame::NoFrame | QFrame::Plain),
lineWidth(1),
midLineWidth(0),
@@ -55,6 +55,10 @@ QFramePrivate::QFramePrivate()
{
}
+QFramePrivate::~QFramePrivate()
+{
+}
+
inline void QFramePrivate::init()
{
setLayoutItemMargins(QStyle::SE_FrameLayoutItem);
diff --git a/src/widgets/widgets/qframe_p.h b/src/widgets/widgets/qframe_p.h
index 2b80e9abbe..eb04bbed4a 100644
--- a/src/widgets/widgets/qframe_p.h
+++ b/src/widgets/widgets/qframe_p.h
@@ -50,11 +50,13 @@
QT_BEGIN_NAMESPACE
-class QFramePrivate : public QWidgetPrivate
+// ### unexport this class when and if QAbstractScrollAreaPrivate is unexported
+class Q_WIDGETS_EXPORT QFramePrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QFrame)
public:
QFramePrivate();
+ ~QFramePrivate();
void updateFrameWidth();
void updateStyledFrameWidths();
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 83e94c4128..409e4a34f9 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -53,6 +53,10 @@
QT_BEGIN_NAMESPACE
+QLabelPrivate::~QLabelPrivate()
+{
+}
+
/*!
\class QLabel
\brief The QLabel widget provides a text or image display.
diff --git a/src/widgets/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h
index 3778cb9d47..2eb4ff9fc6 100644
--- a/src/widgets/widgets/qlabel_p.h
+++ b/src/widgets/widgets/qlabel_p.h
@@ -65,6 +65,7 @@ class QLabelPrivate : public QFramePrivate
Q_DECLARE_PUBLIC(QLabel)
public:
QLabelPrivate() {}
+ ~QLabelPrivate();
void init();
void clearContents();
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 4d5d3e5ec1..935177867d 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -420,6 +420,13 @@ QMainWindow::~QMainWindow()
at the bottom. Implies AllowTabbedDocks. See also
\l setTabPosition().
+ \value GroupedDragging When dragging the titlebar of a dock, all the tabs
+ that are tabbed with it are going to be dragged.
+ Implies AllowTabbedDocks. Does not work well if
+ some QDockWidgets have restrictions in which area
+ they are allowed. (This enum value was added in Qt
+ 5.6.)
+
These options only control how dock widgets may be dropped in a QMainWindow.
They do not re-arrange the dock widgets to conform with the specified
options. For this reason they should be set before any dock widgets
@@ -1080,7 +1087,7 @@ void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget
addDockWidget(area, dockwidget, orientation);
#ifdef Q_DEAD_CODE_FROM_QT4_MAC //drawer support
- QMacCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
if (qt_mac_is_macdrawer(dockwidget)) {
extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp
diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h
index cbbea74b9b..0bd70c87a6 100644
--- a/src/widgets/widgets/qmainwindow.h
+++ b/src/widgets/widgets/qmainwindow.h
@@ -77,7 +77,8 @@ public:
AllowNestedDocks = 0x02,
AllowTabbedDocks = 0x04,
ForceTabbedDocks = 0x08, // implies AllowTabbedDocks, !AllowNestedDocks
- VerticalTabs = 0x10 // implies AllowTabbedDocks
+ VerticalTabs = 0x10, // implies AllowTabbedDocks
+ GroupedDragging = 0x20 // implies AllowTabbedDocks
};
Q_ENUM(DockOption)
Q_DECLARE_FLAGS(DockOptions, DockOption)
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 046666f571..ee76720a27 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@@ -49,6 +50,7 @@
#include <qstatusbar.h>
#include <qstring.h>
#include <qstyle.h>
+#include <qstylepainter.h>
#include <qvarlengtharray.h>
#include <qstack.h>
#include <qmap.h>
@@ -61,6 +63,7 @@
#include <private/qapplication_p.h>
#include <private/qlayoutengine_p.h>
+#include <private/qwidgetresizehandler_p.h>
#ifdef Q_DEAD_CODE_FROM_QT4_MAC
# include <private/qcore_mac_p.h>
# include <private/qt_cocoa_helpers_mac_p.h>
@@ -68,9 +71,7 @@
QT_BEGIN_NAMESPACE
-#ifdef QT_NO_DOCKWIDGET
extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
-#endif
/******************************************************************************
** debug
@@ -165,6 +166,242 @@ QDebug operator<<(QDebug debug, const QMainWindowLayout *layout)
#endif // !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_DEBUG)
/******************************************************************************
+ ** QDockWidgetGroupWindow
+ */
+// QDockWidgetGroupWindow is the floating window containing the tabbed dockwidgets in case several
+// dockwidgets are dragged together (QMainWindow::GroupedDragging feature).
+// QDockWidgetGroupLayout is the layout of that window and use a QDockAreaLayoutInfo to layout
+// the tabs inside it.
+#ifndef QT_NO_DOCKWIDGET
+class QDockWidgetGroupLayout : public QLayout {
+ QDockAreaLayoutInfo info;
+ QWidgetResizeHandler *resizer;
+public:
+ QDockWidgetGroupLayout(QWidget* parent) : QLayout(parent) {
+ setSizeConstraint(QLayout::SetMinAndMaxSize);
+ resizer = new QWidgetResizeHandler(parent);
+ resizer->setMovingEnabled(false);
+ }
+ ~QDockWidgetGroupLayout() {
+ info.deleteAllLayoutItems();
+ }
+
+ void addItem(QLayoutItem*) Q_DECL_OVERRIDE { Q_UNREACHABLE(); }
+ int count() const Q_DECL_OVERRIDE { return 0; }
+ QLayoutItem* itemAt(int index) const Q_DECL_OVERRIDE
+ {
+ int x = 0;
+ return info.itemAt(&x, index);
+ }
+ QLayoutItem* takeAt(int index) Q_DECL_OVERRIDE
+ {
+ int x = 0;
+ return info.takeAt(&x, index);
+ }
+ QSize sizeHint() const Q_DECL_OVERRIDE
+ {
+ int fw = frameWidth();
+ return info.sizeHint() + QSize(fw, fw);
+ }
+ QSize minimumSize() const Q_DECL_OVERRIDE
+ {
+ int fw = frameWidth();
+ return info.minimumSize() + QSize(fw, fw);
+ }
+ QSize maximumSize() const Q_DECL_OVERRIDE
+ {
+ int fw = frameWidth();
+ return info.maximumSize() + QSize(fw, fw);
+ }
+ void setGeometry(const QRect&r) Q_DECL_OVERRIDE
+ {
+ QDockAreaLayoutInfo *li = layoutInfo();
+ if (li->isEmpty()) {
+ static_cast<QDockWidgetGroupWindow *>(parent())->destroyIfEmpty();
+ return;
+ }
+ int fw = frameWidth();
+ li->reparentWidgets(parentWidget());
+ li->rect = r.adjusted(fw, fw, -fw, -fw);
+ li->fitItems();
+ li->apply(false);
+ resizer->setActive(QWidgetResizeHandler::Resize, !nativeWindowDeco());
+ }
+
+ QDockAreaLayoutInfo *layoutInfo() {
+ return &info;
+ }
+
+ bool nativeWindowDeco() const
+ {
+ return QDockWidgetLayout::wmSupportsNativeWindowDeco();
+ }
+
+ int frameWidth() const
+ {
+ return nativeWindowDeco() ? 0 :
+ parentWidget()->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, parentWidget());
+ }
+};
+
+// This item will be used in the layout for the gap item. We cannot use QWidgetItem directly
+// because QWidgetItem functions return an empty size for widgets are are floating.
+class QDockWidgetGroupWindowItem : public QWidgetItem
+{
+public:
+ QDockWidgetGroupWindowItem(QDockWidgetGroupWindow *parent) : QWidgetItem(parent) {}
+ QSize minimumSize() const Q_DECL_OVERRIDE { return lay()->minimumSize(); }
+ QSize maximumSize() const Q_DECL_OVERRIDE { return lay()->maximumSize(); }
+ QSize sizeHint() const Q_DECL_OVERRIDE { return lay()->sizeHint(); }
+
+private:
+ QLayout *lay() const { return const_cast<QDockWidgetGroupWindowItem *>(this)->widget()->layout(); }
+};
+
+bool QDockWidgetGroupWindow::event(QEvent *e)
+{
+ switch (e->type()) {
+ case QEvent::Close:
+ // Forward the close to the QDockWidget just as if its close button was pressed
+ if (QDockWidget *dw = topDockWidget()) {
+ e->ignore();
+ dw->close();
+ adjustFlags();
+ }
+ return true;
+ case QEvent::Move:
+ // Let QDockWidgetPrivate::moseEvent handle the dragging
+ if (QDockWidget *dw = topDockWidget())
+ static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->moveEvent(static_cast<QMoveEvent*>(e));
+ return true;
+ case QEvent::NonClientAreaMouseMove:
+ case QEvent::NonClientAreaMouseButtonPress:
+ case QEvent::NonClientAreaMouseButtonRelease:
+ case QEvent::NonClientAreaMouseButtonDblClick:
+ // Let the QDockWidgetPrivate of the currently visible dock widget handle the drag and drop
+ if (QDockWidget *dw = topDockWidget())
+ static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(e));
+ return true;
+ case QEvent::ChildAdded:
+ if (qobject_cast<QDockWidget *>(static_cast<QChildEvent*>(e)->child()))
+ adjustFlags();
+ break;
+ default:
+ break;
+ }
+ return QWidget::event(e);
+}
+
+void QDockWidgetGroupWindow::paintEvent(QPaintEvent *)
+{
+ QDockWidgetGroupLayout *lay = static_cast<QDockWidgetGroupLayout *>(layout());
+ bool nativeDeco = lay->nativeWindowDeco();
+
+ if (!nativeDeco) {
+ QStyleOptionFrame framOpt;
+ framOpt.init(this);
+ QStylePainter p(this);
+ p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt);
+ }
+}
+
+QDockAreaLayoutInfo *QDockWidgetGroupWindow::layoutInfo() const
+{
+ return static_cast<QDockWidgetGroupLayout*>(layout())->layoutInfo();
+}
+
+/*! \internal
+ Returns the currently active QDockWidget.
+ */
+QDockWidget *QDockWidgetGroupWindow::topDockWidget() const
+{
+ QDockAreaLayoutInfo *info = layoutInfo();
+ QDockWidget *dw = 0;
+ if (info->tabBar && info->tabBar->currentIndex() >= 0) {
+ int i = info->tabIndexToListIndex(info->tabBar->currentIndex());
+ if (i >= 0) {
+ const QDockAreaLayoutItem &item = info->item_list.at(i);
+ if (item.widgetItem)
+ dw = qobject_cast<QDockWidget *>(item.widgetItem->widget());
+ }
+ }
+ if (!dw) {
+ for (int i = 0; !dw && i < info->item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = info->item_list.at(i);
+ if (item.skip())
+ continue;
+ if (!item.widgetItem)
+ continue;
+ dw = qobject_cast<QDockWidget *>(item.widgetItem->widget());
+ }
+ }
+ return dw;
+}
+
+/*! \internal
+ Destroy this window if there is no more QDockWidget in it.
+ */
+void QDockWidgetGroupWindow::destroyIfEmpty()
+{
+ if (layoutInfo()->isEmpty()) {
+ // Make sure to reparent the possibly floating or hidden QDockWidgets to the parent
+ foreach (QDockWidget *dw,
+ findChildren<QDockWidget *>(QString(), Qt::FindDirectChildrenOnly)) {
+ bool wasFloating = dw->isFloating();
+ bool wasHidden = dw->isHidden();
+ dw->setParent(parentWidget());
+ if (wasFloating) {
+ dw->setFloating(true);
+ } else {
+ // maybe it was hidden, we still have to put it back in the main layout.
+ QMainWindowLayout *ml = qt_mainwindow_layout(static_cast<QMainWindow*>(parentWidget()));
+ Qt::DockWidgetArea area = ml->dockWidgetArea(this);
+ if (area == Qt::NoDockWidgetArea)
+ area = Qt::LeftDockWidgetArea;
+ static_cast<QMainWindow*>(parentWidget())->addDockWidget(area, dw);
+ }
+ if (!wasHidden)
+ dw->show();
+ }
+ foreach (QTabBar *tb, findChildren<QTabBar *>(QString(), Qt::FindDirectChildrenOnly))
+ tb->setParent(parentWidget());
+ deleteLater();
+ }
+}
+
+/*! \internal
+ Sets the flags of this window in accordence to the capabilities of the dock widgets
+ */
+void QDockWidgetGroupWindow::adjustFlags()
+{
+ QDockWidget *top = topDockWidget();
+ if (!top)
+ return;
+ const bool nativeDeco = static_cast<QDockWidgetGroupLayout *>(layout())->nativeWindowDeco();
+
+ Qt::WindowFlags oldFlags = windowFlags();
+ Qt::WindowFlags flags = oldFlags;
+ if (nativeDeco) {
+ flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
+ if (top->features() & QDockWidget::DockWidgetClosable)
+ flags |= Qt::WindowCloseButtonHint;
+ else
+ flags &= ~Qt::WindowCloseButtonHint;
+ flags &= ~Qt::FramelessWindowHint;
+ } else {
+ flags |= Qt::FramelessWindowHint;
+ }
+ if (oldFlags != flags) {
+ setWindowFlags(flags);
+ show(); // setWindowFlags hides the window
+ }
+
+ setWindowTitle(top->windowTitle());
+ setWindowIcon(top->windowIcon());
+}
+#endif
+
+/******************************************************************************
** QMainWindowLayoutState
*/
@@ -335,8 +572,8 @@ QList<int> QMainWindowLayoutState::indexOf(QWidget *widget) const
#ifndef QT_NO_DOCKWIDGET
// is it a dock widget?
- if (QDockWidget *dockWidget = qobject_cast<QDockWidget *>(widget)) {
- result = dockAreaLayout.indexOf(dockWidget);
+ if (qobject_cast<QDockWidget *>(widget) || qobject_cast<QDockWidgetGroupWindow *>(widget)) {
+ result = dockAreaLayout.indexOf(widget);
if (!result.isEmpty())
result.prepend(1);
return result;
@@ -413,7 +650,8 @@ QList<int> QMainWindowLayoutState::gapIndex(QWidget *widget,
#ifndef QT_NO_DOCKWIDGET
// is it a dock widget?
- if (qobject_cast<QDockWidget *>(widget) != 0) {
+ if (qobject_cast<QDockWidget *>(widget) != 0
+ || qobject_cast<QDockWidgetGroupWindow *>(widget)) {
result = dockAreaLayout.gapIndex(pos);
if (!result.isEmpty())
result.prepend(1);
@@ -440,7 +678,7 @@ bool QMainWindowLayoutState::insertGap(const QList<int> &path, QLayoutItem *item
#ifndef QT_NO_DOCKWIDGET
if (i == 1) {
- Q_ASSERT(qobject_cast<QDockWidget*>(item->widget()) != 0);
+ Q_ASSERT(qobject_cast<QDockWidget*>(item->widget()) || qobject_cast<QDockWidgetGroupWindow*>(item->widget()));
return dockAreaLayout.insertGap(path.mid(1), item);
}
#endif //QT_NO_DOCKWIDGET
@@ -593,6 +831,17 @@ void QMainWindowLayoutState::saveState(QDataStream &stream) const
{
#ifndef QT_NO_DOCKWIDGET
dockAreaLayout.saveState(stream);
+#ifndef QT_NO_TABBAR
+ QList<QDockWidgetGroupWindow *> floatingTabs =
+ mainWindow->findChildren<QDockWidgetGroupWindow *>(QString(), Qt::FindDirectChildrenOnly);
+
+ foreach (QDockWidgetGroupWindow *floating, floatingTabs) {
+ if (floating->layoutInfo()->isEmpty())
+ continue;
+ stream << uchar(QDockAreaLayout::FloatingDockWidgetTabMarker) << floating->geometry();
+ floating->layoutInfo()->saveState(stream);
+ }
+#endif
#endif
#ifndef QT_NO_TOOLBAR
toolBarAreaLayout.saveState(stream);
@@ -638,12 +887,28 @@ bool QMainWindowLayoutState::checkFormat(QDataStream &stream)
case QDockAreaLayout::DockWidgetStateMarker:
{
QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
+ foreach (QDockWidgetGroupWindow *floating, findChildrenHelper<QDockWidgetGroupWindow*>(mainWindow))
+ dockWidgets += findChildrenHelper<QDockWidget*>(floating);
if (!dockAreaLayout.restoreState(stream, dockWidgets, true /*testing*/)) {
return false;
}
}
break;
-#endif
+#ifndef QT_NO_TABBAR
+ case QDockAreaLayout::FloatingDockWidgetTabMarker:
+ {
+ QRect geom;
+ stream >> geom;
+ QDockAreaLayoutInfo info;
+ QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
+ foreach (QDockWidgetGroupWindow *floating, findChildrenHelper<QDockWidgetGroupWindow*>(mainWindow))
+ dockWidgets += findChildrenHelper<QDockWidget*>(floating);
+ if (!info.restoreState(stream, dockWidgets, true /* testing*/))
+ return false;
+ }
+ break;
+#endif // QT_NO_TABBAR
+#endif // QT_NO_DOCKWIDGET
default:
//there was an error during the parsing
return false;
@@ -682,6 +947,8 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
case QDockAreaLayout::DockWidgetStateMarker:
{
QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
+ foreach (QDockWidgetGroupWindow *floating, findChildrenHelper<QDockWidgetGroupWindow*>(mainWindow))
+ dockWidgets += findChildrenHelper<QDockWidget*>(floating);
if (!dockAreaLayout.restoreState(stream, dockWidgets))
return false;
@@ -702,6 +969,26 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
}
}
break;
+#ifndef QT_NO_TABBAR
+ case QDockAreaLayout::FloatingDockWidgetTabMarker:
+ {
+ QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
+ foreach (QDockWidgetGroupWindow *floating, findChildrenHelper<QDockWidgetGroupWindow*>(mainWindow))
+ dockWidgets += findChildrenHelper<QDockWidget*>(floating);
+ QDockWidgetGroupWindow* floatingTab = qt_mainwindow_layout(mainWindow)->createTabbedDockWindow();
+ *floatingTab->layoutInfo() = QDockAreaLayoutInfo(&dockAreaLayout.sep, QInternal::LeftDock,
+ Qt::Horizontal, QTabBar::RoundedSouth, mainWindow);
+ QRect geometry;
+ stream >> geometry;
+ if (!floatingTab->layoutInfo()->restoreState(stream, dockWidgets, false))
+ return false;
+ geometry = QDockAreaLayout::constrainedRect(geometry, floatingTab);
+ floatingTab->move(geometry.topLeft());
+ floatingTab->resize(geometry.size());
+ floatingTab->show();
+ }
+ break;
+#endif // QT_NO_TABBAR
#endif // QT_NO_DOCKWIDGET
#ifndef QT_NO_TOOLBAR
@@ -1223,7 +1510,7 @@ void QMainWindowLayout::splitDockWidget(QDockWidget *after,
invalidate();
}
-Qt::DockWidgetArea QMainWindowLayout::dockWidgetArea(QDockWidget *widget) const
+Qt::DockWidgetArea QMainWindowLayout::dockWidgetArea(QWidget *widget) const
{
QList<int> pathToWidget = layoutState.dockAreaLayout.indexOf(widget);
if (pathToWidget.isEmpty())
@@ -1238,20 +1525,88 @@ void QMainWindowLayout::keepSize(QDockWidget *w)
#ifndef QT_NO_TABBAR
+// Handle custom tooltip, and allow to drag tabs away.
class QMainWindowTabBar : public QTabBar
{
+ QMainWindow *mainWindow;
+ QDockWidget *draggingDock; // Currently dragging (detached) dock widget
public:
- QMainWindowTabBar(QWidget *parent);
+ QMainWindowTabBar(QMainWindow *parent);
protected:
bool event(QEvent *e) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE;
+
};
-QMainWindowTabBar::QMainWindowTabBar(QWidget *parent)
- : QTabBar(parent)
+QMainWindowTabBar::QMainWindowTabBar(QMainWindow *parent)
+ : QTabBar(parent), mainWindow(parent), draggingDock(0)
{
setExpanding(false);
}
+void QMainWindowTabBar::mouseMoveEvent(QMouseEvent *e)
+{
+ // The QTabBar handles the moving (reordering) of tabs.
+ // When QTabBarPrivate::dragInProgress is true, and that the mouse is outside of a region
+ // around the QTabBar, we will consider the user wants to drag that QDockWidget away from this
+ // tab area.
+
+ QTabBarPrivate *d = static_cast<QTabBarPrivate*>(d_ptr.data());
+ if (!draggingDock && (mainWindow->dockOptions() & QMainWindow::GroupedDragging)) {
+ int offset = QApplication::startDragDistance() + 1;
+ offset *= 3;
+ QRect r = rect().adjusted(-offset, -offset, offset, offset);
+ if (d->dragInProgress && !r.contains(e->pos()) && d->validIndex(d->pressedIndex)) {
+ QMainWindowLayout* mlayout = qt_mainwindow_layout(mainWindow);
+ QDockAreaLayoutInfo *info = mlayout->dockInfo(this);
+ Q_ASSERT(info);
+ int idx = info->tabIndexToListIndex(d->pressedIndex);
+ const QDockAreaLayoutItem &item = info->item_list.at(idx);
+ if (item.widgetItem
+ && (draggingDock = qobject_cast<QDockWidget *>(item.widgetItem->widget()))) {
+ // We should drag this QDockWidget away by unpluging it.
+ // First cancel the QTabBar's internal move
+ d->moveTabFinished(d->pressedIndex);
+ d->pressedIndex = -1;
+ if (d->movingTab)
+ d->movingTab->setVisible(false);
+ d->dragStartPosition = QPoint();
+
+ // Then starts the drag using QDockWidgetPrivate's API
+ QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));
+ QDockWidgetLayout *dwlayout = static_cast<QDockWidgetLayout *>(draggingDock->layout());
+ dockPriv->initDrag(dwlayout->titleArea().center(), true);
+ dockPriv->startDrag(false);
+ if (dockPriv->state)
+ dockPriv->state->ctrlDrag = e->modifiers() & Qt::ControlModifier;
+ }
+ }
+ }
+
+ if (draggingDock) {
+ QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));
+ if (dockPriv->state && dockPriv->state->dragging) {
+ QPoint pos = e->globalPos() - dockPriv->state->pressPos;
+ draggingDock->move(pos);
+ // move will call QMainWindowLayout::hover
+ }
+ }
+ QTabBar::mouseMoveEvent(e);
+}
+
+void QMainWindowTabBar::mouseReleaseEvent(QMouseEvent *e)
+{
+ if (draggingDock && e->button() == Qt::LeftButton) {
+ QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));
+ if (dockPriv->state && dockPriv->state->dragging) {
+ dockPriv->endDrag();
+ }
+ draggingDock = 0;
+ }
+ QTabBar::mouseReleaseEvent(e);
+}
+
bool QMainWindowTabBar::event(QEvent *e)
{
// show the tooltip if tab is too small to fit label
@@ -1276,11 +1631,13 @@ QTabBar *QMainWindowLayout::getTabBar()
if (!unusedTabBars.isEmpty()) {
result = unusedTabBars.takeLast();
} else {
- result = new QMainWindowTabBar(parentWidget());
+ result = new QMainWindowTabBar(static_cast<QMainWindow *>(parentWidget()));
result->setDrawBase(true);
result->setElideMode(Qt::ElideRight);
result->setDocumentMode(_documentMode);
+ result->setMovable(true);
connect(result, SIGNAL(currentChanged(int)), this, SLOT(tabChanged()));
+ connect(result, &QTabBar::tabMoved, this, &QMainWindowLayout::tabMoved);
}
usedTabBars.insert(result);
@@ -1303,12 +1660,30 @@ QWidget *QMainWindowLayout::getSeparatorWidget()
return result;
}
+/*! \internal
+ Returns a pointer QDockAreaLayoutInfo which contains this \a widget directly
+ (in its internal list)
+ */
+QDockAreaLayoutInfo *QMainWindowLayout::dockInfo(QWidget *widget)
+{
+ QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(widget);
+ if (info)
+ return info;
+ foreach (QDockWidgetGroupWindow *dwgw,
+ parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) {
+ info = dwgw->layoutInfo()->info(widget);
+ if (info)
+ return info;
+ }
+ return 0;
+}
+
void QMainWindowLayout::tabChanged()
{
QTabBar *tb = qobject_cast<QTabBar*>(sender());
if (tb == 0)
return;
- QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(tb);
+ QDockAreaLayoutInfo *info = dockInfo(tb);
if (info == 0)
return;
info->apply(false);
@@ -1316,6 +1691,16 @@ void QMainWindowLayout::tabChanged()
if (QWidget *w = centralWidget())
w->raise();
}
+
+void QMainWindowLayout::tabMoved(int from, int to)
+{
+ QTabBar *tb = qobject_cast<QTabBar*>(sender());
+ Q_ASSERT(tb);
+ QDockAreaLayoutInfo *info = dockInfo(tb);
+ Q_ASSERT(info);
+
+ info->moveTab(from, to);
+}
#endif // QT_NO_TABBAR
bool QMainWindowLayout::startSeparatorMove(const QPoint &pos)
@@ -1353,7 +1738,7 @@ bool QMainWindowLayout::endSeparatorMove(const QPoint&)
void QMainWindowLayout::raise(QDockWidget *widget)
{
- QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(widget);
+ QDockAreaLayoutInfo *info = dockInfo(widget);
if (info == 0)
return;
#ifndef QT_NO_TABBAR
@@ -1537,6 +1922,8 @@ void QMainWindowLayout::revert(QLayoutItem *widgetItem)
QWidget *widget = widgetItem->widget();
layoutState = savedState;
currentGapPos = layoutState.indexOf(widget);
+ if (currentGapPos.isEmpty())
+ return;
fixToolBarOrientation(widgetItem, currentGapPos.at(1));
layoutState.unplug(currentGapPos);
layoutState.fitLayout();
@@ -1601,6 +1988,42 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
if (widget == pluggingWidget) {
#ifndef QT_NO_DOCKWIDGET
+ if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(widget)) {
+ // When the animated widget was a QDockWidgetGroupWindow, it means each of the
+ // embedded QDockWidget needs to be plugged back into the QMainWindow layout.
+ savedState.clear();
+ QDockAreaLayoutInfo* info = dwgw->layoutInfo();
+ QList<int> path = layoutState.dockAreaLayout.indexOf(widget);
+ Q_ASSERT(path.size() >= 2);
+
+ QDockAreaLayoutInfo* parentInfo = layoutState.dockAreaLayout.info(path);
+ Q_ASSERT(parentInfo);
+ if (parentInfo->tabbed) {
+ // merge the two tab widgets
+ int idx = path.last();
+ Q_ASSERT(parentInfo->item_list[idx].widgetItem->widget() == dwgw);
+ delete parentInfo->item_list[idx].widgetItem;
+ parentInfo->item_list.removeAt(idx);
+ std::copy(info->item_list.cbegin(), info->item_list.cend(),
+ std::inserter(parentInfo->item_list, parentInfo->item_list.begin() + idx));
+ quintptr currentId = info->currentTabId();
+ *info = QDockAreaLayoutInfo();
+ parentInfo->reparentWidgets(parentWidget());
+ parentInfo->updateTabBar();
+ parentInfo->setCurrentTabId(currentId);
+ } else {
+ QDockAreaLayoutItem &item = layoutState.dockAreaLayout.item(path);
+ Q_ASSERT(item.widgetItem->widget() == dwgw);
+ delete item.widgetItem;
+ item.widgetItem = 0;
+ item.subinfo = new QDockAreaLayoutInfo(qMove(*info));
+ *info = QDockAreaLayoutInfo();
+ item.subinfo->reparentWidgets(parentWidget());
+ item.subinfo->setTabBarShape(parentInfo->tabBarShape);
+ }
+ dwgw->destroyIfEmpty();
+ }
+
if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget))
dw->d_func()->plug(currentGapRect);
#endif
@@ -1621,7 +2044,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
if (qobject_cast<QDockWidget*>(widget) != 0) {
// info() might return null if the widget is destroyed while
// animating but before the animationFinished signal is received.
- if (QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(widget))
+ if (QDockAreaLayoutInfo *info = dockInfo(widget))
info->setCurrentTab(widget);
}
#endif
@@ -1765,8 +2188,33 @@ void QMainWindowLayout::setCentralWidget(QWidget *widget)
invalidate();
}
-QLayoutItem *QMainWindowLayout::unplug(QWidget *widget)
-{
+/*! \internal
+ Unplug \a widget (QDockWidget or QToolBar) from it's parent container.
+
+ If \a group is true we might actually unplug the group of tabs this
+ widget is part if QMainWindow::GroupedDragging is set. When \a group
+ is false, the widget itself is always unplugged alone
+
+ Returns the QLayoutItem of the dragged element.
+ The layout item is kept in the layout but set as a gap item.
+ */
+QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group)
+{
+#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_TABBAR)
+ QDockWidgetGroupWindow *floatingParent = qobject_cast<QDockWidgetGroupWindow *>(widget->parentWidget());
+ if (group && floatingParent && !widget->isWindow()) {
+ // We are just dragging a floating window as it, not need to do anything, we just have to
+ // look up the corresponding QWidgetItem* if it exists
+ QList<int> tabbedWindowPath = layoutState.indexOf(widget->parentWidget());
+ return tabbedWindowPath.isEmpty() ? 0 : layoutState.item(tabbedWindowPath);
+ } else if (floatingParent) {
+ // We are unplugging a dock widget from a floating window.
+ if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
+ dw->d_func()->unplug(widget->geometry());
+ return 0;
+ }
+ }
+#endif
QList<int> path = layoutState.indexOf(widget);
if (path.isEmpty())
return 0;
@@ -1780,9 +2228,35 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget)
#ifndef QT_NO_DOCKWIDGET
if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
- dw->d_func()->unplug(r);
+ Q_ASSERT(path.first() == 1);
+ bool actualGroup = false;
+#ifndef QT_NO_TABBAR
+ if (group && (dockOptions & QMainWindow::GroupedDragging) && path.size() > 3) {
+ QDockAreaLayoutItem &parentItem = layoutState.dockAreaLayout.item(path.mid(1, path.size() - 2));
+ if (parentItem.subinfo && parentItem.subinfo->tabbed) {
+ // The QDockWidget is part of a group of tab and we need to unplug them all.
+ actualGroup = true;
+ path.removeLast();
+
+ QDockWidgetGroupWindow* floatingTabs = createTabbedDockWindow();
+ QDockAreaLayoutInfo* info = floatingTabs->layoutInfo();
+ *info = qMove(*parentItem.subinfo);
+ delete parentItem.subinfo;
+ parentItem.subinfo = 0;
+ floatingTabs->setGeometry(info->rect.translated(parentWidget()->pos()));
+ floatingTabs->show();
+ floatingTabs->raise();
+ item = new QDockWidgetGroupWindowItem(floatingTabs);
+ parentItem.widgetItem = item;
+ savedState = layoutState;
+ }
+ }
+#endif // QT_NO_TABBAR
+ if (!actualGroup) {
+ dw->d_func()->unplug(r);
+ }
}
-#endif
+#endif // QT_NO_DOCKWIDGET
#ifndef QT_NO_TOOLBAR
if (QToolBar *tb = qobject_cast<QToolBar*>(widget)) {
tb->d_func()->unplug(r);
@@ -1829,6 +2303,9 @@ QList<int> QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mouse
#ifndef QT_NO_DOCKWIDGET
if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget))
allowed = dw->isAreaAllowed(toDockWidgetArea(path.at(1)));
+
+ if (qobject_cast<QDockWidgetGroupWindow *>(widget))
+ allowed = true;
#endif
#ifndef QT_NO_TOOLBAR
if (QToolBar *tb = qobject_cast<QToolBar*>(widget))
@@ -1881,11 +2358,23 @@ QList<int> QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mouse
return path;
}
+QDockWidgetGroupWindow *QMainWindowLayout::createTabbedDockWindow()
+{
+ QDockWidgetGroupWindow* f = new QDockWidgetGroupWindow(parentWidget(), Qt::Tool);
+ new QDockWidgetGroupLayout(f);
+ return f;
+}
+
void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animate)
{
#ifndef QT_NO_DOCKWIDGET
#ifndef QT_NO_TABBAR
QSet<QTabBar*> used = newState.dockAreaLayout.usedTabBars();
+ foreach (QDockWidgetGroupWindow *dwgw,
+ parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) {
+ used += dwgw->layoutInfo()->usedTabBars();
+ }
+
QSet<QTabBar*> retired = usedTabBars - used;
usedTabBars = used;
foreach (QTabBar *tab_bar, retired) {
@@ -1904,6 +2393,8 @@ void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animat
}
}
+ for (int i = 0; i < QInternal::DockCount; ++i)
+ newState.dockAreaLayout.docks[i].reparentWidgets(parentWidget());
#endif // QT_NO_TABBAR
#endif // QT_NO_DOCKWIDGET
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
index 9f84ee95db..9155c5fb23 100644
--- a/src/widgets/widgets/qmainwindowlayout_p.h
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -77,6 +77,23 @@ QT_BEGIN_NAMESPACE
class QToolBar;
class QRubberBand;
+#ifndef QT_NO_DOCKWIDGET
+class QDockWidgetGroupWindow : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit QDockWidgetGroupWindow(QWidget* parent = 0, Qt::WindowFlags f = 0)
+ : QWidget(parent, f) {}
+ QDockAreaLayoutInfo *layoutInfo() const;
+ QDockWidget *topDockWidget() const;
+ void destroyIfEmpty();
+ void adjustFlags();
+protected:
+ bool event(QEvent *) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
+};
+#endif
+
/* This data structure represents the state of all the tool-bars and dock-widgets. It's value based
so it can be easilly copied into a temporary variable. All operations are performed without moving
any widgets. Only when we are sure we have the desired state, we call apply(), which moves the
@@ -196,10 +213,11 @@ public:
QDockWidget *dockwidget,
Qt::Orientation orientation);
void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
- Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const;
+ Qt::DockWidgetArea dockWidgetArea(QWidget* widget) const;
void raise(QDockWidget *widget);
void setVerticalTabsEnabled(bool enabled);
bool restoreDockWidget(QDockWidget *dockwidget);
+ QDockAreaLayoutInfo *dockInfo(QWidget *w);
#ifndef QT_NO_TABBAR
bool _documentMode;
@@ -224,6 +242,8 @@ public:
void setTabShape(QTabWidget::TabShape tabShape);
QTabWidget::TabPosition tabPosition(Qt::DockWidgetArea area) const;
void setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition);
+
+ QDockWidgetGroupWindow *createTabbedDockWindow();
#endif // QT_NO_TABWIDGET
#endif // QT_NO_TABBAR
@@ -273,7 +293,7 @@ public:
QList<int> hover(QLayoutItem *widgetItem, const QPoint &mousePos);
bool plug(QLayoutItem *widgetItem);
- QLayoutItem *unplug(QWidget *widget);
+ QLayoutItem *unplug(QWidget *widget, bool group = false);
void revert(QLayoutItem *widgetItem);
void updateGapIndicator();
void paintDropIndicator(QPainter *p, QWidget *widget, const QRegion &clip);
@@ -286,6 +306,7 @@ private Q_SLOTS:
#ifndef QT_NO_DOCKWIDGET
#ifndef QT_NO_TABBAR
void tabChanged();
+ void tabMoved(int from, int to);
#endif
#endif
private:
diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h
index 7f28879f8d..f6bdf61492 100644
--- a/src/widgets/widgets/qmdiarea_p.h
+++ b/src/widgets/widgets/qmdiarea_p.h
@@ -142,8 +142,8 @@ public:
#endif
QMdiAreaTabBar *tabBar;
QList<QMdi::Rearranger *> pendingRearrangements;
- QList< QPointer<QMdiSubWindow> > pendingPlacements;
- QList< QPointer<QMdiSubWindow> > childWindows;
+ QVector< QPointer<QMdiSubWindow> > pendingPlacements;
+ QVector< QPointer<QMdiSubWindow> > childWindows;
QList<int> indicesToActivatedChildren;
QPointer<QMdiSubWindow> active;
QPointer<QMdiSubWindow> aboutToBecomeActive;
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index 1808030639..c3b31ea5a4 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -1091,8 +1091,8 @@ void QMdiSubWindowPrivate::updateDirtyRegions()
if (!parent)
return;
- foreach (Operation operation, operationMap.keys())
- operationMap.find(operation).value().region = getRegion(operation);
+ for (OperationInfoMap::iterator it = operationMap.begin(), end = operationMap.end(); it != end; ++it)
+ it.value().region = getRegion(it.key());
}
/*!
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index e81359feac..3148b140bc 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -1110,8 +1110,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
handleEnterLeaveEvents(&previousMouseMenu,qobject_cast<QMenu *>(caused));
if(e->type() != QEvent::MouseButtonRelease || mouseDown == caused) {
QMouseEvent new_e(e->type(), cpos, caused->mapTo(caused->topLevelWidget(), cpos), e->screenPos(),
- e->button(), e->buttons(), e->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&new_e, e->source());
+ e->button(), e->buttons(), e->modifiers(), e->source());
QApplication::sendEvent(caused, &new_e);
return true;
}
@@ -1572,6 +1571,100 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
return action;
}
+/*!\fn 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 QAction *QMenu::addAction(const QString &text, Functor functor, 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 functor. 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 QAction *QMenu::addAction(const QString &text, const QObject *context, Functor functor, 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 functor. The function adds the newly created
+ action to the menu's list of actions and returns it.
+
+ If \a context is destroyed, the functor will not be called.
+
+ QMenu takes ownership of the returned QAction.
+*/
+
+/*!\fn 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.
+
+ QMenu takes ownership of the returned QAction.
+*/
+
+/*!\fn QAction *QMenu::addAction(const QIcon &icon, const QString &text, Functor functor, 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 functor. 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 QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, 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 functor. The function adds the newly created
+ action to the menu's list of actions and returns it.
+
+ If \a context is destroyed, the functor will not be called.
+
+ QMenu takes ownership of the returned QAction.
+*/
+
/*!
\overload
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h
index 5dda8b2370..21e1432d2a 100644
--- a/src/widgets/widgets/qmenu.h
+++ b/src/widgets/widgets/qmenu.h
@@ -78,6 +78,72 @@ public:
QAction *addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
+#ifdef Q_QDOC
+ QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0);
+ QAction *addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0);
+ QAction *addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0);
+ QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0);
+ QAction *addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0);
+ QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0);
+#else
+ // addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
+ template<class Obj, typename Func1>
+ inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
+ addAction(const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
+ {
+ QAction *result = addAction(text);
+#ifdef QT_NO_SHORTCUT
+ Q_UNUSED(shortcut)
+#else
+ result->setShortcut(shortcut);
+#endif
+ connect(result, &QAction::triggered, object, slot);
+ return result;
+ }
+ // addAction(QString): Connect to a functor or function pointer (without context)
+ template <typename Func1>
+ inline QAction *addAction(const QString &text, Func1 slot, const QKeySequence &shortcut = 0)
+ {
+ QAction *result = addAction(text);
+#ifdef QT_NO_SHORTCUT
+ Q_UNUSED(shortcut)
+#else
+ result->setShortcut(shortcut);
+#endif
+ connect(result, &QAction::triggered, slot);
+ return result;
+ }
+ // addAction(QIcon, QString): Connect to a QObject slot / functor or function pointer (with context)
+ template<class Obj, typename Func1>
+ inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
+ addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
+ {
+ QAction *result = addAction(actionIcon, text);
+#ifdef QT_NO_SHORTCUT
+ Q_UNUSED(shortcut)
+#else
+ result->setShortcut(shortcut);
+#endif
+ connect(result, &QAction::triggered, object, slot);
+ return result;
+ }
+ // addAction(QIcon, QString): Connect to a functor or function pointer (without context)
+ template <typename Func1>
+ inline QAction *addAction(const QIcon &actionIcon, const QString &text, Func1 slot, const QKeySequence &shortcut = 0)
+ {
+ QAction *result = addAction(actionIcon, text);
+#ifdef QT_NO_SHORTCUT
+ Q_UNUSED(shortcut)
+#else
+ result->setShortcut(shortcut);
+#endif
+ connect(result, &QAction::triggered, slot);
+ return result;
+ }
+#endif // !Q_QDOC
+
QAction *addMenu(QMenu *menu);
QMenu *addMenu(const QString &title);
QMenu *addMenu(const QIcon &icon, const QString &title);
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 1ad99bed9c..9e76ff082c 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -195,7 +195,9 @@ void QMenuBarPrivate::updateGeometries()
for(int j = 0; j < shortcutIndexMap.size(); ++j)
q->releaseShortcut(shortcutIndexMap.value(j));
shortcutIndexMap.resize(0); // faster than clear
- for(int i = 0; i < actions.count(); i++)
+ const int actionsCount = actions.count();
+ shortcutIndexMap.reserve(actionsCount);
+ for (int i = 0; i < actionsCount; i++)
shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text())));
}
#endif
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index de6e45234c..c2081c15f8 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -58,6 +58,10 @@ QT_BEGIN_NAMESPACE
//#define QSPLITTER_DEBUG
+QSplitterPrivate::~QSplitterPrivate()
+{
+}
+
/*!
\class QSplitterHandle
\brief The QSplitterHandle class provides handle functionality for the splitter.
@@ -1498,8 +1502,11 @@ QList<int> QSplitter::sizes() const
Q_D(const QSplitter);
ensurePolished();
+ const int numSizes = d->list.size();
QList<int> list;
- for (int i = 0; i < d->list.size(); ++i) {
+ list.reserve(numSizes);
+
+ for (int i = 0; i < numSizes; ++i) {
QSplitterLayoutStruct *s = d->list.at(i);
list.append(d->pick(s->rect.size()));
}
@@ -1594,8 +1601,10 @@ QByteArray QSplitter::saveState() const
stream << qint32(SplitterMagic);
stream << qint32(version);
+ const int numSizes = d->list.size();
QList<int> list;
- for (int i = 0; i < d->list.size(); ++i) {
+ list.reserve(numSizes);
+ for (int i = 0; i < numSizes; ++i) {
QSplitterLayoutStruct *s = d->list.at(i);
list.append(s->sizer);
}
diff --git a/src/widgets/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h
index a45f776da1..890bd535ec 100644
--- a/src/widgets/widgets/qsplitter_p.h
+++ b/src/widgets/widgets/qsplitter_p.h
@@ -76,6 +76,7 @@ class QSplitterPrivate : public QFramePrivate
public:
QSplitterPrivate() : rubberBand(0), opaque(true), firstShow(true),
childrenCollapsible(true), compatMode(false), handleWidth(-1), blockChildAdd(false), opaqueResizeSet(false) {}
+ ~QSplitterPrivate();
QPointer<QRubberBand> rubberBand;
mutable QList<QSplitterLayoutStruct *> list;
diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index ecba6f1974..1e4a39088c 100644
--- a/src/widgets/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
@@ -793,6 +793,82 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
return action;
}
+/*!\fn 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 QAction *QToolBar::addAction(const QString &text, Functor functor)
+
+ \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 functor.
+*/
+
+/*!\fn QAction *QToolBar::addAction(const QString &text, const QObject *context, Functor functor)
+
+ \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 functor.
+
+ If \a context is destroyed, the functor will not be called.
+*/
+
+/*!\fn QAction *QToolBar::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method)
+
+ \since 5.6
+
+ \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.
+*/
+
+/*!\fn QAction *QToolBar::addAction(const QIcon &icon, const QString &text, Functor functor)
+
+ \since 5.6
+
+ \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 functor.
+*/
+
+/*!\fn QAction *QToolBar::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor)
+
+ \since 5.6
+
+ \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 functor.
+
+ If \a context is destroyed, the functor will not be called.
+*/
+
/*!
Adds a separator to the end of the toolbar.
diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h
index f925577646..f4ed13d399 100644
--- a/src/widgets/widgets/qtoolbar.h
+++ b/src/widgets/widgets/qtoolbar.h
@@ -34,6 +34,7 @@
#ifndef QDYNAMICTOOLBAR_H
#define QDYNAMICTOOLBAR_H
+#include <QtWidgets/qaction.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
@@ -92,6 +93,51 @@ 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
+ QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method);
+ QAction *addAction(const QString &text, Functor functor);
+ QAction *addAction(const QString &text, const QObject *context, Functor functor);
+ QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method);
+ QAction *addAction(const QIcon &icon, const QString &text, Functor functor);
+ QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor);
+#else
+ // addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
+ template<class Obj, typename Func1>
+ inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
+ addAction(const QString &text, const Obj *object, Func1 slot)
+ {
+ QAction *result = addAction(text);
+ connect(result, &QAction::triggered, object, slot);
+ return result;
+ }
+ // addAction(QString): Connect to a functor or function pointer (without context)
+ template <typename Func1>
+ inline QAction *addAction(const QString &text, Func1 slot)
+ {
+ QAction *result = addAction(text);
+ connect(result, &QAction::triggered, slot);
+ return result;
+ }
+ // addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
+ template<class Obj, typename Func1>
+ inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
+ addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot)
+ {
+ QAction *result = addAction(actionIcon, text);
+ connect(result, &QAction::triggered, object, slot);
+ return result;
+ }
+ // addAction(QIcon, QString): Connect to a functor or function pointer (without context)
+ template <typename Func1>
+ inline QAction *addAction(const QIcon &actionIcon, const QString &text, Func1 slot)
+ {
+ QAction *result = addAction(actionIcon, text);
+ connect(result, &QAction::triggered, slot);
+ return result;
+ }
+#endif // !Q_QDOC
QAction *addSeparator();
QAction *insertSeparator(QAction *before);
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 759e41a5fa..436937be72 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -189,7 +189,7 @@ void QWidgetLineControl::commitPreedit()
m_preeditCursor = 0;
setPreeditArea(-1, QString());
- m_textLayout.clearAdditionalFormats();
+ m_textLayout.clearFormats();
updateDisplayText(/*force*/ true);
#endif
}
@@ -557,7 +557,8 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
const int oldPreeditCursor = m_preeditCursor;
m_preeditCursor = event->preeditString().length();
m_hideCursor = false;
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
+ formats.reserve(event->attributes().size());
for (int i = 0; i < event->attributes().size(); ++i) {
const QInputMethodEvent::Attribute &a = event->attributes().at(i);
if (a.type == QInputMethodEvent::Cursor) {
@@ -574,7 +575,7 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
}
}
}
- m_textLayout.setAdditionalFormats(formats);
+ m_textLayout.setFormats(formats);
updateDisplayText(/*force*/ true);
if (cursorPositionChanged)
emitCursorPositionChanged();
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 72007ac3e8..deca002bf5 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -883,7 +883,8 @@ void QWidgetTextControl::setTextCursor(const QTextCursor &cursor)
const bool posChanged = cursor.position() != d->cursor.position();
const QTextCursor oldSelection = d->cursor;
d->cursor = cursor;
- d->cursorOn = d->hasFocus && (d->interactionFlags & Qt::TextEditable);
+ d->cursorOn = d->hasFocus
+ && (d->interactionFlags & (Qt::TextSelectableByKeyboard | Qt::TextEditable));
d->_q_updateCurrentCharFormatAndSelection();
ensureCursorVisible();
d->repaintOldAndNewSelection(oldSelection);
@@ -2028,7 +2029,8 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
QTextLayout *layout = block.layout();
if (isGettingInput)
layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());
- QList<QTextLayout::FormatRange> overrides;
+ QVector<QTextLayout::FormatRange> overrides;
+ overrides.reserve(e->attributes().size());
const int oldPreeditCursor = preeditCursor;
preeditCursor = e->preeditString().length();
hideCursor = false;
@@ -2048,7 +2050,7 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
}
}
}
- layout->setAdditionalFormats(overrides);
+ layout->setFormats(overrides);
cursor.endEditBlock();
@@ -2138,7 +2140,7 @@ void QWidgetTextControlPrivate::focusEvent(QFocusEvent *e)
#ifdef QT_KEYPAD_NAVIGATION
if (!QApplication::keypadNavigationEnabled() || (hasEditFocus && (e->reason() == Qt::PopupFocusReason))) {
#endif
- cursorOn = (interactionFlags & Qt::TextSelectableByKeyboard);
+ cursorOn = (interactionFlags & (Qt::TextSelectableByKeyboard | Qt::TextEditable));
if (interactionFlags & Qt::TextEditable) {
setBlinkingCursorEnabled(true);
}
@@ -2437,10 +2439,13 @@ QList<QTextEdit::ExtraSelection> QWidgetTextControl::extraSelections() const
{
Q_D(const QWidgetTextControl);
QList<QTextEdit::ExtraSelection> selections;
- for (int i = 0; i < d->extraSelections.count(); ++i) {
+ const int numExtraSelections = d->extraSelections.count();
+ selections.reserve(numExtraSelections);
+ for (int i = 0; i < numExtraSelections; ++i) {
QTextEdit::ExtraSelection sel;
- sel.cursor = d->extraSelections.at(i).cursor;
- sel.format = d->extraSelections.at(i).format;
+ const QAbstractTextDocumentLayout::Selection &sel2 = d->extraSelections.at(i);
+ sel.cursor = sel2.cursor;
+ sel.format = sel2.format;
selections.append(sel);
}
return selections;
@@ -2877,7 +2882,7 @@ void QWidgetTextControlPrivate::commitPreedit()
QTextBlock block = cursor.block();
QTextLayout *layout = block.layout();
layout->setPreeditArea(-1, QString());
- layout->clearAdditionalFormats();
+ layout->clearFormats();
cursor.endEditBlock();
}