summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2011-05-19 12:15:26 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2011-05-19 12:15:26 (GMT)
commit37c4cd4801106112b638ed9d2164b87bbc0a0d1e (patch)
tree3dcc9e1b9908328d1355f5746fd77de7030b547f /src
parentb6a6953d21a95c402e8a5010c1ea5131509eeea3 (diff)
parent35b5f15c3fe5c2f1f0d046d09b9d95dee3bb91b5 (diff)
downloadQt-37c4cd4801106112b638ed9d2164b87bbc0a0d1e.zip
Qt-37c4cd4801106112b638ed9d2164b87bbc0a0d1e.tar.gz
Qt-37c4cd4801106112b638ed9d2164b87bbc0a0d1e.tar.bz2
Merge branch '4.8-upstream'
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp1
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.cpp6
-rw-r--r--src/3rdparty/phonon/phonon/audiooutputadaptor.cpp25
-rw-r--r--src/3rdparty/phonon/phonon/audiooutputadaptor_p.h25
-rw-r--r--src/activeqt/shared/qaxtypes.cpp2
-rw-r--r--src/corelib/animation/qabstractanimation.cpp3
-rw-r--r--src/corelib/animation/qabstractanimation_p.h3
-rw-r--r--src/corelib/concurrent/qfuturewatcher.cpp14
-rw-r--r--src/corelib/concurrent/qfuturewatcher.h13
-rw-r--r--src/corelib/concurrent/qtconcurrentfilter.h554
-rw-r--r--src/corelib/concurrent/qtconcurrentfunctionwrappers.h119
-rw-r--r--src/corelib/concurrent/qtconcurrentmap.h632
-rw-r--r--src/corelib/global/qglobal.h13
-rw-r--r--src/corelib/global/qlibraryinfo.cpp10
-rw-r--r--src/corelib/global/qnamespace.h6
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp3
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp1
-rw-r--r--src/corelib/io/qprocess.cpp97
-rw-r--r--src/corelib/io/qprocess_p.h104
-rw-r--r--src/corelib/io/qprocess_symbian.cpp5
-rw-r--r--src/corelib/io/qprocess_unix.cpp40
-rw-r--r--src/corelib/io/qprocess_win.cpp45
-rw-r--r--src/corelib/io/qsettings.cpp29
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp11
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h2
-rw-r--r--src/corelib/kernel/qcoreevent.cpp2
-rw-r--r--src/corelib/kernel/qcoreevent.h3
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp6
-rw-r--r--src/corelib/plugin/qlibrary.cpp13
-rw-r--r--src/corelib/thread/qmutex_unix.cpp13
-rw-r--r--src/corelib/thread/qthread_symbian.cpp4
-rw-r--r--src/corelib/tools/qbytearray.h13
-rw-r--r--src/corelib/tools/qdatetime.cpp21
-rw-r--r--src/corelib/tools/qelapsedtimer_symbian.cpp2
-rw-r--r--src/corelib/tools/qlocale.cpp2
-rw-r--r--src/corelib/tools/qlocale_symbian.cpp167
-rw-r--r--src/corelib/tools/qstring.cpp10
-rw-r--r--src/corelib/tools/qstring.h12
-rw-r--r--src/corelib/tools/qstringbuilder.h4
-rw-r--r--src/corelib/tools/qtextboundaryfinder.cpp4
-rw-r--r--src/declarative/debugger/debugger.pri11
-rw-r--r--src/declarative/debugger/qdeclarativedebug.cpp46
-rw-r--r--src/declarative/debugger/qdeclarativedebugserver.cpp71
-rw-r--r--src/declarative/debugger/qdeclarativedebugserver_p.h3
-rw-r--r--src/declarative/debugger/qdeclarativedebugserverconnection_p.h1
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice.cpp10
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice_p.h2
-rw-r--r--src/declarative/debugger/qdeclarativedebugtrace.cpp9
-rw-r--r--src/declarative/debugger/qdeclarativedebugtrace_p.h1
-rw-r--r--src/declarative/debugger/qdeclarativeobserverinterface_p.h69
-rw-r--r--src/declarative/debugger/qdeclarativeobserverservice.cpp137
-rw-r--r--src/declarative/debugger/qdeclarativeobserverservice_p.h91
-rw-r--r--src/declarative/debugger/qjsdebuggeragent.cpp576
-rw-r--r--src/declarative/debugger/qjsdebuggeragent_p.h204
-rw-r--r--src/declarative/debugger/qjsdebugservice.cpp198
-rw-r--r--src/declarative/debugger/qjsdebugservice_p.h99
-rw-r--r--src/declarative/debugger/qpacketprotocol.cpp49
-rw-r--r--src/declarative/debugger/qpacketprotocol_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp3
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp14
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp26
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea_p.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp3
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp1
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp5
-rw-r--r--src/declarative/qml/qdeclarative.h11
-rw-r--r--src/declarative/qml/qdeclarativedirparser.cpp17
-rw-r--r--src/declarative/qml/qdeclarativedirparser_p.h16
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp53
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h11
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp22
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp27
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp2
-rw-r--r--src/declarative/qml/qmetaobjectbuilder.cpp59
-rw-r--r--src/declarative/qml/qmetaobjectbuilder_p.h4
-rw-r--r--src/declarative/util/qdeclarativeview.cpp5
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp4
-rw-r--r--src/gui/graphicsview/qgraphicslayout.cpp143
-rw-r--r--src/gui/graphicsview/qgraphicslayout.h2
-rw-r--r--src/gui/graphicsview/qgraphicslayout_p.cpp9
-rw-r--r--src/gui/graphicsview/qgraphicslinearlayout.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp105
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.cpp4
-rw-r--r--src/gui/image/qimage.cpp2
-rw-r--r--src/gui/image/qpixmap.cpp10
-rw-r--r--src/gui/image/qpixmap_mac.cpp11
-rw-r--r--src/gui/image/qvolatileimage.cpp5
-rw-r--r--src/gui/image/qvolatileimage_p.h1
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_p.h1
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp57
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp44
-rw-r--r--src/gui/itemviews/qabstractitemview.h3
-rw-r--r--src/gui/itemviews/qabstractitemview_p.h7
-rw-r--r--src/gui/itemviews/qdatawidgetmapper.cpp2
-rw-r--r--src/gui/itemviews/qtableview.cpp1
-rw-r--r--src/gui/kernel/qapplication_s60.cpp40
-rw-r--r--src/gui/kernel/qapplication_win.cpp13
-rw-r--r--src/gui/kernel/qapplication_x11.cpp3
-rw-r--r--src/gui/kernel/qclipboard.h1
-rw-r--r--src/gui/kernel/qcursor_x11.cpp3
-rw-r--r--src/gui/kernel/qdesktopwidget_qpa.cpp12
-rw-r--r--src/gui/kernel/qdesktopwidget_qpa_p.h1
-rw-r--r--src/gui/kernel/qevent.cpp219
-rw-r--r--src/gui/kernel/qevent.h46
-rw-r--r--src/gui/kernel/qevent_p.h28
-rw-r--r--src/gui/kernel/qgesturemanager.cpp1
-rw-r--r--src/gui/kernel/qplatformclipboard_qpa.cpp7
-rw-r--r--src/gui/kernel/qplatformclipboard_qpa.h1
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.cpp1
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.cpp2
-rw-r--r--src/gui/kernel/qsessionmanager_qpa.cpp2
-rw-r--r--src/gui/kernel/qsoftkeymanager_s60.cpp75
-rw-r--r--src/gui/kernel/qt_s60_p.h31
-rw-r--r--src/gui/kernel/qt_x11_p.h2
-rw-r--r--src/gui/kernel/qwidget.cpp33
-rw-r--r--src/gui/kernel/qwidget_mac.mm22
-rw-r--r--src/gui/kernel/qwidget_p.h2
-rw-r--r--src/gui/kernel/qwidget_s60.cpp24
-rw-r--r--src/gui/kernel/qwidget_x11.cpp13
-rw-r--r--src/gui/painting/painting.pri7
-rw-r--r--src/gui/painting/qbrush.cpp191
-rw-r--r--src/gui/painting/qbrush.h12
-rw-r--r--src/gui/painting/qcolor.cpp3
-rw-r--r--src/gui/painting/qdrawhelper.cpp248
-rw-r--r--src/gui/painting/qdrawhelper_neon.cpp40
-rw-r--r--src/gui/painting/qdrawhelper_p.h256
-rw-r--r--src/gui/painting/qdrawhelper_sse2.cpp56
-rw-r--r--src/gui/painting/qgraphicssystem.cpp16
-rw-r--r--src/gui/painting/qgraphicssystem_p.h3
-rw-r--r--src/gui/painting/qgraphicssystemex_p.h66
-rw-r--r--src/gui/painting/qgraphicssystemex_symbian.cpp86
-rw-r--r--src/gui/painting/qgraphicssystemex_symbian_p.h (renamed from src/gui/util/qscrollerproperties_p.h)43
-rw-r--r--src/gui/painting/qgraphicssystemfactory.cpp2
-rw-r--r--src/gui/painting/qpaintbuffer.cpp16
-rw-r--r--src/gui/painting/qpaintengine_mac.cpp3
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp81
-rw-r--r--src/gui/painting/qpaintengine_x11.cpp3
-rw-r--r--src/gui/painting/qpaintengineex.cpp46
-rw-r--r--src/gui/painting/qpainter.cpp46
-rw-r--r--src/gui/painting/qpainter.h5
-rw-r--r--src/gui/painting/qpainterpath.cpp1
-rw-r--r--src/gui/painting/qprintengine_pdf.cpp5
-rw-r--r--src/gui/painting/qstroker.cpp1
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp2
-rw-r--r--src/gui/painting/qunifiedtoolbarsurface_mac.cpp3
-rw-r--r--src/gui/painting/qunifiedtoolbarsurface_mac_p.h33
-rw-r--r--src/gui/styles/qcleanlooksstyle.cpp16
-rw-r--r--src/gui/styles/qcommonstyle.cpp3
-rw-r--r--src/gui/styles/qgtkpainter.cpp5
-rw-r--r--src/gui/styles/qgtkstyle.cpp3
-rw-r--r--src/gui/styles/qplastiquestyle.cpp11
-rw-r--r--src/gui/styles/qwindowsstyle.cpp2
-rw-r--r--src/gui/text/qfont.h2
-rw-r--r--src/gui/text/qfont_mac.cpp7
-rw-r--r--src/gui/text/qfontdatabase_s60.cpp30
-rw-r--r--src/gui/text/qfontengine_coretext.mm49
-rw-r--r--src/gui/text/qfontengine_coretext_p.h7
-rw-r--r--src/gui/text/qfontengine_ft.cpp141
-rw-r--r--src/gui/text/qfontengine_ft_p.h7
-rw-r--r--src/gui/text/qfontengine_mac.mm2
-rw-r--r--src/gui/text/qfontengine_mac_p.h2
-rw-r--r--src/gui/text/qfontengine_p.h2
-rw-r--r--src/gui/text/qfontengine_win.cpp17
-rw-r--r--src/gui/text/qfontengine_win_p.h3
-rw-r--r--src/gui/text/qfontengine_x11.cpp14
-rw-r--r--src/gui/text/qfontengine_x11_p.h2
-rw-r--r--src/gui/text/qfontenginedirectwrite.cpp11
-rw-r--r--src/gui/text/qfontenginedirectwrite_p.h2
-rw-r--r--src/gui/text/qglyphrun.cpp (renamed from src/gui/text/qglyphs.cpp)125
-rw-r--r--src/gui/text/qglyphrun.h (renamed from src/gui/text/qglyphs.h)32
-rw-r--r--src/gui/text/qglyphrun_p.h (renamed from src/gui/text/qglyphs_p.h)16
-rw-r--r--src/gui/text/qplatformfontdatabase_qpa.cpp10
-rw-r--r--src/gui/text/qplatformfontdatabase_qpa.h2
-rw-r--r--src/gui/text/qrawfont.cpp149
-rw-r--r--src/gui/text/qrawfont.h10
-rw-r--r--src/gui/text/qrawfont_ft.cpp51
-rw-r--r--src/gui/text/qrawfont_mac.cpp22
-rw-r--r--src/gui/text/qrawfont_p.h4
-rw-r--r--src/gui/text/qrawfont_qpa.cpp (renamed from src/gui/util/qscroller_mac.mm)38
-rw-r--r--src/gui/text/qrawfont_win.cpp47
-rw-r--r--src/gui/text/qtextcontrol.cpp6
-rw-r--r--src/gui/text/qtextcursor.cpp42
-rw-r--r--src/gui/text/qtextdocument.cpp31
-rw-r--r--src/gui/text/qtextdocument.h5
-rw-r--r--src/gui/text/qtextdocument_p.cpp15
-rw-r--r--src/gui/text/qtextdocument_p.h4
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp14
-rw-r--r--src/gui/text/qtextengine.cpp339
-rw-r--r--src/gui/text/qtextengine_mac.cpp4
-rw-r--r--src/gui/text/qtextengine_p.h60
-rw-r--r--src/gui/text/qtextformat.h3
-rw-r--r--src/gui/text/qtextlayout.cpp422
-rw-r--r--src/gui/text/qtextlayout.h12
-rw-r--r--src/gui/text/qtextobject.cpp17
-rw-r--r--src/gui/text/qtextobject.h6
-rw-r--r--src/gui/text/text.pri16
-rw-r--r--src/gui/util/qflickgesture.cpp715
-rw-r--r--src/gui/util/qflickgesture_p.h113
-rw-r--r--src/gui/util/qscroller.cpp2059
-rw-r--r--src/gui/util/qscroller.h155
-rw-r--r--src/gui/util/qscroller_p.h209
-rw-r--r--src/gui/util/qscrollerproperties.cpp393
-rw-r--r--src/gui/util/qscrollerproperties.h140
-rw-r--r--src/gui/util/qundogroup.cpp18
-rw-r--r--src/gui/util/qundostack.cpp90
-rw-r--r--src/gui/util/qundostack.h1
-rw-r--r--src/gui/util/qundostack_p.h3
-rw-r--r--src/gui/util/util.pri12
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp107
-rw-r--r--src/gui/widgets/qabstractscrollarea_p.h2
-rw-r--r--src/gui/widgets/qdatetimeedit.cpp41
-rw-r--r--src/gui/widgets/qdatetimeedit_p.h10
-rw-r--r--src/gui/widgets/qdockarealayout.cpp5
-rw-r--r--src/gui/widgets/qdockwidget.cpp1
-rw-r--r--src/gui/widgets/qlinecontrol.cpp13
-rw-r--r--src/gui/widgets/qlinecontrol_p.h8
-rw-r--r--src/gui/widgets/qlineedit.cpp28
-rw-r--r--src/gui/widgets/qlineedit.h5
-rw-r--r--src/gui/widgets/qmainwindow.cpp2
-rw-r--r--src/gui/widgets/qmainwindowlayout.cpp1
-rw-r--r--src/gui/widgets/qmainwindowlayout_p.h1
-rw-r--r--src/gui/widgets/qmenu.cpp12
-rw-r--r--src/gui/widgets/qplaintextedit.cpp6
-rw-r--r--src/gui/widgets/qtextedit.cpp1
-rw-r--r--src/gui/widgets/qworkspace.cpp1
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp9
-rw-r--r--src/network/access/qhttpnetworkconnection_p.h1
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp11
-rw-r--r--src/network/access/qhttpthreaddelegate.cpp3
-rw-r--r--src/network/access/qhttpthreaddelegate_p.h4
-rw-r--r--src/network/access/qnetworkaccessbackend.cpp76
-rw-r--r--src/network/access/qnetworkaccesscachebackend.cpp9
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp12
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp6
-rw-r--r--src/network/access/qnetworkcookie.cpp9
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp27
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.cpp31
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.h4
-rw-r--r--src/network/kernel/qhostaddress.cpp31
-rw-r--r--src/network/kernel/qnetworkinterface_unix.cpp2
-rw-r--r--src/network/kernel/qnetworkproxy.cpp98
-rw-r--r--src/network/kernel/qnetworkproxy.h16
-rw-r--r--src/network/kernel/qnetworkproxy_symbian.cpp102
-rw-r--r--src/network/socket/qabstractsocket.cpp24
-rw-r--r--src/network/socket/qhttpsocketengine.cpp8
-rw-r--r--src/network/socket/qsocks5socketengine.cpp7
-rw-r--r--src/network/socket/qsymbiansocketengine.cpp70
-rw-r--r--src/network/socket/qsymbiansocketengine_p.h2
-rw-r--r--src/network/socket/qtcpserver.cpp5
-rw-r--r--src/network/ssl/qsslconfiguration.cpp4
-rw-r--r--src/network/ssl/qsslsocket.cpp2
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager.cpp2
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager_p.h2
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadersource_p.h18
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp39
-rw-r--r--src/opengl/qgl.cpp7
-rw-r--r--src/opengl/qgl.h2
-rw-r--r--src/opengl/qgl_p.h3
-rw-r--r--src/opengl/qgl_symbian.cpp30
-rw-r--r--src/opengl/qgl_x11egl.cpp14
-rw-r--r--src/opengl/qglextensions_p.h8
-rw-r--r--src/opengl/qglfunctions.cpp33
-rw-r--r--src/opengl/qgraphicssystem_gl.cpp10
-rw-r--r--src/opengl/qgraphicssystem_gl_p.h13
-rw-r--r--src/opengl/qpaintengine_opengl.cpp60
-rw-r--r--src/opengl/qwindowsurface_gl.cpp23
-rw-r--r--src/openvg/qpaintengine_vg.cpp116
-rw-r--r--src/openvg/qpixmapdata_vg.cpp2
-rw-r--r--src/openvg/qwindowsurface_vg.cpp11
-rw-r--r--src/plugins/codecs/jp/qsjiscodec.cpp4
-rw-r--r--src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp8
-rw-r--r--src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h12
-rw-r--r--src/plugins/platforms/uikit/quikiteventloop.mm7
-rw-r--r--src/plugins/platforms/uikit/quikitintegration.mm2
-rw-r--r--src/plugins/platforms/uikit/quikitscreen.mm4
-rw-r--r--src/plugins/platforms/uikit/quikitwindow.h11
-rw-r--r--src/plugins/platforms/uikit/quikitwindow.mm77
-rw-r--r--src/plugins/platforms/uikit/quikitwindowsurface.mm43
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp8
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h3
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h1
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri9
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h54
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c10
-rw-r--r--src/plugins/platforms/wayland/qwaylandbuffer.h1
-rw-r--r--src/plugins/platforms/wayland/qwaylandclipboard.cpp242
-rw-r--r--src/plugins/platforms/wayland/qwaylandclipboard.h86
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.cpp29
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.h1
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.cpp23
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.h1
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.cpp16
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.h6
-rw-r--r--src/plugins/platforms/wayland/qwaylandnativeinterface.cpp72
-rw-r--r--src/plugins/platforms/wayland/qwaylandnativeinterface.h60
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.cpp1
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.h3
-rw-r--r--src/plugins/platforms/wayland/wayland.pro12
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.cpp1
-rw-r--r--src/plugins/platforms/xlib/qglxintegration.cpp8
-rw-r--r--src/plugins/platforms/xlib/qglxintegration.h4
-rw-r--r--src/plugins/platforms/xlib/qxlibscreen.cpp4
-rw-r--r--src/plugins/platforms/xlib/qxlibstatic.cpp4
-rw-r--r--src/plugins/platforms/xlib/qxlibstatic.h4
-rw-r--r--src/plugins/plugins.pro4
-rw-r--r--src/plugins/qmltooling/declarativeobserver/declarativeobserver.pro53
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/abstractliveedittool.cpp200
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/abstractliveedittool_p.h121
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/boundingrecthighlighter.cpp284
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/boundingrecthighlighter_p.h126
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/colorpickertool.cpp131
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/colorpickertool_p.h99
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/editor.qrc24
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/color-picker-24.pngbin0 -> 3440 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/color-picker-hicontrast.pngbin0 -> 3192 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/color-picker.pngbin0 -> 3173 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/from-qml-24.pngbin0 -> 3395 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/from-qml.pngbin0 -> 3205 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/observermode-24.pngbin0 -> 1283 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/observermode.pngbin0 -> 3539 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/pause-24.pngbin0 -> 3307 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/pause.pngbin0 -> 3097 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/play-24.pngbin0 -> 3655 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/play.pngbin0 -> 3363 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/reload.pngbin0 -> 3418 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/resize_handle.pngbin0 -> 160 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/select-24.pngbin0 -> 3510 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/select-marquee-24.pngbin0 -> 2891 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/select-marquee.pngbin0 -> 2871 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/select.pngbin0 -> 3308 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/to-qml-24.pngbin0 -> 3407 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/to-qml.pngbin0 -> 3227 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/zoom-24.pngbin0 -> 3566 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/images/zoom.pngbin0 -> 3347 bytes
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/livelayeritem.cpp92
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/livelayeritem_p.h73
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/liverubberbandselectionmanipulator.cpp165
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/liverubberbandselectionmanipulator_p.h102
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator.cpp148
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator_p.h90
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/liveselectionrectangle.cpp113
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/liveselectionrectangle_p.h83
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/liveselectiontool.cpp442
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/liveselectiontool_p.h126
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/livesingleselectionmanipulator.cpp151
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/livesingleselectionmanipulator_p.h95
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/qmltoolbar.cpp328
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/qmltoolbar_p.h138
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/subcomponenteditortool.cpp364
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/subcomponenteditortool_p.h131
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/subcomponentmasklayeritem.cpp124
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/subcomponentmasklayeritem_p.h77
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/toolbarcolorbox.cpp134
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/toolbarcolorbox_p.h87
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/zoomtool.cpp336
-rw-r--r--src/plugins/qmltooling/declarativeobserver/editor/zoomtool_p.h113
-rw-r--r--src/plugins/qmltooling/declarativeobserver/qdeclarativeobserverplugin.cpp81
-rw-r--r--src/plugins/qmltooling/declarativeobserver/qdeclarativeobserverplugin.h71
-rw-r--r--src/plugins/qmltooling/declarativeobserver/qdeclarativeobserverprotocol.h145
-rw-r--r--src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp1167
-rw-r--r--src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p.h154
-rw-r--r--src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p_p.h165
-rw-r--r--src/plugins/qmltooling/declarativeobserver/qmlobserverconstants_p.h90
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp6
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h1
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp42
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qostdevice.h4
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp15
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h2
-rw-r--r--src/plugins/qmltooling/qmltooling.pro2
-rw-r--r--src/qbase.pri2
-rw-r--r--src/qt3support/text/q3richtext.cpp1
-rw-r--r--src/s60installs/bwins/QtCoreu.def168
-rw-r--r--src/s60installs/bwins/QtGuiu.def117
-rw-r--r--src/s60installs/bwins/QtNetworku.def5
-rw-r--r--src/s60installs/eabi/QtCoreu.def162
-rw-r--r--src/s60installs/eabi/QtGuiu.def121
-rw-r--r--src/s60installs/eabi/QtNetworku.def8
-rw-r--r--src/s60installs/eabi/QtOpenGLu.def28
-rw-r--r--src/script/api/qscriptengineagent_p.h18
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.cpp8
-rw-r--r--src/tools/uic3/uic3.pro1
-rw-r--r--src/xmlpatterns/data/qitem_p.h4
-rw-r--r--src/xmlpatterns/expr/qdynamiccontextstore.cpp8
-rw-r--r--src/xmlpatterns/expr/qdynamiccontextstore_p.h2
-rw-r--r--src/xmlpatterns/expr/qevaluationcache.cpp2
-rw-r--r--src/xmlpatterns/expr/qevaluationcache_p.h2
-rw-r--r--src/xmlpatterns/expr/qletclause.cpp2
-rw-r--r--src/xmlpatterns/schema/qxsdattribute.cpp4
-rw-r--r--src/xmlpatterns/schema/qxsdattribute_p.h2
-rw-r--r--src/xmlpatterns/schema/qxsdcomplextype.cpp4
-rw-r--r--src/xmlpatterns/schema/qxsdcomplextype_p.h2
-rw-r--r--src/xmlpatterns/schema/qxsdelement.cpp8
-rw-r--r--src/xmlpatterns/schema/qxsdelement_p.h8
-rw-r--r--src/xmlpatterns/schema/qxsdparticlechecker.cpp6
-rw-r--r--src/xmlpatterns/schema/qxsdsimpletype.cpp4
-rw-r--r--src/xmlpatterns/schema/qxsdsimpletype_p.h2
-rw-r--r--src/xmlpatterns/schema/qxsdstatemachinebuilder.cpp10
403 files changed, 13826 insertions, 7360 deletions
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
index c202e1f..3410782 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
@@ -655,6 +655,7 @@ void HB_GetCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength,
const HB_ScriptItem *items, hb_uint32 numItems,
HB_CharAttributes *attributes)
{
+ memset(attributes, 0, stringLength * sizeof(HB_CharAttributes));
calcLineBreaks(string, stringLength, attributes);
for (hb_uint32 i = 0; i < numItems; ++i) {
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.cpp
index fcb8d86..1015923 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.cpp
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.cpp
@@ -1312,6 +1312,9 @@ class RegexGenerator : private MacroAssembler {
push(ARMRegisters::r4);
push(ARMRegisters::r5);
push(ARMRegisters::r6);
+#if CPU(ARM_TRADITIONAL)
+ push(ARMRegisters::r8); // scratch register
+#endif
move(ARMRegisters::r3, output);
#endif
}
@@ -1327,6 +1330,9 @@ class RegexGenerator : private MacroAssembler {
pop(X86Registers::ebx);
pop(X86Registers::ebp);
#elif CPU(ARM)
+#if CPU(ARM_TRADITIONAL)
+ pop(ARMRegisters::r8); // scratch register
+#endif
pop(ARMRegisters::r6);
pop(ARMRegisters::r5);
pop(ARMRegisters::r4);
diff --git a/src/3rdparty/phonon/phonon/audiooutputadaptor.cpp b/src/3rdparty/phonon/phonon/audiooutputadaptor.cpp
index 2c01773..959172d 100644
--- a/src/3rdparty/phonon/phonon/audiooutputadaptor.cpp
+++ b/src/3rdparty/phonon/phonon/audiooutputadaptor.cpp
@@ -1,3 +1,28 @@
+/* This file is part of the KDE project
+ The following license applies to the edits made to the generated
+ source code:
+
+ Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ Copyright (C) 2009 Matthias Kretz.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), Nokia Corporation
+ (or its successors, if any) and the KDE Free Qt Foundation, which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
/*
* This file was generated by dbusidl2cpp version 0.4
* when processing input file org.kde.Phonon.AudioOutput.xml
diff --git a/src/3rdparty/phonon/phonon/audiooutputadaptor_p.h b/src/3rdparty/phonon/phonon/audiooutputadaptor_p.h
index 7178e9b..140a74f 100644
--- a/src/3rdparty/phonon/phonon/audiooutputadaptor_p.h
+++ b/src/3rdparty/phonon/phonon/audiooutputadaptor_p.h
@@ -1,3 +1,28 @@
+/* This file is part of the KDE project
+ The following license applies to the edits made to the generated
+ source code:
+
+ Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ Copyright (C) 2009 Matthias Kretz.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), Nokia Corporation
+ (or its successors, if any) and the KDE Free Qt Foundation, which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
/*
* This file was generated by dbusidl2cpp version 0.4
* when processing input file org.kde.Phonon.AudioOutput.xml
diff --git a/src/activeqt/shared/qaxtypes.cpp b/src/activeqt/shared/qaxtypes.cpp
index c48b55b..8835caf 100644
--- a/src/activeqt/shared/qaxtypes.cpp
+++ b/src/activeqt/shared/qaxtypes.cpp
@@ -265,7 +265,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type
return QVariantToVARIANT(var, *arg.pvarVal, typeName, false);
}
- if (out && proptype == QVariant::Invalid && typeName == "QVariant") {
+ if (out && proptype == QVariant::UserType && typeName == "QVariant") {
VARIANT *pVariant = new VARIANT;
QVariantToVARIANT(var, *pVariant, QByteArray(), false);
arg.vt = VT_VARIANT|VT_BYREF;
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 602cf8a..0a1f5d7 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -260,7 +260,8 @@ void QUnifiedTimer::restartAnimationTimer()
} else if (!driver->isRunning() || isPauseTimerActive) {
driver->start();
isPauseTimerActive = false;
- }
+ } else if (runningLeafAnimations == 0)
+ driver->stop();
}
void QUnifiedTimer::setTimingInterval(int interval)
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index ba92960..0ccc502 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -184,6 +184,9 @@ public:
void restartAnimationTimer();
void updateAnimationsTime();
+ //useful for profiling/debugging
+ int runningAnimationCount() { return animations.count(); }
+
protected:
void timerEvent(QTimerEvent *);
diff --git a/src/corelib/concurrent/qfuturewatcher.cpp b/src/corelib/concurrent/qfuturewatcher.cpp
index ea12bc9..728714a 100644
--- a/src/corelib/concurrent/qfuturewatcher.cpp
+++ b/src/corelib/concurrent/qfuturewatcher.cpp
@@ -589,4 +589,16 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)
QT_END_NAMESPACE
-#endif // QT_NO_CONCURRENT
+#else
+
+// On Symbian winscw target QT_NO_QFUTURE and QT_NO_CONCURRENT are both defined.
+// However moc will be run without having them set, so provide a dummy stub at
+// least for the slots to prevent linker errors.
+
+void QFutureWatcherBase::cancel() { }
+void QFutureWatcherBase::setPaused(bool) { }
+void QFutureWatcherBase::pause() { }
+void QFutureWatcherBase::resume() { }
+void QFutureWatcherBase::togglePaused() { }
+
+#endif // QT_NO_QFUTURE
diff --git a/src/corelib/concurrent/qfuturewatcher.h b/src/corelib/concurrent/qfuturewatcher.h
index 5fe2007..26e549d 100644
--- a/src/corelib/concurrent/qfuturewatcher.h
+++ b/src/corelib/concurrent/qfuturewatcher.h
@@ -44,8 +44,6 @@
#include <QtCore/qfuture.h>
-#ifndef QT_NO_QFUTURE
-
#include <QtCore/qobject.h>
QT_BEGIN_HEADER
@@ -56,6 +54,11 @@ QT_MODULE(Core)
class QEvent;
class QFutureWatcherBasePrivate;
+
+#ifdef QT_NO_QFUTURE
+class QFutureInterfaceBase;
+#endif
+
class Q_CORE_EXPORT QFutureWatcherBase : public QObject
{
Q_OBJECT
@@ -114,6 +117,8 @@ private:
virtual QFutureInterfaceBase &futureInterface() = 0;
};
+#ifndef QT_NO_QFUTURE
+
template <typename T>
class QFutureWatcher : public QFutureWatcherBase
{
@@ -214,9 +219,9 @@ Q_INLINE_TEMPLATE void QFutureWatcher<void>::setFuture(const QFuture<void> &_fut
connectOutputInterface();
}
+#endif // QT_NO_QFUTURE
+
QT_END_NAMESPACE
QT_END_HEADER
-#endif // QT_NO_CONCURRENT
-
#endif // QFUTUREWATCHER_H
diff --git a/src/corelib/concurrent/qtconcurrentfilter.h b/src/corelib/concurrent/qtconcurrentfilter.h
index e392212..63dcc4b 100644
--- a/src/corelib/concurrent/qtconcurrentfilter.h
+++ b/src/corelib/concurrent/qtconcurrentfilter.h
@@ -115,19 +115,7 @@ ThreadEngineStarter<void> filterInternal(Sequence &sequence, KeepFunctor keep, T
template <typename Sequence, typename KeepFunctor>
QFuture<void> filter(Sequence &sequence, KeepFunctor keep)
{
- return filterInternal(sequence, keep, &Sequence::push_back);
-}
-
-template <typename Sequence, typename T>
-QFuture<void> filter(Sequence &sequence, bool (keep)(T))
-{
- return filterInternal(sequence, FunctionWrapper1<bool, T>(keep), &Sequence::push_back);
-}
-
-template <typename Sequence, typename C>
-QFuture<void> filter(Sequence &sequence, bool (C::*keep)() const)
-{
- return filterInternal(sequence, ConstMemberFunctionWrapper<bool, C>(keep), &Sequence::push_back);
+ return filterInternal(sequence, QtPrivate::createFunctionWrapper(keep), &Sequence::push_back);
}
// filteredReduced() on sequences
@@ -137,103 +125,20 @@ QFuture<ResultType> filteredReduced(const Sequence &sequence,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return startFilteredReduced<ResultType>(sequence, keep, reduce, options);
- }
-
-template <typename ResultType, typename Sequence, typename T, typename ReduceFunctor>
-QFuture<ResultType> filteredReduced(const Sequence &sequence,
- bool (filter)(T),
- ReduceFunctor reduce,
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<ResultType>(sequence,
- FunctionWrapper1<bool, T>(filter),
- reduce,
- options);
+ return startFilteredReduced<ResultType>(sequence, QtPrivate::createFunctionWrapper(keep), QtPrivate::createFunctionWrapper(reduce), options);
}
-template <typename ResultType, typename Sequence, typename C, typename ReduceFunctor>
-QFuture<ResultType> filteredReduced(const Sequence &sequence,
- bool (C::*filter)() const,
+template <typename Sequence, typename KeepFunctor, typename ReduceFunctor>
+QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> filteredReduced(const Sequence &sequence,
+ KeepFunctor keep,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return filteredReduced<ResultType>(sequence,
- ConstMemberFunctionWrapper<bool, C>(filter),
- reduce,
- options);
-}
-
-template <typename Sequence, typename KeepFunctor, typename T, typename U, typename V>
-QFuture<U> filteredReduced(const Sequence &sequence,
- KeepFunctor keep,
- T (reduce)(U &, V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<U>(sequence,
- keep,
- FunctionWrapper2<T, U &, V>(reduce),
- options);
-}
-
-template <typename Sequence, typename KeepFunctor, typename T, typename C, typename U>
-QFuture<C> filteredReduced(const Sequence &sequence,
- KeepFunctor keep,
- T (C::*reduce)(U),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<C>(sequence,
- keep,
- MemberFunctionWrapper1<T, C, U>(reduce),
- options);
-}
-
-template <typename Sequence, typename T, typename U, typename V, typename W>
-QFuture<V> filteredReduced(const Sequence &sequence,
- bool (keep)(T),
- U (reduce)(V &, W),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<V>(sequence,
- FunctionWrapper1<bool, T>(keep),
- FunctionWrapper2<U, V &, W>(reduce),
- options);
-}
-
-template <typename Sequence, typename C, typename T, typename U, typename V>
-QFuture<U> filteredReduced(const Sequence &sequence,
- bool (C::*keep)() const,
- T (reduce)(U &, V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<U>(sequence,
- ConstMemberFunctionWrapper<bool, C>(keep),
- FunctionWrapper2<T, U &, V>(reduce),
- options);
-}
-
-template <typename Sequence, typename T, typename U, typename C, typename V>
-QFuture<C> filteredReduced(const Sequence &sequence,
- bool (keep)(T),
- U (C::*reduce)(V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<C>(sequence,
- FunctionWrapper1<bool, T>(keep),
- MemberFunctionWrapper1<U, C, V>(reduce),
- options);
-}
-
-template <typename Sequence, typename C, typename T, typename D, typename U>
-QFuture<D> filteredReduced(const Sequence &sequence,
- bool (C::*keep)() const,
- T (D::*reduce)(U),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<D>(sequence,
- ConstMemberFunctionWrapper<bool, C>(keep),
- MemberFunctionWrapper1<T, D, U>(reduce),
- options);
+ return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
+ (sequence,
+ QtPrivate::createFunctionWrapper(keep),
+ QtPrivate::createFunctionWrapper(reduce),
+ options);
}
// filteredReduced() on iterators
@@ -244,184 +149,42 @@ QFuture<ResultType> filteredReduced(Iterator begin,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return startFilteredReduced<ResultType>(begin, end, keep, reduce, options);
-}
-
-template <typename ResultType, typename Iterator, typename T, typename ReduceFunctor>
-QFuture<ResultType> filteredReduced(Iterator begin,
- Iterator end,
- bool (filter)(T),
- ReduceFunctor reduce,
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<ResultType>(begin,
- end,
- FunctionWrapper1<bool, T>(filter),
- reduce,
- options);
+ return startFilteredReduced<ResultType>(begin, end, QtPrivate::createFunctionWrapper(keep), QtPrivate::createFunctionWrapper(reduce), options);
}
-template <typename ResultType, typename Iterator, typename C, typename ReduceFunctor>
-QFuture<ResultType> filteredReduced(Iterator begin,
+template <typename Iterator, typename KeepFunctor, typename ReduceFunctor>
+QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> filteredReduced(Iterator begin,
Iterator end,
- bool (C::*filter)() const,
+ KeepFunctor keep,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return filteredReduced<ResultType>(begin,
- end,
- ConstMemberFunctionWrapper<bool, C>(filter),
- reduce,
- options);
-}
-
-template <typename Iterator, typename KeepFunctor, typename T, typename U, typename V>
-QFuture<U> filteredReduced(Iterator begin,
- Iterator end,
- KeepFunctor keep,
- T (reduce)(U &, V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<U>(begin,
- end,
- keep,
- FunctionWrapper2<T, U &, V>(reduce),
- options);
-}
-
-template <typename Iterator, typename KeepFunctor, typename T, typename C, typename U>
-QFuture<C> filteredReduced(Iterator begin,
- Iterator end,
- KeepFunctor keep,
- T (C::*reduce)(U),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<C>(begin,
- end,
- keep,
- MemberFunctionWrapper1<T, C, U>(reduce),
- options);
-}
-
-template <typename Iterator, typename T, typename U, typename V, typename W>
-QFuture<V> filteredReduced(Iterator begin,
- Iterator end,
- bool (keep)(T),
- U (reduce)(V &, W),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<V>(begin,
- end,
- FunctionWrapper1<bool, T>(keep),
- FunctionWrapper2<U, V &, W>(reduce),
- options);
-}
-
-template <typename Iterator, typename C, typename T, typename U, typename V>
-QFuture<U> filteredReduced(Iterator begin,
- Iterator end,
- bool (C::*keep)() const,
- T (reduce)(U &, V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<U>(begin,
- end,
- ConstMemberFunctionWrapper<bool, C>(keep),
- FunctionWrapper2<T, U &, V>(reduce),
- options);
-}
-
-template <typename Iterator, typename T, typename U, typename C, typename V>
-QFuture<C> filteredReduced(Iterator begin,
- Iterator end,
- bool (keep)(T),
- U (C::*reduce)(V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<C>(begin,
- end,
- FunctionWrapper1<bool, T>(keep),
- MemberFunctionWrapper1<U, C, V>(reduce),
- options);
+ return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
+ (begin, end,
+ QtPrivate::createFunctionWrapper(keep),
+ QtPrivate::createFunctionWrapper(reduce),
+ options);
}
-template <typename Iterator, typename C, typename T, typename D, typename U>
-QFuture<D> filteredReduced(Iterator begin,
- Iterator end,
- bool (C::*keep)() const,
- T (D::*reduce)(U),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return filteredReduced<D>(begin,
- end,
- ConstMemberFunctionWrapper<bool, C>(keep),
- MemberFunctionWrapper1<T, D, U>(reduce),
- options);
-}
-
-
// filtered() on sequences
template <typename Sequence, typename KeepFunctor>
QFuture<typename Sequence::value_type> filtered(const Sequence &sequence, KeepFunctor keep)
{
- return startFiltered(sequence, keep);
-}
-
-template <typename Sequence, typename T>
-QFuture<typename Sequence::value_type> filtered(const Sequence &sequence, bool (keep)(T))
-{
- return startFiltered(sequence, FunctionWrapper1<bool, T>(keep));
-}
-
-template <typename Sequence, typename C>
-QFuture<typename Sequence::value_type> filtered(const Sequence &sequence, bool (C::*keep)() const)
-{
- return startFiltered(sequence, ConstMemberFunctionWrapper<bool, C>(keep));
+ return startFiltered(sequence, QtPrivate::createFunctionWrapper(keep));
}
// filtered() on iterators
template <typename Iterator, typename KeepFunctor>
QFuture<typename qValueType<Iterator>::value_type> filtered(Iterator begin, Iterator end, KeepFunctor keep)
{
- return startFiltered(begin, end, keep);
+ return startFiltered(begin, end, QtPrivate::createFunctionWrapper(keep));
}
-template <typename Iterator, typename T>
-QFuture<typename qValueType<Iterator>::value_type> filtered(Iterator begin, Iterator end, bool (keep)(T))
-{
- return startFiltered(begin, end, FunctionWrapper1<bool, T>(keep));
-}
-
-template <typename Iterator, typename C>
-QFuture<typename qValueType<Iterator>::value_type> filtered(Iterator begin,
- Iterator end,
- bool (C::*keep)() const)
-{
- return startFiltered(begin, end, ConstMemberFunctionWrapper<bool, C>(keep));
-}
-
-
// blocking filter() on sequences
template <typename Sequence, typename KeepFunctor>
void blockingFilter(Sequence &sequence, KeepFunctor keep)
{
- filterInternal(sequence, keep, &Sequence::push_back).startBlocking();
-}
-
-template <typename Sequence, typename T>
-void blockingFilter(Sequence &sequence, bool (keep)(T))
-{
- filterInternal(sequence, FunctionWrapper1<bool, T>(keep), &Sequence::push_back)
- .startBlocking();
-}
-
-template <typename Sequence, typename C>
-void blockingFilter(Sequence &sequence, bool (C::*keep)() const)
-{
- filterInternal(sequence,
- ConstMemberFunctionWrapper<bool, C>(keep),
- &Sequence::push_back)
- .startBlocking();
+ filterInternal(sequence, QtPrivate::createFunctionWrapper(keep), &Sequence::push_back).startBlocking();
}
// blocking filteredReduced() on sequences
@@ -431,111 +194,20 @@ ResultType blockingFilteredReduced(const Sequence &sequence,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return startFilteredReduced<ResultType>(sequence, keep, reduce, options)
+ return startFilteredReduced<ResultType>(sequence, QtPrivate::createFunctionWrapper(keep), QtPrivate::createFunctionWrapper(reduce), options)
.startBlocking();
}
-template <typename ResultType, typename Sequence, typename T, typename ReduceFunctor>
-ResultType blockingFilteredReduced(const Sequence &sequence,
- bool (filter)(T),
- ReduceFunctor reduce,
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<ResultType>
- (sequence,
- FunctionWrapper1<bool, T>(filter),
- reduce,
- options);
-}
-
-template <typename ResultType, typename Sequence, typename C, typename ReduceFunctor>
-ResultType blockingFilteredReduced(const Sequence &sequence,
- bool (C::*filter)() const,
+template <typename Sequence, typename KeepFunctor, typename ReduceFunctor>
+typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingFilteredReduced(const Sequence &sequence,
+ KeepFunctor keep,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return blockingFilteredReduced<ResultType>
- (sequence,
- ConstMemberFunctionWrapper<bool, C>(filter),
- reduce,
- options);
-}
-
-template <typename Sequence, typename KeepFunctor, typename T, typename U, typename V>
-U blockingFilteredReduced(const Sequence &sequence,
- KeepFunctor keep,
- T (reduce)(U &, V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<U>
- (sequence,
- keep,
- FunctionWrapper2<T, U &, V>(reduce),
- options);
-}
-
-template <typename Sequence, typename KeepFunctor, typename T, typename C, typename U>
-C blockingFilteredReduced(const Sequence &sequence,
- KeepFunctor keep,
- T (C::*reduce)(U),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<C>
+ return blockingFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(sequence,
- keep,
- MemberFunctionWrapper1<T, C, U>(reduce),
- options);
-}
-
-template <typename Sequence, typename T, typename U, typename V, typename W>
-V blockingFilteredReduced(const Sequence &sequence,
- bool (keep)(T),
- U (reduce)(V &, W),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<V>
- (sequence,
- FunctionWrapper1<bool, T>(keep),
- FunctionWrapper2<U, V &, W>(reduce),
- options);
-}
-
-template <typename Sequence, typename C, typename T, typename U, typename V>
-U blockingFilteredReduced(const Sequence &sequence,
- bool (C::*keep)() const,
- T (reduce)(U &, V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<U>
- (sequence,
- ConstMemberFunctionWrapper<bool, C>(keep),
- FunctionWrapper2<T, U &, V>(reduce),
- options);
-}
-
-template <typename Sequence, typename T, typename U, typename C, typename V>
-C blockingFilteredReduced(const Sequence &sequence,
- bool (keep)(T),
- U (C::*reduce)(V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<C>
- (sequence,
- FunctionWrapper1<bool, T>(keep),
- MemberFunctionWrapper1<U, C, V>(reduce),
- options);
-}
-
-template <typename Sequence, typename C, typename T, typename D, typename U>
-D blockingFilteredReduced(const Sequence &sequence,
- bool (C::*keep)() const,
- T (D::*reduce)(U),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<D>
- (sequence,
- ConstMemberFunctionWrapper<bool, C>(keep),
- MemberFunctionWrapper1<T, D, U>(reduce),
+ QtPrivate::createFunctionWrapper(keep),
+ QtPrivate::createFunctionWrapper(reduce),
options);
}
@@ -547,150 +219,34 @@ ResultType blockingFilteredReduced(Iterator begin,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return startFilteredReduced<ResultType>(begin, end, keep, reduce, options)
+ return startFilteredReduced<ResultType>
+ (begin, end,
+ QtPrivate::createFunctionWrapper(keep),
+ QtPrivate::createFunctionWrapper(reduce),
+ options)
.startBlocking();
}
-template <typename ResultType, typename Iterator, typename T, typename ReduceFunctor>
-ResultType blockingFilteredReduced(Iterator begin,
- Iterator end,
- bool (filter)(T),
- ReduceFunctor reduce,
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<ResultType>
- (begin,
- end,
- FunctionWrapper1<bool, T>(filter),
- reduce,
- options);
-}
-
-template <typename ResultType, typename Iterator, typename C, typename ReduceFunctor>
-ResultType blockingFilteredReduced(Iterator begin,
+template <typename Iterator, typename KeepFunctor, typename ReduceFunctor>
+typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingFilteredReduced(Iterator begin,
Iterator end,
- bool (C::*filter)() const,
+ KeepFunctor keep,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return blockingFilteredReduced<ResultType>
- (begin,
- end,
- ConstMemberFunctionWrapper<bool, C>(filter),
- reduce,
- options);
-}
-
-template <typename Iterator, typename KeepFunctor, typename T, typename U, typename V>
-U blockingFilteredReduced(Iterator begin,
- Iterator end,
- KeepFunctor keep,
- T (reduce)(U &, V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<U>
- (begin,
- end,
- keep,
- FunctionWrapper2<T, U &, V>(reduce),
- options);
-}
-
-template <typename Iterator, typename KeepFunctor, typename T, typename C, typename U>
-C blockingFilteredReduced(Iterator begin,
- Iterator end,
- KeepFunctor keep,
- T (C::*reduce)(U),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<C>
- (begin,
- end,
- keep,
- MemberFunctionWrapper1<T, C, U>(reduce),
- options);
-}
-
-template <typename Iterator, typename T, typename U, typename V, typename W>
-V blockingFilteredReduced(Iterator begin,
- Iterator end,
- bool (keep)(T),
- U (reduce)(V &, W),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<V>
- (begin,
- end,
- FunctionWrapper1<bool, T>(keep),
- FunctionWrapper2<U, V &, W>(reduce),
- options);
-}
-
-template <typename Iterator, typename C, typename T, typename U, typename V>
-U blockingFilteredReduced(Iterator begin,
- Iterator end,
- bool (C::*keep)() const,
- T (reduce)(U &, V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<U>
- (begin,
- end,
- ConstMemberFunctionWrapper<bool, C>(keep),
- FunctionWrapper2<T, U &, V>(reduce),
- options);
-}
-
-template <typename Iterator, typename T, typename U, typename C, typename V>
-C blockingFilteredReduced(Iterator begin,
- Iterator end,
- bool (keep)(T),
- U (C::*reduce)(V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<C>
- (begin,
- end,
- FunctionWrapper1<bool, T>(keep),
- MemberFunctionWrapper1<U, C, V>(reduce),
- options);
-}
-
-template <typename Iterator, typename C, typename T, typename D, typename U>
-D blockingFilteredReduced(Iterator begin,
- Iterator end,
- bool (C::*keep)() const,
- T (D::*reduce)(U),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return blockingFilteredReduced<D>
- (begin,
- end,
- ConstMemberFunctionWrapper<bool, C>(keep),
- MemberFunctionWrapper1<T, D, U>(reduce),
- options);
+ return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
+ (begin, end,
+ QtPrivate::createFunctionWrapper(keep),
+ QtPrivate::createFunctionWrapper(reduce),
+ options)
+ .startBlocking();
}
// blocking filtered() on sequences
template <typename Sequence, typename KeepFunctor>
Sequence blockingFiltered(const Sequence &sequence, KeepFunctor keep)
{
- return blockingFilteredReduced(sequence, keep, &Sequence::push_back, OrderedReduce);
-}
-
-template <typename Sequence, typename T>
-Sequence blockingFiltered(const Sequence &sequence, bool (keep)(T))
-{
- return blockingFilteredReduced(sequence, keep, &Sequence::push_back, OrderedReduce);
-}
-
-template <typename Sequence, typename C>
-Sequence blockingFiltered(const Sequence &sequence, bool (C::*filter)() const)
-{
- return blockingFilteredReduced(sequence,
- filter,
- &Sequence::push_back,
- OrderedReduce);
+ return blockingFilteredReduced(sequence, QtPrivate::createFunctionWrapper(keep), &Sequence::push_back, OrderedReduce);
}
// blocking filtered() on iterators
@@ -699,27 +255,7 @@ OutputSequence blockingFiltered(Iterator begin, Iterator end, KeepFunctor keep)
{
return blockingFilteredReduced(begin,
end,
- keep,
- &OutputSequence::push_back,
- OrderedReduce);
-}
-
-template <typename OutputSequence, typename Iterator, typename T>
-OutputSequence blockingFiltered(Iterator begin, Iterator end, bool (keep)(T))
-{
- return blockingFilteredReduced(begin,
- end,
- keep,
- &OutputSequence::push_back,
- OrderedReduce);
-}
-
-template <typename OutputSequence, typename Iterator, typename C>
-OutputSequence blockingFiltered(Iterator begin, Iterator end, bool (C::*filter)() const)
-{
- return blockingFilteredReduced(begin,
- end,
- filter,
+ QtPrivate::createFunctionWrapper(keep),
&OutputSequence::push_back,
OrderedReduce);
}
diff --git a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h
index f31f7d2..98506a5 100644
--- a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h
+++ b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h
@@ -163,6 +163,125 @@ private:
} // namespace QtConcurrent.
+namespace QtPrivate {
+
+template <typename T>
+const T& createFunctionWrapper(const T& t)
+{
+ return t;
+}
+
+template <typename T, typename U>
+QtConcurrent::FunctionWrapper1<T, U> createFunctionWrapper(T (*func)(U))
+{
+ return QtConcurrent::FunctionWrapper1<T, U>(func);
+}
+
+template <typename T, typename C>
+QtConcurrent::MemberFunctionWrapper<T, C> createFunctionWrapper(T (C::*func)())
+{
+ return QtConcurrent::MemberFunctionWrapper<T, C>(func);
+}
+
+template <typename T, typename C, typename U>
+QtConcurrent::MemberFunctionWrapper1<T, C, U> createFunctionWrapper(T (C::*func)(U))
+{
+ return QtConcurrent::MemberFunctionWrapper1<T, C, U>(func);
+}
+
+template <typename T, typename C>
+QtConcurrent::ConstMemberFunctionWrapper<T, C> createFunctionWrapper(T (C::*func)() const)
+{
+ return QtConcurrent::ConstMemberFunctionWrapper<T, C>(func);
+}
+
+
+template<typename T>
+void *lazyResultType_helper(int, typename T::result_type * = 0);
+template<typename T>
+char lazyResultType_helper(double);
+
+template <typename Functor, bool foo = sizeof(lazyResultType_helper<Functor>(0)) != sizeof(void*)>
+struct LazyResultType { typedef typename Functor::result_type Type; };
+template <typename Functor>
+struct LazyResultType<Functor, true> { typedef void Type; };
+
+
+template <class T>
+struct ReduceResultType;
+
+template <class U, class V>
+struct ReduceResultType<void(*)(U&,V)>
+{
+ typedef U ResultType;
+};
+
+template <class T, class C, class U>
+struct ReduceResultType<T(C::*)(U)>
+{
+ typedef C ResultType;
+};
+
+template <class InputSequence, class MapFunctor>
+struct MapResultType
+{
+ typedef typename LazyResultType<MapFunctor>::Type ResultType;
+};
+
+template <class U, class V>
+struct MapResultType<void, U (*)(V)>
+{
+ typedef U ResultType;
+};
+
+template <class T, class C>
+struct MapResultType<void, T(C::*)() const>
+{
+ typedef T ResultType;
+};
+
+#ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
+
+template <template <typename> class InputSequence, typename MapFunctor, typename T>
+struct MapResultType<InputSequence<T>, MapFunctor>
+{
+ typedef InputSequence<typename LazyResultType<MapFunctor>::Type> ResultType;
+};
+
+template <template <typename> class InputSequence, class T, class U, class V>
+struct MapResultType<InputSequence<T>, U (*)(V)>
+{
+ typedef InputSequence<U> ResultType;
+};
+
+template <template <typename> class InputSequence, class T, class U, class C>
+struct MapResultType<InputSequence<T>, U(C::*)() const>
+{
+ typedef InputSequence<U> ResultType;
+};
+
+#endif // QT_NO_TEMPLATE_TEMPLATE_PARAMETER
+
+template <class MapFunctor>
+struct MapResultType<QStringList, MapFunctor>
+{
+ typedef QList<typename LazyResultType<MapFunctor>::Type> ResultType;
+};
+
+template <class U, class V>
+struct MapResultType<QStringList, U (*)(V)>
+{
+ typedef QList<U> ResultType;
+};
+
+template <class U, class C>
+struct MapResultType<QStringList, U(C::*)() const>
+{
+ typedef QList<U> ResultType;
+};
+
+} // namespace QtPrivate.
+
#endif //qdoc
QT_END_NAMESPACE
diff --git a/src/corelib/concurrent/qtconcurrentmap.h b/src/corelib/concurrent/qtconcurrentmap.h
index 80edf7e..a857ab5 100644
--- a/src/corelib/concurrent/qtconcurrentmap.h
+++ b/src/corelib/concurrent/qtconcurrentmap.h
@@ -110,38 +110,14 @@ namespace QtConcurrent {
template <typename Sequence, typename MapFunctor>
QFuture<void> map(Sequence &sequence, MapFunctor map)
{
- return startMap(sequence.begin(), sequence.end(), map);
-}
-
-template <typename Sequence, typename T, typename U>
-QFuture<void> map(Sequence &sequence, T (map)(U))
-{
- return startMap(sequence.begin(), sequence.end(), FunctionWrapper1<T, U>(map));
-}
-
-template <typename Sequence, typename T, typename C>
-QFuture<void> map(Sequence &sequence, T (C::*map)())
-{
- return startMap(sequence.begin(), sequence.end(), MemberFunctionWrapper<T, C>(map));
+ return startMap(sequence.begin(), sequence.end(), QtPrivate::createFunctionWrapper(map));
}
// map() on iterators
template <typename Iterator, typename MapFunctor>
QFuture<void> map(Iterator begin, Iterator end, MapFunctor map)
{
- return startMap(begin, end, map);
-}
-
-template <typename Iterator, typename T, typename U>
-QFuture<void> map(Iterator begin, Iterator end, T (map)(U))
-{
- return startMap(begin, end, FunctionWrapper1<T, U>(map));
-}
-
-template <typename Iterator, typename T, typename C>
-QFuture<void> map(Iterator begin, Iterator end, T (C::*map)())
-{
- return startMap(begin, end, MemberFunctionWrapper<T, C>(map));
+ return startMap(begin, end, QtPrivate::createFunctionWrapper(map));
}
// mappedReduced() for sequences.
@@ -151,88 +127,24 @@ QFuture<ResultType> mappedReduced(const Sequence &sequence,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return startMappedReduced<typename MapFunctor::result_type, ResultType>
- (sequence, map, reduce, options);
-}
-
-template <typename Sequence, typename MapFunctor, typename T, typename U, typename V>
-QFuture<U> mappedReduced(const Sequence &sequence,
- MapFunctor map,
- T (reduce)(U &, V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<typename MapFunctor::result_type, U>
- (sequence, map, FunctionWrapper2<T, U &, V>(reduce), options);
-}
-
-template <typename Sequence, typename MapFunctor, typename T, typename C, typename U>
-QFuture<C> mappedReduced(const Sequence &sequence,
- MapFunctor map,
- T (C::*reduce)(U),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<typename MapFunctor::result_type, C>
- (sequence, map, MemberFunctionWrapper1<T, C, U>(reduce), options);
-}
-
-template <typename ResultType, typename Sequence, typename T, typename U, typename ReduceFunctor>
-QFuture<ResultType> mappedReduced(const Sequence &sequence,
- T (map)(U),
- ReduceFunctor reduce,
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<T, ResultType>
- (sequence, FunctionWrapper1<T, U>(map), reduce, options);
+ return startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, ResultType>
+ (sequence,
+ QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
+ options);
}
-template <typename ResultType, typename Sequence, typename T, typename C, typename ReduceFunctor>
-QFuture<ResultType> mappedReduced(const Sequence &sequence,
- T (C::*map)() const,
+template <typename Sequence, typename MapFunctor, typename ReduceFunctor>
+QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(const Sequence &sequence,
+ MapFunctor map,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return startMappedReduced<T, ResultType>
- (sequence, ConstMemberFunctionWrapper<T, C>(map), reduce, options);
-}
-
-template <typename Sequence, typename T, typename U, typename V, typename W, typename X>
-QFuture<W> mappedReduced(const Sequence &sequence,
- T (map)(U),
- V (reduce)(W &, X),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<T, W>
- (sequence, FunctionWrapper1<T, U>(map), FunctionWrapper2<V, W &, X>(reduce), options);
-}
-
-template <typename Sequence, typename T, typename C, typename U, typename V, typename W>
-QFuture<V> mappedReduced(const Sequence &sequence,
- T (C::*map)() const,
- U (reduce)(V &, W),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<T, V> (sequence, ConstMemberFunctionWrapper<T, C>(map),
- FunctionWrapper2<U, V &, W>(reduce), options);
-}
-
-template <typename Sequence, typename T, typename U, typename V, typename C, typename W>
-QFuture<C> mappedReduced(const Sequence &sequence,
- T (map)(U),
- V (C::*reduce)(W),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<T, C> (sequence, FunctionWrapper1<T, U>(map),
- MemberFunctionWrapper1<V, C, W>(reduce), options);
-}
-
-template <typename Sequence, typename T, typename C, typename U,typename D, typename V>
-QFuture<D> mappedReduced(const Sequence &sequence,
- T (C::*map)() const,
- U (D::*reduce)(V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<T, D>(sequence, ConstMemberFunctionWrapper<T, C>(map),
- MemberFunctionWrapper1<U, D, V>(reduce), options);
+ return startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
+ (sequence,
+ QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
+ options);
}
// mappedReduced() for iterators
@@ -243,295 +155,85 @@ QFuture<ResultType> mappedReduced(Iterator begin,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return startMappedReduced<ResultType, typename MapFunctor::result_type>
- (begin, end, map, reduce, options);
-}
-
-template <typename Iterator, typename MapFunctor, typename T, typename U, typename V>
-QFuture<U> mappedReduced(Iterator begin,
- Iterator end,
- MapFunctor map,
- T (reduce)(U &, V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<typename MapFunctor::result_type, U>
- (begin, end, map, FunctionWrapper2<T, U &, V>(reduce), options);
-}
-
-template <typename Iterator, typename MapFunctor, typename T, typename C, typename U>
-QFuture<C> mappedReduced(Iterator begin,
- Iterator end,
- MapFunctor map,
- T (C::*reduce)(U),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<typename MapFunctor::result_type, C>
- (begin, end, map, MemberFunctionWrapper1<T, C, U>(reduce), options);
+ return startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, ResultType>
+ (begin, end,
+ QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
+ options);
}
-template <typename ResultType, typename Iterator, typename T, typename U, typename ReduceFunctor>
-QFuture<ResultType> mappedReduced(Iterator begin,
+template <typename Iterator, typename MapFunctor, typename ReduceFunctor>
+QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(Iterator begin,
Iterator end,
- T (map)(U),
- ReduceFunctor reduce,
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<T, ResultType>
- (begin, end, FunctionWrapper1<T, U>(map), reduce, options);
-}
-
-template <typename ResultType, typename Iterator, typename T, typename C, typename ReduceFunctor>
-QFuture<ResultType> mappedReduced(Iterator begin,
- Iterator end,
- T (C::*map)() const,
+ MapFunctor map,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return startMappedReduced<T, ResultType>
- (begin, end, ConstMemberFunctionWrapper<T, C>(map), reduce, options);
-}
-
-template <typename Iterator, typename T, typename U, typename V, typename W, typename X>
-QFuture<W> mappedReduced(Iterator begin,
- Iterator end,
- T (map)(U),
- V (reduce)(W &, X),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<T, W>
- (begin, end, FunctionWrapper1<T, U>(map), FunctionWrapper2<V, W &, X>(reduce), options);
-}
-
-template <typename Iterator, typename T, typename C, typename U, typename V, typename W>
-QFuture<V> mappedReduced(Iterator begin,
- Iterator end,
- T (C::*map)() const,
- U (reduce)(V &, W),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<T, V>(begin, end, ConstMemberFunctionWrapper<T, C>(map),
- FunctionWrapper2<U, V &, W>(reduce), options);
-}
-
-template <typename Iterator, typename T, typename U, typename V, typename C, typename W>
-QFuture<C> mappedReduced(Iterator begin,
- Iterator end,
- T (map)(U),
- V (C::*reduce)(W),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<T, C>
- (begin, end, FunctionWrapper1<T, U>(map), MemberFunctionWrapper1<V, C, W>(reduce), options);
-}
-
-template <typename Iterator, typename T, typename C, typename U,typename D, typename V>
-QFuture<D> mappedReduced(Iterator begin,
- Iterator end,
- T (C::*map)() const,
- U (D::*reduce)(V),
- ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
-{
- return startMappedReduced<T, D>(begin, end, ConstMemberFunctionWrapper<T, C>(map),
- MemberFunctionWrapper1<U, D, V>(reduce), options);
+ return startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
+ (begin, end,
+ QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
+ options);
}
// mapped() for sequences
template <typename Sequence, typename MapFunctor>
-QFuture<typename MapFunctor::result_type> mapped(const Sequence &sequence, MapFunctor map)
+QFuture<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType> mapped(const Sequence &sequence, MapFunctor map)
{
- return startMapped<typename MapFunctor::result_type>(sequence, map);
-}
-
-template <typename Sequence, typename T, typename U>
-QFuture<T> mapped(const Sequence &sequence, T (map)(U))
-{
- return startMapped<T>(sequence, FunctionWrapper1<T, U>(map));
-}
-
-template <typename Sequence, typename T, typename C>
-QFuture<T> mapped(const Sequence &sequence, T (C::*map)() const)
-{
- return startMapped<T>(sequence, ConstMemberFunctionWrapper<T, C>(map));
+ return startMapped<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType>(sequence, QtPrivate::createFunctionWrapper(map));
}
// mapped() for iterator ranges.
template <typename Iterator, typename MapFunctor>
-QFuture<typename MapFunctor::result_type> mapped(Iterator begin, Iterator end, MapFunctor map)
-{
- return startMapped<Q_TYPENAME MapFunctor::result_type>(begin, end, map);
-}
-
-template <typename Iterator, typename T, typename U>
-QFuture<T> mapped(Iterator begin, Iterator end, T (map)(U))
+QFuture<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType> mapped(Iterator begin, Iterator end, MapFunctor map)
{
- return startMapped<T>(begin, end, FunctionWrapper1<T, U>(map));
+ return startMapped<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType>(begin, end, QtPrivate::createFunctionWrapper(map));
}
-template <typename Iterator, typename T, typename C>
-QFuture<T> mapped(Iterator begin, Iterator end, T (C::*map)() const)
-{
- return startMapped<T>(begin, end, ConstMemberFunctionWrapper<T, C>(map));
-}
-
-
+// blockingMap() for sequences
template <typename Sequence, typename MapFunctor>
void blockingMap(Sequence &sequence, MapFunctor map)
{
- startMap(sequence.begin(), sequence.end(), map).startBlocking();
-}
-
-template <typename Sequence, typename T, typename U>
-void blockingMap(Sequence &sequence, T (map)(U))
-{
- startMap(sequence.begin(), sequence.end(), QtConcurrent::FunctionWrapper1<T, U>(map)).startBlocking();
-}
-
-template <typename Sequence, typename T, typename C>
-void blockingMap(Sequence &sequence, T (C::*map)())
-{
- startMap(sequence.begin(), sequence.end(), QtConcurrent::MemberFunctionWrapper<T, C>(map)).startBlocking();
+ startMap(sequence.begin(), sequence.end(), QtPrivate::createFunctionWrapper(map)).startBlocking();
}
+// blockingMap() for iterator ranges
template <typename Iterator, typename MapFunctor>
void blockingMap(Iterator begin, Iterator end, MapFunctor map)
{
- startMap(begin, end, map).startBlocking();
-}
-
-template <typename Iterator, typename T, typename U>
-void blockingMap(Iterator begin, Iterator end, T (map)(U))
-{
- startMap(begin, end, QtConcurrent::FunctionWrapper1<T, U>(map)).startBlocking();
-}
-
-template <typename Iterator, typename T, typename C>
-void blockingMap(Iterator begin, Iterator end, T (C::*map)())
-{
- startMap(begin, end, QtConcurrent::MemberFunctionWrapper<T, C>(map)).startBlocking();
+ startMap(begin, end, QtPrivate::createFunctionWrapper(map)).startBlocking();
}
+// blockingMappedReduced() for sequences
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
ResultType blockingMappedReduced(const Sequence &sequence,
MapFunctor map,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, ResultType>
- (sequence, map, reduce, options).startBlocking();
-}
-
-template <typename Sequence, typename MapFunctor, typename T, typename U, typename V>
-U blockingMappedReduced(const Sequence &sequence,
- MapFunctor map,
- T (reduce)(U &, V),
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, U>
- (sequence,
- map,
- QtConcurrent::FunctionWrapper2<T, U &, V>(reduce),
- options)
- .startBlocking();
-}
-
-template <typename Sequence, typename MapFunctor, typename T, typename C, typename U>
-C blockingMappedReduced(const Sequence &sequence,
- MapFunctor map,
- T (C::*reduce)(U),
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, C>
- (sequence,
- map,
- QtConcurrent::MemberFunctionWrapper1<T, C, U>(reduce),
- options)
- .startBlocking();
-}
-
-template <typename ResultType, typename Sequence, typename T, typename U, typename ReduceFunctor>
-ResultType blockingMappedReduced(const Sequence &sequence,
- T (map)(U),
- ReduceFunctor reduce,
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<T, ResultType>
+ return QtConcurrent::startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, ResultType>
(sequence,
- QtConcurrent::FunctionWrapper1<T, U>(map),
- reduce,
+ QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
options)
.startBlocking();
}
-template <typename ResultType, typename Sequence, typename T, typename C, typename ReduceFunctor>
-ResultType blockingMappedReduced(const Sequence &sequence,
- T (C::*map)() const,
+template <typename MapFunctor, typename ReduceFunctor, typename Sequence>
+typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(const Sequence &sequence,
+ MapFunctor map,
ReduceFunctor reduce,
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<T, ResultType>
- (sequence,
- QtConcurrent::ConstMemberFunctionWrapper<T, C>(map),
- reduce,
- options)
- .startBlocking();
-}
-
-template <typename Sequence, typename T, typename U, typename V, typename W, typename X>
-W blockingMappedReduced(const Sequence &sequence,
- T (map)(U),
- V (reduce)(W &, X),
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<T, W>
- (sequence,
- QtConcurrent::FunctionWrapper1<T, U>(map),
- QtConcurrent::FunctionWrapper2<V, W &, X>(reduce),
- options)
- .startBlocking();
-}
-
-template <typename Sequence, typename T, typename C, typename U, typename V, typename W>
-V blockingMappedReduced(const Sequence &sequence,
- T (C::*map)() const,
- U (reduce)(V &, W),
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<T, V>
- (sequence,
- QtConcurrent::ConstMemberFunctionWrapper<T, C>(map),
- QtConcurrent::FunctionWrapper2<U, V &, W>(reduce),
- options)
- .startBlocking();
-}
-
-template <typename Sequence, typename T, typename U, typename V, typename C, typename W>
-C blockingMappedReduced(const Sequence &sequence,
- T (map)(U),
- V (C::*reduce)(W),
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<T, C>
- (sequence,
- QtConcurrent::FunctionWrapper1<T, U>(map),
- QtConcurrent::MemberFunctionWrapper1<V, C, W>(reduce),
- options)
- .startBlocking();
-}
-
-template <typename Sequence, typename T, typename C, typename U,typename D, typename V>
-D blockingMappedReduced(const Sequence &sequence,
- T (C::*map)() const,
- U (D::*reduce)(V),
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
+ ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
{
- return QtConcurrent::startMappedReduced<T, D>
+ return QtConcurrent::startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(sequence,
- QtConcurrent::ConstMemberFunctionWrapper<T, C>(map),
- QtConcurrent::MemberFunctionWrapper1<U, D, V>(reduce),
+ QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
options)
.startBlocking();
}
+// blockingMappedReduced() for iterator ranges
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
ResultType blockingMappedReduced(Iterator begin,
Iterator end,
@@ -539,134 +241,25 @@ ResultType blockingMappedReduced(Iterator begin,
ReduceFunctor reduce,
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
{
- return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, ResultType>
- (begin, end, map, reduce, options).startBlocking();
-}
-
-template <typename Iterator, typename MapFunctor, typename T, typename U, typename V>
-U blockingMappedReduced(Iterator begin,
- Iterator end,
- MapFunctor map,
- T (reduce)(U &, V),
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, U>
- (begin,
- end,
- map,
- QtConcurrent::FunctionWrapper2<T, U &, V>(reduce),
- options)
- .startBlocking();
-}
-
-template <typename Iterator, typename MapFunctor, typename T, typename C, typename U>
-C blockingMappedReduced(Iterator begin,
- Iterator end,
- MapFunctor map,
- T (C::*reduce)(U),
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, C>
- (begin,
- end,
- map,
- QtConcurrent::MemberFunctionWrapper1<T, C, U>(reduce),
+ return QtConcurrent::startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, ResultType>
+ (begin, end,
+ QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
options)
.startBlocking();
}
-template <typename ResultType, typename Iterator, typename T, typename U, typename ReduceFunctor>
-ResultType blockingMappedReduced(Iterator begin,
+template <typename Iterator, typename MapFunctor, typename ReduceFunctor>
+typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(Iterator begin,
Iterator end,
- T (map)(U),
- ReduceFunctor reduce,
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<T, ResultType>
- (begin,
- end,
- QtConcurrent::FunctionWrapper1<T, U>(map),
- reduce,
- options)
- .startBlocking();
-}
-
-template <typename ResultType, typename Iterator, typename T, typename C, typename ReduceFunctor>
-ResultType blockingMappedReduced(Iterator begin,
- Iterator end,
- T (C::*map)() const,
+ MapFunctor map,
ReduceFunctor reduce,
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
{
- return QtConcurrent::startMappedReduced<T, ResultType>
- (begin,
- end,
- QtConcurrent::ConstMemberFunctionWrapper<T, C>(map),
- reduce,
- options)
- .startBlocking();
-}
-
-template <typename Iterator, typename T, typename U, typename V, typename W, typename X>
-W blockingMappedReduced(Iterator begin,
- Iterator end,
- T (map)(U),
- V (reduce)(W &, X),
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<T, W>
- (begin,
- end,
- QtConcurrent::FunctionWrapper1<T, U>(map),
- QtConcurrent::FunctionWrapper2<V, W &, X>(reduce),
- options)
- .startBlocking();
-}
-
-template <typename Iterator, typename T, typename C, typename U, typename V, typename W>
-V blockingMappedReduced(Iterator begin,
- Iterator end,
- T (C::*map)() const,
- U (reduce)(V &, W),
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<T, V>
- (begin,
- end,
- QtConcurrent::ConstMemberFunctionWrapper<T, C>(map),
- QtConcurrent::FunctionWrapper2<U, V &, W>(reduce),
- options)
- .startBlocking();
-}
-
-template <typename Iterator, typename T, typename U, typename V, typename C, typename W>
-C blockingMappedReduced(Iterator begin,
- Iterator end,
- T (map)(U),
- V (C::*reduce)(W),
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<T, C>
- (begin,
- end,
- QtConcurrent::FunctionWrapper1<T, U>(map),
- QtConcurrent::MemberFunctionWrapper1<V, C, W>(reduce),
- options)
- .startBlocking();
-}
-
-template <typename Iterator, typename T, typename C, typename U,typename D, typename V>
-D blockingMappedReduced(Iterator begin,
- Iterator end,
- T (C::*map)() const,
- U (D::*reduce)(V),
- QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
-{
- return QtConcurrent::startMappedReduced<T, D>
- (begin,
- end,
- QtConcurrent::ConstMemberFunctionWrapper<T, C>(map),
- QtConcurrent::MemberFunctionWrapper1<U, D, V>(reduce),
+ return QtConcurrent::startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
+ (begin, end,
+ QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
options)
.startBlocking();
}
@@ -675,97 +268,44 @@ D blockingMappedReduced(Iterator begin,
template <typename OutputSequence, typename InputSequence, typename MapFunctor>
OutputSequence blockingMapped(const InputSequence &sequence, MapFunctor map)
{
- return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
- QtConcurrent::OrderedReduce);
-}
-
-template <typename OutputSequence, typename InputSequence, typename T, typename U>
-OutputSequence blockingMapped(const InputSequence &sequence, T (map)(U))
-{
- return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
- QtConcurrent::OrderedReduce);
-}
-
-template <typename OutputSequence, typename InputSequence, typename T, typename C>
-OutputSequence blockingMapped(const InputSequence &sequence, T (C::*map)() const)
-{
- return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
- QtConcurrent::OrderedReduce);
-}
-#ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
-
-// overloads for changing the container value type:
-template <template <typename> class Sequence, typename MapFunctor, typename T>
-Sequence<typename MapFunctor::result_type> blockingMapped(const Sequence<T> &sequence, MapFunctor map)
-{
- typedef Sequence<typename MapFunctor::result_type> OutputSequence;
- return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
- QtConcurrent::OrderedReduce);
-}
-
-template <template <typename> class Sequence, typename T, typename U, typename V>
-Sequence<U> blockingMapped(const Sequence<T> &sequence, U (map)(V))
-{
- typedef Sequence<U> OutputSequence;
- return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
- QtConcurrent::OrderedReduce);
-}
-
-template <template <typename> class Sequence, typename T, typename U, typename C>
-Sequence<U> blockingMapped(const Sequence<T> &sequence, U (C::*map)() const)
-{
- typedef Sequence<U> OutputSequence;
- return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
- QtConcurrent::OrderedReduce);
-}
-
-#endif // QT_NO_TEMPLATE_TEMPLATE_PARAMETER
-
-// overloads for changing the container value type from a QStringList:
-template <typename MapFunctor>
-QList<typename MapFunctor::result_type> blockingMapped(const QStringList &sequence, MapFunctor map)
-{
- typedef QList<typename MapFunctor::result_type> OutputSequence;
- return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
- QtConcurrent::OrderedReduce);
-}
-
-template <typename U, typename V>
-QList<U> blockingMapped(const QStringList &sequence, U (map)(V))
-{
- typedef QList<U> OutputSequence;
- return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
- QtConcurrent::OrderedReduce);
+ return blockingMappedReduced<OutputSequence>
+ (sequence,
+ QtPrivate::createFunctionWrapper(map),
+ &OutputSequence::push_back,
+ QtConcurrent::OrderedReduce);
}
-template <typename U, typename C>
-QList<U> blockingMapped(const QStringList &sequence, U (C::*map)() const)
+template <typename MapFunctor, typename InputSequence>
+typename QtPrivate::MapResultType<InputSequence, MapFunctor>::ResultType blockingMapped(const InputSequence &sequence, MapFunctor map)
{
- typedef QList<U> OutputSequence;
- return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
- QtConcurrent::OrderedReduce);
+ typedef typename QtPrivate::MapResultType<InputSequence, MapFunctor>::ResultType OutputSequence;
+ return blockingMappedReduced<OutputSequence>
+ (sequence,
+ QtPrivate::createFunctionWrapper(map),
+ &OutputSequence::push_back,
+ QtConcurrent::OrderedReduce);
}
// mapped() for iterator ranges
template <typename Sequence, typename Iterator, typename MapFunctor>
Sequence blockingMapped(Iterator begin, Iterator end, MapFunctor map)
{
- return blockingMappedReduced(begin, end, map, &Sequence::push_back,
- QtConcurrent::OrderedReduce);
-}
-
-template <typename Sequence, typename Iterator, typename T, typename U>
-Sequence blockingMapped(Iterator begin, Iterator end, T (map)(U))
-{
- return blockingMappedReduced(begin, end, map, &Sequence::push_back,
- QtConcurrent::OrderedReduce);
+ return blockingMappedReduced<Sequence>
+ (begin, end,
+ QtPrivate::createFunctionWrapper(map),
+ &Sequence::push_back,
+ QtConcurrent::OrderedReduce);
}
-template <typename Sequence, typename Iterator, typename T, typename C>
-Sequence blockingMapped(Iterator begin, Iterator end, T (C::*map)() const)
-{
- return blockingMappedReduced(begin, end, map, &Sequence::push_back,
- QtConcurrent::OrderedReduce);
+template <typename Iterator, typename MapFunctor>
+typename QtPrivate::MapResultType<Iterator, MapFunctor>::ResultType blockingMapped(Iterator begin, Iterator end, MapFunctor map)
+{
+ typedef typename QtPrivate::MapResultType<Iterator, MapFunctor>::ResultType OutputSequence;
+ return blockingMappedReduced<OutputSequence>
+ (begin, end,
+ QtPrivate::createFunctionWrapper(map),
+ &OutputSequence::push_back,
+ QtConcurrent::OrderedReduce);
}
} // namespace QtConcurrent
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 9434eb2..3e1f011 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -2545,6 +2545,16 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();
//Symbian does not support data imports from a DLL
#define Q_NO_DATA_RELOCATION
+// Winscw compiler is unable to compile QtConcurrent.
+#ifdef Q_CC_NOKIAX86
+#ifndef QT_NO_CONCURRENT
+#define QT_NO_CONCURRENT
+#endif
+#ifndef QT_NO_QFUTURE
+#define QT_NO_QFUTURE
+#endif
+#endif
+
QT_END_NAMESPACE
// forward declare std::exception
#ifdef __cplusplus
@@ -2755,7 +2765,8 @@ QT_LICENSED_MODULE(DBus)
#if !(defined(Q_WS_WIN) && !defined(Q_WS_WINCE)) \
&& !(defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) \
- && !(defined(Q_WS_X11) && !defined(QT_NO_FREETYPE))
+ && !(defined(Q_WS_X11) && !defined(QT_NO_FREETYPE)) \
+ && !(defined(Q_WS_QPA))
# define QT_NO_RAWFONT
#endif
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index aca1cb1..005e90a 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -450,10 +450,11 @@ QLibraryInfo::location(LibraryLocation loc)
}
if (QDir::isRelativePath(ret)) {
+ QString baseDir;
if (loc == PrefixPath) {
// we make the prefix path absolute to the executable's directory
#ifdef BOOTSTRAPPING
- return QFileInfo(qmake_libraryInfoFile()).absolutePath();
+ baseDir = QFileInfo(qmake_libraryInfoFile()).absolutePath();
#else
if (QCoreApplication::instance()) {
#ifdef Q_OS_MAC
@@ -466,15 +467,16 @@ QLibraryInfo::location(LibraryLocation loc)
}
}
#endif
- return QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(ret);
+ baseDir = QCoreApplication::applicationDirPath();
} else {
- return QDir::current().absoluteFilePath(ret);
+ baseDir = QDir::currentPath();
}
#endif
} else {
// we make any other path absolute to the prefix directory
- return QDir(location(PrefixPath)).absoluteFilePath(ret);
+ baseDir = location(PrefixPath);
}
+ ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret);
}
return ret;
}
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 75ce68a..f086513 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -94,6 +94,7 @@ Qt {
Q_ENUMS(GestureState)
Q_ENUMS(GestureType)
#endif
+ Q_ENUMS(CursorMoveStyle)
#endif // (defined(Q_MOC_RUN) || defined(QT_JAMBI_RUN))
#if defined(Q_MOC_RUN)
@@ -1784,6 +1785,11 @@ public:
NavigationModeCursorAuto,
NavigationModeCursorForceVisible
};
+
+ enum CursorMoveStyle {
+ LogicalMoveStyle,
+ VisualMoveStyle
+ };
}
#ifdef Q_MOC_RUN
;
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index c9ebaa4..030b845 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -356,6 +356,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
const QByteArray &path = entry.nativeFilePath();
nativeFilePath = path.constData();
nativeFilePathLength = path.size();
+ Q_UNUSED(nativeFilePathLength);
}
bool entryExists = true; // innocent until proven otherwise
@@ -638,7 +639,7 @@ QFileSystemEntry QFileSystemEngine::currentPath()
#if defined(__GLIBC__) && !defined(PATH_MAX)
char *currentName = ::get_current_dir_name();
if (currentName) {
- result = QFile::decodeName(QByteArray(currentName));
+ result = QFileSystemEntry(QByteArray(currentName), QFileSystemEntry::FromNativePath());
::free(currentName);
}
#else
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 82c6eba..1dbc40f 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -583,6 +583,7 @@ QString QFileSystemEngine::owner(const QFileSystemEntry &entry, QAbstractFileEng
}
}
#else
+ Q_UNUSED(entry);
Q_UNUSED(own);
#endif
return name;
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index a45225f..c2234e9 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -143,55 +143,13 @@ QT_BEGIN_NAMESPACE
\sa QProcess, QProcess::systemEnvironment(), QProcess::setProcessEnvironment()
*/
-#ifdef Q_OS_WIN
-static inline QProcessEnvironmentPrivate::Unit prepareName(const QString &name)
-{ return name.toUpper(); }
-static inline QProcessEnvironmentPrivate::Unit prepareName(const QByteArray &name)
-{ return QString::fromLocal8Bit(name).toUpper(); }
-static inline QString nameToString(const QProcessEnvironmentPrivate::Unit &name)
-{ return name; }
-static inline QProcessEnvironmentPrivate::Unit prepareValue(const QString &value)
-{ return value; }
-static inline QProcessEnvironmentPrivate::Unit prepareValue(const QByteArray &value)
-{ return QString::fromLocal8Bit(value); }
-static inline QString valueToString(const QProcessEnvironmentPrivate::Unit &value)
-{ return value; }
-static inline QByteArray valueToByteArray(const QProcessEnvironmentPrivate::Unit &value)
-{ return value.toLocal8Bit(); }
-#else
-static inline QProcessEnvironmentPrivate::Unit prepareName(const QByteArray &name)
-{ return name; }
-static inline QProcessEnvironmentPrivate::Unit prepareName(const QString &name)
-{ return name.toLocal8Bit(); }
-static inline QString nameToString(const QProcessEnvironmentPrivate::Unit &name)
-{ return QString::fromLocal8Bit(name); }
-static inline QProcessEnvironmentPrivate::Unit prepareValue(const QByteArray &value)
-{ return value; }
-static inline QProcessEnvironmentPrivate::Unit prepareValue(const QString &value)
-{ return value.toLocal8Bit(); }
-static inline QString valueToString(const QProcessEnvironmentPrivate::Unit &value)
-{ return QString::fromLocal8Bit(value); }
-static inline QByteArray valueToByteArray(const QProcessEnvironmentPrivate::Unit &value)
-{ return value; }
-#endif
-
-template<> void QSharedDataPointer<QProcessEnvironmentPrivate>::detach()
-{
- if (d && d->ref == 1)
- return;
- QProcessEnvironmentPrivate *x = (d ? new QProcessEnvironmentPrivate(*d)
- : new QProcessEnvironmentPrivate);
- x->ref.ref();
- if (d && !d->ref.deref())
- delete d;
- d = x;
-}
QStringList QProcessEnvironmentPrivate::toList() const
{
QStringList result;
- QHash<Unit, Unit>::ConstIterator it = hash.constBegin(),
- end = hash.constEnd();
+ result.reserve(hash.size());
+ Hash::ConstIterator it = hash.constBegin(),
+ end = hash.constEnd();
for ( ; it != end; ++it) {
QString data = nameToString(it.key());
QString value = valueToString(it.value());
@@ -224,19 +182,27 @@ QProcessEnvironment QProcessEnvironmentPrivate::fromList(const QStringList &list
QStringList QProcessEnvironmentPrivate::keys() const
{
QStringList result;
- QHash<Unit, Unit>::ConstIterator it = hash.constBegin(),
- end = hash.constEnd();
+ result.reserve(hash.size());
+ Hash::ConstIterator it = hash.constBegin(),
+ end = hash.constEnd();
for ( ; it != end; ++it)
result << nameToString(it.key());
return result;
}
-void QProcessEnvironmentPrivate::insert(const Hash &h)
+void QProcessEnvironmentPrivate::insert(const QProcessEnvironmentPrivate &other)
{
- QHash<Unit, Unit>::ConstIterator it = h.constBegin(),
- end = h.constEnd();
+ Hash::ConstIterator it = other.hash.constBegin(),
+ end = other.hash.constEnd();
for ( ; it != end; ++it)
hash.insert(it.key(), it.value());
+
+#ifdef Q_OS_UNIX
+ QHash<QString, Key>::ConstIterator nit = other.nameMap.constBegin(),
+ nend = other.nameMap.constEnd();
+ for ( ; nit != nend; ++nit)
+ nameMap.insert(nit.key(), nit.value());
+#endif
}
/*!
@@ -317,6 +283,8 @@ void QProcessEnvironment::clear()
{
if (d)
d->hash.clear();
+ // Unix: Don't clear d->nameMap, as the environment is likely to be
+ // re-populated with the same keys again.
}
/*!
@@ -331,7 +299,7 @@ void QProcessEnvironment::clear()
*/
bool QProcessEnvironment::contains(const QString &name) const
{
- return d ? d->hash.contains(prepareName(name)) : false;
+ return d ? d->hash.contains(d->prepareName(name)) : false;
}
/*!
@@ -353,7 +321,7 @@ bool QProcessEnvironment::contains(const QString &name) const
void QProcessEnvironment::insert(const QString &name, const QString &value)
{
// d detaches from null
- d->hash.insert(prepareName(name), prepareValue(value));
+ d->hash.insert(d->prepareName(name), d->prepareValue(value));
}
/*!
@@ -370,7 +338,7 @@ void QProcessEnvironment::insert(const QString &name, const QString &value)
void QProcessEnvironment::remove(const QString &name)
{
if (d)
- d->hash.remove(prepareName(name));
+ d->hash.remove(d->prepareName(name));
}
/*!
@@ -389,11 +357,11 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa
if (!d)
return defaultValue;
- QProcessEnvironmentPrivate::Hash::ConstIterator it = d->hash.constFind(prepareName(name));
+ QProcessEnvironmentPrivate::Hash::ConstIterator it = d->hash.constFind(d->prepareName(name));
if (it == d->hash.constEnd())
return defaultValue;
- return valueToString(it.value());
+ return d->valueToString(it.value());
}
/*!
@@ -438,7 +406,7 @@ void QProcessEnvironment::insert(const QProcessEnvironment &e)
return;
// d detaches from null
- d->insert(e.d->hash);
+ d->insert(*e.d);
}
void QProcessPrivate::Channel::clear()
@@ -2321,6 +2289,8 @@ QStringList QProcess::systemEnvironment()
}
/*!
+ \fn QProcessEnvironment QProcessEnvironment::systemEnvironment()
+
\since 4.6
\brief The systemEnvironment function returns the environment of
@@ -2336,21 +2306,6 @@ QStringList QProcess::systemEnvironment()
\sa QProcess::systemEnvironment()
*/
-QProcessEnvironment QProcessEnvironment::systemEnvironment()
-{
- QProcessEnvironment env;
- const char *entry;
- for (int count = 0; (entry = environ[count]); ++count) {
- const char *equal = strchr(entry, '=');
- if (!equal)
- continue;
-
- QByteArray name(entry, equal - entry);
- QByteArray value(equal + 1);
- env.insert(QString::fromLocal8Bit(name), QString::fromLocal8Bit(value));
- }
- return env;
-}
/*!
\typedef Q_PID
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index 7bfcb31..54d4936 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -81,23 +81,119 @@ class QTimer;
class RProcess;
#endif
+#ifdef Q_OS_WIN
+class QProcEnvKey : public QString
+{
+public:
+ QProcEnvKey() {}
+ explicit QProcEnvKey(const QString &other) : QString(other) {}
+ QProcEnvKey(const QProcEnvKey &other) : QString(other) {}
+ bool operator==(const QProcEnvKey &other) const { return !compare(other, Qt::CaseInsensitive); }
+};
+inline uint qHash(const QProcEnvKey &key) { return qHash(key.toCaseFolded()); }
+
+typedef QString QProcEnvValue;
+#else
+class QProcEnvKey
+{
+public:
+ QProcEnvKey() : hash(0) {}
+ explicit QProcEnvKey(const QByteArray &other) : key(other), hash(qHash(key)) {}
+ QProcEnvKey(const QProcEnvKey &other) { *this = other; }
+ bool operator==(const QProcEnvKey &other) const { return key == other.key; }
+
+ QByteArray key;
+ uint hash;
+};
+inline uint qHash(const QProcEnvKey &key) { return key.hash; }
+
+class QProcEnvValue
+{
+public:
+ QProcEnvValue() {}
+ QProcEnvValue(const QProcEnvValue &other) { *this = other; }
+ explicit QProcEnvValue(const QString &value) : stringValue(value) {}
+ explicit QProcEnvValue(const QByteArray &value) : byteValue(value) {}
+ bool operator==(const QProcEnvValue &other) const
+ {
+ return byteValue.isEmpty() && other.byteValue.isEmpty()
+ ? stringValue == other.stringValue
+ : bytes() == other.bytes();
+ }
+ QByteArray bytes() const
+ {
+ if (byteValue.isEmpty() && !stringValue.isEmpty())
+ byteValue = stringValue.toLocal8Bit();
+ return byteValue;
+ }
+ QString string() const
+ {
+ if (stringValue.isEmpty() && !byteValue.isEmpty())
+ stringValue = QString::fromLocal8Bit(byteValue);
+ return stringValue;
+ }
+
+ mutable QByteArray byteValue;
+ mutable QString stringValue;
+};
+Q_DECLARE_TYPEINFO(QProcEnvValue, Q_MOVABLE_TYPE);
+#endif
+Q_DECLARE_TYPEINFO(QProcEnvKey, Q_MOVABLE_TYPE);
+
class QProcessEnvironmentPrivate: public QSharedData
{
public:
+ typedef QProcEnvKey Key;
+ typedef QProcEnvValue Value;
#ifdef Q_OS_WIN
- typedef QString Unit;
+ inline Key prepareName(const QString &name) const { return Key(name); }
+ inline QString nameToString(const Key &name) const { return name; }
+ inline Value prepareValue(const QString &value) const { return value; }
+ inline QString valueToString(const Value &value) const { return value; }
#else
- typedef QByteArray Unit;
+ inline Key prepareName(const QString &name) const
+ {
+ Key &ent = nameMap[name];
+ if (ent.key.isEmpty())
+ ent = Key(name.toLocal8Bit());
+ return ent;
+ }
+ inline QString nameToString(const Key &name) const
+ {
+ const QString sname = QString::fromLocal8Bit(name.key);
+ nameMap[sname] = name;
+ return sname;
+ }
+ inline Value prepareValue(const QString &value) const { return Value(value); }
+ inline QString valueToString(const Value &value) const { return value.string(); }
#endif
- typedef QHash<Unit, Unit> Hash;
+
+ typedef QHash<Key, Value> Hash;
Hash hash;
+#ifdef Q_OS_UNIX
+ typedef QHash<QString, Key> NameHash;
+ mutable NameHash nameMap;
+#endif
+
static QProcessEnvironment fromList(const QStringList &list);
QStringList toList() const;
QStringList keys() const;
- void insert(const Hash &hash);
+ void insert(const QProcessEnvironmentPrivate &other);
};
+template<> Q_INLINE_TEMPLATE void QSharedDataPointer<QProcessEnvironmentPrivate>::detach()
+{
+ if (d && d->ref == 1)
+ return;
+ QProcessEnvironmentPrivate *x = (d ? new QProcessEnvironmentPrivate(*d)
+ : new QProcessEnvironmentPrivate);
+ x->ref.ref();
+ if (d && !d->ref.deref())
+ delete d;
+ d = x;
+}
+
class QProcessPrivate : public QIODevicePrivate
{
public:
diff --git a/src/corelib/io/qprocess_symbian.cpp b/src/corelib/io/qprocess_symbian.cpp
index 8a74c7b..2ce7a00 100644
--- a/src/corelib/io/qprocess_symbian.cpp
+++ b/src/corelib/io/qprocess_symbian.cpp
@@ -1062,6 +1062,11 @@ void QProcessPrivate::initializeProcessManager()
(void) processManager();
}
+QProcessEnvironment QProcessEnvironment::systemEnvironment()
+{
+ return QProcessEnvironment();
+}
+
QT_END_NAMESPACE
#endif // QT_NO_PROCESS
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 3af9b46..5616d39 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -453,7 +453,35 @@ bool QProcessPrivate::createChannel(Channel &channel)
}
}
-static char **_q_dupEnvironment(const QHash<QByteArray, QByteArray> &environment, int *envc)
+QT_BEGIN_INCLUDE_NAMESPACE
+#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+# include <crt_externs.h>
+# define environ (*_NSGetEnviron())
+#else
+ extern char **environ;
+#endif
+QT_END_INCLUDE_NAMESPACE
+
+QProcessEnvironment QProcessEnvironment::systemEnvironment()
+{
+ QProcessEnvironment env;
+#if !defined(Q_OS_MAC) || !defined(QT_NO_CORESERVICES)
+ const char *entry;
+ for (int count = 0; (entry = environ[count]); ++count) {
+ const char *equal = strchr(entry, '=');
+ if (!equal)
+ continue;
+
+ QByteArray name(entry, equal - entry);
+ QByteArray value(equal + 1);
+ env.d->hash.insert(QProcessEnvironmentPrivate::Key(name),
+ QProcessEnvironmentPrivate::Value(value));
+ }
+#endif
+ return env;
+}
+
+static char **_q_dupEnvironment(const QProcessEnvironmentPrivate::Hash &environment, int *envc)
{
*envc = 0;
if (environment.isEmpty())
@@ -469,17 +497,17 @@ static char **_q_dupEnvironment(const QHash<QByteArray, QByteArray> &environment
#endif
const QByteArray envLibraryPath = qgetenv(libraryPath);
bool needToAddLibraryPath = !envLibraryPath.isEmpty() &&
- !environment.contains(libraryPath);
+ !environment.contains(QProcessEnvironmentPrivate::Key(QByteArray(libraryPath)));
char **envp = new char *[environment.count() + 2];
envp[environment.count()] = 0;
envp[environment.count() + 1] = 0;
- QHash<QByteArray, QByteArray>::ConstIterator it = environment.constBegin();
- const QHash<QByteArray, QByteArray>::ConstIterator end = environment.constEnd();
+ QProcessEnvironmentPrivate::Hash::ConstIterator it = environment.constBegin();
+ const QProcessEnvironmentPrivate::Hash::ConstIterator end = environment.constEnd();
for ( ; it != end; ++it) {
- QByteArray key = it.key();
- QByteArray value = it.value();
+ QByteArray key = it.key().key;
+ QByteArray value = it.value().bytes();
key.reserve(key.length() + 1 + value.length());
key.append('=');
key.append(value);
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 625ed98..bb23954 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -278,29 +278,55 @@ static QString qt_create_commandline(const QString &program, const QStringList &
return args;
}
-static QByteArray qt_create_environment(const QHash<QString, QString> &environment)
+QProcessEnvironment QProcessEnvironment::systemEnvironment()
+{
+ QProcessEnvironment env;
+#if !defined(Q_OS_WINCE)
+ // Calls to setenv() affect the low-level environment as well.
+ // This is not the case the other way round.
+ if (wchar_t *envStrings = GetEnvironmentStringsW()) {
+ for (const wchar_t *entry = envStrings; *entry; ) {
+ int entryLen = wcslen(entry);
+ if (const wchar_t *equal = wcschr(entry, L'=')) {
+ int nameLen = equal - entry;
+ QString name = QString::fromWCharArray(entry, nameLen);
+ QString value = QString::fromWCharArray(equal + 1, entryLen - nameLen - 1);
+ env.d->hash.insert(QProcessEnvironmentPrivate::Key(name), value);
+ }
+ entry += entryLen + 1;
+ }
+ FreeEnvironmentStringsW(envStrings);
+ }
+#endif
+ return env;
+}
+
+#if !defined(Q_OS_WINCE)
+static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Hash &environment)
{
QByteArray envlist;
if (!environment.isEmpty()) {
- QHash<QString, QString> copy = environment;
+ QProcessEnvironmentPrivate::Hash copy = environment;
// add PATH if necessary (for DLL loading)
- if (!copy.contains(QLatin1String("PATH"))) {
+ QProcessEnvironmentPrivate::Key pathKey(QLatin1String("PATH"));
+ if (!copy.contains(pathKey)) {
QByteArray path = qgetenv("PATH");
if (!path.isEmpty())
- copy.insert(QLatin1String("PATH"), QString::fromLocal8Bit(path));
+ copy.insert(pathKey, QString::fromLocal8Bit(path));
}
// add systemroot if needed
- if (!copy.contains(QLatin1String("SYSTEMROOT"))) {
- QByteArray systemRoot = qgetenv("SYSTEMROOT");
+ QProcessEnvironmentPrivate::Key rootKey(QLatin1String("SystemRoot"));
+ if (!copy.contains(rootKey)) {
+ QByteArray systemRoot = qgetenv("SystemRoot");
if (!systemRoot.isEmpty())
- copy.insert(QLatin1String("SYSTEMROOT"), QString::fromLocal8Bit(systemRoot));
+ copy.insert(rootKey, QString::fromLocal8Bit(systemRoot));
}
int pos = 0;
- QHash<QString, QString>::ConstIterator it = copy.constBegin(),
- end = copy.constEnd();
+ QProcessEnvironmentPrivate::Hash::ConstIterator it = copy.constBegin(),
+ end = copy.constEnd();
static const wchar_t equal = L'=';
static const wchar_t nul = L'\0';
@@ -335,6 +361,7 @@ static QByteArray qt_create_environment(const QHash<QString, QString> &environme
}
return envlist;
}
+#endif
void QProcessPrivate::startProcess()
{
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index b084ca5..f43fb31 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -981,23 +981,6 @@ QStringList QSettingsPrivate::splitArgs(const QString &s, int idx)
// ************************************************************************
// QConfFileSettingsPrivate
-/*
- If we don't have the permission to read the file, returns false.
- If the file doesn't exist, returns true.
-*/
-static bool checkAccess(const QString &name)
-{
- QFileInfo fileInfo(name);
-
- if (fileInfo.exists()) {
- QFile file(name);
- // if the file exists but we can't open it, report an error
- return file.open(QFile::ReadOnly);
- } else {
- return true;
- }
-}
-
void QConfFileSettingsPrivate::initFormat()
{
extension = (format == QSettings::NativeFormat) ? QLatin1String(".conf") : QLatin1String(".ini");
@@ -1026,18 +1009,13 @@ void QConfFileSettingsPrivate::initFormat()
void QConfFileSettingsPrivate::initAccess()
{
- bool readAccess = false;
if (confFiles[spec]) {
- readAccess = checkAccess(confFiles[spec]->name);
if (format > QSettings::IniFormat) {
if (!readFunc)
- readAccess = false;
+ setStatus(QSettings::AccessError);
}
}
- if (!readAccess)
- setStatus(QSettings::AccessError);
-
sync(); // loads the files the first time
}
@@ -1432,7 +1410,7 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
We can often optimize the read-only case, if the file on disk
hasn't changed.
*/
- if (readOnly) {
+ if (readOnly && confFile->size > 0) {
QFileInfo fileInfo(confFile->name);
if (confFile->size == fileInfo.size() && confFile->timeStamp == fileInfo.lastModified())
return;
@@ -1455,6 +1433,9 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
if (!file.isOpen())
file.open(QFile::ReadOnly);
+ if (!createFile && !file.isOpen())
+ setStatus(QSettings::AccessError);
+
#ifdef Q_OS_WIN
HANDLE readSemaphore = 0;
HANDLE writeSemaphore = 0;
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index be86c58..c0b1748 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -270,6 +270,17 @@ bool QCoreApplicationPrivate::is_app_closing = false;
Q_CORE_EXPORT bool qt_locale_initialized = false;
+/*
+ Create an instance of Trolltech.conf. This ensures that the settings will not
+ be thrown out of QSetting's cache for unused settings.
+ */
+Q_GLOBAL_STATIC_WITH_ARGS(QSettings, staticTrolltechConf, (QSettings::UserScope, QLatin1String("Trolltech")))
+
+QSettings *QCoreApplicationPrivate::trolltechConf()
+{
+ return staticTrolltechConf();
+}
+
Q_CORE_EXPORT uint qGlobalPostedEventsCount()
{
QThreadData *currentThreadData = QThreadData::current();
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index add2a35..eb46ae5 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -55,6 +55,7 @@
#include "QtCore/qcoreapplication.h"
#include "QtCore/qtranslator.h"
+#include "QtCore/qsettings.h"
#include "private/qobject_p.h"
#ifdef Q_OS_SYMBIAN
@@ -139,6 +140,7 @@ public:
#if defined(QT3_SUPPORT)
static bool useQt3Support;
#endif
+ static QSettings *trolltechConf();
};
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index fbb08fa..a8cf5f1 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -231,8 +231,6 @@ QT_BEGIN_NAMESPACE
\value WinIdChange The window system identifer for this native widget has changed
\value Gesture A gesture was triggered (QGestureEvent)
\value GestureOverride A gesture override was triggered (QGestureEvent)
- \value ScrollPrepare The object needs to fill in its geometry information (QScrollPrepareEvent)
- \value Scroll The object needs to scroll to the supplied position (QScrollEvent)
User events should have values between \c User and \c{MaxUser}:
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index c9d311a..c151c5e 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -288,9 +288,6 @@ public:
Gesture = 198,
GestureOverride = 202,
#endif
- ScrollPrepare = 204,
- Scroll = 205,
-
// 512 reserved for Qt Jambi's MetaCall event
// 513 reserved for Qt Jambi's DeleteOnMainThread event
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index e0eeb08..bd12726 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -1111,6 +1111,12 @@ bool QEventDispatcherSymbian::hasPendingEvents()
void QEventDispatcherSymbian::registerSocketNotifier ( QSocketNotifier * notifier )
{
+ //check socket descriptor is usable
+ if (notifier->socket() >= FD_SETSIZE || notifier->socket() < 0) {
+ //same warning message as the unix event dispatcher for easy testing
+ qWarning("QSocketNotifier: Internal error");
+ return;
+ }
//note - this is only for "open C" file descriptors
//for native sockets, an active object in the symbian socket engine handles this
QSocketActiveObject *socketAO = new QSocketActiveObject(this, notifier);
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 80e927b..d9aac00 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -52,6 +52,7 @@
#include <qmap.h>
#include <qsettings.h>
#include <qdatetime.h>
+#include <private/qcoreapplication_p.h>
#ifdef Q_OS_MAC
# include <private/qcore_mac_p.h>
#endif
@@ -408,12 +409,6 @@ static bool qt_unix_query(const QString &library, uint *version, bool *debug, QB
typedef QMap<QString, QLibraryPrivate*> LibraryMap;
struct LibraryData {
- LibraryData() : settings(0) { }
- ~LibraryData() {
- delete settings;
- }
-
- QSettings *settings;
LibraryMap libraryMap;
QSet<QLibraryPrivate*> loadedLibs;
};
@@ -711,11 +706,7 @@ bool QLibraryPrivate::isPlugin(QSettings *settings)
QStringList reg;
#ifndef QT_NO_SETTINGS
if (!settings) {
- settings = libraryData()->settings;
- if (!settings) {
- settings = new QSettings(QSettings::UserScope, QLatin1String("Trolltech"));
- libraryData()->settings = settings;
- }
+ settings = QCoreApplicationPrivate::trolltechConf();
}
reg = settings->value(regkey).toStringList();
#endif
diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp
index 11e2060..b584ae5 100644
--- a/src/corelib/thread/qmutex_unix.cpp
+++ b/src/corelib/thread/qmutex_unix.cpp
@@ -107,18 +107,21 @@ bool QMutexPrivate::wait(int timeout)
// lock acquired without waiting
return true;
}
- bool returnValue;
+ kern_return_t r;
if (timeout < 0) {
- returnValue = semaphore_wait(mach_semaphore) == KERN_SUCCESS;
+ do {
+ r = semaphore_wait(mach_semaphore);
+ } while (r == KERN_ABORTED);
+ if (r != KERN_SUCCESS)
+ qWarning("QMutex: infinite wait failed, error %d", r);
} else {
mach_timespec_t ts;
ts.tv_nsec = ((timeout % 1000) * 1000) * 1000;
ts.tv_sec = (timeout / 1000);
- kern_return_t r = semaphore_timedwait(mach_semaphore, ts);
- returnValue = r == KERN_SUCCESS;
+ r = semaphore_timedwait(mach_semaphore, ts);
}
contenders.deref();
- return returnValue;
+ return r == KERN_SUCCESS;
}
void QMutexPrivate::wakeUp()
diff --git a/src/corelib/thread/qthread_symbian.cpp b/src/corelib/thread/qthread_symbian.cpp
index 5d8b5cb..665aadd 100644
--- a/src/corelib/thread/qthread_symbian.cpp
+++ b/src/corelib/thread/qthread_symbian.cpp
@@ -329,6 +329,8 @@ void *QThreadPrivate::start(void *arg)
data->quitNow = thr->d_func()->exited;
}
+ CTrapCleanup *cleanup = CTrapCleanup::New();
+
// ### TODO: allow the user to create a custom event dispatcher
createEventDispatcher(data);
@@ -337,6 +339,8 @@ void *QThreadPrivate::start(void *arg)
QThreadPrivate::finish(arg);
+ delete cleanup;
+
return 0;
}
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 0627b4e..df58d95 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -57,9 +57,10 @@
# ifdef QT_USE_FAST_OPERATOR_PLUS
# undef QT_USE_FAST_OPERATOR_PLUS
# endif
-# ifdef QT_USE_FAST_CONCATENATION
-# undef QT_USE_FAST_CONCATENATION
+# ifdef QT_USE_QSTRINGBUILDER
+# undef QT_USE_QSTRINGBUILDER
# endif
+
#endif
@@ -559,8 +560,7 @@ inline bool operator>=(const QByteArray &a1, const char *a2)
{ return qstrcmp(a1, a2) >= 0; }
inline bool operator>=(const char *a1, const QByteArray &a2)
{ return qstrcmp(a1, a2) >= 0; }
-#ifndef QT_USE_FAST_OPERATOR_PLUS
-# ifndef QT_USE_FAST_CONCATENATION
+#if !defined(QT_USE_QSTRINGBUILDER)
inline const QByteArray operator+(const QByteArray &a1, const QByteArray &a2)
{ return QByteArray(a1) += a2; }
inline const QByteArray operator+(const QByteArray &a1, const char *a2)
@@ -571,8 +571,7 @@ inline const QByteArray operator+(const char *a1, const QByteArray &a2)
{ return QByteArray(a1) += a2; }
inline const QByteArray operator+(char a1, const QByteArray &a2)
{ return QByteArray(&a1, 1) += a2; }
-# endif // QT_USE_FAST_CONCATENATION
-#endif // QT_USE_FAST_OPERATOR_PLUS
+#endif // QT_USE_QSTRINGBUILDER
inline QBool QByteArray::contains(const char *c) const
{ return QBool(indexOf(c) != -1); }
inline QByteArray &QByteArray::replace(char before, const char *c)
@@ -615,7 +614,7 @@ QT_END_NAMESPACE
QT_END_HEADER
-#ifdef QT_USE_FAST_CONCATENATION
+#ifdef QT_USE_QSTRINGBUILDER
#include <QtCore/qstring.h>
#endif
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index a3a8884..d9a054a 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -2460,7 +2460,11 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
If the \a format is Qt::ISODate, the string format corresponds
to the ISO 8601 extended specification for representations of
- dates and times, taking the form YYYY-MM-DDTHH:MM:SS.
+ dates and times, taking the form YYYY-MM-DDTHH:MM:SS[Z|[+|-]HH:MM],
+ depending on the timeSpec() of the QDateTime. If the timeSpec()
+ is Qt::UTC, Z will be appended to the string; if the timeSpec() is
+ Qt::OffsetFromUTC the offset in hours and minutes from UTC will
+ be appended to the string.
If the \a format is Qt::SystemLocaleShortDate or
Qt::SystemLocaleLongDate, the string format depends on the locale
@@ -2497,6 +2501,21 @@ QString QDateTime::toString(Qt::DateFormat f) const
return QString(); // failed to convert
buf += QLatin1Char('T');
buf += d->time.toString(Qt::ISODate);
+ switch (d->spec) {
+ case QDateTimePrivate::UTC:
+ buf += QLatin1Char('Z');
+ break;
+ case QDateTimePrivate::OffsetFromUTC: {
+ int sign = d->utcOffset >= 0 ? 1: -1;
+ buf += QString::fromLatin1("%1%2:%3").
+ arg(sign == 1 ? QLatin1Char('+') : QLatin1Char('-')).
+ arg(d->utcOffset * sign / SECS_PER_HOUR, 2, 10, QLatin1Char('0')).
+ arg((d->utcOffset / 60) % 60, 2, 10, QLatin1Char('0'));
+ break;
+ }
+ default:
+ break;
+ }
}
#ifndef QT_NO_TEXTDATE
else if (f == Qt::TextDate) {
diff --git a/src/corelib/tools/qelapsedtimer_symbian.cpp b/src/corelib/tools/qelapsedtimer_symbian.cpp
index b831e03..3667b05 100644
--- a/src/corelib/tools/qelapsedtimer_symbian.cpp
+++ b/src/corelib/tools/qelapsedtimer_symbian.cpp
@@ -95,7 +95,7 @@ qint64 QElapsedTimer::restart()
qint64 oldt1 = t1;
t1 = getMicrosecondFromTick();
t2 = 0;
- return t1 - oldt1;
+ return (t1 - oldt1) / 1000;
}
qint64 QElapsedTimer::nsecsElapsed() const
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 5c4085a..c8ed94b 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -2782,8 +2782,6 @@ bool QLocalePrivate::numberToCLocale(const QString &num,
if (idx == l)
return false;
- const QChar _group = group();
-
while (idx < l) {
const QChar &in = uc[idx];
diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp
index 09d74d0..5dca7b7 100644
--- a/src/corelib/tools/qlocale_symbian.cpp
+++ b/src/corelib/tools/qlocale_symbian.cpp
@@ -44,6 +44,7 @@
#include <QTime>
#include <QVariant>
#include <QThread>
+#include <QStringList>
#include <e32std.h>
#include <e32const.h>
@@ -86,6 +87,7 @@ static TPtrC defaultFormatSpec(TExtendedLocale&)
struct symbianToISO {
int symbian_language;
char iso_name[8];
+ char uilanguage[8];
};
@@ -94,77 +96,80 @@ struct symbianToISO {
NOTE: This array should be sorted by the first column!
*/
static const symbianToISO symbian_to_iso_list[] = {
- { ELangEnglish, "en_GB" }, // 1
- { ELangFrench, "fr_FR" }, // 2
- { ELangGerman, "de_DE" }, // 3
- { ELangSpanish, "es_ES" }, // 4
- { ELangItalian, "it_IT" }, // 5
- { ELangSwedish, "sv_SE" }, // 6
- { ELangDanish, "da_DK" }, // 7
- { ELangNorwegian, "no_NO" }, // 8
- { ELangFinnish, "fi_FI" }, // 9
- { ELangAmerican, "en_US" }, // 10
- { ELangPortuguese, "pt_PT" }, // 13
- { ELangTurkish, "tr_TR" }, // 14
- { ELangIcelandic, "is_IS" }, // 15
- { ELangRussian, "ru_RU" }, // 16
- { ELangHungarian, "hu_HU" }, // 17
- { ELangDutch, "nl_NL" }, // 18
- { ELangBelgianFlemish, "nl_BE" }, // 19
- { ELangCzech, "cs_CZ" }, // 25
- { ELangSlovak, "sk_SK" }, // 26
- { ELangPolish, "pl_PL" }, // 27
- { ELangSlovenian, "sl_SI" }, // 28
- { ELangTaiwanChinese, "zh_TW" }, // 29
- { ELangHongKongChinese, "zh_HK" }, // 30
- { ELangPrcChinese, "zh_CN" }, // 31
- { ELangJapanese, "ja_JP" }, // 32
- { ELangThai, "th_TH" }, // 33
- { ELangArabic, "ar_AE" }, // 37
- { ELangTagalog, "tl_PH" }, // 39
- { ELangBulgarian, "bg_BG" }, // 42
- { ELangCatalan, "ca_ES" }, // 44
- { ELangCroatian, "hr_HR" }, // 45
- { ELangEstonian, "et_EE" }, // 49
- { ELangFarsi, "fa_IR" }, // 50
- { ELangCanadianFrench, "fr_CA" }, // 51
- { ELangGreek, "el_GR" }, // 54
- { ELangHebrew, "he_IL" }, // 57
- { ELangHindi, "hi_IN" }, // 58
- { ELangIndonesian, "id_ID" }, // 59
- { ELangKorean, "ko_KO" }, // 65
- { ELangLatvian, "lv_LV" }, // 67
- { ELangLithuanian, "lt_LT" }, // 68
- { ELangMalay, "ms_MY" }, // 70
- { ELangNorwegianNynorsk, "nn_NO" }, // 75
- { ELangBrazilianPortuguese, "pt_BR" }, // 76
- { ELangRomanian, "ro_RO" }, // 78
- { ELangSerbian, "sr_RS" }, // 79
- { ELangLatinAmericanSpanish,"es_419" }, // 83
- { ELangUkrainian, "uk_UA" }, // 93
- { ELangUrdu, "ur_PK" }, // 94 - India/Pakistan
- { ELangVietnamese, "vi_VN" }, // 96
+ { ELangEnglish, "en_GB", "en" }, // 1
+ { ELangFrench, "fr_FR", "fr" }, // 2
+ { ELangGerman, "de_DE", "de" }, // 3
+ { ELangSpanish, "es_ES", "es" }, // 4
+ { ELangItalian, "it_IT", "it" }, // 5
+ { ELangSwedish, "sv_SE", "sv" }, // 6
+ { ELangDanish, "da_DK", "da" }, // 7
+ { ELangNorwegian, "nb_NO", "nb" }, // 8
+ { ELangFinnish, "fi_FI", "fi" }, // 9
+ { ELangAmerican, "en_US", "en-US" }, // 10
+ { ELangPortuguese, "pt_PT", "pt" }, // 13
+ { ELangTurkish, "tr_TR", "tr" }, // 14
+ { ELangIcelandic, "is_IS", "is" }, // 15
+ { ELangRussian, "ru_RU", "ru" }, // 16
+ { ELangHungarian, "hu_HU", "hu" }, // 17
+ { ELangDutch, "nl_NL", "nl" }, // 18
+ { ELangCzech, "cs_CZ", "cs" }, // 25
+ { ELangSlovak, "sk_SK", "sk" }, // 26
+ { ELangPolish, "pl_PL", "pl" }, // 27
+ { ELangSlovenian, "sl_SI", "sl" }, // 28
+ { ELangTaiwanChinese, "zh_TW", "zh-TW" }, // 29
+ { ELangHongKongChinese, "zh_HK", "zh-HK" }, // 30
+ { ELangPrcChinese, "zh_CN", "zh" }, // 31
+ { ELangJapanese, "ja_JP", "ja" }, // 32
+ { ELangThai, "th_TH", "th" }, // 33
+ { ELangArabic, "ar_AE", "ar" }, // 37
+ { ELangTagalog, "tl_PH", "tl" }, // 39
+ { ELangBulgarian, "bg_BG", "bg" }, // 42
+ { ELangCatalan, "ca_ES", "ca" }, // 44
+ { ELangCroatian, "hr_HR", "hr" }, // 45
+ { ELangEstonian, "et_EE", "et" }, // 49
+ { ELangFarsi, "fa_IR", "fa" }, // 50
+ { ELangCanadianFrench, "fr_CA", "fr-CA" }, // 51
+ { ELangGreek, "el_GR", "el" }, // 54
+ { ELangHebrew, "he_IL", "he" }, // 57
+ { ELangHindi, "hi_IN", "hi" }, // 58
+ { ELangIndonesian, "id_ID", "id" }, // 59
+ { 63/*ELangKazakh*/, "kk_KZ", "kk" }, // 63
+ { ELangKorean, "ko_KO", "ko" }, // 65
+ { ELangLatvian, "lv_LV", "lv" }, // 67
+ { ELangLithuanian, "lt_LT", "lt" }, // 68
+ { ELangMalay, "ms_MY", "ms" }, // 70
+ { ELangNorwegianNynorsk, "nn_NO", "nn" }, // 75
+ { ELangBrazilianPortuguese, "pt_BR", "pt-BR" }, // 76
+ { ELangRomanian, "ro_RO", "ro" }, // 78
+ { ELangSerbian, "sr_RS", "sr" }, // 79
+ { ELangLatinAmericanSpanish,"es_419", "es-419" },// 83
+ { ELangUkrainian, "uk_UA", "uk" }, // 93
+ { ELangUrdu, "ur_PK", "ur" }, // 94 - India/Pakistan
+ { ELangVietnamese, "vi_VN", "vi" }, // 96
#ifdef __E32LANG_H__
// 5.0
- { ELangBasque, "eu_ES" }, // 102
- { ELangGalician, "gl_ES" }, // 103
+ { ELangBasque, "eu_ES", "eu" }, // 102
+ { ELangGalician, "gl_ES", "gl" }, // 103
#endif
#if !defined(__SERIES60_31__)
- { ELangEnglish_Apac, "en" }, // 129
- { ELangEnglish_Taiwan, "en_TW" }, // 157 ### Not supported by CLDR
- { ELangEnglish_HongKong, "en_HK" }, // 158
- { ELangEnglish_Prc, "en_CN" }, // 159 ### Not supported by CLDR
- { ELangEnglish_Japan, "en_JP"}, // 160 ### Not supported by CLDR
- { ELangEnglish_Thailand, "en_TH" }, // 161 ### Not supported by CLDR
- { ELangMalay_Apac, "ms" }, // 326
+ { ELangEnglish_Apac, "en_GB", "en" }, // 129
+ { ELangEnglish_Taiwan, "en_TW", "en-TW" }, // 157 ### Not supported by CLDR
+ { ELangEnglish_HongKong, "en_HK", "en-HK" }, // 158
+ { ELangEnglish_Prc, "en_CN", "en-CN" }, // 159 ### Not supported by CLDR
+ { ELangEnglish_Japan, "en_JP", "en" }, // 160 ### Not supported by CLDR
+ { ELangEnglish_Thailand, "en_TH", "en" }, // 161 ### Not supported by CLDR
+ { 230/*ELangEnglish_India*/,"en_IN", "en" }, // 230
+ { ELangMalay_Apac, "ms_MY", "ms" }, // 326
#endif
- { 327/*ELangIndonesian_Apac*/,"id_ID" } // 327 - appeared in Symbian^3
+ { 327/*ELangIndonesian_Apac*/, "id_ID", "id" } // 327 - appeared in Symbian^3
};
-/*!
- Returns ISO name corresponding to the Symbian locale code \a sys_fmt.
-*/
-QByteArray qt_symbianLocaleName(int code)
+enum LocaleNameType {
+ ISO,
+ UILanguage
+};
+
+QByteArray qt_resolveSymbianLocaleName(int code, LocaleNameType type)
{
//Number of Symbian to ISO locale mappings
static const int symbian_to_iso_count
@@ -174,8 +179,11 @@ QByteArray qt_symbianLocaleName(int code)
if (cmp < 0)
return 0;
- if (cmp == 0)
- return symbian_to_iso_list[0].iso_name;
+ if (cmp == 0) {
+ if (type == ISO)
+ return symbian_to_iso_list[0].iso_name;
+ return symbian_to_iso_list[0].uilanguage;
+ }
int begin = 0;
int end = symbian_to_iso_count;
@@ -185,17 +193,27 @@ QByteArray qt_symbianLocaleName(int code)
const symbianToISO *elt = symbian_to_iso_list + mid;
int cmp = code - elt->symbian_language;
- if (cmp < 0)
+ if (cmp < 0) {
end = mid;
- else if (cmp > 0)
+ } else if (cmp > 0) {
begin = mid;
- else
- return elt->iso_name;
+ } else {
+ if (type == ISO)
+ return elt->iso_name;
+ return elt->uilanguage;
+ }
}
return 0;
}
+/*!
+ Returns ISO name corresponding to the Symbian locale code \a sys_fmt.
+*/
+QByteArray qt_symbianLocaleName(int code)
+{
+ return qt_resolveSymbianLocaleName(code, ISO);
+}
// order is: normal, abbr, nmode, nmode+abbr
static const char *us_locale_dep[] = {
@@ -822,6 +840,13 @@ QLocale QSystemLocale::fallbackLocale() const
return QLocale(locale);
}
+static QStringList symbianUILanguages()
+{
+ TLanguage lang = User::Language();
+ QString s = QLatin1String(qt_resolveSymbianLocaleName(lang, UILanguage));
+ return QStringList(s);
+}
+
QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
{
switch(type) {
@@ -889,6 +914,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
return qt_TDes2QString(TAmPmName(TAmPm(EAm)));
case PMText:
return qt_TDes2QString(TAmPmName(TAmPm(EPm)));
+ case UILanguages:
+ return QVariant(symbianUILanguages());
default:
break;
}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 5493ba9..3b3f715 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -777,16 +777,12 @@ const QString::Null QString::null = { };
\snippet doc/src/snippets/qstring/stringbuilder.cpp 5
- A more global approach is to include this define:
+ A more global approach which is the most convenient but
+ not entirely source compatible, is to this define in your
+ .pro file:
\snippet doc/src/snippets/qstring/stringbuilder.cpp 3
- and use \c{'%'} instead of \c{'+'} for string concatenation
- everywhere. The third approach, which is the most convenient but
- not entirely source compatible, is to include two defines:
-
- \snippet doc/src/snippets/qstring/stringbuilder.cpp 4
-
and the \c{'+'} will automatically be performed as the
\c{QStringBuilder} \c{'%'} everywhere.
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 66cfa74..7c4367e 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -695,9 +695,9 @@ inline QString::QString(const QLatin1String &aLatin1) : d(fromLatin1_helper(aLat
inline int QString::length() const
{ return d->size; }
inline const QChar QString::at(int i) const
-{ Q_ASSERT(i >= 0 && i < size()); return d->data[i]; }
+{ Q_ASSERT(uint(i) < uint(size())); return d->data[i]; }
inline const QChar QString::operator[](int i) const
-{ Q_ASSERT(i >= 0 && i < size()); return d->data[i]; }
+{ Q_ASSERT(uint(i) < uint(size())); return d->data[i]; }
inline const QChar QString::operator[](uint i) const
{ Q_ASSERT(i < uint(size())); return d->data[i]; }
inline bool QString::isEmpty() const
@@ -1016,8 +1016,7 @@ inline int QByteArray::findRev(const QString &s, int from) const
# endif // QT3_SUPPORT
#endif // QT_NO_CAST_TO_ASCII
-#ifndef QT_USE_FAST_OPERATOR_PLUS
-# ifndef QT_USE_FAST_CONCATENATION
+#if !defined(QT_USE_FAST_OPERATOR_PLUS) && !defined(QT_USE_QSTRINGBUILDER)
inline const QString operator+(const QString &s1, const QString &s2)
{ QString t(s1); t += s2; return t; }
inline const QString operator+(const QString &s1, QChar s2)
@@ -1038,8 +1037,7 @@ inline QT_ASCII_CAST_WARN const QString operator+(const QByteArray &ba, const QS
inline QT_ASCII_CAST_WARN const QString operator+(const QString &s, const QByteArray &ba)
{ QString t(s); t += QString::fromAscii(ba.constData(), qstrnlen(ba.constData(), ba.size())); return t; }
# endif // QT_NO_CAST_FROM_ASCII
-# endif // QT_USE_FAST_CONCATENATION
-#endif // QT_USE_FAST_OPERATOR_PLUS
+#endif // QT_USE_QSTRINGBUILDER
#ifndef QT_NO_STL
inline std::string QString::toStdString() const
@@ -1288,7 +1286,7 @@ QT_END_NAMESPACE
QT_END_HEADER
-#ifdef QT_USE_FAST_CONCATENATION
+#if defined(QT_USE_FAST_OPERATOR_PLUS) || defined(QT_USE_QSTRINGBUILDER)
#include <QtCore/qstringbuilder.h>
#endif
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 2d3475f..029aa0b 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -410,7 +410,9 @@ operator%(const A &a, const B &b)
return QStringBuilder<typename QConcatenable<A>::type, typename QConcatenable<B>::type>(a, b);
}
-#ifdef QT_USE_FAST_OPERATOR_PLUS
+// QT_USE_FAST_OPERATOR_PLUS was introduced in 4.7, QT_USE_QSTRINGBUILDER is to be used from 4.8 onwards
+// QT_USE_FAST_OPERATOR_PLUS does not remove the normal operator+ for QByteArray
+#if defined(QT_USE_FAST_OPERATOR_PLUS) || defined(QT_USE_QSTRINGBUILDER)
template <typename A, typename B>
QStringBuilder<typename QConcatenable<A>::type, typename QConcatenable<B>::type>
operator+(const A &a, const B &b)
diff --git a/src/corelib/tools/qtextboundaryfinder.cpp b/src/corelib/tools/qtextboundaryfinder.cpp
index 34bc406..47319d4 100644
--- a/src/corelib/tools/qtextboundaryfinder.cpp
+++ b/src/corelib/tools/qtextboundaryfinder.cpp
@@ -199,11 +199,11 @@ QTextBoundaryFinder &QTextBoundaryFinder::operator=(const QTextBoundaryFinder &o
chars = other.chars;
length = other.length;
pos = other.pos;
- freePrivate = true;
QTextBoundaryFinderPrivate *newD = (QTextBoundaryFinderPrivate *)
- realloc(d, length*sizeof(HB_CharAttributes));
+ realloc(freePrivate ? d : 0, length*sizeof(HB_CharAttributes));
Q_CHECK_PTR(newD);
+ freePrivate = true;
d = newD;
memcpy(d, other.d, length*sizeof(HB_CharAttributes));
diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri
index 75287b4..044db3c 100644
--- a/src/declarative/debugger/debugger.pri
+++ b/src/declarative/debugger/debugger.pri
@@ -8,7 +8,10 @@ SOURCES += \
$$PWD/qdeclarativedebug.cpp \
$$PWD/qdeclarativedebugtrace.cpp \
$$PWD/qdeclarativedebughelper.cpp \
- $$PWD/qdeclarativedebugserver.cpp
+ $$PWD/qdeclarativedebugserver.cpp \
+ $$PWD/qdeclarativeobserverservice.cpp \
+ $$PWD/qjsdebuggeragent.cpp \
+ $$PWD/qjsdebugservice.cpp
HEADERS += \
$$PWD/qdeclarativedebuggerstatus_p.h \
@@ -20,4 +23,8 @@ HEADERS += \
$$PWD/qdeclarativedebugtrace_p.h \
$$PWD/qdeclarativedebughelper_p.h \
$$PWD/qdeclarativedebugserver_p.h \
- debugger/qdeclarativedebugserverconnection_p.h
+ $$PWD/qdeclarativedebugserverconnection_p.h \
+ $$PWD/qdeclarativeobserverservice_p.h \
+ $$PWD/qdeclarativeobserverinterface_p.h \
+ $$PWD/qjsdebuggeragent_p.h \
+ $$PWD/qjsdebugservice_p.h
diff --git a/src/declarative/debugger/qdeclarativedebug.cpp b/src/declarative/debugger/qdeclarativedebug.cpp
index 62eb8fe..049e05e 100644
--- a/src/declarative/debugger/qdeclarativedebug.cpp
+++ b/src/declarative/debugger/qdeclarativedebug.cpp
@@ -84,6 +84,7 @@ public:
static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugRootContextQuery *);
static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugObjectQuery *);
static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugExpressionQuery *);
+ static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugWatch *);
QHash<int, QDeclarativeDebugEnginesQuery *> enginesQuery;
QHash<int, QDeclarativeDebugRootContextQuery *> rootContextQuery;
@@ -120,6 +121,41 @@ QDeclarativeEngineDebugPrivate::~QDeclarativeEngineDebugPrivate()
{
if (client)
client->priv = 0;
+ delete client;
+
+ QHash<int, QDeclarativeDebugEnginesQuery*>::iterator enginesIter = enginesQuery.begin();
+ for (; enginesIter != enginesQuery.end(); ++enginesIter) {
+ enginesIter.value()->m_client = 0;
+ if (enginesIter.value()->state() == QDeclarativeDebugQuery::Waiting)
+ enginesIter.value()->setState(QDeclarativeDebugQuery::Error);
+ }
+
+ QHash<int, QDeclarativeDebugRootContextQuery*>::iterator rootContextIter = rootContextQuery.begin();
+ for (; rootContextIter != rootContextQuery.end(); ++rootContextIter) {
+ rootContextIter.value()->m_client = 0;
+ if (rootContextIter.value()->state() == QDeclarativeDebugQuery::Waiting)
+ rootContextIter.value()->setState(QDeclarativeDebugQuery::Error);
+ }
+
+ QHash<int, QDeclarativeDebugObjectQuery*>::iterator objectIter = objectQuery.begin();
+ for (; objectIter != objectQuery.end(); ++objectIter) {
+ objectIter.value()->m_client = 0;
+ if (objectIter.value()->state() == QDeclarativeDebugQuery::Waiting)
+ objectIter.value()->setState(QDeclarativeDebugQuery::Error);
+ }
+
+ QHash<int, QDeclarativeDebugExpressionQuery*>::iterator exprIter = expressionQuery.begin();
+ for (; exprIter != expressionQuery.end(); ++exprIter) {
+ exprIter.value()->m_client = 0;
+ if (exprIter.value()->state() == QDeclarativeDebugQuery::Waiting)
+ exprIter.value()->setState(QDeclarativeDebugQuery::Error);
+ }
+
+ QHash<int, QDeclarativeDebugWatch*>::iterator watchIter = watched.begin();
+ for (; watchIter != watched.end(); ++watchIter) {
+ watchIter.value()->m_client = 0;
+ watchIter.value()->setState(QDeclarativeDebugWatch::Dead);
+ }
}
int QDeclarativeEngineDebugPrivate::getId()
@@ -160,6 +196,14 @@ void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclara
}
}
+void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugWatch *w)
+{
+ if (c && w) {
+ QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c);
+ p->watched.remove(w->m_queryId);
+ }
+}
+
void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugObjectReference &o,
bool simple)
{
@@ -647,6 +691,8 @@ QDeclarativeDebugWatch::QDeclarativeDebugWatch(QObject *parent)
QDeclarativeDebugWatch::~QDeclarativeDebugWatch()
{
+ if (m_client && m_queryId != -1)
+ QDeclarativeEngineDebugPrivate::remove(m_client, this);
}
int QDeclarativeDebugWatch::queryId() const
diff --git a/src/declarative/debugger/qdeclarativedebugserver.cpp b/src/declarative/debugger/qdeclarativedebugserver.cpp
index c7bdcb6..4343870 100644
--- a/src/declarative/debugger/qdeclarativedebugserver.cpp
+++ b/src/declarative/debugger/qdeclarativedebugserver.cpp
@@ -90,7 +90,11 @@ public:
QHash<QString, QDeclarativeDebugService *> plugins;
QStringList clientPlugins;
bool gotHello;
+ QString waitingForMsgFromService;
+private:
+ // private slot
+ void _q_deliverMessage(const QString &serviceName, const QByteArray &message);
static QDeclarativeDebugServerConnection *loadConnectionPlugin(const QString &pluginName);
};
@@ -116,6 +120,7 @@ void QDeclarativeDebugServerPrivate::advertisePlugins()
QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectionPlugin(
const QString &pluginName)
{
+#ifndef QT_NO_LIBRARY
QStringList pluginCandidates;
const QStringList paths = QCoreApplication::libraryPaths();
foreach (const QString &libPath, paths) {
@@ -142,6 +147,7 @@ QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectio
return connection;
loader.unload();
}
+#endif
return 0;
}
@@ -235,7 +241,6 @@ void QDeclarativeDebugServer::receiveMessage(const QByteArray &message)
QDataStream in(message);
if (!d->gotHello) {
-
QString name;
int op;
in >> name >> op;
@@ -250,6 +255,17 @@ void QDeclarativeDebugServer::receiveMessage(const QByteArray &message)
int version;
in >> version >> d->clientPlugins;
+ // Send the hello answer immediately, since it needs to arrive before
+ // the plugins below start sending messages.
+ QByteArray helloAnswer;
+ {
+ QDataStream out(&helloAnswer, QIODevice::WriteOnly);
+ out << QString(QLatin1String("QDeclarativeDebugClient")) << 0 << protocolVersion << d->plugins.keys();
+ }
+ d->connection->send(helloAnswer);
+
+ d->gotHello = true;
+
QHash<QString, QDeclarativeDebugService*>::Iterator iter = d->plugins.begin();
for (; iter != d->plugins.end(); ++iter) {
QDeclarativeDebugService::Status newStatus = QDeclarativeDebugService::Unavailable;
@@ -259,14 +275,6 @@ void QDeclarativeDebugServer::receiveMessage(const QByteArray &message)
iter.value()->statusChanged(newStatus);
}
- QByteArray helloAnswer;
- {
- QDataStream out(&helloAnswer, QIODevice::WriteOnly);
- out << QString(QLatin1String("QDeclarativeDebugClient")) << 0 << protocolVersion << d->plugins.keys();
- }
- d->connection->send(helloAnswer);
-
- d->gotHello = true;
qWarning("QDeclarativeDebugServer: Connection established");
} else {
@@ -304,17 +312,33 @@ void QDeclarativeDebugServer::receiveMessage(const QByteArray &message)
QByteArray message;
in >> message;
- QHash<QString, QDeclarativeDebugService *>::Iterator iter =
- d->plugins.find(name);
- if (iter == d->plugins.end()) {
- qWarning() << "QDeclarativeDebugServer: Message received for missing plugin" << name;
+ if (d->waitingForMsgFromService == name) {
+ // deliver directly so that it is delivered before waitForMessage is returning.
+ d->_q_deliverMessage(name, message);
+ d->waitingForMsgFromService.clear();
} else {
- (*iter)->messageReceived(message);
+ // deliver message in next event loop run.
+ // Fixes the case that the service does start it's own event loop ...,
+ // but the networking code doesn't deliver any new messages because readyRead
+ // hasn't returned.
+ QMetaObject::invokeMethod(this, "_q_deliverMessage", Qt::QueuedConnection,
+ Q_ARG(QString, name),
+ Q_ARG(QByteArray, message));
}
}
}
}
+void QDeclarativeDebugServerPrivate::_q_deliverMessage(const QString &serviceName, const QByteArray &message)
+{
+ QHash<QString, QDeclarativeDebugService *>::Iterator iter = plugins.find(serviceName);
+ if (iter == plugins.end()) {
+ qWarning() << "QDeclarativeDebugServer: Message received for missing plugin" << serviceName;
+ } else {
+ (*iter)->messageReceived(message);
+ }
+}
+
QList<QDeclarativeDebugService*> QDeclarativeDebugServer::services() const
{
const Q_D(QDeclarativeDebugServer);
@@ -372,4 +396,23 @@ void QDeclarativeDebugServer::sendMessage(QDeclarativeDebugService *service,
d->connection->send(msg);
}
+bool QDeclarativeDebugServer::waitForMessage(QDeclarativeDebugService *service)
+{
+ Q_D(QDeclarativeDebugServer);
+
+ if (!service
+ || !d->plugins.contains(service->name())
+ || !d->waitingForMsgFromService.isEmpty())
+ return false;
+
+ d->waitingForMsgFromService = service->name();
+
+ do {
+ d->connection->waitForMessage();
+ } while (!d->waitingForMsgFromService.isEmpty());
+ return true;
+}
+
QT_END_NAMESPACE
+
+#include "moc_qdeclarativedebugserver_p.cpp"
diff --git a/src/declarative/debugger/qdeclarativedebugserver_p.h b/src/declarative/debugger/qdeclarativedebugserver_p.h
index 68ea4d8..72c664c 100644
--- a/src/declarative/debugger/qdeclarativedebugserver_p.h
+++ b/src/declarative/debugger/qdeclarativedebugserver_p.h
@@ -75,10 +75,13 @@ public:
void sendMessage(QDeclarativeDebugService *service, const QByteArray &message);
void receiveMessage(const QByteArray &message);
+ bool waitForMessage(QDeclarativeDebugService *service);
+
private:
friend class QDeclarativeDebugService;
friend class QDeclarativeDebugServicePrivate;
QDeclarativeDebugServer();
+ Q_PRIVATE_SLOT(d_func(), void _q_deliverMessage(QString, QByteArray))
};
QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h
index 0c2bdb4..ca267e0 100644
--- a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h
+++ b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h
@@ -62,6 +62,7 @@ public:
virtual bool isConnected() const = 0;
virtual void send(const QByteArray &message) = 0;
virtual void disconnect() = 0;
+ virtual bool waitForMessage() = 0;
};
Q_DECLARE_INTERFACE(QDeclarativeDebugServerConnection, "com.trolltech.Qt.QDeclarativeDebugServerConnection/1.0")
diff --git a/src/declarative/debugger/qdeclarativedebugservice.cpp b/src/declarative/debugger/qdeclarativedebugservice.cpp
index 1b39f1c..c7e6615 100644
--- a/src/declarative/debugger/qdeclarativedebugservice.cpp
+++ b/src/declarative/debugger/qdeclarativedebugservice.cpp
@@ -209,6 +209,16 @@ void QDeclarativeDebugService::sendMessage(const QByteArray &message)
d->server->sendMessage(this, message);
}
+bool QDeclarativeDebugService::waitForMessage()
+{
+ Q_D(QDeclarativeDebugService);
+
+ if (status() != Enabled)
+ return false;
+
+ return d->server->waitForMessage(this);
+}
+
void QDeclarativeDebugService::statusChanged(Status)
{
}
diff --git a/src/declarative/debugger/qdeclarativedebugservice_p.h b/src/declarative/debugger/qdeclarativedebugservice_p.h
index 5e30350..f3d1919 100644
--- a/src/declarative/debugger/qdeclarativedebugservice_p.h
+++ b/src/declarative/debugger/qdeclarativedebugservice_p.h
@@ -69,6 +69,7 @@ public:
Status status() const;
void sendMessage(const QByteArray &);
+ bool waitForMessage();
static int idForObject(QObject *);
static QObject *objectForId(int);
@@ -84,6 +85,7 @@ protected:
private:
friend class QDeclarativeDebugServer;
+ friend class QDeclarativeDebugServerPrivate;
};
QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativedebugtrace.cpp b/src/declarative/debugger/qdeclarativedebugtrace.cpp
index 6f28736..edbbe78 100644
--- a/src/declarative/debugger/qdeclarativedebugtrace.cpp
+++ b/src/declarative/debugger/qdeclarativedebugtrace.cpp
@@ -65,9 +65,14 @@ QByteArray QDeclarativeDebugData::toByteArray() const
QDeclarativeDebugTrace::QDeclarativeDebugTrace()
: QDeclarativeDebugService(QLatin1String("CanvasFrameRate")),
- m_enabled(false), m_deferredSend(true)
+ m_enabled(false), m_deferredSend(true), m_messageReceived(false)
{
m_timer.start();
+ if (status() == Enabled) {
+ // wait for first message indicating whether to trace or not
+ while (!m_messageReceived)
+ waitForMessage();
+ }
}
void QDeclarativeDebugTrace::addEvent(EventType t)
@@ -213,6 +218,8 @@ void QDeclarativeDebugTrace::messageReceived(const QByteArray &message)
stream >> m_enabled;
+ m_messageReceived = true;
+
if (!m_enabled)
sendMessages();
}
diff --git a/src/declarative/debugger/qdeclarativedebugtrace_p.h b/src/declarative/debugger/qdeclarativedebugtrace_p.h
index ae0653e..c74cbe0 100644
--- a/src/declarative/debugger/qdeclarativedebugtrace_p.h
+++ b/src/declarative/debugger/qdeclarativedebugtrace_p.h
@@ -120,6 +120,7 @@ private:
QPerformanceTimer m_timer;
bool m_enabled;
bool m_deferredSend;
+ bool m_messageReceived;
QList<QDeclarativeDebugData> m_data;
};
diff --git a/src/declarative/debugger/qdeclarativeobserverinterface_p.h b/src/declarative/debugger/qdeclarativeobserverinterface_p.h
new file mode 100644
index 0000000..501c132
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativeobserverinterface_p.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEOBSERVERINTERFACE_H
+#define QDECLARATIVEOBSERVERINTERFACE_H
+
+#include <QtDeclarative/private/qdeclarativeglobal_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_DECLARATIVE_EXPORT QDeclarativeObserverInterface
+{
+public:
+ QDeclarativeObserverInterface() {}
+ virtual ~QDeclarativeObserverInterface() {}
+
+ virtual void activate() = 0;
+ virtual void deactivate() = 0;
+};
+
+Q_DECLARE_INTERFACE(QDeclarativeObserverInterface, "com.trolltech.Qt.QDeclarativeObserverInterface/1.0")
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEOBSERVERINTERFACE_H
diff --git a/src/declarative/debugger/qdeclarativeobserverservice.cpp b/src/declarative/debugger/qdeclarativeobserverservice.cpp
new file mode 100644
index 0000000..a623c55
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativeobserverservice.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "private/qdeclarativeobserverservice_p.h"
+#include "private/qdeclarativeobserverinterface_p.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QPluginLoader>
+
+#include <QtDeclarative/QDeclarativeView>
+
+QT_BEGIN_NAMESPACE
+
+Q_GLOBAL_STATIC(QDeclarativeObserverService, serviceInstance)
+
+QDeclarativeObserverService::QDeclarativeObserverService()
+ : QDeclarativeDebugService(QLatin1String("QDeclarativeObserverMode"))
+ , m_observer(0)
+{
+}
+
+QDeclarativeObserverService *QDeclarativeObserverService::instance()
+{
+ return serviceInstance();
+}
+
+void QDeclarativeObserverService::addView(QDeclarativeView *view)
+{
+ m_views.append(view);
+}
+
+void QDeclarativeObserverService::removeView(QDeclarativeView *view)
+{
+ m_views.removeAll(view);
+}
+
+void QDeclarativeObserverService::sendMessage(const QByteArray &message)
+{
+ if (status() != Enabled)
+ return;
+
+ QDeclarativeDebugService::sendMessage(message);
+}
+
+void QDeclarativeObserverService::statusChanged(Status status)
+{
+ if (m_views.isEmpty())
+ return;
+
+ if (status == Enabled) {
+ if (!m_observer)
+ m_observer = loadObserverPlugin();
+
+ if (!m_observer) {
+ qWarning() << "Error while loading observer plugin";
+ return;
+ }
+
+ m_observer->activate();
+ } else {
+ if (m_observer)
+ m_observer->deactivate();
+ }
+}
+
+void QDeclarativeObserverService::messageReceived(const QByteArray &message)
+{
+ emit gotMessage(message);
+}
+
+QDeclarativeObserverInterface *QDeclarativeObserverService::loadObserverPlugin()
+{
+ QStringList pluginCandidates;
+ const QStringList paths = QCoreApplication::libraryPaths();
+ foreach (const QString &libPath, paths) {
+ const QDir dir(libPath + QLatin1String("/qmltooling"));
+ if (dir.exists())
+ foreach (const QString &pluginPath, dir.entryList(QDir::Files))
+ pluginCandidates << dir.absoluteFilePath(pluginPath);
+ }
+
+ foreach (const QString &pluginPath, pluginCandidates) {
+ QPluginLoader loader(pluginPath);
+ if (!loader.load())
+ continue;
+
+ QDeclarativeObserverInterface *observer =
+ qobject_cast<QDeclarativeObserverInterface*>(loader.instance());
+
+ if (observer)
+ return observer;
+ loader.unload();
+ }
+ return 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativeobserverservice_p.h b/src/declarative/debugger/qdeclarativeobserverservice_p.h
new file mode 100644
index 0000000..36f31dc
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativeobserverservice_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEOBSERVERSERVICE_H
+#define QDECLARATIVEOBSERVERSERVICE_H
+
+#include "private/qdeclarativedebugservice_p.h"
+#include <private/qdeclarativeglobal_p.h>
+
+#include <QtCore/QList>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeView;
+class QDeclarativeObserverInterface;
+
+class Q_DECLARATIVE_EXPORT QDeclarativeObserverService : public QDeclarativeDebugService
+{
+ Q_OBJECT
+
+public:
+ QDeclarativeObserverService();
+ static QDeclarativeObserverService *instance();
+
+ void addView(QDeclarativeView *);
+ void removeView(QDeclarativeView *);
+ QList<QDeclarativeView*> views() const { return m_views; }
+
+ void sendMessage(const QByteArray &message);
+
+Q_SIGNALS:
+ void gotMessage(const QByteArray &message);
+
+protected:
+ virtual void statusChanged(Status status);
+ virtual void messageReceived(const QByteArray &);
+
+private:
+ static QDeclarativeObserverInterface *loadObserverPlugin();
+
+ QList<QDeclarativeView*> m_views;
+ QDeclarativeObserverInterface *m_observer;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEOBSERVERSERVICE_H
diff --git a/src/declarative/debugger/qjsdebuggeragent.cpp b/src/declarative/debugger/qjsdebuggeragent.cpp
new file mode 100644
index 0000000..601c8c8
--- /dev/null
+++ b/src/declarative/debugger/qjsdebuggeragent.cpp
@@ -0,0 +1,576 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "private/qjsdebuggeragent_p.h"
+#include "private/qdeclarativedebughelper_p.h"
+
+#include <QtCore/qdatetime.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qset.h>
+#include <QtCore/qurl.h>
+#include <QtScript/qscriptcontextinfo.h>
+#include <QtScript/qscriptengine.h>
+#include <QtScript/qscriptvalueiterator.h>
+
+QT_BEGIN_NAMESPACE
+
+class QJSDebuggerAgentPrivate
+{
+public:
+ QJSDebuggerAgentPrivate(QJSDebuggerAgent *q)
+ : q(q), state(NoState)
+ {}
+
+ void continueExec();
+ void recordKnownObjects(const QList<JSAgentWatchData> &);
+ QList<JSAgentWatchData> getLocals(QScriptContext *);
+ void positionChange(qint64 scriptId, int lineNumber, int columnNumber);
+ QScriptEngine *engine() { return q->engine(); }
+ void stopped();
+
+public:
+ QJSDebuggerAgent *q;
+ JSDebuggerState state;
+ int stepDepth;
+ int stepCount;
+
+ QEventLoop loop;
+ QHash<qint64, QString> filenames;
+ JSAgentBreakpoints breakpoints;
+ // breakpoints by filename (without path)
+ QHash<QString, JSAgentBreakpointData> fileNameToBreakpoints;
+ QStringList watchExpressions;
+ QSet<qint64> knownObjectIds;
+};
+
+namespace {
+
+class SetupExecEnv
+{
+public:
+ SetupExecEnv(QJSDebuggerAgentPrivate *a)
+ : agent(a),
+ previousState(a->state),
+ hadException(a->engine()->hasUncaughtException())
+ {
+ agent->state = StoppedState;
+ }
+
+ ~SetupExecEnv()
+ {
+ if (!hadException && agent->engine()->hasUncaughtException())
+ agent->engine()->clearExceptions();
+ agent->state = previousState;
+ }
+
+private:
+ QJSDebuggerAgentPrivate *agent;
+ JSDebuggerState previousState;
+ bool hadException;
+};
+
+} // anonymous namespace
+
+static JSAgentWatchData fromScriptValue(const QString &expression,
+ const QScriptValue &value)
+{
+ static const QString arrayStr = QCoreApplication::translate
+ ("Debugger::JSAgentWatchData", "[Array of length %1]");
+ static const QString undefinedStr = QCoreApplication::translate
+ ("Debugger::JSAgentWatchData", "<undefined>");
+
+ JSAgentWatchData data;
+ data.exp = expression.toUtf8();
+ data.name = data.exp;
+ data.hasChildren = false;
+ data.value = value.toString().toUtf8();
+ data.objectId = value.objectId();
+ if (value.isArray()) {
+ data.type = "Array";
+ data.value = arrayStr.arg(value.property(QLatin1String("length")).toString()).toUtf8();
+ data.hasChildren = true;
+ } else if (value.isBool()) {
+ data.type = "Bool";
+ // data.value = value.toBool() ? "true" : "false";
+ } else if (value.isDate()) {
+ data.type = "Date";
+ data.value = value.toDateTime().toString().toUtf8();
+ } else if (value.isError()) {
+ data.type = "Error";
+ } else if (value.isFunction()) {
+ data.type = "Function";
+ } else if (value.isUndefined()) {
+ data.type = undefinedStr.toUtf8();
+ } else if (value.isNumber()) {
+ data.type = "Number";
+ } else if (value.isRegExp()) {
+ data.type = "RegExp";
+ } else if (value.isString()) {
+ data.type = "String";
+ } else if (value.isVariant()) {
+ data.type = "Variant";
+ } else if (value.isQObject()) {
+ const QObject *obj = value.toQObject();
+ data.type = "Object";
+ data.value += '[';
+ data.value += obj->metaObject()->className();
+ data.value += ']';
+ data.hasChildren = true;
+ } else if (value.isObject()) {
+ data.type = "Object";
+ data.hasChildren = true;
+ data.value = "[Object]";
+ } else if (value.isNull()) {
+ data.type = "<null>";
+ } else {
+ data.type = "<unknown>";
+ }
+ return data;
+}
+
+static QList<JSAgentWatchData> expandObject(const QScriptValue &object)
+{
+ QList<JSAgentWatchData> result;
+ QScriptValueIterator it(object);
+ while (it.hasNext()) {
+ it.next();
+ if (it.flags() & QScriptValue::SkipInEnumeration)
+ continue;
+ if (/*object.isQObject() &&*/ it.value().isFunction()) {
+ // Cosmetics: skip all functions and slot, there are too many of them,
+ // and it is not useful information in the debugger.
+ continue;
+ }
+ JSAgentWatchData data = fromScriptValue(it.name(), it.value());
+ result.append(data);
+ }
+ if (result.isEmpty()) {
+ JSAgentWatchData data;
+ data.name = "<no initialized data>";
+ data.hasChildren = false;
+ data.value = " ";
+ data.objectId = 0;
+ result.append(data);
+ }
+ return result;
+}
+
+static QString fileName(const QString &fileUrl)
+{
+ int lastDelimiterPos = fileUrl.lastIndexOf(QLatin1Char('/'));
+ return fileUrl.mid(lastDelimiterPos, fileUrl.size() - lastDelimiterPos);
+}
+
+void QJSDebuggerAgentPrivate::recordKnownObjects(const QList<JSAgentWatchData>& list)
+{
+ foreach (const JSAgentWatchData &data, list)
+ knownObjectIds << data.objectId;
+}
+
+QList<JSAgentWatchData> QJSDebuggerAgentPrivate::getLocals(QScriptContext *ctx)
+{
+ QList<JSAgentWatchData> locals;
+ if (ctx) {
+ QScriptValue activationObject = ctx->activationObject();
+ QScriptValue thisObject = ctx->thisObject();
+ locals = expandObject(activationObject);
+ if (thisObject.isObject()
+ && thisObject.objectId() != engine()->globalObject().objectId()
+ && QScriptValueIterator(thisObject).hasNext())
+ locals.prepend(fromScriptValue(QLatin1String("this"), thisObject));
+ recordKnownObjects(locals);
+ knownObjectIds << activationObject.objectId();
+ }
+ return locals;
+}
+
+/*!
+ Constructs a new agent for the given \a engine. The agent will
+ report debugging-related events (e.g. step completion) to the given
+ \a backend.
+*/
+QJSDebuggerAgent::QJSDebuggerAgent(QScriptEngine *engine, QObject *parent)
+ : QObject(parent)
+ , QScriptEngineAgent(engine)
+ , d(new QJSDebuggerAgentPrivate(this))
+{
+ QJSDebuggerAgent::engine()->setAgent(this);
+}
+
+QJSDebuggerAgent::QJSDebuggerAgent(QDeclarativeEngine *engine, QObject *parent)
+ : QObject(parent)
+ , QScriptEngineAgent(QDeclarativeDebugHelper::getScriptEngine(engine))
+ , d(new QJSDebuggerAgentPrivate(this))
+{
+ QJSDebuggerAgent::engine()->setAgent(this);
+}
+
+/*!
+ Destroys this QJSDebuggerAgent.
+*/
+QJSDebuggerAgent::~QJSDebuggerAgent()
+{
+ engine()->setAgent(0);
+ delete d;
+}
+
+void QJSDebuggerAgent::setBreakpoints(const JSAgentBreakpoints &breakpoints)
+{
+ d->breakpoints = breakpoints;
+
+ d->fileNameToBreakpoints.clear();
+ foreach (const JSAgentBreakpointData &bp, breakpoints)
+ d->fileNameToBreakpoints.insertMulti(fileName(QString::fromUtf8(bp.fileUrl)), bp);
+}
+
+void QJSDebuggerAgent::setWatchExpressions(const QStringList &watchExpressions)
+{
+ d->watchExpressions = watchExpressions;
+}
+
+void QJSDebuggerAgent::stepOver()
+{
+ d->stepDepth = 0;
+ d->state = SteppingOverState;
+ d->continueExec();
+}
+
+void QJSDebuggerAgent::stepInto()
+{
+ d->stepDepth = 0;
+ d->state = SteppingIntoState;
+ d->continueExec();
+}
+
+void QJSDebuggerAgent::stepOut()
+{
+ d->stepDepth = 0;
+ d->state = SteppingOutState;
+ d->continueExec();
+}
+
+void QJSDebuggerAgent::continueExecution()
+{
+ d->state = NoState;
+ d->continueExec();
+}
+
+JSAgentWatchData QJSDebuggerAgent::executeExpression(const QString &expr)
+{
+ SetupExecEnv execEnv(d);
+
+ JSAgentWatchData data = fromScriptValue(expr, engine()->evaluate(expr));
+ d->knownObjectIds << data.objectId;
+ return data;
+}
+
+QList<JSAgentWatchData> QJSDebuggerAgent::expandObjectById(quint64 objectId)
+{
+ SetupExecEnv execEnv(d);
+
+ QScriptValue v;
+ if (d->knownObjectIds.contains(objectId))
+ v = engine()->objectById(objectId);
+
+ QList<JSAgentWatchData> result = expandObject(v);
+ d->recordKnownObjects(result);
+ return result;
+}
+
+QList<JSAgentWatchData> QJSDebuggerAgent::locals()
+{
+ SetupExecEnv execEnv(d);
+ return d->getLocals(engine()->currentContext());
+}
+
+QList<JSAgentWatchData> QJSDebuggerAgent::localsAtFrame(int frameId)
+{
+ SetupExecEnv execEnv(d);
+
+ int deep = 0;
+ QScriptContext *ctx = engine()->currentContext();
+ while (ctx && deep < frameId) {
+ ctx = ctx->parentContext();
+ deep++;
+ }
+
+ return d->getLocals(ctx);
+}
+
+QList<JSAgentStackData> QJSDebuggerAgent::backtrace()
+{
+ SetupExecEnv execEnv(d);
+
+ QList<JSAgentStackData> backtrace;
+
+ for (QScriptContext *ctx = engine()->currentContext(); ctx; ctx = ctx->parentContext()) {
+ QScriptContextInfo info(ctx);
+
+ JSAgentStackData frame;
+ frame.functionName = info.functionName().toUtf8();
+ if (frame.functionName.isEmpty()) {
+ if (ctx->parentContext()) {
+ switch (info.functionType()) {
+ case QScriptContextInfo::ScriptFunction:
+ frame.functionName = "<anonymous>";
+ break;
+ case QScriptContextInfo::NativeFunction:
+ frame.functionName = "<native>";
+ break;
+ case QScriptContextInfo::QtFunction:
+ case QScriptContextInfo::QtPropertyFunction:
+ frame.functionName = "<native slot>";
+ break;
+ }
+ } else {
+ frame.functionName = "<global>";
+ }
+ }
+ frame.lineNumber = info.lineNumber();
+ // if the line number is unknown, fallback to the function line number
+ if (frame.lineNumber == -1)
+ frame.lineNumber = info.functionStartLineNumber();
+
+ frame.fileUrl = info.fileName().toUtf8();
+ backtrace.append(frame);
+ }
+
+ return backtrace;
+}
+
+QList<JSAgentWatchData> QJSDebuggerAgent::watches()
+{
+ SetupExecEnv execEnv(d);
+
+ QList<JSAgentWatchData> watches;
+ foreach (const QString &expr, d->watchExpressions)
+ watches << fromScriptValue(expr, engine()->evaluate(expr));
+ d->recordKnownObjects(watches);
+ return watches;
+}
+
+void QJSDebuggerAgent::setProperty(qint64 objectId,
+ const QString &property,
+ const QString &value)
+{
+ SetupExecEnv execEnv(d);
+
+ if (d->knownObjectIds.contains(objectId)) {
+ QScriptValue object = engine()->objectById(objectId);
+ if (object.isObject()) {
+ QScriptValue result = engine()->evaluate(value);
+ object.setProperty(property, result);
+ }
+ }
+}
+
+/*!
+ \reimp
+*/
+void QJSDebuggerAgent::scriptLoad(qint64 id, const QString &program,
+ const QString &fileName, int)
+{
+ Q_UNUSED(program);
+ d->filenames.insert(id, fileName);
+}
+
+/*!
+ \reimp
+*/
+void QJSDebuggerAgent::scriptUnload(qint64 id)
+{
+ d->filenames.remove(id);
+}
+
+/*!
+ \reimp
+*/
+void QJSDebuggerAgent::contextPush()
+{
+}
+
+/*!
+ \reimp
+*/
+void QJSDebuggerAgent::contextPop()
+{
+}
+
+/*!
+ \reimp
+*/
+void QJSDebuggerAgent::functionEntry(qint64 scriptId)
+{
+ Q_UNUSED(scriptId);
+ d->stepDepth++;
+}
+
+/*!
+ \reimp
+*/
+void QJSDebuggerAgent::functionExit(qint64 scriptId, const QScriptValue &returnValue)
+{
+ Q_UNUSED(scriptId);
+ Q_UNUSED(returnValue);
+ d->stepDepth--;
+}
+
+/*!
+ \reimp
+*/
+void QJSDebuggerAgent::positionChange(qint64 scriptId, int lineNumber, int columnNumber)
+{
+ d->positionChange(scriptId, lineNumber, columnNumber);
+}
+
+void QJSDebuggerAgentPrivate::positionChange(qint64 scriptId, int lineNumber, int columnNumber)
+{
+ Q_UNUSED(columnNumber);
+
+ if (state == StoppedState)
+ return; //no re-entrency
+
+ // check breakpoints
+ if (!breakpoints.isEmpty()) {
+ QHash<qint64, QString>::const_iterator it = filenames.constFind(scriptId);
+ QScriptContext *ctx = engine()->currentContext();
+ QScriptContextInfo info(ctx);
+ if (it == filenames.constEnd()) {
+ // It is possible that the scripts are loaded before the agent is attached
+ QString filename = info.fileName();
+
+ JSAgentStackData frame;
+ frame.functionName = info.functionName().toUtf8();
+
+ QPair<QString, qint32> key = qMakePair(filename, lineNumber);
+ it = filenames.insert(scriptId, filename);
+ }
+
+ const QString filePath = it.value();
+ JSAgentBreakpoints bps = fileNameToBreakpoints.values(fileName(filePath)).toSet();
+
+ foreach (const JSAgentBreakpointData &bp, bps) {
+ if (bp.lineNumber == lineNumber) {
+ stopped();
+ return;
+ }
+ }
+ }
+
+ switch (state) {
+ case NoState:
+ case StoppedState:
+ // Do nothing
+ break;
+ case SteppingOutState:
+ if (stepDepth >= 0)
+ break;
+ //fallthough
+ case SteppingOverState:
+ if (stepDepth > 0)
+ break;
+ //fallthough
+ case SteppingIntoState:
+ stopped();
+ break;
+ }
+
+}
+
+/*!
+ \reimp
+*/
+void QJSDebuggerAgent::exceptionThrow(qint64 scriptId,
+ const QScriptValue &exception,
+ bool hasHandler)
+{
+ Q_UNUSED(scriptId);
+ Q_UNUSED(exception);
+ Q_UNUSED(hasHandler);
+// qDebug() << Q_FUNC_INFO << exception.toString() << hasHandler;
+#if 0 //sometimes, we get exceptions that we should just ignore.
+ if (!hasHandler && state != StoppedState)
+ stopped(true, exception);
+#endif
+}
+
+/*!
+ \reimp
+*/
+void QJSDebuggerAgent::exceptionCatch(qint64 scriptId, const QScriptValue &exception)
+{
+ Q_UNUSED(scriptId);
+ Q_UNUSED(exception);
+}
+
+bool QJSDebuggerAgent::supportsExtension(Extension extension) const
+{
+ return extension == QScriptEngineAgent::DebuggerInvocationRequest;
+}
+
+QVariant QJSDebuggerAgent::extension(Extension extension, const QVariant &argument)
+{
+ if (extension == QScriptEngineAgent::DebuggerInvocationRequest) {
+ d->stopped();
+ return QVariant();
+ }
+ return QScriptEngineAgent::extension(extension, argument);
+}
+
+void QJSDebuggerAgentPrivate::stopped()
+{
+ bool becauseOfException = false;
+ const QScriptValue &exception = QScriptValue();
+
+ knownObjectIds.clear();
+ state = StoppedState;
+
+ emit q->stopped(becauseOfException, exception.toString());
+
+ loop.exec(QEventLoop::ExcludeUserInputEvents);
+}
+
+void QJSDebuggerAgentPrivate::continueExec()
+{
+ loop.quit();
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qjsdebuggeragent_p.h b/src/declarative/debugger/qjsdebuggeragent_p.h
new file mode 100644
index 0000000..ce5a044
--- /dev/null
+++ b/src/declarative/debugger/qjsdebuggeragent_p.h
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QJSDEBUGGERAGENT_P_H
+#define QJSDEBUGGERAGENT_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 <QtScript/qscriptengineagent.h>
+#include <QtCore/qset.h>
+
+QT_BEGIN_NAMESPACE
+class QScriptValue;
+class QDeclarativeEngine;
+QT_END_NAMESPACE
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QJSDebuggerAgentPrivate;
+
+enum JSDebuggerState
+{
+ NoState,
+ SteppingIntoState,
+ SteppingOverState,
+ SteppingOutState,
+ StoppedState
+};
+
+struct JSAgentWatchData
+{
+ QByteArray exp;
+ QByteArray name;
+ QByteArray value;
+ QByteArray type;
+ bool hasChildren;
+ quint64 objectId;
+};
+
+inline QDataStream &operator<<(QDataStream &s, const JSAgentWatchData &data)
+{
+ return s << data.exp << data.name << data.value
+ << data.type << data.hasChildren << data.objectId;
+}
+
+struct JSAgentStackData
+{
+ QByteArray functionName;
+ QByteArray fileUrl;
+ qint32 lineNumber;
+};
+
+inline QDataStream &operator<<(QDataStream &s, const JSAgentStackData &data)
+{
+ return s << data.functionName << data.fileUrl << data.lineNumber;
+}
+
+struct JSAgentBreakpointData
+{
+ QByteArray functionName;
+ QByteArray fileUrl;
+ qint32 lineNumber;
+};
+
+typedef QSet<JSAgentBreakpointData> JSAgentBreakpoints;
+
+inline QDataStream &operator<<(QDataStream &s, const JSAgentBreakpointData &data)
+{
+ return s << data.functionName << data.fileUrl << data.lineNumber;
+}
+
+inline QDataStream &operator>>(QDataStream &s, JSAgentBreakpointData &data)
+{
+ return s >> data.functionName >> data.fileUrl >> data.lineNumber;
+}
+
+inline bool operator==(const JSAgentBreakpointData &b1, const JSAgentBreakpointData &b2)
+{
+ return b1.lineNumber == b2.lineNumber && b1.fileUrl == b2.fileUrl;
+}
+
+inline uint qHash(const JSAgentBreakpointData &b)
+{
+ return b.lineNumber ^ qHash(b.fileUrl);
+}
+
+
+class QJSDebuggerAgent : public QObject, public QScriptEngineAgent
+{
+ Q_OBJECT
+
+public:
+ QJSDebuggerAgent(QScriptEngine *engine, QObject *parent = 0);
+ QJSDebuggerAgent(QDeclarativeEngine *engine, QObject *parent = 0);
+ ~QJSDebuggerAgent();
+
+ void setBreakpoints(const JSAgentBreakpoints &);
+ void setWatchExpressions(const QStringList &);
+
+ void stepOver();
+ void stepInto();
+ void stepOut();
+ void continueExecution();
+
+ JSAgentWatchData executeExpression(const QString &expr);
+ QList<JSAgentWatchData> expandObjectById(quint64 objectId);
+ QList<JSAgentWatchData> locals();
+ QList<JSAgentWatchData> localsAtFrame(int frameId);
+ QList<JSAgentStackData> backtrace();
+ QList<JSAgentWatchData> watches();
+ void setProperty(qint64 objectId,
+ const QString &property,
+ const QString &value);
+
+ // reimplemented
+ void scriptLoad(qint64 id, const QString &program,
+ const QString &fileName, int baseLineNumber);
+ void scriptUnload(qint64 id);
+
+ void contextPush();
+ void contextPop();
+
+ void functionEntry(qint64 scriptId);
+ void functionExit(qint64 scriptId,
+ const QScriptValue &returnValue);
+
+ void positionChange(qint64 scriptId,
+ int lineNumber, int columnNumber);
+
+ void exceptionThrow(qint64 scriptId,
+ const QScriptValue &exception,
+ bool hasHandler);
+ void exceptionCatch(qint64 scriptId,
+ const QScriptValue &exception);
+
+ bool supportsExtension(Extension extension) const;
+ QVariant extension(Extension extension,
+ const QVariant &argument = QVariant());
+
+Q_SIGNALS:
+ void stopped(bool becauseOfException,
+ const QString &exception);
+
+private:
+ friend class QJSDebuggerAgentPrivate;
+ QJSDebuggerAgentPrivate *d;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QJSDEBUGGERAGENT_P_H
diff --git a/src/declarative/debugger/qjsdebugservice.cpp b/src/declarative/debugger/qjsdebugservice.cpp
new file mode 100644
index 0000000..f8cd095
--- /dev/null
+++ b/src/declarative/debugger/qjsdebugservice.cpp
@@ -0,0 +1,198 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "private/qjsdebugservice_p.h"
+#include "private/qjsdebuggeragent_p.h"
+
+#include <QtCore/qdatastream.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qstringlist.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+
+Q_GLOBAL_STATIC(QJSDebugService, serviceInstance)
+
+QJSDebugService::QJSDebugService(QObject *parent)
+ : QDeclarativeDebugService(QLatin1String("JSDebugger"), parent)
+ , m_agent(0)
+{
+}
+
+QJSDebugService::~QJSDebugService()
+{
+ delete m_agent;
+}
+
+QJSDebugService *QJSDebugService::instance()
+{
+ return serviceInstance();
+}
+
+void QJSDebugService::addEngine(QDeclarativeEngine *engine)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(!m_engines.contains(engine));
+
+ m_engines.append(engine);
+}
+
+void QJSDebugService::removeEngine(QDeclarativeEngine *engine)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(m_engines.contains(engine));
+
+ m_engines.removeAll(engine);
+}
+
+void QJSDebugService::statusChanged(Status status)
+{
+ if (status == Enabled && !m_engines.isEmpty() && !m_agent) {
+ // Multiple engines are currently unsupported
+ QDeclarativeEngine *engine = m_engines.first();
+ m_agent = new QJSDebuggerAgent(engine, engine);
+
+ connect(m_agent, SIGNAL(stopped(bool,QString)),
+ this, SLOT(executionStopped(bool,QString)));
+
+ } else if (status != Enabled && m_agent) {
+ delete m_agent;
+ m_agent = 0;
+ }
+}
+
+void QJSDebugService::messageReceived(const QByteArray &message)
+{
+ if (!m_agent) {
+ qWarning() << "QJSDebugService::messageReceived: No QJSDebuggerAgent available";
+ return;
+ }
+
+ QDataStream ds(message);
+ QByteArray command;
+ ds >> command;
+ if (command == "BREAKPOINTS") {
+ JSAgentBreakpoints breakpoints;
+ ds >> breakpoints;
+ m_agent->setBreakpoints(breakpoints);
+
+ //qDebug() << "BREAKPOINTS";
+ //foreach (const JSAgentBreakpointData &bp, breakpoints)
+ // qDebug() << "BREAKPOINT: " << bp.fileUrl << bp.lineNumber;
+ } else if (command == "WATCH_EXPRESSIONS") {
+ QStringList watchExpressions;
+ ds >> watchExpressions;
+ m_agent->setWatchExpressions(watchExpressions);
+ } else if (command == "STEPOVER") {
+ m_agent->stepOver();
+ } else if (command == "STEPINTO" || command == "INTERRUPT") {
+ m_agent->stepInto();
+ } else if (command == "STEPOUT") {
+ m_agent->stepOut();
+ } else if (command == "CONTINUE") {
+ m_agent->continueExecution();
+ } else if (command == "EXEC") {
+ QByteArray id;
+ QString expr;
+ ds >> id >> expr;
+
+ JSAgentWatchData data = m_agent->executeExpression(expr);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("RESULT") << id << data;
+ sendMessage(reply);
+ } else if (command == "EXPAND") {
+ QByteArray requestId;
+ quint64 objectId;
+ ds >> requestId >> objectId;
+
+ QList<JSAgentWatchData> result = m_agent->expandObjectById(objectId);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("EXPANDED") << requestId << result;
+ sendMessage(reply);
+ } else if (command == "ACTIVATE_FRAME") {
+ int frameId;
+ ds >> frameId;
+
+ QList<JSAgentWatchData> locals = m_agent->localsAtFrame(frameId);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("LOCALS") << frameId << locals;
+ sendMessage(reply);
+ } else if (command == "SET_PROPERTY") {
+ QByteArray id;
+ qint64 objectId;
+ QString property;
+ QString value;
+ ds >> id >> objectId >> property >> value;
+
+ m_agent->setProperty(objectId, property, value);
+
+ //TODO: feedback
+ } else if (command == "PING") {
+ int ping;
+ ds >> ping;
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("PONG") << ping;
+ sendMessage(reply);
+ } else {
+ qDebug() << Q_FUNC_INFO << "Unknown command" << command;
+ }
+
+ QDeclarativeDebugService::messageReceived(message);
+}
+
+void QJSDebugService::executionStopped(bool becauseOfException,
+ const QString &exception)
+{
+ const QList<JSAgentStackData> backtrace = m_agent->backtrace();
+ const QList<JSAgentWatchData> watches = m_agent->watches();
+ const QList<JSAgentWatchData> locals = m_agent->locals();
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("STOPPED") << backtrace << watches << locals
+ << becauseOfException << exception;
+ sendMessage(reply);
+}
diff --git a/src/declarative/debugger/qjsdebugservice_p.h b/src/declarative/debugger/qjsdebugservice_p.h
new file mode 100644
index 0000000..6839ca8
--- /dev/null
+++ b/src/declarative/debugger/qjsdebugservice_p.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QJSDEBUGSERVICE_P_H
+#define QJSDEBUGSERVICE_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 <QtCore/QPointer>
+
+#include "private/qdeclarativedebugservice_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeEngine;
+class QJSDebuggerAgent;
+
+class QJSDebugService : public QDeclarativeDebugService
+{
+ Q_OBJECT
+
+public:
+ QJSDebugService(QObject *parent = 0);
+ ~QJSDebugService();
+
+ static QJSDebugService *instance();
+
+ void addEngine(QDeclarativeEngine *);
+ void removeEngine(QDeclarativeEngine *);
+
+protected:
+ void statusChanged(Status status);
+ void messageReceived(const QByteArray &);
+
+private Q_SLOTS:
+ void executionStopped(bool becauseOfException,
+ const QString &exception);
+
+private:
+ QList<QDeclarativeEngine *> m_engines;
+ QPointer<QJSDebuggerAgent> m_agent;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QJSDEBUGSERVICE_P_H
diff --git a/src/declarative/debugger/qpacketprotocol.cpp b/src/declarative/debugger/qpacketprotocol.cpp
index 15a14cf..c1034a7 100644
--- a/src/declarative/debugger/qpacketprotocol.cpp
+++ b/src/declarative/debugger/qpacketprotocol.cpp
@@ -42,6 +42,7 @@
#include "private/qpacketprotocol_p.h"
#include <QBuffer>
+#include <QElapsedTimer>
QT_BEGIN_NAMESPACE
@@ -114,7 +115,7 @@ Q_OBJECT
public:
QPacketProtocolPrivate(QPacketProtocol * parent, QIODevice * _dev)
: QObject(parent), inProgressSize(-1), maxPacketSize(MAX_PACKET_SIZE),
- dev(_dev)
+ waitingForPacket(false), dev(_dev)
{
Q_ASSERT(4 == sizeof(qint32));
@@ -125,7 +126,7 @@ public:
QObject::connect(this, SIGNAL(invalidPacket()),
parent, SIGNAL(invalidPacket()));
QObject::connect(dev, SIGNAL(readyRead()),
- this, SLOT(readyToRead()), Qt::QueuedConnection);
+ this, SLOT(readyToRead()));
QObject::connect(dev, SIGNAL(aboutToClose()),
this, SLOT(aboutToClose()));
QObject::connect(dev, SIGNAL(bytesWritten(qint64)),
@@ -200,6 +201,7 @@ public Q_SLOTS:
inProgress.clear();
emit readyRead();
+ waitingForPacket = false;
// Need to get trailing data
readyToRead();
@@ -213,6 +215,7 @@ public:
QByteArray inProgress;
qint32 inProgressSize;
qint32 maxPacketSize;
+ bool waitingForPacket;
QIODevice * dev;
};
@@ -324,6 +327,48 @@ QPacket QPacketProtocol::read()
return rv;
}
+/*
+ Returns the difference between msecs and elapsed. If msecs is -1,
+ however, -1 is returned.
+*/
+static int qt_timeout_value(int msecs, int elapsed)
+{
+ if (msecs == -1)
+ return -1;
+
+ int timeout = msecs - elapsed;
+ return timeout < 0 ? 0 : timeout;
+}
+
+/*!
+ This function locks until a new packet is available for reading and the
+ \l{QIODevice::}{readyRead()} signal has been emitted. The function
+ will timeout after \a msecs milliseconds; the default timeout is
+ 30000 milliseconds.
+
+ The function returns true if the readyRead() signal is emitted and
+ there is new data available for reading; otherwise it returns false
+ (if an error occurred or the operation timed out).
+ */
+
+bool QPacketProtocol::waitForReadyRead(int msecs)
+{
+ if (!d->packets.isEmpty())
+ return true;
+
+ QElapsedTimer stopWatch;
+ stopWatch.start();
+
+ d->waitingForPacket = true;
+ do {
+ if (!d->dev->waitForReadyRead(msecs))
+ return false;
+ if (!d->waitingForPacket)
+ return true;
+ msecs = qt_timeout_value(msecs, stopWatch.elapsed());
+ } while (true);
+}
+
/*!
Return the QIODevice passed to the QPacketProtocol constructor.
*/
diff --git a/src/declarative/debugger/qpacketprotocol_p.h b/src/declarative/debugger/qpacketprotocol_p.h
index accb8ef..22bc3c2 100644
--- a/src/declarative/debugger/qpacketprotocol_p.h
+++ b/src/declarative/debugger/qpacketprotocol_p.h
@@ -75,6 +75,8 @@ public:
qint64 packetsAvailable() const;
QPacket read();
+ bool waitForReadyRead(int msecs = 3000);
+
void clear();
QIODevice * device();
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index f30831d..a3395a4 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -1499,6 +1499,7 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate)
d->ownModel = true;
}
if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) {
+ int oldCount = dataModel->count();
dataModel->setDelegate(delegate);
if (isComponentComplete()) {
for (int i = 0; i < d->visibleItems.count(); ++i)
@@ -1516,6 +1517,8 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate)
}
d->moveReason = QDeclarativeGridViewPrivate::Other;
}
+ if (oldCount != dataModel->count())
+ emit countChanged();
emit delegateChanged();
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 3190d7e..ef6b032 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -733,6 +733,7 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer)
if (doBuffer && (bufferMode & BufferBefore))
fillFrom = bufferFrom;
+ bool haveValidItems = false;
int modelIndex = visibleIndex;
qreal itemEnd = visiblePos-1;
if (!visibleItems.isEmpty()) {
@@ -741,11 +742,13 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer)
int i = visibleItems.count() - 1;
while (i > 0 && visibleItems.at(i)->index == -1)
--i;
- if (visibleItems.at(i)->index != -1)
+ if (visibleItems.at(i)->index != -1) {
+ haveValidItems = true;
modelIndex = visibleItems.at(i)->index + 1;
+ }
}
- if (visibleItems.count() && (fillFrom > itemEnd+averageSize+spacing
+ if (haveValidItems && (fillFrom > itemEnd+averageSize+spacing
|| fillTo < visiblePos - averageSize - spacing)) {
// We've jumped more than a page. Estimate which items are now
// visible and fill from there.
@@ -1813,6 +1816,7 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate)
d->ownModel = true;
}
if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) {
+ int oldCount = dataModel->count();
dataModel->setDelegate(delegate);
if (isComponentComplete()) {
for (int i = 0; i < d->visibleItems.count(); ++i)
@@ -1831,6 +1835,8 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate)
}
d->updateViewport();
}
+ if (oldCount != dataModel->count())
+ emit countChanged();
}
emit delegateChanged();
}
@@ -3403,9 +3409,9 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count)
}
}
- if (removedVisible && !haveVisibleIndex) {
+ if (!haveVisibleIndex) {
d->timeline.clear();
- if (d->itemCount == 0) {
+ if (removedVisible && d->itemCount == 0) {
d->visibleIndex = 0;
d->visiblePos = d->header ? d->header->size() : 0;
d->setPosition(0);
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index d4e7f7b..6633256 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -660,6 +660,32 @@ void QDeclarativeMouseArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
setHovered(false);
}
+#ifndef QT_NO_CONTEXTMENU
+void QDeclarativeMouseArea::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
+{
+ bool acceptsContextMenuButton;
+#if defined(Q_OS_SYMBIAN)
+ // In Symbian a Long Tap on the screen will trigger. See QSymbianControl::HandleLongTapEventL().
+ acceptsContextMenuButton = acceptedButtons() & Qt::LeftButton;
+#elif defined(Q_WS_WINCE)
+ // ### WinCE can trigger context menu event with a gesture in the left button or a
+ // click with the right button. Since we have no way here to differentiate them when
+ // event happens, accepting either of the them will block the event.
+ acceptsContextMenuButton = acceptedButtons() & (Qt::LeftButton | Qt::RightButton);
+#else
+ acceptsContextMenuButton = acceptedButtons() & Qt::RightButton;
+#endif
+
+ if (isEnabled() && event->reason() == QGraphicsSceneContextMenuEvent::Mouse
+ && acceptsContextMenuButton) {
+ // Do not let the context menu event propagate to items behind.
+ return;
+ }
+
+ QDeclarativeItem::contextMenuEvent(event);
+}
+#endif // QT_NO_CONTEXTMENU
+
bool QDeclarativeMouseArea::sceneEvent(QEvent *event)
{
bool rv = QDeclarativeItem::sceneEvent(event);
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p.h
index 351d4de..0fe8c6a 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea_p.h
+++ b/src/declarative/graphicsitems/qdeclarativemousearea_p.h
@@ -190,6 +190,9 @@ protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
+#ifndef QT_NO_CONTEXTMENU
+ void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
+#endif // QT_NO_CONTEXTMENU
bool sceneEvent(QEvent *);
bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
bool sceneEventFilter(QGraphicsItem *i, QEvent *e);
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index aed849b..be2bd60 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -1021,9 +1021,12 @@ void QDeclarativePathView::setDelegate(QDeclarativeComponent *delegate)
d->ownModel = true;
}
if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) {
+ int oldCount = dataModel->count();
dataModel->setDelegate(delegate);
d->modelCount = dataModel->count();
d->regenerate();
+ if (oldCount != dataModel->count())
+ emit countChanged();
emit delegateChanged();
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index af2c8f3..ca78593 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -273,7 +273,6 @@ void QDeclarativeTextEdit::setText(const QString &text)
\o TextEdit.AutoText
\o TextEdit.PlainText
\o TextEdit.RichText
- \o TextEdit.StyledText
\endlist
The default is TextEdit.AutoText. If the text format is TextEdit.AutoText the text edit
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 97ce059..4c839a1 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -1398,7 +1398,12 @@ void QDeclarativeVisualDataModel::_q_layoutChanged()
void QDeclarativeVisualDataModel::_q_modelReset()
{
+ Q_D(QDeclarativeVisualDataModel);
+ d->m_root = QModelIndex();
emit modelReset();
+ emit rootIndexChanged();
+ if (d->m_abstractItemModel && d->m_abstractItemModel->canFetchMore(d->m_root))
+ d->m_abstractItemModel->fetchMore(d->m_root);
}
void QDeclarativeVisualDataModel::_q_createdPackage(int index, QDeclarativePackage *package)
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
index 5da7901..28a6be4 100644
--- a/src/declarative/qml/qdeclarative.h
+++ b/src/declarative/qml/qdeclarative.h
@@ -405,6 +405,17 @@ QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true)
return qmlAttachedPropertiesObject(&idx, obj, &T::staticMetaObject, create);
}
+// Enable debugging before any QDeclarativeEngine is created
+struct Q_DECLARATIVE_EXPORT QDeclarativeDebuggingEnabler
+{
+ QDeclarativeDebuggingEnabler();
+};
+
+// Execute code in constructor before first QDeclarativeEngine is instantiated
+#if defined(QT_DECLARATIVE_DEBUG)
+static QDeclarativeDebuggingEnabler qmlEnableDebuggingHelper;
+#endif
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QObject)
diff --git a/src/declarative/qml/qdeclarativedirparser.cpp b/src/declarative/qml/qdeclarativedirparser.cpp
index b5ad33d..362b99c 100644
--- a/src/declarative/qml/qdeclarativedirparser.cpp
+++ b/src/declarative/qml/qdeclarativedirparser.cpp
@@ -160,6 +160,16 @@ bool QDeclarativeDirParser::parse()
Component entry(sections[1], sections[2], -1, -1);
entry.internal = true;
_components.append(entry);
+ } else if (sections[0] == QLatin1String("typeinfo")) {
+ if (sectionCount != 2) {
+ reportError(lineNumber, -1,
+ QString::fromUtf8("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1));
+ continue;
+ }
+#ifdef QT_CREATOR
+ TypeInfo typeInfo(sections[1]);
+ _typeInfos.append(typeInfo);
+#endif
} else if (sectionCount == 2) {
// No version specified (should only be used for relative qmldir files)
@@ -229,4 +239,11 @@ QList<QDeclarativeDirParser::Component> QDeclarativeDirParser::components() cons
return _components;
}
+#ifdef QT_CREATOR
+QList<TypeInfo> QDeclarativeDirParser::typeInfos() const
+{
+ return _typeInfos;
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativedirparser_p.h b/src/declarative/qml/qdeclarativedirparser_p.h
index 95f14bc..d09b90e 100644
--- a/src/declarative/qml/qdeclarativedirparser_p.h
+++ b/src/declarative/qml/qdeclarativedirparser_p.h
@@ -109,6 +109,19 @@ public:
QList<Component> components() const;
QList<Plugin> plugins() const;
+#ifdef QT_CREATOR
+ struct TypeInfo
+ {
+ TypeInfo() {}
+ TypeInfo(const QString &fileName)
+ : fileName(fileName) {}
+
+ QString fileName;
+ };
+
+ QList<TypeInfo> typeInfos() const;
+#endif
+
private:
void reportError(int line, int column, const QString &message);
@@ -118,6 +131,9 @@ private:
QString _source;
QList<Component> _components;
QList<Plugin> _plugins;
+#ifdef QT_CREATOR
+ QList<TypeInfo> _typeInfos;
+#endif
unsigned _isParsed: 1;
};
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 9fde18c..aa4bcd4 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -71,6 +71,7 @@
#include "private/qdeclarativenotifier_p.h"
#include "private/qdeclarativedebugtrace_p.h"
#include "private/qdeclarativeapplication_p.h"
+#include "private/qjsdebugservice_p.h"
#include <QtCore/qmetaobject.h>
#include <QScriptClass>
@@ -123,7 +124,7 @@ QT_BEGIN_NAMESPACE
\brief The QtObject element is the most basic element in QML.
The QtObject element is a non-visual element which contains only the
- objectName property.
+ objectName property.
It can be useful to create a QtObject if you need an extremely
lightweight element to enclose a set of custom properties:
@@ -138,7 +139,7 @@ QT_BEGIN_NAMESPACE
This property holds the QObject::objectName for this specific object instance.
This allows a C++ application to locate an item within a QML component
- using the QObject::findChild() method. For example, the following C++
+ using the QObject::findChild() method. For example, the following C++
application locates the child \l Rectangle item and dynamically changes its
\c color value:
@@ -152,7 +153,7 @@ QT_BEGIN_NAMESPACE
Rectangle {
anchors.fill: parent
- color: "red"
+ color: "red"
objectName: "myRect"
}
}
@@ -166,7 +167,7 @@ QT_BEGIN_NAMESPACE
view.show();
QDeclarativeItem *item = view.rootObject()->findChild<QDeclarativeItem*>("myRect");
- if (item)
+ if (item)
item->setProperty("color", QColor(Qt::yellow));
\endcode
*/
@@ -202,7 +203,7 @@ void QDeclarativeEnginePrivate::defineModule()
\keyword QmlGlobalQtObject
-\brief The \c Qt object provides useful enums and functions from Qt, for use in all QML files.
+\brief The \c Qt object provides useful enums and functions from Qt, for use in all QML files.
The \c Qt object is a global object with utility functions, properties and enums.
@@ -583,6 +584,7 @@ void QDeclarativeEnginePrivate::init()
QDeclarativeEngineDebugServer::isDebuggingEnabled()) {
isDebugging = true;
QDeclarativeEngineDebugServer::instance()->addEngine(q);
+ QJSDebugService::instance()->addEngine(q);
}
}
@@ -645,8 +647,10 @@ QDeclarativeEngine::QDeclarativeEngine(QObject *parent)
QDeclarativeEngine::~QDeclarativeEngine()
{
Q_D(QDeclarativeEngine);
- if (d->isDebugging)
+ if (d->isDebugging) {
QDeclarativeEngineDebugServer::instance()->remEngine(this);
+ QJSDebugService::instance()->removeEngine(this);
+ }
}
/*! \fn void QDeclarativeEngine::quit()
@@ -757,7 +761,7 @@ QNetworkAccessManager *QDeclarativeEngine::networkAccessManager() const
/*!
Sets the \a provider to use for images requested via the \e
- image: url scheme, with host \a providerId. The QDeclarativeEngine
+ image: url scheme, with host \a providerId. The QDeclarativeEngine
takes ownership of \a provider.
Image providers enable support for pixmap and threaded image
@@ -1066,7 +1070,7 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre
rv = pf(const_cast<QObject *>(object));
- if (rv)
+ if (rv)
data->attachedProperties()->insert(id, rv);
return rv;
@@ -1084,6 +1088,17 @@ QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object,
return qmlAttachedPropertiesObjectById(*idCache, object, create);
}
+QDeclarativeDebuggingEnabler::QDeclarativeDebuggingEnabler()
+{
+#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL
+ if (!QDeclarativeEnginePrivate::qml_debugging_enabled) {
+ qWarning("Qml debugging is enabled. Only use this in a safe environment!");
+ }
+ QDeclarativeEnginePrivate::qml_debugging_enabled = true;
+#endif
+}
+
+
class QDeclarativeDataExtended {
public:
QDeclarativeDataExtended();
@@ -1258,7 +1273,7 @@ Returns a \l Component object created using the QML file at the specified \a url
or \c null if an empty string was given.
The returned component's \l Component::status property indicates whether the
-component was successfully created. If the status is \c Component.Error,
+component was successfully created. If the status is \c Component.Error,
see \l Component::errorString() for an error description.
Call \l {Component::createObject()}{Component.createObject()} on the returned
@@ -1311,6 +1326,8 @@ Example (where \c parentItem is the id of an existing QML item):
In the case of an error, a QtScript Error object is thrown. This object has an additional property,
\c qmlErrors, which is an array of the errors encountered.
Each object in this array has the members \c lineNumber, \c columnNumber, \c fileName and \c message.
+For example, if the above snippet had misspelled color as 'colro' then the array would contain an object like the following:
+{ "lineNumber" : 1, "columnNumber" : 32, "fileName" : "dynamicSnippet1", "message" : "Cannot assign to non-existent property \"colro\""}.
Note that this function returns immediately, and therefore may not work if
the \a qml string loads new components (that is, external QML files that have not yet been loaded).
@@ -1618,7 +1635,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr
return engine->newVariant(QVariant::fromValue(date.toString(format)));
} else if (formatArg.isNumber()) {
enumFormat = Qt::DateFormat(formatArg.toUInt32());
- } else {
+ } else {
return ctxt->throwError(QLatin1String("Qt.formatDateTime(): Invalid datetime format"));
}
}
@@ -1683,7 +1700,7 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine
}
/*!
-\qmlmethod rect Qt::rect(int x, int y, int width, int height)
+\qmlmethod rect Qt::rect(int x, int y, int width, int height)
Returns a \c rect with the top-left corner at \c x, \c y and the specified \c width and \c height.
@@ -1855,7 +1872,7 @@ Binary to ASCII - this function returns a base64 encoding of \c data.
*/
QScriptValue QDeclarativeEnginePrivate::btoa(QScriptContext *ctxt, QScriptEngine *)
{
- if (ctxt->argumentCount() != 1)
+ if (ctxt->argumentCount() != 1)
return ctxt->throwError(QLatin1String("Qt.btoa(): Invalid arguments"));
QByteArray data = ctxt->argument(0).toString().toUtf8();
@@ -1870,7 +1887,7 @@ ASCII to binary - this function returns a base64 decoding of \c data.
QScriptValue QDeclarativeEnginePrivate::atob(QScriptContext *ctxt, QScriptEngine *)
{
- if (ctxt->argumentCount() != 1)
+ if (ctxt->argumentCount() != 1)
return ctxt->throwError(QLatin1String("Qt.atob(): Invalid arguments"));
QByteArray data = ctxt->argument(0).toString().toUtf8();
@@ -2289,7 +2306,7 @@ QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(const QMetaObj
}
}
-QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(QDeclarativeType *type, int minorVersion,
+QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(QDeclarativeType *type, int minorVersion,
QDeclarativeError &error)
{
QList<QDeclarativeType *> types;
@@ -2298,7 +2315,7 @@ QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(QDeclarativeTy
const QMetaObject *metaObject = type->metaObject();
while (metaObject) {
- QDeclarativeType *t = QDeclarativeMetaType::qmlType(metaObject, type->module(),
+ QDeclarativeType *t = QDeclarativeMetaType::qmlType(metaObject, type->module(),
type->majorVersion(), minorVersion);
if (t) {
maxMinorVersion = qMax(maxMinorVersion, t->minorVersion());
@@ -2342,7 +2359,7 @@ QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(QDeclarativeTy
// Signals override:
// * other signals and methods of the same name.
- // * properties named on<Signal Name>
+ // * properties named on<Signal Name>
// * automatic <property name>Changed notify signals
// Methods override:
@@ -2367,7 +2384,7 @@ QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(QDeclarativeTy
QDeclarativePropertyCache::Data *current = d;
while (!overloadError && current) {
current = d->overrideData(current);
- if (current && raw->isAllowedInRevision(current))
+ if (current && raw->isAllowedInRevision(current))
overloadError = true;
}
}
@@ -2375,7 +2392,7 @@ QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(QDeclarativeTy
if (overloadError) {
if (hasCopied) raw->release();
-
+
error.setDescription(QLatin1String("Type ") + QString::fromUtf8(type->qmlTypeName()) + QLatin1String(" ") + QString::number(type->majorVersion()) + QLatin1String(".") + QString::number(minorVersion) + QLatin1String(" contains an illegal property \"") + overloadName + QLatin1String("\". This is an error in the type's implementation."));
return 0;
}
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index 88b4e80..fd851f7 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -95,7 +95,6 @@ class QDeclarativeImportDatabase;
class QDeclarativeObjectScriptClass;
class QDeclarativeTypeNameScriptClass;
class QDeclarativeValueTypeScriptClass;
-class QScriptEngineDebugger;
class QNetworkReply;
class QNetworkAccessManager;
class QDeclarativeNetworkAccessManagerFactory;
@@ -332,14 +331,14 @@ public:
/*!
Returns a QDeclarativePropertyCache for \a obj if one is available.
-If \a obj is null, being deleted or contains a dynamic meta object 0
+If \a obj is null, being deleted or contains a dynamic meta object 0
is returned.
The returned cache is not referenced, so if it is to be stored, call addref().
*/
-QDeclarativePropertyCache *QDeclarativeEnginePrivate::cache(QObject *obj)
+QDeclarativePropertyCache *QDeclarativeEnginePrivate::cache(QObject *obj)
{
- if (!obj || QObjectPrivate::get(obj)->metaObject || QObjectPrivate::get(obj)->wasDeleted)
+ if (!obj || QObjectPrivate::get(obj)->metaObject || QObjectPrivate::get(obj)->wasDeleted)
return 0;
const QMetaObject *mo = obj->metaObject();
@@ -349,10 +348,10 @@ QDeclarativePropertyCache *QDeclarativeEnginePrivate::cache(QObject *obj)
}
/*!
-Returns a QDeclarativePropertyCache for \a metaObject.
+Returns a QDeclarativePropertyCache for \a metaObject.
As the cache is persisted for the life of the engine, \a metaObject must be
-a static "compile time" meta-object, or a meta-object that is otherwise known to
+a static "compile time" meta-object, or a meta-object that is otherwise known to
exist for the lifetime of the QDeclarativeEngine.
The returned cache is not referenced, so if it is to be stored, call addref().
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index b2a05c3..b7b88c9 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -524,8 +524,13 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message)
QString propertyName;
QVariant expr;
bool isLiteralValue;
+ QString filename;
+ int line;
ds >> objectId >> propertyName >> expr >> isLiteralValue;
- setBinding(objectId, propertyName, expr, isLiteralValue);
+ if (!ds.atEnd()) { // backward compatibility from 2.1, 2.2
+ ds >> filename >> line;
+ }
+ setBinding(objectId, propertyName, expr, isLiteralValue, filename, line);
} else if (type == "RESET_BINDING") {
int objectId;
QString propertyName;
@@ -543,7 +548,9 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message)
void QDeclarativeEngineDebugServer::setBinding(int objectId,
const QString &propertyName,
const QVariant &expression,
- bool isLiteralValue)
+ bool isLiteralValue,
+ QString filename,
+ int line)
{
QObject *object = objectForId(objectId);
QDeclarativeContext *context = qmlContext(object);
@@ -565,6 +572,7 @@ void QDeclarativeEngineDebugServer::setBinding(int objectId,
newBinding = new QDeclarativeBinding(expression.toString(), object, context);
newBinding->setTarget(property);
newBinding->setNotifyOnValueChanged(true);
+ newBinding->setSourceLocation(filename, line);
}
state->changeBindingInRevertList(object, propertyName, newBinding);
@@ -580,11 +588,12 @@ void QDeclarativeEngineDebugServer::setBinding(int objectId,
property.write(expression);
} else if (hasValidSignal(object, propertyName)) {
QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString());
- QDeclarativeExpression *oldExpression = QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression);
- declarativeExpression->setSourceLocation(oldExpression->sourceFile(), oldExpression->lineNumber());
+ QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression);
+ declarativeExpression->setSourceLocation(filename, line);
} else if (property.isProperty()) {
QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context);
binding->setTarget(property);
+ binding->setSourceLocation(filename, line);
binding->setNotifyOnValueChanged(true);
QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding);
if (oldBinding)
@@ -644,7 +653,10 @@ void QDeclarativeEngineDebugServer::resetBinding(int objectId, const QString &pr
}
}
}
- } else {
+ } else if (hasValidSignal(object, propertyName)) {
+ QDeclarativeProperty property(object, propertyName, context);
+ QDeclarativePropertyPrivate::setSignalExpression(property, 0);
+ } else {
if (QDeclarativePropertyChanges *propertyChanges = qobject_cast<QDeclarativePropertyChanges *>(object)) {
propertyChanges->removeProperty(propertyName);
}
diff --git a/src/declarative/qml/qdeclarativeenginedebug_p.h b/src/declarative/qml/qdeclarativeenginedebug_p.h
index e95676c..64b2724 100644
--- a/src/declarative/qml/qdeclarativeenginedebug_p.h
+++ b/src/declarative/qml/qdeclarativeenginedebug_p.h
@@ -115,7 +115,7 @@ private:
QDeclarativeObjectData objectData(QObject *);
QDeclarativeObjectProperty propertyData(QObject *, int);
QVariant valueContents(const QVariant &defaultValue) const;
- void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue);
+ void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename = QString(), int line = -1);
void resetBinding(int objectId, const QString &propertyName);
void setMethodBody(int objectId, const QString &method, const QString &body);
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index 9eecc65..edc1755 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -403,6 +403,33 @@ void QDeclarativeObjectScriptClass::setProperty(QObject *obj,
} else if (value.isFunction() && !value.isRegExp()) {
// this is handled by the binding creation above
} else {
+ //### expand optimization for other known types
+ if (lastData->propType == QMetaType::Int && value.isNumber()) {
+ int rawValue = qRound(value.toNumber());
+ int status = -1;
+ int flags = 0;
+ void *a[] = { (void *)&rawValue, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty,
+ lastData->coreIndex, a);
+ return;
+ } else if (lastData->propType == QMetaType::QReal && value.isNumber()) {
+ qreal rawValue = qreal(value.toNumber());
+ int status = -1;
+ int flags = 0;
+ void *a[] = { (void *)&rawValue, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty,
+ lastData->coreIndex, a);
+ return;
+ } else if (lastData->propType == QMetaType::QString && value.isString()) {
+ const QString &rawValue = value.toString();
+ int status = -1;
+ int flags = 0;
+ void *a[] = { (void *)&rawValue, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty,
+ lastData->coreIndex, a);
+ return;
+ }
+
QVariant v;
if (lastData->flags & QDeclarativePropertyCache::Data::IsQList)
v = enginePriv->scriptValueToVariant(value, qMetaTypeId<QList<QObject *> >());
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
index 7f74da4..253d744 100644
--- a/src/declarative/qml/qdeclarativeproperty.cpp
+++ b/src/declarative/qml/qdeclarativeproperty.cpp
@@ -1451,6 +1451,7 @@ QByteArray QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObj
QMetaProperty subProp = subObject->property(subIndex);
ValueTypeSerializedData sd;
+ memset(&sd, 0, sizeof(sd));
sd.isValueType = true;
sd.core.load(metaObject->property(index));
sd.valueType.flags = QDeclarativePropertyCache::Data::flagsForProperty(subProp);
@@ -1465,6 +1466,7 @@ QByteArray QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObj
QByteArray QDeclarativePropertyPrivate::saveProperty(const QMetaObject *metaObject, int index)
{
SerializedData sd;
+ memset(&sd, 0, sizeof(sd));
sd.isValueType = false;
sd.core.load(metaObject->property(index));
diff --git a/src/declarative/qml/qmetaobjectbuilder.cpp b/src/declarative/qml/qmetaobjectbuilder.cpp
index dc941e2..d8a7b77 100644
--- a/src/declarative/qml/qmetaobjectbuilder.cpp
+++ b/src/declarative/qml/qmetaobjectbuilder.cpp
@@ -101,7 +101,7 @@ bool isVariantType(const char* type)
return qvariant_nameToType(type) != 0;
}
-// copied from qmetaobject.cpp
+// copied from qmetaobject_p.h
// do not touch without touching the moc as well
enum PropertyFlags {
Invalid = 0x00000000,
@@ -111,6 +111,8 @@ enum PropertyFlags {
EnumOrFlag = 0x00000008,
StdCppSet = 0x00000100,
// Override = 0x00000200,
+ Constant = 0x00000400,
+ Final = 0x00000800,
Designable = 0x00001000,
ResolveDesignable = 0x00002000,
Scriptable = 0x00004000,
@@ -618,6 +620,8 @@ QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& protot
property.setUser(prototype.isUser());
property.setStdCppSet(prototype.hasStdCppSet());
property.setEnumOrFlag(prototype.isEnumType());
+ property.setConstant(prototype.isConstant());
+ property.setFinal(prototype.isFinal());
if (prototype.hasNotifySignal()) {
// Find an existing method for the notify signal, or add a new one.
QMetaMethod method = prototype.notifySignal();
@@ -1448,6 +1452,7 @@ QMetaObject *QMetaObjectBuilder::toMetaObject() const
{
int size = buildMetaObject(d, 0, false);
char *buf = reinterpret_cast<char *>(qMalloc(size));
+ memset(buf, 0, size);
buildMetaObject(d, buf, false);
return reinterpret_cast<QMetaObject *>(buf);
}
@@ -1477,6 +1482,7 @@ QByteArray QMetaObjectBuilder::toRelocatableData(bool *ok) const
QByteArray data;
data.resize(size);
char *buf = data.data();
+ memset(buf, 0, size);
buildMetaObject(d, buf, true);
if (ok) *ok = true;
return data;
@@ -2278,6 +2284,32 @@ bool QMetaPropertyBuilder::isEnumOrFlag() const
}
/*!
+ Returns true if the property is constant; otherwise returns false.
+ The default value is false.
+*/
+bool QMetaPropertyBuilder::isConstant() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->flag(Constant);
+ else
+ return false;
+}
+
+/*!
+ Returns true if the property is final; otherwise returns false.
+ The default value is false.
+*/
+bool QMetaPropertyBuilder::isFinal() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->flag(Final);
+ else
+ return false;
+}
+
+/*!
Sets this property to readable if \a value is true.
\sa isReadable(), setWritable()
@@ -2401,6 +2433,31 @@ void QMetaPropertyBuilder::setEnumOrFlag(bool value)
}
/*!
+ Sets the \c CONSTANT flag on this property to \a value.
+
+ \sa isConstant()
+*/
+void QMetaPropertyBuilder::setConstant(bool value)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ d->setFlag(Constant, value);
+}
+
+/*!
+ Sets the \c FINAL flag on this property to \a value.
+
+ \sa isFinal()
+*/
+void QMetaPropertyBuilder::setFinal(bool value)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ d->setFlag(Final, value);
+}
+
+
+/*!
\class QMetaEnumBuilder
\internal
\brief The QMetaEnumBuilder class enables modifications to an enumerator definition on a meta object builder.
diff --git a/src/declarative/qml/qmetaobjectbuilder_p.h b/src/declarative/qml/qmetaobjectbuilder_p.h
index d7085f8..335a825 100644
--- a/src/declarative/qml/qmetaobjectbuilder_p.h
+++ b/src/declarative/qml/qmetaobjectbuilder_p.h
@@ -258,6 +258,8 @@ public:
bool isUser() const;
bool hasStdCppSet() const;
bool isEnumOrFlag() const;
+ bool isConstant() const;
+ bool isFinal() const;
void setReadable(bool value);
void setWritable(bool value);
@@ -269,6 +271,8 @@ public:
void setUser(bool value);
void setStdCppSet(bool value);
void setEnumOrFlag(bool value);
+ void setConstant(bool value);
+ void setFinal(bool value);
private:
const QMetaObjectBuilder *_mobj;
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index e24f80f..628c82c 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -49,6 +49,7 @@
#include <qdeclarativeguard_p.h>
#include <private/qdeclarativedebugtrace_p.h>
+#include <private/qdeclarativeobserverservice_p.h>
#include <qscriptvalueiterator.h>
#include <qdebug.h>
@@ -299,6 +300,8 @@ void QDeclarativeViewPrivate::init()
q->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
q->viewport()->setAttribute(Qt::WA_NoSystemBackground);
#endif
+
+ QDeclarativeObserverService::instance()->addView(q);
}
/*!
@@ -306,6 +309,7 @@ void QDeclarativeViewPrivate::init()
*/
QDeclarativeView::~QDeclarativeView()
{
+ QDeclarativeObserverService::instance()->removeView(this);
}
/*! \property QDeclarativeView::source
@@ -558,7 +562,6 @@ void QDeclarativeView::continueExecute()
emit statusChanged(status());
}
-
/*!
\internal
*/
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index 48cbec3..78918cc 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -451,8 +451,8 @@ static QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> getFactor(qreal valu
static qreal interpolate(const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> &factor,
qreal min, qreal minPref, qreal pref, qreal maxPref, qreal max)
{
- qreal lower;
- qreal upper;
+ qreal lower = 0;
+ qreal upper = 0;
switch (factor.first) {
case QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred:
diff --git a/src/gui/graphicsview/qgraphicslayout.cpp b/src/gui/graphicsview/qgraphicslayout.cpp
index 904a3de..a67ae48 100644
--- a/src/gui/graphicsview/qgraphicslayout.cpp
+++ b/src/gui/graphicsview/qgraphicslayout.cpp
@@ -167,7 +167,7 @@ QGraphicsLayout::QGraphicsLayout(QGraphicsLayoutItem *parent)
" neither a QGraphicsWidget nor QGraphicsLayout");
}
}
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding, QSizePolicy::DefaultType);
+ d_func()->sizePolicy = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding, QSizePolicy::DefaultType);
setOwnedByLayout(true);
}
@@ -188,7 +188,7 @@ QGraphicsLayout::QGraphicsLayout(QGraphicsLayoutPrivate &dd, QGraphicsLayoutItem
" neither a QGraphicsWidget nor QGraphicsLayout");
}
}
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding, QSizePolicy::DefaultType);
+ d_func()->sizePolicy = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding, QSizePolicy::DefaultType);
setOwnedByLayout(true);
}
@@ -269,12 +269,20 @@ void QGraphicsLayout::activate()
return;
Q_ASSERT(!parentItem->isLayout());
- setGeometry(parentItem->contentsRect()); // relayout children
+ if (QGraphicsLayout::instantInvalidatePropagation()) {
+ QGraphicsWidget *parentWidget = static_cast<QGraphicsWidget*>(parentItem);
+ if (!parentWidget->parentLayoutItem()) {
+ // we've reached the topmost widget, resize it
+ bool wasResized = parentWidget->testAttribute(Qt::WA_Resized);
+ parentWidget->resize(parentWidget->size());
+ parentWidget->setAttribute(Qt::WA_Resized, wasResized);
+ }
- // ### bug, should be parentItem ?
- parentLayoutItem()->updateGeometry(); // bubble up; will set activated to false
- // ### too many resizes? maybe we should walk up the chain to the
- // ### top-level layouted layoutItem and call activate there.
+ setGeometry(parentItem->contentsRect()); // relayout children
+ } else {
+ setGeometry(parentItem->contentsRect()); // relayout children
+ parentLayoutItem()->updateGeometry();
+ }
}
/*!
@@ -300,32 +308,36 @@ bool QGraphicsLayout::isActivated() const
*/
void QGraphicsLayout::invalidate()
{
- // only mark layouts as invalid (activated = false) if we can post a LayoutRequest event.
- QGraphicsLayoutItem *layoutItem = this;
- while (layoutItem && layoutItem->isLayout()) {
- // we could call updateGeometry(), but what if that method
- // does not call the base implementation? In addition, updateGeometry()
- // does more than we need.
- layoutItem->d_func()->sizeHintCacheDirty = true;
- layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true;
- layoutItem = layoutItem->parentLayoutItem();
- }
- if (layoutItem) {
- layoutItem->d_func()->sizeHintCacheDirty = true;
- layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true;
- }
-
- bool postIt = layoutItem ? !layoutItem->isLayout() : false;
- if (postIt) {
- layoutItem = this;
- while (layoutItem && layoutItem->isLayout()
- && static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated) {
- static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated = false;
+ if (QGraphicsLayout::instantInvalidatePropagation()) {
+ updateGeometry();
+ } else {
+ // only mark layouts as invalid (activated = false) if we can post a LayoutRequest event.
+ QGraphicsLayoutItem *layoutItem = this;
+ while (layoutItem && layoutItem->isLayout()) {
+ // we could call updateGeometry(), but what if that method
+ // does not call the base implementation? In addition, updateGeometry()
+ // does more than we need.
+ layoutItem->d_func()->sizeHintCacheDirty = true;
+ layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true;
layoutItem = layoutItem->parentLayoutItem();
}
- if (layoutItem && !layoutItem->isLayout()) {
- // If a layout has a parent that is not a layout it must be a QGraphicsWidget.
- QApplication::postEvent(static_cast<QGraphicsWidget *>(layoutItem), new QEvent(QEvent::LayoutRequest));
+ if (layoutItem) {
+ layoutItem->d_func()->sizeHintCacheDirty = true;
+ layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true;
+ }
+
+ bool postIt = layoutItem ? !layoutItem->isLayout() : false;
+ if (postIt) {
+ layoutItem = this;
+ while (layoutItem && layoutItem->isLayout()
+ && static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated) {
+ static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated = false;
+ layoutItem = layoutItem->parentLayoutItem();
+ }
+ if (layoutItem && !layoutItem->isLayout()) {
+ // If a layout has a parent that is not a layout it must be a QGraphicsWidget.
+ QApplication::postEvent(static_cast<QGraphicsWidget *>(layoutItem), new QEvent(QEvent::LayoutRequest));
+ }
}
}
}
@@ -335,12 +347,27 @@ void QGraphicsLayout::invalidate()
*/
void QGraphicsLayout::updateGeometry()
{
- QGraphicsLayoutItem::updateGeometry();
- if (QGraphicsLayoutItem *parentItem = parentLayoutItem()) {
- if (parentItem->isLayout()) {
+ Q_D(QGraphicsLayout);
+ if (QGraphicsLayout::instantInvalidatePropagation()) {
+ d->activated = false;
+ QGraphicsLayoutItem::updateGeometry();
+
+ QGraphicsLayoutItem *parentItem = parentLayoutItem();
+ if (!parentItem)
+ return;
+
+ if (parentItem->isLayout())
+ static_cast<QGraphicsLayout *>(parentItem)->invalidate();
+ else
parentItem->updateGeometry();
- } else {
- invalidate();
+ } else {
+ QGraphicsLayoutItem::updateGeometry();
+ if (QGraphicsLayoutItem *parentItem = parentLayoutItem()) {
+ if (parentItem->isLayout()) {
+ parentItem->updateGeometry();
+ } else {
+ invalidate();
+ }
}
}
}
@@ -446,6 +473,50 @@ void QGraphicsLayout::addChildLayoutItem(QGraphicsLayoutItem *layoutItem)
d->addChildLayoutItem(layoutItem);
}
+static bool g_instantInvalidatePropagation = false;
+
+/*!
+ \internal
+ \since 4.8
+ \see instantInvalidatePropagation
+
+ Calling this function with \a enable set to true will enable a feature that
+ makes propagation of invalidation up to ancestor layout items to be done in
+ one go. It will propagate up the parentLayoutItem() hierarchy until it has
+ reached the root. If the root item is a QGraphicsWidget, it will *post* a
+ layout request to it. When the layout request is consumed it will traverse
+ down the hierarchy of layouts and widgets and activate all layouts that is
+ invalid (not activated). This is the recommended behaviour.
+
+ If not set it will also propagate up the parentLayoutItem() hierarchy, but
+ it will stop at the \i first \i widget it encounters, and post a layout
+ request to the widget. When the layout request is consumed, this might
+ cause it to continue propagation up to the parentLayoutItem() of the
+ widget. It will continue in this fashion until it has reached a widget with
+ no parentLayoutItem(). This strategy might cause drawing artifacts, since
+ it is not done in one go, and the consumption of layout requests might be
+ interleaved by consumption of paint events, which might cause significant
+ flicker.
+ Note, this is not the recommended behavior, but for compatibility reasons
+ this is the default behaviour.
+*/
+void QGraphicsLayout::setInstantInvalidatePropagation(bool enable)
+{
+ g_instantInvalidatePropagation = enable;
+}
+
+/*!
+ \internal
+ \since 4.8
+ \see setInstantInvalidatePropagation
+
+ returns true if the complete widget/layout hierarchy is rearranged in one go.
+*/
+bool QGraphicsLayout::instantInvalidatePropagation()
+{
+ return g_instantInvalidatePropagation;
+}
+
QT_END_NAMESPACE
#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicslayout.h b/src/gui/graphicsview/qgraphicslayout.h
index c622fb8..6031174 100644
--- a/src/gui/graphicsview/qgraphicslayout.h
+++ b/src/gui/graphicsview/qgraphicslayout.h
@@ -76,6 +76,8 @@ public:
virtual QGraphicsLayoutItem *itemAt(int i) const = 0;
virtual void removeAt(int index) = 0;
+ static void setInstantInvalidatePropagation(bool enable);
+ static bool instantInvalidatePropagation();
protected:
QGraphicsLayout(QGraphicsLayoutPrivate &, QGraphicsLayoutItem *);
void addChildLayoutItem(QGraphicsLayoutItem *layoutItem);
diff --git a/src/gui/graphicsview/qgraphicslayout_p.cpp b/src/gui/graphicsview/qgraphicslayout_p.cpp
index c325602..f73fb6a 100644
--- a/src/gui/graphicsview/qgraphicslayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicslayout_p.cpp
@@ -180,8 +180,13 @@ void QGraphicsLayoutPrivate::activateRecursive(QGraphicsLayoutItem *item)
{
if (item->isLayout()) {
QGraphicsLayout *layout = static_cast<QGraphicsLayout *>(item);
- if (layout->d_func()->activated)
- layout->invalidate();
+ if (layout->d_func()->activated) {
+ if (QGraphicsLayout::instantInvalidatePropagation()) {
+ return;
+ } else {
+ layout->invalidate(); // ### LOOKS SUSPICIOUSLY WRONG!!???
+ }
+ }
for (int i = layout->count() - 1; i >= 0; --i) {
QGraphicsLayoutItem *childItem = layout->itemAt(i);
diff --git a/src/gui/graphicsview/qgraphicslinearlayout.cpp b/src/gui/graphicsview/qgraphicslinearlayout.cpp
index 5591638..40f9b1d 100644
--- a/src/gui/graphicsview/qgraphicslinearlayout.cpp
+++ b/src/gui/graphicsview/qgraphicslinearlayout.cpp
@@ -275,17 +275,13 @@ void QGraphicsLinearLayout::insertItem(int index, QGraphicsLayoutItem *item)
qWarning("QGraphicsLinearLayout::insertItem: cannot insert itself");
return;
}
- Q_ASSERT(item);
-
- //the order of the following instructions is very important because
- //invalidating the layout before adding the child item will make the layout happen
- //before we try to paint the item
- invalidate();
d->addChildLayoutItem(item);
+ Q_ASSERT(item);
d->fixIndex(&index);
d->engine.insertRow(index, d->orientation);
new QGridLayoutItem(&d->engine, item, d->gridRow(index), d->gridColumn(index), 1, 1, 0, index);
+ invalidate();
}
/*!
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 675a5c5..141e305 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -354,8 +354,10 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
newGeom = rect;
newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))
.boundedTo(effectiveSizeHint(Qt::MaximumSize)));
- if (newGeom == d->geom)
- return;
+
+ if (newGeom == d->geom) {
+ goto relayoutChildrenAndReturn;
+ }
// setPos triggers ItemPositionChange, which can adjust position
wd->inSetGeometry = 1;
@@ -363,8 +365,9 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
wd->inSetGeometry = 0;
newGeom.moveTopLeft(pos());
- if (newGeom == d->geom)
- return;
+ if (newGeom == d->geom) {
+ goto relayoutChildrenAndReturn;
+ }
// Update and prepare to change the geometry (remove from index) if the size has changed.
if (wd->scene) {
@@ -375,35 +378,54 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
}
// Update the layout item geometry
- bool moved = oldPos != pos();
- if (moved) {
- // Send move event.
- QGraphicsSceneMoveEvent event;
- event.setOldPos(oldPos);
- event.setNewPos(pos());
- QApplication::sendEvent(this, &event);
- if (wd->inSetPos) {
- //set the new pos
- d->geom.moveTopLeft(pos());
- emit geometryChanged();
- return;
+ {
+ bool moved = oldPos != pos();
+ if (moved) {
+ // Send move event.
+ QGraphicsSceneMoveEvent event;
+ event.setOldPos(oldPos);
+ event.setNewPos(pos());
+ QApplication::sendEvent(this, &event);
+ if (wd->inSetPos) {
+ //set the new pos
+ d->geom.moveTopLeft(pos());
+ emit geometryChanged();
+ goto relayoutChildrenAndReturn;
+ }
+ }
+ QSizeF oldSize = size();
+ QGraphicsLayoutItem::setGeometry(newGeom);
+ // Send resize event
+ bool resized = newGeom.size() != oldSize;
+ if (resized) {
+ QGraphicsSceneResizeEvent re;
+ re.setOldSize(oldSize);
+ re.setNewSize(newGeom.size());
+ if (oldSize.width() != newGeom.size().width())
+ emit widthChanged();
+ if (oldSize.height() != newGeom.size().height())
+ emit heightChanged();
+ QGraphicsLayout *lay = wd->layout;
+ if (QGraphicsLayout::instantInvalidatePropagation()) {
+ if (!lay || lay->isActivated()) {
+ QApplication::sendEvent(this, &re);
+ }
+ } else {
+ QApplication::sendEvent(this, &re);
+ }
}
}
- QSizeF oldSize = size();
- QGraphicsLayoutItem::setGeometry(newGeom);
- // Send resize event
- bool resized = newGeom.size() != oldSize;
- if (resized) {
- QGraphicsSceneResizeEvent re;
- re.setOldSize(oldSize);
- re.setNewSize(newGeom.size());
- if (oldSize.width() != newGeom.size().width())
- emit widthChanged();
- if (oldSize.height() != newGeom.size().height())
- emit heightChanged();
- QApplication::sendEvent(this, &re);
- }
+
emit geometryChanged();
+relayoutChildrenAndReturn:
+ if (QGraphicsLayout::instantInvalidatePropagation()) {
+ if (QGraphicsLayout *lay = wd->layout) {
+ if (!lay->isActivated()) {
+ QEvent layoutRequest(QEvent::LayoutRequest);
+ QApplication::sendEvent(this, &layoutRequest);
+ }
+ }
+ }
}
/*!
@@ -1052,16 +1074,31 @@ void QGraphicsWidget::updateGeometry()
QGraphicsLayoutItem *parentItem = parentLayoutItem();
if (parentItem && parentItem->isLayout()) {
- parentItem->updateGeometry();
+ if (QGraphicsLayout::instantInvalidatePropagation()) {
+ static_cast<QGraphicsLayout *>(parentItem)->invalidate();
+ } else {
+ parentItem->updateGeometry();
+ }
} else {
if (parentItem) {
+ // This is for custom layouting
QGraphicsWidget *parentWid = parentWidget(); //###
if (parentWid->isVisible())
QApplication::postEvent(parentWid, new QEvent(QEvent::LayoutRequest));
+ } else {
+ /**
+ * If this is the topmost widget, post a LayoutRequest event to the widget.
+ * When the event is received, it will start flowing all the way down to the leaf
+ * widgets in one go. This will make a relayout flicker-free.
+ */
+ if (QGraphicsLayout::instantInvalidatePropagation())
+ QApplication::postEvent(static_cast<QGraphicsWidget *>(this), new QEvent(QEvent::LayoutRequest));
+ }
+ if (!QGraphicsLayout::instantInvalidatePropagation()) {
+ bool wasResized = testAttribute(Qt::WA_Resized);
+ resize(size()); // this will restrict the size
+ setAttribute(Qt::WA_Resized, wasResized);
}
- bool wasResized = testAttribute(Qt::WA_Resized);
- resize(size()); // this will restrict the size
- setAttribute(Qt::WA_Resized, wasResized);
}
}
diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp
index 4580055..63d7298 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.cpp
+++ b/src/gui/graphicsview/qgraphicswidget_p.cpp
@@ -857,8 +857,6 @@ void QGraphicsWidgetPrivate::setWidth(qreal w)
if (q->geometry().width() == w)
return;
- QRectF oldGeom = q->geometry();
-
q->setGeometry(QRectF(q->x(), q->y(), w, height()));
}
@@ -882,8 +880,6 @@ void QGraphicsWidgetPrivate::setHeight(qreal h)
if (q->geometry().height() == h)
return;
- QRectF oldGeom = q->geometry();
-
q->setGeometry(QRectF(q->x(), q->y(), width(), h));
}
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 50b372e..25f6295 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -4449,6 +4449,8 @@ QImage QImage::scaled(const QSize& s, Qt::AspectRatioMode aspectMode, Qt::Transf
QSize newSize = size();
newSize.scale(s, aspectMode);
+ newSize.rwidth() = qMax(newSize.width(), 1);
+ newSize.rheight() = qMax(newSize.height(), 1);
if (newSize == size())
return *this;
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 34804e5..640864d 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -1224,12 +1224,8 @@ Qt::HANDLE QPixmap::handle() const
{
#if defined(Q_WS_X11)
const QPixmapData *pd = pixmapData();
- if (pd) {
- if (pd->classId() == QPixmapData::X11Class)
- return static_cast<const QX11PixmapData*>(pd)->handle();
- else
- qWarning("QPixmap::handle(): Pixmap is not an X11 class pixmap");
- }
+ if (pd && pd->classId() == QPixmapData::X11Class)
+ return static_cast<const QX11PixmapData*>(pd)->handle();
#endif
return 0;
}
@@ -1518,6 +1514,8 @@ QPixmap QPixmap::scaled(const QSize& s, Qt::AspectRatioMode aspectMode, Qt::Tran
QSize newSize = size();
newSize.scale(s, aspectMode);
+ newSize.rwidth() = qMax(newSize.width(), 1);
+ newSize.rheight() = qMax(newSize.height(), 1);
if (newSize == size())
return *this;
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp
index 72e2aa6..e107d88 100644
--- a/src/gui/image/qpixmap_mac.cpp
+++ b/src/gui/image/qpixmap_mac.cpp
@@ -54,6 +54,7 @@
#include <private/qpaintengine_mac_p.h>
#include <private/qt_mac_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
+#include <private/qapplication_p.h>
#include <limits.h>
#include <string.h>
@@ -73,12 +74,18 @@ static int qt_pixmap_serial = 0;
Q_GUI_EXPORT quint32 *qt_mac_pixmap_get_base(const QPixmap *pix)
{
- return static_cast<QMacPixmapData*>(pix->data.data())->pixels;
+ if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
+ return reinterpret_cast<quint32 *>(static_cast<QRasterPixmapData*>(pix->data.data())->buffer()->bits());
+ else
+ return static_cast<QMacPixmapData*>(pix->data.data())->pixels;
}
Q_GUI_EXPORT int qt_mac_pixmap_get_bytes_per_line(const QPixmap *pix)
{
- return static_cast<QMacPixmapData*>(pix->data.data())->bytesPerRow;
+ if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
+ return static_cast<QRasterPixmapData*>(pix->data.data())->buffer()->bytesPerLine();
+ else
+ return static_cast<QMacPixmapData*>(pix->data.data())->bytesPerRow;
}
void qt_mac_cgimage_data_free(void *info, const void *memoryToFree, size_t)
diff --git a/src/gui/image/qvolatileimage.cpp b/src/gui/image/qvolatileimage.cpp
index 098e9a1..f5076e1 100644
--- a/src/gui/image/qvolatileimage.cpp
+++ b/src/gui/image/qvolatileimage.cpp
@@ -103,6 +103,11 @@ QVolatileImage &QVolatileImage::operator=(const QVolatileImage &rhs)
return *this;
}
+bool QVolatileImage::paintingActive() const
+{
+ return d->pengine && d->pengine->isActive();
+}
+
bool QVolatileImage::isNull() const
{
return d->image.isNull();
diff --git a/src/gui/image/qvolatileimage_p.h b/src/gui/image/qvolatileimage_p.h
index fc5d6b1..d835f45 100644
--- a/src/gui/image/qvolatileimage_p.h
+++ b/src/gui/image/qvolatileimage_p.h
@@ -71,6 +71,7 @@ public:
~QVolatileImage();
QVolatileImage &operator=(const QVolatileImage &rhs);
+ bool paintingActive() const;
bool isNull() const;
QImage::Format format() const;
int width() const;
diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h
index de3577f..57c1e45 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_p.h
+++ b/src/gui/inputmethod/qcoefepinputcontext_p.h
@@ -168,6 +168,7 @@ private:
};
Q_GUI_EXPORT void qt_s60_setPartialScreenInputMode(bool enable);
+Q_GUI_EXPORT void qt_s60_setPartialScreenAutomaticTranslation(bool enable);
QT_END_NAMESPACE
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index 06dc25c..23109e1 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -88,6 +88,11 @@ Q_GUI_EXPORT void qt_s60_setPartialScreenInputMode(bool enable)
ic->update();
}
+Q_GUI_EXPORT void qt_s60_setPartialScreenAutomaticTranslation(bool enable)
+{
+ S60->partial_keyboardAutoTranslation = enable;
+}
+
QCoeFepInputContext::QCoeFepInputContext(QObject *parent)
: QInputContext(parent),
m_fepState(q_check_ptr(new CAknEdwinState)), // CBase derived object needs check on new
@@ -235,21 +240,6 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event)
return false;
switch (event->type()) {
- case QEvent::MouseButtonPress:
- // Alphanumeric keypad doesn't like it when we click and text is still getting displayed
- // It ignores the mouse event, so we need to commit and send a selection event (which will get triggered
- // after the commit)
- if (!m_preeditString.isEmpty()) {
- commitCurrentString(true);
-
- int pos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt();
-
- QList<QInputMethodEvent::Attribute> selectAttributes;
- selectAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, pos, 0, QVariant());
- QInputMethodEvent selectEvent(QLatin1String(""), selectAttributes);
- sendEvent(selectEvent);
- }
- break;
case QEvent::KeyPress:
commitTemporaryPreeditString();
// fall through intended
@@ -328,7 +318,10 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event)
if (sControl) {
sControl->setIgnoreFocusChanged(false);
}
- return true;
+ //If m_pointerHandler has already been set, it means that fep inline editing is in progress.
+ //When this is happening, do not filter out pointer events.
+ if (!m_pointerHandler)
+ return true;
}
return false;
@@ -380,18 +373,31 @@ void QCoeFepInputContext::commitTemporaryPreeditString()
commitCurrentString(false);
}
-void QCoeFepInputContext::mouseHandler( int x, QMouseEvent *event)
+void QCoeFepInputContext::mouseHandler(int x, QMouseEvent *event)
{
Q_ASSERT(focusWidget());
if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::LeftButton) {
- commitCurrentString(true);
- int pos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt();
+ QWidget *proxy = focusWidget()->focusProxy();
+ Qt::InputMethodHints currentHints = proxy ? proxy->inputMethodHints() : focusWidget()->inputMethodHints();
+
+ //If splitview is open and T9 word is tapped, pass the pointer event to pointer handler.
+ //This will open the "suggested words" list. Pass pointer position always as zero, to make
+ //full word replacement in case user makes a selection.
+ if (S60->partial_keyboard && S60->partialKeyboardOpen
+ && m_pointerHandler
+ && !(currentHints & Qt::ImhNoPredictiveText)
+ && (x > 0 && x < m_preeditString.length())) {
+ m_pointerHandler->HandlePointerEventInInlineTextL(TPointerEvent::EButton1Up, 0, 0);
+ } else {
+ commitCurrentString(true);
+ int pos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt();
- QList<QInputMethodEvent::Attribute> attributes;
- attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, pos + x, 0, QVariant());
- QInputMethodEvent event(QLatin1String(""), attributes);
- sendEvent(event);
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, pos + x, 0, QVariant());
+ QInputMethodEvent event(QLatin1String(""), attributes);
+ sendEvent(event);
+ }
}
}
@@ -559,12 +565,13 @@ void QCoeFepInputContext::ensureFocusWidgetVisible(QWidget *widget)
widget->resize(widget->width(), splitViewRect.height() - windowTop);
}
- if (gv->scene()) {
+ if (gv->scene() && S60->partial_keyboardAutoTranslation) {
const QRectF microFocusRect = gv->scene()->inputMethodQuery(Qt::ImMicroFocus).toRectF();
gv->ensureVisible(microFocusRect);
}
} else {
- translateInputWidget();
+ if (S60->partial_keyboardAutoTranslation)
+ translateInputWidget();
}
if (alwaysResize)
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index d671496..0bf85c6 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -62,9 +62,6 @@
#include <qaccessible.h>
#endif
#include <private/qsoftkeymanager_p.h>
-#ifndef QT_NO_GESTURE
-# include <qscroller.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -194,40 +191,6 @@ void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index
}
}
-#ifndef QT_NO_GESTURES
-
-// stores and restores the selection and current item when flicking
-void QAbstractItemViewPrivate::_q_scrollerStateChanged()
-{
- Q_Q(QAbstractItemView);
-
- if (QScroller *scroller = QScroller::scroller(viewport)) {
- switch (scroller->state()) {
- case QScroller::Pressed:
- // store the current selection in case we start scrolling
- if (q->selectionModel()) {
- oldSelection = q->selectionModel()->selection();
- oldCurrent = q->selectionModel()->currentIndex();
- }
- break;
-
- case QScroller::Dragging:
- // restore the old selection if we really start scrolling
- if (q->selectionModel()) {
- q->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect);
- q->selectionModel()->setCurrentIndex(oldCurrent, QItemSelectionModel::NoUpdate);
- }
- // fall through
-
- default:
- oldSelection = QItemSelection();
- oldCurrent = QModelIndex();
- break;
- }
- }
-}
-
-#endif // QT_NO_GESTURES
/*!
\class QAbstractItemView
@@ -1662,13 +1625,6 @@ bool QAbstractItemView::viewportEvent(QEvent *event)
case QEvent::WindowDeactivate:
d->viewport->update();
break;
- case QEvent::ScrollPrepare:
- executeDelayedItemsLayout();
-#ifndef QT_NO_GESTURES
- connect(QScroller::scroller(d->viewport), SIGNAL(stateChanged(QScroller::State)), this, SLOT(_q_scrollerStateChanged()), Qt::UniqueConnection);
-#endif
- break;
-
default:
break;
}
diff --git a/src/gui/itemviews/qabstractitemview.h b/src/gui/itemviews/qabstractitemview.h
index f11f209..7043a5f 100644
--- a/src/gui/itemviews/qabstractitemview.h
+++ b/src/gui/itemviews/qabstractitemview.h
@@ -359,9 +359,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed())
Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged())
Q_PRIVATE_SLOT(d_func(), void _q_headerDataChanged())
-#ifndef QT_NO_GESTURES
- Q_PRIVATE_SLOT(d_func(), void _q_scrollerStateChanged())
-#endif
friend class QTreeViewPrivate; // needed to compile with MSVC
friend class QAccessibleItemRow;
diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h
index 6041e5e..d5a0d37 100644
--- a/src/gui/itemviews/qabstractitemview_p.h
+++ b/src/gui/itemviews/qabstractitemview_p.h
@@ -114,7 +114,6 @@ public:
virtual void _q_modelDestroyed();
virtual void _q_layoutChanged();
void _q_headerDataChanged() { doDelayedItemsLayout(); }
- void _q_scrollerStateChanged();
void fetchMore();
@@ -415,12 +414,6 @@ public:
QAbstractItemView::ScrollMode verticalScrollMode;
QAbstractItemView::ScrollMode horizontalScrollMode;
-#ifndef QT_NO_GESTURES
- // the selection before the last mouse down. In case we have to restore it for scrolling
- QItemSelection oldSelection;
- QModelIndex oldCurrent;
-#endif
-
bool currentIndexSet;
bool wrapItemText;
diff --git a/src/gui/itemviews/qdatawidgetmapper.cpp b/src/gui/itemviews/qdatawidgetmapper.cpp
index 745ef5a..dac4613 100644
--- a/src/gui/itemviews/qdatawidgetmapper.cpp
+++ b/src/gui/itemviews/qdatawidgetmapper.cpp
@@ -291,7 +291,7 @@ void QDataWidgetMapperPrivate::_q_modelDestroyed()
\snippet doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp 0
After the call to toFirst(), \c mySpinBox displays the value \c{1}, \c myLineEdit
- displays \c {Nokia Corporation and/or its subsidiary(-ies)} and \c myCountryChooser displays \c{Oslo}. The
+ displays \c{Qt Norway} and \c myCountryChooser displays \c{Oslo}. The
navigational functions toFirst(), toNext(), toPrevious(), toLast() and setCurrentIndex()
can be used to navigate in the model and update the widgets with contents from
the model.
diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp
index 59a3d15..e70f356 100644
--- a/src/gui/itemviews/qtableview.cpp
+++ b/src/gui/itemviews/qtableview.cpp
@@ -1300,7 +1300,6 @@ void QTableView::paintEvent(QPaintEvent *event)
const QPen gridPen = QPen(gridColor, 0, d->gridStyle);
const QHeaderView *verticalHeader = d->verticalHeader;
const QHeaderView *horizontalHeader = d->horizontalHeader;
- const QStyle::State state = option.state;
const bool alternate = d->alternatingColors;
const bool rightToLeft = isRightToLeft();
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 408c3b5..815d221 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -1360,6 +1360,23 @@ void QSymbianControl::PositionChanged()
}
}
+// Search recursively if there is a child widget that is both visible and focused.
+bool QSymbianControl::hasFocusedAndVisibleChild(QWidget *parentWidget)
+{
+ for (int i = 0; i < parentWidget->children().size(); ++i) {
+ QObject *object = parentWidget->children().at(i);
+ if (object && object->isWidgetType()) {
+ QWidget *w = static_cast<QWidget *>(object);
+ WId winId = w->internalWinId();
+ if (winId && winId->IsFocused() && winId->IsVisible())
+ return true;
+ if (hasFocusedAndVisibleChild(w))
+ return true;
+ }
+ }
+ return false;
+}
+
void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */)
{
if (m_ignoreFocusChanged || (qwidget->windowType() & Qt::WindowType_Mask) == Qt::Desktop)
@@ -1392,17 +1409,9 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */)
if (qwidget->isWindow())
S60->setRecursiveDecorationsVisibility(qwidget, qwidget->windowState());
#endif
- } else if (QApplication::activeWindow() == qwidget->window()) {
- bool focusedControlFound = false;
- WId winId = 0;
- for (QWidget *w = qwidget->parentWidget(); w && (winId = w->internalWinId()); w = w->parentWidget()) {
- if (winId->IsFocused() && winId->IsVisible()) {
- focusedControlFound = true;
- break;
- } else if (w->isWindow())
- break;
- }
- if (!focusedControlFound) {
+ } else {
+ QWidget *parentWindow = qwidget->window();
+ if (QApplication::activeWindow() == parentWindow && !hasFocusedAndVisibleChild(parentWindow)) {
if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog() || S60->menuBeingConstructed) {
QWidget *fw = QApplication::focusWidget();
if (fw) {
@@ -1481,8 +1490,10 @@ void QSymbianControl::HandleResourceChange(int resourceType)
}
if (ic && isSplitViewWidget(widget)) {
if (resourceType == KSplitViewCloseEvent) {
+ S60->partialKeyboardOpen = false;
ic->resetSplitViewWidget();
} else {
+ S60->partialKeyboardOpen = true;
ic->ensureFocusWidgetVisible(widget);
}
}
@@ -1509,6 +1520,10 @@ void QSymbianControl::HandleResourceChange(int resourceType)
#ifdef Q_WS_S60
case KEikDynamicLayoutVariantSwitch:
{
+#ifdef QT_SOFTKEYS_ENABLED
+ // Update needed just in case softkeys contain icons
+ QSoftKeyManager::updateSoftKeys();
+#endif
handleClientAreaChange();
// Send resize event to trigger desktopwidget workAreaResized signal
if (qt_desktopWidget) {
@@ -2703,6 +2718,9 @@ QS60ThreadLocalData::QS60ThreadLocalData()
QS60ThreadLocalData::~QS60ThreadLocalData()
{
+ for (int i = 0; i < releaseFuncs.count(); ++i)
+ releaseFuncs[i]();
+ releaseFuncs.clear();
if (!usingCONEinstances) {
delete screenDevice;
wsSession.Close();
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 6658300..63e2319 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -237,6 +237,7 @@ static void resolveAygLibs()
# define FE_FONTSMOOTHINGCLEARTYPE 0x0002
#endif
+Q_GUI_EXPORT qreal qt_fontsmoothing_gamma;
Q_GUI_EXPORT bool qt_cleartype_enabled;
Q_GUI_EXPORT bool qt_win_owndc_required; // CS_OWNDC is required if we use the GL graphicssystem as default
@@ -653,8 +654,18 @@ static void qt_win_read_cleartype_settings()
if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0))
qt_cleartype_enabled = (result == FE_FONTSMOOTHINGCLEARTYPE);
#endif
-}
+ int winSmooth;
+ if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0)) {
+ qt_fontsmoothing_gamma = winSmooth / qreal(1000.0);
+ } else {
+ qt_fontsmoothing_gamma = 1.0;
+ }
+
+ // Safeguard ourselves against corrupt registry values...
+ if (qt_fontsmoothing_gamma > 5 || qt_fontsmoothing_gamma < 1)
+ qt_fontsmoothing_gamma = qreal(1.4);
+}
static void qt_set_windows_resources()
{
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 20542ea..577d93b 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -2018,15 +2018,12 @@ void qt_init(QApplicationPrivate *priv, int,
(PtrXRRRootToScreen) xrandrLib.resolve("XRRRootToScreen");
X11->ptrXRRQueryExtension =
(PtrXRRQueryExtension) xrandrLib.resolve("XRRQueryExtension");
- X11->ptrXRRSizes =
- (PtrXRRSizes) xrandrLib.resolve("XRRSizes");
}
# else
X11->ptrXRRSelectInput = XRRSelectInput;
X11->ptrXRRUpdateConfiguration = XRRUpdateConfiguration;
X11->ptrXRRRootToScreen = XRRRootToScreen;
X11->ptrXRRQueryExtension = XRRQueryExtension;
- X11->ptrXRRSizes = XRRSizes;
# endif
if (X11->ptrXRRQueryExtension
diff --git a/src/gui/kernel/qclipboard.h b/src/gui/kernel/qclipboard.h
index b55bdc6..019917e 100644
--- a/src/gui/kernel/qclipboard.h
+++ b/src/gui/kernel/qclipboard.h
@@ -112,6 +112,7 @@ protected:
friend class QBaseApplication;
friend class QDragManager;
friend class QMimeSource;
+ friend class QPlatformClipboard;
private:
Q_DISABLE_COPY(QClipboard)
diff --git a/src/gui/kernel/qcursor_x11.cpp b/src/gui/kernel/qcursor_x11.cpp
index d0ed98e..0bc7250 100644
--- a/src/gui/kernel/qcursor_x11.cpp
+++ b/src/gui/kernel/qcursor_x11.cpp
@@ -55,6 +55,9 @@
#endif // QT_NO_XCURSOR
#ifndef QT_NO_XFIXES
+#ifndef Status
+#define Status int
+#endif
# include <X11/extensions/Xfixes.h>
#endif // QT_NO_XFIXES
diff --git a/src/gui/kernel/qdesktopwidget_qpa.cpp b/src/gui/kernel/qdesktopwidget_qpa.cpp
index cff05f5..6257a8b 100644
--- a/src/gui/kernel/qdesktopwidget_qpa.cpp
+++ b/src/gui/kernel/qdesktopwidget_qpa.cpp
@@ -51,6 +51,8 @@ QT_USE_NAMESPACE
void QDesktopWidgetPrivate::updateScreenList()
{
+ Q_Q(QDesktopWidget);
+
QList<QPlatformScreen *> screenList = QApplicationPrivate::platformIntegration()->screens();
int targetLength = screenList.length();
int currentLength = screens.length();
@@ -72,19 +74,15 @@ void QDesktopWidgetPrivate::updateScreenList()
}
QRegion virtualGeometry;
- bool doVirtualGeometry = QApplicationPrivate::platformIntegration()->isVirtualDesktop();
// update the geometry of each screen widget
for (int i = 0; i < screens.length(); i++) {
QRect screenGeometry = screenList.at(i)->geometry();
screens.at(i)->setGeometry(screenGeometry);
- if (doVirtualGeometry)
- virtualGeometry += screenGeometry;
+ virtualGeometry += screenGeometry;
}
- virtualScreen.setGeometry(virtualGeometry.boundingRect());
- Q_Q(QDesktopWidget);
- q->setGeometry(virtualScreen.geometry());
+ q->setGeometry(virtualGeometry.boundingRect());
}
QDesktopWidget::QDesktopWidget()
@@ -118,8 +116,6 @@ int QDesktopWidget::numScreens() const
QWidget *QDesktopWidget::screen(int screen)
{
Q_D(QDesktopWidget);
- if (QApplicationPrivate::platformIntegration()->isVirtualDesktop())
- return &d->virtualScreen;
if (screen < 0 || screen >= d->screens.length())
return d->screens.at(0);
return d->screens.at(screen);
diff --git a/src/gui/kernel/qdesktopwidget_qpa_p.h b/src/gui/kernel/qdesktopwidget_qpa_p.h
index abee8a1..d6ed686 100644
--- a/src/gui/kernel/qdesktopwidget_qpa_p.h
+++ b/src/gui/kernel/qdesktopwidget_qpa_p.h
@@ -76,7 +76,6 @@ public:
void updateScreenList();
QList<QDesktopScreenWidget *> screens;
- QDesktopScreenWidget virtualScreen;
};
#endif // QDESKTOPWIDGET_QPA_P_H
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 277a5e8..807c385 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -4629,223 +4629,4 @@ const QGestureEventPrivate *QGestureEvent::d_func() const
#endif // QT_NO_GESTURES
-/*!
- \class QScrollPrepareEvent
- \since 4.8
- \ingroup events
-
- \brief The QScrollPrepareEvent class is send in preparation of a scrolling.
-
- The scroll prepare event is send before scrolling (usually by QScroller) is started.
- The object receiving this event should set viewportSize, maxContentPos and contentPos.
- It also should accept this event to indicate that scrolling should be started.
-
- It is not guaranteed that a QScrollEvent will be send after an acceepted
- QScrollPrepareEvent, e.g. in a case where the maximum content position is (0,0).
-
- \sa QScrollEvent, QScroller
-*/
-
-/*!
- Creates new QScrollPrepareEvent
- The \a startPos is the position of a touch or mouse event that started the scrolling.
-*/
-QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos)
- : QEvent(QEvent::ScrollPrepare)
-{
- d = reinterpret_cast<QEventPrivate *>(new QScrollPrepareEventPrivate());
- d_func()->startPos = startPos;
-}
-
-/*!
- Destroys QScrollEvent.
-*/
-QScrollPrepareEvent::~QScrollPrepareEvent()
-{
- delete reinterpret_cast<QScrollPrepareEventPrivate *>(d);
-}
-
-/*!
- Returns the position of the touch or mouse event that started the scrolling.
-*/
-QPointF QScrollPrepareEvent::startPos() const
-{
- return d_func()->startPos;
-}
-
-/*!
- Returns size of the area that is to be scrolled as set by setViewportSize
-
- \sa setViewportSize()
-*/
-QSizeF QScrollPrepareEvent::viewportSize() const
-{
- return d_func()->viewportSize;
-}
-
-/*!
- Returns the range of coordinates for the content as set by setContentPosRange().
-*/
-QRectF QScrollPrepareEvent::contentPosRange() const
-{
- return d_func()->contentPosRange;
-}
-
-/*!
- Returns the current position of the content as set by setContentPos.
-*/
-QPointF QScrollPrepareEvent::contentPos() const
-{
- return d_func()->contentPos;
-}
-
-
-/*!
- Sets the size of the area that is to be scrolled to \a size.
-
- \sa viewportSize()
-*/
-void QScrollPrepareEvent::setViewportSize(const QSizeF &size)
-{
- d_func()->viewportSize = size;
-}
-
-/*!
- Sets the range of content coordinates to \a rect.
-
- \sa contentPosRange()
-*/
-void QScrollPrepareEvent::setContentPosRange(const QRectF &rect)
-{
- d_func()->contentPosRange = rect;
-}
-
-/*!
- Sets the current content position to \a pos.
-
- \sa contentPos()
-*/
-void QScrollPrepareEvent::setContentPos(const QPointF &pos)
-{
- d_func()->contentPos = pos;
-}
-
-
-/*!
- \internal
-*/
-QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func()
-{
- return reinterpret_cast<QScrollPrepareEventPrivate *>(d);
-}
-
-/*!
- \internal
-*/
-const QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func() const
-{
- return reinterpret_cast<const QScrollPrepareEventPrivate *>(d);
-}
-
-/*!
- \class QScrollEvent
- \since 4.8
- \ingroup events
-
- \brief The QScrollEvent class is send when scrolling.
-
- The scroll event is send to indicate that the receiver should be scrolled.
- Usually the receiver should be something visual like QWidget or QGraphicsObject.
-
- Some care should be taken that no conflicting QScrollEvents are sent from two
- sources. Using QScroller::scrollTo is save however.
-
- \sa QScrollPrepareEvent, QScroller
-*/
-
-/*!
- \enum QScrollEvent::ScrollState
-
- This enum describes the states a scroll event can have.
-
- \value ScrollStarted Set for the first scroll event of a scroll activity.
-
- \value ScrollUpdated Set for all but the first and the last scroll event of a scroll activity.
-
- \value ScrollFinished Set for the last scroll event of a scroll activity.
-
- \sa QScrollEvent::scrollState()
-*/
-
-/*!
- Creates a new QScrollEvent
- \a contentPos is the new content position, \a overshootDistance is the
- new overshoot distance while \a scrollState indicates if this scroll
- event is the first one, the last one or some event in between.
-*/
-QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState)
- : QEvent(QEvent::Scroll)
-{
- d = reinterpret_cast<QEventPrivate *>(new QScrollEventPrivate());
- d_func()->contentPos = contentPos;
- d_func()->overshoot= overshootDistance;
- d_func()->state = scrollState;
-}
-
-/*!
- Destroys QScrollEvent.
-*/
-QScrollEvent::~QScrollEvent()
-{
- delete reinterpret_cast<QScrollEventPrivate *>(d);
-}
-
-/*!
- Returns the new scroll position.
-*/
-QPointF QScrollEvent::contentPos() const
-{
- return d_func()->contentPos;
-}
-
-/*!
- Returns the new overshoot distance.
- See QScroller for an explanation of the term overshoot.
-
- \sa QScroller
-*/
-QPointF QScrollEvent::overshootDistance() const
-{
- return d_func()->overshoot;
-}
-
-/*!
- Returns the current scroll state as a combination of ScrollStateFlag values.
- ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity.
- Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent.
- All other scroll events in between will have their state set to ScrollUpdated.
-
- A widget could for example revert selections when scrolling is started and stopped.
-*/
-QScrollEvent::ScrollState QScrollEvent::scrollState() const
-{
- return d_func()->state;
-}
-
-/*!
- \internal
-*/
-QScrollEventPrivate *QScrollEvent::d_func()
-{
- return reinterpret_cast<QScrollEventPrivate *>(d);
-}
-
-/*!
- \internal
-*/
-const QScrollEventPrivate *QScrollEvent::d_func() const
-{
- return reinterpret_cast<const QScrollEventPrivate *>(d);
-}
-
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 93c2bc5..830f037 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -889,52 +889,6 @@ private:
};
#endif // QT_NO_GESTURES
-class QScrollPrepareEventPrivate;
-class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent
-{
-public:
- QScrollPrepareEvent(const QPointF &startPos);
- ~QScrollPrepareEvent();
-
- QPointF startPos() const;
-
- QSizeF viewportSize() const;
- QRectF contentPosRange() const;
- QPointF contentPos() const;
-
- void setViewportSize(const QSizeF &size);
- void setContentPosRange(const QRectF &rect);
- void setContentPos(const QPointF &pos);
-
-private:
- QScrollPrepareEventPrivate *d_func();
- const QScrollPrepareEventPrivate *d_func() const;
-};
-
-
-class QScrollEventPrivate;
-class Q_GUI_EXPORT QScrollEvent : public QEvent
-{
-public:
- enum ScrollState
- {
- ScrollStarted,
- ScrollUpdated,
- ScrollFinished
- };
-
- QScrollEvent(const QPointF &contentPos, const QPointF &overshoot, ScrollState scrollState);
- ~QScrollEvent();
-
- QPointF contentPos() const;
- QPointF overshootDistance() const;
- ScrollState scrollState() const;
-
-private:
- QScrollEventPrivate *d_func();
- const QScrollEventPrivate *d_func() const;
-};
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index b79f372..36655e8 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -186,34 +186,6 @@ public:
#endif
};
-
-class QScrollPrepareEventPrivate
-{
-public:
- inline QScrollPrepareEventPrivate()
- : target(0)
- {
- }
-
- QObject* target;
- QPointF startPos;
- QSizeF viewportSize;
- QRectF contentPosRange;
- QPointF contentPos;
-};
-
-class QScrollEventPrivate
-{
-public:
- inline QScrollEventPrivate()
- {
- }
-
- QPointF contentPos;
- QPointF overshoot;
- QScrollEvent::ScrollState state;
-};
-
QT_END_NAMESPACE
#endif // QEVENT_P_H
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp
index 5359fb3..7aa7dffd 100644
--- a/src/gui/kernel/qgesturemanager.cpp
+++ b/src/gui/kernel/qgesturemanager.cpp
@@ -566,7 +566,6 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,
= w->d_func()->gestureContext.find(type);
if (it != w->d_func()->gestureContext.end()) {
// i.e. 'w' listens to gesture 'type'
- Qt::GestureFlags flags = it.value();
if (!(it.value() & Qt::DontStartGestureOnChildren) && w != widget) {
// conflicting gesture!
(*conflicts)[widget].append(gestures[widget]);
diff --git a/src/gui/kernel/qplatformclipboard_qpa.cpp b/src/gui/kernel/qplatformclipboard_qpa.cpp
index 957a4df..33d2afc 100644
--- a/src/gui/kernel/qplatformclipboard_qpa.cpp
+++ b/src/gui/kernel/qplatformclipboard_qpa.cpp
@@ -42,6 +42,8 @@
#ifndef QT_NO_CLIPBOARD
+#include <QtGui/private/qapplication_p.h>
+
QT_BEGIN_NAMESPACE
class QClipboardData
@@ -100,6 +102,11 @@ bool QPlatformClipboard::supportsMode(QClipboard::Mode mode) const
return mode == QClipboard::Clipboard;
}
+void QPlatformClipboard::emitChanged(QClipboard::Mode mode)
+{
+ QApplication::clipboard()->emitChanged(mode);
+}
+
QT_END_NAMESPACE
#endif //QT_NO_CLIPBOARD
diff --git a/src/gui/kernel/qplatformclipboard_qpa.h b/src/gui/kernel/qplatformclipboard_qpa.h
index 3381c06..5444a1f 100644
--- a/src/gui/kernel/qplatformclipboard_qpa.h
+++ b/src/gui/kernel/qplatformclipboard_qpa.h
@@ -62,6 +62,7 @@ public:
virtual const QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard ) const;
virtual void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard);
virtual bool supportsMode(QClipboard::Mode mode) const;
+ void emitChanged(QClipboard::Mode mode);
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp
index d559c53..8ff12eb 100644
--- a/src/gui/kernel/qplatformintegration_qpa.cpp
+++ b/src/gui/kernel/qplatformintegration_qpa.cpp
@@ -214,6 +214,7 @@ QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
bool QPlatformIntegration::hasCapability(Capability cap) const
{
+ Q_UNUSED(cap);
return false;
}
diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp
index 19bf7a9..f3654b6 100644
--- a/src/gui/kernel/qplatformwindow_qpa.cpp
+++ b/src/gui/kernel/qplatformwindow_qpa.cpp
@@ -150,7 +150,7 @@ void QPlatformWindow::setParent(const QPlatformWindow *parent)
/*!
Reimplement to set the window title to \a title
*/
-void QPlatformWindow::setWindowTitle(const QString &title) {}
+void QPlatformWindow::setWindowTitle(const QString &) {}
/*!
Reimplement to be able to let Qt rais windows to the top of the desktop
diff --git a/src/gui/kernel/qsessionmanager_qpa.cpp b/src/gui/kernel/qsessionmanager_qpa.cpp
index ef532d7..68685b4 100644
--- a/src/gui/kernel/qsessionmanager_qpa.cpp
+++ b/src/gui/kernel/qsessionmanager_qpa.cpp
@@ -42,6 +42,8 @@
#include <qsessionmanager.h>
#include <private/qobject_p.h>
+#include <qapplication.h>
+
#ifndef QT_NO_SESSIONMANAGER
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/gui/kernel/qsoftkeymanager_s60.cpp
index 79ed91a..71ae520 100644
--- a/src/gui/kernel/qsoftkeymanager_s60.cpp
+++ b/src/gui/kernel/qsoftkeymanager_s60.cpp
@@ -176,22 +176,27 @@ void QSoftKeyManagerPrivateS60::setNativeSoftkey(CEikButtonGroupContainer &cba,
QPoint QSoftKeyManagerPrivateS60::softkeyIconPosition(int position, QSize sourceSize, QSize targetSize)
{
QPoint iconPosition(0,0);
- switch( AknLayoutUtils::CbaLocation() )
- {
- case AknLayoutUtils::EAknCbaLocationBottom:
- // RSK must be moved to right, LSK in on correct position by default
- if (position == RSK_POSITION)
- iconPosition.setX(targetSize.width() - sourceSize.width());
- break;
- case AknLayoutUtils::EAknCbaLocationRight:
- case AknLayoutUtils::EAknCbaLocationLeft:
- // Already in correct position
- default:
- break;
- }
- // Align horizontally to center
- iconPosition.setY((targetSize.height() - sourceSize.height()) >> 1);
+ // Prior to S60 5.3 icons need to be properly positioned to buttons, but starting with 5.3
+ // positioning is done on Avkon side.
+ if (QSysInfo::s60Version() < QSysInfo::SV_S60_5_3) {
+ switch (AknLayoutUtils::CbaLocation())
+ {
+ case AknLayoutUtils::EAknCbaLocationBottom:
+ // RSK must be moved to right, LSK in on correct position by default
+ if (position == RSK_POSITION)
+ iconPosition.setX(targetSize.width() - sourceSize.width());
+ break;
+ case AknLayoutUtils::EAknCbaLocationRight:
+ case AknLayoutUtils::EAknCbaLocationLeft:
+ // Already in correct position
+ default:
+ break;
+ }
+
+ // Align horizontally to center
+ iconPosition.setY((targetSize.height() - sourceSize.height()) >> 1);
+ }
return iconPosition;
}
@@ -278,12 +283,6 @@ bool QSoftKeyManagerPrivateS60::setSoftkeyImage(CEikButtonGroupContainer *cba,
EikSoftkeyImage::SetImage(cba, *myimage, left); // Takes myimage ownership
cbaHasImage[position] = true;
ret = true;
- } else {
- // Restore softkey to text based
- if (cbaHasImage[position]) {
- EikSoftkeyImage::SetLabel(cba, left);
- cbaHasImage[position] = false;
- }
}
}
return ret;
@@ -294,7 +293,7 @@ bool QSoftKeyManagerPrivateS60::setSoftkey(CEikButtonGroupContainer &cba,
{
QAction *action = highestPrioritySoftkey(role);
if (action) {
- setSoftkeyImage(&cba, *action, position);
+ bool hasImage = setSoftkeyImage(&cba, *action, position);
QString text = softkeyText(*action);
TPtrC nativeText = qt_QString2TPtrC(text);
int command = S60_COMMAND_START + position;
@@ -303,6 +302,11 @@ bool QSoftKeyManagerPrivateS60::setSoftkey(CEikButtonGroupContainer &cba,
command = softKeyCommandActions.value(action);
#endif
setNativeSoftkey(cba, position, command, nativeText);
+ if (!hasImage && cbaHasImage[position]) {
+ EikSoftkeyImage::SetLabel(&cba, (position == LSK_POSITION));
+ cbaHasImage[position] = false;
+ }
+
const bool dimmed = !action->isEnabled() && !QSoftKeyManager::isForceEnabledInSofkeys(action);
cba.DimCommand(command, dimmed);
realSoftKeyActions.insert(command, action);
@@ -313,7 +317,18 @@ bool QSoftKeyManagerPrivateS60::setSoftkey(CEikButtonGroupContainer &cba,
bool QSoftKeyManagerPrivateS60::setLeftSoftkey(CEikButtonGroupContainer &cba)
{
- return setSoftkey(cba, QAction::PositiveSoftKey, LSK_POSITION);
+ if (!setSoftkey(cba, QAction::PositiveSoftKey, LSK_POSITION)) {
+ if (cbaHasImage[LSK_POSITION]) {
+ // Clear any residual icon if LSK has no action. A real softkey
+ // is needed for SetLabel command to work, so do a temporary dummy
+ setNativeSoftkey(cba, LSK_POSITION, EAknSoftkeyExit, KNullDesC);
+ EikSoftkeyImage::SetLabel(&cba, true);
+ setNativeSoftkey(cba, LSK_POSITION, EAknSoftkeyEmpty, KNullDesC);
+ cbaHasImage[LSK_POSITION] = false;
+ }
+ return false;
+ }
+ return true;
}
bool QSoftKeyManagerPrivateS60::setMiddleSoftkey(CEikButtonGroupContainer &cba)
@@ -332,16 +347,26 @@ bool QSoftKeyManagerPrivateS60::setRightSoftkey(CEikButtonGroupContainer &cba)
if (windowType != Qt::Dialog && windowType != Qt::Popup) {
QString text(QSoftKeyManager::tr("Exit"));
TPtrC nativeText = qt_QString2TPtrC(text);
+ setNativeSoftkey(cba, RSK_POSITION, EAknSoftkeyExit, nativeText);
if (cbaHasImage[RSK_POSITION]) {
EikSoftkeyImage::SetLabel(&cba, false);
cbaHasImage[RSK_POSITION] = false;
}
- setNativeSoftkey(cba, RSK_POSITION, EAknSoftkeyExit, nativeText);
cba.DimCommand(EAknSoftkeyExit, false);
return true;
+ } else {
+ if (cbaHasImage[RSK_POSITION]) {
+ // Clear any residual icon if RSK has no action. A real softkey
+ // is needed for SetLabel command to work, so do a temporary dummy
+ setNativeSoftkey(cba, RSK_POSITION, EAknSoftkeyExit, KNullDesC);
+ EikSoftkeyImage::SetLabel(&cba, false);
+ setNativeSoftkey(cba, RSK_POSITION, EAknSoftkeyEmpty, KNullDesC);
+ cbaHasImage[RSK_POSITION] = false;
+ }
+ return false;
}
}
- return false;
+ return true;
}
void QSoftKeyManagerPrivateS60::setSoftkeys(CEikButtonGroupContainer &cba)
diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h
index 8aba53a..0023649 100644
--- a/src/gui/kernel/qt_s60_p.h
+++ b/src/gui/kernel/qt_s60_p.h
@@ -97,6 +97,10 @@ static const int qt_symbian_max_screens = 4;
//this macro exists because EColor16MAP enum value doesn't exist in Symbian OS 9.2
#define Q_SYMBIAN_ECOLOR16MAP TDisplayMode(13)
+class QSymbianTypeFaceExtras;
+typedef QHash<QString, const QSymbianTypeFaceExtras *> QSymbianTypeFaceExtrasHash;
+typedef void (*QThreadLocalReleaseFunc)();
+
class Q_AUTOTEST_EXPORT QS60ThreadLocalData
{
public:
@@ -105,6 +109,8 @@ public:
bool usingCONEinstances;
RWsSession wsSession;
CWsScreenDevice *screenDevice;
+ QSymbianTypeFaceExtrasHash fontData;
+ QVector<QThreadLocalReleaseFunc> releaseFuncs;
};
class QS60Data
@@ -153,6 +159,8 @@ public:
int menuBeingConstructed : 1;
int orientationSet : 1;
int partial_keyboard : 1;
+ int partial_keyboardAutoTranslation : 1;
+ int partialKeyboardOpen : 1;
QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type
QPointer<QWidget> splitViewLastWidget;
@@ -175,6 +183,8 @@ public:
inline CWsScreenDevice* screenDevice(const QWidget *widget);
inline CWsScreenDevice* screenDevice(int screenNumber);
static inline int screenNumberForWidget(const QWidget *widget);
+ inline QSymbianTypeFaceExtrasHash& fontData();
+ inline void addThreadLocalReleaseFunc(QThreadLocalReleaseFunc func);
static inline CCoeAppUi* appUi();
static inline CEikMenuBar* menuBar();
#ifdef Q_WS_S60
@@ -291,6 +301,7 @@ private:
void translateAdvancedPointerEvent(const TAdvancedPointerEvent *event);
#endif
bool isSplitViewWidget(QWidget *widget);
+ bool hasFocusedAndVisibleChild(QWidget *parentWidget);
public:
void handleClientAreaChange();
@@ -340,6 +351,8 @@ inline QS60Data::QS60Data()
menuBeingConstructed(0),
orientationSet(0),
partial_keyboard(0),
+ partial_keyboardAutoTranslation(1),
+ partialKeyboardOpen(0),
s60ApplicationFactory(0)
#ifdef Q_OS_SYMBIAN
,s60InstalledTrapHandler(0)
@@ -470,6 +483,24 @@ inline int QS60Data::screenNumberForWidget(const QWidget *widget)
return qt_widget_private(const_cast<QWidget *>(w))->symbianScreenNumber;
}
+inline QSymbianTypeFaceExtrasHash& QS60Data::fontData()
+{
+ if (!tls.hasLocalData()) {
+ tls.setLocalData(new QS60ThreadLocalData);
+ }
+ return tls.localData()->fontData;
+}
+
+inline void QS60Data::addThreadLocalReleaseFunc(QThreadLocalReleaseFunc func)
+{
+ if (!tls.hasLocalData()) {
+ tls.setLocalData(new QS60ThreadLocalData);
+ }
+ QS60ThreadLocalData *data = tls.localData();
+ if (!data->releaseFuncs.contains(func))
+ data->releaseFuncs.append(func);
+}
+
inline CCoeAppUi* QS60Data::appUi()
{
return CCoeEnv::Static()-> AppUi();
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index 69079cf..8ab129c 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -226,7 +226,6 @@ typedef void (*PtrXRRSelectInput)(Display *, Window, int);
typedef int (*PtrXRRUpdateConfiguration)(XEvent *);
typedef int (*PtrXRRRootToScreen)(Display *, Window);
typedef Bool (*PtrXRRQueryExtension)(Display *, int *, int *);
-typedef XRRScreenSize *(*PtrXRRSizes)(Display *, int, int *);
#endif // QT_NO_XRANDR
#ifndef QT_NO_XINPUT
@@ -711,7 +710,6 @@ struct QX11Data
PtrXRRUpdateConfiguration ptrXRRUpdateConfiguration;
PtrXRRRootToScreen ptrXRRRootToScreen;
PtrXRRQueryExtension ptrXRRQueryExtension;
- PtrXRRSizes ptrXRRSizes;
#endif // QT_NO_XRANDR
};
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index c5ea239..9556169 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -299,6 +299,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
#ifndef QT_NO_IM
, inheritsInputMethodHints(0)
#endif
+ , inSetParent(0)
#if defined(Q_WS_X11)
, picture(0)
#elif defined(Q_WS_WIN)
@@ -612,7 +613,7 @@ void QWidget::setAutoFillBackground(bool enabled)
\brief The QWidget class is the base class of all user interface objects.
\ingroup basicwidgets
-
+
The widget is the atom of the user interface: it receives mouse, keyboard
and other events from the window system, and paints a representation of
itself on the screen. Every widget is rectangular, and they are sorted in a
@@ -1389,16 +1390,6 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
QApplication::postEvent(q, new QEvent(QEvent::PolishRequest));
extraPaintEngine = 0;
-
-#ifdef QT_MAC_USE_COCOA
- // If we add a child to the unified toolbar, we have to redirect the painting.
- if (parentWidget && parentWidget->d_func() && parentWidget->d_func()->isInUnifiedToolbar) {
- if (parentWidget->d_func()->unifiedSurface) {
- QWidget *toolbar = parentWidget->d_func()->toolbar_ancestor;
- parentWidget->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset);
- }
- }
-#endif // QT_MAC_USE_COCOA
}
@@ -1588,6 +1579,7 @@ QWidget::~QWidget()
// delete layout while we still are a valid widget
delete d->layout;
+ d->layout = 0;
// Remove myself from focus list
Q_ASSERT(d->focus_next->d_func()->focus_prev == this);
@@ -2598,6 +2590,22 @@ WId QWidget::effectiveWinId() const
if (id || !testAttribute(Qt::WA_WState_Created))
return id;
QWidget *realParent = nativeParentWidget();
+ if (!realParent && d_func()->inSetParent) {
+ // In transitional state. This is really just a workaround. The real problem
+ // is that QWidgetPrivate::setParent_sys (platform specific code) first sets
+ // the window id to 0 (setWinId(0)) before it sets the Qt::WA_WState_Created
+ // attribute to false. The correct way is to do it the other way around, and
+ // in that case the Qt::WA_WState_Created logic above will kick in and
+ // return 0 whenever the widget is in a transitional state. However, changing
+ // the original logic for all platforms is far more intrusive and might
+ // break existing applications.
+ // Note: The widget can only be in a transitional state when changing its
+ // parent -- everything else is an internal error -- hence explicitly checking
+ // against 'inSetParent' rather than doing an unconditional return whenever
+ // 'realParent' is 0 (which may cause strange artifacts and headache later).
+ return 0;
+ }
+ // This widget *must* have a native parent widget.
Q_ASSERT(realParent);
Q_ASSERT(realParent->internalWinId());
return realParent->internalWinId();
@@ -10110,6 +10118,7 @@ void QWidget::setParent(QWidget *parent)
void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
{
Q_D(QWidget);
+ d->inSetParent = true;
bool resized = testAttribute(Qt::WA_Resized);
bool wasCreated = testAttribute(Qt::WA_WState_Created);
QWidget *oldtlw = window();
@@ -10270,6 +10279,8 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
ancestorProxy->d_func()->embedSubWindow(this);
}
#endif
+
+ d->inSetParent = false;
}
/*!
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 354f05b..468de22 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -2733,7 +2733,7 @@ QWidget::macCGHandle() const
return handle();
}
-void qt_mac_repaintParentUnderAlienWidget(QWidget *alienWidget)
+void qt_mac_updateParentUnderAlienWidget(QWidget *alienWidget)
{
QWidget *nativeParent = alienWidget->nativeParentWidget();
if (!nativeParent)
@@ -2741,7 +2741,7 @@ void qt_mac_repaintParentUnderAlienWidget(QWidget *alienWidget)
QPoint globalPos = alienWidget->mapToGlobal(QPoint(0, 0));
QRect dirtyRect = QRect(nativeParent->mapFromGlobal(globalPos), alienWidget->size());
- nativeParent->repaint(dirtyRect);
+ nativeParent->update(dirtyRect);
}
void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
@@ -2752,7 +2752,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
if (!isWindow() && parentWidget())
parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
if (!internalWinId())
- qt_mac_repaintParentUnderAlienWidget(this);
+ qt_mac_updateParentUnderAlienWidget(this);
d->deactivateWidgetCleanup();
qt_mac_event_release(this);
if(testAttribute(Qt::WA_WState_Created)) {
@@ -3032,6 +3032,16 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
q->setAttribute(Qt::WA_WState_Hidden);
q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
+#ifdef QT_MAC_USE_COCOA
+ // If we add a child to the unified toolbar, we have to redirect the painting.
+ if (parent && parent->d_func() && parent->d_func()->isInUnifiedToolbar) {
+ if (parent->d_func()->unifiedSurface) {
+ QWidget *toolbar = parent->d_func()->toolbar_ancestor;
+ parent->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset);
+ }
+ }
+#endif // QT_MAC_USE_COCOA
+
if (wasCreated) {
transferChildren();
#ifndef QT_MAC_USE_COCOA
@@ -3526,8 +3536,8 @@ void QWidgetPrivate::show_sys()
// INVARIANT: q is native. Just show the view:
[view setHidden:NO];
} else {
- // INVARIANT: q is alien. Repaint q instead:
- q->repaint();
+ // INVARIANT: q is alien. Update q instead:
+ q->update();
}
#endif
}
@@ -3683,7 +3693,7 @@ void QWidgetPrivate::hide_sys()
[view setHidden:YES];
} else {
// INVARIANT: q is alien. Repaint where q is placed instead:
- qt_mac_repaintParentUnderAlienWidget(q);
+ qt_mac_updateParentUnderAlienWidget(q);
}
#endif
}
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 919f8bc..acf1860 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -232,6 +232,7 @@ struct QTLWExtra {
#elif defined(Q_OS_SYMBIAN)
uint inExpose : 1; // Prevents drawing recursion
uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency
+ uint forcedToRaster : 1;
#elif defined(Q_WS_QPA)
QPlatformWindow *platformWindow;
QPlatformWindowFormat platformWindowFormat;
@@ -770,6 +771,7 @@ public:
#ifndef QT_NO_IM
uint inheritsInputMethodHints : 1;
#endif
+ uint inSetParent : 1;
// *************************** Platform specific ************************************
#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index e28a75a..c011cf1 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -235,11 +235,22 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
QSize oldSize(q->size());
QRect oldGeom(data.crect);
+ bool checkExtra = true;
+ if (q->isWindow() && (data.window_state & (Qt::WindowFullScreen | Qt::WindowMaximized))) {
+ // Do not allow fullscreen/maximized windows to expand beyond client rect
+ TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
+ w = qMin(w, r.Width());
+ h = qMin(h, r.Height());
+
+ if (w == r.Width() && h == r.Height())
+ checkExtra = false;
+ }
+
// Lose maximized status if deliberate resize
if (w != oldSize.width() || h != oldSize.height())
data.window_state &= ~Qt::WindowMaximized;
- if (extra) { // any size restrictions?
+ if (checkExtra && extra) { // any size restrictions?
w = qMin(w,extra->maxw);
h = qMin(h,extra->maxh);
w = qMax(w,extra->minw);
@@ -567,6 +578,11 @@ void QWidgetPrivate::show_sys()
if (isFullscreen) {
const bool cbaVisible = S60->buttonGroupContainer() && S60->buttonGroupContainer()->IsVisible();
S60->setStatusPaneAndButtonGroupVisibility(false, cbaVisible);
+ if (cbaVisible) {
+ // Fix window dimensions as without screen furniture they will have
+ // defaulted to full screen dimensions initially.
+ id->handleClientAreaChange();
+ }
}
}
}
@@ -781,7 +797,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
adjustFlags(data.window_flags, q);
// keep compatibility with previous versions, we need to preserve the created state
// (but we recreate the winId for the widget being reparented, again for compatibility)
- if (wasCreated || (!q->isWindow() && parent->testAttribute(Qt::WA_WState_Created)))
+ if (wasCreated || (!q->isWindow() && parent && parent->testAttribute(Qt::WA_WState_Created)))
createWinId();
if (q->isWindow() || (!parent || parent->isVisible()) || explicitlyHidden)
q->setAttribute(Qt::WA_WState_Hidden);
@@ -824,7 +840,8 @@ void QWidgetPrivate::s60UpdateIsOpaque()
RWindow *const window = static_cast<RWindow *>(q->effectiveWinId()->DrawableWindow());
#ifdef Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE
- if (QApplicationPrivate::instance()->useTranslucentEGLSurfaces) {
+ if (QApplicationPrivate::instance()->useTranslucentEGLSurfaces
+ && !extra->topextra->forcedToRaster) {
window->SetSurfaceTransparency(!isOpaque);
extra->topextra->nativeWindowTransparencyEnabled = !isOpaque;
return;
@@ -1008,6 +1025,7 @@ void QWidgetPrivate::createTLSysExtra()
{
extra->topextra->inExpose = 0;
extra->topextra->nativeWindowTransparencyEnabled = 0;
+ extra->topextra->forcedToRaster = 0;
}
void QWidgetPrivate::deleteTLSysExtra()
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index 5ece7d6..3eec5c7 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -486,8 +486,6 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
bool topLevel = (flags & Qt::Window);
bool popup = (type == Qt::Popup);
- bool dialog = (type == Qt::Dialog
- || type == Qt::Sheet);
bool desktop = (type == Qt::Desktop);
bool tool = (type == Qt::Tool || type == Qt::SplashScreen
|| type == Qt::ToolTip || type == Qt::Drawer);
@@ -553,7 +551,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
int sh = DisplayHeight(dpy,scr);
if (desktop) { // desktop widget
- dialog = popup = false; // force these flags off
+ popup = false; // force these flags off
data.crect.setRect(0, 0, sw, sh);
} else if (topLevel && !q->testAttribute(Qt::WA_Resized)) {
QDesktopWidget *desktopWidget = qApp->desktop();
@@ -954,8 +952,13 @@ static void qt_x11_recreateWidget(QWidget *widget)
// recreate their GL context, which in turn causes them to choose
// their visual again. Now that WA_TranslucentBackground is set,
// QGLContext::chooseVisual will select an ARGB visual.
- QEvent e(QEvent::ParentChange);
- QApplication::sendEvent(widget, &e);
+
+ // QGLWidget expects a ParentAboutToChange to be sent first
+ QEvent aboutToChangeEvent(QEvent::ParentAboutToChange);
+ QApplication::sendEvent(widget, &aboutToChangeEvent);
+
+ QEvent parentChangeEvent(QEvent::ParentChange);
+ QApplication::sendEvent(widget, &parentChangeEvent);
} else {
// For regular widgets, reparent them with their parent which
// also triggers a recreation of the native window
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 65e7af4..f1496b1 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -9,6 +9,7 @@ HEADERS += \
painting/qdrawutil.h \
painting/qemulationpaintengine_p.h \
painting/qgraphicssystem_p.h \
+ painting/qgraphicssystemex_p.h \
painting/qmatrix.h \
painting/qmemrotate_p.h \
painting/qoutlinemapper_p.h \
@@ -249,8 +250,10 @@ embedded {
symbian {
HEADERS += painting/qwindowsurface_s60_p.h \
- painting/qdrawhelper_arm_simd_p.h
- SOURCES += painting/qwindowsurface_s60.cpp
+ painting/qdrawhelper_arm_simd_p.h \
+ painting/qgraphicssystemex_symbian_p.h
+ SOURCES += painting/qwindowsurface_s60.cpp \
+ painting/qgraphicssystemex_symbian.cpp
armccIfdefBlock = \
"$${LITERAL_HASH}if defined(ARMV6)" \
"MACRO QT_HAVE_ARM_SIMD" \
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index bf5764a..3ff7eb8 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -840,6 +840,22 @@ const QGradient *QBrush::gradient() const
return 0;
}
+Q_GUI_EXPORT bool qt_isExtendedRadialGradient(const QBrush &brush)
+{
+ if (brush.style() == Qt::RadialGradientPattern) {
+ const QGradient *g = brush.gradient();
+ const QRadialGradient *rg = static_cast<const QRadialGradient *>(g);
+
+ if (!qFuzzyIsNull(rg->focalRadius()))
+ return true;
+
+ QPointF delta = rg->focalPoint() - rg->center();
+ if (delta.x() * delta.x() + delta.y() * delta.y() > rg->radius() * rg->radius())
+ return true;
+ }
+
+ return false;
+}
/*!
Returns true if the brush is fully opaque otherwise false. A brush
@@ -849,6 +865,7 @@ const QGradient *QBrush::gradient() const
\i The alpha component of the color() is 255.
\i Its texture() does not have an alpha channel and is not a QBitmap.
\i The colors in the gradient() all have an alpha component that is 255.
+ \i It is an extended radial gradient.
\endlist
*/
@@ -860,6 +877,9 @@ bool QBrush::isOpaque() const
if (d->style == Qt::SolidPattern)
return opaqueColor;
+ if (qt_isExtendedRadialGradient(*this))
+ return false;
+
if (d->style == Qt::LinearGradientPattern
|| d->style == Qt::RadialGradientPattern
|| d->style == Qt::ConicalGradientPattern) {
@@ -1209,8 +1229,10 @@ QDataStream &operator>>(QDataStream &s, QBrush &b)
\list
\o \e Linear gradients interpolate colors between start and end points.
- \o \e Radial gradients interpolate colors between a focal point and end
- points on a circle surrounding it.
+ \o \e Simple radial gradients interpolate colors between a focal point
+ and end points on a circle surrounding it.
+ \o \e Extended radial gradients interpolate colors between a center and
+ a focal circle.
\o \e Conical gradients interpolate colors around a center point.
\endlist
@@ -1506,8 +1528,6 @@ void QGradient::setInterpolationMode(InterpolationMode mode)
dummy = p;
}
-#undef Q_DUMMY_ACCESSOR
-
/*!
\fn bool QGradient::operator!=(const QGradient &gradient) const
\since 4.2
@@ -1541,7 +1561,7 @@ bool QGradient::operator==(const QGradient &gradient) const
|| m_data.radial.cy != gradient.m_data.radial.cy
|| m_data.radial.fx != gradient.m_data.radial.fx
|| m_data.radial.fy != gradient.m_data.radial.fy
- || m_data.radial.radius != gradient.m_data.radial.radius)
+ || m_data.radial.cradius != gradient.m_data.radial.cradius)
return false;
} else { // m_type == ConicalGradient
if (m_data.conical.cx != gradient.m_data.conical.cx
@@ -1747,10 +1767,17 @@ void QLinearGradient::setFinalStop(const QPointF &stop)
\brief The QRadialGradient class is used in combination with QBrush to
specify a radial gradient brush.
- Radial gradients interpolate colors between a focal point and end
- points on a circle surrounding it. Outside the end points the
- gradient is either padded, reflected or repeated depending on the
- currently set \l {QGradient::Spread}{spread} method:
+ Qt supports both simple and extended radial gradients.
+
+ Simple radial gradients interpolate colors between a focal point and end
+ points on a circle surrounding it. Extended radial gradients interpolate
+ colors between a focal circle and a center circle. Points outside the cone
+ defined by the two circles will be transparent. For simple radial gradients
+ the focal point is adjusted to lie inside the center circle, whereas the
+ focal point can have any position in an extended radial gradient.
+
+ Outside the end points the gradient is either padded, reflected or repeated
+ depending on the currently set \l {QGradient::Spread}{spread} method:
\table
\row
@@ -1795,9 +1822,14 @@ static QPointF qt_radial_gradient_adapt_focal_point(const QPointF &center,
}
/*!
- Constructs a radial gradient with the given \a center, \a
+ Constructs a simple radial gradient with the given \a center, \a
radius and \a focalPoint.
+ \note If the given focal point is outside the circle defined by the
+ center (\a cx, \a cy) and the \a radius it will be re-adjusted to
+ the intersection between the line from the center to the focal point
+ and the circle.
+
\sa QGradient::setColorAt(), QGradient::setStops()
*/
@@ -1807,7 +1839,7 @@ QRadialGradient::QRadialGradient(const QPointF &center, qreal radius, const QPoi
m_spread = PadSpread;
m_data.radial.cx = center.x();
m_data.radial.cy = center.y();
- m_data.radial.radius = radius;
+ m_data.radial.cradius = radius;
QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(center, radius, focalPoint);
m_data.radial.fx = adapted_focal.x();
@@ -1815,7 +1847,7 @@ QRadialGradient::QRadialGradient(const QPointF &center, qreal radius, const QPoi
}
/*!
- Constructs a radial gradient with the given \a center, \a
+ Constructs a simple radial gradient with the given \a center, \a
radius and the focal point in the circle center.
\sa QGradient::setColorAt(), QGradient::setStops()
@@ -1826,16 +1858,21 @@ QRadialGradient::QRadialGradient(const QPointF &center, qreal radius)
m_spread = PadSpread;
m_data.radial.cx = center.x();
m_data.radial.cy = center.y();
- m_data.radial.radius = radius;
+ m_data.radial.cradius = radius;
m_data.radial.fx = center.x();
m_data.radial.fy = center.y();
}
/*!
- Constructs a radial gradient with the given center (\a cx, \a cy),
+ Constructs a simple radial gradient with the given center (\a cx, \a cy),
\a radius and focal point (\a fx, \a fy).
+ \note If the given focal point is outside the circle defined by the
+ center (\a cx, \a cy) and the \a radius it will be re-adjusted to
+ the intersection between the line from the center to the focal point
+ and the circle.
+
\sa QGradient::setColorAt(), QGradient::setStops()
*/
@@ -1845,7 +1882,7 @@ QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius, qreal fx, qre
m_spread = PadSpread;
m_data.radial.cx = cx;
m_data.radial.cy = cy;
- m_data.radial.radius = radius;
+ m_data.radial.cradius = radius;
QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(QPointF(cx, cy),
radius,
@@ -1856,7 +1893,7 @@ QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius, qreal fx, qre
}
/*!
- Constructs a radial gradient with the center at (\a cx, \a cy) and the
+ Constructs a simple radial gradient with the center at (\a cx, \a cy) and the
specified \a radius. The focal point lies at the center of the circle.
\sa QGradient::setColorAt(), QGradient::setStops()
@@ -1867,14 +1904,14 @@ QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius)
m_spread = PadSpread;
m_data.radial.cx = cx;
m_data.radial.cy = cy;
- m_data.radial.radius = radius;
+ m_data.radial.cradius = radius;
m_data.radial.fx = cx;
m_data.radial.fy = cy;
}
/*!
- Constructs a radial gradient with the center and focal point at
+ Constructs a simple radial gradient with the center and focal point at
(0, 0) with a radius of 1.
*/
QRadialGradient::QRadialGradient()
@@ -1883,11 +1920,51 @@ QRadialGradient::QRadialGradient()
m_spread = PadSpread;
m_data.radial.cx = 0;
m_data.radial.cy = 0;
- m_data.radial.radius = 1;
+ m_data.radial.cradius = 1;
m_data.radial.fx = 0;
m_data.radial.fy = 0;
}
+/*!
+ \since 4.8
+
+ Constructs an extended radial gradient with the given \a center, \a
+ centerRadius, \a focalPoint, and \a focalRadius.
+*/
+QRadialGradient::QRadialGradient(const QPointF &center, qreal centerRadius, const QPointF &focalPoint, qreal focalRadius)
+{
+ m_type = RadialGradient;
+ m_spread = PadSpread;
+ m_data.radial.cx = center.x();
+ m_data.radial.cy = center.y();
+ m_data.radial.cradius = centerRadius;
+
+ m_data.radial.fx = focalPoint.x();
+ m_data.radial.fy = focalPoint.y();
+ setFocalRadius(focalRadius);
+}
+
+/*!
+ \since 4.8
+
+ Constructs an extended radial gradient with the given \a center, \a
+ centerRadius, \a focalPoint, and \a focalRadius.
+ Constructs a radial gradient with the given center (\a cx, \a cy),
+ center radius \a centerRadius, focal point (\a fx, \a fy), and
+ focal radius \a focalRadius.
+*/
+QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal centerRadius, qreal fx, qreal fy, qreal focalRadius)
+{
+ m_type = RadialGradient;
+ m_spread = PadSpread;
+ m_data.radial.cx = cx;
+ m_data.radial.cy = cy;
+ m_data.radial.cradius = centerRadius;
+
+ m_data.radial.fx = fx;
+ m_data.radial.fy = fy;
+ setFocalRadius(focalRadius);
+}
/*!
Returns the center of this radial gradient in logical coordinates.
@@ -1932,13 +2009,15 @@ void QRadialGradient::setCenter(const QPointF &center)
/*!
Returns the radius of this radial gradient in logical coordinates.
+ Equivalent to centerRadius()
+
\sa QGradient::stops()
*/
qreal QRadialGradient::radius() const
{
Q_ASSERT(m_type == RadialGradient);
- return m_data.radial.radius;
+ return m_data.radial.cradius;
}
@@ -1947,13 +2026,81 @@ qreal QRadialGradient::radius() const
Sets the radius of this radial gradient in logical coordinates
to \a radius
+
+ Equivalent to setCenterRadius()
*/
void QRadialGradient::setRadius(qreal radius)
{
Q_ASSERT(m_type == RadialGradient);
- m_data.radial.radius = radius;
+ m_data.radial.cradius = radius;
+}
+
+/*!
+ \since 4.8
+
+ Returns the center radius of this radial gradient in logical
+ coordinates.
+
+ \sa QGradient::stops()
+*/
+qreal QRadialGradient::centerRadius() const
+{
+ Q_ASSERT(m_type == RadialGradient);
+ return m_data.radial.cradius;
+}
+
+/*
+ \since 4.8
+
+ Sets the center radius of this radial gradient in logical coordinates
+ to \a radius
+*/
+void QRadialGradient::setCenterRadius(qreal radius)
+{
+ Q_ASSERT(m_type == RadialGradient);
+ m_data.radial.cradius = radius;
+}
+
+/*!
+ \since 4.8
+
+ Returns the focal radius of this radial gradient in logical
+ coordinates.
+
+ \sa QGradient::stops()
+*/
+qreal QRadialGradient::focalRadius() const
+{
+ Q_ASSERT(m_type == RadialGradient);
+ Q_DUMMY_ACCESSOR
+
+ // mask away low three bits
+ union { float f; quint32 i; } u;
+ u.i = i & ~0x07;
+ return u.f;
}
+/*
+ \since 4.8
+
+ Sets the focal radius of this radial gradient in logical coordinates
+ to \a radius
+*/
+void QRadialGradient::setFocalRadius(qreal radius)
+{
+ Q_ASSERT(m_type == RadialGradient);
+ Q_DUMMY_ACCESSOR
+
+ // Since there's no QGradientData, we only have the dummy void * to
+ // store additional data in. The three lowest bits are already
+ // taken, thus we cut the three lowest bits from the significand
+ // and store the radius as a float.
+ union { float f; quint32 i; } u;
+ u.f = float(radius);
+ // add 0x04 to round up when we drop the three lowest bits
+ i |= (u.i + 0x04) & ~0x07;
+ dummy = p;
+}
/*!
Returns the focal point of this radial gradient in logical
@@ -2193,4 +2340,6 @@ void QConicalGradient::setAngle(qreal angle)
\sa setTransform()
*/
+#undef Q_DUMMY_ACCESSOR
+
QT_END_NAMESPACE
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index 8b31319..d914c8c 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -255,6 +255,7 @@ private:
friend class QLinearGradient;
friend class QRadialGradient;
friend class QConicalGradient;
+ friend class QBrush;
Type m_type;
Spread m_spread;
@@ -264,7 +265,7 @@ private:
qreal x1, y1, x2, y2;
} linear;
struct {
- qreal cx, cy, fx, fy, radius;
+ qreal cx, cy, fx, fy, cradius;
} radial;
struct {
qreal cx, cy, angle;
@@ -303,6 +304,9 @@ public:
QRadialGradient(const QPointF &center, qreal radius);
QRadialGradient(qreal cx, qreal cy, qreal radius);
+ QRadialGradient(const QPointF &center, qreal centerRadius, const QPointF &focalPoint, qreal focalRadius);
+ QRadialGradient(qreal cx, qreal cy, qreal centerRadius, qreal fx, qreal fy, qreal focalRadius);
+
QPointF center() const;
void setCenter(const QPointF &center);
inline void setCenter(qreal x, qreal y) { setCenter(QPointF(x, y)); }
@@ -313,6 +317,12 @@ public:
qreal radius() const;
void setRadius(qreal radius);
+
+ qreal centerRadius() const;
+ void setCenterRadius(qreal radius);
+
+ qreal focalRadius() const;
+ void setFocalRadius(qreal radius);
};
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index ff6c24e..cd87d21 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -532,8 +532,7 @@ QString QColor::name() const
void QColor::setNamedColor(const QString &name)
{
- if (!setColorFromString(name))
- qWarning("QColor::setNamedColor: Unknown color name '%s'", name.toLatin1().constData());
+ setColorFromString(name);
}
/*!
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 5e75e4a..360292c 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -75,43 +75,9 @@ enum {
fixed_scale = 1 << 16,
half_point = 1 << 15
};
-static const int buffer_size = 2048;
-
-struct LinearGradientValues
-{
- qreal dx;
- qreal dy;
- qreal l;
- qreal off;
-};
-
-struct RadialGradientValues
-{
- qreal dx;
- qreal dy;
- qreal a;
-};
-
-struct Operator;
-typedef uint* (QT_FASTCALL *DestFetchProc)(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length);
-typedef void (QT_FASTCALL *DestStoreProc)(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length);
-typedef const uint* (QT_FASTCALL *SourceFetchProc)(uint *buffer, const Operator *o, const QSpanData *data, int y, int x, int length);
-
-struct Operator
-{
- QPainter::CompositionMode mode;
- DestFetchProc dest_fetch;
- DestStoreProc dest_store;
- SourceFetchProc src_fetch;
- CompositionFunctionSolid funcSolid;
- CompositionFunction func;
- union {
- LinearGradientValues linear;
- RadialGradientValues radial;
-// TextureValues texture;
- };
-};
+// must be multiple of 4 for easier SIMD implementations
+static const int buffer_size = 2048;
/*
Destination fetch. This is simple as we don't have to do bounds checks or
@@ -1346,64 +1312,13 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
},
};
-
-static inline uint qt_gradient_pixel(const QGradientData *data, qreal pos)
-{
- int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + qreal(0.5));
-
- // calculate the actual offset.
- if (ipos < 0 || ipos >= GRADIENT_STOPTABLE_SIZE) {
- if (data->spread == QGradient::RepeatSpread) {
- ipos = ipos % GRADIENT_STOPTABLE_SIZE;
- ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos;
-
- } else if (data->spread == QGradient::ReflectSpread) {
- const int limit = GRADIENT_STOPTABLE_SIZE * 2 - 1;
- ipos = ipos % limit;
- ipos = ipos < 0 ? limit + ipos : ipos;
- ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - ipos : ipos;
-
- } else {
- if (ipos < 0) ipos = 0;
- else if (ipos >= GRADIENT_STOPTABLE_SIZE) ipos = GRADIENT_STOPTABLE_SIZE-1;
- }
- }
-
- Q_ASSERT(ipos >= 0);
- Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE);
-
- return data->colorTable[ipos];
-}
-
#define FIXPT_BITS 8
#define FIXPT_SIZE (1<<FIXPT_BITS)
static uint qt_gradient_pixel_fixed(const QGradientData *data, int fixed_pos)
{
int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS;
-
- // calculate the actual offset.
- if (ipos < 0 || ipos >= GRADIENT_STOPTABLE_SIZE) {
- if (data->spread == QGradient::RepeatSpread) {
- ipos = ipos % GRADIENT_STOPTABLE_SIZE;
- ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos;
-
- } else if (data->spread == QGradient::ReflectSpread) {
- const int limit = GRADIENT_STOPTABLE_SIZE * 2 - 1;
- ipos = ipos % limit;
- ipos = ipos < 0 ? limit + ipos : ipos;
- ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - ipos : ipos;
-
- } else {
- if (ipos < 0) ipos = 0;
- else if (ipos >= GRADIENT_STOPTABLE_SIZE) ipos = GRADIENT_STOPTABLE_SIZE-1;
- }
- }
-
- Q_ASSERT(ipos >= 0);
- Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE);
-
- return data->colorTable[ipos];
+ return data->colorTable[qt_gradient_clamp(data, ipos)];
}
static void QT_FASTCALL getLinearGradientValues(LinearGradientValues *v, const QSpanData *data)
@@ -1419,8 +1334,8 @@ static void QT_FASTCALL getLinearGradientValues(LinearGradientValues *v, const Q
}
}
-static const uint * QT_FASTCALL fetchLinearGradient(uint *buffer, const Operator *op, const QSpanData *data,
- int y, int x, int length)
+static const uint * QT_FASTCALL qt_fetch_linear_gradient(uint *buffer, const Operator *op, const QSpanData *data,
+ int y, int x, int length)
{
const uint *b = buffer;
qreal t, inc;
@@ -1487,110 +1402,65 @@ static const uint * QT_FASTCALL fetchLinearGradient(uint *buffer, const Operator
return b;
}
-static inline qreal determinant(qreal a, qreal b, qreal c)
-{
- return (b * b) - (4 * a * c);
-}
-
-// function to evaluate real roots
-static inline qreal realRoots(qreal a, qreal b, qreal detSqrt)
-{
- return (-b + detSqrt)/(2 * a);
-}
-
-static inline qreal qSafeSqrt(qreal x)
-{
- return x > 0 ? qSqrt(x) : 0;
-}
-
static void QT_FASTCALL getRadialGradientValues(RadialGradientValues *v, const QSpanData *data)
{
v->dx = data->gradient.radial.center.x - data->gradient.radial.focal.x;
v->dy = data->gradient.radial.center.y - data->gradient.radial.focal.y;
- v->a = data->gradient.radial.radius*data->gradient.radial.radius - v->dx*v->dx - v->dy*v->dy;
-}
-
-static const uint * QT_FASTCALL fetchRadialGradient(uint *buffer, const Operator *op, const QSpanData *data,
- int y, int x, int length)
-{
- const uint *b = buffer;
- qreal rx = data->m21 * (y + qreal(0.5))
- + data->dx + data->m11 * (x + qreal(0.5));
- qreal ry = data->m22 * (y + qreal(0.5))
- + data->dy + data->m12 * (x + qreal(0.5));
- bool affine = !data->m13 && !data->m23;
- //qreal r = data->gradient.radial.radius;
-
- const uint *end = buffer + length;
- if (affine) {
- rx -= data->gradient.radial.focal.x;
- ry -= data->gradient.radial.focal.y;
-
- qreal inv_a = 1 / qreal(2 * op->radial.a);
-
- const qreal delta_rx = data->m11;
- const qreal delta_ry = data->m12;
-
- qreal b = 2*(rx * op->radial.dx + ry * op->radial.dy);
- qreal delta_b = 2*(delta_rx * op->radial.dx + delta_ry * op->radial.dy);
- const qreal b_delta_b = 2 * b * delta_b;
- const qreal delta_b_delta_b = 2 * delta_b * delta_b;
- const qreal bb = b * b;
- const qreal delta_bb = delta_b * delta_b;
+ v->dr = data->gradient.radial.center.radius - data->gradient.radial.focal.radius;
+ v->sqrfr = data->gradient.radial.focal.radius * data->gradient.radial.focal.radius;
- b *= inv_a;
- delta_b *= inv_a;
+ v->a = v->dr * v->dr - v->dx*v->dx - v->dy*v->dy;
+ v->inv2a = 1 / (2 * v->a);
- const qreal rxrxryry = rx * rx + ry * ry;
- const qreal delta_rxrxryry = delta_rx * delta_rx + delta_ry * delta_ry;
- const qreal rx_plus_ry = 2*(rx * delta_rx + ry * delta_ry);
- const qreal delta_rx_plus_ry = 2 * delta_rxrxryry;
-
- inv_a *= inv_a;
-
- qreal det = (bb + 4 * op->radial.a * rxrxryry) * inv_a;
- qreal delta_det = (b_delta_b + delta_bb + 4 * op->radial.a * (rx_plus_ry + delta_rxrxryry)) * inv_a;
- const qreal delta_delta_det = (delta_b_delta_b + 4 * op->radial.a * delta_rx_plus_ry) * inv_a;
+ v->extended = !qFuzzyIsNull(data->gradient.radial.focal.radius) || v->a <= 0;
+}
- while (buffer < end) {
- *buffer = qt_gradient_pixel(&data->gradient, qSafeSqrt(det) - b);
+class RadialFetchPlain
+{
+public:
+ static inline void fetch(uint *buffer, uint *end, const Operator *op, const QSpanData *data, qreal det,
+ qreal delta_det, qreal delta_delta_det, qreal b, qreal delta_b)
+ {
+ if (op->radial.extended) {
+ while (buffer < end) {
+ quint32 result = 0;
+ if (det >= 0) {
+ qreal w = qSqrt(det) - b;
+ if (data->gradient.radial.focal.radius + op->radial.dr * w >= 0)
+ result = qt_gradient_pixel(&data->gradient, w);
+ }
- det += delta_det;
- delta_det += delta_delta_det;
- b += delta_b;
+ *buffer = result;
- ++buffer;
- }
- } else {
- qreal rw = data->m23 * (y + qreal(0.5))
- + data->m33 + data->m13 * (x + qreal(0.5));
- if (!rw)
- rw = 1;
- while (buffer < end) {
- qreal gx = rx/rw - data->gradient.radial.focal.x;
- qreal gy = ry/rw - data->gradient.radial.focal.y;
- qreal b = 2*(gx*op->radial.dx + gy*op->radial.dy);
- qreal det = determinant(op->radial.a, b , -(gx*gx + gy*gy));
- qreal s = realRoots(op->radial.a, b, qSafeSqrt(det));
+ det += delta_det;
+ delta_det += delta_delta_det;
+ b += delta_b;
- *buffer = qt_gradient_pixel(&data->gradient, s);
+ ++buffer;
+ }
+ } else {
+ while (buffer < end) {
+ *buffer++ = qt_gradient_pixel(&data->gradient, qSqrt(det) - b);
- rx += data->m11;
- ry += data->m12;
- rw += data->m13;
- if (!rw) {
- rw += data->m13;
+ det += delta_det;
+ delta_det += delta_delta_det;
+ b += delta_b;
}
- ++buffer;
}
}
+};
- return b;
+const uint * QT_FASTCALL qt_fetch_radial_gradient_plain(uint *buffer, const Operator *op, const QSpanData *data,
+ int y, int x, int length)
+{
+ return qt_fetch_radial_gradient_template<RadialFetchPlain>(buffer, op, data, y, x, length);
}
-static const uint * QT_FASTCALL fetchConicalGradient(uint *buffer, const Operator *, const QSpanData *data,
- int y, int x, int length)
+static SourceFetchProc qt_fetch_radial_gradient = qt_fetch_radial_gradient_plain;
+
+static const uint * QT_FASTCALL qt_fetch_conical_gradient(uint *buffer, const Operator *, const QSpanData *data,
+ int y, int x, int length)
{
const uint *b = buffer;
qreal rx = data->m21 * (y + qreal(0.5))
@@ -3347,16 +3217,16 @@ static inline Operator getOperator(const QSpanData *data, const QSpan *spans, in
case QSpanData::LinearGradient:
solidSource = !data->gradient.alphaColor;
getLinearGradientValues(&op.linear, data);
- op.src_fetch = fetchLinearGradient;
+ op.src_fetch = qt_fetch_linear_gradient;
break;
case QSpanData::RadialGradient:
solidSource = !data->gradient.alphaColor;
getRadialGradientValues(&op.radial, data);
- op.src_fetch = fetchRadialGradient;
+ op.src_fetch = qt_fetch_radial_gradient;
break;
case QSpanData::ConicalGradient:
solidSource = !data->gradient.alphaColor;
- op.src_fetch = fetchConicalGradient;
+ op.src_fetch = qt_fetch_conical_gradient;
break;
case QSpanData::Texture:
op.src_fetch = sourceFetch[getBlendType(data)][data->texture.format];
@@ -7198,14 +7068,8 @@ void qt_build_pow_tables() {
#endif
#ifdef Q_WS_WIN
- int winSmooth;
- if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0))
- smoothing = winSmooth / qreal(1000.0);
-
- // Safeguard ourselves against corrupt registry values...
- if (smoothing > 5 || smoothing < 1)
- smoothing = qreal(1.4);
-
+ extern qreal qt_fontsmoothing_gamma; // qapplication_win.cpp
+ smoothing = qt_fontsmoothing_gamma;
#endif
#ifdef Q_WS_X11
@@ -7888,6 +7752,11 @@ void qInitDrawhelperAsm()
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2;
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2;
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2;
+
+ extern const uint * QT_FASTCALL qt_fetch_radial_gradient_sse2(uint *buffer, const Operator *op, const QSpanData *data,
+ int y, int x, int length);
+
+ qt_fetch_radial_gradient = qt_fetch_radial_gradient_sse2;
}
#ifdef QT_HAVE_SSSE3
@@ -7983,6 +7852,11 @@ void qInitDrawhelperAsm()
qMemRotateFunctions[QImage::Format_RGB16][0] = qt_memrotate90_16_neon;
qMemRotateFunctions[QImage::Format_RGB16][2] = qt_memrotate270_16_neon;
qt_memfill32 = qt_memfill32_neon;
+
+ extern const uint * QT_FASTCALL qt_fetch_radial_gradient_neon(uint *buffer, const Operator *op, const QSpanData *data,
+ int y, int x, int length);
+
+ qt_fetch_radial_gradient = qt_fetch_radial_gradient_neon;
}
#endif
diff --git a/src/gui/painting/qdrawhelper_neon.cpp b/src/gui/painting/qdrawhelper_neon.cpp
index debca37..e673dd9 100644
--- a/src/gui/painting/qdrawhelper_neon.cpp
+++ b/src/gui/painting/qdrawhelper_neon.cpp
@@ -955,6 +955,46 @@ void qt_memrotate270_16_neon(const uchar *srcPixels, int w, int h,
}
}
+class QSimdNeon
+{
+public:
+ typedef int32x4_t Int32x4;
+ typedef float32x4_t Float32x4;
+
+ union Vect_buffer_i { Int32x4 v; int i[4]; };
+ union Vect_buffer_f { Float32x4 v; float f[4]; };
+
+ static inline Float32x4 v_dup(float x) { return vdupq_n_f32(x); }
+ static inline Int32x4 v_dup(int x) { return vdupq_n_s32(x); }
+ static inline Int32x4 v_dup(uint x) { return vdupq_n_s32(x); }
+
+ static inline Float32x4 v_add(Float32x4 a, Float32x4 b) { return vaddq_f32(a, b); }
+ static inline Int32x4 v_add(Int32x4 a, Int32x4 b) { return vaddq_s32(a, b); }
+
+ static inline Float32x4 v_max(Float32x4 a, Float32x4 b) { return vmaxq_f32(a, b); }
+ static inline Float32x4 v_min(Float32x4 a, Float32x4 b) { return vminq_f32(a, b); }
+ static inline Int32x4 v_min_16(Int32x4 a, Int32x4 b) { return vminq_s32(a, b); }
+
+ static inline Int32x4 v_and(Int32x4 a, Int32x4 b) { return vandq_s32(a, b); }
+
+ static inline Float32x4 v_sub(Float32x4 a, Float32x4 b) { return vsubq_f32(a, b); }
+ static inline Int32x4 v_sub(Int32x4 a, Int32x4 b) { return vsubq_s32(a, b); }
+
+ static inline Float32x4 v_mul(Float32x4 a, Float32x4 b) { return vmulq_f32(a, b); }
+
+ static inline Float32x4 v_sqrt(Float32x4 x) { Float32x4 y = vrsqrteq_f32(x); y = vmulq_f32(y, vrsqrtsq_f32(x, vmulq_f32(y, y))); return vmulq_f32(x, y); }
+
+ static inline Int32x4 v_toInt(Float32x4 x) { return vcvtq_s32_f32(x); }
+
+ static inline Int32x4 v_greaterOrEqual(Float32x4 a, Float32x4 b) { return vcge_f32(a, b); }
+};
+
+const uint * QT_FASTCALL qt_fetch_radial_gradient_neon(uint *buffer, const Operator *op, const QSpanData *data,
+ int y, int x, int length)
+{
+ return qt_fetch_radial_gradient_template<QRadialFetchSimd<QSimdNeon> >(buffer, op, data, y, x, length);
+}
+
QT_END_NAMESPACE
#endif // QT_HAVE_NEON
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index d4e731b..fa6ad0b 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -63,6 +63,7 @@
#endif
#include "private/qrasterdefs_p.h"
#include <private/qsimd_p.h>
+#include <private/qmath_p.h>
#ifdef Q_WS_QWS
#include "QtGui/qscreen_qws.h"
@@ -178,6 +179,44 @@ void qBlendTextureCallback(int count, const QSpan *spans, void *userData);
typedef void (QT_FASTCALL *CompositionFunction)(uint *dest, const uint *src, int length, uint const_alpha);
typedef void (QT_FASTCALL *CompositionFunctionSolid)(uint *dest, int length, uint color, uint const_alpha);
+struct LinearGradientValues
+{
+ qreal dx;
+ qreal dy;
+ qreal l;
+ qreal off;
+};
+
+struct RadialGradientValues
+{
+ qreal dx;
+ qreal dy;
+ qreal dr;
+ qreal sqrfr;
+ qreal a;
+ qreal inv2a;
+ bool extended;
+};
+
+struct Operator;
+typedef uint* (QT_FASTCALL *DestFetchProc)(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length);
+typedef void (QT_FASTCALL *DestStoreProc)(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length);
+typedef const uint* (QT_FASTCALL *SourceFetchProc)(uint *buffer, const Operator *o, const QSpanData *data, int y, int x, int length);
+
+struct Operator
+{
+ QPainter::CompositionMode mode;
+ DestFetchProc dest_fetch;
+ DestStoreProc dest_store;
+ SourceFetchProc src_fetch;
+ CompositionFunctionSolid funcSolid;
+ CompositionFunction func;
+ union {
+ LinearGradientValues linear;
+ RadialGradientValues radial;
+ };
+};
+
void qInitDrawhelperAsm();
class QRasterPaintEngine;
@@ -204,12 +243,13 @@ struct QRadialGradientData
struct {
qreal x;
qreal y;
+ qreal radius;
} center;
struct {
qreal x;
qreal y;
+ qreal radius;
} focal;
- qreal radius;
};
struct QConicalGradientData
@@ -233,8 +273,10 @@ struct QGradientData
#ifdef Q_WS_QWS
#define GRADIENT_STOPTABLE_SIZE 256
+#define GRADIENT_STOPTABLE_SIZE_SHIFT 8
#else
#define GRADIENT_STOPTABLE_SIZE 1024
+#define GRADIENT_STOPTABLE_SIZE_SHIFT 10
#endif
uint* colorTable; //[GRADIENT_STOPTABLE_SIZE];
@@ -308,6 +350,218 @@ struct QSpanData
void adjustSpanMethods();
};
+static inline uint qt_gradient_clamp(const QGradientData *data, int ipos)
+{
+ if (ipos < 0 || ipos >= GRADIENT_STOPTABLE_SIZE) {
+ if (data->spread == QGradient::RepeatSpread) {
+ ipos = ipos % GRADIENT_STOPTABLE_SIZE;
+ ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos;
+ } else if (data->spread == QGradient::ReflectSpread) {
+ const int limit = GRADIENT_STOPTABLE_SIZE * 2;
+ ipos = ipos % limit;
+ ipos = ipos < 0 ? limit + ipos : ipos;
+ ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - 1 - ipos : ipos;
+ } else {
+ if (ipos < 0)
+ ipos = 0;
+ else if (ipos >= GRADIENT_STOPTABLE_SIZE)
+ ipos = GRADIENT_STOPTABLE_SIZE-1;
+ }
+ }
+
+ Q_ASSERT(ipos >= 0);
+ Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE);
+
+ return ipos;
+}
+
+static inline uint qt_gradient_pixel(const QGradientData *data, qreal pos)
+{
+ int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + qreal(0.5));
+ return data->colorTable[qt_gradient_clamp(data, ipos)];
+}
+
+static inline qreal qRadialDeterminant(qreal a, qreal b, qreal c)
+{
+ return (b * b) - (4 * a * c);
+}
+
+template <class RadialFetchFunc>
+const uint * QT_FASTCALL qt_fetch_radial_gradient_template(uint *buffer, const Operator *op, const QSpanData *data,
+ int y, int x, int length)
+{
+ // avoid division by zero
+ if (qFuzzyIsNull(op->radial.a)) {
+ extern void (*qt_memfill32)(quint32 *dest, quint32 value, int count);
+ qt_memfill32(buffer, 0, length);
+ return buffer;
+ }
+
+ const uint *b = buffer;
+ qreal rx = data->m21 * (y + qreal(0.5))
+ + data->dx + data->m11 * (x + qreal(0.5));
+ qreal ry = data->m22 * (y + qreal(0.5))
+ + data->dy + data->m12 * (x + qreal(0.5));
+ bool affine = !data->m13 && !data->m23;
+
+ uint *end = buffer + length;
+ if (affine) {
+ rx -= data->gradient.radial.focal.x;
+ ry -= data->gradient.radial.focal.y;
+
+ qreal inv_a = 1 / qreal(2 * op->radial.a);
+
+ const qreal delta_rx = data->m11;
+ const qreal delta_ry = data->m12;
+
+ qreal b = 2*(op->radial.dr*data->gradient.radial.focal.radius + rx * op->radial.dx + ry * op->radial.dy);
+ qreal delta_b = 2*(delta_rx * op->radial.dx + delta_ry * op->radial.dy);
+ const qreal b_delta_b = 2 * b * delta_b;
+ const qreal delta_b_delta_b = 2 * delta_b * delta_b;
+
+ const qreal bb = b * b;
+ const qreal delta_bb = delta_b * delta_b;
+
+ b *= inv_a;
+ delta_b *= inv_a;
+
+ const qreal rxrxryry = rx * rx + ry * ry;
+ const qreal delta_rxrxryry = delta_rx * delta_rx + delta_ry * delta_ry;
+ const qreal rx_plus_ry = 2*(rx * delta_rx + ry * delta_ry);
+ const qreal delta_rx_plus_ry = 2 * delta_rxrxryry;
+
+ inv_a *= inv_a;
+
+ qreal det = (bb - 4 * op->radial.a * (op->radial.sqrfr - rxrxryry)) * inv_a;
+ qreal delta_det = (b_delta_b + delta_bb + 4 * op->radial.a * (rx_plus_ry + delta_rxrxryry)) * inv_a;
+ const qreal delta_delta_det = (delta_b_delta_b + 4 * op->radial.a * delta_rx_plus_ry) * inv_a;
+
+ RadialFetchFunc::fetch(buffer, end, op, data, det, delta_det, delta_delta_det, b, delta_b);
+ } else {
+ qreal rw = data->m23 * (y + qreal(0.5))
+ + data->m33 + data->m13 * (x + qreal(0.5));
+
+ while (buffer < end) {
+ if (rw == 0) {
+ *buffer = 0;
+ } else {
+ qreal invRw = 1 / rw;
+ qreal gx = rx * invRw - data->gradient.radial.focal.x;
+ qreal gy = ry * invRw - data->gradient.radial.focal.y;
+ qreal b = 2*(op->radial.dr*data->gradient.radial.focal.radius + gx*op->radial.dx + gy*op->radial.dy);
+ qreal det = qRadialDeterminant(op->radial.a, b, op->radial.sqrfr - (gx*gx + gy*gy));
+
+ quint32 result = 0;
+ if (det >= 0) {
+ qreal detSqrt = qSqrt(det);
+
+ qreal s0 = (-b - detSqrt) * op->radial.inv2a;
+ qreal s1 = (-b + detSqrt) * op->radial.inv2a;
+
+ qreal s = qMax(s0, s1);
+
+ if (data->gradient.radial.focal.radius + op->radial.dr * s >= 0)
+ result = qt_gradient_pixel(&data->gradient, s);
+ }
+
+ *buffer = result;
+ }
+
+ rx += data->m11;
+ ry += data->m12;
+ rw += data->m13;
+
+ ++buffer;
+ }
+ }
+
+ return b;
+}
+
+template <class Simd>
+class QRadialFetchSimd
+{
+public:
+ static void fetch(uint *buffer, uint *end, const Operator *op, const QSpanData *data, qreal det,
+ qreal delta_det, qreal delta_delta_det, qreal b, qreal delta_b)
+ {
+ typename Simd::Vect_buffer_f det_vec;
+ typename Simd::Vect_buffer_f delta_det4_vec;
+ typename Simd::Vect_buffer_f b_vec;
+
+ for (int i = 0; i < 4; ++i) {
+ det_vec.f[i] = det;
+ delta_det4_vec.f[i] = 4 * delta_det;
+ b_vec.f[i] = b;
+
+ det += delta_det;
+ delta_det += delta_delta_det;
+ b += delta_b;
+ }
+
+ const typename Simd::Float32x4 v_delta_delta_det16 = Simd::v_dup(16 * delta_delta_det);
+ const typename Simd::Float32x4 v_delta_delta_det6 = Simd::v_dup(6 * delta_delta_det);
+ const typename Simd::Float32x4 v_delta_b4 = Simd::v_dup(4 * delta_b);
+
+ const typename Simd::Float32x4 v_r0 = Simd::v_dup(data->gradient.radial.focal.radius);
+ const typename Simd::Float32x4 v_dr = Simd::v_dup(op->radial.dr);
+
+ const typename Simd::Float32x4 v_min = Simd::v_dup(0.0f);
+ const typename Simd::Float32x4 v_max = Simd::v_dup(float(GRADIENT_STOPTABLE_SIZE-1));
+ const typename Simd::Float32x4 v_half = Simd::v_dup(0.5f);
+
+ const typename Simd::Int32x4 v_repeat_mask = Simd::v_dup(~(uint(0xffffff) << GRADIENT_STOPTABLE_SIZE_SHIFT));
+ const typename Simd::Int32x4 v_reflect_mask = Simd::v_dup(~(uint(0xffffff) << (GRADIENT_STOPTABLE_SIZE_SHIFT+1)));
+
+ const typename Simd::Int32x4 v_reflect_limit = Simd::v_dup(2 * GRADIENT_STOPTABLE_SIZE - 1);
+
+ const int extended_mask = op->radial.extended ? 0x0 : ~0x0;
+
+#define FETCH_RADIAL_LOOP_PROLOGUE \
+ while (buffer < end) { \
+ typename Simd::Vect_buffer_i v_buffer_mask; \
+ v_buffer_mask.v = Simd::v_greaterOrEqual(det_vec.v, v_min); \
+ const typename Simd::Float32x4 v_index_local = Simd::v_sub(Simd::v_sqrt(Simd::v_max(v_min, det_vec.v)), b_vec.v); \
+ const typename Simd::Float32x4 v_index = Simd::v_add(Simd::v_mul(v_index_local, v_max), v_half); \
+ v_buffer_mask.v = Simd::v_and(v_buffer_mask.v, Simd::v_greaterOrEqual(Simd::v_add(v_r0, Simd::v_mul(v_dr, v_index_local)), v_min)); \
+ typename Simd::Vect_buffer_i index_vec;
+#define FETCH_RADIAL_LOOP_CLAMP_REPEAT \
+ index_vec.v = Simd::v_and(v_repeat_mask, Simd::v_toInt(v_index));
+#define FETCH_RADIAL_LOOP_CLAMP_REFLECT \
+ const typename Simd::Int32x4 v_index_i = Simd::v_and(v_reflect_mask, Simd::v_toInt(v_index)); \
+ const typename Simd::Int32x4 v_index_i_inv = Simd::v_sub(v_reflect_limit, v_index_i); \
+ index_vec.v = Simd::v_min_16(v_index_i, v_index_i_inv);
+#define FETCH_RADIAL_LOOP_CLAMP_PAD \
+ index_vec.v = Simd::v_toInt(Simd::v_min(v_max, Simd::v_max(v_min, v_index)));
+#define FETCH_RADIAL_LOOP_EPILOGUE \
+ det_vec.v = Simd::v_add(Simd::v_add(det_vec.v, delta_det4_vec.v), v_delta_delta_det6); \
+ delta_det4_vec.v = Simd::v_add(delta_det4_vec.v, v_delta_delta_det16); \
+ b_vec.v = Simd::v_add(b_vec.v, v_delta_b4); \
+ for (int i = 0; i < 4; ++i) \
+ *buffer++ = (extended_mask | v_buffer_mask.i[i]) & data->gradient.colorTable[index_vec.i[i]]; \
+ }
+
+#define FETCH_RADIAL_LOOP(FETCH_RADIAL_LOOP_CLAMP) \
+ FETCH_RADIAL_LOOP_PROLOGUE \
+ FETCH_RADIAL_LOOP_CLAMP \
+ FETCH_RADIAL_LOOP_EPILOGUE
+
+ switch (data->gradient.spread) {
+ case QGradient::RepeatSpread:
+ FETCH_RADIAL_LOOP(FETCH_RADIAL_LOOP_CLAMP_REPEAT)
+ break;
+ case QGradient::ReflectSpread:
+ FETCH_RADIAL_LOOP(FETCH_RADIAL_LOOP_CLAMP_REFLECT)
+ break;
+ case QGradient::PadSpread:
+ FETCH_RADIAL_LOOP(FETCH_RADIAL_LOOP_CLAMP_PAD)
+ break;
+ default:
+ Q_ASSERT(false);
+ }
+ }
+};
+
#if defined(Q_CC_RVCT)
# pragma push
# pragma arm
diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp
index aad6bc9..75bb619 100644
--- a/src/gui/painting/qdrawhelper_sse2.cpp
+++ b/src/gui/painting/qdrawhelper_sse2.cpp
@@ -112,8 +112,6 @@ void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl,
// First, align dest to 16 bytes:
ALIGNMENT_PROLOGUE_16BYTES(dst, x, w) {
- quint32 s = src[x];
- s = BYTE_MUL(s, const_alpha);
dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha);
}
@@ -127,8 +125,6 @@ void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl,
}
}
for (; x<w; ++x) {
- quint32 s = src[x];
- s = BYTE_MUL(s, const_alpha);
dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha);
}
dst = (quint32 *)(((uchar *) dst) + dbpl);
@@ -491,6 +487,58 @@ void qt_bitmapblit16_sse2(QRasterBuffer *rasterBuffer, int x, int y,
}
}
+class QSimdSse2
+{
+public:
+ typedef __m128i Int32x4;
+ typedef __m128 Float32x4;
+
+ union Vect_buffer_i { Int32x4 v; int i[4]; };
+ union Vect_buffer_f { Float32x4 v; float f[4]; };
+
+ static inline Float32x4 v_dup(float x) { return _mm_set1_ps(x); }
+ static inline Float32x4 v_dup(double x) { return _mm_set1_ps(x); }
+ static inline Int32x4 v_dup(int x) { return _mm_set1_epi32(x); }
+ static inline Int32x4 v_dup(uint x) { return _mm_set1_epi32(x); }
+
+ static inline Float32x4 v_add(Float32x4 a, Float32x4 b) { return _mm_add_ps(a, b); }
+ static inline Int32x4 v_add(Int32x4 a, Int32x4 b) { return _mm_add_epi32(a, b); }
+
+ static inline Float32x4 v_max(Float32x4 a, Float32x4 b) { return _mm_max_ps(a, b); }
+ static inline Float32x4 v_min(Float32x4 a, Float32x4 b) { return _mm_min_ps(a, b); }
+ static inline Int32x4 v_min_16(Int32x4 a, Int32x4 b) { return _mm_min_epi16(a, b); }
+
+ static inline Int32x4 v_and(Int32x4 a, Int32x4 b) { return _mm_and_si128(a, b); }
+
+ static inline Float32x4 v_sub(Float32x4 a, Float32x4 b) { return _mm_sub_ps(a, b); }
+ static inline Int32x4 v_sub(Int32x4 a, Int32x4 b) { return _mm_sub_epi32(a, b); }
+
+ static inline Float32x4 v_mul(Float32x4 a, Float32x4 b) { return _mm_mul_ps(a, b); }
+
+ static inline Float32x4 v_sqrt(Float32x4 x) { return _mm_sqrt_ps(x); }
+
+ static inline Int32x4 v_toInt(Float32x4 x) { return _mm_cvttps_epi32(x); }
+
+ // pre-VS 2008 doesn't have cast intrinsics, whereas 2008 and later requires it
+#if defined(Q_CC_MSVC) && _MSC_VER < 1500
+ static inline Int32x4 v_greaterOrEqual(Float32x4 a, Float32x4 b)
+ {
+ union Convert { Int32x4 vi; Float32x4 vf; } convert;
+ convert.vf = _mm_cmpgt_ps(a, b);
+ return convert.vi;
+ }
+#else
+ static inline Int32x4 v_greaterOrEqual(Float32x4 a, Float32x4 b) { return _mm_castps_si128(_mm_cmpgt_ps(a, b)); }
+#endif
+};
+
+const uint * QT_FASTCALL qt_fetch_radial_gradient_sse2(uint *buffer, const Operator *op, const QSpanData *data,
+ int y, int x, int length)
+{
+ return qt_fetch_radial_gradient_template<QRadialFetchSimd<QSimdSse2> >(buffer, op, data, y, x, length);
+}
+
+
QT_END_NAMESPACE
#endif // QT_HAVE_SSE2
diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp
index 171ef46..d82fdc9 100644
--- a/src/gui/painting/qgraphicssystem.cpp
+++ b/src/gui/painting/qgraphicssystem.cpp
@@ -55,6 +55,9 @@
#endif
#ifdef Q_OS_SYMBIAN
# include <private/qpixmap_s60_p.h>
+# include <private/qgraphicssystemex_symbian_p.h>
+#else
+# include <private/qgraphicssystemex_p.h>
#endif
QT_BEGIN_NAMESPACE
@@ -89,9 +92,18 @@ QPixmapData *QGraphicsSystem::createPixmapData(QPixmapData *origin)
return createPixmapData(origin->pixelType());
}
-void QGraphicsSystem::releaseCachedResources()
+#ifdef Q_OS_SYMBIAN
+Q_GLOBAL_STATIC(QSymbianGraphicsSystemEx, symbianPlatformExtension)
+#endif
+
+QGraphicsSystemEx* QGraphicsSystem::platformExtension()
{
- // Do nothing here
+#ifdef Q_OS_SYMBIAN
+ // this is used on raster graphics systems. HW accelerated
+ // graphics systems will overwrite this function.
+ return symbianPlatformExtension();
+#endif
+ return 0;
}
QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h
index 0f99a31..275f9eb 100644
--- a/src/gui/painting/qgraphicssystem_p.h
+++ b/src/gui/painting/qgraphicssystem_p.h
@@ -63,6 +63,7 @@ QT_BEGIN_NAMESPACE
class QPixmapFilter;
class QBlittable;
+class QGraphicsSystemEx;
class Q_GUI_EXPORT QGraphicsSystem
{
@@ -77,7 +78,7 @@ public:
// to have a graphics system.
static QPixmapData *createDefaultPixmapData(QPixmapData::PixelType type);
- virtual void releaseCachedResources();
+ virtual QGraphicsSystemEx* platformExtension();
};
QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystemex_p.h b/src/gui/painting/qgraphicssystemex_p.h
new file mode 100644
index 0000000..6feb116
--- /dev/null
+++ b/src/gui/painting/qgraphicssystemex_p.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSSYSTEMEX_P_H
+#define QGRAPHICSSYSTEMEX_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 <qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_GUI_EXPORT QGraphicsSystemEx
+{
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/gui/painting/qgraphicssystemex_symbian.cpp b/src/gui/painting/qgraphicssystemex_symbian.cpp
new file mode 100644
index 0000000..2d3f137
--- /dev/null
+++ b/src/gui/painting/qgraphicssystemex_symbian.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgraphicssystemex_symbian_p.h"
+#include "private/qwidget_p.h"
+#include "private/qbackingstore_p.h"
+#include "private/qapplication_p.h"
+
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+void QSymbianGraphicsSystemEx::releaseCachedGpuResources()
+{
+ // Do nothing here
+ // This is implemented in graphics system specific plugin
+}
+
+void QSymbianGraphicsSystemEx::releaseAllGpuResources()
+{
+ releaseCachedGpuResources();
+
+ foreach (QWidget *widget, QApplication::topLevelWidgets()) {
+ if (QTLWExtra *topExtra = qt_widget_private(widget)->maybeTopData())
+ topExtra->backingStore.destroy();
+ }
+}
+
+bool QSymbianGraphicsSystemEx::hasBCM2727()
+{
+ return !QApplicationPrivate::instance()->useTranslucentEGLSurfaces;
+}
+
+void QSymbianGraphicsSystemEx::forceToRaster(QWidget *window)
+{
+ if (window && window->isWindow()) {
+ qt_widget_private(window)->createTLExtra();
+ if (QTLWExtra *topExtra = qt_widget_private(window)->maybeTopData()) {
+ topExtra->forcedToRaster = 1;
+ if (topExtra->backingStore.data()) {
+ topExtra->backingStore.create(window);
+ topExtra->backingStore.registerWidget(window);
+ }
+ }
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/util/qscrollerproperties_p.h b/src/gui/painting/qgraphicssystemex_symbian_p.h
index 76d8b0a..0b1e39e 100644
--- a/src/gui/util/qscrollerproperties_p.h
+++ b/src/gui/painting/qgraphicssystemex_symbian_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QSCROLLERPROPERTIES_P_H
-#define QSCROLLERPROPERTIES_P_H
+#ifndef QSYMBIANGRAPHICSSYSTEMEX_P_H
+#define QSYMBIANGRAPHICSSYSTEMEX_P_H
//
// W A R N I N G
@@ -53,42 +53,21 @@
// We mean it.
//
-#include <QPointF>
-#include <QEasingCurve>
-#include <qscrollerproperties.h>
+#include "private/qgraphicssystemex_p.h"
QT_BEGIN_NAMESPACE
-class QScrollerPropertiesPrivate
+class QWidget;
+
+class Q_GUI_EXPORT QSymbianGraphicsSystemEx : public QGraphicsSystemEx
{
public:
- static QScrollerPropertiesPrivate *defaults();
-
- bool operator==(const QScrollerPropertiesPrivate &) const;
-
- qreal mousePressEventDelay;
- qreal dragStartDistance;
- qreal dragVelocitySmoothingFactor;
- qreal axisLockThreshold;
- QEasingCurve scrollingCurve;
- qreal decelerationFactor;
- qreal minimumVelocity;
- qreal maximumVelocity;
- qreal maximumClickThroughVelocity;
- qreal acceleratingFlickMaximumTime;
- qreal acceleratingFlickSpeedupFactor;
- qreal snapPositionRatio;
- qreal snapTime;
- qreal overshootDragResistanceFactor;
- qreal overshootDragDistanceFactor;
- qreal overshootScrollDistanceFactor;
- qreal overshootScrollTime;
- QScrollerProperties::OvershootPolicy hOvershootPolicy;
- QScrollerProperties::OvershootPolicy vOvershootPolicy;
- QScrollerProperties::FrameRates frameRate;
+ virtual void releaseCachedGpuResources();
+ virtual void releaseAllGpuResources();
+ virtual bool hasBCM2727();
+ virtual void forceToRaster(QWidget *window);
};
QT_END_NAMESPACE
-#endif // QSCROLLERPROPERTIES_P_H
-
+#endif
diff --git a/src/gui/painting/qgraphicssystemfactory.cpp b/src/gui/painting/qgraphicssystemfactory.cpp
index 62a60d7..6212674 100644
--- a/src/gui/painting/qgraphicssystemfactory.cpp
+++ b/src/gui/painting/qgraphicssystemfactory.cpp
@@ -74,7 +74,7 @@ QGraphicsSystem *QGraphicsSystemFactory::create(const QString& key)
if (system.isEmpty()) {
system = QLatin1String("runtime");
}
-#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11)
+#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11) || (defined (Q_WS_MAC) && defined(QT_MAC_USE_COCOA))
if (system.isEmpty()) {
system = QLatin1String("raster");
}
diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp
index 7870def..6f6cd6f 100644
--- a/src/gui/painting/qpaintbuffer.cpp
+++ b/src/gui/painting/qpaintbuffer.cpp
@@ -535,16 +535,6 @@ QString QPaintBuffer::commandDescription(int command) const
QTextItemInt &ti = (*tiCopy)();
QString text(ti.text());
- QFont font(ti.font());
- font.setUnderline(false);
- font.setStrikeOut(false);
- font.setOverline(false);
-
- const QTextItemInt &si = static_cast<const QTextItemInt &>(ti);
- qreal justificationWidth = 0;
- if (si.justified)
- justificationWidth = si.width.toReal();
-
debug << "Cmd_DrawTextItem:" << pos << " " << text;
break; }
case QPaintBufferPrivate::Cmd_SystemStateChanged: {
@@ -1778,12 +1768,12 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
rawFontD->fontEngine = fontD->engineForScript(QUnicodeTables::Common);
rawFontD->fontEngine->ref.ref();
- QGlyphs glyphs;
- glyphs.setFont(rawFont);
+ QGlyphRun glyphs;
+ glyphs.setRawFont(rawFont);
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(positions);
- painter->drawGlyphs(QPointF(), glyphs);
+ painter->drawGlyphRun(QPointF(), glyphs);
break;
}
#endif
diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp
index 8aab7c7..cc75b86 100644
--- a/src/gui/painting/qpaintengine_mac.cpp
+++ b/src/gui/painting/qpaintengine_mac.cpp
@@ -1544,8 +1544,9 @@ void QCoreGraphicsPaintEnginePrivate::setFillBrush(const QPointF &offset)
QPointF center(radialGrad->center());
QPointF focal(radialGrad->focalPoint());
qreal radius = radialGrad->radius();
+ qreal focalRadius = radialGrad->focalRadius();
shading = CGShadingCreateRadial(colorspace, CGPointMake(focal.x(), focal.y()),
- 0.0, CGPointMake(center.x(), center.y()), radius, fill_func, false, true);
+ focalRadius, CGPointMake(center.x(), center.y()), radius, fill_func, false, true);
}
CGFunctionRelease(fill_func);
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 6902543..2119e30 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -5033,6 +5033,84 @@ void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint
bool colorInterpolation = (gradient.interpolationMode() == QGradient::ColorInterpolation);
+ if (stopCount == 2) {
+ uint first_color = ARGB_COMBINE_ALPHA(stops[0].second.rgba(), opacity);
+ uint second_color = ARGB_COMBINE_ALPHA(stops[1].second.rgba(), opacity);
+
+ qreal first_stop = stops[0].first;
+ qreal second_stop = stops[1].first;
+
+ if (second_stop < first_stop) {
+ qSwap(first_color, second_color);
+ qSwap(first_stop, second_stop);
+ }
+
+ if (colorInterpolation) {
+ first_color = PREMUL(first_color);
+ second_color = PREMUL(second_color);
+ }
+
+ int first_index = qRound(first_stop * (GRADIENT_STOPTABLE_SIZE-1));
+ int second_index = qRound(second_stop * (GRADIENT_STOPTABLE_SIZE-1));
+
+ uint red_first = qRed(first_color) << 16;
+ uint green_first = qGreen(first_color) << 16;
+ uint blue_first = qBlue(first_color) << 16;
+ uint alpha_first = qAlpha(first_color) << 16;
+
+ uint red_second = qRed(second_color) << 16;
+ uint green_second = qGreen(second_color) << 16;
+ uint blue_second = qBlue(second_color) << 16;
+ uint alpha_second = qAlpha(second_color) << 16;
+
+ int i = 0;
+ for (; i <= qMin(GRADIENT_STOPTABLE_SIZE, first_index); ++i) {
+ if (colorInterpolation)
+ colorTable[i] = first_color;
+ else
+ colorTable[i] = PREMUL(first_color);
+ }
+
+ if (i < second_index) {
+ qreal reciprocal = qreal(1) / (second_index - first_index);
+
+ int red_delta = qRound(int(red_second - red_first) * reciprocal);
+ int green_delta = qRound(int(green_second - green_first) * reciprocal);
+ int blue_delta = qRound(int(blue_second - blue_first) * reciprocal);
+ int alpha_delta = qRound(int(alpha_second - alpha_first) * reciprocal);
+
+ // rounding
+ red_first += 1 << 15;
+ green_first += 1 << 15;
+ blue_first += 1 << 15;
+ alpha_first += 1 << 15;
+
+ for (; i < qMin(GRADIENT_STOPTABLE_SIZE, second_index); ++i) {
+ red_first += red_delta;
+ green_first += green_delta;
+ blue_first += blue_delta;
+ alpha_first += alpha_delta;
+
+ const uint color = ((alpha_first << 8) & 0xff000000) | (red_first & 0xff0000)
+ | ((green_first >> 8) & 0xff00) | (blue_first >> 16);
+
+ if (colorInterpolation)
+ colorTable[i] = color;
+ else
+ colorTable[i] = PREMUL(color);
+ }
+ }
+
+ for (; i < GRADIENT_STOPTABLE_SIZE; ++i) {
+ if (colorInterpolation)
+ colorTable[i] = second_color;
+ else
+ colorTable[i] = PREMUL(second_color);
+ }
+
+ return;
+ }
+
uint current_color = ARGB_COMBINE_ALPHA(stops[0].second.rgba(), opacity);
if (stopCount == 1) {
current_color = PREMUL(current_color);
@@ -5204,10 +5282,11 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
QPointF center = g->center();
radialData.center.x = center.x();
radialData.center.y = center.y();
+ radialData.center.radius = g->centerRadius();
QPointF focal = g->focalPoint();
radialData.focal.x = focal.x();
radialData.focal.y = focal.y();
- radialData.radius = g->radius();
+ radialData.focal.radius = g->focalRadius();
}
break;
diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp
index 94828fb..6ba9a99 100644
--- a/src/gui/painting/qpaintengine_x11.cpp
+++ b/src/gui/painting/qpaintengine_x11.cpp
@@ -1611,8 +1611,6 @@ void QX11PaintEnginePrivate::fillPolygon_dev(const QPointF *polygonPoints, int p
&& (fill.style() != Qt::NoBrush)
&& ((has_fill_texture && fill.texture().hasAlpha()) || antialias || !solid_fill || has_alpha_pen != has_alpha_brush))
{
- QRect br = tessellator->tessellate((QPointF *)clippedPoints, clippedCount,
- mode == QPaintEngine::WindingMode);
if (tessellator->size > 0) {
XRenderPictureAttributes attrs;
attrs.poly_edge = antialias ? PolyEdgeSmooth : PolyEdgeSharp;
@@ -1771,7 +1769,6 @@ void QX11PaintEngine::drawPath(const QPainterPath &path)
Q_D(QX11PaintEngine);
if (path.isEmpty())
return;
- QTransform old_matrix = d->matrix;
if (d->has_brush)
d->fillPath(path, QX11PaintEnginePrivate::BrushGC, true);
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 509fb77..7f601eb 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -1012,4 +1012,50 @@ void QPaintEngineEx::updateState(const QPaintEngineState &)
// do nothing...
}
+Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath(const QVectorPath &path)
+{
+ const qreal *points = path.points();
+ const QPainterPath::ElementType *types = path.elements();
+
+ QPainterPath p;
+ if (types) {
+ int id = 0;
+ for (int i=0; i<path.elementCount(); ++i) {
+ switch(types[i]) {
+ case QPainterPath::MoveToElement:
+ p.moveTo(QPointF(points[id], points[id+1]));
+ id+=2;
+ break;
+ case QPainterPath::LineToElement:
+ p.lineTo(QPointF(points[id], points[id+1]));
+ id+=2;
+ break;
+ case QPainterPath::CurveToElement: {
+ QPointF p1(points[id], points[id+1]);
+ QPointF p2(points[id+2], points[id+3]);
+ QPointF p3(points[id+4], points[id+5]);
+ p.cubicTo(p1, p2, p3);
+ id+=6;
+ break;
+ }
+ case QPainterPath::CurveToDataElement:
+ ;
+ break;
+ }
+ }
+ } else {
+ p.moveTo(QPointF(points[0], points[1]));
+ int id = 2;
+ for (int i=1; i<path.elementCount(); ++i) {
+ p.lineTo(QPointF(points[id], points[id+1]));
+ id+=2;
+ }
+ }
+ if (path.hints() & QVectorPath::WindingFill)
+ p.setFillRule(Qt::WindingFill);
+
+ return p;
+}
+
+
QT_END_NAMESPACE
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 9fafba5..a965c15 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -62,7 +62,7 @@
#include "qthread.h"
#include "qvarlengtharray.h"
#include "qstatictext.h"
-#include "qglyphs.h"
+#include "qglyphrun.h"
#include <private/qfontengine_p.h>
#include <private/qpaintengine_p.h>
@@ -73,7 +73,7 @@
#include <private/qpaintengine_raster_p.h>
#include <private/qmath_p.h>
#include <private/qstatictext_p.h>
-#include <private/qglyphs_p.h>
+#include <private/qglyphrun_p.h>
#include <private/qstylehelper_p.h>
#include <private/qrawfont_p.h>
@@ -156,7 +156,8 @@ static bool qt_paintengine_supports_transformations(QPaintEngine::Type type)
{
return type == QPaintEngine::OpenGL2
|| type == QPaintEngine::OpenVG
- || type == QPaintEngine::OpenGL;
+ || type == QPaintEngine::OpenGL
+ || type == QPaintEngine::CoreGraphics;
}
#ifndef QT_NO_DEBUG
@@ -503,8 +504,12 @@ void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperatio
q->save();
state->matrix = QTransform();
- state->dirtyFlags |= QPaintEngine::DirtyTransform;
- updateState(state);
+ if (extended) {
+ extended->transformChanged();
+ } else {
+ state->dirtyFlags |= QPaintEngine::DirtyTransform;
+ updateState(state);
+ }
engine->drawImage(absPathRect,
image,
QRectF(0, 0, absPathRect.width(), absPathRect.height()),
@@ -687,11 +692,14 @@ void QPainterPrivate::updateInvMatrix()
invMatrix = state->matrix.inverted();
}
+Q_GUI_EXPORT bool qt_isExtendedRadialGradient(const QBrush &brush);
+
void QPainterPrivate::updateEmulationSpecifier(QPainterState *s)
{
bool alpha = false;
bool linearGradient = false;
bool radialGradient = false;
+ bool extendedRadialGradient = false;
bool conicalGradient = false;
bool patternBrush = false;
bool xform = false;
@@ -723,6 +731,7 @@ void QPainterPrivate::updateEmulationSpecifier(QPainterState *s)
(brushStyle == Qt::LinearGradientPattern));
radialGradient = ((penBrushStyle == Qt::RadialGradientPattern) ||
(brushStyle == Qt::RadialGradientPattern));
+ extendedRadialGradient = radialGradient && (qt_isExtendedRadialGradient(penBrush) || qt_isExtendedRadialGradient(s->brush));
conicalGradient = ((penBrushStyle == Qt::ConicalGradientPattern) ||
(brushStyle == Qt::ConicalGradientPattern));
patternBrush = (((penBrushStyle > Qt::SolidPattern
@@ -806,7 +815,7 @@ void QPainterPrivate::updateEmulationSpecifier(QPainterState *s)
s->emulationSpecifier &= ~QPaintEngine::LinearGradientFill;
// Radial gradient emulation
- if (radialGradient && !engine->hasFeature(QPaintEngine::RadialGradientFill))
+ if (extendedRadialGradient || (radialGradient && !engine->hasFeature(QPaintEngine::RadialGradientFill)))
s->emulationSpecifier |= QPaintEngine::RadialGradientFill;
else
s->emulationSpecifier &= ~QPaintEngine::RadialGradientFill;
@@ -5789,19 +5798,19 @@ void QPainter::drawImage(const QRectF &targetRect, const QImage &image, const QR
\since 4.8
- \sa QGlyphs::setFont(), QGlyphs::setPositions(), QGlyphs::setGlyphIndexes()
+ \sa QGlyphRun::setRawFont(), QGlyphRun::setPositions(), QGlyphRun::setGlyphIndexes()
*/
#if !defined(QT_NO_RAWFONT)
-void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs)
+void QPainter::drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun)
{
Q_D(QPainter);
- QRawFont font = glyphs.font();
+ QRawFont font = glyphRun.rawFont();
if (!font.isValid())
return;
- QVector<quint32> glyphIndexes = glyphs.glyphIndexes();
- QVector<QPointF> glyphPositions = glyphs.positions();
+ QVector<quint32> glyphIndexes = glyphRun.glyphIndexes();
+ QVector<QPointF> glyphPositions = glyphRun.positions();
int count = qMin(glyphIndexes.size(), glyphPositions.size());
QVarLengthArray<QFixedPoint, 128> fixedPointPositions(count);
@@ -5809,7 +5818,14 @@ void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs)
bool paintEngineSupportsTransformations =
d->extended != 0
? qt_paintengine_supports_transformations(d->extended->type())
- : false;
+ : qt_paintengine_supports_transformations(d->engine->type());
+
+ // If the matrix is not affine, the paint engine will fall back to
+ // drawing the glyphs as paths, which in turn means we should not
+ // preprocess the glyph positions
+ if (!d->state->matrix.isAffine())
+ paintEngineSupportsTransformations = true;
+
for (int i=0; i<count; ++i) {
QPointF processedPosition = position + glyphPositions.at(i);
if (!paintEngineSupportsTransformations)
@@ -5817,8 +5833,8 @@ void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs)
fixedPointPositions[i] = QFixedPoint::fromPointF(processedPosition);
}
- d->drawGlyphs(glyphIndexes.data(), fixedPointPositions.data(), count, font, glyphs.overline(),
- glyphs.underline(), glyphs.strikeOut());
+ d->drawGlyphs(glyphIndexes.data(), fixedPointPositions.data(), count, font, glyphRun.overline(),
+ glyphRun.underline(), glyphRun.strikeOut());
}
void QPainterPrivate::drawGlyphs(quint32 *glyphArray, QFixedPoint *positions, int glyphCount,
@@ -5853,7 +5869,7 @@ void QPainterPrivate::drawGlyphs(quint32 *glyphArray, QFixedPoint *positions, in
QFixed width = rightMost - leftMost;
- if (extended != 0) {
+ if (extended != 0 && state->matrix.isAffine()) {
QStaticTextItem staticTextItem;
staticTextItem.color = state->pen.color();
staticTextItem.font = state->font;
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index 4b2c447..601c386 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -79,7 +79,7 @@ class QTextItem;
class QMatrix;
class QTransform;
class QStaticText;
-class QGlyphs;
+class QGlyphRun;
class QPainterPrivateDeleter;
@@ -400,7 +400,7 @@ public:
Qt::LayoutDirection layoutDirection() const;
#if !defined(QT_NO_RAWFONT)
- void drawGlyphs(const QPointF &position, const QGlyphs &glyphs);
+ void drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun);
#endif
void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText);
@@ -553,6 +553,7 @@ private:
friend class QPaintEngine;
friend class QPaintEngineExPrivate;
friend class QOpenGLPaintEngine;
+ friend class QVGPaintEngine;
friend class QX11PaintEngine;
friend class QX11PaintEnginePrivate;
friend class QWin32PaintEngine;
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index 27aed32..9fbac13 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -1126,6 +1126,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
QTextEngine *eng = layout.engine();
layout.beginLayout();
QTextLine line = layout.createLine();
+ Q_UNUSED(line);
layout.endLayout();
const QScriptLine &sl = eng->lines[0];
if (!sl.length || !eng->layoutData)
diff --git a/src/gui/painting/qprintengine_pdf.cpp b/src/gui/painting/qprintengine_pdf.cpp
index b7f5160..353869f 100644
--- a/src/gui/painting/qprintengine_pdf.cpp
+++ b/src/gui/painting/qprintengine_pdf.cpp
@@ -534,7 +534,10 @@ int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_n
QImage image = img;
QImage::Format format = image.format();
- if (image.depth() == 1 && *bitmap && img.colorTable().size() == 0) {
+ if (image.depth() == 1 && *bitmap && img.colorTable().size() == 2
+ && img.colorTable().at(0) == QColor(Qt::black).rgba()
+ && img.colorTable().at(1) == QColor(Qt::white).rgba())
+ {
if (format == QImage::Format_MonoLSB)
image = image.convertToFormat(QImage::Format_Mono);
format = QImage::Format_Mono;
diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp
index fca46b4..dd723ed 100644
--- a/src/gui/painting/qstroker.cpp
+++ b/src/gui/painting/qstroker.cpp
@@ -552,6 +552,7 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine
// // line to the beginning of the arc segment, (should not be needed).
// emitLineTo(qt_real_to_fixed(curve_start.x()), qt_real_to_fixed(curve_start.y()));
+ Q_UNUSED(curve_start);
for (int i=0; i<point_count; i+=3) {
emitCubicTo(qt_real_to_fixed(curves[i].x()),
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index 53f025f..e9e56a2 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -296,7 +296,7 @@ void QTextureGlyphCache::fillInPendingGlyphs()
QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g, QFixed subPixelPosition) const
{
#if defined(Q_WS_X11)
- if (m_transform.type() > QTransform::TxTranslate) {
+ if (m_transform.type() > QTransform::TxTranslate && m_current_fontengine->type() == QFontEngine::Freetype) {
QFontEngineFT::GlyphFormat format = QFontEngineFT::Format_None;
QImage::Format imageFormat = QImage::Format_Invalid;
switch (m_type) {
diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
index 3876c3d..2fda6b9 100644
--- a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
+++ b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
@@ -152,7 +152,8 @@ void QUnifiedToolbarSurface::beginPaint(const QRegion &rgn)
void QUnifiedToolbarSurface::updateToolbarOffset(QWidget *widget)
{
QMainWindowLayout *mlayout = qobject_cast<QMainWindowLayout*> (widget->window()->layout());
- mlayout->updateUnifiedToolbarOffset();
+ if (mlayout)
+ mlayout->updateUnifiedToolbarOffset();
}
void QUnifiedToolbarSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h
index 0a7ebf1..ce07f5c 100644
--- a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h
+++ b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h
@@ -65,6 +65,39 @@ QT_BEGIN_NAMESPACE
class QNativeImage;
+//
+// This is the implementation of the unified toolbar on Mac OS X
+// with the graphics system raster.
+//
+// General idea:
+// -------------
+// We redirect the painting of widgets inside the unified toolbar
+// to a special window surface, the QUnifiedToolbarSurface.
+// We need a separate window surface because the unified toolbar
+// is out of the content view.
+// The input system is the same as for the unified toolbar with the
+// native (CoreGraphics) engine.
+//
+// Execution flow:
+// ---------------
+// The unified toolbar is triggered by QMainWindow::setUnifiedTitleAndToolBarOnMac().
+// It calls QMainWindowLayout::insertIntoMacToolbar() which will
+// set all the appropriate variables (offsets, redirection, ...).
+// When Qt tells a widget to repaint, QWidgetPrivate::drawWidget()
+// checks if the widget is inside the unified toolbar and exits without
+// painting is that is the case.
+// We trigger the rendering of the unified toolbar in QWidget::repaint()
+// and QWidget::update().
+// We keep track of flush requests via "flushRequested" variable. That
+// allow flush() to be a no-op if no repaint occurred for a widget.
+// We rely on the needsDisplay: and drawRect: mecanism for drawing our
+// content into the graphics context.
+//
+// Notes:
+// ------
+// The painting of items inside the unified toolbar is expensive.
+// Too many repaints will drastically slow down the whole application.
+//
class QUnifiedToolbarSurfacePrivate
{
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp
index cc5fe10..786aab3 100644
--- a/src/gui/styles/qcleanlooksstyle.cpp
+++ b/src/gui/styles/qcleanlooksstyle.cpp
@@ -841,7 +841,6 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem,
case PE_PanelButtonTool:
painter->save();
if ((option->state & State_Enabled || option->state & State_On) || !(option->state & State_AutoRaise)) {
- QRect rect = option->rect;
QPen oldPen = painter->pen();
if (widget && widget->inherits("QDockWidgetTitleButton")) {
@@ -1241,7 +1240,6 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem,
if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {
QColor borderColor = darkOutline.lighter(110);
QColor alphaCornerColor = mergedColors(borderColor, option->palette.background().color());
- QColor innerShadow = mergedColors(borderColor, option->palette.base().color());
int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, twf, widget);
bool reverse = (twf->direction == Qt::RightToLeft);
@@ -1879,7 +1877,6 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o
} else {
alphaCornerColor = mergedColors(option->palette.background().color(), borderColor);
}
- QColor alphaTextColor = mergedColors(option->palette.background().color(), option->palette.text().color());
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
painter->fillRect(menuItem->rect, menuBackground);
int w = 0;
@@ -2220,7 +2217,6 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o
&& tabBarAlignment == Qt::AlignLeft);
QColor light = tab->palette.light().color();
- QColor midlight = tab->palette.midlight().color();
QColor background = tab->palette.background().color();
int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
@@ -2444,14 +2440,6 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
QColor gradientStartColor = option->palette.button().color().lighter(108);
QColor gradientStopColor = mergedColors(option->palette.button().color().darker(108), dark.lighter(150), 70);
- QColor highlightedGradientStartColor = option->palette.button().color();
- QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85);
-
- QColor highlightedDarkInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 35);
- QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58);
-
- QColor buttonShadowAlpha = option->palette.background().color().darker(105);
-
QPalette palette = option->palette;
switch (control) {
@@ -3437,7 +3425,6 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
- QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget);
bool horizontal = slider->orientation == Qt::Horizontal;
bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
@@ -3539,8 +3526,6 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
QRect pixmapRect(0, 0, handle.width(), handle.height());
QPainter handlePainter(&cache);
- QColor highlightedGradientStartColor = option->palette.button().color();
- QColor highlightedGradientStopColor = option->palette.light().color();
QColor gradientStartColor = mergedColors(option->palette.button().color().lighter(155),
dark.lighter(155), 50);
QColor gradientStopColor = gradientStartColor.darker(108);
@@ -3557,7 +3542,6 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
}
// gradient fill
- QRect innerBorder = gradRect;
QRect r = pixmapRect.adjusted(1, 1, -1, -1);
qt_cleanlooks_draw_gradient(&handlePainter, gradRect,
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 3d04c9a..95ebdb4 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -916,6 +916,7 @@ static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth)
return QSizeF(widthUsed, height);
}
+
void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewItemV4 *option, const QRect &rect) const
{
Q_Q(const QCommonStyle);
@@ -933,7 +934,7 @@ void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewIt
textLayout.setFont(option->font);
textLayout.setText(option->text);
- QSizeF textLayoutSize = viewItemTextLayout(textLayout, textRect.width());
+ viewItemTextLayout(textLayout, textRect.width());
QString elidedText;
qreal height = 0;
diff --git a/src/gui/styles/qgtkpainter.cpp b/src/gui/styles/qgtkpainter.cpp
index 68ade04..6258fe4 100644
--- a/src/gui/styles/qgtkpainter.cpp
+++ b/src/gui/styles/qgtkpainter.cpp
@@ -586,7 +586,6 @@ void QGtkPainter::paintShadow(GtkWidget *gtkWidget, const gchar* part,
if (!rect.isValid())
return;
- QRect r = rect;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
@@ -605,7 +604,6 @@ void QGtkPainter::paintFlatBox(GtkWidget *gtkWidget, const gchar* part,
{
if (!rect.isValid())
return;
- QRect r = rect;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
@@ -632,7 +630,6 @@ void QGtkPainter::paintExtention(GtkWidget *gtkWidget,
if (!rect.isValid())
return;
- QRect r = rect;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
% HexString<uchar>(gap_pos);
@@ -660,7 +657,6 @@ void QGtkPainter::paintOption(GtkWidget *gtkWidget, const QRect &radiorect,
if (!rect.isValid())
return;
- QRect r = rect;
QPixmap cache;
QString pixmapName = uniqueName(detail, state, shadow, rect.size());
GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
@@ -692,7 +688,6 @@ void QGtkPainter::paintCheckbox(GtkWidget *gtkWidget, const QRect &checkrect,
if (!rect.isValid())
return;
- QRect r = rect;
QPixmap cache;
QString pixmapName = uniqueName(detail, state, shadow, rect.size());
GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index 277e302..d6dd527 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -782,7 +782,6 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GtkStateType state = gtkPainter.gtkState(option);
style = gtkTreeHeader->style;
GtkArrowType type = GTK_ARROW_UP;
- QRect r = header->rect;
QImage arrow;
// This sorting indicator inversion is intentional, and follows the GNOME HIG.
// See http://library.gnome.org/devel/hig-book/stable/controls-lists.html.en#controls-lists-sortable
@@ -1857,7 +1856,6 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
editArea.setRight(upRect.left());
}
if (spinBox->frame) {
- GtkShadowType shadow = GTK_SHADOW_OUT;
GtkStateType state = gtkPainter.gtkState(option);
if (!(option->state & State_Enabled))
@@ -1867,7 +1865,6 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
else if (state == GTK_STATE_PRELIGHT)
state = GTK_STATE_NORMAL;
- shadow = GTK_SHADOW_IN;
style = gtkPainter.getStyle(gtkSpinButton);
diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp
index 02ce60e..1d33212 100644
--- a/src/gui/styles/qplastiquestyle.cpp
+++ b/src/gui/styles/qplastiquestyle.cpp
@@ -2007,14 +2007,10 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op
} else {
alphaCornerColor = mergedColors(option->palette.background().color(), borderColor);
}
- QColor alphaTextColor = mergedColors(option->palette.background().color(), option->palette.text().color());
QColor gradientStartColor = option->palette.button().color().lighter(104);
QColor gradientStopColor = option->palette.button().color().darker(105);
- QColor shadowGradientStartColor = option->palette.button().color().darker(115);
- QColor shadowGradientStopColor = option->palette.button().color().darker(120);
-
QColor highlightedGradientStartColor = option->palette.button().color().lighter(101);
QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85);
@@ -2025,8 +2021,6 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op
QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58);
QColor alphaInnerColor = mergedColors(highlightedDarkInnerBorderColor, option->palette.base().color());
- QColor lightShadow = lightShadowGradientStartColor;
- QColor shadow = shadowGradientStartColor;
switch (element) {
#ifndef QT_NO_TABBAR
@@ -3786,10 +3780,6 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt
}
QColor gradientStartColor = option->palette.button().color().lighter(104);
QColor gradientStopColor = option->palette.button().color().darker(105);
- QColor highlightedGradientStartColor = option->palette.button().color().lighter(101);
- QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85);
- QColor highlightedDarkInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 35);
- QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58);
switch (control) {
#ifndef QT_NO_SLIDER
@@ -3797,7 +3787,6 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
QRect grooveRegion = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
- QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget);
bool horizontal = slider->orientation == Qt::Horizontal;
bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
bool ticksBelow = slider->tickPosition & QSlider::TicksBelow;
diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp
index 1dcfd00..754486e 100644
--- a/src/gui/styles/qwindowsstyle.cpp
+++ b/src/gui/styles/qwindowsstyle.cpp
@@ -2028,10 +2028,8 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
&& tabBarAlignment == Qt::AlignLeft);
QColor light = tab->palette.light().color();
- QColor midlight = tab->palette.midlight().color();
QColor dark = tab->palette.dark().color();
QColor shadow = tab->palette.shadow().color();
- QColor background = tab->palette.background().color();
int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
if (selected)
borderThinkness /= 2;
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index 8dbc746..0c7b6f8 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -239,7 +239,7 @@ public:
bool isCopyOf(const QFont &) const;
#ifdef Q_COMPILER_RVALUE_REFS
inline QFont &operator=(QFont &&other)
- { qSwap(d, other.d); return *this; }
+ { qSwap(d, other.d); qSwap(resolve_mask, other.resolve_mask); return *this; }
#endif
#ifdef Q_WS_WIN
diff --git a/src/gui/text/qfont_mac.cpp b/src/gui/text/qfont_mac.cpp
index daf68c0..044fd84 100644
--- a/src/gui/text/qfont_mac.cpp
+++ b/src/gui/text/qfont_mac.cpp
@@ -43,6 +43,7 @@
#include "qfont_p.h"
#include "qfontengine_p.h"
#include "qfontengine_mac_p.h"
+#include "qfontengine_coretext_p.h"
#include "qfontinfo.h"
#include "qfontmetrics.h"
#include "qpaintdevice.h"
@@ -119,10 +120,10 @@ quint32 QFont::macFontID() const // ### need 64-bit version
// Returns an ATSUFonFamilyRef
Qt::HANDLE QFont::handle() const
{
-#if 0
+#ifdef QT_MAC_USE_COCOA
QFontEngine *fe = d->engineForScript(QUnicodeTables::Common);
- if (fe && fe->type() == QFontEngine::Mac)
- return (Qt::HANDLE)static_cast<QFontEngineMacMulti*>(fe)->fontFamilyRef();
+ if (fe && fe->type() == QFontEngine::Multi)
+ return (Qt::HANDLE)static_cast<QCoreTextFontEngineMulti*>(fe)->macFontID();
#endif
return 0;
}
diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp
index 1db4a7d..3ab1ac8 100644
--- a/src/gui/text/qfontdatabase_s60.cpp
+++ b/src/gui/text/qfontdatabase_s60.cpp
@@ -152,7 +152,6 @@ public:
COpenFontRasterizer *m_rasterizer;
mutable QList<const QSymbianTypeFaceExtras *> m_extras;
- mutable QHash<QString, const QSymbianTypeFaceExtras *> m_extrasHash;
mutable QSet<QString> m_applicationFontFamilies;
};
@@ -255,8 +254,9 @@ void QSymbianFontDatabaseExtrasImplementation::clear()
static_cast<const QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras);
if (!dbExtras)
return; // initializeDb() has never been called
+ QSymbianTypeFaceExtrasHash &extrasHash = S60->fontData();
if (QSymbianTypeFaceExtras::symbianFontTableApiAvailable()) {
- qDeleteAll(dbExtras->m_extrasHash);
+ qDeleteAll(extrasHash);
} else {
typedef QList<const QSymbianTypeFaceExtras *>::iterator iterator;
for (iterator p = dbExtras->m_extras.begin(); p != dbExtras->m_extras.end(); ++p) {
@@ -265,11 +265,16 @@ void QSymbianFontDatabaseExtrasImplementation::clear()
}
dbExtras->m_extras.clear();
}
- dbExtras->m_extrasHash.clear();
+ extrasHash.clear();
}
void qt_cleanup_symbianFontDatabase()
{
+ static bool cleanupDone = false;
+ if (cleanupDone)
+ return;
+ cleanupDone = true;
+
QFontDatabasePrivate *db = privateDb();
if (!db)
return;
@@ -320,9 +325,12 @@ COpenFont* OpenFontFromBitmapFont(const CBitmapFont* aBitmapFont)
const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(const QString &aTypeface,
bool bold, bool italic) const
{
+ QSymbianTypeFaceExtrasHash &extrasHash = S60->fontData();
+ if (extrasHash.isEmpty() && QThread::currentThread() != QApplication::instance()->thread())
+ S60->addThreadLocalReleaseFunc(clear);
const QString typeface = qt_symbian_fontNameWithAppFontMarker(aTypeface);
const QString searchKey = typeface + QString::number(int(bold)) + QString::number(int(italic));
- if (!m_extrasHash.contains(searchKey)) {
+ if (!extrasHash.contains(searchKey)) {
TFontSpec searchSpec(qt_QString2TPtrC(typeface), 1);
if (bold)
searchSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
@@ -336,7 +344,7 @@ const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(c
QScopedPointer<CFont, CFontFromScreenDeviceReleaser> sFont(font);
QSymbianTypeFaceExtras *extras = new QSymbianTypeFaceExtras(font);
sFont.take();
- m_extrasHash.insert(searchKey, extras);
+ extrasHash.insert(searchKey, extras);
} else {
const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, searchSpec);
Q_ASSERT(err == KErrNone && font);
@@ -350,20 +358,20 @@ const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(c
const TOpenFontFaceAttrib* const attrib = openFont->FaceAttrib();
const QString foundKey =
QString((const QChar*)attrib->FullName().Ptr(), attrib->FullName().Length());
- if (!m_extrasHash.contains(foundKey)) {
+ if (!extrasHash.contains(foundKey)) {
QScopedPointer<CFont, CFontFromFontStoreReleaser> sFont(font);
QSymbianTypeFaceExtras *extras = new QSymbianTypeFaceExtras(font, openFont);
sFont.take();
m_extras.append(extras);
- m_extrasHash.insert(searchKey, extras);
- m_extrasHash.insert(foundKey, extras);
+ extrasHash.insert(searchKey, extras);
+ extrasHash.insert(foundKey, extras);
} else {
m_store->ReleaseFont(font);
- m_extrasHash.insert(searchKey, m_extrasHash.value(foundKey));
+ extrasHash.insert(searchKey, extrasHash.value(foundKey));
}
}
}
- return m_extrasHash.value(searchKey);
+ return extrasHash.value(searchKey);
}
void QSymbianFontDatabaseExtrasImplementation::removeAppFontData(
@@ -956,7 +964,7 @@ bool QFontDatabase::removeAllApplicationFonts()
bool QFontDatabase::supportsThreadedFontRendering()
{
- return false;
+ return QSymbianTypeFaceExtras::symbianFontTableApiAvailable();
}
static
diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm
index 20b3730..cbf51e6 100644
--- a/src/gui/text/qfontengine_coretext.mm
+++ b/src/gui/text/qfontengine_coretext.mm
@@ -162,8 +162,10 @@ uint QCoreTextFontEngineMulti::fontIndexForFont(CTFontRef font) const
return engines.count() - 1;
}
-bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags,
- unsigned short *logClusters, const HB_CharAttributes *) const
+bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs,
+ int *nglyphs, QTextEngine::ShaperFlags flags,
+ unsigned short *logClusters, const HB_CharAttributes *,
+ QScriptItem *si) const
{
QCFType<CFStringRef> cfstring = CFStringCreateWithCharactersNoCopy(0,
reinterpret_cast<const UniChar *>(str),
@@ -180,6 +182,8 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
&kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
typeSetter = CTTypesetterCreateWithAttributedStringAndOptions(attributedString, options);
} else
+#else
+ Q_UNUSED(flags);
#endif
typeSetter = CTTypesetterCreateWithAttributedString(attributedString);
@@ -219,6 +223,25 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
Q_ASSERT((CTRunGetStatus(run) & kCTRunStatusRightToLeft) == rtl);
CFRange stringRange = CTRunGetStringRange(run);
+ int prepend = 0;
+#if MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_5
+ UniChar beginGlyph = CFStringGetCharacterAtIndex(cfstring, stringRange.location);
+ QChar dir = QChar::direction(beginGlyph);
+ bool beginWithOverride = dir == QChar::DirLRO || dir == QChar::DirRLO || dir == QChar::DirLRE || dir == QChar::DirRLE;
+ if (beginWithOverride) {
+ logClusters[stringRange.location] = 0;
+ outGlyphs[0] = 0xFFFF;
+ outAdvances_x[0] = 0;
+ outAdvances_y[0] = 0;
+ outAttributes[0].clusterStart = true;
+ outAttributes[0].dontPrint = true;
+ outGlyphs++;
+ outAdvances_x++;
+ outAdvances_y++;
+ outAttributes++;
+ prepend = 1;
+ }
+#endif
UniChar endGlyph = CFStringGetCharacterAtIndex(cfstring, stringRange.location + stringRange.length - 1);
bool endWithPDF = QChar::direction(endGlyph) == QChar::DirPDF;
if (endWithPDF)
@@ -233,7 +256,12 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
if (!runAttribs)
runAttribs = attributeDict;
CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttribs, NSFontAttributeName));
- const uint fontIndex = (fontIndexForFont(runFont) << 24);
+ uint fontIndex = fontIndexForFont(runFont);
+ const QFontEngine *engine = engineAt(fontIndex);
+ fontIndex <<= 24;
+ si->ascent = qMax(engine->ascent(), si->ascent);
+ si->descent = qMax(engine->descent(), si->descent);
+ si->leading = qMax(engine->leading(), si->leading);
//NSLog(@"Run Font Name = %@", CTFontCopyFamilyName(runFont));
if (endWithPDF)
glyphCount--;
@@ -271,9 +299,9 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
CFIndex k = 0;
CFIndex i = 0;
- for (i = stringRange.location;
+ for (i = stringRange.location + prepend;
(i < stringRange.location + stringRange.length) && (k < glyphCount); ++i) {
- if (tmpIndices[k * rtlSign + rtlOffset] == i || i == stringRange.location) {
+ if (tmpIndices[k * rtlSign + rtlOffset] == i || i == stringRange.location + prepend) {
logClusters[i] = k + firstGlyphIndex;
outAttributes[k].clusterStart = true;
++k;
@@ -308,7 +336,7 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
: QFixed::fromReal(lastGlyphAdvance.width);
if (endWithPDF) {
- logClusters[stringRange.location + stringRange.length - 1] = glyphCount;
+ logClusters[stringRange.location + stringRange.length - 1] = glyphCount + prepend;
outGlyphs[glyphCount] = 0xFFFF;
outAdvances_x[glyphCount] = 0;
outAdvances_y[glyphCount] = 0;
@@ -837,6 +865,15 @@ QFixed QCoreTextFontEngine::emSquareSize() const
return QFixed::QFixed(int(CTFontGetUnitsPerEm(ctfont)));
}
+QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const
+{
+ QFontDef newFontDef = fontDef;
+ newFontDef.pixelSize = pixelSize;
+ newFontDef.pointSize = pixelSize * 72.0 / qt_defaultDpi();
+
+ return new QCoreTextFontEngine(cgFont, newFontDef);
+}
+
QT_END_NAMESPACE
#endif// !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
diff --git a/src/gui/text/qfontengine_coretext_p.h b/src/gui/text/qfontengine_coretext_p.h
index 1503c3f..3775bc6 100644
--- a/src/gui/text/qfontengine_coretext_p.h
+++ b/src/gui/text/qfontengine_coretext_p.h
@@ -91,6 +91,8 @@ public:
virtual qreal minLeftBearing() const;
virtual QFixed emSquareSize() const;
+ virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
+
private:
friend class QRawFontPrivate;
@@ -118,9 +120,12 @@ public:
QTextEngine::ShaperFlags flags) const;
bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
QTextEngine::ShaperFlags flags,
- unsigned short *logClusters, const HB_CharAttributes *charAttributes) const;
+ unsigned short *logClusters, const HB_CharAttributes *charAttributes,
+ QScriptItem *si) const;
virtual const char *name() const { return "CoreText"; }
+ inline CTFontRef macFontID() const { return ctfont; }
+
protected:
virtual void loadEngine(int at);
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 8f2da9b..9d4a21a 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -803,106 +803,6 @@ int QFontEngineFT::loadFlags(QGlyphSet *set, GlyphFormat format, int flags,
return load_flags;
}
-QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph, GlyphFormat format) const
-{
- Glyph *g = set->getGlyph(glyph);
- if (g && g->format == format)
- return g;
-
- bool hsubpixel = false;
- int vfactor = 1;
- int load_flags = loadFlags(set, format, 0, hsubpixel, vfactor);
-
- // apply our matrix to this, but note that the metrics will not be affected by this.
- FT_Face face = lockFace();
- FT_Matrix matrix = this->matrix;
- FT_Matrix_Multiply(&set->transformationMatrix, &matrix);
- FT_Set_Transform(face, &matrix, 0);
- freetype->matrix = matrix;
-
- bool transform = matrix.xx != 0x10000 || matrix.yy != 0x10000 || matrix.xy != 0 || matrix.yx != 0;
- if (transform)
- load_flags |= FT_LOAD_NO_BITMAP;
-
- FT_Error err = FT_Load_Glyph(face, glyph, load_flags);
- if (err && (load_flags & FT_LOAD_NO_BITMAP)) {
- load_flags &= ~FT_LOAD_NO_BITMAP;
- err = FT_Load_Glyph(face, glyph, load_flags);
- }
- if (err == FT_Err_Too_Few_Arguments) {
- // this is an error in the bytecode interpreter, just try to run without it
- load_flags |= FT_LOAD_FORCE_AUTOHINT;
- err = FT_Load_Glyph(face, glyph, load_flags);
- }
- if (err != FT_Err_Ok)
- qWarning("load glyph failed err=%x face=%p, glyph=%d", err, face, glyph);
-
- unlockFace();
- if (set->outline_drawing)
- return 0;
-
- if (!g) {
- g = new Glyph;
- g->uploadedToServer = false;
- g->data = 0;
- }
-
- FT_GlyphSlot slot = face->glyph;
- if (embolden) Q_FT_GLYPHSLOT_EMBOLDEN(slot);
- int left = slot->metrics.horiBearingX;
- int right = slot->metrics.horiBearingX + slot->metrics.width;
- int top = slot->metrics.horiBearingY;
- int bottom = slot->metrics.horiBearingY - slot->metrics.height;
- if (transform && slot->format != FT_GLYPH_FORMAT_BITMAP) { // freetype doesn't apply the transformation on the metrics
- int l, r, t, b;
- FT_Vector vector;
- vector.x = left;
- vector.y = top;
- FT_Vector_Transform(&vector, &matrix);
- l = r = vector.x;
- t = b = vector.y;
- vector.x = right;
- vector.y = top;
- FT_Vector_Transform(&vector, &matrix);
- if (l > vector.x) l = vector.x;
- if (r < vector.x) r = vector.x;
- if (t < vector.y) t = vector.y;
- if (b > vector.y) b = vector.y;
- vector.x = right;
- vector.y = bottom;
- FT_Vector_Transform(&vector, &matrix);
- if (l > vector.x) l = vector.x;
- if (r < vector.x) r = vector.x;
- if (t < vector.y) t = vector.y;
- if (b > vector.y) b = vector.y;
- vector.x = left;
- vector.y = bottom;
- FT_Vector_Transform(&vector, &matrix);
- if (l > vector.x) l = vector.x;
- if (r < vector.x) r = vector.x;
- if (t < vector.y) t = vector.y;
- if (b > vector.y) b = vector.y;
- left = l;
- right = r;
- top = t;
- bottom = b;
- }
- left = FLOOR(left);
- right = CEIL(right);
- bottom = FLOOR(bottom);
- top = CEIL(top);
-
- g->linearAdvance = face->glyph->linearHoriAdvance >> 10;
- g->width = TRUNC(right-left);
- g->height = TRUNC(top-bottom);
- g->x = TRUNC(left);
- g->y = TRUNC(top);
- g->advance = TRUNC(ROUND(face->glyph->advance.x));
- g->format = Format_None;
-
- return g;
-}
-
QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
QFixed subPixelPosition,
GlyphFormat format,
@@ -1697,7 +1597,7 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlag
FT_Face face = 0;
bool design = (default_hint_style == HintNone ||
default_hint_style == HintLight ||
- (flags & HB_ShaperFlag_UseDesignMetrics));
+ (flags & HB_ShaperFlag_UseDesignMetrics)) && FT_IS_SCALABLE(freetype->face);
for (int i = 0; i < glyphs->numGlyphs; i++) {
Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]);
if (g) {
@@ -1851,6 +1751,7 @@ glyph_metrics_t QFontEngineFT::alphaMapBoundingBox(glyph_t glyph, QFixed subPixe
} else {
glyphSet = &defaultGlyphSet;
}
+ bool needsDelete = false;
Glyph * g = glyphSet->getGlyph(glyph);
if (!g || g->format != format) {
face = lockFace();
@@ -1858,6 +1759,7 @@ glyph_metrics_t QFontEngineFT::alphaMapBoundingBox(glyph_t glyph, QFixed subPixe
FT_Matrix_Multiply(&glyphSet->transformationMatrix, &m);
freetype->matrix = m;
g = loadGlyph(glyphSet, glyph, subPixelPosition, format);
+ needsDelete = true;
}
if (g) {
@@ -1866,6 +1768,8 @@ glyph_metrics_t QFontEngineFT::alphaMapBoundingBox(glyph_t glyph, QFixed subPixe
overall.width = g->width;
overall.height = g->height;
overall.xoff = g->advance;
+ if (needsDelete)
+ delete g;
} else {
int left = FLOOR(face->glyph->metrics.horiBearingX);
int right = CEIL(face->glyph->metrics.horiBearingX + face->glyph->metrics.width);
@@ -2069,6 +1973,41 @@ HB_Error QFontEngineFT::getPointInOutline(HB_Glyph glyph, int flags, hb_uint32 p
return result;
}
+bool QFontEngineFT::initFromFontEngine(const QFontEngineFT *fe)
+{
+ if (!init(fe->faceId(), fe->antialias, fe->defaultFormat, fe->freetype))
+ return false;
+
+ // Increase the reference of this QFreetypeFace since one more QFontEngineFT
+ // will be using it
+ freetype->ref.ref();
+
+ default_load_flags = fe->default_load_flags;
+ default_hint_style = fe->default_hint_style;
+ antialias = fe->antialias;
+ transform = fe->transform;
+ embolden = fe->embolden;
+ subpixelType = fe->subpixelType;
+ lcdFilterType = fe->lcdFilterType;
+ canUploadGlyphsToServer = fe->canUploadGlyphsToServer;
+ embeddedbitmap = fe->embeddedbitmap;
+
+ return true;
+}
+
+QFontEngine *QFontEngineFT::cloneWithSize(qreal pixelSize) const
+{
+ QFontDef fontDef;
+ fontDef.pixelSize = pixelSize;
+ QFontEngineFT *fe = new QFontEngineFT(fontDef);
+ if (!fe->initFromFontEngine(this)) {
+ delete fe;
+ return 0;
+ } else {
+ return fe;
+ }
+}
+
QT_END_NAMESPACE
#endif // QT_NO_FREETYPE
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index 887efed..a620006 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -122,7 +122,7 @@ struct QFreetypeFace
static void addBitmapToPath(FT_GlyphSlot slot, const QFixedPoint &point, QPainterPath *path, bool = false);
private:
- friend class QFontEngineFTRawFont;
+ friend class QFontEngineFT;
friend class QScopedPointerDeleter<QFreetypeFace>;
QFreetypeFace() : _lock(QMutex::Recursive) {}
~QFreetypeFace() {}
@@ -319,6 +319,10 @@ private:
};
void setDefaultHintStyle(HintStyle style);
+
+ virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
+ bool initFromFontEngine(const QFontEngineFT *fontEngine);
+
HintStyle defaultHintStyle() const { return default_hint_style; }
protected:
@@ -345,7 +349,6 @@ protected:
private:
friend class QFontEngineFTRawFont;
- QFontEngineFT::Glyph *loadGlyphMetrics(QGlyphSet *set, uint glyph, GlyphFormat format) const;
int loadFlags(QGlyphSet *set, GlyphFormat format, int flags, bool &hsubpixel, int &vfactor) const;
GlyphFormat defaultFormat;
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index 673a7c8..9f094ad 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -377,7 +377,7 @@ bool QFontEngineMacMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *
}
bool QFontEngineMacMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags,
- unsigned short *logClusters, const HB_CharAttributes *charAttributes) const
+ unsigned short *logClusters, const HB_CharAttributes *charAttributes, QScriptItem *) const
{
if (*nglyphs < len) {
*nglyphs = len;
diff --git a/src/gui/text/qfontengine_mac_p.h b/src/gui/text/qfontengine_mac_p.h
index 385fa83..292ea98 100644
--- a/src/gui/text/qfontengine_mac_p.h
+++ b/src/gui/text/qfontengine_mac_p.h
@@ -131,7 +131,7 @@ public:
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags,
- unsigned short *logClusters, const HB_CharAttributes *charAttributes) const;
+ unsigned short *logClusters, const HB_CharAttributes *charAttributes, QScriptItem *) const;
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 5b39fd3..6db0aa6 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -235,6 +235,8 @@ public:
virtual int glyphCount() const;
+ virtual QFontEngine *cloneWithSize(qreal /*pixelSize*/) const { return 0; }
+
HB_Font harfbuzzFont() const;
HB_Face harfbuzzFace() const;
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index 82d9da0..54d7ec2 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -1284,6 +1284,23 @@ QImage QFontEngineWin::alphaRGBMapForGlyph(glyph_t glyph, QFixed, int margin, co
return rgbMask;
}
+// From qfontdatabase_win.cpp
+extern QFontEngine *qt_load_font_engine_win(const QFontDef &request);
+QFontEngine *QFontEngineWin::cloneWithSize(qreal pixelSize) const
+{
+ QFontDef request = fontDef;
+ QString actualFontName = request.family;
+ if (!uniqueFamilyName.isEmpty())
+ request.family = uniqueFamilyName;
+ request.pixelSize = pixelSize;
+
+ QFontEngine *fontEngine = qt_load_font_engine_win(request);
+ if (fontEngine != NULL)
+ fontEngine->fontDef.family = actualFontName;
+
+ return fontEngine;
+}
+
// -------------------------------------- Multi font engine
QFontEngineMultiWin::QFontEngineMultiWin(QFontEngine *first, const QStringList &fallbacks)
diff --git a/src/gui/text/qfontengine_win_p.h b/src/gui/text/qfontengine_win_p.h
index 28d8000..114149d 100644
--- a/src/gui/text/qfontengine_win_p.h
+++ b/src/gui/text/qfontengine_win_p.h
@@ -106,6 +106,8 @@ public:
virtual QImage alphaMapForGlyph(glyph_t, const QTransform &xform);
virtual QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, int margin, const QTransform &xform);
+ virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
+
#ifndef Q_CC_MINGW
virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
#endif
@@ -118,6 +120,7 @@ public:
#endif
QString _name;
+ QString uniqueFamilyName;
HFONT hfont;
LOGFONT logfont;
uint stockFont : 1;
diff --git a/src/gui/text/qfontengine_x11.cpp b/src/gui/text/qfontengine_x11.cpp
index 9f3f8d3..4260b85 100644
--- a/src/gui/text/qfontengine_x11.cpp
+++ b/src/gui/text/qfontengine_x11.cpp
@@ -1196,6 +1196,20 @@ bool QFontEngineX11FT::uploadGlyphToServer(QGlyphSet *set, uint glyphid, Glyph *
#endif
}
+QFontEngine *QFontEngineX11FT::cloneWithSize(qreal pixelSize) const
+{
+ QFontDef fontDef;
+ fontDef.pixelSize = pixelSize;
+ QFontEngineX11FT *fe = new QFontEngineX11FT(fontDef);
+ if (!fe->initFromFontEngine(this)) {
+ delete fe;
+ return 0;
+ } else {
+ fe->xglyph_format = xglyph_format;
+ return fe;
+ }
+}
+
#endif // QT_NO_FONTCONFIG
QT_END_NAMESPACE
diff --git a/src/gui/text/qfontengine_x11_p.h b/src/gui/text/qfontengine_x11_p.h
index ad68fac..d7eb39d 100644
--- a/src/gui/text/qfontengine_x11_p.h
+++ b/src/gui/text/qfontengine_x11_p.h
@@ -161,6 +161,8 @@ public:
explicit QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int screen);
~QFontEngineX11FT();
+ QFontEngine *cloneWithSize(qreal pixelSize) const;
+
#ifndef QT_NO_XRENDER
int xglyph_format;
#endif
diff --git a/src/gui/text/qfontenginedirectwrite.cpp b/src/gui/text/qfontenginedirectwrite.cpp
index f0a3644..aab00c0 100644
--- a/src/gui/text/qfontenginedirectwrite.cpp
+++ b/src/gui/text/qfontenginedirectwrite.cpp
@@ -630,6 +630,17 @@ QFontEngine::Type QFontEngineDirectWrite::type() const
return QFontEngine::DirectWrite;
}
+QFontEngine *QFontEngineDirectWrite::cloneWithSize(qreal pixelSize) const
+{
+ QFontEngine *fontEngine = new QFontEngineDirectWrite(m_directWriteFactory, m_directWriteFontFace,
+ pixelSize);
+
+ fontEngine->fontDef = fontDef;
+ fontEngine->fontDef.pixelSize = pixelSize;
+
+ return fontEngine;
+}
+
QT_END_NAMESPACE
#endif // QT_NO_DIRECTWRITE
diff --git a/src/gui/text/qfontenginedirectwrite_p.h b/src/gui/text/qfontenginedirectwrite_p.h
index c440a6c..53a4b0a 100644
--- a/src/gui/text/qfontenginedirectwrite_p.h
+++ b/src/gui/text/qfontenginedirectwrite_p.h
@@ -101,6 +101,8 @@ public:
QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, int margin,
const QTransform &xform);
+ QFontEngine *cloneWithSize(qreal pixelSize) const;
+
bool canRender(const QChar *string, int len);
Type type() const;
diff --git a/src/gui/text/qglyphs.cpp b/src/gui/text/qglyphrun.cpp
index b8a418d..ea52788 100644
--- a/src/gui/text/qglyphs.cpp
+++ b/src/gui/text/qglyphrun.cpp
@@ -43,14 +43,14 @@
#if !defined(QT_NO_RAWFONT)
-#include "qglyphs.h"
-#include "qglyphs_p.h"
+#include "qglyphrun.h"
+#include "qglyphrun_p.h"
QT_BEGIN_NAMESPACE
/*!
- \class QGlyphs
- \brief the QGlyphs class provides direct access to the internal glyphs in a font
+ \class QGlyphRun
+ \brief The QGlyphRun class provides direct access to the internal glyphs in a font.
\since 4.8
\ingroup text
@@ -67,42 +67,43 @@ QT_BEGIN_NAMESPACE
Under certain circumstances, it can be useful as an application developer to have more low-level
control over which glyphs in a specific font are drawn to the screen. This could for instance
be the case in applications that use an external font engine and text shaper together with Qt.
- QGlyphs provides an interface to the raw data needed to get text on the screen. It
+ QGlyphRun provides an interface to the raw data needed to get text on the screen. It
contains a list of glyph indexes, a position for each glyph and a font.
It is the user's responsibility to ensure that the selected font actually contains the
provided glyph indexes.
- QTextLayout::glyphs() or QTextFragment::glyphs() can be used to convert unicode encoded text
- into a list of QGlyphs objects, and QPainter::drawGlyphs() can be used to draw the glyphs.
+ QTextLayout::glyphRuns() or QTextFragment::glyphRuns() can be used to convert unicode encoded
+ text into a list of QGlyphRun objects, and QPainter::drawGlyphRun() can be used to draw the
+ glyphs.
- \note Please note that QRawFont is considered local to the thread in which it is constructed,
- which in turn means that a new QRawFont will have to be created and set on the QGlyphs if it is
- moved to a different thread. If the QGlyphs contains a reference to a QRawFont from a different
+ \note Please note that QRawFont is considered local to the thread in which it is constructed.
+ This in turn means that a new QRawFont will have to be created and set on the QGlyphRun if it is
+ moved to a different thread. If the QGlyphRun contains a reference to a QRawFont from a different
thread than the current, it will not be possible to draw the glyphs using a QPainter, as the
QRawFont is considered invalid and inaccessible in this case.
*/
/*!
- Constructs an empty QGlyphs object.
+ Constructs an empty QGlyphRun object.
*/
-QGlyphs::QGlyphs() : d(new QGlyphsPrivate)
+QGlyphRun::QGlyphRun() : d(new QGlyphRunPrivate)
{
}
/*!
- Constructs a QGlyphs object which is a copy of \a other.
+ Constructs a QGlyphRun object which is a copy of \a other.
*/
-QGlyphs::QGlyphs(const QGlyphs &other)
+QGlyphRun::QGlyphRun(const QGlyphRun &other)
{
d = other.d;
}
/*!
- Destroys the QGlyphs.
+ Destroys the QGlyphRun.
*/
-QGlyphs::~QGlyphs()
+QGlyphRun::~QGlyphRun()
{
// Required for QExplicitlySharedDataPointer
}
@@ -110,26 +111,26 @@ QGlyphs::~QGlyphs()
/*!
\internal
*/
-void QGlyphs::detach()
+void QGlyphRun::detach()
{
if (d->ref != 1)
d.detach();
}
/*!
- Assigns \a other to this QGlyphs object.
+ Assigns \a other to this QGlyphRun object.
*/
-QGlyphs &QGlyphs::operator=(const QGlyphs &other)
+QGlyphRun &QGlyphRun::operator=(const QGlyphRun &other)
{
d = other.d;
return *this;
}
/*!
- Compares \a other to this QGlyphs object. Returns true if the list of glyph indexes,
+ Compares \a other to this QGlyphRun object. Returns true if the list of glyph indexes,
the list of positions and the font are all equal, otherwise returns false.
*/
-bool QGlyphs::operator==(const QGlyphs &other) const
+bool QGlyphRun::operator==(const QGlyphRun &other) const
{
return ((d == other.d)
|| (d->glyphIndexes == other.d->glyphIndexes
@@ -137,14 +138,14 @@ bool QGlyphs::operator==(const QGlyphs &other) const
&& d->overline == other.d->overline
&& d->underline == other.d->underline
&& d->strikeOut == other.d->strikeOut
- && d->font == other.d->font));
+ && d->rawFont == other.d->rawFont));
}
/*!
- Compares \a other to this QGlyphs object. Returns true if any of the list of glyph
+ Compares \a other to this QGlyphRun object. Returns true if any of the list of glyph
indexes, the list of positions or the font are different, otherwise returns false.
*/
-bool QGlyphs::operator!=(const QGlyphs &other) const
+bool QGlyphRun::operator!=(const QGlyphRun &other) const
{
return !(*this == other);
}
@@ -152,13 +153,13 @@ bool QGlyphs::operator!=(const QGlyphs &other) const
/*!
\internal
- Adds together the lists of glyph indexes and positions in \a other and this QGlyphs
- object and returns the result. The font in the returned QGlyphs will be the same as in
- this QGlyphs object.
+ Adds together the lists of glyph indexes and positions in \a other and this QGlyphRun
+ object and returns the result. The font in the returned QGlyphRun will be the same as in
+ this QGlyphRun object.
*/
-QGlyphs QGlyphs::operator+(const QGlyphs &other) const
+QGlyphRun QGlyphRun::operator+(const QGlyphRun &other) const
{
- QGlyphs ret(*this);
+ QGlyphRun ret(*this);
ret += other;
return ret;
}
@@ -166,10 +167,10 @@ QGlyphs QGlyphs::operator+(const QGlyphs &other) const
/*!
\internal
- Appends the glyph indexes and positions in \a other to this QGlyphs object and returns
+ Appends the glyph indexes and positions in \a other to this QGlyphRun object and returns
a reference to the current object.
*/
-QGlyphs &QGlyphs::operator+=(const QGlyphs &other)
+QGlyphRun &QGlyphRun::operator+=(const QGlyphRun &other)
{
detach();
@@ -180,41 +181,41 @@ QGlyphs &QGlyphs::operator+=(const QGlyphs &other)
}
/*!
- Returns the font selected for this QGlyphs object.
+ Returns the font selected for this QGlyphRun object.
- \sa setFont()
+ \sa setRawFont()
*/
-QRawFont QGlyphs::font() const
+QRawFont QGlyphRun::rawFont() const
{
- return d->font;
+ return d->rawFont;
}
/*!
Sets the font in which to look up the glyph indexes to \a font.
- \sa font(), setGlyphIndexes()
+ \sa rawFont(), setGlyphIndexes()
*/
-void QGlyphs::setFont(const QRawFont &font)
+void QGlyphRun::setRawFont(const QRawFont &rawFont)
{
detach();
- d->font = font;
+ d->rawFont = rawFont;
}
/*!
- Returns the glyph indexes for this QGlyphs object.
+ Returns the glyph indexes for this QGlyphRun object.
\sa setGlyphIndexes(), setPositions()
*/
-QVector<quint32> QGlyphs::glyphIndexes() const
+QVector<quint32> QGlyphRun::glyphIndexes() const
{
return d->glyphIndexes;
}
/*!
- Set the glyph indexes for this QGlyphs object to \a glyphIndexes. The glyph indexes must
+ Set the glyph indexes for this QGlyphRun object to \a glyphIndexes. The glyph indexes must
be valid for the selected font.
*/
-void QGlyphs::setGlyphIndexes(const QVector<quint32> &glyphIndexes)
+void QGlyphRun::setGlyphIndexes(const QVector<quint32> &glyphIndexes)
{
detach();
d->glyphIndexes = glyphIndexes;
@@ -223,7 +224,7 @@ void QGlyphs::setGlyphIndexes(const QVector<quint32> &glyphIndexes)
/*!
Returns the position of the edge of the baseline for each glyph in this set of glyph indexes.
*/
-QVector<QPointF> QGlyphs::positions() const
+QVector<QPointF> QGlyphRun::positions() const
{
return d->glyphPositions;
}
@@ -232,87 +233,87 @@ QVector<QPointF> QGlyphs::positions() const
Sets the positions of the edge of the baseline for each glyph in this set of glyph indexes to
\a positions.
*/
-void QGlyphs::setPositions(const QVector<QPointF> &positions)
+void QGlyphRun::setPositions(const QVector<QPointF> &positions)
{
detach();
d->glyphPositions = positions;
}
/*!
- Clears all data in the QGlyphs object.
+ Clears all data in the QGlyphRun object.
*/
-void QGlyphs::clear()
+void QGlyphRun::clear()
{
detach();
d->glyphPositions = QVector<QPointF>();
d->glyphIndexes = QVector<quint32>();
- d->font = QRawFont();
+ d->rawFont = QRawFont();
d->strikeOut = false;
d->overline = false;
d->underline = false;
}
/*!
- Returns true if this QGlyphs should be painted with an overline decoration.
+ Returns true if this QGlyphRun should be painted with an overline decoration.
\sa setOverline()
*/
-bool QGlyphs::overline() const
+bool QGlyphRun::overline() const
{
return d->overline;
}
/*!
- Indicates that this QGlyphs should be painted with an overline decoration if \a overline is true.
- Otherwise the QGlyphs should be painted with no overline decoration.
+ Indicates that this QGlyphRun should be painted with an overline decoration if \a overline is true.
+ Otherwise the QGlyphRun should be painted with no overline decoration.
\sa overline()
*/
-void QGlyphs::setOverline(bool overline)
+void QGlyphRun::setOverline(bool overline)
{
detach();
d->overline = overline;
}
/*!
- Returns true if this QGlyphs should be painted with an underline decoration.
+ Returns true if this QGlyphRun should be painted with an underline decoration.
\sa setUnderline()
*/
-bool QGlyphs::underline() const
+bool QGlyphRun::underline() const
{
return d->underline;
}
/*!
- Indicates that this QGlyphs should be painted with an underline decoration if \a underline is
- true. Otherwise the QGlyphs should be painted with no underline decoration.
+ Indicates that this QGlyphRun should be painted with an underline decoration if \a underline is
+ true. Otherwise the QGlyphRun should be painted with no underline decoration.
\sa underline()
*/
-void QGlyphs::setUnderline(bool underline)
+void QGlyphRun::setUnderline(bool underline)
{
detach();
d->underline = underline;
}
/*!
- Returns true if this QGlyphs should be painted with a strike out decoration.
+ Returns true if this QGlyphRun should be painted with a strike out decoration.
\sa setStrikeOut()
*/
-bool QGlyphs::strikeOut() const
+bool QGlyphRun::strikeOut() const
{
return d->strikeOut;
}
/*!
- Indicates that this QGlyphs should be painted with an strike out decoration if \a strikeOut is
- true. Otherwise the QGlyphs should be painted with no strike out decoration.
+ Indicates that this QGlyphRun should be painted with an strike out decoration if \a strikeOut is
+ true. Otherwise the QGlyphRun should be painted with no strike out decoration.
\sa strikeOut()
*/
-void QGlyphs::setStrikeOut(bool strikeOut)
+void QGlyphRun::setStrikeOut(bool strikeOut)
{
detach();
d->strikeOut = strikeOut;
diff --git a/src/gui/text/qglyphs.h b/src/gui/text/qglyphrun.h
index 4d7dcaf..dcc166e 100644
--- a/src/gui/text/qglyphs.h
+++ b/src/gui/text/qglyphrun.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QGLYPHS_H
-#define QGLYPHS_H
+#ifndef QGLYPHRUN_H
+#define QGLYPHRUN_H
#include <QtCore/qsharedpointer.h>
#include <QtCore/qvector.h>
@@ -55,16 +55,16 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
-class QGlyphsPrivate;
-class Q_GUI_EXPORT QGlyphs
+class QGlyphRunPrivate;
+class Q_GUI_EXPORT QGlyphRun
{
public:
- QGlyphs();
- QGlyphs(const QGlyphs &other);
- ~QGlyphs();
+ QGlyphRun();
+ QGlyphRun(const QGlyphRun &other);
+ ~QGlyphRun();
- QRawFont font() const;
- void setFont(const QRawFont &font);
+ QRawFont rawFont() const;
+ void setRawFont(const QRawFont &rawFont);
QVector<quint32> glyphIndexes() const;
void setGlyphIndexes(const QVector<quint32> &glyphIndexes);
@@ -74,9 +74,9 @@ public:
void clear();
- QGlyphs &operator=(const QGlyphs &other);
- bool operator==(const QGlyphs &other) const;
- bool operator!=(const QGlyphs &other) const;
+ QGlyphRun &operator=(const QGlyphRun &other);
+ bool operator==(const QGlyphRun &other) const;
+ bool operator!=(const QGlyphRun &other) const;
void setOverline(bool overline);
bool overline() const;
@@ -88,14 +88,14 @@ public:
bool strikeOut() const;
private:
- friend class QGlyphsPrivate;
+ friend class QGlyphRunPrivate;
friend class QTextLine;
- QGlyphs operator+(const QGlyphs &other) const;
- QGlyphs &operator+=(const QGlyphs &other);
+ QGlyphRun operator+(const QGlyphRun &other) const;
+ QGlyphRun &operator+=(const QGlyphRun &other);
void detach();
- QExplicitlySharedDataPointer<QGlyphsPrivate> d;
+ QExplicitlySharedDataPointer<QGlyphRunPrivate> d;
};
QT_END_NAMESPACE
diff --git a/src/gui/text/qglyphs_p.h b/src/gui/text/qglyphrun_p.h
index 944f777..4aa01d6 100644
--- a/src/gui/text/qglyphs_p.h
+++ b/src/gui/text/qglyphrun_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QGLYPHS_P_H
-#define QGLYPHS_P_H
+#ifndef QGLYPHRUN_P_H
+#define QGLYPHRUN_P_H
//
// W A R N I N G
@@ -53,7 +53,7 @@
// We mean it.
//
-#include "qglyphs.h"
+#include "qglyphrun.h"
#include "qrawfont.h"
#include <qfont.h>
@@ -64,21 +64,21 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QGlyphsPrivate: public QSharedData
+class QGlyphRunPrivate: public QSharedData
{
public:
- QGlyphsPrivate()
+ QGlyphRunPrivate()
: overline(false)
, underline(false)
, strikeOut(false)
{
}
- QGlyphsPrivate(const QGlyphsPrivate &other)
+ QGlyphRunPrivate(const QGlyphRunPrivate &other)
: QSharedData(other)
, glyphIndexes(other.glyphIndexes)
, glyphPositions(other.glyphPositions)
- , font(other.font)
+ , rawFont(other.rawFont)
, overline(other.overline)
, underline(other.underline)
, strikeOut(other.strikeOut)
@@ -87,7 +87,7 @@ public:
QVector<quint32> glyphIndexes;
QVector<QPointF> glyphPositions;
- QRawFont font;
+ QRawFont rawFont;
uint overline : 1;
uint underline : 1;
diff --git a/src/gui/text/qplatformfontdatabase_qpa.cpp b/src/gui/text/qplatformfontdatabase_qpa.cpp
index 6fa25e7..82ec279 100644
--- a/src/gui/text/qplatformfontdatabase_qpa.cpp
+++ b/src/gui/text/qplatformfontdatabase_qpa.cpp
@@ -218,6 +218,16 @@ QFontEngine *QPlatformFontDatabase::fontEngine(const QFontDef &fontDef, QUnicode
return engine;
}
+QFontEngine *QPlatformFontDatabase::fontEngine(const QByteArray &fontData, qreal pixelSize,
+ QFont::HintingPreference hintingPreference)
+{
+ Q_UNUSED(fontData);
+ Q_UNUSED(pixelSize);
+ Q_UNUSED(hintingPreference);
+ qWarning("This plugin does not support font engines created directly from font data");
+ return 0;
+}
+
/*!
*/
diff --git a/src/gui/text/qplatformfontdatabase_qpa.h b/src/gui/text/qplatformfontdatabase_qpa.h
index e0e4f04..046311f 100644
--- a/src/gui/text/qplatformfontdatabase_qpa.h
+++ b/src/gui/text/qplatformfontdatabase_qpa.h
@@ -92,6 +92,8 @@ public:
virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
virtual void releaseHandle(void *handle);
+ virtual QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference);
+
virtual QString fontDir() const;
//callback
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 4a715c2..44ddfd2 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE
A QRawFont object represents a single, physical instance of a given font in a given pixel size.
I.e. in the typical case it represents a set of TrueType or OpenType font tables and uses a
user specified pixel size to convert metrics into logical pixel units. In can be used in
- combination with the QGlyphs class to draw specific glyph indexes at specific positions, and
+ combination with the QGlyphRun class to draw specific glyph indexes at specific positions, and
also have accessors to some relevant data in the physical font.
QRawFont only provides support for the main font technologies: GDI and DirectWrite on Windows
@@ -87,9 +87,9 @@ QT_BEGIN_NAMESPACE
QRawFont can be constructed in a number of ways:
\list
- \o \l It can be constructed by calling QTextLayout::glyphs() or QTextFragment::glyphs(). The
- returned QGlyphs objects will contain QRawFont objects which represent the actual fonts
- used to render each portion of the text.
+ \o \l It can be constructed by calling QTextLayout::glyphRuns() or QTextFragment::glyphRuns().
+ The returned QGlyphRun objects will contain QRawFont objects which represent the actual
+ fonts used to render each portion of the text.
\o \l It can be constructed by passing a QFont object to QRawFont::fromFont(). The function
will return a QRawFont object representing the font that will be selected as response to
the QFont query and the selected writing system.
@@ -234,7 +234,7 @@ void QRawFont::loadFromData(const QByteArray &fontData,
the pixel in the rasterization of the glyph. Otherwise, the image will be in the format of
QImage::Format_A8 and each pixel will contain the opacity of the pixel in the rasterization.
- \sa pathForGlyph(), QPainter::drawGlyphs()
+ \sa pathForGlyph(), QPainter::drawGlyphRun()
*/
QImage QRawFont::alphaMapForGlyph(quint32 glyphIndex, AntialiasingType antialiasingType,
const QTransform &transform) const
@@ -302,16 +302,68 @@ qreal QRawFont::descent() const
}
/*!
+ Returns the xHeight of this QRawFont in pixel units.
+
+ \sa QFontMetricsF::xHeight()
+*/
+qreal QRawFont::xHeight() const
+{
+ if (!isValid())
+ return 0.0;
+
+ return d->fontEngine->xHeight().toReal();
+}
+
+/*!
+ Returns the leading of this QRawFont in pixel units.
+
+ \sa QFontMetricsF::leading()
+*/
+qreal QRawFont::leading() const
+{
+ if (!isValid())
+ return 0.0;
+
+ return d->fontEngine->leading().toReal();
+}
+
+/*!
+ Returns the average character width of this QRawFont in pixel units.
+
+ \sa QFontMetricsF::averageCharWidth()
+*/
+qreal QRawFont::averageCharWidth() const
+{
+ if (!isValid())
+ return 0.0;
+
+ return d->fontEngine->averageCharWidth().toReal();
+}
+
+/*!
+ Returns the width of the widest character in the font.
+
+ \sa QFontMetricsF::maxWidth()
+*/
+qreal QRawFont::maxCharWidth() const
+{
+ if (!isValid())
+ return 0.0;
+
+ return d->fontEngine->maxCharWidth();
+}
+
+/*!
Returns the pixel size set for this QRawFont. The pixel size affects how glyphs are
rasterized, the size of glyphs returned by pathForGlyph(), and is used to convert
internal metrics from design units to logical pixel units.
\sa setPixelSize()
*/
-int QRawFont::pixelSize() const
+qreal QRawFont::pixelSize() const
{
if (!isValid())
- return -1;
+ return 0.0;
return d->fontEngine->fontDef.pixelSize;
}
@@ -374,9 +426,9 @@ int QRawFont::weight() const
underlying font. Note that in cases where there are other tables in the font that affect the
shaping of the text, the returned glyph indexes will not correctly represent the rendering
of the text. To get the correctly shaped text, you can use QTextLayout to lay out and shape the
- text, and then call QTextLayout::glyphs() to get the set of glyph index list and QRawFont pairs.
+ text, and then call QTextLayout::glyphRuns() to get the set of glyph index list and QRawFont pairs.
- \sa advancesForGlyphIndexes(), QGlyphs, QTextLayout::glyphs(), QTextFragment::glyphs()
+ \sa advancesForGlyphIndexes(), glyphIndexesForChars(), QGlyphRun, QTextLayout::glyphRuns(), QTextFragment::glyphRuns()
*/
QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const
{
@@ -385,11 +437,9 @@ QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const
int nglyphs = text.size();
QVarLengthGlyphLayoutArray glyphs(nglyphs);
- if (!d->fontEngine->stringToCMap(text.data(), text.size(), &glyphs, &nglyphs,
- QTextEngine::GlyphIndicesOnly)) {
+ if (!glyphIndexesForChars(text.data(), text.size(), glyphs.glyphs, &nglyphs)) {
glyphs.resize(nglyphs);
- if (!d->fontEngine->stringToCMap(text.data(), text.size(), &glyphs, &nglyphs,
- QTextEngine::GlyphIndicesOnly)) {
+ if (!glyphIndexesForChars(text.data(), text.size(), glyphs.glyphs, &nglyphs)) {
Q_ASSERT_X(false, Q_FUNC_INFO, "stringToCMap shouldn't fail twice");
return QVector<quint32>();
}
@@ -403,6 +453,26 @@ QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const
}
/*!
+ Converts a string of unicode points to glyph indexes using the CMAP table in the
+ underlying font. The function works like glyphIndexesForString() except it take
+ an array (\a chars), the results will be returned though \a glyphIndexes array
+ and number of glyphs will be set in \a numGlyphs. The size of \a glyphIndexes array
+ must be at least \a numChars, if that's still not enough, this function will return
+ false, then you can resize \a glyphIndexes from the size returned in \a numGlyphs.
+
+ \sa glyphIndexesForString(), advancesForGlyphIndexes(), QGlyphs, QTextLayout::glyphs(), QTextFragment::glyphs()
+*/
+bool QRawFont::glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const
+{
+ if (!isValid())
+ return false;
+
+ QGlyphLayout glyphs;
+ glyphs.glyphs = glyphIndexes;
+ return d->fontEngine->stringToCMap(chars, numChars, &glyphs, numGlyphs, QTextEngine::GlyphIndicesOnly);
+}
+
+/*!
Returns the QRawFont's advances for each of the \a glyphIndexes in pixel units. The advances
give the distance from the position of a given glyph to where the next glyph should be drawn
to make it appear as if the two glyphs are unspaced.
@@ -428,6 +498,36 @@ QVector<QPointF> QRawFont::advancesForGlyphIndexes(const QVector<quint32> &glyph
}
/*!
+ Returns the QRawFont's advances for each of the \a glyphIndexes in pixel units. The advances
+ give the distance from the position of a given glyph to where the next glyph should be drawn
+ to make it appear as if the two glyphs are unspaced. The glyph indexes are given with the
+ array \a glyphIndexes while the results are returned through \a advances, both of them must
+ have \a numGlyphs elements.
+
+ \sa QTextLine::horizontalAdvance(), QFontMetricsF::width()
+*/
+bool QRawFont::advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const
+{
+ if (!isValid())
+ return false;
+
+ QGlyphLayout glyphs;
+ glyphs.glyphs = const_cast<HB_Glyph *>(glyphIndexes);
+ glyphs.numGlyphs = numGlyphs;
+ QVarLengthArray<QFixed> advances_x(numGlyphs);
+ QVarLengthArray<QFixed> advances_y(numGlyphs);
+ glyphs.advances_x = advances_x.data();
+ glyphs.advances_y = advances_y.data();
+
+ d->fontEngine->recalcAdvances(&glyphs, 0);
+
+ for (int i=0; i<numGlyphs; ++i)
+ advances[i] = QPointF(glyphs.advances_x[i].toReal(), glyphs.advances_y[i].toReal());
+
+ return true;
+}
+
+/*!
Returns the hinting preference used to construct this QRawFont.
\sa QFont::hintingPreference()
@@ -535,17 +635,17 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ
layout.beginLayout();
QTextLine line = layout.createLine();
layout.endLayout();
- QList<QGlyphs> list = layout.glyphs();
+ QList<QGlyphRun> list = layout.glyphRuns();
if (list.size()) {
// Pick the one matches the family name we originally requested,
// if none of them match, just pick the first one
for (int i = 0; i < list.size(); i++) {
- QGlyphs glyphs = list.at(i);
- QRawFont rawfont = glyphs.font();
+ QGlyphRun glyphs = list.at(i);
+ QRawFont rawfont = glyphs.rawFont();
if (rawfont.familyName() == font.family())
return rawfont;
}
- return list.at(0).font();
+ return list.at(0).rawFont();
}
return QRawFont();
#else
@@ -577,10 +677,21 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ
/*!
Sets the pixel size with which this font should be rendered to \a pixelSize.
*/
-void QRawFont::setPixelSize(int pixelSize)
+void QRawFont::setPixelSize(qreal pixelSize)
{
+ if (d->fontEngine == 0)
+ return;
+
detach();
- d->platformSetPixelSize(pixelSize);
+ QFontEngine *oldFontEngine = d->fontEngine;
+
+ d->fontEngine = d->fontEngine->cloneWithSize(pixelSize);
+ if (d->fontEngine != 0)
+ d->fontEngine->ref.ref();
+
+ oldFontEngine->ref.deref();
+ if (oldFontEngine->cache_count == 0 && oldFontEngine->ref == 0)
+ delete oldFontEngine;
}
/*!
diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h
index 96dc838..3875fec 100644
--- a/src/gui/text/qrawfont.h
+++ b/src/gui/text/qrawfont.h
@@ -90,19 +90,25 @@ public:
QVector<quint32> glyphIndexesForString(const QString &text) const;
QVector<QPointF> advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes) const;
+ bool glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const;
+ bool advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const;
QImage alphaMapForGlyph(quint32 glyphIndex,
AntialiasingType antialiasingType = SubPixelAntialiasing,
const QTransform &transform = QTransform()) const;
QPainterPath pathForGlyph(quint32 glyphIndex) const;
- void setPixelSize(int pixelSize);
- int pixelSize() const;
+ void setPixelSize(qreal pixelSize);
+ qreal pixelSize() const;
QFont::HintingPreference hintingPreference() const;
qreal ascent() const;
qreal descent() const;
+ qreal leading() const;
+ qreal xHeight() const;
+ qreal averageCharWidth() const;
+ qreal maxCharWidth() const;
qreal unitsPerEm() const;
diff --git a/src/gui/text/qrawfont_ft.cpp b/src/gui/text/qrawfont_ft.cpp
index eefbd92..23d47eb 100644
--- a/src/gui/text/qrawfont_ft.cpp
+++ b/src/gui/text/qrawfont_ft.cpp
@@ -90,32 +90,6 @@ public:
return init(faceId, true, Format_None, fontData);
}
-
- bool initFromFontEngine(QFontEngine *oldFontEngine)
- {
- QFontEngineFT *fe = static_cast<QFontEngineFT *>(oldFontEngine);
-
- // Increase the reference of this QFreetypeFace since one more QFontEngineFT
- // will be using it
- fe->freetype->ref.ref();
- if (!init(fe->faceId(), fe->antialias, fe->defaultFormat, fe->freetype))
- return false;
-
- default_load_flags = fe->default_load_flags;
- default_hint_style = fe->default_hint_style;
- antialias = fe->antialias;
- transform = fe->transform;
- embolden = fe->embolden;
- subpixelType = fe->subpixelType;
- lcdFilterType = fe->lcdFilterType;
- canUploadGlyphsToServer = fe->canUploadGlyphsToServer;
- embeddedbitmap = fe->embeddedbitmap;
-
-#if defined(Q_WS_X11)
- xglyph_format = static_cast<QFontEngineX11FT *>(fe)->xglyph_format;
-#endif
- return true;
- }
};
@@ -159,31 +133,6 @@ void QRawFontPrivate::platformLoadFromData(const QByteArray &fontData, int pixel
fontEngine->ref.ref();
}
-void QRawFontPrivate::platformSetPixelSize(int pixelSize)
-{
- if (fontEngine == NULL)
- return;
-
- QFontEngine *oldFontEngine = fontEngine;
-
- QFontDef fontDef;
- fontDef.pixelSize = pixelSize;
- QFontEngineFTRawFont *fe = new QFontEngineFTRawFont(fontDef);
- if (!fe->initFromFontEngine(oldFontEngine)) {
- delete fe;
- return;
- }
-
- fontEngine = fe;
- fontEngine->fontDef = oldFontEngine->fontDef;
- fontEngine->fontDef.pixelSize = pixelSize;
- fontEngine->ref.ref();
- Q_ASSERT(fontEngine != oldFontEngine);
- oldFontEngine->ref.deref();
- if (oldFontEngine->cache_count == 0 && oldFontEngine->ref == 0)
- delete oldFontEngine;
-}
-
QT_END_NAMESPACE
#endif // QT_NO_RAWFONT
diff --git a/src/gui/text/qrawfont_mac.cpp b/src/gui/text/qrawfont_mac.cpp
index 56005c6..1ed4185 100644
--- a/src/gui/text/qrawfont_mac.cpp
+++ b/src/gui/text/qrawfont_mac.cpp
@@ -78,28 +78,6 @@ void QRawFontPrivate::platformLoadFromData(const QByteArray &fontData,
}
}
-void QRawFontPrivate::platformSetPixelSize(int pixelSize)
-{
- if (fontEngine == NULL)
- return;
-
- QFontEngine *oldFontEngine = fontEngine;
-
- QFontDef fontDef = oldFontEngine->fontDef;
- fontDef.pixelSize = pixelSize;
- fontDef.pointSize = pixelSize * 72.0 / qt_defaultDpi();
-
- QCoreTextFontEngine *ctFontEngine = static_cast<QCoreTextFontEngine *>(oldFontEngine);
- Q_ASSERT(ctFontEngine->cgFont);
-
- fontEngine = new QCoreTextFontEngine(ctFontEngine->cgFont, fontDef);
- fontEngine->ref.ref();
- Q_ASSERT(fontEngine != oldFontEngine);
- oldFontEngine->ref.deref();
- if (oldFontEngine->cache_count == 0 && oldFontEngine->ref == 0)
- delete oldFontEngine;
-}
-
QT_END_NAMESPACE
#endif // QT_NO_RAWFONT
diff --git a/src/gui/text/qrawfont_p.h b/src/gui/text/qrawfont_p.h
index f9a9ab5..e29ea9c 100644
--- a/src/gui/text/qrawfont_p.h
+++ b/src/gui/text/qrawfont_p.h
@@ -83,7 +83,6 @@ public:
, fontHandle(NULL)
, ptrAddFontMemResourceEx(other.ptrAddFontMemResourceEx)
, ptrRemoveFontMemResourceEx(other.ptrRemoveFontMemResourceEx)
- , uniqueFamilyName(other.uniqueFamilyName)
#endif
{
fontEngine = other.fontEngine;
@@ -102,7 +101,6 @@ public:
void platformLoadFromData(const QByteArray &fontData,
int pixelSize,
QFont::HintingPreference hintingPreference);
- void platformSetPixelSize(int pixelSize);
static QRawFontPrivate *get(const QRawFont &font) { return font.d.data(); }
@@ -120,8 +118,6 @@ public:
PtrAddFontMemResourceEx ptrAddFontMemResourceEx;
PtrRemoveFontMemResourceEx ptrRemoveFontMemResourceEx;
- QString uniqueFamilyName;
-
#endif // Q_WS_WIN
};
diff --git a/src/gui/util/qscroller_mac.mm b/src/gui/text/qrawfont_qpa.cpp
index 4bf69c1..103619c 100644
--- a/src/gui/util/qscroller_mac.mm
+++ b/src/gui/text/qrawfont_qpa.cpp
@@ -41,31 +41,29 @@
#include <QtCore/qglobal.h>
-#ifdef Q_WS_MAC
+#if !defined(QT_NO_RAWFONT)
-#import <Cocoa/Cocoa.h>
+#include "qrawfont_p.h"
+#include <QtGui/qplatformfontdatabase_qpa.h>
+#include <private/qapplication_p.h>
-#include "qscroller_p.h"
+QT_BEGIN_NAMESPACE
-QPointF QScrollerPrivate::realDpi(int screen)
+void QRawFontPrivate::platformCleanUp()
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSArray *nsscreens = [NSScreen screens];
-
- if (screen < 0 || screen >= int([nsscreens count]))
- screen = 0;
+}
- NSScreen *nsscreen = [nsscreens objectAtIndex:screen];
- CGDirectDisplayID display = [[[nsscreen deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
+void QRawFontPrivate::platformLoadFromData(const QByteArray &fontData, int pixelSize,
+ QFont::HintingPreference hintingPreference)
+{
+ Q_ASSERT(fontEngine == 0);
- CGSize mmsize = CGDisplayScreenSize(display);
- if (mmsize.width > 0 && mmsize.height > 0) {
- return QPointF(CGDisplayPixelsWide(display) / mmsize.width,
- CGDisplayPixelsHigh(display) / mmsize.height) * qreal(25.4);
- } else {
- return QPointF();
- }
- [pool release];
+ QPlatformFontDatabase *pfdb = QApplicationPrivate::platformIntegration()->fontDatabase();
+ fontEngine = pfdb->fontEngine(fontData, pixelSize, hintingPreference);
+ if (fontEngine != 0)
+ fontEngine->ref.ref();
}
-#endif
+QT_END_NAMESPACE
+
+#endif // QT_NO_RAWFONT
diff --git a/src/gui/text/qrawfont_win.cpp b/src/gui/text/qrawfont_win.cpp
index fb5c6f4..d8acf57 100644
--- a/src/gui/text/qrawfont_win.cpp
+++ b/src/gui/text/qrawfont_win.cpp
@@ -559,7 +559,7 @@ void QRawFontPrivate::platformLoadFromData(const QByteArray &_fontData,
GUID guid;
CoCreateGuid(&guid);
- uniqueFamilyName = QString::fromLatin1("f")
+ QString uniqueFamilyName = QString::fromLatin1("f")
+ QString::number(guid.Data1, 36) + QLatin1Char('-')
+ QString::number(guid.Data2, 36) + QLatin1Char('-')
+ QString::number(guid.Data3, 36) + QLatin1Char('-')
@@ -613,6 +613,7 @@ void QRawFontPrivate::platformLoadFromData(const QByteArray &_fontData,
Q_ASSERT(fontEngine->cache_count == 0 && fontEngine->ref == 0);
// Override the generated font name
+ static_cast<QFontEngineWin *>(fontEngine)->uniqueFamilyName = uniqueFamilyName;
fontEngine->fontDef.family = actualFontName;
fontEngine->ref.ref();
}
@@ -701,50 +702,6 @@ void QRawFontPrivate::platformLoadFromData(const QByteArray &_fontData,
}
}
-void QRawFontPrivate::platformSetPixelSize(int pixelSize)
-{
- if (fontEngine == NULL)
- return;
-
- QFontEngine *oldFontEngine = fontEngine;
-
-#if !defined(QT_NO_DIRECTWRITE)
- if (fontEngine->type() == QFontEngine::Win)
-#endif
-
- {
- QFontDef request = fontEngine->fontDef;
- QString actualFontName = request.family;
- if (!uniqueFamilyName.isEmpty())
- request.family = uniqueFamilyName;
- request.pixelSize = pixelSize;
-
- fontEngine = qt_load_font_engine_win(request);
- if (fontEngine != NULL) {
- fontEngine->fontDef.family = actualFontName;
- fontEngine->ref.ref();
- }
- }
-
-#if !defined(QT_NO_DIRECTWRITE)
- else {
- QFontEngineDirectWrite *dWriteFE = static_cast<QFontEngineDirectWrite *>(fontEngine);
- fontEngine = new QFontEngineDirectWrite(dWriteFE->m_directWriteFactory,
- dWriteFE->m_directWriteFontFace,
- pixelSize);
-
- fontEngine->fontDef = dWriteFE->fontDef;
- fontEngine->fontDef.pixelSize = pixelSize;
- fontEngine->ref.ref();
- }
-#endif
-
- Q_ASSERT(fontEngine != oldFontEngine);
- oldFontEngine->ref.deref();
- if (oldFontEngine->cache_count == 0 && oldFontEngine->ref == 0)
- delete oldFontEngine;
-}
-
QT_END_NAMESPACE
#endif // QT_NO_RAWFONT
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index 4396730..a8bf763 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -677,7 +677,7 @@ void QTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition, qrea
const qreal wordEndX = line.cursorToX(curs.position() - blockPos) + blockCoordinates.x();
- if (mouseXPosition < wordStartX || mouseXPosition > wordEndX)
+ if (!wordSelectionEnabled && (mouseXPosition < wordStartX || mouseXPosition > wordEndX))
return;
// keep the already selected word even when moving to the left
@@ -1579,8 +1579,10 @@ void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, con
emit q->cursorPositionChanged();
_q_updateCurrentCharFormatAndSelection();
} else {
- if (cursor.position() != oldCursorPos)
+ if (cursor.position() != oldCursorPos) {
emit q->cursorPositionChanged();
+ emit q->microFocusChanged();
+ }
selectionChanged();
}
repaintOldAndNewSelection(oldSelection);
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index 6ddfdb0..17bcc6c 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -362,20 +362,23 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
currentCharFormat = -1;
bool adjustX = true;
QTextBlock blockIt = block();
+ bool visualMovement = priv->defaultCursorMoveStyle == Qt::VisualMoveStyle;
if (!blockIt.isValid())
return false;
- if (op >= QTextCursor::Left && op <= QTextCursor::WordRight
- && blockIt.textDirection() == Qt::RightToLeft) {
- if (op == QTextCursor::Left)
- op = QTextCursor::NextCharacter;
- else if (op == QTextCursor::Right)
- op = QTextCursor::PreviousCharacter;
- else if (op == QTextCursor::WordLeft)
+ if (blockIt.textDirection() == Qt::RightToLeft) {
+ if (op == QTextCursor::WordLeft)
op = QTextCursor::NextWord;
else if (op == QTextCursor::WordRight)
op = QTextCursor::PreviousWord;
+
+ if (!visualMovement) {
+ if (op == QTextCursor::Left)
+ op = QTextCursor::NextCharacter;
+ else if (op == QTextCursor::Right)
+ op = QTextCursor::PreviousCharacter;
+ }
}
const QTextLayout *layout = blockLayout(blockIt);
@@ -418,9 +421,12 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
break;
}
case QTextCursor::PreviousCharacter:
- case QTextCursor::Left:
newPosition = priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
break;
+ case QTextCursor::Left:
+ newPosition = visualMovement ? priv->leftCursorPosition(position)
+ : priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
+ break;
case QTextCursor::StartOfWord: {
if (relativePos == 0)
break;
@@ -529,9 +535,12 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
break;
}
case QTextCursor::NextCharacter:
- case QTextCursor::Right:
newPosition = priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
break;
+ case QTextCursor::Right:
+ newPosition = visualMovement ? priv->rightCursorPosition(position)
+ : priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
+ break;
case QTextCursor::NextWord:
case QTextCursor::WordRight:
newPosition = priv->nextCursorPosition(position, QTextLayout::SkipWords);
@@ -2558,4 +2567,19 @@ QTextDocument *QTextCursor::document() const
return 0; // document went away
}
+/*!
+ \enum Qt::CursorMoveStyle
+
+ This enum describes the movement style available to text cursors. The options
+ are:
+
+ \value LogicalMoveStyle Within a left-to-right text block, decrease cursor
+ position when pressing left arrow key, increase cursor position when pressing
+ the right arrow key. If the text block is right-to-left, the opposite behavior
+ applies.
+ \value VisualMoveStyle Pressing the left arrow key will always cause the cursor
+ to move left, regardless of the text's writing direction. Pressing the right
+ arrow key will always cause the cursor to move right.
+*/
+
QT_END_NAMESPACE
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 6dbd755..0d33912 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -586,6 +586,29 @@ void QTextDocument::setDefaultTextOption(const QTextOption &option)
}
/*!
+ \since 4.8
+
+ The default cursor movement style is used by all QTextCursor objects
+ created from the document. The default is Qt::LogicalMoveStyle.
+*/
+Qt::CursorMoveStyle QTextDocument::defaultCursorMoveStyle() const
+{
+ Q_D(const QTextDocument);
+ return d->defaultCursorMoveStyle;
+}
+
+/*!
+ \since 4.8
+
+ Set the default cursor movement style.
+*/
+void QTextDocument::setDefaultCursorMoveStyle(Qt::CursorMoveStyle style)
+{
+ Q_D(QTextDocument);
+ d->defaultCursorMoveStyle = style;
+}
+
+/*!
\fn void QTextDocument::markContentsDirty(int position, int length)
Marks the contents specified by the given \a position and \a length
@@ -2076,6 +2099,10 @@ QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode)
html += QLatin1String(" font-size:");
html += QString::number(defaultCharFormat.fontPointSize());
html += QLatin1String("pt;");
+ } else if (defaultCharFormat.hasProperty(QTextFormat::FontPixelSize)) {
+ html += QLatin1String(" font-size:");
+ html += QString::number(defaultCharFormat.intProperty(QTextFormat::FontPixelSize));
+ html += QLatin1String("px;");
}
html += QLatin1String(" font-weight:");
@@ -2156,6 +2183,10 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format)
html += QLatin1Char(';');
attributesEmitted = true;
}
+ } else if (format.hasProperty(QTextFormat::FontPixelSize)) {
+ html += QLatin1String(" font-size:");
+ html += QString::number(format.intProperty(QTextFormat::FontPixelSize));
+ html += QLatin1String("px;");
}
if (format.hasProperty(QTextFormat::FontWeight)
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index f87ccc9..b826dc1 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -60,7 +60,6 @@ class QPainter;
class QPrinter;
class QAbstractTextDocumentLayout;
class QPoint;
-class QTextCursor;
class QTextObject;
class QTextFormat;
class QTextFrame;
@@ -70,6 +69,7 @@ class QUrl;
class QVariant;
class QRectF;
class QTextOption;
+class QTextCursor;
template<typename T> class QVector;
@@ -269,6 +269,9 @@ public:
QTextOption defaultTextOption() const;
void setDefaultTextOption(const QTextOption &option);
+ Qt::CursorMoveStyle defaultCursorMoveStyle() const;
+ void setDefaultCursorMoveStyle(Qt::CursorMoveStyle style);
+
Q_SIGNALS:
void contentsChange(int from, int charsRemoves, int charsAdded);
void contentsChanged();
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index a997720..640f7aa 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -209,6 +209,7 @@ QTextDocumentPrivate::QTextDocumentPrivate()
defaultTextOption.setTabStop(80); // same as in qtextengine.cpp
defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
+ defaultCursorMoveStyle = Qt::LogicalMoveStyle;
indentWidth = 40;
documentMargin = 4;
@@ -1382,6 +1383,20 @@ int QTextDocumentPrivate::previousCursorPosition(int position, QTextLayout::Curs
return it.layout()->previousCursorPosition(position-start, mode) + start;
}
+int QTextDocumentPrivate::leftCursorPosition(int position) const
+{
+ QTextBlock it = blocksFind(position);
+ int start = it.position();
+ return it.layout()->leftCursorPosition(position-start) + start;
+}
+
+int QTextDocumentPrivate::rightCursorPosition(int position) const
+{
+ QTextBlock it = blocksFind(position);
+ int start = it.position();
+ return it.layout()->rightCursorPosition(position-start) + start;
+}
+
void QTextDocumentPrivate::changeObjectFormat(QTextObject *obj, int format)
{
beginEditBlock();
diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h
index b464f2e..e72d676 100644
--- a/src/gui/text/qtextdocument_p.h
+++ b/src/gui/text/qtextdocument_p.h
@@ -64,6 +64,7 @@
#include "private/qtextformat_p.h"
#include "QtGui/qtextdocument.h"
#include "QtGui/qtextobject.h"
+#include "QtGui/qtextcursor.h"
#include "QtCore/qmap.h"
#include "QtCore/qvariant.h"
#include "QtCore/qurl.h"
@@ -244,6 +245,8 @@ public:
int nextCursorPosition(int position, QTextLayout::CursorMode mode) const;
int previousCursorPosition(int position, QTextLayout::CursorMode mode) const;
+ int leftCursorPosition(int position) const;
+ int rightCursorPosition(int position) const;
void changeObjectFormat(QTextObject *group, int format);
@@ -339,6 +342,7 @@ private:
public:
QTextOption defaultTextOption;
+ Qt::CursorMoveStyle defaultCursorMoveStyle;
#ifndef QT_NO_CSSPARSER
QCss::StyleSheet parsedDefaultStyleSheet;
#endif
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index ce157be..f3dc975 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -2996,10 +2996,19 @@ void QTextDocumentLayout::resizeInlineObject(QTextInlineObject item, int posInDo
QSizeF inlineSize = (pos == QTextFrameFormat::InFlow ? intrinsic : QSizeF(0, 0));
item.setWidth(inlineSize.width());
- if (f.verticalAlignment() == QTextCharFormat::AlignMiddle) {
+
+ QFontMetrics m(f.font());
+ switch (f.verticalAlignment())
+ {
+ case QTextCharFormat::AlignMiddle:
item.setDescent(inlineSize.height() / 2);
item.setAscent(inlineSize.height() / 2 - 1);
- } else {
+ break;
+ case QTextCharFormat::AlignBaseline:
+ item.setDescent(m.descent());
+ item.setAscent(inlineSize.height() - m.descent() - 1);
+ break;
+ default:
item.setDescent(0);
item.setAscent(inlineSize.height() - 1);
}
@@ -3081,6 +3090,7 @@ void QTextDocumentLayoutPrivate::ensureLayouted(QFixed y) const
if (currentLazyLayoutPosition == -1)
return;
const QSizeF oldSize = q->dynamicDocumentSize();
+ Q_UNUSED(oldSize);
if (checkPoints.isEmpty())
layoutStep();
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 08d0eca..ff27bc6 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -856,6 +856,21 @@ void QTextEngine::shapeLine(const QScriptLine &line)
}
}
+#if !defined(QT_ENABLE_HARFBUZZ_FOR_MAC)
+static bool enableHarfBuzz()
+{
+ static enum { Yes, No, Unknown } status = Unknown;
+
+ if (status == Unknown) {
+ QByteArray v = qgetenv("QT_ENABLE_HARFBUZZ");
+ bool value = !v.isEmpty() && v != "0" && v != "false";
+ if (value) status = Yes;
+ else status = No;
+ }
+ return status == Yes;
+}
+#endif
+
void QTextEngine::shapeText(int item) const
{
Q_ASSERT(item < layoutData->items.size());
@@ -865,7 +880,24 @@ void QTextEngine::shapeText(int item) const
return;
#if defined(Q_WS_MAC)
- shapeTextMac(item);
+#if !defined(QT_ENABLE_HARFBUZZ_FOR_MAC)
+ if (enableHarfBuzz()) {
+#endif
+ QFontEngine *actualFontEngine = fontEngine(si, &si.ascent, &si.descent, &si.leading);
+ if (actualFontEngine->type() == QFontEngine::Multi)
+ actualFontEngine = static_cast<QFontEngineMulti *>(actualFontEngine)->engine(0);
+
+ HB_Face face = actualFontEngine->harfbuzzFace();
+ HB_Script script = (HB_Script) si.analysis.script;
+ if (face->supported_scripts[script])
+ shapeTextWithHarfbuzz(item);
+ else
+ shapeTextMac(item);
+#if !defined(QT_ENABLE_HARFBUZZ_FOR_MAC)
+ } else {
+ shapeTextMac(item);
+ }
+#endif
#elif defined(Q_WS_WINCE)
shapeTextWithCE(item);
#else
@@ -1242,6 +1274,10 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
actualFontEngine = static_cast<QFontEngineMulti *>(font)->engine(engineIdx);
}
+ si.ascent = qMax(actualFontEngine->ascent(), si.ascent);
+ si.descent = qMax(actualFontEngine->descent(), si.descent);
+ si.leading = qMax(actualFontEngine->leading(), si.leading);
+
shaper_item.font = actualFontEngine->harfbuzzFont();
shaper_item.face = actualFontEngine->harfbuzzFace();
@@ -1304,6 +1340,7 @@ static void init(QTextEngine *e)
e->ignoreBidi = false;
e->cacheGlyphs = false;
e->forceJustification = false;
+ e->visualMovement = false;
e->layoutData = 0;
@@ -1565,6 +1602,8 @@ bool QTextEngine::isRightToLeft() const
default:
break;
}
+ if (!layoutData)
+ itemize();
// this places the cursor in the right position depending on the keyboard layout
if (layoutData->string.isEmpty())
return QApplication::keyboardInputDirection() == Qt::RightToLeft;
@@ -2737,6 +2776,182 @@ QFixed QTextEngine::leadingSpaceWidth(const QScriptLine &line)
return width(line.from + pos, line.length - pos);
}
+QFixed QTextEngine::alignLine(const QScriptLine &line)
+{
+ QFixed x = 0;
+ justify(line);
+ // if width is QFIXED_MAX that means we used setNumColumns() and that implicitly makes this line left aligned.
+ if (!line.justified && line.width != QFIXED_MAX) {
+ int align = option.alignment();
+ if (align & Qt::AlignLeft)
+ x -= leadingSpaceWidth(line);
+ if (align & Qt::AlignJustify && isRightToLeft())
+ align = Qt::AlignRight;
+ if (align & Qt::AlignRight)
+ x = line.width - (line.textAdvance + leadingSpaceWidth(line));
+ else if (align & Qt::AlignHCenter)
+ x = (line.width - (line.textAdvance + leadingSpaceWidth(line)))/2;
+ }
+ return x;
+}
+
+QFixed QTextEngine::offsetInLigature(const QScriptItem *si, int pos, int max, int glyph_pos)
+{
+ unsigned short *logClusters = this->logClusters(si);
+ const QGlyphLayout &glyphs = shapedGlyphs(si);
+
+ int offsetInCluster = 0;
+ for (int i = pos - 1; i >= 0; i--) {
+ if (logClusters[i] == glyph_pos)
+ offsetInCluster++;
+ else
+ break;
+ }
+
+ // in the case that the offset is inside a (multi-character) glyph,
+ // interpolate the position.
+ if (offsetInCluster > 0) {
+ int clusterLength = 0;
+ for (int i = pos - offsetInCluster; i < max; i++) {
+ if (logClusters[i] == glyph_pos)
+ clusterLength++;
+ else
+ break;
+ }
+ if (clusterLength)
+ return glyphs.advances_x[glyph_pos] * offsetInCluster / clusterLength;
+ }
+
+ return 0;
+}
+
+int QTextEngine::previousLogicalPosition(int oldPos) const
+{
+ const HB_CharAttributes *attrs = attributes();
+ if (!attrs || oldPos < 0)
+ return oldPos;
+
+ if (oldPos <= 0)
+ return 0;
+ oldPos--;
+ while (oldPos && !attrs[oldPos].charStop)
+ oldPos--;
+ return oldPos;
+}
+
+int QTextEngine::nextLogicalPosition(int oldPos) const
+{
+ const HB_CharAttributes *attrs = attributes();
+ int len = block.isValid() ? block.length() - 1
+ : layoutData->string.length();
+ Q_ASSERT(len <= layoutData->string.length());
+ if (!attrs || oldPos < 0 || oldPos >= len)
+ return oldPos;
+
+ oldPos++;
+ while (oldPos < len && !attrs[oldPos].charStop)
+ oldPos++;
+ return oldPos;
+}
+
+int QTextEngine::lineNumberForTextPosition(int pos)
+{
+ if (!layoutData)
+ itemize();
+ if (pos == layoutData->string.length() && lines.size())
+ return lines.size() - 1;
+ for (int i = 0; i < lines.size(); ++i) {
+ const QScriptLine& line = lines[i];
+ if (line.from + line.length > pos)
+ return i;
+ }
+ return -1;
+}
+
+void QTextEngine::insertionPointsForLine(int lineNum, QVector<int> &insertionPoints)
+{
+ QTextLineItemIterator iterator(this, lineNum);
+ bool rtl = isRightToLeft();
+ bool lastLine = lineNum >= lines.size() - 1;
+
+ while (!iterator.atEnd()) {
+ iterator.next();
+ const QScriptItem *si = &layoutData->items[iterator.item];
+ if (si->analysis.bidiLevel % 2) {
+ int i = iterator.itemEnd - 1, min = iterator.itemStart;
+ if (lastLine && (rtl ? iterator.atBeginning() : iterator.atEnd()))
+ i++;
+ for (; i >= min; i--)
+ insertionPoints.push_back(i);
+ } else {
+ int i = iterator.itemStart, max = iterator.itemEnd;
+ if (lastLine && (rtl ? iterator.atBeginning() : iterator.atEnd()))
+ max++;
+ for (; i < max; i++)
+ insertionPoints.push_back(i);
+ }
+ }
+}
+
+int QTextEngine::endOfLine(int lineNum)
+{
+ QVector<int> insertionPoints;
+ insertionPointsForLine(lineNum, insertionPoints);
+
+ if (insertionPoints.size() > 0)
+ return insertionPoints.last();
+ return 0;
+}
+
+int QTextEngine::beginningOfLine(int lineNum)
+{
+ QVector<int> insertionPoints;
+ insertionPointsForLine(lineNum, insertionPoints);
+
+ if (insertionPoints.size() > 0)
+ return insertionPoints.first();
+ return 0;
+}
+
+int QTextEngine::positionAfterVisualMovement(int pos, QTextCursor::MoveOperation op)
+{
+ if (!layoutData)
+ itemize();
+
+ bool moveRight = (op == QTextCursor::Right);
+ bool alignRight = isRightToLeft();
+ if (!layoutData->hasBidi)
+ return moveRight ^ alignRight ? nextLogicalPosition(pos) : previousLogicalPosition(pos);
+
+ int lineNum = lineNumberForTextPosition(pos);
+ Q_ASSERT(lineNum >= 0);
+
+ QVector<int> insertionPoints;
+ insertionPointsForLine(lineNum, insertionPoints);
+ int i, max = insertionPoints.size();
+ for (i = 0; i < max; i++)
+ if (pos == insertionPoints[i]) {
+ if (moveRight) {
+ if (i + 1 < max)
+ return insertionPoints[i + 1];
+ } else {
+ if (i > 0)
+ return insertionPoints[i - 1];
+ }
+
+ if (moveRight ^ alignRight) {
+ if (lineNum + 1 < lines.size())
+ return alignRight ? endOfLine(lineNum + 1) : beginningOfLine(lineNum + 1);
+ }
+ else {
+ if (lineNum > 0)
+ return alignRight ? beginningOfLine(lineNum - 1) : endOfLine(lineNum - 1);
+ }
+ }
+
+ return pos;
+}
+
QStackTextEngine::QStackTextEngine(const QString &string, const QFont &f)
: QTextEngine(string, f),
_layoutData(string, _memory, MemSize)
@@ -2841,5 +3056,127 @@ glyph_metrics_t glyph_metrics_t::transformed(const QTransform &matrix) const
return m;
}
+QTextLineItemIterator::QTextLineItemIterator(QTextEngine *_eng, int _lineNum, const QPointF &pos,
+ const QTextLayout::FormatRange *_selection)
+ : eng(_eng),
+ line(eng->lines[_lineNum]),
+ si(0),
+ lineNum(_lineNum),
+ lineEnd(line.from + line.length),
+ firstItem(eng->findItem(line.from)),
+ lastItem(eng->findItem(lineEnd - 1)),
+ nItems((firstItem >= 0 && lastItem >= firstItem)? (lastItem-firstItem+1) : 0),
+ logicalItem(-1),
+ item(-1),
+ visualOrder(nItems),
+ levels(nItems),
+ selection(_selection)
+{
+ pos_x = x = QFixed::fromReal(pos.x());
+
+ x += line.x;
+
+ x += eng->alignLine(line);
+
+ for (int i = 0; i < nItems; ++i)
+ levels[i] = eng->layoutData->items[i+firstItem].analysis.bidiLevel;
+ QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data());
+
+ eng->shapeLine(line);
+}
+
+QScriptItem &QTextLineItemIterator::next()
+{
+ x += itemWidth;
+
+ ++logicalItem;
+ item = visualOrder[logicalItem] + firstItem;
+ itemLength = eng->length(item);
+ si = &eng->layoutData->items[item];
+ if (!si->num_glyphs)
+ eng->shape(item);
+
+ if (si->analysis.flags >= QScriptAnalysis::TabOrObject) {
+ itemWidth = si->width;
+ return *si;
+ }
+
+ unsigned short *logClusters = eng->logClusters(si);
+ QGlyphLayout glyphs = eng->shapedGlyphs(si);
+
+ itemStart = qMax(line.from, si->position);
+ glyphsStart = logClusters[itemStart - si->position];
+ if (lineEnd < si->position + itemLength) {
+ itemEnd = lineEnd;
+ glyphsEnd = logClusters[itemEnd-si->position];
+ } else {
+ itemEnd = si->position + itemLength;
+ glyphsEnd = si->num_glyphs;
+ }
+ // show soft-hyphen at line-break
+ if (si->position + itemLength >= lineEnd
+ && eng->layoutData->string.at(lineEnd - 1) == 0x00ad)
+ glyphs.attributes[glyphsEnd - 1].dontPrint = false;
+
+ itemWidth = 0;
+ for (int g = glyphsStart; g < glyphsEnd; ++g)
+ itemWidth += glyphs.effectiveAdvance(g);
+
+ return *si;
+}
+
+bool QTextLineItemIterator::getSelectionBounds(QFixed *selectionX, QFixed *selectionWidth) const
+{
+ *selectionX = *selectionWidth = 0;
+
+ if (!selection)
+ return false;
+
+ if (si->analysis.flags >= QScriptAnalysis::TabOrObject) {
+ if (si->position >= selection->start + selection->length
+ || si->position + itemLength <= selection->start)
+ return false;
+
+ *selectionX = x;
+ *selectionWidth = itemWidth;
+ } else {
+ unsigned short *logClusters = eng->logClusters(si);
+ QGlyphLayout glyphs = eng->shapedGlyphs(si);
+
+ int from = qMax(itemStart, selection->start) - si->position;
+ int to = qMin(itemEnd, selection->start + selection->length) - si->position;
+ if (from >= to)
+ return false;
+
+ int start_glyph = logClusters[from];
+ int end_glyph = (to == eng->length(item)) ? si->num_glyphs : logClusters[to];
+ QFixed soff;
+ QFixed swidth;
+ if (si->analysis.bidiLevel %2) {
+ for (int g = glyphsEnd - 1; g >= end_glyph; --g)
+ soff += glyphs.effectiveAdvance(g);
+ for (int g = end_glyph - 1; g >= start_glyph; --g)
+ swidth += glyphs.effectiveAdvance(g);
+ } else {
+ for (int g = glyphsStart; g < start_glyph; ++g)
+ soff += glyphs.effectiveAdvance(g);
+ for (int g = start_glyph; g < end_glyph; ++g)
+ swidth += glyphs.effectiveAdvance(g);
+ }
+
+ // If the starting character is in the middle of a ligature,
+ // selection should only contain the right part of that ligature
+ // glyph, so we need to get the width of the left part here and
+ // add it to *selectionX
+ QFixed leftOffsetInLigature = eng->offsetInLigature(si, from, to, start_glyph);
+ *selectionX = x + soff + leftOffsetInLigature;
+ *selectionWidth = swidth - leftOffsetInLigature;
+ // If the ending character is also part of a ligature, swidth does
+ // not contain that part yet, we also need to find out the width of
+ // that left part
+ *selectionWidth += eng->offsetInLigature(si, to, eng->length(item), end_glyph);
+ }
+ return true;
+}
QT_END_NAMESPACE
diff --git a/src/gui/text/qtextengine_mac.cpp b/src/gui/text/qtextengine_mac.cpp
index 97e8c5b..2c6e579 100644
--- a/src/gui/text/qtextengine_mac.cpp
+++ b/src/gui/text/qtextengine_mac.cpp
@@ -605,11 +605,11 @@ void QTextEngine::shapeTextMac(int item) const
unsigned short *log_clusters = logClusters(&si);
bool stringToCMapFailed = false;
- if (!fe->stringToCMap(str, len, &g, &num_glyphs, flags, log_clusters, attributes())) {
+ if (!fe->stringToCMap(str, len, &g, &num_glyphs, flags, log_clusters, attributes(), &si)) {
ensureSpace(num_glyphs);
g = availableGlyphs(&si);
stringToCMapFailed = !fe->stringToCMap(str, len, &g, &num_glyphs, flags, log_clusters,
- attributes());
+ attributes(), &si);
}
if (!stringToCMapFailed) {
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 366c5c3..e06ca1c 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -64,6 +64,7 @@
#include "QtGui/qpaintengine.h"
#include "QtGui/qtextobject.h"
#include "QtGui/qtextoption.h"
+#include "QtGui/qtextcursor.h"
#include "QtCore/qset.h"
#include "QtCore/qdebug.h"
#ifndef QT_BUILD_COMPAT_LIB
@@ -471,6 +472,7 @@ public:
void shape(int item) const;
void justify(const QScriptLine &si);
+ QFixed alignLine(const QScriptLine &line);
QFixed width(int charFrom, int numChars) const;
glyph_metrics_t boundingBox(int from, int len) const;
@@ -586,12 +588,18 @@ public:
uint cacheGlyphs : 1;
uint stackEngine : 1;
uint forceJustification : 1;
+ uint visualMovement : 1;
int *underlinePositions;
mutable LayoutData *layoutData;
inline bool hasFormats() const { return (block.docHandle() || specialData); }
+ inline bool visualCursorMovement() const
+ {
+ return (visualMovement ||
+ (block.docHandle() ? block.docHandle()->defaultCursorMoveStyle == Qt::VisualMoveStyle : false));
+ }
struct SpecialData {
int preeditPosition;
@@ -611,6 +619,13 @@ public:
void shapeLine(const QScriptLine &line);
QFixed leadingSpaceWidth(const QScriptLine &line);
+ QFixed offsetInLigature(const QScriptItem *si, int pos, int max, int glyph_pos);
+ int previousLogicalPosition(int oldPos) const;
+ int nextLogicalPosition(int oldPos) const;
+ int lineNumberForTextPosition(int pos);
+ int positionAfterVisualMovement(int oldPos, QTextCursor::MoveOperation op);
+ void insertionPointsForLine(int lineNum, QVector<int> &insertionPoints);
+
private:
void setBoundary(int strPos) const;
void addRequiredBoundaries() const;
@@ -625,6 +640,8 @@ private:
void splitItem(int item, int pos) const;
void resolveAdditionalFormats() const;
+ int endOfLine(int lineNum);
+ int beginningOfLine(int lineNum);
};
class QStackTextEngine : public QTextEngine {
@@ -635,6 +652,49 @@ public:
void *_memory[MemSize];
};
+struct QTextLineItemIterator
+{
+ QTextLineItemIterator(QTextEngine *eng, int lineNum, const QPointF &pos = QPointF(),
+ const QTextLayout::FormatRange *_selection = 0);
+
+ inline bool atEnd() const { return logicalItem >= nItems - 1; }
+ inline bool atBeginning() const { return logicalItem <= 0; }
+ QScriptItem &next();
+
+ bool getSelectionBounds(QFixed *selectionX, QFixed *selectionWidth) const;
+ inline bool isOutsideSelection() const {
+ QFixed tmp1, tmp2;
+ return !getSelectionBounds(&tmp1, &tmp2);
+ }
+
+ QTextEngine *eng;
+
+ QFixed x;
+ QFixed pos_x;
+ const QScriptLine &line;
+ QScriptItem *si;
+
+ int lineNum;
+ int lineEnd;
+ int firstItem;
+ int lastItem;
+ int nItems;
+ int logicalItem;
+ int item;
+ int itemLength;
+
+ int glyphsStart;
+ int glyphsEnd;
+ int itemStart;
+ int itemEnd;
+
+ QFixed itemWidth;
+
+ QVarLengthArray<int> visualOrder;
+ QVarLengthArray<uchar> levels;
+
+ const QTextLayout::FormatRange *selection;
+};
Q_DECLARE_OPERATORS_FOR_FLAGS(QTextEngine::ShaperFlags)
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index ff28eaa..4f4752a 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -378,7 +378,8 @@ public:
AlignSubScript,
AlignMiddle,
AlignTop,
- AlignBottom
+ AlignBottom,
+ AlignBaseline
};
enum UnderlineStyle { // keep in sync with Qt::PenStyle!
NoUnderline,
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 93f71d3..07aeb72 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -52,8 +52,8 @@
#include "qtextformat_p.h"
#include "qstyleoption.h"
#include "qpainterpath.h"
-#include "qglyphs.h"
-#include "qglyphs_p.h"
+#include "qglyphrun.h"
+#include "qglyphrun_p.h"
#include "qrawfont.h"
#include "qrawfont_p.h"
#include <limits.h>
@@ -72,23 +72,6 @@ QT_BEGIN_NAMESPACE
#define SuppressText 0x5012
#define SuppressBackground 0x513
-static QFixed alignLine(QTextEngine *eng, const QScriptLine &line)
-{
- QFixed x = 0;
- eng->justify(line);
- // if width is QFIXED_MAX that means we used setNumColumns() and that implicitly makes this line left aligned.
- if (!line.justified && line.width != QFIXED_MAX) {
- int align = eng->option.alignment();
- if (align & Qt::AlignJustify && eng->isRightToLeft())
- align = Qt::AlignRight;
- if (align & Qt::AlignRight)
- x = line.width - (line.textAdvance + eng->leadingSpaceWidth(line));
- else if (align & Qt::AlignHCenter)
- x = (line.width - line.textAdvance)/2;
- }
- return x;
-}
-
/*!
\class QTextLayout::FormatRange
\reentrant
@@ -596,6 +579,30 @@ bool QTextLayout::cacheEnabled() const
}
/*!
+ Set the cursor movement style. If the QTextLayout is backed by
+ a document, you can ignore this and use the option in QTextDocument,
+ this option is for widgets like QLineEdit or custom widgets without
+ a QTextDocument. Default value is Qt::LogicalMoveStyle.
+
+ \sa setCursorMoveStyle()
+*/
+void QTextLayout::setCursorMoveStyle(Qt::CursorMoveStyle style)
+{
+ d->visualMovement = style == Qt::VisualMoveStyle ? true : false;
+}
+
+/*!
+ The cursor movement style of this QTextLayout. The default is
+ Qt::LogicalMoveStyle.
+
+ \sa setCursorMoveStyle()
+*/
+Qt::CursorMoveStyle QTextLayout::cursorMoveStyle() const
+{
+ return d->visualMovement ? Qt::VisualMoveStyle : Qt::LogicalMoveStyle;
+}
+
+/*!
Begins the layout process.
\sa endLayout()
@@ -718,6 +725,34 @@ int QTextLayout::previousCursorPosition(int oldPos, CursorMode mode) const
}
/*!
+ Returns the cursor position to the right of \a oldPos, next to it.
+ It's dependent on the visual position of characters, after bi-directional
+ reordering.
+
+ \sa leftCursorPosition(), nextCursorPosition()
+*/
+int QTextLayout::rightCursorPosition(int oldPos) const
+{
+ int newPos = d->positionAfterVisualMovement(oldPos, QTextCursor::Right);
+// qDebug("%d -> %d", oldPos, newPos);
+ return newPos;
+}
+
+/*!
+ Returns the cursor position to the left of \a oldPos, next to it.
+ It's dependent on the visual position of characters, after bi-directional
+ reordering.
+
+ \sa rightCursorPosition(), previousCursorPosition()
+*/
+int QTextLayout::leftCursorPosition(int oldPos) const
+{
+ int newPos = d->positionAfterVisualMovement(oldPos, QTextCursor::Left);
+// qDebug("%d -> %d", oldPos, newPos);
+ return newPos;
+}
+
+/*!/
Returns true if position \a pos is a valid cursor position.
In a Unicode context some positions in the text are not valid
@@ -815,16 +850,8 @@ QTextLine QTextLayout::lineAt(int i) const
*/
QTextLine QTextLayout::lineForTextPosition(int pos) const
{
- for (int i = 0; i < d->lines.size(); ++i) {
- const QScriptLine& line = d->lines[i];
- if (line.from + (int)line.length > pos)
- return QTextLine(i, d);
- }
- if (!d->layoutData)
- d->itemize();
- if (pos == d->layoutData->string.length() && d->lines.size())
- return QTextLine(d->lines.size()-1, d);
- return QTextLine();
+ int lineNum = d->lineNumberForTextPosition(pos);
+ return lineNum >= 0 ? lineAt(lineNum) : QTextLine();
}
/*!
@@ -919,201 +946,6 @@ void QTextLayout::setFlags(int flags)
}
}
-struct QTextLineItemIterator
-{
- QTextLineItemIterator(QTextEngine *eng, int lineNum, const QPointF &pos = QPointF(),
- const QTextLayout::FormatRange *_selection = 0);
-
- inline bool atEnd() const { return logicalItem >= nItems - 1; }
- QScriptItem &next();
-
- bool getSelectionBounds(QFixed *selectionX, QFixed *selectionWidth) const;
- inline bool isOutsideSelection() const {
- QFixed tmp1, tmp2;
- return !getSelectionBounds(&tmp1, &tmp2);
- }
-
- QTextEngine *eng;
-
- QFixed x;
- QFixed pos_x;
- const QScriptLine &line;
- QScriptItem *si;
-
- int lineEnd;
- int firstItem;
- int lastItem;
- int nItems;
- int logicalItem;
- int item;
- int itemLength;
-
- int glyphsStart;
- int glyphsEnd;
- int itemStart;
- int itemEnd;
-
- QFixed itemWidth;
-
- QVarLengthArray<int> visualOrder;
- QVarLengthArray<uchar> levels;
-
- const QTextLayout::FormatRange *selection;
-};
-
-QTextLineItemIterator::QTextLineItemIterator(QTextEngine *_eng, int lineNum, const QPointF &pos,
- const QTextLayout::FormatRange *_selection)
- : eng(_eng),
- line(eng->lines[lineNum]),
- si(0),
- lineEnd(line.from + line.length),
- firstItem(eng->findItem(line.from)),
- lastItem(eng->findItem(lineEnd - 1)),
- nItems((firstItem >= 0 && lastItem >= firstItem)? (lastItem-firstItem+1) : 0),
- logicalItem(-1),
- item(-1),
- visualOrder(nItems),
- levels(nItems),
- selection(_selection)
-{
- pos_x = x = QFixed::fromReal(pos.x());
-
- x += line.x;
-
- x += alignLine(eng, line);
-
- for (int i = 0; i < nItems; ++i)
- levels[i] = eng->layoutData->items[i+firstItem].analysis.bidiLevel;
- QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data());
-
- eng->shapeLine(line);
-}
-
-QScriptItem &QTextLineItemIterator::next()
-{
- x += itemWidth;
-
- ++logicalItem;
- item = visualOrder[logicalItem] + firstItem;
- itemLength = eng->length(item);
- si = &eng->layoutData->items[item];
- if (!si->num_glyphs)
- eng->shape(item);
-
- if (si->analysis.flags >= QScriptAnalysis::TabOrObject) {
- itemWidth = si->width;
- return *si;
- }
-
- unsigned short *logClusters = eng->logClusters(si);
- QGlyphLayout glyphs = eng->shapedGlyphs(si);
-
- itemStart = qMax(line.from, si->position);
- glyphsStart = logClusters[itemStart - si->position];
- if (lineEnd < si->position + itemLength) {
- itemEnd = lineEnd;
- glyphsEnd = logClusters[itemEnd-si->position];
- } else {
- itemEnd = si->position + itemLength;
- glyphsEnd = si->num_glyphs;
- }
- // show soft-hyphen at line-break
- if (si->position + itemLength >= lineEnd
- && eng->layoutData->string.at(lineEnd - 1) == 0x00ad)
- glyphs.attributes[glyphsEnd - 1].dontPrint = false;
-
- itemWidth = 0;
- for (int g = glyphsStart; g < glyphsEnd; ++g)
- itemWidth += glyphs.effectiveAdvance(g);
-
- return *si;
-}
-
-static QFixed offsetInLigature(const unsigned short *logClusters,
- const QGlyphLayout &glyphs,
- int pos, int max, int glyph_pos)
-{
- int offsetInCluster = 0;
- for (int i = pos - 1; i >= 0; i--) {
- if (logClusters[i] == glyph_pos)
- offsetInCluster++;
- else
- break;
- }
-
- // in the case that the offset is inside a (multi-character) glyph,
- // interpolate the position.
- if (offsetInCluster > 0) {
- int clusterLength = 0;
- for (int i = pos - offsetInCluster; i < max; i++) {
- if (logClusters[i] == glyph_pos)
- clusterLength++;
- else
- break;
- }
- if (clusterLength)
- return glyphs.advances_x[glyph_pos] * offsetInCluster / clusterLength;
- }
-
- return 0;
-}
-
-bool QTextLineItemIterator::getSelectionBounds(QFixed *selectionX, QFixed *selectionWidth) const
-{
- *selectionX = *selectionWidth = 0;
-
- if (!selection)
- return false;
-
- if (si->analysis.flags >= QScriptAnalysis::TabOrObject) {
- if (si->position >= selection->start + selection->length
- || si->position + itemLength <= selection->start)
- return false;
-
- *selectionX = x;
- *selectionWidth = itemWidth;
- } else {
- unsigned short *logClusters = eng->logClusters(si);
- QGlyphLayout glyphs = eng->shapedGlyphs(si);
-
- int from = qMax(itemStart, selection->start) - si->position;
- int to = qMin(itemEnd, selection->start + selection->length) - si->position;
- if (from >= to)
- return false;
-
- int start_glyph = logClusters[from];
- int end_glyph = (to == eng->length(item)) ? si->num_glyphs : logClusters[to];
- QFixed soff;
- QFixed swidth;
- if (si->analysis.bidiLevel %2) {
- for (int g = glyphsEnd - 1; g >= end_glyph; --g)
- soff += glyphs.effectiveAdvance(g);
- for (int g = end_glyph - 1; g >= start_glyph; --g)
- swidth += glyphs.effectiveAdvance(g);
- } else {
- for (int g = glyphsStart; g < start_glyph; ++g)
- soff += glyphs.effectiveAdvance(g);
- for (int g = start_glyph; g < end_glyph; ++g)
- swidth += glyphs.effectiveAdvance(g);
- }
-
- // If the starting character is in the middle of a ligature,
- // selection should only contain the right part of that ligature
- // glyph, so we need to get the width of the left part here and
- // add it to *selectionX
- QFixed leftOffsetInLigature = offsetInLigature(logClusters, glyphs, from,
- to, start_glyph);
- *selectionX = x + soff + leftOffsetInLigature;
- *selectionWidth = swidth - leftOffsetInLigature;
- // If the ending character is also part of a ligature, swidth does
- // not contain that part yet, we also need to find out the width of
- // that left part
- *selectionWidth += offsetInLigature(logClusters, glyphs, to,
- eng->length(item), end_glyph);
- }
- return true;
-}
-
static void addSelectedRegionsToPath(QTextEngine *eng, int lineNumber, const QPointF &pos, QTextLayout::FormatRange *selection,
QPainterPath *region, QRectF boundingRect)
{
@@ -1162,12 +994,12 @@ static inline QRectF clipIfValid(const QRectF &rect, const QRectF &clip)
\since 4.8
- \sa draw(), QPainter::drawGlyphs()
+ \sa draw(), QPainter::drawGlyphRun()
*/
#if !defined(QT_NO_RAWFONT)
-QList<QGlyphs> QTextLayout::glyphs() const
+QList<QGlyphRun> QTextLayout::glyphRuns() const
{
- QList<QGlyphs> glyphs;
+ QList<QGlyphRun> glyphs;
for (int i=0; i<d->lines.size(); ++i)
glyphs += QTextLine(i, d).glyphs(-1, -1);
@@ -1228,6 +1060,7 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang
QRectF lineRect(tl.naturalTextRect());
lineRect.translate(position);
+ lineRect.adjust(0, 0, d->leadingSpaceWidth(sl).toReal(), 0);
bool isLastLineInBlock = (line == d->lines.size()-1);
int sl_length = sl.length + (isLastLineInBlock? 1 : 0); // the infamous newline
@@ -1378,22 +1211,11 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
d->itemize();
QPointF position = pos + d->position;
- QFixed pos_x = QFixed::fromReal(position.x());
- QFixed pos_y = QFixed::fromReal(position.y());
cursorPosition = qBound(0, cursorPosition, d->layoutData->string.length());
- int line = 0;
- if (cursorPosition == d->layoutData->string.length()) {
- line = d->lines.size() - 1;
- } else {
- // ### binary search
- for (line = 0; line < d->lines.size(); line++) {
- const QScriptLine &sl = d->lines[line];
- if (sl.from <= cursorPosition && sl.from + (int)sl.length > cursorPosition)
- break;
- }
- }
-
+ int line = d->lineNumberForTextPosition(cursorPosition);
+ if (line < 0)
+ line = 0;
if (line >= d->lines.size())
return;
@@ -1402,7 +1224,15 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
qreal x = position.x() + l.cursorToX(cursorPosition);
- int itm = d->findItem(cursorPosition - 1);
+ int itm;
+
+ if (d->visualCursorMovement()) {
+ if (cursorPosition == sl.from + sl.length)
+ cursorPosition--;
+ itm = d->findItem(cursorPosition);
+ } else
+ itm = d->findItem(cursorPosition - 1);
+
QFixed base = sl.base();
QFixed descent = sl.descent;
bool rightToLeft = d->isRightToLeft();
@@ -1512,7 +1342,7 @@ QRectF QTextLine::rect() const
QRectF QTextLine::naturalTextRect() const
{
const QScriptLine& sl = eng->lines[i];
- QFixed x = sl.x + alignLine(eng, sl);
+ QFixed x = sl.x + eng->alignLine(sl);
QFixed width = sl.textWidth;
if (sl.justified)
@@ -2263,15 +2093,15 @@ namespace {
\since 4.8
- \sa QTextLayout::glyphs()
+ \sa QTextLayout::glyphRuns()
*/
#if !defined(QT_NO_RAWFONT)
-QList<QGlyphs> QTextLine::glyphs(int from, int length) const
+QList<QGlyphRun> QTextLine::glyphs(int from, int length) const
{
const QScriptLine &line = eng->lines[i];
if (line.length == 0)
- return QList<QGlyphs>();
+ return QList<QGlyphRun>();
QHash<QFontEngine *, GlyphInfo> glyphLayoutHash;
@@ -2317,6 +2147,9 @@ QList<QGlyphs> QTextLine::glyphs(int from, int length) const
QGlyphLayout subLayout = glyphLayout.mid(start, end - start);
glyphLayoutHash.insertMulti(multiFontEngine->engine(which),
GlyphInfo(subLayout, pos, flags));
+ for (int i = 0; i < subLayout.numGlyphs; i++)
+ pos += QPointF(subLayout.advances_x[i].toReal(),
+ subLayout.advances_y[i].toReal());
start = end;
which = e;
@@ -2333,7 +2166,7 @@ QList<QGlyphs> QTextLine::glyphs(int from, int length) const
}
}
- QHash<QPair<QFontEngine *, int>, QGlyphs> glyphsHash;
+ QHash<QPair<QFontEngine *, int>, QGlyphRun> glyphsHash;
QList<QFontEngine *> keys = glyphLayoutHash.uniqueKeys();
for (int i=0; i<keys.size(); ++i) {
@@ -2390,14 +2223,14 @@ QList<QGlyphs> QTextLine::glyphs(int from, int length) const
positions.append(positionsArray.at(i).toPointF() + pos);
}
- QGlyphs glyphIndexes;
+ QGlyphRun glyphIndexes;
glyphIndexes.setGlyphIndexes(glyphs);
glyphIndexes.setPositions(positions);
glyphIndexes.setOverline(flags.testFlag(QTextItem::Overline));
glyphIndexes.setUnderline(flags.testFlag(QTextItem::Underline));
glyphIndexes.setStrikeOut(flags.testFlag(QTextItem::StrikeOut));
- glyphIndexes.setFont(font);
+ glyphIndexes.setRawFont(font);
QPair<QFontEngine *, int> key(fontEngine, int(flags));
if (!glyphsHash.contains(key))
@@ -2632,9 +2465,10 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const
eng->itemize();
const QScriptLine &line = eng->lines[i];
+ bool lastLine = i >= eng->lines.size() - 1;
QFixed x = line.x;
- x += alignLine(eng, line);
+ x += eng->alignLine(line);
if (!i && !eng->layoutData->items.size()) {
*cursorPos = 0;
@@ -2720,21 +2554,29 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const
logClusters = eng->logClusters(si);
glyphs = eng->shapedGlyphs(si);
if (si->analysis.flags >= QScriptAnalysis::TabOrObject) {
- if(pos == l)
+ if (pos == (reverse ? 0 : l))
x += si->width;
} else {
+ bool rtl = eng->isRightToLeft();
+ bool visual = eng->visualCursorMovement();
if (reverse) {
int end = qMin(lineEnd, si->position + l) - si->position;
int glyph_end = end == l ? si->num_glyphs : logClusters[end];
- for (int i = glyph_end - 1; i >= glyph_pos; i--)
+ int glyph_start = glyph_pos;
+ if (visual && !rtl && !(lastLine && itm == (visualOrder[nItems - 1] + firstItem)))
+ glyph_start++;
+ for (int i = glyph_end - 1; i >= glyph_start; i--)
x += glyphs.effectiveAdvance(i);
} else {
int start = qMax(line.from - si->position, 0);
int glyph_start = logClusters[start];
- for (int i = glyph_start; i < glyph_pos; i++)
+ int glyph_end = glyph_pos;
+ if (!visual || !rtl || (lastLine && itm == visualOrder[0] + firstItem))
+ glyph_end--;
+ for (int i = glyph_start; i <= glyph_end; i++)
x += glyphs.effectiveAdvance(i);
}
- x += offsetInLigature(logClusters, glyphs, pos, line.length, glyph_pos);
+ x += eng->offsetInLigature(si, pos, line.length, glyph_pos);
}
*cursorPos = pos + si->position;
@@ -2753,6 +2595,8 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
{
QFixed x = QFixed::fromReal(_x);
const QScriptLine &line = eng->lines[i];
+ bool lastLine = i >= eng->lines.size() - 1;
+ int lineNum = i;
if (!eng->layoutData)
eng->itemize();
@@ -2770,7 +2614,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
return 0;
x -= line.x;
- x -= alignLine(eng, line);
+ x -= eng->alignLine(line);
// qDebug("xToCursor: x=%f, cpos=%d", x.toReal(), cpos);
QVarLengthArray<int> visualOrder(nItems);
@@ -2779,6 +2623,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
levels[i] = eng->layoutData->items[i+firstItem].analysis.bidiLevel;
QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data());
+ bool visual = eng->visualCursorMovement();
if (x <= 0) {
// left of first item
int item = visualOrder[0]+firstItem;
@@ -2795,8 +2640,13 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
|| (line.justified && x < line.width)) {
// has to be in one of the runs
QFixed pos;
+ bool rtl = eng->isRightToLeft();
eng->shapeLine(line);
+ QVector<int> insertionPoints;
+ if (visual && rtl)
+ eng->insertionPointsForLine(lineNum, insertionPoints);
+ int nchars = 0;
for (int i = 0; i < nItems; ++i) {
int item = visualOrder[i]+firstItem;
QScriptItem &si = eng->layoutData->items[item];
@@ -2826,6 +2676,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
if (pos + item_width < x) {
pos += item_width;
+ nchars += end;
continue;
}
// qDebug(" inside run");
@@ -2870,27 +2721,60 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
} else {
QFixed dist = INT_MAX/256;
if (si.analysis.bidiLevel % 2) {
- pos += item_width;
- while (gs <= ge) {
- if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) {
- glyph_pos = gs;
- dist = qAbs(x-pos);
+ if (!visual || rtl || (lastLine && i == nItems - 1)) {
+ pos += item_width;
+ while (gs <= ge) {
+ if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) {
+ glyph_pos = gs;
+ dist = qAbs(x-pos);
+ }
+ pos -= glyphs.effectiveAdvance(gs);
+ ++gs;
+ }
+ } else {
+ while (ge >= gs) {
+ if (glyphs.attributes[ge].clusterStart && qAbs(x-pos) < dist) {
+ glyph_pos = ge;
+ dist = qAbs(x-pos);
+ }
+ pos += glyphs.effectiveAdvance(ge);
+ --ge;
}
- pos -= glyphs.effectiveAdvance(gs);
- ++gs;
}
} else {
- while (gs <= ge) {
- if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) {
- glyph_pos = gs;
- dist = qAbs(x-pos);
+ if (!visual || !rtl || (lastLine && i == 0)) {
+ while (gs <= ge) {
+ if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) {
+ glyph_pos = gs;
+ dist = qAbs(x-pos);
+ }
+ pos += glyphs.effectiveAdvance(gs);
+ ++gs;
}
- pos += glyphs.effectiveAdvance(gs);
- ++gs;
+ } else {
+ QFixed oldPos = pos;
+ while (gs <= ge) {
+ pos += glyphs.effectiveAdvance(gs);
+ if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) {
+ glyph_pos = gs;
+ dist = qAbs(x-pos);
+ }
+ ++gs;
+ }
+ pos = oldPos;
}
}
- if (qAbs(x-pos) < dist)
+ if (qAbs(x-pos) < dist) {
+ if (visual) {
+ if (!rtl && i < nItems - 1) {
+ nchars += end;
+ continue;
+ }
+ if (rtl && nchars > 0)
+ return insertionPoints[lastLine ? nchars : nchars - 1];
+ }
return si.position + end;
+ }
}
Q_ASSERT(glyph_pos != -1);
int j;
diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
index 9dd8ebd..89fbfb2 100644
--- a/src/gui/text/qtextlayout.h
+++ b/src/gui/text/qtextlayout.h
@@ -49,7 +49,8 @@
#include <QtCore/qobject.h>
#include <QtGui/qevent.h>
#include <QtGui/qtextformat.h>
-#include <QtGui/qglyphs.h>
+#include <QtGui/qglyphrun.h>
+#include <QtGui/qtextcursor.h>
QT_BEGIN_HEADER
@@ -136,6 +137,9 @@ public:
void setCacheEnabled(bool enable);
bool cacheEnabled() const;
+ void setCursorMoveStyle(Qt::CursorMoveStyle style);
+ Qt::CursorMoveStyle cursorMoveStyle() const;
+
void beginLayout();
void endLayout();
void clearLayout();
@@ -153,6 +157,8 @@ public:
bool isValidCursorPosition(int pos) const;
int nextCursorPosition(int oldPos, CursorMode mode = SkipCharacters) const;
int previousCursorPosition(int oldPos, CursorMode mode = SkipCharacters) const;
+ int leftCursorPosition(int oldPos) const;
+ int rightCursorPosition(int oldPos) const;
void draw(QPainter *p, const QPointF &pos, const QVector<FormatRange> &selections = QVector<FormatRange>(),
const QRectF &clip = QRectF()) const;
@@ -168,7 +174,7 @@ public:
qreal maximumWidth() const;
#if !defined(QT_NO_RAWFONT)
- QList<QGlyphs> glyphs() const;
+ QList<QGlyphRun> glyphRuns() const;
#endif
QTextEngine *engine() const { return d; }
@@ -243,7 +249,7 @@ private:
void layout_helper(int numGlyphs);
#if !defined(QT_NO_RAWFONT)
- QList<QGlyphs> glyphs(int from, int length) const;
+ QList<QGlyphRun> glyphs(int from, int length) const;
#endif
friend class QTextLayout;
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp
index 5c1c8b9..b7e05d2 100644
--- a/src/gui/text/qtextobject.cpp
+++ b/src/gui/text/qtextobject.cpp
@@ -891,11 +891,6 @@ QTextBlockUserData::~QTextBlockUserData()
Returns true if this text block is valid; otherwise returns false.
*/
-bool QTextBlock::isValid() const
-{
- return p != 0 && p->blockMap().isValid(n);
-}
-
/*!
\fn QTextBlock &QTextBlock::operator=(const QTextBlock &other)
@@ -1493,7 +1488,7 @@ QTextBlock::iterator QTextBlock::end() const
*/
QTextBlock QTextBlock::next() const
{
- if (!isValid())
+ if (!isValid() || !p->blockMap().isValid(n))
return QTextBlock();
return QTextBlock(p, p->blockMap().next(n));
@@ -1664,25 +1659,25 @@ QTextBlock::iterator &QTextBlock::iterator::operator--()
Returns the glyphs of this text fragment. The positions of the glyphs are
relative to the position of the QTextBlock's layout.
- \sa QGlyphs, QTextBlock::layout(), QTextLayout::position(), QPainter::drawGlyphs()
+ \sa QGlyphRun, QTextBlock::layout(), QTextLayout::position(), QPainter::drawGlyphRun()
*/
#if !defined(QT_NO_RAWFONT)
-QList<QGlyphs> QTextFragment::glyphs() const
+QList<QGlyphRun> QTextFragment::glyphRuns() const
{
if (!p || !n)
- return QList<QGlyphs>();
+ return QList<QGlyphRun>();
int pos = position();
int len = length();
if (len == 0)
- return QList<QGlyphs>();
+ return QList<QGlyphRun>();
int blockNode = p->blockMap().findNode(pos);
const QTextBlockData *blockData = p->blockMap().fragment(blockNode);
QTextLayout *layout = blockData->layout;
- QList<QGlyphs> ret;
+ QList<QGlyphRun> ret;
for (int i=0; i<layout->lineCount(); ++i) {
QTextLine textLine = layout->lineAt(i);
ret += textLine.glyphs(pos, len);
diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h
index ad8e657..a443e79 100644
--- a/src/gui/text/qtextobject.h
+++ b/src/gui/text/qtextobject.h
@@ -44,7 +44,7 @@
#include <QtCore/qobject.h>
#include <QtGui/qtextformat.h>
-#include <QtGui/qglyphs.h>
+#include <QtGui/qglyphrun.h>
QT_BEGIN_HEADER
@@ -205,7 +205,7 @@ public:
inline QTextBlock(const QTextBlock &o) : p(o.p), n(o.n) {}
inline QTextBlock &operator=(const QTextBlock &o) { p = o.p; n = o.n; return *this; }
- bool isValid() const;
+ inline bool isValid() const { return p != 0 && n != 0; }
inline bool operator==(const QTextBlock &o) const { return p == o.p && n == o.n; }
inline bool operator!=(const QTextBlock &o) const { return p != o.p || n != o.n; }
@@ -317,7 +317,7 @@ public:
QString text() const;
#if !defined(QT_NO_RAWFONT)
- QList<QGlyphs> glyphs() const;
+ QList<QGlyphRun> glyphRuns() const;
#endif
private:
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index df9398c..b6cdc52 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -40,10 +40,10 @@ HEADERS += \
text/qtextodfwriter_p.h \
text/qstatictext_p.h \
text/qstatictext.h \
- text/qglyphs.h \
- text/qglyphs_p.h \
text/qrawfont.h \
- text/qrawfont_p.h
+ text/qrawfont_p.h \
+ text/qglyphrun.h \
+ text/qglyphrun_p.h
SOURCES += \
text/qfont.cpp \
@@ -74,8 +74,8 @@ SOURCES += \
text/qzip.cpp \
text/qtextodfwriter.cpp \
text/qstatictext.cpp \
- text/qglyphs.cpp \
- text/qrawfont.cpp
+ text/qrawfont.cpp \
+ text/qglyphrun.cpp
win32 {
SOURCES += \
@@ -114,6 +114,9 @@ unix:x11 {
OBJECTIVE_SOURCES += \
text/qfontengine_coretext.mm \
text/qfontengine_mac.mm
+ contains(QT_CONFIG, harfbuzz) {
+ DEFINES += QT_ENABLE_HARFBUZZ_FOR_MAC
+ }
}
embedded {
@@ -136,7 +139,8 @@ qpa {
SOURCES += \
text/qfont_qpa.cpp \
text/qfontengine_qpa.cpp \
- text/qplatformfontdatabase_qpa.cpp
+ text/qplatformfontdatabase_qpa.cpp \
+ text/qrawfont_qpa.cpp
HEADERS += \
text/qplatformfontdatabase_qpa.h
diff --git a/src/gui/util/qflickgesture.cpp b/src/gui/util/qflickgesture.cpp
deleted file mode 100644
index fdd2a95..0000000
--- a/src/gui/util/qflickgesture.cpp
+++ /dev/null
@@ -1,715 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
-** this package.
-**
-** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgesture.h"
-#include "qapplication.h"
-#include "qevent.h"
-#include "qwidget.h"
-#include "qgraphicsitem.h"
-#include "qgraphicsscene.h"
-#include "qgraphicssceneevent.h"
-#include "qgraphicsview.h"
-#include "qscroller.h"
-#include "private/qevent_p.h"
-#include "private/qflickgesture_p.h"
-#include "qdebug.h"
-
-#ifndef QT_NO_GESTURES
-
-QT_BEGIN_NAMESPACE
-
-//#define QFLICKGESTURE_DEBUG
-
-#ifdef QFLICKGESTURE_DEBUG
-# define qFGDebug qDebug
-#else
-# define qFGDebug while (false) qDebug
-#endif
-
-extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
-
-static QMouseEvent *copyMouseEvent(QEvent *e)
-{
- switch (e->type()) {
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseMove: {
- QMouseEvent *me = static_cast<QMouseEvent *>(e);
- return new QMouseEvent(me->type(), QPoint(0, 0), me->globalPos(), me->button(), me->buttons(), me->modifiers());
- }
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseRelease:
- case QEvent::GraphicsSceneMouseMove: {
- QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent *>(e);
-#if 1
- QEvent::Type met = me->type() == QEvent::GraphicsSceneMousePress ? QEvent::MouseButtonPress :
- (me->type() == QEvent::GraphicsSceneMouseRelease ? QEvent::MouseButtonRelease : QEvent::MouseMove);
- return new QMouseEvent(met, QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers());
-#else
- QGraphicsSceneMouseEvent *copy = new QGraphicsSceneMouseEvent(me->type());
- copy->setPos(me->pos());
- copy->setScenePos(me->scenePos());
- copy->setScreenPos(me->screenPos());
- for (int i = 0x1; i <= 0x10; i <<= 1) {
- Qt::MouseButton button = Qt::MouseButton(i);
- copy->setButtonDownPos(button, me->buttonDownPos(button));
- copy->setButtonDownScenePos(button, me->buttonDownScenePos(button));
- copy->setButtonDownScreenPos(button, me->buttonDownScreenPos(button));
- }
- copy->setLastPos(me->lastPos());
- copy->setLastScenePos(me->lastScenePos());
- copy->setLastScreenPos(me->lastScreenPos());
- copy->setButtons(me->buttons());
- copy->setButton(me->button());
- copy->setModifiers(me->modifiers());
- return copy;
-#endif
- }
-#endif // QT_NO_GRAPHICSVIEW
- default:
- return 0;
- }
-}
-
-class PressDelayHandler : public QObject
-{
-private:
- PressDelayHandler(QObject *parent = 0)
- : QObject(parent)
- , pressDelayTimer(0)
- , sendingEvent(false)
- , mouseButton(Qt::NoButton)
- , mouseTarget(0)
- { }
-
- static PressDelayHandler *inst;
-
-public:
- enum {
- UngrabMouseBefore = 1,
- RegrabMouseAfterwards = 2
- };
-
- static PressDelayHandler *instance()
- {
- static PressDelayHandler *inst = 0;
- if (!inst)
- inst = new PressDelayHandler(QCoreApplication::instance());
- return inst;
- }
-
- bool shouldEventBeIgnored(QEvent *) const
- {
- return sendingEvent;
- }
-
- bool isDelaying() const
- {
- return !pressDelayEvent.isNull();
- }
-
- void pressed(QEvent *e, int delay)
- {
- if (!pressDelayEvent) {
- pressDelayEvent.reset(copyMouseEvent(e));
- pressDelayTimer = startTimer(delay);
- mouseTarget = QApplication::widgetAt(pressDelayEvent->globalPos());
- mouseButton = pressDelayEvent->button();
- qFGDebug() << "QFG: consuming/delaying mouse press";
- } else {
- qFGDebug() << "QFG: NOT consuming/delaying mouse press";
- }
- e->setAccepted(true);
- }
-
- bool released(QEvent *e, bool scrollerWasActive, bool scrollerIsActive)
- {
- // consume this event if the scroller was or is active
- bool result = scrollerWasActive || scrollerIsActive;
-
- // stop the timer
- if (pressDelayTimer) {
- killTimer(pressDelayTimer);
- pressDelayTimer = 0;
- }
- // we still haven't even sent the press, so do it now
- if (pressDelayEvent && mouseTarget && !scrollerIsActive) {
- QScopedPointer<QMouseEvent> releaseEvent(copyMouseEvent(e));
-
- qFGDebug() << "QFG: re-sending mouse press (due to release) for " << mouseTarget;
- sendMouseEvent(pressDelayEvent.data(), UngrabMouseBefore);
-
- qFGDebug() << "QFG: faking mouse release (due to release) for " << mouseTarget;
- sendMouseEvent(releaseEvent.data());
-
- result = true; // consume this event
- } else if (mouseTarget && scrollerIsActive) {
- // we grabbed the mouse expicitly when the scroller became active, so undo that now
- sendMouseEvent(0, UngrabMouseBefore);
- }
- pressDelayEvent.reset(0);
- mouseTarget = 0;
- return result;
- }
-
- void scrollerWasIntercepted()
- {
- qFGDebug() << "QFG: deleting delayed mouse press, since scroller was only intercepted";
- if (pressDelayEvent) {
- // we still haven't even sent the press, so just throw it away now
- if (pressDelayTimer) {
- killTimer(pressDelayTimer);
- pressDelayTimer = 0;
- }
- pressDelayEvent.reset(0);
- }
- mouseTarget = 0;
- }
-
- void scrollerBecameActive()
- {
- if (pressDelayEvent) {
- // we still haven't even sent the press, so just throw it away now
- qFGDebug() << "QFG: deleting delayed mouse press, since scroller is active now";
- if (pressDelayTimer) {
- killTimer(pressDelayTimer);
- pressDelayTimer = 0;
- }
- pressDelayEvent.reset(0);
- mouseTarget = 0;
- } else if (mouseTarget) {
- // we did send a press, so we need to fake a release now
- Qt::MouseButtons mouseButtons = QApplication::mouseButtons();
-
- // release all pressed mouse buttons
- /*for (int i = 0; i < 32; ++i) {
- if (mouseButtons & (1 << i)) {
- Qt::MouseButton b = static_cast<Qt::MouseButton>(1 << i);
- mouseButtons &= ~b;
- QPoint farFarAway(-QWIDGETSIZE_MAX, -QWIDGETSIZE_MAX);
-
- qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
- QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway,
- b, mouseButtons, QApplication::keyboardModifiers());
- sendMouseEvent(&re);
- }
- }*/
-
- QPoint farFarAway(-QWIDGETSIZE_MAX, -QWIDGETSIZE_MAX);
-
- qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
- QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway,
- mouseButton, QApplication::mouseButtons() & ~mouseButton,
- QApplication::keyboardModifiers());
- sendMouseEvent(&re, RegrabMouseAfterwards);
- // don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release!
- }
- }
-
-protected:
- void timerEvent(QTimerEvent *e)
- {
- if (e->timerId() == pressDelayTimer) {
- if (pressDelayEvent && mouseTarget) {
- qFGDebug() << "QFG: timer event: re-sending mouse press to " << mouseTarget;
- sendMouseEvent(pressDelayEvent.data(), UngrabMouseBefore);
- }
- pressDelayEvent.reset(0);
-
- if (pressDelayTimer) {
- killTimer(pressDelayTimer);
- pressDelayTimer = 0;
- }
- }
- }
-
- void sendMouseEvent(QMouseEvent *me, int flags = 0)
- {
- if (mouseTarget) {
- sendingEvent = true;
-
-#ifndef QT_NO_GRAPHICSVIEW
- QGraphicsItem *grabber = 0;
- if (mouseTarget->parentWidget()) {
- if (QGraphicsView *gv = qobject_cast<QGraphicsView *>(mouseTarget->parentWidget())) {
- if (gv->scene())
- grabber = gv->scene()->mouseGrabberItem();
- }
- }
-
- if (grabber && (flags & UngrabMouseBefore)) {
- // GraphicsView Mouse Handling Workaround #1:
- // we need to ungrab the mouse before re-sending the press,
- // since the scene had already set the mouse grabber to the
- // original (and consumed) event's receiver
- qFGDebug() << "QFG: ungrabbing" << grabber;
- grabber->ungrabMouse();
- }
-#endif // QT_NO_GRAPHICSVIEW
-
- if (me) {
- QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()), me->globalPos(), me->button(), me->buttons(), me->modifiers());
- qt_sendSpontaneousEvent(mouseTarget, &copy);
- }
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (grabber && (flags & RegrabMouseAfterwards)) {
- // GraphicsView Mouse Handling Workaround #2:
- // we need to re-grab the mouse after sending a faked mouse
- // release, since we still need the mouse moves for the gesture
- // (the scene will clear the item's mouse grabber status on
- // release).
- qFGDebug() << "QFG: re-grabbing" << grabber;
- grabber->grabMouse();
- }
-#endif
- sendingEvent = false;
- }
- }
-
-
-private:
- int pressDelayTimer;
- QScopedPointer<QMouseEvent> pressDelayEvent;
- bool sendingEvent;
- Qt::MouseButton mouseButton;
- QPointer<QWidget> mouseTarget;
-};
-
-
-/*!
- \internal
- \class QFlickGesture
- \since 4.8
- \brief The QFlickGesture class describes a flicking gesture made by the user.
- \ingroup gestures
- The QFlickGesture is more complex than the QPanGesture that uses QScroller and QScrollerProperties
- to decide if it is triggered.
- This gesture is reacting on touch event as compared to the QMouseFlickGesture.
-
- \sa {Gestures Programming}, QScroller, QScrollerProperties, QMouseFlickGesture
-*/
-
-/*!
- \internal
-*/
-QFlickGesture::QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject *parent)
- : QGesture(*new QFlickGesturePrivate, parent)
-{
- d_func()->q_ptr = this;
- d_func()->receiver = receiver;
- d_func()->receiverScroller = (receiver && QScroller::hasScroller(receiver)) ? QScroller::scroller(receiver) : 0;
- d_func()->button = button;
-}
-
-QFlickGesture::~QFlickGesture()
-{ }
-
-QFlickGesturePrivate::QFlickGesturePrivate()
- : receiverScroller(0), button(Qt::NoButton), macIgnoreWheel(false)
-{ }
-
-
-//
-// QFlickGestureRecognizer
-//
-
-
-QFlickGestureRecognizer::QFlickGestureRecognizer(Qt::MouseButton button)
-{
- this->button = button;
-}
-
-/*! \reimp
- */
-QGesture *QFlickGestureRecognizer::create(QObject *target)
-{
-#ifndef QT_NO_GRAPHICSVIEW
- QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target);
- if (go && button == Qt::NoButton) {
- go->setAcceptTouchEvents(true);
- }
-#endif
- return new QFlickGesture(target, button);
-}
-
-/*! \internal
- The recognize function detects a touch event suitable to start the attached QScroller.
- The QFlickGesture will be triggered as soon as the scroller is no longer in the state
- QScroller::Inactive or QScroller::Pressed. It will be finished or canceled
- at the next QEvent::TouchEnd.
- Note that the QScroller might continue scrolling (kinetically) at this point.
- */
-QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
- QObject *watched,
- QEvent *event)
-{
- Q_UNUSED(watched);
-
- static QElapsedTimer monotonicTimer;
- if (!monotonicTimer.isValid())
- monotonicTimer.start();
-
- QFlickGesture *q = static_cast<QFlickGesture *>(state);
- QFlickGesturePrivate *d = q->d_func();
-
- QScroller *scroller = d->receiverScroller;
- if (!scroller)
- return Ignore; // nothing to do without a scroller?
-
- QWidget *receiverWidget = qobject_cast<QWidget *>(d->receiver);
-#ifndef QT_NO_GRAPHICSVIEW
- QGraphicsObject *receiverGraphicsObject = qobject_cast<QGraphicsObject *>(d->receiver);
-#endif
-
- // this is only set for events that we inject into the event loop via sendEvent()
- if (PressDelayHandler::instance()->shouldEventBeIgnored(event)) {
- //qFGDebug() << state << "QFG: ignored event: " << event->type();
- return Ignore;
- }
-
- const QMouseEvent *me = 0;
-#ifndef QT_NO_GRAPHICSVIEW
- const QGraphicsSceneMouseEvent *gsme = 0;
-#endif
- const QTouchEvent *te = 0;
- QPoint globalPos;
-
- // qFGDebug() << "FlickGesture "<<state<<"watched:"<<watched<<"receiver"<<d->receiver<<"event"<<event->type()<<"button"<<button;
-
- switch (event->type()) {
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseMove:
- if (!receiverWidget)
- return Ignore;
- if (button != Qt::NoButton) {
- me = static_cast<const QMouseEvent *>(event);
- globalPos = me->globalPos();
- }
- break;
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseRelease:
- case QEvent::GraphicsSceneMouseMove:
- if (!receiverGraphicsObject)
- return Ignore;
- if (button != Qt::NoButton) {
- gsme = static_cast<const QGraphicsSceneMouseEvent *>(event);
- globalPos = gsme->screenPos();
- }
- break;
-#endif
- case QEvent::TouchBegin:
- case QEvent::TouchEnd:
- case QEvent::TouchUpdate:
- if (button == Qt::NoButton) {
- te = static_cast<const QTouchEvent *>(event);
- if (!te->touchPoints().isEmpty())
- globalPos = te->touchPoints().at(0).screenPos().toPoint();
- }
- break;
-
-#if defined(Q_WS_MAC)
- // the only way to distinguish between real mouse wheels and wheel
- // events generated by the native 2 finger swipe gesture is to listen
- // for these events (according to Apple's Cocoa Event-Handling Guide)
-
- case QEvent::NativeGesture: {
- QNativeGestureEvent *nge = static_cast<QNativeGestureEvent *>(event);
- if (nge->gestureType == QNativeGestureEvent::GestureBegin)
- d->macIgnoreWheel = true;
- else if (nge->gestureType == QNativeGestureEvent::GestureEnd)
- d->macIgnoreWheel = false;
- break;
- }
-#endif
-
- // consume all wheel events if the scroller is active
- case QEvent::Wheel:
- if (d->macIgnoreWheel || (scroller->state() != QScroller::Inactive))
- return Ignore | ConsumeEventHint;
- break;
-
- // consume all dbl click events if the scroller is active
- case QEvent::MouseButtonDblClick:
- if (scroller->state() != QScroller::Inactive)
- return Ignore | ConsumeEventHint;
- break;
-
- default:
- break;
- }
-
- if (!me
-#ifndef QT_NO_GRAPHICSVIEW
- && !gsme
-#endif
- && !te) // Neither mouse nor touch
- return Ignore;
-
- // get the current pointer position in local coordinates.
- QPointF point;
- QScroller::Input inputType = (QScroller::Input) 0;
-
- switch (event->type()) {
- case QEvent::MouseButtonPress:
- if (me && me->button() == button && me->buttons() == button) {
- point = me->globalPos();
- inputType = QScroller::InputPress;
- } else if (me) {
- scroller->stop();
- return CancelGesture;
- }
- break;
- case QEvent::MouseButtonRelease:
- if (me && me->button() == button) {
- point = me->globalPos();
- inputType = QScroller::InputRelease;
- }
- break;
- case QEvent::MouseMove:
-#ifdef Q_OS_SYMBIAN
- // Qt on Symbian tracks the button state internally, while Qt on Win/Mac/Unix
- // relies on the windowing system to report the current buttons state.
- if (me && (me->buttons() == button || !me->buttons())) {
-#else
- if (me && me->buttons() == button) {
-#endif
- point = me->globalPos();
- inputType = QScroller::InputMove;
- }
- break;
-
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMousePress:
- if (gsme && gsme->button() == button && gsme->buttons() == button) {
- point = gsme->scenePos();
- inputType = QScroller::InputPress;
- } else if (gsme) {
- scroller->stop();
- return CancelGesture;
- }
- break;
- case QEvent::GraphicsSceneMouseRelease:
- if (gsme && gsme->button() == button) {
- point = gsme->scenePos();
- inputType = QScroller::InputRelease;
- }
- break;
- case QEvent::GraphicsSceneMouseMove:
-#ifdef Q_OS_SYMBIAN
- // Qt on Symbian tracks the button state internally, while Qt on Win/Mac/Unix
- // relies on the windowing system to report the current buttons state.
- if (gsme && (gsme->buttons() == button || !me->buttons())) {
-#else
- if (gsme && gsme->buttons() == button) {
-#endif
- point = gsme->scenePos();
- inputType = QScroller::InputMove;
- }
- break;
-#endif
-
- case QEvent::TouchBegin:
- inputType = QScroller::InputPress;
- // fall through
- case QEvent::TouchEnd:
- if (!inputType)
- inputType = QScroller::InputRelease;
- // fallthrough
- case QEvent::TouchUpdate:
- if (!inputType)
- inputType = QScroller::InputMove;
-
- if (te->deviceType() == QTouchEvent::TouchPad) {
- if (te->touchPoints().count() != 2) // 2 fingers on pad
- return Ignore;
-
- point = te->touchPoints().at(0).startScenePos() +
- ((te->touchPoints().at(0).scenePos() - te->touchPoints().at(0).startScenePos()) +
- (te->touchPoints().at(1).scenePos() - te->touchPoints().at(1).startScenePos())) / 2;
- } else { // TouchScreen
- if (te->touchPoints().count() != 1) // 1 finger on screen
- return Ignore;
-
- point = te->touchPoints().at(0).scenePos();
- }
- break;
-
- default:
- break;
- }
-
- // Check for an active scroller at globalPos
- if (inputType == QScroller::InputPress) {
- foreach (QScroller *as, QScroller::activeScrollers()) {
- if (as != scroller) {
- QRegion scrollerRegion;
-
- if (QWidget *w = qobject_cast<QWidget *>(as->target())) {
- scrollerRegion = QRect(w->mapToGlobal(QPoint(0, 0)), w->size());
-#ifndef QT_NO_GRAPHICSVIEW
- } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(as->target())) {
- if (go->scene() && !go->scene()->views().isEmpty()) {
- foreach (QGraphicsView *gv, go->scene()->views())
- scrollerRegion |= gv->mapFromScene(go->mapToScene(go->boundingRect()))
- .translated(gv->mapToGlobal(QPoint(0, 0)));
- }
-#endif
- }
- // active scrollers always have priority
- if (scrollerRegion.contains(globalPos))
- return Ignore;
- }
- }
- }
-
- bool scrollerWasDragging = (scroller->state() == QScroller::Dragging);
- bool scrollerWasScrolling = (scroller->state() == QScroller::Scrolling);
-
- if (inputType) {
- if (QWidget *w = qobject_cast<QWidget *>(d->receiver))
- point = w->mapFromGlobal(point.toPoint());
-#ifndef QT_NO_GRAPHICSVIEW
- else if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->receiver))
- point = go->mapFromScene(point);
-#endif
-
- // inform the scroller about the new event
- scroller->handleInput(inputType, point, monotonicTimer.elapsed());
- }
-
- // depending on the scroller state return the gesture state
- Result result(0);
- bool scrollerIsActive = (scroller->state() == QScroller::Dragging ||
- scroller->state() == QScroller::Scrolling);
-
- // Consume all mouse events while dragging or scrolling to avoid nasty
- // side effects with Qt's standard widgets.
- if ((me
-#ifndef QT_NO_GRAPHICSVIEW
- || gsme
-#endif
- ) && scrollerIsActive)
- result |= ConsumeEventHint;
-
- // The only problem with this approach is that we consume the
- // MouseRelease when we start the scrolling with a flick gesture, so we
- // have to fake a MouseRelease "somewhere" to not mess with the internal
- // states of Qt's widgets (a QPushButton would stay in 'pressed' state
- // forever, if it doesn't receive a MouseRelease).
- if (me
-#ifndef QT_NO_GRAPHICSVIEW
- || gsme
-#endif
- ) {
- if (!scrollerWasDragging && !scrollerWasScrolling && scrollerIsActive)
- PressDelayHandler::instance()->scrollerBecameActive();
- else if (scrollerWasScrolling && (scroller->state() == QScroller::Dragging || scroller->state() == QScroller::Inactive))
- PressDelayHandler::instance()->scrollerWasIntercepted();
- }
-
- if (!inputType) {
- result |= Ignore;
- } else {
- switch (event->type()) {
- case QEvent::MouseButtonPress:
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMousePress:
-#endif
- if (scroller->state() == QScroller::Pressed) {
- int pressDelay = int(1000 * scroller->scrollerProperties().scrollMetric(QScrollerProperties::MousePressEventDelay).toReal());
- if (pressDelay > 0) {
- result |= ConsumeEventHint;
-
- PressDelayHandler::instance()->pressed(event, pressDelay);
- event->accept();
- }
- }
- // fall through
- case QEvent::TouchBegin:
- q->setHotSpot(globalPos);
- result |= scrollerIsActive ? TriggerGesture : MayBeGesture;
- break;
-
- case QEvent::MouseMove:
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMouseMove:
-#endif
- if (PressDelayHandler::instance()->isDelaying())
- result |= ConsumeEventHint;
- // fall through
- case QEvent::TouchUpdate:
- result |= scrollerIsActive ? TriggerGesture : Ignore;
- break;
-
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMouseRelease:
-#endif
- case QEvent::MouseButtonRelease:
- if (PressDelayHandler::instance()->released(event, scrollerWasDragging || scrollerWasScrolling, scrollerIsActive))
- result |= ConsumeEventHint;
- // fall through
- case QEvent::TouchEnd:
- result |= scrollerIsActive ? FinishGesture : CancelGesture;
- break;
-
- default:
- result |= Ignore;
- break;
- }
- }
- return result;
-}
-
-
-/*! \reimp
- */
-void QFlickGestureRecognizer::reset(QGesture *state)
-{
- QGestureRecognizer::reset(state);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_GESTURES
diff --git a/src/gui/util/qflickgesture_p.h b/src/gui/util/qflickgesture_p.h
deleted file mode 100644
index 451b579..0000000
--- a/src/gui/util/qflickgesture_p.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
-** this package.
-**
-** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFLICKGESTURE_P_H
-#define QFLICKGESTURE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qevent.h"
-#include "qgesturerecognizer.h"
-#include "private/qgesture_p.h"
-#include "qscroller.h"
-#include "qscopedpointer.h"
-
-#ifndef QT_NO_GESTURES
-
-QT_BEGIN_NAMESPACE
-
-class QFlickGesturePrivate;
-class QGraphicsItem;
-
-class Q_GUI_EXPORT QFlickGesture : public QGesture
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QFlickGesture)
-
-public:
- QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject *parent = 0);
- ~QFlickGesture();
-
- friend class QFlickGestureRecognizer;
-};
-
-class PressDelayHandler;
-
-class QFlickGesturePrivate : public QGesturePrivate
-{
- Q_DECLARE_PUBLIC(QFlickGesture)
-public:
- QFlickGesturePrivate();
-
- QPointer<QObject> receiver;
- QScroller *receiverScroller;
- Qt::MouseButton button; // NoButton == Touch
- bool macIgnoreWheel;
- static PressDelayHandler *pressDelayHandler;
-};
-
-class QFlickGestureRecognizer : public QGestureRecognizer
-{
-public:
- QFlickGestureRecognizer(Qt::MouseButton button);
-
- QGesture *create(QObject *target);
- QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event);
- void reset(QGesture *state);
-
-private:
- Qt::MouseButton button; // NoButton == Touch
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_GESTURES
-
-#endif // QFLICKGESTURE_P_H
diff --git a/src/gui/util/qscroller.cpp b/src/gui/util/qscroller.cpp
deleted file mode 100644
index db128c1..0000000
--- a/src/gui/util/qscroller.cpp
+++ /dev/null
@@ -1,2059 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
-** this package.
-**
-** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qevent.h"
-#include "qwidget.h"
-#include "qscroller.h"
-#include "private/qflickgesture_p.h"
-#include "private/qscroller_p.h"
-#include "qscrollerproperties.h"
-#include "private/qscrollerproperties_p.h"
-#include "qnumeric.h"
-#include "math.h"
-
-#include <QTime>
-#include <QElapsedTimer>
-#include <QMap>
-#include <QApplication>
-#include <QAbstractScrollArea>
-#include <QGraphicsObject>
-#include <QGraphicsScene>
-#include <QGraphicsView>
-#include <QDesktopWidget>
-#include <QtCore/qmath.h>
-#include <QtGui/qevent.h>
-#include <qnumeric.h>
-
-#include <QtDebug>
-
-#if defined(Q_WS_X11)
-# include "private/qt_x11_p.h"
-#endif
-
-
-QT_BEGIN_NAMESPACE
-
-bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
-
-//#define QSCROLLER_DEBUG
-
-#ifdef QSCROLLER_DEBUG
-# define qScrollerDebug qDebug
-#else
-# define qScrollerDebug while (false) qDebug
-#endif
-
-QDebug &operator<<(QDebug &dbg, const QScrollerPrivate::ScrollSegment &s)
-{
- dbg << "\n Time: start:" << s.startTime << " duration:" << s.deltaTime << " stop progress:" << s.stopProgress;
- dbg << "\n Pos: start:" << s.startPos << " delta:" << s.deltaPos << " stop:" << s.stopPos;
- dbg << "\n Curve: type:" << s.curve.type() << "\n";
- return dbg;
-}
-
-
-// a few helper operators to make the code below a lot more readable:
-// otherwise a lot of ifs would have to be multi-line to check both the x
-// and y coordinate separately.
-
-// returns true only if the abs. value of BOTH x and y are <= f
-inline bool operator<=(const QPointF &p, qreal f)
-{
- return (qAbs(p.x()) <= f) && (qAbs(p.y()) <= f);
-}
-
-// returns true only if the abs. value of BOTH x and y are < f
-inline bool operator<(const QPointF &p, qreal f)
-{
- return (qAbs(p.x()) < f) && (qAbs(p.y()) < f);
-}
-
-// returns true if the abs. value of EITHER x or y are >= f
-inline bool operator>=(const QPointF &p, qreal f)
-{
- return (qAbs(p.x()) >= f) || (qAbs(p.y()) >= f);
-}
-
-// returns true if the abs. value of EITHER x or y are > f
-inline bool operator>(const QPointF &p, qreal f)
-{
- return (qAbs(p.x()) > f) || (qAbs(p.y()) > f);
-}
-
-// returns a new point with both coordinates having the abs. value of the original one
-inline QPointF qAbs(const QPointF &p)
-{
- return QPointF(qAbs(p.x()), qAbs(p.y()));
-}
-
-// returns a new point with all components of p1 multiplied by the corresponding components of p2
-inline QPointF operator*(const QPointF &p1, const QPointF &p2)
-{
- return QPointF(p1.x() * p2.x(), p1.y() * p2.y());
-}
-
-// returns a new point with all components of p1 divided by the corresponding components of p2
-inline QPointF operator/(const QPointF &p1, const QPointF &p2)
-{
- return QPointF(p1.x() / p2.x(), p1.y() / p2.y());
-}
-
-inline QPointF clampToRect(const QPointF &p, const QRectF &rect)
-{
- qreal x = qBound(rect.left(), p.x(), rect.right());
- qreal y = qBound(rect.top(), p.y(), rect.bottom());
- return QPointF(x, y);
-}
-
-// returns -1, 0 or +1 according to r being <0, ==0 or >0
-inline int qSign(qreal r)
-{
- return (r < 0) ? -1 : ((r > 0) ? 1 : 0);
-}
-
-// this version is not mathematically exact, but it just works for every
-// easing curve type (even custom ones)
-
-static qreal differentialForProgress(const QEasingCurve &curve, qreal pos)
-{
- const qreal dx = 0.01;
- qreal left = (pos < qreal(0.5)) ? pos : pos - qreal(dx);
- qreal right = (pos >= qreal(0.5)) ? pos : pos + qreal(dx);
- qreal d = (curve.valueForProgress(right) - curve.valueForProgress(left)) / qreal(dx);
-
- //qScrollerDebug() << "differentialForProgress(type: " << curve.type() << ", pos: " << pos << ") = " << d;
-
- return d;
-}
-
-// this version is not mathematically exact, but it just works for every
-// easing curve type (even custom ones)
-
-static qreal progressForValue(const QEasingCurve &curve, qreal value)
-{
- if (curve.type() >= QEasingCurve::InElastic &&
- curve.type() < QEasingCurve::Custom) {
- qWarning("progressForValue(): QEasingCurves of type %d do not have an inverse, since they are not injective.", curve.type());
- return value;
- }
- if (value < qreal(0) || value > qreal(1))
- return value;
-
- qreal progress = value, left(0), right(1);
- for (int iterations = 6; iterations; --iterations) {
- qreal v = curve.valueForProgress(progress);
- if (v < value)
- left = progress;
- else if (v > value)
- right = progress;
- else
- break;
- progress = (left + right) / qreal(2);
- }
- return progress;
-}
-
-
-#ifndef QT_NO_ANIMATION
-class QScrollTimer : public QAbstractAnimation
-{
-public:
- QScrollTimer(QScrollerPrivate *_d)
- : d(_d), ignoreUpdate(false), skip(0)
- { }
-
- int duration() const
- {
- return -1;
- }
-
- void start()
- {
- // QAbstractAnimation::start() will immediately call
- // updateCurrentTime(), but our state is not set correctly yet
- ignoreUpdate = true;
- QAbstractAnimation::start();
- ignoreUpdate = false;
- skip = 0;
- }
-
-protected:
- void updateCurrentTime(int /*currentTime*/)
- {
- if (!ignoreUpdate) {
- if (++skip >= d->frameRateSkip()) {
- skip = 0;
- d->timerTick();
- }
- }
- }
-
-private:
- QScrollerPrivate *d;
- bool ignoreUpdate;
- int skip;
-};
-#endif // QT_NO_ANIMATION
-
-/*!
- \class QScroller
- \brief The QScroller class enables kinetic scrolling for any scrolling widget or graphics item.
- \since 4.8
-
- With kinetic scrolling, the user can push the widget in a given
- direction and it will continue to scroll in this direction until it is
- stopped either by the user or by friction. Aspects of inertia, friction
- and other physical concepts can be changed in order to fine-tune an
- intuitive user experience.
-
- The QScroller object is the object that stores the current position and
- scrolling speed and takes care of updates.
- QScroller can be triggered by a flick gesture
-
- \code
- QWidget *w = ...;
- QScroller::grabGesture(w, QScroller::LeftMouseButtonGesture);
- \endcode
-
- or directly like this:
-
- \code
- QWidget *w = ...;
- QScroller *scroller = QScroller::scroller(w);
- scroller->scrollTo(QPointF(100, 100));
- \endcode
-
- The scrolled QObjects receive a QScrollPrepareEvent whenever the scroller needs to
- update its geometry information and a QScrollEvent whenever the content of the object should
- actually be scrolled.
-
- The scroller uses the global QAbstractAnimation timer to generate its QScrollEvents. This
- can be changed with QScrollerProperties::FrameRate on a per-QScroller basis.
-
- Several examples in the \c scroller examples directory show how QScroller,
- QScrollEvent and the scroller gesture can be used.
-
- Even though this kinetic scroller has a large number of settings available via
- QScrollerProperties, we recommend that you leave them all at their default, platform optimized
- values. Before changing them you can experiment with the \c plot example in
- the \c scroller examples directory.
-
- \sa QScrollEvent, QScrollPrepareEvent, QScrollerProperties
-*/
-
-typedef QMap<QObject *, QScroller *> ScrollerHash;
-typedef QSet<QScroller *> ScrollerSet;
-
-Q_GLOBAL_STATIC(ScrollerHash, qt_allScrollers)
-Q_GLOBAL_STATIC(ScrollerSet, qt_activeScrollers)
-
-/*!
- Returns \c true if a QScroller object was already created for \a target; \c false otherwise.
-
- \sa scroller()
-*/
-bool QScroller::hasScroller(QObject *target)
-{
- return (qt_allScrollers()->value(target));
-}
-
-/*!
- Returns the scroller for the given \a target.
- As long as the object exists this function will always return the same QScroller instance.
- If no QScroller exists for the \a target, one will implicitly be created.
- At no point more than one QScroller will be active on an object.
-
- \sa hasScroller(), target()
-*/
-QScroller *QScroller::scroller(QObject *target)
-{
- if (!target) {
- qWarning("QScroller::scroller() was called with a null target.");
- return 0;
- }
-
- if (qt_allScrollers()->contains(target))
- return qt_allScrollers()->value(target);
-
- QScroller *s = new QScroller(target);
- qt_allScrollers()->insert(target, s);
- return s;
-}
-
-/*!
- \overload
- This is the const version of scroller().
-*/
-const QScroller *QScroller::scroller(const QObject *target)
-{
- return scroller(const_cast<QObject*>(target));
-}
-
-/*!
- Returns an application wide list of currently active QScroller objects.
- Active QScroller objects are in a state() that is not QScroller::Inactive.
- This function is useful when writing your own gesture recognizer.
-*/
-QList<QScroller *> QScroller::activeScrollers()
-{
- return qt_activeScrollers()->toList();
-}
-
-/*!
- Returns the target object of this scroller.
- \sa hasScroller(), scroller()
- */
-QObject *QScroller::target() const
-{
- Q_D(const QScroller);
- return d->target;
-}
-
-/*!
- \fn QScroller::scrollerPropertiesChanged(const QScrollerProperties &newProperties);
-
- QScroller emits this signal whenever its scroller properties change.
- \a newProperties are the new scroller properties.
-
- \sa scrollerProperties
-*/
-
-
-/*! \property QScroller::scrollerProperties
- \brief The scroller properties of this scroller.
- The properties are used by the QScroller to determine its scrolling behavior.
-*/
-QScrollerProperties QScroller::scrollerProperties() const
-{
- Q_D(const QScroller);
- return d->properties;
-}
-
-void QScroller::setScrollerProperties(const QScrollerProperties &sp)
-{
- Q_D(QScroller);
- if (d->properties != sp) {
- d->properties = sp;
- emit scrollerPropertiesChanged(sp);
-
- // we need to force the recalculation here, since the overshootPolicy may have changed and
- // existing segments may include an overshoot animation.
- d->recalcScrollingSegments(true);
- }
-}
-
-#ifndef QT_NO_GESTURES
-
-/*!
- Registers a custom scroll gesture recognizer, grabs it for the \a
- target and returns the resulting gesture type. If \a scrollGestureType is
- set to TouchGesture the gesture triggers on touch events. If it is set to
- one of LeftMouseButtonGesture, RightMouseButtonGesture or
- MiddleMouseButtonGesture it triggers on mouse events of the
- corresponding button.
-
- Only one scroll gesture can be active on a single object at the same
- time. If you call this function twice on the same object, it will
- ungrab the existing gesture before grabbing the new one.
-
- \note To avoid unwanted side-effects, mouse events are consumed while
- the gesture is triggered. Since the initial mouse press event is
- not consumed, the gesture sends a fake mouse release event
- at the global position \c{(INT_MIN, INT_MIN)}. This ensures that
- internal states of the widget that received the original mouse press
- are consistent.
-
- \sa ungrabGesture, grabbedGesture
-*/
-Qt::GestureType QScroller::grabGesture(QObject *target, ScrollerGestureType scrollGestureType)
-{
- // ensure that a scroller for target is created
- QScroller *s = scroller(target);
- if (!s)
- return Qt::GestureType(0);
-
- QScrollerPrivate *sp = s->d_ptr;
- if (sp->recognizer)
- ungrabGesture(target); // ungrab the old gesture
-
- Qt::MouseButton button;
- switch (scrollGestureType) {
- case LeftMouseButtonGesture : button = Qt::LeftButton; break;
- case RightMouseButtonGesture : button = Qt::RightButton; break;
- case MiddleMouseButtonGesture: button = Qt::MiddleButton; break;
- default :
- case TouchGesture : button = Qt::NoButton; break; // NoButton == Touch
- }
-
- sp->recognizer = new QFlickGestureRecognizer(button);
- sp->recognizerType = QGestureRecognizer::registerRecognizer(sp->recognizer);
-
- if (target->isWidgetType()) {
- QWidget *widget = static_cast<QWidget *>(target);
- widget->grabGesture(sp->recognizerType);
- if (scrollGestureType == TouchGesture)
- widget->setAttribute(Qt::WA_AcceptTouchEvents);
-#ifndef QT_NO_GRAPHICSVIEW
- } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) {
- if (scrollGestureType == TouchGesture)
- go->setAcceptTouchEvents(true);
- go->grabGesture(sp->recognizerType);
-#endif // QT_NO_GRAPHICSVIEW
- }
- return sp->recognizerType;
-}
-
-/*!
- Returns the gesture type currently grabbed for the \a target or 0 if no
- gesture is grabbed.
-
- \sa grabGesture, ungrabGesture
-*/
-Qt::GestureType QScroller::grabbedGesture(QObject *target)
-{
- QScroller *s = scroller(target);
- if (s && s->d_ptr)
- return s->d_ptr->recognizerType;
- else
- return Qt::GestureType(0);
-}
-
-/*!
- Ungrabs the gesture for the \a target.
- Does nothing if no gesture is grabbed.
-
- \sa grabGesture, grabbedGesture
-*/
-void QScroller::ungrabGesture(QObject *target)
-{
- QScroller *s = scroller(target);
- if (!s)
- return;
-
- QScrollerPrivate *sp = s->d_ptr;
- if (!sp->recognizer)
- return; // nothing to do
-
- if (target->isWidgetType()) {
- QWidget *widget = static_cast<QWidget *>(target);
- widget->ungrabGesture(sp->recognizerType);
-#ifndef QT_NO_GRAPHICSVIEW
- } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) {
- go->ungrabGesture(sp->recognizerType);
-#endif
- }
-
- QGestureRecognizer::unregisterRecognizer(sp->recognizerType);
- // do not delete the recognizer. The QGestureManager is doing this.
- sp->recognizer = 0;
-}
-
-#endif // QT_NO_GESTURES
-
-/*!
- \internal
-*/
-QScroller::QScroller(QObject *target)
- : d_ptr(new QScrollerPrivate(this, target))
-{
- Q_ASSERT(target); // you can't create a scroller without a target in any normal way
- Q_D(QScroller);
- d->init();
-}
-
-/*!
- \internal
-*/
-QScroller::~QScroller()
-{
- Q_D(QScroller);
-#ifndef QT_NO_GESTURES
- QGestureRecognizer::unregisterRecognizer(d->recognizerType);
- // do not delete the recognizer. The QGestureManager is doing this.
- d->recognizer = 0;
-#endif
- qt_allScrollers()->remove(d->target);
- qt_activeScrollers()->remove(this);
-
- delete d_ptr;
-}
-
-
-/*!
- \fn QScroller::stateChanged(QScroller::State newState);
-
- QScroller emits this signal whenever the state changes. \a newState is the new State.
-
- \sa state
-*/
-
-/*!
- \property QScroller::state
- \brief the state of the scroller
-
- \sa QScroller::State
-*/
-QScroller::State QScroller::state() const
-{
- Q_D(const QScroller);
- return d->state;
-}
-
-/*!
- Stops the scroller and resets its state back to Inactive.
-*/
-void QScroller::stop()
-{
- Q_D(QScroller);
- if (d->state != Inactive) {
- QPointF here = clampToRect(d->contentPosition, d->contentPosRange);
- qreal snapX = d->nextSnapPos(here.x(), 0, Qt::Horizontal);
- qreal snapY = d->nextSnapPos(here.y(), 0, Qt::Vertical);
- QPointF snap = here;
- if (!qIsNaN(snapX))
- snap.setX(snapX);
- if (!qIsNaN(snapY))
- snap.setY(snapY);
- d->contentPosition = snap;
- d->overshootPosition = QPointF(0, 0);
-
- d->setState(Inactive);
- }
-}
-
-/*!
- Returns the pixel per meter metric for the scrolled widget.
-
- The value is reported for both the x and y axis separately by using a QPointF.
-
- \note Please note that this value should be physically correct. The actual DPI settings
- that Qt returns for the display may be reported wrongly on purpose by the underlying
- windowing system, for example on Mac OS X or Maemo 5.
-*/
-QPointF QScroller::pixelPerMeter() const
-{
- Q_D(const QScroller);
- QPointF ppm = d->pixelPerMeter;
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->target)) {
- QTransform viewtr;
- //TODO: the first view isn't really correct - maybe use an additional field in the prepare event?
- if (go->scene() && !go->scene()->views().isEmpty())
- viewtr = go->scene()->views().first()->viewportTransform();
- QTransform tr = go->deviceTransform(viewtr);
- if (tr.isScaling()) {
- QPointF p0 = tr.map(QPointF(0, 0));
- QPointF px = tr.map(QPointF(1, 0));
- QPointF py = tr.map(QPointF(0, 1));
- ppm.rx() /= QLineF(p0, px).length();
- ppm.ry() /= QLineF(p0, py).length();
- }
- }
-#endif // QT_NO_GRAPHICSVIEW
- return ppm;
-}
-
-/*!
- Returns the current scrolling velocity in meter per second when the state is Scrolling or Dragging.
- Returns a zero velocity otherwise.
-
- The velocity is reported for both the x and y axis separately by using a QPointF.
-
- \sa pixelPerMeter()
-*/
-QPointF QScroller::velocity() const
-{
- Q_D(const QScroller);
- const QScrollerPropertiesPrivate *sp = d->properties.d.data();
-
- switch (state()) {
- case Dragging:
- return d->releaseVelocity;
- case Scrolling: {
- QPointF vel;
- qint64 now = d->monotonicTimer.elapsed();
-
- if (!d->xSegments.isEmpty()) {
- const QScrollerPrivate::ScrollSegment &s = d->xSegments.head();
- qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime);
- qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress);
- vel.setX(v);
- }
-
- if (!d->ySegments.isEmpty()) {
- const QScrollerPrivate::ScrollSegment &s = d->ySegments.head();
- qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime);
- qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress);
- vel.setY(v);
- }
- return vel;
- }
- default:
- return QPointF(0, 0);
- }
-}
-
-/*!
- Returns the estimated final position for the current scroll movement.
- Returns the current position if the scroller state is not Scrolling.
- The result is undefined when the scroller state is Inactive.
-
- The target position is in pixel.
-
- \sa pixelPerMeter(), scrollTo()
-*/
-QPointF QScroller::finalPosition() const
-{
- Q_D(const QScroller);
- return QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal),
- d->scrollingSegmentsEndPos(Qt::Vertical));
-}
-
-/*!
- Starts scrolling the widget so that point \a pos is at the top-left position in
- the viewport.
-
- The behaviour when scrolling outside the valid scroll area is undefined.
- In this case the scroller might or might not overshoot.
-
- The scrolling speed will be calculated so that the given position will
- be reached after a platform-defined time span.
-
- \a pos is given in viewport coordinates.
-
- \sa ensureVisible()
-*/
-void QScroller::scrollTo(const QPointF &pos)
-{
- // we could make this adjustable via QScrollerProperties
- scrollTo(pos, 300);
-}
-
-/*! \overload
-
- This version will reach its destination position in \a scrollTime milliseconds.
-*/
-void QScroller::scrollTo(const QPointF &pos, int scrollTime)
-{
- Q_D(QScroller);
-
- if (d->state == Pressed || d->state == Dragging )
- return;
-
- // no need to resend a prepare event if we are already scrolling
- if (d->state == Inactive && !d->prepareScrolling(QPointF()))
- return;
-
- QPointF newpos = clampToRect(pos, d->contentPosRange);
- qreal snapX = d->nextSnapPos(newpos.x(), 0, Qt::Horizontal);
- qreal snapY = d->nextSnapPos(newpos.y(), 0, Qt::Vertical);
- if (!qIsNaN(snapX))
- newpos.setX(snapX);
- if (!qIsNaN(snapY))
- newpos.setY(snapY);
-
- qScrollerDebug() << "QScroller::scrollTo(req:" << pos << " [pix] / snap:" << newpos << ", " << scrollTime << " [ms])";
-
- if (newpos == d->contentPosition + d->overshootPosition)
- return;
-
- QPointF vel = velocity();
-
- if (scrollTime < 0)
- scrollTime = 0;
- qreal time = qreal(scrollTime) / 1000;
-
- d->createScrollToSegments(vel.x(), time, newpos.x(), Qt::Horizontal, QScrollerPrivate::ScrollTypeScrollTo);
- d->createScrollToSegments(vel.y(), time, newpos.y(), Qt::Vertical, QScrollerPrivate::ScrollTypeScrollTo);
-
- if (!scrollTime)
- d->setContentPositionHelperScrolling();
- d->setState(scrollTime ? Scrolling : Inactive);
-}
-
-/*!
- Starts scrolling so that the rectangle \a rect is visible inside the
- viewport with additional margins specified in pixels by \a xmargin and \a ymargin around
- the rect.
-
- In cases where it is not possible to fit the rect plus margins inside the viewport the contents
- are scrolled so that as much as possible is visible from \a rect.
-
- The scrolling speed is calculated so that the given position is reached after a platform-defined
- time span.
-
- This function performs the actual scrolling by calling scrollTo().
-
- \sa scrollTo
-*/
-void QScroller::ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin)
-{
- // we could make this adjustable via QScrollerProperties
- ensureVisible(rect, xmargin, ymargin, 1000);
-}
-
-/*! \overload
-
- This version will reach its destination position in \a scrollTime milliseconds.
-*/
-void QScroller::ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime)
-{
- Q_D(QScroller);
-
- if (d->state == Pressed || d->state == Dragging )
- return;
-
- if (d->state == Inactive && !d->prepareScrolling(QPointF()))
- return;
-
- // -- calculate the current pos (or the position after the current scroll)
- QPointF startPos = d->contentPosition + d->overshootPosition;
- startPos = QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal),
- d->scrollingSegmentsEndPos(Qt::Vertical));
-
- QRectF marginRect(rect.x() - xmargin, rect.y() - ymargin,
- rect.width() + 2 * xmargin, rect.height() + 2 * ymargin);
-
- QSizeF visible = d->viewportSize;
- QRectF visibleRect(startPos, visible);
-
- qScrollerDebug() << "QScroller::ensureVisible(" << rect << " [pix], " << xmargin << " [pix], " << ymargin << " [pix], " << scrollTime << "[ms])";
- qScrollerDebug() << " --> content position:" << d->contentPosition;
-
- if (visibleRect.contains(marginRect))
- return;
-
- QPointF newPos = startPos;
-
- if (visibleRect.width() < rect.width()) {
- // at least try to move the rect into view
- if (rect.left() > visibleRect.left())
- newPos.setX(rect.left());
- else if (rect.right() < visibleRect.right())
- newPos.setX(rect.right() - visible.width());
-
- } else if (visibleRect.width() < marginRect.width()) {
- newPos.setX(rect.center().x() - visibleRect.width() / 2);
- } else if (marginRect.left() > visibleRect.left()) {
- newPos.setX(marginRect.left());
- } else if (marginRect.right() < visibleRect.right()) {
- newPos.setX(marginRect.right() - visible.width());
- }
-
- if (visibleRect.height() < rect.height()) {
- // at least try to move the rect into view
- if (rect.top() > visibleRect.top())
- newPos.setX(rect.top());
- else if (rect.bottom() < visibleRect.bottom())
- newPos.setX(rect.bottom() - visible.height());
-
- } else if (visibleRect.height() < marginRect.height()) {
- newPos.setY(rect.center().y() - visibleRect.height() / 2);
- } else if (marginRect.top() > visibleRect.top()) {
- newPos.setY(marginRect.top());
- } else if (marginRect.bottom() < visibleRect.bottom()) {
- newPos.setY(marginRect.bottom() - visible.height());
- }
-
- // clamp to maximum content position
- newPos = clampToRect(newPos, d->contentPosRange);
- if (newPos == startPos)
- return;
-
- scrollTo(newPos, scrollTime);
-}
-
-/*! This function resends the QScrollPrepareEvent.
- Calling resendPrepareEvent triggers a QScrollPrepareEvent from the scroller.
- This allows the receiver to re-set content position and content size while
- scrolling.
- Calling this function while in the Inactive state is useless as the prepare event
- is sent again before scrolling starts.
- */
-void QScroller::resendPrepareEvent()
-{
- Q_D(QScroller);
- d->prepareScrolling(d->pressPosition);
-}
-
-/*! Set the snap positions for the horizontal axis to a list of \a positions.
- This overwrites all previously set snap positions and also a previously
- set snapping interval.
- Snapping can be deactivated by setting an empty list of positions.
- */
-void QScroller::setSnapPositionsX(const QList<qreal> &positions)
-{
- Q_D(QScroller);
- d->snapPositionsX = positions;
- d->snapIntervalX = 0.0;
-
- d->recalcScrollingSegments();
-}
-
-/*! Set the snap positions for the horizontal axis to regular spaced intervals.
- The first snap position is at \a first. The next at \a first + \a interval.
- This can be used to implement a list header.
- This overwrites all previously set snap positions and also a previously
- set snapping interval.
- Snapping can be deactivated by setting an interval of 0.0
- */
-void QScroller::setSnapPositionsX(qreal first, qreal interval)
-{
- Q_D(QScroller);
- d->snapFirstX = first;
- d->snapIntervalX = interval;
- d->snapPositionsX.clear();
-
- d->recalcScrollingSegments();
-}
-
-/*! Set the snap positions for the vertical axis to a list of \a positions.
- This overwrites all previously set snap positions and also a previously
- set snapping interval.
- Snapping can be deactivated by setting an empty list of positions.
- */
-void QScroller::setSnapPositionsY(const QList<qreal> &positions)
-{
- Q_D(QScroller);
- d->snapPositionsY = positions;
- d->snapIntervalY = 0.0;
-
- d->recalcScrollingSegments();
-}
-
-/*! Set the snap positions for the vertical axis to regular spaced intervals.
- The first snap position is at \a first. The next at \a first + \a interval.
- This overwrites all previously set snap positions and also a previously
- set snapping interval.
- Snapping can be deactivated by setting an interval of 0.0
- */
-void QScroller::setSnapPositionsY(qreal first, qreal interval)
-{
- Q_D(QScroller);
- d->snapFirstY = first;
- d->snapIntervalY = interval;
- d->snapPositionsY.clear();
-
- d->recalcScrollingSegments();
-}
-
-
-
-// -------------- private ------------
-
-QScrollerPrivate::QScrollerPrivate(QScroller *q, QObject *_target)
- : target(_target)
-#ifndef QT_NO_GESTURES
- , recognizer(0)
- , recognizerType(Qt::CustomGesture)
-#endif
- , state(QScroller::Inactive)
- , firstScroll(true)
- , pressTimestamp(0)
- , lastTimestamp(0)
- , snapFirstX(-1.0)
- , snapIntervalX(0.0)
- , snapFirstY(-1.0)
- , snapIntervalY(0.0)
-#ifndef QT_NO_ANIMATION
- , scrollTimer(new QScrollTimer(this))
-#endif
- , q_ptr(q)
-{
- connect(target, SIGNAL(destroyed(QObject*)), this, SLOT(targetDestroyed()));
-}
-
-void QScrollerPrivate::init()
-{
- setDpiFromWidget(0);
- monotonicTimer.start();
-}
-
-void QScrollerPrivate::sendEvent(QObject *o, QEvent *e)
-{
- qt_sendSpontaneousEvent(o, e);
-}
-
-const char *QScrollerPrivate::stateName(QScroller::State state)
-{
- switch (state) {
- case QScroller::Inactive: return "inactive";
- case QScroller::Pressed: return "pressed";
- case QScroller::Dragging: return "dragging";
- case QScroller::Scrolling: return "scrolling";
- default: return "(invalid)";
- }
-}
-
-const char *QScrollerPrivate::inputName(QScroller::Input input)
-{
- switch (input) {
- case QScroller::InputPress: return "press";
- case QScroller::InputMove: return "move";
- case QScroller::InputRelease: return "release";
- default: return "(invalid)";
- }
-}
-
-void QScrollerPrivate::targetDestroyed()
-{
-#ifndef QT_NO_ANIMATION
- scrollTimer->stop();
-#endif
- delete q_ptr;
-}
-
-void QScrollerPrivate::timerTick()
-{
- struct timerevent {
- QScroller::State state;
- typedef void (QScrollerPrivate::*timerhandler_t)();
- timerhandler_t handler;
- };
-
- timerevent timerevents[] = {
- { QScroller::Dragging, &QScrollerPrivate::timerEventWhileDragging },
- { QScroller::Scrolling, &QScrollerPrivate::timerEventWhileScrolling },
- };
-
- for (int i = 0; i < int(sizeof(timerevents) / sizeof(*timerevents)); ++i) {
- timerevent *te = timerevents + i;
-
- if (state == te->state) {
- (this->*te->handler)();
- return;
- }
- }
-
-#ifndef QT_NO_ANIMATION
- scrollTimer->stop();
-#endif
-}
-
-/*!
- This function is used by gesture recognizers to inform the scroller about a new input event.
- The scroller changes its internal state() according to the input event and its attached
- scroller properties. The scroller doesn't distinguish between the kind of input device the
- event came from. Therefore the event needs to be split into the \a input type, a \a position and a
- milli-second \a timestamp. The \a position needs to be in the target's coordinate system.
-
- The return value is \c true if the event should be consumed by the calling filter or \c false
- if the event should be forwarded to the control.
-
- \note Using grabGesture() should be sufficient for most use cases.
-*/
-bool QScroller::handleInput(Input input, const QPointF &position, qint64 timestamp)
-{
- Q_D(QScroller);
-
- qScrollerDebug() << "QScroller::handleInput(" << input << ", " << d->stateName(d->state) << ", " << position << ", " << timestamp << ")";
- struct statechange {
- State state;
- Input input;
- typedef bool (QScrollerPrivate::*inputhandler_t)(const QPointF &position, qint64 timestamp);
- inputhandler_t handler;
- };
-
- statechange statechanges[] = {
- { QScroller::Inactive, InputPress, &QScrollerPrivate::pressWhileInactive },
- { QScroller::Pressed, InputMove, &QScrollerPrivate::moveWhilePressed },
- { QScroller::Pressed, InputRelease, &QScrollerPrivate::releaseWhilePressed },
- { QScroller::Dragging, InputMove, &QScrollerPrivate::moveWhileDragging },
- { QScroller::Dragging, InputRelease, &QScrollerPrivate::releaseWhileDragging },
- { QScroller::Scrolling, InputPress, &QScrollerPrivate::pressWhileScrolling }
- };
-
- for (int i = 0; i < int(sizeof(statechanges) / sizeof(*statechanges)); ++i) {
- statechange *sc = statechanges + i;
-
- if (d->state == sc->state && input == sc->input)
- return (d->*sc->handler)(position - d->overshootPosition, timestamp);
- }
- return false;
-}
-
-#if !defined(Q_WS_MAC)
-// the Mac version is implemented in qscroller_mac.mm
-
-QPointF QScrollerPrivate::realDpi(int screen)
-{
-# ifdef Q_WS_MAEMO_5
- Q_UNUSED(screen);
-
- // The DPI value is hardcoded to 96 on Maemo5:
- // https://projects.maemo.org/bugzilla/show_bug.cgi?id=152525
- // This value (260) is only correct for the N900 though, but
- // there's no way to get the real DPI at run time.
- return QPointF(260, 260);
-
-# elif defined(Q_WS_X11) && !defined(QT_NO_XRANDR)
- if (X11 && X11->use_xrandr && X11->ptrXRRSizes && X11->ptrXRRRootToScreen) {
- int nsizes = 0;
- // QDesktopWidget is based on Xinerama screens, which do not always
- // correspond to RandR screens: NVidia's TwinView e.g. will show up
- // as 2 screens in QDesktopWidget, but libXRandR will only see 1 screen.
- // (although with the combined size of the Xinerama screens).
- // Additionally, libXrandr will simply crash when calling XRRSizes
- // for (the non-existent) screen 1 in this scenario.
- Window root = RootWindow(X11->display, screen == -1 ? X11->defaultScreen : screen);
- int randrscreen = (root != XNone) ? X11->ptrXRRRootToScreen(X11->display, root) : -1;
-
- XRRScreenSize *sizes = X11->ptrXRRSizes(X11->display, randrscreen == -1 ? 0 : randrscreen, &nsizes);
- if (nsizes > 0 && sizes && sizes->width && sizes->height && sizes->mwidth && sizes->mheight) {
- qScrollerDebug() << "XRandR DPI:" << QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth),
- qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight));
- return QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth),
- qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight));
- }
- }
-# endif
-
- QWidget *w = QApplication::desktop()->screen(screen);
- return QPointF(w->physicalDpiX(), w->physicalDpiY());
-}
-
-#endif // !Q_WS_MAC
-
-
-/*! \internal
- Returns the resolution of the used screen.
-*/
-QPointF QScrollerPrivate::dpi() const
-{
- return pixelPerMeter * qreal(0.0254);
-}
-
-/*! \internal
- Sets the resolution used for scrolling.
- This resolution is only used by the kinetic scroller. If you change this
- then the scroller will behave quite different as a lot of the values are
- given in physical distances (millimeter).
-*/
-void QScrollerPrivate::setDpi(const QPointF &dpi)
-{
- pixelPerMeter = dpi / qreal(0.0254);
-}
-
-/*! \internal
- Sets the dpi used for scrolling to the value of the widget.
-*/
-void QScrollerPrivate::setDpiFromWidget(QWidget *widget)
-{
- QDesktopWidget *dw = QApplication::desktop();
- setDpi(realDpi(widget ? dw->screenNumber(widget) : dw->primaryScreen()));
-}
-
-/*! \internal
- Updates the velocity during dragging.
- Sets releaseVelocity.
-*/
-void QScrollerPrivate::updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime)
-{
- if (deltaTime <= 0)
- return;
-
- Q_Q(QScroller);
- QPointF ppm = q->pixelPerMeter();
- const QScrollerPropertiesPrivate *sp = properties.d.data();
- QPointF deltaPixel = deltaPixelRaw;
-
- qScrollerDebug() << "QScroller::updateVelocity(" << deltaPixelRaw << " [delta pix], " << deltaTime << " [delta ms])";
-
- // faster than 2.5mm/ms seems bogus (that would be a screen height in ~20 ms)
- if (((deltaPixelRaw / qreal(deltaTime)).manhattanLength() / ((ppm.x() + ppm.y()) / 2) * 1000) > qreal(2.5))
- deltaPixel = deltaPixelRaw * qreal(2.5) * ppm / 1000 / (deltaPixelRaw / qreal(deltaTime)).manhattanLength();
-
- QPointF newv = -deltaPixel / qreal(deltaTime) * qreal(1000) / ppm;
- // around 95% of all updates are in the [1..50] ms range, so make sure
- // to scale the smoothing factor over that range: this way a 50ms update
- // will have full impact, while 5ms update will only have a 10% impact.
- qreal smoothing = sp->dragVelocitySmoothingFactor * qMin(qreal(deltaTime), qreal(50)) / qreal(50);
-
- // only smooth if we already have a release velocity and only if the
- // user hasn't stopped to move his finger for more than 100ms
- if ((releaseVelocity != QPointF(0, 0)) && (deltaTime < 100)) {
- qScrollerDebug() << "SMOOTHED from " << newv << " to " << newv * smoothing + releaseVelocity * (qreal(1) - smoothing);
- // smooth x or y only if the new velocity is either 0 or at least in
- // the same direction of the release velocity
- if (!newv.x() || (qSign(releaseVelocity.x()) == qSign(newv.x())))
- newv.setX(newv.x() * smoothing + releaseVelocity.x() * (qreal(1) - smoothing));
- if (!newv.y() || (qSign(releaseVelocity.y()) == qSign(newv.y())))
- newv.setY(newv.y() * smoothing + releaseVelocity.y() * (qreal(1) - smoothing));
- } else
- qScrollerDebug() << "NO SMOOTHING to " << newv;
-
- releaseVelocity.setX(qBound(-sp->maximumVelocity, newv.x(), sp->maximumVelocity));
- releaseVelocity.setY(qBound(-sp->maximumVelocity, newv.y(), sp->maximumVelocity));
-
- qScrollerDebug() << " --> new velocity:" << releaseVelocity;
-}
-
-void QScrollerPrivate::pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation)
-{
- if (startPos == stopPos || deltaPos == 0)
- return;
-
- ScrollSegment s;
- if (orientation == Qt::Horizontal && !xSegments.isEmpty())
- s.startTime = xSegments.last().startTime + xSegments.last().deltaTime * xSegments.last().stopProgress;
- else if (orientation == Qt::Vertical && !ySegments.isEmpty())
- s.startTime = ySegments.last().startTime + ySegments.last().deltaTime * ySegments.last().stopProgress;
- else
- s.startTime = monotonicTimer.elapsed();
-
- s.startPos = startPos;
- s.deltaPos = deltaPos;
- s.stopPos = stopPos;
- s.deltaTime = deltaTime * 1000;
- s.stopProgress = stopProgress;
- s.curve.setType(curve);
- s.type = type;
-
- if (orientation == Qt::Horizontal)
- xSegments.enqueue(s);
- else
- ySegments.enqueue(s);
-
- qScrollerDebug() << "+++ Added a new ScrollSegment: " << s;
-}
-
-
-/*! \internal
- Clears the old segments and recalculates them if the current segments are not longer valid
-*/
-void QScrollerPrivate::recalcScrollingSegments(bool forceRecalc)
-{
- Q_Q(QScroller);
- QPointF ppm = q->pixelPerMeter();
-
- releaseVelocity = q->velocity();
-
- if (forceRecalc || !scrollingSegmentsValid(Qt::Horizontal))
- createScrollingSegments(releaseVelocity.x(), contentPosition.x() + overshootPosition.x(), ppm.x(), Qt::Horizontal);
-
- if (forceRecalc || !scrollingSegmentsValid(Qt::Vertical))
- createScrollingSegments(releaseVelocity.y(), contentPosition.y() + overshootPosition.y(), ppm.y(), Qt::Vertical);
-}
-
-/*! \internal
- Returns the end position after the current scroll has finished.
-*/
-qreal QScrollerPrivate::scrollingSegmentsEndPos(Qt::Orientation orientation) const
-{
- if (orientation == Qt::Horizontal) {
- if (xSegments.isEmpty())
- return contentPosition.x() + overshootPosition.x();
- else
- return xSegments.last().stopPos;
- } else {
- if (ySegments.isEmpty())
- return contentPosition.y() + overshootPosition.y();
- else
- return ySegments.last().stopPos;
- }
-}
-
-/*! \internal
- Checks if the scroller segment end in a valid position.
-*/
-bool QScrollerPrivate::scrollingSegmentsValid(Qt::Orientation orientation)
-{
- QQueue<ScrollSegment> *segments;
- qreal minPos;
- qreal maxPos;
-
- if (orientation == Qt::Horizontal) {
- segments = &xSegments;
- minPos = contentPosRange.left();
- maxPos = contentPosRange.right();
- } else {
- segments = &ySegments;
- minPos = contentPosRange.top();
- maxPos = contentPosRange.bottom();
- }
-
- if (segments->isEmpty())
- return true;
-
- const ScrollSegment &last = segments->last();
- qreal stopPos = last.stopPos;
-
- if (last.type == ScrollTypeScrollTo)
- return true; // scrollTo is always valid
-
- if (last.type == ScrollTypeOvershoot &&
- (stopPos != minPos && stopPos != maxPos))
- return false;
-
- if (stopPos < minPos || stopPos > maxPos)
- return false;
-
- if (stopPos == minPos || stopPos == maxPos) // the begin and the end of the list are always ok
- return true;
-
- qreal nextSnap = nextSnapPos(stopPos, 0, orientation);
- if (!qIsNaN(nextSnap) && stopPos != nextSnap)
- return false;
-
- return true;
-}
-
-/*! \internal
- Creates the sections needed to scroll to the specific \a endPos to the segments queue.
-*/
-void QScrollerPrivate::createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type)
-{
- Q_UNUSED(v);
-
- if (orientation == Qt::Horizontal)
- xSegments.clear();
- else
- ySegments.clear();
-
- qScrollerDebug() << "+++ createScrollToSegments: t:" << deltaTime << "ep:" << endPos << "o:" << int(orientation);
-
- const QScrollerPropertiesPrivate *sp = properties.d.data();
-
- qreal startPos = (orientation == Qt::Horizontal) ? contentPosition.x() + overshootPosition.x()
- : contentPosition.y() + overshootPosition.y();
- qreal deltaPos = (endPos - startPos) / 2;
-
- pushSegment(type, deltaTime * qreal(0.3), qreal(1.0), startPos, deltaPos, startPos + deltaPos, QEasingCurve::InQuad, orientation);
- pushSegment(type, deltaTime * qreal(0.7), qreal(1.0), startPos + deltaPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation);
-}
-
-/*! \internal
-*/
-void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qreal ppm, Qt::Orientation orientation)
-{
- const QScrollerPropertiesPrivate *sp = properties.d.data();
-
- QScrollerProperties::OvershootPolicy policy;
- qreal minPos;
- qreal maxPos;
- qreal viewSize;
-
- if (orientation == Qt::Horizontal) {
- xSegments.clear();
- policy = sp->hOvershootPolicy;
- minPos = contentPosRange.left();
- maxPos = contentPosRange.right();
- viewSize = viewportSize.width();
- } else {
- ySegments.clear();
- policy = sp->vOvershootPolicy;
- minPos = contentPosRange.top();
- maxPos = contentPosRange.bottom();
- viewSize = viewportSize.height();
- }
-
- bool alwaysOvershoot = (policy == QScrollerProperties::OvershootAlwaysOn);
- bool noOvershoot = (policy == QScrollerProperties::OvershootAlwaysOff) || !sp->overshootScrollDistanceFactor;
- bool canOvershoot = !noOvershoot && (alwaysOvershoot || maxPos);
-
- qScrollerDebug() << "+++ createScrollingSegments: s:" << startPos << "maxPos:" << maxPos << "o:" << int(orientation);
-
- qScrollerDebug() << "v = " << v << ", decelerationFactor = " << sp->decelerationFactor << ", curveType = " << sp->scrollingCurve.type();
-
- // This is only correct for QEasingCurve::OutQuad (linear velocity,
- // constant deceleration), but the results look and feel ok for OutExpo
- // and OutSine as well
-
- // v(t) = deltaTime * a * 0.5 * differentialForProgress(t / deltaTime)
- // v(0) = vrelease
- // v(deltaTime) = 0
- // deltaTime = (2 * vrelease) / (a * differntial(0))
-
- // pos(t) = integrate(v(t)dt)
- // pos(t) = vrelease * t - 0.5 * a * t * t
- // pos(t) = deltaTime * a * 0.5 * progress(t / deltaTime) * deltaTime
- // deltaPos = pos(deltaTime)
-
- qreal deltaTime = (qreal(2) * qAbs(v)) / (sp->decelerationFactor * differentialForProgress(sp->scrollingCurve, 0));
- qreal deltaPos = qSign(v) * deltaTime * deltaTime * qreal(0.5) * sp->decelerationFactor * ppm;
- qreal endPos = startPos + deltaPos;
-
- qScrollerDebug() << " Real Delta:" << deltaPos;
-
- // -- determine snap points
- qreal nextSnap = nextSnapPos(endPos, 0, orientation);
- qreal lowerSnapPos = nextSnapPos(startPos, -1, orientation);
- qreal higherSnapPos = nextSnapPos(startPos, 1, orientation);
-
- qScrollerDebug() << " Real Delta:" << lowerSnapPos <<"-"<<nextSnap <<"-"<<higherSnapPos;
-
- // - check if we can reach another snap point
- if (nextSnap > higherSnapPos || qIsNaN(higherSnapPos))
- higherSnapPos = nextSnap;
- if (nextSnap < lowerSnapPos || qIsNaN(lowerSnapPos))
- lowerSnapPos = nextSnap;
-
- // -- check if are in overshoot and end in overshoot
- if ((startPos < minPos && endPos < minPos) ||
- (startPos > maxPos && endPos > maxPos)) {
- qreal stopPos = endPos < minPos ? minPos : maxPos;
- qreal oDeltaTime = sp->overshootScrollTime;
-
- pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), startPos, stopPos - startPos, stopPos, sp->scrollingCurve.type(), orientation);
- return;
- }
-
- if (qAbs(v) < sp->minimumVelocity) {
-
- qScrollerDebug() << "### below minimum Vel" << orientation;
-
- // - no snap points or already at one
- if (qIsNaN(nextSnap) || nextSnap == startPos)
- return; // nothing to do, no scrolling needed.
-
- // - decide which point to use
-
- qreal snapDistance = higherSnapPos - lowerSnapPos;
-
- qreal pressDistance = (orientation == Qt::Horizontal) ?
- lastPosition.x() - pressPosition.x() :
- lastPosition.y() - pressPosition.y();
-
- // if not dragged far enough, pick the next snap point.
- if (sp->snapPositionRatio == 0.0 || qAbs(pressDistance / sp->snapPositionRatio) > snapDistance)
- endPos = nextSnap;
- else if (pressDistance < 0.0)
- endPos = lowerSnapPos;
- else
- endPos = higherSnapPos;
-
- deltaPos = endPos - startPos;
- qreal midPos = startPos + deltaPos * qreal(0.3);
- pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.3), qreal(1.0), startPos, midPos - startPos, midPos, QEasingCurve::InQuad, orientation);
- pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.7), qreal(1.0), midPos, endPos - midPos, endPos, sp->scrollingCurve.type(), orientation);
- return;
- }
-
- // - go to the next snappoint if there is one
- if (v > 0 && !qIsNaN(higherSnapPos)) {
- // change the time in relation to the changed end position
- if (endPos - startPos)
- deltaTime *= qAbs((higherSnapPos - startPos) / (endPos - startPos));
- if (deltaTime > sp->snapTime)
- deltaTime = sp->snapTime;
- endPos = higherSnapPos;
-
- } else if (v < 0 && !qIsNaN(lowerSnapPos)) {
- // change the time in relation to the changed end position
- if (endPos - startPos)
- deltaTime *= qAbs((lowerSnapPos - startPos) / (endPos - startPos));
- if (deltaTime > sp->snapTime)
- deltaTime = sp->snapTime;
- endPos = lowerSnapPos;
-
- // -- check if we are overshooting
- } else if (endPos < minPos || endPos > maxPos) {
- qreal stopPos = endPos < minPos ? minPos : maxPos;
-
- qScrollerDebug() << "Overshoot: delta:" << (stopPos - startPos);
-
- qreal stopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos - startPos) / deltaPos));
-
- if (!canOvershoot) {
- qScrollerDebug() << "Overshoot stopp:" << stopProgress;
-
- pushSegment(ScrollTypeFlick, deltaTime, stopProgress, startPos, endPos, stopPos, sp->scrollingCurve.type(), orientation);
- } else {
- qreal oDeltaTime = sp->overshootScrollTime;
- qreal oStopProgress = qMin(stopProgress + oDeltaTime * qreal(0.3) / deltaTime, qreal(1));
- qreal oDistance = startPos + deltaPos * sp->scrollingCurve.valueForProgress(oStopProgress) - stopPos;
- qreal oMaxDistance = qSign(oDistance) * (viewSize * sp->overshootScrollDistanceFactor);
-
- qScrollerDebug() << "1 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress;
-
- if (qAbs(oDistance) > qAbs(oMaxDistance)) {
- oStopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos + oMaxDistance - startPos) / deltaPos));
- oDistance = oMaxDistance;
- qScrollerDebug() << "2 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress;
- }
-
- pushSegment(ScrollTypeFlick, deltaTime, oStopProgress, startPos, deltaPos, stopPos + oDistance, sp->scrollingCurve.type(), orientation);
- pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), stopPos + oDistance, -oDistance, stopPos, sp->scrollingCurve.type(), orientation);
- }
- return;
- }
-
- pushSegment(ScrollTypeFlick, deltaTime, qreal(1.0), startPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation);
-}
-
-
-/*! \internal
- Prepares scrolling by sending a QScrollPrepareEvent to the receiver widget.
- Returns true if the scrolling was accepted and a target was returned.
-*/
-bool QScrollerPrivate::prepareScrolling(const QPointF &position)
-{
- QScrollPrepareEvent spe(position);
- spe.ignore();
- sendEvent(target, &spe);
-
- qScrollerDebug() << "QScrollPrepareEvent returned from" << target << "with" << spe.isAccepted() << "mcp:" << spe.contentPosRange() << "cp:" << spe.contentPos();
- if (spe.isAccepted()) {
- QPointF oldContentPos = contentPosition + overshootPosition;
- QPointF contentDelta = spe.contentPos() - oldContentPos;
-
- viewportSize = spe.viewportSize();
- contentPosRange = spe.contentPosRange();
- if (contentPosRange.width() < 0)
- contentPosRange.setWidth(0);
- if (contentPosRange.height() < 0)
- contentPosRange.setHeight(0);
- contentPosition = clampToRect(spe.contentPos(), contentPosRange);
- overshootPosition = spe.contentPos() - contentPosition;
-
- // - check if the content position was moved
- if (contentDelta != QPointF(0, 0)) {
- // need to correct all segments
- for (int i = 0; i < xSegments.count(); i++)
- xSegments[i].startPos -= contentDelta.x();
-
- for (int i = 0; i < ySegments.count(); i++)
- ySegments[i].startPos -= contentDelta.y();
- }
-
- if (QWidget *w = qobject_cast<QWidget *>(target))
- setDpiFromWidget(w);
-#ifndef QT_NO_GRAPHICSVIEW
- if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(target)) {
- //TODO: the first view isn't really correct - maybe use an additional field in the prepare event?
- if (go->scene() && !go->scene()->views().isEmpty())
- setDpiFromWidget(go->scene()->views().first());
- }
-#endif
-
- if (state == QScroller::Scrolling) {
- recalcScrollingSegments();
- }
- return true;
- }
-
- return false;
-}
-
-void QScrollerPrivate::handleDrag(const QPointF &position, qint64 timestamp)
-{
- const QScrollerPropertiesPrivate *sp = properties.d.data();
-
- QPointF deltaPixel = position - lastPosition;
- qint64 deltaTime = timestamp - lastTimestamp;
-
- if (sp->axisLockThreshold) {
- int dx = qAbs(deltaPixel.x());
- int dy = qAbs(deltaPixel.y());
- if (dx || dy) {
- bool vertical = (dy > dx);
- qreal alpha = qreal(vertical ? dx : dy) / qreal(vertical ? dy : dx);
- //qScrollerDebug() << "QScroller::handleDrag() -- axis lock:" << alpha << " / " << axisLockThreshold << "- isvertical:" << vertical << "- dx:" << dx << "- dy:" << dy;
- if (alpha <= sp->axisLockThreshold) {
- if (vertical)
- deltaPixel.setX(0);
- else
- deltaPixel.setY(0);
- }
- }
- }
-
- // calculate velocity (if the user would release the mouse NOW)
- updateVelocity(deltaPixel, deltaTime);
-
- // restrict velocity, if content is not scrollable
- QRectF max = contentPosRange;
- bool canScrollX = (max.width() > 0) || (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
- bool canScrollY = (max.height() > 0) || (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
-
- if (!canScrollX) {
- deltaPixel.setX(0);
- releaseVelocity.setX(0);
- }
- if (!canScrollY) {
- deltaPixel.setY(0);
- releaseVelocity.setY(0);
- }
-
-// if (firstDrag) {
-// // Do not delay the first drag
-// setContentPositionHelper(q->contentPosition() - overshootDistance - deltaPixel);
-// dragDistance = QPointF(0, 0);
-// } else {
- dragDistance += deltaPixel;
-// }
-//qScrollerDebug() << "######################" << deltaPixel << position.y() << lastPosition.y();
- if (canScrollX)
- lastPosition.setX(position.x());
- if (canScrollY)
- lastPosition.setY(position.y());
- lastTimestamp = timestamp;
-}
-
-bool QScrollerPrivate::pressWhileInactive(const QPointF &position, qint64 timestamp)
-{
- if (prepareScrolling(position)) {
- const QScrollerPropertiesPrivate *sp = properties.d.data();
-
- if (!contentPosRange.isNull() ||
- (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) ||
- (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)) {
-
- lastPosition = pressPosition = position;
- lastTimestamp = pressTimestamp = timestamp;
- setState(QScroller::Pressed);
- }
- }
- return false;
-}
-
-bool QScrollerPrivate::releaseWhilePressed(const QPointF &, qint64)
-{
- if (overshootPosition != QPointF(0.0, 0.0)) {
- setState(QScroller::Scrolling);
- return true;
- } else {
- setState(QScroller::Inactive);
- return false;
- }
-}
-
-bool QScrollerPrivate::moveWhilePressed(const QPointF &position, qint64 timestamp)
-{
- Q_Q(QScroller);
- const QScrollerPropertiesPrivate *sp = properties.d.data();
- QPointF ppm = q->pixelPerMeter();
-
- QPointF deltaPixel = position - pressPosition;
-
- bool moveAborted = false;
- bool moveStarted = (((deltaPixel / ppm).manhattanLength()) > sp->dragStartDistance);
-
- // check the direction of the mouse drag and abort if it's too much in the wrong direction.
- if (moveStarted) {
- QRectF max = contentPosRange;
- bool canScrollX = (max.width() > 0);
- bool canScrollY = (max.height() > 0);
-
- if (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)
- canScrollX = true;
- if (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)
- canScrollY = true;
-
- if (qAbs(deltaPixel.x() / ppm.x()) < qAbs(deltaPixel.y() / ppm.y())) {
- if (!canScrollY)
- moveAborted = true;
- } else {
- if (!canScrollX)
- moveAborted = true;
- }
- }
-
- if (moveAborted) {
- setState(QScroller::Inactive);
- moveStarted = false;
-
- } else if (moveStarted) {
- setState(QScroller::Dragging);
-
- // subtract the dragStartDistance
- deltaPixel = deltaPixel - deltaPixel * (sp->dragStartDistance / deltaPixel.manhattanLength());
-
- if (deltaPixel != QPointF(0, 0)) {
- // handleDrag updates lastPosition, lastTimestamp and velocity
- handleDrag(pressPosition + deltaPixel, timestamp);
- }
- }
- return moveStarted;
-}
-
-bool QScrollerPrivate::moveWhileDragging(const QPointF &position, qint64 timestamp)
-{
- // handleDrag updates lastPosition, lastTimestamp and velocity
- handleDrag(position, timestamp);
- return true;
-}
-
-void QScrollerPrivate::timerEventWhileDragging()
-{
- if (dragDistance != QPointF(0, 0)) {
- qScrollerDebug() << "QScroller::timerEventWhileDragging() -- dragDistance:" << dragDistance;
-
- setContentPositionHelperDragging(-dragDistance);
- dragDistance = QPointF(0, 0);
- }
-}
-
-bool QScrollerPrivate::releaseWhileDragging(const QPointF &position, qint64 timestamp)
-{
- Q_Q(QScroller);
- const QScrollerPropertiesPrivate *sp = properties.d.data();
-
- // handleDrag updates lastPosition, lastTimestamp and velocity
- handleDrag(position, timestamp);
-
- // check if we moved at all - this can happen if you stop a running
- // scroller with a press and release shortly afterwards
- QPointF deltaPixel = position - pressPosition;
- if (((deltaPixel / q->pixelPerMeter()).manhattanLength()) > sp->dragStartDistance) {
-
- // handle accelerating flicks
- if ((oldVelocity != QPointF(0, 0)) && sp->acceleratingFlickMaximumTime &&
- ((timestamp - pressTimestamp) < qint64(sp->acceleratingFlickMaximumTime * 1000))) {
-
- // - determine if the direction was changed
- int signX = 0, signY = 0;
- if (releaseVelocity.x())
- signX = (releaseVelocity.x() > 0) == (oldVelocity.x() > 0) ? 1 : -1;
- if (releaseVelocity.y())
- signY = (releaseVelocity.y() > 0) == (oldVelocity.y() > 0) ? 1 : -1;
-
- if (signX > 0)
- releaseVelocity.setX(qBound(-sp->maximumVelocity,
- oldVelocity.x() * sp->acceleratingFlickSpeedupFactor,
- sp->maximumVelocity));
- if (signY > 0)
- releaseVelocity.setY(qBound(-sp->maximumVelocity,
- oldVelocity.y() * sp->acceleratingFlickSpeedupFactor,
- sp->maximumVelocity));
- }
- }
-
- QPointF ppm = q->pixelPerMeter();
- createScrollingSegments(releaseVelocity.x(), contentPosition.x() + overshootPosition.x(), ppm.x(), Qt::Horizontal);
- createScrollingSegments(releaseVelocity.y(), contentPosition.y() + overshootPosition.y(), ppm.y(), Qt::Vertical);
-
- qScrollerDebug() << "QScroller::releaseWhileDragging() -- velocity:" << releaseVelocity << "-- minimum velocity:" << sp->minimumVelocity << "overshoot" << overshootPosition;
-
- if (xSegments.isEmpty() && ySegments.isEmpty())
- setState(QScroller::Inactive);
- else
- setState(QScroller::Scrolling);
-
- return true;
-}
-
-void QScrollerPrivate::timerEventWhileScrolling()
-{
- qScrollerDebug() << "QScroller::timerEventWhileScrolling()";
-
- setContentPositionHelperScrolling();
- if (xSegments.isEmpty() && ySegments.isEmpty())
- setState(QScroller::Inactive);
-}
-
-bool QScrollerPrivate::pressWhileScrolling(const QPointF &position, qint64 timestamp)
-{
- Q_Q(QScroller);
-
- if ((q->velocity() <= properties.d->maximumClickThroughVelocity) &&
- (overshootPosition == QPointF(0.0, 0.0))) {
- setState(QScroller::Inactive);
- return false;
- } else {
- lastPosition = pressPosition = position;
- lastTimestamp = pressTimestamp = timestamp;
- setState(QScroller::Pressed);
- setState(QScroller::Dragging);
- return true;
- }
-}
-
-/*! \internal
- This function handles all state changes of the scroller.
-*/
-void QScrollerPrivate::setState(QScroller::State newstate)
-{
- Q_Q(QScroller);
- bool sendLastScroll = false;
-
- if (state == newstate)
- return;
-
- qScrollerDebug() << q << "QScroller::setState(" << stateName(newstate) << ")";
-
- switch (newstate) {
- case QScroller::Inactive:
-#ifndef QT_NO_ANIMATION
- scrollTimer->stop();
-#endif
-
- // send the last scroll event (but only after the current state change was finished)
- if (!firstScroll)
- sendLastScroll = true;
-
- releaseVelocity = QPointF(0, 0);
- break;
-
- case QScroller::Pressed:
-#ifndef QT_NO_ANIMATION
- scrollTimer->stop();
-#endif
-
- oldVelocity = releaseVelocity;
- releaseVelocity = QPointF(0, 0);
- break;
-
- case QScroller::Dragging:
- dragDistance = QPointF(0, 0);
-#ifndef QT_NO_ANIMATION
- if (state == QScroller::Pressed)
- scrollTimer->start();
-#endif
- break;
-
- case QScroller::Scrolling:
-#ifndef QT_NO_ANIMATION
- scrollTimer->start();
-#endif
- break;
- }
-
- qSwap(state, newstate);
-
- if (sendLastScroll) {
- QScrollEvent se(contentPosition, overshootPosition, QScrollEvent::ScrollFinished);
- sendEvent(target, &se);
- firstScroll = true;
- }
- if (state == QScroller::Dragging || state == QScroller::Scrolling)
- qt_activeScrollers()->insert(q);
- else
- qt_activeScrollers()->remove(q);
- emit q->stateChanged(state);
-}
-
-
-/*! \internal
- Helps when setting the content position.
- It will try to move the content by the requested delta but stop in case
- when we are coming back from an overshoot or a scrollTo.
- It will also indicate a new overshooting condition by the overshootX and oversthootY flags.
-
- In this cases it will reset the velocity variables and other flags.
-
- Also keeps track of the current over-shooting value in overshootPosition.
-
- \a deltaPos is the amount of pixels the current content position should be moved
-*/
-void QScrollerPrivate::setContentPositionHelperDragging(const QPointF &deltaPos)
-{
- Q_Q(QScroller);
- QPointF ppm = q->pixelPerMeter();
- const QScrollerPropertiesPrivate *sp = properties.d.data();
- QPointF v = q->velocity();
-
- if (sp->overshootDragResistanceFactor)
- overshootPosition /= sp->overshootDragResistanceFactor;
-
- QPointF oldPos = contentPosition + overshootPosition;
- QPointF newPos = oldPos + deltaPos;
-
- qScrollerDebug() << "QScroller::setContentPositionHelperDragging(" << deltaPos << " [pix])";
- qScrollerDebug() << " --> overshoot:" << overshootPosition << "- old pos:" << oldPos << "- new pos:" << newPos;
-
- QPointF oldClampedPos = clampToRect(oldPos, contentPosRange);
- QPointF newClampedPos = clampToRect(newPos, contentPosRange);
-
- // --- handle overshooting and stop if the coordinate is going back inside the normal area
- bool alwaysOvershootX = (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
- bool alwaysOvershootY = (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
- bool noOvershootX = (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) ||
- ((state == QScroller::Dragging) && !sp->overshootDragResistanceFactor) ||
- !sp->overshootDragDistanceFactor;
- bool noOvershootY = (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) ||
- ((state == QScroller::Dragging) && !sp->overshootDragResistanceFactor) ||
- !sp->overshootDragDistanceFactor;
- bool canOvershootX = !noOvershootX && (alwaysOvershootX || contentPosRange.width());
- bool canOvershootY = !noOvershootY && (alwaysOvershootY || contentPosRange.height());
-
- qreal oldOvershootX = (canOvershootX) ? oldPos.x() - oldClampedPos.x() : 0;
- qreal oldOvershootY = (canOvershootY) ? oldPos.y() - oldClampedPos.y() : 0;
-
- qreal newOvershootX = (canOvershootX) ? newPos.x() - newClampedPos.x() : 0;
- qreal newOvershootY = (canOvershootY) ? newPos.y() - newClampedPos.y() : 0;
-
- qreal maxOvershootX = viewportSize.width() * sp->overshootDragDistanceFactor;
- qreal maxOvershootY = viewportSize.height() * sp->overshootDragDistanceFactor;
-
- qScrollerDebug() << " --> noOs:" << noOvershootX << "drf:" << sp->overshootDragResistanceFactor << "mdf:" << sp->overshootScrollDistanceFactor << "ossP:"<<sp->hOvershootPolicy;
- qScrollerDebug() << " --> canOS:" << canOvershootX << "newOS:" << newOvershootX << "maxOS:" << maxOvershootX;
-
- if (sp->overshootDragResistanceFactor) {
- oldOvershootX *= sp->overshootDragResistanceFactor;
- oldOvershootY *= sp->overshootDragResistanceFactor;
- newOvershootX *= sp->overshootDragResistanceFactor;
- newOvershootY *= sp->overshootDragResistanceFactor;
- }
-
- // -- stop at the maximum overshoot distance
-
- newOvershootX = qBound(-maxOvershootX, newOvershootX, maxOvershootX);
- newOvershootY = qBound(-maxOvershootY, newOvershootY, maxOvershootY);
-
- overshootPosition.setX(newOvershootX);
- overshootPosition.setY(newOvershootY);
- contentPosition = newClampedPos;
-
- QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated);
- sendEvent(target, &se);
- firstScroll = false;
-
- qScrollerDebug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition <<
- "- overshoot x/y?:" << overshootPosition;
-}
-
-
-qreal QScrollerPrivate::nextSegmentPosition(QQueue<ScrollSegment> &segments, qint64 now, qreal oldPos)
-{
- qreal pos = oldPos;
-
- // check the X segments for new positions
- while (!segments.isEmpty()) {
- const ScrollSegment s = segments.head();
-
- if ((s.startTime + s.deltaTime * s.stopProgress) <= now) {
- segments.dequeue();
- pos = s.stopPos;
- } else if (s.startTime <= now) {
- qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime);
- pos = s.startPos + s.deltaPos * s.curve.valueForProgress(progress);
- if (s.deltaPos > 0 ? pos > s.stopPos : pos < s.stopPos) {
- segments.dequeue();
- pos = s.stopPos;
- } else {
- break;
- }
- } else {
- break;
- }
- }
- return pos;
-}
-
-void QScrollerPrivate::setContentPositionHelperScrolling()
-{
- qint64 now = monotonicTimer.elapsed();
- QPointF newPos = contentPosition + overshootPosition;
-
- newPos.setX(nextSegmentPosition(xSegments, now, newPos.x()));
- newPos.setY(nextSegmentPosition(ySegments, now, newPos.y()));
-
- // -- set the position and handle overshoot
- qScrollerDebug() << "QScroller::setContentPositionHelperScrolling()";
- qScrollerDebug() << " --> overshoot:" << overshootPosition << "- new pos:" << newPos;
-
- QPointF newClampedPos = clampToRect(newPos, contentPosRange);
-
- overshootPosition = newPos - newClampedPos;
- contentPosition = newClampedPos;
-
- QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated);
- sendEvent(target, &se);
- firstScroll = false;
-
- qScrollerDebug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition;
-}
-
-/*! \internal
- Returns the next snap point in direction.
- If \a direction >0 it will return the next snap point that is larger than the current position.
- If \a direction <0 it will return the next snap point that is smaller than the current position.
- If \a direction ==0 it will return the nearest snap point (or the current position if we are already
- on a snap point.
- Returns the nearest snap position or NaN if no such point could be found.
- */
-qreal QScrollerPrivate::nextSnapPos(qreal p, int dir, Qt::Orientation orientation)
-{
- qreal bestSnapPos = Q_QNAN;
- qreal bestSnapPosDist = Q_INFINITY;
-
- qreal minPos;
- qreal maxPos;
-
- if (orientation == Qt::Horizontal) {
- minPos = contentPosRange.left();
- maxPos = contentPosRange.right();
- } else {
- minPos = contentPosRange.top();
- maxPos = contentPosRange.bottom();
- }
-
- if (orientation == Qt::Horizontal) {
- // the snap points in the list
- foreach (qreal snapPos, snapPositionsX) {
- qreal snapPosDist = snapPos - p;
- if ((dir > 0 && snapPosDist < 0) ||
- (dir < 0 && snapPosDist > 0))
- continue; // wrong direction
- if (snapPos < minPos || snapPos > maxPos )
- continue; // invalid
-
- if (qIsNaN(bestSnapPos) ||
- qAbs(snapPosDist) < bestSnapPosDist ) {
- bestSnapPos = snapPos;
- bestSnapPosDist = qAbs(snapPosDist);
- }
- }
-
- // the snap point interval
- if (snapIntervalX > 0.0) {
- qreal first = minPos + snapFirstX;
- qreal snapPos;
- if (dir > 0)
- snapPos = qCeil((p - first) / snapIntervalX) * snapIntervalX + first;
- else if (dir < 0)
- snapPos = qFloor((p - first) / snapIntervalX) * snapIntervalX + first;
- else if (p <= first)
- snapPos = first;
- else
- {
- qreal last = qFloor((maxPos - first) / snapIntervalX) * snapIntervalX + first;
- if (p >= last)
- snapPos = last;
- else
- snapPos = qRound((p - first) / snapIntervalX) * snapIntervalX + first;
- }
-
- if (snapPos >= first && snapPos <= maxPos ) {
- qreal snapPosDist = snapPos - p;
-
- if (qIsNaN(bestSnapPos) ||
- qAbs(snapPosDist) < bestSnapPosDist ) {
- bestSnapPos = snapPos;
- bestSnapPosDist = qAbs(snapPosDist);
- }
- }
- }
-
- } else { // (orientation == Qt::Vertical)
- // the snap points in the list
- foreach (qreal snapPos, snapPositionsY) {
- qreal snapPosDist = snapPos - p;
- if ((dir > 0 && snapPosDist < 0) ||
- (dir < 0 && snapPosDist > 0))
- continue; // wrong direction
- if (snapPos < minPos || snapPos > maxPos )
- continue; // invalid
-
- if (qIsNaN(bestSnapPos) ||
- qAbs(snapPosDist) < bestSnapPosDist) {
- bestSnapPos = snapPos;
- bestSnapPosDist = qAbs(snapPosDist);
- }
- }
-
- // the snap point interval
- if (snapIntervalY > 0.0) {
- qreal first = minPos + snapFirstY;
- qreal snapPos;
- if (dir > 0)
- snapPos = qCeil((p - first) / snapIntervalY) * snapIntervalY + first;
- else if (dir < 0)
- snapPos = qFloor((p - first) / snapIntervalY) * snapIntervalY + first;
- else if (p <= first)
- snapPos = first;
- else
- {
- qreal last = qFloor((maxPos - first) / snapIntervalY) * snapIntervalY + first;
- if (p >= last)
- snapPos = last;
- else
- snapPos = qRound((p - first) / snapIntervalY) * snapIntervalY + first;
- }
-
- if (snapPos >= first && snapPos <= maxPos ) {
- qreal snapPosDist = snapPos - p;
-
- if (qIsNaN(bestSnapPos) ||
- qAbs(snapPosDist) < bestSnapPosDist) {
- bestSnapPos = snapPos;
- bestSnapPosDist = qAbs(snapPosDist);
- }
- }
- }
- }
-
- return bestSnapPos;
-}
-
-/*!
- \enum QScroller::State
-
- This enum contains the different QScroller states.
-
- \value Inactive The scroller is not scrolling and nothing is pressed.
- \value Pressed A touch event was received or the mouse button was pressed but the scroll area is currently not dragged.
- \value Dragging The scroll area is currently following the touch point or mouse.
- \value Scrolling The scroll area is moving on it's own.
-*/
-
-/*!
- \enum QScroller::ScrollerGestureType
-
- This enum contains the different gesture types that are supported by the QScroller gesture recognizer.
-
- \value TouchGesture The gesture recognizer will only trigger on touch
- events. Specifically it will react on single touch points when using a
- touch screen and dual touch points when using a touchpad.
- \value LeftMouseButtonGesture The gesture recognizer will only trigger on left mouse button events.
- \value MiddleMouseButtonGesture The gesture recognizer will only trigger on middle mouse button events.
- \value RightMouseButtonGesture The gesture recognizer will only trigger on right mouse button events.
-*/
-
-/*!
- \enum QScroller::Input
-
- This enum contains an input device agnostic view of input events that are relevant for QScroller.
-
- \value InputPress The user pressed the input device (e.g. QEvent::MouseButtonPress,
- QEvent::GraphicsSceneMousePress, QEvent::TouchBegin)
-
- \value InputMove The user moved the input device (e.g. QEvent::MouseMove,
- QEvent::GraphicsSceneMouseMove, QEvent::TouchUpdate)
-
- \value InputRelease The user released the input device (e.g. QEvent::MouseButtonRelease,
- QEvent::GraphicsSceneMouseRelease, QEvent::TouchEnd)
-
-*/
-
-QT_END_NAMESPACE
diff --git a/src/gui/util/qscroller.h b/src/gui/util/qscroller.h
deleted file mode 100644
index 1599c7d..0000000
--- a/src/gui/util/qscroller.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
-** this package.
-**
-** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCROLLER_H
-#define QSCROLLER_H
-
-#include <QtCore/QObject>
-#include <QtCore/QPointF>
-#include <QtGui/QScrollerProperties>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QWidget;
-class QScrollerPrivate;
-class QScrollerProperties;
-#ifndef QT_NO_GESTURES
-class QFlickGestureRecognizer;
-class QMouseFlickGestureRecognizer;
-#endif
-
-class Q_GUI_EXPORT QScroller : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(State state READ state NOTIFY stateChanged)
- Q_PROPERTY(QScrollerProperties scrollerProperties READ scrollerProperties WRITE setScrollerProperties NOTIFY scrollerPropertiesChanged)
- Q_ENUMS(State)
-
-public:
- enum State
- {
- Inactive,
- Pressed,
- Dragging,
- Scrolling
- };
-
- enum ScrollerGestureType
- {
- TouchGesture,
- LeftMouseButtonGesture,
- RightMouseButtonGesture,
- MiddleMouseButtonGesture
- };
-
- enum Input
- {
- InputPress = 1,
- InputMove,
- InputRelease
- };
-
- static bool hasScroller(QObject *target);
-
- static QScroller *scroller(QObject *target);
- static const QScroller *scroller(const QObject *target);
-
-#ifndef QT_NO_GESTURES
- static Qt::GestureType grabGesture(QObject *target, ScrollerGestureType gestureType = TouchGesture);
- static Qt::GestureType grabbedGesture(QObject *target);
- static void ungrabGesture(QObject *target);
-#endif
-
- static QList<QScroller *> activeScrollers();
-
- QObject *target() const;
-
- State state() const;
-
- bool handleInput(Input input, const QPointF &position, qint64 timestamp = 0);
-
- void stop();
- QPointF velocity() const;
- QPointF finalPosition() const;
- QPointF pixelPerMeter() const;
-
- QScrollerProperties scrollerProperties() const;
-
- void setSnapPositionsX( const QList<qreal> &positions );
- void setSnapPositionsX( qreal first, qreal interval );
- void setSnapPositionsY( const QList<qreal> &positions );
- void setSnapPositionsY( qreal first, qreal interval );
-
-public Q_SLOTS:
- void setScrollerProperties(const QScrollerProperties &prop);
- void scrollTo(const QPointF &pos);
- void scrollTo(const QPointF &pos, int scrollTime);
- void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin);
- void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime);
- void resendPrepareEvent();
-
-Q_SIGNALS:
- void stateChanged(QScroller::State newstate);
- void scrollerPropertiesChanged(const QScrollerProperties &);
-
-private:
- QScrollerPrivate *d_ptr;
-
- QScroller(QObject *target);
- virtual ~QScroller();
-
- Q_DISABLE_COPY(QScroller)
- Q_DECLARE_PRIVATE(QScroller)
-
-#ifndef QT_NO_GESTURES
- friend class QFlickGestureRecognizer;
-#endif
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCROLLER_H
diff --git a/src/gui/util/qscroller_p.h b/src/gui/util/qscroller_p.h
deleted file mode 100644
index c119615..0000000
--- a/src/gui/util/qscroller_p.h
+++ /dev/null
@@ -1,209 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
-** this package.
-**
-** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCROLLER_P_H
-#define QSCROLLER_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 <QObject>
-#include <QPointer>
-#include <QQueue>
-#include <QSet>
-#include <QEasingCurve>
-#include <QElapsedTimer>
-#include <QSizeF>
-#include <QPointF>
-#include <QRectF>
-#include <qscroller.h>
-#include <qscrollerproperties.h>
-#include <private/qscrollerproperties_p.h>
-#include <QAbstractAnimation>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_GESTURES
-class QFlickGestureRecognizer;
-#endif
-
-#ifndef QT_NO_ANIMATION
-class QScrollTimer;
-#endif
-class QScrollerPrivate : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PUBLIC(QScroller)
-
-public:
- QScrollerPrivate(QScroller *q, QObject *target);
- void init();
-
- void sendEvent(QObject *o, QEvent *e);
-
- void setState(QScroller::State s);
-
- enum ScrollType {
- ScrollTypeFlick = 0,
- ScrollTypeScrollTo,
- ScrollTypeOvershoot
- };
-
- struct ScrollSegment {
- qint64 startTime;
- qint64 deltaTime;
- qreal startPos;
- qreal deltaPos;
- QEasingCurve curve;
- qreal stopProgress; // whatever is..
- qreal stopPos; // ..reached first
- ScrollType type;
- };
-
- bool pressWhileInactive(const QPointF &position, qint64 timestamp);
- bool moveWhilePressed(const QPointF &position, qint64 timestamp);
- bool releaseWhilePressed(const QPointF &position, qint64 timestamp);
- bool moveWhileDragging(const QPointF &position, qint64 timestamp);
- bool releaseWhileDragging(const QPointF &position, qint64 timestamp);
- bool pressWhileScrolling(const QPointF &position, qint64 timestamp);
-
- void timerTick();
- void timerEventWhileDragging();
- void timerEventWhileScrolling();
-
- bool prepareScrolling(const QPointF &position);
- void handleDrag(const QPointF &position, qint64 timestamp);
-
- QPointF realDpi(int screen);
- QPointF dpi() const;
- void setDpi(const QPointF &dpi);
- void setDpiFromWidget(QWidget *widget);
-
- void updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime);
- void pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation);
- void recalcScrollingSegments(bool forceRecalc = false);
- qreal scrollingSegmentsEndPos(Qt::Orientation orientation) const;
- bool scrollingSegmentsValid(Qt::Orientation orientation);
- void createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type);
- void createScrollingSegments(qreal v, qreal startPos, qreal ppm, Qt::Orientation orientation);
-
- void setContentPositionHelperDragging(const QPointF &deltaPos);
- void setContentPositionHelperScrolling();
-
- qreal nextSnapPos(qreal p, int dir, Qt::Orientation orientation);
- static qreal nextSegmentPosition(QQueue<ScrollSegment> &segments, qint64 now, qreal oldPos);
-
- inline int frameRateSkip() const { return properties.d.data()->frameRate; }
-
- static const char *stateName(QScroller::State state);
- static const char *inputName(QScroller::Input input);
-
-public slots:
- void targetDestroyed();
-
-public:
- // non static
- QObject *target;
- QScrollerProperties properties;
-#ifndef QT_NO_GESTURES
- QFlickGestureRecognizer *recognizer;
- Qt::GestureType recognizerType;
-#endif
-
- // scroller state:
-
- // QPointer<QObject> scrollTarget;
- QSizeF viewportSize;
- QRectF contentPosRange;
- QPointF contentPosition;
- QPointF overshootPosition; // the number of pixels we are overshooting (before overshootDragResistanceFactor)
-
- // state
-
- bool enabled;
- QScroller::State state;
- bool firstScroll; // true if we haven't already send a scroll event
-
- QPointF oldVelocity; // the release velocity of the last drag
-
- QPointF pressPosition;
- QPointF lastPosition;
- qint64 pressTimestamp;
- qint64 lastTimestamp;
-
- QPointF dragDistance; // the distance we should move during the next drag timer event
-
- QQueue<ScrollSegment> xSegments;
- QQueue<ScrollSegment> ySegments;
-
- // snap positions
- QList<qreal> snapPositionsX;
- qreal snapFirstX;
- qreal snapIntervalX;
- QList<qreal> snapPositionsY;
- qreal snapFirstY;
- qreal snapIntervalY;
-
- QPointF pixelPerMeter;
-
- QElapsedTimer monotonicTimer;
-
- QPointF releaseVelocity; // the starting velocity of the scrolling state
-#ifndef QT_NO_ANIMATION
- QScrollTimer *scrollTimer;
-#endif
-
- QScroller *q_ptr;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QSCROLLER_P_H
-
diff --git a/src/gui/util/qscrollerproperties.cpp b/src/gui/util/qscrollerproperties.cpp
deleted file mode 100644
index 85e2e82..0000000
--- a/src/gui/util/qscrollerproperties.cpp
+++ /dev/null
@@ -1,393 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
-** this package.
-**
-** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QPointer>
-#include <QObject>
-#include <QtCore/qmath.h>
-#ifdef Q_WS_WIN
-# include <QLibrary>
-#endif
-
-#include "qscrollerproperties.h"
-#include "private/qscrollerproperties_p.h"
-
-QT_BEGIN_NAMESPACE
-
-static QScrollerPropertiesPrivate *userDefaults = 0;
-static QScrollerPropertiesPrivate *systemDefaults = 0;
-
-QScrollerPropertiesPrivate *QScrollerPropertiesPrivate::defaults()
-{
- if (!systemDefaults) {
- QScrollerPropertiesPrivate spp;
- spp.mousePressEventDelay = qreal(0.25);
- spp.dragStartDistance = qreal(5.0 / 1000);
- spp.dragVelocitySmoothingFactor = qreal(0.8);
- spp.axisLockThreshold = qreal(0);
- spp.scrollingCurve.setType(QEasingCurve::OutQuad);
- spp.decelerationFactor = qreal(0.125);
- spp.minimumVelocity = qreal(50.0 / 1000);
- spp.maximumVelocity = qreal(500.0 / 1000);
- spp.maximumClickThroughVelocity = qreal(66.5 / 1000);
- spp.acceleratingFlickMaximumTime = qreal(1.25);
- spp.acceleratingFlickSpeedupFactor = qreal(3.0);
- spp.snapPositionRatio = qreal(0.5);
- spp.snapTime = qreal(0.3);
- spp.overshootDragResistanceFactor = qreal(0.5);
- spp.overshootDragDistanceFactor = qreal(1);
- spp.overshootScrollDistanceFactor = qreal(0.5);
- spp.overshootScrollTime = qreal(0.7);
-# ifdef Q_WS_WIN
- if (QLibrary::resolve(QLatin1String("UxTheme"), "BeginPanningFeedback"))
- spp.overshootScrollTime = qreal(0.35);
-# endif
- spp.hOvershootPolicy = QScrollerProperties::OvershootWhenScrollable;
- spp.vOvershootPolicy = QScrollerProperties::OvershootWhenScrollable;
- spp.frameRate = QScrollerProperties::Standard;
-
- systemDefaults = new QScrollerPropertiesPrivate(spp);
- }
- return new QScrollerPropertiesPrivate(userDefaults ? *userDefaults : *systemDefaults);
-}
-
-/*!
- \class QScrollerProperties
- \brief The QScrollerProperties class stores the settings for a QScroller.
- \since 4.8
-
- The QScrollerProperties class stores the parameters used by QScroller.
-
- The default settings are platform dependent so that Qt emulates the
- platform behaviour for kinetic scrolling.
-
- As a convention the QScrollerProperties are in physical units (meter,
- seconds) and are converted by QScroller using the current DPI.
-
- \sa QScroller
-*/
-
-/*!
- Constructs new scroller properties.
-*/
-QScrollerProperties::QScrollerProperties()
- : d(QScrollerPropertiesPrivate::defaults())
-{
-}
-
-/*!
- Constructs a copy of \a sp.
-*/
-QScrollerProperties::QScrollerProperties(const QScrollerProperties &sp)
- : d(new QScrollerPropertiesPrivate(*sp.d))
-{
-}
-
-/*!
- Assigns \a sp to these scroller properties and returns a reference to these scroller properties.
-*/
-QScrollerProperties &QScrollerProperties::operator=(const QScrollerProperties &sp)
-{
- *d.data() = *sp.d.data();
- return *this;
-}
-
-/*!
- Destroys the scroller properties.
-*/
-QScrollerProperties::~QScrollerProperties()
-{
-}
-
-/*!
- Returns true if these scroller properties are equal to \a sp; otherwise returns false.
-*/
-bool QScrollerProperties::operator==(const QScrollerProperties &sp) const
-{
- return *d.data() == *sp.d.data();
-}
-
-/*!
- Returns true if these scroller properties are different from \a sp; otherwise returns false.
-*/
-bool QScrollerProperties::operator!=(const QScrollerProperties &sp) const
-{
- return !(*d.data() == *sp.d.data());
-}
-
-bool QScrollerPropertiesPrivate::operator==(const QScrollerPropertiesPrivate &p) const
-{
- bool same = true;
- same &= (mousePressEventDelay == p.mousePressEventDelay);
- same &= (dragStartDistance == p.dragStartDistance);
- same &= (dragVelocitySmoothingFactor == p.dragVelocitySmoothingFactor);
- same &= (axisLockThreshold == p.axisLockThreshold);
- same &= (scrollingCurve == p.scrollingCurve);
- same &= (decelerationFactor == p.decelerationFactor);
- same &= (minimumVelocity == p.minimumVelocity);
- same &= (maximumVelocity == p.maximumVelocity);
- same &= (maximumClickThroughVelocity == p.maximumClickThroughVelocity);
- same &= (acceleratingFlickMaximumTime == p.acceleratingFlickMaximumTime);
- same &= (acceleratingFlickSpeedupFactor == p.acceleratingFlickSpeedupFactor);
- same &= (snapPositionRatio == p.snapPositionRatio);
- same &= (snapTime == p.snapTime);
- same &= (overshootDragResistanceFactor == p.overshootDragResistanceFactor);
- same &= (overshootDragDistanceFactor == p.overshootDragDistanceFactor);
- same &= (overshootScrollDistanceFactor == p.overshootScrollDistanceFactor);
- same &= (overshootScrollTime == p.overshootScrollTime);
- same &= (hOvershootPolicy == p.hOvershootPolicy);
- same &= (vOvershootPolicy == p.vOvershootPolicy);
- same &= (frameRate == p.frameRate);
- return same;
-}
-
-/*!
- Sets the scroller properties for all new QScrollerProperties objects to \a sp.
-
- Use this function to override the platform default properties returned by the default
- constructor. If you only want to change the scroller properties of a single scroller, use
- QScroller::setScrollerProperties()
-
- \note Calling this function will not change the content of already existing
- QScrollerProperties objects.
-
- \sa unsetDefaultScrollerProperties()
-*/
-void QScrollerProperties::setDefaultScrollerProperties(const QScrollerProperties &sp)
-{
- if (!userDefaults)
- userDefaults = new QScrollerPropertiesPrivate(*sp.d);
- else
- *userDefaults = *sp.d;
-}
-
-/*!
- Sets the scroller properties returned by the default constructor back to the platform default
- properties.
-
- \sa setDefaultScrollerProperties()
-*/
-void QScrollerProperties::unsetDefaultScrollerProperties()
-{
- delete userDefaults;
- userDefaults = 0;
-}
-
-/*!
- Query the \a metric value of the scroller properties.
-
- \sa setScrollMetric(), ScrollMetric
-*/
-QVariant QScrollerProperties::scrollMetric(ScrollMetric metric) const
-{
- switch (metric) {
- case MousePressEventDelay: return d->mousePressEventDelay;
- case DragStartDistance: return d->dragStartDistance;
- case DragVelocitySmoothingFactor: return d->dragVelocitySmoothingFactor;
- case AxisLockThreshold: return d->axisLockThreshold;
- case ScrollingCurve: return d->scrollingCurve;
- case DecelerationFactor: return d->decelerationFactor;
- case MinimumVelocity: return d->minimumVelocity;
- case MaximumVelocity: return d->maximumVelocity;
- case MaximumClickThroughVelocity: return d->maximumClickThroughVelocity;
- case AcceleratingFlickMaximumTime: return d->acceleratingFlickMaximumTime;
- case AcceleratingFlickSpeedupFactor:return d->acceleratingFlickSpeedupFactor;
- case SnapPositionRatio: return d->snapPositionRatio;
- case SnapTime: return d->snapTime;
- case OvershootDragResistanceFactor: return d->overshootDragResistanceFactor;
- case OvershootDragDistanceFactor: return d->overshootDragDistanceFactor;
- case OvershootScrollDistanceFactor: return d->overshootScrollDistanceFactor;
- case OvershootScrollTime: return d->overshootScrollTime;
- case HorizontalOvershootPolicy: return QVariant::fromValue(d->hOvershootPolicy);
- case VerticalOvershootPolicy: return QVariant::fromValue(d->vOvershootPolicy);
- case FrameRate: return QVariant::fromValue(d->frameRate);
- case ScrollMetricCount: break;
- }
- return QVariant();
-}
-
-/*!
- Set a specific value of the \a metric ScrollerMetric to \a value.
-
- \sa scrollMetric(), ScrollMetric
-*/
-void QScrollerProperties::setScrollMetric(ScrollMetric metric, const QVariant &value)
-{
- switch (metric) {
- case MousePressEventDelay: d->mousePressEventDelay = value.toReal(); break;
- case DragStartDistance: d->dragStartDistance = value.toReal(); break;
- case DragVelocitySmoothingFactor: d->dragVelocitySmoothingFactor = qBound(qreal(0), value.toReal(), qreal(1)); break;
- case AxisLockThreshold: d->axisLockThreshold = qBound(qreal(0), value.toReal(), qreal(1)); break;
- case ScrollingCurve: d->scrollingCurve = value.toEasingCurve(); break;
- case DecelerationFactor: d->decelerationFactor = value.toReal(); break;
- case MinimumVelocity: d->minimumVelocity = value.toReal(); break;
- case MaximumVelocity: d->maximumVelocity = value.toReal(); break;
- case MaximumClickThroughVelocity: d->maximumClickThroughVelocity = value.toReal(); break;
- case AcceleratingFlickMaximumTime: d->acceleratingFlickMaximumTime = value.toReal(); break;
- case AcceleratingFlickSpeedupFactor:d->acceleratingFlickSpeedupFactor = value.toReal(); break;
- case SnapPositionRatio: d->snapPositionRatio = qBound(qreal(0), value.toReal(), qreal(1)); break;
- case SnapTime: d->snapTime = value.toReal(); break;
- case OvershootDragResistanceFactor: d->overshootDragResistanceFactor = value.toReal(); break;
- case OvershootDragDistanceFactor: d->overshootDragDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break;
- case OvershootScrollDistanceFactor: d->overshootScrollDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break;
- case OvershootScrollTime: d->overshootScrollTime = value.toReal(); break;
- case HorizontalOvershootPolicy: d->hOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break;
- case VerticalOvershootPolicy: d->vOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break;
- case FrameRate: d->frameRate = value.value<QScrollerProperties::FrameRates>(); break;
- case ScrollMetricCount: break;
- }
-}
-
-/*!
- \enum QScrollerProperties::FrameRates
-
- This enum describes the available frame rates used while dragging or scrolling.
-
- \value Fps60 60 frames per second
- \value Fps30 30 frames per second
- \value Fps20 20 frames per second
- \value Standard the default value is 60 frames per second (which corresponds to QAbstractAnimation).
-*/
-
-/*!
- \enum QScrollerProperties::OvershootPolicy
-
- This enum describes the various modes of overshooting.
-
- \value OvershootWhenScrollable Overshooting is possible when the content is scrollable. This is the
- default.
-
- \value OvershootAlwaysOff Overshooting is never enabled, even when the content is scrollable.
-
- \value OvershootAlwaysOn Overshooting is always enabled, even when the content is not
- scrollable.
-*/
-
-/*!
- \enum QScrollerProperties::ScrollMetric
-
- This enum contains the different scroll metric types. When not indicated otherwise the
- setScrollMetric function expects a QVariant of type qreal.
-
- See the QScroller documentation for further details of the concepts behind the different
- values.
-
- \value MousePressEventDelay This is the time a mouse press event is delayed when starting
- a flick gesture in \c{[s]}. If the gesture is triggered within that time, no mouse press or
- release is sent to the scrolled object. If it triggers after that delay the delayed
- mouse press plus a faked release event at global postion \c{QPoint(-QWIDGETSIZE_MAX,
- -QWIDGETSIZE_MAX)} is sent. If the gesture is canceled, then both the delayed mouse
- press plus the real release event are delivered.
-
- \value DragStartDistance This is the minimum distance the touch or mouse point needs to be
- moved before the flick gesture is triggered in \c m.
-
- \value DragVelocitySmoothingFactor A value that describes to which extent new drag velocities are
- included in the final scrolling velocity. This value should be in the range between \c 0 and
- \c 1. The lower the value, the more smoothing is applied to the dragging velocity.
-
- \value AxisLockThreshold Restricts the movement to one axis if the movement is inside an angle
- around the axis. The threshold must be in the range \c 0 to \c 1.
-
- \value ScrollingCurve The QEasingCurve used when decelerating the scrolling velocity after an
- user initiated flick. Please note that this is the easing curve for the positions, \bold{not}
- the velocity: the default is QEasingCurve::OutQuad, which results in a linear decrease in
- velocity (1st derivative) and a constant deceleration (2nd derivative).
-
- \value DecelerationFactor This factor influences how long it takes the scroller to decelerate
- to 0 velocity. The actual value depends on the chosen ScrollingCurve. For most
- types the value should be in the range from \c 0.1 to \c 2.0
-
- \value MinimumVelocity The minimum velocity that is needed after ending the touch or releasing
- the mouse to start scrolling in \c{m/s}.
-
- \value MaximumVelocity This is the maximum velocity that can be reached in \c{m/s}.
-
- \value MaximumClickThroughVelocity This is the maximum allowed scroll speed for a click-through
- in \c{m/s}. This means that a click on a currently (slowly) scrolling object will not only stop
- the scrolling but the click event will also be delivered to the UI control. This is
- useful when using exponential-type scrolling curves.
-
- \value AcceleratingFlickMaximumTime This is the maximum time in \c seconds that a flick gesture
- can take to be recognized as an accelerating flick. If set to zero no such gesture is
- detected. An "accelerating flick" is a flick gesture executed on an already scrolling object.
- In such cases the scrolling speed is multiplied by AcceleratingFlickSpeedupFactor in order to
- accelerate it.
-
- \value AcceleratingFlickSpeedupFactor The current speed is multiplied by this number if an
- accelerating flick is detected. Should be \c{>= 1}.
-
- \value SnapPositionRatio This is the distance that the user must drag the area beween two snap
- points in order to snap it to the next position. \c{0.33} means that the scroll must only
- reach one third of the distance between two snap points to snap to the next one. The ratio must
- be between \c 0 and \c 1.
-
- \value SnapTime This is the time factor for the scrolling curve. A lower value means that the
- scrolling will take longer. The scrolling distance is independet of this value.
-
- \value OvershootDragResistanceFactor This value is the factor between the mouse dragging and
- the actual scroll area movement (during overshoot). The factor must be between \c 0 and \c 1.
-
- \value OvershootDragDistanceFactor This is the maximum distance for overshoot movements while
- dragging. The actual overshoot distance is calculated by multiplying this value with the
- viewport size of the scrolled object. The factor must be between \c 0 and \c 1.
-
- \value OvershootScrollDistanceFactor This is the maximum distance for overshoot movements while
- scrolling. The actual overshoot distance is calculated by multiplying this value with the
- viewport size of the scrolled object. The factor must be between \c 0 and \c 1.
-
- \value OvershootScrollTime This is the time in \c seconds that is used to play the
- complete overshoot animation.
-
- \value HorizontalOvershootPolicy This is the horizontal overshooting policy (see OvershootPolicy).
-
- \value VerticalOvershootPolicy This is the horizontal overshooting policy (see OvershootPolicy).
-
- \value FrameRate This is the frame rate which should be used while dragging or scrolling.
- QScroller uses a QAbstractAnimation timer internally to sync all scrolling operations to other
- animations that might be active at the same time. If the standard value of 60 frames per
- second is too fast, it can be lowered with this setting,
- while still being in-sync with QAbstractAnimation. Please note that only the values of the
- FrameRates enum are allowed here.
-
- \value ScrollMetricCount This is always the last entry.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/gui/util/qscrollerproperties.h b/src/gui/util/qscrollerproperties.h
deleted file mode 100644
index 75d8932..0000000
--- a/src/gui/util/qscrollerproperties.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
-** this package.
-**
-** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCROLLERPROPERTIES_H
-#define QSCROLLERPROPERTIES_H
-
-#include <QtCore/QScopedPointer>
-#include <QtCore/QMetaType>
-#include <QtCore/QVariant>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QScroller;
-class QScrollerPrivate;
-class QScrollerPropertiesPrivate;
-
-class Q_GUI_EXPORT QScrollerProperties
-{
-public:
- QScrollerProperties();
- QScrollerProperties(const QScrollerProperties &sp);
- QScrollerProperties &operator=(const QScrollerProperties &sp);
- virtual ~QScrollerProperties();
-
- bool operator==(const QScrollerProperties &sp) const;
- bool operator!=(const QScrollerProperties &sp) const;
-
- static void setDefaultScrollerProperties(const QScrollerProperties &sp);
- static void unsetDefaultScrollerProperties();
-
- enum OvershootPolicy
- {
- OvershootWhenScrollable,
- OvershootAlwaysOff,
- OvershootAlwaysOn
- };
-
- enum FrameRates {
- Standard,
- Fps60,
- Fps30,
- Fps20
- };
-
- enum ScrollMetric
- {
- MousePressEventDelay, // qreal [s]
- DragStartDistance, // qreal [m]
- DragVelocitySmoothingFactor, // qreal [0..1/s] (complex calculation involving time) v = v_new* DASF + v_old * (1-DASF)
- AxisLockThreshold, // qreal [0..1] atan(|min(dx,dy)|/|max(dx,dy)|)
-
- ScrollingCurve, // QEasingCurve
- DecelerationFactor, // slope of the curve
-
- MinimumVelocity, // qreal [m/s]
- MaximumVelocity, // qreal [m/s]
- MaximumClickThroughVelocity, // qreal [m/s]
-
- AcceleratingFlickMaximumTime, // qreal [s]
- AcceleratingFlickSpeedupFactor, // qreal [1..]
-
- SnapPositionRatio, // qreal [0..1]
- SnapTime, // qreal [s]
-
- OvershootDragResistanceFactor, // qreal [0..1]
- OvershootDragDistanceFactor, // qreal [0..1]
- OvershootScrollDistanceFactor, // qreal [0..1]
- OvershootScrollTime, // qreal [s]
-
- HorizontalOvershootPolicy, // enum OvershootPolicy
- VerticalOvershootPolicy, // enum OvershootPolicy
- FrameRate, // enum FrameRates
-
- ScrollMetricCount
- };
-
- QVariant scrollMetric(ScrollMetric metric) const;
- void setScrollMetric(ScrollMetric metric, const QVariant &value);
-
-protected:
- QScopedPointer<QScrollerPropertiesPrivate> d;
-
-private:
- QScrollerProperties(QScrollerPropertiesPrivate &dd);
-
- friend class QScrollerPropertiesPrivate;
- friend class QScroller;
- friend class QScrollerPrivate;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QScrollerProperties::OvershootPolicy)
-Q_DECLARE_METATYPE(QScrollerProperties::FrameRates)
-
-QT_END_HEADER
-
-#endif // QSCROLLERPROPERTIES_H
diff --git a/src/gui/util/qundogroup.cpp b/src/gui/util/qundogroup.cpp
index 42cda74..a24ce8d 100644
--- a/src/gui/util/qundogroup.cpp
+++ b/src/gui/util/qundogroup.cpp
@@ -375,15 +375,18 @@ bool QUndoGroup::isClean() const
for undo, if the group is empty or if none of the stacks are active, this action will
be disabled.
- If \a prefix is empty, the default prefix "Undo" is used.
+ If \a prefix is empty, the default template "Undo %1" is used instead of prefix.
+ Before Qt 4.8, the prefix "Undo" was used by default.
\sa createRedoAction() canUndo() QUndoCommand::text()
*/
QAction *QUndoGroup::createUndoAction(QObject *parent, const QString &prefix) const
{
- QString pref = prefix.isEmpty() ? tr("Undo") : prefix;
- QUndoAction *result = new QUndoAction(pref, parent);
+ QUndoAction *result = new QUndoAction(prefix, parent);
+ if (prefix.isEmpty())
+ result->setTextFormat(tr("Undo %1"), tr("Undo", "Default text for undo action"));
+
result->setEnabled(canUndo());
result->setPrefixedText(undoText());
connect(this, SIGNAL(canUndoChanged(bool)),
@@ -403,15 +406,18 @@ QAction *QUndoGroup::createUndoAction(QObject *parent, const QString &prefix) co
for redo, if the group is empty or if none of the stacks are active, this action will
be disabled.
- If \a prefix is empty, the default prefix "Undo" is used.
+ If \a prefix is empty, the default template "Redo %1" is used instead of prefix.
+ Before Qt 4.8, the prefix "Redo" was used by default.
\sa createUndoAction() canRedo() QUndoCommand::text()
*/
QAction *QUndoGroup::createRedoAction(QObject *parent, const QString &prefix) const
{
- QString pref = prefix.isEmpty() ? tr("Redo") : prefix;
- QUndoAction *result = new QUndoAction(pref, parent);
+ QUndoAction *result = new QUndoAction(prefix, parent);
+ if (prefix.isEmpty())
+ result->setTextFormat(tr("Redo %1"), tr("Redo", "Default text for redo action"));
+
result->setEnabled(canRedo());
result->setPrefixedText(redoText());
connect(this, SIGNAL(canRedoChanged(bool)),
diff --git a/src/gui/util/qundostack.cpp b/src/gui/util/qundostack.cpp
index 6b038ee..1dfab5d 100644
--- a/src/gui/util/qundostack.cpp
+++ b/src/gui/util/qundostack.cpp
@@ -114,7 +114,7 @@ QUndoCommand::QUndoCommand(const QString &text, QUndoCommand *parent)
d = new QUndoCommandPrivate;
if (parent != 0)
parent->d->child_list.append(this);
- d->text = text;
+ setText(text);
}
/*!
@@ -230,10 +230,9 @@ void QUndoCommand::undo()
Returns a short text string describing what this command does; for example,
"insert text".
- The text is used when the text properties of the stack's undo and redo
- actions are updated.
+ The text is used for names of items in QUndoView.
- \sa setText(), QUndoStack::createUndoAction(), QUndoStack::createRedoAction()
+ \sa actionText(), setText(), QUndoStack::createUndoAction(), QUndoStack::createRedoAction()
*/
QString QUndoCommand::text() const
@@ -242,17 +241,47 @@ QString QUndoCommand::text() const
}
/*!
+ \since 4.8
+
+ Returns a short text string describing what this command does; for example,
+ "insert text".
+
+ The text is used when the text properties of the stack's undo and redo
+ actions are updated.
+
+ \sa text(), setText(), QUndoStack::createUndoAction(), QUndoStack::createRedoAction()
+*/
+
+QString QUndoCommand::actionText() const
+{
+ return d->actionText;
+}
+
+/*!
Sets the command's text to be the \a text specified.
The specified text should be a short user-readable string describing what this
command does.
- \sa text() QUndoStack::createUndoAction() QUndoStack::createRedoAction()
+ If you need to have two different strings for text() and actionText(), separate
+ them with "\n" and pass into this function. Even if you do not use this feature
+ for English strings during development, you can still let translators use two
+ different strings in order to match specific languages' needs.
+ The described feature and the function actionText() are available since Qt 4.8.
+
+ \sa text() actionText() QUndoStack::createUndoAction() QUndoStack::createRedoAction()
*/
void QUndoCommand::setText(const QString &text)
{
- d->text = text;
+ int cdpos = text.indexOf(QLatin1Char('\n'));
+ if (cdpos > 0) {
+ d->text = text.left(cdpos);
+ d->actionText = text.mid(cdpos + 1);
+ } else {
+ d->text = text;
+ d->actionText = text;
+ }
}
/*!
@@ -374,11 +403,24 @@ QUndoAction::QUndoAction(const QString &prefix, QObject *parent)
void QUndoAction::setPrefixedText(const QString &text)
{
- QString s = m_prefix;
- if (!m_prefix.isEmpty() && !text.isEmpty())
- s.append(QLatin1Char(' '));
- s.append(text);
- setText(s);
+ if (m_defaultText.isEmpty()) {
+ QString s = m_prefix;
+ if (!m_prefix.isEmpty() && !text.isEmpty())
+ s.append(QLatin1Char(' '));
+ s.append(text);
+ setText(s);
+ } else {
+ if (text.isEmpty())
+ setText(m_defaultText);
+ else
+ setText(m_prefix.arg(text));
+ }
+}
+
+void QUndoAction::setTextFormat(const QString &textFormat, const QString &defaultText)
+{
+ m_prefix = textFormat;
+ m_defaultText = defaultText;
}
#endif // QT_NO_ACTION
@@ -783,7 +825,7 @@ bool QUndoStack::canRedo() const
/*!
Returns the text of the command which will be undone in the next call to undo().
- \sa QUndoCommand::text() redoText()
+ \sa QUndoCommand::actionText() redoText()
*/
QString QUndoStack::undoText() const
@@ -792,14 +834,14 @@ QString QUndoStack::undoText() const
if (!d->macro_stack.isEmpty())
return QString();
if (d->index > 0)
- return d->command_list.at(d->index - 1)->text();
+ return d->command_list.at(d->index - 1)->actionText();
return QString();
}
/*!
Returns the text of the command which will be redone in the next call to redo().
- \sa QUndoCommand::text() undoText()
+ \sa QUndoCommand::actionText() undoText()
*/
QString QUndoStack::redoText() const
@@ -808,7 +850,7 @@ QString QUndoStack::redoText() const
if (!d->macro_stack.isEmpty())
return QString();
if (d->index < d->command_list.size())
- return d->command_list.at(d->index)->text();
+ return d->command_list.at(d->index)->actionText();
return QString();
}
@@ -822,15 +864,18 @@ QString QUndoStack::redoText() const
prefixed by the specified \a prefix. If there is no command available for undo,
this action will be disabled.
- If \a prefix is empty, the default prefix "Undo" is used.
+ If \a prefix is empty, the default template "Undo %1" is used instead of prefix.
+ Before Qt 4.8, the prefix "Undo" was used by default.
\sa createRedoAction(), canUndo(), QUndoCommand::text()
*/
QAction *QUndoStack::createUndoAction(QObject *parent, const QString &prefix) const
{
- QString pref = prefix.isEmpty() ? tr("Undo") : prefix;
- QUndoAction *result = new QUndoAction(pref, parent);
+ QUndoAction *result = new QUndoAction(prefix, parent);
+ if (prefix.isEmpty())
+ result->setTextFormat(tr("Undo %1"), tr("Undo", "Default text for undo action"));
+
result->setEnabled(canUndo());
result->setPrefixedText(undoText());
connect(this, SIGNAL(canUndoChanged(bool)),
@@ -849,15 +894,18 @@ QAction *QUndoStack::createUndoAction(QObject *parent, const QString &prefix) co
prefixed by the specified \a prefix. If there is no command available for redo,
this action will be disabled.
- If \a prefix is empty, the default prefix "Redo" is used.
+ If \a prefix is empty, the default template "Redo %1" is used instead of prefix.
+ Before Qt 4.8, the prefix "Redo" was used by default.
\sa createUndoAction(), canRedo(), QUndoCommand::text()
*/
QAction *QUndoStack::createRedoAction(QObject *parent, const QString &prefix) const
{
- QString pref = prefix.isEmpty() ? tr("Redo") : prefix;
- QUndoAction *result = new QUndoAction(pref, parent);
+ QUndoAction *result = new QUndoAction(prefix, parent);
+ if (prefix.isEmpty())
+ result->setTextFormat(tr("Redo %1"), tr("Redo", "Default text for redo action"));
+
result->setEnabled(canRedo());
result->setPrefixedText(redoText());
connect(this, SIGNAL(canRedoChanged(bool)),
diff --git a/src/gui/util/qundostack.h b/src/gui/util/qundostack.h
index 65941b5..700996f 100644
--- a/src/gui/util/qundostack.h
+++ b/src/gui/util/qundostack.h
@@ -70,6 +70,7 @@ public:
virtual void redo();
QString text() const;
+ QString actionText() const;
void setText(const QString &text);
virtual int id() const;
diff --git a/src/gui/util/qundostack_p.h b/src/gui/util/qundostack_p.h
index 3c7d0e7..a100763 100644
--- a/src/gui/util/qundostack_p.h
+++ b/src/gui/util/qundostack_p.h
@@ -70,6 +70,7 @@ public:
QUndoCommandPrivate() : id(-1) {}
QList<QUndoCommand*> child_list;
QString text;
+ QString actionText;
int id;
};
@@ -98,10 +99,12 @@ class QUndoAction : public QAction
Q_OBJECT
public:
QUndoAction(const QString &prefix, QObject *parent = 0);
+ void setTextFormat(const QString &textFormat, const QString &defaultText);
public Q_SLOTS:
void setPrefixedText(const QString &text);
private:
QString m_prefix;
+ QString m_defaultText;
};
#endif // QT_NO_ACTION
diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri
index 2814a2d..f125f82 100644
--- a/src/gui/util/util.pri
+++ b/src/gui/util/util.pri
@@ -6,11 +6,6 @@ HEADERS += \
util/qcompleter_p.h \
util/qdesktopservices.h \
util/qsystemtrayicon_p.h \
- util/qscroller.h \
- util/qscroller_p.h \
- util/qscrollerproperties.h \
- util/qscrollerproperties_p.h \
- util/qflickgesture_p.h \
util/qundogroup.h \
util/qundostack.h \
util/qundostack_p.h \
@@ -20,9 +15,6 @@ SOURCES += \
util/qsystemtrayicon.cpp \
util/qcompleter.cpp \
util/qdesktopservices.cpp \
- util/qscroller.cpp \
- util/qscrollerproperties.cpp \
- util/qflickgesture.cpp \
util/qundogroup.cpp \
util/qundostack.cpp \
util/qundoview.cpp
@@ -65,7 +57,3 @@ symbian {
DEFINES += USE_SCHEMEHANDLER
}
}
-
-macx {
- OBJECTIVE_SOURCES += util/qscroller_mac.mm
-}
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index dabfec0..2503b99 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -53,8 +53,6 @@
#include "qpainter.h"
#include "qmargins.h"
-#include <QDebug>
-
#include "qabstractscrollarea_p.h"
#include <qwidget.h>
@@ -64,10 +62,6 @@
#include <private/qt_mac_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
#endif
-#ifdef Q_WS_WIN
-# include <qlibrary.h>
-# include <windows.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -301,14 +295,9 @@ void QAbstractScrollAreaPrivate::init()
q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
layoutChildren();
#ifndef Q_WS_MAC
-# ifndef QT_NO_GESTURES
+#ifndef QT_NO_GESTURES
viewport->grabGesture(Qt::PanGesture);
-# endif
#endif
-#ifdef Q_WS_MAEMO_5
-# ifndef QT_NO_GESTURES
- // viewport->grabGesture(Qt::TouchFlickGesture);
-# endif
#endif
}
@@ -563,11 +552,6 @@ void QAbstractScrollArea::setViewport(QWidget *widget)
d->viewport->grabGesture(Qt::PanGesture);
#endif
#endif
-#ifdef Q_WS_MAEMO_5
-#ifndef QT_NO_GESTURES
-// d->viewport->grabGesture(Qt::TouchFlickGesture);
-#endif
-#endif
d->layoutChildren();
if (isVisible())
d->viewport->show();
@@ -1002,66 +986,6 @@ bool QAbstractScrollArea::event(QEvent *e)
return false;
}
#endif // QT_NO_GESTURES
- case QEvent::ScrollPrepare:
- {
- QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e);
- if (d->canStartScrollingAt(se->startPos().toPoint())) {
- QScrollBar *hBar = horizontalScrollBar();
- QScrollBar *vBar = verticalScrollBar();
-
- se->setViewportSize(QSizeF(viewport()->size()));
- se->setContentPosRange(QRectF(0, 0, hBar->maximum(), vBar->maximum()));
- se->setContentPos(QPointF(hBar->value(), vBar->value()));
- se->accept();
- return true;
- }
- return false;
- }
- case QEvent::Scroll:
- {
- QScrollEvent *se = static_cast<QScrollEvent *>(e);
-
- QScrollBar *hBar = horizontalScrollBar();
- QScrollBar *vBar = verticalScrollBar();
- hBar->setValue(se->contentPos().x());
- vBar->setValue(se->contentPos().y());
-
-#ifdef Q_WS_WIN
- typedef BOOL (*PtrBeginPanningFeedback)(HWND);
- typedef BOOL (*PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL);
- typedef BOOL (*PtrEndPanningFeedback)(HWND, BOOL);
-
- static PtrBeginPanningFeedback ptrBeginPanningFeedback = 0;
- static PtrUpdatePanningFeedback ptrUpdatePanningFeedback = 0;
- static PtrEndPanningFeedback ptrEndPanningFeedback = 0;
-
- if (!ptrBeginPanningFeedback)
- ptrBeginPanningFeedback = (PtrBeginPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "BeginPanningFeedback");
- if (!ptrUpdatePanningFeedback)
- ptrUpdatePanningFeedback = (PtrUpdatePanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "UpdatePanningFeedback");
- if (!ptrEndPanningFeedback)
- ptrEndPanningFeedback = (PtrEndPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "EndPanningFeedback");
-
- if (ptrBeginPanningFeedback && ptrUpdatePanningFeedback && ptrEndPanningFeedback) {
- WId wid = window()->winId();
-
- if (!se->overshootDistance().isNull() && d->overshoot.isNull())
- ptrBeginPanningFeedback(wid);
- if (!se->overshootDistance().isNull())
- ptrUpdatePanningFeedback(wid, -se->overshootDistance().x(), -se->overshootDistance().y(), false);
- if (se->overshootDistance().isNull() && !d->overshoot.isNull())
- ptrEndPanningFeedback(wid, true);
- } else
-#endif
- {
- QPoint delta = d->overshoot - se->overshootDistance().toPoint();
- if (!delta.isNull())
- viewport()->move(viewport()->pos() + delta);
- }
- d->overshoot = se->overshootDistance().toPoint();
-
- return true;
- }
case QEvent::StyleChange:
case QEvent::LayoutDirectionChange:
case QEvent::ApplicationLayoutDirectionChange:
@@ -1123,9 +1047,6 @@ bool QAbstractScrollArea::viewportEvent(QEvent *e)
case QEvent::GestureOverride:
return event(e);
#endif
- case QEvent::ScrollPrepare:
- case QEvent::Scroll:
- return event(e);
default:
break;
}
@@ -1382,32 +1303,6 @@ void QAbstractScrollArea::scrollContentsBy(int, int)
viewport()->update();
}
-bool QAbstractScrollAreaPrivate::canStartScrollingAt( const QPoint &startPos )
-{
- Q_Q(QAbstractScrollArea);
-
-#ifndef QT_NO_GRAPHICSVIEW
- // don't start scrolling when a drag mode has been set.
- // don't start scrolling on a movable item.
- if (QGraphicsView *view = qobject_cast<QGraphicsView *>(q)) {
- if (view->dragMode() != QGraphicsView::NoDrag)
- return false;
-
- QGraphicsItem *childItem = view->itemAt(startPos);
-
- if (childItem && (childItem->flags() & QGraphicsItem::ItemIsMovable))
- return false;
- }
-#endif
-
- // don't start scrolling on a QAbstractSlider
- if (qobject_cast<QAbstractSlider *>(q->viewport()->childAt(startPos))) {
- return false;
- }
-
- return true;
-}
-
void QAbstractScrollAreaPrivate::_q_hslide(int x)
{
Q_Q(QAbstractScrollArea);
diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h
index 76e1c34..85536e3 100644
--- a/src/gui/widgets/qabstractscrollarea_p.h
+++ b/src/gui/widgets/qabstractscrollarea_p.h
@@ -84,13 +84,11 @@ public:
int left, top, right, bottom; // viewport margin
int xoffset, yoffset;
- QPoint overshoot;
void init();
void layoutChildren();
// ### Fix for 4.4, talk to Bjoern E or Girish.
virtual void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy) {}
- bool canStartScrollingAt( const QPoint &startPos );
void _q_hslide(int);
void _q_vslide(int);
diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp
index 6337113..a4739a7 100644
--- a/src/gui/widgets/qdatetimeedit.cpp
+++ b/src/gui/widgets/qdatetimeedit.cpp
@@ -2538,20 +2538,32 @@ void QDateTimeEditPrivate::syncCalendarWidget()
}
QCalendarPopup::QCalendarPopup(QWidget * parent, QCalendarWidget *cw)
- : QWidget(parent, Qt::Popup), calendar(0)
+ : QWidget(parent, Qt::Popup)
{
setAttribute(Qt::WA_WindowPropagation);
dateChanged = false;
if (!cw) {
- cw = new QCalendarWidget(this);
+ verifyCalendarInstance();
+ } else {
+ setCalendarWidget(cw);
+ }
+}
+
+QCalendarWidget *QCalendarPopup::verifyCalendarInstance()
+{
+ if (calendar.isNull()) {
+ QCalendarWidget *cw = new QCalendarWidget(this);
cw->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
#ifdef QT_KEYPAD_NAVIGATION
if (QApplication::keypadNavigationEnabled())
cw->setHorizontalHeaderFormat(QCalendarWidget::SingleLetterDayNames);
#endif
+ setCalendarWidget(cw);
+ return cw;
+ } else {
+ return calendar.data();
}
- setCalendarWidget(cw);
}
void QCalendarPopup::setCalendarWidget(QCalendarWidget *cw)
@@ -2563,28 +2575,29 @@ void QCalendarPopup::setCalendarWidget(QCalendarWidget *cw)
widgetLayout->setMargin(0);
widgetLayout->setSpacing(0);
}
- delete calendar;
- calendar = cw;
- widgetLayout->addWidget(calendar);
+ delete calendar.data();
+ calendar = QWeakPointer<QCalendarWidget>(cw);
+ widgetLayout->addWidget(cw);
- connect(calendar, SIGNAL(activated(QDate)), this, SLOT(dateSelected(QDate)));
- connect(calendar, SIGNAL(clicked(QDate)), this, SLOT(dateSelected(QDate)));
- connect(calendar, SIGNAL(selectionChanged()), this, SLOT(dateSelectionChanged()));
+ connect(cw, SIGNAL(activated(QDate)), this, SLOT(dateSelected(QDate)));
+ connect(cw, SIGNAL(clicked(QDate)), this, SLOT(dateSelected(QDate)));
+ connect(cw, SIGNAL(selectionChanged()), this, SLOT(dateSelectionChanged()));
- calendar->setFocus();
+ cw->setFocus();
}
void QCalendarPopup::setDate(const QDate &date)
{
oldDate = date;
- calendar->setSelectedDate(date);
+ verifyCalendarInstance()->setSelectedDate(date);
}
void QCalendarPopup::setDateRange(const QDate &min, const QDate &max)
{
- calendar->setMinimumDate(min);
- calendar->setMaximumDate(max);
+ QCalendarWidget *cw = verifyCalendarInstance();
+ cw->setMinimumDate(min);
+ cw->setMaximumDate(max);
}
void QCalendarPopup::mousePressEvent(QMouseEvent *event)
@@ -2620,7 +2633,7 @@ bool QCalendarPopup::event(QEvent *event)
void QCalendarPopup::dateSelectionChanged()
{
dateChanged = true;
- emit newDateSelected(calendar->selectedDate());
+ emit newDateSelected(verifyCalendarInstance()->selectedDate());
}
void QCalendarPopup::dateSelected(const QDate &date)
{
diff --git a/src/gui/widgets/qdatetimeedit_p.h b/src/gui/widgets/qdatetimeedit_p.h
index acdc878..c85c0fb 100644
--- a/src/gui/widgets/qdatetimeedit_p.h
+++ b/src/gui/widgets/qdatetimeedit_p.h
@@ -148,11 +148,11 @@ class QCalendarPopup : public QWidget
Q_OBJECT
public:
QCalendarPopup(QWidget *parent = 0, QCalendarWidget *cw = 0);
- QDate selectedDate() { return calendar->selectedDate(); }
+ QDate selectedDate() { return verifyCalendarInstance()->selectedDate(); }
void setDate(const QDate &date);
void setDateRange(const QDate &min, const QDate &max);
- void setFirstDayOfWeek(Qt::DayOfWeek dow) { calendar->setFirstDayOfWeek(dow); }
- QCalendarWidget *calendarWidget() const { return calendar; }
+ void setFirstDayOfWeek(Qt::DayOfWeek dow) { verifyCalendarInstance()->setFirstDayOfWeek(dow); }
+ QCalendarWidget *calendarWidget() const { return const_cast<QCalendarPopup*>(this)->verifyCalendarInstance(); }
void setCalendarWidget(QCalendarWidget *cw);
Q_SIGNALS:
void activated(const QDate &date);
@@ -171,7 +171,9 @@ protected:
bool event(QEvent *e);
private:
- QCalendarWidget *calendar;
+ QCalendarWidget *verifyCalendarInstance();
+
+ QWeakPointer<QCalendarWidget> calendar;
QDate oldDate;
bool dateChanged;
};
diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp
index 223421d..28c0388 100644
--- a/src/gui/widgets/qdockarealayout.cpp
+++ b/src/gui/widgets/qdockarealayout.cpp
@@ -2100,7 +2100,6 @@ bool QDockAreaLayoutInfo::updateTabBar() const
bool gap = false;
int tab_idx = 0;
- bool changed = false;
for (int i = 0; i < item_list.count(); ++i) {
const QDockAreaLayoutItem &item = item_list.at(i);
if (item.skip())
@@ -2121,7 +2120,6 @@ bool QDockAreaLayoutInfo::updateTabBar() const
tabBar->setTabToolTip(tab_idx, title);
#endif
tabBar->setTabData(tab_idx, id);
- changed = true;
} else if (qvariant_cast<quintptr>(tabBar->tabData(tab_idx)) != id) {
if (tab_idx + 1 < tabBar->count()
&& qvariant_cast<quintptr>(tabBar->tabData(tab_idx + 1)) == id)
@@ -2133,7 +2131,6 @@ bool QDockAreaLayoutInfo::updateTabBar() const
#endif
tabBar->setTabData(tab_idx, id);
}
- changed = true;
}
if (title != tabBar->tabText(tab_idx)) {
@@ -2141,7 +2138,6 @@ bool QDockAreaLayoutInfo::updateTabBar() const
#ifndef QT_NO_TOOLTIP
tabBar->setTabToolTip(tab_idx, title);
#endif
- changed = true;
}
++tab_idx;
@@ -2149,7 +2145,6 @@ bool QDockAreaLayoutInfo::updateTabBar() const
while (tab_idx < tabBar->count()) {
tabBar->removeTab(tab_idx);
- changed = true;
}
tabBar->blockSignals(blocked);
diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp
index 9d1a737..16b60c8 100644
--- a/src/gui/widgets/qdockwidget.cpp
+++ b/src/gui/widgets/qdockwidget.cpp
@@ -161,7 +161,6 @@ void QDockWidgetTitleButton::paintEvent(QPaintEvent *)
{
QPainter p(this);
- QRect r = rect();
QStyleOptionToolButton opt;
opt.init(this);
opt.state |= QStyle::State_AutoRaise;
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index ced66e5..c9dae77 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -435,6 +435,8 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event)
c += event->commitString().length() - qMin(-event->replacementStart(), event->replacementLength());
m_cursor += event->replacementStart();
+ if (m_cursor < 0)
+ m_cursor = 0;
// insert commit string
if (event->replacementLength()) {
@@ -447,7 +449,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event)
cursorPositionChanged = true;
}
- m_cursor = qMin(c, m_text.length());
+ m_cursor = qBound(0, c, m_text.length());
for (int i = 0; i < event->attributes().size(); ++i) {
const QInputMethodEvent::Attribute &a = event->attributes().at(i);
@@ -1593,6 +1595,7 @@ void QLineControl::processKeyEvent(QKeyEvent* event)
}
bool unknown = false;
+ bool visual = cursorMoveStyle() == Qt::VisualMoveStyle;
if (false) {
}
@@ -1657,11 +1660,11 @@ void QLineControl::processKeyEvent(QKeyEvent* event)
#endif
moveCursor(selectionEnd(), false);
} else {
- cursorForward(0, layoutDirection() == Qt::LeftToRight ? 1 : -1);
+ cursorForward(0, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1));
}
}
else if (event == QKeySequence::SelectNextChar) {
- cursorForward(1, layoutDirection() == Qt::LeftToRight ? 1 : -1);
+ cursorForward(1, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1));
}
else if (event == QKeySequence::MoveToPreviousChar) {
#if !defined(Q_WS_WIN) || defined(QT_NO_COMPLETER)
@@ -1672,11 +1675,11 @@ void QLineControl::processKeyEvent(QKeyEvent* event)
#endif
moveCursor(selectionStart(), false);
} else {
- cursorForward(0, layoutDirection() == Qt::LeftToRight ? -1 : 1);
+ cursorForward(0, visual ? -1 : (layoutDirection() == Qt::LeftToRight ? -1 : 1));
}
}
else if (event == QKeySequence::SelectPreviousChar) {
- cursorForward(1, layoutDirection() == Qt::LeftToRight ? -1 : 1);
+ cursorForward(1, visual ? -1 : (layoutDirection() == Qt::LeftToRight ? -1 : 1));
}
else if (event == QKeySequence::MoveToNextWord) {
if (echoMode() == QLineEdit::Normal)
diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h
index 7f3cad6..9764ba9 100644
--- a/src/gui/widgets/qlinecontrol_p.h
+++ b/src/gui/widgets/qlinecontrol_p.h
@@ -160,6 +160,8 @@ public:
int cursorWidth() const { return m_cursorWidth; }
void setCursorWidth(int value) { m_cursorWidth = value; }
+ Qt::CursorMoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); }
+ void setCursorMoveStyle(Qt::CursorMoveStyle style) { m_textLayout.setCursorMoveStyle(style); }
void moveCursor(int pos, bool mark = false);
void cursorForward(bool mark, int steps)
@@ -167,10 +169,12 @@ public:
int c = m_cursor;
if (steps > 0) {
while (steps--)
- c = m_textLayout.nextCursorPosition(c);
+ c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.rightCursorPosition(c)
+ : m_textLayout.nextCursorPosition(c);
} else if (steps < 0) {
while (steps++)
- c = m_textLayout.previousCursorPosition(c);
+ c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.leftCursorPosition(c)
+ : m_textLayout.previousCursorPosition(c);
}
moveCursor(c, mark);
}
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 07bd273..3c9874e 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1112,6 +1112,34 @@ void QLineEdit::setDragEnabled(bool b)
/*!
+ \property QLineEdit::cursorMoveStyle
+ \brief the movement style of cursor in this line edit
+ \since 4.8
+
+ When this property is set to Qt::VisualMoveStyle, the line edit will use visual
+ movement style. Pressing the left arrow key will always cause the cursor to move
+ left, regardless of the text's writing direction. The same behavior applies to
+ right arrow key.
+
+ When the property is Qt::LogicalMoveStyle (the default), within a LTR text block,
+ increase cursor position when pressing left arrow key, decrease cursor position
+ when pressing the right arrow key. If the text block is right to left, the opposite
+ behavior applies.
+*/
+
+Qt::CursorMoveStyle QLineEdit::cursorMoveStyle() const
+{
+ Q_D(const QLineEdit);
+ return d->control->cursorMoveStyle();
+}
+
+void QLineEdit::setCursorMoveStyle(Qt::CursorMoveStyle style)
+{
+ Q_D(QLineEdit);
+ d->control->setCursorMoveStyle(style);
+}
+
+/*!
\property QLineEdit::acceptableInput
\brief whether the input satisfies the inputMask and the
validator.
diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h
index 636cee7..e88273f 100644
--- a/src/gui/widgets/qlineedit.h
+++ b/src/gui/widgets/qlineedit.h
@@ -43,6 +43,7 @@
#define QLINEEDIT_H
#include <QtGui/qframe.h>
+#include <QtGui/qtextcursor.h>
#include <QtCore/qstring.h>
#include <QtCore/qmargins.h>
@@ -84,6 +85,7 @@ class Q_GUI_EXPORT QLineEdit : public QWidget
Q_PROPERTY(bool redoAvailable READ isRedoAvailable)
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
+ Q_PROPERTY(Qt::CursorMoveStyle cursorMoveStyle READ cursorMoveStyle WRITE setCursorMoveStyle)
public:
explicit QLineEdit(QWidget* parent=0);
@@ -158,6 +160,9 @@ public:
void setDragEnabled(bool b);
bool dragEnabled() const;
+ void setCursorMoveStyle(Qt::CursorMoveStyle style);
+ Qt::CursorMoveStyle cursorMoveStyle() const;
+
QString inputMask() const;
void setInputMask(const QString &inputMask);
bool hasAcceptableInput() const;
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index 43d6796..e39e595 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -78,7 +78,6 @@ public:
: layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly)
#ifdef Q_WS_MAC
, useHIToolBar(false)
- , activateUnifiedToolbarAfterFullScreen(false)
#endif
#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
, hasOldCursor(false) , cursorAdjusted(false)
@@ -90,7 +89,6 @@ public:
Qt::ToolButtonStyle toolButtonStyle;
#ifdef Q_WS_MAC
bool useHIToolBar;
- bool activateUnifiedToolbarAfterFullScreen;
#endif
void init();
QList<int> hoverSeparator;
diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp
index d4afe07..8880ca9 100644
--- a/src/gui/widgets/qmainwindowlayout.cpp
+++ b/src/gui/widgets/qmainwindowlayout.cpp
@@ -1699,6 +1699,7 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLay
, gapIndicator(new QRubberBand(QRubberBand::Rectangle, mainwindow))
#endif //QT_NO_RUBBERBAND
#ifdef Q_WS_MAC
+ , activateUnifiedToolbarAfterFullScreen(false)
, blockVisiblityCheck(false)
#endif
{
diff --git a/src/gui/widgets/qmainwindowlayout_p.h b/src/gui/widgets/qmainwindowlayout_p.h
index 20aca61..0442510 100644
--- a/src/gui/widgets/qmainwindowlayout_p.h
+++ b/src/gui/widgets/qmainwindowlayout_p.h
@@ -338,7 +338,6 @@ public:
void removeFromMacToolbar(QToolBar *toolbar);
void cleanUpMacToolbarItems();
void fixSizeInUnifiedToolbar(QToolBar *tb) const;
- bool useHIToolBar;
bool activateUnifiedToolbarAfterFullScreen;
void syncUnifiedToolbarVisibility();
bool blockVisiblityCheck;
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index b0ea00f..1dac661 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -82,6 +82,10 @@
# include <private/qt_cocoa_helpers_mac_p.h>
#endif
+#ifdef Q_WS_S60
+# include "private/qt_s60_p.h"
+#endif
+
QT_BEGIN_NAMESPACE
@@ -172,6 +176,14 @@ void QMenuPrivate::init()
q->addAction(selectAction);
q->addAction(cancelAction);
#endif
+
+#ifdef Q_WS_S60
+ if (S60->avkonComponentsSupportTransparency) {
+ bool noSystemBackground = q->testAttribute(Qt::WA_NoSystemBackground);
+ q->setAttribute(Qt::WA_TranslucentBackground); // also sets WA_NoSystemBackground
+ q->setAttribute(Qt::WA_NoSystemBackground, noSystemBackground); // restore system background attribute
+ }
+#endif
}
int QMenuPrivate::scrollerHeight() const
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 7435691..51c4ccb 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -483,6 +483,7 @@ int QPlainTextEditPrivate::verticalOffset(int topBlock, int topLine) const
QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout());
Q_ASSERT(documentLayout);
QRectF r = documentLayout->blockBoundingRect(currentBlock);
+ Q_UNUSED(r);
QTextLayout *layout = currentBlock.layout();
if (layout && topLine <= layout->lineCount()) {
QTextLine line = layout->lineAt(topLine - 1);
@@ -648,6 +649,11 @@ void QPlainTextEditPrivate::setTopBlock(int blockNumber, int lineNumber, int dx)
}
control->topBlock = blockNumber;
topLine = lineNumber;
+
+ bool vbarSignalsBlocked = vbar->blockSignals(true);
+ vbar->setValue(block.firstLineNumber() + lineNumber);
+ vbar->blockSignals(vbarSignalsBlocked);
+
if (dx || dy)
viewport->scroll(q->isRightToLeft() ? -dx : dx, dy);
else
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index ff924bf..8df436f 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -2614,7 +2614,6 @@ Qt::TextFormat QTextEdit::textFormat() const
void QTextEdit::append(const QString &text)
{
Q_D(QTextEdit);
- QTextBlock lastBlock = d->control->document()->lastBlock();
const bool atBottom = isReadOnly() ? d->verticalOffset() >= d->vbar->maximum() :
d->control->textCursor().atEnd();
d->control->append(text);
diff --git a/src/gui/widgets/qworkspace.cpp b/src/gui/widgets/qworkspace.cpp
index bf50d07..13ef13b 100644
--- a/src/gui/widgets/qworkspace.cpp
+++ b/src/gui/widgets/qworkspace.cpp
@@ -1239,7 +1239,6 @@ QWidget * QWorkspace::addWindow(QWidget *w, Qt::WindowFlags flags)
int x = w->x();
int y = w->y();
bool hasPos = w->testAttribute(Qt::WA_Moved);
- QSize s = w->size().expandedTo(qSmartMinSize(w));
if (!hasSize && w->sizeHint().isValid())
w->adjustSize();
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 07dd729..a471559 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -519,6 +519,15 @@ bool QHttpNetworkConnectionPrivate::dequeueRequest(QAbstractSocket *socket)
return false;
}
+QHttpNetworkRequest QHttpNetworkConnectionPrivate::predictNextRequest()
+{
+ if (!highPriorityQueue.isEmpty())
+ return highPriorityQueue.last().first;
+ if (!lowPriorityQueue.isEmpty())
+ return lowPriorityQueue.last().first;
+ return QHttpNetworkRequest();
+}
+
// this is called from _q_startNextRequest and when a request has been sent down a socket from the channel
void QHttpNetworkConnectionPrivate::fillPipeline(QAbstractSocket *socket)
{
diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h
index adb779f4..329d3626 100644
--- a/src/network/access/qhttpnetworkconnection_p.h
+++ b/src/network/access/qhttpnetworkconnection_p.h
@@ -169,6 +169,7 @@ public:
void requeueRequest(const HttpMessagePair &pair); // e.g. after pipeline broke
bool dequeueRequest(QAbstractSocket *socket);
void prepareRequest(HttpMessagePair &request);
+ QHttpNetworkRequest predictNextRequest();
void fillPipeline(QAbstractSocket *socket);
bool fillPipeline(QList<HttpMessagePair> &queue, QHttpNetworkConnectionChannel &channel);
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 6fbc6f8..f440101 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -579,6 +579,17 @@ bool QHttpNetworkConnectionChannel::ensureConnection()
connectHost = connection->d_func()->networkProxy.hostName();
connectPort = connection->d_func()->networkProxy.port();
}
+ if (socket->proxy().type() == QNetworkProxy::HttpProxy) {
+ // Make user-agent field available to HTTP proxy socket engine (QTBUG-17223)
+ QByteArray value;
+ // ensureConnection is called before any request has been assigned, but can also be called again if reconnecting
+ if (request.url().isEmpty())
+ value = connection->d_func()->predictNextRequest().headerField("user-agent");
+ else
+ value = request.headerField("user-agent");
+ if (!value.isEmpty())
+ socket->setProperty("_q_user-agent", value);
+ }
#endif
if (ssl) {
#ifndef QT_NO_OPENSSL
diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp
index 99f9376..0364dac 100644
--- a/src/network/access/qhttpthreaddelegate.cpp
+++ b/src/network/access/qhttpthreaddelegate.cpp
@@ -51,6 +51,7 @@
#include "private/qnetworkaccesscache_p.h"
#include "private/qnoncontiguousbytedevice_p.h"
+#ifndef QT_NO_HTTP
QT_BEGIN_NAMESPACE
@@ -576,4 +577,6 @@ void QHttpThreadDelegate::synchronousProxyAuthenticationRequiredSlot(const QNet
#endif
+#endif // QT_NO_HTTP
+
QT_END_NAMESPACE
diff --git a/src/network/access/qhttpthreaddelegate_p.h b/src/network/access/qhttpthreaddelegate_p.h
index 752bc09..c0f2077 100644
--- a/src/network/access/qhttpthreaddelegate_p.h
+++ b/src/network/access/qhttpthreaddelegate_p.h
@@ -68,6 +68,8 @@
#include "private/qnoncontiguousbytedevice_p.h"
#include "qnetworkaccessauthenticationmanager_p.h"
+#ifndef QT_NO_HTTP
+
QT_BEGIN_NAMESPACE
class QAuthenticator;
@@ -285,4 +287,6 @@ signals:
QT_END_NAMESPACE
+#endif // QT_NO_HTTP
+
#endif // QHTTPTHREADDELEGATE_H
diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp
index 6220abe..2aea350 100644
--- a/src/network/access/qnetworkaccessbackend.cpp
+++ b/src/network/access/qnetworkaccessbackend.cpp
@@ -41,6 +41,7 @@
#include "qnetworkaccessbackend_p.h"
#include "qnetworkaccessmanager_p.h"
+#include "qnetworkconfigmanager.h"
#include "qnetworkrequest.h"
#include "qnetworkreply.h"
#include "qnetworkreply_p.h"
@@ -343,8 +344,6 @@ void QNetworkAccessBackend::sslErrors(const QList<QSslError> &errors)
#endif
}
-#ifndef QT_NO_BEARERMANAGEMENT
-
/*!
Starts the backend. Returns true if the backend is started. Returns false if the backend
could not be started due to an unopened or roaming session. The caller should recall this
@@ -352,31 +351,62 @@ void QNetworkAccessBackend::sslErrors(const QList<QSslError> &errors)
*/
bool QNetworkAccessBackend::start()
{
- if (!manager->networkSession) {
- open();
- return true;
- }
-
- // This is not ideal.
- const QString host = reply->url.host();
- if (host == QLatin1String("localhost") ||
- QHostAddress(host) == QHostAddress::LocalHost ||
- QHostAddress(host) == QHostAddress::LocalHostIPv6) {
- // Don't need an open session for localhost access.
- open();
- return true;
+#ifndef QT_NO_BEARERMANAGEMENT
+ // For bearer, check if session start is required
+ if (manager->networkSession) {
+ // session required
+ if (manager->networkSession->isOpen() &&
+ manager->networkSession->state() == QNetworkSession::Connected) {
+ // Session is already open and ready to use.
+ // copy network session down to the backend
+ setProperty("_q_networksession", QVariant::fromValue(manager->networkSession));
+ } else {
+ // Session not ready, but can skip for loopback connections
+
+ // This is not ideal.
+ const QString host = reply->url.host();
+
+ if (host == QLatin1String("localhost") ||
+ QHostAddress(host) == QHostAddress::LocalHost ||
+ QHostAddress(host) == QHostAddress::LocalHostIPv6) {
+ // Don't need an open session for localhost access.
+ } else {
+ // need to wait for session to be opened
+ return false;
+ }
+ }
}
+#endif
- if (manager->networkSession->isOpen() &&
- manager->networkSession->state() == QNetworkSession::Connected) {
- //copy network session down to the backend
- setProperty("_q_networksession", QVariant::fromValue(manager->networkSession));
- open();
- return true;
+#ifndef QT_NO_NETWORKPROXY
+#ifndef QT_NO_BEARERMANAGEMENT
+ // Get the proxy settings from the network session (in the case of service networks,
+ // the proxy settings change depending which AP was activated)
+ QNetworkSession *session = manager->networkSession.data();
+ QNetworkConfiguration config;
+ if (session) {
+ QNetworkConfigurationManager configManager;
+ // The active configuration tells us what IAP is in use
+ QVariant v = session->sessionProperty(QLatin1String("ActiveConfiguration"));
+ if (v.isValid())
+ config = configManager.configurationFromIdentifier(qvariant_cast<QString>(v));
+ // Fallback to using the configuration if no active configuration
+ if (!config.isValid())
+ config = session->configuration();
+ // or unspecified configuration if that is no good either
+ if (!config.isValid())
+ config = QNetworkConfiguration();
}
+ reply->proxyList = manager->queryProxy(QNetworkProxyQuery(config, url()));
+#else // QT_NO_BEARERMANAGEMENT
+ // Without bearer management, the proxy depends only on the url
+ reply->proxyList = manager->queryProxy(QNetworkProxyQuery(url()));
+#endif
+#endif
- return false;
+ // now start the request
+ open();
+ return true;
}
-#endif
QT_END_NAMESPACE
diff --git a/src/network/access/qnetworkaccesscachebackend.cpp b/src/network/access/qnetworkaccesscachebackend.cpp
index 13f4cd9..c585848 100644
--- a/src/network/access/qnetworkaccesscachebackend.cpp
+++ b/src/network/access/qnetworkaccesscachebackend.cpp
@@ -66,6 +66,7 @@ void QNetworkAccessCacheBackend::open()
QString msg = QCoreApplication::translate("QNetworkAccessCacheBackend", "Error opening %1")
.arg(this->url().toString());
error(QNetworkReply::ContentNotFoundError, msg);
+ } else {
setAttribute(QNetworkRequest::SourceIsFromCacheAttribute, true);
}
finished();
@@ -85,14 +86,18 @@ bool QNetworkAccessCacheBackend::sendCacheContents()
QNetworkCacheMetaData::AttributesMap attributes = item.attributes();
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, attributes.value(QNetworkRequest::HttpStatusCodeAttribute));
setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, attributes.value(QNetworkRequest::HttpReasonPhraseAttribute));
- setAttribute(QNetworkRequest::SourceIsFromCacheAttribute, true);
// set the raw headers
QNetworkCacheMetaData::RawHeaderList rawHeaders = item.rawHeaders();
QNetworkCacheMetaData::RawHeaderList::ConstIterator it = rawHeaders.constBegin(),
end = rawHeaders.constEnd();
- for ( ; it != end; ++it)
+ for ( ; it != end; ++it) {
+ if (it->first.toLower() == "cache-control" &&
+ it->second.toLower().contains("must-revalidate")) {
+ return false;
+ }
setRawHeader(it->first, it->second);
+ }
// handle a possible redirect
QVariant redirectionTarget = attributes.value(QNetworkRequest::RedirectionTargetAttribute);
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index c619114..a45c2de 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -262,13 +262,11 @@ bool QNetworkAccessHttpBackend::loadFromCacheIfAllowed(QHttpNetworkRequest &http
if (lastModified.isValid())
httpRequest.setHeaderField("If-Modified-Since", QNetworkHeadersPrivate::toHttpDate(lastModified));
- if (CacheLoadControlAttribute == QNetworkRequest::PreferNetwork) {
- it = cacheHeaders.findRawHeader("Cache-Control");
- if (it != cacheHeaders.rawHeaders.constEnd()) {
- QHash<QByteArray, QByteArray> cacheControl = parseHttpOptionHeader(it->second);
- if (cacheControl.contains("must-revalidate"))
- return false;
- }
+ it = cacheHeaders.findRawHeader("Cache-Control");
+ if (it != cacheHeaders.rawHeaders.constEnd()) {
+ QHash<QByteArray, QByteArray> cacheControl = parseHttpOptionHeader(it->second);
+ if (cacheControl.contains("must-revalidate"))
+ return false;
}
QDateTime currentDateTime = QDateTime::currentDateTime();
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 5a7521e..55d6a7c 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -861,7 +861,7 @@ QNetworkAccessManager::NetworkAccessibility QNetworkAccessManager::networkAccess
device will be uploaded to the server; in that case, data must be open for
reading and must remain valid until the finished() signal is emitted for this reply.
- \note This feature is currently available for HTTP only.
+ \note This feature is currently available for HTTP(S) only.
\sa get(), post(), put(), deleteResource()
*/
@@ -986,10 +986,6 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
// third step: find a backend
priv->backend = d->findBackend(op, request);
-#ifndef QT_NO_NETWORKPROXY
- QList<QNetworkProxy> proxyList = d->queryProxy(QNetworkProxyQuery(request.url()));
- priv->proxyList = proxyList;
-#endif
if (priv->backend) {
priv->backend->setParent(reply);
priv->backend->reply = priv;
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp
index 52eb345..eec8507 100644
--- a/src/network/access/qnetworkcookie.cpp
+++ b/src/network/access/qnetworkcookie.cpp
@@ -395,8 +395,8 @@ static QPair<QByteArray, QByteArray> nextField(const QByteArray &text, int &posi
// qdtext = <any TEXT except <">>
// quoted-pair = "\" CHAR
- // If its NAME=VALUE, retain the value as is
- // refer to ttp://bugreports.qt.nokia.com/browse/QTBUG-17746
+ // If it is NAME=VALUE, retain the value as is
+ // refer to http://bugreports.qt.nokia.com/browse/QTBUG-17746
if (isNameValue)
second += '"';
++i;
@@ -432,7 +432,9 @@ static QPair<QByteArray, QByteArray> nextField(const QByteArray &text, int &posi
position = i;
for ( ; i < length; ++i) {
register char c = text.at(i);
- if (c == ',' || c == ';' || isLWS(c))
+ // for name value pairs, we want to parse until reaching the next ';'
+ // and not break when reaching a space char
+ if (c == ',' || c == ';' || ((isNameValue && (c == '\n' || c == '\r')) || (!isNameValue && isLWS(c))))
break;
}
@@ -487,7 +489,6 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const
result += '=';
if ((d->value.contains(';') ||
d->value.contains(',') ||
- d->value.contains(' ') ||
d->value.contains('"')) &&
(!d->value.startsWith('"') &&
!d->value.endsWith('"'))) {
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 9eb505d..db57e90 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -90,10 +90,10 @@ void QNetworkReplyImplPrivate::_q_startOperation()
return;
}
+ if (!backend->start()) {
#ifndef QT_NO_BEARERMANAGEMENT
- if (!backend->start()) { // ### we should call that method even if bearer is not used
// backend failed to start because the session state is not Connected.
- // QNetworkAccessManager will call reply->backend->start() again for us when the session
+ // QNetworkAccessManager will call _q_startOperation again for us when the session
// state changes.
state = WaitingForSession;
@@ -109,11 +109,20 @@ void QNetworkReplyImplPrivate::_q_startOperation()
session->open();
} else {
qWarning("Backend is waiting for QNetworkSession to connect, but there is none!");
+ state = Working;
+ error(QNetworkReplyImpl::UnknownNetworkError,
+ QCoreApplication::translate("QNetworkReply", "Network session error."));
+ finished();
}
-
+#else
+ qWarning("Backend start failed");
+ state = Working;
+ error(QNetworkReplyImpl::UnknownNetworkError,
+ QCoreApplication::translate("QNetworkReply", "backend start error."));
+ finished();
+#endif
return;
}
-#endif
if (backend && backend->isSynchronous()) {
state = Finished;
@@ -851,6 +860,8 @@ void QNetworkReplyImpl::abort()
if (d->state != QNetworkReplyImplPrivate::Finished) {
// call finished which will emit signals
d->error(OperationCanceledError, tr("Operation canceled"));
+ if (d->state == QNetworkReplyImplPrivate::WaitingForSession)
+ d->state = QNetworkReplyImplPrivate::Working;
d->finished();
}
d->state = QNetworkReplyImplPrivate::Aborted;
@@ -1010,10 +1021,6 @@ bool QNetworkReplyImplPrivate::migrateBackend()
if (state == Finished || state == Aborted)
return true;
- // Backend does not support resuming download.
- if (!backend->canResume())
- return false;
-
// Request has outgoing data, not migrating.
if (outgoingData)
return false;
@@ -1022,6 +1029,10 @@ bool QNetworkReplyImplPrivate::migrateBackend()
if (copyDevice)
return true;
+ // Backend does not support resuming download.
+ if (!backend->canResume())
+ return false;
+
state = QNetworkReplyImplPrivate::Reconnecting;
if (backend) {
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp
index c108ad3..42fc49d 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.cpp
+++ b/src/network/bearer/qnetworkconfigmanager_p.cpp
@@ -60,7 +60,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
#endif
QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate()
- : QObject(), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true)
+ : QObject(), pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true)
{
qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration");
qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer");
@@ -385,8 +385,6 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer)));
connect(engine, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)));
-
- QMetaObject::invokeMethod(engine, "initialize");
}
}
@@ -410,8 +408,19 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
startPolling();
}
- if (firstUpdate)
+ if (firstUpdate) {
firstUpdate = false;
+ QList<QBearerEngine*> enginesToInitialize = sessionEngines; //shallow copy the list in case it is modified when we unlock mutex
+ Qt::ConnectionType connectionType;
+ if (QCoreApplicationPrivate::mainThread() == QThread::currentThread())
+ connectionType = Qt::DirectConnection;
+ else
+ connectionType = Qt::BlockingQueuedConnection;
+ locker.unlock();
+ foreach (QBearerEngine* engine, enginesToInitialize) {
+ QMetaObject::invokeMethod(engine, "initialize", connectionType);
+ }
+ }
}
void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate()
@@ -442,9 +451,19 @@ void QNetworkConfigurationManagerPrivate::startPolling()
{
QMutexLocker locker(&mutex);
+ if(!pollTimer) {
+ pollTimer = new QTimer(this);
+ pollTimer->setInterval(10000);
+ pollTimer->setSingleShot(true);
+ connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollEngines()));
+ }
+
+ if(pollTimer->isActive())
+ return;
+
foreach (QBearerEngine *engine, sessionEngines) {
if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) {
- QTimer::singleShot(10000, this, SLOT(pollEngines()));
+ pollTimer->start();
break;
}
}
@@ -469,7 +488,7 @@ void QNetworkConfigurationManagerPrivate::enablePolling()
++forcedPolling;
if (forcedPolling == 1)
- startPolling();
+ QMetaObject::invokeMethod(this, "startPolling");
}
void QNetworkConfigurationManagerPrivate::disablePolling()
diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h
index 81f38c5..45d6a75 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.h
+++ b/src/network/bearer/qnetworkconfigmanager_p.h
@@ -64,6 +64,7 @@
QT_BEGIN_NAMESPACE
class QBearerEngine;
+class QTimer;
class Q_NETWORK_EXPORT QNetworkConfigurationManagerPrivate : public QObject
{
@@ -106,7 +107,8 @@ private Q_SLOTS:
void pollEngines();
private:
- void startPolling();
+ Q_INVOKABLE void startPolling();
+ QTimer *pollTimer;
private:
mutable QMutex mutex;
diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp
index ae7d7a1..4e7c286 100644
--- a/src/network/kernel/qhostaddress.cpp
+++ b/src/network/kernel/qhostaddress.cpp
@@ -720,7 +720,8 @@ Q_IPV6ADDR QHostAddress::toIPv6Address() const
Returns the address as a string.
For example, if the address is the IPv4 address 127.0.0.1, the
- returned string is "127.0.0.1".
+ returned string is "127.0.0.1". For IPv6 the string format will
+ follow the RFC5952 recommendation.
\sa toIPv4Address()
*/
@@ -741,8 +742,32 @@ QString QHostAddress::toString() const
ugle[i] = (quint16(d->a6[2*i]) << 8) | quint16(d->a6[2*i+1]);
}
QString s;
- s.sprintf("%X:%X:%X:%X:%X:%X:%X:%X",
- ugle[0], ugle[1], ugle[2], ugle[3], ugle[4], ugle[5], ugle[6], ugle[7]);
+ QString temp;
+ bool zeroDetected = false;
+ bool zeroShortened = false;
+ for (int i = 0; i < 8; i++) {
+ if ((ugle[i] != 0) || zeroShortened) {
+ temp.sprintf("%X", ugle[i]);
+ s.append(temp);
+ if (zeroDetected)
+ zeroShortened = true;
+ } else {
+ if (!zeroDetected) {
+ if (i<7 && (ugle[i+1] == 0)) {
+ s.append(QLatin1Char(':'));
+ zeroDetected = true;
+ } else {
+ temp.sprintf("%X", ugle[i]);
+ s.append(temp);
+ if (i<7)
+ s.append(QLatin1Char(':'));
+ }
+ }
+ }
+ if (i<7 && ((ugle[i] != 0) || zeroShortened || (i==0 && zeroDetected)))
+ s.append(QLatin1Char(':'));
+ }
+
if (!d->scopeId.isEmpty())
s.append(QLatin1Char('%') + d->scopeId);
return s;
diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp
index 6098bde..7f251a7 100644
--- a/src/network/kernel/qnetworkinterface_unix.cpp
+++ b/src/network/kernel/qnetworkinterface_unix.cpp
@@ -219,7 +219,7 @@ static QNetworkInterfacePrivate *findInterface(int socket, QList<QNetworkInterfa
#ifdef SIOCGIFHWADDR
// Get the HW address
if (qt_safe_ioctl(socket, SIOCGIFHWADDR, &req) >= 0) {
- uchar *addr = (uchar *)&req.ifr_addr;
+ uchar *addr = (uchar *)req.ifr_addr.sa_data;
iface->hardwareAddress = iface->makeHwAddress(6, addr);
}
#endif
diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp
index 68ff955..14db913 100644
--- a/src/network/kernel/qnetworkproxy.cpp
+++ b/src/network/kernel/qnetworkproxy.cpp
@@ -228,6 +228,10 @@
#include "qmutex.h"
#include "qurl.h"
+#ifndef QT_NO_BEARERMANAGEMENT
+#include <QtNetwork/QNetworkConfiguration>
+#endif
+
QT_BEGIN_NAMESPACE
class QSocks5SocketEngineHandler;
@@ -716,6 +720,9 @@ public:
QUrl remote;
int localPort;
QNetworkProxyQuery::QueryType type;
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkConfiguration config;
+#endif
};
template<> void QSharedDataPointer<QNetworkProxyQueryPrivate>::detach()
@@ -777,6 +784,11 @@ template<> void QSharedDataPointer<QNetworkProxyQueryPrivate>::detach()
like choosing an caching HTTP proxy for HTTP-based connections,
but a more powerful SOCKSv5 proxy for all others.
+ The network configuration specifies which configuration to use,
+ when bearer management is used. For example on a mobile phone
+ the proxy settings are likely to be different for the cellular
+ network vs WLAN.
+
Some of the criteria may not make sense in all of the types of
query. The following table lists the criteria that are most
commonly used, according to the type of query.
@@ -902,6 +914,68 @@ QNetworkProxyQuery::QNetworkProxyQuery(quint16 bindPort, const QString &protocol
d->type = queryType;
}
+#ifndef QT_NO_BEARERMANAGEMENT
+/*!
+ Constructs a QNetworkProxyQuery with the URL \a requestUrl and
+ sets the query type to \a queryType. The specified \a networkConfiguration
+ is used to resolve the proxy settings.
+
+ \sa protocolTag(), peerHostName(), peerPort(), networkConfiguration()
+*/
+QNetworkProxyQuery::QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration,
+ const QUrl &requestUrl, QueryType queryType)
+{
+ d->config = networkConfiguration;
+ d->remote = requestUrl;
+ d->type = queryType;
+}
+
+/*!
+ Constructs a QNetworkProxyQuery of type \a queryType and sets the
+ protocol tag to be \a protocolTag. This constructor is suitable
+ for QNetworkProxyQuery::TcpSocket queries, because it sets the
+ peer hostname to \a hostname and the peer's port number to \a
+ port. The specified \a networkConfiguration
+ is used to resolve the proxy settings.
+
+ \sa networkConfiguration()
+*/
+QNetworkProxyQuery::QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration,
+ const QString &hostname, int port,
+ const QString &protocolTag,
+ QueryType queryType)
+{
+ d->config = networkConfiguration;
+ d->remote.setScheme(protocolTag);
+ d->remote.setHost(hostname);
+ d->remote.setPort(port);
+ d->type = queryType;
+}
+
+/*!
+ Constructs a QNetworkProxyQuery of type \a queryType and sets the
+ protocol tag to be \a protocolTag. This constructor is suitable
+ for QNetworkProxyQuery::TcpSocket queries because it sets the
+ local port number to \a bindPort. The specified \a networkConfiguration
+ is used to resolve the proxy settings.
+
+ Note that \a bindPort is of type quint16 to indicate the exact
+ port number that is requested. The value of -1 (unknown) is not
+ allowed in this context.
+
+ \sa localPort(), networkConfiguration()
+*/
+QNetworkProxyQuery::QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration,
+ quint16 bindPort, const QString &protocolTag,
+ QueryType queryType)
+{
+ d->config = networkConfiguration;
+ d->remote.setScheme(protocolTag);
+ d->localPort = bindPort;
+ d->type = queryType;
+}
+#endif
+
/*!
Constructs a QNetworkProxyQuery object that is a copy of \a other.
*/
@@ -1116,6 +1190,30 @@ void QNetworkProxyQuery::setUrl(const QUrl &url)
d->remote = url;
}
+#ifndef QT_NO_BEARERMANAGEMENT
+QNetworkConfiguration QNetworkProxyQuery::networkConfiguration() const
+{
+ return d ? d->config : QNetworkConfiguration();
+}
+
+/*!
+ Sets the network configuration component of this QNetworkProxyQuery
+ object to be \a networkConfiguration. The network configuration can
+ be used to return different proxy settings based on the network in
+ use, for example WLAN vs cellular networks on a mobile phone.
+
+ In the case of "user choice" or "service network" configurations,
+ you should first start the QNetworkSession and obtain the active
+ configuration from its properties.
+
+ \sa networkConfiguration
+*/
+void QNetworkProxyQuery::setNetworkConfiguration(const QNetworkConfiguration &networkConfiguration)
+{
+ d->config = networkConfiguration;
+}
+#endif
+
/*!
\class QNetworkProxyFactory
\brief The QNetworkProxyFactory class provides fine-grained proxy selection.
diff --git a/src/network/kernel/qnetworkproxy.h b/src/network/kernel/qnetworkproxy.h
index 26562d5..e16b29e 100644
--- a/src/network/kernel/qnetworkproxy.h
+++ b/src/network/kernel/qnetworkproxy.h
@@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Network)
class QUrl;
+class QNetworkConfiguration;
class QNetworkProxyQueryPrivate;
class Q_NETWORK_EXPORT QNetworkProxyQuery
@@ -73,6 +74,16 @@ public:
QNetworkProxyQuery(quint16 bindPort, const QString &protocolTag = QString(),
QueryType queryType = TcpServer);
QNetworkProxyQuery(const QNetworkProxyQuery &other);
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration,
+ const QUrl &requestUrl, QueryType queryType = UrlRequest);
+ QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration,
+ const QString &hostname, int port, const QString &protocolTag = QString(),
+ QueryType queryType = TcpSocket);
+ QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration,
+ quint16 bindPort, const QString &protocolTag = QString(),
+ QueryType queryType = TcpServer);
+#endif
~QNetworkProxyQuery();
QNetworkProxyQuery &operator=(const QNetworkProxyQuery &other);
bool operator==(const QNetworkProxyQuery &other) const;
@@ -97,6 +108,11 @@ public:
QUrl url() const;
void setUrl(const QUrl &url);
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkConfiguration networkConfiguration() const;
+ void setNetworkConfiguration(const QNetworkConfiguration &networkConfiguration);
+#endif
+
private:
QSharedDataPointer<QNetworkProxyQueryPrivate> d;
};
diff --git a/src/network/kernel/qnetworkproxy_symbian.cpp b/src/network/kernel/qnetworkproxy_symbian.cpp
index 79dfb27..1fb31b5 100644
--- a/src/network/kernel/qnetworkproxy_symbian.cpp
+++ b/src/network/kernel/qnetworkproxy_symbian.cpp
@@ -58,6 +58,7 @@
#include <commsdattypeinfov1_1.h> // CCDIAPRecord, CCDProxiesRecord
#include <commsdattypesv1_1.h> // KCDTIdIAPRecord, KCDTIdProxiesRecord
#include <QtNetwork/QNetworkConfigurationManager>
+#include <QtNetwork/QNetworkConfiguration>
#include <QFlags>
using namespace CommsDat;
@@ -67,82 +68,96 @@ QT_BEGIN_NAMESPACE
class SymbianIapId
{
public:
- enum State{
- NotValid,
- Valid
- };
- Q_DECLARE_FLAGS(States, State)
- SymbianIapId() {}
+ SymbianIapId() : valid(false), id(0) {}
~SymbianIapId() {}
- void setIapId(TUint32 iapId) { iapState |= Valid; id = iapId; }
- bool isValid() { return iapState == Valid; }
+ void setIapId(TUint32 iapId) { valid = true; id = iapId; }
+ bool isValid() { return valid; }
TUint32 iapId() { return id; }
private:
- QFlags<States> iapState;
+ bool valid;
TUint32 id;
};
-Q_DECLARE_OPERATORS_FOR_FLAGS(SymbianIapId::States)
-
class SymbianProxyQuery
{
public:
static QNetworkConfiguration findCurrentConfiguration(QNetworkConfigurationManager& configurationManager);
- static SymbianIapId getIapId(QNetworkConfigurationManager& configurationManager);
+ static QNetworkConfiguration findCurrentConfigurationFromServiceNetwork(const QNetworkConfiguration& serviceNetwork);
+ static SymbianIapId getIapId(QNetworkConfigurationManager &configurationManager, const QNetworkProxyQuery &query);
static CCDIAPRecord *getIapRecordLC(TUint32 aIAPId, CMDBSession &aDb);
static CMDBRecordSet<CCDProxiesRecord> *prepareQueryLC(TUint32 serviceId, TDesC& serviceType);
static QList<QNetworkProxy> proxyQueryL(TUint32 aIAPId, const QNetworkProxyQuery &query);
};
+QNetworkConfiguration SymbianProxyQuery::findCurrentConfigurationFromServiceNetwork(const QNetworkConfiguration& serviceNetwork)
+{
+ // Note: This code assumes that the only unambigious way to
+ // find current proxy config is if there is only one access point
+ // or if the found access point is immediately usable.
+ QList<QNetworkConfiguration> childConfigurations = serviceNetwork.children();
+ if (childConfigurations.isEmpty()) {
+ qWarning("QNetworkProxyFactory::systemProxyForQuery called with empty service network");
+ return QNetworkConfiguration();
+ } else if (childConfigurations.count() == 1) {
+ //if only one IAP in the service network, it's always going to be used.
+ return childConfigurations.at(0);
+ } else {
+ //use highest priority active config, if available
+ for (int index = 0; index < childConfigurations.count(); index++) {
+ QNetworkConfiguration childConfig = childConfigurations.at(index);
+ if (childConfig.isValid() && childConfig.state() == QNetworkConfiguration::Active)
+ return childConfig;
+ }
+ //otherwise use highest priority discovered config (that's the one which will be activated if start were called now)
+ for (int index = 0; index < childConfigurations.count(); index++) {
+ QNetworkConfiguration childConfig = childConfigurations.at(index);
+ if (childConfig.isValid() && childConfig.state() == QNetworkConfiguration::Discovered)
+ return childConfig;
+ }
+ //otherwise the highest priority defined (most likely to be activated if all were available when start is called)
+ qWarning("QNetworkProxyFactory::systemProxyForQuery called with service network, but none of its IAPs are available");
+ return childConfigurations.at(0);
+ }
+}
+
QNetworkConfiguration SymbianProxyQuery::findCurrentConfiguration(QNetworkConfigurationManager& configurationManager)
{
QList<QNetworkConfiguration> activeConfigurations = configurationManager.allConfigurations(
QNetworkConfiguration::Active);
- QNetworkConfiguration currentConfig;
if (activeConfigurations.count() > 0) {
- currentConfig = activeConfigurations.at(0);
+ return activeConfigurations.at(0);
} else {
// No active configurations, try default one
QNetworkConfiguration defaultConfiguration = configurationManager.defaultConfiguration();
if (defaultConfiguration.isValid()) {
switch (defaultConfiguration.type()) {
case QNetworkConfiguration::InternetAccessPoint:
- currentConfig = defaultConfiguration;
- break;
+ return defaultConfiguration;
case QNetworkConfiguration::ServiceNetwork:
- {
- // Note: This code assumes that the only unambigious way to
- // find current proxy config is if there is only one access point
- // or if the found access point is immediately usable.
- QList<QNetworkConfiguration> childConfigurations = defaultConfiguration.children();
- if (childConfigurations.count() == 1) {
- currentConfig = childConfigurations.at(0);
- } else {
- for (int index = 0; index < childConfigurations.count(); index++) {
- QNetworkConfiguration childConfig = childConfigurations.at(index);
- if (childConfig.isValid() && childConfig.state() == QNetworkConfiguration::Discovered) {
- currentConfig = childConfig;
- break;
- }
- }
- }
- }
- break;
+ return findCurrentConfigurationFromServiceNetwork(defaultConfiguration);
case QNetworkConfiguration::UserChoice:
- // User choice is not a valid configuration for proxy discovery
+ qWarning("QNetworkProxyFactory::systemProxyForQuery called with user choice configuration, which is not valid");
break;
}
}
}
- return currentConfig;
+ return QNetworkConfiguration();
}
-SymbianIapId SymbianProxyQuery::getIapId(QNetworkConfigurationManager& configurationManager)
+SymbianIapId SymbianProxyQuery::getIapId(QNetworkConfigurationManager& configurationManager, const QNetworkProxyQuery &query)
{
SymbianIapId iapId;
- QNetworkConfiguration currentConfig = findCurrentConfiguration(configurationManager);
- if (currentConfig.isValid()) {
+ QNetworkConfiguration currentConfig = query.networkConfiguration();
+ if (!currentConfig.isValid()) {
+ //If config is not specified, then try to find out an active or default one
+ currentConfig = findCurrentConfiguration(configurationManager);
+ }
+ if (currentConfig.isValid() && currentConfig.type() == QNetworkConfiguration::ServiceNetwork) {
+ //convert service network to the real IAP.
+ currentConfig = findCurrentConfigurationFromServiceNetwork(currentConfig);
+ }
+ if (currentConfig.isValid() && currentConfig.type() == QNetworkConfiguration::InternetAccessPoint) {
// Note: the following code assumes that the identifier is in format
// I_xxxx where xxxx is the identifier of IAP. This is meant as a
// temporary solution until there is a support for returning
@@ -231,7 +246,12 @@ QList<QNetworkProxy> SymbianProxyQuery::proxyQueryL(TUint32 aIAPId, const QNetwo
CleanupStack::Pop(); // serverName
TUint32 port = proxyRecord->iPortNumber;
- QNetworkProxy proxy(QNetworkProxy::HttpProxy, serverNameQt, port);
+ //Symbian config doesn't include proxy type, assume http unless the port matches assigned port of another type
+ //Mobile operators use a wide variety of port numbers for http proxies.
+ QNetworkProxy::ProxyType proxyType = QNetworkProxy::HttpProxy;
+ if (port == 1080) //IANA assigned port for SOCKS
+ proxyType = QNetworkProxy::Socks5Proxy;
+ QNetworkProxy proxy(proxyType, serverNameQt, port);
foundProxies.append(proxy);
}
}
@@ -249,7 +269,7 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
SymbianIapId iapId;
TInt error;
QNetworkConfigurationManager manager;
- iapId = SymbianProxyQuery::getIapId(manager);
+ iapId = SymbianProxyQuery::getIapId(manager, query);
if (iapId.isValid()) {
TRAP(error, proxies = SymbianProxyQuery::proxyQueryL(iapId.iapId(), query))
if (error != KErrNone) {
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 7af71cc..e5af5c6 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -547,15 +547,19 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc
resetSocketLayer();
socketEngine = QAbstractSocketEngine::createSocketEngine(q->socketType(), proxyInUse, q);
-#ifndef QT_NO_BEARERMANAGEMENT
- //copy network session down to the socket engine (if it has been set)
- socketEngine->setProperty("_q_networksession", q->property("_q_networksession"));
-#endif
if (!socketEngine) {
socketError = QAbstractSocket::UnsupportedSocketOperationError;
q->setErrorString(QAbstractSocket::tr("Operation on socket is not supported"));
return false;
}
+#ifndef QT_NO_BEARERMANAGEMENT
+ //copy network session down to the socket engine (if it has been set)
+ socketEngine->setProperty("_q_networksession", q->property("_q_networksession"));
+#endif
+#ifndef QT_NO_NETWORKPROXY
+ //copy user agent to socket engine (if it has been set)
+ socketEngine->setProperty("_q_user-agent", q->property("_q_user-agent"));
+#endif
if (!socketEngine->initialize(q->socketType(), protocol)) {
#if defined (QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::initSocketLayer(%s, %s) failed (%s)",
@@ -1605,15 +1609,15 @@ bool QAbstractSocket::setSocketDescriptor(int socketDescriptor, SocketState sock
d->resetSocketLayer();
d->socketEngine = QAbstractSocketEngine::createSocketEngine(socketDescriptor, this);
-#ifndef QT_NO_BEARERMANAGEMENT
- //copy network session down to the socket engine (if it has been set)
- d->socketEngine->setProperty("_q_networksession", property("_q_networksession"));
-#endif
if (!d->socketEngine) {
d->socketError = UnsupportedSocketOperationError;
setErrorString(tr("Operation on socket is not supported"));
return false;
}
+#ifndef QT_NO_BEARERMANAGEMENT
+ //copy network session down to the socket engine (if it has been set)
+ d->socketEngine->setProperty("_q_networksession", property("_q_networksession"));
+#endif
bool result = d->socketEngine->initialize(socketDescriptor, socketState);
if (!result) {
d->socketError = d->socketEngine->error();
@@ -1877,7 +1881,7 @@ bool QAbstractSocket::waitForReadyRead(int msecs)
}
Q_ASSERT(d->socketEngine);
- forever {
+ do {
bool readyToRead = false;
bool readyToWrite = false;
if (!d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, true, !d->writeBuffer.isEmpty(),
@@ -1904,7 +1908,7 @@ bool QAbstractSocket::waitForReadyRead(int msecs)
if (state() != ConnectedState)
return false;
- }
+ } while (msecs == -1 || qt_timeout_value(msecs, stopWatch.elapsed()) > 0);
return false;
}
diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp
index 7846056..a8a11a7 100644
--- a/src/network/socket/qhttpsocketengine.cpp
+++ b/src/network/socket/qhttpsocketengine.cpp
@@ -501,7 +501,13 @@ void QHttpSocketEngine::slotSocketConnected()
data += path;
data += " HTTP/1.1\r\n";
data += "Proxy-Connection: keep-alive\r\n"
- "User-Agent: Mozilla/5.0\r\n"
+ "User-Agent: ";
+ QVariant v = property("_q_user-agent");
+ if (v.isValid())
+ data += v.toByteArray();
+ else
+ data += "Mozilla/5.0";
+ data += "\r\n"
"Host: " + peerAddress + "\r\n";
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(d->authenticator);
//qDebug() << "slotSocketConnected: priv=" << priv << (priv ? (int)priv->method : -1);
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp
index c365635..88b5aca 100644
--- a/src/network/socket/qsocks5socketengine.cpp
+++ b/src/network/socket/qsocks5socketengine.cpp
@@ -1540,8 +1540,13 @@ qint64 QSocks5SocketEngine::write(const char *data, qint64 len)
// ### Handle this error.
}
- d->data->controlSocket->write(sealedBuf);
+ qint64 written = d->data->controlSocket->write(sealedBuf);
+ if (written <= 0) {
+ QSOCKS5_Q_DEBUG << "native write returned" << written;
+ return written;
+ }
d->data->controlSocket->waitForBytesWritten(0);
+ //NB: returning len rather than written for the OK case, because the "sealing" may increase the length
return len;
#ifndef QT_NO_UDPSOCKET
} else if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode) {
diff --git a/src/network/socket/qsymbiansocketengine.cpp b/src/network/socket/qsymbiansocketengine.cpp
index f1b2982..b6d12fe 100644
--- a/src/network/socket/qsymbiansocketengine.cpp
+++ b/src/network/socket/qsymbiansocketengine.cpp
@@ -251,7 +251,8 @@ QSymbianSocketEnginePrivate::QSymbianSocketEnginePrivate() :
readNotificationsEnabled(false),
writeNotificationsEnabled(false),
exceptNotificationsEnabled(false),
- asyncSelect(0)
+ asyncSelect(0),
+ hasReceivedBufferedDatagram(false)
{
}
@@ -781,21 +782,34 @@ qint64 QSymbianSocketEngine::pendingDatagramSize() const
Q_D(const QSymbianSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QSymbianSocketEngine::pendingDatagramSize(), false);
Q_CHECK_TYPE(QSymbianSocketEngine::hasPendingDatagrams(), QAbstractSocket::UdpSocket, false);
- int nbytes;
+ //can only buffer one datagram at a time
+ if (d->hasReceivedBufferedDatagram)
+ return d->receivedDataBuffer.size();
+ int nbytes = 0;
TInt err = d->nativeSocket.GetOpt(KSOReadBytesPending,KSOLSocket, nbytes);
if (nbytes > 0) {
//nbytes includes IP header, which is of variable length (IPv4 with or without options, IPv6...)
- QByteArray next(nbytes,0);
- TPtr8 buffer((TUint8*)next.data(), next.size());
+ //therefore read the datagram into a buffer to find its true size
+ d->receivedDataBuffer.resize(nbytes);
+ TPtr8 buffer((TUint8*)d->receivedDataBuffer.data(), nbytes);
+ //nbytes = size including IP header, buffer is a pointer descriptor backed by the receivedDataBuffer
TInetAddr addr;
TRequestStatus status;
- //TODO: rather than peek, should we save this for next call to readDatagram?
- //what if calls don't match though?
- d->nativeSocket.RecvFrom(buffer, addr, KSockReadPeek, status);
+ //RecvFrom copies only the payload (we don't want the header so don't specify the option to retrieve it)
+ d->nativeSocket.RecvFrom(buffer, addr, 0, status);
User::WaitForRequest(status);
- if (status.Int())
+ if (status != KErrNone) {
+ d->receivedDataBuffer.clear();
return 0;
- return buffer.Length();
+ }
+ nbytes = buffer.Length();
+ //nbytes = size of payload, resize the receivedDataBuffer to the final size
+ d->receivedDataBuffer.resize(nbytes);
+ d->hasReceivedBufferedDatagram = true;
+ //now receivedDataBuffer contains one datagram, which has been removed from the socket's internal buffer
+#if defined (QNATIVESOCKETENGINE_DEBUG)
+ qDebug() << "QSymbianSocketEngine::pendingDatagramSize buffering" << nbytes << "bytes";
+#endif
}
return qint64(nbytes);
}
@@ -807,6 +821,19 @@ qint64 QSymbianSocketEngine::readDatagram(char *data, qint64 maxSize,
Q_D(QSymbianSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QSymbianSocketEngine::readDatagram(), -1);
Q_CHECK_TYPE(QSymbianSocketEngine::readDatagram(), QAbstractSocket::UdpSocket, false);
+
+ // if a datagram was buffered in pendingDatagramSize(), return it now
+ if (d->hasReceivedBufferedDatagram) {
+ qint64 size = qMin(maxSize, (qint64)d->receivedDataBuffer.size());
+ memcpy(data, d->receivedDataBuffer.constData(), size);
+ d->receivedDataBuffer.clear();
+ d->hasReceivedBufferedDatagram = false;
+#if defined (QNATIVESOCKETENGINE_DEBUG)
+ qDebug() << "QSymbianSocketEngine::readDatagram returning" << size << "bytes from buffer";
+#endif
+ return size;
+ }
+
TPtr8 buffer((TUint8*)data, (int)maxSize);
TInetAddr addr;
TRequestStatus status;
@@ -985,6 +1012,9 @@ void QSymbianSocketEngine::close()
d->localAddress.clear();
d->peerPort = 0;
d->peerAddress.clear();
+
+ d->hasReceivedBufferedDatagram = false;
+ d->receivedDataBuffer.clear();
}
qint64 QSymbianSocketEngine::write(const char *data, qint64 len)
@@ -1036,6 +1066,18 @@ qint64 QSymbianSocketEngine::read(char *data, qint64 maxSize)
Q_CHECK_VALID_SOCKETLAYER(QSymbianSocketEngine::read(), -1);
Q_CHECK_STATES(QSymbianSocketEngine::read(), QAbstractSocket::ConnectedState, QAbstractSocket::BoundState, -1);
+ // if a datagram was buffered in pendingDatagramSize(), return it now
+ if (d->hasReceivedBufferedDatagram) {
+ qint64 size = qMin(maxSize, (qint64)d->receivedDataBuffer.size());
+ memcpy(data, d->receivedDataBuffer.constData(), size);
+ d->receivedDataBuffer.clear();
+ d->hasReceivedBufferedDatagram = false;
+#if defined (QNATIVESOCKETENGINE_DEBUG)
+ qDebug() << "QSymbianSocketEngine::read returning" << size << "bytes from buffer";
+#endif
+ return size;
+ }
+
TPtr8 buffer((TUint8*)data, (int)maxSize);
TSockXfrLength received = 0;
TRequestStatus status;
@@ -1440,6 +1482,7 @@ void QSymbianSocketEngine::startNotifications()
qDebug() << "QSymbianSocketEngine::startNotifications" << d->readNotificationsEnabled << d->writeNotificationsEnabled << d->exceptNotificationsEnabled;
#endif
if (!d->asyncSelect && (d->readNotificationsEnabled || d->writeNotificationsEnabled || d->exceptNotificationsEnabled)) {
+ Q_CHECK_VALID_SOCKETLAYER(QSymbianSocketEngine::startNotifications(), Q_VOID);
if (d->threadData->eventDispatcher) {
d->asyncSelect = q_check_ptr(new QAsyncSelect(
static_cast<QEventDispatcherSymbian*> (d->threadData->eventDispatcher), d->nativeSocket,
@@ -1456,14 +1499,12 @@ void QSymbianSocketEngine::startNotifications()
bool QSymbianSocketEngine::isReadNotificationEnabled() const
{
Q_D(const QSymbianSocketEngine);
- Q_CHECK_VALID_SOCKETLAYER(QSymbianSocketEngine::isReadNotificationEnabled(), false);
return d->readNotificationsEnabled;
}
void QSymbianSocketEngine::setReadNotificationEnabled(bool enable)
{
Q_D(QSymbianSocketEngine);
- Q_CHECK_VALID_SOCKETLAYER(QSymbianSocketEngine::setReadNotificationEnabled(), Q_VOID);
#ifdef QNATIVESOCKETENGINE_DEBUG
qDebug() << "QSymbianSocketEngine::setReadNotificationEnabled" << enable << "socket" << d->socketDescriptor;
#endif
@@ -1474,14 +1515,12 @@ void QSymbianSocketEngine::setReadNotificationEnabled(bool enable)
bool QSymbianSocketEngine::isWriteNotificationEnabled() const
{
Q_D(const QSymbianSocketEngine);
- Q_CHECK_VALID_SOCKETLAYER(QSymbianSocketEngine::isWriteNotificationEnabled(), false);
return d->writeNotificationsEnabled;
}
void QSymbianSocketEngine::setWriteNotificationEnabled(bool enable)
{
Q_D(QSymbianSocketEngine);
- Q_CHECK_VALID_SOCKETLAYER(QSymbianSocketEngine::setWriteNotificationEnabled(), Q_VOID);
#ifdef QNATIVESOCKETENGINE_DEBUG
qDebug() << "QSymbianSocketEngine::setWriteNotificationEnabled" << enable << "socket" << d->socketDescriptor;
#endif
@@ -1492,7 +1531,6 @@ void QSymbianSocketEngine::setWriteNotificationEnabled(bool enable)
bool QSymbianSocketEngine::isExceptionNotificationEnabled() const
{
Q_D(const QSymbianSocketEngine);
- Q_CHECK_VALID_SOCKETLAYER(QSymbianSocketEngine::isExceptionNotificationEnabled(), false);
return d->exceptNotificationsEnabled;
return false;
}
@@ -1500,7 +1538,6 @@ bool QSymbianSocketEngine::isExceptionNotificationEnabled() const
void QSymbianSocketEngine::setExceptionNotificationEnabled(bool enable)
{
Q_D(QSymbianSocketEngine);
- Q_CHECK_VALID_SOCKETLAYER(QSymbianSocketEngine::setExceptionNotificationEnabled(), Q_VOID);
#ifdef QNATIVESOCKETENGINE_DEBUG
qDebug() << "QSymbianSocketEngine::setExceptionNotificationEnabled" << enable << "socket" << d->socketDescriptor;
#endif
@@ -1660,6 +1697,9 @@ void QAsyncSelect::run()
//when event loop disabled socket events, defer until later
if (maybeDeferSocketEvent())
return;
+#if defined (QNATIVESOCKETENGINE_DEBUG)
+ qDebug() << "QAsyncSelect::run" << m_selectBuf() << m_selectFlags;
+#endif
m_inSocketEvent = true;
m_selectBuf() &= m_selectFlags; //the select ioctl reports everything, so mask to only what we requested
//KSockSelectReadContinuation is for reading datagrams in a mode that doesn't discard when the
diff --git a/src/network/socket/qsymbiansocketengine_p.h b/src/network/socket/qsymbiansocketengine_p.h
index 85ab54a..2e7c155 100644
--- a/src/network/socket/qsymbiansocketengine_p.h
+++ b/src/network/socket/qsymbiansocketengine_p.h
@@ -196,6 +196,8 @@ public:
bool exceptNotificationsEnabled;
QAsyncSelect* asyncSelect;
+ mutable QByteArray receivedDataBuffer;
+ mutable bool hasReceivedBufferedDatagram;
// FIXME this is duplicated from qnativesocketengine_p.h
enum ErrorString {
NonBlockingInitFailedErrorString,
diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp
index 5a60764..026ceb4 100644
--- a/src/network/socket/qtcpserver.cpp
+++ b/src/network/socket/qtcpserver.cpp
@@ -416,6 +416,11 @@ bool QTcpServer::setSocketDescriptor(int socketDescriptor)
if (d->socketEngine)
delete d->socketEngine;
d->socketEngine = QAbstractSocketEngine::createSocketEngine(socketDescriptor, this);
+ if (!d->socketEngine) {
+ d->serverSocketError = QAbstractSocket::UnsupportedSocketOperationError;
+ d->serverSocketErrorString = tr("Operation on socket is not supported");
+ return false;
+ }
#ifndef QT_NO_BEARERMANAGEMENT
//copy network session down to the socket engine (if it has been set)
d->socketEngine->setProperty("_q_networksession", property("_q_networksession"));
diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp
index 70d7dd8..ab4d7f1 100644
--- a/src/network/ssl/qsslconfiguration.cpp
+++ b/src/network/ssl/qsslconfiguration.cpp
@@ -233,7 +233,7 @@ void QSslConfiguration::setProtocol(QSsl::SslProtocol protocol)
client), and whether it should require that this certificate is valid.
The default mode is AutoVerifyPeer, which tells QSslSocket to use
- VerifyPeer for clients, QueryPeer for clients.
+ VerifyPeer for clients, QueryPeer for servers.
\sa setPeerVerifyMode()
*/
@@ -249,7 +249,7 @@ QSslSocket::PeerVerifyMode QSslConfiguration::peerVerifyMode() const
client), and whether it should require that this certificate is valid.
The default mode is AutoVerifyPeer, which tells QSslSocket to use
- VerifyPeer for clients, QueryPeer for clients.
+ VerifyPeer for clients, QueryPeer for servers.
\sa peerVerifyMode()
*/
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 0dbf4b5..2695df1 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -1736,6 +1736,8 @@ void QSslSocket::connectToHostImplementation(const QString &hostName, quint16 po
}
#ifndef QT_NO_NETWORKPROXY
d->plainSocket->setProxy(proxy());
+ //copy user agent down to the plain socket (if it has been set)
+ d->plainSocket->setProperty("_q_user-agent", property("_q_user-agent"));
#endif
QIODevice::open(openMode);
d->plainSocket->connectToHost(hostName, port, openMode);
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
index 8068aa8..207ab3d 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
@@ -495,6 +495,8 @@ GLuint QGLEngineShaderManager::getUniformLocation(Uniform id)
"fmp",
"fmp2_m_radius2",
"inverse_2_fmp2_m_radius2",
+ "sqrfr",
+ "bradius",
"invertedTextureSize",
"brushTransform",
"brushTexture",
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
index 7cc9dc3..bf2fe42 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
@@ -442,6 +442,8 @@ public:
Fmp,
Fmp2MRadius2,
Inverse2Fmp2MRadius2,
+ SqrFr,
+ BRadius,
InvertedTextureSize,
BrushTransform,
BrushTexture,
diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
index fc8b9ef..9362c58 100644
--- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
@@ -241,6 +241,7 @@ static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\n\
uniform mediump vec2 halfViewportSize; \n\
uniform highp mat3 brushTransform; \n\
uniform highp vec2 fmp; \n\
+ uniform highp vec3 bradius; \n\
varying highp float b; \n\
varying highp vec2 A; \n\
void setPosition(void) \n\
@@ -253,7 +254,7 @@ static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\n\
mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\
gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\
A = hTexCoords.xy * invertedHTexCoordsZ; \n\
- b = 2.0 * dot(A, fmp); \n\
+ b = bradius.x + 2.0 * dot(A, fmp); \n\
}\n";
static const char* const qglslAffinePositionWithRadialGradientBrushVertexShader
@@ -263,13 +264,22 @@ static const char* const qglslRadialGradientBrushSrcFragmentShader = "\n\
uniform sampler2D brushTexture; \n\
uniform highp float fmp2_m_radius2; \n\
uniform highp float inverse_2_fmp2_m_radius2; \n\
+ uniform highp float sqrfr; \n\
varying highp float b; \n\
varying highp vec2 A; \n\
+ uniform highp vec3 bradius; \n\
lowp vec4 srcPixel() \n\
{ \n\
- highp float c = -dot(A, A); \n\
- highp vec2 val = vec2((-b + sqrt(b*b - 4.0*fmp2_m_radius2*c)) * inverse_2_fmp2_m_radius2, 0.5); \n\
- return texture2D(brushTexture, val); \n\
+ highp float c = sqrfr-dot(A, A); \n\
+ highp float det = b*b - 4.0*fmp2_m_radius2*c; \n\
+ lowp vec4 result = vec4(0.0); \n\
+ if (det >= 0.0) { \n\
+ highp float detSqrt = sqrt(det); \n\
+ highp float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2); \n\
+ if (bradius.y + w * bradius.z >= 0.0) \n\
+ result = texture2D(brushTexture, vec2(w, 0.5)); \n\
+ } \n\
+ return result; \n\
}\n";
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 18c684f..38bd58d 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -301,7 +301,7 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms()
const QRadialGradient *g = static_cast<const QRadialGradient *>(currentBrush.gradient());
QPointF realCenter = g->center();
QPointF realFocal = g->focalPoint();
- qreal realRadius = g->radius();
+ qreal realRadius = g->centerRadius() - g->focalRadius();
translationPoint = realFocal;
QPointF fmp = realCenter - realFocal;
@@ -311,6 +311,12 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms()
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Fmp2MRadius2), fmp2_m_radius2);
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Inverse2Fmp2MRadius2),
GLfloat(1.0 / (2.0*fmp2_m_radius2)));
+ shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::SqrFr),
+ GLfloat(g->focalRadius() * g->focalRadius()));
+ shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::BRadius),
+ GLfloat(2 * (g->centerRadius() - g->focalRadius()) * g->focalRadius()),
+ g->focalRadius(),
+ g->centerRadius() - g->focalRadius());
QVector2D halfViewportSize(width*0.5, height*0.5);
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize);
@@ -1548,6 +1554,14 @@ namespace {
}
+#if defined(Q_WS_WIN)
+static bool fontSmoothingApproximately(qreal target)
+{
+ extern Q_GUI_EXPORT qreal qt_fontsmoothing_gamma; // qapplication_win.cpp
+ return (qAbs(qt_fontsmoothing_gamma - target) < 0.2);
+}
+#endif
+
// #define QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO
void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType,
@@ -1786,7 +1800,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
shaderManager->setMaskType(QGLEngineShaderManager::PixelMask);
prepareForDraw(false); // Text always causes src pixels to be transparent
}
- //### TODO: Gamma correction
QGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate)?QGLTextureGlyphCache::Linear:QGLTextureGlyphCache::Nearest;
if (lastMaskTextureUsed != cache->texture() || cache->filterMode() != filterMode) {
@@ -1809,12 +1822,31 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
}
}
+ bool srgbFrameBufferEnabled = false;
+ if (ctx->d_ptr->extension_flags & QGLExtensions::SRGBFrameBuffer) {
+#if defined(Q_WS_MAC)
+ if (glyphType == QFontEngineGlyphCache::Raster_RGBMask)
+#elif defined(Q_WS_WIN)
+ if (glyphType != QFontEngineGlyphCache::Raster_RGBMask || fontSmoothingApproximately(2.1))
+#else
+ if (false)
+#endif
+ {
+ glEnable(FRAMEBUFFER_SRGB_EXT);
+ srgbFrameBufferEnabled = true;
+ }
+ }
+
#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)
glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#else
glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data());
#endif
+
+ if (srgbFrameBufferEnabled)
+ glDisable(FRAMEBUFFER_SRGB_EXT);
+
}
void QGL2PaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
@@ -1986,7 +2018,8 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
#if !defined(QT_OPENGL_ES_2)
#if defined(Q_WS_WIN)
- if (qt_cleartype_enabled)
+ if (qt_cleartype_enabled
+ && (fontSmoothingApproximately(1.0) || fontSmoothingApproximately(2.1)))
#endif
#if defined(Q_WS_MAC)
if (qt_applefontsmoothing_enabled)
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 057fb55..099cc00 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -5490,6 +5490,13 @@ QGLExtensions::Extensions QGLExtensions::currentContextExtensions()
if (extensions.match("GL_EXT_bgra"))
glExtensions |= BGRATextureFormat;
+ {
+ GLboolean srgbCapableFramebuffers;
+ glGetBooleanv(FRAMEBUFFER_SRGB_CAPABLE_EXT, &srgbCapableFramebuffers);
+ if (srgbCapableFramebuffers)
+ glExtensions |= SRGBFrameBuffer;
+ }
+
return glExtensions;
}
diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h
index c57995d..ab88d9c 100644
--- a/src/opengl/qgl.h
+++ b/src/opengl/qgl.h
@@ -401,7 +401,7 @@ protected:
#if defined(Q_WS_WIN)
virtual int choosePixelFormat(void* pfd, HDC pdc);
#endif
-#if defined(Q_WS_X11) && defined(QT_NO_EGL)
+#if defined(Q_WS_X11)
virtual void* tryVisual(const QGLFormat& f, int bufDepth = 1);
virtual void* chooseVisual();
#endif
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 50d13c9..ac54e2f 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -288,7 +288,8 @@ public:
PVRTCTextureCompression = 0x00020000,
FragmentShader = 0x00040000,
ElementIndexUint = 0x00080000,
- Depth24 = 0x00100000
+ Depth24 = 0x00100000,
+ SRGBFrameBuffer = 0x00200000
};
Q_DECLARE_FLAGS(Extensions, Extension)
diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp
index 1b41db4..ab37977 100644
--- a/src/opengl/qgl_symbian.cpp
+++ b/src/opengl/qgl_symbian.cpp
@@ -49,6 +49,9 @@
#include <private/qpaintengine_opengl_p.h>
#include <private/qwidget_p.h> // to access QWExtra
#include <private/qnativeimagehandleprovider_p.h>
+#include <private/qapplication_p.h>
+#include <private/qgraphicssystem_p.h>
+#include <private/qgraphicssystemex_symbian_p.h>
#include "qgl_egl_p.h"
#include "qpixmapdata_gl_p.h"
#include "qgltexturepool_p.h"
@@ -180,6 +183,15 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) // almost same as
d->ownsEglContext = true;
d->eglContext->setApi(QEgl::OpenGL);
+ QGraphicsSystemEx *ex = QApplicationPrivate::graphicsSystem()->platformExtension();
+ QSymbianGraphicsSystemEx *symex = static_cast<QSymbianGraphicsSystemEx*>(ex);
+ if (symex && !symex->hasBCM2727()) {
+ // Most likely we have hw support for multisampling
+ // so let's enable it.
+ d->glFormat.setSampleBuffers(1);
+ d->glFormat.setSamples(4);
+ }
+
// If the device is a widget with WA_TranslucentBackground set, make sure the glFormat
// has the alpha channel option set:
if (devType == QInternal::Widget) {
@@ -229,20 +241,20 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) // almost same as
d->eglSurface = QEgl::createSurface(device(), d->eglContext->config());
- eglGetError(); // Clear error state first.
+ eglGetError(); // Clear error state first.
#ifdef QGL_NO_PRESERVED_SWAP
- eglSurfaceAttrib(QEgl::display(), d->eglSurface,
- EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED);
+ eglSurfaceAttrib(QEgl::display(), d->eglSurface,
+ EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED);
- if (eglGetError() != EGL_SUCCESS)
- qWarning("QGLContext: could not enable destroyed swap behaviour");
+ if (eglGetError() != EGL_SUCCESS)
+ qWarning("QGLContext: could not enable destroyed swap behaviour");
#else
- eglSurfaceAttrib(QEgl::display(), d->eglSurface,
- EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
+ eglSurfaceAttrib(QEgl::display(), d->eglSurface,
+ EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
- if (eglGetError() != EGL_SUCCESS)
- qWarning("QGLContext: could not enable preserved swap behaviour");
+ if (eglGetError() != EGL_SUCCESS)
+ qWarning("QGLContext: could not enable preserved swap behaviour");
#endif
setWindowCreated(true);
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index 2ddfd35..34ca97d 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -257,6 +257,20 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
return true;
}
+void *QGLContext::chooseVisual()
+{
+ qFatal("QGLContext::chooseVisual - this method must not be called as Qt is built with EGL support");
+ return 0;
+}
+
+void *QGLContext::tryVisual(const QGLFormat& f, int bufDepth)
+{
+ Q_UNUSED(f);
+ Q_UNUSED(bufDepth);
+ qFatal("QGLContext::tryVisual - this method must not be called as Qt is built with EGL support");
+ return 0;
+}
+
void QGLWidget::resizeEvent(QResizeEvent *)
{
Q_D(QGLWidget);
diff --git a/src/opengl/qglextensions_p.h b/src/opengl/qglextensions_p.h
index 529c7a1..ac80ce8 100644
--- a/src/opengl/qglextensions_p.h
+++ b/src/opengl/qglextensions_p.h
@@ -477,6 +477,14 @@ struct QGLExtensionFuncs
// OpenGL constants
+#ifndef FRAMEBUFFER_SRGB_CAPABLE_EXT
+#define FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA
+#endif
+
+#ifndef FRAMEBUFFER_SRGB_EXT
+#define FRAMEBUFFER_SRGB_EXT 0x8DB9
+#endif
+
#ifndef GL_ARRAY_BUFFER
#define GL_ARRAY_BUFFER 0x8892
#endif
diff --git a/src/opengl/qglfunctions.cpp b/src/opengl/qglfunctions.cpp
index be8219a..9137e0f 100644
--- a/src/opengl/qglfunctions.cpp
+++ b/src/opengl/qglfunctions.cpp
@@ -211,19 +211,24 @@ QGLFunctions::QGLFunctions(const QGLContext *context)
static int qt_gl_resolve_features()
{
#if defined(QT_OPENGL_ES_2)
- return QGLFunctions::Multitexture |
- QGLFunctions::Shaders |
- QGLFunctions::Buffers |
- QGLFunctions::Framebuffers |
- QGLFunctions::BlendColor |
- QGLFunctions::BlendEquation |
- QGLFunctions::BlendEquationSeparate |
- QGLFunctions::BlendFuncSeparate |
- QGLFunctions::BlendSubtract |
- QGLFunctions::CompressedTextures |
- QGLFunctions::Multisample |
- QGLFunctions::StencilSeparate |
- QGLFunctions::NPOTTextures;
+ int features = QGLFunctions::Multitexture |
+ QGLFunctions::Shaders |
+ QGLFunctions::Buffers |
+ QGLFunctions::Framebuffers |
+ QGLFunctions::BlendColor |
+ QGLFunctions::BlendEquation |
+ QGLFunctions::BlendEquationSeparate |
+ QGLFunctions::BlendFuncSeparate |
+ QGLFunctions::BlendSubtract |
+ QGLFunctions::CompressedTextures |
+ QGLFunctions::Multisample |
+ QGLFunctions::StencilSeparate;
+ QGLExtensionMatcher extensions;
+ if (extensions.match("GL_OES_texture_npot"))
+ features |= QGLFunctions::NPOTTextures;
+ if (extensions.match("GL_IMG_texture_npot"))
+ features |= QGLFunctions::NPOTTextures;
+ return features;
#elif defined(QT_OPENGL_ES)
int features = QGLFunctions::Multitexture |
QGLFunctions::Buffers |
@@ -240,6 +245,8 @@ static int qt_gl_resolve_features()
features |= QGLFunctions::BlendSubtract;
if (extensions.match("GL_OES_texture_npot"))
features |= QGLFunctions::NPOTTextures;
+ if (extensions.match("GL_IMG_texture_npot"))
+ features |= QGLFunctions::NPOTTextures;
return features;
#else
int features = 0;
diff --git a/src/opengl/qgraphicssystem_gl.cpp b/src/opengl/qgraphicssystem_gl.cpp
index 0aa3c2e..5a01d8c 100644
--- a/src/opengl/qgraphicssystem_gl.cpp
+++ b/src/opengl/qgraphicssystem_gl.cpp
@@ -104,11 +104,17 @@ QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWidget *widget) const
return new QGLWindowSurface(widget);
}
-#ifdef QGL_USE_TEXTURE_POOL
-void QGLGraphicsSystem::releaseCachedResources()
+#ifdef Q_OS_SYMBIAN
+void QGLGraphicsSystem::releaseCachedGpuResources()
{
QGLTexturePool::instance()->hibernate();
}
+
+QGraphicsSystemEx* QGLGraphicsSystem::platformExtension()
+{
+ return this;
+}
#endif
+
QT_END_NAMESPACE
diff --git a/src/opengl/qgraphicssystem_gl_p.h b/src/opengl/qgraphicssystem_gl_p.h
index 5829dcc..5372443 100644
--- a/src/opengl/qgraphicssystem_gl_p.h
+++ b/src/opengl/qgraphicssystem_gl_p.h
@@ -55,11 +55,19 @@
#include "private/qgraphicssystem_p.h"
+#ifdef Q_OS_SYMBIAN
+#include "private/qgraphicssystemex_symbian_p.h"
+#endif
+
#include <QMap>
QT_BEGIN_NAMESPACE
class Q_OPENGL_EXPORT QGLGraphicsSystem : public QGraphicsSystem
+#ifdef Q_OS_SYMBIAN
+ , public QSymbianGraphicsSystemEx
+#endif
+
{
public:
QGLGraphicsSystem(bool useX11GL);
@@ -67,8 +75,9 @@ public:
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QWindowSurface *createWindowSurface(QWidget *widget) const;
-#ifdef QGL_USE_TEXTURE_POOL
- void releaseCachedResources();
+#ifdef Q_OS_SYMBIAN
+ void releaseCachedGpuResources();
+ QGraphicsSystemEx* platformExtension();
#endif
private:
bool m_useX11GL;
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index 9da811a..58ce6f8 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -2119,6 +2119,7 @@ void QOpenGLPaintEnginePrivate::fillPath(const QPainterPath &path)
updateGLMatrix();
}
+Q_GUI_EXPORT bool qt_isExtendedRadialGradient(const QBrush &brush);
static inline bool needsEmulation(Qt::BrushStyle style)
{
@@ -2129,9 +2130,11 @@ static inline bool needsEmulation(Qt::BrushStyle style)
void QOpenGLPaintEnginePrivate::updateUseEmulation()
{
- use_emulation = !use_fragment_programs
- && ((has_pen && needsEmulation(pen_brush_style))
- || (has_brush && needsEmulation(brush_style)));
+ use_emulation = (!use_fragment_programs
+ && ((has_pen && needsEmulation(pen_brush_style))
+ || (has_brush && needsEmulation(brush_style))))
+ || (has_pen && qt_isExtendedRadialGradient(cpen.brush()))
+ || (has_brush && qt_isExtendedRadialGradient(cbrush));
}
void QOpenGLPaintEngine::updatePen(const QPen &pen)
@@ -5447,50 +5450,7 @@ void QOpenGLPaintEngine::transformChanged()
updateMatrix(state()->matrix);
}
-static QPainterPath painterPathFromVectorPath(const QVectorPath &path)
-{
- const qreal *points = path.points();
- const QPainterPath::ElementType *types = path.elements();
-
- QPainterPath p;
- if (types) {
- int id = 0;
- for (int i=0; i<path.elementCount(); ++i) {
- switch(types[i]) {
- case QPainterPath::MoveToElement:
- p.moveTo(QPointF(points[id], points[id+1]));
- id+=2;
- break;
- case QPainterPath::LineToElement:
- p.lineTo(QPointF(points[id], points[id+1]));
- id+=2;
- break;
- case QPainterPath::CurveToElement: {
- QPointF p1(points[id], points[id+1]);
- QPointF p2(points[id+2], points[id+3]);
- QPointF p3(points[id+4], points[id+5]);
- p.cubicTo(p1, p2, p3);
- id+=6;
- break;
- }
- case QPainterPath::CurveToDataElement:
- ;
- break;
- }
- }
- } else {
- p.moveTo(QPointF(points[0], points[1]));
- int id = 2;
- for (int i=1; i<path.elementCount(); ++i) {
- p.lineTo(QPointF(points[id], points[id+1]));
- id+=2;
- }
- }
- if (path.hints() & QVectorPath::WindingFill)
- p.setFillRule(Qt::WindingFill);
-
- return p;
-}
+Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath(const QVectorPath &path);
void QOpenGLPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
{
@@ -5499,11 +5459,11 @@ void QOpenGLPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
if (brush.style() == Qt::NoBrush)
return;
- if (!d->use_fragment_programs && needsEmulation(brush.style())) {
+ if ((!d->use_fragment_programs && needsEmulation(brush.style())) || qt_isExtendedRadialGradient(brush)) {
QPainter *p = painter();
QBrush oldBrush = p->brush();
p->setBrush(brush);
- qt_draw_helper(p->d_ptr.data(), painterPathFromVectorPath(path), QPainterPrivate::FillDraw);
+ qt_draw_helper(p->d_ptr.data(), qt_painterPathFromVectorPath(path), QPainterPrivate::FillDraw);
p->setBrush(oldBrush);
return;
}
@@ -5520,7 +5480,7 @@ void QOpenGLPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
drawRects(&r, 1);
updatePen(old_pen);
} else {
- d->fillPath(painterPathFromVectorPath(path));
+ d->fillPath(qt_painterPathFromVectorPath(path));
}
updateBrush(old_brush, state()->brushOrigin);
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 56e2c3b..49b3dc2 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -184,7 +184,9 @@ QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL)
class QGLGlobalShareWidget
{
public:
- QGLGlobalShareWidget() : firstPixmap(0), widgetRefCount(0), widget(0), initializing(false) {}
+ QGLGlobalShareWidget() : firstPixmap(0), widgetRefCount(0), widget(0), initializing(false) {
+ created = true;
+ }
QGLWidget *shareWidget() {
if (!initializing && !widget && !cleanedUp) {
@@ -223,6 +225,7 @@ public:
}
static bool cleanedUp;
+ static bool created;
QGLPixmapData *firstPixmap;
int widgetRefCount;
@@ -233,6 +236,7 @@ private:
};
bool QGLGlobalShareWidget::cleanedUp = false;
+bool QGLGlobalShareWidget::created = false;
static void qt_cleanup_gl_share_widget();
Q_GLOBAL_STATIC_WITH_INITIALIZER(QGLGlobalShareWidget, _qt_gl_share_widget,
@@ -242,7 +246,8 @@ Q_GLOBAL_STATIC_WITH_INITIALIZER(QGLGlobalShareWidget, _qt_gl_share_widget,
static void qt_cleanup_gl_share_widget()
{
- _qt_gl_share_widget()->cleanup();
+ if (QGLGlobalShareWidget::created)
+ _qt_gl_share_widget()->cleanup();
}
QGLWidget* qt_gl_share_widget()
@@ -254,7 +259,8 @@ QGLWidget* qt_gl_share_widget()
void qt_destroy_gl_share_widget()
{
- _qt_gl_share_widget()->destroy();
+ if (QGLGlobalShareWidget::created)
+ _qt_gl_share_widget()->destroy();
}
const QGLContext *qt_gl_share_context()
@@ -610,6 +616,17 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
if (!d_ptr->destructive_swap_buffers && !d_ptr->did_paint)
return;
+#ifdef Q_OS_SYMBIAN
+ if (window() != widget) {
+ // For performance reasons we don't support
+ // flushing native child widgets on Symbian.
+ // It breaks overlapping native child widget
+ // rendering in some cases but we prefer performance.
+ return;
+ }
+#endif
+
+
QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget();
Q_ASSERT(parent);
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 588c35a..70e26fb 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -173,6 +173,9 @@ public:
bool forcePenChange; // Force a pen change, even if the same.
bool forceBrushChange; // Force a brush change, even if the same.
+ bool hasExtendedRadialGradientPen; // Current pen's brush is extended radial gradient.
+ bool hasExtendedRadialGradientBrush; // Current brush is extended radial gradient.
+
VGPaintType penType; // Type of the last pen that was set.
VGPaintType brushType; // Type of the last brush that was set.
@@ -275,6 +278,27 @@ public:
}
}
+ inline bool needsEmulation(const QBrush &brush) const
+ {
+ Q_GUI_EXPORT bool qt_isExtendedRadialGradient(const QBrush &brush);
+ return qt_isExtendedRadialGradient(brush);
+ }
+
+ inline bool needsEmulation() const
+ {
+ return hasExtendedRadialGradientPen || hasExtendedRadialGradientBrush;
+ }
+
+ inline bool needsPenEmulation() const
+ {
+ return hasExtendedRadialGradientPen;
+ }
+
+ inline bool needsBrushEmulation() const
+ {
+ return hasExtendedRadialGradientBrush;
+ }
+
// Set various modes, but only if different.
inline void setImageMode(VGImageMode mode);
inline void setRenderingQuality(VGRenderingQuality mode);
@@ -355,6 +379,10 @@ void QVGPaintEnginePrivate::init()
forcePenChange = true;
forceBrushChange = true;
+
+ hasExtendedRadialGradientPen = false;
+ hasExtendedRadialGradientBrush = false;
+
penType = (VGPaintType)0;
brushType = (VGPaintType)0;
@@ -1530,12 +1558,18 @@ bool QVGPaintEngine::begin(QPaintDevice *pdev)
bool QVGPaintEngine::end()
{
+ vgSeti(VG_SCISSORING, VG_FALSE);
+ vgSeti(VG_MASKING, VG_FALSE);
return true;
}
void QVGPaintEngine::draw(const QVectorPath &path)
{
Q_D(QVGPaintEngine);
+ if (d->needsEmulation()) {
+ QPaintEngineEx::draw(path);
+ return;
+ }
QVGPainterState *s = state();
VGPath vgpath = d->vectorPathToVGPath(path);
if (!path.hasWindingFill())
@@ -1545,9 +1579,19 @@ void QVGPaintEngine::draw(const QVectorPath &path)
vgDestroyPath(vgpath);
}
+Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath(const QVectorPath &path);
+
void QVGPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
{
Q_D(QVGPaintEngine);
+ if (d->needsEmulation(brush)) {
+ QPainter *p = painter();
+ QBrush oldBrush = p->brush();
+ p->setBrush(brush);
+ qt_draw_helper(p->d_ptr.data(), qt_painterPathFromVectorPath(path), QPainterPrivate::FillDraw);
+ p->setBrush(oldBrush);
+ return;
+ }
VGPath vgpath = d->vectorPathToVGPath(path);
if (!path.hasWindingFill())
d->fill(vgpath, brush, VG_EVEN_ODD);
@@ -1559,6 +1603,10 @@ void QVGPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
void QVGPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
{
Q_D(QVGPaintEngine);
+ if (d->needsEmulation(pen.brush())) {
+ QPaintEngineEx::stroke(path, pen);
+ return;
+ }
VGPath vgpath = d->vectorPathToVGPath(path);
d->stroke(vgpath, pen);
vgDestroyPath(vgpath);
@@ -2362,12 +2410,17 @@ void QVGPaintEngine::penChanged()
{
Q_D(QVGPaintEngine);
d->dirty |= QPaintEngine::DirtyPen;
+
+ d->hasExtendedRadialGradientPen =
+ state()->pen.style() != Qt::NoPen && d->needsEmulation(state()->pen.brush());
}
void QVGPaintEngine::brushChanged()
{
Q_D(QVGPaintEngine);
d->dirty |= QPaintEngine::DirtyBrush;
+
+ d->hasExtendedRadialGradientPen = d->needsEmulation(state()->brush);
}
void QVGPaintEngine::brushOriginChanged()
@@ -2546,6 +2599,11 @@ void QVGPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
return;
}
+ if (d->needsEmulation(brush)) {
+ QPaintEngineEx::fillRect(rect, brush);
+ return;
+ }
+
#if !defined(QVG_NO_MODIFY_PATH)
VGfloat coords[8];
if (d->simpleTransform) {
@@ -2623,6 +2681,10 @@ void QVGPaintEngine::fillRect(const QRectF &rect, const QColor &color)
void QVGPaintEngine::drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode)
{
Q_D(QVGPaintEngine);
+ if (d->needsEmulation()) {
+ QPaintEngineEx::drawRoundedRect(rect, xrad, yrad, mode);
+ return;
+ }
if (d->simpleTransform) {
QVGPainterState *s = state();
VGPath vgpath = d->roundedRectPath(rect, xrad, yrad, mode);
@@ -2639,6 +2701,10 @@ void QVGPaintEngine::drawRects(const QRect *rects, int rectCount)
{
#if !defined(QVG_NO_MODIFY_PATH)
Q_D(QVGPaintEngine);
+ if (d->needsEmulation()) {
+ QPaintEngineEx::drawRects(rects, rectCount);
+ return;
+ }
QVGPainterState *s = state();
for (int i = 0; i < rectCount; ++i, ++rects) {
VGfloat coords[8];
@@ -2680,6 +2746,10 @@ void QVGPaintEngine::drawRects(const QRectF *rects, int rectCount)
{
#if !defined(QVG_NO_MODIFY_PATH)
Q_D(QVGPaintEngine);
+ if (d->needsEmulation()) {
+ QPaintEngineEx::drawRects(rects, rectCount);
+ return;
+ }
QVGPainterState *s = state();
for (int i = 0; i < rectCount; ++i, ++rects) {
VGfloat coords[8];
@@ -2718,6 +2788,10 @@ void QVGPaintEngine::drawLines(const QLine *lines, int lineCount)
{
#if !defined(QVG_NO_MODIFY_PATH)
Q_D(QVGPaintEngine);
+ if (d->needsEmulation()) {
+ QPaintEngineEx::drawLines(lines, lineCount);
+ return;
+ }
QVGPainterState *s = state();
for (int i = 0; i < lineCount; ++i, ++lines) {
VGfloat coords[4];
@@ -2746,6 +2820,10 @@ void QVGPaintEngine::drawLines(const QLineF *lines, int lineCount)
{
#if !defined(QVG_NO_MODIFY_PATH)
Q_D(QVGPaintEngine);
+ if (d->needsEmulation()) {
+ QPaintEngineEx::drawLines(lines, lineCount);
+ return;
+ }
QVGPainterState *s = state();
for (int i = 0; i < lineCount; ++i, ++lines) {
VGfloat coords[4];
@@ -2775,6 +2853,10 @@ void QVGPaintEngine::drawEllipse(const QRectF &r)
// Based on the description of vguEllipse() in the OpenVG specification.
// We don't use vguEllipse(), to avoid unnecessary library dependencies.
Q_D(QVGPaintEngine);
+ if (d->needsEmulation()) {
+ QPaintEngineEx::drawEllipse(r);
+ return;
+ }
if (d->simpleTransform) {
QVGPainterState *s = state();
VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
@@ -2825,6 +2907,10 @@ void QVGPaintEngine::drawPath(const QPainterPath &path)
// Shortcut past the QPainterPath -> QVectorPath conversion,
// converting the QPainterPath directly into a VGPath.
Q_D(QVGPaintEngine);
+ if (d->needsEmulation()) {
+ QPaintEngineEx::drawPath(path);
+ return;
+ }
QVGPainterState *s = state();
VGPath vgpath = d->painterPathToVGPath(path);
if (path.fillRule() == Qt::OddEvenFill)
@@ -2839,6 +2925,11 @@ void QVGPaintEngine::drawPoints(const QPointF *points, int pointCount)
#if !defined(QVG_NO_MODIFY_PATH)
Q_D(QVGPaintEngine);
+ if (d->needsPenEmulation()) {
+ QPaintEngineEx::drawPoints(points, pointCount);
+ return;
+ }
+
// Set up a new pen if necessary.
QPen pen = state()->pen;
if (pen.style() == Qt::NoPen)
@@ -2873,6 +2964,11 @@ void QVGPaintEngine::drawPoints(const QPoint *points, int pointCount)
#if !defined(QVG_NO_MODIFY_PATH)
Q_D(QVGPaintEngine);
+ if (d->needsEmulation()) {
+ QPaintEngineEx::drawPoints(points, pointCount);
+ return;
+ }
+
// Set up a new pen if necessary.
QPen pen = state()->pen;
if (pen.style() == Qt::NoPen)
@@ -2905,6 +3001,12 @@ void QVGPaintEngine::drawPoints(const QPoint *points, int pointCount)
void QVGPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
{
Q_D(QVGPaintEngine);
+
+ if (d->needsEmulation()) {
+ QPaintEngineEx::drawPolygon(points, pointCount, mode);
+ return;
+ }
+
QVGPainterState *s = state();
VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
VG_PATH_DATATYPE_F,
@@ -2952,6 +3054,12 @@ void QVGPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonD
void QVGPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
{
Q_D(QVGPaintEngine);
+
+ if (d->needsEmulation()) {
+ QPaintEngineEx::drawPolygon(points, pointCount, mode);
+ return;
+ }
+
QVGPainterState *s = state();
VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
VG_PATH_DATATYPE_F,
@@ -3611,6 +3719,11 @@ void QVGPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
return;
}
+ if (d->needsPenEmulation()) {
+ QPaintEngineEx::drawTextItem(p, textItem);
+ return;
+ }
+
// Get the glyphs and positions associated with the text item.
QVarLengthArray<QFixedPoint> positions;
QVarLengthArray<glyph_t> glyphs;
@@ -3756,6 +3869,8 @@ void QVGPaintEngine::beginNativePainting()
#if !defined(QVG_NO_DRAW_GLYPHS)
d->setTransform(VG_MATRIX_GLYPH_USER_TO_SURFACE, d->pathTransform);
#endif
+ vgSeti(VG_SCISSORING, VG_FALSE);
+ vgSeti(VG_MASKING, VG_FALSE);
d->rawVG = true;
}
@@ -3816,6 +3931,7 @@ void QVGPaintEngine::restoreState(QPaintEngine::DirtyFlags dirty)
if ((dirty & QPaintEngine::DirtyBrushOrigin) != 0)
brushOriginChanged();
d->fillRule = 0;
+ d->clearColor = QColor();
if ((dirty & QPaintEngine::DirtyOpacity) != 0)
opacityChanged();
if ((dirty & QPaintEngine::DirtyTransform) != 0)
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
index ea93748..e52722d 100644
--- a/src/openvg/qpixmapdata_vg.cpp
+++ b/src/openvg/qpixmapdata_vg.cpp
@@ -378,7 +378,7 @@ VGImage QVGPixmapData::toVGImage()
QVGImagePool::instance()->useImage(this);
}
- if (!source.isNull() && recreate) {
+ if (!source.isNull() && (recreate || source.paintingActive())) {
source.beginDataAccess();
vgImageSubData
(vgImage,
diff --git a/src/openvg/qwindowsurface_vg.cpp b/src/openvg/qwindowsurface_vg.cpp
index eedfea5..dcc5d6a 100644
--- a/src/openvg/qwindowsurface_vg.cpp
+++ b/src/openvg/qwindowsurface_vg.cpp
@@ -78,6 +78,17 @@ QPaintDevice *QVGWindowSurface::paintDevice()
void QVGWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
{
Q_UNUSED(offset);
+
+#ifdef Q_OS_SYMBIAN
+ if (window() != widget) {
+ // For performance reasons we don't support
+ // flushing native child widgets on Symbian.
+ // It breaks overlapping native child widget
+ // rendering in some cases but we prefer performance.
+ return;
+ }
+#endif
+
QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget();
d_ptr->endPaint(parent, region);
}
diff --git a/src/plugins/codecs/jp/qsjiscodec.cpp b/src/plugins/codecs/jp/qsjiscodec.cpp
index 49190d3..3ea5300 100644
--- a/src/plugins/codecs/jp/qsjiscodec.cpp
+++ b/src/plugins/codecs/jp/qsjiscodec.cpp
@@ -155,7 +155,9 @@ QString QSjisCodec::convertToUnicode(const char* chars, int len, ConverterState
uchar ch = chars[i];
switch (nbuf) {
case 0:
- if (ch < 0x80 || IsKana(ch)) {
+ if (ch < 0x80) {
+ result += QValidChar(ch);
+ } else if (IsKana(ch)) {
// JIS X 0201 Latin or JIS X 0201 Kana
u = conv->jisx0201ToUnicode(ch);
result += QValidChar(u);
diff --git a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp
index 4b4f677..bf29dd4 100644
--- a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp
+++ b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp
@@ -80,9 +80,15 @@ QWindowSurface *QVGGraphicsSystem::createWindowSurface(QWidget *widget) const
return new QVGWindowSurface(widget);
}
-void QVGGraphicsSystem::releaseCachedResources()
+#ifdef Q_OS_SYMBIAN
+void QVGGraphicsSystem::releaseCachedGpuResources()
{
QVGImagePool::instance()->hibernate();
}
+QGraphicsSystemEx *QVGGraphicsSystem::platformExtension()
+{
+ return this;
+}
+#endif
QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h
index 9c9b3e2..feff451 100644
--- a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h
+++ b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h
@@ -55,9 +55,16 @@
#include <QtGui/private/qgraphicssystem_p.h>
+#ifdef Q_OS_SYMBIAN
+#include <QtGui/private/qgraphicssystemex_symbian_p.h>
+#endif
+
QT_BEGIN_NAMESPACE
class QVGGraphicsSystem : public QGraphicsSystem
+#ifdef Q_OS_SYMBIAN
+ , public QSymbianGraphicsSystemEx
+#endif
{
public:
QVGGraphicsSystem();
@@ -65,7 +72,10 @@ public:
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QWindowSurface *createWindowSurface(QWidget *widget) const;
- void releaseCachedResources();
+#ifdef Q_OS_SYMBIAN
+ void releaseCachedGpuResources();
+ QGraphicsSystemEx* platformExtension();
+#endif
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/uikit/quikiteventloop.mm b/src/plugins/platforms/uikit/quikiteventloop.mm
index 8d2603c..2b9728c 100644
--- a/src/plugins/platforms/uikit/quikiteventloop.mm
+++ b/src/plugins/platforms/uikit/quikiteventloop.mm
@@ -69,13 +69,8 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
Q_UNUSED(launchOptions)
+ Q_UNUSED(application)
foreach (QWidget *widget, qApp->topLevelWidgets()) {
- QRect geom = widget->geometry();
- CGRect bar = application.statusBarFrame;
- if (geom.y() <= bar.size.height) {
- geom.setY(bar.size.height);
- widget->setGeometry(geom);
- }
QUIKitWindow *platformWindow = static_cast<QUIKitWindow *>(widget->platformWindow());
platformWindow->ensureNativeWindow();
}
diff --git a/src/plugins/platforms/uikit/quikitintegration.mm b/src/plugins/platforms/uikit/quikitintegration.mm
index d4b4192..3a432d1 100644
--- a/src/plugins/platforms/uikit/quikitintegration.mm
+++ b/src/plugins/platforms/uikit/quikitintegration.mm
@@ -66,7 +66,7 @@ QUIKitIntegration::~QUIKitIntegration()
QPixmapData *QUIKitIntegration::createPixmapData(QPixmapData::PixelType type) const
{
- return new QRasterPixmapData(type);
+ return new QRasterPixmapData(type);
}
QPlatformWindow *QUIKitIntegration::createPlatformWindow(QWidget *widget, WId winId) const
diff --git a/src/plugins/platforms/uikit/quikitscreen.mm b/src/plugins/platforms/uikit/quikitscreen.mm
index 21494c9..78389f2 100644
--- a/src/plugins/platforms/uikit/quikitscreen.mm
+++ b/src/plugins/platforms/uikit/quikitscreen.mm
@@ -54,7 +54,7 @@ QUIKitScreen::QUIKitScreen(int screenIndex)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
UIScreen *screen = [[UIScreen screens] objectAtIndex:screenIndex];
CGRect bounds = [screen bounds];
- m_geometry = QRect(0, 0, bounds.size.width, bounds.size.height);
+ m_geometry = QRect(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
m_format = QImage::Format_ARGB32;
@@ -62,7 +62,7 @@ QUIKitScreen::QUIKitScreen(int screenIndex)
const qreal inch = 25.4;
qreal dpi = 160.;
- int dragDistance = 14;
+ int dragDistance = 12;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
dpi = 132.;
dragDistance = 10;
diff --git a/src/plugins/platforms/uikit/quikitwindow.h b/src/plugins/platforms/uikit/quikitwindow.h
index 9e73754..5c6496a 100644
--- a/src/plugins/platforms/uikit/quikitwindow.h
+++ b/src/plugins/platforms/uikit/quikitwindow.h
@@ -47,6 +47,8 @@
#import <UIKit/UIKit.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
+#import <OpenGLES/ES2/gl.h>
+#import <OpenGLES/ES2/glext.h>
#import <OpenGLES/EAGL.h>
@interface EAGLView : UIView <UIKeyInput>
@@ -59,6 +61,7 @@
GLuint mFramebuffer, mColorRenderbuffer, mDepthRenderbuffer;
+ id delegate;
// ------- Text Input ----------
UITextAutocapitalizationType autocapitalizationType;
UITextAutocorrectionType autocorrectionType;
@@ -77,6 +80,8 @@
- (void)setWindow:(QPlatformWindow *)window;
- (void)sendMouseEventForTouches:(NSSet *)touches withEvent:(UIEvent *)event fakeButtons:(Qt::MouseButtons)buttons;
+@property (readonly,getter=fbo) GLint fbo;
+@property (nonatomic, assign) id delegate;
// ------- Text Input ----------
@@ -90,6 +95,10 @@
@end
+@protocol EAGLViewDelegate
+- (void)eaglView:(EAGLView *)view usesFramebuffer:(GLuint)buffer;
+@end
+
class EAGLPlatformContext;
QT_BEGIN_NAMESPACE
@@ -103,7 +112,7 @@ public:
~QUIKitWindow();
UIWindow *nativeWindow() const { return mWindow; }
- UIView *nativeView() const { return mView; }
+ EAGLView *nativeView() const { return mView; }
void setGeometry(const QRect &rect);
UIWindow *ensureNativeWindow();
diff --git a/src/plugins/platforms/uikit/quikitwindow.mm b/src/plugins/platforms/uikit/quikitwindow.mm
index 52d1846..1f57baa 100644
--- a/src/plugins/platforms/uikit/quikitwindow.mm
+++ b/src/plugins/platforms/uikit/quikitwindow.mm
@@ -79,7 +79,11 @@ public:
mFormat.setStereo(false);
mFormat.setDirectRendering(false);
+#if defined(QT_OPENGL_ES_2)
+ EAGLContext *aContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
+#else
EAGLContext *aContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
+#endif
[mView setContext:aContext];
}
@@ -116,6 +120,8 @@ private:
@implementation EAGLView
+@synthesize delegate;
+
+ (Class)layerClass
{
return [CAEAGLLayer class];
@@ -156,8 +162,8 @@ private:
{
if (mContext) {
[EAGLContext setCurrentContext:mContext];
- glBindRenderbufferOES(GL_RENDERBUFFER_OES, mColorRenderbuffer);
- [mContext presentRenderbuffer:GL_RENDERBUFFER_OES];
+ glBindRenderbuffer(GL_RENDERBUFFER, mColorRenderbuffer);
+ [mContext presentRenderbuffer:GL_RENDERBUFFER];
}
}
@@ -167,15 +173,15 @@ private:
{
[EAGLContext setCurrentContext:mContext];
if (mFramebuffer) {
- glDeleteFramebuffersOES(1, &mFramebuffer);
+ glDeleteFramebuffers(1, &mFramebuffer);
mFramebuffer = 0;
}
if (mColorRenderbuffer) {
- glDeleteRenderbuffersOES(1, &mColorRenderbuffer);
+ glDeleteRenderbuffers(1, &mColorRenderbuffer);
mColorRenderbuffer = 0;
}
if (mDepthRenderbuffer) {
- glDeleteRenderbuffersOES(1, &mDepthRenderbuffer);
+ glDeleteRenderbuffers(1, &mDepthRenderbuffer);
mDepthRenderbuffer = 0;
}
}
@@ -186,24 +192,27 @@ private:
if (mContext && !mFramebuffer)
{
[EAGLContext setCurrentContext:mContext];
- glGenFramebuffersOES(1, &mFramebuffer);
- glBindFramebufferOES(GL_FRAMEBUFFER_OES, mFramebuffer);
-
- glGenRenderbuffersOES(1, &mColorRenderbuffer);
- glBindRenderbufferOES(GL_RENDERBUFFER_OES, mColorRenderbuffer);
- [mContext renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer *)self.layer];
- glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &mFramebufferWidth);
- glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &mFramebufferHeight);
- glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, mColorRenderbuffer);
-
- glGenRenderbuffersOES(1, &mDepthRenderbuffer);
- glBindRenderbufferOES(GL_RENDERBUFFER_OES, mDepthRenderbuffer);
- glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH24_STENCIL8_OES, mFramebufferWidth, mFramebufferHeight);
- glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, mDepthRenderbuffer);
- glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, mDepthRenderbuffer);
-
- if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES)
- NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
+ glGenFramebuffers(1, &mFramebuffer);
+ glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
+
+ glGenRenderbuffers(1, &mColorRenderbuffer);
+ glBindRenderbuffer(GL_RENDERBUFFER, mColorRenderbuffer);
+ [mContext renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer *)self.layer];
+ glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &mFramebufferWidth);
+ glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &mFramebufferHeight);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, mColorRenderbuffer);
+
+ glGenRenderbuffers(1, &mDepthRenderbuffer);
+ glBindRenderbuffer(GL_RENDERBUFFER, mDepthRenderbuffer);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, mFramebufferWidth, mFramebufferHeight);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepthRenderbuffer);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mDepthRenderbuffer);
+
+ if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
+ NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER));
+ if (delegate && [delegate respondsToSelector:@selector(eaglView:usesFramebuffer:)]) {
+ [delegate eaglView:self usesFramebuffer:mFramebuffer];
+ }
}
}
@@ -214,11 +223,16 @@ private:
[EAGLContext setCurrentContext:mContext];
if (!mFramebuffer)
[self createFramebuffer];
- glBindFramebufferOES(GL_FRAMEBUFFER_OES, mFramebuffer);
+ glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
glViewport(0, 0, mFramebufferWidth, mFramebufferHeight);
}
}
+- (GLint)fbo
+{
+ return mFramebuffer;
+}
+
- (void)setWindow:(QPlatformWindow *)window
{
mWindow = window;
@@ -322,6 +336,7 @@ QUIKitWindow::QUIKitWindow(QWidget *tlw) :
CGRect screenBounds = [mScreen->uiScreen() bounds];
QRect geom(screenBounds.origin.x, screenBounds.origin.y, screenBounds.size.width, screenBounds.size.height);
setGeometry(geom);
+ mView = [[EAGLView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
// TODO ensure the native window if the application is already running
}
@@ -334,7 +349,7 @@ QUIKitWindow::~QUIKitWindow()
void QUIKitWindow::setGeometry(const QRect &rect)
{
- if (mWindow) {
+ if (mWindow && rect != geometry()) {
mWindow.frame = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
mView.frame = CGRectMake(0, 0, rect.width(), rect.height());
[mView deleteFramebuffer];
@@ -347,14 +362,16 @@ UIWindow *QUIKitWindow::ensureNativeWindow()
{
if (!mWindow) {
// window
- QRect geom = geometry();
- CGRect frame = CGRectMake(geom.x(), geom.y(), geom.width(), geom.height());
- mWindow = [[UIWindow alloc] initWithFrame:frame];
+ CGRect frame = [mScreen->uiScreen() applicationFrame];
+ QRect geom = QRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
+ widget()->setGeometry(geom);
+ mWindow = [[UIWindow alloc] init];
mWindow.screen = mScreen->uiScreen();
- mWindow.frame = frame; // for some reason setting the screen resets frame.origin
+ mWindow.frame = frame; // for some reason setting the screen resets frame.origin, so we need to set the frame afterwards
// view
- mView = [[EAGLView alloc] initWithFrame:CGRectMake(0, 0, geom.width(), geom.height())];
+ [mView deleteFramebuffer];
+ mView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height); // fill
[mView setMultipleTouchEnabled:YES];
[mView setWindow:this];
[mWindow addSubview:mView];
diff --git a/src/plugins/platforms/uikit/quikitwindowsurface.mm b/src/plugins/platforms/uikit/quikitwindowsurface.mm
index bb7dcd7..8caa15f 100644
--- a/src/plugins/platforms/uikit/quikitwindowsurface.mm
+++ b/src/plugins/platforms/uikit/quikitwindowsurface.mm
@@ -47,27 +47,64 @@
#include <QtDebug>
+class EAGLPaintDevice;
+
+@interface PaintDeviceHelper : NSObject {
+ EAGLPaintDevice *device;
+}
+
+@property (nonatomic, assign) EAGLPaintDevice *device;
+
+- (void)eaglView:(EAGLView *)view usesFramebuffer:(GLuint)buffer;
+
+@end
+
class EAGLPaintDevice : public QGLPaintDevice
{
public:
EAGLPaintDevice(QPlatformWindow *window)
:QGLPaintDevice(), mWindow(window)
{
+#if defined(QT_OPENGL_ES_2)
+ helper = [[PaintDeviceHelper alloc] init];
+ helper.device = this;
+ EAGLView *view = static_cast<QUIKitWindow *>(window)->nativeView();
+ view.delegate = helper;
+ m_thisFBO = view.fbo;
+#endif
}
+ ~EAGLPaintDevice()
+ {
+#if defined(QT_OPENGL_ES_2)
+ [helper release];
+#endif
+ }
+
+ void setFramebuffer(GLuint buffer) { m_thisFBO = buffer; }
int devType() const { return QInternal::OpenGL; }
QSize size() const { return mWindow->geometry().size(); }
QGLContext* context() const { return QGLContext::fromPlatformGLContext(mWindow->glContext()); }
QPaintEngine *paintEngine() const { return qt_qgl_paint_engine(); }
- void beginPaint(){
- QGLPaintDevice::beginPaint();
- }
private:
QPlatformWindow *mWindow;
+ PaintDeviceHelper *helper;
};
+@implementation PaintDeviceHelper
+@synthesize device;
+
+- (void)eaglView:(EAGLView *)view usesFramebuffer:(GLuint)buffer
+{
+ Q_UNUSED(view)
+ if (device)
+ device->setFramebuffer(buffer);
+}
+
+@end
+
QT_BEGIN_NAMESPACE
QUIKitWindowSurface::QUIKitWindowSurface(QWidget *window)
diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp
index ebe4c7b..7929ccb 100644
--- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp
@@ -178,7 +178,7 @@ void QWaylandGLWindowSurface::resize(const QSize &size)
QWindowSurface::resize(size);
window()->platformWindow()->glContext()->makeCurrent();
delete mPaintDevice;
- mPaintDevice = new QGLFramebufferObject(size);
+ mPaintDevice = new QGLFramebufferObject(size,QGLFramebufferObject::CombinedDepthStencil);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp
index 39e7be5..ddd1763 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp
@@ -49,7 +49,6 @@
QWaylandEglIntegration::QWaylandEglIntegration(struct wl_display *waylandDisplay)
: mWaylandDisplay(waylandDisplay)
- , mNativeEglDisplay(wl_egl_display_create(mWaylandDisplay))
{
qDebug() << "Using Wayland-EGL";
}
@@ -63,7 +62,7 @@ QWaylandEglIntegration::~QWaylandEglIntegration()
void QWaylandEglIntegration::initialize()
{
EGLint major,minor;
- mEglDisplay = eglGetDisplay((EGLNativeDisplayType)mNativeEglDisplay);
+ mEglDisplay = eglGetDisplay(mWaylandDisplay);
if (mEglDisplay == NULL) {
qWarning("EGL not available");
} else {
@@ -84,11 +83,6 @@ EGLDisplay QWaylandEglIntegration::eglDisplay() const
return mEglDisplay;
}
-wl_egl_display * QWaylandEglIntegration::nativeDisplay() const
-{
- return mNativeEglDisplay;
-}
-
QWaylandGLIntegration *QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay)
{
return new QWaylandEglIntegration(waylandDisplay->wl_display());
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h
index bf4c3fe..3a26f97 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h
@@ -65,9 +65,6 @@ private:
struct wl_display *mWaylandDisplay;
EGLDisplay mEglDisplay;
- struct wl_egl_display *mNativeEglDisplay;
-
-
};
#endif // QWAYLANDEGLINTEGRATION_H
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp
index d7cf0a5..cf52f39 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp
@@ -103,7 +103,7 @@ void QWaylandEglWindow::newSurfaceCreated()
if (!size.isValid())
size = QSize(0,0);
- mWaylandEglWindow = wl_egl_window_create(mEglIntegration->nativeDisplay(),mSurface,size.width(),size.height(),visual);
+ mWaylandEglWindow = wl_egl_window_create(mSurface,size.width(),size.height(),visual);
if (mGLContext) {
EGLNativeWindowType window(reinterpret_cast<EGLNativeWindowType>(mWaylandEglWindow));
EGLSurface surface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mGLContext->eglConfig(),window,NULL);
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h
index 549d039..856321d 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h
@@ -63,7 +63,6 @@ private:
QWaylandEglIntegration *mEglIntegration;
QWaylandGLContext *mGLContext;
struct wl_egl_window *mWaylandEglWindow;
- EGLConfig mConfig;
const QWaylandWindow *mParentWindow;
};
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri b/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri
index bc97864..cd07011 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri
@@ -1,12 +1,11 @@
+include (../../../eglconvenience/eglconvenience.pri)
+
LIBS += -lwayland-egl -lEGL
INCLUDEPATH += $$PWD
SOURCES += $$PWD/qwaylandeglintegration.cpp \
$$PWD/qwaylandglcontext.cpp \
- $$PWD/qwaylandeglwindow.cpp \
- $$PWD/../../../eglconvenience/qeglconvenience.cpp
+ $$PWD/qwaylandeglwindow.cpp
HEADERS += $$PWD/qwaylandeglintegration.h \
$$PWD/qwaylandglcontext.h \
- $$PWD/qwaylandeglwindow.h \
- $$PWD/../../../eglconvenience/qeglconvenience.h \
- gl_integration/wayland_egl/qwaylandeglinclude.h
+ $$PWD/qwaylandeglwindow.h
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp
index 95b4112..7537b52 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp
@@ -111,9 +111,9 @@ const struct wl_xcomposite_listener QWaylandXCompositeEGLIntegration::xcomposite
void QWaylandXCompositeEGLIntegration::wlDisplayHandleGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data)
{
Q_UNUSED(version);
- if (strcmp(interface, "xcomposite") == 0) {
+ if (strcmp(interface, "wl_xcomposite") == 0) {
QWaylandXCompositeEGLIntegration *integration = static_cast<QWaylandXCompositeEGLIntegration *>(data);
- integration->mWaylandComposite = wl_xcomposite_create(display,id);
+ integration->mWaylandComposite = wl_xcomposite_create(display,id,1);
wl_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration);
}
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
index 43c0135..5cb6ef3 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
@@ -106,9 +106,9 @@ const struct wl_xcomposite_listener QWaylandXCompositeGLXIntegration::xcomposite
void QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data)
{
Q_UNUSED(version);
- if (strcmp(interface, "xcomposite") == 0) {
+ if (strcmp(interface, "wl_xcomposite") == 0) {
QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data);
- integration->mWaylandComposite = wl_xcomposite_create(display,id);
+ integration->mWaylandComposite = wl_xcomposite_create(display,id,1);
wl_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration);
}
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h
index 72376e1..85da7a9 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h
@@ -39,7 +39,6 @@
**
****************************************************************************/
-
#ifndef XCOMPOSITE_CLIENT_PROTOCOL_H
#define XCOMPOSITE_CLIENT_PROTOCOL_H
@@ -55,84 +54,63 @@ struct wl_client;
struct wl_xcomposite;
-struct wl_proxy;
-
-extern void
-wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...);
-extern struct wl_proxy *
-wl_proxy_create(struct wl_proxy *factory,
- const struct wl_interface *interface);
-extern struct wl_proxy *
-wl_proxy_create_for_id(struct wl_display *display,
- const struct wl_interface *interface, uint32_t id);
-extern void
-wl_proxy_destroy(struct wl_proxy *proxy);
-
-extern int
-wl_proxy_add_listener(struct wl_proxy *proxy,
- void (**implementation)(void), void *data);
-
-extern void
-wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data);
-
-extern void *
-wl_proxy_get_user_data(struct wl_proxy *proxy);
-
extern const struct wl_interface wl_xcomposite_interface;
struct wl_xcomposite_listener {
void (*root)(void *data,
- struct wl_xcomposite *xcomposite,
+ struct wl_xcomposite *wl_xcomposite,
const char *display_name,
uint32_t root_window);
};
static inline int
-wl_xcomposite_add_listener(struct wl_xcomposite *xcomposite,
- const struct wl_xcomposite_listener *listener, void *data)
+wl_xcomposite_add_listener(struct wl_xcomposite *wl_xcomposite,
+ const struct wl_xcomposite_listener *listener, void *data)
{
- return wl_proxy_add_listener((struct wl_proxy *) xcomposite,
+ return wl_proxy_add_listener((struct wl_proxy *) wl_xcomposite,
(void (**)(void)) listener, data);
}
#define WL_XCOMPOSITE_CREATE_BUFFER 0
static inline struct wl_xcomposite *
-wl_xcomposite_create(struct wl_display *display, uint32_t id)
+wl_xcomposite_create(struct wl_display *display, uint32_t id, uint32_t version)
{
+ wl_display_bind(display, id, "wl_xcomposite", version);
+
return (struct wl_xcomposite *)
wl_proxy_create_for_id(display, &wl_xcomposite_interface, id);
}
static inline void
-wl_xcomposite_set_user_data(struct wl_xcomposite *xcomposite, void *user_data)
+wl_xcomposite_set_user_data(struct wl_xcomposite *wl_xcomposite, void *user_data)
{
- wl_proxy_set_user_data((struct wl_proxy *) xcomposite, user_data);
+ wl_proxy_set_user_data((struct wl_proxy *) wl_xcomposite, user_data);
}
static inline void *
-wl_xcomposite_get_user_data(struct wl_xcomposite *xcomposite)
+wl_xcomposite_get_user_data(struct wl_xcomposite *wl_xcomposite)
{
- return wl_proxy_get_user_data((struct wl_proxy *) xcomposite);
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_xcomposite);
}
static inline void
-wl_xcomposite_destroy(struct wl_xcomposite *xcomposite)
+wl_xcomposite_destroy(struct wl_xcomposite *wl_xcomposite)
{
- wl_proxy_destroy((struct wl_proxy *) xcomposite);
+ wl_proxy_destroy((struct wl_proxy *) wl_xcomposite);
}
static inline struct wl_buffer *
-wl_xcomposite_create_buffer(struct wl_xcomposite *xcomposite, uint32_t x_window, int width, int height, struct wl_visual *visual)
+wl_xcomposite_create_buffer(struct wl_xcomposite *wl_xcomposite, uint32_t x_window, int width, int height, struct wl_visual *visual)
{
struct wl_proxy *id;
- id = wl_proxy_create((struct wl_proxy *) xcomposite,
+ id = wl_proxy_create((struct wl_proxy *) wl_xcomposite,
&wl_buffer_interface);
if (!id)
return NULL;
- wl_proxy_marshal((struct wl_proxy *) xcomposite,
+ wl_proxy_marshal((struct wl_proxy *) wl_xcomposite,
WL_XCOMPOSITE_CREATE_BUFFER, id, x_window, width, height, visual);
return (struct wl_buffer *) id;
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c
index 5c966fd..a1b6325 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c
@@ -43,17 +43,17 @@
#include <stdint.h>
#include "wayland-util.h"
-static const struct wl_message xcomposite_requests[] = {
+static const struct wl_message wl_xcomposite_requests[] = {
{ "create_buffer", "nuiio" },
};
-static const struct wl_message xcomposite_events[] = {
+static const struct wl_message wl_xcomposite_events[] = {
{ "root", "su" },
};
WL_EXPORT const struct wl_interface wl_xcomposite_interface = {
- "xcomposite", 1,
- ARRAY_LENGTH(xcomposite_requests), xcomposite_requests,
- ARRAY_LENGTH(xcomposite_events), xcomposite_events,
+ "wl_xcomposite", 1,
+ ARRAY_LENGTH(wl_xcomposite_requests), wl_xcomposite_requests,
+ ARRAY_LENGTH(wl_xcomposite_events), wl_xcomposite_events,
};
diff --git a/src/plugins/platforms/wayland/qwaylandbuffer.h b/src/plugins/platforms/wayland/qwaylandbuffer.h
index 8779d5f..faeb3e8 100644
--- a/src/plugins/platforms/wayland/qwaylandbuffer.h
+++ b/src/plugins/platforms/wayland/qwaylandbuffer.h
@@ -44,6 +44,7 @@
#include <QtCore/QSize>
+#include <wayland-client.h>
#include <wayland-client-protocol.h>
class QWaylandBuffer {
diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.cpp b/src/plugins/platforms/wayland/qwaylandclipboard.cpp
new file mode 100644
index 0000000..9c533aa
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandclipboard.cpp
@@ -0,0 +1,242 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandclipboard.h"
+#include "qwaylanddisplay.h"
+#include "qwaylandinputdevice.h"
+#include <QtGui/QPlatformNativeInterface>
+#include <QtGui/QApplication>
+#include <QtCore/QMimeData>
+#include <QtCore/QStringList>
+#include <QtCore/QFile>
+#include <QtCore/QtDebug>
+
+static QWaylandClipboard *clipboard;
+
+class QWaylandSelection
+{
+public:
+ QWaylandSelection(QWaylandDisplay *display, QMimeData *data);
+ ~QWaylandSelection();
+
+private:
+ static uint32_t getTime();
+ static void send(void *data, struct wl_selection *selection, const char *mime_type, int fd);
+ static void cancelled(void *data, struct wl_selection *selection);
+ static const struct wl_selection_listener selectionListener;
+
+ QMimeData *mMimeData;
+ struct wl_selection *mSelection;
+};
+
+const struct wl_selection_listener QWaylandSelection::selectionListener = {
+ QWaylandSelection::send,
+ QWaylandSelection::cancelled
+};
+
+uint32_t QWaylandSelection::getTime()
+{
+ struct timeval tv;
+ gettimeofday(&tv, 0);
+ return tv.tv_sec * 1000 + tv.tv_usec / 1000;
+}
+
+QWaylandSelection::QWaylandSelection(QWaylandDisplay *display, QMimeData *data)
+ : mMimeData(data), mSelection(0)
+{
+ struct wl_shell *shell = display->wl_shell();
+ mSelection = wl_shell_create_selection(shell);
+ wl_selection_add_listener(mSelection, &selectionListener, this);
+ foreach (const QString &format, data->formats())
+ wl_selection_offer(mSelection, format.toLatin1().constData());
+ wl_selection_activate(mSelection,
+ display->inputDevices().at(0)->wl_input_device(),
+ getTime());
+}
+
+QWaylandSelection::~QWaylandSelection()
+{
+ if (mSelection) {
+ clipboard->unregisterSelection(this);
+ wl_selection_destroy(mSelection);
+ }
+ delete mMimeData;
+}
+
+void QWaylandSelection::send(void *data,
+ struct wl_selection *selection,
+ const char *mime_type,
+ int fd)
+{
+ Q_UNUSED(selection);
+ QWaylandSelection *self = static_cast<QWaylandSelection *>(data);
+ QString mimeType = QString::fromLatin1(mime_type);
+ QByteArray content = self->mMimeData->data(mimeType);
+ if (!content.isEmpty()) {
+ QFile f;
+ if (f.open(fd, QIODevice::WriteOnly))
+ f.write(content);
+ }
+ close(fd);
+}
+
+void QWaylandSelection::cancelled(void *data, struct wl_selection *selection)
+{
+ Q_UNUSED(selection);
+ delete static_cast<QWaylandSelection *>(data);
+}
+
+QWaylandClipboard::QWaylandClipboard(QWaylandDisplay *display)
+ : mDisplay(display), mSelection(0), mMimeDataIn(0), mOffer(0)
+{
+ clipboard = this;
+}
+
+QWaylandClipboard::~QWaylandClipboard()
+{
+ if (mOffer)
+ wl_selection_offer_destroy(mOffer);
+ delete mMimeDataIn;
+ qDeleteAll(mSelections);
+}
+
+void QWaylandClipboard::unregisterSelection(QWaylandSelection *selection)
+{
+ mSelections.removeOne(selection);
+}
+
+void QWaylandClipboard::syncCallback(void *data)
+{
+ *static_cast<bool *>(data) = true;
+}
+
+void QWaylandClipboard::forceRoundtrip(struct wl_display *display)
+{
+ bool done = false;
+ wl_display_sync_callback(display, syncCallback, &done);
+ wl_display_iterate(display, WL_DISPLAY_WRITABLE);
+ while (!done)
+ wl_display_iterate(display, WL_DISPLAY_READABLE);
+}
+
+const QMimeData *QWaylandClipboard::mimeData(QClipboard::Mode mode) const
+{
+ Q_ASSERT(mode == QClipboard::Clipboard);
+ if (!mMimeDataIn)
+ mMimeDataIn = new QMimeData;
+ mMimeDataIn->clear();
+ if (!mOfferedMimeTypes.isEmpty() && mOffer) {
+ foreach (const QString &mimeType, mOfferedMimeTypes) {
+ int pipefd[2];
+ if (pipe(pipefd) == -1) {
+ qWarning("QWaylandClipboard::mimedata: pipe() failed");
+ break;
+ }
+ QByteArray mimeTypeBa = mimeType.toLatin1();
+ wl_selection_offer_receive(mOffer, mimeTypeBa.constData(), pipefd[1]);
+ QByteArray content;
+ forceRoundtrip(mDisplay->wl_display());
+ char buf[256];
+ int n;
+ close(pipefd[1]);
+ while ((n = read(pipefd[0], &buf, sizeof buf)) > 0)
+ content.append(buf, n);
+ close(pipefd[0]);
+ mMimeDataIn->setData(mimeType, content);
+ }
+ }
+ return mMimeDataIn;
+}
+
+void QWaylandClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
+{
+ Q_ASSERT(mode == QClipboard::Clipboard);
+ if (!mDisplay->inputDevices().isEmpty()) {
+ if (!data)
+ data = new QMimeData;
+ mSelection = new QWaylandSelection(mDisplay, data);
+ } else {
+ qWarning("QWaylandClipboard::setMimeData: No input devices");
+ }
+}
+
+bool QWaylandClipboard::supportsMode(QClipboard::Mode mode) const
+{
+ return mode == QClipboard::Clipboard;
+}
+
+const struct wl_selection_offer_listener QWaylandClipboard::selectionOfferListener = {
+ QWaylandClipboard::offer,
+ QWaylandClipboard::keyboardFocus
+};
+
+void QWaylandClipboard::createSelectionOffer(uint32_t id)
+{
+ mOfferedMimeTypes.clear();
+ if (mOffer)
+ wl_selection_offer_destroy(mOffer);
+ mOffer = 0;
+ struct wl_selection_offer *offer = wl_selection_offer_create(mDisplay->wl_display(), id, 1);
+ wl_selection_offer_add_listener(offer, &selectionOfferListener, this);
+}
+
+void QWaylandClipboard::offer(void *data,
+ struct wl_selection_offer *selection_offer,
+ const char *type)
+{
+ Q_UNUSED(selection_offer);
+ QWaylandClipboard *self = static_cast<QWaylandClipboard *>(data);
+ self->mOfferedMimeTypes.append(QString::fromLatin1(type));
+}
+
+void QWaylandClipboard::keyboardFocus(void *data,
+ struct wl_selection_offer *selection_offer,
+ wl_input_device *input_device)
+{
+ QWaylandClipboard *self = static_cast<QWaylandClipboard *>(data);
+ if (!input_device) {
+ wl_selection_offer_destroy(selection_offer);
+ self->mOffer = 0;
+ return;
+ }
+ self->mOffer = selection_offer;
+ self->emitChanged(QClipboard::Clipboard);
+}
diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.h b/src/plugins/platforms/wayland/qwaylandclipboard.h
new file mode 100644
index 0000000..606a1f6
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandclipboard.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDCLIPBOARD_H
+#define QWAYLANDCLIPBOARD_H
+
+#include <QtGui/QPlatformClipboard>
+#include <QtCore/QStringList>
+
+class QWaylandDisplay;
+class QWaylandSelection;
+struct wl_selection_offer;
+
+class QWaylandClipboard : public QPlatformClipboard
+{
+public:
+ QWaylandClipboard(QWaylandDisplay *display);
+ ~QWaylandClipboard();
+
+ const QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard) const;
+ void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard);
+ bool supportsMode(QClipboard::Mode mode) const;
+
+ void unregisterSelection(QWaylandSelection *selection);
+
+ void createSelectionOffer(uint32_t id);
+
+private:
+ static void offer(void *data,
+ struct wl_selection_offer *selection_offer,
+ const char *type);
+ static void keyboardFocus(void *data,
+ struct wl_selection_offer *selection_offer,
+ struct wl_input_device *input_device);
+ static const struct wl_selection_offer_listener selectionOfferListener;
+
+ static void syncCallback(void *data);
+ static void forceRoundtrip(struct wl_display *display);
+
+ QWaylandDisplay *mDisplay;
+ QWaylandSelection *mSelection;
+ mutable QMimeData *mMimeDataIn;
+ QList<QWaylandSelection *> mSelections;
+ QStringList mOfferedMimeTypes;
+ struct wl_selection_offer *mOffer;
+};
+
+#endif // QWAYLANDCLIPBOARD_H
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
index 1c56561..974453d 100644
--- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
@@ -45,6 +45,7 @@
#include "qwaylandscreen.h"
#include "qwaylandcursor.h"
#include "qwaylandinputdevice.h"
+#include "qwaylandclipboard.h"
#ifdef QT_WAYLAND_GL_SUPPORT
#include "gl_integration/qwaylandglintegration.h"
@@ -52,6 +53,7 @@
#include <QtCore/QAbstractEventDispatcher>
#include <QtGui/QApplication>
+#include <QtGui/private/qapplication_p.h>
#include <unistd.h>
#include <fcntl.h>
@@ -126,6 +128,7 @@ QWaylandDisplay::QWaylandDisplay(void)
#ifdef QT_WAYLAND_GL_SUPPORT
mEglIntegration = QWaylandGLIntegration::createGLIntegration(this);
#endif
+ blockingReadEvents();
qRegisterMetaType<uint32_t>("uint32_t");
@@ -216,9 +219,6 @@ void QWaylandDisplay::outputHandleGeometry(void *data,
int32_t x, int32_t y,
int32_t width, int32_t height)
{
- //call back function called from another thread;
- //but its safe to call createScreen from another thread since
- //QWaylandScreen does a moveToThread
QWaylandDisplay *waylandDisplay = static_cast<QWaylandDisplay *>(data);
QRect outputRect = QRect(x, y, width, height);
waylandDisplay->createNewScreen(output,outputRect);
@@ -251,20 +251,23 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id,
uint32_t version)
{
Q_UNUSED(version);
-
- if (interface == "output") {
- struct wl_output *output = wl_output_create(mDisplay, id);
+ if (interface == "wl_output") {
+ struct wl_output *output = wl_output_create(mDisplay, id, 1);
wl_output_add_listener(output, &outputListener, this);
- } else if (interface == "compositor") {
- mCompositor = wl_compositor_create(mDisplay, id);
- } else if (interface == "shm") {
- mShm = wl_shm_create(mDisplay, id);
- } else if (interface == "shell"){
- mShell = wl_shell_create(mDisplay, id);
+ } else if (interface == "wl_compositor") {
+ mCompositor = wl_compositor_create(mDisplay, id, 1);
+ } else if (interface == "wl_shm") {
+ mShm = wl_shm_create(mDisplay, id, 1);
+ } else if (interface == "wl_shell"){
+ mShell = wl_shell_create(mDisplay, id, 1);
wl_shell_add_listener(mShell, &shellListener, this);
- } else if (interface == "input_device") {
+ } else if (interface == "wl_input_device") {
QWaylandInputDevice *inputDevice =
new QWaylandInputDevice(mDisplay, id);
mInputDevices.append(inputDevice);
+ } else if (interface == "wl_selection_offer") {
+ QPlatformIntegration *plat = QApplicationPrivate::platformIntegration();
+ QWaylandClipboard *clipboard = static_cast<QWaylandClipboard *>(plat->clipboard());
+ clipboard->createSelectionOffer(id);
}
}
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h
index a2cb1b2..0658956 100644
--- a/src/plugins/platforms/wayland/qwaylanddisplay.h
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.h
@@ -80,6 +80,7 @@ public:
void frameCallback(wl_display_frame_func_t func, struct wl_surface *surface, void *data);
struct wl_display *wl_display() const { return mDisplay; }
+ struct wl_shell *wl_shell() const { return mShell; }
QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; }
diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
index 6c2f341..f9e7c95 100644
--- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
+++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
@@ -61,7 +61,7 @@
QWaylandInputDevice::QWaylandInputDevice(struct wl_display *display,
uint32_t id)
: mDisplay(display)
- , mInputDevice(wl_input_device_create(display, id))
+ , mInputDevice(wl_input_device_create(display, id, 1))
, mPointerFocus(NULL)
, mKeyboardFocus(NULL)
, mButtons(0)
@@ -101,6 +101,12 @@ void QWaylandInputDevice::inputHandleMotion(void *data,
QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
QWaylandWindow *window = inputDevice->mPointerFocus;
+ if (window == NULL) {
+ /* We destroyed the pointer focus surface, but the server
+ * didn't get the message yet. */
+ return;
+ }
+
inputDevice->mSurfacePos = QPoint(surface_x, surface_y);
inputDevice->mGlobalPos = QPoint(x, y);
inputDevice->mTime = time;
@@ -120,6 +126,12 @@ void QWaylandInputDevice::inputHandleButton(void *data,
QWaylandWindow *window = inputDevice->mPointerFocus;
Qt::MouseButton qt_button;
+ if (window == NULL) {
+ /* We destroyed the pointer focus surface, but the server
+ * didn't get the message yet. */
+ return;
+ }
+
switch (button) {
case 272:
qt_button = Qt::LeftButton;
@@ -229,6 +241,12 @@ void QWaylandInputDevice::inputHandleKey(void *data,
QEvent::Type type;
char s[2];
+ if (window == NULL) {
+ /* We destroyed the keyboard focus surface, but the server
+ * didn't get the message yet. */
+ return;
+ }
+
code = key + inputDevice->mXkb->min_key_code;
level = 0;
@@ -250,9 +268,6 @@ void QWaylandInputDevice::inputHandleKey(void *data,
sym = translateKey(sym, s, sizeof s);
- qWarning("keycode %d, sym %d, string %d, modifiers 0x%x",
- code, sym, s[0], (int) inputDevice->mModifiers);
-
if (window) {
QWindowSystemInterface::handleKeyEvent(window->widget(),
time, type, sym,
diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.h b/src/plugins/platforms/wayland/qwaylandinputdevice.h
index 3c83252..251259b 100644
--- a/src/plugins/platforms/wayland/qwaylandinputdevice.h
+++ b/src/plugins/platforms/wayland/qwaylandinputdevice.h
@@ -60,6 +60,7 @@ public:
QWaylandInputDevice(struct wl_display *display, uint32_t id);
void attach(QWaylandBuffer *buffer, int x, int y);
void handleWindowDestroyed(QWaylandWindow *window);
+ struct wl_input_device *wl_input_device() const { return mInputDevice; }
private:
struct wl_display *mDisplay;
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp
index 3f3ee5e..6166c14 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration.cpp
+++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp
@@ -44,6 +44,8 @@
#include "qwaylanddisplay.h"
#include "qwaylandshmsurface.h"
#include "qwaylandshmwindow.h"
+#include "qwaylandnativeinterface.h"
+#include "qwaylandclipboard.h"
#include "qgenericunixfontdatabase.h"
@@ -62,9 +64,16 @@ QWaylandIntegration::QWaylandIntegration(bool useOpenGL)
: mFontDb(new QGenericUnixFontDatabase())
, mDisplay(new QWaylandDisplay())
, mUseOpenGL(useOpenGL)
+ , mNativeInterface(new QWaylandNativeInterface)
+ , mClipboard(0)
{
}
+QPlatformNativeInterface * QWaylandIntegration::nativeInterface() const
+{
+ return mNativeInterface;
+}
+
QList<QPlatformScreen *>
QWaylandIntegration::screens() const
{
@@ -125,3 +134,10 @@ bool QWaylandIntegration::hasOpenGL() const
return false;
#endif
}
+
+QPlatformClipboard *QWaylandIntegration::clipboard() const
+{
+ if (!mClipboard)
+ mClipboard = new QWaylandClipboard(mDisplay);
+ return mClipboard;
+}
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h
index fc9b8d6..fc748b0 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration.h
+++ b/src/plugins/platforms/wayland/qwaylandintegration.h
@@ -63,12 +63,18 @@ public:
QPlatformFontDatabase *fontDatabase() const;
+ QPlatformNativeInterface *nativeInterface() const;
+
+ QPlatformClipboard *clipboard() const;
+
private:
bool hasOpenGL() const;
QPlatformFontDatabase *mFontDb;
QWaylandDisplay *mDisplay;
bool mUseOpenGL;
+ QPlatformNativeInterface *mNativeInterface;
+ mutable QPlatformClipboard *mClipboard;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp
new file mode 100644
index 0000000..c3bfba0
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandnativeinterface.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandwindow.h"
+#include <QtGui/private/qapplication_p.h>
+
+void *QWaylandNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget)
+{
+ QByteArray lowerCaseResource = resourceString.toLower();
+
+ if (lowerCaseResource == "display")
+ return qPlatformScreenForWidget(widget)->display()->wl_display();
+ if (lowerCaseResource == "surface") {
+ return ((QWaylandWindow *) widget->platformWindow())->wl_surface();
+ }
+
+ return NULL;
+}
+
+
+QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWidget(QWidget *widget)
+{
+ QWaylandScreen *screen;
+
+ if (widget) {
+ screen = static_cast<QWaylandScreen *>(QPlatformScreen::platformScreenForWidget(widget));
+ } else {
+ screen = static_cast<QWaylandScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]);
+ }
+ return screen;
+}
diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.h b/src/plugins/platforms/wayland/qwaylandnativeinterface.h
new file mode 100644
index 0000000..ac4cdb9
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDNATIVEINTERFACE_H
+#define QWAYLANDNATIVEINTERFACE_H
+
+#include "qwaylandscreen.h"
+
+#include <QtGui/QPlatformNativeInterface>
+
+class QWaylandNativeInterface : public QPlatformNativeInterface
+{
+public:
+ void *nativeResourceForWidget(const QByteArray &resourceString,
+ QWidget *widget);
+
+private:
+ static QWaylandScreen *qPlatformScreenForWidget(QWidget *widget);
+};
+
+
+#endif // QWAYLANDNATIVEINTERFACE_H
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp
index 6f52291..53f2f48 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.cpp
+++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp
@@ -146,6 +146,7 @@ void QWaylandWindow::newSurfaceCreated()
void QWaylandWindow::frameCallback(struct wl_surface *surface, void *data, uint32_t time)
{
Q_UNUSED(time);
+ Q_UNUSED(surface);
QWaylandWindow *self = static_cast<QWaylandWindow*>(data);
self->mWaitingForFrameSync = false;
}
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h
index 1e60508..47d49a7 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.h
+++ b/src/plugins/platforms/wayland/qwaylandwindow.h
@@ -74,6 +74,9 @@ public:
void damage(const QRegion &region);
void waitForFrameSync();
+
+ struct wl_surface *wl_surface() const { return mSurface; }
+
protected:
struct wl_surface *mSurface;
virtual void newSurfaceCreated();
diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro
index 5945438..76f8be5 100644
--- a/src/plugins/platforms/wayland/wayland.pro
+++ b/src/plugins/platforms/wayland/wayland.pro
@@ -8,27 +8,35 @@ DEFINES += $$QMAKE_DEFINES_WAYLAND
SOURCES = main.cpp \
qwaylandintegration.cpp \
+ qwaylandnativeinterface.cpp \
qwaylandshmsurface.cpp \
qwaylandinputdevice.cpp \
qwaylandcursor.cpp \
qwaylanddisplay.cpp \
qwaylandwindow.cpp \
qwaylandscreen.cpp \
- qwaylandshmwindow.cpp
+ qwaylandshmwindow.cpp \
+ qwaylandclipboard.cpp
HEADERS = qwaylandintegration.h \
+ qwaylandnativeinterface.h \
qwaylandcursor.h \
qwaylanddisplay.h \
qwaylandwindow.h \
qwaylandscreen.h \
qwaylandshmsurface.h \
qwaylandbuffer.h \
- qwaylandshmwindow.h
+ qwaylandshmwindow.h \
+ qwaylandclipboard.h
INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND
LIBS += $$QMAKE_LIBS_WAYLAND
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND
+!isEmpty(QMAKE_LFLAGS_RPATH) {
+ !isEmpty(QMAKE_LIBDIR_WAYLAND):QMAKE_LFLAGS += $${QMAKE_LFLAGS_RPATH}$${QMAKE_LIBDIR_WAYLAND}
+}
+
INCLUDEPATH += $$PWD
include ($$PWD/gl_integration/gl_integration.pri)
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp
index 190221c..1417157 100644
--- a/src/plugins/platforms/xcb/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/qglxintegration.cpp
@@ -110,7 +110,6 @@ void QGLXContext::swapBuffers()
{
Q_XCB_NOOP(m_screen->connection());
glXSwapBuffers(DISPLAY_FROM_XCB(m_screen), m_drawable);
- doneCurrent();
Q_XCB_NOOP(m_screen->connection());
}
diff --git a/src/plugins/platforms/xlib/qglxintegration.cpp b/src/plugins/platforms/xlib/qglxintegration.cpp
index 7a0f36d..a43851c 100644
--- a/src/plugins/platforms/xlib/qglxintegration.cpp
+++ b/src/plugins/platforms/xlib/qglxintegration.cpp
@@ -46,15 +46,13 @@
#include "qxlibwindow.h"
#include "qxlibscreen.h"
#include "qxlibdisplay.h"
+#include "qxlibstatic.h"
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <GL/glx.h>
-#include "qglxconvenience.h"
-
#include "qglxintegration.h"
+#include "qglxconvenience.h"
+
#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
#include <dlfcn.h>
#endif
diff --git a/src/plugins/platforms/xlib/qglxintegration.h b/src/plugins/platforms/xlib/qglxintegration.h
index 57c716b..d0527c3 100644
--- a/src/plugins/platforms/xlib/qglxintegration.h
+++ b/src/plugins/platforms/xlib/qglxintegration.h
@@ -47,10 +47,10 @@
#include <QtGui/QPlatformGLContext>
#include <QtGui/QPlatformWindowFormat>
-#include <QtCore/QMutex>
-
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
+#define Status int
#include <GL/glx.h>
+#undef Status
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/xlib/qxlibscreen.cpp b/src/plugins/platforms/xlib/qxlibscreen.cpp
index 7c8a367..c4c8126 100644
--- a/src/plugins/platforms/xlib/qxlibscreen.cpp
+++ b/src/plugins/platforms/xlib/qxlibscreen.cpp
@@ -54,8 +54,6 @@
#include <private/qapplication_p.h>
-#include <X11/extensions/Xfixes.h>
-
QT_BEGIN_NAMESPACE
static int (*original_x_errhandler)(Display *dpy, XErrorEvent *);
@@ -201,7 +199,7 @@ QXlibScreen::QXlibScreen()
#ifndef DONT_USE_MIT_SHM
- Status MIT_SHM_extension_supported = XShmQueryExtension (mDisplay->nativeDisplay());
+ int MIT_SHM_extension_supported = XShmQueryExtension (mDisplay->nativeDisplay());
Q_ASSERT(MIT_SHM_extension_supported == True);
#endif
original_x_errhandler = XSetErrorHandler(qt_x_errhandler);
diff --git a/src/plugins/platforms/xlib/qxlibstatic.cpp b/src/plugins/platforms/xlib/qxlibstatic.cpp
index 6117781..7b562ea 100644
--- a/src/plugins/platforms/xlib/qxlibstatic.cpp
+++ b/src/plugins/platforms/xlib/qxlibstatic.cpp
@@ -51,10 +51,6 @@
#include <QDebug>
-#ifndef QT_NO_XFIXES
-#include <X11/extensions/Xfixes.h>
-#endif // QT_NO_XFIXES
-
static const char * x11_atomnames = {
// window-manager <-> client protocols
"WM_PROTOCOLS\0"
diff --git a/src/plugins/platforms/xlib/qxlibstatic.h b/src/plugins/platforms/xlib/qxlibstatic.h
index 72cfaec..ebc8085 100644
--- a/src/plugins/platforms/xlib/qxlibstatic.h
+++ b/src/plugins/platforms/xlib/qxlibstatic.h
@@ -118,6 +118,10 @@ extern "C" {
}
#endif
+#ifndef QT_NO_XFIXES
+#include <X11/extensions/Xfixes.h>
+#endif // QT_NO_XFIXES
+
// #define QT_NO_XKB
#ifndef QT_NO_XKB
# include <X11/XKBlib.h>
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 7479d2f..2d0c201 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -7,9 +7,9 @@ unix:!symbian {
SUBDIRS *= codecs
}
!contains(QT_CONFIG, no-gui): SUBDIRS *= imageformats iconengines
-!embedded:!qpa:SUBDIRS *= graphicssystems
+!embedded:!qpa:!contains(QT_CONFIG, no-gui):SUBDIRS *= graphicssystems
embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers
-!win32:!embedded:!mac:!symbian:SUBDIRS *= inputmethods
+!win32:!embedded:!mac:!symbian:!contains(QT_CONFIG, no-gui):SUBDIRS *= inputmethods
!symbian:!contains(QT_CONFIG, no-gui):SUBDIRS += accessible
symbian:SUBDIRS += s60
contains(QT_CONFIG, phonon): SUBDIRS *= phonon
diff --git a/src/plugins/qmltooling/declarativeobserver/declarativeobserver.pro b/src/plugins/qmltooling/declarativeobserver/declarativeobserver.pro
new file mode 100644
index 0000000..bccabcb
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/declarativeobserver.pro
@@ -0,0 +1,53 @@
+TARGET = declarativeobserver
+QT += declarative
+
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/qmltooling
+QTDIR_build:REQUIRES += "contains(QT_CONFIG, declarative)"
+
+SOURCES += \
+ qdeclarativeobserverplugin.cpp \
+ qdeclarativeviewobserver.cpp \
+ editor/abstractliveedittool.cpp \
+ editor/liveselectiontool.cpp \
+ editor/livelayeritem.cpp \
+ editor/livesingleselectionmanipulator.cpp \
+ editor/liverubberbandselectionmanipulator.cpp \
+ editor/liveselectionrectangle.cpp \
+ editor/liveselectionindicator.cpp \
+ editor/boundingrecthighlighter.cpp \
+ editor/subcomponenteditortool.cpp \
+ editor/subcomponentmasklayeritem.cpp \
+ editor/zoomtool.cpp \
+ editor/colorpickertool.cpp \
+ editor/qmltoolbar.cpp \
+ editor/toolbarcolorbox.cpp
+
+HEADERS += \
+ qdeclarativeobserverplugin.h \
+ qdeclarativeobserverprotocol.h \
+ qdeclarativeviewobserver_p.h \
+ qdeclarativeviewobserver_p_p.h \
+ qmlobserverconstants_p.h \
+ editor/abstractliveedittool_p.h \
+ editor/liveselectiontool_p.h \
+ editor/livelayeritem_p.h \
+ editor/livesingleselectionmanipulator_p.h \
+ editor/liverubberbandselectionmanipulator_p.h \
+ editor/liveselectionrectangle_p.h \
+ editor/liveselectionindicator_p.h \
+ editor/boundingrecthighlighter_p.h \
+ editor/subcomponenteditortool_p.h \
+ editor/subcomponentmasklayeritem_p.h \
+ editor/zoomtool_p.h \
+ editor/colorpickertool_p.h \
+ editor/qmltoolbar_p.h \
+ editor/toolbarcolorbox_p.h
+
+RESOURCES += editor/editor.qrc
+
+target.path += $$[QT_INSTALL_PLUGINS]/qmltooling
+INSTALLS += target
+
+symbian:TARGET.UID3=0x20031E90
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/abstractliveedittool.cpp b/src/plugins/qmltooling/declarativeobserver/editor/abstractliveedittool.cpp
new file mode 100644
index 0000000..b3ed22e
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/abstractliveedittool.cpp
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "abstractliveedittool_p.h"
+#include "../qdeclarativeviewobserver_p_p.h"
+
+#include <QDeclarativeEngine>
+
+#include <QtDebug>
+#include <QGraphicsItem>
+#include <QDeclarativeItem>
+
+QT_BEGIN_NAMESPACE
+
+AbstractLiveEditTool::AbstractLiveEditTool(QDeclarativeViewObserver *editorView)
+ : QObject(editorView), m_observer(editorView)
+{
+}
+
+
+AbstractLiveEditTool::~AbstractLiveEditTool()
+{
+}
+
+QDeclarativeViewObserver *AbstractLiveEditTool::observer() const
+{
+ return m_observer;
+}
+
+QDeclarativeView *AbstractLiveEditTool::view() const
+{
+ return m_observer->declarativeView();
+}
+
+QGraphicsScene* AbstractLiveEditTool::scene() const
+{
+ return view()->scene();
+}
+
+void AbstractLiveEditTool::updateSelectedItems()
+{
+ selectedItemsChanged(items());
+}
+
+QList<QGraphicsItem*> AbstractLiveEditTool::items() const
+{
+ return observer()->selectedItems();
+}
+
+void AbstractLiveEditTool::enterContext(QGraphicsItem *itemToEnter)
+{
+ observer()->data->enterContext(itemToEnter);
+}
+
+bool AbstractLiveEditTool::topItemIsMovable(const QList<QGraphicsItem*> & itemList)
+{
+ QGraphicsItem *firstSelectableItem = topMovableGraphicsItem(itemList);
+ if (firstSelectableItem == 0)
+ return false;
+ if (toQDeclarativeItem(firstSelectableItem) != 0)
+ return true;
+
+ return false;
+
+}
+
+bool AbstractLiveEditTool::topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList)
+{
+ QList<QGraphicsItem*> selectedItems = observer()->selectedItems();
+
+ foreach (QGraphicsItem *item, itemList) {
+ QDeclarativeItem *declarativeItem = toQDeclarativeItem(item);
+ if (declarativeItem
+ && selectedItems.contains(declarativeItem)
+ /*&& (declarativeItem->qmlItemNode().hasShowContent() || selectNonContentItems)*/)
+ return true;
+ }
+
+ return false;
+
+}
+
+bool AbstractLiveEditTool::topItemIsResizeHandle(const QList<QGraphicsItem*> &/*itemList*/)
+{
+ return false;
+}
+
+QDeclarativeItem *AbstractLiveEditTool::toQDeclarativeItem(QGraphicsItem *item)
+{
+ return qobject_cast<QDeclarativeItem*>(item->toGraphicsObject());
+}
+
+QGraphicsItem *AbstractLiveEditTool::topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList)
+{
+ foreach (QGraphicsItem *item, itemList) {
+ if (item->flags().testFlag(QGraphicsItem::ItemIsMovable))
+ return item;
+ }
+ return 0;
+}
+
+QDeclarativeItem *AbstractLiveEditTool::topMovableDeclarativeItem(const QList<QGraphicsItem*>
+ &itemList)
+{
+ foreach (QGraphicsItem *item, itemList) {
+ QDeclarativeItem *declarativeItem = toQDeclarativeItem(item);
+ if (declarativeItem /*&& (declarativeItem->qmlItemNode().hasShowContent())*/)
+ return declarativeItem;
+ }
+
+ return 0;
+}
+
+QList<QGraphicsObject*> AbstractLiveEditTool::toGraphicsObjectList(const QList<QGraphicsItem*>
+ &itemList)
+{
+ QList<QGraphicsObject*> gfxObjects;
+ foreach (QGraphicsItem *item, itemList) {
+ QGraphicsObject *obj = item->toGraphicsObject();
+ if (obj)
+ gfxObjects << obj;
+ }
+
+ return gfxObjects;
+}
+
+QString AbstractLiveEditTool::titleForItem(QGraphicsItem *item)
+{
+ QString className(QLatin1String("QGraphicsItem"));
+ QString objectStringId;
+
+ QString constructedName;
+
+ QGraphicsObject *gfxObject = item->toGraphicsObject();
+ if (gfxObject) {
+ className = QLatin1String(gfxObject->metaObject()->className());
+
+ className.remove(QRegExp(QLatin1String("_QMLTYPE_\\d+")));
+ className.remove(QRegExp(QLatin1String("_QML_\\d+")));
+ if (className.startsWith(QLatin1String("QDeclarative")))
+ className = className.remove(QLatin1String("QDeclarative"));
+
+ QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(gfxObject);
+ if (declarativeItem) {
+ objectStringId = m_observer->idStringForObject(declarativeItem);
+ }
+
+ if (!objectStringId.isEmpty()) {
+ constructedName = objectStringId + QLatin1String(" (") + className + QLatin1Char(')');
+ } else {
+ if (!gfxObject->objectName().isEmpty()) {
+ constructedName = gfxObject->objectName() + QLatin1String(" (") + className + QLatin1Char(')');
+ } else {
+ constructedName = className;
+ }
+ }
+ }
+
+ return constructedName;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/abstractliveedittool_p.h b/src/plugins/qmltooling/declarativeobserver/editor/abstractliveedittool_p.h
new file mode 100644
index 0000000..1dbc323
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/abstractliveedittool_p.h
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACTLIVEEDITTOOL_H
+#define ABSTRACTLIVEEDITTOOL_H
+
+#include <QtCore/QList>
+#include <QtCore/QObject>
+
+QT_BEGIN_NAMESPACE
+class QMouseEvent;
+class QGraphicsItem;
+class QDeclarativeItem;
+class QKeyEvent;
+class QGraphicsScene;
+class QGraphicsObject;
+class QWheelEvent;
+class QDeclarativeView;
+QT_END_NAMESPACE
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeViewObserver;
+
+class AbstractLiveEditTool : public QObject
+{
+ Q_OBJECT
+public:
+ AbstractLiveEditTool(QDeclarativeViewObserver *observer);
+
+ virtual ~AbstractLiveEditTool();
+
+ virtual void mousePressEvent(QMouseEvent *event) = 0;
+ virtual void mouseMoveEvent(QMouseEvent *event) = 0;
+ virtual void mouseReleaseEvent(QMouseEvent *event) = 0;
+ virtual void mouseDoubleClickEvent(QMouseEvent *event) = 0;
+
+ virtual void hoverMoveEvent(QMouseEvent *event) = 0;
+ virtual void wheelEvent(QWheelEvent *event) = 0;
+
+ virtual void keyPressEvent(QKeyEvent *event) = 0;
+ virtual void keyReleaseEvent(QKeyEvent *keyEvent) = 0;
+ virtual void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList) = 0;
+
+ virtual void clear() = 0;
+
+ void updateSelectedItems();
+ QList<QGraphicsItem*> items() const;
+
+ void enterContext(QGraphicsItem *itemToEnter);
+
+ bool topItemIsMovable(const QList<QGraphicsItem*> &itemList);
+ bool topItemIsResizeHandle(const QList<QGraphicsItem*> &itemList);
+ bool topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList);
+
+ QString titleForItem(QGraphicsItem *item);
+
+ static QList<QGraphicsObject*> toGraphicsObjectList(const QList<QGraphicsItem*> &itemList);
+ static QGraphicsItem* topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList);
+ static QDeclarativeItem* topMovableDeclarativeItem(const QList<QGraphicsItem*> &itemList);
+ static QDeclarativeItem *toQDeclarativeItem(QGraphicsItem *item);
+
+protected:
+ virtual void selectedItemsChanged(const QList<QGraphicsItem*> &objectList) = 0;
+
+ QDeclarativeViewObserver *observer() const;
+ QDeclarativeView *view() const;
+ QGraphicsScene *scene() const;
+
+private:
+ QDeclarativeViewObserver *m_observer;
+ QList<QGraphicsItem*> m_itemList;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // ABSTRACTLIVEEDITTOOL_H
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/boundingrecthighlighter.cpp b/src/plugins/qmltooling/declarativeobserver/editor/boundingrecthighlighter.cpp
new file mode 100644
index 0000000..98dbc4f
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/boundingrecthighlighter.cpp
@@ -0,0 +1,284 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "boundingrecthighlighter_p.h"
+
+#include "../qdeclarativeviewobserver_p.h"
+#include "../qmlobserverconstants_p.h"
+
+#include <QtGui/QGraphicsPolygonItem>
+
+#include <QtCore/QTimer>
+#include <QtCore/QObject>
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+const qreal AnimDelta = 0.025f;
+const int AnimInterval = 30;
+const int AnimFrames = 10;
+
+BoundingBox::BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem,
+ QObject *parent)
+ : QObject(parent),
+ highlightedObject(itemToHighlight),
+ highlightPolygon(0),
+ highlightPolygonEdge(0)
+{
+ highlightPolygon = new BoundingBoxPolygonItem(parentItem);
+ highlightPolygonEdge = new BoundingBoxPolygonItem(parentItem);
+
+ highlightPolygon->setPen(QPen(QColor(0, 22, 159)));
+ highlightPolygonEdge->setPen(QPen(QColor(158, 199, 255)));
+
+ highlightPolygon->setFlag(QGraphicsItem::ItemIsSelectable, false);
+ highlightPolygonEdge->setFlag(QGraphicsItem::ItemIsSelectable, false);
+}
+
+BoundingBox::~BoundingBox()
+{
+ highlightedObject.clear();
+}
+
+BoundingBoxPolygonItem::BoundingBoxPolygonItem(QGraphicsItem *item) : QGraphicsPolygonItem(item)
+{
+ QPen pen;
+ pen.setColor(QColor(108, 141, 221));
+ pen.setWidth(1);
+ setPen(pen);
+}
+
+int BoundingBoxPolygonItem::type() const
+{
+ return Constants::EditorItemType;
+}
+
+BoundingRectHighlighter::BoundingRectHighlighter(QDeclarativeViewObserver *view) :
+ LiveLayerItem(view->declarativeView()->scene()),
+ m_view(view),
+ m_animFrame(0)
+{
+ m_animTimer = new QTimer(this);
+ m_animTimer->setInterval(AnimInterval);
+ connect(m_animTimer, SIGNAL(timeout()), SLOT(animTimeout()));
+}
+
+BoundingRectHighlighter::~BoundingRectHighlighter()
+{
+
+}
+
+void BoundingRectHighlighter::animTimeout()
+{
+ ++m_animFrame;
+ if (m_animFrame == AnimFrames) {
+ m_animTimer->stop();
+ }
+
+ qreal alpha = m_animFrame / float(AnimFrames);
+
+ foreach (BoundingBox *box, m_boxes) {
+ box->highlightPolygonEdge->setOpacity(alpha);
+ }
+}
+
+void BoundingRectHighlighter::clear()
+{
+ if (m_boxes.length()) {
+ m_animTimer->stop();
+
+ foreach (BoundingBox *box, m_boxes) {
+ freeBoundingBox(box);
+ }
+ }
+}
+
+BoundingBox *BoundingRectHighlighter::boxFor(QGraphicsObject *item) const
+{
+ foreach (BoundingBox *box, m_boxes) {
+ if (box->highlightedObject.data() == item) {
+ return box;
+ }
+ }
+ return 0;
+}
+
+void BoundingRectHighlighter::highlight(QList<QGraphicsObject*> items)
+{
+ if (items.isEmpty())
+ return;
+
+ bool animate = false;
+
+ QList<BoundingBox *> newBoxes;
+ foreach (QGraphicsObject *itemToHighlight, items) {
+ BoundingBox *box = boxFor(itemToHighlight);
+ if (!box) {
+ box = createBoundingBox(itemToHighlight);
+ animate = true;
+ }
+
+ newBoxes << box;
+ }
+ qSort(newBoxes);
+
+ if (newBoxes != m_boxes) {
+ clear();
+ m_boxes << newBoxes;
+ }
+
+ highlightAll(animate);
+}
+
+void BoundingRectHighlighter::highlight(QGraphicsObject* itemToHighlight)
+{
+ if (!itemToHighlight)
+ return;
+
+ bool animate = false;
+
+ BoundingBox *box = boxFor(itemToHighlight);
+ if (!box) {
+ box = createBoundingBox(itemToHighlight);
+ m_boxes << box;
+ animate = true;
+ qSort(m_boxes);
+ }
+
+ highlightAll(animate);
+}
+
+BoundingBox *BoundingRectHighlighter::createBoundingBox(QGraphicsObject *itemToHighlight)
+{
+ if (!m_freeBoxes.isEmpty()) {
+ BoundingBox *box = m_freeBoxes.last();
+ if (box->highlightedObject.isNull()) {
+ box->highlightedObject = itemToHighlight;
+ box->highlightPolygon->show();
+ box->highlightPolygonEdge->show();
+ m_freeBoxes.removeLast();
+ return box;
+ }
+ }
+
+ BoundingBox *box = new BoundingBox(itemToHighlight, this, this);
+
+ connect(itemToHighlight, SIGNAL(xChanged()), this, SLOT(refresh()));
+ connect(itemToHighlight, SIGNAL(yChanged()), this, SLOT(refresh()));
+ connect(itemToHighlight, SIGNAL(widthChanged()), this, SLOT(refresh()));
+ connect(itemToHighlight, SIGNAL(heightChanged()), this, SLOT(refresh()));
+ connect(itemToHighlight, SIGNAL(rotationChanged()), this, SLOT(refresh()));
+ connect(itemToHighlight, SIGNAL(destroyed(QObject*)), this, SLOT(itemDestroyed(QObject*)));
+
+ return box;
+}
+
+void BoundingRectHighlighter::removeBoundingBox(BoundingBox *box)
+{
+ delete box;
+ box = 0;
+}
+
+void BoundingRectHighlighter::freeBoundingBox(BoundingBox *box)
+{
+ if (!box->highlightedObject.isNull()) {
+ disconnect(box->highlightedObject.data(), SIGNAL(xChanged()), this, SLOT(refresh()));
+ disconnect(box->highlightedObject.data(), SIGNAL(yChanged()), this, SLOT(refresh()));
+ disconnect(box->highlightedObject.data(), SIGNAL(widthChanged()), this, SLOT(refresh()));
+ disconnect(box->highlightedObject.data(), SIGNAL(heightChanged()), this, SLOT(refresh()));
+ disconnect(box->highlightedObject.data(), SIGNAL(rotationChanged()), this, SLOT(refresh()));
+ }
+
+ box->highlightedObject.clear();
+ box->highlightPolygon->hide();
+ box->highlightPolygonEdge->hide();
+ m_boxes.removeOne(box);
+ m_freeBoxes << box;
+}
+
+void BoundingRectHighlighter::itemDestroyed(QObject *obj)
+{
+ foreach (BoundingBox *box, m_boxes) {
+ if (box->highlightedObject.data() == obj) {
+ freeBoundingBox(box);
+ break;
+ }
+ }
+}
+
+void BoundingRectHighlighter::highlightAll(bool animate)
+{
+ foreach (BoundingBox *box, m_boxes) {
+ if (box && box->highlightedObject.isNull()) {
+ // clear all highlights
+ clear();
+ return;
+ }
+ QGraphicsObject *item = box->highlightedObject.data();
+ QRectF itemAndChildRect = item->boundingRect() | item->childrenBoundingRect();
+
+ QPolygonF boundingRectInSceneSpace(item->mapToScene(itemAndChildRect));
+ QPolygonF boundingRectInLayerItemSpace = mapFromScene(boundingRectInSceneSpace);
+ QRectF bboxRect
+ = m_view->adjustToScreenBoundaries(boundingRectInLayerItemSpace.boundingRect());
+ QRectF edgeRect = bboxRect;
+ edgeRect.adjust(-1, -1, 1, 1);
+
+ box->highlightPolygon->setPolygon(QPolygonF(bboxRect));
+ box->highlightPolygonEdge->setPolygon(QPolygonF(edgeRect));
+
+ if (animate)
+ box->highlightPolygonEdge->setOpacity(0);
+ }
+
+ if (animate) {
+ m_animFrame = 0;
+ m_animTimer->start();
+ }
+}
+
+void BoundingRectHighlighter::refresh()
+{
+ if (!m_boxes.isEmpty())
+ highlightAll(true);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/boundingrecthighlighter_p.h b/src/plugins/qmltooling/declarativeobserver/editor/boundingrecthighlighter_p.h
new file mode 100644
index 0000000..c1beed8
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/boundingrecthighlighter_p.h
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BOUNDINGRECTHIGHLIGHTER_H
+#define BOUNDINGRECTHIGHLIGHTER_H
+
+#include "livelayeritem_p.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QWeakPointer>
+
+QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
+QT_FORWARD_DECLARE_CLASS(QPainter)
+QT_FORWARD_DECLARE_CLASS(QWidget)
+QT_FORWARD_DECLARE_CLASS(QStyleOptionGraphicsItem)
+QT_FORWARD_DECLARE_CLASS(QTimer)
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeViewObserver;
+class BoundingBox;
+
+class BoundingRectHighlighter : public LiveLayerItem
+{
+ Q_OBJECT
+public:
+ explicit BoundingRectHighlighter(QDeclarativeViewObserver *view);
+ ~BoundingRectHighlighter();
+ void clear();
+ void highlight(QList<QGraphicsObject*> items);
+ void highlight(QGraphicsObject* item);
+
+private slots:
+ void refresh();
+ void animTimeout();
+ void itemDestroyed(QObject *);
+
+private:
+ BoundingBox *boxFor(QGraphicsObject *item) const;
+ void highlightAll(bool animate);
+ BoundingBox *createBoundingBox(QGraphicsObject *itemToHighlight);
+ void removeBoundingBox(BoundingBox *box);
+ void freeBoundingBox(BoundingBox *box);
+
+private:
+ Q_DISABLE_COPY(BoundingRectHighlighter)
+
+ QDeclarativeViewObserver *m_view;
+ QList<BoundingBox* > m_boxes;
+ QList<BoundingBox* > m_freeBoxes;
+ QTimer *m_animTimer;
+ qreal m_animScale;
+ int m_animFrame;
+
+};
+
+class BoundingBox : public QObject
+{
+ Q_OBJECT
+public:
+ explicit BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem,
+ QObject *parent = 0);
+ ~BoundingBox();
+ QWeakPointer<QGraphicsObject> highlightedObject;
+ QGraphicsPolygonItem *highlightPolygon;
+ QGraphicsPolygonItem *highlightPolygonEdge;
+
+private:
+ Q_DISABLE_COPY(BoundingBox)
+
+};
+
+class BoundingBoxPolygonItem : public QGraphicsPolygonItem
+{
+public:
+ explicit BoundingBoxPolygonItem(QGraphicsItem *item);
+ int type() const;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // BOUNDINGRECTHIGHLIGHTER_H
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/colorpickertool.cpp b/src/plugins/qmltooling/declarativeobserver/editor/colorpickertool.cpp
new file mode 100644
index 0000000..a71e408
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/colorpickertool.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "colorpickertool_p.h"
+
+#include "../qdeclarativeviewobserver_p.h"
+
+#include <QtGui/QMouseEvent>
+#include <QtGui/QKeyEvent>
+#include <QtCore/QRectF>
+#include <QtGui/QRgb>
+#include <QtGui/QImage>
+#include <QtGui/QApplication>
+#include <QtGui/QPalette>
+
+QT_BEGIN_NAMESPACE
+
+ColorPickerTool::ColorPickerTool(QDeclarativeViewObserver *view) :
+ AbstractLiveEditTool(view)
+{
+ m_selectedColor.setRgb(0,0,0);
+}
+
+ColorPickerTool::~ColorPickerTool()
+{
+
+}
+
+void ColorPickerTool::mousePressEvent(QMouseEvent * /*event*/)
+{
+}
+
+void ColorPickerTool::mouseMoveEvent(QMouseEvent *event)
+{
+ pickColor(event->pos());
+}
+
+void ColorPickerTool::mouseReleaseEvent(QMouseEvent *event)
+{
+ pickColor(event->pos());
+}
+
+void ColorPickerTool::mouseDoubleClickEvent(QMouseEvent * /*event*/)
+{
+}
+
+
+void ColorPickerTool::hoverMoveEvent(QMouseEvent * /*event*/)
+{
+}
+
+void ColorPickerTool::keyPressEvent(QKeyEvent * /*event*/)
+{
+}
+
+void ColorPickerTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/)
+{
+}
+void ColorPickerTool::wheelEvent(QWheelEvent * /*event*/)
+{
+}
+
+void ColorPickerTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
+{
+}
+
+void ColorPickerTool::clear()
+{
+ view()->setCursor(Qt::CrossCursor);
+}
+
+void ColorPickerTool::selectedItemsChanged(const QList<QGraphicsItem*> &/*itemList*/)
+{
+}
+
+void ColorPickerTool::pickColor(const QPoint &pos)
+{
+ QRgb fillColor = view()->backgroundBrush().color().rgb();
+ if (view()->backgroundBrush().style() == Qt::NoBrush)
+ fillColor = view()->palette().color(QPalette::Base).rgb();
+
+ QRectF target(0,0, 1, 1);
+ QRect source(pos.x(), pos.y(), 1, 1);
+ QImage img(1, 1, QImage::Format_ARGB32);
+ img.fill(fillColor);
+ QPainter painter(&img);
+ view()->render(&painter, target, source);
+ m_selectedColor = QColor::fromRgb(img.pixel(0, 0));
+
+ emit selectedColorChanged(m_selectedColor);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/colorpickertool_p.h b/src/plugins/qmltooling/declarativeobserver/editor/colorpickertool_p.h
new file mode 100644
index 0000000..86a8893
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/colorpickertool_p.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef COLORPICKERTOOL_H
+#define COLORPICKERTOOL_H
+
+#include "abstractliveedittool_p.h"
+
+#include <QtGui/QColor>
+
+QT_FORWARD_DECLARE_CLASS(QPoint)
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class ColorPickerTool : public AbstractLiveEditTool
+{
+ Q_OBJECT
+public:
+ explicit ColorPickerTool(QDeclarativeViewObserver *view);
+
+ virtual ~ColorPickerTool();
+
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+
+ void hoverMoveEvent(QMouseEvent *event);
+
+ void keyPressEvent(QKeyEvent *event);
+ void keyReleaseEvent(QKeyEvent *keyEvent);
+
+ void wheelEvent(QWheelEvent *event);
+
+ void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
+
+ void clear();
+
+signals:
+ void selectedColorChanged(const QColor &color);
+
+protected:
+
+ void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
+
+private:
+ void pickColor(const QPoint &pos);
+
+private:
+ QColor m_selectedColor;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // COLORPICKERTOOL_H
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/editor.qrc b/src/plugins/qmltooling/declarativeobserver/editor/editor.qrc
new file mode 100644
index 0000000..77744d5
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/editor.qrc
@@ -0,0 +1,24 @@
+<RCC>
+ <qresource prefix="/qml">
+ <file>images/resize_handle.png</file>
+ <file>images/select.png</file>
+ <file>images/select-marquee.png</file>
+ <file>images/color-picker.png</file>
+ <file>images/play.png</file>
+ <file>images/pause.png</file>
+ <file>images/from-qml.png</file>
+ <file>images/to-qml.png</file>
+ <file>images/color-picker-hicontrast.png</file>
+ <file>images/zoom.png</file>
+ <file>images/color-picker-24.png</file>
+ <file>images/from-qml-24.png</file>
+ <file>images/pause-24.png</file>
+ <file>images/play-24.png</file>
+ <file>images/to-qml-24.png</file>
+ <file>images/zoom-24.png</file>
+ <file>images/select-24.png</file>
+ <file>images/select-marquee-24.png</file>
+ <file>images/observermode.png</file>
+ <file>images/observermode-24.png</file>
+ </qresource>
+</RCC>
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/color-picker-24.png b/src/plugins/qmltooling/declarativeobserver/editor/images/color-picker-24.png
new file mode 100644
index 0000000..cff4721
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/color-picker-24.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/color-picker-hicontrast.png b/src/plugins/qmltooling/declarativeobserver/editor/images/color-picker-hicontrast.png
new file mode 100644
index 0000000..b953d08
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/color-picker-hicontrast.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/color-picker.png b/src/plugins/qmltooling/declarativeobserver/editor/images/color-picker.png
new file mode 100644
index 0000000..026c31b
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/color-picker.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/from-qml-24.png b/src/plugins/qmltooling/declarativeobserver/editor/images/from-qml-24.png
new file mode 100644
index 0000000..0ad21f3
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/from-qml-24.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/from-qml.png b/src/plugins/qmltooling/declarativeobserver/editor/images/from-qml.png
new file mode 100644
index 0000000..666382c
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/from-qml.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/observermode-24.png b/src/plugins/qmltooling/declarativeobserver/editor/images/observermode-24.png
new file mode 100644
index 0000000..5e74d86
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/observermode-24.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/observermode.png b/src/plugins/qmltooling/declarativeobserver/editor/images/observermode.png
new file mode 100644
index 0000000..daed21c
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/observermode.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/pause-24.png b/src/plugins/qmltooling/declarativeobserver/editor/images/pause-24.png
new file mode 100644
index 0000000..d9a2f6f
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/pause-24.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/pause.png b/src/plugins/qmltooling/declarativeobserver/editor/images/pause.png
new file mode 100644
index 0000000..114d89b
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/pause.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/play-24.png b/src/plugins/qmltooling/declarativeobserver/editor/images/play-24.png
new file mode 100644
index 0000000..e2b9fbc
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/play-24.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/play.png b/src/plugins/qmltooling/declarativeobserver/editor/images/play.png
new file mode 100644
index 0000000..011598a
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/play.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/reload.png b/src/plugins/qmltooling/declarativeobserver/editor/images/reload.png
new file mode 100644
index 0000000..7042bec
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/reload.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/resize_handle.png b/src/plugins/qmltooling/declarativeobserver/editor/images/resize_handle.png
new file mode 100644
index 0000000..2934f25
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/resize_handle.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/select-24.png b/src/plugins/qmltooling/declarativeobserver/editor/images/select-24.png
new file mode 100644
index 0000000..5388a9d
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/select-24.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/select-marquee-24.png b/src/plugins/qmltooling/declarativeobserver/editor/images/select-marquee-24.png
new file mode 100644
index 0000000..0111dda
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/select-marquee-24.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/select-marquee.png b/src/plugins/qmltooling/declarativeobserver/editor/images/select-marquee.png
new file mode 100644
index 0000000..92fe40d
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/select-marquee.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/select.png b/src/plugins/qmltooling/declarativeobserver/editor/images/select.png
new file mode 100644
index 0000000..6722855
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/select.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/to-qml-24.png b/src/plugins/qmltooling/declarativeobserver/editor/images/to-qml-24.png
new file mode 100644
index 0000000..b72450d
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/to-qml-24.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/to-qml.png b/src/plugins/qmltooling/declarativeobserver/editor/images/to-qml.png
new file mode 100644
index 0000000..2ab951f
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/to-qml.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/zoom-24.png b/src/plugins/qmltooling/declarativeobserver/editor/images/zoom-24.png
new file mode 100644
index 0000000..0346200
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/zoom-24.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/images/zoom.png b/src/plugins/qmltooling/declarativeobserver/editor/images/zoom.png
new file mode 100644
index 0000000..17f0da6
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/images/zoom.png
Binary files differ
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/livelayeritem.cpp b/src/plugins/qmltooling/declarativeobserver/editor/livelayeritem.cpp
new file mode 100644
index 0000000..7b508a4
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/livelayeritem.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "livelayeritem_p.h"
+
+#include "../qmlobserverconstants_p.h"
+
+#include <QGraphicsScene>
+
+QT_BEGIN_NAMESPACE
+
+LiveLayerItem::LiveLayerItem(QGraphicsScene* scene)
+ : QGraphicsObject()
+{
+ scene->addItem(this);
+ setZValue(1);
+ setFlag(QGraphicsItem::ItemIsMovable, false);
+}
+
+LiveLayerItem::~LiveLayerItem()
+{
+}
+
+void LiveLayerItem::paint(QPainter * /*painter*/, const QStyleOptionGraphicsItem * /*option*/,
+ QWidget * /*widget*/)
+{
+}
+
+int LiveLayerItem::type() const
+{
+ return Constants::EditorItemType;
+}
+
+QRectF LiveLayerItem::boundingRect() const
+{
+ return childrenBoundingRect();
+}
+
+QList<QGraphicsItem*> LiveLayerItem::findAllChildItems() const
+{
+ return findAllChildItems(this);
+}
+
+QList<QGraphicsItem*> LiveLayerItem::findAllChildItems(const QGraphicsItem *item) const
+{
+ QList<QGraphicsItem*> itemList(item->childItems());
+
+ foreach (QGraphicsItem *childItem, item->childItems())
+ itemList += findAllChildItems(childItem);
+
+ return itemList;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/livelayeritem_p.h b/src/plugins/qmltooling/declarativeobserver/editor/livelayeritem_p.h
new file mode 100644
index 0000000..242e365
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/livelayeritem_p.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LIVELAYERITEM_H
+#define LIVELAYERITEM_H
+
+#include <QtGui/QGraphicsObject>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class LiveLayerItem : public QGraphicsObject
+{
+public:
+ LiveLayerItem(QGraphicsScene *scene);
+ ~LiveLayerItem();
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget = 0);
+ QRectF boundingRect() const;
+ int type() const;
+
+ QList<QGraphicsItem*> findAllChildItems() const;
+
+protected:
+ QList<QGraphicsItem*> findAllChildItems(const QGraphicsItem *item) const;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // LIVELAYERITEM_H
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/liverubberbandselectionmanipulator.cpp b/src/plugins/qmltooling/declarativeobserver/editor/liverubberbandselectionmanipulator.cpp
new file mode 100644
index 0000000..6c37ba5
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/liverubberbandselectionmanipulator.cpp
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "liverubberbandselectionmanipulator_p.h"
+
+#include "../qdeclarativeviewobserver_p_p.h"
+
+#include <QtGui/QGraphicsItem>
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+LiveRubberBandSelectionManipulator::LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem,
+ QDeclarativeViewObserver *editorView)
+ : m_selectionRectangleElement(layerItem),
+ m_editorView(editorView),
+ m_beginFormEditorItem(0),
+ m_isActive(false)
+{
+ m_selectionRectangleElement.hide();
+}
+
+void LiveRubberBandSelectionManipulator::clear()
+{
+ m_selectionRectangleElement.clear();
+ m_isActive = false;
+ m_beginPoint = QPointF();
+ m_itemList.clear();
+ m_oldSelectionList.clear();
+}
+
+QGraphicsItem *LiveRubberBandSelectionManipulator::topFormEditorItem(const QList<QGraphicsItem*>
+ &itemList)
+{
+ if (itemList.isEmpty())
+ return 0;
+
+ return itemList.first();
+}
+
+void LiveRubberBandSelectionManipulator::begin(const QPointF &beginPoint)
+{
+ m_beginPoint = beginPoint;
+ m_selectionRectangleElement.setRect(m_beginPoint, m_beginPoint);
+ m_selectionRectangleElement.show();
+ m_isActive = true;
+ QDeclarativeViewObserverPrivate *observerPrivate
+ = QDeclarativeViewObserverPrivate::get(m_editorView);
+ m_beginFormEditorItem = topFormEditorItem(observerPrivate->selectableItems(beginPoint));
+ m_oldSelectionList = m_editorView->selectedItems();
+}
+
+void LiveRubberBandSelectionManipulator::update(const QPointF &updatePoint)
+{
+ m_selectionRectangleElement.setRect(m_beginPoint, updatePoint);
+}
+
+void LiveRubberBandSelectionManipulator::end()
+{
+ m_oldSelectionList.clear();
+ m_selectionRectangleElement.hide();
+ m_isActive = false;
+}
+
+void LiveRubberBandSelectionManipulator::select(SelectionType selectionType)
+{
+ QDeclarativeViewObserverPrivate *observerPrivate
+ = QDeclarativeViewObserverPrivate::get(m_editorView);
+ QList<QGraphicsItem*> itemList
+ = observerPrivate->selectableItems(m_selectionRectangleElement.rect(),
+ Qt::IntersectsItemShape);
+ QList<QGraphicsItem*> newSelectionList;
+
+ foreach (QGraphicsItem* item, itemList) {
+ if (item
+ && item->parentItem()
+ && !newSelectionList.contains(item)
+ //&& m_beginFormEditorItem->childItems().contains(item) // TODO activate this test
+ )
+ {
+ newSelectionList.append(item);
+ }
+ }
+
+ if (newSelectionList.isEmpty() && m_beginFormEditorItem)
+ newSelectionList.append(m_beginFormEditorItem);
+
+ QList<QGraphicsItem*> resultList;
+
+ switch (selectionType) {
+ case AddToSelection: {
+ resultList.append(m_oldSelectionList);
+ resultList.append(newSelectionList);
+ }
+ break;
+ case ReplaceSelection: {
+ resultList.append(newSelectionList);
+ }
+ break;
+ case RemoveFromSelection: {
+ QSet<QGraphicsItem*> oldSelectionSet(m_oldSelectionList.toSet());
+ QSet<QGraphicsItem*> newSelectionSet(newSelectionList.toSet());
+ resultList.append(oldSelectionSet.subtract(newSelectionSet).toList());
+ }
+ }
+
+ m_editorView->setSelectedItems(resultList);
+}
+
+
+void LiveRubberBandSelectionManipulator::setItems(const QList<QGraphicsItem*> &itemList)
+{
+ m_itemList = itemList;
+}
+
+QPointF LiveRubberBandSelectionManipulator::beginPoint() const
+{
+ return m_beginPoint;
+}
+
+bool LiveRubberBandSelectionManipulator::isActive() const
+{
+ return m_isActive;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/liverubberbandselectionmanipulator_p.h b/src/plugins/qmltooling/declarativeobserver/editor/liverubberbandselectionmanipulator_p.h
new file mode 100644
index 0000000..8d15288
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/liverubberbandselectionmanipulator_p.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef RUBBERBANDSELECTIONMANIPULATOR_H
+#define RUBBERBANDSELECTIONMANIPULATOR_H
+
+#include "liveselectionrectangle_p.h"
+
+#include <QtCore/QPointF>
+
+QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeViewObserver;
+
+class LiveRubberBandSelectionManipulator
+{
+public:
+ enum SelectionType {
+ ReplaceSelection,
+ AddToSelection,
+ RemoveFromSelection
+ };
+
+ LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem,
+ QDeclarativeViewObserver *editorView);
+
+ void setItems(const QList<QGraphicsItem*> &itemList);
+
+ void begin(const QPointF& beginPoint);
+ void update(const QPointF& updatePoint);
+ void end();
+
+ void clear();
+
+ void select(SelectionType selectionType);
+
+ QPointF beginPoint() const;
+
+ bool isActive() const;
+
+protected:
+ QGraphicsItem *topFormEditorItem(const QList<QGraphicsItem*> &itemList);
+
+private:
+ QList<QGraphicsItem*> m_itemList;
+ QList<QGraphicsItem*> m_oldSelectionList;
+ LiveSelectionRectangle m_selectionRectangleElement;
+ QPointF m_beginPoint;
+ QDeclarativeViewObserver *m_editorView;
+ QGraphicsItem *m_beginFormEditorItem;
+ bool m_isActive;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // RUBBERBANDSELECTIONMANIPULATOR_H
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator.cpp b/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator.cpp
new file mode 100644
index 0000000..96e9dbf
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "liveselectionindicator_p.h"
+
+#include "../qdeclarativeviewobserver_p_p.h"
+#include "../qmlobserverconstants_p.h"
+
+#include <QtCore/QDebug>
+
+#include <QtGui/QGraphicsPolygonItem>
+#include <QtGui/QGraphicsObject>
+#include <QtGui/QGraphicsScene>
+#include <QtGui/QPen>
+
+#include <cmath>
+
+QT_BEGIN_NAMESPACE
+
+LiveSelectionIndicator::LiveSelectionIndicator(QDeclarativeViewObserver *editorView,
+ QGraphicsObject *layerItem)
+ : m_layerItem(layerItem), m_view(editorView)
+{
+}
+
+LiveSelectionIndicator::~LiveSelectionIndicator()
+{
+ clear();
+}
+
+void LiveSelectionIndicator::show()
+{
+ foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash.values())
+ item->show();
+}
+
+void LiveSelectionIndicator::hide()
+{
+ foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash.values())
+ item->hide();
+}
+
+void LiveSelectionIndicator::clear()
+{
+ if (!m_layerItem.isNull()) {
+ QHashIterator<QGraphicsItem*, QGraphicsPolygonItem *> iter(m_indicatorShapeHash);
+ while (iter.hasNext()) {
+ iter.next();
+ m_layerItem.data()->scene()->removeItem(iter.value());
+ delete iter.value();
+ }
+ }
+
+ m_indicatorShapeHash.clear();
+
+}
+
+QPolygonF LiveSelectionIndicator::addBoundingRectToPolygon(QGraphicsItem *item, QPolygonF &polygon)
+{
+ // ### remove this if statement when QTBUG-12172 gets fixed
+ if (item->boundingRect() != QRectF(0,0,0,0)) {
+ QPolygonF bounding = item->mapToScene(item->boundingRect());
+ if (bounding.isClosed()) //avoid crashes if there is an infinite scale.
+ polygon = polygon.united(bounding);
+ }
+
+ foreach (QGraphicsItem *child, item->childItems()) {
+ if (!QDeclarativeViewObserverPrivate::get(m_view)->isEditorItem(child))
+ addBoundingRectToPolygon(child, polygon);
+ }
+ return polygon;
+}
+
+void LiveSelectionIndicator::setItems(const QList<QWeakPointer<QGraphicsObject> > &itemList)
+{
+ clear();
+
+ // set selections to also all children if they are not editor items
+
+ foreach (const QWeakPointer<QGraphicsObject> &object, itemList) {
+ if (object.isNull())
+ continue;
+
+ QGraphicsItem *item = object.data();
+
+ QGraphicsPolygonItem *newSelectionIndicatorGraphicsItem
+ = new QGraphicsPolygonItem(m_layerItem.data());
+ if (!m_indicatorShapeHash.contains(item)) {
+ m_indicatorShapeHash.insert(item, newSelectionIndicatorGraphicsItem);
+
+ QPolygonF boundingShapeInSceneSpace;
+ addBoundingRectToPolygon(item, boundingShapeInSceneSpace);
+
+ QRectF boundingRect
+ = m_view->adjustToScreenBoundaries(boundingShapeInSceneSpace.boundingRect());
+ QPolygonF boundingRectInLayerItemSpace = m_layerItem.data()->mapFromScene(boundingRect);
+
+ QPen pen;
+ pen.setColor(QColor(108, 141, 221));
+ newSelectionIndicatorGraphicsItem->setData(Constants::EditorItemDataKey,
+ QVariant(true));
+ newSelectionIndicatorGraphicsItem->setFlag(QGraphicsItem::ItemIsSelectable, false);
+ newSelectionIndicatorGraphicsItem->setPolygon(boundingRectInLayerItemSpace);
+ newSelectionIndicatorGraphicsItem->setPen(pen);
+ }
+ }
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator_p.h b/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator_p.h
new file mode 100644
index 0000000..da95955
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LIVESELECTIONINDICATOR_H
+#define LIVESELECTIONINDICATOR_H
+
+#include <QtCore/QWeakPointer>
+#include <QtCore/QHash>
+
+QT_BEGIN_NAMESPACE
+class QGraphicsObject;
+class QGraphicsPolygonItem;
+class QGraphicsItem;
+class QPolygonF;
+QT_END_NAMESPACE
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeViewObserver;
+
+class LiveSelectionIndicator
+{
+public:
+ LiveSelectionIndicator(QDeclarativeViewObserver* editorView, QGraphicsObject *layerItem);
+ ~LiveSelectionIndicator();
+
+ void show();
+ void hide();
+
+ void clear();
+
+ void setItems(const QList<QWeakPointer<QGraphicsObject> > &itemList);
+
+private:
+ QPolygonF addBoundingRectToPolygon(QGraphicsItem *item, QPolygonF &polygon);
+
+private:
+ QHash<QGraphicsItem*, QGraphicsPolygonItem *> m_indicatorShapeHash;
+ QWeakPointer<QGraphicsObject> m_layerItem;
+ QDeclarativeViewObserver *m_view;
+
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // LIVESELECTIONINDICATOR_H
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/liveselectionrectangle.cpp b/src/plugins/qmltooling/declarativeobserver/editor/liveselectionrectangle.cpp
new file mode 100644
index 0000000..2a1d393
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/liveselectionrectangle.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "liveselectionrectangle_p.h"
+
+#include "../qmlobserverconstants_p.h"
+
+#include <QtGui/QPen>
+#include <QtGui/QGraphicsRectItem>
+#include <QtGui/QGraphicsObject>
+#include <QtGui/QGraphicsScene>
+
+#include <QtCore/QtDebug>
+
+#include <cmath>
+
+QT_BEGIN_NAMESPACE
+
+class SelectionRectShape : public QGraphicsRectItem
+{
+public:
+ SelectionRectShape(QGraphicsItem *parent = 0) : QGraphicsRectItem(parent) {}
+ int type() const { return Constants::EditorItemType; }
+};
+
+LiveSelectionRectangle::LiveSelectionRectangle(QGraphicsObject *layerItem)
+ : m_controlShape(new SelectionRectShape(layerItem)),
+ m_layerItem(layerItem)
+{
+ m_controlShape->setPen(QPen(Qt::black));
+ m_controlShape->setBrush(QColor(128, 128, 128, 50));
+}
+
+LiveSelectionRectangle::~LiveSelectionRectangle()
+{
+ if (m_layerItem)
+ m_layerItem.data()->scene()->removeItem(m_controlShape);
+}
+
+void LiveSelectionRectangle::clear()
+{
+ hide();
+}
+void LiveSelectionRectangle::show()
+{
+ m_controlShape->show();
+}
+
+void LiveSelectionRectangle::hide()
+{
+ m_controlShape->hide();
+}
+
+QRectF LiveSelectionRectangle::rect() const
+{
+ return m_controlShape->mapFromScene(m_controlShape->rect()).boundingRect();
+}
+
+void LiveSelectionRectangle::setRect(const QPointF &firstPoint,
+ const QPointF &secondPoint)
+{
+ double firstX = std::floor(firstPoint.x()) + 0.5;
+ double firstY = std::floor(firstPoint.y()) + 0.5;
+ double secondX = std::floor(secondPoint.x()) + 0.5;
+ double secondY = std::floor(secondPoint.y()) + 0.5;
+ QPointF topLeftPoint(firstX < secondX ? firstX : secondX,
+ firstY < secondY ? firstY : secondY);
+ QPointF bottomRightPoint(firstX > secondX ? firstX : secondX,
+ firstY > secondY ? firstY : secondY);
+
+ QRectF rect(topLeftPoint, bottomRightPoint);
+ m_controlShape->setRect(rect);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/liveselectionrectangle_p.h b/src/plugins/qmltooling/declarativeobserver/editor/liveselectionrectangle_p.h
new file mode 100644
index 0000000..d1bed72
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/liveselectionrectangle_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LIVESELECTIONRECTANGLE_H
+#define LIVESELECTIONRECTANGLE_H
+
+#include <QtCore/QWeakPointer>
+
+QT_FORWARD_DECLARE_CLASS(QGraphicsObject)
+QT_FORWARD_DECLARE_CLASS(QGraphicsRectItem)
+QT_FORWARD_DECLARE_CLASS(QPointF)
+QT_FORWARD_DECLARE_CLASS(QRectF)
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class LiveSelectionRectangle
+{
+public:
+ LiveSelectionRectangle(QGraphicsObject *layerItem);
+ ~LiveSelectionRectangle();
+
+ void show();
+ void hide();
+
+ void clear();
+
+ void setRect(const QPointF &firstPoint,
+ const QPointF &secondPoint);
+
+ QRectF rect() const;
+
+private:
+ QGraphicsRectItem *m_controlShape;
+ QWeakPointer<QGraphicsObject> m_layerItem;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // LIVESELECTIONRECTANGLE_H
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/liveselectiontool.cpp b/src/plugins/qmltooling/declarativeobserver/editor/liveselectiontool.cpp
new file mode 100644
index 0000000..d85926e
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/liveselectiontool.cpp
@@ -0,0 +1,442 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "liveselectiontool_p.h"
+#include "livelayeritem_p.h"
+
+#include "../qdeclarativeviewobserver_p_p.h"
+
+#include <QtGui/QApplication>
+#include <QtGui/QWheelEvent>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QClipboard>
+#include <QtGui/QMenu>
+#include <QtGui/QAction>
+#include <QtGui/QGraphicsObject>
+
+#include <QtDeclarative/QDeclarativeItem>
+#include <QtDeclarative/QDeclarativeEngine>
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+LiveSelectionTool::LiveSelectionTool(QDeclarativeViewObserver *editorView) :
+ AbstractLiveEditTool(editorView),
+ m_rubberbandSelectionMode(false),
+ m_rubberbandSelectionManipulator(
+ QDeclarativeViewObserverPrivate::get(editorView)->manipulatorLayer, editorView),
+ m_singleSelectionManipulator(editorView),
+ m_selectionIndicator(editorView,
+ QDeclarativeViewObserverPrivate::get(editorView)->manipulatorLayer),
+ //m_resizeIndicator(editorView->manipulatorLayer()),
+ m_selectOnlyContentItems(true)
+{
+
+}
+
+LiveSelectionTool::~LiveSelectionTool()
+{
+}
+
+void LiveSelectionTool::setRubberbandSelectionMode(bool value)
+{
+ m_rubberbandSelectionMode = value;
+}
+
+LiveSingleSelectionManipulator::SelectionType LiveSelectionTool::getSelectionType(Qt::KeyboardModifiers
+ modifiers)
+{
+ LiveSingleSelectionManipulator::SelectionType selectionType
+ = LiveSingleSelectionManipulator::ReplaceSelection;
+ if (modifiers.testFlag(Qt::ControlModifier)) {
+ selectionType = LiveSingleSelectionManipulator::RemoveFromSelection;
+ } else if (modifiers.testFlag(Qt::ShiftModifier)) {
+ selectionType = LiveSingleSelectionManipulator::AddToSelection;
+ }
+ return selectionType;
+}
+
+bool LiveSelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) const
+{
+ QDeclarativeViewObserverPrivate *observerPrivate
+ = QDeclarativeViewObserverPrivate::get(observer());
+ const QList<QGraphicsItem*> selectedItems = observerPrivate->selectedItems();
+
+ if (selectedItems.isEmpty())
+ return false;
+
+ foreach (QGraphicsItem *item, itemList)
+ if (selectedItems.contains(item))
+ return true;
+
+ return false;
+}
+
+void LiveSelectionTool::mousePressEvent(QMouseEvent *event)
+{
+ QDeclarativeViewObserverPrivate *observerPrivate
+ = QDeclarativeViewObserverPrivate::get(observer());
+ QList<QGraphicsItem*> itemList = observerPrivate->selectableItems(event->pos());
+ LiveSingleSelectionManipulator::SelectionType selectionType = getSelectionType(event->modifiers());
+
+ if (event->buttons() & Qt::LeftButton) {
+ m_mousePressTimer.start();
+
+ if (m_rubberbandSelectionMode) {
+ m_rubberbandSelectionManipulator.begin(event->pos());
+ } else {
+ m_singleSelectionManipulator.begin(event->pos());
+ m_singleSelectionManipulator.select(selectionType, m_selectOnlyContentItems);
+ }
+ } else if (event->buttons() & Qt::RightButton) {
+ createContextMenu(itemList, event->globalPos());
+ }
+}
+
+void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos)
+{
+ if (!QDeclarativeViewObserverPrivate::get(observer())->mouseInsideContextItem())
+ return;
+
+ QMenu contextMenu;
+ connect(&contextMenu, SIGNAL(hovered(QAction*)),
+ this, SLOT(contextMenuElementHovered(QAction*)));
+
+ m_contextMenuItemList = itemList;
+
+ contextMenu.addAction(tr("Items"));
+ contextMenu.addSeparator();
+ int shortcutKey = Qt::Key_1;
+ bool addKeySequence = true;
+ int i = 0;
+
+ foreach (QGraphicsItem * const item, itemList) {
+ QString itemTitle = titleForItem(item);
+ QAction *elementAction = contextMenu.addAction(itemTitle, this,
+ SLOT(contextMenuElementSelected()));
+
+ if (observer()->selectedItems().contains(item)) {
+ QFont boldFont = elementAction->font();
+ boldFont.setBold(true);
+ elementAction->setFont(boldFont);
+ }
+
+ elementAction->setData(i);
+ if (addKeySequence)
+ elementAction->setShortcut(QKeySequence(shortcutKey));
+
+ shortcutKey++;
+ if (shortcutKey > Qt::Key_9)
+ addKeySequence = false;
+
+ ++i;
+ }
+ // add root item separately
+ // QString itemTitle = QString(tr("%1")).arg(titleForItem(view()->currentRootItem()));
+ // contextMenu.addAction(itemTitle, this, SLOT(contextMenuElementSelected()));
+ // m_contextMenuItemList.append(view()->currentRootItem());
+
+ contextMenu.exec(globalPos);
+ m_contextMenuItemList.clear();
+}
+
+void LiveSelectionTool::contextMenuElementSelected()
+{
+ QAction *senderAction = static_cast<QAction*>(sender());
+ int itemListIndex = senderAction->data().toInt();
+ if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) {
+
+ QPointF updatePt(0, 0);
+ QGraphicsItem *item = m_contextMenuItemList.at(itemListIndex);
+ m_singleSelectionManipulator.begin(updatePt);
+ m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection,
+ QList<QGraphicsItem*>() << item,
+ false);
+ m_singleSelectionManipulator.end(updatePt);
+ enterContext(item);
+ }
+}
+
+void LiveSelectionTool::contextMenuElementHovered(QAction *action)
+{
+ int itemListIndex = action->data().toInt();
+ if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) {
+ QGraphicsObject *item = m_contextMenuItemList.at(itemListIndex)->toGraphicsObject();
+ QDeclarativeViewObserverPrivate::get(observer())->highlight(item);
+ }
+}
+
+void LiveSelectionTool::mouseMoveEvent(QMouseEvent *event)
+{
+ if (m_singleSelectionManipulator.isActive()) {
+ QPointF mouseMovementVector = m_singleSelectionManipulator.beginPoint() - event->pos();
+
+ if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance)
+ && (m_mousePressTimer.elapsed() > Constants::DragStartTime))
+ {
+ m_singleSelectionManipulator.end(event->pos());
+ //view()->changeToMoveTool(m_singleSelectionManipulator.beginPoint());
+ return;
+ }
+ } else if (m_rubberbandSelectionManipulator.isActive()) {
+ QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos();
+
+ if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance)
+ && (m_mousePressTimer.elapsed() > Constants::DragStartTime)) {
+ m_rubberbandSelectionManipulator.update(event->pos());
+
+ if (event->modifiers().testFlag(Qt::ControlModifier))
+ m_rubberbandSelectionManipulator.select(
+ LiveRubberBandSelectionManipulator::RemoveFromSelection);
+ else if (event->modifiers().testFlag(Qt::ShiftModifier))
+ m_rubberbandSelectionManipulator.select(
+ LiveRubberBandSelectionManipulator::AddToSelection);
+ else
+ m_rubberbandSelectionManipulator.select(
+ LiveRubberBandSelectionManipulator::ReplaceSelection);
+ }
+ }
+}
+
+void LiveSelectionTool::hoverMoveEvent(QMouseEvent * event)
+{
+// ### commented out until move tool is re-enabled
+// QList<QGraphicsItem*> itemList = view()->items(event->pos());
+// if (!itemList.isEmpty() && !m_rubberbandSelectionMode) {
+//
+// foreach (QGraphicsItem *item, itemList) {
+// if (item->type() == Constants::ResizeHandleItemType) {
+// ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(item);
+// if (resizeHandle)
+// view()->changeTool(Constants::ResizeToolMode);
+// return;
+// }
+// }
+// if (topSelectedItemIsMovable(itemList))
+// view()->changeTool(Constants::MoveToolMode);
+// }
+ QDeclarativeViewObserverPrivate *observerPrivate
+ = QDeclarativeViewObserverPrivate::get(observer());
+
+ QList<QGraphicsItem*> selectableItemList = observerPrivate->selectableItems(event->pos());
+ if (!selectableItemList.isEmpty()) {
+ QGraphicsObject *item = selectableItemList.first()->toGraphicsObject();
+ if (item)
+ QDeclarativeViewObserverPrivate::get(observer())->highlight(item);
+
+ return;
+ }
+
+ QDeclarativeViewObserverPrivate::get(observer())->clearHighlight();
+}
+
+void LiveSelectionTool::mouseReleaseEvent(QMouseEvent *event)
+{
+ if (m_singleSelectionManipulator.isActive()) {
+ m_singleSelectionManipulator.end(event->pos());
+ }
+ else if (m_rubberbandSelectionManipulator.isActive()) {
+
+ QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos();
+ if (mouseMovementVector.toPoint().manhattanLength() < Constants::DragStartDistance) {
+ m_singleSelectionManipulator.begin(event->pos());
+
+ if (event->modifiers().testFlag(Qt::ControlModifier))
+ m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::RemoveFromSelection,
+ m_selectOnlyContentItems);
+ else if (event->modifiers().testFlag(Qt::ShiftModifier))
+ m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::AddToSelection,
+ m_selectOnlyContentItems);
+ else
+ m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection,
+ m_selectOnlyContentItems);
+
+ m_singleSelectionManipulator.end(event->pos());
+ } else {
+ m_rubberbandSelectionManipulator.update(event->pos());
+
+ if (event->modifiers().testFlag(Qt::ControlModifier))
+ m_rubberbandSelectionManipulator.select(
+ LiveRubberBandSelectionManipulator::RemoveFromSelection);
+ else if (event->modifiers().testFlag(Qt::ShiftModifier))
+ m_rubberbandSelectionManipulator.select(
+ LiveRubberBandSelectionManipulator::AddToSelection);
+ else
+ m_rubberbandSelectionManipulator.select(
+ LiveRubberBandSelectionManipulator::ReplaceSelection);
+
+ m_rubberbandSelectionManipulator.end();
+ }
+ }
+}
+
+void LiveSelectionTool::mouseDoubleClickEvent(QMouseEvent * /*event*/)
+{
+}
+
+void LiveSelectionTool::keyPressEvent(QKeyEvent *event)
+{
+ switch (event->key()) {
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ // disabled for now, cannot move stuff yet.
+ //view()->changeTool(Constants::MoveToolMode);
+ //view()->currentTool()->keyPressEvent(event);
+ break;
+ }
+}
+
+void LiveSelectionTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/)
+{
+
+}
+
+void LiveSelectionTool::wheelEvent(QWheelEvent *event)
+{
+ if (event->orientation() == Qt::Horizontal || m_rubberbandSelectionMode)
+ return;
+
+ QDeclarativeViewObserverPrivate *observerPrivate
+ = QDeclarativeViewObserverPrivate::get(observer());
+ QList<QGraphicsItem*> itemList = observerPrivate->selectableItems(event->pos());
+
+ if (itemList.isEmpty())
+ return;
+
+ int selectedIdx = 0;
+ if (!observer()->selectedItems().isEmpty()) {
+ selectedIdx = itemList.indexOf(observer()->selectedItems().first());
+ if (selectedIdx >= 0) {
+ if (event->delta() > 0) {
+ selectedIdx++;
+ if (selectedIdx == itemList.length())
+ selectedIdx = 0;
+ } else if (event->delta() < 0) {
+ selectedIdx--;
+ if (selectedIdx == -1)
+ selectedIdx = itemList.length() - 1;
+ }
+ } else {
+ selectedIdx = 0;
+ }
+ }
+
+ QPointF updatePt(0, 0);
+ m_singleSelectionManipulator.begin(updatePt);
+ m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::ReplaceSelection,
+ QList<QGraphicsItem*>() << itemList.at(selectedIdx),
+ false);
+ m_singleSelectionManipulator.end(updatePt);
+
+}
+
+void LiveSelectionTool::setSelectOnlyContentItems(bool selectOnlyContentItems)
+{
+ m_selectOnlyContentItems = selectOnlyContentItems;
+}
+
+void LiveSelectionTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
+{
+}
+
+void LiveSelectionTool::clear()
+{
+ view()->setCursor(Qt::ArrowCursor);
+ m_rubberbandSelectionManipulator.clear(),
+ m_singleSelectionManipulator.clear();
+ m_selectionIndicator.clear();
+ //m_resizeIndicator.clear();
+}
+
+void LiveSelectionTool::selectedItemsChanged(const QList<QGraphicsItem*> &itemList)
+{
+ foreach (const QWeakPointer<QGraphicsObject> &obj, m_selectedItemList) {
+ if (!obj.isNull()) {
+ disconnect(obj.data(), SIGNAL(xChanged()), this, SLOT(repaintBoundingRects()));
+ disconnect(obj.data(), SIGNAL(yChanged()), this, SLOT(repaintBoundingRects()));
+ disconnect(obj.data(), SIGNAL(widthChanged()), this, SLOT(repaintBoundingRects()));
+ disconnect(obj.data(), SIGNAL(heightChanged()), this, SLOT(repaintBoundingRects()));
+ disconnect(obj.data(), SIGNAL(rotationChanged()), this, SLOT(repaintBoundingRects()));
+ }
+ }
+
+ QList<QGraphicsObject*> objects = toGraphicsObjectList(itemList);
+ m_selectedItemList.clear();
+
+ foreach (QGraphicsObject *obj, objects) {
+ m_selectedItemList.append(obj);
+ connect(obj, SIGNAL(xChanged()), this, SLOT(repaintBoundingRects()));
+ connect(obj, SIGNAL(yChanged()), this, SLOT(repaintBoundingRects()));
+ connect(obj, SIGNAL(widthChanged()), this, SLOT(repaintBoundingRects()));
+ connect(obj, SIGNAL(heightChanged()), this, SLOT(repaintBoundingRects()));
+ connect(obj, SIGNAL(rotationChanged()), this, SLOT(repaintBoundingRects()));
+ }
+
+ m_selectionIndicator.setItems(m_selectedItemList);
+ //m_resizeIndicator.setItems(toGraphicsObjectList(itemList));
+}
+
+void LiveSelectionTool::repaintBoundingRects()
+{
+ m_selectionIndicator.setItems(m_selectedItemList);
+}
+
+void LiveSelectionTool::selectUnderPoint(QMouseEvent *event)
+{
+ m_singleSelectionManipulator.begin(event->pos());
+
+ if (event->modifiers().testFlag(Qt::ControlModifier))
+ m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::RemoveFromSelection,
+ m_selectOnlyContentItems);
+ else if (event->modifiers().testFlag(Qt::ShiftModifier))
+ m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::AddToSelection,
+ m_selectOnlyContentItems);
+ else
+ m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection,
+ m_selectOnlyContentItems);
+
+ m_singleSelectionManipulator.end(event->pos());
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/liveselectiontool_p.h b/src/plugins/qmltooling/declarativeobserver/editor/liveselectiontool_p.h
new file mode 100644
index 0000000..3daac3d
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/liveselectiontool_p.h
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LIVESELECTIONTOOL_H
+#define LIVESELECTIONTOOL_H
+
+#include "abstractliveedittool_p.h"
+#include "liverubberbandselectionmanipulator_p.h"
+#include "livesingleselectionmanipulator_p.h"
+#include "liveselectionindicator_p.h"
+
+#include <QtCore/QList>
+#include <QtCore/QTime>
+
+QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
+QT_FORWARD_DECLARE_CLASS(QMouseEvent)
+QT_FORWARD_DECLARE_CLASS(QKeyEvent)
+QT_FORWARD_DECLARE_CLASS(QAction)
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class LiveSelectionTool : public AbstractLiveEditTool
+{
+ Q_OBJECT
+
+public:
+ LiveSelectionTool(QDeclarativeViewObserver* editorView);
+ ~LiveSelectionTool();
+
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+ void hoverMoveEvent(QMouseEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+ void keyReleaseEvent(QKeyEvent *keyEvent);
+ void wheelEvent(QWheelEvent *event);
+
+ void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
+// QVariant itemChange(const QList<QGraphicsItem*> &itemList,
+// QGraphicsItem::GraphicsItemChange change,
+// const QVariant &value );
+
+// void update();
+
+ void clear();
+
+ void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
+
+ void selectUnderPoint(QMouseEvent *event);
+
+ void setSelectOnlyContentItems(bool selectOnlyContentItems);
+
+ void setRubberbandSelectionMode(bool value);
+
+private slots:
+ void contextMenuElementSelected();
+ void contextMenuElementHovered(QAction *action);
+ void repaintBoundingRects();
+
+private:
+ void createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos);
+ LiveSingleSelectionManipulator::SelectionType getSelectionType(Qt::KeyboardModifiers modifiers);
+ bool alreadySelected(const QList<QGraphicsItem*> &itemList) const;
+
+private:
+ bool m_rubberbandSelectionMode;
+ LiveRubberBandSelectionManipulator m_rubberbandSelectionManipulator;
+ LiveSingleSelectionManipulator m_singleSelectionManipulator;
+ LiveSelectionIndicator m_selectionIndicator;
+ //ResizeIndicator m_resizeIndicator;
+ QTime m_mousePressTimer;
+ bool m_selectOnlyContentItems;
+
+ QList<QWeakPointer<QGraphicsObject> > m_selectedItemList;
+
+ QList<QGraphicsItem*> m_contextMenuItemList;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // LIVESELECTIONTOOL_H
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/livesingleselectionmanipulator.cpp b/src/plugins/qmltooling/declarativeobserver/editor/livesingleselectionmanipulator.cpp
new file mode 100644
index 0000000..e753b64
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/livesingleselectionmanipulator.cpp
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "livesingleselectionmanipulator_p.h"
+
+#include "../qdeclarativeviewobserver_p_p.h"
+
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+LiveSingleSelectionManipulator::LiveSingleSelectionManipulator(QDeclarativeViewObserver *editorView)
+ : m_editorView(editorView),
+ m_isActive(false)
+{
+}
+
+
+void LiveSingleSelectionManipulator::begin(const QPointF &beginPoint)
+{
+ m_beginPoint = beginPoint;
+ m_isActive = true;
+ m_oldSelectionList = QDeclarativeViewObserverPrivate::get(m_editorView)->selectedItems();
+}
+
+void LiveSingleSelectionManipulator::update(const QPointF &/*updatePoint*/)
+{
+ m_oldSelectionList.clear();
+}
+
+void LiveSingleSelectionManipulator::clear()
+{
+ m_beginPoint = QPointF();
+ m_oldSelectionList.clear();
+}
+
+
+void LiveSingleSelectionManipulator::end(const QPointF &/*updatePoint*/)
+{
+ m_oldSelectionList.clear();
+ m_isActive = false;
+}
+
+void LiveSingleSelectionManipulator::select(SelectionType selectionType,
+ const QList<QGraphicsItem*> &items,
+ bool /*selectOnlyContentItems*/)
+{
+ QGraphicsItem *selectedItem = 0;
+
+ foreach (QGraphicsItem* item, items)
+ {
+ //FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
+ if (item
+ /*&& !formEditorItem->qmlItemNode().isRootNode()
+ && (formEditorItem->qmlItemNode().hasShowContent() || !selectOnlyContentItems)*/)
+ {
+ selectedItem = item;
+ break;
+ }
+ }
+
+ QList<QGraphicsItem*> resultList;
+
+ switch (selectionType) {
+ case AddToSelection: {
+ resultList.append(m_oldSelectionList);
+ if (selectedItem && !m_oldSelectionList.contains(selectedItem))
+ resultList.append(selectedItem);
+ }
+ break;
+ case ReplaceSelection: {
+ if (selectedItem)
+ resultList.append(selectedItem);
+ }
+ break;
+ case RemoveFromSelection: {
+ resultList.append(m_oldSelectionList);
+ if (selectedItem)
+ resultList.removeAll(selectedItem);
+ }
+ break;
+ case InvertSelection: {
+ if (selectedItem
+ && !m_oldSelectionList.contains(selectedItem))
+ {
+ resultList.append(selectedItem);
+ }
+ }
+ }
+
+ m_editorView->setSelectedItems(resultList);
+}
+
+void LiveSingleSelectionManipulator::select(SelectionType selectionType, bool selectOnlyContentItems)
+{
+ QDeclarativeViewObserverPrivate *observerPrivate =
+ QDeclarativeViewObserverPrivate::get(m_editorView);
+ QList<QGraphicsItem*> itemList = observerPrivate->selectableItems(m_beginPoint);
+ select(selectionType, itemList, selectOnlyContentItems);
+}
+
+
+bool LiveSingleSelectionManipulator::isActive() const
+{
+ return m_isActive;
+}
+
+QPointF LiveSingleSelectionManipulator::beginPoint() const
+{
+ return m_beginPoint;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/livesingleselectionmanipulator_p.h b/src/plugins/qmltooling/declarativeobserver/editor/livesingleselectionmanipulator_p.h
new file mode 100644
index 0000000..68329e5
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/livesingleselectionmanipulator_p.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LIVESINGLESELECTIONMANIPULATOR_H
+#define LIVESINGLESELECTIONMANIPULATOR_H
+
+#include <QtCore/QPointF>
+#include <QtCore/QList>
+
+QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeViewObserver;
+
+class LiveSingleSelectionManipulator
+{
+public:
+ LiveSingleSelectionManipulator(QDeclarativeViewObserver *editorView);
+
+ enum SelectionType {
+ ReplaceSelection,
+ AddToSelection,
+ RemoveFromSelection,
+ InvertSelection
+ };
+
+ void begin(const QPointF& beginPoint);
+ void update(const QPointF& updatePoint);
+ void end(const QPointF& updatePoint);
+
+ void select(SelectionType selectionType, const QList<QGraphicsItem*> &items,
+ bool selectOnlyContentItems);
+ void select(SelectionType selectionType, bool selectOnlyContentItems);
+
+ void clear();
+
+ QPointF beginPoint() const;
+
+ bool isActive() const;
+
+private:
+ QList<QGraphicsItem*> m_oldSelectionList;
+ QPointF m_beginPoint;
+ QDeclarativeViewObserver *m_editorView;
+ bool m_isActive;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // LIVESINGLESELECTIONMANIPULATOR_H
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/qmltoolbar.cpp b/src/plugins/qmltooling/declarativeobserver/editor/qmltoolbar.cpp
new file mode 100644
index 0000000..359e9ef
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/qmltoolbar.cpp
@@ -0,0 +1,328 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmltoolbar_p.h"
+#include "toolbarcolorbox_p.h"
+
+#include <QtGui/QLabel>
+#include <QtGui/QIcon>
+#include <QtGui/QAction>
+#include <QtGui/QMenu>
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QmlToolBar::QmlToolBar(QWidget *parent)
+ : QToolBar(parent)
+ , m_emitSignals(true)
+ , m_paused(false)
+ , m_animationSpeed(1.0f)
+ , ui(new Ui)
+{
+ ui->playIcon = QIcon(QLatin1String(":/qml/images/play-24.png"));
+ ui->pauseIcon = QIcon(QLatin1String(":/qml/images/pause-24.png"));
+
+ ui->designmode = new QAction(QIcon(QLatin1String(":/qml/images/observermode-24.png")),
+ tr("Observer Mode"), this);
+ ui->play = new QAction(ui->pauseIcon, tr("Play/Pause Animations"), this);
+ ui->select = new QAction(QIcon(QLatin1String(":/qml/images/select-24.png")), tr("Select"), this);
+ ui->selectMarquee = new QAction(QIcon(QLatin1String(":/qml/images/select-marquee-24.png")),
+ tr("Select (Marquee)"), this);
+ ui->zoom = new QAction(QIcon(QLatin1String(":/qml/images/zoom-24.png")), tr("Zoom"), this);
+ ui->colorPicker = new QAction(QIcon(QLatin1String(":/qml/images/color-picker-24.png")),
+ tr("Color Picker"), this);
+ ui->toQml = new QAction(QIcon(QLatin1String(":/qml/images/to-qml-24.png")),
+ tr("Apply Changes to QML Viewer"), this);
+ ui->fromQml = new QAction(QIcon(QLatin1String(":/qml/images/from-qml-24.png")),
+ tr("Apply Changes to Document"), this);
+ ui->designmode->setCheckable(true);
+ ui->designmode->setChecked(false);
+
+ ui->play->setCheckable(false);
+ ui->select->setCheckable(true);
+ ui->selectMarquee->setCheckable(true);
+ ui->zoom->setCheckable(true);
+ ui->colorPicker->setCheckable(true);
+
+ setWindowTitle(tr("Tools"));
+
+ addAction(ui->designmode);
+ addAction(ui->play);
+ addSeparator();
+
+ addAction(ui->select);
+ // disabled because multi selection does not do anything useful without design mode
+ //addAction(ui->selectMarquee);
+ addSeparator();
+ addAction(ui->zoom);
+ addAction(ui->colorPicker);
+ //addAction(ui->fromQml);
+
+ ui->colorBox = new ToolBarColorBox(this);
+ ui->colorBox->setMinimumSize(24, 24);
+ ui->colorBox->setMaximumSize(28, 28);
+ ui->colorBox->setColor(Qt::black);
+ addWidget(ui->colorBox);
+
+ setWindowFlags(Qt::Tool);
+
+ QMenu *playSpeedMenu = new QMenu(this);
+ ui->playSpeedMenuActions = new QActionGroup(this);
+ ui->playSpeedMenuActions->setExclusive(true);
+
+ QAction *speedAction = playSpeedMenu->addAction(tr("1x"), this, SLOT(changeAnimationSpeed()));
+ speedAction->setCheckable(true);
+ speedAction->setChecked(true);
+ speedAction->setData(1.0f);
+ ui->playSpeedMenuActions->addAction(speedAction);
+
+ speedAction = playSpeedMenu->addAction(tr("0.5x"), this, SLOT(changeAnimationSpeed()));
+ speedAction->setCheckable(true);
+ speedAction->setData(2.0f);
+ ui->playSpeedMenuActions->addAction(speedAction);
+
+ speedAction = playSpeedMenu->addAction(tr("0.25x"), this, SLOT(changeAnimationSpeed()));
+ speedAction->setCheckable(true);
+ speedAction->setData(4.0f);
+ ui->playSpeedMenuActions->addAction(speedAction);
+
+ speedAction = playSpeedMenu->addAction(tr("0.125x"), this, SLOT(changeAnimationSpeed()));
+ speedAction->setCheckable(true);
+ speedAction->setData(8.0f);
+ ui->playSpeedMenuActions->addAction(speedAction);
+
+ speedAction = playSpeedMenu->addAction(tr("0.1x"), this, SLOT(changeAnimationSpeed()));
+ speedAction->setCheckable(true);
+ speedAction->setData(10.0f);
+ ui->playSpeedMenuActions->addAction(speedAction);
+
+ ui->play->setMenu(playSpeedMenu);
+
+ connect(ui->designmode, SIGNAL(toggled(bool)), SLOT(setDesignModeBehaviorOnClick(bool)));
+
+ connect(ui->colorPicker, SIGNAL(triggered()), SLOT(activateColorPickerOnClick()));
+
+ connect(ui->play, SIGNAL(triggered()), SLOT(activatePlayOnClick()));
+
+ connect(ui->zoom, SIGNAL(triggered()), SLOT(activateZoomOnClick()));
+ connect(ui->colorPicker, SIGNAL(triggered()), SLOT(activateColorPickerOnClick()));
+ connect(ui->select, SIGNAL(triggered()), SLOT(activateSelectToolOnClick()));
+ connect(ui->selectMarquee, SIGNAL(triggered()), SLOT(activateMarqueeSelectToolOnClick()));
+
+ connect(ui->toQml, SIGNAL(triggered()), SLOT(activateToQml()));
+ connect(ui->fromQml, SIGNAL(triggered()), SLOT(activateFromQml()));
+}
+
+QmlToolBar::~QmlToolBar()
+{
+ delete ui;
+}
+
+void QmlToolBar::activateColorPicker()
+{
+ m_emitSignals = false;
+ activateColorPickerOnClick();
+ m_emitSignals = true;
+}
+
+void QmlToolBar::activateSelectTool()
+{
+ m_emitSignals = false;
+ activateSelectToolOnClick();
+ m_emitSignals = true;
+}
+
+void QmlToolBar::activateMarqueeSelectTool()
+{
+ m_emitSignals = false;
+ activateMarqueeSelectToolOnClick();
+ m_emitSignals = true;
+}
+
+void QmlToolBar::activateZoom()
+{
+ m_emitSignals = false;
+ activateZoomOnClick();
+ m_emitSignals = true;
+}
+
+void QmlToolBar::setAnimationSpeed(qreal slowDownFactor)
+{
+ if (m_animationSpeed == slowDownFactor)
+ return;
+
+ m_emitSignals = false;
+ m_animationSpeed = slowDownFactor;
+
+ foreach (QAction *action, ui->playSpeedMenuActions->actions()) {
+ if (action->data().toReal() == slowDownFactor) {
+ action->setChecked(true);
+ break;
+ }
+ }
+
+ m_emitSignals = true;
+}
+
+void QmlToolBar::setAnimationPaused(bool paused)
+{
+ if (m_paused == paused)
+ return;
+
+ m_paused = paused;
+ updatePlayAction();
+}
+
+void QmlToolBar::changeAnimationSpeed()
+{
+ QAction *action = qobject_cast<QAction*>(sender());
+ m_animationSpeed = action->data().toReal();
+ emit animationSpeedChanged(m_animationSpeed);
+}
+
+void QmlToolBar::setDesignModeBehavior(bool inDesignMode)
+{
+ m_emitSignals = false;
+ ui->designmode->setChecked(inDesignMode);
+ setDesignModeBehaviorOnClick(inDesignMode);
+ m_emitSignals = true;
+}
+
+void QmlToolBar::setDesignModeBehaviorOnClick(bool checked)
+{
+ ui->select->setEnabled(checked);
+ ui->selectMarquee->setEnabled(checked);
+ ui->zoom->setEnabled(checked);
+ ui->colorPicker->setEnabled(checked);
+ ui->toQml->setEnabled(checked);
+ ui->fromQml->setEnabled(checked);
+
+ if (m_emitSignals)
+ emit designModeBehaviorChanged(checked);
+}
+
+void QmlToolBar::setColorBoxColor(const QColor &color)
+{
+ ui->colorBox->setColor(color);
+}
+
+void QmlToolBar::activatePlayOnClick()
+{
+ m_paused = !m_paused;
+ emit animationPausedChanged(m_paused);
+ updatePlayAction();
+}
+
+void QmlToolBar::updatePlayAction()
+{
+ ui->play->setIcon(m_paused ? ui->playIcon : ui->pauseIcon);
+}
+
+void QmlToolBar::activateColorPickerOnClick()
+{
+ ui->zoom->setChecked(false);
+ ui->select->setChecked(false);
+ ui->selectMarquee->setChecked(false);
+
+ ui->colorPicker->setChecked(true);
+ if (m_activeTool != Constants::ColorPickerMode) {
+ m_activeTool = Constants::ColorPickerMode;
+ if (m_emitSignals)
+ emit colorPickerSelected();
+ }
+}
+
+void QmlToolBar::activateSelectToolOnClick()
+{
+ ui->zoom->setChecked(false);
+ ui->selectMarquee->setChecked(false);
+ ui->colorPicker->setChecked(false);
+
+ ui->select->setChecked(true);
+ if (m_activeTool != Constants::SelectionToolMode) {
+ m_activeTool = Constants::SelectionToolMode;
+ if (m_emitSignals)
+ emit selectToolSelected();
+ }
+}
+
+void QmlToolBar::activateMarqueeSelectToolOnClick()
+{
+ ui->zoom->setChecked(false);
+ ui->select->setChecked(false);
+ ui->colorPicker->setChecked(false);
+
+ ui->selectMarquee->setChecked(true);
+ if (m_activeTool != Constants::MarqueeSelectionToolMode) {
+ m_activeTool = Constants::MarqueeSelectionToolMode;
+ if (m_emitSignals)
+ emit marqueeSelectToolSelected();
+ }
+}
+
+void QmlToolBar::activateZoomOnClick()
+{
+ ui->select->setChecked(false);
+ ui->selectMarquee->setChecked(false);
+ ui->colorPicker->setChecked(false);
+
+ ui->zoom->setChecked(true);
+ if (m_activeTool != Constants::ZoomMode) {
+ m_activeTool = Constants::ZoomMode;
+ if (m_emitSignals)
+ emit zoomToolSelected();
+ }
+}
+
+void QmlToolBar::activateFromQml()
+{
+ if (m_emitSignals)
+ emit applyChangesFromQmlFileSelected();
+}
+
+void QmlToolBar::activateToQml()
+{
+ if (m_emitSignals)
+ emit applyChangesToQmlFileSelected();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/qmltoolbar_p.h b/src/plugins/qmltooling/declarativeobserver/editor/qmltoolbar_p.h
new file mode 100644
index 0000000..459eafd
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/qmltoolbar_p.h
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLTOOLBAR_H
+#define QMLTOOLBAR_H
+
+#include <QtGui/QToolBar>
+#include <QtGui/QIcon>
+
+#include "../qmlobserverconstants_p.h"
+
+QT_FORWARD_DECLARE_CLASS(QActionGroup)
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class ToolBarColorBox;
+
+class QmlToolBar : public QToolBar
+{
+ Q_OBJECT
+
+public:
+ explicit QmlToolBar(QWidget *parent = 0);
+ ~QmlToolBar();
+
+public slots:
+ void setDesignModeBehavior(bool inDesignMode);
+ void setColorBoxColor(const QColor &color);
+ void activateColorPicker();
+ void activateSelectTool();
+ void activateMarqueeSelectTool();
+ void activateZoom();
+
+ void setAnimationSpeed(qreal slowDownFactor);
+ void setAnimationPaused(bool paused);
+
+signals:
+ void animationSpeedChanged(qreal factor);
+ void animationPausedChanged(bool paused);
+
+ void designModeBehaviorChanged(bool inDesignMode);
+ void colorPickerSelected();
+ void selectToolSelected();
+ void marqueeSelectToolSelected();
+ void zoomToolSelected();
+
+ void applyChangesToQmlFileSelected();
+ void applyChangesFromQmlFileSelected();
+
+private slots:
+ void setDesignModeBehaviorOnClick(bool inDesignMode);
+ void activatePlayOnClick();
+ void activateColorPickerOnClick();
+ void activateSelectToolOnClick();
+ void activateMarqueeSelectToolOnClick();
+ void activateZoomOnClick();
+
+ void activateFromQml();
+ void activateToQml();
+
+ void changeAnimationSpeed();
+
+ void updatePlayAction();
+
+private:
+ class Ui {
+ public:
+ QAction *designmode;
+ QAction *play;
+ QAction *select;
+ QAction *selectMarquee;
+ QAction *zoom;
+ QAction *colorPicker;
+ QAction *toQml;
+ QAction *fromQml;
+ QIcon playIcon;
+ QIcon pauseIcon;
+ ToolBarColorBox *colorBox;
+
+ QActionGroup *playSpeedMenuActions;
+ };
+
+ bool m_emitSignals;
+ bool m_paused;
+ qreal m_animationSpeed;
+
+ Constants::DesignTool m_activeTool;
+
+ Ui *ui;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMLTOOLBAR_H
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/subcomponenteditortool.cpp b/src/plugins/qmltooling/declarativeobserver/editor/subcomponenteditortool.cpp
new file mode 100644
index 0000000..ab77296
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/subcomponenteditortool.cpp
@@ -0,0 +1,364 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "subcomponenteditortool_p.h"
+#include "subcomponentmasklayeritem_p.h"
+#include "livelayeritem_p.h"
+
+#include "../qdeclarativeviewobserver_p_p.h"
+
+#include <QtGui/QGraphicsItem>
+#include <QtGui/QGraphicsObject>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QKeyEvent>
+
+#include <QtCore/QTimer>
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+const qreal MaxOpacity = 0.5f;
+
+SubcomponentEditorTool::SubcomponentEditorTool(QDeclarativeViewObserver *view)
+ : AbstractLiveEditTool(view),
+ m_animIncrement(0.05f),
+ m_animTimer(new QTimer(this))
+{
+ QDeclarativeViewObserverPrivate *observerPrivate =
+ QDeclarativeViewObserverPrivate::get(view);
+ m_mask = new SubcomponentMaskLayerItem(view, observerPrivate->manipulatorLayer);
+ connect(m_animTimer, SIGNAL(timeout()), SLOT(animate()));
+ m_animTimer->setInterval(20);
+}
+
+SubcomponentEditorTool::~SubcomponentEditorTool()
+{
+
+}
+
+void SubcomponentEditorTool::mousePressEvent(QMouseEvent * /*event*/)
+{
+
+}
+
+void SubcomponentEditorTool::mouseMoveEvent(QMouseEvent * /*event*/)
+{
+
+}
+
+bool SubcomponentEditorTool::containsCursor(const QPoint &mousePos) const
+{
+ if (!m_currentContext.size())
+ return false;
+
+ QPointF scenePos = view()->mapToScene(mousePos);
+ QRectF itemRect = m_currentContext.top()->boundingRect()
+ | m_currentContext.top()->childrenBoundingRect();
+ QRectF polyRect = m_currentContext.top()->mapToScene(itemRect).boundingRect();
+
+ return polyRect.contains(scenePos);
+}
+
+void SubcomponentEditorTool::mouseReleaseEvent(QMouseEvent * /*event*/)
+{
+
+}
+
+void SubcomponentEditorTool::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ if (event->buttons() & Qt::LeftButton
+ && !containsCursor(event->pos())
+ && m_currentContext.size() > 1)
+ {
+ aboutToPopContext();
+ }
+}
+
+void SubcomponentEditorTool::hoverMoveEvent(QMouseEvent *event)
+{
+ if (!containsCursor(event->pos()) && m_currentContext.size() > 1) {
+ QDeclarativeViewObserverPrivate::get(observer())->clearHighlight();
+ }
+}
+
+void SubcomponentEditorTool::wheelEvent(QWheelEvent * /*event*/)
+{
+
+}
+
+void SubcomponentEditorTool::keyPressEvent(QKeyEvent * /*event*/)
+{
+
+}
+
+void SubcomponentEditorTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/)
+{
+
+}
+
+void SubcomponentEditorTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
+{
+
+}
+
+void SubcomponentEditorTool::animate()
+{
+ if (m_animIncrement > 0) {
+ if (m_mask->opacity() + m_animIncrement < MaxOpacity) {
+ m_mask->setOpacity(m_mask->opacity() + m_animIncrement);
+ } else {
+ m_animTimer->stop();
+ m_mask->setOpacity(MaxOpacity);
+ }
+ } else {
+ if (m_mask->opacity() + m_animIncrement > 0) {
+ m_mask->setOpacity(m_mask->opacity() + m_animIncrement);
+ } else {
+ m_animTimer->stop();
+ m_mask->setOpacity(0);
+ popContext();
+ emit contextPathChanged(m_path);
+ }
+ }
+
+}
+
+void SubcomponentEditorTool::clear()
+{
+ m_currentContext.clear();
+ m_mask->setCurrentItem(0);
+ m_animTimer->stop();
+ m_mask->hide();
+ m_path.clear();
+
+ emit contextPathChanged(m_path);
+ emit cleared();
+}
+
+void SubcomponentEditorTool::selectedItemsChanged(const QList<QGraphicsItem*> &/*itemList*/)
+{
+
+}
+
+void SubcomponentEditorTool::setCurrentItem(QGraphicsItem* contextItem)
+{
+ if (!contextItem)
+ return;
+
+ QGraphicsObject *gfxObject = contextItem->toGraphicsObject();
+ if (!gfxObject)
+ return;
+
+ //QString parentClassName = gfxObject->metaObject()->className();
+ //if (parentClassName.contains(QRegExp("_QMLTYPE_\\d+")))
+
+ bool containsSelectableItems = false;
+ foreach (QGraphicsItem *item, gfxObject->childItems()) {
+ if (item->type() == Constants::EditorItemType
+ || item->type() == Constants::ResizeHandleItemType)
+ {
+ continue;
+ }
+ containsSelectableItems = true;
+ break;
+ }
+
+ if (containsSelectableItems) {
+ m_mask->setCurrentItem(gfxObject);
+ m_mask->setOpacity(0);
+ m_mask->show();
+ m_animIncrement = 0.05f;
+ m_animTimer->start();
+
+ QDeclarativeViewObserverPrivate::get(observer())->clearHighlight();
+ observer()->setSelectedItems(QList<QGraphicsItem*>());
+
+ pushContext(gfxObject);
+ }
+}
+
+QGraphicsItem *SubcomponentEditorTool::firstChildOfContext(QGraphicsItem *item) const
+{
+ if (!item)
+ return 0;
+
+ if (isDirectChildOfContext(item))
+ return item;
+
+ QGraphicsItem *parent = item->parentItem();
+ while (parent) {
+ if (isDirectChildOfContext(parent))
+ return parent;
+ parent = parent->parentItem();
+ }
+
+ return 0;
+}
+
+bool SubcomponentEditorTool::isChildOfContext(QGraphicsItem *item) const
+{
+ return (firstChildOfContext(item) != 0);
+}
+
+bool SubcomponentEditorTool::isDirectChildOfContext(QGraphicsItem *item) const
+{
+ return (item->parentItem() == m_currentContext.top());
+}
+
+bool SubcomponentEditorTool::itemIsChildOfQmlSubComponent(QGraphicsItem *item) const
+{
+ if (item->parentItem() && item->parentItem() != m_currentContext.top()) {
+ QGraphicsObject *parent = item->parentItem()->toGraphicsObject();
+ QString parentClassName = QLatin1String(parent->metaObject()->className());
+
+ if (parentClassName.contains(QRegExp(QLatin1String("_QMLTYPE_\\d+")))) {
+ return true;
+ } else {
+ return itemIsChildOfQmlSubComponent(parent);
+ }
+ }
+
+ return false;
+}
+
+void SubcomponentEditorTool::pushContext(QGraphicsObject *contextItem)
+{
+ connect(contextItem, SIGNAL(destroyed(QObject*)), this, SLOT(contextDestroyed(QObject*)));
+ connect(contextItem, SIGNAL(xChanged()), this, SLOT(resizeMask()));
+ connect(contextItem, SIGNAL(yChanged()), this, SLOT(resizeMask()));
+ connect(contextItem, SIGNAL(widthChanged()), this, SLOT(resizeMask()));
+ connect(contextItem, SIGNAL(heightChanged()), this, SLOT(resizeMask()));
+ connect(contextItem, SIGNAL(rotationChanged()), this, SLOT(resizeMask()));
+
+ m_currentContext.push(contextItem);
+ QString title = titleForItem(contextItem);
+ emit contextPushed(title);
+
+ m_path << title;
+ emit contextPathChanged(m_path);
+}
+
+void SubcomponentEditorTool::aboutToPopContext()
+{
+ if (m_currentContext.size() > 2) {
+ popContext();
+ emit contextPathChanged(m_path);
+ } else {
+ m_animIncrement = -0.05f;
+ m_animTimer->start();
+ }
+}
+
+QGraphicsObject *SubcomponentEditorTool::popContext()
+{
+ QGraphicsObject *popped = m_currentContext.pop();
+ m_path.removeLast();
+
+ emit contextPopped();
+
+ disconnect(popped, SIGNAL(xChanged()), this, SLOT(resizeMask()));
+ disconnect(popped, SIGNAL(yChanged()), this, SLOT(resizeMask()));
+ disconnect(popped, SIGNAL(scaleChanged()), this, SLOT(resizeMask()));
+ disconnect(popped, SIGNAL(widthChanged()), this, SLOT(resizeMask()));
+ disconnect(popped, SIGNAL(heightChanged()), this, SLOT(resizeMask()));
+
+ if (m_currentContext.size() > 1) {
+ QGraphicsObject *item = m_currentContext.top();
+ m_mask->setCurrentItem(item);
+ m_mask->setOpacity(MaxOpacity);
+ m_mask->setVisible(true);
+ } else {
+ m_mask->setVisible(false);
+ }
+
+ return popped;
+}
+
+void SubcomponentEditorTool::resizeMask()
+{
+ QGraphicsObject *item = m_currentContext.top();
+ m_mask->setCurrentItem(item);
+}
+
+QGraphicsObject *SubcomponentEditorTool::currentRootItem() const
+{
+ return m_currentContext.top();
+}
+
+void SubcomponentEditorTool::contextDestroyed(QObject *contextToDestroy)
+{
+ disconnect(contextToDestroy, SIGNAL(destroyed(QObject*)),
+ this, SLOT(contextDestroyed(QObject*)));
+
+ // pop out the whole context - it might not be safe anymore.
+ while (m_currentContext.size() > 1) {
+ m_currentContext.pop();
+ m_path.removeLast();
+ emit contextPopped();
+ }
+ m_mask->setVisible(false);
+
+ emit contextPathChanged(m_path);
+}
+
+QGraphicsObject *SubcomponentEditorTool::setContext(int contextIndex)
+{
+ Q_ASSERT(contextIndex >= 0);
+
+ // sometimes we have to delete the context while user was still clicking around,
+ // so just bail out.
+ if (contextIndex >= m_currentContext.size() -1)
+ return 0;
+
+ while (m_currentContext.size() - 1 > contextIndex) {
+ popContext();
+ }
+ emit contextPathChanged(m_path);
+
+ return m_currentContext.top();
+}
+
+int SubcomponentEditorTool::contextIndex() const
+{
+ return m_currentContext.size() - 1;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/subcomponenteditortool_p.h b/src/plugins/qmltooling/declarativeobserver/editor/subcomponenteditortool_p.h
new file mode 100644
index 0000000..15217eb
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/subcomponenteditortool_p.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SUBCOMPONENTEDITORTOOL_H
+#define SUBCOMPONENTEDITORTOOL_H
+
+#include "abstractliveedittool_p.h"
+
+#include <QtCore/QStack>
+#include <QtCore/QStringList>
+
+QT_FORWARD_DECLARE_CLASS(QGraphicsObject)
+QT_FORWARD_DECLARE_CLASS(QPoint)
+QT_FORWARD_DECLARE_CLASS(QTimer)
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class SubcomponentMaskLayerItem;
+
+class SubcomponentEditorTool : public AbstractLiveEditTool
+{
+ Q_OBJECT
+
+public:
+ SubcomponentEditorTool(QDeclarativeViewObserver *view);
+ ~SubcomponentEditorTool();
+
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+
+ void hoverMoveEvent(QMouseEvent *event);
+ void wheelEvent(QWheelEvent *event);
+
+ void keyPressEvent(QKeyEvent *event);
+ void keyReleaseEvent(QKeyEvent *keyEvent);
+ void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
+
+ void clear();
+
+ bool containsCursor(const QPoint &mousePos) const;
+ bool itemIsChildOfQmlSubComponent(QGraphicsItem *item) const;
+
+ bool isChildOfContext(QGraphicsItem *item) const;
+ bool isDirectChildOfContext(QGraphicsItem *item) const;
+ QGraphicsItem *firstChildOfContext(QGraphicsItem *item) const;
+
+ void setCurrentItem(QGraphicsItem *contextObject);
+
+ void pushContext(QGraphicsObject *contextItem);
+
+ QGraphicsObject *currentRootItem() const;
+ QGraphicsObject *setContext(int contextIndex);
+ int contextIndex() const;
+
+signals:
+ void exitContextRequested();
+ void cleared();
+ void contextPushed(const QString &contextTitle);
+ void contextPopped();
+ void contextPathChanged(const QStringList &path);
+
+protected:
+ void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
+
+private slots:
+ void animate();
+ void contextDestroyed(QObject *context);
+ void resizeMask();
+
+private:
+ QGraphicsObject *popContext();
+ void aboutToPopContext();
+
+private:
+ QStack<QGraphicsObject *> m_currentContext;
+ QStringList m_path;
+
+ qreal m_animIncrement;
+ SubcomponentMaskLayerItem *m_mask;
+ QTimer *m_animTimer;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // SUBCOMPONENTEDITORTOOL_H
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/subcomponentmasklayeritem.cpp b/src/plugins/qmltooling/declarativeobserver/editor/subcomponentmasklayeritem.cpp
new file mode 100644
index 0000000..15d2a2c
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/subcomponentmasklayeritem.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "subcomponentmasklayeritem_p.h"
+
+#include "../qmlobserverconstants_p.h"
+#include "../qdeclarativeviewobserver_p.h"
+
+#include <QtGui/QPolygonF>
+
+QT_BEGIN_NAMESPACE
+
+SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeViewObserver *observer,
+ QGraphicsItem *parentItem) :
+ QGraphicsPolygonItem(parentItem),
+ m_observer(observer),
+ m_currentItem(0),
+ m_borderRect(new QGraphicsRectItem(this))
+{
+ m_borderRect->setRect(0,0,0,0);
+ m_borderRect->setPen(QPen(QColor(60, 60, 60), 1));
+ m_borderRect->setData(Constants::EditorItemDataKey, QVariant(true));
+
+ setBrush(QBrush(QColor(160,160,160)));
+ setPen(Qt::NoPen);
+}
+
+int SubcomponentMaskLayerItem::type() const
+{
+ return Constants::EditorItemType;
+}
+
+static QRectF resizeRect(const QRectF &newRect, const QRectF &oldRect)
+{
+ QRectF result = newRect;
+ if (oldRect.left() < newRect.left())
+ result.setLeft(oldRect.left());
+
+ if (oldRect.top() < newRect.top())
+ result.setTop(oldRect.top());
+
+ if (oldRect.right() > newRect.right())
+ result.setRight(oldRect.right());
+
+ if (oldRect.bottom() > newRect.bottom())
+ result.setBottom(oldRect.bottom());
+
+ return result;
+}
+
+
+void SubcomponentMaskLayerItem::setCurrentItem(QGraphicsItem *item)
+{
+ QGraphicsItem *prevItem = m_currentItem;
+ m_currentItem = item;
+
+ if (!m_currentItem)
+ return;
+
+ QPolygonF viewPoly(QRectF(m_observer->declarativeView()->rect()));
+ viewPoly = m_observer->declarativeView()->mapToScene(viewPoly.toPolygon());
+
+ QRectF itemRect = item->boundingRect() | item->childrenBoundingRect();
+ QPolygonF itemPoly(itemRect);
+ itemPoly = item->mapToScene(itemPoly);
+
+ // if updating the same item as before, resize the rectangle only bigger, not smaller.
+ if (prevItem == item && prevItem != 0) {
+ m_itemPolyRect = resizeRect(itemPoly.boundingRect(), m_itemPolyRect);
+ } else {
+ m_itemPolyRect = itemPoly.boundingRect();
+ }
+ QRectF borderRect = m_itemPolyRect;
+ borderRect.adjust(-1, -1, 1, 1);
+ m_borderRect->setRect(borderRect);
+
+ itemPoly = viewPoly.subtracted(QPolygonF(m_itemPolyRect));
+ setPolygon(itemPoly);
+}
+
+QGraphicsItem *SubcomponentMaskLayerItem::currentItem() const
+{
+ return m_currentItem;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/subcomponentmasklayeritem_p.h b/src/plugins/qmltooling/declarativeobserver/editor/subcomponentmasklayeritem_p.h
new file mode 100644
index 0000000..e0b892d
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/subcomponentmasklayeritem_p.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SUBCOMPONENTMASKLAYERITEM_H
+#define SUBCOMPONENTMASKLAYERITEM_H
+
+#include <QtGui/QGraphicsPolygonItem>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeViewObserver;
+
+class SubcomponentMaskLayerItem : public QGraphicsPolygonItem
+{
+public:
+ explicit SubcomponentMaskLayerItem(QDeclarativeViewObserver *observer,
+ QGraphicsItem *parentItem = 0);
+ int type() const;
+ void setCurrentItem(QGraphicsItem *item);
+ void setBoundingBox(const QRectF &boundingBox);
+ QGraphicsItem *currentItem() const;
+ QRectF itemRect() const;
+
+private:
+ QDeclarativeViewObserver *m_observer;
+ QGraphicsItem *m_currentItem;
+ QGraphicsRectItem *m_borderRect;
+ QRectF m_itemPolyRect;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // SUBCOMPONENTMASKLAYERITEM_H
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/toolbarcolorbox.cpp b/src/plugins/qmltooling/declarativeobserver/editor/toolbarcolorbox.cpp
new file mode 100644
index 0000000..35582fb
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/toolbarcolorbox.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "toolbarcolorbox_p.h"
+
+#include "../qmlobserverconstants_p.h"
+
+#include <QtGui/QPixmap>
+#include <QtGui/QPainter>
+#include <QtGui/QMenu>
+#include <QtGui/QAction>
+#include <QtGui/QContextMenuEvent>
+#include <QtGui/QClipboard>
+#include <QtGui/QApplication>
+#include <QtGui/QColorDialog>
+#include <QtGui/QDrag>
+
+#include <QtCore/QMimeData>
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+ToolBarColorBox::ToolBarColorBox(QWidget *parent) :
+ QLabel(parent)
+{
+ m_copyHexColor = new QAction(QIcon(QLatin1String(":/qml/images/color-picker-hicontrast.png")),
+ tr("Copy Color"), this);
+ connect(m_copyHexColor, SIGNAL(triggered()), SLOT(copyColorToClipboard()));
+ setScaledContents(false);
+}
+
+void ToolBarColorBox::setColor(const QColor &color)
+{
+ m_color = color;
+
+ QPixmap pix = createDragPixmap(width());
+ setPixmap(pix);
+ update();
+}
+
+void ToolBarColorBox::mousePressEvent(QMouseEvent *event)
+{
+ m_dragBeginPoint = event->pos();
+ m_dragStarted = false;
+}
+
+void ToolBarColorBox::mouseMoveEvent(QMouseEvent *event)
+{
+
+ if (event->buttons() & Qt::LeftButton
+ && (QPoint(event->pos() - m_dragBeginPoint).manhattanLength()
+ > Constants::DragStartDistance)
+ && !m_dragStarted)
+ {
+ m_dragStarted = true;
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ mimeData->setText(m_color.name());
+ drag->setMimeData(mimeData);
+ drag->setPixmap(createDragPixmap());
+
+ drag->exec();
+ }
+}
+
+QPixmap ToolBarColorBox::createDragPixmap(int size) const
+{
+ QPixmap pix(size, size);
+ QPainter p(&pix);
+
+ QColor borderColor1 = QColor(143, 143 ,143);
+ QColor borderColor2 = QColor(43, 43, 43);
+
+ p.setBrush(QBrush(m_color));
+ p.setPen(QPen(QBrush(borderColor2),1));
+
+ p.fillRect(0, 0, size, size, borderColor1);
+ p.drawRect(1,1, size - 3, size - 3);
+ return pix;
+}
+
+void ToolBarColorBox::contextMenuEvent(QContextMenuEvent *ev)
+{
+ QMenu contextMenu;
+ contextMenu.addAction(m_copyHexColor);
+ contextMenu.exec(ev->globalPos());
+}
+
+void ToolBarColorBox::copyColorToClipboard()
+{
+ QClipboard *clipboard = QApplication::clipboard();
+ clipboard->setText(m_color.name());
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/toolbarcolorbox_p.h b/src/plugins/qmltooling/declarativeobserver/editor/toolbarcolorbox_p.h
new file mode 100644
index 0000000..d4914fa
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/toolbarcolorbox_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TOOLBARCOLORBOX_H
+#define TOOLBARCOLORBOX_H
+
+#include <QtGui/QLabel>
+#include <QtGui/QColor>
+#include <QtCore/QPoint>
+
+QT_FORWARD_DECLARE_CLASS(QContextMenuEvent)
+QT_FORWARD_DECLARE_CLASS(QAction)
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class ToolBarColorBox : public QLabel
+{
+ Q_OBJECT
+
+public:
+ explicit ToolBarColorBox(QWidget *parent = 0);
+ void setColor(const QColor &color);
+
+protected:
+ void contextMenuEvent(QContextMenuEvent *ev);
+ void mousePressEvent(QMouseEvent *ev);
+ void mouseMoveEvent(QMouseEvent *ev);
+private slots:
+ void copyColorToClipboard();
+
+private:
+ QPixmap createDragPixmap(int size = 24) const;
+
+private:
+ bool m_dragStarted;
+ QPoint m_dragBeginPoint;
+ QAction *m_copyHexColor;
+ QColor m_color;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // TOOLBARCOLORBOX_H
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/zoomtool.cpp b/src/plugins/qmltooling/declarativeobserver/editor/zoomtool.cpp
new file mode 100644
index 0000000..b70cda5
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/zoomtool.cpp
@@ -0,0 +1,336 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "zoomtool_p.h"
+
+#include "../qdeclarativeviewobserver_p_p.h"
+
+#include <QtGui/QMouseEvent>
+#include <QtGui/QWheelEvent>
+#include <QtGui/QKeyEvent>
+#include <QtGui/QMenu>
+#include <QtGui/QAction>
+
+#include <QtCore/QRectF>
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+ZoomTool::ZoomTool(QDeclarativeViewObserver *view) :
+ AbstractLiveEditTool(view),
+ m_rubberbandManipulator(),
+ m_smoothZoomMultiplier(0.05f),
+ m_currentScale(1.0f)
+{
+ m_zoomTo100Action = new QAction(tr("Zoom to &100%"), this);
+ m_zoomInAction = new QAction(tr("Zoom In"), this);
+ m_zoomOutAction = new QAction(tr("Zoom Out"), this);
+ m_zoomInAction->setShortcut(QKeySequence(Qt::Key_Plus));
+ m_zoomOutAction->setShortcut(QKeySequence(Qt::Key_Minus));
+
+
+ LiveLayerItem *layerItem = QDeclarativeViewObserverPrivate::get(view)->manipulatorLayer;
+ QGraphicsObject *layerObject = reinterpret_cast<QGraphicsObject *>(layerItem);
+ m_rubberbandManipulator = new LiveRubberBandSelectionManipulator(layerObject, view);
+
+
+ connect(m_zoomTo100Action, SIGNAL(triggered()), SLOT(zoomTo100()));
+ connect(m_zoomInAction, SIGNAL(triggered()), SLOT(zoomIn()));
+ connect(m_zoomOutAction, SIGNAL(triggered()), SLOT(zoomOut()));
+}
+
+ZoomTool::~ZoomTool()
+{
+ delete m_rubberbandManipulator;
+}
+
+void ZoomTool::mousePressEvent(QMouseEvent *event)
+{
+ m_mousePos = event->pos();
+
+ QPointF scenePos = view()->mapToScene(event->pos());
+
+ if (event->buttons() & Qt::RightButton) {
+ QMenu contextMenu;
+ contextMenu.addAction(m_zoomTo100Action);
+ contextMenu.addSeparator();
+ contextMenu.addAction(m_zoomInAction);
+ contextMenu.addAction(m_zoomOutAction);
+ contextMenu.exec(event->globalPos());
+ } else if (event->buttons() & Qt::LeftButton) {
+ m_dragBeginPos = scenePos;
+ m_dragStarted = false;
+ }
+}
+
+void ZoomTool::mouseMoveEvent(QMouseEvent *event)
+{
+ m_mousePos = event->pos();
+
+ QPointF scenePos = view()->mapToScene(event->pos());
+
+ if (event->buttons() & Qt::LeftButton
+ && (QPointF(scenePos - m_dragBeginPos).manhattanLength()
+ > Constants::DragStartDistance / 3)
+ && !m_dragStarted)
+ {
+ m_dragStarted = true;
+ m_rubberbandManipulator->begin(m_dragBeginPos);
+ return;
+ }
+
+ if (m_dragStarted)
+ m_rubberbandManipulator->update(scenePos);
+
+}
+
+void ZoomTool::mouseReleaseEvent(QMouseEvent *event)
+{
+ m_mousePos = event->pos();
+ QPointF scenePos = view()->mapToScene(event->pos());
+
+ if (m_dragStarted) {
+ m_rubberbandManipulator->end();
+
+ int x1 = qMin(scenePos.x(), m_rubberbandManipulator->beginPoint().x());
+ int x2 = qMax(scenePos.x(), m_rubberbandManipulator->beginPoint().x());
+ int y1 = qMin(scenePos.y(), m_rubberbandManipulator->beginPoint().y());
+ int y2 = qMax(scenePos.y(), m_rubberbandManipulator->beginPoint().y());
+
+ QPointF scenePosTopLeft = QPoint(x1, y1);
+ QPointF scenePosBottomRight = QPoint(x2, y2);
+
+ QRectF sceneArea(scenePosTopLeft, scenePosBottomRight);
+
+ m_currentScale = qMin(view()->rect().width() / sceneArea.width(),
+ view()->rect().height() / sceneArea.height());
+
+
+ QTransform transform;
+ transform.scale(m_currentScale, m_currentScale);
+
+ view()->setTransform(transform);
+ view()->setSceneRect(sceneArea);
+ } else {
+ Qt::KeyboardModifier modifierKey = Qt::ControlModifier;
+#ifdef Q_WS_MAC
+ modifierKey = Qt::AltModifier;
+#endif
+ if (event->modifiers() & modifierKey) {
+ zoomOut();
+ } else {
+ zoomIn();
+ }
+ }
+}
+
+void ZoomTool::zoomIn()
+{
+ m_currentScale = nextZoomScale(ZoomIn);
+ scaleView(view()->mapToScene(m_mousePos));
+}
+
+void ZoomTool::zoomOut()
+{
+ m_currentScale = nextZoomScale(ZoomOut);
+ scaleView(view()->mapToScene(m_mousePos));
+}
+
+void ZoomTool::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ m_mousePos = event->pos();
+}
+
+
+void ZoomTool::hoverMoveEvent(QMouseEvent *event)
+{
+ m_mousePos = event->pos();
+}
+
+
+void ZoomTool::keyPressEvent(QKeyEvent * /*event*/)
+{
+}
+
+void ZoomTool::wheelEvent(QWheelEvent *event)
+{
+ if (event->orientation() != Qt::Vertical)
+ return;
+
+ Qt::KeyboardModifier smoothZoomModifier = Qt::ControlModifier;
+ if (event->modifiers() & smoothZoomModifier) {
+ int numDegrees = event->delta() / 8;
+ m_currentScale += m_smoothZoomMultiplier * (numDegrees / 15.0f);
+
+ scaleView(view()->mapToScene(m_mousePos));
+
+ } else if (!event->modifiers()) {
+ if (event->delta() > 0) {
+ m_currentScale = nextZoomScale(ZoomIn);
+ } else if (event->delta() < 0) {
+ m_currentScale = nextZoomScale(ZoomOut);
+ }
+ scaleView(view()->mapToScene(m_mousePos));
+ }
+}
+
+void ZoomTool::keyReleaseEvent(QKeyEvent *event)
+{
+ switch (event->key()) {
+ case Qt::Key_Plus:
+ zoomIn();
+ break;
+ case Qt::Key_Minus:
+ zoomOut();
+ break;
+ case Qt::Key_1:
+ case Qt::Key_2:
+ case Qt::Key_3:
+ case Qt::Key_4:
+ case Qt::Key_5:
+ case Qt::Key_6:
+ case Qt::Key_7:
+ case Qt::Key_8:
+ case Qt::Key_9:
+ {
+ m_currentScale = ((event->key() - Qt::Key_0) * 1.0f);
+ scaleView(view()->mapToScene(m_mousePos)); // view()->mapToScene(view()->rect().center())
+ break;
+ }
+
+ default:
+ break;
+ }
+
+}
+
+void ZoomTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
+{
+}
+
+void ZoomTool::clear()
+{
+ view()->setCursor(Qt::ArrowCursor);
+}
+
+void ZoomTool::selectedItemsChanged(const QList<QGraphicsItem*> &/*itemList*/)
+{
+}
+
+void ZoomTool::scaleView(const QPointF &centerPos)
+{
+
+ QTransform transform;
+ transform.scale(m_currentScale, m_currentScale);
+ view()->setTransform(transform);
+
+ QPointF adjustedCenterPos = centerPos;
+ QSize rectSize(view()->rect().width() / m_currentScale,
+ view()->rect().height() / m_currentScale);
+
+ QRectF sceneRect;
+ if (qAbs(m_currentScale - 1.0f) < Constants::ZoomSnapDelta) {
+ adjustedCenterPos.rx() = rectSize.width() / 2;
+ adjustedCenterPos.ry() = rectSize.height() / 2;
+ }
+
+ if (m_currentScale < 1.0f) {
+ adjustedCenterPos.rx() = rectSize.width() / 2;
+ adjustedCenterPos.ry() = rectSize.height() / 2;
+ sceneRect.setRect(view()->rect().width() / 2 -rectSize.width() / 2,
+ view()->rect().height() / 2 -rectSize.height() / 2,
+ rectSize.width(),
+ rectSize.height());
+ } else {
+ sceneRect.setRect(adjustedCenterPos.x() - rectSize.width() / 2,
+ adjustedCenterPos.y() - rectSize.height() / 2,
+ rectSize.width(),
+ rectSize.height());
+ }
+
+ view()->setSceneRect(sceneRect);
+}
+
+void ZoomTool::zoomTo100()
+{
+ m_currentScale = 1.0f;
+ scaleView(view()->mapToScene(view()->rect().center()));
+}
+
+qreal ZoomTool::nextZoomScale(ZoomDirection direction) const
+{
+ static QList<qreal> zoomScales =
+ QList<qreal>()
+ << 0.125f
+ << 1.0f / 6.0f
+ << 0.25f
+ << 1.0f / 3.0f
+ << 0.5f
+ << 2.0f / 3.0f
+ << 1.0f
+ << 2.0f
+ << 3.0f
+ << 4.0f
+ << 5.0f
+ << 6.0f
+ << 7.0f
+ << 8.0f
+ << 12.0f
+ << 16.0f
+ << 32.0f
+ << 48.0f;
+
+ if (direction == ZoomIn) {
+ for (int i = 0; i < zoomScales.length(); ++i) {
+ if (zoomScales[i] > m_currentScale || i == zoomScales.length() - 1)
+ return zoomScales[i];
+ }
+ } else {
+ for (int i = zoomScales.length() - 1; i >= 0; --i) {
+ if (zoomScales[i] < m_currentScale || i == 0)
+ return zoomScales[i];
+ }
+ }
+
+ return 1.0f;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/zoomtool_p.h b/src/plugins/qmltooling/declarativeobserver/editor/zoomtool_p.h
new file mode 100644
index 0000000..6734cf9
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/editor/zoomtool_p.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ZOOMTOOL_H
+#define ZOOMTOOL_H
+
+#include "abstractliveedittool_p.h"
+#include "liverubberbandselectionmanipulator_p.h"
+
+QT_FORWARD_DECLARE_CLASS(QAction)
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class ZoomTool : public AbstractLiveEditTool
+{
+ Q_OBJECT
+
+public:
+ enum ZoomDirection {
+ ZoomIn,
+ ZoomOut
+ };
+
+ explicit ZoomTool(QDeclarativeViewObserver *view);
+
+ virtual ~ZoomTool();
+
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+
+ void hoverMoveEvent(QMouseEvent *event);
+ void wheelEvent(QWheelEvent *event);
+
+ void keyPressEvent(QKeyEvent *event);
+ void keyReleaseEvent(QKeyEvent *keyEvent);
+ void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
+
+ void clear();
+
+protected:
+ void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
+
+private slots:
+ void zoomTo100();
+ void zoomIn();
+ void zoomOut();
+
+private:
+ qreal nextZoomScale(ZoomDirection direction) const;
+ void scaleView(const QPointF &centerPos);
+
+private:
+ bool m_dragStarted;
+ QPoint m_mousePos; // in view coords
+ QPointF m_dragBeginPos;
+ QAction *m_zoomTo100Action;
+ QAction *m_zoomInAction;
+ QAction *m_zoomOutAction;
+ LiveRubberBandSelectionManipulator *m_rubberbandManipulator;
+
+ qreal m_smoothZoomMultiplier;
+ qreal m_currentScale;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // ZOOMTOOL_H
diff --git a/src/plugins/qmltooling/declarativeobserver/qdeclarativeobserverplugin.cpp b/src/plugins/qmltooling/declarativeobserver/qdeclarativeobserverplugin.cpp
new file mode 100644
index 0000000..458b7ef
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/qdeclarativeobserverplugin.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeobserverplugin.h"
+
+#include "qdeclarativeviewobserver_p.h"
+
+#include <QtCore/qplugin.h>
+#include <QtDeclarative/private/qdeclarativeobserverservice_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeObserverPlugin::QDeclarativeObserverPlugin() :
+ m_observer(0)
+{
+}
+
+QDeclarativeObserverPlugin::~QDeclarativeObserverPlugin()
+{
+ delete m_observer;
+}
+
+void QDeclarativeObserverPlugin::activate()
+{
+ QDeclarativeObserverService *service = QDeclarativeObserverService::instance();
+ QList<QDeclarativeView*> views = service->views();
+ if (views.isEmpty())
+ return;
+
+ // TODO: Support multiple views
+ QDeclarativeView *view = service->views().at(0);
+ m_observer = new QDeclarativeViewObserver(view, view);
+}
+
+void QDeclarativeObserverPlugin::deactivate()
+{
+ delete m_observer;
+}
+
+Q_EXPORT_PLUGIN2(declarativeobserver, QDeclarativeObserverPlugin)
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/qmltooling/declarativeobserver/qdeclarativeobserverplugin.h b/src/plugins/qmltooling/declarativeobserver/qdeclarativeobserverplugin.h
new file mode 100644
index 0000000..82d3dbc
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/qdeclarativeobserverplugin.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEOBSERVERPLUGIN_H
+#define QDECLARATIVEOBSERVERPLUGIN_H
+
+#include <QtCore/QPointer>
+#include <QtDeclarative/private/qdeclarativeobserverinterface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeViewObserver;
+
+class QDeclarativeObserverPlugin : public QObject, public QDeclarativeObserverInterface
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(QDeclarativeObserverPlugin)
+ Q_INTERFACES(QDeclarativeObserverInterface)
+
+public:
+ QDeclarativeObserverPlugin();
+ ~QDeclarativeObserverPlugin();
+
+ void activate();
+ void deactivate();
+
+private:
+ QPointer<QDeclarativeViewObserver> m_observer;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEOBSERVERPLUGIN_H
diff --git a/src/plugins/qmltooling/declarativeobserver/qdeclarativeobserverprotocol.h b/src/plugins/qmltooling/declarativeobserver/qdeclarativeobserverprotocol.h
new file mode 100644
index 0000000..eb46693
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/qdeclarativeobserverprotocol.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEOBSERVERPROTOCOL_H
+#define QDECLARATIVEOBSERVERPROTOCOL_H
+
+#include <QtCore/QDebug>
+#include <QtCore/QMetaType>
+#include <QtCore/QMetaEnum>
+#include <QtCore/QObject>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class ObserverProtocol : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(Message Tool)
+
+public:
+ enum Message {
+ AnimationSpeedChanged = 0,
+ AnimationPausedChanged = 19, // highest value
+ ChangeTool = 1,
+ ClearComponentCache = 2,
+ ColorChanged = 3,
+ ContextPathUpdated = 4,
+ CreateObject = 5,
+ CurrentObjectsChanged = 6,
+ DestroyObject = 7,
+ MoveObject = 8,
+ ObjectIdList = 9,
+ Reload = 10,
+ Reloaded = 11,
+ SetAnimationSpeed = 12,
+ SetAnimationPaused = 18,
+ SetContextPathIdx = 13,
+ SetCurrentObjects = 14,
+ SetDesignMode = 15,
+ ShowAppOnTop = 16,
+ ToolChanged = 17
+ };
+
+ enum Tool {
+ ColorPickerTool,
+ SelectMarqueeTool,
+ SelectTool,
+ ZoomTool
+ };
+
+ static inline QString toString(Message message)
+ {
+ return QLatin1String(staticMetaObject.enumerator(0).valueToKey(message));
+ }
+
+ static inline QString toString(Tool tool)
+ {
+ return QLatin1String(staticMetaObject.enumerator(1).valueToKey(tool));
+ }
+};
+
+inline QDataStream & operator<< (QDataStream &stream, ObserverProtocol::Message message)
+{
+ return stream << static_cast<quint32>(message);
+}
+
+inline QDataStream & operator>> (QDataStream &stream, ObserverProtocol::Message &message)
+{
+ quint32 i;
+ stream >> i;
+ message = static_cast<ObserverProtocol::Message>(i);
+ return stream;
+}
+
+inline QDebug operator<< (QDebug dbg, ObserverProtocol::Message message)
+{
+ dbg << ObserverProtocol::toString(message);
+ return dbg;
+}
+
+inline QDataStream & operator<< (QDataStream &stream, ObserverProtocol::Tool tool)
+{
+ return stream << static_cast<quint32>(tool);
+}
+
+inline QDataStream & operator>> (QDataStream &stream, ObserverProtocol::Tool &tool)
+{
+ quint32 i;
+ stream >> i;
+ tool = static_cast<ObserverProtocol::Tool>(i);
+ return stream;
+}
+
+inline QDebug operator<< (QDebug dbg, ObserverProtocol::Tool tool)
+{
+ dbg << ObserverProtocol::toString(tool);
+ return dbg;
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEOBSERVERPROTOCOL_H
diff --git a/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp
new file mode 100644
index 0000000..2286990
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp
@@ -0,0 +1,1167 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "QtDeclarative/private/qdeclarativeobserverservice_p.h"
+#include "QtDeclarative/private/qdeclarativedebughelper_p.h"
+
+#include "qdeclarativeviewobserver_p.h"
+#include "qdeclarativeviewobserver_p_p.h"
+#include "qdeclarativeobserverprotocol.h"
+
+#include "editor/liveselectiontool_p.h"
+#include "editor/zoomtool_p.h"
+#include "editor/colorpickertool_p.h"
+#include "editor/livelayeritem_p.h"
+#include "editor/boundingrecthighlighter_p.h"
+#include "editor/subcomponenteditortool_p.h"
+#include "editor/qmltoolbar_p.h"
+
+#include <QtDeclarative/QDeclarativeItem>
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtDeclarative/QDeclarativeContext>
+#include <QtDeclarative/QDeclarativeExpression>
+#include <QtGui/QWidget>
+#include <QtGui/QVBoxLayout>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QGraphicsObject>
+#include <QtGui/QApplication>
+#include <QtCore/QSettings>
+
+static inline void initEditorResource() { Q_INIT_RESOURCE(editor); }
+
+QT_BEGIN_NAMESPACE
+
+const char * const KEY_TOOLBOX_GEOMETRY = "toolBox/geometry";
+
+const int SceneChangeUpdateInterval = 5000;
+
+
+class ToolBox : public QWidget
+{
+ Q_OBJECT
+
+public:
+ ToolBox(QWidget *parent = 0);
+ ~ToolBox();
+
+ QmlToolBar *toolBar() const { return m_toolBar; }
+
+private:
+ QSettings m_settings;
+ QmlToolBar *m_toolBar;
+};
+
+ToolBox::ToolBox(QWidget *parent)
+ : QWidget(parent, Qt::Tool)
+ , m_settings(QLatin1String("Nokia"), QLatin1String("QmlObserver"), this)
+ , m_toolBar(new QmlToolBar)
+{
+ setWindowFlags((windowFlags() & ~Qt::WindowCloseButtonHint) | Qt::CustomizeWindowHint);
+ setWindowTitle(tr("Qt Quick Toolbox"));
+
+ QVBoxLayout *verticalLayout = new QVBoxLayout;
+ verticalLayout->setMargin(0);
+ verticalLayout->addWidget(m_toolBar);
+ setLayout(verticalLayout);
+
+ restoreGeometry(m_settings.value(QLatin1String(KEY_TOOLBOX_GEOMETRY)).toByteArray());
+}
+
+ToolBox::~ToolBox()
+{
+ m_settings.setValue(QLatin1String(KEY_TOOLBOX_GEOMETRY), saveGeometry());
+}
+
+
+QDeclarativeViewObserverPrivate::QDeclarativeViewObserverPrivate(QDeclarativeViewObserver *q) :
+ q(q),
+ designModeBehavior(false),
+ showAppOnTop(false),
+ animationPaused(false),
+ slowDownFactor(1.0f),
+ toolBox(0)
+{
+}
+
+QDeclarativeViewObserverPrivate::~QDeclarativeViewObserverPrivate()
+{
+}
+
+QDeclarativeViewObserver::QDeclarativeViewObserver(QDeclarativeView *view,
+ QObject *parent) :
+ QObject(parent),
+ data(new QDeclarativeViewObserverPrivate(this))
+{
+ initEditorResource();
+
+ data->view = view;
+ data->manipulatorLayer = new LiveLayerItem(view->scene());
+ data->selectionTool = new LiveSelectionTool(this);
+ data->zoomTool = new ZoomTool(this);
+ data->colorPickerTool = new ColorPickerTool(this);
+ data->boundingRectHighlighter = new BoundingRectHighlighter(this);
+ data->subcomponentEditorTool = new SubcomponentEditorTool(this);
+ data->currentTool = data->selectionTool;
+
+ // to capture ChildRemoved event when viewport changes
+ data->view->installEventFilter(this);
+
+ data->setViewport(data->view->viewport());
+
+ data->debugService = QDeclarativeObserverService::instance();
+ connect(data->debugService, SIGNAL(gotMessage(QByteArray)),
+ this, SLOT(handleMessage(QByteArray)));
+
+ connect(data->view, SIGNAL(statusChanged(QDeclarativeView::Status)),
+ data.data(), SLOT(_q_onStatusChanged(QDeclarativeView::Status)));
+
+ connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
+ SIGNAL(selectedColorChanged(QColor)));
+ connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
+ this, SLOT(sendColorChanged(QColor)));
+
+ connect(data->subcomponentEditorTool, SIGNAL(cleared()), SIGNAL(inspectorContextCleared()));
+ connect(data->subcomponentEditorTool, SIGNAL(contextPushed(QString)),
+ SIGNAL(inspectorContextPushed(QString)));
+ connect(data->subcomponentEditorTool, SIGNAL(contextPopped()),
+ SIGNAL(inspectorContextPopped()));
+ connect(data->subcomponentEditorTool, SIGNAL(contextPathChanged(QStringList)),
+ this, SLOT(sendContextPathUpdated(QStringList)));
+
+ data->_q_changeToSingleSelectTool();
+}
+
+QDeclarativeViewObserver::~QDeclarativeViewObserver()
+{
+}
+
+void QDeclarativeViewObserver::setObserverContext(int contextIndex)
+{
+ if (data->subcomponentEditorTool->contextIndex() != contextIndex) {
+ QGraphicsObject *object = data->subcomponentEditorTool->setContext(contextIndex);
+ if (object)
+ setSelectedItems(QList<QGraphicsItem*>() << object);
+ }
+}
+
+void QDeclarativeViewObserverPrivate::_q_setToolBoxVisible(bool visible)
+{
+#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR)
+ if (!toolBox && visible)
+ createToolBox();
+ if (toolBox)
+ toolBox->setVisible(visible);
+#else
+ Q_UNUSED(visible)
+#endif
+}
+
+void QDeclarativeViewObserverPrivate::_q_reloadView()
+{
+ subcomponentEditorTool->clear();
+ clearHighlight();
+ emit q->reloadRequested();
+}
+
+void QDeclarativeViewObserverPrivate::setViewport(QWidget *widget)
+{
+ if (viewport.data() == widget)
+ return;
+
+ if (viewport)
+ viewport.data()->removeEventFilter(q);
+
+ viewport = widget;
+ if (viewport) {
+ // make sure we get mouse move events
+ viewport.data()->setMouseTracking(true);
+ viewport.data()->installEventFilter(q);
+ }
+}
+
+void QDeclarativeViewObserverPrivate::clearEditorItems()
+{
+ clearHighlight();
+ setSelectedItems(QList<QGraphicsItem*>());
+}
+
+bool QDeclarativeViewObserver::eventFilter(QObject *obj, QEvent *event)
+{
+ if (obj == data->view) {
+ // Event from view
+ if (event->type() == QEvent::ChildRemoved) {
+ // Might mean that viewport has changed
+ if (data->view->viewport() != data->viewport.data())
+ data->setViewport(data->view->viewport());
+ }
+ return QObject::eventFilter(obj, event);
+ }
+
+ // Event from viewport
+ switch (event->type()) {
+ case QEvent::Leave: {
+ if (leaveEvent(event))
+ return true;
+ break;
+ }
+ case QEvent::MouseButtonPress: {
+ if (mousePressEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ }
+ case QEvent::MouseMove: {
+ if (mouseMoveEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ }
+ case QEvent::MouseButtonRelease: {
+ if (mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ }
+ case QEvent::KeyPress: {
+ if (keyPressEvent(static_cast<QKeyEvent*>(event)))
+ return true;
+ break;
+ }
+ case QEvent::KeyRelease: {
+ if (keyReleaseEvent(static_cast<QKeyEvent*>(event)))
+ return true;
+ break;
+ }
+ case QEvent::MouseButtonDblClick: {
+ if (mouseDoubleClickEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ }
+ case QEvent::Wheel: {
+ if (wheelEvent(static_cast<QWheelEvent*>(event)))
+ return true;
+ break;
+ }
+ default: {
+ break;
+ }
+ } //switch
+
+ // standard event processing
+ return QObject::eventFilter(obj, event);
+}
+
+bool QDeclarativeViewObserver::leaveEvent(QEvent * /*event*/)
+{
+ if (!data->designModeBehavior)
+ return false;
+ data->clearHighlight();
+ return true;
+}
+
+bool QDeclarativeViewObserver::mousePressEvent(QMouseEvent *event)
+{
+ if (!data->designModeBehavior)
+ return false;
+ data->cursorPos = event->pos();
+ data->currentTool->mousePressEvent(event);
+ return true;
+}
+
+bool QDeclarativeViewObserver::mouseMoveEvent(QMouseEvent *event)
+{
+ if (!data->designModeBehavior) {
+ data->clearEditorItems();
+ return false;
+ }
+ data->cursorPos = event->pos();
+
+ QList<QGraphicsItem*> selItems = data->selectableItems(event->pos());
+ if (!selItems.isEmpty()) {
+ declarativeView()->setToolTip(data->currentTool->titleForItem(selItems.first()));
+ } else {
+ declarativeView()->setToolTip(QString());
+ }
+ if (event->buttons()) {
+ data->subcomponentEditorTool->mouseMoveEvent(event);
+ data->currentTool->mouseMoveEvent(event);
+ } else {
+ data->subcomponentEditorTool->hoverMoveEvent(event);
+ data->currentTool->hoverMoveEvent(event);
+ }
+ return true;
+}
+
+bool QDeclarativeViewObserver::mouseReleaseEvent(QMouseEvent *event)
+{
+ if (!data->designModeBehavior)
+ return false;
+ data->subcomponentEditorTool->mouseReleaseEvent(event);
+
+ data->cursorPos = event->pos();
+ data->currentTool->mouseReleaseEvent(event);
+ return true;
+}
+
+bool QDeclarativeViewObserver::keyPressEvent(QKeyEvent *event)
+{
+ if (!data->designModeBehavior)
+ return false;
+
+ data->currentTool->keyPressEvent(event);
+ return true;
+}
+
+bool QDeclarativeViewObserver::keyReleaseEvent(QKeyEvent *event)
+{
+ if (!data->designModeBehavior)
+ return false;
+
+ switch (event->key()) {
+ case Qt::Key_V:
+ data->_q_changeToSingleSelectTool();
+ break;
+// disabled because multiselection does not do anything useful without design mode
+// case Qt::Key_M:
+// data->_q_changeToMarqueeSelectTool();
+// break;
+ case Qt::Key_I:
+ data->_q_changeToColorPickerTool();
+ break;
+ case Qt::Key_Z:
+ data->_q_changeToZoomTool();
+ break;
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ if (!data->selectedItems().isEmpty())
+ data->subcomponentEditorTool->setCurrentItem(data->selectedItems().first());
+ break;
+ case Qt::Key_Space:
+ setAnimationPaused(!data->animationPaused);
+ break;
+ default:
+ break;
+ }
+
+ data->currentTool->keyReleaseEvent(event);
+ return true;
+}
+
+void QDeclarativeViewObserverPrivate::_q_createQmlObject(const QString &qml, QObject *parent,
+ const QStringList &importList,
+ const QString &filename)
+{
+ if (!parent)
+ return;
+
+ QString imports;
+ foreach (const QString &s, importList) {
+ imports += s;
+ imports += QLatin1Char('\n');
+ }
+
+ QDeclarativeContext *parentContext = view->engine()->contextForObject(parent);
+ QDeclarativeComponent component(view->engine(), q);
+ QByteArray constructedQml = QString(imports + qml).toLatin1();
+
+ component.setData(constructedQml, QUrl::fromLocalFile(filename));
+ QObject *newObject = component.create(parentContext);
+ if (newObject) {
+ newObject->setParent(parent);
+ QDeclarativeItem *parentItem = qobject_cast<QDeclarativeItem*>(parent);
+ QDeclarativeItem *newItem = qobject_cast<QDeclarativeItem*>(newObject);
+ if (parentItem && newItem)
+ newItem->setParentItem(parentItem);
+ }
+}
+
+void QDeclarativeViewObserverPrivate::_q_reparentQmlObject(QObject *object, QObject *newParent)
+{
+ if (!newParent)
+ return;
+
+ object->setParent(newParent);
+ QDeclarativeItem *newParentItem = qobject_cast<QDeclarativeItem*>(newParent);
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(object);
+ if (newParentItem && item)
+ item->setParentItem(newParentItem);
+}
+
+void QDeclarativeViewObserverPrivate::_q_clearComponentCache()
+{
+ view->engine()->clearComponentCache();
+}
+
+void QDeclarativeViewObserverPrivate::_q_removeFromSelection(QObject *obj)
+{
+ QList<QGraphicsItem*> items = selectedItems();
+ if (QGraphicsItem *item = qobject_cast<QGraphicsObject*>(obj))
+ items.removeOne(item);
+ setSelectedItems(items);
+}
+
+QGraphicsItem *QDeclarativeViewObserverPrivate::currentRootItem() const
+{
+ return subcomponentEditorTool->currentRootItem();
+}
+
+bool QDeclarativeViewObserver::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ if (!data->designModeBehavior)
+ return false;
+
+ if (data->currentToolMode != Constants::SelectionToolMode
+ && data->currentToolMode != Constants::MarqueeSelectionToolMode)
+ return true;
+
+ QGraphicsItem *itemToEnter = 0;
+ QList<QGraphicsItem*> itemList = data->view->items(event->pos());
+ data->filterForSelection(itemList);
+
+ if (data->selectedItems().isEmpty() && !itemList.isEmpty()) {
+ itemToEnter = itemList.first();
+ } else if (!data->selectedItems().isEmpty() && !itemList.isEmpty()) {
+ itemToEnter = itemList.first();
+ }
+
+ if (itemToEnter)
+ itemToEnter = data->subcomponentEditorTool->firstChildOfContext(itemToEnter);
+
+ data->subcomponentEditorTool->setCurrentItem(itemToEnter);
+ data->subcomponentEditorTool->mouseDoubleClickEvent(event);
+
+ if ((event->buttons() & Qt::LeftButton) && itemToEnter) {
+ if (QGraphicsObject *objectToEnter = itemToEnter->toGraphicsObject())
+ setSelectedItems(QList<QGraphicsItem*>() << objectToEnter);
+ }
+
+ return true;
+}
+
+bool QDeclarativeViewObserver::wheelEvent(QWheelEvent *event)
+{
+ if (!data->designModeBehavior)
+ return false;
+ data->currentTool->wheelEvent(event);
+ return true;
+}
+
+void QDeclarativeViewObserverPrivate::enterContext(QGraphicsItem *itemToEnter)
+{
+ QGraphicsItem *itemUnderCurrentContext = itemToEnter;
+ if (itemUnderCurrentContext)
+ itemUnderCurrentContext = subcomponentEditorTool->firstChildOfContext(itemToEnter);
+
+ if (itemUnderCurrentContext)
+ subcomponentEditorTool->setCurrentItem(itemToEnter);
+}
+
+void QDeclarativeViewObserver::setDesignModeBehavior(bool value)
+{
+ emit designModeBehaviorChanged(value);
+
+ if (data->toolBox)
+ data->toolBox->toolBar()->setDesignModeBehavior(value);
+ sendDesignModeBehavior(value);
+
+ data->designModeBehavior = value;
+ if (data->subcomponentEditorTool) {
+ data->subcomponentEditorTool->clear();
+ data->clearHighlight();
+ data->setSelectedItems(QList<QGraphicsItem*>());
+
+ if (data->view->rootObject())
+ data->subcomponentEditorTool->pushContext(data->view->rootObject());
+ }
+
+ if (!data->designModeBehavior)
+ data->clearEditorItems();
+}
+
+bool QDeclarativeViewObserver::designModeBehavior()
+{
+ return data->designModeBehavior;
+}
+
+bool QDeclarativeViewObserver::showAppOnTop() const
+{
+ return data->showAppOnTop;
+}
+
+void QDeclarativeViewObserver::setShowAppOnTop(bool appOnTop)
+{
+ if (data->view) {
+ QWidget *window = data->view->window();
+ Qt::WindowFlags flags = window->windowFlags();
+ if (appOnTop)
+ flags |= Qt::WindowStaysOnTopHint;
+ else
+ flags &= ~Qt::WindowStaysOnTopHint;
+
+ window->setWindowFlags(flags);
+ window->show();
+ }
+
+ data->showAppOnTop = appOnTop;
+ sendShowAppOnTop(appOnTop);
+
+ emit showAppOnTopChanged(appOnTop);
+}
+
+void QDeclarativeViewObserverPrivate::changeTool(Constants::DesignTool tool,
+ Constants::ToolFlags /*flags*/)
+{
+ switch (tool) {
+ case Constants::SelectionToolMode:
+ _q_changeToSingleSelectTool();
+ break;
+ case Constants::NoTool:
+ default:
+ currentTool = 0;
+ break;
+ }
+}
+
+void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(QList<QGraphicsItem *> items)
+{
+ foreach (const QWeakPointer<QGraphicsObject> &obj, currentSelection) {
+ if (QGraphicsItem *item = obj.data()) {
+ if (!items.contains(item)) {
+ QObject::disconnect(obj.data(), SIGNAL(destroyed(QObject*)),
+ this, SLOT(_q_removeFromSelection(QObject*)));
+ currentSelection.removeOne(obj);
+ }
+ }
+ }
+
+ foreach (QGraphicsItem *item, items) {
+ if (item) {
+ if (QGraphicsObject *obj = item->toGraphicsObject()) {
+ QObject::connect(obj, SIGNAL(destroyed(QObject*)),
+ this, SLOT(_q_removeFromSelection(QObject*)));
+ currentSelection.append(obj);
+ }
+ }
+ }
+
+ currentTool->updateSelectedItems();
+}
+
+void QDeclarativeViewObserverPrivate::setSelectedItems(QList<QGraphicsItem *> items)
+{
+ QList<QWeakPointer<QGraphicsObject> > oldList = currentSelection;
+ setSelectedItemsForTools(items);
+ if (oldList != currentSelection) {
+ QList<QObject*> objectList;
+ foreach (const QWeakPointer<QGraphicsObject> &graphicsObject, currentSelection) {
+ if (graphicsObject)
+ objectList << graphicsObject.data();
+ }
+
+ q->sendCurrentObjects(objectList);
+ }
+}
+
+QList<QGraphicsItem *> QDeclarativeViewObserverPrivate::selectedItems() const
+{
+ QList<QGraphicsItem *> selection;
+ foreach (const QWeakPointer<QGraphicsObject> &selectedObject, currentSelection) {
+ if (selectedObject.data())
+ selection << selectedObject.data();
+ }
+
+ return selection;
+}
+
+void QDeclarativeViewObserver::setSelectedItems(QList<QGraphicsItem *> items)
+{
+ data->setSelectedItems(items);
+}
+
+QList<QGraphicsItem *> QDeclarativeViewObserver::selectedItems() const
+{
+ return data->selectedItems();
+}
+
+QDeclarativeView *QDeclarativeViewObserver::declarativeView()
+{
+ return data->view;
+}
+
+void QDeclarativeViewObserverPrivate::clearHighlight()
+{
+ boundingRectHighlighter->clear();
+}
+
+void QDeclarativeViewObserverPrivate::highlight(QGraphicsObject * item, ContextFlags flags)
+{
+ highlight(QList<QGraphicsObject*>() << item, flags);
+}
+
+void QDeclarativeViewObserverPrivate::highlight(QList<QGraphicsObject *> items, ContextFlags flags)
+{
+ if (items.isEmpty())
+ return;
+
+ QList<QGraphicsObject*> objectList;
+ foreach (QGraphicsItem *item, items) {
+ QGraphicsItem *child = item;
+ if (flags & ContextSensitive)
+ child = subcomponentEditorTool->firstChildOfContext(item);
+
+ if (child) {
+ QGraphicsObject *childObject = child->toGraphicsObject();
+ if (childObject)
+ objectList << childObject;
+ }
+ }
+
+ boundingRectHighlighter->highlight(objectList);
+}
+
+bool QDeclarativeViewObserverPrivate::mouseInsideContextItem() const
+{
+ return subcomponentEditorTool->containsCursor(cursorPos.toPoint());
+}
+
+QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::selectableItems(
+ const QPointF &scenePos) const
+{
+ QList<QGraphicsItem*> itemlist = view->scene()->items(scenePos);
+ return filterForCurrentContext(itemlist);
+}
+
+QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::selectableItems(const QPoint &pos) const
+{
+ QList<QGraphicsItem*> itemlist = view->items(pos);
+ return filterForCurrentContext(itemlist);
+}
+
+QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::selectableItems(
+ const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const
+{
+ QList<QGraphicsItem*> itemlist = view->scene()->items(sceneRect, selectionMode);
+
+ return filterForCurrentContext(itemlist);
+}
+
+void QDeclarativeViewObserverPrivate::_q_changeToSingleSelectTool()
+{
+ currentToolMode = Constants::SelectionToolMode;
+ selectionTool->setRubberbandSelectionMode(false);
+
+ changeToSelectTool();
+
+ emit q->selectToolActivated();
+ q->sendCurrentTool(Constants::SelectionToolMode);
+}
+
+void QDeclarativeViewObserverPrivate::changeToSelectTool()
+{
+ if (currentTool == selectionTool)
+ return;
+
+ currentTool->clear();
+ currentTool = selectionTool;
+ currentTool->clear();
+ currentTool->updateSelectedItems();
+}
+
+void QDeclarativeViewObserverPrivate::_q_changeToMarqueeSelectTool()
+{
+ changeToSelectTool();
+ currentToolMode = Constants::MarqueeSelectionToolMode;
+ selectionTool->setRubberbandSelectionMode(true);
+
+ emit q->marqueeSelectToolActivated();
+ q->sendCurrentTool(Constants::MarqueeSelectionToolMode);
+}
+
+void QDeclarativeViewObserverPrivate::_q_changeToZoomTool()
+{
+ currentToolMode = Constants::ZoomMode;
+ currentTool->clear();
+ currentTool = zoomTool;
+ currentTool->clear();
+
+ emit q->zoomToolActivated();
+ q->sendCurrentTool(Constants::ZoomMode);
+}
+
+void QDeclarativeViewObserverPrivate::_q_changeToColorPickerTool()
+{
+ if (currentTool == colorPickerTool)
+ return;
+
+ currentToolMode = Constants::ColorPickerMode;
+ currentTool->clear();
+ currentTool = colorPickerTool;
+ currentTool->clear();
+
+ emit q->colorPickerActivated();
+ q->sendCurrentTool(Constants::ColorPickerMode);
+}
+
+void QDeclarativeViewObserverPrivate::_q_changeContextPathIndex(int index)
+{
+ subcomponentEditorTool->setContext(index);
+}
+
+void QDeclarativeViewObserver::setAnimationSpeed(qreal slowDownFactor)
+{
+ Q_ASSERT(slowDownFactor > 0);
+ if (data->slowDownFactor == slowDownFactor)
+ return;
+
+ animationSpeedChangeRequested(slowDownFactor);
+ sendAnimationSpeed(slowDownFactor);
+}
+
+void QDeclarativeViewObserver::setAnimationPaused(bool paused)
+{
+ if (data->animationPaused == paused)
+ return;
+
+ animationPausedChangeRequested(paused);
+ sendAnimationPaused(paused);
+}
+
+void QDeclarativeViewObserver::animationSpeedChangeRequested(qreal factor)
+{
+ if (data->slowDownFactor != factor) {
+ data->slowDownFactor = factor;
+ emit animationSpeedChanged(factor);
+ }
+
+ const float effectiveFactor = data->animationPaused ? 0 : factor;
+ QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor);
+}
+
+void QDeclarativeViewObserver::animationPausedChangeRequested(bool paused)
+{
+ if (data->animationPaused != paused) {
+ data->animationPaused = paused;
+ emit animationPausedChanged(paused);
+ }
+
+ const float effectiveFactor = paused ? 0 : data->slowDownFactor;
+ QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor);
+}
+
+
+void QDeclarativeViewObserverPrivate::_q_applyChangesFromClient()
+{
+}
+
+
+QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::filterForSelection(
+ QList<QGraphicsItem*> &itemlist) const
+{
+ foreach (QGraphicsItem *item, itemlist) {
+ if (isEditorItem(item) || !subcomponentEditorTool->isChildOfContext(item))
+ itemlist.removeOne(item);
+ }
+
+ return itemlist;
+}
+
+QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::filterForCurrentContext(
+ QList<QGraphicsItem*> &itemlist) const
+{
+ foreach (QGraphicsItem *item, itemlist) {
+
+ if (isEditorItem(item) || !subcomponentEditorTool->isDirectChildOfContext(item)) {
+
+ // if we're a child, but not directly, replace with the parent that is directly in context.
+ if (QGraphicsItem *contextParent = subcomponentEditorTool->firstChildOfContext(item)) {
+ if (contextParent != item) {
+ if (itemlist.contains(contextParent)) {
+ itemlist.removeOne(item);
+ } else {
+ itemlist.replace(itemlist.indexOf(item), contextParent);
+ }
+ }
+ } else {
+ itemlist.removeOne(item);
+ }
+ }
+ }
+
+ return itemlist;
+}
+
+bool QDeclarativeViewObserverPrivate::isEditorItem(QGraphicsItem *item) const
+{
+ return (item->type() == Constants::EditorItemType
+ || item->type() == Constants::ResizeHandleItemType
+ || item->data(Constants::EditorItemDataKey).toBool());
+}
+
+void QDeclarativeViewObserverPrivate::_q_onStatusChanged(QDeclarativeView::Status status)
+{
+ if (status == QDeclarativeView::Ready) {
+ if (view->rootObject()) {
+ if (subcomponentEditorTool->contextIndex() != -1)
+ subcomponentEditorTool->clear();
+ subcomponentEditorTool->pushContext(view->rootObject());
+ }
+ q->sendReloaded();
+ }
+}
+
+void QDeclarativeViewObserverPrivate::_q_onCurrentObjectsChanged(QList<QObject*> objects)
+{
+ QList<QGraphicsItem*> items;
+ QList<QGraphicsObject*> gfxObjects;
+ foreach (QObject *obj, objects) {
+ QDeclarativeItem* declarativeItem = qobject_cast<QDeclarativeItem*>(obj);
+ if (declarativeItem) {
+ items << declarativeItem;
+ if (QGraphicsObject *gfxObj = declarativeItem->toGraphicsObject())
+ gfxObjects << gfxObj;
+ }
+ }
+ if (designModeBehavior) {
+ setSelectedItemsForTools(items);
+ clearHighlight();
+ highlight(gfxObjects, QDeclarativeViewObserverPrivate::IgnoreContext);
+ }
+}
+
+// adjusts bounding boxes on edges of screen to be visible
+QRectF QDeclarativeViewObserver::adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace)
+{
+ int marginFromEdge = 1;
+ QRectF boundingRect(boundingRectInSceneSpace);
+ if (qAbs(boundingRect.left()) - 1 < 2)
+ boundingRect.setLeft(marginFromEdge);
+
+ QRect rect = data->view->rect();
+
+ if (boundingRect.right() >= rect.right())
+ boundingRect.setRight(rect.right() - marginFromEdge);
+
+ if (qAbs(boundingRect.top()) - 1 < 2)
+ boundingRect.setTop(marginFromEdge);
+
+ if (boundingRect.bottom() >= rect.bottom())
+ boundingRect.setBottom(rect.bottom() - marginFromEdge);
+
+ return boundingRect;
+}
+
+void QDeclarativeViewObserverPrivate::createToolBox()
+{
+ toolBox = new ToolBox(q->declarativeView());
+
+ QmlToolBar *toolBar = toolBox->toolBar();
+
+ QObject::connect(q, SIGNAL(selectedColorChanged(QColor)),
+ toolBar, SLOT(setColorBoxColor(QColor)));
+
+ QObject::connect(q, SIGNAL(designModeBehaviorChanged(bool)),
+ toolBar, SLOT(setDesignModeBehavior(bool)));
+
+ QObject::connect(toolBar, SIGNAL(designModeBehaviorChanged(bool)),
+ q, SLOT(setDesignModeBehavior(bool)));
+ QObject::connect(toolBar, SIGNAL(animationSpeedChanged(qreal)), q, SLOT(setAnimationSpeed(qreal)));
+ QObject::connect(toolBar, SIGNAL(animationPausedChanged(bool)), q, SLOT(setAnimationPaused(bool)));
+ QObject::connect(toolBar, SIGNAL(colorPickerSelected()), this, SLOT(_q_changeToColorPickerTool()));
+ QObject::connect(toolBar, SIGNAL(zoomToolSelected()), this, SLOT(_q_changeToZoomTool()));
+ QObject::connect(toolBar, SIGNAL(selectToolSelected()), this, SLOT(_q_changeToSingleSelectTool()));
+ QObject::connect(toolBar, SIGNAL(marqueeSelectToolSelected()),
+ this, SLOT(_q_changeToMarqueeSelectTool()));
+
+ QObject::connect(toolBar, SIGNAL(applyChangesFromQmlFileSelected()),
+ this, SLOT(_q_applyChangesFromClient()));
+
+ QObject::connect(q, SIGNAL(animationSpeedChanged(qreal)), toolBar, SLOT(setAnimationSpeed(qreal)));
+ QObject::connect(q, SIGNAL(animationPausedChanged(bool)), toolBar, SLOT(setAnimationPaused(bool)));
+
+ QObject::connect(q, SIGNAL(selectToolActivated()), toolBar, SLOT(activateSelectTool()));
+
+ // disabled features
+ //connect(d->m_toolBar, SIGNAL(applyChangesToQmlFileSelected()), SLOT(applyChangesToClient()));
+ //connect(q, SIGNAL(resizeToolActivated()), d->m_toolBar, SLOT(activateSelectTool()));
+ //connect(q, SIGNAL(moveToolActivated()), d->m_toolBar, SLOT(activateSelectTool()));
+
+ QObject::connect(q, SIGNAL(colorPickerActivated()), toolBar, SLOT(activateColorPicker()));
+ QObject::connect(q, SIGNAL(zoomToolActivated()), toolBar, SLOT(activateZoom()));
+ QObject::connect(q, SIGNAL(marqueeSelectToolActivated()),
+ toolBar, SLOT(activateMarqueeSelectTool()));
+}
+
+void QDeclarativeViewObserver::handleMessage(const QByteArray &message)
+{
+ QDataStream ds(message);
+
+ ObserverProtocol::Message type;
+ ds >> type;
+
+ switch (type) {
+ case ObserverProtocol::SetCurrentObjects: {
+ int itemCount = 0;
+ ds >> itemCount;
+
+ QList<QObject*> selectedObjects;
+ for (int i = 0; i < itemCount; ++i) {
+ int debugId = -1;
+ ds >> debugId;
+ QObject *obj = QDeclarativeDebugService::objectForId(debugId);
+
+ if (obj)
+ selectedObjects << obj;
+ }
+
+ data->_q_onCurrentObjectsChanged(selectedObjects);
+ break;
+ }
+ case ObserverProtocol::Reload: {
+ data->_q_reloadView();
+ break;
+ }
+ case ObserverProtocol::SetAnimationSpeed: {
+ qreal speed;
+ ds >> speed;
+ animationSpeedChangeRequested(speed);
+ break;
+ }
+ case ObserverProtocol::SetAnimationPaused: {
+ bool paused;
+ ds >> paused;
+ animationPausedChangeRequested(paused);
+ break;
+ }
+ case ObserverProtocol::ChangeTool: {
+ ObserverProtocol::Tool tool;
+ ds >> tool;
+ switch (tool) {
+ case ObserverProtocol::ColorPickerTool:
+ data->_q_changeToColorPickerTool();
+ break;
+ case ObserverProtocol::SelectTool:
+ data->_q_changeToSingleSelectTool();
+ break;
+ case ObserverProtocol::SelectMarqueeTool:
+ data->_q_changeToMarqueeSelectTool();
+ break;
+ case ObserverProtocol::ZoomTool:
+ data->_q_changeToZoomTool();
+ break;
+ default:
+ qWarning() << "Warning: Unhandled tool:" << tool;
+ }
+ break;
+ }
+ case ObserverProtocol::SetDesignMode: {
+ bool inDesignMode;
+ ds >> inDesignMode;
+ setDesignModeBehavior(inDesignMode);
+ break;
+ }
+ case ObserverProtocol::ShowAppOnTop: {
+ bool showOnTop;
+ ds >> showOnTop;
+ setShowAppOnTop(showOnTop);
+ break;
+ }
+ case ObserverProtocol::CreateObject: {
+ QString qml;
+ int parentId;
+ QString filename;
+ QStringList imports;
+ ds >> qml >> parentId >> imports >> filename;
+ data->_q_createQmlObject(qml, QDeclarativeDebugService::objectForId(parentId),
+ imports, filename);
+ break;
+ }
+ case ObserverProtocol::DestroyObject: {
+ int debugId;
+ ds >> debugId;
+ if (QObject* obj = QDeclarativeDebugService::objectForId(debugId))
+ obj->deleteLater();
+ break;
+ }
+ case ObserverProtocol::MoveObject: {
+ int debugId, newParent;
+ ds >> debugId >> newParent;
+ data->_q_reparentQmlObject(QDeclarativeDebugService::objectForId(debugId),
+ QDeclarativeDebugService::objectForId(newParent));
+ break;
+ }
+ case ObserverProtocol::ObjectIdList: {
+ int itemCount;
+ ds >> itemCount;
+ data->stringIdForObjectId.clear();
+ for (int i = 0; i < itemCount; ++i) {
+ int itemDebugId;
+ QString itemIdString;
+ ds >> itemDebugId
+ >> itemIdString;
+
+ data->stringIdForObjectId.insert(itemDebugId, itemIdString);
+ }
+ break;
+ }
+ case ObserverProtocol::SetContextPathIdx: {
+ int contextPathIndex;
+ ds >> contextPathIndex;
+ data->_q_changeContextPathIndex(contextPathIndex);
+ break;
+ }
+ case ObserverProtocol::ClearComponentCache: {
+ data->_q_clearComponentCache();
+ break;
+ }
+ default:
+ qWarning() << "Warning: Not handling message:" << type;
+ }
+}
+
+void QDeclarativeViewObserver::sendDesignModeBehavior(bool inDesignMode)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << ObserverProtocol::SetDesignMode
+ << inDesignMode;
+
+ data->debugService->sendMessage(message);
+}
+
+void QDeclarativeViewObserver::sendCurrentObjects(QList<QObject*> objects)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << ObserverProtocol::CurrentObjectsChanged
+ << objects.length();
+
+ foreach (QObject *object, objects) {
+ int id = QDeclarativeDebugService::idForObject(object);
+ ds << id;
+ }
+
+ data->debugService->sendMessage(message);
+}
+
+void QDeclarativeViewObserver::sendCurrentTool(Constants::DesignTool toolId)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << ObserverProtocol::ToolChanged
+ << toolId;
+
+ data->debugService->sendMessage(message);
+}
+
+void QDeclarativeViewObserver::sendAnimationSpeed(qreal slowDownFactor)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << ObserverProtocol::AnimationSpeedChanged
+ << slowDownFactor;
+
+ data->debugService->sendMessage(message);
+}
+
+void QDeclarativeViewObserver::sendAnimationPaused(bool paused)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << ObserverProtocol::AnimationPausedChanged
+ << paused;
+
+ data->debugService->sendMessage(message);
+}
+
+void QDeclarativeViewObserver::sendReloaded()
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << ObserverProtocol::Reloaded;
+
+ data->debugService->sendMessage(message);
+}
+
+void QDeclarativeViewObserver::sendShowAppOnTop(bool showAppOnTop)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << ObserverProtocol::ShowAppOnTop << showAppOnTop;
+
+ data->debugService->sendMessage(message);
+}
+
+void QDeclarativeViewObserver::sendColorChanged(const QColor &color)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << ObserverProtocol::ColorChanged
+ << color;
+
+ data->debugService->sendMessage(message);
+}
+
+void QDeclarativeViewObserver::sendContextPathUpdated(const QStringList &contextPath)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+
+ ds << ObserverProtocol::ContextPathUpdated
+ << contextPath;
+
+ data->debugService->sendMessage(message);
+}
+
+QString QDeclarativeViewObserver::idStringForObject(QObject *obj) const
+{
+ int id = QDeclarativeDebugService::idForObject(obj);
+ QString idString = data->stringIdForObjectId.value(id, QString());
+ return idString;
+}
+
+QT_END_NAMESPACE
+
+#include "qdeclarativeviewobserver.moc"
diff --git a/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p.h b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p.h
new file mode 100644
index 0000000..6e986c2
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p.h
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEVIEWOBSERVER_P_H
+#define QDECLARATIVEVIEWOBSERVER_P_H
+
+#include <private/qdeclarativeglobal_p.h>
+#include "qmlobserverconstants_p.h"
+
+#include <QtCore/QScopedPointer>
+#include <QtDeclarative/QDeclarativeView>
+
+QT_FORWARD_DECLARE_CLASS(QDeclarativeItem)
+QT_FORWARD_DECLARE_CLASS(QMouseEvent)
+QT_FORWARD_DECLARE_CLASS(QToolBar)
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeViewObserverPrivate;
+
+class QDeclarativeViewObserver : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit QDeclarativeViewObserver(QDeclarativeView *view, QObject *parent = 0);
+ ~QDeclarativeViewObserver();
+
+ void setSelectedItems(QList<QGraphicsItem *> items);
+ QList<QGraphicsItem *> selectedItems() const;
+
+ QDeclarativeView *declarativeView();
+
+ QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace);
+
+ bool showAppOnTop() const;
+
+ void sendDesignModeBehavior(bool inDesignMode);
+ void sendCurrentObjects(QList<QObject*> items);
+ void sendAnimationSpeed(qreal slowDownFactor);
+ void sendAnimationPaused(bool paused);
+ void sendCurrentTool(Constants::DesignTool toolId);
+ void sendReloaded();
+ void sendShowAppOnTop(bool showAppOnTop);
+
+ QString idStringForObject(QObject *obj) const;
+
+public Q_SLOTS:
+ void sendColorChanged(const QColor &color);
+ void sendContextPathUpdated(const QStringList &contextPath);
+
+ void setDesignModeBehavior(bool value);
+ bool designModeBehavior();
+
+ void setShowAppOnTop(bool appOnTop);
+
+ void setAnimationSpeed(qreal factor);
+ void setAnimationPaused(bool paused);
+
+ void setObserverContext(int contextIndex);
+
+Q_SIGNALS:
+ void designModeBehaviorChanged(bool inDesignMode);
+ void showAppOnTopChanged(bool showAppOnTop);
+ void reloadRequested();
+ void marqueeSelectToolActivated();
+ void selectToolActivated();
+ void zoomToolActivated();
+ void colorPickerActivated();
+ void selectedColorChanged(const QColor &color);
+
+ void animationSpeedChanged(qreal factor);
+ void animationPausedChanged(bool paused);
+
+ void inspectorContextCleared();
+ void inspectorContextPushed(const QString &contextTitle);
+ void inspectorContextPopped();
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *event);
+
+ bool leaveEvent(QEvent *);
+ bool mousePressEvent(QMouseEvent *event);
+ bool mouseMoveEvent(QMouseEvent *event);
+ bool mouseReleaseEvent(QMouseEvent *event);
+ bool keyPressEvent(QKeyEvent *event);
+ bool keyReleaseEvent(QKeyEvent *keyEvent);
+ bool mouseDoubleClickEvent(QMouseEvent *event);
+ bool wheelEvent(QWheelEvent *event);
+
+ void setSelectedItemsForTools(QList<QGraphicsItem *> items);
+
+private slots:
+ void handleMessage(const QByteArray &message);
+
+ void animationSpeedChangeRequested(qreal factor);
+ void animationPausedChangeRequested(bool paused);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeViewObserver)
+
+ inline QDeclarativeViewObserverPrivate *d_func() { return data.data(); }
+ QScopedPointer<QDeclarativeViewObserverPrivate> data;
+ friend class QDeclarativeViewObserverPrivate;
+ friend class AbstractLiveEditTool;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEVIEWOBSERVER_P_H
diff --git a/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p_p.h b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p_p.h
new file mode 100644
index 0000000..6022555
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p_p.h
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEVIEWOBSERVER_P_P_H
+#define QDECLARATIVEVIEWOBSERVER_P_P_H
+
+#include "qdeclarativeviewobserver_p.h"
+
+#include <QtCore/QWeakPointer>
+#include <QtCore/QPointF>
+
+#include "QtDeclarative/private/qdeclarativeobserverservice_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeViewObserver;
+class LiveSelectionTool;
+class ZoomTool;
+class ColorPickerTool;
+class LiveLayerItem;
+class BoundingRectHighlighter;
+class SubcomponentEditorTool;
+class ToolBox;
+class AbstractLiveEditTool;
+
+class QDeclarativeViewObserverPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ enum ContextFlags {
+ IgnoreContext,
+ ContextSensitive
+ };
+
+ QDeclarativeViewObserverPrivate(QDeclarativeViewObserver *);
+ ~QDeclarativeViewObserverPrivate();
+
+ QDeclarativeView *view;
+ QDeclarativeViewObserver *q;
+ QDeclarativeObserverService *debugService;
+ QWeakPointer<QWidget> viewport;
+ QHash<int, QString> stringIdForObjectId;
+
+ QPointF cursorPos;
+ QList<QWeakPointer<QGraphicsObject> > currentSelection;
+
+ Constants::DesignTool currentToolMode;
+ AbstractLiveEditTool *currentTool;
+
+ LiveSelectionTool *selectionTool;
+ ZoomTool *zoomTool;
+ ColorPickerTool *colorPickerTool;
+ SubcomponentEditorTool *subcomponentEditorTool;
+ LiveLayerItem *manipulatorLayer;
+
+ BoundingRectHighlighter *boundingRectHighlighter;
+
+ bool designModeBehavior;
+ bool showAppOnTop;
+
+ bool animationPaused;
+ qreal slowDownFactor;
+
+ ToolBox *toolBox;
+
+ void setViewport(QWidget *widget);
+
+ void clearEditorItems();
+ void createToolBox();
+ void changeToSelectTool();
+ QList<QGraphicsItem*> filterForCurrentContext(QList<QGraphicsItem*> &itemlist) const;
+ QList<QGraphicsItem*> filterForSelection(QList<QGraphicsItem*> &itemlist) const;
+
+ QList<QGraphicsItem*> selectableItems(const QPoint &pos) const;
+ QList<QGraphicsItem*> selectableItems(const QPointF &scenePos) const;
+ QList<QGraphicsItem*> selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const;
+
+ void setSelectedItemsForTools(QList<QGraphicsItem *> items);
+ void setSelectedItems(QList<QGraphicsItem *> items);
+ QList<QGraphicsItem *> selectedItems() const;
+
+ void changeTool(Constants::DesignTool tool,
+ Constants::ToolFlags flags = Constants::NoToolFlags);
+
+ void clearHighlight();
+ void highlight(QList<QGraphicsObject *> item, ContextFlags flags = ContextSensitive);
+ void highlight(QGraphicsObject *item, ContextFlags flags = ContextSensitive);
+
+ bool mouseInsideContextItem() const;
+ bool isEditorItem(QGraphicsItem *item) const;
+
+ QGraphicsItem *currentRootItem() const;
+
+ void enterContext(QGraphicsItem *itemToEnter);
+
+public slots:
+ void _q_setToolBoxVisible(bool visible);
+
+ void _q_reloadView();
+ void _q_onStatusChanged(QDeclarativeView::Status status);
+ void _q_onCurrentObjectsChanged(QList<QObject*> objects);
+ void _q_applyChangesFromClient();
+ void _q_createQmlObject(const QString &qml, QObject *parent,
+ const QStringList &imports, const QString &filename = QString());
+ void _q_reparentQmlObject(QObject *, QObject *);
+
+ void _q_changeToSingleSelectTool();
+ void _q_changeToMarqueeSelectTool();
+ void _q_changeToZoomTool();
+ void _q_changeToColorPickerTool();
+ void _q_changeContextPathIndex(int index);
+ void _q_clearComponentCache();
+ void _q_removeFromSelection(QObject *);
+
+public:
+ static QDeclarativeViewObserverPrivate *get(QDeclarativeViewObserver *v) { return v->d_func(); }
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEVIEWOBSERVER_P_P_H
diff --git a/src/plugins/qmltooling/declarativeobserver/qmlobserverconstants_p.h b/src/plugins/qmltooling/declarativeobserver/qmlobserverconstants_p.h
new file mode 100644
index 0000000..353e235
--- /dev/null
+++ b/src/plugins/qmltooling/declarativeobserver/qmlobserverconstants_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLOBSERVERCONSTANTS_H
+#define QMLOBSERVERCONSTANTS_H
+
+#include <QtDeclarative/private/qdeclarativeglobal_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+namespace Constants {
+
+enum DesignTool {
+ NoTool = 0,
+ SelectionToolMode = 1,
+ MarqueeSelectionToolMode = 2,
+ MoveToolMode = 3,
+ ResizeToolMode = 4,
+ ColorPickerMode = 5,
+ ZoomMode = 6
+};
+
+enum ToolFlags {
+ NoToolFlags = 0,
+ UseCursorPos = 1
+};
+
+static const int DragStartTime = 50;
+
+static const int DragStartDistance = 20;
+
+static const double ZoomSnapDelta = 0.04;
+
+static const int EditorItemDataKey = 1000;
+
+enum GraphicsItemTypes {
+ EditorItemType = 0xEAAA,
+ ResizeHandleItemType = 0xEAEA
+};
+
+
+} // namespace Constants
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMLOBSERVERCONSTANTS_H
diff --git a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp
index 1c91c34..ac32081 100644
--- a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp
+++ b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp
@@ -109,6 +109,12 @@ void QmlOstPlugin::disconnect()
d->protocol = 0;
}
+bool QmlOstPlugin::waitForMessage()
+{
+ Q_D(QmlOstPlugin);
+ return d->protocol->waitForReadyRead(-1);
+}
+
void QmlOstPlugin::setPort(int port, bool block)
{
Q_UNUSED(port);
diff --git a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h
index eee6ee1..b4ff377 100644
--- a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h
+++ b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h
@@ -68,6 +68,7 @@ public:
bool isConnected() const;
void send(const QByteArray &message);
void disconnect();
+ bool waitForMessage();
private Q_SLOTS:
void readyRead();
diff --git a/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp b/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp
index 21b0169..d3b2661 100644
--- a/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp
+++ b/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp
@@ -57,6 +57,8 @@ public:
Cancel();
}
+ TInt& AoFlags() { return ((TInt*)&iStatus)[1]; }
+
private:
void RunL();
void DoCancel();
@@ -65,6 +67,7 @@ private:
RUsbOstComm ost;
TBuf8<4096> readBuf;
QByteArray dataBuf;
+ TBool inReadyRead;
};
QOstDevice::QOstDevice(QObject *parent) :
@@ -116,7 +119,11 @@ void QOstDevicePrivate::RunL()
ost.ReadMessage(iStatus, readBuf);
SetActive();
- emit q->readyRead();
+ if (!inReadyRead) {
+ inReadyRead = true;
+ emit q->readyRead();
+ inReadyRead = false;
+ }
} else {
q->setErrorString(QString("Error %1 from RUsbOstComm::ReadMessage()").arg(iStatus.Int()));
}
@@ -178,3 +185,36 @@ qint64 QOstDevice::bytesAvailable() const
Q_D(const QOstDevice);
return d->dataBuf.length();
}
+
+bool QOstDevice::waitForReadyRead(int msecs)
+{
+ Q_D(QOstDevice);
+ if (msecs >= 0) {
+ RTimer timer;
+ TInt err = timer.CreateLocal();
+ if (err) return false;
+ TRequestStatus timeoutStat;
+ timer.After(timeoutStat, msecs*1000);
+ User::WaitForRequest(timeoutStat, d->iStatus);
+ if (timeoutStat != KRequestPending) {
+ // Timed out
+ timer.Close();
+ return false;
+ } else {
+ // We got data, so cancel timer
+ timer.Cancel();
+ User::WaitForRequest(timeoutStat);
+ timer.Close();
+ // And drop through
+ }
+ } else {
+ // Just wait forever for data
+ User::WaitForRequest(d->iStatus);
+ }
+
+ // If we get here we have data
+ TInt err = d->iStatus.Int();
+ d->AoFlags() &= ~3; // This is necessary to clean up the scheduler as you're not supposed to bypass it like this
+ TRAP_IGNORE(d->RunL());
+ return err == KErrNone;
+}
diff --git a/src/plugins/qmltooling/qmldbg_ost/qostdevice.h b/src/plugins/qmltooling/qmldbg_ost/qostdevice.h
index 2c26ff7..200e607 100644
--- a/src/plugins/qmltooling/qmldbg_ost/qostdevice.h
+++ b/src/plugins/qmltooling/qmldbg_ost/qostdevice.h
@@ -61,10 +61,12 @@ public:
bool open(int ostProtocolId);
void close();
+ bool waitForReadyRead(int msecs);
+ qint64 bytesAvailable() const;
+
protected:
qint64 readData(char *data, qint64 maxSize);
qint64 writeData(const char *data, qint64 maxSize);
- qint64 bytesAvailable() const;
private:
QOstDevicePrivate* d_ptr;
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
index 85c43e3..7cd3d73 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
@@ -41,6 +41,7 @@
#include "qtcpserverconnection.h"
+#include <QtCore/qplugin.h>
#include <QtNetwork/qtcpserver.h>
#include <QtNetwork/qtcpsocket.h>
@@ -54,6 +55,7 @@ public:
QTcpServerConnectionPrivate();
int port;
+ bool block;
QTcpSocket *socket;
QPacketProtocol *protocol;
QTcpServer *tcpServer;
@@ -63,6 +65,7 @@ public:
QTcpServerConnectionPrivate::QTcpServerConnectionPrivate() :
port(0),
+ block(false),
socket(0),
protocol(0),
tcpServer(0),
@@ -119,10 +122,17 @@ void QTcpServerConnection::disconnect()
d->socket = 0;
}
+bool QTcpServerConnection::waitForMessage()
+{
+ Q_D(QTcpServerConnection);
+ return d->protocol->waitForReadyRead(-1);
+}
+
void QTcpServerConnection::setPort(int port, bool block)
{
Q_D(QTcpServerConnection);
d->port = port;
+ d->block = block;
listen();
if (block)
@@ -169,8 +179,11 @@ void QTcpServerConnection::newConnection()
d->socket->setParent(this);
d->protocol = new QPacketProtocol(d->socket, this);
QObject::connect(d->protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
-}
+ if (d->block) {
+ d->protocol->waitForReadyRead(-1);
+ }
+}
Q_EXPORT_PLUGIN2(tcpserver, QTcpServerConnection)
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
index 66a10e1..dd5a5ec 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
@@ -42,7 +42,6 @@
#ifndef QTCPSERVERCONNECTION_H
#define QTCPSERVERCONNECTION_H
-#include <QtGui/QStylePlugin>
#include <QtDeclarative/private/qdeclarativedebugserverconnection_p.h>
QT_BEGIN_NAMESPACE
@@ -67,6 +66,7 @@ public:
bool isConnected() const;
void send(const QByteArray &message);
void disconnect();
+ bool waitForMessage();
void listen();
void waitForConnection();
diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro
index 9b3346f..0d60eb1 100644
--- a/src/plugins/qmltooling/qmltooling.pro
+++ b/src/plugins/qmltooling/qmltooling.pro
@@ -1,4 +1,4 @@
TEMPLATE = subdirs
-SUBDIRS = qmldbg_tcp
+SUBDIRS = qmldbg_tcp declarativeobserver
symbian:SUBDIRS += qmldbg_ost
diff --git a/src/qbase.pri b/src/qbase.pri
index ce69757..c4d081f 100644
--- a/src/qbase.pri
+++ b/src/qbase.pri
@@ -163,7 +163,7 @@ contains(QT_PRODUCT, OpenSource.*):DEFINES *= QT_OPENSOURCE
DEFINES *= QT_NO_CAST_TO_ASCII QT_ASCII_CAST_WARNINGS
contains(QT_CONFIG, qt3support):DEFINES *= QT3_SUPPORT
DEFINES *= QT_MOC_COMPAT #we don't need warnings from calling moc code in our generated code
-DEFINES *= QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_CONCATENATION
+DEFINES *= QT_USE_QSTRINGBUILDER
TARGET = $$qtLibraryTarget($$TARGET$$QT_LIBINFIX) #do this towards the end
diff --git a/src/qt3support/text/q3richtext.cpp b/src/qt3support/text/q3richtext.cpp
index 668a322..6c77405 100644
--- a/src/qt3support/text/q3richtext.cpp
+++ b/src/qt3support/text/q3richtext.cpp
@@ -63,6 +63,7 @@
#include "qstyleoption.h"
#include "q3stylesheet.h"
#include "qtextstream.h"
+#include <private/qtextdocument_p.h>
#include <private/qtextengine_p.h>
#include <stdlib.h>
diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def
index 0e6021a..f26b4d0 100644
--- a/src/s60installs/bwins/QtCoreu.def
+++ b/src/s60installs/bwins/QtCoreu.def
@@ -4844,4 +4844,172 @@ EXPORTS
?staticMetaObjectExtraData@QEventTransition@@0UQMetaObjectExtraData@@B @ 4843 NONAME ; struct QMetaObjectExtraData const QEventTransition::staticMetaObjectExtraData
?qt_static_metacall@QEventLoop@@CAXPAVQObject@@W4Call@QMetaObject@@HPAPAX@Z @ 4844 NONAME ; void QEventLoop::qt_static_metacall(class QObject *, enum QMetaObject::Call, int, void * *)
?keys@QProcessEnvironment@@QBE?AVQStringList@@XZ @ 4845 NONAME ; class QStringList QProcessEnvironment::keys(void) const
+ ?progressTextChanged@QFutureWatcherBase@@IAEXABVQString@@@Z @ 4846 NONAME ; void QFutureWatcherBase::progressTextChanged(class QString const &)
+ ?timeAfterUser@BlockSizeManager@QtConcurrent@@QAEXXZ @ 4847 NONAME ; void QtConcurrent::BlockSizeManager::timeAfterUser(void)
+ ?hasThrown@ExceptionStore@internal@QtConcurrent@@QBE_NXZ @ 4848 NONAME ; bool QtConcurrent::internal::ExceptionStore::hasThrown(void) const
+ ??1ExceptionStore@internal@QtConcurrent@@QAE@XZ @ 4849 NONAME ; QtConcurrent::internal::ExceptionStore::~ExceptionStore(void)
+ ?isVector@ResultIteratorBase@QtConcurrent@@QBE_NXZ @ 4850 NONAME ; bool QtConcurrent::ResultIteratorBase::isVector(void) const
+ ?queryState@QFutureInterfaceBase@@QBE_NW4State@1@@Z @ 4851 NONAME ; bool QFutureInterfaceBase::queryState(enum QFutureInterfaceBase::State) const
+ ?end@ResultStoreBase@QtConcurrent@@QBE?AVResultIteratorBase@2@XZ @ 4852 NONAME ; class QtConcurrent::ResultIteratorBase QtConcurrent::ResultStoreBase::end(void) const
+ ?run@ThreadEngineBase@QtConcurrent@@EAEXXZ @ 4853 NONAME ; void QtConcurrent::ThreadEngineBase::run(void)
+ ?exception@ExceptionStore@internal@QtConcurrent@@QAE?AVExceptionHolder@23@XZ @ 4854 NONAME ; class QtConcurrent::internal::ExceptionHolder QtConcurrent::internal::ExceptionStore::exception(void)
+ ?isStarted@QFutureWatcherBase@@QBE_NXZ @ 4855 NONAME ; bool QFutureWatcherBase::isStarted(void) const
+ ?resultIndex@ResultIteratorBase@QtConcurrent@@QBEHXZ @ 4856 NONAME ; int QtConcurrent::ResultIteratorBase::resultIndex(void) const
+ ?qt_metacast@QFutureWatcherBase@@UAEPAXPBD@Z @ 4857 NONAME ; void * QFutureWatcherBase::qt_metacast(char const *)
+ ??9QFutureInterfaceBase@@QBE_NABV0@@Z @ 4858 NONAME ; bool QFutureInterfaceBase::operator!=(class QFutureInterfaceBase const &) const
+ ??0QFutureInterfaceBase@@QAE@W4State@0@@Z @ 4859 NONAME ; QFutureInterfaceBase::QFutureInterfaceBase(enum QFutureInterfaceBase::State)
+ ?staticMetaObjectExtraData@QFutureWatcherBase@@0UQMetaObjectExtraData@@B @ 4860 NONAME ; struct QMetaObjectExtraData const QFutureWatcherBase::staticMetaObjectExtraData
+ ??0QFutureWatcherBase@@QAE@PAVQObject@@@Z @ 4861 NONAME ; QFutureWatcherBase::QFutureWatcherBase(class QObject *)
+ ??1QFutureInterfaceBase@@UAE@XZ @ 4862 NONAME ; QFutureInterfaceBase::~QFutureInterfaceBase(void)
+ ?resume@QFutureWatcherBase@@QAEXXZ @ 4863 NONAME ; void QFutureWatcherBase::resume(void)
+ ?startSingleThreaded@ThreadEngineBase@QtConcurrent@@QAEXXZ @ 4864 NONAME ; void QtConcurrent::ThreadEngineBase::startSingleThreaded(void)
+ ?setPaused@QFutureWatcherBase@@QAEX_N@Z @ 4865 NONAME ; void QFutureWatcherBase::setPaused(bool)
+ ?waitForResume@QFutureInterfaceBase@@QAEXXZ @ 4866 NONAME ; void QFutureInterfaceBase::waitForResume(void)
+ ?progressMinimum@QFutureInterfaceBase@@QBEHXZ @ 4867 NONAME ; int QFutureInterfaceBase::progressMinimum(void) const
+ ?hasException@ExceptionStore@internal@QtConcurrent@@QBE_NXZ @ 4868 NONAME ; bool QtConcurrent::internal::ExceptionStore::hasException(void) const
+ ?tr@QFutureWatcherBase@@SA?AVQString@@PBD0H@Z @ 4869 NONAME ; class QString QFutureWatcherBase::tr(char const *, char const *, int)
+ ?resultAt@ResultStoreBase@QtConcurrent@@QBE?AVResultIteratorBase@2@H@Z @ 4870 NONAME ; class QtConcurrent::ResultIteratorBase QtConcurrent::ResultStoreBase::resultAt(int) const
+ ?connectOutputInterface@QFutureWatcherBase@@IAEXXZ @ 4871 NONAME ; void QFutureWatcherBase::connectOutputInterface(void)
+ ?insertResultItem@ResultStoreBase@QtConcurrent@@IAEHHAAVResultItem@2@@Z @ 4872 NONAME ; int QtConcurrent::ResultStoreBase::insertResultItem(int, class QtConcurrent::ResultItem &)
+ ?syncResultCount@ResultStoreBase@QtConcurrent@@IAEXXZ @ 4873 NONAME ; void QtConcurrent::ResultStoreBase::syncResultCount(void)
+ ?setProgressRange@ThreadEngineBase@QtConcurrent@@QAEXHH@Z @ 4874 NONAME ; void QtConcurrent::ThreadEngineBase::setProgressRange(int, int)
+ ??_EQFutureWatcherBase@@UAE@I@Z @ 4875 NONAME ; QFutureWatcherBase::~QFutureWatcherBase(unsigned int)
+ ?progressValueChanged@QFutureWatcherBase@@IAEXH@Z @ 4876 NONAME ; void QFutureWatcherBase::progressValueChanged(int)
+ ?threadExit@ThreadEngineBase@QtConcurrent@@AAEXXZ @ 4877 NONAME ; void QtConcurrent::ThreadEngineBase::threadExit(void)
+ ?mutex@QFutureInterfaceBase@@QBEPAVQMutex@@XZ @ 4878 NONAME ; class QMutex * QFutureInterfaceBase::mutex(void) const
+ ?staticMetaObject@QFutureWatcherBase@@2UQMetaObject@@B @ 4879 NONAME ; struct QMetaObject const QFutureWatcherBase::staticMetaObject
+ ?setException@ExceptionStore@internal@QtConcurrent@@QAEXABVException@3@@Z @ 4880 NONAME ; void QtConcurrent::internal::ExceptionStore::setException(class QtConcurrent::Exception const &)
+ ??0ResultIteratorBase@QtConcurrent@@QAE@XZ @ 4881 NONAME ; QtConcurrent::ResultIteratorBase::ResultIteratorBase(void)
+ ?hasNextResult@ResultStoreBase@QtConcurrent@@QBE_NXZ @ 4882 NONAME ; bool QtConcurrent::ResultStoreBase::hasNextResult(void) const
+ ??_EResultStoreBase@QtConcurrent@@UAE@I@Z @ 4883 NONAME ; QtConcurrent::ResultStoreBase::~ResultStoreBase(unsigned int)
+ ?contains@ResultStoreBase@QtConcurrent@@QBE_NH@Z @ 4884 NONAME ; bool QtConcurrent::ResultStoreBase::contains(int) const
+ ?updateInsertIndex@ResultStoreBase@QtConcurrent@@IAEHHH@Z @ 4885 NONAME ; int QtConcurrent::ResultStoreBase::updateInsertIndex(int, int)
+ ??_EException@QtConcurrent@@UAE@I@Z @ 4886 NONAME ; QtConcurrent::Exception::~Exception(unsigned int)
+ ?qt_metacall@QFutureWatcherBase@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 4887 NONAME ; int QFutureWatcherBase::qt_metacall(enum QMetaObject::Call, int, void * *)
+ ?isStarted@QFutureInterfaceBase@@QBE_NXZ @ 4888 NONAME ; bool QFutureInterfaceBase::isStarted(void) const
+ ??0QFutureInterfaceBase@@QAE@ABV0@@Z @ 4889 NONAME ; QFutureInterfaceBase::QFutureInterfaceBase(class QFutureInterfaceBase const &)
+ ??_EUnhandledException@QtConcurrent@@UAE@I@Z @ 4890 NONAME ; QtConcurrent::UnhandledException::~UnhandledException(unsigned int)
+ ?progressValue@QFutureWatcherBase@@QBEHXZ @ 4891 NONAME ; int QFutureWatcherBase::progressValue(void) const
+ ??8ResultIteratorBase@QtConcurrent@@QBE_NABV01@@Z @ 4892 NONAME ; bool QtConcurrent::ResultIteratorBase::operator==(class QtConcurrent::ResultIteratorBase const &) const
+ ?tr@QFutureWatcherBase@@SA?AVQString@@PBD0@Z @ 4893 NONAME ; class QString QFutureWatcherBase::tr(char const *, char const *)
+ ?startBlocking@ThreadEngineBase@QtConcurrent@@QAEXXZ @ 4894 NONAME ; void QtConcurrent::ThreadEngineBase::startBlocking(void)
+ ?threadThrottleExit@ThreadEngineBase@QtConcurrent@@AAE_NXZ @ 4895 NONAME ; bool QtConcurrent::ThreadEngineBase::threadThrottleExit(void)
+ ?isFinished@QFutureWatcherBase@@QBE_NXZ @ 4896 NONAME ; bool QFutureWatcherBase::isFinished(void) const
+ ?resultsReadyAt@QFutureWatcherBase@@IAEXHH@Z @ 4897 NONAME ; void QFutureWatcherBase::resultsReadyAt(int, int)
+ ?start@ThreadEngineBase@QtConcurrent@@MAEXXZ @ 4898 NONAME ; void QtConcurrent::ThreadEngineBase::start(void)
+ ?runningAnimationCount@QUnifiedTimer@@QAEHXZ @ 4899 NONAME ; int QUnifiedTimer::runningAnimationCount(void)
+ ??9ResultIteratorBase@QtConcurrent@@QBE_NABV01@@Z @ 4900 NONAME ; bool QtConcurrent::ResultIteratorBase::operator!=(class QtConcurrent::ResultIteratorBase const &) const
+ ??1UnhandledException@QtConcurrent@@UAE@XZ @ 4901 NONAME ; QtConcurrent::UnhandledException::~UnhandledException(void)
+ ?shouldStartThread@ThreadEngineBase@QtConcurrent@@MAE_NXZ @ 4902 NONAME ; bool QtConcurrent::ThreadEngineBase::shouldStartThread(void)
+ ?d_func@QFutureWatcherBase@@AAEPAVQFutureWatcherBasePrivate@@XZ @ 4903 NONAME ; class QFutureWatcherBasePrivate * QFutureWatcherBase::d_func(void)
+ ?startThread@ThreadEngineBase@QtConcurrent@@QAEXXZ @ 4904 NONAME ; void QtConcurrent::ThreadEngineBase::startThread(void)
+ ?threadFunction@ThreadEngineBase@QtConcurrent@@MAE?AW4ThreadFunctionResult@2@XZ @ 4905 NONAME ; enum QtConcurrent::ThreadFunctionResult QtConcurrent::ThreadEngineBase::threadFunction(void)
+ ?count@ResultStoreBase@QtConcurrent@@QBEHXZ @ 4906 NONAME ; int QtConcurrent::ResultStoreBase::count(void) const
+ ?isThrottled@QFutureInterfaceBase@@QBE_NXZ @ 4907 NONAME ; bool QFutureInterfaceBase::isThrottled(void) const
+ ?waitForResume@ThreadEngineBase@QtConcurrent@@QAEXXZ @ 4908 NONAME ; void QtConcurrent::ThreadEngineBase::waitForResume(void)
+ ?progressMinimum@QFutureWatcherBase@@QBEHXZ @ 4909 NONAME ; int QFutureWatcherBase::progressMinimum(void) const
+ ??1ThreadEngineBase@QtConcurrent@@UAE@XZ @ 4910 NONAME ; QtConcurrent::ThreadEngineBase::~ThreadEngineBase(void)
+ ?finished@QFutureWatcherBase@@IAEXXZ @ 4911 NONAME ; void QFutureWatcherBase::finished(void)
+ ?progressMaximum@QFutureInterfaceBase@@QBEHXZ @ 4912 NONAME ; int QFutureInterfaceBase::progressMaximum(void) const
+ ?pause@QFutureWatcherBase@@QAEXXZ @ 4913 NONAME ; void QFutureWatcherBase::pause(void)
+ ?isProgressReportingEnabled@ThreadEngineBase@QtConcurrent@@QAE_NXZ @ 4914 NONAME ; bool QtConcurrent::ThreadEngineBase::isProgressReportingEnabled(void)
+ ?blockSizeMaxed@BlockSizeManager@QtConcurrent@@AAE_NXZ @ 4915 NONAME ; bool QtConcurrent::BlockSizeManager::blockSizeMaxed(void)
+ ?isCanceled@QFutureInterfaceBase@@QBE_NXZ @ 4916 NONAME ; bool QFutureInterfaceBase::isCanceled(void) const
+ ?cancel@QFutureInterfaceBase@@QAEXXZ @ 4917 NONAME ; void QFutureInterfaceBase::cancel(void)
+ ?setFilterMode@QFutureInterfaceBase@@QAEX_N@Z @ 4918 NONAME ; void QFutureInterfaceBase::setFilterMode(bool)
+ ?setProgressValueAndText@QFutureInterfaceBase@@QAEXHABVQString@@@Z @ 4919 NONAME ; void QFutureInterfaceBase::setProgressValueAndText(int, class QString const &)
+ ?setRunnable@QFutureInterfaceBase@@QAEXPAVQRunnable@@@Z @ 4920 NONAME ; void QFutureInterfaceBase::setRunnable(class QRunnable *)
+ ?trUtf8@QFutureWatcherBase@@SA?AVQString@@PBD0H@Z @ 4921 NONAME ; class QString QFutureWatcherBase::trUtf8(char const *, char const *, int)
+ ?paused@QFutureWatcherBase@@IAEXXZ @ 4922 NONAME ; void QFutureWatcherBase::paused(void)
+ ?disconnectOutputInterface@QFutureWatcherBase@@IAEX_N@Z @ 4923 NONAME ; void QFutureWatcherBase::disconnectOutputInterface(bool)
+ ?isCanceled@QFutureWatcherBase@@QBE_NXZ @ 4924 NONAME ; bool QFutureWatcherBase::isCanceled(void) const
+ ?expectedResultCount@QFutureInterfaceBase@@QAEHXZ @ 4925 NONAME ; int QFutureInterfaceBase::expectedResultCount(void)
+ ??_EQFutureInterfaceBase@@UAE@I@Z @ 4926 NONAME ; QFutureInterfaceBase::~QFutureInterfaceBase(unsigned int)
+ ?waitForResult@QFutureInterfaceBase@@QAEXH@Z @ 4927 NONAME ; void QFutureInterfaceBase::waitForResult(int)
+ ?d_func@QFutureWatcherBase@@ABEPBVQFutureWatcherBasePrivate@@XZ @ 4928 NONAME ; class QFutureWatcherBasePrivate const * QFutureWatcherBase::d_func(void) const
+ ?setPaused@QFutureInterfaceBase@@QAEX_N@Z @ 4929 NONAME ; void QFutureInterfaceBase::setPaused(bool)
+ ??_EThreadEngineBase@QtConcurrent@@UAE@I@Z @ 4930 NONAME ; QtConcurrent::ThreadEngineBase::~ThreadEngineBase(unsigned int)
+ ??0Exception@QtConcurrent@@QAE@ABV01@@Z @ 4931 NONAME ; QtConcurrent::Exception::Exception(class QtConcurrent::Exception const &)
+ ?referenceCountIsOne@QFutureInterfaceBase@@IBE_NXZ @ 4932 NONAME ; bool QFutureInterfaceBase::referenceCountIsOne(void) const
+ ?progressText@QFutureInterfaceBase@@QBE?AVQString@@XZ @ 4933 NONAME ; class QString QFutureInterfaceBase::progressText(void) const
+ ?startThreadInternal@ThreadEngineBase@QtConcurrent@@AAE_NXZ @ 4934 NONAME ; bool QtConcurrent::ThreadEngineBase::startThreadInternal(void)
+ ?addResult@ResultStoreBase@QtConcurrent@@QAEHHPBX@Z @ 4935 NONAME ; int QtConcurrent::ResultStoreBase::addResult(int, void const *)
+ ?waitForFinished@QFutureWatcherBase@@QAEXXZ @ 4936 NONAME ; void QFutureWatcherBase::waitForFinished(void)
+ ?togglePaused@QFutureInterfaceBase@@QAEXXZ @ 4937 NONAME ; void QFutureInterfaceBase::togglePaused(void)
+ ?isProgressUpdateNeeded@QFutureInterfaceBase@@QBE_NXZ @ 4938 NONAME ; bool QFutureInterfaceBase::isProgressUpdateNeeded(void) const
+ ?resultReadyAt@QFutureWatcherBase@@IAEXH@Z @ 4939 NONAME ; void QFutureWatcherBase::resultReadyAt(int)
+ ?waitForNextResult@QFutureInterfaceBase@@QAE_NXZ @ 4940 NONAME ; bool QFutureInterfaceBase::waitForNextResult(void)
+ ?raise@UnhandledException@QtConcurrent@@UBEXXZ @ 4941 NONAME ; void QtConcurrent::UnhandledException::raise(void) const
+ ?setProgressValue@QFutureInterfaceBase@@QAEXH@Z @ 4942 NONAME ; void QFutureInterfaceBase::setProgressValue(int)
+ ?startThreads@ThreadEngineBase@QtConcurrent@@AAEXXZ @ 4943 NONAME ; void QtConcurrent::ThreadEngineBase::startThreads(void)
+ ?isPaused@QFutureInterfaceBase@@QBE_NXZ @ 4944 NONAME ; bool QFutureInterfaceBase::isPaused(void) const
+ ?resultStoreBase@QFutureInterfaceBase@@QAEAAVResultStoreBase@QtConcurrent@@XZ @ 4945 NONAME ; class QtConcurrent::ResultStoreBase & QFutureInterfaceBase::resultStoreBase(void)
+ ?isRunning@QFutureInterfaceBase@@QBE_NXZ @ 4946 NONAME ; bool QFutureInterfaceBase::isRunning(void) const
+ ?begin@ResultStoreBase@QtConcurrent@@QBE?AVResultIteratorBase@2@XZ @ 4947 NONAME ; class QtConcurrent::ResultIteratorBase QtConcurrent::ResultStoreBase::begin(void) const
+ ?resultStoreBase@QFutureInterfaceBase@@QBEABVResultStoreBase@QtConcurrent@@XZ @ 4948 NONAME ; class QtConcurrent::ResultStoreBase const & QFutureInterfaceBase::resultStoreBase(void) const
+ ?setExpectedResultCount@QFutureInterfaceBase@@QAEXH@Z @ 4949 NONAME ; void QFutureInterfaceBase::setExpectedResultCount(int)
+ ?progressMaximum@QFutureWatcherBase@@QBEHXZ @ 4950 NONAME ; int QFutureWatcherBase::progressMaximum(void) const
+ ??0ResultStoreBase@QtConcurrent@@QAE@XZ @ 4951 NONAME ; QtConcurrent::ResultStoreBase::ResultStoreBase(void)
+ ?setProgressRange@QFutureInterfaceBase@@QAEXHH@Z @ 4952 NONAME ; void QFutureInterfaceBase::setProgressRange(int, int)
+ ?canIncrementVectorIndex@ResultIteratorBase@QtConcurrent@@QBE_NXZ @ 4953 NONAME ; bool QtConcurrent::ResultIteratorBase::canIncrementVectorIndex(void) const
+ ?progressValue@QFutureInterfaceBase@@QBEHXZ @ 4954 NONAME ; int QFutureInterfaceBase::progressValue(void) const
+ ?cancel@QFutureWatcherBase@@QAEXXZ @ 4955 NONAME ; void QFutureWatcherBase::cancel(void)
+ ?trolltechConf@QCoreApplicationPrivate@@SAPAVQSettings@@XZ @ 4956 NONAME ; class QSettings * QCoreApplicationPrivate::trolltechConf(void)
+ ?trUtf8@QFutureWatcherBase@@SA?AVQString@@PBD0@Z @ 4957 NONAME ; class QString QFutureWatcherBase::trUtf8(char const *, char const *)
+ ?getStaticMetaObject@QFutureWatcherBase@@SAABUQMetaObject@@XZ @ 4958 NONAME ; struct QMetaObject const & QFutureWatcherBase::getStaticMetaObject(void)
+ ?vectorIndex@ResultIteratorBase@QtConcurrent@@QBEHXZ @ 4959 NONAME ; int QtConcurrent::ResultIteratorBase::vectorIndex(void) const
+ ?syncPendingResults@ResultStoreBase@QtConcurrent@@IAEXXZ @ 4960 NONAME ; void QtConcurrent::ResultStoreBase::syncPendingResults(void)
+ ?progressText@QFutureWatcherBase@@QBE?AVQString@@XZ @ 4961 NONAME ; class QString QFutureWatcherBase::progressText(void) const
+ ??1QFutureWatcherBase@@UAE@XZ @ 4962 NONAME ; QFutureWatcherBase::~QFutureWatcherBase(void)
+ ?togglePaused@QFutureWatcherBase@@QAEXXZ @ 4963 NONAME ; void QFutureWatcherBase::togglePaused(void)
+ ?acquireBarrierSemaphore@ThreadEngineBase@QtConcurrent@@QAEXXZ @ 4964 NONAME ; void QtConcurrent::ThreadEngineBase::acquireBarrierSemaphore(void)
+ ?setFilterMode@ResultStoreBase@QtConcurrent@@QAEX_N@Z @ 4965 NONAME ; void QtConcurrent::ResultStoreBase::setFilterMode(bool)
+ ?disconnectNotify@QFutureWatcherBase@@MAEXPBD@Z @ 4966 NONAME ; void QFutureWatcherBase::disconnectNotify(char const *)
+ ?handleException@ThreadEngineBase@QtConcurrent@@AAEXABVException@2@@Z @ 4967 NONAME ; void QtConcurrent::ThreadEngineBase::handleException(class QtConcurrent::Exception const &)
+ ?setThrottled@QFutureInterfaceBase@@QAEX_N@Z @ 4968 NONAME ; void QFutureInterfaceBase::setThrottled(bool)
+ ?setProgressValue@ThreadEngineBase@QtConcurrent@@QAEXH@Z @ 4969 NONAME ; void QtConcurrent::ThreadEngineBase::setProgressValue(int)
+ ??4QFutureInterfaceBase@@QAEAAV0@ABV0@@Z @ 4970 NONAME ; class QFutureInterfaceBase & QFutureInterfaceBase::operator=(class QFutureInterfaceBase const &)
+ ?isFinished@QFutureInterfaceBase@@QBE_NXZ @ 4971 NONAME ; bool QFutureInterfaceBase::isFinished(void) const
+ ?progressRangeChanged@QFutureWatcherBase@@IAEXHH@Z @ 4972 NONAME ; void QFutureWatcherBase::progressRangeChanged(int, int)
+ ?finish@ThreadEngineBase@QtConcurrent@@MAEXXZ @ 4973 NONAME ; void QtConcurrent::ThreadEngineBase::finish(void)
+ ?isRunning@QFutureWatcherBase@@QBE_NXZ @ 4974 NONAME ; bool QFutureWatcherBase::isRunning(void) const
+ ?reportResultsReady@QFutureInterfaceBase@@QAEXHH@Z @ 4975 NONAME ; void QFutureInterfaceBase::reportResultsReady(int, int)
+ ?qt_static_metacall@QFutureWatcherBase@@CAXPAVQObject@@W4Call@QMetaObject@@HPAPAX@Z @ 4976 NONAME ; void QFutureWatcherBase::qt_static_metacall(class QObject *, enum QMetaObject::Call, int, void * *)
+ ?blockSize@BlockSizeManager@QtConcurrent@@QAEHXZ @ 4977 NONAME ; int QtConcurrent::BlockSizeManager::blockSize(void)
+ ??0BlockSizeManager@QtConcurrent@@QAE@H@Z @ 4978 NONAME ; QtConcurrent::BlockSizeManager::BlockSizeManager(int)
+ ?batchSize@ResultIteratorBase@QtConcurrent@@QBEHXZ @ 4979 NONAME ; int QtConcurrent::ResultIteratorBase::batchSize(void) const
+ ?started@QFutureWatcherBase@@IAEXXZ @ 4980 NONAME ; void QFutureWatcherBase::started(void)
+ ?metaObject@QFutureWatcherBase@@UBEPBUQMetaObject@@XZ @ 4981 NONAME ; struct QMetaObject const * QFutureWatcherBase::metaObject(void) const
+ ?resumed@QFutureWatcherBase@@IAEXXZ @ 4982 NONAME ; void QFutureWatcherBase::resumed(void)
+ ??0UnhandledException@QtConcurrent@@QAE@ABV01@@Z @ 4983 NONAME ; QtConcurrent::UnhandledException::UnhandledException(class QtConcurrent::UnhandledException const &)
+ ?timeBeforeUser@BlockSizeManager@QtConcurrent@@QAEXXZ @ 4984 NONAME ; void QtConcurrent::BlockSizeManager::timeBeforeUser(void)
+ ??EResultIteratorBase@QtConcurrent@@QAE?AV01@XZ @ 4985 NONAME ; class QtConcurrent::ResultIteratorBase QtConcurrent::ResultIteratorBase::operator++(void)
+ ?isResultReadyAt@QFutureInterfaceBase@@QBE_NH@Z @ 4986 NONAME ; bool QFutureInterfaceBase::isResultReadyAt(int) const
+ ?throwPossibleException@ExceptionStore@internal@QtConcurrent@@QAEXXZ @ 4987 NONAME ; void QtConcurrent::internal::ExceptionStore::throwPossibleException(void)
+ ?setPendingResultsLimit@QFutureWatcherBase@@QAEXH@Z @ 4988 NONAME ; void QFutureWatcherBase::setPendingResultsLimit(int)
+ ?resultCount@QFutureInterfaceBase@@QBEHXZ @ 4989 NONAME ; int QFutureInterfaceBase::resultCount(void) const
+ ?event@QFutureWatcherBase@@UAE_NPAVQEvent@@@Z @ 4990 NONAME ; bool QFutureWatcherBase::event(class QEvent *)
+ ?isPaused@QFutureWatcherBase@@QBE_NXZ @ 4991 NONAME ; bool QFutureWatcherBase::isPaused(void) const
+ ?clone@Exception@QtConcurrent@@UBEPAV12@XZ @ 4992 NONAME ; class QtConcurrent::Exception * QtConcurrent::Exception::clone(void) const
+ ?insertResultItemIfValid@ResultStoreBase@QtConcurrent@@IAEXHAAVResultItem@2@@Z @ 4993 NONAME ; void QtConcurrent::ResultStoreBase::insertResultItemIfValid(int, class QtConcurrent::ResultItem &)
+ ?reportException@QFutureInterfaceBase@@QAEXABVException@QtConcurrent@@@Z @ 4994 NONAME ; void QFutureInterfaceBase::reportException(class QtConcurrent::Exception const &)
+ ?waitForFinished@QFutureInterfaceBase@@QAEXXZ @ 4995 NONAME ; void QFutureInterfaceBase::waitForFinished(void)
+ ??0ResultIteratorBase@QtConcurrent@@QAE@Vconst_iterator@?$QMap@HVResultItem@QtConcurrent@@@@H@Z @ 4996 NONAME ; QtConcurrent::ResultIteratorBase::ResultIteratorBase(class QMap<int, class QtConcurrent::ResultItem>::const_iterator, int)
+ ?reportStarted@QFutureInterfaceBase@@QAEXXZ @ 4997 NONAME ; void QFutureInterfaceBase::reportStarted(void)
+ ??8QFutureInterfaceBase@@QBE_NABV0@@Z @ 4998 NONAME ; bool QFutureInterfaceBase::operator==(class QFutureInterfaceBase const &) const
+ ?addResults@ResultStoreBase@QtConcurrent@@QAEHHPBXHH@Z @ 4999 NONAME ; int QtConcurrent::ResultStoreBase::addResults(int, void const *, int, int)
+ ?shouldThrottleThread@ThreadEngineBase@QtConcurrent@@MAE_NXZ @ 5000 NONAME ; bool QtConcurrent::ThreadEngineBase::shouldThrottleThread(void)
+ ?reportFinished@QFutureInterfaceBase@@QAEXXZ @ 5001 NONAME ; void QFutureInterfaceBase::reportFinished(void)
+ ??0ThreadEngineBase@QtConcurrent@@QAE@XZ @ 5002 NONAME ; QtConcurrent::ThreadEngineBase::ThreadEngineBase(void)
+ ??1Exception@QtConcurrent@@UAE@XZ @ 5003 NONAME ; QtConcurrent::Exception::~Exception(void)
+ ?filterMode@ResultStoreBase@QtConcurrent@@QBE_NXZ @ 5004 NONAME ; bool QtConcurrent::ResultStoreBase::filterMode(void) const
+ ?raise@Exception@QtConcurrent@@UBEXXZ @ 5005 NONAME ; void QtConcurrent::Exception::raise(void) const
+ ?batchedAdvance@ResultIteratorBase@QtConcurrent@@QAEXXZ @ 5006 NONAME ; void QtConcurrent::ResultIteratorBase::batchedAdvance(void)
+ ?exceptionStore@QFutureInterfaceBase@@QAEAAVExceptionStore@internal@QtConcurrent@@XZ @ 5007 NONAME ; class QtConcurrent::internal::ExceptionStore & QFutureInterfaceBase::exceptionStore(void)
+ ?reportCanceled@QFutureInterfaceBase@@QAEXXZ @ 5008 NONAME ; void QFutureInterfaceBase::reportCanceled(void)
+ ?connectNotify@QFutureWatcherBase@@MAEXPBD@Z @ 5009 NONAME ; void QFutureWatcherBase::connectNotify(char const *)
+ ??1ResultStoreBase@QtConcurrent@@UAE@XZ @ 5010 NONAME ; QtConcurrent::ResultStoreBase::~ResultStoreBase(void)
+ ?isCanceled@ThreadEngineBase@QtConcurrent@@QAE_NXZ @ 5011 NONAME ; bool QtConcurrent::ThreadEngineBase::isCanceled(void)
+ ?canceled@QFutureWatcherBase@@IAEXXZ @ 5012 NONAME ; void QFutureWatcherBase::canceled(void)
+ ?clone@UnhandledException@QtConcurrent@@UBEPAVException@2@XZ @ 5013 NONAME ; class QtConcurrent::Exception * QtConcurrent::UnhandledException::clone(void) const
diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def
index 813bbf8..88973f9 100644
--- a/src/s60installs/bwins/QtGuiu.def
+++ b/src/s60installs/bwins/QtGuiu.def
@@ -12855,7 +12855,7 @@ EXPORTS
?populate@QTextureGlyphCache@@QAEXPAVQFontEngine@@HPBIPBUQFixedPoint@@@Z @ 12854 NONAME ABSENT ; void QTextureGlyphCache::populate(class QFontEngine *, int, unsigned int const *, struct QFixedPoint const *)
?hasPartialUpdateSupport@QWindowSurface@@UBE_NXZ @ 12855 NONAME ABSENT ; bool QWindowSurface::hasPartialUpdateSupport(void) const
?scroll@QRuntimePixmapData@@UAE_NHHABVQRect@@@Z @ 12856 NONAME ; bool QRuntimePixmapData::scroll(int, int, class QRect const &)
- ?qt_draw_glyphs@@YAXPAVQPainter@@PBIPBVQPointF@@H@Z @ 12857 NONAME ; void qt_draw_glyphs(class QPainter *, unsigned int const *, class QPointF const *, int)
+ ?qt_draw_glyphs@@YAXPAVQPainter@@PBIPBVQPointF@@H@Z @ 12857 NONAME ABSENT ; void qt_draw_glyphs(class QPainter *, unsigned int const *, class QPointF const *, int)
?nativeDisplay@QEgl@@YAHXZ @ 12858 NONAME ; int QEgl::nativeDisplay(void)
?PreDocConstructL@QS60MainApplication@@UAEXXZ @ 12859 NONAME ; void QS60MainApplication::PreDocConstructL(void)
?detach@QStaticText@@AAEXXZ @ 12860 NONAME ; void QStaticText::detach(void)
@@ -13213,7 +13213,7 @@ EXPORTS
??0QRasterWindowSurface@@QAE@PAVQWidget@@_N@Z @ 13212 NONAME ; QRasterWindowSurface::QRasterWindowSurface(class QWidget *, bool)
?brushChanged@QBlitterPaintEngine@@UAEXXZ @ 13213 NONAME ; void QBlitterPaintEngine::brushChanged(void)
?clip@QBlitterPaintEngine@@UAEXABVQRect@@W4ClipOperation@Qt@@@Z @ 13214 NONAME ; void QBlitterPaintEngine::clip(class QRect const &, enum Qt::ClipOperation)
- ?detach@QGlyphs@@AAEXXZ @ 13215 NONAME ; void QGlyphs::detach(void)
+ ?detach@QGlyphs@@AAEXXZ @ 13215 NONAME ABSENT ; void QGlyphs::detach(void)
?trUtf8@QInternalMimeData@@SA?AVQString@@PBD0@Z @ 13216 NONAME ; class QString QInternalMimeData::trUtf8(char const *, char const *)
??0QShowEvent@@QAE@ABV0@@Z @ 13217 NONAME ABSENT ; QShowEvent::QShowEvent(class QShowEvent const &)
??0QMouseEvent@@QAE@ABV0@@Z @ 13218 NONAME ABSENT ; QMouseEvent::QMouseEvent(class QMouseEvent const &)
@@ -13260,7 +13260,7 @@ EXPORTS
?trUtf8@QFlickGesture@@SA?AVQString@@PBD0@Z @ 13259 NONAME ; class QString QFlickGesture::trUtf8(char const *, char const *)
?stop@QScroller@@QAEXXZ @ 13260 NONAME ; void QScroller::stop(void)
?retrieveData@QInternalMimeData@@MBE?AVQVariant@@ABVQString@@W4Type@2@@Z @ 13261 NONAME ; class QVariant QInternalMimeData::retrieveData(class QString const &, enum QVariant::Type) const
- ??8QGlyphs@@QBE_NABV0@@Z @ 13262 NONAME ; bool QGlyphs::operator==(class QGlyphs const &) const
+ ??8QGlyphs@@QBE_NABV0@@Z @ 13262 NONAME ABSENT ; bool QGlyphs::operator==(class QGlyphs const &) const
?drawImage@QBlitterPaintEngine@@UAEXABVQRectF@@ABVQImage@@0V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 13263 NONAME ; void QBlitterPaintEngine::drawImage(class QRectF const &, class QImage const &, class QRectF const &, class QFlags<enum Qt::ImageConversionFlag>)
?contentPos@QScrollEvent@@QBE?AVQPointF@@XZ @ 13264 NONAME ; class QPointF QScrollEvent::contentPos(void) const
?mimeTypes@QAbstractProxyModel@@UBE?AVQStringList@@XZ @ 13265 NONAME ; class QStringList QAbstractProxyModel::mimeTypes(void) const
@@ -13286,7 +13286,7 @@ EXPORTS
?canFetchMore@QAbstractProxyModel@@UBE_NABVQModelIndex@@@Z @ 13285 NONAME ; bool QAbstractProxyModel::canFetchMore(class QModelIndex const &) const
??4QStyleOptionProgressBarV2@@QAEAAV0@ABV0@@Z @ 13286 NONAME ABSENT ; class QStyleOptionProgressBarV2 & QStyleOptionProgressBarV2::operator=(class QStyleOptionProgressBarV2 const &)
??1QScroller@@EAE@XZ @ 13287 NONAME ; QScroller::~QScroller(void)
- ?setFont@QGlyphs@@QAEXABVQFont@@@Z @ 13288 NONAME ; void QGlyphs::setFont(class QFont const &)
+ ?setFont@QGlyphs@@QAEXABVQFont@@@Z @ 13288 NONAME ABSENT ; void QGlyphs::setFont(class QFont const &)
?startPos@QScrollPrepareEvent@@QBE?AVQPointF@@XZ @ 13289 NONAME ; class QPointF QScrollPrepareEvent::startPos(void) const
?resize@QBlittablePixmapData@@UAEXHH@Z @ 13290 NONAME ; void QBlittablePixmapData::resize(int, int)
?setTabsClosable@QMdiArea@@QAEX_N@Z @ 13291 NONAME ; void QMdiArea::setTabsClosable(bool)
@@ -13304,14 +13304,14 @@ EXPORTS
?opacityChanged@QBlitterPaintEngine@@UAEXXZ @ 13303 NONAME ; void QBlitterPaintEngine::opacityChanged(void)
?tr@QFlickGesture@@SA?AVQString@@PBD0H@Z @ 13304 NONAME ; class QString QFlickGesture::tr(char const *, char const *, int)
??_EQTextCursor@@QAE@I@Z @ 13305 NONAME ABSENT ; QTextCursor::~QTextCursor(unsigned int)
- ?createExplicitFontWithName@QFontEngine@@IBE?AVQFont@@ABVQString@@@Z @ 13306 NONAME ; class QFont QFontEngine::createExplicitFontWithName(class QString const &) const
+ ?createExplicitFontWithName@QFontEngine@@IBE?AVQFont@@ABVQString@@@Z @ 13306 NONAME ABSENT ; class QFont QFontEngine::createExplicitFontWithName(class QString const &) const
?setState@QBlitterPaintEngine@@UAEXPAVQPainterState@@@Z @ 13307 NONAME ; void QBlitterPaintEngine::setState(class QPainterState *)
?clip@QBlitterPaintEngine@@UAEXABVQRegion@@W4ClipOperation@Qt@@@Z @ 13308 NONAME ; void QBlitterPaintEngine::clip(class QRegion const &, enum Qt::ClipOperation)
?subPixelPositionForX@QTextureGlyphCache@@QBE?AUQFixed@@U2@@Z @ 13309 NONAME ; struct QFixed QTextureGlyphCache::subPixelPositionForX(struct QFixed) const
?hasAlphaChannel@QBlittablePixmapData@@UBE_NXZ @ 13310 NONAME ; bool QBlittablePixmapData::hasAlphaChannel(void) const
?setSnapPositionsX@QScroller@@QAEXABV?$QList@M@@@Z @ 13311 NONAME ; void QScroller::setSnapPositionsX(class QList<float> const &)
?numberSuffix@QTextListFormat@@QBE?AVQString@@XZ @ 13312 NONAME ; class QString QTextListFormat::numberSuffix(void) const
- ??HQGlyphs@@ABE?AV0@ABV0@@Z @ 13313 NONAME ; class QGlyphs QGlyphs::operator+(class QGlyphs const &) const
+ ??HQGlyphs@@ABE?AV0@ABV0@@Z @ 13313 NONAME ABSENT ; class QGlyphs QGlyphs::operator+(class QGlyphs const &) const
??0QGradient@@QAE@ABV0@@Z @ 13314 NONAME ABSENT ; QGradient::QGradient(class QGradient const &)
?tabsMovable@QMdiArea@@QBE_NXZ @ 13315 NONAME ; bool QMdiArea::tabsMovable(void) const
??4QInputMethodEvent@@QAEAAV0@ABV0@@Z @ 13316 NONAME ABSENT ; class QInputMethodEvent & QInputMethodEvent::operator=(class QInputMethodEvent const &)
@@ -13329,7 +13329,7 @@ EXPORTS
??_EQKeySequence@@QAE@I@Z @ 13328 NONAME ABSENT ; QKeySequence::~QKeySequence(unsigned int)
?tr@QInternalMimeData@@SA?AVQString@@PBD0H@Z @ 13329 NONAME ; class QString QInternalMimeData::tr(char const *, char const *, int)
?velocity@QScroller@@QBE?AVQPointF@@XZ @ 13330 NONAME ; class QPointF QScroller::velocity(void) const
- ?glyphIndexes@QGlyphs@@QBE?AV?$QVector@I@@XZ @ 13331 NONAME ; class QVector<unsigned int> QGlyphs::glyphIndexes(void) const
+ ?glyphIndexes@QGlyphs@@QBE?AV?$QVector@I@@XZ @ 13331 NONAME ABSENT ; class QVector<unsigned int> QGlyphs::glyphIndexes(void) const
?get@QFontPrivate@@SAPAV1@ABVQFont@@@Z @ 13332 NONAME ; class QFontPrivate * QFontPrivate::get(class QFont const &)
?setScrollMetric@QScrollerProperties@@QAEXW4ScrollMetric@1@ABVQVariant@@@Z @ 13333 NONAME ; void QScrollerProperties::setScrollMetric(enum QScrollerProperties::ScrollMetric, class QVariant const &)
??4QGradient@@QAEAAV0@ABV0@@Z @ 13334 NONAME ABSENT ; class QGradient & QGradient::operator=(class QGradient const &)
@@ -13339,7 +13339,7 @@ EXPORTS
??0QTextTableFormat@@QAE@ABV0@@Z @ 13338 NONAME ABSENT ; QTextTableFormat::QTextTableFormat(class QTextTableFormat const &)
??_EQImagePixmapCleanupHooks@@QAE@I@Z @ 13339 NONAME ABSENT ; QImagePixmapCleanupHooks::~QImagePixmapCleanupHooks(unsigned int)
?fetchMore@QAbstractProxyModel@@UAEXABVQModelIndex@@@Z @ 13340 NONAME ; void QAbstractProxyModel::fetchMore(class QModelIndex const &)
- ?glyphs@QTextLine@@ABE?AV?$QList@VQGlyphs@@@@HH@Z @ 13341 NONAME ; class QList<class QGlyphs> QTextLine::glyphs(int, int) const
+ ?glyphs@QTextLine@@ABE?AV?$QList@VQGlyphs@@@@HH@Z @ 13341 NONAME ABSENT ; class QList<class QGlyphs> QTextLine::glyphs(int, int) const
?getStaticMetaObject@QFlickGesture@@SAABUQMetaObject@@XZ @ 13342 NONAME ; struct QMetaObject const & QFlickGesture::getStaticMetaObject(void)
?setViewportSize@QScrollPrepareEvent@@QAEXABVQSizeF@@@Z @ 13343 NONAME ; void QScrollPrepareEvent::setViewportSize(class QSizeF const &)
??0QStatusTipEvent@@QAE@ABV0@@Z @ 13344 NONAME ABSENT ; QStatusTipEvent::QStatusTipEvent(class QStatusTipEvent const &)
@@ -13374,7 +13374,7 @@ EXPORTS
??4QStyleOptionQ3DockWindow@@QAEAAV0@ABV0@@Z @ 13373 NONAME ABSENT ; class QStyleOptionQ3DockWindow & QStyleOptionQ3DockWindow::operator=(class QStyleOptionQ3DockWindow const &)
?qt_metacast@QFlickGesture@@UAEPAXPBD@Z @ 13374 NONAME ; void * QFlickGesture::qt_metacast(char const *)
??_EQFont@@QAE@I@Z @ 13375 NONAME ABSENT ; QFont::~QFont(unsigned int)
- ?setPositions@QGlyphs@@QAEXABV?$QVector@VQPointF@@@@@Z @ 13376 NONAME ; void QGlyphs::setPositions(class QVector<class QPointF> const &)
+ ?setPositions@QGlyphs@@QAEXABV?$QVector@VQPointF@@@@@Z @ 13376 NONAME ABSENT ; void QGlyphs::setPositions(class QVector<class QPointF> const &)
??4QStyleOptionDockWidget@@QAEAAV0@ABV0@@Z @ 13377 NONAME ABSENT ; class QStyleOptionDockWidget & QStyleOptionDockWidget::operator=(class QStyleOptionDockWidget const &)
??0QPainterState@@QAE@ABV0@@Z @ 13378 NONAME ABSENT ; QPainterState::QPainterState(class QPainterState const &)
??4QStyleOptionFrame@@QAEAAV0@ABV0@@Z @ 13379 NONAME ABSENT ; class QStyleOptionFrame & QStyleOptionFrame::operator=(class QStyleOptionFrame const &)
@@ -13384,7 +13384,7 @@ EXPORTS
?renderHintsChanged@QBlitterPaintEngine@@UAEXXZ @ 13383 NONAME ; void QBlitterPaintEngine::renderHintsChanged(void)
?supportedDropActions@QAbstractProxyModel@@UBE?AV?$QFlags@W4DropAction@Qt@@@@XZ @ 13384 NONAME ; class QFlags<enum Qt::DropAction> QAbstractProxyModel::supportedDropActions(void) const
?fillRect@QBlitterPaintEngine@@UAEXABVQRectF@@ABVQBrush@@@Z @ 13385 NONAME ; void QBlitterPaintEngine::fillRect(class QRectF const &, class QBrush const &)
- ?setGlyphIndexes@QGlyphs@@QAEXABV?$QVector@I@@@Z @ 13386 NONAME ; void QGlyphs::setGlyphIndexes(class QVector<unsigned int> const &)
+ ?setGlyphIndexes@QGlyphs@@QAEXABV?$QVector@I@@@Z @ 13386 NONAME ABSENT ; void QGlyphs::setGlyphIndexes(class QVector<unsigned int> const &)
?alphaMapBoundingBox@QFontEngine@@UAE?AUglyph_metrics_t@@IABVQTransform@@W4GlyphFormat@1@@Z @ 13387 NONAME ABSENT ; struct glyph_metrics_t QFontEngine::alphaMapBoundingBox(unsigned int, class QTransform const &, enum QFontEngine::GlyphFormat)
?resendPrepareEvent@QScroller@@QAEXXZ @ 13388 NONAME ; void QScroller::resendPrepareEvent(void)
??4QTextLength@@QAEAAV0@ABV0@@Z @ 13389 NONAME ABSENT ; class QTextLength & QTextLength::operator=(class QTextLength const &)
@@ -13399,12 +13399,12 @@ EXPORTS
?scrollTo@QScroller@@QAEXABVQPointF@@H@Z @ 13398 NONAME ; void QScroller::scrollTo(class QPointF const &, int)
?ungrabGesture@QScroller@@SAXPAVQObject@@@Z @ 13399 NONAME ; void QScroller::ungrabGesture(class QObject *)
??4QItemSelectionRange@@QAEAAV0@ABV0@@Z @ 13400 NONAME ABSENT ; class QItemSelectionRange & QItemSelectionRange::operator=(class QItemSelectionRange const &)
- ?clear@QGlyphs@@QAEXXZ @ 13401 NONAME ; void QGlyphs::clear(void)
+ ?clear@QGlyphs@@QAEXXZ @ 13401 NONAME ABSENT ; void QGlyphs::clear(void)
??_EQStyleOptionViewItemV4@@QAE@I@Z @ 13402 NONAME ABSENT ; QStyleOptionViewItemV4::~QStyleOptionViewItemV4(unsigned int)
??1QBlittablePixmapData@@UAE@XZ @ 13403 NONAME ; QBlittablePixmapData::~QBlittablePixmapData(void)
?formatsHelper@QInternalMimeData@@SA?AVQStringList@@PBVQMimeData@@@Z @ 13404 NONAME ; class QStringList QInternalMimeData::formatsHelper(class QMimeData const *)
?qt_metacast@QInternalMimeData@@UAEPAXPBD@Z @ 13405 NONAME ; void * QInternalMimeData::qt_metacast(char const *)
- ?font@QGlyphs@@QBE?AVQFont@@XZ @ 13406 NONAME ; class QFont QGlyphs::font(void) const
+ ?font@QGlyphs@@QBE?AVQFont@@XZ @ 13406 NONAME ABSENT ; class QFont QGlyphs::font(void) const
?paintEngine@QBlittablePixmapData@@UBEPAVQPaintEngine@@XZ @ 13407 NONAME ; class QPaintEngine * QBlittablePixmapData::paintEngine(void) const
?unsetDefaultScrollerProperties@QScrollerProperties@@SAXXZ @ 13408 NONAME ; void QScrollerProperties::unsetDefaultScrollerProperties(void)
?hasChildren@QAbstractProxyModel@@UBE_NABVQModelIndex@@@Z @ 13409 NONAME ; bool QAbstractProxyModel::hasChildren(class QModelIndex const &) const
@@ -13422,7 +13422,7 @@ EXPORTS
?qt_metacall@QInternalMimeData@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 13421 NONAME ; int QInternalMimeData::qt_metacall(enum QMetaObject::Call, int, void * *)
?lineHeightType@QTextBlockFormat@@QBEHXZ @ 13422 NONAME ; int QTextBlockFormat::lineHeightType(void) const
?hintingPreference@QFont@@QBE?AW4HintingPreference@1@XZ @ 13423 NONAME ; enum QFont::HintingPreference QFont::hintingPreference(void) const
- ??0QGlyphs@@QAE@XZ @ 13424 NONAME ; QGlyphs::QGlyphs(void)
+ ??0QGlyphs@@QAE@XZ @ 13424 NONAME ABSENT ; QGlyphs::QGlyphs(void)
?trUtf8@QInternalMimeData@@SA?AVQString@@PBD0H@Z @ 13425 NONAME ; class QString QInternalMimeData::trUtf8(char const *, char const *, int)
??0QImageIOHandlerFactoryInterface@@QAE@XZ @ 13426 NONAME ABSENT ; QImageIOHandlerFactoryInterface::QImageIOHandlerFactoryInterface(void)
??_EQRegion@@QAE@I@Z @ 13427 NONAME ABSENT ; QRegion::~QRegion(unsigned int)
@@ -13442,10 +13442,10 @@ EXPORTS
?clip@QBlitterPaintEngine@@UAEXABVQVectorPath@@W4ClipOperation@Qt@@@Z @ 13441 NONAME ; void QBlitterPaintEngine::clip(class QVectorPath const &, enum Qt::ClipOperation)
??1QScrollEvent@@UAE@XZ @ 13442 NONAME ; QScrollEvent::~QScrollEvent(void)
?state@QScroller@@QBE?AW4State@1@XZ @ 13443 NONAME ; enum QScroller::State QScroller::state(void) const
- ?positions@QGlyphs@@QBE?AV?$QVector@VQPointF@@@@XZ @ 13444 NONAME ; class QVector<class QPointF> QGlyphs::positions(void) const
+ ?positions@QGlyphs@@QBE?AV?$QVector@VQPointF@@@@XZ @ 13444 NONAME ABSENT ; class QVector<class QPointF> QGlyphs::positions(void) const
?tr@QScroller@@SA?AVQString@@PBD0@Z @ 13445 NONAME ; class QString QScroller::tr(char const *, char const *)
?canReadData@QInternalMimeData@@SA_NABVQString@@@Z @ 13446 NONAME ; bool QInternalMimeData::canReadData(class QString const &)
- ?glyphs@QTextLayout@@QBE?AV?$QList@VQGlyphs@@@@XZ @ 13447 NONAME ; class QList<class QGlyphs> QTextLayout::glyphs(void) const
+ ?glyphs@QTextLayout@@QBE?AV?$QList@VQGlyphs@@@@XZ @ 13447 NONAME ABSENT ; class QList<class QGlyphs> QTextLayout::glyphs(void) const
?leadingSpaceWidth@QTextEngine@@QAE?AUQFixed@@ABUQScriptLine@@@Z @ 13448 NONAME ; struct QFixed QTextEngine::leadingSpaceWidth(struct QScriptLine const &)
??_EQTextFormat@@QAE@I@Z @ 13449 NONAME ABSENT ; QTextFormat::~QTextFormat(unsigned int)
??4QStyleOptionTabWidgetFrame@@QAEAAV0@ABV0@@Z @ 13450 NONAME ABSENT ; class QStyleOptionTabWidgetFrame & QStyleOptionTabWidgetFrame::operator=(class QStyleOptionTabWidgetFrame const &)
@@ -13463,7 +13463,7 @@ EXPORTS
??0QInternalMimeData@@QAE@XZ @ 13462 NONAME ; QInternalMimeData::QInternalMimeData(void)
??_EQScrollEvent@@UAE@I@Z @ 13463 NONAME ; QScrollEvent::~QScrollEvent(unsigned int)
?features@QRasterWindowSurface@@UBE?AV?$QFlags@W4WindowSurfaceFeature@QWindowSurface@@@@XZ @ 13464 NONAME ; class QFlags<enum QWindowSurface::WindowSurfaceFeature> QRasterWindowSurface::features(void) const
- ??4QGlyphs@@QAEAAV0@ABV0@@Z @ 13465 NONAME ; class QGlyphs & QGlyphs::operator=(class QGlyphs const &)
+ ??4QGlyphs@@QAEAAV0@ABV0@@Z @ 13465 NONAME ABSENT ; class QGlyphs & QGlyphs::operator=(class QGlyphs const &)
??4QQuaternion@@QAEAAV0@ABV0@@Z @ 13466 NONAME ABSENT ; class QQuaternion & QQuaternion::operator=(class QQuaternion const &)
??4Symbol@QCss@@QAEAAU01@ABU01@@Z @ 13467 NONAME ABSENT ; struct QCss::Symbol & QCss::Symbol::operator=(struct QCss::Symbol const &)
??0QBlittable@@QAE@ABVQSize@@V?$QFlags@W4Capability@QBlittable@@@@@Z @ 13468 NONAME ; QBlittable::QBlittable(class QSize const &, class QFlags<enum QBlittable::Capability>)
@@ -13480,10 +13480,10 @@ EXPORTS
?calculateSubPixelPositionCount@QTextureGlyphCache@@IBEHI@Z @ 13479 NONAME ; int QTextureGlyphCache::calculateSubPixelPositionCount(unsigned int) const
??0QTextImageFormat@@QAE@ABV0@@Z @ 13480 NONAME ABSENT ; QTextImageFormat::QTextImageFormat(class QTextImageFormat const &)
??0QMoveEvent@@QAE@ABV0@@Z @ 13481 NONAME ABSENT ; QMoveEvent::QMoveEvent(class QMoveEvent const &)
- ?glyphs@QTextFragment@@QBE?AV?$QList@VQGlyphs@@@@XZ @ 13482 NONAME ; class QList<class QGlyphs> QTextFragment::glyphs(void) const
+ ?glyphs@QTextFragment@@QBE?AV?$QList@VQGlyphs@@@@XZ @ 13482 NONAME ABSENT ; class QList<class QGlyphs> QTextFragment::glyphs(void) const
??0QInputContextFactoryInterface@@QAE@XZ @ 13483 NONAME ABSENT ; QInputContextFactoryInterface::QInputContextFactoryInterface(void)
??0QTextFrameFormat@@QAE@ABV0@@Z @ 13484 NONAME ABSENT ; QTextFrameFormat::QTextFrameFormat(class QTextFrameFormat const &)
- ?resetInternalData@QAbstractProxyModel@@IAEXXZ @ 13485 NONAME ; void QAbstractProxyModel::resetInternalData(void)
+ ?resetInternalData@QAbstractProxyModel@@IAEXXZ @ 13485 NONAME ABSENT ; void QAbstractProxyModel::resetInternalData(void)
??0Symbol@QCss@@QAE@ABU01@@Z @ 13486 NONAME ABSENT ; QCss::Symbol::Symbol(struct QCss::Symbol const &)
?features@QWindowSurface@@UBE?AV?$QFlags@W4WindowSurfaceFeature@QWindowSurface@@@@XZ @ 13487 NONAME ; class QFlags<enum QWindowSurface::WindowSurfaceFeature> QWindowSurface::features(void) const
?markRasterOverlay@QBlittablePixmapData@@QAEXABVQVectorPath@@@Z @ 13488 NONAME ; void QBlittablePixmapData::markRasterOverlay(class QVectorPath const &)
@@ -13499,7 +13499,7 @@ EXPORTS
?swap@QPainterPath@@QAEXAAV1@@Z @ 13498 NONAME ; void QPainterPath::swap(class QPainterPath &)
??4QStyleOptionRubberBand@@QAEAAV0@ABV0@@Z @ 13499 NONAME ABSENT ; class QStyleOptionRubberBand & QStyleOptionRubberBand::operator=(class QStyleOptionRubberBand const &)
?minimumSizeHint@QCheckBox@@UBE?AVQSize@@XZ @ 13500 NONAME ; class QSize QCheckBox::minimumSizeHint(void) const
- ?createExplicitFont@QFontEngine@@UBE?AVQFont@@XZ @ 13501 NONAME ; class QFont QFontEngine::createExplicitFont(void) const
+ ?createExplicitFont@QFontEngine@@UBE?AVQFont@@XZ @ 13501 NONAME ABSENT ; class QFont QFontEngine::createExplicitFont(void) const
?alphaMapForGlyph@QFontEngine@@UAE?AVQImage@@IUQFixed@@@Z @ 13502 NONAME ; class QImage QFontEngine::alphaMapForGlyph(unsigned int, struct QFixed)
?fillTexture@QImageTextureGlyphCache@@UAEXABUCoord@QTextureGlyphCache@@IUQFixed@@@Z @ 13503 NONAME ; void QImageTextureGlyphCache::fillTexture(struct QTextureGlyphCache::Coord const &, unsigned int, struct QFixed)
?swap@QIcon@@QAEXAAV1@@Z @ 13504 NONAME ; void QIcon::swap(class QIcon &)
@@ -13532,11 +13532,11 @@ EXPORTS
?pixelPerMeter@QScroller@@QBE?AVQPointF@@XZ @ 13531 NONAME ; class QPointF QScroller::pixelPerMeter(void) const
?target@QScroller@@QBEPAVQObject@@XZ @ 13532 NONAME ; class QObject * QScroller::target(void) const
?swap@QKeySequence@@QAEXAAV1@@Z @ 13533 NONAME ; void QKeySequence::swap(class QKeySequence &)
- ??1QGlyphs@@QAE@XZ @ 13534 NONAME ; QGlyphs::~QGlyphs(void)
+ ??1QGlyphs@@QAE@XZ @ 13534 NONAME ABSENT ; QGlyphs::~QGlyphs(void)
?lineHeight@QTextBlockFormat@@QBEMXZ @ 13535 NONAME ; float QTextBlockFormat::lineHeight(void) const
?stroke@QBlitterPaintEngine@@UAEXABVQVectorPath@@ABVQPen@@@Z @ 13536 NONAME ; void QBlitterPaintEngine::stroke(class QVectorPath const &, class QPen const &)
?tr@QInternalMimeData@@SA?AVQString@@PBD0@Z @ 13537 NONAME ; class QString QInternalMimeData::tr(char const *, char const *)
- ??9QGlyphs@@QBE_NABV0@@Z @ 13538 NONAME ; bool QGlyphs::operator!=(class QGlyphs const &) const
+ ??9QGlyphs@@QBE_NABV0@@Z @ 13538 NONAME ABSENT ; bool QGlyphs::operator!=(class QGlyphs const &) const
??1QBlittable@@UAE@XZ @ 13539 NONAME ; QBlittable::~QBlittable(void)
??_EQBlitterPaintEngine@@UAE@I@Z @ 13540 NONAME ; QBlitterPaintEngine::~QBlitterPaintEngine(unsigned int)
??0QCloseEvent@@QAE@ABV0@@Z @ 13541 NONAME ABSENT ; QCloseEvent::QCloseEvent(class QCloseEvent const &)
@@ -13547,7 +13547,7 @@ EXPORTS
?finalPosition@QScroller@@QBE?AVQPointF@@XZ @ 13546 NONAME ; class QPointF QScroller::finalPosition(void) const
??4QStyleOptionTabWidgetFrameV2@@QAEAAV0@ABV0@@Z @ 13547 NONAME ABSENT ; class QStyleOptionTabWidgetFrameV2 & QStyleOptionTabWidgetFrameV2::operator=(class QStyleOptionTabWidgetFrameV2 const &)
?drawStaticTextItem@QBlitterPaintEngine@@UAEXPAVQStaticTextItem@@@Z @ 13548 NONAME ; void QBlitterPaintEngine::drawStaticTextItem(class QStaticTextItem *)
- ??0QGlyphs@@QAE@ABV0@@Z @ 13549 NONAME ; QGlyphs::QGlyphs(class QGlyphs const &)
+ ??0QGlyphs@@QAE@ABV0@@Z @ 13549 NONAME ABSENT ; QGlyphs::QGlyphs(class QGlyphs const &)
?lock@QBlittable@@QAEPAVQImage@@XZ @ 13550 NONAME ; class QImage * QBlittable::lock(void)
?setFontHintingPreference@QTextCharFormat@@QAEXW4HintingPreference@QFont@@@Z @ 13551 NONAME ; void QTextCharFormat::setFontHintingPreference(enum QFont::HintingPreference)
??4QStyleOptionTabV2@@QAEAAV0@ABV0@@Z @ 13552 NONAME ABSENT ; class QStyleOptionTabV2 & QStyleOptionTabV2::operator=(class QStyleOptionTabV2 const &)
@@ -13559,7 +13559,7 @@ EXPORTS
?markRasterOverlay@QBlittablePixmapData@@QAEXABVQPointF@@ABVQTextItem@@@Z @ 13558 NONAME ; void QBlittablePixmapData::markRasterOverlay(class QPointF const &, class QTextItem const &)
?trUtf8@QScroller@@SA?AVQString@@PBD0@Z @ 13559 NONAME ; class QString QScroller::trUtf8(char const *, char const *)
??_EQIcon@@QAE@I@Z @ 13560 NONAME ABSENT ; QIcon::~QIcon(unsigned int)
- ??YQGlyphs@@AAEAAV0@ABV0@@Z @ 13561 NONAME ; class QGlyphs & QGlyphs::operator+=(class QGlyphs const &)
+ ??YQGlyphs@@AAEAAV0@ABV0@@Z @ 13561 NONAME ABSENT ; class QGlyphs & QGlyphs::operator+=(class QGlyphs const &)
??9QScrollerProperties@@QBE_NABV0@@Z @ 13562 NONAME ; bool QScrollerProperties::operator!=(class QScrollerProperties const &) const
??0QTextListFormat@@QAE@ABV0@@Z @ 13563 NONAME ABSENT ; QTextListFormat::QTextListFormat(class QTextListFormat const &)
?drawEllipse@QBlitterPaintEngine@@UAEXABVQRectF@@@Z @ 13564 NONAME ; void QBlitterPaintEngine::drawEllipse(class QRectF const &)
@@ -13590,7 +13590,7 @@ EXPORTS
?qt_addBitmapToPath@@YAXMMPBEHHHPAVQPainterPath@@@Z @ 13589 NONAME ; void qt_addBitmapToPath(float, float, unsigned char const *, int, int, int, class QPainterPath *)
?staticMetaObject@QInternalMimeData@@2UQMetaObject@@B @ 13590 NONAME ; struct QMetaObject const QInternalMimeData::staticMetaObject
?activeScrollers@QScroller@@SA?AV?$QList@PAVQScroller@@@@XZ @ 13591 NONAME ; class QList<class QScroller *> QScroller::activeScrollers(void)
- ?drawGlyphs@QPainter@@QAEXABVQPointF@@ABVQGlyphs@@@Z @ 13592 NONAME ; void QPainter::drawGlyphs(class QPointF const &, class QGlyphs const &)
+ ?drawGlyphs@QPainter@@QAEXABVQPointF@@ABVQGlyphs@@@Z @ 13592 NONAME ABSENT ; void QPainter::drawGlyphs(class QPointF const &, class QGlyphs const &)
??4QTextFrameFormat@@QAEAAV0@ABV0@@Z @ 13593 NONAME ABSENT ; class QTextFrameFormat & QTextFrameFormat::operator=(class QTextFrameFormat const &)
?staticMetaObjectExtraData@QStylePlugin@@0UQMetaObjectExtraData@@B @ 13594 NONAME ; struct QMetaObjectExtraData const QStylePlugin::staticMetaObjectExtraData
?staticMetaObjectExtraData@QToolBar@@0UQMetaObjectExtraData@@B @ 13595 NONAME ; struct QMetaObjectExtraData const QToolBar::staticMetaObjectExtraData
@@ -13953,4 +13953,71 @@ EXPORTS
?staticMetaObjectExtraData@QWorkspace@@0UQMetaObjectExtraData@@B @ 13952 NONAME ; struct QMetaObjectExtraData const QWorkspace::staticMetaObjectExtraData
?staticMetaObjectExtraData@QSessionManager@@0UQMetaObjectExtraData@@B @ 13953 NONAME ; struct QMetaObjectExtraData const QSessionManager::staticMetaObjectExtraData
?qt_static_metacall@QGraphicsItemAnimation@@CAXPAVQObject@@W4Call@QMetaObject@@HPAPAX@Z @ 13954 NONAME ; void QGraphicsItemAnimation::qt_static_metacall(class QObject *, enum QMetaObject::Call, int, void * *)
-
+ ?cursorMoveStyle@QLineEdit@@QBE?AW4MoveStyle@QTextCursor@@XZ @ 13955 NONAME ; enum QTextCursor::MoveStyle QLineEdit::cursorMoveStyle(void) const
+ ?focalRadius@QRadialGradient@@QBEMXZ @ 13956 NONAME ; float QRadialGradient::focalRadius(void) const
+ ?alignLine@QTextEngine@@QAE?AUQFixed@@ABUQScriptLine@@@Z @ 13957 NONAME ; struct QFixed QTextEngine::alignLine(struct QScriptLine const &)
+ ?match@QIdentityProxyModel@@UBE?AV?$QList@VQModelIndex@@@@ABVQModelIndex@@HABVQVariant@@HV?$QFlags@W4MatchFlag@Qt@@@@@Z @ 13958 NONAME ; class QList<class QModelIndex> QIdentityProxyModel::match(class QModelIndex const &, int, class QVariant const &, int, class QFlags<enum Qt::MatchFlag>) const
+ ?positionAfterVisualMovement@QTextEngine@@QAEHHW4MoveOperation@QTextCursor@@@Z @ 13959 NONAME ; int QTextEngine::positionAfterVisualMovement(int, enum QTextCursor::MoveOperation)
+ ?qt_painterPathFromVectorPath@@YA?AVQPainterPath@@ABVQVectorPath@@@Z @ 13960 NONAME ; class QPainterPath qt_painterPathFromVectorPath(class QVectorPath const &)
+ ?metaObject@QIdentityProxyModel@@UBEPBUQMetaObject@@XZ @ 13961 NONAME ; struct QMetaObject const * QIdentityProxyModel::metaObject(void) const
+ ?qt_static_metacall@QIdentityProxyModel@@CAXPAVQObject@@W4Call@QMetaObject@@HPAPAX@Z @ 13962 NONAME ; void QIdentityProxyModel::qt_static_metacall(class QObject *, enum QMetaObject::Call, int, void * *)
+ ?setCursorMoveStyle@QLineControl@@QAEXW4MoveStyle@QTextCursor@@@Z @ 13963 NONAME ; void QLineControl::setCursorMoveStyle(enum QTextCursor::MoveStyle)
+ ?visualCursorMovement@QTextEngine@@QBE_NXZ @ 13964 NONAME ; bool QTextEngine::visualCursorMovement(void) const
+ ?setFocalRadius@QRadialGradient@@QAEXM@Z @ 13965 NONAME ; void QRadialGradient::setFocalRadius(float)
+ ??_EQIdentityProxyModel@@UAE@I@Z @ 13966 NONAME ; QIdentityProxyModel::~QIdentityProxyModel(unsigned int)
+ ??1QIdentityProxyModel@@UAE@XZ @ 13967 NONAME ; QIdentityProxyModel::~QIdentityProxyModel(void)
+ ?d_func@QIdentityProxyModel@@AAEPAVQIdentityProxyModelPrivate@@XZ @ 13968 NONAME ; class QIdentityProxyModelPrivate * QIdentityProxyModel::d_func(void)
+ ?rowCount@QIdentityProxyModel@@UBEHABVQModelIndex@@@Z @ 13969 NONAME ; int QIdentityProxyModel::rowCount(class QModelIndex const &) const
+ ?previousLogicalPosition@QTextEngine@@QBEHH@Z @ 13970 NONAME ; int QTextEngine::previousLogicalPosition(int) const
+ ?endOfLine@QTextEngine@@AAEHH@Z @ 13971 NONAME ; int QTextEngine::endOfLine(int)
+ ?lineNumberForTextPosition@QTextEngine@@QAEHH@Z @ 13972 NONAME ; int QTextEngine::lineNumberForTextPosition(int)
+ ?mapToSource@QIdentityProxyModel@@UBE?AVQModelIndex@@ABV2@@Z @ 13973 NONAME ; class QModelIndex QIdentityProxyModel::mapToSource(class QModelIndex const &) const
+ ?setCursorMoveStyle@QTextLayout@@QAEXW4MoveStyle@QTextCursor@@@Z @ 13974 NONAME ; void QTextLayout::setCursorMoveStyle(enum QTextCursor::MoveStyle)
+ ?dropMimeData@QIdentityProxyModel@@UAE_NPBVQMimeData@@W4DropAction@Qt@@HHABVQModelIndex@@@Z @ 13975 NONAME ; bool QIdentityProxyModel::dropMimeData(class QMimeData const *, enum Qt::DropAction, int, int, class QModelIndex const &)
+ ?mapSelectionFromSource@QIdentityProxyModel@@UBE?AVQItemSelection@@ABV2@@Z @ 13976 NONAME ; class QItemSelection QIdentityProxyModel::mapSelectionFromSource(class QItemSelection const &) const
+ ?setInstantInvalidatePropagation@QGraphicsLayout@@SAX_N@Z @ 13977 NONAME ; void QGraphicsLayout::setInstantInvalidatePropagation(bool)
+ ?mapFromSource@QIdentityProxyModel@@UBE?AVQModelIndex@@ABV2@@Z @ 13978 NONAME ; class QModelIndex QIdentityProxyModel::mapFromSource(class QModelIndex const &) const
+ ?centerRadius@QRadialGradient@@QBEMXZ @ 13979 NONAME ; float QRadialGradient::centerRadius(void) const
+ ?mapSelectionToSource@QIdentityProxyModel@@UBE?AVQItemSelection@@ABV2@@Z @ 13980 NONAME ; class QItemSelection QIdentityProxyModel::mapSelectionToSource(class QItemSelection const &) const
+ ?tr@QIdentityProxyModel@@SA?AVQString@@PBD0H@Z @ 13981 NONAME ; class QString QIdentityProxyModel::tr(char const *, char const *, int)
+ ?cursorMoveStyle@QTextLayout@@QBE?AW4MoveStyle@QTextCursor@@XZ @ 13982 NONAME ; enum QTextCursor::MoveStyle QTextLayout::cursorMoveStyle(void) const
+ ?index@QIdentityProxyModel@@UBE?AVQModelIndex@@HHABV2@@Z @ 13983 NONAME ; class QModelIndex QIdentityProxyModel::index(int, int, class QModelIndex const &) const
+ ?qt_draw_decoration_for_glyphs@@YAXPAVQPainter@@PBIPBUQFixedPoint@@HPAVQFontEngine@@ABVQFont@@ABVQTextCharFormat@@@Z @ 13984 NONAME ; void qt_draw_decoration_for_glyphs(class QPainter *, unsigned int const *, struct QFixedPoint const *, int, class QFontEngine *, class QFont const &, class QTextCharFormat const &)
+ ?defaultCursorMoveStyle@QTextDocument@@QBE?AW4MoveStyle@QTextCursor@@XZ @ 13985 NONAME ; enum QTextCursor::MoveStyle QTextDocument::defaultCursorMoveStyle(void) const
+ ?insertRows@QIdentityProxyModel@@UAE_NHHABVQModelIndex@@@Z @ 13986 NONAME ; bool QIdentityProxyModel::insertRows(int, int, class QModelIndex const &)
+ ?qt_isExtendedRadialGradient@@YA_NABVQBrush@@@Z @ 13987 NONAME ; bool qt_isExtendedRadialGradient(class QBrush const &)
+ ?trUtf8@QIdentityProxyModel@@SA?AVQString@@PBD0H@Z @ 13988 NONAME ; class QString QIdentityProxyModel::trUtf8(char const *, char const *, int)
+ ?instantInvalidatePropagation@QGraphicsLayout@@SA_NXZ @ 13989 NONAME ; bool QGraphicsLayout::instantInvalidatePropagation(void)
+ ?trUtf8@QIdentityProxyModel@@SA?AVQString@@PBD0@Z @ 13990 NONAME ; class QString QIdentityProxyModel::trUtf8(char const *, char const *)
+ ??0QIdentityProxyModel@@QAE@PAVQObject@@@Z @ 13991 NONAME ; QIdentityProxyModel::QIdentityProxyModel(class QObject *)
+ ?removeColumns@QIdentityProxyModel@@UAE_NHHABVQModelIndex@@@Z @ 13992 NONAME ; bool QIdentityProxyModel::removeColumns(int, int, class QModelIndex const &)
+ ??0QIdentityProxyModel@@IAE@AAVQIdentityProxyModelPrivate@@PAVQObject@@@Z @ 13993 NONAME ; QIdentityProxyModel::QIdentityProxyModel(class QIdentityProxyModelPrivate &, class QObject *)
+ ?tr@QIdentityProxyModel@@SA?AVQString@@PBD0@Z @ 13994 NONAME ; class QString QIdentityProxyModel::tr(char const *, char const *)
+ ?columnCount@QIdentityProxyModel@@UBEHABVQModelIndex@@@Z @ 13995 NONAME ; int QIdentityProxyModel::columnCount(class QModelIndex const &) const
+ ??0QRadialGradient@@QAE@MMMMMM@Z @ 13996 NONAME ; QRadialGradient::QRadialGradient(float, float, float, float, float, float)
+ ?offsetInLigature@QTextEngine@@QAE?AUQFixed@@PBUQScriptItem@@HHH@Z @ 13997 NONAME ; struct QFixed QTextEngine::offsetInLigature(struct QScriptItem const *, int, int, int)
+ ?cursorMoveStyle@QLineControl@@QBE?AW4MoveStyle@QTextCursor@@XZ @ 13998 NONAME ; enum QTextCursor::MoveStyle QLineControl::cursorMoveStyle(void) const
+ ?beginningOfLine@QTextEngine@@AAEHH@Z @ 13999 NONAME ; int QTextEngine::beginningOfLine(int)
+ ?setCenterRadius@QRadialGradient@@QAEXM@Z @ 14000 NONAME ; void QRadialGradient::setCenterRadius(float)
+ ?setCursorMoveStyle@QLineEdit@@QAEXW4MoveStyle@QTextCursor@@@Z @ 14001 NONAME ; void QLineEdit::setCursorMoveStyle(enum QTextCursor::MoveStyle)
+ ??0QRadialGradient@@QAE@ABVQPointF@@M0M@Z @ 14002 NONAME ; QRadialGradient::QRadialGradient(class QPointF const &, float, class QPointF const &, float)
+ ?actionText@QUndoCommand@@QBE?AVQString@@XZ @ 14003 NONAME ; class QString QUndoCommand::actionText(void) const
+ ?insertionPointsForLine@QTextEngine@@QAEXHAAV?$QVector@H@@@Z @ 14004 NONAME ; void QTextEngine::insertionPointsForLine(int, class QVector<int> &)
+ ?rightCursorPosition@QTextLayout@@QBEHH@Z @ 14005 NONAME ; int QTextLayout::rightCursorPosition(int) const
+ ?insertColumns@QIdentityProxyModel@@UAE_NHHABVQModelIndex@@@Z @ 14006 NONAME ; bool QIdentityProxyModel::insertColumns(int, int, class QModelIndex const &)
+ ?setDefaultCursorMoveStyle@QTextDocument@@QAEXW4MoveStyle@QTextCursor@@@Z @ 14007 NONAME ; void QTextDocument::setDefaultCursorMoveStyle(enum QTextCursor::MoveStyle)
+ ?doItemsLayout@QTableView@@UAEXXZ @ 14008 NONAME ; void QTableView::doItemsLayout(void)
+ ?qt_metacast@QIdentityProxyModel@@UAEPAXPBD@Z @ 14009 NONAME ; void * QIdentityProxyModel::qt_metacast(char const *)
+ ?setSourceModel@QIdentityProxyModel@@UAEXPAVQAbstractItemModel@@@Z @ 14010 NONAME ; void QIdentityProxyModel::setSourceModel(class QAbstractItemModel *)
+ ?d_func@QIdentityProxyModel@@ABEPBVQIdentityProxyModelPrivate@@XZ @ 14011 NONAME ; class QIdentityProxyModelPrivate const * QIdentityProxyModel::d_func(void) const
+ ?cloneWithSize@QFontEngine@@UBEPAV1@M@Z @ 14012 NONAME ; class QFontEngine * QFontEngine::cloneWithSize(float) const
+ ?leftCursorPosition@QTextLayout@@QBEHH@Z @ 14013 NONAME ; int QTextLayout::leftCursorPosition(int) const
+ ?paintingActive@QVolatileImage@@QBE_NXZ @ 14014 NONAME ; bool QVolatileImage::paintingActive(void) const
+ ?parent@QIdentityProxyModel@@UBE?AVQModelIndex@@ABV2@@Z @ 14015 NONAME ; class QModelIndex QIdentityProxyModel::parent(class QModelIndex const &) const
+ ?nextLogicalPosition@QTextEngine@@QBEHH@Z @ 14016 NONAME ; int QTextEngine::nextLogicalPosition(int) const
+ ?qt_metacall@QIdentityProxyModel@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 14017 NONAME ; int QIdentityProxyModel::qt_metacall(enum QMetaObject::Call, int, void * *)
+ ?staticMetaObject@QIdentityProxyModel@@2UQMetaObject@@B @ 14018 NONAME ; struct QMetaObject const QIdentityProxyModel::staticMetaObject
+ ?staticMetaObjectExtraData@QIdentityProxyModel@@0UQMetaObjectExtraData@@B @ 14019 NONAME ; struct QMetaObjectExtraData const QIdentityProxyModel::staticMetaObjectExtraData
+ ?getStaticMetaObject@QIdentityProxyModel@@SAABUQMetaObject@@XZ @ 14020 NONAME ; struct QMetaObject const & QIdentityProxyModel::getStaticMetaObject(void)
+ ?removeRows@QIdentityProxyModel@@UAE_NHHABVQModelIndex@@@Z @ 14021 NONAME ; bool QIdentityProxyModel::removeRows(int, int, class QModelIndex const &)
+ ?qt_s60_setPartialScreenAutomaticTranslation@@YAX_N@Z @ 14022 NONAME ; void qt_s60_setPartialScreenAutomaticTranslation(bool)
diff --git a/src/s60installs/bwins/QtNetworku.def b/src/s60installs/bwins/QtNetworku.def
index 49538ef..dd9dfae 100644
--- a/src/s60installs/bwins/QtNetworku.def
+++ b/src/s60installs/bwins/QtNetworku.def
@@ -1237,4 +1237,9 @@ EXPORTS
?qt_static_metacall@QBearerEnginePlugin@@CAXPAVQObject@@W4Call@QMetaObject@@HPAPAX@Z @ 1236 NONAME ; void QBearerEnginePlugin::qt_static_metacall(class QObject *, enum QMetaObject::Call, int, void * *)
?staticMetaObjectExtraData@QNetworkConfigurationManager@@0UQMetaObjectExtraData@@B @ 1237 NONAME ; struct QMetaObjectExtraData const QNetworkConfigurationManager::staticMetaObjectExtraData
?qt_static_metacall@QTcpSocket@@CAXPAVQObject@@W4Call@QMetaObject@@HPAPAX@Z @ 1238 NONAME ; void QTcpSocket::qt_static_metacall(class QObject *, enum QMetaObject::Call, int, void * *)
+ ??0QNetworkProxyQuery@@QAE@ABVQNetworkConfiguration@@GABVQString@@W4QueryType@0@@Z @ 1239 NONAME ; QNetworkProxyQuery::QNetworkProxyQuery(class QNetworkConfiguration const &, unsigned short, class QString const &, enum QNetworkProxyQuery::QueryType)
+ ??0QNetworkProxyQuery@@QAE@ABVQNetworkConfiguration@@ABVQString@@H1W4QueryType@0@@Z @ 1240 NONAME ; QNetworkProxyQuery::QNetworkProxyQuery(class QNetworkConfiguration const &, class QString const &, int, class QString const &, enum QNetworkProxyQuery::QueryType)
+ ?networkConfiguration@QNetworkProxyQuery@@QBE?AVQNetworkConfiguration@@XZ @ 1241 NONAME ; class QNetworkConfiguration QNetworkProxyQuery::networkConfiguration(void) const
+ ?setNetworkConfiguration@QNetworkProxyQuery@@QAEXABVQNetworkConfiguration@@@Z @ 1242 NONAME ; void QNetworkProxyQuery::setNetworkConfiguration(class QNetworkConfiguration const &)
+ ??0QNetworkProxyQuery@@QAE@ABVQNetworkConfiguration@@ABVQUrl@@W4QueryType@0@@Z @ 1243 NONAME ; QNetworkProxyQuery::QNetworkProxyQuery(class QNetworkConfiguration const &, class QUrl const &, enum QNetworkProxyQuery::QueryType)
diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def
index 81b5267..6c4e837 100644
--- a/src/s60installs/eabi/QtCoreu.def
+++ b/src/s60installs/eabi/QtCoreu.def
@@ -3992,4 +3992,166 @@ EXPORTS
_ZNK7QLocale9bcp47NameEv @ 3991 NONAME
_ZTI13QActiveObject @ 3992 NONAME
_ZTV13QActiveObject @ 3993 NONAME
+ _ZN23QCoreApplicationPrivate13trolltechConfEv @ 3994 NONAME
+ _ZN12QtConcurrent15ResultStoreBase10addResultsEiPKvii @ 3995 NONAME
+ _ZN12QtConcurrent15ResultStoreBase13setFilterModeEb @ 3996 NONAME
+ _ZN12QtConcurrent15ResultStoreBase15syncResultCountEv @ 3997 NONAME
+ _ZN12QtConcurrent15ResultStoreBase16insertResultItemEiRNS_10ResultItemE @ 3998 NONAME
+ _ZN12QtConcurrent15ResultStoreBase17updateInsertIndexEii @ 3999 NONAME
+ _ZN12QtConcurrent15ResultStoreBase18syncPendingResultsEv @ 4000 NONAME
+ _ZN12QtConcurrent15ResultStoreBase23insertResultItemIfValidEiRNS_10ResultItemE @ 4001 NONAME
+ _ZN12QtConcurrent15ResultStoreBase9addResultEiPKv @ 4002 NONAME
+ _ZN12QtConcurrent15ResultStoreBaseC1Ev @ 4003 NONAME
+ _ZN12QtConcurrent15ResultStoreBaseC2Ev @ 4004 NONAME
+ _ZN12QtConcurrent16BlockSizeManager13timeAfterUserEv @ 4005 NONAME
+ _ZN12QtConcurrent16BlockSizeManager14timeBeforeUserEv @ 4006 NONAME
+ _ZN12QtConcurrent16BlockSizeManager9blockSizeEv @ 4007 NONAME
+ _ZN12QtConcurrent16BlockSizeManagerC1Ei @ 4008 NONAME
+ _ZN12QtConcurrent16BlockSizeManagerC2Ei @ 4009 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase10isCanceledEv @ 4010 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase10threadExitEv @ 4011 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase11startThreadEv @ 4012 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase12startThreadsEv @ 4013 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase13startBlockingEv @ 4014 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase13waitForResumeEv @ 4015 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase15handleExceptionERKNS_9ExceptionE @ 4016 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase16setProgressRangeEii @ 4017 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase16setProgressValueEi @ 4018 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase18threadThrottleExitEv @ 4019 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase19startSingleThreadedEv @ 4020 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase19startThreadInternalEv @ 4021 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase23acquireBarrierSemaphoreEv @ 4022 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase26isProgressReportingEnabledEv @ 4023 NONAME
+ _ZN12QtConcurrent16ThreadEngineBase3runEv @ 4024 NONAME
+ _ZN12QtConcurrent16ThreadEngineBaseC2Ev @ 4025 NONAME
+ _ZN12QtConcurrent16ThreadEngineBaseD0Ev @ 4026 NONAME
+ _ZN12QtConcurrent16ThreadEngineBaseD1Ev @ 4027 NONAME
+ _ZN12QtConcurrent16ThreadEngineBaseD2Ev @ 4028 NONAME
+ _ZN12QtConcurrent18ResultIteratorBase14batchedAdvanceEv @ 4029 NONAME
+ _ZN12QtConcurrent18ResultIteratorBaseC1EN4QMapIiNS_10ResultItemEE14const_iteratorEi @ 4030 NONAME
+ _ZN12QtConcurrent18ResultIteratorBaseC1Ev @ 4031 NONAME
+ _ZN12QtConcurrent18ResultIteratorBaseC2EN4QMapIiNS_10ResultItemEE14const_iteratorEi @ 4032 NONAME
+ _ZN12QtConcurrent18ResultIteratorBaseC2Ev @ 4033 NONAME
+ _ZN12QtConcurrent18ResultIteratorBaseppEv @ 4034 NONAME
+ _ZN12QtConcurrent8internal14ExceptionStore12setExceptionERKNS_9ExceptionE @ 4035 NONAME
+ _ZN12QtConcurrent8internal14ExceptionStore22throwPossibleExceptionEv @ 4036 NONAME
+ _ZN12QtConcurrent8internal14ExceptionStore9exceptionEv @ 4037 NONAME
+ _ZN18QFutureWatcherBase11qt_metacallEN11QMetaObject4CallEiPPv @ 4038 NONAME
+ _ZN18QFutureWatcherBase11qt_metacastEPKc @ 4039 NONAME
+ _ZN18QFutureWatcherBase12togglePausedEv @ 4040 NONAME
+ _ZN18QFutureWatcherBase13connectNotifyEPKc @ 4041 NONAME
+ _ZN18QFutureWatcherBase13resultReadyAtEi @ 4042 NONAME
+ _ZN18QFutureWatcherBase14resultsReadyAtEii @ 4043 NONAME
+ _ZN18QFutureWatcherBase15waitForFinishedEv @ 4044 NONAME
+ _ZN18QFutureWatcherBase16disconnectNotifyEPKc @ 4045 NONAME
+ _ZN18QFutureWatcherBase16staticMetaObjectE @ 4046 NONAME DATA 16
+ _ZN18QFutureWatcherBase18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv @ 4047 NONAME
+ _ZN18QFutureWatcherBase19getStaticMetaObjectEv @ 4048 NONAME
+ _ZN18QFutureWatcherBase19progressTextChangedERK7QString @ 4049 NONAME
+ _ZN18QFutureWatcherBase20progressRangeChangedEii @ 4050 NONAME
+ _ZN18QFutureWatcherBase20progressValueChangedEi @ 4051 NONAME
+ _ZN18QFutureWatcherBase22connectOutputInterfaceEv @ 4052 NONAME
+ _ZN18QFutureWatcherBase22setPendingResultsLimitEi @ 4053 NONAME
+ _ZN18QFutureWatcherBase25disconnectOutputInterfaceEb @ 4054 NONAME
+ _ZN18QFutureWatcherBase25staticMetaObjectExtraDataE @ 4055 NONAME DATA 8
+ _ZN18QFutureWatcherBase5eventEP6QEvent @ 4056 NONAME
+ _ZN18QFutureWatcherBase5pauseEv @ 4057 NONAME
+ _ZN18QFutureWatcherBase6cancelEv @ 4058 NONAME
+ _ZN18QFutureWatcherBase6pausedEv @ 4059 NONAME
+ _ZN18QFutureWatcherBase6resumeEv @ 4060 NONAME
+ _ZN18QFutureWatcherBase7resumedEv @ 4061 NONAME
+ _ZN18QFutureWatcherBase7startedEv @ 4062 NONAME
+ _ZN18QFutureWatcherBase8canceledEv @ 4063 NONAME
+ _ZN18QFutureWatcherBase8finishedEv @ 4064 NONAME
+ _ZN18QFutureWatcherBase9setPausedEb @ 4065 NONAME
+ _ZN18QFutureWatcherBaseC2EP7QObject @ 4066 NONAME
+ _ZN20QFutureInterfaceBase11setRunnableEP9QRunnable @ 4067 NONAME
+ _ZN20QFutureInterfaceBase12setThrottledEb @ 4068 NONAME
+ _ZN20QFutureInterfaceBase12togglePausedEv @ 4069 NONAME
+ _ZN20QFutureInterfaceBase13reportStartedEv @ 4070 NONAME
+ _ZN20QFutureInterfaceBase13setFilterModeEb @ 4071 NONAME
+ _ZN20QFutureInterfaceBase13waitForResultEi @ 4072 NONAME
+ _ZN20QFutureInterfaceBase13waitForResumeEv @ 4073 NONAME
+ _ZN20QFutureInterfaceBase14exceptionStoreEv @ 4074 NONAME
+ _ZN20QFutureInterfaceBase14reportCanceledEv @ 4075 NONAME
+ _ZN20QFutureInterfaceBase14reportFinishedEv @ 4076 NONAME
+ _ZN20QFutureInterfaceBase15reportExceptionERKN12QtConcurrent9ExceptionE @ 4077 NONAME
+ _ZN20QFutureInterfaceBase15resultStoreBaseEv @ 4078 NONAME
+ _ZN20QFutureInterfaceBase15waitForFinishedEv @ 4079 NONAME
+ _ZN20QFutureInterfaceBase16setProgressRangeEii @ 4080 NONAME
+ _ZN20QFutureInterfaceBase16setProgressValueEi @ 4081 NONAME
+ _ZN20QFutureInterfaceBase17waitForNextResultEv @ 4082 NONAME
+ _ZN20QFutureInterfaceBase18reportResultsReadyEii @ 4083 NONAME
+ _ZN20QFutureInterfaceBase19expectedResultCountEv @ 4084 NONAME
+ _ZN20QFutureInterfaceBase22setExpectedResultCountEi @ 4085 NONAME
+ _ZN20QFutureInterfaceBase23setProgressValueAndTextEiRK7QString @ 4086 NONAME
+ _ZN20QFutureInterfaceBase6cancelEv @ 4087 NONAME
+ _ZN20QFutureInterfaceBase9setPausedEb @ 4088 NONAME
+ _ZN20QFutureInterfaceBaseC1ENS_5StateE @ 4089 NONAME
+ _ZN20QFutureInterfaceBaseC1ERKS_ @ 4090 NONAME
+ _ZN20QFutureInterfaceBaseC2ENS_5StateE @ 4091 NONAME
+ _ZN20QFutureInterfaceBaseC2ERKS_ @ 4092 NONAME
+ _ZN20QFutureInterfaceBaseD0Ev @ 4093 NONAME
+ _ZN20QFutureInterfaceBaseD1Ev @ 4094 NONAME
+ _ZN20QFutureInterfaceBaseD2Ev @ 4095 NONAME
+ _ZN20QFutureInterfaceBaseaSERKS_ @ 4096 NONAME
+ _ZNK12QtConcurrent15ResultStoreBase10filterModeEv @ 4097 NONAME
+ _ZNK12QtConcurrent15ResultStoreBase13hasNextResultEv @ 4098 NONAME
+ _ZNK12QtConcurrent15ResultStoreBase3endEv @ 4099 NONAME
+ _ZNK12QtConcurrent15ResultStoreBase5beginEv @ 4100 NONAME
+ _ZNK12QtConcurrent15ResultStoreBase5countEv @ 4101 NONAME
+ _ZNK12QtConcurrent15ResultStoreBase8containsEi @ 4102 NONAME
+ _ZNK12QtConcurrent15ResultStoreBase8resultAtEi @ 4103 NONAME
+ _ZNK12QtConcurrent18ResultIteratorBase11resultIndexEv @ 4104 NONAME
+ _ZNK12QtConcurrent18ResultIteratorBase11vectorIndexEv @ 4105 NONAME
+ _ZNK12QtConcurrent18ResultIteratorBase23canIncrementVectorIndexEv @ 4106 NONAME
+ _ZNK12QtConcurrent18ResultIteratorBase8isVectorEv @ 4107 NONAME
+ _ZNK12QtConcurrent18ResultIteratorBase9batchSizeEv @ 4108 NONAME
+ _ZNK12QtConcurrent18ResultIteratorBaseeqERKS0_ @ 4109 NONAME
+ _ZNK12QtConcurrent18ResultIteratorBaseneERKS0_ @ 4110 NONAME
+ _ZNK12QtConcurrent18UnhandledException5cloneEv @ 4111 NONAME
+ _ZNK12QtConcurrent18UnhandledException5raiseEv @ 4112 NONAME
+ _ZNK12QtConcurrent8internal14ExceptionStore12hasExceptionEv @ 4113 NONAME
+ _ZNK12QtConcurrent8internal14ExceptionStore9hasThrownEv @ 4114 NONAME
+ _ZNK12QtConcurrent9Exception5cloneEv @ 4115 NONAME
+ _ZNK12QtConcurrent9Exception5raiseEv @ 4116 NONAME
+ _ZNK18QFutureWatcherBase10isCanceledEv @ 4117 NONAME
+ _ZNK18QFutureWatcherBase10isFinishedEv @ 4118 NONAME
+ _ZNK18QFutureWatcherBase10metaObjectEv @ 4119 NONAME
+ _ZNK18QFutureWatcherBase12progressTextEv @ 4120 NONAME
+ _ZNK18QFutureWatcherBase13progressValueEv @ 4121 NONAME
+ _ZNK18QFutureWatcherBase15progressMaximumEv @ 4122 NONAME
+ _ZNK18QFutureWatcherBase15progressMinimumEv @ 4123 NONAME
+ _ZNK18QFutureWatcherBase8isPausedEv @ 4124 NONAME
+ _ZNK18QFutureWatcherBase9isRunningEv @ 4125 NONAME
+ _ZNK18QFutureWatcherBase9isStartedEv @ 4126 NONAME
+ _ZNK20QFutureInterfaceBase10isCanceledEv @ 4127 NONAME
+ _ZNK20QFutureInterfaceBase10isFinishedEv @ 4128 NONAME
+ _ZNK20QFutureInterfaceBase10queryStateENS_5StateE @ 4129 NONAME
+ _ZNK20QFutureInterfaceBase11isThrottledEv @ 4130 NONAME
+ _ZNK20QFutureInterfaceBase11resultCountEv @ 4131 NONAME
+ _ZNK20QFutureInterfaceBase12progressTextEv @ 4132 NONAME
+ _ZNK20QFutureInterfaceBase13progressValueEv @ 4133 NONAME
+ _ZNK20QFutureInterfaceBase15isResultReadyAtEi @ 4134 NONAME
+ _ZNK20QFutureInterfaceBase15progressMaximumEv @ 4135 NONAME
+ _ZNK20QFutureInterfaceBase15progressMinimumEv @ 4136 NONAME
+ _ZNK20QFutureInterfaceBase15resultStoreBaseEv @ 4137 NONAME
+ _ZNK20QFutureInterfaceBase19referenceCountIsOneEv @ 4138 NONAME
+ _ZNK20QFutureInterfaceBase22isProgressUpdateNeededEv @ 4139 NONAME
+ _ZNK20QFutureInterfaceBase5mutexEv @ 4140 NONAME
+ _ZNK20QFutureInterfaceBase8isPausedEv @ 4141 NONAME
+ _ZNK20QFutureInterfaceBase9isRunningEv @ 4142 NONAME
+ _ZNK20QFutureInterfaceBase9isStartedEv @ 4143 NONAME
+ _ZTI18QFutureWatcherBase @ 4144 NONAME
+ _ZTI20QFutureInterfaceBase @ 4145 NONAME
+ _ZTIN12QtConcurrent15ResultStoreBaseE @ 4146 NONAME
+ _ZTIN12QtConcurrent16ThreadEngineBaseE @ 4147 NONAME
+ _ZTIN12QtConcurrent18UnhandledExceptionE @ 4148 NONAME
+ _ZTIN12QtConcurrent9ExceptionE @ 4149 NONAME
+ _ZTV18QFutureWatcherBase @ 4150 NONAME
+ _ZTV20QFutureInterfaceBase @ 4151 NONAME
+ _ZTVN12QtConcurrent15ResultStoreBaseE @ 4152 NONAME
+ _ZTVN12QtConcurrent16ThreadEngineBaseE @ 4153 NONAME
+ _ZTVN12QtConcurrent18UnhandledExceptionE @ 4154 NONAME
+ _ZTVN12QtConcurrent9ExceptionE @ 4155 NONAME
diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def
index 6646401..2a0cf21 100644
--- a/src/s60installs/eabi/QtGuiu.def
+++ b/src/s60installs/eabi/QtGuiu.def
@@ -11820,7 +11820,7 @@ EXPORTS
_ZN20QGraphicsItemPrivate16clearFocusHelperEb @ 11819 NONAME
_ZN24QImagePixmapCleanupHooks13isImageCachedERK6QImage @ 11820 NONAME
_ZN24QImagePixmapCleanupHooks14isPixmapCachedERK7QPixmap @ 11821 NONAME
- _Z14qt_draw_glyphsP8QPainterPKjPK7QPointFi @ 11822 NONAME
+ _Z14qt_draw_glyphsP8QPainterPKjPK7QPointFi @ 11822 NONAME ABSENT
_ZN10QImageData14convertInPlaceEN6QImage6FormatE6QFlagsIN2Qt19ImageConversionFlagEE @ 11823 NONAME
_ZN10QZipReader5closeEv @ 11824 NONAME
_ZN10QZipReader8FileInfoC1ERKS0_ @ 11825 NONAME
@@ -12230,7 +12230,7 @@ EXPORTS
_ZN17QInternalMimeDataD2Ev @ 12229 NONAME
_ZN18QTextureGlyphCache19fillInPendingGlyphsEv @ 12230 NONAME
_ZN19QAbstractProxyModel11setItemDataERK11QModelIndexRK4QMapIi8QVariantE @ 12231 NONAME
- _ZN19QAbstractProxyModel17resetInternalDataEv @ 12232 NONAME
+ _ZN19QAbstractProxyModel17resetInternalDataEv @ 12232 NONAME ABSENT
_ZN19QAbstractProxyModel4sortEiN2Qt9SortOrderE @ 12233 NONAME
_ZN19QAbstractProxyModel9fetchMoreERK11QModelIndex @ 12234 NONAME
_ZN19QApplicationPrivateC1ERiPPcN12QApplication4TypeEi @ 12235 NONAME
@@ -12302,22 +12302,22 @@ EXPORTS
_ZN5QFont20setHintingPreferenceENS_17HintingPreferenceE @ 12301 NONAME
_ZN6QImage4fillEN2Qt11GlobalColorE @ 12302 NONAME
_ZN6QImage4fillERK6QColor @ 12303 NONAME
- _ZN7QGlyphs12setPositionsERK7QVectorI7QPointFE @ 12304 NONAME
- _ZN7QGlyphs15setGlyphIndexesERK7QVectorIjE @ 12305 NONAME
- _ZN7QGlyphs5clearEv @ 12306 NONAME
- _ZN7QGlyphs6detachEv @ 12307 NONAME
- _ZN7QGlyphs7setFontERK5QFont @ 12308 NONAME
- _ZN7QGlyphsC1ERKS_ @ 12309 NONAME
- _ZN7QGlyphsC1Ev @ 12310 NONAME
- _ZN7QGlyphsC2ERKS_ @ 12311 NONAME
- _ZN7QGlyphsC2Ev @ 12312 NONAME
- _ZN7QGlyphsD1Ev @ 12313 NONAME
- _ZN7QGlyphsD2Ev @ 12314 NONAME
- _ZN7QGlyphsaSERKS_ @ 12315 NONAME
- _ZN7QGlyphspLERKS_ @ 12316 NONAME
+ _ZN7QGlyphs12setPositionsERK7QVectorI7QPointFE @ 12304 NONAME ABSENT
+ _ZN7QGlyphs15setGlyphIndexesERK7QVectorIjE @ 12305 NONAME ABSENT
+ _ZN7QGlyphs5clearEv @ 12306 NONAME ABSENT
+ _ZN7QGlyphs6detachEv @ 12307 NONAME ABSENT
+ _ZN7QGlyphs7setFontERK5QFont @ 12308 NONAME ABSENT
+ _ZN7QGlyphsC1ERKS_ @ 12309 NONAME ABSENT
+ _ZN7QGlyphsC1Ev @ 12310 NONAME ABSENT
+ _ZN7QGlyphsC2ERKS_ @ 12311 NONAME ABSENT
+ _ZN7QGlyphsC2Ev @ 12312 NONAME ABSENT
+ _ZN7QGlyphsD1Ev @ 12313 NONAME ABSENT
+ _ZN7QGlyphsD2Ev @ 12314 NONAME ABSENT
+ _ZN7QGlyphsaSERKS_ @ 12315 NONAME ABSENT
+ _ZN7QGlyphspLERKS_ @ 12316 NONAME ABSENT
_ZN8QMdiArea14setTabsMovableEb @ 12317 NONAME
_ZN8QMdiArea15setTabsClosableEb @ 12318 NONAME
- _ZN8QPainter10drawGlyphsERK7QPointFRK7QGlyphs @ 12319 NONAME
+ _ZN8QPainter10drawGlyphsERK7QPointFRK7QGlyphs @ 12319 NONAME ABSENT
_ZN9QScroller11grabGestureEP7QObjectNS_19ScrollerGestureTypeE @ 12320 NONAME
_ZN9QScroller11handleInputENS_5InputERK7QPointFx @ 12321 NONAME
_ZN9QScroller11hasScrollerEP7QObject @ 12322 NONAME
@@ -12351,9 +12351,9 @@ EXPORTS
_ZNK10QBlittable12capabilitiesEv @ 12350 NONAME
_ZNK10QBlittable4sizeEv @ 12351 NONAME
_ZNK10QTabWidget14heightForWidthEi @ 12352 NONAME
- _ZNK11QFontEngine18createExplicitFontEv @ 12353 NONAME
- _ZNK11QFontEngine26createExplicitFontWithNameERK7QString @ 12354 NONAME
- _ZNK11QTextLayout6glyphsEv @ 12355 NONAME
+ _ZNK11QFontEngine18createExplicitFontEv @ 12353 NONAME ABSENT
+ _ZNK11QFontEngine26createExplicitFontWithNameERK7QString @ 12354 NONAME ABSENT
+ _ZNK11QTextLayout6glyphsEv @ 12355 NONAME ABSENT
_ZNK12QFontMetrics10inFontUcs4Ej @ 12356 NONAME
_ZNK12QRadioButton15minimumSizeHintEv @ 12357 NONAME
_ZNK12QScrollEvent10contentPosEv @ 12358 NONAME
@@ -12362,7 +12362,7 @@ EXPORTS
_ZNK12QScrollEvent6d_funcEv @ 12361 NONAME
_ZNK13QFlickGesture10metaObjectEv @ 12362 NONAME
_ZNK13QFontMetricsF10inFontUcs4Ej @ 12363 NONAME
- _ZNK13QTextFragment6glyphsEv @ 12364 NONAME
+ _ZNK13QTextFragment6glyphsEv @ 12364 NONAME ABSENT
_ZNK14QFileOpenEvent8openFileER5QFile6QFlagsIN9QIODevice12OpenModeFlagEE @ 12365 NONAME
_ZNK14QWidgetPrivate17hasHeightForWidthEv @ 12366 NONAME
_ZNK16QFileSystemModel5rmdirERK11QModelIndex @ 12367 NONAME
@@ -12396,12 +12396,12 @@ EXPORTS
_ZNK20QBlittablePixmapData9blittableEv @ 12395 NONAME
_ZNK20QRasterWindowSurface24hasStaticContentsSupportEv @ 12396 NONAME ABSENT
_ZNK5QFont17hintingPreferenceEv @ 12397 NONAME
- _ZNK7QGlyphs12glyphIndexesEv @ 12398 NONAME
- _ZNK7QGlyphs4fontEv @ 12399 NONAME
- _ZNK7QGlyphs9positionsEv @ 12400 NONAME
- _ZNK7QGlyphseqERKS_ @ 12401 NONAME
- _ZNK7QGlyphsneERKS_ @ 12402 NONAME
- _ZNK7QGlyphsplERKS_ @ 12403 NONAME
+ _ZNK7QGlyphs12glyphIndexesEv @ 12398 NONAME ABSENT
+ _ZNK7QGlyphs4fontEv @ 12399 NONAME ABSENT
+ _ZNK7QGlyphs9positionsEv @ 12400 NONAME ABSENT
+ _ZNK7QGlyphseqERKS_ @ 12401 NONAME ABSENT
+ _ZNK7QGlyphsneERKS_ @ 12402 NONAME ABSENT
+ _ZNK7QGlyphsplERKS_ @ 12403 NONAME ABSENT
_ZNK8QMdiArea11tabsMovableEv @ 12404 NONAME
_ZNK8QMdiArea12tabsClosableEv @ 12405 NONAME
_ZNK8QPainter16clipBoundingRectEv @ 12406 NONAME
@@ -12413,7 +12413,7 @@ EXPORTS
_ZNK9QScroller5stateEv @ 12412 NONAME
_ZNK9QScroller6targetEv @ 12413 NONAME
_ZNK9QScroller8velocityEv @ 12414 NONAME
- _ZNK9QTextLine6glyphsEii @ 12415 NONAME
+ _ZNK9QTextLine6glyphsEii @ 12415 NONAME ABSENT
_ZTI10QBlittable @ 12416 NONAME
_ZTI12QScrollEvent @ 12417 NONAME
_ZTI13QFlickGesture @ 12418 NONAME
@@ -12799,4 +12799,69 @@ EXPORTS
_ZNK10QZipWriter6deviceEv @ 12798 NONAME
_ZNK10QZipWriter6existsEv @ 12799 NONAME
_ZNK10QZipWriter6statusEv @ 12800 NONAME
-
+ _Z27qt_isExtendedRadialGradientRK6QBrush @ 12801 NONAME
+ _Z28qt_painterPathFromVectorPathRK11QVectorPath @ 12802 NONAME
+ _Z29qt_draw_decoration_for_glyphsP8QPainterPKjPK11QFixedPointiP11QFontEngineRK5QFontRK15QTextCharFormat @ 12803 NONAME
+ _ZN10QTableView13doItemsLayoutEv @ 12804 NONAME
+ _ZN11QTextEngine15beginningOfLineEi @ 12805 NONAME
+ _ZN11QTextEngine16offsetInLigatureEPK11QScriptItemiii @ 12806 NONAME
+ _ZN11QTextEngine22insertionPointsForLineEiR7QVectorIiE @ 12807 NONAME
+ _ZN11QTextEngine25lineNumberForTextPositionEi @ 12808 NONAME
+ _ZN11QTextEngine27positionAfterVisualMovementEiN11QTextCursor13MoveOperationE @ 12809 NONAME
+ _ZN11QTextEngine9alignLineERK11QScriptLine @ 12810 NONAME
+ _ZN11QTextEngine9endOfLineEi @ 12811 NONAME
+ _ZN11QTextLayout18setCursorMoveStyleEN11QTextCursor9MoveStyleE @ 12812 NONAME
+ _ZN13QTextDocument25setDefaultCursorMoveStyleEN11QTextCursor9MoveStyleE @ 12813 NONAME
+ _ZN15QGraphicsLayout28instantInvalidatePropagationEv @ 12814 NONAME
+ _ZN15QGraphicsLayout31setInstantInvalidatePropagationEb @ 12815 NONAME
+ _ZN15QRadialGradient14setFocalRadiusEf @ 12816 NONAME
+ _ZN15QRadialGradient15setCenterRadiusEf @ 12817 NONAME
+ _ZN15QRadialGradientC1ERK7QPointFfS2_f @ 12818 NONAME
+ _ZN15QRadialGradientC1Effffff @ 12819 NONAME
+ _ZN15QRadialGradientC2ERK7QPointFfS2_f @ 12820 NONAME
+ _ZN15QRadialGradientC2Effffff @ 12821 NONAME
+ _ZN19QIdentityProxyModel10insertRowsEiiRK11QModelIndex @ 12822 NONAME
+ _ZN19QIdentityProxyModel10removeRowsEiiRK11QModelIndex @ 12823 NONAME
+ _ZN19QIdentityProxyModel11qt_metacallEN11QMetaObject4CallEiPPv @ 12824 NONAME
+ _ZN19QIdentityProxyModel11qt_metacastEPKc @ 12825 NONAME
+ _ZN19QIdentityProxyModel12dropMimeDataEPK9QMimeDataN2Qt10DropActionEiiRK11QModelIndex @ 12826 NONAME
+ _ZN19QIdentityProxyModel13insertColumnsEiiRK11QModelIndex @ 12827 NONAME
+ _ZN19QIdentityProxyModel13removeColumnsEiiRK11QModelIndex @ 12828 NONAME
+ _ZN19QIdentityProxyModel14setSourceModelEP18QAbstractItemModel @ 12829 NONAME
+ _ZN19QIdentityProxyModel16staticMetaObjectE @ 12830 NONAME DATA 16
+ _ZN19QIdentityProxyModel18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv @ 12831 NONAME
+ _ZN19QIdentityProxyModel19getStaticMetaObjectEv @ 12832 NONAME
+ _ZN19QIdentityProxyModel25staticMetaObjectExtraDataE @ 12833 NONAME DATA 8
+ _ZN19QIdentityProxyModelC1EP7QObject @ 12834 NONAME
+ _ZN19QIdentityProxyModelC1ER26QIdentityProxyModelPrivateP7QObject @ 12835 NONAME
+ _ZN19QIdentityProxyModelC2EP7QObject @ 12836 NONAME
+ _ZN19QIdentityProxyModelC2ER26QIdentityProxyModelPrivateP7QObject @ 12837 NONAME
+ _ZN19QIdentityProxyModelD0Ev @ 12838 NONAME
+ _ZN19QIdentityProxyModelD1Ev @ 12839 NONAME
+ _ZN19QIdentityProxyModelD2Ev @ 12840 NONAME
+ _ZN9QLineEdit18setCursorMoveStyleEN11QTextCursor9MoveStyleE @ 12841 NONAME
+ _ZNK10QTextBlock7isValidEv @ 12842 NONAME
+ _ZNK11QTextEngine19nextLogicalPositionEi @ 12843 NONAME
+ _ZNK11QTextEngine23previousLogicalPositionEi @ 12844 NONAME
+ _ZNK11QTextLayout15cursorMoveStyleEv @ 12845 NONAME
+ _ZNK11QTextLayout18leftCursorPositionEi @ 12846 NONAME
+ _ZNK11QTextLayout19rightCursorPositionEi @ 12847 NONAME
+ _ZNK12QUndoCommand10actionTextEv @ 12848 NONAME
+ _ZNK13QTextDocument22defaultCursorMoveStyleEv @ 12849 NONAME
+ _ZNK14QVolatileImage14paintingActiveEv @ 12850 NONAME
+ _ZNK15QRadialGradient11focalRadiusEv @ 12851 NONAME
+ _ZNK15QRadialGradient12centerRadiusEv @ 12852 NONAME
+ _ZNK19QIdentityProxyModel10metaObjectEv @ 12853 NONAME
+ _ZNK19QIdentityProxyModel11columnCountERK11QModelIndex @ 12854 NONAME
+ _ZNK19QIdentityProxyModel11mapToSourceERK11QModelIndex @ 12855 NONAME
+ _ZNK19QIdentityProxyModel13mapFromSourceERK11QModelIndex @ 12856 NONAME
+ _ZNK19QIdentityProxyModel20mapSelectionToSourceERK14QItemSelection @ 12857 NONAME
+ _ZNK19QIdentityProxyModel22mapSelectionFromSourceERK14QItemSelection @ 12858 NONAME
+ _ZNK19QIdentityProxyModel5indexEiiRK11QModelIndex @ 12859 NONAME
+ _ZNK19QIdentityProxyModel5matchERK11QModelIndexiRK8QVarianti6QFlagsIN2Qt9MatchFlagEE @ 12860 NONAME
+ _ZNK19QIdentityProxyModel6parentERK11QModelIndex @ 12861 NONAME
+ _ZNK19QIdentityProxyModel8rowCountERK11QModelIndex @ 12862 NONAME
+ _ZNK9QLineEdit15cursorMoveStyleEv @ 12863 NONAME
+ _ZTI19QIdentityProxyModel @ 12864 NONAME
+ _ZTV19QIdentityProxyModel @ 12865 NONAME
+ _Z43qt_s60_setPartialScreenAutomaticTranslationb @ 12866 NONAME
diff --git a/src/s60installs/eabi/QtNetworku.def b/src/s60installs/eabi/QtNetworku.def
index b0cbb38..8e29c2d 100644
--- a/src/s60installs/eabi/QtNetworku.def
+++ b/src/s60installs/eabi/QtNetworku.def
@@ -1260,4 +1260,12 @@ EXPORTS
_ZN4QFtp25staticMetaObjectExtraDataE @ 1259 NONAME DATA 8
_ZN5QHttp18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv @ 1260 NONAME
_ZN5QHttp25staticMetaObjectExtraDataE @ 1261 NONAME DATA 8
+ _ZN18QNetworkProxyQuery23setNetworkConfigurationERK21QNetworkConfiguration @ 1262 NONAME
+ _ZN18QNetworkProxyQueryC1ERK21QNetworkConfigurationRK4QUrlNS_9QueryTypeE @ 1263 NONAME
+ _ZN18QNetworkProxyQueryC1ERK21QNetworkConfigurationRK7QStringiS5_NS_9QueryTypeE @ 1264 NONAME
+ _ZN18QNetworkProxyQueryC1ERK21QNetworkConfigurationtRK7QStringNS_9QueryTypeE @ 1265 NONAME
+ _ZN18QNetworkProxyQueryC2ERK21QNetworkConfigurationRK4QUrlNS_9QueryTypeE @ 1266 NONAME
+ _ZN18QNetworkProxyQueryC2ERK21QNetworkConfigurationRK7QStringiS5_NS_9QueryTypeE @ 1267 NONAME
+ _ZN18QNetworkProxyQueryC2ERK21QNetworkConfigurationtRK7QStringNS_9QueryTypeE @ 1268 NONAME
+ _ZNK18QNetworkProxyQuery20networkConfigurationEv @ 1269 NONAME
diff --git a/src/s60installs/eabi/QtOpenGLu.def b/src/s60installs/eabi/QtOpenGLu.def
index 44f7306..c252484 100644
--- a/src/s60installs/eabi/QtOpenGLu.def
+++ b/src/s60installs/eabi/QtOpenGLu.def
@@ -759,11 +759,25 @@ EXPORTS
_ZNK14QGLPaintDevice9isFlippedEv @ 758 NONAME
_ZNK16QGLWindowSurface8featuresEv @ 759 NONAME
_ZNK26QGLFramebufferObjectFormat6mipmapEv @ 760 NONAME
- _ZTI22QGLContextResourceBase @ 761 NONAME
- _ZTI27QGLContextGroupResourceBase @ 762 NONAME
- _ZTV22QGLContextResourceBase @ 763 NONAME
- _ZTV27QGLContextGroupResourceBase @ 764 NONAME
- _ZThn104_N20QGLTextureGlyphCacheD0Ev @ 765 NONAME
- _ZThn104_N20QGLTextureGlyphCacheD1Ev @ 766 NONAME
- _ZThn8_NK16QGLWindowSurface8featuresEv @ 767 NONAME
+ _ZTI22QGLContextResourceBase @ 761 NONAME ABSENT
+ _ZTI27QGLContextGroupResourceBase @ 762 NONAME ABSENT
+ _ZTV22QGLContextResourceBase @ 763 NONAME ABSENT
+ _ZTV27QGLContextGroupResourceBase @ 764 NONAME ABSENT
+ _ZThn104_N20QGLTextureGlyphCacheD0Ev @ 765 NONAME ABSENT
+ _ZThn104_N20QGLTextureGlyphCacheD1Ev @ 766 NONAME ABSENT
+ _ZThn8_NK16QGLWindowSurface8featuresEv @ 767 NONAME ABSENT
+ _ZN14QGLSignalProxy18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv @ 768 NONAME
+ _ZN14QGLSignalProxy25staticMetaObjectExtraDataE @ 769 NONAME DATA 8
+ _ZN16QGLShaderProgram18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv @ 770 NONAME
+ _ZN16QGLShaderProgram25staticMetaObjectExtraDataE @ 771 NONAME DATA 8
+ _ZN16QGLWindowSurface18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv @ 772 NONAME
+ _ZN16QGLWindowSurface25staticMetaObjectExtraDataE @ 773 NONAME DATA 8
+ _ZN21QGraphicsShaderEffect18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv @ 774 NONAME
+ _ZN21QGraphicsShaderEffect25staticMetaObjectExtraDataE @ 775 NONAME DATA 8
+ _ZN22QGLEngineShaderManager18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv @ 776 NONAME
+ _ZN22QGLEngineShaderManager25staticMetaObjectExtraDataE @ 777 NONAME DATA 8
+ _ZN9QGLShader18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv @ 778 NONAME
+ _ZN9QGLShader25staticMetaObjectExtraDataE @ 779 NONAME DATA 8
+ _ZN9QGLWidget18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv @ 780 NONAME
+ _ZN9QGLWidget25staticMetaObjectExtraDataE @ 781 NONAME DATA 8
diff --git a/src/script/api/qscriptengineagent_p.h b/src/script/api/qscriptengineagent_p.h
index abe4e9e..b96d19d 100644
--- a/src/script/api/qscriptengineagent_p.h
+++ b/src/script/api/qscriptengineagent_p.h
@@ -57,22 +57,22 @@ public:
static QScriptEngineAgentPrivate* get(QScriptEngineAgent* p) {return p->d_func();}
QScriptEngineAgentPrivate(){}
- virtual ~QScriptEngineAgentPrivate(){};
+ virtual ~QScriptEngineAgentPrivate(){}
void attach();
void detach();
//scripts
- virtual void sourceParsed(JSC::ExecState*, const JSC::SourceCode&, int /*errorLine*/, const JSC::UString& /*errorMsg*/) {};
+ virtual void sourceParsed(JSC::ExecState*, const JSC::SourceCode&, int /*errorLine*/, const JSC::UString& /*errorMsg*/) {}
virtual void scriptUnload(qint64 id)
{
q_ptr->scriptUnload(id);
- };
+ }
virtual void scriptLoad(qint64 id, const JSC::UString &program,
const JSC::UString &fileName, int baseLineNumber)
{
q_ptr->scriptLoad(id,program, fileName, baseLineNumber);
- };
+ }
//exceptions
virtual void exception(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno, bool hasHandler)
@@ -81,7 +81,7 @@ public:
Q_UNUSED(sourceID);
Q_UNUSED(lineno);
Q_UNUSED(hasHandler);
- };
+ }
virtual void exceptionThrow(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, bool hasHandler);
virtual void exceptionCatch(const JSC::DebuggerCallFrame& frame, intptr_t sourceID);
@@ -92,20 +92,20 @@ public:
Q_UNUSED(lineno);
q_ptr->contextPush();
q_ptr->functionEntry(sourceID);
- };
+ }
virtual void returnEvent(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno);
virtual void willExecuteProgram(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno)
{
Q_UNUSED(frame);
Q_UNUSED(sourceID);
Q_UNUSED(lineno);
- };
+ }
virtual void didExecuteProgram(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno)
{
Q_UNUSED(frame);
- Q_UNUSED(sourceID);
+ Q_UNUSED(sourceID);
Q_UNUSED(lineno);
- };
+ }
virtual void functionExit(const JSC::JSValue& returnValue, intptr_t sourceID);
//others
virtual void didReachBreakpoint(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno/*, int column*/);
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp
index 49e7f13..4250b61 100644
--- a/src/sql/drivers/mysql/qsql_mysql.cpp
+++ b/src/sql/drivers/mysql/qsql_mysql.cpp
@@ -1374,12 +1374,16 @@ QStringList QMYSQLDriver::tables(QSql::TableType type) const
} else {
QSqlQuery q(createResult());
if(type & QSql::Tables) {
- q.exec(QLatin1String("select table_name from information_schema.tables where table_type = 'BASE TABLE'"));
+ QString sql = QLatin1String("select table_name from information_schema.tables where table_schema = '") + QLatin1String(d->mysql->db) + QLatin1String("' and table_type = 'BASE TABLE'");
+ q.exec(sql);
+
while(q.next())
tl.append(q.value(0).toString());
}
if(type & QSql::Views) {
- q.exec(QLatin1String("select table_name from information_schema.tables where table_type = 'VIEW'"));
+ QString sql = QLatin1String("select table_name from information_schema.tables where table_schema = '") + QLatin1String(d->mysql->db) + QLatin1String("' and table_type = 'VIEW'");
+ q.exec(sql);
+
while(q.next())
tl.append(q.value(0).toString());
}
diff --git a/src/tools/uic3/uic3.pro b/src/tools/uic3/uic3.pro
index 5ad3c4d..54f7dc8 100644
--- a/src/tools/uic3/uic3.pro
+++ b/src/tools/uic3/uic3.pro
@@ -1,5 +1,6 @@
TEMPLATE = app
CONFIG += console qt_no_compat_warning
+win32-msvc*:CONFIG += no_batch # otherwise the wrong main.cpp may be picked up
CONFIG -= app_bundle
build_all:!build_pass {
CONFIG -= build_all
diff --git a/src/xmlpatterns/data/qitem_p.h b/src/xmlpatterns/data/qitem_p.h
index 8184b25..fb3866e 100644
--- a/src/xmlpatterns/data/qitem_p.h
+++ b/src/xmlpatterns/data/qitem_p.h
@@ -408,6 +408,10 @@ namespace QPatternist
inline void reset()
{
+ /* Delete the atomicValue if necessary*/
+ if(isAtomicValue() && !atomicValue->ref.deref())
+ delete atomicValue;
+
/* Note that this function should be equal to the default
* constructor. */
node.model = 0;
diff --git a/src/xmlpatterns/expr/qdynamiccontextstore.cpp b/src/xmlpatterns/expr/qdynamiccontextstore.cpp
index 762b7d6..7e7ead7 100644
--- a/src/xmlpatterns/expr/qdynamiccontextstore.cpp
+++ b/src/xmlpatterns/expr/qdynamiccontextstore.cpp
@@ -51,24 +51,24 @@ using namespace QPatternist;
DynamicContextStore::DynamicContextStore(const Expression::Ptr &operand,
const DynamicContext::Ptr &context) : SingleContainer(operand),
- m_context(context)
+ m_context(context.data())
{
Q_ASSERT(context);
}
bool DynamicContextStore::evaluateEBV(const DynamicContext::Ptr &) const
{
- return m_operand->evaluateEBV(m_context);
+ return m_operand->evaluateEBV(DynamicContext::Ptr(m_context));
}
Item::Iterator::Ptr DynamicContextStore::evaluateSequence(const DynamicContext::Ptr &) const
{
- return m_operand->evaluateSequence(m_context);
+ return m_operand->evaluateSequence(DynamicContext::Ptr(m_context));
}
Item DynamicContextStore::evaluateSingleton(const DynamicContext::Ptr &) const
{
- return m_operand->evaluateSingleton(m_context);
+ return m_operand->evaluateSingleton(DynamicContext::Ptr(m_context));
}
SequenceType::Ptr DynamicContextStore::staticType() const
diff --git a/src/xmlpatterns/expr/qdynamiccontextstore_p.h b/src/xmlpatterns/expr/qdynamiccontextstore_p.h
index 1d5d035..40bfcd1 100644
--- a/src/xmlpatterns/expr/qdynamiccontextstore_p.h
+++ b/src/xmlpatterns/expr/qdynamiccontextstore_p.h
@@ -86,7 +86,7 @@ namespace QPatternist
virtual const SourceLocationReflection *actualReflection() const;
private:
- const DynamicContext::Ptr m_context;
+ DynamicContext *m_context;
};
}
diff --git a/src/xmlpatterns/expr/qevaluationcache.cpp b/src/xmlpatterns/expr/qevaluationcache.cpp
index 2d1bb56..cb95af6 100644
--- a/src/xmlpatterns/expr/qevaluationcache.cpp
+++ b/src/xmlpatterns/expr/qevaluationcache.cpp
@@ -49,7 +49,7 @@ template<bool IsForGlobal>
EvaluationCache<IsForGlobal>::EvaluationCache(const Expression::Ptr &op,
const VariableDeclaration::Ptr &varDecl,
const VariableSlotID aSlot) : SingleContainer(op)
- , m_declaration(varDecl)
+ , m_declaration(varDecl.constData())
, m_varSlot(aSlot)
{
Q_ASSERT(m_declaration);
diff --git a/src/xmlpatterns/expr/qevaluationcache_p.h b/src/xmlpatterns/expr/qevaluationcache_p.h
index 86aeaf8..af4cfa0 100644
--- a/src/xmlpatterns/expr/qevaluationcache_p.h
+++ b/src/xmlpatterns/expr/qevaluationcache_p.h
@@ -124,7 +124,7 @@ namespace QPatternist
private:
static DynamicContext::Ptr topFocusContext(const DynamicContext::Ptr &context);
- const VariableDeclaration::Ptr m_declaration;
+ const VariableDeclaration* m_declaration;
/**
* This variable must not be called m_slot. If it so, a compiler bug on
* HP-UX-aCC-64 is triggered in the constructor initializor. See the
diff --git a/src/xmlpatterns/expr/qletclause.cpp b/src/xmlpatterns/expr/qletclause.cpp
index d3e939b..b789b48 100644
--- a/src/xmlpatterns/expr/qletclause.cpp
+++ b/src/xmlpatterns/expr/qletclause.cpp
@@ -60,7 +60,7 @@ LetClause::LetClause(const Expression::Ptr &operand1,
DynamicContext::Ptr LetClause::bindVariable(const DynamicContext::Ptr &context) const
{
- context->setExpressionVariable(m_varDecl->slot, Expression::Ptr(new DynamicContextStore(m_operand1, context)));
+ context->setExpressionVariable(m_varDecl->slot, m_operand1);
return context;
}
diff --git a/src/xmlpatterns/schema/qxsdattribute.cpp b/src/xmlpatterns/schema/qxsdattribute.cpp
index 68f9e3d..fb768d4 100644
--- a/src/xmlpatterns/schema/qxsdattribute.cpp
+++ b/src/xmlpatterns/schema/qxsdattribute.cpp
@@ -59,12 +59,12 @@ XsdAttribute::Scope::Variety XsdAttribute::Scope::variety() const
void XsdAttribute::Scope::setParent(const NamedSchemaComponent::Ptr &parent)
{
- m_parent = parent;
+ m_parent = parent.data();
}
NamedSchemaComponent::Ptr XsdAttribute::Scope::parent() const
{
- return m_parent;
+ return NamedSchemaComponent::Ptr(m_parent);
}
void XsdAttribute::ValueConstraint::setVariety(Variety variety)
diff --git a/src/xmlpatterns/schema/qxsdattribute_p.h b/src/xmlpatterns/schema/qxsdattribute_p.h
index d64d335..a21fe70 100644
--- a/src/xmlpatterns/schema/qxsdattribute_p.h
+++ b/src/xmlpatterns/schema/qxsdattribute_p.h
@@ -131,7 +131,7 @@ namespace QPatternist
private:
Variety m_variety;
- NamedSchemaComponent::Ptr m_parent;
+ NamedSchemaComponent *m_parent;
};
diff --git a/src/xmlpatterns/schema/qxsdcomplextype.cpp b/src/xmlpatterns/schema/qxsdcomplextype.cpp
index 42aeb60..0932060 100644
--- a/src/xmlpatterns/schema/qxsdcomplextype.cpp
+++ b/src/xmlpatterns/schema/qxsdcomplextype.cpp
@@ -140,12 +140,12 @@ SchemaType::Ptr XsdComplexType::wxsSuperType() const
void XsdComplexType::setContext(const NamedSchemaComponent::Ptr &component)
{
- m_context = component;
+ m_context = component.data();
}
NamedSchemaComponent::Ptr XsdComplexType::context() const
{
- return m_context;
+ return NamedSchemaComponent::Ptr(m_context);
}
void XsdComplexType::setContentType(const ContentType::Ptr &type)
diff --git a/src/xmlpatterns/schema/qxsdcomplextype_p.h b/src/xmlpatterns/schema/qxsdcomplextype_p.h
index d28d2fc..d02583c 100644
--- a/src/xmlpatterns/schema/qxsdcomplextype_p.h
+++ b/src/xmlpatterns/schema/qxsdcomplextype_p.h
@@ -386,7 +386,7 @@ namespace QPatternist
private:
SchemaType::Ptr m_superType;
- NamedSchemaComponent::Ptr m_context;
+ NamedSchemaComponent *m_context;
DerivationMethod m_derivationMethod;
bool m_isAbstract;
XsdAttributeUse::List m_attributeUses;
diff --git a/src/xmlpatterns/schema/qxsdelement.cpp b/src/xmlpatterns/schema/qxsdelement.cpp
index 1ebec06..b0c5661 100644
--- a/src/xmlpatterns/schema/qxsdelement.cpp
+++ b/src/xmlpatterns/schema/qxsdelement.cpp
@@ -57,12 +57,12 @@ XsdElement::Scope::Variety XsdElement::Scope::variety() const
void XsdElement::Scope::setParent(const NamedSchemaComponent::Ptr &parent)
{
- m_parent = parent;
+ m_parent = parent.data();
}
NamedSchemaComponent::Ptr XsdElement::Scope::parent() const
{
- return m_parent;
+ return NamedSchemaComponent::Ptr(m_parent);
}
void XsdElement::ValueConstraint::setVariety(Variety variety)
@@ -233,10 +233,10 @@ XsdElement::List XsdElement::substitutionGroupAffiliations() const
void XsdElement::addSubstitutionGroup(const XsdElement::Ptr &element)
{
- m_substitutionGroups.insert(element);
+ m_substitutionGroups.insert(element.data());
}
-XsdElement::List XsdElement::substitutionGroups() const
+XsdElement::WeakList XsdElement::substitutionGroups() const
{
return m_substitutionGroups.toList();
}
diff --git a/src/xmlpatterns/schema/qxsdelement_p.h b/src/xmlpatterns/schema/qxsdelement_p.h
index 93c5983..3794c96 100644
--- a/src/xmlpatterns/schema/qxsdelement_p.h
+++ b/src/xmlpatterns/schema/qxsdelement_p.h
@@ -85,7 +85,7 @@ namespace QPatternist
public:
typedef QExplicitlySharedDataPointer<XsdElement> Ptr;
typedef QList<XsdElement::Ptr> List;
-
+ typedef QList<XsdElement *> WeakList;
/**
* Describes the <a href="http://www.w3.org/TR/xmlschema11-1/#ed-value_constraint">constraint type</a> of the element.
@@ -138,7 +138,7 @@ namespace QPatternist
private:
Variety m_variety;
- NamedSchemaComponent::Ptr m_parent;
+ NamedSchemaComponent *m_parent;
};
/**
@@ -379,7 +379,7 @@ namespace QPatternist
/**
* Returns the substitution groups of the element.
*/
- XsdElement::List substitutionGroups() const;
+ XsdElement::WeakList substitutionGroups() const;
private:
SchemaType::Ptr m_type;
@@ -392,7 +392,7 @@ namespace QPatternist
SchemaType::DerivationConstraints m_substitutionGroupExclusions;
XsdIdentityConstraint::List m_identityConstraints;
XsdElement::List m_substitutionGroupAffiliations;
- QSet<XsdElement::Ptr> m_substitutionGroups;
+ QSet<XsdElement *> m_substitutionGroups;
};
}
diff --git a/src/xmlpatterns/schema/qxsdparticlechecker.cpp b/src/xmlpatterns/schema/qxsdparticlechecker.cpp
index 15c2afe..d4beae7 100644
--- a/src/xmlpatterns/schema/qxsdparticlechecker.cpp
+++ b/src/xmlpatterns/schema/qxsdparticlechecker.cpp
@@ -309,12 +309,12 @@ static bool hasDuplicatedElementsInternal(const XsdParticle::Ptr &particle, cons
const XsdTerm::Ptr term = particle->term();
if (term->isElement()) {
const XsdElement::Ptr mainElement(term);
- XsdElement::List substGroups = mainElement->substitutionGroups();
+ XsdElement::WeakList substGroups = mainElement->substitutionGroups();
if (substGroups.isEmpty())
- substGroups << mainElement;
+ substGroups << mainElement.data();
for (int i = 0; i < substGroups.count(); ++i) {
- const XsdElement::Ptr element = substGroups.at(i);
+ const XsdElement::Ptr element(substGroups.at(i));
if (hash.contains(element->name(namePool))) {
if (element->type()->name(namePool) != hash.value(element->name(namePool))->type()->name(namePool)) {
conflictingElement = element;
diff --git a/src/xmlpatterns/schema/qxsdsimpletype.cpp b/src/xmlpatterns/schema/qxsdsimpletype.cpp
index 6fd5658..3e77aca 100644
--- a/src/xmlpatterns/schema/qxsdsimpletype.cpp
+++ b/src/xmlpatterns/schema/qxsdsimpletype.cpp
@@ -72,12 +72,12 @@ SchemaType::Ptr XsdSimpleType::wxsSuperType() const
void XsdSimpleType::setContext(const NamedSchemaComponent::Ptr &component)
{
- m_context = component;
+ m_context = component.data();
}
NamedSchemaComponent::Ptr XsdSimpleType::context() const
{
- return m_context;
+ return NamedSchemaComponent::Ptr(m_context);
}
void XsdSimpleType::setPrimitiveType(const AnySimpleType::Ptr &type)
diff --git a/src/xmlpatterns/schema/qxsdsimpletype_p.h b/src/xmlpatterns/schema/qxsdsimpletype_p.h
index 6305fc7..a5b72a7 100644
--- a/src/xmlpatterns/schema/qxsdsimpletype_p.h
+++ b/src/xmlpatterns/schema/qxsdsimpletype_p.h
@@ -202,7 +202,7 @@ namespace QPatternist
private:
SchemaType::Ptr m_superType;
- NamedSchemaComponent::Ptr m_context;
+ NamedSchemaComponent* m_context;
AnySimpleType::Ptr m_primitiveType;
AnySimpleType::Ptr m_itemType;
AnySimpleType::List m_memberTypes;
diff --git a/src/xmlpatterns/schema/qxsdstatemachinebuilder.cpp b/src/xmlpatterns/schema/qxsdstatemachinebuilder.cpp
index fed8a41..b6c8704 100644
--- a/src/xmlpatterns/schema/qxsdstatemachinebuilder.cpp
+++ b/src/xmlpatterns/schema/qxsdstatemachinebuilder.cpp
@@ -166,14 +166,14 @@ XsdStateMachine<XsdTerm::Ptr>::StateId XsdStateMachineBuilder::buildTerm(const X
const XsdElement::Ptr element(term);
if (m_mode == CheckingMode) {
- const XsdElement::List substGroups = element->substitutionGroups();
+ const XsdElement::WeakList substGroups = element->substitutionGroups();
for (int i = 0; i < substGroups.count(); ++i)
- m_stateMachine->addTransition(b, substGroups.at(i), endState);
+ m_stateMachine->addTransition(b, XsdElement::Ptr(substGroups.at(i)), endState);
} else if (m_mode == ValidatingMode) {
- const XsdElement::List substGroups = element->substitutionGroups();
+ const XsdElement::WeakList substGroups = element->substitutionGroups();
for (int i = 0; i < substGroups.count(); ++i) {
- if (XsdSchemaHelper::substitutionGroupOkTransitive(element, substGroups.at(i), m_namePool))
- m_stateMachine->addTransition(b, substGroups.at(i), endState);
+ if (XsdSchemaHelper::substitutionGroupOkTransitive(element, XsdElement::Ptr(substGroups.at(i)), m_namePool))
+ m_stateMachine->addTransition(b, XsdElement::Ptr(substGroups.at(i)), endState);
}
}