summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/phonon/qt7/audionode.mm16
-rw-r--r--src/3rdparty/phonon/qt7/backendinfo.mm1
-rw-r--r--src/3rdparty/phonon/qt7/quicktimevideoplayer.h1
-rw-r--r--src/3rdparty/webkit/VERSION2
-rw-r--r--src/3rdparty/webkit/WebCore/ChangeLog138
-rw-r--r--src/3rdparty/webkit/WebCore/html/HTMLCanvasElement.cpp4
-rw-r--r--src/3rdparty/webkit/WebCore/page/DOMWindow.cpp3
-rw-r--r--src/3rdparty/webkit/WebCore/page/DOMWindow.h2
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp16
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp55
-rw-r--r--src/3rdparty/webkit/WebCore/platform/network/qt/ResourceRequestQt.cpp16
-rw-r--r--src/3rdparty/webkit/WebCore/platform/qt/DragDataQt.cpp6
-rw-r--r--src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp26
-rw-r--r--src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.h3
-rw-r--r--src/3rdparty/webkit/WebCore/plugins/mac/PluginViewMac.cpp9
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp4
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp22
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp4
-rw-r--r--src/3rdparty/webkit/WebKit/qt/ChangeLog55
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp34
-rw-r--r--src/activeqt/container/qaxbase.cpp12
-rw-r--r--src/corelib/concurrent/qtconcurrentreducekernel.h10
-rw-r--r--src/corelib/global/qfeatures.txt122
-rw-r--r--src/corelib/global/qglobal.cpp43
-rw-r--r--src/corelib/global/qglobal.h39
-rw-r--r--src/corelib/global/qnamespace.h6
-rw-r--r--src/corelib/io/qdir.cpp12
-rw-r--r--src/corelib/io/qdiriterator.cpp38
-rw-r--r--src/corelib/io/qfile.cpp22
-rw-r--r--src/corelib/io/qfileinfo.cpp10
-rw-r--r--src/corelib/io/qfilesystemwatcher_inotify.cpp2
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp2
-rw-r--r--src/corelib/io/qiodevice.cpp8
-rw-r--r--src/corelib/io/qprocess.cpp34
-rw-r--r--src/corelib/io/qprocess_unix.cpp8
-rw-r--r--src/corelib/io/qresource.cpp78
-rw-r--r--src/corelib/io/qsettings.cpp4
-rw-r--r--src/corelib/io/qtemporaryfile.cpp2
-rw-r--r--src/corelib/io/qtextstream.cpp11
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp8
-rw-r--r--src/corelib/kernel/qcoreevent.h1
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp15
-rw-r--r--src/corelib/kernel/qmetaobject.cpp18
-rw-r--r--src/corelib/kernel/qmetatype.cpp2
-rw-r--r--src/corelib/kernel/qsharedmemory_unix.cpp7
-rw-r--r--src/corelib/kernel/qtranslator.cpp5
-rw-r--r--src/corelib/thread/qmutexpool.cpp15
-rw-r--r--src/corelib/thread/qmutexpool_p.h5
-rw-r--r--src/corelib/thread/qthread.cpp12
-rw-r--r--src/corelib/tools/qlinkedlist.cpp4
-rw-r--r--src/corelib/tools/qlistdata.cpp4
-rw-r--r--src/corelib/tools/qlocale.cpp9
-rw-r--r--src/corelib/tools/qpoint.cpp13
-rw-r--r--src/corelib/tools/qpoint.h2
-rw-r--r--src/corelib/tools/qsize.h8
-rw-r--r--src/corelib/tools/qstring.cpp37
-rw-r--r--src/corelib/tools/qvector.h2
-rw-r--r--src/dbus/qdbusintegrator.cpp10
-rw-r--r--src/dbus/qdbuspendingreply.h4
-rw-r--r--src/dbus/qdbusthreaddebug_p.h7
-rw-r--r--src/gui/accessible/qaccessible_mac.mm122
-rw-r--r--src/gui/accessible/qaccessiblewidget.cpp13
-rw-r--r--src/gui/dialogs/qcolordialog.cpp8
-rw-r--r--src/gui/dialogs/qfiledialog.cpp64
-rw-r--r--src/gui/dialogs/qfiledialog_mac.mm2
-rw-r--r--src/gui/dialogs/qfiledialog_p.h39
-rw-r--r--src/gui/dialogs/qfilesystemmodel.cpp5
-rw-r--r--src/gui/dialogs/qinputdialog.cpp181
-rw-r--r--src/gui/dialogs/qmessagebox.cpp32
-rw-r--r--src/gui/embedded/embedded.pri19
-rw-r--r--src/gui/embedded/qkbd_defaultmap_qws_p.h796
-rw-r--r--src/gui/embedded/qkbd_qws.cpp481
-rw-r--r--src/gui/embedded/qkbd_qws.h22
-rw-r--r--src/gui/embedded/qkbd_qws_p.h129
-rw-r--r--src/gui/embedded/qkbddriverfactory_qws.cpp14
-rw-r--r--src/gui/embedded/qkbdlinuxinput_qws.cpp241
-rw-r--r--src/gui/embedded/qkbdlinuxinput_qws.h (renamed from src/gui/embedded/qkbdusb_qws.h)24
-rw-r--r--src/gui/embedded/qkbdpc101_qws.cpp485
-rw-r--r--src/gui/embedded/qkbdsl5000_qws.cpp25
-rw-r--r--src/gui/embedded/qkbdsl5000_qws.h19
-rw-r--r--src/gui/embedded/qkbdtty_qws.cpp300
-rw-r--r--src/gui/embedded/qkbdtty_qws.h8
-rw-r--r--src/gui/embedded/qkbdum_qws.cpp9
-rw-r--r--src/gui/embedded/qkbdusb_qws.cpp401
-rw-r--r--src/gui/embedded/qscreen_qws.cpp8
-rw-r--r--src/gui/embedded/qwscommand_qws.cpp1
-rw-r--r--src/gui/embedded/qwssignalhandler.cpp6
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp597
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h61
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp432
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h7
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp314
-rw-r--r--src/gui/graphicsview/qgraphicsview_p.h7
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp63
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.cpp9
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.h2
-rw-r--r--src/gui/image/qicon.cpp2
-rw-r--r--src/gui/image/qimage.cpp34
-rw-r--r--src/gui/image/qnativeimage.cpp4
-rw-r--r--src/gui/image/qpaintengine_pic.cpp21
-rw-r--r--src/gui/image/qpaintengine_pic_p.h2
-rw-r--r--src/gui/image/qpicture.cpp16
-rw-r--r--src/gui/image/qpicture_p.h1
-rw-r--r--src/gui/image/qpixmap.cpp18
-rw-r--r--src/gui/image/qpixmap_mac.cpp2
-rw-r--r--src/gui/inputmethod/qinputcontext_p.h4
-rw-r--r--src/gui/inputmethod/qmacinputcontext_mac.cpp20
-rw-r--r--src/gui/inputmethod/qmacinputcontext_p.h5
-rw-r--r--src/gui/inputmethod/qwininputcontext_p.h1
-rw-r--r--src/gui/inputmethod/qwininputcontext_win.cpp21
-rw-r--r--src/gui/inputmethod/qwsinputcontext_p.h1
-rw-r--r--src/gui/inputmethod/qwsinputcontext_qws.cpp11
-rw-r--r--src/gui/inputmethod/qximinputcontext_x11.cpp4
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp23
-rw-r--r--src/gui/itemviews/qheaderview.cpp39
-rw-r--r--src/gui/itemviews/qheaderview_p.h9
-rw-r--r--src/gui/itemviews/qlistview.cpp20
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.cpp18
-rw-r--r--src/gui/itemviews/qtableview.cpp333
-rw-r--r--src/gui/itemviews/qtableview_p.h98
-rw-r--r--src/gui/itemviews/qtreeview.cpp4
-rw-r--r--src/gui/kernel/qapplication.cpp15
-rw-r--r--src/gui/kernel/qapplication_mac.mm9
-rw-r--r--src/gui/kernel/qapplication_qws.cpp9
-rw-r--r--src/gui/kernel/qapplication_x11.cpp40
-rw-r--r--src/gui/kernel/qcocoaapplication_mac.mm22
-rw-r--r--src/gui/kernel/qcocoaapplicationdelegate_mac.mm46
-rw-r--r--src/gui/kernel/qcocoaapplicationdelegate_mac_p.h1
-rw-r--r--src/gui/kernel/qcocoamenuloader_mac.mm22
-rw-r--r--src/gui/kernel/qcocoapanel_mac.mm107
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm74
-rw-r--r--src/gui/kernel/qcocoaview_mac_p.h1
-rw-r--r--src/gui/kernel/qcocoawindow_mac.mm49
-rw-r--r--src/gui/kernel/qcocoawindowdelegate_mac.mm22
-rw-r--r--src/gui/kernel/qcursor.h2
-rw-r--r--src/gui/kernel/qcursor_mac.mm16
-rw-r--r--src/gui/kernel/qkeymapper_mac.cpp15
-rw-r--r--src/gui/kernel/qmacdefines_mac.h2
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm5
-rw-r--r--src/gui/kernel/qt_mac.cpp45
-rw-r--r--src/gui/kernel/qt_mac_p.h3
-rw-r--r--src/gui/kernel/qwidget.cpp145
-rw-r--r--src/gui/kernel/qwidget.h1
-rw-r--r--src/gui/kernel/qwidget_mac.mm87
-rw-r--r--src/gui/kernel/qwidget_p.h2
-rw-r--r--src/gui/kernel/qwidget_x11.cpp7
-rw-r--r--src/gui/kernel/qx11embed_x11.cpp7
-rw-r--r--src/gui/math3d/math3d.pri5
-rw-r--r--src/gui/math3d/qfixedpt.cpp681
-rw-r--r--src/gui/math3d/qfixedpt.h521
-rw-r--r--src/gui/math3d/qgenericmatrix.cpp32
-rw-r--r--src/gui/math3d/qgenericmatrix.h54
-rw-r--r--src/gui/math3d/qmath3dglobal.h72
-rw-r--r--src/gui/math3d/qmath3dutil.cpp164
-rw-r--r--src/gui/math3d/qmath3dutil_p.h66
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp411
-rw-r--r--src/gui/math3d/qmatrix4x4.h209
-rw-r--r--src/gui/math3d/qquaternion.cpp137
-rw-r--r--src/gui/math3d/qquaternion.h88
-rw-r--r--src/gui/math3d/qvector2d.cpp71
-rw-r--r--src/gui/math3d/qvector2d.h69
-rw-r--r--src/gui/math3d/qvector3d.cpp70
-rw-r--r--src/gui/math3d/qvector3d.h76
-rw-r--r--src/gui/math3d/qvector4d.cpp75
-rw-r--r--src/gui/math3d/qvector4d.h81
-rw-r--r--src/gui/painting/qbezier.cpp24
-rw-r--r--src/gui/painting/qcolor.cpp4
-rw-r--r--src/gui/painting/qdrawhelper.cpp1010
-rw-r--r--src/gui/painting/qmatrix.cpp63
-rw-r--r--src/gui/painting/qmatrix.h20
-rw-r--r--src/gui/painting/qpaintengine_alpha.cpp12
-rw-r--r--src/gui/painting/qpaintengine_alpha_p.h1
-rw-r--r--src/gui/painting/qpaintengine_d3d.cpp6
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp140
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h2
-rw-r--r--src/gui/painting/qpaintengine_x11.cpp19
-rw-r--r--src/gui/painting/qpainter.cpp49
-rw-r--r--src/gui/painting/qpainterpath.cpp31
-rw-r--r--src/gui/painting/qpainterpath.h2
-rw-r--r--src/gui/painting/qpainterpath_p.h11
-rw-r--r--src/gui/painting/qpathclipper.cpp36
-rw-r--r--src/gui/painting/qpdf.cpp5
-rw-r--r--src/gui/painting/qprintengine_mac.mm66
-rw-r--r--src/gui/painting/qprintengine_mac_p.h1
-rw-r--r--src/gui/painting/qprintengine_win.cpp2
-rw-r--r--src/gui/painting/qprinter.cpp6
-rw-r--r--src/gui/painting/qregion.cpp22
-rw-r--r--src/gui/painting/qstroker.cpp12
-rw-r--r--src/gui/painting/qtessellator.cpp2
-rw-r--r--src/gui/painting/qtransform.cpp243
-rw-r--r--src/gui/painting/qtransform.h30
-rw-r--r--src/gui/painting/qwindowsurface.cpp7
-rw-r--r--src/gui/styles/gtksymbols.cpp63
-rw-r--r--src/gui/styles/gtksymbols_p.h11
-rw-r--r--src/gui/styles/qcleanlooksstyle.cpp41
-rw-r--r--src/gui/styles/qcommonstyle.cpp89
-rw-r--r--src/gui/styles/qgtkstyle.cpp65
-rw-r--r--src/gui/styles/qmacstyle_mac.mm31
-rw-r--r--src/gui/styles/qplastiquestyle.cpp7
-rw-r--r--src/gui/styles/qstyle.h1
-rw-r--r--src/gui/styles/qstylehelper.cpp295
-rw-r--r--src/gui/styles/qstylehelper_p.h39
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp40
-rw-r--r--src/gui/styles/qwindowsmobilestyle.cpp3
-rw-r--r--src/gui/styles/qwindowsstyle.cpp4
-rw-r--r--src/gui/styles/qwindowsvistastyle.cpp23
-rw-r--r--src/gui/styles/qwindowsvistastyle_p.h1
-rw-r--r--src/gui/styles/qwindowsxpstyle.cpp11
-rw-r--r--src/gui/styles/styles.pri2
-rw-r--r--src/gui/text/qfontdatabase_qws.cpp5
-rw-r--r--src/gui/text/qfontengine_ft.cpp2
-rw-r--r--src/gui/text/qfontengine_mac.mm141
-rw-r--r--src/gui/text/qfontengine_p.h5
-rw-r--r--src/gui/text/qfontengine_qpf.cpp12
-rw-r--r--src/gui/text/qfontengine_qws.cpp2
-rw-r--r--src/gui/text/qtextdocument.h1
-rw-r--r--src/gui/text/qtextdocument_p.cpp1
-rw-r--r--src/gui/text/qtextlist.cpp7
-rw-r--r--src/gui/text/qtextobject.cpp8
-rw-r--r--src/gui/text/qtextobject_p.h15
-rw-r--r--src/gui/text/qtexttable.cpp2
-rw-r--r--src/gui/text/qtexttable_p.h2
-rw-r--r--src/gui/util/qcompleter.cpp7
-rw-r--r--src/gui/util/qdesktopservices.cpp5
-rw-r--r--src/gui/widgets/qabstractbutton.cpp9
-rw-r--r--src/gui/widgets/qabstractbutton.h3
-rw-r--r--src/gui/widgets/qcocoamenu_mac.mm41
-rw-r--r--src/gui/widgets/qcombobox.cpp39
-rw-r--r--src/gui/widgets/qcombobox_p.h3
-rw-r--r--src/gui/widgets/qcommandlinkbutton.cpp9
-rw-r--r--src/gui/widgets/qdialogbuttonbox.cpp3
-rw-r--r--src/gui/widgets/qlcdnumber.cpp12
-rw-r--r--src/gui/widgets/qlineedit.cpp2
-rw-r--r--src/gui/widgets/qmaccocoaviewcontainer_mac.mm22
-rw-r--r--src/gui/widgets/qmacnativewidget_mac.mm22
-rw-r--r--src/gui/widgets/qmainwindow.cpp2
-rw-r--r--src/gui/widgets/qmainwindowlayout_mac.mm44
-rw-r--r--src/gui/widgets/qmenu.cpp4
-rw-r--r--src/gui/widgets/qplaintextedit.cpp7
-rw-r--r--src/gui/widgets/qsplitter.cpp12
-rw-r--r--src/gui/widgets/qsplitter_p.h9
-rw-r--r--src/gui/widgets/qtabbar.cpp90
-rw-r--r--src/gui/widgets/qtabbar_p.h33
-rw-r--r--src/gui/widgets/qtextedit.cpp7
-rw-r--r--src/gui/widgets/qtoolbar.cpp11
-rw-r--r--src/network/access/access.pri6
-rw-r--r--src/network/access/qhttp.cpp6
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp1119
-rw-r--r--src/network/access/qhttpnetworkconnection_p.h243
-rw-r--r--src/network/access/qhttpnetworkheader.cpp123
-rw-r--r--src/network/access/qhttpnetworkheader_p.h (renamed from src/gui/embedded/qkbdpc101_qws.h)90
-rw-r--r--src/network/access/qhttpnetworkreply.cpp663
-rw-r--r--src/network/access/qhttpnetworkreply_p.h224
-rw-r--r--src/network/access/qhttpnetworkrequest.cpp261
-rw-r--r--src/network/access/qhttpnetworkrequest_p.h144
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp36
-rw-r--r--src/network/access/qnetworkcookie.cpp466
-rw-r--r--src/network/access/qnetworkdiskcache.cpp3
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp44
-rw-r--r--src/network/kernel/qauthenticator.cpp2
-rw-r--r--src/network/kernel/qhostaddress.cpp2
-rw-r--r--src/network/kernel/qnetworkinterface_win.cpp6
-rw-r--r--src/network/socket/qabstractsocket.cpp4
-rw-r--r--src/network/socket/qlocalsocket_p.h1
-rw-r--r--src/network/socket/qlocalsocket_unix.cpp28
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp19
-rw-r--r--src/opengl/opengl.pro10
-rw-r--r--src/opengl/qgl.cpp8
-rw-r--r--src/opengl/qgl_cl_p.h2
-rw-r--r--src/opengl/qgl_mac.mm30
-rw-r--r--src/opengl/qgl_p.h1
-rw-r--r--src/opengl/qglframebufferobject.cpp4
-rw-r--r--src/opengl/qglpixelbuffer_egl.cpp8
-rw-r--r--src/opengl/qglpixelbuffer_mac.mm6
-rw-r--r--src/opengl/qglpixelbuffer_win.cpp2
-rw-r--r--src/opengl/qpaintengine_opengl.cpp56
-rw-r--r--src/opengl/qwindowsurface_gl.cpp4
-rw-r--r--src/plugins/gfxdrivers/directfb/directfb.pro2
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp41
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h18
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp459
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp396
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h7
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp412
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.h49
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp125
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbsurface.h13
-rw-r--r--src/plugins/gfxdrivers/powervr/README3
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp2
-rw-r--r--src/plugins/kbddrivers/kbddrivers.pro3
-rw-r--r--src/plugins/kbddrivers/linuxinput/linuxinput.pro14
-rw-r--r--src/plugins/kbddrivers/linuxinput/main.cpp (renamed from src/plugins/kbddrivers/usb/main.cpp)22
-rw-r--r--src/plugins/kbddrivers/linuxis/README1
-rw-r--r--src/plugins/kbddrivers/linuxis/linuxis.pro11
-rw-r--r--src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.cpp87
-rw-r--r--src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.h58
-rw-r--r--src/plugins/kbddrivers/linuxis/linuxiskbdhandler.cpp171
-rw-r--r--src/plugins/kbddrivers/linuxis/linuxiskbdhandler.h80
-rw-r--r--src/plugins/kbddrivers/usb/usb.pro14
-rw-r--r--src/qt3support/text/q3richtext.cpp3
-rw-r--r--src/script/qscriptengine.cpp3
-rw-r--r--src/scripttools/debugging/qscriptbreakpointswidget.cpp8
-rw-r--r--src/scripttools/debugging/qscriptcompletiontask.cpp8
-rw-r--r--src/scripttools/debugging/qscriptdebugger.cpp6
-rw-r--r--src/scripttools/debugging/qscriptdebuggeragent.cpp19
-rw-r--r--src/scripttools/debugging/qscriptdebuggeragent_p.h3
-rw-r--r--src/scripttools/debugging/qscriptdebuggeragent_p_p.h6
-rw-r--r--src/scripttools/debugging/qscriptdebuggerbackend.cpp2
-rw-r--r--src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp4
-rw-r--r--src/scripttools/debugging/qscriptdebuggerconsoleglobalobject.cpp5
-rw-r--r--src/scripttools/debugging/qscriptdebuggerlocalswidget.cpp8
-rw-r--r--src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp18
-rw-r--r--src/scripttools/debugging/qscriptedit.cpp10
-rw-r--r--src/scripttools/debugging/qscriptenginedebugger.h4
-rw-r--r--src/sql/drivers/db2/qsql_db2.cpp105
-rw-r--r--src/sql/drivers/ibase/qsql_ibase.cpp16
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.cpp19
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.h3
-rw-r--r--src/sql/drivers/oci/qsql_oci.cpp58
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp136
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.h4
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp38
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite.cpp16
-rw-r--r--src/sql/drivers/sqlite2/qsql_sqlite2.cpp20
-rw-r--r--src/sql/drivers/tds/qsql_tds.cpp21
-rw-r--r--src/sql/kernel/qsqldriver.cpp140
-rw-r--r--src/sql/kernel/qsqldriver.h6
-rw-r--r--src/sql/models/qsqlrelationaltablemodel.cpp73
-rw-r--r--src/sql/models/qsqltablemodel.cpp20
-rw-r--r--src/svg/qgraphicssvgitem.cpp2
-rw-r--r--src/svg/qsvggenerator.cpp31
-rw-r--r--src/svg/qsvggraphics.cpp16
-rw-r--r--src/svg/qsvghandler.cpp18
-rw-r--r--src/svg/qsvgstyle.cpp11
-rw-r--r--src/svg/qsvgstyle_p.h11
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp16
337 files changed, 11297 insertions, 8719 deletions
diff --git a/src/3rdparty/phonon/qt7/audionode.mm b/src/3rdparty/phonon/qt7/audionode.mm
index cb9e82f..961230c 100644
--- a/src/3rdparty/phonon/qt7/audionode.mm
+++ b/src/3rdparty/phonon/qt7/audionode.mm
@@ -68,13 +68,15 @@ void AudioNode::createAndConnectAUNodes()
<< QString(!FindNextComponent(0, &description) ? "ERROR: COMPONENT NOT FOUND!" : "OK!"))
OSStatus err = noErr;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
- err = AUGraphAddNode(m_audioGraph->audioGraphRef(), &description, &m_auNode);
- else
-#endif
- err = AUGraphNewNode(m_audioGraph->audioGraphRef(), &description, 0, 0, &m_auNode);
-
+
+ // The proper function to call here is AUGraphAddNode() but the type has
+ // changed between 10.5 and 10.6. it's still OK to call this function, but
+ // if we want to use the proper thing we need to move over to
+ // AudioComponentDescription everywhere, which is very similar to the
+ // ComponentDescription, but a different size. however,
+ // AudioComponentDescription only exists on 10.6+. More fun than we need to
+ // deal with at the moment, so we'll take the "deprecated" warning instead.
+ err = AUGraphNewNode(m_audioGraph->audioGraphRef(), &description, 0, 0, &m_auNode);
BACKEND_ASSERT2(err != kAUGraphErr_OutputNodeErr, "A MediaObject can only be connected to one audio output device.", FATAL_ERROR)
BACKEND_ASSERT2(err == noErr, "Could not create new AUNode.", FATAL_ERROR)
}
diff --git a/src/3rdparty/phonon/qt7/backendinfo.mm b/src/3rdparty/phonon/qt7/backendinfo.mm
index e173f05..0d51db0 100644
--- a/src/3rdparty/phonon/qt7/backendinfo.mm
+++ b/src/3rdparty/phonon/qt7/backendinfo.mm
@@ -22,6 +22,7 @@
#include <AudioUnit/AudioUnit.h>
#include <CoreServices/CoreServices.h>
+#include <QtGui/qmacdefines_mac.h>
#import <QTKit/QTMovie.h>
#ifdef QUICKTIME_C_API_AVAILABLE
diff --git a/src/3rdparty/phonon/qt7/quicktimevideoplayer.h b/src/3rdparty/phonon/qt7/quicktimevideoplayer.h
index 3fa815e..bf4f216 100644
--- a/src/3rdparty/phonon/qt7/quicktimevideoplayer.h
+++ b/src/3rdparty/phonon/qt7/quicktimevideoplayer.h
@@ -20,6 +20,7 @@
#include "backendheader.h"
+#include <QtGui/qmacdefines_mac.h>
#import <QTKit/QTDataReference.h>
#import <QTKit/QTMovie.h>
diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION
index af48a6e..bfaefa2 100644
--- a/src/3rdparty/webkit/VERSION
+++ b/src/3rdparty/webkit/VERSION
@@ -8,4 +8,4 @@ The commit imported was from the
and has the sha1 checksum
- 70604503a0365edaeff82ffad7b71f90641fa592
+ 450331808bfe11b1472c213a8cb311190355c2de
diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog
index 10a3840..9be6e72 100644
--- a/src/3rdparty/webkit/WebCore/ChangeLog
+++ b/src/3rdparty/webkit/WebCore/ChangeLog
@@ -1,3 +1,141 @@
+2009-02-04 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Unreviewed Qt build fix.
+
+ Changed ASSERT(image) to ASSERT(!image.isNull()).
+
+ * platform/graphics/qt/ImageBufferQt.cpp:
+ (WebCore::ImageBuffer::getImageData):
+
+2009-02-03 Dirk Schulze <krit@webkit.org>
+
+ Reviewed by Sam Weinig.
+
+ This is a follow up of r40546. Call toImage() once speeds up ImageBuffer::getImageData()
+
+ * platform/graphics/qt/ImageBufferQt.cpp:
+ (WebCore::ImageBuffer::getImageData):
+
+2009-02-03 Dirk Schulze <krit@webkit.org>
+
+ Reviewed by Sam Weinig and Oliver Hunt.
+
+ Added getImageData() support for QtWebKit.
+
+ [QT] lacks getImageData / putImageData support in Canvas
+ https://bugs.webkit.org/show_bug.cgi?id=22186
+
+ * platform/graphics/qt/ImageBufferQt.cpp:
+ (WebCore::ImageBuffer::getImageData):
+
+2009-04-14 Benjamin C Meyer <benjamin.meyer@torchmobile.com>
+
+ Reviewed by George Staikos.
+
+ https://bugs.webkit.org/show_bug.cgi?id=25099
+
+ When creating a QNetworkRequest make sure to populate the
+ CacheLoadControlAttribute with the value set by the ResourceRequest::cachePolicy() so that the cache will be used as WebKit expects.
+
+ * WebKit/qt/tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::requestCache):
+
+ * platform/network/qt/ResourceRequestQt.cpp:
+ (WebCore::ResourceRequest::toNetworkRequest):
+
+2009-04-07 Brady Eidson <beidson@apple.com>
+
+ Reviewed by Darin Adler
+
+ While working on <rdar://problem/5968249>, noticed some glaring problems with LocalStorage.
+
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::localStorage): Return the cached m_localStorage object if it exists to
+ avoid creating multiple representations for the same underlying StorageArea.
+ * page/DOMWindow.h:
+ (WebCore::DOMWindow::optionalLocalStorage): Return m_localStorage, not m_sessionStorage.
+
+2009-04-06 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Don't show and hide the platformPluginWidget, as it's our QWebView
+
+ * plugins/mac/PluginViewMac.cpp:
+ (WebCore::PluginView::show):
+ (WebCore::PluginView::hide):
+ (WebCore::PluginView::setParentVisible):
+
+2009-04-06 Mike Belshe <mike@belshe.com>
+
+ Reviewed by Eric Seidel.
+
+ HTMLCanvasElement crash when ImageBuffer creation fails.
+ https://bugs.webkit.org/show_bug.cgi?id=23212
+
+ Check for NULL before using the ImageBuffer as we might
+ be low on memory and creation may have failed.
+
+ Test case creation blocked by:
+ https://bugs.webkit.org/show_bug.cgi?id=25055
+
+ * html/HTMLCanvasElement.cpp:
+ (WebCore::HTMLCanvasElement::createImageBuffer):
+
+2009-04-05 Erik L. Bunce <elbunce@xendom.com>
+
+ Reviewed by Simon Hausmann.
+
+ https://bugs.webkit.org/show_bug.cgi?id=25050
+
+ Fix an assert failure when dropping an 'empty' text/uri-list on a QWebView.
+
+ * platform/qt/DragDataQt.cpp:
+ (WebCore::DragData::asURL):
+
+2009-03-27 Zack Rusin <zack@kde.org>
+
+ Reviewed by Simon Hausmann.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24280
+
+ Fix propagation of fill rules when rendering paths in the Qt build.
+
+ * platform/graphics/qt/GraphicsContextQt.cpp:
+ (WebCore::toQtFillRule):
+ (WebCore::GraphicsContext::fillPath):
+ (WebCore::GraphicsContext::strokePath):
+
+2009-03-27 Zack Rusin <zack@kde.org>
+
+ Reviewed by Tor Arne Vestbø.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24275
+
+ Fix text field theming in the Qt build with the KDE 4 Oxygen
+ style by adjusting the size vertically and horizontally to
+ set padding on the element equal to the width of the style painted border.
+
+ * platform/qt/RenderThemeQt.cpp:
+ (WebCore::RenderThemeQt::RenderThemeQt):
+ (WebCore::RenderThemeQt::computeSizeBasedOnStyle):
+ (WebCore::RenderThemeQt::adjustTextFieldStyle):
+ (WebCore::RenderThemeQt::paintTextField):
+ * platform/qt/RenderThemeQt.h:
+
+2009-02-06 Dirk Schulze <krit@webkit.org>
+
+ Reviewed by Simon Hausmann.
+
+ Fix bug in clearRect(). Use fillRect() instead of eraseRect() to get
+ the context transparent.
+
+ [QT] clearRect fill's a given rect with white
+ https://bugs.webkit.org/show_bug.cgi?id=23728
+
+ * platform/graphics/qt/GraphicsContextQt.cpp:
+ (WebCore::GraphicsContext::clearRect):
+
2009-03-19 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Tor Arne Vestbø.
diff --git a/src/3rdparty/webkit/WebCore/html/HTMLCanvasElement.cpp b/src/3rdparty/webkit/WebCore/html/HTMLCanvasElement.cpp
index fb6d9fe..76c3202 100644
--- a/src/3rdparty/webkit/WebCore/html/HTMLCanvasElement.cpp
+++ b/src/3rdparty/webkit/WebCore/html/HTMLCanvasElement.cpp
@@ -257,6 +257,10 @@ void HTMLCanvasElement::createImageBuffer() const
return;
m_imageBuffer.set(ImageBuffer::create(size, false).release());
+ // The convertLogicalToDevice MaxCanvasArea check should prevent common cases
+ // where ImageBuffer::create() returns NULL, however we could still be low on memory.
+ if (!m_imageBuffer)
+ return;
m_imageBuffer->context()->scale(FloatSize(size.width() / unscaledSize.width(), size.height() / unscaledSize.height()));
m_imageBuffer->context()->setShadowsIgnoreTransforms(true);
}
diff --git a/src/3rdparty/webkit/WebCore/page/DOMWindow.cpp b/src/3rdparty/webkit/WebCore/page/DOMWindow.cpp
index 42d2e90..dd14fb9 100644
--- a/src/3rdparty/webkit/WebCore/page/DOMWindow.cpp
+++ b/src/3rdparty/webkit/WebCore/page/DOMWindow.cpp
@@ -333,6 +333,9 @@ Storage* DOMWindow::sessionStorage() const
Storage* DOMWindow::localStorage() const
{
+ if (m_localStorage)
+ return m_localStorage.get();
+
Document* document = this->document();
if (!document)
return 0;
diff --git a/src/3rdparty/webkit/WebCore/page/DOMWindow.h b/src/3rdparty/webkit/WebCore/page/DOMWindow.h
index 0277441..e7fab18 100644
--- a/src/3rdparty/webkit/WebCore/page/DOMWindow.h
+++ b/src/3rdparty/webkit/WebCore/page/DOMWindow.h
@@ -265,7 +265,7 @@ namespace WebCore {
Location* optionalLocation() const { return m_location.get(); }
#if ENABLE(DOM_STORAGE)
Storage* optionalSessionStorage() const { return m_sessionStorage.get(); }
- Storage* optionalLocalStorage() const { return m_sessionStorage.get(); }
+ Storage* optionalLocalStorage() const { return m_localStorage.get(); }
#endif
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
DOMApplicationCache* optionalApplicationCache() const { return m_applicationCache.get(); }
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index 80a6390..936c1ea 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -168,6 +168,18 @@ static inline QGradient applySpreadMethod(QGradient gradient, GradientSpreadMeth
return gradient;
}
+static inline Qt::FillRule toQtFillRule(WindRule rule)
+{
+ switch(rule) {
+ case RULE_EVENODD:
+ return Qt::OddEvenFill;
+ case RULE_NONZERO:
+ return Qt::WindingFill;
+ }
+ qDebug("Qt: unrecognized wind rule!");
+ return Qt::OddEvenFill;
+}
+
struct TransparencyLayer
{
TransparencyLayer(const QPainter* p, const QRect &rect)
@@ -541,6 +553,7 @@ void GraphicsContext::fillPath()
QPainter *p = m_data->p();
QPainterPath path = m_data->currentPath;
+ path.setFillRule(toQtFillRule(fillRule()));
switch (m_common->state.fillColorSpace) {
case SolidColorSpace:
@@ -569,6 +582,7 @@ void GraphicsContext::strokePath()
QPainter *p = m_data->p();
QPen pen = p->pen();
QPainterPath path = m_data->currentPath;
+ path.setFillRule(toQtFillRule(fillRule()));
switch (m_common->state.strokeColorSpace) {
case SolidColorSpace:
@@ -815,7 +829,7 @@ void GraphicsContext::clearRect(const FloatRect& rect)
QPainter::CompositionMode currentCompositionMode = p->compositionMode();
if (p->paintEngine()->hasFeature(QPaintEngine::PorterDuff))
p->setCompositionMode(QPainter::CompositionMode_Source);
- p->eraseRect(rect);
+ p->fillRect(rect, Qt::transparent);
if (p->paintEngine()->hasFeature(QPaintEngine::PorterDuff))
p->setCompositionMode(currentCompositionMode);
}
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp
index d4ab59f..d1009b5 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp
@@ -35,6 +35,8 @@
#include "StillImageQt.h"
#include <QBuffer>
+#include <QColor>
+#include <QImage>
#include <QImageWriter>
#include <QPainter>
#include <QPixmap>
@@ -79,10 +81,57 @@ Image* ImageBuffer::image() const
return m_image.get();
}
-PassRefPtr<ImageData> ImageBuffer::getImageData(const IntRect&) const
+PassRefPtr<ImageData> ImageBuffer::getImageData(const IntRect& rect) const
{
- notImplemented();
- return 0;
+ PassRefPtr<ImageData> result = ImageData::create(rect.width(), rect.height());
+ unsigned char* data = result->data()->data();
+
+ if (rect.x() < 0 || rect.y() < 0 || (rect.x() + rect.width()) > m_size.width() || (rect.y() + rect.height()) > m_size.height())
+ memset(data, 0, result->data()->length());
+
+ int originx = rect.x();
+ int destx = 0;
+ if (originx < 0) {
+ destx = -originx;
+ originx = 0;
+ }
+ int endx = rect.x() + rect.width();
+ if (endx > m_size.width())
+ endx = m_size.width();
+ int numColumns = endx - originx;
+
+ int originy = rect.y();
+ int desty = 0;
+ if (originy < 0) {
+ desty = -originy;
+ originy = 0;
+ }
+ int endy = rect.y() + rect.height();
+ if (endy > m_size.height())
+ endy = m_size.height();
+ int numRows = endy - originy;
+
+ QImage image = m_data.m_pixmap.toImage();
+ if (image.format() != QImage::Format_ARGB32)
+ image = image.convertToFormat(QImage::Format_ARGB32);
+ ASSERT(!image.isNull());
+
+ unsigned destBytesPerRow = 4 * rect.width();
+ unsigned char* destRows = data + desty * destBytesPerRow + destx * 4;
+ for (int y = 0; y < numRows; ++y) {
+ for (int x = 0; x < numColumns; x++) {
+ QRgb value = image.pixel(x + originx, y + originy);
+ int basex = x * 4;
+
+ destRows[basex] = qRed(value);
+ destRows[basex + 1] = qGreen(value);
+ destRows[basex + 2] = qBlue(value);
+ destRows[basex + 3] = qAlpha(value);
+ }
+ destRows += destBytesPerRow;
+ }
+
+ return result;
}
void ImageBuffer::putImageData(ImageData*, const IntRect&, const IntPoint&)
diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceRequestQt.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceRequestQt.cpp
index 9308878..c8f6ad5 100644
--- a/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceRequestQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceRequestQt.cpp
@@ -41,6 +41,22 @@ QNetworkRequest ResourceRequest::toNetworkRequest() const
request.setRawHeader(name, value);
}
+ switch (cachePolicy()) {
+ case ReloadIgnoringCacheData:
+ request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
+ break;
+ case ReturnCacheDataElseLoad:
+ request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
+ break;
+ case ReturnCacheDataDontLoad:
+ request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache);
+ break;
+ case UseProtocolCachePolicy:
+ // QNetworkRequest::PreferNetwork
+ default:
+ break;
+ }
+
return request;
}
diff --git a/src/3rdparty/webkit/WebCore/platform/qt/DragDataQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/DragDataQt.cpp
index 9d95373..218f7be 100644
--- a/src/3rdparty/webkit/WebCore/platform/qt/DragDataQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/qt/DragDataQt.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -126,6 +126,10 @@ String DragData::asURL(String* title) const
if (!m_platformDragData)
return String();
QList<QUrl> urls = m_platformDragData->urls();
+
+ if (urls.isEmpty())
+ return String();
+
return urls.first().toString();
}
diff --git a/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp
index cc9d314..a9da76b 100644
--- a/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp
@@ -41,6 +41,7 @@
#include <QWidget>
#include <QPainter>
#include <QPushButton>
+#include <QLineEdit>
#include <QStyleFactory>
#include <QStyleOptionButton>
#include <QStyleOptionFrameV2>
@@ -123,6 +124,12 @@ RenderThemeQt::RenderThemeQt()
#endif
m_fallbackStyle = 0;
+
+ // this will need to be regenerated when the style changes
+ QLineEdit lineEdit;
+ QStyleOptionFrameV2 opt;
+ m_frameLineWidth = QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth,
+ &opt, &lineEdit);
}
RenderThemeQt::~RenderThemeQt()
@@ -268,7 +275,7 @@ int RenderThemeQt::minimumMenuListSize(RenderStyle*) const
return 7 * fm.width(QLatin1Char('x'));
}
-static void computeSizeBasedOnStyle(RenderStyle* renderStyle)
+void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const
{
// If the width and height are both specified, then we have nothing to do.
if (!renderStyle->width().isIntrinsicOrAuto() && !renderStyle->height().isAuto())
@@ -335,13 +342,15 @@ static void computeSizeBasedOnStyle(RenderStyle* renderStyle)
int h = qMax(fm.lineSpacing(), 14) + 2*verticalMargin;
int w = fm.width(QLatin1Char('x')) * 17 + 2*horizontalMargin;
QStyleOptionFrameV2 opt;
- opt.lineWidth = applicationStyle->pixelMetric(QStyle::PM_DefaultFrameWidth,
- &opt, 0);
+ opt.lineWidth = m_frameLineWidth;
QSize sz = applicationStyle->sizeFromContents(QStyle::CT_LineEdit,
- &opt,
- QSize(w, h).expandedTo(QApplication::globalStrut()),
- 0);
+ &opt,
+ QSize(w, h).expandedTo(QApplication::globalStrut()),
+ 0);
size.setHeight(sz.height());
+
+ renderStyle->setPaddingLeft(Length(opt.lineWidth, Fixed));
+ renderStyle->setPaddingRight(Length(opt.lineWidth, Fixed));
break;
}
default:
@@ -482,6 +491,9 @@ void RenderThemeQt::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style,
{
style->setBackgroundColor(Color::transparent);
style->setColor(QApplication::palette().text().color());
+ style->resetBorder();
+ style->resetPadding();
+ computeSizeBasedOnStyle(style);
}
bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
@@ -495,7 +507,7 @@ bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInf
panel.initFrom(p.widget);
panel.rect = r;
- panel.lineWidth = p.style->pixelMetric(QStyle::PM_DefaultFrameWidth, &panel, p.widget);
+ panel.lineWidth = m_frameLineWidth;
panel.state |= QStyle::State_Sunken;
panel.features = QStyleOptionFrameV2::None;
diff --git a/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.h b/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.h
index b4a5064..5c78a72 100644
--- a/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.h
+++ b/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.h
@@ -128,6 +128,7 @@ private:
void paintMediaBackground(QPainter* painter, const IntRect& r) const;
QColor getMediaControlForegroundColor(RenderObject* o = 0) const;
#endif
+ void computeSizeBasedOnStyle(RenderStyle* renderStyle) const;
private:
bool supportsFocus(ControlPart) const;
@@ -144,6 +145,8 @@ private:
QStyle* m_fallbackStyle;
QStyle* fallbackStyle();
+
+ int m_frameLineWidth;
};
class StylePainter
diff --git a/src/3rdparty/webkit/WebCore/plugins/mac/PluginViewMac.cpp b/src/3rdparty/webkit/WebCore/plugins/mac/PluginViewMac.cpp
index e0e178b..1d7d570 100644
--- a/src/3rdparty/webkit/WebCore/plugins/mac/PluginViewMac.cpp
+++ b/src/3rdparty/webkit/WebCore/plugins/mac/PluginViewMac.cpp
@@ -299,9 +299,6 @@ void PluginView::show()
setSelfVisible(true);
- if (isParentVisible() && platformPluginWidget())
- platformPluginWidget()->setVisible(true);
-
Widget::show();
}
@@ -311,9 +308,6 @@ void PluginView::hide()
setSelfVisible(false);
- if (isParentVisible() && platformPluginWidget())
- platformPluginWidget()->setVisible(false);
-
Widget::hide();
}
@@ -345,9 +339,6 @@ void PluginView::setParentVisible(bool visible)
return;
Widget::setParentVisible(visible);
-
- if (isSelfVisible() && platformPluginWidget())
- platformPluginWidget()->setVisible(visible);
}
void PluginView::setNPWindowRect(const IntRect&)
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp
index ae71356..5dc6363 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp
@@ -534,6 +534,8 @@ void QWebFrame::load(const QNetworkRequest &req,
Sets the content of this frame to \a html. \a baseUrl is optional and used to resolve relative
URLs in the document, such as referenced images or stylesheets.
+ The \a html is loaded immediately; external objects are loaded asynchronously.
+
When using this method WebKit assumes that external resources such as JavaScript programs or style
sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external
script can be specified through the charset attribute of the HTML script tag. It is also possible
@@ -558,6 +560,8 @@ void QWebFrame::setHtml(const QString &html, const QUrl &baseUrl)
External objects referenced in the content are located relative to \a baseUrl.
+ The \a data is loaded immediately; external objects are loaded asynchronously.
+
\sa toHtml()
*/
void QWebFrame::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
index 5e3c656..e17306d 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
@@ -533,6 +533,8 @@ void QWebPagePrivate::updateEditorActions()
updateAction(QWebPage::ToggleBold);
updateAction(QWebPage::ToggleItalic);
updateAction(QWebPage::ToggleUnderline);
+ updateAction(QWebPage::InsertParagraphSeparator);
+ updateAction(QWebPage::InsertLineSeparator);
}
void QWebPagePrivate::timerEvent(QTimerEvent *ev)
@@ -894,14 +896,14 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev)
return;
}
- if (!ev->preeditString().isEmpty()) {
+ if (!ev->commitString().isEmpty())
+ editor->confirmComposition(ev->commitString());
+ else {
QString preedit = ev->preeditString();
// ### FIXME: use the provided QTextCharFormat (use color at least)
Vector<CompositionUnderline> underlines;
underlines.append(CompositionUnderline(0, preedit.length(), Color(0,0,0), false));
editor->setComposition(preedit, underlines, preedit.length(), 0);
- } else if (!ev->commitString().isEmpty()) {
- editor->confirmComposition(ev->commitString());
}
ev->accept();
}
@@ -1792,6 +1794,13 @@ QAction *QWebPage::action(WebAction action) const
text = contextMenuItemTagInspectElement();
break;
+ case InsertParagraphSeparator:
+ text = tr("Insert a new paragraph");
+ break;
+ case InsertLineSeparator:
+ text = tr("Insert a new line");
+ break;
+
case NoWebAction:
return 0;
}
@@ -2319,7 +2328,8 @@ QWebPluginFactory *QWebPage::pluginFactory() const
\list
\o %Platform% and %Subplatform% are expanded to the windowing system and the operation system.
\o %Security% expands to U if SSL is enabled, otherwise N. SSL is enabled if QSslSocket::supportsSsl() returns true.
- \o %Locale% is replaced with QLocale::name().
+ \o %Locale% is replaced with QLocale::name(). The locale is determined from the view of the QWebPage. If no view is set on the QWebPage,
+ then a default constructed QLocale is used instead.
\o %WebKitVersion% currently expands to 527+
\o %AppVersion% expands to QCoreApplication::applicationName()/QCoreApplication::applicationVersion() if they're set; otherwise defaulting to Qt and the current Qt version.
\endlist
@@ -2507,7 +2517,7 @@ void QWebPagePrivate::_q_onLoadProgressChanged(int) {
\sa bytesReceived()
*/
quint64 QWebPage::totalBytes() const {
- return d->m_bytesReceived;
+ return d->m_totalBytes;
}
@@ -2517,7 +2527,7 @@ quint64 QWebPage::totalBytes() const {
\sa totalBytes()
*/
quint64 QWebPage::bytesReceived() const {
- return d->m_totalBytes;
+ return d->m_bytesReceived;
}
/*!
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp
index ea503a1..a843eba 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp
@@ -289,6 +289,8 @@ void QWebView::load(const QNetworkRequest &request,
External objects such as stylesheets or images referenced in the HTML
document are located relative to \a baseUrl.
+ The \a html is loaded immediately; external objects are loaded asynchronously.
+
When using this method, WebKit assumes that external resources such as
JavaScript programs or style sheets are encoded in UTF-8 unless otherwise
specified. For example, the encoding of an external script can be specified
@@ -309,6 +311,8 @@ void QWebView::setHtml(const QString &html, const QUrl &baseUrl)
External objects referenced in the content are located relative to \a baseUrl.
+ The \a data is loaded immediately; external objects are loaded asynchronously.
+
\sa load(), setHtml(), QWebFrame::toHtml()
*/
void QWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog
index 0755133..5a23200 100644
--- a/src/3rdparty/webkit/WebKit/qt/ChangeLog
+++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog
@@ -1,3 +1,58 @@
+2009-03-07 Adam Treat <adam.treat@torchmobile.com>
+
+ Reviewed by Cameron Zwarich.
+
+ These methods are clearly returning the wrong values as the two were
+ returning swapped information.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::totalBytes):
+ (QWebPage::bytesReceived):
+
+2009-04-02 Takumi Asaki <takumi.asaki@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Fix pre-edit handling of text fields with input methods.
+
+ The input method sends an empty preeditString() if all characters of
+ the preedit should be deleted. So inputMethodEvent() has to use
+ preeditString() if it's empty.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::inputMethodEvent):
+
+2009-03-30 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Rubber-stamped by Tor Arne Vestbø.
+
+ Document that setHtml/setContent loads only the html/data immediately, not external objects.
+
+ * Api/qwebframe.cpp:
+ * Api/qwebview.cpp:
+
+2009-03-26 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Rubber-stamped by Tor Arne Vestbø.
+
+ Fix the documentation of the QLocale usage in userAgentForUrl.
+
+ * Api/qwebpage.cpp:
+
+2009-03-20 Erik L. Bunce <elbunce@xendom.com>
+
+ Reviewed by Simon Hausmann.
+
+ Fix for InsertParagraphSeparator and InsertLineSeparator so that
+ QWebPage::action() creates QActions for them. Also make sure they get
+ updated appropriately.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::updateEditorActions):
+ (QWebPage::action):
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::textEditing):
+
2009-03-20 Erik L. Bunce <elbunce@xendom.com>
Reviewed by Tor Arne Vestbø.
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
index 54d342e..fe74fac 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -106,6 +106,8 @@ private slots:
void textSelection();
void textEditing();
+ void requestCache();
+
private:
@@ -956,6 +958,8 @@ void tst_QWebPage::textEditing()
QVERIFY(page->action(QWebPage::ToggleBold) != 0);
QVERIFY(page->action(QWebPage::ToggleItalic) != 0);
QVERIFY(page->action(QWebPage::ToggleUnderline) != 0);
+ QVERIFY(page->action(QWebPage::InsertParagraphSeparator) != 0);
+ QVERIFY(page->action(QWebPage::InsertLineSeparator) != 0);
// right now they are disabled because contentEditable is false
QCOMPARE(page->action(QWebPage::DeleteStartOfWord)->isEnabled(), false);
@@ -966,6 +970,8 @@ void tst_QWebPage::textEditing()
QCOMPARE(page->action(QWebPage::ToggleBold)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::ToggleItalic)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::ToggleUnderline)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::InsertParagraphSeparator)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::InsertLineSeparator)->isEnabled(), false);
// make it editable before navigating the cursor
page->setContentEditable(true);
@@ -979,10 +985,38 @@ void tst_QWebPage::textEditing()
QCOMPARE(page->action(QWebPage::ToggleBold)->isEnabled(), true);
QCOMPARE(page->action(QWebPage::ToggleItalic)->isEnabled(), true);
QCOMPARE(page->action(QWebPage::ToggleUnderline)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::InsertParagraphSeparator)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::InsertLineSeparator)->isEnabled(), true);
delete page;
}
+void tst_QWebPage::requestCache()
+{
+ TestPage page;
+ QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool)));
+
+ page.mainFrame()->setUrl(QString("data:text/html,<a href=\"data:text/html,Reached\" target=\"_blank\">Click me</a>"));
+ QTRY_COMPARE(loadSpy.count(), 1);
+ QTRY_COMPARE(page.navigations.count(), 1);
+
+ page.mainFrame()->setUrl(QString("data:text/html,<a href=\"data:text/html,Reached\" target=\"_blank\">Click me2</a>"));
+ QTRY_COMPARE(loadSpy.count(), 2);
+ QTRY_COMPARE(page.navigations.count(), 2);
+
+ page.triggerAction(QWebPage::Stop);
+ QVERIFY(page.history()->canGoBack());
+ page.triggerAction(QWebPage::Back);
+
+ QTRY_COMPARE(loadSpy.count(), 3);
+ QTRY_COMPARE(page.navigations.count(), 3);
+ QCOMPARE(page.navigations.at(0).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(),
+ (int)QNetworkRequest::PreferNetwork);
+ QCOMPARE(page.navigations.at(1).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(),
+ (int)QNetworkRequest::PreferNetwork);
+ QCOMPARE(page.navigations.at(2).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(),
+ (int)QNetworkRequest::PreferCache);
+}
QTEST_MAIN(tst_QWebPage)
#include "tst_qwebpage.moc"
diff --git a/src/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp
index 1ec704a..44c3e9e 100644
--- a/src/activeqt/container/qaxbase.cpp
+++ b/src/activeqt/container/qaxbase.cpp
@@ -1660,11 +1660,15 @@ private:
QMap<QByteArray, Property> property_list;
void addProperty(const QByteArray &type, const QByteArray &name, uint flags)
{
+ QByteArray propertyType(type);
+ if (propertyType.endsWith("&"))
+ propertyType.chop(1);
+
Property &prop = property_list[name];
- if (!type.isEmpty() && type != "HRESULT") {
- prop.type = replaceType(type);
- if (prop.type != type)
- prop.realType = type;
+ if (!propertyType.isEmpty() && propertyType != "HRESULT") {
+ prop.type = replaceType(propertyType);
+ if (prop.type != propertyType)
+ prop.realType = propertyType;
}
if (flags & Writable)
flags |= Stored;
diff --git a/src/corelib/concurrent/qtconcurrentreducekernel.h b/src/corelib/concurrent/qtconcurrentreducekernel.h
index e863b63..2dad519 100644
--- a/src/corelib/concurrent/qtconcurrentreducekernel.h
+++ b/src/corelib/concurrent/qtconcurrentreducekernel.h
@@ -51,6 +51,7 @@
#include <QtCore/qmap.h>
#include <QtCore/qmutex.h>
#include <QtCore/qthread.h>
+#include <QtCore/qthreadpool.h>
#include <QtCore/qvector.h>
QT_BEGIN_HEADER
@@ -107,7 +108,7 @@ class ReduceKernel
const ReduceOptions reduceOptions;
QMutex mutex;
- int progress, resultsMapSize;
+ int progress, resultsMapSize, threadCount;
ResultsMap resultsMap;
bool canReduce(int begin) const
@@ -140,7 +141,8 @@ class ReduceKernel
public:
ReduceKernel(ReduceOptions _reduceOptions)
- : reduceOptions(_reduceOptions), progress(0), resultsMapSize(0)
+ : reduceOptions(_reduceOptions), progress(0), resultsMapSize(0),
+ threadCount(QThreadPool::globalInstance()->maxThreadCount())
{ }
void runReduce(ReduceFunctor &reduce,
@@ -210,12 +212,12 @@ public:
inline bool shouldThrottle()
{
- return (resultsMapSize > (ReduceQueueThrottleLimit * QThread::idealThreadCount()));
+ return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
}
inline bool shouldStartThread()
{
- return (resultsMapSize <= (ReduceQueueStartLimit * QThread::idealThreadCount()));
+ return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
}
};
diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt
index 2c5b580..5d63e46 100644
--- a/src/corelib/global/qfeatures.txt
+++ b/src/corelib/global/qfeatures.txt
@@ -3,28 +3,28 @@
Feature: PROPERTIES
Description: Supports scripting Qt-based applications.
Section: Kernel
-Requires:
+Requires:
Name: Properties
SeeAlso: ???
Feature: TEXTHTMLPARSER
Description: Parser for HTML
Section: Kernel
-Requires:
+Requires:
Name: HtmlParser
SeeAlso: ???
Feature: TEXTODFWRITER
Description: Provides an ODF writer
Section: Kernel
-Requires: XMLSTREAMWRITER
+Requires: XMLSTREAMWRITER
Name: OdfWriter
SeeAlso: ???
Feature: CSSPARSER
Description: Parser for Style Sheets
Section: Kernel
-Requires:
+Requires:
Name: CssParser
SeeAlso: ???
@@ -52,21 +52,21 @@ SeeAlso: ???
Feature: SESSIONMANAGER
Description: Supports session management.
Section: Kernel
-Requires:
+Requires:
Name: Session Manager
SeeAlso: ???
Feature: SHORTCUT
Description: Supports keyboard accelerators and shortcuts.
Section: Kernel
-Requires:
+Requires:
Name: QShortcut
SeeAlso: ???
Feature: ACTION
Description: Supports widget actions.
Section: Kernel
-Requires:
+Requires:
Name: QAction
SeeAlso: ???
@@ -129,8 +129,8 @@ SeeAlso: ???
Feature: XMLSTREAM
Description: Provides a simple streaming API for XML.
Section: Kernel
-Requires:
-Name:
+Requires:
+Name:
SeeAlso: ???
Feature: XMLSTREAMREADER
@@ -159,14 +159,14 @@ SeeAlso: ???
Feature: QUUID_STRING
Description: Supports convertion between UUID and strings.
Section: Data structures
-Requires:
+Requires:
Name: Universally Unique Identifier Convertion
SeeAlso: ???
Feature: TEXTDATE
Description: Supports month and day names in dates.
Section: Data structures
-Requires:
+Requires:
Name: Text Date
SeeAlso: ???
@@ -210,7 +210,7 @@ SeeAlso: ???
Feature: SETTINGS
Description: Supports persistent application settings.
Section: File I/O
-Requires: TEXTSTREAM
+Requires: TEXTSTREAM
Name: QSettings
SeeAlso: ???
@@ -229,7 +229,7 @@ Name: QFileSystemModel
SeeAlso: ???
Feature: FILESYSTEMWATCHER
-Description: Provides an interface for monitoring files and directories
+Description: Provides an interface for monitoring files and directories
for modications.
Section: File I/O
Requires: THREAD
@@ -239,7 +239,7 @@ SeeAlso: ???
# Widgets
Feature: TREEWIDGET
-Description: Supports views using tree models.
+Description: Supports views using tree models.
Section: Widgets
Requires: TREEVIEW
Name: QTreeWidget
@@ -283,7 +283,7 @@ SeeAlso: ???
Feature: SPLASHSCREEN
Description: Supports splash screens that can be shown during application startup.
Section: Widgets
-Requires:
+Requires:
Name: Splash screen widget
SeeAlso: ???
@@ -295,7 +295,7 @@ Name: QSplitter
SeeAlso: ???
Feature: LCDNUMBER
-Description: Supports LCD-like digits.
+Description: Supports LCD-like digits.
Section: Widgets
Requires:
Name: QLCDNumber
@@ -381,7 +381,7 @@ SeeAlso: ???
Feature: BUTTONGROUP
Description: Supports organizing groups of button widgets.
Section: Widgets
-Requires: GROUPBOX
+Requires: GROUPBOX
Name: QButtonGroup
SeeAlso: ???
@@ -393,7 +393,7 @@ Name: QMainWindow
SeeAlso: ???
Feature: DOCKWIDGET
-Description: Supports docking widgets inside a QMainWindow or floated as
+Description: Supports docking widgets inside a QMainWindow or floated as
a top-level window on the desktop.
Section: Widgets
Requires: RUBBERBAND MAINWINDOW
@@ -401,7 +401,7 @@ Name: QDockwidget
SeeAlso: ???
Feature: WORKSPACE
-Description: Supports workspace windows, e.g. used in an MDI application.
+Description: Supports workspace windows, e.g. used in an MDI application.
Section: Widgets
Requires: SCROLLBAR RESIZEHANDLER MENU TOOLBUTTON MAINWINDOW TOOLBAR MENUBAR
Name: QWorkSpace
@@ -457,8 +457,8 @@ Name: QSlider
SeeAlso: ???
Feature: SCROLLBAR
-Description: Supports scrollbars allowing the user access parts of a
-document that is larger than the widget used to display it.
+Description: Supports scrollbars allowing the user access parts of a
+document that is larger than the widget used to display it.
Section: Widgets
Requires: SLIDER
Name: QScrollBar
@@ -500,7 +500,7 @@ Name: QTextEdit
SeeAlso: ???
Feature: SYNTAXHIGHLIGHTER
-Description: Supports custom syntax highlighting.
+Description: Supports custom syntax highlighting.
Section: Widgets
Requires: TEXTEDIT
Name: QSyntaxHighlighter
@@ -556,7 +556,7 @@ Name: QSizeGrip
SeeAlso: ???
Feature: CALENDARWIDGET
-Description: Provides a monthly based calendar widget allowing the user to select
+Description: Provides a monthly based calendar widget allowing the user to select
a date.
Section: Widgets
Requires: TABLEVIEW MENU TEXTDATE SPINBOX TOOLBUTTON
@@ -567,14 +567,14 @@ Feature: PRINTPREVIEWWIDGET
Description: Provides a widget for previewing page layouts for printer output.
a date.
Section: Widgets
-Requires: GRAPHICSVIEW PRINTER PICTURE
+Requires: GRAPHICSVIEW PRINTER
Name: QPrintPreviewWidget
SeeAlso: ???
# Dialogs
Feature: MESSAGEBOX
-Description: Supports message boxes displaying
+Description: Supports message boxes displaying
informative messages and simple questions.
Section: Dialogs
Requires:
@@ -589,7 +589,7 @@ Name: QColorDialog
SeeAlso: ???
Feature: FILEDIALOG
-Description: Supports a dialog widget for selecting files or directories.
+Description: Supports a dialog widget for selecting files or directories.
Section: Dialogs
Requires: DIRMODEL TREEVIEW COMBOBOX TOOLBUTTON BUTTONGROUP TOOLTIP SPLITTER STACKEDWIDGET FILESYSTEMMODEL
Name: QFileDialog
@@ -654,7 +654,7 @@ SeeAlso: ???
# ItemViews
Feature: ITEMVIEWS
-Description: Supports the model/view architecture managing the relationship
+Description: Supports the model/view architecture managing the relationship
between data and the way it is presented to the user.
Section: ItemViews
Requires: RUBBERBAND SCROLLAREA
@@ -683,8 +683,8 @@ Name: QAbstractProxyModel
SeeAlso: ???
Feature: SORTFILTERPROXYMODEL
-Description: Supports sorting and filtering of data passed between
-another model and a view.
+Description: Supports sorting and filtering of data passed between
+another model and a view.
Section: ItemViews
Requires: PROXYMODEL
Name: QSortFilterProxyModel
@@ -705,9 +705,9 @@ Name: QListView
SeeAlso: ???
Feature: TABLEVIEW
-Description: Supports a default model/view implementation of a table view.
+Description: Supports a default model/view implementation of a table view.
Section: ItemViews
-Requires: ITEMVIEWS
+Requires: ITEMVIEWS
Name: QTableView
SeeAlso: ???
@@ -735,21 +735,21 @@ SeeAlso: ???
# Styles
Feature: STYLE_WINDOWS
-Description: Supports a Microsoft Windows-like look and feel.
+Description: Supports a Microsoft Windows-like look and feel.
Section: Styles
Requires:
Name: QWindowsStyle
SeeAlso: ???
Feature: STYLE_MOTIF
-Description: Supports a Motif look and feel.
+Description: Supports a Motif look and feel.
Section: Styles
Requires:
Name: QMotifStyle
SeeAlso: ???
Feature: STYLE_CDE
-Description: Supports a CDE look and feel.
+Description: Supports a CDE look and feel.
Section: Styles
Requires: STYLE_MOTIF
Name: QCDEStyle
@@ -798,7 +798,7 @@ Name: QWindowsMobileStyle
SeeAlso: ???
Feature: STYLE_STYLESHEET
-Description:
+Description:
Section: Styles
Requires: STYLE_WINDOWS PROPERTIES CSSPARSER
Name: QStyleSheetStyle
@@ -809,14 +809,14 @@ SeeAlso: ???
Feature: IMAGEFORMATPLUGIN
Description: Supports writing an image format plugin.
Section: Images
-Requires:
+Requires:
Name: QImageIOPlugin
SeeAlso: ???
Feature: ICON
Description: Supports scalable icons in different modes and states.
Section: Images
-Requires:
+Requires:
Name: QIcon
SeeAlso: ???
@@ -837,14 +837,14 @@ SeeAlso: ???
Feature: IMAGEFORMAT_PPM
Description: Supports the Portable Pixmap image file format.
Section: Images
-Requires:
+Requires:
Name: PPM Image Format
SeeAlso: ???
Feature: IMAGEFORMAT_XBM
Description: Supports the X11 Bitmap image file format.
Section: Images
-Requires:
+Requires:
Name: XBM Image Format
SeeAlso: ???
@@ -858,14 +858,14 @@ SeeAlso: ???
Feature: IMAGEFORMAT_PNG
Description: Supports the Portable Network Graphics image file format.
Section: Images
-Requires:
+Requires:
Name: PNG Image Format
SeeAlso: ???
Feature: IMAGEFORMAT_JPEG
Description: Supports the Joint Photographic Experts Group image file format.
Section: Images
-Requires:
+Requires:
Name: JPEG Image Format
SeeAlso: ???
@@ -895,7 +895,7 @@ SeeAlso: ???
Feature: PICTURE
Description: Supports recording and replaying QPainter commands.
Section: Painting
-Requires:
+Requires:
Name: QPicture
SeeAlso: ???
@@ -908,9 +908,9 @@ Name: Color Names
SeeAlso: ???
Feature: PRINTER
-Description: Supports printing
+Description: Supports printing
Section: Painting
-Requires: TEXTSTREAM
+Requires: TEXTSTREAM PICTURE
Name: QPrinter
SeeAlso: ???
@@ -952,7 +952,7 @@ Name: Freetype Font Engine
SeeAlso: ???
Feature: QWS_QPF
-Description: Supports Qt's pre-rendered fonts, a light-weight non-scalable font format
+Description: Supports Qt's pre-rendered fonts, a light-weight non-scalable font format
specific to Qt for Embedded Linux.
Section: Fonts
Requires:
@@ -960,7 +960,7 @@ Name: Qt Prerendered Font Format
SeeAlso: ???
Feature: QWS_QPF2
-Description: Supports Qt's second generation of pre-rendered fonts, a light-weight
+Description: Supports Qt's second generation of pre-rendered fonts, a light-weight
non-scalable font format specific to Qt for Embedded Linux.
Section: Fonts
Requires:
@@ -987,7 +987,7 @@ Feature: TRANSLATION_UTF8
Description: Supports translations using QObject::trUtf8().
Section: Internationalization
Requires: TRANSLATION TEXTCODEC
-Name: Translation (UTF-8 representation)
+Name: Translation (UTF-8 representation)
SeeAlso: ???
Feature: TEXTCODEC
@@ -1007,14 +1007,14 @@ SeeAlso: ???
Feature: BIG_CODECS
Description: Supports big codecs, e.g. CJK.
Section: Internationalization
-Requires:
+Requires:
Name: Big Codecs
SeeAlso: ???
Feature: QWS_INPUTMETHODS
Description: Supports international input methods.
Section: Internationalization
-Requires:
+Requires:
Name: QWSInputMethod
SeeAlso: ???
@@ -1023,14 +1023,14 @@ SeeAlso: ???
Feature: URLINFO
Description: Supports storage of URL information.
Section: Networking
-Requires:
+Requires:
Name: QUrlInfo
SeeAlso: ???
Feature: HOSTINFO
Description: Supports host name lookups.
Section: Networking
-Requires: TEXTSTREAM
+Requires: TEXTSTREAM
Name: QHostInfo
SeeAlso: ???
@@ -1051,14 +1051,14 @@ SeeAlso: ???
Feature: UDPSOCKET
Description: Supports User Datagram Protocol sockets.
Section: Networking
-Requires:
+Requires:
Name: QUdpSocket
SeeAlso: ???
Feature: NETWORKPROXY
Description: Supports configuring network layer proxy support to the Qt network classes.
Section: Networking
-Requires:
+Requires:
Name: QNetworkProxy
SeeAlso: ???
@@ -1130,7 +1130,7 @@ Name: QUndoStack
SeeAlso: ???
Feature: UNDOGROUP
-Description:
+Description:
Section: Utilities
Requires: UNDOCOMMAND UNDOSTACK
Name: QUndoGroup
@@ -1188,7 +1188,7 @@ Name: QSvgRenderer
SeeAlso: ???
Feature: SVGWIDGET
-Description: Provides a widget that is used to display the contents of SVG files.
+Description: Provides a widget that is used to display the contents of SVG files.
Section: SVG
Requires: SVGRENDERER
Name: QSvgWidget
@@ -1240,21 +1240,21 @@ Name: Manager
SeeAlso: ???
Feature: QWS_DECORATION_DEFAULT
-Description: Supports default decoration of the top level windows.
+Description: Supports default decoration of the top level windows.
Section: Qt for Embedded Linux
-Requires:
+Requires:
Name: Decoration
SeeAlso: ???
Feature: QWS_DECORATION_WINDOWS
-Description: Supports a "Windows" style decoration of the top level windows.
+Description: Supports a "Windows" style decoration of the top level windows.
Section: Qt for Embedded Linux
Requires: QWS_DECORATION_DEFAULT
Name: Decoration (Windows Style)
SeeAlso: ???
Feature: QWS_DECORATION_STYLED
-Description: Supports styled decoration of the top level windows.
+Description: Supports styled decoration of the top level windows.
Section: Qt for Embedded Linux
Requires: QWS_DECORATION_DEFAULT
Name: Decoration (Styled)
@@ -1402,13 +1402,13 @@ SeeAlso: ???
Feature: PHONON_MEDIACONTROLLER
Description: Support for the MediaController class
Section: Phonon
-Requires:
+Requires:
Name: Phonon::MediaController
SeeAlso: ???
Feature: PHONON_ABSTRACTMEDIASTREAM
Description: Support for streaming of raw data (QIODevice...)
Section: Phonon
-Requires:
+Requires:
Name: Phonon::AbstractMediaStream
SeeAlso: ???
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 459167e..ce98ec4 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1054,6 +1054,7 @@ bool qSharedBuild()
\value WV_XP Windows XP (operating system version 5.1)
\value WV_2003 Windows Server 2003, Windows Server 2003 R2, Windows Home Server, Windows XP Professional x64 Edition (operating system version 5.2)
\value WV_VISTA Windows Vista, Windows Server 2008 (operating system version 6.0)
+ \value WV_WINDOWS7 Windows 7 (operating system version 6.1)
Alternatively, you may use the following macros which correspond directly to the Windows operating system version number:
@@ -1062,6 +1063,7 @@ bool qSharedBuild()
\value WV_5_1 Operating system version 5.1, corresponds to Windows XP
\value WV_5_2 Operating system version 5.2, corresponds to Windows Server 2003, Windows Server 2003 R2, Windows Home Server, and Windows XP Professional x64 Edition
\value WV_6_0 Operating system version 6.0, corresponds to Windows Vista and Windows Server 2008
+ \value WV_6_1 Operating system version 6.1, corresponds to Windows 7
CE-based versions:
@@ -1095,6 +1097,7 @@ bool qSharedBuild()
\value MV_10_3 Mac OS X 10.3
\value MV_10_4 Mac OS X 10.4
\value MV_10_5 Mac OS X 10.5
+ \value MV_10_6 Mac OS X 10.6
\value MV_Unknown An unknown and currently unsupported platform
\value MV_CHEETAH Apple codename for MV_10_0
@@ -1103,6 +1106,7 @@ bool qSharedBuild()
\value MV_PANTHER Apple codename for MV_10_3
\value MV_TIGER Apple codename for MV_10_4
\value MV_LEOPARD Apple codename for MV_10_5
+ \value MV_SNOWLEOPARD Apple codename for MV_10_6
\sa WinVersion
*/
@@ -1631,16 +1635,19 @@ QSysInfo::WinVersion QSysInfo::windowsVersion()
default: // VER_PLATFORM_WIN32_NT
if (osver.dwMajorVersion < 5) {
winver = QSysInfo::WV_NT;
- } else if (osver.dwMajorVersion == 6) {
- winver = QSysInfo::WV_VISTA;
- } else if (osver.dwMinorVersion == 0) {
+ } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 0) {
winver = QSysInfo::WV_2000;
- } else if (osver.dwMinorVersion == 1) {
+ } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 1) {
winver = QSysInfo::WV_XP;
- } else if (osver.dwMinorVersion == 2) {
+ } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 2) {
winver = QSysInfo::WV_2003;
+ } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 0) {
+ winver = QSysInfo::WV_VISTA;
+ } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1) {
+ winver = QSysInfo::WV_WINDOWS7;
} else {
- qWarning("Qt: Untested Windows version detected!");
+ qWarning("Qt: Untested Windows version %d.%d detected!",
+ osver.dwMajorVersion, osver.dwMinorVersion);
winver = QSysInfo::WV_NT_based;
}
}
@@ -1667,6 +1674,8 @@ QSysInfo::WinVersion QSysInfo::windowsVersion()
winver = QSysInfo::WV_XP;
else if (override == "VISTA")
winver = QSysInfo::WV_VISTA;
+ else if (override == "WINDOWS7")
+ winver = QSysInfo::WV_WINDOWS7;
}
#endif
@@ -1925,9 +1934,11 @@ QString qt_error_string(int errorCode)
The message handler is a function that prints out debug messages,
warnings, critical and fatal error messages. The Qt library (debug
- version) contains hundreds of warning messages that are printed
+ mode) contains hundreds of warning messages that are printed
when internal errors (usually invalid function arguments)
- occur. If you implement your own message handler, you get total
+ occur. Qt built in release mode also contains such warnings unless
+ QT_NO_WARNING_OUTPUT and/or QT_NO_DEBUG_OUTPUT have been set during
+ compilation. If you implement your own message handler, you get total
control of these messages.
The default message handler prints the message to the standard
@@ -2022,7 +2033,8 @@ void qt_message_output(QtMsgType msgType, const char *buf)
during compilation.
If you pass the function a format string and a list of arguments,
- it works in similar way to the C printf() function.
+ it works in similar way to the C printf() function. The format
+ should be a Latin-1 string.
Example:
@@ -2068,7 +2080,8 @@ void qDebug(const char *msg, ...)
QT_FATAL_WARNINGS is defined.
This function takes a format string and a list of arguments,
- similar to the C printf() function.
+ similar to the C printf() function. The format should be a Latin-1
+ string.
Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 26
@@ -2106,8 +2119,9 @@ void qWarning(const char *msg, ...)
message handler has been installed, the message is printed to
stderr. Under Windows, the message is sent to the debugger.
- This function takes a format string and a list of arguments, similar
- to the C printf() function.
+ This function takes a format string and a list of arguments,
+ similar to the C printf() function. The format should be a Latin-1
+ string.
Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 28
@@ -2931,6 +2945,11 @@ bool QInternal::callFunction(InternalFunction func, void **args)
Compares the floating point value \a p1 and \a p2 and
returns \c true if they are considered equal, otherwise \c false.
+ Note that comparing values where either \a p1 or \a p2 is 0.0 will not work.
+ The solution to this is to compare against values greater than or equal to 1.0.
+
+ \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 46
+
The two numbers are compared in a relative way, where the
exactness is stronger the smaller the numbers are.
*/
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 9522e39..f058b36 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -821,17 +821,12 @@ typedef quint64 qulonglong;
sizeof(void *) == sizeof(quintptr)
&& sizeof(void *) == sizeof(qptrdiff)
*/
-template <int> class QUintForSize { private: typedef void Type; };
-template <> class QUintForSize<4> { public: typedef quint32 Type; };
-template <> class QUintForSize<8> { public: typedef quint64 Type; };
-template <typename T> class QUintForType : public QUintForSize<sizeof(T)> { };
-typedef QUintForType<void *>::Type quintptr;
-
-template <int> class QIntForSize { private: typedef void Type; };
-template <> class QIntForSize<4> { public: typedef qint32 Type; };
-template <> class QIntForSize<8> { public: typedef qint64 Type; };
-template <typename T> class QIntForType : public QIntForSize<sizeof(T)> { };
-typedef QIntForType<void *>::Type qptrdiff;
+template <int> struct QIntegerForSize;
+template <> struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; };
+template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; };
+template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
+typedef QIntegerForSizeof<void*>::Unsigned quintptr;
+typedef QIntegerForSizeof<void*>::Signed qptrdiff;
/*
Useful type definitions for Qt
@@ -1309,6 +1304,7 @@ public:
WV_XP = 0x0030,
WV_2003 = 0x0040,
WV_VISTA = 0x0080,
+ WV_WINDOWS7 = 0x0090,
WV_NT_based = 0x00f0,
/* version numbers */
@@ -1317,6 +1313,7 @@ public:
WV_5_1 = WV_XP,
WV_5_2 = WV_2003,
WV_6_0 = WV_VISTA,
+ WV_6_1 = WV_WINDOWS7,
WV_CE = 0x0100,
WV_CENET = 0x0200,
@@ -1340,6 +1337,7 @@ public:
MV_10_3 = 0x0005,
MV_10_4 = 0x0006,
MV_10_5 = 0x0007,
+ MV_10_6 = 0x0008,
/* codenames */
MV_CHEETAH = MV_10_0,
@@ -1347,7 +1345,8 @@ public:
MV_JAGUAR = MV_10_2,
MV_PANTHER = MV_10_3,
MV_TIGER = MV_10_4,
- MV_LEOPARD = MV_10_5
+ MV_LEOPARD = MV_10_5,
+ MV_SNOWLEOPARD = MV_10_6
};
static const MacVersion MacintoshVersion;
#endif
@@ -1702,6 +1701,22 @@ static inline bool qFuzzyCompare(float p1, float p2)
return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2)));
}
+/*!
+ \internal
+*/
+static inline bool qFuzzyIsNull(double d)
+{
+ return qAbs(d) <= 0.000000000001;
+}
+
+/*!
+ \internal
+*/
+static inline bool qFuzzyIsNull(float f)
+{
+ return qAbs(f) <= 0.00001f;
+}
+
/*
This function tests a double for a null value. It doesn't
check whether the actual value is 0 or close to 0, but whether
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index fb7fa0c..a519f4a 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -280,9 +280,7 @@ public:
WindowStaysOnTopHint = 0x00040000,
// reserved for Qt3Support:
// WMouseNoMask = 0x00080000,
- WindowOkButtonHint = 0x00080000,
// WDestructiveClose = 0x00100000,
- WindowCancelButtonHint = 0x00100000,
// WStaticContents = 0x00200000,
// WGroupLeader = 0x00400000,
// WShowModal = 0x00800000,
@@ -291,7 +289,9 @@ public:
WindowStaysOnBottomHint = 0x04000000,
WindowCloseButtonHint = 0x08000000,
MacWindowToolBarButtonHint = 0x10000000,
- BypassGraphicsProxyWidget = 0x20000000
+ BypassGraphicsProxyWidget = 0x20000000,
+ WindowOkButtonHint = 0x00080000,
+ WindowCancelButtonHint = 0x00100000
#ifdef QT3_SUPPORT
,
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 6d75c59..d62328f 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -54,6 +54,8 @@
# include "qresource.h"
#endif
+#include "qvarlengtharray.h"
+
#include "../kernel/qcoreglobaldata_p.h"
#include <stdlib.h>
@@ -2065,11 +2067,13 @@ QString QDir::cleanPath(const QString &path)
QString name = path;
QChar dir_separator = separator();
if(dir_separator != QLatin1Char('/'))
- name.replace(dir_separator, QLatin1Char('/'));
+ name.replace(dir_separator, QLatin1Char('/'));
int used = 0, levels = 0;
const int len = name.length();
- QVector<QChar> out(len);
+ QVarLengthArray<QChar> outVector(len);
+ QChar *out = outVector.data();
+
const QChar *p = name.unicode();
for(int i = 0, last = -1, iwrite = 0; i < len; i++) {
if(p[i] == QLatin1Char('/')) {
@@ -2169,7 +2173,7 @@ QString QDir::cleanPath(const QString &path)
if(used == len)
ret = name;
else
- ret = QString(out.data(), used);
+ ret = QString(out, used);
// Strip away last slash except for root directories
if (ret.endsWith(QLatin1Char('/'))
@@ -2232,7 +2236,7 @@ QStringList QDir::nameFiltersFromString(const QString &nameFilter)
\snippet doc/src/snippets/code/src_corelib_io_qdir.cpp 13
- If the file name contains characters that cannot be part of a valid C++ function name
+ If the file name contains characters that cannot be part of a valid C++ function name
(such as '-'), they have to be replaced by the underscore character ('_').
Note: This macro cannot be used in a namespace. It should be called from
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index 46c7dd8..b14f436 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -116,7 +116,9 @@ public:
QAbstractFileEngine *engine;
QStack<QAbstractFileEngineIterator *> fileEngineIterators;
QString path;
- QFileInfo fileInfo;
+ QFileInfo nextFileInfo;
+ //This fileinfo is the current that we will return from the public API
+ QFileInfo currentFileInfo;
QString currentFilePath;
QDirIterator::IteratorFlags iteratorFlags;
QDir::Filters filters;
@@ -140,8 +142,8 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList
this->filters = filters;
this->nameFilters = nameFilters;
- fileInfo.setFile(path);
- pushSubDirectory(fileInfo.isSymLink() ? fileInfo.canonicalFilePath() : path,
+ nextFileInfo.setFile(path);
+ pushSubDirectory(nextFileInfo.isSymLink() ? nextFileInfo.canonicalFilePath() : path,
nameFilters, filters);
}
@@ -160,12 +162,12 @@ void QDirIteratorPrivate::pushSubDirectory(const QString &path, const QStringLis
QDir::Filters filters)
{
if (iteratorFlags & QDirIterator::FollowSymlinks) {
- if (fileInfo.filePath() != path)
- fileInfo.setFile(path);
- if (fileInfo.isSymLink()) {
- visitedLinks << fileInfo.canonicalFilePath();
+ if (nextFileInfo.filePath() != path)
+ nextFileInfo.setFile(path);
+ if (nextFileInfo.isSymLink()) {
+ visitedLinks << nextFileInfo.canonicalFilePath();
} else {
- visitedLinks << fileInfo.absoluteFilePath();
+ visitedLinks << nextFileInfo.absoluteFilePath();
}
}
@@ -199,8 +201,8 @@ void QDirIteratorPrivate::advance()
QString subDir = it->currentFilePath();
#ifdef Q_OS_WIN
- if (fileInfo.isSymLink())
- subDir = fileInfo.canonicalFilePath();
+ if (currentFileInfo.isSymLink())
+ subDir = currentFileInfo.canonicalFilePath();
#endif
pushSubDirectory(subDir, it->nameFilters(), it->filters());
}
@@ -213,15 +215,16 @@ void QDirIteratorPrivate::advance()
while (it->hasNext()) {
it->next();
if (matchesFilters(it)) {
- fileInfo = it->currentFileInfo();
+ currentFileInfo = nextFileInfo;
+ nextFileInfo = it->currentFileInfo();
// Signal that we want to follow this entry.
- followNextDir = shouldFollowDirectory(fileInfo);
-
+ followNextDir = shouldFollowDirectory(nextFileInfo);
//We found a matching entry.
return;
} else if (iteratorFlags & QDirIterator::Subdirectories) {
QFileInfo fileInfo = it->currentFileInfo();
+
if (!shouldFollowDirectory(fileInfo))
continue;
QString subDir = it->currentFilePath();
@@ -238,6 +241,7 @@ void QDirIteratorPrivate::advance()
if (!foundDirectory)
delete fileEngineIterators.pop();
}
+ currentFileInfo = nextFileInfo;
done = true;
}
@@ -518,9 +522,7 @@ bool QDirIterator::hasNext() const
*/
QString QDirIterator::fileName() const
{
- if (d->fileInfo.path() != d->currentFilePath)
- d->fileInfo.setFile(d->currentFilePath);
- return d->fileInfo.fileName();
+ return d->currentFileInfo.fileName();
}
/*!
@@ -543,9 +545,7 @@ QString QDirIterator::filePath() const
*/
QFileInfo QDirIterator::fileInfo() const
{
- if (d->fileInfo.filePath() != d->currentFilePath)
- d->fileInfo.setFile(d->currentFilePath);
- return d->fileInfo;
+ return d->currentFileInfo;
}
/*!
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index d8f08c9..d7da800 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -712,6 +712,9 @@ QFile::rename(const QString &newName)
if(error() == QFile::NoError) {
if (fileEngine()->rename(newName)) {
unsetError();
+ // engine was able to handle the new name so we just reset it
+ fileEngine()->setFileName(newName);
+ d->fileName = newName;
return true;
}
@@ -731,10 +734,18 @@ QFile::rename(const QString &newName)
}
if (read == -1) {
d->setError(QFile::RenameError, in.errorString());
- return true;
+ error = true;
+ }
+ if(!error) {
+ if (!in.remove()) {
+ d->setError(QFile::RenameError, tr("Cannot remove source file"));
+ error = true;
+ }
}
- if(!error)
- in.remove();
+ if (error)
+ out.remove();
+ else
+ setFileName(newName);
return !error;
}
}
@@ -889,7 +900,10 @@ QFile::copy(const QString &newName)
error = true;
d->setError(QFile::CopyError, tr("Cannot create %1 for output").arg(newName));
}
-#ifndef QT_NO_TEMPORARYFILE
+#ifdef QT_NO_TEMPORARYFILE
+ if (error)
+ out.remove();
+#else
if (!error)
out.setAutoRemove(false);
#endif
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 96e0f82..a8d28cb 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -537,8 +537,7 @@ QFileInfo &QFileInfo::operator=(const QFileInfo &fileinfo)
void QFileInfo::setFile(const QString &file)
{
- Q_D(QFileInfo);
- d->initFileEngine(file);
+ *this = QFileInfo(file);
}
/*!
@@ -555,8 +554,7 @@ void QFileInfo::setFile(const QString &file)
void QFileInfo::setFile(const QFile &file)
{
- Q_D(QFileInfo);
- d->initFileEngine(file.fileName());
+ *this = QFileInfo(file.fileName());
}
/*!
@@ -574,7 +572,7 @@ void QFileInfo::setFile(const QFile &file)
void QFileInfo::setFile(const QDir &dir, const QString &file)
{
Q_D(QFileInfo);
- d->initFileEngine(dir.filePath(file));
+ *this = QFileInfo(dir.filePath(file));
}
/*!
@@ -921,7 +919,7 @@ QString QFileInfo::suffix() const
\bold{Note:} The QDir returned always corresponds to the object's
parent directory, even if the QFileInfo represents a directory.
-
+
For each of the follwing, dir() returns a QDir for
\c{"~/examples/191697"}.
diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp
index 4445e3c..fa44531 100644
--- a/src/corelib/io/qfilesystemwatcher_inotify.cpp
+++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp
@@ -316,7 +316,7 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
// qDebug() << "QInotifyFileSystemWatcherEngine::readFromInotify";
int buffSize = 0;
- ioctl(inotifyFd, FIONREAD, &buffSize);
+ ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
QVarLengthArray<char, 4096> buffer(buffSize);
buffSize = read(inotifyFd, buffer.data(), buffSize);
const char *at = buffer.data();
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 0d88b06..8a0a3f5 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -935,6 +935,8 @@ bool QFSFileEngine::setSize(qint64 size)
Q_D(QFSFileEngine);
if (d->fd != -1)
return !QT_FTRUNCATE(d->fd, size);
+ if (d->fh)
+ return !QT_FTRUNCATE(QT_FILENO(d->fh), size);
return !QT_TRUNCATE(d->nativeFilePath.constData(), size);
}
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index c739054..b6c4eb1 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -48,6 +48,10 @@
#include "qstringlist.h"
#include <limits.h>
+#ifdef QIODEVICE_DEBUG
+# include <ctype.h>
+#endif
+
QT_BEGIN_NAMESPACE
#ifdef QIODEVICE_DEBUG
@@ -362,7 +366,7 @@ QIODevice::QIODevice()
{
#if defined QIODEVICE_DEBUG
QFile *file = qobject_cast<QFile *>(this);
- printf("%p QIODevice::QIODevice(\"%s\") %s\n", this, className(),
+ printf("%p QIODevice::QIODevice(\"%s\") %s\n", this, metaObject()->className(),
qPrintable(file ? file->fileName() : QString()));
#endif
}
@@ -375,7 +379,7 @@ QIODevice::QIODevice(QObject *parent)
: QObject(*new QIODevicePrivate, parent)
{
#if defined QIODEVICE_DEBUG
- printf("%p QIODevice::QIODevice(%p \"%s\")\n", this, parent, className());
+ printf("%p QIODevice::QIODevice(%p \"%s\")\n", this, parent, metaObject()->className());
#endif
}
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 759d473..30f4291 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1555,11 +1555,15 @@ QByteArray QProcess::readAllStandardError()
}
/*!
- Starts the program \a program in a new process, passing the
- command line arguments in \a arguments. The OpenMode is set to \a
- mode. QProcess will immediately enter the Starting state. If the
- process starts successfully, QProcess will emit started();
- otherwise, error() will be emitted.
+ Starts the program \a program in a new process, if one is not already
+ running, passing the command line arguments in \a arguments. The OpenMode
+ is set to \a mode.
+
+ The QProcess object will immediately enter the Starting state. If the
+ process starts successfully, QProcess will emit started(); otherwise,
+ error() will be emitted. If the QProcess object is already running a
+ process, a warning may be printed at the console, and the existing
+ process will continue running.
Note that arguments that contain spaces are not passed to the
process as separate arguments.
@@ -1656,10 +1660,10 @@ static QStringList parseCombinedArgString(const QString &program)
/*!
\overload
- Starts the program \a program in a new process. \a program is a
- single string of text containing both the program name and its
- arguments. The arguments are separated by one or more
- spaces. For example:
+ Starts the program \a program in a new process, if one is not already
+ running. \a program is a single string of text containing both the
+ program name and its arguments. The arguments are separated by one or
+ more spaces. For example:
\snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 5
@@ -1668,6 +1672,9 @@ static QStringList parseCombinedArgString(const QString &program)
\snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 6
+ If the QProcess object is already running a process, a warning may be
+ printed at the console, and the existing process will continue running.
+
Note that, on Windows, quotes need to be both escaped and quoted.
For example, the above code would be specified in the following
way to ensure that \c{"My Documents"} is used as the argument to
@@ -1680,6 +1687,13 @@ static QStringList parseCombinedArgString(const QString &program)
void QProcess::start(const QString &program, OpenMode mode)
{
QStringList args = parseCombinedArgString(program);
+ if (args.isEmpty()) {
+ Q_D(QProcess);
+ d->processError = QProcess::FailedToStart;
+ setErrorString(tr("No program defined"));
+ emit error(d->processError);
+ return;
+ }
QString prog = args.first();
args.removeFirst();
@@ -1848,6 +1862,8 @@ bool QProcess::startDetached(const QString &program,
bool QProcess::startDetached(const QString &program)
{
QStringList args = parseCombinedArgString(program);
+ if (args.isEmpty())
+ return false;
QString prog = args.first();
args.removeFirst();
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 5537c9d..2f05f6e 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -856,10 +856,10 @@ bool QProcessPrivate::processStarted()
qint64 QProcessPrivate::bytesAvailableFromStdout() const
{
- size_t nbytes = 0;
+ int nbytes = 0;
qint64 available = 0;
if (::ioctl(stdoutChannel.pipe[0], FIONREAD, (char *) &nbytes) >= 0)
- available = (qint64) *((int *) &nbytes);
+ available = (qint64) nbytes;
#if defined (QPROCESS_DEBUG)
qDebug("QProcessPrivate::bytesAvailableFromStdout() == %lld", available);
#endif
@@ -868,10 +868,10 @@ qint64 QProcessPrivate::bytesAvailableFromStdout() const
qint64 QProcessPrivate::bytesAvailableFromStderr() const
{
- size_t nbytes = 0;
+ int nbytes = 0;
qint64 available = 0;
if (::ioctl(stderrChannel.pipe[0], FIONREAD, (char *) &nbytes) >= 0)
- available = (qint64) *((int *) &nbytes);
+ available = (qint64) nbytes;
#if defined (QPROCESS_DEBUG)
qDebug("QProcessPrivate::bytesAvailableFromStderr() == %lld", available);
#endif
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index a1f921e..779a742 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -60,6 +60,37 @@
QT_BEGIN_NAMESPACE
+
+class QStringSplitter
+{
+public:
+ QStringSplitter(const QString &s)
+ : m_string(s), m_data(m_string.constData()), m_len(s.length()), m_pos(0)
+ {
+ m_splitChar = QLatin1Char('/');
+ }
+
+ inline bool hasNext() {
+ while (m_pos < m_len && m_data[m_pos] == m_splitChar)
+ ++m_pos;
+ return m_pos < m_len;
+ }
+
+ inline QStringRef next() {
+ int start = m_pos;
+ while (m_pos < m_len && m_data[m_pos] != m_splitChar)
+ ++m_pos;
+ return QStringRef(&m_string, start, m_pos - start);
+ }
+
+ QString m_string;
+ const QChar *m_data;
+ QChar m_splitChar;
+ int m_len;
+ int m_pos;
+};
+
+
//resource glue
class QResourceRoot
{
@@ -101,6 +132,16 @@ protected:
}
};
+static QString cleanPath(const QString &_path)
+{
+ QString path = QDir::cleanPath(_path);
+ // QDir::cleanPath does not remove two trailing slashes under _Windows_
+ // due to support for UNC paths. Remove those manually.
+ if (path.startsWith(QLatin1String("//")))
+ path.remove(0, 1);
+ return path;
+}
+
Q_DECLARE_TYPEINFO(QResourceRoot, Q_MOVABLE_TYPE);
Q_GLOBAL_STATIC_WITH_ARGS(QMutex, resourceMutex, (QMutex::Recursive))
@@ -216,9 +257,10 @@ QResourcePrivate::load(const QString &file)
related.clear();
QMutexLocker lock(resourceMutex());
const ResourceList *list = resourceList();
+ QString cleaned = cleanPath(file);
for(int i = 0; i < list->size(); ++i) {
QResourceRoot *res = list->at(i);
- const int node = res->findNode(file);
+ const int node = res->findNode(cleaned);
if(node != -1) {
if(related.isEmpty()) {
container = res->isContainer(node);
@@ -292,6 +334,7 @@ QResourcePrivate::ensureChildren() const
if(path.startsWith(QLatin1Char(':')))
path = path.mid(1);
QSet<QString> kids;
+ QString cleaned = cleanPath(path);
for(int i = 0; i < related.size(); ++i) {
QResourceRoot *res = related.at(i);
if(res->mappingRootSubdir(path, &k) && !k.isEmpty()) {
@@ -300,7 +343,7 @@ QResourcePrivate::ensureChildren() const
kids.insert(k);
}
} else {
- const int node = res->findNode(path);
+ const int node = res->findNode(cleaned);
if(node != -1) {
QStringList related_children = res->children(node);
for(int kid = 0; kid < related_children.size(); ++kid) {
@@ -562,18 +605,20 @@ inline QString QResourceRoot::name(int node) const
(names[name_offset+1] << 0);
name_offset += 2;
name_offset += 4; //jump past hash
- for(int i = 0; i < name_length*2; i+=2)
- ret += QChar(names[name_offset+i+1], names[name_offset+i]);
+
+ ret.resize(name_length);
+ QChar *strData = ret.data();
+ for(int i = 0; i < name_length*2; i+=2) {
+ QChar c(names[name_offset+i+1], names[name_offset+i]);
+ *strData = c;
+ ++strData;
+ }
return ret;
}
+
int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
{
- QString path = QDir::cleanPath(_path);
- // QDir::cleanPath does not remove two trailing slashes under _Windows_
- // due to support for UNC paths. Remove those manually.
- if (path.startsWith(QLatin1String("//")))
- path.remove(0, 1);
-
+ QString path = _path;
{
QString root = mappingRoot();
if(!root.isEmpty()) {
@@ -604,12 +649,11 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
//now iterate up the tree
int node = -1;
- QStringList segments = path.split(QLatin1Char('/'), QString::SkipEmptyParts);
-#ifdef DEBUG_RESOURCE_MATCH
- qDebug() << "****" << segments;
-#endif
- for(int i = 0; child_count && i < segments.size(); ++i) {
- const QString &segment = segments[i];
+
+ QStringSplitter splitter(path);
+ while (child_count && splitter.hasNext()) {
+ QStringRef segment = splitter.next();
+
#ifdef DEBUG_RESOURCE_MATCH
qDebug() << " CHILDREN" << segment;
for(int j = 0; j < child_count; ++j) {
@@ -651,7 +695,7 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
(tree[offset+1] << 0);
offset += 2;
- if(i == segments.size()-1) {
+ if(!splitter.hasNext()) {
if(!(flags & Directory)) {
const short country = (tree[offset+0] << 8) +
(tree[offset+1] << 0);
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 62b4ed5..484e79a 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -2330,6 +2330,10 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
\o \c{HKEY_LOCAL_MACHINE\Software\MySoft}
\endlist
+ \note On Windows, for 32-bit programs running in WOW64 mode, settings are
+ stored in the following registry path:
+ \c{HKEY_LOCAL_MACHINE\Software\WOW6432node}.
+
If the file format is IniFormat, the following files are
used on Unix and Mac OS X:
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 3cfce83..6a7b067 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -268,11 +268,13 @@ static int _gettemp(char *path, int *doopen, int domkdir, int slen)
/*NOTREACHED*/
}
+#ifndef Q_WS_WIN
static int qt_mkstemps(char *path, int slen)
{
int fd = 0;
return (_gettemp(path, &fd, 0, slen) ? fd : -1);
}
+#endif
//************* QTemporaryFileEngine
class QTemporaryFileEngine : public QFSFileEngine
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 512332e..73408dc 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -409,6 +409,7 @@ public:
QString writeBuffer;
QString readBuffer;
int readBufferOffset;
+ int readConverterSavedStateOffset; //the offset between readBufferStartDevicePos and that start of the buffer
qint64 readBufferStartDevicePos;
// streaming parameters
@@ -435,6 +436,7 @@ QTextStreamPrivate::QTextStreamPrivate(QTextStream *q_ptr)
#ifndef QT_NO_TEXTCODEC
readConverterSavedState(0),
#endif
+ readConverterSavedStateOffset(0),
locale(QLocale::C)
{
this->q_ptr = q_ptr;
@@ -833,6 +835,10 @@ inline void QTextStreamPrivate::consume(int size)
readBufferOffset = 0;
readBuffer.clear();
saveConverterState(device->pos());
+ } else if (readBufferOffset > QTEXTSTREAM_BUFFERSIZE) {
+ readBuffer = readBuffer.remove(0,readBufferOffset);
+ readConverterSavedStateOffset += readBufferOffset;
+ readBufferOffset = 0;
}
}
}
@@ -854,6 +860,7 @@ inline void QTextStreamPrivate::saveConverterState(qint64 newPos)
#endif
readBufferStartDevicePos = newPos;
+ readConverterSavedStateOffset = 0;
}
/*! \internal
@@ -1218,7 +1225,7 @@ qint64 QTextStream::pos() const
// Rewind the device to get to the current position Ensure that
// readBufferOffset is unaffected by fillReadBuffer()
- int oldReadBufferOffset = d->readBufferOffset;
+ int oldReadBufferOffset = d->readBufferOffset + d->readConverterSavedStateOffset;
while (d->readBuffer.size() < oldReadBufferOffset) {
if (!thatd->fillReadBuffer(1))
return qint64(-1);
@@ -1370,7 +1377,7 @@ QTextStream::FieldAlignment QTextStream::fieldAlignment() const
\snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 5
- The string \a s contains:
+ The string \c s contains:
\snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 6
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index b3f9f1a..a23b2dd 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -377,6 +377,14 @@ QString qAppName()
QLibrary) can be retrieved with libraryPaths() and manipulated by
setLibraryPaths(), addLibraryPath(), and removeLibraryPath().
+ On Unix/Linux Qt is configured to use the system local settings by
+ default. This can cause a conflict when using POSIX functions, for
+ instance, when converting between data types such as floats and
+ strings, since the notation may differ between locales. To get
+ around this problem call the POSIX function setlocale(LC_NUMERIC,"C")
+ right after initializing QApplication or QCoreApplication to reset
+ the locale that is used for number formatting to "C"-locale.
+
\sa QApplication, QAbstractEventDispatcher, QEventLoop,
{Semaphores Example}, {Wait Conditions Example}
*/
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index 5487703..fa472e6 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -264,6 +264,7 @@ public:
GrabKeyboard = 188,
UngrabKeyboard = 189,
CocoaRequestModal = 190, // Internal for requesting an application modal Cocoa Window
+ MacGLClearDrawable = 191, // Internal Cocoa, the window has changed, so we must clear
// 512 reserved for Qt Jambi's MetaCall event
// 513 reserved for Qt Jambi's DeleteOnMainThread event
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 880e95c..c4061f4 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -1059,11 +1059,20 @@ bool QEventDispatcherWin32::event(QEvent *e)
QZeroTimerEvent *zte = static_cast<QZeroTimerEvent*>(e);
WinTimerInfo *t = d->timerDict.value(zte->timerId());
if (t) {
+ t->inTimerEvent = true;
+
QTimerEvent te(zte->timerId());
QCoreApplication::sendEvent(t->obj, &te);
- WinTimerInfo *tn = d->timerDict.value(zte->timerId());
- if (tn && t == tn)
- QCoreApplication::postEvent(this, new QZeroTimerEvent(zte->timerId()));
+
+ t = d->timerDict.value(zte->timerId());
+ if (t) {
+ if (t->interval == 0 && t->inTimerEvent) {
+ // post the next zero timer event as long as the timer was not restarted
+ QCoreApplication::postEvent(this, new QZeroTimerEvent(zte->timerId()));
+ }
+
+ t->inTimerEvent = false;
+ }
}
return true;
} else if (e->type() == QEvent::Timer) {
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 719398c..b65f956 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -1007,6 +1007,11 @@ enum { MaximumParamCount = 11 }; // up to 10 arguments + 1 return value
a QEvent will be sent and the member is invoked as soon as the application
enters the main event loop.
+ \o If \a type is Qt::BlockingQueuedConnection, the method will be invoked in
+ the same way as for Qt::QueuedConnection, except that the current thread
+ will block until the event is delivered. Using this connection type to
+ communicate between objects in the same thread will lead to deadlocks.
+
\o If \a type is Qt::AutoConnection, the member is invoked
synchronously if \a obj lives in the same thread as the
caller; otherwise it will invoke the member asynchronously.
@@ -1897,6 +1902,12 @@ static QByteArray qualifiedName(const QMetaEnum &e)
\ingroup objectmodel
+ Property meta-data is obtained from an object's meta-object. See
+ QMetaObject::property() and QMetaObject::propertyCount() for
+ details.
+
+ \section1 Property Meta-Data
+
A property has a name() and a type(), as well as various
attributes that specify its behavior: isReadable(), isWritable(),
isDesignable(), isScriptable(), and isStored().
@@ -1912,9 +1923,10 @@ static QByteArray qualifiedName(const QMetaEnum &e)
functions. See QObject::setProperty() and QObject::property() for
details.
- You get property meta-data through an object's meta-object. See
- QMetaObject::property() and QMetaObject::propertyCount() for
- details.
+ \section1 Copying and Assignment
+
+ QMetaProperty objects can be copied by value. However, each copy will
+ refer to the same underlying property meta-data.
\sa QMetaObject, QMetaEnum, QMetaMethod, {Qt's Property System}
*/
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 4d7d309..ce10bae 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -1255,7 +1255,7 @@ void QMetaType::destroy(int type, void *data)
\relates QMetaType
\threadsafe
- Registers the type name \a typeName to the type \c{T}. Returns
+ Registers the type name \a typeName for the type \c{T}. Returns
the internal ID used by QMetaType. Any class or struct that has a
public default constructor, a public copy constructor and a public
destructor can be registered.
diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp
index 487c653..cd248dc 100644
--- a/src/corelib/kernel/qsharedmemory_unix.cpp
+++ b/src/corelib/kernel/qsharedmemory_unix.cpp
@@ -47,12 +47,9 @@
#include <qdir.h>
#include <qdebug.h>
-#include <errno.h>
-
-QT_BEGIN_NAMESPACE
-
#ifndef QT_NO_SHAREDMEMORY
+#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
@@ -61,6 +58,8 @@ QT_BEGIN_NAMESPACE
#include <fcntl.h>
#include <unistd.h>
+QT_BEGIN_NAMESPACE
+
QSharedMemoryPrivate::QSharedMemoryPrivate()
: QObjectPrivate(), memory(0), size(0), error(QSharedMemory::NoError),
#ifndef QT_NO_SYSTEMSEMAPHORE
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index cdddf36..77d6599 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -95,8 +95,7 @@ static bool match(const uchar* found, const char* target, uint len)
// (normalize it to be without the zero-terminating symbol)
if (len > 0 && found[len-1] == '\0')
--len;
- // 0 means anything, "" means empty
- return !found || (qstrncmp((const char *)found, target, len) == 0 && target[len] == '\0');
+ return (memcmp(found, target, len) == 0 && target[len] == '\0');
}
static uint elfHash(const char *name)
@@ -765,8 +764,6 @@ void QTranslatorPrivate::clear()
}
/*!
- \since 4.5
-
Returns the translation for the key (\a context, \a sourceText,
\a disambiguation). If none is found, also tries (\a context, \a
sourceText, ""). If that still fails, returns an empty string.
diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp
index 71ecab5..96a9940 100644
--- a/src/corelib/thread/qmutexpool.cpp
+++ b/src/corelib/thread/qmutexpool.cpp
@@ -96,9 +96,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (true))
QMutexPool is destructed.
*/
QMutexPool::QMutexPool(bool recursive, int size)
- : count(size), recurs(recursive)
+ : mutexes(size), count(size), recurs(recursive)
{
- mutexes = new QMutex*[count];
for (int index = 0; index < count; ++index) {
mutexes[index] = 0;
}
@@ -110,13 +109,10 @@ QMutexPool::QMutexPool(bool recursive, int size)
*/
QMutexPool::~QMutexPool()
{
- QMutexLocker locker(&mutex);
for (int index = 0; index < count; ++index) {
delete mutexes[index];
mutexes[index] = 0;
}
- delete [] mutexes;
- mutexes = 0;
}
/*!
@@ -138,12 +134,9 @@ QMutex *QMutexPool::get(const void *address)
if (!mutexes[index]) {
// mutex not created, create one
-
- QMutexLocker locker(&mutex);
- // we need to check once again that the mutex hasn't been created, since
- // 2 threads could be trying to create a mutex at the same index...
- if (!mutexes[index])
- mutexes[index] = new QMutex(recurs ? QMutex::Recursive : QMutex::NonRecursive);
+ QMutex *newMutex = new QMutex(recurs ? QMutex::Recursive : QMutex::NonRecursive);
+ if (!mutexes[index].testAndSetOrdered(0, newMutex))
+ delete newMutex;
}
return mutexes[index];
diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h
index 65a3b54..1009ebb 100644
--- a/src/corelib/thread/qmutexpool_p.h
+++ b/src/corelib/thread/qmutexpool_p.h
@@ -53,7 +53,9 @@
// We mean it.
//
+#include "QtCore/qatomic.h"
#include "QtCore/qmutex.h"
+#include "QtCore/qvarlengtharray.h"
#ifndef QT_NO_THREAD
@@ -70,8 +72,7 @@ public:
static QMutex *globalInstanceGet(const void *address);
private:
- QMutex mutex;
- QMutex **mutexes;
+ QVarLengthArray<QAtomicPointer<QMutex>, 128> mutexes;
int count;
bool recurs;
};
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 7f87897..2fb6335 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -297,6 +297,12 @@ void QAdoptedThread::run()
priority parameter. If the thread is already running, this
function does nothing.
+ The effect of the \a priority parameter is dependent on the
+ operating system's scheduling policy. In particular, the \a priority
+ will be ignored on systems that do not support thread priorities
+ (such as on Linux, see http://linux.die.net/man/2/sched_setscheduler
+ for more details).
+
\sa run(), terminate()
*/
@@ -590,6 +596,12 @@ void QThread::cleanup()
The \a priority argument can be any value in the \c
QThread::Priority enum except for \c InheritPriorty.
+ The effect of the \a priority parameter is dependent on the
+ operating system's scheduling policy. In particular, the \a priority
+ will be ignored on systems that do not support thread priorities
+ (such as on Linux, see http://linux.die.net/man/2/sched_setscheduler
+ for more details).
+
\sa Priority priority() start()
*/
diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp
index a3cbecc..c454224 100644
--- a/src/corelib/tools/qlinkedlist.cpp
+++ b/src/corelib/tools/qlinkedlist.cpp
@@ -652,7 +652,7 @@ QLinkedListData QLinkedListData::shared_null = {
Constructs an uninitialized iterator.
Functions like operator*() and operator++() should not be called
- on an uninitialized iterartor. Use operator=() to assign a value
+ on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
\sa QLinkedList::begin() QLinkedList::end()
@@ -858,7 +858,7 @@ QLinkedListData QLinkedListData::shared_null = {
Constructs an uninitialized iterator.
Functions like operator*() and operator++() should not be called
- on an uninitialized iterartor. Use operator=() to assign a value
+ on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
\sa QLinkedList::constBegin() QLinkedList::constEnd()
diff --git a/src/corelib/tools/qlistdata.cpp b/src/corelib/tools/qlistdata.cpp
index 2b1c086..d7c39a7 100644
--- a/src/corelib/tools/qlistdata.cpp
+++ b/src/corelib/tools/qlistdata.cpp
@@ -1193,7 +1193,7 @@ void **QListData::erase(void **xi)
Constructs an uninitialized iterator.
Functions like operator*() and operator++() should not be called
- on an uninitialized iterartor. Use operator=() to assign a value
+ on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
\sa QList::begin() QList::end()
@@ -1416,7 +1416,7 @@ void **QListData::erase(void **xi)
Constructs an uninitialized iterator.
Functions like operator*() and operator++() should not be called
- on an uninitialized iterartor. Use operator=() to assign a value
+ on an uninitialized iterator. Use operator=() to assign a value
to it before using it.
\sa QList::constBegin() QList::constEnd()
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index db2fc26..559ba81 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -4399,7 +4399,8 @@ double QLocalePrivate::stringToDouble(const QString &number, bool *ok,
GroupSeparatorMode group_sep_mode) const
{
CharBuff buff;
- if (!numberToCLocale(number, group_sep_mode, &buff)) {
+ if (!numberToCLocale(group().unicode() == 0xa0 ? number.trimmed() : number,
+ group_sep_mode, &buff)) {
if (ok != 0)
*ok = false;
return 0.0;
@@ -4411,7 +4412,8 @@ qlonglong QLocalePrivate::stringToLongLong(const QString &number, int base,
bool *ok, GroupSeparatorMode group_sep_mode) const
{
CharBuff buff;
- if (!numberToCLocale(number, group_sep_mode, &buff)) {
+ if (!numberToCLocale(group().unicode() == 0xa0 ? number.trimmed() : number,
+ group_sep_mode, &buff)) {
if (ok != 0)
*ok = false;
return 0;
@@ -4424,7 +4426,8 @@ qulonglong QLocalePrivate::stringToUnsLongLong(const QString &number, int base,
bool *ok, GroupSeparatorMode group_sep_mode) const
{
CharBuff buff;
- if (!numberToCLocale(number, group_sep_mode, &buff)) {
+ if (!numberToCLocale(group().unicode() == 0xa0 ? number.trimmed() : number,
+ group_sep_mode, &buff)) {
if (ok != 0)
*ok = false;
return 0;
diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp
index feea473..5cc71d6 100644
--- a/src/corelib/tools/qpoint.cpp
+++ b/src/corelib/tools/qpoint.cpp
@@ -442,6 +442,19 @@ QDebug operator<<(QDebug d, const QPointF &p)
otherwise returns false.
*/
+
+/*!
+ Returns the sum of the absolute values of x() and y(),
+ traditionally known as the "Manhattan length" of the vector from
+ the origin to the point.
+
+ \sa QPoint::manhattanLength()
+*/
+qreal QPointF::manhattanLength() const
+{
+ return qAbs(x())+qAbs(y());
+}
+
/*!
\fn qreal QPointF::x() const
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index 1dab7e2..e716bf7 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -192,6 +192,8 @@ public:
QPointF(const QPoint &p);
QPointF(qreal xpos, qreal ypos);
+ qreal manhattanLength() const;
+
bool isNull() const;
qreal x() const;
diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h
index 57c55ca..34a6c99 100644
--- a/src/corelib/tools/qsize.h
+++ b/src/corelib/tools/qsize.h
@@ -171,14 +171,14 @@ inline const QSize operator*(qreal c, const QSize &s)
inline QSize &QSize::operator/=(qreal c)
{
- Q_ASSERT(!qFuzzyCompare(c + 1, 1));
+ Q_ASSERT(!qFuzzyIsNull(c));
wd = qRound(wd/c); ht = qRound(ht/c);
return *this;
}
inline const QSize operator/(const QSize &s, qreal c)
{
- Q_ASSERT(!qFuzzyCompare(c + 1, 1));
+ Q_ASSERT(!qFuzzyIsNull(c));
return QSize(qRound(s.wd/c), qRound(s.ht/c));
}
@@ -327,14 +327,14 @@ inline const QSizeF operator*(qreal c, const QSizeF &s)
inline QSizeF &QSizeF::operator/=(qreal c)
{
- Q_ASSERT(!qFuzzyCompare(c + 1, 1));
+ Q_ASSERT(!qFuzzyIsNull(c));
wd = wd/c; ht = ht/c;
return *this;
}
inline const QSizeF operator/(const QSizeF &s, qreal c)
{
- Q_ASSERT(!qFuzzyCompare(c + 1, 1));
+ Q_ASSERT(!qFuzzyIsNull(c));
return QSizeF(s.wd/c, s.ht/c);
}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 1b29adc..375d672 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -579,7 +579,7 @@ const QString::Null QString::null = { };
'\\0' character for a null string (\e not a null pointer), and
QString() compares equal to QString(""). We recommend that you
always use the isEmpty() function and avoid isNull().
-
+
\section1 Argument Formats
In member functions where an argument \e format can be specified
@@ -1433,7 +1433,7 @@ QString &QString::append(QChar ch)
truncated at the specified \a position.
\snippet doc/src/snippets/qstring/main.cpp 37
-
+
\sa insert(), replace()
*/
QString &QString::remove(int pos, int len)
@@ -1552,7 +1552,7 @@ QString &QString::replace(int pos, int len, const QChar *unicode, int size)
return *this;
if (pos + len > d->size)
len = d->size - pos;
-
+
uint index = pos;
replace_helper(&index, 1, len, unicode, size);
return *this;
@@ -1561,15 +1561,13 @@ QString &QString::replace(int pos, int len, const QChar *unicode, int size)
/*!
\fn QString &QString::replace(int position, int n, QChar after)
\overload replace()
-
+
Replaces \a n characters beginning at index \a position with the
character \a after and returns a reference to this string.
*/
QString &QString::replace(int pos, int len, QChar after)
{
- uint index = pos;
- replace_helper(&index, 1, len, &after, 1);
- return *this;
+ return replace(pos, len, &after, 1);
}
/*!
@@ -1602,7 +1600,7 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar
{
if (blen == alen) {
detach();
- for (int i = 0; i < nIndices; ++i)
+ for (int i = 0; i < nIndices; ++i)
memcpy(d->data + indices[i], after, alen * sizeof(QChar));
} else if (alen < blen) {
detach();
@@ -1633,7 +1631,7 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar
int newLen = d->size + adjust;
int moveend = d->size;
resize(newLen);
-
+
while (nIndices) {
--nIndices;
int movestart = indices[nIndices] + blen;
@@ -1685,7 +1683,7 @@ QString &QString::replace(const QChar *before, int blen,
memcpy(copy, before, blen*sizeof(QChar));
b = copy;
}
-
+
QStringMatcher matcher(b, blen, cs);
int index = 0;
@@ -1712,7 +1710,7 @@ QString &QString::replace(const QChar *before, int blen,
// index has to be adjusted in case we get back into the loop above.
index += pos*(alen-blen);
}
-
+
if (a != after)
::free((QChar *)a);
if (b != before)
@@ -2250,7 +2248,7 @@ int QString::indexOf(const QLatin1String &str, int from, Qt::CaseSensitivity cs)
QVarLengthArray<ushort> s(len);
for (int i = 0; i < len; ++i)
s[i] = str.latin1()[i];
-
+
return qFindString(unicode(), length(), from, (const QChar *)s.data(), len, cs);
}
@@ -2346,7 +2344,7 @@ static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *nee
/*
See indexOf() for explanations.
*/
-
+
const ushort *end = haystack;
haystack += from;
const int sl_minus_1 = sl-1;
@@ -2408,7 +2406,7 @@ int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) c
const int sl = str.d->size;
if (sl == 1)
return lastIndexOf(QChar(str.d->data[0]), from, cs);
-
+
const int l = d->size;
if (from < 0)
from += l;
@@ -2446,7 +2444,7 @@ int QString::lastIndexOf(const QLatin1String &str, int from, Qt::CaseSensitivity
const int sl = qstrlen(str.latin1());
if (sl == 1)
return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs);
-
+
const int l = d->size;
if (from < 0)
from += l;
@@ -4864,7 +4862,8 @@ QString QString::toUpper() const
a pointer to a zero-terminated array of unicode characters of type
ushort (as returned by QString::utf16()).
- \note This function expects a UTF-8 string for %s.
+ \note This function expects a UTF-8 string for %s and Latin-1 for
+ the format string.
The format string supports most of the conversion specifiers
provided by printf() in the standard C++ library. It doesn't
@@ -5994,7 +5993,7 @@ QString QString::normalized(QString::NormalizationForm mode, QChar::UnicodeVersi
}
if (simple)
return *this;
-
+
QString s = *this;
if (version != CURRENT_VERSION) {
for (int i = 0; i < NumNormalizationCorrections; ++i) {
@@ -6206,7 +6205,7 @@ static QString replaceArgEscapes(const QString &s, const ArgEscapeData &d, int f
/*!
Returns a copy of this string with the lowest numbered place marker
replaced by string \a a, i.e., \c %1, \c %2, ..., \c %99.
-
+
\a fieldWidth specifies the minimum amount of space that argument \a
a shall occupy. If \a a requires less space than \a fieldWidth, it
is padded to \a fieldWidth with character \a fillChar. A positive
@@ -6818,7 +6817,7 @@ void QString::updateProperties() const
Appends the given \a ch character onto the end of this string.
*/
-/*!
+/*!
\fn std::string QString::toStdString() const
Returns a std::string object with the data contained in this
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 6bea03b..3fd52ee 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -98,6 +98,8 @@ struct QVectorTypedData
T array[1];
};
+class QRegion;
+
template <typename T>
class QVector
{
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 91b9cb1..8c701f5 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -137,6 +137,7 @@ static dbus_bool_t qDBusAddTimeout(DBusTimeout *timeout, void *data)
if (!q_dbus_timeout_get_enabled(timeout))
return true;
+ QDBusWatchAndTimeoutLocker locker(AddTimeoutAction, d);
if (QCoreApplication::instance() && QThread::currentThread() == d->thread()) {
// correct thread
return qDBusRealAddTimeout(d, timeout, q_dbus_timeout_get_interval(timeout));
@@ -152,7 +153,6 @@ static dbus_bool_t qDBusAddTimeout(DBusTimeout *timeout, void *data)
static bool qDBusRealAddTimeout(QDBusConnectionPrivate *d, DBusTimeout *timeout, int ms)
{
- QDBusWatchAndTimeoutLocker locker(AddTimeoutAction, d);
Q_ASSERT(d->timeouts.keys(timeout).isEmpty());
int timerId = d->startTimer(ms);
@@ -921,10 +921,9 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
rootNode(QString(QLatin1Char('/')))
{
static const bool threads = qDBusInitThreads();
- static const int debugging = qgetenv("QDBUS_DEBUG").toInt();
+ static const int debugging = ::isDebugging = qgetenv("QDBUS_DEBUG").toInt();
Q_UNUSED(threads)
- ::isDebugging = debugging;
#ifdef QDBUS_THREAD_DEBUG
if (debugging > 1)
qdbusThreadDebug = qdbusDefaultThreadDebug;
@@ -1036,15 +1035,16 @@ void QDBusConnectionPrivate::customEvent(QEvent *e)
QDBusLockerBase::BeforeDeliver, this);
switch (ev->subtype)
{
- case QDBusConnectionCallbackEvent::AddTimeout:
+ case QDBusConnectionCallbackEvent::AddTimeout: {
+ QDBusWatchAndTimeoutLocker locker(RealAddTimeoutAction, this);
while (!timeoutsPendingAdd.isEmpty()) {
QPair<DBusTimeout *, int> entry = timeoutsPendingAdd.takeFirst();
qDBusRealAddTimeout(this, entry.first, entry.second);
}
break;
+ }
case QDBusConnectionCallbackEvent::KillTimer:
- qDebug() << QThread::currentThread() << "RemoveTimeout: killing timer" << (ev->timerId & 0xffffff);
killTimer(ev->timerId);
break;
diff --git a/src/dbus/qdbuspendingreply.h b/src/dbus/qdbuspendingreply.h
index 3880a7f..5ec9800 100644
--- a/src/dbus/qdbuspendingreply.h
+++ b/src/dbus/qdbuspendingreply.h
@@ -95,7 +95,7 @@ namespace QDBusPendingReplyTypes {
enum { Total = Next::Total + 1 };
static inline void fillMetaTypes(int *p)
{
- *p = metaTypeFor<T1>();
+ *p = metaTypeFor<T1>(0);
Next::fillMetaTypes(++p);
}
};
@@ -171,7 +171,7 @@ public:
Q_ASSERT_X(Index < count() && Index >= 0, "QDBusPendingReply::argumentAt",
"Index out of bounds");
typedef typename Select<Index>::Type ResultType;
- return qdbus_cast<ResultType>(argumentAt(Index));
+ return qdbus_cast<ResultType>(argumentAt(Index), 0);
}
inline typename Select<0>::Type value() const
diff --git a/src/dbus/qdbusthreaddebug_p.h b/src/dbus/qdbusthreaddebug_p.h
index 715bd6f..20d819f 100644
--- a/src/dbus/qdbusthreaddebug_p.h
+++ b/src/dbus/qdbusthreaddebug_p.h
@@ -92,9 +92,10 @@ enum ThreadAction {
PendingCallBlockAction = 28,
AddTimeoutAction = 50,
- RemoveTimeoutAction = 51,
- KillTimerAction = 52,
- TimerEventAction = 53,
+ RealAddTimeoutAction = 51,
+ RemoveTimeoutAction = 52,
+ KillTimerAction = 58,
+ TimerEventAction = 59,
AddWatchAction = 60,
RemoveWatchAction = 61,
ToggleWatchAction = 62,
diff --git a/src/gui/accessible/qaccessible_mac.mm b/src/gui/accessible/qaccessible_mac.mm
index b6412c2..68efb8f 100644
--- a/src/gui/accessible/qaccessible_mac.mm
+++ b/src/gui/accessible/qaccessible_mac.mm
@@ -72,55 +72,36 @@ typedef NSString * const QAXRoleType;
#define QAXApplicationRole NSAccessibilityApplicationRole
#define QAXButtonRole NSAccessibilityButtonRole
#define QAXCancelAction NSAccessibilityCancelAction
-#define QAXCancelAction NSAccessibilityCancelAction
#define QAXCheckBoxRole NSAccessibilityCheckBoxRole
#define QAXChildrenAttribute NSAccessibilityChildrenAttribute
-#define QAXChildrenAttribute NSAccessibilityChildrenAttribute
-#define QAXChildrenAttribute NSAccessibilityChildrenAttribute
#define QAXCloseButtonAttribute NSAccessibilityCloseButtonAttribute
#define QAXCloseButtonAttribute NSAccessibilityCloseButtonAttribute
#define QAXColumnRole NSAccessibilityColumnRole
#define QAXConfirmAction NSAccessibilityConfirmAction
-#define QAXConfirmAction NSAccessibilityConfirmAction
#define QAXContentsAttribute NSAccessibilityContentsAttribute
-#define QAXContentsAttribute NSAccessibilityContentsAttribute
-#define QAXDecrementAction NSAccessibilityDecrementAction
#define QAXDecrementAction NSAccessibilityDecrementAction
#define QAXDecrementArrowSubrole NSAccessibilityDecrementArrowSubrole
#define QAXDecrementPageSubrole NSAccessibilityDecrementPageSubrole
#define QAXDescriptionAttribute NSAccessibilityDescriptionAttribute
-#define QAXDescriptionAttribute NSAccessibilityDescriptionAttribute
-#define QAXDescriptionAttribute NSAccessibilityDescriptionAttribute
-#define QAXDescriptionAttribute NSAccessibilityDescriptionAttribute
-#define QAXEnabledAttribute NSAccessibilityEnabledAttribute
#define QAXEnabledAttribute NSAccessibilityEnabledAttribute
#define QAXExpandedAttribute NSAccessibilityExpandedAttribute
#define QAXFocusedAttribute NSAccessibilityFocusedAttribute
-#define QAXFocusedAttribute NSAccessibilityFocusedAttribute
-#define QAXFocusedAttribute NSAccessibilityFocusedAttribute
#define QAXFocusedUIElementChangedNotification NSAccessibilityFocusedUIElementChangedNotification
#define QAXFocusedWindowChangedNotification NSAccessibilityFocusedWindowChangedNotification
#define QAXGroupRole NSAccessibilityGroupRole
#define QAXGrowAreaAttribute NSAccessibilityGrowAreaAttribute
-#define QAXGrowAreaAttribute NSAccessibilityGrowAreaAttribute
#define QAXGrowAreaRole NSAccessibilityGrowAreaRole
#define QAXHelpAttribute NSAccessibilityHelpAttribute
-#define QAXHelpAttribute NSAccessibilityHelpAttribute
-#define QAXHelpAttribute NSAccessibilityHelpAttribute
#define QAXHorizontalOrientationValue NSAccessibilityHorizontalOrientationValue
#define QAXHorizontalScrollBarAttribute NSAccessibilityHorizontalScrollBarAttribute
-#define QAXHorizontalScrollBarAttribute NSAccessibilityHorizontalScrollBarAttribute
-#define QAXIncrementAction NSAccessibilityIncrementAction
#define QAXIncrementAction NSAccessibilityIncrementAction
#define QAXIncrementArrowSubrole NSAccessibilityIncrementArrowSubrole
#define QAXIncrementPageSubrole NSAccessibilityIncrementPageSubrole
#define QAXIncrementorRole NSAccessibilityIncrementorRole
#define QAXLinkedUIElementsAttribute NSAccessibilityLinkedUIElementsAttribute
-#define QAXLinkedUIElementsAttribute NSAccessibilityLinkedUIElementsAttribute
#define QAXListRole NSAccessibilityListRole
#define QAXMainAttribute NSAccessibilityMainAttribute
#define QAXMaxValueAttribute NSAccessibilityMaxValueAttribute
-#define QAXMaxValueAttribute NSAccessibilityMaxValueAttribute
#define QAXMenuBarRole NSAccessibilityMenuBarRole
#define QAXMenuButtonRole NSAccessibilityMenuButtonRole
#define QAXMenuClosedNotification NSAccessibilityMenuClosedNotification
@@ -128,151 +109,90 @@ typedef NSString * const QAXRoleType;
#define QAXMenuOpenedNotification NSAccessibilityMenuOpenedNotification
#define QAXMenuRole NSAccessibilityMenuRole
#define QAXMinValueAttribute NSAccessibilityMinValueAttribute
-#define QAXMinValueAttribute NSAccessibilityMinValueAttribute
#define QAXMinimizeButtonAttribute NSAccessibilityMinimizeButtonAttribute
-#define QAXMinimizeButtonAttribute NSAccessibilityMinimizeButtonAttribute
-#define QAXMinimizedAttribute NSAccessibilityMinimizedAttribute
#define QAXMinimizedAttribute NSAccessibilityMinimizedAttribute
#define QAXNextContentsAttribute NSAccessibilityNextContentsAttribute
-#define QAXNextContentsAttribute NSAccessibilityNextContentsAttribute
-#define QAXOrientationAttribute NSAccessibilityOrientationAttribute
-#define QAXOrientationAttribute NSAccessibilityOrientationAttribute
#define QAXOrientationAttribute NSAccessibilityOrientationAttribute
#define QAXParentAttribute NSAccessibilityParentAttribute
#define QAXPickAction NSAccessibilityPickAction
-#define QAXPickAction NSAccessibilityPickAction
#define QAXPopUpButtonRole NSAccessibilityPopUpButtonRole
#define QAXPositionAttribute NSAccessibilityPositionAttribute
-#define QAXPositionAttribute NSAccessibilityPositionAttribute
-#define QAXPressAction NSAccessibilityPressAction
#define QAXPressAction NSAccessibilityPressAction
#define QAXPreviousContentsAttribute NSAccessibilityPreviousContentsAttribute
-#define QAXPreviousContentsAttribute NSAccessibilityPreviousContentsAttribute
-#define QAXPreviousContentsAttribute NSAccessibilityPreviousContentsAttribute
#define QAXProgressIndicatorRole NSAccessibilityProgressIndicatorRole
#define QAXRadioButtonRole NSAccessibilityRadioButtonRole
#define QAXRoleAttribute NSAccessibilityRoleAttribute
-#define QAXRoleAttribute NSAccessibilityRoleAttribute
#define QAXRoleDescriptionAttribute NSAccessibilityRoleDescriptionAttribute
#define QAXRowRole NSAccessibilityRowRole
#define QAXRowsAttribute NSAccessibilityRowsAttribute
-#define QAXRowsAttribute NSAccessibilityRowsAttribute
-#define QAXScrollAreaRole NSAccessibilityScrollAreaRole
-#define QAXScrollAreaRole NSAccessibilityScrollAreaRole
#define QAXScrollAreaRole NSAccessibilityScrollAreaRole
#define QAXScrollBarRole NSAccessibilityScrollBarRole
#define QAXSelectedAttribute NSAccessibilitySelectedAttribute
#define QAXSelectedChildrenAttribute NSAccessibilitySelectedChildrenAttribute
#define QAXSelectedRowsAttribute NSAccessibilitySelectedRowsAttribute
-#define QAXSelectedRowsAttribute NSAccessibilitySelectedRowsAttribute
-#define QAXSizeAttribute NSAccessibilitySizeAttribute
#define QAXSizeAttribute NSAccessibilitySizeAttribute
#define QAXSliderRole NSAccessibilitySliderRole
#define QAXSplitGroupRole NSAccessibilitySplitGroupRole
#define QAXSplitterRole NSAccessibilitySplitterRole
-#define QAXSplitterRole NSAccessibilitySplitterRole
-#define QAXSplitterRole NSAccessibilitySplitterRole
-#define QAXSplittersAttribute NSAccessibilitySplittersAttribute
#define QAXSplittersAttribute NSAccessibilitySplittersAttribute
#define QAXStaticTextRole NSAccessibilityStaticTextRole
-#define QAXStaticTextRole NSAccessibilityStaticTextRole
-#define QAXSubroleAttribute NSAccessibilitySubroleAttribute
#define QAXSubroleAttribute NSAccessibilitySubroleAttribute
#define QAXSubroleAttribute NSAccessibilitySubroleAttribute
#define QAXTabGroupRole NSAccessibilityTabGroupRole
-#define QAXTabGroupRole NSAccessibilityTabGroupRole
#define QAXTableRole NSAccessibilityTableRole
#define QAXTabsAttribute NSAccessibilityTabsAttribute
-#define QAXTabsAttribute NSAccessibilityTabsAttribute
#define QAXTextFieldRole NSAccessibilityTextFieldRole
-#define QAXTextFieldRole NSAccessibilityTextFieldRole
-#define QAXTitleAttribute NSAccessibilityTitleAttribute
-#define QAXTitleAttribute NSAccessibilityTitleAttribute
#define QAXTitleAttribute NSAccessibilityTitleAttribute
-#define QAXTitleAttribute NSAccessibilityTitleAttribute
-#define QAXTitleUIElementAttribute NSAccessibilityTitleUIElementAttribute
#define QAXTitleUIElementAttribute NSAccessibilityTitleUIElementAttribute
#define QAXToolbarButtonAttribute NSAccessibilityToolbarButtonAttribute
-#define QAXToolbarButtonAttribute NSAccessibilityToolbarButtonAttribute
#define QAXToolbarRole NSAccessibilityToolbarRole
#define QAXTopLevelUIElementAttribute NSAccessibilityTopLevelUIElementAttribute
-#define QAXTopLevelUIElementAttribute NSAccessibilityTopLevelUIElementAttribute
-#define QAXTopLevelUIElementAttribute NSAccessibilityTopLevelUIElementAttribute
-#define QAXUnknownRole NSAccessibilityUnknownRole
#define QAXUnknownRole NSAccessibilityUnknownRole
#define QAXValueAttribute NSAccessibilityValueAttribute
-#define QAXValueAttribute NSAccessibilityValueAttribute
-#define QAXValueAttribute NSAccessibilityValueAttribute
-#define QAXValueAttribute NSAccessibilityValueAttribute
#define QAXValueChangedNotification NSAccessibilityValueChangedNotification
#define QAXValueIndicatorRole NSAccessibilityValueIndicatorRole
#define QAXVerticalOrientationValue NSAccessibilityVerticalOrientationValue
#define QAXVerticalScrollBarAttribute NSAccessibilityVerticalScrollBarAttribute
-#define QAXVerticalScrollBarAttribute NSAccessibilityVerticalScrollBarAttribute
#define QAXVisibleRowsAttribute NSAccessibilityVisibleRowsAttribute
-#define QAXVisibleRowsAttribute NSAccessibilityVisibleRowsAttribute
-#define QAXWindowAttribute NSAccessibilityWindowAttribute
-#define QAXWindowAttribute NSAccessibilityWindowAttribute
#define QAXWindowAttribute NSAccessibilityWindowAttribute
#define QAXWindowCreatedNotification NSAccessibilityWindowCreatedNotification
#define QAXWindowMovedNotification NSAccessibilityWindowMovedNotification
#define QAXWindowRole NSAccessibilityWindowRole
#define QAXZoomButtonAttribute NSAccessibilityZoomButtonAttribute
-#define QAXZoomButtonAttribute NSAccessibilityZoomButtonAttribute
#else
typedef CFStringRef const QAXRoleType;
#define QAXApplicationRole kAXApplicationRole
#define QAXButtonRole kAXButtonRole
#define QAXCancelAction kAXCancelAction
-#define QAXCancelAction kAXCancelAction
#define QAXCheckBoxRole kAXCheckBoxRole
#define QAXChildrenAttribute kAXChildrenAttribute
-#define QAXChildrenAttribute kAXChildrenAttribute
-#define QAXChildrenAttribute kAXChildrenAttribute
-#define QAXCloseButtonAttribute kAXCloseButtonAttribute
#define QAXCloseButtonAttribute kAXCloseButtonAttribute
#define QAXColumnRole kAXColumnRole
#define QAXConfirmAction kAXConfirmAction
-#define QAXConfirmAction kAXConfirmAction
#define QAXContentsAttribute kAXContentsAttribute
-#define QAXContentsAttribute kAXContentsAttribute
-#define QAXDecrementAction kAXDecrementAction
#define QAXDecrementAction kAXDecrementAction
#define QAXDecrementArrowSubrole kAXDecrementArrowSubrole
#define QAXDecrementPageSubrole kAXDecrementPageSubrole
#define QAXDescriptionAttribute kAXDescriptionAttribute
-#define QAXDescriptionAttribute kAXDescriptionAttribute
-#define QAXDescriptionAttribute kAXDescriptionAttribute
-#define QAXDescriptionAttribute kAXDescriptionAttribute
-#define QAXEnabledAttribute kAXEnabledAttribute
#define QAXEnabledAttribute kAXEnabledAttribute
#define QAXExpandedAttribute kAXExpandedAttribute
#define QAXFocusedAttribute kAXFocusedAttribute
-#define QAXFocusedAttribute kAXFocusedAttribute
-#define QAXFocusedAttribute kAXFocusedAttribute
#define QAXFocusedUIElementChangedNotification kAXFocusedUIElementChangedNotification
#define QAXFocusedWindowChangedNotification kAXFocusedWindowChangedNotification
#define QAXGroupRole kAXGroupRole
#define QAXGrowAreaAttribute kAXGrowAreaAttribute
-#define QAXGrowAreaAttribute kAXGrowAreaAttribute
#define QAXGrowAreaRole kAXGrowAreaRole
#define QAXHelpAttribute kAXHelpAttribute
-#define QAXHelpAttribute kAXHelpAttribute
-#define QAXHelpAttribute kAXHelpAttribute
#define QAXHorizontalOrientationValue kAXHorizontalOrientationValue
#define QAXHorizontalScrollBarAttribute kAXHorizontalScrollBarAttribute
-#define QAXHorizontalScrollBarAttribute kAXHorizontalScrollBarAttribute
-#define QAXIncrementAction kAXIncrementAction
#define QAXIncrementAction kAXIncrementAction
#define QAXIncrementArrowSubrole kAXIncrementArrowSubrole
#define QAXIncrementPageSubrole kAXIncrementPageSubrole
#define QAXIncrementorRole kAXIncrementorRole
#define QAXLinkedUIElementsAttribute kAXLinkedUIElementsAttribute
-#define QAXLinkedUIElementsAttribute kAXLinkedUIElementsAttribute
#define QAXListRole kAXListRole
#define QAXMainAttribute kAXMainAttribute
#define QAXMaxValueAttribute kAXMaxValueAttribute
-#define QAXMaxValueAttribute kAXMaxValueAttribute
#define QAXMenuBarRole kAXMenuBarRole
#define QAXMenuButtonRole kAXMenuButtonRole
#define QAXMenuClosedNotification kAXMenuClosedNotification
@@ -280,97 +200,55 @@ typedef CFStringRef const QAXRoleType;
#define QAXMenuOpenedNotification kAXMenuOpenedNotification
#define QAXMenuRole kAXMenuRole
#define QAXMinValueAttribute kAXMinValueAttribute
-#define QAXMinValueAttribute kAXMinValueAttribute
#define QAXMinimizeButtonAttribute kAXMinimizeButtonAttribute
-#define QAXMinimizeButtonAttribute kAXMinimizeButtonAttribute
-#define QAXMinimizedAttribute kAXMinimizedAttribute
#define QAXMinimizedAttribute kAXMinimizedAttribute
#define QAXNextContentsAttribute kAXNextContentsAttribute
-#define QAXNextContentsAttribute kAXNextContentsAttribute
-#define QAXOrientationAttribute kAXOrientationAttribute
-#define QAXOrientationAttribute kAXOrientationAttribute
#define QAXOrientationAttribute kAXOrientationAttribute
#define QAXParentAttribute kAXParentAttribute
#define QAXPickAction kAXPickAction
-#define QAXPickAction kAXPickAction
#define QAXPopUpButtonRole kAXPopUpButtonRole
#define QAXPositionAttribute kAXPositionAttribute
-#define QAXPositionAttribute kAXPositionAttribute
-#define QAXPressAction kAXPressAction
#define QAXPressAction kAXPressAction
#define QAXPreviousContentsAttribute kAXPreviousContentsAttribute
-#define QAXPreviousContentsAttribute kAXPreviousContentsAttribute
-#define QAXPreviousContentsAttribute kAXPreviousContentsAttribute
#define QAXProgressIndicatorRole kAXProgressIndicatorRole
#define QAXRadioButtonRole kAXRadioButtonRole
#define QAXRoleAttribute kAXRoleAttribute
-#define QAXRoleAttribute kAXRoleAttribute
#define QAXRoleDescriptionAttribute kAXRoleDescriptionAttribute
#define QAXRowRole kAXRowRole
#define QAXRowsAttribute kAXRowsAttribute
-#define QAXRowsAttribute kAXRowsAttribute
-#define QAXScrollAreaRole kAXScrollAreaRole
-#define QAXScrollAreaRole kAXScrollAreaRole
#define QAXScrollAreaRole kAXScrollAreaRole
#define QAXScrollBarRole kAXScrollBarRole
#define QAXSelectedAttribute kAXSelectedAttribute
#define QAXSelectedChildrenAttribute kAXSelectedChildrenAttribute
#define QAXSelectedRowsAttribute kAXSelectedRowsAttribute
-#define QAXSelectedRowsAttribute kAXSelectedRowsAttribute
-#define QAXSizeAttribute kAXSizeAttribute
#define QAXSizeAttribute kAXSizeAttribute
#define QAXSliderRole kAXSliderRole
#define QAXSplitGroupRole kAXSplitGroupRole
#define QAXSplitterRole kAXSplitterRole
-#define QAXSplitterRole kAXSplitterRole
-#define QAXSplitterRole kAXSplitterRole
-#define QAXSplittersAttribute kAXSplittersAttribute
#define QAXSplittersAttribute kAXSplittersAttribute
#define QAXStaticTextRole kAXStaticTextRole
-#define QAXStaticTextRole kAXStaticTextRole
-#define QAXSubroleAttribute kAXSubroleAttribute
#define QAXSubroleAttribute kAXSubroleAttribute
-#define QAXSubroleAttribute kAXSubroleAttribute
-#define QAXTabGroupRole kAXTabGroupRole
#define QAXTabGroupRole kAXTabGroupRole
#define QAXTableRole kAXTableRole
#define QAXTabsAttribute kAXTabsAttribute
-#define QAXTabsAttribute kAXTabsAttribute
-#define QAXTextFieldRole kAXTextFieldRole
#define QAXTextFieldRole kAXTextFieldRole
#define QAXTitleAttribute kAXTitleAttribute
-#define QAXTitleAttribute kAXTitleAttribute
-#define QAXTitleAttribute kAXTitleAttribute
-#define QAXTitleAttribute kAXTitleAttribute
#define QAXTitleUIElementAttribute kAXTitleUIElementAttribute
-#define QAXTitleUIElementAttribute kAXTitleUIElementAttribute
-#define QAXToolbarButtonAttribute kAXToolbarButtonAttribute
#define QAXToolbarButtonAttribute kAXToolbarButtonAttribute
#define QAXToolbarRole kAXToolbarRole
#define QAXTopLevelUIElementAttribute kAXTopLevelUIElementAttribute
-#define QAXTopLevelUIElementAttribute kAXTopLevelUIElementAttribute
-#define QAXTopLevelUIElementAttribute kAXTopLevelUIElementAttribute
#define QAXUnknownRole kAXUnknownRole
-#define QAXUnknownRole kAXUnknownRole
-#define QAXValueAttribute kAXValueAttribute
-#define QAXValueAttribute kAXValueAttribute
-#define QAXValueAttribute kAXValueAttribute
#define QAXValueAttribute kAXValueAttribute
#define QAXValueChangedNotification kAXValueChangedNotification
#define QAXValueIndicatorRole kAXValueIndicatorRole
#define QAXVerticalOrientationValue kAXVerticalOrientationValue
#define QAXVerticalScrollBarAttribute kAXVerticalScrollBarAttribute
-#define QAXVerticalScrollBarAttribute kAXVerticalScrollBarAttribute
-#define QAXVisibleRowsAttribute kAXVisibleRowsAttribute
#define QAXVisibleRowsAttribute kAXVisibleRowsAttribute
#define QAXWindowAttribute kAXWindowAttribute
-#define QAXWindowAttribute kAXWindowAttribute
-#define QAXWindowAttribute kAXWindowAttribute
#define QAXWindowCreatedNotification kAXWindowCreatedNotification
#define QAXWindowMovedNotification kAXWindowMovedNotification
#define QAXWindowRole kAXWindowRole
#define QAXZoomButtonAttribute kAXZoomButtonAttribute
-#define QAXZoomButtonAttribute kAXZoomButtonAttribute
#endif
diff --git a/src/gui/accessible/qaccessiblewidget.cpp b/src/gui/accessible/qaccessiblewidget.cpp
index 4b2b2ab..753ac57 100644
--- a/src/gui/accessible/qaccessiblewidget.cpp
+++ b/src/gui/accessible/qaccessiblewidget.cpp
@@ -131,9 +131,16 @@ QString Q_GUI_EXPORT qt_accHotKey(const QString &text)
int fa = 0;
QChar ac;
while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) {
- if (fa == text.length() - 1 || text.at(fa+1) != QLatin1Char('&')) {
- ac = text.at(fa+1);
- break;
+ ++fa;
+ if (fa < text.length()) {
+ // ignore "&&"
+ if (text.at(fa) == QLatin1Char('&')) {
+ ++fa;
+ continue;
+ } else {
+ ac = text.at(fa);
+ break;
+ }
}
}
if (ac.isNull())
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index b744dca..3aa04f6 100644
--- a/src/gui/dialogs/qcolordialog.cpp
+++ b/src/gui/dialogs/qcolordialog.cpp
@@ -1523,10 +1523,10 @@ static const Qt::WindowFlags DefaultWindowFlags =
If you require a modeless dialog, use the QColorDialog constructor.
\endomit
- The static getColor() function shows the dialog, and allows the
- user to specify a color. The getRgba() function does the same, but
- also allows the user to specify a color with an alpha channel
- (transparency) value.
+ The static getColor() function shows the dialog, and allows the user to
+ specify a color. This function can also be used to let users choose a
+ color with a level of transparency: pass the ShowAlphaChannel option as
+ an additional argument.
The user can store customCount() different custom colors. The
custom colors are shared by all color dialogs, and remembered
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index 2ce5563..f70669c 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -957,25 +957,29 @@ void QFileDialog::setNameFilters(const QStringList &filters)
{
Q_D(QFileDialog);
d->defaultFileTypes = (filters == QStringList(QFileDialog::tr("All Files (*)")));
- d->nameFilters = filters;
+ QStringList cleanedFilters;
+ for (int i = 0; i < filters.count(); ++i) {
+ cleanedFilters << filters[i].simplified();
+ }
+ d->nameFilters = cleanedFilters;
if (d->nativeDialogInUse){
- d->setNameFilters_sys(filters);
+ d->setNameFilters_sys(cleanedFilters);
return;
}
d->qFileDialogUi->fileTypeCombo->clear();
- if (filters.isEmpty())
+ if (cleanedFilters.isEmpty())
return;
if (testOption(HideNameFilterDetails)) {
QStringList strippedFilters;
- for (int i = 0; i < filters.count(); ++i) {
- strippedFilters.append(filters[i].mid(0, filters[i].indexOf(QLatin1String(" ("))));
+ for (int i = 0; i < cleanedFilters.count(); ++i) {
+ strippedFilters.append(cleanedFilters[i].mid(0, cleanedFilters[i].indexOf(QLatin1String(" ("))));
}
d->qFileDialogUi->fileTypeCombo->addItems(strippedFilters);
} else {
- d->qFileDialogUi->fileTypeCombo->addItems(filters);
+ d->qFileDialogUi->fileTypeCombo->addItems(cleanedFilters);
}
d->_q_useNameFilter(0);
}
@@ -1589,7 +1593,12 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
args.parent = parent;
args.caption = caption;
args.directory = QFileDialogPrivate::workingDirectory(dir);
- args.selection = QFileDialogPrivate::initialSelection(dir);
+ //If workingDirectory returned a different path than the initial one,
+ //it means that the initial path was invalid. There is no point to try select a file
+ if (args.directory != QFileInfo(dir).path())
+ args.selection = QString();
+ else
+ args.selection = QFileDialogPrivate::initialSelection(dir);
args.filter = filter;
args.mode = ExistingFile;
args.options = options;
@@ -1674,7 +1683,12 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
args.parent = parent;
args.caption = caption;
args.directory = QFileDialogPrivate::workingDirectory(dir);
- args.selection = QFileDialogPrivate::initialSelection(dir);
+ //If workingDirectory returned a different path than the initial one,
+ //it means that the initial path was invalid. There is no point to try select a file
+ if (args.directory != QFileInfo(dir).path())
+ args.selection = QString();
+ else
+ args.selection = QFileDialogPrivate::initialSelection(dir);
args.filter = filter;
args.mode = ExistingFiles;
args.options = options;
@@ -1760,7 +1774,12 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
args.parent = parent;
args.caption = caption;
args.directory = QFileDialogPrivate::workingDirectory(dir);
- args.selection = QFileDialogPrivate::initialSelection(dir);
+ //If workingDirectory returned a different path than the initial one,
+ //it means that the initial path was invalid. There is no point to try select a file
+ if (args.directory != QFileInfo(dir).path())
+ args.selection = QString();
+ else
+ args.selection = QFileDialogPrivate::initialSelection(dir);
args.filter = filter;
args.mode = AnyFile;
args.options = options;
@@ -2124,6 +2143,7 @@ void QFileDialogPrivate::createWidgets()
#ifndef QT_NO_COMPLETER
completer = new QFSCompletor(model, q);
qFileDialogUi->fileNameEdit->setCompleter(completer);
+ completer->sourceModel = model;
QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)),
q, SLOT(_q_autoCompleteFileName(QString)));
#endif // QT_NO_COMPLETER
@@ -2246,12 +2266,21 @@ void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel)
proxyModel->setSourceModel(d->model);
d->qFileDialogUi->listView->setModel(d->proxyModel);
d->qFileDialogUi->treeView->setModel(d->proxyModel);
+#ifndef QT_NO_COMPLETER
+ d->completer->setModel(d->proxyModel);
+ d->completer->proxyModel = d->proxyModel;
+#endif
connect(d->proxyModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
this, SLOT(_q_rowsInserted(const QModelIndex &)));
} else {
d->proxyModel = 0;
d->qFileDialogUi->listView->setModel(d->model);
d->qFileDialogUi->treeView->setModel(d->model);
+#ifndef QT_NO_COMPLETER
+ d->completer->setModel(d->model);
+ d->completer->sourceModel = d->model;
+ d->completer->proxyModel = 0;
+#endif
connect(d->model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
this, SLOT(_q_rowsInserted(const QModelIndex &)));
}
@@ -2764,8 +2793,9 @@ void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index)
{
Q_Q(QFileDialog);
// My Computer or a directory
- QString path = index.data(QFileSystemModel::FilePathRole).toString();
- if (path.isEmpty() || model->isDir(index)) {
+ QModelIndex sourceIndex = mapToSource(index);
+ QString path = sourceIndex.data(QFileSystemModel::FilePathRole).toString();
+ if (path.isEmpty() || model->isDir(sourceIndex)) {
q->setDirectory(path);
emit q->directoryEntered(path);
if (fileMode == QFileDialog::Directory
@@ -3139,7 +3169,11 @@ void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e)
QString QFSCompletor::pathFromIndex(const QModelIndex &index) const
{
- const QFileSystemModel *dirModel = static_cast<const QFileSystemModel *>(model());
+ const QFileSystemModel *dirModel;
+ if (proxyModel)
+ dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel());
+ else
+ dirModel = sourceModel;
QString currentLocation = dirModel->rootPath();
QString path = index.data(QFileSystemModel::FilePathRole).toString();
if (!currentLocation.isEmpty() && path.startsWith(currentLocation)) {
@@ -3185,7 +3219,11 @@ QStringList QFSCompletor::splitPath(const QString &path) const
bool startsFromRoot = path[0] == sep[0];
#endif
if (parts.count() == 1 || (parts.count() > 1 && !startsFromRoot)) {
- const QFileSystemModel *dirModel = static_cast<const QFileSystemModel *>(model());
+ const QFileSystemModel *dirModel;
+ if (proxyModel)
+ dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel());
+ else
+ dirModel = sourceModel;
QString currentLocation = QDir::toNativeSeparators(dirModel->rootPath());
if (currentLocation.contains(sep) && path != currentLocation) {
QStringList currentLocationList = splitPath(currentLocation);
diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm
index 4c13d01..90af9fc 100644
--- a/src/gui/dialogs/qfiledialog_mac.mm
+++ b/src/gui/dialogs/qfiledialog_mac.mm
@@ -278,7 +278,7 @@ QT_USE_NAMESPACE
{
Q_UNUSED(sender);
QString qtFileName = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)(filename);
- QFileInfo info(qtFileName);
+ QFileInfo info(qtFileName.normalized(QT_PREPEND_NAMESPACE(QString::NormalizationForm_C)));
QString path = info.absolutePath();
if (path != *mLastFilterCheckPath){
*mLastFilterCheckPath = path;
diff --git a/src/gui/dialogs/qfiledialog_p.h b/src/gui/dialogs/qfiledialog_p.h
index 8cb2cb0..dc24390 100644
--- a/src/gui/dialogs/qfiledialog_p.h
+++ b/src/gui/dialogs/qfiledialog_p.h
@@ -91,6 +91,26 @@ class QCompleter;
class QHBoxLayout;
class Ui_QFileDialog;
+#ifndef QT_NO_COMPLETER
+/*!
+ QCompleter that can deal with QFileSystemModel
+ */
+class QFSCompletor : public QCompleter {
+public:
+ QFSCompletor(QAbstractItemModel *model, QObject *parent = 0) : QCompleter(model, parent), proxyModel(0), sourceModel(0)
+ {
+#ifdef Q_OS_WIN
+ setCaseSensitivity(Qt::CaseInsensitive);
+#endif
+ }
+ QString pathFromIndex(const QModelIndex &index) const;
+ QStringList splitPath(const QString& path) const;
+
+ QAbstractProxyModel *proxyModel;
+ QFileSystemModel *sourceModel;
+};
+#endif // QT_NO_COMPLETER
+
struct QFileDialogArgs
{
QFileDialogArgs() : parent(0), mode(QFileDialog::AnyFile) {}
@@ -255,7 +275,7 @@ public:
// data
QStringList watching;
QFileSystemModel *model;
- QCompleter *completer;
+ QFSCompletor *completer;
QFileDialog::FileMode fileMode;
QFileDialog::AcceptMode acceptMode;
@@ -434,23 +454,6 @@ inline QString QFileDialogPrivate::rootPath() const {
inline QString QFileDialogPrivate::selectedNameFilter_sys() const { return QString(); }
#endif
-#ifndef QT_NO_COMPLETER
-/*!
- QCompleter that can deal with QFileSystemModel
- */
-class QFSCompletor : public QCompleter {
-public:
- QFSCompletor(QAbstractItemModel *model, QObject *parent = 0) : QCompleter(model, parent)
- {
-#ifdef Q_OS_WIN
- setCaseSensitivity(Qt::CaseInsensitive);
-#endif
- }
- QString pathFromIndex(const QModelIndex &index) const;
- QStringList splitPath(const QString& path) const;
-};
-#endif // QT_NO_COMPLETER
-
QT_END_NAMESPACE
#endif // QT_NO_FILEDIALOG
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp
index c7b3137..012d3a1 100644
--- a/src/gui/dialogs/qfilesystemmodel.cpp
+++ b/src/gui/dialogs/qfilesystemmodel.cpp
@@ -1430,7 +1430,10 @@ void QFileSystemModel::setFilter(QDir::Filters filters)
}
/*!
- Returns the filter specification for the directory model.
+ Returns the filter specified for the directory model.
+
+ If a filter has not been set, the default filter is QDir::AllEntries |
+ QDir::NoDotAndDotDot | QDir::AllDirs.
\sa QDir::Filters
*/
diff --git a/src/gui/dialogs/qinputdialog.cpp b/src/gui/dialogs/qinputdialog.cpp
index b63c8ee..78d99e3 100644
--- a/src/gui/dialogs/qinputdialog.cpp
+++ b/src/gui/dialogs/qinputdialog.cpp
@@ -424,26 +424,27 @@ void QInputDialogPrivate::_q_currentRowChanged(const QModelIndex &newIndex,
/*!
\class QInputDialog
- \brief The QInputDialog class provides a simple convenience dialog to get a single value from the user.
+ \brief The QInputDialog class provides a simple convenience dialog to get a
+ single value from the user.
\ingroup dialogs
\mainclass
- The input value can be a string, a number or an item from a list. A
- label must be set to tell the user what they should enter.
+ The input value can be a string, a number or an item from a list. A label
+ must be set to tell the user what they should enter.
- Four static convenience functions are provided:
- getText(), getInt(), getDouble(), and getItem(). All the
- functions can be used in a similar way, for example:
+ Four static convenience functions are provided: getText(), getInt(),
+ getDouble(), and getItem(). All the functions can be used in a similar way,
+ for example:
\snippet examples/dialogs/standarddialogs/dialog.cpp 3
- The \c ok variable is set to true if the user clicks \gui OK;
- otherwise it is set to false.
+ The \c ok variable is set to true if the user clicks \gui OK; otherwise it
+ is set to false.
\img inputdialogs.png Input Dialogs
- The \l{dialogs/standarddialogs}{Standard Dialogs} example shows
- how to use QInputDialog as well as other built-in Qt dialogs.
+ The \l{dialogs/standarddialogs}{Standard Dialogs} example shows how to use
+ QInputDialog as well as other built-in Qt dialogs.
\sa QMessageBox, {Standard Dialogs Example}
*/
@@ -452,11 +453,13 @@ void QInputDialogPrivate::_q_currentRowChanged(const QModelIndex &newIndex,
\enum QInputDialog::InputMode
\since 4.5
- This enum describes the different modes of input that can be selected for the dialog.
+ This enum describes the different modes of input that can be selected for
+ the dialog.
\value TextInput Used to input text strings.
\value IntInput Used to input integers.
- \value DoubleInput Used to input floating point numbers with double precision accuracy.
+ \value DoubleInput Used to input floating point numbers with double
+ precision accuracy.
\sa inputMode
*/
@@ -487,7 +490,8 @@ QInputDialog::~QInputDialog()
\brief the mode used for input
- This property help determines which widget is used for entering input into the dialog.
+ This property help determines which widget is used for entering input into
+ the dialog.
*/
void QInputDialog::setInputMode(InputMode mode)
{
@@ -1104,15 +1108,18 @@ void QInputDialog::done(int result)
}
/*!
- Static convenience function to get a string from the user. \a
- title is the text which is displayed in the title bar of the
- dialog. \a label is the text which is shown to the user (it should
- say what should be entered). \a text is the default text which is
- placed in the line edit. The \a mode is the echo mode the line
- edit will use. If \a ok is nonnull \e *\a ok will be set to true
- if the user pressed \gui OK and to false if the user pressed
- \gui Cancel. The dialog's parent is \a parent. The dialog will be
- modal and uses the specified widget \a flags.
+ Static convenience function to get a string from the user.
+
+ \a title is the text which is displayed in the title bar of the dialog.
+ \a label is the text which is shown to the user (it should say what should
+ be entered).
+ \a text is the default text which is placed in the line edit.
+ \a mode is the echo mode the line edit will use.
+
+ If \a ok is nonnull \e *\a ok will be set to true if the user pressed
+ \gui OK and to false if the user pressed \gui Cancel. The dialog's parent
+ is \a parent. The dialog will be modal and uses the specified widget
+ \a flags.
This function returns the text which has been entered in the line
edit. It will not return an empty string.
@@ -1121,11 +1128,11 @@ void QInputDialog::done(int result)
\snippet examples/dialogs/standarddialogs/dialog.cpp 3
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QInputDialog constructors.
+ \warning Do not delete \a parent during the execution of the dialog. If you
+ want to do this, you should create the dialog yourself using one of the
+ QInputDialog constructors.
- \sa getInteger(), getDouble(), getItem()
+ \sa getInt(), getDouble(), getItem()
*/
QString QInputDialog::getText(QWidget *parent, const QString &title, const QString &label,
@@ -1149,30 +1156,32 @@ QString QInputDialog::getText(QWidget *parent, const QString &title, const QStri
}
/*!
- Static convenience function to get an integer input from the
- user. \a title is the text which is displayed in the title bar
- of the dialog. \a label is the text which is shown to the user
- (it should say what should be entered). \a value is the default
- integer which the spinbox will be set to. \a min and \a
- max are the minimum and maximum values the user may choose,
- and \a step is the amount by which the values change as the user
- presses the arrow buttons to increment or decrement the value.
-
- If \a ok is nonnull *\a ok will be set to true if the user
- pressed \gui OK and to false if the user pressed \gui Cancel. The
- dialog's parent is \a parent. The dialog will be modal and uses
- the widget \a flags.
-
- On success, this function returns the integer which has been
- entered by the user; on failure, it returns the initial \a value.
+ \since 4.5
+
+ Static convenience function to get an integer input from the user.
+
+ \a title is the text which is displayed in the title bar of the dialog.
+ \a label is the text which is shown to the user (it should say what should
+ be entered).
+ \a value is the default integer which the spinbox will be set to.
+ \a min and \a max are the minimum and maximum values the user may choose.
+ \a step is the amount by which the values change as the user presses the
+ arrow buttons to increment or decrement the value.
+
+ If \a ok is nonnull *\a ok will be set to true if the user pressed \gui OK
+ and to false if the user pressed \gui Cancel. The dialog's parent is
+ \a parent. The dialog will be modal and uses the widget \a flags.
+
+ On success, this function returns the integer which has been entered by the
+ user; on failure, it returns the initial \a value.
Use this static function like this:
\snippet examples/dialogs/standarddialogs/dialog.cpp 0
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QInputDialog constructors.
+ \warning Do not delete \a parent during the execution of the dialog. If you
+ want to do this, you should create the dialog yourself using one of the
+ QInputDialog constructors.
\sa getText(), getDouble(), getItem()
*/
@@ -1198,32 +1207,32 @@ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &l
}
/*!
- Static convenience function to get a floating point number from
- the user. \a title is the text which is displayed in the title
- bar of the dialog. \a label is the text which is shown to the user
- (it should say what should be entered). \a value is the default
- floating point number that the line edit will be set to. \a
- min and \a max are the minimum and maximum values the
- user may choose, and \a decimals is the maximum number of decimal
- places the number may have.
-
- If \a ok is nonnull, *\a ok will be set to true if the user
- pressed \gui OK and to false if the user pressed \gui Cancel. The
- dialog's parent is \a parent. The dialog will be modal and uses
- the widget \a flags.
-
- This function returns the floating point number which has been
- entered by the user.
+ Static convenience function to get a floating point number from the user.
+
+ \a title is the text which is displayed in the title bar of the dialog.
+ \a label is the text which is shown to the user (it should say what should
+ be entered).
+ \a value is the default floating point number that the line edit will be
+ set to.
+ \a min and \a max are the minimum and maximum values the user may choose.
+ \a decimals is the maximum number of decimal places the number may have.
+
+ If \a ok is nonnull, *\a ok will be set to true if the user pressed \gui OK
+ and to false if the user pressed \gui Cancel. The dialog's parent is
+ \a parent. The dialog will be modal and uses the widget \a flags.
+
+ This function returns the floating point number which has been entered by
+ the user.
Use this static function like this:
\snippet examples/dialogs/standarddialogs/dialog.cpp 1
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QInputDialog constructors.
+ \warning Do not delete \a parent during the execution of the dialog. If you
+ want to do this, you should create the dialog yourself using one of the
+ QInputDialog constructors.
- \sa getText(), getInteger(), getItem()
+ \sa getText(), getInt(), getItem()
*/
double QInputDialog::getDouble(QWidget *parent, const QString &title, const QString &label,
@@ -1248,32 +1257,34 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr
}
/*!
- Static convenience function to let the user select an item from a
- string list. \a title is the text which is displayed in the title
- bar of the dialog. \a label is the text which is shown to the user (it
- should say what should be entered). \a items is the
- string list which is inserted into the combobox, and \a current is the number
- of the item which should be the current item. If \a editable is true
- the user can enter their own text; if \a editable is false the user
- may only select one of the existing items.
-
- If \a ok is nonnull \e *\a ok will be set to true if the user
- pressed \gui OK and to false if the user pressed \gui Cancel. The
- dialog's parent is \a parent. The dialog will be modal and uses
- the widget \a flags.
-
- This function returns the text of the current item, or if \a
- editable is true, the current text of the combobox.
+ Static convenience function to let the user select an item from a string
+ list.
+
+ \a title is the text which is displayed in the title bar of the dialog.
+ \a label is the text which is shown to the user (it should say what should
+ be entered).
+ \a items is the string list which is inserted into the combobox.
+ \a current is the number of the item which should be the current item.
+
+ If \a editable is true the user can enter their own text; otherwise the
+ user may only select one of the existing items.
+
+ If \a ok is nonnull \e *\a ok will be set to true if the user pressed
+ \gui OK and to false if the user pressed \gui Cancel. The dialog's parent
+ is \a parent. The dialog will be modal and uses the widget \a flags.
+
+ This function returns the text of the current item, or if \a editable is
+ true, the current text of the combobox.
Use this static function like this:
\snippet examples/dialogs/standarddialogs/dialog.cpp 2
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QInputDialog constructors.
+ \warning Do not delete \a parent during the execution of the dialog. If you
+ want to do this, you should create the dialog yourself using one of the
+ QInputDialog constructors.
- \sa getText(), getInteger(), getDouble()
+ \sa getText(), getInt(), getDouble()
*/
QString QInputDialog::getItem(QWidget *parent, const QString &title, const QString &label,
diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp
index f343405..1967837 100644
--- a/src/gui/dialogs/qmessagebox.cpp
+++ b/src/gui/dialogs/qmessagebox.cpp
@@ -532,11 +532,11 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
\section2 Severity Levels and the Icon and Pixmap Properties
- QMessageBox supports four predefined message severity levels, or
- message types, which really only differ in the predefined icon
- they each show. Specify one of the four predefined message types
- by setting the \l{QMessageBox::icon} {icon} property to one of the
- \l{QMessageBox::Icon} {predefined Icons}. The following rules are
+ QMessageBox supports four predefined message severity levels, or message
+ types, which really only differ in the predefined icon they each show.
+ Specify one of the four predefined message types by setting the
+ \l{QMessageBox::icon}{icon} property to one of the
+ \l{QMessageBox::Icon}{predefined icons}. The following rules are
guidelines:
\table
@@ -558,17 +558,17 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
\o For reporting critical errors.
\endtable
- The default value is \l{QMessageBox::NoIcon} {No Icon}. The
- message boxes are otherwise the same for all cases. When using a
- standard icon, use the one recommended in the table, or use the
- one recommended by the style guidelines for your platform. If none
- of the standard icons is right for your message box, you can use a
- custom icon by setting the \l{QMessageBox::iconPixmap} {icon
- pixmap} property instead of setting the \l{QMessageBox::icon}
- {icon} property.
-
- In summary, to set an icon, use \e{either} setIcon() for one of
- the standard icons, \e{or} setIconPixmap() for a custom icon.
+ \l{QMessageBox::Icon}{Predefined icons} are not defined by QMessageBox, but
+ provided by the style. The default value is \l{QMessageBox::NoIcon}
+ {No Icon}. The message boxes are otherwise the same for all cases. When
+ using a standard icon, use the one recommended in the table, or use the
+ one recommended by the style guidelines for your platform. If none of the
+ standard icons is right for your message box, you can use a custom icon by
+ setting the \l{QMessageBox::iconPixmap}{icon pixmap} property instead of
+ setting the \l{QMessageBox::icon}{icon} property.
+
+ In summary, to set an icon, use \e{either} setIcon() for one of the
+ standard icons, \e{or} setIconPixmap() for a custom icon.
\section1 The Static Functions API
diff --git a/src/gui/embedded/embedded.pri b/src/gui/embedded/embedded.pri
index 95c4132..4a9aa3f 100644
--- a/src/gui/embedded/embedded.pri
+++ b/src/gui/embedded/embedded.pri
@@ -89,6 +89,8 @@ embedded {
HEADERS += embedded/qscreendriverplugin_qws.h \
embedded/qscreendriverfactory_qws.h \
embedded/qkbd_qws.h \
+ embedded/qkbd_qws_p.h \
+ embedded/qkbd_defaultmap_qws_p.h \
embedded/qkbddriverplugin_qws.h \
embedded/qkbddriverfactory_qws.h \
embedded/qmouse_qws.h \
@@ -152,17 +154,11 @@ embedded {
contains( kbd-drivers, tty ) {
HEADERS +=embedded/qkbdtty_qws.h
SOURCES +=embedded/qkbdtty_qws.cpp
- !contains( kbd-drivers, pc101 ) {
- kbd-drivers += pc101
- }
}
- contains( kbd-drivers, usb ) {
- HEADERS +=embedded/qkbdusb_qws.h
- SOURCES +=embedded/qkbdusb_qws.cpp
- !contains( kbd-drivers, pc101 ) {
- kbd-drivers += pc101
- }
+ contains( kbd-drivers, linuxinput ) {
+ HEADERS +=embedded/qkbdlinuxinput_qws.h
+ SOURCES +=embedded/qkbdlinuxinput_qws.cpp
}
contains( kbd-drivers, um ) {
@@ -170,11 +166,6 @@ embedded {
SOURCES +=embedded/qkbdum_qws.cpp
}
- contains( kbd-drivers, pc101 ) {
- HEADERS +=embedded/qkbdpc101_qws.h
- SOURCES +=embedded/qkbdpc101_qws.cpp
- }
-
contains( kbd-drivers, yopy ) {
HEADERS +=embedded/qkbdyopy_qws.h
SOURCES +=embedded/qkbdyopy_qws.cpp
diff --git a/src/gui/embedded/qkbd_defaultmap_qws_p.h b/src/gui/embedded/qkbd_defaultmap_qws_p.h
new file mode 100644
index 0000000..0d6d77d
--- /dev/null
+++ b/src/gui/embedded/qkbd_defaultmap_qws_p.h
@@ -0,0 +1,796 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWSKEYBOARDHANDLER_DEFAULTMAP_H
+#define QWSKEYBOARDHANDLER_DEFAULTMAP_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+const QWSKeyboard::Mapping QWSKbPrivate::s_keymap_default[] = {
+ { 1, 0xffff, 0x01000000, 0x00, 0x00, 0x0000 },
+ { 2, 0x0031, 0x00000031, 0x00, 0x00, 0x0000 },
+ { 2, 0x0021, 0x00000021, 0x01, 0x00, 0x0000 },
+ { 3, 0x0032, 0x00000032, 0x00, 0x00, 0x0000 },
+ { 3, 0x0040, 0x00000040, 0x01, 0x00, 0x0000 },
+ { 3, 0x0040, 0x00000040, 0x02, 0x00, 0x0000 },
+ { 4, 0x0033, 0x00000033, 0x00, 0x00, 0x0000 },
+ { 4, 0x0023, 0x00000023, 0x01, 0x00, 0x0000 },
+ { 4, 0xffff, 0x01000000, 0x04, 0x00, 0x0000 },
+ { 5, 0x0034, 0x00000034, 0x00, 0x00, 0x0000 },
+ { 5, 0x0024, 0x00000024, 0x01, 0x00, 0x0000 },
+ { 5, 0x0024, 0x00000024, 0x02, 0x00, 0x0000 },
+ { 5, 0x005c, 0x0400005c, 0x04, 0x00, 0x0000 },
+ { 6, 0x0035, 0x00000035, 0x00, 0x00, 0x0000 },
+ { 6, 0x0025, 0x00000025, 0x01, 0x00, 0x0000 },
+ { 6, 0x005d, 0x0400005d, 0x04, 0x00, 0x0000 },
+ { 7, 0x0036, 0x00000036, 0x00, 0x00, 0x0000 },
+ { 7, 0x005e, 0x0000005e, 0x01, 0x00, 0x0000 },
+ { 7, 0x005e, 0x01001252, 0x02, 0x01, 0x0000 },
+ { 7, 0x005e, 0x0400005e, 0x04, 0x00, 0x0000 },
+ { 8, 0x0037, 0x00000037, 0x00, 0x00, 0x0000 },
+ { 8, 0x0026, 0x00000026, 0x01, 0x00, 0x0000 },
+ { 8, 0x007b, 0x0000007b, 0x02, 0x00, 0x0000 },
+ { 8, 0x005f, 0x0400005f, 0x04, 0x00, 0x0000 },
+ { 9, 0x0038, 0x00000038, 0x00, 0x00, 0x0000 },
+ { 9, 0x002a, 0x0000002a, 0x01, 0x00, 0x0000 },
+ { 9, 0x005b, 0x0000005b, 0x02, 0x00, 0x0000 },
+ { 9, 0xffff, 0x01000003, 0x04, 0x00, 0x0000 },
+ { 10, 0x0039, 0x00000039, 0x00, 0x00, 0x0000 },
+ { 10, 0x0028, 0x00000028, 0x01, 0x00, 0x0000 },
+ { 10, 0x005d, 0x0000005d, 0x02, 0x00, 0x0000 },
+ { 11, 0x0030, 0x00000030, 0x00, 0x00, 0x0000 },
+ { 11, 0x0029, 0x00000029, 0x01, 0x00, 0x0000 },
+ { 11, 0x007d, 0x0000007d, 0x02, 0x00, 0x0000 },
+ { 12, 0x002d, 0x0000002d, 0x00, 0x00, 0x0000 },
+ { 12, 0x005f, 0x0000005f, 0x01, 0x00, 0x0000 },
+ { 12, 0x005c, 0x0000005c, 0x02, 0x00, 0x0000 },
+ { 12, 0x005f, 0x0400005f, 0x04, 0x00, 0x0000 },
+ { 12, 0x005f, 0x0400005f, 0x05, 0x00, 0x0000 },
+ { 13, 0x003d, 0x0000003d, 0x00, 0x00, 0x0000 },
+ { 13, 0x002b, 0x0000002b, 0x01, 0x00, 0x0000 },
+ { 14, 0xffff, 0x01000003, 0x00, 0x00, 0x0000 },
+ { 14, 0xffff, 0x01000000, 0x0c, 0x08, 0x0300 },
+ { 15, 0xffff, 0x01000001, 0x00, 0x00, 0x0000 },
+ { 16, 0x0071, 0x00000051, 0x00, 0x00, 0x0000 },
+ { 16, 0x0051, 0x00000051, 0x01, 0x00, 0x0000 },
+ { 16, 0x0071, 0x00000051, 0x02, 0x00, 0x0000 },
+ { 16, 0x0051, 0x00000051, 0x03, 0x00, 0x0000 },
+ { 16, 0x0071, 0x04000051, 0x04, 0x00, 0x0000 },
+ { 16, 0x0071, 0x04000051, 0x05, 0x00, 0x0000 },
+ { 16, 0x0071, 0x04000051, 0x06, 0x00, 0x0000 },
+ { 16, 0x0071, 0x04000051, 0x07, 0x00, 0x0000 },
+ { 16, 0x0071, 0x08000051, 0x08, 0x00, 0x0000 },
+ { 16, 0x0071, 0x08000051, 0x09, 0x00, 0x0000 },
+ { 16, 0x0071, 0x08000051, 0x0a, 0x00, 0x0000 },
+ { 16, 0x0071, 0x08000051, 0x0b, 0x00, 0x0000 },
+ { 16, 0x0071, 0x0c000051, 0x0c, 0x00, 0x0000 },
+ { 16, 0x0071, 0x0c000051, 0x0d, 0x00, 0x0000 },
+ { 16, 0x0071, 0x0c000051, 0x0e, 0x00, 0x0000 },
+ { 16, 0x0071, 0x0c000051, 0x0f, 0x00, 0x0000 },
+ { 17, 0x0077, 0x00000057, 0x00, 0x00, 0x0000 },
+ { 17, 0x0057, 0x00000057, 0x01, 0x00, 0x0000 },
+ { 17, 0x0077, 0x00000057, 0x02, 0x00, 0x0000 },
+ { 17, 0x0057, 0x00000057, 0x03, 0x00, 0x0000 },
+ { 17, 0x0077, 0x04000057, 0x04, 0x00, 0x0000 },
+ { 17, 0x0077, 0x04000057, 0x05, 0x00, 0x0000 },
+ { 17, 0x0077, 0x04000057, 0x06, 0x00, 0x0000 },
+ { 17, 0x0077, 0x04000057, 0x07, 0x00, 0x0000 },
+ { 17, 0x0077, 0x08000057, 0x08, 0x00, 0x0000 },
+ { 17, 0x0077, 0x08000057, 0x09, 0x00, 0x0000 },
+ { 17, 0x0077, 0x08000057, 0x0a, 0x00, 0x0000 },
+ { 17, 0x0077, 0x08000057, 0x0b, 0x00, 0x0000 },
+ { 17, 0x0077, 0x0c000057, 0x0c, 0x00, 0x0000 },
+ { 17, 0x0077, 0x0c000057, 0x0d, 0x00, 0x0000 },
+ { 17, 0x0077, 0x0c000057, 0x0e, 0x00, 0x0000 },
+ { 17, 0x0077, 0x0c000057, 0x0f, 0x00, 0x0000 },
+ { 18, 0x0065, 0x00000045, 0x00, 0x00, 0x0000 },
+ { 18, 0x0045, 0x00000045, 0x01, 0x00, 0x0000 },
+ { 18, 0x0065, 0x00000045, 0x02, 0x00, 0x0000 },
+ { 18, 0x0045, 0x00000045, 0x03, 0x00, 0x0000 },
+ { 18, 0x0065, 0x04000045, 0x04, 0x00, 0x0000 },
+ { 18, 0x0065, 0x04000045, 0x05, 0x00, 0x0000 },
+ { 18, 0x0065, 0x04000045, 0x06, 0x00, 0x0000 },
+ { 18, 0x0065, 0x04000045, 0x07, 0x00, 0x0000 },
+ { 18, 0x0065, 0x08000045, 0x08, 0x00, 0x0000 },
+ { 18, 0x0065, 0x08000045, 0x09, 0x00, 0x0000 },
+ { 18, 0x0065, 0x08000045, 0x0a, 0x00, 0x0000 },
+ { 18, 0x0065, 0x08000045, 0x0b, 0x00, 0x0000 },
+ { 18, 0x0065, 0x0c000045, 0x0c, 0x00, 0x0000 },
+ { 18, 0x0065, 0x0c000045, 0x0d, 0x00, 0x0000 },
+ { 18, 0x0065, 0x0c000045, 0x0e, 0x00, 0x0000 },
+ { 18, 0x0065, 0x0c000045, 0x0f, 0x00, 0x0000 },
+ { 19, 0x0072, 0x00000052, 0x00, 0x00, 0x0000 },
+ { 19, 0x0052, 0x00000052, 0x01, 0x00, 0x0000 },
+ { 19, 0x0072, 0x00000052, 0x02, 0x00, 0x0000 },
+ { 19, 0x0052, 0x00000052, 0x03, 0x00, 0x0000 },
+ { 19, 0x0072, 0x04000052, 0x04, 0x00, 0x0000 },
+ { 19, 0x0072, 0x04000052, 0x05, 0x00, 0x0000 },
+ { 19, 0x0072, 0x04000052, 0x06, 0x00, 0x0000 },
+ { 19, 0x0072, 0x04000052, 0x07, 0x00, 0x0000 },
+ { 19, 0x0072, 0x08000052, 0x08, 0x00, 0x0000 },
+ { 19, 0x0072, 0x08000052, 0x09, 0x00, 0x0000 },
+ { 19, 0x0072, 0x08000052, 0x0a, 0x00, 0x0000 },
+ { 19, 0x0072, 0x08000052, 0x0b, 0x00, 0x0000 },
+ { 19, 0x0072, 0x0c000052, 0x0c, 0x00, 0x0000 },
+ { 19, 0x0072, 0x0c000052, 0x0d, 0x00, 0x0000 },
+ { 19, 0x0072, 0x0c000052, 0x0e, 0x00, 0x0000 },
+ { 19, 0x0072, 0x0c000052, 0x0f, 0x00, 0x0000 },
+ { 20, 0x0074, 0x00000054, 0x00, 0x00, 0x0000 },
+ { 20, 0x0054, 0x00000054, 0x01, 0x00, 0x0000 },
+ { 20, 0x0074, 0x00000054, 0x02, 0x00, 0x0000 },
+ { 20, 0x0054, 0x00000054, 0x03, 0x00, 0x0000 },
+ { 20, 0x0074, 0x04000054, 0x04, 0x00, 0x0000 },
+ { 20, 0x0074, 0x04000054, 0x05, 0x00, 0x0000 },
+ { 20, 0x0074, 0x04000054, 0x06, 0x00, 0x0000 },
+ { 20, 0x0074, 0x04000054, 0x07, 0x00, 0x0000 },
+ { 20, 0x0074, 0x08000054, 0x08, 0x00, 0x0000 },
+ { 20, 0x0074, 0x08000054, 0x09, 0x00, 0x0000 },
+ { 20, 0x0074, 0x08000054, 0x0a, 0x00, 0x0000 },
+ { 20, 0x0074, 0x08000054, 0x0b, 0x00, 0x0000 },
+ { 20, 0x0074, 0x0c000054, 0x0c, 0x00, 0x0000 },
+ { 20, 0x0074, 0x0c000054, 0x0d, 0x00, 0x0000 },
+ { 20, 0x0074, 0x0c000054, 0x0e, 0x00, 0x0000 },
+ { 20, 0x0074, 0x0c000054, 0x0f, 0x00, 0x0000 },
+ { 21, 0x0079, 0x00000059, 0x00, 0x00, 0x0000 },
+ { 21, 0x0059, 0x00000059, 0x01, 0x00, 0x0000 },
+ { 21, 0x0079, 0x00000059, 0x02, 0x00, 0x0000 },
+ { 21, 0x0059, 0x00000059, 0x03, 0x00, 0x0000 },
+ { 21, 0x0079, 0x04000059, 0x04, 0x00, 0x0000 },
+ { 21, 0x0079, 0x04000059, 0x05, 0x00, 0x0000 },
+ { 21, 0x0079, 0x04000059, 0x06, 0x00, 0x0000 },
+ { 21, 0x0079, 0x04000059, 0x07, 0x00, 0x0000 },
+ { 21, 0x0079, 0x08000059, 0x08, 0x00, 0x0000 },
+ { 21, 0x0079, 0x08000059, 0x09, 0x00, 0x0000 },
+ { 21, 0x0079, 0x08000059, 0x0a, 0x00, 0x0000 },
+ { 21, 0x0079, 0x08000059, 0x0b, 0x00, 0x0000 },
+ { 21, 0x0079, 0x0c000059, 0x0c, 0x00, 0x0000 },
+ { 21, 0x0079, 0x0c000059, 0x0d, 0x00, 0x0000 },
+ { 21, 0x0079, 0x0c000059, 0x0e, 0x00, 0x0000 },
+ { 21, 0x0079, 0x0c000059, 0x0f, 0x00, 0x0000 },
+ { 22, 0x0075, 0x00000055, 0x00, 0x00, 0x0000 },
+ { 22, 0x0055, 0x00000055, 0x01, 0x00, 0x0000 },
+ { 22, 0x0075, 0x00000055, 0x02, 0x00, 0x0000 },
+ { 22, 0x0055, 0x00000055, 0x03, 0x00, 0x0000 },
+ { 22, 0x0075, 0x04000055, 0x04, 0x00, 0x0000 },
+ { 22, 0x0075, 0x04000055, 0x05, 0x00, 0x0000 },
+ { 22, 0x0075, 0x04000055, 0x06, 0x00, 0x0000 },
+ { 22, 0x0075, 0x04000055, 0x07, 0x00, 0x0000 },
+ { 22, 0x0075, 0x08000055, 0x08, 0x00, 0x0000 },
+ { 22, 0x0075, 0x08000055, 0x09, 0x00, 0x0000 },
+ { 22, 0x0075, 0x08000055, 0x0a, 0x00, 0x0000 },
+ { 22, 0x0075, 0x08000055, 0x0b, 0x00, 0x0000 },
+ { 22, 0x0075, 0x0c000055, 0x0c, 0x00, 0x0000 },
+ { 22, 0x0075, 0x0c000055, 0x0d, 0x00, 0x0000 },
+ { 22, 0x0075, 0x0c000055, 0x0e, 0x00, 0x0000 },
+ { 22, 0x0075, 0x0c000055, 0x0f, 0x00, 0x0000 },
+ { 23, 0x0069, 0x00000049, 0x00, 0x00, 0x0000 },
+ { 23, 0x0049, 0x00000049, 0x01, 0x00, 0x0000 },
+ { 23, 0x0069, 0x00000049, 0x02, 0x00, 0x0000 },
+ { 23, 0x0049, 0x00000049, 0x03, 0x00, 0x0000 },
+ { 23, 0x0069, 0x04000049, 0x04, 0x00, 0x0000 },
+ { 23, 0x0069, 0x04000049, 0x05, 0x00, 0x0000 },
+ { 23, 0x0069, 0x04000049, 0x06, 0x00, 0x0000 },
+ { 23, 0x0069, 0x04000049, 0x07, 0x00, 0x0000 },
+ { 23, 0x0069, 0x08000049, 0x08, 0x00, 0x0000 },
+ { 23, 0x0069, 0x08000049, 0x09, 0x00, 0x0000 },
+ { 23, 0x0069, 0x08000049, 0x0a, 0x00, 0x0000 },
+ { 23, 0x0069, 0x08000049, 0x0b, 0x00, 0x0000 },
+ { 23, 0x0069, 0x0c000049, 0x0c, 0x00, 0x0000 },
+ { 23, 0x0069, 0x0c000049, 0x0d, 0x00, 0x0000 },
+ { 23, 0x0069, 0x0c000049, 0x0e, 0x00, 0x0000 },
+ { 23, 0x0069, 0x0c000049, 0x0f, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0000004f, 0x00, 0x00, 0x0000 },
+ { 24, 0x004f, 0x0000004f, 0x01, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0000004f, 0x02, 0x00, 0x0000 },
+ { 24, 0x004f, 0x0000004f, 0x03, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0400004f, 0x04, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0400004f, 0x05, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0400004f, 0x06, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0400004f, 0x07, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0800004f, 0x08, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0800004f, 0x09, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0800004f, 0x0a, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0800004f, 0x0b, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0c00004f, 0x0c, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0c00004f, 0x0d, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0c00004f, 0x0e, 0x00, 0x0000 },
+ { 24, 0x006f, 0x0c00004f, 0x0f, 0x00, 0x0000 },
+ { 25, 0x0070, 0x00000050, 0x00, 0x00, 0x0000 },
+ { 25, 0x0050, 0x00000050, 0x01, 0x00, 0x0000 },
+ { 25, 0x0070, 0x00000050, 0x02, 0x00, 0x0000 },
+ { 25, 0x0050, 0x00000050, 0x03, 0x00, 0x0000 },
+ { 25, 0x0070, 0x04000050, 0x04, 0x00, 0x0000 },
+ { 25, 0x0070, 0x04000050, 0x05, 0x00, 0x0000 },
+ { 25, 0x0070, 0x04000050, 0x06, 0x00, 0x0000 },
+ { 25, 0x0070, 0x04000050, 0x07, 0x00, 0x0000 },
+ { 25, 0x0070, 0x08000050, 0x08, 0x00, 0x0000 },
+ { 25, 0x0070, 0x08000050, 0x09, 0x00, 0x0000 },
+ { 25, 0x0070, 0x08000050, 0x0a, 0x00, 0x0000 },
+ { 25, 0x0070, 0x08000050, 0x0b, 0x00, 0x0000 },
+ { 25, 0x0070, 0x0c000050, 0x0c, 0x00, 0x0000 },
+ { 25, 0x0070, 0x0c000050, 0x0d, 0x00, 0x0000 },
+ { 25, 0x0070, 0x0c000050, 0x0e, 0x00, 0x0000 },
+ { 25, 0x0070, 0x0c000050, 0x0f, 0x00, 0x0000 },
+ { 26, 0x005b, 0x0000005b, 0x00, 0x00, 0x0000 },
+ { 26, 0x007b, 0x0000007b, 0x01, 0x00, 0x0000 },
+ { 26, 0xffff, 0x01000000, 0x04, 0x00, 0x0000 },
+ { 27, 0x005d, 0x0000005d, 0x00, 0x00, 0x0000 },
+ { 27, 0x007d, 0x0000007d, 0x01, 0x00, 0x0000 },
+ { 27, 0x007e, 0x0000007e, 0x02, 0x00, 0x0000 },
+ { 27, 0x005d, 0x0400005d, 0x04, 0x00, 0x0000 },
+ { 28, 0xffff, 0x01000004, 0x00, 0x00, 0x0000 },
+ { 28, 0x006d, 0x0c00004d, 0x08, 0x00, 0x0000 },
+ { 29, 0xffff, 0x01000021, 0x00, 0x04, 0x0004 },
+ { 30, 0x0061, 0x00000041, 0x00, 0x00, 0x0000 },
+ { 30, 0x0041, 0x00000041, 0x01, 0x00, 0x0000 },
+ { 30, 0x0061, 0x00000041, 0x02, 0x00, 0x0000 },
+ { 30, 0x0041, 0x00000041, 0x03, 0x00, 0x0000 },
+ { 30, 0x0061, 0x04000041, 0x04, 0x00, 0x0000 },
+ { 30, 0x0061, 0x04000041, 0x05, 0x00, 0x0000 },
+ { 30, 0x0061, 0x04000041, 0x06, 0x00, 0x0000 },
+ { 30, 0x0061, 0x04000041, 0x07, 0x00, 0x0000 },
+ { 30, 0x0061, 0x08000041, 0x08, 0x00, 0x0000 },
+ { 30, 0x0061, 0x08000041, 0x09, 0x00, 0x0000 },
+ { 30, 0x0061, 0x08000041, 0x0a, 0x00, 0x0000 },
+ { 30, 0x0061, 0x08000041, 0x0b, 0x00, 0x0000 },
+ { 30, 0x0061, 0x0c000041, 0x0c, 0x00, 0x0000 },
+ { 30, 0x0061, 0x0c000041, 0x0d, 0x00, 0x0000 },
+ { 30, 0x0061, 0x0c000041, 0x0e, 0x00, 0x0000 },
+ { 30, 0x0061, 0x0c000041, 0x0f, 0x00, 0x0000 },
+ { 31, 0x0073, 0x00000053, 0x00, 0x00, 0x0000 },
+ { 31, 0x0053, 0x00000053, 0x01, 0x00, 0x0000 },
+ { 31, 0x0073, 0x00000053, 0x02, 0x00, 0x0000 },
+ { 31, 0x0053, 0x00000053, 0x03, 0x00, 0x0000 },
+ { 31, 0x0073, 0x04000053, 0x04, 0x00, 0x0000 },
+ { 31, 0x0073, 0x04000053, 0x05, 0x00, 0x0000 },
+ { 31, 0x0073, 0x04000053, 0x06, 0x00, 0x0000 },
+ { 31, 0x0073, 0x04000053, 0x07, 0x00, 0x0000 },
+ { 31, 0x0073, 0x08000053, 0x08, 0x00, 0x0000 },
+ { 31, 0x0073, 0x08000053, 0x09, 0x00, 0x0000 },
+ { 31, 0x0073, 0x08000053, 0x0a, 0x00, 0x0000 },
+ { 31, 0x0073, 0x08000053, 0x0b, 0x00, 0x0000 },
+ { 31, 0x0073, 0x0c000053, 0x0c, 0x00, 0x0000 },
+ { 31, 0x0073, 0x0c000053, 0x0d, 0x00, 0x0000 },
+ { 31, 0x0073, 0x0c000053, 0x0e, 0x00, 0x0000 },
+ { 31, 0x0073, 0x0c000053, 0x0f, 0x00, 0x0000 },
+ { 32, 0x0064, 0x00000044, 0x00, 0x00, 0x0000 },
+ { 32, 0x0044, 0x00000044, 0x01, 0x00, 0x0000 },
+ { 32, 0x0064, 0x00000044, 0x02, 0x00, 0x0000 },
+ { 32, 0x0044, 0x00000044, 0x03, 0x00, 0x0000 },
+ { 32, 0x0064, 0x04000044, 0x04, 0x00, 0x0000 },
+ { 32, 0x0064, 0x04000044, 0x05, 0x00, 0x0000 },
+ { 32, 0x0064, 0x04000044, 0x06, 0x00, 0x0000 },
+ { 32, 0x0064, 0x04000044, 0x07, 0x00, 0x0000 },
+ { 32, 0x0064, 0x08000044, 0x08, 0x00, 0x0000 },
+ { 32, 0x0064, 0x08000044, 0x09, 0x00, 0x0000 },
+ { 32, 0x0064, 0x08000044, 0x0a, 0x00, 0x0000 },
+ { 32, 0x0064, 0x08000044, 0x0b, 0x00, 0x0000 },
+ { 32, 0x0064, 0x0c000044, 0x0c, 0x00, 0x0000 },
+ { 32, 0x0064, 0x0c000044, 0x0d, 0x00, 0x0000 },
+ { 32, 0x0064, 0x0c000044, 0x0e, 0x00, 0x0000 },
+ { 32, 0x0064, 0x0c000044, 0x0f, 0x00, 0x0000 },
+ { 33, 0x0066, 0x00000046, 0x00, 0x00, 0x0000 },
+ { 33, 0x0046, 0x00000046, 0x01, 0x00, 0x0000 },
+ { 33, 0x0066, 0x00000046, 0x02, 0x00, 0x0000 },
+ { 33, 0x0046, 0x00000046, 0x03, 0x00, 0x0000 },
+ { 33, 0x0066, 0x04000046, 0x04, 0x00, 0x0000 },
+ { 33, 0x0066, 0x04000046, 0x05, 0x00, 0x0000 },
+ { 33, 0x0066, 0x04000046, 0x06, 0x00, 0x0000 },
+ { 33, 0x0066, 0x04000046, 0x07, 0x00, 0x0000 },
+ { 33, 0x0066, 0x08000046, 0x08, 0x00, 0x0000 },
+ { 33, 0x0066, 0x08000046, 0x09, 0x00, 0x0000 },
+ { 33, 0x0066, 0x08000046, 0x0a, 0x00, 0x0000 },
+ { 33, 0x0066, 0x08000046, 0x0b, 0x00, 0x0000 },
+ { 33, 0x0066, 0x0c000046, 0x0c, 0x00, 0x0000 },
+ { 33, 0x0066, 0x0c000046, 0x0d, 0x00, 0x0000 },
+ { 33, 0x0066, 0x0c000046, 0x0e, 0x00, 0x0000 },
+ { 33, 0x0066, 0x0c000046, 0x0f, 0x00, 0x0000 },
+ { 34, 0x0067, 0x00000047, 0x00, 0x00, 0x0000 },
+ { 34, 0x0047, 0x00000047, 0x01, 0x00, 0x0000 },
+ { 34, 0x0067, 0x00000047, 0x02, 0x00, 0x0000 },
+ { 34, 0x0047, 0x00000047, 0x03, 0x00, 0x0000 },
+ { 34, 0x0067, 0x04000047, 0x04, 0x00, 0x0000 },
+ { 34, 0x0067, 0x04000047, 0x05, 0x00, 0x0000 },
+ { 34, 0x0067, 0x04000047, 0x06, 0x00, 0x0000 },
+ { 34, 0x0067, 0x04000047, 0x07, 0x00, 0x0000 },
+ { 34, 0x0067, 0x08000047, 0x08, 0x00, 0x0000 },
+ { 34, 0x0067, 0x08000047, 0x09, 0x00, 0x0000 },
+ { 34, 0x0067, 0x08000047, 0x0a, 0x00, 0x0000 },
+ { 34, 0x0067, 0x08000047, 0x0b, 0x00, 0x0000 },
+ { 34, 0x0067, 0x0c000047, 0x0c, 0x00, 0x0000 },
+ { 34, 0x0067, 0x0c000047, 0x0d, 0x00, 0x0000 },
+ { 34, 0x0067, 0x0c000047, 0x0e, 0x00, 0x0000 },
+ { 34, 0x0067, 0x0c000047, 0x0f, 0x00, 0x0000 },
+ { 35, 0x0068, 0x00000048, 0x00, 0x00, 0x0000 },
+ { 35, 0x0048, 0x00000048, 0x01, 0x00, 0x0000 },
+ { 35, 0x0068, 0x00000048, 0x02, 0x00, 0x0000 },
+ { 35, 0x0048, 0x00000048, 0x03, 0x00, 0x0000 },
+ { 35, 0x0068, 0x04000048, 0x04, 0x00, 0x0000 },
+ { 35, 0x0068, 0x04000048, 0x05, 0x00, 0x0000 },
+ { 35, 0x0068, 0x04000048, 0x06, 0x00, 0x0000 },
+ { 35, 0x0068, 0x04000048, 0x07, 0x00, 0x0000 },
+ { 35, 0x0068, 0x08000048, 0x08, 0x00, 0x0000 },
+ { 35, 0x0068, 0x08000048, 0x09, 0x00, 0x0000 },
+ { 35, 0x0068, 0x08000048, 0x0a, 0x00, 0x0000 },
+ { 35, 0x0068, 0x08000048, 0x0b, 0x00, 0x0000 },
+ { 35, 0x0068, 0x0c000048, 0x0c, 0x00, 0x0000 },
+ { 35, 0x0068, 0x0c000048, 0x0d, 0x00, 0x0000 },
+ { 35, 0x0068, 0x0c000048, 0x0e, 0x00, 0x0000 },
+ { 35, 0x0068, 0x0c000048, 0x0f, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0000004a, 0x00, 0x00, 0x0000 },
+ { 36, 0x004a, 0x0000004a, 0x01, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0000004a, 0x02, 0x00, 0x0000 },
+ { 36, 0x004a, 0x0000004a, 0x03, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0400004a, 0x04, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0400004a, 0x05, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0400004a, 0x06, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0400004a, 0x07, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0800004a, 0x08, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0800004a, 0x09, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0800004a, 0x0a, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0800004a, 0x0b, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0c00004a, 0x0c, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0c00004a, 0x0d, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0c00004a, 0x0e, 0x00, 0x0000 },
+ { 36, 0x006a, 0x0c00004a, 0x0f, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0000004b, 0x00, 0x00, 0x0000 },
+ { 37, 0x004b, 0x0000004b, 0x01, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0000004b, 0x02, 0x00, 0x0000 },
+ { 37, 0x004b, 0x0000004b, 0x03, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0400004b, 0x04, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0400004b, 0x05, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0400004b, 0x06, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0400004b, 0x07, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0800004b, 0x08, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0800004b, 0x09, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0800004b, 0x0a, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0800004b, 0x0b, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0c00004b, 0x0c, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0c00004b, 0x0d, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0c00004b, 0x0e, 0x00, 0x0000 },
+ { 37, 0x006b, 0x0c00004b, 0x0f, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0000004c, 0x00, 0x00, 0x0000 },
+ { 38, 0x004c, 0x0000004c, 0x01, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0000004c, 0x02, 0x00, 0x0000 },
+ { 38, 0x004c, 0x0000004c, 0x03, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0400004c, 0x04, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0400004c, 0x05, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0400004c, 0x06, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0400004c, 0x07, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0800004c, 0x08, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0800004c, 0x09, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0800004c, 0x0a, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0800004c, 0x0b, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0c00004c, 0x0c, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0c00004c, 0x0d, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0c00004c, 0x0e, 0x00, 0x0000 },
+ { 38, 0x006c, 0x0c00004c, 0x0f, 0x00, 0x0000 },
+ { 39, 0x003b, 0x0000003b, 0x00, 0x00, 0x0000 },
+ { 39, 0x003a, 0x0000003a, 0x01, 0x00, 0x0000 },
+ { 40, 0x0027, 0x00000027, 0x00, 0x00, 0x0000 },
+ { 40, 0x0022, 0x00000022, 0x01, 0x00, 0x0000 },
+ { 40, 0x0027, 0x01001251, 0x02, 0x01, 0x0000 },
+ { 40, 0x0022, 0x01001257, 0x03, 0x01, 0x0000 },
+ { 40, 0x0067, 0x04000047, 0x04, 0x00, 0x0000 },
+ { 41, 0x0060, 0x00000060, 0x00, 0x00, 0x0000 },
+ { 41, 0x007e, 0x0000007e, 0x01, 0x00, 0x0000 },
+ { 41, 0x0060, 0x01001250, 0x02, 0x01, 0x0000 },
+ { 41, 0x007e, 0x01001253, 0x03, 0x01, 0x0000 },
+ { 42, 0xffff, 0x01000020, 0x00, 0x04, 0x0001 },
+ { 43, 0x005c, 0x0000005c, 0x00, 0x00, 0x0000 },
+ { 43, 0x007c, 0x0000007c, 0x01, 0x00, 0x0000 },
+ { 43, 0x005c, 0x0400005c, 0x04, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0000005a, 0x00, 0x00, 0x0000 },
+ { 44, 0x005a, 0x0000005a, 0x01, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0000005a, 0x02, 0x00, 0x0000 },
+ { 44, 0x005a, 0x0000005a, 0x03, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0400005a, 0x04, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0400005a, 0x05, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0400005a, 0x06, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0400005a, 0x07, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0800005a, 0x08, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0800005a, 0x09, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0800005a, 0x0a, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0800005a, 0x0b, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0c00005a, 0x0c, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0c00005a, 0x0d, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0c00005a, 0x0e, 0x00, 0x0000 },
+ { 44, 0x007a, 0x0c00005a, 0x0f, 0x00, 0x0000 },
+ { 45, 0x0078, 0x00000058, 0x00, 0x00, 0x0000 },
+ { 45, 0x0058, 0x00000058, 0x01, 0x00, 0x0000 },
+ { 45, 0x0078, 0x00000058, 0x02, 0x00, 0x0000 },
+ { 45, 0x0058, 0x00000058, 0x03, 0x00, 0x0000 },
+ { 45, 0x0078, 0x04000058, 0x04, 0x00, 0x0000 },
+ { 45, 0x0078, 0x04000058, 0x05, 0x00, 0x0000 },
+ { 45, 0x0078, 0x04000058, 0x06, 0x00, 0x0000 },
+ { 45, 0x0078, 0x04000058, 0x07, 0x00, 0x0000 },
+ { 45, 0x0078, 0x08000058, 0x08, 0x00, 0x0000 },
+ { 45, 0x0078, 0x08000058, 0x09, 0x00, 0x0000 },
+ { 45, 0x0078, 0x08000058, 0x0a, 0x00, 0x0000 },
+ { 45, 0x0078, 0x08000058, 0x0b, 0x00, 0x0000 },
+ { 45, 0x0078, 0x0c000058, 0x0c, 0x00, 0x0000 },
+ { 45, 0x0078, 0x0c000058, 0x0d, 0x00, 0x0000 },
+ { 45, 0x0078, 0x0c000058, 0x0e, 0x00, 0x0000 },
+ { 45, 0x0078, 0x0c000058, 0x0f, 0x00, 0x0000 },
+ { 46, 0x0063, 0x00000043, 0x00, 0x00, 0x0000 },
+ { 46, 0x0043, 0x00000043, 0x01, 0x00, 0x0000 },
+ { 46, 0x0063, 0x00000043, 0x02, 0x00, 0x0000 },
+ { 46, 0x0043, 0x00000043, 0x03, 0x00, 0x0000 },
+ { 46, 0x0063, 0x04000043, 0x04, 0x00, 0x0000 },
+ { 46, 0x0063, 0x04000043, 0x05, 0x00, 0x0000 },
+ { 46, 0x0063, 0x04000043, 0x06, 0x00, 0x0000 },
+ { 46, 0x0063, 0x04000043, 0x07, 0x00, 0x0000 },
+ { 46, 0x0063, 0x08000043, 0x08, 0x00, 0x0000 },
+ { 46, 0x0063, 0x08000043, 0x09, 0x00, 0x0000 },
+ { 46, 0x0063, 0x08000043, 0x0a, 0x00, 0x0000 },
+ { 46, 0x0063, 0x08000043, 0x0b, 0x00, 0x0000 },
+ { 46, 0x0063, 0x0c000043, 0x0c, 0x00, 0x0000 },
+ { 46, 0x0063, 0x0c000043, 0x0d, 0x00, 0x0000 },
+ { 46, 0x0063, 0x0c000043, 0x0e, 0x00, 0x0000 },
+ { 46, 0x0063, 0x0c000043, 0x0f, 0x00, 0x0000 },
+ { 47, 0x0076, 0x00000056, 0x00, 0x00, 0x0000 },
+ { 47, 0x0056, 0x00000056, 0x01, 0x00, 0x0000 },
+ { 47, 0x0076, 0x00000056, 0x02, 0x00, 0x0000 },
+ { 47, 0x0056, 0x00000056, 0x03, 0x00, 0x0000 },
+ { 47, 0x0076, 0x04000056, 0x04, 0x00, 0x0000 },
+ { 47, 0x0076, 0x04000056, 0x05, 0x00, 0x0000 },
+ { 47, 0x0076, 0x04000056, 0x06, 0x00, 0x0000 },
+ { 47, 0x0076, 0x04000056, 0x07, 0x00, 0x0000 },
+ { 47, 0x0076, 0x08000056, 0x08, 0x00, 0x0000 },
+ { 47, 0x0076, 0x08000056, 0x09, 0x00, 0x0000 },
+ { 47, 0x0076, 0x08000056, 0x0a, 0x00, 0x0000 },
+ { 47, 0x0076, 0x08000056, 0x0b, 0x00, 0x0000 },
+ { 47, 0x0076, 0x0c000056, 0x0c, 0x00, 0x0000 },
+ { 47, 0x0076, 0x0c000056, 0x0d, 0x00, 0x0000 },
+ { 47, 0x0076, 0x0c000056, 0x0e, 0x00, 0x0000 },
+ { 47, 0x0076, 0x0c000056, 0x0f, 0x00, 0x0000 },
+ { 48, 0x0062, 0x00000042, 0x00, 0x00, 0x0000 },
+ { 48, 0x0042, 0x00000042, 0x01, 0x00, 0x0000 },
+ { 48, 0x0062, 0x00000042, 0x02, 0x00, 0x0000 },
+ { 48, 0x0042, 0x00000042, 0x03, 0x00, 0x0000 },
+ { 48, 0x0062, 0x04000042, 0x04, 0x00, 0x0000 },
+ { 48, 0x0062, 0x04000042, 0x05, 0x00, 0x0000 },
+ { 48, 0x0062, 0x04000042, 0x06, 0x00, 0x0000 },
+ { 48, 0x0062, 0x04000042, 0x07, 0x00, 0x0000 },
+ { 48, 0x0062, 0x08000042, 0x08, 0x00, 0x0000 },
+ { 48, 0x0062, 0x08000042, 0x09, 0x00, 0x0000 },
+ { 48, 0x0062, 0x08000042, 0x0a, 0x00, 0x0000 },
+ { 48, 0x0062, 0x08000042, 0x0b, 0x00, 0x0000 },
+ { 48, 0x0062, 0x0c000042, 0x0c, 0x00, 0x0000 },
+ { 48, 0x0062, 0x0c000042, 0x0d, 0x00, 0x0000 },
+ { 48, 0x0062, 0x0c000042, 0x0e, 0x00, 0x0000 },
+ { 48, 0x0062, 0x0c000042, 0x0f, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0000004e, 0x00, 0x00, 0x0000 },
+ { 49, 0x004e, 0x0000004e, 0x01, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0000004e, 0x02, 0x00, 0x0000 },
+ { 49, 0x004e, 0x0000004e, 0x03, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0400004e, 0x04, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0400004e, 0x05, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0400004e, 0x06, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0400004e, 0x07, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0800004e, 0x08, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0800004e, 0x09, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0800004e, 0x0a, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0800004e, 0x0b, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0c00004e, 0x0c, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0c00004e, 0x0d, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0c00004e, 0x0e, 0x00, 0x0000 },
+ { 49, 0x006e, 0x0c00004e, 0x0f, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0000004d, 0x00, 0x00, 0x0000 },
+ { 50, 0x004d, 0x0000004d, 0x01, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0000004d, 0x02, 0x00, 0x0000 },
+ { 50, 0x004d, 0x0000004d, 0x03, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0400004d, 0x04, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0400004d, 0x05, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0400004d, 0x06, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0400004d, 0x07, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0800004d, 0x08, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0800004d, 0x09, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0800004d, 0x0a, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0800004d, 0x0b, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0c00004d, 0x0c, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0c00004d, 0x0d, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0c00004d, 0x0e, 0x00, 0x0000 },
+ { 50, 0x006d, 0x0c00004d, 0x0f, 0x00, 0x0000 },
+ { 51, 0x002c, 0x0000002c, 0x00, 0x00, 0x0000 },
+ { 51, 0x003c, 0x0000003c, 0x01, 0x00, 0x0000 },
+ { 51, 0x002c, 0x0100125b, 0x02, 0x01, 0x0000 },
+ { 52, 0x002e, 0x0000002e, 0x00, 0x00, 0x0000 },
+ { 52, 0x003e, 0x0000003e, 0x01, 0x00, 0x0000 },
+ { 52, 0xffff, 0x01001120, 0x02, 0x00, 0x0000 },
+ { 53, 0x002f, 0x0000002f, 0x00, 0x00, 0x0000 },
+ { 53, 0x003f, 0x0000003f, 0x01, 0x00, 0x0000 },
+ { 53, 0xffff, 0x01000003, 0x04, 0x00, 0x0000 },
+ { 54, 0xffff, 0x01000020, 0x00, 0x04, 0x0001 },
+ { 55, 0x002a, 0x2000002a, 0x00, 0x00, 0x0000 },
+ { 56, 0xffff, 0x01000023, 0x00, 0x04, 0x0008 },
+ { 57, 0x0020, 0x00000020, 0x00, 0x00, 0x0000 },
+ { 58, 0xffff, 0x01000024, 0x00, 0x00, 0x0000 },
+ { 59, 0xffff, 0x01000030, 0x00, 0x00, 0x0000 },
+ { 59, 0xffff, 0x0100003c, 0x01, 0x00, 0x0000 },
+ { 59, 0xffff, 0x01000048, 0x04, 0x00, 0x0000 },
+ { 59, 0xffff, 0x01000000, 0x0c, 0x08, 0x0100 },
+ { 60, 0xffff, 0x01000031, 0x00, 0x00, 0x0000 },
+ { 60, 0xffff, 0x0100003d, 0x01, 0x00, 0x0000 },
+ { 60, 0xffff, 0x01000049, 0x04, 0x00, 0x0000 },
+ { 60, 0xffff, 0x01000000, 0x0c, 0x08, 0x0101 },
+ { 61, 0xffff, 0x01000032, 0x00, 0x00, 0x0000 },
+ { 61, 0xffff, 0x0100003e, 0x01, 0x00, 0x0000 },
+ { 61, 0xffff, 0x0100004a, 0x04, 0x00, 0x0000 },
+ { 61, 0xffff, 0x01000000, 0x0c, 0x08, 0x0102 },
+ { 62, 0xffff, 0x01000033, 0x00, 0x00, 0x0000 },
+ { 62, 0xffff, 0x0100003f, 0x01, 0x00, 0x0000 },
+ { 62, 0xffff, 0x0100004b, 0x04, 0x00, 0x0000 },
+ { 62, 0xffff, 0x01000000, 0x0c, 0x08, 0x0103 },
+ { 63, 0xffff, 0x01000034, 0x00, 0x00, 0x0000 },
+ { 63, 0xffff, 0x01000040, 0x01, 0x00, 0x0000 },
+ { 63, 0xffff, 0x0100004c, 0x04, 0x00, 0x0000 },
+ { 63, 0xffff, 0x01000000, 0x0c, 0x08, 0x0104 },
+ { 64, 0xffff, 0x01000035, 0x00, 0x00, 0x0000 },
+ { 64, 0xffff, 0x01000041, 0x01, 0x00, 0x0000 },
+ { 64, 0xffff, 0x0100004d, 0x04, 0x00, 0x0000 },
+ { 64, 0xffff, 0x01000000, 0x0c, 0x08, 0x0105 },
+ { 65, 0xffff, 0x01000036, 0x00, 0x00, 0x0000 },
+ { 65, 0xffff, 0x01000042, 0x01, 0x00, 0x0000 },
+ { 65, 0xffff, 0x0100004e, 0x04, 0x00, 0x0000 },
+ { 65, 0xffff, 0x01000000, 0x0c, 0x08, 0x0106 },
+ { 66, 0xffff, 0x01000037, 0x00, 0x00, 0x0000 },
+ { 66, 0xffff, 0x01000043, 0x01, 0x00, 0x0000 },
+ { 66, 0xffff, 0x0100004f, 0x04, 0x00, 0x0000 },
+ { 66, 0xffff, 0x01000000, 0x0c, 0x08, 0x0107 },
+ { 67, 0xffff, 0x01000038, 0x00, 0x00, 0x0000 },
+ { 67, 0xffff, 0x01000044, 0x01, 0x00, 0x0000 },
+ { 67, 0xffff, 0x01000050, 0x04, 0x00, 0x0000 },
+ { 67, 0xffff, 0x01000000, 0x0c, 0x08, 0x0108 },
+ { 68, 0xffff, 0x01000039, 0x00, 0x00, 0x0000 },
+ { 68, 0xffff, 0x01000045, 0x01, 0x00, 0x0000 },
+ { 68, 0xffff, 0x01000051, 0x04, 0x00, 0x0000 },
+ { 68, 0xffff, 0x01000000, 0x0c, 0x08, 0x0109 },
+ { 69, 0xffff, 0x01000025, 0x00, 0x00, 0x0000 },
+ { 70, 0xffff, 0x01000026, 0x00, 0x00, 0x0000 },
+ { 70, 0xffff, 0x01000026, 0x08, 0x00, 0x0000 },
+ { 71, 0x0037, 0x20000037, 0x00, 0x00, 0x0000 },
+ { 72, 0x0038, 0x20000038, 0x00, 0x00, 0x0000 },
+ { 73, 0x0039, 0x20000039, 0x00, 0x00, 0x0000 },
+ { 74, 0x002d, 0x2000002d, 0x00, 0x00, 0x0000 },
+ { 75, 0x0034, 0x20000034, 0x00, 0x00, 0x0000 },
+ { 76, 0x0035, 0x20000035, 0x00, 0x00, 0x0000 },
+ { 77, 0x0036, 0x20000036, 0x00, 0x00, 0x0000 },
+ { 78, 0x002b, 0x2000002b, 0x00, 0x00, 0x0000 },
+ { 79, 0x0031, 0x20000031, 0x00, 0x00, 0x0000 },
+ { 80, 0x0032, 0x20000032, 0x00, 0x00, 0x0000 },
+ { 81, 0x0033, 0x20000033, 0x00, 0x00, 0x0000 },
+ { 82, 0x0030, 0x20000030, 0x00, 0x00, 0x0000 },
+ { 83, 0x002e, 0x2000002e, 0x00, 0x00, 0x0000 },
+ { 83, 0xffff, 0x01000000, 0x06, 0x08, 0x0200 },
+ { 83, 0xffff, 0x01000000, 0x0c, 0x08, 0x0200 },
+ { 86, 0x003c, 0x0000003c, 0x00, 0x00, 0x0000 },
+ { 86, 0x003e, 0x0000003e, 0x01, 0x00, 0x0000 },
+ { 86, 0x007c, 0x0000007c, 0x02, 0x00, 0x0000 },
+ { 87, 0xffff, 0x0100003a, 0x00, 0x00, 0x0000 },
+ { 87, 0xffff, 0x01000046, 0x01, 0x00, 0x0000 },
+ { 87, 0xffff, 0x01000052, 0x04, 0x00, 0x0000 },
+ { 87, 0xffff, 0x01000000, 0x0c, 0x08, 0x010a },
+ { 88, 0xffff, 0x0100003b, 0x00, 0x00, 0x0000 },
+ { 88, 0xffff, 0x01000047, 0x01, 0x00, 0x0000 },
+ { 88, 0xffff, 0x01000000, 0x0c, 0x08, 0x010b },
+ { 96, 0xffff, 0x21000005, 0x00, 0x00, 0x0000 },
+ { 97, 0xffff, 0x01000021, 0x00, 0x04, 0x0004 },
+ { 98, 0x002f, 0x2000002f, 0x00, 0x00, 0x0000 },
+ { 99, 0x005c, 0x0400005c, 0x00, 0x00, 0x0000 },
+ { 100, 0xffff, 0x01001103, 0x00, 0x04, 0x0002 },
+ { 102, 0xffff, 0x01000010, 0x00, 0x00, 0x0000 },
+ { 103, 0xffff, 0x01000013, 0x00, 0x00, 0x0000 },
+ { 104, 0xffff, 0x01000016, 0x00, 0x00, 0x0000 },
+ { 105, 0xffff, 0x01000012, 0x00, 0x00, 0x0000 },
+ { 105, 0xffff, 0x01000000, 0x0c, 0x08, 0x0180 },
+ { 106, 0xffff, 0x01000014, 0x00, 0x00, 0x0000 },
+ { 106, 0xffff, 0x01000000, 0x0c, 0x08, 0x0181 },
+ { 107, 0xffff, 0x01000011, 0x00, 0x00, 0x0000 },
+ { 108, 0xffff, 0x01000015, 0x00, 0x00, 0x0000 },
+ { 109, 0xffff, 0x01000017, 0x00, 0x00, 0x0000 },
+ { 110, 0xffff, 0x01000006, 0x00, 0x00, 0x0000 },
+ { 111, 0xffff, 0x01000007, 0x00, 0x00, 0x0000 },
+ { 111, 0xffff, 0x01000000, 0x06, 0x08, 0x0200 },
+ { 111, 0xffff, 0x01000000, 0x0c, 0x08, 0x0200 },
+ { 119, 0xffff, 0x01000008, 0x00, 0x00, 0x0000 },
+};
+
+const QWSKeyboard::Composing QWSKbPrivate::s_keycompose_default[] = {
+ { 0x0060, 0x0041, 0x00c0 },
+ { 0x0060, 0x0061, 0x00e0 },
+ { 0x0027, 0x0041, 0x00c1 },
+ { 0x0027, 0x0061, 0x00e1 },
+ { 0x005e, 0x0041, 0x00c2 },
+ { 0x005e, 0x0061, 0x00e2 },
+ { 0x007e, 0x0041, 0x00c3 },
+ { 0x007e, 0x0061, 0x00e3 },
+ { 0x0022, 0x0041, 0x00c4 },
+ { 0x0022, 0x0061, 0x00e4 },
+ { 0x002d, 0x0061, 0x00aa },
+ { 0x002d, 0x0041, 0x00aa },
+ { 0x004f, 0x0041, 0x00c5 },
+ { 0x006f, 0x0061, 0x00e5 },
+ { 0x0030, 0x0041, 0x00c5 },
+ { 0x0030, 0x0061, 0x00e5 },
+ { 0x0041, 0x0041, 0x00c5 },
+ { 0x0061, 0x0061, 0x00e5 },
+ { 0x00b0, 0x0041, 0x00c5 },
+ { 0x00b0, 0x0061, 0x00e5 },
+ { 0x0041, 0x0045, 0x00c6 },
+ { 0x0061, 0x0065, 0x00e6 },
+ { 0x002c, 0x0043, 0x00c7 },
+ { 0x002c, 0x0063, 0x00e7 },
+ { 0x005e, 0x0043, 0x00c7 },
+ { 0x005e, 0x0063, 0x00e7 },
+ { 0x0060, 0x0045, 0x00c8 },
+ { 0x0060, 0x0065, 0x00e8 },
+ { 0x0027, 0x0045, 0x00c9 },
+ { 0x0027, 0x0065, 0x00e9 },
+ { 0x005e, 0x0045, 0x00ca },
+ { 0x005e, 0x0065, 0x00ea },
+ { 0x0022, 0x0045, 0x00cb },
+ { 0x0022, 0x0065, 0x00eb },
+ { 0x0060, 0x0049, 0x00cc },
+ { 0x0060, 0x0069, 0x00ec },
+ { 0x0027, 0x0049, 0x00cd },
+ { 0x0027, 0x0069, 0x00ed },
+ { 0x005e, 0x0049, 0x00ce },
+ { 0x005e, 0x0069, 0x00ee },
+ { 0x0022, 0x0049, 0x00cf },
+ { 0x0022, 0x0069, 0x00ef },
+ { 0x002d, 0x0044, 0x00d0 },
+ { 0x002d, 0x0064, 0x00f0 },
+ { 0x005e, 0x0044, 0x00d0 },
+ { 0x005e, 0x0064, 0x00f0 },
+ { 0x007e, 0x004e, 0x00d1 },
+ { 0x007e, 0x006e, 0x00f1 },
+ { 0x005e, 0x004e, 0x00d1 },
+ { 0x005e, 0x006e, 0x00f1 },
+ { 0x0060, 0x004f, 0x00d2 },
+ { 0x0060, 0x006f, 0x00f2 },
+ { 0x0027, 0x004f, 0x00d3 },
+ { 0x0027, 0x006f, 0x00f3 },
+ { 0x005e, 0x004f, 0x00d4 },
+ { 0x005e, 0x006f, 0x00f4 },
+ { 0x007e, 0x004f, 0x00d5 },
+ { 0x007e, 0x006f, 0x00f5 },
+ { 0x0022, 0x004f, 0x00d6 },
+ { 0x0022, 0x006f, 0x00f6 },
+ { 0x002f, 0x004f, 0x00d8 },
+ { 0x002f, 0x006f, 0x00f8 },
+ { 0x002d, 0x006f, 0x00ba },
+ { 0x002d, 0x004f, 0x00ba },
+ { 0x0060, 0x0055, 0x00d9 },
+ { 0x0060, 0x0075, 0x00f9 },
+ { 0x0027, 0x0055, 0x00da },
+ { 0x0027, 0x0075, 0x00fa },
+ { 0x005e, 0x0055, 0x00db },
+ { 0x005e, 0x0075, 0x00fb },
+ { 0x0022, 0x0055, 0x00dc },
+ { 0x0022, 0x0075, 0x00fc },
+ { 0x0027, 0x0059, 0x00dd },
+ { 0x0027, 0x0079, 0x00fd },
+ { 0x0054, 0x0048, 0x00de },
+ { 0x0074, 0x0068, 0x00fe },
+ { 0x0073, 0x0073, 0x00df },
+ { 0x0022, 0x0079, 0x00ff },
+ { 0x0073, 0x007a, 0x00df },
+ { 0x006e, 0x006e, 0x00f1 },
+ { 0x006e, 0x0068, 0x00f1 },
+ { 0x004e, 0x0059, 0x00d1 },
+ { 0x004e, 0x004e, 0x00d1 },
+ { 0x004e, 0x0048, 0x00d1 },
+ { 0x004e, 0x0079, 0x00d1 },
+ { 0x004e, 0x006e, 0x00d1 },
+ { 0x004e, 0x0068, 0x00d1 },
+ { 0x002d, 0x004c, 0x00a3 },
+ { 0x003c, 0x003c, 0x00ab },
+ { 0x003e, 0x003e, 0x00bb },
+ { 0x003f, 0x003f, 0x00bf },
+ { 0x005e, 0x003f, 0x00bf },
+ { 0x0021, 0x0021, 0x00a1 },
+ { 0x005e, 0x0021, 0x00a1 },
+ { 0x005e, 0x0031, 0x00b9 },
+ { 0x005e, 0x0032, 0x00b2 },
+ { 0x005e, 0x0033, 0x00b3 },
+ { 0x002b, 0x002d, 0x00b1 },
+ { 0x0063, 0x003d, 0x00a2 },
+ { 0x0063, 0x002f, 0x00a2 },
+ { 0x002f, 0x0063, 0x00a2 },
+ { 0x002d, 0x0063, 0x00a2 },
+ { 0x002d, 0x0043, 0x00a2 },
+ { 0x004c, 0x003d, 0x00a3 },
+ { 0x002d, 0x004c, 0x00a3 },
+ { 0x002d, 0x006c, 0x00a3 },
+ { 0x005e, 0x002a, 0x00d7 },
+ { 0x005e, 0x0078, 0x00d7 },
+ { 0x0078, 0x0078, 0x00d7 },
+ { 0x005e, 0x002e, 0x00b7 },
+ { 0x002e, 0x002e, 0x00b7 },
+ { 0x005e, 0x002f, 0x00f7 },
+ { 0x005e, 0x003a, 0x00f7 },
+ { 0x002d, 0x003a, 0x00f7 },
+ { 0x003a, 0x002d, 0x00f7 },
+ { 0x0059, 0x003d, 0x00a5 },
+ { 0x002d, 0x0059, 0x00a5 },
+ { 0x002d, 0x006c, 0x00a5 },
+ { 0x0028, 0x0063, 0x00a9 },
+ { 0x0022, 0x0063, 0x00a9 },
+ { 0x002d, 0x0061, 0x00aa },
+ { 0x002d, 0x0041, 0x00aa },
+ { 0x002d, 0x006f, 0x00ba },
+ { 0x002d, 0x004f, 0x00ba },
+ { 0x0028, 0x0072, 0x00ae },
+ { 0x0022, 0x0072, 0x00ae },
+ { 0x006d, 0x0075, 0x00b5 },
+ { 0x0031, 0x0034, 0x0152 },
+ { 0x0031, 0x0032, 0x0153 },
+ { 0x0033, 0x0034, 0x0178 },
+ { 0x0065, 0x003d, 0x20ac },
+ { 0x002d, 0x0065, 0x20ac },
+ { 0x002d, 0x0045, 0x20ac },
+ { 0x0076, 0x0053, 0x0160 },
+ { 0x005e, 0x0053, 0x0160 },
+ { 0x0076, 0x0073, 0x0161 },
+ { 0x005e, 0x0073, 0x0161 },
+ { 0x0076, 0x005a, 0x017d },
+ { 0x005e, 0x005a, 0x017d },
+ { 0x0076, 0x007a, 0x017e },
+ { 0x005e, 0x007a, 0x017e },
+ { 0x004f, 0x0045, 0x0152 },
+ { 0x004f, 0x0065, 0x0152 },
+ { 0x006f, 0x0065, 0x0153 },
+ { 0x0022, 0x0059, 0x0178 },
+ { 0x0069, 0x006a, 0x00ff },
+ { 0x0049, 0x004a, 0x0178 },
+};
+
+#endif
diff --git a/src/gui/embedded/qkbd_qws.cpp b/src/gui/embedded/qkbd_qws.cpp
index 8cf87db..dc92a01 100644
--- a/src/gui/embedded/qkbd_qws.cpp
+++ b/src/gui/embedded/qkbd_qws.cpp
@@ -40,56 +40,217 @@
****************************************************************************/
#include "qkbd_qws.h"
+#include "qkbd_qws_p.h"
#ifndef QT_NO_QWS_KEYBOARD
+#include <QFile>
+#include <QDataStream>
+#include <QStringList>
+
#include "qwindowsystem_qws.h"
#include "qscreen_qws.h"
#include "qtimer.h"
#include <stdlib.h>
+//#define QT_DEBUG_KEYMAP
+
+
QT_BEGIN_NAMESPACE
class QWSKbPrivate : public QObject
{
Q_OBJECT
public:
- QWSKbPrivate(QWSKeyboardHandler *h) {
- handler = h;
- arTimer = new QTimer(this);
- arTimer->setSingleShot(true);
- connect(arTimer, SIGNAL(timeout()), SLOT(autoRepeat()));
- repeatdelay = 400;
- repeatperiod = 80;
+ QWSKbPrivate(QWSKeyboardHandler *h, const QString &device)
+ : m_handler(h), m_modifiers(0), m_composing(0), m_dead_unicode(0xffff),
+ m_no_zap(false), m_do_compose(false),
+ m_keymap(0), m_keymap_size(0), m_keycompose(0), m_keycompose_size(0)
+ {
+ m_ar_timer = new QTimer(this);
+ m_ar_timer->setSingleShot(true);
+ connect(m_ar_timer, SIGNAL(timeout()), SLOT(autoRepeat()));
+ m_ar_delay = 400;
+ m_ar_period = 80;
+
+ memset(m_locks, 0, sizeof(m_locks));
+
+ QString keymap;
+ QStringList args = device.split(QLatin1Char(':'));
+ foreach (const QString &arg, args) {
+ if (arg.startsWith(QLatin1String("keymap=")))
+ keymap = arg.mid(7);
+ else if (arg == QLatin1String("disable-zap"))
+ m_no_zap = true;
+ else if (arg == QLatin1String("enable-compose"))
+ m_do_compose = true;
+ else if (arg.startsWith(QLatin1String("repeat-delay=")))
+ m_ar_delay = arg.mid(13).toInt();
+ else if (arg.startsWith(QLatin1String("repeat-rate=")))
+ m_ar_period = arg.mid(12).toInt();
+ }
+
+ if (keymap.isEmpty() || !loadKeymap(keymap))
+ unloadKeymap();
}
- void beginAutoRepeat(int uni, int code, Qt::KeyboardModifiers mod) {
- unicode = uni;
- keycode = code;
- modifier = mod;
- arTimer->start(repeatdelay);
+ ~QWSKbPrivate()
+ {
+ unloadKeymap();
}
- void endAutoRepeat() {
- arTimer->stop();
+
+ void beginAutoRepeat(int uni, int code, Qt::KeyboardModifiers mod)
+ {
+ m_ar_unicode = uni;
+ m_ar_keycode = code;
+ m_ar_modifier = mod;
+ m_ar_timer->start(m_ar_delay);
}
+ void endAutoRepeat()
+ {
+ m_ar_timer->stop();
+ }
+
+ static Qt::KeyboardModifiers toQtModifiers(quint8 mod)
+ {
+ Qt::KeyboardModifiers qtmod = Qt::NoModifier;
+
+ if (mod & (QWSKeyboard::ModShift | QWSKeyboard::ModShiftL | QWSKeyboard::ModShiftR))
+ qtmod |= Qt::ShiftModifier;
+ if (mod & (QWSKeyboard::ModControl | QWSKeyboard::ModCtrlL | QWSKeyboard::ModCtrlR))
+ qtmod |= Qt::ControlModifier;
+ if (mod & QWSKeyboard::ModAlt)
+ qtmod |= Qt::AltModifier;
+
+ return qtmod;
+ }
+
+ void unloadKeymap();
+ bool loadKeymap(const QString &file);
+
private slots:
- void autoRepeat() {
- handler->processKeyEvent(unicode, keycode, modifier, false, true);
- handler->processKeyEvent(unicode, keycode, modifier, true, true);
- arTimer->start(repeatperiod);
+ void autoRepeat()
+ {
+ m_handler->processKeyEvent(m_ar_unicode, m_ar_keycode, m_ar_modifier, false, true);
+ m_handler->processKeyEvent(m_ar_unicode, m_ar_keycode, m_ar_modifier, true, true);
+ m_ar_timer->start(m_ar_period);
}
private:
- QWSKeyboardHandler *handler;
- int unicode;
- int keycode;
- Qt::KeyboardModifiers modifier;
- int repeatdelay;
- int repeatperiod;
- QTimer *arTimer;
+ QWSKeyboardHandler *m_handler;
+
+ // auto repeat simulation
+ int m_ar_unicode;
+ int m_ar_keycode;
+ Qt::KeyboardModifiers m_ar_modifier;
+ int m_ar_delay;
+ int m_ar_period;
+ QTimer *m_ar_timer;
+
+ // keymap handling
+ quint8 m_modifiers;
+ quint8 m_locks[3];
+ int m_composing;
+ quint16 m_dead_unicode;
+
+ bool m_no_zap;
+ bool m_do_compose;
+
+ const QWSKeyboard::Mapping *m_keymap;
+ int m_keymap_size;
+ const QWSKeyboard::Composing *m_keycompose;
+ int m_keycompose_size;
+
+ static const QWSKeyboard::Mapping s_keymap_default[];
+ static const QWSKeyboard::Composing s_keycompose_default[];
+
+ friend class QWSKeyboardHandler;
};
+// simple builtin US keymap
+#include "qkbd_defaultmap_qws_p.h"
+
+// the unloadKeymap() function needs to be AFTER the defaultmap include,
+// since the sizeof(s_keymap_default) wouldn't work otherwise.
+
+void QWSKbPrivate::unloadKeymap()
+{
+ if (m_keymap && m_keymap != s_keymap_default)
+ delete [] m_keymap;
+ if (m_keycompose && m_keycompose != s_keycompose_default)
+ delete [] m_keycompose;
+
+ m_keymap = s_keymap_default;
+ m_keymap_size = sizeof(s_keymap_default) / sizeof(s_keymap_default[0]);
+ m_keycompose = s_keycompose_default;
+ m_keycompose_size = sizeof(s_keycompose_default) / sizeof(s_keycompose_default[0]);
+
+ // reset state, so we could switch keymaps at runtime
+ m_modifiers = 0;
+ memset(m_locks, 0, sizeof(m_locks));
+ m_composing = 0;
+ m_dead_unicode = 0xffff;
+}
+
+bool QWSKbPrivate::loadKeymap(const QString &file)
+{
+ QFile f(file);
+
+ if (!f.open(QIODevice::ReadOnly)) {
+ qWarning("Could not open keymap file '%s'", qPrintable(file));
+ return false;
+ }
+
+ // .qmap files have a very simple structure:
+ // quint32 magic (QWSKeyboard::FileMagic)
+ // quint32 version (1)
+ // quint32 keymap_size (# of struct QWSKeyboard::Mappings)
+ // quint32 keycompose_size (# of struct QWSKeyboard::Composings)
+ // all QWSKeyboard::Mappings via QDataStream::operator(<<|>>)
+ // all QWSKeyboard::Composings via QDataStream::operator(<<|>>)
+
+ quint32 qmap_magic, qmap_version, qmap_keymap_size, qmap_keycompose_size;
+
+ QDataStream ds(&f);
+
+ ds >> qmap_magic >> qmap_version >> qmap_keymap_size >> qmap_keycompose_size;
+
+ if (ds.status() != QDataStream::Ok || qmap_magic != QWSKeyboard::FileMagic || qmap_version != 1 || qmap_keymap_size == 0) {
+ qWarning("'%s' is ot a valid.qmap keymap file.", qPrintable(file));
+ return false;
+ }
+
+ QWSKeyboard::Mapping *qmap_keymap = new QWSKeyboard::Mapping[qmap_keymap_size];
+ QWSKeyboard::Composing *qmap_keycompose = qmap_keycompose_size ? new QWSKeyboard::Composing[qmap_keycompose_size] : 0;
+
+ for (quint32 i = 0; i < qmap_keymap_size; ++i)
+ ds >> qmap_keymap[i];
+ for (quint32 i = 0; i < qmap_keycompose_size; ++i)
+ ds >> qmap_keycompose[i];
+
+ if (ds.status() != QDataStream::Ok) {
+ delete [] qmap_keymap;
+ delete [] qmap_keycompose;
+
+ qWarning("Keymap file '%s' can not be loaded.", qPrintable(file));
+ return false;
+ }
+
+ // unload currently active and clear state
+ unloadKeymap();
+
+ m_keymap = qmap_keymap;
+ m_keymap_size = qmap_keymap_size;
+ m_keycompose = qmap_keycompose;
+ m_keycompose_size = qmap_keycompose_size;
+
+ m_do_compose = true;
+
+ return true;
+}
+
+
/*!
\class QWSKeyboardHandler
\ingroup qws
@@ -132,18 +293,29 @@ private:
/*!
- Constructs a keyboard driver.
+ Constructs a keyboard driver. The \a device argument is passed by the
+ QWS_KEYBOARD environment variable.
Call the QWSServer::setKeyboardHandler() function to make the
newly created keyboard driver, the primary driver. Note that the
primary driver is controlled by the system, i.e., the system will
delete it upon exit.
*/
+QWSKeyboardHandler::QWSKeyboardHandler(const QString &device)
+{
+ d = new QWSKbPrivate(this, device);
+}
+
+/*!
+ \overload
+*/
QWSKeyboardHandler::QWSKeyboardHandler()
{
- d = new QWSKbPrivate(this);
+ d = new QWSKbPrivate(this, QString());
}
+
+
/*!
Destroys this keyboard driver.
@@ -172,7 +344,10 @@ QWSKeyboardHandler::~QWSKeyboardHandler()
event is caused by an auto-repeat mechanism and not an actual key
press.
- \sa beginAutoRepeat(), endAutoRepeat(), transformDirKey()
+ Note that this function does not handle key mapping. Please use
+ processKeycode() if you need that functionality.
+
+ \sa processKeycode(), beginAutoRepeat(), endAutoRepeat(), transformDirKey()
*/
void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
bool isPress, bool autoRepeat)
@@ -241,6 +416,256 @@ void QWSKeyboardHandler::endAutoRepeat()
d->endAutoRepeat();
}
+/*!
+ \enum QWSKeyboardHandler::KeycodeAction
+
+ This enum describes the various special actions that actual
+ QWSKeyboardHandler implementations have to take care of.
+
+ \value None No further action required.
+
+ \value CapsLockOn Set the state of the Caps lock LED to on.
+ \value CapsLockOff Set the state of the Caps lock LED to off.
+ \value NumLockOn Set the state of the Num lock LED to on.
+ \value NumLockOff Set the state of the Num lock LED to off.
+ \value ScrollLockOn Set the state of the Scroll lock LED to on.
+ \value ScrollLockOff Set the state of the Scroll lock LED to off.
+
+ \value PreviousConsole Switch to the previous virtual console (by
+ default Ctrl+Alt+Left on Linux).
+ \value NextConsole Switch to the next virtual console (by default
+ Ctrl+Alt+Right on Linux).
+ \value SwitchConsoleFirst Switch to the first virtual console (0).
+ \value SwitchConsoleLast Switch to the last virtual console (255).
+ \value SwitchConsoleMask If the KeyAction value is between SwitchConsoleFirst
+ and SwitchConsoleLast, you can use this mask to get
+ the specific virtual console number to switch to.
+
+ \value Reboot Reboot the machine - this is ignored in both the TTY and
+ LinuxInput handlers though (by default Ctrl+Alt+Del on Linux).
+
+ \sa processKeycode()
+*/
+
+/*!
+ \fn QWSKeyboardHandler::KeycodeAction QWSKeyboardHandler::processKeycode(quint16 keycode, bool isPress, bool autoRepeat)
+
+ Maps \a keycode according to a keymap and sends that key event to the
+ \l{Qt for Embedded Linux} server application.
+
+ Please see the QWS_KEYBOARD documentation for a description on how to
+ create and use keymap files.
+
+ The key event is identified by its \a keycode value and the \a isPress
+ and \a autoRepeat parameters.
+
+ The \a keycode parameter is \bold NOT the Qt keycode value as defined by
+ the Qt::Key enum. This functions expects a standard Linux 16 bit kernel
+ keycode as it is used in the Linux Input Event sub-system. This
+ \a keycode is transformed to a Qt::Key code by using either a
+ compiled-in US keyboard layout or by dynamically loading a keymap at
+ startup which can be specified via the QWS_KEYBOARD environment
+ variable.
+
+ The \a isPress parameter is true if the event is a key press event and
+ \a autoRepeat is true if the event is caused by an auto-repeat mechanism
+ and not an actual key press.
+
+ The return value indicates if the actual QWSKeyboardHandler
+ implementation needs to take care of a special action, like console
+ switching or LED handling.
+
+ Standard Linux console keymaps can be found at the
+ \l {http://lct.sourceforege.net}{LCT project}
+
+ If standard Linux console keymaps are used, \a keycode must be one of the
+ standardized values defined in \c /usr/include/linux/input.h
+
+ \sa processKeyEvent(), KeycodeAction
+*/
+
+QWSKeyboardHandler::KeycodeAction QWSKeyboardHandler::processKeycode(quint16 keycode, bool pressed, bool autorepeat)
+{
+ KeycodeAction result = None;
+ bool first_press = pressed && !autorepeat;
+
+ const QWSKeyboard::Mapping *map_plain = 0;
+ const QWSKeyboard::Mapping *map_withmod = 0;
+
+ // get a specific and plain mapping for the keycode and the current modifiers
+ for (int i = 0; i < d->m_keymap_size && !(map_plain && map_withmod); ++i) {
+ const QWSKeyboard::Mapping *m = d->m_keymap + i;
+ if (m->keycode == keycode) {
+ if (m->modifiers == 0)
+ map_plain = m;
+
+ quint8 testmods = d->m_modifiers;
+ if (d->m_locks[0] /*CapsLock*/ && (m->flags & QWSKeyboard::IsLetter))
+ testmods ^= QWSKeyboard::ModShift;
+ if (m->modifiers == testmods)
+ map_withmod = m;
+ }
+ }
+
+#ifdef QT_DEBUG_KEYMAP
+ qWarning("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", \
+ keycode, d->m_modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, \
+ map_plain ? map_plain - d->m_keymap : -1, \
+ map_withmod ? map_withmod - d->m_keymap : -1, \
+ d->m_keymap_size);
+#endif
+
+ const QWSKeyboard::Mapping *it = map_withmod ? map_withmod : map_plain;
+
+ if (!it) {
+#ifdef QT_DEBUG_KEYMAP
+ // we couldn't even find a plain mapping
+ qWarning("Could not find a suitable mapping for keycode: %3d, modifiers: %02x", keycode, d->m_modifiers);
+#endif
+ return result;
+ }
+
+ bool skip = false;
+ quint16 unicode = it->unicode;
+ quint32 qtcode = it->qtcode;
+
+ if ((it->flags & QWSKeyboard::IsModifier) && it->special) {
+ // this is a modifier, i.e. Shift, Alt, ...
+ if (pressed)
+ d->m_modifiers |= quint8(it->special);
+ else
+ d->m_modifiers &= ~quint8(it->special);
+ } else if (qtcode >= Qt::Key_CapsLock && qtcode <= Qt::Key_ScrollLock) {
+ // (Caps|Num|Scroll)Lock
+ if (first_press) {
+ quint8 &lock = d->m_locks[qtcode - Qt::Key_CapsLock];
+ lock ^= 1;
+
+ switch (qtcode) {
+ case Qt::Key_CapsLock : result = lock ? CapsLockOn : CapsLockOff; break;
+ case Qt::Key_NumLock : result = lock ? NumLockOn : NumLockOff; break;
+ case Qt::Key_ScrollLock: result = lock ? ScrollLockOn : ScrollLockOff; break;
+ default : break;
+ }
+ }
+ } else if ((it->flags & QWSKeyboard::IsSystem) && it->special && first_press) {
+ switch (it->special) {
+ case QWSKeyboard::SystemReboot:
+ result = Reboot;
+ break;
+
+ case QWSKeyboard::SystemZap:
+ if (!d->m_no_zap)
+ qApp->quit();
+ break;
+
+ case QWSKeyboard::SystemConsolePrevious:
+ result = PreviousConsole;
+ break;
+
+ case QWSKeyboard::SystemConsoleNext:
+ result = NextConsole;
+ break;
+
+ default:
+ if (it->special >= QWSKeyboard::SystemConsoleFirst &&
+ it->special <= QWSKeyboard::SystemConsoleLast) {
+ result = KeycodeAction(SwitchConsoleFirst + ((it->special & QWSKeyboard::SystemConsoleMask) & SwitchConsoleMask));
+ }
+ break;
+ }
+
+ skip = true; // no need to tell QWS about it
+ } else if ((qtcode == Qt::Key_Multi_key) && d->m_do_compose) {
+ // the Compose key was pressed
+ if (first_press)
+ d->m_composing = 2;
+ skip = true;
+ } else if ((it->flags & QWSKeyboard::IsDead) && d->m_do_compose) {
+ // a Dead key was pressed
+ if (first_press && d->m_composing == 1 && d->m_dead_unicode == unicode) { // twice
+ d->m_composing = 0;
+ qtcode = Qt::Key_unknown; // otherwise it would be Qt::Key_Dead...
+ } else if (first_press && unicode != 0xffff) {
+ d->m_dead_unicode = unicode;
+ d->m_composing = 1;
+ skip = true;
+ } else {
+ skip = true;
+ }
+ }
+
+ if (!skip) {
+ // a normal key was pressed
+ const int modmask = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier;
+
+ // we couldn't find a specific mapping for the current modifiers,
+ // or that mapping didn't have special modifiers:
+ // so just report the plain mapping with additional modifiers.
+ if ((it == map_plain && it != map_withmod) ||
+ (map_withmod && !(map_withmod->qtcode & modmask))) {
+ qtcode |= QWSKbPrivate::toQtModifiers(d->m_modifiers);
+ }
+
+ if (d->m_composing == 2 && first_press && !(it->flags & QWSKeyboard::IsModifier)) {
+ // the last key press was the Compose key
+ if (unicode != 0xffff) {
+ int idx = 0;
+ // check if this code is in the compose table at all
+ for ( ; idx < d->m_keycompose_size; ++idx) {
+ if (d->m_keycompose[idx].first == unicode)
+ break;
+ }
+ if (idx < d->m_keycompose_size) {
+ // found it -> simulate a Dead key press
+ d->m_dead_unicode = unicode;
+ unicode = 0xffff;
+ d->m_composing = 1;
+ skip = true;
+ } else {
+ d->m_composing = 0;
+ }
+ } else {
+ d->m_composing = 0;
+ }
+ } else if (d->m_composing == 1 && first_press && !(it->flags & QWSKeyboard::IsModifier)) {
+ // the last key press was a Dead key
+ bool valid = false;
+ if (unicode != 0xffff) {
+ int idx = 0;
+ // check if this code is in the compose table at all
+ for ( ; idx < d->m_keycompose_size; ++idx) {
+ if (d->m_keycompose[idx].first == d->m_dead_unicode && d->m_keycompose[idx].second == unicode)
+ break;
+ }
+ if (idx < d->m_keycompose_size) {
+ quint16 composed = d->m_keycompose[idx].result;
+ if (composed != 0xffff) {
+ unicode = composed;
+ qtcode = Qt::Key_unknown;
+ valid = true;
+ }
+ }
+ }
+ if (!valid) {
+ unicode = d->m_dead_unicode;
+ qtcode = Qt::Key_unknown;
+ }
+ d->m_composing = 0;
+ }
+
+ if (!skip) {
+#ifdef QT_DEBUG_KEYMAP
+ qWarning("Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode & ~modmask, (qtcode & modmask));
+#endif
+
+ // send the result to the QWS server
+ processKeyEvent(unicode, qtcode & ~modmask, Qt::KeyboardModifiers(qtcode & modmask), pressed, autorepeat);
+ }
+ }
+ return result;
+}
+
QT_END_NAMESPACE
#include "qkbd_qws.moc"
diff --git a/src/gui/embedded/qkbd_qws.h b/src/gui/embedded/qkbd_qws.h
index 8809f0a..171adc0 100644
--- a/src/gui/embedded/qkbd_qws.h
+++ b/src/gui/embedded/qkbd_qws.h
@@ -58,11 +58,33 @@ class Q_GUI_EXPORT QWSKeyboardHandler
{
public:
QWSKeyboardHandler();
+ QWSKeyboardHandler(const QString &device);
virtual ~QWSKeyboardHandler();
virtual void processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
bool isPress, bool autoRepeat);
+ enum KeycodeAction {
+ None = 0,
+
+ CapsLockOff = 0x01000000,
+ CapsLockOn = 0x01000001,
+ NumLockOff = 0x02000000,
+ NumLockOn = 0x02000001,
+ ScrollLockOff = 0x03000000,
+ ScrollLockOn = 0x03000001,
+
+ Reboot = 0x04000000,
+
+ PreviousConsole = 0x05000000,
+ NextConsole = 0x05000001,
+ SwitchConsoleFirst = 0x06000000,
+ SwitchConsoleLast = 0x0600007f,
+ SwitchConsoleMask = 0x0000007f,
+ };
+
+ KeycodeAction processKeycode(quint16 keycode, bool pressed, bool autorepeat);
+
protected:
int transformDirKey(int key);
void beginAutoRepeat(int uni, int code, Qt::KeyboardModifiers mod);
diff --git a/src/gui/embedded/qkbd_qws_p.h b/src/gui/embedded/qkbd_qws_p.h
new file mode 100644
index 0000000..3224da2
--- /dev/null
+++ b/src/gui/embedded/qkbd_qws_p.h
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWSKEYBOARD_P_H
+#define QWSKEYBOARD_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QDataStream>
+
+namespace QWSKeyboard {
+ const quint32 FileMagic = 0x514d4150; // 'QMAP'
+
+ struct Mapping {
+ quint16 keycode;
+ quint16 unicode;
+ quint32 qtcode;
+ quint8 modifiers;
+ quint8 flags;
+ quint16 special;
+
+ };
+
+ enum Flags {
+ IsDead = 0x01,
+ IsLetter = 0x02,
+ IsModifier = 0x04,
+ IsSystem = 0x08,
+ };
+
+ enum System {
+ SystemConsoleFirst = 0x0100,
+ SystemConsoleMask = 0x007f,
+ SystemConsoleLast = 0x017f,
+ SystemConsolePrevious = 0x0180,
+ SystemConsoleNext = 0x0181,
+ SystemReboot = 0x0200,
+ SystemZap = 0x0300,
+ };
+
+ struct Composing {
+ quint16 first;
+ quint16 second;
+ quint16 result;
+ };
+
+ enum Modifiers {
+ ModPlain = 0x00,
+ ModShift = 0x01,
+ ModAltGr = 0x02,
+ ModControl = 0x04,
+ ModAlt = 0x08,
+ ModShiftL = 0x10,
+ ModShiftR = 0x20,
+ ModCtrlL = 0x40,
+ ModCtrlR = 0x80,
+ // ModCapsShift = 0x100, // not supported!
+ };
+};
+
+inline QDataStream &operator>>(QDataStream &ds, QWSKeyboard::Mapping &m)
+{
+ return ds >> m.keycode >> m.unicode >> m.qtcode >> m.modifiers >> m.flags >> m.special;
+}
+
+inline QDataStream &operator<<(QDataStream &ds, const QWSKeyboard::Mapping &m)
+{
+ return ds << m.keycode << m.unicode << m.qtcode << m.modifiers << m.flags << m.special;
+}
+
+inline QDataStream &operator>>(QDataStream &ds, QWSKeyboard::Composing &c)
+{
+ return ds >> c.first >> c.second >> c.result;
+}
+
+inline QDataStream &operator<<(QDataStream &ds, const QWSKeyboard::Composing &c)
+{
+ return ds << c.first << c.second << c.result;
+}
+
+
+#endif // QWSKEYBOARD_H
diff --git a/src/gui/embedded/qkbddriverfactory_qws.cpp b/src/gui/embedded/qkbddriverfactory_qws.cpp
index 1ade652..dbfac5c 100644
--- a/src/gui/embedded/qkbddriverfactory_qws.cpp
+++ b/src/gui/embedded/qkbddriverfactory_qws.cpp
@@ -45,7 +45,7 @@
#include "qapplication.h"
#include "qkbdtty_qws.h"
-#include "qkbdusb_qws.h"
+#include "qkbdlinuxinput_qws.h"
#include "qkbdum_qws.h"
#include "qkbdsl5000_qws.h"
#include "qkbdvfb_qws.h"
@@ -121,9 +121,11 @@ QWSKeyboardHandler *QKbdDriverFactory::create(const QString& key, const QString&
if (driver == QLatin1String("tty") || driver.isEmpty())
return new QWSTtyKeyboardHandler(device);
# endif
-# ifndef QT_NO_QWS_KBD_USB
- if (driver == QLatin1String("usb"))
- return new QWSUsbKeyboardHandler(device);
+# ifndef QT_NO_QWS_KBD_LINUXINPUT
+ if (driver == QLatin1String("linuxinput") || \
+ driver == QLatin1String("usb") || \
+ driver == QLatin1String("linuxis"))
+ return new QWSLinuxInputKeyboardHandler(device);
# endif
# ifndef QT_NO_QWS_KBD_UM
if (driver == QLatin1String("um") || driver == QLatin1String("qvfbkeyboard"))
@@ -168,8 +170,8 @@ QStringList QKbdDriverFactory::keys()
#ifndef QT_NO_QWS_KBD_TTY
list << QLatin1String("TTY");
#endif
-#ifndef QT_NO_QWS_KBD_USB
- list << QLatin1String("USB");
+#ifndef QT_NO_QWS_KBD_LINUXINPUT
+ list << QLatin1String("LinuxInput");
#endif
#ifndef QT_NO_QWS_KBD_UM
list << QLatin1String("UM");
diff --git a/src/gui/embedded/qkbdlinuxinput_qws.cpp b/src/gui/embedded/qkbdlinuxinput_qws.cpp
new file mode 100644
index 0000000..1ef2696
--- /dev/null
+++ b/src/gui/embedded/qkbdlinuxinput_qws.cpp
@@ -0,0 +1,241 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qkbdlinuxinput_qws.h"
+
+#ifndef QT_NO_QWS_KEYBOARD
+
+#include <QSocketNotifier>
+#include <QStringList>
+
+#include <qplatformdefs.h>
+
+#include <errno.h>
+#include <termios.h>
+
+#include <linux/kd.h>
+#include <linux/input.h>
+
+QT_BEGIN_NAMESPACE
+
+
+class QWSLinuxInputKbPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *, const QString &);
+ ~QWSLinuxInputKbPrivate();
+
+private:
+ void switchLed(int, bool);
+
+private Q_SLOTS:
+ void readKeycode();
+
+private:
+ QWSLinuxInputKeyboardHandler *m_handler;
+ int m_fd;
+ int m_tty_fd;
+ struct termios m_tty_attr;
+};
+
+QWSLinuxInputKeyboardHandler::QWSLinuxInputKeyboardHandler(const QString &device)
+ : QWSKeyboardHandler(device)
+{
+ d = new QWSLinuxInputKbPrivate(this, device);
+}
+
+QWSLinuxInputKeyboardHandler::~QWSLinuxInputKeyboardHandler()
+{
+ delete d;
+}
+
+bool QWSLinuxInputKeyboardHandler::filterInputEvent(quint16 &, qint32 &)
+{
+ return false;
+}
+
+QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h, const QString &device)
+ : m_handler(h), m_fd(-1), m_tty_fd(-1)
+
+{
+ setObjectName(QLatin1String("LinuxInputSubsystem Keyboard Handler"));
+
+ QString dev = QLatin1String("/dev/input/event1");
+ int repeat_delay = -1;
+ int repeat_rate = -1;
+
+ QStringList args = device.split(QLatin1Char(':'));
+ foreach (const QString &arg, args) {
+ if (arg.startsWith(QLatin1String("repeat-delay=")))
+ repeat_delay = arg.mid(13).toInt();
+ else if (arg.startsWith(QLatin1String("repeat-rate=")))
+ repeat_rate = arg.mid(12).toInt();
+ else if (arg.startsWith(QLatin1String("/dev/")))
+ dev = arg;
+ }
+
+ m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDWR, 0);
+ if (m_fd >= 0) {
+ if (repeat_delay > 0 && repeat_rate > 0) {
+ int kbdrep[2] = { repeat_delay, repeat_rate };
+ ::ioctl(m_fd, EVIOCSREP, kbdrep);
+ }
+
+ QSocketNotifier *notifier;
+ notifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
+ connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode()));
+
+ // play nice in case we are started from a shell (e.g. for debugging)
+ m_tty_fd = isatty(0) ? 0 : -1;
+
+ if (m_tty_fd >= 0) {
+ // save tty config for restore.
+ tcgetattr(m_tty_fd, &m_tty_attr);
+
+ struct ::termios termdata;
+ tcgetattr(m_tty_fd, &termdata);
+
+ // setting this tranlation mode is also needed in INPUT mode to prevent
+ // the shell from also interpreting codes, if the process has a tty
+ // attached: e.g. Ctrl+C wouldn't copy, but kill the application.
+ ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
+
+ // set the tty layer to pass-through
+ termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ termdata.c_oflag = 0;
+ termdata.c_cflag = CREAD | CS8;
+ termdata.c_lflag = 0;
+ termdata.c_cc[VTIME]=0;
+ termdata.c_cc[VMIN]=1;
+ cfsetispeed(&termdata, 9600);
+ cfsetospeed(&termdata, 9600);
+ tcsetattr(m_tty_fd, TCSANOW, &termdata);
+ }
+ } else {
+ qWarning("Cannot open input device '%s': %s", qPrintable(dev), strerror(errno));
+ return;
+ }
+}
+
+QWSLinuxInputKbPrivate::~QWSLinuxInputKbPrivate()
+{
+ if (m_tty_fd >= 0) {
+ ::ioctl(m_tty_fd, KDSKBMODE, K_XLATE);
+ tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr);
+ }
+ if (m_fd >= 0)
+ QT_CLOSE(m_fd);
+}
+
+void QWSLinuxInputKbPrivate::switchLed(int led, bool state)
+{
+ struct ::input_event led_ie;
+ ::gettimeofday(&led_ie.time, 0);
+ led_ie.type = EV_LED;
+ led_ie.code = led;
+ led_ie.value = state;
+
+ QT_WRITE(m_fd, &led_ie, sizeof(led_ie));
+}
+
+void QWSLinuxInputKbPrivate::readKeycode()
+{
+ struct ::input_event buffer[32];
+ int n = 0;
+
+ forever {
+ n = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
+
+ if (n == 0) {
+ qWarning("Got EOF from the input device.");
+ return;
+ } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
+ qWarning("Could not read from input device: %s", strerror(errno));
+ return;
+ } else if (n % sizeof(buffer[0]) == 0) {
+ break;
+ }
+ }
+
+ n /= sizeof(buffer[0]);
+
+ for (int i = 0; i < n; ++i) {
+ if (buffer[i].type != EV_KEY)
+ continue;
+
+ quint16 code = buffer[i].code;
+ qint32 value = buffer[i].value;
+
+ if (m_handler->filterInputEvent(code, value))
+ continue;
+
+ QWSKeyboardHandler::KeycodeAction ka;
+ ka = m_handler->processKeycode(code, value != 0, value == 2);
+
+ switch (ka) {
+ case QWSKeyboardHandler::CapsLockOn:
+ case QWSKeyboardHandler::CapsLockOff:
+ switchLed(LED_CAPSL, ka == QWSKeyboardHandler::CapsLockOn);
+ break;
+
+ case QWSKeyboardHandler::NumLockOn:
+ case QWSKeyboardHandler::NumLockOff:
+ switchLed(LED_NUML, ka == QWSKeyboardHandler::NumLockOn);
+ break;
+
+ case QWSKeyboardHandler::ScrollLockOn:
+ case QWSKeyboardHandler::ScrollLockOff:
+ switchLed(LED_SCROLLL, ka == QWSKeyboardHandler::ScrollLockOn);
+ break;
+
+ default:
+ // ignore console switching and reboot
+ break;
+ }
+ }
+}
+
+QT_END_NAMESPACE
+
+#include "qkbdlinuxinput_qws.moc"
+
+#endif // QT_NO_QWS_KEYBOARD
diff --git a/src/gui/embedded/qkbdusb_qws.h b/src/gui/embedded/qkbdlinuxinput_qws.h
index 81d0103..5fa8214 100644
--- a/src/gui/embedded/qkbdusb_qws.h
+++ b/src/gui/embedded/qkbdlinuxinput_qws.h
@@ -39,10 +39,10 @@
**
****************************************************************************/
-#ifndef QKBDUSB_QWS_H
-#define QKBDUSB_QWS_H
+#ifndef QKBDLINUXINPUT_QWS_H
+#define QKBDLINUXINPUT_QWS_H
-#include <QtGui/qkbdpc101_qws.h>
+#include <QtGui/qkbd_qws.h>
QT_BEGIN_HEADER
@@ -52,21 +52,23 @@ QT_MODULE(Gui)
#ifndef QT_NO_QWS_KEYBOARD
-#ifndef QT_NO_QWS_KBD_USB
+#ifndef QT_NO_QWS_KBD_LINUXINPUT
-class QWSUsbKbPrivate;
+class QWSLinuxInputKbPrivate;
-class QWSUsbKeyboardHandler : public QWSPC101KeyboardHandler
+class QWSLinuxInputKeyboardHandler : public QWSKeyboardHandler
{
public:
- QWSUsbKeyboardHandler(const QString&);
- virtual ~QWSUsbKeyboardHandler();
+ QWSLinuxInputKeyboardHandler(const QString&);
+ virtual ~QWSLinuxInputKeyboardHandler();
+
+ virtual bool filterInputEvent(quint16 &input_code, qint32 &input_value);
private:
- QWSUsbKbPrivate *d;
+ QWSLinuxInputKbPrivate *d;
};
-#endif // QT_NO_QWS_KBD_USB
+#endif // QT_NO_QWS_KBD_LINUXINPUT
#endif // QT_NO_QWS_KEYBOARD
@@ -74,4 +76,4 @@ QT_END_NAMESPACE
QT_END_HEADER
-#endif // QKBDUSB_QWS_H
+#endif // QKBDLINUXINPUT_QWS_H
diff --git a/src/gui/embedded/qkbdpc101_qws.cpp b/src/gui/embedded/qkbdpc101_qws.cpp
deleted file mode 100644
index 3173645..0000000
--- a/src/gui/embedded/qkbdpc101_qws.cpp
+++ /dev/null
@@ -1,485 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qkbdpc101_qws.h"
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-#include "qscreen_qws.h"
-#include "qwindowsystem_qws.h"
-#include "qnamespace.h"
-#include "qapplication.h"
-
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#ifdef Q_OS_LINUX
-#include <sys/kd.h>
-#include <sys/vt.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-static const QWSKeyMap pc101KeyM[] = {
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Escape, 27 , 27 , 0xffff },
- { Qt::Key_1, '1' , '!' , 0xffff },
- { Qt::Key_2, '2' , '@' , 0xffff },
- { Qt::Key_3, '3' , '#' , 0xffff },
- { Qt::Key_4, '4' , '$' , 0xffff },
- { Qt::Key_5, '5' , '%' , 0xffff },
- { Qt::Key_6, '6' , '^' , 0xffff },
- { Qt::Key_7, '7' , '&' , 0xffff },
- { Qt::Key_8, '8' , '*' , 0xffff },
- { Qt::Key_9, '9' , '(' , 0xffff }, // 10
- { Qt::Key_0, '0' , ')' , 0xffff },
- { Qt::Key_Minus, '-' , '_' , 0xffff },
- { Qt::Key_Equal, '=' , '+' , 0xffff },
- { Qt::Key_Backspace, 8 , 8 , 0xffff },
- { Qt::Key_Tab, 9 , 9 , 0xffff },
- { Qt::Key_Q, 'q' , 'Q' , 'Q'-64 },
- { Qt::Key_W, 'w' , 'W' , 'W'-64 },
- { Qt::Key_E, 'e' , 'E' , 'E'-64 },
- { Qt::Key_R, 'r' , 'R' , 'R'-64 },
- { Qt::Key_T, 't' , 'T' , 'T'-64 }, // 20
- { Qt::Key_Y, 'y' , 'Y' , 'Y'-64 },
- { Qt::Key_U, 'u' , 'U' , 'U'-64 },
- { Qt::Key_I, 'i' , 'I' , 'I'-64 },
- { Qt::Key_O, 'o' , 'O' , 'O'-64 },
- { Qt::Key_P, 'p' , 'P' , 'P'-64 },
- { Qt::Key_BraceLeft, '[' , '{' , 0xffff },
- { Qt::Key_BraceRight, ']' , '}' , 0xffff },
- { Qt::Key_Return, 13 , 13 , 0xffff },
- { Qt::Key_Control, 0xffff , 0xffff , 0xffff },
- { Qt::Key_A, 'a' , 'A' , 'A'-64 }, // 30
- { Qt::Key_S, 's' , 'S' , 'S'-64 },
- { Qt::Key_D, 'd' , 'D' , 'D'-64 },
- { Qt::Key_F, 'f' , 'F' , 'F'-64 },
- { Qt::Key_G, 'g' , 'G' , 'G'-64 },
- { Qt::Key_H, 'h' , 'H' , 'H'-64 },
- { Qt::Key_J, 'j' , 'J' , 'J'-64 },
- { Qt::Key_K, 'k' , 'K' , 'K'-64 },
- { Qt::Key_L, 'l' , 'L' , 'L'-64 },
- { Qt::Key_Semicolon, ';' , ':' , 0xffff },
- { Qt::Key_Apostrophe, '\'' , '"' , 0xffff }, // 40
- { Qt::Key_QuoteLeft, '`' , '~' , 0xffff },
- { Qt::Key_Shift, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Backslash, '\\' , '|' , 0xffff },
- { Qt::Key_Z, 'z' , 'Z' , 'Z'-64 },
- { Qt::Key_X, 'x' , 'X' , 'X'-64 },
- { Qt::Key_C, 'c' , 'C' , 'C'-64 },
- { Qt::Key_V, 'v' , 'V' , 'V'-64 },
- { Qt::Key_B, 'b' , 'B' , 'B'-64 },
- { Qt::Key_N, 'n' , 'N' , 'N'-64 },
- { Qt::Key_M, 'm' , 'M' , 'M'-64 }, // 50
- { Qt::Key_Comma, ',' , '<' , 0xffff },
- { Qt::Key_Period, '.' , '>' , 0xffff },
- { Qt::Key_Slash, '/' , '?' , 0xffff },
- { Qt::Key_Shift, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Asterisk, '*' , '*' , 0xffff },
- { Qt::Key_Alt, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Space, ' ' , ' ' , 0xffff },
- { Qt::Key_CapsLock, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F1, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F2, 0xffff , 0xffff , 0xffff }, // 60
- { Qt::Key_F3, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F4, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F5, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F6, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F7, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F8, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F9, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F10, 0xffff , 0xffff , 0xffff },
- { Qt::Key_NumLock, 0xffff , 0xffff , 0xffff },
- { Qt::Key_ScrollLock, 0xffff , 0xffff , 0xffff }, // 70
- { Qt::Key_7, '7' , '7' , 0xffff },
- { Qt::Key_8, '8' , '8' , 0xffff },
- { Qt::Key_9, '9' , '9' , 0xffff },
- { Qt::Key_Minus, '-' , '-' , 0xffff },
- { Qt::Key_4, '4' , '4' , 0xffff },
- { Qt::Key_5, '5' , '5' , 0xffff },
- { Qt::Key_6, '6' , '6' , 0xffff },
- { Qt::Key_Plus, '+' , '+' , 0xffff },
- { Qt::Key_1, '1' , '1' , 0xffff },
- { Qt::Key_2, '2' , '2' , 0xffff }, // 80
- { Qt::Key_3, '3' , '3' , 0xffff },
- { Qt::Key_0, '0' , '0' , 0xffff },
- { Qt::Key_Period, '.' , '.' , 0xffff },
- { Qt::Key_SysReq, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Less, '<' , '>' , 0xffff },
- { Qt::Key_F11, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F12, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 90
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Enter, 13 , 13 , 0xffff },
- { Qt::Key_Control, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Slash, '/' , '/' , 0xffff },
- { Qt::Key_SysReq, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Meta, 0xffff , 0xffff , 0xffff }, // 100
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // break
- { Qt::Key_Home, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Up, 0xffff , 0xffff , 0xffff },
- { Qt::Key_PageUp, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Left, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Right, 0xffff , 0xffff , 0xffff },
- { Qt::Key_End, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Down, 0xffff , 0xffff , 0xffff },
- { Qt::Key_PageDown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Insert, 0xffff , 0xffff , 0xffff }, // 110
- { Qt::Key_Delete, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // macro
- { Qt::Key_F13, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F14, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Help, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // do
- { Qt::Key_F17, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Plus, '+' , '-' , 0xffff },
- { Qt::Key_Pause, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { 0, 0xffff , 0xffff , 0xffff }
-};
-
-static const int keyMSize = sizeof(pc101KeyM)/sizeof(QWSKeyMap)-1;
-
-//===========================================================================
-
-//
-// PC-101 type keyboards
-//
-
-/*!
- \class QWSPC101KeyboardHandler
- \ingroup qws
-
- \internal
-*/
-
-QWSPC101KeyboardHandler::QWSPC101KeyboardHandler(const QString&)
-{
- shift = false;
- alt = false;
- ctrl = false;
- extended = 0;
- prevuni = 0;
- prevkey = 0;
- caps = false;
-#if defined(QT_QWS_IPAQ)
- // iPAQ Action Key has ScanCode 0x60: 0x60|0x80 = 0xe0 == extended mode 1 !
- ipaq_return_pressed = false;
-#endif
-}
-
-QWSPC101KeyboardHandler::~QWSPC101KeyboardHandler()
-{
-}
-
-const QWSKeyMap *QWSPC101KeyboardHandler::keyMap() const
-{
- return pc101KeyM;
-}
-
-void QWSPC101KeyboardHandler::doKey(uchar code)
-{
-
- int keyCode = Qt::Key_unknown;
- bool release = false;
- int keypad = 0;
- bool softwareRepeat = false;
-
-#ifndef QT_QWS_USE_KEYCODES
- // extended?
- if (code == 224
-#if defined(QT_QWS_IPAQ)
- && !ipaq_return_pressed
-#endif
- ) {
- extended = 1;
- return;
- } else if (code == 225) {
- extended = 2;
- return;
- }
-#endif
-
- if (code & 0x80) {
- release = true;
- code &= 0x7f;
- }
-
-#ifndef QT_QWS_USE_KEYCODES
- if (extended == 1) {
- switch (code) {
- case 72:
- keyCode = Qt::Key_Up;
- break;
- case 75:
- keyCode = Qt::Key_Left;
- break;
- case 77:
- keyCode = Qt::Key_Right;
- break;
- case 80:
- keyCode = Qt::Key_Down;
- break;
- case 82:
- keyCode = Qt::Key_Insert;
- break;
- case 71:
- keyCode = Qt::Key_Home;
- break;
- case 73:
- keyCode = Qt::Key_PageUp;
- break;
- case 83:
- keyCode = Qt::Key_Delete;
- break;
- case 79:
- keyCode = Qt::Key_End;
- break;
- case 81:
- keyCode = Qt::Key_PageDown;
- break;
- case 28:
- keyCode = Qt::Key_Enter;
- break;
- case 53:
- keyCode = Qt::Key_Slash;
- break;
- case 0x1d:
- keyCode = Qt::Key_Control;
- break;
- case 0x2a:
- keyCode = Qt::Key_Print;
- break;
- case 0x38:
- keyCode = Qt::Key_Alt;
- break;
- case 0x5b:
- keyCode = Qt::Key_Super_L;
- break;
- case 0x5c:
- keyCode = Qt::Key_Super_R;
- break;
- case 0x5d:
- keyCode = Qt::Key_Menu;
- break;
-#if 0
- default:
- qDebug("extended1 code %x release %d", code, release);
- break;
-#endif
- }
- } else if (extended == 2) {
- switch (code) {
- case 0x1d:
- return;
- case 0x45:
- keyCode = Qt::Key_Pause;
- break;
- }
- } else
-#endif
- {
- if (code < keyMSize) {
- keyCode = pc101KeyM[code].key_code;
- }
-
-#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
- softwareRepeat = true;
-
- switch (code) {
- case 0x7a: case 0x7b: case 0x7c: case 0x7d:
- keyCode = code - 0x7a + Qt::Key_F9;
- softwareRepeat = false;
- break;
- case 0x79:
- keyCode = Qt::Key_SysReq;
- softwareRepeat = false;
- break;
- case 0x78:
-# ifdef QT_QWS_IPAQ
- keyCode = Qt::Key_F24; // record
-# else
- keyCode = Qt::Key_Escape;
-# endif
- softwareRepeat = false;
- break;
- case 0x60:
- keyCode = Qt::Key_Return;
-# ifdef QT_QWS_IPAQ
- ipaq_return_pressed = !release;
-# endif
- break;
- case 0x67:
- keyCode = Qt::Key_Right;
- break;
- case 0x69:
- keyCode = Qt::Key_Up;
- break;
- case 0x6a:
- keyCode = Qt::Key_Down;
- break;
- case 0x6c:
- keyCode = Qt::Key_Left;
- break;
- }
-
- if (qt_screen->isTransformed()
- && keyCode >= Qt::Key_Left && keyCode <= Qt::Key_Down)
- {
- keyCode = transformDirKey(keyCode);
- }
-#endif
- /*
- Translate shift+Qt::Key_Tab to Qt::Key_Backtab
- */
- if ((keyCode == Qt::Key_Tab) && shift)
- keyCode = Qt::Key_Backtab;
- }
-
-#ifndef QT_QWS_USE_KEYCODES
- /*
- Qt::Keypad consists of extended keys 53 and 28,
- and non-extended keys 55 and 71 through 83.
- */
- if ((extended == 1) ? (code == 53 || code == 28) :
- (code == 55 || (code >= 71 && code <= 83)))
-#else
- if (code == 55 || code >= 71 && code <= 83 || code == 96
- || code == 98 || code == 118)
-#endif
- {
- keypad = Qt::KeypadModifier;
- }
-
- // Ctrl-Alt-Backspace exits qws
- if (ctrl && alt && keyCode == Qt::Key_Backspace) {
- qApp->quit();
- }
-
- if (keyCode == Qt::Key_Alt) {
- alt = !release;
- } else if (keyCode == Qt::Key_Control) {
- ctrl = !release;
- } else if (keyCode == Qt::Key_Shift) {
- shift = !release;
- } else if (keyCode == Qt::Key_CapsLock && release) {
- caps = !caps;
-#if defined(Q_OS_LINUX)
- char leds;
- ioctl(0, KDGETLED, &leds);
- leds = leds & ~LED_CAP;
- if (caps) leds |= LED_CAP;
- ioctl(0, KDSETLED, leds);
-#endif
- }
- if (keyCode != Qt::Key_unknown) {
- bool bAlt = alt;
- bool bCtrl = ctrl;
- bool bShift = shift;
- int unicode = 0;
- if (code < keyMSize) {
- if (!extended) {
- bool bCaps = shift ||
- (caps ? QChar(keyMap()[code].unicode).isLetter() : false);
- if (bCtrl)
- unicode = keyMap()[code].ctrl_unicode ? keyMap()[code].ctrl_unicode : 0xffff;
- else if (bCaps)
- unicode = keyMap()[code].shift_unicode ? keyMap()[code].shift_unicode : 0xffff;
- else
- unicode = keyMap()[code].unicode ? keyMap()[code].unicode : 0xffff;
-#ifndef QT_QWS_USE_KEYCODES
- } else if (extended==1) {
- if (code == 53)
- unicode = '/';
-#endif
- }
- }
-
- modifiers = 0;
- if (bAlt) modifiers |= Qt::AltModifier;
- if (bCtrl) modifiers |= Qt::ControlModifier;
- if (bShift) modifiers |= Qt::ShiftModifier;
- if (keypad) modifiers |= Qt::KeypadModifier;
-
- // looks wrong -- WWA
- bool repeat = false;
- if (prevuni == unicode && prevkey == keyCode && !release)
- repeat = true;
-
- processKeyEvent(unicode, keyCode, modifiers, !release, repeat);
-
- if (!release) {
- prevuni = unicode;
- prevkey = keyCode;
- } else {
- prevkey = prevuni = 0;
- }
- }
-
- if (softwareRepeat && !release)
- beginAutoRepeat(prevuni, prevkey, modifiers);
- else
- endAutoRepeat();
-
- extended = 0;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_KEYBOARD
diff --git a/src/gui/embedded/qkbdsl5000_qws.cpp b/src/gui/embedded/qkbdsl5000_qws.cpp
index bc412b6..1e8095e 100644
--- a/src/gui/embedded/qkbdsl5000_qws.cpp
+++ b/src/gui/embedded/qkbdsl5000_qws.cpp
@@ -195,6 +195,13 @@ static const int keyMSize = sizeof(sl5000KeyMap)/sizeof(QWSKeyMap)-1;
QWSSL5000KeyboardHandler::QWSSL5000KeyboardHandler(const QString &device)
: QWSTtyKeyboardHandler(device)
{
+ shift = false;
+ alt = false;
+ ctrl = false;
+ extended = 0;
+ prevuni = 0;
+ prevkey = 0;
+ caps = false;
meta = false;
fn = false;
numLock = false;
@@ -220,7 +227,7 @@ const QWSKeyMap *QWSSL5000KeyboardHandler::keyMap() const
return sl5000KeyMap;
}
-void QWSSL5000KeyboardHandler::doKey(uchar code)
+bool QWSSL5000KeyboardHandler::filterKeycode(char &code)
{
int keyCode = Qt::Key_unknown;
bool release = false;
@@ -239,19 +246,19 @@ void QWSSL5000KeyboardHandler::doKey(uchar code)
else if (code == 0x52) { unicode='Z'-'@'; scan=Qt::Key_Z; } // Undo
if (scan) {
processKeyEvent(unicode, scan, Qt::ControlModifier, !release, false);
- return;
+ return true;
}
}
if (code < keyMSize) {
- keyCode = keyMap()[code].key_code;
+ keyCode = keyMap()[int(code)].key_code;
}
bool repeatable = true;
if (release && (keyCode == Qt::Key_F34 || keyCode == Qt::Key_F35))
- return; // no release for power and light keys
- if (keyCode >= Qt::Key_F1 && keyCode <= Qt::Key_F35
+ return true; // no release for power and light keys
+ if ((keyCode >= Qt::Key_F1 && keyCode <= Qt::Key_F35)
|| keyCode == Qt::Key_Escape || keyCode == Qt::Key_Home
|| keyCode == Qt::Key_Shift || keyCode == Qt::Key_Meta)
repeatable = false;
@@ -318,11 +325,11 @@ void QWSSL5000KeyboardHandler::doKey(uchar code)
keyCode = Qt::Key_QuoteLeft;
unicode = '`';
} else if (bCtrl)
- unicode = keyMap()[code].ctrl_unicode ? keyMap()[code].ctrl_unicode : 0xffff;
+ unicode = keyMap()[int(code)].ctrl_unicode ? keyMap()[int(code)].ctrl_unicode : 0xffff;
else if (bCaps)
- unicode = keyMap()[code].shift_unicode ? keyMap()[code].shift_unicode : 0xffff;
+ unicode = keyMap()[int(code)].shift_unicode ? keyMap()[int(code)].shift_unicode : 0xffff;
else
- unicode = keyMap()[code].unicode ? keyMap()[code].unicode : 0xffff;
+ unicode = keyMap()[int(code)].unicode ? keyMap()[int(code)].unicode : 0xffff;
}
modifiers = 0;
@@ -349,6 +356,8 @@ void QWSSL5000KeyboardHandler::doKey(uchar code)
beginAutoRepeat(prevuni, prevkey, modifiers);
else
endAutoRepeat();
+
+ return true;
}
QT_END_NAMESPACE
diff --git a/src/gui/embedded/qkbdsl5000_qws.h b/src/gui/embedded/qkbdsl5000_qws.h
index 514d602..a96e038 100644
--- a/src/gui/embedded/qkbdsl5000_qws.h
+++ b/src/gui/embedded/qkbdsl5000_qws.h
@@ -52,7 +52,13 @@ QT_MODULE(Gui)
#ifndef QT_NO_QWS_KBD_SL5000
-class QWSSL5000KbPrivate;
+struct QWSKeyMap {
+ uint key_code;
+ ushort unicode;
+ ushort shift_unicode;
+ ushort ctrl_unicode;
+};
+
class QWSSL5000KeyboardHandler : public QWSTtyKeyboardHandler
{
@@ -60,14 +66,21 @@ public:
explicit QWSSL5000KeyboardHandler(const QString&);
virtual ~QWSSL5000KeyboardHandler();
- virtual void doKey(uchar scancode);
+ bool filterKeycode(char &keycode);
virtual const QWSKeyMap *keyMap() const;
private:
+ bool shift;
+ bool alt;
+ bool ctrl;
+ bool caps;
+ uint extended:2;
+ Qt::KeyboardModifiers modifiers;
+ int prevuni;
+ int prevkey;
bool meta;
bool fn;
bool numLock;
- QWSSL5000KbPrivate *d;
};
#endif // QT_NO_QWS_KBD_SL5000
diff --git a/src/gui/embedded/qkbdtty_qws.cpp b/src/gui/embedded/qkbdtty_qws.cpp
index b588e55..5c0dec8 100644
--- a/src/gui/embedded/qkbdtty_qws.cpp
+++ b/src/gui/embedded/qkbdtty_qws.cpp
@@ -43,64 +43,57 @@
#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_TTY)
-#include "qscreen_qws.h"
-
-#include "qwindowsystem_qws.h"
-#include "qapplication.h"
-#include "qsocketnotifier.h"
-#include "qnamespace.h"
-#include "qtimer.h"
-#include <private/qwssignalhandler_p.h>
-#include <private/qwindowsurface_qws_p.h>
-
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <signal.h>
-#include <termios.h>
+#include <QSocketNotifier>
+#include <QStringList>
-#include <qeventloop.h>
+#include <qplatformdefs.h>
-#ifdef Q_OS_LINUX
-#include <sys/kd.h>
-#include <sys/vt.h>
-#endif
+#include <errno.h>
+#include <termios.h>
-QT_BEGIN_NAMESPACE
+#if defined Q_OS_LINUX
+# include <linux/kd.h>
+# include <linux/vt.h> //TODO: move vt handling somewhere else (QLinuxFbScreen?)
-#define VTACQSIG SIGUSR1
-#define VTRELSIG SIGUSR2
+# include "qscreen_qws.h"
+# include "qwindowsystem_qws.h"
+# include "qapplication.h"
+# include "private/qwindowsurface_qws_p.h"
+# include "private/qwssignalhandler_p.h"
-static int vtQws = 0;
-static int kbdFD = -1;
+# define VTACQSIG SIGUSR1
+# define VTRELSIG SIGUSR2
+#endif
-//===========================================================================
-//
-// Tty keyboard
-//
+QT_BEGIN_NAMESPACE
class QWSTtyKbPrivate : public QObject
{
Q_OBJECT
public:
- QWSTtyKbPrivate(QWSPC101KeyboardHandler *, const QString &device);
+ QWSTtyKbPrivate(QWSTtyKeyboardHandler *handler, const QString &device);
~QWSTtyKbPrivate();
-private slots:
- void readKeyboardData();
- void handleTtySwitch(int);
+private:
+ void switchLed(char, bool);
+ void switchConsole(int vt);
+
+private Q_SLOTS:
+ void readKeycode();
+ void handleConsoleSwitch(int sig);
private:
- QWSPC101KeyboardHandler *handler;
- struct termios origTermData;
+ QWSTtyKeyboardHandler *m_handler;
+ int m_tty_fd;
+ struct termios m_tty_attr;
+ char m_last_keycode;
+ int m_vt_qws;
};
+
QWSTtyKeyboardHandler::QWSTtyKeyboardHandler(const QString &device)
- : QWSPC101KeyboardHandler(device)
+ : QWSKeyboardHandler(device)
{
d = new QWSTtyKbPrivate(this, device);
}
@@ -110,59 +103,63 @@ QWSTtyKeyboardHandler::~QWSTtyKeyboardHandler()
delete d;
}
-void QWSTtyKeyboardHandler::processKeyEvent(int unicode, int keycode,
- Qt::KeyboardModifiers modifiers, bool isPress,
- bool autoRepeat)
+bool QWSTtyKeyboardHandler::filterKeycode(char &)
{
-#if defined(Q_OS_LINUX)
- // Virtual console switching
- int term = 0;
- bool ctrl = modifiers & Qt::ControlModifier;
- bool alt = modifiers & Qt::AltModifier;
- if (ctrl && alt && keycode >= Qt::Key_F1 && keycode <= Qt::Key_F10)
- term = keycode - Qt::Key_F1 + 1;
- else if (ctrl && alt && keycode == Qt::Key_Left)
- term = qMax(vtQws - 1, 1);
- else if (ctrl && alt && keycode == Qt::Key_Right)
- term = qMin(vtQws + 1, 10);
- if (term && isPress) {
- ioctl(kbdFD, VT_ACTIVATE, term);
- return;
- }
-#endif
-
- QWSPC101KeyboardHandler::processKeyEvent(unicode, keycode, modifiers,
- isPress, autoRepeat);
+ return false;
}
-
-QWSTtyKbPrivate::QWSTtyKbPrivate(QWSPC101KeyboardHandler *h, const QString &device) : handler(h)
+QWSTtyKbPrivate::QWSTtyKbPrivate(QWSTtyKeyboardHandler *h, const QString &device)
+ : m_handler(h), m_tty_fd(-1), m_last_keycode(0), m_vt_qws(0)
{
- kbdFD = ::open(device.isEmpty()?"/dev/tty0":device.toLatin1().constData(), O_RDWR|O_NDELAY, 0);
+ setObjectName(QLatin1String("TTY Keyboard Handler"));
#ifndef QT_NO_QWS_SIGNALHANDLER
QWSSignalHandler::instance()->addObject(this);
#endif
- if (kbdFD >= 0) {
+ QString dev = QLatin1String("/dev/tty0");
+ int repeat_delay = -1;
+ int repeat_rate = -1;
+
+ QStringList args = device.split(QLatin1Char(':'));
+ foreach (const QString &arg, args) {
+ if (arg.startsWith(QLatin1String("repeat-delay=")))
+ repeat_delay = arg.mid(13).toInt();
+ else if (arg.startsWith(QLatin1String("repeat-rate=")))
+ repeat_rate = arg.mid(12).toInt();
+ else if (arg.startsWith(QLatin1String("/dev/")))
+ dev = arg;
+ }
+
+ m_tty_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDWR, 0);
+ if (m_tty_fd >= 0) {
+ if (repeat_delay > 0 && repeat_rate > 0) {
+#if defined(Q_OS_LINUX)
+ struct ::kbd_repeat kbdrep = { repeat_delay, repeat_rate };
+ ::ioctl(m_tty_fd, KDKBDREP, &kbdrep);
+#endif
+ }
+
QSocketNotifier *notifier;
- notifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this);
- connect(notifier, SIGNAL(activated(int)),this,
- SLOT(readKeyboardData()));
+ notifier = new QSocketNotifier(m_tty_fd, QSocketNotifier::Read, this);
+ connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode()));
- // save for restore.
- tcgetattr(kbdFD, &origTermData);
+ // save tty config for restore.
+ tcgetattr(m_tty_fd, &m_tty_attr);
- struct termios termdata;
- tcgetattr(kbdFD, &termdata);
+ struct ::termios termdata;
+ tcgetattr(m_tty_fd, &termdata);
#if defined(Q_OS_LINUX)
-# ifdef QT_QWS_USE_KEYCODES
- ioctl(kbdFD, KDSKBMODE, K_MEDIUMRAW);
-# else
- ioctl(kbdFD, KDSKBMODE, K_RAW);
-# endif
+ // PLEASE NOTE:
+ // The tty keycode interface can only report keycodes 0x01 .. 0x7f
+ // KEY_MAX is however defined to 0x1ff. In practice this is sufficient
+ // for a PC style keyboard though.
+ // we don't support K_RAW anymore - if you need, you habe to add a
+ // scan- to keycode converter.
+ ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
#endif
+ // set the tty layer to pass-through
termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
termdata.c_oflag = 0;
termdata.c_cflag = CREAD | CS8;
@@ -171,50 +168,145 @@ QWSTtyKbPrivate::QWSTtyKbPrivate(QWSPC101KeyboardHandler *h, const QString &devi
termdata.c_cc[VMIN]=1;
cfsetispeed(&termdata, 9600);
cfsetospeed(&termdata, 9600);
- tcsetattr(kbdFD, TCSANOW, &termdata);
+ tcsetattr(m_tty_fd, TCSANOW, &termdata);
#if defined(Q_OS_LINUX)
-
- connect(QApplication::instance(), SIGNAL(unixSignal(int)), this, SLOT(handleTtySwitch(int)));
+ // VT switching is handled via unix signals
+ connect(QApplication::instance(), SIGNAL(unixSignal(int)), this, SLOT(handleConsoleSwitch(int)));
QApplication::instance()->watchUnixSignal(VTACQSIG, true);
QApplication::instance()->watchUnixSignal(VTRELSIG, true);
- struct vt_mode vtMode;
- ioctl(kbdFD, VT_GETMODE, &vtMode);
+ struct ::vt_mode vtMode;
+ if (::ioctl(m_tty_fd, VT_GETMODE, &vtMode) == 0) {
+ vtMode.mode = VT_PROCESS;
+ vtMode.relsig = VTRELSIG;
+ vtMode.acqsig = VTACQSIG;
- // let us control VT switching
- vtMode.mode = VT_PROCESS;
- vtMode.relsig = VTRELSIG;
- vtMode.acqsig = VTACQSIG;
- ioctl(kbdFD, VT_SETMODE, &vtMode);
+ if (::ioctl(m_tty_fd, VT_SETMODE, &vtMode) == 0) {
+ struct ::vt_stat vtStat;
+ ::memset(&vtStat, 0, sizeof(vtStat));
- struct vt_stat vtStat;
- ioctl(kbdFD, VT_GETSTATE, &vtStat);
- vtQws = vtStat.v_active;
+ if (::ioctl(m_tty_fd, VT_GETSTATE, &vtStat) == 0 ) {
+ m_vt_qws = vtStat.v_active;
+ }
+ }
+ }
+
+ if (!m_vt_qws)
+ qWarning("Could not initialize virtual console switching");
#endif
} else {
- qCritical("Cannot open keyboard: %s", strerror(errno));
+ qWarning("Cannot open input device '%s': %s", qPrintable(dev), strerror(errno));
+ return;
}
}
QWSTtyKbPrivate::~QWSTtyKbPrivate()
{
- if (kbdFD >= 0) {
+ if (m_tty_fd >= 0) {
#if defined(Q_OS_LINUX)
- ioctl(kbdFD, KDSKBMODE, K_XLATE);
+ ::ioctl(m_tty_fd, KDSKBMODE, K_XLATE);
#endif
- tcsetattr(kbdFD, TCSANOW, &origTermData);
- ::close(kbdFD);
- kbdFD = -1;
+ tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr);
}
}
-void QWSTtyKbPrivate::handleTtySwitch(int sig)
+
+
+void QWSTtyKbPrivate::switchLed(char led, bool state)
{
#if defined(Q_OS_LINUX)
+ char ledstate;
+
+ ::ioctl(m_tty_fd, KDGETLED, &ledstate);
+ if (state)
+ ledstate |= led;
+ else
+ ledstate &= ~led;
+ ::ioctl(m_tty_fd, KDSETLED, ledstate);
+#endif
+}
+
+void QWSTtyKbPrivate::readKeycode()
+{
+ char buffer[32];
+ int n = 0;
+
+ forever {
+ n = QT_READ(m_tty_fd, buffer + n, 32 - n);
+
+ if (n == 0) {
+ qWarning("Got EOF from the input device.");
+ return;
+ } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
+ qWarning("Could not read from input device: %s", strerror(errno));
+ return;
+ } else {
+ break;
+ }
+ }
+
+ for (int i = 0; i < n; ++i) {
+ if (m_handler->filterKeycode(buffer[i]))
+ continue;
+
+ QWSKeyboardHandler::KeycodeAction ka;
+ ka = m_handler->processKeycode(buffer[i] & 0x7f, (buffer[i] & 0x80) == 0x00, buffer[i] == m_last_keycode);
+ m_last_keycode = buffer[i];
+
+ switch (ka) {
+ case QWSKeyboardHandler::CapsLockOn:
+ case QWSKeyboardHandler::CapsLockOff:
+ switchLed(LED_CAP, ka == QWSKeyboardHandler::CapsLockOn);
+ break;
+
+ case QWSKeyboardHandler::NumLockOn:
+ case QWSKeyboardHandler::NumLockOff:
+ switchLed(LED_NUM, ka == QWSKeyboardHandler::NumLockOn);
+ break;
+
+ case QWSKeyboardHandler::ScrollLockOn:
+ case QWSKeyboardHandler::ScrollLockOff:
+ switchLed(LED_SCR, ka == QWSKeyboardHandler::ScrollLockOn);
+ break;
+
+ case QWSKeyboardHandler::PreviousConsole:
+ switchConsole(qBound(1, m_vt_qws - 1, 10));
+ break;
+
+ case QWSKeyboardHandler::NextConsole:
+ switchConsole(qBound(1, m_vt_qws + 1, 10));
+ break;
+
+ default:
+ if (ka >= QWSKeyboardHandler::SwitchConsoleFirst &&
+ ka <= QWSKeyboardHandler::SwitchConsoleLast) {
+ switchConsole(1 + (ka & QWSKeyboardHandler::SwitchConsoleMask));
+ }
+ //ignore reboot
+ break;
+ }
+ }
+}
+
+
+void QWSTtyKbPrivate::switchConsole(int vt)
+{
+#if defined(Q_OS_LINUX)
+ if (m_vt_qws && vt && (m_tty_fd >= 0 ))
+ ::ioctl(m_tty_fd, VT_ACTIVATE, vt);
+#endif
+}
+
+void QWSTtyKbPrivate::handleConsoleSwitch(int sig)
+{
+#if defined(Q_OS_LINUX)
+ // received a notification from the kernel that the current VT is
+ // changing: either enable or disable QWS painting accordingly.
+
if (sig == VTACQSIG) {
- if (ioctl(kbdFD, VT_RELDISP, VT_ACKACQ) == 0) {
+ if (::ioctl(m_tty_fd, VT_RELDISP, VT_ACKACQ) == 0) {
qwsServer->enablePainting(true);
qt_screen->restore();
qwsServer->resumeMouse();
@@ -236,9 +328,9 @@ void QWSTtyKbPrivate::handleTtySwitch(int sig)
}
if (!allWindowsHidden) {
- ioctl(kbdFD, VT_RELDISP, 0); // abort console switch
+ ::ioctl(m_tty_fd, VT_RELDISP, 0); // abort console switch
qwsServer->enablePainting(true);
- } else if (ioctl(kbdFD, VT_RELDISP, 1) == 0) {
+ } else if (::ioctl(m_tty_fd, VT_RELDISP, 1) == 0) {
qt_screen->save();
qwsServer->suspendMouse();
} else {
@@ -248,14 +340,6 @@ void QWSTtyKbPrivate::handleTtySwitch(int sig)
#endif
}
-void QWSTtyKbPrivate::readKeyboardData()
-{
- unsigned char buf[81];
- int n = read(kbdFD, buf, 80);
- for (int loop = 0; loop < n; loop++)
- handler->doKey(buf[loop]);
-}
-
QT_END_NAMESPACE
#include "qkbdtty_qws.moc"
diff --git a/src/gui/embedded/qkbdtty_qws.h b/src/gui/embedded/qkbdtty_qws.h
index 4f93d6c..fc3eaa1 100644
--- a/src/gui/embedded/qkbdtty_qws.h
+++ b/src/gui/embedded/qkbdtty_qws.h
@@ -42,7 +42,7 @@
#ifndef QKBDTTY_QWS_H
#define QKBDTTY_QWS_H
-#include <QtGui/qkbdpc101_qws.h>
+#include <QtGui/qkbd_qws.h>
QT_BEGIN_HEADER
@@ -56,15 +56,13 @@ QT_MODULE(Gui)
class QWSTtyKbPrivate;
-class QWSTtyKeyboardHandler : public QWSPC101KeyboardHandler
+class QWSTtyKeyboardHandler : public QWSKeyboardHandler
{
public:
explicit QWSTtyKeyboardHandler(const QString&);
virtual ~QWSTtyKeyboardHandler();
-protected:
- virtual void processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
- bool isPress, bool autoRepeat);
+ virtual bool filterKeycode(char &code);
private:
QWSTtyKbPrivate *d;
diff --git a/src/gui/embedded/qkbdum_qws.cpp b/src/gui/embedded/qkbdum_qws.cpp
index d525c66..fa05d6c 100644
--- a/src/gui/embedded/qkbdum_qws.cpp
+++ b/src/gui/embedded/qkbdum_qws.cpp
@@ -54,6 +54,7 @@
#include <qstring.h>
#include <qwindowsystem_qws.h>
#include <qsocketnotifier.h>
+#include "qplatformdefs.h"
QT_BEGIN_NAMESPACE
@@ -81,13 +82,13 @@ QWSUmKeyboardHandlerPrivate::QWSUmKeyboardHandlerPrivate(const QString &device)
{
kbdBuffer = new unsigned char [kbdBufferLen];
- if ((kbdFD = open((const char *)device.toLocal8Bit(), O_RDONLY | O_NDELAY)) < 0) {
+ if ((kbdFD = QT_OPEN((const char *)device.toLocal8Bit(), O_RDONLY | O_NDELAY, 0)) < 0) {
qDebug("Cannot open %s (%s)", (const char *)device.toLocal8Bit(),
strerror(errno));
} else {
// Clear pending input
char buf[2];
- while (read(kbdFD, buf, 1) > 0) { }
+ while (QT_READ(kbdFD, buf, 1) > 0) { }
notifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this);
connect(notifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData()));
@@ -97,7 +98,7 @@ QWSUmKeyboardHandlerPrivate::QWSUmKeyboardHandlerPrivate(const QString &device)
QWSUmKeyboardHandlerPrivate::~QWSUmKeyboardHandlerPrivate()
{
if (kbdFD >= 0)
- close(kbdFD);
+ QT_CLOSE(kbdFD);
delete [] kbdBuffer;
}
@@ -106,7 +107,7 @@ void QWSUmKeyboardHandlerPrivate::readKeyboardData()
{
int n;
do {
- n = read(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
+ n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
if (n > 0)
kbdIdx += n;
} while (n > 0);
diff --git a/src/gui/embedded/qkbdusb_qws.cpp b/src/gui/embedded/qkbdusb_qws.cpp
deleted file mode 100644
index e35ac55..0000000
--- a/src/gui/embedded/qkbdusb_qws.cpp
+++ /dev/null
@@ -1,401 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qkbdusb_qws.h"
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-#include "qscreen_qws.h"
-
-#include "qwindowsystem_qws.h"
-#include "qapplication.h"
-#include "qsocketnotifier.h"
-#include "qnamespace.h"
-#include "qtimer.h"
-
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <signal.h>
-
-#include <linux/input.h>
-
-#ifdef Q_OS_LINUX
-#include <sys/kd.h>
-#include <sys/vt.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-/* USB driver */
-
-
-class QWSUsbKbPrivate : public QObject
-{
- Q_OBJECT
-public:
- QWSUsbKbPrivate(QWSPC101KeyboardHandler *, const QString &);
- ~QWSUsbKbPrivate();
-
-private slots:
- void readKeyboardData();
-
-private:
- QWSPC101KeyboardHandler *handler;
- int fd;
-#ifdef QT_QWS_ZYLONITE
- bool shift;
-#endif
-};
-
-QWSUsbKeyboardHandler::QWSUsbKeyboardHandler(const QString &device)
- : QWSPC101KeyboardHandler(device)
-{
- d = new QWSUsbKbPrivate(this, device);
-}
-
-QWSUsbKeyboardHandler::~QWSUsbKeyboardHandler()
-{
- delete d;
-}
-
-QWSUsbKbPrivate::QWSUsbKbPrivate(QWSPC101KeyboardHandler *h, const QString &device) : handler(h)
-{
-#ifdef QT_QWS_ZYLONITE
- shift = FALSE;
-#endif
- fd = ::open(device.isEmpty()?"/dev/input/event1":device.toLocal8Bit(),O_RDONLY, 0);
- if (fd >= 0) {
- QSocketNotifier *notifier;
- notifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
- connect(notifier, SIGNAL(activated(int)),this,
- SLOT(readKeyboardData()));
- }
-}
-
-QWSUsbKbPrivate::~QWSUsbKbPrivate()
-{
- ::close(fd);
-}
-
-void QWSUsbKbPrivate::readKeyboardData()
-{
- input_event event;
- if (read(fd, &event, sizeof(input_event)) != sizeof(input_event))
- return;
-
- if (event.type != EV_KEY)
- return;
-
-#ifdef QT_QWS_ZYLONITE
- qDebug("keypressed: code=%03d (%s)\n",event.code,((event.value)!=0) ? "Down":"Up");
- int modifiers=0;
- int unicode=0xffff;
- int key_code=0;
-
- switch(event.code)
- {
- case 0xA2:
- key_code = ((!shift) ? Qt::Key_0 : Qt::Key_Plus );
- unicode = ((!shift) ? 0x30 : 0x2B );
- break;
- case 0x70:
- key_code = ((!shift) ? Qt::Key_1 : Qt::Key_At );
- unicode = ((!shift) ? 0x31 : 0x40 );
- break;
- case 0x72:
- key_code = ((!shift) ? Qt::Key_2 : Qt::Key_Ampersand );
- unicode = ((!shift) ? 0x32 : 0x26 );
- break;
- case 0x74:
- key_code = ((!shift) ? Qt::Key_3 : Qt::Key_At );
- unicode = ((!shift) ? 0x33 : 0x3F );
- break;
- case 0x80:
- key_code = ((!shift) ? Qt::Key_4 : Qt::Key_Minus );
- unicode = ((!shift) ? 0x34 : 0x2D );
- break;
- case 0x82:
- key_code = ((!shift) ? Qt::Key_5 : Qt::Key_Apostrophe);
- unicode = ((!shift) ? 0x35 : 0x27 );
- break;
- case 0x84:
- key_code = ((!shift) ? Qt::Key_6 : Qt::Key_Slash );
- unicode = ((!shift) ? 0x36 : 0x5C );
- break;
- case 0x90:
- key_code = ((!shift) ? Qt::Key_7 : Qt::Key_Colon );
- unicode = ((!shift) ? 0x37 : 0x3A );
- break;
- case 0x92:
- key_code = ((!shift) ? Qt::Key_8 : Qt::Key_Semicolon );
- unicode = ((!shift) ? 0x38 : 0x3B );
- break;
- case 0x94:
- key_code = ((!shift) ? Qt::Key_9 : Qt::Key_QuoteDbl );
- unicode = ((!shift) ? 0x39 : 0x22 );
- break;
- case 0x0:
- key_code = Qt::Key_A;
- unicode = ((!shift) ? 0x61 : 0x41 );
- break;
- case 0x10:
- key_code = Qt::Key_B;
- unicode = ((!shift) ? 0x62 : 0x42 );
- break;
- case 0x20:
- key_code = Qt::Key_C;
- unicode = ((!shift) ? 0x63 : 0x43 );
- break;
- case 0x30:
- key_code = Qt::Key_D;
- unicode = ((!shift) ? 0x64 : 0x44 );
- break;
- case 0x40:
- key_code = Qt::Key_E;
- unicode = ((!shift) ? 0x65 : 0x45 );
- break;
- case 0x50:
- key_code = Qt::Key_F;
- unicode = ((!shift) ? 0x66 : 0x46 );
- break;
- case 0x01:
- key_code = Qt::Key_G;
- unicode = ((!shift) ? 0x67 : 0x47 );
- break;
- case 0x11:
- key_code = Qt::Key_H;
- unicode = ((!shift) ? 0x68 : 0x48 );
- break;
- case 0x21:
- key_code = Qt::Key_I;
- unicode = ((!shift) ? 0x69 : 0x49 );
- break;
- case 0x31:
- key_code = Qt::Key_J;
- unicode = ((!shift) ? 0x6A : 0x4A );
- break;
- case 0x41:
- key_code = Qt::Key_K;
- unicode = ((!shift) ? 0x6B : 0x4B );
- break;
- case 0x51:
- key_code = Qt::Key_L;
- unicode = ((!shift) ? 0x6C : 0x4C );
- break;
- case 0x02:
- key_code = Qt::Key_M;
- unicode = ((!shift) ? 0x6D : 0x4D );
- break;
- case 0x12:
- key_code = Qt::Key_N;
- unicode = ((!shift) ? 0x6E : 0x4E );
- break;
- case 0x22:
- key_code = Qt::Key_O;
- unicode = ((!shift) ? 0x6F : 0x4F );
- break;
- case 0x32:
- key_code = Qt::Key_P;
- unicode = ((!shift) ? 0x70 : 0x50 );
- break;
- case 0x42:
- key_code = Qt::Key_Q;
- unicode = ((!shift) ? 0x71 : 0x51 );
- break;
- case 0x52:
- key_code = Qt::Key_R;
- unicode = ((!shift) ? 0x72 : 0x52 );
- break;
- case 0x03:
- key_code = Qt::Key_S;
- unicode = ((!shift) ? 0x73 : 0x53 );
- break;
- case 0x13:
- key_code = Qt::Key_T;
- unicode = ((!shift) ? 0x74 : 0x54 );
- break;
- case 0x23:
- key_code = Qt::Key_U;
- unicode = ((!shift) ? 0x75 : 0x55 );
- break;
- case 0x33:
- key_code = Qt::Key_V;
- unicode = ((!shift) ? 0x76 : 0x56 );
- break;
- case 0x43:
- key_code = Qt::Key_W;
- unicode = ((!shift) ? 0x77 : 0x57 );
- break;
- case 0x53:
- key_code = Qt::Key_X;
- unicode = ((!shift) ? 0x78 : 0x58 );
- break;
- case 0x24:
- key_code = Qt::Key_Y;
- unicode = ((!shift) ? 0x79 : 0x59 );
- break;
- case 0x34:
- key_code = Qt::Key_Z;
- unicode = ((!shift) ? 0x7A : 0x5A );
- break;
- case 0xA4:
- key_code = ((!shift) ? Qt::Key_NumberSign : Qt::Key_Period);
- unicode = ((!shift) ? 0x23 : 0x2E );
- break;
- case 0xA0:
- key_code = ((!shift) ? Qt::Key_Asterisk : Qt::Key_NumberSign );
- unicode = ((!shift) ? 0x2A : 0x2C );
- break;
- case 0x25:
- key_code = Qt::Key_Space;
- unicode = 0x20;
- break;
- case 0x06:
- key_code = Qt::Key_Up;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x16:
- key_code = Qt::Key_Down;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x26:
- key_code = Qt::Key_Left;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x36:
- key_code = Qt::Key_Right;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x46:
- key_code = Qt::Key_Select;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x61:
- key_code = Qt::Key_No;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x60:
- key_code = Qt::Key_Call;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x55:
- key_code = Qt::Key_Hangup;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x62:
- key_code = Qt::Key_Context1;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x63:
- key_code = Qt::Key_No;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x05:
- key_code = Qt::Key_Home;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x15:
- key_code = Qt::Key_Shift;
- unicode = 0xffff; modifiers |= Qt::ShiftModifier;
- if(event.value==0) break;
- if(shift) {
- shift = FALSE;
- qWarning("Caps Off!");
- } else {
- shift = TRUE;
- qWarning("Caps On!");
- }
- break;
- case 0x1C:
- key_code = ((!shift) ? Qt::Key_Back : Qt::Key_Enter );
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x19:
- key_code = Qt::Key_Context2;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x1A:
- key_code = Qt::Key_Context3;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- case 0x1B:
- key_code = Qt::Key_Context4;
- unicode = 0xffff; modifiers |= Qt::KeypadModifier;
- break;
- }
- if(shift) modifiers |= Qt::ShiftModifier;
- handler->processKeyEvent(unicode, key_code, (Qt::KeyboardModifiers)modifiers, event.value!=0, false);
-#else
-
- int key=event.code;
-#ifndef QT_QWS_USE_KEYCODES
- // Handle SOME keys, otherwise it's useless.
-
- if(key==103) {
- handler->processKeyEvent(0, Qt::Key_Up, 0, event.value!=0, false);
- } else if(key==106) {
- handler->processKeyEvent(0, Qt::Key_Right, 0, event.value!=0, false );
- } else if(key==108) {
- handler->processKeyEvent(0, Qt::Key_Down, 0, event.value!=0, false);
- } else if(key==105) {
- handler->processKeyEvent(0, Qt::Key_Left, 0, event.value!=0, false);
- } else
-
-#endif
-
- {
- if(event.value == 0) {
- key=key | 0x80;
- }
- handler->doKey(key);
- }
-#endif
-}
-
-QT_END_NAMESPACE
-
-#include "qkbdusb_qws.moc"
-
-#endif // QT_NO_QWS_KEYBOARD
diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp
index 6741f2c..ff48403 100644
--- a/src/gui/embedded/qscreen_qws.cpp
+++ b/src/gui/embedded/qscreen_qws.cpp
@@ -198,10 +198,12 @@ void QScreenCursor::set(const QImage &image, int hotx, int hoty)
*/
void QScreenCursor::move(int x, int y)
{
- const QRegion r = boundingRect();
+ QRegion r = boundingRect();
pos = QPoint(x,y);
- if (enable && !hwaccel)
- qt_screen->exposeRegion(r | boundingRect(), 0);
+ if (enable && !hwaccel) {
+ r |= boundingRect();
+ qt_screen->exposeRegion(r, 0);
+ }
}
diff --git a/src/gui/embedded/qwscommand_qws.cpp b/src/gui/embedded/qwscommand_qws.cpp
index 88e33a3..b0fd78b 100644
--- a/src/gui/embedded/qwscommand_qws.cpp
+++ b/src/gui/embedded/qwscommand_qws.cpp
@@ -43,7 +43,6 @@
#include "qtransportauth_qws.h"
#include "qtransportauth_qws_p.h"
-#include <sys/uio.h>
#include <unistd.h>
// #define QWSCOMMAND_DEBUG 1 // Uncomment to debug client/server communication
diff --git a/src/gui/embedded/qwssignalhandler.cpp b/src/gui/embedded/qwssignalhandler.cpp
index 0946fb6..e85bd36 100644
--- a/src/gui/embedded/qwssignalhandler.cpp
+++ b/src/gui/embedded/qwssignalhandler.cpp
@@ -44,8 +44,10 @@
#ifndef QT_NO_QWS_SIGNALHANDLER
#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
+#ifndef QT_NO_QWS_MULTIPROCESS
+# include <sys/ipc.h>
+# include <sys/sem.h>
+#endif
#include <signal.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index fc81f39..3aa74f3 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -533,25 +533,22 @@ QT_BEGIN_NAMESPACE
// QRectF::intersects() returns false always if either the source or target
// rectangle's width or height are 0. This works around that problem.
-static QRectF _q_adjustedRect(const QRectF &rect)
-{
- static const qreal p = (qreal)0.00001;
- QRectF r = rect;
- if (!r.width())
- r.adjust(-p, 0, p, 0);
- if (!r.height())
- r.adjust(0, -p, 0, p);
- return r;
+static inline void _q_adjustRect(QRectF *rect)
+{
+ Q_ASSERT(rect);
+ if (!rect->width())
+ rect->adjust(-0.00001, 0, 0.00001, 0);
+ if (!rect->height())
+ rect->adjust(0, -0.00001, 0, 0.00001);
}
-static QRect _q_adjustedRect(const QRect &rect)
+static inline void _q_adjustRect(QRect *rect)
{
- QRect r = rect;
- if (!r.width())
- r.adjust(0, 0, 1, 0);
- if (!r.height())
- r.adjust(0, 0, 0, 1);
- return r;
+ Q_ASSERT(rect);
+ if (!rect->width())
+ rect->adjust(0, 0, 1, 0);
+ if (!rect->height())
+ rect->adjust(0, 0, 0, 1);
}
/*
@@ -613,6 +610,7 @@ void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag ch
case QGraphicsItem::ItemClipsChildrenToShape:
flag = AncestorClipsChildren;
enabled = flags & QGraphicsItem::ItemClipsChildrenToShape;
+ invalidateCachedClipPathRecursively(/*childrenOnly=*/true);
break;
case QGraphicsItem::ItemIgnoresTransformations:
flag = AncestorIgnoresTransformations;
@@ -779,9 +777,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, bool de
if (newParent == parent)
return;
- QVariant variant;
- qVariantSetValue<QGraphicsItem *>(variant, newParent);
- newParent = qVariantValue<QGraphicsItem *>(q->itemChange(QGraphicsItem::ItemParentChange, variant));
+ const QVariant newParentVariant(q->itemChange(QGraphicsItem::ItemParentChange,
+ qVariantFromValue<QGraphicsItem *>(newParent)));
+ newParent = qVariantValue<QGraphicsItem *>(newParentVariant);
if (newParent == parent)
return;
@@ -799,11 +797,11 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, bool de
if (!deleting)
q_ptr->prepareGeometryChange();
+ const QVariant thisPointerVariant(qVariantFromValue<QGraphicsItem *>(q));
if (parent) {
// Remove from current parent
parent->d_ptr->removeChild(q);
- qVariantSetValue<QGraphicsItem *>(variant, q);
- parent->itemChange(QGraphicsItem::ItemChildRemovedChange, variant);
+ parent->itemChange(QGraphicsItem::ItemChildRemovedChange, thisPointerVariant);
}
// Update toplevelitem list. If this item is being deleted, its parent
@@ -828,10 +826,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, bool de
}
parent->d_ptr->addChild(q);
- qVariantSetValue<QGraphicsItem *>(variant, q);
- parent->itemChange(QGraphicsItem::ItemChildAddedChange, variant);
+ parent->itemChange(QGraphicsItem::ItemChildAddedChange, thisPointerVariant);
if (!implicitUpdate)
- updateHelper();
+ updateHelper(QRectF(), false, true);
// Inherit ancestor flags from the new parent.
updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1));
@@ -854,15 +851,16 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, bool de
updateAncestorFlag(QGraphicsItem::ItemClipsChildrenToShape);
updateAncestorFlag(QGraphicsItem::ItemIgnoresTransformations);
- // Update item visible / enabled.
- if (!visible && !explicitlyHidden)
- setVisibleHelper(true, /* explicit = */ false);
- if (!enabled && !explicitlyDisabled)
- setEnabledHelper(true, /* explicit = */ false);
+ if (!deleting) {
+ // Update item visible / enabled.
+ if (!visible && !explicitlyHidden)
+ setVisibleHelper(true, /* explicit = */ false);
+ if (!enabled && !explicitlyDisabled)
+ setEnabledHelper(true, /* explicit = */ false);
- // If the item is being deleted, the whole scene will be updated.
- if (!deleting)
- updateHelper();
+ // If the item is being deleted, the whole scene will be updated.
+ updateHelper(QRectF(), false, true);
+ }
}
if (scene) {
@@ -872,10 +870,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, bool de
}
// Resolve opacity.
- if (parent)
- resolveEffectiveOpacity(parent->effectiveOpacity());
- else
- resolveEffectiveOpacity(1.0);
+ updateEffectiveOpacity();
// Resolve depth.
resolveDepth(parent ? parent->d_ptr->depth : -1);
@@ -884,7 +879,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, bool de
invalidateSceneTransformCache();
// Deliver post-change notification
- q->itemChange(QGraphicsItem::ItemParentHasChanged, qVariantFromValue<QGraphicsItem *>(parent));
+ q->itemChange(QGraphicsItem::ItemParentHasChanged, newParentVariant);
}
/*!
@@ -1239,7 +1234,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
int geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations);
bool fullUpdate = (flags & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask);
if (fullUpdate)
- d_ptr->fullUpdateHelper();
+ d_ptr->fullUpdateHelper(false, true);
// Keep the old flags to compare the diff.
GraphicsItemFlags oldFlags = this->flags();
@@ -1249,12 +1244,8 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
// Reresolve effective opacity if the opacity flags change.
static const quint32 opacityFlagsMask = ItemIgnoresParentOpacity | ItemDoesntPropagateOpacityToChildren;
- if ((flags & opacityFlagsMask) != (oldFlags & opacityFlagsMask)) {
- if (QGraphicsItem *p = d_ptr->parent)
- d_ptr->resolveEffectiveOpacity(p->effectiveOpacity());
- else
- d_ptr->resolveEffectiveOpacity(1.0);
- }
+ if ((flags & opacityFlagsMask) != (oldFlags & opacityFlagsMask))
+ d_ptr->updateEffectiveOpacity();
if (!(d_ptr->flags & ItemIsFocusable) && hasFocus()) {
// Clear focus on the item if it has focus when the focusable flag
@@ -1274,6 +1265,9 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
d_ptr->updateAncestorFlag(ItemClipsChildrenToShape);
}
+ if ((flags & ItemClipsToShape) != (oldFlags & ItemClipsToShape))
+ d_ptr->invalidateCachedClipPath();
+
if ((flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)) {
// Item children clipping changes. Propagate the ancestor flag to
// all children.
@@ -1281,7 +1275,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
}
// ### Why updateHelper?
- d_ptr->updateHelper();
+ d_ptr->updateHelper(QRectF(), false, true);
// Notify change.
itemChange(ItemFlagsHaveChanged, quint32(flags));
@@ -1379,9 +1373,9 @@ QString QGraphicsItem::toolTip() const
*/
void QGraphicsItem::setToolTip(const QString &toolTip)
{
- QString newCursor = itemChange(ItemToolTipChange, toolTip).toString();
- d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTip);
- itemChange(ItemToolTipHasChanged, toolTip);
+ const QVariant toolTipVariant(itemChange(ItemToolTipChange, toolTip));
+ d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString());
+ itemChange(ItemToolTipHasChanged, toolTipVariant);
}
#endif // QT_NO_TOOLTIP
@@ -1423,12 +1417,13 @@ QCursor QGraphicsItem::cursor() const
*/
void QGraphicsItem::setCursor(const QCursor &cursor)
{
- QCursor newCursor = qVariantValue<QCursor>(itemChange(ItemCursorChange,
- qVariantFromValue<QCursor>(cursor)));
- d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, newCursor);
+ const QVariant cursorVariant(itemChange(ItemCursorChange, qVariantFromValue<QCursor>(cursor)));
+ d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qVariantValue<QCursor>(cursorVariant));
d_ptr->hasCursor = 1;
if (d_ptr->scene) {
+ d_ptr->scene->d_func()->allItemsUseDefaultCursor = false;
foreach (QGraphicsView *view, d_ptr->scene->views()) {
+ view->viewport()->setMouseTracking(true);
// Note: Some of this logic is duplicated in QGraphicsView's mouse events.
if (view->underMouse()) {
foreach (QGraphicsItem *itemUnderCursor, view->items(view->mapFromGlobal(QCursor::pos()))) {
@@ -1442,7 +1437,7 @@ void QGraphicsItem::setCursor(const QCursor &cursor)
}
}
}
- itemChange(ItemCursorHasChanged, qVariantFromValue<QCursor>(newCursor));
+ itemChange(ItemCursorHasChanged, cursorVariant);
}
/*!
@@ -1536,7 +1531,9 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
return;
// Modify the property.
- newVisible = q_ptr->itemChange(QGraphicsItem::ItemVisibleChange, quint32(newVisible)).toBool();
+ const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange,
+ quint32(newVisible)));
+ newVisible = newVisibleVariant.toBool();
if (visible == quint32(newVisible))
return;
visible = newVisible;
@@ -1583,9 +1580,10 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
}
// Update children with explicitly = false.
+ const bool updateChildren = update && !(flags & QGraphicsItem::ItemClipsChildrenToShape);
foreach (QGraphicsItem *child, children) {
if (!newVisible || !child->d_ptr->explicitlyHidden)
- child->d_ptr->setVisibleHelper(newVisible, false);
+ child->d_ptr->setVisibleHelper(newVisible, false, updateChildren);
}
// Enable subfocus
@@ -1597,7 +1595,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
}
// Deliver post-change notification.
- q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, quint32(visible));
+ q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, newVisibleVariant);
}
/*!
@@ -1703,7 +1701,9 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo
}
// Modify the property.
- enabled = q_ptr->itemChange(QGraphicsItem::ItemEnabledChange, quint32(newEnabled)).toBool();
+ const QVariant newEnabledVariant(q_ptr->itemChange(QGraphicsItem::ItemEnabledChange,
+ quint32(newEnabled)));
+ enabled = newEnabledVariant.toBool();
// Schedule redraw.
if (update)
@@ -1715,7 +1715,7 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo
}
// Deliver post-change notification.
- q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, quint32(enabled));
+ q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, newEnabledVariant);
}
/*!
@@ -1802,7 +1802,8 @@ void QGraphicsItem::setSelected(bool selected)
selected = false;
if (d_ptr->selected == selected)
return;
- bool newSelected = itemChange(ItemSelectedChange, quint32(selected)).toBool();
+ const QVariant newSelectedVariant(itemChange(ItemSelectedChange, quint32(selected)));
+ bool newSelected = newSelectedVariant.toBool();
if (d_ptr->selected == newSelected)
return;
d_ptr->selected = newSelected;
@@ -1822,7 +1823,7 @@ void QGraphicsItem::setSelected(bool selected)
}
// Deliver post-change notification.
- itemChange(QGraphicsItem::ItemSelectedHasChanged, quint32(d_ptr->selected));
+ itemChange(QGraphicsItem::ItemSelectedHasChanged, newSelectedVariant);
}
/*!
@@ -1866,6 +1867,9 @@ qreal QGraphicsItem::opacity() const
*/
qreal QGraphicsItem::effectiveOpacity() const
{
+ if (!d_ptr->hasEffectiveOpacity)
+ return qreal(1.0);
+
QVariant effectiveOpacity = d_ptr->extra(QGraphicsItemPrivate::ExtraEffectiveOpacity);
return effectiveOpacity.isNull() ? qreal(1.0) : qreal(effectiveOpacity.toDouble());
}
@@ -1895,17 +1899,18 @@ qreal QGraphicsItem::effectiveOpacity() const
void QGraphicsItem::setOpacity(qreal opacity)
{
// Notify change.
- qreal newOpacity = itemChange(ItemOpacityChange, double(opacity)).toDouble();
+ const QVariant newOpacityVariant(itemChange(ItemOpacityChange, double(opacity)));
+ qreal newOpacity = newOpacityVariant.toDouble();
// Normalize.
newOpacity = qBound<qreal>(0.0, newOpacity, 1.0);
// No change? Done.
- if (qFuzzyCompare(newOpacity, this->opacity()))
+ if (qFuzzyIsNull(newOpacity - this->opacity()))
return;
// Assign local opacity.
- if (qFuzzyCompare(newOpacity, qreal(1.0))) {
+ if (qFuzzyIsNull(newOpacity - 1)) {
// Opaque, unset opacity.
d_ptr->hasOpacity = 0;
d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraOpacity);
@@ -2050,7 +2055,13 @@ bool QGraphicsItem::acceptsHoverEvents() const
*/
void QGraphicsItem::setAcceptHoverEvents(bool enabled)
{
+ if (d_ptr->acceptsHover == quint32(enabled))
+ return;
d_ptr->acceptsHover = quint32(enabled);
+ if (d_ptr->acceptsHover && d_ptr->scene && d_ptr->scene->d_func()->allItemsIgnoreHoverEvents) {
+ d_ptr->scene->d_func()->allItemsIgnoreHoverEvents = false;
+ d_ptr->scene->d_func()->enableMouseTrackingOnViews();
+ }
}
/*!
@@ -2060,7 +2071,7 @@ void QGraphicsItem::setAcceptHoverEvents(bool enabled)
*/
void QGraphicsItem::setAcceptsHoverEvents(bool enabled)
{
- d_ptr->acceptsHover = quint32(enabled);
+ setAcceptHoverEvents(enabled);
}
/*!
@@ -2353,19 +2364,22 @@ QPointF QGraphicsItem::scenePos() const
the item is also updated; otherwise it is not updated before and after the
change.
*/
-void QGraphicsItemPrivate::setPosHelper(const QPointF &pos, bool update)
+void QGraphicsItemPrivate::setPosHelper(const QPointF &pos)
{
Q_Q(QGraphicsItem);
if (this->pos == pos)
return;
// Notify the item that the position is changing.
- QPointF newPos = q->itemChange(QGraphicsItem::ItemPositionChange, pos).toPointF();
+ const QVariant newPosVariant(q->itemChange(QGraphicsItem::ItemPositionChange, pos));
+ QPointF newPos = newPosVariant.toPointF();
if (newPos == this->pos)
return;
// Update and repositition.
- if (scene && update) {
+ inSetPosHelper = 1;
+ updateCachedClipPathFromSetPosHelper(newPos);
+ if (scene) {
fullUpdateHelper(true);
q->prepareGeometryChange();
}
@@ -2373,7 +2387,8 @@ void QGraphicsItemPrivate::setPosHelper(const QPointF &pos, bool update)
invalidateSceneTransformCache();
// Send post-notification.
- q->itemChange(QGraphicsItem::ItemPositionHasChanged, newPos);
+ q->itemChange(QGraphicsItem::ItemPositionHasChanged, newPosVariant);
+ inSetPosHelper = 0;
}
/*!
@@ -2388,7 +2403,7 @@ void QGraphicsItemPrivate::setPosHelper(const QPointF &pos, bool update)
*/
void QGraphicsItem::setPos(const QPointF &pos)
{
- d_ptr->setPosHelper(pos, /* update = */ true);
+ d_ptr->setPosHelper(pos);
}
/*!
@@ -2515,10 +2530,10 @@ QTransform QGraphicsItem::sceneTransform() const
QTransform m;
if (d_ptr->hasTransform) {
m = transform();
- m *= QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y());
- } else {
- // ### ? QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y())
- m.translate(d_ptr->pos.x(), d_ptr->pos.y());
+ if (!d_ptr->pos.isNull())
+ m *= QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y());
+ } else if (!d_ptr->pos.isNull()) {
+ m = QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y());
}
// Combine with parent and add to cache.
@@ -2643,6 +2658,8 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
if (ok)
*ok = true;
const QPointF &itemPos = d_ptr->pos;
+ if (itemPos.isNull())
+ return d_ptr->hasTransform ? transform() : QTransform();
if (d_ptr->hasTransform)
return transform() * QTransform::fromTranslate(itemPos.x(), itemPos.y());
return QTransform::fromTranslate(itemPos.x(), itemPos.y());
@@ -2653,7 +2670,8 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
const QPointF &otherPos = other->d_ptr->pos;
if (other->d_ptr->hasTransform) {
QTransform otherToParent = other->transform();
- otherToParent *= QTransform::fromTranslate(otherPos.x(), otherPos.y());
+ if (!otherPos.isNull())
+ otherToParent *= QTransform::fromTranslate(otherPos.x(), otherPos.y());
return otherToParent.inverted(ok);
} else {
if (ok)
@@ -2678,11 +2696,11 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
QTransform itemToParent = QTransform::fromTranslate(itemPos.x(), itemPos.y());
if (hasTr)
- itemToParent = transform() * itemToParent;
+ itemToParent = itemPos.isNull() ? transform() : transform() * itemToParent;
QTransform otherToParent = QTransform::fromTranslate(otherPos.x(), otherPos.y());
if (otherHasTr)
- otherToParent = other->transform() * otherToParent;
+ otherToParent = otherPos.isNull() ? other->transform() : other->transform() * otherToParent;
return itemToParent * otherToParent.inverted(ok);
}
@@ -2722,7 +2740,8 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
const QGraphicsItemPrivate *pd = p->d_ptr;
if (pd->hasTransform)
x *= p->transform();
- x *= QTransform::fromTranslate(pd->pos.x(), pd->pos.y());
+ if (!pd->pos.isNull())
+ x *= QTransform::fromTranslate(pd->pos.x(), pd->pos.y());
} while ((p = p->d_ptr->parent) && p != root);
if (parentOfOther)
return x.inverted(ok);
@@ -2754,21 +2773,23 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)
return;
// Notify the item that the matrix is changing.
- QVariant variant;
- qVariantSetValue<QMatrix>(variant, newTransform.toAffine());
- newTransform = QTransform(qVariantValue<QMatrix>(itemChange(ItemMatrixChange, variant)));
+ QVariant newTransformVariant(itemChange(ItemMatrixChange,
+ qVariantFromValue<QMatrix>(newTransform.toAffine())));
+ newTransform = QTransform(qVariantValue<QMatrix>(newTransformVariant));
if (oldTransform == newTransform)
return;
// Update and set the new transformation.
- d_ptr->fullUpdateHelper(true);
+ d_ptr->fullUpdateHelper(true, true);
prepareGeometryChange();
d_ptr->hasTransform = !newTransform.isIdentity();
d_ptr->setExtra(QGraphicsItemPrivate::ExtraTransform, newTransform);
d_ptr->invalidateSceneTransformCache();
// Send post-notification.
- itemChange(ItemTransformHasChanged, newTransform);
+ // NB! We have to change the value from QMatrix to QTransform.
+ qVariantSetValue<QTransform>(newTransformVariant, newTransform);
+ itemChange(ItemTransformHasChanged, newTransformVariant);
}
/*!
@@ -2800,21 +2821,21 @@ void QGraphicsItem::setTransform(const QTransform &matrix, bool combine)
return;
// Notify the item that the transformation matrix is changing.
- QVariant variant;
- qVariantSetValue<QTransform>(variant, newTransform);
- newTransform = qVariantValue<QTransform>(itemChange(ItemTransformChange, variant));
+ const QVariant newTransformVariant(itemChange(ItemTransformChange,
+ qVariantFromValue<QTransform>(newTransform)));
+ newTransform = qVariantValue<QTransform>(newTransformVariant);
if (oldTransform == newTransform)
return;
// Update and set the new transformation.
- d_ptr->fullUpdateHelper(true);
+ d_ptr->fullUpdateHelper(true, true);
prepareGeometryChange();
d_ptr->hasTransform = !newTransform.isIdentity();
d_ptr->setExtra(QGraphicsItemPrivate::ExtraTransform, newTransform);
d_ptr->invalidateSceneTransformCache();
// Send post-notification.
- itemChange(ItemTransformHasChanged, newTransform);
+ itemChange(ItemTransformHasChanged, newTransformVariant);
}
/*!
@@ -2962,7 +2983,8 @@ qreal QGraphicsItem::zValue() const
*/
void QGraphicsItem::setZValue(qreal z)
{
- qreal newZ = qreal(itemChange(ItemZValueChange, double(z)).toDouble());
+ const QVariant newZVariant(itemChange(ItemZValueChange, double(z)));
+ qreal newZ = qreal(newZVariant.toDouble());
if (newZ == d_ptr->z)
return;
d_ptr->z = newZ;
@@ -2974,7 +2996,7 @@ void QGraphicsItem::setZValue(qreal z)
d_ptr->scene->d_func()->invalidateSortCache();
}
- itemChange(ItemZValueHasChanged, double(newZ));
+ itemChange(ItemZValueHasChanged, newZVariant);
}
/*!
@@ -2999,7 +3021,9 @@ QRectF QGraphicsItem::childrenBoundingRect() const
QRectF childRect;
foreach (QGraphicsItem *child, children()) {
QPointF childPos = child->pos();
- QTransform matrix = child->transform() * QTransform::fromTranslate(childPos.x(), childPos.y());
+ QTransform matrix = child->transform();
+ if (!childPos.isNull())
+ matrix *= QTransform::fromTranslate(childPos.x(), childPos.y());
childRect |= matrix.mapRect(child->boundingRect() | child->childrenBoundingRect());
}
return childRect;
@@ -3131,57 +3155,79 @@ bool QGraphicsItem::isClipped() const
QPainterPath QGraphicsItem::clipPath() const
{
Q_D(const QGraphicsItem);
- QPainterPath clip;
- if (!isClipped())
- return clip;
+ if (!d->dirtyClipPath)
+ return d->emptyClipPath ? QPainterPath() : d->cachedClipPath;
+
+ if (!isClipped()) {
+ d_ptr->setCachedClipPath(QPainterPath());
+ return d->cachedClipPath;
+ }
+ const QRectF thisBoundingRect(boundingRect());
+ if (thisBoundingRect.isEmpty()) {
+ if (d_ptr->flags & ItemClipsChildrenToShape)
+ d_ptr->setEmptyCachedClipPathRecursively();
+ else
+ d_ptr->setEmptyCachedClipPath();
+ return QPainterPath();
+ }
+
+ QPainterPath clip;
// Start with the item's bounding rect.
- clip.addRect(boundingRect());
+ clip.addRect(thisBoundingRect);
- bool clipAway = false;
if (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
- // Make list of parents up to the farthest ancestor that clips its
- // children to its shape.
- QVarLengthArray<const QGraphicsItem *, 32> clippingAncestors;
- const QGraphicsItem *parent = parentItem();
- const QGraphicsItem *clipOwner = 0;
- do {
+ const QGraphicsItem *parent = this;
+ const QGraphicsItem *lastParent = this;
+
+ // Intersect any in-between clips starting at the top and moving downwards.
+ bool foundValidClipPath = false;
+ while ((parent = parent->d_ptr->parent)) {
if (parent->d_ptr->flags & ItemClipsChildrenToShape) {
- clippingAncestors.append(parent);
- clipOwner = parent;
- }
- } while ((parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) && (parent = parent->parentItem()));
+ // Map clip to the current parent and intersect with its shape/clipPath
+ clip = lastParent->itemTransform(parent).map(clip);
+ if ((foundValidClipPath = !parent->d_ptr->dirtyClipPath && parent->isClipped())) {
+ if (parent->d_ptr->emptyClipPath) {
+ if (d_ptr->flags & ItemClipsChildrenToShape)
+ d_ptr->setEmptyCachedClipPathRecursively();
+ else
+ d_ptr->setEmptyCachedClipPath();
+ return QPainterPath();
+ }
+ clip = clip.intersected(parent->d_ptr->cachedClipPath);
+ if (!(parent->d_ptr->flags & ItemClipsToShape))
+ clip = clip.intersected(parent->shape());
+ } else {
+ clip = clip.intersected(parent->shape());
+ }
- // Start with the topmost clip.
- QPainterPath parentClip = clipOwner->shape();
+ if (clip.isEmpty()) {
+ if (d_ptr->flags & ItemClipsChildrenToShape)
+ d_ptr->setEmptyCachedClipPathRecursively();
+ else
+ d_ptr->setEmptyCachedClipPath();
+ return clip;
+ }
+ lastParent = parent;
+ }
- // Intersect any in-between clips starting at the bottom and moving
- // upwards.
- for (int i = clippingAncestors.size() - 2; i >= 0; --i) {
- const QGraphicsItem *item = clippingAncestors[i];
- // ### what if itemtransform fails
- if (clipOwner)
- parentClip = clipOwner->itemTransform(item).map(parentClip);
- parentClip = parentClip.intersected(item->shape());
- if (parentClip.isEmpty()) {
- clip = parentClip;
- clipAway = true;
+ if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
+ || foundValidClipPath) {
break;
}
- clipOwner = item;
}
- if (!clipAway) {
+ if (lastParent != this) {
+ // Map clip back to the item's transform.
// ### what if itemtransform fails
- clip = clip.intersected(clipOwner->itemTransform(this).map(parentClip));
- if (clip.isEmpty())
- clipAway = true;
+ clip = lastParent->itemTransform(this).map(clip);
}
}
- if (!clipAway && d->flags & ItemClipsToShape)
+ if (d->flags & ItemClipsToShape)
clip = clip.intersected(shape());
+ d_ptr->setCachedClipPath(clip);
return clip;
}
@@ -3270,8 +3316,10 @@ bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelection
return false;
}
- QRectF rectA = _q_adjustedRect(boundingRect());
- QRectF rectB = _q_adjustedRect(path.controlPointRect());
+ QRectF rectA(boundingRect());
+ _q_adjustRect(&rectA);
+ QRectF rectB(path.controlPointRect());
+ _q_adjustRect(&rectB);
if (!rectA.intersects(rectB)) {
// This we can determine efficiently. If the two rects neither
// intersect nor contain eachother, then the two items do not collide.
@@ -3280,12 +3328,11 @@ bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelection
// For further testing, we need this item's shape or bounding rect.
QPainterPath thisShape;
- if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape) {
+ if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape)
thisShape = (isClipped() && !d_ptr->localCollisionHack) ? clipPath() : shape();
- } else {
- thisShape.addPolygon(_q_adjustedRect(boundingRect()));
- thisShape.closeSubpath();
- }
+ else
+ thisShape.addRect(rectA);
+
if (thisShape == QPainterPath()) {
// Empty shape? No collision.
return false;
@@ -3455,7 +3502,8 @@ QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) c
// into the bitmap, converts the result to a QRegion and scales the region
// back to device space with inverse granularity.
qreal granularity = boundingRegionGranularity();
- QRect deviceRect = _q_adjustedRect(itemToDeviceTransform.mapRect(boundingRect()).toRect());
+ QRect deviceRect = itemToDeviceTransform.mapRect(boundingRect()).toRect();
+ _q_adjustRect(&deviceRect);
if (granularity == 0.0)
return QRegion(deviceRect);
@@ -3585,6 +3633,24 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)
/*!
\internal
+ Returns true if we can discard an update request; otherwise false.
+*/
+bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreClipping,
+ bool ignoreVisibleBit,
+ bool ignoreDirtyBit) const
+{
+ // No scene, or if the scene is updating everything, means we have nothing
+ // to do. The only exception is if the scene tracks the growing scene rect.
+ return (!visible && !ignoreVisibleBit)
+ || (dirty && !ignoreDirtyBit)
+ || !scene
+ || (scene->d_func()->updateAll && scene->d_func()->hasSceneRect)
+ || (!ignoreClipping && (childrenClippedToShape() && isClippedAway()))
+ || (childrenCombineOpacity() && isFullyTransparent());
+}
+
+/*!
+ \internal
Asks the scene to mark this item's scene rect as dirty, requesting a
redraw. This does not invalidate any cache.
@@ -3593,31 +3659,16 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)
only case where the item's background should be marked as dirty even when
the item isn't visible.
*/
-void QGraphicsItemPrivate::updateHelper(const QRectF &rect, bool force, bool updateCache)
+void QGraphicsItemPrivate::updateHelper(const QRectF &rect, bool force, bool maybeDirtyClipPath)
{
// No scene, or if the scene is updating everything, means we have nothing
// to do. The only exception is if the scene tracks the growing scene rect.
- QGraphicsItemCache *cache = maybeExtraItemCache();
- if (dirty && (!updateCache || !cache || cache->allExposed))
+ if (discardUpdateRequest(/*ignoreClipping=*/maybeDirtyClipPath, /*ignoreVisibleBit=*/force))
return;
- if (!scene || (scene && scene->d_func()->updateAll && scene->d_func()->hasSceneRect))
- return;
-
- if (updateCache && QGraphicsItem::CacheMode(cacheMode) != QGraphicsItem::NoCache) {
- if (rect.isNull()) {
- cache->allExposed = true;
- cache->exposed.clear();
- } else {
- cache->exposed.append(rect);
- }
- }
-
- if (!dirty && scene && (visible || force)) {
- if (rect.isNull())
- dirty = 1;
- scene->itemUpdated(q_ptr, rect);
- }
+ if (rect.isNull())
+ dirty = 1;
+ scene->itemUpdated(q_ptr, rect);
}
/*!
@@ -3625,21 +3676,25 @@ void QGraphicsItemPrivate::updateHelper(const QRectF &rect, bool force, bool upd
Propagates updates to \a item and all its children.
*/
-void QGraphicsItemPrivate::fullUpdateHelper(bool childrenOnly)
+void QGraphicsItemPrivate::fullUpdateHelper(bool childrenOnly, bool maybeDirtyClipPath)
{
- // No scene, or if the scene is updating everything, means we have nothing
- // to do. The only exception is if the scene tracks the growing scene rect.
- if (!scene || (scene && scene->d_func()->updateAll && scene->d_func()->hasSceneRect))
+ if (discardUpdateRequest(/*ignoreClipping=*/maybeDirtyClipPath,
+ /*ignoreVisibleBit=*/false,
+ /*ignoreDirtyBit=*/true)) {
return;
- if (!childrenOnly && !dirty)
- updateHelper();
- if (children.isEmpty() || dirtyChildren)
- return;
- if (flags & QGraphicsItem::ItemClipsChildrenToShape) {
- // ### mark all children dirty?
+ }
+
+ if (!childrenOnly && !dirty) {
+ // Effectively the same as updateHelper(QRectF(), false, maybeDirtyClipPath).
+ dirty = 1;
+ scene->itemUpdated(q_ptr, QRectF());
+ }
+
+ if (dirtyChildren || childrenClippedToShape()) {
// Unnecessary to update children as well.
return;
}
+
if (ancestorFlags & AncestorClipsChildren) {
Q_Q(QGraphicsItem);
// Check if we can avoid updating all children.
@@ -3662,10 +3717,36 @@ void QGraphicsItemPrivate::fullUpdateHelper(bool childrenOnly)
}
}
foreach (QGraphicsItem *child, children)
- child->d_ptr->fullUpdateHelper();
+ child->d_ptr->fullUpdateHelper(false, maybeDirtyClipPath);
dirtyChildren = 1;
}
+static inline bool allChildrenCombineOpacityHelper(QGraphicsItem *parent)
+{
+ Q_ASSERT(parent);
+ if (parent->flags() & QGraphicsItem::ItemDoesntPropagateOpacityToChildren)
+ return false;
+
+ const QList<QGraphicsItem *> children(parent->childItems());
+ for (int i = 0; i < children.size(); ++i) {
+ if (children.at(i)->flags() & QGraphicsItem::ItemIgnoresParentOpacity)
+ return false;
+ }
+ return true;
+}
+
+void QGraphicsItemPrivate::updateEffectiveOpacity()
+{
+ Q_Q(QGraphicsItem);
+ if (parent) {
+ resolveEffectiveOpacity(parent->effectiveOpacity());
+ parent->d_ptr->allChildrenCombineOpacity = allChildrenCombineOpacityHelper(parent);
+ } else {
+ resolveEffectiveOpacity(1.0);
+ }
+ allChildrenCombineOpacity = allChildrenCombineOpacityHelper(q);
+}
+
/*!
\internal
@@ -3690,7 +3771,14 @@ void QGraphicsItemPrivate::resolveEffectiveOpacity(qreal parentEffectiveOpacity)
}
// Set this item's resolved opacity.
- setExtra(ExtraEffectiveOpacity, myEffectiveOpacity);
+ if (qFuzzyIsNull(myEffectiveOpacity - 1)) {
+ // Opaque, unset effective opacity.
+ hasEffectiveOpacity = 0;
+ unsetExtra(ExtraEffectiveOpacity);
+ } else {
+ hasEffectiveOpacity = 1;
+ setExtra(ExtraEffectiveOpacity, myEffectiveOpacity);
+ }
// Resolve children always.
for (int i = 0; i < children.size(); ++i)
@@ -3781,6 +3869,109 @@ void QGraphicsItemPrivate::removeExtraItemCache()
unsetExtra(ExtraCacheData);
}
+void QGraphicsItemPrivate::setEmptyCachedClipPathRecursively(const QRectF &emptyIfOutsideThisRect)
+{
+ setEmptyCachedClipPath();
+
+ const bool checkRect = !emptyIfOutsideThisRect.isNull()
+ && !(flags & QGraphicsItem::ItemClipsChildrenToShape);
+ for (int i = 0; i < children.size(); ++i) {
+ if (!checkRect) {
+ children.at(i)->d_ptr->setEmptyCachedClipPathRecursively();
+ continue;
+ }
+
+ QGraphicsItem *child = children.at(i);
+ const QRectF rect = child->mapRectFromParent(emptyIfOutsideThisRect);
+ if (rect.intersects(child->boundingRect()))
+ child->d_ptr->invalidateCachedClipPathRecursively(false, rect);
+ else
+ child->d_ptr->setEmptyCachedClipPathRecursively(rect);
+ }
+}
+
+void QGraphicsItemPrivate::invalidateCachedClipPathRecursively(bool childrenOnly, const QRectF &emptyIfOutsideThisRect)
+{
+ if (!childrenOnly)
+ invalidateCachedClipPath();
+
+ const bool checkRect = !emptyIfOutsideThisRect.isNull();
+ for (int i = 0; i < children.size(); ++i) {
+ if (!checkRect) {
+ children.at(i)->d_ptr->invalidateCachedClipPathRecursively(false);
+ continue;
+ }
+
+ QGraphicsItem *child = children.at(i);
+ const QRectF rect = child->mapRectFromParent(emptyIfOutsideThisRect);
+ if (rect.intersects(child->boundingRect()))
+ child->d_ptr->invalidateCachedClipPathRecursively(false, rect);
+ else
+ child->d_ptr->setEmptyCachedClipPathRecursively(rect);
+ }
+}
+
+void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(const QPointF &newPos)
+{
+ Q_ASSERT(inSetPosHelper);
+
+ if (!(ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
+ return; // Not clipped by any ancestor.
+
+ // Find closest clip ancestor and transform.
+ Q_Q(QGraphicsItem);
+ QTransform thisToParentTransform = hasTransform
+ ? q->transform() * QTransform::fromTranslate(newPos.x(), newPos.y())
+ : QTransform::fromTranslate(newPos.x(), newPos.y());
+ QGraphicsItem *clipParent = parent;
+ while (clipParent && !(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)) {
+ if (clipParent->d_ptr->hasTransform)
+ thisToParentTransform *= clipParent->transform();
+ if (!clipParent->d_ptr->pos.isNull()) {
+ thisToParentTransform *= QTransform::fromTranslate(clipParent->d_ptr->pos.x(),
+ clipParent->d_ptr->pos.y());
+ }
+ clipParent = clipParent->d_ptr->parent;
+ }
+
+ // thisToParentTransform is now the same as q->itemTransform(clipParent), except
+ // that the new position (which is not yet set on the item) is taken into account.
+ Q_ASSERT(clipParent);
+ Q_ASSERT(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
+
+ // From here everything is calculated in clip parent's coordinates.
+ const QRectF parentBoundingRect(clipParent->boundingRect());
+ const QRectF thisBoundingRect(thisToParentTransform.mapRect(q->boundingRect()));
+
+ if (!parentBoundingRect.intersects(thisBoundingRect)) {
+ // Item is moved outside the clip parent's bounding rect,
+ // i.e. it is fully clipped and the clip path is empty.
+ if (flags & QGraphicsItem::ItemClipsChildrenToShape)
+ setEmptyCachedClipPathRecursively();
+ else
+ setEmptyCachedClipPathRecursively(thisToParentTransform.inverted().mapRect(parentBoundingRect));
+ return;
+ }
+
+ const QPainterPath parentClip(clipParent->isClipped() ? clipParent->clipPath() : clipParent->shape());
+ if (parentClip.contains(thisBoundingRect))
+ return; // Item is inside the clip parent's shape. No update required.
+
+ const QRectF parentClipRect(parentClip.controlPointRect());
+ if (!parentClipRect.intersects(thisBoundingRect)) {
+ // Item is moved outside the clip parent's shape,
+ // i.e. it is fully clipped and the clip path is empty.
+ if (flags & QGraphicsItem::ItemClipsChildrenToShape)
+ setEmptyCachedClipPathRecursively();
+ else
+ setEmptyCachedClipPathRecursively(thisToParentTransform.inverted().mapRect(parentClipRect));
+ } else {
+ // Item is partially inside the clip parent's shape,
+ // i.e. the cached clip path must be invalidated.
+ invalidateCachedClipPathRecursively(false, thisToParentTransform.inverted().mapRect(parentClipRect));
+ }
+}
+
/*!
\internal
@@ -3811,7 +4002,25 @@ bool QGraphicsItemPrivate::isProxyWidget() const
*/
void QGraphicsItem::update(const QRectF &rect)
{
- d_ptr->updateHelper(rect, /* force = */ false, /* updateCache = */ true);
+ if ((rect.isEmpty() && !rect.isNull()) || d_ptr->discardUpdateRequest())
+ return;
+
+ if (CacheMode(d_ptr->cacheMode) != NoCache) {
+ QGraphicsItemCache *cache = d_ptr->extraItemCache();
+ if (!cache->allExposed) {
+ if (rect.isNull()) {
+ cache->allExposed = true;
+ cache->exposed.clear();
+ } else {
+ cache->exposed.append(rect);
+ }
+ }
+ }
+
+ // Effectively the same as updateHelper(rect);
+ if (rect.isNull())
+ d_ptr->dirty = 1;
+ d_ptr->scene->itemUpdated(this, rect);
}
/*!
@@ -3882,7 +4091,7 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect)
return;
if (d->cacheMode != NoCache) {
QGraphicsItemCache *c;
- bool scrollCache = qFuzzyCompare(dx - int(dx), qreal(0.0)) && qFuzzyCompare(dy - int(dy), qreal(0.0))
+ bool scrollCache = qFuzzyIsNull(dx - int(dx)) && qFuzzyIsNull(dy - int(dy))
&& (c = (QGraphicsItemCache *)qVariantValue<void *>(d_ptr->extra(QGraphicsItemPrivate::ExtraCacheData)))
&& (d->cacheMode == ItemCoordinateCache && !c->fixedSize.isValid());
if (scrollCache) {
@@ -4076,7 +4285,9 @@ QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPointF &point
*/
QPointF QGraphicsItem::mapToParent(const QPointF &point) const
{
- return d_ptr->pos + (d_ptr->hasTransform ? transform().map(point) : point);
+ if (!d_ptr->hasTransform)
+ return point + d_ptr->pos;
+ return transform().map(point) + d_ptr->pos;
}
/*!
@@ -4142,8 +4353,8 @@ QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QRectF &rect
QPolygonF QGraphicsItem::mapToParent(const QRectF &rect) const
{
if (!d_ptr->hasTransform)
- return QPolygonF(rect.translated(d_ptr->pos));
- return transform().map(rect.translated(d_ptr->pos));
+ return rect.translated(d_ptr->pos);
+ return transform().map(rect).translated(d_ptr->pos);
}
/*!
@@ -4210,8 +4421,8 @@ QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, const QRectF &rec
*/
QRectF QGraphicsItem::mapRectToParent(const QRectF &rect) const
{
- QRectF r = rect.translated(d_ptr->pos.x(), d_ptr->pos.y());
- return !d_ptr->hasTransform ? r : transform().mapRect(r);
+ QRectF r = !d_ptr->hasTransform ? rect : transform().mapRect(rect);
+ return r.translated(d_ptr->pos);
}
/*!
@@ -4342,9 +4553,9 @@ QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPolygonF &p
*/
QPolygonF QGraphicsItem::mapToParent(const QPolygonF &polygon) const
{
- QPolygonF p = polygon;
- p.translate(d_ptr->pos);
- return d_ptr->hasTransform ? transform().map(p) : p;
+ if (!d_ptr->hasTransform)
+ return polygon.translated(d_ptr->pos);
+ return transform().map(polygon).translated(d_ptr->pos);
}
/*!
@@ -4386,7 +4597,9 @@ QPainterPath QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPainterP
*/
QPainterPath QGraphicsItem::mapToParent(const QPainterPath &path) const
{
- return d_ptr->parent ? itemTransform(d_ptr->parent).map(path) : mapToScene(path);
+ if (!d_ptr->hasTransform)
+ return path.translated(d_ptr->pos);
+ return transform().map(path).translated(d_ptr->pos);
}
/*!
@@ -4601,9 +4814,9 @@ QPainterPath QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPainte
*/
QPainterPath QGraphicsItem::mapFromParent(const QPainterPath &path) const
{
- if (d_ptr->parent)
- return d_ptr->parent->itemTransform(this).map(path);
- return mapFromScene(path);
+ QPainterPath p(path);
+ p.translate(-d_ptr->pos);
+ return d_ptr->hasTransform ? transform().inverted().map(p) : p;
}
/*!
@@ -5616,11 +5829,18 @@ void QGraphicsItem::removeFromIndex()
void QGraphicsItem::prepareGeometryChange()
{
if (d_ptr->scene) {
- d_ptr->updateHelper();
-
+ d_ptr->updateHelper(QRectF(), false, /*maybeDirtyClipPath=*/!d_ptr->inSetPosHelper);
QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func();
scenePrivate->removeFromIndex(this);
}
+
+ if (d_ptr->inSetPosHelper)
+ return;
+
+ if (d_ptr->flags & ItemClipsChildrenToShape)
+ d_ptr->invalidateCachedClipPathRecursively();
+ else
+ d_ptr->invalidateCachedClipPath();
}
/*!
@@ -5635,7 +5855,7 @@ static void qt_graphicsItem_highlightSelected(
QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option)
{
const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1));
- if (qFuzzyCompare(qMax(murect.width(), murect.height()) + 1, 1))
+ if (qFuzzyIsNull(qMax(murect.width(), murect.height())))
return;
const QRectF mbrect = painter->transform().mapRect(item->boundingRect());
@@ -8204,6 +8424,8 @@ void QGraphicsTextItem::setTabChangesFocus(bool b)
Returns true if the \gui Tab key will cause the widget to change focus;
otherwise, false is returned.
+ By default, this behavior is disabled, and this function will return false.
+
\sa setTabChangesFocus()
*/
bool QGraphicsTextItem::tabChangesFocus() const
@@ -8395,6 +8617,7 @@ void QGraphicsSimpleTextItem::setText(const QString &text)
return;
d->text = text;
d->updateBoundingRect();
+ update();
}
/*!
@@ -8656,13 +8879,17 @@ void QGraphicsItemGroup::addToGroup(QGraphicsItem *item)
QTransform oldSceneMatrix = item->sceneTransform();
item->setPos(mapFromItem(item, 0, 0));
item->setParentItem(this);
- item->setTransform(oldSceneMatrix
- * sceneTransform().inverted()
- * QTransform::fromTranslate(-item->x(), -item->y()));
+ QTransform newItemTransform(oldSceneMatrix);
+ newItemTransform *= sceneTransform().inverted();
+ if (!item->pos().isNull())
+ newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
+ item->setTransform(newItemTransform);
item->d_func()->setIsMemberOfGroup(true);
prepareGeometryChange();
- d->itemsBoundingRect |= (item->transform() * QTransform::fromTranslate(item->x(), item->y()))
- .mapRect(item->boundingRect() | item->childrenBoundingRect());
+ QTransform itemTransform(item->transform());
+ if (!item->pos().isNull())
+ itemTransform *= QTransform::fromTranslate(item->x(), item->y());
+ d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect());
update();
}
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index af0b077..078c543 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -134,10 +134,15 @@ public:
hasBoundingRegionGranularity(0),
flags(0),
hasOpacity(0),
+ hasEffectiveOpacity(0),
isWidget(0),
dirty(0),
dirtyChildren(0),
localCollisionHack(0),
+ dirtyClipPath(1),
+ emptyClipPath(0),
+ inSetPosHelper(0),
+ allChildrenCombineOpacity(1),
globalStackingOrder(-1),
sceneTransformIndex(-1),
q_ptr(0)
@@ -158,11 +163,15 @@ public:
virtual QVariant inputMethodQueryHelper(Qt::InputMethodQuery query) const;
static bool movableAncestorIsSelected(const QGraphicsItem *item);
- void setPosHelper(const QPointF &pos, bool update);
+ void setPosHelper(const QPointF &pos);
void setVisibleHelper(bool newVisible, bool explicitly, bool update = true);
void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true);
- void updateHelper(const QRectF &rect = QRectF(), bool force = false, bool updateCache = false);
- void fullUpdateHelper(bool childrenOnly = false);
+ bool discardUpdateRequest(bool ignoreClipping = false,
+ bool ignoreVisibleBit = false,
+ bool ignoreDirtyBit = false) const;
+ void updateHelper(const QRectF &rect = QRectF(), bool force = false, bool maybeDirtyClipPath = false);
+ void fullUpdateHelper(bool childrenOnly = false, bool maybeDirtyClipPath = false);
+ void updateEffectiveOpacity();
void resolveEffectiveOpacity(qreal effectiveParentOpacity);
void resolveDepth(int parentDepth);
void invalidateSceneTransformCache();
@@ -238,6 +247,47 @@ public:
QGraphicsItemCache *extraItemCache() const;
void removeExtraItemCache();
+ inline void setCachedClipPath(const QPainterPath &path)
+ {
+ cachedClipPath = path;
+ dirtyClipPath = 0;
+ emptyClipPath = 0;
+ }
+
+ inline void setEmptyCachedClipPath()
+ {
+ emptyClipPath = 1;
+ dirtyClipPath = 0;
+ }
+
+ void setEmptyCachedClipPathRecursively(const QRectF &emptyIfOutsideThisRect = QRectF());
+
+ inline void invalidateCachedClipPath()
+ { /*static int count = 0 ;qWarning("%i", ++count);*/ dirtyClipPath = 1; emptyClipPath = 0; }
+
+ void invalidateCachedClipPathRecursively(bool childrenOnly = false, const QRectF &emptyIfOutsideThisRect = QRectF());
+ void updateCachedClipPathFromSetPosHelper(const QPointF &newPos);
+
+ inline bool isFullyTransparent() const
+ { return hasEffectiveOpacity && qFuzzyIsNull(q_func()->effectiveOpacity()); }
+
+ inline bool childrenCombineOpacity() const
+ { return allChildrenCombineOpacity || children.isEmpty(); }
+
+ inline bool isClippedAway() const
+ { return !dirtyClipPath && q_func()->isClipped() && (emptyClipPath || cachedClipPath.isEmpty()); }
+
+ inline bool childrenClippedToShape() const
+ { return (flags & QGraphicsItem::ItemClipsChildrenToShape) || children.isEmpty(); }
+
+ inline bool isInvisible() const
+ {
+ return !visible
+ || (childrenClippedToShape() && isClippedAway())
+ || (childrenCombineOpacity() && isFullyTransparent());
+ }
+
+ QPainterPath cachedClipPath;
QPointF pos;
qreal z;
QGraphicsScene *scene;
@@ -268,10 +318,15 @@ public:
// New 32 bytes
quint32 hasOpacity : 1;
+ quint32 hasEffectiveOpacity : 1;
quint32 isWidget : 1;
quint32 dirty : 1;
quint32 dirtyChildren : 1;
quint32 localCollisionHack : 1;
+ quint32 dirtyClipPath : 1;
+ quint32 emptyClipPath : 1;
+ quint32 inSetPosHelper : 1;
+ quint32 allChildrenCombineOpacity : 1;
// Optional stacking order
int globalStackingOrder;
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp
index 1d2721b..e660879 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp
@@ -177,6 +177,10 @@ QT_BEGIN_NAMESPACE
while the widget is embedded. In this state, the widget may differ slightly
in behavior from when it is not embedded.
+ \warning This class is provided for convenience when bridging
+ QWidgets and QGraphicsItems, it should not be used for
+ high-performance scenarios.
+
\sa QGraphicsScene::addWidget(), QGraphicsWidget
*/
@@ -1033,7 +1037,7 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
if (receiver != d->dragDropWidget) {
// Try to enter before we leave
QDragEnterEvent dragEnter(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
- dragEnter.setDropAction(event->proposedAction());
+ dragEnter.setDropAction(event->proposedAction());
QApplication::sendEvent(receiver, &dragEnter);
event->setAccepted(dragEnter.isAccepted());
event->setDropAction(dragEnter.dropAction());
@@ -1431,7 +1435,7 @@ int QGraphicsProxyWidget::type() const
Creates a proxy widget for the given \a child of the widget
contained in this proxy.
-
+
This function makes it possible to aquire proxies for
non top-level widgets. For instance, you can embed a dialog,
and then transform only one of its widgets.
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 553967c..d9e0eec 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -292,15 +292,21 @@ static inline bool QRectF_intersects(const QRectF &s, const QRectF &r)
// QRectF::intersects() returns false always if either the source or target
// rectangle's width or height are 0. This works around that problem.
-static QRectF _q_adjustedRect(const QRectF &rect)
+static inline void _q_adjustRect(QRectF *rect)
{
- static const qreal p = (qreal)0.00001;
- QRectF r = rect;
- if (!r.width())
- r.adjust(-p, 0, p, 0);
- if (!r.height())
- r.adjust(0, -p, 0, p);
- return r;
+ Q_ASSERT(rect);
+ if (!rect->width())
+ rect->adjust(-0.00001, 0, 0.00001, 0);
+ if (!rect->height())
+ rect->adjust(0, -0.00001, 0, 0.00001);
+}
+
+static inline QRectF adjustedItemBoundingRect(const QGraphicsItem *item)
+{
+ Q_ASSERT(item);
+ QRectF boundingRect(item->boundingRect());
+ _q_adjustRect(&boundingRect);
+ return boundingRect;
}
static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraphicsSceneMouseEvent *mouseEvent)
@@ -345,6 +351,8 @@ QGraphicsScenePrivate::QGraphicsScenePrivate()
dragDropItem(0),
enterWidget(0),
lastDropAction(Qt::IgnoreAction),
+ allItemsIgnoreHoverEvents(true),
+ allItemsUseDefaultCursor(true),
painterStateProtection(true),
sortCacheEnabled(false),
updatingSortCache(false),
@@ -656,10 +664,11 @@ void QGraphicsScenePrivate::_q_updateLater()
*/
void QGraphicsScenePrivate::_q_polishItems()
{
+ const QVariant booleanTrueVariant(true);
foreach (QGraphicsItem *item, unpolishedItems) {
if (!item->d_ptr->explicitlyHidden) {
- item->itemChange(QGraphicsItem::ItemVisibleChange, true);
- item->itemChange(QGraphicsItem::ItemVisibleHasChanged, true);
+ item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant);
+ item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant);
}
if (item->isWidget()) {
QEvent event(QEvent::Polish);
@@ -757,6 +766,15 @@ void QGraphicsScenePrivate::_q_removeItemLater(QGraphicsItem *item)
unpolishedItems.removeAll(item);
dirtyItems.removeAll(item);
+ //We remove all references of item from the sceneEventFilter arrays
+ QMultiMap<QGraphicsItem*, QGraphicsItem*>::iterator iterator = sceneEventFilters.begin();
+ while (iterator != sceneEventFilters.end()) {
+ if (iterator.value() == item || iterator.key() == item)
+ iterator = sceneEventFilters.erase(iterator);
+ else
+ ++iterator;
+ }
+
// Remove from scene transform cache
int transformIndex = item->d_func()->sceneTransformIndex;
if (transformIndex != -1) {
@@ -884,11 +902,18 @@ void QGraphicsScenePrivate::grabMouse(QGraphicsItem *item, bool implicit)
{
// Append to list of mouse grabber items, and send a mouse grab event.
if (mouseGrabberItems.contains(item)) {
- if (mouseGrabberItems.last() == item)
- qWarning("QGraphicsItem::grabMouse: already a mouse grabber");
- else
+ if (mouseGrabberItems.last() == item) {
+ Q_ASSERT(!implicit);
+ if (!lastMouseGrabberItemHasImplicitMouseGrab) {
+ qWarning("QGraphicsItem::grabMouse: already a mouse grabber");
+ } else {
+ // Upgrade to an explicit mouse grab
+ lastMouseGrabberItemHasImplicitMouseGrab = false;
+ }
+ } else {
qWarning("QGraphicsItem::grabMouse: already blocked by mouse grabber: %p",
mouseGrabberItems.last());
+ }
return;
}
@@ -1040,6 +1065,12 @@ void QGraphicsScenePrivate::clearKeyboardGrabber()
ungrabKeyboard(keyboardGrabberItems.first());
}
+void QGraphicsScenePrivate::enableMouseTrackingOnViews()
+{
+ foreach (QGraphicsView *view, views)
+ view->viewport()->setMouseTracking(true);
+}
+
/*!
Returns all items for the screen position in \a event.
*/
@@ -1371,6 +1402,48 @@ QGraphicsWidget *QGraphicsScenePrivate::windowForItem(const QGraphicsItem *item)
return 0;
}
+
+QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPointF &pos) const
+{
+ QList<QGraphicsItem *> items;
+
+ // The index returns a rough estimate of what items are inside the rect.
+ // Refine it by iterating through all returned items.
+ QRectF adjustedRect = QRectF(pos, QSize(1,1));
+ foreach (QGraphicsItem *item, estimateItemsInRect(adjustedRect)) {
+ // Find the item's scene transform in a clever way.
+ QTransform x = item->sceneTransform();
+ bool keep = false;
+
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ // Rect intersects/contains item's shape
+ if (QRectF_intersects(adjustedRect, x.mapRect(br))) {
+ bool ok;
+ QTransform xinv = x.inverted(&ok);
+ if (ok) {
+ if (item->contains(xinv.map(pos))) {
+ items << item;
+ keep = true;
+ }
+ }
+ }
+
+ if (keep && (item->flags() & QGraphicsItem::ItemClipsChildrenToShape)) {
+ // Recurse into children that clip children.
+ bool ok;
+ QTransform xinv = x.inverted(&ok);
+ if (ok)
+ childItems_helper(&items, item, xinv.map(pos));
+ }
+ }
+
+ sortItems(&items, Qt::AscendingOrder, sortCacheEnabled);
+ return items;
+}
+
QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QRectF &rect,
Qt::ItemSelectionMode mode,
Qt::SortOrder order) const
@@ -1381,7 +1454,8 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QRectF &rect,
// The index returns a rough estimate of what items are inside the rect.
// Refine it by iterating through all returned items.
- QRectF adjustedRect = _q_adjustedRect(rect);
+ QRectF adjustedRect(rect);
+ _q_adjustRect(&adjustedRect);
foreach (QGraphicsItem *item, estimateItemsInRect(adjustedRect)) {
// Find the item's scene transform in a clever way.
QTransform x = item->sceneTransform();
@@ -1390,7 +1464,7 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QRectF &rect,
// ### _q_adjustedRect is only needed because QRectF::intersects,
// QRectF::contains and QTransform::map() and friends don't work with
// flat rectangles.
- QRectF br = _q_adjustedRect(item->boundingRect());
+ const QRectF br(adjustedItemBoundingRect(item));
if (mode >= Qt::ContainsItemBoundingRect) {
// Rect intersects/contains item's bounding rect
QRectF mbr = x.mapRect(br);
@@ -1405,7 +1479,7 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QRectF &rect,
bool ok;
QTransform xinv = x.inverted(&ok);
if (ok) {
- if (path == QPainterPath())
+ if (path.isEmpty())
path.addRect(rect);
if (itemCollidesWithPath(item, xinv.map(path), mode)) {
items << item;
@@ -1442,7 +1516,8 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPolygonF &poly
{
QList<QGraphicsItem *> items;
- QRectF polyRect = _q_adjustedRect(polygon.boundingRect());
+ QRectF polyRect(polygon.boundingRect());
+ _q_adjustRect(&polyRect);
QPainterPath path;
// The index returns a rough estimate of what items are inside the rect.
@@ -1455,7 +1530,7 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPolygonF &poly
// ### _q_adjustedRect is only needed because QRectF::intersects,
// QRectF::contains and QTransform::map() and friends don't work with
// flat rectangles.
- QRectF br = _q_adjustedRect(item->boundingRect());
+ const QRectF br(adjustedItemBoundingRect(item));
if (mode >= Qt::ContainsItemBoundingRect) {
// Polygon contains/intersects item's bounding rect
if (path == QPainterPath())
@@ -1500,21 +1575,47 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPainterPath &p
Qt::SortOrder order) const
{
QList<QGraphicsItem *> items;
+ QRectF pathRect(path.controlPointRect());
+ _q_adjustRect(&pathRect);
+
// The index returns a rough estimate of what items are inside the rect.
// Refine it by iterating through all returned items.
- foreach (QGraphicsItem *item, estimateItemsInRect(_q_adjustedRect(path.controlPointRect()))) {
+ foreach (QGraphicsItem *item, estimateItemsInRect(pathRect)) {
// Find the item's scene transform in a clever way.
QTransform x = item->sceneTransform();
- bool ok;
- QTransform xinv = x.inverted(&ok);
- if (ok) {
- QPainterPath mappedPath = xinv.map(path);
- if (itemCollidesWithPath(item, mappedPath, mode)) {
+ bool keep = false;
+
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ if (mode >= Qt::ContainsItemBoundingRect) {
+ // Path contains/intersects item's bounding rect
+ if ((mode == Qt::IntersectsItemBoundingRect && path.intersects(x.mapRect(br)))
+ || (mode == Qt::ContainsItemBoundingRect && path.contains(x.mapRect(br)))) {
items << item;
- if (item->flags() & QGraphicsItem::ItemClipsChildrenToShape)
- childItems_helper(&items, item, mappedPath, mode);
+ keep = true;
+ }
+ } else {
+ // Path contains/intersects item's shape
+ if (QRectF_intersects(pathRect, x.mapRect(br))) {
+ bool ok;
+ QTransform xinv = x.inverted(&ok);
+ if (ok) {
+ if (itemCollidesWithPath(item, xinv.map(path), mode)) {
+ items << item;
+ keep = true;
+ }
+ }
}
}
+
+ if (keep && (item->flags() & QGraphicsItem::ItemClipsChildrenToShape)) {
+ bool ok;
+ QTransform xinv = x.inverted(&ok);
+ if (ok)
+ childItems_helper(&items, item, xinv.map(path), mode);
+ }
}
if (order != Qt::SortOrder(-1))
@@ -1524,13 +1625,13 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPainterPath &p
void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
const QGraphicsItem *parent,
- const QRectF &rect,
- Qt::ItemSelectionMode mode) const
+ const QPointF &pos) const
{
- QPainterPath path;
bool parentClip = (parent->flags() & QGraphicsItem::ItemClipsChildrenToShape);
- QRectF r = !parentClip ? _q_adjustedRect(rect) : _q_adjustedRect(rect).intersected(_q_adjustedRect(parent->boundingRect()));
- if (r.isEmpty())
+ if (parentClip && parent->d_ptr->isClippedAway())
+ return;
+ // ### is this needed?
+ if (parentClip && !parent->boundingRect().contains(pos))
return;
QList<QGraphicsItem *> &children = parent->d_ptr->children;
@@ -1540,31 +1641,73 @@ void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
continue;
// Skip invisible items and all their children.
- if (!item->d_ptr->visible || qFuzzyCompare(item->effectiveOpacity(), qreal(0.0)))
+ if (item->d_ptr->isInvisible())
continue;
- // ### _q_adjustedRect is only needed because QRectF::intersects,
- // QRectF::contains and QTransform::map() and friends don't work with
- // flat rectangles.
- QRectF br = _q_adjustedRect(item->boundingRect());
- QRectF mbr = item->mapRectToParent(br);
bool keep = false;
- if (mode >= Qt::ContainsItemBoundingRect) {
- // Rect intersects/contains item's bounding rect
- if ((mode == Qt::IntersectsItemBoundingRect && QRectF_intersects(rect, mbr))
- || (mode == Qt::ContainsItemBoundingRect && rect != mbr && rect.contains(br))) {
+ if (!item->d_ptr->isClippedAway()) {
+ if (item->contains(item->mapFromParent(pos))) {
items->append(item);
keep = true;
}
- } else {
- // Rect intersects/contains item's shape
- if (QRectF_intersects(rect, mbr)) {
- if (path == QPainterPath())
- path.addRect(rect);
- if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ }
+
+ if ((keep || !(item->flags() & QGraphicsItem::ItemClipsChildrenToShape)) && !item->d_ptr->children.isEmpty())
+ // Recurse into children.
+ childItems_helper(items, item, item->mapFromParent(pos));
+ }
+}
+
+
+void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
+ const QGraphicsItem *parent,
+ const QRectF &rect,
+ Qt::ItemSelectionMode mode) const
+{
+ bool parentClip = (parent->flags() & QGraphicsItem::ItemClipsChildrenToShape);
+ if (parentClip && parent->d_ptr->isClippedAway())
+ return;
+ QRectF adjustedRect(rect);
+ _q_adjustRect(&adjustedRect);
+ QRectF r = !parentClip ? adjustedRect : adjustedRect.intersected(adjustedItemBoundingRect(parent));
+ if (r.isEmpty())
+ return;
+
+ QPainterPath path;
+ QList<QGraphicsItem *> &children = parent->d_ptr->children;
+ for (int i = 0; i < children.size(); ++i) {
+ QGraphicsItem *item = children.at(i);
+ if (item->d_ptr->hasTransform && !item->transform().isInvertible())
+ continue;
+
+ // Skip invisible items and all their children.
+ if (item->d_ptr->isInvisible())
+ continue;
+
+ bool keep = false;
+ if (!item->d_ptr->isClippedAway()) {
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ QRectF mbr = item->mapRectToParent(br);
+ if (mode >= Qt::ContainsItemBoundingRect) {
+ // Rect intersects/contains item's bounding rect
+ if ((mode == Qt::IntersectsItemBoundingRect && QRectF_intersects(rect, mbr))
+ || (mode == Qt::ContainsItemBoundingRect && rect != mbr && rect.contains(br))) {
items->append(item);
keep = true;
}
+ } else {
+ // Rect intersects/contains item's shape
+ if (QRectF_intersects(rect, mbr)) {
+ if (path == QPainterPath())
+ path.addRect(rect);
+ if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ items->append(item);
+ keep = true;
+ }
+ }
}
}
@@ -1581,18 +1724,22 @@ void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
}
}
+
void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
const QGraphicsItem *parent,
const QPolygonF &polygon,
Qt::ItemSelectionMode mode) const
{
- QPainterPath path;
bool parentClip = (parent->flags() & QGraphicsItem::ItemClipsChildrenToShape);
- QRectF polyRect = _q_adjustedRect(polygon.boundingRect());
- QRectF r = !parentClip ? polyRect : polyRect.intersected(_q_adjustedRect(parent->boundingRect()));
+ if (parentClip && parent->d_ptr->isClippedAway())
+ return;
+ QRectF polyRect(polygon.boundingRect());
+ _q_adjustRect(&polyRect);
+ QRectF r = !parentClip ? polyRect : polyRect.intersected(adjustedItemBoundingRect(parent));
if (r.isEmpty())
return;
+ QPainterPath path;
QList<QGraphicsItem *> &children = parent->d_ptr->children;
for (int i = 0; i < children.size(); ++i) {
QGraphicsItem *item = children.at(i);
@@ -1600,32 +1747,34 @@ void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
continue;
// Skip invisible items.
- if (!item->d_ptr->visible || qFuzzyCompare(item->effectiveOpacity() + 1, qreal(1.0)))
+ if (item->d_ptr->isInvisible())
continue;
- // ### _q_adjustedRect is only needed because QRectF::intersects,
- // QRectF::contains and QTransform::map() and friends don't work with
- // flat rectangles.
- QRectF br = _q_adjustedRect(item->boundingRect());
bool keep = false;
- if (mode >= Qt::ContainsItemBoundingRect) {
- // Polygon contains/intersects item's bounding rect
- if (path == QPainterPath())
- path.addPolygon(polygon);
- if ((mode == Qt::IntersectsItemBoundingRect && path.intersects(item->mapRectToParent(br)))
- || (mode == Qt::ContainsItemBoundingRect && path.contains(item->mapRectToParent(br)))) {
- items->append(item);
- keep = true;
- }
- } else {
- // Polygon contains/intersects item's shape
- if (QRectF_intersects(polyRect, item->mapRectToParent(br))) {
+ if (!item->d_ptr->isClippedAway()) {
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ if (mode >= Qt::ContainsItemBoundingRect) {
+ // Polygon contains/intersects item's bounding rect
if (path == QPainterPath())
path.addPolygon(polygon);
- if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ if ((mode == Qt::IntersectsItemBoundingRect && path.intersects(item->mapRectToParent(br)))
+ || (mode == Qt::ContainsItemBoundingRect && path.contains(item->mapRectToParent(br)))) {
items->append(item);
keep = true;
}
+ } else {
+ // Polygon contains/intersects item's shape
+ if (QRectF_intersects(polyRect, item->mapRectToParent(br))) {
+ if (path == QPainterPath())
+ path.addPolygon(polygon);
+ if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ items->append(item);
+ keep = true;
+ }
+ }
}
}
@@ -1642,30 +1791,52 @@ void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
Qt::ItemSelectionMode mode) const
{
bool parentClip = (parent->flags() & QGraphicsItem::ItemClipsChildrenToShape);
- QPainterPath intersectedPath = !parentClip ? path : path.intersected(parent->shape());
- if (intersectedPath.isEmpty())
+ if (parentClip && parent->d_ptr->isClippedAway())
+ return;
+ QRectF pathRect(path.boundingRect());
+ _q_adjustRect(&pathRect);
+ QRectF r = !parentClip ? pathRect : pathRect.intersected(adjustedItemBoundingRect(parent));
+ if (r.isEmpty())
return;
QList<QGraphicsItem *> &children = parent->d_ptr->children;
for (int i = 0; i < children.size(); ++i) {
QGraphicsItem *item = children.at(i);
+ if (item->d_ptr->hasTransform && !item->transform().isInvertible())
+ continue;
// Skip invisible items.
- if (!item->d_ptr->visible || qFuzzyCompare(item->effectiveOpacity(), qreal(0.0)))
+ if (item->d_ptr->isInvisible())
continue;
- QTransform x = item->sceneTransform();
-
- bool ok;
- QTransform xinv = x.inverted(&ok);
- if (ok) {
- QPainterPath mappedPath = xinv.map(path);
- if (itemCollidesWithPath(item, mappedPath, mode)) {
- items->append(item);
- if (!item->d_ptr->children.isEmpty())
- childItems_helper(items, item, mappedPath, mode);
+ bool keep = false;
+ if (!item->d_ptr->isClippedAway()) {
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ if (mode >= Qt::ContainsItemBoundingRect) {
+ // Polygon contains/intersects item's bounding rect
+ if ((mode == Qt::IntersectsItemBoundingRect && path.intersects(item->mapRectToParent(br)))
+ || (mode == Qt::ContainsItemBoundingRect && path.contains(item->mapRectToParent(br)))) {
+ items->append(item);
+ keep = true;
+ }
+ } else {
+ // Path contains/intersects item's shape
+ if (QRectF_intersects(pathRect, item->mapRectToParent(br))) {
+ if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ items->append(item);
+ keep = true;
+ }
+ }
}
}
+
+ if ((keep || !(item->flags() & QGraphicsItem::ItemClipsChildrenToShape)) && !item->d_ptr->children.isEmpty()) {
+ // Recurse into children that clip children.
+ childItems_helper(items, item, item->mapFromParent(path), mode);
+ }
}
}
@@ -2339,17 +2510,8 @@ QList<QGraphicsItem *> QGraphicsScene::items() const
*/
QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos) const
{
- QList<QGraphicsItem *> itemsAtPoint;
-
- // Find all items within a 1x1 rect area starting at pos. This can be
- // inefficient for scenes that use small coordinates (like unity
- // coordinates), or for detailed graphs. ### The index should support
- // fetching items at a pos to avoid this limitation.
- foreach (QGraphicsItem *item, items(QRectF(pos, QSizeF(1, 1)), Qt::IntersectsItemBoundingRect)) {
- if (item->contains(item->mapFromScene(pos)))
- itemsAtPoint << item;
- }
- return itemsAtPoint;
+ Q_D(const QGraphicsScene);
+ return d->items_helper(pos);
}
@@ -2625,6 +2787,8 @@ void QGraphicsScene::clear()
d->lastItemCount = 0;
d->bspTree.clear();
d->largestUntransformableItem = QRectF();
+ d->allItemsIgnoreHoverEvents = true;
+ d->allItemsUseDefaultCursor = true;
}
/*!
@@ -2734,8 +2898,9 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
// Notify the item that its scene is changing, and allow the item to
// react.
- QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(item->itemChange(QGraphicsItem::ItemSceneChange,
- qVariantFromValue<QGraphicsScene *>(this)));
+ const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
+ qVariantFromValue<QGraphicsScene *>(this)));
+ QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(newSceneVariant);
if (targetScene != this) {
if (targetScene && item->scene() != targetScene)
targetScene->addItem(item);
@@ -2788,6 +2953,17 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
++d->selectionChanging;
int oldSelectedItemSize = d->selectedItems.size();
+ // Enable mouse tracking if the item accepts hover events or has a cursor set.
+ if (d->allItemsIgnoreHoverEvents && d->itemAcceptsHoverEvents_helper(item)) {
+ d->allItemsIgnoreHoverEvents = false;
+ d->enableMouseTrackingOnViews();
+ }
+ if (d->allItemsUseDefaultCursor && item->hasCursor()) {
+ d->allItemsUseDefaultCursor = false;
+ if (d->allItemsIgnoreHoverEvents) // already enabled otherwise
+ d->enableMouseTrackingOnViews();
+ }
+
// Update selection lists
if (item->isSelected())
d->selectedItems << item;
@@ -2833,7 +3009,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
emit selectionChanged();
// Deliver post-change notification
- item->itemChange(QGraphicsItem::ItemSceneHasChanged, qVariantFromValue<QGraphicsScene *>(this));
+ item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
}
/*!
@@ -3097,8 +3273,9 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
// Notify the item that it's scene is changing to 0, allowing the item to
// react.
- QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(item->itemChange(QGraphicsItem::ItemSceneChange,
- qVariantFromValue<QGraphicsScene *>(0)));
+ const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
+ qVariantFromValue<QGraphicsScene *>(0)));
+ QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(newSceneVariant);
if (targetScene != 0 && targetScene != this) {
targetScene->addItem(item);
return;
@@ -3171,6 +3348,16 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
d->unpolishedItems.removeAll(item);
d->dirtyItems.removeAll(item);
+ //We remove all references of item from the sceneEventFilter arrays
+ QMultiMap<QGraphicsItem*, QGraphicsItem*>::iterator iterator = d->sceneEventFilters.begin();
+ while (iterator != d->sceneEventFilters.end()) {
+ if (iterator.value() == item || iterator.key() == item)
+ iterator = d->sceneEventFilters.erase(iterator);
+ else
+ ++iterator;
+ }
+
+
//Ensure dirty flag have the correct default value so the next time it will be added it will receive updates
item->d_func()->dirty = 0;
item->d_func()->dirtyChildren = 0;
@@ -3198,7 +3385,7 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
emit selectionChanged();
// Deliver post-change notification
- item->itemChange(QGraphicsItem::ItemSceneHasChanged, qVariantFromValue<QGraphicsScene *>(0));
+ item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
}
/*!
@@ -3472,7 +3659,7 @@ QVariant QGraphicsScene::inputMethodQuery(Qt::InputMethodQuery query) const
void QGraphicsScene::update(const QRectF &rect)
{
Q_D(QGraphicsScene);
- if (d->updateAll)
+ if (d->updateAll || (rect.isEmpty() && !rect.isNull()))
return;
// Check if anyone's connected; if not, we can send updates directly to
@@ -4079,6 +4266,9 @@ bool QGraphicsScenePrivate::itemAcceptsHoverEvents_helper(const QGraphicsItem *i
*/
bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEvent)
{
+ if (allItemsIgnoreHoverEvents)
+ return false;
+
// Find the first item that accepts hover events, reusing earlier
// calculated data is possible.
if (cachedItemsUnderMouse.isEmpty()) {
@@ -4478,7 +4668,7 @@ static void _q_paintItem(QGraphicsItem *item, QPainter *painter,
? proxy->widget()->windowOpacity() : 1.0;
const qreal oldPainterOpacity = painter->opacity();
- if (qFuzzyCompare(windowOpacity + 1, qreal(1.0)))
+ if (qFuzzyIsNull(windowOpacity))
return;
// Set new painter opacity.
if (windowOpacity < 1.0)
@@ -4581,7 +4771,9 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
// Item's (local) bounding rect
QRectF brect = item->boundingRect();
- if (_q_adjustedRect(brect).isEmpty())
+ QRectF adjustedBrect(brect);
+ _q_adjustRect(&adjustedBrect);
+ if (adjustedBrect.isEmpty())
return;
// Fetch the off-screen transparent buffer and exposed area info.
@@ -4612,16 +4804,17 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
QSize pixmapSize;
bool fixedCacheSize = false;
+ QRectF brectAligned = brect.toAlignedRect();
if ((fixedCacheSize = itemCache->fixedSize.isValid())) {
pixmapSize = itemCache->fixedSize;
} else {
- pixmapSize = brect.toAlignedRect().size();
+ pixmapSize = brectAligned.size().toSize();
}
// Create or recreate the pixmap.
int adjust = itemCache->fixedSize.isValid() ? 0 : 2;
QSize adjustSize(adjust*2, adjust*2);
- QRectF br = brect.adjusted(-adjust, -adjust, adjust, adjust);
+ QRectF br = brectAligned.adjusted(-adjust, -adjust, adjust, adjust);
if (pix.isNull() || (!fixedCacheSize && (pixmapSize + adjustSize) != pix.size())) {
pix = QPixmap(pixmapSize + adjustSize);
itemCache->exposed.clear();
@@ -4631,9 +4824,11 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
// Redraw any newly exposed areas.
if (itemCache->allExposed || !itemCache->exposed.isEmpty()) {
// Fit the item's bounding rect into the pixmap's coordinates.
- const QPointF scale(pixmapSize.width() / brect.width(), pixmapSize.height() / brect.height());
QTransform itemToPixmap;
- itemToPixmap.scale(scale.x(), scale.y());
+ if (fixedCacheSize) {
+ const QPointF scale(pixmapSize.width() / brect.width(), pixmapSize.height() / brect.height());
+ itemToPixmap.scale(scale.x(), scale.y());
+ }
itemToPixmap.translate(-br.x(), -br.y());
// Generate the item's exposedRect and map its list of expose
@@ -4750,11 +4945,9 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
if (newCacheIndent != deviceData->cacheIndent || deviceRect.size() != pix.size()) {
QPoint diff = newCacheIndent - deviceData->cacheIndent;
QPixmap newPix(deviceRect.size());
- // ### Investigate removing this fill (test with Plasma and
- // graphicssystem raster).
- newPix.fill(Qt::transparent);
if (!pix.isNull()) {
QPainter newPixPainter(&newPix);
+ newPixPainter.setCompositionMode(QPainter::CompositionMode_Source);
newPixPainter.drawPixmap(-diff, pix);
newPixPainter.end();
}
@@ -4786,8 +4979,9 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
if (itemCache->allExposed || !itemCache->exposed.isEmpty() || !scrollExposure.isEmpty()) {
// Construct an item-to-pixmap transform.
QPointF p = deviceRect.topLeft();
- QTransform itemToPixmap = QTransform::fromTranslate(-p.x(), -p.y());
- itemToPixmap = painter->worldTransform() * itemToPixmap;
+ QTransform itemToPixmap = painter->worldTransform();
+ if (!p.isNull())
+ itemToPixmap *= QTransform::fromTranslate(-p.x(), -p.y());
// Map the item's logical expose to pixmap coordinates.
QRegion pixmapExposed = scrollExposure;
@@ -5114,16 +5308,19 @@ void QGraphicsScene::itemUpdated(QGraphicsItem *item, const QRectF &rect)
// Deliver the actual update.
if (!d->updateAll) {
if (d->views.isEmpty() || ((d->connectedSignals & d->changedSignalMask) && !item->d_ptr->itemIsUntransformable()
- && qFuzzyCompare(item->boundingRegionGranularity(), qreal(0.0)))) {
+ && qFuzzyIsNull(item->boundingRegionGranularity()))) {
// This block of code is kept for compatibility. Since 4.5, by default
// QGraphicsView does not connect the signal and we use the below
// method of delivering updates.
update(item->sceneBoundingRect());
} else {
// ### Remove _q_adjustedRects().
- QRectF boundingRect = _q_adjustedRect(item->boundingRect());
- if (!rect.isNull())
- boundingRect &= _q_adjustedRect(rect);
+ QRectF boundingRect(adjustedItemBoundingRect(item));
+ if (!rect.isNull()) {
+ QRectF adjustedRect(rect);
+ _q_adjustRect(&adjustedRect);
+ boundingRect &= adjustedRect;
+ }
// Update each view directly.
for (int i = 0; i < d->views.size(); ++i)
@@ -5135,6 +5332,9 @@ void QGraphicsScene::itemUpdated(QGraphicsItem *item, const QRectF &rect)
d->resetDirtyItemsLater();
}
+ if (!item->isVisible())
+ return; // Hiding an item won't effect the largestUntransformableItem/sceneRect.
+
// Update d->largestUntransformableItem by mapping this item's bounding
// rect back to the topmost untransformable item's untransformed
// coordinate system (which sort of equals the 1:1 coordinate system of an
@@ -5150,7 +5350,9 @@ void QGraphicsScene::itemUpdated(QGraphicsItem *item, const QRectF &rect)
// defined scene rect.
if (!d->hasSceneRect) {
QRectF oldGrowingItemsBoundingRect = d->growingItemsBoundingRect;
- d->growingItemsBoundingRect |= _q_adjustedRect(item->sceneBoundingRect());
+ QRectF adjustedItemSceneBoundingRect(item->sceneBoundingRect());
+ _q_adjustRect(&adjustedItemSceneBoundingRect);
+ d->growingItemsBoundingRect |= adjustedItemSceneBoundingRect;
if (d->growingItemsBoundingRect != oldGrowingItemsBoundingRect)
emit sceneRectChanged(d->growingItemsBoundingRect);
}
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index 7f441da..9ace725 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -168,6 +168,9 @@ public:
Qt::DropAction lastDropAction;
QList<QGraphicsItem *> cachedItemsUnderMouse;
QList<QGraphicsItem *> hoverItems;
+ bool allItemsIgnoreHoverEvents;
+ bool allItemsUseDefaultCursor;
+ void enableMouseTrackingOnViews();
QMap<Qt::MouseButton, QPointF> mouseGrabberButtonDownPos;
QMap<Qt::MouseButton, QPointF> mouseGrabberButtonDownScenePos;
QMap<Qt::MouseButton, QPoint> mouseGrabberButtonDownScreenPos;
@@ -200,6 +203,7 @@ public:
void mousePressEventHandler(QGraphicsSceneMouseEvent *mouseEvent);
QGraphicsWidget *windowForItem(const QGraphicsItem *item) const;
+ QList<QGraphicsItem *> items_helper(const QPointF &pos) const;
QList<QGraphicsItem *> items_helper(const QRectF &rect,
Qt::ItemSelectionMode mode,
Qt::SortOrder order) const;
@@ -211,6 +215,9 @@ public:
Qt::SortOrder order) const;
void childItems_helper(QList<QGraphicsItem *> *items,
const QGraphicsItem *parent,
+ const QPointF &pos) const;
+ void childItems_helper(QList<QGraphicsItem *> *items,
+ const QGraphicsItem *parent,
const QRectF &rect,
Qt::ItemSelectionMode mode) const;
void childItems_helper(QList<QGraphicsItem *> *items,
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index a661441..a9d585c 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -587,6 +587,10 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event)
return;
if (!scene)
return;
+ if (scene->d_func()->allItemsIgnoreHoverEvents && scene->d_func()->allItemsUseDefaultCursor
+ && !event->buttons()) { // forward event to the scene if something is pressed.
+ return; // No need to process this event further.
+ }
QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
mouseEvent.setWidget(q->viewport());
@@ -614,6 +618,16 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event)
}
#ifndef QT_NO_CURSOR
+ // If all the items ignore hover events, we don't look-up any items
+ // in QGraphicsScenePrivate::dispatchHoverEvent, hence the
+ // cachedItemsUnderMouse list will be empty. We therefore do the look-up
+ // for cursor items here if not all items use the default cursor.
+ if (scene->d_func()->allItemsIgnoreHoverEvents && !scene->d_func()->allItemsUseDefaultCursor
+ && scene->d_func()->cachedItemsUnderMouse.isEmpty()) {
+ scene->d_func()->cachedItemsUnderMouse = scene->d_func()->itemsAtPosition(mouseEvent.screenPos(),
+ mouseEvent.scenePos(),
+ mouseEvent.widget());
+ }
// Find the topmost item under the mouse with a cursor.
foreach (QGraphicsItem *item, scene->d_func()->cachedItemsUnderMouse) {
if (item->hasCursor()) {
@@ -790,6 +804,19 @@ QRegion QGraphicsViewPrivate::mapToViewRegion(const QGraphicsItem *item, const Q
return item->boundingRegion(itv) & itv.mapRect(rect).toAlignedRect();
}
+// QRectF::intersects() returns false always if either the source or target
+// rectangle's width or height are 0. This works around that problem.
+static inline QRectF adjustedItemBoundingRect(const QGraphicsItem *item)
+{
+ Q_ASSERT(item);
+ QRectF boundingRect(item->boundingRect());
+ if (!boundingRect.width())
+ boundingRect.adjust(-0.00001, 0, 0.00001, 0);
+ if (!boundingRect.height())
+ boundingRect.adjust(0, -0.00001, 0, 0.00001);
+ return boundingRect;
+}
+
/*!
\internal
*/
@@ -801,38 +828,37 @@ void QGraphicsViewPrivate::itemUpdated(QGraphicsItem *item, const QRectF &rect)
updateLater();
QRectF updateRect = rect;
- if (item->isClipped()) {
+ if ((item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape) || item->d_ptr->children.isEmpty()) {
+ updateRect &= adjustedItemBoundingRect(item);
+ if (updateRect.isEmpty())
+ return;
+ }
+
+ QGraphicsItem *clipItem = item;
+ if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
// Minimize unnecessary redraw.
- QGraphicsItem *p = item;
- while ((p = p->d_ptr->parent)) {
- if (p->flags() & QGraphicsItem::ItemClipsChildrenToShape) {
- updateRect &= p->itemTransform(item).mapRect(p->boundingRect());
- if (updateRect.isNull())
+ QGraphicsItem *parent = item;
+ while ((parent = parent->d_ptr->parent)) {
+ if (parent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape) {
+ // Map update rect to the current parent and itersect with its bounding rect.
+ updateRect = clipItem->itemTransform(parent).mapRect(updateRect)
+ & adjustedItemBoundingRect(parent);
+ if (updateRect.isEmpty())
return;
+ clipItem = parent;
}
- if (!(p->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
+ if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
break;
}
-
- if (updateRect.isNull())
- return;
}
- // Map the rect to view coordinates.
- QRect vr = viewport->rect();
-
- if (!item->d_ptr->hasBoundingRegionGranularity) {
- QRect r = mapToViewRect(item, updateRect) & vr;
- if (r.isNull())
- return;
- this->updateRect(r);
- } else {
- QRegion r = mapToViewRegion(item, updateRect) & vr;
- if (r.isEmpty())
- return;
- updateRegion(r);
- }
+ // Map update rect from clipItem coordinates to view coordinates.
+ Q_ASSERT(clipItem);
+ if (!item->d_ptr->hasBoundingRegionGranularity)
+ this->updateRect(mapToViewRect(clipItem, updateRect) & viewport->rect());
+ else
+ updateRegion(mapToViewRegion(clipItem, updateRect) & viewport->rect());
}
void QGraphicsViewPrivate::updateLater()
@@ -855,16 +881,19 @@ void QGraphicsViewPrivate::_q_updateLaterSlot()
const QList<QGraphicsItem *> &dirtyItems = scene->d_func()->dirtyItems;
for (int i = 0; i < dirtyItems.size(); ++i) {
const QGraphicsItem *item = dirtyItems.at(i);
+ if (item->d_ptr->discardUpdateRequest(/*ignoreClipping=*/false,
+ /*ignoreVisibleBit=*/false,
+ /*ignoreDirtyBit=*/true)) {
+ continue;
+ }
QTransform x = item->sceneTransform() * viewTransform;
- QRect viewRect = x.mapRect(item->boundingRect()).toAlignedRect() & vr;
- if (!viewRect.isNull())
- updateRect(viewRect);
+ updateRect(x.mapRect(item->boundingRect()).toAlignedRect() & vr);
}
dirtyRectCount += dirtyRects.size();
bool noUpdate = !fullUpdatePending && viewportUpdateMode == QGraphicsView::FullViewportUpdate;
- if ((dirtyRectCount > 0 || !dirtyBoundingRect.isNull()) && !fullUpdatePending && !noUpdate) {
+ if ((dirtyRectCount > 0 || !dirtyBoundingRect.isEmpty()) && !fullUpdatePending && !noUpdate) {
if (viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate
|| (viewportUpdateMode == QGraphicsView::SmartViewportUpdate
&& dirtyRectCount >= QGRAPHICSVIEW_REGION_RECT_THRESHOLD)) {
@@ -921,6 +950,9 @@ void QGraphicsViewPrivate::updateAll()
void QGraphicsViewPrivate::updateRegion(const QRegion &r)
{
+ if (r.isEmpty())
+ return;
+
Q_Q(QGraphicsView);
// Rect intersects viewport - update everything?
@@ -969,6 +1001,9 @@ void QGraphicsViewPrivate::updateRegion(const QRegion &r)
void QGraphicsViewPrivate::updateRect(const QRect &r)
{
+ if (r.isEmpty())
+ return;
+
Q_Q(QGraphicsView);
// Rect intersects viewport - update everything?
@@ -1025,103 +1060,71 @@ void QGraphicsViewPrivate::freeStyleOptionsArray(QStyleOptionGraphicsItem *array
extern QPainterPath qt_regionToPath(const QRegion &region);
-QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedRegion,
- const QTransform &worldTransform,
- bool *allItems) const
+/*!
+ ### Adjustments in findItems: mapToScene(QRect) forces us to adjust the
+ input rectangle by (0, 0, 1, 1), because it uses QRect::bottomRight()
+ (etc) when mapping the rectangle to a polygon (which is _wrong_). In
+ addition, as QGraphicsItem::boundingRect() is defined in logical space,
+ but the default pen for QPainter is cosmetic with a width of 0, QPainter
+ is at risk of painting 1 pixel outside the bounding rect. Therefore we
+ must search for items with an adjustment of (-1, -1, 1, 1).
+*/
+QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedRegion, bool *allItems) const
{
Q_Q(const QGraphicsView);
- QList<QGraphicsItem *> itemList;
- QSet<QGraphicsItem *> tmp;
- bool simpleTransform = worldTransform.type() <= QTransform::TxScale;
-
- QPainterPath path = qt_regionToPath(exposedRegion);
- *allItems = path.contains(q->mapFromScene(scene->d_func()->growingItemsBoundingRect).boundingRect());
- QList<QRectF> exposedRects;
- QList<QPolygonF> exposedPolys;
-
- // Transform the exposed viewport rects to scene rects or polygons
- foreach (const QRect &rect, exposedRegion.rects()) {
- QPolygonF exposedPoly = q->mapToScene(rect.adjusted(-1, -1, 1, 1));
- QRectF exposedRect = exposedPoly.boundingRect();
- if (!simpleTransform)
- exposedPolys << exposedPoly;
- exposedRects << exposedRect;
- }
-
- // Find which items need to be drawn.
- if (*allItems) {
+
+ // Step 1) If all items are contained within the expose region, then
+ // return a list of all visible items.
+ const QRectF exposedRegionSceneBounds = q->mapToScene(exposedRegion.boundingRect().adjusted(-1, -1, 1, 1))
+ .boundingRect();
+ if (exposedRegionSceneBounds.contains(scene->d_func()->growingItemsBoundingRect)) {
+ Q_ASSERT(allItems);
+ *allItems = true;
+
// All items are guaranteed within the exposed region, don't bother using the index.
- foreach (QGraphicsItem *item, scene->items()) {
+ QList<QGraphicsItem *> itemList(scene->items());
+ int i = 0;
+ while (i < itemList.size()) {
// But we only want to include items that are visible
- if (item->isVisible())
- itemList << item;
- }
- } else if (simpleTransform) {
- // Simple rect lookups will do.
- if (exposedRects.size() > 1) {
- foreach (const QRectF &rect, exposedRects) {
- foreach (QGraphicsItem *item, scene->d_func()->items_helper(rect, Qt::IntersectsItemBoundingRect, Qt::SortOrder(-1) /* don't sort */)) {
- if (!tmp.contains(item)) {
- tmp << item;
- itemList << item;
- }
- }
- }
- } else {
- itemList += scene->d_func()->items_helper(exposedRects[0], Qt::IntersectsItemBoundingRect, Qt::SortOrder(-1) /* don't sort */);
- }
- } else {
- // Polygon lookup is necessary.
- if (exposedRects.size() > 1) {
- foreach (const QPolygonF &poly, exposedPolys) {
- foreach (QGraphicsItem *item, scene->d_func()->items_helper(poly, Qt::IntersectsItemBoundingRect, Qt::SortOrder(-1) /* don't sort */)) {
- if (!tmp.contains(item)) {
- tmp << item;
- itemList << item;
- }
- }
- }
- } else {
- itemList += scene->d_func()->items_helper(exposedPolys[0], Qt::IntersectsItemBoundingRect, Qt::SortOrder(-1) /* don't sort */);
+ if (!itemList.at(i)->isVisible())
+ itemList.removeAt(i);
+ else
+ ++i;
}
+
+ // Sort the items.
+ QGraphicsScenePrivate::sortItems(&itemList, Qt::DescendingOrder, scene->d_func()->sortCacheEnabled);
+ return itemList;
}
- // Check for items that ignore inherited transformations, and add them if
- // necessary.
- QRectF untr = scene->d_func()->largestUntransformableItem;
- if (!*allItems && !untr.isNull()) {
- // Map the largest untransformable item subtree boundingrect from view
- // to scene coordinates, and use this to expand all exposed rects in
- // search for untransformable items.
- QRectF ltri = matrix.inverted().mapRect(untr);
- ltri.adjust(-untr.width(), -untr.height(), untr.width(), untr.height());
-
- foreach (const QRect &rect, exposedRegion.rects()) {
- QRectF exposed = q->mapToScene(rect.adjusted(-1, -1, 1, 1)).boundingRect();
- exposed.adjust(-ltri.width(), -ltri.height(), ltri.width(), ltri.height());
-
- foreach (QGraphicsItem *item, scene->d_func()->estimateItemsInRect(exposed)) {
- if (item->d_ptr->itemIsUntransformable()) {
- if (!tmp.contains(item)) {
- QPainterPath rectPath;
- rectPath.addRect(rect);
- QPainterPath path = item->deviceTransform(q->viewportTransform()).inverted().map(rectPath);
- if (item->collidesWithPath(path, Qt::IntersectsItemBoundingRect)) {
- itemList << item;
- tmp << item;
- }
- }
- }
- }
- }
+ // Step 2) If the expose region is a simple rect and the view is only
+ // translated or scaled, search for items using
+ // QGraphicsScene::items(QRectF).
+ bool simpleRectLookup = (scene->d_func()->largestUntransformableItem.isNull()
+ && exposedRegion.numRects() == 1 && matrix.type() <= QTransform::TxScale);
+ if (simpleRectLookup) {
+ return scene->d_func()->items_helper(exposedRegionSceneBounds,
+ Qt::IntersectsItemBoundingRect,
+ Qt::DescendingOrder);
}
- tmp.clear();
- // Sort the items.
- QGraphicsScenePrivate::sortItems(&itemList, Qt::DescendingOrder,
- scene->d_func()->sortCacheEnabled);
+ // If the region is complex or the view has a complex transform, adjust
+ // the expose region, convert it to a path, and then search for items
+ // using QGraphicsScene::items(QPainterPath);
+ QRegion adjustedRegion;
+ foreach (const QRect &r, exposedRegion.rects())
+ adjustedRegion += r.adjusted(-1, -1, 1, 1);
+
+ const QPainterPath exposedPath(qt_regionToPath(adjustedRegion));
+ if (scene->d_func()->largestUntransformableItem.isNull()) {
+ const QPainterPath exposedScenePath(q->mapToScene(exposedPath));
+ return scene->d_func()->items_helper(exposedScenePath,
+ Qt::IntersectsItemBoundingRect,
+ Qt::DescendingOrder);
+ }
- return itemList;
+ // NB! Path must be in viewport coordinates.
+ return itemsInArea(exposedPath, Qt::IntersectsItemBoundingRect, Qt::DescendingOrder);
}
void QGraphicsViewPrivate::generateStyleOptions(const QList<QGraphicsItem *> &itemList,
@@ -1699,6 +1702,12 @@ void QGraphicsView::setScene(QGraphicsScene *scene)
d->recalculateContentSize();
d->lastCenterPoint = sceneRect().center();
d->keepLastCenterPoint = true;
+ // We are only interested in mouse tracking if items accept
+ // hover events or use non-default cursors.
+ if (!d->scene->d_func()->allItemsIgnoreHoverEvents
+ || !d->scene->d_func()->allItemsUseDefaultCursor) {
+ d->viewport->setMouseTracking(true);
+ }
} else {
d->recalculateContentSize();
}
@@ -2224,7 +2233,8 @@ QList<QGraphicsItem *> QGraphicsView::items() const
certainly room for improvement.
*/
QList<QGraphicsItem *> QGraphicsViewPrivate::itemsInArea(const QPainterPath &path,
- Qt::ItemSelectionMode mode) const
+ Qt::ItemSelectionMode mode,
+ Qt::SortOrder order) const
{
Q_Q(const QGraphicsView);
@@ -2274,8 +2284,8 @@ QList<QGraphicsItem *> QGraphicsViewPrivate::itemsInArea(const QPainterPath &pat
}
// ### Insertion sort would be faster.
- QGraphicsScenePrivate::sortItems(&result, Qt::AscendingOrder,
- scene->d_func()->sortCacheEnabled);
+ if (order != Qt::SortOrder(-1))
+ QGraphicsScenePrivate::sortItems(&result, order, scene->d_func()->sortCacheEnabled);
return result;
}
@@ -2303,7 +2313,7 @@ QList<QGraphicsItem *> QGraphicsView::items(const QPoint &pos) const
QTransform xinv = viewportTransform().inverted();
return d->scene->items(xinv.mapRect(QRectF(pos.x(), pos.y(), 1, 1)));
}
- return d->scene->items(mapToScene(pos.x(), pos.y(), 2, 2));
+ return d->scene->items(mapToScene(pos.x(), pos.y(), 1, 1));
}
QPainterPath path;
@@ -2465,10 +2475,11 @@ QPolygonF QGraphicsView::mapToScene(const QRect &rect) const
return QPolygonF();
QPointF scrollOffset(d->horizontalScroll(), d->verticalScroll());
- QPointF tl = scrollOffset + rect.topLeft();
- QPointF tr = scrollOffset + rect.topRight();
- QPointF br = scrollOffset + rect.bottomRight();
- QPointF bl = scrollOffset + rect.bottomLeft();
+ QRect r = rect.adjusted(0, 0, 1, 1);
+ QPointF tl = scrollOffset + r.topLeft();
+ QPointF tr = scrollOffset + r.topRight();
+ QPointF br = scrollOffset + r.bottomRight();
+ QPointF bl = scrollOffset + r.bottomLeft();
QPolygonF poly;
poly.resize(4);
@@ -2809,7 +2820,12 @@ void QGraphicsView::setupViewport(QWidget *widget)
widget->setAutoFillBackground(true);
}
- widget->setMouseTracking(true);
+ // We are only interested in mouse tracking if items
+ // accept hover events or use non-default cursors.
+ if (d->scene && (!d->scene->d_func()->allItemsIgnoreHoverEvents
+ || !d->scene->d_func()->allItemsUseDefaultCursor)) {
+ widget->setMouseTracking(true);
+ }
widget->setAcceptDrops(acceptDrops());
}
@@ -3280,7 +3296,7 @@ void QGraphicsView::mouseMoveEvent(QMouseEvent *event)
}
// Update old rubberband
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate && !d->rubberBandRect.isNull()) {
+ if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate && !d->rubberBandRect.isEmpty()) {
if (d->viewportUpdateMode != FullViewportUpdate)
viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect));
else
@@ -3456,13 +3472,13 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
exposedRegion = viewport()->rect();
else if (d->viewportUpdateMode == BoundingRectViewportUpdate)
exposedRegion = event->rect();
- QRectF exposedSceneRect = mapToScene(exposedRegion.boundingRect().adjusted(0, 0, 1, 1)).boundingRect();
+ QRectF exposedSceneRect = mapToScene(exposedRegion.boundingRect()).boundingRect();
// Set up the painter
QPainter painter(viewport());
QTransform original = painter.worldTransform();
#ifndef QT_NO_RUBBERBAND
- if (d->rubberBanding && !d->rubberBandRect.isNull())
+ if (d->rubberBanding && !d->rubberBandRect.isEmpty())
painter.save();
#endif
// Set up render hints
@@ -3481,7 +3497,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
// Find all exposed items
bool allItems = false;
- QList<QGraphicsItem *> itemList = d->findItems(exposedRegion, viewTransform, &allItems);
+ QList<QGraphicsItem *> itemList = d->findItems(exposedRegion, &allItems);
#ifdef QGRAPHICSVIEW_DEBUG
int exposedTime = stopWatch.elapsed();
@@ -3558,7 +3574,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
#ifndef QT_NO_RUBBERBAND
// Rubberband
- if (d->rubberBanding && !d->rubberBandRect.isNull()) {
+ if (d->rubberBanding && !d->rubberBandRect.isEmpty()) {
painter.restore();
QStyleOptionRubberBand option;
option.initFrom(viewport());
@@ -3632,30 +3648,30 @@ void QGraphicsView::scrollContentsBy(int dx, int dy)
if (isRightToLeft())
dx = -dx;
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate
- && d->viewportUpdateMode != QGraphicsView::FullViewportUpdate) {
- for (int i = 0; i < d->dirtyRects.size(); ++i)
- d->dirtyRects[i].translate(dx, dy);
- for (int i = 0; i < d->dirtyRegions.size(); ++i)
- d->dirtyRegions[i].translate(dx, dy);
- }
-
+ if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate) {
+ if (d->viewportUpdateMode != QGraphicsView::FullViewportUpdate) {
+ for (int i = 0; i < d->dirtyRects.size(); ++i)
+ d->dirtyRects[i].translate(dx, dy);
+ for (int i = 0; i < d->dirtyRegions.size(); ++i)
+ d->dirtyRegions[i].translate(dx, dy);
+ if (d->accelerateScrolling) {
#ifndef QT_NO_RUBBERBAND
- // Update old rubberband
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate && !d->rubberBandRect.isNull()) {
- if (d->viewportUpdateMode != FullViewportUpdate)
- viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect));
- else
- viewport()->update();
- }
+ // Update new and old rubberband regions
+ if (!d->rubberBandRect.isEmpty()) {
+ QRegion rubberBandRegion(d->rubberBandRegion(viewport(), d->rubberBandRect));
+ rubberBandRegion += rubberBandRegion.translated(-dx, -dy);
+ viewport()->update(rubberBandRegion);
+ }
#endif
-
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate){
- if (d->accelerateScrolling && d->viewportUpdateMode != FullViewportUpdate)
- viewport()->scroll(dx, dy);
- else
+ viewport()->scroll(dx, dy);
+ } else {
+ viewport()->update();
+ }
+ } else {
viewport()->update();
+ }
}
+
d->updateLastCenterPoint();
if ((d->cacheMode & CacheBackground)
diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h
index 2109673..a76279e 100644
--- a/src/gui/graphicsview/qgraphicsview_p.h
+++ b/src/gui/graphicsview/qgraphicsview_p.h
@@ -85,7 +85,8 @@ public:
qint64 verticalScroll() const;
QList<QGraphicsItem *> itemsInArea(const QPainterPath &path,
- Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
+ Qt::ItemSelectionMode mode = Qt::IntersectsItemShape,
+ Qt::SortOrder = Qt::AscendingOrder) const;
QPointF mousePressItemPoint;
QPointF mousePressScenePoint;
@@ -172,9 +173,7 @@ public:
void updateRegion(const QRegion &region);
bool updateSceneSlotReimplementedChecked;
- QList<QGraphicsItem *> findItems(const QRegion &exposedRegion,
- const QTransform &worldTransform,
- bool *allItems) const;
+ QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems) const;
void generateStyleOptions(const QList<QGraphicsItem *> &itemList,
QGraphicsItem **itemArray,
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 64ec0e7..2e7d82a 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -366,32 +366,33 @@ void QGraphicsWidget::resize(const QSizeF &size)
void QGraphicsWidget::setGeometry(const QRectF &rect)
{
QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
- const QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr;
- setAttribute(Qt::WA_Resized);
- QRectF newGeom = rect;
- newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))
- .boundedTo(effectiveSizeHint(Qt::MaximumSize)));
- if (newGeom == d->geom)
- return;
-
- // Update and prepare to change the geometry (remove from index).
- if (wd->scene) {
- if (rect.topLeft() != d->geom.topLeft())
- wd->fullUpdateHelper(true);
- else
- update();
- }
- prepareGeometryChange();
-
- // setPos triggers ItemPositionChange, which can adjust position
+ QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr;
+ QRectF newGeom;
QPointF oldPos = d->geom.topLeft();
- wd->inSetGeometry = 1;
- wd->setPosHelper(newGeom.topLeft(), /* update = */ false);
- wd->inSetGeometry = 0;
- newGeom.moveTopLeft(pos());
-
- if (newGeom == d->geom)
- return;
+ if (!wd->inSetPos) {
+ setAttribute(Qt::WA_Resized);
+ newGeom = rect;
+ newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))
+ .boundedTo(effectiveSizeHint(Qt::MaximumSize)));
+ if (newGeom == d->geom)
+ return;
+
+ // setPos triggers ItemPositionChange, which can adjust position
+ wd->inSetGeometry = 1;
+ wd->setPosHelper(newGeom.topLeft());
+ wd->inSetGeometry = 0;
+ newGeom.moveTopLeft(pos());
+
+ if (newGeom == d->geom)
+ return;
+
+ // Update and prepare to change the geometry (remove from index) if the size has changed.
+ if (wd->scene) {
+ if (rect.topLeft() == d->geom.topLeft()) {
+ prepareGeometryChange();
+ }
+ }
+ }
// Update the layout item geometry
bool moved = oldPos != pos();
@@ -401,6 +402,11 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
event.setOldPos(oldPos);
event.setNewPos(pos());
QApplication::sendEvent(this, &event);
+ if (wd->inSetPos) {
+ //set the new pos
+ d->geom.moveTopLeft(pos());
+ return;
+ }
}
QSizeF oldSize = size();
QGraphicsLayoutItem::setGeometry(newGeom);
@@ -1016,9 +1022,11 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant &
break;
case ItemPositionHasChanged:
if (!d->inSetGeometry) {
+ d->inSetPos = 1;
// Ensure setGeometry is called (avoid recursion when setPos is
// called from within setGeometry).
setGeometry(QRectF(pos(), size()));
+ d->inSetPos = 0 ;
}
break;
case ItemParentChange: {
@@ -1627,6 +1635,11 @@ void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags)
else
d->scene->d_func()->addPopup(this);
}
+
+ if (d->scene && d->scene->d_func()->allItemsIgnoreHoverEvents && d->hasDecoration()) {
+ d->scene->d_func()->allItemsIgnoreHoverEvents = false;
+ d->scene->d_func()->enableMouseTrackingOnViews();
+ }
}
/*!
diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp
index 789f8da..06ffe73 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.cpp
+++ b/src/gui/graphicsview/qgraphicswidget_p.cpp
@@ -66,15 +66,16 @@ void QGraphicsWidgetPrivate::init(QGraphicsItem *parentItem, Qt::WindowFlags wFl
isWidget = 1; // QGraphicsItem::isWidget() returns true.
focusNext = focusPrev = q;
focusPolicy = Qt::NoFocus;
+
+ if (!parentItem)
+ adjustWindowFlags(&wFlags);
+ windowFlags = wFlags;
+
q->setParentItem(parentItem);
q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::DefaultType));
q->setGraphicsItem(q);
resolveLayoutDirection();
-
- if (!parentItem)
- adjustWindowFlags(&wFlags);
- windowFlags = wFlags;
q->unsetWindowFrameMargins();
}
qreal QGraphicsWidgetPrivate::titleBarHeight(const QStyleOptionTitleBar &options) const
diff --git a/src/gui/graphicsview/qgraphicswidget_p.h b/src/gui/graphicsview/qgraphicswidget_p.h
index 455a129..53eaa31 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.h
+++ b/src/gui/graphicsview/qgraphicswidget_p.h
@@ -86,6 +86,7 @@ public:
inheritedFontResolveMask(0),
inSetGeometry(0),
polished(0),
+ inSetPos(0),
focusPolicy(Qt::NoFocus),
focusNext(0),
focusPrev(0),
@@ -195,6 +196,7 @@ public:
quint32 attributes : 10;
quint32 inSetGeometry : 1;
quint32 polished: 1;
+ quint32 inSetPos : 1;
// Focus
Qt::FocusPolicy focusPolicy;
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 3c71f15..0514567 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -304,6 +304,8 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St
QString key = QLatin1String("$qt_icon_")
+ QString::number(pm.cacheKey())
+ QString::number(pe->mode)
+ + QString::number(qApp->palette().cacheKey())
+ + QLatin1Char('_')
+ QString::number(actualSize.width())
+ QLatin1Char('_')
+ QString::number(actualSize.height())
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 558d574..14e8b8f 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -1691,8 +1691,12 @@ void QImage::setColorTable(const QVector<QRgb> colors)
d->colortable = colors;
d->has_alpha_clut = false;
- for (int i = 0; i < d->colortable.size(); ++i)
- d->has_alpha_clut |= (qAlpha(d->colortable.at(i)) != 255);
+ for (int i = 0; i < d->colortable.size(); ++i) {
+ if (qAlpha(d->colortable.at(i)) != 255) {
+ d->has_alpha_clut = true;
+ break;
+ }
+ }
}
/*!
@@ -3607,6 +3611,9 @@ 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.
+
\sa setPixel(), valid(), {QImage#Pixel Manipulation}{Pixel
Manipulation}
*/
@@ -4937,10 +4944,12 @@ int QImage::dotsPerMeterY() const
meter, to \a x.
Together with dotsPerMeterY(), this number defines the intended
- scale and aspect ratio of the image.
+ scale and aspect ratio of the image, and determines the scale
+ at which QPainter will draw graphics on the image. It does not
+ change the scale or aspect ratio of the image when it is rendered
+ on other paint devices.
- \sa dotsPerMeterX(), {QImage#Image Information}{Image
- Information}
+ \sa dotsPerMeterX(), {QImage#Image Information}{Image Information}
*/
void QImage::setDotsPerMeterX(int x)
{
@@ -4957,10 +4966,12 @@ void QImage::setDotsPerMeterX(int x)
to \a y.
Together with dotsPerMeterX(), this number defines the intended
- scale and aspect ratio of the image.
+ scale and aspect ratio of the image, and determines the scale
+ at which QPainter will draw graphics on the image. It does not
+ change the scale or aspect ratio of the image when it is rendered
+ on other paint devices.
- \sa dotsPerMeterY(), {QImage#Image Information}{Image
- Information}
+ \sa dotsPerMeterY(), {QImage#Image Information}{Image Information}
*/
void QImage::setDotsPerMeterY(int y)
{
@@ -5577,6 +5588,8 @@ bool QImage::isDetached() const
Use one of the composition mods in QPainter::CompositionMode instead.
+ \warning This function is expensive.
+
\sa alphaChannel(), {QImage#Image Transformations}{Image
Transformations}, {QImage#Image Formats}{Image Formats}
*/
@@ -5659,6 +5672,11 @@ void QImage::setAlphaChannel(const QImage &alphaChannel)
\l{QPixmap::}{alphaChannel()}, which works in the same way as
this function on QPixmaps.
+ Most usecases for this function can be replaced with QPainter and
+ using composition modes.
+
+ \warning This is an expensive function.
+
\sa setAlphaChannel(), hasAlphaChannel(),
{QPixmap#Pixmap Information}{Pixmap},
{QImage#Image Transformations}{Image Transformations}
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp
index 6b74323..33e565c 100644
--- a/src/gui/image/qnativeimage.cpp
+++ b/src/gui/image/qnativeimage.cpp
@@ -100,7 +100,9 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool is
bmi.blueMask = 0;
}
- hdc = CreateCompatibleDC(qt_win_display_dc());
+ HDC display_dc = GetDC(0);
+ hdc = CreateCompatibleDC(display_dc);
+ ReleaseDC(0, display_dc);
Q_ASSERT(hdc);
uchar *bits = 0;
diff --git a/src/gui/image/qpaintengine_pic.cpp b/src/gui/image/qpaintengine_pic.cpp
index cba9827..a130a1a 100644
--- a/src/gui/image/qpaintengine_pic.cpp
+++ b/src/gui/image/qpaintengine_pic.cpp
@@ -346,7 +346,7 @@ void QPicturePaintEngine::writeCmdLength(int pos, const QRectF &r, bool corr)
if (corr) { // widen bounding rect
int w2 = painter()->pen().width() / 2;
br.setCoords(br.left() - w2, br.top() - w2,
- br.right() + w2, br.bottom() + w2);
+ br.right() + w2, br.bottom() + w2);
}
br = painter()->transform().mapRect(br);
if (painter()->hasClipping()) {
@@ -458,6 +458,25 @@ void QPicturePaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap
writeCmdLength(pos, r, false);
}
+void QPicturePaintEngine::drawImage(const QRectF &r, const QImage &image, const QRectF &sr,
+ Qt::ImageConversionFlags flags)
+{
+ Q_D(QPicturePaintEngine);
+#ifdef QT_PICTURE_DEBUG
+ qDebug() << " -> drawImage():" << r << sr;
+#endif
+ int pos;
+ SERIALIZE_CMD(QPicturePrivate::PdcDrawImage);
+ if (d->pic_d->in_memory_only) {
+ int index = d->pic_d->image_list.size();
+ d->pic_d->image_list.append(image);
+ d->s << r << index << sr << (quint32) flags;
+ } else {
+ d->s << r << image << sr << (quint32) flags;
+ }
+ writeCmdLength(pos, r, false);
+}
+
extern int qt_defaultDpi();
void QPicturePaintEngine::drawTextItem(const QPointF &p , const QTextItem &ti)
diff --git a/src/gui/image/qpaintengine_pic_p.h b/src/gui/image/qpaintengine_pic_p.h
index 3ae0845..745d057 100644
--- a/src/gui/image/qpaintengine_pic_p.h
+++ b/src/gui/image/qpaintengine_pic_p.h
@@ -100,6 +100,8 @@ public:
void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
+ void drawImage(const QRectF &r, const QImage &image, const QRectF &sr,
+ Qt::ImageConversionFlags flags = Qt::AutoColor);
void drawTextItem(const QPointF &p, const QTextItem &ti);
Type type() const { return Picture; }
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index d5d7cb0..92023e0 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -759,13 +759,21 @@ bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords)
QImage image;
if (d->formatMajor < 4) {
s >> p >> image;
- painter->drawPixmap(p, QPixmap::fromImage(image));
+ painter->drawImage(p, image);
} else if (d->formatMajor <= 5){
s >> ir >> image;
- painter->drawPixmap(ir, QPixmap::fromImage(image), QRect(0, 0, ir.width(), ir.height()));
+ painter->drawImage(ir, image, QRect(0, 0, ir.width(), ir.height()));
} else {
- s >> r >> image;
- painter->drawPixmap(r, QPixmap::fromImage(image), QRectF(0, 0, r.width(), r.height()));
+ QRectF sr;
+ if (d->in_memory_only) {
+ int index;
+ s >> r >> index >> sr >> ul;
+ Q_ASSERT(index < d->image_list.size());
+ image = d->image_list.at(index);
+ } else {
+ s >> r >> image >> sr >> ul;
+ }
+ painter->drawImage(r, image, sr, Qt::ImageConversionFlags(ul));
}
}
break;
diff --git a/src/gui/image/qpicture_p.h b/src/gui/image/qpicture_p.h
index 1da7f07..a3fd34f 100644
--- a/src/gui/image/qpicture_p.h
+++ b/src/gui/image/qpicture_p.h
@@ -158,6 +158,7 @@ public:
QRect override_rect;
QPaintEngine *paintEngine;
bool in_memory_only;
+ QList<QImage> image_list;
QList<QPixmap> pixmap_list;
QList<QBrush> brush_list;
QList<QPen> pen_list;
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index e563fc9..3b82da8 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -724,7 +724,7 @@ void QPixmap::resize_helper(const QSize &s)
pixels black. The effect of this function is undefined when the pixmap is
being painted on.
- This is potentially an expensive operation.
+ \warning This is potentially an expensive operation.
\sa mask(), {QPixmap#Pixmap Transformations}{Pixmap Transformations},
QBitmap
@@ -1430,6 +1430,12 @@ void QPixmap::deref()
If the given \a size is empty, this function returns a null
pixmap.
+
+ In some cases it can be more beneficial to draw the pixmap to a
+ painter with a scale set rather than scaling the pixmap. This is
+ the case when the painter is for instance based on OpenGL or when
+ the scale factor changes rapidly.
+
\sa isNull(), {QPixmap#Pixmap Transformations}{Pixmap
Transformations}
@@ -1801,6 +1807,10 @@ int QPixmap::metric(PaintDeviceMetric metric) const
The effect of this function is undefined when the pixmap is being
painted on.
+ \warning This is potentially an expensive operation. Most usecases
+ for this function are covered by QPainter and compositionModes
+ which will normally execute faster.
+
\sa alphaChannel(), {QPixmap#Pixmap Transformations}{Pixmap
Transformations}
*/
@@ -1843,6 +1853,9 @@ void QPixmap::setAlphaChannel(const QPixmap &alphaChannel)
\image alphachannelimage.png The pixmap and channelImage QPixmaps
+ \warning This is an expensive operation. The alpha channel of the
+ pixmap is extracted dynamically from the pixeldata.
+
\sa setAlphaChannel(), {QPixmap#Pixmap Information}{Pixmap
Information}
*/
@@ -1864,7 +1877,8 @@ QPaintEngine *QPixmap::paintEngine() const
Extracts a bitmap mask from the pixmap's alphachannel.
- This is potentially an expensive operation.
+ \warning This is potentially an expensive operation. The mask of
+ the pixmap is extracted dynamically from the pixeldata.
\sa setMask(), {QPixmap#Pixmap Information}{Pixmap Information}
*/
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp
index b0075b2..973cd78 100644
--- a/src/gui/image/qpixmap_mac.cpp
+++ b/src/gui/image/qpixmap_mac.cpp
@@ -303,7 +303,7 @@ void QMacPixmapData::fromImage(const QImage &img,
else
one_bit = one_bit >> (x % 8);
if ((one_bit & 0x01))
- *(drow+x) = 0x00000000;
+ *(drow+x) = 0xFF000000;
else
*(drow+x) = 0xFFFFFFFF;
}
diff --git a/src/gui/inputmethod/qinputcontext_p.h b/src/gui/inputmethod/qinputcontext_p.h
index 8c1b8de..a5e3d91 100644
--- a/src/gui/inputmethod/qinputcontext_p.h
+++ b/src/gui/inputmethod/qinputcontext_p.h
@@ -84,10 +84,6 @@ public:
{}
QWidget *focusWidget;
-
-#if defined(Q_WS_WIN) || defined(Q_WS_QWS)
- static void updateImeStatus(QWidget *w, bool hasFocus);
-#endif
};
QT_END_NAMESPACE
diff --git a/src/gui/inputmethod/qmacinputcontext_mac.cpp b/src/gui/inputmethod/qmacinputcontext_mac.cpp
index f0e7ea9..86385fa 100644
--- a/src/gui/inputmethod/qmacinputcontext_mac.cpp
+++ b/src/gui/inputmethod/qmacinputcontext_mac.cpp
@@ -45,6 +45,7 @@
#include "qtextformat.h"
#include <qdebug.h>
#include <private/qapplication_p.h>
+#include <private/qkeymapper_p.h>
QT_BEGIN_NAMESPACE
@@ -63,7 +64,8 @@ static QTextFormat qt_mac_compose_format()
}
QMacInputContext::QMacInputContext(QObject *parent)
- : QInputContext(parent), composing(false), recursionGuard(false), textDocument(0)
+ : QInputContext(parent), composing(false), recursionGuard(false), textDocument(0),
+ keydownEvent(0)
{
// createTextDocument();
}
@@ -183,6 +185,16 @@ QMacInputContext::cleanup()
#endif
}
+void QMacInputContext::setLastKeydownEvent(EventRef event)
+{
+ EventRef tmpEvent = keydownEvent;
+ keydownEvent = event;
+ if (keydownEvent)
+ RetainEvent(keydownEvent);
+ if (tmpEvent)
+ ReleaseEvent(tmpEvent);
+}
+
OSStatus
QMacInputContext::globalEventProcessor(EventHandlerCallRef, EventRef event, void *)
{
@@ -335,6 +347,12 @@ QMacInputContext::globalEventProcessor(EventHandlerCallRef, EventRef event, void
GetEventParameter(key_ev, kEventParamKeyMacCharCodes, typeChar, 0, sizeof(chr), 0, &chr);
if(!chr || chr >= 128 || (text.length() > 0 && (text.length() > 1 || text.at(0) != QLatin1Char(chr))))
handled_event = !widget->testAttribute(Qt::WA_InputMethodEnabled);
+ QMacInputContext *context = qobject_cast<QMacInputContext*>(qApp->inputContext());
+ if (context && context->lastKeydownEvent()) {
+ qt_keymapper_private()->translateKeyEvent(widget, 0, context->lastKeydownEvent(),
+ 0, false);
+ context->setLastKeydownEvent(0);
+ }
}
break; }
default:
diff --git a/src/gui/inputmethod/qmacinputcontext_p.h b/src/gui/inputmethod/qmacinputcontext_p.h
index f708040..c3f245a 100644
--- a/src/gui/inputmethod/qmacinputcontext_p.h
+++ b/src/gui/inputmethod/qmacinputcontext_p.h
@@ -78,6 +78,10 @@ public:
static OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *);
static void initialize();
static void cleanup();
+
+ EventRef lastKeydownEvent() { return keydownEvent; }
+ void setLastKeydownEvent(EventRef);
+
protected:
void mouseHandler(int pos, QMouseEvent *);
private:
@@ -85,6 +89,7 @@ private:
bool recursionGuard;
TSMDocumentID textDocument;
QString currentText;
+ EventRef keydownEvent;
};
QT_END_NAMESPACE
diff --git a/src/gui/inputmethod/qwininputcontext_p.h b/src/gui/inputmethod/qwininputcontext_p.h
index 38d7e32..c6ad19e 100644
--- a/src/gui/inputmethod/qwininputcontext_p.h
+++ b/src/gui/inputmethod/qwininputcontext_p.h
@@ -83,6 +83,7 @@ public:
static void TranslateMessage(const MSG *msg);
static LRESULT DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+ static void updateImeStatus(QWidget *w, bool hasFocus);
static void enablePopupChild(QWidget *w, bool e);
static void enable(QWidget *w, bool e);
diff --git a/src/gui/inputmethod/qwininputcontext_win.cpp b/src/gui/inputmethod/qwininputcontext_win.cpp
index 720f0b8..0ba4cd4 100644
--- a/src/gui/inputmethod/qwininputcontext_win.cpp
+++ b/src/gui/inputmethod/qwininputcontext_win.cpp
@@ -57,15 +57,17 @@
#ifdef Q_IME_DEBUG
#include "qdebug.h"
-#endif
-
-QT_BEGIN_NAMESPACE
+#endif
-extern bool qt_sendSpontaneousEvent(QObject*, QEvent*);
#if defined(Q_OS_WINCE)
extern void qt_wince_show_SIP(bool show); // defined in qguifunctions_wince.cpp
#endif
+QT_BEGIN_NAMESPACE
+
+extern bool qt_sendSpontaneousEvent(QObject*, QEvent*);
+
+
DEFINE_GUID(IID_IActiveIMMApp,
0x08c0e040, 0x62d1, 0x11d1, 0x93, 0x26, 0x0, 0x60, 0xb0, 0x67, 0xb8, 0x6e);
@@ -753,7 +755,7 @@ inline void enableIme(QWidget *w, bool value)
}
-void QInputContextPrivate::updateImeStatus(QWidget *w, bool hasFocus)
+void QWinInputContext::updateImeStatus(QWidget *w, bool hasFocus)
{
if (!w)
return;
@@ -822,6 +824,15 @@ void QWinInputContext::enable(QWidget *w, bool e)
void QWinInputContext::setFocusWidget(QWidget *w)
{
+ QWidget *oldFocus = focusWidget();
+ if (oldFocus == w)
+ return;
+ if (w) {
+ QWinInputContext::updateImeStatus(w, true);
+ } else {
+ if (oldFocus)
+ QWinInputContext::updateImeStatus(oldFocus , false);
+ }
QInputContext::setFocusWidget(w);
update();
}
diff --git a/src/gui/inputmethod/qwsinputcontext_p.h b/src/gui/inputmethod/qwsinputcontext_p.h
index 20811da..835cb3f 100644
--- a/src/gui/inputmethod/qwsinputcontext_p.h
+++ b/src/gui/inputmethod/qwsinputcontext_p.h
@@ -87,6 +87,7 @@ public:
static bool translateIMEvent(QWidget *w, const QWSIMEvent *e);
static bool translateIMQueryEvent(QWidget *w, const QWSIMQueryEvent *e);
static bool translateIMInitEvent(const QWSIMInitEvent *e);
+ static void updateImeStatus(QWidget *w, bool hasFocus);
};
QT_END_NAMESPACE
diff --git a/src/gui/inputmethod/qwsinputcontext_qws.cpp b/src/gui/inputmethod/qwsinputcontext_qws.cpp
index 46ac13d..6180c48 100644
--- a/src/gui/inputmethod/qwsinputcontext_qws.cpp
+++ b/src/gui/inputmethod/qwsinputcontext_qws.cpp
@@ -73,10 +73,17 @@ void QWSInputContext::reset()
void QWSInputContext::setFocusWidget( QWidget *w )
{
- QWidget *oldFocus = focusWidget();
+ QWidget *oldFocus = focusWidget();
if (oldFocus == w)
return;
+ if (w) {
+ QWSInputContext::updateImeStatus(w, true);
+ } else {
+ if (oldFocus)
+ QWSInputContext::updateImeStatus(oldFocus, false);
+ }
+
if (oldFocus) {
QWidget *tlw = oldFocus->window();
int winid = tlw->internalWinId();
@@ -224,7 +231,7 @@ bool QWSInputContext::translateIMEvent(QWidget *w, const QWSIMEvent *e)
Q_GUI_EXPORT void (*qt_qws_inputMethodStatusChanged)(QWidget*) = 0;
-void QInputContextPrivate::updateImeStatus(QWidget *w, bool hasFocus)
+void QWSInputContext::updateImeStatus(QWidget *w, bool hasFocus)
{
Q_UNUSED(hasFocus);
diff --git a/src/gui/inputmethod/qximinputcontext_x11.cpp b/src/gui/inputmethod/qximinputcontext_x11.cpp
index 1c8560f..b43a134 100644
--- a/src/gui/inputmethod/qximinputcontext_x11.cpp
+++ b/src/gui/inputmethod/qximinputcontext_x11.cpp
@@ -437,7 +437,9 @@ void QXIMInputContext::create_xim()
// reinitialize input context after the input method
// server (like SCIM) has been launched without
// requiring the user to manually switch focus.
- if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
+ if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled)
+ && focusWidget->testAttribute(Qt::WA_WState_Created)
+ && focusWidget->isEnabled())
setFocusWidget(focusWidget);
}
// following code fragment is not required for immodule
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 7bd6207..b1aac37 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -1400,6 +1400,9 @@ bool QAbstractItemView::event(QEvent *event)
case QEvent::FocusOut:
d->checkPersistentEditorFocus();
break;
+ case QEvent::FontChange:
+ d->doDelayedItemsLayout(); // the size of the items will change
+ break;
default:
break;
}
@@ -1421,10 +1424,10 @@ bool QAbstractItemView::viewportEvent(QEvent *event)
case QEvent::HoverEnter: {
QHoverEvent *he = static_cast<QHoverEvent*>(event);
d->hover = indexAt(he->pos());
- d->viewport->update(visualRect(d->hover));
+ update(d->hover);
break; }
case QEvent::HoverLeave: {
- d->viewport->update(visualRect(d->hover)); // update old
+ update(d->hover); // update old
d->hover = QModelIndex();
break; }
case QEvent::HoverMove: {
@@ -1637,7 +1640,7 @@ void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event)
if (d->isIndexValid(index)
&& d->isIndexEnabled(index)
&& d->sendDelegateEvent(index, event))
- d->viewport->update(visualRect(index));
+ update(index);
return;
}
@@ -2320,7 +2323,7 @@ bool QAbstractItemView::edit(const QModelIndex &index, EditTrigger trigger, QEve
}
if (d->sendDelegateEvent(index, event)) {
- d->viewport->update(visualRect(index));
+ update(index);
return true;
}
@@ -2921,7 +2924,7 @@ void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelInde
}
if (isVisible() && !d->delayedPendingLayout) {
// otherwise the items will be update later anyway
- d->viewport->update(visualRect(topLeft));
+ update(topLeft);
}
return;
}
@@ -3126,9 +3129,7 @@ void QAbstractItemView::selectionChanged(const QItemSelection &selected,
{
Q_D(QAbstractItemView);
if (isVisible() && updatesEnabled()) {
- d->setDirtyRegion(visualRegionForSelection(deselected));
- d->setDirtyRegion(visualRegionForSelection(selected));
- d->updateDirtyRegion();
+ d->viewport->update(visualRegionForSelection(deselected) | visualRegionForSelection(selected));
}
}
@@ -3156,15 +3157,13 @@ void QAbstractItemView::currentChanged(const QModelIndex &current, const QModelI
closeEditor(editor, QAbstractItemDelegate::NoHint);
}
if (isVisible()) {
- d->setDirtyRegion(visualRect(previous));
- d->updateDirtyRegion();
+ update(previous);
}
}
if (isVisible() && current.isValid() && !d->autoScrollTimer.isActive()) {
if (d->autoScroll)
scrollTo(current);
- d->setDirtyRegion(visualRect(current));
- d->updateDirtyRegion();
+ update(current);
edit(current, CurrentChanged, 0);
if (current.row() == (d->model->rowCount(d->root) - 1))
d->_q_fetchMore();
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index 5bd82d4..eb36178 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1195,7 +1195,7 @@ QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const
Q_D(const QHeaderView);
int visual = visualIndex(logicalIndex);
Q_ASSERT(visual != -1);
- return d->visualIndexResizeMode(visual);
+ return d->headerSectionResizeMode(visual);
}
/*!
@@ -1234,7 +1234,7 @@ void QHeaderView::setSortIndicatorShown(bool show)
if (sortIndicatorSection() < 0 || sortIndicatorSection() > count())
return;
- if (d->visualIndexResizeMode(sortIndicatorSection()) == ResizeToContents)
+ if (d->headerSectionResizeMode(sortIndicatorSection()) == ResizeToContents)
resizeSections();
d->viewport->update();
@@ -1971,20 +1971,19 @@ void QHeaderView::currentChanged(const QModelIndex &current, const QModelIndex &
if (d->orientation == Qt::Horizontal && current.column() != old.column()) {
if (old.isValid() && old.parent() == d->root)
- d->setDirtyRegion(QRect(sectionViewportPosition(old.column()), 0,
+ d->viewport->update(QRect(sectionViewportPosition(old.column()), 0,
sectionSize(old.column()), d->viewport->height()));
if (current.isValid() && current.parent() == d->root)
- d->setDirtyRegion(QRect(sectionViewportPosition(current.column()), 0,
+ d->viewport->update(QRect(sectionViewportPosition(current.column()), 0,
sectionSize(current.column()), d->viewport->height()));
} else if (d->orientation == Qt::Vertical && current.row() != old.row()) {
if (old.isValid() && old.parent() == d->root)
- d->setDirtyRegion(QRect(0, sectionViewportPosition(old.row()),
+ d->viewport->update(QRect(0, sectionViewportPosition(old.row()),
d->viewport->width(), sectionSize(old.row())));
if (current.isValid() && current.parent() == d->root)
- d->setDirtyRegion(QRect(0, sectionViewportPosition(current.row()),
+ d->viewport->update(QRect(0, sectionViewportPosition(current.row()),
d->viewport->width(), sectionSize(current.row())));
}
- d->updateDirtyRegion();
}
@@ -2938,22 +2937,25 @@ int QHeaderViewPrivate::lastVisibleVisualIndex() const
void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool useGlobalMode)
{
Q_Q(QHeaderView);
+ //stop the timer in case it is delayed
+ delayedResize.stop();
executePostedLayout();
if (sectionCount == 0)
return;
+
+ if (resizeRecursionBlock)
+ return;
+ resizeRecursionBlock = true;
+
invalidateCachedSizeHint();
+ const int lastVisibleSection = lastVisibleVisualIndex();
+
// find stretchLastSection if we have it
int stretchSection = -1;
- if (stretchLastSection && !useGlobalMode) {
- for (int i = sectionCount - 1; i >= 0; --i) {
- if (!isVisualIndexHidden(i)) {
- stretchSection = i;
- break;
- }
- }
- }
+ if (stretchLastSection && !useGlobalMode)
+ stretchSection = lastVisibleVisualIndex();
// count up the number of strected sections and how much space left for them
int lengthToStrech = (orientation == Qt::Horizontal ? viewport->width() : viewport->height());
@@ -2967,7 +2969,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
if (useGlobalMode && (i != stretchSection))
resizeMode = globalMode;
else
- resizeMode = (i == stretchSection ? QHeaderView::Stretch : visualIndexResizeMode(i));
+ resizeMode = (i == stretchSection ? QHeaderView::Stretch : headerSectionResizeMode(i));
if (resizeMode == QHeaderView::Stretch) {
++numberOfStretchedSections;
@@ -2999,7 +3001,6 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
int spanStartSection = 0;
int previousSectionLength = 0;
- const int lastVisibleSection = lastVisibleVisualIndex();
QHeaderView::ResizeMode previousSectionResizeMode = QHeaderView::Interactive;
@@ -3018,7 +3019,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
else
resizeMode = (i == stretchSection
? QHeaderView::Stretch
- : visualIndexResizeMode(i));
+ : newSectionResizeMode);
if (resizeMode == QHeaderView::Stretch && stretchSectionLength != -1) {
if (i == lastVisibleSection)
newSectionLength = qMax(stretchSectionLength, lastSectionSize);
@@ -3055,7 +3056,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
(sectionCount - spanStartSection) * previousSectionLength,
previousSectionResizeMode);
//Q_ASSERT(headerLength() == length);
-
+ resizeRecursionBlock = false;
viewport->update();
}
diff --git a/src/gui/itemviews/qheaderview_p.h b/src/gui/itemviews/qheaderview_p.h
index fbba69a..95bd84c 100644
--- a/src/gui/itemviews/qheaderview_p.h
+++ b/src/gui/itemviews/qheaderview_p.h
@@ -91,6 +91,7 @@ public:
stretchLastSection(false),
cascadingResizing(false),
forceInitializing(false),
+ resizeRecursionBlock(false),
stretchSections(0),
contentsSections(0),
minimumSectionSize(-1),
@@ -170,10 +171,6 @@ public:
if (!sectionHidden.isEmpty()) sectionHidden.setBit(visual, hidden);
}
- inline QHeaderView::ResizeMode visualIndexResizeMode(int visual) const {
- return headerSectionResizeMode(visual);
- }
-
inline bool hasAutoResizeSections() const {
return stretchSections || stretchLastSection || contentsSections;
}
@@ -211,7 +208,7 @@ public:
}
inline bool sectionIsCascadable(int visual) const {
- return visualIndexResizeMode(visual) == QHeaderView::Interactive;
+ return headerSectionResizeMode(visual) == QHeaderView::Interactive;
}
inline int modelSectionCount() const {
@@ -231,7 +228,6 @@ public:
inline void executePostedResize() const {
if (delayedResize.isActive() && state == NoState) {
- delayedResize.stop();
const_cast<QHeaderView*>(q_func())->resizeSections();
}
}
@@ -276,6 +272,7 @@ public:
bool stretchLastSection;
bool cascadingResizing;
bool forceInitializing;
+ bool resizeRecursionBlock;
int stretchSections;
int contentsSections;
int defaultSectionSize;
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index 07f0a38..a5a194f 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -588,7 +588,7 @@ void QListView::scrollTo(const QModelIndex &index, ScrollHint hint)
const QRect rect = visualRect(index);
if (hint == EnsureVisible && d->viewport->rect().contains(rect)) {
- d->setDirtyRegion(rect);
+ d->viewport->update(rect);
return;
}
@@ -755,7 +755,7 @@ void QListView::scrollContentsBy(int dx, int dy)
// update the dragged items
if (d->viewMode == IconMode) // ### move to dynamic class
if (!d->dynamicListView->draggedItems.isEmpty())
- d->setDirtyRegion(d->dynamicListView->draggedItemsRect().translated(dx, dy));
+ d->viewport->update(d->dynamicListView->draggedItemsRect().translated(dx, dy));
}
/*!
@@ -835,7 +835,7 @@ void QListView::mouseMoveEvent(QMouseEvent *e)
&& d->selectionMode != NoSelection) {
QRect rect(d->pressedPosition, e->pos() + QPoint(horizontalOffset(), verticalOffset()));
rect = rect.normalized();
- d->setDirtyRegion(d->mapToViewport(rect.united(d->elasticBand), d->viewMode == QListView::ListMode));
+ d->viewport->update(d->mapToViewport(rect.united(d->elasticBand), d->viewMode == QListView::ListMode));
d->elasticBand = rect;
}
}
@@ -849,7 +849,7 @@ void QListView::mouseReleaseEvent(QMouseEvent *e)
QAbstractItemView::mouseReleaseEvent(e);
// #### move this implementation into a dynamic class
if (d->showElasticBand && d->elasticBand.isValid()) {
- d->setDirtyRegion(d->mapToViewport(d->elasticBand, d->viewMode == QListView::ListMode));
+ d->viewport->update(d->mapToViewport(d->elasticBand, d->viewMode == QListView::ListMode));
d->elasticBand = QRect();
}
}
@@ -914,11 +914,11 @@ void QListView::dragMoveEvent(QDragMoveEvent *e)
if (d->canDecode(e)) {
// get old dragged items rect
QRect itemsRect = d->dynamicListView->itemsRect(d->dynamicListView->draggedItems);
- d->setDirtyRegion(itemsRect.translated(d->dynamicListView->draggedItemsDelta()));
+ d->viewport->update(itemsRect.translated(d->dynamicListView->draggedItemsDelta()));
// update position
d->dynamicListView->draggedItemsPos = e->pos();
// get new items rect
- d->setDirtyRegion(itemsRect.translated(d->dynamicListView->draggedItemsDelta()));
+ d->viewport->update(itemsRect.translated(d->dynamicListView->draggedItemsDelta()));
// set the item under the cursor to current
QModelIndex index;
if (d->movement == Snap) {
@@ -1007,12 +1007,12 @@ void QListView::internalDrop(QDropEvent *event)
for (int i = 0; i < indexes.count(); ++i) {
QModelIndex index = indexes.at(i);
QRect rect = rectForIndex(index);
- d->setDirtyRegion(d->mapToViewport(rect, d->viewMode == QListView::ListMode));
+ d->viewport->update(d->mapToViewport(rect, d->viewMode == QListView::ListMode));
QPoint dest = rect.topLeft() + delta;
if (isRightToLeft())
dest.setX(d->flipX(dest.x()) - rect.width());
d->dynamicListView->moveItem(index.row(), dest);
- d->setDirtyRegion(visualRect(index));
+ update(index);
}
stopAutoScroll();
d->dynamicListView->draggedItems.clear();
@@ -1455,9 +1455,9 @@ void QListView::setPositionForIndex(const QPoint &position, const QModelIndex &i
if (index.row() >= d->dynamicListView->items.count())
return;
const QSize oldContents = d->contentsSize();
- d->setDirtyRegion(visualRect(index)); // update old position
+ update(index); // update old position
d->dynamicListView->moveItem(index.row(), position);
- d->setDirtyRegion(visualRect(index)); // update new position
+ update(index); // update new position
if (d->contentsSize() != oldContents)
updateGeometries(); // update the scroll bars
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp
index 10bcb9a..91431c4 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.cpp
+++ b/src/gui/itemviews/qsortfilterproxymodel.cpp
@@ -1032,9 +1032,21 @@ void QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &sourc
}
}
- if (!source_rows_remove.isEmpty())
+ if (!source_rows_remove.isEmpty()) {
remove_source_items(m->proxy_rows, m->source_rows,
source_rows_remove, source_parent, Qt::Vertical);
+ QSet<int> source_rows_remove_set = source_rows_remove.toList().toSet();
+ QVector<QModelIndex>::iterator it = m->mapped_children.begin();
+ while (it != m->mapped_children.end()) {
+ const QModelIndex source_child_index = *it;
+ if (source_rows_remove_set.contains(source_child_index.row())) {
+ it = m->mapped_children.erase(it);
+ remove_from_mapping(source_child_index);
+ } else {
+ ++it;
+ }
+ }
+ }
if (!source_rows_resort.isEmpty()) {
// Re-sort the rows
@@ -1569,6 +1581,10 @@ bool QSortFilterProxyModel::hasChildren(const QModelIndex &parent) const
return false;
if (!d->model->hasChildren(source_parent))
return false;
+
+ if (d->model->canFetchMore(source_parent))
+ return true; //we assume we might have children that can be fetched
+
QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value();
return m->source_rows.count() != 0 && m->source_columns.count() != 0;
}
diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp
index 2902768..757ecf2 100644
--- a/src/gui/itemviews/qtableview.cpp
+++ b/src/gui/itemviews/qtableview.cpp
@@ -59,6 +59,138 @@
QT_BEGIN_NAMESPACE
+/** \internal
+ Add a span to the collection. the collection takes the ownership.
+ */
+void QSpanCollection::addSpan(QSpanCollection::Span *span)
+{
+ spans.append(span);
+ Index::iterator it_y = index.lowerBound(-span->top());
+ if (it_y == index.end() || it_y.key() != -span->top()) {
+ //there is no spans that starts with the row in the index, so create a sublist for it.
+ SubIndex sub_index;
+ if (it_y != index.end()) {
+ //the previouslist is the list of spans that sarts _before_ the row of the span.
+ // and which may intersect this row.
+ const SubIndex previousList = it_y.value();
+ foreach(Span *s, previousList) {
+ //If a subspans intersect the row, we need to split it into subspans
+ if(s->bottom() >= span->top())
+ sub_index.insert(-s->left(), s);
+ }
+ }
+ it_y = index.insert(-span->top(), sub_index);
+ //we will insert span to *it_y in the later loop
+ }
+
+ //insert the span as supspan in all the lists that intesects the span
+ while(-it_y.key() <= span->bottom()) {
+ (*it_y).insert(-span->left(), span);
+ if(it_y == index.begin())
+ break;
+ --it_y;
+ }
+}
+
+
+/** \internal
+* Has to be called after the height and width of a span is changed.
+*
+* old_height is the height before the change
+*
+* if the size of the span is now 0x0 the span will be deleted.
+*/
+void QSpanCollection::updateSpan(QSpanCollection::Span *span, int old_height)
+{
+ if (old_height < span->height()) {
+ //add the span as subspan in all the lists that intersect the new covered columns
+ Index::iterator it_y = index.lowerBound(-(span->top() + old_height - 1));
+ Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list
+ while (-it_y.key() <= span->bottom()) {
+ (*it_y).insert(-span->left(), span);
+ if(it_y == index.begin())
+ break;
+ --it_y;
+ }
+ } else if (old_height > span->height()) {
+ //remove the span from all the subspans lists that intersect the columns not covered anymore
+ Index::iterator it_y = index.lowerBound(-span->bottom());
+ Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list
+ while (-it_y.key() <= span->top() + old_height -1) {
+ if(-it_y.key() != span->bottom()) {
+ (*it_y).remove(-span->left());
+ if (it_y->isEmpty()) {
+ it_y = index.erase(it_y) - 1;
+ }
+ }
+ if(it_y == index.begin())
+ break;
+ --it_y;
+ }
+ }
+
+ if (span->width() == 0 && span->height() == 0) {
+ spans.removeOne(span);
+ delete span;
+ }
+}
+
+/** \internal
+ * \return a spans that spans over cell x,y (column,row) or 0 if there is none.
+ */
+QSpanCollection::Span *QSpanCollection::spanAt(int x, int y) const
+{
+ Index::const_iterator it_y = index.lowerBound(-y);
+ if (it_y == index.end())
+ return 0;
+ SubIndex::const_iterator it_x = (*it_y).lowerBound(-x);
+ if (it_x == (*it_y).end())
+ return 0;
+ Span *span = *it_x;
+ if (span->right() >= x && span->bottom() >= y)
+ return span;
+ return 0;
+}
+
+
+/** \internal
+* remove and deletes all spans inside the collection
+*/
+void QSpanCollection::clear()
+{
+ qDeleteAll(spans);
+ index.clear();
+ spans.clear();
+}
+
+/** \internal
+ * return a list to all the spans that spans over cells in the given rectangle
+ */
+QList<QSpanCollection::Span *> QSpanCollection::spansInRect(int x, int y, int w, int h) const
+{
+ QSet<Span *> list;
+ Index::const_iterator it_y = index.lowerBound(-y);
+ if(it_y == index.end())
+ --it_y;
+ while(-it_y.key() <= y + h) {
+ SubIndex::const_iterator it_x = (*it_y).lowerBound(-x);
+ if (it_x == (*it_y).end())
+ --it_x;
+ while(-it_x.key() <= x + w) {
+ Span *s = *it_x;
+ if (s->bottom() >= y && s->right() >= x)
+ list << s;
+ if (it_x == (*it_y).begin())
+ break;
+ --it_x;
+ }
+ if(it_y == index.begin())
+ break;
+ --it_y;
+ }
+ return list.toList();
+}
+
class QTableCornerButton : public QAbstractButton
{
Q_OBJECT
@@ -149,35 +281,40 @@ void QTableViewPrivate::trimHiddenSelections(QItemSelectionRange *range) const
*/
void QTableViewPrivate::setSpan(int row, int column, int rowSpan, int columnSpan)
{
- if (row < 0 || column < 0 || rowSpan < 0 || columnSpan < 0)
+ if (row < 0 || column < 0 || rowSpan <= 0 || columnSpan <= 0) {
+ qWarning() << "QTableView::setSpan: invalid span given: (" << row << "," << column << "," << rowSpan << "," << columnSpan << ")";
return;
- Span sp(row, column, rowSpan, columnSpan);
- QList<Span>::iterator it;
- for (it = spans.begin(); it != spans.end(); ++it) {
- if (((*it).top() == sp.top()) && ((*it).left() == sp.left())) {
- if ((sp.height() == 1) && (sp.width() == 1))
- spans.erase(it); // "Implicit" span (1, 1), no need to store it
- else
- *it = sp; // Replace
+ }
+ QSpanCollection::Span *sp = spans.spanAt(column, row);
+ if (sp) {
+ if (sp->top() != row || sp->left() != column) {
+ qWarning() << "QTableView::setSpan: span cannot overlap";
return;
}
+ if (rowSpan == 1 && columnSpan == 1) {
+ rowSpan = columnSpan = 0;
+ }
+ const int old_height = sp->height();
+ sp->m_bottom = row + rowSpan - 1;
+ sp->m_right = column + columnSpan - 1;
+ spans.updateSpan(sp, old_height);
+ return;
}
- spans.append(sp);
+ sp = new QSpanCollection::Span(row, column, rowSpan, columnSpan);
+ spans.addSpan(sp);
}
/*!
\internal
Gets the span information for the cell at (\a row, \a column).
*/
-QTableViewPrivate::Span QTableViewPrivate::span(int row, int column) const
+QSpanCollection::Span QTableViewPrivate::span(int row, int column) const
{
- QList<Span>::const_iterator it;
- for (it = spans.constBegin(); it != spans.constEnd(); ++it) {
- Span span = *it;
- if (isInSpan(row, column, span))
- return span;
- }
- return Span(row, column, 1, 1);
+ QSpanCollection::Span *sp = spans.spanAt(column, row);
+ if (sp)
+ return *sp;
+
+ return QSpanCollection::Span(row, column, 1, 1);
}
/*!
@@ -233,67 +370,9 @@ bool QTableViewPrivate::spanContainsSection(const QHeaderView *header, int logic
/*!
\internal
- Returns true if one or more spans intersect column \a column.
-*/
-bool QTableViewPrivate::spansIntersectColumn(int column) const
-{
- QList<Span>::const_iterator it;
- for (it = spans.constBegin(); it != spans.constEnd(); ++it) {
- Span span = *it;
- if (spanContainsColumn(column, span.left(), span.width()))
- return true;
- }
- return false;
-}
-
-/*!
- \internal
- Returns true if one or more spans intersect row \a row.
-*/
-bool QTableViewPrivate::spansIntersectRow(int row) const
-{
- QList<Span>::const_iterator it;
- for (it = spans.constBegin(); it != spans.constEnd(); ++it) {
- Span span = *it;
- if (spanContainsRow(row, span.top(), span.height()))
- return true;
- }
- return false;
-}
-
-/*!
- \internal
- Returns true if one or more spans intersect one or more columns.
-*/
-bool QTableViewPrivate::spansIntersectColumns(const QList<int> &columns) const
-{
- QList<int>::const_iterator it;
- for (it = columns.constBegin(); it != columns.constEnd(); ++it) {
- if (spansIntersectColumn(*it))
- return true;
- }
- return false;
-}
-
-/*!
- \internal
- Returns true if one or more spans intersect one or more rows.
-*/
-bool QTableViewPrivate::spansIntersectRows(const QList<int> &rows) const
-{
- QList<int>::const_iterator it;
- for (it = rows.constBegin(); it != rows.constEnd(); ++it) {
- if (spansIntersectRow(*it))
- return true;
- }
- return false;
-}
-
-/*!
- \internal
Returns the visual rect for the given \a span.
*/
-QRect QTableViewPrivate::visualSpanRect(const Span &span) const
+QRect QTableViewPrivate::visualSpanRect(const QSpanCollection::Span &span) const
{
Q_Q(const QTableView);
// vertical
@@ -319,42 +398,54 @@ QRect QTableViewPrivate::visualSpanRect(const Span &span) const
preparation for the main drawing loop.
\a drawn is a QBitArray of visualRowCountxvisualCoulumnCount which say if particular cell has been drawn
*/
-void QTableViewPrivate::drawAndClipSpans(const QRect &area, QPainter *painter,
+void QTableViewPrivate::drawAndClipSpans(const QRegion &area, QPainter *painter,
const QStyleOptionViewItemV4 &option, QBitArray *drawn,
int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn)
{
bool alternateBase = false;
QRegion region = viewport->rect();
- QList<Span>::const_iterator it;
- for (it = spans.constBegin(); it != spans.constEnd(); ++it) {
- Span span = *it;
+ QList<QSpanCollection::Span *> visibleSpans;
+ bool sectionMoved = verticalHeader->sectionsMoved() || horizontalHeader->sectionsMoved();
+
+ if (!sectionMoved) {
+ visibleSpans = spans.spansInRect(logicalColumn(firstVisualColumn), logicalRow(firstVisualRow),
+ lastVisualColumn - firstVisualColumn + 1, lastVisualRow - firstVisualRow + 1);
+ } else {
+ QSet<QSpanCollection::Span *> set;
+ for(int x = firstVisualColumn; x <= lastVisualColumn; x++)
+ for(int y = firstVisualRow; y <= lastVisualRow; y++)
+ set.insert(spans.spanAt(x,y));
+ set.remove(0);
+ visibleSpans = set.toList();
+ }
- int row = span.top();
- int col = span.left();
+ foreach (QSpanCollection::Span *span, visibleSpans) {
+ int row = span->top();
+ int col = span->left();
if (isHidden(row, col))
continue;
QModelIndex index = model->index(row, col, root);
if (!index.isValid())
continue;
- QRect rect = visualSpanRect(span);
+ QRect rect = visualSpanRect(*span);
rect.translate(scrollDelayOffset);
- if (!rect.intersects(area))
+ if (!area.intersects(rect))
continue;
QStyleOptionViewItemV4 opt = option;
opt.rect = rect;
- alternateBase = alternatingColors && (span.top() & 1);
+ alternateBase = alternatingColors && (span->top() & 1);
if (alternateBase)
opt.features |= QStyleOptionViewItemV2::Alternate;
else
opt.features &= ~QStyleOptionViewItemV2::Alternate;
drawCell(painter, opt, index);
region -= rect;
- for (int r = span.top(); r <= span.bottom(); ++r) {
+ for (int r = span->top(); r <= span->bottom(); ++r) {
const int vr = visualRow(r);
if (vr < firstVisualRow || vr > lastVisualRow)
continue;
- for (int c = span.left(); c <= span.right(); ++c) {
+ for (int c = span->left(); c <= span->right(); ++c) {
const int vc = visualColumn(c);
if (vc < firstVisualColumn || vc > lastVisualColumn)
continue;
@@ -753,7 +844,8 @@ void QTableView::paintEvent(QPaintEvent *event)
uint x = horizontalHeader->length() - horizontalHeader->offset() - (rightToLeft ? 0 : 1);
uint y = verticalHeader->length() - verticalHeader->offset() - 1;
- QVector<QRect> rects = event->region().rects();
+ const QRegion region = event->region().translated(offset);
+ const QVector<QRect> rects = region.rects();
//firstVisualRow is the visual index of the first visible row. lastVisualRow is the visual index of the last visible Row.
//same goes for ...VisualColumn
@@ -773,9 +865,13 @@ void QTableView::paintEvent(QPaintEvent *event)
QBitArray drawn((lastVisualRow - firstVisualRow + 1) * (lastVisualColumn - firstVisualColumn + 1));
+ if (d->hasSpans()) {
+ d->drawAndClipSpans(region, &painter, option, &drawn,
+ firstVisualRow, lastVisualRow, firstVisualColumn, lastVisualColumn);
+ }
+
for (int i = 0; i < rects.size(); ++i) {
QRect dirtyArea = rects.at(i);
- dirtyArea.translate(offset);
dirtyArea.setBottom(qMin(dirtyArea.bottom(), int(y)));
if (rightToLeft) {
dirtyArea.setLeft(qMax(dirtyArea.left(), d->viewport->width() - int(x)));
@@ -783,10 +879,6 @@ void QTableView::paintEvent(QPaintEvent *event)
dirtyArea.setRight(qMin(dirtyArea.right(), int(x)));
}
- if (d->hasSpans())
- d->drawAndClipSpans(dirtyArea, &painter, option, &drawn,
- firstVisualRow, lastVisualRow, firstVisualColumn, lastVisualColumn);
-
// get the horizontal start and end visual sections
int left = horizontalHeader->visualIndexAt(dirtyArea.left());
int right = horizontalHeader->visualIndexAt(dirtyArea.right());
@@ -913,7 +1005,7 @@ QModelIndex QTableView::indexAt(const QPoint &pos) const
int c = columnAt(pos.x());
if (r >= 0 && c >= 0) {
if (d->hasSpans()) {
- QTableViewPrivate::Span span = d->span(r, c);
+ QSpanCollection::Span span = d->span(r, c);
r = span.top();
c = span.left();
}
@@ -1011,14 +1103,14 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi
--visualRow;
if (d->hasSpans()) {
int row = d->logicalRow(visualRow);
- QTableViewPrivate::Span span = d->span(row, current.column());
+ QSpanCollection::Span span = d->span(row, current.column());
visualRow = d->visualRow(span.top());
visualColumn = d->visualColumn(span.left());
}
break;
case MoveDown:
if (d->hasSpans()) {
- QTableViewPrivate::Span span = d->span(current.row(), current.column());
+ QSpanCollection::Span span = d->span(current.row(), current.column());
visualRow = d->visualRow(d->rowSpanEndLogical(span.top(), span.height()));
}
#ifdef QT_KEYPAD_NAVIGATION
@@ -1030,7 +1122,7 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi
++visualRow;
if (d->hasSpans()) {
int row = d->logicalRow(visualRow);
- QTableViewPrivate::Span span = d->span(row, current.column());
+ QSpanCollection::Span span = d->span(row, current.column());
visualColumn = d->visualColumn(span.left());
}
break;
@@ -1058,7 +1150,7 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi
--visualColumn;
if (d->hasSpans()) {
int column = d->logicalColumn(visualColumn);
- QTableViewPrivate::Span span = d->span(current.row(), column);
+ QSpanCollection::Span span = d->span(current.row(), column);
visualRow = d->visualRow(span.top());
visualColumn = d->visualColumn(span.left());
}
@@ -1078,7 +1170,7 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi
} // else MoveRight
case MoveRight:
if (d->hasSpans()) {
- QTableViewPrivate::Span span = d->span(current.row(), current.column());
+ QSpanCollection::Span span = d->span(current.row(), current.column());
visualColumn = d->visualColumn(d->columnSpanEndLogical(span.left(), span.width()));
}
++visualColumn;
@@ -1086,7 +1178,7 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi
++visualColumn;
if (d->hasSpans()) {
int column = d->logicalColumn(visualColumn);
- QTableViewPrivate::Span span = d->span(current.row(), column);
+ QSpanCollection::Span span = d->span(current.row(), column);
visualRow = d->visualRow(span.top());
}
break;
@@ -1161,9 +1253,8 @@ void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionF
int right = qMax(d->visualColumn(tl.column()), d->visualColumn(br.column()));
do {
expanded = false;
- QList<QTableViewPrivate::Span>::const_iterator it;
- for (it = d->spans.constBegin(); it != d->spans.constEnd(); ++it) {
- QTableViewPrivate::Span span = *it;
+ foreach (QSpanCollection::Span *it, d->spans.spans) {
+ const QSpanCollection::Span &span = *it;
int t = d->visualRow(span.top());
int l = d->visualColumn(span.left());
int b = d->visualRow(d->rowSpanEndLogical(span.top(), span.height()));
@@ -1253,7 +1344,7 @@ QRegion QTableView::visualRegionForSelection(const QItemSelection &selection) co
bool verticalMoved = verticalHeader()->sectionsMoved();
bool horizontalMoved = horizontalHeader()->sectionsMoved();
- if ((verticalMoved && horizontalMoved) || d->hasSpans()) {
+ if ((verticalMoved && horizontalMoved) || (d->hasSpans() && (verticalMoved || horizontalMoved))) {
for (int i = 0; i < selection.count(); ++i) {
QItemSelectionRange range = selection.at(i);
if (range.parent() != d->root || !range.isValid())
@@ -1296,9 +1387,19 @@ QRegion QTableView::visualRegionForSelection(const QItemSelection &selection) co
if (range.parent() != d->root || !range.isValid())
continue;
d->trimHiddenSelections(&range);
- QRect tl = visualRect(range.topLeft());
- QRect br = visualRect(range.bottomRight());
- selectionRegion += QRegion(tl|br);
+
+ const int rtop = rowViewportPosition(range.top());
+ const int rbottom = rowViewportPosition(range.bottom()) + rowHeight(range.bottom());
+ const int rleft = columnViewportPosition(range.left());
+ const int rright = columnViewportPosition(range.right()) + columnWidth(range.right());
+ selectionRegion += QRect(QPoint(rleft, rtop), QPoint(rright, rbottom));
+ if (d->hasSpans()) {
+ foreach (QSpanCollection::Span *s,
+ d->spans.spansInRect(range.left(), range.top(), range.width(), range.height())) {
+ if (range.contains(s->top(), s->left(), range.parent()))
+ selectionRegion += d->visualSpanRect(*s);
+ }
+ }
}
}
@@ -1874,7 +1975,7 @@ QRect QTableView::visualRect(const QModelIndex &index) const
d->executePostedLayout();
if (d->hasSpans()) {
- QTableViewPrivate::Span span = d->span(index.row(), index.column());
+ QSpanCollection::Span span = d->span(index.row(), index.column());
return d->visualSpanRect(span);
}
@@ -1903,7 +2004,7 @@ void QTableView::scrollTo(const QModelIndex &index, ScrollHint hint)
|| isIndexHidden(index))
return;
- QTableViewPrivate::Span span;
+ QSpanCollection::Span span;
if (d->hasSpans())
span = d->span(index.row(), index.column());
@@ -2010,7 +2111,7 @@ void QTableView::scrollTo(const QModelIndex &index, ScrollHint hint)
}
}
- d->setDirtyRegion(visualRect(index));
+ update(index);
}
/*!
@@ -2058,7 +2159,7 @@ void QTableView::timerEvent(QTimerEvent *event)
QRect rect;
int viewportHeight = d->viewport->height();
int viewportWidth = d->viewport->width();
- if (d->hasSpans() && d->spansIntersectColumns(d->columnsToUpdate)) {
+ if (d->hasSpans()) {
rect = QRect(0, 0, viewportWidth, viewportHeight);
} else {
for (int i = d->columnsToUpdate.size()-1; i >= 0; --i) {
@@ -2083,7 +2184,7 @@ void QTableView::timerEvent(QTimerEvent *event)
int viewportHeight = d->viewport->height();
int viewportWidth = d->viewport->width();
int top;
- if (d->hasSpans() && d->spansIntersectRows(d->rowsToUpdate)) {
+ if (d->hasSpans()) {
top = 0;
} else {
top = viewportHeight;
@@ -2114,7 +2215,7 @@ void QTableView::rowMoved(int, int oldIndex, int newIndex)
updateGeometries();
int logicalOldIndex = d->verticalHeader->logicalIndex(oldIndex);
int logicalNewIndex = d->verticalHeader->logicalIndex(newIndex);
- if (d->hasSpans() && (d->spansIntersectRow(logicalOldIndex) || d->spansIntersectRow(logicalNewIndex))) {
+ if (d->hasSpans()) {
d->viewport->update();
} else {
int oldTop = rowViewportPosition(logicalOldIndex);
@@ -2142,7 +2243,7 @@ void QTableView::columnMoved(int, int oldIndex, int newIndex)
updateGeometries();
int logicalOldIndex = d->horizontalHeader->logicalIndex(oldIndex);
int logicalNewIndex = d->horizontalHeader->logicalIndex(newIndex);
- if (d->hasSpans() && (d->spansIntersectColumn(logicalOldIndex) || d->spansIntersectColumn(logicalNewIndex))) {
+ if (d->hasSpans()) {
d->viewport->update();
} else {
int oldLeft = columnViewportPosition(logicalOldIndex);
@@ -2325,7 +2426,7 @@ bool QTableView::isIndexHidden(const QModelIndex &index) const
if (isRowHidden(index.row()) || isColumnHidden(index.column()))
return true;
if (d->hasSpans()) {
- QTableViewPrivate::Span span = d->span(index.row(), index.column());
+ QSpanCollection::Span span = d->span(index.row(), index.column());
return !((span.top() == index.row()) && (span.left() == index.column()));
}
return false;
diff --git a/src/gui/itemviews/qtableview_p.h b/src/gui/itemviews/qtableview_p.h
index b08eabd..3f3dd36 100644
--- a/src/gui/itemviews/qtableview_p.h
+++ b/src/gui/itemviews/qtableview_p.h
@@ -53,12 +53,69 @@
// We mean it.
//
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QSet>
+#include <QtCore/QDebug>
#include "private/qabstractitemview_p.h"
#ifndef QT_NO_TABLEVIEW
QT_BEGIN_NAMESPACE
+/** \internal
+*
+* This is a list of span with a binary index to look up quickly a span at a certain index.
+*
+* The index is a map of map.
+* spans are mentaly divided into sub spans so that the start of any subspans doesn't overlap
+* with any other subspans. There is no real representation of the subspans.
+* The key of the first map is the row where the subspan starts, the value of the first map is
+* a list (map) of all subspans that starts at the same row. It is indexed with its row
+*/
+class QSpanCollection
+{
+public:
+ struct Span
+ {
+ int m_top;
+ int m_left;
+ int m_bottom;
+ int m_right;
+ Span()
+ : m_top(-1), m_left(-1), m_bottom(-1), m_right(-1) { }
+ Span(int row, int column, int rowCount, int columnCount)
+ : m_top(row), m_left(column), m_bottom(row+rowCount-1), m_right(column+columnCount-1) { }
+ inline int top() const { return m_top; }
+ inline int left() const { return m_left; }
+ inline int bottom() const { return m_bottom; }
+ inline int right() const { return m_right; }
+ inline int height() const { return m_bottom - m_top + 1; }
+ inline int width() const { return m_right - m_left + 1; }
+ };
+
+ ~QSpanCollection()
+ {
+ qDeleteAll(spans);
+ }
+
+ void addSpan(Span *span);
+ void updateSpan(Span *span, int old_height);
+ Span *spanAt(int x, int y) const;
+ void clear();
+ QList<Span *> spansInRect(int x, int y, int w, int h) const;
+
+ QList<Span *> spans; //lists of all spans
+private:
+ //the indexes are negative so the QMap::lowerBound do what i need.
+ typedef QMap<int, Span *> SubIndex;
+ typedef QMap<int, SubIndex> Index;
+ Index index;
+};
+
+Q_DECLARE_TYPEINFO ( QSpanCollection::Span, Q_MOVABLE_TYPE);
+
+
class QTableViewPrivate : public QAbstractItemViewPrivate
{
Q_DECLARE_PUBLIC(QTableView)
@@ -98,11 +155,7 @@ public:
int sectionSpanEndLogical(const QHeaderView *header, int logical, int span) const;
int sectionSpanSize(const QHeaderView *header, int logical, int span) const;
bool spanContainsSection(const QHeaderView *header, int logical, int spanLogical, int span) const;
- bool spansIntersectColumn(int column) const;
- bool spansIntersectRow(int row) const;
- bool spansIntersectColumns(const QList<int> &columns) const;
- bool spansIntersectRows(const QList<int> &rows) const;
- void drawAndClipSpans(const QRect &area, QPainter *painter,
+ void drawAndClipSpans(const QRegion &area, QPainter *painter,
const QStyleOptionViewItemV4 &option, QBitArray *drawn,
int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn);
void drawCell(QPainter *painter, const QStyleOptionViewItemV4 &option, const QModelIndex &index);
@@ -121,27 +174,10 @@ public:
bool sortingEnabled;
bool geometryRecursionBlock;
- struct Span
- {
- int m_top;
- int m_left;
- int m_bottom;
- int m_right;
- Span()
- : m_top(-1), m_left(-1), m_bottom(-1), m_right(-1) { }
- Span(int row, int column, int rowCount, int columnCount)
- : m_top(row), m_left(column), m_bottom(row+rowCount-1), m_right(column+columnCount-1) { }
- inline int top() const { return m_top; }
- inline int left() const { return m_left; }
- inline int bottom() const { return m_bottom; }
- inline int right() const { return m_right; }
- inline int height() const { return m_bottom - m_top + 1; }
- inline int width() const { return m_right - m_left + 1; }
- };
- QList<Span> spans;
+ QSpanCollection spans;
void setSpan(int row, int column, int rowSpan, int columnSpan);
- Span span(int row, int column) const;
+ QSpanCollection::Span span(int row, int column) const;
inline int rowSpan(int row, int column) const {
return span(row, column).height();
}
@@ -149,17 +185,7 @@ public:
return span(row, column).width();
}
inline bool hasSpans() const {
- return !spans.isEmpty();
- }
- inline bool spanContainsRow(int row, int spanRow, int span) const {
- return spanContainsSection(verticalHeader, row, spanRow, span);
- }
- inline bool spanContainsColumn(int column, int spanColumn, int span) const {
- return spanContainsSection(horizontalHeader, column, spanColumn, span);
- }
- inline bool isInSpan(int row, int column, const Span &span) const {
- return spanContainsRow(row, span.top(), span.height())
- && spanContainsColumn(column, span.left(), span.width());
+ return !spans.spans.isEmpty();
}
inline int rowSpanHeight(int row, int span) const {
return sectionSpanSize(verticalHeader, row, span);
@@ -194,7 +220,7 @@ public:
return isColumnHidden(c) || !isCellEnabled(r, c);
}
- QRect visualSpanRect(const Span &span) const;
+ QRect visualSpanRect(const QSpanCollection::Span &span) const;
void _q_selectRow(int row);
void _q_selectColumn(int column);
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 2aa0c57..61f1b5b 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -1140,7 +1140,7 @@ void QTreeView::scrollTo(const QModelIndex &index, ScrollHint hint)
if (rect.isEmpty()) {
// nothing to do
} else if (hint == EnsureVisible && area.contains(rect)) {
- d->setDirtyRegion(rect);
+ d->viewport->update(rect);
// nothing to do
} else {
bool above = (hint == EnsureVisible
@@ -2019,6 +2019,7 @@ int QTreeView::verticalOffset() const
// If we are scrolling per item and have non-uniform row heights,
// finding the vertical offset in pixels is going to be relatively slow.
// ### find a faster way to do this
+ d->executePostedLayout();
int offset = 0;
for (int i = 0; i < d->viewItems.count(); ++i) {
if (i == verticalScrollBar()->value())
@@ -3507,6 +3508,7 @@ void QTreeViewPrivate::updateScrollBars()
int QTreeViewPrivate::itemDecorationAt(const QPoint &pos) const
{
+ const_cast<QTreeView *>(q_func())->executeDelayedItemsLayout();
int x = pos.x();
int column = header->logicalIndexAt(x);
if (column != 0)
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index c4224ed..d5a96bd 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -2055,9 +2055,13 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason)
QWidget *prev = focus_widget;
focus_widget = focus;
- if (prev && reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason &&
- prev->testAttribute(Qt::WA_InputMethodEnabled)) {
- QInputContext *qic = prev->inputContext();
+ if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
+ && prev->testAttribute(Qt::WA_InputMethodEnabled))
+ // Do reset the input context, in case the new focus widget won't accept keyboard input
+ // or it is not created fully yet.
+ || (focus_widget && (!focus_widget->testAttribute(Qt::WA_InputMethodEnabled)
+ || !focus_widget->testAttribute(Qt::WA_WState_Created))))) {
+ QInputContext *qic = prev->inputContext();
if(qic) {
qic->reset();
qic->setFocusWidget(0);
@@ -2086,8 +2090,9 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason)
if(focus && QApplicationPrivate::focus_widget == focus) {
if (focus->testAttribute(Qt::WA_InputMethodEnabled)) {
QInputContext *qic = focus->inputContext();
- if (qic && focus_widget->testAttribute(Qt::WA_WState_Created))
- qic->setFocusWidget( focus_widget );
+ if (qic && focus->testAttribute(Qt::WA_WState_Created)
+ && focus->isEnabled())
+ qic->setFocusWidget(focus);
}
QFocusEvent in(QEvent::FocusIn, reason);
QPointer<QWidget> that = focus;
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index 5f8c572..ae99e83 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -1638,15 +1638,6 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
bool inNonClientArea = false;
GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0,
sizeof(where), 0, &where);
- if(ekind == kEventMouseMoved && qt_mac_app_fullscreen &&
- QApplication::desktop()->screenNumber(QPoint(where.h, where.v)) ==
- QApplication::desktop()->primaryScreen()) {
- if(where.v <= 0)
- ShowMenuBar();
- else if(qt_mac_window_at(where.h, where.v, 0) != inMenuBar)
- HideMenuBar();
- }
-
#if defined(DEBUG_MOUSE_MAPS)
const char *edesc = 0;
switch(ekind) {
diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp
index 2deda8e..fcfd2a4 100644
--- a/src/gui/kernel/qapplication_qws.cpp
+++ b/src/gui/kernel/qapplication_qws.cpp
@@ -195,14 +195,14 @@ QString qws_dataDir()
if (!result.isEmpty())
return result;
QByteArray dataDir = QString(QLatin1String("/tmp/qtembedded-%1")).arg(qws_display_id).toLocal8Bit();
- if (mkdir(dataDir, 0700)) {
+ if (QT_MKDIR(dataDir, 0700)) {
if (errno != EEXIST) {
qFatal("Cannot create Qt for Embedded Linux data directory: %s", dataDir.constData());
}
}
- struct stat buf;
- if (lstat(dataDir, &buf))
+ QT_STATBUF buf;
+ if (QT_LSTAT(dataDir, &buf))
qFatal("stat failed for Qt for Embedded Linux data directory: %s", dataDir.constData());
if (!S_ISDIR(buf.st_mode))
@@ -2280,7 +2280,8 @@ void qt_init(QApplicationPrivate *priv, int type)
qt_appType = QApplication::Type(type);
qws_single_process = true;
QWSServer::startup(flags);
- setenv("QWS_DISPLAY", qws_display_spec.constData(), 0);
+ if (!display) // if not already set
+ qputenv("QWS_DISPLAY", qws_display_spec);
}
if(qt_is_gui_used) {
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 1df442f..b1270bc 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -829,8 +829,11 @@ bool QApplicationPrivate::x11_apply_settings()
QColor(strlist[i]));
}
- if (groupCount == QPalette::NColorGroups)
- QApplicationPrivate::setSystemPalette(pal);
+ // ### Fix properly for 4.6
+ if (!(QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"))) {
+ if (groupCount == QPalette::NColorGroups)
+ QApplicationPrivate::setSystemPalette(pal);
+ }
int kdeSessionVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt();
@@ -887,11 +890,15 @@ bool QApplicationPrivate::x11_apply_settings()
}
}
+ static QString currentStyleName = stylename;
if (QCoreApplication::startingUp()) {
if (!stylename.isEmpty() && !QApplicationPrivate::styleOverride)
QApplicationPrivate::styleOverride = new QString(stylename);
} else {
- QApplication::setStyle(stylename);
+ if (currentStyleName != stylename) {
+ currentStyleName = stylename;
+ QApplication::setStyle(stylename);
+ }
}
int num =
@@ -1355,8 +1362,10 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::darkBlue);
}
- QApplicationPrivate::setSystemPalette(pal);
-
+ // QGtkStyle sets it's own system palette
+ if (!(QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"))) {
+ QApplicationPrivate::setSystemPalette(pal);
+ }
QColor::setAllowX11ColorNames(allowX11ColorNames);
}
@@ -3351,15 +3360,24 @@ int QApplication::x11ProcessEvent(XEvent* event)
// update the size for desktop widget
int scr = X11->ptrXRRRootToScreen(X11->display, event->xany.window);
- QWidget *w = desktop()->screen(scr);
+ QDesktopWidget *desktop = QApplication::desktop();
+ QWidget *w = desktop->screen(scr);
QSize oldSize(w->size());
w->data->crect.setWidth(DisplayWidth(X11->display, scr));
w->data->crect.setHeight(DisplayHeight(X11->display, scr));
- if (w->size() != oldSize) {
- QResizeEvent e(w->size(), oldSize);
- QApplication::sendEvent(w, &e);
- emit desktop()->resized(scr);
- }
+ QVarLengthArray<QRect> oldSizes(desktop->numScreens());
+ for (int i = 0; i < desktop->numScreens(); ++i)
+ oldSizes[i] = desktop->screenGeometry(i);
+ QResizeEvent e(w->size(), oldSize);
+ QApplication::sendEvent(w, &e);
+ for (int i = 0; i < qMin(oldSizes.count(), desktop->numScreens()); ++i) {
+ if (oldSizes[i] != desktop->screenGeometry(i))
+ emit desktop->resized(i);
+ }
+ for (int i = oldSizes.count(); i < desktop->numScreens(); ++i)
+ emit desktop->resized(i); // added
+ for (int i = desktop->numScreens(); i < oldSizes.count(); ++i)
+ emit desktop->resized(i); // removed
}
#endif // QT_NO_XRANDR
diff --git a/src/gui/kernel/qcocoaapplication_mac.mm b/src/gui/kernel/qcocoaapplication_mac.mm
index f95f004f..a3cc2c1 100644
--- a/src/gui/kernel/qcocoaapplication_mac.mm
+++ b/src/gui/kernel/qcocoaapplication_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
/****************************************************************************
**
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
index 650ebbd..6571068 100644
--- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
+++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
/****************************************************************************
**
@@ -107,6 +107,8 @@ static void cleanupCocoaApplicationDelegate()
- (id)init
{
self = [super init];
+ if (self)
+ inLaunch = true;
return self;
}
@@ -198,12 +200,26 @@ static void cleanupCocoaApplicationDelegate()
return reply;
}
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
+{
+ Q_UNUSED(aNotification);
+ inLaunch = false;
+}
+
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
{
- unsigned int ix;
- for( ix = 0; ix < [filenames count]; ix++) {
- NSString *fileName = [filenames objectAtIndex:ix];
- qApp->postEvent(qApp, new QFileOpenEvent(QCFString::toQString((CFStringRef)fileName)));
+ for (NSString *fileName in filenames) {
+ QString qtFileName = qt_mac_NSStringToQString(fileName);
+ if (inLaunch) {
+ // We need to be careful because Cocoa will be nice enough to take
+ // command line arguments and send them to us as events. Given the history
+ // of Qt Applications, this will result in behavior people don't want, as
+ // they might be doing the opening themselves with the command line parsing.
+ if (qApp->arguments().contains(qtFileName))
+ continue;
+ }
+ QFileOpenEvent foe(qtFileName);
+ qt_sendSpontaneousEvent(qAppInstance(), &foe);
}
if (reflectionDelegate &&
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h b/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h
index c5336f1..fca2a15 100644
--- a/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h
+++ b/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h
@@ -107,6 +107,7 @@ QT_FORWARD_DECLARE_CLASS(QApplicationPrivate);
NSMenu *dockMenu;
QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader;
id <NSApplicationDelegate> reflectionDelegate;
+ bool inLaunch;
}
+ (QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate)*)sharedDelegate;
- (void)setDockMenu:(NSMenu *)newMenu;
diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm
index 7ecb765..e836286 100644
--- a/src/gui/kernel/qcocoamenuloader_mac.mm
+++ b/src/gui/kernel/qcocoamenuloader_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#include "qmacdefines_mac.h"
#ifdef QT_MAC_USE_COCOA
diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/gui/kernel/qcocoapanel_mac.mm
index 6aeee34..c69826f 100644
--- a/src/gui/kernel/qcocoapanel_mac.mm
+++ b/src/gui/kernel/qcocoapanel_mac.mm
@@ -43,10 +43,16 @@
#ifdef QT_MAC_USE_COCOA
#import <private/qt_cocoa_helpers_mac_p.h>
#import <private/qcocoawindow_mac_p.h>
+#import <private/qcocoawindowdelegate_mac_p.h>
+#import <private/qcocoaview_mac_p.h>
#import <private/qcocoawindowcustomthemeframe_mac_p.h>
#include <QtGui/QWidget>
+QT_FORWARD_DECLARE_CLASS(QWidget);
+QT_BEGIN_NAMESPACE
+extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
+QT_END_NAMESPACE
QT_USE_NAMESPACE
@implementation QT_MANGLE_NAMESPACE(QCocoaPanel)
@@ -60,18 +66,115 @@ QT_USE_NAMESPACE
return !(isPopup || isToolTip);
}
+/***********************************************************************
+ BEGIN Copy and Paste between QCocoaWindow and QCocoaPanel
+ This is a bit unfortunate, but thanks to the dynamic dispatch we
+ have to duplicate this code or resort to really silly forwarding methods
+**************************************************************************/
+
+/*
+ The methods keyDown, keyUp, and flagsChanged... These really shouldn't ever
+ get hit. We automatically say we can be first responder if we are a window.
+ So, the handling should get handled by the view. This is here more as a
+ last resort (i.e., this is code that can potentially be removed).
+ */
+
+- (void)keyDown:(NSEvent *)theEvent
+{
+ bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
+ if (!keyOK)
+ [super keyDown:theEvent];
+}
+
+- (void)keyUp:(NSEvent *)theEvent
+{
+ bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
+ if (!keyOK)
+ [super keyUp:theEvent];
+}
+
+- (void)flagsChanged:(NSEvent *)theEvent
+{
+ qt_dispatchModifiersChanged(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
+ [super flagsChanged:theEvent];
+}
+
+
+- (void)tabletProximity:(NSEvent *)tabletEvent
+{
+ qt_dispatchTabletProximityEvent(tabletEvent);
+}
+
- (void)sendEvent:(NSEvent *)event
{
[self retain];
- [super sendEvent:event];
+
+ QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
+ QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_nativeview_for(widget));
+ Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]);
+
+ // sometimes need to redirect mouse events to the popup.
+ QWidget *popup = qAppInstance()->activePopupWidget();
+ if (popup && popup != widget) {
+ switch([event type])
+ {
+ case NSLeftMouseDown:
+ qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton);
+ // Don't call super here. This prevents us from getting the mouseUp event,
+ // which we need to send even if the mouseDown event was not accepted.
+ // (this is standard Qt behavior.)
+ break;
+ case NSRightMouseDown:
+ case NSOtherMouseDown:
+ if (!qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton))
+ [super sendEvent:event];
+ break;
+ case NSLeftMouseUp:
+ case NSRightMouseUp:
+ case NSOtherMouseUp:
+ if (!qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonRelease, mouseButton))
+ [super sendEvent:event];
+ break;
+ case NSMouseMoved:
+ qt_mac_handleMouseEvent(view, event, QEvent::MouseMove, Qt::NoButton);
+ break;
+ case NSLeftMouseDragged:
+ case NSRightMouseDragged:
+ case NSOtherMouseDragged:
+ [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->view = view;
+ [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->theEvent = event;
+ if (!qt_mac_handleMouseEvent(view, event, QEvent::MouseMove, mouseButton))
+ [super sendEvent:event];
+ break;
+ default:
+ [super sendEvent:event];
+ break;
+ }
+ } else {
+ [super sendEvent:event];
+ }
qt_mac_dispatchNCMouseMessage(self, event, [self QT_MANGLE_NAMESPACE(qt_qwidget)], leftButtonIsRightButton);
+
+
[self release];
}
+- (BOOL)makeFirstResponder:(NSResponder *)responder
+{
+ // For some reason Cocoa wants to flip the first responder
+ // when Qt doesn't want to, sorry, but "No" :-)
+ if (responder == nil && qApp->focusWidget())
+ return NO;
+ return [super makeFirstResponder:responder];
+}
+
+/***********************************************************************
+ END Copy and Paste between QCocoaWindow and QCocoaPanel
+***********************************************************************/
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask
{
if (styleMask & QtMacCustomizeWindow)
- return [QCocoaWindowCustomThemeFrame class];
+ return [QT_MANGLE_NAMESPACE(QCocoaWindowCustomThemeFrame) class];
return [super frameViewClassForStyleMask:styleMask];
}
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 19367d1..dcb3564 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -181,6 +181,7 @@ QT_FORWARD_DECLARE_CLASS(QAbstractScrollAreaPrivate)
QT_FORWARD_DECLARE_CLASS(QPaintEvent)
QT_FORWARD_DECLARE_CLASS(QPainter)
QT_FORWARD_DECLARE_CLASS(QHoverEvent)
+QT_FORWARD_DECLARE_CLASS(QCursor)
QT_USE_NAMESPACE
extern "C" {
extern NSString *NSTextInputReplacementRangeAttributeName;
@@ -195,6 +196,7 @@ extern "C" {
if (self) {
[self finishInitWithQWidget:widget widgetPrivate:widgetprivate];
}
+ composingText = new QString();
composing = false;
sendKeyEvents = true;
[self setHidden:YES];
@@ -236,6 +238,34 @@ extern "C" {
}
}
+- (void)resetCursorRects
+{
+ QWidget *cursorWidget = qwidget;
+
+ if (cursorWidget->testAttribute(Qt::WA_TransparentForMouseEvents))
+ cursorWidget = QApplication::widgetAt(qwidget->mapToGlobal(qwidget->rect().center()));
+
+ if (cursorWidget == 0)
+ return;
+
+ if (!cursorWidget->testAttribute(Qt::WA_SetCursor)) {
+ [super resetCursorRects];
+ return;
+ }
+
+ QRegion mask = qt_widget_private(cursorWidget)->extra->mask;
+ NSCursor *nscursor = static_cast<NSCursor *>(nsCursorForQCursor(cursorWidget->cursor()));
+ if (mask.isEmpty()) {
+ [self addCursorRect:[qt_mac_nativeview_for(cursorWidget) visibleRect] cursor:nscursor];
+ } else {
+ const QVector<QRect> &rects = mask.rects();
+ for (int i = 0; i < rects.size(); ++i) {
+ const QRect &rect = rects.at(i);
+ [self addCursorRect:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()) cursor:nscursor];
+ }
+ }
+}
+
- (void)removeDropData
{
if (dropData) {
@@ -300,11 +330,13 @@ extern "C" {
NSPoint windowPoint = [sender draggingLocation];
NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint];
NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
+ NSDragOperation nsActions = [sender draggingSourceOperationMask];
QPoint posDrag(localPoint.x, localPoint.y);
- if (qt_mac_mouse_inside_answer_rect(posDrag))
+ if (qt_mac_mouse_inside_answer_rect(posDrag)
+ && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions)
return QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction));
// send drag move event to the widget
- NSDragOperation nsActions = [sender draggingSourceOperationMask];
+ QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions;
Qt::DropActions qtAllowed = QT_PREPEND_NAMESPACE(qt_mac_mapNSDragOperations)(nsActions);
QMimeData *mimeData = dropData;
if (QDragManager::self()->source())
@@ -364,6 +396,7 @@ extern "C" {
- (void)dealloc
{
+ delete composingText;
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
@@ -599,7 +632,7 @@ extern "C" {
for (NSView *lookView in viewsToLookAt) {
NSPoint tmpPoint = [lookView convertPoint:windowPoint fromView:nil];
for (NSView *view in [lookView subviews]) {
- if (view == mouseView)
+ if (view == mouseView || [view isHidden])
continue;
NSRect frameRect = [view frame];
if (NSMouseInRect(tmpPoint, [view frame], [view isFlipped]))
@@ -618,7 +651,7 @@ extern "C" {
NSPoint tmpPoint = [viewForDescent convertPoint:windowPoint fromView:nil];
// Apply same rule as above wrt z-order.
for (NSView *view in [viewForDescent subviews]) {
- if (NSMouseInRect(tmpPoint, [view frame], [view isFlipped]))
+ if (![view isHidden] && NSMouseInRect(tmpPoint, [view frame], [view isFlipped]))
lowerView = view;
}
if (!lowerView) // Low as we can be at this point.
@@ -913,11 +946,32 @@ extern "C" {
}
}
+- (void)viewWillMoveToWindow:(NSWindow *)window
+{
+ if (qwidget->windowFlags() & Qt::MSWindowsOwnDC
+ && (window != [self window])) { // OpenGL Widget
+ // Create a stupid ClearDrawable Event
+ QEvent event(QEvent::MacGLClearDrawable);
+ qApp->sendEvent(qwidget, &event);
+ }
+}
+
+- (void)viewDidMoveToWindow
+{
+ if (qwidget->windowFlags() & Qt::MSWindowsOwnDC && [self window]) {
+ // call update paint event
+ qwidgetprivate->needWindowChange = true;
+ QEvent event(QEvent::MacGLWindowChange);
+ qApp->sendEvent(qwidget, &event);
+ }
+}
+
+
// NSTextInput Protocol implementation
- (void) insertText:(id)aString
{
- if (composing) {
+ if ([aString length]) {
// Send the commit string to the widget.
QString commitText;
if ([aString isKindOfClass:[NSAttributedString class]]) {
@@ -931,6 +985,7 @@ extern "C" {
e.setCommitString(commitText);
qt_sendSpontaneousEvent(qwidget, &e);
}
+ composingText->clear();
}
- (void) setMarkedText:(id)aString selectedRange:(NSRange)selRange
@@ -984,12 +1039,21 @@ extern "C" {
attrs<<QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
0, composingLength, format);
}
+ *composingText = qtText;
QInputMethodEvent e(qtText, attrs);
qt_sendSpontaneousEvent(qwidget, &e);
+ if (!composingLength)
+ composing = false;
}
- (void) unmarkText
{
+ if (composing) {
+ QInputMethodEvent e;
+ e.setCommitString(*composingText);
+ qt_sendSpontaneousEvent(qwidget, &e);
+ }
+ composingText->clear();
composing = false;
}
diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h
index 9de94d5..ec1281e 100644
--- a/src/gui/kernel/qcocoaview_mac_p.h
+++ b/src/gui/kernel/qcocoaview_mac_p.h
@@ -83,6 +83,7 @@ Q_GUI_EXPORT
bool composing;
int composingLength;
bool sendKeyEvents;
+ QString *composingText;
}
- (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
- (void) finishInitWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/gui/kernel/qcocoawindow_mac.mm
index 6b30444..89f481f 100644
--- a/src/gui/kernel/qcocoawindow_mac.mm
+++ b/src/gui/kernel/qcocoawindow_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#include "qmacdefines_mac.h"
#ifdef QT_MAC_USE_COCOA
@@ -53,9 +53,10 @@
#include <QtGui/QWidget>
QT_FORWARD_DECLARE_CLASS(QWidget);
-QT_USE_NAMESPACE
-
+QT_BEGIN_NAMESPACE
extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
+QT_END_NAMESPACE
+QT_USE_NAMESPACE
@implementation NSWindow (QT_MANGLE_NAMESPACE(QWidgetIntegration))
@@ -86,6 +87,12 @@ extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.
return YES;
}
+/***********************************************************************
+ BEGIN Copy and Paste between QCocoaWindow and QCocoaPanel
+ This is a bit unfortunate, but thanks to the dynamic dispatch we
+ have to duplicate this code or resort to really silly forwarding methods
+**************************************************************************/
+
/*
The methods keyDown, keyUp, and flagsChanged... These really shouldn't ever
get hit. We automatically say we can be first responder if we are a window.
@@ -124,7 +131,7 @@ extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.
[self retain];
QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
- QCocoaView *view = static_cast<QCocoaView *>(qt_mac_nativeview_for(widget));
+ QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_nativeview_for(widget));
Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]);
// sometimes need to redirect mouse events to the popup.
@@ -173,6 +180,20 @@ extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.
[self release];
}
+
+- (BOOL)makeFirstResponder:(NSResponder *)responder
+{
+ // For some reason Cocoa wants to flip the first responder
+ // when Qt doesn't want to, sorry, but "No" :-)
+ if (responder == nil && qApp->focusWidget())
+ return NO;
+ return [super makeFirstResponder:responder];
+}
+
+/***********************************************************************
+ END Copy and Paste between QCocoaWindow and QCocoaPanel
+***********************************************************************/
+
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask
{
if (styleMask & QtMacCustomizeWindow)
diff --git a/src/gui/kernel/qcocoawindowdelegate_mac.mm b/src/gui/kernel/qcocoawindowdelegate_mac.mm
index 8480179..03b2fce 100644
--- a/src/gui/kernel/qcocoawindowdelegate_mac.mm
+++ b/src/gui/kernel/qcocoawindowdelegate_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#import "private/qcocoawindowdelegate_mac_p.h"
#ifdef QT_MAC_USE_COCOA
diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h
index 15b4597..ad1860d 100644
--- a/src/gui/kernel/qcursor.h
+++ b/src/gui/kernel/qcursor.h
@@ -77,6 +77,7 @@ class QBitmap;
class QPixmap;
#if defined(Q_WS_MAC)
+void *nsCursorForQCursor(const QCursor &c);
void qt_mac_set_cursor(const QCursor *c, const QPoint &p);
#endif
@@ -128,6 +129,7 @@ public:
private:
QCursorData *d;
#if defined(Q_WS_MAC)
+ friend void *nsCursorForQCursor(const QCursor &c);
friend void qt_mac_set_cursor(const QCursor *c, const QPoint &p);
#endif
};
diff --git a/src/gui/kernel/qcursor_mac.mm b/src/gui/kernel/qcursor_mac.mm
index d632eb79..ae98f2e 100644
--- a/src/gui/kernel/qcursor_mac.mm
+++ b/src/gui/kernel/qcursor_mac.mm
@@ -95,9 +95,19 @@ protected:
}
};
+void *nsCursorForQCursor(const QCursor &c)
+{
+ c.d->update();
+ return [[static_cast<NSCursor *>(c.d->curs.cp.nscursor) retain] autorelease];
+}
+
static QCursorData *currentCursor = 0; //current cursor
void qt_mac_set_cursor(const QCursor *c, const QPoint &)
{
+#ifdef QT_MAC_USE_COCOA
+ Q_UNUSED(c);
+ return;
+#else
if (!c) {
currentCursor = 0;
return;
@@ -128,10 +138,15 @@ void qt_mac_set_cursor(const QCursor *c, const QPoint &)
}
}
currentCursor = c->d;
+#endif
}
void qt_mac_update_cursor_at_global_pos(const QPoint &globalPos)
{
+#ifdef QT_MAC_USE_COCOA
+ Q_UNUSED(globalPos);
+ return;
+#else
QCursor cursor(Qt::ArrowCursor);
if (QApplication::overrideCursor()) {
cursor = *QApplication::overrideCursor();
@@ -144,6 +159,7 @@ void qt_mac_update_cursor_at_global_pos(const QPoint &globalPos)
}
}
qt_mac_set_cursor(&cursor, globalPos);
+#endif
}
void qt_mac_update_cursor()
diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp
index 1a0fb08..39abc5e 100644
--- a/src/gui/kernel/qkeymapper_mac.cpp
+++ b/src/gui/kernel/qkeymapper_mac.cpp
@@ -48,6 +48,7 @@
#include <qinputcontext.h>
#include <private/qkeymapper_p.h>
#include <private/qapplication_p.h>
+#include <private/qmacinputcontext_p.h>
QT_BEGIN_NAMESPACE
@@ -480,7 +481,8 @@ static bool translateKeyEventInternal(EventHandlerCallRef er, EventRef keyEvent,
#ifdef QT_MAC_USE_COCOA
if (outHandled) {
qt_mac_eat_unicode_key = false;
- CallNextEventHandler(er, keyEvent);
+ if (er)
+ CallNextEventHandler(er, keyEvent);
*outHandled = qt_mac_eat_unicode_key;
}
#endif
@@ -692,8 +694,14 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
return true;
}
- if (qApp->inputContext() && qApp->inputContext()->isComposing())
+ if (qApp->inputContext() && qApp->inputContext()->isComposing()) {
+ if (ekind == kEventRawKeyDown) {
+ QMacInputContext *context = qobject_cast<QMacInputContext*>(qApp->inputContext());
+ if (context)
+ context->setLastKeydownEvent(event);
+ }
return false;
+ }
//get modifiers
Qt::KeyboardModifiers modifiers;
int qtKey;
@@ -721,7 +729,8 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
//is it of use to text services? If so we won't bother
//with a QKeyEvent.
qt_mac_eat_unicode_key = false;
- CallNextEventHandler(er, event);
+ if (er)
+ CallNextEventHandler(er, event);
extern bool qt_mac_menubar_is_open();
if (qt_mac_eat_unicode_key || qt_mac_menubar_is_open()) {
return true;
diff --git a/src/gui/kernel/qmacdefines_mac.h b/src/gui/kernel/qmacdefines_mac.h
index 97ec544..035b8c5 100644
--- a/src/gui/kernel/qmacdefines_mac.h
+++ b/src/gui/kernel/qmacdefines_mac.h
@@ -105,7 +105,7 @@ Yes, it is an informative comment ;-)
# undef qDebug
#endif
-#if __LP64__
+#ifdef __LP64__
typedef signed int OSStatus;
#else
typedef signed long OSStatus;
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 9c381b4..52e76d8 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -555,12 +555,15 @@ bool qt_dispatchKeyEventWithCocoa(void * /*NSEvent * */ keyEvent, QWidget *widge
int keyLength = [keyChars length];
if (keyLength == 0)
return false; // Dead Key, nothing to do!
+ bool ignoreText = false;
Qt::Key qtKey = Qt::Key_unknown;
if (keyLength == 1) {
QChar ch([keyChars characterAtIndex:0]);
if (ch.isLower())
ch = ch.toUpper();
qtKey = cocoaKey2QtKey(ch);
+ // Do not set the text for Function-Key Unicodes characters (0xF700–0xF8FF).
+ ignoreText = (ch.unicode() >= 0xF700 && ch.unicode() <= 0xF8FF);
}
Qt::KeyboardModifiers keyMods = qt_cocoaModifiers2QtModifiers([event modifierFlags]);
QString text;
@@ -568,7 +571,7 @@ bool qt_dispatchKeyEventWithCocoa(void * /*NSEvent * */ keyEvent, QWidget *widge
// To quote from the Carbon port: This is actually wrong--but it is the best that
// can be done for now because of the Control/Meta mapping issues
// (we always get text on the Mac)
- if (!(keyMods & (Qt::ControlModifier | Qt::MetaModifier)))
+ if (!ignoreText && !(keyMods & (Qt::ControlModifier | Qt::MetaModifier)))
text = QCFString::toQString(reinterpret_cast<CFStringRef>(keyChars));
UInt32 macScanCode = 1;
diff --git a/src/gui/kernel/qt_mac.cpp b/src/gui/kernel/qt_mac.cpp
index 4703475..b1247e8 100644
--- a/src/gui/kernel/qt_mac.cpp
+++ b/src/gui/kernel/qt_mac.cpp
@@ -131,16 +131,47 @@ QColor qcolorForTheme(ThemeBrush brush)
QColor qcolorForThemeTextColor(ThemeTextColor themeColor)
{
-#ifndef QT_MAC_USE_COCOA
+#ifdef QT_OS_MAC32
RGBColor c;
GetThemeTextColor(themeColor, 32, true, &c);
- return QColor(c.red / 265, c.green / 256, c.blue / 256);
+ QColor color = QColor(c.red / 265, c.green / 256, c.blue / 256);
+ return color;
#else
- QNativeImage nativeImage(16,16, QNativeImage::systemFormat());
- CGRect cgrect = CGRectMake(0, 0, 16, 16);
- HIThemeSetTextFill(themeColor, 0, nativeImage.cg, kHIThemeOrientationNormal);
- CGContextFillRect(nativeImage.cg, cgrect);
- return QColor(nativeImage.image.pixel(0 , 0));
+ // There is no equivalent to GetThemeTextColor in 64-bit and it was rather bad that
+ // I didn't file a request to implement this for Snow Leopard. So, in the meantime
+ // I've encoded the values from the GetThemeTextColor. This is not exactly ideal
+ // as if someone really wants to mess with themeing, these colors will be wrong.
+ // It also means that we need to make sure the values for differences between
+ // OS releases (and it will be likely that we are a step behind.)
+ switch (themeColor) {
+ case kThemeTextColorAlertActive:
+ case kThemeTextColorTabFrontActive:
+ case kThemeTextColorBevelButtonActive:
+ case kThemeTextColorListView:
+ case kThemeTextColorPlacardActive:
+ case kThemeTextColorPopupButtonActive:
+ case kThemeTextColorPopupLabelActive:
+ case kThemeTextColorPushButtonActive:
+ return Qt::black;
+ case kThemeTextColorAlertInactive:
+ case kThemeTextColorDialogInactive:
+ case kThemeTextColorPlacardInactive:
+ return QColor(67, 69, 69, 255);
+ case kThemeTextColorPopupButtonInactive:
+ case kThemeTextColorPopupLabelInactive:
+ case kThemeTextColorPushButtonInactive:
+ case kThemeTextColorTabFrontInactive:
+ case kThemeTextColorBevelButtonInactive:
+ return QColor(123, 127, 127, 255);
+ default: {
+ QNativeImage nativeImage(16,16, QNativeImage::systemFormat());
+ CGRect cgrect = CGRectMake(0, 0, 16, 16);
+ HIThemeSetTextFill(themeColor, 0, nativeImage.cg, kHIThemeOrientationNormal);
+ CGContextFillRect(nativeImage.cg, cgrect);
+ QColor color = nativeImage.image.pixel(0,0);
+ return QColor(nativeImage.image.pixel(0 , 0));
+ }
+ }
#endif
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qt_mac_p.h b/src/gui/kernel/qt_mac_p.h
index 3aec23f..ca995dc 100644
--- a/src/gui/kernel/qt_mac_p.h
+++ b/src/gui/kernel/qt_mac_p.h
@@ -233,6 +233,7 @@ extern QPaintDevice *qt_mac_safe_pdev; //qapplication_mac.cpp
extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.mm
extern OSViewRef qt_mac_nativeview_for(const QWidget *); //qwidget_mac.mm
+extern QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt); //qwidget_mac.mm
#ifdef check
# undef check
@@ -249,11 +250,13 @@ struct QMacDndAnswerRecord {
Qt::KeyboardModifiers modifiers;
Qt::MouseButtons buttons;
Qt::DropAction lastAction;
+ unsigned int lastOperation;
void clear() {
rect = QRect();
modifiers = Qt::NoModifier;
buttons = Qt::NoButton;
lastAction = Qt::IgnoreAction;
+ lastOperation = 0;
}
};
extern QMacDndAnswerRecord qt_mac_dnd_answer_rec;
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 06810e0..3e25ffc 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -66,6 +66,7 @@
#ifdef Q_WS_MAC
# include "qt_mac_p.h"
# include "qt_cocoa_helpers_mac_p.h"
+# include "qmainwindow.h"
#endif
#if defined(Q_WS_QWS)
# include "qwsdisplay_qws.h"
@@ -164,6 +165,7 @@ static inline bool bypassGraphicsProxyWidget(QWidget *p)
#endif
extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp
+extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
QWidgetPrivate::QWidgetPrivate(int version) :
QObjectPrivate(version), extra(0), focus_child(0)
@@ -234,28 +236,6 @@ QWindowSurface *QWidgetPrivate::createDefaultWindowSurface()
/*!
\internal
- This is an internal function, you should never call this.
-
- This function is called to focus associated input context. The
- code intends to eliminate duplicate focus for the context even if
- the context is shared between widgets
-
- \sa QInputContext::setFocus()
- */
-void QWidgetPrivate::focusInputContext()
-{
-#ifndef QT_NO_IM
- Q_Q(QWidget);
- QInputContext *qic = q->inputContext();
- if (qic) {
- if(qic->focusWidget() != q)
- qic->setFocusWidget(q);
- }
-#endif // QT_NO_IM
-}
-
-/*!
- \internal
*/
void QWidgetPrivate::scrollChildren(int dx, int dy)
{
@@ -329,20 +309,24 @@ void QWidget::setInputContext(QInputContext *context)
/*!
+ \obsolete
+
This function can be called on the widget that currently has focus
to reset the input method operating on it.
- \sa QInputContext, QInputContext::reset()
+ This function is providing for convenience, instead you should use
+ \l{QInputContext::}{reset()} on the input context that was
+ returned by inputContext().
+
+ \sa QInputContext, inputContext(), QInputContext::reset()
*/
void QWidget::resetInputContext()
{
if (!hasFocus())
return;
#ifndef QT_NO_IM
- if (!d_func()->ic)
- return;
QInputContext *qic = this->inputContext();
- if( qic )
+ if(qic)
qic->reset();
#endif // QT_NO_IM
}
@@ -1400,7 +1384,13 @@ int QWidgetPrivate::maxInstances = 0; // Maximum number of widget instances
void QWidgetPrivate::setWinId(WId id) // set widget identifier
{
Q_Q(QWidget);
- if (mapper && data.winid) {
+ // the user might create a widget with Qt::Desktop window
+ // attribute (or create another QDesktopWidget instance), which
+ // will have the same windowid (the root window id) as the
+ // qt_desktopWidget. We should not add the second desktop widget
+ // to the mapper.
+ bool userDesktopWidget = qt_desktopWidget != 0 && qt_desktopWidget != q && q->windowType() == Qt::Desktop;
+ if (mapper && data.winid && !userDesktopWidget) {
mapper->remove(data.winid);
uncreatedWidgets->insert(q);
}
@@ -1409,7 +1399,7 @@ void QWidgetPrivate::setWinId(WId id) // set widget identifier
#if defined(Q_WS_X11)
hd = id; // X11: hd == ident
#endif
- if (mapper && id) {
+ if (mapper && id && !userDesktopWidget) {
mapper->insert(data.winid, q);
uncreatedWidgets->remove(q);
}
@@ -2960,10 +2950,15 @@ void QWidgetPrivate::setEnabled_helper(bool enable)
#if defined(Q_WS_MAC)
setEnabled_helper_sys(enable);
#endif
-#if defined (Q_WS_WIN)
- if (q->hasFocus())
- QInputContextPrivate::updateImeStatus(q, true);
-#endif
+ if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) {
+ QInputContext *qic = inputContext();
+ if (enable) {
+ qic->setFocusWidget(q);
+ } else {
+ qic->reset();
+ qic->setFocusWidget(0);
+ }
+ }
QEvent e(QEvent::EnabledChange);
QApplication::sendEvent(q, &e);
#ifdef QT3_SUPPORT
@@ -4785,7 +4780,7 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
}
const qreal opacity = painter->opacity();
- if (qFuzzyCompare(opacity + 1, qreal(1.0)))
+ if (qFuzzyIsNull(opacity))
return; // Fully transparent.
Q_D(QWidget);
@@ -5890,6 +5885,8 @@ QWidget *QWidget::focusWidget() const
/*!
Returns the next widget in this widget's focus chain.
+
+ \sa previousInFocusChain
*/
QWidget *QWidget::nextInFocusChain() const
{
@@ -5897,6 +5894,18 @@ QWidget *QWidget::nextInFocusChain() const
}
/*!
+ Returns the previous widget in this widget's focus chain.
+
+ \sa nextInFocusChain
+
+ \since 4.6
+*/
+QWidget *QWidget::previousInFocusChain() const
+{
+ return const_cast<QWidget *>(d_func()->focus_prev);
+}
+
+/*!
\property QWidget::isActiveWindow
\brief whether this widget's window is the active window
@@ -7623,16 +7632,10 @@ bool QWidget::event(QEvent *event)
}
break;
case QEvent::FocusIn:
-#if defined(Q_WS_WIN)
- QInputContextPrivate::updateImeStatus(this, true);
-#endif
focusInEvent((QFocusEvent*)event);
break;
case QEvent::FocusOut:
-#if defined(Q_WS_WIN)
- QInputContextPrivate::updateImeStatus(this, false);
-#endif
focusOutEvent((QFocusEvent*)event);
break;
@@ -8977,17 +8980,36 @@ QWidget *QWidget::childAt(const QPoint &p) const
QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const
{
Q_Q(const QWidget);
- if (!q->rect().contains(p))
+#ifdef Q_WS_MAC
+ bool includeFrame = q->isWindow() && qobject_cast<const QMainWindow *>(q)
+ && static_cast<const QMainWindow *>(q)->unifiedTitleAndToolBarOnMac();
+#endif
+
+ if (
+#ifdef Q_WS_MAC
+ !includeFrame &&
+#endif
+ !q->rect().contains(p))
return 0;
+
for (int i = children.size(); i > 0 ;) {
--i;
QWidget *w = qobject_cast<QWidget *>(children.at(i));
- if (w && !w->isWindow() && !w->isHidden() && w->geometry().contains(p)) {
+ if (w && !w->isWindow() && !w->isHidden()
+ && (w->geometry().contains(p)
+#ifdef Q_WS_MAC
+ || (includeFrame && w->geometry().contains(qt_mac_nativeMapFromParent(w, p)))
+#endif
+ )) {
if (ignoreChildrenInDestructor && w->data->in_destructor)
continue;
if (w->testAttribute(Qt::WA_TransparentForMouseEvents))
continue;
QPoint childPoint = w->mapFromParent(p);
+#ifdef Q_WS_MAC
+ if (includeFrame && !w->geometry().contains(p))
+ childPoint = qt_mac_nativeMapFromParent(w, p);
+#endif
if (QWidget *t = w->d_func()->childAt_helper(childPoint, ignoreChildrenInDestructor))
return t;
// if WMouseNoMask is set the widget mask is ignored, if
@@ -9428,11 +9450,13 @@ void QWidget::repaint(const QRect &rect)
if (!isVisible() || !updatesEnabled() || rect.isEmpty())
return;
- QTLWExtra *tlwExtra = !d->paintOnScreen() ? window()->d_func()->maybeTopData() : 0;
- if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
- tlwExtra->inRepaint = true;
- tlwExtra->backingStore->markDirty(rect, this, true);
- tlwExtra->inRepaint = false;
+ if (hasBackingStoreSupport()) {
+ QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
+ if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
+ tlwExtra->inRepaint = true;
+ tlwExtra->backingStore->markDirty(rect, this, true);
+ tlwExtra->inRepaint = false;
+ }
} else {
d->repaint_sys(rect);
}
@@ -9455,11 +9479,13 @@ void QWidget::repaint(const QRegion &rgn)
if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
return;
- QTLWExtra *tlwExtra = !d->paintOnScreen() ? window()->d_func()->maybeTopData() : 0;
- if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
- tlwExtra->inRepaint = true;
- tlwExtra->backingStore->markDirty(rgn, this, true);
- tlwExtra->inRepaint = false;
+ if (hasBackingStoreSupport()) {
+ QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
+ if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
+ tlwExtra->inRepaint = true;
+ tlwExtra->backingStore->markDirty(rgn, this, true);
+ tlwExtra->inRepaint = false;
+ }
} else {
d->repaint_sys(rgn);
}
@@ -9786,12 +9812,21 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
}
break;
#endif
- case Qt::WA_NativeWindow:
+ case Qt::WA_NativeWindow: {
+ QInputContext *ic = 0;
+ if (on && !internalWinId() && testAttribute(Qt::WA_InputMethodEnabled) && hasFocus()) {
+ ic = d->inputContext();
+ ic->reset();
+ ic->setFocusWidget(0);
+ }
if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget())
parentWidget()->d_func()->enforceNativeChildren();
if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
d->createWinId();
+ if (ic && isEnabled())
+ ic->setFocusWidget(this);
break;
+ }
case Qt::WA_PaintOnScreen:
d->updateIsOpaque();
#if defined(Q_WS_WIN) || defined(Q_WS_X11)
@@ -9819,10 +9854,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
#endif
break;
case Qt::WA_InputMethodEnabled: {
-#if defined(Q_WS_WIN) || (defined(Q_WS_QWS) && !defined(QT_NO_QWS_INPUTMETHODS))
- if (hasFocus())
- QInputContextPrivate::updateImeStatus(this, true);
-#endif
QInputContext *ic = d->ic;
if (!ic) {
// implicitly create input context only if we have a focus
@@ -9830,7 +9861,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
ic = d->inputContext();
}
if (ic) {
- if (on && hasFocus() && ic->focusWidget() != this) {
+ if (on && hasFocus() && ic->focusWidget() != this && isEnabled()) {
ic->setFocusWidget(this);
} else if (!on && ic->focusWidget() == this) {
ic->reset();
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index f54ebf9..309463e 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -539,6 +539,7 @@ public:
QWidget *focusWidget() const;
QWidget *nextInFocusChain() const;
+ QWidget *previousInFocusChain() const;
// drag and drop
bool acceptDrops() const;
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index f599b7c..ec05f12 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -295,9 +295,7 @@ bool qt_mac_is_macsheet(const QWidget *w)
Qt::WindowModality modality = w->windowModality();
if (modality == Qt::ApplicationModal)
return false;
- if (modality == Qt::WindowModal || w->windowType() == Qt::Sheet)
- return true;
- return false;
+ return w->parentWidget() && (modality == Qt::WindowModal || w->windowType() == Qt::Sheet);
}
bool qt_mac_is_macdrawer(const QWidget *w)
@@ -392,21 +390,15 @@ QWidget *qt_mac_find_window(OSWindowRef window)
inline static void qt_mac_set_fullscreen_mode(bool b)
{
- extern bool qt_mac_app_fullscreen; //qapplication_mac.cpp
+ extern bool qt_mac_app_fullscreen; //qapplication_mac.mm
if(qt_mac_app_fullscreen == b)
return;
qt_mac_app_fullscreen = b;
-#if QT_MAC_USE_COCOA
- if(b)
- SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);
- else
+ if (b) {
+ SetSystemUIMode(kUIModeAllSuppressed, 0);
+ } else {
SetSystemUIMode(kUIModeNormal, 0);
-#else
- if(b)
- HideMenuBar();
- else
- ShowMenuBar();
-#endif
+ }
}
Q_GUI_EXPORT OSViewRef qt_mac_nativeview_for(const QWidget *w)
@@ -467,7 +459,18 @@ Q_GUI_EXPORT OSWindowRef qt_mac_window_for(const QWidget *w)
if (hiview){
OSWindowRef window = qt_mac_window_for(hiview);
if (!window && qt_isGenuineQWidget(hiview)) {
- w->window()->d_func()->createWindow_sys();
+ QWidget *myWindow = w->window();
+ // This is a workaround for NSToolbar. When a widget is hidden
+ // by clicking the toolbar button, Cocoa reparents the widgets
+ // to another window (but Qt doesn't know about it).
+ // When we start showing them, it reparents back,
+ // but at this point it's window is nil, but the window it's being brought
+ // into (the Qt one) is for sure created.
+ // This stops the hierarchy moving under our feet.
+ if (myWindow != w && qt_mac_window_for(qt_mac_nativeview_for(myWindow)))
+ return qt_mac_window_for(qt_mac_nativeview_for(myWindow));
+
+ myWindow->d_func()->createWindow_sys();
// Reget the hiview since the "create window could potentially move the view (I guess).
hiview = qt_mac_nativeview_for(w);
window = qt_mac_window_for(hiview);
@@ -2174,7 +2177,10 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin
if ((popup || type == Qt::Tool || type == Qt::ToolTip) && !q->isModal()) {
[windowRef setHidesOnDeactivate:YES];
[windowRef setHasShadow:YES];
+ } else {
+ [windowRef setHidesOnDeactivate:NO];
}
+
Q_UNUSED(parentWidget);
Q_UNUSED(dialog);
@@ -2514,6 +2520,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
}
updateIsOpaque();
+ if (q->hasFocus())
+ setFocus_sys();
if (!topLevel && initializeWindow)
setWSGeometry();
@@ -2844,12 +2852,26 @@ void QWidgetPrivate::updateSystemBackground()
void QWidgetPrivate::setCursor_sys(const QCursor &)
{
+#ifndef QT_MAC_USE_COCOA
qt_mac_update_cursor();
+#else
+ Q_Q(QWidget);
+ if (q->testAttribute(Qt::WA_WState_Created)) {
+ [qt_mac_window_for(q) invalidateCursorRectsForView:qt_mac_nativeview_for(q)];
+ }
+#endif
}
void QWidgetPrivate::unsetCursor_sys()
{
+#ifndef QT_MAC_USE_COCOA
qt_mac_update_cursor();
+#else
+ Q_Q(QWidget);
+ if (q->testAttribute(Qt::WA_WState_Created)) {
+ [qt_mac_window_for(q) invalidateCursorRectsForView:qt_mac_nativeview_for(q)];
+ }
+#endif
}
void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
@@ -3274,6 +3296,20 @@ void QWidgetPrivate::show_sys()
qt_event_request_window_change(q);
}
+
+QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt)
+{
+#ifndef QT_MAC_USE_COCOA
+ CGPoint nativePoint = CGPointMake(pt.x(), pt.y());
+ HIViewConvertPoint(&nativePoint, qt_mac_nativeview_for(child->parentWidget()),
+ qt_mac_nativeview_for(child));
+#else
+ NSPoint nativePoint = [qt_mac_nativeview_for(child) convertPoint:NSMakePoint(pt.x(), pt.y()) fromView:qt_mac_nativeview_for(child->parentWidget())];
+#endif
+ return QPoint(nativePoint.x, nativePoint.y);
+}
+
+
void QWidgetPrivate::hide_sys()
{
Q_Q(QWidget);
@@ -4448,14 +4484,6 @@ void QWidgetPrivate::setMask_sys(const QRegion &region)
#endif
}
-extern "C" {
- typedef struct CGSConnection *CGSConnectionRef;
- typedef struct CGSWindow *CGSWindowRef;
- extern OSStatus CGSSetWindowAlpha(CGSConnectionRef, CGSWindowRef, float);
- extern CGSWindowRef GetNativeWindowFromWindowRef(WindowRef);
- extern CGSConnectionRef _CGSDefaultConnection();
-}
-
void QWidgetPrivate::setWindowOpacity_sys(qreal level)
{
Q_Q(QWidget);
@@ -4468,12 +4496,11 @@ void QWidgetPrivate::setWindowOpacity_sys(qreal level)
if (!q->testAttribute(Qt::WA_WState_Created))
return;
-#if QT_MAC_USE_COCOA
OSWindowRef oswindow = qt_mac_window_for(q);
+#if QT_MAC_USE_COCOA
[oswindow setAlphaValue:level];
#else
- CGSSetWindowAlpha(_CGSDefaultConnection(),
- GetNativeWindowFromWindowRef(qt_mac_window_for(q)), level);
+ SetWindowAlpha(oswindow, level);
#endif
}
@@ -4581,11 +4608,11 @@ void QWidgetPrivate::setModal_sys()
OSWindowRef windowRef = qt_mac_window_for(q);
#ifdef QT_MAC_USE_COCOA
- bool windowIsSheet = [windowRef styleMask] & NSDocModalWindowMask;
+ bool alreadySheet = [windowRef styleMask] & NSDocModalWindowMask;
- if (q->windowModality() == Qt::WindowModal){
+ if (windowParent && q->windowModality() == Qt::WindowModal){
// Window should be window-modal, which implies a sheet.
- if (!windowIsSheet)
+ if (!alreadySheet)
recreateMacWindow();
if ([windowRef isKindOfClass:[NSPanel class]]){
// If the primary window of the sheet parent is a child of a modal dialog,
@@ -4599,7 +4626,7 @@ void QWidgetPrivate::setModal_sys()
}
} else {
// Window shold not be window-modal, and as such, not a sheet.
- if (windowIsSheet){
+ if (alreadySheet){
// NB: the following call will call setModal_sys recursivly:
recreateMacWindow();
windowRef = qt_mac_window_for(q);
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index f254c4a..9e93f66 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -354,8 +354,6 @@ public:
void setWindowIcon_sys(bool forceReset = false);
void setWindowOpacity_sys(qreal opacity);
- void focusInputContext();
-
void adjustQuitOnCloseAttribute();
#if defined(Q_WS_X11)
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index a12b50c..76734d4 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -898,7 +898,7 @@ void QWidgetPrivate::x11UpdateIsOpaque()
bool visible = q->isVisible();
if (visible)
q->hide();
- q->setParent(q->parentWidget(), q->windowFlags() & ~Qt::WindowType_Mask);
+ q->setParent(q->parentWidget(), q->windowFlags());
q->move(pos);
if (visible)
q->show();
@@ -1516,7 +1516,6 @@ void QWidget::activateWindow()
X11->userTime = X11->time;
qt_net_update_user_time(tlw, X11->userTime);
XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time);
- d->focusInputContext();
}
}
@@ -1751,8 +1750,8 @@ void QWidgetPrivate::show_sys()
mwmhints.functions &= ~MWM_FUNC_RESIZE;
}
- mwmhints.flags |= MWM_HINTS_DECORATIONS;
if (mwmhints.decorations == MWM_DECOR_ALL) {
+ mwmhints.flags |= MWM_HINTS_DECORATIONS;
mwmhints.decorations = (MWM_DECOR_BORDER
| MWM_DECOR_TITLE
| MWM_DECOR_MENU);
@@ -1761,10 +1760,12 @@ void QWidgetPrivate::show_sys()
}
if (q->windowFlags() & Qt::WindowMinimizeButtonHint) {
+ mwmhints.flags |= MWM_HINTS_DECORATIONS;
mwmhints.decorations |= MWM_DECOR_MINIMIZE;
mwmhints.functions |= MWM_FUNC_MINIMIZE;
}
if (q->windowFlags() & Qt::WindowMaximizeButtonHint) {
+ mwmhints.flags |= MWM_HINTS_DECORATIONS;
mwmhints.decorations |= MWM_DECOR_MAXIMIZE;
mwmhints.functions |= MWM_FUNC_MAXIMIZE;
}
diff --git a/src/gui/kernel/qx11embed_x11.cpp b/src/gui/kernel/qx11embed_x11.cpp
index e49c4d6..6329135 100644
--- a/src/gui/kernel/qx11embed_x11.cpp
+++ b/src/gui/kernel/qx11embed_x11.cpp
@@ -481,7 +481,7 @@ QX11EmbedWidget::QX11EmbedWidget(QWidget *parent)
| ExposureMask | StructureNotifyMask
| SubstructureNotifyMask | PropertyChangeMask);
- unsigned int data[] = {XEMBED_VERSION, XEMBED_MAPPED};
+ long data[] = {XEMBED_VERSION, XEMBED_MAPPED};
XChangeProperty(x11Info().display(), internalWinId(), ATOM(_XEMBED_INFO),
ATOM(_XEMBED_INFO), 32, PropModeReplace,
(unsigned char*) data, 2);
@@ -1571,7 +1571,7 @@ void QX11EmbedContainer::showEvent(QShowEvent *)
{
Q_D(QX11EmbedContainer);
if (d->client) {
- unsigned int data[] = {XEMBED_VERSION, XEMBED_MAPPED};
+ long data[] = {XEMBED_VERSION, XEMBED_MAPPED};
XChangeProperty(x11Info().display(), d->client, ATOM(_XEMBED_INFO), ATOM(_XEMBED_INFO), 32,
PropModeReplace, (unsigned char *) data, 2);
}
@@ -1587,8 +1587,7 @@ void QX11EmbedContainer::hideEvent(QHideEvent *)
{
Q_D(QX11EmbedContainer);
if (d->client) {
- unsigned int data[] = {XEMBED_VERSION, XEMBED_MAPPED};
-
+ long data[] = {XEMBED_VERSION, XEMBED_MAPPED};
XChangeProperty(x11Info().display(), d->client, ATOM(_XEMBED_INFO), ATOM(_XEMBED_INFO), 32,
PropModeReplace, (unsigned char *) data, 2);
}
diff --git a/src/gui/math3d/math3d.pri b/src/gui/math3d/math3d.pri
index 581adbd..e4dd53a 100644
--- a/src/gui/math3d/math3d.pri
+++ b/src/gui/math3d/math3d.pri
@@ -1,8 +1,5 @@
HEADERS += \
- math3d/qfixedpt.h \
math3d/qgenericmatrix.h \
- math3d/qmath3dglobal.h \
- math3d/qmath3dutil_p.h \
math3d/qmatrix4x4.h \
math3d/qquaternion.h \
math3d/qvector2d.h \
@@ -10,9 +7,7 @@ HEADERS += \
math3d/qvector4d.h
SOURCES += \
- math3d/qfixedpt.cpp \
math3d/qgenericmatrix.cpp \
- math3d/qmath3dutil.cpp \
math3d/qmatrix4x4.cpp \
math3d/qquaternion.cpp \
math3d/qvector2d.cpp \
diff --git a/src/gui/math3d/qfixedpt.cpp b/src/gui/math3d/qfixedpt.cpp
deleted file mode 100644
index e7e61b6..0000000
--- a/src/gui/math3d/qfixedpt.cpp
+++ /dev/null
@@ -1,681 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $TROLLTECH_DUAL_LICENSE$
-**
-****************************************************************************/
-
-#include "qfixedpt.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- Returns the fixed-point square root of \a value.
-*/
-qint64 qt_math3d_fixed_sqrt(qint64 value)
-{
- qint64 result = 0;
- qint64 bit = ((qint64)1) << 62;
- while (bit > value)
- bit >>= 2;
- while (bit != 0) {
- if (value >= (result + bit)) {
- value -= result + bit;
- result += (bit << 1);
- }
- result >>= 1;
- bit >>= 2;
- }
- return result;
-}
-
-/*!
- \class QFixedPt
- \brief The QFixedPt class represents fixed-point numbers within a 32-bit integer with a configurable precision.
-
- The template parameter is the number of bits of precision after
- the decimal point. For example, QFixedPt<5> indicates that there
- are 27 bits before the decimal point, and 5 bits of precision after
- the decimal point.
-*/
-
-/*!
- \fn QFixedPt::QFixedPt()
-
- Constructs a default fixed-point number. The initial value
- is undefined.
-*/
-
-/*!
- \fn QFixedPt::QFixedPt(int value)
-
- Constructs a fixed-point number from the integer \a value.
-*/
-
-/*!
- \fn QFixedPt::QFixedPt(qreal value)
-
- Constructs a fixed-point number from the floating-point \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator=(int value)
-
- Assigns the integer \a value to this fixed-point variable.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator=(qreal value)
-
- Assigns the floating-point \a value to this fixed-point variable.
-*/
-
-/*!
- \fn int QFixedPt::bits() const
-
- Returns the raw bits that represent the fixed-point value of this object.
-
- \sa setBits()
-*/
-
-/*!
- \fn void QFixedPt::setBits(int value)
-
- Sets the raw bits that represent the fixed-point value of
- this object to \a value.
-
- \sa bits()
-*/
-
-#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
-
-/*!
- \fn QFixedPt<Prec> QFixedPt::toPrecision() const
-
- Returns this fixed-point number, converted to the new fixed-point
- precision Prec.
-
- \sa qFixedPtToPrecision()
-*/
-
-#endif
-
-/*!
- \fn QFixedPt<Prec> qFixedPtToPrecision(const QFixedPt<PrecBits>& value)
-
- Returns the fixed-point number \a value, converted to the new fixed-point
- precision Prec.
-
- \sa QFixedPt::toPrecision()
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator+=(const QFixedPt<PrecBits>& value)
-
- Adds \a value to this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator+=(int value)
-
- Adds an integer \a value to this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator+=(qreal value)
-
- Adds a floating-point \a value to this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator-=(const QFixedPt<PrecBits>& value)
-
- Subtracts \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator-=(int value)
-
- Subtracts an integer \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator-=(qreal value)
-
- Subtracts a floating-point \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator*=(const QFixedPt<PrecBits>& value)
-
- Multiplies this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator*=(int value)
-
- Multiplies this fixed-point number by an integer \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator*=(qreal value)
-
- Multiplies this fixed-point number by a floating-point \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator/=(const QFixedPt<PrecBits>& value)
-
- Divides this fixed-point number by \a value. Division by zero
- will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator/=(int value)
-
- Divides this fixed-point number by an integer \a value. Division
- by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator/=(qreal value)
-
- Divides this fixed-point number by a floating-point \a value. Division
- by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator<<=(int value)
-
- Shifts this fixed-point number left by \a value bits.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator>>=(int value)
-
- Shifts this fixed-point number right by \a value bits.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator<<(int value) const
-
- Returns the result of shifting this fixed-point number
- left by \a value bits.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator>>(int value) const
-
- Returns the result of shifting this fixed-point number
- right by \a value bits.
-*/
-
-/*!
- \fn bool QFixedPt::operator==(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is equal to \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator==(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator==(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator==(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator==(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator!=(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is not equal to \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator!=(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator!=(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator!=(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator!=(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator<=(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is less than or equal to
- \a value; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator<(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is less than \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator<(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator>=(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is greater than or equal to
- \a value; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator>(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is greater than \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator>(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator+(const QFixedPt<PrecBits>& value) const
-
- Returns the result of adding this fixed-point number and \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator+(int value) const
-
- Returns the result of adding this fixed-point number and \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator+(qreal value) const
-
- Returns the result of adding this fixed-point number and \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator+(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of adding \a v1 and \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator+(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of adding \a v1 and \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-(const QFixedPt<PrecBits>& value) const
-
- Returns the result of subtracting \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-(int value) const
-
- Returns the result of subtracting \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-(qreal value) const
-
- Returns the result of subtracting \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator-(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of subtracting \a v2 from \a v1.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator-(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of subtracting \a v2 from \a v1.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator*(const QFixedPt<PrecBits>& value) const
-
- Returns the result of multiplying this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator*(int value) const
-
- Returns the result of multiplying this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator*(qreal value) const
-
- Returns the result of multiplying this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator*(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of multiplying \a v1 by \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator*(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of multiplying \a v1 by \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator/(const QFixedPt<PrecBits>& value) const
-
- Returns the result of dividing this fixed-point number by \a value.
- Division by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator/(int value) const
-
- Returns the result of dividing this fixed-point number by \a value.
- Division by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator/(qreal value) const
-
- Returns the result of dividing this fixed-point number by \a value.
- Division by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator/(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of dividing \a v1 by \a v2. Division by zero will
- result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator/(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of dividing \a v1 by \a v2. Division by zero will
- result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-() const
-
- Returns the negation of this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::sqrt() const
-
- Returns the square root of this fixed-point number.
-
- \sa sqrtF()
-*/
-
-/*!
- \fn qreal QFixedPt::sqrtF() const
-
- Return the square root of this fixed-point number as a
- floating-point value.
-
- \sa sqrt()
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::round() const
-
- Returns this fixed-point number, rounded to the nearest integer.
-
- \sa floor(), ceil(), truncate()
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::floor() const;
-
- Returns the largest integer that is less than or equal to
- this fixed-point number.
-
- \sa round(), ceil(), truncate()
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::ceil() const
-
- Returns the smallest integer that is greater than or equal to
- this fixed-point number.
-
- \sa round(), floor(), truncate()
-*/
-
-/*!
- \fn int QFixedPt::truncate() const
-
- Returns this fixed-point number with the bits after the
- decimal point truncated.
-
- \sa round(), floor(), ceil()
-*/
-
-/*!
- \fn int QFixedPt::toInt() const
-
- Returns this fixed-point number, rounded to the nearest integer.
-
- \sa toReal()
-*/
-
-/*!
- \fn qreal QFixedPt::toReal() const
-
- Returns this fixed-point number as a floating-point value.
-
- \sa toInt()
-*/
-
-/*!
- \fn int qCeil(const QFixedPt<PrecBits>& value)
- \relates QFixedPt
-
- Returns the smallest integer that is greater than or equal to
- \a value.
-
- \sa qFloor(), qRound(), QFixedPt::ceil()
-*/
-
-/*!
- \fn int qFloor(const QFixedPt<PrecBits>& value)
- \relates QFixedPt
-
- Returns the largest integer that is less than or equal to
- \a value.
-
- \sa qCeil(), qRound(), QFixedPt::floor()
-*/
-
-/*!
- \fn int qRound(const QFixedPt<PrecBits>& value)
- \relates QFixedPt
-
- Returns \a value, rounded to the nearest integer.
-
- \sa qCeil(), qFloor(), QFixedPt::round()
-*/
-
-/*!
- \fn bool qFuzzyCompare(const QFixedPt<PrecBits>& v1, const QFixedPt<PrecBits>& v2, int compareBits)
- \relates QFixedPt
-
- Returns true if \a v1 is almost equal to \a v2; false otherwise.
- The \a compareBits parameter specifies the number of bits of precision
- that should be considered relevant when performing the comparison.
- By default, \a compareBits is PrecBits / 4.
-*/
-
-/*!
- \fn bool qIsNull(const QFixedPt<PrecBits>& v)
- \relates QFixedPt
-
- Returns true if \a v is zero; false otherwise.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/gui/math3d/qfixedpt.h b/src/gui/math3d/qfixedpt.h
deleted file mode 100644
index ecbcad4..0000000
--- a/src/gui/math3d/qfixedpt.h
+++ /dev/null
@@ -1,521 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $TROLLTECH_DUAL_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFIXEDPT_H
-#define QFIXEDPT_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-Q_GUI_EXPORT qint64 qt_math3d_fixed_sqrt(qint64 value);
-
-// Should be called QFixed or QFixedPoint, but both of those
-// are already in use in src/gui/painting/qfixed_p.h.
-template <int PrecBits>
-class QFixedPt
-{
-public:
- inline QFixedPt() {} // Deliberately not initialized - don't change this.
- inline QFixedPt(int value) : val(value << PrecBits) {}
- inline QFixedPt(qreal value) : val(int(value * (1 << PrecBits))) {}
-
- inline QFixedPt<PrecBits>& operator=(int value)
- { val = value << PrecBits; return *this; }
- inline QFixedPt<PrecBits>& operator=(qreal value)
- { val = int(value * (1 << PrecBits)); return *this; }
-
- inline int bits() const { return val; }
- inline void setBits(int value) { val = value; }
-
-#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
- template <int Prec>
- inline QFixedPt<Prec> toPrecision() const
- {
- QFixedPt<Prec> result;
- if (Prec < PrecBits)
- result.setBits(shiftRight(val, (PrecBits - Prec)));
- else
- result.setBits(shiftLeft(val, (Prec - PrecBits)));
- return result;
- }
-#endif
-
- inline QFixedPt<PrecBits>& operator+=(const QFixedPt<PrecBits>& value)
- { val += value.val; return *this; }
- inline QFixedPt<PrecBits>& operator+=(int value)
- { val += (value << PrecBits); return *this; }
- inline QFixedPt<PrecBits>& operator+=(qreal value)
- { val += int(value * (1 << PrecBits)); return *this; }
-
- inline QFixedPt<PrecBits>& operator-=(const QFixedPt<PrecBits>& value)
- { val -= value.val; return *this; }
- inline QFixedPt<PrecBits>& operator-=(int value)
- { val -= (value << PrecBits); return *this; }
- inline QFixedPt<PrecBits>& operator-=(qreal value)
- { val -= int(value * (1 << PrecBits)); return *this; }
-
- inline QFixedPt<PrecBits>& operator*=(const QFixedPt<PrecBits>& value)
- { val = mul(val, value.val); return *this; }
- inline QFixedPt<PrecBits>& operator*=(int value)
- { val = mul(val, (value << PrecBits)); return *this; }
- inline QFixedPt<PrecBits>& operator*=(qreal value)
- { val = mul(val, int(value * (1 << PrecBits))); return *this; }
-
- inline QFixedPt<PrecBits>& operator/=(const QFixedPt<PrecBits>& value)
- { val = div(val, value.val); return *this; }
- inline QFixedPt<PrecBits>& operator/=(int value)
- { val = div(val, (value << PrecBits)); return *this; }
- inline QFixedPt<PrecBits>& operator/=(qreal value)
- { val = div(val, int(value * (1 << PrecBits))); return *this; }
-
- inline QFixedPt<PrecBits>& operator<<=(int value)
- { val <<= value; return *this; }
- inline QFixedPt<PrecBits>& operator>>=(int value)
- { val >>= value; return *this; }
-
- inline QFixedPt<PrecBits> operator<<(int value) const
- { QFixedPt<PrecBits> result; result.val = val << value; return result; }
- inline QFixedPt<PrecBits> operator>>(int value) const
- { QFixedPt<PrecBits> result; result.val = val >> value; return result; }
-
- inline bool operator==(const QFixedPt<PrecBits>& value) const
- { return val == value.val; }
- inline bool operator!=(const QFixedPt<PrecBits>& value) const
- { return val != value.val; }
- inline bool operator<=(const QFixedPt<PrecBits>& value) const
- { return val <= value.val; }
- inline bool operator<(const QFixedPt<PrecBits>& value) const
- { return val < value.val; }
- inline bool operator>=(const QFixedPt<PrecBits>& value) const
- { return val >= value.val; }
- inline bool operator>(const QFixedPt<PrecBits>& value) const
- { return val > value.val; }
-
- inline QFixedPt<PrecBits> operator+(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = val + value.val; return result; }
- inline QFixedPt<PrecBits> operator+(int value) const
- { QFixedPt<PrecBits> result;
- result.val = val + (value << PrecBits); return result; }
- inline QFixedPt<PrecBits> operator+(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = val + int(value * (1 << PrecBits)); return result; }
-
- inline QFixedPt<PrecBits> operator-(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = val - value.val; return result; }
- inline QFixedPt<PrecBits> operator-(int value) const
- { QFixedPt<PrecBits> result;
- result.val = val - (value << PrecBits); return result; }
- inline QFixedPt<PrecBits> operator-(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = val - int(value * (1 << PrecBits)); return result; }
-
- inline QFixedPt<PrecBits> operator*(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = mul(val, value.val); return result; }
- inline QFixedPt<PrecBits> operator*(int value) const
- { QFixedPt<PrecBits> result;
- result.val = mul(val, (value << PrecBits)); return result; }
- inline QFixedPt<PrecBits> operator*(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = mul(val, int(value * (1 << PrecBits))); return result; }
-
- inline QFixedPt<PrecBits> operator/(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = div(val, value.val); return result; }
- inline QFixedPt<PrecBits> operator/(int value) const
- { QFixedPt<PrecBits> result;
- result.val = div(val, (value << PrecBits)); return result; }
- inline QFixedPt<PrecBits> operator/(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = div(val, int(value * (1 << PrecBits))); return result; }
-
- inline QFixedPt<PrecBits> operator-() const
- { QFixedPt<PrecBits> result; result.val = -val; return result; }
-
- inline QFixedPt<PrecBits> sqrt() const;
- inline qreal sqrtF() const;
- inline QFixedPt<PrecBits> round() const;
- inline QFixedPt<PrecBits> floor() const;
- inline QFixedPt<PrecBits> ceil() const;
- inline int truncate() const { return val >> PrecBits; }
-
- inline int toInt() const { return (val + (1 << (PrecBits - 1))) >> PrecBits; }
- inline qreal toReal() const { return qreal(val) / qreal(1 << PrecBits); }
-
-#if !defined(Q_NO_TEMPLATE_FRIENDS)
- template <int Prec>
- friend QFixedPt<Prec> operator/(int v1, const QFixedPt<Prec>& v2);
- template <int Prec>
- friend QFixedPt<Prec> operator/(qreal v1, const QFixedPt<Prec>& v2);
-
-private:
-#endif
- int val;
-
- inline static int mul(int v1, int v2)
- {
- return int((qint64(v1) * qint64(v2)) >> PrecBits);
- }
-
- inline static int div(int v1, int v2)
- {
- if (v2)
- return int((qint64(v1) << PrecBits) / qint64(v2));
- else
- return 0;
- }
-
- // These are used by toPrecision() to avoid a silly gcc compiler warning
- // related to negative shift values that will never actually be used.
- inline static int shiftRight(int val, int shift)
- {
- return val >> shift;
- }
- inline static int shiftLeft(int val, int shift)
- {
- return val << shift;
- }
-
-#if !defined(Q_NO_TEMPLATE_FRIENDS)
- template <int Prec, int Prec2>
- friend QFixedPt<Prec> qFixedPtToPrecision(const QFixedPt<Prec2>& value);
-#endif
-};
-
-template <int PrecBits>
-inline bool operator==(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() == (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator==(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) == v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator==(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() == int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator==(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) == v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator!=(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() != (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator!=(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) != v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator!=(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() != int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator!=(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) != v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<=(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() <= (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator<=(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) <= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<=(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() <= int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator<=(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) <= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() < (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator<(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) < v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() < int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator<(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) < v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>=(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() >= (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator>=(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) >= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>=(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() >= int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator>=(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) >= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() > (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator>(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) > v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() > int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator>(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) > v2.bits();
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator+(int v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 + v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator+(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 + v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator-(int v1, const QFixedPt<PrecBits>& v2)
-{
- return -(v2 - v1);
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator-(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return -(v2 - v1);
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator*(int v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 * v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator*(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 * v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator/(int v1, const QFixedPt<PrecBits>& v2)
-{
- QFixedPt<PrecBits> result;
- result.val = QFixedPt<PrecBits>::div(v1 << PrecBits, v2.val);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator/(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- QFixedPt<PrecBits> result;
- result.val = QFixedPt<PrecBits>::div(int(v1 * (1 << PrecBits)), v2.val);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::sqrt() const
-{
- QFixedPt<PrecBits> result;
- result.val = int(qt_math3d_fixed_sqrt
- (qint64(val) << (PrecBits * 2)) >> (PrecBits / 2));
- return result;
-}
-
-template <int PrecBits>
-inline qreal QFixedPt<PrecBits>::sqrtF() const
-{
- return qt_math3d_fixed_sqrt
- (qint64(val) << (PrecBits * 2)) / (qreal)(1 << (PrecBits + (PrecBits / 2)));
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::round() const
-{
- QFixedPt<PrecBits> result;
- result.val = (val + (1 << (PrecBits - 1))) & ~((1 << PrecBits) - 1);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::floor() const
-{
- QFixedPt<PrecBits> result;
- result.val = val & ~((1 << PrecBits) - 1);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::ceil() const
-{
- QFixedPt<PrecBits> result;
- result.val = (val + (1 << PrecBits) - 1) & ~((1 << PrecBits) - 1);
- return result;
-}
-
-template <int PrecBits>
-inline int qCeil(const QFixedPt<PrecBits>& value)
-{
- return value.ceil().bits() >> PrecBits;
-}
-
-template <int PrecBits>
-inline int qFloor(const QFixedPt<PrecBits>& value)
-{
- return value.floor().bits() >> PrecBits;
-}
-
-template <int PrecBits>
-inline int qRound(const QFixedPt<PrecBits>& value)
-{
- return value.round().bits() >> PrecBits;
-}
-
-template <int PrecBits>
-inline bool qFuzzyCompare(const QFixedPt<PrecBits>& v1, const QFixedPt<PrecBits>& v2, int compareBits = (PrecBits / 4))
-{
- return ((v1.bits() ^ v2.bits()) & ~((1 << compareBits) - 1)) == 0;
-}
-
-template <int PrecBits>
-inline bool qIsNull(const QFixedPt<PrecBits>& v)
-{
- return v.bits() == 0;
-}
-
-template <int Prec, int PrecBits>
-QFixedPt<Prec> qFixedPtToPrecision(const QFixedPt<PrecBits>& value)
-{
- QFixedPt<Prec> result;
- if (Prec < PrecBits)
- result.setBits(QFixedPt<PrecBits>::shiftRight(value.bits(), (PrecBits - Prec)));
- else
- result.setBits(QFixedPt<PrecBits>::shiftLeft(value.bits(), (Prec - PrecBits)));
- return result;
-}
-
-template <int PrecBits>
-inline QDebug &operator<<(QDebug &dbg, const QFixedPt<PrecBits> &f)
-{
- return dbg << f.toReal();
-}
-
-Q_DECLARE_TYPEINFO(QFixedPt<0>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<1>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<2>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<3>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<4>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<5>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<6>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<7>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<8>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<9>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<10>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<11>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<12>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<13>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<14>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<15>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<16>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<17>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<18>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<19>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<20>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<21>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<22>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<23>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<24>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<25>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<26>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<27>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<28>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<29>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<30>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<31>, Q_PRIMITIVE_TYPE);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/gui/math3d/qgenericmatrix.cpp b/src/gui/math3d/qgenericmatrix.cpp
index cb48909..734c1e6 100644
--- a/src/gui/math3d/qgenericmatrix.cpp
+++ b/src/gui/math3d/qgenericmatrix.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h
index 26a0e48..d0b22de 100644
--- a/src/gui/math3d/qgenericmatrix.h
+++ b/src/gui/math3d/qgenericmatrix.h
@@ -5,15 +5,45 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGENERICMATRIX_H
#define QGENERICMATRIX_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qmetatype.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_HEADER
@@ -104,7 +134,7 @@ template <int N, int M, typename T, typename InnerT>
Q_INLINE_TEMPLATE T QGenericMatrix<N, M, T, InnerT>::operator()(int row, int column) const
{
Q_ASSERT(row >= 0 && row < M && column >= 0 && column < N);
- return qt_math3d_convert<T, InnerT>(m[column][row]);
+ return T(m[column][row]);
}
template <int N, int M, typename T, typename InnerT>
@@ -293,18 +323,18 @@ Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T, InnerT>::toValueArray(T *value
{
for (int col = 0; col < N; ++col)
for (int row = 0; row < M; ++row)
- values[row * N + col] = qt_math3d_convert<T, InnerT>(m[col][row]);
+ values[row * N + col] = T(m[col][row]);
}
// Define aliases for the useful variants of QGenericMatrix.
-typedef QGenericMatrix<2, 2, qreal, qrealinner> QMatrix2x2;
-typedef QGenericMatrix<2, 3, qreal, qrealinner> QMatrix2x3;
-typedef QGenericMatrix<2, 4, qreal, qrealinner> QMatrix2x4;
-typedef QGenericMatrix<3, 2, qreal, qrealinner> QMatrix3x2;
-typedef QGenericMatrix<3, 3, qreal, qrealinner> QMatrix3x3;
-typedef QGenericMatrix<3, 4, qreal, qrealinner> QMatrix3x4;
-typedef QGenericMatrix<4, 2, qreal, qrealinner> QMatrix4x2;
-typedef QGenericMatrix<4, 3, qreal, qrealinner> QMatrix4x3;
+typedef QGenericMatrix<2, 2, qreal, float> QMatrix2x2;
+typedef QGenericMatrix<2, 3, qreal, float> QMatrix2x3;
+typedef QGenericMatrix<2, 4, qreal, float> QMatrix2x4;
+typedef QGenericMatrix<3, 2, qreal, float> QMatrix3x2;
+typedef QGenericMatrix<3, 3, qreal, float> QMatrix3x3;
+typedef QGenericMatrix<3, 4, qreal, float> QMatrix3x4;
+typedef QGenericMatrix<4, 2, qreal, float> QMatrix4x2;
+typedef QGenericMatrix<4, 3, qreal, float> QMatrix4x3;
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qmath3dglobal.h b/src/gui/math3d/qmath3dglobal.h
deleted file mode 100644
index ee5e734..0000000
--- a/src/gui/math3d/qmath3dglobal.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $TROLLTECH_DUAL_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMATH3DGLOBAL_H
-#define QMATH3DGLOBAL_H
-
-#include <QtCore/qglobal.h>
-#include <QtGui/qfixedpt.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-// Detect the presence of a fixed-point OpenGL implementation.
-#if defined(QT_OPENGL_ES_1_CL) || defined(QT_NO_GL_FLOAT)
-#ifndef QT_GL_FIXED_PREFERRED
-#define QT_GL_FIXED_PREFERRED 1
-#endif
-#endif
-
-// QT_GL_FIXED_PREFERRED indicates that fixed-point should be
-// preferred over floating-point for operations requiring high performance.
-//
-// qreal is the floating-point type that should be used in
-// user-visible functions. qrealinner is used internally where
-// values may be stored as either floating-point or fixed-point.
-// qrealinner will typically be the same size as GLfloat or GLfixed.
-#if defined(QT_GL_FIXED_PREFERRED)
-typedef QFixedPt<16> qrealinner;
-#else
-typedef float qrealinner;
-#endif
-
-// Explicit conversion operator, primarily for converting from
-// fixed point back to floating-point. This is safer than
-// declaring conversion operators in the QFixedPt class.
-template <typename T1, typename T2>
-T1 qt_math3d_convert(T2 v)
-{
- return T1(v);
-}
-template <>
-inline float qt_math3d_convert< float, QFixedPt<16> >(QFixedPt<16> v)
-{
- return float(v.toReal());
-}
-template <>
-inline double qt_math3d_convert< double, QFixedPt<16> >(QFixedPt<16> v)
-{
- return double(v.toReal());
-}
-template <>
-inline int qt_math3d_convert< int, QFixedPt<16> >(QFixedPt<16> v)
-{
- return v.toInt();
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/gui/math3d/qmath3dutil.cpp b/src/gui/math3d/qmath3dutil.cpp
deleted file mode 100644
index 91d4b15..0000000
--- a/src/gui/math3d/qmath3dutil.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $TROLLTECH_DUAL_LICENSE$
-**
-****************************************************************************/
-
-#include "qmath3dutil_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_GL_FIXED_PREFERRED
-
-// The table that follows was automatically generated by the following code:
-//
-//#include <math.h>
-//#include <stdio.h>
-//
-//int main()
-//{
-// double angle;
-// int count = 0;
-// for (angle = 0.0; angle < 360.0; angle += 1.0) {
-// if ((count % 4) == 0)
-// printf(" ");
-// printf(" qf2vt(%f)", sin(angle * M_PI / 180.0));
-// ++count;
-// if (count != 360)
-// printf(",");
-// if ((count % 4) == 0)
-// printf("\n");
-// }
-// return 0;
-//}
-
-#define qf2vt(x) (int((x) * 65536.0))
-
-static int const sinTable[360] = {
- qf2vt(0.000000), qf2vt(0.017452), qf2vt(0.034899), qf2vt(0.052336),
- qf2vt(0.069756), qf2vt(0.087156), qf2vt(0.104528), qf2vt(0.121869),
- qf2vt(0.139173), qf2vt(0.156434), qf2vt(0.173648), qf2vt(0.190809),
- qf2vt(0.207912), qf2vt(0.224951), qf2vt(0.241922), qf2vt(0.258819),
- qf2vt(0.275637), qf2vt(0.292372), qf2vt(0.309017), qf2vt(0.325568),
- qf2vt(0.342020), qf2vt(0.358368), qf2vt(0.374607), qf2vt(0.390731),
- qf2vt(0.406737), qf2vt(0.422618), qf2vt(0.438371), qf2vt(0.453990),
- qf2vt(0.469472), qf2vt(0.484810), qf2vt(0.500000), qf2vt(0.515038),
- qf2vt(0.529919), qf2vt(0.544639), qf2vt(0.559193), qf2vt(0.573576),
- qf2vt(0.587785), qf2vt(0.601815), qf2vt(0.615661), qf2vt(0.629320),
- qf2vt(0.642788), qf2vt(0.656059), qf2vt(0.669131), qf2vt(0.681998),
- qf2vt(0.694658), qf2vt(0.707107), qf2vt(0.719340), qf2vt(0.731354),
- qf2vt(0.743145), qf2vt(0.754710), qf2vt(0.766044), qf2vt(0.777146),
- qf2vt(0.788011), qf2vt(0.798636), qf2vt(0.809017), qf2vt(0.819152),
- qf2vt(0.829038), qf2vt(0.838671), qf2vt(0.848048), qf2vt(0.857167),
- qf2vt(0.866025), qf2vt(0.874620), qf2vt(0.882948), qf2vt(0.891007),
- qf2vt(0.898794), qf2vt(0.906308), qf2vt(0.913545), qf2vt(0.920505),
- qf2vt(0.927184), qf2vt(0.933580), qf2vt(0.939693), qf2vt(0.945519),
- qf2vt(0.951057), qf2vt(0.956305), qf2vt(0.961262), qf2vt(0.965926),
- qf2vt(0.970296), qf2vt(0.974370), qf2vt(0.978148), qf2vt(0.981627),
- qf2vt(0.984808), qf2vt(0.987688), qf2vt(0.990268), qf2vt(0.992546),
- qf2vt(0.994522), qf2vt(0.996195), qf2vt(0.997564), qf2vt(0.998630),
- qf2vt(0.999391), qf2vt(0.999848), qf2vt(1.000000), qf2vt(0.999848),
- qf2vt(0.999391), qf2vt(0.998630), qf2vt(0.997564), qf2vt(0.996195),
- qf2vt(0.994522), qf2vt(0.992546), qf2vt(0.990268), qf2vt(0.987688),
- qf2vt(0.984808), qf2vt(0.981627), qf2vt(0.978148), qf2vt(0.974370),
- qf2vt(0.970296), qf2vt(0.965926), qf2vt(0.961262), qf2vt(0.956305),
- qf2vt(0.951057), qf2vt(0.945519), qf2vt(0.939693), qf2vt(0.933580),
- qf2vt(0.927184), qf2vt(0.920505), qf2vt(0.913545), qf2vt(0.906308),
- qf2vt(0.898794), qf2vt(0.891007), qf2vt(0.882948), qf2vt(0.874620),
- qf2vt(0.866025), qf2vt(0.857167), qf2vt(0.848048), qf2vt(0.838671),
- qf2vt(0.829038), qf2vt(0.819152), qf2vt(0.809017), qf2vt(0.798636),
- qf2vt(0.788011), qf2vt(0.777146), qf2vt(0.766044), qf2vt(0.754710),
- qf2vt(0.743145), qf2vt(0.731354), qf2vt(0.719340), qf2vt(0.707107),
- qf2vt(0.694658), qf2vt(0.681998), qf2vt(0.669131), qf2vt(0.656059),
- qf2vt(0.642788), qf2vt(0.629320), qf2vt(0.615661), qf2vt(0.601815),
- qf2vt(0.587785), qf2vt(0.573576), qf2vt(0.559193), qf2vt(0.544639),
- qf2vt(0.529919), qf2vt(0.515038), qf2vt(0.500000), qf2vt(0.484810),
- qf2vt(0.469472), qf2vt(0.453990), qf2vt(0.438371), qf2vt(0.422618),
- qf2vt(0.406737), qf2vt(0.390731), qf2vt(0.374607), qf2vt(0.358368),
- qf2vt(0.342020), qf2vt(0.325568), qf2vt(0.309017), qf2vt(0.292372),
- qf2vt(0.275637), qf2vt(0.258819), qf2vt(0.241922), qf2vt(0.224951),
- qf2vt(0.207912), qf2vt(0.190809), qf2vt(0.173648), qf2vt(0.156434),
- qf2vt(0.139173), qf2vt(0.121869), qf2vt(0.104528), qf2vt(0.087156),
- qf2vt(0.069756), qf2vt(0.052336), qf2vt(0.034899), qf2vt(0.017452),
- qf2vt(0.000000), qf2vt(-0.017452), qf2vt(-0.034899), qf2vt(-0.052336),
- qf2vt(-0.069756), qf2vt(-0.087156), qf2vt(-0.104528), qf2vt(-0.121869),
- qf2vt(-0.139173), qf2vt(-0.156434), qf2vt(-0.173648), qf2vt(-0.190809),
- qf2vt(-0.207912), qf2vt(-0.224951), qf2vt(-0.241922), qf2vt(-0.258819),
- qf2vt(-0.275637), qf2vt(-0.292372), qf2vt(-0.309017), qf2vt(-0.325568),
- qf2vt(-0.342020), qf2vt(-0.358368), qf2vt(-0.374607), qf2vt(-0.390731),
- qf2vt(-0.406737), qf2vt(-0.422618), qf2vt(-0.438371), qf2vt(-0.453990),
- qf2vt(-0.469472), qf2vt(-0.484810), qf2vt(-0.500000), qf2vt(-0.515038),
- qf2vt(-0.529919), qf2vt(-0.544639), qf2vt(-0.559193), qf2vt(-0.573576),
- qf2vt(-0.587785), qf2vt(-0.601815), qf2vt(-0.615661), qf2vt(-0.629320),
- qf2vt(-0.642788), qf2vt(-0.656059), qf2vt(-0.669131), qf2vt(-0.681998),
- qf2vt(-0.694658), qf2vt(-0.707107), qf2vt(-0.719340), qf2vt(-0.731354),
- qf2vt(-0.743145), qf2vt(-0.754710), qf2vt(-0.766044), qf2vt(-0.777146),
- qf2vt(-0.788011), qf2vt(-0.798636), qf2vt(-0.809017), qf2vt(-0.819152),
- qf2vt(-0.829038), qf2vt(-0.838671), qf2vt(-0.848048), qf2vt(-0.857167),
- qf2vt(-0.866025), qf2vt(-0.874620), qf2vt(-0.882948), qf2vt(-0.891007),
- qf2vt(-0.898794), qf2vt(-0.906308), qf2vt(-0.913545), qf2vt(-0.920505),
- qf2vt(-0.927184), qf2vt(-0.933580), qf2vt(-0.939693), qf2vt(-0.945519),
- qf2vt(-0.951057), qf2vt(-0.956305), qf2vt(-0.961262), qf2vt(-0.965926),
- qf2vt(-0.970296), qf2vt(-0.974370), qf2vt(-0.978148), qf2vt(-0.981627),
- qf2vt(-0.984808), qf2vt(-0.987688), qf2vt(-0.990268), qf2vt(-0.992546),
- qf2vt(-0.994522), qf2vt(-0.996195), qf2vt(-0.997564), qf2vt(-0.998630),
- qf2vt(-0.999391), qf2vt(-0.999848), qf2vt(-1.000000), qf2vt(-0.999848),
- qf2vt(-0.999391), qf2vt(-0.998630), qf2vt(-0.997564), qf2vt(-0.996195),
- qf2vt(-0.994522), qf2vt(-0.992546), qf2vt(-0.990268), qf2vt(-0.987688),
- qf2vt(-0.984808), qf2vt(-0.981627), qf2vt(-0.978148), qf2vt(-0.974370),
- qf2vt(-0.970296), qf2vt(-0.965926), qf2vt(-0.961262), qf2vt(-0.956305),
- qf2vt(-0.951057), qf2vt(-0.945519), qf2vt(-0.939693), qf2vt(-0.933580),
- qf2vt(-0.927184), qf2vt(-0.920505), qf2vt(-0.913545), qf2vt(-0.906308),
- qf2vt(-0.898794), qf2vt(-0.891007), qf2vt(-0.882948), qf2vt(-0.874620),
- qf2vt(-0.866025), qf2vt(-0.857167), qf2vt(-0.848048), qf2vt(-0.838671),
- qf2vt(-0.829038), qf2vt(-0.819152), qf2vt(-0.809017), qf2vt(-0.798636),
- qf2vt(-0.788011), qf2vt(-0.777146), qf2vt(-0.766044), qf2vt(-0.754710),
- qf2vt(-0.743145), qf2vt(-0.731354), qf2vt(-0.719340), qf2vt(-0.707107),
- qf2vt(-0.694658), qf2vt(-0.681998), qf2vt(-0.669131), qf2vt(-0.656059),
- qf2vt(-0.642788), qf2vt(-0.629320), qf2vt(-0.615661), qf2vt(-0.601815),
- qf2vt(-0.587785), qf2vt(-0.573576), qf2vt(-0.559193), qf2vt(-0.544639),
- qf2vt(-0.529919), qf2vt(-0.515038), qf2vt(-0.500000), qf2vt(-0.484810),
- qf2vt(-0.469472), qf2vt(-0.453990), qf2vt(-0.438371), qf2vt(-0.422618),
- qf2vt(-0.406737), qf2vt(-0.390731), qf2vt(-0.374607), qf2vt(-0.358368),
- qf2vt(-0.342020), qf2vt(-0.325568), qf2vt(-0.309017), qf2vt(-0.292372),
- qf2vt(-0.275637), qf2vt(-0.258819), qf2vt(-0.241922), qf2vt(-0.224951),
- qf2vt(-0.207912), qf2vt(-0.190809), qf2vt(-0.173648), qf2vt(-0.156434),
- qf2vt(-0.139173), qf2vt(-0.121869), qf2vt(-0.104528), qf2vt(-0.087156),
- qf2vt(-0.069756), qf2vt(-0.052336), qf2vt(-0.034899), qf2vt(-0.017452)
-};
-
-void qt_math3d_sincos(qreal angle, qrealinner *s, qrealinner *c)
-{
- if (angle == qFloor(angle)) {
- // The angle is an integer number of degrees, so look up the results.
- int a = (int)angle;
- if (a >= 0)
- a = (a % 360);
- else
- a = 360 - (-a % 360);
- s->setBits(sinTable[a]);
- c->setBits(sinTable[(a + 90) % 360]);
- } else {
- qreal a = angle * M_PI / 180.0f;
- *s = qSin(a);
- *c = qCos(a);
- }
-}
-
-#else
-
-void qt_math3d_sincos(qreal angle, qrealinner *s, qrealinner *c)
-{
- qreal a = angle * M_PI / 180.0f;
- *s = qSin(a);
- *c = qCos(a);
-}
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/gui/math3d/qmath3dutil_p.h b/src/gui/math3d/qmath3dutil_p.h
deleted file mode 100644
index 1cb0bb9..0000000
--- a/src/gui/math3d/qmath3dutil_p.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $TROLLTECH_DUAL_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMATH3DUTIL_P_H
-#define QMATH3DUTIL_P_H
-
-#include <QtGui/qmath3dglobal.h>
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_GL_FIXED_PREFERRED
-#define qvtsqrt(x) ((x).sqrtF())
-#else
-#define qvtsqrt(x) qSqrt((x))
-#endif
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-void qt_math3d_sincos(qreal degrees, qrealinner *s, qrealinner *c);
-
-#ifdef QT_GL_FIXED_PREFERRED
-
-inline qrealinner qf2vt_round(qreal x)
-{
- QFixedPt<16> result;
- if (x >= 0.0f)
- result.setBits(int(x * 65536.0f + 0.5f));
- else
- result.setBits(int(x * 65536.0f - 0.5f));
- return result;
-}
-
-// Helper macros for computing dot products without losing precision.
-// In fixed-point mode, a 64-bit intermediate result is used.
-#define qvtmul64(x,y) ((qint64((x).bits())) * (qint64((y).bits())))
-#define qvtsqrt64(x) \
- (qt_math3d_fixed_sqrt((x) << 16) / (qreal)(1 << 24))
-#define qvtdot64(x) ((x) / (qreal)(((qint64)1) << 32))
-
-#else
-
-inline qrealinner qf2vt_round(qreal x)
-{
- return x;
-}
-
-#define qvtmul64(x,y) ((x) * (y))
-#define qvtsqrt64(x) (qvtsqrt((x)))
-#define qvtdot64(x) ((x))
-
-#endif
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index 9941ca8..649532d 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -5,12 +5,41 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#include "qmatrix4x4.h"
-#include "qmath3dutil_p.h"
#include <QtCore/qmath.h>
#include <QtGui/qmatrix.h>
#include <QtGui/qtransform.h>
@@ -76,7 +105,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
/*!
- \fn QMatrix4x4::QMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+ \fn QMatrix4x4::QMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
Constructs a 4x4 matrix from the left-most 4 columns and top-most
4 rows of \a matrix. If \a matrix has less than 4 columns or rows,
@@ -87,7 +116,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
*/
/*!
- \fn QGenericMatrix<N, M, qreal, qrealinner> QMatrix4x4::toGenericMatrix() const
+ \fn QGenericMatrix<N, M, qreal, float> QMatrix4x4::toGenericMatrix() const
Constructs a NxM generic matrix from the left-most N columns and
top-most M rows of this 4x4 matrix. If N or M is greater than 4,
@@ -100,7 +129,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
#endif
/*!
- \fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+ \fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
\relates QMatrix4x4
Returns a 4x4 matrix constructed from the left-most 4 columns and
@@ -112,7 +141,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
*/
/*!
- \fn QGenericMatrix<N, M, qreal, qrealinner> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
+ \fn QGenericMatrix<N, M, qreal, float> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
\relates QMatrix4x4
Returns a NxM generic matrix constructed from the left-most N columns
@@ -126,7 +155,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
/*!
\internal
*/
-QMatrix4x4::QMatrix4x4(const qrealinner *values, int cols, int rows)
+QMatrix4x4::QMatrix4x4(const float *values, int cols, int rows)
{
for (int col = 0; col < 4; ++col) {
for (int row = 0; row < 4; ++row) {
@@ -214,7 +243,7 @@ QMatrix4x4::QMatrix4x4(const QTransform& transform)
*/
/*!
- \fn qrealinner& QMatrix4x4::operator()(int row, int column)
+ \fn float& QMatrix4x4::operator()(int row, int column)
Returns a reference to the element at position (\a row, \a column)
in this matrix so that the element can be assigned to.
@@ -286,8 +315,8 @@ QMatrix4x4::QMatrix4x4(const QTransform& transform)
// | A B C |
// M = | D E F | det(M) = A * (EI - HF) - B * (DI - GF) + C * (DH - GE)
// | G H I |
-static inline qrealinner matrixDet3
- (const qrealinner m[4][4], int col0, int col1, int col2,
+static inline float matrixDet3
+ (const float m[4][4], int col0, int col1, int col2,
int row0, int row1, int row2)
{
return m[col0][row0] *
@@ -302,9 +331,9 @@ static inline qrealinner matrixDet3
}
// Calculate the determinant of a 4x4 matrix.
-static inline qrealinner matrixDet4(const qrealinner m[4][4])
+static inline float matrixDet4(const float m[4][4])
{
- qrealinner det;
+ float det;
det = m[0][0] * matrixDet3(m, 1, 2, 3, 1, 2, 3);
det -= m[1][0] * matrixDet3(m, 0, 2, 3, 1, 2, 3);
det += m[2][0] * matrixDet3(m, 0, 1, 3, 1, 2, 3);
@@ -317,7 +346,7 @@ static inline qrealinner matrixDet4(const qrealinner m[4][4])
*/
qreal QMatrix4x4::determinant() const
{
- return qt_math3d_convert<qreal, qrealinner>(matrixDet4(m));
+ return qreal(matrixDet4(m));
}
/*!
@@ -356,13 +385,13 @@ QMatrix4x4 QMatrix4x4::inverted(bool *invertible) const
QMatrix4x4 inv(1); // The "1" says to not load the identity.
- qrealinner det = matrixDet4(m);
+ float det = matrixDet4(m);
if (det == 0.0f) {
if (invertible)
*invertible = false;
return QMatrix4x4();
}
- det = qrealinner(1.0f) / det;
+ det = 1.0f / det;
inv.m[0][0] = matrixDet3(m, 1, 2, 3, 1, 2, 3) * det;
inv.m[0][1] = -matrixDet3(m, 0, 2, 3, 1, 2, 3) * det;
@@ -404,18 +433,18 @@ QMatrix3x3 QMatrix4x4::normalMatrix() const
} else if (flagBits == Scale || flagBits == (Translation | Scale)) {
if (m[0][0] == 0.0f || m[1][1] == 0.0f || m[2][2] == 0.0f)
return inv;
- inv.data()[0] = qrealinner(1.0f) / m[0][0];
- inv.data()[4] = qrealinner(1.0f) / m[1][1];
- inv.data()[8] = qrealinner(1.0f) / m[2][2];
+ inv.data()[0] = 1.0f / m[0][0];
+ inv.data()[4] = 1.0f / m[1][1];
+ inv.data()[8] = 1.0f / m[2][2];
return inv;
}
- qrealinner det = matrixDet3(m, 0, 1, 2, 0, 1, 2);
+ float det = matrixDet3(m, 0, 1, 2, 0, 1, 2);
if (det == 0.0f)
return inv;
- det = qrealinner(1.0f) / det;
+ det = 1.0f / det;
- qrealinner *invm = inv.data();
+ float *invm = inv.data();
// Invert and transpose in a single step.
invm[0 + 0 * 3] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]) * det;
@@ -477,23 +506,22 @@ QMatrix4x4 QMatrix4x4::transposed() const
*/
QMatrix4x4& QMatrix4x4::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- m[0][0] /= d;
- m[0][1] /= d;
- m[0][2] /= d;
- m[0][3] /= d;
- m[1][0] /= d;
- m[1][1] /= d;
- m[1][2] /= d;
- m[1][3] /= d;
- m[2][0] /= d;
- m[2][1] /= d;
- m[2][2] /= d;
- m[2][3] /= d;
- m[3][0] /= d;
- m[3][1] /= d;
- m[3][2] /= d;
- m[3][3] /= d;
+ m[0][0] /= divisor;
+ m[0][1] /= divisor;
+ m[0][2] /= divisor;
+ m[0][3] /= divisor;
+ m[1][0] /= divisor;
+ m[1][1] /= divisor;
+ m[1][2] /= divisor;
+ m[1][3] /= divisor;
+ m[2][0] /= divisor;
+ m[2][1] /= divisor;
+ m[2][2] /= divisor;
+ m[2][3] /= divisor;
+ m[3][0] /= divisor;
+ m[3][1] /= divisor;
+ m[3][2] /= divisor;
+ m[3][3] /= divisor;
flagBits = General;
return *this;
}
@@ -635,23 +663,22 @@ QMatrix4x4& QMatrix4x4::operator/=(qreal divisor)
QMatrix4x4 operator/(const QMatrix4x4& matrix, qreal divisor)
{
QMatrix4x4 m(1); // The "1" says to not load the identity.
- qrealinner d(divisor);
- m.m[0][0] = matrix.m[0][0] / d;
- m.m[0][1] = matrix.m[0][1] / d;
- m.m[0][2] = matrix.m[0][2] / d;
- m.m[0][3] = matrix.m[0][3] / d;
- m.m[1][0] = matrix.m[1][0] / d;
- m.m[1][1] = matrix.m[1][1] / d;
- m.m[1][2] = matrix.m[1][2] / d;
- m.m[1][3] = matrix.m[1][3] / d;
- m.m[2][0] = matrix.m[2][0] / d;
- m.m[2][1] = matrix.m[2][1] / d;
- m.m[2][2] = matrix.m[2][2] / d;
- m.m[2][3] = matrix.m[2][3] / d;
- m.m[3][0] = matrix.m[3][0] / d;
- m.m[3][1] = matrix.m[3][1] / d;
- m.m[3][2] = matrix.m[3][2] / d;
- m.m[3][3] = matrix.m[3][3] / d;
+ m.m[0][0] = matrix.m[0][0] / divisor;
+ m.m[0][1] = matrix.m[0][1] / divisor;
+ m.m[0][2] = matrix.m[0][2] / divisor;
+ m.m[0][3] = matrix.m[0][3] / divisor;
+ m.m[1][0] = matrix.m[1][0] / divisor;
+ m.m[1][1] = matrix.m[1][1] / divisor;
+ m.m[1][2] = matrix.m[1][2] / divisor;
+ m.m[1][3] = matrix.m[1][3] / divisor;
+ m.m[2][0] = matrix.m[2][0] / divisor;
+ m.m[2][1] = matrix.m[2][1] / divisor;
+ m.m[2][2] = matrix.m[2][2] / divisor;
+ m.m[2][3] = matrix.m[2][3] / divisor;
+ m.m[3][0] = matrix.m[3][0] / divisor;
+ m.m[3][1] = matrix.m[3][1] / divisor;
+ m.m[3][2] = matrix.m[3][2] / divisor;
+ m.m[3][3] = matrix.m[3][3] / divisor;
return m;
}
@@ -673,9 +700,9 @@ QMatrix4x4 operator/(const QMatrix4x4& matrix, qreal divisor)
*/
QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector)
{
- qrealinner vx = vector.xp;
- qrealinner vy = vector.yp;
- qrealinner vz = vector.zp;
+ float vx = vector.xp;
+ float vy = vector.yp;
+ float vz = vector.zp;
if (flagBits == Identity) {
m[0][0] = vx;
m[1][1] = vy;
@@ -719,9 +746,9 @@ QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector)
*/
QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y, qreal z)
{
- qrealinner vx(x);
- qrealinner vy(y);
- qrealinner vz(z);
+ float vx(x);
+ float vy(y);
+ float vz(z);
if (flagBits == Identity) {
m[0][0] = vx;
m[1][1] = vy;
@@ -764,34 +791,33 @@ QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y, qreal z)
*/
QMatrix4x4& QMatrix4x4::scale(qreal factor)
{
- qrealinner f(factor);
if (flagBits == Identity) {
- m[0][0] = f;
- m[1][1] = f;
- m[2][2] = f;
+ m[0][0] = factor;
+ m[1][1] = factor;
+ m[2][2] = factor;
flagBits = Scale;
} else if (flagBits == Scale || flagBits == (Scale | Translation)) {
- m[0][0] *= f;
- m[1][1] *= f;
- m[2][2] *= f;
+ m[0][0] *= factor;
+ m[1][1] *= factor;
+ m[2][2] *= factor;
} else if (flagBits == Translation) {
- m[0][0] = f;
- m[1][1] = f;
- m[2][2] = f;
+ m[0][0] = factor;
+ m[1][1] = factor;
+ m[2][2] = factor;
flagBits |= Scale;
} else {
- m[0][0] *= f;
- m[0][1] *= f;
- m[0][2] *= f;
- m[0][3] *= f;
- m[1][0] *= f;
- m[1][1] *= f;
- m[1][2] *= f;
- m[1][3] *= f;
- m[2][0] *= f;
- m[2][1] *= f;
- m[2][2] *= f;
- m[2][3] *= f;
+ m[0][0] *= factor;
+ m[0][1] *= factor;
+ m[0][2] *= factor;
+ m[0][3] *= factor;
+ m[1][0] *= factor;
+ m[1][1] *= factor;
+ m[1][2] *= factor;
+ m[1][3] *= factor;
+ m[2][0] *= factor;
+ m[2][1] *= factor;
+ m[2][2] *= factor;
+ m[2][3] *= factor;
flagBits = General;
}
return *this;
@@ -806,9 +832,9 @@ QMatrix4x4& QMatrix4x4::scale(qreal factor)
*/
QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector)
{
- qrealinner vx = vector.xp;
- qrealinner vy = vector.yp;
- qrealinner vz = vector.zp;
+ float vx = vector.xp;
+ float vy = vector.yp;
+ float vz = vector.zp;
if (flagBits == Identity) {
m[3][0] = vx;
m[3][1] = vy;
@@ -852,9 +878,9 @@ QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector)
*/
QMatrix4x4& QMatrix4x4::translate(qreal x, qreal y, qreal z)
{
- qrealinner vx(x);
- qrealinner vy(y);
- qrealinner vz(z);
+ float vx(x);
+ float vy(y);
+ float vz(z);
if (flagBits == Identity) {
m[3][0] = vx;
m[3][1] = vy;
@@ -901,6 +927,10 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector)
#endif
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
/*!
\overload
@@ -912,8 +942,10 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector)
QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
{
QMatrix4x4 m(1); // The "1" says to not load the identity.
- qrealinner c, s, ic;
- qt_math3d_sincos(angle, &s, &c);
+ qreal a = angle * M_PI / 180.0f;
+ qreal c = qCos(a);
+ qreal s = qSin(a);
+ qreal ic;
bool quick = false;
if (x == 0.0f) {
if (y == 0.0f) {
@@ -963,27 +995,25 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
quick = true;
}
if (!quick) {
- qrealinner vx(x);
- qrealinner vy(y);
- qrealinner vz(z);
- qrealinner len(qvtsqrt(vx * vx + vy * vy + vz * vz));
- if (len != 0) {
- vx /= len;
- vy /= len;
- vz /= len;
+ qreal len = x * x + y * y + z * z;
+ if (!qFuzzyIsNull(len - 1.0f) && !qFuzzyIsNull(len)) {
+ len = qSqrt(len);
+ x /= len;
+ y /= len;
+ z /= len;
}
ic = 1.0f - c;
- m.m[0][0] = vx * vx * ic + c;
- m.m[1][0] = vx * vy * ic - vz * s;
- m.m[2][0] = vx * vz * ic + vy * s;
+ m.m[0][0] = x * x * ic + c;
+ m.m[1][0] = x * y * ic - z * s;
+ m.m[2][0] = x * z * ic + y * s;
m.m[3][0] = 0.0f;
- m.m[0][1] = vy * vx * ic + vz * s;
- m.m[1][1] = vy * vy * ic + c;
- m.m[2][1] = vy * vz * ic - vx * s;
+ m.m[0][1] = y * x * ic + z * s;
+ m.m[1][1] = y * y * ic + c;
+ m.m[2][1] = y * z * ic - x * s;
m.m[3][1] = 0.0f;
- m.m[0][2] = vx * vz * ic - vy * s;
- m.m[1][2] = vy * vz * ic + vx * s;
- m.m[2][2] = vz * vz * ic + c;
+ m.m[0][2] = x * z * ic - y * s;
+ m.m[1][2] = y * z * ic + x * s;
+ m.m[2][2] = z * z * ic + c;
m.m[3][2] = 0.0f;
m.m[0][3] = 0.0f;
m.m[1][3] = 0.0f;
@@ -1013,15 +1043,15 @@ QMatrix4x4& QMatrix4x4::rotate(const QQuaternion& quaternion)
// Algorithm from:
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q54
QMatrix4x4 m(1);
- qrealinner xx = quaternion.xp * quaternion.xp;
- qrealinner xy = quaternion.xp * quaternion.yp;
- qrealinner xz = quaternion.xp * quaternion.zp;
- qrealinner xw = quaternion.xp * quaternion.wp;
- qrealinner yy = quaternion.yp * quaternion.yp;
- qrealinner yz = quaternion.yp * quaternion.zp;
- qrealinner yw = quaternion.yp * quaternion.wp;
- qrealinner zz = quaternion.zp * quaternion.zp;
- qrealinner zw = quaternion.zp * quaternion.wp;
+ float xx = quaternion.xp * quaternion.xp;
+ float xy = quaternion.xp * quaternion.yp;
+ float xz = quaternion.xp * quaternion.zp;
+ float xw = quaternion.xp * quaternion.wp;
+ float yy = quaternion.yp * quaternion.yp;
+ float yz = quaternion.yp * quaternion.zp;
+ float yw = quaternion.yp * quaternion.wp;
+ float zz = quaternion.zp * quaternion.zp;
+ float zw = quaternion.zp * quaternion.wp;
m.m[0][0] = 1.0f - 2 * (yy + zz);
m.m[1][0] = 2 * (xy - zw);
m.m[2][0] = 2 * (xz + yw);
@@ -1107,33 +1137,33 @@ QMatrix4x4& QMatrix4x4::ortho(qreal left, qreal right, qreal bottom, qreal top,
// which will be more efficient to modify with further
// transformations than producing a "General" matrix.
translate(QVector3D
- (qf2vt_round(-(left + right) / width),
- qf2vt_round(-(top + bottom) / invheight),
+ (-(left + right) / width,
+ -(top + bottom) / invheight,
0.0f, 1));
scale(QVector3D
- (qf2vt_round(2.0f / width),
- qf2vt_round(2.0f / invheight),
+ (2.0f / width,
+ 2.0f / invheight,
-1.0f, 1));
return *this;
}
#endif
QMatrix4x4 m(1);
- m.m[0][0] = qf2vt_round(2.0f / width);
- m.m[1][0] = qf2vt_round(0.0f);
- m.m[2][0] = qf2vt_round(0.0f);
- m.m[3][0] = qf2vt_round(-(left + right) / width);
- m.m[0][1] = qf2vt_round(0.0f);
- m.m[1][1] = qf2vt_round(2.0f / invheight);
- m.m[2][1] = qf2vt_round(0.0f);
- m.m[3][1] = qf2vt_round(-(top + bottom) / invheight);
- m.m[0][2] = qf2vt_round(0.0f);
- m.m[1][2] = qf2vt_round(0.0f);
- m.m[2][2] = qf2vt_round(-2.0f / clip);
- m.m[3][2] = qf2vt_round(-(nearPlane + farPlane) / clip);
- m.m[0][3] = qf2vt_round(0.0f);
- m.m[1][3] = qf2vt_round(0.0f);
- m.m[2][3] = qf2vt_round(0.0f);
- m.m[3][3] = qf2vt_round(1.0f);
+ m.m[0][0] = 2.0f / width;
+ m.m[1][0] = 0.0f;
+ m.m[2][0] = 0.0f;
+ m.m[3][0] = -(left + right) / width;
+ m.m[0][1] = 0.0f;
+ m.m[1][1] = 2.0f / invheight;
+ m.m[2][1] = 0.0f;
+ m.m[3][1] = -(top + bottom) / invheight;
+ m.m[0][2] = 0.0f;
+ m.m[1][2] = 0.0f;
+ m.m[2][2] = -2.0f / clip;
+ m.m[3][2] = -(nearPlane + farPlane) / clip;
+ m.m[0][3] = 0.0f;
+ m.m[1][3] = 0.0f;
+ m.m[2][3] = 0.0f;
+ m.m[3][3] = 1.0f;
// Apply the projection.
*this *= m;
@@ -1159,22 +1189,22 @@ QMatrix4x4& QMatrix4x4::frustum(qreal left, qreal right, qreal bottom, qreal top
qreal width = right - left;
qreal invheight = top - bottom;
qreal clip = farPlane - nearPlane;
- m.m[0][0] = qf2vt_round(2.0f * nearPlane / width);
- m.m[1][0] = qf2vt_round(0.0f);
- m.m[2][0] = qf2vt_round((left + right) / width);
- m.m[3][0] = qf2vt_round(0.0f);
- m.m[0][1] = qf2vt_round(0.0f);
- m.m[1][1] = qf2vt_round(2.0f * nearPlane / invheight);
- m.m[2][1] = qf2vt_round((top + bottom) / invheight);
- m.m[3][1] = qf2vt_round(0.0f);
- m.m[0][2] = qf2vt_round(0.0f);
- m.m[1][2] = qf2vt_round(0.0f);
- m.m[2][2] = qf2vt_round(-(nearPlane + farPlane) / clip);
- m.m[3][2] = qf2vt_round(-(2.0f * nearPlane * farPlane) / clip);
- m.m[0][3] = qf2vt_round(0.0f);
- m.m[1][3] = qf2vt_round(0.0f);
- m.m[2][3] = qf2vt_round(-1.0f);
- m.m[3][3] = qf2vt_round(0.0f);
+ m.m[0][0] = 2.0f * nearPlane / width;
+ m.m[1][0] = 0.0f;
+ m.m[2][0] = (left + right) / width;
+ m.m[3][0] = 0.0f;
+ m.m[0][1] = 0.0f;
+ m.m[1][1] = 2.0f * nearPlane / invheight;
+ m.m[2][1] = (top + bottom) / invheight;
+ m.m[3][1] = 0.0f;
+ m.m[0][2] = 0.0f;
+ m.m[1][2] = 0.0f;
+ m.m[2][2] = -(nearPlane + farPlane) / clip;
+ m.m[3][2] = -2.0f * nearPlane * farPlane / clip;
+ m.m[0][3] = 0.0f;
+ m.m[1][3] = 0.0f;
+ m.m[2][3] = -1.0f;
+ m.m[3][3] = 0.0f;
// Apply the projection.
*this *= m;
@@ -1204,22 +1234,22 @@ QMatrix4x4& QMatrix4x4::perspective(qreal angle, qreal aspect, qreal nearPlane,
return *this;
qreal cotan = qCos(radians) / sine;
qreal clip = farPlane - nearPlane;
- m.m[0][0] = qf2vt_round(cotan / aspect);
- m.m[1][0] = qf2vt_round(0.0f);
- m.m[2][0] = qf2vt_round(0.0f);
- m.m[3][0] = qf2vt_round(0.0f);
- m.m[0][1] = qf2vt_round(0.0f);
- m.m[1][1] = qf2vt_round(cotan);
- m.m[2][1] = qf2vt_round(0.0f);
- m.m[3][1] = qf2vt_round(0.0f);
- m.m[0][2] = qf2vt_round(0.0f);
- m.m[1][2] = qf2vt_round(0.0f);
- m.m[2][2] = qf2vt_round(-(nearPlane + farPlane) / clip);
- m.m[3][2] = qf2vt_round(-(2.0f * nearPlane * farPlane) / clip);
- m.m[0][3] = qf2vt_round(0.0f);
- m.m[1][3] = qf2vt_round(0.0f);
- m.m[2][3] = qf2vt_round(-1.0f);
- m.m[3][3] = qf2vt_round(0.0f);
+ m.m[0][0] = cotan / aspect;
+ m.m[1][0] = 0.0f;
+ m.m[2][0] = 0.0f;
+ m.m[3][0] = 0.0f;
+ m.m[0][1] = 0.0f;
+ m.m[1][1] = cotan;
+ m.m[2][1] = 0.0f;
+ m.m[3][1] = 0.0f;
+ m.m[0][2] = 0.0f;
+ m.m[1][2] = 0.0f;
+ m.m[2][2] = -(nearPlane + farPlane) / clip;
+ m.m[3][2] = -(2.0f * nearPlane * farPlane) / clip;
+ m.m[0][3] = 0.0f;
+ m.m[1][3] = 0.0f;
+ m.m[2][3] = -1.0f;
+ m.m[3][3] = 0.0f;
// Apply the projection.
*this *= m;
@@ -1309,7 +1339,7 @@ void QMatrix4x4::toValueArray(qreal *values) const
{
for (int row = 0; row < 4; ++row)
for (int col = 0; col < 4; ++col)
- values[row * 4 + col] = qt_math3d_convert<qreal, qrealinner>(m[col][row]);
+ values[row * 4 + col] = qreal(m[col][row]);
}
/*!
@@ -1321,12 +1351,9 @@ void QMatrix4x4::toValueArray(qreal *values) const
*/
QMatrix QMatrix4x4::toAffine() const
{
- return QMatrix(qt_math3d_convert<qreal, qrealinner>(m[0][0]),
- qt_math3d_convert<qreal, qrealinner>(m[0][1]),
- qt_math3d_convert<qreal, qrealinner>(m[1][0]),
- qt_math3d_convert<qreal, qrealinner>(m[1][1]),
- qt_math3d_convert<qreal, qrealinner>(m[3][0]),
- qt_math3d_convert<qreal, qrealinner>(m[3][1]));
+ return QMatrix(qreal(m[0][0]), qreal(m[0][1]),
+ qreal(m[1][0]), qreal(m[1][1]),
+ qreal(m[3][0]), qreal(m[3][1]));
}
/*!
@@ -1338,15 +1365,9 @@ QMatrix QMatrix4x4::toAffine() const
*/
QTransform QMatrix4x4::toTransform() const
{
- return QTransform(qt_math3d_convert<qreal, qrealinner>(m[0][0]),
- qt_math3d_convert<qreal, qrealinner>(m[0][1]),
- qt_math3d_convert<qreal, qrealinner>(m[0][3]),
- qt_math3d_convert<qreal, qrealinner>(m[1][0]),
- qt_math3d_convert<qreal, qrealinner>(m[1][1]),
- qt_math3d_convert<qreal, qrealinner>(m[1][3]),
- qt_math3d_convert<qreal, qrealinner>(m[3][0]),
- qt_math3d_convert<qreal, qrealinner>(m[3][1]),
- qt_math3d_convert<qreal, qrealinner>(m[3][3]));
+ return QTransform(qreal(m[0][0]), qreal(m[0][1]), qreal(m[0][3]),
+ qreal(m[1][0]), qreal(m[1][1]), qreal(m[1][3]),
+ qreal(m[3][0]), qreal(m[3][1]), qreal(m[3][3]));
}
/*!
@@ -1412,7 +1433,7 @@ QTransform QMatrix4x4::toTransform() const
*/
/*!
- \fn qrealinner *QMatrix4x4::data()
+ \fn float *QMatrix4x4::data()
Returns a pointer to the raw data of this matrix. This is indended
for use with raw GL functions.
@@ -1421,7 +1442,7 @@ QTransform QMatrix4x4::toTransform() const
*/
/*!
- \fn const qrealinner *QMatrix4x4::data() const
+ \fn const float *QMatrix4x4::data() const
Returns a constant pointer to the raw data of this matrix.
This is indended for use with raw GL functions.
@@ -1430,7 +1451,7 @@ QTransform QMatrix4x4::toTransform() const
*/
/*!
- \fn const qrealinner *QMatrix4x4::constData() const
+ \fn const float *QMatrix4x4::constData() const
Returns a constant pointer to the raw data of this matrix.
This is indended for use with raw GL functions.
@@ -1489,12 +1510,12 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
{
// Orientation is dependent on the upper 3x3 matrix; subtract the
// homogeneous scaling element from the trace of the 4x4 matrix
- qrealinner tr = m[0][0] + m[1][1] + m[2][2];
- qreal cosa = qt_math3d_convert<qreal, qrealinner>(0.5f * (tr - 1.0f));
+ float tr = m[0][0] + m[1][1] + m[2][2];
+ qreal cosa = qreal(0.5f * (tr - 1.0f));
angle = acos(cosa) * 180.0f / M_PI;
// Any axis will work if r is zero (means no rotation)
- if (qFuzzyCompare(angle, (qreal)0.0f)) {
+ if (qFuzzyIsNull(angle)) {
axis.setX(1.0f);
axis.setY(0.0f);
axis.setZ(0.0f);
@@ -1510,11 +1531,11 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
}
// rads == PI
- qrealinner tmp;
+ float tmp;
// r00 is maximum
if ((m[0][0] >= m[2][2]) && (m[0][0] >= m[1][1])) {
- axis.xp = 0.5f * qvtsqrt(m[0][0] - m[1][1] - m[2][2] + 1.0f);
+ axis.xp = 0.5f * qSqrt(m[0][0] - m[1][1] - m[2][2] + 1.0f);
tmp = 0.5f / axis.x();
axis.yp = m[1][0] * tmp;
axis.zp = m[2][0] * tmp;
@@ -1522,7 +1543,7 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
// r11 is maximum
if ((m[1][1] >= m[2][2]) && (m[1][1] >= m[0][0])) {
- axis.yp = 0.5f * qvtsqrt(m[1][1] - m[0][0] - m[2][2] + 1.0f);
+ axis.yp = 0.5f * qSqrt(m[1][1] - m[0][0] - m[2][2] + 1.0f);
tmp = 0.5f / axis.y();
axis.xp = tmp * m[1][0];
axis.zp = tmp * m[2][1];
@@ -1530,7 +1551,7 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
// r22 is maximum
if ((m[2][2] >= m[1][1]) && (m[2][2] >= m[0][0])) {
- axis.zp = 0.5f * qvtsqrt(m[2][2] - m[0][0] - m[1][1] + 1.0f);
+ axis.zp = 0.5f * qSqrt(m[2][2] - m[0][0] - m[1][1] + 1.0f);
tmp = 0.5f / axis.z();
axis.xp = m[2][0]*tmp;
axis.yp = m[2][1]*tmp;
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index 8ef73bf..2b485c1 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -40,14 +70,14 @@ public:
qreal m41, qreal m42, qreal m43, qreal m44);
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
template <int N, int M>
- explicit QMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix);
+ explicit QMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix);
#endif
- QMatrix4x4(const qrealinner *values, int cols, int rows);
+ QMatrix4x4(const float *values, int cols, int rows);
QMatrix4x4(const QTransform& transform);
QMatrix4x4(const QMatrix& matrix);
inline qreal operator()(int row, int column) const;
- inline qrealinner& operator()(int row, int column);
+ inline float& operator()(int row, int column);
inline QVector4D column(int index) const;
inline void setColumn(int index, const QVector4D& value);
@@ -141,12 +171,12 @@ public:
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
template <int N, int M>
- QGenericMatrix<N, M, qreal, qrealinner> toGenericMatrix() const;
+ QGenericMatrix<N, M, qreal, float> toGenericMatrix() const;
#endif
- inline qrealinner *data();
- inline const qrealinner *data() const { return m[0]; }
- inline const qrealinner *constData() const { return m[0]; }
+ inline float *data();
+ inline const float *data() const { return m[0]; }
+ inline const float *constData() const { return m[0]; }
void inferSpecialType();
@@ -155,7 +185,7 @@ public:
#endif
private:
- qrealinner m[4][4]; // Column-major order to match OpenGL.
+ float m[4][4]; // Column-major order to match OpenGL.
int flagBits; // Flag bits from the enum below.
enum {
@@ -189,9 +219,9 @@ inline QMatrix4x4::QMatrix4x4
template <int N, int M>
Q_INLINE_TEMPLATE QMatrix4x4::QMatrix4x4
- (const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+ (const QGenericMatrix<N, M, qreal, float>& matrix)
{
- const qrealinner *values = matrix.constData();
+ const float *values = matrix.constData();
for (int col = 0; col < 4; ++col) {
for (int row = 0; row < 4; ++row) {
if (col < N && row < M)
@@ -206,10 +236,10 @@ Q_INLINE_TEMPLATE QMatrix4x4::QMatrix4x4
}
template <int N, int M>
-QGenericMatrix<N, M, qreal, qrealinner> QMatrix4x4::toGenericMatrix() const
+QGenericMatrix<N, M, qreal, float> QMatrix4x4::toGenericMatrix() const
{
- QGenericMatrix<N, M, qreal, qrealinner> result;
- qrealinner *values = result.data();
+ QGenericMatrix<N, M, qreal, float> result;
+ float *values = result.data();
for (int col = 0; col < N; ++col) {
for (int row = 0; row < M; ++row) {
if (col < 4 && row < 4)
@@ -228,10 +258,10 @@ QGenericMatrix<N, M, qreal, qrealinner> QMatrix4x4::toGenericMatrix() const
inline qreal QMatrix4x4::operator()(int row, int column) const
{
Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4);
- return qt_math3d_convert<qreal, qrealinner>(m[column][row]);
+ return qreal(m[column][row]);
}
-inline qrealinner& QMatrix4x4::operator()(int row, int column)
+inline float& QMatrix4x4::operator()(int row, int column)
{
Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4);
flagBits = General;
@@ -390,23 +420,22 @@ inline QMatrix4x4& QMatrix4x4::operator*=(const QMatrix4x4& other)
inline QMatrix4x4& QMatrix4x4::operator*=(qreal factor)
{
- qrealinner f(factor);
- m[0][0] *= f;
- m[0][1] *= f;
- m[0][2] *= f;
- m[0][3] *= f;
- m[1][0] *= f;
- m[1][1] *= f;
- m[1][2] *= f;
- m[1][3] *= f;
- m[2][0] *= f;
- m[2][1] *= f;
- m[2][2] *= f;
- m[2][3] *= f;
- m[3][0] *= f;
- m[3][1] *= f;
- m[3][2] *= f;
- m[3][3] *= f;
+ m[0][0] *= factor;
+ m[0][1] *= factor;
+ m[0][2] *= factor;
+ m[0][3] *= factor;
+ m[1][0] *= factor;
+ m[1][1] *= factor;
+ m[1][2] *= factor;
+ m[1][3] *= factor;
+ m[2][0] *= factor;
+ m[2][1] *= factor;
+ m[2][2] *= factor;
+ m[2][3] *= factor;
+ m[3][0] *= factor;
+ m[3][1] *= factor;
+ m[3][2] *= factor;
+ m[3][3] *= factor;
flagBits = General;
return *this;
}
@@ -574,7 +603,7 @@ inline QMatrix4x4 operator*(const QMatrix4x4& m1, const QMatrix4x4& m2)
inline QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[0][1] +
vector.zp * matrix.m[0][2] +
@@ -599,7 +628,7 @@ inline QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix)
inline QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[1][0] +
vector.zp * matrix.m[2][0] +
@@ -628,7 +657,7 @@ inline QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector)
inline QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[0][1] +
vector.zp * matrix.m[0][2] +
@@ -650,7 +679,7 @@ inline QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix)
inline QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[1][0] +
vector.zp * matrix.m[2][0] +
@@ -674,8 +703,8 @@ inline QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector)
inline QPoint operator*(const QPoint& point, const QMatrix4x4& matrix)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -695,8 +724,8 @@ inline QPoint operator*(const QPoint& point, const QMatrix4x4& matrix)
inline QPointF operator*(const QPointF& point, const QMatrix4x4& matrix)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -709,18 +738,16 @@ inline QPointF operator*(const QPointF& point, const QMatrix4x4& matrix)
yin * matrix.m[3][1] +
matrix.m[3][3];
if (w == 1.0f) {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x),
- qt_math3d_convert<qreal, qrealinner>(y));
+ return QPointF(qreal(x), qreal(y));
} else {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x / w),
- qt_math3d_convert<qreal, qrealinner>(y / w));
+ return QPointF(qreal(x / w), qreal(y / w));
}
}
inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -740,8 +767,8 @@ inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point)
inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -754,11 +781,9 @@ inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point)
yin * matrix.m[1][3] +
matrix.m[3][3];
if (w == 1.0f) {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x),
- qt_math3d_convert<qreal, qrealinner>(y));
+ return QPointF(qreal(x), qreal(y));
} else {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x / w),
- qt_math3d_convert<qreal, qrealinner>(y / w));
+ return QPointF(qreal(x / w), qreal(y / w));
}
}
@@ -787,46 +812,44 @@ inline QMatrix4x4 operator-(const QMatrix4x4& matrix)
inline QMatrix4x4 operator*(qreal factor, const QMatrix4x4& matrix)
{
QMatrix4x4 m(1);
- qrealinner f(factor);
- m.m[0][0] = matrix.m[0][0] * f;
- m.m[0][1] = matrix.m[0][1] * f;
- m.m[0][2] = matrix.m[0][2] * f;
- m.m[0][3] = matrix.m[0][3] * f;
- m.m[1][0] = matrix.m[1][0] * f;
- m.m[1][1] = matrix.m[1][1] * f;
- m.m[1][2] = matrix.m[1][2] * f;
- m.m[1][3] = matrix.m[1][3] * f;
- m.m[2][0] = matrix.m[2][0] * f;
- m.m[2][1] = matrix.m[2][1] * f;
- m.m[2][2] = matrix.m[2][2] * f;
- m.m[2][3] = matrix.m[2][3] * f;
- m.m[3][0] = matrix.m[3][0] * f;
- m.m[3][1] = matrix.m[3][1] * f;
- m.m[3][2] = matrix.m[3][2] * f;
- m.m[3][3] = matrix.m[3][3] * f;
+ m.m[0][0] = matrix.m[0][0] * factor;
+ m.m[0][1] = matrix.m[0][1] * factor;
+ m.m[0][2] = matrix.m[0][2] * factor;
+ m.m[0][3] = matrix.m[0][3] * factor;
+ m.m[1][0] = matrix.m[1][0] * factor;
+ m.m[1][1] = matrix.m[1][1] * factor;
+ m.m[1][2] = matrix.m[1][2] * factor;
+ m.m[1][3] = matrix.m[1][3] * factor;
+ m.m[2][0] = matrix.m[2][0] * factor;
+ m.m[2][1] = matrix.m[2][1] * factor;
+ m.m[2][2] = matrix.m[2][2] * factor;
+ m.m[2][3] = matrix.m[2][3] * factor;
+ m.m[3][0] = matrix.m[3][0] * factor;
+ m.m[3][1] = matrix.m[3][1] * factor;
+ m.m[3][2] = matrix.m[3][2] * factor;
+ m.m[3][3] = matrix.m[3][3] * factor;
return m;
}
inline QMatrix4x4 operator*(const QMatrix4x4& matrix, qreal factor)
{
QMatrix4x4 m(1);
- qrealinner f(factor);
- m.m[0][0] = matrix.m[0][0] * f;
- m.m[0][1] = matrix.m[0][1] * f;
- m.m[0][2] = matrix.m[0][2] * f;
- m.m[0][3] = matrix.m[0][3] * f;
- m.m[1][0] = matrix.m[1][0] * f;
- m.m[1][1] = matrix.m[1][1] * f;
- m.m[1][2] = matrix.m[1][2] * f;
- m.m[1][3] = matrix.m[1][3] * f;
- m.m[2][0] = matrix.m[2][0] * f;
- m.m[2][1] = matrix.m[2][1] * f;
- m.m[2][2] = matrix.m[2][2] * f;
- m.m[2][3] = matrix.m[2][3] * f;
- m.m[3][0] = matrix.m[3][0] * f;
- m.m[3][1] = matrix.m[3][1] * f;
- m.m[3][2] = matrix.m[3][2] * f;
- m.m[3][3] = matrix.m[3][3] * f;
+ m.m[0][0] = matrix.m[0][0] * factor;
+ m.m[0][1] = matrix.m[0][1] * factor;
+ m.m[0][2] = matrix.m[0][2] * factor;
+ m.m[0][3] = matrix.m[0][3] * factor;
+ m.m[1][0] = matrix.m[1][0] * factor;
+ m.m[1][1] = matrix.m[1][1] * factor;
+ m.m[1][2] = matrix.m[1][2] * factor;
+ m.m[1][3] = matrix.m[1][3] * factor;
+ m.m[2][0] = matrix.m[2][0] * factor;
+ m.m[2][1] = matrix.m[2][1] * factor;
+ m.m[2][2] = matrix.m[2][2] * factor;
+ m.m[2][3] = matrix.m[2][3] * factor;
+ m.m[3][0] = matrix.m[3][0] * factor;
+ m.m[3][1] = matrix.m[3][1] * factor;
+ m.m[3][2] = matrix.m[3][2] * factor;
+ m.m[3][3] = matrix.m[3][3] * factor;
return m;
}
@@ -904,7 +927,7 @@ inline QRectF QMatrix4x4::mapRect(const QRectF& rect) const
return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax));
}
-inline qrealinner *QMatrix4x4::data()
+inline float *QMatrix4x4::data()
{
// We have to assume that the caller will modify the matrix elements,
// so we flip it over to "General" mode.
@@ -917,17 +940,17 @@ Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QMatrix4x4 &m);
#endif
template <int N, int M>
-QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
{
return QMatrix4x4(matrix.constData(), N, M);
}
template <int N, int M>
-QGenericMatrix<N, M, qreal, qrealinner> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
+QGenericMatrix<N, M, qreal, float> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
{
- QGenericMatrix<N, M, qreal, qrealinner> result;
- const qrealinner *m = matrix.constData();
- qrealinner *values = result.data();
+ QGenericMatrix<N, M, qreal, float> result;
+ const float *m = matrix.constData();
+ float *values = result.data();
for (int col = 0; col < N; ++col) {
for (int row = 0; row < M; ++row) {
if (col < 4 && row < 4)
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index 730844f..96659ea 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -5,13 +5,43 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#include "qquaternion.h"
-#include "qmath3dutil_p.h"
#include <QtCore/qmath.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
@@ -44,13 +74,6 @@ QT_BEGIN_NAMESPACE
and \a scalar.
*/
-/*!
- \fn QQuaternion::QQuaternion(int scalar, int xpos, int ypos, int zpos)
-
- Constructs a quaternion with the vector (\a xpos, \a ypos, \a zpos)
- and \a scalar.
-*/
-
#ifndef QT_NO_VECTOR3D
/*!
@@ -193,8 +216,7 @@ QT_BEGIN_NAMESPACE
*/
qreal QQuaternion::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return qSqrt(xp * xp + yp * yp + zp * zp + wp * wp);
}
/*!
@@ -204,45 +226,50 @@ qreal QQuaternion::length() const
*/
qreal QQuaternion::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return xp * xp + yp * yp + zp * zp + wp * wp;
}
/*!
- Returns the normalized unit form of this quaternion. If this quaternion
- is not null, the returned quaternion is guaranteed to be 1.0 in length.
+ Returns the normalized unit form of this quaternion.
+
If this quaternion is null, then a null quaternion is returned.
+ If the length of the quaternion is very close to 1, then the quaternion
+ will be returned as-is. Otherwise the normalized form of the
+ quaternion of length 1 will be returned.
\sa length(), normalize()
*/
QQuaternion QQuaternion::normalized() const
{
- qreal len = length();
- if (!qIsNull(len))
- return *this / len;
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f))
+ return *this;
+ else if (!qFuzzyIsNull(len))
+ return *this / qSqrt(len);
else
return QQuaternion(0.0f, 0.0f, 0.0f, 0.0f);
}
/*!
Normalizes the currect quaternion in place. Nothing happens if this
- is a null quaternion.
+ is a null quaternion or the length of the quaternion is very close to 1.
\sa length(), normalized()
*/
void QQuaternion::normalize()
{
- qreal len = length();
- if (qIsNull(len))
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len))
return;
+ len = qSqrt(len);
+
xp /= len;
yp /= len;
zp /= len;
wp /= len;
}
-
/*!
\fn QQuaternion QQuaternion::conjugate() const
@@ -312,6 +339,10 @@ QVector3D QQuaternion::rotateVector(const QVector3D& vector) const
\sa operator*=()
*/
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
#ifndef QT_NO_VECTOR3D
/*!
@@ -324,9 +355,10 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, qreal angle)
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56
// We normalize the result just in case the values are close
// to zero, as suggested in the above FAQ.
- qrealinner s, c;
+ qreal a = (angle / 2.0f) * M_PI / 180.0f;
+ qreal s = qSin(a);
+ qreal c = qCos(a);
QVector3D ax = axis.normalized();
- qt_math3d_sincos(angle / 2.0f, &s, &c);
return QQuaternion(c, ax.xp * s, ax.yp * s, ax.zp * s, 1).normalized();
}
@@ -339,17 +371,18 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, qreal angle)
QQuaternion QQuaternion::fromAxisAndAngle
(qreal x, qreal y, qreal z, qreal angle)
{
- qrealinner xp = x;
- qrealinner yp = y;
- qrealinner zp = z;
- qrealinner s, c;
- qreal length = qvtsqrt(xp * xp + yp * yp + zp * zp);
+ float xp = x;
+ float yp = y;
+ float zp = z;
+ qreal length = qSqrt(xp * xp + yp * yp + zp * zp);
if (!qIsNull(length)) {
xp /= length;
yp /= length;
zp /= length;
}
- qt_math3d_sincos(angle / 2.0f, &s, &c);
+ qreal a = (angle / 2.0f) * M_PI / 180.0f;
+ qreal s = qSin(a);
+ qreal c = qCos(a);
return QQuaternion(c, xp * s, yp * s, zp * s, 1).normalized();
}
@@ -457,8 +490,10 @@ QQuaternion QQuaternion::fromAxisAndAngle
If \a t is less than or equal to 0, then \a q1 will be returned.
If \a t is greater than or equal to 1, then \a q2 will be returned.
+
+ \sa nlerp()
*/
-QQuaternion QQuaternion::interpolate
+QQuaternion QQuaternion::slerp
(const QQuaternion& q1, const QQuaternion& q2, qreal t)
{
// Handle the easy cases first.
@@ -470,8 +505,7 @@ QQuaternion QQuaternion::interpolate
// Determine the angle between the two quaternions.
QQuaternion q2b;
qreal dot;
- dot = qvtdot64(qvtmul64(q1.xp, q2.xp) + qvtmul64(q1.yp, q2.yp) +
- qvtmul64(q1.zp, q2.zp) + qvtmul64(q1.wp, q2.wp));
+ dot = q1.xp * q2.xp + q1.yp * q2.yp + q1.zp * q2.zp + q1.wp * q2.wp;
if (dot >= 0.0f) {
q2b = q2;
} else {
@@ -496,6 +530,43 @@ QQuaternion QQuaternion::interpolate
return q1 * factor1 + q2b * factor2;
}
+/*!
+ Interpolates along the shortest linear path between the rotational
+ positions \a q1 and \a q2. The value \a t should be between 0 and 1,
+ indicating the distance to travel between \a q1 and \a q2.
+ The result will be normalized().
+
+ If \a t is less than or equal to 0, then \a q1 will be returned.
+ If \a t is greater than or equal to 1, then \a q2 will be returned.
+
+ The nlerp() function is typically faster than slerp() and will
+ give approximate results to spherical interpolation that are
+ good enough for some applications.
+
+ \sa slerp()
+*/
+QQuaternion QQuaternion::nlerp
+ (const QQuaternion& q1, const QQuaternion& q2, qreal t)
+{
+ // Handle the easy cases first.
+ if (t <= 0.0f)
+ return q1;
+ else if (t >= 1.0f)
+ return q2;
+
+ // Determine the angle between the two quaternions.
+ QQuaternion q2b;
+ qreal dot;
+ dot = q1.xp * q2.xp + q1.yp * q2.yp + q1.zp * q2.zp + q1.wp * q2.wp;
+ if (dot >= 0.0f)
+ q2b = q2;
+ else
+ q2b = -q2;
+
+ // Perform the linear interpolation.
+ return (q1 * (1.0f - t) + q2b * t).normalized();
+}
+
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QQuaternion &q)
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index cc71b7d..c05c641 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -30,7 +60,6 @@ class Q_GUI_EXPORT QQuaternion
public:
QQuaternion();
QQuaternion(qreal scalar, qreal xpos, qreal ypos, qreal zpos);
- QQuaternion(int scalar, int xpos, int ypos, int zpos);
#ifndef QT_NO_VECTOR3D
QQuaternion(qreal scalar, const QVector3D& vector);
#endif
@@ -95,15 +124,17 @@ public:
static QQuaternion fromAxisAndAngle
(qreal x, qreal y, qreal z, qreal angle);
- static QQuaternion interpolate
+ static QQuaternion slerp
+ (const QQuaternion& q1, const QQuaternion& q2, qreal t);
+ static QQuaternion nlerp
(const QQuaternion& q1, const QQuaternion& q2, qreal t);
private:
- qrealinner wp, xp, yp, zp;
+ float wp, xp, yp, zp;
friend class QMatrix4x4;
- QQuaternion(qrealinner scalar, qrealinner xpos, qrealinner ypos, qrealinner zpos, int dummy);
+ QQuaternion(float scalar, float xpos, float ypos, float zpos, int dummy);
};
inline QQuaternion::QQuaternion() : wp(1.0f), xp(0.0f), yp(0.0f), zp(0.0f) {}
@@ -111,9 +142,7 @@ inline QQuaternion::QQuaternion() : wp(1.0f), xp(0.0f), yp(0.0f), zp(0.0f) {}
inline QQuaternion::QQuaternion(qreal scalar, qreal xpos, qreal ypos, qreal zpos) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
-inline QQuaternion::QQuaternion(qrealinner scalar, qrealinner xpos, qrealinner ypos, qrealinner zpos, int) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
-
-inline QQuaternion::QQuaternion(int scalar, int xpos, int ypos, int zpos) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
+inline QQuaternion::QQuaternion(float scalar, float xpos, float ypos, float zpos, int) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
inline bool QQuaternion::isNull() const
{
@@ -125,10 +154,10 @@ inline bool QQuaternion::isIdentity() const
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && wp == 1.0f;
}
-inline qreal QQuaternion::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QQuaternion::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
-inline qreal QQuaternion::z() const { return qt_math3d_convert<qreal, qrealinner>(zp); }
-inline qreal QQuaternion::scalar() const { return qt_math3d_convert<qreal, qrealinner>(wp); }
+inline qreal QQuaternion::x() const { return qreal(xp); }
+inline qreal QQuaternion::y() const { return qreal(yp); }
+inline qreal QQuaternion::z() const { return qreal(zp); }
+inline qreal QQuaternion::scalar() const { return qreal(wp); }
inline void QQuaternion::setX(qreal x) { xp = x; }
inline void QQuaternion::setY(qreal y) { yp = y; }
@@ -160,11 +189,10 @@ inline QQuaternion &QQuaternion::operator-=(const QQuaternion &quaternion)
inline QQuaternion &QQuaternion::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
- zp *= f;
- wp *= f;
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
+ wp *= factor;
return *this;
}
@@ -172,19 +200,19 @@ inline const QQuaternion operator*(const QQuaternion &q1, const QQuaternion& q2)
{
// Algorithm from:
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q53
- qrealinner x = q1.wp * q2.xp +
+ float x = q1.wp * q2.xp +
q1.xp * q2.wp +
q1.yp * q2.zp -
q1.zp * q2.yp;
- qrealinner y = q1.wp * q2.yp +
+ float y = q1.wp * q2.yp +
q1.yp * q2.wp +
q1.zp * q2.xp -
q1.xp * q2.zp;
- qrealinner z = q1.wp * q2.zp +
+ float z = q1.wp * q2.zp +
q1.zp * q2.wp +
q1.xp * q2.yp -
q1.yp * q2.xp;
- qrealinner w = q1.wp * q2.wp -
+ float w = q1.wp * q2.wp -
q1.xp * q2.xp -
q1.yp * q2.yp -
q1.zp * q2.zp;
@@ -199,11 +227,10 @@ inline QQuaternion &QQuaternion::operator*=(const QQuaternion &quaternion)
inline QQuaternion &QQuaternion::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
- zp /= d;
- wp /= d;
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
+ wp /= divisor;
return *this;
}
@@ -229,14 +256,12 @@ inline const QQuaternion operator-(const QQuaternion &q1, const QQuaternion &q2)
inline const QQuaternion operator*(qreal factor, const QQuaternion &quaternion)
{
- qrealinner f(factor);
- return QQuaternion(quaternion.wp * f, quaternion.xp * f, quaternion.yp * f, quaternion.zp * f, 1);
+ return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor, 1);
}
inline const QQuaternion operator*(const QQuaternion &quaternion, qreal factor)
{
- qrealinner f(factor);
- return QQuaternion(quaternion.wp * f, quaternion.xp * f, quaternion.yp * f, quaternion.zp * f, 1);
+ return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor, 1);
}
inline const QQuaternion operator-(const QQuaternion &quaternion)
@@ -246,8 +271,7 @@ inline const QQuaternion operator-(const QQuaternion &quaternion)
inline const QQuaternion operator/(const QQuaternion &quaternion, qreal divisor)
{
- qrealinner d(divisor);
- return QQuaternion(quaternion.wp / d, quaternion.xp / d, quaternion.yp / d, quaternion.zp / d, 1);
+ return QQuaternion(quaternion.wp / divisor, quaternion.xp / divisor, quaternion.yp / divisor, quaternion.zp / divisor, 1);
}
inline bool qFuzzyCompare(const QQuaternion& q1, const QQuaternion& q2)
diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp
index 13d6cc9..c3aaa42 100644
--- a/src/gui/math3d/qvector2d.cpp
+++ b/src/gui/math3d/qvector2d.cpp
@@ -5,14 +5,45 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#include "qvector2d.h"
#include "qvector3d.h"
#include "qvector4d.h"
-#include "qmath3dutil_p.h"
+#include <QtCore/qdebug.h>
+#include <QtCore/qmath.h>
QT_BEGIN_NAMESPACE
@@ -44,12 +75,6 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QVector2D::QVector2D(int xpos, int ypos)
-
- Constructs a vector with coordinates (\a xpos, \a ypos).
-*/
-
-/*!
\fn QVector2D::QVector2D(const QPoint& point)
Constructs a vector with x and y coordinates from a 2D \a point.
@@ -139,7 +164,7 @@ QVector2D::QVector2D(const QVector4D& vector)
*/
qreal QVector2D::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp));
+ return qSqrt(xp * xp + yp * yp);
}
/*!
@@ -150,37 +175,43 @@ qreal QVector2D::length() const
*/
qreal QVector2D::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp));
+ return xp * xp + yp * yp;
}
/*!
- Returns the normalized unit vector form of this vector. If this vector
- is not null, the returned vector is guaranteed to be 1.0 in length.
- If this vector is null, then a null vector is returned.
+ Returns the normalized unit vector form of this vector.
+
+ If this vector is null, then a null vector is returned. If the length
+ of the vector is very close to 1, then the vector will be returned as-is.
+ Otherwise the normalized form of the vector of length 1 will be returned.
\sa length(), normalize()
*/
QVector2D QVector2D::normalized() const
{
- qreal len = length();
- if (!qIsNull(len))
- return *this / len;
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f))
+ return *this;
+ else if (!qFuzzyIsNull(len))
+ return *this / qSqrt(len);
else
return QVector2D();
}
/*!
Normalizes the currect vector in place. Nothing happens if this
- vector is a null vector.
+ vector is a null vector or the length of the vector is very close to 1.
\sa length(), normalized()
*/
void QVector2D::normalize()
{
- qreal len = length();
- if (qIsNull(len))
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len))
return;
+ len = qSqrt(len);
+
xp /= len;
yp /= len;
}
@@ -233,7 +264,7 @@ void QVector2D::normalize()
*/
qreal QVector2D::dotProduct(const QVector2D& v1, const QVector2D& v2)
{
- return qvtdot64(qvtmul64(v1.xp, v2.xp) + qvtmul64(v1.yp, v2.yp));
+ return v1.xp * v2.xp + v1.yp * v2.yp;
}
/*!
diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h
index 55452b0..b027df4 100644
--- a/src/gui/math3d/qvector2d.h
+++ b/src/gui/math3d/qvector2d.h
@@ -5,14 +5,43 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QVECTOR2D_H
#define QVECTOR2D_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
@@ -32,7 +61,6 @@ class Q_GUI_EXPORT QVector2D
public:
QVector2D();
QVector2D(qreal xpos, qreal ypos);
- QVector2D(int xpos, int ypos);
explicit QVector2D(const QPoint& point);
explicit QVector2D(const QPointF& point);
#ifndef QT_NO_VECTOR3D
@@ -87,23 +115,20 @@ public:
QPointF toPointF() const;
private:
- qrealinner xp, yp;
+ float xp, yp;
- QVector2D(qrealinner xpos, qrealinner ypos, int dummy);
+ QVector2D(float xpos, float ypos, int dummy);
friend class QVector3D;
friend class QVector4D;
- friend class QVertexArray;
};
inline QVector2D::QVector2D() : xp(0.0f), yp(0.0f) {}
-inline QVector2D::QVector2D(qrealinner xpos, qrealinner ypos, int) : xp(xpos), yp(ypos) {}
+inline QVector2D::QVector2D(float xpos, float ypos, int) : xp(xpos), yp(ypos) {}
inline QVector2D::QVector2D(qreal xpos, qreal ypos) : xp(xpos), yp(ypos) {}
-inline QVector2D::QVector2D(int xpos, int ypos) : xp(xpos), yp(ypos) {}
-
inline QVector2D::QVector2D(const QPoint& point) : xp(point.x()), yp(point.y()) {}
inline QVector2D::QVector2D(const QPointF& point) : xp(point.x()), yp(point.y()) {}
@@ -113,8 +138,8 @@ inline bool QVector2D::isNull() const
return qIsNull(xp) && qIsNull(yp);
}
-inline qreal QVector2D::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QVector2D::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
+inline qreal QVector2D::x() const { return qreal(xp); }
+inline qreal QVector2D::y() const { return qreal(yp); }
inline void QVector2D::setX(qreal x) { xp = x; }
inline void QVector2D::setY(qreal y) { yp = y; }
@@ -135,9 +160,8 @@ inline QVector2D &QVector2D::operator-=(const QVector2D &vector)
inline QVector2D &QVector2D::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
+ xp *= factor;
+ yp *= factor;
return *this;
}
@@ -150,9 +174,8 @@ inline QVector2D &QVector2D::operator*=(const QVector2D &vector)
inline QVector2D &QVector2D::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
+ xp /= divisor;
+ yp /= divisor;
return *this;
}
@@ -178,14 +201,12 @@ inline const QVector2D operator-(const QVector2D &v1, const QVector2D &v2)
inline const QVector2D operator*(qreal factor, const QVector2D &vector)
{
- qrealinner f(factor);
- return QVector2D(vector.xp * f, vector.yp * f, 1);
+ return QVector2D(vector.xp * factor, vector.yp * factor, 1);
}
inline const QVector2D operator*(const QVector2D &vector, qreal factor)
{
- qrealinner f(factor);
- return QVector2D(vector.xp * f, vector.yp * f, 1);
+ return QVector2D(vector.xp * factor, vector.yp * factor, 1);
}
inline const QVector2D operator*(const QVector2D &v1, const QVector2D &v2)
@@ -200,8 +221,7 @@ inline const QVector2D operator-(const QVector2D &vector)
inline const QVector2D operator/(const QVector2D &vector, qreal divisor)
{
- qrealinner d(divisor);
- return QVector2D(vector.xp / d, vector.yp / d, 1);
+ return QVector2D(vector.xp / divisor, vector.yp / divisor, 1);
}
inline bool qFuzzyCompare(const QVector2D& v1, const QVector2D& v2)
@@ -216,8 +236,7 @@ inline QPoint QVector2D::toPoint() const
inline QPointF QVector2D::toPointF() const
{
- return QPointF(qt_math3d_convert<qreal, qrealinner>(xp),
- qt_math3d_convert<qreal, qrealinner>(yp));
+ return QPointF(qreal(xp), qreal(yp));
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp
index f0b3aeb..c83cd60 100644
--- a/src/gui/math3d/qvector3d.cpp
+++ b/src/gui/math3d/qvector3d.cpp
@@ -5,15 +5,45 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#include "qvector3d.h"
#include "qvector2d.h"
#include "qvector4d.h"
-#include "qmath3dutil_p.h"
#include <QtCore/qmath.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
@@ -49,12 +79,6 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QVector3D::QVector3D(int xpos, int ypos, int zpos)
-
- Constructs a vector with coordinates (\a xpos, \a ypos, \a zpos).
-*/
-
-/*!
\fn QVector3D::QVector3D(const QPoint& point)
Constructs a vector with x and y coordinates from a 2D \a point, and a
@@ -171,33 +195,39 @@ QVector3D::QVector3D(const QVector4D& vector)
*/
/*!
- Returns the normalized unit vector form of this vector. If this vector
- is not null, the returned vector is guaranteed to be 1.0 in length.
- If this vector is null, then a null vector is returned.
+ Returns the normalized unit vector form of this vector.
+
+ If this vector is null, then a null vector is returned. If the length
+ of the vector is very close to 1, then the vector will be returned as-is.
+ Otherwise the normalized form of the vector of length 1 will be returned.
\sa length(), normalize()
*/
QVector3D QVector3D::normalized() const
{
- qreal len = length();
- if (!qIsNull(len))
- return *this / len;
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f))
+ return *this;
+ else if (!qFuzzyIsNull(len))
+ return *this / qSqrt(len);
else
return QVector3D();
}
/*!
Normalizes the currect vector in place. Nothing happens if this
- vector is a null vector.
+ vector is a null vector or the length of the vector is very close to 1.
\sa length(), normalized()
*/
void QVector3D::normalize()
{
- qreal len = length();
- if (qIsNull(len))
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len))
return;
+ len = qSqrt(len);
+
xp /= len;
yp /= len;
zp /= len;
@@ -257,7 +287,7 @@ void QVector3D::normalize()
*/
qreal QVector3D::dotProduct(const QVector3D& v1, const QVector3D& v2)
{
- return qvtdot64(qvtmul64(v1.xp, v2.xp) + qvtmul64(v1.yp, v2.yp) + qvtmul64(v1.zp, v2.zp));
+ return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp;
}
/*!
@@ -505,7 +535,7 @@ QVector4D QVector3D::toVector4D() const
*/
qreal QVector3D::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp) + qvtmul64(zp, zp));
+ return qSqrt(xp * xp + yp * yp + zp * zp);
}
/*!
@@ -516,7 +546,7 @@ qreal QVector3D::length() const
*/
qreal QVector3D::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp) + qvtmul64(zp, zp));
+ return xp * xp + yp * yp + zp * zp;
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h
index dd1d014..02873f2 100644
--- a/src/gui/math3d/qvector3d.h
+++ b/src/gui/math3d/qvector3d.h
@@ -5,14 +5,43 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QVECTOR3D_H
#define QVECTOR3D_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
@@ -34,7 +63,6 @@ class Q_GUI_EXPORT QVector3D
public:
QVector3D();
QVector3D(qreal xpos, qreal ypos, qreal zpos);
- QVector3D(int xpos, int ypos, int zpos);
explicit QVector3D(const QPoint& point);
explicit QVector3D(const QPointF& point);
#ifndef QT_NO_VECTOR2D
@@ -100,16 +128,14 @@ public:
QPointF toPointF() const;
private:
- qrealinner xp, yp, zp;
+ float xp, yp, zp;
- QVector3D(qrealinner xpos, qrealinner ypos, qrealinner zpos, int dummy);
+ QVector3D(float xpos, float ypos, float zpos, int dummy);
friend class QVector2D;
friend class QVector4D;
friend class QQuaternion;
friend class QMatrix4x4;
- friend class QVertexArray;
- friend class QGLPainter;
#ifndef QT_NO_MATRIX4X4
friend QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix);
friend QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector);
@@ -120,9 +146,7 @@ inline QVector3D::QVector3D() : xp(0.0f), yp(0.0f), zp(0.0f) {}
inline QVector3D::QVector3D(qreal xpos, qreal ypos, qreal zpos) : xp(xpos), yp(ypos), zp(zpos) {}
-inline QVector3D::QVector3D(qrealinner xpos, qrealinner ypos, qrealinner zpos, int) : xp(xpos), yp(ypos), zp(zpos) {}
-
-inline QVector3D::QVector3D(int xpos, int ypos, int zpos) : xp(xpos), yp(ypos), zp(zpos) {}
+inline QVector3D::QVector3D(float xpos, float ypos, float zpos, int) : xp(xpos), yp(ypos), zp(zpos) {}
inline QVector3D::QVector3D(const QPoint& point) : xp(point.x()), yp(point.y()), zp(0.0f) {}
@@ -133,9 +157,9 @@ inline bool QVector3D::isNull() const
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp);
}
-inline qreal QVector3D::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QVector3D::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
-inline qreal QVector3D::z() const { return qt_math3d_convert<qreal, qrealinner>(zp); }
+inline qreal QVector3D::x() const { return qreal(xp); }
+inline qreal QVector3D::y() const { return qreal(yp); }
+inline qreal QVector3D::z() const { return qreal(zp); }
inline void QVector3D::setX(qreal x) { xp = x; }
inline void QVector3D::setY(qreal y) { yp = y; }
@@ -159,10 +183,9 @@ inline QVector3D &QVector3D::operator-=(const QVector3D &vector)
inline QVector3D &QVector3D::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
- zp *= f;
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
return *this;
}
@@ -176,10 +199,9 @@ inline QVector3D &QVector3D::operator*=(const QVector3D& vector)
inline QVector3D &QVector3D::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
- zp /= d;
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
return *this;
}
@@ -205,14 +227,12 @@ inline const QVector3D operator-(const QVector3D &v1, const QVector3D &v2)
inline const QVector3D operator*(qreal factor, const QVector3D &vector)
{
- qrealinner f(factor);
- return QVector3D(vector.xp * f, vector.yp * f, vector.zp * f, 1);
+ return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor, 1);
}
inline const QVector3D operator*(const QVector3D &vector, qreal factor)
{
- qrealinner f(factor);
- return QVector3D(vector.xp * f, vector.yp * f, vector.zp * f, 1);
+ return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor, 1);
}
inline const QVector3D operator*(const QVector3D &v1, const QVector3D& v2)
@@ -227,8 +247,7 @@ inline const QVector3D operator-(const QVector3D &vector)
inline const QVector3D operator/(const QVector3D &vector, qreal divisor)
{
- qrealinner d(divisor);
- return QVector3D(vector.xp / d, vector.yp / d, vector.zp / d, 1);
+ return QVector3D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor, 1);
}
inline bool qFuzzyCompare(const QVector3D& v1, const QVector3D& v2)
@@ -245,8 +264,7 @@ inline QPoint QVector3D::toPoint() const
inline QPointF QVector3D::toPointF() const
{
- return QPointF(qt_math3d_convert<qreal, qrealinner>(xp),
- qt_math3d_convert<qreal, qrealinner>(yp));
+ return QPointF(qreal(xp), qreal(yp));
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp
index 1239df0..010fa53 100644
--- a/src/gui/math3d/qvector4d.cpp
+++ b/src/gui/math3d/qvector4d.cpp
@@ -5,14 +5,45 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#include "qvector4d.h"
#include "qvector3d.h"
#include "qvector2d.h"
-#include "qmath3dutil_p.h"
+#include <QtCore/qdebug.h>
+#include <QtCore/qmath.h>
QT_BEGIN_NAMESPACE
@@ -46,12 +77,6 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QVector4D::QVector4D(int xpos, int ypos, int zpos, int wpos)
-
- Constructs a vector with coordinates (\a xpos, \a ypos, \a zpos, \a wpos).
-*/
-
-/*!
\fn QVector4D::QVector4D(const QPoint& point)
Constructs a vector with x and y coordinates from a 2D \a point, and
@@ -207,8 +232,7 @@ QVector4D::QVector4D(const QVector3D& vector, qreal wpos)
*/
qreal QVector4D::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return qSqrt(xp * xp + yp * yp + zp * zp + wp * wp);
}
/*!
@@ -219,45 +243,49 @@ qreal QVector4D::length() const
*/
qreal QVector4D::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return xp * xp + yp * yp + zp * zp + wp * wp;
}
/*!
- Returns the normalized unit vector form of this vector. If this vector
- is not null, the returned vector is guaranteed to be 1.0 in length.
- If this vector is null, then a null vector is returned.
+ Returns the normalized unit vector form of this vector.
+
+ If this vector is null, then a null vector is returned. If the length
+ of the vector is very close to 1, then the vector will be returned as-is.
+ Otherwise the normalized form of the vector of length 1 will be returned.
\sa length(), normalize()
*/
QVector4D QVector4D::normalized() const
{
- qreal len = length();
- if (!qIsNull(len))
- return *this / len;
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f))
+ return *this;
+ else if (!qFuzzyIsNull(len))
+ return *this / qSqrt(len);
else
return QVector4D();
}
/*!
Normalizes the currect vector in place. Nothing happens if this
- vector is a null vector.
+ vector is a null vector or the length of the vector is very close to 1.
\sa length(), normalized()
*/
void QVector4D::normalize()
{
- qreal len = length();
- if (qIsNull(len))
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len))
return;
+ len = qSqrt(len);
+
xp /= len;
yp /= len;
zp /= len;
wp /= len;
}
-
/*!
\fn QVector4D &QVector4D::operator+=(const QVector4D &vector)
@@ -306,8 +334,7 @@ void QVector4D::normalize()
*/
qreal QVector4D::dotProduct(const QVector4D& v1, const QVector4D& v2)
{
- return qvtdot64(qvtmul64(v1.xp, v2.xp) + qvtmul64(v1.yp, v2.yp) +
- qvtmul64(v1.zp, v2.zp) + qvtmul64(v1.wp, v2.wp));
+ return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp + v1.wp * v2.wp;
}
/*!
diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h
index 078c328..8e673f3 100644
--- a/src/gui/math3d/qvector4d.h
+++ b/src/gui/math3d/qvector4d.h
@@ -5,14 +5,43 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QVECTOR4D_H
#define QVECTOR4D_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
@@ -34,7 +63,6 @@ class Q_GUI_EXPORT QVector4D
public:
QVector4D();
QVector4D(qreal xpos, qreal ypos, qreal zpos, qreal wpos);
- QVector4D(int xpos, int ypos, int zpos, int wpos);
explicit QVector4D(const QPoint& point);
explicit QVector4D(const QPointF& point);
#ifndef QT_NO_VECTOR2D
@@ -97,15 +125,14 @@ public:
QPointF toPointF() const;
private:
- qrealinner xp, yp, zp, wp;
+ float xp, yp, zp, wp;
- QVector4D(qrealinner xpos, qrealinner ypos, qrealinner zpos, qrealinner wpos, int dummy);
+ QVector4D(float xpos, float ypos, float zpos, float wpos, int dummy);
friend class QVector2D;
friend class QVector3D;
friend class QQuaternion;
friend class QMatrix4x4;
- friend class QVertexArray;
#ifndef QT_NO_MATRIX4X4
friend QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix);
friend QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector);
@@ -116,9 +143,7 @@ inline QVector4D::QVector4D() : xp(0.0f), yp(0.0f), zp(0.0f), wp(0.0f) {}
inline QVector4D::QVector4D(qreal xpos, qreal ypos, qreal zpos, qreal wpos) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
-inline QVector4D::QVector4D(qrealinner xpos, qrealinner ypos, qrealinner zpos, qrealinner wpos, int) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
-
-inline QVector4D::QVector4D(int xpos, int ypos, int zpos, int wpos) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
+inline QVector4D::QVector4D(float xpos, float ypos, float zpos, float wpos, int) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
inline QVector4D::QVector4D(const QPoint& point) : xp(point.x()), yp(point.y()), zp(0.0f), wp(0.0f) {}
@@ -129,10 +154,10 @@ inline bool QVector4D::isNull() const
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && qIsNull(wp);
}
-inline qreal QVector4D::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QVector4D::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
-inline qreal QVector4D::z() const { return qt_math3d_convert<qreal, qrealinner>(zp); }
-inline qreal QVector4D::w() const { return qt_math3d_convert<qreal, qrealinner>(wp); }
+inline qreal QVector4D::x() const { return qreal(xp); }
+inline qreal QVector4D::y() const { return qreal(yp); }
+inline qreal QVector4D::z() const { return qreal(zp); }
+inline qreal QVector4D::w() const { return qreal(wp); }
inline void QVector4D::setX(qreal x) { xp = x; }
inline void QVector4D::setY(qreal y) { yp = y; }
@@ -159,11 +184,10 @@ inline QVector4D &QVector4D::operator-=(const QVector4D &vector)
inline QVector4D &QVector4D::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
- zp *= f;
- wp *= f;
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
+ wp *= factor;
return *this;
}
@@ -178,11 +202,10 @@ inline QVector4D &QVector4D::operator*=(const QVector4D &vector)
inline QVector4D &QVector4D::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
- zp /= d;
- wp /= d;
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
+ wp /= divisor;
return *this;
}
@@ -208,14 +231,12 @@ inline const QVector4D operator-(const QVector4D &v1, const QVector4D &v2)
inline const QVector4D operator*(qreal factor, const QVector4D &vector)
{
- qrealinner f(factor);
- return QVector4D(vector.xp * f, vector.yp * f, vector.zp * f, vector.wp * f, 1);
+ return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor, 1);
}
inline const QVector4D operator*(const QVector4D &vector, qreal factor)
{
- qrealinner f(factor);
- return QVector4D(vector.xp * f, vector.yp * f, vector.zp * f, vector.wp * f, 1);
+ return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor, 1);
}
inline const QVector4D operator*(const QVector4D &v1, const QVector4D& v2)
@@ -230,8 +251,7 @@ inline const QVector4D operator-(const QVector4D &vector)
inline const QVector4D operator/(const QVector4D &vector, qreal divisor)
{
- qrealinner d(divisor);
- return QVector4D(vector.xp / d, vector.yp / d, vector.zp / d, vector.wp / d, 1);
+ return QVector4D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor, vector.wp / divisor, 1);
}
inline bool qFuzzyCompare(const QVector4D& v1, const QVector4D& v2)
@@ -249,8 +269,7 @@ inline QPoint QVector4D::toPoint() const
inline QPointF QVector4D::toPointF() const
{
- return QPointF(qt_math3d_convert<qreal, qrealinner>(xp),
- qt_math3d_convert<qreal, qrealinner>(yp));
+ return QPointF(qreal(xp), qreal(yp));
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp
index 8317dd8..7ed521e 100644
--- a/src/gui/painting/qbezier.cpp
+++ b/src/gui/painting/qbezier.cpp
@@ -127,13 +127,13 @@ static inline void flattenBezierWithoutInflections(QBezier &bez,
qreal dy = bez.y2 - bez.y1;
qreal normalized = qSqrt(dx * dx + dy * dy);
- if (qFuzzyCompare(normalized + 1, 1))
+ if (qFuzzyIsNull(normalized))
break;
qreal d = qAbs(dx * (bez.y3 - bez.y2) - dy * (bez.x3 - bez.x2));
qreal t = qSqrt(4. / 3. * normalized * flatness / d);
- if (t > 1 || qFuzzyCompare(t, (qreal)1.))
+ if (t > 1 || qFuzzyIsNull(t - (qreal)1.))
break;
bez.parameterSplitLeft(t, &left);
p->append(bez.pt1());
@@ -144,19 +144,19 @@ static inline void flattenBezierWithoutInflections(QBezier &bez,
static inline int quadraticRoots(qreal a, qreal b, qreal c,
qreal *x1, qreal *x2)
{
- if (qFuzzyCompare(a + 1, 1)) {
- if (qFuzzyCompare(b + 1, 1))
+ if (qFuzzyIsNull(a)) {
+ if (qFuzzyIsNull(b))
return 0;
*x1 = *x2 = (-c / b);
return 1;
} else {
const qreal det = b * b - 4 * a * c;
- if (qFuzzyCompare(det + 1, 1)) {
+ if (qFuzzyIsNull(det)) {
*x1 = *x2 = -b / (2 * a);
return 1;
}
if (det > 0) {
- if (qFuzzyCompare(b + 1, 1)) {
+ if (qFuzzyIsNull(b)) {
*x2 = qSqrt(-c / a);
*x1 = -(*x2);
return 2;
@@ -187,7 +187,7 @@ static inline bool findInflections(qreal a, qreal b, qreal c,
*t1 = r2;
*t2 = r1;
}
- if (!qFuzzyCompare(a + 1, 1))
+ if (!qFuzzyIsNull(a))
*tCups = 0.5 * (-b / a);
else
*tCups = 2;
@@ -243,7 +243,7 @@ void QBezier::addToPolygonMixed(QPolygonF *polygon) const
qreal b = 6 * (ay * cx - ax * cy);
qreal c = 2 * (by * cx - bx * cy);
- if ((qFuzzyCompare(a + 1, 1) && qFuzzyCompare(b + 1, 1)) ||
+ if ((qFuzzyIsNull(a) && qFuzzyIsNull(b)) ||
(b * b - 4 * a *c) < 0) {
QBezier bez(*this);
flattenBezierWithoutInflections(bez, polygon);
@@ -447,7 +447,7 @@ static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qr
qreal r = 1.0 + prev_normal.x() * next_normal.x()
+ prev_normal.y() * next_normal.y();
- if (qFuzzyCompare(r + 1, 1)) {
+ if (qFuzzyIsNull(r)) {
points_shifted[i] = points[i] + offset * prev_normal;
} else {
qreal k = offset / r;
@@ -477,12 +477,12 @@ static bool addCircle(const QBezier *b, qreal offset, QBezier *o)
normals[0] = QPointF(b->y2 - b->y1, b->x1 - b->x2);
qreal dist = qSqrt(normals[0].x()*normals[0].x() + normals[0].y()*normals[0].y());
- if (qFuzzyCompare(dist + 1, 1))
+ if (qFuzzyIsNull(dist))
return false;
normals[0] /= dist;
normals[2] = QPointF(b->y4 - b->y3, b->x3 - b->x4);
dist = qSqrt(normals[2].x()*normals[2].x() + normals[2].y()*normals[2].y());
- if (qFuzzyCompare(dist + 1, 1))
+ if (qFuzzyIsNull(dist))
return false;
normals[2] /= dist;
@@ -1022,7 +1022,7 @@ int QBezier::stationaryYPoints(qreal &t0, qreal &t1) const
QList<qreal> result;
- if (qFuzzyCompare(reciprocal + 1, 1)) {
+ if (qFuzzyIsNull(reciprocal)) {
t0 = -b / (2 * a);
return 1;
} else if (reciprocal > 0) {
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 5d7d4ab..24d167e 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -1387,7 +1387,7 @@ QColor QColor::toHsv() const
const qreal min = Q_MIN_3(r, g, b);
const qreal delta = max - min;
color.ct.ahsv.value = qRound(max * USHRT_MAX);
- if (qFuzzyCompare(delta + 1, 1)) {
+ if (qFuzzyIsNull(delta)) {
// achromatic case, hue is undefined
color.ct.ahsv.hue = USHRT_MAX;
color.ct.ahsv.saturation = 0;
@@ -1441,7 +1441,7 @@ QColor QColor::toCmyk() const
// cmy -> cmyk
const qreal k = qMin(c, qMin(m, y));
- if (!qFuzzyCompare(k,1)) {
+ if (!qFuzzyIsNull(k - 1)) {
c = (c - k) / (1.0 - k);
m = (m - k) / (1.0 - k);
y = (y - k) / (1.0 - k);
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index efdc778..63e14ca 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -157,46 +157,9 @@ static uint * QT_FASTCALL destFetchRGB16(uint *buffer, QRasterBuffer *rasterBuff
return buffer;
}
-#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL)
-template <typename EnumType, int value>
-class QEnumToType
-{
-public:
- inline EnumType operator()() const
- {
- return EnumType(value);
- }
-};
-template <QImage::Format format>
-class QImageFormatToType
-{
-public:
- inline QImage::Format operator()() const
- {
- return format;
- }
-};
-// Would have used QEnumToType instead of creating a specialized version for QImageFormatToType,
-// but that causes internal compiler error on VC6
-#define Q_TEMPLATE_IMAGEFORMAT_FIX(format) , const QImageFormatToType<format> &imageFormatType
-#define Q_TEMPLATE_IMAGEFORMAT_CALL(format) , QImageFormatToType<format>()
-#define Q_TEMPLATE_ENUM_FIX(Type, Value) , const QEnumToType<Type, Value> &enumTemplateType
-#define Q_TEMPLATE_ENUM_CALL(Type, Value) , QEnumToType<Type, Value>()
-#define Q_TEMPLATE_FIX(Type) , const QTypeInfo<Type> &templateType
-#define Q_TEMPLATE_CALL(Type) , QTypeInfo<Type>()
-#else
-#define Q_TEMPLATE_IMAGEFORMAT_FIX(format)
-#define Q_TEMPLATE_IMAGEFORMAT_CALL(format)
-#define Q_TEMPLATE_ENUM_FIX(Type, Value)
-#define Q_TEMPLATE_ENUM_CALL(Type, Value)
-#define Q_TEMPLATE_FIX(Type)
-#define Q_TEMPLATE_CALL(Type)
-#endif
-
template <class DST>
Q_STATIC_TEMPLATE_FUNCTION uint * QT_FASTCALL destFetch(uint *buffer, QRasterBuffer *rasterBuffer,
- int x, int y, int length
- Q_TEMPLATE_FIX(DST))
+ int x, int y, int length)
{
const DST *src = reinterpret_cast<DST*>(rasterBuffer->scanLine(y)) + x;
quint32 *dest = reinterpret_cast<quint32*>(buffer);
@@ -205,28 +168,7 @@ Q_STATIC_TEMPLATE_FUNCTION uint * QT_FASTCALL destFetch(uint *buffer, QRasterBuf
return buffer;
}
-#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL)
-#define DEST_FETCH_DECL(DST) \
- static uint * QT_FASTCALL destFetch_##DST(uint *buffer, \
- QRasterBuffer *rasterBuffer, \
- int x, int y, int length) \
- { \
- return destFetch<DST>(buffer, rasterBuffer, x, y, length Q_TEMPLATE_CALL(DST)); \
- }
-
-DEST_FETCH_DECL(qargb8565)
-DEST_FETCH_DECL(qrgb666)
-DEST_FETCH_DECL(qargb6666)
-DEST_FETCH_DECL(qrgb555)
-DEST_FETCH_DECL(qrgb888)
-DEST_FETCH_DECL(qargb8555)
-DEST_FETCH_DECL(qrgb444)
-DEST_FETCH_DECL(qargb4444)
-#undef DEST_FETCH_DECL
-# define SPANFUNC_POINTER_DESTFETCH(Arg) destFetch_##Arg
-#else // !VC6 && !VC2002
# define SPANFUNC_POINTER_DESTFETCH(Arg) destFetch<Arg>
-#endif
static const DestFetchProc destFetchProc[QImage::NImageFormats] =
{
@@ -366,8 +308,7 @@ static void QT_FASTCALL destStoreRGB16(QRasterBuffer *rasterBuffer, int x, int y
template <class DST>
Q_STATIC_TEMPLATE_FUNCTION void QT_FASTCALL destStore(QRasterBuffer *rasterBuffer,
int x, int y,
- const uint *buffer, int length
- Q_TEMPLATE_FIX(DST))
+ const uint *buffer, int length)
{
DST *dest = reinterpret_cast<DST*>(rasterBuffer->scanLine(y)) + x;
const quint32 *src = reinterpret_cast<const quint32*>(buffer);
@@ -375,28 +316,7 @@ Q_STATIC_TEMPLATE_FUNCTION void QT_FASTCALL destStore(QRasterBuffer *rasterBuffe
*dest++ = DST(*src++);
}
-#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL)
-# define DEST_STORE_DECL(DST) \
- static void QT_FASTCALL destStore_##DST(QRasterBuffer *rasterBuffer, \
- int x, int y, \
- const uint *buffer, int length) \
- { \
- destStore<DST>(rasterBuffer, x, y, buffer, length Q_TEMPLATE_CALL(DST)); \
- }
-
-DEST_STORE_DECL(qargb8565)
-DEST_STORE_DECL(qrgb555)
-DEST_STORE_DECL(qrgb666)
-DEST_STORE_DECL(qargb6666)
-DEST_STORE_DECL(qargb8555)
-DEST_STORE_DECL(qrgb888)
-DEST_STORE_DECL(qrgb444)
-DEST_STORE_DECL(qargb4444)
-# undef DEST_FETCH_DECL
-# define SPANFUNC_POINTER_DESTSTORE(DEST) destStore_##DEST
-#else // !VC6 && !VC2002
# define SPANFUNC_POINTER_DESTSTORE(DEST) destStore<DEST>
-#endif
static const DestStoreProc destStoreProc[QImage::NImageFormats] =
{
@@ -425,10 +345,8 @@ static const DestStoreProc destStoreProc[QImage::NImageFormats] =
We need 5 fetch methods per surface type:
untransformed
- transformed
- transformed tiled
- transformed bilinear
- transformed bilinear tiled
+ transformed (tiled and not tiled)
+ transformed bilinear (tiled and not tiled)
We don't need bounds checks for untransformed, but we need them for the other ones.
@@ -436,14 +354,12 @@ static const DestStoreProc destStoreProc[QImage::NImageFormats] =
*/
template <QImage::Format format>
-Q_STATIC_TEMPLATE_FUNCTION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, const QVector<QRgb> *rgb
- Q_TEMPLATE_IMAGEFORMAT_FIX(format));
+Q_STATIC_TEMPLATE_FUNCTION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, const QVector<QRgb> *rgb);
template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_Mono>(const uchar *scanLine,
- int x, const QVector<QRgb> *rgb
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_Mono))
+ int x, const QVector<QRgb> *rgb)
{
bool pixel = scanLine[x>>3] & (0x80 >> (x & 7));
if (rgb) return PREMUL(rgb->at(pixel ? 1 : 0));
@@ -453,8 +369,7 @@ uint QT_FASTCALL qt_fetchPixel<QImage::Format_Mono>(const uchar *scanLine,
template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_MonoLSB>(const uchar *scanLine,
- int x, const QVector<QRgb> *rgb
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_MonoLSB))
+ int x, const QVector<QRgb> *rgb)
{
bool pixel = scanLine[x>>3] & (0x1 << (x & 7));
if (rgb) return PREMUL(rgb->at(pixel ? 1 : 0));
@@ -464,8 +379,7 @@ uint QT_FASTCALL qt_fetchPixel<QImage::Format_MonoLSB>(const uchar *scanLine,
template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_Indexed8>(const uchar *scanLine,
- int x, const QVector<QRgb> *rgb
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_Indexed8))
+ int x, const QVector<QRgb> *rgb)
{
return PREMUL(rgb->at(scanLine[x]));
}
@@ -473,8 +387,7 @@ uint QT_FASTCALL qt_fetchPixel<QImage::Format_Indexed8>(const uchar *scanLine,
template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB32>(const uchar *scanLine,
- int x, const QVector<QRgb> *
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB32))
+ int x, const QVector<QRgb> *)
{
return PREMUL(((const uint *)scanLine)[x]);
}
@@ -482,8 +395,7 @@ uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB32>(const uchar *scanLine,
template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB32_Premultiplied>(const uchar *scanLine,
- int x, const QVector<QRgb> *
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB32_Premultiplied))
+ int x, const QVector<QRgb> *)
{
return ((const uint *)scanLine)[x];
}
@@ -491,8 +403,7 @@ uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB32_Premultiplied>(const uchar
template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB16>(const uchar *scanLine,
- int x, const QVector<QRgb> *
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_RGB16))
+ int x, const QVector<QRgb> *)
{
return qConvertRgb16To32(((const ushort *)scanLine)[x]);
}
@@ -501,8 +412,7 @@ template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB8565_Premultiplied>(const uchar *scanLine,
int x,
- const QVector<QRgb> *
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB8565_Premultiplied))
+ const QVector<QRgb> *)
{
const qargb8565 color = reinterpret_cast<const qargb8565*>(scanLine)[x];
return qt_colorConvert<quint32, qargb8565>(color, 0);
@@ -512,8 +422,7 @@ template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB666>(const uchar *scanLine,
int x,
- const QVector<QRgb> *
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_RGB666))
+ const QVector<QRgb> *)
{
const qrgb666 color = reinterpret_cast<const qrgb666*>(scanLine)[x];
return qt_colorConvert<quint32, qrgb666>(color, 0);
@@ -523,8 +432,7 @@ template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB6666_Premultiplied>(const uchar *scanLine,
int x,
- const QVector<QRgb> *
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB6666_Premultiplied))
+ const QVector<QRgb> *)
{
const qargb6666 color = reinterpret_cast<const qargb6666*>(scanLine)[x];
return qt_colorConvert<quint32, qargb6666>(color, 0);
@@ -534,8 +442,7 @@ template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB555>(const uchar *scanLine,
int x,
- const QVector<QRgb> *
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_RGB555))
+ const QVector<QRgb> *)
{
const qrgb555 color = reinterpret_cast<const qrgb555*>(scanLine)[x];
return qt_colorConvert<quint32, qrgb555>(color, 0);
@@ -545,8 +452,7 @@ template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB8555_Premultiplied>(const uchar *scanLine,
int x,
- const QVector<QRgb> *
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB8555_Premultiplied))
+ const QVector<QRgb> *)
{
const qargb8555 color = reinterpret_cast<const qargb8555*>(scanLine)[x];
return qt_colorConvert<quint32, qargb8555>(color, 0);
@@ -556,8 +462,7 @@ template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB888>(const uchar *scanLine,
int x,
- const QVector<QRgb> *
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_RGB888))
+ const QVector<QRgb> *)
{
const qrgb888 color = reinterpret_cast<const qrgb888*>(scanLine)[x];
return qt_colorConvert<quint32, qrgb888>(color, 0);
@@ -567,8 +472,7 @@ template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB444>(const uchar *scanLine,
int x,
- const QVector<QRgb> *
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_RGB444))
+ const QVector<QRgb> *)
{
const qrgb444 color = reinterpret_cast<const qrgb444*>(scanLine)[x];
return qt_colorConvert<quint32, qrgb444>(color, 0);
@@ -578,47 +482,24 @@ template<>
Q_STATIC_TEMPLATE_SPECIALIZATION
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB4444_Premultiplied>(const uchar *scanLine,
int x,
- const QVector<QRgb> *
- Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB4444_Premultiplied))
+ const QVector<QRgb> *)
{
const qargb4444 color = reinterpret_cast<const qargb4444*>(scanLine)[x];
return qt_colorConvert<quint32, qargb4444>(color, 0);
}
-typedef uint (QT_FASTCALL *FetchPixelProc)(const uchar *scanLine, int x, const QVector<QRgb> *);
-
-#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL)
-
-// explicit template instantiations needed to compile with VC6 and VC2002
-
-#define SPANFUNC_INSTANTIATION_FETCHPIXEL(Arg) \
- static inline uint fetchPixel_##Arg(const uchar * scanLine, int x, const QVector<QRgb> * rgb) \
-{ \
- return qt_fetchPixel<QImage::Arg>(scanLine, x, rgb Q_TEMPLATE_IMAGEFORMAT_CALL(QImage::Arg)); \
+template<>
+Q_STATIC_TEMPLATE_SPECIALIZATION
+uint QT_FASTCALL qt_fetchPixel<QImage::Format_Invalid>(const uchar *,
+ int ,
+ const QVector<QRgb> *)
+{
+ return 0;
}
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_Mono);
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_MonoLSB);
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_Indexed8);
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_ARGB32_Premultiplied);
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_ARGB32);
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_RGB16);
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_ARGB8565_Premultiplied);
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_RGB666);
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_ARGB6666_Premultiplied);
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_RGB555);
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_ARGB8555_Premultiplied);
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_RGB888);
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_RGB444);
-SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_ARGB4444_Premultiplied);
-
-#undef SPANFUNC_INSTANTIATION_FETCHPIXEL
-
-#define SPANFUNC_POINTER_FETCHPIXEL(Arg) fetchPixel_##Arg
+typedef uint (QT_FASTCALL *FetchPixelProc)(const uchar *scanLine, int x, const QVector<QRgb> *);
-#else // !VC6 && !VC2002
-# define SPANFUNC_POINTER_FETCHPIXEL(Arg) qt_fetchPixel<QImage::Arg>
-#endif
+#define SPANFUNC_POINTER_FETCHPIXEL(Arg) qt_fetchPixel<QImage::Arg>
static const FetchPixelProc fetchPixelProc[QImage::NImageFormats] =
@@ -653,11 +534,11 @@ enum TextureBlendType {
template <QImage::Format format>
Q_STATIC_TEMPLATE_FUNCTION const uint * QT_FASTCALL qt_fetchUntransformed(uint *buffer, const Operator *, const QSpanData *data,
- int y, int x, int length Q_TEMPLATE_IMAGEFORMAT_FIX(format))
+ int y, int x, int length)
{
const uchar *scanLine = data->texture.scanLine(y);
for (int i = 0; i < length; ++i)
- buffer[i] = qt_fetchPixel<format>(scanLine, x + i, data->texture.colorTable Q_TEMPLATE_IMAGEFORMAT_CALL(format));
+ buffer[i] = qt_fetchPixel<format>(scanLine, x + i, data->texture.colorTable);
return buffer;
}
@@ -665,13 +546,15 @@ template <>
Q_STATIC_TEMPLATE_SPECIALIZATION const uint * QT_FASTCALL
qt_fetchUntransformed<QImage::Format_ARGB32_Premultiplied>(uint *, const Operator *,
const QSpanData *data,
- int y, int x, int Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB32_Premultiplied))
+ int y, int x, int)
{
const uchar *scanLine = data->texture.scanLine(y);
return ((const uint *)scanLine) + x;
}
-static const uint * QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const QSpanData *data,
+template<TextureBlendType blendType> /* either BlendTransformed or BlendTransformedTiled */
+Q_STATIC_TEMPLATE_FUNCTION
+const uint * QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const QSpanData *data,
int y, int x, int length)
{
FetchPixelProc fetch = fetchPixelProc[data->texture.format];
@@ -698,84 +581,23 @@ static const uint * QT_FASTCALL fetchTransformed(uint *buffer, const Operator *,
int px = fx >> 16;
int py = fy >> 16;
- bool out = (px < 0) || (px >= image_width)
- || (py < 0) || (py >= image_height);
+ if (blendType == BlendTransformedTiled) {
+ px %= image_width;
+ py %= image_height;
+ if (px < 0) px += image_width;
+ if (py < 0) py += image_height;
- const uchar *scanLine = data->texture.scanLine(py);
- *b = out ? uint(0) : fetch(scanLine, px, data->texture.colorTable);
- fx += fdx;
- fy += fdy;
- ++b;
- }
- } 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;
-
- while (b < end) {
- const qreal iw = fw == 0 ? 1 : 1 / fw;
- const qreal tx = fx * iw;
- const qreal ty = fy * iw;
- const int px = int(tx) - (tx < 0);
- const int py = int(ty) - (ty < 0);
-
- bool out = (px < 0) || (px >= image_width)
- || (py < 0) || (py >= image_height);
-
- const uchar *scanLine = data->texture.scanLine(py);
- *b = out ? uint(0) : fetch(scanLine, px, data->texture.colorTable);
- fx += fdx;
- fy += fdy;
- fw += fdw;
- //force increment to avoid /0
- if (!fw) {
- fw += fdw;
+ const uchar *scanLine = data->texture.scanLine(py);
+ *b = fetch(scanLine, px, data->texture.colorTable);
+ } else {
+ if ((px < 0) || (px >= image_width)
+ || (py < 0) || (py >= image_height)) {
+ *b = uint(0);
+ } else {
+ const uchar *scanLine = data->texture.scanLine(py);
+ *b = fetch(scanLine, px, data->texture.colorTable);
+ }
}
- ++b;
- }
- }
-
- return buffer;
-}
-
-static const uint * QT_FASTCALL fetchTransformedTiled(uint *buffer, const Operator *, const QSpanData *data,
- int y, int x, int length)
-{
- FetchPixelProc fetch = fetchPixelProc[data->texture.format];
-
- int image_width = data->texture.width;
- int image_height = data->texture.height;
-
- const qreal cx = x + 0.5;
- const qreal cy = y + 0.5;
-
- const uint *end = buffer + length;
- uint *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);
-
- while (b < end) {
- int px = fx >> 16;
- int py = fy >> 16;
-
- px %= image_width;
- py %= image_height;
- if (px < 0) px += image_width;
- if (py < 0) py += image_height;
-
- const uchar *scanLine = data->texture.scanLine(py);
- *b = fetch(scanLine, px, data->texture.colorTable);
fx += fdx;
fy += fdy;
++b;
@@ -796,13 +618,23 @@ static const uint * QT_FASTCALL fetchTransformedTiled(uint *buffer, const Operat
int px = int(tx) - (tx < 0);
int py = int(ty) - (ty < 0);
- px %= image_width;
- py %= image_height;
- if (px < 0) px += image_width;
- if (py < 0) py += image_height;
+ if (blendType == BlendTransformedTiled) {
+ px %= image_width;
+ py %= image_height;
+ if (px < 0) px += image_width;
+ if (py < 0) py += image_height;
- const uchar *scanLine = data->texture.scanLine(py);
- *b = fetch(scanLine, px, data->texture.colorTable);
+ const uchar *scanLine = data->texture.scanLine(py);
+ *b = fetch(scanLine, px, data->texture.colorTable);
+ } else {
+ if ((px < 0) || (px >= image_width)
+ || (py < 0) || (py >= image_height)) {
+ *b = uint(0);
+ } else {
+ const uchar *scanLine = data->texture.scanLine(py);
+ *b = fetch(scanLine, px, data->texture.colorTable);
+ }
+ }
fx += fdx;
fy += fdy;
fw += fdw;
@@ -817,10 +649,12 @@ static const uint * QT_FASTCALL fetchTransformedTiled(uint *buffer, const Operat
return buffer;
}
-static const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *, const QSpanData *data,
- int y, int x, int length)
+template<TextureBlendType blendType, QImage::Format format> /* blendType = BlendTransformedBilinear or BlendTransformedBilinearTiled */
+Q_STATIC_TEMPLATE_FUNCTION
+const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *, const QSpanData *data,
+ int y, int x, int length)
{
- FetchPixelProc fetch = fetchPixelProc[data->texture.format];
+ FetchPixelProc fetch = (format != QImage::Format_Invalid) ? FetchPixelProc(qt_fetchPixel<format>) : fetchPixelProc[data->texture.format];
int image_width = data->texture.width;
int image_height = data->texture.height;
@@ -853,130 +687,27 @@ static const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Ope
int idistx = 256 - distx;
int idisty = 256 - disty;
- x1 = qBound(0, x1, image_width - 1);
- x2 = qBound(0, x2, image_width - 1);
- y1 = qBound(0, y1, image_height - 1);
- y2 = qBound(0, y2, image_height - 1);
-
- const uchar *s1 = data->texture.scanLine(y1);
- const uchar *s2 = data->texture.scanLine(y2);
-
- uint tl = fetch(s1, x1, data->texture.colorTable);
- uint tr = fetch(s1, x2, data->texture.colorTable);
- uint bl = fetch(s2, x1, data->texture.colorTable);
- uint br = fetch(s2, x2, data->texture.colorTable);
-
- uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx);
- uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx);
- *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty);
-
- fx += fdx;
- fy += fdy;
- ++b;
- }
- } 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;
-
- while (b < end) {
- const qreal iw = fw == 0 ? 1 : 1 / fw;
- const qreal px = fx * iw - 0.5;
- const qreal py = fy * iw - 0.5;
-
- int x1 = int(px) - (px < 0);
- int x2 = x1 + 1;
- int y1 = int(py) - (py < 0);
- int y2 = y1 + 1;
-
- int distx = int((px - x1) * 256);
- int disty = int((py - y1) * 256);
- int idistx = 256 - distx;
- int idisty = 256 - disty;
-
- x1 = qBound(0, x1, image_width - 1);
- x2 = qBound(0, x2, image_width - 1);
- y1 = qBound(0, y1, image_height - 1);
- y2 = qBound(0, y2, image_height - 1);
-
- const uchar *s1 = data->texture.scanLine(y1);
- const uchar *s2 = data->texture.scanLine(y2);
-
- uint tl = fetch(s1, x1, data->texture.colorTable);
- uint tr = fetch(s1, x2, data->texture.colorTable);
- uint bl = fetch(s2, x1, data->texture.colorTable);
- uint br = fetch(s2, x2, data->texture.colorTable);
-
- uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx);
- uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx);
- *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty);
-
- fx += fdx;
- fy += fdy;
- fw += fdw;
- //force increment to avoid /0
- if (!fw) {
- fw += fdw;
+ if (blendType == BlendTransformedBilinearTiled) {
+ x1 %= image_width;
+ x2 %= image_width;
+ y1 %= image_height;
+ y2 %= image_height;
+
+ if (x1 < 0) x1 += image_width;
+ if (x2 < 0) x2 += image_width;
+ if (y1 < 0) y1 += image_height;
+ if (y2 < 0) y2 += image_height;
+
+ Q_ASSERT(x1 >= 0 && x1 < image_width);
+ Q_ASSERT(x2 >= 0 && x2 < image_width);
+ Q_ASSERT(y1 >= 0 && y1 < image_height);
+ Q_ASSERT(y2 >= 0 && y2 < image_height);
+ } else {
+ x1 = qBound(0, x1, image_width - 1);
+ x2 = qBound(0, x2, image_width - 1);
+ y1 = qBound(0, y1, image_height - 1);
+ y2 = qBound(0, y2, image_height - 1);
}
- ++b;
- }
- }
-
- return buffer;
-}
-
-static const uint * QT_FASTCALL fetchTransformedBilinearTiled(uint *buffer, const Operator *, const QSpanData *data,
- int y, int x, int length)
-{
- FetchPixelProc fetch = fetchPixelProc[data->texture.format];
-
- int image_width = data->texture.width;
- int image_height = data->texture.height;
-
- const qreal cx = x + 0.5;
- const qreal cy = y + 0.5;
-
- const uint *end = buffer + length;
- uint *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);
-
- fx -= half_point;
- fy -= half_point;
- while (b < end) {
- int x1 = (fx >> 16);
- int x2 = x1 + 1;
- int y1 = (fy >> 16);
- int y2 = y1 + 1;
-
- int distx = ((fx - (x1 << 16)) >> 8);
- int disty = ((fy - (y1 << 16)) >> 8);
- int idistx = 256 - distx;
- int idisty = 256 - disty;
-
- x1 %= image_width;
- x2 %= image_width;
- y1 %= image_height;
- y2 %= image_height;
-
- if (x1 < 0) x1 += image_width;
- if (x2 < 0) x2 += image_width;
- if (y1 < 0) y1 += image_height;
- if (y2 < 0) y2 += image_height;
-
- Q_ASSERT(x1 >= 0 && x1 < image_width);
- Q_ASSERT(x2 >= 0 && x2 < image_width);
- Q_ASSERT(y1 >= 0 && y1 < image_height);
- Q_ASSERT(y2 >= 0 && y2 < image_height);
const uchar *s1 = data->texture.scanLine(y1);
const uchar *s2 = data->texture.scanLine(y2);
@@ -1018,20 +749,27 @@ static const uint * QT_FASTCALL fetchTransformedBilinearTiled(uint *buffer, cons
int idistx = 256 - distx;
int idisty = 256 - disty;
- x1 %= image_width;
- x2 %= image_width;
- y1 %= image_height;
- y2 %= image_height;
-
- if (x1 < 0) x1 += image_width;
- if (x2 < 0) x2 += image_width;
- if (y1 < 0) y1 += image_height;
- if (y2 < 0) y2 += image_height;
-
- Q_ASSERT(x1 >= 0 && x1 < image_width);
- Q_ASSERT(x2 >= 0 && x2 < image_width);
- Q_ASSERT(y1 >= 0 && y1 < image_height);
- Q_ASSERT(y2 >= 0 && y2 < image_height);
+ if (blendType == BlendTransformedBilinearTiled) {
+ x1 %= image_width;
+ x2 %= image_width;
+ y1 %= image_height;
+ y2 %= image_height;
+
+ if (x1 < 0) x1 += image_width;
+ if (x2 < 0) x2 += image_width;
+ if (y1 < 0) y1 += image_height;
+ if (y2 < 0) y2 += image_height;
+
+ Q_ASSERT(x1 >= 0 && x1 < image_width);
+ Q_ASSERT(x2 >= 0 && x2 < image_width);
+ Q_ASSERT(y1 >= 0 && y1 < image_height);
+ Q_ASSERT(y2 >= 0 && y2 < image_height);
+ } else {
+ x1 = qBound(0, x1, image_width - 1);
+ x2 = qBound(0, x2, image_width - 1);
+ y1 = qBound(0, y1, image_height - 1);
+ y2 = qBound(0, y2, image_height - 1);
+ }
const uchar *s1 = data->texture.scanLine(y1);
const uchar *s2 = data->texture.scanLine(y2);
@@ -1059,39 +797,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearTiled(uint *buffer, cons
return buffer;
}
-#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL)
-
-// explicit template instantiations needed to compile with VC6 and VC2002
-
-#define SPANFUNC_POINTER_FETCHUNTRANSFORMED(Arg) \
- const uint *qt_fetchUntransformed_##Arg(uint *buffer, const Operator *op, const QSpanData *data, \
- int y, int x, int length) \
-{ \
- return qt_fetchUntransformed<QImage::Arg>(buffer, op, data, y, x, length Q_TEMPLATE_IMAGEFORMAT_CALL(QImage::Arg)); \
-}
-
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_Mono);
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_MonoLSB);
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_Indexed8);
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_ARGB32_Premultiplied);
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_ARGB32);
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_RGB16);
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_ARGB8565_Premultiplied);
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_RGB666);
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_ARGB6666_Premultiplied);
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_RGB555);
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_ARGB8555_Premultiplied);
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_RGB888);
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_RGB444);
-SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_ARGB4444_Premultiplied);
-
-#undef SPANFUNC_POINTER_FETCHUNTRANSFORMED
-
-#define SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Arg) qt_fetchUntransformed_##Arg
-
-#else // !VC6 && !VC2002
-# define SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Arg) qt_fetchUntransformed<QImage::Arg>
-#endif
+#define SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Arg) qt_fetchUntransformed<QImage::Arg>
static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
// Untransformed
@@ -1135,75 +841,75 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
// Transformed
{
0, // Invalid
- fetchTransformed, // Mono
- fetchTransformed, // MonoLsb
- fetchTransformed, // Indexed8
- fetchTransformed, // RGB32
- fetchTransformed, // ARGB32
- fetchTransformed, // ARGB32_Premultiplied
- fetchTransformed, // RGB16
- fetchTransformed, // ARGB8565_Premultiplied
- fetchTransformed, // RGB666
- fetchTransformed, // ARGB6666_Premultiplied
- fetchTransformed, // RGB555
- fetchTransformed, // ARGB8555_Premultiplied
- fetchTransformed, // RGB888
- fetchTransformed, // RGB444
- fetchTransformed, // ARGB4444_Premultiplied
+ fetchTransformed<BlendTransformed>, // Mono
+ fetchTransformed<BlendTransformed>, // MonoLsb
+ fetchTransformed<BlendTransformed>, // Indexed8
+ fetchTransformed<BlendTransformed>, // RGB32
+ fetchTransformed<BlendTransformed>, // ARGB32
+ fetchTransformed<BlendTransformed>, // ARGB32_Premultiplied
+ fetchTransformed<BlendTransformed>, // RGB16
+ fetchTransformed<BlendTransformed>, // ARGB8565_Premultiplied
+ fetchTransformed<BlendTransformed>, // RGB666
+ fetchTransformed<BlendTransformed>, // ARGB6666_Premultiplied
+ fetchTransformed<BlendTransformed>, // RGB555
+ fetchTransformed<BlendTransformed>, // ARGB8555_Premultiplied
+ fetchTransformed<BlendTransformed>, // RGB888
+ fetchTransformed<BlendTransformed>, // RGB444
+ fetchTransformed<BlendTransformed>, // ARGB4444_Premultiplied
},
{
0, // TransformedTiled
- fetchTransformedTiled, // Mono
- fetchTransformedTiled, // MonoLsb
- fetchTransformedTiled, // Indexed8
- fetchTransformedTiled, // RGB32
- fetchTransformedTiled, // ARGB32
- fetchTransformedTiled, // ARGB32_Premultiplied
- fetchTransformedTiled, // RGB16
- fetchTransformedTiled, // ARGB8565_Premultiplied
- fetchTransformedTiled, // RGB666
- fetchTransformedTiled, // ARGB6666_Premultiplied
- fetchTransformedTiled, // RGB555
- fetchTransformedTiled, // ARGB8555_Premultiplied
- fetchTransformedTiled, // RGB888
- fetchTransformedTiled, // RGB444
- fetchTransformedTiled, // ARGB4444_Premultiplied
+ fetchTransformed<BlendTransformedTiled>, // Mono
+ fetchTransformed<BlendTransformedTiled>, // MonoLsb
+ fetchTransformed<BlendTransformedTiled>, // Indexed8
+ fetchTransformed<BlendTransformedTiled>, // RGB32
+ fetchTransformed<BlendTransformedTiled>, // ARGB32
+ fetchTransformed<BlendTransformedTiled>, // ARGB32_Premultiplied
+ fetchTransformed<BlendTransformedTiled>, // RGB16
+ fetchTransformed<BlendTransformedTiled>, // ARGB8565_Premultiplied
+ fetchTransformed<BlendTransformedTiled>, // RGB666
+ fetchTransformed<BlendTransformedTiled>, // ARGB6666_Premultiplied
+ fetchTransformed<BlendTransformedTiled>, // RGB555
+ fetchTransformed<BlendTransformedTiled>, // ARGB8555_Premultiplied
+ fetchTransformed<BlendTransformedTiled>, // RGB888
+ fetchTransformed<BlendTransformedTiled>, // RGB444
+ fetchTransformed<BlendTransformedTiled>, // ARGB4444_Premultiplied
},
{
0, // Bilinear
- fetchTransformedBilinear, // Mono
- fetchTransformedBilinear, // MonoLsb
- fetchTransformedBilinear, // Indexed8
- fetchTransformedBilinear, // RGB32
- fetchTransformedBilinear, // ARGB32
- fetchTransformedBilinear, // ARGB32_Premultiplied
- fetchTransformedBilinear, // RGB16
- fetchTransformedBilinear, // ARGB8565_Premultiplied
- fetchTransformedBilinear, // RGB666
- fetchTransformedBilinear, // ARGB6666_Premultiplied
- fetchTransformedBilinear, // RGB555
- fetchTransformedBilinear, // ARGB8555_Premultiplied
- fetchTransformedBilinear, // RGB888
- fetchTransformedBilinear, // RGB444
- fetchTransformedBilinear // ARGB4444_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // Mono
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // MonoLsb
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // Indexed8
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_ARGB32_Premultiplied>, // RGB32
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_ARGB32>, // ARGB32
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_ARGB32_Premultiplied>, // ARGB32_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB16
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // ARGB8565_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB666
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // ARGB6666_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB555
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // ARGB8555_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB888
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB444
+ fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid> // ARGB4444_Premultiplied
},
{
0, // BilinearTiled
- fetchTransformedBilinearTiled, // Mono
- fetchTransformedBilinearTiled, // MonoLsb
- fetchTransformedBilinearTiled, // Indexed8
- fetchTransformedBilinearTiled, // RGB32
- fetchTransformedBilinearTiled, // ARGB32
- fetchTransformedBilinearTiled, // ARGB32_Premultiplied
- fetchTransformedBilinearTiled, // RGB16
- fetchTransformedBilinearTiled, // ARGB8565_Premultiplied
- fetchTransformedBilinearTiled, // RGB666
- fetchTransformedBilinearTiled, // ARGB6666_Premultiplied
- fetchTransformedBilinearTiled, // RGB555
- fetchTransformedBilinearTiled, // ARGB8555_Premultiplied
- fetchTransformedBilinearTiled, // RGB888
- fetchTransformedBilinearTiled, // RGB444
- fetchTransformedBilinearTiled // ARGB4444_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // Mono
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // MonoLsb
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // Indexed8
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_ARGB32_Premultiplied>, // RGB32
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_ARGB32>, // ARGB32
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_ARGB32_Premultiplied>, // ARGB32_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB16
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // ARGB8565_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB666
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // ARGB6666_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB555
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // ARGB8555_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB888
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB444
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid> // ARGB4444_Premultiplied
},
};
@@ -3220,8 +2926,7 @@ static void blend_color_argb(int count, const QSpan *spans, void *userData)
}
template <class T>
-Q_STATIC_TEMPLATE_FUNCTION void blendColor(int count, const QSpan *spans, void *userData
- Q_TEMPLATE_FIX(T))
+Q_STATIC_TEMPLATE_FUNCTION void blendColor(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
Operator op = getOperator(data, spans, count);
@@ -3267,28 +2972,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendColor(int count, const QSpan *spans, void *
blend_color_generic(count, spans, userData);
}
-#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL)
-#define BLEND_COLOR_DECL(DST) \
- static void blendColor_##DST(int count, \
- const QSpan *spans, \
- void *userData) \
- { \
- blendColor<DST>(count, spans, userData Q_TEMPLATE_CALL(DST)); \
- }
-
-BLEND_COLOR_DECL(qargb8565)
-BLEND_COLOR_DECL(qrgb666)
-BLEND_COLOR_DECL(qargb6666)
-BLEND_COLOR_DECL(qrgb555)
-BLEND_COLOR_DECL(qargb8555)
-BLEND_COLOR_DECL(qrgb888)
-BLEND_COLOR_DECL(qrgb444)
-BLEND_COLOR_DECL(qargb4444)
-#undef DEST_FETCH_DECL
-#define SPANFUNC_POINTER_BLENDCOLOR(DST) blendColor_##DST
-#else // !VC6 && !VC2002
-# define SPANFUNC_POINTER_BLENDCOLOR(DST) blendColor<DST>
-#endif
+#define SPANFUNC_POINTER_BLENDCOLOR(DST) blendColor<DST>
static void blend_color_rgb16(int count, const QSpan *spans, void *userData)
{
@@ -3366,45 +3050,117 @@ static void blend_color_rgb16(int count, const QSpan *spans, void *userData)
blend_color_generic(count, spans, userData);
}
-template <SpanMethod spanMethod>
-Q_STATIC_TEMPLATE_FUNCTION void blend_src_generic(int count, const QSpan *spans, void *userData
- Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod))
+template <typename T>
+void handleSpans(int count, const QSpan *spans, const QSpanData *data, T &handler)
{
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- uint buffer[buffer_size];
- uint src_buffer[buffer_size];
- Operator op = getOperator(data, spans, count);
-
uint const_alpha = 256;
if (data->type == QSpanData::Texture)
const_alpha = data->texture.const_alpha;
- while (count--) {
+ int coverage = 0;
+ while (count) {
int x = spans->x;
- int length = spans->len;
- const int coverage = (spans->coverage * const_alpha) >> 8;
+ const int y = spans->y;
+ int right = x + spans->len;
+
+ // compute length of adjacent spans
+ for (int i = 1; i < count && spans[i].y == y && spans[i].x == right; ++i)
+ right += spans[i].len;
+ int length = right - x;
+
while (length) {
int l = qMin(buffer_size, length);
- const uint *src = op.src_fetch(src_buffer, &op, data, spans->y, x, l);
- if (spanMethod == RegularSpans) {
- uint *dest = op.dest_fetch ? op.dest_fetch(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);
- } else {
- drawBufferSpan(data, src, l, x, spans->y, l, coverage);
- }
- x += l;
length -= l;
+
+ int process_length = l;
+ int process_x = x;
+
+ const uint *src = handler.fetch(process_x, y, process_length);
+ int offset = 0;
+ while (l > 0) {
+ if (x == spans->x) // new span?
+ coverage = (spans->coverage * const_alpha) >> 8;
+
+ int right = spans->x + spans->len;
+ int len = qMin(l, right - x);
+
+ handler.process(x, y, len, coverage, src, offset);
+
+ l -= len;
+ x += len;
+ offset += len;
+
+ if (x == right) { // done with current span?
+ ++spans;
+ --count;
+ }
+ }
+ handler.store(process_x, y, process_length);
}
- ++spans;
}
}
+struct QBlendBase
+{
+ QBlendBase(QSpanData *d, Operator o)
+ : data(d)
+ , op(o)
+ , dest(0)
+ {
+ }
+
+ QSpanData *data;
+ Operator op;
+
+ uint *dest;
+
+ uint buffer[buffer_size];
+ uint src_buffer[buffer_size];
+};
+
+template <SpanMethod spanMethod>
+class BlendSrcGeneric : public QBlendBase
+{
+public:
+ BlendSrcGeneric(QSpanData *d, Operator o)
+ : QBlendBase(d, o)
+ {
+ }
+
+ const uint *fetch(int x, int y, int len)
+ {
+ if (spanMethod == RegularSpans)
+ 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);
+ }
+
+ void process(int x, int y, int len, int coverage, const uint *src, int offset)
+ {
+ if (spanMethod == RegularSpans)
+ op.func(dest + offset, src + offset, len, coverage);
+ else
+ drawBufferSpan(data, src + offset, len, x, y, len, coverage);
+ }
+
+ void store(int x, int y, int len)
+ {
+ if (spanMethod == RegularSpans && op.dest_store) {
+ op.dest_store(data->rasterBuffer, x, y, dest, len);
+ }
+ }
+};
+
+template <SpanMethod spanMethod>
+Q_STATIC_TEMPLATE_FUNCTION void blend_src_generic(int count, const QSpan *spans, void *userData)
+{
+ QSpanData *data = reinterpret_cast<QSpanData *>(userData);
+ BlendSrcGeneric<spanMethod> blend(data, getOperator(data, spans, count));
+ handleSpans(count, spans, data, blend);
+}
+
template <SpanMethod spanMethod>
-Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_generic(int count, const QSpan *spans, void *userData
- Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod))
+Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_generic(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
@@ -3455,13 +3211,12 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_generic(int count, const QSp
}
template <SpanMethod spanMethod>
-Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_argb(int count, const QSpan *spans, void *userData
- Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod))
+Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_argb(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format != QImage::Format_ARGB32_Premultiplied
&& data->texture.format != QImage::Format_RGB32) {
- blend_untransformed_generic<spanMethod>(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, spanMethod));
+ blend_untransformed_generic<spanMethod>(count, spans, userData);
return;
}
@@ -4707,8 +4462,7 @@ void QT_FASTCALL blendUntransformed(int count, const QSpan *spans, void *userDat
if (mode != QPainter::CompositionMode_SourceOver &&
mode != QPainter::CompositionMode_Source)
{
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
return;
}
@@ -4770,8 +4524,7 @@ static void blend_untransformed_rgb888(int count, const QSpan *spans,
blendUntransformed<qrgb888, qrgb888>(count, spans, userData);
else
#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_argb6666(int count, const QSpan *spans,
@@ -4786,8 +4539,7 @@ static void blend_untransformed_argb6666(int count, const QSpan *spans,
blendUntransformed<qargb6666, qrgb666>(count, spans, userData);
else
#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_rgb666(int count, const QSpan *spans,
@@ -4802,8 +4554,7 @@ static void blend_untransformed_rgb666(int count, const QSpan *spans,
blendUntransformed<qrgb666, qrgb666>(count, spans, userData);
else
#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_argb8565(int count, const QSpan *spans,
@@ -4818,8 +4569,7 @@ static void blend_untransformed_argb8565(int count, const QSpan *spans,
blendUntransformed<qargb8565, qrgb565>(count, spans, userData);
else
#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_rgb565(int count, const QSpan *spans,
@@ -4834,8 +4584,7 @@ static void blend_untransformed_rgb565(int count, const QSpan *spans,
blendUntransformed<qrgb565, qrgb565>(count, spans, userData);
else
#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_argb8555(int count, const QSpan *spans,
@@ -4850,8 +4599,7 @@ static void blend_untransformed_argb8555(int count, const QSpan *spans,
blendUntransformed<qargb8555, qrgb555>(count, spans, userData);
else
#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_rgb555(int count, const QSpan *spans,
@@ -4866,8 +4614,7 @@ static void blend_untransformed_rgb555(int count, const QSpan *spans,
blendUntransformed<qrgb555, qrgb555>(count, spans, userData);
else
#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_argb4444(int count, const QSpan *spans,
@@ -4882,8 +4629,7 @@ static void blend_untransformed_argb4444(int count, const QSpan *spans,
blendUntransformed<qargb4444, qrgb444>(count, spans, userData);
else
#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_rgb444(int count, const QSpan *spans,
@@ -4898,13 +4644,11 @@ static void blend_untransformed_rgb444(int count, const QSpan *spans,
blendUntransformed<qrgb444, qrgb444>(count, spans, userData);
else
#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
template <SpanMethod spanMethod>
-Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_generic(int count, const QSpan *spans, void *userData
- Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod))
+Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_generic(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
@@ -4958,13 +4702,12 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_generic(int count, const QSpan *span
}
template <SpanMethod spanMethod>
-Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_argb(int count, const QSpan *spans, void *userData
- Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod))
+Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_argb(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format != QImage::Format_ARGB32_Premultiplied
&& data->texture.format != QImage::Format_RGB32) {
- blend_tiled_generic<spanMethod>(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, spanMethod));
+ blend_tiled_generic<spanMethod>(count, spans, userData);
return;
}
@@ -5020,8 +4763,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTiled(int count, const QSpan *spans, void *
if (mode != QPainter::CompositionMode_SourceOver &&
mode != QPainter::CompositionMode_Source)
{
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
return;
}
@@ -5091,8 +4833,7 @@ static void blend_tiled_rgb888(int count, const QSpan *spans, void *userData)
blendTiled<qrgb888, qrgb888>(count, spans, userData);
else
#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData)
@@ -5106,8 +4847,7 @@ static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData)
blendTiled<qargb6666, qrgb666>(count, spans, userData);
else
#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData)
@@ -5121,8 +4861,7 @@ static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData)
blendTiled<qrgb666, qrgb666>(count, spans, userData);
else
#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData)
@@ -5136,8 +4875,7 @@ static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData)
blendTiled<qargb8565, qrgb565>(count, spans, userData);
else
#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData)
@@ -5151,8 +4889,7 @@ static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData)
blendTiled<qrgb565, qrgb565>(count, spans, userData);
else
#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData)
@@ -5166,8 +4903,7 @@ static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData)
blendTiled<qargb8555, qrgb555>(count, spans, userData);
else
#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData)
@@ -5181,8 +4917,7 @@ static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData)
blendTiled<qrgb555, qrgb555>(count, spans, userData);
else
#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData)
@@ -5196,8 +4931,7 @@ static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData)
blendTiled<qargb4444, qrgb444>(count, spans, userData);
else
#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData)
@@ -5211,19 +4945,17 @@ static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData)
blendTiled<qrgb444, qrgb444>(count, spans, userData);
else
#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
template <SpanMethod spanMethod>
-Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const QSpan *spans, void *userData
- Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod))
+Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format != QImage::Format_ARGB32_Premultiplied
&& data->texture.format != QImage::Format_RGB32) {
- blend_src_generic<spanMethod>(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, spanMethod));
+ blend_src_generic<spanMethod>(count, spans, userData);
return;
}
@@ -5402,8 +5134,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan
if (mode != QPainter::CompositionMode_SourceOver) {
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
return;
}
@@ -5606,8 +5337,7 @@ static void blend_transformed_bilinear_rgb888(int count, const QSpan *spans, voi
blendTransformedBilinear<qrgb888, qrgb888>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, void *userData)
@@ -5621,8 +5351,7 @@ static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, v
blendTransformedBilinear<qargb6666, qrgb666>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, void *userData)
@@ -5636,8 +5365,7 @@ static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, voi
blendTransformedBilinear<qrgb666, qrgb666>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, void *userData)
@@ -5651,8 +5379,7 @@ static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, v
blendTransformedBilinear<qargb8565, qrgb565>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans,
@@ -5667,8 +5394,7 @@ static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans,
blendTransformedBilinear<qrgb565, qargb8565>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, void *userData)
@@ -5682,8 +5408,7 @@ static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, v
blendTransformedBilinear<qargb8555, qrgb555>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, void *userData)
@@ -5697,8 +5422,7 @@ static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, voi
blendTransformedBilinear<qrgb555, qrgb555>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, void *userData)
@@ -5712,8 +5436,7 @@ static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, v
blendTransformedBilinear<qargb4444, qrgb444>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_rgb444(int count, const QSpan *spans, void *userData)
@@ -5727,18 +5450,16 @@ static void blend_transformed_bilinear_rgb444(int count, const QSpan *spans, voi
blendTransformedBilinear<qrgb444, qrgb444>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
template <SpanMethod spanMethod>
-Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_tiled_argb(int count, const QSpan *spans, void *userData
- Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod))
+Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_tiled_argb(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format != QImage::Format_ARGB32_Premultiplied
&& data->texture.format != QImage::Format_RGB32) {
- blend_src_generic<spanMethod>(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, spanMethod));
+ blend_src_generic<spanMethod>(count, spans, userData);
return;
}
@@ -5924,13 +5645,12 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_tiled_argb(int count,
}
template <SpanMethod spanMethod>
-Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_argb(int count, const QSpan *spans, void *userData
- Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod))
+Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_argb(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format != QImage::Format_ARGB32_Premultiplied
&& data->texture.format != QImage::Format_RGB32) {
- blend_src_generic<spanMethod>(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, spanMethod));
+ blend_src_generic<spanMethod>(count, spans, userData);
return;
}
@@ -6052,8 +5772,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformed(int count, const QSpan *spans,
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode;
if (mode != QPainter::CompositionMode_SourceOver) {
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
return;
}
@@ -6202,8 +5921,7 @@ static void blend_transformed_rgb888(int count, const QSpan *spans,
blendTransformed<qrgb888, qrgb888>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_argb6666(int count, const QSpan *spans,
@@ -6218,8 +5936,7 @@ static void blend_transformed_argb6666(int count, const QSpan *spans,
blendTransformed<qargb6666, qrgb666>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_rgb666(int count, const QSpan *spans,
@@ -6234,8 +5951,7 @@ static void blend_transformed_rgb666(int count, const QSpan *spans,
blendTransformed<qrgb666, qrgb666>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_argb8565(int count, const QSpan *spans,
@@ -6250,8 +5966,7 @@ static void blend_transformed_argb8565(int count, const QSpan *spans,
blendTransformed<qargb8565, qrgb565>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_rgb565(int count, const QSpan *spans,
@@ -6266,8 +5981,7 @@ static void blend_transformed_rgb565(int count, const QSpan *spans,
blendTransformed<qrgb565, qrgb565>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_argb8555(int count, const QSpan *spans,
@@ -6282,8 +5996,7 @@ static void blend_transformed_argb8555(int count, const QSpan *spans,
blendTransformed<qargb8555, qrgb555>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_rgb555(int count, const QSpan *spans,
@@ -6298,8 +6011,7 @@ static void blend_transformed_rgb555(int count, const QSpan *spans,
blendTransformed<qrgb555, qrgb555>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_argb4444(int count, const QSpan *spans,
@@ -6314,8 +6026,7 @@ static void blend_transformed_argb4444(int count, const QSpan *spans,
blendTransformed<qargb4444, qrgb444>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_rgb444(int count, const QSpan *spans,
@@ -6330,18 +6041,16 @@ static void blend_transformed_rgb444(int count, const QSpan *spans,
blendTransformed<qrgb444, qrgb444>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
template <SpanMethod spanMethod>
-Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_tiled_argb(int count, const QSpan *spans, void *userData
- Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod))
+Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_tiled_argb(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format != QImage::Format_ARGB32_Premultiplied
&& data->texture.format != QImage::Format_RGB32) {
- blend_src_generic<spanMethod>(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, spanMethod));
+ blend_src_generic<spanMethod>(count, spans, userData);
return;
}
@@ -6475,8 +6184,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedTiled(int count, const QSpan *sp
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode;
if (mode != QPainter::CompositionMode_SourceOver) {
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
return;
}
@@ -6626,8 +6334,7 @@ static void blend_transformed_tiled_rgb888(int count, const QSpan *spans,
blendTransformedTiled<qrgb888, qrgb888>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_argb6666(int count, const QSpan *spans,
@@ -6642,8 +6349,7 @@ static void blend_transformed_tiled_argb6666(int count, const QSpan *spans,
blendTransformedTiled<qargb6666, qrgb666>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_rgb666(int count, const QSpan *spans,
@@ -6658,8 +6364,7 @@ static void blend_transformed_tiled_rgb666(int count, const QSpan *spans,
blendTransformedTiled<qrgb666, qrgb666>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_argb8565(int count, const QSpan *spans,
@@ -6674,8 +6379,7 @@ static void blend_transformed_tiled_argb8565(int count, const QSpan *spans,
blendTransformedTiled<qargb8565, qrgb565>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_rgb565(int count, const QSpan *spans,
@@ -6690,8 +6394,7 @@ static void blend_transformed_tiled_rgb565(int count, const QSpan *spans,
blendTransformedTiled<qrgb565, qrgb565>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_argb8555(int count, const QSpan *spans,
@@ -6706,8 +6409,7 @@ static void blend_transformed_tiled_argb8555(int count, const QSpan *spans,
blendTransformedTiled<qargb8555, qrgb555>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_rgb555(int count, const QSpan *spans,
@@ -6722,8 +6424,7 @@ static void blend_transformed_tiled_rgb555(int count, const QSpan *spans,
blendTransformedTiled<qrgb555, qrgb555>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_argb4444(int count, const QSpan *spans,
@@ -6738,8 +6439,7 @@ static void blend_transformed_tiled_argb4444(int count, const QSpan *spans,
blendTransformedTiled<qargb4444, qrgb444>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_rgb444(int count, const QSpan *spans,
@@ -6754,36 +6454,10 @@ static void blend_transformed_tiled_rgb444(int count, const QSpan *spans,
blendTransformedTiled<qrgb444, qrgb444>(count, spans, userData);
else
#endif
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
-#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL)
-
-// explicit template instantiations needed to compile with VC6 and VC2002
-
-#define SPANFUNC_INSTANTIATION(Name, Arg) \
-static inline void Name##_##Arg(int count, const QSpan *spans, void *userData) \
-{ \
- Name<Arg>(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, Arg)); \
-}
-
-SPANFUNC_INSTANTIATION(blend_untransformed_generic, RegularSpans);
-SPANFUNC_INSTANTIATION(blend_untransformed_argb, RegularSpans);
-SPANFUNC_INSTANTIATION(blend_tiled_generic, RegularSpans);
-SPANFUNC_INSTANTIATION(blend_tiled_argb, RegularSpans);
-SPANFUNC_INSTANTIATION(blend_src_generic, RegularSpans);
-SPANFUNC_INSTANTIATION(blend_transformed_argb, RegularSpans);
-SPANFUNC_INSTANTIATION(blend_transformed_tiled_argb, RegularSpans);
-SPANFUNC_INSTANTIATION(blend_transformed_bilinear_argb, RegularSpans);
-SPANFUNC_INSTANTIATION(blend_transformed_bilinear_tiled_argb, RegularSpans);
-#undef SPANFUNC_INSTANTIATION
-
-#define SPANFUNC_POINTER(Name, Arg) Name##_##Arg
-
-#else // !VC6 && !VC2002
# define SPANFUNC_POINTER(Name, Arg) Name<Arg>
-#endif
/* Image formats here are target formats */
@@ -7150,8 +6824,7 @@ static void qt_gradient_quint32(int count, const QSpan *spans, void *userData)
}
} else {
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
}
@@ -7199,8 +6872,7 @@ static void qt_gradient_quint16(int count, const QSpan *spans, void *userData)
data->solid.color = oldColor;
} else {
- blend_src_generic<RegularSpans>(count, spans, userData
- Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans));
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
}
@@ -7261,6 +6933,12 @@ static void qt_alphamapblit_quint16(QRasterBuffer *rasterBuffer,
void qt_build_pow_tables() {
qreal smoothing = 1.7;
+#ifdef Q_WS_MAC
+ // decided by testing a few things on an iMac, should probably get this from the
+ // system...
+ smoothing = 2.0;
+#endif
+
#ifdef Q_WS_WIN
int winSmooth;
if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0))
@@ -7405,7 +7083,7 @@ static void qt_alphamapblit_quint32(QRasterBuffer *rasterBuffer,
#endif
{
int ialpha = 255 - coverage;
- dest[i] = BYTE_MUL(c, uint(coverage)) + BYTE_MUL(dest[i], ialpha);
+ dest[i] = INTERPOLATE_PIXEL_255(c, coverage, dest[i], ialpha);
}
}
}
@@ -7446,7 +7124,7 @@ static void qt_alphamapblit_quint32(QRasterBuffer *rasterBuffer,
#endif
{
int ialpha = 255 - coverage;
- dest[xp] = BYTE_MUL(c, uint(coverage)) + BYTE_MUL(dest[xp], ialpha);
+ dest[xp] = INTERPOLATE_PIXEL_255(c, coverage, dest[xp], ialpha);
}
}
diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp
index 4439d52..31abcad 100644
--- a/src/gui/painting/qmatrix.cpp
+++ b/src/gui/painting/qmatrix.cpp
@@ -208,9 +208,13 @@ QT_BEGIN_NAMESPACE
*/
QMatrix::QMatrix()
+ : _m11(1.)
+ , _m12(0.)
+ , _m21(0.)
+ , _m22(1.)
+ , _dx(0.)
+ , _dy(0.)
{
- _m11 = _m22 = 1.0;
- _m12 = _m21 = _dx = _dy = 0.0;
}
/*!
@@ -220,12 +224,14 @@ QMatrix::QMatrix()
\sa setMatrix()
*/
-QMatrix::QMatrix(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy)
+QMatrix::QMatrix(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy)
+ : _m11(m11)
+ , _m12(m12)
+ , _m21(m21)
+ , _m22(m22)
+ , _dx(dx)
+ , _dy(dy)
{
- _m11 = m11; _m12 = m12;
- _m21 = m21; _m22 = m22;
- _dx = dx; _dy = dy;
}
@@ -233,8 +239,13 @@ QMatrix::QMatrix(qreal m11, qreal m12, qreal m21, qreal m22,
Constructs a matrix that is a copy of the given \a matrix.
*/
QMatrix::QMatrix(const QMatrix &matrix)
+ : _m11(matrix._m11)
+ , _m12(matrix._m12)
+ , _m21(matrix._m21)
+ , _m22(matrix._m22)
+ , _dx(matrix._dx)
+ , _dy(matrix._dy)
{
- *this = matrix;
}
/*!
@@ -249,12 +260,14 @@ QMatrix::QMatrix(const QMatrix &matrix)
\sa QMatrix()
*/
-void QMatrix::setMatrix(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy)
+void QMatrix::setMatrix(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy)
{
- _m11 = m11; _m12 = m12;
- _m21 = m21; _m22 = m22;
- _dx = dx; _dy = dy;
+ _m11 = m11;
+ _m12 = m12;
+ _m21 = m21;
+ _m22 = m22;
+ _dx = dx;
+ _dy = dy;
}
@@ -968,18 +981,17 @@ QMatrix QMatrix::inverted(bool *invertible) const
if (determinant == 0.0) {
if (invertible)
*invertible = false; // singular matrix
- QMatrix defaultMatrix;
- return defaultMatrix;
+ return QMatrix(true);
}
else { // invertible matrix
if (invertible)
*invertible = true;
qreal dinv = 1.0/determinant;
- QMatrix imatrix((_m22*dinv), (-_m12*dinv),
- (-_m21*dinv), (_m11*dinv),
- ((_m21*_dy - _m22*_dx)*dinv),
- ((_m12*_dx - _m11*_dy)*dinv));
- return imatrix;
+ return QMatrix((_m22*dinv), (-_m12*dinv),
+ (-_m21*dinv), (_m11*dinv),
+ ((_m21*_dy - _m22*_dx)*dinv),
+ ((_m12*_dx - _m11*_dy)*dinv),
+ true);
}
}
@@ -1054,9 +1066,14 @@ QMatrix &QMatrix::operator *=(const QMatrix &m)
QMatrix QMatrix::operator *(const QMatrix &m) const
{
- QMatrix result = *this;
- result *= m;
- return result;
+ qreal tm11 = _m11*m._m11 + _m12*m._m21;
+ qreal tm12 = _m11*m._m12 + _m12*m._m22;
+ qreal tm21 = _m21*m._m11 + _m22*m._m21;
+ qreal tm22 = _m21*m._m12 + _m22*m._m22;
+
+ qreal tdx = _dx*m._m11 + _dy*m._m21 + m._dx;
+ qreal tdy = _dx*m._m12 + _dy*m._m22 + m._dy;
+ return QMatrix(tm11, tm12, tm21, tm22, tdx, tdy, true);
}
/*!
diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h
index bf53c32..1e5fbb4 100644
--- a/src/gui/painting/qmatrix.h
+++ b/src/gui/painting/qmatrix.h
@@ -99,7 +99,7 @@ public:
QMatrix &shear(qreal sh, qreal sv);
QMatrix &rotate(qreal a);
- bool isInvertible() const { return !qFuzzyCompare(_m11*_m22 - _m12*_m21 + 1, 1); }
+ bool isInvertible() const { return !qFuzzyIsNull(_m11*_m22 - _m12*_m21); }
qreal det() const { return _m11*_m22 - _m12*_m21; }
QMatrix inverted(bool *invertible = 0) const;
@@ -121,6 +121,20 @@ public:
#endif
private:
+ inline QMatrix(bool)
+ : _m11(1.)
+ , _m12(0.)
+ , _m21(0.)
+ , _m22(1.)
+ , _dx(0.)
+ , _dy(0.) {}
+ inline QMatrix(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy, bool)
+ : _m11(m11)
+ , _m12(m12)
+ , _m21(m21)
+ , _m22(m22)
+ , _dx(dx)
+ , _dy(dy) {}
friend class QTransform;
qreal _m11, _m12;
qreal _m21, _m22;
@@ -147,8 +161,8 @@ Q_GUI_EXPORT QPainterPath operator *(const QPainterPath &p, const QMatrix &m);
inline bool QMatrix::isIdentity() const
{
- return qFuzzyCompare(_m11, 1) && qFuzzyCompare(_m22, 1) && qFuzzyCompare(_m12 + 1, 1)
- && qFuzzyCompare(_m21 + 1, 1) && qFuzzyCompare(_dx + 1, 1) && qFuzzyCompare(_dy + 1, 1);
+ return qFuzzyIsNull(_m11 - 1) && qFuzzyIsNull(_m22 - 1) && qFuzzyIsNull(_m12)
+ && qFuzzyIsNull(_m21) && qFuzzyIsNull(_dx) && qFuzzyIsNull(_dy);
}
/*****************************************************************************
diff --git a/src/gui/painting/qpaintengine_alpha.cpp b/src/gui/painting/qpaintengine_alpha.cpp
index e38f6a4..74cbebe 100644
--- a/src/gui/painting/qpaintengine_alpha.cpp
+++ b/src/gui/painting/qpaintengine_alpha.cpp
@@ -80,6 +80,7 @@ bool QAlphaPaintEngine::begin(QPaintDevice *pdev)
d->m_advancedPen = false;
d->m_advancedBrush = false;
d->m_complexTransform = false;
+ d->m_emulateProjectiveTransforms = false;
// clear alpha region
d->m_alphargn = QRegion();
@@ -116,6 +117,9 @@ void QAlphaPaintEngine::updateState(const QPaintEngineState &state)
if (flags & QPaintEngine::DirtyTransform) {
d->m_transform = state.transform();
d->m_complexTransform = (d->m_transform.type() > QTransform::TxScale);
+ d->m_emulateProjectiveTransforms = !(d->m_savedcaps & QPaintEngine::PerspectiveTransform)
+ && !(d->m_savedcaps & QPaintEngine::AlphaBlend)
+ && (d->m_transform.type() >= QTransform::TxProject);
}
if (flags & QPaintEngine::DirtyPen) {
d->m_pen = state.pen();
@@ -163,7 +167,9 @@ void QAlphaPaintEngine::drawPath(const QPainterPath &path)
if (d->m_pass == 0) {
d->m_continueCall = false;
- if (d->m_hasalpha || d->m_advancedPen || d->m_advancedBrush) {
+ if (d->m_hasalpha || d->m_advancedPen || d->m_advancedBrush
+ || d->m_emulateProjectiveTransforms)
+ {
d->addAlphaRect(tr);
}
if (d->m_picengine)
@@ -187,7 +193,9 @@ void QAlphaPaintEngine::drawPolygon(const QPointF *points, int pointCount, Polyg
if (d->m_pass == 0) {
d->m_continueCall = false;
- if (d->m_hasalpha || d->m_advancedPen || d->m_advancedBrush) {
+ if (d->m_hasalpha || d->m_advancedPen || d->m_advancedBrush
+ || d->m_emulateProjectiveTransforms)
+ {
d->addAlphaRect(tr);
}
diff --git a/src/gui/painting/qpaintengine_alpha_p.h b/src/gui/painting/qpaintengine_alpha_p.h
index f510c73..f7d7a34 100644
--- a/src/gui/painting/qpaintengine_alpha_p.h
+++ b/src/gui/painting/qpaintengine_alpha_p.h
@@ -113,6 +113,7 @@ public:
bool m_advancedPen;
bool m_advancedBrush;
bool m_complexTransform;
+ bool m_emulateProjectiveTransforms;
bool m_continueCall;
QTransform m_transform;
diff --git a/src/gui/painting/qpaintengine_d3d.cpp b/src/gui/painting/qpaintengine_d3d.cpp
index bb81623..9a7638b 100644
--- a/src/gui/painting/qpaintengine_d3d.cpp
+++ b/src/gui/painting/qpaintengine_d3d.cpp
@@ -2506,8 +2506,8 @@ void QD3DDrawHelper::addTrap(const Trapezoid &trap)
qreal _rightA = (qreal)_w/_h;
qreal _rightB = topRightX - _rightA * topRightY;
- qreal invLeftA = qFuzzyCompare(_leftA + 1, 1) ? 0.0 : 1.0 / _leftA;
- qreal invRightA = qFuzzyCompare(_rightA + 1, 1) ? 0.0 : 1.0 / _rightA;
+ qreal invLeftA = qFuzzyIsNull(_leftA) ? 0.0 : 1.0 / _leftA;
+ qreal invRightA = qFuzzyIsNull(_rightA) ? 0.0 : 1.0 / _rightA;
vertex v1 = { {1.f, top - 1.f, 0.5f}, 0.f,
top, bottom, invLeftA, -invRightA,
@@ -2970,7 +2970,7 @@ qreal calculateAngle(qreal dx, qreal dy)
{
qreal angle;
- if (qFuzzyCompare(dx + 1, 1)) {
+ if (qFuzzyIsNull(dx)) {
angle = (dy < 0) ? -M_PI/2 : M_PI/2;
} else {
angle = atanf(dy/dx);
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index ba79b5b..8e3d822 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -509,16 +509,20 @@ bool QRasterPaintEngine::begin(QPaintDevice *device)
if (d->mono_surface)
d->glyphCacheType = QFontEngineGlyphCache::Raster_Mono;
-#ifdef Q_WS_WIN
- else if (qt_cleartype_enabled) {
+#if defined(Q_WS_WIN)
+ else if (qt_cleartype_enabled)
+#elif defined (Q_WS_MAC)
+ else if (true)
+#else
+ else if (false)
+#endif
+ {
QImage::Format format = static_cast<QImage *>(d->device)->format();
if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32)
d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask;
else
d->glyphCacheType = QFontEngineGlyphCache::Raster_A8;
- }
-#endif
- else
+ } else
d->glyphCacheType = QFontEngineGlyphCache::Raster_A8;
setActive(true);
@@ -618,22 +622,22 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
d->isPlain45DegreeRotation = false;
if (txop >= QTransform::TxRotate) {
d->isPlain45DegreeRotation =
- (qFuzzyCompare(matrix.m11() + 1, qreal(1))
- && qFuzzyCompare(matrix.m12(), qreal(1))
- && qFuzzyCompare(matrix.m21(), qreal(-1))
- && qFuzzyCompare(matrix.m22() + 1, qreal(1))
+ (qFuzzyIsNull(matrix.m11())
+ && qFuzzyIsNull(matrix.m12() - qreal(1))
+ && qFuzzyIsNull(matrix.m21() + qreal(1))
+ && qFuzzyIsNull(matrix.m22())
)
||
- (qFuzzyCompare(matrix.m11(), qreal(-1))
- && qFuzzyCompare(matrix.m12() + 1, qreal(1))
- && qFuzzyCompare(matrix.m21() + 1, qreal(1))
- && qFuzzyCompare(matrix.m22(), qreal(-1))
+ (qFuzzyIsNull(matrix.m11() + qreal(1))
+ && qFuzzyIsNull(matrix.m12())
+ && qFuzzyIsNull(matrix.m21())
+ && qFuzzyIsNull(matrix.m22() + qreal(1))
)
||
- (qFuzzyCompare(matrix.m11() + 1, qreal(1))
- && qFuzzyCompare(matrix.m12(), qreal(-1))
- && qFuzzyCompare(matrix.m21(), qreal(1))
- && qFuzzyCompare(matrix.m22() + 1, qreal(1))
+ (qFuzzyIsNull(matrix.m11())
+ && qFuzzyIsNull(matrix.m12() + qreal(1))
+ && qFuzzyIsNull(matrix.m21() - qreal(1))
+ && qFuzzyIsNull(matrix.m22())
)
;
}
@@ -1529,7 +1533,7 @@ void QRasterPaintEngine::drawRects(const QRectF *rects, int rectCount)
d->initializeRasterizer(&s->brushData);
for (int i = 0; i < rectCount; ++i) {
const QRectF &rect = rects[i].normalized();
- if (rects[i].isEmpty())
+ if (rect.isEmpty())
continue;
const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f);
const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f);
@@ -2355,11 +2359,6 @@ void QRasterPaintEngine::strokePolygonCosmetic(const QPoint *points, int pointCo
}
}
-#define IMAGE_FROM_PIXMAP(pixmap) \
- pixmap.data->classId() == QPixmapData::RasterClass \
- ? ((QRasterPixmapData *) pixmap.data)->image \
- : pixmap.toImage()
-
/*!
\internal
*/
@@ -2368,16 +2367,33 @@ void QRasterPaintEngine::drawPixmap(const QPointF &pos, const QPixmap &pixmap)
#ifdef QT_DEBUG_DRAW
qDebug() << " - QRasterPaintEngine::drawPixmap(), pos=" << pos << " pixmap=" << pixmap.size() << "depth=" << pixmap.depth();
#endif
- if (pixmap.depth() == 1) {
- Q_D(QRasterPaintEngine);
- QRasterPaintEngineState *s = state();
- if (s->matrix.type() <= QTransform::TxTranslate) {
- drawBitmap(pos + QPointF(s->matrix.dx(), s->matrix.dy()), pixmap, &s->penData);
+
+ if (pixmap.data->classId() == QPixmapData::RasterClass) {
+ const QImage &image = ((QRasterPixmapData *) pixmap.data)->image;
+ if (image.depth() == 1) {
+ Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
+ if (s->matrix.type() <= QTransform::TxTranslate) {
+ drawBitmap(pos + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData);
+ } else {
+ drawImage(pos, d->rasterBuffer->colorizeBitmap(image, s->pen.color()));
+ }
} else {
- drawImage(pos, d->rasterBuffer->colorizeBitmap(IMAGE_FROM_PIXMAP(pixmap), s->pen.color()));
+ QRasterPaintEngine::drawImage(pos, image);
}
} else {
- QRasterPaintEngine::drawImage(pos, IMAGE_FROM_PIXMAP(pixmap));
+ const QImage image = pixmap.toImage();
+ if (pixmap.depth() == 1) {
+ Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
+ if (s->matrix.type() <= QTransform::TxTranslate) {
+ drawBitmap(pos + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData);
+ } else {
+ drawImage(pos, d->rasterBuffer->colorizeBitmap(image, s->pen.color()));
+ }
+ } else {
+ QRasterPaintEngine::drawImage(pos, image);
+ }
}
}
@@ -2390,22 +2406,40 @@ void QRasterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, cons
qDebug() << " - QRasterPaintEngine::drawPixmap(), r=" << r << " sr=" << sr << " pixmap=" << pixmap.size() << "depth=" << pixmap.depth();
#endif
- Q_D(QRasterPaintEngine);
- QRasterPaintEngineState *s = state();
-
- if (pixmap.depth() == 1) {
- if (s->matrix.type() <= QTransform::TxTranslate
- && r.size() == sr.size()
- && r.size() == pixmap.size()) {
- ensurePen();
- drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), pixmap, &s->penData);
- return;
+ if (pixmap.data->classId() == QPixmapData::RasterClass) {
+ const QImage &image = ((QRasterPixmapData *) pixmap.data)->image;
+ if (image.depth() == 1) {
+ Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
+ if (s->matrix.type() <= QTransform::TxTranslate
+ && r.size() == sr.size()
+ && r.size() == pixmap.size()) {
+ ensurePen();
+ drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData);
+ return;
+ } else {
+ drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), sr);
+ }
} else {
- drawImage(r, d->rasterBuffer->colorizeBitmap(IMAGE_FROM_PIXMAP(pixmap),
- s->pen.color()), sr);
+ drawImage(r, image, sr);
}
} else {
- drawImage(r, IMAGE_FROM_PIXMAP(pixmap), sr);
+ const QImage image = pixmap.toImage();
+ if (image.depth() == 1) {
+ Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
+ if (s->matrix.type() <= QTransform::TxTranslate
+ && r.size() == sr.size()
+ && r.size() == pixmap.size()) {
+ ensurePen();
+ drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData);
+ return;
+ } else {
+ drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), sr);
+ }
+ } else {
+ drawImage(r, image, sr);
+ }
}
}
@@ -2614,10 +2648,15 @@ void QRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap,
QRasterPaintEngineState *s = state();
QImage image;
- if (pixmap.depth() == 1)
- image = d->rasterBuffer->colorizeBitmap(IMAGE_FROM_PIXMAP(pixmap), s->pen.color());
- else
- image = IMAGE_FROM_PIXMAP(pixmap);
+
+ if (pixmap.data->classId() == QPixmapData::RasterClass) {
+ image = ((QRasterPixmapData *) pixmap.data)->image;
+ } else {
+ image = pixmap.toImage();
+ }
+
+ if (image.depth() == 1)
+ image = d->rasterBuffer->colorizeBitmap(image, s->pen.color());
if (s->matrix.type() > QTransform::TxTranslate) {
QTransform copy = s->matrix;
@@ -3650,14 +3689,13 @@ void QRasterPaintEngine::drawBufferSpan(const uint *buffer, int bufsize,
}
#endif // Q_WS_QWS
-void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QPixmap &pm, QSpanData *fg)
+void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fg)
{
Q_ASSERT(fg);
if (!fg->blend)
return;
Q_D(QRasterPaintEngine);
- const QImage image = IMAGE_FROM_PIXMAP(pm);
Q_ASSERT(image.depth() == 1);
const int spanCount = 256;
@@ -3665,8 +3703,8 @@ void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QPixmap &pm, QSpan
int n = 0;
// Boundaries
- int w = pm.width();
- int h = pm.height();
+ int w = image.width();
+ int h = image.height();
int ymax = qMin(qRound(pos.y() + h), d->rasterBuffer->height());
int ymin = qMax(qRound(pos.y()), 0);
int xmax = qMin(qRound(pos.x() + w), d->rasterBuffer->width());
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index 0f8060a..26a2b3f 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -256,7 +256,7 @@ private:
void init();
void fillRect(const QRectF &rect, QSpanData *data);
- void drawBitmap(const QPointF &pos, const QPixmap &image, QSpanData *fill);
+ void drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fill);
void drawCachedGlyphs(const QPointF &p, const QTextItemInt &ti);
diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp
index e9f1bb3..39ce59f 100644
--- a/src/gui/painting/qpaintengine_x11.cpp
+++ b/src/gui/painting/qpaintengine_x11.cpp
@@ -62,6 +62,7 @@
#include <private/qpaintengine_x11_p.h>
#include <private/qfontengine_x11_p.h>
#include <private/qwidget_p.h>
+#include <private/qpainterpath_p.h>
#include "qpen.h"
#include "qcolor.h"
@@ -1479,14 +1480,10 @@ void QX11PaintEngine::drawEllipse(const QRect &rect)
return;
}
d->setupAdaptedOrigin(rect.topLeft());
- if (d->has_brush) { // draw filled ellipse
- if (!d->has_pen) {
- XFillArc(d->dpy, d->hd, d->gc_brush, x, y, w-1, h-1, 0, 360*64);
+ if (d->has_brush) { // draw filled ellipse
+ XFillArc(d->dpy, d->hd, d->gc_brush, x, y, w, h, 0, 360*64);
+ if (!d->has_pen) // make smoother outline
XDrawArc(d->dpy, d->hd, d->gc_brush, x, y, w-1, h-1, 0, 360*64);
- return;
- } else{
- XFillArc(d->dpy, d->hd, d->gc_brush, x, y, w, h, 0, 360*64);
- }
}
if (d->has_pen) // draw outline
XDrawArc(d->dpy, d->hd, d->gc, x, y, w, h, 0, 360*64);
@@ -1760,9 +1757,14 @@ void QX11PaintEngine::drawPath(const QPainterPath &path)
QPainterPath stroke;
qreal width = d->cpen.widthF();
QPolygonF poly;
+ QRectF deviceRect(0, 0, d->pdev->width(), d->pdev->height());
// necessary to get aliased alphablended primitives to be drawn correctly
if (d->cpen.isCosmetic() || d->has_scaling_xform) {
- stroker.setWidth(width == 0 ? 1 : width * d->xform_scale);
+ if (d->cpen.isCosmetic())
+ stroker.setWidth(width == 0 ? 1 : width);
+ else
+ stroker.setWidth(width * d->xform_scale);
+ stroker.d_ptr->stroker.setClipRect(deviceRect);
stroke = stroker.createStroke(path * d->matrix);
if (stroke.isEmpty())
return;
@@ -1770,6 +1772,7 @@ void QX11PaintEngine::drawPath(const QPainterPath &path)
d->fillPath(stroke, QX11PaintEnginePrivate::PenGC, false);
} else {
stroker.setWidth(width);
+ stroker.d_ptr->stroker.setClipRect(d->matrix.inverted().mapRect(deviceRect));
stroke = stroker.createStroke(path);
if (stroke.isEmpty())
return;
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index e2d9b32..82c22c2 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -1293,7 +1293,7 @@ void QPainterPrivate::updateState(QPainterState *newState)
destination.
Note that composition transformation operates pixelwise. For that
- reason, there is a difference between using the grahic primitive
+ reason, there is a difference between using the graphic primitive
itself and its bounding rectangle: The bounding rect contains
pixels with alpha == 0 (i.e the pixels surrounding the
primitive). These pixels will overwrite the other image's pixels,
@@ -1465,8 +1465,8 @@ bool QPainter::isActive() const
/*!
Initializes the painters pen, background and font to the same as
- the given \a widget. Call this function after begin() while the
- painter is active.
+ the given \a widget. This function is called automatically when the
+ painter is opened on a QWidget.
\sa begin(), {QPainter#Settings}{Settings}
*/
@@ -2371,6 +2371,11 @@ void QPainter::setClipping(bool enable)
Returns the currently set clip region. Note that the clip region
is given in logical coordinates.
+ \warning QPainter does not store the combined clip explicitly as
+ this is handled by the underlying QPaintEngine, so the path is
+ recreated on demand and transformed to the current logical
+ coordinate system. This is potentially an expensive operation.
+
\sa setClipRegion(), clipPath(), setClipping()
*/
@@ -2486,6 +2491,11 @@ extern QPainterPath qt_regionToPath(const QRegion &region);
Returns the currently clip as a path. Note that the clip path is
given in logical coordinates.
+ \warning QPainter does not store the combined clip explicitly as
+ this is handled by the underlying QPaintEngine, so the path is
+ recreated on demand and transformed to the current logical
+ coordinate system. This is potentially an expensive operation.
+
\sa setClipPath(), clipRegion(), setClipping()
*/
QPainterPath QPainter::clipPath() const
@@ -5155,9 +5165,6 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm)
Q_D(QPainter);
- if (!d->engine || pm.isNull())
- return;
-
#ifndef QT_NO_DEBUG
qt_painter_thread_test(d->device->devType(), "drawPixmap()");
#endif
@@ -5167,12 +5174,18 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm)
return;
}
+ if (!d->engine)
+ return;
+
qreal x = p.x();
qreal y = p.y();
int w = pm.width();
int h = pm.height();
+ if (w <= 0)
+ return;
+
// Emulate opaque background for bitmaps
if (d->state->bgMode == Qt::OpaqueMode && pm.isQBitmap()) {
fillRect(QRectF(x, y, w, h), d->state->bgBrush.color());
@@ -6042,22 +6055,22 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti)
const QTransform &m = d->state->matrix;
if (d->state->matrix.type() < QTransform::TxShear) {
bool isPlain90DegreeRotation =
- (qFuzzyCompare(m.m11() + 1, qreal(1))
- && qFuzzyCompare(m.m12(), qreal(1))
- && qFuzzyCompare(m.m21(), qreal(-1))
- && qFuzzyCompare(m.m22() + 1, qreal(1))
+ (qFuzzyIsNull(m.m11())
+ && qFuzzyIsNull(m.m12() - qreal(1))
+ && qFuzzyIsNull(m.m21() + qreal(1))
+ && qFuzzyIsNull(m.m22())
)
||
- (qFuzzyCompare(m.m11(), qreal(-1))
- && qFuzzyCompare(m.m12() + 1, qreal(1))
- && qFuzzyCompare(m.m21() + 1, qreal(1))
- && qFuzzyCompare(m.m22(), qreal(-1))
+ (qFuzzyIsNull(m.m11() + qreal(1))
+ && qFuzzyIsNull(m.m12())
+ && qFuzzyIsNull(m.m21())
+ && qFuzzyIsNull(m.m22() + qreal(1))
)
||
- (qFuzzyCompare(m.m11() + 1, qreal(1))
- && qFuzzyCompare(m.m12(), qreal(-1))
- && qFuzzyCompare(m.m21(), qreal(1))
- && qFuzzyCompare(m.m22() + 1, qreal(1))
+ (qFuzzyIsNull(m.m11())
+ && qFuzzyIsNull(m.m12() + qreal(1))
+ && qFuzzyIsNull(m.m21() - qreal(1))
+ && qFuzzyIsNull(m.m22())
)
;
aa = !isPlain90DegreeRotation;
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index 0d985c3..d471aaa 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -1299,10 +1299,10 @@ static QRectF qt_painterpath_bezier_extrema(const QBezier &b)
qreal bx = QT_BEZIER_B(b, x);
qreal cx = QT_BEZIER_C(b, x);
// specialcase quadratic curves to avoid div by zero
- if (qFuzzyCompare(ax + 1, 1)) {
+ if (qFuzzyIsNull(ax)) {
// linear curves are covered by initialization.
- if (!qFuzzyCompare(bx + 1, 1)) {
+ if (!qFuzzyIsNull(bx)) {
qreal t = -cx / bx;
QT_BEZIER_CHECK_T(b, t);
}
@@ -1329,10 +1329,10 @@ static QRectF qt_painterpath_bezier_extrema(const QBezier &b)
qreal cy = QT_BEZIER_C(b, y);
// specialcase quadratic curves to avoid div by zero
- if (qFuzzyCompare(ay + 1, 1)) {
+ if (qFuzzyIsNull(ay)) {
// linear curves are covered by initialization.
- if (!qFuzzyCompare(by + 1, 1)) {
+ if (!qFuzzyIsNull(by)) {
qreal t = -cy / by;
QT_BEZIER_CHECK_T(b, t);
}
@@ -1725,7 +1725,7 @@ static void qt_painterpath_isect_curve(const QBezier &bezier, const QPointF &pt,
*/
bool QPainterPath::contains(const QPointF &pt) const
{
- if (isEmpty())
+ if (isEmpty() || !controlPointRect().contains(pt))
return false;
QPainterPathData *d = d_func();
@@ -2443,21 +2443,13 @@ void qt_path_stroke_cubic_to(qfixed c1x, qfixed c1y,
\sa QPen, QBrush
*/
-class QPainterPathStrokerPrivate
+QPainterPathStrokerPrivate::QPainterPathStrokerPrivate()
+ : dashOffset(0)
{
-public:
- QPainterPathStrokerPrivate()
- : dashOffset(0)
- {
- stroker.setMoveToHook(qt_path_stroke_move_to);
- stroker.setLineToHook(qt_path_stroke_line_to);
- stroker.setCubicToHook(qt_path_stroke_cubic_to);
- }
-
- QStroker stroker;
- QVector<qfixed> dashPattern;
- qreal dashOffset;
-};
+ stroker.setMoveToHook(qt_path_stroke_move_to);
+ stroker.setLineToHook(qt_path_stroke_line_to);
+ stroker.setCubicToHook(qt_path_stroke_cubic_to);
+}
/*!
Creates a new stroker.
@@ -2501,6 +2493,7 @@ QPainterPath QPainterPathStroker::createStroke(const QPainterPath &path) const
QDashStroker dashStroker(&d->stroker);
dashStroker.setDashPattern(d->dashPattern);
dashStroker.setDashOffset(d->dashOffset);
+ dashStroker.setClipRect(d->stroker.clipRect());
dashStroker.strokePath(path, &stroke, QTransform());
}
stroke.setFillRule(Qt::WindingFill);
diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h
index 56d783d..e343a28 100644
--- a/src/gui/painting/qpainterpath.h
+++ b/src/gui/painting/qpainterpath.h
@@ -283,6 +283,8 @@ public:
QPainterPath createStroke(const QPainterPath &path) const;
private:
+ friend class QX11PaintEngine;
+
QPainterPathStrokerPrivate *d_ptr;
};
diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h
index 93f9704..29c48df 100644
--- a/src/gui/painting/qpainterpath_p.h
+++ b/src/gui/painting/qpainterpath_p.h
@@ -61,9 +61,20 @@
#include <qdebug.h>
#include <private/qvectorpath_p.h>
+#include <private/qstroker_p.h>
QT_BEGIN_NAMESPACE
+class QPainterPathStrokerPrivate
+{
+public:
+ QPainterPathStrokerPrivate();
+
+ QStroker stroker;
+ QVector<qfixed> dashPattern;
+ qreal dashOffset;
+};
+
class QPolygonF;
class QVectorPathConverter;
diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp
index 297cdd3..9ef3eb7 100644
--- a/src/gui/painting/qpathclipper.cpp
+++ b/src/gui/painting/qpathclipper.cpp
@@ -138,11 +138,11 @@ bool QIntersectionFinder::linesIntersect(const QLineF &a, const QLineF &b) const
const qreal par = pDelta.x() * qDelta.y() - pDelta.y() * qDelta.x();
- if (qFuzzyCompare(par + 1, 1)) {
+ if (qFuzzyIsNull(par)) {
const QPointF normal(-pDelta.y(), pDelta.x());
// coinciding?
- if (qFuzzyCompare(dot(normal, q1 - p1) + 1, 1)) {
+ if (qFuzzyIsNull(dot(normal, q1 - p1))) {
const qreal dp = dot(pDelta, pDelta);
const qreal tq1 = dot(pDelta, q1 - p1);
@@ -202,13 +202,13 @@ void QIntersectionFinder::intersectBeziers(const QBezier &one, const QBezier &tw
qreal alpha_q = t.at(i).second;
QPointF pt;
- if (qFuzzyCompare(alpha_p + 1, 1)) {
+ if (qFuzzyIsNull(alpha_p)) {
pt = one.pt1();
- } else if (qFuzzyCompare(alpha_p, 1)) {
+ } else if (qFuzzyIsNull(alpha_p - 1)) {
pt = one.pt4();
- } else if (qFuzzyCompare(alpha_q + 1, 1)) {
+ } else if (qFuzzyIsNull(alpha_q)) {
pt = two.pt1();
- } else if (qFuzzyCompare(alpha_q, 1)) {
+ } else if (qFuzzyIsNull(alpha_q - 1)) {
pt = two.pt4();
} else {
pt = one.pointAt(alpha_p);
@@ -250,11 +250,11 @@ void QIntersectionFinder::intersectLines(const QLineF &a, const QLineF &b, QData
const qreal par = pDelta.x() * qDelta.y() - pDelta.y() * qDelta.x();
- if (qFuzzyCompare(par + 1, 1)) {
+ if (qFuzzyIsNull(par)) {
const QPointF normal(-pDelta.y(), pDelta.x());
// coinciding?
- if (qFuzzyCompare(dot(normal, q1 - p1) + 1, 1)) {
+ if (qFuzzyIsNull(dot(normal, q1 - p1))) {
const qreal invDp = 1 / dot(pDelta, pDelta);
const qreal tq1 = dot(pDelta, q1 - p1) * invDp;
@@ -315,11 +315,11 @@ void QIntersectionFinder::intersectLines(const QLineF &a, const QLineF &b, QData
if (tp<0 || tp>1 || tq<0 || tq>1)
return;
- const bool p_zero = qFuzzyCompare(tp + 1, 1);
- const bool p_one = qFuzzyCompare(tp, 1);
+ const bool p_zero = qFuzzyIsNull(tp);
+ const bool p_one = qFuzzyIsNull(tp - 1);
- const bool q_zero = qFuzzyCompare(tq + 1, 1);
- const bool q_one = qFuzzyCompare(tq, 1);
+ const bool q_zero = qFuzzyIsNull(tq);
+ const bool q_one = qFuzzyIsNull(tq - 1);
if ((q_zero || q_one) && (p_zero || p_one))
return;
@@ -922,7 +922,7 @@ qreal QWingedEdge::delta(int vertex, int a, int b) const
qreal result = b_angle - a_angle;
- if (qFuzzyCompare(result + 1, 1) || qFuzzyCompare(result, 128))
+ if (qFuzzyIsNull(result) || qFuzzyCompare(result, 128))
return 0;
if (result < 0)
@@ -951,7 +951,7 @@ static inline QPointF tangentAt(const QWingedEdge &list, int vi, int ei)
if (ep->bezier) {
normal = ep->bezier->derivedAt(t);
- if (qFuzzyCompare(normal.x() + 1, 1) && qFuzzyCompare(normal.y() + 1, 1))
+ if (qFuzzyIsNull(normal.x()) && qFuzzyIsNull(normal.y()))
normal = ep->bezier->secondDerivedAt(t);
} else {
const QPointF a = *list.vertex(ep->first);
@@ -1080,7 +1080,7 @@ QWingedEdge::TraversalStatus QWingedEdge::findInsertStatus(int vi, int ei) const
qDebug() << "Delta to edge" << status.edge << d2 << ", angles: " << op->angle << op->invAngle;
#endif
- if (!(qFuzzyCompare(d2 + 1, 1) && isLeftOf(*this, vi, status.edge, ei))
+ if (!(qFuzzyIsNull(d2) && isLeftOf(*this, vi, status.edge, ei))
&& (d2 < d || (qFuzzyCompare(d2, d) && isLeftOf(*this, vi, status.edge, position)))) {
position = status.edge;
d = d2;
@@ -1232,10 +1232,10 @@ int QWingedEdge::addEdge(int fi, int si, const QBezier *bezier, qreal t0, qreal
QPointF aTangent = bezier->derivedAt(t0);
QPointF bTangent = -bezier->derivedAt(t1);
- if (qFuzzyCompare(aTangent.x() + 1, 1) && qFuzzyCompare(aTangent.y() + 1, 1))
+ if (qFuzzyIsNull(aTangent.x()) && qFuzzyIsNull(aTangent.y()))
aTangent = bezier->secondDerivedAt(t0);
- if (qFuzzyCompare(bTangent.x() + 1, 1) && qFuzzyCompare(bTangent.y() + 1, 1))
+ if (qFuzzyIsNull(bTangent.x()) && qFuzzyIsNull(bTangent.y()))
bTangent = bezier->secondDerivedAt(t1);
ep->angle = computeAngle(aTangent);
@@ -1400,7 +1400,7 @@ static void addLineTo(QPainterPath &path, const QPointF &point)
const QPointF p(-d1.y(), d1.x());
- if (qFuzzyCompare(dot(p, d2) + 1, 1)) {
+ if (qFuzzyIsNull(dot(p, d2))) {
path.setElementPositionAt(elementCount - 1, point.x(), point.y());
return;
}
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index b010209..55006f6 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1106,6 +1106,11 @@ void QPdfBaseEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
if (!d->hasPen || (d->clipEnabled && d->allClipped))
return;
+ if (d->stroker.matrix.type() >= QTransform::TxProject) {
+ QPaintEngine::drawTextItem(p, textItem);
+ return;
+ }
+
*d->currentPage << "q\n";
if(!d->simplePen)
*d->currentPage << QPdf::generateMatrix(d->stroker.matrix);
diff --git a/src/gui/painting/qprintengine_mac.mm b/src/gui/painting/qprintengine_mac.mm
index 7a77e47..b1216b7 100644
--- a/src/gui/painting/qprintengine_mac.mm
+++ b/src/gui/painting/qprintengine_mac.mm
@@ -62,6 +62,10 @@ bool QMacPrintEngine::begin(QPaintDevice *dev)
{
Q_D(QMacPrintEngine);
+ Q_ASSERT(dev && dev->devType() == QInternal::Printer);
+ if (!static_cast<QPrinter *>(dev)->isValid())
+ return false;
+
if (d->state == QPrinter::Idle && !d->isPrintSessionInitialized()) // Need to reinitialize
d->initialize();
@@ -121,24 +125,8 @@ bool QMacPrintEngine::end()
if(d->paintEngine->type() == QPaintEngine::CoreGraphics)
static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->hd = 0;
d->paintEngine->end();
- if (d->state != QPrinter::Idle) {
-#ifndef QT_MAC_USE_COCOA
- if (d->shouldSuppressStatus()) {
- PMSessionEndPageNoDialog(d->session);
- PMSessionEndDocumentNoDialog(d->session);
- } else {
- PMSessionEndPage(d->session);
- PMSessionEndDocument(d->session);
- }
- PMRelease(d->session);
-#else
- PMSessionEndPageNoDialog(d->session);
- PMSessionEndDocumentNoDialog(d->session);
- [d->printInfo release];
-#endif
- d->printInfo = 0;
- d->session = 0;
- }
+ if (d->state != QPrinter::Idle)
+ d->releaseSession();
d->state = QPrinter::Idle;
return true;
}
@@ -509,6 +497,26 @@ void QMacPrintEnginePrivate::initialize()
}
}
+void QMacPrintEnginePrivate::releaseSession()
+{
+#ifndef QT_MAC_USE_COCOA
+ if (shouldSuppressStatus()) {
+ PMSessionEndPageNoDialog(session);
+ PMSessionEndDocumentNoDialog(session);
+ } else {
+ PMSessionEndPage(session);
+ PMSessionEndDocument(session);
+ }
+ PMRelease(session);
+#else
+ PMSessionEndPageNoDialog(session);
+ PMSessionEndDocumentNoDialog(session);
+ [printInfo release];
+#endif
+ printInfo = 0;
+ session = 0;
+}
+
bool QMacPrintEnginePrivate::newPage_helper()
{
Q_Q(QMacPrintEngine);
@@ -737,6 +745,7 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
d->setPaperSize(QPrinter::PaperSize(value.toInt()));
break;
case PPK_PrinterName: {
+ bool printerNameSet = false;
OSStatus status = noErr;
QCFType<CFArrayRef> printerList;
status = PMServerCreatePrinterList(kPMServerLocal, &printerList);
@@ -747,12 +756,18 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
QString name = QCFString::toQString(PMPrinterGetName(printer));
if (name == value.toString()) {
status = PMSessionSetCurrentPMPrinter(d->session, printer);
+ printerNameSet = true;
break;
}
}
}
if (status != noErr)
qWarning("QMacPrintEngine::setPrinterName: Error setting printer: %ld", long(status));
+ if (!printerNameSet) {
+ qWarning("QMacPrintEngine::setPrinterName: Failed to set printer named '%s'.", qPrintable(value.toString()));
+ d->releaseSession();
+ d->state = QPrinter::Idle;
+ }
break; }
case PPK_SuppressSystemPrintStatus:
d->suppressStatus = value.toBool();
@@ -876,17 +891,12 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
ret = r;
break; }
case PPK_PrinterName: {
- CFIndex currIndex;
- PMPrinter unused;
- QCFType<CFArrayRef> printerList;
- OSStatus status = PMSessionCreatePrinterList(d->session, &printerList, &currIndex, &unused);
+ PMPrinter printer;
+ OSStatus status = PMSessionGetCurrentPrinter(d->session, &printer);
if (status != noErr)
- qWarning("QMacPrintEngine::printerName: Problem getting list of printers: %ld", long(status));
- if (currIndex != -1 && printerList && currIndex < CFArrayGetCount(printerList)) {
- const CFStringRef name = static_cast<CFStringRef>(CFArrayGetValueAtIndex(printerList, currIndex));
- if (name)
- ret = QCFString::toQString(name);
- }
+ qWarning("QMacPrintEngine::printerName: Failed getting current PMPrinter: %ld", long(status));
+ if (printer)
+ ret = QCFString::toQString(PMPrinterGetName(printer));
break; }
case PPK_Resolution: {
ret = d->resolution.hRes;
diff --git a/src/gui/painting/qprintengine_mac_p.h b/src/gui/painting/qprintengine_mac_p.h
index 5e18845..bc917e7 100644
--- a/src/gui/painting/qprintengine_mac_p.h
+++ b/src/gui/painting/qprintengine_mac_p.h
@@ -143,6 +143,7 @@ public:
hasCustomPaperSize(false), hasCustomPageMargins(false) {}
~QMacPrintEnginePrivate();
void initialize();
+ void releaseSession();
bool newPage_helper();
void setPaperSize(QPrinter::PaperSize ps);
QPrinter::PaperSize paperSize() const;
diff --git a/src/gui/painting/qprintengine_win.cpp b/src/gui/painting/qprintengine_win.cpp
index d48b525..c8674b7 100644
--- a/src/gui/painting/qprintengine_win.cpp
+++ b/src/gui/painting/qprintengine_win.cpp
@@ -369,7 +369,7 @@ void QWin32PrintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem
QRgb brushColor = state->pen().brush().color().rgb();
bool fallBack = state->pen().brush().style() != Qt::SolidPattern
|| qAlpha(brushColor) != 0xff
- || QT_WA_INLINE(false, d->txop >= QTransform::TxScale)
+ || QT_WA_INLINE(d->txop >= QTransform::TxProject, d->txop >= QTransform::TxScale)
|| ti.fontEngine->type() != QFontEngine::Win;
diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp
index 413f4a1..4f3e71c 100644
--- a/src/gui/painting/qprinter.cpp
+++ b/src/gui/painting/qprinter.cpp
@@ -284,6 +284,10 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke
to send PostScript or PDF output to the printer. As an alternative,
the printProgram() function can be used to specify the command or utility
to use instead of the system default.
+
+ Note that setting parameters like paper size and resolution on an
+ invalid printer is undefined. You can use QPrinter::isValid() to
+ verify this before changing any parameters.
QPrinter supports a number of parameters, most of which can be
changed by the end user through a \l{QPrintDialog}{print dialog}. In
@@ -849,7 +853,7 @@ void QPrinter::setPrinterName(const QString &name)
Returns true if the printer currently selected is a valid printer
in the system, or a pure PDF/PostScript printer; otherwise returns false.
- To detect other failures check the output of QPainter::begin() or QPainter::nextPage().
+ To detect other failures check the output of QPainter::begin() or QPrinter::newPage().
\snippet doc/src/snippets/printing-qprinter/errors.cpp 0
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index 8169ef8..c88af7c 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -65,9 +65,17 @@ QT_BEGIN_NAMESPACE
\ingroup shared
QRegion is used with QPainter::setClipRegion() to limit the paint
- area to what needs to be painted. There is also a
- QWidget::repaint() function that takes a QRegion parameter.
- QRegion is the best tool for reducing flicker.
+ area to what needs to be painted. There is also a QWidget::repaint()
+ function that takes a QRegion parameter. QRegion is the best tool for
+ minimizing the amount of screen area to be updated by a repaint.
+
+ This class is not suitable for constructing shapes for rendering, especially
+ as outlines. Use QPainterPath to create paths and shapes for use with
+ QPainter.
+
+ QRegion is an \l{implicitly shared} class.
+
+ \section1 Creating and Using Regions
A region can be created from a rectangle, an ellipse, a polygon or
a bitmap. Complex regions may be created by combining simple
@@ -84,8 +92,6 @@ QT_BEGIN_NAMESPACE
Example of using complex regions:
\snippet doc/src/snippets/code/src_gui_painting_qregion.cpp 0
- QRegion is an \l{implicitly shared} class.
-
\warning Due to window system limitations, the whole coordinate space for a
region is limited to the points between -32767 and 32767 on Windows
95/98/ME. You can circumvent this limitation by using a QPainterPath.
@@ -93,7 +99,7 @@ QT_BEGIN_NAMESPACE
\section1 Additional License Information
On Embedded Linux, Windows CE and X11 platforms, parts of this class rely on
- code obtained under the following license:
+ code obtained under the following licenses:
\legalese
Copyright (c) 1987 X Consortium
@@ -120,9 +126,7 @@ QT_BEGIN_NAMESPACE
in this Software without prior written authorization from the X Consortium.
\endlegalese
- \raw HTML
- <hr />
- \endraw
+ \br
\legalese
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp
index b894c62..5fffc72 100644
--- a/src/gui/painting/qstroker.cpp
+++ b/src/gui/painting/qstroker.cpp
@@ -763,7 +763,7 @@ template <class Iterator> bool qt_stroke_side(Iterator *it,
qreal qt_t_for_arc_angle(qreal angle)
{
- if (qFuzzyCompare(angle + 1, qreal(1)))
+ if (qFuzzyIsNull(angle))
return 0;
if (qFuzzyCompare(angle, qreal(90)))
@@ -904,13 +904,13 @@ QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLengt
}
// avoid empty start segment
- if (qFuzzyCompare(startT, qreal(1))) {
+ if (qFuzzyIsNull(startT - qreal(1))) {
startT = 0;
startSegment += delta;
}
// avoid empty end segment
- if (qFuzzyCompare(endT + 1, qreal(1))) {
+ if (qFuzzyIsNull(endT)) {
endT = 1;
endSegment -= delta;
}
@@ -918,8 +918,8 @@ QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLengt
startT = qt_t_for_arc_angle(startT * 90);
endT = qt_t_for_arc_angle(endT * 90);
- const bool splitAtStart = !qFuzzyCompare(startT + 1, qreal(1));
- const bool splitAtEnd = !qFuzzyCompare(endT, qreal(1));
+ const bool splitAtStart = !qFuzzyIsNull(startT);
+ const bool splitAtEnd = !qFuzzyIsNull(endT - qreal(1));
const int end = endSegment + delta;
@@ -1018,7 +1018,7 @@ void QDashStroker::processCurrentSubpath()
sumLength += dashes[i];
}
- if (qFuzzyCompare(sumLength + 1, qreal(1)))
+ if (qFuzzyIsNull(sumLength))
return;
Q_ASSERT(dashCount > 0);
diff --git a/src/gui/painting/qtessellator.cpp b/src/gui/painting/qtessellator.cpp
index e02f02d..ce5ab74 100644
--- a/src/gui/painting/qtessellator.cpp
+++ b/src/gui/painting/qtessellator.cpp
@@ -1436,7 +1436,7 @@ void QTessellator::tessellateRect(const QPointF &a_, const QPointF &b_, qreal wi
QPointF perp(pb.y() - pa.y(), pa.x() - pb.x());
qreal length = qSqrt(perp.x() * perp.x() + perp.y() * perp.y());
- if (qFuzzyCompare(length + 1, static_cast<qreal>(1)))
+ if (qFuzzyIsNull(length))
return;
// need the half of the width
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index 39b3319..d06107f 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -168,10 +168,10 @@ QT_BEGIN_NAMESPACE
\image qtransform-representation.png
- A QTransform object contains a 3 x 3 matrix. The \c dx and \c dy
- elements specify horizontal and vertical translation. The \c m11
- and \c m22 elements specify horizontal and vertical scaling. The
- \c m21 and \c m12 elements specify horizontal and vertical \e shearing.
+ A QTransform object contains a 3 x 3 matrix. The \c m31 (\c dx) and
+ \c m32 (\c dy) elements specify horizontal and vertical translation.
+ The \c m11 and \c m22 elements specify horizontal and vertical scaling.
+ The \c m21 and \c m12 elements specify horizontal and vertical \e shearing.
And finally, the \c m13 and \c m23 elements specify horizontal and vertical
projection, with \c m33 as an additional projection factor.
@@ -238,44 +238,45 @@ QT_BEGIN_NAMESPACE
\sa reset()
*/
QTransform::QTransform()
- : m_13(0), m_23(0), m_33(1)
+ : affine(true)
+ , m_13(0), m_23(0), m_33(1)
, m_type(TxNone)
, m_dirty(TxNone)
{
-
}
/*!
- Constructs a matrix with the elements, \a h11, \a h12, \a h13,
- \a h21, \a h22, \a h23, \a h31, \a h32, \a h33.
+ \fn QTransform::QTransform(qreal m11, qreal m12, qreal m13, qreal m21, qreal m22, qreal m23, qreal m31, qreal m32, qreal m33)
+
+ Constructs a matrix with the elements, \a m11, \a m12, \a m13,
+ \a m21, \a m22, \a m23, \a m31, \a m32, \a m33.
\sa setMatrix()
*/
QTransform::QTransform(qreal h11, qreal h12, qreal h13,
qreal h21, qreal h22, qreal h23,
qreal h31, qreal h32, qreal h33)
- : affine(h11, h12, h21, h22, h31, h32),
- m_13(h13), m_23(h23), m_33(h33)
+ : affine(h11, h12, h21, h22, h31, h32, true)
+ , m_13(h13), m_23(h23), m_33(h33)
, m_type(TxNone)
, m_dirty(TxProject)
{
-
}
/*!
- Constructs a matrix with the elements, \a h11, \a h12, \a h21, \a
- h22, \a dx and \a dy.
+ \fn QTransform::QTransform(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy)
+
+ Constructs a matrix with the elements, \a m11, \a m12, \a m21, \a m22, \a dx and \a dy.
\sa setMatrix()
*/
QTransform::QTransform(qreal h11, qreal h12, qreal h21,
qreal h22, qreal dx, qreal dy)
- : affine(h11, h12, h21, h22, dx, dy),
- m_13(0), m_23(0), m_33(1)
+ : affine(h11, h12, h21, h22, dx, dy, true)
+ , m_13(0), m_23(0), m_33(1)
, m_type(TxNone)
, m_dirty(TxShear)
{
-
}
/*!
@@ -286,12 +287,11 @@ QTransform::QTransform(qreal h11, qreal h12, qreal h21,
and 1 respectively.
*/
QTransform::QTransform(const QMatrix &mtx)
- : affine(mtx),
+ : affine(mtx._m11, mtx._m12, mtx._m21, mtx._m22, mtx._dx, mtx._dy, true),
m_13(0), m_23(0), m_33(1)
, m_type(TxNone)
, m_dirty(TxShear)
{
-
}
/*!
@@ -314,7 +314,7 @@ QTransform QTransform::adjoint() const
return QTransform(h11, h12, h13,
h21, h22, h23,
- h31, h32, h33);
+ h31, h32, h33, true);
}
/*!
@@ -324,7 +324,7 @@ QTransform QTransform::transposed() const
{
QTransform t(affine._m11, affine._m21, affine._dx,
affine._m12, affine._m22, affine._dy,
- m_13, m_23, m_33);
+ m_13, m_23, m_33, true);
t.m_type = m_type;
t.m_dirty = m_dirty;
return t;
@@ -342,11 +342,10 @@ QTransform QTransform::transposed() const
*/
QTransform QTransform::inverted(bool *invertible) const
{
- QTransform invert;
+ QTransform invert(true);
bool inv = true;
- qreal det;
- switch(type()) {
+ switch(inline_type()) {
case TxNone:
break;
case TxTranslate:
@@ -354,11 +353,11 @@ QTransform QTransform::inverted(bool *invertible) const
invert.affine._dy = -affine._dy;
break;
case TxScale:
- inv = !qFuzzyCompare(affine._m11 + 1, 1);
- inv &= !qFuzzyCompare(affine._m22 + 1, 1);
+ inv = !qFuzzyIsNull(affine._m11);
+ inv &= !qFuzzyIsNull(affine._m22);
if (inv) {
- invert.affine._m11 = 1 / affine._m11;
- invert.affine._m22 = 1 / affine._m22;
+ invert.affine._m11 = 1. / affine._m11;
+ invert.affine._m22 = 1. / affine._m22;
invert.affine._dx = -affine._dx * invert.affine._m11;
invert.affine._dy = -affine._dy * invert.affine._m22;
}
@@ -369,8 +368,8 @@ QTransform QTransform::inverted(bool *invertible) const
break;
default:
// general case
- det = determinant();
- inv = !qFuzzyCompare(det + 1, 1);
+ qreal det = determinant();
+ inv = !qFuzzyIsNull(det);
if (inv)
invert = adjoint() / det;
break;
@@ -394,12 +393,12 @@ QTransform QTransform::inverted(bool *invertible) const
\sa setMatrix()
*/
-QTransform & QTransform::translate(qreal dx, qreal dy)
+QTransform &QTransform::translate(qreal dx, qreal dy)
{
if (dx == 0 && dy == 0)
return *this;
- switch(type()) {
+ switch(inline_type()) {
case TxNone:
affine._dx = dx;
affine._dy = dy;
@@ -434,7 +433,7 @@ QTransform & QTransform::translate(qreal dx, qreal dy)
*/
QTransform QTransform::fromTranslate(qreal dx, qreal dy)
{
- QTransform transform(1, 0, 0, 1, dx, dy);
+ QTransform transform(1, 0, 0, 0, 1, 0, dx, dy, 1, true);
if (dx == 0 && dy == 0)
transform.m_dirty = TxNone;
else
@@ -453,7 +452,7 @@ QTransform & QTransform::scale(qreal sx, qreal sy)
if (sx == 1 && sy == 1)
return *this;
- switch(type()) {
+ switch(inline_type()) {
case TxNone:
case TxTranslate:
affine._m11 = sx;
@@ -486,8 +485,8 @@ QTransform & QTransform::scale(qreal sx, qreal sy)
*/
QTransform QTransform::fromScale(qreal sx, qreal sy)
{
- QTransform transform(sx, 0, 0, sy, 0, 0);
- if (sx == 1 && sy == 1)
+ QTransform transform(sx, 0, 0, 0, sy, 0, 0, 0, 1, true);
+ if (sx == 1. && sy == 1.)
transform.m_dirty = TxNone;
else
transform.m_dirty = TxScale;
@@ -502,7 +501,7 @@ QTransform QTransform::fromScale(qreal sx, qreal sy)
*/
QTransform & QTransform::shear(qreal sh, qreal sv)
{
- switch(type()) {
+ switch(inline_type()) {
case TxNone:
case TxTranslate:
affine._m12 = sv;
@@ -571,7 +570,7 @@ QTransform & QTransform::rotate(qreal a, Qt::Axis axis)
}
if (axis == Qt::ZAxis) {
- switch(type()) {
+ switch(inline_type()) {
case TxNone:
case TxTranslate:
affine._m11 = cosa;
@@ -643,7 +642,7 @@ QTransform & QTransform::rotateRadians(qreal a, Qt::Axis axis)
qreal cosa = qCos(a);
if (axis == Qt::ZAxis) {
- switch(type()) {
+ switch(inline_type()) {
case TxNone:
case TxTranslate:
affine._m11 = cosa;
@@ -727,11 +726,11 @@ bool QTransform::operator!=(const QTransform &o) const
*/
QTransform & QTransform::operator*=(const QTransform &o)
{
- const TransformationType otherType = o.type();
+ const TransformationType otherType = o.inline_type();
if (otherType == TxNone)
return *this;
- const TransformationType thisType = type();
+ const TransformationType thisType = inline_type();
if (thisType == TxNone)
return operator=(o);
@@ -809,9 +808,77 @@ QTransform & QTransform::operator*=(const QTransform &o)
*/
QTransform QTransform::operator*(const QTransform &m) const
{
- QTransform result = *this;
- result *= m;
- return result;
+ const TransformationType otherType = m.inline_type();
+ if (otherType == TxNone)
+ return *this;
+
+ const TransformationType thisType = inline_type();
+ if (thisType == TxNone)
+ return m;
+
+ QTransform t(true);
+ TransformationType type = qMax(thisType, otherType);
+ switch(type) {
+ case TxNone:
+ break;
+ case TxTranslate:
+ t.affine._dx = affine._dx + m.affine._dx;
+ t.affine._dy += affine._dy + m.affine._dy;
+ break;
+ case TxScale:
+ {
+ qreal m11 = affine._m11*m.affine._m11;
+ qreal m22 = affine._m22*m.affine._m22;
+
+ qreal m31 = affine._dx*m.affine._m11 + m.affine._dx;
+ qreal m32 = affine._dy*m.affine._m22 + m.affine._dy;
+
+ t.affine._m11 = m11;
+ t.affine._m22 = m22;
+ t.affine._dx = m31; t.affine._dy = m32;
+ break;
+ }
+ case TxRotate:
+ case TxShear:
+ {
+ qreal m11 = affine._m11*m.affine._m11 + affine._m12*m.affine._m21;
+ qreal m12 = affine._m11*m.affine._m12 + affine._m12*m.affine._m22;
+
+ qreal m21 = affine._m21*m.affine._m11 + affine._m22*m.affine._m21;
+ qreal m22 = affine._m21*m.affine._m12 + affine._m22*m.affine._m22;
+
+ qreal m31 = affine._dx*m.affine._m11 + affine._dy*m.affine._m21 + m.affine._dx;
+ qreal m32 = affine._dx*m.affine._m12 + affine._dy*m.affine._m22 + m.affine._dy;
+
+ t.affine._m11 = m11; t.affine._m12 = m12;
+ t.affine._m21 = m21; t.affine._m22 = m22;
+ t.affine._dx = m31; t.affine._dy = m32;
+ break;
+ }
+ case TxProject:
+ {
+ qreal m11 = affine._m11*m.affine._m11 + affine._m12*m.affine._m21 + m_13*m.affine._dx;
+ qreal m12 = affine._m11*m.affine._m12 + affine._m12*m.affine._m22 + m_13*m.affine._dy;
+ qreal m13 = affine._m11*m.m_13 + affine._m12*m.m_23 + m_13*m.m_33;
+
+ qreal m21 = affine._m21*m.affine._m11 + affine._m22*m.affine._m21 + m_23*m.affine._dx;
+ qreal m22 = affine._m21*m.affine._m12 + affine._m22*m.affine._m22 + m_23*m.affine._dy;
+ qreal m23 = affine._m21*m.m_13 + affine._m22*m.m_23 + m_23*m.m_33;
+
+ qreal m31 = affine._dx*m.affine._m11 + affine._dy*m.affine._m21 + m_33*m.affine._dx;
+ qreal m32 = affine._dx*m.affine._m12 + affine._dy*m.affine._m22 + m_33*m.affine._dy;
+ qreal m33 = affine._dx*m.m_13 + affine._dy*m.m_23 + m_33*m.m_33;
+
+ t.affine._m11 = m11; t.affine._m12 = m12; t.m_13 = m13;
+ t.affine._m21 = m21; t.affine._m22 = m22; t.m_23 = m23;
+ t.affine._dx = m31; t.affine._dy = m32; t.m_33 = m33;
+ }
+ }
+
+ t.m_dirty = type;
+ t.m_type = type;
+
+ return t;
}
/*!
@@ -973,7 +1040,7 @@ QPoint QTransform::map(const QPoint &p) const
qreal x = 0, y = 0;
- TransformationType t = type();
+ TransformationType t = inline_type();
switch(t) {
case TxNone:
x = fx;
@@ -1024,7 +1091,7 @@ QPointF QTransform::map(const QPointF &p) const
qreal x = 0, y = 0;
- TransformationType t = type();
+ TransformationType t = inline_type();
switch(t) {
case TxNone:
x = fx;
@@ -1095,7 +1162,7 @@ QLine QTransform::map(const QLine &l) const
qreal x1 = 0, y1 = 0, x2 = 0, y2 = 0;
- TransformationType t = type();
+ TransformationType t = inline_type();
switch(t) {
case TxNone:
x1 = fx1;
@@ -1154,7 +1221,7 @@ QLineF QTransform::map(const QLineF &l) const
qreal x1 = 0, y1 = 0, x2 = 0, y2 = 0;
- TransformationType t = type();
+ TransformationType t = inline_type();
switch(t) {
case TxNone:
x1 = fx1;
@@ -1242,7 +1309,7 @@ static QPolygonF mapProjective(const QTransform &transform, const QPolygonF &pol
*/
QPolygonF QTransform::map(const QPolygonF &a) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
if (t <= TxTranslate)
return a.translated(affine._dx, affine._dy);
@@ -1272,7 +1339,7 @@ QPolygonF QTransform::map(const QPolygonF &a) const
*/
QPolygon QTransform::map(const QPolygon &a) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
if (t <= TxTranslate)
return a.translated(qRound(affine._dx), qRound(affine._dy));
@@ -1317,7 +1384,7 @@ extern QPainterPath qt_regionToPath(const QRegion &region);
*/
QRegion QTransform::map(const QRegion &r) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
if (t == TxNone)
return r;
if (t == TxTranslate) {
@@ -1340,7 +1407,7 @@ struct QHomogeneousCoordinate
QHomogeneousCoordinate(qreal x_, qreal y_, qreal w_) : x(x_), y(y_), w(w_) {}
const QPointF toPoint() const {
- qreal iw = 1 / w;
+ qreal iw = 1. / w;
return QPointF(x * iw, y * iw);
}
};
@@ -1478,7 +1545,7 @@ static QPainterPath mapProjective(const QTransform &transform, const QPainterPat
*/
QPainterPath QTransform::map(const QPainterPath &path) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
if (t == TxNone || path.isEmpty())
return path;
@@ -1523,7 +1590,7 @@ QPainterPath QTransform::map(const QPainterPath &path) const
*/
QPolygon QTransform::mapToPolygon(const QRect &rect) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
QPolygon a(4);
qreal x[4] = { 0, 0, 0, 0 }, y[4] = { 0, 0, 0, 0 };
@@ -1697,7 +1764,7 @@ void QTransform::setMatrix(qreal m11, qreal m12, qreal m13,
QRect QTransform::mapRect(const QRect &rect) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
if (t <= TxTranslate)
return rect.translated(qRound(affine._dx), qRound(affine._dy));
@@ -1717,13 +1784,12 @@ QRect QTransform::mapRect(const QRect &rect) const
return QRect(x, y, w, h);
} else if (t < TxProject) {
// see mapToPolygon for explanations of the algorithm.
- qreal x0 = 0, y0 = 0;
- qreal x, y;
- MAP(rect.left(), rect.top(), x0, y0);
- qreal xmin = x0;
- qreal ymin = y0;
- qreal xmax = x0;
- qreal ymax = y0;
+ qreal x = 0, y = 0;
+ MAP(rect.left(), rect.top(), x, y);
+ qreal xmin = x;
+ qreal ymin = y;
+ qreal xmax = x;
+ qreal ymax = y;
MAP(rect.right() + 1, rect.top(), x, y);
xmin = qMin(xmin, x);
ymin = qMin(ymin, y);
@@ -1768,7 +1834,7 @@ QRect QTransform::mapRect(const QRect &rect) const
*/
QRectF QTransform::mapRect(const QRectF &rect) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
if (t <= TxTranslate)
return rect.translated(affine._dx, affine._dy);
@@ -1787,13 +1853,12 @@ QRectF QTransform::mapRect(const QRectF &rect) const
}
return QRectF(x, y, w, h);
} else if (t < TxProject) {
- qreal x0 = 0, y0 = 0;
- qreal x, y;
- MAP(rect.x(), rect.y(), x0, y0);
- qreal xmin = x0;
- qreal ymin = y0;
- qreal xmax = x0;
- qreal ymax = y0;
+ qreal x = 0, y = 0;
+ MAP(rect.x(), rect.y(), x, y);
+ qreal xmin = x;
+ qreal ymin = y;
+ qreal xmax = x;
+ qreal ymax = y;
MAP(rect.x() + rect.width(), rect.y(), x, y);
xmin = qMin(xmin, x);
ymin = qMin(ymin, y);
@@ -1843,7 +1908,7 @@ QRectF QTransform::mapRect(const QRectF &rect) const
*/
void QTransform::map(qreal x, qreal y, qreal *tx, qreal *ty) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
MAP(x, y, *tx, *ty);
}
@@ -1857,7 +1922,7 @@ void QTransform::map(qreal x, qreal y, qreal *tx, qreal *ty) const
*/
void QTransform::map(int x, int y, int *tx, int *ty) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
qreal fx = 0, fy = 0;
MAP(x, y, fx, fy);
*tx = qRound(fx);
@@ -1886,25 +1951,41 @@ const QMatrix &QTransform::toAffine() const
*/
QTransform::TransformationType QTransform::type() const
{
- if (m_dirty >= m_type) {
- if (m_dirty > TxShear && (!qFuzzyCompare(m_13 + 1, 1) || !qFuzzyCompare(m_23 + 1, 1)))
+ if(m_dirty == TxNone || m_dirty < m_type)
+ return static_cast<TransformationType>(m_type);
+
+ switch (static_cast<TransformationType>(m_dirty)) {
+ case TxProject:
+ if (!qFuzzyIsNull(m_13) || !qFuzzyIsNull(m_23) || !qFuzzyIsNull(m_33 - 1)) {
m_type = TxProject;
- else if (m_dirty > TxScale && (!qFuzzyCompare(affine._m12 + 1, 1) || !qFuzzyCompare(affine._m21 + 1, 1))) {
+ break;
+ }
+ case TxShear:
+ case TxRotate:
+ if (!qFuzzyIsNull(affine._m12) || !qFuzzyIsNull(affine._m21)) {
const qreal dot = affine._m11 * affine._m12 + affine._m21 * affine._m22;
- if (qFuzzyCompare(dot + 1, 1))
+ if (qFuzzyIsNull(dot))
m_type = TxRotate;
else
m_type = TxShear;
- } else if (m_dirty > TxTranslate && (!qFuzzyCompare(affine._m11, 1) || !qFuzzyCompare(affine._m22, 1) || !qFuzzyCompare(m_33, 1)))
+ break;
+ }
+ case TxScale:
+ if (!qFuzzyIsNull(affine._m11 - 1) || !qFuzzyIsNull(affine._m22 - 1)) {
m_type = TxScale;
- else if (m_dirty > TxNone && (!qFuzzyCompare(affine._dx + 1, 1) || !qFuzzyCompare(affine._dy + 1, 1)))
+ break;
+ }
+ case TxTranslate:
+ if (!qFuzzyIsNull(affine._dx) || !qFuzzyIsNull(affine._dy)) {
m_type = TxTranslate;
- else
- m_type = TxNone;
-
- m_dirty = TxNone;
+ break;
+ }
+ case TxNone:
+ m_type = TxNone;
+ break;
}
+ m_dirty = TxNone;
return static_cast<TransformationType>(m_type);
}
diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h
index c76409b..aac7c31 100644
--- a/src/gui/painting/qtransform.h
+++ b/src/gui/painting/qtransform.h
@@ -159,6 +159,19 @@ public:
static QTransform fromScale(qreal dx, qreal dy);
private:
+ inline QTransform(qreal h11, qreal h12, qreal h13,
+ qreal h21, qreal h22, qreal h23,
+ qreal h31, qreal h32, qreal h33, bool)
+ : affine(h11, h12, h21, h22, h31, h32, true)
+ , m_13(h13), m_23(h23), m_33(h33)
+ , m_type(TxNone)
+ , m_dirty(TxProject) {}
+ inline QTransform(bool)
+ : affine(true)
+ , m_13(0), m_23(0), m_33(1)
+ , m_type(TxNone)
+ , m_dirty(TxNone) {}
+ inline TransformationType inline_type() const;
QMatrix affine;
qreal m_13;
qreal m_23;
@@ -173,18 +186,25 @@ private:
Q_DECLARE_TYPEINFO(QTransform, Q_MOVABLE_TYPE);
/******* inlines *****/
+inline QTransform::TransformationType QTransform::inline_type() const
+{
+ if (m_dirty == TxNone)
+ return static_cast<TransformationType>(m_type);
+ return type();
+}
+
inline bool QTransform::isAffine() const
{
- return type() < TxProject;
+ return inline_type() < TxProject;
}
inline bool QTransform::isIdentity() const
{
- return type() == TxNone;
+ return inline_type() == TxNone;
}
inline bool QTransform::isInvertible() const
{
- return !qFuzzyCompare(determinant() + 1, 1);
+ return !qFuzzyIsNull(determinant());
}
inline bool QTransform::isScaling() const
@@ -193,12 +213,12 @@ inline bool QTransform::isScaling() const
}
inline bool QTransform::isRotating() const
{
- return type() >= TxRotate;
+ return inline_type() >= TxRotate;
}
inline bool QTransform::isTranslating() const
{
- return type() >= TxTranslate;
+ return inline_type() >= TxTranslate;
}
inline qreal QTransform::determinant() const
diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp
index bcb0380..d941a24 100644
--- a/src/gui/painting/qwindowsurface.cpp
+++ b/src/gui/painting/qwindowsurface.cpp
@@ -310,10 +310,13 @@ void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
int lineskip = img.bytesPerLine();
int depth = img.depth() >> 3;
-
- const QRect r = rect & QRect(0, 0, img.width(), img.height());
+ const QRect imageRect(0, 0, img.width(), img.height());
+ const QRect r = rect & imageRect & imageRect.translated(-offset);
const QPoint p = rect.topLeft() + offset;
+ if (r.isEmpty())
+ return;
+
const uchar *src;
uchar *dest;
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp
index 3fbf233..acb8437 100644
--- a/src/gui/styles/gtksymbols.cpp
+++ b/src/gui/styles/gtksymbols.cpp
@@ -75,6 +75,7 @@
QT_BEGIN_NAMESPACE
static bool displayDepth = -1;
+Q_GLOBAL_STATIC(QGtkStyleUpdateScheduler, styleScheduler)
typedef QHash<QString, GtkWidget*> WidgetMap;
Q_GLOBAL_STATIC(WidgetMap, gtkWidgetMap)
@@ -486,11 +487,11 @@ static void init_gtk_menu()
}
// Updates window/windowtext palette based on the indicated gtk widget
-static void ensureWidgetPalette(QWidget* widget, const QString &gtkWidgetName)
+static QPalette gtkWidgetPalette(const QString &gtkWidgetName)
{
GtkWidget *gtkWidget = QGtk::gtkWidget(gtkWidgetName);
Q_ASSERT(gtkWidget);
- QPalette pal = widget->palette();
+ QPalette pal = QApplication::palette();
GdkColor gdkBg = gtkWidget->style->bg[GTK_STATE_NORMAL];
GdkColor gdkText = gtkWidget->style->fg[GTK_STATE_NORMAL];
GdkColor gdkDisabledText = gtkWidget->style->fg[GTK_STATE_INSENSITIVE];
@@ -503,8 +504,7 @@ static void ensureWidgetPalette(QWidget* widget, const QString &gtkWidgetName)
pal.setBrush(QPalette::Disabled, QPalette::WindowText, disabledTextColor);
pal.setBrush(QPalette::All, QPalette::ButtonText, textColor);
pal.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledTextColor);
- widget->setPalette(pal);
- widget->setAttribute(Qt::WA_SetPalette, false);
+ return pal;
}
bool QGtk::isKDE4Session()
@@ -515,44 +515,47 @@ bool QGtk::isKDE4Session()
return (version == 4);
}
-// Maps a Gtk widget palettes to a Qt widget
-void QGtk::applyGtkSystemPalette(QWidget *widget)
+void QGtk::applyCustomPaletteHash()
{
- // Do not apply if the widget has a custom palette;
- if (widget->testAttribute(Qt::WA_SetPalette))
- return;
+ QPalette menuPal = gtkWidgetPalette(QLS("GtkMenu"));
+ GdkColor gdkBg = QGtk::gtkWidget(QLS("GtkMenu"))->style->bg[GTK_STATE_NORMAL];
+ QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
+ menuPal.setBrush(QPalette::Base, bgColor);
+ menuPal.setBrush(QPalette::Window, bgColor);
+ qApp->setPalette(menuPal, "QMenu");
- QPalette pal;
- if (QStatusBar *statusbar = qobject_cast<QStatusBar*> (widget))
- ensureWidgetPalette(statusbar, QLS("GtkStatusbar"));
- else if (QMenuBar *menubar = qobject_cast<QMenuBar*> (widget))
- ensureWidgetPalette(menubar, QLS("GtkMenuBar"));
- else if (QToolBar *toolbar = qobject_cast<QToolBar*> (widget))
- ensureWidgetPalette(toolbar, QLS("GtkToolbar"));
- else if (QMenu *menubar = qobject_cast<QMenu*> (widget)) {
- // This really applies to the combo box rendering since
- // QComboBox copies the palette from a QMenu
- QPalette pal = widget->palette();
- GdkColor gdkBg = QGtk::gtkWidget(QLS("GtkMenu"))->style->bg[GTK_STATE_NORMAL];
- QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
- pal.setBrush(QPalette::Base, bgColor);
- menubar->setPalette(pal);
- }
- widget->setAttribute(Qt::WA_SetPalette, false);
+ QPalette toolbarPal = gtkWidgetPalette(QLS("GtkToolbar"));
+ qApp->setPalette(toolbarPal, "QToolBar");
+
+ QPalette menuBarPal = gtkWidgetPalette(QLS("GtkMenuBar"));
+ qApp->setPalette(menuBarPal, "QMenuBar");
}
static void gtkStyleSetCallback(GtkWidget*, GtkStyle*, void*)
{
+ // We have to let this function return and complete the event
+ // loop to ensure that all gtk widgets have been styled before
+ // updating
+ QMetaObject::invokeMethod(styleScheduler(), "updateTheme", Qt::QueuedConnection);
+}
+
+void QGtkStyleUpdateScheduler::updateTheme()
+{
static QString oldTheme(QLS("qt_not_set"));
QPixmapCache::clear();
- qApp->setFont(QGtk::getThemeFont());
- QGtk::initGtkWidgets();
if (oldTheme != getThemeName()) {
oldTheme = getThemeName();
- QApplicationPrivate::setSystemPalette(qApp->style()->standardPalette());
+ qApp->setFont(QGtk::getThemeFont());
+ QPalette newPalette = qApp->style()->standardPalette();
+ QApplicationPrivate::setSystemPalette(newPalette);
+ QApplication::setPalette(newPalette);
+ QGtk::initGtkWidgets();
+ QGtk::applyCustomPaletteHash();
QList<QWidget*> widgets = QApplication::allWidgets();
+ // Notify all widgets that size metrics might have changed
foreach (QWidget *widget, widgets) {
- QGtk::applyGtkSystemPalette(widget);
+ QEvent e(QEvent::StyleChange);
+ QApplication::sendEvent(widget, &e);
}
}
}
diff --git a/src/gui/styles/gtksymbols_p.h b/src/gui/styles/gtksymbols_p.h
index 0cea542..74c5dc3 100644
--- a/src/gui/styles/gtksymbols_p.h
+++ b/src/gui/styles/gtksymbols_p.h
@@ -204,7 +204,7 @@ public:
static void cleanup_gtk_widgets();
static void initGtkWidgets();
static bool isKDE4Session();
- static void applyGtkSystemPalette(QWidget* widget);
+ static void applyCustomPaletteHash();
static QFont getThemeFont();
static bool isThemeAvailable() { return gtkStyle() != 0; }
@@ -329,6 +329,15 @@ public:
static Ptr_gconf_client_get_string gconf_client_get_string;
};
+// Helper to ensure that we have polished all our gtk widgets
+// before updating our own palettes
+class QGtkStyleUpdateScheduler : public QObject
+{
+ Q_OBJECT
+public slots:
+ void updateTheme();
+};
+
QT_END_NAMESPACE
#endif // !QT_NO_STYLE_GTK
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp
index 468ada9..11f4d26 100644
--- a/src/gui/styles/qcleanlooksstyle.cpp
+++ b/src/gui/styles/qcleanlooksstyle.cpp
@@ -44,6 +44,7 @@
#if !defined(QT_NO_STYLE_CLEANLOOKS) || defined(QT_PLUGIN)
+#include <private/qstylehelper_p.h>
#include "qwindowsstyle_p.h"
#include <qcombobox.h>
#include <qpushbutton.h>
@@ -72,7 +73,7 @@
QT_BEGIN_NAMESPACE
-static const bool UsePixmapCache = true;
+using namespace QStyleHelper;
enum Direction {
TopDown,
@@ -553,26 +554,6 @@ static void qt_cleanlooks_draw_buttongradient(QPainter *painter, const QRect &re
delete gradient;
}
-static QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
-{
- QString tmp;
- const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option);
- tmp.sprintf("%s-%d-%d-%lld-%dx%d-%d", key.toLatin1().constData(), uint(option->state),
- complexOption ? uint(complexOption->activeSubControls) : uint(0),
- option->palette.cacheKey(), size.width(), size.height(), option->direction);
-#ifndef QT_NO_SPINBOX
- if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- tmp.append(QLatin1Char('-'));
- tmp.append(QString::number(spinBox->buttonSymbols));
- tmp.append(QLatin1Char('-'));
- tmp.append(QString::number(spinBox->stepEnabled));
- tmp.append(QLatin1Char('-'));
- tmp.append(QLatin1Char(spinBox->frame ? '1' : '0'));
- }
-#endif // QT_NO_SPINBOX
- return tmp;
-}
-
static void qt_cleanlooks_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken)
{
QColor dark;
@@ -1664,7 +1645,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o
// Draws the header in tables.
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
QPixmap cache;
- QString pixmapName = uniqueName(QLatin1String("headersection"), option, option->rect.size());
+ QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size());
pixmapName += QLatin1String("-") + QString::number(int(header->position));
pixmapName += QLatin1String("-") + QString::number(int(header->orientation));
QRect r = option->rect;
@@ -2456,7 +2437,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
case CC_SpinBox:
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
QPixmap cache;
- QString pixmapName = uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size());
+ QString pixmapName = QStyleHelper::uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size());
if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
cache = QPixmap(spinBox->rect.size());
cache.fill(Qt::transparent);
@@ -3137,7 +3118,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
// The AddLine (down/right) button
if (scrollBar->subControls & SC_ScrollBarAddLine) {
- QString addLinePixmapName = uniqueName(QLatin1String("scrollbar_addline"), option, QSize(16, 16));
+ QString addLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_addline"), option, QSize(16, 16));
QRect pixmapRect = scrollBarAddLine;
if (isEnabled) {
QRect fillRect = pixmapRect.adjusted(1, 1, -1, -1);
@@ -3198,7 +3179,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
bool isEnabled = (comboBox->state & State_Enabled);
bool focus = isEnabled && (comboBox->state & State_HasFocus);
QPixmap cache;
- QString pixmapName = uniqueName(QLatin1String("combobox"), option, comboBox->rect.size());
+ QString pixmapName = QStyleHelper::uniqueName(QLatin1String("combobox"), option, comboBox->rect.size());
if (sunken)
pixmapName += QLatin1String("-sunken");
if (comboBox->editable)
@@ -3421,7 +3402,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
highlightAlpha.setAlpha(80);
if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
- QString groovePixmapName = uniqueName(QLatin1String("slider_groove"), option, groove.size());
+ QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_groove"), option, groove.size());
QRect pixmapRect(0, 0, groove.width(), groove.height());
// draw background groove
@@ -3501,7 +3482,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
// draw handle
if ((option->subControls & SC_SliderHandle) ) {
- QString handlePixmapName = uniqueName(QLatin1String("slider_handle"), option, handle.size());
+ QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size());
if (!UsePixmapCache || !QPixmapCache::find(handlePixmapName, cache)) {
cache = QPixmap(handle.size());
cache.fill(Qt::transparent);
@@ -3656,6 +3637,12 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
}
break;
#endif // QT_NO_SLIDER
+#ifndef QT_NO_DIAL
+ case CC_Dial:
+ if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option))
+ QStyleHelper::drawDial(dial, painter);
+ break;
+#endif // QT_NO_DIAL
default:
QWindowsStyle::drawComplexControl(control, option, painter, widget);
break;
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 3cae08a..d5ce8df 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -66,6 +66,7 @@
#include <private/qapplication_p.h>
#include <private/qcommonstylepixmaps_p.h>
#include <private/qmath_p.h>
+#include <private/qstylehelper_p.h>
#include <qdebug.h>
#include <qtextformat.h>
#include <qwizard.h>
@@ -2267,7 +2268,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
drawPrimitive(PE_PanelItemViewItem, opt, p, widget);
// draw the check mark
- if (checkRect.isValid()) {
+ if (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator) {
QStyleOptionViewItemV4 option(*vopt);
option.rect = checkRect;
option.state = option.state & ~QStyle::State_HasFocus;
@@ -3189,47 +3190,6 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
}
#ifndef QT_NO_DIAL
-static qreal angle(const QPointF &p1, const QPointF &p2)
-{
- static const qreal rad_factor = 180 / Q_PI;
- qreal _angle = 0;
-
- if (p1.x() == p2.x()) {
- if (p1.y() < p2.y())
- _angle = 270;
- else
- _angle = 90;
- } else {
- qreal x1, x2, y1, y2;
-
- if (p1.x() <= p2.x()) {
- x1 = p1.x(); y1 = p1.y();
- x2 = p2.x(); y2 = p2.y();
- } else {
- x2 = p1.x(); y2 = p1.y();
- x1 = p2.x(); y1 = p2.y();
- }
-
- qreal m = -(y2 - y1) / (x2 - x1);
- _angle = atan(m) * rad_factor;
-
- if (p1.x() < p2.x())
- _angle = 180 - _angle;
- else
- _angle = -_angle;
- }
- return _angle;
-}
-
-static int calcBigLineSize(int radius)
-{
- int bigLineSize = radius / 6;
- if (bigLineSize < 4)
- bigLineSize = 4;
- if (bigLineSize > radius / 2)
- bigLineSize = radius / 2;
- return bigLineSize;
-}
static QPolygonF calcArrow(const QStyleOptionSlider *dial, qreal &a)
{
@@ -3250,7 +3210,7 @@ static QPolygonF calcArrow(const QStyleOptionSlider *dial, qreal &a)
int xc = width / 2;
int yc = height / 2;
- int len = r - calcBigLineSize(r) - 5;
+ int len = r - QStyleHelper::calcBigLineSize(r) - 5;
if (len < 5)
len = 5;
int back = len / 2;
@@ -3265,45 +3225,6 @@ static QPolygonF calcArrow(const QStyleOptionSlider *dial, qreal &a)
return arrow;
}
-static QPolygonF calcLines(const QStyleOptionSlider *dial, const QWidget *)
-{
- QPolygonF poly;
- int width = dial->rect.width();
- int height = dial->rect.height();
- qreal r = qMin(width, height) / 2;
- int bigLineSize = calcBigLineSize(int(r));
-
- qreal xc = width / 2;
- qreal yc = height / 2;
- int ns = dial->tickInterval;
- int notches = (dial->maximum + ns - 1 - dial->minimum) / ns;
- if (notches <= 0)
- return poly;
- if (dial->maximum < dial->minimum
- || dial->maximum - dial->minimum > 1000) {
- int maximum = dial->minimum + 1000;
- notches = (maximum + ns - 1 - dial->minimum) / ns;
- }
-
- poly.resize(2 + 2 * notches);
- int smallLineSize = bigLineSize / 2;
- for (int i = 0; i <= notches; ++i) {
- qreal angle = dial->dialWrapping ? Q_PI * 3 / 2 - i * 2 * Q_PI / notches
- : (Q_PI * 8 - i * 10 * Q_PI / notches) / 6;
- qreal s = qSin(angle);
- qreal c = qCos(angle);
- if (i == 0 || (((ns * i) % (dial->pageStep ? dial->pageStep : 1)) == 0)) {
- poly[2 * i] = QPointF(xc + (r - bigLineSize) * c,
- yc - (r - bigLineSize) * s);
- poly[2 * i + 1] = QPointF(xc + r * c, yc - r * s);
- } else {
- poly[2 * i] = QPointF(xc + (r - 1 - smallLineSize) * c,
- yc - (r - 1 - smallLineSize) * s);
- poly[2 * i + 1] = QPointF(xc + (r - 1) * c, yc -(r - 1) * s);
- }
- }
- return poly;
-}
#endif // QT_NO_DIAL
/*!
@@ -3794,7 +3715,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
// draw notches
if (dial->subControls & QStyle::SC_DialTickmarks) {
p->setPen(pal.foreground().color());
- p->drawLines(calcLines(dial, widget)); // ### calcLines could be cached...
+ p->drawLines(QStyleHelper::calcLines(dial));
}
if (dial->state & State_Enabled) {
@@ -3816,7 +3737,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
p->setBrush(pal.button());
p->drawPolygon(arrow);
- a = angle(QPointF(width / 2, height / 2), arrow[0]);
+ a = QStyleHelper::angle(QPointF(width / 2, height / 2), arrow[0]);
p->setBrush(Qt::NoBrush);
if (a <= 0 || a > 200) {
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index 582962a..b7fa575 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -38,7 +38,6 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
#include "qgtkstyle.h"
#if !defined(QT_NO_STYLE_GTK)
@@ -138,6 +137,30 @@ static const char * const dock_widget_restore_xpm[] =
};
+class QGtkStyleFilter : public QObject
+{
+public:
+ QGtkStyleFilter() {
+ qApp->installEventFilter(this);
+ }
+
+private:
+ bool eventFilter(QObject *obj, QEvent *e);
+};
+
+bool QGtkStyleFilter::eventFilter(QObject *obj, QEvent *e)
+{
+ if (e->type() == QEvent::ApplicationPaletteChange) {
+ // Only do this the first time since this will also
+ // generate applicationPaletteChange events
+ extern QHash<QByteArray, QPalette> *qt_app_palettes_hash(); //qapplication.cpp
+ if (!qt_app_palettes_hash() || qt_app_palettes_hash()->isEmpty()) {
+ QGtk::applyCustomPaletteHash();
+ }
+ }
+ return QObject::eventFilter(obj, e);
+}
+
class QGtkStylePrivate : public QCleanlooksStylePrivate
{
Q_DECLARE_PUBLIC(QGtkStyle)
@@ -145,6 +168,7 @@ public:
QGtkStylePrivate()
: QCleanlooksStylePrivate()
{}
+ QGtkStyleFilter filter;
};
static const int groupBoxBottomMargin = 2; // space below the groupbox
@@ -217,6 +241,7 @@ static QString uniqueName(const QString &key, const QStyleOption *option, const
Constructs a QGtkStyle object.
*/
QGtkStyle::QGtkStyle()
+ : QCleanlooksStyle(*new QGtkStylePrivate)
{
QGtk::initGtkWidgets();
}
@@ -313,7 +338,7 @@ void QGtkStyle::polish(QPalette &palette)
if (!QGtk::isThemeAvailable())
QCleanlooksStyle::polish(palette);
else
- palette = standardPalette();
+ palette = palette.resolve(standardPalette());
}
/*!
@@ -328,6 +353,7 @@ void QGtkStyle::polish(QApplication *app)
if (app->desktopSettingsAware() && QGtk::isThemeAvailable()) {
QApplicationPrivate::setSystemPalette(standardPalette());
QApplicationPrivate::setSystemFont(QGtk::getThemeFont());
+ QGtk::applyCustomPaletteHash();
if (!QGtk::isKDE4Session()) {
qt_filedialog_open_filename_hook = &QGtk::openFilename;
qt_filedialog_save_filename_hook = &QGtk::saveFilename;
@@ -357,12 +383,12 @@ void QGtkStyle::unpolish(QApplication *app)
/*!
\reimp
*/
+
void QGtkStyle::polish(QWidget *widget)
{
QCleanlooksStyle::polish(widget);
if (!QGtk::isThemeAvailable())
return;
-
if (qobject_cast<QAbstractButton*>(widget)
|| qobject_cast<QToolButton*>(widget)
|| qobject_cast<QComboBox*>(widget)
@@ -375,8 +401,6 @@ void QGtkStyle::polish(QWidget *widget)
widget->setAttribute(Qt::WA_Hover);
else if (QTreeView *tree = qobject_cast<QTreeView *> (widget))
tree->viewport()->setAttribute(Qt::WA_Hover);
-
- QGtk::applyGtkSystemPalette(widget);
}
/*!
@@ -647,6 +671,12 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
switch (element) {
case PE_Frame: {
+ if (widget && widget->inherits("QComboBoxPrivateContainer")){
+ QStyleOption copy = *option;
+ copy.state |= State_Raised;
+ drawPrimitive(PE_PanelMenu, &copy, painter, widget);
+ break;
+ }
// Drawing the entire itemview frame is very expensive, especially on the native X11 engine
// Instead we cheat a bit and draw a border image without the center part, hence only scaling
// thin rectangular images
@@ -947,7 +977,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
- painter->fillRect(textRect, option->palette.base().color());
+ painter->fillRect(textRect, option->palette.base());
else
gtkPainter.paintFlatBox( gtkEntry, "entry_bg", textRect,
option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, gtkEntry->style);
@@ -2477,6 +2507,10 @@ void QGtkStyle::drawControl(ControlElement element,
if (selected) {
QRect rect = option->rect.adjusted(0, 0, -1, -1);
+#ifndef QT_NO_COMBOBOX
+ if (qobject_cast<const QComboBox*>(widget))
+ rect = option->rect;
+#endif
gtkPainter.paintBox( gtkMenuItem, "menuitem", rect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style);
}
@@ -2593,16 +2627,24 @@ void QGtkStyle::drawControl(ControlElement element,
opt.rect = vCheckRect;
drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);
}
-
painter->drawPixmap(pmr.topLeft(), pixmap);
}
GdkColor gdkText = gtkMenuItem->style->fg[GTK_STATE_NORMAL];
GdkColor gdkDText = gtkMenuItem->style->fg[GTK_STATE_INSENSITIVE];
GdkColor gdkHText = gtkMenuItem->style->fg[GTK_STATE_PRELIGHT];
+ uint resolve_mask = option->palette.resolve();
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
QColor disabledTextColor = QColor(gdkDText.red>>8, gdkDText.green>>8, gdkDText.blue>>8);
+ if (resolve_mask & (1 << QPalette::ButtonText)) {
+ textColor = option->palette.buttonText().color();
+ disabledTextColor = option->palette.brush(QPalette::Disabled, QPalette::ButtonText).color();
+ }
+
QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8);
+ if (resolve_mask & (1 << QPalette::HighlightedText)) {
+ highlightedTextColor = option->palette.highlightedText().color();
+ }
if (selected)
painter->setPen(highlightedTextColor);
@@ -2718,10 +2760,13 @@ void QGtkStyle::drawControl(ControlElement element,
if (tab->state & State_Selected)
state = GTK_STATE_NORMAL;
- bool first = tab->position == QStyleOptionTab::Beginning || tab->position == QStyleOptionTab::OnlyOneTab;
- bool last = tab->position == QStyleOptionTab::End || tab->position == QStyleOptionTab::OnlyOneTab;
bool selected = (tab->state & State_Selected);
- if (option->direction == Qt::RightToLeft) {
+ bool first = false, last = false;
+ if (widget) {
+ // This is most accurate and avoids resizing tabs while moving
+ first = tab->rect.left() == widget->rect().left();
+ last = tab->rect.right() == widget->rect().right();
+ } else if (option->direction == Qt::RightToLeft) {
bool tmp = first;
first = last;
last = tmp;
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index 08d6fed..5d08c58 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -50,6 +50,7 @@
#include <private/qpaintengine_mac_p.h>
#include <private/qpainter_p.h>
#include <private/qprintengine_mac_p.h>
+#include <private/qstylehelper_p.h>
#include <qapplication.h>
#include <qbitmap.h>
#include <qcheckbox.h>
@@ -131,6 +132,13 @@ enum {
kThemePushButtonTexturedSmall = 32,
kThemePushButtonTexturedMini = 33
};
+
+/* Search fields */
+enum {
+ kHIThemeFrameTextFieldRound = 1000,
+ kHIThemeFrameTextFieldRoundSmall = 1001,
+ kHIThemeFrameTextFieldRoundMini = 1002
+};
#endif
// Resolve these at run-time, since the functions was moved in Leopard.
@@ -2196,7 +2204,7 @@ void QMacStyle::polish(QWidget* w)
}
if (qobject_cast<QMenu*>(w) || qobject_cast<QComboBoxPrivateContainer *>(w)) {
- w->setWindowOpacity(0.94);
+ w->setWindowOpacity(QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 ? 0.985 : 0.94);
if (!w->testAttribute(Qt::WA_SetPalette)) {
QPixmap px(64, 64);
HIThemeMenuDrawInfo mtinfo;
@@ -3888,13 +3896,16 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
}
break;
case CE_TabBarTabShape:
- if (const QStyleOptionTabV3 *tabOpt = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) {
- if (tabOpt->documentMode) {
- p->save();
- QRect tabRect = tabOpt->rect;
- drawTabShape(p, tabOpt);
- p->restore();
- return;
+ if (const QStyleOptionTab *tabOpt = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
+
+ if (const QStyleOptionTabV3 *tabOptV3 = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) {
+ if (tabOptV3->documentMode) {
+ p->save();
+ QRect tabRect = tabOptV3->rect;
+ drawTabShape(p, tabOptV3);
+ p->restore();
+ return;
+ }
}
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
@@ -5375,6 +5386,10 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
}
}
break;
+ case CC_Dial:
+ if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(opt))
+ QStyleHelper::drawDial(dial, p);
+ break;
default:
QWindowsStyle::drawComplexControl(cc, opt, p, widget);
break;
diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp
index 24d7748..66464ff 100644
--- a/src/gui/styles/qplastiquestyle.cpp
+++ b/src/gui/styles/qplastiquestyle.cpp
@@ -51,6 +51,7 @@ static const int ProgressBarFps = 25;
static const int blueFrameWidth = 2; // with of line edit focus frame
#include "qwindowsstyle_p.h"
+#include <private/qstylehelper_p.h>
#include <qapplication.h>
#include <qbitmap.h>
#include <qabstractitemview.h>
@@ -4970,6 +4971,12 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt
painter->restore();
}
break;
+#ifndef QT_NO_DIAL
+ case CC_Dial:
+ if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option))
+ QStyleHelper::drawDial(dial, painter);
+ break;
+#endif // QT_NO_DIAL
default:
QWindowsStyle::drawComplexControl(control, option, painter, widget);
break;
diff --git a/src/gui/styles/qstyle.h b/src/gui/styles/qstyle.h
index 6191d51..c1cbbdd 100644
--- a/src/gui/styles/qstyle.h
+++ b/src/gui/styles/qstyle.h
@@ -453,6 +453,7 @@ public:
SC_MdiNormalButton = 0x00000002,
SC_MdiCloseButton = 0x00000004,
+ SC_CustomBase = 0xf0000000,
SC_All = 0xffffffff
};
Q_DECLARE_FLAGS(SubControls, SubControl)
diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp
new file mode 100644
index 0000000..3320970
--- /dev/null
+++ b/src/gui/styles/qstylehelper.cpp
@@ -0,0 +1,295 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstylehelper_p.h"
+
+#include <qstyleoption.h>
+#include <qpainter.h>
+#include <qpixmapcache.h>
+#include <private/qmath_p.h>
+#include <private/qstyle_p.h>
+#include <qmath.h>
+
+QT_BEGIN_NAMESPACE
+
+const bool QStyleHelper::UsePixmapCache = true;
+
+QString QStyleHelper::uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
+{
+ QString tmp;
+ const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option);
+ tmp.sprintf("%s-%d-%d-%lld-%dx%d-%d", key.toLatin1().constData(), uint(option->state),
+ complexOption ? uint(complexOption->activeSubControls) : uint(0),
+ option->palette.cacheKey(), size.width(), size.height(), option->direction);
+#ifndef QT_NO_SPINBOX
+ if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
+ tmp.append(QLatin1Char('-'));
+ tmp.append(QString::number(spinBox->buttonSymbols));
+ tmp.append(QLatin1Char('-'));
+ tmp.append(QString::number(spinBox->stepEnabled));
+ tmp.append(QLatin1Char('-'));
+ tmp.append(QLatin1Char(spinBox->frame ? '1' : '0'));
+ }
+#endif // QT_NO_SPINBOX
+ return tmp;
+}
+
+#ifndef QT_NO_DIAL
+
+int QStyleHelper::calcBigLineSize(int radius)
+{
+ int bigLineSize = radius / 6;
+ if (bigLineSize < 4)
+ bigLineSize = 4;
+ if (bigLineSize > radius / 2)
+ bigLineSize = radius / 2;
+ return bigLineSize;
+}
+
+static QPointF calcRadialPos(const QStyleOptionSlider *dial, qreal offset)
+{
+ const int width = dial->rect.width();
+ const int height = dial->rect.height();
+ const int r = qMin(width, height) / 2;
+ const int currentSliderPosition = dial->upsideDown ? dial->sliderPosition : (dial->maximum - dial->sliderPosition);
+ qreal a = 0;
+ if (dial->maximum == dial->minimum)
+ a = Q_PI / 2;
+ else if (dial->dialWrapping)
+ a = Q_PI * 3 / 2 - (currentSliderPosition - dial->minimum) * 2 * Q_PI
+ / (dial->maximum - dial->minimum);
+ else
+ a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI
+ / (dial->maximum - dial->minimum)) / 6;
+ qreal xc = width / 2.0;
+ qreal yc = height / 2.0;
+ qreal len = r - QStyleHelper::calcBigLineSize(r) - 3;
+ qreal back = offset * len;
+ QPointF pos(QPointF(xc + back * qCos(a), yc - back * qSin(a)));
+ return pos;
+}
+
+qreal QStyleHelper::angle(const QPointF &p1, const QPointF &p2)
+{
+ static const qreal rad_factor = 180 / Q_PI;
+ qreal _angle = 0;
+
+ if (p1.x() == p2.x()) {
+ if (p1.y() < p2.y())
+ _angle = 270;
+ else
+ _angle = 90;
+ } else {
+ qreal x1, x2, y1, y2;
+
+ if (p1.x() <= p2.x()) {
+ x1 = p1.x(); y1 = p1.y();
+ x2 = p2.x(); y2 = p2.y();
+ } else {
+ x2 = p1.x(); y2 = p1.y();
+ x1 = p2.x(); y1 = p2.y();
+ }
+
+ qreal m = -(y2 - y1) / (x2 - x1);
+ _angle = atan(m) * rad_factor;
+
+ if (p1.x() < p2.x())
+ _angle = 180 - _angle;
+ else
+ _angle = -_angle;
+ }
+ return _angle;
+}
+
+QPolygonF QStyleHelper::calcLines(const QStyleOptionSlider *dial)
+{
+ QPolygonF poly;
+ int width = dial->rect.width();
+ int height = dial->rect.height();
+ qreal r = qMin(width, height) / 2;
+ int bigLineSize = calcBigLineSize(int(r));
+
+ qreal xc = width / 2 + 0.5;
+ qreal yc = height / 2 + 0.5;
+ int ns = dial->tickInterval;
+ int notches = (dial->maximum + ns - 1 - dial->minimum) / ns;
+ if (notches <= 0)
+ return poly;
+ if (dial->maximum < dial->minimum || dial->maximum - dial->minimum > 1000) {
+ int maximum = dial->minimum + 1000;
+ notches = (maximum + ns - 1 - dial->minimum) / ns;
+ }
+
+ poly.resize(2 + 2 * notches);
+ int smallLineSize = bigLineSize / 2;
+ for (int i = 0; i <= notches; ++i) {
+ qreal angle = dial->dialWrapping ? Q_PI * 3 / 2 - i * 2 * Q_PI / notches
+ : (Q_PI * 8 - i * 10 * Q_PI / notches) / 6;
+ qreal s = qSin(angle);
+ qreal c = qCos(angle);
+ if (i == 0 || (((ns * i) % (dial->pageStep ? dial->pageStep : 1)) == 0)) {
+ poly[2 * i] = QPointF(xc + (r - bigLineSize) * c,
+ yc - (r - bigLineSize) * s);
+ poly[2 * i + 1] = QPointF(xc + r * c, yc - r * s);
+ } else {
+ poly[2 * i] = QPointF(xc + (r - 1 - smallLineSize) * c,
+ yc - (r - 1 - smallLineSize) * s);
+ poly[2 * i + 1] = QPointF(xc + (r - 1) * c, yc -(r - 1) * s);
+ }
+ }
+ return poly;
+}
+
+
+// This will draw a nice and shiny QDial for us. We don't want
+// all the shinyness in QWindowsStyle, hence we place it here
+
+void QStyleHelper::drawDial(const QStyleOptionSlider *option, QPainter *painter)
+{
+ QPalette pal = option->palette;
+ QColor buttonColor = pal.button().color();
+ const int width = option->rect.width();
+ const int height = option->rect.height();
+ const bool enabled = option->state & QStyle::State_Enabled;
+ qreal r = qMin(width, height) / 2;
+ r -= r/50;
+ const qreal penSize = r/20.0;
+
+ painter->save();
+ painter->setRenderHint(QPainter::Antialiasing);
+
+ // Draw notches
+ if (option->subControls & QStyle::SC_DialTickmarks) {
+ painter->setPen(option->palette.dark().color().darker(120));
+ painter->drawLines(QStyleHelper::calcLines(option));
+ }
+
+ // Cache dial background
+ BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("qdial"));
+ p->setRenderHint(QPainter::Antialiasing);
+
+ const qreal d_ = r / 6;
+ const qreal dx = option->rect.x() + d_ + (width - 2 * r) / 2 + 1;
+ const qreal dy = option->rect.y() + d_ + (height - 2 * r) / 2 + 1;
+
+ QRectF br = QRectF(dx + 0.5, dy + 0.5,
+ int(r * 2 - 2 * d_ - 2),
+ int(r * 2 - 2 * d_ - 2));
+ buttonColor.setHsv(buttonColor .hue(),
+ qMin(140, buttonColor .saturation()),
+ qMax(180, buttonColor.value()));
+ QColor shadowColor(0, 0, 0, 20);
+
+ if (enabled) {
+ // Drop shadow
+ qreal shadowSize = qMax(1.0, penSize/2.0);
+ QRectF shadowRect= br.adjusted(-2*shadowSize, -2*shadowSize,
+ 2*shadowSize, 2*shadowSize);
+ QRadialGradient shadowGradient(shadowRect.center().x(),
+ shadowRect.center().y(), shadowRect.width()/2.0,
+ shadowRect.center().x(), shadowRect.center().y());
+ shadowGradient.setColorAt(0.91, QColor(0, 0, 0, 40));
+ shadowGradient.setColorAt(1.0, Qt::transparent);
+ p->setBrush(shadowGradient);
+ p->setPen(Qt::NoPen);
+ p->translate(shadowSize, shadowSize);
+ p->drawEllipse(shadowRect);
+ p->translate(-shadowSize, -shadowSize);
+
+ // Main gradient
+ QRadialGradient gradient(br.center().x() - br.width()/3, dy,
+ br.width()*1.3, br.center().x(),
+ br.center().y() - br.height()/2);
+ gradient.setColorAt(0, buttonColor.lighter(110));
+ gradient.setColorAt(0.5, buttonColor);
+ gradient.setColorAt(0.501, buttonColor.darker(102));
+ gradient.setColorAt(1, buttonColor.darker(115));
+ p->setBrush(gradient);
+ } else {
+ p->setBrush(Qt::NoBrush);
+ }
+
+ p->setPen(QPen(buttonColor.darker(280)));
+ p->drawEllipse(br);
+ p->setBrush(Qt::NoBrush);
+ p->setPen(buttonColor.lighter(110));
+ p->drawEllipse(br.adjusted(1, 1, -1, -1));
+
+ if (option->state & QStyle::State_HasFocus) {
+ QColor highlight = pal.highlight().color();
+ highlight.setHsv(highlight.hue(),
+ qMin(160, highlight.saturation()),
+ qMax(230, highlight.value()));
+ highlight.setAlpha(127);
+ p->setPen(QPen(highlight, 2.0));
+ p->setBrush(Qt::NoBrush);
+ p->drawEllipse(br.adjusted(-1, -1, 1, 1));
+ }
+
+ END_STYLE_PIXMAPCACHE
+
+ QPointF dp = calcRadialPos(option, 0.70);
+ buttonColor = buttonColor.lighter(104);
+ buttonColor.setAlphaF(0.8);
+ const qreal ds = r/7.0;
+ QRectF dialRect(dp.x() - ds, dp.y() - ds, 2*ds, 2*ds);
+ QRadialGradient dialGradient(dialRect.center().x() + dialRect.width()/2,
+ dialRect.center().y() + dialRect.width(),
+ dialRect.width()*2,
+ dialRect.center().x(), dialRect.center().y());
+ dialGradient.setColorAt(1, buttonColor.darker(140));
+ dialGradient.setColorAt(0.4, buttonColor.darker(120));
+ dialGradient.setColorAt(0, buttonColor.darker(110));
+ if (penSize > 3.0) {
+ painter->setPen(QPen(QColor(0, 0, 0, 25), penSize));
+ painter->drawLine(calcRadialPos(option, 0.90), calcRadialPos(option, 0.96));
+ }
+
+ painter->setBrush(dialGradient);
+ painter->setPen(QColor(255, 255, 255, 150));
+ painter->drawEllipse(dialRect.adjusted(-1, -1, 1, 1));
+ painter->setPen(QColor(0, 0, 0, 80));
+ painter->drawEllipse(dialRect);
+ painter->restore();
+}
+#endif //QT_NO_DIAL
+
+QT_END_NAMESPACE
diff --git a/src/gui/styles/qstylehelper_p.h b/src/gui/styles/qstylehelper_p.h
new file mode 100644
index 0000000..d9b2e28
--- /dev/null
+++ b/src/gui/styles/qstylehelper_p.h
@@ -0,0 +1,39 @@
+#include <QtCore/qglobal.h>
+#include <QtCore/qpoint.h>
+#include <QtGui/qpolygon.h>
+
+#ifndef QSTYLEHELPER_P_H
+#define QSTYLEHELPER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QPainter;
+class QStyleOptionSlider;
+class QStyleOption;
+
+namespace QStyleHelper
+{
+ extern const bool UsePixmapCache;
+ QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size);
+#ifndef QT_NO_DIAL
+ qreal angle(const QPointF &p1, const QPointF &p2);
+ QPolygonF calcLines(const QStyleOptionSlider *dial);
+ int calcBigLineSize(int radius);
+ void drawDial(const QStyleOptionSlider *dial, QPainter *painter);
+#endif //QT_NO_DIAL
+}
+
+QT_END_NAMESPACE
+
+#endif // QSTYLEHELPER_P_H
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index f22cd56..49ac57a 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -1514,20 +1514,11 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorRole fr, QPalette
void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const QWidget *w, bool embedded)
{
-#ifdef QT_NO_COMBOBOX
- const bool isReadOnlyCombo = false;
-#else
- const bool isReadOnlyCombo = qobject_cast<const QComboBox *>(w) != 0;
-#endif
-
if (bg && bg->brush.style() != Qt::NoBrush) {
- if (isReadOnlyCombo) {
- p->setBrush(cg, QPalette::Base, bg->brush); // for windows, windowxp
- p->setBrush(cg, QPalette::Button, bg->brush); // for plastique
- } else {
- p->setBrush(cg, w->backgroundRole(), bg->brush);
- //p->setBrush(cg, QPalette::Window, bg->brush);
- }
+ p->setBrush(cg, QPalette::Base, bg->brush); // for windows, windowxp
+ p->setBrush(cg, QPalette::Button, bg->brush); // for plastique
+ p->setBrush(cg, w->backgroundRole(), bg->brush);
+ p->setBrush(cg, QPalette::Window, bg->brush);
}
if (embedded) {
@@ -1542,12 +1533,9 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q
return;
if (pal->foreground.style() != Qt::NoBrush) {
- if (isReadOnlyCombo) {
- p->setBrush(cg, QPalette::ButtonText, pal->foreground);
- } else {
- p->setBrush(cg, w->foregroundRole(), pal->foreground);
- p->setBrush(cg, QPalette::WindowText, pal->foreground);
- }
+ p->setBrush(cg, QPalette::ButtonText, pal->foreground);
+ p->setBrush(cg, w->foregroundRole(), pal->foreground);
+ p->setBrush(cg, QPalette::WindowText, pal->foreground);
p->setBrush(cg, QPalette::Text, pal->foreground);
}
if (pal->selectionBackground.style() != Qt::NoBrush)
@@ -2916,6 +2904,10 @@ void QStyleSheetStyle::polish(QWidget *w)
if (ew->autoFillBackground()) {
ew->setAutoFillBackground(false);
autoFillDisabledWidgets->insert(w);
+ if (ew != w) { //eg. viewport of a scrollarea
+ //(in order to draw the background anyway in case we don't.)
+ ew->setAttribute(Qt::WA_StyledBackground, true);
+ }
}
if (!rule.hasBackground() || rule.background()->isTransparent() || rule.hasBox()
|| (!rule.hasNativeBorder() && !rule.border()->isOpaque()))
@@ -4345,8 +4337,16 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
return;
case PE_Widget:
- if (!rule.hasBackground())
+ if (!rule.hasBackground()) {
+ QWidget *container = containerWidget(w);
+ if (autoFillDisabledWidgets->contains(container)
+ && (container == w || !renderRule(container, opt).hasBackground())) {
+ //we do not have a background, but we disabled the autofillbackground anyway. so fill the background now.
+ // (this may happen if we have rules like :focus)
+ p->fillRect(opt->rect, opt->palette.brush(w->backgroundRole()));
+ }
break;
+ }
#ifndef QT_NO_SCROLLAREA
if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w)) {
diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp
index c52c700..1c03b9e 100644
--- a/src/gui/styles/qwindowsmobilestyle.cpp
+++ b/src/gui/styles/qwindowsmobilestyle.cpp
@@ -3401,6 +3401,9 @@ int QWindowsMobileStyle::styleHint(StyleHint hint, const QStyleOption *opt, cons
case SH_ScrollBar_ContextMenu:
ret = false;
break;
+ case SH_MenuBar_AltKeyNavigation:
+ ret = false;
+ break;
default:
ret = QWindowsStyle::styleHint(hint, opt, widget, returnData);
break;
diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp
index 00c3f99..bf3a3cb 100644
--- a/src/gui/styles/qwindowsstyle.cpp
+++ b/src/gui/styles/qwindowsstyle.cpp
@@ -67,6 +67,9 @@
#include "qpixmapcache.h"
#include "qwizard.h"
#include "qlistview.h"
+#include <private/qmath_p.h>
+#include <qmath.h>
+
#ifdef Q_WS_X11
#include "qfileinfo.h"
@@ -3177,6 +3180,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp
}
break;
#endif // QT_NO_SPINBOX
+
default:
QCommonStyle::drawComplexControl(cc, opt, p, widget);
}
diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp
index 4c3060d..013ca1e 100644
--- a/src/gui/styles/qwindowsvistastyle.cpp
+++ b/src/gui/styles/qwindowsvistastyle.cpp
@@ -801,12 +801,20 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
if (vopt->viewItemPosition == QStyleOptionViewItemV4::OnlyOne
|| vopt->viewItemPosition == QStyleOptionViewItemV4::Invalid)
painter->drawPixmap(pixmapRect.topLeft(), pixmap);
- else if (reverse ? rightSection : leftSection)
- painter->drawPixmap(pixmapRect, pixmap, srcRect.adjusted(0, 0, -frame, 0));
- else if (reverse ? leftSection : rightSection)
- painter->drawPixmap(pixmapRect, pixmap,
- srcRect.adjusted(frame, 0, 0, 0));
- else if (vopt->viewItemPosition == QStyleOptionViewItemV4::Middle)
+ else if (reverse ? rightSection : leftSection){
+ painter->drawPixmap(QRect(pixmapRect.topLeft(),
+ QSize(frame, pixmapRect.height())), pixmap,
+ QRect(QPoint(0, 0), QSize(frame, pixmapRect.height())));
+ painter->drawPixmap(pixmapRect.adjusted(frame, 0, 0, 0),
+ pixmap, srcRect.adjusted(frame, 0, -frame, 0));
+ } else if (reverse ? leftSection : rightSection) {
+ painter->drawPixmap(QRect(pixmapRect.topRight() - QPoint(frame - 1, 0),
+ QSize(frame, pixmapRect.height())), pixmap,
+ QRect(QPoint(pixmapRect.width() - frame, 0),
+ QSize(frame, pixmapRect.height())));
+ painter->drawPixmap(pixmapRect.adjusted(0, 0, -frame, 0),
+ pixmap, srcRect.adjusted(frame, 0, -frame, 0));
+ } else if (vopt->viewItemPosition == QStyleOptionViewItemV4::Middle)
painter->drawPixmap(pixmapRect, pixmap,
srcRect.adjusted(frame, 0, -frame, 0));
} else {
@@ -2388,6 +2396,9 @@ void QWindowsVistaStyle::polish(QWidget *widget)
else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) {
tree->viewport()->setAttribute(Qt::WA_Hover);
}
+ else if (QListView *list = qobject_cast<QListView *> (widget)) {
+ list->viewport()->setAttribute(Qt::WA_Hover);
+ }
}
/*!
diff --git a/src/gui/styles/qwindowsvistastyle_p.h b/src/gui/styles/qwindowsvistastyle_p.h
index 877bc50..cef2b71 100644
--- a/src/gui/styles/qwindowsvistastyle_p.h
+++ b/src/gui/styles/qwindowsvistastyle_p.h
@@ -76,6 +76,7 @@
#include <qscrollbar.h>
#include <qprogressbar.h>
#include <qdockwidget.h>
+#include <qlistview.h>
#include <qtreeview.h>
#include <qtextedit.h>
#include <qmessagebox.h>
diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp
index 9d735a7..639eff0 100644
--- a/src/gui/styles/qwindowsxpstyle.cpp
+++ b/src/gui/styles/qwindowsxpstyle.cpp
@@ -46,6 +46,7 @@
#include <private/qobject_p.h>
#include <private/qpaintengine_raster_p.h>
#include <private/qapplication_p.h>
+#include <private/qstylehelper_p.h>
#include <qlibrary.h>
#include <qpainter.h>
#include <qpaintengine.h>
@@ -607,7 +608,7 @@ void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
QPainter *painter = themeData.painter;
Q_ASSERT_X(painter != 0, "QWindowsXPStylePrivate::drawBackground()", "Trying to draw a theme part without a painter");
- if (!painter)
+ if (!painter || !painter->isActive())
return;
painter->save();
@@ -2834,7 +2835,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
bflags |= State_MouseOver;
}
}
-
+
QStyleOption tool(0);
tool.palette = toolbutton->palette;
if (toolbutton->subControls & SC_ToolButton) {
@@ -3164,6 +3165,12 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
}
break;
#endif //QT_NO_WORKSPACE
+#ifndef QT_NO_DIAL
+ case CC_Dial:
+ if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option))
+ QStyleHelper::drawDial(dial, p);
+ break;
+#endif // QT_NO_DIAL
default:
QWindowsStyle::drawComplexControl(cc, option, p, widget);
break;
diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri
index 376f834..2164e1e 100644
--- a/src/gui/styles/styles.pri
+++ b/src/gui/styles/styles.pri
@@ -7,12 +7,14 @@ HEADERS += \
styles/qstyleplugin.h \
styles/qcommonstylepixmaps_p.h \
styles/qcommonstyle.h \
+ styles/qstylehelper_p.h \
styles/qstylesheetstyle_p.h
SOURCES += \
styles/qstyle.cpp \
styles/qstylefactory.cpp \
styles/qstyleoption.cpp \
styles/qstyleplugin.cpp \
+ styles/qstylehelper.cpp \
styles/qcommonstyle.cpp \
styles/qstylesheetstyle.cpp \
styles/qstylesheetstyle_default.cpp
diff --git a/src/gui/text/qfontdatabase_qws.cpp b/src/gui/text/qfontdatabase_qws.cpp
index eb8a0cf..f62a6d1 100644
--- a/src/gui/text/qfontdatabase_qws.cpp
+++ b/src/gui/text/qfontdatabase_qws.cpp
@@ -58,6 +58,7 @@
#include "qabstractfontengine_qws.h"
#include "qabstractfontengine_p.h"
#include <qdatetime.h>
+#include "qplatformdefs.h"
// for mmap
#include <stdlib.h>
@@ -127,7 +128,7 @@ void QFontDatabasePrivate::addQPF2File(const QByteArray &file)
struct stat st;
if (stat(file.constData(), &st))
return;
- int f = ::open(file, O_RDONLY);
+ int f = ::open(file, O_RDONLY, 0);
if (f < 0)
return;
const uchar *data = (const uchar *)mmap(0, st.st_size, PROT_READ, MAP_SHARED, f, 0);
@@ -675,7 +676,7 @@ QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp,
qDebug() << "Resource not valid" << size->fileName;
}
#else
- int f = ::open(size->fileName, O_RDONLY);
+ int f = ::open(size->fileName, O_RDONLY, 0);
if (f >= 0) {
QFontEngineQPF *fe = new QFontEngineQPF(request, f);
if (fe->isValid())
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 45a25a4..cb0b436 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1051,7 +1051,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph
Q_ASSERT(antialias);
uchar *convoluted = new uchar[bitmap.rows*bitmap.pitch];
bool useLegacyLcdFilter = false;
-#if defined(FT_LCD_FILTER_H)
+#if defined(FC_LCD_FILTER) && defined(FT_LCD_FILTER_H)
useLegacyLcdFilter = (lcdFilterType == FT_LCD_FILTER_LEGACY);
#endif
uchar *buffer = bitmap.buffer;
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index 40d145a..6b5bd0f 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -120,7 +120,7 @@ OSStatus QMacFontPath::closePath(void *data)
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool)
+QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool kerning)
: QFontEngineMulti(0)
{
this->fontDef = fontDef;
@@ -135,12 +135,12 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, con
symbolicTraits |= kCTFontItalicTrait;
break;
}
-
+
QCFString name;
ATSFontGetName(atsFontRef, kATSOptionFlagsDefault, &name);
- QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pixelSize);
- QCFType<CTFontRef> baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, 0);
- ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, 0, symbolicTraits, symbolicTraits);
+ QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pointSize);
+ QCFType<CTFontRef> baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pointSize, 0);
+ ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pointSize, 0, symbolicTraits, symbolicTraits);
// CTFontCreateCopyWithSymbolicTraits returns NULL if we ask for a trait that does
// not exist for the given font. (for example italic)
@@ -149,16 +149,20 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, con
CFRetain(ctfont);
}
- const void *keys[] = { NSFontAttributeName };
- const void *values[] = { ctfont };
- attributeDict = CFDictionaryCreate(0, keys, values, 1,
+ attributeDict = CFDictionaryCreateMutable(0, 2,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
+ CFDictionaryAddValue(attributeDict, NSFontAttributeName, ctfont);
+ if (!kerning) {
+ float zero = 0.0;
+ QCFType<CFNumberRef> noKern = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &zero);
+ CFDictionaryAddValue(attributeDict, kCTKernAttributeName, &noKern);
+ }
QCoreTextFontEngine *fe = new QCoreTextFontEngine(ctfont, fontDef, this);
fe->ref.ref();
engines.append(fe);
-
+
}
QCoreTextFontEngineMulti::~QCoreTextFontEngineMulti()
@@ -172,7 +176,7 @@ uint QCoreTextFontEngineMulti::fontIndexForFont(CTFontRef id) const
if (CFEqual(engineAt(i)->ctfont, id))
return i;
}
-
+
QCoreTextFontEngineMulti *that = const_cast<QCoreTextFontEngineMulti *>(this);
QCoreTextFontEngine *fe = new QCoreTextFontEngine(id, fontDef, that);
fe->ref.ref();
@@ -223,7 +227,7 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttribs, NSFontAttributeName));
const uint fontIndex = (fontIndexForFont(runFont) << 24);
//NSLog(@"Run Font Name = %@", CTFontCopyFamilyName(runFont));
- QVarLengthArray<CGGlyph, 512> cgglyphs(0);
+ QVarLengthArray<CGGlyph, 512> cgglyphs(0);
const CGGlyph *tmpGlyphs = CTRunGetGlyphsPtr(run);
if (!tmpGlyphs) {
cgglyphs.resize(glyphCount);
@@ -256,7 +260,7 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
CFIndex k = 0;
CFIndex i = 0;
- for (i = stringRange.location;
+ for (i = stringRange.location;
(i < stringRange.location + stringRange.length) && (k < glyphCount); ++i) {
if (tmpIndices[k * rtlSign + rtlOffset] == i || i == stringRange.location) {
logClusters[i] = k + firstGlyphIndex;
@@ -277,10 +281,11 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
outAdvances_x[idx] = QFixed::fromReal(tmpPoints[i + 1].x - tmpPoints[i].x);
outAdvances_y[idx] = QFixed::fromReal(tmpPoints[i + 1].y - tmpPoints[i].y);
}
- double runWidth = ceil(CTRunGetTypographicBounds(run, range, 0, 0, 0));
- runWidth += tmpPoints[0].x;
+ CGSize lastGlyphAdvance;
+ CTFontGetAdvancesForGlyphs(runFont, kCTFontHorizontalOrientation, tmpGlyphs + glyphCount - 1, &lastGlyphAdvance, 1);
+
outGlyphs[rtl ? 0 : (glyphCount - 1)] = tmpGlyphs[glyphCount - 1] | fontIndex;
- outAdvances_x[rtl ? 0 : (glyphCount - 1)] = QFixed::fromReal(runWidth - tmpPoints[glyphCount - 1].x);
+ outAdvances_x[rtl ? 0 : (glyphCount - 1)] = QFixed::fromReal(lastGlyphAdvance.width).ceil();
}
outGlyphs += glyphCount;
outAttributes += glyphCount;
@@ -365,26 +370,26 @@ glyph_metrics_t QCoreTextFontEngine::boundingBox(glyph_t glyph)
ret.y = -QFixed::fromReal(rect.origin.y) - ret.height;
CGSize advances[1];
CTFontGetAdvancesForGlyphs(ctfont, kCTFontHorizontalOrientation, &g, advances, 1);
- ret.xoff = QFixed::fromReal(advances[0].width);
- ret.yoff = QFixed::fromReal(advances[0].height);
+ ret.xoff = QFixed::fromReal(advances[0].width).ceil();
+ ret.yoff = QFixed::fromReal(advances[0].height).ceil();
return ret;
}
QFixed QCoreTextFontEngine::ascent() const
{
- return QFixed::fromReal(CTFontGetAscent(ctfont));
+ return QFixed::fromReal(CTFontGetAscent(ctfont)).ceil();
}
QFixed QCoreTextFontEngine::descent() const
{
- return QFixed::fromReal(CTFontGetDescent(ctfont));
+ return QFixed::fromReal(CTFontGetDescent(ctfont)).ceil();
}
QFixed QCoreTextFontEngine::leading() const
{
- return QFixed::fromReal(CTFontGetLeading(ctfont));
+ return QFixed::fromReal(CTFontGetLeading(ctfont)).ceil();
}
QFixed QCoreTextFontEngine::xHeight() const
{
- return QFixed::fromReal(CTFontGetXHeight(ctfont));
+ return QFixed::fromReal(CTFontGetXHeight(ctfont)).ceil();
}
QFixed QCoreTextFontEngine::averageCharWidth() const
{
@@ -420,28 +425,28 @@ void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextIt
getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
if (glyphs.size() == 0)
return;
-
+
CGContextSetFontSize(ctx, fontDef.pixelSize);
-
+
CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
-
+
CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, -1, 0, -paintDeviceHeight);
-
+
CGAffineTransformConcat(cgMatrix, oldTextMatrix);
-
+
if (synthesisFlags & QFontEngine::SynthesizedItalic)
cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -tanf(14 * acosf(0) / 90), 1, 0, 0));
-
+
// ### cgMatrix = CGAffineTransformConcat(cgMatrix, transform);
-
+
CGContextSetTextMatrix(ctx, cgMatrix);
-
+
CGContextSetTextDrawingMode(ctx, kCGTextFill);
-
-
+
+
QVarLengthArray<CGSize> advances(glyphs.size());
QVarLengthArray<CGGlyph> cgGlyphs(glyphs.size());
-
+
for (int i = 0; i < glyphs.size() - 1; ++i) {
advances[i].width = (positions[i + 1].x - positions[i].x).toReal();
advances[i].height = (positions[i + 1].y - positions[i].y).toReal();
@@ -450,21 +455,21 @@ void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextIt
advances[glyphs.size() - 1].width = 0;
advances[glyphs.size() - 1].height = 0;
cgGlyphs[glyphs.size() - 1] = glyphs[glyphs.size() - 1];
-
+
CGContextSetFont(ctx, cgFont);
//NSLog(@"Font inDraw %@ ctfont %@", CGFontCopyFullName(cgFont), CTFontCopyFamilyName(ctfont));
-
+
CGContextSetTextPosition(ctx, positions[0].x.toReal(), positions[0].y.toReal());
-
+
CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
-
+
if (synthesisFlags & QFontEngine::SynthesizedBold) {
CGContextSetTextPosition(ctx, positions[0].x.toReal() + 0.5 * lineThickness().toReal(),
positions[0].y.toReal());
-
+
CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
}
-
+
CGContextSetTextMatrix(ctx, oldTextMatrix);
}
@@ -617,7 +622,7 @@ QFontEngine::FaceId QCoreTextFontEngine::faceId() const
bool QCoreTextFontEngine::canRender(const QChar *string, int len)
{
- QCFType<CTFontRef> retFont = CTFontCreateForString(ctfont,
+ QCFType<CTFontRef> retFont = CTFontCreateForString(ctfont,
QCFType<CFStringRef>(CFStringCreateWithCharactersNoCopy(0,
reinterpret_cast<const UniChar *>(string),
len, kCFAllocatorNull)),
@@ -667,7 +672,7 @@ QFontEngineMacMulti::QFontEngineMacMulti(const ATSFontFamilyRef &atsFamily, cons
} else {
if (fontDef.weight >= QFont::Bold)
fntStyle |= ::bold;
- if (fontDef.style != QFont::StyleNormal)
+ if (fontDef.style != QFont::StyleNormal)
fntStyle |= ::italic;
FMFontStyle intrinsicStyle;
@@ -950,7 +955,7 @@ bool QFontEngineMacMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *
tmpItem.length = charCount;
tmpItem.glyphs = shaperItem.glyphs.mid(glyphIdx, glyphCount);
tmpItem.log_clusters = shaperItem.log_clusters + charIdx;
- if (!stringToCMapInternal(tmpItem.string + tmpItem.from, tmpItem.length,
+ if (!stringToCMapInternal(tmpItem.string + tmpItem.from, tmpItem.length,
&tmpItem.glyphs, &glyphCount, flags,
&tmpItem)) {
*nglyphs = glyphIdx + glyphCount;
@@ -1216,12 +1221,12 @@ QFontEngineMac::QFontEngineMac(ATSUStyle baseStyle, ATSUFontID fontID, const QFo
transform = multiEngine->transform;
else
transform = CGAffineTransformIdentity;
-
+
ATSUTextMeasurement metric;
ATSUGetAttribute(style, kATSUAscentTag, sizeof(metric), &metric, 0);
m_ascent = FixRound(metric);
-
+
ATSUGetAttribute(style, kATSUDescentTag, sizeof(metric), &metric, 0);
m_descent = FixRound(metric);
@@ -1417,11 +1422,16 @@ void QFontEngineMac::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, in
addGlyphsToPathHelper(style, glyphs, positions, numGlyphs, path);
}
-QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph)
+
+/*!
+ Helper function for alphaMapForGlyph and alphaRGBMapForGlyph. The two are identical, except for
+ the subpixel antialiasing...
+*/
+QImage QFontEngineMac::imageForGlyph(glyph_t glyph, int margin, bool colorful)
{
const glyph_metrics_t br = boundingBox(glyph);
QImage im(qRound(br.width)+2, qRound(br.height)+4, QImage::Format_RGB32);
- im.fill(0);
+ im.fill(0xff000000);
CGColorSpaceRef colorspace = QCoreGraphicsPaintEngine::macGenericColorSpace();
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
@@ -1439,7 +1449,7 @@ QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph)
CGContextSetFontSize(ctx, fontDef.pixelSize);
CGContextSetShouldAntialias(ctx, fontDef.pointSize > qt_antialiasing_threshold && !(fontDef.styleStrategy & QFont::NoAntialias));
// turn off sub-pixel hinting - no support for that in OpenGL
- CGContextSetShouldSmoothFonts(ctx, false);
+ CGContextSetShouldSmoothFonts(ctx, colorful);
CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
CGAffineTransformConcat(cgMatrix, oldTextMatrix);
@@ -1471,6 +1481,13 @@ QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph)
CGContextRelease(ctx);
+ return im;
+}
+
+QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph)
+{
+ QImage im = imageForGlyph(glyph, 2, false);
+
QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
QVector<QRgb> colors(256);
for (int i=0; i<256; ++i)
@@ -1490,6 +1507,32 @@ QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph)
return indexed;
}
+QImage QFontEngineMac::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTransform &t)
+{
+ QImage im = imageForGlyph(glyph, margin, true);
+
+ if (t.type() >= QTransform::TxScale) {
+ im = im.transformed(t);
+ }
+
+ extern uchar qt_pow_rgb_gamma[256];
+
+ // gamma correct the pixels back to linear color space...
+ for (int y=0; y<im.height(); ++y) {
+ uint *pixels = (uint *) im.scanLine(y);
+ for (int x=0; x<im.width(); ++x) {
+ uint p = pixels[x];
+ uint r = qt_pow_rgb_gamma[qRed(p)];
+ uint g = qt_pow_rgb_gamma[qGreen(p)];
+ uint b = qt_pow_rgb_gamma[qBlue(p)];
+ pixels[x] = (r << 16) | (g << 8) | b | 0xff000000;
+ }
+ }
+
+ return im;
+}
+
+
bool QFontEngineMac::canRender(const QChar *string, int len)
{
Q_ASSERT(false);
@@ -1643,7 +1686,7 @@ QFontEngine::Properties QFontEngineMac::properties() const
if (ATSFontGetTable(atsFont, MAKE_TAG('p', 'o', 's', 't'), 10, 2, &lw, 0) == noErr)
lw = qFromBigEndian<quint16>(lw);
props.lineWidth = lw;
-
+
// CTFontCopyPostScriptName
QCFString psName;
if (ATSFontGetPostScriptName(FMGetATSFontRefFromFont(fontID), kATSOptionFlagsDefault, &psName) == noErr)
@@ -1658,7 +1701,7 @@ void QFontEngineMac::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_m
ATSUCreateAndCopyStyle(style, &unscaledStyle);
int emSquare = properties().emSquare.toInt();
-
+
const int maxAttributeCount = 4;
ATSUAttributeTag tags[maxAttributeCount + 1];
ByteCount sizes[maxAttributeCount + 1];
@@ -1670,7 +1713,7 @@ void QFontEngineMac::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_m
sizes[attributeCount] = sizeof(size);
values[attributeCount] = &size;
++attributeCount;
-
+
Q_ASSERT(attributeCount < maxAttributeCount + 1);
OSStatus err = ATSUSetAttributes(unscaledStyle, attributeCount, tags, sizes, values);
Q_ASSERT(err == noErr);
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index e289aa9..8f6b92a 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -480,7 +480,7 @@ private:
uint fontIndexForFont(CTFontRef id) const;
CTFontRef ctfont;
- mutable QCFType<CFDictionaryRef> attributeDict;
+ mutable QCFType<CFMutableDictionaryRef> attributeDict;
friend class QFontDialogPrivate;
};
@@ -525,8 +525,11 @@ public:
virtual Properties properties() const;
virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
virtual QImage alphaMapForGlyph(glyph_t);
+ virtual QImage alphaRGBMapForGlyph(glyph_t, int margin, const QTransform &t);
private:
+ QImage imageForGlyph(glyph_t glyph, int margin, bool colorful);
+
ATSUFontID fontID;
QCFType<CGFontRef> cgFont;
ATSUStyle style;
diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp
index e9fcac4..b7d1c59 100644
--- a/src/gui/text/qfontengine_qpf.cpp
+++ b/src/gui/text/qfontengine_qpf.cpp
@@ -252,7 +252,7 @@ QList<QByteArray> QFontEngineQPF::cleanUpAfterClientCrash(const QList<int> &cras
for (int i = 0; i < int(dir.count()); ++i) {
const QByteArray fileName = QFile::encodeName(dir.absoluteFilePath(dir[i]));
- int fd = ::open(fileName.constData(), O_RDONLY);
+ int fd = ::open(fileName.constData(), O_RDONLY, 0);
if (fd >= 0) {
void *header = ::mmap(0, sizeof(QFontEngineQPF::Header), PROT_READ, MAP_SHARED, fd, 0);
if (header && header != MAP_FAILED) {
@@ -331,9 +331,9 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng
qDebug() << "found existing qpf:" << fileName;
#endif
if (::access(encodedName, W_OK | R_OK) == 0)
- fd = ::open(encodedName, O_RDWR);
+ fd = ::open(encodedName, O_RDWR, 0);
else if (::access(encodedName, R_OK) == 0)
- fd = ::open(encodedName, O_RDONLY);
+ fd = ::open(encodedName, O_RDONLY, 0);
} else {
#if defined(DEBUG_FONTENGINE)
qDebug() << "creating qpf on the fly:" << fileName;
@@ -347,7 +347,7 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng
generator.generate();
buffer.close();
const QByteArray &data = buffer.data();
- ::write(fd, data.constData(), data.size());
+ QT_WRITE(fd, data.constData(), data.size());
}
}
}
@@ -893,8 +893,8 @@ void QFontEngineQPF::loadGlyph(glyph_t glyph)
g.y = qRound(metrics.y);
g.advance = qRound(metrics.xoff);
- ::write(fd, &g, sizeof(g));
- ::write(fd, img.bits(), img.numBytes());
+ QT_WRITE(fd, &g, sizeof(g));
+ QT_WRITE(fd, img.bits(), img.numBytes());
glyphPos = oldSize - glyphDataOffset;
#if 0 && defined(DEBUG_FONTENGINE)
diff --git a/src/gui/text/qfontengine_qws.cpp b/src/gui/text/qfontengine_qws.cpp
index d776329..10aef4c 100644
--- a/src/gui/text/qfontengine_qws.cpp
+++ b/src/gui/text/qfontengine_qws.cpp
@@ -387,7 +387,7 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn)
{
cache_cost = 1;
- int f = ::open( QFile::encodeName(fn), O_RDONLY );
+ int f = ::open( QFile::encodeName(fn), O_RDONLY, 0);
Q_ASSERT(f>=0);
QT_STATBUF st;
if ( QT_FSTAT( f, &st ) )
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index c337783..9c3d6c2 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -287,6 +287,7 @@ public:
private:
Q_DISABLE_COPY(QTextDocument)
Q_DECLARE_PRIVATE(QTextDocument)
+ friend class QTextObjectPrivate;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QTextDocument::FindFlags)
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 320ecbf..05ddf47 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -1484,7 +1484,6 @@ QTextObject *QTextDocumentPrivate::createObject(const QTextFormat &f, int object
QTextObject *obj = document()->createObject(f);
if (obj) {
- obj->d_func()->pieceTable = this;
obj->d_func()->objectIndex = objectIndex == -1 ? formats.createObjectIndex(f) : objectIndex;
objects[obj->d_func()->objectIndex] = obj;
}
diff --git a/src/gui/text/qtextlist.cpp b/src/gui/text/qtextlist.cpp
index e305027..d1a3361 100644
--- a/src/gui/text/qtextlist.cpp
+++ b/src/gui/text/qtextlist.cpp
@@ -50,6 +50,11 @@ QT_BEGIN_NAMESPACE
class QTextListPrivate : public QTextBlockGroupPrivate
{
+public:
+ QTextListPrivate(QTextDocument *doc)
+ : QTextBlockGroupPrivate(doc)
+ {
+ }
};
/*!
@@ -111,7 +116,7 @@ class QTextListPrivate : public QTextBlockGroupPrivate
/*! \internal
*/
QTextList::QTextList(QTextDocument *doc)
- : QTextBlockGroup(*new QTextListPrivate, doc)
+ : QTextBlockGroup(*new QTextListPrivate(doc), doc)
{
}
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp
index 1645a21..3f4c8e5 100644
--- a/src/gui/text/qtextobject.cpp
+++ b/src/gui/text/qtextobject.cpp
@@ -88,7 +88,7 @@ QT_BEGIN_NAMESPACE
from QTextDocument::createObject().
*/
QTextObject::QTextObject(QTextDocument *doc)
- : QObject(*new QTextObjectPrivate, doc)
+ : QObject(*new QTextObjectPrivate(doc), doc)
{
}
@@ -98,7 +98,7 @@ QTextObject::QTextObject(QTextDocument *doc)
\internal
*/
QTextObject::QTextObject(QTextObjectPrivate &p, QTextDocument *doc)
- :QObject(p, doc)
+ : QObject(p, doc)
{
}
@@ -221,7 +221,7 @@ void QTextBlockGroupPrivate::markBlocksDirty()
QTextDocument::createObject().
*/
QTextBlockGroup::QTextBlockGroup(QTextDocument *doc)
- : QTextObject(*new QTextBlockGroupPrivate, doc)
+ : QTextObject(*new QTextBlockGroupPrivate(doc), doc)
{
}
@@ -410,7 +410,7 @@ QTextFrameLayoutData::~QTextFrameLayoutData()
Creates a new empty frame for the text \a document.
*/
QTextFrame::QTextFrame(QTextDocument *doc)
- : QTextObject(*new QTextFramePrivate, doc)
+ : QTextObject(*new QTextFramePrivate(doc), doc)
{
Q_D(QTextFrame);
d->fragment_start = 0;
diff --git a/src/gui/text/qtextobject_p.h b/src/gui/text/qtextobject_p.h
index b00a16a..dd05eb4 100644
--- a/src/gui/text/qtextobject_p.h
+++ b/src/gui/text/qtextobject_p.h
@@ -55,6 +55,7 @@
#include "QtGui/qtextobject.h"
#include "private/qobject_p.h"
+#include "QtGui/qtextdocument.h"
QT_BEGIN_NAMESPACE
@@ -64,6 +65,10 @@ class QTextObjectPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QTextObject)
public:
+ QTextObjectPrivate(QTextDocument *doc)
+ : pieceTable(doc->d_func()), objectIndex(-1)
+ {
+ }
QTextDocumentPrivate *pieceTable;
int objectIndex;
};
@@ -72,7 +77,10 @@ class QTextBlockGroupPrivate : public QTextObjectPrivate
{
Q_DECLARE_PUBLIC(QTextBlockGroup)
public:
-
+ QTextBlockGroupPrivate(QTextDocument *doc)
+ : QTextObjectPrivate(doc)
+ {
+ }
typedef QList<QTextBlock> BlockList;
BlockList blocks;
void markBlocksDirty();
@@ -85,7 +93,10 @@ class QTextFramePrivate : public QTextObjectPrivate
friend class QTextDocumentPrivate;
Q_DECLARE_PUBLIC(QTextFrame)
public:
-
+ QTextFramePrivate(QTextDocument *doc)
+ : QTextObjectPrivate(doc)
+ {
+ }
virtual void fragmentAdded(const QChar &type, uint fragment);
virtual void fragmentRemoved(const QChar &type, uint fragment);
void remove_me();
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index 375bb09..ba1c04f 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -553,7 +553,7 @@ void QTextTablePrivate::update() const
/*! \internal
*/
QTextTable::QTextTable(QTextDocument *doc)
- : QTextFrame(*new QTextTablePrivate, doc)
+ : QTextFrame(*new QTextTablePrivate(doc), doc)
{
}
diff --git a/src/gui/text/qtexttable_p.h b/src/gui/text/qtexttable_p.h
index 1ba3a3f..f2b45b6 100644
--- a/src/gui/text/qtexttable_p.h
+++ b/src/gui/text/qtexttable_p.h
@@ -62,7 +62,7 @@ class QTextTablePrivate : public QTextFramePrivate
{
Q_DECLARE_PUBLIC(QTextTable)
public:
- QTextTablePrivate() : grid(0), nRows(0), dirty(true), blockFragmentUpdates(false) {}
+ QTextTablePrivate(QTextDocument *document) : QTextFramePrivate(document), grid(0), nRows(0), dirty(true), blockFragmentUpdates(false) {}
~QTextTablePrivate();
static QTextTable *createTable(QTextDocumentPrivate *, int pos, int rows, int cols, const QTextTableFormat &tableFormat);
diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp
index aeb7e91..7571dfe 100644
--- a/src/gui/util/qcompleter.cpp
+++ b/src/gui/util/qcompleter.cpp
@@ -1079,7 +1079,14 @@ void QCompleter::setPopup(QAbstractItemView *popup)
popup->setModel(d->proxy);
popup->hide();
popup->setParent(0, Qt::Popup);
+
+ Qt::FocusPolicy origPolicy;
+ if (d->widget)
+ origPolicy = d->widget->focusPolicy();
popup->setFocusPolicy(Qt::NoFocus);
+ if (d->widget)
+ d->widget->setFocusPolicy(origPolicy);
+
popup->setFocusProxy(d->widget);
popup->installEventFilter(this);
popup->setItemDelegate(new QCompleterItemDelegate(popup));
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp
index 0fe1d69..84aa16e 100644
--- a/src/gui/util/qdesktopservices.cpp
+++ b/src/gui/util/qdesktopservices.cpp
@@ -157,6 +157,11 @@ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
If the URL is a reference to a local file (i.e., the URL scheme is "file") then
it will be opened with a suitable application instead of a Web browser.
+ The following example opens a file on the Windows file system residing on a path
+ that contains spaces:
+
+ \snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 2
+
If a \c mailto URL is specified, the user's e-mail client will be used to open a
composer window containing the options specified in the URL, similar to the way
\c mailto links are handled by a Web browser.
diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/gui/widgets/qabstractbutton.cpp
index c25253a..f2a9ceb 100644
--- a/src/gui/widgets/qabstractbutton.cpp
+++ b/src/gui/widgets/qabstractbutton.cpp
@@ -1250,15 +1250,6 @@ void QAbstractButton::timerEvent(QTimerEvent *e)
}
}
-#if defined(Q_OS_WINCE) && !defined(QT_NO_CONTEXTMENU)
-/*! \reimp */
-void QAbstractButton::contextMenuEvent(QContextMenuEvent *e)
-{
- e->ignore();
- setDown(false);
-}
-#endif
-
/*! \reimp */
void QAbstractButton::focusInEvent(QFocusEvent *e)
{
diff --git a/src/gui/widgets/qabstractbutton.h b/src/gui/widgets/qabstractbutton.h
index 6503a56..f0cbb05 100644
--- a/src/gui/widgets/qabstractbutton.h
+++ b/src/gui/widgets/qabstractbutton.h
@@ -143,9 +143,6 @@ protected:
void focusOutEvent(QFocusEvent *e);
void changeEvent(QEvent *e);
void timerEvent(QTimerEvent *e);
-#ifdef Q_OS_WINCE
- void contextMenuEvent(QContextMenuEvent *e);
-#endif
#ifdef QT3_SUPPORT
public:
diff --git a/src/gui/widgets/qcocoamenu_mac.mm b/src/gui/widgets/qcocoamenu_mac.mm
index c92dfc0..6434289 100644
--- a/src/gui/widgets/qcocoamenu_mac.mm
+++ b/src/gui/widgets/qcocoamenu_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#include "qmacdefines_mac.h"
#include "qapplication.h"
@@ -55,11 +55,17 @@
QT_FORWARD_DECLARE_CLASS(QAction)
QT_FORWARD_DECLARE_CLASS(QWidget)
QT_FORWARD_DECLARE_CLASS(QApplication)
+QT_FORWARD_DECLARE_CLASS(QCoreApplication)
+QT_FORWARD_DECLARE_CLASS(QApplicationPrivate)
+QT_FORWARD_DECLARE_CLASS(QKeyEvent)
+QT_FORWARD_DECLARE_CLASS(QEvent)
QT_BEGIN_NAMESPACE
extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); //qapplication.cpp
QT_END_NAMESPACE
+QT_USE_NAMESPACE
+
@implementation QT_MANGLE_NAMESPACE(QCocoaMenu)
- (id)initWithQMenu:(QMenu*)menu
@@ -134,8 +140,9 @@ QT_END_NAMESPACE
// If it does, then we will first send the key sequence to the QWidget that has focus
// since (in Qt's eyes) it needs to a chance at the key event first. If the widget
// accepts the key event, we then return YES, but set the target and action to be nil,
- // which means that the action should not be triggered. In every other case we return
- // NO, which means that Cocoa can do as it pleases (i.e., fire the menu action).
+ // which means that the action should not be triggered, and instead dispatch the event ourselves.
+ // In every other case we return NO, which means that Cocoa can do as it pleases
+ // (i.e., fire the menu action).
NSMenuItem *whichItem;
if ([self hasShortcut:menu
forKey:[event characters]
@@ -158,9 +165,11 @@ QT_END_NAMESPACE
accel_ev.ignore();
qt_sendSpontaneousEvent(widget, &accel_ev);
if (accel_ev.isAccepted()) {
- *target = nil;
- *action = nil;
- return YES;
+ if (qt_dispatchKeyEvent(event, widget)) {
+ *target = nil;
+ *action = nil;
+ return YES;
+ }
}
}
}
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index c7e2590..f30ece4 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -109,7 +109,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
const QModelIndex &index) const
{
QStyleOptionMenuItem menuOption;
- menuOption.palette = QComboBoxPrivate::viewContainerPalette(mCombo).resolve(QApplication::palette("QMenu"));
+ menuOption.palette = option.palette.resolve(QApplication::palette("QMenu"));
menuOption.state = QStyle::State_None;
if (mCombo->window()->isActiveWindow())
menuOption.state = QStyle::State_Active;
@@ -949,6 +949,7 @@ QComboBoxPrivateContainer* QComboBoxPrivate::viewContainer()
container->itemView()->setTextElideMode(Qt::ElideMiddle);
updateDelegate();
updateLayoutDirection();
+ updateViewContainerPaletteAndOpacity();
QObject::connect(container, SIGNAL(itemSelected(QModelIndex)),
q, SLOT(_q_itemSelected(QModelIndex)));
QObject::connect(container->itemView()->selectionModel(),
@@ -1051,6 +1052,27 @@ void QComboBoxPrivate::_q_rowsRemoved(const QModelIndex &parent, int /*start*/,
}
+void QComboBoxPrivate::updateViewContainerPaletteAndOpacity()
+{
+ if (!container)
+ return;
+ Q_Q(QComboBox);
+ QStyleOptionComboBox opt;
+ q->initStyleOption(&opt);
+#ifndef QT_NO_MENU
+ if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) {
+ QMenu menu;
+ menu.ensurePolished();
+ container->setPalette(menu.palette());
+ container->setWindowOpacity(menu.windowOpacity());
+ } else
+#endif
+ {
+ container->setPalette(q->palette());
+ container->setWindowOpacity(1.0);
+ }
+}
+
/*!
Initialize \a option with the values from this QComboBox. This method
is useful for subclasses when they need a QStyleOptionComboBox, but don't want
@@ -2572,20 +2594,7 @@ void QComboBox::changeEvent(QEvent *e)
hidePopup();
break;
case QEvent::PaletteChange: {
- QStyleOptionComboBox opt;
- initStyleOption(&opt);
-#ifndef QT_NO_MENU
- if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) {
- QMenu menu;
- menu.ensurePolished();
- d->viewContainer()->setPalette(menu.palette());
- d->viewContainer()->setWindowOpacity(menu.windowOpacity());
- } else
-#endif
- {
- d->viewContainer()->setPalette(palette());
- d->viewContainer()->setWindowOpacity(1.0);
- }
+ d->updateViewContainerPaletteAndOpacity();
break;
}
case QEvent::FontChange:
diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h
index f1203dc..a0b76cf 100644
--- a/src/gui/widgets/qcombobox_p.h
+++ b/src/gui/widgets/qcombobox_p.h
@@ -265,7 +265,7 @@ protected:
const QStyleOptionViewItem &option,
const QModelIndex &index) const {
QStyleOptionMenuItem opt = getStyleOption(option, index);
- painter->eraseRect(option.rect);
+ painter->fillRect(option.rect, opt.palette.background());
mCombo->style()->drawControl(QStyle::CE_MenuItem, &opt, painter, mCombo);
}
QSize sizeHint(const QStyleOptionViewItem &option,
@@ -370,6 +370,7 @@ public:
void updateDelegate();
void keyboardSearchString(const QString &text);
void modelChanged();
+ void updateViewContainerPaletteAndOpacity();
QAbstractItemModel *model;
QLineEdit *lineEdit;
diff --git a/src/gui/widgets/qcommandlinkbutton.cpp b/src/gui/widgets/qcommandlinkbutton.cpp
index 13ee6af..92d89a1 100644
--- a/src/gui/widgets/qcommandlinkbutton.cpp
+++ b/src/gui/widgets/qcommandlinkbutton.cpp
@@ -140,10 +140,12 @@ QFont QCommandLinkButtonPrivate::titleFont() const
Q_Q(const QCommandLinkButton);
QFont font = q->font();
if (usingVistaStyle()) {
- font.setPointSizeF(12.0);
+ if (!q->testAttribute(Qt::WA_SetFont))
+ font.setPointSizeF(12.0);
} else {
font.setBold(true);
- font.setPointSizeF(9.0);
+ if (!q->testAttribute(Qt::WA_SetFont))
+ font.setPointSizeF(9.0);
}
return font;
}
@@ -152,7 +154,8 @@ QFont QCommandLinkButtonPrivate::descriptionFont() const
{
Q_Q(const QCommandLinkButton);
QFont font = q->font();
- font.setPointSizeF(9.0);
+ if (!q->testAttribute(Qt::WA_SetFont))
+ font.setPointSizeF(9.0);
return font;
}
diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp
index 246da95..4a95292 100644
--- a/src/gui/widgets/qdialogbuttonbox.cpp
+++ b/src/gui/widgets/qdialogbuttonbox.cpp
@@ -752,7 +752,8 @@ QDialogButtonBox::~QDialogButtonBox()
\value KdeLayout Use a policy appropriate for applications on KDE.
\value GnomeLayout Use a policy appropriate for applications on GNOME.
- The button layout is specified by the \l{style()}{current style}.
+ The button layout is specified by the \l{style()}{current style}. However,
+ on the X11 platform, it may be influenced by the desktop environment.
*/
/*!
diff --git a/src/gui/widgets/qlcdnumber.cpp b/src/gui/widgets/qlcdnumber.cpp
index 0136f1a..9d98dbc 100644
--- a/src/gui/widgets/qlcdnumber.cpp
+++ b/src/gui/widgets/qlcdnumber.cpp
@@ -403,7 +403,7 @@ QLCDNumber::QLCDNumber(QWidget *parent)
Constructs an LCD number, sets the number of digits to \a
numDigits, the base to decimal, the decimal point mode to 'small'
and the frame style to a raised box. The segmentStyle() is set to
- \c Outline.
+ \c Filled.
The \a parent argument is passed to the QFrame constructor.
@@ -427,7 +427,7 @@ void QLCDNumberPrivate::init()
base = QLCDNumber::Dec;
smallPoint = false;
q->setNumDigits(ndigits);
- q->setSegmentStyle(QLCDNumber::Outline);
+ q->setSegmentStyle(QLCDNumber::Filled);
q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
}
@@ -756,6 +756,10 @@ void QLCDNumber::paintEvent(QPaintEvent *)
Q_D(QLCDNumber);
QPainter p(this);
drawFrame(&p);
+ p.setRenderHint(QPainter::Antialiasing);
+ if (d->shadow)
+ p.translate(0.5, 0.5);
+
if (d->smallPoint)
d->drawString(d->digitStr, p, &d->points, false);
else
@@ -1070,7 +1074,7 @@ void QLCDNumberPrivate::drawSegment(const QPoint &pos, char segmentNo, QPainter
q->objectName().toLocal8Bit().constData(), segmentNo);
}
// End exact copy
- p.setPen(fgColor);
+ p.setPen(Qt::NoPen);
p.setBrush(fgColor);
p.drawPolygon(a);
p.setBrush(Qt::NoBrush);
@@ -1218,8 +1222,8 @@ void QLCDNumberPrivate::drawSegment(const QPoint &pos, char segmentNo, QPainter
\header \i Style \i Result
\row \i \c Outline
\i Produces raised segments filled with the background color
- (this is the default).
\row \i \c Filled
+ (this is the default).
\i Produces raised segments filled with the foreground color.
\row \i \c Flat
\i Produces flat segments filled with the foreground color.
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index b03df9e..e243ad0 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -3523,6 +3523,8 @@ void QLineEditPrivate::redo() {
case RemoveSelection:
case DeleteSelection:
text.remove(cmd.pos, 1);
+ selstart = cmd.selStart;
+ selend = cmd.selEnd;
cursor = cmd.pos;
break;
case Separator:
diff --git a/src/gui/widgets/qmaccocoaviewcontainer_mac.mm b/src/gui/widgets/qmaccocoaviewcontainer_mac.mm
index 710af6a..380e983 100644
--- a/src/gui/widgets/qmaccocoaviewcontainer_mac.mm
+++ b/src/gui/widgets/qmaccocoaviewcontainer_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#import <Cocoa/Cocoa.h>
#include <private/qwidget_p.h>
diff --git a/src/gui/widgets/qmacnativewidget_mac.mm b/src/gui/widgets/qmacnativewidget_mac.mm
index 1bc0430..0f4edf9 100644
--- a/src/gui/widgets/qmacnativewidget_mac.mm
+++ b/src/gui/widgets/qmacnativewidget_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#import <Cocoa/Cocoa.h>
#import <private/qcocoaview_mac_p.h>
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index 46d6471..2abc9e8 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -481,7 +481,7 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar)
oldMenuBar->deleteLater();
}
#ifdef Q_OS_WINCE
- if (menuBar->size().height() > 0)
+ if (menuBar && menuBar->size().height() > 0)
#endif
d->layout->setMenuBar(menuBar);
}
diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm
index 950f758..c807afb 100644
--- a/src/gui/widgets/qmainwindowlayout_mac.mm
+++ b/src/gui/widgets/qmainwindowlayout_mac.mm
@@ -1,3 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
#include <private/qmainwindowlayout_p.h>
#include <qtoolbar.h>
#include <private/qtoolbarlayout_p.h>
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index ed3e338..7396a9d 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -2889,8 +2889,8 @@ void QMenu::internalDelayedPopup()
int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this);
const QRect actionRect(d->actionRect(d->currentAction));
const QSize menuSize(d->activeMenu->sizeHint());
- const QPoint rightPos(mapToGlobal(QPoint(rect().right() + subMenuOffset + 1, actionRect.top())));
- const QPoint leftPos(mapToGlobal(QPoint(rect().left() - subMenuOffset - menuSize.width(), actionRect.top())));
+ const QPoint rightPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top())));
+ const QPoint leftPos(mapToGlobal(QPoint(actionRect.left() - subMenuOffset - menuSize.width(), actionRect.top())));
QPoint pos(rightPos);
QMenu *caused = qobject_cast<QMenu*>(d->activeMenu->d_func()->causedPopup.widget);
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 2e9201d..a51ed2d 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -370,11 +370,16 @@ void QPlainTextDocumentLayout::layoutBlock(const QTextBlock &block)
extraMargin += fm.width(QChar(0x21B5));
}
tl->beginLayout();
+ qreal availableWidth = d->width;
+ if (availableWidth <= 0) {
+ availableWidth = INT_MAX; // similar to text edit with pageSize.width == 0
+ }
+ availableWidth -= 2*margin + extraMargin;
while (1) {
QTextLine line = tl->createLine();
if (!line.isValid())
break;
- line.setLineWidth(d->width - 2*margin - extraMargin);
+ line.setLineWidth(availableWidth);
height += leading;
line.setPosition(QPointF(margin, height));
diff --git a/src/gui/widgets/qsplitter.cpp b/src/gui/widgets/qsplitter.cpp
index bf8af35..06774bc 100644
--- a/src/gui/widgets/qsplitter.cpp
+++ b/src/gui/widgets/qsplitter.cpp
@@ -119,7 +119,6 @@ QSplitterHandle::QSplitterHandle(Qt::Orientation orientation, QSplitter *parent)
{
Q_D(QSplitterHandle);
d->s = parent;
- d->hover = false;
setOrientation(orientation);
}
@@ -269,8 +268,11 @@ void QSplitterHandle::mouseMoveEvent(QMouseEvent *e)
void QSplitterHandle::mousePressEvent(QMouseEvent *e)
{
Q_D(QSplitterHandle);
- if (e->button() == Qt::LeftButton)
+ if (e->button() == Qt::LeftButton) {
d->mouseOffset = d->pick(e->pos());
+ d->pressed = true;
+ update();
+ }
}
/*!
@@ -285,6 +287,10 @@ void QSplitterHandle::mouseReleaseEvent(QMouseEvent *e)
d->s->setRubberBand(-1);
moveSplitter(pos);
}
+ if (e->button() == Qt::LeftButton) {
+ d->pressed = false;
+ update();
+ }
}
/*!
@@ -303,6 +309,8 @@ void QSplitterHandle::paintEvent(QPaintEvent *)
opt.state = QStyle::State_None;
if (d->hover)
opt.state |= QStyle::State_MouseOver;
+ if (d->pressed)
+ opt.state |= QStyle::State_Sunken;
if (isEnabled())
opt.state |= QStyle::State_Enabled;
parentWidget()->style()->drawControl(QStyle::CE_Splitter, &opt, &p, d->s);
diff --git a/src/gui/widgets/qsplitter_p.h b/src/gui/widgets/qsplitter_p.h
index 5cc43af..9f6fe0c 100644
--- a/src/gui/widgets/qsplitter_p.h
+++ b/src/gui/widgets/qsplitter_p.h
@@ -131,16 +131,17 @@ class QSplitterHandlePrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QSplitterHandle)
public:
- QSplitterHandlePrivate() : orient(Qt::Horizontal), opaq(false), s(0), mouseOffset(0) {}
+ QSplitterHandlePrivate() : s(0), orient(Qt::Horizontal), mouseOffset(0), opaq(false), hover(false), pressed(false) {}
inline int pick(const QPoint &pos) const
{ return orient == Qt::Horizontal ? pos.x() : pos.y(); }
- Qt::Orientation orient;
- bool opaq;
QSplitter *s;
- bool hover;
+ Qt::Orientation orient;
int mouseOffset;
+ bool opaq : 1;
+ bool hover : 1;
+ bool pressed : 1;
};
QT_END_NAMESPACE
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index 7d970ad..b6e6b6d 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -131,7 +131,7 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const
option->state &= ~QStyle::State_Enabled;
if (isActiveWindow())
option->state |= QStyle::State_Active;
- if (option->rect == d->hoverRect)
+ if (!d->dragInProgress && option->rect == d->hoverRect)
option->state |= QStyle::State_MouseOver;
option->shape = d->shape;
option->text = tab.text;
@@ -454,9 +454,6 @@ void QTabBarPrivate::layoutTabs()
maxExtent = maxWidth;
}
- if (pressedIndex != -1 && movable)
- grabCache(0, tabList.count(), true);
-
Q_ASSERT(tabChainIndex == tabChain.count() - 1); // add an assert just to make sure.
// Mirror our front item.
tabChain[tabChainIndex].init();
@@ -1484,6 +1481,8 @@ void QTabBar::paintEvent(QPaintEvent *)
bool vertical = verticalTabs(d->shape);
QStyleOptionTab cutTab;
selected = d->currentIndex;
+ if (d->dragInProgress)
+ selected = d->pressedIndex;
for (int i = 0; i < d->tabList.count(); ++i)
optTabBase.tabBarRect |= tabRect(i);
@@ -1522,11 +1521,7 @@ void QTabBar::paintEvent(QPaintEvent *)
if (i == selected)
continue;
- if (!d->tabList[i].animatingCache.isNull() && d->paintWithOffsets) {
- p.drawPixmap(tab.rect, d->tabList[i].animatingCache);
- } else {
- p.drawControl(QStyle::CE_TabBarTab, tab);
- }
+ p.drawControl(QStyle::CE_TabBarTab, tab);
}
// Draw the selected tab last to get it "on top"
@@ -1539,7 +1534,11 @@ void QTabBar::paintEvent(QPaintEvent *)
else
tab.rect.moveLeft(tab.rect.x() + d->tabList[selected].dragOffset);
}
- p.drawControl(QStyle::CE_TabBarTab, tab);
+ if (!d->dragInProgress)
+ p.drawControl(QStyle::CE_TabBarTab, tab);
+ else
+ d->movingTab->setGeometry(tab.rect);
+
}
// Only draw the tear indicator if necessary. Most of the time we don't need too.
@@ -1680,6 +1679,7 @@ void QTabBarPrivate::_q_moveTab(int offset)
if (!validIndex(index))
return;
tabList[index].dragOffset = offset;
+ layoutTab(index); // Make buttons follow tab
q->update();
}
}
@@ -1727,8 +1727,7 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event)
if (!d->dragInProgress && d->pressedIndex != -1) {
if ((event->pos() - d->dragStartPosition).manhattanLength() > QApplication::startDragDistance()) {
d->dragInProgress = true;
- if (d->animations.isEmpty())
- d->grabCache(0, d->tabList.count(), false);
+ d->setupMovableTab();
}
}
@@ -1773,7 +1772,6 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event)
if (dragDistance > needsToBeOver)
d->slide(i + offset, d->pressedIndex);
}
-
}
// Buttons needs to follow the dragged tab
d->layoutTab(d->pressedIndex);
@@ -1801,32 +1799,41 @@ void QTabBarPrivate::_q_moveTabFinished()
}
}
-void QTabBarPrivate::grabCache(int start, int end, bool unhide)
+void QTabBarPrivate::setupMovableTab()
{
Q_Q(QTabBar);
- paintWithOffsets = false;
- bool showButtonsAgain = rightB->isVisible();
- rightB->hide();
- leftB->hide();
-
- QWidget *topLevel = q->window();
- QPoint topLevelOffset(q->mapTo(topLevel, QPoint()));
- for (int i = start; i < end; ++i) {
- QRect tabRect = q->tabRect(i);
- tabRect.translate(topLevelOffset);
- if (unhide) {
- tabList[i].unHideWidgets();
- layoutWidgets(i);
- }
- tabList[i].animatingCache = QPixmap::grabWidget(topLevel, tabRect);
- if (i != pressedIndex)
- tabList[i].hideWidgets();
- }
- if (showButtonsAgain) {
- rightB->show();
- leftB->show();
- }
- paintWithOffsets = true;
+ if (!movingTab)
+ movingTab = new QWidget(q);
+
+ QRect grabRect = q->tabRect(pressedIndex);
+
+ QPixmap grabImage(grabRect.size());
+ grabImage.fill(Qt::transparent);
+ QStylePainter p(&grabImage, q);
+
+ QStyleOptionTabV3 tab;
+ q->initStyleOption(&tab, pressedIndex);
+ tab.rect.moveTopLeft(QPoint(0, 0));
+ p.drawControl(QStyle::CE_TabBarTab, tab);
+ p.end();
+
+ QPalette pal;
+ pal.setBrush(QPalette::All, QPalette::Window, grabImage);
+ movingTab->setPalette(pal);
+ movingTab->setGeometry(grabRect);
+ movingTab->setAutoFillBackground(true);
+ movingTab->raise();
+
+ // Re-arrange widget order to avoid overlaps
+ if (tabList[pressedIndex].leftWidget)
+ tabList[pressedIndex].leftWidget->raise();
+ if (tabList[pressedIndex].rightWidget)
+ tabList[pressedIndex].rightWidget->raise();
+ if (leftB)
+ leftB->raise();
+ if (rightB)
+ rightB->raise();
+ movingTab->setVisible(true);
}
void QTabBarPrivate::_q_moveTabFinished(int index)
@@ -1834,10 +1841,9 @@ void QTabBarPrivate::_q_moveTabFinished(int index)
Q_Q(QTabBar);
bool cleanup = (pressedIndex == index) || (pressedIndex == -1) || !validIndex(index);
if (animations.isEmpty() && cleanup) {
+ movingTab->setVisible(false); // We might not get a mouse release
for (int i = 0; i < tabList.count(); ++i) {
tabList[i].dragOffset = 0;
- tabList[i].unHideWidgets();
- tabList[i].animatingCache = QPixmap();
}
if (pressedIndex != -1 && movable) {
pressedIndex = -1;
@@ -1881,6 +1887,7 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event)
d->_q_moveTabFinished(d->pressedIndex);
}
d->dragInProgress = false;
+ d->movingTab->setVisible(false);
d->dragStartPosition = QPoint();
}
@@ -2203,19 +2210,16 @@ void QTabBar::setTabButton(int index, ButtonPosition position, QWidget *widget)
widget->setParent(this);
// make sure our left and right widgets stay on top
widget->lower();
+ widget->show();
}
if (position == LeftSide) {
if (d->tabList[index].leftWidget)
d->tabList[index].leftWidget->hide();
d->tabList[index].leftWidget = widget;
- if(!d->tabList[index].hidLeft && widget)
- widget->show();
} else {
if (d->tabList[index].rightWidget)
d->tabList[index].rightWidget->hide();
d->tabList[index].rightWidget = widget;
- if(!d->tabList[index].hidRight && widget)
- widget->show();
}
d->layoutTabs();
update();
diff --git a/src/gui/widgets/qtabbar_p.h b/src/gui/widgets/qtabbar_p.h
index a117aa3..cb1a15b 100644
--- a/src/gui/widgets/qtabbar_p.h
+++ b/src/gui/widgets/qtabbar_p.h
@@ -70,7 +70,6 @@
QT_BEGIN_NAMESPACE
-
class QTabBarPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QTabBar)
@@ -78,7 +77,7 @@ public:
QTabBarPrivate()
:currentIndex(-1), pressedIndex(-1),
shape(QTabBar::RoundedNorth),
- layoutDirty(false), drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false) {}
+ layoutDirty(false), drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false), movingTab(0) {}
int currentIndex;
int pressedIndex;
@@ -98,8 +97,6 @@ public:
, lastTab(-1)
, timeLine(0)
, dragOffset(0)
- , hidLeft(false)
- , hidRight(false)
{}
bool enabled;
int shortcutId;
@@ -123,9 +120,6 @@ public:
QTimeLine *timeLine;
int dragOffset;
- QPixmap animatingCache;
- bool hidLeft;
- bool hidRight;
void makeTimeLine(QWidget *q) {
if (timeLine)
@@ -135,27 +129,6 @@ public:
q->connect(timeLine, SIGNAL(finished()), q, SLOT(_q_moveTabFinished()));
}
- void hideWidgets() {
- if (!hidRight && rightWidget) {
- hidRight = rightWidget->isVisible();
- rightWidget->hide();
- }
-
- if (!hidLeft && leftWidget) {
- hidLeft = leftWidget->isVisible();
- leftWidget->hide();
- }
- }
-
- void unHideWidgets() {
- if (leftWidget && hidLeft)
- leftWidget->show();
- hidLeft = false;
- if (rightWidget && hidRight)
- rightWidget->show();
- hidRight = false;
- }
-
};
QList<Tab> tabList;
QHash<QTimeLine*, int> animations;
@@ -184,12 +157,12 @@ public:
void _q_moveTabFinished(int offset);
QRect hoverRect;
- void grabCache(int start, int end, bool unhide);
void refresh();
void layoutTabs();
void layoutWidgets(int index = -1);
void layoutTab(int index);
void updateMacBorderMetrics();
+ void setupMovableTab();
void makeVisible(int index);
QSize iconSize;
@@ -206,6 +179,8 @@ public:
bool dragInProgress;
bool documentMode;
+ QWidget *movingTab;
+
// shared by tabwidget and qtabbar
static void initStyleBaseOption(QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size)
{
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index 01ab884..1c4df93 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -1478,7 +1478,12 @@ void QTextEditPrivate::paint(QPainter *p, QPaintEvent *e)
layout->setViewport(QRect());
}
-/*! \warning The underlying text document must not be modified from within a reimplementation
+/*! \fn void QTextEdit::paintEvent(QPaintEvent *event)
+
+This event handler can be reimplemented in a subclass to receive paint events passed in \a event.
+It is usually unnecessary to reimplement this function in a subclass of QTextEdit.
+
+\warning The underlying text document must not be modified from within a reimplementation
of this function.
*/
void QTextEdit::paintEvent(QPaintEvent *e)
diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp
index 85d6ea2..1babb6d 100644
--- a/src/gui/widgets/qtoolbar.cpp
+++ b/src/gui/widgets/qtoolbar.cpp
@@ -1153,6 +1153,17 @@ bool QToolBar::event(QEvent *event)
if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event)))
return true;
break;
+#ifdef Q_OS_WINCE
+ case QEvent::ContextMenu:
+ {
+ QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event);
+ QWidget* child = childAt(contextMenuEvent->pos());
+ QAbstractButton* button = qobject_cast<QAbstractButton*>(child);
+ if (button)
+ button->setDown(false);
+ }
+ break;
+#endif
case QEvent::Leave:
if (d->state != 0 && d->state->dragging) {
#ifdef Q_OS_WIN
diff --git a/src/network/access/access.pri b/src/network/access/access.pri
index 6bcca0c..3269b2e 100644
--- a/src/network/access/access.pri
+++ b/src/network/access/access.pri
@@ -2,6 +2,9 @@
HEADERS += access/qftp.h \
access/qhttp.h \
+ access/qhttpnetworkheader_p.h \
+ access/qhttpnetworkrequest_p.h \
+ access/qhttpnetworkreply_p.h \
access/qhttpnetworkconnection_p.h \
access/qnetworkaccessmanager.h \
access/qnetworkaccessmanager_p.h \
@@ -27,6 +30,9 @@ HEADERS += access/qftp.h \
SOURCES += access/qftp.cpp \
access/qhttp.cpp \
+ access/qhttpnetworkheader.cpp \
+ access/qhttpnetworkrequest.cpp \
+ access/qhttpnetworkreply.cpp \
access/qhttpnetworkconnection.cpp \
access/qnetworkaccessmanager.cpp \
access/qnetworkaccesscache.cpp \
diff --git a/src/network/access/qhttp.cpp b/src/network/access/qhttp.cpp
index 0141ae2..96ccc91 100644
--- a/src/network/access/qhttp.cpp
+++ b/src/network/access/qhttp.cpp
@@ -2120,6 +2120,10 @@ int QHttp::setUser(const QString &userName, const QString &password)
Web proxy cache server (from \l http://www.squid.org/). For transparent
proxying, such as SOCKS5, use QNetworkProxy instead.
+ \note setProxy() has to be called before setHost() for it to take effect.
+ If setProxy() is called after setHost(), then it will not apply until after
+ setHost() is called again.
+
\sa QFtp::setProxy()
*/
int QHttp::setProxy(const QString &host, int port,
@@ -2139,7 +2143,7 @@ int QHttp::setProxy(const QString &host, int port,
is QNetworkProxy::HttpCachingProxy, QHttp will behave like the
previous function.
- Note: for compatibility with Qt 4.3, if the proxy type is
+ \note for compatibility with Qt 4.3, if the proxy type is
QNetworkProxy::HttpProxy and the request type is unencrypted (that
is, ConnectionModeHttp), QHttp will treat the proxy as a caching
proxy.
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index edb2988..980c0e0 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -45,7 +45,7 @@
#include <private/qauthenticator_p.h>
#include <qnetworkproxy.h>
#include <qauthenticator.h>
-#include <qbytearraymatcher.h>
+
#include <qbuffer.h>
#include <qpair.h>
#include <qhttp.h>
@@ -59,875 +59,9 @@
# include <QtNetwork/qsslconfiguration.h>
#endif
-#ifndef QT_NO_COMPRESS
-# include <zlib.h>
-static const unsigned char gz_magic[2] = {0x1f, 0x8b}; // gzip magic header
-// gzip flag byte
-#define HEAD_CRC 0x02 // bit 1 set: header CRC present
-#define EXTRA_FIELD 0x04 // bit 2 set: extra field present
-#define ORIG_NAME 0x08 // bit 3 set: original file name present
-#define COMMENT 0x10 // bit 4 set: file comment present
-#define RESERVED 0xE0 // bits 5..7: reserved
-#define CHUNK 16384
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QHttpNetworkHeaderPrivate : public QSharedData
-{
-public:
- QUrl url;
- QList<QPair<QByteArray, QByteArray> > fields;
-
- QHttpNetworkHeaderPrivate(const QUrl &newUrl = QUrl());
- QHttpNetworkHeaderPrivate(const QHttpNetworkHeaderPrivate &other);
- inline qint64 contentLength() const;
- inline void setContentLength(qint64 length);
-
- inline QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const;
- inline QList<QByteArray> headerFieldValues(const QByteArray &name) const;
- inline void setHeaderField(const QByteArray &name, const QByteArray &data);
- bool operator==(const QHttpNetworkHeaderPrivate &other) const;
-
-};
-
-QHttpNetworkHeaderPrivate::QHttpNetworkHeaderPrivate(const QUrl &newUrl)
- :url(newUrl)
-{
-}
-
-QHttpNetworkHeaderPrivate::QHttpNetworkHeaderPrivate(const QHttpNetworkHeaderPrivate &other)
- :QSharedData(other)
-{
- url = other.url;
- fields = other.fields;
-}
-
-qint64 QHttpNetworkHeaderPrivate::contentLength() const
-{
- bool ok = false;
- QByteArray value = headerField("content-length");
- qint64 length = value.toULongLong(&ok);
- if (ok)
- return length;
- return -1; // the header field is not set
-}
-
-void QHttpNetworkHeaderPrivate::setContentLength(qint64 length)
-{
- setHeaderField("Content-Length", QByteArray::number(length));
-}
-
-QByteArray QHttpNetworkHeaderPrivate::headerField(const QByteArray &name, const QByteArray &defaultValue) const
-{
- QList<QByteArray> allValues = headerFieldValues(name);
- if (allValues.isEmpty())
- return defaultValue;
-
- QByteArray result;
- bool first = true;
- foreach (QByteArray value, allValues) {
- if (!first)
- result += ", ";
- first = false;
- result += value;
- }
- return result;
-}
-
-QList<QByteArray> QHttpNetworkHeaderPrivate::headerFieldValues(const QByteArray &name) const
-{
- QList<QByteArray> result;
- QByteArray lowerName = name.toLower();
- QList<QPair<QByteArray, QByteArray> >::ConstIterator it = fields.constBegin(),
- end = fields.constEnd();
- for ( ; it != end; ++it)
- if (lowerName == it->first.toLower())
- result += it->second;
-
- return result;
-}
-
-void QHttpNetworkHeaderPrivate::setHeaderField(const QByteArray &name, const QByteArray &data)
-{
- QByteArray lowerName = name.toLower();
- QList<QPair<QByteArray, QByteArray> >::Iterator it = fields.begin();
- while (it != fields.end()) {
- if (lowerName == it->first.toLower())
- it = fields.erase(it);
- else
- ++it;
- }
- fields.append(qMakePair(name, data));
-}
-
-bool QHttpNetworkHeaderPrivate::operator==(const QHttpNetworkHeaderPrivate &other) const
-{
- return (url == other.url);
-}
-
-// QHttpNetworkRequestPrivate
-class QHttpNetworkRequestPrivate : public QHttpNetworkHeaderPrivate
-{
-public:
- QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op,
- QHttpNetworkRequest::Priority pri, const QUrl &newUrl = QUrl());
- QHttpNetworkRequestPrivate(const QHttpNetworkRequestPrivate &other);
- ~QHttpNetworkRequestPrivate();
- bool operator==(const QHttpNetworkRequestPrivate &other) const;
- QByteArray methodName() const;
- QByteArray uri(bool throughProxy) const;
-
- static QByteArray header(const QHttpNetworkRequest &request, bool throughProxy);
-
- QHttpNetworkRequest::Operation operation;
- QHttpNetworkRequest::Priority priority;
- mutable QIODevice *data;
- bool autoDecompress;
-};
-
-QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op,
- QHttpNetworkRequest::Priority pri, const QUrl &newUrl)
- : QHttpNetworkHeaderPrivate(newUrl), operation(op), priority(pri), data(0),
- autoDecompress(false)
-{
-}
-
-QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(const QHttpNetworkRequestPrivate &other)
- : QHttpNetworkHeaderPrivate(other)
-{
- operation = other.operation;
- priority = other.priority;
- data = other.data;
- autoDecompress = other.autoDecompress;
-}
-
-QHttpNetworkRequestPrivate::~QHttpNetworkRequestPrivate()
-{
-}
-
-bool QHttpNetworkRequestPrivate::operator==(const QHttpNetworkRequestPrivate &other) const
-{
- return QHttpNetworkHeaderPrivate::operator==(other)
- && (operation == other.operation)
- && (data == other.data);
-}
-
-QByteArray QHttpNetworkRequestPrivate::methodName() const
-{
- QByteArray ba;
- switch (operation) {
- case QHttpNetworkRequest::Options:
- ba += "OPTIONS";
- break;
- case QHttpNetworkRequest::Get:
- ba += "GET";
- break;
- case QHttpNetworkRequest::Head:
- ba += "HEAD";
- break;
- case QHttpNetworkRequest::Post:
- ba += "POST";
- break;
- case QHttpNetworkRequest::Put:
- ba += "PUT";
- break;
- case QHttpNetworkRequest::Delete:
- ba += "DELETE";
- break;
- case QHttpNetworkRequest::Trace:
- ba += "TRACE";
- break;
- case QHttpNetworkRequest::Connect:
- ba += "CONNECT";
- break;
- default:
- break;
- }
- return ba;
-}
-
-QByteArray QHttpNetworkRequestPrivate::uri(bool throughProxy) const
-{
- QUrl::FormattingOptions format(QUrl::RemoveFragment);
-
- // for POST, query data is send as content
- if (operation == QHttpNetworkRequest::Post && !data)
- format |= QUrl::RemoveQuery;
- // for requests through proxy, the Request-URI contains full url
- if (throughProxy)
- format |= QUrl::RemoveUserInfo;
- else
- format |= QUrl::RemoveScheme | QUrl::RemoveAuthority;
- QByteArray uri = url.toEncoded(format);
- if (uri.isEmpty() || (throughProxy && url.path().isEmpty()))
- uri += '/';
- return uri;
-}
-
-QByteArray QHttpNetworkRequestPrivate::header(const QHttpNetworkRequest &request, bool throughProxy)
-{
- QByteArray ba = request.d->methodName();
- QByteArray uri = request.d->uri(throughProxy);
- ba += " " + uri;
-
- QString majorVersion = QString::number(request.majorVersion());
- QString minorVersion = QString::number(request.minorVersion());
- ba += " HTTP/" + majorVersion.toLatin1() + "." + minorVersion.toLatin1() + "\r\n";
-
- QList<QPair<QByteArray, QByteArray> > fields = request.header();
- QList<QPair<QByteArray, QByteArray> >::const_iterator it = fields.constBegin();
- for (; it != fields.constEnd(); ++it)
- ba += it->first + ": " + it->second + "\r\n";
- if (request.d->operation == QHttpNetworkRequest::Post) {
- // add content type, if not set in the request
- if (request.headerField("content-type").isEmpty())
- ba += "Content-Type: application/x-www-form-urlencoded\r\n";
- if (!request.d->data && request.d->url.hasQuery()) {
- QByteArray query = request.d->url.encodedQuery();
- ba += "Content-Length: "+ QByteArray::number(query.size()) + "\r\n";
- ba += "\r\n";
- ba += query;
- } else {
- ba += "\r\n";
- }
- } else {
- ba += "\r\n";
- }
- return ba;
-}
-
-class QHttpNetworkReplyPrivate : public QObjectPrivate, public QHttpNetworkHeaderPrivate
-{
-public:
- QHttpNetworkReplyPrivate(const QUrl &newUrl = QUrl());
- ~QHttpNetworkReplyPrivate();
- qint64 readStatus(QAbstractSocket *socket);
- void parseStatus(const QByteArray &status);
- qint64 readHeader(QAbstractSocket *socket);
- void parseHeader(const QByteArray &header);
- qint64 readBody(QAbstractSocket *socket, QIODevice *out);
- bool findChallenge(bool forProxy, QByteArray &challenge) const;
- QAuthenticatorPrivate::Method authenticationMethod(bool isProxy) const;
- void clear();
-
- qint64 transferRaw(QIODevice *in, QIODevice *out, qint64 size);
- qint64 transferChunked(QIODevice *in, QIODevice *out);
- qint64 getChunkSize(QIODevice *in, qint64 *chunkSize);
-
- qint64 bytesAvailable() const;
- bool isChunked();
- bool connectionCloseEnabled();
- bool isGzipped();
-#ifndef QT_NO_COMPRESS
- bool gzipCheckHeader(QByteArray &content, int &pos);
- int gunzipBodyPartially(QByteArray &compressed, QByteArray &inflated);
-#endif
- void removeAutoDecompressHeader();
-
- enum ReplyState {
- NothingDoneState,
- ReadingStatusState,
- ReadingHeaderState,
- ReadingDataState,
- AllDoneState
- } state;
-
- QHttpNetworkRequest request;
- int statusCode;
- int majorVersion;
- int minorVersion;
- QString errorString;
- QString reasonPhrase;
- qint64 bodyLength;
- qint64 contentRead;
- qint64 totalProgress;
- QByteArray fragment;
- qint64 currentChunkSize;
- qint64 currentChunkRead;
- QPointer<QHttpNetworkConnection> connection;
- bool initInflate;
- bool streamEnd;
-#ifndef QT_NO_COMPRESS
- z_stream inflateStrm;
-#endif
- bool autoDecompress;
-
- QByteArray responseData; // uncompressed body
- QByteArray compressedData; // compressed body (temporary)
- QBuffer requestDataBuffer;
- bool requestIsBuffering;
- bool requestIsPrepared;
-};
-
-QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl)
- : QHttpNetworkHeaderPrivate(newUrl), state(NothingDoneState), statusCode(100),
- majorVersion(0), minorVersion(0), bodyLength(0), contentRead(0), totalProgress(0),
- currentChunkSize(0), currentChunkRead(0), connection(0), initInflate(false),
- autoDecompress(false), requestIsBuffering(false), requestIsPrepared(false)
-{
-}
-
-QHttpNetworkReplyPrivate::~QHttpNetworkReplyPrivate()
-{
-}
-
-void QHttpNetworkReplyPrivate::clear()
-{
- state = NothingDoneState;
- statusCode = 100;
- bodyLength = 0;
- contentRead = 0;
- totalProgress = 0;
- currentChunkSize = 0;
- currentChunkRead = 0;
- connection = 0;
-#ifndef QT_NO_COMPRESS
- if (initInflate)
- inflateEnd(&inflateStrm);
-#endif
- initInflate = false;
- streamEnd = false;
- autoDecompress = false;
- fields.clear();
-}
-
-// QHttpNetworkReplyPrivate
-qint64 QHttpNetworkReplyPrivate::bytesAvailable() const
-{
- return (state != ReadingDataState ? 0 : fragment.size());
-}
-
-bool QHttpNetworkReplyPrivate::isGzipped()
-{
- QByteArray encoding = headerField("content-encoding");
- return encoding.toLower() == "gzip";
-}
-
-void QHttpNetworkReplyPrivate::removeAutoDecompressHeader()
-{
- // The header "Content-Encoding = gzip" is retained.
- // Content-Length is removed since the actual one send by the server is for compressed data
- QByteArray name("content-length");
- QByteArray lowerName = name.toLower();
- QList<QPair<QByteArray, QByteArray> >::Iterator it = fields.begin(),
- end = fields.end();
- while (it != end) {
- if (name == it->first.toLower()) {
- fields.erase(it);
- break;
- }
- ++it;
- }
-
-}
-
-bool QHttpNetworkReplyPrivate::findChallenge(bool forProxy, QByteArray &challenge) const
-{
- challenge.clear();
- // find out the type of authentication protocol requested.
- QByteArray header = forProxy ? "proxy-authenticate" : "www-authenticate";
- // pick the best protocol (has to match parsing in QAuthenticatorPrivate)
- QList<QByteArray> challenges = headerFieldValues(header);
- for (int i = 0; i<challenges.size(); i++) {
- QByteArray line = challenges.at(i);
- if (!line.toLower().startsWith("negotiate"))
- challenge = line;
- }
- return !challenge.isEmpty();
-}
-
-QAuthenticatorPrivate::Method QHttpNetworkReplyPrivate::authenticationMethod(bool isProxy) const
-{
- // The logic is same as the one used in void QAuthenticatorPrivate::parseHttpResponse()
- QAuthenticatorPrivate::Method method = QAuthenticatorPrivate::None;
- QByteArray header = isProxy ? "proxy-authenticate" : "www-authenticate";
- QList<QByteArray> challenges = headerFieldValues(header);
- for (int i = 0; i<challenges.size(); i++) {
- QByteArray line = challenges.at(i).trimmed().toLower();
- if (method < QAuthenticatorPrivate::Basic
- && line.startsWith("basic")) {
- method = QAuthenticatorPrivate::Basic;
- } else if (method < QAuthenticatorPrivate::Ntlm
- && line.startsWith("ntlm")) {
- method = QAuthenticatorPrivate::Ntlm;
- } else if (method < QAuthenticatorPrivate::DigestMd5
- && line.startsWith("digest")) {
- method = QAuthenticatorPrivate::DigestMd5;
- }
- }
- return method;
-}
-
-#ifndef QT_NO_COMPRESS
-bool QHttpNetworkReplyPrivate::gzipCheckHeader(QByteArray &content, int &pos)
-{
- int method = 0; // method byte
- int flags = 0; // flags byte
- bool ret = false;
-
- // Assure two bytes in the buffer so we can peek ahead -- handle case
- // where first byte of header is at the end of the buffer after the last
- // gzip segment
- pos = -1;
- QByteArray &body = content;
- int maxPos = body.size()-1;
- if (maxPos < 1) {
- return ret;
- }
-
- // Peek ahead to check the gzip magic header
- if (body[0] != char(gz_magic[0]) ||
- body[1] != char(gz_magic[1])) {
- return ret;
- }
- pos += 2;
- // Check the rest of the gzip header
- if (++pos <= maxPos)
- method = body[pos];
- if (pos++ <= maxPos)
- flags = body[pos];
- if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
- return ret;
- }
-
- // Discard time, xflags and OS code:
- pos += 6;
- if (pos > maxPos)
- return ret;
- if ((flags & EXTRA_FIELD) && ((pos+2) <= maxPos)) { // skip the extra field
- unsigned len = (unsigned)body[++pos];
- len += ((unsigned)body[++pos])<<8;
- pos += len;
- if (pos > maxPos)
- return ret;
- }
- if ((flags & ORIG_NAME) != 0) { // skip the original file name
- while(++pos <= maxPos && body[pos]) {}
- }
- if ((flags & COMMENT) != 0) { // skip the .gz file comment
- while(++pos <= maxPos && body[pos]) {}
- }
- if ((flags & HEAD_CRC) != 0) { // skip the header crc
- pos += 2;
- if (pos > maxPos)
- return ret;
- }
- ret = (pos < maxPos); // return failed, if no more bytes left
- return ret;
-}
-
-int QHttpNetworkReplyPrivate::gunzipBodyPartially(QByteArray &compressed, QByteArray &inflated)
-{
- int ret = Z_DATA_ERROR;
- unsigned have;
- unsigned char out[CHUNK];
- int pos = -1;
-
- if (!initInflate) {
- // check the header
- if (!gzipCheckHeader(compressed, pos))
- return ret;
- // allocate inflate state
- inflateStrm.zalloc = Z_NULL;
- inflateStrm.zfree = Z_NULL;
- inflateStrm.opaque = Z_NULL;
- inflateStrm.avail_in = 0;
- inflateStrm.next_in = Z_NULL;
- ret = inflateInit2(&inflateStrm, -MAX_WBITS);
- if (ret != Z_OK)
- return ret;
- initInflate = true;
- streamEnd = false;
- }
-
- //remove the header.
- compressed.remove(0, pos+1);
- // expand until deflate stream ends
- inflateStrm.next_in = (unsigned char *)compressed.data();
- inflateStrm.avail_in = compressed.size();
- do {
- inflateStrm.avail_out = sizeof(out);
- inflateStrm.next_out = out;
- ret = inflate(&inflateStrm, Z_NO_FLUSH);
- switch (ret) {
- case Z_NEED_DICT:
- ret = Z_DATA_ERROR;
- // and fall through
- case Z_DATA_ERROR:
- case Z_MEM_ERROR:
- inflateEnd(&inflateStrm);
- initInflate = false;
- return ret;
- }
- have = sizeof(out) - inflateStrm.avail_out;
- inflated.append(QByteArray((const char *)out, have));
- } while (inflateStrm.avail_out == 0);
- // clean up and return
- if (ret <= Z_ERRNO || ret == Z_STREAM_END) {
- inflateEnd(&inflateStrm);
- initInflate = false;
- }
- streamEnd = (ret == Z_STREAM_END);
- return ret;
-}
-#endif
-
-qint64 QHttpNetworkReplyPrivate::readStatus(QAbstractSocket *socket)
-{
- qint64 bytes = 0;
- char c;
-
- while (socket->bytesAvailable()) {
- // allow both CRLF & LF (only) line endings
- if (socket->peek(&c, 1) == 1 && c == '\n') {
- bytes += socket->read(&c, 1); // read the "n"
- // remove the CR at the end
- if (fragment.endsWith('\r')) {
- fragment.truncate(fragment.length()-1);
- }
- parseStatus(fragment);
- state = ReadingHeaderState;
- fragment.clear(); // next fragment
- break;
- } else {
- c = 0;
- bytes += socket->read(&c, 1);
- fragment.append(c);
- }
- }
- return bytes;
-}
-
-void QHttpNetworkReplyPrivate::parseStatus(const QByteArray &status)
-{
- const QByteArrayMatcher sp(" ");
- int i = sp.indexIn(status);
- const QByteArray version = status.mid(0, i);
- int j = sp.indexIn(status, i + 1);
- const QByteArray code = status.mid(i + 1, j - i - 1);
- const QByteArray reason = status.mid(j + 1, status.count() - j);
-
- const QByteArrayMatcher slash("/");
- int k = slash.indexIn(version);
- const QByteArrayMatcher dot(".");
- int l = dot.indexIn(version, k);
- const QByteArray major = version.mid(k + 1, l - k - 1);
- const QByteArray minor = version.mid(l + 1, version.count() - l);
-
- majorVersion = QString::fromAscii(major.constData()).toInt();
- minorVersion = QString::fromAscii(minor.constData()).toInt();
- statusCode = QString::fromAscii(code.constData()).toInt();
- reasonPhrase = QString::fromAscii(reason.constData());
-}
-
-qint64 QHttpNetworkReplyPrivate::readHeader(QAbstractSocket *socket)
-{
- qint64 bytes = 0;
- char crlfcrlf[5];
- crlfcrlf[4] = '\0';
- char c = 0;
- bool allHeaders = false;
- while (!allHeaders && socket->bytesAvailable()) {
- if (socket->peek(&c, 1) == 1 && c == '\n') {
- // check for possible header endings. As per HTTP rfc,
- // the header endings will be marked by CRLFCRLF. But
- // we will allow CRLFLF, LFLF & CRLFCRLF
- if (fragment.endsWith("\n\r") || fragment.endsWith('\n'))
- allHeaders = true;
- }
- bytes += socket->read(&c, 1);
- fragment.append(c);
- }
- // we received all headers now parse them
- if (allHeaders) {
- parseHeader(fragment);
- state = ReadingDataState;
- fragment.clear(); // next fragment
- bodyLength = contentLength(); // cache the length
- }
- return bytes;
-}
-
-void QHttpNetworkReplyPrivate::parseHeader(const QByteArray &header)
-{
- // see rfc2616, sec 4 for information about HTTP/1.1 headers.
- // allows relaxed parsing here, accepts both CRLF & LF line endings
- const QByteArrayMatcher lf("\n");
- const QByteArrayMatcher colon(":");
- int i = 0;
- while (i < header.count()) {
- int j = colon.indexIn(header, i); // field-name
- if (j == -1)
- break;
- const QByteArray field = header.mid(i, j - i).trimmed();
- j++;
- // any number of LWS is allowed before and after the value
- QByteArray value;
- do {
- i = lf.indexIn(header, j);
- if (i == -1)
- break;
- if (!value.isEmpty())
- value += ' ';
- // check if we have CRLF or only LF
- bool hasCR = (i && header[i-1] == '\r');
- int length = i -(hasCR ? 1: 0) - j;
- value += header.mid(j, length).trimmed();
- j = ++i;
- } while (i < header.count() && (header.at(i) == ' ' || header.at(i) == '\t'));
- if (i == -1)
- break; // something is wrong
-
- fields.append(qMakePair(field, value));
- }
-}
-
-bool QHttpNetworkReplyPrivate::isChunked()
-{
- return headerField("transfer-encoding").toLower().contains("chunked");
-}
-
-bool QHttpNetworkReplyPrivate::connectionCloseEnabled()
-{
- return (headerField("connection").toLower().contains("close") ||
- headerField("proxy-connection").toLower().contains("close"));
-}
-
-qint64 QHttpNetworkReplyPrivate::readBody(QAbstractSocket *socket, QIODevice *out)
-{
- qint64 bytes = 0;
- if (isChunked()) {
- bytes += transferChunked(socket, out); // chunked transfer encoding (rfc 2616, sec 3.6)
- } else if (bodyLength > 0) { // we have a Content-Length
- bytes += transferRaw(socket, out, bodyLength - contentRead);
- if (contentRead + bytes == bodyLength)
- state = AllDoneState;
- } else {
- bytes += transferRaw(socket, out, socket->bytesAvailable());
- }
- if (state == AllDoneState)
- socket->readAll(); // Read the rest to clean (CRLF)
- contentRead += bytes;
- return bytes;
-}
-
-qint64 QHttpNetworkReplyPrivate::transferRaw(QIODevice *in, QIODevice *out, qint64 size)
-{
- qint64 bytes = 0;
- Q_ASSERT(in);
- Q_ASSERT(out);
-
- int toBeRead = qMin<qint64>(128*1024, qMin<qint64>(size, in->bytesAvailable()));
- QByteArray raw(toBeRead, 0);
- while (size > 0) {
- qint64 read = in->read(raw.data(), raw.size());
- if (read == 0)
- return bytes;
- // ### error checking here
- qint64 written = out->write(raw.data(), read);
- if (written == 0)
- return bytes;
- if (read != written)
- qDebug() << "### read" << read << "written" << written;
- bytes += read;
- size -= read;
- out->waitForBytesWritten(-1); // throttle
- }
- return bytes;
-
-}
-
-qint64 QHttpNetworkReplyPrivate::transferChunked(QIODevice *in, QIODevice *out)
-{
- qint64 bytes = 0;
- while (in->bytesAvailable()) { // while we can read from input
- // if we are done with the current chunk, get the size of the new chunk
- if (currentChunkRead >= currentChunkSize) {
- currentChunkSize = 0;
- currentChunkRead = 0;
- if (bytes) {
- char crlf[2];
- bytes += in->read(crlf, 2); // read the "\r\n" after the chunk
- }
- bytes += getChunkSize(in, &currentChunkSize);
- if (currentChunkSize == -1)
- break;
- }
- // if the chunk size is 0, end of the stream
- if (currentChunkSize == 0) {
- state = AllDoneState;
- break;
- }
- // otherwise, read data
- qint64 readSize = qMin(in->bytesAvailable(), currentChunkSize - currentChunkRead);
- QByteArray buffer(readSize, 0);
- qint64 read = in->read(buffer.data(), readSize);
- bytes += read;
- currentChunkRead += read;
- qint64 written = out->write(buffer);
- Q_UNUSED(written); // Avoid compile warning when building release
- Q_ASSERT(read == written);
- // ### error checking here
- out->waitForBytesWritten(-1);
- }
- return bytes;
-}
-
-qint64 QHttpNetworkReplyPrivate::getChunkSize(QIODevice *in, qint64 *chunkSize)
-{
- qint64 bytes = 0;
- char crlf[2];
- *chunkSize = -1;
- int bytesAvailable = in->bytesAvailable();
- while (bytesAvailable > bytes) {
- qint64 sniffedBytes = in->peek(crlf, 2);
- int fragmentSize = fragment.size();
- // check the next two bytes for a "\r\n", skip blank lines
- if ((fragmentSize && sniffedBytes == 2 && crlf[0] == '\r' && crlf[1] == '\n')
- ||(fragmentSize > 1 && fragment.endsWith('\r') && crlf[0] == '\n'))
- {
- bytes += in->read(crlf, 1); // read the \r or \n
- if (crlf[0] == '\r')
- bytes += in->read(crlf, 1); // read the \n
- bool ok = false;
- // ignore the chunk-extension
- fragment = fragment.mid(0, fragment.indexOf(';')).trimmed();
- *chunkSize = fragment.toLong(&ok, 16);
- fragment.clear();
- break; // size done
- } else {
- // read the fragment to the buffer
- char c = 0;
- bytes += in->read(&c, 1);
- fragment.append(c);
- }
- }
- return bytes;
-}
-
-// QHttpNetworkConnectionPrivate
-
-typedef QPair<QHttpNetworkRequest, QHttpNetworkReply*> HttpMessagePair;
-
-class QHttpNetworkConnectionPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QHttpNetworkConnection)
-public:
- QHttpNetworkConnectionPrivate(const QString &hostName, quint16 port, bool encrypt);
- ~QHttpNetworkConnectionPrivate();
- void init();
- void connectSignals(QAbstractSocket *socket);
-
- enum SocketState {
- IdleState = 0, // ready to send request
- ConnectingState = 1, // connecting to host
- WritingState = 2, // writing the data
- WaitingState = 4, // waiting for reply
- ReadingState = 8, // reading the reply
- Wait4AuthState = 0x10, // blocked for send till the current authentication slot is done
- BusyState = (ConnectingState|WritingState|WaitingState|ReadingState|Wait4AuthState)
- };
-
- enum { ChunkSize = 4096 };
-
- int indexOf(QAbstractSocket *socket) const;
- bool isSocketBusy(QAbstractSocket *socket) const;
- bool isSocketWriting(QAbstractSocket *socket) const;
- bool isSocketWaiting(QAbstractSocket *socket) const;
- bool isSocketReading(QAbstractSocket *socket) const;
-
- QHttpNetworkReply *queueRequest(const QHttpNetworkRequest &request);
- void unqueueRequest(QAbstractSocket *socket);
- void prepareRequest(HttpMessagePair &request);
- bool sendRequest(QAbstractSocket *socket);
- void receiveReply(QAbstractSocket *socket, QHttpNetworkReply *reply);
- void resendCurrentRequest(QAbstractSocket *socket);
- void closeChannel(int channel);
- void copyCredentials(int fromChannel, QAuthenticator *auth, bool isProxy);
-
- // private slots
- void _q_bytesWritten(qint64 bytes); // proceed sending
- void _q_readyRead(); // pending data to read
- void _q_disconnected(); // disconnected from host
- void _q_startNextRequest(); // send the next request from the queue
- void _q_restartPendingRequest(); // send the currently blocked request
- void _q_connected(); // start sending request
- void _q_error(QAbstractSocket::SocketError); // error from socket
-#ifndef QT_NO_NETWORKPROXY
- void _q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth); // from transparent proxy
-#endif
- void _q_dataReadyReadNoBuffer();
- void _q_dataReadyReadBuffer();
-
- void createAuthorization(QAbstractSocket *socket, QHttpNetworkRequest &request);
- bool ensureConnection(QAbstractSocket *socket);
- QString errorDetail(QNetworkReply::NetworkError errorCode, QAbstractSocket *socket);
- void eraseData(QHttpNetworkReply *reply);
-#ifndef QT_NO_COMPRESS
- bool expand(QAbstractSocket *socket, QHttpNetworkReply *reply, bool dataComplete);
-#endif
- void bufferData(HttpMessagePair &request);
- void removeReply(QHttpNetworkReply *reply);
-
- QString hostName;
- quint16 port;
- bool encrypt;
-
- struct Channel {
- QAbstractSocket *socket;
- SocketState state;
- QHttpNetworkRequest request; // current request
- QHttpNetworkReply *reply; // current reply for this request
- qint64 written;
- qint64 bytesTotal;
- bool resendCurrent;
- int lastStatus; // last status received on this channel
- bool pendingEncrypt; // for https (send after encrypted)
- int reconnectAttempts; // maximum 2 reconnection attempts
- QAuthenticatorPrivate::Method authMehtod;
- QAuthenticatorPrivate::Method proxyAuthMehtod;
- QAuthenticator authenticator;
- QAuthenticator proxyAuthenticator;
-#ifndef QT_NO_OPENSSL
- bool ignoreSSLErrors;
-#endif
- Channel() :state(IdleState), reply(0), written(0), bytesTotal(0), resendCurrent(false), reconnectAttempts(2),
- authMehtod(QAuthenticatorPrivate::None), proxyAuthMehtod(QAuthenticatorPrivate::None)
-#ifndef QT_NO_OPENSSL
- , ignoreSSLErrors(false)
-#endif
- {}
- };
- static const int channelCount;
- Channel channels[2]; // maximum of 2 socket connections to the server
- bool pendingAuthSignal; // there is an incomplete authentication signal
- bool pendingProxyAuthSignal; // there is an incomplete proxy authentication signal
-
- void appendData(QHttpNetworkReply &reply, const QByteArray &fragment, bool compressed);
- qint64 bytesAvailable(const QHttpNetworkReply &reply, bool compressed = false) const;
- qint64 read(QHttpNetworkReply &reply, QByteArray &data, qint64 maxSize, bool compressed);
- void emitReplyError(QAbstractSocket *socket, QHttpNetworkReply *reply, QNetworkReply::NetworkError errorCode);
- bool handleAuthenticateChallenge(QAbstractSocket *socket, QHttpNetworkReply *reply, bool isProxy, bool &resend);
- void allDone(QAbstractSocket *socket, QHttpNetworkReply *reply);
- void handleStatus(QAbstractSocket *socket, QHttpNetworkReply *reply);
- inline bool emitSignals(QHttpNetworkReply *reply);
- inline bool expectContent(QHttpNetworkReply *reply);
-
-#ifndef QT_NO_OPENSSL
- void _q_encrypted(); // start sending request (https)
- void _q_sslErrors(const QList<QSslError> &errors); // ssl errors from the socket
- QSslConfiguration sslConfiguration(const QHttpNetworkReply &reply) const;
-#endif
-#ifndef QT_NO_NETWORKPROXY
- QNetworkProxy networkProxy;
-#endif
- //The request queues
- QList<HttpMessagePair> highPriorityQueue;
- QList<HttpMessagePair> lowPriorityQueue;
-};
+QT_BEGIN_NAMESPACE
const int QHttpNetworkConnectionPrivate::channelCount = 2;
@@ -2150,235 +1284,6 @@ QNetworkProxy QHttpNetworkConnection::transparentProxy() const
}
#endif
-// QHttpNetworkRequest
-
-QHttpNetworkRequest::QHttpNetworkRequest(const QUrl &url, Operation operation, Priority priority)
- : d(new QHttpNetworkRequestPrivate(operation, priority, url))
-{
-}
-
-QHttpNetworkRequest::QHttpNetworkRequest(const QHttpNetworkRequest &other)
- : QHttpNetworkHeader(other), d(other.d)
-{
-}
-
-QHttpNetworkRequest::~QHttpNetworkRequest()
-{
-}
-
-QUrl QHttpNetworkRequest::url() const
-{
- return d->url;
-}
-void QHttpNetworkRequest::setUrl(const QUrl &url)
-{
- d->url = url;
-}
-
-qint64 QHttpNetworkRequest::contentLength() const
-{
- return d->contentLength();
-}
-
-void QHttpNetworkRequest::setContentLength(qint64 length)
-{
- d->setContentLength(length);
-}
-
-QList<QPair<QByteArray, QByteArray> > QHttpNetworkRequest::header() const
-{
- return d->fields;
-}
-
-QByteArray QHttpNetworkRequest::headerField(const QByteArray &name, const QByteArray &defaultValue) const
-{
- return d->headerField(name, defaultValue);
-}
-
-void QHttpNetworkRequest::setHeaderField(const QByteArray &name, const QByteArray &data)
-{
- d->setHeaderField(name, data);
-}
-
-QHttpNetworkRequest &QHttpNetworkRequest::operator=(const QHttpNetworkRequest &other)
-{
- d = other.d;
- return *this;
-}
-
-bool QHttpNetworkRequest::operator==(const QHttpNetworkRequest &other) const
-{
- return d->operator==(*other.d);
-}
-
-QHttpNetworkRequest::Operation QHttpNetworkRequest::operation() const
-{
- return d->operation;
-}
-
-void QHttpNetworkRequest::setOperation(Operation operation)
-{
- d->operation = operation;
-}
-
-QHttpNetworkRequest::Priority QHttpNetworkRequest::priority() const
-{
- return d->priority;
-}
-
-void QHttpNetworkRequest::setPriority(Priority priority)
-{
- d->priority = priority;
-}
-
-QIODevice *QHttpNetworkRequest::data() const
-{
- return d->data;
-}
-
-void QHttpNetworkRequest::setData(QIODevice *data)
-{
- d->data = data;
-}
-
-int QHttpNetworkRequest::majorVersion() const
-{
- return 1;
-}
-
-int QHttpNetworkRequest::minorVersion() const
-{
- return 1;
-}
-
-// QHttpNetworkReply
-
-QHttpNetworkReply::QHttpNetworkReply(const QUrl &url, QObject *parent)
- : QObject(*new QHttpNetworkReplyPrivate(url), parent)
-{
-}
-
-QHttpNetworkReply::~QHttpNetworkReply()
-{
- Q_D(QHttpNetworkReply);
- if (d->connection) {
- d->connection->d_func()->removeReply(this);
- }
-}
-
-QUrl QHttpNetworkReply::url() const
-{
- return d_func()->url;
-}
-void QHttpNetworkReply::setUrl(const QUrl &url)
-{
- Q_D(QHttpNetworkReply);
- d->url = url;
-}
-
-qint64 QHttpNetworkReply::contentLength() const
-{
- return d_func()->contentLength();
-}
-
-void QHttpNetworkReply::setContentLength(qint64 length)
-{
- Q_D(QHttpNetworkReply);
- d->setContentLength(length);
-}
-
-QList<QPair<QByteArray, QByteArray> > QHttpNetworkReply::header() const
-{
- return d_func()->fields;
-}
-
-QByteArray QHttpNetworkReply::headerField(const QByteArray &name, const QByteArray &defaultValue) const
-{
- return d_func()->headerField(name, defaultValue);
-}
-
-void QHttpNetworkReply::setHeaderField(const QByteArray &name, const QByteArray &data)
-{
- Q_D(QHttpNetworkReply);
- d->setHeaderField(name, data);
-}
-
-void QHttpNetworkReply::parseHeader(const QByteArray &header)
-{
- Q_D(QHttpNetworkReply);
- d->parseHeader(header);
-}
-
-QHttpNetworkRequest QHttpNetworkReply::request() const
-{
- return d_func()->request;
-}
-
-void QHttpNetworkReply::setRequest(const QHttpNetworkRequest &request)
-{
- Q_D(QHttpNetworkReply);
- d->request = request;
-}
-
-int QHttpNetworkReply::statusCode() const
-{
- return d_func()->statusCode;
-}
-
-void QHttpNetworkReply::setStatusCode(int code)
-{
- Q_D(QHttpNetworkReply);
- d->statusCode = code;
-}
-
-QString QHttpNetworkReply::errorString() const
-{
- return d_func()->errorString;
-}
-
-QString QHttpNetworkReply::reasonPhrase() const
-{
- return d_func()->reasonPhrase;
-}
-
-void QHttpNetworkReply::setErrorString(const QString &error)
-{
- Q_D(QHttpNetworkReply);
- d->errorString = error;
-}
-
-int QHttpNetworkReply::majorVersion() const
-{
- return d_func()->majorVersion;
-}
-
-int QHttpNetworkReply::minorVersion() const
-{
- return d_func()->minorVersion;
-}
-
-qint64 QHttpNetworkReply::bytesAvailable() const
-{
- Q_D(const QHttpNetworkReply);
- if (d->connection)
- return d->connection->d_func()->bytesAvailable(*this);
- else
- return -1;
-}
-
-QByteArray QHttpNetworkReply::read(qint64 maxSize)
-{
- Q_D(QHttpNetworkReply);
- QByteArray data;
- if (d->connection)
- d->connection->d_func()->read(*this, data, maxSize, false);
- return data;
-}
-
-bool QHttpNetworkReply::isFinished() const
-{
- return d_func()->state == QHttpNetworkReplyPrivate::AllDoneState;
-}
// SSL support below
#ifndef QT_NO_OPENSSL
@@ -2433,27 +1338,7 @@ void QHttpNetworkConnection::ignoreSslErrors(int channel)
}
}
-QSslConfiguration QHttpNetworkReply::sslConfiguration() const
-{
- Q_D(const QHttpNetworkReply);
- if (d->connection)
- return d->connection->d_func()->sslConfiguration(*this);
- return QSslConfiguration();
-}
-void QHttpNetworkReply::setSslConfiguration(const QSslConfiguration &config)
-{
- Q_D(QHttpNetworkReply);
- if (d->connection)
- d->connection->setSslConfiguration(config);
-}
-
-void QHttpNetworkReply::ignoreSslErrors()
-{
- Q_D(QHttpNetworkReply);
- if (d->connection)
- d->connection->ignoreSslErrors();
-}
#endif //QT_NO_OPENSSL
diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h
index 8dbcb3d..09bd459 100644
--- a/src/network/access/qhttpnetworkconnection_p.h
+++ b/src/network/access/qhttpnetworkconnection_p.h
@@ -56,6 +56,16 @@
#include <QtNetwork/qnetworkreply.h>
#include <QtNetwork/qabstractsocket.h>
+#include <private/qobject_p.h>
+#include <qauthenticator.h>
+#include <qnetworkproxy.h>
+#include <qbuffer.h>
+
+#include <private/qhttpnetworkheader_p.h>
+#include <private/qhttpnetworkrequest_p.h>
+#include <private/qhttpnetworkreply_p.h>
+
+
#ifndef QT_NO_HTTP
#ifndef QT_NO_OPENSSL
@@ -145,144 +155,137 @@ private:
#endif
};
-class Q_AUTOTEST_EXPORT QHttpNetworkHeader
-{
-public:
- virtual ~QHttpNetworkHeader() {};
- virtual QUrl url() const = 0;
- virtual void setUrl(const QUrl &url) = 0;
- virtual int majorVersion() const = 0;
- virtual int minorVersion() const = 0;
- virtual qint64 contentLength() const = 0;
- virtual void setContentLength(qint64 length) = 0;
- virtual QList<QPair<QByteArray, QByteArray> > header() const = 0;
- virtual QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const = 0;
- virtual void setHeaderField(const QByteArray &name, const QByteArray &data) = 0;
-};
+// private classes
+typedef QPair<QHttpNetworkRequest, QHttpNetworkReply*> HttpMessagePair;
+
-class QHttpNetworkRequestPrivate;
-class Q_AUTOTEST_EXPORT QHttpNetworkRequest: public QHttpNetworkHeader
+class QHttpNetworkConnectionPrivate : public QObjectPrivate
{
+ Q_DECLARE_PUBLIC(QHttpNetworkConnection)
public:
- enum Operation {
- Options,
- Get,
- Head,
- Post,
- Put,
- Delete,
- Trace,
- Connect
+ QHttpNetworkConnectionPrivate(const QString &hostName, quint16 port, bool encrypt);
+ ~QHttpNetworkConnectionPrivate();
+ void init();
+ void connectSignals(QAbstractSocket *socket);
+
+ enum SocketState {
+ IdleState = 0, // ready to send request
+ ConnectingState = 1, // connecting to host
+ WritingState = 2, // writing the data
+ WaitingState = 4, // waiting for reply
+ ReadingState = 8, // reading the reply
+ Wait4AuthState = 0x10, // blocked for send till the current authentication slot is done
+ BusyState = (ConnectingState|WritingState|WaitingState|ReadingState|Wait4AuthState)
};
- enum Priority {
- HighPriority,
- NormalPriority,
- LowPriority
+ enum { ChunkSize = 4096 };
+
+ int indexOf(QAbstractSocket *socket) const;
+ bool isSocketBusy(QAbstractSocket *socket) const;
+ bool isSocketWriting(QAbstractSocket *socket) const;
+ bool isSocketWaiting(QAbstractSocket *socket) const;
+ bool isSocketReading(QAbstractSocket *socket) const;
+
+ QHttpNetworkReply *queueRequest(const QHttpNetworkRequest &request);
+ void unqueueRequest(QAbstractSocket *socket);
+ void prepareRequest(HttpMessagePair &request);
+ bool sendRequest(QAbstractSocket *socket);
+ void receiveReply(QAbstractSocket *socket, QHttpNetworkReply *reply);
+ void resendCurrentRequest(QAbstractSocket *socket);
+ void closeChannel(int channel);
+ void copyCredentials(int fromChannel, QAuthenticator *auth, bool isProxy);
+
+ // private slots
+ void _q_bytesWritten(qint64 bytes); // proceed sending
+ void _q_readyRead(); // pending data to read
+ void _q_disconnected(); // disconnected from host
+ void _q_startNextRequest(); // send the next request from the queue
+ void _q_restartPendingRequest(); // send the currently blocked request
+ void _q_connected(); // start sending request
+ void _q_error(QAbstractSocket::SocketError); // error from socket
+#ifndef QT_NO_NETWORKPROXY
+ void _q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth); // from transparent proxy
+#endif
+ void _q_dataReadyReadNoBuffer();
+ void _q_dataReadyReadBuffer();
+
+ void createAuthorization(QAbstractSocket *socket, QHttpNetworkRequest &request);
+ bool ensureConnection(QAbstractSocket *socket);
+ QString errorDetail(QNetworkReply::NetworkError errorCode, QAbstractSocket *socket);
+ void eraseData(QHttpNetworkReply *reply);
+#ifndef QT_NO_COMPRESS
+ bool expand(QAbstractSocket *socket, QHttpNetworkReply *reply, bool dataComplete);
+#endif
+ void bufferData(HttpMessagePair &request);
+ void removeReply(QHttpNetworkReply *reply);
+
+ QString hostName;
+ quint16 port;
+ bool encrypt;
+
+ struct Channel {
+ QAbstractSocket *socket;
+ SocketState state;
+ QHttpNetworkRequest request; // current request
+ QHttpNetworkReply *reply; // current reply for this request
+ qint64 written;
+ qint64 bytesTotal;
+ bool resendCurrent;
+ int lastStatus; // last status received on this channel
+ bool pendingEncrypt; // for https (send after encrypted)
+ int reconnectAttempts; // maximum 2 reconnection attempts
+ QAuthenticatorPrivate::Method authMehtod;
+ QAuthenticatorPrivate::Method proxyAuthMehtod;
+ QAuthenticator authenticator;
+ QAuthenticator proxyAuthenticator;
+#ifndef QT_NO_OPENSSL
+ bool ignoreSSLErrors;
+#endif
+ Channel() :state(IdleState), reply(0), written(0), bytesTotal(0), resendCurrent(false), reconnectAttempts(2),
+ authMehtod(QAuthenticatorPrivate::None), proxyAuthMehtod(QAuthenticatorPrivate::None)
+#ifndef QT_NO_OPENSSL
+ , ignoreSSLErrors(false)
+#endif
+ {}
};
-
- QHttpNetworkRequest(const QUrl &url = QUrl(), Operation operation = Get, Priority priority = NormalPriority);
- QHttpNetworkRequest(const QHttpNetworkRequest &other);
- virtual ~QHttpNetworkRequest();
- QHttpNetworkRequest &operator=(const QHttpNetworkRequest &other);
- bool operator==(const QHttpNetworkRequest &other) const;
-
- QUrl url() const;
- void setUrl(const QUrl &url);
-
- int majorVersion() const;
- int minorVersion() const;
-
- qint64 contentLength() const;
- void setContentLength(qint64 length);
-
- QList<QPair<QByteArray, QByteArray> > header() const;
- QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const;
- void setHeaderField(const QByteArray &name, const QByteArray &data);
-
- Operation operation() const;
- void setOperation(Operation operation);
-
- Priority priority() const;
- void setPriority(Priority priority);
-
- QIODevice *data() const;
- void setData(QIODevice *data);
-
-private:
- QSharedDataPointer<QHttpNetworkRequestPrivate> d;
- friend class QHttpNetworkRequestPrivate;
- friend class QHttpNetworkConnectionPrivate;
-};
-
-class QHttpNetworkReplyPrivate;
-class Q_AUTOTEST_EXPORT QHttpNetworkReply : public QObject, public QHttpNetworkHeader
-{
- Q_OBJECT
-public:
-
- explicit QHttpNetworkReply(const QUrl &url = QUrl(), QObject *parent = 0);
- virtual ~QHttpNetworkReply();
-
- QUrl url() const;
- void setUrl(const QUrl &url);
-
- int majorVersion() const;
- int minorVersion() const;
-
- qint64 contentLength() const;
- void setContentLength(qint64 length);
-
- QList<QPair<QByteArray, QByteArray> > header() const;
- QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const;
- void setHeaderField(const QByteArray &name, const QByteArray &data);
- void parseHeader(const QByteArray &header); // mainly for testing
-
- QHttpNetworkRequest request() const;
- void setRequest(const QHttpNetworkRequest &request);
-
- int statusCode() const;
- void setStatusCode(int code);
-
- QString errorString() const;
- void setErrorString(const QString &error);
-
- QString reasonPhrase() const;
-
- qint64 bytesAvailable() const;
- QByteArray read(qint64 maxSize = -1);
-
- bool isFinished() const;
+ static const int channelCount;
+ Channel channels[2]; // maximum of 2 socket connections to the server
+ bool pendingAuthSignal; // there is an incomplete authentication signal
+ bool pendingProxyAuthSignal; // there is an incomplete proxy authentication signal
+
+ void appendData(QHttpNetworkReply &reply, const QByteArray &fragment, bool compressed);
+ qint64 bytesAvailable(const QHttpNetworkReply &reply, bool compressed = false) const;
+ qint64 read(QHttpNetworkReply &reply, QByteArray &data, qint64 maxSize, bool compressed);
+ void emitReplyError(QAbstractSocket *socket, QHttpNetworkReply *reply, QNetworkReply::NetworkError errorCode);
+ bool handleAuthenticateChallenge(QAbstractSocket *socket, QHttpNetworkReply *reply, bool isProxy, bool &resend);
+ void allDone(QAbstractSocket *socket, QHttpNetworkReply *reply);
+ void handleStatus(QAbstractSocket *socket, QHttpNetworkReply *reply);
+ inline bool emitSignals(QHttpNetworkReply *reply);
+ inline bool expectContent(QHttpNetworkReply *reply);
#ifndef QT_NO_OPENSSL
- QSslConfiguration sslConfiguration() const;
- void setSslConfiguration(const QSslConfiguration &config);
- void ignoreSslErrors();
-
-Q_SIGNALS:
- void sslErrors(const QList<QSslError> &errors);
+ void _q_encrypted(); // start sending request (https)
+ void _q_sslErrors(const QList<QSslError> &errors); // ssl errors from the socket
+ QSslConfiguration sslConfiguration(const QHttpNetworkReply &reply) const;
#endif
-Q_SIGNALS:
- void readyRead();
- void finished();
- void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail = QString());
- void headerChanged();
- void dataReadProgress(int done, int total);
- void dataSendProgress(int done, int total);
+#ifndef QT_NO_NETWORKPROXY
+ QNetworkProxy networkProxy;
+#endif
-private:
- Q_DECLARE_PRIVATE(QHttpNetworkReply)
- friend class QHttpNetworkConnection;
- friend class QHttpNetworkConnectionPrivate;
+ //The request queues
+ QList<HttpMessagePair> highPriorityQueue;
+ QList<HttpMessagePair> lowPriorityQueue;
};
+
+
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QHttpNetworkRequest)
+//Q_DECLARE_METATYPE(QHttpNetworkRequest)
//Q_DECLARE_METATYPE(QHttpNetworkReply)
#endif // QT_NO_HTTP
diff --git a/src/network/access/qhttpnetworkheader.cpp b/src/network/access/qhttpnetworkheader.cpp
new file mode 100644
index 0000000..6f7f6f7
--- /dev/null
+++ b/src/network/access/qhttpnetworkheader.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qhttpnetworkheader_p.h"
+
+
+QT_BEGIN_NAMESPACE
+
+QHttpNetworkHeaderPrivate::QHttpNetworkHeaderPrivate(const QUrl &newUrl)
+ :url(newUrl)
+{
+}
+
+QHttpNetworkHeaderPrivate::QHttpNetworkHeaderPrivate(const QHttpNetworkHeaderPrivate &other)
+ :QSharedData(other)
+{
+ url = other.url;
+ fields = other.fields;
+}
+
+qint64 QHttpNetworkHeaderPrivate::contentLength() const
+{
+ bool ok = false;
+ QByteArray value = headerField("content-length");
+ qint64 length = value.toULongLong(&ok);
+ if (ok)
+ return length;
+ return -1; // the header field is not set
+}
+
+void QHttpNetworkHeaderPrivate::setContentLength(qint64 length)
+{
+ setHeaderField("Content-Length", QByteArray::number(length));
+}
+
+QByteArray QHttpNetworkHeaderPrivate::headerField(const QByteArray &name, const QByteArray &defaultValue) const
+{
+ QList<QByteArray> allValues = headerFieldValues(name);
+ if (allValues.isEmpty())
+ return defaultValue;
+
+ QByteArray result;
+ bool first = true;
+ foreach (QByteArray value, allValues) {
+ if (!first)
+ result += ", ";
+ first = false;
+ result += value;
+ }
+ return result;
+}
+
+QList<QByteArray> QHttpNetworkHeaderPrivate::headerFieldValues(const QByteArray &name) const
+{
+ QList<QByteArray> result;
+ QByteArray lowerName = name.toLower();
+ QList<QPair<QByteArray, QByteArray> >::ConstIterator it = fields.constBegin(),
+ end = fields.constEnd();
+ for ( ; it != end; ++it)
+ if (lowerName == it->first.toLower())
+ result += it->second;
+
+ return result;
+}
+
+void QHttpNetworkHeaderPrivate::setHeaderField(const QByteArray &name, const QByteArray &data)
+{
+ QByteArray lowerName = name.toLower();
+ QList<QPair<QByteArray, QByteArray> >::Iterator it = fields.begin();
+ while (it != fields.end()) {
+ if (lowerName == it->first.toLower())
+ it = fields.erase(it);
+ else
+ ++it;
+ }
+ fields.append(qMakePair(name, data));
+}
+
+bool QHttpNetworkHeaderPrivate::operator==(const QHttpNetworkHeaderPrivate &other) const
+{
+ return (url == other.url);
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/gui/embedded/qkbdpc101_qws.h b/src/network/access/qhttpnetworkheader_p.h
index f9f0104..4e62352 100644
--- a/src/gui/embedded/qkbdpc101_qws.h
+++ b/src/network/access/qhttpnetworkheader_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,57 +39,73 @@
**
****************************************************************************/
-#ifndef QKBDPC101_QWS_H
-#define QKBDPC101_QWS_H
+#ifndef QHTTPNETWORKHEADER_H
+#define QHTTPNETWORKHEADER_H
-#include <QtGui/qkbd_qws.h>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the Network Access API. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+#ifndef QT_NO_HTTP
-QT_BEGIN_HEADER
+#include <qshareddata.h>
+#include <qurl.h>
QT_BEGIN_NAMESPACE
-QT_MODULE(Gui)
+class Q_AUTOTEST_EXPORT QHttpNetworkHeader
+{
+public:
+ virtual ~QHttpNetworkHeader() {};
+ virtual QUrl url() const = 0;
+ virtual void setUrl(const QUrl &url) = 0;
-#ifndef QT_NO_QWS_KEYBOARD
+ virtual int majorVersion() const = 0;
+ virtual int minorVersion() const = 0;
-#ifndef QT_NO_QWS_KBD_PC101
+ virtual qint64 contentLength() const = 0;
+ virtual void setContentLength(qint64 length) = 0;
-struct QWSKeyMap {
- uint key_code;
- ushort unicode;
- ushort shift_unicode;
- ushort ctrl_unicode;
+ virtual QList<QPair<QByteArray, QByteArray> > header() const = 0;
+ virtual QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const = 0;
+ virtual void setHeaderField(const QByteArray &name, const QByteArray &data) = 0;
};
-class QWSPC101KeyboardHandler : public QWSKeyboardHandler
+class QHttpNetworkHeaderPrivate : public QSharedData
{
public:
- explicit QWSPC101KeyboardHandler(const QString&);
- virtual ~QWSPC101KeyboardHandler();
-
- virtual void doKey(uchar scancode);
- virtual const QWSKeyMap *keyMap() const;
-
-protected:
- bool shift;
- bool alt;
- bool ctrl;
- bool caps;
-#if defined(QT_QWS_IPAQ)
- uint ipaq_return_pressed:1;
-#endif
- uint extended:2;
- Qt::KeyboardModifiers modifiers;
- int prevuni;
- int prevkey;
-};
+ QUrl url;
+ QList<QPair<QByteArray, QByteArray> > fields;
-#endif // QT_NO_QWS_KBD_PC101
+ QHttpNetworkHeaderPrivate(const QUrl &newUrl = QUrl());
+ QHttpNetworkHeaderPrivate(const QHttpNetworkHeaderPrivate &other);
+ qint64 contentLength() const;
+ void setContentLength(qint64 length);
+
+ QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const;
+ QList<QByteArray> headerFieldValues(const QByteArray &name) const;
+ void setHeaderField(const QByteArray &name, const QByteArray &data);
+ bool operator==(const QHttpNetworkHeaderPrivate &other) const;
+
+};
-#endif // QT_NO_QWS_KEYBOARD
QT_END_NAMESPACE
-QT_END_HEADER
-#endif // QKBDPC101_QWS_H
+#endif // QT_NO_HTTP
+
+
+#endif // QHTTPNETWORKHEADER_H
+
+
+
+
+
+
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
new file mode 100644
index 0000000..fe3f6af
--- /dev/null
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -0,0 +1,663 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qhttpnetworkreply_p.h"
+#include "qhttpnetworkconnection_p.h"
+
+#include <qbytearraymatcher.h>
+
+#ifndef QT_NO_HTTP
+
+#ifndef QT_NO_OPENSSL
+# include <QtNetwork/qsslkey.h>
+# include <QtNetwork/qsslcipher.h>
+# include <QtNetwork/qsslconfiguration.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QHttpNetworkReply::QHttpNetworkReply(const QUrl &url, QObject *parent)
+ : QObject(*new QHttpNetworkReplyPrivate(url), parent)
+{
+}
+
+QHttpNetworkReply::~QHttpNetworkReply()
+{
+ Q_D(QHttpNetworkReply);
+ if (d->connection) {
+ d->connection->d_func()->removeReply(this);
+ }
+}
+
+QUrl QHttpNetworkReply::url() const
+{
+ return d_func()->url;
+}
+void QHttpNetworkReply::setUrl(const QUrl &url)
+{
+ Q_D(QHttpNetworkReply);
+ d->url = url;
+}
+
+qint64 QHttpNetworkReply::contentLength() const
+{
+ return d_func()->contentLength();
+}
+
+void QHttpNetworkReply::setContentLength(qint64 length)
+{
+ Q_D(QHttpNetworkReply);
+ d->setContentLength(length);
+}
+
+QList<QPair<QByteArray, QByteArray> > QHttpNetworkReply::header() const
+{
+ return d_func()->fields;
+}
+
+QByteArray QHttpNetworkReply::headerField(const QByteArray &name, const QByteArray &defaultValue) const
+{
+ return d_func()->headerField(name, defaultValue);
+}
+
+void QHttpNetworkReply::setHeaderField(const QByteArray &name, const QByteArray &data)
+{
+ Q_D(QHttpNetworkReply);
+ d->setHeaderField(name, data);
+}
+
+void QHttpNetworkReply::parseHeader(const QByteArray &header)
+{
+ Q_D(QHttpNetworkReply);
+ d->parseHeader(header);
+}
+
+QHttpNetworkRequest QHttpNetworkReply::request() const
+{
+ return d_func()->request;
+}
+
+void QHttpNetworkReply::setRequest(const QHttpNetworkRequest &request)
+{
+ Q_D(QHttpNetworkReply);
+ d->request = request;
+}
+
+int QHttpNetworkReply::statusCode() const
+{
+ return d_func()->statusCode;
+}
+
+void QHttpNetworkReply::setStatusCode(int code)
+{
+ Q_D(QHttpNetworkReply);
+ d->statusCode = code;
+}
+
+QString QHttpNetworkReply::errorString() const
+{
+ return d_func()->errorString;
+}
+
+QString QHttpNetworkReply::reasonPhrase() const
+{
+ return d_func()->reasonPhrase;
+}
+
+void QHttpNetworkReply::setErrorString(const QString &error)
+{
+ Q_D(QHttpNetworkReply);
+ d->errorString = error;
+}
+
+int QHttpNetworkReply::majorVersion() const
+{
+ return d_func()->majorVersion;
+}
+
+int QHttpNetworkReply::minorVersion() const
+{
+ return d_func()->minorVersion;
+}
+
+qint64 QHttpNetworkReply::bytesAvailable() const
+{
+ Q_D(const QHttpNetworkReply);
+ if (d->connection)
+ return d->connection->d_func()->bytesAvailable(*this);
+ else
+ return -1;
+}
+
+QByteArray QHttpNetworkReply::read(qint64 maxSize)
+{
+ Q_D(QHttpNetworkReply);
+ QByteArray data;
+ if (d->connection)
+ d->connection->d_func()->read(*this, data, maxSize, false);
+ return data;
+}
+
+bool QHttpNetworkReply::isFinished() const
+{
+ return d_func()->state == QHttpNetworkReplyPrivate::AllDoneState;
+}
+
+
+
+QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl)
+ : QHttpNetworkHeaderPrivate(newUrl), state(NothingDoneState), statusCode(100),
+ majorVersion(0), minorVersion(0), bodyLength(0), contentRead(0), totalProgress(0),
+ currentChunkSize(0), currentChunkRead(0), connection(0), initInflate(false),
+ autoDecompress(false), requestIsBuffering(false), requestIsPrepared(false)
+{
+}
+
+QHttpNetworkReplyPrivate::~QHttpNetworkReplyPrivate()
+{
+}
+
+void QHttpNetworkReplyPrivate::clear()
+{
+ state = NothingDoneState;
+ statusCode = 100;
+ bodyLength = 0;
+ contentRead = 0;
+ totalProgress = 0;
+ currentChunkSize = 0;
+ currentChunkRead = 0;
+ connection = 0;
+#ifndef QT_NO_COMPRESS
+ if (initInflate)
+ inflateEnd(&inflateStrm);
+#endif
+ initInflate = false;
+ streamEnd = false;
+ autoDecompress = false;
+ fields.clear();
+}
+
+// QHttpNetworkReplyPrivate
+qint64 QHttpNetworkReplyPrivate::bytesAvailable() const
+{
+ return (state != ReadingDataState ? 0 : fragment.size());
+}
+
+bool QHttpNetworkReplyPrivate::isGzipped()
+{
+ QByteArray encoding = headerField("content-encoding");
+ return encoding.toLower() == "gzip";
+}
+
+void QHttpNetworkReplyPrivate::removeAutoDecompressHeader()
+{
+ // The header "Content-Encoding = gzip" is retained.
+ // Content-Length is removed since the actual one send by the server is for compressed data
+ QByteArray name("content-length");
+ QByteArray lowerName = name.toLower();
+ QList<QPair<QByteArray, QByteArray> >::Iterator it = fields.begin(),
+ end = fields.end();
+ while (it != end) {
+ if (name == it->first.toLower()) {
+ fields.erase(it);
+ break;
+ }
+ ++it;
+ }
+
+}
+
+bool QHttpNetworkReplyPrivate::findChallenge(bool forProxy, QByteArray &challenge) const
+{
+ challenge.clear();
+ // find out the type of authentication protocol requested.
+ QByteArray header = forProxy ? "proxy-authenticate" : "www-authenticate";
+ // pick the best protocol (has to match parsing in QAuthenticatorPrivate)
+ QList<QByteArray> challenges = headerFieldValues(header);
+ for (int i = 0; i<challenges.size(); i++) {
+ QByteArray line = challenges.at(i);
+ if (!line.toLower().startsWith("negotiate"))
+ challenge = line;
+ }
+ return !challenge.isEmpty();
+}
+
+QAuthenticatorPrivate::Method QHttpNetworkReplyPrivate::authenticationMethod(bool isProxy) const
+{
+ // The logic is same as the one used in void QAuthenticatorPrivate::parseHttpResponse()
+ QAuthenticatorPrivate::Method method = QAuthenticatorPrivate::None;
+ QByteArray header = isProxy ? "proxy-authenticate" : "www-authenticate";
+ QList<QByteArray> challenges = headerFieldValues(header);
+ for (int i = 0; i<challenges.size(); i++) {
+ QByteArray line = challenges.at(i).trimmed().toLower();
+ if (method < QAuthenticatorPrivate::Basic
+ && line.startsWith("basic")) {
+ method = QAuthenticatorPrivate::Basic;
+ } else if (method < QAuthenticatorPrivate::Ntlm
+ && line.startsWith("ntlm")) {
+ method = QAuthenticatorPrivate::Ntlm;
+ } else if (method < QAuthenticatorPrivate::DigestMd5
+ && line.startsWith("digest")) {
+ method = QAuthenticatorPrivate::DigestMd5;
+ }
+ }
+ return method;
+}
+
+#ifndef QT_NO_COMPRESS
+bool QHttpNetworkReplyPrivate::gzipCheckHeader(QByteArray &content, int &pos)
+{
+ int method = 0; // method byte
+ int flags = 0; // flags byte
+ bool ret = false;
+
+ // Assure two bytes in the buffer so we can peek ahead -- handle case
+ // where first byte of header is at the end of the buffer after the last
+ // gzip segment
+ pos = -1;
+ QByteArray &body = content;
+ int maxPos = body.size()-1;
+ if (maxPos < 1) {
+ return ret;
+ }
+
+ // Peek ahead to check the gzip magic header
+ if (body[0] != char(gz_magic[0]) ||
+ body[1] != char(gz_magic[1])) {
+ return ret;
+ }
+ pos += 2;
+ // Check the rest of the gzip header
+ if (++pos <= maxPos)
+ method = body[pos];
+ if (pos++ <= maxPos)
+ flags = body[pos];
+ if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
+ return ret;
+ }
+
+ // Discard time, xflags and OS code:
+ pos += 6;
+ if (pos > maxPos)
+ return ret;
+ if ((flags & EXTRA_FIELD) && ((pos+2) <= maxPos)) { // skip the extra field
+ unsigned len = (unsigned)body[++pos];
+ len += ((unsigned)body[++pos])<<8;
+ pos += len;
+ if (pos > maxPos)
+ return ret;
+ }
+ if ((flags & ORIG_NAME) != 0) { // skip the original file name
+ while(++pos <= maxPos && body[pos]) {}
+ }
+ if ((flags & COMMENT) != 0) { // skip the .gz file comment
+ while(++pos <= maxPos && body[pos]) {}
+ }
+ if ((flags & HEAD_CRC) != 0) { // skip the header crc
+ pos += 2;
+ if (pos > maxPos)
+ return ret;
+ }
+ ret = (pos < maxPos); // return failed, if no more bytes left
+ return ret;
+}
+
+int QHttpNetworkReplyPrivate::gunzipBodyPartially(QByteArray &compressed, QByteArray &inflated)
+{
+ int ret = Z_DATA_ERROR;
+ unsigned have;
+ unsigned char out[CHUNK];
+ int pos = -1;
+
+ if (!initInflate) {
+ // check the header
+ if (!gzipCheckHeader(compressed, pos))
+ return ret;
+ // allocate inflate state
+ inflateStrm.zalloc = Z_NULL;
+ inflateStrm.zfree = Z_NULL;
+ inflateStrm.opaque = Z_NULL;
+ inflateStrm.avail_in = 0;
+ inflateStrm.next_in = Z_NULL;
+ ret = inflateInit2(&inflateStrm, -MAX_WBITS);
+ if (ret != Z_OK)
+ return ret;
+ initInflate = true;
+ streamEnd = false;
+ }
+
+ //remove the header.
+ compressed.remove(0, pos+1);
+ // expand until deflate stream ends
+ inflateStrm.next_in = (unsigned char *)compressed.data();
+ inflateStrm.avail_in = compressed.size();
+ do {
+ inflateStrm.avail_out = sizeof(out);
+ inflateStrm.next_out = out;
+ ret = inflate(&inflateStrm, Z_NO_FLUSH);
+ switch (ret) {
+ case Z_NEED_DICT:
+ ret = Z_DATA_ERROR;
+ // and fall through
+ case Z_DATA_ERROR:
+ case Z_MEM_ERROR:
+ inflateEnd(&inflateStrm);
+ initInflate = false;
+ return ret;
+ }
+ have = sizeof(out) - inflateStrm.avail_out;
+ inflated.append(QByteArray((const char *)out, have));
+ } while (inflateStrm.avail_out == 0);
+ // clean up and return
+ if (ret <= Z_ERRNO || ret == Z_STREAM_END) {
+ inflateEnd(&inflateStrm);
+ initInflate = false;
+ }
+ streamEnd = (ret == Z_STREAM_END);
+ return ret;
+}
+#endif
+
+qint64 QHttpNetworkReplyPrivate::readStatus(QAbstractSocket *socket)
+{
+ qint64 bytes = 0;
+ char c;
+
+ while (socket->bytesAvailable()) {
+ // allow both CRLF & LF (only) line endings
+ if (socket->peek(&c, 1) == 1 && c == '\n') {
+ bytes += socket->read(&c, 1); // read the "n"
+ // remove the CR at the end
+ if (fragment.endsWith('\r')) {
+ fragment.truncate(fragment.length()-1);
+ }
+ parseStatus(fragment);
+ state = ReadingHeaderState;
+ fragment.clear(); // next fragment
+ break;
+ } else {
+ c = 0;
+ bytes += socket->read(&c, 1);
+ fragment.append(c);
+ }
+ }
+ return bytes;
+}
+
+void QHttpNetworkReplyPrivate::parseStatus(const QByteArray &status)
+{
+ const QByteArrayMatcher sp(" ");
+ int i = sp.indexIn(status);
+ const QByteArray version = status.mid(0, i);
+ int j = sp.indexIn(status, i + 1);
+ const QByteArray code = status.mid(i + 1, j - i - 1);
+ const QByteArray reason = status.mid(j + 1, status.count() - j);
+
+ const QByteArrayMatcher slash("/");
+ int k = slash.indexIn(version);
+ const QByteArrayMatcher dot(".");
+ int l = dot.indexIn(version, k);
+ const QByteArray major = version.mid(k + 1, l - k - 1);
+ const QByteArray minor = version.mid(l + 1, version.count() - l);
+
+ majorVersion = QString::fromAscii(major.constData()).toInt();
+ minorVersion = QString::fromAscii(minor.constData()).toInt();
+ statusCode = QString::fromAscii(code.constData()).toInt();
+ reasonPhrase = QString::fromAscii(reason.constData());
+}
+
+qint64 QHttpNetworkReplyPrivate::readHeader(QAbstractSocket *socket)
+{
+ qint64 bytes = 0;
+ char crlfcrlf[5];
+ crlfcrlf[4] = '\0';
+ char c = 0;
+ bool allHeaders = false;
+ while (!allHeaders && socket->bytesAvailable()) {
+ if (socket->peek(&c, 1) == 1 && c == '\n') {
+ // check for possible header endings. As per HTTP rfc,
+ // the header endings will be marked by CRLFCRLF. But
+ // we will allow CRLFLF, LFLF & CRLFCRLF
+ if (fragment.endsWith("\n\r") || fragment.endsWith('\n'))
+ allHeaders = true;
+ }
+ bytes += socket->read(&c, 1);
+ fragment.append(c);
+ }
+ // we received all headers now parse them
+ if (allHeaders) {
+ parseHeader(fragment);
+ state = ReadingDataState;
+ fragment.clear(); // next fragment
+ bodyLength = contentLength(); // cache the length
+ }
+ return bytes;
+}
+
+void QHttpNetworkReplyPrivate::parseHeader(const QByteArray &header)
+{
+ // see rfc2616, sec 4 for information about HTTP/1.1 headers.
+ // allows relaxed parsing here, accepts both CRLF & LF line endings
+ const QByteArrayMatcher lf("\n");
+ const QByteArrayMatcher colon(":");
+ int i = 0;
+ while (i < header.count()) {
+ int j = colon.indexIn(header, i); // field-name
+ if (j == -1)
+ break;
+ const QByteArray field = header.mid(i, j - i).trimmed();
+ j++;
+ // any number of LWS is allowed before and after the value
+ QByteArray value;
+ do {
+ i = lf.indexIn(header, j);
+ if (i == -1)
+ break;
+ if (!value.isEmpty())
+ value += ' ';
+ // check if we have CRLF or only LF
+ bool hasCR = (i && header[i-1] == '\r');
+ int length = i -(hasCR ? 1: 0) - j;
+ value += header.mid(j, length).trimmed();
+ j = ++i;
+ } while (i < header.count() && (header.at(i) == ' ' || header.at(i) == '\t'));
+ if (i == -1)
+ break; // something is wrong
+
+ fields.append(qMakePair(field, value));
+ }
+}
+
+bool QHttpNetworkReplyPrivate::isChunked()
+{
+ return headerField("transfer-encoding").toLower().contains("chunked");
+}
+
+bool QHttpNetworkReplyPrivate::connectionCloseEnabled()
+{
+ return (headerField("connection").toLower().contains("close") ||
+ headerField("proxy-connection").toLower().contains("close"));
+}
+
+qint64 QHttpNetworkReplyPrivate::readBody(QAbstractSocket *socket, QIODevice *out)
+{
+ qint64 bytes = 0;
+ if (isChunked()) {
+ bytes += transferChunked(socket, out); // chunked transfer encoding (rfc 2616, sec 3.6)
+ } else if (bodyLength > 0) { // we have a Content-Length
+ bytes += transferRaw(socket, out, bodyLength - contentRead);
+ if (contentRead + bytes == bodyLength)
+ state = AllDoneState;
+ } else {
+ bytes += transferRaw(socket, out, socket->bytesAvailable());
+ }
+ if (state == AllDoneState)
+ socket->readAll(); // Read the rest to clean (CRLF)
+ contentRead += bytes;
+ return bytes;
+}
+
+qint64 QHttpNetworkReplyPrivate::transferRaw(QIODevice *in, QIODevice *out, qint64 size)
+{
+ qint64 bytes = 0;
+ Q_ASSERT(in);
+ Q_ASSERT(out);
+
+ int toBeRead = qMin<qint64>(128*1024, qMin<qint64>(size, in->bytesAvailable()));
+ QByteArray raw(toBeRead, 0);
+ while (size > 0) {
+ qint64 read = in->read(raw.data(), raw.size());
+ if (read == 0)
+ return bytes;
+ // ### error checking here
+ qint64 written = out->write(raw.data(), read);
+ if (written == 0)
+ return bytes;
+ if (read != written)
+ qDebug() << "### read" << read << "written" << written;
+ bytes += read;
+ size -= read;
+ out->waitForBytesWritten(-1); // throttle
+ }
+ return bytes;
+
+}
+
+qint64 QHttpNetworkReplyPrivate::transferChunked(QIODevice *in, QIODevice *out)
+{
+ qint64 bytes = 0;
+ while (in->bytesAvailable()) { // while we can read from input
+ // if we are done with the current chunk, get the size of the new chunk
+ if (currentChunkRead >= currentChunkSize) {
+ currentChunkSize = 0;
+ currentChunkRead = 0;
+ if (bytes) {
+ char crlf[2];
+ bytes += in->read(crlf, 2); // read the "\r\n" after the chunk
+ }
+ bytes += getChunkSize(in, &currentChunkSize);
+ if (currentChunkSize == -1)
+ break;
+ }
+ // if the chunk size is 0, end of the stream
+ if (currentChunkSize == 0) {
+ state = AllDoneState;
+ break;
+ }
+ // otherwise, read data
+ qint64 readSize = qMin(in->bytesAvailable(), currentChunkSize - currentChunkRead);
+ QByteArray buffer(readSize, 0);
+ qint64 read = in->read(buffer.data(), readSize);
+ bytes += read;
+ currentChunkRead += read;
+ qint64 written = out->write(buffer);
+ Q_UNUSED(written); // Avoid compile warning when building release
+ Q_ASSERT(read == written);
+ // ### error checking here
+ out->waitForBytesWritten(-1);
+ }
+ return bytes;
+}
+
+qint64 QHttpNetworkReplyPrivate::getChunkSize(QIODevice *in, qint64 *chunkSize)
+{
+ qint64 bytes = 0;
+ char crlf[2];
+ *chunkSize = -1;
+ int bytesAvailable = in->bytesAvailable();
+ while (bytesAvailable > bytes) {
+ qint64 sniffedBytes = in->peek(crlf, 2);
+ int fragmentSize = fragment.size();
+ // check the next two bytes for a "\r\n", skip blank lines
+ if ((fragmentSize && sniffedBytes == 2 && crlf[0] == '\r' && crlf[1] == '\n')
+ ||(fragmentSize > 1 && fragment.endsWith('\r') && crlf[0] == '\n'))
+ {
+ bytes += in->read(crlf, 1); // read the \r or \n
+ if (crlf[0] == '\r')
+ bytes += in->read(crlf, 1); // read the \n
+ bool ok = false;
+ // ignore the chunk-extension
+ fragment = fragment.mid(0, fragment.indexOf(';')).trimmed();
+ *chunkSize = fragment.toLong(&ok, 16);
+ fragment.clear();
+ break; // size done
+ } else {
+ // read the fragment to the buffer
+ char c = 0;
+ bytes += in->read(&c, 1);
+ fragment.append(c);
+ }
+ }
+ return bytes;
+}
+
+// SSL support below
+#ifndef QT_NO_OPENSSL
+
+QSslConfiguration QHttpNetworkReply::sslConfiguration() const
+{
+ Q_D(const QHttpNetworkReply);
+ if (d->connection)
+ return d->connection->d_func()->sslConfiguration(*this);
+ return QSslConfiguration();
+}
+
+void QHttpNetworkReply::setSslConfiguration(const QSslConfiguration &config)
+{
+ Q_D(QHttpNetworkReply);
+ if (d->connection)
+ d->connection->setSslConfiguration(config);
+}
+
+void QHttpNetworkReply::ignoreSslErrors()
+{
+ Q_D(QHttpNetworkReply);
+ if (d->connection)
+ d->connection->ignoreSslErrors();
+}
+
+
+#endif //QT_NO_OPENSSL
+
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_HTTP \ No newline at end of file
diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h
new file mode 100644
index 0000000..c17c65c
--- /dev/null
+++ b/src/network/access/qhttpnetworkreply_p.h
@@ -0,0 +1,224 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QHTTPNETWORKREPLY_H
+#define QHTTPNETWORKREPLY_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the Network Access API. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+#ifndef QT_NO_HTTP
+
+#ifndef QT_NO_COMPRESS
+# include <zlib.h>
+static const unsigned char gz_magic[2] = {0x1f, 0x8b}; // gzip magic header
+// gzip flag byte
+#define HEAD_CRC 0x02 // bit 1 set: header CRC present
+#define EXTRA_FIELD 0x04 // bit 2 set: extra field present
+#define ORIG_NAME 0x08 // bit 3 set: original file name present
+#define COMMENT 0x10 // bit 4 set: file comment present
+#define RESERVED 0xE0 // bits 5..7: reserved
+#define CHUNK 16384
+#endif
+
+#include <QtNetwork/qtcpsocket.h>
+// it's safe to include these even if SSL support is not enabled
+#include <QtNetwork/qsslsocket.h>
+#include <QtNetwork/qsslerror.h>
+
+#include <QtNetwork/qnetworkrequest.h>
+#include <QtNetwork/qnetworkreply.h>
+#include <qbuffer.h>
+
+#include <private/qobject_p.h>
+#include <private/qhttpnetworkheader_p.h>
+#include <private/qhttpnetworkrequest_p.h>
+#include <private/qauthenticator_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QHttpNetworkConnection;
+class QHttpNetworkRequest;
+class QHttpNetworkConnectionPrivate;
+class QHttpNetworkReplyPrivate;
+class Q_AUTOTEST_EXPORT QHttpNetworkReply : public QObject, public QHttpNetworkHeader
+{
+ Q_OBJECT
+public:
+
+ explicit QHttpNetworkReply(const QUrl &url = QUrl(), QObject *parent = 0);
+ virtual ~QHttpNetworkReply();
+
+ QUrl url() const;
+ void setUrl(const QUrl &url);
+
+ int majorVersion() const;
+ int minorVersion() const;
+
+ qint64 contentLength() const;
+ void setContentLength(qint64 length);
+
+ QList<QPair<QByteArray, QByteArray> > header() const;
+ QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const;
+ void setHeaderField(const QByteArray &name, const QByteArray &data);
+ void parseHeader(const QByteArray &header); // mainly for testing
+
+ QHttpNetworkRequest request() const;
+ void setRequest(const QHttpNetworkRequest &request);
+
+ int statusCode() const;
+ void setStatusCode(int code);
+
+ QString errorString() const;
+ void setErrorString(const QString &error);
+
+ QString reasonPhrase() const;
+
+ qint64 bytesAvailable() const;
+ QByteArray read(qint64 maxSize = -1);
+
+ bool isFinished() const;
+
+#ifndef QT_NO_OPENSSL
+ QSslConfiguration sslConfiguration() const;
+ void setSslConfiguration(const QSslConfiguration &config);
+ void ignoreSslErrors();
+
+Q_SIGNALS:
+ void sslErrors(const QList<QSslError> &errors);
+#endif
+
+Q_SIGNALS:
+ void readyRead();
+ void finished();
+ void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail = QString());
+ void headerChanged();
+ void dataReadProgress(int done, int total);
+ void dataSendProgress(int done, int total);
+
+private:
+ Q_DECLARE_PRIVATE(QHttpNetworkReply)
+ friend class QHttpNetworkConnection;
+ friend class QHttpNetworkConnectionPrivate;
+};
+
+
+class QHttpNetworkReplyPrivate : public QObjectPrivate, public QHttpNetworkHeaderPrivate
+{
+public:
+ QHttpNetworkReplyPrivate(const QUrl &newUrl = QUrl());
+ ~QHttpNetworkReplyPrivate();
+ qint64 readStatus(QAbstractSocket *socket);
+ void parseStatus(const QByteArray &status);
+ qint64 readHeader(QAbstractSocket *socket);
+ void parseHeader(const QByteArray &header);
+ qint64 readBody(QAbstractSocket *socket, QIODevice *out);
+ bool findChallenge(bool forProxy, QByteArray &challenge) const;
+ QAuthenticatorPrivate::Method authenticationMethod(bool isProxy) const;
+ void clear();
+
+ qint64 transferRaw(QIODevice *in, QIODevice *out, qint64 size);
+ qint64 transferChunked(QIODevice *in, QIODevice *out);
+ qint64 getChunkSize(QIODevice *in, qint64 *chunkSize);
+
+ qint64 bytesAvailable() const;
+ bool isChunked();
+ bool connectionCloseEnabled();
+ bool isGzipped();
+#ifndef QT_NO_COMPRESS
+ bool gzipCheckHeader(QByteArray &content, int &pos);
+ int gunzipBodyPartially(QByteArray &compressed, QByteArray &inflated);
+#endif
+ void removeAutoDecompressHeader();
+
+ enum ReplyState {
+ NothingDoneState,
+ ReadingStatusState,
+ ReadingHeaderState,
+ ReadingDataState,
+ AllDoneState
+ } state;
+
+ QHttpNetworkRequest request;
+ int statusCode;
+ int majorVersion;
+ int minorVersion;
+ QString errorString;
+ QString reasonPhrase;
+ qint64 bodyLength;
+ qint64 contentRead;
+ qint64 totalProgress;
+ QByteArray fragment;
+ qint64 currentChunkSize;
+ qint64 currentChunkRead;
+ QPointer<QHttpNetworkConnection> connection;
+ bool initInflate;
+ bool streamEnd;
+#ifndef QT_NO_COMPRESS
+ z_stream inflateStrm;
+#endif
+ bool autoDecompress;
+
+ QByteArray responseData; // uncompressed body
+ QByteArray compressedData; // compressed body (temporary)
+ QBuffer requestDataBuffer;
+ bool requestIsBuffering;
+ bool requestIsPrepared;
+};
+
+
+
+
+QT_END_NAMESPACE
+
+//Q_DECLARE_METATYPE(QHttpNetworkReply)
+
+#endif // QT_NO_HTTP
+
+
+#endif // QHTTPNETWORKREPLY_H
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp
new file mode 100644
index 0000000..420cb69
--- /dev/null
+++ b/src/network/access/qhttpnetworkrequest.cpp
@@ -0,0 +1,261 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qhttpnetworkrequest_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op,
+ QHttpNetworkRequest::Priority pri, const QUrl &newUrl)
+ : QHttpNetworkHeaderPrivate(newUrl), operation(op), priority(pri), data(0),
+ autoDecompress(false)
+{
+}
+
+QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(const QHttpNetworkRequestPrivate &other)
+ : QHttpNetworkHeaderPrivate(other)
+{
+ operation = other.operation;
+ priority = other.priority;
+ data = other.data;
+ autoDecompress = other.autoDecompress;
+}
+
+QHttpNetworkRequestPrivate::~QHttpNetworkRequestPrivate()
+{
+}
+
+bool QHttpNetworkRequestPrivate::operator==(const QHttpNetworkRequestPrivate &other) const
+{
+ return QHttpNetworkHeaderPrivate::operator==(other)
+ && (operation == other.operation)
+ && (data == other.data);
+}
+
+QByteArray QHttpNetworkRequestPrivate::methodName() const
+{
+ QByteArray ba;
+ switch (operation) {
+ case QHttpNetworkRequest::Options:
+ ba += "OPTIONS";
+ break;
+ case QHttpNetworkRequest::Get:
+ ba += "GET";
+ break;
+ case QHttpNetworkRequest::Head:
+ ba += "HEAD";
+ break;
+ case QHttpNetworkRequest::Post:
+ ba += "POST";
+ break;
+ case QHttpNetworkRequest::Put:
+ ba += "PUT";
+ break;
+ case QHttpNetworkRequest::Delete:
+ ba += "DELETE";
+ break;
+ case QHttpNetworkRequest::Trace:
+ ba += "TRACE";
+ break;
+ case QHttpNetworkRequest::Connect:
+ ba += "CONNECT";
+ break;
+ default:
+ break;
+ }
+ return ba;
+}
+
+QByteArray QHttpNetworkRequestPrivate::uri(bool throughProxy) const
+{
+ QUrl::FormattingOptions format(QUrl::RemoveFragment);
+
+ // for POST, query data is send as content
+ if (operation == QHttpNetworkRequest::Post && !data)
+ format |= QUrl::RemoveQuery;
+ // for requests through proxy, the Request-URI contains full url
+ if (throughProxy)
+ format |= QUrl::RemoveUserInfo;
+ else
+ format |= QUrl::RemoveScheme | QUrl::RemoveAuthority;
+ QByteArray uri = url.toEncoded(format);
+ if (uri.isEmpty() || (throughProxy && url.path().isEmpty()))
+ uri += '/';
+ return uri;
+}
+
+QByteArray QHttpNetworkRequestPrivate::header(const QHttpNetworkRequest &request, bool throughProxy)
+{
+ QByteArray ba = request.d->methodName();
+ QByteArray uri = request.d->uri(throughProxy);
+ ba += " " + uri;
+
+ QString majorVersion = QString::number(request.majorVersion());
+ QString minorVersion = QString::number(request.minorVersion());
+ ba += " HTTP/" + majorVersion.toLatin1() + "." + minorVersion.toLatin1() + "\r\n";
+
+ QList<QPair<QByteArray, QByteArray> > fields = request.header();
+ QList<QPair<QByteArray, QByteArray> >::const_iterator it = fields.constBegin();
+ for (; it != fields.constEnd(); ++it)
+ ba += it->first + ": " + it->second + "\r\n";
+ if (request.d->operation == QHttpNetworkRequest::Post) {
+ // add content type, if not set in the request
+ if (request.headerField("content-type").isEmpty())
+ ba += "Content-Type: application/x-www-form-urlencoded\r\n";
+ if (!request.d->data && request.d->url.hasQuery()) {
+ QByteArray query = request.d->url.encodedQuery();
+ ba += "Content-Length: "+ QByteArray::number(query.size()) + "\r\n";
+ ba += "\r\n";
+ ba += query;
+ } else {
+ ba += "\r\n";
+ }
+ } else {
+ ba += "\r\n";
+ }
+ return ba;
+}
+
+
+// QHttpNetworkRequest
+
+QHttpNetworkRequest::QHttpNetworkRequest(const QUrl &url, Operation operation, Priority priority)
+ : d(new QHttpNetworkRequestPrivate(operation, priority, url))
+{
+}
+
+QHttpNetworkRequest::QHttpNetworkRequest(const QHttpNetworkRequest &other)
+ : QHttpNetworkHeader(other), d(other.d)
+{
+}
+
+QHttpNetworkRequest::~QHttpNetworkRequest()
+{
+}
+
+QUrl QHttpNetworkRequest::url() const
+{
+ return d->url;
+}
+void QHttpNetworkRequest::setUrl(const QUrl &url)
+{
+ d->url = url;
+}
+
+qint64 QHttpNetworkRequest::contentLength() const
+{
+ return d->contentLength();
+}
+
+void QHttpNetworkRequest::setContentLength(qint64 length)
+{
+ d->setContentLength(length);
+}
+
+QList<QPair<QByteArray, QByteArray> > QHttpNetworkRequest::header() const
+{
+ return d->fields;
+}
+
+QByteArray QHttpNetworkRequest::headerField(const QByteArray &name, const QByteArray &defaultValue) const
+{
+ return d->headerField(name, defaultValue);
+}
+
+void QHttpNetworkRequest::setHeaderField(const QByteArray &name, const QByteArray &data)
+{
+ d->setHeaderField(name, data);
+}
+
+QHttpNetworkRequest &QHttpNetworkRequest::operator=(const QHttpNetworkRequest &other)
+{
+ d = other.d;
+ return *this;
+}
+
+bool QHttpNetworkRequest::operator==(const QHttpNetworkRequest &other) const
+{
+ return d->operator==(*other.d);
+}
+
+QHttpNetworkRequest::Operation QHttpNetworkRequest::operation() const
+{
+ return d->operation;
+}
+
+void QHttpNetworkRequest::setOperation(Operation operation)
+{
+ d->operation = operation;
+}
+
+QHttpNetworkRequest::Priority QHttpNetworkRequest::priority() const
+{
+ return d->priority;
+}
+
+void QHttpNetworkRequest::setPriority(Priority priority)
+{
+ d->priority = priority;
+}
+
+QIODevice *QHttpNetworkRequest::data() const
+{
+ return d->data;
+}
+
+void QHttpNetworkRequest::setData(QIODevice *data)
+{
+ d->data = data;
+}
+
+int QHttpNetworkRequest::majorVersion() const
+{
+ return 1;
+}
+
+int QHttpNetworkRequest::minorVersion() const
+{
+ return 1;
+}
+
+
+QT_END_NAMESPACE
+
diff --git a/src/network/access/qhttpnetworkrequest_p.h b/src/network/access/qhttpnetworkrequest_p.h
new file mode 100644
index 0000000..d18e116
--- /dev/null
+++ b/src/network/access/qhttpnetworkrequest_p.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QHTTPNETWORKREQUEST_H
+#define QHTTPNETWORKREQUEST_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the Network Access API. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+#ifndef QT_NO_HTTP
+
+#include <private/qhttpnetworkheader_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QHttpNetworkRequestPrivate;
+class Q_AUTOTEST_EXPORT QHttpNetworkRequest: public QHttpNetworkHeader
+{
+public:
+ enum Operation {
+ Options,
+ Get,
+ Head,
+ Post,
+ Put,
+ Delete,
+ Trace,
+ Connect
+ };
+
+ enum Priority {
+ HighPriority,
+ NormalPriority,
+ LowPriority
+ };
+
+ QHttpNetworkRequest(const QUrl &url = QUrl(), Operation operation = Get, Priority priority = NormalPriority);
+ QHttpNetworkRequest(const QHttpNetworkRequest &other);
+ virtual ~QHttpNetworkRequest();
+ QHttpNetworkRequest &operator=(const QHttpNetworkRequest &other);
+ bool operator==(const QHttpNetworkRequest &other) const;
+
+ QUrl url() const;
+ void setUrl(const QUrl &url);
+
+ int majorVersion() const;
+ int minorVersion() const;
+
+ qint64 contentLength() const;
+ void setContentLength(qint64 length);
+
+ QList<QPair<QByteArray, QByteArray> > header() const;
+ QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const;
+ void setHeaderField(const QByteArray &name, const QByteArray &data);
+
+ Operation operation() const;
+ void setOperation(Operation operation);
+
+ Priority priority() const;
+ void setPriority(Priority priority);
+
+ QIODevice *data() const;
+ void setData(QIODevice *data);
+
+private:
+ QSharedDataPointer<QHttpNetworkRequestPrivate> d;
+ friend class QHttpNetworkRequestPrivate;
+ friend class QHttpNetworkConnectionPrivate;
+};
+
+
+class QHttpNetworkRequestPrivate : public QHttpNetworkHeaderPrivate
+{
+public:
+ QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op,
+ QHttpNetworkRequest::Priority pri, const QUrl &newUrl = QUrl());
+ QHttpNetworkRequestPrivate(const QHttpNetworkRequestPrivate &other);
+ ~QHttpNetworkRequestPrivate();
+ bool operator==(const QHttpNetworkRequestPrivate &other) const;
+ QByteArray methodName() const;
+ QByteArray uri(bool throughProxy) const;
+
+ static QByteArray header(const QHttpNetworkRequest &request, bool throughProxy);
+
+ QHttpNetworkRequest::Operation operation;
+ QHttpNetworkRequest::Priority priority;
+ mutable QIODevice *data;
+ bool autoDecompress;
+};
+
+
+QT_END_NAMESPACE
+
+//Q_DECLARE_METATYPE(QHttpNetworkRequest)
+
+#endif // QT_NO_HTTP
+
+
+#endif // QHTTPNETWORKREQUEST_H
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index 4b41aa7..a52b5a0 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -527,8 +527,10 @@ void QNetworkAccessHttpBackend::postRequest()
foreach (const QByteArray &header, headers)
httpRequest.setHeaderField(header, request().rawHeader(header));
- if (loadedFromCache)
+ if (loadedFromCache) {
+ QNetworkAccessBackend::finished();
return; // no need to send the request! :)
+ }
httpReply = http->sendRequest(httpRequest);
httpReply->setParent(this);
@@ -767,8 +769,12 @@ void QNetworkAccessHttpBackend::replyHeaderChanged()
for (; it != end; ++it) {
QByteArray value = rawHeader(it->first);
- if (!value.isEmpty())
- value += ", ";
+ if (!value.isEmpty()) {
+ if (it->first.toLower() == "set-cookie")
+ value += "\n";
+ else
+ value += ", ";
+ }
value += it->second;
setRawHeader(it->first, value);
}
@@ -886,8 +892,6 @@ bool QNetworkAccessHttpBackend::sendCacheContents(const QNetworkCacheMetaData &m
if (status < 100)
status = 200; // fake it
- checkForRedirect(status);
-
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, status);
setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, attributes.value(QNetworkRequest::HttpReasonPhraseAttribute));
setAttribute(QNetworkRequest::SourceIsFromCacheAttribute, true);
@@ -898,6 +902,8 @@ bool QNetworkAccessHttpBackend::sendCacheContents(const QNetworkCacheMetaData &m
for ( ; it != end; ++it)
setRawHeader(it->first, it->second);
+ checkForRedirect(status);
+
writeDownstreamData(contents);
#if defined(QNETWORKACCESSHTTPBACKEND_DEBUG)
qDebug() << "Successfully sent cache:" << url() << contents->size() << "bytes";
@@ -951,6 +957,7 @@ QNetworkCacheMetaData QNetworkAccessHttpBackend::fetchCacheMetaData(const QNetwo
QList<QByteArray> newHeaders = rawHeaderList();
foreach (QByteArray header, newHeaders) {
+ QByteArray originalHeader = header;
header = header.toLower();
bool hop_by_hop =
(header == "connection"
@@ -974,19 +981,32 @@ QNetworkCacheMetaData QNetworkAccessHttpBackend::fetchCacheMetaData(const QNetwo
continue;
}
+ it = cacheHeaders.findRawHeader(header);
+ if (it != cacheHeaders.rawHeaders.constEnd()) {
+ // Match the behavior of Firefox and assume Cache-Control: "no-transform"
+ if (header == "content-encoding"
+ || header == "content-range"
+ || header == "content-type")
+ continue;
+
+ // For MS servers that send "Content-Length: 0" on 304 responses
+ // ignore this too
+ if (header == "content-length")
+ continue;
+ }
+
#if defined(QNETWORKACCESSHTTPBACKEND_DEBUG)
QByteArray n = rawHeader(header);
QByteArray o;
- it = cacheHeaders.findRawHeader(header);
if (it != cacheHeaders.rawHeaders.constEnd())
o = (*it).second;
- if (n != o && header != "Date") {
+ if (n != o && header != "date") {
qDebug() << "replacing" << header;
qDebug() << "new" << n;
qDebug() << "old" << o;
}
#endif
- cacheHeaders.setRawHeader(header, rawHeader(header));
+ cacheHeaders.setRawHeader(originalHeader, rawHeader(header));
}
metaData.setRawHeaders(cacheHeaders.rawHeaders);
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp
index 1235960..01a743b 100644
--- a/src/network/access/qnetworkcookie.cpp
+++ b/src/network/access/qnetworkcookie.cpp
@@ -49,6 +49,7 @@
#include "QtCore/qlist.h"
#include "QtCore/qlocale.h"
#include "QtCore/qstring.h"
+#include "QtCore/qstringlist.h"
#include "QtCore/qurl.h"
#include "private/qobject_p.h"
@@ -163,7 +164,7 @@ bool QNetworkCookie::operator==(const QNetworkCookie &other) const
return true;
return d->name == other.d->name &&
d->value == other.d->value &&
- d->expirationDate == other.d->expirationDate &&
+ d->expirationDate.toUTC() == other.d->expirationDate.toUTC() &&
d->domain == other.d->domain &&
d->path == other.d->path &&
d->secure == other.d->secure &&
@@ -513,6 +514,392 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const
return result;
}
+static const char zones[] =
+ "pst\0" // -8
+ "pdt\0"
+ "mst\0" // -7
+ "mdt\0"
+ "cst\0" // -6
+ "cdt\0"
+ "est\0" // -5
+ "edt\0"
+ "ast\0" // -4
+ "nst\0" // -3
+ "gmt\0" // 0
+ "utc\0"
+ "bst\0"
+ "met\0" // 1
+ "eet\0" // 2
+ "jst\0" // 9
+ "\0";
+static int zoneOffsets[] = {-8, -8, -7, -7, -6, -6, -5, -5, -4, -3, 0, 0, 0, 1, 2, 9 };
+
+static const char months[] =
+ "jan\0"
+ "feb\0"
+ "mar\0"
+ "apr\0"
+ "may\0"
+ "jun\0"
+ "jul\0"
+ "aug\0"
+ "sep\0"
+ "oct\0"
+ "nov\0"
+ "dec\0"
+ "\0";
+
+static inline bool isNumber(char s)
+{ return s >= '0' && s <= '9'; }
+
+static inline bool isTerminator(char c)
+{ return c == '\n' || c == '\r'; }
+
+static inline bool isValueSeparator(char c)
+{ return isTerminator(c) || c == ';'; }
+
+static inline bool isWhitespace(char c)
+{ return c == ' ' || c == '\t'; }
+
+static bool checkStaticArray(int &val, const QByteArray &dateString, int at, const char *array, int size)
+{
+ if (dateString[at] < 'a' || dateString[at] > 'z')
+ return false;
+ if (val == -1 && dateString.length() >= at + 3) {
+ int j = 0;
+ int i = 0;
+ while (i <= size) {
+ const char *str = array + i;
+ if (str[0] == dateString[at]
+ && str[1] == dateString[at + 1]
+ && str[2] == dateString[at + 2]) {
+ val = j;
+ return true;
+ }
+ i += strlen(str) + 1;
+ ++j;
+ }
+ }
+ return false;
+}
+
+//#define PARSEDATESTRINGDEBUG
+
+#define ADAY 1
+#define AMONTH 2
+#define AYEAR 4
+
+/*
+ Parse all the date formats that Firefox can.
+
+ The official format is:
+ expires=ddd(d)?, dd-MMM-yyyy hh:mm:ss GMT
+
+ But browsers have been supporting a very wide range of date
+ strings. To work on many sites we need to support more then
+ just the official date format.
+
+ For reference see Firefox's PR_ParseTimeStringToExplodedTime in
+ prtime.c. The Firefox date parser is coded in a very complex way
+ and is slightly over ~700 lines long. While this implementation
+ will be slightly slower for the non standard dates it is smaller,
+ more readable, and maintainable.
+
+ Or in their own words:
+ "} // else what the hell is this."
+*/
+static QDateTime parseDateString(const QByteArray &dateString)
+{
+ QTime time;
+ // placeholders for values when we are not sure it is a year, month or day
+ int unknown[3] = {-1, -1, -1};
+ int month = -1;
+ int day = -1;
+ int year = -1;
+ int zoneOffset = -1;
+
+ // hour:minute:second.ms pm
+ QRegExp timeRx(QLatin1String("(\\d{1,2}):(\\d{1,2})(:(\\d{1,2})|)(\\.(\\d{1,3})|)((\\s{0,}(am|pm))|)"));
+
+ int at = 0;
+ while (at < dateString.length()) {
+#ifdef PARSEDATESTRINGDEBUG
+ qDebug() << dateString.mid(at);
+#endif
+ bool isNum = isNumber(dateString[at]);
+
+ // Month
+ if (!isNum
+ && checkStaticArray(month, dateString, at, months, sizeof(months)- 1)) {
+ ++month;
+#ifdef PARSEDATESTRINGDEBUG
+ qDebug() << "Month:" << month;
+#endif
+ at += 3;
+ continue;
+ }
+ // Zone
+ if (!isNum
+ && zoneOffset == -1
+ && checkStaticArray(zoneOffset, dateString, at, zones, sizeof(zones)- 1)) {
+ int sign = (at >= 0 && dateString[at - 1] == '-') ? -1 : 1;
+ zoneOffset = sign * zoneOffsets[zoneOffset] * 60 * 60;
+#ifdef PARSEDATESTRINGDEBUG
+ qDebug() << "Zone:" << month;
+#endif
+ at += 3;
+ continue;
+ }
+ // Zone offset
+ if (!isNum
+ && (zoneOffset == -1 || zoneOffset == 0) // Can only go after gmt
+ && (dateString[at] == '+' || dateString[at] == '-')
+ && (at == 0
+ || isWhitespace(dateString[at - 1])
+ || dateString[at - 1] == ','
+ || (at >= 3
+ && (dateString[at - 3] == 'g')
+ && (dateString[at - 2] == 'm')
+ && (dateString[at - 1] == 't')))) {
+
+ int end = 1;
+ while (end < 5 && dateString.length() > at+end
+ && dateString[at + end] >= '0' && dateString[at + end] <= '9')
+ ++end;
+ int minutes = 0;
+ int hours = 0;
+ switch (end - 1) {
+ case 4:
+ minutes = atoi(dateString.mid(at + 3, 2).constData());
+ // fall through
+ case 2:
+ hours = atoi(dateString.mid(at + 1, 2).constData());
+ break;
+ case 1:
+ hours = atoi(dateString.mid(at + 1, 1).constData());
+ break;
+ default:
+ at += end;
+ continue;
+ }
+ if (end != 1) {
+ int sign = dateString[at] == '-' ? -1 : 1;
+ zoneOffset = sign * ((minutes * 60) + (hours * 60 * 60));
+#ifdef PARSEDATESTRINGDEBUG
+ qDebug() << "Zone offset:" << zoneOffset << hours << minutes;
+#endif
+ at += end;
+ continue;
+ }
+ }
+
+ // Time
+ if (isNum && time.isNull()
+ && dateString.length() >= at + 3
+ && (dateString[at + 2] == ':' || dateString[at + 1] == ':')) {
+ // While the date can be found all over the string the format
+ // for the time is set and a nice regexp can be used.
+ int pos = timeRx.indexIn(QLatin1String(dateString), at);
+ if (pos != -1) {
+ QStringList list = timeRx.capturedTexts();
+ int h = atoi(list.at(1).toLatin1().constData());
+ int m = atoi(list.at(2).toLatin1().constData());
+ int s = atoi(list.at(4).toLatin1().constData());
+ int ms = atoi(list.at(6).toLatin1().constData());
+ if (h < 12 && !list.at(9).isEmpty())
+ if (list.at(9) == QLatin1String("pm"))
+ h += 12;
+ time = QTime(h, m, s, ms);
+#ifdef PARSEDATESTRINGDEBUG
+ qDebug() << "Time:" << list << timeRx.matchedLength();
+#endif
+ at += timeRx.matchedLength();
+ continue;
+ }
+ }
+
+ // 4 digit Year
+ if (isNum
+ && year == -1
+ && dateString.length() >= at + 3) {
+ if (isNumber(dateString[at + 1])
+ && isNumber(dateString[at + 2])
+ && isNumber(dateString[at + 3])) {
+ year = atoi(dateString.mid(at, 4).constData());
+ at += 4;
+#ifdef PARSEDATESTRINGDEBUG
+ qDebug() << "Year:" << year;
+#endif
+ continue;
+ }
+ }
+
+ // a one or two digit number
+ // Could be month, day or year
+ if (isNum) {
+ int length = 1;
+ if (dateString.length() > at + 1
+ && isNumber(dateString[at + 1]))
+ ++length;
+ int x = atoi(dateString.mid(at, length).constData());
+ if (year == -1 && (x > 31 || x == 0)) {
+ year = x;
+ } else {
+ if (unknown[0] == -1) unknown[0] = x;
+ else if (unknown[1] == -1) unknown[1] = x;
+ else if (unknown[2] == -1) unknown[2] = x;
+ }
+ at += length;
+#ifdef PARSEDATESTRINGDEBUG
+ qDebug() << "Saving" << x;
+#endif
+ continue;
+ }
+
+ // Unknown character, typically a weekday such as 'Mon'
+ ++at;
+ }
+
+ // Once we are done parsing the string take the digits in unknown
+ // and determine which is the unknown year/month/day
+
+ int couldBe[3] = { 0, 0, 0 };
+ int unknownCount = 3;
+ for (int i = 0; i < unknownCount; ++i) {
+ if (unknown[i] == -1) {
+ couldBe[i] = ADAY | AYEAR | AMONTH;
+ unknownCount = i;
+ continue;
+ }
+
+ if (unknown[i] >= 1)
+ couldBe[i] = ADAY;
+
+ if (month == -1 && unknown[i] >= 1 && unknown[i] <= 12)
+ couldBe[i] |= AMONTH;
+
+ if (year == -1)
+ couldBe[i] |= AYEAR;
+ }
+
+ // For any possible day make sure one of the values that could be a month
+ // can contain that day.
+ // For any possible month make sure one of the values that can be a
+ // day that month can have.
+ // Example: 31 11 06
+ // 31 can't be a day because 11 and 6 don't have 31 days
+ for (int i = 0; i < unknownCount; ++i) {
+ int currentValue = unknown[i];
+ bool findMatchingMonth = couldBe[i] & ADAY && currentValue >= 29;
+ bool findMatchingDay = couldBe[i] & AMONTH;
+ if (!findMatchingMonth || !findMatchingDay)
+ continue;
+ for (int j = 0; j < 3; ++j) {
+ if (j == i)
+ continue;
+ for (int k = 0; k < 2; ++k) {
+ if (k == 0 && !(findMatchingMonth && (couldBe[j] & AMONTH)))
+ continue;
+ else if (k == 1 && !(findMatchingDay && (couldBe[j] & ADAY)))
+ continue;
+ int m = currentValue;
+ int d = unknown[j];
+ if (k == 0)
+ qSwap(m, d);
+ if (m == -1) m = month;
+ bool found = true;
+ switch(m) {
+ case 2:
+ // When we get 29 and the year ends up having only 28
+ // See date.isValid below
+ // Example: 29 23 Feb
+ if (d <= 29)
+ found = false;
+ break;
+ case 4: case 6: case 9: case 11:
+ if (d <= 30)
+ found = false;
+ break;
+ default:
+ if (d > 0 && d <= 31)
+ found = false;
+ }
+ if (k == 0) findMatchingMonth = found;
+ else if (k == 1) findMatchingDay = found;
+ }
+ }
+ if (findMatchingMonth)
+ couldBe[i] &= ~ADAY;
+ if (findMatchingDay)
+ couldBe[i] &= ~AMONTH;
+ }
+
+ // First set the year/month/day that have been deduced
+ // and reduce the set as we go along to deduce more
+ for (int i = 0; i < unknownCount; ++i) {
+ int unset = 0;
+ for (int j = 0; j < 3; ++j) {
+ if (couldBe[j] == ADAY && day == -1) {
+ day = unknown[j];
+ unset |= ADAY;
+ } else if (couldBe[j] == AMONTH && month == -1) {
+ month = unknown[j];
+ unset |= AMONTH;
+ } else if (couldBe[j] == AYEAR && year == -1) {
+ year = unknown[j];
+ unset |= AYEAR;
+ } else {
+ // common case
+ break;
+ }
+ couldBe[j] &= ~unset;
+ }
+ }
+
+ // Now fallback to a standardized order to fill in the rest with
+ for (int i = 0; i < unknownCount; ++i) {
+ if (couldBe[i] & AMONTH && month == -1) month = unknown[i];
+ else if (couldBe[i] & ADAY && day == -1) day = unknown[i];
+ else if (couldBe[i] & AYEAR && year == -1) year = unknown[i];
+ }
+#ifdef PARSEDATESTRINGDEBUG
+ qDebug() << "Final set" << year << month << day;
+#endif
+
+ if (year == -1 || month == -1 || day == -1) {
+#ifdef PARSEDATESTRINGDEBUG
+ qDebug() << "Parser failure" << year << month << day;
+#endif
+ return QDateTime();
+ }
+
+ // Y2k behavior
+ int y2k = 0;
+ if (year < 70)
+ y2k = 2000;
+ else if (year < 100)
+ y2k = 1900;
+
+ QDate date(year + y2k, month, day);
+
+ // When we were given a bad cookie that when parsed
+ // set the day to 29 and the year to one that doesn't
+ // have the 29th of Feb rather then adding the extra
+ // complicated checking earlier just swap here.
+ // Example: 29 23 Feb
+ if (!date.isValid())
+ date = QDate(day + y2k, month, year);
+
+ QDateTime dateTime(date, time, Qt::UTC);
+
+ if (zoneOffset != -1) {
+ dateTime = dateTime.addSecs(zoneOffset);
+ }
+ if (!dateTime.isValid())
+ return QDateTime();
+ return dateTime;
+}
+
/*!
Parses the cookie string \a cookieString as received from a server
response in the "Set-Cookie:" header. If there's a parsing error,
@@ -543,17 +930,23 @@ QList<QNetworkCookie> QNetworkCookie::parseCookies(const QByteArray &cookieStrin
while (position < length) {
QNetworkCookie cookie;
+ // When there are multiple SetCookie headers they are join with a new line
+ // \n will always be the start of a new cookie
+ int endOfSetCookie = cookieString.indexOf('\n', position);
+ if (endOfSetCookie == -1)
+ endOfSetCookie = length;
+
// The first part is always the "NAME=VALUE" part
QPair<QByteArray,QByteArray> field = nextField(cookieString, position);
if (field.first.isEmpty() || field.second.isNull())
// parsing error
- return QList<QNetworkCookie>();
+ break;
cookie.setName(field.first);
cookie.setValue(field.second);
position = nextNonWhitespace(cookieString, position);
bool endOfCookie = false;
- while (!endOfCookie && position < length)
+ while (!endOfCookie && position < endOfSetCookie)
switch (cookieString.at(position++)) {
case ',':
// end of the cookie
@@ -566,64 +959,20 @@ QList<QNetworkCookie> QNetworkCookie::parseCookies(const QByteArray &cookieStrin
field.first = field.first.toLower(); // everything but the NAME=VALUE is case-insensitive
if (field.first == "expires") {
- static const char dateFormats[] =
- "d-MMM-yyyy hh:mm:ss\0"
- "d MMM yyyy hh:mm:ss\0"
- "d-MMM-yy hh:mm:ss\0"
- "\0";
-
- // expires is a special case because it contains a naked comma
- // and naked spaces. The format is:
- // expires=ddd(d)?, dd-MMM-yyyy hh:mm:ss GMT
- // but we also accept standard HTTP dates
-
- // make sure we're at the comma
- if (position >= length || cookieString.at(position) != ',')
- // invalid cookie string
- return QList<QNetworkCookie>();
-
- ++position;
+ position -= field.second.length();
int end;
for (end = position; end < length; ++end)
- if (cookieString.at(end) == ',' || cookieString.at(end) == ';')
+ if (isValueSeparator(cookieString.at(end)))
break;
- QByteArray datestring = cookieString.mid(position, end - position).trimmed();
+ QByteArray dateString = cookieString.mid(position, end - position).trimmed();
position = end;
- if (datestring.endsWith(" GMT") || datestring.endsWith(" UTC"))
- datestring.chop(4);
- else if (datestring.endsWith(" +0000"))
- datestring.chop(6);
-
- size_t i = 0;
- int j = 0;
- QLocale cLocale = QLocale::c();
- QDateTime dt;
- do {
- QLatin1String df(dateFormats + i);
- i += strlen(dateFormats + i) + 1;
-
-#ifndef QT_NO_DATESTRING
- dt = cLocale.toDateTime(QString::fromLatin1(datestring), df);
-
- // some cookies are set with a two-digit year
- // (although this is not allowed); this is interpreted as a year
- // in the 20th century by QDateTime.
- // Work around this case here (assuming 00-69 is 21st century,
- // 70-99 is 20th century)
- QDate date = dt.date();
- if (j == 2 && date.year() >= 1900 && date.year() < 1970)
- dt = dt.addYears(100);
- if (date.year() >= 0 && date.year() < 100)
- dt = dt.addYears(1900);
-#endif
- j++;
- } while (!dt.isValid() && i <= sizeof dateFormats - 1);
- if (!dt.isValid())
- // invalid cookie string
- return QList<QNetworkCookie>();
-
- dt.setTimeSpec(Qt::UTC);
+ QDateTime dt = parseDateString(dateString.toLower());
+ if (!dt.isValid()) {
+ cookie = QNetworkCookie();
+ endOfCookie = true;
+ continue;
+ }
cookie.setExpirationDate(dt);
} else if (field.first == "domain") {
QByteArray rawDomain = field.second;
@@ -664,9 +1013,12 @@ QList<QNetworkCookie> QNetworkCookie::parseCookies(const QByteArray &cookieStrin
}
position = nextNonWhitespace(cookieString, position);
+ if (position > endOfSetCookie)
+ endOfCookie = true;
}
- result += cookie;
+ if (!cookie.name().isEmpty())
+ result += cookie;
}
return result;
diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp
index e472b9d..14a04f1 100644
--- a/src/network/access/qnetworkdiskcache.cpp
+++ b/src/network/access/qnetworkdiskcache.cpp
@@ -255,7 +255,8 @@ void QNetworkDiskCachePrivate::storeItem(QCacheItem *cacheItem)
// ### use atomic rename rather then remove & rename
if (cacheItem->file->rename(fileName))
currentCacheSize += cacheItem->file->size();
- cacheItem->file->setAutoRemove(true);
+ else
+ cacheItem->file->setAutoRemove(true);
}
if (cacheItem->metaData.url() == lastItem.metaData.url())
lastItem.reset();
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index eaa572f..79c3d1a 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -131,27 +131,37 @@ void QNetworkReplyImplPrivate::_q_copyReadyRead()
if (!copyDevice && !q->isOpen())
return;
- qint64 bytesToRead = nextDownstreamBlockSize();
- if (bytesToRead == 0)
- // we'll be called again, eventually
- return;
+ forever {
+ qint64 bytesToRead = nextDownstreamBlockSize();
+ if (bytesToRead == 0)
+ // we'll be called again, eventually
+ break;
- bytesToRead = qBound<qint64>(1, bytesToRead, copyDevice->bytesAvailable());
- char *ptr = readBuffer.reserve(bytesToRead);
- qint64 bytesActuallyRead = copyDevice->read(ptr, bytesToRead);
- if (bytesActuallyRead == -1) {
- readBuffer.chop(bytesToRead);
- backendNotify(NotifyCopyFinished);
- return;
- }
+ bytesToRead = qBound<qint64>(1, bytesToRead, copyDevice->bytesAvailable());
+ char *ptr = readBuffer.reserve(bytesToRead);
+ qint64 bytesActuallyRead = copyDevice->read(ptr, bytesToRead);
+ if (bytesActuallyRead == -1) {
+ readBuffer.chop(bytesToRead);
+ backendNotify(NotifyCopyFinished);
+ return;
+ }
- if (bytesActuallyRead != bytesToRead)
- readBuffer.chop(bytesToRead - bytesActuallyRead);
+ if (bytesActuallyRead != bytesToRead)
+ readBuffer.chop(bytesToRead - bytesActuallyRead);
- if (!copyDevice->isSequential() && copyDevice->atEnd())
- backendNotify(NotifyCopyFinished);
+ if (!copyDevice->isSequential() && copyDevice->atEnd()) {
+ backendNotify(NotifyCopyFinished);
+ break;
+ }
+
+ bytesDownloaded += bytesActuallyRead;
+ }
+
+ if (bytesDownloaded == lastBytesDownloaded) {
+ // we didn't read anything
+ return;
+ }
- bytesDownloaded += bytesActuallyRead;
lastBytesDownloaded = bytesDownloaded;
QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
emit q->downloadProgress(bytesDownloaded,
diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp
index 4f477bd..c9161f8 100644
--- a/src/network/kernel/qauthenticator.cpp
+++ b/src/network/kernel/qauthenticator.cpp
@@ -52,7 +52,7 @@
QT_BEGIN_NAMESPACE
-#include <../3rdparty/des/des.cpp>
+#include "../../3rdparty/des/des.cpp"
static QByteArray qNtlmPhase1();
static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phase2data);
diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp
index fc43369..b225c17 100644
--- a/src/network/kernel/qhostaddress.cpp
+++ b/src/network/kernel/qhostaddress.cpp
@@ -435,7 +435,7 @@ void QNetmaskAddress::setPrefixLength(QAbstractSocket::NetworkLayerProtocol prot
The class also supports common predefined addresses: \l Null, \l
LocalHost, \l LocalHostIPv6, \l Broadcast, and \l Any.
- \sa QTcpSocket, QTcpServer, QUdpSocket
+ \sa QHostInfo, QTcpSocket, QTcpServer, QUdpSocket
*/
/*! \enum QHostAddress::SpecialAddress
diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp
index 9540c18..de97629 100644
--- a/src/network/kernel/qnetworkinterface_win.cpp
+++ b/src/network/kernel/qnetworkinterface_win.cpp
@@ -173,14 +173,14 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWinXP()
interfaces << iface;
iface->index = 0;
- if (ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Ipv6IfIndex))
+ if (ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Ipv6IfIndex) && ptr->Ipv6IfIndex != 0)
iface->index = ptr->Ipv6IfIndex;
else if (ptr->IfIndex != 0)
iface->index = ptr->IfIndex;
iface->flags = QNetworkInterface::CanBroadcast;
- if (ptr->OperStatus == IfOperStatusUp)
- iface->flags |= QNetworkInterface::IsUp | QNetworkInterface::IsRunning;
+ if (ptr->OperStatus == IfOperStatusUp)
+ iface->flags |= QNetworkInterface::IsUp | QNetworkInterface::IsRunning;
if ((ptr->Flags & IP_ADAPTER_NO_MULTICAST) == 0)
iface->flags |= QNetworkInterface::CanMulticast;
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 910e30a..f9750f2 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -1263,7 +1263,7 @@ void QAbstractSocket::connectToHostImplementation(const QString &hostName, quint
(int) openMode);
#endif
- if (d->state == ConnectedState || d->state == ConnectingState) {
+ if (d->state == ConnectedState || d->state == ConnectingState || d->state == ClosingState) {
qWarning("QAbstractSocket::connectToHost() called when already connecting/connected to \"%s\"", qPrintable(hostName));
return;
}
@@ -2279,7 +2279,7 @@ void QAbstractSocket::disconnectFromHostImplementation()
emit delayedCloseFinished(); // compat signal
#endif
// only emit disconnected if we were connected before
- if (previousState == ConnectedState || ClosingState)
+ if (previousState == ConnectedState || previousState == ClosingState)
emit disconnected();
d->localPort = 0;
diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h
index dd48d0a..781d3da 100644
--- a/src/network/socket/qlocalsocket_p.h
+++ b/src/network/socket/qlocalsocket_p.h
@@ -192,6 +192,7 @@ public:
void _q_error(QAbstractSocket::SocketError newError);
void _q_connectToSocket();
void _q_abortConnectionAttempt();
+ void cancelDelayedConnect();
QSocketNotifier *delayConnect;
QTimer *connectTimer;
int connectingSocket;
diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp
index a375e9b..38643f1 100644
--- a/src/network/socket/qlocalsocket_unix.cpp
+++ b/src/network/socket/qlocalsocket_unix.cpp
@@ -322,11 +322,8 @@ void QLocalSocketPrivate::_q_connectToSocket()
}
// connected!
- if (delayConnect) {
- delayConnect->setEnabled(false);
- delete delayConnect;
- delayConnect = 0;
- }
+ cancelDelayedConnect();
+
serverName = connectingName;
fullServerName = connectingPathName;
if (unixSocket.setSocketDescriptor(connectingSocket,
@@ -373,6 +370,18 @@ void QLocalSocketPrivate::_q_abortConnectionAttempt()
q->close();
}
+void QLocalSocketPrivate::cancelDelayedConnect()
+{
+ if (delayConnect) {
+ delayConnect->setEnabled(false);
+ delete delayConnect;
+ delayConnect = 0;
+ connectTimer->stop();
+ delete connectTimer;
+ connectTimer = 0;
+ }
+}
+
quintptr QLocalSocket::socketDescriptor() const
{
Q_D(const QLocalSocket);
@@ -419,14 +428,7 @@ void QLocalSocket::close()
{
Q_D(QLocalSocket);
d->unixSocket.close();
- if (d->delayConnect) {
- d->delayConnect->setEnabled(false);
- delete d->delayConnect;
- d->delayConnect = 0;
- d->connectTimer->stop();
- delete d->connectTimer;
- d->connectTimer = 0;
- }
+ d->cancelDelayedConnect();
if (d->connectingSocket != -1)
::close(d->connectingSocket);
d->connectingSocket = -1;
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 73f6f84..cc372a6 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -506,26 +506,11 @@ int QNativeSocketEnginePrivate::nativeAccept()
qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const
{
- /*
- Apparently, there is not consistency among different operating
- systems on how to use FIONREAD.
-
- FreeBSD, Linux and Solaris all expect the 3rd argument to
- ioctl() to be an int, which is normally 32-bit even on 64-bit
- machines.
-
- IRIX, on the other hand, expects a size_t, which is 64-bit on
- 64-bit machines.
-
- So, the solution is to use size_t initialized to zero to make
- sure all bits are set to zero, preventing underflow with the
- FreeBSD/Linux/Solaris ioctls.
- */
- size_t nbytes = 0;
+ int nbytes = 0;
// gives shorter than true amounts on Unix domain sockets.
qint64 available = 0;
if (::ioctl(socketDescriptor, FIONREAD, (char *) &nbytes) >= 0)
- available = (qint64) *((int *) &nbytes);
+ available = (qint64) nbytes;
#if defined (QNATIVESOCKETENGINE_DEBUG)
qDebug("QNativeSocketEnginePrivate::nativeBytesAvailable() == %lli", available);
diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro
index 48d7caf..78aaddb 100644
--- a/src/opengl/opengl.pro
+++ b/src/opengl/opengl.pro
@@ -25,18 +25,16 @@ HEADERS += qgl.h \
qglcolormap.h \
qglpixelbuffer.h \
qglframebufferobject.h \
- qglpixmapfilter_p.h
SOURCES += qgl.cpp \
qglcolormap.cpp \
qglpixelbuffer.cpp \
qglframebufferobject.cpp \
qglextensions.cpp \
- qglpixmapfilter.cpp
!contains(QT_CONFIG, opengles2) {
- HEADERS += qpaintengine_opengl_p.h
- SOURCES += qpaintengine_opengl.cpp
+ HEADERS += qpaintengine_opengl_p.h qglpixmapfilter_p.h
+ SOURCES += qpaintengine_opengl.cpp qglpixmapfilter.cpp
}
contains(QT_CONFIG, opengles2) {
@@ -130,6 +128,10 @@ wince*: {
contains(QT_CONFIG,opengles1cl) {
QMAKE_LIBS += "libGLES_CL.lib"
}
+ contains(QT_CONFIG,opengles2) {
+ QMAKE_LIBS += "libGLESv2.lib"
+ }
+
} else {
QMAKE_LIBS += $$QMAKE_LIBS_OPENGL
}
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 4c152e2..99df658 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -2616,6 +2616,10 @@ const QGLContext* QGLContext::currentContext()
QGLWidget. This will side-step the issue altogether, and is what
we recommend for users that need this kind of functionality.
+ On Mac OS X, when Qt is built with Cocoa support, a QGLWidget
+ can't have any sibling widgets placed ontop of itself. This is due
+ to limitations in the Cocoa API and is not supported by Apple.
+
\section1 Overlays
The QGLWidget creates a GL overlay context in addition to the
@@ -3231,6 +3235,10 @@ bool QGLWidget::event(QEvent *e)
update();
}
return true;
+# if defined(QT_MAC_USE_COCOA)
+ } else if (e->type() == QEvent::MacGLClearDrawable) {
+ d->glcx->d_ptr->clearDrawable();
+# endif
}
#endif
diff --git a/src/opengl/qgl_cl_p.h b/src/opengl/qgl_cl_p.h
index e514ff5..c05a7d7 100644
--- a/src/opengl/qgl_cl_p.h
+++ b/src/opengl/qgl_cl_p.h
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
inline void glTexParameterf (GLenum target, GLenum pname, GLfloat param)
{
- glTexParameterx(target, pname, param);
+ glTexParameterx(target, pname, FLOAT2X(param));
}
inline void glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
{
diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm
index 314c659..1319396 100644
--- a/src/opengl/qgl_mac.mm
+++ b/src/opengl/qgl_mac.mm
@@ -87,29 +87,6 @@ QT_FORWARD_DECLARE_CLASS(QWidget)
QT_FORWARD_DECLARE_CLASS(QWidgetPrivate)
QT_FORWARD_DECLARE_CLASS(QGLWidgetPrivate)
-@interface QT_MANGLE_NAMESPACE(QCocoaOpenGLView) : QT_MANGLE_NAMESPACE(QCocoaView)
-{
-}
-- (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
-@end
-
-@implementation QT_MANGLE_NAMESPACE(QCocoaOpenGLView)
-- (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate
-{
- self = [super initWithQWidget:widget widgetPrivate:widgetprivate];
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(_surfaceNeedsUpdate:)
- name:NSViewGlobalFrameDidChangeNotification
- object:self];
- return self;
-}
-
-- (void) _surfaceNeedsUpdate:(NSNotification*)notification
-{
- Q_UNUSED(notification);
- static_cast<QGLWidgetPrivate *>(qwidgetprivate)->glcx->updatePaintDevice();
-}
-@end
QT_BEGIN_NAMESPACE
void *qt_current_nsopengl_context()
@@ -435,6 +412,11 @@ void *QGLContextPrivate::tryFormat(const QGLFormat &format)
#endif
}
+void QGLContextPrivate::clearDrawable()
+{
+ [static_cast<NSOpenGLContext *>(cx) clearDrawable];
+}
+
/*!
\bold{Mac OS X only:} This virtual function tries to find a visual that
matches the format, reducing the demands if the original request
@@ -647,7 +629,7 @@ void QGLContext::updatePaintDevice()
// ideally we would use QWidget::isVisible(), but we get "invalid drawable" errors
if (![(NSWindow *)qt_mac_window_for(w) isVisible])
return;
- if ([static_cast<NSOpenGLContext *>(d->cx) view] != view)
+ if ([static_cast<NSOpenGLContext *>(d->cx) view] != view && ![view isHidden])
[static_cast<NSOpenGLContext *>(d->cx) setView:view];
} else if (d->paintDevice->devType() == QInternal::Pixmap) {
const QPixmap *pm = static_cast<const QPixmap *>(d->paintDevice);
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index b15eebc..1214f20 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -234,6 +234,7 @@ public:
#if defined(Q_WS_MAC)
bool update;
void *tryFormat(const QGLFormat &format);
+ void clearDrawable();
#endif
QGLFormat glFormat;
QGLFormat reqFormat;
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index 8524dfa..4ba9213 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -48,6 +48,10 @@
#include <qlibrary.h>
#include <qimage.h>
+#ifdef QT_OPENGL_ES_1_CL
+#include "qgl_cl_p.h"
+#endif
+
QT_BEGIN_NAMESPACE
extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool);
diff --git a/src/opengl/qglpixelbuffer_egl.cpp b/src/opengl/qglpixelbuffer_egl.cpp
index 964efa2..5390fd1 100644
--- a/src/opengl/qglpixelbuffer_egl.cpp
+++ b/src/opengl/qglpixelbuffer_egl.cpp
@@ -47,6 +47,10 @@
#include <qimage.h>
#include <private/qgl_p.h>
+#ifdef QT_OPENGL_ES_1_CL
+#include "qgl_cl_p.h"
+#endif
+
QT_BEGIN_NAMESPACE
#ifdef EGL_BIND_TO_TEXTURE_RGBA
@@ -188,8 +192,8 @@ GLuint QGLPixelBuffer::generateDynamicTexture() const
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, d->req_size.width(), d->req_size.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, d->req_size.width(), d->req_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
return texture;
#else
return 0;
diff --git a/src/opengl/qglpixelbuffer_mac.mm b/src/opengl/qglpixelbuffer_mac.mm
index 14941ab..9a679b1 100644
--- a/src/opengl/qglpixelbuffer_mac.mm
+++ b/src/opengl/qglpixelbuffer_mac.mm
@@ -308,10 +308,6 @@ GLuint QGLPixelBuffer::generateDynamicTexture() const
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
- [static_cast<NSOpenGLContext *>(d->share_ctx)
- setTextureImageToPixelBuffer:static_cast<NSOpenGLPixelBuffer *>(d->pbuf)
- colorBuffer:GL_FRONT];
- glBindTexture(GL_TEXTURE_2D, texture); // updates texture target
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -322,8 +318,6 @@ GLuint QGLPixelBuffer::generateDynamicTexture() const
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
- aglTexImagePBuffer(d->share_ctx, d->pbuf, GL_FRONT);
- glBindTexture(GL_TEXTURE_2D, texture); // updates texture target
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
return texture;
diff --git a/src/opengl/qglpixelbuffer_win.cpp b/src/opengl/qglpixelbuffer_win.cpp
index e81a576..e3228cc 100644
--- a/src/opengl/qglpixelbuffer_win.cpp
+++ b/src/opengl/qglpixelbuffer_win.cpp
@@ -43,7 +43,7 @@
#include <qgl.h>
#include <private/qgl_p.h>
-#include <qglpixelbuffer_p.h>
+#include <private/qglpixelbuffer_p.h>
#include <qimage.h>
#include <qdebug.h>
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index f332a50..4afc621 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -1924,15 +1924,15 @@ static void drawTrapezoid(const QGLTrapezoid &trap, const qreal offscreenHeight,
qreal leftB = trap.bottomLeftX + (trap.topLeftX - trap.bottomLeftX) * reciprocal;
qreal rightB = trap.bottomRightX + (trap.topRightX - trap.bottomRightX) * reciprocal;
- const bool topZero = qFuzzyCompare(topDist + 1, 1);
+ const bool topZero = qFuzzyIsNull(topDist);
reciprocal = topZero ? 1.0 / bottomDist : 1.0 / topDist;
qreal leftA = topZero ? (trap.bottomLeftX - leftB) * reciprocal : (trap.topLeftX - leftB) * reciprocal;
qreal rightA = topZero ? (trap.bottomRightX - rightB) * reciprocal : (trap.topRightX - rightB) * reciprocal;
- qreal invLeftA = qFuzzyCompare(leftA + 1, 1) ? 0.0 : 1.0 / leftA;
- qreal invRightA = qFuzzyCompare(rightA + 1, 1) ? 0.0 : 1.0 / rightA;
+ qreal invLeftA = qFuzzyIsNull(leftA) ? 0.0 : 1.0 / leftA;
+ qreal invRightA = qFuzzyIsNull(rightA) ? 0.0 : 1.0 / rightA;
// fragment program needs the negative of invRightA as it mirrors the line
glTexCoord4f(topDist, bottomDist, invLeftA, -invRightA);
@@ -1983,7 +1983,7 @@ public:
void QOpenGLTrapezoidToArrayTessellator::addTrap(const Trapezoid &trap)
{
// On OpenGL ES we convert the trap to 2 triangles
-#ifndef QT_OPENGL_ES_1
+#ifndef QT_OPENGL_ES
if (size > allocated - 8) {
#else
if (size > allocated - 12) {
@@ -1994,31 +1994,31 @@ void QOpenGLTrapezoidToArrayTessellator::addTrap(const Trapezoid &trap)
QGLTrapezoid t = toGLTrapezoid(trap);
-#ifndef QT_OPENGL_ES_1
- vertices[size++] = t.topLeftX;
- vertices[size++] = t.top;
- vertices[size++] = t.topRightX;
- vertices[size++] = t.top;
- vertices[size++] = t.bottomRightX;
- vertices[size++] = t.bottom;
- vertices[size++] = t.bottomLeftX;
- vertices[size++] = t.bottom;
+#ifndef QT_OPENGL_ES
+ vertices[size++] = f2vt(t.topLeftX);
+ vertices[size++] = f2vt(t.top);
+ vertices[size++] = f2vt(t.topRightX);
+ vertices[size++] = f2vt(t.top);
+ vertices[size++] = f2vt(t.bottomRightX);
+ vertices[size++] = f2vt(t.bottom);
+ vertices[size++] = f2vt(t.bottomLeftX);
+ vertices[size++] = f2vt(t.bottom);
#else
// First triangle
- vertices[size++] = t.topLeftX;
- vertices[size++] = t.top;
- vertices[size++] = t.topRightX;
- vertices[size++] = t.top;
- vertices[size++] = t.bottomRightX;
- vertices[size++] = t.bottom;
+ vertices[size++] = f2vt(t.topLeftX);
+ vertices[size++] = f2vt(t.top);
+ vertices[size++] = f2vt(t.topRightX);
+ vertices[size++] = f2vt(t.top);
+ vertices[size++] = f2vt(t.bottomRightX);
+ vertices[size++] = f2vt(t.bottom);
// Second triangle
- vertices[size++] = t.bottomLeftX;
- vertices[size++] = t.bottom;
- vertices[size++] = t.topLeftX;
- vertices[size++] = t.top;
- vertices[size++] = t.bottomRightX;
- vertices[size++] = t.bottom;
+ vertices[size++] = f2vt(t.bottomLeftX);
+ vertices[size++] = f2vt(t.bottom);
+ vertices[size++] = f2vt(t.topLeftX);
+ vertices[size++] = f2vt(t.top);
+ vertices[size++] = f2vt(t.bottomRightX);
+ vertices[size++] = f2vt(t.bottom);
#endif
}
@@ -3445,8 +3445,7 @@ QVector<QGLTrapezoid> QGLRectMaskGenerator::generateTrapezoids()
// manhattan distance (no rotation)
qreal width = qAbs(delta.x()) + qAbs(delta.y());
- Q_ASSERT(qFuzzyCompare(delta.x() + 1, static_cast<qreal>(1))
- || qFuzzyCompare(delta.y() + 1, static_cast<qreal>(1)));
+ Q_ASSERT(qFuzzyIsNull(delta.x()) || qFuzzyIsNull(delta.y()));
tessellator.tessellateRect(first, last, width);
} else {
@@ -5328,6 +5327,9 @@ void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const q_vertexType *
Q_Q(QOpenGLPaintEngine);
QGL_FUNC_CONTEXT;
+ if (current_style == Qt::NoBrush)
+ return;
+
DEBUG_ONCE qDebug() << "QOpenGLPaintEnginePrivate: Using compositing program: fragment_brush ="
<< fragment_brush << ", fragment_composition_mode =" << fragment_composition_mode;
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 3dd3064..837ccf2 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -76,6 +76,10 @@
#define GLX_SAMPLES_ARB 100001
#endif
+#ifdef QT_OPENGL_ES_1_CL
+#include "qgl_cl_p.h"
+#endif
+
QT_BEGIN_NAMESPACE
//
diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro
index 96eb536..89a289c 100644
--- a/src/plugins/gfxdrivers/directfb/directfb.pro
+++ b/src/plugins/gfxdrivers/directfb/directfb.pro
@@ -12,6 +12,8 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers
#DEFINES += QT_NO_DIRECTFB_PREALLOCATED
#DEFINES += QT_NO_DIRECTFB_MOUSE
#DEFINES += QT_NO_DIRECTFB_KEYBOARD
+#DEFINES += QT_DIRECTFB_TIMING
+#DEFINES += QT_NO_DIRECTFB_OPAQUE_DETECTION
target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers
INSTALLS += target
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
index 8a30ad4..2a2ef5c 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
@@ -50,7 +50,7 @@ QDirectFBPaintDevice::~QDirectFBPaintDevice()
}
-IDirectFBSurface *QDirectFBPaintDevice::directFbSurface() const
+IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const
{
return dfbSurface;
}
@@ -64,8 +64,6 @@ void QDirectFBPaintDevice::lockDirectFB() {
void *mem;
int w, h;
- DFBSurfacePixelFormat format;
-
DFBResult result = dfbSurface->Lock(dfbSurface, DSLF_WRITE, &mem, &bpl);
if (result != DFB_OK || !mem) {
DirectFBError("QDirectFBPixmapData::buffer()", result);
@@ -73,10 +71,8 @@ void QDirectFBPaintDevice::lockDirectFB() {
}
dfbSurface->GetSize(dfbSurface, &w, &h);
- dfbSurface->GetPixelFormat(dfbSurface, &format);
-
lockedImage = new QImage(static_cast<uchar*>(mem), w, h, bpl,
- QDirectFBScreen::getImageFormat(format));
+ QDirectFBScreen::getImageFormat(dfbSurface));
}
@@ -102,9 +98,7 @@ void* QDirectFBPaintDevice::memory() const
QImage::Format QDirectFBPaintDevice::format() const
{
- DFBSurfacePixelFormat dfbFormat;
- dfbSurface->GetPixelFormat(dfbSurface, &dfbFormat);
- return QDirectFBScreen::getImageFormat(dfbFormat);
+ return QDirectFBScreen::getImageFormat(dfbSurface);
}
@@ -116,7 +110,6 @@ int QDirectFBPaintDevice::bytesPerLine() const
QDirectFBPaintDevice* that = const_cast<QDirectFBPaintDevice*>(this);
that->lockDirectFB();
Q_ASSERT(bpl != -1);
- that->unlockDirectFB();
}
return bpl;
}
@@ -129,7 +122,6 @@ QSize QDirectFBPaintDevice::size() const
return QSize(w, h);
}
-
int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
{
if (!dfbSurface)
@@ -138,40 +130,21 @@ int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
int w, h;
dfbSurface->GetSize(dfbSurface, &w, &h);
- int dpmX, dpmY; // Dots-per-meter ;-)
-
- // Do some common calculations:
- switch (metric) {
- case QPaintDevice::PdmWidthMM:
- case QPaintDevice::PdmPhysicalDpiX:
- case QPaintDevice::PdmDpiX:
- dpmX = (screen->deviceWidth() * 1000) / screen->physicalWidth();
- break;
- case QPaintDevice::PdmHeightMM:
- case QPaintDevice::PdmPhysicalDpiY:
- case QPaintDevice::PdmDpiY:
- dpmY = (screen->deviceHeight() * 1000) / screen->physicalHeight();
- break;
- default:
- break;
- }
-
- // Now use those calculations
switch (metric) {
case QPaintDevice::PdmWidth:
return w;
case QPaintDevice::PdmHeight:
return h;
case QPaintDevice::PdmWidthMM:
- return (w * 1000) / dpmX;
+ return (w * 1000) / dotsPerMeterX();
case QPaintDevice::PdmHeightMM:
- return (h * 1000) / dpmY;
+ return (h * 1000) / dotsPerMeterY();
case QPaintDevice::PdmPhysicalDpiX:
case QPaintDevice::PdmDpiX:
- return (dpmX * 254) / 10000; // 0.0254 meters-per-inch
+ return (dotsPerMeterX() * 254) / 10000; // 0.0254 meters-per-inch
case QPaintDevice::PdmPhysicalDpiY:
case QPaintDevice::PdmDpiY:
- return (dpmY * 254) / 10000; // 0.0254 meters-per-inch
+ return (dotsPerMeterY() * 254) / 10000; // 0.0254 meters-per-inch
case QPaintDevice::PdmDepth:
DFBSurfacePixelFormat format;
dfbSurface->GetPixelFormat(dfbSurface, &format);
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
index 23fa5d6..a11064b 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
@@ -56,30 +56,42 @@ class QDirectFBPaintDevice : public QCustomRasterPaintDevice
public:
~QDirectFBPaintDevice();
- IDirectFBSurface *directFbSurface() const;
+ IDirectFBSurface *directFBSurface() const;
void lockDirectFB();
void unlockDirectFB();
+ inline bool forceRasterPrimitives() const { return forceRaster; }
+
// Reimplemented from QCustomRasterPaintDevice:
void* memory() const;
QImage::Format format() const;
int bytesPerLine() const;
QSize size() const;
int metric(QPaintDevice::PaintDeviceMetric metric) const;
-
protected:
// Shouldn't create QDirectFBPaintDevice by itself but only sub-class it:
QDirectFBPaintDevice(QDirectFBScreen *scr = QDirectFBScreen::instance())
: QCustomRasterPaintDevice(0),
dfbSurface(0),
lockedImage(0),
- screen(scr) {}
+ screen(scr),
+ forceRaster(false) {}
+
+ inline int dotsPerMeterX() const
+ {
+ return (screen->deviceWidth() * 1000) / screen->physicalWidth();
+ }
+ inline int dotsPerMeterY() const
+ {
+ return (screen->deviceHeight() * 1000) / screen->physicalHeight();
+ }
IDirectFBSurface *dfbSurface;
QImage *lockedImage;
QDirectFBScreen *screen;
int bpl;
+ bool forceRaster;
private:
Q_DISABLE_COPY(QDirectFBPaintDevice)
};
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
index 86357e6..d9346fd 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
@@ -61,17 +61,6 @@ static inline uint ALPHA_MUL(uint x, uint a)
return t;
}
-static inline QRect mapRect(const QTransform &transform, const QRect &rect)
-{
- return (transform.isIdentity() ? rect : transform.mapRect(rect));
-}
-
-static inline QRect mapRect(const QTransform &transform, const QRectF &rect)
-{
- return (transform.isIdentity() ? rect : transform.mapRect(rect)).
- toRect();
-}
-
class SurfaceCache
{
public:
@@ -112,7 +101,7 @@ CachedImage::CachedImage(const QImage &image)
description = QDirectFBScreen::getSurfaceDescription(image);
QDirectFBScreen* screen = QDirectFBScreen::instance();
- tmpSurface = screen->createDFBSurface(&description);
+ tmpSurface = screen->createDFBSurface(&description, QDirectFBScreen::TrackSurface);
if (!tmpSurface) {
qWarning("CachedImage CreateSurface failed!");
return;
@@ -124,7 +113,7 @@ CachedImage::CachedImage(const QImage &image)
description.flags = DFBSurfaceDescriptionFlags(description.flags & ~DSDESC_PREALLOCATED);
- s = screen->createDFBSurface(&description);
+ s = screen->createDFBSurface(&description, QDirectFBScreen::TrackSurface);
if (!s)
qWarning("QDirectFBPaintEngine failed caching image");
@@ -159,7 +148,7 @@ IDirectFBSurface* SurfaceCache::getSurface(const uint *buf, int size)
DFBSurfaceDescription description;
description = QDirectFBScreen::getSurfaceDescription(buf, size);
- surface = QDirectFBScreen::instance()->createDFBSurface(&description);
+ surface = QDirectFBScreen::instance()->createDFBSurface(&description, QDirectFBScreen::TrackSurface);
if (!surface)
qWarning("QDirectFBPaintEngine: SurfaceCache: Unable to create surface");
@@ -195,6 +184,7 @@ public:
QBrush brush;
bool antialiased;
+ bool forceRasterPrimitives;
bool simplePen;
bool simpleBrush;
@@ -206,10 +196,10 @@ public:
void setPen(const QPen &pen);
void setBrush(const QBrush &brush);
void setCompositionMode(QPainter::CompositionMode mode);
- void setOpacity(const qreal value);
+ void setOpacity(quint8 value);
void setRenderHints(QPainter::RenderHints hints);
- inline void setDFBColor(const QColor &color) const;
+ inline void setDFBColor(const QColor &color);
inline void lock();
inline void unlock();
@@ -232,20 +222,18 @@ public:
void drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap);
void drawImage(const QRectF &dest, const QImage &image, const QRectF &src);
- void updateClip();
- void updateFlags();
+ inline void updateClip();
inline void setClipDirty();
- void systemStateChanged(); //Needed to be notified when system clip changes
+ void systemStateChanged();
void begin(QPaintDevice *device);
void end();
+ void prepareForBlit(bool alpha);
SurfaceCache *surfaceCache;
QTransform transform;
+ int lastLockedHeight;
private:
-// QRegion rectsToClippedRegion(const QRect *rects, int n) const;
-// QRegion rectsToClippedRegion(const QRectF *rects, int n) const;
-
IDirectFB *fb;
DFBSurfaceDescription fbDescription;
int fbWidth;
@@ -253,10 +241,9 @@ private:
quint8 opacity;
- quint32 drawFlags;
- quint32 blitFlags;
- quint32 duffFlags;
- bool dirtyFlags;
+ quint32 drawFlagsFromCompositionMode, blitFlagsFromCompositionMode;
+ DFBSurfacePorterDuffRule porterDuffRule;
+
bool dirtyClip;
bool dfbHandledClip;
QDirectFBPaintDevice *dfbDevice;
@@ -265,9 +252,10 @@ private:
};
QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p)
- : surface(0), antialiased(false), simplePen(false),
- simpleBrush(false), matrixRotShear(false), matrixScale(false), fbWidth(-1), fbHeight(-1),
- opacity(255), drawFlags(0), blitFlags(0), duffFlags(0), dirtyFlags(false), dirtyClip(true),
+ : surface(0), antialiased(false), forceRasterPrimitives(false), simplePen(false),
+ simpleBrush(false), matrixRotShear(false), matrixScale(false), lastLockedHeight(-1),
+ fbWidth(-1), fbHeight(-1), opacity(255), drawFlagsFromCompositionMode(0),
+ blitFlagsFromCompositionMode(0), porterDuffRule(DSPD_SRC_OVER), dirtyClip(true),
dfbHandledClip(false), dfbDevice(0), q(p)
{
fb = QDirectFBScreen::instance()->dfb();
@@ -304,12 +292,13 @@ void QDirectFBPaintEnginePrivate::setClipDirty()
dirtyClip = true;
}
-
void QDirectFBPaintEnginePrivate::lock()
{
// We will potentially get a new pointer to the buffer after a
// lock so we need to call the base implementation of prepare so
// it updates its rasterBuffer to point to the new buffer address.
+ lastLockedHeight = dfbDevice->height();
+
Q_ASSERT(dfbDevice);
prepare(dfbDevice);
}
@@ -329,6 +318,7 @@ void QDirectFBPaintEnginePrivate::setTransform(const QTransform &m)
void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device)
{
+ lastLockedHeight = -1;
if (device->devType() == QInternal::CustomRaster)
dfbDevice = static_cast<QDirectFBPaintDevice*>(device);
else if (device->devType() == QInternal::Pixmap) {
@@ -339,22 +329,20 @@ void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device)
}
if (dfbDevice)
- surface = dfbDevice->directFbSurface();
+ surface = dfbDevice->directFBSurface();
if (!surface) {
qFatal("QDirectFBPaintEngine used on an invalid device: 0x%x",
device->devType());
}
+ forceRasterPrimitives = dfbDevice->forceRasterPrimitives();
surface->GetSize(surface, &fbWidth, &fbHeight);
setTransform(QTransform());
antialiased = false;
- drawFlags = DSDRAW_BLEND;
- blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
- duffFlags = DSPD_SRC_OVER;
opacity = 255;
- dirtyFlags = true;
+ setCompositionMode(q->state()->compositionMode());
dirtyClip = true;
setPen(q->state()->pen);
setDFBColor(pen.color());
@@ -372,13 +360,14 @@ void QDirectFBPaintEnginePrivate::setPen(const QPen &p)
{
pen = p;
simplePen = (pen.style() == Qt::NoPen) ||
- (pen.style() == Qt::SolidLine && !antialiased
+ (pen.style() == Qt::SolidLine
+ && !antialiased
+ && (pen.brush().style() == Qt::SolidPattern)
&& (pen.widthF() <= 1 && !matrixScale));
}
void QDirectFBPaintEnginePrivate::setBrush(const QBrush &b)
{
- // TODO: accelerate texture pattern
brush = b;
simpleBrush = (brush.style() == Qt::NoBrush) ||
(brush.style() == Qt::SolidPattern && !antialiased);
@@ -386,91 +375,72 @@ void QDirectFBPaintEnginePrivate::setBrush(const QBrush &b)
void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode)
{
- drawFlags &= ~(DSDRAW_XOR);
- blitFlags &= ~(DSBLIT_XOR);
-
- // TODO: check these mappings!!!!
- quint32 duff = DSPD_NONE;
- quint32 blit = blitFlags;
+ blitFlagsFromCompositionMode = DSBLIT_NOFX;
+ drawFlagsFromCompositionMode = DSDRAW_NOFX;
+ bool blend = true;
switch (mode) {
case QPainter::CompositionMode_SourceOver:
- duff = DSPD_SRC_OVER;
- blit |= DSBLIT_BLEND_ALPHACHANNEL;
+ porterDuffRule = DSPD_SRC_OVER;
break;
case QPainter::CompositionMode_DestinationOver:
- duff = DSPD_DST_OVER;
- blit |= DSBLIT_BLEND_ALPHACHANNEL;
+ porterDuffRule = DSPD_DST_OVER;
break;
case QPainter::CompositionMode_Clear:
- duff = DSPD_CLEAR;
- blit &= ~DSBLIT_BLEND_ALPHACHANNEL;
+ porterDuffRule = DSPD_CLEAR;
+ blend = false;
break;
case QPainter::CompositionMode_Source:
- duff = DSPD_SRC;
- blit &= ~DSBLIT_BLEND_ALPHACHANNEL;
+ porterDuffRule = DSPD_SRC;
+ blend = false;
break;
case QPainter::CompositionMode_Destination:
- blit &= ~DSBLIT_BLEND_ALPHACHANNEL;
+ porterDuffRule = DSPD_NONE; // ### need to double check this
+ blend = false;
return;
case QPainter::CompositionMode_SourceIn:
- duff = DSPD_SRC_IN;
- blit |= DSBLIT_BLEND_ALPHACHANNEL;
+ porterDuffRule = DSPD_SRC_IN;
break;
case QPainter::CompositionMode_DestinationIn:
- duff = DSPD_DST_IN;
- blit |= DSBLIT_BLEND_ALPHACHANNEL;
+ porterDuffRule = DSPD_DST_IN;
break;
case QPainter::CompositionMode_SourceOut:
- duff = DSPD_SRC_OUT;
- blit |= DSBLIT_BLEND_ALPHACHANNEL;
+ porterDuffRule = DSPD_SRC_OUT;
break;
case QPainter::CompositionMode_DestinationOut:
- duff = DSPD_DST_OUT;
- blit |= DSBLIT_BLEND_ALPHACHANNEL;
- break;
- case QPainter::CompositionMode_SourceAtop:
- duff = DSPD_SRC_OVER;
- blit |= DSBLIT_BLEND_ALPHACHANNEL;
- break;
- case QPainter::CompositionMode_DestinationAtop:
- duff = DSPD_DST_OVER;
+ porterDuffRule = DSPD_DST_OUT;
break;
case QPainter::CompositionMode_Xor:
- duff = DSPD_NONE;
- blit |= DSBLIT_BLEND_ALPHACHANNEL;
- drawFlags |= DSDRAW_XOR;
- blit |= DSBLIT_XOR;
- dirtyFlags = true;
+ porterDuffRule = DSPD_XOR;
+ blitFlagsFromCompositionMode |= DSBLIT_XOR;
+ drawFlagsFromCompositionMode |= DSDRAW_XOR;
break;
+// case QPainter::CompositionMode_Plus: // ???
+// porterDuffRule = DSPD_ADD;
+// break;
default:
qWarning("QDirectFBPaintEnginePrivate::setCompositionMode(): "
"mode %d not implemented", mode);
- break;
+ return;
}
-
- if (duff != duffFlags || blit != blitFlags) {
- duffFlags = duff;
- blitFlags = blit;
- dirtyFlags = true;
+ // intentially not comparing with current porterDuffRule. surface might have changed.
+ if (blend) {
+ blitFlagsFromCompositionMode |= DSBLIT_BLEND_ALPHACHANNEL;
+ drawFlagsFromCompositionMode |= DSDRAW_BLEND;
+ }
+ if (opacity != 255) {
+ setOpacity(opacity);
}
}
-void QDirectFBPaintEnginePrivate::setOpacity(const qreal value)
+void QDirectFBPaintEnginePrivate::setOpacity(quint8 op)
{
- const bool wasOpaque = (opacity == 255);
- opacity = quint8(value * 255);
- const bool opaque = (opacity == 255);
-
- if (opaque == wasOpaque)
- return;
-
- if (opaque)
- blitFlags &= ~(DSBLIT_BLEND_COLORALPHA | DSBLIT_SRC_PREMULTCOLOR);
- else
- blitFlags |= (DSBLIT_BLEND_COLORALPHA | DSBLIT_SRC_PREMULTCOLOR);
-
- dirtyFlags = true;
+ opacity = op;
+ if (opacity == 255) {
+ blitFlagsFromCompositionMode &= ~DSBLIT_BLEND_COLORALPHA;
+ } else {
+ blitFlagsFromCompositionMode |= DSBLIT_BLEND_COLORALPHA;
+ }
}
void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints)
@@ -482,133 +452,83 @@ void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints)
}
}
-void QDirectFBPaintEnginePrivate::updateFlags()
+void QDirectFBPaintEnginePrivate::prepareForBlit(bool alpha)
{
- if (!dirtyFlags)
- return;
- surface->SetDrawingFlags(surface, DFBSurfaceDrawingFlags(drawFlags));
- surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(blitFlags));
- surface->SetPorterDuff(surface, DFBSurfacePorterDuffRule(duffFlags));
- dirtyFlags = false;
+ quint32 blittingFlags = blitFlagsFromCompositionMode;
+ if (alpha) {
+ surface->SetPorterDuff(surface,
+ (blittingFlags & DSBLIT_BLEND_COLORALPHA)
+ ? DSPD_NONE
+ : porterDuffRule);
+ } else {
+ blittingFlags &= ~DSBLIT_BLEND_ALPHACHANNEL;
+ surface->SetPorterDuff(surface, DSPD_NONE);
+ }
+ surface->SetColor(surface, 0xff, 0xff, 0xff, opacity);
+ surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(blittingFlags));
}
-void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color) const
+void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color)
{
+ Q_ASSERT(surface);
const quint8 alpha = (opacity == 255 ?
color.alpha() : ALPHA_MUL(color.alpha(), opacity));
surface->SetColor(surface,
color.red(), color.green(), color.blue(), alpha);
+ quint32 drawingFlags = drawFlagsFromCompositionMode;
+ if (alpha == 255) {
+ drawingFlags &= ~DSDRAW_BLEND;
+ }
+ surface->SetPorterDuff(surface, DSPD_NONE);
+ // PorterDuff messes up alpha values for primitives
+ surface->SetDrawingFlags(surface, DFBSurfaceDrawingFlags(drawingFlags));
}
void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) const
{
- QVarLengthArray<DFBRegion> regions(n);
-
for (int i = 0; i < n; ++i) {
const QLine l = transform.map(lines[i]);
-
- // TODO: clip!
-
- regions[i].x1 = l.x1();
- regions[i].y1 = l.y1();
- regions[i].x2 = l.x2();
- regions[i].y2 = l.y2();
+ surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2());
}
- surface->DrawLines(surface, regions.data(), n);
}
void QDirectFBPaintEnginePrivate::drawLines(const QLineF *lines, int n) const
{
- QVarLengthArray<DFBRegion> regions(n);
-
for (int i = 0; i < n; ++i) {
const QLine l = transform.map(lines[i]).toLine();
-
- // TODO: clip!
-
- regions[i].x1 = l.x1();
- regions[i].y1 = l.y1();
- regions[i].x2 = l.x2();
- regions[i].y2 = l.y2();
- }
- surface->DrawLines(surface, regions.data(), n);
-}
-
-/* ### Commented out until it can be implemented properly using raster's QClipData
-QRegion QDirectFBPaintEnginePrivate::rectsToClippedRegion(const QRect *rects,
- int n) const
-{
- QRegion region;
-
- for (int i = 0; i < n; ++i) {
- const QRect r = ::mapRect(transform, rects[i]);
- region += clip & r;
- }
-
- return region;
-}
-
-QRegion QDirectFBPaintEnginePrivate::rectsToClippedRegion(const QRectF *rects,
- int n) const
-{
- QRegion region;
-
- for (int i = 0; i < n; ++i) {
- const QRect r = ::mapRect(transform, rects[i]);
- region += clip & r;
+ surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2());
}
-
- return region;
}
-*/
void QDirectFBPaintEnginePrivate::fillRegion(const QRegion &region) const
{
const QVector<QRect> rects = region.rects();
const int n = rects.size();
- QVarLengthArray<DFBRectangle> dfbRects(n);
-
- for (int i = 0; i < n; ++i) {
- const QRect r = rects.at(i);
- dfbRects[i].x = r.x();
- dfbRects[i].y = r.y();
- dfbRects[i].w = r.width();
- dfbRects[i].h = r.height();
-
- }
- surface->FillRectangles(surface, dfbRects.data(), n);
+ fillRects(rects.constData(), n);
}
void QDirectFBPaintEnginePrivate::fillRects(const QRect *rects, int n) const
{
- QVarLengthArray<DFBRectangle> dfbRects(n);
for (int i = 0; i < n; ++i) {
- const QRect r = ::mapRect(transform, rects[i]);
- dfbRects[i].x = r.x();
- dfbRects[i].y = r.y();
- dfbRects[i].w = r.width();
- dfbRects[i].h = r.height();
+ const QRect r = transform.mapRect(rects[i]);
+ surface->FillRectangle(surface, r.x(), r.y(),
+ r.width(), r.height());
}
- surface->FillRectangles(surface, dfbRects.data(), n);
}
void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) const
{
- QVarLengthArray<DFBRectangle> dfbRects(n);
for (int i = 0; i < n; ++i) {
- const QRect r = ::mapRect(transform, rects[i]);
- dfbRects[i].x = r.x();
- dfbRects[i].y = r.y();
- dfbRects[i].w = r.width();
- dfbRects[i].h = r.height();
+ const QRect r = transform.mapRect(rects[i]).toRect();
+ surface->FillRectangle(surface, r.x(), r.y(),
+ r.width(), r.height());
}
- surface->FillRectangles(surface, dfbRects.data(), n);
}
void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) const
{
for (int i = 0; i < n; ++i) {
- const QRect r = ::mapRect(transform, rects[i]);
+ const QRect r = transform.mapRect(rects[i]);
surface->DrawRectangle(surface, r.x(), r.y(),
r.width() + 1, r.height() + 1);
}
@@ -617,7 +537,7 @@ void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) const
void QDirectFBPaintEnginePrivate::drawRects(const QRectF *rects, int n) const
{
for (int i = 0; i < n; ++i) {
- const QRect r = ::mapRect(transform, rects[i]);
+ const QRect r = transform.mapRect(rects[i]).toRect();
surface->DrawRectangle(surface, r.x(), r.y(),
r.width() + 1, r.height() + 1);
}
@@ -627,21 +547,13 @@ void QDirectFBPaintEnginePrivate::drawPixmap(const QRectF &dest,
const QPixmap &pixmap,
const QRectF &src)
{
- surface->SetColor(surface, 0xff, 0xff, 0xff, opacity);
-
- const bool changeFlags = !pixmap.hasAlphaChannel()
- && (blitFlags & DSBLIT_BLEND_ALPHACHANNEL);
- if (changeFlags) {
- quint32 flags = blitFlags & ~DSBLIT_BLEND_ALPHACHANNEL;
- surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(flags));
- }
-
+ prepareForBlit(pixmap.hasAlphaChannel());
QPixmapData *data = pixmap.pixmapData();
Q_ASSERT(data->classId() == QPixmapData::DirectFBClass);
QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data);
- IDirectFBSurface *s = dfbData->directFbSurface();
+ IDirectFBSurface *s = dfbData->directFBSurface();
const QRect sr = src.toRect();
- const QRect dr = ::mapRect(transform, dest);
+ const QRect dr = transform.mapRect(dest).toRect();
const DFBRectangle sRect = { sr.x(), sr.y(), sr.width(), sr.height() };
DFBResult result;
@@ -653,27 +565,17 @@ void QDirectFBPaintEnginePrivate::drawPixmap(const QRectF &dest,
}
if (result != DFB_OK)
DirectFBError("QDirectFBPaintEngine::drawPixmap()", result);
- if (changeFlags)
- surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(blitFlags));
}
void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest,
const QPixmap &pixmap)
{
- surface->SetColor(surface, 0xff, 0xff, 0xff, opacity);
-
- const bool changeFlags = !pixmap.hasAlphaChannel()
- && (blitFlags & DSBLIT_BLEND_ALPHACHANNEL);
- if (changeFlags) {
- quint32 flags = blitFlags & ~DSBLIT_BLEND_ALPHACHANNEL;
- surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(flags));
- }
-
+ prepareForBlit(pixmap.hasAlphaChannel());
QPixmapData *data = pixmap.pixmapData();
Q_ASSERT(data->classId() == QPixmapData::DirectFBClass);
QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data);
- IDirectFBSurface *s = dfbData->directFbSurface();
- const QRect dr = ::mapRect(transform, dest);
+ IDirectFBSurface *s = dfbData->directFBSurface();
+ const QRect dr = transform.mapRect(dest).toRect();
DFBResult result = DFB_OK;
if (!matrixScale && dr == QRect(0, 0, fbWidth, fbHeight)) {
@@ -695,7 +597,7 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest,
result = surface->BatchBlit(surface, s, rects.constData(),
points.constData(), points.size());
} else {
- const QRect sr = ::mapRect(transform, QRect(0, 0, pixmap.width(), pixmap.height()));
+ const QRect sr = transform.mapRect(QRect(0, 0, pixmap.width(), pixmap.height()));
const int dx = sr.width();
const int dy = sr.height();
const DFBRectangle sRect = { 0, 0, dx, dy };
@@ -714,25 +616,13 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest,
if (result != DFB_OK)
DirectFBError("QDirectFBPaintEngine::drawTiledPixmap()", result);
-
- if (changeFlags)
- surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(blitFlags));
}
void QDirectFBPaintEnginePrivate::drawImage(const QRectF &dest,
- const QImage &srcImage,
+ const QImage &image,
const QRectF &src)
{
- QImage image = srcImage;
- if (QDirectFBScreen::getSurfacePixelFormat(image) == DSPF_UNKNOWN) {
- QImage::Format format;
- if (image.hasAlphaChannel())
- format = QImage::Format_ARGB32_Premultiplied;
- else
- format = QImage::Format_RGB32;
- image = image.convertToFormat(format);
- }
-
+ Q_ASSERT(QDirectFBScreen::getSurfacePixelFormat(image.format()) != DSPF_UNKNOWN);
CachedImage *img = imageCache[image.cacheKey()];
IDirectFBSurface *imgSurface = 0;
bool doRelease = false;
@@ -756,7 +646,8 @@ void QDirectFBPaintEnginePrivate::drawImage(const QRectF &dest,
DFBSurfaceDescription description;
description = QDirectFBScreen::getSurfaceDescription(image);
- imgSurface = QDirectFBScreen::instance()->createDFBSurface(&description);
+ imgSurface = QDirectFBScreen::instance()->createDFBSurface(&description,
+ QDirectFBScreen::DontTrackSurface);
if (!imgSurface) {
qWarning("QDirectFBPaintEnginePrivate::drawImage");
return;
@@ -770,17 +661,10 @@ void QDirectFBPaintEnginePrivate::drawImage(const QRectF &dest,
}
const QRect sr = src.toRect();
- const QRect dr = ::mapRect(transform, dest);
+ const QRect dr = transform.mapRect(dest).toRect();
const DFBRectangle sRect = { sr.x(), sr.y(), sr.width(), sr.height() };
- surface->SetColor(surface, 0xff, 0xff, 0xff, opacity);
-
- const bool changeFlags = !image.hasAlphaChannel()
- && (blitFlags & DSBLIT_BLEND_ALPHACHANNEL);
- if (changeFlags) {
- quint32 flags = blitFlags & ~DSBLIT_BLEND_ALPHACHANNEL;
- surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(flags));
- }
+ prepareForBlit(image.hasAlphaChannel());
if (dr.size() == sr.size()) {
surface->Blit(surface, imgSurface, &sRect, dr.x(), dr.y());
} else {
@@ -788,10 +672,10 @@ void QDirectFBPaintEnginePrivate::drawImage(const QRectF &dest,
dr.width(), dr.height() };
surface->StretchBlit(surface, imgSurface, &sRect, &dRect);
}
- if (changeFlags)
- surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(blitFlags));
- if (doRelease)
- QDirectFBScreen::instance()->releaseDFBSurface(imgSurface);
+ if (doRelease) {
+ surface->ReleaseSource(surface);
+ imgSurface->Release(imgSurface);
+ }
}
void QDirectFBPaintEnginePrivate::updateClip()
@@ -882,8 +766,7 @@ void QDirectFBPaintEngine::brushChanged()
void QDirectFBPaintEngine::opacityChanged()
{
Q_D(QDirectFBPaintEngine);
- d->setOpacity(state()->opacity);
-
+ d->setOpacity(quint8(state()->opacity * 255));
QRasterPaintEngine::opacityChanged();
}
@@ -891,7 +774,6 @@ void QDirectFBPaintEngine::compositionModeChanged()
{
Q_D(QDirectFBPaintEngine);
d->setCompositionMode(state()->compositionMode());
-
QRasterPaintEngine::compositionModeChanged();
}
@@ -917,11 +799,10 @@ void QDirectFBPaintEngine::setState(QPainterState *s)
{
Q_D(QDirectFBPaintEngine);
QRasterPaintEngine::setState(s);
- if (d->surface)
- d->updateClip();
+ d->setClipDirty();
d->setPen(state()->pen);
d->setBrush(state()->brush);
- d->setOpacity(state()->opacity);
+ d->setOpacity(quint8(state()->opacity * 255));
d->setCompositionMode(state()->compositionMode());
d->setTransform(state()->transform());
}
@@ -930,6 +811,9 @@ void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
{
Q_D(QDirectFBPaintEngine);
d->setClipDirty();
+ const QPoint bottom = d->transform.map(QPoint(0, path.controlPointRect().y2));
+ if (bottom.y() >= d->lastLockedHeight)
+ d->lock();
QRasterPaintEngine::clip(path, op);
}
@@ -937,15 +821,21 @@ void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op)
{
Q_D(QDirectFBPaintEngine);
d->setClipDirty();
+ if (!d->clip()->hasRectClip && d->clip()->enabled) {
+ const QPoint bottom = d->transform.map(QPoint(0, rect.bottom()));
+ if (bottom.y() >= d->lastLockedHeight)
+ d->lock();
+ }
+
QRasterPaintEngine::clip(rect, op);
}
-
void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount)
{
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (!d->dfbCanHandleClip() || d->matrixRotShear || !d->simpleBrush || !d->simplePen) {
+ if (!d->dfbCanHandleClip() || d->matrixRotShear || !d->simpleBrush
+ || !d->simplePen || d->forceRasterPrimitives) {
d->lock();
QRasterPaintEngine::drawRects(rects, rectCount);
return;
@@ -954,12 +844,10 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount)
d->unlock();
if (d->brush != Qt::NoBrush) {
- d->updateFlags();
d->setDFBColor(d->brush.color());
d->fillRects(rects, rectCount);
}
if (d->pen != Qt::NoPen) {
- d->updateFlags();
d->setDFBColor(d->pen.color());
d->drawRects(rects, rectCount);
}
@@ -969,7 +857,8 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount)
{
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (!d->dfbCanHandleClip() || d->matrixRotShear || !d->simpleBrush || !d->simplePen) {
+ if (!d->dfbCanHandleClip() || d->matrixRotShear || !d->simpleBrush
+ || !d->simplePen || d->forceRasterPrimitives) {
d->lock();
QRasterPaintEngine::drawRects(rects, rectCount);
return;
@@ -978,12 +867,10 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount)
d->unlock();
if (d->brush != Qt::NoBrush) {
- d->updateFlags();
d->setDFBColor(d->brush.color());
d->fillRects(rects, rectCount);
}
if (d->pen != Qt::NoPen) {
- d->updateFlags();
d->setDFBColor(d->pen.color());
d->drawRects(rects, rectCount);
}
@@ -993,7 +880,7 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount)
{
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (!d->simplePen || !d->dfbCanHandleClip()) {
+ if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) {
d->lock();
QRasterPaintEngine::drawLines(lines, lineCount);
return;
@@ -1001,7 +888,6 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount)
if (d->pen != Qt::NoPen) {
d->unlock();
- d->updateFlags();
d->setDFBColor(d->pen.color());
d->drawLines(lines, lineCount);
}
@@ -1011,7 +897,7 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount)
{
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (!d->simplePen || !d->dfbCanHandleClip()) {
+ if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) {
d->lock();
QRasterPaintEngine::drawLines(lines, lineCount);
return;
@@ -1019,7 +905,6 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount)
if (d->pen != Qt::NoPen) {
d->unlock();
- d->updateFlags();
d->setDFBColor(d->pen.color());
d->drawLines(lines, lineCount);
}
@@ -1034,7 +919,8 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image,
#ifndef QT_NO_DIRECTFB_PREALLOCATED
d->updateClip();
- if (!d->dfbCanHandleClip(r) || d->matrixRotShear)
+ if (!d->dfbCanHandleClip(r) || d->matrixRotShear
+ || QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN)
#endif
{
d->lock();
@@ -1044,7 +930,6 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image,
#ifndef QT_NO_DIRECTFB_PREALLOCATED
d->unlock();
- d->updateFlags();
d->drawImage(r, image, sr);
#endif
}
@@ -1063,15 +948,12 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap,
if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) {
d->lock();
QRasterPaintEngine::drawPixmap(r, pixmap, sr);
- }
- else if (!d->dfbCanHandleClip(r) || d->matrixRotShear) {
+ } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear) {
const QImage *img = static_cast<QDirectFBPixmapData*>(pixmap.pixmapData())->buffer();
d->lock();
QRasterPaintEngine::drawImage(r, *img, sr);
- }
- else {
+ } else {
d->unlock();
- d->updateFlags();
d->drawPixmap(r, pixmap, sr);
}
}
@@ -1090,18 +972,15 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r,
if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) {
d->lock();
QRasterPaintEngine::drawTiledPixmap(r, pixmap, sp);
- }
- else if (!d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull()) {
- QImage* img = static_cast<QDirectFBPixmapData*>(pixmap.pixmapData())->buffer();
+ } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull()) {
+ const QImage *img = static_cast<QDirectFBPixmapData*>(pixmap.pixmapData())->buffer();
+ d->lock();
QRasterPixmapData *data = new QRasterPixmapData(QPixmapData::PixmapType);
data->fromImage(*img, Qt::AutoColor);
const QPixmap pix(data);
- d->lock();
QRasterPaintEngine::drawTiledPixmap(r, pix, sp);
- }
- else {
+ } else {
d->unlock();
- d->updateFlags();
d->drawTiledPixmap(r, pixmap);
}
}
@@ -1181,10 +1060,11 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
if (d->dfbCanHandleClip(rect) && !d->matrixRotShear) {
switch (brush.style()) {
case Qt::SolidPattern: {
+ if (d->forceRasterPrimitives)
+ break;
d->unlock();
- d->updateFlags();
d->setDFBColor(brush.color());
- const QRect r = ::mapRect(d->transform, rect);
+ const QRect r = d->transform.mapRect(rect).toRect();
d->surface->FillRectangle(d->surface, r.x(), r.y(),
r.width(), r.height());
return; }
@@ -1192,7 +1072,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
if (state()->brushOrigin == QPointF() && brush.transform().isIdentity()) {
//could handle certain types of brush.transform() E.g. scale
d->unlock();
- d->updateFlags();
d->drawTiledPixmap(rect, brush.texture());
return;
}
@@ -1209,14 +1088,13 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color)
{
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (!d->dfbCanHandleClip() || d->matrixRotShear) {
+ if (!d->dfbCanHandleClip() || d->matrixRotShear || d->forceRasterPrimitives) {
d->lock();
QRasterPaintEngine::fillRect(rect, color);
} else {
d->unlock();
- d->updateFlags();
d->setDFBColor(color);
- const QRect r = ::mapRect(d->transform, rect);
+ const QRect r = d->transform.mapRect(rect).toRect();
d->surface->FillRectangle(d->surface, r.x(), r.y(),
r.width(), r.height());
}
@@ -1226,31 +1104,37 @@ void QDirectFBPaintEngine::drawColorSpans(const QSpan *spans, int count,
uint color)
{
Q_D(QDirectFBPaintEngine);
- color = INV_PREMUL(color);
-
- QVarLengthArray<DFBRegion> lines(count);
- int j = 0;
- for (int i = 0; i < count; ++i) {
- if (spans[i].coverage == 255) {
- lines[j].x1 = spans[i].x;
- lines[j].y1 = spans[i].y;
- lines[j].x2 = spans[i].x + spans[i].len - 1;
- lines[j].y2 = spans[i].y;
- ++j;
- } else {
- DFBSpan span = { spans[i].x, spans[i].len };
- uint c = BYTE_MUL(color, spans[i].coverage);
+ if (d->forceRasterPrimitives) {
+ d->lock();
+ QRasterPaintEngine::drawColorSpans(spans, count, color);
+ } else {
+ color = INV_PREMUL(color);
+
+ QVarLengthArray<DFBRegion> lines(count);
+ int j = 0;
+ for (int i = 0; i < count; ++i) {
+ if (spans[i].coverage == 255) {
+ lines[j].x1 = spans[i].x;
+ lines[j].y1 = spans[i].y;
+ lines[j].x2 = spans[i].x + spans[i].len - 1;
+ lines[j].y2 = spans[i].y;
+ ++j;
+ } else {
+ DFBSpan span = { spans[i].x, spans[i].len };
+ uint c = BYTE_MUL(color, spans[i].coverage);
+ // ### how does this play with setDFBColor
+ d->surface->SetColor(d->surface,
+ qRed(c), qGreen(c), qBlue(c), qAlpha(c));
+ d->surface->FillSpans(d->surface, spans[i].y, &span, 1);
+ }
+ }
+ if (j > 0) {
d->surface->SetColor(d->surface,
- qRed(c), qGreen(c), qBlue(c), qAlpha(c));
- d->surface->FillSpans(d->surface, spans[i].y, &span, 1);
+ qRed(color), qGreen(color), qBlue(color),
+ qAlpha(color));
+ d->surface->DrawLines(d->surface, lines.data(), j);
}
}
- if (j > 0) {
- d->surface->SetColor(d->surface,
- qRed(color), qGreen(color), qBlue(color),
- qAlpha(color));
- d->surface->DrawLines(d->surface, lines.data(), j);
- }
}
void QDirectFBPaintEngine::drawBufferSpan(const uint *buffer, int bufsize,
@@ -1259,6 +1143,7 @@ void QDirectFBPaintEngine::drawBufferSpan(const uint *buffer, int bufsize,
{
Q_D(QDirectFBPaintEngine);
IDirectFBSurface *src = d->surfaceCache->getSurface(buffer, bufsize);
+ // ### how does this play with setDFBColor
src->SetColor(src, 0, 0, 0, const_alpha);
const DFBRectangle rect = { 0, 0, length, 1 };
d->surface->Blit(d->surface, src, &rect, x, y);
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
index 6352652..0a1696a 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
@@ -51,7 +51,7 @@ static int global_ser_no = 0;
QDirectFBPixmapData::QDirectFBPixmapData(PixelType pixelType)
: QPixmapData(pixelType, DirectFBClass),
- engine(0)
+ engine(0), format(QImage::Format_Invalid), alpha(false)
{
setSerialNumber(0);
}
@@ -67,81 +67,119 @@ QDirectFBPixmapData::~QDirectFBPixmapData()
void QDirectFBPixmapData::resize(int width, int height)
{
if (width <= 0 || height <= 0) {
- setSerialNumber(0);
+ invalidate();
return;
}
- DFBSurfaceDescription description;
- description.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH |
- DSDESC_HEIGHT);
- description.width = width;
- description.height = height;
-
- dfbSurface = screen->createDFBSurface(&description);
- if (!dfbSurface)
- qCritical("QDirectFBPixmapData::resize(): Unable to allocate surface");
+ format = screen->pixelFormat();
+ dfbSurface = QDirectFBScreen::instance()->createDFBSurface(QSize(width, height),
+ format,
+ QDirectFBScreen::TrackSurface);
+ alpha = false;
+ forceRaster = (format == QImage::Format_RGB32);
+ if (!dfbSurface) {
+ invalidate();
+ qWarning("QDirectFBPixmapData::resize(): Unable to allocate surface");
+ return;
+ }
setSerialNumber(++global_ser_no);
}
-void QDirectFBPixmapData::fromImage(const QImage &img,
- Qt::ImageConversionFlags)
-{
- QImage image;
- if (QDirectFBScreen::getSurfacePixelFormat(img) == DSPF_UNKNOWN)
- image = img.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- else
- image = img;
- DFBSurfaceDescription description;
- description = QDirectFBScreen::getSurfaceDescription(image);
+// mostly duplicated from qimage.cpp (QImageData::checkForAlphaPixels)
+static bool checkForAlphaPixels(const QImage &img)
+{
+ const uchar *bits = img.bits();
+ const int bytes_per_line = img.bytesPerLine();
+ const uchar *end_bits = bits + bytes_per_line;
+ const int width = img.width();
+ const int height = img.height();
+ switch (img.format()) {
+ case QImage::Format_Indexed8:
+ return img.hasAlphaChannel();
+ case QImage::Format_ARGB32:
+ case QImage::Format_ARGB32_Premultiplied:
+ for (int y=0; y<height; ++y) {
+ for (int x=0; x<width; ++x) {
+ if ((((uint *)bits)[x] & 0xff000000) != 0xff000000) {
+ return true;
+ }
+ }
+ bits += bytes_per_line;
+ }
+ break;
+
+ case QImage::Format_ARGB8555_Premultiplied:
+ case QImage::Format_ARGB8565_Premultiplied:
+ for (int y=0; y<height; ++y) {
+ while (bits < end_bits) {
+ if (bits[0] != 0) {
+ return true;
+ }
+ bits += 3;
+ }
+ bits = end_bits;
+ end_bits += bytes_per_line;
+ }
+ break;
+
+ case QImage::Format_ARGB6666_Premultiplied:
+ for (int y=0; y<height; ++y) {
+ while (bits < end_bits) {
+ if ((bits[0] & 0xfc) != 0) {
+ return true;
+ }
+ bits += 3;
+ }
+ bits = end_bits;
+ end_bits += bytes_per_line;
+ }
+ break;
+
+ case QImage::Format_ARGB4444_Premultiplied:
+ for (int y=0; y<height; ++y) {
+ while (bits < end_bits) {
+ if ((bits[0] & 0xf0) != 0) {
+ return true;
+ }
+ bits += 2;
+ }
+ bits = end_bits;
+ end_bits += bytes_per_line;
+ }
+ break;
-#ifndef QT_NO_DIRECTFB_PREALLOCATED
- IDirectFBSurface *imgSurface;
- imgSurface = screen->createDFBSurface(&description);
- if (!imgSurface) {
- qWarning("QDirectFBPixmapData::fromImage()");
- setSerialNumber(0);
- return;
+ default:
+ break;
}
-#ifndef QT_NO_DIRECTFB_PALETTE
- QDirectFBScreen::setSurfaceColorTable(imgSurface, image);
-#endif
-#endif // QT_NO_DIRECTFB_PREALLOCATED
- description.flags = DFBSurfaceDescriptionFlags(description.flags
- & ~DSDESC_PREALLOCATED);
- dfbSurface = screen->createDFBSurface(&description);
+ return false;
+}
+
+void QDirectFBPixmapData::fromImage(const QImage &img,
+ Qt::ImageConversionFlags flags)
+{
+ Q_ASSERT(img.depth() != 1); // these should be handled by QRasterPixmapData
+ if (img.hasAlphaChannel()
+#ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION
+ && (flags & Qt::NoOpaqueDetection || ::checkForAlphaPixels(img))
+#endif
+ ) {
+ alpha = true;
+ format = screen->alphaPixmapFormat();
+ } else {
+ alpha = false;
+ format = screen->pixelFormat();
+ }
+ dfbSurface = screen->copyToDFBSurface(img, format,
+ QDirectFBScreen::TrackSurface);
+ forceRaster = (format == QImage::Format_RGB32);
if (!dfbSurface) {
qWarning("QDirectFBPixmapData::fromImage()");
- setSerialNumber(0);
+ invalidate();
return;
}
-
-#ifndef QT_NO_DIRECTFB_PALETTE
- QDirectFBScreen::setSurfaceColorTable(dfbSurface, image);
-#endif
-
-#ifdef QT_NO_DIRECTFB_PREALLOCATED
- char *mem;
- surface->Lock(surface, DSLF_WRITE, (void**)&mem, &bpl);
- const int w = image.width() * image.depth() / 8;
- for (int i = 0; i < image.height(); ++i) {
- memcpy(mem, image.scanLine(i), w);
- mem += bpl;
- }
- surface->Unlock(surface);
-#else
- DFBResult result;
- dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
- result = dfbSurface->Blit(dfbSurface, imgSurface, 0, 0, 0);
- if (result != DFB_OK)
- DirectFBError("QDirectFBPixmapData::fromImage()", result);
- dfbSurface->Flip(dfbSurface, 0, DSFLIP_NONE);
- dfbSurface->ReleaseSource(dfbSurface);
- screen->releaseDFBSurface(imgSurface);
-#endif // QT_NO_DIRECTFB_PREALLOCATED
-
setSerialNumber(++global_ser_no);
}
@@ -152,43 +190,55 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect)
return;
}
- IDirectFBSurface *src = static_cast<const QDirectFBPixmapData*>(data)->directFbSurface();
+ IDirectFBSurface *src = static_cast<const QDirectFBPixmapData*>(data)->directFBSurface();
+ const bool hasAlpha = data->hasAlphaChannel();
+ format = (hasAlpha
+ ? QDirectFBScreen::instance()->alphaPixmapFormat()
+ : QDirectFBScreen::instance()->pixelFormat());
- DFBSurfaceDescription description;
- description.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH |
- DSDESC_HEIGHT |
- DSDESC_PIXELFORMAT);
- description.width = rect.width();
- description.height = rect.height();
- src->GetPixelFormat(src, &description.pixelformat);
-
- dfbSurface = screen->createDFBSurface(&description);
+ dfbSurface = screen->createDFBSurface(rect.size(), format,
+ QDirectFBScreen::TrackSurface);
if (!dfbSurface) {
qWarning("QDirectFBPixmapData::copy()");
- setSerialNumber(0);
+ invalidate();
return;
}
+ forceRaster = (format == QImage::Format_RGB32);
- DFBResult result;
-#ifndef QT_NO_DIRECTFB_PALETTE
- IDirectFBPalette *palette;
- result = src->GetPalette(src, &palette);
- if (result == DFB_OK) {
- dfbSurface->SetPalette(dfbSurface, palette);
- palette->Release(palette);
+ if (hasAlpha) {
+ dfbSurface->Clear(dfbSurface, 0, 0, 0, 0);
+ dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_BLEND_ALPHACHANNEL);
+ } else {
+ dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
}
-#endif
-
- dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
const DFBRectangle blitRect = { rect.x(), rect.y(),
rect.width(), rect.height() };
- result = dfbSurface->Blit(dfbSurface, src, &blitRect, 0, 0);
- if (result != DFB_OK)
+ DFBResult result = dfbSurface->Blit(dfbSurface, src, &blitRect, 0, 0);
+ dfbSurface->ReleaseSource(dfbSurface);
+ if (result != DFB_OK) {
DirectFBError("QDirectFBPixmapData::copy()", result);
+ invalidate();
+ return;
+ }
setSerialNumber(++global_ser_no);
}
+static inline bool isOpaqueFormat(QImage::Format format)
+{
+ switch (format) {
+ case QImage::Format_RGB32:
+ case QImage::Format_RGB16:
+ case QImage::Format_RGB666:
+ case QImage::Format_RGB555:
+ case QImage::Format_RGB888:
+ case QImage::Format_RGB444:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
void QDirectFBPixmapData::fill(const QColor &color)
{
@@ -197,72 +247,39 @@ void QDirectFBPixmapData::fill(const QColor &color)
Q_ASSERT(dfbSurface);
- if (color.alpha() < 255 && !hasAlphaChannel()) {
- // convert to surface supporting alpha channel
- DFBSurfacePixelFormat format;
- dfbSurface->GetPixelFormat(dfbSurface, &format);
- switch (format) {
- case DSPF_YUY2:
- case DSPF_UYVY:
- format = DSPF_AYUV;
- break;
-#if (Q_DIRECTFB_VERSION >= 0x010100)
- case DSPF_RGB444:
- format = DSPF_ARGB4444;
- break;
- case DSPF_RGB555:
-#endif
- case DSPF_RGB18:
- format = DSPF_ARGB6666;
- break;
- default:
- format = DSPF_ARGB;
- break;
- }
+ alpha = (color.alpha() < 255);
- DFBSurfaceDescription description;
- description.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH |
- DSDESC_HEIGHT |
- DSDESC_PIXELFORMAT);
- dfbSurface->GetSize(dfbSurface, &description.width, &description.height);
- description.pixelformat = format;
- screen->releaseDFBSurface(dfbSurface); // release old surface
-
- dfbSurface = screen->createDFBSurface(&description);
+ if (alpha && ::isOpaqueFormat(format)) {
+ QSize size;
+ dfbSurface->GetSize(dfbSurface, &size.rwidth(), &size.rheight());
+ screen->releaseDFBSurface(dfbSurface);
+ format = screen->alphaPixmapFormat();
+ dfbSurface = screen->createDFBSurface(size, screen->alphaPixmapFormat(), QDirectFBScreen::TrackSurface);
+ forceRaster = false;
+ setSerialNumber(++global_ser_no);
if (!dfbSurface) {
- qWarning("QDirectFBPixmapData::fill()");
- setSerialNumber(0);
+ qWarning("QDirecttFBPixmapData::fill()");
+ invalidate();
return;
}
}
- dfbSurface->Clear(dfbSurface, color.red(), color.green(), color.blue(),
- color.alpha());
-}
-
-bool QDirectFBPixmapData::hasAlphaChannel() const
-{
- if (!serialNumber())
- return false;
-
- DFBSurfacePixelFormat format;
- dfbSurface->GetPixelFormat(dfbSurface, &format);
- switch (format) {
- case DSPF_ARGB1555:
- case DSPF_ARGB:
- case DSPF_LUT8:
- case DSPF_AiRGB:
- case DSPF_A1:
- case DSPF_ARGB2554:
- case DSPF_ARGB4444:
- case DSPF_AYUV:
- case DSPF_A4:
- case DSPF_ARGB1666:
- case DSPF_ARGB6666:
- case DSPF_LUT2:
- return true;
- default:
- return false;
+ if (forceRaster) {
+ // in DSPF_RGB32 all dfb drawing causes the Alpha byte to be
+ // set to 0. This causes issues for the raster engine.
+ char *mem;
+ int bpl;
+ const int h = QPixmapData::height();
+ dfbSurface->Lock(dfbSurface, DSLF_WRITE, (void**)&mem, &bpl);
+ const int c = color.rgba();
+ for (int i = 0; i < h; ++i) {
+ memset(mem, c, bpl);
+ mem += bpl;
+ }
+ dfbSurface->Unlock(dfbSurface);
+ } else {
+ dfbSurface->Clear(dfbSurface, color.red(), color.green(), color.blue(),
+ color.alpha());
}
}
@@ -274,14 +291,12 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
{
QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
const QImage *image = that->buffer();
- if (image) { // avoid deep copy
- const QImage transformed = image->transformed(transform, mode);
- that->unlockDirectFB();
- QDirectFBPixmapData *data = new QDirectFBPixmapData(pixelType());
- data->fromImage(transformed, Qt::AutoColor);
- return QPixmap(data);
- }
- return QPixmapData::transformed(transform, mode);
+ Q_ASSERT(image);
+ const QImage transformed = image->transformed(transform, mode);
+ that->unlockDirectFB();
+ QDirectFBPixmapData *data = new QDirectFBPixmapData(QPixmapData::PixmapType);
+ data->fromImage(transformed, Qt::AutoColor);
+ return QPixmap(data);
}
int w, h;
@@ -291,15 +306,23 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
if (size.isEmpty())
return QPixmap();
- QDirectFBPixmapData *data = new QDirectFBPixmapData(pixelType());
- data->resize(size.width(), size.height());
-
- IDirectFBSurface *dest = data->dfbSurface;
- dest->SetBlittingFlags(dest, DSBLIT_NOFX);
+ QDirectFBPixmapData *data = new QDirectFBPixmapData(QPixmapData::PixmapType);
+ DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
+ data->alpha = alpha;
+ if (alpha) {
+ flags = DSBLIT_BLEND_ALPHACHANNEL;
+ }
+ data->dfbSurface = screen->createDFBSurface(size,
+ format,
+ QDirectFBScreen::TrackSurface);
+ if (flags & DSBLIT_BLEND_ALPHACHANNEL) {
+ data->dfbSurface->Clear(data->dfbSurface, 0, 0, 0, 0);
+ }
+ data->dfbSurface->SetBlittingFlags(data->dfbSurface, flags);
- const DFBRectangle srcRect = { 0, 0, w, h };
const DFBRectangle destRect = { 0, 0, size.width(), size.height() };
- dest->StretchBlit(dest, dfbSurface, &srcRect, &destRect);
+ data->dfbSurface->StretchBlit(data->dfbSurface, dfbSurface, 0, &destRect);
+ data->dfbSurface->ReleaseSource(data->dfbSurface);
return QPixmap(data);
}
@@ -309,39 +332,25 @@ QImage QDirectFBPixmapData::toImage() const
if (!dfbSurface)
return QImage();
-#ifdef QT_NO_DIRECTFB_PREALLOCATED
- QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
- const QImage *img = that->buffer();
- const QImage copied = img->copy();
- that->unlockDirectFB();
- return copied;
-#else
-
- int w, h;
- dfbSurface->GetSize(dfbSurface, &w, &h);
-
- // Always convert to ARGB32:
- QImage image(w, h, QImage::Format_ARGB32);
-
- DFBSurfaceDescription description;
- description = QDirectFBScreen::getSurfaceDescription(image);
-
- IDirectFBSurface *imgSurface = screen->createDFBSurface(&description);
- if (!imgSurface) {
- qWarning("QDirectFBPixmapData::toImage()");
- return QImage();
- }
-
- imgSurface->SetBlittingFlags(imgSurface, DSBLIT_NOFX);
- DFBResult result = imgSurface->Blit(imgSurface, dfbSurface, 0, 0, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::toImage() blit failed", result);
- return QImage();
+#ifndef QT_NO_DIRECTFB_PREALLOCATED
+ QImage ret(size(), QDirectFBScreen::getImageFormat(dfbSurface));
+ if (IDirectFBSurface *imgSurface = screen->createDFBSurface(ret, QDirectFBScreen::DontTrackSurface)) {
+ if (hasAlphaChannel()) {
+ imgSurface->SetBlittingFlags(imgSurface, DSBLIT_BLEND_ALPHACHANNEL);
+ imgSurface->Clear(imgSurface, 0, 0, 0, 0);
+ } else {
+ imgSurface->SetBlittingFlags(imgSurface, DSBLIT_NOFX);
+ }
+ imgSurface->Blit(imgSurface, dfbSurface, 0, 0, 0);
+ imgSurface->ReleaseSource(imgSurface);
+ imgSurface->Release(imgSurface);
+ return ret;
}
- screen->releaseDFBSurface(imgSurface);
+#endif
- return image;
-#endif // QT_NO_DIRECTFB_PREALLOCATED
+ QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
+ const QImage *img = that->buffer();
+ return img->copy();
}
QPaintEngine* QDirectFBPixmapData::paintEngine() const
@@ -361,3 +370,10 @@ QImage* QDirectFBPixmapData::buffer()
lockDirectFB();
return lockedImage;
}
+
+void QDirectFBPixmapData::invalidate()
+{
+ setSerialNumber(0);
+ alpha = false;
+ format = QImage::Format_Invalid;
+}
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
index 32676f8..6cfafcd 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
@@ -64,7 +64,7 @@ public:
void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
void copy(const QPixmapData *data, const QRect &rect);
void fill(const QColor &color);
- bool hasAlphaChannel() const;
+ inline bool hasAlphaChannel() const { return alpha; }
QPixmap transformed(const QTransform &matrix,
Qt::TransformationMode mode) const;
QImage toImage() const;
@@ -73,9 +73,12 @@ public:
// Pure virtual in QPixmapData, so re-implement here and delegate to QDirectFBPaintDevice
int metric(QPaintDevice::PaintDeviceMetric m) const {return QDirectFBPaintDevice::metric(m);}
-
+ inline QImage::Format pixelFormat() const { return format; }
private:
+ void invalidate();
QDirectFBPaintEngine *engine;
+ QImage::Format format;
+ bool alpha;
};
QT_END_HEADER
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index 26c023f..041d522 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -81,10 +81,11 @@ public:
QDirectFBKeyboardHandler *keyboard;
#endif
bool videoonly;
+ QImage::Format alphaPixmapFormat;
};
QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen* screen)
- : QWSGraphicsSystem(screen), dfb(0), dfbSurface(0), flipFlags(DSFLIP_BLIT)
+ : QWSGraphicsSystem(screen), dfb(0), dfbSurface(0), flipFlags(DSFLIP_NONE)
#ifndef QT_NO_DIRECTFB_LAYER
, dfbLayer(0)
#endif
@@ -96,6 +97,7 @@ QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen* screen)
, keyboard(0)
#endif
, videoonly(false)
+ , alphaPixmapFormat(QImage::Format_Invalid)
{
#ifndef QT_NO_QWS_SIGNALHANDLER
QWSSignalHandler::instance()->addObject(this);
@@ -130,7 +132,88 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate()
dfb->Release(dfb);
}
-IDirectFBSurface* QDirectFBScreen::createDFBSurface(const DFBSurfaceDescription* desc, bool track)
+
+
+// creates a preallocated surface with the same format as the image if
+// possible.
+
+IDirectFBSurface* QDirectFBScreen::createDFBSurface(const QImage &img, SurfaceCreationOptions options)
+{
+ if (img.isNull()) // assert?
+ return 0;
+ if (QDirectFBScreen::getSurfacePixelFormat(img.format()) == DSPF_UNKNOWN) {
+ QImage image = img.convertToFormat(img.hasAlphaChannel()
+ ? d_ptr->alphaPixmapFormat
+ : pixelFormat());
+ IDirectFBSurface *tmp = createDFBSurface(image, false);
+ if (!tmp) {
+ qWarning("Couldn't create surface createDFBSurface(QImage, bool)");
+ return 0;
+ }
+ IDirectFBSurface *surface = copyDFBSurface(tmp, image.format(), options);
+ tmp->Release(tmp);
+ return surface;
+ }
+
+ DFBSurfaceDescription desc = QDirectFBScreen::getSurfaceDescription(img);
+ IDirectFBSurface *surface = createDFBSurface(&desc, options);
+#ifdef QT_NO_DIRECTFB_PREALLOCATED
+ if (surface) {
+ char *mem;
+ int bpl;
+ surface->Lock(surface, DSLF_WRITE, (void**)&mem, &bpl);
+ const int h = img.height();
+ for (int i = 0; i < h; ++i) {
+ memcpy(mem, img.scanLine(i), bpl);
+ mem += bpl;
+ }
+ surface->Unlock(surface);
+ }
+#endif
+#ifndef QT_NO_DIRECTFB_PALETTE
+ if (img.numColors() != 0 && surface)
+ QDirectFBScreen::setSurfaceColorTable(surface, img);
+#endif
+ return surface;
+}
+
+IDirectFBSurface *QDirectFBScreen::copyDFBSurface(IDirectFBSurface *src,
+ QImage::Format format,
+ SurfaceCreationOptions options)
+{
+ Q_ASSERT(src);
+ QSize size;
+ src->GetSize(src, &size.rwidth(), &size.rheight());
+ IDirectFBSurface *surface = createDFBSurface(size, format, options);
+ DFBSurfacePixelFormat dspf;
+ src->GetPixelFormat(src, &dspf);
+ DFBSurfaceBlittingFlags flags = QDirectFBScreen::hasAlpha(dspf)
+ ? DSBLIT_BLEND_ALPHACHANNEL
+ : DSBLIT_NOFX;
+ if (flags & DSBLIT_BLEND_ALPHACHANNEL)
+ surface->Clear(surface, 0, 0, 0, 0);
+
+ surface->SetBlittingFlags(surface, flags);
+ surface->Blit(surface, src, 0, 0, 0);
+ surface->ReleaseSource(surface);
+ return surface;
+}
+
+IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QSize &size,
+ QImage::Format format,
+ SurfaceCreationOptions options)
+{
+ DFBSurfaceDescription desc;
+ desc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH|DSDESC_HEIGHT);
+ if (!QDirectFBScreen::initSurfaceDescriptionPixelFormat(&desc, format))
+ return 0;
+ desc.width = size.width();
+ desc.height = size.height();
+ return createDFBSurface(&desc, options);
+}
+
+
+IDirectFBSurface* QDirectFBScreen::createDFBSurface(const DFBSurfaceDescription *desc, SurfaceCreationOptions options)
{
DFBResult result;
IDirectFBSurface* newSurface = 0;
@@ -143,22 +226,43 @@ IDirectFBSurface* QDirectFBScreen::createDFBSurface(const DFBSurfaceDescription*
if (d_ptr->videoonly && !(desc->flags & DSDESC_PREALLOCATED)) {
// Add the video only capability. This means the surface will be created in video ram
DFBSurfaceDescription voDesc = *desc;
- voDesc.caps = DFBSurfaceCapabilities(voDesc.caps | DSCAPS_VIDEOONLY);
- voDesc.flags = DFBSurfaceDescriptionFlags(voDesc.flags | DSDESC_CAPS);
+ if (!(voDesc.flags & DSDESC_CAPS)) {
+ voDesc.caps = DSCAPS_VIDEOONLY;
+ voDesc.flags = DFBSurfaceDescriptionFlags(voDesc.flags | DSDESC_CAPS);
+ } else {
+ voDesc.caps = DFBSurfaceCapabilities(voDesc.caps | DSCAPS_VIDEOONLY);
+ }
result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &voDesc, &newSurface);
+ if (result != DFB_OK
+#ifdef QT_NO_DEBUG
+ && (desc->flags & DSDESC_CAPS) && (desc->caps & DSCAPS_PRIMARY)
+#endif
+ ) {
+ qWarning("QDirectFBScreen::createDFBSurface() Failed to create surface in video memory!\n"
+ " Flags %0x Caps %0x width %d height %d pixelformat %0x %d preallocated %p %d\n%s",
+ desc->flags, desc->caps, desc->width, desc->height,
+ desc->pixelformat, DFB_PIXELFORMAT_INDEX(desc->pixelformat),
+ desc->preallocated[0].data, desc->preallocated[0].pitch,
+ DirectFBErrorString(result));
+ }
}
if (!newSurface)
result = d_ptr->dfb->CreateSurface(d_ptr->dfb, desc, &newSurface);
if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::createDFBSurface", result);
+ qWarning("QDirectFBScreen::createDFBSurface() Failed!\n"
+ " Flags %0x Caps %0x width %d height %d pixelformat %0x %d preallocated %p %d\n%s",
+ desc->flags, desc->caps, desc->width, desc->height,
+ desc->pixelformat, DFB_PIXELFORMAT_INDEX(desc->pixelformat),
+ desc->preallocated[0].data, desc->preallocated[0].pitch,
+ DirectFBErrorString(result));
return 0;
}
Q_ASSERT(newSurface);
- if (track) {
+ if (options & TrackSurface) {
d_ptr->allocatedSurfaces.insert(newSurface);
//qDebug("Created a new DirectFB surface at %p. New count = %d",
@@ -168,8 +272,67 @@ IDirectFBSurface* QDirectFBScreen::createDFBSurface(const DFBSurfaceDescription*
return newSurface;
}
-void QDirectFBScreen::releaseDFBSurface(IDirectFBSurface* surface)
+IDirectFBSurface *QDirectFBScreen::copyToDFBSurface(const QImage &img,
+ QImage::Format pixmapFormat,
+ SurfaceCreationOptions options)
+{
+ QImage image = img;
+ if (QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN
+#ifdef QT_NO_DIRECTFB_PREALLOCATED
+ || image.format() != pixmapFormat
+#endif
+#ifdef QT_NO_DIRECTFB_PALETTE
+ || image.numColors() != 0
+#endif
+ ) {
+ image = image.convertToFormat(pixmapFormat);
+ }
+
+ IDirectFBSurface *dfbSurface = createDFBSurface(image.size(), pixmapFormat, options);
+ if (!dfbSurface) {
+ qWarning("QDirectFBPixmapData::fromImage() Couldn't create surface");
+ return 0;
+ }
+
+#ifndef QT_NO_DIRECTFB_PREALLOCATED
+ IDirectFBSurface *imgSurface = createDFBSurface(image, DontTrackSurface);
+ if (!imgSurface) {
+ qWarning("QDirectFBPixmapData::fromImage()");
+ QDirectFBScreen::releaseDFBSurface(dfbSurface);
+ return 0;
+ }
+
+ Q_ASSERT(imgSurface);
+ DFBSurfaceBlittingFlags flags = img.hasAlphaChannel()
+ ? DSBLIT_BLEND_ALPHACHANNEL
+ : DSBLIT_NOFX;
+ if (flags & DSBLIT_BLEND_ALPHACHANNEL)
+ dfbSurface->Clear(dfbSurface, 0, 0, 0, 0);
+
+ dfbSurface->SetBlittingFlags(dfbSurface, flags);
+ DFBResult result = dfbSurface->Blit(dfbSurface, imgSurface, 0, 0, 0);
+ if (result != DFB_OK)
+ DirectFBError("QDirectFBPixmapData::fromImage()", result);
+ dfbSurface->ReleaseSource(dfbSurface);
+ imgSurface->Release(imgSurface);
+#else // QT_NO_DIRECTFB_PREALLOCATED
+ Q_ASSERT(image.format() == pixmapFormat);
+ char *mem;
+ int bpl;
+ dfbSurface->Lock(dfbSurface, DSLF_WRITE, (void**)&mem, &bpl);
+ const int w = image.width() * image.depth() / 8;
+ for (int i = 0; i < image.height(); ++i) {
+ memcpy(mem, image.scanLine(i), w);
+ mem += bpl;
+ }
+ dfbSurface->Unlock(dfbSurface);
+#endif
+ return dfbSurface;
+}
+
+void QDirectFBScreen::releaseDFBSurface(IDirectFBSurface *surface)
{
+ Q_ASSERT(QDirectFBScreen::instance());
Q_ASSERT(surface);
surface->Release(surface);
if (!d_ptr->allocatedSurfaces.remove(surface))
@@ -200,9 +363,9 @@ IDirectFBDisplayLayer* QDirectFBScreen::dfbDisplayLayer()
}
#endif
-DFBSurfacePixelFormat QDirectFBScreen::getSurfacePixelFormat(const QImage &image)
+DFBSurfacePixelFormat QDirectFBScreen::getSurfacePixelFormat(QImage::Format format)
{
- switch (image.format()) {
+ switch (format) {
#ifndef QT_NO_DIRECTFB_PALETTE
case QImage::Format_Indexed8:
return DSPF_LUT8;
@@ -233,8 +396,11 @@ DFBSurfacePixelFormat QDirectFBScreen::getSurfacePixelFormat(const QImage &image
};
}
-QImage::Format QDirectFBScreen::getImageFormat(DFBSurfacePixelFormat format)
+QImage::Format QDirectFBScreen::getImageFormat(IDirectFBSurface *surface)
{
+ DFBSurfacePixelFormat format;
+ surface->GetPixelFormat(surface, &format);
+
switch (format) {
case DSPF_LUT8:
return QImage::Format_Indexed8;
@@ -257,8 +423,14 @@ QImage::Format QDirectFBScreen::getImageFormat(DFBSurfacePixelFormat format)
return QImage::Format_RGB666;
case DSPF_RGB32:
return QImage::Format_RGB32;
- case DSPF_ARGB:
- return QImage::Format_ARGB32_Premultiplied;
+ case DSPF_ARGB: {
+ DFBSurfaceCapabilities caps;
+ const DFBResult result = surface->GetCapabilities(surface, &caps);
+ Q_ASSERT(result == DFB_OK);
+ Q_UNUSED(result);
+ return (caps & DSCAPS_PREMULTIPLIED
+ ? QImage::Format_ARGB32_Premultiplied
+ : QImage::Format_ARGB32); }
default:
break;
}
@@ -268,38 +440,32 @@ QImage::Format QDirectFBScreen::getImageFormat(DFBSurfacePixelFormat format)
DFBSurfaceDescription QDirectFBScreen::getSurfaceDescription(const QImage &image)
{
DFBSurfaceDescription description;
- DFBSurfacePixelFormat format = getSurfacePixelFormat(image);
+
+ const DFBSurfacePixelFormat format = getSurfacePixelFormat(image.format());
if (format == DSPF_UNKNOWN || image.isNull()) {
description.flags = DFBSurfaceDescriptionFlags(0);
return description;
}
- description.flags = DFBSurfaceDescriptionFlags(DSDESC_CAPS
- | DSDESC_WIDTH
+ description.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH
| DSDESC_HEIGHT
- | DSDESC_PIXELFORMAT
- | DSDESC_PREALLOCATED);
-
- description.caps = DSCAPS_NONE;
+#ifndef QT_NO_DIRECTFB_PREALLOCATED
+ | DSDESC_PREALLOCATED
+#endif
+ | DSDESC_PIXELFORMAT);
+ QDirectFBScreen::initSurfaceDescriptionPixelFormat(&description, image.format());
description.width = image.width();
description.height = image.height();
- description.pixelformat = format;
+#ifndef QT_NO_DIRECTFB_PREALLOCATED
description.preallocated[0].data = (void*)(image.bits());
description.preallocated[0].pitch = image.bytesPerLine();
description.preallocated[1].data = 0;
description.preallocated[1].pitch = 0;
+#endif
- switch (image.format()) {
- case QImage::Format_ARGB32_Premultiplied:
- case QImage::Format_ARGB8565_Premultiplied:
- case QImage::Format_ARGB6666_Premultiplied:
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_ARGB4444_Premultiplied:
+ if (QDirectFBScreen::isPremultiplied(image.format()))
description.caps = DSCAPS_PREMULTIPLIED;
- default:
- break;
- }
return description;
}
@@ -337,7 +503,7 @@ void QDirectFBScreen::setSurfaceColorTable(IDirectFBSurface *surface,
if (numColors == 0)
return;
- QVarLengthArray<DFBColor> colors(numColors);
+ QVarLengthArray<DFBColor, 256> colors(numColors);
for (int i = 0; i < numColors; ++i) {
QRgb c = image.color(i);
colors[i].a = qAlpha(c);
@@ -461,18 +627,10 @@ void QDirectFBScreenCursor::set(const QImage &image, int hotx, int hoty)
} else if (!image.isNull() && implicitHide) {
show();
}
+ cursor = image.convertToFormat(QDirectFBScreen::instance()->alphaPixmapFormat());
if (!image.isNull()) {
-#ifdef QT_NO_DIRECTFB_PALETTE
- if (image.numColors() > 0)
- cursor = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- else
-#endif
- if (image.format() == QImage::Format_Indexed8) {
- cursor = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- } else {
- cursor = image;
- }
+ Q_ASSERT(cursor.numColors() == 0);
size = cursor.size();
hotspot = QPoint(hotx, hoty);
@@ -480,15 +638,12 @@ void QDirectFBScreenCursor::set(const QImage &image, int hotx, int hoty)
description = QDirectFBScreen::getSurfaceDescription(cursor);
IDirectFBSurface *surface;
- surface = QDirectFBScreen::instance()->createDFBSurface(&description);
+ surface = QDirectFBScreen::instance()->createDFBSurface(&description,
+ QDirectFBScreen::TrackSurface);
if (!surface) {
qWarning("QDirectFBScreenCursor::set: Unable to create surface");
return;
}
-#ifndef QT_NO_DIRECTFB_PALETTE
- QDirectFBScreen::setSurfaceColorTable(surface, cursor);
-#endif
-
DFBResult result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
if (result != DFB_OK) {
DirectFBError("QDirectFBScreenCursor::set: "
@@ -567,7 +722,7 @@ int QDirectFBScreen::depth(DFBSurfacePixelFormat format)
void QDirectFBScreenPrivate::setFlipFlags(const QStringList &args)
{
- QRegExp flipRegexp(QLatin1String("^flip=([\\w,]+)$"));
+ QRegExp flipRegexp(QLatin1String("^flip=([\\w,]*)$"));
int index = args.indexOf(flipRegexp);
if (index >= 0) {
const QStringList flips = flipRegexp.cap(1).split(QLatin1Char(','),
@@ -586,6 +741,8 @@ void QDirectFBScreenPrivate::setFlipFlags(const QStringList &args)
qWarning("QDirectFBScreen: Unknown flip argument: %s",
qPrintable(flip));
}
+ } else {
+ flipFlags = DFBSurfaceFlipFlags(DSFLIP_BLIT);
}
}
@@ -615,6 +772,18 @@ static void printDirectFBInfo(IDirectFB *fb)
dev.blitting_flags, dev.drawing_flags, dev.video_memory);
}
+static inline bool setIntOption(const QStringList &arguments, const QString &variable, int *value)
+{
+ Q_ASSERT(value);
+ QRegExp rx(QString("%1=?(\\d+)").arg(variable));
+ rx.setCaseSensitivity(Qt::CaseInsensitive);
+ if (arguments.indexOf(rx) != -1) {
+ *value = rx.cap(1).toInt();
+ return true;
+ }
+ return false;
+}
+
bool QDirectFBScreen::connect(const QString &displaySpec)
{
DFBResult result = DFB_OK;
@@ -636,7 +805,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
}
const QStringList displayArgs = displaySpec.split(QLatin1Char(':'),
- QString::SkipEmptyParts);
+ QString::SkipEmptyParts);
d_ptr->setFlipFlags(displayArgs);
@@ -660,23 +829,57 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
DFBSurfaceDescription description;
description.flags = DFBSurfaceDescriptionFlags(DSDESC_CAPS);
+ if (::setIntOption(displayArgs, QLatin1String("width"), &description.width))
+ description.flags = DFBSurfaceDescriptionFlags(description.flags | DSDESC_WIDTH);
+ if (::setIntOption(displayArgs, QLatin1String("height"), &description.height))
+ description.flags = DFBSurfaceDescriptionFlags(description.flags | DSDESC_HEIGHT);
description.caps = DFBSurfaceCapabilities(DSCAPS_PRIMARY
| DSCAPS_DOUBLE
| DSCAPS_STATIC_ALLOC);
- if (!(d_ptr->flipFlags & DSFLIP_BLIT)) {
+ if (displayArgs.contains(QLatin1String("forcepremultiplied"),
+ Qt::CaseInsensitive)) {
description.caps = DFBSurfaceCapabilities(description.caps
- | DSCAPS_DOUBLE
- | DSCAPS_TRIPLE);
+ | DSCAPS_PREMULTIPLIED);
}
-
// We don't track the primary surface as it's released in disconnect
- d_ptr->dfbSurface = createDFBSurface(&description, false);
+ d_ptr->dfbSurface = createDFBSurface(&description, DontTrackSurface);
if (!d_ptr->dfbSurface) {
DirectFBError("QDirectFBScreen: error creating primary surface",
result);
return false;
}
+
+ // Work out what format we're going to use for surfaces with an alpha channel
+ d_ptr->alphaPixmapFormat = QDirectFBScreen::getImageFormat(d_ptr->dfbSurface);
+ setPixelFormat(d_ptr->alphaPixmapFormat);
+ switch (d_ptr->alphaPixmapFormat) {
+ case QImage::Format_RGB666:
+ d_ptr->alphaPixmapFormat = QImage::Format_ARGB6666_Premultiplied;
+ break;
+ case QImage::Format_RGB444:
+ d_ptr->alphaPixmapFormat = QImage::Format_ARGB4444_Premultiplied;
+ break;
+ case QImage::NImageFormats:
+ case QImage::Format_Invalid:
+ case QImage::Format_Mono:
+ case QImage::Format_MonoLSB:
+ case QImage::Format_Indexed8:
+ case QImage::Format_RGB32:
+ case QImage::Format_RGB888:
+ case QImage::Format_RGB16:
+ case QImage::Format_RGB555:
+ d_ptr->alphaPixmapFormat = QImage::Format_ARGB32_Premultiplied;
+ break;
+ case QImage::Format_ARGB32:
+ case QImage::Format_ARGB32_Premultiplied:
+ case QImage::Format_ARGB4444_Premultiplied:
+ case QImage::Format_ARGB8555_Premultiplied:
+ case QImage::Format_ARGB8565_Premultiplied:
+ case QImage::Format_ARGB6666_Premultiplied:
+ // works already
+ break;
+ }
d_ptr->dfbSurface->GetSize(d_ptr->dfbSurface, &w, &h);
data = 0;
@@ -692,21 +895,11 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
else
DirectFBError("QDirectFBScreen: error getting surface format", result);
- setPixelFormat(getImageFormat(format));
+ setPixelFormat(getImageFormat(d_ptr->dfbSurface));
physWidth = physHeight = -1;
- QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)"));
- int dimIdxW = displayArgs.indexOf(mmWidthRx);
- if (dimIdxW >= 0) {
- mmWidthRx.exactMatch(displayArgs.at(dimIdxW));
- physWidth = mmWidthRx.cap(1).toInt();
- }
- QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)"));
- int dimIdxH = displayArgs.indexOf(mmHeightRx);
- if (dimIdxH >= 0) {
- mmHeightRx.exactMatch(displayArgs.at(dimIdxH));
- physHeight = mmHeightRx.cap(1).toInt();
- }
+ ::setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth);
+ ::setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight);
const int dpi = 72;
if (physWidth < 0)
physWidth = qRound(dw * 25.4 / dpi);
@@ -814,19 +1007,21 @@ void QDirectFBScreen::blank(bool on)
QWSWindowSurface* QDirectFBScreen::createSurface(QWidget *widget) const
{
#ifdef QT_NO_DIRECTFB_WM
- if (QApplication::type() == QApplication::GuiServer)
- return new QDirectFBSurface(const_cast<QDirectFBScreen*>(this), widget);
- else
+ if (QApplication::type() == QApplication::GuiServer) {
+ return new QDirectFBSurface(d_ptr->flipFlags, const_cast<QDirectFBScreen*>(this), widget);
+ } else {
return QScreen::createSurface(widget);
+ }
#else
- return new QDirectFBSurface(const_cast<QDirectFBScreen*>(this), widget);
+ return new QDirectFBSurface(d_ptr->flipFlags, const_cast<QDirectFBScreen*>(this), widget);
#endif
}
QWSWindowSurface* QDirectFBScreen::createSurface(const QString &key) const
{
- if (key == QLatin1String("directfb"))
- return new QDirectFBSurface(const_cast<QDirectFBScreen*>(this));
+ if (key == QLatin1String("directfb")) {
+ return new QDirectFBSurface(d_ptr->flipFlags, const_cast<QDirectFBScreen*>(this));
+ }
return QScreen::createSurface(key);
}
@@ -859,7 +1054,7 @@ void QDirectFBScreen::compose(const QRegion &region)
if (surface->key() == QLatin1String("directfb")) {
QDirectFBSurface *s = static_cast<QDirectFBSurface*>(surface);
- blit(s->directFbSurface(), offset, r);
+ blit(s->directFBSurface(), offset, r);
} else {
blit(surface->image(), offset, r);
}
@@ -908,11 +1103,12 @@ void QDirectFBScreen::compose(const QRegion &region)
if (surface->key() == QLatin1String("directfb")) {
QDirectFBSurface *s = static_cast<QDirectFBSurface*>(surface);
- blit(s->directFbSurface(), offset, r);
+ blit(s->directFBSurface(), offset, r);
} else {
blit(surface->image(), offset, r);
}
}
+ d_ptr->dfbSurface->ReleaseSource(d_ptr->dfbSurface);
}
// Normally, when using DirectFB to compose the windows (I.e. when
@@ -954,21 +1150,14 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing)
void QDirectFBScreen::blit(const QImage &img, const QPoint &topLeft,
const QRegion &reg)
{
- IDirectFBSurface *src = 0;
- DFBSurfaceDescription description = getSurfaceDescription(img);
-
- src = createDFBSurface(&description);
+ IDirectFBSurface *src = createDFBSurface(img, QDirectFBScreen::DontTrackSurface);
if (!src) {
qWarning("QDirectFBScreen::blit(): Error creating surface");
return;
}
-#ifndef QT_NO_DIRECTFB_PALETTE
- setSurfaceColorTable(d_ptr->dfbSurface, img);
-#endif
-
blit(src, topLeft, reg);
-
- releaseDFBSurface(src);
+ d_ptr->dfbSurface->ReleaseSource(d_ptr->dfbSurface);
+ src->Release(src);
}
void QDirectFBScreen::blit(IDirectFBSurface *src, const QPoint &topLeft,
@@ -1004,20 +1193,51 @@ void QDirectFBScreen::solidFill(const QColor &color, const QRegion &region)
if (region.isEmpty())
return;
- const QVector<QRect> rects = region.rects();
- QVarLengthArray<DFBRectangle> dfbRects(rects.size());
- for (int i = 0; i < rects.size(); ++i) {
- const QRect r = rects.at(i);
- dfbRects[i].x = r.x();
- dfbRects[i].y = r.y();
- dfbRects[i].w = r.width();
- dfbRects[i].h = r.height();
+ if (QDirectFBScreen::getImageFormat(d_ptr->dfbSurface) == QImage::Format_RGB32) {
+ uchar *mem;
+ int bpl;
+ d_ptr->dfbSurface->Lock(d_ptr->dfbSurface, DSLF_WRITE, (void**)&mem, &bpl);
+ QImage img(mem, w, h, bpl, QImage::Format_RGB32);
+ QPainter p(&img);
+ p.setBrush(color);
+ p.setPen(Qt::NoPen);
+ const QVector<QRect> rects = region.rects();
+ p.drawRects(rects.constData(), rects.size());
+ p.end();
+ d_ptr->dfbSurface->Unlock(d_ptr->dfbSurface);
+ } else {
+ d_ptr->dfbSurface->SetColor(d_ptr->dfbSurface,
+ color.red(), color.green(), color.blue(),
+ color.alpha());
+ const QVector<QRect> rects = region.rects();
+ for (int i=0; i<rects.size(); ++i) {
+ const QRect &r = rects.at(i);
+ d_ptr->dfbSurface->FillRectangle(d_ptr->dfbSurface,
+ r.x(), r.y(), r.width(), r.height());
+ }
}
+}
- d_ptr->dfbSurface->SetColor(d_ptr->dfbSurface,
- color.red(), color.green(), color.blue(),
- color.alpha());
- d_ptr->dfbSurface->FillRectangles(d_ptr->dfbSurface, dfbRects.data(),
- dfbRects.size());
+QImage::Format QDirectFBScreen::alphaPixmapFormat() const
+{
+ return d_ptr->alphaPixmapFormat;
}
+bool QDirectFBScreen::initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *description,
+ QImage::Format format)
+{
+ const DFBSurfacePixelFormat pixelformat = QDirectFBScreen::getSurfacePixelFormat(format);
+ if (pixelformat == DSPF_UNKNOWN)
+ return false;
+ description->flags = DFBSurfaceDescriptionFlags(description->flags | DSDESC_PIXELFORMAT);
+ description->pixelformat = pixelformat;
+ if (QDirectFBScreen::isPremultiplied(format)) {
+ if (!(description->flags & DSDESC_CAPS)) {
+ description->caps = DSCAPS_PREMULTIPLIED;
+ description->flags = DFBSurfaceDescriptionFlags(description->flags | DSDESC_CAPS);
+ } else {
+ description->caps = DFBSurfaceCapabilities(description->caps | DSCAPS_PREMULTIPLIED);
+ }
+ }
+ return true;
+}
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
index 35dea0d..f394ac1 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
@@ -88,18 +88,39 @@ public:
#endif
// Track surface creation/release so we can release all on exit
- IDirectFBSurface* createDFBSurface(const DFBSurfaceDescription* desc, bool track = true);
+ enum SurfaceCreationOption {
+ DontTrackSurface = 0,
+ TrackSurface = 1
+ };
+ Q_DECLARE_FLAGS(SurfaceCreationOptions, SurfaceCreationOption);
+ IDirectFBSurface *createDFBSurface(const DFBSurfaceDescription *desc,
+ SurfaceCreationOptions options);
+ IDirectFBSurface *createDFBSurface(const QImage &image,
+ SurfaceCreationOptions options);
+ IDirectFBSurface *createDFBSurface(const QSize &size,
+ QImage::Format format,
+ SurfaceCreationOptions options);
+ IDirectFBSurface *copyDFBSurface(IDirectFBSurface *src,
+ QImage::Format format,
+ SurfaceCreationOptions options);
+ IDirectFBSurface *copyToDFBSurface(const QImage &image,
+ QImage::Format format,
+ SurfaceCreationOptions options);
void releaseDFBSurface(IDirectFBSurface* surface);
+
bool preferVideoOnly() const;
static int depth(DFBSurfacePixelFormat format);
- static DFBSurfacePixelFormat getSurfacePixelFormat(const QImage &image);
+ static DFBSurfacePixelFormat getSurfacePixelFormat(QImage::Format format);
static DFBSurfaceDescription getSurfaceDescription(const QImage &image);
static DFBSurfaceDescription getSurfaceDescription(const uint *buffer,
int length);
- static QImage::Format getImageFormat(DFBSurfacePixelFormat format);
+ static QImage::Format getImageFormat(IDirectFBSurface *surface);
+ static bool initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *description, QImage::Format format);
static inline bool isPremultiplied(QImage::Format format);
+ static inline bool hasAlpha(DFBSurfacePixelFormat format);
+ QImage::Format alphaPixmapFormat() const;
#ifndef QT_NO_DIRECTFB_PALETTE
static void setSurfaceColorTable(IDirectFBSurface *surface,
@@ -114,6 +135,8 @@ private:
QDirectFBScreenPrivate *d_ptr;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::SurfaceCreationOptions);
+
inline bool QDirectFBScreen::isPremultiplied(QImage::Format format)
{
switch (format) {
@@ -129,6 +152,26 @@ inline bool QDirectFBScreen::isPremultiplied(QImage::Format format)
return false;
}
+inline bool QDirectFBScreen::hasAlpha(DFBSurfacePixelFormat format)
+{
+ switch (format) {
+ case DSPF_ARGB1555:
+ case DSPF_ARGB:
+ case DSPF_LUT8:
+ case DSPF_AiRGB:
+ case DSPF_A1:
+ case DSPF_ARGB2554:
+ case DSPF_ARGB4444:
+ case DSPF_AYUV:
+ case DSPF_A4:
+ case DSPF_ARGB1666:
+ case DSPF_ARGB6666:
+ case DSPF_LUT2:
+ return true;
+ default:
+ return false;
+ }
+}
QT_END_HEADER
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp
index ce026ea..8ed308c 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp
@@ -50,28 +50,38 @@
//#define QT_DIRECTFB_DEBUG_SURFACES 1
-QDirectFBSurface::QDirectFBSurface(QDirectFBScreen* scr)
+QDirectFBSurface::QDirectFBSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen* scr)
: QDirectFBPaintDevice(scr)
#ifndef QT_NO_DIRECTFB_WM
, dfbWindow(0)
#endif
, engine(0)
+ , flipFlags(flip)
{
setSurfaceFlags(Opaque | Buffered);
+#ifdef QT_DIRECTFB_TIMING
+ frames = 0;
+ timer.start();
+#endif
}
-QDirectFBSurface::QDirectFBSurface(QDirectFBScreen* scr, QWidget *widget)
+QDirectFBSurface::QDirectFBSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr, QWidget *widget)
: QWSWindowSurface(widget), QDirectFBPaintDevice(scr)
#ifndef QT_NO_DIRECTFB_WM
, dfbWindow(0)
#endif
, engine(0)
+ , flipFlags(flip)
{
onscreen = widget->testAttribute(Qt::WA_PaintOnScreen);
if (onscreen)
setSurfaceFlags(Opaque | RegionReserved);
else
setSurfaceFlags(Opaque | Buffered);
+#ifdef QT_DIRECTFB_TIMING
+ frames = 0;
+ timer.start();
+#endif
}
QDirectFBSurface::~QDirectFBSurface()
@@ -86,14 +96,26 @@ bool QDirectFBSurface::isValid() const
#ifndef QT_NO_DIRECTFB_WM
void QDirectFBSurface::createWindow()
{
+#ifdef QT_NO_DIRECTFB_LAYER
+#warning QT_NO_DIRECTFB_LAYER requires QT_NO_DIRECTFB_WM
+#else
IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer();
if (!layer)
qFatal("QDirectFBWindowSurface: Unable to get primary display layer!");
- DFBWindowDescription description;
- description.caps = DFBWindowCapabilities(DWCAPS_NODECORATION |
- DWCAPS_ALPHACHANNEL);
- description.flags = DWDESC_CAPS;
+ DFBWindowDescription description;
+ description.caps = DFBWindowCapabilities(DWCAPS_NODECORATION);
+ description.flags = DFBWindowDescriptionFlags(DWDESC_CAPS
+ |DWDESC_SURFACE_CAPS
+ |DWDESC_PIXELFORMAT);
+
+ description.surface_caps = DSCAPS_NONE;
+ if (screen->preferVideoOnly())
+ description.surface_caps = DFBSurfaceCapabilities(description.surface_caps|DSCAPS_VIDEOONLY);
+ const QImage::Format format = screen->pixelFormat();
+ description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(format);
+ if (QDirectFBScreen::isPremultiplied(format))
+ description.surface_caps = DFBSurfaceCapabilities(DSCAPS_PREMULTIPLIED|description.caps);
DFBResult result = layer->CreateWindow(layer, &description, &dfbWindow);
if (result != DFB_OK)
@@ -103,6 +125,8 @@ void QDirectFBSurface::createWindow()
dfbSurface->Release(dfbSurface);
dfbWindow->GetSurface(dfbWindow, &dfbSurface);
+ forceRaster = (format == QImage::Format_RGB32);
+#endif
}
#endif // QT_NO_DIRECTFB_WM
@@ -115,27 +139,32 @@ void QDirectFBSurface::setGeometry(const QRect &rect, const QRegion &mask)
dfbWindow = 0;
}
#endif
- if (dfbSurface) {
+ if (dfbSurface && dfbSurface != screen->dfbSurface()) {
dfbSurface->Release(dfbSurface);
dfbSurface = 0;
}
} else if (rect != geometry()) {
- const bool isResize = rect.size() != geometry().size();
DFBResult result = DFB_OK;
// If we're in a resize, the surface shouldn't be locked
- Q_ASSERT( (lockedImage == 0) || (isResize == false));
+ Q_ASSERT((lockedImage == 0) || (rect.size() == geometry().size()));
if (onscreen) {
- if (dfbSurface)
- dfbSurface->Release(dfbSurface);
-
- DFBRectangle r = { rect.x(), rect.y(),
- rect.width(), rect.height() };
IDirectFBSurface *primarySurface = screen->dfbSurface();
Q_ASSERT(primarySurface);
- result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface);
+ if (dfbSurface && dfbSurface != primarySurface)
+ dfbSurface->Release(dfbSurface);
+
+ if (rect == screen->region().boundingRect()) {
+ dfbSurface = primarySurface;
+ } else {
+ const DFBRectangle r = { rect.x(), rect.y(),
+ rect.width(), rect.height() };
+ result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface);
+ }
+ forceRaster = (dfbSurface && QDirectFBScreen::getImageFormat(dfbSurface) == QImage::Format_RGB32);
} else {
+ const bool isResize = rect.size() != geometry().size();
#ifdef QT_NO_DIRECTFB_WM
if (isResize) {
if (dfbSurface)
@@ -153,9 +182,10 @@ void QDirectFBSurface::setGeometry(const QRect &rect, const QRegion &mask)
DSDESC_PIXELFORMAT);
description.width = rect.width();
description.height = rect.height();
- description.pixelformat = DSPF_ARGB;
-
- dfbSurface = QDirectFBScreen::instance()->createDFBSurface(&description, false);
+ QDirectFBScreen::initSurfaceDescriptionPixelFormat(&description,
+ screen->pixelFormat());
+ dfbSurface = screen->createDFBSurface(&description, false);
+ forceRaster = (dfbSurface && QDirectFBScreen::getImageFormat(dfbSurface) == QImage::Format_RGB32);
} else {
Q_ASSERT(dfbSurface);
}
@@ -220,7 +250,7 @@ void QDirectFBSurface::setPermanentState(const QByteArray &state)
bool QDirectFBSurface::scroll(const QRegion &region, int dx, int dy)
{
- if (!dfbSurface)
+ if (!dfbSurface || !(flipFlags & DSFLIP_BLIT))
return false;
const QVector<QRect> rects = region.rects();
@@ -242,7 +272,7 @@ bool QDirectFBSurface::scroll(const QRegion &region, int dx, int dy)
dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
dfbSurface->BatchBlit(dfbSurface, dfbSurface,
dfbRects.data(), dfbPoints.data(), n);
-
+ dfbSurface->ReleaseSource(dfbSurface);
return true;
}
@@ -307,10 +337,15 @@ inline bool isWidgetOpaque(const QWidget *w)
return false;
}
-
void QDirectFBSurface::flush(QWidget *widget, const QRegion &region,
const QPoint &offset)
{
+ Q_UNUSED(widget);
+#ifdef QT_NO_DIRECTFB_WM
+ Q_UNUSED(region);
+ Q_UNUSED(offset);
+#endif
+
QWidget *win = window();
// hw: make sure opacity information is updated before compositing
@@ -331,28 +366,40 @@ void QDirectFBSurface::flush(QWidget *widget, const QRegion &region,
if (winOpacity != opacity)
dfbWindow->SetOpacity(dfbWindow, winOpacity);
}
-#endif
-
- // XXX: have to call the base function first as the decoration is
- // currently painted there
- QWSWindowSurface::flush(widget, region, offset);
-
-#ifndef QT_NO_DIRECTFB_WM
- if (region.numRects() > 1) {
- const QVector<QRect> rects = region.rects();
- for (int i=0; i<rects.size(); ++i) {
- const QRect &r = rects.at(i);
+ if (!(flipFlags & DSFLIP_BLIT)) {
+ dfbSurface->Flip(dfbSurface, 0, flipFlags);
+ } else {
+ if (region.numRects() > 1) {
+ const QVector<QRect> rects = region.rects();
+ DFBSurfaceFlipFlags tmpFlags = flipFlags;
+ if (flipFlags & DSFLIP_WAIT)
+ tmpFlags = DFBSurfaceFlipFlags(flipFlags & ~DSFLIP_WAIT);
+ for (int i=0; i<rects.size(); ++i) {
+ const QRect &r = rects.at(i);
+ const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(),
+ r.x() + r.width() + offset.x(),
+ r.y() + r.height() + offset.y() };
+ dfbSurface->Flip(dfbSurface, &dfbReg,
+ i + 1 < rects.size()
+ ? tmpFlags
+ : flipFlags);
+ }
+ } else {
+ const QRect r = region.boundingRect();
const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(),
r.x() + r.width() + offset.x(),
r.y() + r.height() + offset.y() };
- dfbSurface->Flip(dfbSurface, &dfbReg, DSFLIP_ONSYNC);
+ dfbSurface->Flip(dfbSurface, &dfbReg, flipFlags);
}
- } else {
- const QRect r = region.boundingRect();
- const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(),
- r.x() + r.width() + offset.x(),
- r.y() + r.height() + offset.y() };
- dfbSurface->Flip(dfbSurface, &dfbReg, DSFLIP_ONSYNC);
+ }
+#endif
+#ifdef QT_DIRECTFB_TIMING
+ enum { Secs = 3 };
+ ++frames;
+ if (timer.elapsed() >= Secs * 1000) {
+ qDebug("%d fps", int(double(frames) / double(Secs)));
+ frames = 0;
+ timer.restart();
}
#endif
}
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h
index a9cdb7d..ab4145d 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h
@@ -50,6 +50,10 @@
#include <private/qwindowsurface_qws_p.h>
#include <directfb.h>
+#ifdef QT_DIRECTFB_TIMING
+#include <qdatetime.h>
+#endif
+
QT_BEGIN_HEADER
QT_MODULE(Gui)
@@ -57,8 +61,8 @@ QT_MODULE(Gui)
class QDirectFBSurface: public QWSWindowSurface, public QDirectFBPaintDevice
{
public:
- QDirectFBSurface(QDirectFBScreen* scr);
- QDirectFBSurface(QDirectFBScreen* scr, QWidget *widget);
+ QDirectFBSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen* scr);
+ QDirectFBSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen* scr, QWidget *widget);
~QDirectFBSurface();
bool isValid() const;
@@ -95,6 +99,11 @@ private:
bool onscreen;
QList<QImage*> bufferImages;
+ DFBSurfaceFlipFlags flipFlags;
+#ifdef QT_DIRECTFB_TIMING
+ int frames;
+ QTime timer;
+#endif
};
QT_END_HEADER
diff --git a/src/plugins/gfxdrivers/powervr/README b/src/plugins/gfxdrivers/powervr/README
index b830066..ec02efb 100644
--- a/src/plugins/gfxdrivers/powervr/README
+++ b/src/plugins/gfxdrivers/powervr/README
@@ -8,6 +8,9 @@ is built as two libraries: The actual QScreen plugin used by Qt (in the
pvreglscreen directory) and a WSEGL plugin for the PowerVR drivers (in the
QWSWSEGL directory).
+Qt/Embedded needs to be configured with the QT_QWS_CLIENTBLIT and
+QT_NO_QWS_CURSOR defines.
+
The PowerVR drivers provide the WSEGL plugin API to allow window systems such as
QWS to integrate correctly. In order to use the integration, the WSEGL plugin
(libpvrQWSWSEGL.so, usually installed into the Qt library directory) must be in
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp
index 3a94851..b0ffbf1 100644
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp
+++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp
@@ -381,7 +381,7 @@ void PvrEglSurfaceHolder::removeSurface()
// create the temporary surface again.
if (surface == EGL_NO_SURFACE && dpy != EGL_NO_DISPLAY) {
surface = eglCreateWindowSurface
- (dpy, config, (EGLNativeWindowType)tempSurface, NULL);
+ (dpy, config, (EGLNativeWindowType)(-1), NULL);
if (surface == EGL_NO_SURFACE)
qWarning("Could not re-create the temporary EGL surface");
}
diff --git a/src/plugins/kbddrivers/kbddrivers.pro b/src/plugins/kbddrivers/kbddrivers.pro
index 6605972..a34b780 100644
--- a/src/plugins/kbddrivers/kbddrivers.pro
+++ b/src/plugins/kbddrivers/kbddrivers.pro
@@ -1,6 +1,5 @@
TEMPLATE = subdirs
-contains(kbd-plugins, usb): SUBDIRS += usb
+contains(kbd-plugins, linuxinput): SUBDIRS += linuxinput
contains(kbd-plugins, sl5000): SUBDIRS += sl5000
contains(kbd-plugins, vr41xx): SUBDIRS += vr41xx
contains(kbd-plugins, yopy): SUBDIRS += yopy
-contains(kbd-plugins, linuxis): SUBDIRS += linuxis
diff --git a/src/plugins/kbddrivers/linuxinput/linuxinput.pro b/src/plugins/kbddrivers/linuxinput/linuxinput.pro
new file mode 100644
index 0000000..862a220
--- /dev/null
+++ b/src/plugins/kbddrivers/linuxinput/linuxinput.pro
@@ -0,0 +1,14 @@
+TARGET = qlinuxinputkbddriver
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers
+target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers
+INSTALLS += target
+
+DEFINES += QT_QWS_KBD_LINUXINPUT
+
+HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdlinuxinput_qws.h
+
+SOURCES = main.cpp \
+ $$QT_SOURCE_TREE/src/gui/embedded/qkbdlinuxinput_qws.cpp
+
diff --git a/src/plugins/kbddrivers/usb/main.cpp b/src/plugins/kbddrivers/linuxinput/main.cpp
index 1d6ab89..45d06c4 100644
--- a/src/plugins/kbddrivers/usb/main.cpp
+++ b/src/plugins/kbddrivers/linuxinput/main.cpp
@@ -40,38 +40,38 @@
****************************************************************************/
#include <qkbddriverplugin_qws.h>
-#include <qkbdusb_qws.h>
+#include <qkbdlinuxinput_qws.h>
QT_BEGIN_NAMESPACE
-class QUsbKbdDriver : public QKbdDriverPlugin
+class QLinuxInputKbdDriver : public QKbdDriverPlugin
{
public:
- QUsbKbdDriver();
+ QLinuxInputKbdDriver();
QStringList keys() const;
QWSKeyboardHandler* create(const QString &driver, const QString &device);
};
-QUsbKbdDriver::QUsbKbdDriver()
+QLinuxInputKbdDriver::QLinuxInputKbdDriver()
: QKbdDriverPlugin()
{
}
-QStringList QUsbKbdDriver::keys() const
+QStringList QLinuxInputKbdDriver::keys() const
{
- return (QStringList() << QLatin1String("Usb"));
+ return (QStringList() << QLatin1String("LinuxInput"));
}
-QWSKeyboardHandler* QUsbKbdDriver::create(const QString &driver,
- const QString &device)
+QWSKeyboardHandler* QLinuxInputKbdDriver::create(const QString &driver,
+ const QString &device)
{
Q_UNUSED(device);
- if (driver.compare(QLatin1String("Usb"), Qt::CaseInsensitive))
+ if (driver.compare(QLatin1String("LinuxInput"), Qt::CaseInsensitive))
return 0;
- return new QWSUsbKeyboardHandler(driver);
+ return new QWSLinuxInputKeyboardHandler(driver, device);
}
-Q_EXPORT_PLUGIN2(qwsusbkbddriver, QUsbKbdDriver)
+Q_EXPORT_PLUGIN2(qwslinuxinputkbddriver, QLinuxInputKbdDriver)
QT_END_NAMESPACE
diff --git a/src/plugins/kbddrivers/linuxis/README b/src/plugins/kbddrivers/linuxis/README
deleted file mode 100644
index 37a9a89..0000000
--- a/src/plugins/kbddrivers/linuxis/README
+++ /dev/null
@@ -1 +0,0 @@
-This is a keypad/only keyboard driver based on the Linux input subsystem.
diff --git a/src/plugins/kbddrivers/linuxis/linuxis.pro b/src/plugins/kbddrivers/linuxis/linuxis.pro
deleted file mode 100644
index 5e652b5..0000000
--- a/src/plugins/kbddrivers/linuxis/linuxis.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TARGET = linuxiskbdhandler
-include(../../qpluginbase.pri)
-
-QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers
-target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers
-INSTALLS += target
-
-CONFIG+=no_tr
-
-HEADERS = linuxiskbddriverplugin.h linuxiskbdhandler.h
-SOURCES = linuxiskbddriverplugin.cpp linuxiskbdhandler.cpp
diff --git a/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.cpp b/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.cpp
deleted file mode 100644
index 79cd298..0000000
--- a/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "linuxiskbddriverplugin.h"
-#include "linuxiskbdhandler.h"
-
-#include <qdebug.h>
-#if 1
-#define qLog(x) qDebug()
-#else
-#define qLog(x) while (0) qDebug()
-#endif
-
-LinuxInputSubsystemKbdDriverPlugin::LinuxInputSubsystemKbdDriverPlugin( QObject *parent )
- : QKbdDriverPlugin( parent )
-{
-}
-
-LinuxInputSubsystemKbdDriverPlugin::~LinuxInputSubsystemKbdDriverPlugin()
-{
-}
-
-QWSKeyboardHandler* LinuxInputSubsystemKbdDriverPlugin::create(const QString &driver, const QString &device)
-{
- if (device.isEmpty()) {
- return create( driver );
- }
- if( driver.toLower() == "linuxis" || driver.toLower() == "linuxiskbdhandler" ) {
- qLog(Input) << "Before call LinuxInputSubsystemKbdHandler(" << device << ")";
- return new LinuxInputSubsystemKbdHandler(device);
- }
- return 0;
-}
-
-QWSKeyboardHandler* LinuxInputSubsystemKbdDriverPlugin::create( const QString &driver)
-{
- if( driver.toLower() == "linuxis" || driver.toLower() == "linuxiskbdhandler" ) {
- qLog(Input) << "Before call LinuxInputSubsystemKbdHandler()";
- return new LinuxInputSubsystemKbdHandler();
- }
- return 0;
-}
-
-QStringList LinuxInputSubsystemKbdDriverPlugin::keys() const
-{
- return QStringList() << "linuxis" << "linuxiskbdhandler";
-}
-
-Q_EXPORT_PLUGIN2(qwslinuxiskbdhandler, LinuxInputSubsystemKbdDriverPlugin)
diff --git a/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.h b/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.h
deleted file mode 100644
index b5f599f..0000000
--- a/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef LINUXISKBDDRIVERPLUGIN_H
-#define LINUXISKBDDRIVERPLUGIN_H
-
-#include <QtGui/QWSKeyboardHandlerFactoryInterface>
-
-class LinuxInputSubsystemKbdDriverPlugin : public QKbdDriverPlugin {
- Q_OBJECT
-public:
- LinuxInputSubsystemKbdDriverPlugin( QObject *parent = 0 );
- ~LinuxInputSubsystemKbdDriverPlugin();
-
- QWSKeyboardHandler* create(const QString& driver, const QString& device);
- QWSKeyboardHandler* create(const QString& driver);
- QStringList keys()const;
-};
-
-#endif // LINUXISKBDDRIVERPLUGIN_H
diff --git a/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.cpp b/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.cpp
deleted file mode 100644
index 99b98b7..0000000
--- a/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "linuxiskbdhandler.h"
-
-#include <QSocketNotifier>
-
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-
-#include <linux/input.h>
-#include <linux/kd.h>
-
-#include <qdebug.h>
-#if 1
-#define qLog(x) qDebug()
-#else
-#define qLog(x) while (0) qDebug()
-#endif
-
-struct LinuxInputSubsystemKbdHandler::keytable_s LinuxInputSubsystemKbdHandler::keytable[] = {
- { KEY_PAGEDOWN, 0xffff, Qt::Key_Context1 },
- { KEY_END, 0xffff, Qt::Key_Back },
- { KEY_RIGHTCTRL, 0xffff, Qt::Key_Home },
- { KEY_SPACE, 0xffff, Qt::Key_Menu },
- { KEY_ENTER, 0xffff, Qt::Key_Select },
- { KEY_UP, 0xffff, Qt::Key_Up },
- { KEY_LEFT, 0xffff, Qt::Key_Left },
- { KEY_RIGHT, 0xffff, Qt::Key_Right },
- { KEY_DOWN, 0xffff, Qt::Key_Down },
- { KEY_POWER, 0xffff, Qt::Key_Call },
- { KEY_BACKSPACE, 0xffff, Qt::Key_Backspace },
- { KEY_F1, 0xffff, Qt::Key_Hangup },
- { KEY_KP1, '1', Qt::Key_1 },
- { KEY_KP2, '2', Qt::Key_2 },
- { KEY_KP3, '3', Qt::Key_3 },
- { KEY_KP4, '4', Qt::Key_4 },
- { KEY_KP5, '5', Qt::Key_5 },
- { KEY_KP6, '6', Qt::Key_6 },
- { KEY_KP7, '7', Qt::Key_7 },
- { KEY_KP8, '8', Qt::Key_8 },
- { KEY_KP9, '9', Qt::Key_9 },
- { KEY_KP0, '0', Qt::Key_0 },
- { KEY_APOSTROPHE, '*', Qt::Key_Asterisk },
- { KEY_3, '#', Qt::Key_NumberSign },
- { KEY_F2, 0xffff, Qt::Key_F2 },
- { KEY_F3, 0xffff, Qt::Key_F3 },
- { KEY_F4, 0xffff, Qt::Key_F4 },
- { KEY_F5, 0xffff, Qt::Key_F5 },
- { KEY_F6, 0xffff, Qt::Key_F6 },
- { KEY_F7, 0xffff, Qt::Key_VolumeUp },
- { KEY_F8, 0xffff, Qt::Key_VolumeDown },
- { KEY_F9, 0xffff, Qt::Key_F9 },
- { 0, 0, Qt::Key_unknown },
-};
-
-struct LinuxInputSubsystemKbdHandler::keymap_s LinuxInputSubsystemKbdHandler::keymap[KEY_MAX];
-
-LinuxInputSubsystemKbdHandler::LinuxInputSubsystemKbdHandler(const QString &device)
-{
- qLog(Input) << "Loaded LinuxInputSubsystem keypad plugin!";
- setObjectName( "LinuxInputSubsystem Keypad Handler" );
- kbdFD = ::open(device.toLocal8Bit().constData(), O_RDONLY, 0);
- if (kbdFD >= 0) {
- qLog(Input) << "Opened" << device << "as keypad input";
-#if 0
- struct kbd_repeat kbdrep;
- kbdrep.delay = 500; /* ms */
- kbdrep.period = 250; /* ms */
- ioctl(kbdFD, KDKBDREP, &kbdrep);
-#endif
- m_notify = new QSocketNotifier( kbdFD, QSocketNotifier::Read, this );
- connect( m_notify, SIGNAL(activated(int)), this, SLOT(readKbdData()));
- } else {
- qWarning("Cannot open '%s' for keypad (%s)",
- device.toLocal8Bit().constData(), strerror(errno));
- return;
- }
- shift = false;
-
- initmap();
-}
-
-LinuxInputSubsystemKbdHandler::~LinuxInputSubsystemKbdHandler()
-{
-}
-
-void LinuxInputSubsystemKbdHandler::initmap()
-{
- for (int i = 0; i < KEY_MAX; i++) {
- keymap[i].unicode = 0xffff;
- keymap[i].keycode = Qt::Key_unknown;
- }
- for (int i = 0; keytable[i].unicode; i++) {
- int idx = keytable[i].code;
- keymap[idx].unicode = keytable[i].unicode;
- keymap[idx].keycode = keytable[i].keycode;
- }
-}
-
-void LinuxInputSubsystemKbdHandler::readKbdData()
-{
- struct input_event *ie;
- struct input_event iebuf[32];
-
- uint n = ::read(kbdFD, iebuf, sizeof(iebuf));
-
- bool pressed;
- bool autorepeat;
- int modifiers = 0;
- int unicode, keycode;
-
- n /= sizeof(struct input_event);
- ie = iebuf;
- for (uint i = 0; i < n; i++) {
-
- pressed = ie->value != 0;
- autorepeat = ie->value == 2;
- qLog() << "keyEvent" << hex << ie->type << ie->code << ie->value;
- unicode = keymap[ie->code].unicode;
- keycode = keymap[ie->code].keycode;
-
- processKeyEvent(unicode, keycode, (Qt::KeyboardModifiers)modifiers,
- pressed, autorepeat);
-
- ie++;
- }
-
-}
-
diff --git a/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.h b/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.h
deleted file mode 100644
index 3211309..0000000
--- a/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef LINUXISKBDHANDLER_H
-#define LINUXISKBDHANDLER_H
-
-#include <QObject>
-#include <QWSKeyboardHandler>
-
-class QSocketNotifier;
-class LinuxInputSubsystemKbdHandler : public QObject, public QWSKeyboardHandler {
- Q_OBJECT
-public:
- LinuxInputSubsystemKbdHandler(const QString &device = QString("/dev/input/event0"));
- ~LinuxInputSubsystemKbdHandler();
-
- struct keytable_s {
- int code;
- int unicode;
- int keycode;
- };
-
- struct keymap_s {
- int unicode;
- int keycode;
- };
-
-private:
- void initmap();
-
- QSocketNotifier *m_notify;
- int kbdFD;
- bool shift;
-
- static struct keytable_s keytable[];
- static struct keymap_s keymap[];
-
-private Q_SLOTS:
- void readKbdData();
-};
-
-#endif // LINUXISKBDHANDLER_H
diff --git a/src/plugins/kbddrivers/usb/usb.pro b/src/plugins/kbddrivers/usb/usb.pro
deleted file mode 100644
index 4187255..0000000
--- a/src/plugins/kbddrivers/usb/usb.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qusbkbddriver
-include(../../qpluginbase.pri)
-
-QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers
-target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers
-INSTALLS += target
-
-DEFINES += QT_QWS_KBD_USB
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdusb_qws.h
-
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qkbdusb_qws.cpp
-
diff --git a/src/qt3support/text/q3richtext.cpp b/src/qt3support/text/q3richtext.cpp
index c058e37..e508001 100644
--- a/src/qt3support/text/q3richtext.cpp
+++ b/src/qt3support/text/q3richtext.cpp
@@ -4895,7 +4895,8 @@ void Q3TextParagraph::drawString(QPainter &painter, const QString &str, int star
bool extendRight = false;
bool extendLeft = false;
bool selWrap = (real_selEnd == length()-1 && n && n->hasSelection(it.key()));
- if (selWrap || this->str->at(real_selEnd).lineStart) {
+ if (selWrap
+ || ((real_selEnd < this->str->length()) && this->str->at(real_selEnd).lineStart)) {
extendRight = (fullSelectionWidth != 0);
if (!extendRight && !rightToLeft)
tmpw += painter.fontMetrics().width(QLatin1Char(' '));
diff --git a/src/script/qscriptengine.cpp b/src/script/qscriptengine.cpp
index d4e1923..d8908ed 100644
--- a/src/script/qscriptengine.cpp
+++ b/src/script/qscriptengine.cpp
@@ -1169,7 +1169,8 @@ bool QScriptEngine::convert(const QScriptValue &value, int type, void *ptr)
bool QScriptEngine::convertV2(const QScriptValue &value, int type, void *ptr)
{
QScriptValueImpl impl = QScriptValuePrivate::valueOf(value);
- return QScriptEnginePrivate::convert(impl, type, ptr, /*engine=*/0);
+ QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(value.engine());
+ return QScriptEnginePrivate::convert(impl, type, ptr, eng_p);
}
/*!
diff --git a/src/scripttools/debugging/qscriptbreakpointswidget.cpp b/src/scripttools/debugging/qscriptbreakpointswidget.cpp
index aea1fe7..efb3047 100644
--- a/src/scripttools/debugging/qscriptbreakpointswidget.cpp
+++ b/src/scripttools/debugging/qscriptbreakpointswidget.cpp
@@ -225,7 +225,6 @@ public:
bool eventFilter(QObject *editor, QEvent *event)
{
-#if QT_VERSION >= 0x040500
if (QLineEdit *le = qobject_cast<QLineEdit*>(editor)) {
if (event->type() == QEvent::KeyPress) {
int key = static_cast<QKeyEvent*>(event)->key();
@@ -237,21 +236,18 @@ public:
}
}
}
-#endif
return QStyledItemDelegate::eventFilter(editor, event);
}
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
-#if QT_VERSION >= 0x040500
if (index.column() == 2) {
// check that the syntax is OK
QString condition = qobject_cast<QLineEdit*>(editor)->text();
if (QScriptEngine::checkSyntax(condition).state() != QScriptSyntaxCheckResult::Valid)
return;
}
-#endif
QStyledItemDelegate::setModelData(editor, model, index);
}
@@ -261,11 +257,7 @@ private Q_SLOTS:
QWidget *editor = qobject_cast<QWidget*>(sender());
QPalette pal = editor->palette();
QColor col;
-#if QT_VERSION >= 0x040500
bool ok = (QScriptEngine::checkSyntax(text).state() == QScriptSyntaxCheckResult::Valid);
-#else
- bool ok = true;
-#endif
if (ok) {
col = Qt::white;
} else {
diff --git a/src/scripttools/debugging/qscriptcompletiontask.cpp b/src/scripttools/debugging/qscriptcompletiontask.cpp
index 3767505..119b96a 100644
--- a/src/scripttools/debugging/qscriptcompletiontask.cpp
+++ b/src/scripttools/debugging/qscriptcompletiontask.cpp
@@ -162,11 +162,7 @@ void QScriptCompletionTaskPrivate::completeScriptExpression()
obj = ctx->thisObject();
} else {
QScriptValueList scopeChain;
-#if QT_VERSION >= 0x040500
scopeChain = ctx->scopeChain();
-#else
- scopeChain.append(ctx->activationObject());
-#endif
for (int i = 0; i < scopeChain.size(); ++i) {
QScriptValue oo = scopeChain.at(i).property(topLevelIdent);
if (oo.isObject()) {
@@ -180,11 +176,7 @@ void QScriptCompletionTaskPrivate::completeScriptExpression()
if (obj.isValid())
objects.append(obj);
} else {
-#if QT_VERSION >= 0x040500
objects << ctx->scopeChain();
-#else
- objects.append(ctx->activationObject());
-#endif
QStringList keywords;
keywords.append(QString::fromLatin1("this"));
keywords.append(QString::fromLatin1("true"));
diff --git a/src/scripttools/debugging/qscriptdebugger.cpp b/src/scripttools/debugging/qscriptdebugger.cpp
index 5a356ae..ce43572 100644
--- a/src/scripttools/debugging/qscriptdebugger.cpp
+++ b/src/scripttools/debugging/qscriptdebugger.cpp
@@ -663,11 +663,7 @@ QString QScriptDebuggerPrivate::toolTip(int frameIndex, int lineNumber,
objects.append(ctx->thisObject());
++pathIndex;
} else {
-#if QT_VERSION >= 0x040500
objects << ctx->scopeChain();
-#else
- objects.append(ctx->activationObject());
-#endif
}
for (int i = 0; i < objects.size(); ++i) {
QScriptValue val = objects.at(i);
@@ -991,13 +987,11 @@ public:
qint64 scriptId = m_added.at(m_index);
m_debugger->scriptsModel->addScript(scriptId, data);
-#if QT_VERSION >= 0x040500
// ### could be slow, might want to do this in a separate thread
QString xml = qt_scriptToXml(data.contents(), data.baseLineNumber());
QScriptXmlParser::Result extraInfo = QScriptXmlParser::parse(xml);
m_debugger->scriptsModel->addExtraScriptInfo(
scriptId, extraInfo.functionsInfo, extraInfo.executableLineNumbers);
-#endif
if (++m_index < m_added.size())
frontend.scheduleGetScriptData(m_added.at(m_index));
diff --git a/src/scripttools/debugging/qscriptdebuggeragent.cpp b/src/scripttools/debugging/qscriptdebuggeragent.cpp
index fcba033..0ea9c99 100644
--- a/src/scripttools/debugging/qscriptdebuggeragent.cpp
+++ b/src/scripttools/debugging/qscriptdebuggeragent.cpp
@@ -88,16 +88,9 @@ QScriptDebuggerAgentPrivate *QScriptDebuggerAgentPrivate::get(
*/
QScriptDebuggerAgent::QScriptDebuggerAgent(
QScriptDebuggerBackendPrivate *backend, QScriptEngine *engine)
-#if QT_VERSION >= 0x040500
: QScriptEngineAgent(*new QScriptDebuggerAgentPrivate, engine)
-#else
- : QScriptEngineAgent(engine), d_ptr(new QScriptDebuggerAgentPrivate)
-#endif
{
Q_D(QScriptDebuggerAgent);
-#if QT_VERSION < 0x040500
- d_ptr->q_ptr = this;
-#endif
d->backend = backend;
QScriptContext *ctx = engine->currentContext();
@@ -117,9 +110,6 @@ QScriptDebuggerAgent::~QScriptDebuggerAgent()
Q_D(QScriptDebuggerAgent);
if (d->backend)
d->backend->agentDestroyed(this);
-#if QT_VERSION < 0x040500
- delete d_ptr;
-#endif
}
/*!
@@ -712,12 +702,7 @@ void QScriptDebuggerAgent::exceptionCatch(qint64 scriptId,
*/
bool QScriptDebuggerAgent::supportsExtension(Extension extension) const
{
-#if QT_VERSION >= 0x040500
return (extension == DebuggerInvocationRequest);
-#else
- Q_UNUSED(extension);
- return false;
-#endif
}
/*!
@@ -727,7 +712,6 @@ QVariant QScriptDebuggerAgent::extension(Extension extension,
const QVariant &argument)
{
Q_UNUSED(extension);
-#if QT_VERSION >= 0x040500
Q_D(QScriptDebuggerAgent);
Q_ASSERT(extension == DebuggerInvocationRequest);
QVariantList lst = argument.toList();
@@ -739,9 +723,6 @@ QVariant QScriptDebuggerAgent::extension(Extension extension,
d->backend->debuggerInvocationRequest(
scriptId, lineNumber, columnNumber);
}
-#else
- Q_UNUSED(argument);
-#endif
return QVariant();
}
diff --git a/src/scripttools/debugging/qscriptdebuggeragent_p.h b/src/scripttools/debugging/qscriptdebuggeragent_p.h
index 556b17b..28ec46a 100644
--- a/src/scripttools/debugging/qscriptdebuggeragent_p.h
+++ b/src/scripttools/debugging/qscriptdebuggeragent_p.h
@@ -125,9 +125,6 @@ public:
const QVariant &argument = QVariant());
private:
-#if QT_VERSION < 0x040500
- QScriptDebuggerAgentPrivate *d_ptr;
-#endif
Q_DECLARE_PRIVATE(QScriptDebuggerAgent)
Q_DISABLE_COPY(QScriptDebuggerAgent)
};
diff --git a/src/scripttools/debugging/qscriptdebuggeragent_p_p.h b/src/scripttools/debugging/qscriptdebuggeragent_p_p.h
index cf6fd1a..313b1c0 100644
--- a/src/scripttools/debugging/qscriptdebuggeragent_p_p.h
+++ b/src/scripttools/debugging/qscriptdebuggeragent_p_p.h
@@ -68,9 +68,7 @@ QT_BEGIN_NAMESPACE
class QScriptDebuggerAgent;
class QScriptDebuggerAgentPrivate
-#if QT_VERSION >= 0x040500
: public QScriptEngineAgentPrivate
-#endif
{
Q_DECLARE_PUBLIC(QScriptDebuggerAgent)
public:
@@ -125,10 +123,6 @@ public:
int statementCounter;
QScriptDebuggerBackendPrivate *backend;
-
-#if QT_VERSION < 0x040500
- QScriptDebuggerAgent *q_ptr;
-#endif
};
QT_END_NAMESPACE
diff --git a/src/scripttools/debugging/qscriptdebuggerbackend.cpp b/src/scripttools/debugging/qscriptdebuggerbackend.cpp
index 24a3847..3c29130 100644
--- a/src/scripttools/debugging/qscriptdebuggerbackend.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerbackend.cpp
@@ -615,13 +615,11 @@ void QScriptDebuggerBackend::doPendingEvaluate(bool postEvent)
// push a new context and initialize its scope chain etc.
{
QScriptContext *evalContext = engine()->pushContext();
-#if QT_VERSION >= 0x040500
QScriptValueList scopeChain = ctx->scopeChain();
if (scopeChain.isEmpty())
scopeChain.append(engine()->globalObject());
while (!scopeChain.isEmpty())
evalContext->pushScope(scopeChain.takeLast());
-#endif
evalContext->setActivationObject(ctx->activationObject());
evalContext->setThisObject(ctx->thisObject());
}
diff --git a/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp b/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp
index e36386d..1be8c5f 100644
--- a/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp
+++ b/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp
@@ -287,13 +287,9 @@ QScriptDebuggerResponse QScriptDebuggerCommandExecutor::execute(
QScriptContext *ctx = backend->context(command.contextIndex());
if (ctx) {
QScriptDebuggerValueList dest;
-#if QT_VERSION >= 0x040500
QScriptValueList src = ctx->scopeChain();
for (int i = 0; i < src.size(); ++i)
dest.append(src.at(i));
-#else
- dest.append(ctx->activationObject());
-#endif
response.setResult(dest);
} else {
response.setError(QScriptDebuggerResponse::InvalidContextIndex);
diff --git a/src/scripttools/debugging/qscriptdebuggerconsoleglobalobject.cpp b/src/scripttools/debugging/qscriptdebuggerconsoleglobalobject.cpp
index 0018b92..f923508 100644
--- a/src/scripttools/debugging/qscriptdebuggerconsoleglobalobject.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerconsoleglobalobject.cpp
@@ -448,12 +448,7 @@ QStringList QScriptDebuggerConsoleGlobalObject::getCommandCompletions(const QStr
bool QScriptDebuggerConsoleGlobalObject::checkSyntax(const QString &program)
{
-#if QT_VERSION >= 0x040500
return (QScriptEngine::checkSyntax(program).state() == QScriptSyntaxCheckResult::Valid);
-#else
- Q_UNUSED(program);
- return true;
-#endif
}
void QScriptDebuggerConsoleGlobalObject::setEvaluateAction(int action)
diff --git a/src/scripttools/debugging/qscriptdebuggerlocalswidget.cpp b/src/scripttools/debugging/qscriptdebuggerlocalswidget.cpp
index a4919be..60fe48d 100644
--- a/src/scripttools/debugging/qscriptdebuggerlocalswidget.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerlocalswidget.cpp
@@ -206,11 +206,7 @@ private Q_SLOTS:
QWidget *editor = qobject_cast<QWidget*>(sender());
QPalette pal = editor->palette();
QColor col;
-#if QT_VERSION >= 0x040500
bool ok = (QScriptEngine::checkSyntax(text).state() == QScriptSyntaxCheckResult::Valid);
-#else
- bool ok = true;
-#endif
if (ok) {
col = Qt::white;
} else {
@@ -277,12 +273,10 @@ bool QScriptDebuggerLocalsItemDelegate::eventFilter(QObject *watched, QEvent *ev
return QStyledItemDelegate::eventFilter(watched, event);
QKeyEvent *ke = static_cast<QKeyEvent*>(event);
if ((ke->key() == Qt::Key_Enter) || (ke->key() == Qt::Key_Return)) {
-#if QT_VERSION >= 0x040500
if (QScriptEngine::checkSyntax(le->text()).state() != QScriptSyntaxCheckResult::Valid) {
// ignore when script contains syntax error
return true;
}
-#endif
}
if (ke->key() != Qt::Key_Tab)
return QStyledItemDelegate::eventFilter(watched, event);
@@ -296,14 +290,12 @@ void QScriptDebuggerLocalsItemDelegate::setModelData(
QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
-#if QT_VERSION >= 0x040500
if (index.column() == 1) {
// check that the syntax is OK
QString expression = qobject_cast<QLineEdit*>(editor)->text();
if (QScriptEngine::checkSyntax(expression).state() != QScriptSyntaxCheckResult::Valid)
return;
}
-#endif
QStyledItemDelegate::setModelData(editor, model, index);
}
diff --git a/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp b/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp
index 20350f6..fa30d84 100644
--- a/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp
@@ -410,11 +410,7 @@ void QScriptDebuggerScriptedConsoleCommandJob::start()
for (int i = 0; i < d->arguments.size(); ++i)
args.append(QScriptValue(engine, d->arguments.at(i)));
QScriptDebuggerConsoleGlobalObject *global;
-#if QT_VERSION >= 0x040500
global = qobject_cast<QScriptDebuggerConsoleGlobalObject*>(engine->globalObject().toQObject());
-#else
- global = qobject_cast<QScriptDebuggerConsoleGlobalObject*>(engine->globalObject().scope().toQObject());
-#endif
Q_ASSERT(global != 0);
global->setScheduler(this);
global->setResponseHandler(this);
@@ -444,11 +440,7 @@ void QScriptDebuggerScriptedConsoleCommandJob::handleResponse(
args.append(qScriptValueFromValue(engine, response));
args.append(QScriptValue(engine, commandId));
QScriptDebuggerConsoleGlobalObject *global;
-#if QT_VERSION >= 0x040500
global = qobject_cast<QScriptDebuggerConsoleGlobalObject*>(engine->globalObject().toQObject());
-#else
- global = qobject_cast<QScriptDebuggerConsoleGlobalObject*>(engine->globalObject().scope().toQObject());
-#endif
Q_ASSERT(global != 0);
global->setScheduler(this);
global->setResponseHandler(this);
@@ -566,12 +558,7 @@ QScriptDebuggerScriptedConsoleCommand *QScriptDebuggerScriptedConsoleCommand::pa
QScriptDebuggerConsoleGlobalObject *cppGlobal = new QScriptDebuggerConsoleGlobalObject();
QScriptValue global = engine->newQObject(cppGlobal,
QScriptEngine::ScriptOwnership,
-#if QT_VERSION >= 0x040500
QScriptEngine::ExcludeSuperClassContents);
-#else
- QScriptEngine::ExcludeSuperClassMethods
- | QScriptEngine::ExcludeSuperClassProperties);
-#endif
{
QScriptValueIterator it(engine->globalObject());
while (it.hasNext()) {
@@ -579,12 +566,7 @@ QScriptDebuggerScriptedConsoleCommand *QScriptDebuggerScriptedConsoleCommand::pa
global.setProperty(it.scriptName(), it.value(), it.flags());
}
}
-#if QT_VERSION >= 0x040500
engine->setGlobalObject(global);
-#else
- engine->globalObject().setScope(global);
- global = engine->globalObject();
-#endif
cppGlobal->setMessageHandler(messageHandler);
QScriptValue ret = engine->evaluate(program, fileName);
diff --git a/src/scripttools/debugging/qscriptedit.cpp b/src/scripttools/debugging/qscriptedit.cpp
index 2bc0a40..7c2a72c 100644
--- a/src/scripttools/debugging/qscriptedit.cpp
+++ b/src/scripttools/debugging/qscriptedit.cpp
@@ -342,11 +342,9 @@ void QScriptEdit::extraAreaPaintEvent(QPaintEvent *e)
icon.paint(&painter, r, Qt::AlignCenter);
}
-#if QT_VERSION >= 0x040500
if (!m_executableLineNumbers.contains(lineNumber))
painter.setPen(pal.color(QPalette::Mid));
else
-#endif
painter.setPen(QColor(Qt::darkCyan));
QString number = QString::number(lineNumber);
painter.drawText(rect.x() + markWidth, (int)top, rect.x() + extraAreaWidth - markWidth - 4,
@@ -370,10 +368,8 @@ void QScriptEdit::extraAreaMouseEvent(QMouseEvent *e)
if (e->type() == QEvent::MouseMove && e->buttons() == 0) { // mouse tracking
bool hand = (e->pos().x() <= markWidth);
-#if QT_VERSION >= 0x040500
int lineNumber = cursor.blockNumber() + m_baseLineNumber;
hand = hand && m_executableLineNumbers.contains(lineNumber);
-#endif
#ifndef QT_NO_CURSOR
if (hand != (m_extraArea->cursor().shape() == Qt::PointingHandCursor))
m_extraArea->setCursor(hand ? Qt::PointingHandCursor : Qt::ArrowCursor);
@@ -382,12 +378,8 @@ void QScriptEdit::extraAreaMouseEvent(QMouseEvent *e)
if (e->type() == QEvent::MouseButtonPress) {
if (e->button() == Qt::LeftButton) {
-#if QT_VERSION >= 0x040500
int lineNumber = cursor.blockNumber() + m_baseLineNumber;
bool executable = m_executableLineNumbers.contains(lineNumber);
-#else
- bool executable = true;
-#endif
if ((e->pos().x() <= markWidth) && executable)
m_extraAreaToggleBlockNumber = cursor.blockNumber();
else
@@ -402,10 +394,8 @@ void QScriptEdit::extraAreaMouseEvent(QMouseEvent *e)
}
} else if (e->button() == Qt::RightButton) {
int lineNumber = cursor.blockNumber() + m_baseLineNumber;
-#if QT_VERSION >= 0x040500
if (!m_executableLineNumbers.contains(lineNumber))
return;
-#endif
bool has = m_breakpoints.contains(lineNumber);
QMenu *popup = new QMenu();
QAction *toggleAct = new QAction(QObject::tr("Toggle Breakpoint"), popup);
diff --git a/src/scripttools/debugging/qscriptenginedebugger.h b/src/scripttools/debugging/qscriptenginedebugger.h
index d5e127f..a4853f0 100644
--- a/src/scripttools/debugging/qscriptenginedebugger.h
+++ b/src/scripttools/debugging/qscriptenginedebugger.h
@@ -48,11 +48,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-#if QT_VERSION >= 0x040500
QT_MODULE(ScriptTools)
-#else
-# define Q_SCRIPTTOOLS_EXPORT
-#endif
class QAction;
class QScriptEngine;
diff --git a/src/sql/drivers/db2/qsql_db2.cpp b/src/sql/drivers/db2/qsql_db2.cpp
index 69383f7..11d0041 100644
--- a/src/sql/drivers/db2/qsql_db2.cpp
+++ b/src/sql/drivers/db2/qsql_db2.cpp
@@ -49,6 +49,7 @@
#include <qstringlist.h>
#include <qvarlengtharray.h>
#include <qvector.h>
+#include <QDebug>
#ifndef UNICODE
#define UNICODE
@@ -87,8 +88,19 @@ public:
{}
~QDB2ResultPrivate()
{
- for (int i = 0; i < valueCache.count(); ++i)
+ emptyValueCache();
+ }
+ void clearValueCache()
+ {
+ for (int i = 0; i < valueCache.count(); ++i) {
delete valueCache[i];
+ valueCache[i] = NULL;
+ }
+ }
+ void emptyValueCache()
+ {
+ clearValueCache();
+ valueCache.clear();
}
const QDB2DriverPrivate* dp;
@@ -544,7 +556,7 @@ bool QDB2Result::reset (const QString& query)
SQLRETURN r;
d->recInf.clear();
- d->valueCache.clear();
+ d->emptyValueCache();
if (!qMakeStatement(d, isForwardOnly()))
return false;
@@ -568,6 +580,7 @@ bool QDB2Result::reset (const QString& query)
setSelect(false);
}
d->valueCache.resize(count);
+ d->valueCache.fill(NULL);
setActive(true);
return true;
}
@@ -579,7 +592,7 @@ bool QDB2Result::prepare(const QString& query)
SQLRETURN r;
d->recInf.clear();
- d->valueCache.clear();
+ d->emptyValueCache();
if (!qMakeStatement(d, isForwardOnly()))
return false;
@@ -607,7 +620,7 @@ bool QDB2Result::exec()
SQLRETURN r;
d->recInf.clear();
- d->valueCache.clear();
+ d->emptyValueCache();
if (!qMakeStatement(d, isForwardOnly(), false))
return false;
@@ -811,6 +824,7 @@ bool QDB2Result::exec()
}
setActive(true);
d->valueCache.resize(count);
+ d->valueCache.fill(NULL);
//get out parameters
if (!hasOutValues())
@@ -858,7 +872,7 @@ bool QDB2Result::fetch(int i)
return false;
if (i == at())
return true;
- d->valueCache.fill(0);
+ d->clearValueCache();
int actualIdx = i + 1;
if (actualIdx <= 0) {
setAt(QSql::BeforeFirstRow);
@@ -887,7 +901,7 @@ bool QDB2Result::fetch(int i)
bool QDB2Result::fetchNext()
{
SQLRETURN r;
- d->valueCache.fill(0);
+ d->clearValueCache();
r = SQLFetchScroll(d->hStmt,
SQL_FETCH_NEXT,
0);
@@ -907,7 +921,7 @@ bool QDB2Result::fetchFirst()
return false;
if (isForwardOnly())
return fetchNext();
- d->valueCache.fill(0);
+ d->clearValueCache();
SQLRETURN r;
r = SQLFetchScroll(d->hStmt,
SQL_FETCH_FIRST,
@@ -923,7 +937,7 @@ bool QDB2Result::fetchFirst()
bool QDB2Result::fetchLast()
{
- d->valueCache.fill(0);
+ d->clearValueCache();
int i = at();
if (i == QSql::AfterLastRow) {
@@ -1044,7 +1058,7 @@ QVariant QDB2Result::data(int field)
case QSql::HighPrecision:
default:
// length + 1 for the comma
- v = new QVariant(qGetStringData(d->hStmt, field, info.length() + 1, isNull));
+ v = new QVariant(value);
ok = true;
break;
}
@@ -1101,7 +1115,7 @@ bool QDB2Result::nextResult()
setActive(false);
setAt(QSql::BeforeFirstRow);
d->recInf.clear();
- d->valueCache.clear();
+ d->emptyValueCache();
setSelect(false);
SQLRETURN r = SQLMoreResults(d->hStmt);
@@ -1120,6 +1134,7 @@ bool QDB2Result::nextResult()
d->recInf.append(qMakeFieldInfo(d, i));
d->valueCache.resize(fieldCount);
+ d->valueCache.fill(NULL);
setActive(true);
return true;
@@ -1167,7 +1182,7 @@ QDB2Driver::~QDB2Driver()
delete d;
}
-bool QDB2Driver::open(const QString& db, const QString& user, const QString& password, const QString&, int,
+bool QDB2Driver::open(const QString& db, const QString& user, const QString& password, const QString& host, int port,
const QString& connOpts)
{
if (isOpen())
@@ -1190,6 +1205,8 @@ bool QDB2Driver::open(const QString& db, const QString& user, const QString& pas
setOpenError(true);
return false;
}
+
+ QString protocol;
// Set connection attributes
const QStringList opts(connOpts.split(QLatin1Char(';'), QString::SkipEmptyParts));
for (int i = 0; i < opts.count(); ++i) {
@@ -1220,7 +1237,10 @@ bool QDB2Driver::open(const QString& db, const QString& user, const QString& pas
} else if (opt == QLatin1String("SQL_ATTR_LOGIN_TIMEOUT")) {
v = val.toUInt();
r = SQLSetConnectAttr(d->hDbc, SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER) v, 0);
- } else {
+ } else if (opt.compare(QLatin1String("PROTOCOL"), Qt::CaseInsensitive) == 0) {
+ protocol = tmp;
+ }
+ else {
qWarning("QDB2Driver::open: Unknown connection attribute '%s'",
tmp.toLocal8Bit().constData());
}
@@ -1229,9 +1249,18 @@ bool QDB2Driver::open(const QString& db, const QString& user, const QString& pas
"Unable to set connection attribute '%1'").arg(opt), d);
}
+ if (protocol.isEmpty())
+ protocol = QLatin1String("PROTOCOL=TCPIP");
+
+ if (port < 0 )
+ port = 50000;
+
QString connQStr;
- connQStr = QLatin1String("DSN=") + db + QLatin1String(";UID=") + user + QLatin1String(";PWD=")
- + password;
+ connQStr = protocol + QLatin1String(";DATABASE=") + db + QLatin1String(";HOSTNAME=") + host
+ + QLatin1String(";PORT=") + QString::number(port) + QLatin1String(";UID=") + user
+ + QLatin1String(";PWD=") + password;
+
+
SQLTCHAR connOut[SQL_MAX_OPTION_STRING_LENGTH];
SQLSMALLINT cb;
@@ -1250,7 +1279,7 @@ bool QDB2Driver::open(const QString& db, const QString& user, const QString& pas
return false;
}
- d->user = user.toUpper();
+ d->user = user;
setOpen(true);
setOpenError(false);
return true;
@@ -1295,10 +1324,25 @@ QSqlRecord QDB2Driver::record(const QString& tableName) const
SQLHANDLE hStmt;
QString catalog, schema, table;
- qSplitTableQualifier(tableName.toUpper(), &catalog, &schema, &table);
+ qSplitTableQualifier(tableName, &catalog, &schema, &table);
if (schema.isEmpty())
schema = d->user;
+ if (isIdentifierEscaped(catalog, QSqlDriver::TableName))
+ catalog = stripDelimiters(catalog, QSqlDriver::TableName);
+ else
+ catalog = catalog.toUpper();
+
+ if (isIdentifierEscaped(schema, QSqlDriver::TableName))
+ schema = stripDelimiters(schema, QSqlDriver::TableName);
+ else
+ schema = schema.toUpper();
+
+ if (isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
+ else
+ table = table.toUpper();
+
SQLRETURN r = SQLAllocHandle(SQL_HANDLE_STMT,
d->hDbc,
&hStmt);
@@ -1312,6 +1356,9 @@ QSqlRecord QDB2Driver::record(const QString& tableName) const
(SQLPOINTER) SQL_CURSOR_FORWARD_ONLY,
SQL_IS_UINTEGER);
+
+ //Aside: szSchemaName and szTableName parameters of SQLColumns
+ //are case sensitive search patterns, so no escaping is used.
r = SQLColumns(hStmt,
NULL,
0,
@@ -1392,7 +1439,13 @@ QStringList QDB2Driver::tables(QSql::TableType type) const
bool isNull;
QString fieldVal = qGetStringData(hStmt, 2, -1, isNull);
QString userVal = qGetStringData(hStmt, 1, -1, isNull);
- if (userVal != d->user)
+ QString user = d->user;
+ if ( isIdentifierEscaped(user, QSqlDriver::TableName))
+ user = stripDelimiters(user, QSqlDriver::TableName);
+ else
+ user = user.toUpper();
+
+ if (userVal != user)
fieldVal = userVal + QLatin1Char('.') + fieldVal;
tl.append(fieldVal);
r = SQLFetchScroll(hStmt,
@@ -1423,7 +1476,23 @@ QSqlIndex QDB2Driver::primaryIndex(const QString& tablename) const
return index;
}
QString catalog, schema, table;
- qSplitTableQualifier(tablename.toUpper(), &catalog, &schema, &table);
+ qSplitTableQualifier(tablename, &catalog, &schema, &table);
+
+ if (isIdentifierEscaped(catalog, QSqlDriver::TableName))
+ catalog = stripDelimiters(catalog, QSqlDriver::TableName);
+ else
+ catalog = catalog.toUpper();
+
+ if (isIdentifierEscaped(schema, QSqlDriver::TableName))
+ schema = stripDelimiters(schema, QSqlDriver::TableName);
+ else
+ schema = schema.toUpper();
+
+ if (isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
+ else
+ table = table.toUpper();
+
r = SQLSetStmtAttr(hStmt,
SQL_ATTR_CURSOR_TYPE,
(SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp
index 64f13b5..0705722 100644
--- a/src/sql/drivers/ibase/qsql_ibase.cpp
+++ b/src/sql/drivers/ibase/qsql_ibase.cpp
@@ -1552,12 +1552,16 @@ QSqlRecord QIBaseDriver::record(const QString& tablename) const
QSqlQuery q(createResult());
q.setForwardOnly(true);
-
+ QString table = tablename;
+ if (isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
+ else
+ table = table.toUpper();
q.exec(QLatin1String("SELECT a.RDB$FIELD_NAME, b.RDB$FIELD_TYPE, b.RDB$FIELD_LENGTH, "
"b.RDB$FIELD_SCALE, b.RDB$FIELD_PRECISION, a.RDB$NULL_FLAG "
"FROM RDB$RELATION_FIELDS a, RDB$FIELDS b "
"WHERE b.RDB$FIELD_NAME = a.RDB$FIELD_SOURCE "
- "AND a.RDB$RELATION_NAME = '") + tablename.toUpper() + QLatin1String("' "
+ "AND a.RDB$RELATION_NAME = '") + table + QLatin1String("' "
"ORDER BY a.RDB$FIELD_POSITION"));
while (q.next()) {
@@ -1585,12 +1589,18 @@ QSqlIndex QIBaseDriver::primaryIndex(const QString &table) const
if (!isOpen())
return index;
+ QString tablename = table;
+ if (isIdentifierEscaped(tablename, QSqlDriver::TableName))
+ tablename = stripDelimiters(tablename, QSqlDriver::TableName);
+ else
+ tablename = tablename.toUpper();
+
QSqlQuery q(createResult());
q.setForwardOnly(true);
q.exec(QLatin1String("SELECT a.RDB$INDEX_NAME, b.RDB$FIELD_NAME, d.RDB$FIELD_TYPE, d.RDB$FIELD_SCALE "
"FROM RDB$RELATION_CONSTRAINTS a, RDB$INDEX_SEGMENTS b, RDB$RELATION_FIELDS c, RDB$FIELDS d "
"WHERE a.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' "
- "AND a.RDB$RELATION_NAME = '") + table.toUpper() +
+ "AND a.RDB$RELATION_NAME = '") + tablename +
QLatin1String(" 'AND a.RDB$INDEX_NAME = b.RDB$INDEX_NAME "
"AND c.RDB$RELATION_NAME = a.RDB$RELATION_NAME "
"AND c.RDB$FIELD_NAME = b.RDB$FIELD_NAME "
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp
index 9b57f3c..a84e840 100644
--- a/src/sql/drivers/mysql/qsql_mysql.cpp
+++ b/src/sql/drivers/mysql/qsql_mysql.cpp
@@ -1314,7 +1314,7 @@ QSqlIndex QMYSQLDriver::primaryIndex(const QString& tablename) const
QSqlQuery i(createResult());
QString stmt(QLatin1String("show index from %1;"));
QSqlRecord fil = record(tablename);
- i.exec(stmt.arg(escapeIdentifier(tablename, QSqlDriver::TableName)));
+ i.exec(stmt.arg(tablename));
while (i.isActive() && i.next()) {
if (i.value(2).toString() == QLatin1String("PRIMARY")) {
idx.append(fil.field(i.value(4).toString()));
@@ -1329,10 +1329,14 @@ QSqlIndex QMYSQLDriver::primaryIndex(const QString& tablename) const
QSqlRecord QMYSQLDriver::record(const QString& tablename) const
{
+ QString table=tablename;
+ if(isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
+
QSqlRecord info;
if (!isOpen())
return info;
- MYSQL_RES* r = mysql_list_fields(d->mysql, tablename.toLocal8Bit().constData(), 0);
+ MYSQL_RES* r = mysql_list_fields(d->mysql, table.toLocal8Bit().constData(), 0);
if (!r) {
return info;
}
@@ -1443,4 +1447,15 @@ QString QMYSQLDriver::escapeIdentifier(const QString &identifier, IdentifierType
return res;
}
+bool QMYSQLDriver::isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const
+{
+ Q_UNUSED(type);
+ bool isLeftDelimited = (identifier.left(1) == QString(QLatin1Char('`')));
+ bool isRightDelimited = (identifier.right(1) == QString(QLatin1Char('`')));
+ if( identifier.size() > 2 && isLeftDelimited && isRightDelimited )
+ return true;
+ else
+ return false;
+}
+
QT_END_NAMESPACE
diff --git a/src/sql/drivers/mysql/qsql_mysql.h b/src/sql/drivers/mysql/qsql_mysql.h
index 97aa346..31d9dcf 100644
--- a/src/sql/drivers/mysql/qsql_mysql.h
+++ b/src/sql/drivers/mysql/qsql_mysql.h
@@ -123,6 +123,9 @@ public:
QVariant handle() const;
QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
+protected Q_SLOTS:
+ bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const;
+
protected:
bool beginTransaction();
bool commitTransaction();
diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp
index 7017d6c..fa9b5f0 100644
--- a/src/sql/drivers/oci/qsql_oci.cpp
+++ b/src/sql/drivers/oci/qsql_oci.cpp
@@ -2098,7 +2098,7 @@ bool QOCIDriver::open(const QString & db,
setOpen(true);
setOpenError(false);
- d->user = user.toUpper();
+ d->user = user;
return true;
}
@@ -2200,8 +2200,15 @@ QStringList QOCIDriver::tables(QSql::TableType type) const
"and owner != 'WKSYS'"
"and owner != 'CTXSYS'"
"and owner != 'WMSYS'"));
+
+ QString user = d->user;
+ if ( isIdentifierEscaped(user, QSqlDriver::TableName))
+ user = stripDelimiters(user, QSqlDriver::TableName);
+ else
+ user = user.toUpper();
+
while (t.next()) {
- if (t.value(0).toString() != d->user)
+ if (t.value(0).toString() != user)
tl.append(t.value(0).toString() + QLatin1String(".") + t.value(1).toString());
else
tl.append(t.value(1).toString());
@@ -2237,10 +2244,10 @@ void qSplitTableAndOwner(const QString & tname, QString * tbl,
{
int i = tname.indexOf(QLatin1Char('.')); // prefixed with owner?
if (i != -1) {
- *tbl = tname.right(tname.length() - i - 1).toUpper();
- *owner = tname.left(i).toUpper();
+ *tbl = tname.right(tname.length() - i - 1);
+ *owner = tname.left(i);
} else {
- *tbl = tname.toUpper();
+ *tbl = tname;
}
}
@@ -2256,7 +2263,7 @@ QSqlRecord QOCIDriver::record(const QString& tablename) const
QString stmt(QLatin1String("select column_name, data_type, data_length, "
"data_precision, data_scale, nullable, data_default%1"
"from all_tab_columns "
- "where upper(table_name)=%2"));
+ "where table_name=%2"));
if (d->serverVersion >= 9)
stmt = stmt.arg(QLatin1String(", char_length "));
else
@@ -2264,11 +2271,23 @@ QSqlRecord QOCIDriver::record(const QString& tablename) const
bool buildRecordInfo = false;
QString table, owner, tmpStmt;
qSplitTableAndOwner(tablename, &table, &owner);
+
+ if (isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
+ else
+ table = table.toUpper();
+
tmpStmt = stmt.arg(QLatin1Char('\'') + table + QLatin1Char('\''));
if (owner.isEmpty()) {
owner = d->user;
}
- tmpStmt += QLatin1String(" and upper(owner)='") + owner + QLatin1String("'");
+
+ if (isIdentifierEscaped(owner, QSqlDriver::TableName))
+ owner = stripDelimiters(owner, QSqlDriver::TableName);
+ else
+ owner = owner.toUpper();
+
+ tmpStmt += QLatin1String(" and owner='") + owner + QLatin1String("'");
t.setForwardOnly(true);
t.exec(tmpStmt);
if (!t.next()) { // try and see if the tablename is a synonym
@@ -2317,11 +2336,23 @@ QSqlIndex QOCIDriver::primaryIndex(const QString& tablename) const
bool buildIndex = false;
QString table, owner, tmpStmt;
qSplitTableAndOwner(tablename, &table, &owner);
- tmpStmt = stmt + QLatin1String(" and upper(a.table_name)='") + table + QLatin1String("'");
+
+ if (isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
+ else
+ table = table.toUpper();
+
+ tmpStmt = stmt + QLatin1String(" and a.table_name='") + table + QLatin1String("'");
if (owner.isEmpty()) {
owner = d->user;
}
- tmpStmt += QLatin1String(" and upper(a.owner)='") + owner + QLatin1String("'");
+
+ if (isIdentifierEscaped(owner, QSqlDriver::TableName))
+ owner = stripDelimiters(owner, QSqlDriver::TableName);
+ else
+ owner = owner.toUpper();
+
+ tmpStmt += QLatin1String(" and a.owner='") + owner + QLatin1String("'");
t.setForwardOnly(true);
t.exec(tmpStmt);
@@ -2415,13 +2446,14 @@ QVariant QOCIDriver::handle() const
return qVariantFromValue(d->env);
}
-QString QOCIDriver::escapeIdentifier(const QString &identifier, IdentifierType /* type */) const
+QString QOCIDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const
{
QString res = identifier;
- res.replace(QLatin1Char('"'), QLatin1String("\"\""));
- if (identifier.indexOf(QLatin1Char(' ')) != -1)
+ if(!identifier.isEmpty() && !isIdentifierEscaped(identifier, type)) {
+ res.replace(QLatin1Char('"'), QLatin1String("\"\""));
res.prepend(QLatin1Char('"')).append(QLatin1Char('"'));
-// res.replace(QLatin1Char('.'), QLatin1String("\".\""));
+ res.replace(QLatin1Char('.'), QLatin1String("\".\""));
+ }
return res;
}
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index f6710db..2a83fe6 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -55,6 +55,7 @@
#include <qvarlengtharray.h>
#include <qvector.h>
#include <QDebug>
+#include <QSqlQuery>
QT_BEGIN_NAMESPACE
@@ -88,6 +89,7 @@ static const SQLSMALLINT qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL
class QODBCDriverPrivate
{
public:
+ enum DefaultCase{Lower, Mixed, Upper, Sensitive};
QODBCDriverPrivate()
: hEnv(0), hDbc(0), useSchema(false), disconnectCount(0), isMySqlServer(false),
isMSSqlServer(false), hasSQLFetchScroll(true), hasMultiResultSets(false)
@@ -119,6 +121,9 @@ public:
bool setConnectionOptions(const QString& connOpts);
void splitTableQualifier(const QString &qualifier, QString &catalog,
QString &schema, QString &table);
+ DefaultCase defaultCase() const;
+ QString adjustCase(const QString&) const;
+ QChar quoteChar() const;
};
class QODBCPrivate
@@ -350,7 +355,7 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni
} else {
fieldVal += QString::fromAscii(buf, rSize);
}
- if (fieldVal.size() + lengthIndicator >= colSize) {
+ if (lengthIndicator - fieldVal.size() <= 0) {
// workaround for Drivermanagers that don't return SQL_NO_DATA
break;
}
@@ -555,6 +560,29 @@ static int qGetODBCVersion(const QString &connOpts)
return SQL_OV_ODBC2;
}
+QChar QODBCDriverPrivate::quoteChar() const
+{
+ static bool isQuoteInitialized = false;
+ static QChar quote = QChar::fromLatin1('"');
+ if (!isQuoteInitialized) {
+ char driverResponse[4];
+ SQLUSMALLINT casing;
+ SQLSMALLINT length;
+ int r = SQLGetInfo(hDbc,
+ SQL_IDENTIFIER_QUOTE_CHAR,
+ &driverResponse,
+ sizeof(driverResponse),
+ &length);
+ if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
+ quote = QChar::fromLatin1(driverResponse[0]);
+ } else {
+ quote = QChar::fromLatin1('"');
+ }
+ isQuoteInitialized = true;
+ }
+ return quote;
+}
+
bool QODBCDriverPrivate::setConnectionOptions(const QString& connOpts)
{
// Set any connection attributes
@@ -705,6 +733,65 @@ void QODBCDriverPrivate::splitTableQualifier(const QString & qualifier, QString
}
}
+QODBCDriverPrivate::DefaultCase QODBCDriverPrivate::defaultCase() const
+{
+ static bool isInitialized = false;
+ static DefaultCase ret;
+
+ if (!isInitialized) {
+ SQLUSMALLINT casing;
+ int r = SQLGetInfo(hDbc,
+ SQL_IDENTIFIER_CASE,
+ &casing,
+ sizeof(casing),
+ NULL);
+ if ( r != SQL_SUCCESS)
+ ret = Lower;//arbitrary case if driver cannot be queried
+ else {
+ switch (casing) {
+ case (SQL_IC_UPPER):
+ ret = Upper;
+ break;
+ case (SQL_IC_LOWER):
+ ret = Lower;
+ break;
+ case (SQL_IC_SENSITIVE):
+ ret = Sensitive;
+ break;
+ case (SQL_IC_MIXED):
+ ret = Mixed;
+ break;
+ default:
+ ret = Upper;
+ }
+ }
+ isInitialized = true;
+ }
+ return ret;
+}
+
+/*
+ Adjust the casing of an identifier to match what the
+ database engine would have done to it.
+*/
+QString QODBCDriverPrivate::adjustCase(const QString &identifier) const
+{
+ QString ret = identifier;
+ switch(defaultCase()) {
+ case (Lower):
+ ret = identifier.toLower();
+ break;
+ case (Upper):
+ ret = identifier.toUpper();
+ break;
+ case(Mixed):
+ case(Sensitive):
+ default:
+ ret = identifier;
+ }
+ return ret;
+}
+
////////////////////////////////////////////////////////////////////////////
QODBCResult::QODBCResult(const QODBCDriver * db, QODBCDriverPrivate* p)
@@ -1714,6 +1801,10 @@ bool QODBCDriver::open(const QString & db,
d->checkHasMultiResults();
setOpen(true);
setOpenError(false);
+ if(d->isMSSqlServer) {
+ QSqlQuery i(createResult());
+ i.exec(QLatin1String("SET QUOTED_IDENTIFIER ON"));
+ }
return true;
}
@@ -2084,6 +2175,22 @@ QSqlIndex QODBCDriver::primaryIndex(const QString& tablename) const
}
QString catalog, schema, table;
d->splitTableQualifier(tablename, catalog, schema, table);
+
+ if (isIdentifierEscaped(catalog, QSqlDriver::TableName))
+ catalog = stripDelimiters(catalog, QSqlDriver::TableName);
+ else
+ catalog = d->adjustCase(catalog);
+
+ if (isIdentifierEscaped(schema, QSqlDriver::TableName))
+ schema = stripDelimiters(schema, QSqlDriver::TableName);
+ else
+ schema = d->adjustCase(schema);
+
+ if (isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
+ else
+ table = d->adjustCase(table);
+
r = SQLSetStmtAttr(hStmt,
SQL_ATTR_CURSOR_TYPE,
(SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
@@ -2186,6 +2293,22 @@ QSqlRecord QODBCDriver::record(const QString& tablename) const
SQLHANDLE hStmt;
QString catalog, schema, table;
d->splitTableQualifier(tablename, catalog, schema, table);
+
+ if (isIdentifierEscaped(catalog, QSqlDriver::TableName))
+ catalog = stripDelimiters(catalog, QSqlDriver::TableName);
+ else
+ catalog = d->adjustCase(catalog);
+
+ if (isIdentifierEscaped(schema, QSqlDriver::TableName))
+ schema = stripDelimiters(schema, QSqlDriver::TableName);
+ else
+ schema = d->adjustCase(schema);
+
+ if (isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
+ else
+ table = d->adjustCase(table);
+
SQLRETURN r = SQLAllocHandle(SQL_HANDLE_STMT,
d->hDbc,
&hStmt);
@@ -2309,4 +2432,15 @@ QString QODBCDriver::escapeIdentifier(const QString &identifier, IdentifierType)
return res;
}
+bool QODBCDriver::isIdentifierEscapedImplementation(const QString &identifier, IdentifierType) const
+{
+ QString quote = d->quoteChar();
+ bool isLeftDelimited = identifier.left(1) == quote;
+ bool isRightDelimited = identifier.right(1) == quote;
+ if( identifier.size() > 2 && isLeftDelimited && isRightDelimited )
+ return true;
+ else
+ return false;
+}
+
QT_END_NAMESPACE
diff --git a/src/sql/drivers/odbc/qsql_odbc.h b/src/sql/drivers/odbc/qsql_odbc.h
index 4148007..51f53ea 100644
--- a/src/sql/drivers/odbc/qsql_odbc.h
+++ b/src/sql/drivers/odbc/qsql_odbc.h
@@ -145,10 +145,14 @@ public:
QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
+protected Q_SLOTS:
+ bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const;
+
protected:
bool beginTransaction();
bool commitTransaction();
bool rollbackTransaction();
+
private:
void init();
bool endTrans();
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index e33dd95..16d19f1 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -351,8 +351,9 @@ QVariant QPSQLResult::data(int i)
#ifndef QT_NO_DATESTRING
if (str.isEmpty())
return QVariant(QTime());
- if (str.at(str.length() - 3) == QLatin1Char('+'))
+ if (str.at(str.length() - 3) == QLatin1Char('+') || str.at(str.length() - 3) == QLatin1Char('-'))
// strip the timezone
+ // TODO: fix this when timestamp support comes into QDateTime
return QVariant(QTime::fromString(str.left(str.length() - 3), Qt::ISODate));
return QVariant(QTime::fromString(str, Qt::ISODate));
#else
@@ -365,7 +366,8 @@ QVariant QPSQLResult::data(int i)
if (dtval.length() < 10)
return QVariant(QDateTime());
// remove the timezone
- if (dtval.at(dtval.length() - 3) == QLatin1Char('+'))
+ // TODO: fix this when timestamp support comes into QDateTime
+ if (dtval.at(dtval.length() - 3) == QLatin1Char('+') || dtval.at(dtval.length() - 3) == QLatin1Char('-'))
dtval.chop(3);
// milliseconds are sometimes returned with 2 digits only
if (dtval.at(dtval.length() - 3).isPunct())
@@ -892,6 +894,16 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const
QString schema;
qSplitTableName(tbl, schema);
+ if (isIdentifierEscaped(tbl, QSqlDriver::TableName))
+ tbl = stripDelimiters(tbl, QSqlDriver::TableName);
+ else
+ tbl = tbl.toLower();
+
+ if (isIdentifierEscaped(schema, QSqlDriver::TableName))
+ schema = stripDelimiters(schema, QSqlDriver::TableName);
+ else
+ schema = schema.toLower();
+
switch(d->pro) {
case QPSQLDriver::Version6:
stmt = QLatin1String("select pg_att1.attname, int(pg_att1.atttypid), pg_cl.relname "
@@ -924,7 +936,7 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const
"FROM pg_attribute, pg_class "
"WHERE %1 pg_class.oid IN "
"(SELECT indexrelid FROM pg_index WHERE indisprimary = true AND indrelid IN "
- " (SELECT oid FROM pg_class WHERE lower(relname) = '%2')) "
+ " (SELECT oid FROM pg_class WHERE relname = '%2')) "
"AND pg_attribute.attrelid = pg_class.oid "
"AND pg_attribute.attisdropped = false "
"ORDER BY pg_attribute.attnum");
@@ -932,11 +944,11 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const
stmt = stmt.arg(QLatin1String("pg_table_is_visible(pg_class.oid) AND"));
else
stmt = stmt.arg(QString::fromLatin1("pg_class.relnamespace = (select oid from "
- "pg_namespace where pg_namespace.nspname = '%1') AND ").arg(schema.toLower()));
+ "pg_namespace where pg_namespace.nspname = '%1') AND ").arg(schema));
break;
}
- i.exec(stmt.arg(tbl.toLower()));
+ i.exec(stmt.arg(tbl));
while (i.isActive() && i.next()) {
QSqlField f(i.value(0).toString(), qDecodePSQLType(i.value(1).toInt()));
idx.append(f);
@@ -955,6 +967,16 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const
QString schema;
qSplitTableName(tbl, schema);
+ if (isIdentifierEscaped(tbl, QSqlDriver::TableName))
+ tbl = stripDelimiters(tbl, QSqlDriver::TableName);
+ else
+ tbl = tbl.toLower();
+
+ if (isIdentifierEscaped(schema, QSqlDriver::TableName))
+ schema = stripDelimiters(schema, QSqlDriver::TableName);
+ else
+ schema = schema.toLower();
+
QString stmt;
switch(d->pro) {
case QPSQLDriver::Version6:
@@ -999,7 +1021,7 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const
"left join pg_attrdef on (pg_attrdef.adrelid = "
"pg_attribute.attrelid and pg_attrdef.adnum = pg_attribute.attnum) "
"where %1 "
- "and lower(pg_class.relname) = '%2' "
+ "and pg_class.relname = '%2' "
"and pg_attribute.attnum > 0 "
"and pg_attribute.attrelid = pg_class.oid "
"and pg_attribute.attisdropped = false "
@@ -1008,12 +1030,12 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const
stmt = stmt.arg(QLatin1String("pg_table_is_visible(pg_class.oid)"));
else
stmt = stmt.arg(QString::fromLatin1("pg_class.relnamespace = (select oid from "
- "pg_namespace where pg_namespace.nspname = '%1')").arg(schema.toLower()));
+ "pg_namespace where pg_namespace.nspname = '%1')").arg(schema));
break;
}
QSqlQuery query(createResult());
- query.exec(stmt.arg(tbl.toLower()));
+ query.exec(stmt.arg(tbl));
if (d->pro >= QPSQLDriver::Version71) {
while (query.next()) {
int len = query.value(3).toInt();
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp
index 605c4e8..f732077 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite.cpp
+++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp
@@ -661,9 +661,13 @@ QSqlIndex QSQLiteDriver::primaryIndex(const QString &tblname) const
if (!isOpen())
return QSqlIndex();
+ QString table = tblname;
+ if (isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
+
QSqlQuery q(createResult());
q.setForwardOnly(true);
- return qGetTableInfo(q, tblname, true);
+ return qGetTableInfo(q, table, true);
}
QSqlRecord QSQLiteDriver::record(const QString &tbl) const
@@ -671,9 +675,13 @@ QSqlRecord QSQLiteDriver::record(const QString &tbl) const
if (!isOpen())
return QSqlRecord();
+ QString table = tbl;
+ if (isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
+
QSqlQuery q(createResult());
q.setForwardOnly(true);
- return qGetTableInfo(q, tbl);
+ return qGetTableInfo(q, table);
}
QVariant QSQLiteDriver::handle() const
@@ -681,10 +689,10 @@ QVariant QSQLiteDriver::handle() const
return qVariantFromValue(d->access);
}
-QString QSQLiteDriver::escapeIdentifier(const QString &identifier, IdentifierType /*type*/) const
+QString QSQLiteDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const
{
QString res = identifier;
- if(!identifier.isEmpty() && identifier.left(1) != QString(QLatin1Char('"')) && identifier.right(1) != QString(QLatin1Char('"')) ) {
+ if(!identifier.isEmpty() && !isIdentifierEscaped(identifier, type) ) {
res.replace(QLatin1Char('"'), QLatin1String("\"\""));
res.prepend(QLatin1Char('"')).append(QLatin1Char('"'));
res.replace(QLatin1Char('.'), QLatin1String("\".\""));
diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp
index ff73caa..d0c6e18 100644
--- a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp
+++ b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp
@@ -167,7 +167,15 @@ void QSQLite2ResultPrivate::init(const char **cnames, int numCols)
for (int i = 0; i < numCols; ++i) {
const char* lastDot = strrchr(cnames[i], '.');
const char* fieldName = lastDot ? lastDot + 1 : cnames[i];
- rInf.append(QSqlField(QString::fromAscii(fieldName),
+
+ //remove quotations around the field name if any
+ QString fieldStr = QString::fromAscii(fieldName);
+ QString quote = QString::fromLatin1("\"");
+ if ( fieldStr.length() > 2 && fieldStr.left(1) == quote && fieldStr.right(1) == quote) {
+ fieldStr = fieldStr.mid(1);
+ fieldStr.chop(1);
+ }
+ rInf.append(QSqlField(fieldStr,
nameToType(QString::fromAscii(cnames[i+numCols]))));
}
}
@@ -503,8 +511,11 @@ QSqlIndex QSQLite2Driver::primaryIndex(const QString &tblname) const
QSqlQuery q(createResult());
q.setForwardOnly(true);
+ QString table = tblname;
+ if (isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
// finrst find a UNIQUE INDEX
- q.exec(QLatin1String("PRAGMA index_list('") + tblname + QLatin1String("');"));
+ q.exec(QLatin1String("PRAGMA index_list('") + table + QLatin1String("');"));
QString indexname;
while(q.next()) {
if (q.value(2).toInt()==1) {
@@ -517,7 +528,7 @@ QSqlIndex QSQLite2Driver::primaryIndex(const QString &tblname) const
q.exec(QLatin1String("PRAGMA index_info('") + indexname + QLatin1String("');"));
- QSqlIndex index(tblname, indexname);
+ QSqlIndex index(table, indexname);
while(q.next()) {
QString name = q.value(2).toString();
QVariant::Type type = QVariant::Invalid;
@@ -532,6 +543,9 @@ QSqlRecord QSQLite2Driver::record(const QString &tbl) const
{
if (!isOpen())
return QSqlRecord();
+ QString table = tbl;
+ if (isIdentifierEscaped(tbl, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
QSqlQuery q(createResult());
q.setForwardOnly(true);
diff --git a/src/sql/drivers/tds/qsql_tds.cpp b/src/sql/drivers/tds/qsql_tds.cpp
index 46e4a0b..515f0de 100644
--- a/src/sql/drivers/tds/qsql_tds.cpp
+++ b/src/sql/drivers/tds/qsql_tds.cpp
@@ -293,6 +293,8 @@ QTDSResult::QTDSResult(const QTDSDriver* db)
// insert d in error handler dict
errs()->insert(d->dbproc, d);
+ dbcmd(d->dbproc, "set quoted_identifier on");
+ dbsqlexec(d->dbproc);
}
QTDSResult::~QTDSResult()
@@ -367,7 +369,7 @@ bool QTDSResult::gotoNext(QSqlCachedResult::ValueCache &values, int index)
if (qIsNull(d->buffer.at(i * 2 + 1)))
values[idx] = QVariant(QVariant::String);
else
- values[idx] = QString::fromLocal8Bit((const char*)d->buffer.at(i * 2));
+ values[idx] = QString::fromLocal8Bit((const char*)d->buffer.at(i * 2)).trimmed();
break;
case QVariant::ByteArray: {
if (qIsNull(d->buffer.at(i * 2 + 1)))
@@ -698,9 +700,14 @@ QSqlRecord QTDSDriver::record(const QString& tablename) const
return info;
QSqlQuery t(createResult());
t.setForwardOnly(true);
+
+ QString table = tablename;
+ if (isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
+
QString stmt (QLatin1String("select name, type, length, prec from syscolumns "
"where id = (select id from sysobjects where name = '%1')"));
- t.exec(stmt.arg(tablename));
+ t.exec(stmt.arg(table));
while (t.next()) {
QSqlField f(t.value(0).toString().simplified(), qDecodeTDSType(t.value(1).toInt()));
f.setLength(t.value(2).toInt());
@@ -770,13 +777,17 @@ QSqlIndex QTDSDriver::primaryIndex(const QString& tablename) const
{
QSqlRecord rec = record(tablename);
- QSqlIndex idx(tablename);
- if ((!isOpen()) || (tablename.isEmpty()))
+ QString table = tablename;
+ if (isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = stripDelimiters(table, QSqlDriver::TableName);
+
+ QSqlIndex idx(table);
+ if ((!isOpen()) || (table.isEmpty()))
return QSqlIndex();
QSqlQuery t(createResult());
t.setForwardOnly(true);
- t.exec(QString::fromLatin1("sp_helpindex '%1'").arg(tablename));
+ t.exec(QString::fromLatin1("sp_helpindex '%1'").arg(table));
if (t.next()) {
QStringList fNames = t.value(2).toString().simplified().split(QLatin1Char(','));
QRegExp regx(QLatin1String("\\s*(\\S+)(?:\\s+(DESC|desc))?\\s*"));
diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp
index ddebe45..40bc0df 100644
--- a/src/sql/kernel/qsqldriver.cpp
+++ b/src/sql/kernel/qsqldriver.cpp
@@ -49,6 +49,17 @@
QT_BEGIN_NAMESPACE
+static QString prepareIdentifier(const QString &identifier,
+ QSqlDriver::IdentifierType type, const QSqlDriver *driver)
+{
+ Q_ASSERT( driver != NULL );
+ QString ret = identifier;
+ if (!driver->isIdentifierEscaped(identifier, type)) {
+ ret = driver->escapeIdentifier(identifier, type);
+ }
+ return ret;
+}
+
class QSqlDriverPrivate : public QObjectPrivate
{
public:
@@ -372,6 +383,7 @@ QSqlRecord QSqlDriver::record(const QString & /* tableName */) const
on \a type.
The default implementation does nothing.
+ \sa isIdentifierEscaped()
*/
QString QSqlDriver::escapeIdentifier(const QString &identifier, IdentifierType) const
{
@@ -379,6 +391,55 @@ QString QSqlDriver::escapeIdentifier(const QString &identifier, IdentifierType)
}
/*!
+ Returns whether \a identifier is escaped according to the database rules.
+ \a identifier can either be a table name or field name, dependent
+ on \a type.
+
+ \warning Because of binary compatability constraints, this function is not virtual.
+ If you want to provide your own implementation in your QSqlDriver subclass,
+ reimplement the isIdentifierEscapedImplementation() slot in your subclass instead.
+ The isIdentifierEscapedFunction() will dynamically detect the slot and call it.
+
+ \sa stripDelimiters(), escapeIdentifier()
+ */
+bool QSqlDriver::isIdentifierEscaped(const QString &identifier, IdentifierType type) const
+{
+ bool result;
+ QMetaObject::invokeMethod(const_cast<QSqlDriver*>(this),
+ "isIdentifierEscapedImplementation", Qt::DirectConnection,
+ Q_RETURN_ARG(bool, result),
+ Q_ARG(QString, identifier),
+ Q_ARG(IdentifierType, type));
+ return result;
+}
+
+/*!
+ Returns the \a identifier with the leading and trailing delimiters removed,
+ \a identifier can either be a table name or field name,
+ dependent on \a type. If \a identifier does not have leading
+ and trailing delimiter characters, \a identifier is returned without
+ modification.
+
+ \warning Because of binary compatability constraints, this function is not virtual,
+ If you want to provide your own implementation in your QSqlDriver subclass,
+ reimplement the stripDelimitersImplementation() slot in your subclass instead.
+ The stripDelimiters() function will dynamically detect the slot and call it.
+
+ \since 4.5
+ \sa isIdentifierEscaped()
+ */
+QString QSqlDriver::stripDelimiters(const QString &identifier, IdentifierType type) const
+{
+ QString result;
+ QMetaObject::invokeMethod(const_cast<QSqlDriver*>(this),
+ "stripDelimitersImplementation", Qt::DirectConnection,
+ Q_RETURN_ARG(QString, result),
+ Q_ARG(QString, identifier),
+ Q_ARG(IdentifierType, type));
+ return result;
+}
+
+/*!
Returns a SQL statement of type \a type for the table \a tableName
with the values from \a rec. If \a preparedStatement is true, the
string will contain placeholders instead of values.
@@ -397,21 +458,26 @@ QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName,
case SelectStatement:
for (i = 0; i < rec.count(); ++i) {
if (rec.isGenerated(i))
- s.append(escapeIdentifier(rec.fieldName(i), FieldName)).append(QLatin1String(", "));
+ s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1String(", "));
}
if (s.isEmpty())
return s;
s.chop(2);
- s.prepend(QLatin1String("SELECT ")).append(QLatin1String(" FROM ")).append(escapeIdentifier(tableName, TableName));
+ s.prepend(QLatin1String("SELECT ")).append(QLatin1String(" FROM ")).append(tableName);
break;
case WhereStatement:
if (preparedStatement) {
- for (int i = 0; i < rec.count(); ++i)
- s.append(escapeIdentifier(rec.fieldName(i), FieldName)).append(
- QLatin1String(" = ? AND "));
+ for (int i = 0; i < rec.count(); ++i) {
+ s.append(prepareIdentifier(rec.fieldName(i), FieldName,this));
+ if (rec.isNull(i))
+ s.append(QLatin1String(" IS NULL"));
+ else
+ s.append(QLatin1String(" = ?"));
+ s.append(QLatin1String(" AND "));
+ }
} else {
for (i = 0; i < rec.count(); ++i) {
- s.append(escapeIdentifier(rec.fieldName(i), FieldName));
+ s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this));
QString val = formatValue(rec.field(i));
if (val == QLatin1String("NULL"))
s.append(QLatin1String(" IS NULL"));
@@ -426,12 +492,12 @@ QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName,
}
break;
case UpdateStatement:
- s.append(QLatin1String("UPDATE ")).append(escapeIdentifier(tableName, TableName)).append(
+ s.append(QLatin1String("UPDATE ")).append(tableName).append(
QLatin1String(" SET "));
for (i = 0; i < rec.count(); ++i) {
if (!rec.isGenerated(i) || !rec.value(i).isValid())
continue;
- s.append(escapeIdentifier(rec.fieldName(i), FieldName)).append(QLatin1Char('='));
+ s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1Char('='));
if (preparedStatement)
s.append(QLatin1Char('?'));
else
@@ -444,15 +510,15 @@ QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName,
s.clear();
break;
case DeleteStatement:
- s.append(QLatin1String("DELETE FROM ")).append(escapeIdentifier(tableName, TableName));
+ s.append(QLatin1String("DELETE FROM ")).append(tableName);
break;
case InsertStatement: {
- s.append(QLatin1String("INSERT INTO ")).append(escapeIdentifier(tableName, TableName)).append(QLatin1String(" ("));
+ s.append(QLatin1String("INSERT INTO ")).append(tableName).append(QLatin1String(" ("));
QString vals;
for (i = 0; i < rec.count(); ++i) {
if (!rec.isGenerated(i) || !rec.value(i).isValid())
continue;
- s.append(escapeIdentifier(rec.fieldName(i), FieldName)).append(QLatin1String(", "));
+ s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1String(", "));
if (preparedStatement)
vals.append(QLatin1String("?"));
else
@@ -800,4 +866,56 @@ QStringList QSqlDriver::subscribedToNotificationsImplementation() const
return QStringList();
}
+/*!
+ This slot returns whether \a identifier is escaped according to the database rules.
+ \a identifier can either be a table name or field name, dependent
+ on \a type.
+
+ Because of binary compatability constraints, isIdentifierEscaped() function
+ (introduced in Qt 4.5) is not virtual. Instead, isIdentifierEscaped() will
+ dynamically detect and call \e this slot. The default implementation
+ assumes the escape/delimiter character is a double quote. Reimplement this
+ slot in your own QSqlDriver if your database engine uses a different
+ delimiter character.
+
+ \since 4.5
+ \sa isIdentifierEscaped()
+ */
+bool QSqlDriver::isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const
+{
+ Q_UNUSED(type);
+ bool isLeftDelimited = identifier.left(1) == QString(QLatin1Char('"'));
+ bool isRightDelimited = identifier.right(1) == QString(QLatin1Char('"'));
+ if( identifier.size() > 2 && isLeftDelimited && isRightDelimited )
+ return true;
+ else
+ return false;
+}
+
+/*!
+ This slot returns \a identifier with the leading and trailing delimiters removed,
+ \a identifier can either be a tablename or field name, dependent on \a type.
+ If \a identifier does not have leading and trailing delimiter characters, \a
+ identifier is returned without modification.
+
+ Because of binary compatability constraints, the stripDelimiters() function
+ (introduced in Qt 4.5) is not virtual. Instead, stripDelimiters() will
+ dynamically detect and call \e this slot. It generally unnecessary
+ to reimplement this slot.
+
+ \since 4.5
+ \sa stripDelimiters()
+ */
+QString QSqlDriver::stripDelimitersImplementation(const QString &identifier, IdentifierType type) const
+{
+ QString ret;
+ if (this->isIdentifierEscaped(identifier, type)) {
+ ret = identifier.mid(1);
+ ret.chop(1);
+ } else {
+ ret = identifier;
+ }
+ return ret;
+}
+
QT_END_NAMESPACE
diff --git a/src/sql/kernel/qsqldriver.h b/src/sql/kernel/qsqldriver.h
index e763719..8ac1471 100644
--- a/src/sql/kernel/qsqldriver.h
+++ b/src/sql/kernel/qsqldriver.h
@@ -127,6 +127,9 @@ public:
bool unsubscribeFromNotification(const QString &name); // ### Qt 5: make virtual
QStringList subscribedToNotifications() const; // ### Qt 5: make virtual
+ bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const; // ### Qt 5: make virtual
+ QString stripDelimiters(const QString &identifier, IdentifierType type) const; // ### Qt 5: make virtual
+
Q_SIGNALS:
void notification(const QString &name);
@@ -140,6 +143,9 @@ protected Q_SLOTS:
bool unsubscribeFromNotificationImplementation(const QString &name); // ### Qt 5: eliminate, see unsubscribeFromNotification()
QStringList subscribedToNotificationsImplementation() const; // ### Qt 5: eliminate, see subscribedNotifications()
+ bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const; // ### Qt 5: eliminate, see isIdentifierEscaped()
+ QString stripDelimitersImplementation(const QString &identifier, IdentifierType type) const; // ### Qt 5: eliminate, see stripDelimiters()
+
private:
Q_DISABLE_COPY(QSqlDriver)
};
diff --git a/src/sql/models/qsqlrelationaltablemodel.cpp b/src/sql/models/qsqlrelationaltablemodel.cpp
index 935466b..12eae84 100644
--- a/src/sql/models/qsqlrelationaltablemodel.cpp
+++ b/src/sql/models/qsqlrelationaltablemodel.cpp
@@ -182,10 +182,21 @@ void QRelation::populateDictionary()
populateModel();
QSqlRecord record;
+ QString indexColumn;
+ QString displayColumn;
for (int i=0; i < model->rowCount(); ++i) {
record = model->record(i);
- dictionary[record.field(rel.indexColumn()).value().toString()] =
- record.field(rel.displayColumn()).value();
+
+ indexColumn = rel.indexColumn();
+ if (m_parent->database().driver()->isIdentifierEscaped(indexColumn, QSqlDriver::FieldName))
+ indexColumn = m_parent->database().driver()->stripDelimiters(indexColumn, QSqlDriver::FieldName);
+
+ displayColumn = rel.displayColumn();
+ if (m_parent->database().driver()->isIdentifierEscaped(displayColumn, QSqlDriver::FieldName))
+ displayColumn = m_parent->database().driver()->stripDelimiters(displayColumn, QSqlDriver::FieldName);
+
+ dictionary[record.field(indexColumn).value().toString()] =
+ record.field(displayColumn).value();
}
m_dictInitialized = true;
}
@@ -215,7 +226,7 @@ public:
QSqlRelationalTableModelPrivate()
: QSqlTableModelPrivate()
{}
- QString escapedRelationField(const QString &tableName, const QString &fieldName) const;
+ QString relationField(const QString &tableName, const QString &fieldName) const;
int nameToIndex(const QString &name) const;
mutable QVector<QRelation> relations;
@@ -255,7 +266,10 @@ void QSqlRelationalTableModelPrivate::revertCachedRow(int row)
int QSqlRelationalTableModelPrivate::nameToIndex(const QString &name) const
{
- return baseRec.indexOf(name);
+ QString fieldname = name;
+ if (db.driver()->isIdentifierEscaped(fieldname, QSqlDriver::FieldName))
+ fieldname = db.driver()->stripDelimiters(fieldname, QSqlDriver::FieldName);
+ return baseRec.indexOf(fieldname);
}
void QSqlRelationalTableModelPrivate::clearEditBuffer()
@@ -481,14 +495,14 @@ QSqlRelation QSqlRelationalTableModel::relation(int column) const
return d->relations.value(column).rel;
}
-QString QSqlRelationalTableModelPrivate::escapedRelationField(const QString &tableName,
+QString QSqlRelationalTableModelPrivate::relationField(const QString &tableName,
const QString &fieldName) const
{
- QString esc;
- esc.reserve(tableName.size() + fieldName.size() + 1);
- esc.append(tableName).append(QLatin1Char('.')).append(fieldName);
+ QString ret;
+ ret.reserve(tableName.size() + fieldName.size() + 1);
+ ret.append(tableName).append(QLatin1Char('.')).append(fieldName);
- return db.driver()->escapeIdentifier(esc, QSqlDriver::FieldName);
+ return ret;
}
/*!
@@ -514,15 +528,29 @@ QString QSqlRelationalTableModel::selectStatement() const
// Count how many times each field name occurs in the record
QHash<QString, int> fieldNames;
+ QStringList fieldList;
for (int i = 0; i < rec.count(); ++i) {
QSqlRelation relation = d->relations.value(i, nullRelation).rel;
QString name;
if (relation.isValid())
+ {
// Count the display column name, not the original foreign key
name = relation.displayColumn();
+ if (d->db.driver()->isIdentifierEscaped(name, QSqlDriver::FieldName))
+ name = d->db.driver()->stripDelimiters(name, QSqlDriver::FieldName);
+
+ QSqlRecord rec = database().record(relation.tableName());
+ for (int i = 0; i < rec.count(); ++i) {
+ if (name.compare(rec.fieldName(i), Qt::CaseInsensitive) == 0) {
+ name = rec.fieldName(i);
+ break;
+ }
+ }
+ }
else
name = rec.fieldName(i);
fieldNames.insert(name, fieldNames.value(name, 0) + 1);
+ fieldList.append(name);
}
for (int i = 0; i < rec.count(); ++i) {
@@ -531,27 +559,30 @@ QString QSqlRelationalTableModel::selectStatement() const
QString relTableAlias = QString::fromLatin1("relTblAl_%1").arg(i);
if (!fList.isEmpty())
fList.append(QLatin1String(", "));
- fList.append(d->escapedRelationField(relTableAlias, relation.displayColumn()));
+ fList.append(d->relationField(relTableAlias,relation.displayColumn()));
// If there are duplicate field names they must be aliased
- if (fieldNames.value(relation.displayColumn()) > 1) {
- fList.append(QString::fromLatin1(" AS %1_%2").arg(relation.tableName()).arg(relation.displayColumn()));
+ if (fieldNames.value(fieldList[i]) > 1) {
+ QString relTableName = relation.tableName();
+ if (d->db.driver()->isIdentifierEscaped(relTableName, QSqlDriver::TableName))
+ relTableName = d->db.driver()->stripDelimiters(relTableName, QSqlDriver::TableName);
+ QString displayColumn = relation.displayColumn();
+ if (d->db.driver()->isIdentifierEscaped(displayColumn, QSqlDriver::FieldName))
+ displayColumn = d->db.driver()->stripDelimiters(displayColumn, QSqlDriver::FieldName);
+ fList.append(QString::fromLatin1(" AS %1_%2").arg(relTableName).arg(displayColumn));
}
// this needs fixing!! the below if is borken.
- if (!tables.contains(relation.tableName()))
- tables.append(d->db.driver()->escapeIdentifier(relation.tableName(),QSqlDriver::TableName)
- .append(QLatin1String(" "))
- .append(d->db.driver()->escapeIdentifier(relTableAlias, QSqlDriver::TableName)));
+ tables.append(relation.tableName().append(QLatin1String(" ")).append(relTableAlias));
if(!where.isEmpty())
where.append(QLatin1String(" AND "));
- where.append(d->escapedRelationField(tableName(), rec.fieldName(i)));
+ where.append(d->relationField(tableName(), d->db.driver()->escapeIdentifier(rec.fieldName(i), QSqlDriver::FieldName)));
where.append(QLatin1String(" = "));
- where.append(d->escapedRelationField(relTableAlias, relation.indexColumn()));
+ where.append(d->relationField(relTableAlias, relation.indexColumn()));
} else {
if (!fList.isEmpty())
fList.append(QLatin1String(", "));
- fList.append(d->escapedRelationField(tableName(), rec.fieldName(i)));
+ fList.append(d->relationField(tableName(), d->db.driver()->escapeIdentifier(rec.fieldName(i), QSqlDriver::FieldName)));
}
}
if (!tables.isEmpty())
@@ -560,7 +591,7 @@ QString QSqlRelationalTableModel::selectStatement() const
return query;
if(!tList.isEmpty())
tList.prepend(QLatin1String(", "));
- tList.prepend(d->db.driver()->escapeIdentifier(tableName(),QSqlDriver::TableName));
+ tList.prepend(tableName());
query.append(QLatin1String("SELECT "));
query.append(fList).append(QLatin1String(" FROM ")).append(tList);
qAppendWhereClause(query, where, filter());
@@ -690,7 +721,7 @@ QString QSqlRelationalTableModel::orderByClause() const
return QSqlTableModel::orderByClause();
QString s = QLatin1String("ORDER BY ");
- s.append(d->escapedRelationField(QLatin1String("relTblAl_") + QString::number(d->sortColumn),
+ s.append(d->relationField(QLatin1String("relTblAl_") + QString::number(d->sortColumn),
rel.displayColumn()));
s += d->sortOrder == Qt::AscendingOrder ? QLatin1String(" ASC") : QLatin1String(" DESC");
return s;
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index 2fb9b0f..c2442c5 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -98,7 +98,10 @@ bool QSqlTableModelPrivate::setRecord(int row, const QSqlRecord &record)
int QSqlTableModelPrivate::nameToIndex(const QString &name) const
{
- return rec.indexOf(name);
+ QString fieldname = name;
+ if (db.driver()->isIdentifierEscaped(fieldname, QSqlDriver::FieldName))
+ fieldname = db.driver()->stripDelimiters(fieldname, QSqlDriver::FieldName);
+ return rec.indexOf(fieldname);
}
void QSqlTableModelPrivate::initRecordAndPrimaryIndex()
@@ -367,10 +370,7 @@ void QSqlTableModel::setTable(const QString &tableName)
{
Q_D(QSqlTableModel);
clear();
- if(d->db.tables().contains(tableName.toUpper()))
- d->tableName = tableName.toUpper();
- else
- d->tableName = tableName;
+ d->tableName = tableName;
d->initRecordAndPrimaryIndex();
d->initColOffsets(d->rec.count());
@@ -976,7 +976,9 @@ QString QSqlTableModel::orderByClause() const
if (!f.isValid())
return s;
- QString table = d->db.driver()->escapeIdentifier(d->tableName, QSqlDriver::TableName);
+ QString table = d->tableName;
+ //we can safely escape the field because it would have been obtained from the database
+ //and have the correct case
QString field = d->db.driver()->escapeIdentifier(f.name(), QSqlDriver::FieldName);
s.append(QLatin1String("ORDER BY ")).append(table).append(QLatin1Char('.')).append(field);
s += d->sortOrder == Qt::AscendingOrder ? QLatin1String(" ASC") : QLatin1String(" DESC");
@@ -1317,8 +1319,12 @@ bool QSqlTableModel::setRecord(int row, const QSqlRecord &record)
mrow.rec = d->rec;
mrow.primaryValues = d->primaryValues(indexInQuery(createIndex(row, 0)).row());
}
+ QString fieldName;
for (int i = 0; i < record.count(); ++i) {
- int idx = mrow.rec.indexOf(record.fieldName(i));
+ fieldName = record.fieldName(i);
+ if (d->db.driver()->isIdentifierEscaped(fieldName, QSqlDriver::FieldName))
+ fieldName = d->db.driver()->stripDelimiters(fieldName, QSqlDriver::FieldName);
+ int idx = mrow.rec.indexOf(fieldName);
if (idx == -1)
isOk = false;
else
diff --git a/src/svg/qgraphicssvgitem.cpp b/src/svg/qgraphicssvgitem.cpp
index e17df03..a14636e 100644
--- a/src/svg/qgraphicssvgitem.cpp
+++ b/src/svg/qgraphicssvgitem.cpp
@@ -186,7 +186,7 @@ static void qt_graphicsItem_highlightSelected(
QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option)
{
const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1));
- if (qFuzzyCompare(qMax(murect.width(), murect.height()) + 1, 1))
+ if (qFuzzyIsNull(qMax(murect.width(), murect.height())))
return;
const QRectF mbrect = painter->transform().mapRect(item->boundingRect());
diff --git a/src/svg/qsvggenerator.cpp b/src/svg/qsvggenerator.cpp
index f7b2ae8..2b5fbd5 100644
--- a/src/svg/qsvggenerator.cpp
+++ b/src/svg/qsvggenerator.cpp
@@ -516,7 +516,34 @@ public:
\brief The QSvgGenerator class provides a paint device that is used to create SVG drawings.
\reentrant
- \sa QSvgRenderer, QSvgWidget
+ This paint device represents a Scalable Vector Graphics (SVG) drawing. Like QPrinter, it is
+ designed as a write-only device that generates output in a specific format.
+
+ To write an SVG file, you first need to configure the output by setting the \l fileName
+ or \l outputDevice properties. It is usually necessary to specify the size of the drawing
+ by setting the \l size property, and in some cases where the drawing will be included in
+ another, the \l viewBox property also needs to be set.
+
+ \snippet examples/painting/svggenerator/window.cpp configure SVG generator
+
+ Other meta-data can be specified by setting the \a title, \a description and \a resolution
+ properties.
+
+ As with other QPaintDevice subclasses, a QPainter object is used to paint onto an instance
+ of this class:
+
+ \snippet examples/painting/svggenerator/window.cpp begin painting
+ \dots
+ \snippet examples/painting/svggenerator/window.cpp end painting
+
+ Painting is performed in the same way as for any other paint device. However,
+ it is necessary to use the QPainter::begin() and \l{QPainter::}{end()} to
+ explicitly begin and end painting on the device.
+
+ The \l{SVG Generator Example} shows how the same painting commands can be used
+ for painting a widget and writing an SVG file.
+
+ \sa QSvgRenderer, QSvgWidget, {About SVG}
*/
/*!
@@ -944,7 +971,7 @@ void QSvgPaintEngine::updateState(const QPaintEngineState &state)
}
if (flags & QPaintEngine::DirtyOpacity) {
- if (!qFuzzyCompare(state.opacity(), 1))
+ if (!qFuzzyIsNull(state.opacity() - 1))
stream() << "opacity=\""<<state.opacity()<<"\" ";
}
diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp
index 9ff9c26..1cd1f8b 100644
--- a/src/svg/qsvggraphics.cpp
+++ b/src/svg/qsvggraphics.cpp
@@ -94,7 +94,7 @@ QSvgCircle::QSvgCircle(QSvgNode *parent, const QRectF &rect)
QRectF QSvgCircle::bounds() const
{
qreal sw = strokeWidth();
- if (qFuzzyCompare(sw + 1, 1))
+ if (qFuzzyIsNull(sw))
return m_bounds;
else {
QPainterPath path;
@@ -129,7 +129,7 @@ QSvgEllipse::QSvgEllipse(QSvgNode *parent, const QRectF &rect)
QRectF QSvgEllipse::bounds() const
{
qreal sw = strokeWidth();
- if (qFuzzyCompare(sw + 1, 1))
+ if (qFuzzyIsNull(sw))
return m_bounds;
else {
QPainterPath path;
@@ -190,7 +190,7 @@ void QSvgPath::draw(QPainter *p, QSvgExtraStates &states)
QRectF QSvgPath::bounds() const
{
qreal sw = strokeWidth();
- if (qFuzzyCompare(sw + 1, 1))
+ if (qFuzzyIsNull(sw))
return m_cachedBounds;
else {
return boundsOnStroke(m_path, sw);
@@ -206,7 +206,7 @@ QSvgPolygon::QSvgPolygon(QSvgNode *parent, const QPolygonF &poly)
QRectF QSvgPolygon::bounds() const
{
qreal sw = strokeWidth();
- if (qFuzzyCompare(sw + 1, 1))
+ if (qFuzzyIsNull(sw))
return m_poly.boundingRect();
else {
QPainterPath path;
@@ -249,7 +249,7 @@ QSvgRect::QSvgRect(QSvgNode *node, const QRectF &rect, int rx, int ry)
QRectF QSvgRect::bounds() const
{
qreal sw = strokeWidth();
- if (qFuzzyCompare(sw + 1, 1))
+ if (qFuzzyIsNull(sw))
return m_rect;
else {
QPainterPath path;
@@ -596,7 +596,7 @@ QRectF QSvgUse::transformedBounds(const QTransform &transform) const
QRectF QSvgPolyline::bounds() const
{
qreal sw = strokeWidth();
- if (qFuzzyCompare(sw + 1, 1))
+ if (qFuzzyIsNull(sw))
return m_poly.boundingRect();
else {
QPainterPath path;
@@ -608,7 +608,7 @@ QRectF QSvgPolyline::bounds() const
QRectF QSvgArc::bounds() const
{
qreal sw = strokeWidth();
- if (qFuzzyCompare(sw + 1, 1))
+ if (qFuzzyIsNull(sw))
return m_cachedBounds;
else {
return boundsOnStroke(cubic, sw);
@@ -623,7 +623,7 @@ QRectF QSvgImage::bounds() const
QRectF QSvgLine::bounds() const
{
qreal sw = strokeWidth();
- if (qFuzzyCompare(sw + 1, 1)) {
+ if (qFuzzyIsNull(sw)) {
qreal minX = qMin(m_bounds.x1(), m_bounds.x2());
qreal minY = qMin(m_bounds.y1(), m_bounds.y2());
qreal maxX = qMax(m_bounds.x1(), m_bounds.x2());
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index 56dab5f..433a3ad 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -2587,10 +2587,12 @@ static void parseBaseGradient(QSvgNode *node,
if (prop && prop->type() == QSvgStyleProperty::GRADIENT) {
QSvgGradientStyle *inherited =
static_cast<QSvgGradientStyle*>(prop);
- if (!inherited->stopLink().isEmpty())
+ if (!inherited->stopLink().isEmpty()) {
gradProp->setStopLink(inherited->stopLink(), handler->document());
- else
+ } else {
grad->setStops(inherited->qgradient()->stops());
+ gradProp->setGradientStopsSet(inherited->gradientStopsSet());
+ }
matrix = inherited->qmatrix();
} else {
@@ -2649,7 +2651,6 @@ static QSvgStyleProperty *createLinearGradientNode(QSvgNode *node,
}
QLinearGradient *grad = new QLinearGradient(nx1, ny1, nx2, ny2);
- grad->setColorAt(qQNaN(), QColor());
grad->setInterpolationMode(QGradient::ComponentInterpolation);
QSvgGradientStyle *prop = new QSvgGradientStyle(grad);
parseBaseGradient(node, attributes, prop, handler);
@@ -2783,7 +2784,6 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
nfy = toDouble(fy);
QRadialGradient *grad = new QRadialGradient(ncx, ncy, nr, nfx, nfy);
- grad->setColorAt(qQNaN(), QColor());
grad->setInterpolationMode(QGradient::ComponentInterpolation);
QSvgGradientStyle *prop = new QSvgGradientStyle(grad);
@@ -2929,12 +2929,9 @@ static bool parseStopNode(QSvgStyleProperty *parent,
QGradient *grad = style->qgradient();
offset = qMin(qreal(1), qMax(qreal(0), offset)); // Clamp to range [0, 1]
- QGradientStops stops = grad->stops();
- // Check if the gradient is marked as empty (marked with one single stop at NaN).
- if ((stops.size() == 1) && qIsNaN(stops.at(0).first)) {
- stops.clear();
- grad->setStops(stops);
- } else {
+ QGradientStops stops;
+ if (style->gradientStopsSet()) {
+ stops = grad->stops();
// If the stop offset equals the one previously added, add an epsilon to make it greater.
if (offset <= stops.back().first)
offset = stops.back().first + FLT_EPSILON;
@@ -2950,6 +2947,7 @@ static bool parseStopNode(QSvgStyleProperty *parent,
}
grad->setColorAt(offset, color);
+ style->setGradientStopsSet(true);
if (!colorOK)
style->addResolve(offset);
return true;
diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp
index 389f68f..b065395 100644
--- a/src/svg/qsvgstyle.cpp
+++ b/src/svg/qsvgstyle.cpp
@@ -231,7 +231,7 @@ void QSvgSolidColorStyle::revert(QPainter *p, QSvgExtraStates &)
}
QSvgGradientStyle::QSvgGradientStyle(QGradient *grad)
- : m_gradient(grad)
+ : m_gradient(grad), m_gradientStopsSet(false)
{
}
@@ -256,14 +256,13 @@ void QSvgGradientStyle::apply(QPainter *p, const QRectF &/*rect*/, QSvgNode *, Q
}
// If the gradient is marked as empty, insert transparent black
- QGradientStops stops = m_gradient->stops();
- if (stops.size() == 1 && qIsNaN(stops.at(0).first))
+ if (!m_gradientStopsSet) {
m_gradient->setStops(QGradientStops() << QGradientStop(0.0, QColor(0, 0, 0, 0)));
-
- QGradient gradient = *m_gradient;
+ m_gradientStopsSet = true;
+ }
QBrush brush;
- brush = QBrush(gradient);
+ brush = QBrush(*m_gradient);
if (!m_matrix.isIdentity())
brush.setMatrix(m_matrix);
diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h
index ff4058b..058ba35 100644
--- a/src/svg/qsvgstyle_p.h
+++ b/src/svg/qsvgstyle_p.h
@@ -376,6 +376,16 @@ public:
}
void addResolve(qreal offset);
+
+ bool gradientStopsSet() const
+ {
+ return m_gradientStopsSet;
+ }
+
+ void setGradientStopsSet(bool set)
+ {
+ m_gradientStopsSet = set;
+ }
private:
QGradient *m_gradient;
QList<qreal> m_resolvePoints;
@@ -386,6 +396,7 @@ private:
QSvgTinyDocument *m_doc;
QString m_link;
+ bool m_gradientStopsSet;
};
class QSvgTransformStyle : public QSvgStyleProperty
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index ed06006..3d702dd 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -1648,21 +1648,21 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i)
const QString pixmap = QLatin1String("QPixmap");
m_output << m_indent << "QIcon " << iconName << ";\n";
if (i->hasElementNormalOff())
- m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementNormalOff()->text()) << ", QIcon::Normal, QIcon::Off);\n";
+ m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Normal, QIcon::Off);\n";
if (i->hasElementNormalOn())
- m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementNormalOn()->text()) << ", QIcon::Normal, QIcon::On);\n";
+ m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Normal, QIcon::On);\n";
if (i->hasElementDisabledOff())
- m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementDisabledOff()->text()) << ", QIcon::Disabled, QIcon::Off);\n";
+ m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::Off);\n";
if (i->hasElementDisabledOn())
- m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementDisabledOn()->text()) << ", QIcon::Disabled, QIcon::On);\n";
+ m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::On);\n";
if (i->hasElementActiveOff())
- m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementActiveOff()->text()) << ", QIcon::Active, QIcon::Off);\n";
+ m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::Off);\n";
if (i->hasElementActiveOn())
- m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementActiveOn()->text()) << ", QIcon::Active, QIcon::On);\n";
+ m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::On);\n";
if (i->hasElementSelectedOff())
- m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementSelectedOff()->text()) << ", QIcon::Selected, QIcon::Off);\n";
+ m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::Off);\n";
if (i->hasElementSelectedOn())
- m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementSelectedOn()->text()) << ", QIcon::Selected, QIcon::On);\n";
+ m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::On);\n";
} else { // pre-4.4 legacy
m_output << m_indent << "const QIcon " << iconName << " = " << pixCall(QLatin1String("QIcon"), i->text())<< ";\n";
}