summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2011-03-01 09:40:06 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2011-03-01 09:40:06 (GMT)
commit48cd01714e3aa76872983cae820cfc1c7504b065 (patch)
tree0d7cf0938619e845599fe2eb65f21e7999b66c50 /src
parent4d803a3493d15fdf7374689b774d02662dbd43b3 (diff)
parent54869c8727e5403cea866c99a5f83ae9c8533f82 (diff)
downloadQt-48cd01714e3aa76872983cae820cfc1c7504b065.zip
Qt-48cd01714e3aa76872983cae820cfc1c7504b065.tar.gz
Qt-48cd01714e3aa76872983cae820cfc1c7504b065.tar.bz2
Merge remote-tracking branch 'origin/master' into lighthouse-master
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog53
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri3
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp46
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h9
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/runtime/UStringImpl.cpp14
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/runtime/UStringImpl.h117
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp132
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h120
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/RegisterFileAllocatorSymbian.cpp6
-rw-r--r--src/3rdparty/javascriptcore/VERSION4
-rw-r--r--src/3rdparty/phonon/mmf/abstractaudioeffect.h2
-rw-r--r--src/3rdparty/phonon/phonon/factory.cpp18
-rw-r--r--src/3rdparty/webkit/WebCore/WebCore.pro2
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h4
-rw-r--r--src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp10
-rw-r--r--src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc2
-rw-r--r--src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc19
-rw-r--r--src/3rdparty/zlib/zlib.h2
-rw-r--r--src/corelib/animation/qabstractanimation.cpp11
-rw-r--r--src/corelib/animation/qabstractanimation.h6
-rw-r--r--src/corelib/animation/qvariantanimation.cpp13
-rw-r--r--src/corelib/arch/arch.pri2
-rw-r--r--src/corelib/arch/integrity/arch.pri3
-rw-r--r--src/corelib/arch/qatomic_arch.h4
-rw-r--r--src/corelib/arch/qatomic_armv5.h2
-rw-r--r--src/corelib/arch/qatomic_integrity.h289
-rw-r--r--src/corelib/arch/symbian/qt_hybridheap_symbian_p.h3
-rw-r--r--src/corelib/codecs/qtextcodec.cpp6
-rw-r--r--src/corelib/concurrent/qfutureinterface.cpp9
-rw-r--r--src/corelib/concurrent/qfutureinterface_p.h5
-rw-r--r--src/corelib/corelib.pro9
-rw-r--r--src/corelib/global/global.pri2
-rw-r--r--src/corelib/global/qglobal.cpp2
-rw-r--r--src/corelib/global/qglobal.h51
-rw-r--r--src/corelib/global/qnamespace.h16
-rw-r--r--src/corelib/global/qnamespace.qdoc15
-rw-r--r--src/corelib/io/io.pri4
-rw-r--r--src/corelib/io/qfilesystemengine.cpp2
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp8
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp8
-rw-r--r--src/corelib/io/qprocess_unix.cpp34
-rw-r--r--src/corelib/io/qresource.cpp2
-rw-r--r--src/corelib/kernel/kernel.pri16
-rw-r--r--src/corelib/kernel/qcore_symbian_p.h16
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp26
-rw-r--r--src/corelib/kernel/qcoreapplication.h1
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h2
-rw-r--r--src/corelib/kernel/qcrashhandler.cpp3
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp5
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian_p.h3
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp5
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp5
-rw-r--r--src/corelib/kernel/qeventloop.cpp5
-rw-r--r--src/corelib/kernel/qmetaobject.cpp48
-rw-r--r--src/corelib/kernel/qmetaobject.h3
-rw-r--r--src/corelib/kernel/qmetaobject_p.h6
-rw-r--r--src/corelib/kernel/qmetatype.h2
-rw-r--r--src/corelib/kernel/qobject.h8
-rw-r--r--src/corelib/kernel/qobjectdefs.h2
-rw-r--r--src/corelib/kernel/qsharedmemory.cpp6
-rw-r--r--src/corelib/kernel/qsharedmemory_unix.cpp14
-rw-r--r--src/corelib/kernel/qsharedmemory_win.cpp3
-rw-r--r--src/corelib/kernel/qsystemsemaphore_symbian.cpp4
-rw-r--r--src/corelib/kernel/qsystemsemaphore_win.cpp3
-rw-r--r--src/corelib/kernel/qtranslator.cpp2
-rw-r--r--src/corelib/plugin/plugin.pri4
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp4
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp7
-rw-r--r--src/corelib/thread/qmutex.h9
-rw-r--r--src/corelib/thread/qmutex_unix.cpp5
-rw-r--r--src/corelib/thread/qthread.cpp10
-rw-r--r--src/corelib/thread/qthread_p.h2
-rw-r--r--src/corelib/thread/qthread_unix.cpp28
-rw-r--r--src/corelib/thread/qthread_win.cpp5
-rw-r--r--src/corelib/thread/thread.pri4
-rw-r--r--src/corelib/tools/qbytearray.cpp10
-rw-r--r--src/corelib/tools/qeasingcurve.cpp20
-rw-r--r--src/corelib/tools/qlocale.cpp2
-rw-r--r--src/corelib/tools/qscopedvaluerollback.cpp84
-rw-r--r--src/corelib/tools/qscopedvaluerollback.h81
-rw-r--r--src/corelib/tools/qset.h2
-rw-r--r--src/corelib/tools/qshareddata.h4
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h10
-rw-r--r--src/corelib/tools/qstring.cpp8
-rw-r--r--src/corelib/tools/tools.pri8
-rw-r--r--src/dbus/qdbusargument.h15
-rw-r--r--src/dbus/qdbusconnection.cpp20
-rw-r--r--src/dbus/qdbusdemarshaller.cpp21
-rw-r--r--src/dbus/qdbusintegrator.cpp43
-rw-r--r--src/dbus/qdbusmetaobject.cpp37
-rw-r--r--src/dbus/qdbusmetatype.cpp1
-rw-r--r--src/dbus/qdbusxmlparser.cpp53
-rw-r--r--src/declarative/debugger/debugger.pri8
-rw-r--r--src/declarative/debugger/qdeclarativedebugclient.cpp36
-rw-r--r--src/declarative/debugger/qdeclarativedebugserver.cpp361
-rw-r--r--src/declarative/debugger/qdeclarativedebugserver_p.h88
-rw-r--r--src/declarative/debugger/qdeclarativedebugserverconnection_p.h73
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice.cpp319
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice_p_p.h71
-rw-r--r--src/declarative/debugger/qdeclarativedebugtrace.cpp144
-rw-r--r--src/declarative/debugger/qdeclarativedebugtrace_p.h50
-rw-r--r--src/declarative/debugger/qpacketprotocol.cpp9
-rw-r--r--src/declarative/debugger/qpacketprotocol_p.h5
-rw-r--r--src/declarative/declarative.pro7
-rw-r--r--src/declarative/graphicsitems/graphicsitems.pri11
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp43
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage.cpp64
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp119
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflipable.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflipable_p.h6
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp249
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp112
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase.cpp52
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p.h15
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h10
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimplicitsizeitem.cpp92
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimplicitsizeitem_p.h100
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimplicitsizeitem_p_p.h (renamed from src/network/access/qnetworkaccessdatabackend_p.h)48
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp286
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h12
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp25
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp252
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp38
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader_p_p.h8
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp57
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea_p.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea_p_p.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath.cpp6
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp60
-rw-r--r--src/declarative/graphicsitems/qdeclarativepincharea.cpp582
-rw-r--r--src/declarative/graphicsitems/qdeclarativepincharea_p.h308
-rw-r--r--src/declarative/graphicsitems/qdeclarativepincharea_p_p.h109
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp252
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners_p.h24
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners_p_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle.cpp25
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater.cpp125
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater_p.h6
-rw-r--r--src/declarative/graphicsitems/qdeclarativescalegrid.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp377
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p.h34
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p_p.h19
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp329
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h31
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p_p.h17
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp311
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p.h22
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p_p.h16
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp7
-rw-r--r--src/declarative/qml/parser/qdeclarativejslexer.cpp2
-rw-r--r--src/declarative/qml/qdeclarative.h77
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp62
-rw-r--r--src/declarative/qml/qdeclarativebinding_p.h13
-rw-r--r--src/declarative/qml/qdeclarativeboundsignal.cpp31
-rw-r--r--src/declarative/qml/qdeclarativecompiledbindings.cpp48
-rw-r--r--src/declarative/qml/qdeclarativecompileddata.cpp30
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp271
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h8
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp109
-rw-r--r--src/declarative/qml/qdeclarativecomponent.h1
-rw-r--r--src/declarative/qml/qdeclarativecomponent_p.h3
-rw-r--r--src/declarative/qml/qdeclarativecontext_p.h1
-rw-r--r--src/declarative/qml/qdeclarativecustomparser.cpp11
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p.h3
-rw-r--r--src/declarative/qml/qdeclarativedom.cpp8
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp305
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h36
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp169
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug_p.h6
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp41
-rw-r--r--src/declarative/qml/qdeclarativeexpression.h3
-rw-r--r--src/declarative/qml/qdeclarativeexpression_p.h12
-rw-r--r--src/declarative/qml/qdeclarativeimageprovider.cpp10
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp126
-rw-r--r--src/declarative/qml/qdeclarativeinstruction_p.h1
-rw-r--r--src/declarative/qml/qdeclarativelist.cpp1
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp183
-rw-r--r--src/declarative/qml/qdeclarativemetatype_p.h8
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp29
-rw-r--r--src/declarative/qml/qdeclarativeparser.cpp7
-rw-r--r--src/declarative/qml/qdeclarativeparser_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeprivate.h2
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp123
-rw-r--r--src/declarative/qml/qdeclarativeproperty_p.h18
-rw-r--r--src/declarative/qml/qdeclarativepropertycache.cpp24
-rw-r--r--src/declarative/qml/qdeclarativepropertycache_p.h39
-rw-r--r--src/declarative/qml/qdeclarativerefcount_p.h2
-rw-r--r--src/declarative/qml/qdeclarativerewrite.cpp62
-rw-r--r--src/declarative/qml/qdeclarativerewrite_p.h4
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp37
-rw-r--r--src/declarative/qml/qdeclarativesqldatabase.cpp2
-rw-r--r--src/declarative/qml/qdeclarativestringconverters.cpp6
-rw-r--r--src/declarative/qml/qdeclarativetypeloader.cpp6
-rw-r--r--src/declarative/qml/qdeclarativetypeloader_p.h4
-rw-r--r--src/declarative/qml/qdeclarativetypenamescriptclass.cpp5
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp1
-rw-r--r--src/declarative/qml/qdeclarativevaluetypescriptclass.cpp32
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp24
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp73
-rw-r--r--src/declarative/qml/qmetaobjectbuilder.cpp33
-rw-r--r--src/declarative/qml/qmetaobjectbuilder_p.h2
-rw-r--r--src/declarative/qml/qml.pri9
-rw-r--r--src/declarative/qml/qperformancetimer.cpp226
-rw-r--r--src/declarative/qml/qperformancetimer_p.h79
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp70
-rw-r--r--src/declarative/util/qdeclarativeanimation_p_p.h3
-rw-r--r--src/declarative/util/qdeclarativeapplication.cpp112
-rw-r--r--src/declarative/util/qdeclarativeapplication_p.h86
-rw-r--r--src/declarative/util/qdeclarativeconnections.cpp19
-rw-r--r--src/declarative/util/qdeclarativefontloader.cpp14
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp93
-rw-r--r--src/declarative/util/qdeclarativelistmodel_p.h3
-rw-r--r--src/declarative/util/qdeclarativelistmodel_p_p.h6
-rw-r--r--src/declarative/util/qdeclarativelistmodelworkeragent.cpp28
-rw-r--r--src/declarative/util/qdeclarativelistmodelworkeragent_p.h5
-rw-r--r--src/declarative/util/qdeclarativeopenmetaobject.cpp1
-rw-r--r--src/declarative/util/qdeclarativepixmapcache.cpp22
-rw-r--r--src/declarative/util/qdeclarativepixmapcache_p.h12
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp135
-rw-r--r--src/declarative/util/qdeclarativepropertychanges_p.h18
-rw-r--r--src/declarative/util/qdeclarativespringanimation.cpp2
-rw-r--r--src/declarative/util/qdeclarativestate.cpp45
-rw-r--r--src/declarative/util/qdeclarativestate_p.h16
-rw-r--r--src/declarative/util/qdeclarativestategroup.cpp48
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp138
-rw-r--r--src/declarative/util/qdeclarativetransition.cpp34
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp3
-rw-r--r--src/declarative/util/qdeclarativeview.cpp24
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp187
-rw-r--r--src/declarative/util/util.pri2
-rw-r--r--src/gui/dialogs/qfiledialog.cpp2
-rw-r--r--src/gui/dialogs/qfiledialog_symbian.cpp64
-rw-r--r--src/gui/dialogs/qfileinfogatherer.cpp6
-rw-r--r--src/gui/dialogs/qpagesetupdialog.cpp8
-rw-r--r--src/gui/embedded/embedded.pri16
-rw-r--r--src/gui/embedded/qkbddriverfactory_qws.cpp8
-rw-r--r--src/gui/embedded/qkbdintegrity_qws.cpp197
-rw-r--r--src/gui/embedded/qkbdintegrity_qws.h81
-rw-r--r--src/gui/embedded/qmousedriverfactory_qws.cpp8
-rw-r--r--src/gui/embedded/qmouseintegrity_qws.cpp271
-rw-r--r--src/gui/embedded/qmouseintegrity_qws.h82
-rw-r--r--src/gui/embedded/qscreen_qws.cpp2
-rw-r--r--src/gui/embedded/qscreen_qws.h3
-rw-r--r--src/gui/embedded/qscreendriverfactory_qws.cpp8
-rw-r--r--src/gui/embedded/qscreenintegrityfb_qws.cpp405
-rw-r--r--src/gui/embedded/qscreenintegrityfb_qws.h83
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout.cpp4
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp12
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp29
-rw-r--r--src/gui/graphicsview/qgridlayoutengine.cpp5
-rw-r--r--src/gui/gui.pro7
-rw-r--r--src/gui/image/qbmphandler.cpp2
-rw-r--r--src/gui/image/qgifhandler.cpp10
-rw-r--r--src/gui/image/qimage.cpp8
-rw-r--r--src/gui/image/qnativeimage.cpp8
-rw-r--r--src/gui/image/qpixmap_s60.cpp27
-rw-r--r--src/gui/image/qpixmap_s60_p.h2
-rw-r--r--src/gui/image/qxpmhandler.cpp2
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp2
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp4
-rw-r--r--src/gui/itemviews/qtreeview.cpp11
-rw-r--r--src/gui/kernel/qapplication.cpp31
-rw-r--r--src/gui/kernel/qapplication_mac.mm124
-rw-r--r--src/gui/kernel/qapplication_p.h2
-rw-r--r--src/gui/kernel/qapplication_qws.cpp5
-rw-r--r--src/gui/kernel/qapplication_s60.cpp46
-rw-r--r--src/gui/kernel/qapplication_x11.cpp48
-rw-r--r--src/gui/kernel/qcocoaapplicationdelegate_mac.mm24
-rw-r--r--src/gui/kernel/qcocoapanel_mac.mm7
-rw-r--r--src/gui/kernel/qcocoapanel_mac_p.h9
-rw-r--r--src/gui/kernel/qcocoasharedwindowmethods_mac_p.h411
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm857
-rw-r--r--src/gui/kernel/qcocoaview_mac_p.h29
-rw-r--r--src/gui/kernel/qcocoawindow_mac.mm2
-rw-r--r--src/gui/kernel/qcocoawindow_mac_p.h10
-rw-r--r--src/gui/kernel/qcursor.h5
-rw-r--r--src/gui/kernel/qcursor_mac.mm128
-rw-r--r--src/gui/kernel/qdnd_mac.mm4
-rw-r--r--src/gui/kernel/qevent.cpp76
-rw-r--r--src/gui/kernel/qevent.h9
-rw-r--r--src/gui/kernel/qevent_p.h8
-rw-r--r--src/gui/kernel/qgesture.cpp2
-rw-r--r--src/gui/kernel/qkeymapper_p.h1
-rw-r--r--src/gui/kernel/qkeymapper_s60.cpp32
-rw-r--r--src/gui/kernel/qkeymapper_x11_p.cpp1
-rw-r--r--src/gui/kernel/qlayout.cpp6
-rw-r--r--src/gui/kernel/qmacgesturerecognizer_mac.mm6
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm457
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac_p.h84
-rw-r--r--src/gui/kernel/qt_s60_p.h2
-rw-r--r--src/gui/kernel/qwidget.cpp101
-rw-r--r--src/gui/kernel/qwidget_mac.mm832
-rw-r--r--src/gui/kernel/qwidget_p.h11
-rw-r--r--src/gui/kernel/qwidget_s60.cpp49
-rw-r--r--src/gui/kernel/qwidget_x11.cpp54
-rw-r--r--src/gui/kernel/qx11embed_x11.cpp7
-rw-r--r--src/gui/math3d/qgenericmatrix.h6
-rw-r--r--src/gui/math3d/qmatrix4x4.h6
-rw-r--r--src/gui/painting/qbackingstore_p.h3
-rw-r--r--src/gui/painting/qblendfunctions.cpp2
-rw-r--r--src/gui/painting/qbrush.cpp8
-rw-r--r--src/gui/painting/qcolor.cpp6
-rw-r--r--src/gui/painting/qdrawhelper.cpp2
-rw-r--r--src/gui/painting/qdrawhelper_arm_simd.cpp4
-rw-r--r--src/gui/painting/qgraphicssystem_runtime.cpp1
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp15
-rw-r--r--src/gui/painting/qpainter.cpp12
-rw-r--r--src/gui/painting/qpainterpath.cpp25
-rw-r--r--src/gui/painting/qstroker.cpp40
-rw-r--r--src/gui/painting/qwindowsurface_raster.cpp30
-rw-r--r--src/gui/painting/qwindowsurface_raster_p.h3
-rw-r--r--src/gui/painting/qwindowsurface_s60.cpp17
-rw-r--r--src/gui/s60framework/qs60mainappui.cpp11
-rw-r--r--src/gui/s60framework/qs60mainappui.h1
-rw-r--r--src/gui/s60framework/qs60maindocument.cpp20
-rw-r--r--src/gui/statemachine/qguistatemachine.cpp1
-rw-r--r--src/gui/styles/qs60style.cpp6
-rw-r--r--src/gui/styles/qs60style_s60.cpp8
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp2
-rw-r--r--src/gui/styles/qstylesheetstyle_default.cpp2
-rw-r--r--src/gui/text/qcssparser.cpp44
-rw-r--r--src/gui/text/qcssparser_p.h3
-rw-r--r--src/gui/text/qfont_s60.cpp18
-rw-r--r--src/gui/text/qfontdatabase.cpp20
-rw-r--r--src/gui/text/qfontdatabase_s60.cpp553
-rw-r--r--src/gui/text/qfontdatabase_x11.cpp11
-rw-r--r--src/gui/text/qfontengine_qws.cpp51
-rw-r--r--src/gui/text/qfontengine_s60.cpp5
-rw-r--r--src/gui/text/qtextcontrol.cpp162
-rw-r--r--src/gui/text/qtextcontrol_p.h8
-rw-r--r--src/gui/text/qtextcontrol_p_p.h24
-rw-r--r--src/gui/text/qtextdocument_p.cpp4
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp1
-rw-r--r--src/gui/text/qtextengine.cpp18
-rw-r--r--src/gui/text/text.pri2
-rw-r--r--src/gui/widgets/qcocoamenu_mac.mm1
-rw-r--r--src/gui/widgets/qcombobox.cpp16
-rw-r--r--src/gui/widgets/qfocusframe.cpp3
-rw-r--r--src/gui/widgets/qlinecontrol.cpp10
-rw-r--r--src/gui/widgets/qlinecontrol_p.h1
-rw-r--r--src/gui/widgets/qmainwindow.cpp5
-rw-r--r--src/gui/widgets/qmainwindowlayout_mac.mm25
-rw-r--r--src/gui/widgets/qmenubar.cpp5
-rw-r--r--src/gui/widgets/qplaintextedit.cpp2
-rw-r--r--src/gui/widgets/qscrollbar.cpp39
-rw-r--r--src/gui/widgets/qsizegrip.cpp4
-rw-r--r--src/imports/gestures/qdeclarativegesturearea.cpp18
-rw-r--r--src/multimedia/audio/qaudiooutput_symbian_p.cpp2
-rw-r--r--src/network/access/access.pri2
-rw-r--r--src/network/access/qnetworkaccessauthenticationmanager.cpp297
-rw-r--r--src/network/access/qnetworkaccessauthenticationmanager_p.h107
-rw-r--r--src/network/access/qnetworkaccessbackend.cpp2
-rw-r--r--src/network/access/qnetworkaccessftpbackend.cpp4
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp299
-rw-r--r--src/network/access/qnetworkaccessmanager.h2
-rw-r--r--src/network/access/qnetworkaccessmanager_p.h9
-rw-r--r--src/network/access/qnetworkdiskcache.cpp2
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp12
-rw-r--r--src/network/access/qnetworkrequest.cpp5
-rw-r--r--src/network/bearer/bearer.pri6
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp17
-rw-r--r--src/network/bearer/qnetworksession.cpp7
-rw-r--r--src/network/bearer/qnetworksession.h2
-rw-r--r--src/network/bearer/qsharednetworksession.cpp90
-rw-r--r--src/network/bearer/qsharednetworksession_p.h81
-rw-r--r--src/network/kernel/kernel.pri1
-rw-r--r--src/network/kernel/qauthenticator.cpp19
-rw-r--r--src/network/kernel/qnetworkinterface_symbian.cpp2
-rw-r--r--src/network/socket/qlocalsocket.cpp2
-rw-r--r--src/network/socket/socket.pri10
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp1
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp15
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp3
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h4
-rw-r--r--src/opengl/opengl.pro7
-rw-r--r--src/opengl/qgl.cpp2
-rw-r--r--src/opengl/qgl_symbian.cpp114
-rw-r--r--src/opengl/qglframebufferobject.cpp4
-rw-r--r--src/opengl/qglpixelbuffer.cpp4
-rw-r--r--src/opengl/qglpixmapfilter.cpp6
-rw-r--r--src/opengl/qglshaderprogram.cpp4
-rw-r--r--src/opengl/qpaintengine_opengl.cpp2
-rw-r--r--src/opengl/qpixmapdata_gl.cpp167
-rw-r--r--src/opengl/qpixmapdata_gl_p.h9
-rw-r--r--src/opengl/qwindowsurface_gl.cpp44
-rw-r--r--src/openvg/openvg.pro7
-rw-r--r--src/openvg/qpaintengine_vg.cpp45
-rw-r--r--src/openvg/qpixmapdata_vg.cpp16
-rw-r--r--src/openvg/qvg_symbian.cpp2
-rw-r--r--src/openvg/qwindowsurface_vgegl.cpp3
-rw-r--r--src/plugins/bearer/icd/dbusdispatcher.cpp8
-rw-r--r--src/plugins/bearer/icd/qnetworksession_impl.cpp6
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp5
-rw-r--r--src/plugins/bearer/symbian/qnetworksession_impl.cpp6
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp27
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp2
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp46
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h1
-rw-r--r--src/plugins/graphicssystems/meego/dithering.cpp147
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.cpp8
-rw-r--r--src/plugins/imageformats/ico/qicohandler.cpp2
-rw-r--r--src/plugins/phonon/mmf/mmf.pro2
-rw-r--r--src/plugins/plugins.pro2
-rw-r--r--src/plugins/qmltooling/qmltooling.pro4
-rw-r--r--src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp173
-rw-r--r--src/plugins/qmltooling/tcpserver/qtcpserverconnection.h84
-rw-r--r--src/plugins/qmltooling/tcpserver/tcpserver.pro18
-rw-r--r--src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri6
-rw-r--r--src/qbase.pri2
-rw-r--r--src/qt3support/network/q3dns.cpp27
-rw-r--r--src/qt3support/tools/q3memarray.qdoc4
-rw-r--r--src/qt3support/tools/q3ptrlist.qdoc3
-rw-r--r--src/s60installs/bwins/QtCoreu.def2
-rw-r--r--src/s60installs/bwins/QtDeclarativeu.def124
-rw-r--r--src/s60installs/bwins/QtGuiu.def8
-rw-r--r--src/s60installs/bwins/QtScriptu.def2
-rw-r--r--src/s60installs/eabi/QtCoreu.def2
-rw-r--r--src/s60installs/eabi/QtDeclarativeu.def133
-rw-r--r--src/s60installs/eabi/QtGuiu.def12
-rw-r--r--src/s60installs/eabi/QtScriptu.def2
-rw-r--r--src/s60installs/s60installs.pro23
-rw-r--r--src/script/api/qscriptcontext.cpp9
-rw-r--r--src/script/api/qscriptcontextinfo.cpp7
-rw-r--r--src/script/api/qscriptengine.cpp34
-rw-r--r--src/script/api/qscriptengine_p.h36
-rw-r--r--src/script/api/qscriptprogram.cpp22
-rw-r--r--src/script/api/qscriptprogram_p.h1
-rw-r--r--src/script/bridge/qscriptclassobject.cpp5
-rw-r--r--src/script/bridge/qscriptdeclarativeclass.cpp13
-rw-r--r--src/script/bridge/qscriptdeclarativeclass_p.h2
-rw-r--r--src/script/script.pro5
-rw-r--r--src/sql/drivers/oci/qsql_oci.h6
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp2
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp6
-rw-r--r--src/sql/kernel/qsqldatabase.cpp2
-rw-r--r--src/sql/kernel/qsqlquery.cpp3
-rw-r--r--src/sql/models/qsqlquerymodel.cpp11
-rw-r--r--src/sql/models/qsqltablemodel.cpp26
-rw-r--r--src/sql/models/qsqltablemodel_p.h2
-rw-r--r--src/sql/sql.pro9
-rw-r--r--src/src.pro3
-rw-r--r--src/testlib/qbenchmark_p.h4
-rw-r--r--src/testlib/qtestcase.cpp53
-rw-r--r--src/testlib/qtestlog_p.h2
-rw-r--r--src/testlib/qtestmouse.h4
-rw-r--r--src/testlib/qtestresult_p.h2
-rw-r--r--src/testlib/qtesttable_p.h2
-rw-r--r--src/tools/moc/generator.cpp36
-rw-r--r--src/tools/moc/generator.h1
-rw-r--r--src/tools/moc/keywords.cpp20
-rw-r--r--src/tools/moc/main.cpp10
-rw-r--r--src/tools/moc/moc.cpp82
-rw-r--r--src/tools/moc/moc.h13
-rw-r--r--src/tools/moc/parser.cpp6
-rw-r--r--src/tools/moc/parser.h4
-rw-r--r--src/tools/moc/token.cpp1
-rw-r--r--src/tools/moc/token.h1
-rw-r--r--src/tools/moc/util/generate_keywords.cpp1
466 files changed, 15028 insertions, 4680 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog
index fd6c3f7..9cbf0c1 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog
@@ -232,6 +232,34 @@
without using doubles, but the code would be much more complicated, and there is no important
reason to stick to integers here.
+2010-03-22 Siddharth Mathur <siddharth.mathur@nokia.com>
+
+ Reviewed by Laszlo Gombos.
+
+ [Symbian] More efficient aligned memory allocation for JSC Collector
+ https://bugs.webkit.org/show_bug.cgi?id=34350
+
+ * JavaScriptCore.pri: Added 2 new Symbian source files and HAL linkage
+
+ * runtime/Collector.cpp: Reduced port-specific code and added private data member
+ (JSC::Heap::Heap):
+ (JSC::Heap::~Heap):
+ (JSC::Heap::destroy):
+ (JSC::Heap::allocateBlock):
+ (JSC::Heap::freeBlockPtr):
+
+ * runtime/Collector.h: Added private data member
+
+ * wtf/symbian: Added.
+ * wtf/symbian/BlockAllocatorSymbian.cpp: Added.
+ (WTF::AlignedBlockAllocator::AlignedBlockAllocator): Helper class to allocate
+ aligned blocks more efficiently as required by Collector
+ (WTF::AlignedBlockAllocator::alloc):
+ (WTF::AlignedBlockAllocator::free):
+ (WTF::AlignedBlockAllocator::destroy):
+ (WTF::AlignedBlockAllocator::~AlignedBlockAllocator):
+ * wtf/symbian/BlockAllocatorSymbian.h: Added.
+
2010-03-22 Geoffrey Garen <ggaren@apple.com>
Reviewed by Sam Weinig.
@@ -330,6 +358,31 @@
* wtf/AlwaysInline.h:
+2010-02-12 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by Darin Adler.
+
+ https://bugs.webkit.org/show_bug.cgi?id=33731
+ Many false leaks in release builds due to PtrAndFlags
+
+ Remove UntypedPtrAndBitfield (similar to PtrAndFlags) in UStringImpl,
+ and steal bits from the refCount instead.
+
+ * runtime/UStringImpl.cpp:
+ (JSC::UStringImpl::baseSharedBuffer):
+ (JSC::UStringImpl::~UStringImpl):
+ * runtime/UStringImpl.h:
+ (JSC::UStringImpl::cost):
+ (JSC::UStringImpl::isIdentifier):
+ (JSC::UStringImpl::setIsIdentifier):
+ (JSC::UStringImpl::ref):
+ (JSC::UStringImpl::deref):
+ (JSC::UStringImpl::UStringImpl):
+ (JSC::UStringImpl::bufferOwnerString):
+ (JSC::UStringImpl::bufferOwnership):
+ (JSC::UStringImpl::isStatic):
+ (JSC::UStringImpl::):
+
2010-02-12 Kwang Yul Seo <skyul@company100.net>
Reviewed by Adam Barth.
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri
index d75bd31..b061321 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri
@@ -16,6 +16,7 @@ CONFIG(debug, debug|release) {
symbian: {
# Need to guarantee this comes before system includes of /epoc32/include
MMP_RULES += "USERINCLUDE ../JavaScriptCore/profiler"
+ LIBS += -lhal
}
INCLUDEPATH = \
@@ -33,6 +34,7 @@ INCLUDEPATH = \
$$PWD/runtime \
$$PWD/wrec \
$$PWD/wtf \
+ $$PWD/wtf/symbian \
$$PWD/wtf/unicode \
$$PWD/yarr \
$$PWD/API \
@@ -211,6 +213,7 @@ SOURCES += \
wtf/qt/ThreadingQt.cpp \
wtf/RandomNumber.cpp \
wtf/RefCountedLeakCounter.cpp \
+ wtf/symbian/BlockAllocatorSymbian.cpp \
wtf/symbian/RegisterFileAllocatorSymbian.cpp \
wtf/ThreadingNone.cpp \
wtf/Threading.cpp \
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp
index 24873c8..42e2a35 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp
@@ -53,11 +53,6 @@
#include <mach/thread_act.h>
#include <mach/vm_map.h>
-#elif OS(SYMBIAN)
-#include <e32std.h>
-#include <e32cmn.h>
-#include <unistd.h>
-
#elif OS(WINDOWS)
#include <windows.h>
@@ -109,11 +104,6 @@ const size_t ALLOCATIONS_PER_COLLECTION = 3600;
// a PIC branch in Mach-O binaries, see <rdar://problem/5971391>.
#define MIN_ARRAY_SIZE (static_cast<size_t>(14))
-#if OS(SYMBIAN)
-const size_t MAX_NUM_BLOCKS = 256; // Max size of collector heap set to 16 MB
-static RHeap* userChunk = 0;
-#endif
-
#if ENABLE(JSC_MULTIPLE_THREADS)
#if OS(DARWIN)
@@ -146,29 +136,11 @@ Heap::Heap(JSGlobalData* globalData)
, m_currentThreadRegistrar(0)
#endif
, m_globalData(globalData)
+#if OS(SYMBIAN)
+ , m_blockallocator(JSCCOLLECTOR_VIRTUALMEM_RESERVATION, BLOCK_SIZE)
+#endif
{
ASSERT(globalData);
-
-#if OS(SYMBIAN)
- // Symbian OpenC supports mmap but currently not the MAP_ANON flag.
- // Using fastMalloc() does not properly align blocks on 64k boundaries
- // and previous implementation was flawed/incomplete.
- // UserHeap::ChunkHeap allows allocation of continuous memory and specification
- // of alignment value for (symbian) cells within that heap.
- //
- // Clarification and mapping of terminology:
- // RHeap (created by UserHeap::ChunkHeap below) is continuos memory chunk,
- // which can dynamically grow up to 8 MB,
- // that holds all CollectorBlocks of this session (static).
- // Each symbian cell within RHeap maps to a 64kb aligned CollectorBlock.
- // JSCell objects are maintained as usual within CollectorBlocks.
- if (!userChunk) {
- userChunk = UserHeap::ChunkHeap(0, 0, MAX_NUM_BLOCKS * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE);
- if (!userChunk)
- CRASH();
- }
-#endif // OS(SYMBIAN)
-
memset(&m_heap, 0, sizeof(CollectorHeap));
allocateBlock();
}
@@ -211,7 +183,9 @@ void Heap::destroy()
t = next;
}
#endif
-
+#if OS(SYMBIAN)
+ m_blockallocator.destroy();
+#endif
m_globalData = 0;
}
@@ -221,11 +195,9 @@ NEVER_INLINE CollectorBlock* Heap::allocateBlock()
vm_address_t address = 0;
vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE | VM_TAG_FOR_COLLECTOR_MEMORY, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT);
#elif OS(SYMBIAN)
- // Allocate a 64 kb aligned CollectorBlock
- unsigned char* mask = reinterpret_cast<unsigned char*>(userChunk->Alloc(BLOCK_SIZE));
- if (!mask)
+ void* address = m_blockallocator.alloc();
+ if (!address)
CRASH();
- uintptr_t address = reinterpret_cast<uintptr_t>(mask);
#elif OS(WINCE)
void* address = VirtualAlloc(NULL, BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
#elif OS(WINDOWS)
@@ -316,7 +288,7 @@ NEVER_INLINE void Heap::freeBlockPtr(CollectorBlock* block)
#if OS(DARWIN)
vm_deallocate(current_task(), reinterpret_cast<vm_address_t>(block), BLOCK_SIZE);
#elif OS(SYMBIAN)
- userChunk->Free(reinterpret_cast<TAny*>(block));
+ m_blockallocator.free(reinterpret_cast<void*>(block));
#elif OS(WINCE)
VirtualFree(block, 0, MEM_RELEASE);
#elif OS(WINDOWS)
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h
index 7f7a679..d3616dc 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h
@@ -35,6 +35,10 @@
#include <pthread.h>
#endif
+#if OS(SYMBIAN)
+#include <wtf/symbian/BlockAllocatorSymbian.h>
+#endif
+
#define ASSERT_CLASS_FITS_IN_CELL(class) COMPILE_ASSERT(sizeof(class) <= CELL_SIZE, class_fits_in_cell)
namespace JSC {
@@ -167,6 +171,11 @@ namespace JSC {
pthread_key_t m_currentThreadRegistrar;
#endif
+#if OS(SYMBIAN)
+ // Allocates collector blocks with correct alignment
+ WTF::AlignedBlockAllocator m_blockallocator;
+#endif
+
JSGlobalData* m_globalData;
};
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UStringImpl.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UStringImpl.cpp
index 4b0d1c9..4fde49e 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UStringImpl.cpp
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UStringImpl.cpp
@@ -38,12 +38,14 @@ namespace JSC {
SharedUChar* UStringImpl::baseSharedBuffer()
{
ASSERT((bufferOwnership() == BufferShared)
- || ((bufferOwnership() == BufferOwned) && !m_dataBuffer.asPtr<void*>()));
+ || ((bufferOwnership() == BufferOwned) && !m_buffer));
- if (bufferOwnership() != BufferShared)
- m_dataBuffer = UntypedPtrAndBitfield(SharedUChar::create(new OwnFastMallocPtr<UChar>(m_data)).releaseRef(), BufferShared);
+ if (bufferOwnership() != BufferShared) {
+ m_refCountAndFlags = (m_refCountAndFlags & ~s_refCountMaskBufferOwnership) | BufferShared;
+ m_bufferShared = SharedUChar::create(new OwnFastMallocPtr<UChar>(m_data)).releaseRef();
+ }
- return m_dataBuffer.asPtr<SharedUChar*>();
+ return m_bufferShared;
}
SharedUChar* UStringImpl::sharedBuffer()
@@ -71,10 +73,10 @@ UStringImpl::~UStringImpl()
if (bufferOwnership() == BufferOwned)
fastFree(m_data);
else if (bufferOwnership() == BufferSubstring)
- m_dataBuffer.asPtr<UStringImpl*>()->deref();
+ m_bufferSubstring->deref();
else {
ASSERT(bufferOwnership() == BufferShared);
- m_dataBuffer.asPtr<SharedUChar*>()->deref();
+ m_bufferShared->deref();
}
}
}
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UStringImpl.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UStringImpl.h
index 4e1ddc7..e6d1a8a 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UStringImpl.h
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UStringImpl.h
@@ -40,48 +40,6 @@ class IdentifierTable;
typedef CrossThreadRefCounted<OwnFastMallocPtr<UChar> > SharedUChar;
-class UntypedPtrAndBitfield {
-public:
- UntypedPtrAndBitfield() {}
-
- UntypedPtrAndBitfield(void* ptrValue, uintptr_t bitValue)
- : m_value(reinterpret_cast<uintptr_t>(ptrValue) | bitValue)
-#ifndef NDEBUG
- , m_leaksPtr(ptrValue)
-#endif
- {
- ASSERT(ptrValue == asPtr<void*>());
- ASSERT((*this & ~s_alignmentMask) == bitValue);
- }
-
- template<typename T>
- T asPtr() const { return reinterpret_cast<T>(m_value & s_alignmentMask); }
-
- UntypedPtrAndBitfield& operator&=(uintptr_t bits)
- {
- m_value &= bits | s_alignmentMask;
- return *this;
- }
-
- UntypedPtrAndBitfield& operator|=(uintptr_t bits)
- {
- m_value |= bits & ~s_alignmentMask;
- return *this;
- }
-
- uintptr_t operator&(uintptr_t mask) const
- {
- return m_value & mask & ~s_alignmentMask;
- }
-
-private:
- static const uintptr_t s_alignmentMask = ~static_cast<uintptr_t>(0x7);
- uintptr_t m_value;
-#ifndef NDEBUG
- void* m_leaksPtr; // Only used to allow tools like leaks on OSX to detect that the memory is referenced.
-#endif
-};
-
class UStringImpl : Noncopyable {
public:
template<size_t inlineCapacity>
@@ -151,21 +109,27 @@ public:
{
// For substrings, return the cost of the base string.
if (bufferOwnership() == BufferSubstring)
- return m_dataBuffer.asPtr<UStringImpl*>()->cost();
+ return m_bufferSubstring->cost();
- if (m_dataBuffer & s_reportedCostBit)
+ if (m_refCountAndFlags & s_refCountFlagHasReportedCost)
return 0;
- m_dataBuffer |= s_reportedCostBit;
+ m_refCountAndFlags |= s_refCountFlagHasReportedCost;
return m_length;
}
unsigned hash() const { if (!m_hash) m_hash = computeHash(data(), m_length); return m_hash; }
unsigned existingHash() const { ASSERT(m_hash); return m_hash; } // fast path for Identifiers
void setHash(unsigned hash) { ASSERT(hash == computeHash(data(), m_length)); m_hash = hash; } // fast path for Identifiers
- bool isIdentifier() const { return m_isIdentifier; }
- void setIsIdentifier(bool isIdentifier) { m_isIdentifier = isIdentifier; }
+ bool isIdentifier() const { return m_refCountAndFlags & s_refCountFlagIsIdentifier; }
+ void setIsIdentifier(bool isIdentifier)
+ {
+ if (isIdentifier)
+ m_refCountAndFlags |= s_refCountFlagIsIdentifier;
+ else
+ m_refCountAndFlags &= ~s_refCountFlagIsIdentifier;
+ }
- UStringImpl* ref() { m_refCount += s_refCountIncrement; return this; }
- ALWAYS_INLINE void deref() { if (!(m_refCount -= s_refCountIncrement)) delete this; }
+ UStringImpl* ref() { m_refCountAndFlags += s_refCountIncrement; return this; }
+ ALWAYS_INLINE void deref() { m_refCountAndFlags -= s_refCountIncrement; if (!(m_refCountAndFlags & s_refCountMask)) delete this; }
static void copyChars(UChar* destination, const UChar* source, unsigned numCharacters)
{
@@ -205,11 +169,10 @@ private:
// Used to construct normal strings with an internal or external buffer.
UStringImpl(UChar* data, int length, BufferOwnership ownership)
: m_data(data)
+ , m_buffer(0)
, m_length(length)
- , m_refCount(s_refCountIncrement)
+ , m_refCountAndFlags(s_refCountIncrement | ownership)
, m_hash(0)
- , m_isIdentifier(false)
- , m_dataBuffer(0, ownership)
{
ASSERT((ownership == BufferInternal) || (ownership == BufferOwned));
checkConsistency();
@@ -221,11 +184,10 @@ private:
enum StaticStringConstructType { ConstructStaticString };
UStringImpl(UChar* data, int length, StaticStringConstructType)
: m_data(data)
+ , m_buffer(0)
, m_length(length)
- , m_refCount(s_staticRefCountInitialValue)
+ , m_refCountAndFlags(s_refCountFlagStatic | BufferOwned)
, m_hash(0)
- , m_isIdentifier(false)
- , m_dataBuffer(0, BufferOwned)
{
checkConsistency();
}
@@ -233,28 +195,26 @@ private:
// Used to create new strings that are a substring of an existing string.
UStringImpl(UChar* data, int length, PassRefPtr<UStringImpl> base)
: m_data(data)
+ , m_bufferSubstring(base.releaseRef())
, m_length(length)
- , m_refCount(s_refCountIncrement)
+ , m_refCountAndFlags(s_refCountIncrement | BufferSubstring)
, m_hash(0)
- , m_isIdentifier(false)
- , m_dataBuffer(base.releaseRef(), BufferSubstring)
{
// Do use static strings as a base for substrings; UntypedPtrAndBitfield assumes
// that all pointers will be at least 8-byte aligned, we cannot guarantee that of
// UStringImpls that are not heap allocated.
- ASSERT(m_dataBuffer.asPtr<UStringImpl*>()->size());
- ASSERT(!m_dataBuffer.asPtr<UStringImpl*>()->isStatic());
+ ASSERT(m_bufferSubstring->size());
+ ASSERT(!m_bufferSubstring->isStatic());
checkConsistency();
}
// Used to construct new strings sharing an existing shared buffer.
UStringImpl(UChar* data, int length, PassRefPtr<SharedUChar> sharedBuffer)
: m_data(data)
+ , m_bufferShared(sharedBuffer.releaseRef())
, m_length(length)
- , m_refCount(s_refCountIncrement)
+ , m_refCountAndFlags(s_refCountIncrement | BufferShared)
, m_hash(0)
- , m_isIdentifier(false)
- , m_dataBuffer(sharedBuffer.releaseRef(), BufferShared)
{
checkConsistency();
}
@@ -277,26 +237,31 @@ private:
// This number must be at least 2 to avoid sharing empty, null as well as 1 character strings from SmallStrings.
static const int s_minLengthToShare = 10;
static const unsigned s_copyCharsInlineCutOff = 20;
- static const uintptr_t s_bufferOwnershipMask = 3;
- static const uintptr_t s_reportedCostBit = 4;
// We initialize and increment/decrement the refCount for all normal (non-static) strings by the value 2.
// We initialize static strings with an odd number (specifically, 1), such that the refCount cannot reach zero.
- static const int s_refCountIncrement = 2;
- static const int s_staticRefCountInitialValue = 1;
-
- UStringImpl* bufferOwnerString() { return (bufferOwnership() == BufferSubstring) ? m_dataBuffer.asPtr<UStringImpl*>() : this; }
- const UStringImpl* bufferOwnerString() const { return (bufferOwnership() == BufferSubstring) ? m_dataBuffer.asPtr<UStringImpl*>() : this; }
+ static const unsigned s_refCountMask = 0xFFFFFFF0;
+ static const int s_refCountIncrement = 0x20;
+ static const int s_refCountFlagStatic = 0x10;
+ static const unsigned s_refCountFlagHasReportedCost = 0x8;
+ static const unsigned s_refCountFlagIsIdentifier = 0x4;
+ static const unsigned s_refCountMaskBufferOwnership = 0x3;
+
+ UStringImpl* bufferOwnerString() { return (bufferOwnership() == BufferSubstring) ? m_bufferSubstring : this; }
+ const UStringImpl* bufferOwnerString() const { return (bufferOwnership() == BufferSubstring) ? m_bufferSubstring : this; }
SharedUChar* baseSharedBuffer();
- unsigned bufferOwnership() const { return m_dataBuffer & s_bufferOwnershipMask; }
- bool isStatic() const { return m_refCount & 1; }
+ unsigned bufferOwnership() const { return m_refCountAndFlags & s_refCountMaskBufferOwnership; }
+ bool isStatic() const { return m_refCountAndFlags & s_refCountFlagStatic; }
// unshared data
UChar* m_data;
+ union {
+ void* m_buffer;
+ UStringImpl* m_bufferSubstring;
+ SharedUChar* m_bufferShared;
+ };
int m_length;
- unsigned m_refCount;
- mutable unsigned m_hash : 31;
- mutable unsigned m_isIdentifier : 1;
- UntypedPtrAndBitfield m_dataBuffer;
+ unsigned m_refCountAndFlags;
+ mutable unsigned m_hash;
JS_EXPORTDATA static UStringImpl* s_null;
JS_EXPORTDATA static UStringImpl* s_empty;
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp
new file mode 100644
index 0000000..6a28e9e
--- /dev/null
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if OS(SYMBIAN)
+
+#include "BlockAllocatorSymbian.h"
+
+
+namespace WTF {
+
+/** Efficiently allocates blocks of size blockSize with blockSize alignment.
+ * Primarly designed for JSC Collector's needs.
+ * Not thread-safe.
+ */
+AlignedBlockAllocator::AlignedBlockAllocator(TUint32 reservationSize, TUint32 blockSize )
+ : m_reservation(reservationSize),
+ m_blockSize(blockSize)
+{
+
+ // Get system's page size value.
+ SYMBIAN_PAGESIZE(m_pageSize);
+
+ // We only accept multiples of system page size for both initial reservation and the alignment/block size
+ m_reservation = SYMBIAN_ROUNDUPTOMULTIPLE(m_reservation, m_pageSize);
+ __ASSERT_ALWAYS(SYMBIAN_ROUNDUPTOMULTIPLE(m_blockSize, m_pageSize), User::Panic(_L("AlignedBlockAllocator1"), KErrArgument));
+
+ // Calculate max. bit flags we need to carve a reservationSize range into blockSize-sized blocks
+ m_map.numBits = m_reservation / m_blockSize;
+ const TUint32 bitsPerWord = 8*sizeof(TUint32);
+ const TUint32 numWords = (m_map.numBits + bitsPerWord -1) / bitsPerWord;
+
+ m_map.bits = new TUint32[numWords];
+ __ASSERT_ALWAYS(m_map.bits, User::Panic(_L("AlignedBlockAllocator2"), KErrNoMemory));
+ m_map.clearAll();
+
+ // Open a Symbian RChunk, and reserve requested virtual address range
+ // Any thread in this process can operate this rchunk due to EOwnerProcess access rights.
+ TInt ret = m_chunk.CreateDisconnectedLocal(0 , 0, (TInt)m_reservation , EOwnerProcess);
+ if (ret != KErrNone)
+ User::Panic(_L("AlignedBlockAllocator3"), ret);
+
+ // This is the offset to m_chunk.Base() required to make it m_blockSize-aligned
+ m_offset = SYMBIAN_ROUNDUPTOMULTIPLE(TUint32(m_chunk.Base()), m_blockSize) - TUint(m_chunk.Base());
+
+}
+
+void* AlignedBlockAllocator::alloc()
+{
+
+ TInt freeRam = 0;
+ void* address = 0;
+
+ // Look up first free slot in bit map
+ const TInt freeIdx = m_map.findFree();
+
+ // Pseudo OOM: We ate up the address space we reserved..
+ // ..even though the device may have free RAM left
+ if (freeIdx < 0)
+ return 0;
+
+ TInt ret = m_chunk.Commit(m_offset + (m_blockSize * freeIdx), m_blockSize);
+ if (ret != KErrNone)
+ return 0; // True OOM: Device didn't have physical RAM to spare
+
+ // Updated bit to mark region as in use.
+ m_map.set(freeIdx);
+
+ // Calculate address of committed region (block)
+ address = (void*)( (m_chunk.Base() + m_offset) + (TUint)(m_blockSize * freeIdx) );
+
+ return address;
+}
+
+void AlignedBlockAllocator::free(void* block)
+{
+ // Calculate index of block to be freed
+ TInt idx = TUint(static_cast<TUint8*>(block) - m_chunk.Base() - m_offset) / m_blockSize;
+
+ __ASSERT_DEBUG(idx >= 0 && idx < m_map.numBits, User::Panic(_L("AlignedBlockAllocator4"), KErrCorrupt)); // valid index check
+ __ASSERT_DEBUG(m_map.get(idx), User::Panic(_L("AlignedBlockAllocator5"), KErrCorrupt)); // in-use flag check
+
+ // Return committed region to system RAM pool (the physical RAM becomes usable by others)
+ TInt ret = m_chunk.Decommit(m_offset + m_blockSize * idx, m_blockSize);
+
+ // mark this available again
+ m_map.clear(idx);
+}
+
+void AlignedBlockAllocator::destroy()
+{
+ // release everything!
+ m_chunk.Decommit(0, m_chunk.MaxSize());
+ m_map.clearAll();
+}
+
+AlignedBlockAllocator::~AlignedBlockAllocator()
+{
+ destroy();
+ m_chunk.Close();
+ delete [] m_map.bits;
+}
+
+} // end of namespace
+
+#endif // SYMBIAN
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h
new file mode 100644
index 0000000..21422f6
--- /dev/null
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BlockAllocatorSymbian_h
+#define BlockAllocatorSymbian_h
+
+#include <e32cmn.h>
+#include <e32std.h>
+#include <hal.h>
+
+
+#define SYMBIAN_PAGESIZE(x) (HAL::Get(HALData::EMemoryPageSize, x));
+#define SYMBIAN_FREERAM(x) (HAL::Get(HALData::EMemoryRAMFree, x));
+#define SYMBIAN_ROUNDUPTOMULTIPLE(x, multipleof) ( (x + multipleof - 1) & ~(multipleof - 1) )
+
+// Set sane defaults if -D<flagname=value> wasn't provided via compiler args
+#ifndef JSCCOLLECTOR_VIRTUALMEM_RESERVATION
+#if defined(__WINS__)
+ // Emulator has limited virtual address space
+ #define JSCCOLLECTOR_VIRTUALMEM_RESERVATION (4*1024*1024)
+#else
+ // HW has plenty of virtual addresses
+ #define JSCCOLLECTOR_VIRTUALMEM_RESERVATION (128*1024*1024)
+#endif
+#endif
+
+namespace WTF {
+
+/**
+ * Allocates contiguous region of size blockSize with blockSize-aligned address.
+ * blockSize must be a multiple of system page size (typically 4K on Symbian/ARM)
+ *
+ * @param reservationSize Virtual address range to be reserved upon creation of chunk (bytes).
+ * @param blockSize Size of a single allocation. Returned address will also be blockSize-aligned.
+ */
+class AlignedBlockAllocator {
+ public:
+ AlignedBlockAllocator(TUint32 reservationSize, TUint32 blockSize);
+ ~AlignedBlockAllocator();
+ void destroy();
+ void* alloc();
+ void free(void* data);
+
+ private:
+ RChunk m_chunk; // Symbian chunk that lets us reserve/commit/decommit
+ TUint m_offset; // offset of first committed region from base
+ TInt m_pageSize; // cached value of system page size, typically 4K on Symbian
+ TUint32 m_reservation;
+ TUint32 m_blockSize;
+
+ // Tracks comitted/decommitted state of a blockSize region
+ struct {
+
+ TUint32 *bits; // array of bit flags
+ TUint32 numBits; // number of regions to keep track of
+
+ bool get(TUint32 n) const
+ {
+ return !!(bits[n >> 5] & (1 << (n & 0x1F)));
+ }
+
+ void set(TUint32 n)
+ {
+ bits[n >> 5] |= (1 << (n & 0x1F));
+ }
+
+ void clear(TUint32 n)
+ {
+ bits[n >> 5] &= ~(1 << (n & 0x1F));
+ }
+
+ void clearAll()
+ {
+ for (TUint32 i = 0; i < numBits; i++)
+ clear(i);
+ }
+
+ TInt findFree() const
+ {
+ for (TUint32 i = 0; i < numBits; i++) {
+ if (!get(i))
+ return i;
+ }
+ return -1;
+ }
+
+ } m_map;
+
+};
+
+}
+
+#endif // end of BlockAllocatorSymbian_h
+
+
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/RegisterFileAllocatorSymbian.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/RegisterFileAllocatorSymbian.cpp
index da5cc99..e89dd7a 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/RegisterFileAllocatorSymbian.cpp
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/RegisterFileAllocatorSymbian.cpp
@@ -83,10 +83,16 @@ void RegisterFileAllocator::grow(void* newEnd)
TInt nBytes = (TInt)(newEnd) - (TInt)(m_comEnd);
nBytes = SYMBIAN_ROUNDUPTOMULTIPLE(nBytes, m_poolSize);
TInt offset = (TInt)m_comEnd - (TInt)m_buffer;
+ // The reserved size is not guaranteed to be a multiple of the pool size.
+ TInt maxBytes = (TInt)m_resEnd - (TInt)m_comEnd;
+ if (nBytes > maxBytes)
+ nBytes = maxBytes;
TInt ret = m_chunk.Commit(offset, nBytes);
if (ret == KErrNone)
m_comEnd = (void*)(m_chunk.Base() + m_chunk.Size());
+ else
+ CRASH();
}
}
diff --git a/src/3rdparty/javascriptcore/VERSION b/src/3rdparty/javascriptcore/VERSION
index 9991ac0..13943b2 100644
--- a/src/3rdparty/javascriptcore/VERSION
+++ b/src/3rdparty/javascriptcore/VERSION
@@ -4,8 +4,8 @@ This is a snapshot of JavaScriptCore from
The commit imported was from the
- javascriptcore-snapshot-05102010 branch/tag
+ javascriptcore-snapshot-27012011 branch/tag
and has the sha1 checksum
- 82ead85cfea5859044eeb25b33314dcc0fa5eea1
+ 3ab0f621048fbeb480b687a28ed31d92d8506150
diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h
index 70adcf6..517a334 100644
--- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h
+++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h
@@ -124,7 +124,7 @@ private:
#define PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(Effect) \
\
-void Effect##::createEffect(AudioPlayer::NativePlayer *player) \
+void Effect::createEffect(AudioPlayer::NativePlayer *player) \
{ \
C##Effect *ptr = 0; \
QT_TRAP_THROWING(ptr = C##Effect::NewL(*player)); \
diff --git a/src/3rdparty/phonon/phonon/factory.cpp b/src/3rdparty/phonon/phonon/factory.cpp
index 2785dff..b5e565b 100644
--- a/src/3rdparty/phonon/phonon/factory.cpp
+++ b/src/3rdparty/phonon/phonon/factory.cpp
@@ -137,21 +137,15 @@ bool FactoryPrivate::createBackend()
QStringList plugins(dir.entryList(QDir::Files));
#ifdef Q_OS_SYMBIAN
- /* On Symbian OS we might have two plugins, one which uses Symbian
- * MMF framework("mmf"), and one which uses Real Networks's
- * Helix("hxphonon"). We prefer the latter because it's more
- * sophisticated, so we make sure the Helix backend is attempted
- * to be loaded first, and the MMF backend is used for backup. */
- {
- const int helix = plugins.indexOf(QLatin1String("hxphonon"));
- if (helix != -1)
- plugins.move(helix, 0);
- }
+ static const QString preferredPluginName = QLatin1String("phonon_mmf");
+ const int preferredPluginIndex = plugins.indexOf(preferredPluginName + ".qtplugin");
+ if (preferredPluginIndex != -1)
+ plugins.move(preferredPluginIndex, 0);
#endif
const QStringList files = dir.entryList(QDir::Files);
- for (int i = 0; i < files.count(); ++i) {
- QPluginLoader pluginLoader(libPath + files.at(i));
+ for (int i = 0; i < plugins.count(); ++i) {
+ QPluginLoader pluginLoader(libPath + plugins.at(i));
if (!pluginLoader.load()) {
pDebug() << Q_FUNC_INFO << " load failed:"
<< pluginLoader.errorString();
diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro
index e82ec4c..2de6961 100644
--- a/src/3rdparty/webkit/WebCore/WebCore.pro
+++ b/src/3rdparty/webkit/WebCore/WebCore.pro
@@ -15,7 +15,7 @@ symbian: {
webkitlibs.path = /sys/bin
vendorinfo = \
"; Localised Vendor name" \
- "%{\"Nokia, Qt\"}" \
+ "%{\"Nokia\"}" \
" " \
"; Unique Vendor name" \
":\"Nokia, Qt\"" \
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h
index 63d9e55..2c0bf6d 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h
@@ -22,9 +22,9 @@
#include <QtCore/qglobal.h>
-#define QTWEBKIT_VERSION_STR "2.0.1"
+#define QTWEBKIT_VERSION_STR "2.0.2"
// QTWEBKIT_VERSION is (major << 16) + (minor << 8) + patch. Similar to Qt.
-#define QTWEBKIT_VERSION 0x020001
+#define QTWEBKIT_VERSION 0x020002
// Use: #if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 0, 0)). Similar to Qt.
#define QTWEBKIT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp
index 7a8aae7..4238d33 100644
--- a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp
@@ -742,11 +742,11 @@ QWebPage* QDeclarativeWebView::page() const
See QWebSettings for details of these properties.
\qml
- WebView {
- settings.pluginsEnabled: true
- settings.standardFontFamily: "Arial"
- ...
- }
+ WebView {
+ settings.pluginsEnabled: true
+ settings.standardFontFamily: "Arial"
+ // ...
+ }
\endqml
*/
QDeclarativeWebSettings* QDeclarativeWebView::settingsObject() const
diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc
index c2a38fd..d8ca5f9 100644
--- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc
+++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc
@@ -415,7 +415,7 @@
\section2 Internet Security
- When exposing native object to an open web environment, it is importwhichant to understand the security
+ When exposing native object to an open web environment, it is important to understand the security
implications. Think whether the exposed object enables the web environment access to things that
shouldn't be open, and whether the web content loaded by that web page comes from a trusted. In general, when
exposing native QObjects that give the web environment access to private information or to functionality
diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc
index 0335d46..2be8e5e 100644
--- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc
+++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc
@@ -103,8 +103,8 @@
The following locations are searched for plugins:
\table
- \header \o Linux/Unix (X11) \o Windows
- \row \o{1,3}
+ \header \o Linux/Unix (X11)
+ \row \o
\list
\o \c{.mozilla/plugins} in the user's home directory
\o \c{.netscape/plugins} in the user's home directory
@@ -134,19 +134,20 @@
\o \c{$QTWEBKIT_PLUGIN_PATH}
\endlist
\endlist
+ \endtable
- \o
+ \table
+ \header \o Windows
+ \row \o
\list
\o The user's \c{Application Data\Mozilla\plugins} directory
\o Standard system locations of plugins for Quicktime, Flash, etc.
\endlist
+ \endtable
- \row
- \raw HTML
- <th class="qt-style">Mac OS X</th>
- \endraw
- \row
- \o
+ \table
+ \header \o Mac OS X
+ \row \o
\list
\o \c{Library/Internet Plug-Ins} in the user's home directory
\o The system \c{/Library/Internet Plug-Ins} directory
diff --git a/src/3rdparty/zlib/zlib.h b/src/3rdparty/zlib/zlib.h
index 9e5b467..bdb9a3d 100644
--- a/src/3rdparty/zlib/zlib.h
+++ b/src/3rdparty/zlib/zlib.h
@@ -1171,7 +1171,7 @@ ZEXTERN int Q_ZEXPORT gzgetc OF((gzFile file));
or -1 in case of end of file or error.
*/
-ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
+ZEXTERN int Q_ZEXPORT gzungetc OF((int c, gzFile file));
/*
Push one character back onto the stream to be read again later.
Only one character of push-back is allowed. gzungetc() returns the
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 7c16f7e..2d5cfab 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -404,6 +404,8 @@ void QUnifiedTimer::installAnimationDriver(QAnimationDriver *d)
The default animation system is driven by a timer that fires at regular intervals.
In some scenarios, it is better to drive the animation based on other synchronization
mechanisms, such as the vertical refresh rate of the screen.
+
+ \internal
*/
QAnimationDriver::QAnimationDriver(QObject *parent)
@@ -420,6 +422,8 @@ QAnimationDriver::QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent)
/*!
Advances the animation based on the current time. This function should
be continuously called by the driver while the animation is running.
+
+ \internal
*/
void QAnimationDriver::advance()
{
@@ -434,6 +438,8 @@ void QAnimationDriver::advance()
/*!
Installs this animation driver. The animation driver is thread local and
will only apply for the thread its installed in.
+
+ \internal
*/
void QAnimationDriver::install()
{
@@ -471,6 +477,8 @@ void QAnimationDriver::stop()
This function is called by the animation framework to notify the driver
that it should start running.
+
+ \internal
*/
/*!
@@ -478,6 +486,8 @@ void QAnimationDriver::stop()
This function is called by the animation framework to notify the driver
that it should stop running.
+
+ \internal
*/
/*!
@@ -491,6 +501,7 @@ QDefaultAnimationDriver::QDefaultAnimationDriver(QUnifiedTimer *timer)
void QDefaultAnimationDriver::timerEvent(QTimerEvent *e)
{
Q_ASSERT(e->timerId() == m_timer.timerId());
+ Q_UNUSED(e); // if the assertions are disabled
advance();
}
diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h
index 957b9d5..0900870 100644
--- a/src/corelib/animation/qabstractanimation.h
+++ b/src/corelib/animation/qabstractanimation.h
@@ -140,7 +140,7 @@ class Q_CORE_EXPORT QAnimationDriver : public QObject
Q_DECLARE_PRIVATE(QAnimationDriver)
public:
- QAnimationDriver(QObject *parent);
+ QAnimationDriver(QObject *parent = 0);
void advance();
void install();
@@ -148,8 +148,8 @@ public:
bool isRunning() const;
protected:
- virtual void started() = 0;
- virtual void stopped() = 0;
+ virtual void started() {};
+ virtual void stopped() {};
QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent = 0);
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp
index 212e85d..c76cb89 100644
--- a/src/corelib/animation/qvariantanimation.cpp
+++ b/src/corelib/animation/qvariantanimation.cpp
@@ -431,12 +431,17 @@ void QVariantAnimation::registerInterpolator(QVariantAnimation::Interpolator fun
{
// will override any existing interpolators
QInterpolatorVector *interpolators = registeredInterpolators();
+ // When built on solaris with GCC, the destructors can be called
+ // in such an order that we get here with interpolators == NULL,
+ // to continue causes the app to crash on exit with a SEGV
+ if (interpolators) {
#ifndef QT_NO_THREAD
- QMutexLocker locker(QMutexPool::globalInstanceGet(interpolators));
+ QMutexLocker locker(QMutexPool::globalInstanceGet(interpolators));
#endif
- if (int(interpolationType) >= interpolators->count())
- interpolators->resize(int(interpolationType) + 1);
- interpolators->replace(interpolationType, func);
+ if (int(interpolationType) >= interpolators->count())
+ interpolators->resize(int(interpolationType) + 1);
+ interpolators->replace(interpolationType, func);
+ }
}
diff --git a/src/corelib/arch/arch.pri b/src/corelib/arch/arch.pri
index 971069f..cd23e5e 100644
--- a/src/corelib/arch/arch.pri
+++ b/src/corelib/arch/arch.pri
@@ -12,6 +12,8 @@ symbian:HEADERS += arch/qatomic_symbian.h \
vxworks:HEADERS += arch/qatomic_vxworks.h
+integrity:HEADERS += arch/qatomic_integrity.h
+
!wince*:!win32:!mac:!symbian:HEADERS += arch/qatomic_alpha.h \
arch/qatomic_avr32.h \
arch/qatomic_ia64.h \
diff --git a/src/corelib/arch/integrity/arch.pri b/src/corelib/arch/integrity/arch.pri
new file mode 100644
index 0000000..2c4196e
--- /dev/null
+++ b/src/corelib/arch/integrity/arch.pri
@@ -0,0 +1,3 @@
+#
+# INTEGRITY RTOS architecture
+#
diff --git a/src/corelib/arch/qatomic_arch.h b/src/corelib/arch/qatomic_arch.h
index f32aec7..3da833a 100644
--- a/src/corelib/arch/qatomic_arch.h
+++ b/src/corelib/arch/qatomic_arch.h
@@ -46,7 +46,9 @@ QT_BEGIN_HEADER
#include "QtCore/qglobal.h"
-#if defined(QT_ARCH_VXWORKS)
+#if defined(QT_ARCH_INTEGRITY)
+# include "QtCore/qatomic_integrity.h"
+#elif defined(QT_ARCH_VXWORKS)
# include "QtCore/qatomic_vxworks.h"
#elif defined(QT_ARCH_ALPHA)
# include "QtCore/qatomic_alpha.h"
diff --git a/src/corelib/arch/qatomic_armv5.h b/src/corelib/arch/qatomic_armv5.h
index f0f2f9a..820be7b 100644
--- a/src/corelib/arch/qatomic_armv5.h
+++ b/src/corelib/arch/qatomic_armv5.h
@@ -107,7 +107,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree()
// kernel places a restartable cmpxchg implementation at a fixed address
extern "C" typedef int (qt_atomic_eabi_cmpxchg_int_t)(int oldval, int newval, volatile int *ptr);
-extern "C" typedef int (qt_atomic_eabi_cmpxchg_ptr_t)(const void *oldval, void *newval, volatile void *ptr);
+extern "C" typedef int (qt_atomic_eabi_cmpxchg_ptr_t)(const void *oldval, const void *newval, volatile void *ptr);
#define qt_atomic_eabi_cmpxchg_int (*reinterpret_cast<qt_atomic_eabi_cmpxchg_int_t *>(0xffff0fc0))
#define qt_atomic_eabi_cmpxchg_ptr (*reinterpret_cast<qt_atomic_eabi_cmpxchg_ptr_t *>(0xffff0fc0))
diff --git a/src/corelib/arch/qatomic_integrity.h b/src/corelib/arch/qatomic_integrity.h
new file mode 100644
index 0000000..6563903
--- /dev/null
+++ b/src/corelib/arch/qatomic_integrity.h
@@ -0,0 +1,289 @@
+/****************************************************************************
+**
+** 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 QATOMIC_INTEGRITY_H
+#define QATOMIC_INTEGRITY_H
+
+#include <INTEGRITY.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+#define qt_i2addr(a) reinterpret_cast<Address *>(const_cast<int *>(a))
+#define qt_p2addr(a) reinterpret_cast<Address *>(const_cast<void *>(a))
+#define qt_addr(a) reinterpret_cast<Address>(a)
+
+
+#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_NOT_NATIVE
+
+inline bool QBasicAtomicInt::isReferenceCountingNative()
+{ return false; }
+inline bool QBasicAtomicInt::isReferenceCountingWaitFree()
+{ return false; }
+
+#define Q_ATOMIC_INT_TEST_AND_SET_IS_NOT_NATIVE
+
+inline bool QBasicAtomicInt::isTestAndSetNative()
+{ return true; }
+inline bool QBasicAtomicInt::isTestAndSetWaitFree()
+{ return true; }
+
+#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_NOT_NATIVE
+
+inline bool QBasicAtomicInt::isFetchAndStoreNative()
+{ return true; }
+inline bool QBasicAtomicInt::isFetchAndStoreWaitFree()
+{ return true; }
+
+#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_NOT_NATIVE
+
+inline bool QBasicAtomicInt::isFetchAndAddNative()
+{ return true; }
+inline bool QBasicAtomicInt::isFetchAndAddWaitFree()
+{ return true; }
+
+#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_NOT_NATIVE
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetNative()
+{ return true; }
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetWaitFree()
+{ return true; }
+
+#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_NOT_NATIVE
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndStoreNative()
+{ return true; }
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndStoreWaitFree()
+{ return true; }
+
+#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_NOT_NATIVE
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddNative()
+{ return true; }
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree()
+{ return true; }
+
+// Reference counting
+
+inline bool QBasicAtomicInt::ref()
+{
+ int oldval;
+ AtomicModify(qt_i2addr(&_q_value), qt_i2addr(&oldval), 0, 1);
+ return _q_value != -1;
+}
+
+inline bool QBasicAtomicInt::deref()
+{
+ int oldval;
+ AtomicModify(qt_i2addr(&_q_value), qt_i2addr(&oldval), 0, -1U);
+ return _q_value != 0;
+}
+
+// Test and set for integers
+
+inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
+{
+ return TestAndSet(qt_i2addr(&_q_value), expectedValue, newValue) == Success;
+}
+
+inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+// Fetch and store for integers
+
+inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
+{
+ int old_val;
+ do {
+ old_val = _q_value;
+ } while (TestAndSet(qt_i2addr(&_q_value), old_val, newValue) != Success);
+ return old_val;
+}
+
+inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+// Fetch and add for integers
+
+inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
+{
+ int old_val;
+ do {
+ old_val = _q_value;
+ } while (TestAndSet(qt_i2addr(&_q_value), old_val, old_val + valueToAdd) != Success);
+ return old_val;
+}
+
+inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+// Test and set for pointers
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
+{
+ return TestAndSet((Address*)&_q_value, qt_addr(expectedValue), qt_addr(newValue)) == Success;
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+// Fetch and store for pointers
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
+{
+ Address old_val;
+ do {
+ old_val = *reinterpret_cast<Address *>(const_cast<T *>(newValue));
+ } while (TestAndSet(reinterpret_cast<Address *>(const_cast<T **>(&_q_value)), old_val, qt_addr(newValue)) != Success);
+ return reinterpret_cast<T *>(old_val);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+// Fetch and add for pointers
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
+{
+ AtomicModify(qt_p2addr(&_q_value), qt_addr(_q_value), qt_addr(_q_value) + valueToAdd * sizeof(T));
+ return _q_value;
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QATOMIC_INTEGRITY_H
+
diff --git a/src/corelib/arch/symbian/qt_hybridheap_symbian_p.h b/src/corelib/arch/symbian/qt_hybridheap_symbian_p.h
index 4eff0f3..d1ce705 100644
--- a/src/corelib/arch/symbian/qt_hybridheap_symbian_p.h
+++ b/src/corelib/arch/symbian/qt_hybridheap_symbian_p.h
@@ -43,8 +43,9 @@
#define QT_HYBRIDHEAP_SYMBIAN_H
#include <qglobal.h>
+#include <e32cmn.h>
-#if !defined(SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS) && !defined(__WINS__)
+#if !defined(__SYMBIAN_KERNEL_HYBRID_HEAP__) && !defined(__WINS__)
//Enable the (backported) new allocator. When it is available in OS,
//this flag should be disabled for that OS version onward
#define QT_USE_NEW_SYMBIAN_ALLOCATOR
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 93ed5ed..3c3d39e 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -64,7 +64,7 @@
#ifndef QT_NO_CODECS
# include "qtsciicodec_p.h"
# include "qisciicodec_p.h"
-#ifndef Q_OS_SYMBIAN
+#if !defined(Q_OS_SYMBIAN) && !defined(Q_OS_INTEGRITY)
# if defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
// no iconv(3) support, must build all codecs into the library
# include "../../plugins/codecs/cn/qgb18030codec.h"
@@ -772,7 +772,7 @@ static void setup()
# endif // Q_WS_X11
-#ifndef Q_OS_SYMBIAN
+#if !defined(Q_OS_SYMBIAN) && !defined(Q_OS_INTEGRITY)
# if defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
// no asian codecs when bootstrapping, sorry
(void)new QGb18030Codec;
@@ -805,7 +805,7 @@ static void setup()
(void)new QLatin1Codec;
(void)new QUtf8Codec;
-#ifndef Q_OS_SYMBIAN
+#if !defined(Q_OS_SYMBIAN) && !defined(Q_OS_INTEGRITY)
#if defined(Q_OS_UNIX) && !defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
// QIconvCodec depends on the UTF-16 codec, so it needs to be created last
(void) new QIconvCodec();
diff --git a/src/corelib/concurrent/qfutureinterface.cpp b/src/corelib/concurrent/qfutureinterface.cpp
index 6256944..627d0c7 100644
--- a/src/corelib/concurrent/qfutureinterface.cpp
+++ b/src/corelib/concurrent/qfutureinterface.cpp
@@ -421,9 +421,11 @@ bool QFutureInterfaceBase::referenceCountIsOne() const
QFutureInterfaceBasePrivate::QFutureInterfaceBasePrivate(QFutureInterfaceBase::State initialState)
: refCount(1), m_progressValue(0), m_progressMinimum(0), m_progressMaximum(0),
- state(initialState), progressTimeStarted(false), pendingResults(0),
+ state(initialState), pendingResults(0),
manualProgress(false), m_expectedResultCount(0), runnable(0)
-{ }
+{
+ progressTime.invalidate();
+}
int QFutureInterfaceBasePrivate::internal_resultCount() const
{
@@ -455,12 +457,11 @@ bool QFutureInterfaceBasePrivate::internal_updateProgress(int progress,
m_progressValue = progress;
m_progressText = progressText;
- if (progressTimeStarted == true && m_progressValue != m_progressMaximum) // make sure the first and last steps are emitted.
+ if (progressTime.isValid() && m_progressValue != m_progressMaximum) // make sure the first and last steps are emitted.
if (progressTime.elapsed() < (1000 / MaxProgressEmitsPerSecond))
return false;
progressTime.start();
- progressTimeStarted = true;
return true;
}
diff --git a/src/corelib/concurrent/qfutureinterface_p.h b/src/corelib/concurrent/qfutureinterface_p.h
index 7f93c75..538947e 100644
--- a/src/corelib/concurrent/qfutureinterface_p.h
+++ b/src/corelib/concurrent/qfutureinterface_p.h
@@ -53,7 +53,7 @@
// We mean it.
//
-#include <QtCore/qdatetime.h>
+#include <QtCore/qelapsedtimer.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qlist.h>
#include <QtCore/qwaitcondition.h>
@@ -137,8 +137,7 @@ public:
int m_progressMinimum;
int m_progressMaximum;
QFutureInterfaceBase::State state;
- QTime progressTime;
- bool progressTimeStarted;
+ QElapsedTimer progressTime;
QWaitCondition pausedWaitCondition;
int pendingResults;
QtConcurrent::ResultStoreBase m_results;
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index e946d5d..f03550d 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -40,7 +40,10 @@ contains(DEFINES,QT_EVAL):include(eval.pri)
symbian: {
TARGET.UID3=0x2001B2DC
- # Workaroud for problems with paging this dll
- MMP_RULES -= PAGED
- MMP_RULES *= UNPAGED
+ # Problems using data exports from this DLL mean that we can't page it on releases that don't support
+ # data exports (currently that's any release before Symbian^3)
+ pagingBlock = "$${LITERAL_HASH}ifndef SYMBIAN_DLL_DATA_EXPORTS_SUPPORTED" \
+ "UNPAGED" \
+ "$${LITERAL_HASH}endif"
+ MMP_RULES += pagingBlock
}
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index 8eae391..83caa96 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -23,7 +23,7 @@ INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global
# Only used on platforms with CONFIG += precompile_header
PRECOMPILED_HEADER = global/qt_pch.h
-linux*:!static:!symbian-armcc:!symbian-gcce {
+linux*:!static:!symbian-gcce:!*-armcc* {
QMAKE_LFLAGS += -Wl,-e,qt_core_boilerplate
prog=$$quote(if (/program interpreter: (.*)]/) { print $1; })
DEFINES += ELF_INTERPRETER=\\\"$$system(readelf -l /bin/ls | perl -n -e \'$$prog\')\\\"
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index fb39ee5..134ef2f 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1738,7 +1738,7 @@ QSysInfo::WinVersion QSysInfo::windowsVersion()
if (winver)
return winver;
winver = QSysInfo::WV_NT;
- OSVERSIONINFOW osver;
+ OSVERSIONINFO osver;
osver.dwOSVersionInfoSize = sizeof(osver);
GetVersionEx(&osver);
#ifdef Q_OS_WINCE
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 2a41b9e..1879537 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -369,7 +369,20 @@ namespace QT_NAMESPACE {}
*/
#if defined(__ghs)
-# define Q_OUTOFLINE_TEMPLATE inline
+# define Q_OUTOFLINE_TEMPLATE inline
+
+/* the following are necessary because the GHS C++ name mangling relies on __*/
+# define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \
+ static const int AFUNC ## _init_variable_ = AFUNC();
+# define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC)
+# define Q_DESTRUCTOR_FUNCTION0(AFUNC) \
+ class AFUNC ## _dest_class_ { \
+ public: \
+ inline AFUNC ## _dest_class_() { } \
+ inline ~ AFUNC ## _dest_class_() { AFUNC(); } \
+ } AFUNC ## _dest_instance_;
+# define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC)
+
#endif
/* Symantec C++ is now Digital Mars */
@@ -448,6 +461,9 @@ namespace QT_NAMESPACE {}
# if __TARGET_ARCH_ARM >= 6
# define QT_HAVE_ARMV6
# endif
+/* work-around for missing compiler intrinsics */
+# define __is_empty(X) false
+# define __is_pod(X) false
#elif defined(__GNUC__)
# define Q_CC_GNU
# define Q_C_CALLBACKS
@@ -457,7 +473,6 @@ namespace QT_NAMESPACE {}
# if defined(__INTEL_COMPILER)
/* Intel C++ also masquerades as GCC 3.2.0 */
# define Q_CC_INTEL
-# define Q_NO_TEMPLATE_FRIENDS
# endif
# if defined(__clang__)
/* Clang also masquerades as GCC 4.2.1 */
@@ -760,6 +775,24 @@ namespace QT_NAMESPACE {}
# error "Qt has not been tested with this compiler - talk to qt-bugs@trolltech.com"
#endif
+#ifdef Q_CC_INTEL
+# if __INTEL_COMPILER < 1200
+# define Q_NO_TEMPLATE_FRIENDS
+# endif
+# if defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(__GXX_EXPERIMENTAL_CPP0X__)
+# if __INTEL_COMPILER >= 1100
+# define Q_COMPILER_RVALUE_REFS
+# define Q_COMPILER_EXTERN_TEMPLATES
+# elif __INTEL_COMPILER >= 1200
+# define Q_COMPILER_VARIADIC_TEMPLATES
+# define Q_COMPILER_AUTO_TYPE
+# define Q_COMPILER_DEFAULT_DELETE_MEMBERS
+# define Q_COMPILER_CLASS_ENUM
+# define Q_COMPILER_LAMBDA
+# endif
+# endif
+#endif
+
#ifndef Q_PACKED
# define Q_PACKED
# undef Q_NO_PACKED_REFERENCE
@@ -1199,6 +1232,11 @@ class QDataStream;
#define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE))
+#if defined(Q_OS_LINUX) && defined(Q_CC_RVCT)
+# define Q_DECL_EXPORT __attribute__((visibility("default")))
+# define Q_DECL_IMPORT __attribute__((visibility("default")))
+#endif
+
#ifndef Q_DECL_EXPORT
# if defined(Q_OS_WIN) || defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT)
# define Q_DECL_EXPORT __declspec(dllexport)
@@ -1420,7 +1458,7 @@ class QDataStream;
# define Q_AUTOTEST_EXPORT
#endif
-inline void qt_noop() {}
+inline void qt_noop(void) {}
/* These wrap try/catch so we can switch off exceptions later.
@@ -2461,9 +2499,14 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();
# define QT_SYMBIAN_SUPPORTS_SGIMAGE
#endif
-#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+#ifdef SYMBIAN_GRAPHICS_SET_SURFACE_TRANSPARENCY_AVAILABLE
# define Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE
#endif
+
+#ifdef SYMBIAN_GRAPHICS_TRANSITION_EFFECTS_SIGNALING_AVAILABLE
+# define Q_SYMBIAN_TRANSITION_EFFECTS
+#endif
+
#endif
//Symbian does not support data imports from a DLL
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 7a6ab36..d84da0d 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -511,9 +511,16 @@ public:
#if 0 // these values are reserved for Maemo5 - do not re-use them
WA_Maemo5NonComposited = 126,
WA_Maemo5StackedWindow = 127,
- WA_Maemo5PortraitOrientation = 128,
- WA_Maemo5LandscapeOrientation = 129,
- WA_Maemo5AutoOrientation = 130,
+#endif
+
+ WA_LockPortraitOrientation = 128,
+ WA_LockLandscapeOrientation = 129,
+ WA_AutoOrientation = 130,
+
+#if 0 // these values are reserved for Maemo5 - do not re-use them
+ WA_Maemo5PortraitOrientation = WA_LockPortraitOrientation,
+ WA_Maemo5LandscapeOrientation = WA_LockLandscapeOrientation,
+ WA_Maemo5AutoOrientation = WA_AutoOrientation,
WA_Maemo5ShowProgressIndicator = 131,
#endif
@@ -536,7 +543,8 @@ public:
AA_DontUseNativeMenuBar = 6,
AA_MacDontSwapCtrlAndMeta = 7,
AA_S60DontConstructApplicationPanes = 8,
- AA_X11InitThreads = 9,
+ AA_S60DisablePartialScreenInputMode = 9,
+ AA_X11InitThreads = 10,
// Add new attributes before this line
AA_AttributeCount
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 9facad7..cbdf9d1 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -156,11 +156,17 @@
whole lifetime. This attribute must be set before QApplication is
constructed.
+ \omitvalue AA_S60DisablePartialScreenInputMode By default in Symbian^3,
+ a separate editing window is opened on top of an application. This is exactly
+ like editing on previous versions of Symbian behave. When this attribute
+ is true, a virtual keyboard window is shown on top of application and it
+ is ensured that the focused text widget is visible. This is only supported in
+ Symbian^3. (internal)
+
\value AA_X11InitThreads Calls XInitThreads() as part of the QApplication
construction in order to make Xlib calls thread-safe. This
attribute must be set before QApplication is constructed.
-
\omitvalue AA_AttributeCount
*/
@@ -1257,6 +1263,13 @@
to this top level window. This attribute has no effect on non-X11
platforms.
+ \value WA_LockPortraitOrientation Locks the widget to a portrait orientation,
+ ignoring changes to the display's orientation with respect to the user.
+ \value WA_LockLandscapeOrientation Locks the widget to a landscape orientation,
+ ignoring changes to the display's orientation with respect to the user.
+ \value WA_AutoOrientation Causes the widget to change orientation whenever the
+ display changes orientation with respect to the user.
+
\value WA_MacNoShadow Since Qt 4.8, this attribute disables drop shadows
for this top level window. Only affects Cocoa builds of Qt for Mac OS X.
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index 4d4ae21..2b61192 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -113,3 +113,7 @@ win32 {
LIBS += -lplatformenv
}
}
+integrity {
+ SOURCES += io/qfsfileengine_unix.cpp \
+ io/qfsfileengine_iterator_unix.cpp
+}
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index 9446ebb..cf19224 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -168,7 +168,7 @@ static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &ent
const QStringList &paths = QDir::searchPaths(filePath.left(prefixSeparator));
for (int i = 0; i < paths.count(); i++) {
- entry = QFileSystemEntry(paths.at(i) % QLatin1Char('/') % filePath.mid(prefixSeparator + 1));
+ entry = QFileSystemEntry(QDir::cleanPath(paths.at(i) % QLatin1Char('/') % filePath.mid(prefixSeparator + 1)));
// Recurse!
if (_q_resolveEntryAndCreateLegacyEngine_recursive(entry, data, engine, true))
return true;
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 6acd811..030be1b 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -174,8 +174,9 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
if (entry.isEmpty() || entry.isRoot())
return entry;
-#ifdef __UCLIBC__
- return QFileSystemEntry::slowCanonicalName(entry);
+#if !defined(Q_OS_MAC) && _POSIX_VERSION < 200809L
+ // realpath(X,0) is not supported
+ return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath()));
#else
char *ret = 0;
# if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
@@ -533,8 +534,7 @@ bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSyst
{
Q_UNUSED(source);
Q_UNUSED(target);
- // # we can implement this using sendfile(2)
- //when this function returns false, block copy is used in QFile which sets the error code.
+ error = QSystemError(ENOSYS, QSystemError::StandardLibraryError); //Function not implemented
return false;
}
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 62e7c9f..6c03b32 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -1029,7 +1029,11 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla
if (openMode & QIODevice::ReadOnly) access |= PROT_READ;
if (openMode & QIODevice::WriteOnly) access |= PROT_WRITE;
+#if defined(Q_OS_INTEGRITY)
+ int pageSize = sysconf(_SC_PAGESIZE);
+#else
int pageSize = getpagesize();
+#endif
int extra = offset % pageSize;
if (quint64(size + extra) > quint64((size_t)-1)) {
@@ -1079,6 +1083,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla
bool QFSFileEnginePrivate::unmap(uchar *ptr)
{
+#if !defined(Q_OS_INTEGRITY)
Q_Q(QFSFileEngine);
if (!maps.contains(ptr)) {
q->setError(QFile::PermissionsError, qt_error_string(EACCES));
@@ -1093,6 +1098,9 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr)
}
maps.remove(ptr);
return true;
+#else
+ return false;
+#endif
}
QT_END_NAMESPACE
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index b120f7f..ba61bda 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -169,27 +169,17 @@ private:
Q_GLOBAL_STATIC(QMutex, processManagerGlobalMutex)
-static QProcessManager *processManagerInstance = 0;
-
-static QProcessManager *processManager()
-{
+static QProcessManager *processManager() {
// The constructor of QProcessManager should be called only once
// so we cannot use Q_GLOBAL_STATIC directly for QProcessManager
QMutex *mutex = processManagerGlobalMutex();
QMutexLocker locker(mutex);
-
- if (!processManagerInstance)
- QProcessPrivate::initializeProcessManager();
-
- Q_ASSERT(processManagerInstance);
- return processManagerInstance;
+ static QProcessManager processManager;
+ return &processManager;
}
QProcessManager::QProcessManager()
{
- // can only be called from main thread
- Q_ASSERT(!qApp || qApp->thread() == QThread::currentThread());
-
#if defined (QPROCESS_DEBUG)
qDebug() << "QProcessManager::QProcessManager()";
#endif
@@ -208,8 +198,6 @@ QProcessManager::QProcessManager()
::sigaction(SIGCHLD, &action, &oldAction);
if (oldAction.sa_handler != qt_sa_sigchld_handler)
qt_sa_old_sigchld_handler = oldAction.sa_handler;
-
- processManagerInstance = this;
}
QProcessManager::~QProcessManager()
@@ -238,8 +226,6 @@ QProcessManager::~QProcessManager()
if (oldAction.sa_handler != qt_sa_sigchld_handler) {
::sigaction(SIGCHLD, &oldAction, 0);
}
-
- processManagerInstance = 0;
}
void QProcessManager::run()
@@ -659,7 +645,7 @@ void QProcessPrivate::startProcess()
if (childPid < 0) {
// Cleanup, report error and return
#if defined (QPROCESS_DEBUG)
- qDebug("qt_fork failed: %s", qt_error_string(lastForkErrno));
+ qDebug("qt_fork failed: %s", qPrintable(qt_error_string(lastForkErrno)));
#endif
processManager()->unlock();
q->setProcessState(QProcess::NotRunning);
@@ -863,7 +849,7 @@ qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen)
qDebug("QProcessPrivate::writeToStdin(%p \"%s\", %lld) == %lld",
data, qt_prettyDebug(data, maxlen, 16).constData(), maxlen, written);
if (written == -1)
- qDebug("QProcessPrivate::writeToStdin(), failed to write (%s)", qt_error_string(errno));
+ qDebug("QProcessPrivate::writeToStdin(), failed to write (%s)", qPrintable(qt_error_string(errno)));
#endif
// If the O_NONBLOCK flag is set and If some data can be written without blocking
// the process, write() will transfer what it can and return the number of bytes written.
@@ -1306,15 +1292,7 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
void QProcessPrivate::initializeProcessManager()
{
- if (qApp && qApp->thread() != QThread::currentThread()) {
- // The process manager must be initialized in the main thread
- // Note: The call below will re-enter this function, but in the right thread,
- // so the else statement below will be executed.
- QMetaObject::invokeMethod(qApp, "_q_initializeProcessManager", Qt::BlockingQueuedConnection);
- } else {
- static QProcessManager processManager;
- Q_UNUSED(processManager);
- }
+ (void) processManager();
}
QT_END_NAMESPACE
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 2a9d8ee..0435256 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -928,7 +928,7 @@ public:
}
};
-#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && ! defined (Q_OS_NACL)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined (Q_OS_NACL) && !defined(Q_OS_INTEGRITY)
#define QT_USE_MMAP
#endif
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 93818d1..c3a6721 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -139,3 +139,19 @@ vxworks {
kernel/qfunctions_vxworks.h
}
+
+integrity {
+ SOURCES += \
+ kernel/qcore_unix.cpp \
+ kernel/qcrashhandler.cpp \
+ kernel/qsharedmemory_unix.cpp \
+ kernel/qsystemsemaphore_unix.cpp \
+ kernel/qeventdispatcher_unix.cpp
+ HEADERS += \
+ kernel/qcore_unix_p.h \
+ kernel/qcrashhandler_p.h \
+ kernel/qeventdispatcher_unix_p.h
+
+ contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
+}
+
diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h
index 3ef71e0..5b48689 100644
--- a/src/corelib/kernel/qcore_symbian_p.h
+++ b/src/corelib/kernel/qcore_symbian_p.h
@@ -158,6 +158,22 @@ Q_CORE_EXPORT RFs& qt_s60GetRFs();
// Defined in qlocale_symbian.cpp.
Q_CORE_EXPORT QByteArray qt_symbianLocaleName(int code);
+template <typename R>
+struct QScopedPointerRCloser
+{
+ static inline void cleanup(R *rPointer)
+ {
+ // Enforce a complete type.
+ // If you get a compile error here, read the section on forward declared
+ // classes in the QScopedPointer documentation.
+ typedef char IsIncompleteType[ sizeof(R) ? 1 : -1 ];
+ (void) sizeof(IsIncompleteType);
+
+ if (rPointer)
+ rPointer->Close();
+ }
+};
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 9bd32d1..be86c58 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -392,16 +392,6 @@ void QCoreApplicationPrivate::createEventDispatcher()
#endif
}
-void QCoreApplicationPrivate::_q_initializeProcessManager()
-{
-#ifndef QT_NO_PROCESS
-# ifdef Q_OS_UNIX
- QProcessPrivate::initializeProcessManager();
-# endif
-#endif
-}
-
-
QThread *QCoreApplicationPrivate::theMainThread = 0;
QThread *QCoreApplicationPrivate::mainThread()
{
@@ -482,10 +472,10 @@ QString qAppName()
operations can call processEvents() to keep the application
responsive.
- In general, we recommend that you create a QCoreApplication or
- a QApplication object in your \c main() function as early as
- possible. exit() will not return until the event loop exits;
- e.g., when quit() is called.
+ In general, we recommend that you create a QCoreApplication or a
+ QApplication object in your \c main() function as early as
+ possible. exec() will not return until the event loop exits; e.g.,
+ when quit() is called.
Several static convenience functions are also provided. The
QCoreApplication object is available from instance(). Events can
@@ -666,6 +656,12 @@ void QCoreApplication::init()
}
#endif
+#if defined(Q_OS_UNIX) && !(defined(QT_NO_PROCESS))
+ // Make sure the process manager thread object is created in the main
+ // thread.
+ QProcessPrivate::initializeProcessManager();
+#endif
+
#ifdef QT_EVAL
extern void qt_core_eval_init(uint);
qt_core_eval_init(d->application_type);
@@ -2732,5 +2728,3 @@ int QCoreApplication::loopLevel()
*/
QT_END_NAMESPACE
-
-#include "moc_qcoreapplication.cpp"
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index 024c509..3957158 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -205,7 +205,6 @@ protected:
QCoreApplication(QCoreApplicationPrivate &p);
private:
- Q_PRIVATE_SLOT(d_func(), void _q_initializeProcessManager())
static bool sendSpontaneousEvent(QObject *receiver, QEvent *event);
bool notifyInternal(QObject *receiver, QEvent *event);
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index fdceab4..add2a35 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -85,8 +85,6 @@ public:
bool sendThroughObjectEventFilters(QObject *, QEvent *);
bool notify_helper(QObject *, QEvent *);
- void _q_initializeProcessManager();
-
virtual QString appName() const;
virtual void createEventDispatcher();
static void removePostedEvent(QEvent *);
diff --git a/src/corelib/kernel/qcrashhandler.cpp b/src/corelib/kernel/qcrashhandler.cpp
index 59f3796..fbdbac0 100644
--- a/src/corelib/kernel/qcrashhandler.cpp
+++ b/src/corelib/kernel/qcrashhandler.cpp
@@ -339,6 +339,9 @@ static void print_backtrace(FILE *outb)
"EOF\n",
globalProgName, (int)getpid()))
return;
+#elif defined(Q_OS_INTEGRITY)
+ /* abort */
+ CheckSuccess(Failure);
#else /* All other platforms */
/*
* TODO: SCO/UnixWare 7 must be something like (not tested)
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index 8872045..53796be 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -657,7 +657,7 @@ public:
: m_state(STATE_RUN), m_stop(false)
{
qt_symbian_throwIfError(m_lock.CreateLocal(0));
- TInt err = m_idleDetectorThread.Create(KNullDesC(), &idleDetectorThreadFunc, 1024, NULL, this);
+ TInt err = m_idleDetectorThread.Create(KNullDesC(), &idleDetectorThreadFunc, 1024, &User::Allocator(), this);
if (err != KErrNone)
m_lock.Close();
qt_symbian_throwIfError(err);
@@ -692,6 +692,7 @@ public:
private:
static TInt idleDetectorThreadFunc(TAny* self)
{
+ User::RenameThread(_L("IdleDetectorThread"));
static_cast<QIdleDetectorThread*>(self)->IdleLoop();
return KErrNone;
}
@@ -809,7 +810,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla
m_interrupt = false;
#ifdef QT_SYMBIAN_PRIORITY_DROP
- QTime eventTimer;
+ QElapsedTimer eventTimer;
#endif
while (1) {
diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h
index b785aea..bdb6dce 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian_p.h
+++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h
@@ -63,6 +63,7 @@
#include <qwaitcondition.h>
#include <qsocketnotifier.h>
#include <qdatetime.h>
+#include <qelapsedtimer.h>
#include <e32base.h>
@@ -284,7 +285,7 @@ private:
int m_delay;
int m_avgEventTime;
- QTime m_lastIdleRequestTimer;
+ QElapsedTimer m_lastIdleRequestTimer;
};
#ifdef QT_DEBUG
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp
index 46604b0..dceb51d 100644
--- a/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ b/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -116,7 +116,7 @@ QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate()
// do nothing.
#elif defined(Q_OS_INTEGRITY)
// INTEGRITY doesn't like a "select" on pipes, so use socketpair instead
- if (socketpair(AF_INET, SOCK_STREAM, PF_INET, thread_pipe) == -1) {
+ if (socketpair(AF_INET, SOCK_STREAM, 0, thread_pipe) == -1) {
perror("QEventDispatcherUNIXPrivate(): Unable to create socket pair");
pipefail = true;
} else {
@@ -343,7 +343,7 @@ timeval QTimerInfoList::updateCurrentTime()
return (currentTime = qt_gettime());
}
-#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)) || defined(QT_BOOTSTRAPPED)
+#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) && !defined(Q_OS_INTEGRITY)) || defined(QT_BOOTSTRAPPED)
template <>
timeval qAbs(const timeval &t)
@@ -509,7 +509,6 @@ bool QTimerInfoList::unregisterTimer(int timerId)
}
}
// id not found
- qWarning("Application asked to unregister timer 0x%x which is not registered in this thread. Fix application.", timerId);
return false;
}
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 3d8352e..6badb6a 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -532,10 +532,7 @@ LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp)
PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0);
}
} else if (d->sendPostedEventsWindowsTimerId == 0
- && localSerialNumber != d->lastSerialNumber
- // if this message IS the one that triggers sendPostedEvents(), no need to post it again
- && (msg->hwnd != d->internalHwnd
- || msg->message != WM_QT_SENDPOSTEDEVENTS)) {
+ && localSerialNumber != d->lastSerialNumber) {
// start a special timer to continue delivering posted events while
// there are still input and timer messages in the message queue
d->sendPostedEventsWindowsTimerId = SetTimer(d->internalHwnd,
diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp
index e78f86a..d213b0e 100644
--- a/src/corelib/kernel/qeventloop.cpp
+++ b/src/corelib/kernel/qeventloop.cpp
@@ -175,6 +175,8 @@ bool QEventLoop::processEvents(ProcessEventsFlags flags)
int QEventLoop::exec(ProcessEventsFlags flags)
{
Q_D(QEventLoop);
+ //we need to protect from race condition with QThread::exit
+ QMutexLocker locker(&static_cast<QThreadPrivate *>(QObjectPrivate::get(d->threadData->thread))->mutex);
if (d->threadData->quitNow)
return -1;
@@ -186,6 +188,7 @@ int QEventLoop::exec(ProcessEventsFlags flags)
d->exit = false;
++d->threadData->loopLevel;
d->threadData->eventLoops.push(this);
+ locker.unlock();
// remove posted quit events when entering a new event loop
QCoreApplication *app = QCoreApplication::instance();
@@ -205,6 +208,7 @@ int QEventLoop::exec(ProcessEventsFlags flags)
"reimplement QApplication::notify() and catch all exceptions there.\n");
// copied from below
+ locker.relock();
QEventLoop *eventLoop = d->threadData->eventLoops.pop();
Q_ASSERT_X(eventLoop == this, "QEventLoop::exec()", "internal error");
Q_UNUSED(eventLoop); // --release warning
@@ -216,6 +220,7 @@ int QEventLoop::exec(ProcessEventsFlags flags)
#endif
// copied above
+ locker.relock();
QEventLoop *eventLoop = d->threadData->eventLoops.pop();
Q_ASSERT_X(eventLoop == this, "QEventLoop::exec()", "internal error");
Q_UNUSED(eventLoop); // --release warning
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 7928f4f..c5775f6 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -1387,6 +1387,25 @@ int QMetaMethod::methodIndex() const
}
/*!
+ \internal
+
+ Returns the method revision if one was
+ specified by Q_REVISION, otherwise returns 0.
+ */
+int QMetaMethod::revision() const
+{
+ if (!mobj)
+ return 0;
+ if ((QMetaMethod::Access)(mobj->d.data[handle + 4] & MethodRevisioned)) {
+ int offset = priv(mobj->d.data)->methodData
+ + priv(mobj->d.data)->methodCount * 5
+ + (handle - priv(mobj->d.data)->methodData) / 5;
+ return mobj->d.data[offset];
+ }
+ return 0;
+}
+
+/*!
Returns the access specification of this method (private,
protected, or public).
@@ -2394,6 +2413,35 @@ int QMetaProperty::notifySignalIndex() const
}
/*!
+ \internal
+
+ Returns the property revision if one was
+ specified by REVISION, otherwise returns 0.
+ */
+int QMetaProperty::revision() const
+{
+ if (!mobj)
+ return 0;
+ int flags = mobj->d.data[handle + 2];
+ if (flags & Revisioned) {
+ int offset = priv(mobj->d.data)->propertyData +
+ priv(mobj->d.data)->propertyCount * 3 + idx;
+ // Revision data is placed after NOTIFY data, if present.
+ // Iterate through properties to discover whether we have NOTIFY signals.
+ for (int i = 0; i < priv(mobj->d.data)->propertyCount; ++i) {
+ int handle = priv(mobj->d.data)->propertyData + 3*i;
+ if (mobj->d.data[handle + 2] & Notify) {
+ offset += priv(mobj->d.data)->propertyCount;
+ break;
+ }
+ }
+ return mobj->d.data[offset];
+ } else {
+ return 0;
+ }
+}
+
+/*!
Returns true if this property is writable; otherwise returns
false.
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index 4fb353d..e9bba45 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -70,6 +70,7 @@ public:
enum Attributes { Compatibility = 0x1, Cloned = 0x2, Scriptable = 0x4 };
int attributes() const;
int methodIndex() const;
+ int revision() const;
inline const QMetaObject *enclosingMetaObject() const { return mobj; }
@@ -202,6 +203,8 @@ public:
QMetaMethod notifySignal() const;
int notifySignalIndex() const;
+ int revision() const;
+
QVariant read(const QObject *obj) const;
bool write(QObject *obj, const QVariant &value) const;
bool reset(QObject *obj) const;
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index dd0baf0..210b32c 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -78,7 +78,8 @@ enum PropertyFlags {
ResolveEditable = 0x00080000,
User = 0x00100000,
ResolveUser = 0x00200000,
- Notify = 0x00400000
+ Notify = 0x00400000,
+ Revisioned = 0x00800000
};
enum MethodFlags {
@@ -95,7 +96,8 @@ enum MethodFlags {
MethodCompatibility = 0x10,
MethodCloned = 0x20,
- MethodScriptable = 0x40
+ MethodScriptable = 0x40,
+ MethodRevisioned = 0x80
};
enum MetaObjectFlags {
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 47d3a3b..a2bb7d1 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -138,7 +138,7 @@ template <typename T>
void *qMetaTypeConstructHelper(const T *t)
{
if (!t)
- return new T;
+ return new T();
return new T(*static_cast<const T*>(t));
}
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 5a7ee2f..0ad73f5 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -370,18 +370,18 @@ template <class T>
inline T qobject_cast(QObject *object)
{
#if !defined(QT_NO_QOBJECT_CHECK)
- reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(object));
+ reinterpret_cast<T>(object)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(object));
#endif
- return static_cast<T>(reinterpret_cast<T>(0)->staticMetaObject.cast(object));
+ return static_cast<T>(reinterpret_cast<T>(object)->staticMetaObject.cast(object));
}
template <class T>
inline T qobject_cast(const QObject *object)
{
#if !defined(QT_NO_QOBJECT_CHECK)
- reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<QObject *>(object)));
+ reinterpret_cast<T>(object)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<QObject *>(object)));
#endif
- return static_cast<T>(reinterpret_cast<T>(0)->staticMetaObject.cast(object));
+ return static_cast<T>(reinterpret_cast<T>(object)->staticMetaObject.cast(object));
}
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 94e6241..54b5ab2 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -79,6 +79,7 @@ class QString;
#define Q_INTERFACES(x)
#define Q_PROPERTY(text)
#define Q_PRIVATE_PROPERTY(d, text)
+#define Q_REVISION(v)
#define Q_OVERRIDE(text)
#define Q_ENUMS(x)
#define Q_FLAGS(x)
@@ -180,6 +181,7 @@ private:
#define Q_INTERFACES(x) Q_INTERFACES(x)
#define Q_PROPERTY(text) Q_PROPERTY(text)
#define Q_PRIVATE_PROPERTY(d, text) Q_PRIVATE_PROPERTY(d, text)
+#define Q_REVISION(v) Q_REVISION(v)
#define Q_OVERRIDE(text) Q_OVERRIDE(text)
#define Q_ENUMS(x) Q_ENUMS(x)
#define Q_FLAGS(x) Q_FLAGS(x)
diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp
index b61509e..78715a1 100644
--- a/src/corelib/kernel/qsharedmemory.cpp
+++ b/src/corelib/kernel/qsharedmemory.cpp
@@ -458,11 +458,7 @@ bool QSharedMemory::detach()
return false;
#endif
- if (d->detach()) {
- d->size = 0;
- return true;
- }
- return false;
+ return d->detach();
}
/*!
diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp
index fc0a438..b30117f 100644
--- a/src/corelib/kernel/qsharedmemory_unix.cpp
+++ b/src/corelib/kernel/qsharedmemory_unix.cpp
@@ -198,7 +198,7 @@ bool QSharedMemoryPrivate::create(int size)
}
// create
- if (-1 == shmget(handle(), size, 0666 | IPC_CREAT | IPC_EXCL)) {
+ if (-1 == shmget(unix_key, size, 0666 | IPC_CREAT | IPC_EXCL)) {
QString function = QLatin1String("QSharedMemory::create");
switch (errno) {
case EINVAL:
@@ -219,10 +219,7 @@ bool QSharedMemoryPrivate::create(int size)
bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
{
// grab the shared memory segment id
- if (!handle())
- return false;
-
- int id = shmget(handle(), 0, (mode == QSharedMemory::ReadOnly ? 0444 : 0660));
+ int id = shmget(unix_key, 0, (mode == QSharedMemory::ReadOnly ? 0444 : 0660));
if (-1 == id) {
setErrorString(QLatin1String("QSharedMemory::attach (shmget)"));
return false;
@@ -264,12 +261,11 @@ bool QSharedMemoryPrivate::detach()
return false;
}
memory = 0;
+ size = 0;
// Get the number of current attachments
- if (!handle())
- return false;
- int id = shmget(handle(), 0, 0444);
- unix_key = 0;
+ int id = shmget(unix_key, 0, 0444);
+ cleanHandle();
struct shmid_ds shmid_ds;
if (0 != shmctl(id, IPC_STAT, &shmid_ds)) {
diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp
index 75ab4e8..bc13e33 100644
--- a/src/corelib/kernel/qsharedmemory_win.cpp
+++ b/src/corelib/kernel/qsharedmemory_win.cpp
@@ -123,8 +123,8 @@ bool QSharedMemoryPrivate::cleanHandle()
{
if (hand != 0 && !CloseHandle(hand)) {
hand = 0;
- return false;
setErrorString(QLatin1String("QSharedMemory::cleanHandle"));
+ return false;
}
hand = 0;
return true;
@@ -183,6 +183,7 @@ bool QSharedMemoryPrivate::detach()
return false;
}
memory = 0;
+ size = 0;
// close handle
return cleanHandle();
diff --git a/src/corelib/kernel/qsystemsemaphore_symbian.cpp b/src/corelib/kernel/qsystemsemaphore_symbian.cpp
index 07cfffc..0d257b8 100644
--- a/src/corelib/kernel/qsystemsemaphore_symbian.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_symbian.cpp
@@ -73,6 +73,7 @@ void QSystemSemaphorePrivate::setErrorString(const QString &function, int err)
case KErrInUse:
errorString = QCoreApplication::tr("%1: out of resources", "QSystemSemaphore").arg(function);
error = QSystemSemaphore::OutOfResources;
+ break;
case KErrPermissionDenied:
errorString = QCoreApplication::tr("%1: permission denied", "QSystemSemaphore").arg(function);
error = QSystemSemaphore::PermissionDenied;
@@ -97,8 +98,7 @@ int QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode)
if (key.isEmpty())
return 0;
- QString safeName = makeKeyFileName();
- TPtrC name(qt_QString2TPtrC(safeName));
+ TPtrC name(qt_QString2TPtrC(fileName));
int err = KErrAlreadyExists;
int tryCount = 10;
// Sort out race conditions by retrying several times until existing handle is acquired.
diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp
index 7f002f8..fad50f2 100644
--- a/src/corelib/kernel/qsystemsemaphore_win.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_win.cpp
@@ -86,8 +86,7 @@ HANDLE QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode)
// Create it if it doesn't already exists.
if (semaphore == 0) {
- QString safeName = makeKeyFileName();
- semaphore = CreateSemaphore(0, initialValue, MAXLONG, (wchar_t*)safeName.utf16());
+ semaphore = CreateSemaphore(0, initialValue, MAXLONG, (wchar_t*)fileName.utf16());
if (semaphore == NULL)
setErrorString(QLatin1String("QSystemSemaphore::handle"));
}
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index d72c1ab..daa5dc6 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -56,7 +56,7 @@
#include "qhash.h"
#include "qtranslator_p.h"
-#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined(Q_OS_INTEGRITY)
#define QT_USE_MMAP
#include "private/qcore_unix_p.h"
#endif
diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri
index 50b005d..eb7a7f7 100644
--- a/src/corelib/plugin/plugin.pri
+++ b/src/corelib/plugin/plugin.pri
@@ -28,4 +28,8 @@ unix {
SOURCES += plugin/qlibrary_unix.cpp
}
+integrity {
+ SOURCES += plugin/qlibrary_unix.cpp
+}
+
LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
index 1be32ad..c0b947a 100644
--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -155,9 +155,11 @@ void QFactoryLoader::update()
continue;
}
QObject *instance = library->instance();
- if (!instance)
+ if (!instance) {
+ library->release();
// ignore plugins that have a valid signature but cannot be loaded.
continue;
+ }
QFactoryInterface *factory = qobject_cast<QFactoryInterface*>(instance);
if (instance && factory && instance->qt_metacast(d->iid))
keys = factory->keys();
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 392c45d..b2af5ca 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -1245,9 +1245,7 @@ void QStateMachinePrivate::_q_process()
#endif
while (processing) {
if (stop) {
- stop = false;
processing = false;
- stopProcessingReason = Stopped;
break;
}
QSet<QAbstractTransition*> enabledTransitions;
@@ -1299,6 +1297,11 @@ void QStateMachinePrivate::_q_process()
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": finished the event processing loop";
#endif
+ if (stop) {
+ stop = false;
+ stopProcessingReason = Stopped;
+ }
+
switch (stopProcessingReason) {
case EventQueueEmpty:
break;
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index dfe4aae..5f75195 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -163,6 +163,7 @@ class QMutexData
~QMutexData();
};
+#ifdef QT_NO_DEBUG
inline void QMutex::unlockInline()
{
if (d->recursive) {
@@ -189,7 +190,13 @@ inline void QMutex::lockInline()
lockInternal();
}
}
-
+#else // QT_NO_DEBUG
+//in debug we do not use inline calls in order to allow debugging tools
+// to hook the mutex locking functions.
+inline void QMutex::unlockInline() { unlock(); }
+inline bool QMutex::tryLockInline() { return tryLock(); }
+inline void QMutex::lockInline() { lock(); }
+#endif // QT_NO_DEBUG
#else // QT_NO_THREAD
diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp
index 5321252..11e2060 100644
--- a/src/corelib/thread/qmutex_unix.cpp
+++ b/src/corelib/thread/qmutex_unix.cpp
@@ -180,8 +180,11 @@ bool QMutexPrivate::wait(int timeout)
errorCode = pthread_cond_timedwait(&cond, &mutex, &ti);
}
if (errorCode) {
- if (errorCode == ETIMEDOUT)
+ if (errorCode == ETIMEDOUT) {
+ if (wakeup)
+ errorCode = 0;
break;
+ }
report_error(errorCode, "QMutex::lock()", "cv wait");
}
}
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 1494745..326f494 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -515,10 +515,12 @@ int QThread::exec()
Note that unlike the C library function of the same name, this
function \e does return to the caller -- it is event processing
- that stops.
-
- This function does nothing if the thread does not have an event
- loop.
+ that stops.
+
+ No QEventLoops will be started anymore in this thread until
+ QThread::exec() has been called again. If the eventloop in QThread::exec()
+ is not running then the next call to QThread::exec() will also return
+ immediately.
\sa quit() QEventLoop
*/
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index 9a2dbec..36e07c0 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -209,8 +209,6 @@ public:
bool canWait;
QVector<void *> tls;
- QMutex mutex;
-
# ifdef Q_OS_SYMBIAN
RThread symbian_thread_handle;
# endif
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 0766447..5e0d2a2 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -110,6 +110,17 @@ QT_BEGIN_NAMESPACE
enum { ThreadPriorityResetFlag = 0x80000000 };
+#if defined(Q_OS_LINUX) && defined(__GLIBC__) && (defined(Q_CC_GNU) || defined(Q_CC_INTEL))
+#define HAVE_TLS
+#endif
+#if defined(Q_CC_XLC) || defined (Q_CC_SUN)
+#define HAVE_TLS
+#endif
+
+#ifdef HAVE_TLS
+static __thread QThreadData *currentThreadData = 0;
+#endif
+
static pthread_once_t current_thread_data_once = PTHREAD_ONCE_INIT;
static pthread_key_t current_thread_data_key;
@@ -157,7 +168,9 @@ Q_DESTRUCTOR_FUNCTION(destroy_current_thread_data_key)
// that pthread has, so pthread_setspecific is also used.
static QThreadData *get_thread_data()
{
-#ifdef Q_OS_SYMBIAN
+#ifdef HAVE_TLS
+ return currentThreadData;
+#elif defined Q_OS_SYMBIAN
return reinterpret_cast<QThreadData *>(Dll::Tls());
#else
pthread_once(&current_thread_data_once, create_current_thread_data_key);
@@ -167,7 +180,9 @@ static QThreadData *get_thread_data()
static void set_thread_data(QThreadData *data)
{
-#ifdef Q_OS_SYMBIAN
+#ifdef HAVE_TLS
+ currentThreadData = data;
+#elif defined Q_OS_SYMBIAN
qt_symbian_throwIfError(Dll::SetTls(data));
#endif
pthread_once(&current_thread_data_once, create_current_thread_data_key);
@@ -176,7 +191,9 @@ static void set_thread_data(QThreadData *data)
static void clear_thread_data()
{
-#ifdef Q_OS_SYMBIAN
+#ifdef HAVE_TLS
+ currentThreadData = 0;
+#elif defined Q_OS_SYMBIAN
Dll::FreeTls();
#endif
pthread_setspecific(current_thread_data_key, 0);
@@ -310,7 +327,10 @@ void *QThreadPrivate::start(void *arg)
set_thread_data(data);
data->ref();
- data->quitNow = false;
+ {
+ QMutexLocker locker(&thr->d_func()->mutex);
+ data->quitNow = thr->d_func()->exited;
+ }
// ### TODO: allow the user to create a custom event dispatcher
createEventDispatcher(data);
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index cb2d1a9..6b7932b 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -298,7 +298,10 @@ unsigned int __stdcall QThreadPrivate::start(void *arg)
QThread::setTerminationEnabled(false);
- data->quitNow = false;
+ {
+ QMutexLocker locker(&thr->d_func()->mutex);
+ data->quitNow = thr->d_func()->exited;
+ }
// ### TODO: allow the user to create a custom event dispatcher
createEventDispatcher(data);
diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri
index 03f661d..90583bb 100644
--- a/src/corelib/thread/thread.pri
+++ b/src/corelib/thread/thread.pri
@@ -31,3 +31,7 @@ unix:SOURCES += thread/qmutex_unix.cpp \
win32:SOURCES += thread/qmutex_win.cpp \
thread/qthread_win.cpp \
thread/qwaitcondition_win.cpp
+
+integrity:SOURCES += thread/qmutex_unix.cpp \
+ thread/qthread_unix.cpp \
+ thread/qwaitcondition_unix.cpp
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index cc81c1b..b281c1b 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -492,7 +492,7 @@ QByteArray qCompress(const uchar* data, int nbytes, int compressionLevel)
#endif
/*!
- \fn QByteArray qUncompress(const QByteArray& data)
+ \fn QByteArray qUncompress(const QByteArray &data)
\relates QByteArray
@@ -506,10 +506,10 @@ QByteArray qCompress(const uchar* data, int nbytes, int compressionLevel)
feature was added.
\bold{Note:} If you want to use this function to uncompress external
- data compressed using zlib, you first need to prepend four bytes to the
- byte array that contain the expected length (as an unsigned integer)
- of the uncompressed data encoded in big-endian order (most significant
- byte first).
+ data that was compressed using zlib, you first need to prepend a four
+ byte header to the byte array containing the data. The header must
+ contain the expected length (in bytes) of the uncompressed data,
+ expressed as an unsigned, big-endian, 32-bit integer.
\sa qCompress()
*/
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index 801600a..7daf95a 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -92,14 +92,18 @@
animation.setEasingCurve(QEasingCurve::InOutQuad);
\endcode
- The ability to set an amplitude, overshoot, or period depends on the QEasingCurve type. Amplitude access
- is available to curves that behave as springs such as elastic and bounce curves. Changing the amplitude changes
- the height of the curve. Period access is only available to elastic curves and setting a higher period slows
- the rate of bounce. Only curves that have "boomerang" behaviors such as the InBack, OutBack, InOutBack, and OutInBack
- have overshoot settings. These curves will interpolate beyond the end points and return to the end point,
- acting similar to a boomerang.
-
- The \l{Easing Curves Example} contains samples of QEasingCurve types and lets you change the curve settings.
+ The ability to set an amplitude, overshoot, or period depends on
+ the QEasingCurve type. Amplitude access is available to curves
+ that behave as springs such as elastic and bounce curves. Changing
+ the amplitude changes the height of the curve. Period access is
+ only available to elastic curves and setting a higher period slows
+ the rate of bounce. Only curves that have "boomerang" behaviors
+ such as the InBack, OutBack, InOutBack, and OutInBack have
+ overshoot settings. These curves will interpolate beyond the end
+ points and return to the end point, acting similar to a boomerang.
+
+ The \l{Easing Curves Example} contains samples of QEasingCurve
+ types and lets you change the curve settings.
*/
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index fcfa8f0..6515edb 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -2199,7 +2199,7 @@ static quint16 localePrivateIndex(const QLocalePrivate *p)
/*!
Constructs a QLocale object with the specified \a name,
which has the format
- "language[_country][.codeset][@modifier]" or "C", where:
+ "language[_territory][.codeset][@modifier]" or "C", where:
\list
\i language is a lowercase, two-letter, ISO 639 language code,
diff --git a/src/corelib/tools/qscopedvaluerollback.cpp b/src/corelib/tools/qscopedvaluerollback.cpp
new file mode 100644
index 0000000..8933efc
--- /dev/null
+++ b/src/corelib/tools/qscopedvaluerollback.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** 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 QtCore 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 "qscopedvaluerollback.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QScopedValueRollback
+ \brief The QScopedValueRollback resets a variable to its previous value on destruction
+ \since 4.8
+ \ingroup misc
+
+ The QScopedAssignment class can be used to revert state when an
+ exception is thrown without needing to write try-catch blocks.
+
+ It can also be used to manage variables that are temporarily set,
+ such as reentrancy guards. By using this class, the variable will
+ be reset whether the function is exited normally, exited early by
+ a return statement, or exited by an exception.
+
+ The template can only be instantiated with a type that supports assignment.
+
+ \sa QScopedPointer
+*/
+
+/*!
+ \fn QScopedValueRollback::QScopedValueRollback(T &var)
+
+ Stores the previous value of var internally, for revert on destruction.
+*/
+
+/*!
+ \fn QScopedValueRollback::~QScopedValueRollback()
+
+ Assigns the previous value to the managed variable.
+ This is the value at construction time, or at the last call to commit()
+*/
+
+/*!
+ \fn void QScopedValueRollback::commit()
+
+ Updates the previous value of the managed variable to its current value.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/corelib/tools/qscopedvaluerollback.h b/src/corelib/tools/qscopedvaluerollback.h
new file mode 100644
index 0000000..e874428
--- /dev/null
+++ b/src/corelib/tools/qscopedvaluerollback.h
@@ -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 QtCore 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 QSCOPEDVALUEROLLBACK_H
+#define QSCOPEDVALUEROLLBACK_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+QT_MODULE(Core)
+
+template <typename T>
+class QScopedValueRollback
+{
+public:
+ QScopedValueRollback(T &var) :
+ varRef(var)
+ {
+ oldValue = varRef;
+ }
+
+ ~QScopedValueRollback()
+ {
+ varRef = oldValue;
+ }
+
+ void commit()
+ {
+ oldValue = varRef;
+ }
+
+private:
+ T& varRef;
+ T oldValue;
+
+ Q_DISABLE_COPY(QScopedValueRollback)
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // QSCOPEDVALUEROLLBACK_H
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index a8ae40c..a2a8052 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -335,7 +335,7 @@ class QMutableSetIterator
typedef typename QSet<T>::iterator iterator;
QSet<T> *c;
iterator i, n;
- inline bool item_exists() const { return n != c->constEnd(); }
+ inline bool item_exists() const { return c->constEnd() != n; }
public:
inline QMutableSetIterator(QSet<T> &container)
diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h
index 1bdba2c..1494373 100644
--- a/src/corelib/tools/qshareddata.h
+++ b/src/corelib/tools/qshareddata.h
@@ -114,6 +114,7 @@ public:
return *this;
}
#ifdef Q_COMPILER_RVALUE_REFS
+ QSharedDataPointer(QSharedDataPointer &&o) : d(o.d) { o.d = 0; }
inline QSharedDataPointer<T> &operator=(QSharedDataPointer<T> &&other)
{ qSwap(d, other.d); return *this; }
#endif
@@ -197,7 +198,8 @@ public:
return *this;
}
#ifdef Q_COMPILER_RVALUE_REFS
- inline QSharedDataPointer<T> &operator=(QSharedDataPointer<T> &&other)
+ inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) : d(o.d) { o.d = 0; }
+ inline QExplicitlySharedDataPointer<T> &operator=(QExplicitlySharedDataPointer<T> &&other)
{ qSwap(d, other.d); return *this; }
#endif
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 273c5bd..b29e5b6 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -44,7 +44,17 @@
#ifndef QSHAREDPOINTER_H
#error Do not include qsharedpointer_impl.h directly
#endif
+
#if 0
+// These macros are duplicated here to make syncqt not complain a about
+// this header, as we have a "qt_sync_stop_processing" below, which in turn
+// is here because this file contains a template mess and duplicates the
+// classes found in qsharedpointer.h
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+QT_MODULE(Core)
+QT_END_NAMESPACE
+QT_END_HEADER
#pragma qt_sync_stop_processing
#endif
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 95c80a1..b7272ec 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -658,10 +658,11 @@ const QString::Null QString::null = { };
class.)
\table 100 %
+ \header
+ \o Note for C Programmers
+
\row
\o
- \section1 Note for C Programmers
-
Due to C++'s type system and the fact that QString is
\l{implicitly shared}, QStrings may be treated like \c{int}s or
other basic types. For example:
@@ -3890,8 +3891,7 @@ const char *QString::latin1_helper() const
If \a size is -1 (default), it is taken to be qstrlen(\a
str).
- QTextCodec::codecForLocale() is used to perform the conversion
- from Unicode.
+ QTextCodec::codecForLocale() is used to perform the conversion.
\sa toLocal8Bit(), fromAscii(), fromLatin1(), fromUtf8()
*/
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 03bb32d..fb1b466 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -29,6 +29,9 @@ HEADERS += \
tools/qrect.h \
tools/qregexp.h \
tools/qringbuffer_p.h \
+ tools/qscopedpointer.h \
+ tools/qscopedpointer_p.h \
+ tools/qscopedvaluerollback.h \
tools/qshareddata.h \
tools/qsharedpointer.h \
tools/qsharedpointer_impl.h \
@@ -45,9 +48,7 @@ HEADERS += \
tools/qelapsedtimer.h \
tools/qunicodetables_p.h \
tools/qvarlengtharray.h \
- tools/qvector.h \
- tools/qscopedpointer.h \
- tools/qscopedpointer_p.h
+ tools/qvector.h
SOURCES += \
@@ -87,6 +88,7 @@ symbian:SOURCES+=tools/qlocale_symbian.cpp
else:symbian:SOURCES += tools/qelapsedtimer_symbian.cpp
else:unix:SOURCES += tools/qelapsedtimer_unix.cpp
else:win32:SOURCES += tools/qelapsedtimer_win.cpp
+else:integrity:SOURCES += tools/qelapsedtimer_unix.cpp
else:SOURCES += tools/qelapsedtimer_generic.cpp
contains(QT_CONFIG, zlib):include($$PWD/../../3rdparty/zlib.pri)
diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h
index 2c8693b..e331d8f 100644
--- a/src/dbus/qdbusargument.h
+++ b/src/dbus/qdbusargument.h
@@ -376,6 +376,21 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, QHash<Key, T> &
return arg;
}
+inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantHash &map)
+{
+ arg.beginMap(QVariant::String, qMetaTypeId<QDBusVariant>());
+ QVariantHash::ConstIterator it = map.constBegin();
+ QVariantHash::ConstIterator end = map.constEnd();
+ for ( ; it != end; ++it) {
+ arg.beginMapEntry();
+ arg << it.key() << QDBusVariant(it.value());
+ arg.endMapEntry();
+ }
+ arg.endMap();
+ return arg;
+}
+
+
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QDBusArgument)
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index eb312d2..3fb63eb 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -632,10 +632,26 @@ bool QDBusConnection::connect(const QString &service, const QString &path, const
if (!receiver || !slot || !d || !d->connection)
return false;
- if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface))
- return false;
if (interface.isEmpty() && name.isEmpty())
return false;
+ if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) {
+#ifndef QT_NO_DEBUG
+ qWarning("QDBusConnection::connect: interface name '%s' is not valid", interface.toLatin1().constData());
+#endif
+ return false;
+ }
+ if (!service.isEmpty() && !QDBusUtil::isValidBusName(service)) {
+#ifndef QT_NO_DEBUG
+ qWarning("QDBusConnection::connect: service name '%s' is not valid", service.toLatin1().constData());
+#endif
+ return false;
+ }
+ if (!path.isEmpty() && !QDBusUtil::isValidObjectPath(path)) {
+#ifndef QT_NO_DEBUG
+ qWarning("QDBusConnection::connect: object path '%s' is not valid", path.toLatin1().constData());
+#endif
+ return false;
+ }
QDBusWriteLocker locker(ConnectAction, d);
return d->connectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot);
diff --git a/src/dbus/qdbusdemarshaller.cpp b/src/dbus/qdbusdemarshaller.cpp
index 3882edb..6638263 100644
--- a/src/dbus/qdbusdemarshaller.cpp
+++ b/src/dbus/qdbusdemarshaller.cpp
@@ -176,10 +176,10 @@ QDBusArgument::ElementType QDBusDemarshaller::currentType()
case DBUS_TYPE_INVALID:
return QDBusArgument::UnknownType;
- default:
- qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'",
- q_dbus_message_iter_get_arg_type(&iterator),
- q_dbus_message_iter_get_arg_type(&iterator));
+// default:
+// qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'",
+// q_dbus_message_iter_get_arg_type(&iterator),
+// q_dbus_message_iter_get_arg_type(&iterator));
}
return QDBusArgument::UnknownType;
}
@@ -232,10 +232,15 @@ QVariant QDBusDemarshaller::toVariantInternal()
return QVariant::fromValue(duplicate());
default:
- qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'",
- q_dbus_message_iter_get_arg_type(&iterator),
- q_dbus_message_iter_get_arg_type(&iterator));
- return QVariant();
+// qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'",
+// q_dbus_message_iter_get_arg_type(&iterator),
+// q_dbus_message_iter_get_arg_type(&iterator));
+ char *ptr = 0;
+ ptr += q_dbus_message_iter_get_arg_type(&iterator);
+ q_dbus_message_iter_next(&iterator);
+
+ // I hope you never dereference this pointer!
+ return QVariant::fromValue<void *>(ptr);
break;
};
}
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 3c0cb6e..14138e0 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -558,8 +558,9 @@ bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg)
switch (amsg.type()) {
case QDBusMessage::SignalMessage:
handleSignal(amsg);
- return true;
- break;
+ // if there are any other filters in this DBusConnection,
+ // let them see the signal too
+ return false;
case QDBusMessage::MethodCallMessage:
handleObjectCall(amsg);
return true;
@@ -2073,30 +2074,20 @@ void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook
if (connection) {
qDBusDebug("Adding rule: %s", hook.matchRule.constData());
- QDBusErrorInternal error;
- q_dbus_bus_add_match(connection, hook.matchRule, error);
- if (!!error) {
- QDBusError qerror = error;
- qWarning("QDBusConnectionPrivate::connectSignal: received error from D-Bus server "
- "while connecting signal to %s::%s: %s (%s)",
- hook.obj->metaObject()->className(),
- hook.obj->metaObject()->method(hook.midx).signature(),
- qPrintable(qerror.name()), qPrintable(qerror.message()));
- Q_ASSERT(false);
- } else {
- // Successfully connected the signal
- // Do we need to watch for this name?
- if (shouldWatchService(hook.service)) {
- WatchedServicesHash::mapped_type &data = watchedServices[hook.service];
- if (++data.refcount == 1) {
- // we need to watch for this service changing
- connectSignal(dbusServiceString(), QString(), dbusInterfaceString(),
- QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(),
- this, SLOT(serviceOwnerChangedNoLock(QString,QString,QString)));
- data.owner = getNameOwnerNoCache(hook.service);
- qDBusDebug() << this << "Watching service" << hook.service << "for owner changes (current owner:"
- << data.owner << ")";
- }
+ q_dbus_bus_add_match(connection, hook.matchRule, NULL);
+
+ // Successfully connected the signal
+ // Do we need to watch for this name?
+ if (shouldWatchService(hook.service)) {
+ WatchedServicesHash::mapped_type &data = watchedServices[hook.service];
+ if (++data.refcount == 1) {
+ // we need to watch for this service changing
+ connectSignal(dbusServiceString(), QString(), dbusInterfaceString(),
+ QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(),
+ this, SLOT(serviceOwnerChangedNoLock(QString,QString,QString)));
+ data.owner = getNameOwnerNoCache(hook.service);
+ qDBusDebug() << this << "Watching service" << hook.service << "for owner changes (current owner:"
+ << data.owner << ")";
}
}
}
diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp
index 5fe0589..df8bc1d 100644
--- a/src/dbus/qdbusmetaobject.cpp
+++ b/src/dbus/qdbusmetaobject.cpp
@@ -169,6 +169,8 @@ QDBusMetaObjectGenerator::QDBusMetaObjectGenerator(const QString &interfaceName,
}
}
+Q_DBUS_EXPORT bool qt_dbus_metaobject_skip_annotations = false;
+
QDBusMetaObjectGenerator::Type
QDBusMetaObjectGenerator::findType(const QByteArray &signature,
const QDBusIntrospection::Annotations &annotations,
@@ -178,7 +180,7 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
result.id = QVariant::Invalid;
int type = QDBusMetaType::signatureToType(signature);
- if (type == QVariant::Invalid) {
+ if (type == QVariant::Invalid && !qt_dbus_metaobject_skip_annotations) {
// it's not a type normally handled by our meta type system
// it must contain an annotation
QString annotationName = QString::fromLatin1("com.trolltech.QtDBus.QtTypeName");
@@ -191,16 +193,35 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
QByteArray typeName = annotations.value(annotationName).toLatin1();
// verify that it's a valid one
- if (typeName.isEmpty())
- return result; // invalid
+ if (!typeName.isEmpty()) {
+ // type name found
+ type = QVariant::nameToType(typeName);
+ if (type == QVariant::UserType)
+ type = QMetaType::type(typeName);
+ }
- type = QVariant::nameToType(typeName);
- if (type == QVariant::UserType)
- type = QMetaType::type(typeName);
- if (type == QVariant::Invalid || signature != QDBusMetaType::typeToSignature(type))
- return result; // unknown type is invalid too
+ if (type == QVariant::Invalid || signature != QDBusMetaType::typeToSignature(type)) {
+ // type is still unknown or doesn't match back to the signature that it
+ // was expected to, so synthesize a fake type
+ type = QMetaType::VoidStar;
+ typeName = "QDBusRawType<0x" + signature.toHex() + ">*";
+ }
result.name = typeName;
+ } else if (type == QVariant::Invalid) {
+ // this case is used only by the qdbus command-line tool
+ // invalid, let's create an impossible type that contains the signature
+
+ if (signature == "av") {
+ result.name = "QVariantList";
+ type = QVariant::List;
+ } else if (signature == "a{sv}") {
+ result.name = "QVariantMap";
+ type = QVariant::Map;
+ } else {
+ result.name = "QDBusRawType::" + signature;
+ type = -1;
+ }
} else {
result.name = QVariant::typeToName( QVariant::Type(type) );
}
diff --git a/src/dbus/qdbusmetatype.cpp b/src/dbus/qdbusmetatype.cpp
index 6de5d93..9f29205 100644
--- a/src/dbus/qdbusmetatype.cpp
+++ b/src/dbus/qdbusmetatype.cpp
@@ -127,6 +127,7 @@ void QDBusMetaTypeId::init()
registerHelper<QLineF>();
registerHelper<QVariantList>();
registerHelper<QVariantMap>();
+ registerHelper<QVariantHash>();
qDBusRegisterMetaType<QList<bool> >();
qDBusRegisterMetaType<QList<short> >();
diff --git a/src/dbus/qdbusxmlparser.cpp b/src/dbus/qdbusxmlparser.cpp
index 1b99ced..3feedde 100644
--- a/src/dbus/qdbusxmlparser.cpp
+++ b/src/dbus/qdbusxmlparser.cpp
@@ -52,6 +52,13 @@
#ifndef QT_NO_DBUS
+//#define QDBUS_PARSER_DEBUG
+#ifdef QDBUS_PARSER_DEBUG
+# define qDBusParserError qWarning
+#else
+# define qDBusParserError if (true) {} else qDebug
+#endif
+
QT_BEGIN_NAMESPACE
static QDBusIntrospection::Annotations
@@ -69,8 +76,8 @@ parseAnnotations(const QDomElement& elem)
value = ann.attribute(QLatin1String("value"));
if (!QDBusUtil::isValidInterfaceName(name)) {
- qWarning("Invalid D-BUS annotation '%s' found while parsing introspection",
- qPrintable(name));
+ qDBusParserError("Invalid D-BUS annotation '%s' found while parsing introspection",
+ qPrintable(name));
continue;
}
@@ -99,9 +106,8 @@ parseArgs(const QDomElement& elem, const QLatin1String& direction, bool acceptEm
argData.name = arg.attribute(QLatin1String("name")); // can be empty
argData.type = arg.attribute(QLatin1String("type"));
if (!QDBusUtil::isValidSingleSignature(argData.type)) {
- qWarning("Invalid D-BUS type signature '%s' found while parsing introspection",
- qPrintable(argData.type));
- continue;
+ qDBusParserError("Invalid D-BUS type signature '%s' found while parsing introspection",
+ qPrintable(argData.type));
}
retval << argData;
@@ -141,8 +147,8 @@ QDBusXmlParser::interfaces() const
if (iface.isNull())
continue; // for whatever reason
if (!QDBusUtil::isValidInterfaceName(ifaceName)) {
- qWarning("Invalid D-BUS interface name '%s' found while parsing introspection",
- qPrintable(ifaceName));
+ qDBusParserError("Invalid D-BUS interface name '%s' found while parsing introspection",
+ qPrintable(ifaceName));
continue;
}
@@ -166,8 +172,8 @@ QDBusXmlParser::interfaces() const
if (method.isNull())
continue;
if (!QDBusUtil::isValidMemberName(methodName)) {
- qWarning("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
- qPrintable(methodName), qPrintable(ifaceName));
+ qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
+ qPrintable(methodName), qPrintable(ifaceName));
continue;
}
@@ -192,8 +198,8 @@ QDBusXmlParser::interfaces() const
if (signal.isNull())
continue;
if (!QDBusUtil::isValidMemberName(signalName)) {
- qWarning("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
- qPrintable(signalName), qPrintable(ifaceName));
+ qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
+ qPrintable(signalName), qPrintable(ifaceName));
continue;
}
@@ -217,8 +223,8 @@ QDBusXmlParser::interfaces() const
if (property.isNull())
continue;
if (!QDBusUtil::isValidMemberName(propertyName)) {
- qWarning("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
- qPrintable(propertyName), qPrintable(ifaceName));
+ qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
+ qPrintable(propertyName), qPrintable(ifaceName));
continue;
}
@@ -231,10 +237,9 @@ QDBusXmlParser::interfaces() const
if (!QDBusUtil::isValidSingleSignature(propertyData.type)) {
// cannot be!
- qWarning("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection",
- qPrintable(propertyData.type), qPrintable(ifaceName),
- qPrintable(propertyName));
- continue;
+ qDBusParserError("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection",
+ qPrintable(propertyData.type), qPrintable(ifaceName),
+ qPrintable(propertyName));
}
QString access = property.attribute(QLatin1String("access"));
@@ -245,9 +250,9 @@ QDBusXmlParser::interfaces() const
else if (access == QLatin1String("readwrite"))
propertyData.access = QDBusIntrospection::Property::ReadWrite;
else {
- qWarning("Invalid D-BUS property access '%s' found in property '%s.%s' while parsing introspection",
- qPrintable(access), qPrintable(ifaceName),
- qPrintable(propertyName));
+ qDBusParserError("Invalid D-BUS property access '%s' found in property '%s.%s' while parsing introspection",
+ qPrintable(access), qPrintable(ifaceName),
+ qPrintable(propertyName));
continue; // invalid one!
}
@@ -286,8 +291,8 @@ QDBusXmlParser::object() const
if (obj.isNull())
continue; // for whatever reason
if (!QDBusUtil::isValidObjectPath(m_path + QLatin1Char('/') + objName)) {
- qWarning("Invalid D-BUS object path '%s/%s' found while parsing introspection",
- qPrintable(m_path), qPrintable(objName));
+ qDBusParserError("Invalid D-BUS object path '%s/%s' found while parsing introspection",
+ qPrintable(m_path), qPrintable(objName));
continue;
}
@@ -301,8 +306,8 @@ QDBusXmlParser::object() const
if (iface.isNull())
continue;
if (!QDBusUtil::isValidInterfaceName(ifaceName)) {
- qWarning("Invalid D-BUS interface name '%s' found while parsing introspection",
- qPrintable(ifaceName));
+ qDBusParserError("Invalid D-BUS interface name '%s' found while parsing introspection",
+ qPrintable(ifaceName));
continue;
}
diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri
index 25f7687..75287b4 100644
--- a/src/declarative/debugger/debugger.pri
+++ b/src/declarative/debugger/debugger.pri
@@ -7,13 +7,17 @@ SOURCES += \
$$PWD/qdeclarativedebugclient.cpp \
$$PWD/qdeclarativedebug.cpp \
$$PWD/qdeclarativedebugtrace.cpp \
- $$PWD/qdeclarativedebughelper.cpp
+ $$PWD/qdeclarativedebughelper.cpp \
+ $$PWD/qdeclarativedebugserver.cpp
HEADERS += \
$$PWD/qdeclarativedebuggerstatus_p.h \
$$PWD/qpacketprotocol_p.h \
$$PWD/qdeclarativedebugservice_p.h \
+ $$PWD/qdeclarativedebugservice_p_p.h \
$$PWD/qdeclarativedebugclient_p.h \
$$PWD/qdeclarativedebug_p.h \
$$PWD/qdeclarativedebugtrace_p.h \
- $$PWD/qdeclarativedebughelper_p.h
+ $$PWD/qdeclarativedebughelper_p.h \
+ $$PWD/qdeclarativedebugserver_p.h \
+ debugger/qdeclarativedebugserverconnection_p.h
diff --git a/src/declarative/debugger/qdeclarativedebugclient.cpp b/src/declarative/debugger/qdeclarativedebugclient.cpp
index e6a3f69..036dee1 100644
--- a/src/declarative/debugger/qdeclarativedebugclient.cpp
+++ b/src/declarative/debugger/qdeclarativedebugclient.cpp
@@ -61,7 +61,7 @@ public:
QDeclarativeDebugClientPrivate();
QString name;
- QDeclarativeDebugConnection *client;
+ QDeclarativeDebugConnection *connection;
};
class QDeclarativeDebugConnectionPrivate : public QObject
@@ -202,7 +202,7 @@ QDeclarativeDebugConnection::~QDeclarativeDebugConnection()
{
QHash<QString, QDeclarativeDebugClient*>::iterator iter = d->plugins.begin();
for (; iter != d->plugins.end(); ++iter) {
- iter.value()->d_func()->client = 0;
+ iter.value()->d_func()->connection = 0;
iter.value()->statusChanged(QDeclarativeDebugClient::NotConnected);
}
}
@@ -213,7 +213,7 @@ bool QDeclarativeDebugConnection::isConnected() const
}
QDeclarativeDebugClientPrivate::QDeclarativeDebugClientPrivate()
-: client(0)
+: connection(0)
{
}
@@ -223,26 +223,26 @@ QDeclarativeDebugClient::QDeclarativeDebugClient(const QString &name,
{
Q_D(QDeclarativeDebugClient);
d->name = name;
- d->client = parent;
+ d->connection = parent;
- if (!d->client)
+ if (!d->connection)
return;
- if (d->client->d->plugins.contains(name)) {
+ if (d->connection->d->plugins.contains(name)) {
qWarning() << "QDeclarativeDebugClient: Conflicting plugin name" << name;
- d->client = 0;
+ d->connection = 0;
} else {
- d->client->d->plugins.insert(name, this);
- d->client->d->advertisePlugins();
+ d->connection->d->plugins.insert(name, this);
+ d->connection->d->advertisePlugins();
}
}
QDeclarativeDebugClient::~QDeclarativeDebugClient()
{
Q_D(const QDeclarativeDebugClient);
- if (d->client && d->client->d) {
- d->client->d->plugins.remove(d->name);
- d->client->d->advertisePlugins();
+ if (d->connection && d->connection->d) {
+ d->connection->d->plugins.remove(d->name);
+ d->connection->d->advertisePlugins();
}
}
@@ -255,12 +255,12 @@ QString QDeclarativeDebugClient::name() const
QDeclarativeDebugClient::Status QDeclarativeDebugClient::status() const
{
Q_D(const QDeclarativeDebugClient);
- if (!d->client
- || !d->client->isConnected()
- || !d->client->d->gotHello)
+ if (!d->connection
+ || !d->connection->isConnected()
+ || !d->connection->d->gotHello)
return NotConnected;
- if (d->client->d->serverPlugins.contains(d->name))
+ if (d->connection->d->serverPlugins.contains(d->name))
return Enabled;
return Unavailable;
@@ -275,8 +275,8 @@ void QDeclarativeDebugClient::sendMessage(const QByteArray &message)
QPacket pack;
pack << d->name << message;
- d->client->d->protocol->send(pack);
- d->client->d->q->flush();
+ d->connection->d->protocol->send(pack);
+ d->connection->d->q->flush();
}
void QDeclarativeDebugClient::statusChanged(Status)
diff --git a/src/declarative/debugger/qdeclarativedebugserver.cpp b/src/declarative/debugger/qdeclarativedebugserver.cpp
new file mode 100644
index 0000000..ea3d9a3
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativedebugserver.cpp
@@ -0,0 +1,361 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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/qdeclarativedebugserver_p.h"
+#include "private/qdeclarativedebugservice_p.h"
+#include "private/qdeclarativedebugservice_p_p.h"
+#include "private/qdeclarativeengine_p.h"
+
+#include <QtCore/QDir>
+#include <QtCore/QPluginLoader>
+#include <QtCore/QStringList>
+
+#include <private/qobject_p.h>
+#include <private/qapplication_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ QDeclarativeDebug Protocol (Version 1):
+
+ handshake:
+ 1. Client sends
+ "QDeclarativeDebugServer" 0 version pluginNames
+ version: an int representing the highest protocol version the client knows
+ pluginNames: plugins available on client side
+ 2. Server sends
+ "QDeclarativeDebugClient" 0 version pluginNames
+ version: an int representing the highest protocol version the client & server know
+ pluginNames: plugins available on server side. plugins both in the client and server message are enabled.
+ client plugin advertisement
+ 1. Client sends
+ "QDeclarativeDebugServer" 1 pluginNames
+ server plugin advertisement
+ 1. Server sends
+ "QDeclarativeDebugClient" 1 pluginNames
+ plugin communication:
+ Everything send with a header different to "QDeclarativeDebugServer" is sent to the appropriate plugin.
+ */
+
+const int protocolVersion = 1;
+
+
+class QDeclarativeDebugServerPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeDebugServer)
+public:
+ QDeclarativeDebugServerPrivate();
+
+ void advertisePlugins();
+
+ QDeclarativeDebugServerConnection *connection;
+ QHash<QString, QDeclarativeDebugService *> plugins;
+ QStringList clientPlugins;
+ bool gotHello;
+
+ static QDeclarativeDebugServerConnection *loadConnectionPlugin();
+};
+
+QDeclarativeDebugServerPrivate::QDeclarativeDebugServerPrivate() :
+ connection(0),
+ gotHello(false)
+{
+}
+
+void QDeclarativeDebugServerPrivate::advertisePlugins()
+{
+ if (!gotHello)
+ return;
+
+ QByteArray message;
+ {
+ QDataStream out(&message, QIODevice::WriteOnly);
+ out << QString(QLatin1String("QDeclarativeDebugClient")) << 1 << plugins.keys();
+ }
+ connection->send(message);
+}
+
+QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectionPlugin()
+{
+ QStringList pluginCandidates;
+ const QStringList paths = QCoreApplication::libraryPaths();
+ foreach (const QString &libPath, paths) {
+ const QDir dir(libPath + QLatin1String("/qmltooling"));
+ if (dir.exists()) {
+ QStringList plugins(dir.entryList(QDir::Files));
+ foreach (const QString &pluginPath, plugins) {
+ pluginCandidates << dir.absoluteFilePath(pluginPath);
+ }
+ }
+ }
+
+ foreach (const QString &pluginPath, pluginCandidates) {
+ QPluginLoader loader(pluginPath);
+ if (!loader.load()) {
+ continue;
+ }
+ QDeclarativeDebugServerConnection *connection = 0;
+ if (QObject *instance = loader.instance())
+ connection = qobject_cast<QDeclarativeDebugServerConnection*>(instance);
+
+ if (connection)
+ return connection;
+ loader.unload();
+ }
+ return 0;
+}
+
+bool QDeclarativeDebugServer::hasDebuggingClient() const
+{
+ Q_D(const QDeclarativeDebugServer);
+ return d->connection
+ && d->connection->isConnected()
+ && d->gotHello;
+}
+
+QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
+{
+ static bool commandLineTested = false;
+ static QDeclarativeDebugServer *server = 0;
+
+ if (!commandLineTested) {
+ commandLineTested = true;
+
+#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL
+ QApplicationPrivate *appD = static_cast<QApplicationPrivate*>(QObjectPrivate::get(qApp));
+ // ### remove port definition when protocol is changed
+ int port = 0;
+ bool block = false;
+ bool ok = false;
+
+ // format: qmljsdebugger=port:3768[,block]
+ if (!appD->qmljsDebugArgumentsString().isEmpty()) {
+ if (!QDeclarativeEnginePrivate::qml_debugging_enabled) {
+ const QString message =
+ QString::fromAscii("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
+ "Debugging has not been enabled.").arg(
+ appD->qmljsDebugArgumentsString());
+ qWarning("%s", qPrintable(message));
+ return 0;
+ }
+
+ if (appD->qmljsDebugArgumentsString().indexOf(QLatin1String("port:")) == 0) {
+ int separatorIndex = appD->qmljsDebugArgumentsString().indexOf(QLatin1Char(','));
+ port = appD->qmljsDebugArgumentsString().mid(5, separatorIndex - 5).toInt(&ok);
+ }
+ block = appD->qmljsDebugArgumentsString().contains(QLatin1String("block"));
+
+ if (ok) {
+ server = new QDeclarativeDebugServer();
+
+ QDeclarativeDebugServerConnection *connection
+ = QDeclarativeDebugServerPrivate::loadConnectionPlugin();
+ if (connection) {
+ server->d_func()->connection = connection;
+
+ connection->setServer(server);
+ connection->setPort(port, block);
+ } else {
+ qWarning() << QString::fromAscii("QDeclarativeDebugServer: Ignoring\"-qmljsdebugger=%1\". "
+ "Remote debugger plugin has not been found.").arg(appD->qmljsDebugArgumentsString());
+ }
+
+ } else {
+ qWarning(QString::fromAscii("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
+ "Format is -qmljsdebugger=port:<port>[,block]").arg(
+ appD->qmljsDebugArgumentsString()).toAscii().constData());
+ }
+ }
+#endif
+ }
+
+ return server;
+}
+
+QDeclarativeDebugServer::QDeclarativeDebugServer()
+: QObject(*(new QDeclarativeDebugServerPrivate))
+{
+}
+
+void QDeclarativeDebugServer::receiveMessage(const QByteArray &message)
+{
+ Q_D(QDeclarativeDebugServer);
+
+ QDataStream in(message);
+ if (!d->gotHello) {
+
+ QString name;
+ int op;
+ in >> name >> op;
+
+ if (name != QLatin1String("QDeclarativeDebugServer")
+ || op != 0) {
+ qWarning("QDeclarativeDebugServer: Invalid hello message");
+ d->connection->disconnect();
+ return;
+ }
+
+ int version;
+ in >> version >> d->clientPlugins;
+
+ QHash<QString, QDeclarativeDebugService*>::Iterator iter = d->plugins.begin();
+ for (; iter != d->plugins.end(); ++iter) {
+ QDeclarativeDebugService::Status newStatus = QDeclarativeDebugService::Unavailable;
+ if (d->clientPlugins.contains(iter.key()))
+ newStatus = QDeclarativeDebugService::Enabled;
+ iter.value()->d_func()->status = newStatus;
+ 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 {
+
+ QString debugServer(QLatin1String("QDeclarativeDebugServer"));
+
+ QString name;
+ in >> name;
+
+ if (name == debugServer) {
+ int op = -1;
+ in >> op;
+
+ if (op == 1) {
+ // Service Discovery
+ QStringList oldClientPlugins = d->clientPlugins;
+ in >> d->clientPlugins;
+
+ QHash<QString, QDeclarativeDebugService*>::Iterator iter = d->plugins.begin();
+ for (; iter != d->plugins.end(); ++iter) {
+ const QString pluginName = iter.key();
+ QDeclarativeDebugService::Status newStatus = QDeclarativeDebugService::Unavailable;
+ if (d->clientPlugins.contains(pluginName))
+ newStatus = QDeclarativeDebugService::Enabled;
+
+ if (oldClientPlugins.contains(pluginName)
+ != d->clientPlugins.contains(pluginName)) {
+ iter.value()->d_func()->status = newStatus;
+ iter.value()->statusChanged(newStatus);
+ }
+ }
+ } else {
+ qWarning("QDeclarativeDebugServer: Invalid control message %d", op);
+ }
+ } else {
+ 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;
+ } else {
+ (*iter)->messageReceived(message);
+ }
+ }
+ }
+}
+
+QList<QDeclarativeDebugService*> QDeclarativeDebugServer::services() const
+{
+ const Q_D(QDeclarativeDebugServer);
+ return d->plugins.values();
+}
+
+QStringList QDeclarativeDebugServer::serviceNames() const
+{
+ const Q_D(QDeclarativeDebugServer);
+ return d->plugins.keys();
+}
+
+bool QDeclarativeDebugServer::addService(QDeclarativeDebugService *service)
+{
+ Q_D(QDeclarativeDebugServer);
+ if (!service || d->plugins.contains(service->name()))
+ return false;
+
+ d->plugins.insert(service->name(), service);
+ d->advertisePlugins();
+
+ QDeclarativeDebugService::Status newStatus = QDeclarativeDebugService::Unavailable;
+ if (d->clientPlugins.contains(service->name()))
+ newStatus = QDeclarativeDebugService::Enabled;
+ service->d_func()->status = newStatus;
+ service->statusChanged(newStatus);
+ return true;
+}
+
+bool QDeclarativeDebugServer::removeService(QDeclarativeDebugService *service)
+{
+ Q_D(QDeclarativeDebugServer);
+ if (!service || !d->plugins.contains(service->name()))
+ return false;
+
+ d->plugins.remove(service->name());
+ d->advertisePlugins();
+
+ QDeclarativeDebugService::Status newStatus = QDeclarativeDebugService::NotConnected;
+ service->d_func()->server = 0;
+ service->d_func()->status = newStatus;
+ service->statusChanged(newStatus);
+ return true;
+}
+
+void QDeclarativeDebugServer::sendMessage(QDeclarativeDebugService *service,
+ const QByteArray &message)
+{
+ Q_D(QDeclarativeDebugServer);
+ QByteArray msg;
+ {
+ QDataStream out(&msg, QIODevice::WriteOnly);
+ out << service->name() << message;
+ }
+ d->connection->send(msg);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativedebugserver_p.h b/src/declarative/debugger/qdeclarativedebugserver_p.h
new file mode 100644
index 0000000..ec3e60f
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativedebugserver_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 QDECLARATIVEDEBUGSERVER_H
+#define QDECLARATIVEDEBUGSERVER_H
+
+#include <private/qdeclarativeglobal_p.h>
+#include <private/qdeclarativedebugserverconnection_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeDebugService;
+
+class QDeclarativeDebugServerPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugServer : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeDebugServer)
+ Q_DISABLE_COPY(QDeclarativeDebugServer)
+public:
+ static QDeclarativeDebugServer *instance();
+
+ void setConnection(QDeclarativeDebugServerConnection *connection);
+
+ bool hasDebuggingClient() const;
+
+ QList<QDeclarativeDebugService*> services() const;
+ QStringList serviceNames() const;
+
+ bool addService(QDeclarativeDebugService *service);
+ bool removeService(QDeclarativeDebugService *service);
+
+ void sendMessage(QDeclarativeDebugService *service, const QByteArray &message);
+ void receiveMessage(const QByteArray &message);
+
+private:
+ friend class QDeclarativeDebugService;
+ friend class QDeclarativeDebugServicePrivate;
+ QDeclarativeDebugServer();
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEDEBUGSERVICE_H
diff --git a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h
new file mode 100644
index 0000000..631da74
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 QDECLARATIVEDEBUGSERVERCONNECTION_H
+#define QDECLARATIVEDEBUGSERVERCONNECTION_H
+
+#include <QtDeclarative/private/qdeclarativeglobal_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeDebugServer;
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugServerConnection
+{
+public:
+ QDeclarativeDebugServerConnection() {}
+ virtual ~QDeclarativeDebugServerConnection() {}
+
+ virtual void setServer(QDeclarativeDebugServer *server) = 0;
+ virtual void setPort(int port, bool bock) = 0;
+ virtual bool isConnected() const = 0;
+ virtual void send(const QByteArray &message) = 0;
+ virtual void disconnect() = 0;
+};
+
+Q_DECLARE_INTERFACE(QDeclarativeDebugServerConnection, "com.trolltech.Qt.QDeclarativeDebugServerConnection/1.0")
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEDEBUGSERVERCONNECTION_H
diff --git a/src/declarative/debugger/qdeclarativedebugservice.cpp b/src/declarative/debugger/qdeclarativedebugservice.cpp
index e916de4..1b39f1c 100644
--- a/src/declarative/debugger/qdeclarativedebugservice.cpp
+++ b/src/declarative/debugger/qdeclarativedebugservice.cpp
@@ -40,301 +40,14 @@
****************************************************************************/
#include "private/qdeclarativedebugservice_p.h"
+#include "private/qdeclarativedebugservice_p_p.h"
+#include "private/qdeclarativedebugserver_p.h"
-#include "private/qpacketprotocol_p.h"
-#include "private/qdeclarativeengine_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtNetwork/qtcpserver.h>
-#include <QtNetwork/qtcpsocket.h>
-#include <QtCore/qstringlist.h>
-
-#include <private/qobject_p.h>
-#include <private/qapplication_p.h>
-#include <QtGui/qapplication.h>
+#include <QtCore/QDebug>
+#include <QtCore/QStringList>
QT_BEGIN_NAMESPACE
-/*
- QDeclarativeDebug Protocol (Version 1):
-
- handshake:
- 1. Client sends
- "QDeclarativeDebugServer" 0 version pluginNames
- version: an int representing the highest protocol version the client knows
- pluginNames: plugins available on client side
- 2. Server sends
- "QDeclarativeDebugClient" 0 version pluginNames
- version: an int representing the highest protocol version the client & server know
- pluginNames: plugins available on server side. plugins both in the client and server message are enabled.
- client plugin advertisement
- 1. Client sends
- "QDeclarativeDebugServer" 1 pluginNames
- server plugin advertisement
- 1. Server sends
- "QDeclarativeDebugClient" 1 pluginNames
- plugin communication:
- Everything send with a header different to "QDeclarativeDebugServer" is sent to the appropriate plugin.
- */
-
-const int protocolVersion = 1;
-
-class QDeclarativeDebugServerPrivate;
-class QDeclarativeDebugServer : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeDebugServer)
- Q_DISABLE_COPY(QDeclarativeDebugServer)
-public:
- static QDeclarativeDebugServer *instance();
- void listen();
- void waitForConnection();
- bool hasDebuggingClient() const;
-
-private Q_SLOTS:
- void readyRead();
- void newConnection();
-
-private:
- friend class QDeclarativeDebugService;
- friend class QDeclarativeDebugServicePrivate;
- QDeclarativeDebugServer(int);
-};
-
-class QDeclarativeDebugServerPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeDebugServer)
-public:
- QDeclarativeDebugServerPrivate();
-
- void advertisePlugins();
-
- int port;
- QTcpSocket *connection;
- QPacketProtocol *protocol;
- QHash<QString, QDeclarativeDebugService *> plugins;
- QStringList clientPlugins;
- QTcpServer *tcpServer;
- bool gotHello;
-};
-
-class QDeclarativeDebugServicePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeDebugService)
-public:
- QDeclarativeDebugServicePrivate();
-
- QString name;
- QDeclarativeDebugServer *server;
-};
-
-QDeclarativeDebugServerPrivate::QDeclarativeDebugServerPrivate()
-: connection(0), protocol(0), gotHello(false)
-{
-}
-
-void QDeclarativeDebugServerPrivate::advertisePlugins()
-{
- if (!connection
- || connection->state() != QTcpSocket::ConnectedState
- || !gotHello)
- return;
-
- QPacket pack;
- pack << QString(QLatin1String("QDeclarativeDebugClient")) << 1 << plugins.keys();
- protocol->send(pack);
- connection->flush();
-}
-
-void QDeclarativeDebugServer::listen()
-{
- Q_D(QDeclarativeDebugServer);
-
- d->tcpServer = new QTcpServer(this);
- QObject::connect(d->tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection()));
- if (d->tcpServer->listen(QHostAddress::Any, d->port))
- qWarning("QDeclarativeDebugServer: Waiting for connection on port %d...", d->port);
- else
- qWarning("QDeclarativeDebugServer: Unable to listen on port %d", d->port);
-}
-
-void QDeclarativeDebugServer::waitForConnection()
-{
- Q_D(QDeclarativeDebugServer);
- d->tcpServer->waitForNewConnection(-1);
-}
-
-void QDeclarativeDebugServer::newConnection()
-{
- Q_D(QDeclarativeDebugServer);
-
- if (d->connection) {
- qWarning("QDeclarativeDebugServer error: another client is already connected");
- QTcpSocket *faultyConnection = d->tcpServer->nextPendingConnection();
- delete faultyConnection;
- return;
- }
-
- d->connection = d->tcpServer->nextPendingConnection();
- d->connection->setParent(this);
- d->protocol = new QPacketProtocol(d->connection, this);
- QObject::connect(d->protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
-}
-
-bool QDeclarativeDebugServer::hasDebuggingClient() const
-{
- Q_D(const QDeclarativeDebugServer);
- return d->connection
- && (d->connection->state() == QTcpSocket::ConnectedState)
- && d->gotHello;
-}
-
-QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
-{
- static bool commandLineTested = false;
- static QDeclarativeDebugServer *server = 0;
-
- if (!commandLineTested) {
- commandLineTested = true;
-
-#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL
- QApplicationPrivate *appD = static_cast<QApplicationPrivate*>(QObjectPrivate::get(qApp));
- // ### remove port definition when protocol is changed
- int port = 0;
- bool block = false;
- bool ok = false;
-
- // format: qmljsdebugger=port:3768[,block]
- if (!appD->qmljsDebugArgumentsString().isEmpty()) {
- if (!QDeclarativeEnginePrivate::qml_debugging_enabled) {
- qWarning() << QString::fromLatin1("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
- "Debugging has not been enabled.").arg(
- appD->qmljsDebugArgumentsString()).toAscii().constData();
- return 0;
- }
-
- if (appD->qmljsDebugArgumentsString().indexOf(QLatin1String("port:")) == 0) {
- int separatorIndex = appD->qmljsDebugArgumentsString().indexOf(QLatin1Char(','));
- port = appD->qmljsDebugArgumentsString().mid(5, separatorIndex - 5).toInt(&ok);
- }
- block = appD->qmljsDebugArgumentsString().contains(QLatin1String("block"));
-
- if (ok) {
- server = new QDeclarativeDebugServer(port);
- server->listen();
- if (block) {
- server->waitForConnection();
- }
- } else {
- const QString message =
- QString::fromAscii("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
- "Format is -qmljsdebugger=port:<port>[,block]").
- arg(appD->qmljsDebugArgumentsString());
- qWarning("%s", qPrintable(message));
- }
- }
-#endif
- }
-
- return server;
-}
-
-QDeclarativeDebugServer::QDeclarativeDebugServer(int port)
-: QObject(*(new QDeclarativeDebugServerPrivate))
-{
- Q_D(QDeclarativeDebugServer);
- d->port = port;
-}
-
-void QDeclarativeDebugServer::readyRead()
-{
- Q_D(QDeclarativeDebugServer);
-
- if (!d->gotHello) {
- QPacket hello = d->protocol->read();
-
- QString name;
- int op;
- hello >> name >> op;
-
- if (name != QLatin1String("QDeclarativeDebugServer")
- || op != 0) {
- qWarning("QDeclarativeDebugServer: Invalid hello message");
- QObject::disconnect(d->protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
- d->protocol->deleteLater();
- d->protocol = 0;
- d->connection->deleteLater();
- d->connection = 0;
- return;
- }
-
- int version;
- hello >> version >> d->clientPlugins;
-
- QHash<QString, QDeclarativeDebugService*>::Iterator iter = d->plugins.begin();
- for (; iter != d->plugins.end(); ++iter) {
- QDeclarativeDebugService::Status newStatus = QDeclarativeDebugService::Unavailable;
- if (d->clientPlugins.contains(iter.key()))
- newStatus = QDeclarativeDebugService::Enabled;
- iter.value()->statusChanged(newStatus);
- }
-
- QPacket helloAnswer;
- helloAnswer << QString(QLatin1String("QDeclarativeDebugClient")) << 0 << protocolVersion << d->plugins.keys();
- d->protocol->send(helloAnswer);
- d->connection->flush();
-
- d->gotHello = true;
- qWarning("QDeclarativeDebugServer: Connection established");
- }
-
- QString debugServer(QLatin1String("QDeclarativeDebugServer"));
-
- while (d->protocol->packetsAvailable()) {
- QPacket pack = d->protocol->read();
-
- QString name;
- pack >> name;
-
- if (name == debugServer) {
- int op = -1;
- pack >> op;
-
- if (op == 1) {
- // Service Discovery
- QStringList oldClientPlugins = d->clientPlugins;
- pack >> d->clientPlugins;
-
- QHash<QString, QDeclarativeDebugService*>::Iterator iter = d->plugins.begin();
- for (; iter != d->plugins.end(); ++iter) {
- const QString pluginName = iter.key();
- QDeclarativeDebugService::Status newStatus = QDeclarativeDebugService::Unavailable;
- if (d->clientPlugins.contains(pluginName))
- newStatus = QDeclarativeDebugService::Enabled;
-
- if (oldClientPlugins.contains(pluginName)
- != d->clientPlugins.contains(pluginName)) {
- iter.value()->statusChanged(newStatus);
- }
- }
- } else {
- qWarning("QDeclarativeDebugServer: Invalid control message %d", op);
- }
- } else {
- QByteArray message;
- pack >> message;
-
- QHash<QString, QDeclarativeDebugService *>::Iterator iter =
- d->plugins.find(name);
- if (iter == d->plugins.end()) {
- qWarning() << "QDeclarativeDebugServer: Message received for missing plugin" << name;
- } else {
- (*iter)->messageReceived(message);
- }
- }
- }
-}
-
QDeclarativeDebugServicePrivate::QDeclarativeDebugServicePrivate()
: server(0)
{
@@ -346,16 +59,16 @@ QDeclarativeDebugService::QDeclarativeDebugService(const QString &name, QObject
Q_D(QDeclarativeDebugService);
d->name = name;
d->server = QDeclarativeDebugServer::instance();
+ d->status = QDeclarativeDebugService::NotConnected;
if (!d->server)
return;
- if (d->server->d_func()->plugins.contains(name)) {
+ if (d->server->serviceNames().contains(name)) {
qWarning() << "QDeclarativeDebugService: Conflicting plugin name" << name;
d->server = 0;
} else {
- d->server->d_func()->plugins.insert(name, this);
- d->server->d_func()->advertisePlugins();
+ d->server->addService(this);
}
}
@@ -363,8 +76,7 @@ QDeclarativeDebugService::~QDeclarativeDebugService()
{
Q_D(const QDeclarativeDebugService);
if (d->server) {
- d->server->d_func()->plugins.remove(d->name);
- d->server->d_func()->advertisePlugins();
+ d->server->removeService(this);
}
}
@@ -377,13 +89,7 @@ QString QDeclarativeDebugService::name() const
QDeclarativeDebugService::Status QDeclarativeDebugService::status() const
{
Q_D(const QDeclarativeDebugService);
- if (!d->server
- || !d->server->hasDebuggingClient())
- return NotConnected;
- if (d->server->d_func()->clientPlugins.contains(d->name))
- return Enabled;
-
- return Unavailable;
+ return d->status;
}
namespace {
@@ -500,10 +206,7 @@ void QDeclarativeDebugService::sendMessage(const QByteArray &message)
if (status() != Enabled)
return;
- QPacket pack;
- pack << d->name << message;
- d->server->d_func()->protocol->send(pack);
- d->server->d_func()->connection->flush();
+ d->server->sendMessage(this, message);
}
void QDeclarativeDebugService::statusChanged(Status)
@@ -515,5 +218,3 @@ void QDeclarativeDebugService::messageReceived(const QByteArray &)
}
QT_END_NAMESPACE
-
-#include <qdeclarativedebugservice.moc>
diff --git a/src/declarative/debugger/qdeclarativedebugservice_p_p.h b/src/declarative/debugger/qdeclarativedebugservice_p_p.h
new file mode 100644
index 0000000..d2c8dda
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativedebugservice_p_p.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 QDECLARATIVEDEBUGSERVICE_P_H
+#define QDECLARATIVEDEBUGSERVICE_P_H
+
+#include <QtCore/qglobal.h>
+#include <private/qobject_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeDebugServer;
+
+class QDeclarativeDebugServicePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeDebugService)
+public:
+ QDeclarativeDebugServicePrivate();
+
+ QString name;
+ QDeclarativeDebugServer *server;
+ QDeclarativeDebugService::Status status;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEDEBUGSERVICE_P_H
diff --git a/src/declarative/debugger/qdeclarativedebugtrace.cpp b/src/declarative/debugger/qdeclarativedebugtrace.cpp
index 5b78683..6f28736 100644
--- a/src/declarative/debugger/qdeclarativedebugtrace.cpp
+++ b/src/declarative/debugger/qdeclarativedebugtrace.cpp
@@ -43,11 +43,29 @@
#include <QtCore/qdatastream.h>
#include <QtCore/qurl.h>
+#include <QtCore/qtimer.h>
Q_GLOBAL_STATIC(QDeclarativeDebugTrace, traceInstance);
+// convert to a QByteArray that can be sent to the debug client
+// use of QDataStream can skew results if m_deferredSend == false
+// (see tst_qperformancetimer::trace() benchmark)
+QByteArray QDeclarativeDebugData::toByteArray() const
+{
+ QByteArray data;
+ //### using QDataStream is relatively expensive
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << time << messageType << detailType;
+ if (messageType == (int)QDeclarativeDebugTrace::RangeData)
+ ds << detailData;
+ if (messageType == (int)QDeclarativeDebugTrace::RangeLocation)
+ ds << detailData << line;
+ return data;
+}
+
QDeclarativeDebugTrace::QDeclarativeDebugTrace()
-: QDeclarativeDebugService(QLatin1String("CanvasFrameRate"))
+: QDeclarativeDebugService(QLatin1String("CanvasFrameRate")),
+ m_enabled(false), m_deferredSend(true)
{
m_timer.start();
}
@@ -64,10 +82,28 @@ void QDeclarativeDebugTrace::startRange(RangeType t)
traceInstance()->startRangeImpl(t);
}
-void QDeclarativeDebugTrace::rangeData(RangeType t, const QUrl &url)
+void QDeclarativeDebugTrace::rangeData(RangeType t, const QString &data)
{
if (QDeclarativeDebugService::isDebuggingEnabled())
- traceInstance()->rangeDataImpl(t, url);
+ traceInstance()->rangeDataImpl(t, data);
+}
+
+void QDeclarativeDebugTrace::rangeData(RangeType t, const QUrl &data)
+{
+ if (QDeclarativeDebugService::isDebuggingEnabled())
+ traceInstance()->rangeDataImpl(t, data);
+}
+
+void QDeclarativeDebugTrace::rangeLocation(RangeType t, const QString &fileName, int line)
+{
+ if (QDeclarativeDebugService::isDebuggingEnabled())
+ traceInstance()->rangeLocationImpl(t, fileName, line);
+}
+
+void QDeclarativeDebugTrace::rangeLocation(RangeType t, const QUrl &fileName, int line)
+{
+ if (QDeclarativeDebugService::isDebuggingEnabled())
+ traceInstance()->rangeLocationImpl(t, fileName, line);
}
void QDeclarativeDebugTrace::endRange(RangeType t)
@@ -78,45 +114,105 @@ void QDeclarativeDebugTrace::endRange(RangeType t)
void QDeclarativeDebugTrace::addEventImpl(EventType event)
{
- if (status() != Enabled)
+ if (status() != Enabled || !m_enabled)
return;
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << m_timer.elapsed() << (int)Event << (int)event;
- sendMessage(data);
+ QDeclarativeDebugData ed = {m_timer.elapsed(), (int)Event, (int)event, QString(), -1};
+ processMessage(ed);
}
void QDeclarativeDebugTrace::startRangeImpl(RangeType range)
{
- if (status() != Enabled)
+ if (status() != Enabled || !m_enabled)
return;
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << m_timer.elapsed() << (int)RangeStart << (int)range;
- sendMessage(data);
+ QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeStart, (int)range, QString(), -1};
+ processMessage(rd);
}
-void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QUrl &u)
+void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QString &rData)
{
- if (status() != Enabled)
+ if (status() != Enabled || !m_enabled)
return;
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << m_timer.elapsed() << (int)RangeData << (int)range << (QString)u.toString();
- sendMessage(data);
+ QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeData, (int)range, rData, -1};
+ processMessage(rd);
+}
+
+void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QUrl &rData)
+{
+ if (status() != Enabled || !m_enabled)
+ return;
+
+ QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeData, (int)range, rData.toString(QUrl::FormattingOption(0x100)), -1};
+ processMessage(rd);
+}
+
+void QDeclarativeDebugTrace::rangeLocationImpl(RangeType range, const QString &fileName, int line)
+{
+ if (status() != Enabled || !m_enabled)
+ return;
+
+ QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeLocation, (int)range, fileName, line};
+ processMessage(rd);
+}
+
+void QDeclarativeDebugTrace::rangeLocationImpl(RangeType range, const QUrl &fileName, int line)
+{
+ if (status() != Enabled || !m_enabled)
+ return;
+
+ QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeLocation, (int)range, fileName.toString(QUrl::FormattingOption(0x100)), line};
+ processMessage(rd);
}
void QDeclarativeDebugTrace::endRangeImpl(RangeType range)
{
- if (status() != Enabled)
+ if (status() != Enabled || !m_enabled)
return;
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << m_timer.elapsed() << (int)RangeEnd << (int)range;
- sendMessage(data);
+ QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeEnd, (int)range, QString(), -1};
+ processMessage(rd);
+}
+
+/*
+ Either send the message directly, or queue up
+ a list of messages to send later (via sendMessages)
+*/
+void QDeclarativeDebugTrace::processMessage(const QDeclarativeDebugData &message)
+{
+ if (m_deferredSend)
+ m_data.append(message);
+ else
+ sendMessage(message.toByteArray());
}
+/*
+ Send the messages queued up by processMessage
+*/
+void QDeclarativeDebugTrace::sendMessages()
+{
+ if (m_deferredSend) {
+ //### this is a suboptimal way to send batched messages
+ for (int i = 0; i < m_data.count(); ++i)
+ sendMessage(m_data.at(i).toByteArray());
+ m_data.clear();
+
+ //indicate completion
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << (qint64)-1 << (int)Complete;
+ sendMessage(data);
+ }
+}
+
+void QDeclarativeDebugTrace::messageReceived(const QByteArray &message)
+{
+ QByteArray rwData = message;
+ QDataStream stream(&rwData, QIODevice::ReadOnly);
+
+ stream >> m_enabled;
+
+ if (!m_enabled)
+ sendMessages();
+}
diff --git a/src/declarative/debugger/qdeclarativedebugtrace_p.h b/src/declarative/debugger/qdeclarativedebugtrace_p.h
index 008b618..ae0653e 100644
--- a/src/declarative/debugger/qdeclarativedebugtrace_p.h
+++ b/src/declarative/debugger/qdeclarativedebugtrace_p.h
@@ -43,37 +43,54 @@
#define QDECLARATIVEDEBUGTRACE_P_H
#include <private/qdeclarativedebugservice_p.h>
-#include <QtCore/qelapsedtimer.h>
+#include <private/qperformancetimer_p.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
+struct QDeclarativeDebugData
+{
+ qint64 time;
+ int messageType;
+ int detailType;
+
+ //###
+ QString detailData; //used by RangeData and RangeLocation
+ int line; //used by RangeLocation
+
+ QByteArray toByteArray() const;
+};
+
class QUrl;
class Q_AUTOTEST_EXPORT QDeclarativeDebugTrace : public QDeclarativeDebugService
{
public:
- enum EventType {
- FramePaint,
- Mouse,
- Key,
-
- MaximumEventType
- };
-
enum Message {
Event,
RangeStart,
RangeData,
+ RangeLocation,
RangeEnd,
+ Complete,
MaximumMessage
};
+ enum EventType {
+ FramePaint,
+ Mouse,
+ Key,
+
+ MaximumEventType
+ };
+
enum RangeType {
Painting,
Compiling,
Creating,
+ Binding, //running a binding
+ HandlingSignal, //running a signal handler
MaximumRangeType
};
@@ -81,16 +98,29 @@ public:
static void addEvent(EventType);
static void startRange(RangeType);
+ static void rangeData(RangeType, const QString &);
static void rangeData(RangeType, const QUrl &);
+ static void rangeLocation(RangeType, const QString &, int);
+ static void rangeLocation(RangeType, const QUrl &, int);
static void endRange(RangeType);
QDeclarativeDebugTrace();
+protected:
+ virtual void messageReceived(const QByteArray &);
private:
void addEventImpl(EventType);
void startRangeImpl(RangeType);
+ void rangeDataImpl(RangeType, const QString &);
void rangeDataImpl(RangeType, const QUrl &);
+ void rangeLocationImpl(RangeType, const QString &, int);
+ void rangeLocationImpl(RangeType, const QUrl &, int);
void endRangeImpl(RangeType);
- QElapsedTimer m_timer;
+ void processMessage(const QDeclarativeDebugData &);
+ void sendMessages();
+ QPerformanceTimer m_timer;
+ bool m_enabled;
+ bool m_deferredSend;
+ QList<QDeclarativeDebugData> m_data;
};
QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qpacketprotocol.cpp b/src/declarative/debugger/qpacketprotocol.cpp
index 0adfb76..15a14cf 100644
--- a/src/declarative/debugger/qpacketprotocol.cpp
+++ b/src/declarative/debugger/qpacketprotocol.cpp
@@ -407,6 +407,7 @@ QPacket::QPacket()
buf = new QBuffer(&b);
buf->open(QIODevice::WriteOnly);
setDevice(buf);
+ setVersion(QDataStream::Qt_4_7);
}
/*!
@@ -452,6 +453,14 @@ bool QPacket::isEmpty() const
}
/*!
+ Returns raw packet data.
+ */
+QByteArray QPacket::data() const
+{
+ return b;
+}
+
+/*!
Clears data in the packet. This is useful for reusing one writable packet.
For example
\code
diff --git a/src/declarative/debugger/qpacketprotocol_p.h b/src/declarative/debugger/qpacketprotocol_p.h
index 120579d..accb8ef 100644
--- a/src/declarative/debugger/qpacketprotocol_p.h
+++ b/src/declarative/debugger/qpacketprotocol_p.h
@@ -59,7 +59,7 @@ class QPacket;
class QPacketAutoSend;
class QPacketProtocolPrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QPacketProtocol : public QObject
+class Q_DECLARATIVE_EXPORT QPacketProtocol : public QObject
{
Q_OBJECT
public:
@@ -89,7 +89,7 @@ private:
};
-class Q_DECLARATIVE_PRIVATE_EXPORT QPacket : public QDataStream
+class Q_DECLARATIVE_EXPORT QPacket : public QDataStream
{
public:
QPacket();
@@ -98,6 +98,7 @@ public:
void clear();
bool isEmpty() const;
+ QByteArray data() const;
protected:
friend class QPacketProtocol;
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro
index 4ed4f9f..6bd314f 100644
--- a/src/declarative/declarative.pro
+++ b/src/declarative/declarative.pro
@@ -27,6 +27,13 @@ include(debugger/debugger.pri)
symbian: {
TARGET.UID3=0x2001E623
LIBS += -lefsrv
+
+ contains(QT_CONFIG, freetype) {
+ DEFINES += QT_NO_FONTCONFIG
+ INCLUDEPATH += \
+ ../3rdparty/freetype/src \
+ ../3rdparty/freetype/include
+ }
}
DEFINES += QT_NO_OPENTYPE
diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri
index ffdeb29..9904274 100644
--- a/src/declarative/graphicsitems/graphicsitems.pri
+++ b/src/declarative/graphicsitems/graphicsitems.pri
@@ -50,7 +50,12 @@ HEADERS += \
$$PWD/qdeclarativelayoutitem_p.h \
$$PWD/qdeclarativeitemchangelistener_p.h \
$$PWD/qdeclarativegraphicswidget_p.h \
- $$PWD/qdeclarativetextlayout_p.h
+ $$PWD/qdeclarativetextlayout_p.h \
+ $$PWD/qdeclarativepincharea_p.h \
+ $$PWD/qdeclarativepincharea_p_p.h \
+ $$PWD/qdeclarativeimplicitsizeitem_p.h \
+ $$PWD/qdeclarativeimplicitsizeitem_p_p.h
+
SOURCES += \
$$PWD/qdeclarativeitemsmodule.cpp \
@@ -83,5 +88,7 @@ SOURCES += \
$$PWD/qdeclarativelistview.cpp \
$$PWD/qdeclarativelayoutitem.cpp \
$$PWD/qdeclarativegraphicswidget.cpp \
- $$PWD/qdeclarativetextlayout.cpp
+ $$PWD/qdeclarativetextlayout.cpp \
+ $$PWD/qdeclarativepincharea.cpp \
+ $$PWD/qdeclarativeimplicitsizeitem.cpp
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
index 4729817..016b87d 100644
--- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
@@ -86,6 +86,25 @@ QT_BEGIN_NAMESPACE
\sa BorderImage, Image
*/
+/*!
+ \qmlproperty bool AnimatedImage::cache
+ \since Quick 1.1
+
+ Specifies whether the image should be cached. The default value is
+ true. Setting \a cache to false is useful when dealing with large images,
+ to make sure that they aren't cached at the expense of small 'ui element' images.
+*/
+
+/*!
+ \qmlproperty bool AnimatedImage::mirror
+ \since Quick 1.1
+
+ This property holds whether the image should be horizontally inverted
+ (effectively displaying a mirrored image).
+
+ The default value is false.
+*/
+
QDeclarativeAnimatedImage::QDeclarativeAnimatedImage(QDeclarativeItem *parent)
: QDeclarativeImage(*(new QDeclarativeAnimatedImagePrivate), parent)
{
@@ -126,7 +145,7 @@ void QDeclarativeAnimatedImage::setPaused(bool pause)
\qmlproperty bool AnimatedImage::playing
This property holds whether the animated image is playing.
- By defaults, this property is true, meaning that the animation
+ By default, this property is true, meaning that the animation
will start playing immediately.
*/
bool QDeclarativeAnimatedImage::isPlaying() const
@@ -202,13 +221,22 @@ void QDeclarativeAnimatedImage::setSource(const QUrl &url)
}
d->url = url;
+ emit sourceChanged(d->url);
+
+ if (isComponentComplete())
+ load();
+}
+
+void QDeclarativeAnimatedImage::load()
+{
+ Q_D(QDeclarativeAnimatedImage);
- if (url.isEmpty()) {
+ if (d->url.isEmpty()) {
delete d->_movie;
d->status = Null;
} else {
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url);
if (!lf.isEmpty()) {
//### should be unified with movieRequestFinished
d->_movie = new QMovie(lf);
@@ -216,6 +244,8 @@ void QDeclarativeAnimatedImage::setSource(const QUrl &url)
qmlInfo(this) << "Error Reading Animated Image File " << d->url.toString();
delete d->_movie;
d->_movie = 0;
+ d->status = Error;
+ emit statusChanged(d->status);
return;
}
connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),
@@ -245,7 +275,6 @@ void QDeclarativeAnimatedImage::setSource(const QUrl &url)
QObject::connect(d->reply, SIGNAL(finished()),
this, SLOT(movieRequestFinished()));
}
-
emit statusChanged(d->status);
}
@@ -275,6 +304,8 @@ void QDeclarativeAnimatedImage::movieRequestFinished()
#endif
delete d->_movie;
d->_movie = 0;
+ d->status = Error;
+ emit statusChanged(d->status);
return;
}
connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),
@@ -291,6 +322,8 @@ void QDeclarativeAnimatedImage::movieRequestFinished()
if(d->paused)
d->_movie->setPaused(true);
d->setPixmap(d->_movie->currentPixmap());
+ d->status = Ready;
+ emit statusChanged(d->status);
}
void QDeclarativeAnimatedImage::movieUpdate()
@@ -317,6 +350,8 @@ void QDeclarativeAnimatedImage::componentComplete()
{
Q_D(QDeclarativeAnimatedImage);
QDeclarativeItem::componentComplete(); // NOT QDeclarativeImage
+ if (d->url.isValid())
+ load();
if (!d->reply) {
setCurrentFrame(d->preset_currentframe);
d->preset_currentframe = 0;
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h
index e5025bf..e2ed70b 100644
--- a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h
@@ -97,6 +97,7 @@ private Q_SLOTS:
void playingStatusChanged();
protected:
+ virtual void load();
void componentComplete();
private:
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
index 16fb376..c03c624 100644
--- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
@@ -200,6 +200,16 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage()
*/
/*!
+ \qmlproperty bool BorderImage::mirror
+ \since Quick 1.1
+
+ This property holds whether the image should be horizontally inverted
+ (effectively displaying a mirrored image).
+
+ The default value is false.
+*/
+
+/*!
\qmlproperty url BorderImage::source
This property holds the URL that refers to the source image.
@@ -215,17 +225,29 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage()
image \c picture.png:
\qml
- border.left: 10
- border.top: 10
- border.bottom: 10
- border.right: 10
- source: picture.png
+ BorderImage {
+ border.left: 10
+ border.top: 10
+ border.bottom: 10
+ border.right: 10
+ source: "picture.png"
+ }
\endqml
The URL may be absolute, or relative to the URL of the component.
\sa QDeclarativeImageProvider
*/
+
+/*!
+ \qmlproperty QSize BorderImage::sourceSize
+
+ This property holds the actual width and height of the loaded image.
+
+ In BorderImage, this property is read-only.
+
+ \sa Image::sourceSize
+*/
void QDeclarativeBorderImage::setSource(const QUrl &url)
{
Q_D(QDeclarativeBorderImage);
@@ -290,7 +312,12 @@ void QDeclarativeBorderImage::load()
}
} else {
- d->pix.load(qmlEngine(this), d->url, d->async);
+ QDeclarativePixmap::Options options;
+ if (d->async)
+ options |= QDeclarativePixmap::Asynchronous;
+ if (d->cache)
+ options |= QDeclarativePixmap::Cache;
+ d->pix.load(qmlEngine(this), d->url, options);
if (d->pix.isLoading()) {
d->pix.connectFinished(this, SLOT(requestFinished()));
@@ -310,6 +337,7 @@ void QDeclarativeBorderImage::load()
d->progress = 1.0;
emit statusChanged(d->status);
emit progressChanged(d->progress);
+ requestFinished();
update();
}
}
@@ -337,7 +365,10 @@ void QDeclarativeBorderImage::load()
the bottom of the image:
\qml
- border.bottom: 10
+ BorderImage {
+ border.bottom: 10
+ // ...
+ }
\endqml
The border lines can also be specified using a
@@ -413,7 +444,12 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma
d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl()));
- d->pix.load(qmlEngine(this), d->sciurl, d->async);
+ QDeclarativePixmap::Options options;
+ if (d->async)
+ options |= QDeclarativePixmap::Asynchronous;
+ if (d->cache)
+ options |= QDeclarativePixmap::Cache;
+ d->pix.load(qmlEngine(this), d->sciurl, options);
if (d->pix.isLoading()) {
static int thisRequestProgress = -1;
@@ -465,6 +501,9 @@ void QDeclarativeBorderImage::requestFinished()
setImplicitWidth(impsize.width());
setImplicitHeight(impsize.height());
+ if (d->sourcesize.width() != d->pix.width() || d->sourcesize.height() != d->pix.height())
+ emit sourceSizeChanged();
+
d->progress = 1.0;
emit statusChanged(d->status);
emit progressChanged(1.0);
@@ -514,8 +553,15 @@ void QDeclarativeBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem
bool oldAA = p->testRenderHint(QPainter::Antialiasing);
bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
+ QTransform oldTransform;
if (d->smooth)
p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
+ if (d->mirror) {
+ oldTransform = p->transform();
+ QTransform mirror;
+ mirror.translate(d->width(), 0).scale(-1, 1.0);
+ p->setWorldTransform(mirror * oldTransform);
+ }
const QDeclarativeScaleGrid *border = d->getScaleGrid();
int left = border->left();
@@ -541,6 +587,8 @@ void QDeclarativeBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem
p->setRenderHint(QPainter::Antialiasing, oldAA);
p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
}
+ if (d->mirror)
+ p->setWorldTransform(oldTransform);
}
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage_p.h b/src/declarative/graphicsitems/qdeclarativeborderimage_p.h
index ca1eae8..f4c6594 100644
--- a/src/declarative/graphicsitems/qdeclarativeborderimage_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage_p.h
@@ -63,6 +63,9 @@ class Q_AUTOTEST_EXPORT QDeclarativeBorderImage : public QDeclarativeImageBase
Q_PROPERTY(TileMode horizontalTileMode READ horizontalTileMode WRITE setHorizontalTileMode NOTIFY horizontalTileModeChanged)
Q_PROPERTY(TileMode verticalTileMode READ verticalTileMode WRITE setVerticalTileMode NOTIFY verticalTileModeChanged)
+ // read-only for BorderImage
+ Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged)
+
public:
QDeclarativeBorderImage(QDeclarativeItem *parent=0);
~QDeclarativeBorderImage();
@@ -83,6 +86,7 @@ public:
Q_SIGNALS:
void horizontalTileModeChanged();
void verticalTileModeChanged();
+ void sourceSizeChanged();
protected:
virtual void load();
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index db63cda..1f1b39a 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -53,6 +53,10 @@ QT_BEGIN_NAMESPACE
// before we perform a flick.
static const int FlickThreshold = 20;
+// RetainGrabVelocity is the maxmimum instantaneous velocity that
+// will ensure the Flickable retains the grab on consecutive flicks.
+static const int RetainGrabVelocity = 15;
+
QDeclarativeFlickableVisibleArea::QDeclarativeFlickableVisibleArea(QDeclarativeFlickable *parent)
: QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.)
, m_yPosition(0.), m_heightRatio(0.)
@@ -299,7 +303,7 @@ void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal
timeline.move(data.move, maxExtent - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
timeline.move(data.move, maxExtent, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4);
} else {
- timeline.set(data.move, minExtent);
+ timeline.set(data.move, maxExtent);
}
}
vTime = timeline.time();
@@ -373,9 +377,9 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd()
\section1 Example Usage
- \beginfloatright
+ \div {float-right}
\inlineimage flickable.gif
- \endfloat
+ \enddiv
The following example shows a small view onto a large image in which the
user can drag or flick the image in order to view different parts of it.
@@ -672,7 +676,8 @@ void QDeclarativeFlickable::setFlickableDirection(FlickableDirection direction)
void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_Q(QDeclarativeFlickable);
- if (interactive && timeline.isActive() && (qAbs(hData.velocity) > 10 || qAbs(vData.velocity) > 10))
+ if (interactive && timeline.isActive()
+ && (qAbs(hData.smoothVelocity.value()) > RetainGrabVelocity || qAbs(vData.smoothVelocity.value()) > RetainGrabVelocity))
stealMouse = true; // If we've been flicked then steal the click.
else
stealMouse = false;
@@ -840,7 +845,8 @@ void QDeclarativeFlickable::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeFlickable);
if (d->interactive) {
- d->handleMousePressEvent(event);
+ if (!d->pressed)
+ d->handleMousePressEvent(event);
event->accept();
} else {
QDeclarativeItem::mousePressEvent(event);
@@ -876,7 +882,7 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event)
Q_D(QDeclarativeFlickable);
if (!d->interactive) {
QDeclarativeItem::wheelEvent(event);
- } else if (yflick()) {
+ } else if (yflick() && event->orientation() == Qt::Vertical) {
if (event->delta() > 0)
d->vData.velocity = qMax(event->delta() - d->vData.smoothVelocity.value(), qreal(250.0));
else
@@ -888,7 +894,7 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event)
movementStarting();
}
event->accept();
- } else if (xflick()) {
+ } else if (xflick() && event->orientation() == Qt::Horizontal) {
if (event->delta() > 0)
d->hData.velocity = qMax(event->delta() - d->hData.smoothVelocity.value(), qreal(250.0));
else
@@ -905,11 +911,27 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event)
}
}
+bool QDeclarativeFlickablePrivate::isOutermostPressDelay() const
+{
+ Q_Q(const QDeclarativeFlickable);
+ QDeclarativeItem *item = q->parentItem();
+ while (item) {
+ QDeclarativeFlickable *flick = qobject_cast<QDeclarativeFlickable*>(item);
+ if (flick && flick->pressDelay() > 0 && flick->isInteractive())
+ return false;
+ item = item->parentItem();
+ }
+
+ return true;
+}
+
void QDeclarativeFlickablePrivate::captureDelayedPress(QGraphicsSceneMouseEvent *event)
{
Q_Q(QDeclarativeFlickable);
if (!q->scene() || pressDelay <= 0)
return;
+ if (!isOutermostPressDelay())
+ return;
delayedPressTarget = q->scene()->mouseGrabberItem();
delayedPressEvent = new QGraphicsSceneMouseEvent(event->type());
delayedPressEvent->setAccepted(false);
@@ -965,9 +987,10 @@ void QDeclarativeFlickable::timerEvent(QTimerEvent *event)
if (scene()->mouseGrabberItem() == d->delayedPressTarget)
d->delayedPressTarget->ungrabMouse();
//Use the event handler that will take care of finding the proper item to propagate the event
- QApplication::sendEvent(scene(), d->delayedPressEvent);
+ QApplication::postEvent(scene(), d->delayedPressEvent);
+ } else {
+ delete d->delayedPressEvent;
}
- delete d->delayedPressEvent;
d->delayedPressEvent = 0;
}
}
@@ -1250,6 +1273,60 @@ void QDeclarativeFlickable::setContentHeight(qreal h)
d->updateBeginningEnd();
}
+/*!
+ \qmlmethod Flickable::resizeContent(real width, real height, QPointF center)
+ \preliminary
+
+ Resizes the content to \a width x \a height about \a center.
+
+ \bold {This method was added in QtQuick 1.1.}
+
+ This does not scale the contents of the Flickable - it only resizes the \l contentWidth
+ and \l contentHeight.
+
+ Resizing the content may result in the content being positioned outside
+ the bounds of the Flickable. Calling \l returnToBounds() will
+ move the content back within legal bounds.
+*/
+void QDeclarativeFlickable::resizeContent(qreal w, qreal h, QPointF center)
+{
+ Q_D(QDeclarativeFlickable);
+ if (w != d->hData.viewSize) {
+ qreal oldSize = d->hData.viewSize;
+ setContentWidth(w);
+ if (center.x() != 0) {
+ qreal pos = center.x() * w / oldSize;
+ setContentX(contentX() + pos - center.x());
+ }
+ }
+ if (h != d->vData.viewSize) {
+ qreal oldSize = d->vData.viewSize;
+ setContentHeight(h);
+ if (center.y() != 0) {
+ qreal pos = center.y() * h / oldSize;
+ setContentY(contentY() + pos - center.y());
+ }
+ }
+}
+
+/*!
+ \qmlmethod Flickable::returnToBounds()
+ \preliminary
+
+ Ensures the content is within legal bounds.
+
+ \bold {This method was added in QtQuick 1.1.}
+
+ This may be called to ensure that the content is within legal bounds
+ after manually positioning the content.
+*/
+void QDeclarativeFlickable::returnToBounds()
+{
+ Q_D(QDeclarativeFlickable);
+ d->fixupX();
+ d->fixupY();
+}
+
qreal QDeclarativeFlickable::vWidth() const
{
Q_D(const QDeclarativeFlickable);
@@ -1284,6 +1361,22 @@ bool QDeclarativeFlickable::yflick() const
return d->flickableDirection & QDeclarativeFlickable::VerticalFlick;
}
+bool QDeclarativeFlickable::sceneEvent(QEvent *event)
+{
+ bool rv = QDeclarativeItem::sceneEvent(event);
+ if (event->type() == QEvent::UngrabMouse) {
+ Q_D(QDeclarativeFlickable);
+ if (d->pressed) {
+ // if our mouse grab has been removed (probably by another Flickable),
+ // fix our state
+ d->pressed = false;
+ d->stealMouse = false;
+ setKeepMouseGrab(false);
+ }
+ }
+ return rv;
+}
+
bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeFlickable);
@@ -1311,7 +1404,7 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
d->handleMouseMoveEvent(&mouseEvent);
break;
case QEvent::GraphicsSceneMousePress:
- if (d->delayedPressEvent)
+ if (d->pressed) // we are already pressed - this is a delayed replay
return false;
d->handleMousePressEvent(&mouseEvent);
@@ -1330,6 +1423,8 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
// We send the release
scene()->sendEvent(s->mouseGrabberItem(), event);
// And the event has been consumed
+ d->stealMouse = false;
+ d->pressed = false;
return true;
}
d->handleMouseReleaseEvent(&mouseEvent);
@@ -1352,6 +1447,7 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
d->stealMouse = false;
d->pressed = false;
}
+
return false;
}
@@ -1450,6 +1546,9 @@ bool QDeclarativeFlickable::isFlickingVertically() const
If the flickable is dragged/flicked before the delay times out
the press event will not be delivered. If the button is released
within the timeout, both the press and release will be delivered.
+
+ Note that for nested Flickables with pressDelay set, the pressDelay of
+ inner Flickables is overridden by the outermost Flickable.
*/
int QDeclarativeFlickable::pressDelay() const
{
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
index 1359dc8..a14cc1c 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
@@ -149,6 +149,9 @@ public:
FlickableDirection flickableDirection() const;
void setFlickableDirection(FlickableDirection);
+ Q_INVOKABLE Q_REVISION(1) void resizeContent(qreal w, qreal h, QPointF center);
+ Q_INVOKABLE Q_REVISION(1) void returnToBounds();
+
Q_SIGNALS:
void contentWidthChanged();
void contentHeightChanged();
@@ -201,6 +204,7 @@ protected:
virtual void viewportMoved();
virtual void geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry);
+ bool sceneEvent(QEvent *event);
bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
bool xflick() const;
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
index 5ad6ff6..1b6081c 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
@@ -118,6 +118,7 @@ public:
void updateBeginningEnd();
+ bool isOutermostPressDelay() const;
void captureDelayedPress(QGraphicsSceneMouseEvent *event);
void clearDelayedPress();
diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
index 160872c..5fda758 100644
--- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
@@ -142,6 +142,7 @@ void QDeclarativeFlipable::setFront(QGraphicsObject *front)
d->front->setParentItem(this);
if (Back == d->current)
d->front->setOpacity(0.);
+ emit frontChanged();
}
QGraphicsObject *QDeclarativeFlipable::back()
@@ -165,6 +166,7 @@ void QDeclarativeFlipable::setBack(QGraphicsObject *back)
this, SLOT(retransformBack()));
connect(back, SIGNAL(heightChanged()),
this, SLOT(retransformBack()));
+ emit backChanged();
}
void QDeclarativeFlipable::retransformBack()
diff --git a/src/declarative/graphicsitems/qdeclarativeflipable_p.h b/src/declarative/graphicsitems/qdeclarativeflipable_p.h
index c294697..4ea2ec0 100644
--- a/src/declarative/graphicsitems/qdeclarativeflipable_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflipable_p.h
@@ -60,8 +60,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeFlipable : public QDeclarativeItem
Q_OBJECT
Q_ENUMS(Side)
- Q_PROPERTY(QGraphicsObject *front READ front WRITE setFront)
- Q_PROPERTY(QGraphicsObject *back READ back WRITE setBack)
+ Q_PROPERTY(QGraphicsObject *front READ front WRITE setFront NOTIFY frontChanged)
+ Q_PROPERTY(QGraphicsObject *back READ back WRITE setBack NOTIFY backChanged)
Q_PROPERTY(Side side READ side NOTIFY sideChanged)
//### flipAxis
//### flipRotation
@@ -79,6 +79,8 @@ public:
Side side() const;
Q_SIGNALS:
+ void frontChanged();
+ void backChanged();
void sideChanged();
private Q_SLOTS:
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 89d7493..6d2285d 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -82,7 +82,7 @@ public:
item->setPos(QPointF(row, col));
}
}
- bool contains(int x, int y) const {
+ bool contains(qreal x, qreal y) const {
return (x >= item->x() && x < item->x() + view->cellWidth() &&
y >= item->y() && y < item->y() + view->cellHeight());
}
@@ -331,11 +331,14 @@ public:
}
}
} else if ((header && header->item == item) || (footer && footer->item == item)) {
- updateHeader();
- updateFooter();
+ if (header)
+ updateHeader();
+ if (footer)
+ updateFooter();
}
}
+ void positionViewAtIndex(int index, int mode);
virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent);
virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity);
@@ -1095,9 +1098,9 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
\snippet doc/src/snippets/declarative/gridview/ContactModel.qml 0
- \beginfloatright
+ \div {float-right}
\inlineimage gridview-simple.png
- \endfloat
+ \enddiv
This model can be referenced as \c ContactModel in other QML files. See \l{QML Modules}
for more information about creating reusable components like this.
@@ -1111,9 +1114,9 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
\codeline
\snippet doc/src/snippets/declarative/gridview/gridview.qml classdocs simple
- \beginfloatright
+ \div {float-right}
\inlineimage gridview-highlight.png
- \endfloat
+ \enddiv
The view will create a new delegate for each item in the model. Note that the delegate
is able to access the model's \c name and \c portrait data directly.
@@ -1615,6 +1618,8 @@ void QDeclarativeGridView::setFlow(Flow flow)
setContentHeight(-1);
setFlickableDirection(QDeclarativeFlickable::HorizontalFlick);
}
+ setContentX(0);
+ setContentY(0);
d->clear();
d->updateGrid();
refill();
@@ -1776,6 +1781,9 @@ void QDeclarativeGridView::setFooter(QDeclarativeComponent *footer)
Q_D(QDeclarativeGridView);
if (d->footerComponent != footer) {
if (d->footer) {
+ if (scene())
+ scene()->removeItem(d->footer->item);
+ d->footer->item->deleteLater();
delete d->footer;
d->footer = 0;
}
@@ -1783,6 +1791,7 @@ void QDeclarativeGridView::setFooter(QDeclarativeComponent *footer)
if (isComponentComplete()) {
d->updateFooter();
d->updateGrid();
+ d->fixupPosition();
}
emit footerChanged();
}
@@ -1808,6 +1817,9 @@ void QDeclarativeGridView::setHeader(QDeclarativeComponent *header)
Q_D(QDeclarativeGridView);
if (d->headerComponent != header) {
if (d->header) {
+ if (scene())
+ scene()->removeItem(d->header->item);
+ d->header->item->deleteLater();
delete d->header;
d->header = 0;
}
@@ -1816,6 +1828,7 @@ void QDeclarativeGridView::setHeader(QDeclarativeComponent *header)
d->updateHeader();
d->updateFooter();
d->updateGrid();
+ d->fixupPosition();
}
emit headerChanged();
}
@@ -2122,6 +2135,78 @@ void QDeclarativeGridView::moveCurrentIndexRight()
}
}
+void QDeclarativeGridViewPrivate::positionViewAtIndex(int index, int mode)
+{
+ Q_Q(QDeclarativeGridView);
+ if (!isValid())
+ return;
+ if (mode < QDeclarativeGridView::Beginning || mode > QDeclarativeGridView::Contain)
+ return;
+
+ int idx = qMax(qMin(index, model->count()-1), 0);
+
+ if (layoutScheduled)
+ layout();
+ qreal pos = position();
+ FxGridItem *item = visibleItem(idx);
+ qreal maxExtent = flow == QDeclarativeGridView::LeftToRight ? -q->maxYExtent() : -q->maxXExtent();
+ if (!item) {
+ int itemPos = rowPosAt(idx);
+ // save the currently visible items in case any of them end up visible again
+ QList<FxGridItem*> oldVisible = visibleItems;
+ visibleItems.clear();
+ visibleIndex = idx - idx % columns;
+ maxExtent = flow == QDeclarativeGridView::LeftToRight ? -q->maxYExtent() : -q->maxXExtent();
+ setPosition(qMin(qreal(itemPos), maxExtent));
+ // now release the reference to all the old visible items.
+ for (int i = 0; i < oldVisible.count(); ++i)
+ releaseItem(oldVisible.at(i));
+ item = visibleItem(idx);
+ }
+ if (item) {
+ qreal itemPos = item->rowPos();
+ switch (mode) {
+ case QDeclarativeGridView::Beginning:
+ pos = itemPos;
+ if (index < 0 && header) {
+ pos -= flow == QDeclarativeGridView::LeftToRight
+ ? header->item->height()
+ : header->item->width();
+ }
+ break;
+ case QDeclarativeGridView::Center:
+ pos = itemPos - (size() - rowSize())/2;
+ break;
+ case QDeclarativeGridView::End:
+ pos = itemPos - size() + rowSize();
+ if (index >= model->count() && footer) {
+ pos += flow == QDeclarativeGridView::LeftToRight
+ ? footer->item->height()
+ : footer->item->width();
+ }
+ break;
+ case QDeclarativeGridView::Visible:
+ if (itemPos > pos + size())
+ pos = itemPos - size() + rowSize();
+ else if (item->endRowPos() < pos)
+ pos = itemPos;
+ break;
+ case QDeclarativeGridView::Contain:
+ if (item->endRowPos() > pos + size())
+ pos = itemPos - size() + rowSize();
+ if (itemPos < pos)
+ pos = itemPos;
+ }
+ pos = qMin(pos, maxExtent);
+ qreal minExtent = flow == QDeclarativeGridView::LeftToRight ? -q->minYExtent() : -q->minXExtent();
+ pos = qMax(pos, minExtent);
+ moveReason = QDeclarativeGridViewPrivate::Other;
+ q->cancelFlick();
+ setPosition(pos);
+ }
+ fixupPosition();
+}
+
/*!
\qmlmethod GridView::positionViewAtIndex(int index, PositionMode mode)
@@ -2159,58 +2244,42 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode)
Q_D(QDeclarativeGridView);
if (!d->isValid() || index < 0 || index >= d->model->count())
return;
- if (mode < Beginning || mode > Contain)
+ d->positionViewAtIndex(index, mode);
+}
+
+/*!
+ \qmlmethod GridView::positionViewAtBeginning()
+ \qmlmethod GridView::positionViewAtEnd()
+
+ Positions the view at the beginning or end, taking into account any header or footer.
+
+ It is not recommended to use \l {Flickable::}{contentX} or \l {Flickable::}{contentY} to position the view
+ at a particular index. This is unreliable since removing items from the start
+ of the list does not cause all other items to be repositioned, and because
+ the actual start of the view can vary based on the size of the delegates.
+
+ \bold Note: methods should only be called after the Component has completed. To position
+ the view at startup, this method should be called by Component.onCompleted. For
+ example, to position the view at the end on startup:
+
+ \code
+ Component.onCompleted: positionViewAtEnd()
+ \endcode
+*/
+void QDeclarativeGridView::positionViewAtBeginning()
+{
+ Q_D(QDeclarativeGridView);
+ if (!d->isValid())
return;
+ d->positionViewAtIndex(-1, Beginning);
+}
- if (d->layoutScheduled)
- d->layout();
- qreal pos = d->position();
- FxGridItem *item = d->visibleItem(index);
- if (!item) {
- int itemPos = d->rowPosAt(index);
- // save the currently visible items in case any of them end up visible again
- QList<FxGridItem*> oldVisible = d->visibleItems;
- d->visibleItems.clear();
- d->visibleIndex = index - index % d->columns;
- d->setPosition(itemPos);
- // now release the reference to all the old visible items.
- for (int i = 0; i < oldVisible.count(); ++i)
- d->releaseItem(oldVisible.at(i));
- item = d->visibleItem(index);
- }
- if (item) {
- qreal itemPos = item->rowPos();
- switch (mode) {
- case Beginning:
- pos = itemPos;
- break;
- case Center:
- pos = itemPos - (d->size() - d->rowSize())/2;
- break;
- case End:
- pos = itemPos - d->size() + d->rowSize();
- break;
- case Visible:
- if (itemPos > pos + d->size())
- pos = itemPos - d->size() + d->rowSize();
- else if (item->endRowPos() < pos)
- pos = itemPos;
- break;
- case Contain:
- if (item->endRowPos() > pos + d->size())
- pos = itemPos - d->size() + d->rowSize();
- if (itemPos < pos)
- pos = itemPos;
- }
- qreal maxExtent = d->flow == QDeclarativeGridView::LeftToRight ? -maxYExtent() : -maxXExtent();
- pos = qMin(pos, maxExtent);
- qreal minExtent = d->flow == QDeclarativeGridView::LeftToRight ? -minYExtent() : -minXExtent();
- pos = qMax(pos, minExtent);
- d->moveReason = QDeclarativeGridViewPrivate::Other;
- cancelFlick();
- d->setPosition(pos);
- }
- d->fixupPosition();
+void QDeclarativeGridView::positionViewAtEnd()
+{
+ Q_D(QDeclarativeGridView);
+ if (!d->isValid())
+ return;
+ d->positionViewAtIndex(d->model->count(), End);
}
/*!
@@ -2225,7 +2294,7 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode)
\bold Note: methods should only be called after the Component has completed.
*/
-int QDeclarativeGridView::indexAt(int x, int y) const
+int QDeclarativeGridView::indexAt(qreal x, qreal y) const
{
Q_D(const QDeclarativeGridView);
for (int i = 0; i < d->visibleItems.count(); ++i) {
@@ -2321,24 +2390,9 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
Q_D(QDeclarativeGridView);
if (!isComponentComplete())
return;
- if (!d->visibleItems.count() || d->model->count() <= 1) {
- d->scheduleLayout();
- if (d->itemCount && d->currentIndex >= modelIndex) {
- // adjust current item index
- d->currentIndex += count;
- if (d->currentItem)
- d->currentItem->index = d->currentIndex;
- emit currentIndexChanged();
- } else if (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared)) {
- d->updateCurrent(0);
- }
- d->itemCount += count;
- emit countChanged();
- return;
- }
- int index = d->mapFromModel(modelIndex);
- if (index == -1) {
+ int index = d->visibleItems.count() ? d->mapFromModel(modelIndex) : 0;
+ if (index < 0) {
int i = d->visibleItems.count() - 1;
while (i > 0 && d->visibleItems.at(i)->index == -1)
--i;
@@ -2369,28 +2423,35 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
}
}
- // At least some of the added items will be visible
int insertCount = count;
- if (index < d->visibleIndex) {
+ if (index < d->visibleIndex && d->visibleItems.count()) {
insertCount -= d->visibleIndex - index;
index = d->visibleIndex;
modelIndex = d->visibleIndex;
}
- index -= d->visibleIndex;
int to = d->buffer+d->position()+d->size()-1;
- int colPos, rowPos;
- if (index < d->visibleItems.count()) {
- colPos = d->visibleItems.at(index)->colPos();
- rowPos = d->visibleItems.at(index)->rowPos();
- } else {
- // appending items to visible list
- colPos = d->visibleItems.at(index-1)->colPos() + d->colSize();
- rowPos = d->visibleItems.at(index-1)->rowPos();
- if (colPos > d->colSize() * (d->columns-1)) {
- colPos = 0;
- rowPos += d->rowSize();
+ int colPos = 0;
+ int rowPos = 0;
+ if (d->visibleItems.count()) {
+ index -= d->visibleIndex;
+ if (index < d->visibleItems.count()) {
+ colPos = d->visibleItems.at(index)->colPos();
+ rowPos = d->visibleItems.at(index)->rowPos();
+ } else {
+ // appending items to visible list
+ colPos = d->visibleItems.at(index-1)->colPos() + d->colSize();
+ rowPos = d->visibleItems.at(index-1)->rowPos();
+ if (colPos > d->colSize() * (d->columns-1)) {
+ colPos = 0;
+ rowPos += d->rowSize();
+ }
}
+ } else if (d->itemCount == 0 && d->header) {
+ if (d->flow == QDeclarativeGridView::LeftToRight)
+ rowPos = d->headerSize();
+ else
+ colPos = d->headerSize();
}
// Update the indexes of the following visible items.
@@ -2443,6 +2504,8 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
if (d->currentItem) {
d->currentItem->index = d->currentIndex;
d->currentItem->setPosition(d->colPosAt(d->currentIndex), d->rowPosAt(d->currentIndex));
+ } else if (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared)) {
+ d->updateCurrent(0);
}
emit currentIndexChanged();
}
@@ -2560,12 +2623,8 @@ void QDeclarativeGridView::itemsMoved(int from, int to, int count)
return;
QHash<int,FxGridItem*> moved;
- bool removedBeforeVisible = false;
FxGridItem *firstItem = d->firstVisibleItem();
- if (from < to && from < d->visibleIndex && to > d->visibleIndex)
- removedBeforeVisible = true;
-
QList<FxGridItem*>::Iterator it = d->visibleItems.begin();
while (it != d->visibleItems.end()) {
FxGridItem *item = *it;
@@ -2574,16 +2633,12 @@ void QDeclarativeGridView::itemsMoved(int from, int to, int count)
item->index += (to-from);
moved.insert(item->index, item);
it = d->visibleItems.erase(it);
- if (item->rowPos() < firstItem->rowPos())
- removedBeforeVisible = true;
} else {
if (item->index > from && item->index != -1) {
// move everything after the moved items.
item->index -= count;
if (item->index < d->visibleIndex)
d->visibleIndex = item->index;
- } else if (item->index != -1) {
- removedBeforeVisible = true;
}
++it;
}
diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h
index 7dc8954..e68a9ba 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h
@@ -158,7 +158,9 @@ public:
enum PositionMode { Beginning, Center, End, Visible, Contain };
Q_INVOKABLE void positionViewAtIndex(int index, int mode);
- Q_INVOKABLE int indexAt(int x, int y) const;
+ Q_INVOKABLE int indexAt(qreal x, qreal y) const;
+ Q_INVOKABLE Q_REVISION(1) void positionViewAtBeginning();
+ Q_INVOKABLE Q_REVISION(1) void positionViewAtEnd();
static QDeclarativeGridViewAttached *qmlAttachedProperties(QObject *);
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index e90a4df..2c9bde5 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -458,84 +458,102 @@ QRectF QDeclarativeImage::boundingRect() const
are always loaded asynchonously.
*/
+/*!
+ \qmlproperty bool Image::cache
+ \since Quick 1.1
+
+ Specifies whether the image should be cached. The default value is
+ true. Setting \a cache to false is useful when dealing with large images,
+ to make sure that they aren't cached at the expense of small 'ui element' images.
+*/
+
+/*!
+ \qmlproperty bool Image::mirror
+ \since Quick 1.1
+
+ This property holds whether the image should be horizontally inverted
+ (effectively displaying a mirrored image).
+
+ The default value is false.
+*/
+
+
void QDeclarativeImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_D(QDeclarativeImage);
if (d->pix.pixmap().isNull() )
return;
- bool oldAA = p->testRenderHint(QPainter::Antialiasing);
- bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
- if (d->smooth)
- p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
+ int drawWidth = width();
+ int drawHeight = height();
+ bool doClip = false;
+ QTransform transform;
+ qreal widthScale = width() / qreal(d->pix.width());
+ qreal heightScale = height() / qreal(d->pix.height());
if (width() != d->pix.width() || height() != d->pix.height()) {
if (d->fillMode >= Tile) {
- if (d->fillMode == Tile) {
- p->drawTiledPixmap(QRectF(0,0,width(),height()), d->pix);
- } else {
- qreal widthScale = width() / qreal(d->pix.width());
- qreal heightScale = height() / qreal(d->pix.height());
-
- QTransform scale;
- if (d->fillMode == TileVertically) {
- scale.scale(widthScale, 1.0);
- QTransform old = p->transform();
- p->setWorldTransform(scale * old);
- p->drawTiledPixmap(QRectF(0,0,d->pix.width(),height()), d->pix);
- p->setWorldTransform(old);
- } else {
- scale.scale(1.0, heightScale);
- QTransform old = p->transform();
- p->setWorldTransform(scale * old);
- p->drawTiledPixmap(QRectF(0,0,width(),d->pix.height()), d->pix);
- p->setWorldTransform(old);
- }
+ if (d->fillMode == TileVertically) {
+ transform.scale(widthScale, 1.0);
+ drawWidth = d->pix.width();
+ } else if (d->fillMode == TileHorizontally) {
+ transform.scale(1.0, heightScale);
+ drawHeight = d->pix.height();
}
} else {
- qreal widthScale = width() / qreal(d->pix.width());
- qreal heightScale = height() / qreal(d->pix.height());
-
- QTransform scale;
-
if (d->fillMode == PreserveAspectFit) {
if (widthScale <= heightScale) {
heightScale = widthScale;
- scale.translate(0, (height() - heightScale * d->pix.height()) / 2);
+ transform.translate(0, (height() - heightScale * d->pix.height()) / 2);
} else if(heightScale < widthScale) {
widthScale = heightScale;
- scale.translate((width() - widthScale * d->pix.width()) / 2, 0);
+ transform.translate((width() - widthScale * d->pix.width()) / 2, 0);
}
} else if (d->fillMode == PreserveAspectCrop) {
if (widthScale < heightScale) {
widthScale = heightScale;
- scale.translate((width() - widthScale * d->pix.width()) / 2, 0);
+ transform.translate((width() - widthScale * d->pix.width()) / 2, 0);
} else if(heightScale < widthScale) {
heightScale = widthScale;
- scale.translate(0, (height() - heightScale * d->pix.height()) / 2);
+ transform.translate(0, (height() - heightScale * d->pix.height()) / 2);
}
}
- if (clip()) {
- p->save();
- p->setClipRect(QRectF(0, 0, d->mWidth, d->mHeight), Qt::IntersectClip);
- }
- scale.scale(widthScale, heightScale);
- QTransform old = p->transform();
- p->setWorldTransform(scale * old);
- p->drawPixmap(0, 0, d->pix);
- p->setWorldTransform(old);
- if (clip()) {
- p->restore();
- }
+ transform.scale(widthScale, heightScale);
+ drawWidth = d->pix.width();
+ drawHeight = d->pix.height();
+ doClip = clip();
}
- } else {
- p->drawPixmap(0, 0, d->pix);
}
+ QTransform oldTransform;
+ bool oldAA = p->testRenderHint(QPainter::Antialiasing);
+ bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
+ if (d->smooth)
+ p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
+ if (doClip) {
+ p->save();
+ p->setClipRect(QRectF(0, 0, d->mWidth, d->mHeight), Qt::IntersectClip);
+ }
+ if (d->mirror)
+ transform.translate(drawWidth, 0).scale(-1.0, 1.0);
+ if (!transform.isIdentity()) {
+ oldTransform = p->transform();
+ p->setWorldTransform(transform * oldTransform);
+ }
+
+ if (d->fillMode >= Tile)
+ p->drawTiledPixmap(QRectF(0, 0, drawWidth, drawHeight), d->pix);
+ else
+ p->drawPixmap(QRectF(0, 0, drawWidth, drawHeight), d->pix, QRectF(0, 0, drawWidth, drawHeight));
+
if (d->smooth) {
p->setRenderHint(QPainter::Antialiasing, oldAA);
p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
}
+ if (doClip)
+ p->restore();
+ if (!transform.isIdentity())
+ p->setWorldTransform(oldTransform);
}
void QDeclarativeImage::pixmapChange()
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
index 74e9337..471c87f 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
@@ -48,8 +48,13 @@
QT_BEGIN_NAMESPACE
+QDeclarativeImageBase::QDeclarativeImageBase(QDeclarativeItem *parent)
+ : QDeclarativeImplicitSizeItem(*(new QDeclarativeImageBasePrivate), parent)
+{
+}
+
QDeclarativeImageBase::QDeclarativeImageBase(QDeclarativeImageBasePrivate &dd, QDeclarativeItem *parent)
- : QDeclarativeItem(dd, parent)
+ : QDeclarativeImplicitSizeItem(dd, parent)
{
}
@@ -128,6 +133,44 @@ QSize QDeclarativeImageBase::sourceSize() const
return QSize(width != -1 ? width : implicitWidth(), height != -1 ? height : implicitHeight());
}
+bool QDeclarativeImageBase::cache() const
+{
+ Q_D(const QDeclarativeImageBase);
+ return d->cache;
+}
+
+void QDeclarativeImageBase::setCache(bool cache)
+{
+ Q_D(QDeclarativeImageBase);
+ if (d->cache == cache)
+ return;
+
+ d->cache = cache;
+ emit cacheChanged();
+ if (isComponentComplete())
+ load();
+}
+
+void QDeclarativeImageBase::setMirror(bool mirror)
+{
+ Q_D(QDeclarativeImageBase);
+ if (mirror == d->mirror)
+ return;
+
+ d->mirror = mirror;
+
+ if (isComponentComplete())
+ update();
+
+ emit mirrorChanged();
+}
+
+bool QDeclarativeImageBase::mirror() const
+{
+ Q_D(const QDeclarativeImageBase);
+ return d->mirror;
+}
+
void QDeclarativeImageBase::load()
{
Q_D(QDeclarativeImageBase);
@@ -143,7 +186,12 @@ void QDeclarativeImageBase::load()
pixmapChange();
update();
} else {
- d->pix.load(qmlEngine(this), d->url, d->explicitSourceSize ? sourceSize() : QSize(), d->async);
+ QDeclarativePixmap::Options options;
+ if (d->async)
+ options |= QDeclarativePixmap::Asynchronous;
+ if (d->cache)
+ options |= QDeclarativePixmap::Cache;
+ d->pix.load(qmlEngine(this), d->url, d->explicitSourceSize ? sourceSize() : QSize(), options);
if (d->pix.isLoading()) {
d->progress = 0.0;
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
index 7135170..abee25d 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
@@ -42,14 +42,14 @@
#ifndef QDECLARATIVEIMAGEBASE_H
#define QDECLARATIVEIMAGEBASE_H
-#include "qdeclarativeitem.h"
+#include "qdeclarativeimplicitsizeitem_p.h"
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QDeclarativeImageBasePrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeImageBase : public QDeclarativeItem
+class Q_AUTOTEST_EXPORT QDeclarativeImageBase : public QDeclarativeImplicitSizeItem
{
Q_OBJECT
Q_ENUMS(Status)
@@ -58,9 +58,12 @@ class Q_AUTOTEST_EXPORT QDeclarativeImageBase : public QDeclarativeItem
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
+ Q_PROPERTY(bool cache READ cache WRITE setCache NOTIFY cacheChanged REVISION 1)
Q_PROPERTY(QSize sourceSize READ sourceSize WRITE setSourceSize NOTIFY sourceSizeChanged)
+ Q_PROPERTY(bool mirror READ mirror WRITE setMirror NOTIFY mirrorChanged REVISION 1)
public:
+ QDeclarativeImageBase(QDeclarativeItem *parent=0);
~QDeclarativeImageBase();
enum Status { Null, Ready, Loading, Error };
Status status() const;
@@ -72,15 +75,23 @@ public:
bool asynchronous() const;
void setAsynchronous(bool);
+ bool cache() const;
+ void setCache(bool);
+
virtual void setSourceSize(const QSize&);
QSize sourceSize() const;
+ virtual void setMirror(bool mirror);
+ bool mirror() const;
+
Q_SIGNALS:
void sourceChanged(const QUrl &);
void sourceSizeChanged();
void statusChanged(QDeclarativeImageBase::Status);
void progressChanged(qreal progress);
void asynchronousChanged();
+ Q_REVISION(1) void cacheChanged();
+ Q_REVISION(1) void mirrorChanged();
protected:
virtual void load();
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
index 5d892ad..ab16e66 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
@@ -53,7 +53,7 @@
// We mean it.
//
-#include "private/qdeclarativeitem_p.h"
+#include "private/qdeclarativeimplicitsizeitem_p_p.h"
#include "private/qdeclarativepixmapcache_p.h"
#include <QtCore/QPointer>
@@ -61,7 +61,7 @@
QT_BEGIN_NAMESPACE
class QNetworkReply;
-class QDeclarativeImageBasePrivate : public QDeclarativeItemPrivate
+class QDeclarativeImageBasePrivate : public QDeclarativeImplicitSizeItemPrivate
{
Q_DECLARE_PUBLIC(QDeclarativeImageBase)
@@ -70,7 +70,9 @@ public:
: status(QDeclarativeImageBase::Null),
progress(0.0),
explicitSourceSize(false),
- async(false)
+ async(false),
+ cache(true),
+ mirror(false)
{
QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents;
}
@@ -82,6 +84,8 @@ public:
QSize sourcesize;
bool explicitSourceSize : 1;
bool async : 1;
+ bool cache : 1;
+ bool mirror: 1;
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem.cpp b/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem.cpp
new file mode 100644
index 0000000..31ac28f
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem.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 "private/qdeclarativeimplicitsizeitem_p.h"
+#include "private/qdeclarativeimplicitsizeitem_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+void QDeclarativeImplicitSizeItemPrivate::implicitWidthChanged()
+{
+ Q_Q(QDeclarativeImplicitSizeItem);
+ emit q->implicitWidthChanged();
+}
+
+void QDeclarativeImplicitSizeItemPrivate::implicitHeightChanged()
+{
+ Q_Q(QDeclarativeImplicitSizeItem);
+ emit q->implicitHeightChanged();
+}
+
+QDeclarativeImplicitSizeItem::QDeclarativeImplicitSizeItem(QDeclarativeItem *parent)
+ : QDeclarativeItem(*(new QDeclarativeImplicitSizeItemPrivate), parent)
+{
+}
+
+QDeclarativeImplicitSizeItem::QDeclarativeImplicitSizeItem(QDeclarativeImplicitSizeItemPrivate &dd, QDeclarativeItem *parent)
+ : QDeclarativeItem(dd, parent)
+{
+}
+
+
+void QDeclarativeImplicitSizePaintedItemPrivate::implicitWidthChanged()
+{
+ Q_Q(QDeclarativeImplicitSizePaintedItem);
+ emit q->implicitWidthChanged();
+}
+
+void QDeclarativeImplicitSizePaintedItemPrivate::implicitHeightChanged()
+{
+ Q_Q(QDeclarativeImplicitSizePaintedItem);
+ emit q->implicitHeightChanged();
+}
+
+QDeclarativeImplicitSizePaintedItem::QDeclarativeImplicitSizePaintedItem(QDeclarativeItem *parent)
+ : QDeclarativePaintedItem(*(new QDeclarativeImplicitSizePaintedItemPrivate), parent)
+{
+}
+
+QDeclarativeImplicitSizePaintedItem::QDeclarativeImplicitSizePaintedItem(QDeclarativeImplicitSizePaintedItemPrivate &dd, QDeclarativeItem *parent)
+ : QDeclarativePaintedItem(dd, parent)
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem_p.h b/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem_p.h
new file mode 100644
index 0000000..1863d95
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem_p.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** 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 QDECLARATIVEIMPLICITSIZEITEM_H
+#define QDECLARATIVEIMPLICITSIZEITEM_H
+
+#include "qdeclarativepainteditem_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeImplicitSizeItemPrivate;
+class Q_AUTOTEST_EXPORT QDeclarativeImplicitSizeItem : public QDeclarativeItem
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal implicitWidth READ implicitWidth NOTIFY implicitWidthChanged REVISION 1)
+ Q_PROPERTY(qreal implicitHeight READ implicitHeight NOTIFY implicitHeightChanged REVISION 1)
+
+public:
+ QDeclarativeImplicitSizeItem(QDeclarativeItem *parent = 0);
+
+protected:
+ QDeclarativeImplicitSizeItem(QDeclarativeImplicitSizeItemPrivate &dd, QDeclarativeItem *parent);
+
+Q_SIGNALS:
+ Q_REVISION(1) void implicitWidthChanged();
+ Q_REVISION(1) void implicitHeightChanged();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeImplicitSizeItem)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeImplicitSizeItem)
+};
+
+class QDeclarativeImplicitSizePaintedItemPrivate;
+class Q_AUTOTEST_EXPORT QDeclarativeImplicitSizePaintedItem : public QDeclarativePaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal implicitWidth READ implicitWidth NOTIFY implicitWidthChanged REVISION 1)
+ Q_PROPERTY(qreal implicitHeight READ implicitHeight NOTIFY implicitHeightChanged REVISION 1)
+
+public:
+ QDeclarativeImplicitSizePaintedItem(QDeclarativeItem *parent = 0);
+
+protected:
+ QDeclarativeImplicitSizePaintedItem(QDeclarativeImplicitSizePaintedItemPrivate &dd, QDeclarativeItem *parent);
+ virtual void drawContents(QPainter *, const QRect &) {};
+
+Q_SIGNALS:
+ Q_REVISION(1) void implicitWidthChanged();
+ Q_REVISION(1) void implicitHeightChanged();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeImplicitSizePaintedItem)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeImplicitSizePaintedItem)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEIMPLICITSIZEITEM_H
diff --git a/src/network/access/qnetworkaccessdatabackend_p.h b/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem_p_p.h
index 18569ec..0bb7163 100644
--- a/src/network/access/qnetworkaccessdatabackend_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem_p_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtNetwork module of the Qt Toolkit.
+** This file is part of the QtDeclarative module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,46 +39,52 @@
**
****************************************************************************/
-#ifndef QNETWORKACCESSDATABACKEND_P_H
-#define QNETWORKACCESSDATABACKEND_P_H
+#ifndef QDECLARATIVEIMPLICITSIZEITEM_P_H
+#define QDECLARATIVEIMPLICITSIZEITEM_P_H
//
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of the Network Access API. This header file may change from
-// version to version without notice, or even be removed.
+// 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 "qnetworkaccessbackend_p.h"
+#include "private/qdeclarativeitem_p.h"
+#include "private/qdeclarativepainteditem_p_p.h"
QT_BEGIN_NAMESPACE
-class QNetworkAccessDataBackend: public QNetworkAccessBackend
+class QDeclarativeImplicitSizeItemPrivate : public QDeclarativeItemPrivate
{
-public:
- QNetworkAccessDataBackend();
- virtual ~QNetworkAccessDataBackend();
+ Q_DECLARE_PUBLIC(QDeclarativeImplicitSizeItem)
- virtual void open();
- virtual void closeDownstreamChannel();
- virtual void closeUpstreamChannel();
- virtual bool waitForDownstreamReadyRead(int msecs);
- virtual bool waitForUpstreamBytesWritten(int msecs);
+public:
+ QDeclarativeImplicitSizeItemPrivate()
+ {
+ }
- virtual bool processRequestSynchronously();
+ virtual void implicitWidthChanged();
+ virtual void implicitHeightChanged();
};
-class QNetworkAccessDataBackendFactory: public QNetworkAccessBackendFactory
+
+class QDeclarativeImplicitSizePaintedItemPrivate : public QDeclarativePaintedItemPrivate
{
+ Q_DECLARE_PUBLIC(QDeclarativeImplicitSizePaintedItem)
+
public:
- virtual QNetworkAccessBackend *create(QNetworkAccessManager::Operation op,
- const QNetworkRequest &request) const;
+ QDeclarativeImplicitSizePaintedItemPrivate()
+ {
+ }
+
+ virtual void implicitWidthChanged();
+ virtual void implicitHeightChanged();
};
QT_END_NAMESPACE
-#endif
+#endif // QDECLARATIVEIMPLICITSIZEITEM_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 2e3a5a2..ffef61b 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -444,6 +444,11 @@ void QDeclarativeItemKeyFilter::componentComplete()
\c KeyNavigation.BeforeItem allows the event to be used for key navigation
before the item, rather than after.
+ If item to which the focus is switching is not enabled or visible, an attempt will
+ be made to skip this item and focus on the next. This is possible if there are
+ a chain of items with the same KeyNavigation handler. If multiple items in a row are not enabled
+ or visible, they will also be skipped.
+
\sa {Keys}{Keys attached property}
*/
@@ -452,10 +457,12 @@ void QDeclarativeItemKeyFilter::componentComplete()
\qmlproperty Item KeyNavigation::right
\qmlproperty Item KeyNavigation::up
\qmlproperty Item KeyNavigation::down
+ \qmlproperty Item KeyNavigation::tab
+ \qmlproperty Item KeyNavigation::backtab
These properties hold the item to assign focus to
- when the left, right, up or down cursor keys are
- pressed.
+ when the left, right, up or down cursor keys, or the
+ tab key are pressed.
*/
/*!
@@ -611,37 +618,37 @@ void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event, bool post)
switch(event->key()) {
case Qt::Key_Left:
if (d->left) {
- d->left->setFocus(true);
+ setFocusNavigation(d->left, "left");
event->accept();
}
break;
case Qt::Key_Right:
if (d->right) {
- d->right->setFocus(true);
+ setFocusNavigation(d->right, "right");
event->accept();
}
break;
case Qt::Key_Up:
if (d->up) {
- d->up->setFocus(true);
+ setFocusNavigation(d->up, "up");
event->accept();
}
break;
case Qt::Key_Down:
if (d->down) {
- d->down->setFocus(true);
+ setFocusNavigation(d->down, "down");
event->accept();
}
break;
case Qt::Key_Tab:
if (d->tab) {
- d->tab->setFocus(true);
+ setFocusNavigation(d->tab, "tab");
event->accept();
}
break;
case Qt::Key_Backtab:
if (d->backtab) {
- d->backtab->setFocus(true);
+ setFocusNavigation(d->backtab, "backtab");
event->accept();
}
break;
@@ -700,6 +707,29 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event, bool post)
if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post);
}
+void QDeclarativeKeyNavigationAttached::setFocusNavigation(QDeclarativeItem *currentItem, const char *dir)
+{
+ QDeclarativeItem *initialItem = currentItem;
+ bool isNextItem = false;
+ do {
+ isNextItem = false;
+ if (currentItem->isVisible() && currentItem->isEnabled()) {
+ currentItem->setFocus(true);
+ } else {
+ QObject *attached =
+ qmlAttachedPropertiesObject<QDeclarativeKeyNavigationAttached>(currentItem, false);
+ if (attached) {
+ QDeclarativeItem *tempItem = qvariant_cast<QDeclarativeItem*>(attached->property(dir));
+ if (tempItem) {
+ currentItem = tempItem;
+ isNextItem = true;
+ }
+ }
+ }
+ }
+ while (currentItem != initialItem && isNextItem);
+}
+
/*!
\qmlclass Keys QDeclarativeKeysAttached
\ingroup qml-basic-interaction-elements
@@ -799,10 +829,18 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event, bool post)
This example forwards key events to two lists:
\qml
- ListView { id: list1 ... }
- ListView { id: list2 ... }
- Keys.forwardTo: [list1, list2]
- focus: true
+ Item {
+ ListView {
+ id: list1
+ // ...
+ }
+ ListView {
+ id: list2
+ // ...
+ }
+ Keys.forwardTo: [list1, list2]
+ focus: true
+ }
\endqml
*/
@@ -1881,11 +1919,26 @@ void QDeclarativeItem::setClip(bool c)
/*!
\qmlproperty bool Item::visible
- Whether the item is visible. By default this is true.
+ This property holds whether the item is visible. By default this is true.
+
+ Setting this property directly affects the \c visible value of child
+ items. When set to \c false, the \c visible values of all child items also
+ become \c false. When set to \c true, the \c visible values of child items
+ are returned to \c true, unless they have explicitly been set to \c false.
- \note visible is not linked to actual visibility; if an item
- moves off screen, or the opacity changes to 0, this will
- not affect the visible property.
+ (Because of this flow-on behavior, using the \c visible property may not
+ have the intended effect if a property binding should only respond to
+ explicit property changes. In such cases it may be better to use the
+ \l opacity property instead.)
+
+ Setting this property to \c false automatically causes \l focus to be set
+ to \c false, and this item will longer receive mouse and keyboard events.
+ (In contrast, setting the \l opacity to 0 does not affect the \l focus
+ property and the receiving of key events.)
+
+ \note This property's value is only affected by changes to this property or
+ the parent's \c visible property. It does not change, for example, if this
+ item moves off-screen, or if the \l opacity changes to 0.
*/
@@ -2116,13 +2169,18 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::baseline() const
\o \image declarative-anchors_example.png
\o Text anchored to Image, horizontally centered and vertically below, with a margin.
\qml
- Image { id: pic; ... }
- Text {
- id: label
- anchors.horizontalCenter: pic.horizontalCenter
- anchors.top: pic.bottom
- anchors.topMargin: 5
- ...
+ Item {
+ Image {
+ id: pic
+ // ...
+ }
+ Text {
+ id: label
+ anchors.horizontalCenter: pic.horizontalCenter
+ anchors.top: pic.bottom
+ anchors.topMargin: 5
+ // ...
+ }
}
\endqml
\row
@@ -2132,13 +2190,18 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::baseline() const
property of both defaults to 0.
\qml
- Image { id: pic; ... }
- Text {
- id: label
- anchors.left: pic.right
- anchors.leftMargin: 5
- ...
- }
+ Item {
+ Image {
+ id: pic
+ // ...
+ }
+ Text {
+ id: label
+ anchors.left: pic.right
+ anchors.leftMargin: 5
+ // ...
+ }
+ }
\endqml
\endtable
@@ -2259,13 +2322,15 @@ void QDeclarativeItem::setBaselineOffset(qreal offset)
/*!
\qmlproperty real Item::opacity
- The opacity of the item. Opacity is specified as a number between 0
- (fully transparent) and 1 (fully opaque). The default is 1.
+ This property holds the opacity of the item. Opacity is specified as a
+ number between 0 (fully transparent) and 1 (fully opaque). The default is 1.
- Opacity is an \e inherited attribute. That is, the opacity is
- also applied individually to child items. In almost all cases this
- is what you want, but in some cases (like the following example)
- it may produce undesired results.
+ When this property is set, the specified opacity is also applied
+ individually to child items. In almost all cases this is what you want,
+ but in some cases it may produce undesired results. For example in the
+ second set of rectangles below, the red rectangle has specified an opacity
+ of 0.5, which affects the opacity of its blue child rectangle even though
+ the child has not specified an opacity.
\table
\row
@@ -2300,6 +2365,12 @@ void QDeclarativeItem::setBaselineOffset(qreal offset)
}
\endqml
\endtable
+
+ If an item's opacity is set to 0, the item will no longer receive mouse
+ events, but will continue to receive key events and will retain the keyboard
+ \l focus if it has been set. (In contrast, setting the \l visible property
+ to \c false stops both mouse and keyboard events, and also removes focus
+ from the item.)
*/
/*!
@@ -2452,11 +2523,15 @@ QDeclarativeListProperty<QObject> QDeclarativeItemPrivate::resources()
\qml
Item {
- states: [
- State { ... },
- State { ... }
- ...
- ]
+ states: [
+ State {
+ // ...
+ },
+ State {
+ // ...
+ }
+ // ...
+ ]
}
\endqml
@@ -2474,11 +2549,15 @@ QDeclarativeListProperty<QDeclarativeState> QDeclarativeItemPrivate::states()
\qml
Item {
- transitions: [
- Transition { ... },
- Transition { ... }
- ...
- ]
+ transitions: [
+ Transition {
+ // ...
+ },
+ Transition {
+ // ...
+ }
+ // ...
+ ]
}
\endqml
@@ -2503,11 +2582,15 @@ QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeItemPrivate::transi
\qml
Item {
- filter: [
- Blur { ... },
- Reflection { ... }
- ...
- ]
+ filter: [
+ Blur {
+ // ...
+ },
+ Reflection {
+ // ...
+ }
+ // ...
+ ]
}
\endqml
*/
@@ -2542,14 +2625,14 @@ QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeItemPrivate::transi
This property is often used in scripts to change between states. For
example:
- \qml
- function toggle() {
- if (button.state == 'On')
- button.state = 'Off';
- else
- button.state = 'On';
- }
- \endqml
+ \js
+ function toggle() {
+ if (button.state == 'On')
+ button.state = 'Off';
+ else
+ button.state = 'On';
+ }
+ \endjs
If the item is in its base state (i.e. no explicit state has been
set), \c state will be a blank string. Likewise, you can return an
@@ -3026,13 +3109,24 @@ void QDeclarativeItemPrivate::resetWidth()
q->setImplicitWidth(q->implicitWidth());
}
+void QDeclarativeItemPrivate::implicitWidthChanged()
+{
+ Q_Q(QDeclarativeItem);
+ emit q->implicitWidthChanged();
+}
+
+qreal QDeclarativeItemPrivate::implicitWidth() const
+{
+ return mImplicitWidth;
+}
+
/*!
Returns the width of the item that is implied by other properties that determine the content.
*/
qreal QDeclarativeItem::implicitWidth() const
{
Q_D(const QDeclarativeItem);
- return d->implicitWidth;
+ return d->implicitWidth();
}
/*!
@@ -3042,9 +3136,13 @@ qreal QDeclarativeItem::implicitWidth() const
void QDeclarativeItem::setImplicitWidth(qreal w)
{
Q_D(QDeclarativeItem);
- d->implicitWidth = w;
- if (d->mWidth == w || widthValid())
+ bool changed = w != d->mImplicitWidth;
+ d->mImplicitWidth = w;
+ if (d->mWidth == w || widthValid()) {
+ if (changed)
+ d->implicitWidthChanged();
return;
+ }
qreal oldWidth = d->mWidth;
@@ -3053,6 +3151,9 @@ void QDeclarativeItem::setImplicitWidth(qreal w)
geometryChanged(QRectF(x(), y(), width(), height()),
QRectF(x(), y(), oldWidth, height()));
+
+ if (changed)
+ d->implicitWidthChanged();
}
/*!
@@ -3134,25 +3235,77 @@ void QDeclarativeItemPrivate::resetHeight()
q->setImplicitHeight(q->implicitHeight());
}
+void QDeclarativeItemPrivate::implicitHeightChanged()
+{
+ Q_Q(QDeclarativeItem);
+ emit q->implicitHeightChanged();
+}
+
+qreal QDeclarativeItemPrivate::implicitHeight() const
+{
+ return mImplicitHeight;
+}
+
/*!
Returns the height of the item that is implied by other properties that determine the content.
*/
qreal QDeclarativeItem::implicitHeight() const
{
Q_D(const QDeclarativeItem);
- return d->implicitHeight;
+ return d->implicitHeight();
}
/*!
+ \qmlproperty real Item::implicitWidth
+ \qmlproperty real Item::implicitHeight
+ \since Quick 1.1
+
+ Defines the natural width or height of the Item if no \l width or \l height is specified.
+
+ The default implicit size for most items is 0x0, however some elements have an inherent
+ implicit size which cannot be overridden, e.g. Image, Text.
+
+ Setting the implicit size is useful for defining components that have a preferred size
+ based on their content, for example:
+
+ \code
+ // Label.qml
+ import QtQuick 1.1
+
+ Item {
+ property alias icon: image.source
+ property alias label: text.text
+ implicitWidth: text.implicitWidth + image.implicitWidth
+ implicitHeight: Math.max(text.implicitHeight, image.implicitHeight)
+ Image { id: image }
+ Text {
+ id: text
+ wrapMode: Text.Wrap
+ anchors.left: image.right; anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+ \endcode
+
+ \bold Note: using implicitWidth of Text or TextEdit and setting the width explicitly
+ incurs a performance penalty as the text must be laid out twice.
+*/
+
+
+/*!
Sets the implied height of the item to \a h.
This is the height implied by other properties that determine the content.
*/
void QDeclarativeItem::setImplicitHeight(qreal h)
{
Q_D(QDeclarativeItem);
- d->implicitHeight = h;
- if (d->mHeight == h || heightValid())
+ bool changed = h != d->mImplicitHeight;
+ d->mImplicitHeight = h;
+ if (d->mHeight == h || heightValid()) {
+ if (changed)
+ d->implicitHeightChanged();
return;
+ }
qreal oldHeight = d->mHeight;
@@ -3161,6 +3314,9 @@ void QDeclarativeItem::setImplicitHeight(qreal h)
geometryChanged(QRectF(x(), y(), width(), height()),
QRectF(x(), y(), width(), oldHeight));
+
+ if (changed)
+ d->implicitHeightChanged();
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h
index 0dd3937..839b934 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem.h
@@ -92,6 +92,9 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItem : public QGraphicsObject, public QDe
Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged)
Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint) // transformOriginPoint is read-only for Item
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
+ Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged REVISION 1)
+ Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged REVISION 1)
+
Q_ENUMS(TransformOrigin)
Q_CLASSINFO("DefaultProperty", "data")
@@ -161,6 +164,8 @@ Q_SIGNALS:
void transformOriginChanged(TransformOrigin);
void smoothChanged(bool);
void clipChanged(bool);
+ Q_REVISION(1) void implicitWidthChanged();
+ Q_REVISION(1) void implicitHeightChanged();
protected:
bool isComponentComplete() const;
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index 781dd6d..4303c0a 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -126,7 +126,7 @@ public:
widthValid(false), heightValid(false),
componentComplete(true), keepMouse(false),
smooth(false), transformOriginDirty(true), doneEventPreHandler(false), keyHandler(0),
- mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0), hadSubFocusItem(false)
+ mWidth(0), mHeight(0), mImplicitWidth(0), mImplicitHeight(0), hadSubFocusItem(false)
{
QGraphicsItemPrivate::acceptedMouseButtons = 0;
isDeclarativeItem = 1;
@@ -157,6 +157,11 @@ public:
void setHeight(qreal);
void resetHeight();
+ virtual qreal implicitWidth() const;
+ virtual qreal implicitHeight() const;
+ virtual void implicitWidthChanged();
+ virtual void implicitHeightChanged();
+
QDeclarativeListProperty<QObject> data();
QDeclarativeListProperty<QObject> resources();
@@ -272,8 +277,8 @@ public:
qreal mWidth;
qreal mHeight;
- qreal implicitWidth;
- qreal implicitHeight;
+ qreal mImplicitWidth;
+ qreal mImplicitHeight;
bool hadSubFocusItem;
@@ -415,6 +420,7 @@ Q_SIGNALS:
private:
virtual void keyPressed(QKeyEvent *event, bool post);
virtual void keyReleased(QKeyEvent *event, bool post);
+ void setFocusNavigation(QDeclarativeItem *currentItem, const char *dir);
};
class QDeclarativeKeysAttachedPrivate : public QObjectPrivate
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
index 52703c2..3c8f64e 100644
--- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
@@ -78,6 +78,7 @@
#include "private/qdeclarativewebview_p_p.h"
#endif
#include "private/qdeclarativeanchors_p.h"
+#include "private/qdeclarativepincharea_p.h"
static QDeclarativePrivate::AutoParentResult qgraphicsobject_autoParent(QObject *obj, QObject *parent)
{
@@ -174,6 +175,30 @@ void QDeclarativeItemModule::defineModule()
qmlRegisterUncreatableType<QDeclarativeKeyNavigationAttached>("QtQuick",1,0,"KeyNavigation",QDeclarativeKeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
qmlRegisterUncreatableType<QDeclarativeKeysAttached>("QtQuick",1,0,"Keys",QDeclarativeKeysAttached::tr("Keys is only available via attached properties"));
+ // QtQuick 1.1 items
+ qmlRegisterType<QDeclarativePinchArea>("QtQuick",1,1,"PinchArea");
+ qmlRegisterType<QDeclarativePinch>("QtQuick",1,1,"Pinch");
+ qmlRegisterType<QDeclarativePinchEvent>();
+ qmlRegisterType<QDeclarativeItem,1>("QtQuick",1,1,"Item");
+ qmlRegisterType<QDeclarativeMouseArea,1>("QtQuick",1,1,"MouseArea");
+ qmlRegisterType<QDeclarativeFlickable,1>("QtQuick",1,1,"Flickable");
+ qmlRegisterType<QDeclarativeListView,1>("QtQuick",1,1,"ListView");
+ qmlRegisterType<QDeclarativeGridView,1>("QtQuick",1,1,"GridView");
+ qmlRegisterType<QDeclarativeRow,1>("QtQuick",1,1,"Row");
+ qmlRegisterType<QDeclarativeGrid,1>("QtQuick",1,1,"Grid");
+ qmlRegisterType<QDeclarativeFlow,1>("QtQuick",1,1,"Flow");
+ qmlRegisterType<QDeclarativeRepeater,1>("QtQuick",1,1,"Repeater");
+ qmlRegisterType<QDeclarativeText,1>("QtQuick",1,1,"Text");
+ qmlRegisterType<QDeclarativeTextEdit,1>("QtQuick",1,1,"TextEdit");
+#ifndef QT_NO_LINEEDIT
+ qmlRegisterType<QDeclarativeTextInput,1>("QtQuick",1,1,"TextInput");
+#endif
+ qmlRegisterRevision<QDeclarativeImageBase,1>("QtQuick",1,1);
+ qmlRegisterRevision<QDeclarativeImplicitSizeItem,0>("QtQuick",1,0);
+ qmlRegisterRevision<QDeclarativeImplicitSizeItem,1>("QtQuick",1,1);
+ qmlRegisterRevision<QDeclarativeImplicitSizePaintedItem,0>("QtQuick",1,0);
+ qmlRegisterRevision<QDeclarativeImplicitSizePaintedItem,1>("QtQuick",1,1);
+
#ifndef QT_NO_IMPORT_QT47_QML
#ifdef QT_NO_MOVIE
qmlRegisterTypeNotAvailable("Qt",4,7,"AnimatedImage",
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index b4fd571..338cb58 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -148,7 +148,7 @@ public:
else
item->setWidth(size);
}
- bool contains(int x, int y) const {
+ bool contains(qreal x, qreal y) const {
return (x >= item->x() && x < item->x() + item->width() &&
y >= item->y() && y < item->y() + item->height());
}
@@ -228,6 +228,26 @@ public:
return 0;
}
+ // Returns the item before modelIndex, if created.
+ // May return an item marked for removal.
+ FxListItem *itemBefore(int modelIndex) const {
+ if (modelIndex < visibleIndex)
+ return 0;
+ int idx = 1;
+ int lastIndex = -1;
+ while (idx < visibleItems.count()) {
+ FxListItem *item = visibleItems.at(idx);
+ if (item->index != -1)
+ lastIndex = item->index;
+ if (item->index == modelIndex)
+ return visibleItems.at(idx-1);
+ ++idx;
+ }
+ if (lastIndex == modelIndex-1)
+ return visibleItems.last();
+ return 0;
+ }
+
qreal position() const {
Q_Q(const QDeclarativeListView);
return orient == QDeclarativeListView::Vertical ? q->contentY() : q->contentX();
@@ -413,8 +433,10 @@ public:
}
}
if ((header && header->item == item) || (footer && footer->item == item)) {
- updateHeader();
- updateFooter();
+ if (header)
+ updateHeader();
+ if (footer)
+ updateFooter();
}
if (currentItem && currentItem->item == item)
updateHighlight();
@@ -451,6 +473,7 @@ public:
void updateHeader();
void updateFooter();
void fixupPosition();
+ void positionViewAtIndex(int index, int mode);
virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent);
virtual void flick(QDeclarativeFlickablePrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity);
@@ -558,7 +581,7 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex)
QString propValue = model->stringValue(modelIndex, sectionCriteria->property());
listItem->attached->m_section = sectionCriteria->sectionString(propValue);
if (modelIndex > 0) {
- if (FxListItem *item = visibleItem(modelIndex-1))
+ if (FxListItem *item = itemBefore(modelIndex))
listItem->attached->m_prevSection = item->attached->section();
else
listItem->attached->m_prevSection = sectionAt(modelIndex-1);
@@ -935,6 +958,9 @@ void QDeclarativeListViewPrivate::createSection(FxListItem *listItem)
}
}
listItem->setPosition(pos);
+ } else {
+ QDeclarativeContext *context = QDeclarativeEngine::contextForObject(listItem->section)->parentContext();
+ context->setContextProperty(QLatin1String("section"), listItem->attached->m_section);
}
} else if (listItem->section) {
qreal pos = listItem->position();
@@ -963,18 +989,18 @@ void QDeclarativeListViewPrivate::updateSections()
QDeclarativeListViewAttached *prevAtt = 0;
int idx = -1;
for (int i = 0; i < visibleItems.count(); ++i) {
+ QDeclarativeListViewAttached *attached = visibleItems.at(i)->attached;
+ attached->setPrevSection(prevSection);
if (visibleItems.at(i)->index != -1) {
- QDeclarativeListViewAttached *attached = visibleItems.at(i)->attached;
- attached->setPrevSection(prevSection);
QString propValue = model->stringValue(visibleItems.at(i)->index, sectionCriteria->property());
attached->setSection(sectionCriteria->sectionString(propValue));
- if (prevAtt)
- prevAtt->setNextSection(attached->section());
- createSection(visibleItems.at(i));
- prevSection = attached->section();
- prevAtt = attached;
idx = visibleItems.at(i)->index;
}
+ createSection(visibleItems.at(i));
+ if (prevAtt)
+ prevAtt->setNextSection(attached->section());
+ prevSection = attached->section();
+ prevAtt = attached;
}
if (prevAtt) {
if (idx > 0 && idx < model->count()-1)
@@ -2231,6 +2257,9 @@ void QDeclarativeListView::setFooter(QDeclarativeComponent *footer)
Q_D(QDeclarativeListView);
if (d->footerComponent != footer) {
if (d->footer) {
+ if (scene())
+ scene()->removeItem(d->footer->item);
+ d->footer->item->deleteLater();
delete d->footer;
d->footer = 0;
}
@@ -2240,6 +2269,7 @@ void QDeclarativeListView::setFooter(QDeclarativeComponent *footer)
if (isComponentComplete()) {
d->updateFooter();
d->updateViewport();
+ d->fixupPosition();
}
emit footerChanged();
}
@@ -2265,6 +2295,9 @@ void QDeclarativeListView::setHeader(QDeclarativeComponent *header)
Q_D(QDeclarativeListView);
if (d->headerComponent != header) {
if (d->header) {
+ if (scene())
+ scene()->removeItem(d->header->item);
+ d->header->item->deleteLater();
delete d->header;
d->header = 0;
}
@@ -2275,6 +2308,7 @@ void QDeclarativeListView::setHeader(QDeclarativeComponent *header)
d->updateHeader();
d->updateFooter();
d->updateViewport();
+ d->fixupPosition();
}
emit headerChanged();
}
@@ -2558,6 +2592,78 @@ void QDeclarativeListView::decrementCurrentIndex()
}
}
+void QDeclarativeListViewPrivate::positionViewAtIndex(int index, int mode)
+{
+ Q_Q(QDeclarativeListView);
+ if (!isValid())
+ return;
+ if (mode < QDeclarativeListView::Beginning || mode > QDeclarativeListView::Contain)
+ return;
+ int idx = qMax(qMin(index, model->count()-1), 0);
+
+ if (layoutScheduled)
+ layout();
+ qreal pos = position();
+ FxListItem *item = visibleItem(idx);
+ qreal maxExtent = orient == QDeclarativeListView::Vertical ? -q->maxYExtent() : -q->maxXExtent();
+ if (!item) {
+ int itemPos = positionAt(idx);
+ // save the currently visible items in case any of them end up visible again
+ QList<FxListItem*> oldVisible = visibleItems;
+ visibleItems.clear();
+ visiblePos = itemPos;
+ visibleIndex = idx;
+ setPosition(qMin(qreal(itemPos), maxExtent));
+ // now release the reference to all the old visible items.
+ for (int i = 0; i < oldVisible.count(); ++i)
+ releaseItem(oldVisible.at(i));
+ item = visibleItem(idx);
+ }
+ if (item) {
+ const qreal itemPos = item->position();
+ switch (mode) {
+ case QDeclarativeListView::Beginning:
+ pos = itemPos;
+ if (index < 0 && header)
+ pos -= header->size();
+ break;
+ case QDeclarativeListView::Center:
+ pos = itemPos - (size() - item->size())/2;
+ break;
+ case QDeclarativeListView::End:
+ pos = itemPos - size() + item->size();
+ if (index >= model->count() && footer)
+ pos += footer->size();
+ break;
+ case QDeclarativeListView::Visible:
+ if (itemPos > pos + size())
+ pos = itemPos - size() + item->size();
+ else if (item->endPosition() < pos)
+ pos = itemPos;
+ break;
+ case QDeclarativeListView::Contain:
+ if (item->endPosition() > pos + size())
+ pos = itemPos - size() + item->size();
+ if (itemPos < pos)
+ pos = itemPos;
+ }
+ pos = qMin(pos, maxExtent);
+ qreal minExtent = orient == QDeclarativeListView::Vertical ? -q->minYExtent() : -q->minXExtent();
+ pos = qMax(pos, minExtent);
+ moveReason = QDeclarativeListViewPrivate::Other;
+ q->cancelFlick();
+ setPosition(pos);
+ if (highlight) {
+ if (autoHighlight) {
+ highlight->setPosition(currentItem->itemPosition());
+ highlight->setSize(currentItem->itemSize());
+ }
+ updateHighlight();
+ }
+ }
+ fixupPosition();
+}
+
/*!
\qmlmethod ListView::positionViewAtIndex(int index, PositionMode mode)
@@ -2596,66 +2702,42 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode)
Q_D(QDeclarativeListView);
if (!d->isValid() || index < 0 || index >= d->model->count())
return;
- if (mode < Beginning || mode > Contain)
+ d->positionViewAtIndex(index, mode);
+}
+
+/*!
+ \qmlmethod ListView::positionViewAtBeginning()
+ \qmlmethod ListView::positionViewAtEnd()
+
+ Positions the view at the beginning or end, taking into account any header or footer.
+
+ It is not recommended to use \l {Flickable::}{contentX} or \l {Flickable::}{contentY} to position the view
+ at a particular index. This is unreliable since removing items from the start
+ of the list does not cause all other items to be repositioned, and because
+ the actual start of the view can vary based on the size of the delegates.
+
+ \bold Note: methods should only be called after the Component has completed. To position
+ the view at startup, this method should be called by Component.onCompleted. For
+ example, to position the view at the end on startup:
+
+ \code
+ Component.onCompleted: positionViewAtEnd()
+ \endcode
+*/
+void QDeclarativeListView::positionViewAtBeginning()
+{
+ Q_D(QDeclarativeListView);
+ if (!d->isValid())
return;
+ d->positionViewAtIndex(-1, Beginning);
+}
- if (d->layoutScheduled)
- d->layout();
- qreal pos = d->position();
- FxListItem *item = d->visibleItem(index);
- if (!item) {
- int itemPos = d->positionAt(index);
- // save the currently visible items in case any of them end up visible again
- QList<FxListItem*> oldVisible = d->visibleItems;
- d->visibleItems.clear();
- d->visiblePos = itemPos;
- d->visibleIndex = index;
- d->setPosition(itemPos);
- // now release the reference to all the old visible items.
- for (int i = 0; i < oldVisible.count(); ++i)
- d->releaseItem(oldVisible.at(i));
- item = d->visibleItem(index);
- }
- if (item) {
- const qreal itemPos = item->position();
- switch (mode) {
- case Beginning:
- pos = itemPos;
- break;
- case Center:
- pos = itemPos - (d->size() - item->size())/2;
- break;
- case End:
- pos = itemPos - d->size() + item->size();
- break;
- case Visible:
- if (itemPos > pos + d->size())
- pos = itemPos - d->size() + item->size();
- else if (item->endPosition() < pos)
- pos = itemPos;
- break;
- case Contain:
- if (item->endPosition() > pos + d->size())
- pos = itemPos - d->size() + item->size();
- if (itemPos < pos)
- pos = itemPos;
- }
- qreal maxExtent = d->orient == QDeclarativeListView::Vertical ? -maxYExtent() : -maxXExtent();
- pos = qMin(pos, maxExtent);
- qreal minExtent = d->orient == QDeclarativeListView::Vertical ? -minYExtent() : -minXExtent();
- pos = qMax(pos, minExtent);
- d->moveReason = QDeclarativeListViewPrivate::Other;
- cancelFlick();
- d->setPosition(pos);
- if (d->highlight) {
- if (d->autoHighlight) {
- d->highlight->setPosition(d->currentItem->itemPosition());
- d->highlight->setSize(d->currentItem->itemSize());
- }
- d->updateHighlight();
- }
- }
- d->fixupPosition();
+void QDeclarativeListView::positionViewAtEnd()
+{
+ Q_D(QDeclarativeListView);
+ if (!d->isValid())
+ return;
+ d->positionViewAtIndex(d->model->count(), End);
}
/*!
@@ -2670,7 +2752,7 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode)
\bold Note: methods should only be called after the Component has completed.
*/
-int QDeclarativeListView::indexAt(int x, int y) const
+int QDeclarativeListView::indexAt(qreal x, qreal y) const
{
Q_D(const QDeclarativeListView);
for (int i = 0; i < d->visibleItems.count(); ++i) {
@@ -2791,23 +2873,8 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
return;
d->updateUnrequestedIndexes();
d->moveReason = QDeclarativeListViewPrivate::Other;
- if (!d->visibleItems.count() || d->model->count() <= 1) {
- d->scheduleLayout();
- if (d->itemCount && d->currentIndex >= modelIndex) {
- // adjust current item index
- d->currentIndex += count;
- if (d->currentItem)
- d->currentItem->index = d->currentIndex;
- emit currentIndexChanged();
- } else if (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared)) {
- d->updateCurrent(0);
- }
- d->itemCount += count;
- emit countChanged();
- return;
- }
- int index = d->mapFromModel(modelIndex);
+ int index = d->visibleItems.count() ? d->mapFromModel(modelIndex) : 0;
if (index < 0) {
int i = d->visibleItems.count() - 1;
while (i > 0 && d->visibleItems.at(i)->index == -1)
@@ -2843,11 +2910,15 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
}
}
- // At least some of the added items will be visible
-
// index can be the next item past the end of the visible items list (i.e. appended)
- int pos = index < d->visibleItems.count() ? d->visibleItems.at(index)->position()
+ int pos = 0;
+ if (d->visibleItems.count()) {
+ pos = index < d->visibleItems.count() ? d->visibleItems.at(index)->position()
: d->visibleItems.last()->endPosition()+d->spacing+1;
+ } else if (d->itemCount == 0 && d->header) {
+ pos = d->header->size();
+ }
+
int initialPos = pos;
int diff = 0;
QList<FxListItem*> added;
@@ -2914,6 +2985,8 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
if (d->currentItem) {
d->currentItem->index = d->currentIndex;
d->currentItem->setPosition(d->currentItem->position() + diff);
+ } else if (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared)) {
+ d->updateCurrent(0);
}
emit currentIndexChanged();
}
@@ -3043,6 +3116,7 @@ void QDeclarativeListView::destroyRemoved()
}
// Correct the positioning of the items
+ d->updateSections();
d->layout();
}
diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h
index 7ffcb43..265f4bd 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h
@@ -208,7 +208,9 @@ public:
enum PositionMode { Beginning, Center, End, Visible, Contain };
Q_INVOKABLE void positionViewAtIndex(int index, int mode);
- Q_INVOKABLE int indexAt(int x, int y) const;
+ Q_INVOKABLE int indexAt(qreal x, qreal y) const;
+ Q_INVOKABLE Q_REVISION(1) void positionViewAtBeginning();
+ Q_INVOKABLE Q_REVISION(1) void positionViewAtEnd();
public Q_SLOTS:
void incrementCurrentIndex();
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index 86e438f..6c1f1be 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -48,7 +48,8 @@
QT_BEGIN_NAMESPACE
QDeclarativeLoaderPrivate::QDeclarativeLoaderPrivate()
- : item(0), component(0), ownComponent(false), isComponentComplete(false)
+ : item(0), component(0), ownComponent(false), updatingSize(false),
+ itemWidthValid(false), itemHeightValid(false)
{
}
@@ -58,8 +59,13 @@ QDeclarativeLoaderPrivate::~QDeclarativeLoaderPrivate()
void QDeclarativeLoaderPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, const QRectF &newGeometry, const QRectF &oldGeometry)
{
- if (resizeItem == item)
+ if (resizeItem == item) {
+ if (!updatingSize && newGeometry.width() != oldGeometry.width())
+ itemWidthValid = true;
+ if (!updatingSize && newGeometry.height() != oldGeometry.height())
+ itemHeightValid = true;
_q_updateSize(false);
+ }
QDeclarativeItemChangeListener::itemGeometryChanged(resizeItem, newGeometry, oldGeometry);
}
@@ -99,6 +105,10 @@ void QDeclarativeLoaderPrivate::initResize()
QDeclarativeItemPrivate *p =
static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(qmlItem));
p->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
+ // We may override the item's size, so we need to remember
+ // whether the item provided its own valid size.
+ itemWidthValid = p->widthValid;
+ itemHeightValid = p->heightValid;
} else if (item && item->isWidget()) {
QGraphicsWidget *widget = static_cast<QGraphicsWidget*>(item);
widget->installEventFilter(q);
@@ -216,7 +226,7 @@ void QDeclarativeLoaderPrivate::initResize()
*/
QDeclarativeLoader::QDeclarativeLoader(QDeclarativeItem *parent)
- : QDeclarativeItem(*(new QDeclarativeLoaderPrivate), parent)
+ : QDeclarativeImplicitSizeItem(*(new QDeclarativeLoaderPrivate), parent)
{
Q_D(QDeclarativeLoader);
d->flags |= QGraphicsItem::ItemIsFocusScope;
@@ -274,7 +284,7 @@ void QDeclarativeLoader::setSource(const QUrl &url)
d->component = new QDeclarativeComponent(qmlEngine(this), d->source, this);
d->ownComponent = true;
- if (d->isComponentComplete)
+ if (isComponentComplete())
d->load();
}
@@ -325,7 +335,7 @@ void QDeclarativeLoader::setSourceComponent(QDeclarativeComponent *comp)
return;
}
- if (d->isComponentComplete)
+ if (isComponentComplete())
d->load();
}
@@ -338,7 +348,7 @@ void QDeclarativeLoaderPrivate::load()
{
Q_Q(QDeclarativeLoader);
- if (!isComponentComplete || !component)
+ if (!q->isComponentComplete() || !component)
return;
if (!component->isLoading()) {
@@ -472,7 +482,6 @@ void QDeclarativeLoader::componentComplete()
Q_D(QDeclarativeLoader);
QDeclarativeItem::componentComplete();
- d->isComponentComplete = true;
d->load();
}
@@ -510,13 +519,21 @@ qreal QDeclarativeLoader::progress() const
void QDeclarativeLoaderPrivate::_q_updateSize(bool loaderGeometryChanged)
{
Q_Q(QDeclarativeLoader);
- if (!item)
+ if (!item || updatingSize)
return;
+
+ updatingSize = true;
if (QDeclarativeItem *qmlItem = qobject_cast<QDeclarativeItem*>(item)) {
- q->setImplicitWidth(qmlItem->width());
+ if (!itemWidthValid)
+ q->setImplicitWidth(qmlItem->implicitWidth());
+ else
+ q->setImplicitWidth(qmlItem->width());
if (loaderGeometryChanged && q->widthValid())
qmlItem->setWidth(q->width());
- q->setImplicitHeight(qmlItem->height());
+ if (!itemHeightValid)
+ q->setImplicitHeight(qmlItem->implicitHeight());
+ else
+ q->setImplicitHeight(qmlItem->height());
if (loaderGeometryChanged && q->heightValid())
qmlItem->setHeight(q->height());
} else if (item && item->isWidget()) {
@@ -531,6 +548,7 @@ void QDeclarativeLoaderPrivate::_q_updateSize(bool loaderGeometryChanged)
if (widget->size() != widgetSize)
widget->resize(widgetSize);
}
+ updatingSize = false;
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativeloader_p.h b/src/declarative/graphicsitems/qdeclarativeloader_p.h
index 1fe7ae7..96b883c 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeloader_p.h
@@ -42,7 +42,7 @@
#ifndef QDECLARATIVELOADER_H
#define QDECLARATIVELOADER_H
-#include "qdeclarativeitem.h"
+#include "qdeclarativeimplicitsizeitem_p.h"
QT_BEGIN_HEADER
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeLoaderPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeLoader : public QDeclarativeItem
+class Q_AUTOTEST_EXPORT QDeclarativeLoader : public QDeclarativeImplicitSizeItem
{
Q_OBJECT
Q_ENUMS(Status)
diff --git a/src/declarative/graphicsitems/qdeclarativeloader_p_p.h b/src/declarative/graphicsitems/qdeclarativeloader_p_p.h
index 81ca66d..4593dfc 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeloader_p_p.h
@@ -55,13 +55,13 @@
#include "private/qdeclarativeloader_p.h"
-#include "private/qdeclarativeitem_p.h"
+#include "private/qdeclarativeimplicitsizeitem_p_p.h"
#include "private/qdeclarativeitemchangelistener_p.h"
QT_BEGIN_NAMESPACE
class QDeclarativeContext;
-class QDeclarativeLoaderPrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener
+class QDeclarativeLoaderPrivate : public QDeclarativeImplicitSizeItemPrivate, public QDeclarativeItemChangeListener
{
Q_DECLARE_PUBLIC(QDeclarativeLoader)
@@ -78,7 +78,9 @@ public:
QGraphicsObject *item;
QDeclarativeComponent *component;
bool ownComponent : 1;
- bool isComponentComplete : 1;
+ bool updatingSize: 1;
+ bool itemWidthValid : 1;
+ bool itemHeightValid : 1;
void _q_sourceLoaded();
void _q_updateSize(bool loaderGeometryChanged = true);
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index 4b555d0..da11b00 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -216,9 +216,9 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate()
\section1 Example Usage
- \beginfloatright
+ \div {float-right}
\inlineimage qml-mousearea-snippet.png
- \endfloat
+ \enddiv
The following example uses a MouseArea in a \l Rectangle that changes
the \l Rectangle color to red when clicked:
@@ -314,6 +314,8 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate()
position of the release of the click, and whether the click was held.
The \e accepted property of the MouseEvent parameter is ignored in this handler.
+
+ \sa onCanceled()
*/
/*!
@@ -414,6 +416,40 @@ void QDeclarativeMouseArea::setEnabled(bool a)
emit enabledChanged();
}
}
+
+/*!
+ \qmlproperty bool MouseArea::preventStealing
+ \since Quick 1.1
+ This property holds whether the mouse events may be stolen from this
+ MouseArea.
+
+ If a MouseArea is placed within an item that filters child mouse
+ events, such as Flickable, the mouse
+ events may be stolen from the MouseArea if a gesture is recognized
+ by the parent element, e.g. a flick gesture. If preventStealing is
+ set to true, no element will steal the mouse events.
+
+ Note that setting preventStealing to true once an element has started
+ stealing events will have no effect until the next press event.
+
+ By default this property is false.
+*/
+bool QDeclarativeMouseArea::preventStealing() const
+{
+ Q_D(const QDeclarativeMouseArea);
+ return d->preventStealing;
+}
+
+void QDeclarativeMouseArea::setPreventStealing(bool prevent)
+{
+ Q_D(QDeclarativeMouseArea);
+ if (prevent != d->preventStealing) {
+ d->preventStealing = prevent;
+ setKeepMouseGrab(d->preventStealing && d->absorb);
+ emit preventStealingChanged();
+ }
+}
+
/*!
\qmlproperty MouseButtons MouseArea::pressedButtons
This property holds the mouse buttons currently pressed.
@@ -441,7 +477,7 @@ void QDeclarativeMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeMouseArea);
d->moved = false;
- d->stealMouse = false;
+ d->stealMouse = d->preventStealing;
if (!d->absorb)
QDeclarativeItem::mousePressEvent(event);
else {
@@ -458,7 +494,7 @@ void QDeclarativeMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event)
// we should only start timer if pressAndHold is connected to.
if (d->isPressAndHoldConnected())
d->pressAndHoldTimer.start(PressAndHoldDelay, this);
- setKeepMouseGrab(false);
+ setKeepMouseGrab(d->stealMouse);
event->setAccepted(setPressed(true));
}
}
@@ -583,18 +619,22 @@ void QDeclarativeMouseArea::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
Q_D(QDeclarativeMouseArea);
if (!d->absorb)
QDeclarativeItem::hoverEnterEvent(event);
- else
+ else {
+ d->lastPos = event->pos();
setHovered(true);
+ QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, event->modifiers(), false, false);
+ emit mousePositionChanged(&me);
+ }
}
void QDeclarativeMouseArea::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_D(QDeclarativeMouseArea);
if (!d->absorb) {
- QDeclarativeItem::hoverEnterEvent(event);
+ QDeclarativeItem::hoverMoveEvent(event);
} else {
d->lastPos = event->pos();
- QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, d->lastButtons, d->lastModifiers, false, d->longPress);
+ QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, event->modifiers(), false, false);
emit mousePositionChanged(&me);
me.setX(d->lastPos.x());
me.setY(d->lastPos.y());
@@ -859,15 +899,16 @@ bool QDeclarativeMouseArea::setPressed(bool p)
me.setX(d->lastPos.x());
me.setY(d->lastPos.y());
emit mousePositionChanged(&me);
+ emit pressedChanged();
} else {
emit released(&me);
me.setX(d->lastPos.x());
me.setY(d->lastPos.y());
+ emit pressedChanged();
if (isclick && !d->longPress && !d->doubleClick)
emit clicked(&me);
}
- emit pressedChanged();
return me.isAccepted();
}
return false;
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p.h
index 937ac78..985f27e 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea_p.h
+++ b/src/declarative/graphicsitems/qdeclarativemousearea_p.h
@@ -129,6 +129,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeMouseArea : public QDeclarativeItem
Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
Q_PROPERTY(QDeclarativeDrag *drag READ drag CONSTANT) //### add flicking to QDeclarativeDrag or add a QDeclarativeFlick ???
+ Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged REVISION 1)
public:
QDeclarativeMouseArea(QDeclarativeItem *parent=0);
@@ -153,6 +154,9 @@ public:
QDeclarativeDrag *drag();
+ bool preventStealing() const;
+ void setPreventStealing(bool prevent);
+
Q_SIGNALS:
void hoveredChanged();
void pressedChanged();
@@ -161,6 +165,7 @@ Q_SIGNALS:
void hoverEnabledChanged();
void positionChanged(QDeclarativeMouseEvent *mouse);
void mousePositionChanged(QDeclarativeMouseEvent *mouse);
+ Q_REVISION(1) void preventStealingChanged();
void pressed(QDeclarativeMouseEvent *mouse);
void pressAndHold(QDeclarativeMouseEvent *mouse);
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
index 2a327af..67694fb 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
@@ -68,7 +68,7 @@ class QDeclarativeMouseAreaPrivate : public QDeclarativeItemPrivate
public:
QDeclarativeMouseAreaPrivate()
: absorb(true), hovered(false), pressed(false), longPress(false),
- moved(false), stealMouse(false), doubleClick(false), drag(0)
+ moved(false), stealMouse(false), doubleClick(false), preventStealing(false), drag(0)
{
}
@@ -110,6 +110,7 @@ public:
bool dragY : 1;
bool stealMouse : 1;
bool doubleClick : 1;
+ bool preventStealing : 1;
QDeclarativeDrag *drag;
QPointF startScene;
qreal startX;
diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp
index bc395d2..48e3f66 100644
--- a/src/declarative/graphicsitems/qdeclarativepath.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepath.cpp
@@ -845,7 +845,7 @@ void QDeclarativePathCubic::addToPath(QPainterPath &path)
\o
\qml
PathView {
- ...
+ // ...
Path {
startX: 20; startY: 0
PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 }
@@ -859,7 +859,7 @@ void QDeclarativePathCubic::addToPath(QPainterPath &path)
\o
\qml
PathView {
- ...
+ // ...
Path {
startX: 20; startY: 0
PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 }
@@ -892,7 +892,7 @@ void QDeclarativePathCubic::addToPath(QPainterPath &path)
\qml
PathView {
- ...
+ // ...
Path {
startX: 0; startY: 0
PathLine { x:100; y: 0; }
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index 64656af..4e401e9 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -379,14 +379,14 @@ void QDeclarativePathViewPrivate::regenerate()
\l decrementCurrentIndex() or \l incrementCurrentIndex(), for example to navigate
using the left and right arrow keys:
- \code
+ \qml
PathView {
- ...
+ // ...
focus: true
Keys.onLeftPressed: decrementCurrentIndex()
Keys.onRightPressed: incrementCurrentIndex()
}
- \endcode
+ \endqml
The path view itself is a focus scope (see \l{qmlfocus#Acquiring Focus and Focus Scopes}{the focus documentation page} for more details).
@@ -444,7 +444,7 @@ QDeclarativePathView::~QDeclarativePathView()
Component {
Rectangle {
visible: PathView.onPath
- ...
+ // ...
}
}
\endqml
@@ -706,14 +706,14 @@ void QDeclarativePathViewPrivate::setAdjustedOffset(qreal o)
of the \l{PathView::onPath}{PathView.onPath} attached property to ensure that
the highlight is hidden when flicked away from the path.
- \code
+ \qml
Component {
Rectangle {
visible: PathView.onPath
- ...
+ // ...
}
}
- \endcode
+ \endqml
\sa highlightItem, highlightRangeMode
*/
@@ -1152,7 +1152,7 @@ void QDeclarativePathViewPrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
moveReason = QDeclarativePathViewPrivate::Mouse;
qreal diff = (newPc - startPc)*modelCount*mappedRange;
if (diff) {
- setOffset(offset + diff);
+ q->setOffset(offset + diff);
if (diff > modelCount/2)
diff -= modelCount;
@@ -1455,17 +1455,18 @@ void QDeclarativePathView::itemsInserted(int modelIndex, int count)
if (!d->isValid() || !isComponentComplete())
return;
- d->itemCache += d->items;
- d->items.clear();
- if (modelIndex <= d->currentIndex) {
- d->currentIndex += count;
- emit currentIndexChanged();
- } else if (d->offset != 0) {
- d->offset += count;
- d->offsetAdj += count;
+ if (d->modelCount) {
+ d->itemCache += d->items;
+ d->items.clear();
+ if (modelIndex <= d->currentIndex) {
+ d->currentIndex += count;
+ emit currentIndexChanged();
+ } else if (d->offset != 0) {
+ d->offset += count;
+ d->offsetAdj += count;
+ }
}
-
- d->modelCount = d->model->count();
+ d->modelCount += count;
if (d->flicking || d->moving) {
d->regenerate();
d->updateCurrent();
@@ -1502,18 +1503,29 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count)
d->itemCache += d->items;
d->items.clear();
+ bool changedOffset = false;
if (modelIndex > d->currentIndex) {
if (d->offset >= count) {
+ changedOffset = true;
d->offset -= count;
d->offsetAdj -= count;
}
}
- d->modelCount = d->model->count();
- d->regenerate();
- d->updateCurrent();
- if (!d->modelCount)
+ d->modelCount -= count;
+ if (!d->modelCount) {
+ while (d->itemCache.count())
+ d->releaseItem(d->itemCache.takeLast());
+ d->offset = 0;
+ changedOffset = true;
+ d->tl.reset(d->moveOffset);
update();
+ } else {
+ d->regenerate();
+ d->updateCurrent();
+ }
+ if (changedOffset)
+ emit offsetChanged();
if (currentChanged)
emit currentIndexChanged();
emit countChanged();
@@ -1601,7 +1613,7 @@ void QDeclarativePathView::movementEnding()
int QDeclarativePathViewPrivate::calcCurrentIndex()
{
int current = -1;
- if (model && items.count()) {
+ if (modelCount && model && items.count()) {
offset = qmlMod(offset, modelCount);
if (offset < 0)
offset += modelCount;
@@ -1617,7 +1629,7 @@ void QDeclarativePathViewPrivate::updateCurrent()
Q_Q(QDeclarativePathView);
if (moveReason != Mouse)
return;
- if (!haveHighlightRange || highlightRangeMode != QDeclarativePathView::StrictlyEnforceRange)
+ if (!modelCount || !haveHighlightRange || highlightRangeMode != QDeclarativePathView::StrictlyEnforceRange)
return;
int idx = calcCurrentIndex();
diff --git a/src/declarative/graphicsitems/qdeclarativepincharea.cpp b/src/declarative/graphicsitems/qdeclarativepincharea.cpp
new file mode 100644
index 0000000..eae83f6
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepincharea.cpp
@@ -0,0 +1,582 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 "qdeclarativepincharea_p.h"
+#include "qdeclarativepincharea_p_p.h"
+
+#include <QApplication>
+#include <QGraphicsScene>
+
+#include <float.h>
+#include <math.h>
+
+QT_BEGIN_NAMESPACE
+
+
+/*!
+ \qmlclass PinchEvent QDeclarativePinchEvent
+ \ingroup qml-event-elements
+ \brief The PinchEvent object provides information about a pinch event.
+
+ \bold {The PinchEvent element was added in QtQuick 1.1}
+
+ The \c center, \c startCenter, \c previousCenter properties provide the center position between the two touch points.
+
+ The \c scale and \c previousScale properties provide the scale factor.
+
+ The \c angle, \c previousAngle and \c rotation properties provide the angle between the two points and the amount of rotation.
+
+ The \c point1, \c point2, \c startPoint1, \c startPoint2 properties provide the positions of the touch points.
+
+ The \c accepted property may be set to false in the \c onPinchStarted handler if the gesture should not
+ be handled.
+
+ \sa PinchArea
+*/
+
+/*!
+ \qmlproperty QPointF PinchEvent::center
+ \qmlproperty QPointF PinchEvent::startCenter
+ \qmlproperty QPointF PinchEvent::previousCenter
+
+ These properties hold the position of the center point between the two touch points.
+
+ \list
+ \o \c center is the current center point
+ \o \c previousCenter is the center point of the previous event.
+ \o \c startCenter is the center point when the gesture began
+ \endlist
+*/
+
+/*!
+ \qmlproperty real PinchEvent::scale
+ \qmlproperty real PinchEvent::previousScale
+
+ These properties hold the scale factor determined by the change in distance between the two touch points.
+
+ \list
+ \o \c scale is the current scale factor.
+ \o \c previousScale is the scale factor of the previous event.
+ \endlist
+
+ When a pinch gesture is started, the scale is 1.0.
+*/
+
+/*!
+ \qmlproperty real PinchEvent::angle
+ \qmlproperty real PinchEvent::previousAngle
+ \qmlproperty real PinchEvent::rotation
+
+ These properties hold the angle between the two touch points.
+
+ \list
+ \o \c angle is the current angle between the two points in the range -180 to 180.
+ \o \c previousAngle is the angle of the previous event.
+ \o \c rotation is the total rotation since the pinch gesture started.
+ \endlist
+
+ When a pinch gesture is started, the rotation is 0.0.
+*/
+
+/*!
+ \qmlproperty QPointF PinchEvent::point1
+ \qmlproperty QPointF PinchEvent::startPoint1
+ \qmlproperty QPointF PinchEvent::point2
+ \qmlproperty QPointF PinchEvent::startPoint2
+
+ These properties provide the actual touch points generating the pinch.
+
+ \list
+ \o \c point1 and \c point2 hold the current positions of the points.
+ \o \c startPoint1 and \c startPoint2 hold the positions of the points when the second point was touched.
+ \endlist
+*/
+
+/*!
+ \qmlproperty bool PinchEvent::accepted
+
+ Setting this property to false in the \c PinchArea::onPinchStarted handler
+ will result in no further pinch events being generated, and the gesture
+ ignored.
+*/
+
+QDeclarativePinch::QDeclarativePinch()
+ : m_target(0), m_minScale(1.0), m_maxScale(1.0)
+ , m_minRotation(0.0), m_maxRotation(0.0)
+ , m_axis(NoDrag), m_xmin(-FLT_MAX), m_xmax(FLT_MAX)
+ , m_ymin(-FLT_MAX), m_ymax(FLT_MAX), m_active(false)
+{
+}
+
+QDeclarativePinchAreaPrivate::~QDeclarativePinchAreaPrivate()
+{
+ delete pinch;
+}
+
+/*!
+ \qmlclass PinchArea QDeclarativePinchArea
+ \brief The PinchArea item enables simple pinch gesture handling.
+ \inherits Item
+
+ \bold {The PinchArea element was added in QtQuick 1.1}
+
+ A PinchArea is an invisible item that is typically used in conjunction with
+ a visible item in order to provide pinch gesture handling for that item.
+
+ The \l enabled property is used to enable and disable pinch handling for
+ the proxied item. When disabled, the pinch area becomes transparent to
+ mouse/touch events.
+
+ PinchArea can be used in two ways:
+
+ \list
+ \o setting a \c pinch.target to provide automatic interaction with an element
+ \o using the onPinchStarted, onPinchUpdated and onPinchFinished handlers
+ \endlist
+
+ \sa PinchEvent
+*/
+
+/*!
+ \qmlsignal PinchArea::onPinchStarted()
+
+ This handler is called when the pinch area detects that a pinch gesture has started.
+
+ The \l {PinchEvent}{pinch} parameter provides information about the pinch gesture,
+ including the scale, center and angle of the pinch.
+
+ To ignore this gesture set the \c pinch.accepted property to false. The gesture
+ will be cancelled and no further events will be sent.
+*/
+
+/*!
+ \qmlsignal PinchArea::onPinchUpdated()
+
+ This handler is called when the pinch area detects that a pinch gesture has changed.
+
+ The \l {PinchEvent}{pinch} parameter provides information about the pinch gesture,
+ including the scale, center and angle of the pinch.
+*/
+
+/*!
+ \qmlsignal PinchArea::onPinchFinished()
+
+ This handler is called when the pinch area detects that a pinch gesture has finished.
+
+ The \l {PinchEvent}{pinch} parameter provides information about the pinch gesture,
+ including the scale, center and angle of the pinch.
+*/
+
+
+/*!
+ \qmlproperty Item PinchArea::pinch.target
+ \qmlproperty bool PinchArea::pinch.active
+ \qmlproperty real PinchArea::pinch.minimumScale
+ \qmlproperty real PinchArea::pinch.maximumScale
+ \qmlproperty real PinchArea::pinch.minimumRotation
+ \qmlproperty real PinchArea::pinch.maximumRotation
+ \qmlproperty enumeration PinchArea::pinch.dragAxis
+ \qmlproperty real PinchArea::pinch.minimumX
+ \qmlproperty real PinchArea::pinch.maximumX
+ \qmlproperty real PinchArea::pinch.minimumY
+ \qmlproperty real PinchArea::pinch.maximumY
+
+ \c pinch provides a convenient way to make an item react to pinch gestures.
+
+ \list
+ \i \c pinch.target specifies the id of the item to drag.
+ \i \c pinch.active specifies if the target item is currently being dragged.
+ \i \c pinch.minimumScale and \c pinch.maximumScale limit the range of the Item::scale property.
+ \i \c pinch.minimumRotation and \c pinch.maximumRotation limit the range of the Item::rotation property.
+ \i \c pinch.dragAxis specifies whether dragging in not allowed (\c Pinch.NoDrag), can be done horizontally (\c Pinch.XAxis), vertically (\c Pinch.YAxis), or both (\c Pinch.XandYAxis)
+ \i \c pinch.minimum and \c pinch.maximum limit how far the target can be dragged along the corresponding axes.
+ \endlist
+*/
+
+QDeclarativePinchArea::QDeclarativePinchArea(QDeclarativeItem *parent)
+ : QDeclarativeItem(*(new QDeclarativePinchAreaPrivate), parent)
+{
+ Q_D(QDeclarativePinchArea);
+ d->init();
+}
+
+QDeclarativePinchArea::~QDeclarativePinchArea()
+{
+}
+
+/*!
+ \qmlproperty bool PinchArea::enabled
+ This property holds whether the item accepts pinch gestures.
+
+ This property defaults to true.
+*/
+bool QDeclarativePinchArea::isEnabled() const
+{
+ Q_D(const QDeclarativePinchArea);
+ return d->absorb;
+}
+
+void QDeclarativePinchArea::setEnabled(bool a)
+{
+ Q_D(QDeclarativePinchArea);
+ if (a != d->absorb) {
+ d->absorb = a;
+ emit enabledChanged();
+ }
+}
+
+bool QDeclarativePinchArea::event(QEvent *event)
+{
+ Q_D(QDeclarativePinchArea);
+ if (!d->absorb || !isVisible())
+ return QDeclarativeItem::event(event);
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate: {
+ QTouchEvent *touch = static_cast<QTouchEvent*>(event);
+ d->touchPoints.clear();
+ for (int i = 0; i < touch->touchPoints().count(); ++i) {
+ if (!(touch->touchPoints().at(i).state() & Qt::TouchPointReleased)) {
+ d->touchPoints << touch->touchPoints().at(i);
+ }
+ }
+ updatePinch();
+ }
+ return true;
+ case QEvent::TouchEnd:
+ d->touchPoints.clear();
+ updatePinch();
+ break;
+ default:
+ return QDeclarativeItem::event(event);
+ }
+
+ return QDeclarativeItem::event(event);
+}
+
+void QDeclarativePinchArea::updatePinch()
+{
+ Q_D(QDeclarativePinchArea);
+ if (d->touchPoints.count() != 2) {
+ if (d->inPinch) {
+ d->stealMouse = false;
+ setKeepMouseGrab(false);
+ d->inPinch = false;
+ const qreal rotationAngle = d->pinchStartAngle - d->pinchLastAngle;
+ QPointF pinchCenter = mapFromScene(d->sceneLastCenter);
+ QDeclarativePinchEvent pe(pinchCenter, d->pinchLastScale, d->pinchLastAngle, rotationAngle);
+ pe.setStartCenter(d->pinchStartCenter);
+ pe.setPreviousCenter(pinchCenter);
+ pe.setPreviousAngle(d->pinchLastAngle);
+ pe.setPreviousScale(d->pinchLastScale);
+ pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));
+ pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
+ pe.setPoint1(d->lastPoint1);
+ pe.setPoint2(d->lastPoint2);
+ emit pinchFinished(&pe);
+ d->pinchStartDist = 0;
+ if (d->pinch && d->pinch->target())
+ d->pinch->setActive(false);
+ }
+ return;
+ }
+ if (d->touchPoints.at(0).state() & Qt::TouchPointPressed
+ || d->touchPoints.at(1).state() & Qt::TouchPointPressed) {
+ d->sceneStartPoint1 = d->touchPoints.at(0).scenePos();
+ d->sceneStartPoint2 = d->touchPoints.at(1).scenePos();
+ d->inPinch = false;
+ d->pinchRejected = false;
+ } else if (!d->pinchRejected){
+ QDeclarativeItem *grabber = scene() ? qobject_cast<QDeclarativeItem*>(scene()->mouseGrabberItem()) : 0;
+ if (grabber == this || !grabber || !grabber->keepMouseGrab()) {
+ const int dragThreshold = QApplication::startDragDistance();
+ QPointF p1 = d->touchPoints.at(0).scenePos();
+ QPointF p2 = d->touchPoints.at(1).scenePos();
+ qreal dx = p1.x() - p2.x();
+ qreal dy = p1.y() - p2.y();
+ qreal dist = sqrt(dx*dx + dy*dy);
+ QPointF sceneCenter = (p1 + p2)/2;
+ qreal angle = QLineF(p1, p2).angle();
+ if (angle > 180)
+ angle -= 360;
+ if (!d->inPinch) {
+ if (qAbs(p1.x()-d->sceneStartPoint1.x()) > dragThreshold
+ || qAbs(p1.y()-d->sceneStartPoint1.y()) > dragThreshold
+ || qAbs(p2.x()-d->sceneStartPoint2.x()) > dragThreshold
+ || qAbs(p2.y()-d->sceneStartPoint2.y()) > dragThreshold) {
+ d->sceneStartCenter = sceneCenter;
+ d->sceneLastCenter = sceneCenter;
+ d->pinchStartCenter = mapFromScene(sceneCenter);
+ d->pinchStartDist = dist;
+ d->pinchStartAngle = angle;
+ d->pinchLastScale = 1.0;
+ d->pinchLastAngle = angle;
+ d->lastPoint1 = d->touchPoints.at(0).pos();
+ d->lastPoint2 = d->touchPoints.at(1).pos();
+ QDeclarativePinchEvent pe(d->pinchStartCenter, 1.0, angle, 0.0);
+ pe.setStartCenter(d->pinchStartCenter);
+ pe.setPreviousCenter(d->pinchStartCenter);
+ pe.setPreviousAngle(d->pinchLastAngle);
+ pe.setPreviousScale(d->pinchLastScale);
+ pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));
+ pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
+ pe.setPoint1(d->lastPoint1);
+ pe.setPoint2(d->lastPoint2);
+ emit pinchStarted(&pe);
+ if (pe.accepted()) {
+ d->inPinch = true;
+ d->stealMouse = true;
+ QGraphicsScene *s = scene();
+ if (s && s->mouseGrabberItem() != this)
+ grabMouse();
+ setKeepMouseGrab(true);
+ if (d->pinch && d->pinch->target()) {
+ d->pinchStartPos = pinch()->target()->pos();
+ d->pinchStartScale = d->pinch->target()->scale();
+ d->pinchStartRotation = d->pinch->target()->rotation();
+ d->pinch->setActive(true);
+ }
+ } else {
+ d->pinchRejected = true;
+ }
+ }
+ } else if (d->pinchStartDist > 0) {
+ qreal scale = dist / d->pinchStartDist;
+ qreal rotationAngle = d->pinchStartAngle - angle;
+ if (rotationAngle > 180)
+ rotationAngle -= 360;
+ QPointF pinchCenter = mapFromScene(sceneCenter);
+ QDeclarativePinchEvent pe(pinchCenter, scale, angle, rotationAngle);
+ pe.setStartCenter(d->pinchStartCenter);
+ pe.setPreviousCenter(mapFromScene(d->sceneLastCenter));
+ pe.setPreviousAngle(d->pinchLastAngle);
+ pe.setPreviousScale(d->pinchLastScale);
+ pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));
+ pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
+ pe.setPoint1(d->touchPoints.at(0).pos());
+ pe.setPoint2(d->touchPoints.at(1).pos());
+ d->pinchLastScale = scale;
+ d->sceneLastCenter = sceneCenter;
+ d->pinchLastAngle = angle;
+ d->lastPoint1 = d->touchPoints.at(0).pos();
+ d->lastPoint2 = d->touchPoints.at(1).pos();
+ emit pinchUpdated(&pe);
+ if (d->pinch && d->pinch->target()) {
+ qreal s = d->pinchStartScale * scale;
+ s = qMin(qMax(pinch()->minimumScale(),s), pinch()->maximumScale());
+ pinch()->target()->setScale(s);
+ QPointF pos = sceneCenter - d->sceneStartCenter + d->pinchStartPos;
+ if (pinch()->axis() & QDeclarativePinch::XAxis) {
+ qreal x = pos.x();
+ if (x < pinch()->xmin())
+ x = pinch()->xmin();
+ else if (x > pinch()->xmax())
+ x = pinch()->xmax();
+ pinch()->target()->setX(x);
+ }
+ if (pinch()->axis() & QDeclarativePinch::YAxis) {
+ qreal y = pos.y();
+ if (y < pinch()->ymin())
+ y = pinch()->ymin();
+ else if (y > pinch()->ymax())
+ y = pinch()->ymax();
+ pinch()->target()->setY(y);
+ }
+ if (d->pinchStartRotation >= pinch()->minimumRotation()
+ && d->pinchStartRotation <= pinch()->maximumRotation()) {
+ qreal r = rotationAngle + d->pinchStartRotation;
+ r = qMin(qMax(pinch()->minimumRotation(),r), pinch()->maximumRotation());
+ pinch()->target()->setRotation(r);
+ }
+ }
+ }
+ }
+ }
+}
+
+void QDeclarativePinchArea::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativePinchArea);
+ d->stealMouse = false;
+ if (!d->absorb)
+ QDeclarativeItem::mousePressEvent(event);
+ else {
+ setKeepMouseGrab(false);
+ event->setAccepted(true);
+ }
+}
+
+void QDeclarativePinchArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativePinchArea);
+ if (!d->absorb) {
+ QDeclarativeItem::mouseMoveEvent(event);
+ return;
+ }
+}
+
+void QDeclarativePinchArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativePinchArea);
+ d->stealMouse = false;
+ if (!d->absorb) {
+ QDeclarativeItem::mouseReleaseEvent(event);
+ } else {
+ QGraphicsScene *s = scene();
+ if (s && s->mouseGrabberItem() == this)
+ ungrabMouse();
+ setKeepMouseGrab(false);
+ }
+}
+
+bool QDeclarativePinchArea::sceneEvent(QEvent *event)
+{
+ bool rv = QDeclarativeItem::sceneEvent(event);
+ if (event->type() == QEvent::UngrabMouse) {
+ setKeepMouseGrab(false);
+ }
+ return rv;
+}
+
+bool QDeclarativePinchArea::sendMouseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativePinchArea);
+ QGraphicsSceneMouseEvent mouseEvent(event->type());
+ QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect();
+
+ QGraphicsScene *s = scene();
+ QDeclarativeItem *grabber = s ? qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()) : 0;
+ bool stealThisEvent = d->stealMouse;
+ if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
+ mouseEvent.setAccepted(false);
+ for (int i = 0x1; i <= 0x10; i <<= 1) {
+ if (event->buttons() & i) {
+ Qt::MouseButton button = Qt::MouseButton(i);
+ mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button)));
+ }
+ }
+ mouseEvent.setScenePos(event->scenePos());
+ mouseEvent.setLastScenePos(event->lastScenePos());
+ mouseEvent.setPos(mapFromScene(event->scenePos()));
+ mouseEvent.setLastPos(mapFromScene(event->lastScenePos()));
+
+ switch(mouseEvent.type()) {
+ case QEvent::GraphicsSceneMouseMove:
+ mouseMoveEvent(&mouseEvent);
+ break;
+ case QEvent::GraphicsSceneMousePress:
+ mousePressEvent(&mouseEvent);
+ break;
+ case QEvent::GraphicsSceneMouseRelease:
+ mouseReleaseEvent(&mouseEvent);
+ break;
+ default:
+ break;
+ }
+ grabber = qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem());
+ if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this)
+ grabMouse();
+
+ return stealThisEvent;
+ }
+ if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) {
+ d->stealMouse = false;
+ if (s && s->mouseGrabberItem() == this)
+ ungrabMouse();
+ setKeepMouseGrab(false);
+ }
+ return false;
+}
+
+bool QDeclarativePinchArea::sceneEventFilter(QGraphicsItem *i, QEvent *e)
+{
+ Q_D(QDeclarativePinchArea);
+ if (!d->absorb || !isVisible())
+ return QDeclarativeItem::sceneEventFilter(i, e);
+ switch (e->type()) {
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseMove:
+ case QEvent::GraphicsSceneMouseRelease:
+ return sendMouseEvent(static_cast<QGraphicsSceneMouseEvent *>(e));
+ break;
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate: {
+ QTouchEvent *touch = static_cast<QTouchEvent*>(e);
+ d->touchPoints.clear();
+ for (int i = 0; i < touch->touchPoints().count(); ++i)
+ if (!(touch->touchPoints().at(i).state() & Qt::TouchPointReleased))
+ d->touchPoints << touch->touchPoints().at(i);
+ updatePinch();
+ }
+ return d->inPinch;
+ case QEvent::TouchEnd:
+ d->touchPoints.clear();
+ updatePinch();
+ break;
+ default:
+ break;
+ }
+
+ return QDeclarativeItem::sceneEventFilter(i, e);
+}
+
+void QDeclarativePinchArea::geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry)
+{
+ QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+QVariant QDeclarativePinchArea::itemChange(GraphicsItemChange change,
+ const QVariant &value)
+{
+ return QDeclarativeItem::itemChange(change, value);
+}
+
+QDeclarativePinch *QDeclarativePinchArea::pinch()
+{
+ Q_D(QDeclarativePinchArea);
+ if (!d->pinch)
+ d->pinch = new QDeclarativePinch;
+ return d->pinch;
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativepincharea_p.h b/src/declarative/graphicsitems/qdeclarativepincharea_p.h
new file mode 100644
index 0000000..6d04708
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepincharea_p.h
@@ -0,0 +1,308 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 QDECLARATIVEPINCHAREA_H
+#define QDECLARATIVEPINCHAREA_H
+
+#include <qdeclarativeitem.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_AUTOTEST_EXPORT QDeclarativePinch : public QObject
+{
+ Q_OBJECT
+
+ Q_ENUMS(Axis)
+ Q_PROPERTY(QGraphicsObject *target READ target WRITE setTarget RESET resetTarget)
+ Q_PROPERTY(qreal minimumScale READ minimumScale WRITE setMinimumScale NOTIFY minimumScaleChanged)
+ Q_PROPERTY(qreal maximumScale READ maximumScale WRITE setMaximumScale NOTIFY maximumScaleChanged)
+ Q_PROPERTY(qreal minimumRotation READ minimumRotation WRITE setMinimumRotation NOTIFY minimumRotationChanged)
+ Q_PROPERTY(qreal maximumRotation READ maximumRotation WRITE setMaximumRotation NOTIFY maximumRotationChanged)
+ Q_PROPERTY(Axis dragAxis READ axis WRITE setAxis NOTIFY dragAxisChanged)
+ Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
+ Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
+ Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
+ Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
+ Q_PROPERTY(bool active READ active NOTIFY activeChanged)
+
+public:
+ QDeclarativePinch();
+
+ QGraphicsObject *target() const { return m_target; }
+ void setTarget(QGraphicsObject *target) {
+ if (target == m_target)
+ return;
+ m_target = target;
+ emit targetChanged();
+ }
+ void resetTarget() {
+ if (!m_target)
+ return;
+ m_target = 0;
+ emit targetChanged();
+ }
+
+ qreal minimumScale() const { return m_minScale; }
+ void setMinimumScale(qreal s) {
+ if (s == m_minScale)
+ return;
+ m_minScale = s;
+ emit minimumScaleChanged();
+ }
+ qreal maximumScale() const { return m_maxScale; }
+ void setMaximumScale(qreal s) {
+ if (s == m_maxScale)
+ return;
+ m_maxScale = s;
+ emit maximumScaleChanged();
+ }
+
+ qreal minimumRotation() const { return m_minRotation; }
+ void setMinimumRotation(qreal r) {
+ if (r == m_minRotation)
+ return;
+ m_minRotation = r;
+ emit minimumRotationChanged();
+ }
+ qreal maximumRotation() const { return m_maxRotation; }
+ void setMaximumRotation(qreal r) {
+ if (r == m_maxRotation)
+ return;
+ m_maxRotation = r;
+ emit maximumRotationChanged();
+ }
+
+ enum Axis { NoDrag=0x00, XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
+ Axis axis() const { return m_axis; }
+ void setAxis(Axis a) {
+ if (a == m_axis)
+ return;
+ m_axis = a;
+ emit dragAxisChanged();
+ }
+
+ qreal xmin() const { return m_xmin; }
+ void setXmin(qreal x) {
+ if (x == m_xmin)
+ return;
+ m_xmin = x;
+ emit minimumXChanged();
+ }
+ qreal xmax() const { return m_xmax; }
+ void setXmax(qreal x) {
+ if (x == m_xmax)
+ return;
+ m_xmax = x;
+ emit maximumXChanged();
+ }
+ qreal ymin() const { return m_ymin; }
+ void setYmin(qreal y) {
+ if (y == m_ymin)
+ return;
+ m_ymin = y;
+ emit minimumYChanged();
+ }
+ qreal ymax() const { return m_ymax; }
+ void setYmax(qreal y) {
+ if (y == m_ymax)
+ return;
+ m_ymax = y;
+ emit maximumYChanged();
+ }
+
+ bool active() const { return m_active; }
+ void setActive(bool a) {
+ if (a == m_active)
+ return;
+ m_active = a;
+ emit activeChanged();
+ }
+
+signals:
+ void targetChanged();
+ void minimumScaleChanged();
+ void maximumScaleChanged();
+ void minimumRotationChanged();
+ void maximumRotationChanged();
+ void dragAxisChanged();
+ void minimumXChanged();
+ void maximumXChanged();
+ void minimumYChanged();
+ void maximumYChanged();
+ void activeChanged();
+
+private:
+ QGraphicsObject *m_target;
+ qreal m_minScale;
+ qreal m_maxScale;
+ qreal m_minRotation;
+ qreal m_maxRotation;
+ Axis m_axis;
+ qreal m_xmin;
+ qreal m_xmax;
+ qreal m_ymin;
+ qreal m_ymax;
+ bool m_active;
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativePinchEvent : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QPointF center READ center)
+ Q_PROPERTY(QPointF startCenter READ startCenter)
+ Q_PROPERTY(QPointF previousCenter READ previousCenter)
+ Q_PROPERTY(qreal scale READ scale)
+ Q_PROPERTY(qreal previousScale READ previousScale)
+ Q_PROPERTY(qreal angle READ angle)
+ Q_PROPERTY(qreal previousAngle READ previousAngle)
+ Q_PROPERTY(qreal rotation READ rotation)
+ Q_PROPERTY(QPointF point1 READ point1)
+ Q_PROPERTY(QPointF startPoint1 READ startPoint1)
+ Q_PROPERTY(QPointF point2 READ point2)
+ Q_PROPERTY(QPointF startPoint2 READ startPoint2)
+ Q_PROPERTY(bool accepted READ accepted WRITE setAccepted)
+
+public:
+ QDeclarativePinchEvent(QPointF c, qreal s, qreal a, qreal r)
+ : QObject(), m_center(c), m_scale(s), m_angle(a), m_rotation(r), m_accepted(true) {}
+
+ QPointF center() const { return m_center; }
+ QPointF startCenter() const { return m_startCenter; }
+ void setStartCenter(QPointF c) { m_startCenter = c; }
+ QPointF previousCenter() const { return m_lastCenter; }
+ void setPreviousCenter(QPointF c) { m_lastCenter = c; }
+ qreal scale() const { return m_scale; }
+ qreal previousScale() const { return m_lastScale; }
+ void setPreviousScale(qreal s) { m_lastScale = s; }
+ qreal angle() const { return m_angle; }
+ qreal previousAngle() const { return m_lastAngle; }
+ void setPreviousAngle(qreal a) { m_lastAngle = a; }
+ qreal rotation() const { return m_rotation; }
+ QPointF point1() const { return m_point1; }
+ void setPoint1(QPointF p) { m_point1 = p; }
+ QPointF startPoint1() const { return m_startPoint1; }
+ void setStartPoint1(QPointF p) { m_startPoint1 = p; }
+ QPointF point2() const { return m_point2; }
+ void setPoint2(QPointF p) { m_point2 = p; }
+ QPointF startPoint2() const { return m_startPoint2; }
+ void setStartPoint2(QPointF p) { m_startPoint2 = p; }
+
+ bool accepted() const { return m_accepted; }
+ void setAccepted(bool a) { m_accepted = a; }
+
+private:
+ QPointF m_center;
+ QPointF m_startCenter;
+ QPointF m_lastCenter;
+ qreal m_scale;
+ qreal m_lastScale;
+ qreal m_angle;
+ qreal m_lastAngle;
+ qreal m_rotation;
+ QPointF m_point1;
+ QPointF m_point2;
+ QPointF m_startPoint1;
+ QPointF m_startPoint2;
+ bool m_accepted;
+};
+
+
+class QDeclarativeMouseEvent;
+class QDeclarativePinchAreaPrivate;
+class Q_AUTOTEST_EXPORT QDeclarativePinchArea : public QDeclarativeItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(QDeclarativePinch *pinch READ pinch CONSTANT)
+
+public:
+ QDeclarativePinchArea(QDeclarativeItem *parent=0);
+ ~QDeclarativePinchArea();
+
+ bool isEnabled() const;
+ void setEnabled(bool);
+
+ QDeclarativePinch *pinch();
+
+Q_SIGNALS:
+ void enabledChanged();
+ void pinchStarted(QDeclarativePinchEvent *pinch);
+ void pinchUpdated(QDeclarativePinchEvent *pinch);
+ void pinchFinished(QDeclarativePinchEvent *pinch);
+
+protected:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ bool sceneEvent(QEvent *);
+ bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
+ bool sceneEventFilter(QGraphicsItem *i, QEvent *e);
+ bool event(QEvent *);
+
+ virtual void geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry);
+ virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value);
+
+private:
+ void updatePinch();
+ void handlePress();
+ void handleRelease();
+
+private:
+ Q_DISABLE_COPY(QDeclarativePinchArea)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativePinchArea)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativePinch)
+QML_DECLARE_TYPE(QDeclarativePinchEvent)
+QML_DECLARE_TYPE(QDeclarativePinchArea)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEPINCHAREA_H
diff --git a/src/declarative/graphicsitems/qdeclarativepincharea_p_p.h b/src/declarative/graphicsitems/qdeclarativepincharea_p_p.h
new file mode 100644
index 0000000..5641e35
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepincharea_p_p.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 QDECLARATIVEPINCHAREA_P_H
+#define QDECLARATIVEPINCHAREA_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 <qdatetime.h>
+#include <qbasictimer.h>
+#include <qevent.h>
+#include <qgraphicssceneevent.h>
+#include "qdeclarativeitem_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativePinch;
+class QDeclarativePinchAreaPrivate : public QDeclarativeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativePinchArea)
+public:
+ QDeclarativePinchAreaPrivate()
+ : absorb(true), stealMouse(false), inPinch(false)
+ , pinchRejected(false), pinch(0), pinchStartDist(0)
+ {
+ }
+
+ ~QDeclarativePinchAreaPrivate();
+
+ void init()
+ {
+ Q_Q(QDeclarativePinchArea);
+ q->setAcceptedMouseButtons(Qt::LeftButton);
+ q->setAcceptTouchEvents(true);
+ q->setFiltersChildEvents(true);
+ }
+
+ bool absorb : 1;
+ bool stealMouse : 1;
+ bool inPinch : 1;
+ bool pinchRejected : 1;
+ QDeclarativePinch *pinch;
+ QPointF sceneStartPoint1;
+ QPointF sceneStartPoint2;
+ QPointF lastPoint1;
+ QPointF lastPoint2;
+ qreal pinchStartDist;
+ qreal pinchStartScale;
+ qreal pinchLastScale;
+ qreal pinchStartRotation;
+ qreal pinchStartAngle;
+ qreal pinchLastAngle;
+ QPointF sceneStartCenter;
+ QPointF pinchStartCenter;
+ QPointF sceneLastCenter;
+ QPointF pinchStartPos;
+ QList<QTouchEvent::TouchPoint> touchPoints;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEPINCHAREA_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
index 4e049c7..27a1301 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -111,14 +111,14 @@ void QDeclarativeBasePositioner::graphicsWidgetGeometryChanged()
Note that the subclass is responsible for adding the spacing in between items.
*/
QDeclarativeBasePositioner::QDeclarativeBasePositioner(PositionerType at, QDeclarativeItem *parent)
- : QDeclarativeItem(*(new QDeclarativeBasePositionerPrivate), parent)
+ : QDeclarativeImplicitSizeItem(*(new QDeclarativeBasePositionerPrivate), parent)
{
Q_D(QDeclarativeBasePositioner);
d->init(at);
}
QDeclarativeBasePositioner::QDeclarativeBasePositioner(QDeclarativeBasePositionerPrivate &dd, PositionerType at, QDeclarativeItem *parent)
- : QDeclarativeItem(dd, parent)
+ : QDeclarativeImplicitSizeItem(dd, parent)
{
Q_D(QDeclarativeBasePositioner);
d->init(at);
@@ -364,9 +364,13 @@ void QDeclarativeBasePositioner::finishApplyTransitions()
\qml
Column {
spacing: 2
- add: ...
- move: ...
- ...
+ add: Transition {
+ // Define an animation for adding a new item...
+ }
+ move: Transition {
+ // Define an animation for moving items within the column...
+ }
+ // ...
}
\endqml
@@ -381,7 +385,7 @@ void QDeclarativeBasePositioner::finishApplyTransitions()
Items with a width or height of 0 will not be positioned.
- \sa Row, Grid, Flow, {declarative/positioners}{Positioners example}
+ \sa Row, Grid, Flow, {declarative/positioners/addandremove}{Positioners example}
*/
/*!
\qmlproperty Transition Column::add
@@ -421,7 +425,7 @@ void QDeclarativeBasePositioner::finishApplyTransitions()
}
\endqml
- \sa add, {declarative/positioners}{Positioners example}
+ \sa add, {declarative/positioners/addandremove}{Positioners example}
*/
/*!
\qmlproperty int Column::spacing
@@ -524,7 +528,7 @@ void QDeclarativeColumn::reportConflictingAnchors()
Items with a width or height of 0 will not be positioned.
- \sa Column, Grid, Flow, {declarative/positioners}{Positioners example}
+ \sa Column, Grid, Flow, {declarative/positioners/addandremove}{Positioners example}
*/
/*!
\qmlproperty Transition Row::add
@@ -563,7 +567,7 @@ void QDeclarativeColumn::reportConflictingAnchors()
}
\endqml
- \sa add, {declarative/positioners}{Positioners example}
+ \sa add, {declarative/positioners/addandremove}{Positioners example}
*/
/*!
\qmlproperty int Row::spacing
@@ -574,21 +578,55 @@ void QDeclarativeColumn::reportConflictingAnchors()
\sa Grid::spacing
*/
QDeclarativeRow::QDeclarativeRow(QDeclarativeItem *parent)
-: QDeclarativeBasePositioner(Horizontal, parent)
+: QDeclarativeBasePositioner(Horizontal, parent), m_layoutDirection(Qt::LeftToRight)
{
}
+/*!
+ \qmlproperty enumeration Row::layoutDirection
+ This property holds the layoutDirection of the row.
+
+ Possible values:
+
+ \list
+ \o Qt.LeftToRight (default) - Items are laid out from left to right. If the width of the row is explicitly set,
+ the left anchor remains to the left of the row.
+ \o Qt.RightToLeft - Items are laid out from right to left. If the width of the row is explicitly set,
+ the right anchor remains to the right of the row.
+ \endlist
+
+ \sa Grid::layoutDirection, Flow::layoutDirection, {declarative/positioners/layoutdirection}{Layout directions example}
+*/
+Qt::LayoutDirection QDeclarativeRow::layoutDirection() const
+{
+ return m_layoutDirection;
+}
+
+void QDeclarativeRow::setLayoutDirection(Qt::LayoutDirection layoutDirection)
+{
+ if (m_layoutDirection != layoutDirection) {
+ m_layoutDirection = layoutDirection;
+ prePositioning();
+ emit layoutDirectionChanged();
+ }
+}
+
void QDeclarativeRow::doPositioning(QSizeF *contentSize)
{
int hoffset = 0;
+ QList<int> hoffsets;
for (int ii = 0; ii < positionedItems.count(); ++ii) {
const PositionedItem &child = positionedItems.at(ii);
if (!child.item || !child.isVisible)
continue;
- if(child.item->x() != hoffset)
- positionX(hoffset, child);
+ if(m_layoutDirection == Qt::LeftToRight){
+ if(child.item->x() != hoffset)
+ positionX(hoffset, child);
+ }else{
+ hoffsets << hoffset;
+ }
contentSize->setHeight(qMax(contentSize->height(), QGraphicsItemPrivate::get(child.item)->height()));
@@ -597,6 +635,26 @@ void QDeclarativeRow::doPositioning(QSizeF *contentSize)
}
contentSize->setWidth(hoffset - spacing());
+
+ if(m_layoutDirection == Qt::LeftToRight)
+ return;
+
+ //Right to Left layout
+ int end = 0;
+ if(!widthValid())
+ end = contentSize->width();
+ else
+ end = width();
+
+ int acc = 0;
+ for (int ii = 0; ii < positionedItems.count(); ++ii) {
+ const PositionedItem &child = positionedItems.at(ii);
+ if (!child.item || !child.isVisible)
+ continue;
+ hoffset = end - hoffsets[acc++] - QGraphicsItemPrivate::get(child.item)->width();
+ if(child.item->x() != hoffset)
+ positionX(hoffset, child);
+ }
}
void QDeclarativeRow::reportConflictingAnchors()
@@ -674,7 +732,7 @@ void QDeclarativeRow::reportConflictingAnchors()
Items with a width or height of 0 will not be positioned.
- \sa Flow, Row, Column, {declarative/positioners}{Positioners example}
+ \sa Flow, Row, Column, {declarative/positioners/addandremove}{Positioners example}
*/
/*!
\qmlproperty Transition Grid::add
@@ -712,7 +770,7 @@ void QDeclarativeRow::reportConflictingAnchors()
}
\endqml
- \sa add, {declarative/positioners}{Positioners example}
+ \sa add, {declarative/positioners/addandremove}{Positioners example}
*/
/*!
\qmlproperty int Grid::spacing
@@ -732,7 +790,7 @@ void QDeclarativeRow::reportConflictingAnchors()
\sa rows, columns
*/
QDeclarativeGrid::QDeclarativeGrid(QDeclarativeItem *parent) :
- QDeclarativeBasePositioner(Both, parent), m_rows(-1), m_columns(-1), m_flow(LeftToRight)
+ QDeclarativeBasePositioner(Both, parent), m_rows(-1), m_columns(-1), m_flow(LeftToRight), m_layoutDirection(Qt::LeftToRight)
{
}
@@ -780,7 +838,7 @@ void QDeclarativeGrid::setRows(const int rows)
\list
\o Grid.LeftToRight (default) - Items are positioned next to
- to each other from left to right, then wrapped to the next line.
+ each other in the \l layoutDirection, then wrapped to the next line.
\o Grid.TopToBottom - Items are positioned next to each
other from top to bottom, then wrapped to the next column.
\endlist
@@ -799,6 +857,37 @@ void QDeclarativeGrid::setFlow(Flow flow)
}
}
+/*!
+ \qmlproperty enumeration Grid::layoutDirection
+ This property holds the layout direction of the layout.
+
+ Possible values are:
+
+ \list
+ \o Qt.LeftToRight (default) - Items are positioned beginning
+ from the top, left anchor. The flow direction is dependent
+ on the \l Grid::flow property.
+ \o Qt.RightToLeft - Items are positioned beginning from the
+ top, right anchor. The flow direction is dependent on the
+ \l Grid::flow property.
+ \endlist
+
+ \sa Flow::layoutDirection, Row::layoutDirection, {declarative/positioners/layoutdirection}{Layout directions example}
+*/
+Qt::LayoutDirection QDeclarativeGrid::layoutDirection() const
+{
+ return m_layoutDirection;
+}
+
+void QDeclarativeGrid::setLayoutDirection(Qt::LayoutDirection layoutDirection)
+{
+ if (m_layoutDirection != layoutDirection) {
+ m_layoutDirection = layoutDirection;
+ prePositioning();
+ emit layoutDirectionChanged();
+ }
+}
+
void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
{
@@ -821,6 +910,9 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
c = (numVisible+(m_rows-1))/m_rows;
}
+ if(r==0 || c==0)
+ return; //Nothing to do
+
QList<int> maxColWidth;
QList<int> maxRowHeight;
int childIndex =0;
@@ -851,7 +943,7 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
if (i==0)
maxColWidth << 0;
- if (childIndex == positionedItems.count())
+ if (childIndex == visibleItems.count())
break;
const PositionedItem &child = visibleItems.at(childIndex++);
@@ -864,40 +956,71 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
}
}
+ int widthSum = 0;
+ for(int j=0; j < maxColWidth.size(); j++){
+ if(j)
+ widthSum += spacing();
+ widthSum += maxColWidth[j];
+ }
+
+ int heightSum = 0;
+ for(int i=0; i < maxRowHeight.size(); i++){
+ if(i)
+ heightSum += spacing();
+ heightSum += maxRowHeight[i];
+ }
+
+ contentSize->setHeight(heightSum);
+ contentSize->setWidth(widthSum);
+
+ int end = 0;
+ if(widthValid())
+ end = width();
+ else
+ end = widthSum;
+
int xoffset=0;
+ if(m_layoutDirection == Qt::RightToLeft)
+ xoffset=end;
int yoffset=0;
int curRow =0;
int curCol =0;
for (int i = 0; i < visibleItems.count(); ++i) {
const PositionedItem &child = visibleItems.at(i);
- if((child.item->x()!=xoffset)||(child.item->y()!=yoffset)){
- positionX(xoffset, child);
+ int childXOffset = xoffset;
+ if(m_layoutDirection == Qt::RightToLeft)
+ childXOffset -= QGraphicsItemPrivate::get(child.item)->width();
+ if((child.item->x()!=childXOffset)||(child.item->y()!=yoffset)){
+ positionX(childXOffset, child);
positionY(yoffset, child);
}
if (m_flow == LeftToRight) {
- contentSize->setWidth(qMax(contentSize->width(), xoffset + QGraphicsItemPrivate::get(child.item)->width()));
- contentSize->setHeight(yoffset + maxRowHeight[curRow]);
-
- xoffset+=maxColWidth[curCol]+spacing();
+ if(m_layoutDirection == Qt::LeftToRight)
+ xoffset+=maxColWidth[curCol]+spacing();
+ else
+ xoffset-=maxColWidth[curCol]+spacing();
curCol++;
curCol%=c;
if (!curCol){
yoffset+=maxRowHeight[curRow]+spacing();
- xoffset=0;
+ if(m_layoutDirection == Qt::LeftToRight)
+ xoffset=0;
+ else
+ xoffset=end;
curRow++;
if (curRow>=r)
break;
}
} else {
- contentSize->setHeight(qMax(contentSize->height(), yoffset + QGraphicsItemPrivate::get(child.item)->height()));
- contentSize->setWidth(xoffset + maxColWidth[curCol]);
-
yoffset+=maxRowHeight[curRow]+spacing();
curRow++;
curRow%=r;
if (!curRow){
- xoffset+=maxColWidth[curCol]+spacing();
+ if(m_layoutDirection == Qt::LeftToRight)
+ xoffset+=maxColWidth[curCol]+spacing();
+ else
+ xoffset-=maxColWidth[curCol]+spacing();
yoffset=0;
curCol++;
if (curCol>=c)
@@ -973,7 +1096,7 @@ void QDeclarativeGrid::reportConflictingAnchors()
Items with a width or height of 0 will not be positioned.
- \sa Column, Row, Grid, {declarative/positioners}{Positioners example}
+ \sa Column, Row, Grid, {declarative/positioners/addandremove}{Positioners example}
*/
/*!
\qmlproperty Transition Flow::add
@@ -1012,7 +1135,7 @@ void QDeclarativeGrid::reportConflictingAnchors()
}
\endqml
- \sa add, {declarative/positioners}{Positioners example}
+ \sa add, {declarative/positioners/addandremove}{Positioners example}
*/
/*!
\qmlproperty int Flow::spacing
@@ -1029,10 +1152,12 @@ class QDeclarativeFlowPrivate : public QDeclarativeBasePositionerPrivate
public:
QDeclarativeFlowPrivate()
- : QDeclarativeBasePositionerPrivate(), flow(QDeclarativeFlow::LeftToRight)
+ : QDeclarativeBasePositionerPrivate(), flow(QDeclarativeFlow::LeftToRight),
+ layoutDirection(Qt::LeftToRight)
{}
QDeclarativeFlow::Flow flow;
+ Qt::LayoutDirection layoutDirection;
};
QDeclarativeFlow::QDeclarativeFlow(QDeclarativeItem *parent)
@@ -1051,7 +1176,7 @@ QDeclarativeFlow::QDeclarativeFlow(QDeclarativeItem *parent)
\list
\o Flow.LeftToRight (default) - Items are positioned next to
- to each other from left to right until the width of the Flow
+ to each other according to the \l layoutDirection until the width of the Flow
is exceeded, then wrapped to the next line.
\o Flow.TopToBottom - Items are positioned next to each
other from top to bottom until the height of the Flow is exceeded,
@@ -1074,6 +1199,40 @@ void QDeclarativeFlow::setFlow(Flow flow)
}
}
+/*!
+ \qmlproperty enumeration Flow::layoutDirection
+ This property holds the layout direction of the layout.
+
+ Possible values are:
+
+ \list
+ \o Qt.LeftToRight (default) - Items are positioned beginning
+ from the top, left anchor. The flow direction is dependent
+ on the \l Flow::flow property.
+ \o Qt.RightToLeft - Items are positioned beginning from the
+ top, right anchor. The flow direction is dependent on the
+ \l Flow::flow property.
+ \endlist
+
+ \sa Grid::layoutDirection, Row::layoutDirection, {declarative/positioners/layoutdirection}{Layout directions example}
+*/
+
+Qt::LayoutDirection QDeclarativeFlow::layoutDirection() const
+{
+ Q_D(const QDeclarativeFlow);
+ return d->layoutDirection;
+}
+
+void QDeclarativeFlow::setLayoutDirection(Qt::LayoutDirection layoutDirection)
+{
+ Q_D(QDeclarativeFlow);
+ if (d->layoutDirection != layoutDirection) {
+ d->layoutDirection = layoutDirection;
+ prePositioning();
+ emit layoutDirectionChanged();
+ }
+}
+
void QDeclarativeFlow::doPositioning(QSizeF *contentSize)
{
Q_D(QDeclarativeFlow);
@@ -1081,6 +1240,7 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize)
int hoffset = 0;
int voffset = 0;
int linemax = 0;
+ QList<int> hoffsets;
for (int i = 0; i < positionedItems.count(); ++i) {
const PositionedItem &child = positionedItems.at(i);
@@ -1102,10 +1262,14 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize)
}
}
- if(child.item->x() != hoffset || child.item->y() != voffset){
- positionX(hoffset, child);
- positionY(voffset, child);
+ if(d->layoutDirection == Qt::LeftToRight){
+ if(child.item->x() != hoffset)
+ positionX(hoffset, child);
+ }else{
+ hoffsets << hoffset;
}
+ if(child.item->y() != voffset)
+ positionY(voffset, child);
contentSize->setWidth(qMax(contentSize->width(), hoffset + childPrivate->width()));
contentSize->setHeight(qMax(contentSize->height(), voffset + childPrivate->height()));
@@ -1120,6 +1284,24 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize)
linemax = qMax(linemax, qCeil(childPrivate->width()));
}
}
+
+ if(d->layoutDirection == Qt::LeftToRight)
+ return;
+
+ int end;
+ if(widthValid())
+ end = width();
+ else
+ end = contentSize->width();
+ int acc = 0;
+ for (int i = 0; i < positionedItems.count(); ++i) {
+ const PositionedItem &child = positionedItems.at(i);
+ if (!child.item || !child.isVisible)
+ continue;
+ hoffset = end - hoffsets[acc++] - QGraphicsItemPrivate::get(child.item)->width();
+ if(child.item->x() != hoffset)
+ positionX(hoffset, child);
+ }
}
void QDeclarativeFlow::reportConflictingAnchors()
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
index 9efbeb9..55d8fa1 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
@@ -42,7 +42,7 @@
#ifndef QDECLARATIVELAYOUTS_H
#define QDECLARATIVELAYOUTS_H
-#include "qdeclarativeitem.h"
+#include "qdeclarativeimplicitsizeitem_p.h"
#include <private/qdeclarativestate_p.h>
#include <private/qpodvector_p.h>
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeBasePositionerPrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeBasePositioner : public QDeclarativeItem
+class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeBasePositioner : public QDeclarativeImplicitSizeItem
{
Q_OBJECT
@@ -129,12 +129,21 @@ private:
class Q_AUTOTEST_EXPORT QDeclarativeRow: public QDeclarativeBasePositioner
{
Q_OBJECT
+ Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1)
public:
QDeclarativeRow(QDeclarativeItem *parent=0);
+
+ Qt::LayoutDirection layoutDirection() const;
+ void setLayoutDirection (Qt::LayoutDirection);
+
+Q_SIGNALS:
+ Q_REVISION(1) void layoutDirectionChanged();
+
protected:
virtual void doPositioning(QSizeF *contentSize);
virtual void reportConflictingAnchors();
private:
+ Qt::LayoutDirection m_layoutDirection;
Q_DISABLE_COPY(QDeclarativeRow)
};
@@ -144,6 +153,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeGrid : public QDeclarativeBasePositioner
Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged)
Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
+ Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1)
public:
QDeclarativeGrid(QDeclarativeItem *parent=0);
@@ -159,10 +169,14 @@ public:
Flow flow() const;
void setFlow(Flow);
+ Qt::LayoutDirection layoutDirection() const;
+ void setLayoutDirection (Qt::LayoutDirection);
+
Q_SIGNALS:
void rowsChanged();
void columnsChanged();
void flowChanged();
+ Q_REVISION(1) void layoutDirectionChanged();
protected:
virtual void doPositioning(QSizeF *contentSize);
@@ -172,6 +186,7 @@ private:
int m_rows;
int m_columns;
Flow m_flow;
+ Qt::LayoutDirection m_layoutDirection;
Q_DISABLE_COPY(QDeclarativeGrid)
};
@@ -179,6 +194,7 @@ class QDeclarativeFlowPrivate;
class Q_AUTOTEST_EXPORT QDeclarativeFlow: public QDeclarativeBasePositioner
{
Q_OBJECT
+ Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1)
Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
public:
QDeclarativeFlow(QDeclarativeItem *parent=0);
@@ -188,8 +204,12 @@ public:
Flow flow() const;
void setFlow(Flow);
+ Qt::LayoutDirection layoutDirection() const;
+ void setLayoutDirection (Qt::LayoutDirection);
+
Q_SIGNALS:
void flowChanged();
+ Q_REVISION(1) void layoutDirectionChanged();
protected:
virtual void doPositioning(QSizeF *contentSize);
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h
index c6535a7..df105c6 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h
@@ -55,7 +55,7 @@
#include "private/qdeclarativepositioners_p.h"
-#include "private/qdeclarativeitem_p.h"
+#include "private/qdeclarativeimplicitsizeitem_p_p.h"
#include <qdeclarativestate_p.h>
#include <qdeclarativetransitionmanager_p_p.h>
@@ -67,7 +67,7 @@
#include <QDebug>
QT_BEGIN_NAMESPACE
-class QDeclarativeBasePositionerPrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener
+class QDeclarativeBasePositionerPrivate : public QDeclarativeImplicitSizeItemPrivate, public QDeclarativeItemChangeListener
{
Q_DECLARE_PUBLIC(QDeclarativeBasePositioner)
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
index 94db2f1..d962919 100644
--- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
@@ -60,7 +60,10 @@ QT_BEGIN_NAMESPACE
Example:
\qml
- Rectangle { border.width: 2; border.color: "red" ... }
+ Rectangle {
+ border.width: 2
+ border.color: "red"
+ }
\endqml
*/
@@ -131,9 +134,9 @@ void QDeclarativeGradientStop::updateGradient()
\section1 Example Usage
- \beginfloatright
+ \div {float-right}
\inlineimage qml-gradient.png
- \endfloat
+ \enddiv
The following example declares a \l Rectangle item with a gradient starting
with red, blending to yellow at one third of the height of the rectangle,
@@ -217,9 +220,9 @@ void QDeclarativeGradient::doUpdate()
\section1 Example Usage
- \beginfloatright
+ \div {float-right}
\inlineimage declarative-rect.png
- \endfloat
+ \enddiv
The following example shows the effects of some of the common properties on a
Rectangle item, which in this case is used to create a square:
@@ -269,9 +272,9 @@ void QDeclarativeRectangle::doUpdate()
rectangle (as documented for QRect rendering). This can cause unintended effects if
\c border.width is 1 and the rectangle is \l{Item::clip}{clipped} by a parent item:
- \beginfloatright
+ \div {float-right}
\inlineimage rect-border-width.png
- \endfloat
+ \enddiv
\snippet doc/src/snippets/declarative/rectangle/rect-border-width.qml 0
@@ -293,9 +296,9 @@ QDeclarativePen *QDeclarativeRectangle::border()
This property allows for the construction of simple vertical gradients.
Other gradients may by formed by adding rotation to the rectangle.
- \beginfloatleft
+ \div {float-left}
\inlineimage declarative-rect_gradient.png
- \endfloat
+ \enddiv
\snippet doc/src/snippets/declarative/rectangle/rectangle-gradient.qml rectangles
\clearfloat
@@ -361,9 +364,9 @@ void QDeclarativeRectangle::setRadius(qreal radius)
The default color is white.
- \beginfloatright
+ \div {float-right}
\inlineimage rect-color.png
- \endfloat
+ \enddiv
The following example shows rectangles with colors specified
using hexadecimal and named color notation:
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
index 7aa30e5..4d0f34c 100644
--- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
@@ -84,43 +84,23 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate()
\image repeater-simple.png
- The \l model of a Repeater can be any of the supported \l {qmlmodels}{Data Models}.
+ A Repeater's \l model can be any of the supported \l {qmlmodels}{data models}.
+ Additionally, like delegates for other views, a Repeater delegate can access
+ its index within the repeater, as well as the model data relevant to the
+ delegate. See the \l delegate property documentation for details.
Items instantiated by the Repeater are inserted, in order, as
children of the Repeater's parent. The insertion starts immediately after
the repeater's position in its parent stacking list. This allows
a Repeater to be used inside a layout. For example, the following Repeater's
items are stacked between a red rectangle and a blue rectangle:
-
+
\snippet doc/src/snippets/declarative/repeaters/repeater.qml layout
\image repeater.png
- \section2 The \c index and \c modelData properties
-
- The index of a delegate is exposed as an accessible \c index property in the delegate.
- Properties of the model are also available depending upon the type of \l {qmlmodels}{Data Model}.
-
- Here is a Repeater that uses the \c index property inside the instantiated items:
-
- \table
- \row
- \o \snippet doc/src/snippets/declarative/repeaters/repeater.qml index
- \o \image repeater-index.png
- \endtable
-
- Here is another Repeater that uses the \c modelData property to reference the data for a
- particular index:
-
- \table
- \row
- \o \snippet doc/src/snippets/declarative/repeaters/repeater.qml modeldata
- \o \image repeater-modeldata.png
- \endtable
-
-
- A Repeater item owns all items it instantiates. Removing or dynamically destroying
+ \note A Repeater item owns all items it instantiates. Removing or dynamically destroying
an item created by a Repeater results in unpredictable behavior.
@@ -146,6 +126,27 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate()
\endcode
*/
+/*!
+ \qmlsignal Repeater::onItemAdded(int index, Item item)
+ \since Quick 1.1
+
+ This handler is called when an item is added to the repeater. The \a index
+ parameter holds the index at which the item has been inserted within the
+ repeater, and the \a item parameter holds the \l Item that has been added.
+*/
+
+/*!
+ \qmlsignal Repeater::onItemRemoved(int index, Item item)
+ \since Quick 1.1
+
+ This handler is called when an item is removed from the repeater. The \a index
+ parameter holds the index at which the item was removed from the repeater,
+ and the \a item parameter holds the \l Item that was removed.
+
+ Do not keep a reference to \a item if it was created by this repeater, as
+ in these cases it will be deleted shortly after the handler is called.
+*/
+
QDeclarativeRepeater::QDeclarativeRepeater(QDeclarativeItem *parent)
: QDeclarativeItem(*(new QDeclarativeRepeaterPrivate), parent)
{
@@ -160,26 +161,16 @@ QDeclarativeRepeater::~QDeclarativeRepeater()
The model providing data for the repeater.
- This property can be set to any of the following:
+ This property can be set to any of the supported \l {qmlmodels}{data models}:
\list
- \o A number that indicates the number of delegates to be created
+ \o A number that indicates the number of delegates to be created by the repeater
\o A model (e.g. a ListModel item, or a QAbstractItemModel subclass)
\o A string list
\o An object list
\endlist
- In each case, the data element and the index is exposed to each instantiated
- component. The index is always exposed as an accessible \c index property.
- In the case of an object or string list, the data element (of type string
- or object) is available as the \c modelData property. In the case of a Qt model,
- all roles are available as named properties just like in the view classes.
-
- As a special case the model can also be merely a number. In this case it will
- create that many instances of the component. They will also be assigned an index
- based on the order they are created.
-
- Models can also be created directly in QML, using a \l{ListModel} or \l{XmlListModel}.
+ The type of model affects the properties that are exposed to the \l delegate.
\sa {qmlmodels}{Data Models}
*/
@@ -207,7 +198,6 @@ void QDeclarativeRepeater::setModel(const QVariant &model)
*/
}
d->dataSource = model;
- emit modelChanged();
QObject *object = qvariant_cast<QObject*>(model);
QDeclarativeVisualModel *vim = 0;
if (object && (vim = qobject_cast<QDeclarativeVisualModel *>(object))) {
@@ -235,6 +225,7 @@ void QDeclarativeRepeater::setModel(const QVariant &model)
*/
regenerate();
}
+ emit modelChanged();
emit countChanged();
}
@@ -243,8 +234,33 @@ void QDeclarativeRepeater::setModel(const QVariant &model)
\default
The delegate provides a template defining each item instantiated by the repeater.
- The index is exposed as an accessible \c index property. Properties of the
- model are also available depending upon the type of \l {qmlmodels}{Data Model}.
+
+ Delegates are exposed to a read-only \c index property that indicates the index
+ of the delegate within the repeater. For example, the following \l Text delegate
+ displays the index of each repeated item:
+
+ \table
+ \row
+ \o \snippet doc/src/snippets/declarative/repeaters/repeater.qml index
+ \o \image repeater-index.png
+ \endtable
+
+ If the \l model is a \l{QStringList-based model}{string list} or
+ \l{QObjectList-based model}{object list}, the delegate is also exposed to
+ a read-only \c modelData property that holds the string or object data. For
+ example:
+
+ \table
+ \row
+ \o \snippet doc/src/snippets/declarative/repeaters/repeater.qml modeldata
+ \o \image repeater-modeldata.png
+ \endtable
+
+ If the \l model is a model object (such as a \l ListModel) the delegate
+ can access all model roles as named properties, in the same way that delegates
+ do for view classes like ListView.
+
+ \sa {QML Data Models}
*/
QDeclarativeComponent *QDeclarativeRepeater::delegate() const
{
@@ -288,6 +304,21 @@ int QDeclarativeRepeater::count() const
return 0;
}
+/*!
+ \qmlmethod Item Repeater::itemAt(index)
+ \since Quick 1.1
+
+ Returns the \l Item that has been created at the given \a index, or \c null
+ if no item exists at \a index.
+*/
+QDeclarativeItem *QDeclarativeRepeater::itemAt(int index) const
+{
+ Q_D(const QDeclarativeRepeater);
+ if (index >= 0 && index < d->deletables.count())
+ return d->deletables[index];
+ return 0;
+
+}
void QDeclarativeRepeater::componentComplete()
{
@@ -309,8 +340,13 @@ QVariant QDeclarativeRepeater::itemChange(GraphicsItemChange change,
void QDeclarativeRepeater::clear()
{
Q_D(QDeclarativeRepeater);
+ bool complete = isComponentComplete();
+
if (d->model) {
- foreach (QDeclarativeItem *item, d->deletables) {
+ while (d->deletables.count() > 0) {
+ QDeclarativeItem *item = d->deletables.takeLast();
+ if (complete)
+ emit itemRemoved(d->deletables.count()-1, item);
d->model->release(item);
}
}
@@ -335,6 +371,7 @@ void QDeclarativeRepeater::regenerate()
item->setParentItem(parentItem());
item->stackBefore(this);
d->deletables << item;
+ emit itemAdded(ii, item);
}
}
}
@@ -355,6 +392,7 @@ void QDeclarativeRepeater::itemsInserted(int index, int count)
else
item->stackBefore(this);
d->deletables.insert(modelIndex, item);
+ emit itemAdded(modelIndex, item);
}
}
emit countChanged();
@@ -367,6 +405,7 @@ void QDeclarativeRepeater::itemsRemoved(int index, int count)
return;
while (count--) {
QDeclarativeItem *item = d->deletables.takeAt(index);
+ emit itemRemoved(index, item);
if (item)
d->model->release(item);
else
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater_p.h b/src/declarative/graphicsitems/qdeclarativerepeater_p.h
index 73b50c2..9cb4e30 100644
--- a/src/declarative/graphicsitems/qdeclarativerepeater_p.h
+++ b/src/declarative/graphicsitems/qdeclarativerepeater_p.h
@@ -72,10 +72,16 @@ public:
int count() const;
+ Q_INVOKABLE Q_REVISION(1) QDeclarativeItem *itemAt(int index) const;
+
Q_SIGNALS:
void modelChanged();
void delegateChanged();
void countChanged();
+
+ Q_REVISION(1) void itemAdded(int index, QDeclarativeItem *item);
+ Q_REVISION(1) void itemRemoved(int index, QDeclarativeItem *item);
+
private:
void clear();
void regenerate();
diff --git a/src/declarative/graphicsitems/qdeclarativescalegrid.cpp b/src/declarative/graphicsitems/qdeclarativescalegrid.cpp
index 804e91d..3ad0da6 100644
--- a/src/declarative/graphicsitems/qdeclarativescalegrid.cpp
+++ b/src/declarative/graphicsitems/qdeclarativescalegrid.cpp
@@ -136,12 +136,12 @@ QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(QIODevice *data)
if (line.isEmpty() || line.startsWith(QLatin1Char('#')))
continue;
- QStringList list = line.split(QLatin1Char(':'));
- if (list.count() != 2)
+ int colonId = line.indexOf(QLatin1Char(':'));
+ if (colonId <= 0)
return;
-
- list[0] = list[0].trimmed();
- list[1] = list[1].trimmed();
+ QStringList list;
+ list.append(line.left(colonId).trimmed());
+ list.append(line.mid(colonId+1).trimmed());
if (list[0] == QLatin1String("border.left"))
l = list[1].toInt();
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index 2f3c8e5..559d061 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -54,6 +54,7 @@
#include <QPainter>
#include <QAbstractTextDocumentLayout>
#include <qmath.h>
+#include <limits.h>
QT_BEGIN_NAMESPACE
@@ -84,12 +85,16 @@ private:
DEFINE_BOOL_CONFIG_OPTION(enableImageCache, QML_ENABLE_TEXT_IMAGE_CACHE);
+QString QDeclarativeTextPrivate::elideChar = QString(0x2026);
+
QDeclarativeTextPrivate::QDeclarativeTextPrivate()
: color((QRgb)0), style(QDeclarativeText::Normal), hAlign(QDeclarativeText::AlignLeft),
vAlign(QDeclarativeText::AlignTop), elideMode(QDeclarativeText::ElideNone),
- format(QDeclarativeText::AutoText), wrapMode(QDeclarativeText::NoWrap), imageCacheDirty(true),
- updateOnComponentComplete(true), richText(false), singleline(false), cacheAllTextAsImage(true),
- internalWidthUpdate(false), doc(0)
+ format(QDeclarativeText::AutoText), wrapMode(QDeclarativeText::NoWrap), lineHeight(1),
+ lineHeightMode(QDeclarativeText::ProportionalHeight),
+ lineCount(1), truncated(false), maximumLineCount(INT_MAX),
+ maximumLineCountValid(false), imageCacheDirty(true), updateOnComponentComplete(true), richText(false), singleline(false),
+ cacheAllTextAsImage(true), internalWidthUpdate(false), requireImplicitWidth(false), naturalWidth(0), doc(0)
{
cacheAllTextAsImage = enableImageCache();
QGraphicsItemPrivate::acceptedMouseButtons = Qt::LeftButton;
@@ -176,6 +181,18 @@ QDeclarativeTextPrivate::~QDeclarativeTextPrivate()
{
}
+qreal QDeclarativeTextPrivate::implicitWidth() const
+{
+ if (!requireImplicitWidth) {
+ // We don't calculate implicitWidth unless it is required.
+ // We need to force a size update now to ensure implicitWidth is calculated
+ QDeclarativeTextPrivate *me = const_cast<QDeclarativeTextPrivate*>(this);
+ me->requireImplicitWidth = true;
+ me->updateSize();
+ }
+ return mImplicitWidth;
+}
+
void QDeclarativeTextPrivate::updateLayout()
{
Q_Q(QDeclarativeText);
@@ -192,9 +209,13 @@ void QDeclarativeTextPrivate::updateLayout()
QString tmp = text;
tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
singleline = !tmp.contains(QChar::LineSeparator);
- if (singleline && elideMode != QDeclarativeText::ElideNone && q->widthValid()) {
+ if (singleline && !maximumLineCountValid && elideMode != QDeclarativeText::ElideNone && q->widthValid()) {
QFontMetrics fm(font);
tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width()); // XXX still worth layout...?
+ if (tmp != text && !truncated) {
+ truncated = true;
+ emit q->truncatedChanged();
+ }
}
layout.setText(tmp);
} else {
@@ -215,12 +236,20 @@ void QDeclarativeTextPrivate::updateSize()
return;
}
+ if (!requireImplicitWidth) {
+ emit q->implicitWidthChanged();
+ // if the implicitWidth is used, then updateSize() has already been called (recursively)
+ if (requireImplicitWidth)
+ return;
+ }
+
invalidateImageCache();
QFontMetrics fm(font);
if (text.isEmpty()) {
q->setImplicitWidth(0);
q->setImplicitHeight(fm.height());
+ paintedSize = QSize(0, fm.height());
emit q->paintedSizeChanged();
q->update();
return;
@@ -241,9 +270,14 @@ void QDeclarativeTextPrivate::updateSize()
singleline = false; // richtext can't elide or be optimized for single-line case
ensureDoc();
doc->setDefaultFont(font);
- QTextOption option((Qt::Alignment)int(hAlign | vAlign));
+ QTextOption option;
+ option.setAlignment((Qt::Alignment)int(hAlign | vAlign));
option.setWrapMode(QTextOption::WrapMode(wrapMode));
doc->setDefaultTextOption(option);
+ if (requireImplicitWidth && q->widthValid()) {
+ doc->setTextWidth(-1);
+ naturalWidth = doc->idealWidth();
+ }
if (wrapMode != QDeclarativeText::NoWrap && q->widthValid())
doc->setTextWidth(q->width());
else
@@ -268,10 +302,16 @@ void QDeclarativeTextPrivate::updateSize()
//### need to comfirm cost of always setting these for richText
internalWidthUpdate = true;
- q->setImplicitWidth(size.width());
+ if (!q->widthValid())
+ q->setImplicitWidth(size.width());
+ else if (requireImplicitWidth)
+ q->setImplicitWidth(naturalWidth);
internalWidthUpdate = false;
q->setImplicitHeight(size.height());
- emit q->paintedSizeChanged();
+ if (paintedSize != size) {
+ paintedSize = size;
+ emit q->paintedSizeChanged();
+ }
q->update();
}
@@ -291,25 +331,107 @@ QSize QDeclarativeTextPrivate::setupTextLayout()
qreal height = 0;
qreal widthUsed = 0;
qreal lineWidth = 0;
+ int visibleTextLength = 0;
+ int visibleCount = 0;
//set manual width
if ((wrapMode != QDeclarativeText::NoWrap || elideMode != QDeclarativeText::ElideNone) && q->widthValid())
lineWidth = q->width();
QTextOption textOption = layout.textOption();
+ if (hAlign == QDeclarativeText::AlignJustify)
+ textOption.setAlignment(Qt::Alignment(hAlign));
textOption.setWrapMode(QTextOption::WrapMode(wrapMode));
layout.setTextOption(textOption);
- layout.beginLayout();
- forever {
- QTextLine line = layout.createLine();
- if (!line.isValid())
- break;
+ QDeclarativeText::HAlignment hAlignment = hAlign;
+ if(text.isRightToLeft()) {
+ if ((hAlign == QDeclarativeText::AlignLeft) || (hAlign == QDeclarativeText::AlignJustify)) {
+ hAlignment = QDeclarativeText::AlignRight;
+ } else if (hAlign == QDeclarativeText::AlignRight) {
+ hAlignment = QDeclarativeText::AlignLeft;
+ } else {
+ hAlignment = hAlign;
+ }
+ }
- if (lineWidth)
+ bool elideText = false;
+ bool truncate = false;
+
+ QFontMetrics fm(layout.font());
+ qreal elideWidth = fm.width(elideChar);
+ elidePos = QPointF();
+
+ if (requireImplicitWidth && q->widthValid()) {
+ // requires an extra layout
+ layout.beginLayout();
+ forever {
+ QTextLine line = layout.createLine();
+ if (!line.isValid())
+ break;
+ }
+ layout.endLayout();
+ naturalWidth = 0;
+ for (int i = 0; i < layout.lineCount(); ++i) {
+ QTextLine line = layout.lineAt(i);
+ naturalWidth = qMax(naturalWidth, line.naturalTextWidth());
+ }
+ }
+
+ if (maximumLineCountValid) {
+ layout.beginLayout();
+ if (!lineWidth)
+ lineWidth = INT_MAX;
+ int y = 0;
+ int linesLeft = maximumLineCount;
+ while (linesLeft > 0) {
+ QTextLine line = layout.createLine();
+ if (!line.isValid())
+ break;
+
+ visibleCount++;
line.setLineWidth(lineWidth);
+ visibleTextLength += line.textLength();
+
+ if (--linesLeft == 0) {
+ if (visibleTextLength < text.length()) {
+ truncate = true;
+ if (elideMode==QDeclarativeText::ElideRight && q->widthValid()) {
+ // Need to correct for alignment
+ line.setLineWidth(lineWidth-elideWidth);
+ int x = line.naturalTextWidth();
+ if (hAlignment == QDeclarativeText::AlignRight) {
+ x = q->width()-elideWidth;
+ } else if (hAlignment == QDeclarativeText::AlignHCenter) {
+ x = (q->width()+line.naturalTextWidth()-elideWidth)/2;
+ }
+ elidePos = QPointF(x, y + fm.ascent());
+ elideText = true;
+ }
+ }
+ }
+
+ y += line.height();
+ }
+ layout.endLayout();
+
+ //Update truncated
+ if (truncated != truncate) {
+ truncated = truncate;
+ emit q->truncatedChanged();
+ }
+ } else {
+ layout.beginLayout();
+ forever {
+ QTextLine line = layout.createLine();
+ if (!line.isValid())
+ break;
+ visibleCount++;
+ if (lineWidth)
+ line.setLineWidth(lineWidth);
+ }
+ layout.endLayout();
}
- layout.endLayout();
for (int i = 0; i < layout.lineCount(); ++i) {
QTextLine line = layout.lineAt(i);
@@ -317,26 +439,38 @@ QSize QDeclarativeTextPrivate::setupTextLayout()
}
qreal layoutWidth = q->widthValid() ? q->width() : widthUsed;
+ if (!q->widthValid())
+ naturalWidth = layoutWidth;
qreal x = 0;
for (int i = 0; i < layout.lineCount(); ++i) {
QTextLine line = layout.lineAt(i);
line.setPosition(QPointF(0, height));
- height += line.height();
+ height += (lineHeightMode == QDeclarativeText::FixedHeight) ? lineHeight : line.height() * lineHeight;
if (!cacheAllTextAsImage) {
- if (hAlign == QDeclarativeText::AlignLeft) {
+ if ((hAlignment == QDeclarativeText::AlignLeft) || (hAlignment == QDeclarativeText::AlignJustify)) {
x = 0;
- } else if (hAlign == QDeclarativeText::AlignRight) {
+ } else if (hAlignment == QDeclarativeText::AlignRight) {
x = layoutWidth - line.naturalTextWidth();
- } else if (hAlign == QDeclarativeText::AlignHCenter) {
+ if (elideText && i == layout.lineCount()-1)
+ x -= elideWidth; // Correct for when eliding multilines
+ } else if (hAlignment == QDeclarativeText::AlignHCenter) {
x = (layoutWidth - line.naturalTextWidth()) / 2;
+ if (elideText && i == layout.lineCount()-1)
+ x -= elideWidth/2; // Correct for when eliding multilines
}
line.setPosition(QPointF(x, line.y()));
}
}
- return layout.boundingRect().toAlignedRect().size();
+ //Update the number of visible lines
+ if (lineCount != visibleCount) {
+ lineCount = visibleCount;
+ emit q->lineCountChanged();
+ }
+
+ return QSize(qCeil(widthUsed), qCeil(height));
}
/*!
@@ -351,7 +485,7 @@ QPixmap QDeclarativeTextPrivate::textLayoutImage(bool drawStyle)
qreal x = 0;
for (int i = 0; i < layout.lineCount(); ++i) {
QTextLine line = layout.lineAt(i);
- if (hAlign == QDeclarativeText::AlignLeft) {
+ if ((hAlign == QDeclarativeText::AlignLeft) || (hAlign == QDeclarativeText::AlignJustify)) {
x = 0;
} else if (hAlign == QDeclarativeText::AlignRight) {
x = size.width() - line.naturalTextWidth();
@@ -389,7 +523,9 @@ void QDeclarativeTextPrivate::drawTextLayout(QPainter *painter, const QPointF &p
else
painter->setPen(color);
painter->setFont(font);
- layout.draw(painter, pos);
+ layout.draw(painter, pos);
+ if (!elidePos.isNull())
+ painter->drawText(elidePos, elideChar);
}
/*!
@@ -558,11 +694,24 @@ QPixmap QDeclarativeTextPrivate::drawOutline(const QPixmap &source, const QPixma
\brief The Text item allows you to add formatted text to a scene.
\inherits Item
- A Text item can display both plain and rich text. For example:
+ Text items can display both plain and rich text. For example, red text with
+ a specific font and size can be defined like this:
\qml
- Text { text: "Hello World!"; font.family: "Helvetica"; font.pointSize: 24; color: "red" }
- Text { text: "<b>Hello</b> <i>World!</i>" }
+ Text {
+ text: "Hello World!"
+ font.family: "Helvetica"
+ font.pointSize: 24
+ color: "red"
+ }
+ \endqml
+
+ Rich text is defined using HTML-style markup:
+
+ \qml
+ Text {
+ text: "<b>Hello</b> <i>World!</i>"
+ }
\endqml
\image declarative-text.png
@@ -582,7 +731,7 @@ QPixmap QDeclarativeTextPrivate::drawOutline(const QPixmap &source, const QPixma
\sa {declarative/text/fonts}{Fonts example}
*/
QDeclarativeText::QDeclarativeText(QDeclarativeItem *parent)
- : QDeclarativeItem(*(new QDeclarativeTextPrivate), parent)
+ : QDeclarativeImplicitSizeItem(*(new QDeclarativeTextPrivate), parent)
{
}
@@ -736,19 +885,28 @@ QDeclarativeText::~QDeclarativeText()
QFont QDeclarativeText::font() const
{
Q_D(const QDeclarativeText);
- return d->font;
+ return d->sourceFont;
}
void QDeclarativeText::setFont(const QFont &font)
{
Q_D(QDeclarativeText);
- if (d->font == font)
+ if (d->sourceFont == font)
return;
+ d->sourceFont = font;
+ QFont oldFont = d->font;
d->font = font;
- d->updateLayout();
+ if (d->font.pointSizeF() != -1) {
+ // 0.5pt resolution
+ qreal size = qRound(d->font.pointSizeF()*2.0);
+ d->font.setPointSizeF(size/2.0);
+ }
+
+ if (oldFont != d->font)
+ d->updateLayout();
- emit fontChanged(d->font);
+ emit fontChanged(d->sourceFont);
}
/*!
@@ -789,12 +947,20 @@ void QDeclarativeText::setText(const QString &n)
The text color.
+ An example of green text defined using hexadecimal notation:
\qml
- //green text using hexadecimal notation
- Text { color: "#00FF00"; ... }
+ Text {
+ color: "#00FF00"
+ text: "green text"
+ }
+ \endqml
- //steelblue text using SVG color name
- Text { color: "steelblue"; ... }
+ An example of steel blue text defined using an SVG color name:
+ \qml
+ Text {
+ color: "steelblue"
+ text: "blue text"
+ }
\endqml
*/
QColor QDeclarativeText::color() const
@@ -898,8 +1064,8 @@ void QDeclarativeText::setStyleColor(const QColor &color)
Sets the horizontal and vertical alignment of the text within the Text items
width and height. By default, the text is top-left aligned.
- The valid values for \c horizontalAlignment are \c Text.AlignLeft, \c Text.AlignRight and
- \c Text.AlignHCenter. The valid values for \c verticalAlignment are \c Text.AlignTop, \c Text.AlignBottom
+ The valid values for \c horizontalAlignment are \c Text.AlignLeft, \c Text.AlignRight, \c Text.AlignHCenter and
+ \c Text.AlignJustify. The valid values for \c verticalAlignment are \c Text.AlignTop, \c Text.AlignBottom
and \c Text.AlignVCenter.
Note that for a single line of text, the size of the text is the area of the text. In this common case,
@@ -977,6 +1143,76 @@ void QDeclarativeText::setWrapMode(WrapMode mode)
emit wrapModeChanged();
}
+/*!
+ \qmlproperty int Text::lineCount
+
+ Returns the number of lines visible in the text item.
+
+ This property is not supported for rich text.
+
+ \sa maximumLineCount
+*/
+int QDeclarativeText::lineCount() const
+{
+ Q_D(const QDeclarativeText);
+ return d->lineCount;
+}
+
+/*!
+ \qmlproperty bool Text::truncated
+
+ Returns true if the text has been truncated due to \l maximumLineCount
+ or \l elide.
+
+ This property is not supported for rich text.
+
+ \sa maximumLineCount, elide
+*/
+bool QDeclarativeText::truncated() const
+{
+ Q_D(const QDeclarativeText);
+ return d->truncated;
+}
+
+/*!
+ \qmlproperty int Text::maximumLineCount
+
+ Set this property to limit the number of lines that the text item will show.
+ If elide is set to Text.ElideRight, the text will be elided appropriately.
+ By default, this is the value of the largest possible integer.
+
+ This property is not supported for rich text.
+
+ \sa lineCount, elide
+*/
+int QDeclarativeText::maximumLineCount() const
+{
+ Q_D(const QDeclarativeText);
+ return d->maximumLineCount;
+}
+
+void QDeclarativeText::setMaximumLineCount(int lines)
+{
+ Q_D(QDeclarativeText);
+
+ d->maximumLineCountValid = lines==INT_MAX ? false : true;
+ if (d->maximumLineCount != lines) {
+ d->maximumLineCount = lines;
+ d->updateLayout();
+ emit maximumLineCountChanged();
+ }
+}
+
+void QDeclarativeText::resetMaximumLineCount()
+{
+ Q_D(QDeclarativeText);
+ setMaximumLineCount(INT_MAX);
+ d->elidePos = QPointF();
+ if (d->truncated != false) {
+ d->truncated = false;
+ emit truncatedChanged();
+ }
+}
/*!
\qmlproperty enumeration Text::textFormat
@@ -1064,7 +1300,7 @@ void QDeclarativeText::setTextFormat(TextFormat format)
Set this property to elide parts of the text fit to the Text item's width.
The text will only elide if an explicit width has been set.
- This property cannot be used with multi-line text or with rich text.
+ This property cannot be used with rich text.
Eliding can be:
\list
@@ -1074,6 +1310,9 @@ void QDeclarativeText::setTextFormat(TextFormat format)
\o Text.ElideRight
\endlist
+ If this property is set to Text.ElideRight, it can be used with multiline
+ text. The text will only elide if maximumLineCount has been set.
+
If the text is a multi-length string, and the mode is not \c Text.ElideNone,
the first string that fits will be used, otherwise the last will be elided.
@@ -1117,6 +1356,7 @@ QRectF QDeclarativeText::boundingRect() const
switch (d->hAlign) {
case AlignLeft:
+ case AlignJustify:
x = 0;
break;
case AlignRight:
@@ -1150,7 +1390,7 @@ void QDeclarativeText::geometryChanged(const QRectF &newGeometry, const QRectF &
&& (d->wrapMode != QDeclarativeText::NoWrap
|| d->elideMode != QDeclarativeText::ElideNone
|| d->hAlign != QDeclarativeText::AlignLeft)) {
- if (d->singleline && d->elideMode != QDeclarativeText::ElideNone && widthValid()) {
+ if ((d->singleline || d->maximumLineCountValid) && d->elideMode != QDeclarativeText::ElideNone && widthValid()) {
// We need to re-elide
d->updateLayout();
} else {
@@ -1170,7 +1410,8 @@ void QDeclarativeText::geometryChanged(const QRectF &newGeometry, const QRectF &
*/
qreal QDeclarativeText::paintedWidth() const
{
- return implicitWidth();
+ Q_D(const QDeclarativeText);
+ return d->paintedSize.width();
}
/*!
@@ -1181,7 +1422,65 @@ qreal QDeclarativeText::paintedWidth() const
*/
qreal QDeclarativeText::paintedHeight() const
{
- return implicitHeight();
+ Q_D(const QDeclarativeText);
+ return d->paintedSize.height();
+}
+
+/*!
+ \qmlproperty real Text::lineHeight
+
+ Sets the line height for the text.
+ The value can be in pixels or a multiplier depending on lineHeightMode.
+
+ The default value is a multiplier of 1.0.
+ The line height must be a positive value.
+*/
+qreal QDeclarativeText::lineHeight() const
+{
+ Q_D(const QDeclarativeText);
+ return d->lineHeight;
+}
+
+void QDeclarativeText::setLineHeight(qreal lineHeight)
+{
+ Q_D(QDeclarativeText);
+
+ if ((d->lineHeight == lineHeight) || (lineHeight < 0.0))
+ return;
+
+ d->lineHeight = lineHeight;
+ d->updateLayout();
+ emit lineHeightChanged(lineHeight);
+}
+
+/*!
+ \qmlproperty enumeration Text::lineHeightMode
+
+ This property determines how the line height is specified.
+ The possible values are:
+
+ \list
+ \o Text.ProportionalHeight (default) - this sets the spacing proportional to the
+ line (as a multiplier). For example, set to 2 for double spacing.
+ \o Text.FixedHeight - this sets the line height to a fixed line height (in pixels).
+ \endlist
+*/
+QDeclarativeText::LineHeightMode QDeclarativeText::lineHeightMode() const
+{
+ Q_D(const QDeclarativeText);
+ return d->lineHeightMode;
+}
+
+void QDeclarativeText::setLineHeightMode(LineHeightMode mode)
+{
+ Q_D(QDeclarativeText);
+ if (mode == d->lineHeightMode)
+ return;
+
+ d->lineHeightMode = mode;
+ d->updateLayout();
+
+ emit lineHeightModeChanged(mode);
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/declarative/graphicsitems/qdeclarativetext_p.h
index abc45f9..b8835d1 100644
--- a/src/declarative/graphicsitems/qdeclarativetext_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetext_p.h
@@ -43,7 +43,7 @@
#define QDECLARATIVETEXT_H
#include <QtGui/qtextoption.h>
-#include "qdeclarativeitem.h"
+#include "qdeclarativeimplicitsizeitem_p.h"
#include <private/qdeclarativeglobal_p.h>
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeTextPrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeText : public QDeclarativeItem
+class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeText : public QDeclarativeImplicitSizeItem
{
Q_OBJECT
Q_ENUMS(HAlignment)
@@ -62,6 +62,7 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeText : public QDeclarativeItem
Q_ENUMS(TextFormat)
Q_ENUMS(TextElideMode)
Q_ENUMS(WrapMode)
+ Q_ENUMS(LineHeightMode)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
@@ -71,10 +72,16 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeText : public QDeclarativeItem
Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign NOTIFY horizontalAlignmentChanged)
Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
+ Q_PROPERTY(int lineCount READ lineCount NOTIFY lineCountChanged REVISION 1)
+ Q_PROPERTY(bool truncated READ truncated NOTIFY truncatedChanged REVISION 1)
+ Q_PROPERTY(int maximumLineCount READ maximumLineCount WRITE setMaximumLineCount NOTIFY maximumLineCountChanged RESET resetMaximumLineCount REVISION 1)
+
Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode?
Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
+ Q_PROPERTY(qreal lineHeight READ lineHeight WRITE setLineHeight NOTIFY lineHeightChanged REVISION 1)
+ Q_PROPERTY(LineHeightMode lineHeightMode READ lineHeightMode WRITE setLineHeightMode NOTIFY lineHeightModeChanged REVISION 1)
public:
QDeclarativeText(QDeclarativeItem *parent=0);
@@ -82,7 +89,8 @@ public:
enum HAlignment { AlignLeft = Qt::AlignLeft,
AlignRight = Qt::AlignRight,
- AlignHCenter = Qt::AlignHCenter };
+ AlignHCenter = Qt::AlignHCenter,
+ AlignJustify = Qt::AlignJustify }; // ### VERSIONING: Only in QtQuick 1.1
enum VAlignment { AlignTop = Qt::AlignTop,
AlignBottom = Qt::AlignBottom,
AlignVCenter = Qt::AlignVCenter };
@@ -106,6 +114,8 @@ public:
Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
};
+ enum LineHeightMode { ProportionalHeight, FixedHeight };
+
QString text() const;
void setText(const QString &);
@@ -130,12 +140,25 @@ public:
WrapMode wrapMode() const;
void setWrapMode(WrapMode w);
+ int lineCount() const;
+ bool truncated() const;
+
+ int maximumLineCount() const;
+ void setMaximumLineCount(int lines);
+ void resetMaximumLineCount();
+
TextFormat textFormat() const;
void setTextFormat(TextFormat format);
TextElideMode elideMode() const;
void setElideMode(TextElideMode);
+ qreal lineHeight() const;
+ void setLineHeight(qreal lineHeight);
+
+ LineHeightMode lineHeightMode() const;
+ void setLineHeightMode(LineHeightMode);
+
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
virtual void componentComplete();
@@ -157,9 +180,14 @@ Q_SIGNALS:
void horizontalAlignmentChanged(HAlignment alignment);
void verticalAlignmentChanged(VAlignment alignment);
void wrapModeChanged();
+ Q_REVISION(1) void lineCountChanged();
+ Q_REVISION(1) void truncatedChanged();
+ Q_REVISION(1) void maximumLineCountChanged();
void textFormatChanged(TextFormat textFormat);
void elideModeChanged(TextElideMode mode);
void paintedSizeChanged();
+ Q_REVISION(1) void lineHeightChanged(qreal lineHeight);
+ Q_REVISION(1) void lineHeightModeChanged(LineHeightMode mode);
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p_p.h b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
index 67f2289..36ae123 100644
--- a/src/declarative/graphicsitems/qdeclarativetext_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
@@ -54,7 +54,7 @@
//
#include "qdeclarativeitem.h"
-#include "private/qdeclarativeitem_p.h"
+#include "private/qdeclarativeimplicitsizeitem_p_p.h"
#include "private/qdeclarativetextlayout_p.h"
#include <qdeclarative.h>
@@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE
class QTextLayout;
class QTextDocumentWithImageResources;
-class QDeclarativeTextPrivate : public QDeclarativeItemPrivate
+class Q_AUTOTEST_EXPORT QDeclarativeTextPrivate : public QDeclarativeImplicitSizeItemPrivate
{
Q_DECLARE_PUBLIC(QDeclarativeText)
public:
@@ -79,6 +79,7 @@ public:
QString text;
QFont font;
+ QFont sourceFont;
QColor color;
QDeclarativeText::TextStyle style;
QColor styleColor;
@@ -88,6 +89,15 @@ public:
QDeclarativeText::TextElideMode elideMode;
QDeclarativeText::TextFormat format;
QDeclarativeText::WrapMode wrapMode;
+ qreal lineHeight;
+ QDeclarativeText::LineHeightMode lineHeightMode;
+ int lineCount;
+ bool truncated;
+ int maximumLineCount;
+ int maximumLineCountValid;
+ QPointF elidePos;
+
+ static QString elideChar;
void invalidateImageCache();
void checkImageCache();
@@ -99,9 +109,12 @@ public:
bool singleline:1;
bool cacheAllTextAsImage:1;
bool internalWidthUpdate:1;
+ bool requireImplicitWidth:1;
QSize layedOutTextSize;
-
+ QSize paintedSize;
+ qreal naturalWidth;
+ virtual qreal implicitWidth() const;
void ensureDoc();
QPixmap textDocumentImage(bool drawStyle);
QTextDocumentWithImageResources *doc;
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 675f8d9..7f383a6 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -51,6 +51,7 @@
#include <QTextLayout>
#include <QTextLine>
#include <QTextDocument>
+#include <QTextObject>
#include <QGraphicsSceneMouseEvent>
#include <QDebug>
#include <QPainter>
@@ -103,8 +104,16 @@ TextEdit {
\sa Text, TextInput, {declarative/text/textselection}{Text Selection example}
*/
+/*!
+ \qmlsignal TextEdit::onLinkActivated(string link)
+ \since Quick 1.1
+
+ This handler is called when the user clicks on a link embedded in the text.
+ The link must be in rich text or HTML format and the
+ \a link string provides access to the particular link.
+*/
QDeclarativeTextEdit::QDeclarativeTextEdit(QDeclarativeItem *parent)
-: QDeclarativePaintedItem(*(new QDeclarativeTextEditPrivate), parent)
+: QDeclarativeImplicitSizePaintedItem(*(new QDeclarativeTextEditPrivate), parent)
{
Q_D(QDeclarativeTextEdit);
d->init();
@@ -326,22 +335,35 @@ void QDeclarativeTextEdit::setTextFormat(TextFormat format)
QFont QDeclarativeTextEdit::font() const
{
Q_D(const QDeclarativeTextEdit);
- return d->font;
+ return d->sourceFont;
}
void QDeclarativeTextEdit::setFont(const QFont &font)
{
Q_D(QDeclarativeTextEdit);
+ if (d->sourceFont == font)
+ return;
+
+ d->sourceFont = font;
+ QFont oldFont = d->font;
d->font = font;
+ if (d->font.pointSizeF() != -1) {
+ // 0.5pt resolution
+ qreal size = qRound(d->font.pointSizeF()*2.0);
+ d->font.setPointSizeF(size/2.0);
+ }
- clearCache();
- d->document->setDefaultFont(d->font);
- if(d->cursor){
- d->cursor->setHeight(QFontMetrics(d->font).height());
- moveCursorDelegate();
+ if (oldFont != d->font) {
+ clearCache();
+ d->document->setDefaultFont(d->font);
+ if(d->cursor){
+ d->cursor->setHeight(QFontMetrics(d->font).height());
+ moveCursorDelegate();
+ }
+ updateSize();
+ update();
}
- updateSize();
- update();
+ emit fontChanged(d->sourceFont);
}
/*!
@@ -350,11 +372,13 @@ void QDeclarativeTextEdit::setFont(const QFont &font)
The text color.
\qml
-// green text using hexadecimal notation
-TextEdit { color: "#00FF00"; ... }
+ // green text using hexadecimal notation
+ TextEdit { color: "#00FF00" }
+ \endqml
-// steelblue text using SVG color name
-TextEdit { color: "steelblue"; ... }
+ \qml
+ // steelblue text using SVG color name
+ TextEdit { color: "steelblue" }
\endqml
*/
QColor QDeclarativeTextEdit::color() const
@@ -442,6 +466,7 @@ void QDeclarativeTextEdit::setSelectedTextColor(const QColor &color)
\o TextEdit.AlignLeft (default)
\o TextEdit.AlignRight
\o TextEdit.AlignHCenter
+ \o TextEdit.AlignJustify
\endlist
Valid values for \c verticalAlignment are:
@@ -518,6 +543,17 @@ void QDeclarativeTextEdit::setWrapMode(WrapMode mode)
}
/*!
+ \qmlproperty int TextEdit::lineCount
+
+ Returns the total number of lines in the textEdit item.
+*/
+int QDeclarativeTextEdit::lineCount() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->lineCount;
+}
+
+/*!
\qmlproperty real TextEdit::paintedWidth
Returns the width of the text, including the width past the width
@@ -525,7 +561,8 @@ void QDeclarativeTextEdit::setWrapMode(WrapMode mode)
*/
qreal QDeclarativeTextEdit::paintedWidth() const
{
- return implicitWidth();
+ Q_D(const QDeclarativeTextEdit);
+ return d->paintedSize.width();
}
/*!
@@ -536,7 +573,8 @@ qreal QDeclarativeTextEdit::paintedWidth() const
*/
qreal QDeclarativeTextEdit::paintedHeight() const
{
- return implicitHeight();
+ Q_D(const QDeclarativeTextEdit);
+ return d->paintedSize.height();
}
/*!
@@ -570,37 +608,101 @@ int QDeclarativeTextEdit::positionAt(int x, int y) const
return r;
}
+void QDeclarativeTextEdit::moveCursorSelection(int pos)
+{
+ //Note that this is the same as setCursorPosition but with the KeepAnchor flag set
+ Q_D(QDeclarativeTextEdit);
+ QTextCursor cursor = d->control->textCursor();
+ if (cursor.position() == pos)
+ return;
+ cursor.setPosition(pos, QTextCursor::KeepAnchor);
+ d->control->setTextCursor(cursor);
+}
+
/*!
- \qmlmethod int TextEdit::moveCursorSelection(int pos)
+ \qmlmethod void TextEdit::moveCursorSelection(int position, SelectionMode mode = TextEdit.SelectCharacters)
+ \since Quick 1.1
- Moves the cursor to \a position and updates the selection accordingly.
- (To only move the cursor, set the \l cursorPosition property.)
+ Moves the cursor to \a position and updates the selection according to the optional \a mode
+ parameter. (To only move the cursor, set the \l cursorPosition property.)
When this method is called it additionally sets either the
selectionStart or the selectionEnd (whichever was at the previous cursor position)
to the specified position. This allows you to easily extend and contract the selected
text range.
+ The selection mode specifies whether the selection is updated on a per character or a per word
+ basis. If not specified the selection mode will default to TextEdit.SelectCharacters.
+
+ \list
+ \o TextEdit.SelectCharacters - Sets either the selectionStart or selectionEnd (whichever was at
+ the previous cursor position) to the specified position.
+ \o TextEdit.SelectWords - Sets the selectionStart and selectionEnd to include all
+ words between the specified postion and the previous cursor position. Words partially in the
+ range are included.
+ \endlist
+
For example, take this sequence of calls:
\code
cursorPosition = 5
- moveCursorSelection(9)
- moveCursorSelection(7)
+ moveCursorSelection(9, TextEdit.SelectCharacters)
+ moveCursorSelection(7, TextEdit.SelectCharacters)
\endcode
This moves the cursor to position 5, extend the selection end from 5 to 9
and then retract the selection end from 9 to 7, leaving the text from position 5 to 7
selected (the 6th and 7th characters).
+
+ The same sequence with TextEdit.SelectWords will extend the selection start to a word boundary
+ before or on position 5 and extend the selection end to a word boundary on or past position 9.
*/
-void QDeclarativeTextEdit::moveCursorSelection(int pos)
+void QDeclarativeTextEdit::moveCursorSelection(int pos, SelectionMode mode)
{
- //Note that this is the same as setCursorPosition but with the KeepAnchor flag set
Q_D(QDeclarativeTextEdit);
QTextCursor cursor = d->control->textCursor();
if (cursor.position() == pos)
return;
- cursor.setPosition(pos, QTextCursor::KeepAnchor);
+ if (mode == SelectCharacters) {
+ cursor.setPosition(pos, QTextCursor::KeepAnchor);
+ } else if (cursor.anchor() < pos || (cursor.anchor() == pos && cursor.position() < pos)) {
+ if (cursor.anchor() > cursor.position()) {
+ cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor);
+ cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
+ if (cursor.position() == cursor.anchor())
+ cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::MoveAnchor);
+ else
+ cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor);
+ } else {
+ cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor);
+ cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
+ }
+
+ cursor.setPosition(pos, QTextCursor::KeepAnchor);
+ cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
+ if (cursor.position() != pos)
+ cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
+ } else if (cursor.anchor() > pos || (cursor.anchor() == pos && cursor.position() > pos)) {
+ if (cursor.anchor() < cursor.position()) {
+ cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor);
+ cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::MoveAnchor);
+ } else {
+ cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor);
+ cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor);
+ cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
+ if (cursor.position() != cursor.anchor()) {
+ cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor);
+ cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::MoveAnchor);
+ }
+ }
+
+ cursor.setPosition(pos, QTextCursor::KeepAnchor);
+ cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
+ if (cursor.position() != pos) {
+ cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor);
+ cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
+ }
+ }
d->control->setTextCursor(cursor);
}
@@ -646,7 +748,7 @@ void QDeclarativeTextEdit::setCursorPosition(int pos)
if (pos < 0 || pos > d->text.length())
return;
QTextCursor cursor = d->control->textCursor();
- if (cursor.position() == pos)
+ if (cursor.position() == pos && cursor.anchor() == pos)
return;
cursor.setPosition(pos);
d->control->setTextCursor(cursor);
@@ -874,11 +976,45 @@ void QDeclarativeTextEdit::setSelectByMouse(bool on)
Q_D(QDeclarativeTextEdit);
if (d->selectByMouse != on) {
d->selectByMouse = on;
+ setKeepMouseGrab(on);
+ if (on)
+ setTextInteractionFlags(d->control->textInteractionFlags() | Qt::TextSelectableByMouse);
+ else
+ setTextInteractionFlags(d->control->textInteractionFlags() & ~Qt::TextSelectableByMouse);
emit selectByMouseChanged(on);
}
}
+/*!
+ \qmlproperty enum TextEdit::mouseSelectionMode
+ \since Quick 1.1
+
+ Specifies how text should be selected using a mouse.
+
+ \list
+ \o TextEdit.SelectCharacters - The selection is updated with individual characters. (Default)
+ \o TextEdit.SelectWords - The selection is updated with whole words.
+ \endlist
+
+ This property only applies when \l selectByMouse is true.
+*/
+
+QDeclarativeTextEdit::SelectionMode QDeclarativeTextEdit::mouseSelectionMode() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->mouseSelectionMode;
+}
+
+void QDeclarativeTextEdit::setMouseSelectionMode(SelectionMode mode)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (d->mouseSelectionMode != mode) {
+ d->mouseSelectionMode = mode;
+ d->control->setWordSelectionEnabled(mode == SelectWords);
+ emit mouseSelectionModeChanged(mode);
+ }
+}
/*!
\qmlproperty bool TextEdit::readOnly
@@ -894,13 +1030,13 @@ void QDeclarativeTextEdit::setReadOnly(bool r)
if (r == isReadOnly())
return;
+ setFlag(QGraphicsItem::ItemAcceptsInputMethod, !r);
- Qt::TextInteractionFlags flags = Qt::NoTextInteraction;
- if (r) {
- flags = Qt::TextSelectableByMouse;
- } else {
- flags = Qt::TextEditorInteraction;
- }
+ Qt::TextInteractionFlags flags = Qt::LinksAccessibleByMouse;
+ if (d->selectByMouse)
+ flags = flags | Qt::TextSelectableByMouse;
+ if (!r)
+ flags = flags | Qt::TextSelectableByKeyboard | Qt::TextEditable;
d->control->setTextInteractionFlags(flags);
if (!r)
d->control->moveCursor(QTextCursor::End);
@@ -992,11 +1128,24 @@ void QDeclarativeTextEdit::keyReleaseEvent(QKeyEvent *event)
void QDeclarativeTextEditPrivate::focusChanged(bool hasFocus)
{
Q_Q(QDeclarativeTextEdit);
- q->setCursorVisible(hasFocus);
+ q->setCursorVisible(hasFocus && scene && scene->hasFocus());
QDeclarativeItemPrivate::focusChanged(hasFocus);
}
/*!
+ \qmlmethod void TextEdit::deselect()
+
+ Removes active text selection.
+*/
+void QDeclarativeTextEdit::deselect()
+{
+ Q_D(QDeclarativeTextEdit);
+ QTextCursor c = d->control->textCursor();
+ c.clearSelection();
+ d->control->setTextCursor(c);
+}
+
+/*!
\qmlmethod void TextEdit::selectAll()
Causes all text to be selected.
@@ -1105,8 +1254,8 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
}
}
- if (event->type() != QEvent::GraphicsSceneMouseDoubleClick || d->selectByMouse)
- d->control->processEvent(event, QPointF(0, -d->yoff));
+
+ d->control->processEvent(event, QPointF(0, -d->yoff));
if (!event->isAccepted())
QDeclarativePaintedItem::mousePressEvent(event);
}
@@ -1141,13 +1290,11 @@ Handles the given mouse \a event.
void QDeclarativeTextEdit::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextEdit);
- if (d->selectByMouse) {
- d->control->processEvent(event, QPointF(0, -d->yoff));
- if (!event->isAccepted())
- QDeclarativePaintedItem::mouseDoubleClickEvent(event);
- } else {
+
+ d->control->processEvent(event, QPointF(0, -d->yoff));
+ if (!event->isAccepted())
QDeclarativePaintedItem::mouseDoubleClickEvent(event);
- }
+
}
/*!
@@ -1157,14 +1304,9 @@ Handles the given mouse \a event.
void QDeclarativeTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextEdit);
- if (d->selectByMouse) {
- d->control->processEvent(event, QPointF(0, -d->yoff));
- if (!event->isAccepted())
- QDeclarativePaintedItem::mouseMoveEvent(event);
- event->setAccepted(true);
- } else {
+ d->control->processEvent(event, QPointF(0, -d->yoff));
+ if (!event->isAccepted())
QDeclarativePaintedItem::mouseMoveEvent(event);
- }
}
/*!
@@ -1237,6 +1379,21 @@ void QDeclarativeTextEdit::updateImgCache(const QRectF &rf)
filtering at the beginning of the animation and reenable it at the conclusion.
*/
+/*!
+ \qmlproperty bool TextEdit::canPaste
+
+ Returns true if the TextEdit is writable and the content of the clipboard is
+ suitable for pasting into the TextEdit.
+
+ \since QtQuick 1.1
+*/
+
+bool QDeclarativeTextEdit::canPaste() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->canPaste;
+}
+
void QDeclarativeTextEditPrivate::init()
{
Q_Q(QDeclarativeTextEdit);
@@ -1248,6 +1405,8 @@ void QDeclarativeTextEditPrivate::init()
control = new QTextControl(q);
control->setIgnoreUnusedNavigationEvents(true);
+ control->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByKeyboard | Qt::TextEditable);
+ control->setDragEnabled(false);
// QTextControl follows the default text color
// defined by the platform, declarative text
@@ -1266,6 +1425,11 @@ void QDeclarativeTextEditPrivate::init()
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(updateSelectionMarkers()));
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorRectangleChanged()));
+ QObject::connect(control, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString)));
+#ifndef QT_NO_CLIPBOARD
+ QObject::connect(q, SIGNAL(readOnlyChanged(bool)), q, SLOT(q_canPasteChanged()));
+ QObject::connect(QApplication::clipboard(), SIGNAL(dataChanged()), q, SLOT(q_canPasteChanged()));
+#endif
document = control->document();
document->setDefaultFont(font);
@@ -1280,6 +1444,7 @@ void QDeclarativeTextEdit::q_textChanged()
Q_D(QDeclarativeTextEdit);
d->text = text();
updateSize();
+ updateTotalLines();
updateMicroFocus();
emit textChanged(d->text);
}
@@ -1341,6 +1506,17 @@ QRectF QDeclarativeTextEdit::boundingRect() const
return r.translated(0,d->yoff);
}
+qreal QDeclarativeTextEditPrivate::implicitWidth() const
+{
+ Q_Q(const QDeclarativeTextEdit);
+ if (!requireImplicitWidth) {
+ // We don't calculate implicitWidth unless it is required.
+ // We need to force a size update now to ensure implicitWidth is calculated
+ const_cast<QDeclarativeTextEditPrivate*>(this)->requireImplicitWidth = true;
+ const_cast<QDeclarativeTextEdit*>(q)->updateSize();
+ }
+ return mImplicitWidth;
+}
//### we should perhaps be a bit smarter here -- depending on what has changed, we shouldn't
// need to do all the calculations each time
@@ -1348,12 +1524,27 @@ void QDeclarativeTextEdit::updateSize()
{
Q_D(QDeclarativeTextEdit);
if (isComponentComplete()) {
- QFontMetrics fm = QFontMetrics(d->font);
- int dy = height();
+ qreal naturalWidth = d->mImplicitWidth;
// ### assumes that if the width is set, the text will fill to edges
// ### (unless wrap is false, then clipping will occur)
- if (widthValid() && d->document->textWidth() != width())
- d->document->setTextWidth(width());
+ if (widthValid()) {
+ if (!d->requireImplicitWidth) {
+ emit implicitWidthChanged();
+ // if the implicitWidth is used, then updateSize() has already been called (recursively)
+ if (d->requireImplicitWidth)
+ return;
+ }
+ if (d->requireImplicitWidth) {
+ d->document->setTextWidth(-1);
+ naturalWidth = d->document->idealWidth();
+ }
+ if (d->document->textWidth() != width())
+ d->document->setTextWidth(width());
+ } else {
+ d->document->setTextWidth(-1);
+ }
+ QFontMetrics fm = QFontMetrics(d->font);
+ int dy = height();
dy -= (int)d->document->size().height();
int nyoff;
@@ -1378,12 +1569,15 @@ void QDeclarativeTextEdit::updateSize()
if (!widthValid() && d->document->textWidth() != newWidth)
d->document->setTextWidth(newWidth); // ### Text does not align if width is not set (QTextDoc bug)
// ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed.
- setImplicitWidth(newWidth);
+ if (!widthValid())
+ setImplicitWidth(newWidth);
+ else if (d->requireImplicitWidth)
+ setImplicitWidth(naturalWidth);
qreal newHeight = d->document->isEmpty() ? fm.height() : (int)d->document->size().height();
setImplicitHeight(newHeight);
- setContentsSize(QSize(newWidth, newHeight));
-
+ d->paintedSize = QSize(newWidth, newHeight);
+ setContentsSize(d->paintedSize);
emit paintedSizeChanged();
} else {
d->dirty = true;
@@ -1391,6 +1585,26 @@ void QDeclarativeTextEdit::updateSize()
emit update();
}
+void QDeclarativeTextEdit::updateTotalLines()
+{
+ Q_D(QDeclarativeTextEdit);
+
+ int subLines = 0;
+
+ for (QTextBlock it = d->document->begin(); it != d->document->end(); it = it.next()) {
+ QTextLayout *layout = it.layout();
+ if (!layout)
+ continue;
+ subLines += layout->lineCount()-1;
+ }
+
+ int newTotalLines = d->document->lineCount() + subLines;
+ if (d->lineCount != newTotalLines) {
+ d->lineCount = newTotalLines;
+ emit lineCountChanged();
+ }
+}
+
void QDeclarativeTextEditPrivate::updateDefaultTextOption()
{
QTextOption opt = document->defaultTextOption();
@@ -1519,4 +1733,13 @@ void QDeclarativeTextEdit::focusInEvent(QFocusEvent *event)
QDeclarativePaintedItem::focusInEvent(event);
}
+void QDeclarativeTextEdit::q_canPasteChanged()
+{
+ Q_D(QDeclarativeTextEdit);
+ bool old = d->canPaste;
+ d->canPaste = d->control->canPaste();
+ if(old!=d->canPaste)
+ emit canPasteChanged();
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
index cff55f0..7785a7a 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
@@ -43,7 +43,7 @@
#define QDECLARATIVETEXTEDIT_H
#include "private/qdeclarativetext_p.h"
-#include "private/qdeclarativepainteditem_p.h"
+#include "private/qdeclarativeimplicitsizeitem_p.h"
#include <QtGui/qtextdocument.h>
#include <QtGui/qtextoption.h>
@@ -58,13 +58,14 @@ QT_MODULE(Declarative)
class QDeclarativeTextEditPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem
+class Q_AUTOTEST_EXPORT QDeclarativeTextEdit : public QDeclarativeImplicitSizePaintedItem
{
Q_OBJECT
Q_ENUMS(VAlignment)
Q_ENUMS(HAlignment)
Q_ENUMS(TextFormat)
Q_ENUMS(WrapMode)
+ Q_ENUMS(SelectionMode)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
@@ -74,6 +75,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem
Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign NOTIFY horizontalAlignmentChanged)
Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
+ Q_PROPERTY(int lineCount READ lineCount NOTIFY lineCountChanged REVISION 1)
Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
@@ -90,6 +92,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem
Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged)
Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
+ Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged REVISION 1)
+ Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged REVISION 1)
public:
QDeclarativeTextEdit(QDeclarativeItem *parent=0);
@@ -97,7 +101,8 @@ public:
enum HAlignment {
AlignLeft = Qt::AlignLeft,
AlignRight = Qt::AlignRight,
- AlignHCenter = Qt::AlignHCenter
+ AlignHCenter = Qt::AlignHCenter,
+ AlignJustify = Qt::AlignJustify // ### VERSIONING: Only in QtQuick 1.1
};
enum VAlignment {
@@ -119,6 +124,11 @@ public:
Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
};
+ enum SelectionMode {
+ SelectCharacters,
+ SelectWords
+ };
+
Q_INVOKABLE void openSoftwareInputPanel();
Q_INVOKABLE void closeSoftwareInputPanel();
@@ -149,6 +159,8 @@ public:
WrapMode wrapMode() const;
void setWrapMode(WrapMode w);
+ int lineCount() const;
+
bool isCursorVisible() const;
void setCursorVisible(bool on);
@@ -175,6 +187,11 @@ public:
bool selectByMouse() const;
void setSelectByMouse(bool);
+ SelectionMode mouseSelectionMode() const;
+ void setMouseSelectionMode(SelectionMode mode);
+
+ bool canPaste() const;
+
virtual void componentComplete();
/* FROM EDIT */
@@ -194,6 +211,7 @@ public:
Q_INVOKABLE QRectF positionToRectangle(int) const;
Q_INVOKABLE int positionAt(int x, int y) const;
Q_INVOKABLE void moveCursorSelection(int pos);
+ Q_INVOKABLE Q_REVISION(1) void moveCursorSelection(int pos, SelectionMode mode);
QRectF boundingRect() const;
@@ -212,6 +230,7 @@ Q_SIGNALS:
void horizontalAlignmentChanged(HAlignment alignment);
void verticalAlignmentChanged(VAlignment alignment);
void wrapModeChanged();
+ void lineCountChanged();
void textFormatChanged(TextFormat textFormat);
void readOnlyChanged(bool isReadOnly);
void cursorVisibleChanged(bool isCursorVisible);
@@ -220,11 +239,15 @@ Q_SIGNALS:
void persistentSelectionChanged(bool isPersistentSelection);
void textMarginChanged(qreal textMargin);
void selectByMouseChanged(bool selectByMouse);
+ Q_REVISION(1) void mouseSelectionModeChanged(SelectionMode mode);
+ Q_REVISION(1) void linkActivated(const QString &link);
+ Q_REVISION(1) void canPasteChanged();
public Q_SLOTS:
void selectAll();
void selectWord();
void select(int start, int end);
+ Q_REVISION(1) void deselect();
#ifndef QT_NO_CLIPBOARD
void cut();
void copy();
@@ -237,9 +260,11 @@ private Q_SLOTS:
void updateSelectionMarkers();
void moveCursorDelegate();
void loadCursorDelegate();
+ void q_canPasteChanged();
private:
void updateSize();
+ void updateTotalLines();
protected:
virtual void geometryChanged(const QRectF &newGeometry,
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
index 68a9cc8..111cc02 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
@@ -54,7 +54,7 @@
//
#include "qdeclarativeitem.h"
-#include "private/qdeclarativepainteditem_p_p.h"
+#include "private/qdeclarativeimplicitsizeitem_p_p.h"
#include <qdeclarative.h>
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
class QTextLayout;
class QTextDocument;
class QTextControl;
-class QDeclarativeTextEditPrivate : public QDeclarativePaintedItemPrivate
+class QDeclarativeTextEditPrivate : public QDeclarativeImplicitSizePaintedItemPrivate
{
Q_DECLARE_PUBLIC(QDeclarativeTextEdit)
@@ -70,10 +70,10 @@ public:
QDeclarativeTextEditPrivate()
: color("black"), hAlign(QDeclarativeTextEdit::AlignLeft), vAlign(QDeclarativeTextEdit::AlignTop),
imgDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true),
- showInputPanelOnFocus(true), clickCausedFocus(false), persistentSelection(true), textMargin(0.0),
- lastSelectionStart(0), lastSelectionEnd(0), cursorComponent(0), cursor(0),
+ showInputPanelOnFocus(true), clickCausedFocus(false), persistentSelection(true), requireImplicitWidth(false),
+ textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), cursorComponent(0), cursor(0),
format(QDeclarativeTextEdit::AutoText), document(0), wrapMode(QDeclarativeTextEdit::NoWrap),
- selectByMouse(false),
+ mouseSelectionMode(QDeclarativeTextEdit::SelectCharacters), selectByMouse(false), canPaste(false),
yoff(0)
{
#ifdef Q_OS_SYMBIAN
@@ -88,10 +88,12 @@ public:
void updateDefaultTextOption();
void relayoutDocument();
void updateSelection();
+ qreal implicitWidth() const;
void focusChanged(bool);
QString text;
QFont font;
+ QFont sourceFont;
QColor color;
QColor selectionColor;
QColor selectedTextColor;
@@ -109,6 +111,7 @@ public:
bool showInputPanelOnFocus : 1;
bool clickCausedFocus : 1;
bool persistentSelection : 1;
+ bool requireImplicitWidth:1;
qreal textMargin;
int lastSelectionStart;
int lastSelectionEnd;
@@ -118,8 +121,12 @@ public:
QTextDocument *document;
QTextControl *control;
QDeclarativeTextEdit::WrapMode wrapMode;
+ QDeclarativeTextEdit::SelectionMode mouseSelectionMode;
+ int lineCount;
bool selectByMouse;
+ bool canPaste;
int yoff;
+ QSize paintedSize;
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 57a2177..78f34db 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -50,6 +50,9 @@
#include <QApplication>
#include <QFontMetrics>
#include <QPainter>
+#include <QTextBoundaryFinder>
+#include <QInputContext>
+#include <qstyle.h>
#ifndef QT_NO_LINEEDIT
@@ -75,7 +78,7 @@ QT_BEGIN_NAMESPACE
\sa TextEdit, Text, {declarative/text/textselection}{Text Selection example}
*/
QDeclarativeTextInput::QDeclarativeTextInput(QDeclarativeItem* parent)
- : QDeclarativePaintedItem(*(new QDeclarativeTextInputPrivate), parent)
+ : QDeclarativeImplicitSizePaintedItem(*(new QDeclarativeTextInputPrivate), parent)
{
Q_D(QDeclarativeTextInput);
d->init();
@@ -213,24 +216,33 @@ void QDeclarativeTextInput::setText(const QString &s)
QFont QDeclarativeTextInput::font() const
{
Q_D(const QDeclarativeTextInput);
- return d->font;
+ return d->sourceFont;
}
void QDeclarativeTextInput::setFont(const QFont &font)
{
Q_D(QDeclarativeTextInput);
- if (d->font == font)
+ if (d->sourceFont == font)
return;
+ d->sourceFont = font;
+ QFont oldFont = d->font;
d->font = font;
+ if (d->font.pointSizeF() != -1) {
+ // 0.5pt resolution
+ qreal size = qRound(d->font.pointSizeF()*2.0);
+ d->font.setPointSizeF(size/2.0);
+ }
- d->control->setFont(d->font);
- if(d->cursorItem){
- d->cursorItem->setHeight(QFontMetrics(d->font).height());
- moveCursor();
+ if (oldFont != d->font) {
+ d->control->setFont(d->font);
+ if(d->cursorItem){
+ d->cursorItem->setHeight(QFontMetrics(d->font).height());
+ moveCursor();
+ }
+ updateSize();
}
- updateSize();
- emit fontChanged(d->font);
+ emit fontChanged(d->sourceFont);
}
/*!
@@ -344,6 +356,16 @@ void QDeclarativeTextInput::setHAlign(HAlignment align)
emit horizontalAlignmentChanged(d->hAlign);
}
+/*!
+ \qmlproperty bool TextInput::readOnly
+
+ Sets whether user input can modify the contents of the TextInput.
+
+ If readOnly is set to true, then user input will not affect the text
+ property. Any bindings or attempts to set the text property will still
+ work.
+*/
+
bool QDeclarativeTextInput::isReadOnly() const
{
Q_D(const QDeclarativeTextInput);
@@ -356,11 +378,20 @@ void QDeclarativeTextInput::setReadOnly(bool ro)
if (d->control->isReadOnly() == ro)
return;
+ setFlag(QGraphicsItem::ItemAcceptsInputMethod, !ro);
d->control->setReadOnly(ro);
emit readOnlyChanged(ro);
}
+/*!
+ \qmlproperty int TextInput::maximumLength
+ The maximum permitted length of the text in the TextInput.
+
+ If the text is too long, it is truncated at the limit.
+
+ By default, this property contains a value of 32767.
+*/
int QDeclarativeTextInput::maxLength() const
{
Q_D(const QDeclarativeTextInput);
@@ -520,10 +551,10 @@ void QDeclarativeTextInput::select(int start, int end)
It is equivalent to the following snippet, but is faster and easier
to use.
- \qml
+ \js
myTextInput.text.toString().substring(myTextInput.selectionStart,
myTextInput.selectionEnd);
- \endqml
+ \endjs
*/
QString QDeclarativeTextInput::selectedText() const
{
@@ -584,6 +615,11 @@ void QDeclarativeTextInput::setAutoScroll(bool b)
\ingroup qml-basic-visual-elements
This element provides a validator for integer values.
+
+ IntValidator uses the \l {QLocale::setDefault()}{default locale} to interpret the number and
+ will accept locale specific digits, group separators, and positive and negative signs. In
+ addition, IntValidator is always guaranteed to accept a number formatted according to the "C"
+ locale.
*/
/*!
\qmlproperty int IntValidator::top
@@ -741,6 +777,15 @@ bool QDeclarativeTextInput::hasAcceptableInput() const
}
/*!
+ \qmlsignal TextInput::onAccepted()
+
+ This handler is called when the Return or Enter key is pressed.
+ Note that if there is a \l validator or \l inputMask set on the text
+ input, the handler will only be emitted if the input is in an acceptable
+ state.
+*/
+
+/*!
\qmlproperty enumeration TextInput::echoMode
Specifies how the text should be displayed in the TextInput.
@@ -903,7 +948,7 @@ void QDeclarativeTextInputPrivate::focusChanged(bool hasFocus)
{
Q_Q(QDeclarativeTextInput);
focused = hasFocus;
- q->setCursorVisible(hasFocus);
+ q->setCursorVisible(hasFocus && scene && scene->hasFocus());
if(q->echoMode() == QDeclarativeTextInput::PasswordEchoOnEdit && !hasFocus)
control->updatePasswordEchoEditing(false);//QLineControl sets it on key events, but doesn't deal with focus events
if (!hasFocus)
@@ -945,6 +990,7 @@ void QDeclarativeTextInput::inputMethodEvent(QInputMethodEvent *ev)
} else {
d->control->processInputMethodEvent(ev);
updateSize();
+ d->updateHorizontalScroll();
}
if (!ev->isAccepted())
QDeclarativePaintedItem::inputMethodEvent(ev);
@@ -957,6 +1003,8 @@ Handles the given mouse \a event.
void QDeclarativeTextInput::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextInput);
+ if (d->sendMouseEventToInputContext(event, QEvent::MouseButtonDblClick))
+ return;
if (d->selectByMouse) {
int cursor = d->xToPos(event->pos().x());
d->control->selectWordAtPos(cursor);
@@ -969,6 +1017,8 @@ void QDeclarativeTextInput::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even
void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextInput);
+ if (d->sendMouseEventToInputContext(event, QEvent::MouseButtonPress))
+ return;
if(d->focusOnPress){
bool hadActiveFocus = hasActiveFocus();
forceActiveFocus();
@@ -983,6 +1033,10 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
}
}
+ if (d->selectByMouse) {
+ setKeepMouseGrab(false);
+ d->pressPos = event->pos();
+ }
bool mark = event->modifiers() & Qt::ShiftModifier;
int cursor = d->xToPos(event->pos().x());
d->control->moveCursor(cursor, mark);
@@ -992,8 +1046,12 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
void QDeclarativeTextInput::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextInput);
+ if (d->sendMouseEventToInputContext(event, QEvent::MouseMove))
+ event->setAccepted(true);
if (d->selectByMouse) {
- d->control->moveCursor(d->xToPos(event->pos().x()), true);
+ if (qAbs(int(event->pos().x() - d->pressPos.x())) > QApplication::startDragDistance())
+ setKeepMouseGrab(true);
+ moveCursorSelection(d->xToPos(event->pos().x()), d->mouseSelectionMode);
event->setAccepted(true);
} else {
QDeclarativePaintedItem::mouseMoveEvent(event);
@@ -1007,6 +1065,10 @@ Handles the given mouse \a event.
void QDeclarativeTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextInput);
+ if (d->sendMouseEventToInputContext(event, QEvent::MouseButtonRelease))
+ return;
+ if (d->selectByMouse)
+ setKeepMouseGrab(false);
if (!d->showInputPanelOnFocus) { // input panel on click
if (d->focusOnPress && !isReadOnly() && boundingRect().contains(event->pos())) {
if (QGraphicsView * view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
@@ -1022,6 +1084,53 @@ void QDeclarativeTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
QDeclarativePaintedItem::mouseReleaseEvent(event);
}
+bool QDeclarativeTextInputPrivate::sendMouseEventToInputContext(
+ QGraphicsSceneMouseEvent *event, QEvent::Type eventType)
+{
+#if !defined QT_NO_IM
+ if (event->widget() && control->composeMode()) {
+ int tmp_cursor = xToPos(event->pos().x());
+ int mousePos = tmp_cursor - control->cursor();
+ if (mousePos < 0 || mousePos > control->preeditAreaText().length()) {
+ mousePos = -1;
+ // don't send move events outside the preedit area
+ if (eventType == QEvent::MouseMove)
+ return true;
+ }
+
+ QInputContext *qic = event->widget()->inputContext();
+ if (qic) {
+ QMouseEvent mouseEvent(
+ eventType,
+ event->widget()->mapFromGlobal(event->screenPos()),
+ event->screenPos(),
+ event->button(),
+ event->buttons(),
+ event->modifiers());
+ // may be causing reset() in some input methods
+ qic->mouseHandler(mousePos, &mouseEvent);
+ event->setAccepted(mouseEvent.isAccepted());
+ }
+ if (!control->preeditAreaText().isEmpty())
+ return true;
+ }
+#else
+ Q_UNUSED(event);
+ Q_UNUSED(eventType)
+#endif
+
+ return false;
+}
+
+bool QDeclarativeTextInput::sceneEvent(QEvent *event)
+{
+ bool rv = QDeclarativeItem::sceneEvent(event);
+ if (event->type() == QEvent::UngrabMouse) {
+ setKeepMouseGrab(false);
+ }
+ return rv;
+}
+
bool QDeclarativeTextInput::event(QEvent* ev)
{
Q_D(QDeclarativeTextInput);
@@ -1063,13 +1172,15 @@ int QDeclarativeTextInputPrivate::calculateTextWidth()
void QDeclarativeTextInputPrivate::updateHorizontalScroll()
{
Q_Q(QDeclarativeTextInput);
- int cix = qRound(control->cursorToX());
+ const int preeditLength = control->preeditAreaText().length();
+ int cix = qRound(control->cursorToX(control->cursor() + preeditLength));
QRect br(q->boundingRect().toRect());
int widthUsed = calculateTextWidth();
+ Qt::Alignment va = QStyle::visualAlignment(control->layoutDirection(), QFlag(Qt::Alignment(hAlign)));
if (autoScroll) {
if (widthUsed <= br.width()) {
// text fits in br; use hscroll for alignment
- switch (hAlign & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) {
+ switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) {
case Qt::AlignRight:
hscroll = widthUsed - br.width() - 1;
break;
@@ -1092,13 +1203,26 @@ void QDeclarativeTextInputPrivate::updateHorizontalScroll()
// right
hscroll = widthUsed - br.width() + 1;
}
+ if (preeditLength > 0) {
+ // check to ensure long pre-edit text doesn't push the cursor
+ // off to the left
+ cix = qRound(control->cursorToX(
+ control->cursor() + qMax(0, control->preeditCursor() - 1)));
+ if (cix < hscroll)
+ hscroll = cix;
+ }
} else {
- if(hAlign == QDeclarativeTextInput::AlignRight){
+ switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) {
+ case Qt::AlignRight:
hscroll = q->width() - widthUsed;
- }else if(hAlign == QDeclarativeTextInput::AlignHCenter){
+ break;
+ case Qt::AlignHCenter:
hscroll = (q->width() - widthUsed) / 2;
- } else {
+ break;
+ default:
+ // Left
hscroll = 0;
+ break;
}
}
}
@@ -1160,6 +1284,17 @@ QVariant QDeclarativeTextInput::inputMethodQuery(Qt::InputMethodQuery property)
}
/*!
+ \qmlmethod void TextInput::deselect()
+
+ Removes active text selection.
+*/
+void QDeclarativeTextInput::deselect()
+{
+ Q_D(QDeclarativeTextInput);
+ d->control->deselect();
+}
+
+/*!
\qmlmethod void TextInput::selectAll()
Causes all text to be selected.
@@ -1202,7 +1337,8 @@ void QDeclarativeTextInput::copy()
void QDeclarativeTextInput::paste()
{
Q_D(QDeclarativeTextInput);
- d->control->paste();
+ if(!d->control->isReadOnly())
+ d->control->paste();
}
#endif // QT_NO_CLIPBOARD
@@ -1301,35 +1437,137 @@ void QDeclarativeTextInput::setSelectByMouse(bool on)
}
}
+/*!
+ \qmlproperty enum TextInput::mouseSelectionMode
+ \since Quick 1.1
+
+ Specifies how text should be selected using a mouse.
+
+ \list
+ \o TextInput.SelectCharacters - The selection is updated with individual characters. (Default)
+ \o TextInput.SelectWords - The selection is updated with whole words.
+ \endlist
+
+ This property only applies when \l selectByMouse is true.
+*/
+
+QDeclarativeTextInput::SelectionMode QDeclarativeTextInput::mouseSelectionMode() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->mouseSelectionMode;
+}
+
+void QDeclarativeTextInput::setMouseSelectionMode(SelectionMode mode)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->mouseSelectionMode != mode) {
+ d->mouseSelectionMode = mode;
+ emit mouseSelectionModeChanged(mode);
+ }
+}
+
+bool QDeclarativeTextInput::canPaste() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->canPaste;
+}
+
+void QDeclarativeTextInput::moveCursorSelection(int position)
+{
+ Q_D(QDeclarativeTextInput);
+ d->control->moveCursor(position, true);
+ d->updateHorizontalScroll();
+}
/*!
- \qmlmethod void TextInput::moveCursorSelection(int position)
+ \qmlmethod void TextInput::moveCursorSelection(int position, SelectionMode mode = TextInput.SelectCharacters)
+ \since Quick 1.1
- Moves the cursor to \a position and updates the selection accordingly.
- (To only move the cursor, set the \l cursorPosition property.)
+ Moves the cursor to \a position and updates the selection according to the optional \a mode
+ parameter. (To only move the cursor, set the \l cursorPosition property.)
When this method is called it additionally sets either the
selectionStart or the selectionEnd (whichever was at the previous cursor position)
to the specified position. This allows you to easily extend and contract the selected
text range.
+ The selection mode specifies whether the selection is updated on a per character or a per word
+ basis. If not specified the selection mode will default to TextInput.SelectCharacters.
+
+ \list
+ \o TextEdit.SelectCharacters - Sets either the selectionStart or selectionEnd (whichever was at
+ the previous cursor position) to the specified position.
+ \o TextEdit.SelectWords - Sets the selectionStart and selectionEnd to include all
+ words between the specified postion and the previous cursor position. Words partially in the
+ range are included.
+ \endlist
+
For example, take this sequence of calls:
\code
cursorPosition = 5
- moveCursorSelection(9)
- moveCursorSelection(7)
+ moveCursorSelection(9, TextInput.SelectCharacters)
+ moveCursorSelection(7, TextInput.SelectCharacters)
\endcode
This moves the cursor to position 5, extend the selection end from 5 to 9
and then retract the selection end from 9 to 7, leaving the text from position 5 to 7
selected (the 6th and 7th characters).
+
+ The same sequence with TextInput.SelectWords will extend the selection start to a word boundary
+ before or on position 5 and extend the selection end to a word boundary on or past position 9.
*/
-void QDeclarativeTextInput::moveCursorSelection(int position)
+void QDeclarativeTextInput::moveCursorSelection(int pos, SelectionMode mode)
{
Q_D(QDeclarativeTextInput);
- d->control->moveCursor(position, true);
- d->updateHorizontalScroll();
+
+ if (mode == SelectCharacters) {
+ d->control->moveCursor(pos, true);
+ } else if (pos != d->control->cursor()){
+ const int cursor = d->control->cursor();
+ int anchor;
+ if (!d->control->hasSelectedText())
+ anchor = d->control->cursor();
+ else if (d->control->selectionStart() == d->control->cursor())
+ anchor = d->control->selectionEnd();
+ else
+ anchor = d->control->selectionStart();
+
+ if (anchor < pos || (anchor == pos && cursor < pos)) {
+ QTextBoundaryFinder finder(QTextBoundaryFinder::Word, d->control->text());
+ finder.setPosition(anchor);
+
+ const QTextBoundaryFinder::BoundaryReasons reasons = finder.boundaryReasons();
+ if (!(reasons & QTextBoundaryFinder::StartWord)
+ || ((reasons & QTextBoundaryFinder::EndWord) && anchor > cursor)) {
+ finder.toPreviousBoundary();
+ }
+ anchor = finder.position();
+
+ finder.setPosition(pos);
+ if (!finder.isAtBoundary())
+ finder.toNextBoundary();
+
+ d->control->setSelection(anchor, finder.position() - anchor);
+ } else if (anchor > pos || (anchor == pos && cursor > pos)) {
+ QTextBoundaryFinder finder(QTextBoundaryFinder::Word, d->control->text());
+ finder.setPosition(anchor);
+
+ const QTextBoundaryFinder::BoundaryReasons reasons = finder.boundaryReasons();
+ if (!(reasons & QTextBoundaryFinder::EndWord)
+ || ((reasons & QTextBoundaryFinder::StartWord) && anchor < cursor)) {
+ finder.toNextBoundary();
+ }
+
+ anchor = finder.position();
+
+ finder.setPosition(pos);
+ if (!finder.isAtBoundary())
+ finder.toPreviousBoundary();
+
+ d->control->setSelection(anchor, finder.position() - anchor);
+ }
+ }
}
/*!
@@ -1465,6 +1703,14 @@ void QDeclarativeTextInputPrivate::init()
q, SIGNAL(accepted()));
q->connect(control, SIGNAL(updateNeeded(QRect)),
q, SLOT(updateRect(QRect)));
+#ifndef QT_NO_CLIPBOARD
+ q->connect(q, SIGNAL(readOnlyChanged(bool)),
+ q, SLOT(q_canPasteChanged()));
+ q->connect(QApplication::clipboard(), SIGNAL(dataChanged()),
+ q, SLOT(q_canPasteChanged()));
+#endif // QT_NO_CLIPBOARD
+ q->connect(control, SIGNAL(updateMicroFocus()),
+ q, SLOT(updateMicroFocus()));
q->updateSize();
oldValidity = control->hasAcceptableInput();
lastSelectionStart = 0;
@@ -1566,6 +1812,17 @@ void QDeclarativeTextInput::updateSize(bool needsRedraw)
}
}
+void QDeclarativeTextInput::q_canPasteChanged()
+{
+ Q_D(QDeclarativeTextInput);
+ bool old = d->canPaste;
+#ifndef QT_NO_CLIPBOARD
+ d->canPaste = !d->control->isReadOnly() && QApplication::clipboard()->text().length() != 0;
+#endif
+ if(d->canPaste != old)
+ emit canPasteChanged();
+}
+
QT_END_NAMESPACE
#endif // QT_NO_LINEEDIT
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
index abea0e8..e1e66a9 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
@@ -43,7 +43,7 @@
#define QDECLARATIVETEXTINPUT_H
#include "private/qdeclarativetext_p.h"
-#include "private/qdeclarativepainteditem_p.h"
+#include "private/qdeclarativeimplicitsizeitem_p.h"
#include <QGraphicsSceneMouseEvent>
#include <QIntValidator>
@@ -58,11 +58,12 @@ QT_MODULE(Declarative)
class QDeclarativeTextInputPrivate;
class QValidator;
-class Q_AUTOTEST_EXPORT QDeclarativeTextInput : public QDeclarativePaintedItem
+class Q_AUTOTEST_EXPORT QDeclarativeTextInput : public QDeclarativeImplicitSizePaintedItem
{
Q_OBJECT
Q_ENUMS(HAlignment)
Q_ENUMS(EchoMode)
+ Q_ENUMS(SelectionMode)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
@@ -94,6 +95,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextInput : public QDeclarativePaintedItem
Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged)
Q_PROPERTY(bool autoScroll READ autoScroll WRITE setAutoScroll NOTIFY autoScrollChanged)
Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
+ Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged REVISION 1)
+ Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged REVISION 1)
public:
QDeclarativeTextInput(QDeclarativeItem* parent=0);
@@ -112,10 +115,16 @@ public:
AlignHCenter = Qt::AlignHCenter
};
+ enum SelectionMode {
+ SelectCharacters,
+ SelectWords
+ };
+
//Auxilliary functions needed to control the TextInput from QML
Q_INVOKABLE int positionAt(int x) const;
Q_INVOKABLE QRectF positionToRectangle(int pos) const;
Q_INVOKABLE void moveCursorSelection(int pos);
+ Q_INVOKABLE Q_REVISION(1) void moveCursorSelection(int pos, SelectionMode mode);
Q_INVOKABLE void openSoftwareInputPanel();
Q_INVOKABLE void closeSoftwareInputPanel();
@@ -184,12 +193,16 @@ public:
bool selectByMouse() const;
void setSelectByMouse(bool);
+ SelectionMode mouseSelectionMode() const;
+ void setMouseSelectionMode(SelectionMode mode);
+
bool hasAcceptableInput() const;
void drawContents(QPainter *p,const QRect &r);
QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
QRectF boundingRect() const;
+ bool canPaste() const;
Q_SIGNALS:
void textChanged();
@@ -216,6 +229,8 @@ Q_SIGNALS:
void activeFocusOnPressChanged(bool activeFocusOnPress);
void autoScrollChanged(bool autoScroll);
void selectByMouseChanged(bool selectByMouse);
+ Q_REVISION(1) void mouseSelectionModeChanged(SelectionMode mode);
+ Q_REVISION(1) void canPasteChanged();
protected:
virtual void geometryChanged(const QRectF &newGeometry,
@@ -225,6 +240,7 @@ protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
+ bool sceneEvent(QEvent *event);
void keyPressEvent(QKeyEvent* ev);
void inputMethodEvent(QInputMethodEvent *);
bool event(QEvent *e);
@@ -234,6 +250,7 @@ public Q_SLOTS:
void selectAll();
void selectWord();
void select(int start, int end);
+ Q_REVISION(1) void deselect();
#ifndef QT_NO_CLIPBOARD
void cut();
void copy();
@@ -248,6 +265,7 @@ private Q_SLOTS:
void moveCursor();
void cursorPosChanged();
void updateRect(const QRect &r = QRect());
+ void q_canPasteChanged();
private:
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeTextInput)
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
index 18e9c81..ab2838b 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
@@ -44,7 +44,7 @@
#include "private/qdeclarativetextinput_p.h"
-#include "private/qdeclarativepainteditem_p_p.h"
+#include "private/qdeclarativeimplicitsizeitem_p_p.h"
#include <qdeclarative.h>
@@ -66,16 +66,17 @@
QT_BEGIN_NAMESPACE
-class QDeclarativeTextInputPrivate : public QDeclarativePaintedItemPrivate
+class Q_AUTOTEST_EXPORT QDeclarativeTextInputPrivate : public QDeclarativeImplicitSizePaintedItemPrivate
{
Q_DECLARE_PUBLIC(QDeclarativeTextInput)
public:
QDeclarativeTextInputPrivate() : control(new QLineControl(QString())),
color((QRgb)0), style(QDeclarativeText::Normal),
styleColor((QRgb)0), hAlign(QDeclarativeTextInput::AlignLeft),
+ mouseSelectionMode(QDeclarativeTextInput::SelectCharacters),
hscroll(0), oldScroll(0), focused(false), focusOnPress(true),
showInputPanelOnFocus(true), clickCausedFocus(false), cursorVisible(false),
- autoScroll(true), selectByMouse(false)
+ autoScroll(true), selectByMouse(false), canPaste(false)
{
#ifdef Q_OS_SYMBIAN
if (QSysInfo::symbianVersion() == QSysInfo::SV_SF_1 || QSysInfo::symbianVersion() == QSysInfo::SV_SF_3) {
@@ -103,18 +104,22 @@ public:
void focusChanged(bool hasFocus);
void updateHorizontalScroll();
int calculateTextWidth();
+ bool sendMouseEventToInputContext(QGraphicsSceneMouseEvent *event, QEvent::Type eventType);
QLineControl* control;
QFont font;
+ QFont sourceFont;
QColor color;
QColor selectionColor;
QColor selectedTextColor;
QDeclarativeText::TextStyle style;
QColor styleColor;
QDeclarativeTextInput::HAlignment hAlign;
+ QDeclarativeTextInput::SelectionMode mouseSelectionMode;
QPointer<QDeclarativeComponent> cursorComponent;
QPointer<QDeclarativeItem> cursorItem;
+ QPointF pressPos;
int lastSelectionStart;
int lastSelectionEnd;
@@ -130,6 +135,11 @@ public:
bool cursorVisible;
bool autoScroll;
bool selectByMouse;
+ bool canPaste;
+
+ static inline QDeclarativeTextInputPrivate *get(QDeclarativeTextInput *t) {
+ return t->d_func();
+ }
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 065a388..a8082f8 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -557,8 +557,9 @@ QDeclarativeVisualDataModelData::~QDeclarativeVisualDataModelData()
void QDeclarativeVisualDataModelData::ensureProperties()
{
QDeclarativeVisualDataModelPrivate *modelPriv = QDeclarativeVisualDataModelPrivate::get(m_model);
- if (modelPriv->m_metaDataCacheable && !modelPriv->m_metaDataCreated) {
- modelPriv->createMetaData();
+ if (modelPriv->m_metaDataCacheable) {
+ if (!modelPriv->m_metaDataCreated)
+ modelPriv->createMetaData();
if (modelPriv->m_metaDataCreated)
m_meta->setCached(true);
}
@@ -1076,7 +1077,7 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
} else {
delete data;
delete ctxt;
- qmlInfo(this, d->m_delegate->errors()) << "Error creating delgate";
+ qmlInfo(this, d->m_delegate->errors()) << "Error creating delegate";
}
}
QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(nobj);
diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp
index af955a4..4dfef45 100644
--- a/src/declarative/qml/parser/qdeclarativejslexer.cpp
+++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp
@@ -619,7 +619,7 @@ int Lexer::lex()
} else {
setDone(Bad);
err = IllegalEscapeSequence;
- errmsg = QCoreApplication::translate("QDeclarativeParser", "Illegal escape squence");
+ errmsg = QCoreApplication::translate("QDeclarativeParser", "Illegal escape sequence");
}
} else if (current == 'x')
state = InHexEscape;
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
index 3017385..5da7901 100644
--- a/src/declarative/qml/qdeclarative.h
+++ b/src/declarative/qml/qdeclarative.h
@@ -113,6 +113,7 @@ int qmlRegisterType()
0, 0,
+ 0,
0
};
@@ -148,6 +149,7 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin
0, 0,
+ 0,
0
};
@@ -181,12 +183,82 @@ int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const c
0, 0,
+ 0,
0
};
return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
+template<typename T, int metaObjectRevision>
+int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterType type = {
+ 1,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ sizeof(T), QDeclarativePrivate::createInto<T>,
+ QString(),
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ 0,
+ metaObjectRevision
+ };
+
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
+}
+
+template<typename T, int metaObjectRevision>
+int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterType type = {
+ 1,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ sizeof(T), QDeclarativePrivate::createInto<T>,
+ QString(),
+
+ uri, versionMajor, versionMinor, 0, &T::staticMetaObject,
+
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ 0,
+ metaObjectRevision
+ };
+
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
+}
+
+
template<typename T, typename E>
int qmlRegisterExtendedType()
{
@@ -214,6 +286,7 @@ int qmlRegisterExtendedType()
QDeclarativePrivate::createParent<E>, &E::staticMetaObject,
+ 0,
0
};
@@ -255,6 +328,7 @@ int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
QDeclarativePrivate::createParent<E>, &E::staticMetaObject,
+ 0,
0
};
@@ -309,7 +383,8 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
0, 0,
- parser
+ parser,
+ 0
};
return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
index d9dff44..a5bd604 100644
--- a/src/declarative/qml/qdeclarativebinding.cpp
+++ b/src/declarative/qml/qdeclarativebinding.cpp
@@ -46,9 +46,11 @@
#include "qdeclarativecontext.h"
#include "qdeclarativeinfo.h"
#include "private/qdeclarativecontext_p.h"
+#include "private/qdeclarativecompiler_p.h"
#include "private/qdeclarativedata_p.h"
#include "private/qdeclarativestringconverters_p.h"
#include "private/qdeclarativestate_p_p.h"
+#include "private/qdeclarativedebugtrace_p.h"
#include <QVariant>
#include <QtCore/qdebug.h>
@@ -207,6 +209,8 @@ void QDeclarativeAbstractBinding::setEnabled(bool enabled, QDeclarativePropertyP
if (enabled) update(flags);
}
+QDeclarativeBinding::Identifier QDeclarativeBinding::Invalid = -1;
+
void QDeclarativeBindingPrivate::refresh()
{
Q_Q(QDeclarativeBinding);
@@ -232,6 +236,28 @@ QDeclarativeBinding::QDeclarativeBinding(void *data, QDeclarativeRefCount *rc, Q
setNotifyOnValueChanged(true);
}
+QDeclarativeBinding *
+QDeclarativeBinding::createBinding(Identifier id, QObject *obj, QDeclarativeContext *ctxt,
+ const QString &url, int lineNumber, QObject *parent)
+{
+ if (id < 0)
+ return 0;
+
+ QDeclarativeContextData *ctxtdata = QDeclarativeContextData::get(ctxt);
+
+ QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(qmlEngine(obj));
+ QDeclarativeCompiledData *cdata = 0;
+ QDeclarativeTypeData *typeData = 0;
+ if (engine && ctxtdata && !ctxtdata->url.isEmpty()) {
+ typeData = engine->typeLoader.get(ctxtdata->url);
+ cdata = typeData->compiledData();
+ }
+ QDeclarativeBinding *rv = cdata ? new QDeclarativeBinding((void*)cdata->datas.at(id).constData(), cdata, obj, ctxtdata, url, lineNumber, parent) : 0;
+ if (typeData)
+ typeData->release();
+ return rv;
+}
+
QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContext *ctxt,
QObject *parent)
: QDeclarativeExpression(QDeclarativeContextData::get(ctxt), obj, str, *new QDeclarativeBindingPrivate)
@@ -248,6 +274,13 @@ QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDecl
setNotifyOnValueChanged(true);
}
+QDeclarativeBinding::QDeclarativeBinding(const QScriptValue &func, QObject *obj, QDeclarativeContextData *ctxt, QObject *parent)
+: QDeclarativeExpression(ctxt, obj, func, *new QDeclarativeBindingPrivate)
+{
+ setParent(parent);
+ setNotifyOnValueChanged(true);
+}
+
QDeclarativeBinding::~QDeclarativeBinding()
{
}
@@ -266,6 +299,34 @@ QDeclarativeProperty QDeclarativeBinding::property() const
return d->property;
}
+void QDeclarativeBinding::setEvaluateFlags(EvaluateFlags flags)
+{
+ Q_D(QDeclarativeBinding);
+ d->setEvaluateFlags(QDeclarativeQtScriptExpression::EvaluateFlags(static_cast<int>(flags)));
+}
+
+QDeclarativeBinding::EvaluateFlags QDeclarativeBinding::evaluateFlags() const
+{
+ Q_D(const QDeclarativeBinding);
+ return QDeclarativeBinding::EvaluateFlags(static_cast<int>(d->evaluateFlags()));
+}
+
+
+class QDeclarativeBindingProfiler {
+public:
+ QDeclarativeBindingProfiler(QDeclarativeBinding *bind)
+ {
+ QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Binding);
+ QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::Binding, bind->expression());
+ QDeclarativeDebugTrace::rangeLocation(QDeclarativeDebugTrace::Binding, bind->sourceFile(), bind->lineNumber());
+ }
+
+ ~QDeclarativeBindingProfiler()
+ {
+ QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::Binding);
+ }
+};
+
void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags)
{
Q_D(QDeclarativeBinding);
@@ -274,6 +335,7 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags)
return;
if (!d->updating) {
+ QDeclarativeBindingProfiler prof(this);
d->updating = true;
bool wasDeleted = false;
d->deleted = &wasDeleted;
diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h
index 56a5d77..0260b95 100644
--- a/src/declarative/qml/qdeclarativebinding_p.h
+++ b/src/declarative/qml/qdeclarativebinding_p.h
@@ -147,14 +147,21 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeBinding : public QDeclarativeExpr
{
Q_OBJECT
public:
+ enum EvaluateFlag { RequiresThisObject = 0x01 };
+ Q_DECLARE_FLAGS(EvaluateFlags, EvaluateFlag)
+
QDeclarativeBinding(const QString &, QObject *, QDeclarativeContext *, QObject *parent=0);
QDeclarativeBinding(const QString &, QObject *, QDeclarativeContextData *, QObject *parent=0);
QDeclarativeBinding(void *, QDeclarativeRefCount *, QObject *, QDeclarativeContextData *,
const QString &, int, QObject *parent);
+ QDeclarativeBinding(const QScriptValue &, QObject *, QDeclarativeContextData *, QObject *parent=0);
void setTarget(const QDeclarativeProperty &);
QDeclarativeProperty property() const;
+ void setEvaluateFlags(EvaluateFlags flags);
+ EvaluateFlags evaluateFlags() const;
+
bool enabled() const;
// Inherited from QDeclarativeAbstractBinding
@@ -162,6 +169,10 @@ public:
virtual void update(QDeclarativePropertyPrivate::WriteFlags flags);
virtual QString expression() const;
+ typedef int Identifier;
+ static Identifier Invalid;
+ static QDeclarativeBinding *createBinding(Identifier, QObject *, QDeclarativeContext *, const QString &, int, QObject *parent=0);
+
public Q_SLOTS:
void update() { update(QDeclarativePropertyPrivate::DontRemoveBinding); }
@@ -173,6 +184,8 @@ private:
Q_DECLARE_PRIVATE(QDeclarativeBinding)
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeBinding::EvaluateFlags)
+
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QDeclarativeBinding*)
diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp
index d039c68..28dfea9 100644
--- a/src/declarative/qml/qdeclarativeboundsignal.cpp
+++ b/src/declarative/qml/qdeclarativeboundsignal.cpp
@@ -49,7 +49,9 @@
#include "qdeclarative.h"
#include "qdeclarativecontext.h"
#include "private/qdeclarativeglobal_p.h"
+#include "private/qdeclarativedebugtrace_p.h"
+#include <QtCore/qstringbuilder.h>
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
@@ -165,6 +167,13 @@ QDeclarativeBoundSignal *QDeclarativeBoundSignal::cast(QObject *o)
int QDeclarativeBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a)
{
if (c == QMetaObject::InvokeMetaMethod && id == evaluateIdx) {
+ if (!m_expression)
+ return -1;
+ if (QDeclarativeDebugService::isDebuggingEnabled()) {
+ QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::HandlingSignal);
+ QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::HandlingSignal, QLatin1String(m_signal.signature()) % QLatin1String(": ") % m_expression->expression());
+ QDeclarativeDebugTrace::rangeLocation(QDeclarativeDebugTrace::HandlingSignal, m_expression->sourceFile(), m_expression->lineNumber());
+ }
m_isEvaluating = true;
if (!m_paramsValid) {
if (!m_signal.parameterTypes().isEmpty())
@@ -180,6 +189,7 @@ int QDeclarativeBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a)
}
if (m_params) m_params->clearValues();
m_isEvaluating = false;
+ QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::HandlingSignal);
return -1;
} else {
return QObject::qt_metacall(c, id, a);
@@ -187,13 +197,12 @@ int QDeclarativeBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a)
}
QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(const QMetaMethod &method,
- QObject *parent)
+ QObject *parent)
: QObject(parent), types(0), values(0)
{
MetaObject *mo = new MetaObject(this);
// ### Optimize!
- // ### Ensure only supported types are allowed, otherwise it might crash
QMetaObjectBuilder mob;
mob.setSuperClass(&QDeclarativeBoundSignalParameters::staticMetaObject);
mob.setClassName("QDeclarativeBoundSignalParameters");
@@ -216,9 +225,15 @@ QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(const QMeta
QMetaPropertyBuilder prop = mob.addProperty(name, "QObject*");
prop.setWritable(false);
} else {
- types[ii] = t;
- QMetaPropertyBuilder prop = mob.addProperty(name, type);
- prop.setWritable(false);
+ if (QDeclarativeMetaType::canCopy(t)) {
+ types[ii] = t;
+ QMetaPropertyBuilder prop = mob.addProperty(name, type);
+ prop.setWritable(false);
+ } else {
+ types[ii] = 0x80000000 | t;
+ QMetaPropertyBuilder prop = mob.addProperty(name, "QVariant");
+ prop.setWritable(false);
+ }
}
}
myMetaObject = mob.toMetaObject();
@@ -249,7 +264,11 @@ int QDeclarativeBoundSignalParameters::metaCall(QMetaObject::Call c, int id, voi
return -1;
if (c == QMetaObject::ReadProperty && id >= 1) {
- QDeclarativeMetaType::copy(types[id - 1], a[0], values[id]);
+ if (types[id - 1] & 0x80000000) {
+ *((QVariant *)a[0]) = QVariant(types[id - 1] & 0x7FFFFFFF, values[id]);
+ } else {
+ QDeclarativeMetaType::copy(types[id - 1], a[0], values[id]);
+ }
return -1;
} else {
return qt_metacall(c, id, a);
diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp
index 9db24de..a6fcce4 100644
--- a/src/declarative/qml/qdeclarativecompiledbindings.cpp
+++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
// #define COMPILEDBINDINGS_DEBUG
+// #define REGISTER_CLEANUP_DEBUG
#include "private/qdeclarativecompiledbindings_p.h"
@@ -54,6 +55,7 @@
#include <private/qdeclarativeanchors_p_p.h>
#include <private/qdeclarativeglobal_p.h>
#include <private/qdeclarativefastproperties_p.h>
+#include <private/qdeclarativedebugtrace_p.h>
QT_BEGIN_NAMESPACE
@@ -170,6 +172,24 @@ struct Register {
int type; // Optional type
void *data[2]; // Object stored here
+
+#ifdef REGISTER_CLEANUP_DEBUG
+ Register() {
+ type = 0;
+ }
+
+ ~Register() {
+ int allowedTypes[] = { QMetaType::QObjectStar, QMetaType::QReal, QMetaType::Int, QMetaType::Bool, 0 };
+ bool found = (type == 0);
+ int *ctype = allowedTypes;
+ while (!found && *ctype) {
+ found = (*ctype == type);
+ ++ctype;
+ }
+ if (!found)
+ qWarning("Register leaked of type %d", type);
+ }
+#endif
};
}
@@ -302,7 +322,9 @@ void QDeclarativeCompiledBindingsPrivate::Binding::setEnabled(bool e, QDeclarati
void QDeclarativeCompiledBindingsPrivate::Binding::update(QDeclarativePropertyPrivate::WriteFlags flags)
{
+ QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Binding);
parent->run(this, flags);
+ QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::Binding);
}
void QDeclarativeCompiledBindingsPrivate::Binding::destroy()
@@ -1409,10 +1431,16 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
QML_BEGIN_INSTR(CleanupString)
registers[instr->cleanup.reg].getstringptr()->~QString();
+#ifdef REGISTER_CLEANUP_DEBUG
+ registers[instr->cleanup.reg].setUndefined();
+#endif
QML_END_INSTR(CleanupString)
QML_BEGIN_INSTR(CleanupUrl)
registers[instr->cleanup.reg].geturlptr()->~QUrl();
+#ifdef REGISTER_CLEANUP_DEBUG
+ registers[instr->cleanup.reg].setUndefined();
+#endif
QML_END_INSTR(CleanupUrl)
QML_BEGIN_INSTR(Fetch)
@@ -1530,10 +1558,19 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
int type = registers[instr->cleanup.reg].gettype();
if (type == qMetaTypeId<QVariant>()) {
registers[instr->cleanup.reg].getvariantptr()->~QVariant();
+#ifdef REGISTER_CLEANUP_DEBUG
+ registers[instr->cleanup.reg].setUndefined();
+#endif
} else if (type == QMetaType::QString) {
registers[instr->cleanup.reg].getstringptr()->~QString();
+#ifdef REGISTER_CLEANUP_DEBUG
+ registers[instr->cleanup.reg].setUndefined();
+#endif
} else if (type == QMetaType::QUrl) {
registers[instr->cleanup.reg].geturlptr()->~QUrl();
+#ifdef REGISTER_CLEANUP_DEBUG
+ registers[instr->cleanup.reg].setUndefined();
+#endif
}
}
QML_END_INSTR(CleanupGeneric)
@@ -1746,7 +1783,6 @@ bool QDeclarativeBindingCompilerPrivate::compile(QDeclarativeJS::AST::Node *node
done.common.type = Instr::Done;
bytecode << done;
- return true;
} else {
// Can we store the final value?
if (type.type == QVariant::Int &&
@@ -1788,12 +1824,12 @@ bool QDeclarativeBindingCompilerPrivate::compile(QDeclarativeJS::AST::Node *node
Instr done;
done.common.type = Instr::Done;
bytecode << done;
-
- return true;
} else {
return false;
}
}
+
+ return true;
}
bool QDeclarativeBindingCompilerPrivate::parseExpression(QDeclarativeJS::AST::Node *node, Result &type)
@@ -2233,6 +2269,8 @@ bool QDeclarativeBindingCompilerPrivate::stringArith(Result &type, const Result
if (lhsTmp != -1) releaseReg(lhsTmp);
if (rhsTmp != -1) releaseReg(rhsTmp);
+ releaseReg(lhs.reg);
+ releaseReg(rhs.reg);
return true;
}
@@ -2524,6 +2562,10 @@ bool QDeclarativeBindingCompilerPrivate::fetch(Result &rv, const QMetaObject *mo
rv.metaObject = 0;
rv.type = 0;
+ //XXX binding optimizer doesn't handle properties with a revision
+ if (prop.revision() > 0)
+ return false;
+
int fastFetchIndex = fastProperties()->accessorIndexForProperty(mo, idx);
Instr fetch;
diff --git a/src/declarative/qml/qdeclarativecompileddata.cpp b/src/declarative/qml/qdeclarativecompileddata.cpp
index 70cace4..03deea1 100644
--- a/src/declarative/qml/qdeclarativecompileddata.cpp
+++ b/src/declarative/qml/qdeclarativecompileddata.cpp
@@ -171,6 +171,8 @@ QDeclarativeCompiledData::~QDeclarativeCompiledData()
for (int ii = 0; ii < types.count(); ++ii) {
if (types.at(ii).component)
types.at(ii).component->release();
+ if (types.at(ii).typePropertyCache)
+ types.at(ii).typePropertyCache->release();
}
for (int ii = 0; ii < propertyCaches.count(); ++ii)
@@ -209,6 +211,34 @@ const QMetaObject *QDeclarativeCompiledData::TypeReference::metaObject() const
}
}
+/*!
+Returns the property cache, if one alread exists. The cache is not referenced.
+*/
+QDeclarativePropertyCache *QDeclarativeCompiledData::TypeReference::propertyCache() const
+{
+ if (type)
+ return typePropertyCache;
+ else
+ return component->rootPropertyCache;
+}
+
+/*!
+Returns the property cache, creating one if it doesn't already exist. The cache is not referenced.
+*/
+QDeclarativePropertyCache *QDeclarativeCompiledData::TypeReference::createPropertyCache(QDeclarativeEngine *engine)
+{
+ if (typePropertyCache) {
+ return typePropertyCache;
+ } else if (type) {
+ typePropertyCache = QDeclarativeEnginePrivate::get(engine)->cache(type->metaObject());
+ typePropertyCache->addref();
+ return typePropertyCache;
+ } else {
+ return component->rootPropertyCache;
+ }
+}
+
+
void QDeclarativeCompiledData::dumpInstructions()
{
if (!name.isEmpty())
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 5c73f76..f57f842 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -589,6 +589,18 @@ bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine,
err = tr( "Element is not creatable.");
COMPILE_EXCEPTION(parserRef->refObjects.first(), err);
}
+
+ if (ref.type->containsRevisionedAttributes()) {
+ QDeclarativeError cacheError;
+ ref.typePropertyCache =
+ QDeclarativeEnginePrivate::get(engine)->cache(ref.type, resolvedTypes.at(ii).minorVersion, cacheError);
+
+ if (!ref.typePropertyCache) {
+ COMPILE_EXCEPTION(parserRef->refObjects.first(), cacheError.description());
+ }
+ ref.typePropertyCache->addref();
+ }
+
} else if (tref.typeData) {
ref.component = tref.typeData->compiledData();
}
@@ -596,7 +608,7 @@ bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine,
out->types << ref;
}
- Object *root = unit->parser().tree();
+ QDeclarativeParser::Object *root = unit->parser().tree();
Q_ASSERT(root);
this->engine = engine;
@@ -625,7 +637,7 @@ bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine,
return !isError();
}
-void QDeclarativeCompiler::compileTree(Object *tree)
+void QDeclarativeCompiler::compileTree(QDeclarativeParser::Object *tree)
{
compileState.root = tree;
componentStat.lineNumber = tree->location.start.line;
@@ -703,14 +715,14 @@ void QDeclarativeCompiler::compileTree(Object *tree)
enginePrivate->registerCompositeType(output);
}
-static bool ValuePtrLessThan(const Value *t1, const Value *t2)
+static bool ValuePtrLessThan(const QDeclarativeParser::Value *t1, const QDeclarativeParser::Value *t2)
{
return t1->location.start.line < t2->location.start.line ||
(t1->location.start.line == t2->location.start.line &&
t1->location.start.column < t2->location.start.column);
}
-bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt)
+bool QDeclarativeCompiler::buildObject(QDeclarativeParser::Object *obj, const BindingContext &ctxt)
{
componentStat.objects++;
@@ -787,7 +799,7 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt)
defaultProperty->values = obj->defaultProperty->values;
defaultProperty->values += explicitProperty->values;
- foreach(Value *value, defaultProperty->values)
+ foreach(QDeclarativeParser::Value *value, defaultProperty->values)
value->addref();
qSort(defaultProperty->values.begin(), defaultProperty->values.end(), ValuePtrLessThan);
@@ -886,8 +898,7 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt)
void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj)
{
- const QDeclarativeCompiledData::TypeReference &tr =
- output->types.at(obj->type);
+ QDeclarativeCompiledData::TypeReference &tr = output->types[obj->type];
if (tr.type && obj->metatype == &QDeclarativeComponent::staticMetaObject) {
genComponent(obj);
return;
@@ -902,6 +913,7 @@ void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj)
create.line = obj->location.start.line;
create.createSimple.create = output->types.at(obj->type).type->createFunction();
create.createSimple.typeSize = output->types.at(obj->type).type->createSize();
+ create.createSimple.type = obj->type;
create.createSimple.column = obj->location.start.column;
output->bytecode << create;
@@ -935,16 +947,10 @@ void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj)
meta.storeMeta.data = output->indexForByteArray(obj->metadata);
meta.storeMeta.aliasData = output->indexForByteArray(obj->synthdata);
meta.storeMeta.propertyCache = output->propertyCaches.count();
- // ### Surely the creation of this property cache could be more efficient
- QDeclarativePropertyCache *propertyCache = 0;
- if (tr.component)
- propertyCache = tr.component->rootPropertyCache->copy();
- else
- propertyCache = enginePrivate->cache(obj->metaObject()->superClass())->copy();
- propertyCache->append(engine, obj->metaObject(), QDeclarativePropertyCache::Data::NoFlags,
- QDeclarativePropertyCache::Data::IsVMEFunction,
- QDeclarativePropertyCache::Data::IsVMESignal);
+ QDeclarativePropertyCache *propertyCache = obj->synthCache;
+ Q_ASSERT(propertyCache);
+ propertyCache->addref();
// Add flag for alias properties
if (!obj->synthdata.isEmpty()) {
@@ -964,11 +970,7 @@ void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj)
output->propertyCaches << propertyCache;
output->bytecode << meta;
} else if (obj == unitRoot) {
- if (tr.component)
- output->rootPropertyCache = tr.component->rootPropertyCache;
- else
- output->rootPropertyCache = enginePrivate->cache(obj->metaObject());
-
+ output->rootPropertyCache = tr.createPropertyCache(engine);
output->rootPropertyCache->addref();
}
@@ -1103,15 +1105,7 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
meta.line = 0;
meta.storeMeta.data = output->indexForByteArray(prop->value->metadata);
meta.storeMeta.aliasData = output->indexForByteArray(prop->value->synthdata);
- meta.storeMeta.propertyCache = output->propertyCaches.count();
- // ### Surely the creation of this property cache could be more efficient
- QDeclarativePropertyCache *propertyCache =
- enginePrivate->cache(prop->value->metaObject()->superClass())->copy();
- propertyCache->append(engine, prop->value->metaObject(), QDeclarativePropertyCache::Data::NoFlags,
- QDeclarativePropertyCache::Data::IsVMEFunction,
- QDeclarativePropertyCache::Data::IsVMESignal);
-
- output->propertyCaches << propertyCache;
+ meta.storeMeta.propertyCache = -1;
output->bytecode << meta;
}
@@ -1268,7 +1262,7 @@ bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj,
if (!obj->dynamicSlots.isEmpty())
COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new functions."));
- Object *root = 0;
+ QDeclarativeParser::Object *root = 0;
if (obj->defaultProperty && obj->defaultProperty->values.count())
root = obj->defaultProperty->values.first()->object;
@@ -1308,7 +1302,7 @@ bool QDeclarativeCompiler::buildComponentFromRoot(QDeclarativeParser::Object *ob
// Build a sub-object. A sub-object is one that was not created directly by
// QML - such as a grouped property object, or an attached object. Sub-object's
// can't have an id, involve a custom parser, have attached properties etc.
-bool QDeclarativeCompiler::buildSubObject(Object *obj, const BindingContext &ctxt)
+bool QDeclarativeCompiler::buildSubObject(QDeclarativeParser::Object *obj, const BindingContext &ctxt)
{
Q_ASSERT(obj->metatype);
Q_ASSERT(!obj->defaultProperty);
@@ -1351,10 +1345,22 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl
if(name[0] >= 'A' && name[0] <= 'Z')
name[0] = name[0] - 'A' + 'a';
- int sigIdx = QDeclarativePropertyPrivate::findSignalByName(obj->metaObject(), name).methodIndex();
+ bool notInRevision = false;
+ int sigIdx = indexOfSignal(obj, name, &notInRevision);
if (sigIdx == -1) {
+ if (notInRevision && -1 == indexOfProperty(obj, prop->name, 0)) {
+ Q_ASSERT(obj->type != -1);
+ const QList<QDeclarativeTypeData::TypeReference> &resolvedTypes = unit->resolvedTypes();
+ const QDeclarativeTypeData::TypeReference &type = resolvedTypes.at(obj->type);
+ if (type.type) {
+ COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(QString::fromUtf8(obj->className)).arg(QString::fromUtf8(prop->name)).arg(QString::fromUtf8(type.type->module())).arg(type.majorVersion).arg(type.minorVersion));
+ } else {
+ COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available due to component versioning.").arg(QString::fromUtf8(obj->className)).arg(QString::fromUtf8(prop->name)));
+ }
+ }
+
// If the "on<Signal>" name doesn't resolve into a signal, try it as a
// property.
COMPILE_CHECK(buildProperty(prop, obj, ctxt));
@@ -1403,7 +1409,7 @@ bool QDeclarativeCompiler::doesPropertyExist(QDeclarativeParser::Property *prop,
QMetaProperty p = QDeclarativeMetaType::defaultProperty(mo);
return p.name() != 0;
} else {
- int idx = mo->indexOfProperty(prop->name.constData());
+ int idx = indexOfProperty(obj, prop->name);
return idx != -1 && mo->property(idx).isScriptable();
}
}
@@ -1464,7 +1470,17 @@ bool QDeclarativeCompiler::buildProperty(QDeclarativeParser::Property *prop,
}
} else {
- prop->index = metaObject->indexOfProperty(prop->name.constData());
+ bool notInRevision = false;
+ prop->index = indexOfProperty(obj, prop->name, &notInRevision);
+ if (prop->index == -1 && notInRevision) {
+ const QList<QDeclarativeTypeData::TypeReference> &resolvedTypes = unit->resolvedTypes();
+ const QDeclarativeTypeData::TypeReference &type = resolvedTypes.at(obj->type);
+ if (type.type) {
+ COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(QString::fromUtf8(obj->className)).arg(QString::fromUtf8(prop->name)).arg(QString::fromUtf8(type.type->module())).arg(type.majorVersion).arg(type.minorVersion));
+ } else {
+ COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available due to component versioning.").arg(QString::fromUtf8(obj->className)).arg(QString::fromUtf8(prop->name)));
+ }
+ }
if (prop->index != -1) {
p = metaObject->property(prop->index);
@@ -1479,9 +1495,8 @@ bool QDeclarativeCompiler::buildProperty(QDeclarativeParser::Property *prop,
// We can't error here as the "id" property does not require a
// successful index resolution
- if (p.name()) {
+ if (p.name())
prop->type = p.userType();
- }
// Check if this is an alias
if (prop->index != -1 &&
@@ -1600,7 +1615,7 @@ void QDeclarativeCompiler::genListProperty(QDeclarativeParser::Property *prop,
output->bytecode << fetch;
for (int ii = 0; ii < prop->values.count(); ++ii) {
- Value *v = prop->values.at(ii);
+ QDeclarativeParser::Value *v = prop->values.at(ii);
if (v->type == Value::CreatedObject) {
@@ -1888,20 +1903,28 @@ bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
if (prop->values.count() > 1) {
COMPILE_EXCEPTION(prop, tr("Single property assignment expected"));
} else if (prop->values.count()) {
- Value *value = prop->values.at(0);
+ QDeclarativeParser::Value *value = prop->values.at(0);
if (value->object) {
COMPILE_EXCEPTION(prop, tr("Unexpected object assignment"));
} else if (value->value.isScript()) {
// ### Check for writability
- BindingReference reference;
- reference.expression = value->value;
- reference.property = prop;
- reference.value = value;
- reference.bindingContext = ctxt;
- reference.bindingContext.owner++;
- addBindingReference(reference);
- value->type = Value::PropertyBinding;
+
+ //optimization for <Type>.<EnumValue> enum assignments
+ bool isEnumAssignment = false;
+ COMPILE_CHECK(testQualifiedEnumAssignment(p, obj, value, &isEnumAssignment));
+ if (isEnumAssignment) {
+ value->type = Value::Literal;
+ } else {
+ BindingReference reference;
+ reference.expression = value->value;
+ reference.property = prop;
+ reference.value = value;
+ reference.bindingContext = ctxt;
+ reference.bindingContext.owner++;
+ addBindingReference(reference);
+ value->type = Value::PropertyBinding;
+ }
} else {
COMPILE_CHECK(testLiteralAssignment(p, value));
value->type = Value::Literal;
@@ -1909,7 +1932,7 @@ bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
}
for (int ii = 0; ii < prop->onValues.count(); ++ii) {
- Value *v = prop->onValues.at(ii);
+ QDeclarativeParser::Value *v = prop->onValues.at(ii);
Q_ASSERT(v->object);
COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, baseObj, v, ctxt));
@@ -1939,7 +1962,7 @@ bool QDeclarativeCompiler::buildListProperty(QDeclarativeParser::Property *prop,
bool assignedBinding = false;
for (int ii = 0; ii < prop->values.count(); ++ii) {
- Value *v = prop->values.at(ii);
+ QDeclarativeParser::Value *v = prop->values.at(ii);
if (v->object) {
v->type = Value::CreatedObject;
COMPILE_CHECK(buildObject(v->object, ctxt));
@@ -1994,7 +2017,7 @@ bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeParser::Property
COMPILE_EXCEPTION(prop->values.at(0), tr( "Cannot assign multiple values to a singular property") );
for (int ii = 0; ii < prop->values.count(); ++ii) {
- Value *v = prop->values.at(ii);
+ QDeclarativeParser::Value *v = prop->values.at(ii);
if (v->object) {
COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
@@ -2007,7 +2030,7 @@ bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeParser::Property
}
for (int ii = 0; ii < prop->onValues.count(); ++ii) {
- Value *v = prop->onValues.at(ii);
+ QDeclarativeParser::Value *v = prop->onValues.at(ii);
Q_ASSERT(v->object);
COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, obj, v, ctxt));
@@ -2196,7 +2219,15 @@ bool QDeclarativeCompiler::testQualifiedEnumAssignment(const QMetaProperty &prop
QDeclarativeType *type = 0;
unit->imports().resolveType(typeName.toUtf8(), &type, 0, 0, 0, 0);
- if (!type || obj->typeName != type->qmlTypeName())
+ //handle enums on value types (where obj->typeName is empty)
+ QByteArray objTypeName = obj->typeName;
+ if (objTypeName.isEmpty()) {
+ QDeclarativeType *objType = toQmlType(obj);
+ if (objType)
+ objTypeName = objType->qmlTypeName();
+ }
+
+ if (!type || objTypeName != type->qmlTypeName())
return true;
QString enumValue = parts.at(1);
@@ -2246,6 +2277,35 @@ const QMetaObject *QDeclarativeCompiler::resolveType(const QByteArray& name) con
return qmltype->metaObject();
}
+// similar to logic of completeComponentBuild, but also sticks data
+// into datas at the end
+int QDeclarativeCompiler::rewriteBinding(const QString& expression, const QByteArray& name)
+{
+ QDeclarativeRewrite::RewriteBinding rewriteBinding;
+ rewriteBinding.setName('$' + name.mid(name.lastIndexOf('.') + 1));
+ bool isSharable = false;
+ QString rewrite = rewriteBinding(expression, 0, &isSharable);
+
+ quint32 length = rewrite.length();
+ quint32 pc;
+
+ if (isSharable) {
+ pc = output->cachedClosures.count();
+ pc |= 0x80000000;
+ output->cachedClosures.append(0);
+ } else {
+ pc = output->cachedPrograms.length();
+ output->cachedPrograms.append(0);
+ }
+
+ QByteArray compiledData =
+ QByteArray((const char *)&pc, sizeof(quint32)) +
+ QByteArray((const char *)&length, sizeof(quint32)) +
+ QByteArray((const char *)rewrite.constData(),
+ rewrite.length() * sizeof(QChar));
+
+ return output->indexForByteArray(compiledData);
+}
// Ensures that the dynamic meta specification on obj is valid
bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
@@ -2325,7 +2385,7 @@ bool QDeclarativeCompiler::mergeDynamicMetaProperties(QDeclarativeParser::Object
COMPILE_EXCEPTION(property, tr("Invalid property nesting"));
for (int ii = 0; ii < p.defaultValue->values.count(); ++ii) {
- Value *v = p.defaultValue->values.at(ii);
+ QDeclarativeParser::Value *v = p.defaultValue->values.at(ii);
v->addref();
property->values.append(v);
}
@@ -2370,8 +2430,7 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, Dyn
for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
const Object::DynamicProperty &p = obj->dynamicProperties.at(ii);
- int propIdx =
- obj->metaObject()->indexOfProperty(p.name.constData());
+ int propIdx = obj->metaObject()->indexOfProperty(p.name.constData());
if (-1 != propIdx) {
QMetaProperty prop = obj->metaObject()->property(propIdx);
if (prop.isFinal())
@@ -2556,6 +2615,19 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, Dyn
obj->synthdata = dynamicData;
+ if (obj->synthCache) {
+ obj->synthCache->release();
+ obj->synthCache = 0;
+ }
+
+ if (obj->type != -1) {
+ QDeclarativePropertyCache *cache = output->types[obj->type].createPropertyCache(engine)->copy();
+ cache->append(engine, &obj->extObject, QDeclarativePropertyCache::Data::NoFlags,
+ QDeclarativePropertyCache::Data::IsVMEFunction,
+ QDeclarativePropertyCache::Data::IsVMESignal);
+ obj->synthCache = cache;
+ }
+
return true;
}
@@ -2605,9 +2677,9 @@ static QStringList astNodeToStringList(QDeclarativeJS::AST::Node *node)
}
bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder,
- QByteArray &data,
- Object *obj,
- const Object::DynamicProperty &prop)
+ QByteArray &data,
+ QDeclarativeParser::Object *obj,
+ const Object::DynamicProperty &prop)
{
if (!prop.defaultValue)
COMPILE_EXCEPTION(obj, tr("No property alias location"));
@@ -2629,7 +2701,7 @@ bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder,
if (!compileState.ids.contains(alias.at(0)))
COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. Unable to find id \"%1\"").arg(alias.at(0)));
- Object *idObject = compileState.ids[alias.at(0)];
+ QDeclarativeParser::Object *idObject = compileState.ids[alias.at(0)];
QByteArray typeName;
@@ -2637,7 +2709,7 @@ bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder,
int flags = 0;
bool writable = false;
if (alias.count() == 2 || alias.count() == 3) {
- propIdx = idObject->metaObject()->indexOfProperty(alias.at(1).toUtf8().constData());
+ propIdx = indexOfProperty(idObject, alias.at(1).toUtf8());
if (-1 == propIdx) {
COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
@@ -2812,7 +2884,7 @@ bool QDeclarativeCompiler::completeComponentBuild()
componentStat.ids = compileState.ids.count();
for (int ii = 0; ii < compileState.aliasingObjects.count(); ++ii) {
- Object *aliasObject = compileState.aliasingObjects.at(ii);
+ QDeclarativeParser::Object *aliasObject = compileState.aliasingObjects.at(ii);
COMPILE_CHECK(buildDynamicMeta(aliasObject, ResolveAliases));
}
@@ -2849,13 +2921,10 @@ bool QDeclarativeCompiler::completeComponentBuild()
// Pre-rewrite the expression
QString expression = binding.expression.asScript();
- // ### Optimize
- QDeclarativeRewrite::SharedBindingTester sharableTest;
- bool isSharable = sharableTest.isSharable(expression);
-
QDeclarativeRewrite::RewriteBinding rewriteBinding;
rewriteBinding.setName('$'+binding.property->name);
- expression = rewriteBinding(expression);
+ bool isSharable = false;
+ expression = rewriteBinding(binding.expression.asAST(), expression, &isSharable);
quint32 length = expression.length();
quint32 pc;
@@ -2981,4 +3050,74 @@ QStringList QDeclarativeCompiler::deferredProperties(QDeclarativeParser::Object
return rv;
}
+// This code must match the semantics of QDeclarativePropertyPrivate::findSignalByName
+int QDeclarativeCompiler::indexOfSignal(QDeclarativeParser::Object *object, const QByteArray &name,
+ bool *notInRevision)
+{
+ if (notInRevision) *notInRevision = false;
+
+ if (object->synthCache || (object->type != -1 && output->types.at(object->type).propertyCache())) {
+ // XXX fromUtf8
+ QString strName(QString::fromUtf8(name));
+ QDeclarativePropertyCache *cache =
+ object->synthCache?object->synthCache:output->types.at(object->type).propertyCache();
+
+ QDeclarativePropertyCache::Data *d = cache->property(strName);
+ if (notInRevision) *notInRevision = false;
+
+ while (d && !(d->flags & QDeclarativePropertyCache::Data::IsFunction))
+ d = cache->overrideData(d);
+
+ if (d && !cache->isAllowedInRevision(d)) {
+ if (notInRevision) *notInRevision = true;
+ return -1;
+ } else if (d) {
+ return d->coreIndex;
+ }
+
+ if (name.endsWith("Changed")) {
+ QByteArray propName = name.mid(0, name.length() - 7);
+
+ int propIndex = indexOfProperty(object, propName, notInRevision);
+ if (propIndex != -1) {
+ d = cache->property(propIndex);
+ return d->notifyIndex;
+ }
+ }
+
+ return -1;
+ } else {
+ return QDeclarativePropertyPrivate::findSignalByName(object->metaObject(), name).methodIndex();
+ }
+
+}
+
+int QDeclarativeCompiler::indexOfProperty(QDeclarativeParser::Object *object, const QByteArray &name,
+ bool *notInRevision)
+{
+ if (notInRevision) *notInRevision = false;
+
+ if (object->synthCache || (object->type != -1 && output->types.at(object->type).propertyCache())) {
+ // XXX fromUtf8
+ QString strName(QString::fromUtf8(name));
+ QDeclarativePropertyCache *cache =
+ object->synthCache?object->synthCache:output->types.at(object->type).propertyCache();
+
+ QDeclarativePropertyCache::Data *d = cache->property(strName);
+ // Find the first property
+ while (d && d->flags & QDeclarativePropertyCache::Data::IsFunction)
+ d = cache->overrideData(d);
+
+ if (d && !cache->isAllowedInRevision(d)) {
+ if (notInRevision) *notInRevision = true;
+ return -1;
+ } else {
+ return d?d->coreIndex:-1;
+ }
+ } else {
+ const QMetaObject *mo = object->metaObject();
+ return mo->indexOfProperty(name.constData());
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
index 984db81..93b6a09 100644
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -89,14 +89,17 @@ public:
struct TypeReference
{
TypeReference()
- : type(0), component(0) {}
+ : type(0), typePropertyCache(0), component(0) {}
QByteArray className;
QDeclarativeType *type;
+ QDeclarativePropertyCache *typePropertyCache;
QDeclarativeCompiledData *component;
QObject *createInstance(QDeclarativeContextData *, const QBitField &, QList<QDeclarativeError> *) const;
const QMetaObject *metaObject() const;
+ QDeclarativePropertyCache *propertyCache() const;
+ QDeclarativePropertyCache *createPropertyCache(QDeclarativeEngine *);
};
QList<TypeReference> types;
struct CustomTypeData
@@ -161,6 +164,7 @@ public:
int evaluateEnum(const QByteArray& script) const; // for QDeclarativeCustomParser::evaluateEnum
const QMetaObject *resolveType(const QByteArray& name) const; // for QDeclarativeCustomParser::resolveType
+ int rewriteBinding(const QString& expression, const QByteArray& name); // for QDeclarativeCustomParser::rewriteBinding
private:
static void reset(QDeclarativeCompiledData *);
@@ -276,6 +280,8 @@ private:
bool canCoerce(int to, QDeclarativeParser::Object *from);
QStringList deferredProperties(QDeclarativeParser::Object *);
+ int indexOfProperty(QDeclarativeParser::Object *, const QByteArray &, bool *notInRevision = 0);
+ int indexOfSignal(QDeclarativeParser::Object *, const QByteArray &, bool *notInRevision = 0);
void addId(const QString &, QDeclarativeParser::Object *);
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index f716f85..cf40182 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -54,11 +54,13 @@
#include "private/qdeclarativescriptparser_p.h"
#include "private/qdeclarativedebugtrace_p.h"
#include "private/qdeclarativeenginedebug_p.h"
+#include <QtScript/qscriptvalueiterator.h>
#include <QStack>
#include <QStringList>
#include <QtCore/qdebug.h>
#include <QApplication>
+#include <qdeclarativeinfo.h>
QT_BEGIN_NAMESPACE
@@ -613,7 +615,7 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
}
/*!
- \qmlmethod object Component::createObject(Item parent)
+ \qmlmethod object Component::createObject(Item parent, Script valuemap = null)
Creates and returns an object instance of this component that will have the given
\a parent. Returns null if object creation fails.
@@ -631,6 +633,12 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
it is not destroyed by the garbage collector. This is regardless of Item.parent being set afterwards,
since setting the Item parent does not change object ownership; only the graphical parent is changed.
+ Since QtQuick 1.1, a map of property values can be optionally passed to the method that applies values to the object's properties
+ before its creation is finalised. This will avoid binding issues that can occur when the object is
+ instantiated before property bindings have been set. For example:
+
+ \code component.createObject(parent, {"x": 100, "y": 100, "specialProperty": someObject}); \endcode
+
Dynamically created instances can be deleted with the \c destroy() method.
See \l {Dynamic Object Management in QML} for more information.
*/
@@ -646,25 +654,46 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
QScriptValue QDeclarativeComponent::createObject(QObject* parent)
{
Q_D(QDeclarativeComponent);
- QDeclarativeContext* ctxt = creationContext();
- if(!ctxt && d->engine)
- ctxt = d->engine->rootContext();
+ return d->createObject(parent, QScriptValue(QScriptValue::NullValue));
+}
+
+/*!
+ \internal
+ Overloadable method allows properties to be set during creation
+*/
+QScriptValue QDeclarativeComponent::createObject(QObject* parent, const QScriptValue& valuemap)
+{
+ Q_D(QDeclarativeComponent);
+
+ if (!valuemap.isObject() || valuemap.isArray()) {
+ qmlInfo(this) << tr("createObject: value is not an object");
+ return QScriptValue(QScriptValue::NullValue);
+ }
+ return d->createObject(parent, valuemap);
+}
+
+QScriptValue QDeclarativeComponentPrivate::createObject(QObject *publicParent, const QScriptValue valuemap)
+{
+ Q_Q(QDeclarativeComponent);
+ QDeclarativeContext* ctxt = q->creationContext();
+ if(!ctxt && engine)
+ ctxt = engine->rootContext();
if (!ctxt)
return QScriptValue(QScriptValue::NullValue);
- QObject* ret = beginCreate(ctxt);
+ QObject* ret = q->beginCreate(ctxt);
if (!ret) {
- completeCreate();
+ q->completeCreate();
return QScriptValue(QScriptValue::NullValue);
}
- if (parent) {
- ret->setParent(parent);
+ if (publicParent) {
+ ret->setParent(publicParent);
QList<QDeclarativePrivate::AutoParentFunction> functions = QDeclarativeMetaType::parentFunctions();
bool needParent = false;
for (int ii = 0; ii < functions.count(); ++ii) {
- QDeclarativePrivate::AutoParentResult res = functions.at(ii)(ret, parent);
+ QDeclarativePrivate::AutoParentResult res = functions.at(ii)(ret, publicParent);
if (res == QDeclarativePrivate::Parented) {
needParent = false;
break;
@@ -673,14 +702,41 @@ QScriptValue QDeclarativeComponent::createObject(QObject* parent)
}
}
- if (needParent)
+ if (needParent)
qWarning("QDeclarativeComponent: Created graphical object was not placed in the graphics scene.");
}
- completeCreate();
- QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(d->engine);
+ QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(engine);
QDeclarativeData::get(ret, true)->setImplicitDestructible();
- return priv->objectClass->newQObject(ret, QMetaType::QObjectStar);
+ QScriptValue newObject = priv->objectClass->newQObject(ret, QMetaType::QObjectStar);
+
+ if (valuemap.isObject() && !valuemap.isArray()) {
+ //Iterate through and assign properties
+ QScriptValueIterator it(valuemap);
+ while (it.hasNext()) {
+ it.next();
+ QScriptValue prop = newObject;
+ QString propName = it.name();
+ int index = propName.indexOf(QLatin1Char('.'));
+ if (index > 0) {
+ QString subProp = propName;
+ int lastIndex = 0;
+ while (index > 0) {
+ subProp = propName.mid(lastIndex, index - lastIndex);
+ prop = prop.property(subProp);
+ lastIndex = index + 1;
+ index = propName.indexOf(QLatin1Char('.'), index + 1);
+ }
+ prop.setProperty(propName.mid(propName.lastIndexOf(QLatin1Char('.')) + 1), it.value());
+ } else {
+ newObject.setProperty(propName, it.value());
+ }
+ }
+ }
+
+ q->completeCreate();
+
+ return newObject;
}
/*!
@@ -782,8 +838,10 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *parentCon
Q_ASSERT(!isRoot || state); // Either this isn't a root component, or a state data must be provided
Q_ASSERT((state != 0) ^ (errors != 0)); // One of state or errors (but not both) must be provided
- if (isRoot)
+ if (isRoot) {
QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Creating);
+ QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::Creating, component->url);
+ }
QDeclarativeContextData *ctxt = new QDeclarativeContextData;
ctxt->isInternal = true;
@@ -812,7 +870,6 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *parentCon
state->bindValues = enginePriv->bindValues;
state->parserStatus = enginePriv->parserStatus;
- state->finalizedParserStatus = enginePriv->finalizedParserStatus;
state->componentAttached = enginePriv->componentAttached;
if (state->componentAttached)
state->componentAttached->prev = &state->componentAttached;
@@ -820,7 +877,6 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *parentCon
enginePriv->componentAttached = 0;
enginePriv->bindValues.clear();
enginePriv->parserStatus.clear();
- enginePriv->finalizedParserStatus.clear();
state->completePending = true;
enginePriv->inProgressCreations++;
}
@@ -851,7 +907,6 @@ void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeEnginePrivate *engi
state->bindValues = enginePriv->bindValues;
state->parserStatus = enginePriv->parserStatus;
- state->finalizedParserStatus = enginePriv->finalizedParserStatus;
state->componentAttached = enginePriv->componentAttached;
if (state->componentAttached)
state->componentAttached->prev = &state->componentAttached;
@@ -859,7 +914,6 @@ void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeEnginePrivate *engi
enginePriv->componentAttached = 0;
enginePriv->bindValues.clear();
enginePriv->parserStatus.clear();
- enginePriv->finalizedParserStatus.clear();
state->completePending = true;
enginePriv->inProgressCreations++;
}
@@ -897,14 +951,17 @@ void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePri
QDeclarativeEnginePrivate::clear(ps);
}
- for (int ii = 0; ii < state->finalizedParserStatus.count(); ++ii) {
- QPair<QDeclarativeGuard<QObject>, int> status = state->finalizedParserStatus.at(ii);
- QObject *obj = status.first;
- if (obj) {
- void *args[] = { 0 };
- QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod,
- status.second, args);
+ if (1 == enginePriv->inProgressCreations) {
+ for (int ii = 0; ii < enginePriv->finalizedParserStatus.count(); ++ii) {
+ QPair<QDeclarativeGuard<QObject>, int> status = enginePriv->finalizedParserStatus.at(ii);
+ QObject *obj = status.first;
+ if (obj) {
+ void *args[] = { 0 };
+ QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod,
+ status.second, args);
+ }
}
+ enginePriv->finalizedParserStatus.clear();
}
while (state->componentAttached) {
@@ -919,7 +976,6 @@ void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePri
state->bindValues.clear();
state->parserStatus.clear();
- state->finalizedParserStatus.clear();
state->completePending = false;
enginePriv->inProgressCreations--;
@@ -929,7 +985,6 @@ void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePri
enginePriv->erroredBindings->removeError();
}
}
-
}
}
diff --git a/src/declarative/qml/qdeclarativecomponent.h b/src/declarative/qml/qdeclarativecomponent.h
index 6f28f2e..9a60a8b 100644
--- a/src/declarative/qml/qdeclarativecomponent.h
+++ b/src/declarative/qml/qdeclarativecomponent.h
@@ -110,6 +110,7 @@ Q_SIGNALS:
protected:
QDeclarativeComponent(QDeclarativeComponentPrivate &dd, QObject* parent);
Q_INVOKABLE QScriptValue createObject(QObject* parent);
+ Q_INVOKABLE Q_REVISION(1) QScriptValue createObject(QObject* parent, const QScriptValue& valuemap); //XXX Versioning
private:
QDeclarativeComponent(QDeclarativeEngine *, QDeclarativeCompiledData *, int, int, QObject *parent);
diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h
index 02a6ce8..020c5e0 100644
--- a/src/declarative/qml/qdeclarativecomponent_p.h
+++ b/src/declarative/qml/qdeclarativecomponent_p.h
@@ -101,7 +101,6 @@ public:
ConstructionState() : componentAttached(0), completePending(false) {}
QList<QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding> > bindValues;
QList<QDeclarativeEnginePrivate::SimpleList<QDeclarativeParserStatus> > parserStatus;
- QList<QPair<QDeclarativeGuard<QObject>, int> > finalizedParserStatus;
QDeclarativeComponentAttached *componentAttached;
QList<QDeclarativeError> errors;
bool completePending;
@@ -116,6 +115,8 @@ public:
ConstructionState *state);
static void complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state);
+ QScriptValue createObject(QObject *publicParent, const QScriptValue valuemap);
+
QDeclarativeEngine *engine;
QDeclarativeGuardedContextData creationContext;
diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h
index f7d2c62..b7e4c6a 100644
--- a/src/declarative/qml/qdeclarativecontext_p.h
+++ b/src/declarative/qml/qdeclarativecontext_p.h
@@ -77,7 +77,6 @@ class QDeclarativeEngine;
class QDeclarativeExpression;
class QDeclarativeExpressionPrivate;
class QDeclarativeAbstractExpression;
-class QDeclarativeBinding_Id;
class QDeclarativeCompiledBindings;
class QDeclarativeContextData;
diff --git a/src/declarative/qml/qdeclarativecustomparser.cpp b/src/declarative/qml/qdeclarativecustomparser.cpp
index e8ffe3b..856108c 100644
--- a/src/declarative/qml/qdeclarativecustomparser.cpp
+++ b/src/declarative/qml/qdeclarativecustomparser.cpp
@@ -131,7 +131,7 @@ QDeclarativeCustomParserNodePrivate::fromProperty(QDeclarativeParser::Property *
prop.d->values << QVariant::fromValue(props.at(ii));
} else {
for(int ii = 0; ii < p->values.count(); ++ii) {
- Value *v = p->values.at(ii);
+ QDeclarativeParser::Value *v = p->values.at(ii);
v->type = QDeclarativeParser::Value::Literal;
if(v->object) {
@@ -304,5 +304,14 @@ const QMetaObject *QDeclarativeCustomParser::resolveType(const QByteArray& name)
return compiler->resolveType(name);
}
+/*!
+ Rewrites \a expression and returns an identifier that can be
+ used to construct the binding later. \a name
+ is used as the name of the rewritten function.
+*/
+QDeclarativeBinding::Identifier QDeclarativeCustomParser::rewriteBinding(const QString& expression, const QByteArray& name)
+{
+ return compiler->rewriteBinding(expression, name);
+}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h
index 32d85ae..be9f514 100644
--- a/src/declarative/qml/qdeclarativecustomparser_p.h
+++ b/src/declarative/qml/qdeclarativecustomparser_p.h
@@ -56,6 +56,7 @@
#include "private/qdeclarativemetatype_p.h"
#include "qdeclarativeerror.h"
#include "private/qdeclarativeparser_p.h"
+#include "private/qdeclarativebinding_p.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qxmlstream.h>
@@ -140,6 +141,8 @@ protected:
const QMetaObject *resolveType(const QByteArray&) const;
+ QDeclarativeBinding::Identifier rewriteBinding(const QString&, const QByteArray&);
+
private:
QList<QDeclarativeError> exceptions;
QDeclarativeCompiler *compiler;
diff --git a/src/declarative/qml/qdeclarativedom.cpp b/src/declarative/qml/qdeclarativedom.cpp
index 89aa79a..f1296aa 100644
--- a/src/declarative/qml/qdeclarativedom.cpp
+++ b/src/declarative/qml/qdeclarativedom.cpp
@@ -334,10 +334,10 @@ QList<QByteArray> QDeclarativeDomProperty::propertyNameParts() const
Return true if this property is used as a default property in the QML
document.
- \qml
+ \code
<Text text="hello"/>
<Text>hello</Text>
- \endqml
+ \endcode
The above two examples return the same DOM tree, except that the second has
the default property flag set on the text property. Observe that whether
@@ -509,10 +509,10 @@ QByteArray QDeclarativeDomDynamicProperty::propertyTypeName() const
Return true if this property is used as a default property in the QML
document.
- \qml
+ \code
<Text text="hello"/>
<Text>hello</Text>
- \endqml
+ \endcode
The above two examples return the same DOM tree, except that the second has
the default property flag set on the text property. Observe that whether
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 545037f..b7a02f1 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -69,6 +69,8 @@
#include "private/qdeclarativetypenamecache_p.h"
#include "private/qdeclarativeinclude_p.h"
#include "private/qdeclarativenotifier_p.h"
+#include "private/qdeclarativedebugtrace_p.h"
+#include "private/qdeclarativeapplication_p.h"
#include <QtCore/qmetaobject.h>
#include <QScriptClass>
@@ -202,8 +204,9 @@ void QDeclarativeEnginePrivate::defineModule()
\brief The \c Qt object provides useful enums and functions from Qt, for use in all QML files.
-The \c Qt object is not a QML element; it cannot be instantiated. It is a global object
-with enums and functions. To use it, call the members of the global \c Qt object directly.
+The \c Qt object is a global object with utility functions, properties and enums.
+
+It is not instantiable; to use it, call the members of the global \c Qt object directly.
For example:
\qml
@@ -218,8 +221,8 @@ Text {
\section1 Enums
-The Qt object contains enums that declared into Qt's Meta-Object System. For example, you can access
-the \c Leftbutton member of the \c Qt::MouseButton enum with \c Qt.LeftButton.
+The Qt object contains the enums available in the \l {Qt Namespace}. For example, you can access
+the \l Qt::LeftButton and \l Qt::RightButton enum values as \c Qt.LeftButton and \c Qt.RightButton.
\section1 Types
@@ -261,6 +264,57 @@ of their use.
\endlist
*/
+
+/*!
+ \qmlproperty object QML:Qt::application
+ \since QtQuick 1.1
+
+ The \c application object provides access to global application state
+ properties shared by many QML components.
+
+ Its properties are:
+
+ \table
+ \row
+ \o \c application.active
+ \o
+ This read-only property indicates whether the application is the top-most and focused
+ application, and the user is able to interact with the application. The property
+ is false when the application is in the background, the device keylock or screen
+ saver is active, the screen backlight is turned off, or the global system dialog
+ is being displayed on top of the application. It can be used for stopping and
+ pausing animations, timers and active processing of data in order to save device
+ battery power and free device memory and processor load when the application is not
+ active.
+
+ \row
+ \o \c application.layoutDirection
+ \o
+ This read-only property can be used to query the default layout direction of the
+ application. On system start-up, the default layout direction depends on the
+ application's language. The property has a value of \c Qt.RightToLeft in locales
+ where text and graphic elements are read from right to left, and \c Qt.LeftToRight
+ where the reading direction flows from left to right. You can bind to this
+ property to customize your application layouts to support both layout directions.
+
+ Possible values are:
+
+ \list
+ \o Qt.LeftToRight - Text and graphics elements should be positioned
+ from left to right.
+ \o Qt.RightToLeft - Text and graphics elements should be positioned
+ from right to left.
+ \endlist
+ \endtable
+
+ The following example uses the \c application object to indicate
+ whether the application is currently active:
+
+ \snippet doc/src/snippets/declarative/application.qml document
+
+*/
+
+
/*!
\qmlmethod object Qt::include(string url, jsobject callback)
@@ -458,6 +512,8 @@ QDeclarativeEnginePrivate::~QDeclarativeEnginePrivate()
(*iter)->release();
for(QHash<const QMetaObject *, QDeclarativePropertyCache *>::Iterator iter = propertyCache.begin(); iter != propertyCache.end(); ++iter)
(*iter)->release();
+ for(QHash<QPair<QDeclarativeType *, int>, QDeclarativePropertyCache *>::Iterator iter = typePropertyCache.begin(); iter != typePropertyCache.end(); ++iter)
+ (*iter)->release();
}
@@ -520,6 +576,9 @@ void QDeclarativeEnginePrivate::init()
listClass = new QDeclarativeListScriptClass(q);
rootContext = new QDeclarativeContext(q,true);
+ QScriptValue applicationObject = objectClass->newQObject(new QDeclarativeApplication(q));
+ scriptEngine.globalObject().property(QLatin1String("Qt")).setProperty(QLatin1String("application"), applicationObject);
+
if (QCoreApplication::instance()->thread() == q->thread() &&
QDeclarativeEngineDebugServer::isDebuggingEnabled()) {
isDebugging = true;
@@ -717,7 +776,7 @@ void QDeclarativeEngine::addImageProvider(const QString &providerId, QDeclarativ
{
Q_D(QDeclarativeEngine);
QMutexLocker locker(&d->mutex);
- d->imageProviders.insert(providerId, QSharedPointer<QDeclarativeImageProvider>(provider));
+ d->imageProviders.insert(providerId.toLower(), QSharedPointer<QDeclarativeImageProvider>(provider));
}
/*!
@@ -959,7 +1018,14 @@ Q_AUTOTEST_EXPORT void qmlExecuteDeferred(QObject *object)
QDeclarativeData *data = QDeclarativeData::get(object);
if (data && data->deferredComponent) {
-
+ if (QDeclarativeDebugService::isDebuggingEnabled()) {
+ QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Creating);
+ QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject());
+ QString typeName = type ? QLatin1String(type->qmlTypeName()) : QString::fromLatin1(object->metaObject()->className());
+ QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::Creating, typeName);
+ if (data->outerContext)
+ QDeclarativeDebugTrace::rangeLocation(QDeclarativeDebugTrace::Creating, data->outerContext->url, data->lineNumber);
+ }
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(data->context->engine);
QDeclarativeComponentPrivate::ConstructionState state;
@@ -969,6 +1035,7 @@ Q_AUTOTEST_EXPORT void qmlExecuteDeferred(QObject *object)
data->deferredComponent = 0;
QDeclarativeComponentPrivate::complete(ep, &state);
+ QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::Creating);
}
}
@@ -1372,7 +1439,17 @@ QScriptValue QDeclarativeEnginePrivate::vector3d(QScriptContext *ctxt, QScriptEn
/*!
\qmlmethod string Qt::formatDate(datetime date, variant format)
-Returns the string representation of \c date, formatted according to \c format.
+
+Returns a string representation of \c date, optionally formatted according
+to \c format.
+
+The \a date parameter may be a JavaScript \c Date object, a \l{date}{date}
+property, a QDate, or QDateTime value. The \a format parameter may be any of
+the possible format values as described for
+\l{QML:Qt::formatDateTime()}{Qt.formatDateTime()}.
+
+If \a format is not specified, \a date is formatted using
+\l {Qt::DefaultLocaleShortDate}{Qt.DefaultLocaleShortDate}.
*/
#ifndef QT_NO_DATESTRING
QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptEngine*engine)
@@ -1399,9 +1476,16 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE
/*!
\qmlmethod string Qt::formatTime(datetime time, variant format)
-Returns the string representation of \c time, formatted according to \c format.
-See Qt::formatDateTime for how to define \c format.
+Returns a string representation of \c time, optionally formatted according to
+\c format.
+
+The \a time parameter may be a JavaScript \c Date object, a QTime, or QDateTime
+value. The \a format parameter may be any of the possible format values as
+described for \l{QML:Qt::formatDateTime()}{Qt.formatDateTime()}.
+
+If \a format is not specified, \a time is formatted using
+\l {Qt::DefaultLocaleShortDate}{Qt.DefaultLocaleShortDate}.
*/
QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptEngine*engine)
{
@@ -1409,29 +1493,49 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE
if(argCount == 0 || argCount > 2)
return ctxt->throwError(QLatin1String("Qt.formatTime(): Invalid arguments"));
- QTime date = ctxt->argument(0).toDateTime().time();
+ QTime time;
+ QScriptValue sv = ctxt->argument(0);
+ if (sv.isDate())
+ time = sv.toDateTime().time();
+ else if (sv.toVariant().type() == QVariant::Time)
+ time = sv.toVariant().toTime();
+
Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
if (argCount == 2) {
QScriptValue formatArg = ctxt->argument(1);
if (formatArg.isString()) {
QString format = formatArg.toString();
- return engine->newVariant(QVariant::fromValue(date.toString(format)));
+ return engine->newVariant(QVariant::fromValue(time.toString(format)));
} else if (formatArg.isNumber()) {
enumFormat = Qt::DateFormat(formatArg.toUInt32());
} else {
return ctxt->throwError(QLatin1String("Qt.formatTime(): Invalid time format"));
}
}
- return engine->newVariant(QVariant::fromValue(date.toString(enumFormat)));
+ return engine->newVariant(QVariant::fromValue(time.toString(enumFormat)));
}
/*!
\qmlmethod string Qt::formatDateTime(datetime dateTime, variant format)
-Returns the string representation of \c dateTime, formatted according to \c format.
-\c format for the date/time formatting functions is be specified as follows.
+Returns a string representation of \c datetime, optionally formatted according to
+\c format.
+
+The \a date parameter may be a JavaScript \c Date object, a \l{date}{date}
+property, a QDate, QTime, or QDateTime value.
- These expressions may be used for the date:
+If \a format is not provided, \a dateTime is formatted using
+\l {Qt::DefaultLocaleShortDate}{Qt.DefaultLocaleShortDate}. Otherwise,
+\a format should be either.
+
+\list
+\o One of the Qt::DateFormat enumeration values, such as
+ \c Qt.DefaultLocaleShortDate or \c Qt.ISODate
+\o A string that specifies the format of the returned string, as detailed below.
+\endlist
+
+If \a format specifies a format string, it should use the following expressions
+to specify the date:
\table
\header \i Expression \i Output
@@ -1455,7 +1559,7 @@ Returns the string representation of \c dateTime, formatted according to \c form
\row \i yyyy \i the year as four digit number
\endtable
- These expressions may be used for the time:
+In addition the following expressions can be used to specify the time:
\table
\header \i Expression \i Output
@@ -1476,23 +1580,28 @@ Returns the string representation of \c dateTime, formatted according to \c form
\endtable
All other input characters will be ignored. Any sequence of characters that
- are enclosed in singlequotes will be treated as text and not be used as an
- expression. Two consecutive singlequotes ("''") are replaced by a singlequote
+ are enclosed in single quotes will be treated as text and not be used as an
+ expression. Two consecutive single quotes ("''") are replaced by a single quote
in the output.
- Example format strings (assumed that the date and time is 21 May 2001
- 14:13:09):
+For example, if the following date/time value was specified:
+
+ \code
+ // 21 May 2001 14:13:09
+ var dateTime = new Date(2001, 5, 21, 14, 13, 09)
+ \endcode
+
+This \a dateTime value could be passed to \c Qt.formatDateTime(),
+\l {QML:Qt::formatDate()}{Qt.formatDate()} or \l {QML:Qt::formatTime()}{Qt.formatTime()}
+with the \a format values below to produce the following results:
\table
- \header \i Format \i Result
- \row \i dd.MM.yyyy \i 21.05.2001
- \row \i ddd MMMM d yy \i Tue May 21 01
- \row \i hh:mm:ss.zzz \i 14:13:09.042
- \row \i h:m:s ap \i 2:13:9 pm
+ \header \i Format \i Result
+ \row \i "dd.MM.yyyy" \i 21.05.2001
+ \row \i "ddd MMMM d yy" \i Tue May 21 01
+ \row \i "hh:mm:ss.zzz" \i 14:13:09.042
+ \row \i "h:m:s ap" \i 2:13:9 pm
\endtable
-
-If no format is specified the locale's short format is used. Alternatively, you can specify
-\c Qt.DefaultLocaleLongDate to get the locale's long format.
*/
QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScriptEngine*engine)
{
@@ -1872,14 +1981,24 @@ QScriptValue QDeclarativeEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptE
}
/*!
-\qmlmethod color Qt::tint(color baseColor, color tintColor)
+ \qmlmethod color Qt::tint(color baseColor, color tintColor)
This function allows tinting one color with another.
- The tint color should usually be mostly transparent, or you will not be able to see the underlying color. The below example provides a slight red tint by having the tint color be pure red which is only 1/16th opaque.
+ The tint color should usually be mostly transparent, or you will not be
+ able to see the underlying color. The below example provides a slight red
+ tint by having the tint color be pure red which is only 1/16th opaque.
\qml
- Rectangle { x: 0; width: 80; height: 80; color: "lightsteelblue" }
- Rectangle { x: 100; width: 80; height: 80; color: Qt.tint("lightsteelblue", "#10FF0000") }
+ Item {
+ Rectangle {
+ x: 0; width: 80; height: 80
+ color: "lightsteelblue"
+ }
+ Rectangle {
+ x: 100; width: 80; height: 80
+ color: Qt.tint("lightsteelblue", "#10FF0000")
+ }
+ }
\endqml
\image declarative-rect_tint.png
@@ -1994,10 +2113,11 @@ QVariant QDeclarativeEnginePrivate::scriptValueToVariant(const QScriptValue &val
/*!
Adds \a path as a directory where the engine searches for
installed modules in a URL-based directory structure.
+ The \a path may be a local filesystem directory or a URL.
The newly added \a path will be first in the importPathList().
- \sa setImportPathList()
+ \sa setImportPathList(), \l {QML Modules}
*/
void QDeclarativeEngine::addImportPath(const QString& path)
{
@@ -2152,6 +2272,125 @@ static void *voidptr_constructor(const void *v)
}
}
+QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(const QMetaObject *mo)
+{
+ Q_Q(QDeclarativeEngine);
+
+ if (!mo->superClass()) {
+ QDeclarativePropertyCache *rv = new QDeclarativePropertyCache(q, mo);
+ propertyCache.insert(mo, rv);
+ return rv;
+ } else {
+ QDeclarativePropertyCache *super = cache(mo->superClass());
+ QDeclarativePropertyCache *rv = super->copy();
+ rv->append(q, mo);
+ propertyCache.insert(mo, rv);
+ return rv;
+ }
+}
+
+QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(QDeclarativeType *type, int minorVersion,
+ QDeclarativeError &error)
+{
+ QList<QDeclarativeType *> types;
+
+ int maxMinorVersion = 0;
+
+ const QMetaObject *metaObject = type->metaObject();
+ while (metaObject) {
+ QDeclarativeType *t = QDeclarativeMetaType::qmlType(metaObject, type->module(),
+ type->majorVersion(), minorVersion);
+ if (t) {
+ maxMinorVersion = qMax(maxMinorVersion, t->minorVersion());
+ types << t;
+ } else {
+ types << 0;
+ }
+
+ metaObject = metaObject->superClass();
+ }
+
+ if (QDeclarativePropertyCache *c = typePropertyCache.value(qMakePair(type, maxMinorVersion))) {
+ c->addref();
+ typePropertyCache.insert(qMakePair(type, minorVersion), c);
+ return c;
+ }
+
+ QDeclarativePropertyCache *raw = cache(type->metaObject());
+
+ bool hasCopied = false;
+
+ for (int ii = 0; ii < types.count(); ++ii) {
+ QDeclarativeType *currentType = types.at(ii);
+ if (!currentType)
+ continue;
+
+ int rev = currentType->metaObjectRevision();
+ int moIndex = types.count() - 1 - ii;
+
+ if (raw->allowedRevisionCache[moIndex] != rev) {
+ if (!hasCopied) {
+ raw = raw->copy();
+ hasCopied = true;
+ }
+ raw->allowedRevisionCache[moIndex] = rev;
+ }
+ }
+
+ // Test revision compatibility - the basic rule is:
+ // * Anything that is excluded, cannot overload something that is not excluded *
+
+ // Signals override:
+ // * other signals and methods of the same name.
+ // * properties named on<Signal Name>
+ // * automatic <property name>Changed notify signals
+
+ // Methods override:
+ // * other methods of the same name
+
+ // Properties override:
+ // * other elements of the same name
+
+ bool overloadError = false;
+ QString overloadName;
+
+#if 0
+ for (QDeclarativePropertyCache::StringCache::ConstIterator iter = raw->stringCache.begin();
+ !overloadError && iter != raw->stringCache.end();
+ ++iter) {
+
+ QDeclarativePropertyCache::Data *d = *iter;
+ if (raw->isAllowedInRevision(d))
+ continue; // Not excluded - no problems
+
+ // check that a regular "name" overload isn't happening
+ QDeclarativePropertyCache::Data *current = d;
+ while (!overloadError && current) {
+ current = d->overrideData(current);
+ if (current && raw->isAllowedInRevision(current))
+ overloadError = true;
+ }
+ }
+#endif
+
+ 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;
+ }
+
+ if (!hasCopied) raw->addref();
+ typePropertyCache.insert(qMakePair(type, minorVersion), raw);
+
+ if (minorVersion != maxMinorVersion) {
+ raw->addref();
+ typePropertyCache.insert(qMakePair(type, maxMinorVersion), raw);
+ }
+
+ return raw;
+}
+
void QDeclarativeEnginePrivate::registerCompositeType(QDeclarativeCompiledData *data)
{
QByteArray name = data->root->className();
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index fc996b5..88b4e80 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -251,8 +251,12 @@ public:
QDeclarativeValueTypeFactory valueTypes;
QHash<const QMetaObject *, QDeclarativePropertyCache *> propertyCache;
+ QHash<QPair<QDeclarativeType *, int>, QDeclarativePropertyCache *> typePropertyCache;
inline QDeclarativePropertyCache *cache(QObject *obj);
inline QDeclarativePropertyCache *cache(const QMetaObject *);
+ inline QDeclarativePropertyCache *cache(QDeclarativeType *, int, QDeclarativeError &error);
+ QDeclarativePropertyCache *createCache(const QMetaObject *);
+ QDeclarativePropertyCache *createCache(QDeclarativeType *, int, QDeclarativeError &error);
void registerCompositeType(QDeclarativeCompiledData *);
@@ -330,19 +334,17 @@ Returns a QDeclarativePropertyCache for \a obj if one is available.
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)
{
- Q_Q(QDeclarativeEngine);
if (!obj || QObjectPrivate::get(obj)->metaObject || QObjectPrivate::get(obj)->wasDeleted)
return 0;
const QMetaObject *mo = obj->metaObject();
QDeclarativePropertyCache *rv = propertyCache.value(mo);
- if (!rv) {
- rv = new QDeclarativePropertyCache(q, mo);
- propertyCache.insert(mo, rv);
- }
+ if (!rv) rv = createCache(mo);
return rv;
}
@@ -352,18 +354,32 @@ 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
exist for the lifetime of the QDeclarativeEngine.
+
+The returned cache is not referenced, so if it is to be stored, call addref().
*/
QDeclarativePropertyCache *QDeclarativeEnginePrivate::cache(const QMetaObject *metaObject)
{
- Q_Q(QDeclarativeEngine);
Q_ASSERT(metaObject);
QDeclarativePropertyCache *rv = propertyCache.value(metaObject);
- if (!rv) {
- rv = new QDeclarativePropertyCache(q, metaObject);
- propertyCache.insert(metaObject, rv);
- }
+ if (!rv) rv = createCache(metaObject);
+ return rv;
+}
+
+/*!
+Returns a QDeclarativePropertyCache for \a type with \a minorVersion.
+
+The returned cache is not referenced, so if it is to be stored, call addref().
+*/
+QDeclarativePropertyCache *QDeclarativeEnginePrivate::cache(QDeclarativeType *type, int minorVersion, QDeclarativeError &error)
+{
+ Q_ASSERT(type);
+
+ if (minorVersion == -1 || !type->containsRevisionedAttributes())
+ return cache(type->metaObject());
+ QDeclarativePropertyCache *rv = typePropertyCache.value(qMakePair(type, minorVersion));
+ if (!rv) rv = createCache(type, minorVersion, error);
return rv;
}
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index 3dfd0f2..31fd516 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -52,6 +52,7 @@
#include "private/qdeclarativevaluetype_p.h"
#include "private/qdeclarativevmemetaobject_p.h"
#include "private/qdeclarativeexpression_p.h"
+#include "private/qdeclarativepropertychanges_p.h"
#include <QtCore/qdebug.h>
#include <QtCore/qmetaobject.h>
@@ -166,17 +167,19 @@ QDeclarativeEngineDebugServer::propertyData(QObject *obj, int propIdx)
QVariant QDeclarativeEngineDebugServer::valueContents(const QVariant &value) const
{
int userType = value.userType();
- if (QDeclarativeValueTypeFactory::isValueType(userType))
- return value;
- /*
- if (QDeclarativeMetaType::isList(userType)) {
- int count = QDeclarativeMetaType::listCount(value);
+ if (value.type() == QVariant::List) {
QVariantList contents;
- for (int i=0; i<count; i++)
- contents << valueContents(QDeclarativeMetaType::listAt(value, i));
+ QVariantList list = value.toList();
+ int count = list.size();
+ for (int i = 0; i < count; i++)
+ contents << valueContents(list.at(i));
return contents;
- } else */
+ }
+
+ if (QDeclarativeValueTypeFactory::isValueType(userType))
+ return value;
+
if (QDeclarativeMetaType::isQObject(userType)) {
QObject *o = QDeclarativeMetaType::toQObject(value);
if (o) {
@@ -195,11 +198,6 @@ void QDeclarativeEngineDebugServer::buildObjectDump(QDataStream &message,
{
message << objectData(object);
- // Some children aren't added to an object until particular properties are read
- // - e.g. child state objects aren't added until the 'states' property is read -
- // but this should only affect internal objects that aren't shown by the
- // debugger anyway.
-
QObjectList children = object->children();
int childrenCount = children.count();
@@ -260,6 +258,18 @@ void QDeclarativeEngineDebugServer::buildObjectDump(QDataStream &message,
message << fakeProperties[ii];
}
+void QDeclarativeEngineDebugServer::prepareDeferredObjects(QObject *obj)
+{
+ qmlExecuteDeferred(obj);
+
+ QObjectList children = obj->children();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QObject *child = children.at(ii);
+ prepareDeferredObjects(child);
+ }
+
+}
+
void QDeclarativeEngineDebugServer::buildObjectList(QDataStream &message, QDeclarativeContext *ctxt)
{
QDeclarativeContextData *p = QDeclarativeContextData::get(ctxt);
@@ -300,6 +310,35 @@ void QDeclarativeEngineDebugServer::buildObjectList(QDataStream &message, QDecla
}
}
+void QDeclarativeEngineDebugServer::buildStatesList(QDeclarativeContext *ctxt, bool cleanList=false)
+{
+ if (cleanList)
+ m_allStates.clear();
+
+ QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(ctxt);
+ for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) {
+ buildStatesList(ctxtPriv->instances.at(ii));
+ }
+
+ QDeclarativeContextData *child = QDeclarativeContextData::get(ctxt)->childContexts;
+ while (child) {
+ buildStatesList(child->asQDeclarativeContext());
+ child = child->nextChild;
+ }
+}
+
+void QDeclarativeEngineDebugServer::buildStatesList(QObject *obj)
+{
+ if (QDeclarativeState *state = qobject_cast<QDeclarativeState *>(obj)) {
+ m_allStates.append(state);
+ }
+
+ QObjectList children = obj->children();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ buildStatesList(children.at(ii));
+ }
+}
+
QDeclarativeEngineDebugServer::QDeclarativeObjectData
QDeclarativeEngineDebugServer::objectData(QObject *object)
{
@@ -378,8 +417,10 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message)
QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("LIST_OBJECTS_R") << queryId;
- if (engine)
+ if (engine) {
buildObjectList(rs, engine->rootContext());
+ buildStatesList(engine->rootContext(), true);
+ }
sendMessage(reply);
} else if (type == "FETCH_OBJECT") {
@@ -396,8 +437,11 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message)
QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("FETCH_OBJECT_R") << queryId;
- if (object)
+ if (object) {
+ if (recurse)
+ prepareDeferredObjects(object);
buildObjectDump(rs, object, recurse, dumpProperties);
+ }
sendMessage(reply);
} else if (type == "WATCH_OBJECT") {
@@ -499,24 +543,63 @@ void QDeclarativeEngineDebugServer::setBinding(int objectId,
QDeclarativeContext *context = qmlContext(object);
if (object && context) {
-
QDeclarativeProperty property(object, propertyName, context);
- if (isLiteralValue) {
- 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());
- } else if (property.isProperty()) {
- QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context);
- binding->setTarget(property);
- binding->setNotifyOnValueChanged(true);
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding);
- if (oldBinding)
- oldBinding->destroy();
- binding->update();
+ if (property.isValid()) {
+
+ bool inBaseState = true;
+
+ foreach(QWeakPointer<QDeclarativeState> statePointer, m_allStates) {
+ if (QDeclarativeState *state = statePointer.data()) {
+ // here we assume that the revert list on itself defines the base state
+ if (state->isStateActive() && state->containsPropertyInRevertList(object, propertyName)) {
+ inBaseState = false;
+
+ QDeclarativeBinding *newBinding = 0;
+ if (!isLiteralValue) {
+ newBinding = new QDeclarativeBinding(expression.toString(), object, context);
+ newBinding->setTarget(property);
+ newBinding->setNotifyOnValueChanged(true);
+ }
+
+ state->changeBindingInRevertList(object, propertyName, newBinding);
+
+ if (isLiteralValue)
+ state->changeValueInRevertList(object, propertyName, expression);
+ }
+ }
+ }
+
+ if (inBaseState) {
+ if (isLiteralValue) {
+ 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());
+ } else if (property.isProperty()) {
+ QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context);
+ binding->setTarget(property);
+ binding->setNotifyOnValueChanged(true);
+ QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding);
+ if (oldBinding)
+ oldBinding->destroy();
+ binding->update();
+ } else {
+ qWarning() << "QDeclarativeEngineDebugServer::setBinding: unable to set property" << propertyName << "on object" << object;
+ }
+ }
+
} else {
- qWarning() << "QDeclarativeEngineDebugServer::setBinding: unable to set property" << propertyName << "on object" << object;
+ // not a valid property
+ if (QDeclarativePropertyChanges *propertyChanges = qobject_cast<QDeclarativePropertyChanges *>(object)) {
+ if (isLiteralValue) {
+ propertyChanges->changeValue(propertyName, expression);
+ } else {
+ propertyChanges->changeExpression(propertyName, expression.toString());
+ }
+ } else {
+ qWarning() << "QDeclarativeEngineDebugServer::setBinding: unable to set property" << propertyName << "on object" << object;
+ }
}
}
}
@@ -534,11 +617,31 @@ void QDeclarativeEngineDebugServer::resetBinding(int objectId, const QString &pr
QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, 0);
if (oldBinding)
oldBinding->destroy();
+ }
+ if (property.isResettable()) {
+ // Note: this will reset the property in any case, without regard to states
+ // Right now almost no QDeclarativeItem has reset methods for its properties (with the
+ // notable exception of QDeclarativeAnchors), so this is not a big issue
+ // later on, setBinding does take states into account
+ property.reset();
} else {
- if (property.isResettable()) {
- property.reset();
+ // overwrite with default value
+ if (QDeclarativeType *objType = QDeclarativeMetaType::qmlType(object->metaObject())) {
+ if (QObject *emptyObject = objType->create()) {
+ if (emptyObject->property(propertyName.toLatin1()).isValid()) {
+ QVariant defaultValue = QDeclarativeProperty(emptyObject, propertyName).read();
+ if (defaultValue.isValid()) {
+ setBinding(objectId, propertyName, defaultValue, true);
+ }
+ }
+ delete emptyObject;
+ }
}
}
+ } 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 58eb046..e95676c 100644
--- a/src/declarative/qml/qdeclarativeenginedebug_p.h
+++ b/src/declarative/qml/qdeclarativeenginedebug_p.h
@@ -57,6 +57,7 @@
#include <QtCore/qurl.h>
#include <QtCore/qvariant.h>
+#include <QWeakPointer>
QT_BEGIN_NAMESPACE
@@ -64,6 +65,7 @@ class QDeclarativeEngine;
class QDeclarativeContext;
class QDeclarativeWatcher;
class QDataStream;
+class QDeclarativeState;
class QDeclarativeEngineDebugServer : public QDeclarativeDebugService
{
@@ -105,8 +107,11 @@ private Q_SLOTS:
void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value);
private:
+ void prepareDeferredObjects(QObject *);
void buildObjectList(QDataStream &, QDeclarativeContext *);
void buildObjectDump(QDataStream &, QObject *, bool, bool);
+ void buildStatesList(QDeclarativeContext *, bool);
+ void buildStatesList(QObject *obj);
QDeclarativeObjectData objectData(QObject *);
QDeclarativeObjectProperty propertyData(QObject *, int);
QVariant valueContents(const QVariant &defaultValue) const;
@@ -116,6 +121,7 @@ private:
QList<QDeclarativeEngine *> m_engines;
QDeclarativeWatcher *m_watch;
+ QList<QWeakPointer<QDeclarativeState> > m_allStates;
};
Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugServer::QDeclarativeObjectData &);
Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugServer::QDeclarativeObjectData &);
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index 26c91a5..7a85ada 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -103,6 +103,19 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, const QS
expressionFunctionValid = false;
}
+void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, const QScriptValue &func,
+ QObject *me)
+{
+ expression = func.toString();
+
+ QDeclarativeAbstractExpression::setContext(ctxt);
+ scopeObject = me;
+
+ expressionFunction = func;
+ expressionFunctionMode = ExplicitContext;
+ expressionFunctionValid = true;
+}
+
void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, void *expr,
QDeclarativeRefCount *rc,
QObject *me, const QString &srcUrl, int lineNumber)
@@ -304,6 +317,19 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QO
d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
}
+/*! \internal */
+QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QObject *scope, const QScriptValue &func,
+ QDeclarativeExpressionPrivate &dd)
+: QObject(dd, 0)
+{
+ Q_D(QDeclarativeExpression);
+ d->init(ctxt, func, scope);
+
+ if (QDeclarativeExpression_notifyIdx == -1)
+ QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
+ d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
+}
+
/*!
Destroy the QDeclarativeExpression instance.
*/
@@ -412,6 +438,16 @@ void QDeclarativeQtScriptExpression::setNotifyObject(QObject *object, int notify
}
}
+void QDeclarativeQtScriptExpression::setEvaluateFlags(EvaluateFlags flags)
+{
+ evalFlags = flags;
+}
+
+QDeclarativeQtScriptExpression::EvaluateFlags QDeclarativeQtScriptExpression::evaluateFlags() const
+{
+ return evalFlags;
+}
+
QScriptValue QDeclarativeQtScriptExpression::scriptValue(QObject *secondaryScope, bool *isUndefined)
{
Q_ASSERT(context() && context()->engine);
@@ -476,7 +512,10 @@ QScriptValue QDeclarativeQtScriptExpression::eval(QObject *secondaryScope, bool
oldOverride = ep->contextClass->setOverrideObject(expressionContext, secondaryScope);
}
- QScriptValue svalue = expressionFunction.call(); // This could cause this to be deleted
+ QScriptValue thisObject;
+ if (evalFlags & RequiresThisObject)
+ thisObject = ep->objectClass->newQObject(scopeObject);
+ QScriptValue svalue = expressionFunction.call(thisObject); // This could cause this c++ object to be deleted
if (isShared) {
ep->sharedContext = oldSharedContext;
diff --git a/src/declarative/qml/qdeclarativeexpression.h b/src/declarative/qml/qdeclarativeexpression.h
index 72c5947..d40094b 100644
--- a/src/declarative/qml/qdeclarativeexpression.h
+++ b/src/declarative/qml/qdeclarativeexpression.h
@@ -59,6 +59,7 @@ class QDeclarativeEngine;
class QDeclarativeContext;
class QDeclarativeExpressionPrivate;
class QDeclarativeContextData;
+class QScriptValue;
class Q_DECLARATIVE_EXPORT QDeclarativeExpression : public QObject
{
Q_OBJECT
@@ -94,6 +95,8 @@ Q_SIGNALS:
protected:
QDeclarativeExpression(QDeclarativeContextData *, QObject *, const QString &,
QDeclarativeExpressionPrivate &dd);
+ QDeclarativeExpression(QDeclarativeContextData *, QObject *, const QScriptValue &,
+ QDeclarativeExpressionPrivate &dd);
QDeclarativeExpression(QDeclarativeContextData *, void *, QDeclarativeRefCount *rc,
QObject *me, const QString &, int, QDeclarativeExpressionPrivate &dd);
diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h
index 1d25609..51cae0f 100644
--- a/src/declarative/qml/qdeclarativeexpression_p.h
+++ b/src/declarative/qml/qdeclarativeexpression_p.h
@@ -113,6 +113,9 @@ class QDeclarativeQtScriptExpression : public QDeclarativeAbstractExpression,
public:
enum Mode { SharedContext, ExplicitContext };
+ enum EvaluateFlag { RequiresThisObject = 0x01 };
+ Q_DECLARE_FLAGS(EvaluateFlags, EvaluateFlag)
+
QDeclarativeQtScriptExpression();
virtual ~QDeclarativeQtScriptExpression();
@@ -131,6 +134,9 @@ public:
void resetNotifyOnChange();
void setNotifyObject(QObject *, int );
+ void setEvaluateFlags(EvaluateFlags flags);
+ EvaluateFlags evaluateFlags() const;
+
QScriptValue scriptValue(QObject *secondaryScope, bool *isUndefined);
class DeleteWatcher {
@@ -157,8 +163,13 @@ private:
QObject *guardObject;
int guardObjectNotifyIndex;
bool *deleted;
+
+ EvaluateFlags evalFlags;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeQtScriptExpression::EvaluateFlags)
+
+
class QDeclarativeExpression;
class QString;
class QDeclarativeExpressionPrivate : public QObjectPrivate, public QDeclarativeQtScriptExpression
@@ -169,6 +180,7 @@ public:
~QDeclarativeExpressionPrivate();
void init(QDeclarativeContextData *, const QString &, QObject *);
+ void init(QDeclarativeContextData *, const QScriptValue &, QObject *);
void init(QDeclarativeContextData *, void *, QDeclarativeRefCount *, QObject *, const QString &, int);
QVariant value(QObject *secondaryScope = 0, bool *isUndefined = 0);
diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp
index 560077f..f111c20 100644
--- a/src/declarative/qml/qdeclarativeimageprovider.cpp
+++ b/src/declarative/qml/qdeclarativeimageprovider.cpp
@@ -75,6 +75,16 @@ public:
invokes the appropriate image provider according to the providers that have
been registered through QDeclarativeEngine::addImageProvider().
+ Note that the identifiers are case-insensitive, but the rest of the URL will be passed on with
+ preserved case. For example, the below snippet would still specify that the image is loaded by the
+ image provider named "myimageprovider", but it would request a different image than the above snippet
+ ("Image.png" instead of "image.png").
+ \qml
+ Image { source: "image://MyImageProvider/Image.png" }
+ \endqml
+
+ If you want the rest of the URL to be case insensitive, you will have to take care
+ of that yourself inside your image provider.
\section2 An example
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index c89666d..7a1234d 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -425,8 +425,18 @@ QString QDeclarativeImportsPrivate::resolvedUri(const QString &dir_arg, QDeclara
break;
}
}
+
+ stableRelativePath.replace(QLatin1Char('\\'), QLatin1Char('/'));
+
+ // remove optional versioning in dot notation from uri
+ int lastSlash = stableRelativePath.lastIndexOf(QLatin1Char('/'));
+ if (lastSlash >= 0) {
+ int versionDot = stableRelativePath.indexOf(QLatin1Char('.'), lastSlash);
+ if (versionDot >= 0)
+ stableRelativePath = stableRelativePath.left(versionDot);
+ }
+
stableRelativePath.replace(QLatin1Char('/'), QLatin1Char('.'));
- stableRelativePath.replace(QLatin1Char('\\'), QLatin1Char('.'));
return stableRelativePath;
}
@@ -447,42 +457,85 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
}
QString url = uri;
+ bool versionFound = false;
if (importType == QDeclarativeScriptParser::Import::Library) {
url.replace(QLatin1Char('.'), QLatin1Char('/'));
bool found = false;
QString dir;
- foreach (const QString &p, database->fileImportPath) {
- dir = p+QLatin1Char('/')+url;
+ // step 1: search for extension with fully encoded version number
+ if (vmaj >= 0 && vmin >= 0) {
+ foreach (const QString &p, database->fileImportPath) {
+ dir = p+QLatin1Char('/')+url;
- QFileInfo fi(dir+QLatin1String("/qmldir"));
- const QString absoluteFilePath = fi.absoluteFilePath();
+ QFileInfo fi(dir+QString(QLatin1String(".%1.%2")).arg(vmaj).arg(vmin)+QLatin1String("/qmldir"));
+ const QString absoluteFilePath = fi.absoluteFilePath();
- if (fi.isFile()) {
- found = true;
+ if (fi.isFile()) {
+ found = true;
- url = QUrl::fromLocalFile(fi.absolutePath()).toString();
- uri = resolvedUri(dir, database);
- if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, errorString))
- return false;
- break;
+ url = QUrl::fromLocalFile(fi.absolutePath()).toString();
+ uri = resolvedUri(dir, database);
+ if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, errorString))
+ return false;
+ break;
+ }
}
}
+ // step 2: search for extension with encoded version major
+ if (vmaj >= 0 && vmin >= 0) {
+ foreach (const QString &p, database->fileImportPath) {
+ dir = p+QLatin1Char('/')+url;
+
+ QFileInfo fi(dir+QString(QLatin1String(".%1")).arg(vmaj)+QLatin1String("/qmldir"));
+ const QString absoluteFilePath = fi.absoluteFilePath();
+ if (fi.isFile()) {
+ found = true;
+
+ url = QUrl::fromLocalFile(fi.absolutePath()).toString();
+ uri = resolvedUri(dir, database);
+ if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, errorString))
+ return false;
+ break;
+ }
+ }
+ }
if (!found) {
- found = QDeclarativeMetaType::isModule(uri.toUtf8(), vmaj, vmin);
- if (!found) {
- if (errorString) {
- bool anyversion = QDeclarativeMetaType::isModule(uri.toUtf8(), -1, -1);
- if (anyversion)
- *errorString = QDeclarativeImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin);
- else
- *errorString = QDeclarativeImportDatabase::tr("module \"%1\" is not installed").arg(uri_arg);
+ // step 3: search for extension without version number
+
+ foreach (const QString &p, database->fileImportPath) {
+ dir = p+QLatin1Char('/')+url;
+
+ QFileInfo fi(dir+QLatin1String("/qmldir"));
+ const QString absoluteFilePath = fi.absoluteFilePath();
+
+ if (fi.isFile()) {
+ found = true;
+
+ url = QUrl::fromLocalFile(fi.absolutePath()).toString();
+ uri = resolvedUri(dir, database);
+ if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, errorString))
+ return false;
+ break;
}
- return false;
}
}
+
+ if (QDeclarativeMetaType::isModule(uri.toUtf8(), vmaj, vmin))
+ versionFound = true;
+
+ if (!versionFound && qmldircomponents.isEmpty()) {
+ if (errorString) {
+ bool anyversion = QDeclarativeMetaType::isModule(uri.toUtf8(), -1, -1);
+ if (anyversion)
+ *errorString = QDeclarativeImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin);
+ else
+ *errorString = QDeclarativeImportDatabase::tr("module \"%1\" is not installed").arg(uri_arg);
+ }
+ return false;
+ }
} else {
if (importType == QDeclarativeScriptParser::Import::File && qmldircomponents.isEmpty()) {
@@ -526,7 +579,7 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
url.chop(1);
}
- if (vmaj > -1 && vmin > -1 && !qmldircomponents.isEmpty()) {
+ if (!versionFound && vmaj > -1 && vmin > -1 && !qmldircomponents.isEmpty()) {
QList<QDeclarativeDirParser::Component>::ConstIterator it = qmldircomponents.begin();
int lowest_maj = INT_MAX;
int lowest_min = INT_MAX;
@@ -660,6 +713,7 @@ bool QDeclarativeImportedNamespace::find(const QByteArray& type, int *vmajor, in
/*!
\class QDeclarativeImportDatabase
\brief The QDeclarativeImportDatabase class manages the QML imports for a QDeclarativeEngine.
+\internal
*/
QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e)
: engine(e)
@@ -874,23 +928,33 @@ QString QDeclarativeImportDatabase::resolvePlugin(const QDir &qmldirPath, const
#endif
}
+/*!
+ \internal
+*/
QStringList QDeclarativeImportDatabase::pluginPathList() const
{
return filePluginPath;
}
+/*!
+ \internal
+*/
void QDeclarativeImportDatabase::setPluginPathList(const QStringList &paths)
{
filePluginPath = paths;
}
+/*!
+ \internal
+*/
void QDeclarativeImportDatabase::addPluginPath(const QString& path)
{
if (qmlImportTrace())
qDebug().nospace() << "QDeclarativeImportDatabase::addPluginPath: " << path;
QUrl url = QUrl(path);
- if (url.isRelative() || url.scheme() == QLatin1String("file")) {
+ if (url.isRelative() || url.scheme() == QLatin1String("file")
+ || (url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path
QDir dir = QDir(path);
filePluginPath.prepend(dir.canonicalPath());
} else {
@@ -898,6 +962,9 @@ void QDeclarativeImportDatabase::addPluginPath(const QString& path)
}
}
+/*!
+ \internal
+*/
void QDeclarativeImportDatabase::addImportPath(const QString& path)
{
if (qmlImportTrace())
@@ -909,7 +976,8 @@ void QDeclarativeImportDatabase::addImportPath(const QString& path)
QUrl url = QUrl(path);
QString cPath;
- if (url.isRelative() || url.scheme() == QLatin1String("file")) {
+ if (url.isRelative() || url.scheme() == QLatin1String("file")
+ || (url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path
QDir dir = QDir(path);
cPath = dir.canonicalPath();
} else {
@@ -922,17 +990,25 @@ void QDeclarativeImportDatabase::addImportPath(const QString& path)
fileImportPath.prepend(cPath);
}
+/*!
+ \internal
+*/
QStringList QDeclarativeImportDatabase::importPathList() const
{
return fileImportPath;
}
+/*!
+ \internal
+*/
void QDeclarativeImportDatabase::setImportPathList(const QStringList &paths)
{
fileImportPath = paths;
}
-
+/*!
+ \internal
+*/
bool QDeclarativeImportDatabase::importPlugin(const QString &filePath, const QString &uri, QString *errorString)
{
if (qmlImportTrace())
diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h
index 59cce84..20be889 100644
--- a/src/declarative/qml/qdeclarativeinstruction_p.h
+++ b/src/declarative/qml/qdeclarativeinstruction_p.h
@@ -182,6 +182,7 @@ public:
struct CreateSimpleInstruction {
void (*create)(void *);
int typeSize;
+ int type;
ushort column;
};
struct StoreMetaInstruction {
diff --git a/src/declarative/qml/qdeclarativelist.cpp b/src/declarative/qml/qdeclarativelist.cpp
index 9598d98..346fee5 100644
--- a/src/declarative/qml/qdeclarativelist.cpp
+++ b/src/declarative/qml/qdeclarativelist.cpp
@@ -88,6 +88,7 @@ void QDeclarativeListReferencePrivate::release()
/*!
\class QDeclarativeListReference
\since 4.7
+\module QtDeclarative
\brief The QDeclarativeListReference class allows the manipulation of QDeclarativeListProperty properties.
QDeclarativeListReference allows C++ programs to read from, and assign values to a QML list property in a
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
index 27fb2c7..bf1f699 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -134,10 +134,14 @@ public:
bool m_isInterface : 1;
const char *m_iid;
+ QByteArray m_module;
QByteArray m_name;
int m_version_maj;
int m_version_min;
int m_typeId; int m_listId;
+ int m_revision;
+ mutable bool m_containsRevisionedAttributes;
+ mutable QDeclarativeType *m_superType;
int m_allocationSize;
void (*m_newFunc)(void *);
@@ -155,6 +159,7 @@ public:
int m_index;
QDeclarativeCustomParser *m_customParser;
mutable volatile bool m_isSetup:1;
+ mutable bool m_haveSuperType : 1;
mutable QList<QDeclarativeProxyMetaObject::ProxyData> m_metaObjects;
static QHash<const QMetaObject *, int> m_attachedPropertyIds;
@@ -163,10 +168,11 @@ public:
QHash<const QMetaObject *, int> QDeclarativeTypePrivate::m_attachedPropertyIds;
QDeclarativeTypePrivate::QDeclarativeTypePrivate()
-: m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0),
- m_allocationSize(0), m_newFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0), m_attachedPropertiesType(0),
- m_parserStatusCast(-1), m_propertyValueSourceCast(-1), m_propertyValueInterceptorCast(-1),
- m_extFunc(0), m_extMetaObject(0), m_index(-1), m_customParser(0), m_isSetup(false)
+: m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0), m_revision(0), m_containsRevisionedAttributes(false),
+ m_superType(0), m_allocationSize(0), m_newFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0),
+ m_attachedPropertiesType(0), m_parserStatusCast(-1), m_propertyValueSourceCast(-1),
+ m_propertyValueInterceptorCast(-1), m_extFunc(0), m_extMetaObject(0), m_index(-1), m_customParser(0),
+ m_isSetup(false), m_haveSuperType(false)
{
}
@@ -192,9 +198,12 @@ QDeclarativeType::QDeclarativeType(int index, const QDeclarativePrivate::Registe
if (type.uri) name += '/';
name += type.elementName;
+ d->m_module = type.uri;
d->m_name = name;
d->m_version_maj = type.versionMajor;
d->m_version_min = type.versionMinor;
+ if (type.version >= 1) // revisions added in version 1
+ d->m_revision = type.revision;
d->m_typeId = type.typeId;
d->m_listId = type.listId;
d->m_allocationSize = type.objectSize;
@@ -228,6 +237,11 @@ QDeclarativeType::~QDeclarativeType()
delete d;
}
+QByteArray QDeclarativeType::module() const
+{
+ return d->m_module;
+}
+
int QDeclarativeType::majorVersion() const
{
return d->m_version_maj;
@@ -243,6 +257,26 @@ bool QDeclarativeType::availableInVersion(int vmajor, int vminor) const
return vmajor > d->m_version_maj || (vmajor == d->m_version_maj && vminor >= d->m_version_min);
}
+bool QDeclarativeType::availableInVersion(const QByteArray &module, int vmajor, int vminor) const
+{
+ return module == d->m_module && (vmajor > d->m_version_maj || (vmajor == d->m_version_maj && vminor >= d->m_version_min));
+}
+
+// returns the nearest _registered_ super class
+QDeclarativeType *QDeclarativeType::superType() const
+{
+ if (!d->m_haveSuperType) {
+ const QMetaObject *mo = d->m_baseMetaObject->superClass();
+ while (mo && !d->m_superType) {
+ d->m_superType = QDeclarativeMetaType::qmlType(mo, d->m_module, d->m_version_maj, d->m_version_min);
+ mo = mo->superClass();
+ }
+ d->m_haveSuperType = true;
+ }
+
+ return d->m_superType;
+}
+
static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo,
const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd)
{
@@ -356,6 +390,25 @@ void QDeclarativeTypePrivate::init() const
m_metaObjects[ii].methodOffset =
m_metaObjects.at(ii).metaObject->methodOffset();
}
+
+ // Check for revisioned details
+ {
+ const QMetaObject *mo = 0;
+ if (m_metaObjects.isEmpty())
+ mo = m_baseMetaObject;
+ else
+ mo = m_metaObjects.first().metaObject;
+
+ for (int ii = 0; !m_containsRevisionedAttributes && ii < mo->propertyCount(); ++ii) {
+ if (mo->property(ii).revision() != 0)
+ m_containsRevisionedAttributes = true;
+ }
+
+ for (int ii = 0; !m_containsRevisionedAttributes && ii < mo->methodCount(); ++ii) {
+ if (mo->method(ii).revision() != 0)
+ m_containsRevisionedAttributes = true;
+ }
+ }
m_isSetup = true;
lock.unlock();
@@ -464,6 +517,18 @@ const QMetaObject *QDeclarativeType::baseMetaObject() const
return d->m_baseMetaObject;
}
+bool QDeclarativeType::containsRevisionedAttributes() const
+{
+ d->init();
+
+ return d->m_containsRevisionedAttributes;
+}
+
+int QDeclarativeType::metaObjectRevision() const
+{
+ return d->m_revision;
+}
+
QDeclarativeAttachedPropertiesFunc QDeclarativeType::attachedPropertiesFunction() const
{
return d->m_attachedPropertiesFunc;
@@ -572,7 +637,7 @@ int registerType(const QDeclarativePrivate::RegisterType &type)
if (!dtype->qmlTypeName().isEmpty())
data->nameToType.insertMulti(dtype->qmlTypeName(), dtype);
- data->metaObjectToType.insert(dtype->baseMetaObject(), dtype);
+ data->metaObjectToType.insertMulti(dtype->baseMetaObject(), dtype);
if (data->objects.size() <= type.typeId)
data->objects.resize(type.typeId + 16);
@@ -862,6 +927,27 @@ QDeclarativeType *QDeclarativeMetaType::qmlType(const QMetaObject *metaObject)
}
/*!
+ Returns the type (if any) that corresponds to the \a metaObject in version specified
+ by \a version_major and \a version_minor in module specified by \a uri. Returns null if no
+ type is registered.
+*/
+QDeclarativeType *QDeclarativeMetaType::qmlType(const QMetaObject *metaObject, const QByteArray &module, int version_major, int version_minor)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+
+ QDeclarativeMetaTypeData::MetaObjects::const_iterator it = data->metaObjectToType.find(metaObject);
+ while (it != data->metaObjectToType.end() && it.key() == metaObject) {
+ QDeclarativeType *t = *it;
+ if (version_major < 0 || t->availableInVersion(module, version_major,version_minor))
+ return t;
+ ++it;
+ }
+
+ return 0;
+}
+
+/*!
Returns the type (if any) that corresponds to the QVariant::Type \a userType.
Returns null if no type is registered.
*/
@@ -929,6 +1015,93 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QScriptValue);
QT_BEGIN_NAMESPACE
+
+bool QDeclarativeMetaType::canCopy(int type)
+{
+ switch(type) {
+ case QMetaType::VoidStar:
+ case QMetaType::QObjectStar:
+ case QMetaType::QWidgetStar:
+ case QMetaType::Long:
+ case QMetaType::Int:
+ case QMetaType::Short:
+ case QMetaType::Char:
+ case QMetaType::ULong:
+ case QMetaType::UInt:
+ case QMetaType::LongLong:
+ case QMetaType::ULongLong:
+ case QMetaType::UShort:
+ case QMetaType::UChar:
+ case QMetaType::Bool:
+ case QMetaType::Float:
+ case QMetaType::Double:
+ case QMetaType::QChar:
+ case QMetaType::QVariantMap:
+ case QMetaType::QVariantHash:
+ case QMetaType::QVariantList:
+ case QMetaType::QByteArray:
+ case QMetaType::QString:
+ case QMetaType::QStringList:
+ case QMetaType::QBitArray:
+ case QMetaType::QDate:
+ case QMetaType::QTime:
+ case QMetaType::QDateTime:
+ case QMetaType::QUrl:
+ case QMetaType::QLocale:
+ case QMetaType::QRect:
+ case QMetaType::QRectF:
+ case QMetaType::QSize:
+ case QMetaType::QSizeF:
+ case QMetaType::QLine:
+ case QMetaType::QLineF:
+ case QMetaType::QPoint:
+ case QMetaType::QPointF:
+ case QMetaType::QVector3D:
+#ifndef QT_NO_REGEXP
+ case QMetaType::QRegExp:
+#endif
+ case QMetaType::Void:
+#ifdef QT3_SUPPORT
+ case QMetaType::QColorGroup:
+#endif
+ case QMetaType::QFont:
+ case QMetaType::QPixmap:
+ case QMetaType::QBrush:
+ case QMetaType::QColor:
+ case QMetaType::QPalette:
+ case QMetaType::QIcon:
+ case QMetaType::QImage:
+ case QMetaType::QPolygon:
+ case QMetaType::QRegion:
+ case QMetaType::QBitmap:
+#ifndef QT_NO_CURSOR
+ case QMetaType::QCursor:
+#endif
+ case QMetaType::QSizePolicy:
+ case QMetaType::QKeySequence:
+ case QMetaType::QPen:
+ case QMetaType::QTextLength:
+ case QMetaType::QTextFormat:
+ case QMetaType::QMatrix:
+ case QMetaType::QTransform:
+ case QMetaType::QMatrix4x4:
+ case QMetaType::QVector2D:
+ case QMetaType::QVector4D:
+ case QMetaType::QQuaternion:
+ return true;
+
+ default:
+ if (type == qMetaTypeId<QVariant>() ||
+ type == qMetaTypeId<QScriptValue>() ||
+ typeCategory(type) != Unknown) {
+ return true;
+ }
+ break;
+ }
+
+ return false;
+}
+
/*!
Copies \a copy into \a data, assuming they both are of type \a type. If
\a copy is zero, a default type is copied. Returns true if the copy was
diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h
index 4e84ee8..aab1c31 100644
--- a/src/declarative/qml/qdeclarativemetatype_p.h
+++ b/src/declarative/qml/qdeclarativemetatype_p.h
@@ -69,6 +69,7 @@ class QDeclarativeTypePrivate;
class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeMetaType
{
public:
+ static bool canCopy(int type);
static bool copy(int type, void *data, const void *copy = 0);
static QList<QByteArray> qmlTypeNames();
@@ -76,6 +77,7 @@ public:
static QDeclarativeType *qmlType(const QByteArray &, int, int);
static QDeclarativeType *qmlType(const QMetaObject *);
+ static QDeclarativeType *qmlType(const QMetaObject *metaObject, const QByteArray &module, int version_major, int version_minor);
static QDeclarativeType *qmlType(int);
static QMetaProperty defaultProperty(const QMetaObject *);
@@ -112,9 +114,12 @@ public:
QByteArray typeName() const;
QByteArray qmlTypeName() const;
+ QByteArray module() const;
int majorVersion() const;
int minorVersion() const;
+
bool availableInVersion(int vmajor, int vminor) const;
+ bool availableInVersion(const QByteArray &module, int vmajor, int vminor) const;
QObject *create() const;
void create(QObject **, void **, size_t) const;
@@ -135,6 +140,8 @@ public:
const QMetaObject *metaObject() const;
const QMetaObject *baseMetaObject() const;
+ int metaObjectRevision() const;
+ bool containsRevisionedAttributes() const;
QDeclarativeAttachedPropertiesFunc attachedPropertiesFunction() const;
const QMetaObject *attachedPropertiesType() const;
@@ -149,6 +156,7 @@ public:
int index() const;
private:
+ QDeclarativeType *superType() const;
friend class QDeclarativeTypePrivate;
friend struct QDeclarativeMetaTypeData;
friend int registerType(const QDeclarativePrivate::RegisterType &);
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index eea928c..dc3ecca 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -149,8 +149,8 @@ QDeclarativeObjectScriptClass::queryProperty(Object *object, const Identifier &n
QScriptClass::QueryFlags
QDeclarativeObjectScriptClass::queryProperty(QObject *obj, const Identifier &name,
- QScriptClass::QueryFlags flags, QDeclarativeContextData *evalContext,
- QueryHints hints)
+ QScriptClass::QueryFlags flags, QDeclarativeContextData *evalContext,
+ QueryHints hints)
{
Q_UNUSED(flags);
lastData = 0;
@@ -165,6 +165,12 @@ QDeclarativeObjectScriptClass::queryProperty(QObject *obj, const Identifier &nam
QDeclarativeEnginePrivate *enginePrivate = QDeclarativeEnginePrivate::get(engine);
lastData = QDeclarativePropertyCache::property(engine, obj, name, local);
+ if ((hints & ImplicitObject) && lastData && lastData->revision != 0) {
+
+ QDeclarativeData *ddata = QDeclarativeData::get(obj);
+ if (ddata && ddata->propertyCache && !ddata->propertyCache->isAllowedInRevision(lastData))
+ return 0;
+ }
if (lastData)
return QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess;
@@ -354,8 +360,20 @@ void QDeclarativeObjectScriptClass::setProperty(QObject *obj,
}
}
+ QDeclarativeBinding *newBinding = 0;
+ if (value.isFunction() && !value.isRegExp()) {
+ QScriptContextInfo ctxtInfo(context);
+ QDeclarativePropertyCache::ValueTypeData valueTypeData;
+
+ newBinding = new QDeclarativeBinding(value, obj, evalContext);
+ newBinding->setSourceLocation(ctxtInfo.fileName(), ctxtInfo.functionStartLineNumber());
+ newBinding->setTarget(QDeclarativePropertyPrivate::restore(*lastData, valueTypeData, obj, evalContext));
+ if (newBinding->expression().contains(QLatin1String("this")))
+ newBinding->setEvaluateFlags(newBinding->evaluateFlags() | QDeclarativeBinding::RequiresThisObject);
+ }
+
QDeclarativeAbstractBinding *delBinding =
- QDeclarativePropertyPrivate::setBinding(obj, lastData->coreIndex, -1, 0);
+ QDeclarativePropertyPrivate::setBinding(obj, lastData->coreIndex, -1, newBinding);
if (delBinding)
delBinding->destroy();
@@ -374,9 +392,8 @@ void QDeclarativeObjectScriptClass::setProperty(QObject *obj,
QString error = QLatin1String("Cannot assign [undefined] to ") +
QLatin1String(QMetaType::typeName(lastData->propType));
context->throwError(error);
- } else if (!value.isRegExp() && value.isFunction()) {
- QString error = QLatin1String("Cannot assign a function to a property.");
- context->throwError(error);
+ } else if (value.isFunction() && !value.isRegExp()) {
+ // this is handled by the binding creation above
} else {
QVariant v;
if (lastData->flags & QDeclarativePropertyCache::Data::IsQList)
diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp
index da4016e..d5b9424 100644
--- a/src/declarative/qml/qdeclarativeparser.cpp
+++ b/src/declarative/qml/qdeclarativeparser.cpp
@@ -66,13 +66,14 @@ using namespace QDeclarativeJS;
using namespace QDeclarativeParser;
QDeclarativeParser::Object::Object()
-: type(-1), majorVersion(-1), minorVersion(-1), idIndex(-1), metatype(0), defaultProperty(0), parserStatusCast(-1)
+: type(-1), majorVersion(-1), minorVersion(-1), idIndex(-1), metatype(0), synthCache(0), defaultProperty(0), parserStatusCast(-1)
{
}
QDeclarativeParser::Object::~Object()
{
if (defaultProperty) defaultProperty->release();
+ if (synthCache) synthCache->release();
foreach(Property *prop, properties)
prop->release();
foreach(Property *prop, valueProperties)
@@ -224,9 +225,9 @@ QDeclarativeParser::Property::~Property()
if (value) value->release();
}
-Object *QDeclarativeParser::Property::getValue(const LocationSpan &l)
+QDeclarativeParser::Object *QDeclarativeParser::Property::getValue(const LocationSpan &l)
{
- if (!value) { value = new Object; value->location = l; }
+ if (!value) { value = new QDeclarativeParser::Object; value->location = l; }
return value;
}
diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h
index 6ef2811..8f41a91 100644
--- a/src/declarative/qml/qdeclarativeparser_p.h
+++ b/src/declarative/qml/qdeclarativeparser_p.h
@@ -71,6 +71,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+class QDeclarativePropertyCache;
namespace QDeclarativeJS { namespace AST { class Node; } }
/*
@@ -154,6 +155,7 @@ namespace QDeclarativeParser
QAbstractDynamicMetaObject extObject;
QByteArray metadata; // Generated by compiler
QByteArray synthdata; // Generated by compiler
+ QDeclarativePropertyCache *synthCache; // Generated by compiler
Property *getDefaultProperty();
Property *getProperty(const QByteArray &name, bool create=true);
diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h
index 6e73ec9..7ac3369 100644
--- a/src/declarative/qml/qdeclarativeprivate.h
+++ b/src/declarative/qml/qdeclarativeprivate.h
@@ -214,6 +214,8 @@ namespace QDeclarativePrivate
const QMetaObject *extensionMetaObject;
QDeclarativeCustomParser *customParser;
+ int revision;
+ // If this is extended ensure "version" is bumped!!!
};
struct RegisterInterface {
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
index 8210314..0dd0edb 100644
--- a/src/declarative/qml/qdeclarativeproperty.cpp
+++ b/src/declarative/qml/qdeclarativeproperty.cpp
@@ -106,15 +106,16 @@ qWarning() << "Pixel size should now be 24:" << property.read().toInt();
Create an invalid QDeclarativeProperty.
*/
QDeclarativeProperty::QDeclarativeProperty()
-: d(new QDeclarativePropertyPrivate)
+: d(0)
{
- d->q = this;
}
/*! \internal */
QDeclarativeProperty::~QDeclarativeProperty()
{
- delete d; d = 0;
+ if (d)
+ d->release();
+ d = 0;
}
/*!
@@ -124,7 +125,6 @@ QDeclarativeProperty::~QDeclarativeProperty()
QDeclarativeProperty::QDeclarativeProperty(QObject *obj)
: d(new QDeclarativePropertyPrivate)
{
- d->q = this;
d->initDefault(obj);
}
@@ -137,7 +137,6 @@ QDeclarativeProperty::QDeclarativeProperty(QObject *obj)
QDeclarativeProperty::QDeclarativeProperty(QObject *obj, QDeclarativeContext *ctxt)
: d(new QDeclarativePropertyPrivate)
{
- d->q = this;
d->context = ctxt?QDeclarativeContextData::get(ctxt):0;
d->engine = ctxt?ctxt->engine():0;
d->initDefault(obj);
@@ -152,7 +151,6 @@ QDeclarativeProperty::QDeclarativeProperty(QObject *obj, QDeclarativeContext *ct
QDeclarativeProperty::QDeclarativeProperty(QObject *obj, QDeclarativeEngine *engine)
: d(new QDeclarativePropertyPrivate)
{
- d->q = this;
d->context = 0;
d->engine = engine;
d->initDefault(obj);
@@ -178,7 +176,6 @@ void QDeclarativePropertyPrivate::initDefault(QObject *obj)
QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name)
: d(new QDeclarativePropertyPrivate)
{
- d->q = this;
d->initProperty(obj, name);
if (!isValid()) d->object = 0;
}
@@ -190,7 +187,6 @@ QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name)
QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QDeclarativeContext *ctxt)
: d(new QDeclarativePropertyPrivate)
{
- d->q = this;
d->context = ctxt?QDeclarativeContextData::get(ctxt):0;
d->engine = ctxt?ctxt->engine():0;
d->initProperty(obj, name);
@@ -205,7 +201,6 @@ QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QD
QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QDeclarativeEngine *engine)
: d(new QDeclarativePropertyPrivate)
{
- d->q = this;
d->context = 0;
d->engine = engine;
d->initProperty(obj, name);
@@ -315,6 +310,8 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name
if (property && !(property->flags & QDeclarativePropertyCache::Data::IsFunction)) {
object = currentObject;
core = *property;
+ nameCache = terminal;
+ isNameCached = true;
}
}
@@ -322,9 +319,10 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name
Create a copy of \a other.
*/
QDeclarativeProperty::QDeclarativeProperty(const QDeclarativeProperty &other)
-: d(new QDeclarativePropertyPrivate(*other.d))
{
- d->q = this;
+ d = other.d;
+ if (d)
+ d->addref();
}
/*!
@@ -353,13 +351,13 @@ QDeclarativeProperty::QDeclarativeProperty(const QDeclarativeProperty &other)
*/
QDeclarativeProperty::PropertyTypeCategory QDeclarativeProperty::propertyTypeCategory() const
{
- return d->propertyTypeCategory();
+ return d ? d->propertyTypeCategory() : InvalidCategory;
}
QDeclarativeProperty::PropertyTypeCategory
QDeclarativePropertyPrivate::propertyTypeCategory() const
{
- uint type = q->type();
+ uint type = this->type();
if (isValueType()) {
return QDeclarativeProperty::Normal;
@@ -386,6 +384,8 @@ QDeclarativePropertyPrivate::propertyTypeCategory() const
*/
const char *QDeclarativeProperty::propertyTypeName() const
{
+ if (!d)
+ return 0;
if (d->isValueType()) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(d->context);
@@ -412,6 +412,8 @@ const char *QDeclarativeProperty::propertyTypeName() const
*/
bool QDeclarativeProperty::operator==(const QDeclarativeProperty &other) const
{
+ if (!d || !other.d)
+ return false;
// category is intentially omitted here as it is generated
// from the other members
return d->object == other.d->object &&
@@ -425,7 +427,7 @@ bool QDeclarativeProperty::operator==(const QDeclarativeProperty &other) const
*/
int QDeclarativeProperty::propertyType() const
{
- return d->propertyType();
+ return d ? d->propertyType() : int(QVariant::Invalid);
}
bool QDeclarativePropertyPrivate::isValueType() const
@@ -435,7 +437,7 @@ bool QDeclarativePropertyPrivate::isValueType() const
int QDeclarativePropertyPrivate::propertyType() const
{
- uint type = q->type();
+ uint type = this->type();
if (isValueType()) {
return valueType.valueTypePropType;
} else if (type & QDeclarativeProperty::Property) {
@@ -448,17 +450,22 @@ int QDeclarativePropertyPrivate::propertyType() const
}
}
+QDeclarativeProperty::Type QDeclarativePropertyPrivate::type() const
+{
+ if (core.flags & QDeclarativePropertyCache::Data::IsFunction)
+ return QDeclarativeProperty::SignalProperty;
+ else if (core.isValid())
+ return QDeclarativeProperty::Property;
+ else
+ return QDeclarativeProperty::Invalid;
+}
+
/*!
Returns the type of the property.
*/
QDeclarativeProperty::Type QDeclarativeProperty::type() const
{
- if (d->core.flags & QDeclarativePropertyCache::Data::IsFunction)
- return SignalProperty;
- else if (d->core.isValid())
- return Property;
- else
- return Invalid;
+ return d ? d->type() : Invalid;
}
/*!
@@ -482,7 +489,7 @@ bool QDeclarativeProperty::isSignalProperty() const
*/
QObject *QDeclarativeProperty::object() const
{
- return d->object;
+ return d ? d->object : 0;
}
/*!
@@ -490,15 +497,11 @@ QObject *QDeclarativeProperty::object() const
*/
QDeclarativeProperty &QDeclarativeProperty::operator=(const QDeclarativeProperty &other)
{
- d->context = other.d->context;
- d->engine = other.d->engine;
- d->object = other.d->object;
-
- d->isNameCached = other.d->isNameCached;
- d->core = other.d->core;
- d->nameCache = other.d->nameCache;
-
- d->valueType = other.d->valueType;
+ if (d)
+ d->release();
+ d = other.d;
+ if (d)
+ d->addref();
return *this;
}
@@ -508,6 +511,8 @@ QDeclarativeProperty &QDeclarativeProperty::operator=(const QDeclarativeProperty
*/
bool QDeclarativeProperty::isWritable() const
{
+ if (!d)
+ return false;
if (!d->object)
return false;
if (d->core.flags & QDeclarativePropertyCache::Data::IsQList) //list
@@ -525,6 +530,8 @@ bool QDeclarativeProperty::isWritable() const
*/
bool QDeclarativeProperty::isDesignable() const
{
+ if (!d)
+ return false;
if (type() & Property && d->core.isValid() && d->object)
return d->object->metaObject()->property(d->core.coreIndex).isDesignable();
else
@@ -536,6 +543,8 @@ bool QDeclarativeProperty::isDesignable() const
*/
bool QDeclarativeProperty::isResettable() const
{
+ if (!d)
+ return false;
if (type() & Property && d->core.isValid() && d->object)
return d->core.flags & QDeclarativePropertyCache::Data::IsResettable;
else
@@ -548,6 +557,8 @@ bool QDeclarativeProperty::isResettable() const
*/
bool QDeclarativeProperty::isValid() const
{
+ if (!d)
+ return false;
return type() != Invalid;
}
@@ -556,6 +567,8 @@ bool QDeclarativeProperty::isValid() const
*/
QString QDeclarativeProperty::name() const
{
+ if (!d)
+ return QString();
if (!d->isNameCached) {
// ###
if (!d->object) {
@@ -592,6 +605,8 @@ QString QDeclarativeProperty::name() const
*/
QMetaProperty QDeclarativeProperty::property() const
{
+ if (!d)
+ return QMetaProperty();
if (type() & Property && d->core.isValid() && d->object)
return d->object->metaObject()->property(d->core.coreIndex);
else
@@ -604,6 +619,8 @@ QMetaProperty QDeclarativeProperty::property() const
*/
QMetaMethod QDeclarativeProperty::method() const
{
+ if (!d)
+ return QMetaMethod();
if (type() & SignalProperty && d->object)
return d->object->metaObject()->method(d->core.coreIndex);
else
@@ -617,7 +634,7 @@ QMetaMethod QDeclarativeProperty::method() const
QDeclarativeAbstractBinding *
QDeclarativePropertyPrivate::binding(const QDeclarativeProperty &that)
{
- if (!that.isProperty() || !that.d->object)
+ if (!that.d || !that.isProperty() || !that.d->object)
return 0;
return binding(that.d->object, that.d->core.coreIndex, that.d->valueType.valueTypeCoreIdx);
@@ -641,7 +658,7 @@ QDeclarativePropertyPrivate::setBinding(const QDeclarativeProperty &that,
QDeclarativeAbstractBinding *newBinding,
WriteFlags flags)
{
- if (!that.isProperty() || !that.d->object) {
+ if (!that.d || !that.isProperty() || !that.d->object) {
if (newBinding)
newBinding->destroy();
return 0;
@@ -891,6 +908,8 @@ QDeclarativePropertyPrivate::setSignalExpression(const QDeclarativeProperty &tha
*/
QVariant QDeclarativeProperty::read() const
{
+ if (!d)
+ return QVariant();
if (!d->object)
return QVariant();
@@ -1032,8 +1051,10 @@ bool QDeclarativePropertyPrivate::writeEnumProperty(const QMetaProperty &prop, i
bool QDeclarativePropertyPrivate::writeValueProperty(const QVariant &value, WriteFlags flags)
{
// Remove any existing bindings on this property
- if (!(flags & DontRemoveBinding)) {
- QDeclarativeAbstractBinding *binding = setBinding(*q, 0);
+ if (!(flags & DontRemoveBinding) &&
+ (type() & QDeclarativeProperty::Property) && object) {
+ QDeclarativeAbstractBinding *binding = setBinding(object, core.coreIndex,
+ valueType.valueTypeCoreIdx, 0, flags);
if (binding) binding->destroy();
}
@@ -1312,6 +1333,8 @@ bool QDeclarativeProperty::reset() const
bool QDeclarativePropertyPrivate::write(const QDeclarativeProperty &that,
const QVariant &value, WriteFlags flags)
{
+ if (!that.d)
+ return false;
if (that.d->object && that.type() & QDeclarativeProperty::Property &&
that.d->core.isValid() && that.isWritable())
return that.d->writeValueProperty(value, flags);
@@ -1390,12 +1413,12 @@ bool QDeclarativeProperty::connectNotifySignal(QObject *dest, const char *slot)
*/
int QDeclarativeProperty::index() const
{
- return d->core.coreIndex;
+ return d ? d->core.coreIndex : -1;
}
int QDeclarativePropertyPrivate::valueTypeCoreIndex(const QDeclarativeProperty &that)
{
- return that.d->valueType.valueTypeCoreIdx;
+ return that.d ? that.d->valueType.valueTypeCoreIdx : -1;
}
/*!
@@ -1404,6 +1427,8 @@ int QDeclarativePropertyPrivate::valueTypeCoreIndex(const QDeclarativeProperty &
*/
int QDeclarativePropertyPrivate::bindingIndex(const QDeclarativeProperty &that)
{
+ if (!that.d)
+ return -1;
int rv = that.d->core.coreIndex;
if (rv != -1 && that.d->valueType.valueTypeCoreIdx != -1)
rv = rv | (that.d->valueType.valueTypeCoreIdx << 24);
@@ -1455,18 +1480,28 @@ QDeclarativePropertyPrivate::restore(const QByteArray &data, QObject *object, QD
if (data.isEmpty())
return prop;
- prop.d->object = object;
- prop.d->context = ctxt;
- prop.d->engine = ctxt->engine;
-
const SerializedData *sd = (const SerializedData *)data.constData();
if (sd->isValueType) {
const ValueTypeSerializedData *vt = (const ValueTypeSerializedData *)sd;
- prop.d->core = vt->core;
- prop.d->valueType = vt->valueType;
+ return restore(vt->core, vt->valueType, object, ctxt);
} else {
- prop.d->core = sd->core;
+ QDeclarativePropertyCache::ValueTypeData data;
+ return restore(sd->core, data, object, ctxt);
}
+}
+
+QDeclarativeProperty
+QDeclarativePropertyPrivate::restore(const QDeclarativePropertyCache::Data &data, const QDeclarativePropertyCache::ValueTypeData &valueType, QObject *object, QDeclarativeContextData *ctxt)
+{
+ QDeclarativeProperty prop;
+
+ prop.d = new QDeclarativePropertyPrivate;
+ prop.d->object = object;
+ prop.d->context = ctxt;
+ prop.d->engine = ctxt->engine;
+
+ prop.d->core = data;
+ prop.d->valueType = valueType;
return prop;
}
diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h
index 334cfcf..bd2c891 100644
--- a/src/declarative/qml/qdeclarativeproperty_p.h
+++ b/src/declarative/qml/qdeclarativeproperty_p.h
@@ -65,23 +65,15 @@ QT_BEGIN_NAMESPACE
class QDeclarativeContext;
class QDeclarativeEnginePrivate;
class QDeclarativeExpression;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativePropertyPrivate
+class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativePropertyPrivate : public QDeclarativeRefCount
{
public:
enum WriteFlag { BypassInterceptor = 0x01, DontRemoveBinding = 0x02, RemoveBindingOnAliasWrite = 0x04 };
Q_DECLARE_FLAGS(WriteFlags, WriteFlag)
QDeclarativePropertyPrivate()
- : q(0), context(0), engine(0), object(0), isNameCached(false) {}
-
+ : context(0), engine(0), object(0), isNameCached(false) {}
- QDeclarativePropertyPrivate(const QDeclarativePropertyPrivate &other)
- : q(0), context(other.context), engine(other.engine), object(other.object),
- isNameCached(other.isNameCached),
- core(other.core), nameCache(other.nameCache),
- valueType(other.valueType) {}
-
- QDeclarativeProperty *q;
QDeclarativeContextData *context;
QDeclarativeEngine *engine;
QDeclarativeGuard<QObject> object;
@@ -98,6 +90,7 @@ public:
bool isValueType() const;
int propertyType() const;
+ QDeclarativeProperty::Type type() const;
QDeclarativeProperty::PropertyTypeCategory propertyTypeCategory() const;
QVariant readValueProperty();
@@ -119,7 +112,12 @@ public:
static QByteArray saveValueType(const QMetaObject *, int,
const QMetaObject *, int);
static QByteArray saveProperty(const QMetaObject *, int);
+
static QDeclarativeProperty restore(const QByteArray &, QObject *, QDeclarativeContextData *);
+ static QDeclarativeProperty restore(const QDeclarativePropertyCache::Data &,
+ const QDeclarativePropertyCache::ValueTypeData &,
+ QObject *,
+ QDeclarativeContextData *);
static bool equal(const QMetaObject *, const QMetaObject *);
static bool canConvert(const QMetaObject *from, const QMetaObject *to);
diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp
index 91badae..6a39a65 100644
--- a/src/declarative/qml/qdeclarativepropertycache.cpp
+++ b/src/declarative/qml/qdeclarativepropertycache.cpp
@@ -88,6 +88,7 @@ void QDeclarativePropertyCache::Data::load(const QMetaProperty &p, QDeclarativeE
coreIndex = p.propertyIndex();
notifyIndex = p.notifySignalIndex();
flags = flagsForProperty(p, engine);
+ revision = p.revision();
}
void QDeclarativePropertyCache::Data::load(const QMetaMethod &m)
@@ -106,6 +107,7 @@ void QDeclarativePropertyCache::Data::load(const QMetaMethod &m)
QList<QByteArray> params = m.parameterTypes();
if (!params.isEmpty())
flags |= Data::HasArguments;
+ revision = m.revision();
}
@@ -216,6 +218,7 @@ QDeclarativePropertyCache *QDeclarativePropertyCache::copy() const
cache->methodIndexCache = methodIndexCache;
cache->stringCache = stringCache;
cache->identifierCache = identifierCache;
+ cache->allowedRevisionCache = allowedRevisionCache;
for (int ii = 0; ii < indexCache.count(); ++ii) {
if (indexCache.at(ii)) indexCache.at(ii)->addref();
@@ -234,8 +237,18 @@ QDeclarativePropertyCache *QDeclarativePropertyCache::copy() const
void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaObject *metaObject,
Data::Flag propertyFlags, Data::Flag methodFlags, Data::Flag signalFlags)
{
- QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
+ append(engine, metaObject, -1, propertyFlags, methodFlags, signalFlags);
+}
+
+void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaObject *metaObject,
+ int revision,
+ Data::Flag propertyFlags, Data::Flag methodFlags, Data::Flag signalFlags)
+{
+ Q_UNUSED(revision);
+
+ allowedRevisionCache.append(0);
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
int methodCount = metaObject->methodCount();
// 3 to block the destroyed signal and the deleteLater() slot
int methodOffset = qMax(3, metaObject->methodOffset());
@@ -261,11 +274,15 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb
else if (m.methodType() == QMetaMethod::Signal)
data->flags |= signalFlags;
+ data->metaObjectOffset = allowedRevisionCache.count() - 1;
+
if (stringCache.contains(methodName)) {
RData *old = stringCache[methodName];
// We only overload methods in the same class, exactly like C++
if (old->flags & Data::IsFunction && old->coreIndex >= methodOffset)
data->relatedIndex = old->coreIndex;
+ data->overrideIndexIsProperty = !bool(old->flags & Data::IsFunction);
+ data->overrideIndex = old->coreIndex;
stringCache[methodName]->release();
identifierCache[data->identifier.identifier]->release();
}
@@ -294,7 +311,12 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb
data->load(p, engine);
data->flags |= propertyFlags;
+ data->metaObjectOffset = allowedRevisionCache.count() - 1;
+
if (stringCache.contains(propName)) {
+ RData *old = stringCache[propName];
+ data->overrideIndexIsProperty = !bool(old->flags & Data::IsFunction);
+ data->overrideIndex = old->coreIndex;
stringCache[propName]->release();
identifierCache[data->identifier.identifier]->release();
}
diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h
index df2412c..eeeff1a 100644
--- a/src/declarative/qml/qdeclarativepropertycache_p.h
+++ b/src/declarative/qml/qdeclarativepropertycache_p.h
@@ -110,6 +110,10 @@ public:
int notifyIndex; // When !IsFunction
int relatedIndex; // When IsFunction
};
+ uint overrideIndexIsProperty : 1;
+ int overrideIndex : 31;
+ int revision;
+ int metaObjectOffset;
static Flags flagsForProperty(const QMetaProperty &, QDeclarativeEngine *engine = 0);
void load(const QMetaProperty &, QDeclarativeEngine *engine = 0);
@@ -131,8 +135,9 @@ public:
QDeclarativePropertyCache *copy() const;
void append(QDeclarativeEngine *, const QMetaObject *, Data::Flag propertyFlags = Data::NoFlags,
Data::Flag methodFlags = Data::NoFlags, Data::Flag signalFlags = Data::NoFlags);
+ void append(QDeclarativeEngine *, const QMetaObject *, int revision, Data::Flag propertyFlags = Data::NoFlags,
+ Data::Flag methodFlags = Data::NoFlags, Data::Flag signalFlags = Data::NoFlags);
- static QDeclarativePropertyCache *create(QDeclarativeEngine *, const QMetaObject *);
static Data create(const QMetaObject *, const QString &);
inline Data *property(const QScriptDeclarativeClass::Identifier &id) const;
@@ -141,13 +146,19 @@ public:
Data *method(int) const;
QStringList propertyNames() const;
+ inline Data *overrideData(Data *) const;
+ inline bool isAllowedInRevision(Data *) const;
+
inline QDeclarativeEngine *qmlEngine() const;
static Data *property(QDeclarativeEngine *, QObject *, const QScriptDeclarativeClass::Identifier &, Data &);
static Data *property(QDeclarativeEngine *, QObject *, const QString &, Data &);
+
protected:
virtual void clear();
private:
+ friend class QDeclarativeEnginePrivate;
+
struct RData : public Data, public QDeclarativeRefCount {
QScriptDeclarativeClass::PersistentIdentifier identifier;
};
@@ -155,6 +166,7 @@ private:
typedef QVector<RData *> IndexCache;
typedef QHash<QString, RData *> StringCache;
typedef QHash<QScriptDeclarativeClass::Identifier, RData *> IdentifierCache;
+ typedef QVector<int> AllowedRevisionCache;
void updateRecur(QDeclarativeEngine *, const QMetaObject *);
@@ -163,11 +175,13 @@ private:
IndexCache methodIndexCache;
StringCache stringCache;
IdentifierCache identifierCache;
+ AllowedRevisionCache allowedRevisionCache;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyCache::Data::Flags);
QDeclarativePropertyCache::Data::Data()
-: flags(0), propType(0), coreIndex(-1), notifyIndex(-1)
+: flags(0), propType(0), coreIndex(-1), notifyIndex(-1), overrideIndexIsProperty(false), overrideIndex(-1),
+ revision(0), metaObjectOffset(-1)
{
}
@@ -176,7 +190,20 @@ bool QDeclarativePropertyCache::Data::operator==(const QDeclarativePropertyCache
return flags == other.flags &&
propType == other.propType &&
coreIndex == other.coreIndex &&
- notifyIndex == other.notifyIndex;
+ notifyIndex == other.notifyIndex &&
+ revision == other.revision;
+}
+
+QDeclarativePropertyCache::Data *
+QDeclarativePropertyCache::overrideData(Data *data) const
+{
+ if (data->overrideIndex < 0)
+ return 0;
+
+ if (data->overrideIndexIsProperty)
+ return indexCache.at(data->overrideIndex);
+ else
+ return methodIndexCache.at(data->overrideIndex);
}
QDeclarativePropertyCache::Data *
@@ -197,6 +224,12 @@ bool QDeclarativePropertyCache::ValueTypeData::operator==(const ValueTypeData &o
valueTypePropType == o.valueTypePropType;
}
+bool QDeclarativePropertyCache::isAllowedInRevision(Data *data) const
+{
+ return (data->metaObjectOffset == -1 && data->revision == 0) ||
+ (allowedRevisionCache[data->metaObjectOffset] >= data->revision);
+}
+
QDeclarativeEngine *QDeclarativePropertyCache::qmlEngine() const
{
return engine;
diff --git a/src/declarative/qml/qdeclarativerefcount_p.h b/src/declarative/qml/qdeclarativerefcount_p.h
index 868cdc4..b896e5f 100644
--- a/src/declarative/qml/qdeclarativerefcount_p.h
+++ b/src/declarative/qml/qdeclarativerefcount_p.h
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class Q_AUTOTEST_EXPORT QDeclarativeRefCount
+class Q_DECLARATIVE_EXPORT QDeclarativeRefCount
{
public:
QDeclarativeRefCount();
diff --git a/src/declarative/qml/qdeclarativerewrite.cpp b/src/declarative/qml/qdeclarativerewrite.cpp
index 2cb1c65..6311e01 100644
--- a/src/declarative/qml/qdeclarativerewrite.cpp
+++ b/src/declarative/qml/qdeclarativerewrite.cpp
@@ -62,12 +62,17 @@ bool SharedBindingTester::isSharable(const QString &code)
if (!parser.statement())
return false;
+ return isSharable(parser.statement());
+}
+
+bool SharedBindingTester::isSharable(AST::Node *node)
+{
_sharable = true;
- AST::Node::acceptChild(parser.statement(), this);
+ AST::Node::acceptChild(node, this);
return _sharable;
}
-QString RewriteBinding::operator()(const QString &code, bool *ok)
+QString RewriteBinding::operator()(const QString &code, bool *ok, bool *sharable)
{
Engine engine;
NodePool pool(QString(), &engine);
@@ -80,10 +85,63 @@ QString RewriteBinding::operator()(const QString &code, bool *ok)
return QString();
} else {
if (ok) *ok = true;
+ if (sharable) {
+ SharedBindingTester tester;
+ *sharable = tester.isSharable(parser.statement());
+ }
}
return rewrite(code, 0, parser.statement());
}
+QString RewriteBinding::operator()(QDeclarativeJS::AST::Node *node, const QString &code, bool *sharable)
+{
+ if (!node)
+ return code;
+
+ if (sharable) {
+ SharedBindingTester tester;
+ *sharable = tester.isSharable(node);
+ }
+
+ QDeclarativeJS::AST::ExpressionNode *expression = node->expressionCast();
+ QDeclarativeJS::AST::Statement *statement = node->statementCast();
+ if(!expression && !statement)
+ return code;
+
+ TextWriter w;
+ _writer = &w;
+ _position = expression ? expression->firstSourceLocation().begin() : statement->firstSourceLocation().begin();
+ _inLoop = 0;
+
+ accept(node);
+
+ unsigned startOfStatement = 0;
+ unsigned endOfStatement = (expression ? expression->lastSourceLocation().end() : statement->lastSourceLocation().end()) - _position;
+
+ QString startString = QLatin1String("(function ") + QString::fromUtf8(_name) + QLatin1String("() { ");
+ if (expression)
+ startString += QLatin1String("return ");
+ _writer->replace(startOfStatement, 0, startString);
+ _writer->replace(endOfStatement, 0, QLatin1String(" })"));
+
+ if (rewriteDump()) {
+ qWarning() << "=============================================================";
+ qWarning() << "Rewrote:";
+ qWarning() << qPrintable(code);
+ }
+
+ QString codeCopy = code;
+ w.write(&codeCopy);
+
+ if (rewriteDump()) {
+ qWarning() << "To:";
+ qWarning() << qPrintable(code);
+ qWarning() << "=============================================================";
+ }
+
+ return codeCopy;
+}
+
void RewriteBinding::accept(AST::Node *node)
{
AST::Node::acceptChild(node, this);
diff --git a/src/declarative/qml/qdeclarativerewrite_p.h b/src/declarative/qml/qdeclarativerewrite_p.h
index fc44a81..7c20a39 100644
--- a/src/declarative/qml/qdeclarativerewrite_p.h
+++ b/src/declarative/qml/qdeclarativerewrite_p.h
@@ -68,6 +68,7 @@ class SharedBindingTester : protected AST::Visitor
bool _sharable;
public:
bool isSharable(const QString &code);
+ bool isSharable(AST::Node *Node);
virtual bool visit(AST::FunctionDeclaration *) { _sharable = false; return false; }
virtual bool visit(AST::FunctionExpression *) { _sharable = false; return false; }
@@ -81,7 +82,8 @@ class RewriteBinding: protected AST::Visitor
QByteArray _name;
public:
- QString operator()(const QString &code, bool *ok = 0);
+ QString operator()(const QString &code, bool *ok = 0, bool *sharable = 0);
+ QString operator()(QDeclarativeJS::AST::Node *node, const QString &code, bool *sharable = 0);
//name of the function: used for the debugger
void setName(const QByteArray &name) { _name = name; }
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index 4531381..e8f6b0d 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -65,16 +65,16 @@ class ProcessAST: protected AST::Visitor
{
struct State {
State() : object(0), property(0) {}
- State(Object *o) : object(o), property(0) {}
- State(Object *o, Property *p) : object(o), property(p) {}
+ State(QDeclarativeParser::Object *o) : object(o), property(0) {}
+ State(QDeclarativeParser::Object *o, Property *p) : object(o), property(p) {}
- Object *object;
+ QDeclarativeParser::Object *object;
Property *property;
};
struct StateStack : public QStack<State>
{
- void pushObject(Object *obj)
+ void pushObject(QDeclarativeParser::Object *obj)
{
push(State(obj));
}
@@ -105,7 +105,7 @@ public:
protected:
- Object *defineObjectBinding(AST::UiQualifiedId *propertyName, bool onAssignment,
+ QDeclarativeParser::Object *defineObjectBinding(AST::UiQualifiedId *propertyName, bool onAssignment,
const QString &objectType,
AST::SourceLocation typeLocation,
LocationSpan location,
@@ -134,7 +134,7 @@ protected:
QString asString(AST::UiQualifiedId *node) const;
const State state() const;
- Object *currentObject() const;
+ QDeclarativeParser::Object *currentObject() const;
Property *currentProperty() const;
QString qualifiedNameId() const;
@@ -170,12 +170,6 @@ private:
StateStack _stateStack;
QStringList _scope;
QString _contents;
-
- inline bool isSignalProperty(const QByteArray &propertyName) const {
- return (propertyName.length() >= 3 && propertyName.startsWith("on") &&
- ('A' <= propertyName.at(2) && 'Z' >= propertyName.at(2)));
- }
-
};
ProcessAST::ProcessAST(QDeclarativeScriptParser *parser)
@@ -206,7 +200,7 @@ const ProcessAST::State ProcessAST::state() const
return _stateStack.back();
}
-Object *ProcessAST::currentObject() const
+QDeclarativeParser::Object *ProcessAST::currentObject() const
{
return state().object;
}
@@ -235,7 +229,7 @@ QString ProcessAST::asString(AST::UiQualifiedId *node) const
return s;
}
-Object *
+QDeclarativeParser::Object *
ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName,
bool onAssignment,
const QString &objectType,
@@ -292,7 +286,7 @@ ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName,
if (lastTypeDot >= 0)
resolvableObjectType.replace(QLatin1Char('.'),QLatin1Char('/'));
- Object *obj = new Object;
+ QDeclarativeParser::Object *obj = new QDeclarativeParser::Object;
QDeclarativeScriptParser::TypeReference *typeRef = _parser->findOrCreateType(resolvableObjectType);
obj->type = typeRef->id;
@@ -307,9 +301,8 @@ ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName,
obj->location = location;
if (propertyCount) {
-
Property *prop = currentProperty();
- Value *v = new Value;
+ QDeclarativeParser::Value *v = new QDeclarativeParser::Value;
v->object = obj;
v->location = obj->location;
if (onAssignment)
@@ -326,7 +319,7 @@ ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName,
_parser->setTree(obj);
} else {
const State state = _stateStack.top();
- Value *v = new Value;
+ QDeclarativeParser::Value *v = new QDeclarativeParser::Value;
v->object = obj;
v->location = obj->location;
if (state.property) {
@@ -601,7 +594,7 @@ bool ProcessAST::visit(AST::UiPublicMember *node)
property.defaultValue->location =
location(node->expression->firstSourceLocation(),
node->expression->lastSourceLocation());
- Value *value = new Value;
+ QDeclarativeParser::Value *value = new QDeclarativeParser::Value;
value->location = location(node->expression->firstSourceLocation(),
node->expression->lastSourceLocation());
value->value = getVariant(node->expression);
@@ -705,7 +698,7 @@ bool ProcessAST::visit(AST::UiScriptBinding *node)
prop->location.range.length = prop->location.range.offset + prop->location.range.length - node->qualifiedId->identifierToken.offset;
prop->location.range.offset = node->qualifiedId->identifierToken.offset;
- Value *v = new Value;
+ QDeclarativeParser::Value *v = new QDeclarativeParser::Value;
v->value = primitive;
v->location = location(node->statement->firstSourceLocation(),
node->statement->lastSourceLocation());
@@ -877,7 +870,7 @@ QList<QDeclarativeScriptParser::TypeReference*> QDeclarativeScriptParser::refere
return _refTypes;
}
-Object *QDeclarativeScriptParser::tree() const
+QDeclarativeParser::Object *QDeclarativeScriptParser::tree() const
{
return root;
}
@@ -1200,7 +1193,7 @@ QDeclarativeScriptParser::TypeReference *QDeclarativeScriptParser::findOrCreateT
return type;
}
-void QDeclarativeScriptParser::setTree(Object *tree)
+void QDeclarativeScriptParser::setTree(QDeclarativeParser::Object *tree)
{
Q_ASSERT(! root);
diff --git a/src/declarative/qml/qdeclarativesqldatabase.cpp b/src/declarative/qml/qdeclarativesqldatabase.cpp
index 7d3450d..207fb57 100644
--- a/src/declarative/qml/qdeclarativesqldatabase.cpp
+++ b/src/declarative/qml/qdeclarativesqldatabase.cpp
@@ -351,7 +351,7 @@ static QScriptValue qmlsqldatabase_read_transaction(QScriptContext *context, QSc
}
/*
- Currently documented in doc/src/declarastive/globalobject.qdoc
+ Currently documented in doc/src/declarative/globalobject.qdoc
*/
static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEngine *engine)
{
diff --git a/src/declarative/qml/qdeclarativestringconverters.cpp b/src/declarative/qml/qdeclarativestringconverters.cpp
index 371c504..aa1de43 100644
--- a/src/declarative/qml/qdeclarativestringconverters.cpp
+++ b/src/declarative/qml/qdeclarativestringconverters.cpp
@@ -136,7 +136,7 @@ QVariant QDeclarativeStringConverters::variantFromString(const QString &s, int p
QColor QDeclarativeStringConverters::colorFromString(const QString &s, bool *ok)
{
- if (s.startsWith(QLatin1Char('#')) && s.length() == 9) {
+ if (s.length() == 9 && s.startsWith(QLatin1Char('#'))) {
uchar a = fromHex(s, 1);
uchar r = fromHex(s, 3);
uchar g = fromHex(s, 5);
@@ -144,9 +144,7 @@ QColor QDeclarativeStringConverters::colorFromString(const QString &s, bool *ok)
if (ok) *ok = true;
return QColor(r, g, b, a);
} else {
- QColor rv;
- if (s.startsWith(QLatin1Char('#')) || QColor::colorNames().contains(s.toLower()))
- rv = QColor(s);
+ QColor rv(s);
if (ok) *ok = rv.isValid();
return rv;
}
diff --git a/src/declarative/qml/qdeclarativetypeloader.cpp b/src/declarative/qml/qdeclarativetypeloader.cpp
index 45e6dbf..36cdde9 100644
--- a/src/declarative/qml/qdeclarativetypeloader.cpp
+++ b/src/declarative/qml/qdeclarativetypeloader.cpp
@@ -45,6 +45,7 @@
#include <private/qdeclarativecompiler_p.h>
#include <private/qdeclarativecomponent_p.h>
#include <private/qdeclarativeglobal_p.h>
+#include <private/qdeclarativedebugtrace_p.h>
#include <QtDeclarative/qdeclarativecomponent.h>
#include <QtCore/qdebug.h>
@@ -895,10 +896,12 @@ void QDeclarativeTypeData::downloadProgressChanged(qreal p)
void QDeclarativeTypeData::compile()
{
Q_ASSERT(m_compiledData == 0);
+ QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Compiling);
m_compiledData = new QDeclarativeCompiledData(typeLoader()->engine());
m_compiledData->url = m_imports.baseUrl();
m_compiledData->name = m_compiledData->url.toString();
+ QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::Compiling, m_compiledData->name);
QDeclarativeCompiler compiler;
if (!compiler.compile(typeLoader()->engine(), this, m_compiledData)) {
@@ -906,6 +909,7 @@ void QDeclarativeTypeData::compile()
m_compiledData->release();
m_compiledData = 0;
}
+ QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::Compiling);
}
void QDeclarativeTypeData::resolveTypes()
@@ -1001,6 +1005,8 @@ void QDeclarativeTypeData::resolveTypes()
}
if (ref.type) {
+ ref.majorVersion = majorVersion;
+ ref.minorVersion = minorVersion;
foreach (QDeclarativeParser::Object *obj, parserRef->refObjects) {
// store namespace for DOM
obj->majorVersion = majorVersion;
diff --git a/src/declarative/qml/qdeclarativetypeloader_p.h b/src/declarative/qml/qdeclarativetypeloader_p.h
index beee358..6938892 100644
--- a/src/declarative/qml/qdeclarativetypeloader_p.h
+++ b/src/declarative/qml/qdeclarativetypeloader_p.h
@@ -215,10 +215,12 @@ class Q_AUTOTEST_EXPORT QDeclarativeTypeData : public QDeclarativeDataBlob
public:
struct TypeReference
{
- TypeReference() : type(0), typeData(0) {}
+ TypeReference() : type(0), majorVersion(0), minorVersion(0), typeData(0) {}
QDeclarativeParser::Location location;
QDeclarativeType *type;
+ int majorVersion;
+ int minorVersion;
QDeclarativeTypeData *typeData;
};
diff --git a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
index 4a8ffe0..d3e2025 100644
--- a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
+++ b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
@@ -109,9 +109,8 @@ QDeclarativeTypeNameScriptClass::queryProperty(Object *obj, const Identifier &na
} else if (data->type) {
- QString strName = toString(name);
-
- if (strName.at(0).isUpper()) {
+ if (startsWithUpper(name)) {
+ QString strName = toString(name);
// Must be an enum
if (data->mode == IncludeEnums) {
// ### Optimize
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index 659c986..0f884b6 100644
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -71,6 +71,7 @@ int qmlRegisterValueTypeEnums(const char *uri, int versionMajor, int versionMino
0, 0,
+ 0,
0
};
diff --git a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp
index 558ef90..4c312b5 100644
--- a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp
+++ b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp
@@ -46,6 +46,8 @@
#include "private/qdeclarativeengine_p.h"
#include "private/qdeclarativeguard_p.h"
+#include <QtScript/qscriptcontextinfo.h>
+
QT_BEGIN_NAMESPACE
struct QDeclarativeValueTypeObject : public QScriptDeclarativeClass::Object {
@@ -161,17 +163,41 @@ void QDeclarativeValueTypeScriptClass::setProperty(Object *obj, const Identifier
if (o->objectType == QDeclarativeValueTypeObject::Reference) {
QDeclarativeValueTypeReference *ref = static_cast<QDeclarativeValueTypeReference *>(obj);
+ ref->type->read(ref->object, ref->property);
+ QMetaProperty p = ref->type->metaObject()->property(m_lastIndex);
+
+ QDeclarativeBinding *newBinding = 0;
+ if (value.isFunction() && !value.isRegExp()) {
+ QDeclarativeContextData *ctxt = QDeclarativeEnginePrivate::get(engine)->getContext(context());
+
+ QDeclarativePropertyCache::Data cacheData;
+ cacheData.flags = QDeclarativePropertyCache::Data::IsWritable;
+ cacheData.propType = ref->object->metaObject()->property(ref->property).userType();
+ cacheData.coreIndex = ref->property;
+
+ QDeclarativePropertyCache::ValueTypeData valueTypeData;
+ valueTypeData.valueTypeCoreIdx = m_lastIndex;
+ valueTypeData.valueTypePropType = p.userType();
+
+ newBinding = new QDeclarativeBinding(value, ref->object, ctxt);
+ QScriptContextInfo ctxtInfo(context());
+ newBinding->setSourceLocation(ctxtInfo.fileName(), ctxtInfo.functionStartLineNumber());
+ QDeclarativeProperty prop = QDeclarativePropertyPrivate::restore(cacheData, valueTypeData, ref->object, ctxt);
+ newBinding->setTarget(prop);
+ if (newBinding->expression().contains(QLatin1String("this")))
+ newBinding->setEvaluateFlags(newBinding->evaluateFlags() | QDeclarativeBinding::RequiresThisObject);
+ }
+
QDeclarativeAbstractBinding *delBinding =
- QDeclarativePropertyPrivate::setBinding(ref->object, ref->property, m_lastIndex, 0);
+ QDeclarativePropertyPrivate::setBinding(ref->object, ref->property, m_lastIndex, newBinding);
if (delBinding)
delBinding->destroy();
- ref->type->read(ref->object, ref->property);
- QMetaProperty p = ref->type->metaObject()->property(m_lastIndex);
if (p.isEnumType() && (QMetaType::Type)v.type() == QMetaType::Double)
v = v.toInt();
p.write(ref->type, v);
ref->type->write(ref->object, ref->property, 0);
+
} else {
QDeclarativeValueTypeCopy *copy = static_cast<QDeclarativeValueTypeCopy *>(obj);
copy->type->setValue(copy->value);
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index fb07bef..2d551f2 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -247,8 +247,12 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
::memset(o, 0, instr.createSimple.typeSize + sizeof(QDeclarativeData));
instr.createSimple.create(o);
- QDeclarativeData *ddata =
- (QDeclarativeData *)(((const char *)o) + instr.createSimple.typeSize);
+ QDeclarativeData *ddata = (QDeclarativeData *)(((const char *)o) + instr.createSimple.typeSize);
+ const QDeclarativeCompiledData::TypeReference &ref = types.at(instr.createSimple.type);
+ if (!ddata->propertyCache && ref.typePropertyCache) {
+ ddata->propertyCache = ref.typePropertyCache;
+ ddata->propertyCache->addref();
+ }
ddata->lineNumber = instr.line;
ddata->columnNumber = instr.createSimple.column;
@@ -320,10 +324,12 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
(void)new QDeclarativeVMEMetaObject(target, &mo, data, comp);
- QDeclarativeData *ddata = QDeclarativeData::get(target, true);
- if (ddata->propertyCache) ddata->propertyCache->release();
- ddata->propertyCache = propertyCaches.at(instr.storeMeta.propertyCache);
- ddata->propertyCache->addref();
+ if (instr.storeMeta.propertyCache != -1) {
+ QDeclarativeData *ddata = QDeclarativeData::get(target, true);
+ if (ddata->propertyCache) ddata->propertyCache->release();
+ ddata->propertyCache = propertyCaches.at(instr.storeMeta.propertyCache);
+ ddata->propertyCache->addref();
+ }
}
break;
@@ -932,7 +938,6 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
QDeclarativeEnginePrivate::clear(bindValues);
QDeclarativeEnginePrivate::clear(parserStatus);
- ep->finalizedParserStatus.clear();
return 0;
}
@@ -974,6 +979,11 @@ QDeclarativeCompiledData::TypeReference::createInstance(QDeclarativeContextData
ddata->ownMemory = false;
QObjectPrivate::get(rv)->declarativeData = ddata;
+ if (typePropertyCache && !ddata->propertyCache) {
+ ddata->propertyCache = typePropertyCache;
+ ddata->propertyCache->addref();
+ }
+
return rv;
} else {
Q_ASSERT(component);
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index a3a32e9..2e8ab18 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -43,6 +43,7 @@
#include "private/qdeclarativelistmodel_p.h"
#include "private/qdeclarativelistmodelworkeragent_p.h"
#include "private/qdeclarativeengine_p.h"
+#include "private/qdeclarativeexpression_p.h"
#include <QtCore/qcoreevent.h>
#include <QtCore/qcoreapplication.h>
@@ -104,6 +105,19 @@ private:
int m_id;
};
+class WorkerErrorEvent : public QEvent
+{
+public:
+ enum Type { WorkerError = WorkerRemoveEvent::WorkerRemove + 1 };
+
+ WorkerErrorEvent(const QDeclarativeError &error);
+
+ QDeclarativeError error() const;
+
+private:
+ QDeclarativeError m_error;
+};
+
class QDeclarativeWorkerScriptEnginePrivate : public QObject
{
Q_OBJECT
@@ -146,6 +160,7 @@ public:
WorkerScript();
int id;
+ QUrl source;
bool initialized;
QDeclarativeWorkerScript *owner;
QScriptValue object;
@@ -173,6 +188,7 @@ protected:
private:
void processMessage(int, const QVariant &);
void processLoad(int, const QUrl &);
+ void reportScriptException(WorkerScript *);
};
QDeclarativeWorkerScriptEnginePrivate::QDeclarativeWorkerScriptEnginePrivate(QDeclarativeEngine *engine)
@@ -273,6 +289,11 @@ void QDeclarativeWorkerScriptEnginePrivate::processMessage(int id, const QVarian
args.setProperty(0, variantToScriptValue(data, workerEngine));
script->callback.call(script->object, args);
+
+ if (workerEngine->hasUncaughtException()) {
+ reportScriptException(script);
+ workerEngine->clearExceptions();
+ }
}
}
@@ -286,7 +307,7 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
QFile f(fileName);
if (f.open(QIODevice::ReadOnly)) {
QByteArray data = f.readAll();
- QString script = QString::fromUtf8(data);
+ QString sourceCode = QString::fromUtf8(data);
QScriptValue activation = getWorker(id);
@@ -296,10 +317,19 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
ctxt->pushScope(urlContext);
ctxt->pushScope(activation);
ctxt->setActivationObject(activation);
- QDeclarativeScriptParser::extractPragmas(script);
+ QDeclarativeScriptParser::extractPragmas(sourceCode);
workerEngine->baseUrl = url;
- workerEngine->evaluate(script);
+ workerEngine->evaluate(sourceCode);
+
+ WorkerScript *script = workers.value(id);
+ if (script) {
+ script->source = url;
+ if (workerEngine->hasUncaughtException()) {
+ reportScriptException(script);
+ workerEngine->clearExceptions();
+ }
+ }
workerEngine->popContext();
} else {
@@ -307,6 +337,22 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
}
}
+void QDeclarativeWorkerScriptEnginePrivate::reportScriptException(WorkerScript *script)
+{
+ if (!script || !workerEngine->hasUncaughtException())
+ return;
+
+ QDeclarativeError error;
+ QDeclarativeExpressionPrivate::exceptionToError(workerEngine, error);
+ error.setUrl(script->source);
+
+ QDeclarativeWorkerScriptEnginePrivate *p = QDeclarativeWorkerScriptEnginePrivate::get(workerEngine);
+
+ QMutexLocker(&p->m_lock);
+ if (script->owner)
+ QCoreApplication::postEvent(script->owner, new WorkerErrorEvent(error));
+}
+
QVariant QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(const QScriptValue &value)
{
if (value.isBool()) {
@@ -453,6 +499,16 @@ int WorkerRemoveEvent::workerId() const
return m_id;
}
+WorkerErrorEvent::WorkerErrorEvent(const QDeclarativeError &error)
+: QEvent((QEvent::Type)WorkerError), m_error(error)
+{
+}
+
+QDeclarativeError WorkerErrorEvent::error() const
+{
+ return m_error;
+}
+
QDeclarativeWorkerScriptEngine::QDeclarativeWorkerScriptEngine(QDeclarativeEngine *parent)
: QThread(parent), d(new QDeclarativeWorkerScriptEnginePrivate(parent))
{
@@ -544,12 +600,7 @@ void QDeclarativeWorkerScriptEngine::run()
The above worker script specifies a JavaScript file, "script.js", that handles
the operations to be performed in the new thread. Here is \c script.js:
- \qml
- WorkerScript.onMessage = function(message) {
- // ... long-running operations and calculations are done here
- WorkerScript.sendMessage({ 'reply': 'Mouse is at ' + message.x + ',' + message.y })
- }
- \endqml
+ \quotefile doc/src/snippets/declarative/script.js
When the user clicks anywhere within the rectangle, \c sendMessage() is
called, triggering the \tt WorkerScript.onMessage() handler in
@@ -687,6 +738,10 @@ bool QDeclarativeWorkerScript::event(QEvent *event)
emit message(value);
}
return true;
+ } else if (event->type() == (QEvent::Type)WorkerErrorEvent::WorkerError) {
+ WorkerErrorEvent *workerEvent = static_cast<WorkerErrorEvent *>(event);
+ QDeclarativeEnginePrivate::warning(qmlEngine(this), workerEvent->error());
+ return true;
} else {
return QObject::event(event);
}
diff --git a/src/declarative/qml/qmetaobjectbuilder.cpp b/src/declarative/qml/qmetaobjectbuilder.cpp
index cefc561..6a0226f 100644
--- a/src/declarative/qml/qmetaobjectbuilder.cpp
+++ b/src/declarative/qml/qmetaobjectbuilder.cpp
@@ -122,7 +122,7 @@ enum PropertyFlags {
User = 0x00100000,
ResolveUser = 0x00200000,
Notify = 0x00400000,
- Dynamic = 0x00800000
+ Revisioned = 0x00800000
};
enum MethodFlags {
@@ -139,7 +139,8 @@ enum MethodFlags {
MethodCompatibility = 0x10,
MethodCloned = 0x20,
- MethodScriptable = 0x40
+ MethodScriptable = 0x40,
+ MethodRevisioned = 0x80
};
struct QMetaObjectPrivate
@@ -2277,21 +2278,6 @@ bool QMetaPropertyBuilder::isEnumOrFlag() const
}
/*!
- Returns true if the property has the dynamic flag set;
- otherwise returns false. The default value is false.
-
- \sa setDynamic()
-*/
-bool QMetaPropertyBuilder::isDynamic() const
-{
- QMetaPropertyBuilderPrivate *d = d_func();
- if (d)
- return d->flag(Dynamic);
- else
- return false;
-}
-
-/*!
Sets this property to readable if \a value is true.
\sa isReadable(), setWritable()
@@ -2415,19 +2401,6 @@ void QMetaPropertyBuilder::setEnumOrFlag(bool value)
}
/*!
- Sets this property to have the dynamic flag if \a value is
- true.
-
- \sa isDynamic()
-*/
-void QMetaPropertyBuilder::setDynamic(bool value)
-{
- QMetaPropertyBuilderPrivate *d = d_func();
- if (d)
- d->setFlag(Dynamic, 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 6afd755..2678bff 100644
--- a/src/declarative/qml/qmetaobjectbuilder_p.h
+++ b/src/declarative/qml/qmetaobjectbuilder_p.h
@@ -258,7 +258,6 @@ public:
bool isUser() const;
bool hasStdCppSet() const;
bool isEnumOrFlag() const;
- bool isDynamic() const;
void setReadable(bool value);
void setWritable(bool value);
@@ -270,7 +269,6 @@ public:
void setUser(bool value);
void setStdCppSet(bool value);
void setEnumOrFlag(bool value);
- void setDynamic(bool value);
private:
const QMetaObjectBuilder *_mobj;
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index 66b69f9..bf9e54a 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -55,7 +55,8 @@ SOURCES += \
$$PWD/qdeclarativedirparser.cpp \
$$PWD/qdeclarativeextensionplugin.cpp \
$$PWD/qdeclarativeimport.cpp \
- $$PWD/qdeclarativelist.cpp
+ $$PWD/qdeclarativelist.cpp \
+ $$PWD/qperformancetimer.cpp
HEADERS += \
$$PWD/qdeclarativeparser_p.h \
@@ -129,8 +130,12 @@ HEADERS += \
$$PWD/qdeclarativedirparser_p.h \
$$PWD/qdeclarativeextensioninterface.h \
$$PWD/qdeclarativeimport_p.h \
- $$PWD/qdeclarativeextensionplugin.h
+ $$PWD/qdeclarativeextensionplugin.h \
+ $$PWD/qperformancetimer_p.h
QT += sql
include(parser/parser.pri)
include(rewriter/rewriter.pri)
+
+# mirrors logic in corelib/kernel/kernel.pri
+unix:!symbian: contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
diff --git a/src/declarative/qml/qperformancetimer.cpp b/src/declarative/qml/qperformancetimer.cpp
new file mode 100644
index 0000000..1d7ca80
--- /dev/null
+++ b/src/declarative/qml/qperformancetimer.cpp
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 "qperformancetimer_p.h"
+
+#if defined(Q_OS_MAC)
+#include <sys/time.h>
+#include <unistd.h>
+#include <mach/mach_time.h>
+#elif defined(Q_OS_UNIX)
+#include <sys/time.h>
+#include <time.h>
+#include <unistd.h>
+#elif defined(Q_OS_SYMBIAN)
+#include <e32std.h>
+#include <sys/time.h>
+#include <hal.h>
+#elif defined(Q_OS_WIN)
+#include <windows.h>
+#endif
+
+// mac/unix code heavily copied from QElapsedTimer
+
+QT_BEGIN_NAMESPACE
+
+////////////////////////////// Mac //////////////////////////////
+#if defined(Q_OS_MAC)
+
+static mach_timebase_info_data_t info = {0,0};
+static qint64 absoluteToNSecs(qint64 cpuTime)
+{
+ if (info.denom == 0)
+ mach_timebase_info(&info);
+ qint64 nsecs = cpuTime * info.numer / info.denom;
+ return nsecs;
+}
+
+void QPerformanceTimer::start()
+{
+ t1 = mach_absolute_time();
+}
+
+qint64 QPerformanceTimer::elapsed() const
+{
+ uint64_t cpu_time = mach_absolute_time();
+ return absoluteToNSecs(cpu_time - t1);
+}
+
+////////////////////////////// Unix //////////////////////////////
+#elif defined(Q_OS_UNIX)
+
+#if defined(QT_NO_CLOCK_MONOTONIC) || defined(QT_BOOTSTRAPPED)
+// turn off the monotonic clock
+# ifdef _POSIX_MONOTONIC_CLOCK
+# undef _POSIX_MONOTONIC_CLOCK
+# endif
+# define _POSIX_MONOTONIC_CLOCK -1
+#endif
+
+#if (_POSIX_MONOTONIC_CLOCK-0 != 0)
+static const bool monotonicClockChecked = true;
+static const bool monotonicClockAvailable = _POSIX_MONOTONIC_CLOCK > 0;
+#else
+static int monotonicClockChecked = false;
+static int monotonicClockAvailable = false;
+#endif
+
+#ifdef Q_CC_GNU
+# define is_likely(x) __builtin_expect((x), 1)
+#else
+# define is_likely(x) (x)
+#endif
+#define load_acquire(x) ((volatile const int&)(x))
+#define store_release(x,v) ((volatile int&)(x) = (v))
+
+static void unixCheckClockType()
+{
+#if (_POSIX_MONOTONIC_CLOCK-0 == 0)
+ if (is_likely(load_acquire(monotonicClockChecked)))
+ return;
+
+# if defined(_SC_MONOTONIC_CLOCK)
+ // detect if the system support monotonic timers
+ long x = sysconf(_SC_MONOTONIC_CLOCK);
+ store_release(monotonicClockAvailable, x >= 200112L);
+# endif
+
+ store_release(monotonicClockChecked, true);
+#endif
+}
+
+static inline void do_gettime(qint64 *sec, qint64 *frac)
+{
+#if (_POSIX_MONOTONIC_CLOCK-0 >= 0)
+ unixCheckClockType();
+ if (is_likely(monotonicClockAvailable)) {
+ timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ *sec = ts.tv_sec;
+ *frac = ts.tv_nsec;
+ return;
+ }
+#endif
+ *sec = 0;
+ *frac = 0;
+}
+
+void QPerformanceTimer::start()
+{
+ do_gettime(&t1, &t2);
+}
+
+qint64 QPerformanceTimer::elapsed() const
+{
+ qint64 sec, frac;
+ do_gettime(&sec, &frac);
+ sec = sec - t1;
+ frac = frac - t2;
+
+ return sec * Q_INT64_C(1000000000) + frac;
+}
+
+////////////////////////////// Symbian //////////////////////////////
+#elif defined(Q_OS_SYMBIAN)
+
+static qint64 getTimeFromTick(quint64 elapsed)
+{
+ static TInt freq;
+ if (!freq)
+ HAL::Get(HALData::EFastCounterFrequency, freq);
+
+ // ### not sure on units
+ return elapsed / freq;
+}
+
+void QPerformanceTimer::start()
+{
+ t1 = User::FastCounter();
+}
+
+qint64 QPerformanceTimer::elapsed() const
+{
+ return getTimeFromTick(User::FastCounter() - t1);
+}
+
+////////////////////////////// Windows //////////////////////////////
+#elif defined(Q_OS_WIN)
+
+static qint64 getTimeFromTick(quint64 elapsed)
+{
+ static LARGE_INTEGER freq;
+ if (!freq.QuadPart)
+ QueryPerformanceFrequency(&freq);
+ return 1000000000 * elapsed / freq.QuadPart;
+}
+
+void QPerformanceTimer::start()
+{
+ LARGE_INTEGER li;
+ QueryPerformanceCounter(&li);
+ t1 = li.QuadPart;
+}
+
+qint64 QPerformanceTimer::elapsed() const
+{
+ LARGE_INTEGER li;
+ QueryPerformanceCounter(&li);
+ return getTimeFromTick(li.QuadPart - t1);
+}
+
+////////////////////////////// Default //////////////////////////////
+#else
+
+// default implementation (no hi-perf timer) does nothing
+void QPerformanceTimer::start()
+{
+}
+
+qint64 QPerformanceTimer::elapsed() const
+{
+ return 0;
+}
+
+#endif
+
+QT_END_NAMESPACE
+
+
diff --git a/src/declarative/qml/qperformancetimer_p.h b/src/declarative/qml/qperformancetimer_p.h
new file mode 100644
index 0000000..14310bf
--- /dev/null
+++ b/src/declarative/qml/qperformancetimer_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 QPERFORMANCETIMER_P_H
+#define QPERFORMANCETIMER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of moc. This header file may change from version to version without notice,
+// or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_AUTOTEST_EXPORT QPerformanceTimer
+{
+public:
+ void start();
+ qint64 elapsed() const;
+
+private:
+ qint64 t1;
+ qint64 t2;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPERFORMANCETIMER_P_H
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 681cea0..dc6d524 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -182,12 +182,11 @@ void QDeclarativeAbstractAnimation::setRunning(bool r)
{
Q_D(QDeclarativeAbstractAnimation);
if (!d->componentComplete) {
- if (d->running && r == d->running) //don't re-register
- return;
d->running = r;
if (r == false)
d->avoidPropertyValueSourceStart = true;
- else {
+ else if (!d->registered) {
+ d->registered = true;
QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this));
engPriv->registerFinalizedParserStatusObject(this, this->metaObject()->indexOfSlot("componentFinalized()"));
}
@@ -204,6 +203,7 @@ void QDeclarativeAbstractAnimation::setRunning(bool r)
d->running = r;
if (d->running) {
+ bool supressStart = false;
if (d->alwaysRunToEnd && d->loopCount != 1
&& qtAnimation()->state() == QAbstractAnimation::Running) {
//we've restarted before the final loop finished; restore proper loop count
@@ -211,6 +211,7 @@ void QDeclarativeAbstractAnimation::setRunning(bool r)
qtAnimation()->setLoopCount(d->loopCount);
else
qtAnimation()->setLoopCount(qtAnimation()->currentLoop() + d->loopCount);
+ supressStart = true; //we want the animation to continue, rather than restart
}
if (!d->connectedTimeLine) {
@@ -218,7 +219,8 @@ void QDeclarativeAbstractAnimation::setRunning(bool r)
this, SLOT(timelineComplete()));
d->connectedTimeLine = true;
}
- d->commence();
+ if (!supressStart)
+ d->commence();
emit started();
} else {
if (d->alwaysRunToEnd) {
@@ -672,7 +674,9 @@ QDeclarativeColorAnimation::~QDeclarativeColorAnimation()
\qml
Item {
- states: [ ... ]
+ states: [
+ // States are defined here...
+ ]
transition: Transition {
NumberAnimation { from: "#c0c0c0"; duration: 2000 }
@@ -725,40 +729,29 @@ void QDeclarativeColorAnimation::setTo(const QColor &t)
/*!
\qmlclass ScriptAction QDeclarativeScriptAction
- \ingroup qml-animation-transition
+ \ingroup qml-animation-transition
\since 4.7
\inherits Animation
\brief The ScriptAction element allows scripts to be run during an animation.
- ScriptAction can be used to run script at a specific point in an animation.
+ ScriptAction can be used to run a script at a specific point in an animation.
\qml
SequentialAnimation {
- NumberAnimation { ... }
+ NumberAnimation {
+ // ...
+ }
ScriptAction { script: doSomething(); }
- NumberAnimation { ... }
+ NumberAnimation {
+ // ...
+ }
}
\endqml
When used as part of a Transition, you can also target a specific
StateChangeScript to run using the \c scriptName property.
- \qml
- State {
- StateChangeScript {
- name: "myScript"
- script: doStateStuff();
- }
- }
- ...
- Transition {
- SequentialAnimation {
- NumberAnimation { ... }
- ScriptAction { scriptName: "myScript" }
- NumberAnimation { ... }
- }
- }
- \endqml
+ \snippet doc/src/snippets/declarative/states/statechangescript.qml state and transition
\sa StateChangeScript
*/
@@ -870,7 +863,7 @@ QAbstractAnimation *QDeclarativeScriptAction::qtAnimation()
/*!
\qmlclass PropertyAction QDeclarativePropertyAction
- \ingroup qml-animation-transition
+ \ingroup qml-animation-transition
\since 4.7
\inherits Animation
\brief The PropertyAction element allows immediate property changes during animation.
@@ -896,21 +889,14 @@ QAbstractAnimation *QDeclarativeScriptAction::qtAnimation()
However, with this code, the \c transformOrigin is not set until \e after
the animation, as a \l State is taken to define the values at the \e end of
a transition. The animation would rotate at the default \c transformOrigin,
- then jump to \c Item.BottomRight. To fix this, insert a PropertyChanges
+ then jump to \c Item.BottomRight. To fix this, insert a PropertyAction
before the RotationAnimation begins:
- \qml
- transitions: Transition {
- SequentialAnimation {
- PropertyAction { target: rect; property: "transformOrigin" }
- RotationAnimation { ... }
- }
- }
- \endqml
+ \snippet doc/src/snippets/declarative/propertyaction-sequential.qml sequential
This immediately sets the \c transformOrigin property to the value defined
in the end state of the \l Transition (i.e. the value defined in the
- PropertyChanges object) so that the rotation animation begins with the
+ PropertyAction object) so that the rotation animation begins with the
correct transform origin.
\sa {QML Animation}, QtDeclarative
@@ -1195,7 +1181,9 @@ void QDeclarativeNumberAnimation::init()
\qml
Item {
- states: [ ... ]
+ states: [
+ // ...
+ ]
transition: Transition {
NumberAnimation { properties: "x"; from: 100; duration: 200 }
@@ -1421,7 +1409,9 @@ QDeclarativeRotationAnimation::~QDeclarativeRotationAnimation()
\qml
Item {
- states: [ ... ]
+ states: [
+ // ...
+ ]
transition: Transition {
RotationAnimation { properties: "angle"; from: 100; duration: 2000 }
@@ -2253,7 +2243,7 @@ void QDeclarativePropertyAnimation::setProperties(const QString &prop)
width: 100; height: 100
color: Qt.rgba(0,0,1)
//need to explicitly specify target and property
- NumberAnimation { id: theAnim; target: theRect; property: "x" to: 500 }
+ NumberAnimation { id: theAnim; target: theRect; property: "x"; to: 500 }
MouseArea {
anchors.fill: parent
onClicked: theAnim.start()
@@ -2555,7 +2545,7 @@ void QDeclarativeParentAnimation::setNewParent(QDeclarativeItem *newParent)
ParentAnimation {
target: myItem
via: topLevelItem
- ...
+ // ...
}
\endqml
*/
diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h
index 15bda3c..048ecb1 100644
--- a/src/declarative/util/qdeclarativeanimation_p_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p_p.h
@@ -210,7 +210,7 @@ public:
: running(false), paused(false), alwaysRunToEnd(false),
connectedTimeLine(false), componentComplete(true),
avoidPropertyValueSourceStart(false), disableUserControl(false),
- loopCount(1), group(0) {}
+ registered(false), loopCount(1), group(0) {}
bool running:1;
bool paused:1;
@@ -219,6 +219,7 @@ public:
bool componentComplete:1;
bool avoidPropertyValueSourceStart:1;
bool disableUserControl:1;
+ bool registered:1;
int loopCount;
diff --git a/src/declarative/util/qdeclarativeapplication.cpp b/src/declarative/util/qdeclarativeapplication.cpp
new file mode 100644
index 0000000..e0f6df2
--- /dev/null
+++ b/src/declarative/util/qdeclarativeapplication.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 "qdeclarativeapplication_p.h"
+#include <private/qobject_p.h>
+#include <QtGui/QApplication>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeApplicationPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeApplication)
+public:
+ QDeclarativeApplicationPrivate() : active(QApplication::activeWindow() != 0),
+ layoutDirection(QApplication::layoutDirection()) {}
+ bool active;
+ Qt::LayoutDirection layoutDirection;
+};
+
+/*
+ This object and its properties are documented as part of the Qt object,
+ in qdeclarativengine.cpp
+*/
+
+QDeclarativeApplication::QDeclarativeApplication(QObject *parent) : QObject(*new QDeclarativeApplicationPrivate(), parent)
+{
+ if (qApp)
+ qApp->installEventFilter(this);
+}
+
+QDeclarativeApplication::~QDeclarativeApplication()
+{
+}
+
+bool QDeclarativeApplication::active() const
+{
+ Q_D(const QDeclarativeApplication);
+ return d->active;
+}
+
+Qt::LayoutDirection QDeclarativeApplication::layoutDirection() const
+{
+ Q_D(const QDeclarativeApplication);
+ return d->layoutDirection;
+}
+
+bool QDeclarativeApplication::eventFilter(QObject *obj, QEvent *event)
+{
+ Q_UNUSED(obj)
+ Q_D(QDeclarativeApplication);
+ if (event->type() == QEvent::ApplicationActivate
+ || event->type() == QEvent::ApplicationDeactivate) {
+ bool active = d->active;
+ if (event->type() == QEvent::ApplicationActivate)
+ active = true;
+ else if (event->type() == QEvent::ApplicationDeactivate)
+ active = false;
+
+ if (d->active != active) {
+ d->active = active;
+ emit activeChanged();
+ }
+ }
+ if (event->type() == QEvent::LayoutDirectionChange) {
+ Qt::LayoutDirection direction = QApplication::layoutDirection();
+ if (d->layoutDirection != direction) {
+ d->layoutDirection = direction;
+ emit layoutDirectionChanged();
+ }
+ }
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativeapplication_p.h b/src/declarative/util/qdeclarativeapplication_p.h
new file mode 100644
index 0000000..caaed18
--- /dev/null
+++ b/src/declarative/util/qdeclarativeapplication_p.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 QDECLARATIVEAPPLICATION_P_H
+#define QDECLARATIVEAPPLICATION_P_H
+
+#include <QtCore/QObject>
+#include <qdeclarative.h>
+#include <private/qdeclarativeglobal_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeApplicationPrivate;
+class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeApplication : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool active READ active NOTIFY activeChanged)
+ Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged)
+
+public:
+ explicit QDeclarativeApplication(QObject *parent = 0);
+ virtual ~QDeclarativeApplication();
+ bool active() const;
+ Qt::LayoutDirection layoutDirection() const;
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *event);
+
+Q_SIGNALS:
+ void activeChanged();
+ void layoutDirectionChanged();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeApplication)
+ Q_DECLARE_PRIVATE(QDeclarativeApplication)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeApplication)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEAPPLICATION_P_H
diff --git a/src/declarative/util/qdeclarativeconnections.cpp b/src/declarative/util/qdeclarativeconnections.cpp
index 6f35957..5a66aab 100644
--- a/src/declarative/util/qdeclarativeconnections.cpp
+++ b/src/declarative/util/qdeclarativeconnections.cpp
@@ -45,6 +45,7 @@
#include <qdeclarativeproperty_p.h>
#include <qdeclarativeboundsignal_p.h>
#include <qdeclarativecontext.h>
+#include <qdeclarativecontext_p.h>
#include <qdeclarativeinfo.h>
#include <QtCore/qdebug.h>
@@ -71,8 +72,8 @@ public:
/*!
\qmlclass Connections QDeclarativeConnections
- \ingroup qml-utility-elements
- \since 4.7
+ \ingroup qml-utility-elements
+ \since 4.7
\brief A Connections element describes generalized connections to signals.
A Connections object creates a connection to a QML signal.
@@ -82,7 +83,7 @@ public:
\qml
MouseArea {
- onClicked: { foo(...) }
+ onClicked: { foo(parameters) }
}
\endqml
@@ -103,7 +104,7 @@ public:
\qml
MouseArea {
Connections {
- onClicked: foo(...)
+ onClicked: foo(parameters)
}
}
\endqml
@@ -115,10 +116,10 @@ public:
MouseArea {
id: area
}
- ...
+ // ...
Connections {
target: area
- onClicked: foo(...)
+ onClicked: foo(parameters)
}
\endqml
@@ -257,7 +258,11 @@ void QDeclarativeConnections::connectSignals()
if (prop.isValid() && (prop.type() & QDeclarativeProperty::SignalProperty)) {
QDeclarativeBoundSignal *signal =
new QDeclarativeBoundSignal(target(), prop.method(), this);
- signal->setExpression(new QDeclarativeExpression(qmlContext(this), 0, script));
+ QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(this), 0, script);
+ QDeclarativeData *ddata = QDeclarativeData::get(this);
+ if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
+ expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber);
+ signal->setExpression(expression);
d->boundsignals += signal;
} else {
if (!d->ignoreUnknownSignals)
diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp
index d39da3f..eba9cf9 100644
--- a/src/declarative/util/qdeclarativefontloader.cpp
+++ b/src/declarative/util/qdeclarativefontloader.cpp
@@ -262,8 +262,18 @@ void QDeclarativeFontLoader::updateFontInfo(const QString& name, QDeclarativeFon
Example:
\qml
- FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" }
- Text { text: "Fancy font"; font.family: webFont.name }
+ Item {
+ width: 200; height: 50
+
+ FontLoader {
+ id: webFont
+ source: "http://www.mysite.com/myfont.ttf"
+ }
+ Text {
+ text: "Fancy font"
+ font.family: webFont.name
+ }
+ }
\endqml
*/
QString QDeclarativeFontLoader::name() const
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index e5ba5e0..80b52fd 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -108,9 +108,9 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM
The following example shows a ListModel containing three elements, with the roles
"name" and "cost".
- \beginfloatright
+ \div {float-right}
\inlineimage listmodel.png
- \endfloat
+ \enddiv
\snippet doc/src/snippets/declarative/listmodel.qml 0
@@ -133,9 +133,9 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM
The delegate displays all the fruit attributes:
- \beginfloatright
+ \div {float-right}
\inlineimage listmodel-nested.png
- \endfloat
+ \enddiv
\snippet doc/src/snippets/declarative/listmodel-nested.qml delegate
@@ -559,6 +559,14 @@ QScriptValue QDeclarativeListModel::get(int index) const
*/
void QDeclarativeListModel::set(int index, const QScriptValue& valuemap)
{
+ QList<int> roles;
+ set(index, valuemap, &roles);
+ if (!roles.isEmpty() && !inWorkerThread())
+ emit itemsChanged(index, 1, roles);
+}
+
+void QDeclarativeListModel::set(int index, const QScriptValue& valuemap, QList<int> *roles)
+{
if (!valuemap.isObject() || valuemap.isArray()) {
qmlInfo(this) << tr("set: value is not an object");
return;
@@ -571,14 +579,10 @@ void QDeclarativeListModel::set(int index, const QScriptValue& valuemap)
if (index == count()) {
append(valuemap);
} else {
- QList<int> roles;
if (m_flat)
- m_flat->set(index, valuemap, &roles);
+ m_flat->set(index, valuemap, roles);
else
- m_nested->set(index, valuemap, &roles);
-
- if (!inWorkerThread())
- emit itemsChanged(index, 1, roles);
+ m_nested->set(index, valuemap, roles);
}
}
@@ -597,19 +601,23 @@ void QDeclarativeListModel::set(int index, const QScriptValue& valuemap)
*/
void QDeclarativeListModel::setProperty(int index, const QString& property, const QVariant& value)
{
+ QList<int> roles;
+ setProperty(index, property, value, &roles);
+ if (!roles.isEmpty() && !inWorkerThread())
+ emit itemsChanged(index, 1, roles);
+}
+
+void QDeclarativeListModel::setProperty(int index, const QString& property, const QVariant& value, QList<int> *roles)
+{
if (count() == 0 || index >= count() || index < 0) {
qmlInfo(this) << tr("set: index %1 out of range").arg(index);
return;
}
- QList<int> roles;
if (m_flat)
- m_flat->setProperty(index, property, value, &roles);
+ m_flat->setProperty(index, property, value, roles);
else
- m_nested->setProperty(index, property, value, &roles);
-
- if (!inWorkerThread())
- emit itemsChanged(index, 1, roles);
+ m_nested->setProperty(index, property, value, roles);
}
/*!
@@ -1011,9 +1019,11 @@ void FlatListModel::setProperty(int index, const QString& property, const QVaria
} else {
role = iter.value();
}
- roles->append(role);
- m_values[index][role] = value;
+ if (m_values[index][role] != value) {
+ roles->append(role);
+ m_values[index][role] = value;
+ }
}
void FlatListModel::move(int from, int to, int n)
@@ -1043,6 +1053,10 @@ bool FlatListModel::addValue(const QScriptValue &value, QHash<int, QVariant> *ro
iter = m_strings.insert(name, role);
if (roles)
roles->append(role);
+ } else {
+ int role = iter.value();
+ if (roles && row->contains(role) && row->value(role) != v)
+ roles->append(role);
}
row->insert(*iter, v);
}
@@ -1151,14 +1165,14 @@ void FlatListScriptClass::setProperty(Object *obj, const Identifier &name, const
QHash<int, QVariant> &row = m_model->m_values[index];
row[role] = value.toVariant();
+ QList<int> roles;
+ roles << role;
if (m_model->m_parentAgent) {
// This is the list in the worker thread, so tell the agent to
// emit itemsChanged() later
- m_model->m_parentAgent->changedData(index, 1);
+ m_model->m_parentAgent->changedData(index, 1, roles);
} else {
// This is the list in the main thread, so emit itemsChanged()
- QList<int> roles;
- roles << role;
emit m_model->m_listModel->itemsChanged(index, 1, roles);
}
}
@@ -1350,7 +1364,9 @@ void NestedListModel::set(int index, const QScriptValue& valuemap, QList<int> *r
Q_ASSERT(index >=0 && index < count());
ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- node->setObjectValue(valuemap);
+ bool emitItemsChanged = node->setObjectValue(valuemap);
+ if (!emitItemsChanged)
+ return;
QScriptValueIterator it(valuemap);
while (it.hasNext()) {
@@ -1369,7 +1385,9 @@ void NestedListModel::setProperty(int index, const QString& property, const QVar
Q_ASSERT(index >=0 && index < count());
ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- node->setProperty(property, value);
+ bool emitItemsChanged = node->setProperty(property, value);
+ if (!emitItemsChanged)
+ return;
int r = roleStrings.indexOf(property);
if (r < 0) {
@@ -1441,24 +1459,37 @@ void ModelNode::clear()
properties.clear();
}
-void ModelNode::setObjectValue(const QScriptValue& valuemap, bool writeToCache) {
+bool ModelNode::setObjectValue(const QScriptValue& valuemap, bool writeToCache)
+{
+ bool emitItemsChanged = false;
+
QScriptValueIterator it(valuemap);
while (it.hasNext()) {
it.next();
+ ModelNode *prev = properties.value(it.name());
ModelNode *value = new ModelNode(m_model);
QScriptValue v = it.value();
+
if (v.isArray()) {
value->isArray = true;
value->setListValue(v);
+ if (writeToCache && objectCache)
+ objectCache->setValue(it.name().toUtf8(), QVariant::fromValue(value->model(m_model)));
+ emitItemsChanged = true; // for now, too inefficient to check whether list and sublists have changed
} else {
value->values << v.toVariant();
if (writeToCache && objectCache)
objectCache->setValue(it.name().toUtf8(), value->values.last());
+ if (!emitItemsChanged && prev && prev->values.count() == 1
+ && prev->values[0] != value->values.last()) {
+ emitItemsChanged = true;
+ }
}
if (properties.contains(it.name()))
delete properties[it.name()];
properties.insert(it.name(), value);
}
+ return emitItemsChanged;
}
void ModelNode::setListValue(const QScriptValue& valuelist) {
@@ -1481,9 +1512,12 @@ void ModelNode::setListValue(const QScriptValue& valuelist) {
}
}
-void ModelNode::setProperty(const QString& prop, const QVariant& val) {
+bool ModelNode::setProperty(const QString& prop, const QVariant& val) {
QHash<QString, ModelNode *>::const_iterator it = properties.find(prop);
+ bool emitItemsChanged = false;
if (it != properties.end()) {
+ if (val != (*it)->values[0])
+ emitItemsChanged = true;
(*it)->values[0] = val;
} else {
ModelNode *n = new ModelNode(m_model);
@@ -1492,6 +1526,7 @@ void ModelNode::setProperty(const QString& prop, const QVariant& val) {
}
if (objectCache)
objectCache->setValue(prop.toUtf8(), val);
+ return emitItemsChanged;
}
void ModelNode::updateListIndexes()
@@ -1559,7 +1594,7 @@ ModelObject::ModelObject(ModelNode *node, NestedListModel *model, QScriptEngine
void ModelObject::setValue(const QByteArray &name, const QVariant &val)
{
m_meta->setValue(name, val);
- setProperty(name.constData(), val);
+ //setProperty(name.constData(), val);
}
void ModelObject::setNodeUpdatesEnabled(bool enable)
@@ -1586,9 +1621,9 @@ void ModelNodeMetaObject::propertyWritten(int index)
QScriptValue sv = m_seng->newObject();
sv.setProperty(propName, m_seng->newVariant(value));
- m_obj->m_node->setObjectValue(sv, false);
-
- m_obj->m_node->changedProperty(propName);
+ bool changed = m_obj->m_node->setObjectValue(sv, false);
+ if (changed)
+ m_obj->m_node->changedProperty(propName);
}
diff --git a/src/declarative/util/qdeclarativelistmodel_p.h b/src/declarative/util/qdeclarativelistmodel_p.h
index 5f73557..7870b4f 100644
--- a/src/declarative/util/qdeclarativelistmodel_p.h
+++ b/src/declarative/util/qdeclarativelistmodel_p.h
@@ -103,6 +103,9 @@ private:
// Constructs a flat list model for a worker agent
QDeclarativeListModel(const QDeclarativeListModel *orig, QDeclarativeListModelWorkerAgent *parent);
+ void set(int index, const QScriptValue&, QList<int> *roles);
+ void setProperty(int index, const QString& property, const QVariant& value, QList<int> *roles);
+
bool flatten();
bool inWorkerThread() const;
diff --git a/src/declarative/util/qdeclarativelistmodel_p_p.h b/src/declarative/util/qdeclarativelistmodel_p_p.h
index 5ba702c..7236e8b 100644
--- a/src/declarative/util/qdeclarativelistmodel_p_p.h
+++ b/src/declarative/util/qdeclarativelistmodel_p_p.h
@@ -190,7 +190,7 @@ public:
bool insert(int index, const QScriptValue&);
QScriptValue get(int index) const;
void set(int index, const QScriptValue&, QList<int> *roles);
- void setProperty(int index, const QString& property, const QVariant& value, QList<int> *role);
+ void setProperty(int index, const QString& property, const QVariant& value, QList<int> *roles);
void move(int from, int to, int count);
QVariant valueForNode(ModelNode *, bool *hasNested = 0) const;
@@ -255,9 +255,9 @@ struct ModelNode
QDeclarativeListModel *model(const NestedListModel *model);
ModelObject *object(const NestedListModel *model);
- void setObjectValue(const QScriptValue& valuemap, bool writeToCache = true);
+ bool setObjectValue(const QScriptValue& valuemap, bool writeToCache = true);
void setListValue(const QScriptValue& valuelist);
- void setProperty(const QString& prop, const QVariant& val);
+ bool setProperty(const QString& prop, const QVariant& val);
void changedProperty(const QString &name) const;
void updateListIndexes();
static void dump(ModelNode *node, int ind);
diff --git a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp
index 69353f1..befa8eb 100644
--- a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp
+++ b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp
@@ -60,25 +60,25 @@ void QDeclarativeListModelWorkerAgent::Data::clearChange()
void QDeclarativeListModelWorkerAgent::Data::insertChange(int index, int count)
{
- Change c = { Change::Inserted, index, count, 0 };
+ Change c = { Change::Inserted, index, count, 0, QList<int>() };
changes << c;
}
void QDeclarativeListModelWorkerAgent::Data::removeChange(int index, int count)
{
- Change c = { Change::Removed, index, count, 0 };
+ Change c = { Change::Removed, index, count, 0, QList<int>() };
changes << c;
}
void QDeclarativeListModelWorkerAgent::Data::moveChange(int index, int count, int to)
{
- Change c = { Change::Moved, index, count, to };
+ Change c = { Change::Moved, index, count, to, QList<int>() };
changes << c;
}
-void QDeclarativeListModelWorkerAgent::Data::changedChange(int index, int count)
+void QDeclarativeListModelWorkerAgent::Data::changedChange(int index, int count, const QList<int> &roles)
{
- Change c = { Change::Changed, index, count, 0 };
+ Change c = { Change::Changed, index, count, 0, roles };
changes << c;
}
@@ -165,14 +165,18 @@ QScriptValue QDeclarativeListModelWorkerAgent::get(int index) const
void QDeclarativeListModelWorkerAgent::set(int index, const QScriptValue &value)
{
- m_copy->set(index, value);
- data.changedChange(index, 1);
+ QList<int> roles;
+ m_copy->set(index, value, &roles);
+ if (!roles.isEmpty())
+ data.changedChange(index, 1, roles);
}
void QDeclarativeListModelWorkerAgent::setProperty(int index, const QString& property, const QVariant& value)
{
- m_copy->setProperty(index, property, value);
- data.changedChange(index, 1);
+ QList<int> roles;
+ m_copy->setProperty(index, property, value, &roles);
+ if (!roles.isEmpty())
+ data.changedChange(index, 1, roles);
}
void QDeclarativeListModelWorkerAgent::move(int from, int to, int count)
@@ -194,9 +198,9 @@ void QDeclarativeListModelWorkerAgent::sync()
mutex.unlock();
}
-void QDeclarativeListModelWorkerAgent::changedData(int index, int count)
+void QDeclarativeListModelWorkerAgent::changedData(int index, int count, const QList<int> &roles)
{
- data.changedChange(index, count);
+ data.changedChange(index, count, roles);
}
bool QDeclarativeListModelWorkerAgent::event(QEvent *e)
@@ -255,7 +259,7 @@ bool QDeclarativeListModelWorkerAgent::event(QEvent *e)
emit m_orig->itemsMoved(change.index, change.to, change.count);
break;
case Change::Changed:
- emit m_orig->itemsChanged(change.index, change.count, orig->m_roles.keys());
+ emit m_orig->itemsChanged(change.index, change.count, change.roles);
break;
}
}
diff --git a/src/declarative/util/qdeclarativelistmodelworkeragent_p.h b/src/declarative/util/qdeclarativelistmodelworkeragent_p.h
index fbe0195..4c800e9 100644
--- a/src/declarative/util/qdeclarativelistmodelworkeragent_p.h
+++ b/src/declarative/util/qdeclarativelistmodelworkeragent_p.h
@@ -124,6 +124,7 @@ private:
int index; // Inserted/Removed/Moved/Changed
int count; // Inserted/Removed/Moved/Changed
int to; // Moved
+ QList<int> roles;
};
struct Data {
@@ -133,7 +134,7 @@ private:
void insertChange(int index, int count);
void removeChange(int index, int count);
void moveChange(int index, int count, int to);
- void changedChange(int index, int count);
+ void changedChange(int index, int count, const QList<int> &roles);
};
Data data;
@@ -143,7 +144,7 @@ private:
QDeclarativeListModel *list;
};
- void changedData(int index, int count);
+ void changedData(int index, int count, const QList<int> &roles);
QAtomicInt m_ref;
QDeclarativeListModel *m_orig;
diff --git a/src/declarative/util/qdeclarativeopenmetaobject.cpp b/src/declarative/util/qdeclarativeopenmetaobject.cpp
index 510a0c1..0ceda35 100644
--- a/src/declarative/util/qdeclarativeopenmetaobject.cpp
+++ b/src/declarative/util/qdeclarativeopenmetaobject.cpp
@@ -97,7 +97,6 @@ int QDeclarativeOpenMetaObjectType::createProperty(const QByteArray &name)
int id = d->mob.propertyCount();
d->mob.addSignal("__" + QByteArray::number(id) + "()");
QMetaPropertyBuilder build = d->mob.addProperty(name, "QVariant", id);
- build.setDynamic(true);
propertyCreated(id, build);
qFree(d->mem);
d->mem = d->mob.toMetaObject();
diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp
index 1dd01f6..5190eab 100644
--- a/src/declarative/util/qdeclarativepixmapcache.cpp
+++ b/src/declarative/util/qdeclarativepixmapcache.cpp
@@ -959,20 +959,20 @@ QRect QDeclarativePixmap::rect() const
void QDeclarativePixmap::load(QDeclarativeEngine *engine, const QUrl &url)
{
- load(engine, url, QSize(), false);
+ load(engine, url, QSize(), QDeclarativePixmap::Cache);
}
-void QDeclarativePixmap::load(QDeclarativeEngine *engine, const QUrl &url, bool async)
+void QDeclarativePixmap::load(QDeclarativeEngine *engine, const QUrl &url, QDeclarativePixmap::Options options)
{
- load(engine, url, QSize(), async);
+ load(engine, url, QSize(), options);
}
void QDeclarativePixmap::load(QDeclarativeEngine *engine, const QUrl &url, const QSize &size)
{
- load(engine, url, size, false);
+ load(engine, url, size, QDeclarativePixmap::Cache);
}
-void QDeclarativePixmap::load(QDeclarativeEngine *engine, const QUrl &url, const QSize &requestSize, bool async)
+void QDeclarativePixmap::load(QDeclarativeEngine *engine, const QUrl &url, const QSize &requestSize, QDeclarativePixmap::Options options)
{
if (d) { d->release(); d = 0; }
@@ -982,19 +982,20 @@ void QDeclarativePixmap::load(QDeclarativeEngine *engine, const QUrl &url, const
QHash<QDeclarativePixmapKey, QDeclarativePixmapData *>::Iterator iter = store->m_cache.find(key);
if (iter == store->m_cache.end()) {
- if (async) {
+ if (options & QDeclarativePixmap::Asynchronous) {
// pixmaps can only be loaded synchronously
if (url.scheme() == QLatin1String("image")
&& QDeclarativeEnginePrivate::get(engine)->getImageProviderType(url) == QDeclarativeImageProvider::Pixmap) {
- async = false;
+ options &= ~QDeclarativePixmap::Asynchronous;
}
}
- if (!async) {
+ if (!(options & QDeclarativePixmap::Asynchronous)) {
bool ok = false;
d = createPixmapDataSync(engine, url, requestSize, &ok);
if (ok) {
- d->addToCache();
+ if (options & QDeclarativePixmap::Cache)
+ d->addToCache();
return;
}
if (d) // loadable, but encountered error while loading
@@ -1007,7 +1008,8 @@ void QDeclarativePixmap::load(QDeclarativeEngine *engine, const QUrl &url, const
QDeclarativePixmapReader *reader = QDeclarativePixmapReader::instance(engine);
d = new QDeclarativePixmapData(url, requestSize);
- d->addToCache();
+ if (options & QDeclarativePixmap::Cache)
+ d->addToCache();
d->reply = reader->getImage(d);
} else {
diff --git a/src/declarative/util/qdeclarativepixmapcache_p.h b/src/declarative/util/qdeclarativepixmapcache_p.h
index f9ebf3b..1cf76dd 100644
--- a/src/declarative/util/qdeclarativepixmapcache_p.h
+++ b/src/declarative/util/qdeclarativepixmapcache_p.h
@@ -66,6 +66,12 @@ public:
enum Status { Null, Ready, Error, Loading };
+ enum Option {
+ Asynchronous = 0x00000001,
+ Cache = 0x00000002
+ };
+ Q_DECLARE_FLAGS(Options, Option)
+
bool isNull() const;
bool isReady() const;
bool isError() const;
@@ -85,9 +91,9 @@ public:
inline operator const QPixmap &() const;
void load(QDeclarativeEngine *, const QUrl &);
- void load(QDeclarativeEngine *, const QUrl &, bool);
+ void load(QDeclarativeEngine *, const QUrl &, QDeclarativePixmap::Options options);
void load(QDeclarativeEngine *, const QUrl &, const QSize &);
- void load(QDeclarativeEngine *, const QUrl &, const QSize &, bool);
+ void load(QDeclarativeEngine *, const QUrl &, const QSize &, QDeclarativePixmap::Options options);
void clear();
void clear(QObject *);
@@ -107,6 +113,8 @@ inline QDeclarativePixmap::operator const QPixmap &() const
return pixmap();
}
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePixmap::Options)
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp
index 1c5d463..9bcb263 100644
--- a/src/declarative/util/qdeclarativepropertychanges.cpp
+++ b/src/declarative/util/qdeclarativepropertychanges.cpp
@@ -42,6 +42,9 @@
#include "private/qdeclarativepropertychanges_p.h"
#include "private/qdeclarativeopenmetaobject_p.h"
+#include "private/qdeclarativerewrite_p.h"
+#include "private/qdeclarativeengine_p.h"
+#include "private/qdeclarativecompiler_p.h"
#include <qdeclarativeinfo.h>
#include <qdeclarativecustomparser_p.h>
@@ -217,11 +220,22 @@ public:
void decode();
- QList<QPair<QByteArray, QVariant> > properties;
- QList<QPair<QByteArray, QDeclarativeExpression *> > expressions;
+ class ExpressionChange {
+ public:
+ ExpressionChange(const QString &_name,
+ QDeclarativeBinding::Identifier _id,
+ QDeclarativeExpression *_expr)
+ : name(_name), id(_id), expression(_expr) {}
+ QString name;
+ QDeclarativeBinding::Identifier id;
+ QDeclarativeExpression *expression;
+ };
+
+ QList<QPair<QString, QVariant> > properties;
+ QList<ExpressionChange> expressions;
QList<QDeclarativeReplaceSignalHandler*> signalReplacements;
- QDeclarativeProperty property(const QByteArray &);
+ QDeclarativeProperty property(const QString &);
};
void
@@ -267,6 +281,7 @@ QDeclarativePropertyChangesParser::compile(const QList<QDeclarativeCustomParserP
QDeclarativeParser::Variant v = qvariant_cast<QDeclarativeParser::Variant>(data.at(ii).second);
QVariant var;
bool isScript = v.isScript();
+ QDeclarativeBinding::Identifier id = 0;
switch(v.type()) {
case QDeclarativeParser::Variant::Boolean:
var = QVariant(v.asBoolean());
@@ -280,10 +295,17 @@ QDeclarativePropertyChangesParser::compile(const QList<QDeclarativeCustomParserP
case QDeclarativeParser::Variant::Invalid:
case QDeclarativeParser::Variant::Script:
var = QVariant(v.asScript());
+ {
+ // Pre-rewrite the expression
+ QString expression = v.asScript();
+ id = rewriteBinding(expression, data.at(ii).first); //### recreates the AST, which is slow
+ }
break;
}
- ds << data.at(ii).first << isScript << var;
+ ds << QString::fromUtf8(data.at(ii).first) << isScript << var;
+ if (isScript)
+ ds << id;
}
return rv;
@@ -300,12 +322,15 @@ void QDeclarativePropertyChangesPrivate::decode()
int count;
ds >> count;
for (int ii = 0; ii < count; ++ii) {
- QByteArray name;
+ QString name;
bool isScript;
QVariant data;
+ QDeclarativeBinding::Identifier id = QDeclarativeBinding::Invalid;
ds >> name;
ds >> isScript;
ds >> data;
+ if (isScript)
+ ds >> id;
QDeclarativeProperty prop = property(name); //### better way to check for signal property?
if (prop.type() & QDeclarativeProperty::SignalProperty) {
@@ -322,7 +347,7 @@ void QDeclarativePropertyChangesPrivate::decode()
QDeclarativeData *ddata = QDeclarativeData::get(q);
if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber);
- expressions << qMakePair(name, expression);
+ expressions << ExpressionChange(name, id, expression);
} else {
properties << qMakePair(name, data);
}
@@ -350,7 +375,7 @@ QDeclarativePropertyChanges::~QDeclarativePropertyChanges()
{
Q_D(QDeclarativePropertyChanges);
for(int ii = 0; ii < d->expressions.count(); ++ii)
- delete d->expressions.at(ii).second;
+ delete d->expressions.at(ii).expression;
for(int ii = 0; ii < d->signalReplacements.count(); ++ii)
delete d->signalReplacements.at(ii);
}
@@ -389,15 +414,15 @@ void QDeclarativePropertyChanges::setRestoreEntryValues(bool v)
}
QDeclarativeProperty
-QDeclarativePropertyChangesPrivate::property(const QByteArray &property)
+QDeclarativePropertyChangesPrivate::property(const QString &property)
{
Q_Q(QDeclarativePropertyChanges);
- QDeclarativeProperty prop(object, QString::fromUtf8(property), qmlContext(q));
+ QDeclarativeProperty prop(object, property, qmlContext(q));
if (!prop.isValid()) {
- qmlInfo(q) << QDeclarativePropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(property));
+ qmlInfo(q) << QDeclarativePropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(property);
return QDeclarativeProperty();
} else if (!(prop.type() & QDeclarativeProperty::SignalProperty) && !prop.isWritable()) {
- qmlInfo(q) << QDeclarativePropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(QString::fromUtf8(property));
+ qmlInfo(q) << QDeclarativePropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(property);
return QDeclarativeProperty();
}
return prop;
@@ -413,9 +438,7 @@ QDeclarativePropertyChanges::ActionList QDeclarativePropertyChanges::actions()
for (int ii = 0; ii < d->properties.count(); ++ii) {
- QByteArray property = d->properties.at(ii).first;
-
- QDeclarativeAction a(d->object, QString::fromUtf8(property),
+ QDeclarativeAction a(d->object, d->properties.at(ii).first,
qmlContext(this), d->properties.at(ii).second);
if (a.property.isValid()) {
@@ -437,7 +460,7 @@ QDeclarativePropertyChanges::ActionList QDeclarativePropertyChanges::actions()
for (int ii = 0; ii < d->expressions.count(); ++ii) {
- QByteArray property = d->expressions.at(ii).first;
+ const QString &property = d->expressions.at(ii).name;
QDeclarativeProperty prop = d->property(property);
if (prop.isValid()) {
@@ -446,16 +469,20 @@ QDeclarativePropertyChanges::ActionList QDeclarativePropertyChanges::actions()
a.property = prop;
a.fromValue = a.property.read();
a.specifiedObject = d->object;
- a.specifiedProperty = QString::fromUtf8(property);
+ a.specifiedProperty = property;
if (d->isExplicit) {
- a.toValue = d->expressions.at(ii).second->evaluate();
+ a.toValue = d->expressions.at(ii).expression->evaluate();
} else {
- QDeclarativeExpression *e = d->expressions.at(ii).second;
- QDeclarativeBinding *newBinding =
- new QDeclarativeBinding(e->expression(), object(), qmlContext(this));
+ QDeclarativeExpression *e = d->expressions.at(ii).expression;
+
+ QDeclarativeBinding::Identifier id = d->expressions.at(ii).id;
+ QDeclarativeBinding *newBinding = id != QDeclarativeBinding::Invalid ? QDeclarativeBinding::createBinding(id, object(), qmlContext(this), e->sourceFile(), e->lineNumber()) : 0;
+ if (!newBinding) {
+ newBinding = new QDeclarativeBinding(e->expression(), object(), qmlContext(this));
+ newBinding->setSourceLocation(e->sourceFile(), e->lineNumber());
+ }
newBinding->setTarget(prop);
- newBinding->setSourceLocation(e->sourceFile(), e->lineNumber());
a.toBinding = newBinding;
a.deletableToBinding = true;
}
@@ -498,10 +525,10 @@ void QDeclarativePropertyChanges::setIsExplicit(bool e)
d->isExplicit = e;
}
-bool QDeclarativePropertyChanges::containsValue(const QByteArray &name) const
+bool QDeclarativePropertyChanges::containsValue(const QString &name) const
{
Q_D(const QDeclarativePropertyChanges);
- typedef QPair<QByteArray, QVariant> PropertyEntry;
+ typedef QPair<QString, QVariant> PropertyEntry;
QListIterator<PropertyEntry> propertyIterator(d->properties);
while (propertyIterator.hasNext()) {
@@ -514,15 +541,15 @@ bool QDeclarativePropertyChanges::containsValue(const QByteArray &name) const
return false;
}
-bool QDeclarativePropertyChanges::containsExpression(const QByteArray &name) const
+bool QDeclarativePropertyChanges::containsExpression(const QString &name) const
{
Q_D(const QDeclarativePropertyChanges);
- typedef QPair<QByteArray, QDeclarativeExpression *> ExpressionEntry;
+ typedef QDeclarativePropertyChangesPrivate::ExpressionChange ExpressionEntry;
QListIterator<ExpressionEntry> expressionIterator(d->expressions);
while (expressionIterator.hasNext()) {
const ExpressionEntry &entry = expressionIterator.next();
- if (entry.first == name) {
+ if (entry.name == name) {
return true;
}
}
@@ -530,21 +557,21 @@ bool QDeclarativePropertyChanges::containsExpression(const QByteArray &name) con
return false;
}
-bool QDeclarativePropertyChanges::containsProperty(const QByteArray &name) const
+bool QDeclarativePropertyChanges::containsProperty(const QString &name) const
{
return containsValue(name) || containsExpression(name);
}
-void QDeclarativePropertyChanges::changeValue(const QByteArray &name, const QVariant &value)
+void QDeclarativePropertyChanges::changeValue(const QString &name, const QVariant &value)
{
Q_D(QDeclarativePropertyChanges);
- typedef QPair<QByteArray, QVariant> PropertyEntry;
- typedef QPair<QByteArray, QDeclarativeExpression *> ExpressionEntry;
+ typedef QPair<QString, QVariant> PropertyEntry;
+ typedef QDeclarativePropertyChangesPrivate::ExpressionChange ExpressionEntry;
QMutableListIterator<ExpressionEntry> expressionIterator(d->expressions);
while (expressionIterator.hasNext()) {
const ExpressionEntry &entry = expressionIterator.next();
- if (entry.first == name) {
+ if (entry.name == name) {
expressionIterator.remove();
if (state() && state()->isStateActive()) {
QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name));
@@ -576,7 +603,7 @@ void QDeclarativePropertyChanges::changeValue(const QByteArray &name, const QVar
action.property = d->property(name);
action.fromValue = action.property.read();
action.specifiedObject = object();
- action.specifiedProperty = QString::fromUtf8(name);
+ action.specifiedProperty = name;
action.toValue = value;
propertyIterator.insert(PropertyEntry(name, value));
@@ -589,11 +616,11 @@ void QDeclarativePropertyChanges::changeValue(const QByteArray &name, const QVar
}
}
-void QDeclarativePropertyChanges::changeExpression(const QByteArray &name, const QString &expression)
+void QDeclarativePropertyChanges::changeExpression(const QString &name, const QString &expression)
{
Q_D(QDeclarativePropertyChanges);
- typedef QPair<QByteArray, QVariant> PropertyEntry;
- typedef QPair<QByteArray, QDeclarativeExpression *> ExpressionEntry;
+ typedef QPair<QString, QVariant> PropertyEntry;
+ typedef QDeclarativePropertyChangesPrivate::ExpressionChange ExpressionEntry;
bool hadValue = false;
@@ -610,8 +637,8 @@ void QDeclarativePropertyChanges::changeExpression(const QByteArray &name, const
QMutableListIterator<ExpressionEntry> expressionIterator(d->expressions);
while (expressionIterator.hasNext()) {
const ExpressionEntry &entry = expressionIterator.next();
- if (entry.first == name) {
- entry.second->setExpression(expression);
+ if (entry.name == name) {
+ entry.expression->setExpression(expression);
if (state() && state()->isStateActive()) {
QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name));
if (oldBinding) {
@@ -628,7 +655,7 @@ void QDeclarativePropertyChanges::changeExpression(const QByteArray &name, const
}
QDeclarativeExpression *newExpression = new QDeclarativeExpression(qmlContext(this), d->object, expression);
- expressionIterator.insert(ExpressionEntry(name, newExpression));
+ expressionIterator.insert(ExpressionEntry(name, QDeclarativeBinding::Invalid, newExpression));
if (state() && state()->isStateActive()) {
if (hadValue) {
@@ -647,7 +674,7 @@ void QDeclarativePropertyChanges::changeExpression(const QByteArray &name, const
action.property = d->property(name);
action.fromValue = action.property.read();
action.specifiedObject = object();
- action.specifiedProperty = QString::fromUtf8(name);
+ action.specifiedProperty = name;
if (d->isExplicit) {
@@ -670,11 +697,11 @@ void QDeclarativePropertyChanges::changeExpression(const QByteArray &name, const
// what about the signal handler?
}
-QVariant QDeclarativePropertyChanges::property(const QByteArray &name) const
+QVariant QDeclarativePropertyChanges::property(const QString &name) const
{
Q_D(const QDeclarativePropertyChanges);
- typedef QPair<QByteArray, QVariant> PropertyEntry;
- typedef QPair<QByteArray, QDeclarativeExpression *> ExpressionEntry;
+ typedef QPair<QString, QVariant> PropertyEntry;
+ typedef QDeclarativePropertyChangesPrivate::ExpressionChange ExpressionEntry;
QListIterator<PropertyEntry> propertyIterator(d->properties);
while (propertyIterator.hasNext()) {
@@ -687,24 +714,24 @@ QVariant QDeclarativePropertyChanges::property(const QByteArray &name) const
QListIterator<ExpressionEntry> expressionIterator(d->expressions);
while (expressionIterator.hasNext()) {
const ExpressionEntry &entry = expressionIterator.next();
- if (entry.first == name) {
- return QVariant(entry.second->expression());
+ if (entry.name == name) {
+ return QVariant(entry.expression->expression());
}
}
return QVariant();
}
-void QDeclarativePropertyChanges::removeProperty(const QByteArray &name)
+void QDeclarativePropertyChanges::removeProperty(const QString &name)
{
Q_D(QDeclarativePropertyChanges);
- typedef QPair<QByteArray, QVariant> PropertyEntry;
- typedef QPair<QByteArray, QDeclarativeExpression *> ExpressionEntry;
+ typedef QPair<QString, QVariant> PropertyEntry;
+ typedef QDeclarativePropertyChangesPrivate::ExpressionChange ExpressionEntry;
QMutableListIterator<ExpressionEntry> expressionIterator(d->expressions);
while (expressionIterator.hasNext()) {
const ExpressionEntry &entry = expressionIterator.next();
- if (entry.first == name) {
+ if (entry.name == name) {
expressionIterator.remove();
state()->removeEntryFromRevertList(object(), name);
return;
@@ -722,10 +749,10 @@ void QDeclarativePropertyChanges::removeProperty(const QByteArray &name)
}
}
-QVariant QDeclarativePropertyChanges::value(const QByteArray &name) const
+QVariant QDeclarativePropertyChanges::value(const QString &name) const
{
Q_D(const QDeclarativePropertyChanges);
- typedef QPair<QByteArray, QVariant> PropertyEntry;
+ typedef QPair<QString, QVariant> PropertyEntry;
QListIterator<PropertyEntry> propertyIterator(d->properties);
while (propertyIterator.hasNext()) {
@@ -738,16 +765,16 @@ QVariant QDeclarativePropertyChanges::value(const QByteArray &name) const
return QVariant();
}
-QString QDeclarativePropertyChanges::expression(const QByteArray &name) const
+QString QDeclarativePropertyChanges::expression(const QString &name) const
{
Q_D(const QDeclarativePropertyChanges);
- typedef QPair<QByteArray, QDeclarativeExpression *> ExpressionEntry;
+ typedef QDeclarativePropertyChangesPrivate::ExpressionChange ExpressionEntry;
QListIterator<ExpressionEntry> expressionIterator(d->expressions);
while (expressionIterator.hasNext()) {
const ExpressionEntry &entry = expressionIterator.next();
- if (entry.first == name) {
- return entry.second->expression();
+ if (entry.name == name) {
+ return entry.expression->expression();
}
}
diff --git a/src/declarative/util/qdeclarativepropertychanges_p.h b/src/declarative/util/qdeclarativepropertychanges_p.h
index aa57657..09e3a16 100644
--- a/src/declarative/util/qdeclarativepropertychanges_p.h
+++ b/src/declarative/util/qdeclarativepropertychanges_p.h
@@ -75,19 +75,19 @@ public:
virtual ActionList actions();
- bool containsProperty(const QByteArray &name) const;
- bool containsValue(const QByteArray &name) const;
- bool containsExpression(const QByteArray &name) const;
- void changeValue(const QByteArray &name, const QVariant &value);
- void changeExpression(const QByteArray &name, const QString &expression);
- void removeProperty(const QByteArray &name);
- QVariant value(const QByteArray &name) const;
- QString expression(const QByteArray &name) const;
+ bool containsProperty(const QString &name) const;
+ bool containsValue(const QString &name) const;
+ bool containsExpression(const QString &name) const;
+ void changeValue(const QString &name, const QVariant &value);
+ void changeExpression(const QString &name, const QString &expression);
+ void removeProperty(const QString &name);
+ QVariant value(const QString &name) const;
+ QString expression(const QString &name) const;
void detachFromState();
void attachToState();
- QVariant property(const QByteArray &name) const;
+ QVariant property(const QString &name) const;
};
class QDeclarativePropertyChangesParser : public QDeclarativeCustomParser
diff --git a/src/declarative/util/qdeclarativespringanimation.cpp b/src/declarative/util/qdeclarativespringanimation.cpp
index ec2b083..1212a1c 100644
--- a/src/declarative/util/qdeclarativespringanimation.cpp
+++ b/src/declarative/util/qdeclarativespringanimation.cpp
@@ -236,7 +236,7 @@ void QDeclarativeSpringAnimationPrivate::updateMode()
/*!
\qmlclass SpringAnimation QDeclarativeSpringAnimation
\ingroup qml-animation-transition
- \inherits Animation
+ \inherits NumberAnimation
\since 4.7
\brief The SpringAnimation element allows a property to track a value in a spring-like motion.
diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp
index bb1a0b8..5a4e2b1 100644
--- a/src/declarative/util/qdeclarativestate.cpp
+++ b/src/declarative/util/qdeclarativestate.cpp
@@ -66,7 +66,7 @@ QDeclarativeAction::QDeclarativeAction()
QDeclarativeAction::QDeclarativeAction(QObject *target, const QString &propertyName,
const QVariant &value)
: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false),
- property(target, propertyName), toValue(value),
+ property(target, propertyName, qmlEngine(target)), toValue(value),
fromBinding(0), event(0),
specifiedObject(target), specifiedProperty(propertyName)
{
@@ -216,15 +216,18 @@ bool QDeclarativeState::isWhenKnown() const
\snippet doc/src/snippets/declarative/state-when.qml 0
- If multiple states in a group have \c when clauses that evaluate to \c true at the same time,
- the first matching state will be applied. For example, in the following snippet
- \c state1 will always be selected rather than \c state2 when sharedCondition becomes
- \c true.
+ If multiple states in a group have \c when clauses that evaluate to \c true
+ at the same time, the first matching state will be applied. For example, in
+ the following snippet \c state1 will always be selected rather than
+ \c state2 when sharedCondition becomes \c true.
\qml
- states: [
- State { name: "state1"; when: sharedCondition },
- State { name: "state2"; when: sharedCondition }
- ]
+ Item {
+ states: [
+ State { name: "state1"; when: sharedCondition },
+ State { name: "state2"; when: sharedCondition }
+ ]
+ // ...
+ }
\endqml
*/
QDeclarativeBinding *QDeclarativeState::when() const
@@ -370,7 +373,7 @@ void QDeclarativeAction::deleteFromBinding()
}
}
-bool QDeclarativeState::containsPropertyInRevertList(QObject *target, const QByteArray &name) const
+bool QDeclarativeState::containsPropertyInRevertList(QObject *target, const QString &name) const
{
Q_D(const QDeclarativeState);
@@ -379,7 +382,7 @@ bool QDeclarativeState::containsPropertyInRevertList(QObject *target, const QByt
while (revertListIterator.hasNext()) {
const QDeclarativeSimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty().toUtf8() == name)
+ if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
return true;
}
}
@@ -387,7 +390,7 @@ bool QDeclarativeState::containsPropertyInRevertList(QObject *target, const QByt
return false;
}
-bool QDeclarativeState::changeValueInRevertList(QObject *target, const QByteArray &name, const QVariant &revertValue)
+bool QDeclarativeState::changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue)
{
Q_D(QDeclarativeState);
@@ -396,7 +399,7 @@ bool QDeclarativeState::changeValueInRevertList(QObject *target, const QByteArra
while (revertListIterator.hasNext()) {
QDeclarativeSimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty().toUtf8() == name) {
+ if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) {
simpleAction.setValue(revertValue);
return true;
}
@@ -406,7 +409,7 @@ bool QDeclarativeState::changeValueInRevertList(QObject *target, const QByteArra
return false;
}
-bool QDeclarativeState::changeBindingInRevertList(QObject *target, const QByteArray &name, QDeclarativeAbstractBinding *binding)
+bool QDeclarativeState::changeBindingInRevertList(QObject *target, const QString &name, QDeclarativeAbstractBinding *binding)
{
Q_D(QDeclarativeState);
@@ -415,7 +418,7 @@ bool QDeclarativeState::changeBindingInRevertList(QObject *target, const QByteAr
while (revertListIterator.hasNext()) {
QDeclarativeSimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty().toUtf8() == name) {
+ if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) {
if (simpleAction.binding())
simpleAction.binding()->destroy();
@@ -428,7 +431,7 @@ bool QDeclarativeState::changeBindingInRevertList(QObject *target, const QByteAr
return false;
}
-bool QDeclarativeState::removeEntryFromRevertList(QObject *target, const QByteArray &name)
+bool QDeclarativeState::removeEntryFromRevertList(QObject *target, const QString &name)
{
Q_D(QDeclarativeState);
@@ -437,7 +440,7 @@ bool QDeclarativeState::removeEntryFromRevertList(QObject *target, const QByteAr
while (revertListIterator.hasNext()) {
QDeclarativeSimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.property().object() == target && simpleAction.property().name().toUtf8() == name) {
+ if (simpleAction.property().object() == target && simpleAction.property().name() == name) {
QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property());
if (oldBinding) {
QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0);
@@ -517,7 +520,7 @@ void QDeclarativeState::addEntriesToRevertList(const QList<QDeclarativeAction> &
}
}
-QVariant QDeclarativeState::valueInRevertList(QObject *target, const QByteArray &name) const
+QVariant QDeclarativeState::valueInRevertList(QObject *target, const QString &name) const
{
Q_D(const QDeclarativeState);
@@ -526,7 +529,7 @@ QVariant QDeclarativeState::valueInRevertList(QObject *target, const QByteArray
while (revertListIterator.hasNext()) {
const QDeclarativeSimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty().toUtf8() == name)
+ if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
return simpleAction.value();
}
}
@@ -534,7 +537,7 @@ QVariant QDeclarativeState::valueInRevertList(QObject *target, const QByteArray
return QVariant();
}
-QDeclarativeAbstractBinding *QDeclarativeState::bindingInRevertList(QObject *target, const QByteArray &name) const
+QDeclarativeAbstractBinding *QDeclarativeState::bindingInRevertList(QObject *target, const QString &name) const
{
Q_D(const QDeclarativeState);
@@ -543,7 +546,7 @@ QDeclarativeAbstractBinding *QDeclarativeState::bindingInRevertList(QObject *tar
while (revertListIterator.hasNext()) {
const QDeclarativeSimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty().toUtf8() == name)
+ if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
return simpleAction.binding();
}
}
diff --git a/src/declarative/util/qdeclarativestate_p.h b/src/declarative/util/qdeclarativestate_p.h
index 4a0b4ff..60d0e0b 100644
--- a/src/declarative/util/qdeclarativestate_p.h
+++ b/src/declarative/util/qdeclarativestate_p.h
@@ -45,7 +45,7 @@
#include <qdeclarative.h>
#include <qdeclarativeproperty.h>
#include <QtCore/qobject.h>
-#include <private/qdeclarativebinding_p.h>
+#include <QtCore/qsharedpointer.h>
#include <private/qdeclarativeglobal_p.h>
QT_BEGIN_HEADER
@@ -76,7 +76,7 @@ public:
QVariant toValue;
QDeclarativeAbstractBinding *fromBinding;
- QDeclarativeAbstractBinding::Pointer toBinding;
+ QWeakPointer<QDeclarativeAbstractBinding> toBinding;
QDeclarativeActionEvent *event;
//strictly for matching
@@ -180,15 +180,15 @@ public:
QDeclarativeStateGroup *stateGroup() const;
void setStateGroup(QDeclarativeStateGroup *);
- bool containsPropertyInRevertList(QObject *target, const QByteArray &name) const;
- bool changeValueInRevertList(QObject *target, const QByteArray &name, const QVariant &revertValue);
- bool changeBindingInRevertList(QObject *target, const QByteArray &name, QDeclarativeAbstractBinding *binding);
- bool removeEntryFromRevertList(QObject *target, const QByteArray &name);
+ bool containsPropertyInRevertList(QObject *target, const QString &name) const;
+ bool changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue);
+ bool changeBindingInRevertList(QObject *target, const QString &name, QDeclarativeAbstractBinding *binding);
+ bool removeEntryFromRevertList(QObject *target, const QString &name);
void addEntryToRevertList(const QDeclarativeAction &action);
void removeAllEntriesFromRevertList(QObject *target);
void addEntriesToRevertList(const QList<QDeclarativeAction> &actions);
- QVariant valueInRevertList(QObject *target, const QByteArray &name) const;
- QDeclarativeAbstractBinding *bindingInRevertList(QObject *target, const QByteArray &name) const;
+ QVariant valueInRevertList(QObject *target, const QString &name) const;
+ QDeclarativeAbstractBinding *bindingInRevertList(QObject *target, const QString &name) const;
bool isStateActive() const;
diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp
index 7aeea12..f1d0997 100644
--- a/src/declarative/util/qdeclarativestategroup.cpp
+++ b/src/declarative/util/qdeclarativestategroup.cpp
@@ -102,10 +102,10 @@ public:
id: myStateGroup
states: State {
name: "state1"
- ...
+ // ...
}
transitions: Transition {
- ...
+ // ...
}
}
@@ -140,11 +140,15 @@ QList<QDeclarativeState *> QDeclarativeStateGroup::states() const
\qml
StateGroup {
- states: [
- State { ... },
- State { ... }
- ...
- ]
+ states: [
+ State {
+ // State definition...
+ },
+ State {
+ // ...
+ }
+ // Other states...
+ ]
}
\endqml
@@ -197,11 +201,15 @@ void QDeclarativeStateGroupPrivate::clear_states(QDeclarativeListProperty<QDecla
\qml
StateGroup {
- transitions: [
- Transition { ... },
- Transition { ... }
- ...
- ]
+ transitions: [
+ Transition {
+ // ...
+ },
+ Transition {
+ // ...
+ }
+ // ...
+ ]
}
\endqml
@@ -221,14 +229,14 @@ QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeStateGroup::transit
This property is often used in scripts to change between states. For
example:
- \qml
- function toggle() {
- if (button.state == 'On')
- button.state = 'Off';
- else
- button.state = 'On';
- }
- \endqml
+ \js
+ function toggle() {
+ if (button.state == 'On')
+ button.state = 'Off';
+ else
+ button.state = 'On';
+ }
+ \endjs
If the state group is in its base state (i.e. no explicit state has been
set), \c state will be a blank string. Likewise, you can return a
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 346a374..9aca71f 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -83,6 +83,13 @@ public:
QDeclarativeNullableValue<QDeclarativeScriptString> scaleString;
QDeclarativeNullableValue<QDeclarativeScriptString> rotationString;
+ QDeclarativeNullableValue<qreal> x;
+ QDeclarativeNullableValue<qreal> y;
+ QDeclarativeNullableValue<qreal> width;
+ QDeclarativeNullableValue<qreal> height;
+ QDeclarativeNullableValue<qreal> scale;
+ QDeclarativeNullableValue<qreal> rotation;
+
void doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore = 0);
};
@@ -213,10 +220,21 @@ QDeclarativeScriptString QDeclarativeParentChange::x() const
return d->xString.value;
}
+void tryReal(QDeclarativeNullableValue<qreal> &value, const QString &string)
+{
+ bool ok = false;
+ qreal realValue = string.toFloat(&ok);
+ if (ok)
+ value = realValue;
+ else
+ value.invalidate();
+}
+
void QDeclarativeParentChange::setX(QDeclarativeScriptString x)
{
Q_D(QDeclarativeParentChange);
d->xString = x;
+ tryReal(d->x, x.script());
}
bool QDeclarativeParentChange::xIsSet() const
@@ -235,6 +253,7 @@ void QDeclarativeParentChange::setY(QDeclarativeScriptString y)
{
Q_D(QDeclarativeParentChange);
d->yString = y;
+ tryReal(d->y, y.script());
}
bool QDeclarativeParentChange::yIsSet() const
@@ -253,6 +272,7 @@ void QDeclarativeParentChange::setWidth(QDeclarativeScriptString width)
{
Q_D(QDeclarativeParentChange);
d->widthString = width;
+ tryReal(d->width, width.script());
}
bool QDeclarativeParentChange::widthIsSet() const
@@ -271,6 +291,7 @@ void QDeclarativeParentChange::setHeight(QDeclarativeScriptString height)
{
Q_D(QDeclarativeParentChange);
d->heightString = height;
+ tryReal(d->height, height.script());
}
bool QDeclarativeParentChange::heightIsSet() const
@@ -289,6 +310,7 @@ void QDeclarativeParentChange::setScale(QDeclarativeScriptString scale)
{
Q_D(QDeclarativeParentChange);
d->scaleString = scale;
+ tryReal(d->scale, scale.script());
}
bool QDeclarativeParentChange::scaleIsSet() const
@@ -307,6 +329,7 @@ void QDeclarativeParentChange::setRotation(QDeclarativeScriptString rotation)
{
Q_D(QDeclarativeParentChange);
d->rotationString = rotation;
+ tryReal(d->rotation, rotation.script());
}
bool QDeclarativeParentChange::rotationIsSet() const
@@ -367,16 +390,15 @@ QDeclarativeStateOperation::ActionList QDeclarativeParentChange::actions()
a.event = this;
actions << a;
+ QDeclarativeContext *ctxt = qmlContext(this);
+
if (d->xString.isValid()) {
- bool ok = false;
- QString script = d->xString.value.script();
- qreal x = script.toFloat(&ok);
- if (ok) {
- QDeclarativeAction xa(d->target, QLatin1String("x"), x);
+ if (d->x.isValid()) {
+ QDeclarativeAction xa(d->target, QLatin1String("x"), ctxt, d->x.value);
actions << xa;
} else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
- newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("x")));
+ QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->xString.value.script(), d->target, ctxt);
+ newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("x"), ctxt));
QDeclarativeAction xa;
xa.property = newBinding->property();
xa.toBinding = newBinding;
@@ -387,15 +409,12 @@ QDeclarativeStateOperation::ActionList QDeclarativeParentChange::actions()
}
if (d->yString.isValid()) {
- bool ok = false;
- QString script = d->yString.value.script();
- qreal y = script.toFloat(&ok);
- if (ok) {
- QDeclarativeAction ya(d->target, QLatin1String("y"), y);
+ if (d->y.isValid()) {
+ QDeclarativeAction ya(d->target, QLatin1String("y"), ctxt, d->y.value);
actions << ya;
} else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
- newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("y")));
+ QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->yString.value.script(), d->target, ctxt);
+ newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("y"), ctxt));
QDeclarativeAction ya;
ya.property = newBinding->property();
ya.toBinding = newBinding;
@@ -406,15 +425,12 @@ QDeclarativeStateOperation::ActionList QDeclarativeParentChange::actions()
}
if (d->scaleString.isValid()) {
- bool ok = false;
- QString script = d->scaleString.value.script();
- qreal scale = script.toFloat(&ok);
- if (ok) {
- QDeclarativeAction sa(d->target, QLatin1String("scale"), scale);
+ if (d->scale.isValid()) {
+ QDeclarativeAction sa(d->target, QLatin1String("scale"), ctxt, d->scale.value);
actions << sa;
} else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
- newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("scale")));
+ QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->scaleString.value.script(), d->target, ctxt);
+ newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("scale"), ctxt));
QDeclarativeAction sa;
sa.property = newBinding->property();
sa.toBinding = newBinding;
@@ -425,15 +441,12 @@ QDeclarativeStateOperation::ActionList QDeclarativeParentChange::actions()
}
if (d->rotationString.isValid()) {
- bool ok = false;
- QString script = d->rotationString.value.script();
- qreal rotation = script.toFloat(&ok);
- if (ok) {
- QDeclarativeAction ra(d->target, QLatin1String("rotation"), rotation);
+ if (d->rotation.isValid()) {
+ QDeclarativeAction ra(d->target, QLatin1String("rotation"), ctxt, d->rotation.value);
actions << ra;
} else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
- newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("rotation")));
+ QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->rotationString.value.script(), d->target, ctxt);
+ newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("rotation"), ctxt));
QDeclarativeAction ra;
ra.property = newBinding->property();
ra.toBinding = newBinding;
@@ -444,15 +457,12 @@ QDeclarativeStateOperation::ActionList QDeclarativeParentChange::actions()
}
if (d->widthString.isValid()) {
- bool ok = false;
- QString script = d->widthString.value.script();
- qreal width = script.toFloat(&ok);
- if (ok) {
- QDeclarativeAction wa(d->target, QLatin1String("width"), width);
+ if (d->width.isValid()) {
+ QDeclarativeAction wa(d->target, QLatin1String("width"), ctxt, d->width.value);
actions << wa;
} else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
- newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("width")));
+ QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->widthString.value.script(), d->target, ctxt);
+ newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("width"), ctxt));
QDeclarativeAction wa;
wa.property = newBinding->property();
wa.toBinding = newBinding;
@@ -463,15 +473,12 @@ QDeclarativeStateOperation::ActionList QDeclarativeParentChange::actions()
}
if (d->heightString.isValid()) {
- bool ok = false;
- QString script = d->heightString.value.script();
- qreal height = script.toFloat(&ok);
- if (ok) {
- QDeclarativeAction ha(d->target, QLatin1String("height"), height);
+ if (d->height.isValid()) {
+ QDeclarativeAction ha(d->target, QLatin1String("height"), ctxt, d->height.value);
actions << ha;
} else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
- newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("height")));
+ QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->heightString.value.script(), d->target, ctxt);
+ newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("height"), ctxt));
QDeclarativeAction ha;
ha.property = newBinding->property();
ha.toBinding = newBinding;
@@ -599,25 +606,7 @@ public:
ScriptAction to specify the point in the transition at which
the StateChangeScript should to be run.
- \qml
- State {
- name "state1"
- StateChangeScript {
- name: "myScript"
- script: doStateStuff();
- }
- ...
- }
- ...
- Transition {
- to: "state1"
- SequentialAnimation {
- NumberAnimation { ... }
- ScriptAction { scriptName: "myScript" }
- NumberAnimation { ... }
- }
- }
- \endqml
+ \snippet snippets/declarative/states/statechangescript.qml state and transition
\sa ScriptAction
*/
@@ -652,7 +641,7 @@ void QDeclarativeStateChangeScript::setScript(const QDeclarativeScriptString &s)
This property holds the name of the script. This name can be used by a
ScriptAction to target a specific script.
- \sa ScriptAction::stateChangeScriptName
+ \sa ScriptAction::scriptName
*/
QString QDeclarativeStateChangeScript::name() const
{
@@ -1075,32 +1064,34 @@ QDeclarativeAnchorChanges::ActionList QDeclarativeAnchorChanges::actions()
d->vCenterProp = QDeclarativeProperty(d->target, QLatin1String("anchors.verticalCenter"));
d->baselineProp = QDeclarativeProperty(d->target, QLatin1String("anchors.baseline"));
+ QDeclarativeContext *ctxt = qmlContext(this);
+
if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::LeftAnchor) {
- d->leftBinding = new QDeclarativeBinding(d->anchorSet->d_func()->leftScript.script(), d->target, qmlContext(this));
+ d->leftBinding = new QDeclarativeBinding(d->anchorSet->d_func()->leftScript.script(), d->target, ctxt);
d->leftBinding->setTarget(d->leftProp);
}
if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::RightAnchor) {
- d->rightBinding = new QDeclarativeBinding(d->anchorSet->d_func()->rightScript.script(), d->target, qmlContext(this));
+ d->rightBinding = new QDeclarativeBinding(d->anchorSet->d_func()->rightScript.script(), d->target, ctxt);
d->rightBinding->setTarget(d->rightProp);
}
if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::HCenterAnchor) {
- d->hCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->hCenterScript.script(), d->target, qmlContext(this));
+ d->hCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->hCenterScript.script(), d->target, ctxt);
d->hCenterBinding->setTarget(d->hCenterProp);
}
if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::TopAnchor) {
- d->topBinding = new QDeclarativeBinding(d->anchorSet->d_func()->topScript.script(), d->target, qmlContext(this));
+ d->topBinding = new QDeclarativeBinding(d->anchorSet->d_func()->topScript.script(), d->target, ctxt);
d->topBinding->setTarget(d->topProp);
}
if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::BottomAnchor) {
- d->bottomBinding = new QDeclarativeBinding(d->anchorSet->d_func()->bottomScript.script(), d->target, qmlContext(this));
+ d->bottomBinding = new QDeclarativeBinding(d->anchorSet->d_func()->bottomScript.script(), d->target, ctxt);
d->bottomBinding->setTarget(d->bottomProp);
}
if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::VCenterAnchor) {
- d->vCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->vCenterScript.script(), d->target, qmlContext(this));
+ d->vCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->vCenterScript.script(), d->target, ctxt);
d->vCenterBinding->setTarget(d->vCenterProp);
}
if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::BaselineAnchor) {
- d->baselineBinding = new QDeclarativeBinding(d->anchorSet->d_func()->baselineScript.script(), d->target, qmlContext(this));
+ d->baselineBinding = new QDeclarativeBinding(d->anchorSet->d_func()->baselineScript.script(), d->target, ctxt);
d->baselineBinding->setTarget(d->baselineProp);
}
@@ -1380,24 +1371,25 @@ QList<QDeclarativeAction> QDeclarativeAnchorChanges::additionalActions()
bool vChange = combined & QDeclarativeAnchors::Vertical_Mask;
if (d->target) {
+ QDeclarativeContext *ctxt = qmlContext(this);
QDeclarativeAction a;
if (hChange && d->fromX != d->toX) {
- a.property = QDeclarativeProperty(d->target, QLatin1String("x"));
+ a.property = QDeclarativeProperty(d->target, QLatin1String("x"), ctxt);
a.toValue = d->toX;
extra << a;
}
if (vChange && d->fromY != d->toY) {
- a.property = QDeclarativeProperty(d->target, QLatin1String("y"));
+ a.property = QDeclarativeProperty(d->target, QLatin1String("y"), ctxt);
a.toValue = d->toY;
extra << a;
}
if (hChange && d->fromWidth != d->toWidth) {
- a.property = QDeclarativeProperty(d->target, QLatin1String("width"));
+ a.property = QDeclarativeProperty(d->target, QLatin1String("width"), ctxt);
a.toValue = d->toWidth;
extra << a;
}
if (vChange && d->fromHeight != d->toHeight) {
- a.property = QDeclarativeProperty(d->target, QLatin1String("height"));
+ a.property = QDeclarativeProperty(d->target, QLatin1String("height"), ctxt);
a.toValue = d->toHeight;
extra << a;
}
diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp
index e533a07..063ec3e 100644
--- a/src/declarative/util/qdeclarativetransition.cpp
+++ b/src/declarative/util/qdeclarativetransition.cpp
@@ -82,15 +82,7 @@ QT_BEGIN_NAMESPACE
To define multiple transitions, specify \l Item::transitions as a list:
- \qml
- Item {
- ...
- transitions: [
- Transition { to: "state1" ... },
- Transition { ... }
- ]
- }
- \endqml
+ \snippet doc/src/snippets/declarative/transitions-list.qml list of transitions
If multiple Transitions are specified, only a single (best-matching) Transition will be applied for any particular
state change. In the example above, when changing to \c state1, the first transition will be used, rather
@@ -222,13 +214,7 @@ void QDeclarativeTransition::prepare(QDeclarativeStateOperation::ActionList &act
If the transition was changed to this:
- \qml
- transitions: Transition {
- to: "brighter"
- ColorAnimation { duration: 1000 }
- }
- }
- \endqml
+ \snippet doc/src/snippets/declarative/transition-from-to-modified.qml modified transition
The animation would only be applied when changing from the default state to
the "brighter" state (i.e. when the mouse is pressed, but not on release).
@@ -313,24 +299,12 @@ void QDeclarativeTransition::setToState(const QString &t)
This property holds a list of the animations to be run for this transition.
- \qml
- Transition {
- PropertyAnimation { ... }
- NumberAnimation { ... }
- }
- \endqml
+ \snippet examples/declarative/toys/dynamicscene/dynamicscene.qml top-level transitions
The top-level animations are run in parallel. To run them sequentially,
define them within a SequentialAnimation:
- \qml
- Transition {
- SequentialAnimation {
- PropertyAnimation { ... }
- NumberAnimation { ... }
- }
- }
- \endqml
+ \snippet doc/src/snippets/declarative/transition-reversible.qml sequential animations
*/
QDeclarativeListProperty<QDeclarativeAbstractAnimation> QDeclarativeTransition::animations()
{
diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
index 0544f22..f32f390 100644
--- a/src/declarative/util/qdeclarativeutilmodule.cpp
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -66,6 +66,7 @@
#include "private/qdeclarativetimer_p.h"
#include "private/qdeclarativetransitionmanager_p_p.h"
#include "private/qdeclarativetransition_p.h"
+#include "private/qdeclarativeapplication_p.h"
#include "qdeclarativeview.h"
#include "qdeclarativeinfo.h"
#include "private/qdeclarativetypenotavailable_p.h"
@@ -75,6 +76,8 @@
void QDeclarativeUtilModule::defineModule()
{
+ qmlRegisterUncreatableType<QDeclarativeApplication>("QtQuick",1,1,"Application", QDeclarativeApplication::tr("Application is an abstract class"));
+
qmlRegisterType<QDeclarativeAnchorAnimation>("QtQuick",1,0,"AnchorAnimation");
qmlRegisterType<QDeclarativeAnchorChanges>("QtQuick",1,0,"AnchorChanges");
qmlRegisterType<QDeclarativeBehavior>("QtQuick",1,0,"Behavior");
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index 20028eb..99c29d5 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -77,7 +77,7 @@ extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled;
class QDeclarativeScene : public QGraphicsScene
{
public:
- QDeclarativeScene();
+ QDeclarativeScene(QObject *parent = 0);
protected:
virtual void keyPressEvent(QKeyEvent *);
@@ -88,7 +88,7 @@ protected:
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
};
-QDeclarativeScene::QDeclarativeScene()
+QDeclarativeScene::QDeclarativeScene(QObject *parent) : QGraphicsScene(parent)
{
}
@@ -132,7 +132,8 @@ class QDeclarativeViewPrivate : public QGraphicsViewPrivate, public QDeclarative
Q_DECLARE_PUBLIC(QDeclarativeView)
public:
QDeclarativeViewPrivate()
- : root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject), initialSize(0,0) {}
+ : root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0),
+ resizeMode(QDeclarativeView::SizeViewToRootObject), initialSize(0,0) {}
~QDeclarativeViewPrivate() { delete root; delete engine; }
void execute();
void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry);
@@ -155,8 +156,6 @@ public:
QElapsedTimer frameTimer;
void init();
-
- QDeclarativeScene scene;
};
void QDeclarativeViewPrivate::execute()
@@ -234,6 +233,9 @@ void QDeclarativeViewPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem,
you can connect to the statusChanged() signal and monitor for QDeclarativeView::Error.
The errors are available via QDeclarativeView::errors().
+ If you're using your own QGraphicsScene-based scene with QDeclarativeView, remember to
+ enable scene's sticky focus mode and to set itemIndexMethod to QGraphicsScene::NoIndex.
+
\sa {Integrating QML with existing Qt UI code}, {Using QML in C++ Applications}
*/
@@ -277,7 +279,7 @@ void QDeclarativeViewPrivate::init()
{
Q_Q(QDeclarativeView);
engine = new QDeclarativeEngine();
- q->setScene(&scene);
+ q->setScene(new QDeclarativeScene(q));
q->setOptimizationFlags(QGraphicsView::DontSavePainterState);
q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -286,11 +288,11 @@ void QDeclarativeViewPrivate::init()
// These seem to give the best performance
q->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
- scene.setItemIndexMethod(QGraphicsScene::NoIndex);
+ q->scene()->setItemIndexMethod(QGraphicsScene::NoIndex);
q->viewport()->setFocusPolicy(Qt::NoFocus);
q->setFocusPolicy(Qt::StrongFocus);
- scene.setStickyFocus(true); //### needed for correct focus handling
+ q->scene()->setStickyFocus(true); //### needed for correct focus handling
}
/*!
@@ -557,14 +559,14 @@ void QDeclarativeView::continueExecute()
void QDeclarativeView::setRootObject(QObject *obj)
{
Q_D(QDeclarativeView);
- if (d->root == obj)
+ if (d->root == obj || !scene())
return;
if (QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem *>(obj)) {
- d->scene.addItem(declarativeItem);
+ scene()->addItem(declarativeItem);
d->root = declarativeItem;
d->declarativeItemRoot = declarativeItem;
} else if (QGraphicsObject *graphicsObject = qobject_cast<QGraphicsObject *>(obj)) {
- d->scene.addItem(graphicsObject);
+ scene()->addItem(graphicsObject);
d->root = graphicsObject;
if (graphicsObject->isWidget()) {
d->graphicsWidgetRoot = static_cast<QGraphicsWidget*>(graphicsObject);
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index 8053a5e..d5c7d1b 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -46,11 +46,9 @@
#include <QDebug>
#include <QStringList>
-#include <QQueue>
+#include <QMap>
#include <QApplication>
#include <QThread>
-#include <QMutex>
-#include <QWaitCondition>
#include <QXmlQuery>
#include <QXmlResultItems>
#include <QXmlNodeModelIndex>
@@ -58,6 +56,7 @@
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QTimer>
+#include <QMutex>
#include <private/qobject_p.h>
@@ -90,10 +89,15 @@ typedef QPair<int, int> QDeclarativeXmlListRange;
\qml
XmlListModel {
id: xmlModel
- ...
- XmlRole { name: "title"; query: "title/string()" }
+ // ...
+ XmlRole {
+ name: "title"
+ query: "title/string()"
+ }
}
+ \endqml
+ \qml
ListView {
model: xmlModel
delegate: Text { text: title }
@@ -142,39 +146,32 @@ struct XmlQueryJob
QStringList keyRoleResultsCache;
};
-class QDeclarativeXmlQuery : public QThread
+class QDeclarativeXmlQuery : public QObject
{
Q_OBJECT
public:
QDeclarativeXmlQuery(QObject *parent=0)
- : QThread(parent), m_quit(false), m_abortQueryId(-1), m_queryIds(XMLLISTMODEL_CLEAR_ID + 1) {
+ : QObject(parent), m_queryIds(XMLLISTMODEL_CLEAR_ID + 1) {
qRegisterMetaType<QDeclarativeXmlQueryResult>("QDeclarativeXmlQueryResult");
- m_currentJob.queryId = -1;
+ moveToThread(&m_thread);
+ m_thread.start(QThread::IdlePriority);
}
~QDeclarativeXmlQuery() {
- m_mutex.lock();
- m_quit = true;
- m_condition.wakeOne();
- m_mutex.unlock();
-
- wait();
+ if(m_thread.isRunning()) {
+ m_thread.quit();
+ m_thread.wait();
+ }
}
void abort(int id) {
- QMutexLocker locker(&m_mutex);
- QQueue<XmlQueryJob>::iterator it;
- for (it = m_jobs.begin(); it != m_jobs.end(); ++it) {
- if ((*it).queryId == id) {
- m_jobs.erase(it);
- return;
- }
+ QMutexLocker ml(&m_mutex);
+ if (id != -1) {
+ m_jobs.remove(id);
}
- m_abortQueryId = id;
}
- int doQuery(QString query, QString namespaces, QByteArray data, QList<QDeclarativeXmlListModelRole *> *roleObjects, QStringList keyRoleResultsCache) {
- QMutexLocker locker(&m_mutex);
+ int doQuery(QString query, QString namespaces, QByteArray data, QList<QDeclarativeXmlListModelRole *>* roleObjects, QStringList keyRoleResultsCache) {
XmlQueryJob job;
job.queryId = m_queryIds;
@@ -193,69 +190,69 @@ public:
if (roleObjects->at(i)->isKey())
job.keyRoleQueries << job.roleQueries.last();
}
- m_jobs.enqueue(job);
- m_queryIds++;
- if (!isRunning())
- start(QThread::IdlePriority);
- else
- m_condition.wakeOne();
+ {
+ QMutexLocker ml(&m_mutex);
+ m_jobs.insert(m_queryIds, job);
+ m_queryIds++;
+ if (m_queryIds <= 0)
+ m_queryIds = 1;
+ }
+
+ QMetaObject::invokeMethod(this, "processQuery", Qt::QueuedConnection, Q_ARG(int, job.queryId));
return job.queryId;
}
+private slots:
+ void processQuery(int queryId) {
+ XmlQueryJob job;
+
+ {
+ QMutexLocker ml(&m_mutex);
+ if (!m_jobs.contains(queryId))
+ return;
+ job = m_jobs.value(queryId);
+ }
+
+ QDeclarativeXmlQueryResult r;
+ doQueryJob(&job);
+ doSubQueryJob(&job);
+ r.queryId = job.queryId;
+ r.size = m_size;
+ r.data = m_modelData;
+ r.inserted = m_insertedItemRanges;
+ r.removed = m_removedItemRanges;
+ r.keyRoleResultsCache = job.keyRoleResultsCache;
+
+ {
+ QMutexLocker ml(&m_mutex);
+ if (m_jobs.contains(queryId)) {
+ emit queryCompleted(r);
+ m_jobs.remove(queryId);
+ }
+ }
+ }
+
Q_SIGNALS:
void queryCompleted(const QDeclarativeXmlQueryResult &);
void error(void*, const QString&);
protected:
- void run() {
- m_mutex.lock();
-
- while (!m_quit) {
- if (!m_jobs.isEmpty())
- m_currentJob = m_jobs.dequeue();
- m_mutex.unlock();
-
- QDeclarativeXmlQueryResult r;
- if (m_currentJob.queryId != -1) {
- doQueryJob();
- doSubQueryJob();
- r.queryId = m_currentJob.queryId;
- r.size = m_size;
- r.data = m_modelData;
- r.inserted = m_insertedItemRanges;
- r.removed = m_removedItemRanges;
- r.keyRoleResultsCache = m_currentJob.keyRoleResultsCache;
- }
-
- m_mutex.lock();
- if (m_currentJob.queryId != -1 && m_abortQueryId != m_currentJob.queryId)
- emit queryCompleted(r);
- if (m_jobs.isEmpty() && !m_quit)
- m_condition.wait(&m_mutex);
- m_currentJob.queryId = -1;
- m_abortQueryId = -1;
- }
- m_mutex.unlock();
- }
private:
- void doQueryJob();
- void doSubQueryJob();
- void getValuesOfKeyRoles(QStringList *values, QXmlQuery *query) const;
+ void doQueryJob(XmlQueryJob* job);
+ void doSubQueryJob(XmlQueryJob* job);
+ void getValuesOfKeyRoles(const XmlQueryJob& currentJob, QStringList *values, QXmlQuery *query) const;
void addIndexToRangeList(QList<QDeclarativeXmlListRange> *ranges, int index) const;
private:
QMutex m_mutex;
- QWaitCondition m_condition;
- QQueue<XmlQueryJob> m_jobs;
- XmlQueryJob m_currentJob;
- bool m_quit;
- int m_abortQueryId;
+ QThread m_thread;
+ QMap<int, XmlQueryJob> m_jobs;
+ int m_queryIds;
QString m_prefix;
int m_size;
- int m_queryIds;
QList<QList<QVariant> > m_modelData;
QList<QDeclarativeXmlListRange> m_insertedItemRanges;
QList<QDeclarativeXmlListRange> m_removedItemRanges;
@@ -263,16 +260,16 @@ private:
Q_GLOBAL_STATIC(QDeclarativeXmlQuery, globalXmlQuery)
-void QDeclarativeXmlQuery::doQueryJob()
+void QDeclarativeXmlQuery::doQueryJob(XmlQueryJob* currentJob)
{
- Q_ASSERT(m_currentJob.queryId != -1);
+ Q_ASSERT(currentJob->queryId != -1);
QString r;
QXmlQuery query;
- QBuffer buffer(&m_currentJob.data);
+ QBuffer buffer(&currentJob->data);
buffer.open(QIODevice::ReadOnly);
query.bindVariable(QLatin1String("src"), &buffer);
- query.setQuery(m_currentJob.namespaces + m_currentJob.query);
+ query.setQuery(currentJob->namespaces + currentJob->query);
query.evaluateTo(&r);
//always need a single root element
@@ -280,9 +277,9 @@ void QDeclarativeXmlQuery::doQueryJob()
QBuffer b(&xml);
b.open(QIODevice::ReadOnly);
- QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + m_currentJob.namespaces;
+ QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + currentJob->namespaces;
QString prefix = QLatin1String("doc($inputDocument)/dummy:items") +
- m_currentJob.query.mid(m_currentJob.query.lastIndexOf(QLatin1Char('/')));
+ currentJob->query.mid(currentJob->query.lastIndexOf(QLatin1Char('/')));
//figure out how many items we are dealing with
int count = -1;
@@ -297,18 +294,16 @@ void QDeclarativeXmlQuery::doQueryJob()
count = item.toAtomicValue().toInt();
}
- m_currentJob.data = xml;
+ currentJob->data = xml;
m_prefix = namespaces + prefix + QLatin1Char('/');
m_size = 0;
if (count > 0)
m_size = count;
}
-void QDeclarativeXmlQuery::getValuesOfKeyRoles(QStringList *values, QXmlQuery *query) const
+void QDeclarativeXmlQuery::getValuesOfKeyRoles(const XmlQueryJob& currentJob, QStringList *values, QXmlQuery *query) const
{
- Q_ASSERT(m_currentJob.queryId != -1);
-
- const QStringList &keysQueries = m_currentJob.keyRoleQueries;
+ const QStringList &keysQueries = currentJob.keyRoleQueries;
QString keysQuery;
if (keysQueries.count() == 1)
keysQuery = m_prefix + keysQueries[0];
@@ -336,34 +331,34 @@ void QDeclarativeXmlQuery::addIndexToRangeList(QList<QDeclarativeXmlListRange> *
ranges->append(qMakePair(index, 1));
}
-void QDeclarativeXmlQuery::doSubQueryJob()
+void QDeclarativeXmlQuery::doSubQueryJob(XmlQueryJob* currentJob)
{
- Q_ASSERT(m_currentJob.queryId != -1);
+ Q_ASSERT(currentJob->queryId != -1);
m_modelData.clear();
- QBuffer b(&m_currentJob.data);
+ QBuffer b(&currentJob->data);
b.open(QIODevice::ReadOnly);
QXmlQuery subquery;
subquery.bindVariable(QLatin1String("inputDocument"), &b);
QStringList keyRoleResults;
- getValuesOfKeyRoles(&keyRoleResults, &subquery);
+ getValuesOfKeyRoles(*currentJob, &keyRoleResults, &subquery);
// See if any values of key roles have been inserted or removed.
m_insertedItemRanges.clear();
m_removedItemRanges.clear();
- if (m_currentJob.keyRoleResultsCache.isEmpty()) {
+ if (currentJob->keyRoleResultsCache.isEmpty()) {
m_insertedItemRanges << qMakePair(0, m_size);
} else {
- if (keyRoleResults != m_currentJob.keyRoleResultsCache) {
+ if (keyRoleResults != currentJob->keyRoleResultsCache) {
QStringList temp;
- for (int i=0; i<m_currentJob.keyRoleResultsCache.count(); i++) {
- if (!keyRoleResults.contains(m_currentJob.keyRoleResultsCache[i]))
+ for (int i=0; i<currentJob->keyRoleResultsCache.count(); i++) {
+ if (!keyRoleResults.contains(currentJob->keyRoleResultsCache[i]))
addIndexToRangeList(&m_removedItemRanges, i);
else
- temp << m_currentJob.keyRoleResultsCache[i];
+ temp << currentJob->keyRoleResultsCache[i];
}
for (int i=0; i<keyRoleResults.count(); i++) {
@@ -374,15 +369,15 @@ void QDeclarativeXmlQuery::doSubQueryJob()
}
}
}
- m_currentJob.keyRoleResultsCache = keyRoleResults;
+ currentJob->keyRoleResultsCache = keyRoleResults;
// Get the new values for each role.
//### we might be able to condense even further (query for everything in one go)
- const QStringList &queries = m_currentJob.roleQueries;
+ const QStringList &queries = currentJob->roleQueries;
for (int i = 0; i < queries.size(); ++i) {
QList<QVariant> resultList;
if (!queries[i].isEmpty()) {
- subquery.setQuery(m_prefix + QLatin1String("(let $v := ") + queries[i] + QLatin1String(" return if ($v) then ") + queries[i] + QLatin1String(" else \"\")"));
+ subquery.setQuery(m_prefix + QLatin1String("(let $v := string(") + queries[i] + QLatin1String(") return if ($v) then ") + queries[i] + QLatin1String(" else \"\")"));
if (subquery.isValid()) {
QXmlResultItems resultItems;
subquery.evaluateTo(&resultItems);
@@ -392,7 +387,7 @@ void QDeclarativeXmlQuery::doSubQueryJob()
item = resultItems.next();
}
} else {
- emit error(m_currentJob.roleQueryErrorId.at(i), queries[i]);
+ emit error(currentJob->roleQueryErrorId.at(i), queries[i]);
}
}
//### should warn here if things have gone wrong.
@@ -792,9 +787,9 @@ void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarati
This will access the \c title value for the first item in the model:
- \qml
- var title = model.get(0).title;
- \endqml
+ \js
+ var title = model.get(0).title;
+ \endjs
*/
QScriptValue QDeclarativeXmlListModel::get(int index) const
{
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index fd57144..62fa8f1 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -1,6 +1,7 @@
INCLUDEPATH += $$PWD
SOURCES += \
+ $$PWD/qdeclarativeapplication.cpp \
$$PWD/qdeclarativeutilmodule.cpp\
$$PWD/qdeclarativeview.cpp \
$$PWD/qdeclarativeconnections.cpp \
@@ -30,6 +31,7 @@ SOURCES += \
$$PWD/qlistmodelinterface.cpp
HEADERS += \
+ $$PWD/qdeclarativeapplication_p.h \
$$PWD/qdeclarativeutilmodule_p.h\
$$PWD/qdeclarativeview.h \
$$PWD/qdeclarativeconnections_p.h \
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index e81773b..0c1304f 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -1770,7 +1770,7 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
On Symbian^3 the parameter \a selectedFilter has no meaning and the
\a options parameter is only used to define if the native file dialog is
- used.
+ used. On Symbian^3, this function can only return a single filename.
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
diff --git a/src/gui/dialogs/qfiledialog_symbian.cpp b/src/gui/dialogs/qfiledialog_symbian.cpp
index e7197bd..ed98950 100644
--- a/src/gui/dialogs/qfiledialog_symbian.cpp
+++ b/src/gui/dialogs/qfiledialog_symbian.cpp
@@ -54,6 +54,9 @@
QT_BEGIN_NAMESPACE
+extern QStringList qt_make_filter_list(const QString &filter); // defined in qfiledialog.cpp
+extern QStringList qt_clean_filter_list(const QString &filter); // defined in qfiledialog.cpp
+
enum DialogMode { DialogOpen, DialogSave, DialogFolder };
#if defined(Q_WS_S60) && defined(SYMBIAN_VERSION_SYMBIAN3)
class CExtensionFilter : public MAknFileFilter
@@ -61,56 +64,39 @@ class CExtensionFilter : public MAknFileFilter
public:
void setFilter(const QString filter)
{
- filterList.clear();
- if (filter.left(2) == QLatin1String("*.")) {
- //Filter has only extensions
- filterList << filter.split(QLatin1String(" "));
- return;
- } else {
- //Extensions are in parenthesis and there may be several filters
- QStringList separatedFilters(filter.split(QLatin1String(";;")));
- for (int i = 0; i < separatedFilters.size(); i++) {
- if (separatedFilters.at(i).contains(QLatin1String("(*)"))) {
- filterList << QLatin1String("(*)");
- return;
- }
- }
- QRegExp rx(QLatin1String("\\(([^\\)]*)\\)"));
- int pos = 0;
- while ((pos = rx.indexIn(filter, pos)) != -1) {
- filterList << rx.cap(1).split(QLatin1String(" "));
- pos += rx.matchedLength();
- }
+ QStringList unparsedFiltersList = qt_make_filter_list(filter);
+ QStringList filterList;
+ filterRxList.clear();
+
+ foreach (QString unparsedFilter, unparsedFiltersList) {
+ filterList << qt_clean_filter_list(unparsedFilter);
+ }
+ foreach (QString currentFilter, filterList) {
+ QRegExp filterRx(currentFilter, Qt::CaseInsensitive, QRegExp::Wildcard);
+ filterRxList << filterRx;
}
}
TBool Accept(const TDesC &/*aDriveAndPath*/, const TEntry &aEntry) const
{
- if (aEntry.IsDir())
- return ETrue;
-
//If no filter for files, all can be accepted
- if (filterList.isEmpty())
+ if (filterRxList.isEmpty())
return ETrue;
- if (filterList == QStringList(QLatin1String("(*)")))
+ if (aEntry.IsDir())
return ETrue;
- for (int i = 0; i < filterList.size(); ++i) {
- QString extension = filterList.at(i);
- //remove '*' from the beginning of the extension
- if (extension.at(0) == QLatin1Char('*'))
- extension = extension.mid(1);
-
+ foreach (QRegExp rx, filterRxList) {
QString fileName = qt_TDesC2QString(aEntry.iName);
- if (fileName.endsWith(extension))
+ if (rx.exactMatch(fileName))
return ETrue;
}
+
return EFalse;
}
private:
- QStringList filterList;
+ QList<QRegExp> filterRxList;
};
#endif
@@ -140,11 +126,13 @@ static QString launchSymbianDialog(const QString dialogCaption, const QString st
CleanupStack::PushL(extensionFilter);
extensionFilter->setFilter(filter);
select = AknCommonDialogsDynMem::RunSelectDlgLD(types, target,
- startFolder, NULL, NULL, titlePtr, extensionFilter);
+ startFolder, 0, 0, titlePtr, extensionFilter);
CleanupStack::Pop(extensionFilter);
} else if (dialogMode == DialogSave) {
+ QString defaultFileName = QFileDialogPrivate::initialSelection(startDirectory);
+ target = qt_QString2TPtrC(defaultFileName);
select = AknCommonDialogsDynMem::RunSaveDlgLD(types, target,
- startFolder, NULL, NULL, titlePtr);
+ startFolder, 0, 0, titlePtr);
} else if (dialogMode == DialogFolder) {
select = AknCommonDialogsDynMem::RunFolderSelectDlgLD(types, target, startFolder,
0, 0, titlePtr, NULL, NULL);
@@ -160,8 +148,10 @@ static QString launchSymbianDialog(const QString dialogCaption, const QString st
startFolder = qt_QString2TPtrC(dir);
}
}
- if (select)
- selection.append(qt_TDesC2QString(target));
+ if (select) {
+ QFileInfo fi(qt_TDesC2QString(target));
+ selection = fi.absoluteFilePath();
+ }
#endif
return selection;
}
diff --git a/src/gui/dialogs/qfileinfogatherer.cpp b/src/gui/dialogs/qfileinfogatherer.cpp
index 12e77b1..b36b21e 100644
--- a/src/gui/dialogs/qfileinfogatherer.cpp
+++ b/src/gui/dialogs/qfileinfogatherer.cpp
@@ -78,11 +78,11 @@ QFileInfoGatherer::QFileInfoGatherer(QObject *parent)
#endif
m_resolveSymlinks(false), m_iconProvider(&defaultProvider)
{
-#ifndef Q_OS_WIN
+#ifdef Q_OS_WIN
+ m_resolveSymlinks = true;
+#elif !defined(Q_OS_INTEGRITY)
userId = getuid();
groupId = getgid();
-#else
- m_resolveSymlinks = true;
#endif
#ifndef QT_NO_FILESYSTEMWATCHER
watcher = new QFileSystemWatcher(this);
diff --git a/src/gui/dialogs/qpagesetupdialog.cpp b/src/gui/dialogs/qpagesetupdialog.cpp
index 2a7847e..4037e1c 100644
--- a/src/gui/dialogs/qpagesetupdialog.cpp
+++ b/src/gui/dialogs/qpagesetupdialog.cpp
@@ -107,10 +107,10 @@ class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate
This value is obsolete and does nothing since Qt 4.5:
- \value DontUseSheet In previous versions of Qt, exec() the page setup dialog
- would create a sheet by default if the dialog was given a parent.
- This is no longer supported in Qt 4.5. If you want to use sheets, use
- QPageSetupDialog::open() instead.
+ \value DontUseSheet In previous versions of QDialog::exec() the
+ page setup dialog would create a sheet by default if the dialog
+ was given a parent. This is no longer supported from Qt 4.5. If
+ you want to use sheets, use QPageSetupDialog::open() instead.
\omitvalue None
\omitvalue OwnsPrinter
diff --git a/src/gui/embedded/embedded.pri b/src/gui/embedded/embedded.pri
index eb13d8d..31f0bc6 100644
--- a/src/gui/embedded/embedded.pri
+++ b/src/gui/embedded/embedded.pri
@@ -120,6 +120,12 @@ embedded {
LIBS += -lgf
}
+ contains( gfx-drivers, integrityfb ) {
+ HEADERS += embedded/qscreenintegrityfb_qws.h
+ SOURCES += embedded/qscreenintegrityfb_qws.cpp
+ LIBS += -lfbdev
+ }
+
contains( gfx-drivers, qvfb ) {
HEADERS += embedded/qscreenvfb_qws.h
SOURCES += embedded/qscreenvfb_qws.cpp
@@ -174,6 +180,11 @@ embedded {
SOURCES += embedded/qkbdqnx_qws.cpp
}
+ contains( kbd-drivers, integrity ) {
+ HEADERS += embedded/qkbdintegrity_qws.h
+ SOURCES += embedded/qkbdintegrity_qws.cpp
+ }
+
#
# Mouse drivers
#
@@ -207,4 +218,9 @@ embedded {
HEADERS += embedded/qmouseqnx_qws.h
SOURCES += embedded/qmouseqnx_qws.cpp
}
+
+ contains( mouse-drivers, integrity ) {
+ HEADERS += embedded/qmouseintegrity_qws.h
+ SOURCES += embedded/qmouseintegrity_qws.cpp
+ }
}
diff --git a/src/gui/embedded/qkbddriverfactory_qws.cpp b/src/gui/embedded/qkbddriverfactory_qws.cpp
index 661b073..45825e5 100644
--- a/src/gui/embedded/qkbddriverfactory_qws.cpp
+++ b/src/gui/embedded/qkbddriverfactory_qws.cpp
@@ -49,6 +49,7 @@
#include "qkbdum_qws.h"
#include "qkbdvfb_qws.h"
#include "qkbdqnx_qws.h"
+#include "qkbdintegrity_qws.h"
#include <stdlib.h>
#include "private/qfactoryloader_p.h"
#include "qkbddriverplugin_qws.h"
@@ -106,6 +107,10 @@ QWSKeyboardHandler *QKbdDriverFactory::create(const QString& key, const QString&
if (driver == QLatin1String("qnx") || driver.isEmpty())
return new QWSQnxKeyboardHandler(device);
#endif
+#if defined(Q_OS_INTEGRITY)
+ if (driver == QLatin1String("integrity") || driver.isEmpty())
+ return new QWSIntKeyboardHandler(device);
+#endif
#ifndef QT_NO_QWS_KEYBOARD
# ifndef QT_NO_QWS_KBD_TTY
if (driver == QLatin1String("tty") || driver.isEmpty())
@@ -151,6 +156,9 @@ QStringList QKbdDriverFactory::keys()
#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_KBD_QNX)
list << QLatin1String("QNX");
#endif
+#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_QWS_KBD_INTEGRITY)
+ list << QLatin1String("INTEGRITY");
+#endif
#ifndef QT_NO_QWS_KBD_TTY
list << QLatin1String("TTY");
#endif
diff --git a/src/gui/embedded/qkbdintegrity_qws.cpp b/src/gui/embedded/qkbdintegrity_qws.cpp
new file mode 100644
index 0000000..b2df422
--- /dev/null
+++ b/src/gui/embedded/qkbdintegrity_qws.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_INTEGRITY)
+
+#include "qkbdintegrity_qws.h"
+#include <qwindowsystem_qws.h>
+#include <qapplication.h>
+#include <qtimer.h>
+#include <qthread.h>
+
+#include <INTEGRITY.h>
+
+
+//===========================================================================
+
+QT_BEGIN_NAMESPACE
+
+//
+// INTEGRITY keyboard
+//
+
+class QIntKeyboardListenThread;
+
+class QWSIntKbPrivate : public QObject
+{
+ Q_OBJECT
+ friend class QIntKeyboardListenThread;
+public:
+ QWSIntKbPrivate(QWSKeyboardHandler *, const QString &device);
+ ~QWSIntKbPrivate();
+ void dataReady(int amount) { emit kbdDataAvailable(amount); }
+ uint8_t scancodebuf[32 /* USB_SCANCODE_BUF_LEN */ ];
+ uint8_t rxpost;
+ uint8_t rxack;
+
+Q_SIGNALS:
+ void kbdDataAvailable(int amount);
+
+private Q_SLOTS:
+ void readKeyboardData(int amount);
+
+private:
+ QWSKeyboardHandler *handler;
+ QIntKeyboardListenThread *kbdthread;
+};
+class QIntKeyboardListenThread : public QThread
+{
+protected:
+ QWSIntKbPrivate *imp;
+ bool loop;
+public:
+ QIntKeyboardListenThread(QWSIntKbPrivate *im) : QThread(), imp(im) {};
+ ~QIntKeyboardListenThread() {};
+ void run();
+ void stoploop() { loop = false; };
+};
+
+
+QWSIntKeyboardHandler::QWSIntKeyboardHandler(const QString &device)
+ : QWSKeyboardHandler(device)
+{
+ d = new QWSIntKbPrivate(this, device);
+}
+
+QWSIntKeyboardHandler::~QWSIntKeyboardHandler()
+{
+ delete d;
+}
+
+//void QWSIntKeyboardHandler::processKeyEvent(int keycode, bool isPress,
+// bool autoRepeat)
+//{
+// QWSKeyboardHandler::processKeyEvent(keycode, isPress, autoRepeat);
+//}
+
+void QIntKeyboardListenThread::run(void)
+{
+ Error E;
+ Buffer b;
+ Connection kbdc;
+ bool waitforresource = true;
+ do {
+ E = RequestResource((Object*)&kbdc,
+ "USBKeyboardClient", "!systempassword");
+ if (E == Success) {
+ loop = false;
+ } else {
+ E = RequestResource((Object*)&kbdc,
+ "KeyboardClient", "!systempassword");
+ if (E == Success) {
+ waitforresource = false;
+ }
+ }
+ if (waitforresource)
+ ::sleep(1);
+ } while (loop && waitforresource);
+ if (!loop)
+ return;
+ b.BufferType = DataBuffer | LastBuffer;
+ b.Length = sizeof(imp->scancodebuf);
+ b.TheAddress = (Address)imp->scancodebuf;
+ do {
+ b.Transferred = 0;
+ b.TheAddress = (Address)imp->scancodebuf + imp->rxpost;
+ CheckSuccess(SynchronousReceive(kbdc, &b));
+ imp->rxpost += b.Transferred;
+ if (imp->rxpost >= 32 /* USB_SCANCODE_BUF_LEN */)
+ imp->rxpost = 0;
+ if (imp->rxpost == (imp->rxack + b.Transferred) % 32 /* USB_SCANCODE_BUF_LEN */) {
+ imp->kbdDataAvailable(b.Transferred);
+ }
+ } while (loop);
+}
+
+void QWSIntKbPrivate::readKeyboardData(int amount)
+{
+ uint16_t keycode;
+ do {
+ if (scancodebuf[rxack] == 0xe0) {
+ keycode = scancodebuf[rxack] << 8;
+ rxack++;
+ if (rxack >= 32 /* USB_SCANCODE_BUF_LEN */)
+ rxack = 0;
+ } else {
+ keycode = 0;
+ }
+
+ handler->processKeycode(keycode + (scancodebuf[rxack] & 0x7f),
+ (scancodebuf[rxack] & 0x80) == 0,
+ scancodebuf[rxack] == 2);
+ rxack++;
+ if (rxack >= 32 /* USB_SCANCODE_BUF_LEN */)
+ rxack = 0;
+ } while (rxack != rxpost);
+}
+
+QWSIntKbPrivate::QWSIntKbPrivate(QWSKeyboardHandler *h, const QString &device) : handler(h)
+{
+ connect(this, SIGNAL(kbdDataAvailable(int)), this, SLOT(readKeyboardData(int)));
+ this->handler = handler;
+ rxack = rxpost = 0;
+ kbdthread = new QIntKeyboardListenThread(this);
+ kbdthread->start();
+}
+
+QWSIntKbPrivate::~QWSIntKbPrivate()
+{
+ kbdthread->stoploop();
+ kbdthread->wait();
+ delete kbdthread;
+}
+
+
+QT_END_NAMESPACE
+
+#include "qkbdintegrity_qws.moc"
+
+#endif // QT_NO_QWS_KEYBOARD || QT_NO_QWS_KBD_TTY
diff --git a/src/gui/embedded/qkbdintegrity_qws.h b/src/gui/embedded/qkbdintegrity_qws.h
new file mode 100644
index 0000000..f9ae4e3
--- /dev/null
+++ b/src/gui/embedded/qkbdintegrity_qws.h
@@ -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 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 QKBDINTEGRITY_QWS_H
+#define QKBDINTEGRITY_QWS_H
+
+#include <QtGui/qkbd_qws.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_QWS_KEYBOARD
+
+#ifndef QT_NO_QWS_KBD_INTEGRITY
+
+class QSocketNotifier;
+class QWSIntKbPrivate;
+
+class QWSIntKeyboardHandler : public QWSKeyboardHandler
+{
+public:
+ explicit QWSIntKeyboardHandler(const QString&);
+ virtual ~QWSIntKeyboardHandler();
+
+//protected:
+// virtual void processKeyEvent(int keycode, bool isPress, bool autoRepeat);
+
+private:
+ QWSIntKbPrivate *d;
+};
+
+#endif // QT_NO_QWS_KBD_INTEGRITY
+
+#endif // QT_NO_QWS_KEYBOARD
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QKBDINTEGRITY_QWS_H
diff --git a/src/gui/embedded/qmousedriverfactory_qws.cpp b/src/gui/embedded/qmousedriverfactory_qws.cpp
index 81e6552..f67284d 100644
--- a/src/gui/embedded/qmousedriverfactory_qws.cpp
+++ b/src/gui/embedded/qmousedriverfactory_qws.cpp
@@ -48,6 +48,7 @@
#include "qmousevfb_qws.h"
#include "qmousetslib_qws.h"
#include "qmouseqnx_qws.h"
+#include "qmouseintegrity_qws.h"
#include <stdlib.h>
#include "private/qfactoryloader_p.h"
#include "qmousedriverplugin_qws.h"
@@ -107,6 +108,10 @@ QWSMouseHandler *QMouseDriverFactory::create(const QString& key, const QString &
if (driver == QLatin1String("qnx") || driver.isEmpty())
return new QQnxMouseHandler(key, device);
#endif
+#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_MOUSE_INTEGRITY)
+ if (driver == QLatin1String("integrity") || driver.isEmpty())
+ return new QIntMouseHandler(key, device);
+#endif
#ifndef QT_NO_QWS_MOUSE_LINUXTP
if (driver == QLatin1String("linuxtp") || driver.isEmpty())
return new QWSLinuxTPMouseHandler(key, device);
@@ -157,6 +162,9 @@ QStringList QMouseDriverFactory::keys()
#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_MOUSE_QNX)
list << QLatin1String("QNX");
#endif
+#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_QWS_MOUSE_INTEGRITY)
+ list << QLatin1String("INTEGRITY");
+#endif
#ifndef QT_NO_QWS_MOUSE_LINUXTP
list << QLatin1String("LinuxTP");
#endif
diff --git a/src/gui/embedded/qmouseintegrity_qws.cpp b/src/gui/embedded/qmouseintegrity_qws.cpp
new file mode 100644
index 0000000..78a8c1b
--- /dev/null
+++ b/src/gui/embedded/qmouseintegrity_qws.cpp
@@ -0,0 +1,271 @@
+/****************************************************************************
+**
+** 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 QT_NO_QWS_MOUSE_INTEGRITY
+
+#include "qmouseintegrity_qws.h"
+#include <qwindowsystem_qws.h>
+#include <qapplication.h>
+#include <qtimer.h>
+#include <qthread.h>
+
+#include <INTEGRITY.h>
+
+
+typedef Address MOUSEHandler;
+typedef struct MOUSEMessageStruct
+{
+ Value x;
+ Value y;
+ Value z;
+ Value buttons;
+} MOUSEMessage;
+
+static Error MOUSE_Init(MOUSEHandler *handler, Boolean *isabsolute);
+static Error MOUSE_SynchronousGetPosition(MOUSEHandler handler, MOUSEMessage *msg,
+ Boolean absolute);
+static Error MOUSE_ShouldFilter(MOUSEHandler handler, Boolean *filter);
+
+QT_BEGIN_NAMESPACE
+
+class QIntMouseListenThread;
+
+class QIntMousePrivate : public QObject
+{
+ Q_OBJECT
+ friend class QIntMouseListenTaskThread;
+Q_SIGNALS:
+ void mouseDataAvailable(int x, int y, int buttons);
+public:
+ QIntMousePrivate(QIntMouseHandler *handler);
+ ~QIntMousePrivate();
+ void dataReady(int x, int y, int buttons) { emit mouseDataAvailable(x, y, buttons); }
+ bool calibrated;
+ bool waitforread;
+ bool suspended;
+ QIntMouseListenThread *mousethread;
+
+private:
+ QIntMouseHandler *handler;
+};
+
+class QIntMouseListenThread : public QThread
+{
+protected:
+ QIntMousePrivate *imp;
+ bool loop;
+public:
+ QIntMouseListenThread(QIntMousePrivate *im) : QThread(), imp(im) {};
+ ~QIntMouseListenThread() {};
+ void run();
+ void stoploop() { loop = false; };
+};
+
+
+QIntMouseHandler::QIntMouseHandler(const QString &driver, const QString &device)
+ : QObject(), QWSCalibratedMouseHandler(driver, device)
+{
+ QPoint test(1,1);
+ d = new QIntMousePrivate(this);
+ connect(d, SIGNAL(mouseDataAvailable(int, int, int)), this, SLOT(readMouseData(int, int, int)));
+
+ d->calibrated = (test != transform(test));
+
+ d->mousethread->start();
+}
+
+QIntMouseHandler::~QIntMouseHandler()
+{
+ disconnect(d, SIGNAL(mouseDataAvailable(int, int, int)), this, SLOT(readMouseData(int, int, int)));
+ delete d;
+}
+
+void QIntMouseHandler::resume()
+{
+ d->suspended = true;
+}
+
+void QIntMouseHandler::suspend()
+{
+ d->suspended = false;
+}
+
+void QIntMouseHandler::readMouseData(int x, int y, int buttons)
+{
+ d->waitforread = false;
+ if (d->suspended)
+ return;
+ if (d->calibrated) {
+ sendFiltered(QPoint(x, y), buttons);
+ } else {
+ QPoint pos;
+ pos = transform(QPoint(x, y));
+ limitToScreen(pos);
+ mouseChanged(pos, buttons, 0);
+ }
+}
+
+void QIntMouseHandler::clearCalibration()
+{
+ QWSCalibratedMouseHandler::clearCalibration();
+}
+
+void QIntMouseHandler::calibrate(const QWSPointerCalibrationData *data)
+{
+ QWSCalibratedMouseHandler::calibrate(data);
+}
+
+void QIntMouseListenThread::run(void)
+{
+ MOUSEHandler handler;
+ MOUSEMessage msg;
+ Boolean filter;
+ Boolean isabsolute;
+ loop = true;
+ CheckSuccess(MOUSE_Init(&handler, &isabsolute));
+ CheckSuccess(MOUSE_ShouldFilter(handler, &filter));
+ if (!filter)
+ imp->calibrated = false;
+ imp->waitforread = false;
+ do {
+ MOUSE_SynchronousGetPosition(handler, &msg, isabsolute);
+ imp->dataReady(msg.x, msg.y, msg.buttons);
+ } while (loop);
+ QThread::exit(0);
+}
+
+QIntMousePrivate::QIntMousePrivate(QIntMouseHandler *handler)
+ : QObject()
+{
+ this->handler = handler;
+ suspended = false;
+ mousethread = new QIntMouseListenThread(this);
+}
+
+QIntMousePrivate::~QIntMousePrivate()
+{
+ mousethread->stoploop();
+ mousethread->wait();
+ delete mousethread;
+}
+
+QT_END_NAMESPACE
+
+#include "qmouseintegrity_qws.moc"
+
+typedef struct USBMouseStruct
+{
+ Connection mouseconn;
+ Buffer mousemsg[2];
+ Value x;
+ Value y;
+} USBMouse;
+
+USBMouse mousedev;
+
+Error MOUSE_Init(MOUSEHandler *handler, Boolean *isabsolute)
+{
+ Error E;
+ bool loop = true;
+ memset((void*)&mousedev, 0, sizeof(USBMouse));
+ mousedev.mousemsg[0].BufferType = DataImmediate;
+ mousedev.mousemsg[1].BufferType = DataImmediate | LastBuffer;
+ do {
+ E = RequestResource((Object*)&mousedev.mouseconn,
+ "MouseClient", "!systempassword");
+ if (E == Success) {
+ *isabsolute = true;
+ loop = false;
+ } else {
+ E = RequestResource((Object*)&mousedev.mouseconn,
+ "USBMouseClient", "!systempassword");
+ if (E == Success) {
+ *isabsolute = false;
+ loop = false;
+ }
+ }
+ if (loop)
+ sleep(1);
+ } while (loop);
+ *handler = (MOUSEHandler)&mousedev;
+ return Success;
+}
+
+Error MOUSE_SynchronousGetPosition(MOUSEHandler handler, MOUSEMessage *msg,
+ Boolean isabsolute)
+{
+ signed long x;
+ signed long y;
+ USBMouse *mdev = (USBMouse *)handler;
+ mdev->mousemsg[0].Transferred = 0;
+ mdev->mousemsg[1].Transferred = 0;
+ SynchronousReceive(mdev->mouseconn, mdev->mousemsg);
+ if (isabsolute) {
+ x = (signed long)mdev->mousemsg[0].Length;
+ y = (signed long)mdev->mousemsg[1].TheAddress;
+ } else {
+ x = mdev->x + (signed long)mdev->mousemsg[0].Length;
+ y = mdev->y + (signed long)mdev->mousemsg[1].TheAddress;
+ }
+ if (x < 0)
+ mdev->x = 0;
+ else
+ mdev->x = x;
+ if (y < 0)
+ mdev->y = 0;
+ else
+ mdev->y = y;
+ msg->x = mdev->x;
+ msg->y = mdev->y;
+ msg->buttons = mdev->mousemsg[0].TheAddress;
+ return Success;
+}
+
+Error MOUSE_ShouldFilter(MOUSEHandler handler, Boolean *filter)
+{
+ if (filter == NULL)
+ return Failure;
+ *filter = false;
+ return Success;
+}
+
+#endif // QT_NO_QWS_MOUSE_INTEGRITY
+
diff --git a/src/gui/embedded/qmouseintegrity_qws.h b/src/gui/embedded/qmouseintegrity_qws.h
new file mode 100644
index 0000000..46d27a3
--- /dev/null
+++ b/src/gui/embedded/qmouseintegrity_qws.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** 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 QMOUSEINTEGRITY_QWS_H
+#define QMOUSEINTEGRITY_QWS_H
+
+#include <QtGui/qmouse_qws.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_QWS_MOUSE_INTEGRITY
+
+class QSocketNotifier;
+class QIntMousePrivate;
+
+class QIntMouseHandler : public QObject, public QWSCalibratedMouseHandler {
+ Q_OBJECT
+public:
+ QIntMouseHandler(const QString &driver = QString(),
+ const QString &device = QString());
+ ~QIntMouseHandler();
+
+ void resume();
+ void suspend();
+
+ void calibrate(const QWSPointerCalibrationData *data);
+ void clearCalibration();
+
+private:
+ QIntMousePrivate *d;
+private Q_SLOTS:
+ void readMouseData(int x, int y, int buttons);
+};
+#endif // QT_NO_QWS_MOUSE_INTEGRITY
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMOUSEINTEGRITY_QWS_H
diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp
index 4656af8..e207ed1 100644
--- a/src/gui/embedded/qscreen_qws.cpp
+++ b/src/gui/embedded/qscreen_qws.cpp
@@ -1768,7 +1768,7 @@ QImage::Format QScreenPrivate::preferredImageFormat() const
This function is called by every \l{Qt for Embedded Linux}
application on startup, and must be implemented to map in the
framebuffer and the accelerated drivers that the graphics card
- control registers. Note that coonnect must be called \e before
+ control registers. Note that connect must be called \e before
the initDevice() function.
Ensure that true is returned if a connection to the screen device
diff --git a/src/gui/embedded/qscreen_qws.h b/src/gui/embedded/qscreen_qws.h
index d237dd8..17ffbbb 100644
--- a/src/gui/embedded/qscreen_qws.h
+++ b/src/gui/embedded/qscreen_qws.h
@@ -193,7 +193,7 @@ class Q_GUI_EXPORT QScreen {
public:
enum ClassId { LinuxFBClass, TransformedClass, VNCClass, MultiClass,
VFbClass, DirectFBClass, SvgalibClass, ProxyClass,
- GLClass, CustomClass = 1024 };
+ GLClass, IntfbClass, CustomClass = 1024 };
QScreen(int display_id, ClassId classId);
explicit QScreen(int display_id);
@@ -358,6 +358,7 @@ private:
friend class QLinuxFbScreen;
friend class QVFbScreen;
friend class QProxyScreen;
+ friend class QIntfbScreen;
#endif
friend void qt_solidFill_setup(QScreen*, const QColor&, const QRegion&);
friend void qt_blit_setup(QScreen *screen, const QImage &image,
diff --git a/src/gui/embedded/qscreendriverfactory_qws.cpp b/src/gui/embedded/qscreendriverfactory_qws.cpp
index c0ae214..ea194e5 100644
--- a/src/gui/embedded/qscreendriverfactory_qws.cpp
+++ b/src/gui/embedded/qscreendriverfactory_qws.cpp
@@ -48,6 +48,7 @@
#include "qscreenvfb_qws.h"
#include "qscreenmulti_qws_p.h"
#include "qscreenqnx_qws.h"
+#include "qscreenintegrityfb_qws.h"
#include <stdlib.h>
#include "private/qfactoryloader_p.h"
#include "qscreendriverplugin_qws.h"
@@ -112,6 +113,10 @@ QScreen *QScreenDriverFactory::create(const QString& key, int displayId)
if (driver == QLatin1String("qnx") || driver.isEmpty())
return new QQnxScreen(displayId);
#endif
+#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_QWS_INTEGRITY)
+ if (driver == QLatin1String("integrityfb") || driver.isEmpty())
+ return new QIntfbScreen(displayId);
+#endif
#ifndef QT_NO_QWS_QVFB
if (driver == QLatin1String("qvfb") || driver.isEmpty())
return new QVFbScreen(displayId);
@@ -159,6 +164,9 @@ QStringList QScreenDriverFactory::keys()
#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_QNX)
list << QLatin1String("QNX");
#endif
+#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_QWS_INTEGRITY)
+ list << QLatin1String("INTEGRITYFB");
+#endif
#ifndef QT_NO_QWS_QVFB
list << QLatin1String("QVFb");
#endif
diff --git a/src/gui/embedded/qscreenintegrityfb_qws.cpp b/src/gui/embedded/qscreenintegrityfb_qws.cpp
new file mode 100644
index 0000000..7b24490
--- /dev/null
+++ b/src/gui/embedded/qscreenintegrityfb_qws.cpp
@@ -0,0 +1,405 @@
+/****************************************************************************
+**
+** 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 QT_NO_QWS_INTEGRITYFB
+
+#include <qscreenintegrityfb_qws.h>
+#include <qwindowsystem_qws.h>
+#include <qsocketnotifier.h>
+#include <qapplication.h>
+#include <qscreen_qws.h>
+#include "qmouseintegrity_qws.h"
+#include "qkbdintegrity_qws.h"
+#include <qmousedriverfactory_qws.h>
+#include <qkbddriverfactory_qws.h>
+#include <qdebug.h>
+
+#include <INTEGRITY.h>
+#include <device/fbdriver.h>
+
+QT_BEGIN_NAMESPACE
+
+class QIntfbScreenPrivate
+{
+public:
+ QIntfbScreenPrivate();
+ ~QIntfbScreenPrivate();
+
+ FBHandle handle;
+ struct FBInfoStruct fbinfo;
+
+ QWSMouseHandler *mouse;
+#ifndef QT_NO_QWS_KEYBOARD
+ QWSKeyboardHandler *keyboard;
+#endif
+};
+
+QIntfbScreenPrivate::QIntfbScreenPrivate()
+ : mouse(0)
+
+{
+#ifndef QT_NO_QWS_KEYBOARD
+ keyboard = 0;
+#endif
+}
+
+QIntfbScreenPrivate::~QIntfbScreenPrivate()
+{
+ delete mouse;
+#ifndef QT_NO_QWS_KEYBOARD
+ delete keyboard;
+#endif
+}
+
+/*!
+ \internal
+
+ \class QIntfbScreen
+ \ingroup qws
+
+ \brief The QIntfbScreen class implements a screen driver for the
+ INTEGRITY framebuffer drivers.
+
+ Note that this class is only available in \l{Qt for INTEGRITY}.
+ Custom screen drivers can be added by subclassing the
+ QScreenDriverPlugin class, using the QScreenDriverFactory class to
+ dynamically load the driver into the application, but there should
+ only be one screen object per application.
+
+ \sa QScreen, QScreenDriverPlugin, {Running Applications}
+*/
+
+/*!
+ \fn bool QIntfbScreen::connect(const QString & displaySpec)
+ \reimp
+*/
+
+/*!
+ \fn void QIntfbScreen::disconnect()
+ \reimp
+*/
+
+/*!
+ \fn bool QIntfbScreen::initDevice()
+ \reimp
+*/
+
+/*!
+ \fn void QIntfbScreen::restore()
+ \reimp
+*/
+
+/*!
+ \fn void QIntfbScreen::save()
+ \reimp
+*/
+
+/*!
+ \fn void QIntfbScreen::setDirty(const QRect & r)
+ \reimp
+*/
+
+/*!
+ \fn void QIntfbScreen::setMode(int nw, int nh, int nd)
+ \reimp
+*/
+
+/*!
+ \fn void QIntfbScreen::shutdownDevice()
+ \reimp
+*/
+
+/*!
+ \fn QIntfbScreen::QIntfbScreen(int displayId)
+
+ Constructs a QVNCScreen object. The \a displayId argument
+ identifies the Qt for Embedded Linux server to connect to.
+*/
+QIntfbScreen::QIntfbScreen(int display_id)
+ : QScreen(display_id, IntfbClass), d_ptr(new QIntfbScreenPrivate)
+{
+ d_ptr->handle = 0;
+ data = 0;
+}
+
+/*!
+ Destroys this QIntfbScreen object.
+*/
+QIntfbScreen::~QIntfbScreen()
+{
+ delete d_ptr;
+}
+
+static QIntfbScreen *connected = 0;
+
+bool QIntfbScreen::connect(const QString &displaySpec)
+{
+ FBDriver *fbdev;
+
+ CheckSuccess(gh_FB_get_driver(0, &fbdev));
+ CheckSuccess(gh_FB_init_device(fbdev, 0, &d_ptr->handle));
+ CheckSuccess(gh_FB_get_info(d_ptr->handle, &d_ptr->fbinfo));
+
+ data = (uchar *)d_ptr->fbinfo.start;
+
+ d = d_ptr->fbinfo.bitsperpixel;
+ switch (d) {
+ case 1:
+ setPixelFormat(QImage::Format_Mono);
+ break;
+ case 8:
+ setPixelFormat(QImage::Format_Indexed8);
+ break;
+ case 12:
+ setPixelFormat(QImage::Format_RGB444);
+ break;
+ case 15:
+ setPixelFormat(QImage::Format_RGB555);
+ break;
+ case 16:
+ setPixelFormat(QImage::Format_RGB16);
+ break;
+ case 18:
+ setPixelFormat(QImage::Format_RGB666);
+ break;
+ case 24:
+ setPixelFormat(QImage::Format_RGB888);
+#ifdef QT_QWS_DEPTH_GENERIC
+#if Q_BYTE_ORDER != Q_BIG_ENDIAN
+ qt_set_generic_blit(this, 24,
+ d_ptr->fbinfo.redbits,
+ d_ptr->fbinfo.greenbits,
+ d_ptr->fbinfo.bluebits,
+ d_ptr->fbinfo.alphabits,
+ d_ptr->fbinfo.redoffset,
+ d_ptr->fbinfo.greenoffset,
+ d_ptr->fbinfo.blueoffset,
+ d_ptr->fbinfo.alphaoffset);
+#else
+ qt_set_generic_blit(this, 24,
+ d_ptr->fbinfo.redbits,
+ d_ptr->fbinfo.greenbits,
+ d_ptr->fbinfo.bluebits,
+ d_ptr->fbinfo.alphabits,
+ 16 - d_ptr->fbinfo.redoffset,
+ 16 - d_ptr->fbinfo.greenoffset,
+ 16 - d_ptr->fbinfo.blueoffset,
+ d_ptr->fbinfo.alphaoffset);
+#endif
+#endif
+ break;
+ case 32:
+ setPixelFormat(QImage::Format_ARGB32_Premultiplied);
+#ifdef QT_QWS_DEPTH_GENERIC
+#if Q_BYTE_ORDER != Q_BIG_ENDIAN
+ qt_set_generic_blit(this, 32,
+ d_ptr->fbinfo.redbits,
+ d_ptr->fbinfo.greenbits,
+ d_ptr->fbinfo.bluebits,
+ d_ptr->fbinfo.alphabits,
+ d_ptr->fbinfo.redoffset,
+ d_ptr->fbinfo.greenoffset,
+ d_ptr->fbinfo.blueoffset,
+ d_ptr->fbinfo.alphaoffset);
+#else
+ qt_set_generic_blit(this, 32,
+ d_ptr->fbinfo.redbits,
+ d_ptr->fbinfo.greenbits,
+ d_ptr->fbinfo.bluebits,
+ d_ptr->fbinfo.alphabits,
+ 24 - d_ptr->fbinfo.redoffset,
+ 24 - d_ptr->fbinfo.greenoffset,
+ 24 - d_ptr->fbinfo.blueoffset,
+ d_ptr->fbinfo.alphaoffset ? 24 - d_ptr->fbinfo.alphaoffset : 0);
+#endif
+#endif
+ break;
+ }
+
+ dw = w = d_ptr->fbinfo.width;
+ dh = h = d_ptr->fbinfo.height;
+
+ /* assumes no padding */
+ lstep = w * ((d + 7) >> 3);
+
+ mapsize = size = h * lstep;
+
+ /* default values */
+ int dpi = 72;
+ physWidth = qRound(dw * 25.4 / dpi);
+ physHeight = qRound(dh * 25.4 / dpi);
+
+ qDebug("Connected to INTEGRITYfb server: %d x %d x %d %dx%dmm (%dx%ddpi)",
+ w, h, d, physWidth, physHeight, qRound(dw*25.4/physWidth), qRound(dh*25.4/physHeight) );
+
+
+ QWSServer::setDefaultMouse("integrity");
+ QWSServer::setDefaultKeyboard("integrity");
+
+ connected = this;
+
+ return true;
+}
+
+void QIntfbScreen::disconnect()
+{
+ connected = 0;
+}
+
+bool QIntfbScreen::initDevice()
+{
+
+ CheckSuccess(gh_FB_set_info(d_ptr->handle, &d_ptr->fbinfo, false));
+ CheckSuccess(gh_FB_get_info(d_ptr->handle, &d_ptr->fbinfo));
+ data = (uchar *)d_ptr->fbinfo.start;
+ d = d_ptr->fbinfo.bitsperpixel;
+ dw = w = d_ptr->fbinfo.width;
+ dh = h = d_ptr->fbinfo.height;
+ mapsize = d_ptr->fbinfo.length;
+ /* assumes no padding */
+ lstep = w * ((d + 7) >> 3);
+
+ mapsize = size = h * lstep;
+
+ data = (uchar *)d_ptr->fbinfo.start;
+
+ d = d_ptr->fbinfo.bitsperpixel;
+ switch (d) {
+ case 1:
+ setPixelFormat(QImage::Format_Mono);
+ break;
+ case 8:
+ setPixelFormat(QImage::Format_Indexed8);
+ break;
+ case 12:
+ setPixelFormat(QImage::Format_RGB444);
+ break;
+ case 15:
+ setPixelFormat(QImage::Format_RGB555);
+ break;
+ case 16:
+ setPixelFormat(QImage::Format_RGB16);
+ break;
+ case 18:
+ setPixelFormat(QImage::Format_RGB666);
+ break;
+ case 24:
+ setPixelFormat(QImage::Format_RGB888);
+ break;
+ case 32:
+ setPixelFormat(QImage::Format_ARGB32_Premultiplied);
+ break;
+ }
+#ifdef QT_QWS_DEPTH_GENERIC
+#if defined(__BIG_ENDIAN__)
+ qt_set_generic_blit(this, d,
+ d_ptr->fbinfo.redbits,
+ d_ptr->fbinfo.greenbits,
+ d_ptr->fbinfo.bluebits,
+ d_ptr->fbinfo.alphabits,
+ 24 - d_ptr->fbinfo.redoffset,
+ 24 - d_ptr->fbinfo.greenoffset,
+ 24 - d_ptr->fbinfo.blueoffset,
+ d_ptr->fbinfo.alphaoffset ? 24 - d_ptr->fbinfo.alphaoffset : 0);
+#else
+ qt_set_generic_blit(this, d,
+ d_ptr->fbinfo.redbits,
+ d_ptr->fbinfo.greenbits,
+ d_ptr->fbinfo.bluebits,
+ d_ptr->fbinfo.alphabits,
+ d_ptr->fbinfo.redoffset,
+ d_ptr->fbinfo.greenoffset,
+ d_ptr->fbinfo.blueoffset,
+ d_ptr->fbinfo.alphaoffset);
+#endif
+#endif
+
+#ifndef QT_NO_QWS_CURSOR
+ QScreenCursor::initSoftwareCursor();
+#endif
+ return true;
+}
+
+void QIntfbScreen::shutdownDevice()
+{
+ gh_FB_close(d_ptr->handle);
+}
+
+void QIntfbScreen::setMode(int ,int ,int)
+{
+}
+
+// save the state of the graphics card
+// This is needed so that e.g. we can restore the palette when switching
+// between linux virtual consoles.
+void QIntfbScreen::save()
+{
+ // nothing to do.
+}
+
+// restore the state of the graphics card.
+void QIntfbScreen::restore()
+{
+}
+void QIntfbScreen::setDirty(const QRect& rect)
+{
+ FBRect fbrect;
+ fbrect.dx = rect.x();
+ fbrect.dy = rect.y();
+ fbrect.width = rect.width();
+ fbrect.height = rect.height();
+ gh_FB_expose(d_ptr->handle, &fbrect);
+}
+
+void QIntfbScreen::setBrightness(int b)
+{
+ if (connected) {
+ }
+}
+
+void QIntfbScreen::blank(bool on)
+{
+}
+
+#endif // QT_NO_QWS_INTEGRITYFB
+
+QT_END_NAMESPACE
+
diff --git a/src/gui/embedded/qscreenintegrityfb_qws.h b/src/gui/embedded/qscreenintegrityfb_qws.h
new file mode 100644
index 0000000..06b3967
--- /dev/null
+++ b/src/gui/embedded/qscreenintegrityfb_qws.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 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 QSCREENINTEGRITYFB_QWS_H
+#define QSCREENINTEGRITYFB_QWS_H
+
+#include <QtGui/qscreen_qws.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_QWS_INTEGRITYFB
+
+class QIntfbScreenPrivate;
+
+class Q_GUI_EXPORT QIntfbScreen : public QScreen
+{
+public:
+ explicit QIntfbScreen(int display_id);
+ virtual ~QIntfbScreen();
+ virtual bool initDevice();
+ virtual bool connect(const QString &displaySpec);
+ virtual void disconnect();
+ virtual void shutdownDevice();
+ virtual void save();
+ virtual void restore();
+ virtual void setMode(int nw,int nh,int nd);
+ virtual void setDirty(const QRect& r);
+ virtual void blank(bool);
+ static void setBrightness(int b);
+
+private:
+ QIntfbScreenPrivate *d_ptr;
+};
+
+#endif // QT_NO_QWS_INTEGRITYFB
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSCREENINTEGRITYFB_QWS_H
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp
index b059bd2..014b61b 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp
@@ -56,9 +56,9 @@
Items that are anchored are automatically added to the layout, and if items
are removed, all their anchors will be automatically removed.
- \beginfloatleft
+ \div {float-left}
\inlineimage simpleanchorlayout-example.png Using an anchor layout to align simple colored widgets.
- \endfloat
+ \enddiv
Anchors are always set up between edges of an item, where the "center" is also considered to
be an edge. Consider the following example:
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 01fed8c..ecc8941 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -7689,11 +7689,13 @@ void QGraphicsObject::updateMicroFocus()
void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item)
{
- QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object);
- if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) {
- item->setParentItem(graphicsObject);
- } else {
- QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0);
+ if (item) {
+ QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object);
+ if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) {
+ item->setParentItem(graphicsObject);
+ } else {
+ QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0);
+ }
}
}
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 7b87239..77ccc8e 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -130,7 +130,7 @@
item on the scene gains focus, the scene automatically gains focus. If the
scene has focus, hasFocus() will return true, and key events will be
forwarded to the focus item, if any. If the scene loses focus, (i.e.,
- someone calls clearFocus(),) while an item has focus, the scene will
+ someone calls clearFocus()) while an item has focus, the scene will
maintain its item focus information, and once the scene regains focus, it
will make sure the last focus item regains focus.
@@ -806,28 +806,23 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
}
if (focusItem) {
- QFocusEvent event(QEvent::FocusOut, focusReason);
lastFocusItem = focusItem;
- focusItem = 0;
- sendEvent(lastFocusItem, &event);
#ifndef QT_NO_IM
if (lastFocusItem
&& (lastFocusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)) {
- // Reset any visible preedit text
- QInputMethodEvent imEvent;
- sendEvent(lastFocusItem, &imEvent);
-
// Close any external input method panel. This happens
// automatically by removing WA_InputMethodEnabled on
// the views, but if we are changing focus, we have to
// do it ourselves.
- if (item) {
- for (int i = 0; i < views.size(); ++i)
- if (views.at(i)->inputContext())
- views.at(i)->inputContext()->reset();
- }
+ for (int i = 0; i < views.size(); ++i)
+ if (views.at(i)->inputContext())
+ views.at(i)->inputContext()->reset();
}
+
+ focusItem = 0;
+ QFocusEvent event(QEvent::FocusOut, focusReason);
+ sendEvent(lastFocusItem, &event);
#endif //QT_NO_IM
}
@@ -3104,8 +3099,8 @@ bool QGraphicsScene::stickyFocus() const
\list
\o If the item receives a mouse release event when there are no other
buttons pressed, it loses the mouse grab.
- \o If the item becomes invisible (i.e., someone calls \c {item->setVisible(false))},
- or if it becomes disabled (i.e., someone calls \c {item->setEnabled(false))},
+ \o If the item becomes invisible (i.e., someone calls \c {item->setVisible(false)}),
+ or if it becomes disabled (i.e., someone calls \c {item->setEnabled(false)}),
it loses the mouse grab.
\o If the item is removed from the scene, it loses the mouse grab.
\endlist
@@ -5924,6 +5919,8 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
}
if (item->isPanel())
break;
+ if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
+ break;
}
// If nobody could take focus, clear it.
@@ -5956,6 +5953,8 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
}
if (item && item->isPanel())
break;
+ if (item && (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation))
+ break;
}
touchEvent->setAccepted(eventAccepted);
diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp
index 41ede20..375c723 100644
--- a/src/gui/graphicsview/qgridlayoutengine.cpp
+++ b/src/gui/graphicsview/qgridlayoutengine.cpp
@@ -194,7 +194,8 @@ void QGridLayoutRowData::distributeMultiCells(const QGridLayoutRowInfo &rowInfo)
for (int k = 0; k < span; ++k) {
boxes[start + k].combine(extras[k]);
- stretches[start + k] = qMax(stretches[start + k], stretch);
+ if (stretch != 0)
+ stretches[start + k] = qMax(stretches[start + k], stretch);
}
}
multiCellMap.clear();
@@ -1481,7 +1482,7 @@ void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData, const QLayoutSt
QGridLayoutBox *box;
if (effectiveRowSpan == 1) {
box = &rowBox;
- if (!userRowStretch)
+ if (!userRowStretch && itemStretch != 0)
rowStretch = qMax(rowStretch, itemStretch);
} else {
QGridLayoutMultiCellData &multiCell =
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index fe1a595..076fe0a 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -65,15 +65,14 @@ symbian {
neon:*-g++* {
DEFINES += QT_HAVE_NEON
HEADERS += $$NEON_HEADERS
- SOURCES += $$NEON_SOURCES
DRAWHELPER_NEON_ASM_FILES = $$NEON_ASM
- neon_compiler.commands = $$QMAKE_CXX -c -mfpu=neon
- neon_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
+ neon_compiler.commands = $$QMAKE_CXX -c
+ neon_compiler.commands += $(CXXFLAGS) -mfpu=neon $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
neon_compiler.dependency_type = TYPE_C
neon_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
- neon_compiler.input = DRAWHELPER_NEON_ASM_FILES
+ neon_compiler.input = DRAWHELPER_NEON_ASM_FILES NEON_SOURCES
neon_compiler.variable_out = OBJECTS
neon_compiler.name = compiling[neon] ${QMAKE_FILE_IN}
silent:neon_compiler.commands = @echo compiling[neon] ${QMAKE_FILE_IN} && $$neon_compiler.commands
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp
index 09c086a..6dea9d9 100644
--- a/src/gui/image/qbmphandler.cpp
+++ b/src/gui/image/qbmphandler.cpp
@@ -246,6 +246,8 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
if (depth != 32) {
ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits;
+ if (ncols > 256) // sanity check - don't run out of mem if color table is broken
+ return false;
image.setColorCount(ncols);
}
diff --git a/src/gui/image/qgifhandler.cpp b/src/gui/image/qgifhandler.cpp
index 4dd4743..7cb7373 100644
--- a/src/gui/image/qgifhandler.cpp
+++ b/src/gui/image/qgifhandler.cpp
@@ -1046,7 +1046,7 @@ QGifHandler::QGifHandler()
{
gifFormat = new QGIFFormat;
nextDelay = 100;
- loopCnt = 1;
+ loopCnt = -1;
frameNumber = -1;
scanIsCached = false;
}
@@ -1192,7 +1192,13 @@ int QGifHandler::loopCount() const
QGIFFormat::scan(device(), &imageSizes, &loopCnt);
scanIsCached = true;
}
- return loopCnt-1; // In GIF, loop count is iteration count, so subtract one
+
+ if (loopCnt == 0)
+ return -1;
+ else if (loopCnt == -1)
+ return 0;
+ else
+ return loopCnt;
}
int QGifHandler::currentImageNumber() const
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 91ee697..d992dd5 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -477,12 +477,12 @@ bool QImageData::checkForAlphaPixels() const
function. For example:
\table
+ \header
+ \o {2,1}32-bit
\row
\o \inlineimage qimage-32bit_scaled.png
\o
\snippet doc/src/snippets/code/src_gui_image_qimage.cpp 0
- \header
- \o {2,1}32-bit
\endtable
In case of a 8-bit and monchrome images, the pixel value is only
@@ -498,12 +498,12 @@ bool QImageData::checkForAlphaPixels() const
example:
\table
+ \header
+ \o {2,1} 8-bit
\row
\o \inlineimage qimage-8bit_scaled.png
\o
\snippet doc/src/snippets/code/src_gui_image_qimage.cpp 1
- \header
- \o {2,1} 8-bit
\endtable
QImage also provide the scanLine() function which returns a
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp
index 01baa36..8face87 100644
--- a/src/gui/image/qnativeimage.cpp
+++ b/src/gui/image/qnativeimage.cpp
@@ -181,15 +181,17 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /*
if (ok) {
xshmimg->data = (char*)shmat(xshminfo.shmid, 0, 0);
xshminfo.shmaddr = xshmimg->data;
- if (shmctl(xshminfo.shmid, IPC_RMID, 0) == -1)
- qWarning() << "Error while marking the shared memory segment to be destroyed";
ok = (xshminfo.shmaddr != (char*)-1);
if (ok)
image = QImage((uchar *)xshmimg->data, width, height, format);
}
xshminfo.readOnly = false;
- if (ok)
+ if (ok) {
ok = XShmAttach(X11->display, &xshminfo);
+ XSync(X11->display, False);
+ if (shmctl(xshminfo.shmid, IPC_RMID, 0) == -1)
+ qWarning() << "Error while marking the shared memory segment to be destroyed";
+ }
if (!ok) {
qWarning() << "QNativeImage: Unable to attach to shared memory segment.";
if (xshmimg->data) {
diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp
index dbe8177..ca5f133 100644
--- a/src/gui/image/qpixmap_s60.cpp
+++ b/src/gui/image/qpixmap_s60.cpp
@@ -1012,6 +1012,33 @@ void QS60PixmapData::fromNativeType(void* pixmap, NativeType nativeType)
}
}
+void QS60PixmapData::convertToDisplayMode(int mode)
+{
+ const TDisplayMode displayMode = static_cast<TDisplayMode>(mode);
+ if (!cfbsBitmap || cfbsBitmap->DisplayMode() == displayMode)
+ return;
+ if (image.depth() != TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode)) {
+ qWarning("Cannot convert display mode due to depth mismatch");
+ return;
+ }
+
+ const TSize size = cfbsBitmap->SizeInPixels();
+ QScopedPointer<CFbsBitmap> newBitmap(createSymbianCFbsBitmap(size, displayMode));
+
+ const uchar *sptr = const_cast<const QImage &>(image).bits();
+ symbianBitmapDataAccess->beginDataAccess(newBitmap.data());
+ uchar *dptr = (uchar*)newBitmap->DataAddress();
+ Mem::Copy(dptr, sptr, image.byteCount());
+ symbianBitmapDataAccess->endDataAccess(newBitmap.data());
+
+ QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
+ delete cfbsBitmap;
+ lock.relock();
+ cfbsBitmap = newBitmap.take();
+ setSerialNumber(cfbsBitmap->Handle());
+ UPDATE_BUFFER();
+}
+
QPixmapData *QS60PixmapData::createCompatiblePixmapData() const
{
return new QS60PixmapData(pixelType());
diff --git a/src/gui/image/qpixmap_s60_p.h b/src/gui/image/qpixmap_s60_p.h
index e4060dc..c440bbc 100644
--- a/src/gui/image/qpixmap_s60_p.h
+++ b/src/gui/image/qpixmap_s60_p.h
@@ -107,6 +107,8 @@ public:
void* toNativeType(NativeType type);
void fromNativeType(void* pixmap, NativeType type);
+ void convertToDisplayMode(int mode);
+
private:
void release();
void fromSymbianBitmap(CFbsBitmap* bitmap, bool lockFormat=false);
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index ffad75b..075d5da 100644
--- a/src/gui/image/qxpmhandler.cpp
+++ b/src/gui/image/qxpmhandler.cpp
@@ -864,7 +864,7 @@ static bool read_xpm_body(
QByteArray buf(200, 0);
int i;
- if (cpp > 15)
+ if (cpp < 0 || cpp > 15)
return false;
// For > 256 colors, we delay creation of the image until
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index ff199b1..1bef64d 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -706,6 +706,7 @@ void QCoeFepInputContext::CancelFepInlineEdit()
QInputMethodEvent event(QLatin1String(""), attributes);
event.setCommitString(QLatin1String(""), 0, 0);
m_preeditString.clear();
+ m_inlinePosition = 0;
sendEvent(event);
}
@@ -853,6 +854,7 @@ void QCoeFepInputContext::commitCurrentString(bool cancelFepTransaction)
QInputMethodEvent event(QLatin1String(""), attributes);
event.setCommitString(m_preeditString, 0, 0);
m_preeditString.clear();
+ m_inlinePosition = 0;
sendEvent(event);
m_hasTempPreeditString = false;
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 4dd0aa3..291ec6e 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -657,9 +657,9 @@ QAbstractItemView::~QAbstractItemView()
deleteLater() functions to explicitly delete them.
The view \e{does not} take ownership of the model unless it is the model's
- parent object because the view may be shared between many different views.
+ parent object because the model may be shared between many different views.
- \sa selectionModel(), setSelectionModel()
+ \sa selectionModel(), setSelectionModel()
*/
void QAbstractItemView::setModel(QAbstractItemModel *model)
{
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index d03babb..21c9d3b 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -2744,6 +2744,7 @@ int QTreeView::indexRowSizeHint(const QModelIndex &index) const
int start = -1;
int end = -1;
+ int indexRow = index.row();
int count = d->header->count();
bool emptyHeader = (count == 0);
QModelIndex parent = index.parent();
@@ -2780,7 +2781,7 @@ int QTreeView::indexRowSizeHint(const QModelIndex &index) const
int logicalColumn = emptyHeader ? column : d->header->logicalIndex(column);
if (d->header->isSectionHidden(logicalColumn))
continue;
- QModelIndex idx = d->model->index(index.row(), logicalColumn, parent);
+ QModelIndex idx = d->model->index(indexRow, logicalColumn, parent);
if (idx.isValid()) {
QWidget *editor = d->editorForIndex(idx).widget.data();
if (editor && d->persistent.contains(editor)) {
@@ -3215,14 +3216,14 @@ int QTreeViewPrivate::itemHeight(int item) const
if (viewItems.isEmpty())
return 0;
const QModelIndex &index = viewItems.at(item).index;
+ if (!index.isValid())
+ return 0;
int height = viewItems.at(item).height;
- if (height <= 0 && index.isValid()) {
+ if (height <= 0) {
height = q_func()->indexRowSizeHint(index);
viewItems[item].height = height;
}
- if (!index.isValid() || height < 0)
- return 0;
- return height;
+ return qMax(height, 0);
}
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 5c4a314..e91fe04 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -2771,7 +2771,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
for (int i = 0; i < leaveList.size(); ++i) {
w = leaveList.at(i);
if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC)
if (leaveAfterRelease == w)
leaveAfterRelease = 0;
#endif
@@ -3142,13 +3142,11 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
// Dispatch enter/leave if:
// 1) the mouse grabber is an alien widget
// 2) the button is released on an alien widget
-
QWidget *enter = 0;
if (nativeGuard)
enter = alienGuard ? alienWidget : nativeWidget;
else // The receiver is typically deleted on mouse release with drag'n'drop.
enter = QApplication::widgetAt(event->globalPos());
-
dispatchEnterLeave(enter, leaveAfterRelease);
leaveAfterRelease = 0;
lastMouseReceiver = enter;
@@ -3695,15 +3693,6 @@ void QApplication::changeOverrideCursor(const QCursor &cursor)
if (qApp->d_func()->cursor_list.isEmpty())
return;
qApp->d_func()->cursor_list.removeFirst();
-#ifdef QT_MAC_USE_COCOA
- // We use native NSCursor stacks in Cocoa. The currentCursor is the
- // top of this stack. So to avoid flickering of cursor, we have to
- // change the cusor instead of pop-ing the existing OverrideCursor
- // and pushing the new one.
- qApp->d_func()->cursor_list.prepend(cursor);
- qt_cocoaChangeOverrideCursor(cursor);
- return;
-#endif
setOverrideCursor(cursor);
}
#endif
@@ -4434,6 +4423,24 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
break;
}
#endif // QT_NO_GESTURES
+#ifdef QT_MAC_USE_COCOA
+ case QEvent::Enter:
+ if (receiver->isWidgetType()) {
+ QWidget *w = static_cast<QWidget *>(receiver);
+ if (w->testAttribute(Qt::WA_AcceptTouchEvents))
+ qt_widget_private(w)->registerTouchWindow(true);
+ }
+ res = d->notify_helper(receiver, e);
+ break;
+ case QEvent::Leave:
+ if (receiver->isWidgetType()) {
+ QWidget *w = static_cast<QWidget *>(receiver);
+ if (w->testAttribute(Qt::WA_AcceptTouchEvents))
+ qt_widget_private(w)->registerTouchWindow(false);
+ }
+ res = d->notify_helper(receiver, e);
+ break;
+#endif
default:
res = d->notify_helper(receiver, e);
break;
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index b22a6b3..f607a72 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -165,6 +165,7 @@ QT_BEGIN_NAMESPACE
//for qt_mac.h
QPaintDevice *qt_mac_safe_pdev = 0;
QList<QMacWindowChangeEvent*> *QMacWindowChangeEvent::change_events = 0;
+QPointer<QWidget> topLevelAt_cache = 0;
/*****************************************************************************
Internal variables and functions
@@ -192,7 +193,6 @@ static bool qt_mac_previous_press_in_popup_mode = false;
static bool qt_mac_no_click_through_mode = false;
static int tablet_button_state = 0;
#endif
-QPointer<QWidget> qt_mouseover;
#if defined(QT_DEBUG)
static bool appNoGrab = false; // mouse/keyboard grabbing
#endif
@@ -216,11 +216,12 @@ extern bool qt_mac_can_clickThrough(const QWidget *); //qwidget_mac.cpp
extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.cpp
extern QWidget *qt_mac_find_window(OSWindowRef); //qwidget_mac.cpp
-extern void qt_mac_set_cursor(const QCursor *, const QPoint &); //qcursor_mac.cpp
+extern void qt_mac_set_cursor(const QCursor *); //qcursor_mac.cpp
extern bool qt_mac_is_macsheet(const QWidget *); //qwidget_mac.cpp
extern QString qt_mac_from_pascal_string(const Str255); //qglobal.cpp
extern void qt_mac_command_set_enabled(MenuRef, UInt32, bool); //qmenu_mac.cpp
extern bool qt_sendSpontaneousEvent(QObject *obj, QEvent *event); // qapplication.cpp
+extern void qt_mac_update_cursor(); // qcursor_mac.mm
// Forward Decls
void onApplicationWindowChangedActivation( QWidget*widget, bool activated );
@@ -1364,43 +1365,16 @@ void QApplication::setMainWidget(QWidget *mainWidget)
/*****************************************************************************
QApplication cursor stack
*****************************************************************************/
-#ifdef QT_MAC_USE_COCOA
-void QApplicationPrivate::disableUsageOfCursorRects(bool disable)
-{
- // In Cocoa there are two competing ways of setting the cursor; either
- // by using cursor rects (see qcocoaview_mac.mm), or by pushing/popping
- // the cursor manually. When we use override cursors, it makes most sense
- // to use the latter. But then we need to tell cocoa to stop using the
- // first approach so it doesn't change the cursor back when hovering over
- // a cursor rect:
- QWidgetList topLevels = qApp->topLevelWidgets();
- for (int i=0; i<topLevels.size(); ++i) {
- if (NSWindow *window = qt_mac_window_for(topLevels.at(i)))
- disable ? [window disableCursorRects] : [window enableCursorRects];
- }
-}
-
-void QApplicationPrivate::updateOverrideCursor()
-{
- // Sometimes Cocoa forgets that we have set a Cursor
- // manually. In those cases, remind it again:
- if (QCursor *override = qApp->overrideCursor())
- [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(*override)) set];
-}
-#endif
void QApplication::setOverrideCursor(const QCursor &cursor)
{
qApp->d_func()->cursor_list.prepend(cursor);
#ifdef QT_MAC_USE_COCOA
- QMacCocoaAutoReleasePool pool;
- if (qApp->d_func()->cursor_list.size() == 1)
- qApp->d_func()->disableUsageOfCursorRects(true);
- [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(cursor)) push];
+ qt_mac_update_cursor();
#else
if (qApp && qApp->activeWindow())
- qt_mac_set_cursor(&qApp->d_func()->cursor_list.first(), QCursor::pos());
+ qt_mac_set_cursor(&qApp->d_func()->cursor_list.first());
#endif
}
@@ -1411,14 +1385,11 @@ void QApplication::restoreOverrideCursor()
qApp->d_func()->cursor_list.removeFirst();
#ifdef QT_MAC_USE_COCOA
- QMacCocoaAutoReleasePool pool;
- [NSCursor pop];
- if (qApp->d_func()->cursor_list.isEmpty())
- qApp->d_func()->disableUsageOfCursorRects(false);
+ qt_mac_update_cursor();
#else
if (qApp && qApp->activeWindow()) {
const QCursor def(Qt::ArrowCursor);
- qt_mac_set_cursor(qApp->d_func()->cursor_list.isEmpty() ? &def : &qApp->d_func()->cursor_list.first(), QCursor::pos());
+ qt_mac_set_cursor(qApp->d_func()->cursor_list.isEmpty() ? &def : &qApp->d_func()->cursor_list.first());
}
#endif
}
@@ -1431,30 +1402,54 @@ QWidget *QApplication::topLevelAt(const QPoint &p)
qt_mac_window_at(p.x(), p.y(), &widget);
return widget;
#else
+ // Use a cache to avoid iterate through the whole list of windows for all
+ // calls to to topLevelAt. We e.g. do this for each and every mouse
+ // move since we need to find the widget under mouse:
+ if (topLevelAt_cache && topLevelAt_cache->frameGeometry().contains(p))
+ return topLevelAt_cache;
+
+ // INVARIANT: Cache miss. Go through the list if windows instead:
+ QMacCocoaAutoReleasePool pool;
+ NSPoint cocoaPoint = flipPoint(p);
NSInteger windowCount;
NSCountWindows(&windowCount);
if (windowCount <= 0)
return 0; // There's no window to find!
- QMacCocoaAutoReleasePool pool;
- NSPoint cocoaPoint = flipPoint(p);
+
QVarLengthArray<NSInteger> windowList(windowCount);
NSWindowList(windowCount, windowList.data());
+ int firstQtWindowFound = -1;
for (int i = 0; i < windowCount; ++i) {
NSWindow *window = [NSApp windowWithWindowNumber:windowList[i]];
- if (window && NSPointInRect(cocoaPoint, [window frame])) {
+ if (window) {
QWidget *candidateWindow = [window QT_MANGLE_NAMESPACE(qt_qwidget)];
- // Check to see if there's a hole in the window where the mask is.
- // If there is, we should just continue to see if there is a window below.
- if (candidateWindow && !candidateWindow->mask().isEmpty()) {
- QPoint localPoint = candidateWindow->mapFromGlobal(p);
- if (!candidateWindow->mask().contains(localPoint)) {
- continue;
+ if (candidateWindow && firstQtWindowFound == -1)
+ firstQtWindowFound = i;
+
+ if (NSPointInRect(cocoaPoint, [window frame])) {
+ // Check to see if there's a hole in the window where the mask is.
+ // If there is, we should just continue to see if there is a window below.
+ if (candidateWindow && !candidateWindow->mask().isEmpty()) {
+ QPoint localPoint = candidateWindow->mapFromGlobal(p);
+ if (!candidateWindow->mask().contains(localPoint))
+ continue;
+ else
+ return candidateWindow;
+ } else {
+ if (i == firstQtWindowFound) {
+ // The cache will only work when the window under mouse is
+ // top most (that is, not partially obscured by other windows.
+ // And we only set it if no mask is present to optimize for the common case:
+ topLevelAt_cache = candidateWindow;
+ }
+ return candidateWindow;
}
}
- return candidateWindow;
}
}
- return 0; // Couldn't find a window at this point
+
+ topLevelAt_cache = 0;
+ return 0;
#endif
}
@@ -1480,8 +1475,8 @@ void QApplicationPrivate::enterModal_sys(QWidget *widget)
if (!qt_modal_stack)
qt_modal_stack = new QWidgetList;
- dispatchEnterLeave(0, qt_mouseover);
- qt_mouseover = 0;
+ dispatchEnterLeave(0, qt_last_mouse_receiver);
+ qt_last_mouse_receiver = 0;
qt_modal_stack->insert(0, widget);
if (!app_do_modal)
@@ -1512,8 +1507,8 @@ void QApplicationPrivate::leaveModal_sys(QWidget *widget)
w = grabber;
else
w = QApplication::widgetAt(p.x(), p.y());
- dispatchEnterLeave(w, qt_mouseover); // send synthetic enter event
- qt_mouseover = w;
+ dispatchEnterLeave(w, qt_last_mouse_receiver); // send synthetic enter event
+ qt_last_mouse_receiver = w;
}
#ifdef QT_MAC_USE_COCOA
if (!qt_mac_is_macsheet(widget))
@@ -1938,7 +1933,7 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
}
}
}
- qt_mac_set_cursor(&cursor, QPoint(where.h, where.v));
+ qt_mac_set_cursor(&cursor);
}
//This mouse button state stuff looks like this on purpose
@@ -2132,20 +2127,20 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
QWidget * const enterLeaveWidget = (inPopupMode || ekind == kEventMouseUp) ?
QApplication::widgetAt(where.h, where.v) : static_cast<QWidget*>(widget);
- if ((QWidget *) qt_mouseover != enterLeaveWidget || inNonClientArea) {
+ if ((QWidget *) qt_last_mouse_receiver != enterLeaveWidget || inNonClientArea) {
#ifdef DEBUG_MOUSE_MAPS
qDebug("Entering: %p - %s (%s), Leaving %s (%s)", (QWidget*)enterLeaveWidget,
enterLeaveWidget ? enterLeaveWidget->metaObject()->className() : "none",
enterLeaveWidget ? enterLeaveWidget->objectName().toLocal8Bit().constData() : "",
- qt_mouseover ? qt_mouseover->metaObject()->className() : "none",
- qt_mouseover ? qt_mouseover->objectName().toLocal8Bit().constData() : "");
+ qt_last_mouse_receiver ? qt_last_mouse_receiver->metaObject()->className() : "none",
+ qt_last_mouse_receiver ? qt_last_mouse_receiver->objectName().toLocal8Bit().constData() : "");
#endif
QWidget * const mouseGrabber = QWidget::mouseGrabber();
if (inPopupMode) {
QWidget *enter = enterLeaveWidget;
- QWidget *leave = qt_mouseover;
+ QWidget *leave = qt_last_mouse_receiver;
if (mouseGrabber) {
QWidget * const popupWidget = qApp->activePopupWidget();
if (leave == popupWidget)
@@ -2155,15 +2150,15 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
if ((enter == mouseGrabber && leave == popupWidget)
|| (leave == mouseGrabber && enter == popupWidget)) {
QApplicationPrivate::dispatchEnterLeave(enter, leave);
- qt_mouseover = enter;
+ qt_last_mouse_receiver = enter;
}
} else {
QApplicationPrivate::dispatchEnterLeave(enter, leave);
- qt_mouseover = enter;
+ qt_last_mouse_receiver = enter;
}
- } else if ((!qt_button_down || !qt_mouseover) && !mouseGrabber && !leaveAfterRelease) {
- QApplicationPrivate::dispatchEnterLeave(enterLeaveWidget, qt_mouseover);
- qt_mouseover = enterLeaveWidget;
+ } else if ((!qt_button_down || !qt_last_mouse_receiver) && !mouseGrabber && !leaveAfterRelease) {
+ QApplicationPrivate::dispatchEnterLeave(enterLeaveWidget, qt_last_mouse_receiver);
+ qt_last_mouse_receiver = enterLeaveWidget;
}
}
break; }
@@ -2240,7 +2235,7 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
if (leaveAfterRelease) {
QWidget *enter = QApplication::widgetAt(where.h, where.v);
QApplicationPrivate::dispatchEnterLeave(enter, leaveAfterRelease);
- qt_mouseover = enter;
+ qt_last_mouse_receiver = enter;
leaveAfterRelease = 0;
}
@@ -2503,7 +2498,7 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
void QApplicationPrivate::qt_initAfterNSAppStarted()
{
setupAppleEvents();
- updateOverrideCursor();
+ qt_mac_update_cursor();
}
void QApplicationPrivate::setupAppleEvents()
@@ -3080,7 +3075,7 @@ void onApplicationWindowChangedActivation(QWidget *widget, bool activated)
}
QMenuBar::macUpdateMenuBar();
- QApplicationPrivate::updateOverrideCursor();
+ qt_mac_update_cursor();
#else
Q_UNUSED(widget);
Q_UNUSED(activated);
@@ -3115,6 +3110,7 @@ void onApplicationChangedActivation( bool activated )
app->setActiveWindow(tmp_w);
}
QMenuBar::macUpdateMenuBar();
+ qt_mac_update_cursor();
} else { // de-activated
QApplicationPrivate *priv = [[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] qAppPrivate];
while (priv->inPopupMode())
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 1a511a8..a6815a8 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -489,8 +489,6 @@ public:
#ifdef QT_MAC_USE_COCOA
static void qt_initAfterNSAppStarted();
static void setupAppleEvents();
- static void updateOverrideCursor();
- static void disableUsageOfCursorRects(bool disable);
#endif
static bool qt_mac_apply_settings();
#endif
diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp
index f0801e3..642d3e6 100644
--- a/src/gui/kernel/qapplication_qws.cpp
+++ b/src/gui/kernel/qapplication_qws.cpp
@@ -204,6 +204,11 @@ QString qws_dataDir()
result = QT_VFB_DATADIR(qws_display_id);
QByteArray dataDir = result.toLocal8Bit();
+#if defined(Q_OS_INTEGRITY)
+ /* ensure filesystem is ready before starting requests */
+ WaitForFileSystemInitialization();
+#endif
+
if (QT_MKDIR(dataDir, 0700)) {
if (errno != EEXIST) {
qFatal("Cannot create Qt for Embedded Linux data directory: %s", dataDir.constData());
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 3a70dd5..586869a 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -87,7 +87,7 @@
#include <hal.h>
#include <hal_data.h>
-#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+#ifdef Q_SYMBIAN_TRANSITION_EFFECTS
#include <graphics/wstfxconst.h>
#endif
@@ -432,7 +432,7 @@ void QSymbianControl::ConstructL(bool isWindowOwning, bool desktop)
DrawableWindow()->SetPointerGrab(ETrue);
}
-#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+#ifdef Q_SYMBIAN_TRANSITION_EFFECTS
if (OwnsWindow()) {
TTfxWindowPurpose windowPurpose(ETfxPurposeNone);
switch (qwidget->windowType()) {
@@ -1245,12 +1245,14 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */)
#ifdef Q_WS_S60
// If widget is fullscreen/minimized, hide status pane and button container otherwise show them.
QWidget *const window = qwidget->window();
- const bool visible = !(window->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized));
- const bool statusPaneVisibility = visible;
- const bool isFullscreen = window->windowState() & Qt::WindowFullScreen;
- const bool cbaVisibilityHint = window->windowFlags() & Qt::WindowSoftkeysVisibleHint;
- const bool buttonGroupVisibility = (visible || (isFullscreen && cbaVisibilityHint));
- S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility);
+ if (!window->parentWidget()) { // Only top level native windows have control over cba/status pane
+ const bool decorationsVisible = !(window->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized));
+ const bool statusPaneVisibility = decorationsVisible;
+ const bool isFullscreen = window->windowState() & Qt::WindowFullScreen;
+ const bool cbaVisibilityHint = window->windowFlags() & Qt::WindowSoftkeysVisibleHint;
+ const bool buttonGroupVisibility = (decorationsVisible || (isFullscreen && cbaVisibilityHint));
+ S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility);
+ }
#endif
} else if (QApplication::activeWindow() == qwidget->window()) {
bool focusedControlFound = false;
@@ -1545,6 +1547,8 @@ void qt_init(QApplicationPrivate * /* priv */, int)
repository = 0;
#endif
+ qt_keymapper_private()->updateInputLanguage();
+
#ifdef QT_KEYPAD_NAVIGATION
if (touch) {
QApplicationPrivate::navigationMode = Qt::NavigationModeNone;
@@ -1584,7 +1588,7 @@ void qt_init(QApplicationPrivate * /* priv */, int)
systemFont.setFamily(systemFont.defaultFamily());
QApplicationPrivate::setSystemFont(systemFont);
-#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+#ifdef Q_SYMBIAN_TRANSITION_EFFECTS
QObject::connect(qApp, SIGNAL(aboutToQuit()), qApp, SLOT(_q_aboutToQuit()));
#endif
@@ -1616,7 +1620,9 @@ void qt_init(QApplicationPrivate * /* priv */, int)
qRegisterMetaType<WId>("WId");
}
-extern void qt_cleanup_symbianFontDatabaseExtras(); // qfontdatabase_s60.cpp
+#ifdef QT_NO_FREETYPE
+extern void qt_cleanup_symbianFontDatabase(); // qfontdatabase_s60.cpp
+#endif
/*****************************************************************************
qt_cleanup() - cleans up when the application is finished
@@ -1633,7 +1639,9 @@ void qt_cleanup()
QFontCache::cleanup(); // Has to happen now, since QFontEngineS60 has FBS handles
QPixmapCache::clear(); // Has to happen now, since QS60PixmapData has FBS handles
- qt_cleanup_symbianFontDatabaseExtras();
+#ifdef QT_NO_FREETYPE
+ qt_cleanup_symbianFontDatabase();
+#endif
// S60 structure and window server session are freed in eventdispatcher destructor as they are needed there
// It's important that this happens here, before the event dispatcher gets
@@ -1687,7 +1695,7 @@ bool QApplicationPrivate::modalState()
void QApplicationPrivate::enterModal_sys(QWidget *widget)
{
-#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+#ifdef Q_SYMBIAN_TRANSITION_EFFECTS
S60->wsSession().SendEffectCommand(ETfxCmdAppModalModeEnter);
#endif
if (widget) {
@@ -1705,7 +1713,7 @@ void QApplicationPrivate::enterModal_sys(QWidget *widget)
void QApplicationPrivate::leaveModal_sys(QWidget *widget)
{
-#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+#ifdef Q_SYMBIAN_TRANSITION_EFFECTS
S60->wsSession().SendEffectCommand(ETfxCmdAppModalModeExit);
#endif
if (widget) {
@@ -2019,6 +2027,9 @@ int QApplicationPrivate::symbianProcessWsEvent(const QSymbianEvent *symbianEvent
S60->wsSession().SetPointerCursorMode(EPointerCursorNormal);
}
#endif
+#ifdef QT_SOFTKEYS_ENABLED
+ QSoftKeyManager::updateSoftKeys();
+#endif
break;
case EEventFocusLost:
if (callSymbianEventFilters(symbianEvent))
@@ -2085,6 +2096,13 @@ int QApplicationPrivate::symbianProcessWsEvent(const QSymbianEvent *symbianEvent
}
break;
#endif
+
+#ifdef Q_WS_S60
+ case KEikInputLanguageChange:
+ qt_keymapper_private()->updateInputLanguage();
+ break;
+#endif
+
default:
break;
}
@@ -2383,7 +2401,7 @@ void QApplication::restoreOverrideCursor()
void QApplicationPrivate::_q_aboutToQuit()
{
-#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+#ifdef Q_SYMBIAN_TRANSITION_EFFECTS
// Send the shutdown tfx command
S60->wsSession().SendEffectCommand(ETfxCmdAppShutDown);
#endif
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 2c51722..589b12e 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -5227,14 +5227,15 @@ bool QETWidget::translateConfigEvent(const XEvent *event)
bool trust = isVisible()
&& (d->topData()->parentWinId == XNone ||
d->topData()->parentWinId == QX11Info::appRootWindow());
+ bool isCPos = false;
if (event->xconfigure.send_event || trust) {
// if a ConfigureNotify comes from a real sendevent request, we can
// trust its values.
newCPos.rx() = event->xconfigure.x + event->xconfigure.border_width;
newCPos.ry() = event->xconfigure.y + event->xconfigure.border_width;
+ isCPos = true;
}
-
if (isVisible())
QApplication::syncX();
@@ -5260,6 +5261,7 @@ bool QETWidget::translateConfigEvent(const XEvent *event)
otherEvent.xconfigure.border_width;
newCPos.ry() = otherEvent.xconfigure.y +
otherEvent.xconfigure.border_width;
+ isCPos = true;
}
}
#ifndef QT_NO_XSYNC
@@ -5272,6 +5274,19 @@ bool QETWidget::translateConfigEvent(const XEvent *event)
#endif // QT_NO_XSYNC
}
+ if (!isCPos) {
+ // we didn't get an updated position of the toplevel.
+ // either we haven't moved or there is a bug in the window manager.
+ // anyway, let's query the position to be certain.
+ int x, y;
+ Window child;
+ XTranslateCoordinates(X11->display, internalWinId(),
+ QApplication::desktop()->screen(d->xinfo.screen())->internalWinId(),
+ 0, 0, &x, &y, &child);
+ newCPos.rx() = x;
+ newCPos.ry() = y;
+ }
+
QRect cr (geometry());
if (newCPos != cr.topLeft()) { // compare with cpos (exluding frame)
QPoint oldPos = geometry().topLeft();
@@ -5314,18 +5329,6 @@ bool QETWidget::translateConfigEvent(const XEvent *event)
}
if (wasResize) {
- static bool slowResize = qgetenv("QT_SLOW_TOPLEVEL_RESIZE").toInt();
- if (d->extra->compress_events && !slowResize && !data->in_show && isVisible()) {
- QApplication::syncX();
- XEvent otherEvent;
- while (XCheckTypedWindowEvent(X11->display, internalWinId(), ConfigureNotify, &otherEvent)
- && !qt_x11EventFilter(&otherEvent) && !x11Event(&otherEvent)
- && otherEvent.xconfigure.event == otherEvent.xconfigure.window) {
- data->crect.setWidth(otherEvent.xconfigure.width);
- data->crect.setHeight(otherEvent.xconfigure.height);
- }
- }
-
if (isVisible() && data->crect.size() != oldSize) {
Q_ASSERT(d->extra->topextra);
QWidgetBackingStore *bs = d->extra->topextra->backingStore.data();
@@ -5334,7 +5337,7 @@ bool QETWidget::translateConfigEvent(const XEvent *event)
// resize optimization in order to get invalidated regions for resized widgets.
// The optimization discards all invalidateBuffer() calls since we're going to
// repaint everything anyways, but that's not the case with static contents.
- if (!slowResize && !hasStaticContents)
+ if (!hasStaticContents)
d->extra->topextra->inTopLevelResize = true;
QResizeEvent e(data->crect.size(), oldSize);
QApplication::sendSpontaneousEvent(this, &e);
@@ -5658,10 +5661,21 @@ static void sm_performSaveYourself(QSessionManagerPrivate* smd)
sm_setProperty(QString::fromLatin1(SmProgram), argument0);
// tell the session manager about our user as well.
struct passwd *entryPtr = 0;
-#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
- QVarLengthArray<char, 1024> buf(sysconf(_SC_GETPW_R_SIZE_MAX));
+#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
+ QVarLengthArray<char, 1024> buf(qMax<long>(sysconf(_SC_GETPW_R_SIZE_MAX), 1024L));
struct passwd entry;
- getpwuid_r(geteuid(), &entry, buf.data(), buf.size(), &entryPtr);
+ while (getpwuid_r(geteuid(), &entry, buf.data(), buf.size(), &entryPtr) == ERANGE) {
+ if (buf.size() >= 32768) {
+ // too big already, fail
+ static char badusername[] = "";
+ entryPtr = &entry;
+ entry.pw_name = badusername;
+ break;
+ }
+
+ // retry with a bigger buffer
+ buf.resize(buf.size() * 2);
+ }
#else
entryPtr = getpwuid(geteuid());
#endif
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
index bf4d9e5..77cd890 100644
--- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
+++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
@@ -90,6 +90,10 @@
QT_BEGIN_NAMESPACE
extern void onApplicationChangedActivation(bool); // qapplication_mac.mm
extern void qt_release_apple_event_handler(); //qapplication_mac.mm
+extern QPointer<QWidget> qt_last_mouse_receiver; // qapplication_mac.cpp
+extern QPointer<QWidget> qt_last_native_mouse_receiver; // qt_cocoa_helpers_mac.mm
+extern QPointer<QWidget> qt_button_down; // qapplication_mac.cpp
+
QT_END_NAMESPACE
QT_FORWARD_DECLARE_CLASS(QDesktopWidgetImplementation)
@@ -254,7 +258,20 @@ static void cleanupCocoaApplicationDelegate()
if (reflectionDelegate
&& [reflectionDelegate respondsToSelector:@selector(applicationDidBecomeActive:)])
[reflectionDelegate applicationDidBecomeActive:notification];
+
onApplicationChangedActivation(true);
+
+ if (!QWidget::mouseGrabber()){
+ // Update enter/leave immidiatly, don't wait for a move event. But only
+ // if no grab exists (even if the grab points to this widget, it seems, ref X11)
+ QPoint qlocal, qglobal;
+ QWidget *widgetUnderMouse = 0;
+ qt_mac_getTargetForMouseEvent(0, QEvent::Enter, qlocal, qglobal, 0, &widgetUnderMouse);
+ QApplicationPrivate::dispatchEnterLeave(widgetUnderMouse, 0);
+ qt_last_mouse_receiver = widgetUnderMouse;
+ qt_last_native_mouse_receiver = widgetUnderMouse ?
+ (widgetUnderMouse->internalWinId() ? widgetUnderMouse : widgetUnderMouse->nativeParentWidget()) : 0;
+ }
}
- (void)applicationDidResignActive:(NSNotification *)notification
@@ -262,7 +279,14 @@ static void cleanupCocoaApplicationDelegate()
if (reflectionDelegate
&& [reflectionDelegate respondsToSelector:@selector(applicationDidResignActive:)])
[reflectionDelegate applicationDidResignActive:notification];
+
onApplicationChangedActivation(false);
+
+ if (!QWidget::mouseGrabber())
+ QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver);
+ qt_last_mouse_receiver = 0;
+ qt_last_native_mouse_receiver = 0;
+ qt_button_down = 0;
}
- (void)applicationDidChangeScreenParameters:(NSNotification *)notification
diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/gui/kernel/qcocoapanel_mac.mm
index a0f17bc..67a12e2 100644
--- a/src/gui/kernel/qcocoapanel_mac.mm
+++ b/src/gui/kernel/qcocoapanel_mac.mm
@@ -47,9 +47,10 @@
#import <private/qcocoaview_mac_p.h>
#import <private/qcocoawindowcustomthemeframe_mac_p.h>
#import <private/qcocoaapplication_mac_p.h>
-#include <private/qapplication_p.h>
-#include <private/qbackingstore_p.h>
-
+#import <private/qmultitouch_mac_p.h>
+#import <private/qapplication_p.h>
+#import <private/qbackingstore_p.h>
+#import <private/qdnd_p.h>
#include <QtGui/QWidget>
diff --git a/src/gui/kernel/qcocoapanel_mac_p.h b/src/gui/kernel/qcocoapanel_mac_p.h
index e4dd73b..b41a4b5 100644
--- a/src/gui/kernel/qcocoapanel_mac_p.h
+++ b/src/gui/kernel/qcocoapanel_mac_p.h
@@ -50,20 +50,27 @@
// We mean it.
//
+#ifndef QCOCOAPANEL_MAC_P
+#define QCOCOAPANEL_MAC_P
+
#include "qmacdefines_mac.h"
#ifdef QT_MAC_USE_COCOA
#import <Cocoa/Cocoa.h>
QT_FORWARD_DECLARE_CLASS(QStringList);
+QT_FORWARD_DECLARE_CLASS(QCocoaDropData);
@interface QT_MANGLE_NAMESPACE(QCocoaPanel) : NSPanel {
- bool leftButtonIsRightButton;
QStringList *currentCustomDragTypes;
+ QCocoaDropData *dropData;
+ NSInteger dragEnterSequence;
}
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask;
- (void)registerDragTypes;
+- (void)drawRectOriginal:(NSRect)rect;
@end
#endif
+#endif
diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
index df0f24e..c4b74c6 100644
--- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
+++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
@@ -62,7 +62,6 @@ extern void qt_event_request_window_change(QWidget *); // qapplication_mac.mm
extern void qt_mac_send_posted_gl_updates(QWidget *widget); // qapplication_mac.mm
Q_GLOBAL_STATIC(QPointer<QWidget>, currentDragTarget);
-
QT_END_NAMESPACE
- (id)initWithContentRect:(NSRect)contentRect
@@ -89,6 +88,8 @@ QT_END_NAMESPACE
QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)];
if (!widget)
return NO; // This should happen only for qt_root_win
+ if (QApplicationPrivate::isBlockedByModal(widget))
+ return NO;
bool isToolTip = (widget->windowType() == Qt::ToolTip);
bool isPopup = (widget->windowType() == Qt::Popup);
@@ -100,6 +101,8 @@ QT_END_NAMESPACE
QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)];
if (!widget)
return NO; // This should happen only for qt_root_win
+ if ([self isSheet])
+ return NO;
bool isToolTip = (widget->windowType() == Qt::ToolTip);
bool isPopup = (widget->windowType() == Qt::Popup);
@@ -145,66 +148,27 @@ QT_END_NAMESPACE
- (void)sendEvent:(NSEvent *)event
{
- QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
- // Cocoa can hold onto the window after we've disavowed its knowledge. So,
- // if we get sent an event afterwards just have it go through the super's
- // version and don't do any stuff with Qt.
- if (!widget) {
- [super sendEvent:event];
- return;
- }
-
[self retain];
- QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_nativeview_for(widget));
- Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]);
bool handled = false;
- // sometimes need to redirect mouse events to the popup.
- QWidget *popup = qAppInstance()->activePopupWidget();
- if (popup && popup != widget) {
- switch([event type])
- {
- case NSLeftMouseDown:
- if (!qt_button_down)
- qt_button_down = widget;
- handled = qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton);
- // Don't call super here. This prevents us from getting the mouseUp event,
- // which we need to send even if the mouseDown event was not accepted.
- // (this is standard Qt behavior.)
- break;
- case NSRightMouseDown:
- case NSOtherMouseDown:
- if (!qt_button_down)
- qt_button_down = widget;
- handled = qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton);
- break;
- case NSLeftMouseUp:
- case NSRightMouseUp:
- case NSOtherMouseUp:
- handled = qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonRelease, mouseButton);
- qt_button_down = 0;
- break;
- case NSMouseMoved:
- handled = qt_mac_handleMouseEvent(view, event, QEvent::MouseMove, Qt::NoButton);
- break;
- case NSLeftMouseDragged:
- case NSRightMouseDragged:
- case NSOtherMouseDragged:
- [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->view = view;
- [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->theEvent = event;
- handled = qt_mac_handleMouseEvent(view, event, QEvent::MouseMove, mouseButton);
- break;
- default:
- [super sendEvent:event];
- break;
- }
- } else {
- [super sendEvent:event];
+ switch([event type]) {
+ case NSMouseMoved:
+ // Cocoa sends move events to a parent and all its children under the mouse, much
+ // like Qt handles hover events. But we only want to handle the move event once, so
+ // to optimize a bit (since we subscribe for move event for all views), we handle it
+ // here before this logic happends. Note: it might be tempting to do this shortcut for
+ // all mouse events. The problem is that Cocoa does more than just find the correct view
+ // when sending the event, like raising windows etc. So avoid it as much as possible:
+ handled = qt_mac_handleMouseEvent(event, QEvent::MouseMove, Qt::NoButton, 0);
+ break;
+ default:
+ break;
}
- if (!handled)
- qt_mac_dispatchNCMouseMessage(self, event, [self QT_MANGLE_NAMESPACE(qt_qwidget)], leftButtonIsRightButton);
-
+ if (!handled) {
+ [super sendEvent:event];
+ qt_mac_handleNonClientAreaMouseEvent(self, event);
+ }
[self release];
}
@@ -237,6 +201,56 @@ QT_END_NAMESPACE
return [super frameViewClassForStyleMask:styleMask];
}
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+- (void)touchesBeganWithEvent:(NSEvent *)event;
+{
+ QPoint qlocal, qglobal;
+ QWidget *widgetToGetTouch = 0;
+ qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, 0, &widgetToGetTouch);
+ if (!widgetToGetTouch)
+ return;
+
+ bool all = widgetToGetTouch->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
+ qt_translateRawTouchEvent(widgetToGetTouch, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
+}
+
+- (void)touchesMovedWithEvent:(NSEvent *)event;
+{
+ QPoint qlocal, qglobal;
+ QWidget *widgetToGetTouch = 0;
+ qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, 0, &widgetToGetTouch);
+ if (!widgetToGetTouch)
+ return;
+
+ bool all = widgetToGetTouch->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
+ qt_translateRawTouchEvent(widgetToGetTouch, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
+}
+
+- (void)touchesEndedWithEvent:(NSEvent *)event;
+{
+ QPoint qlocal, qglobal;
+ QWidget *widgetToGetTouch = 0;
+ qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, 0, &widgetToGetTouch);
+ if (!widgetToGetTouch)
+ return;
+
+ bool all = widgetToGetTouch->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
+ qt_translateRawTouchEvent(widgetToGetTouch, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
+}
+
+- (void)touchesCancelledWithEvent:(NSEvent *)event;
+{
+ QPoint qlocal, qglobal;
+ QWidget *widgetToGetTouch = 0;
+ qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, 0, &widgetToGetTouch);
+ if (!widgetToGetTouch)
+ return;
+
+ bool all = widgetToGetTouch->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
+ qt_translateRawTouchEvent(widgetToGetTouch, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
+}
+#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+
-(void)registerDragTypes
{
// Calling registerForDraggedTypes below is slow, so only do
@@ -259,21 +273,47 @@ QT_END_NAMESPACE
NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil];
// Add custom types supported by the application.
for (int i = 0; i < customTypes.size(); i++) {
- [supportedTypes addObject:reinterpret_cast<const NSString *>(QCFString::toCFStringRef(customTypes[i]))];
+ [supportedTypes addObject:qt_mac_QStringToNSString(customTypes[i])];
}
[self registerForDraggedTypes:supportedTypes];
}
}
-- (QWidget *)dragTargetHitTest:(id <NSDraggingInfo>)sender
+- (void)removeDropData
{
- // Do a hittest to find the NSView under the
- // mouse, and return the corresponding QWidget:
- NSPoint windowPoint = [sender draggingLocation];
- NSView *candidateView = [[self contentView] hitTest:windowPoint];
- if (![candidateView isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]])
- return 0;
- return [static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(candidateView) qt_qwidget];
+ if (dropData) {
+ delete dropData;
+ dropData = 0;
+ }
+}
+
+- (void)addDropData:(id <NSDraggingInfo>)sender
+{
+ [self removeDropData];
+ CFStringRef dropPasteboard = (CFStringRef) [[sender draggingPasteboard] name];
+ dropData = new QCocoaDropData(dropPasteboard);
+}
+
+- (void)changeDraggingCursor:(NSDragOperation)newOperation
+{
+ static SEL action = nil;
+ static bool operationSupported = false;
+ if (action == nil) {
+ action = NSSelectorFromString(@"operationNotAllowedCursor");
+ if ([NSCursor respondsToSelector:action]) {
+ operationSupported = true;
+ }
+ }
+ if (operationSupported) {
+ NSCursor *notAllowedCursor = [NSCursor performSelector:action];
+ bool isNotAllowedCursor = ([NSCursor currentCursor] == notAllowedCursor);
+ if (newOperation == NSDragOperationNone && !isNotAllowedCursor) {
+ [notAllowedCursor push];
+ } else if (newOperation != NSDragOperationNone && isNotAllowedCursor) {
+ [notAllowedCursor pop];
+ }
+
+ }
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
@@ -286,64 +326,211 @@ QT_END_NAMESPACE
// registerForDraggedTypes on the views will severly degrade initialization time
// for an application that uses a lot of drag subscribing widgets.
- QWidget *target = [self dragTargetHitTest:sender];
- if (!target)
+ NSPoint nswindowPoint = [sender draggingLocation];
+ NSPoint nsglobalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:nswindowPoint];
+ QPoint globalPoint = flipPoint(nsglobalPoint).toPoint();
+
+ QWidget *qwidget = QApplication::widgetAt(globalPoint);
+ *currentDragTarget() = qwidget;
+ if (!qwidget)
return [super draggingEntered:sender];
- if (target->testAttribute(Qt::WA_DropSiteRegistered) == false)
+ if (qwidget->testAttribute(Qt::WA_DropSiteRegistered) == false)
return NSDragOperationNone;
- *currentDragTarget() = target;
- return [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) draggingEntered:sender];
+ [self addDropData:sender];
+
+ QMimeData *mimeData = dropData;
+ if (QDragManager::self()->source())
+ mimeData = QDragManager::self()->dragPrivate()->data;
+
+ NSDragOperation nsActions = [sender draggingSourceOperationMask];
+ Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions);
+ QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions;
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier;
+
+ if ([sender draggingSource] != nil) {
+ // modifier flags might have changed, update it here since we don't send any input events.
+ QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
+ modifiers = QApplication::keyboardModifiers();
+ } else {
+ // when the source is from another application the above technique will not work.
+ modifiers = qt_cocoaDragOperation2QtModifiers(nsActions);
+ }
+
+ // send the drag enter event to the widget.
+ QPoint localPoint(qwidget->mapFromGlobal(globalPoint));
+ QDragEnterEvent qDEEvent(localPoint, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
+ QApplication::sendEvent(qwidget, &qDEEvent);
+
+ if (!qDEEvent.isAccepted()) {
+ // The enter event was not accepted. We mark this by removing
+ // the drop data so we don't send subsequent drag move events:
+ [self removeDropData];
+ [self changeDraggingCursor:NSDragOperationNone];
+ return NSDragOperationNone;
+ } else {
+ // Send a drag move event immediately after a drag enter event (as per documentation).
+ QDragMoveEvent qDMEvent(localPoint, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
+ qDMEvent.setDropAction(qDEEvent.dropAction());
+ qDMEvent.accept(); // accept by default, since enter event was accepted.
+ QApplication::sendEvent(qwidget, &qDMEvent);
+
+ if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction) {
+ // Since we accepted the drag enter event, the widget expects
+ // future drage move events.
+ nsActions = NSDragOperationNone;
+ // Save as ignored in the answer rect.
+ qDMEvent.setDropAction(Qt::IgnoreAction);
+ } else {
+ nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDMEvent.dropAction());
+ }
+
+ QT_PREPEND_NAMESPACE(qt_mac_copy_answer_rect)(qDMEvent);
+ [self changeDraggingCursor:nsActions];
+ return nsActions;
+ }
}
-- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender
+- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
{
- QWidget *target = [self dragTargetHitTest:sender];
- if (!target)
- return [super draggingUpdated:sender];
-
- if (target == *currentDragTarget()) {
- // The drag continues to move over the widget that we have sendt
- // a draggingEntered message to. So just update the view:
- return [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) draggingUpdated:sender];
- } else {
- // The widget under the mouse has changed.
- // So we need to fake enter/leave events:
- if (*currentDragTarget())
- [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) draggingExited:sender];
- if (target->testAttribute(Qt::WA_DropSiteRegistered) == false) {
- *currentDragTarget() = 0;
- return NSDragOperationNone;
+ NSPoint nswindowPoint = [sender draggingLocation];
+ NSPoint nsglobalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:nswindowPoint];
+ QPoint globalPoint = flipPoint(nsglobalPoint).toPoint();
+
+ QWidget *qwidget = QApplication::widgetAt(globalPoint);
+ if (!qwidget)
+ return [super draggingEntered:sender];
+
+ // First, check if the widget under the mouse has changed since the
+ // last drag move events. If so, we need to change target, and dispatch
+ // syntetic drag enter/leave events:
+ if (qwidget != *currentDragTarget()) {
+ if (*currentDragTarget() && dropData) {
+ QDragLeaveEvent de;
+ QApplication::sendEvent(*currentDragTarget(), &de);
+ [self removeDropData];
}
- *currentDragTarget() = target;
- return [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) draggingEntered:sender];
+ return [self draggingEntered:sender];
+ }
+
+ if (qwidget->testAttribute(Qt::WA_DropSiteRegistered) == false)
+ return NSDragOperationNone;
+
+ // If we have no drop data (which will be assigned inside draggingEntered), it means
+ // that the current drag target did not accept the enter event. If so, we ignore
+ // subsequent move events as well:
+ if (dropData == 0) {
+ [self changeDraggingCursor:NSDragOperationNone];
+ return NSDragOperationNone;
+ }
+
+ // If the mouse is still within the accepted rect (provided by
+ // the application on a previous event), we follow the optimization
+ // and just return the answer given at that point:
+ NSDragOperation nsActions = [sender draggingSourceOperationMask];
+ QPoint localPoint(qwidget->mapFromGlobal(globalPoint));
+ if (qt_mac_mouse_inside_answer_rect(localPoint)
+ && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions) {
+ NSDragOperation operation = QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction));
+ [self changeDraggingCursor:operation];
+ return operation;
}
+
+ QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions;
+ Qt::DropActions qtAllowed = QT_PREPEND_NAMESPACE(qt_mac_mapNSDragOperations)(nsActions);
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier;
+
+ // Update modifiers:
+ if ([sender draggingSource] != nil) {
+ QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
+ modifiers = QApplication::keyboardModifiers();
+ } else {
+ modifiers = qt_cocoaDragOperation2QtModifiers(nsActions);
+ }
+
+ QMimeData *mimeData = dropData;
+ if (QDragManager::self()->source())
+ mimeData = QDragManager::self()->dragPrivate()->data;
+
+ // Insert the same drop action on the event according to
+ // what the application told us it should be on the previous event:
+ QDragMoveEvent qDMEvent(localPoint, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
+ if (QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).lastAction != Qt::IgnoreAction
+ && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).buttons == qDMEvent.mouseButtons()
+ && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).modifiers == qDMEvent.keyboardModifiers())
+ qDMEvent.setDropAction(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).lastAction);
+
+ // Now, end the drag move event to the widget:
+ qDMEvent.accept();
+ QApplication::sendEvent(qwidget, &qDMEvent);
+
+ NSDragOperation operation = qt_mac_mapDropAction(qDMEvent.dropAction());
+ if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction) {
+ // Ignore this event (we will still receive further
+ // notifications), save as ignored in the answer rect:
+ operation = NSDragOperationNone;
+ qDMEvent.setDropAction(Qt::IgnoreAction);
+ }
+
+ qt_mac_copy_answer_rect(qDMEvent);
+ [self changeDraggingCursor:operation];
+
+ return operation;
}
-- (void)draggingExited:(id < NSDraggingInfo >)sender
+- (void)draggingExited:(id <NSDraggingInfo>)sender
{
- QWidget *target = [self dragTargetHitTest:sender];
- if (!target)
+ NSPoint nswindowPoint = [sender draggingLocation];
+ NSPoint nsglobalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:nswindowPoint];
+ QPoint globalPoint = flipPoint(nsglobalPoint).toPoint();
+
+ QWidget *qwidget = *currentDragTarget();
+ if (!qwidget)
return [super draggingExited:sender];
- if (*currentDragTarget()) {
- [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) draggingExited:sender];
- *currentDragTarget() = 0;
+ if (dropData) {
+ QDragLeaveEvent de;
+ QApplication::sendEvent(qwidget, &de);
+ [self removeDropData];
}
+
+ // Clean-up:
+ [self removeDropData];
+ *currentDragTarget() = 0;
+ [self changeDraggingCursor:NSDragOperationEvery];
}
-- (BOOL)performDragOperation:(id < NSDraggingInfo >)sender
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
- QWidget *target = [self dragTargetHitTest:sender];
- if (!target)
- return [super performDragOperation:sender];
-
- BOOL dropResult = NO;
- if (*currentDragTarget()) {
- dropResult = [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) performDragOperation:sender];
- *currentDragTarget() = 0;
- }
- return dropResult;
+ QWidget *qwidget = *currentDragTarget();
+ if (!qwidget)
+ return NO;
+
+ *currentDragTarget() = 0;
+ NSPoint nswindowPoint = [sender draggingLocation];
+ NSPoint nsglobalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:nswindowPoint];
+ QPoint globalPoint = flipPoint(nsglobalPoint).toPoint();
+
+ [self addDropData:sender];
+
+ NSDragOperation nsActions = [sender draggingSourceOperationMask];
+ Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions);
+ QMimeData *mimeData = dropData;
+
+ if (QDragManager::self()->source())
+ mimeData = QDragManager::self()->dragPrivate()->data;
+ if (QDragManager::self()->object)
+ QDragManager::self()->dragPrivate()->target = qwidget;
+
+ QPoint localPoint(qwidget->mapFromGlobal(globalPoint));
+ QDropEvent de(localPoint, qtAllowed, mimeData,
+ QApplication::mouseButtons(), QApplication::keyboardModifiers());
+ QApplication::sendEvent(qwidget, &de);
+
+ if (QDragManager::self()->object)
+ QDragManager::self()->dragPrivate()->executed_action = de.dropAction();
+
+ return de.isAccepted();
}
- (void)displayIfNeeded
@@ -394,8 +581,8 @@ static bool firstDrawingInvocation = true;
- (void)drawRectSpecial:(NSRect)rect
{
// Call the original drawing method.
- [self drawRectOriginal:rect];
- NSWindow *window = [self window];
+ [id(self) drawRectOriginal:rect];
+ NSWindow *window = [id(self) window];
NSToolbar *toolbar = [window toolbar];
if(!toolbar) {
// There is no toolbar, we have to draw a line on top of the line drawn by Cocoa.
@@ -415,3 +602,11 @@ static bool firstDrawingInvocation = true;
}
}
}
+
+- (void)drawRectOriginal:(NSRect)rect
+{
+ Q_UNUSED(rect)
+ // This method implementation is here to silenct the compiler.
+ // See drawRectSpecial for information.
+}
+
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 5ea893c..ff2dfe7 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -49,7 +49,6 @@
#include <private/qt_cocoa_helpers_mac_p.h>
#include <private/qdnd_p.h>
#include <private/qmacinputcontext_p.h>
-#include <private/qmultitouch_mac_p.h>
#include <private/qevent_p.h>
#include <private/qbackingstore_p.h>
@@ -76,70 +75,16 @@
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC(DnDParams, qMacDnDParams);
-
-extern void qt_mac_update_cursor_at_global_pos(const QPoint &globalPos); // qcursor_mac.mm
+extern void qt_mac_update_cursor(); // qcursor_mac.mm
extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); // qapplication.cpp
+extern QPointer<QWidget> qt_last_mouse_receiver; // qapplication_mac.cpp
+extern QPointer<QWidget> qt_last_native_mouse_receiver; // qt_cocoa_helpers_mac.mm
extern OSViewRef qt_mac_nativeview_for(const QWidget *w); // qwidget_mac.mm
-extern QPointer<QWidget> qt_mouseover; //qapplication_mac.mm
+extern OSViewRef qt_mac_effectiveview_for(const QWidget *w); // qwidget_mac.mm
extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum);
-
-struct dndenum_mapper
-{
- NSDragOperation mac_code;
- Qt::DropAction qt_code;
- bool Qt2Mac;
-};
-
-static dndenum_mapper dnd_enums[] = {
- { NSDragOperationLink, Qt::LinkAction, true },
- { NSDragOperationMove, Qt::MoveAction, true },
- { NSDragOperationCopy, Qt::CopyAction, true },
- { NSDragOperationGeneric, Qt::CopyAction, false },
- { NSDragOperationEvery, Qt::ActionMask, false },
- { NSDragOperationNone, Qt::IgnoreAction, false }
-};
-
-static NSDragOperation qt_mac_mapDropAction(Qt::DropAction action)
-{
- for (int i=0; dnd_enums[i].qt_code; i++) {
- if (dnd_enums[i].Qt2Mac && (action & dnd_enums[i].qt_code)) {
- return dnd_enums[i].mac_code;
- }
- }
- return NSDragOperationNone;
-}
-
-static NSDragOperation qt_mac_mapDropActions(Qt::DropActions actions)
-{
- NSDragOperation nsActions = NSDragOperationNone;
- for (int i=0; dnd_enums[i].qt_code; i++) {
- if (dnd_enums[i].Qt2Mac && (actions & dnd_enums[i].qt_code))
- nsActions |= dnd_enums[i].mac_code;
- }
- return nsActions;
-}
-
-static Qt::DropAction qt_mac_mapNSDragOperation(NSDragOperation nsActions)
-{
- Qt::DropAction action = Qt::IgnoreAction;
- for (int i=0; dnd_enums[i].mac_code; i++) {
- if (nsActions & dnd_enums[i].mac_code)
- return dnd_enums[i].qt_code;
- }
- return action;
-}
-
-static Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions)
-{
- Qt::DropActions actions = Qt::IgnoreAction;
- for (int i=0; dnd_enums[i].mac_code; i++) {
- if (nsActions & dnd_enums[i].mac_code)
- actions |= dnd_enums[i].qt_code;
- }
- return actions;
-}
+extern QWidget *mac_mouse_grabber;
+extern bool qt_mac_clearDirtyOnWidgetInsideDrawWidget; // qwidget.cpp
static QColor colorFrom(NSColor *color)
{
@@ -185,6 +130,7 @@ extern "C" {
extern NSString *NSTextInputReplacementRangeAttributeName;
}
+//#define ALIEN_DEBUG 1
#ifdef ALIEN_DEBUG
static int qCocoaViewCount = 0;
#endif
@@ -202,12 +148,14 @@ static int qCocoaViewCount = 0;
#ifdef ALIEN_DEBUG
++qCocoaViewCount;
- qDebug() << "init: qCocoaViewCount is" << qCocoaViewCount;
+ qDebug() << "Alien: create native view for" << widget << ". qCocoaViewCount is:" << qCocoaViewCount;
#endif
composing = false;
sendKeyEvents = true;
fromKeyDownEvent = false;
+ alienTouchCount = 0;
+
[self setHidden:YES];
return self;
}
@@ -222,246 +170,15 @@ static int qCocoaViewCount = 0;
object:self];
}
-- (void)resetCursorRects
-{
- // [NSView addCursorRect] is slow, so bail out early if we can:
- if (NSIsEmptyRect([self visibleRect]))
- return;
-
- QWidget *cursorWidget = qwidget;
-
- if (cursorWidget->testAttribute(Qt::WA_TransparentForMouseEvents))
- cursorWidget = QApplication::widgetAt(qwidget->mapToGlobal(qwidget->rect().center()));
-
- if (cursorWidget == 0)
- return;
-
- if (!cursorWidget->testAttribute(Qt::WA_SetCursor)) {
- [super resetCursorRects];
- return;
- }
-
- QRegion mask = qt_widget_private(cursorWidget)->extra->mask;
- NSCursor *nscursor = static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(cursorWidget->cursor()));
- // The mask could have the WA_MouseNoMask attribute set and that means that we have to ignore the mask.
- if (mask.isEmpty() || cursorWidget->testAttribute(Qt::WA_MouseNoMask)) {
- [self addCursorRect:[qt_mac_nativeview_for(cursorWidget) visibleRect] cursor:nscursor];
- } else {
- const QVector<QRect> &rects = mask.rects();
- for (int i = 0; i < rects.size(); ++i) {
- const QRect &rect = rects.at(i);
- [self addCursorRect:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()) cursor:nscursor];
- }
- }
-}
-
-- (void)removeDropData
-{
- if (dropData) {
- delete dropData;
- dropData = 0;
- }
-}
-
-- (void)addDropData:(id <NSDraggingInfo>)sender
-{
- [self removeDropData];
- CFStringRef dropPasteboard = (CFStringRef) [[sender draggingPasteboard] name];
- dropData = new QCocoaDropData(dropPasteboard);
-}
-
-- (void)changeDraggingCursor:(NSDragOperation)newOperation
-{
- static SEL action = nil;
- static bool operationSupported = false;
- if (action == nil) {
- action = NSSelectorFromString(@"operationNotAllowedCursor");
- if ([NSCursor respondsToSelector:action]) {
- operationSupported = true;
- }
- }
- if (operationSupported) {
- NSCursor *notAllowedCursor = [NSCursor performSelector:action];
- bool isNotAllowedCursor = ([NSCursor currentCursor] == notAllowedCursor);
- if (newOperation == NSDragOperationNone && !isNotAllowedCursor) {
- [notAllowedCursor push];
- } else if (newOperation != NSDragOperationNone && isNotAllowedCursor) {
- [notAllowedCursor pop];
- }
-
- }
-}
-
-- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
-{
- // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly
- // from Cocoa. They modify the drag target, and might fake enter/leave events.
- NSPoint windowPoint = [sender draggingLocation];
- dragEnterSequence = [sender draggingSequenceNumber];
- [self addDropData:sender];
- QMimeData *mimeData = dropData;
- if (QDragManager::self()->source())
- mimeData = QDragManager::self()->dragPrivate()->data;
- NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
- QPoint posDrag(localPoint.x, localPoint.y);
- NSDragOperation nsActions = [sender draggingSourceOperationMask];
- Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions);
- QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions;
- Qt::KeyboardModifiers modifiers = Qt::NoModifier;
- if ([sender draggingSource] != nil) {
- // modifier flags might have changed, update it here since we don't send any input events.
- QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
- modifiers = QApplication::keyboardModifiers();
- } else {
- // when the source is from another application the above technique will not work.
- modifiers = qt_cocoaDragOperation2QtModifiers(nsActions);
- }
- // send the drag enter event to the widget.
- QDragEnterEvent qDEEvent(posDrag, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
- QApplication::sendEvent(qwidget, &qDEEvent);
- if (!qDEEvent.isAccepted()) {
- // widget is not interested in this drag, so ignore this drop data.
- [self removeDropData];
- [self changeDraggingCursor:NSDragOperationNone];
- return NSDragOperationNone;
- } else {
- // save the mouse position, used by draggingExited handler.
- DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent];
- dndParams->activeDragEnterPos = windowPoint;
- // send a drag move event immediately after a drag enter event (as per documentation).
- QDragMoveEvent qDMEvent(posDrag, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
- qDMEvent.setDropAction(qDEEvent.dropAction());
- qDMEvent.accept(); // accept by default, since enter event was accepted.
- QApplication::sendEvent(qwidget, &qDMEvent);
- if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction) {
- // since we accepted the drag enter event, the widget expects
- // future drage move events.
- // ### check if we need to treat this like the drag enter event.
- nsActions = NSDragOperationNone;
- // Save as ignored in the answer rect.
- qDMEvent.setDropAction(Qt::IgnoreAction);
- } else {
- nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDMEvent.dropAction());
- }
- QT_PREPEND_NAMESPACE(qt_mac_copy_answer_rect)(qDMEvent);
- [self changeDraggingCursor:nsActions];
- return nsActions;
- }
- }
-- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender
-{
- // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly
- // from Cocoa. They modify the drag target, and might fake enter/leave events.
- NSPoint windowPoint = [sender draggingLocation];
- // in cases like QFocusFrame, the view under the mouse might
- // not have received the drag enter. Generate a synthetic
- // drag enter event for that view.
- if (dragEnterSequence != [sender draggingSequenceNumber])
- [self draggingEntered:sender];
- // drag enter event was rejected, so ignore the move event.
- if (dropData == 0) {
- [self changeDraggingCursor:NSDragOperationNone];
- return NSDragOperationNone;
- }
- // return last value, if we are still in the answerRect.
- NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
- NSDragOperation nsActions = [sender draggingSourceOperationMask];
- QPoint posDrag(localPoint.x, localPoint.y);
- if (qt_mac_mouse_inside_answer_rect(posDrag)
- && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions) {
- NSDragOperation operation = QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction));
- [self changeDraggingCursor:operation];
- return operation;
- }
- // send drag move event to the widget
- QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions;
- Qt::DropActions qtAllowed = QT_PREPEND_NAMESPACE(qt_mac_mapNSDragOperations)(nsActions);
- Qt::KeyboardModifiers modifiers = Qt::NoModifier;
- if ([sender draggingSource] != nil) {
- // modifier flags might have changed, update it here since we don't send any input events.
- QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
- modifiers = QApplication::keyboardModifiers();
- } else {
- // when the source is from another application the above technique will not work.
- modifiers = qt_cocoaDragOperation2QtModifiers(nsActions);
- }
- QMimeData *mimeData = dropData;
- if (QDragManager::self()->source())
- mimeData = QDragManager::self()->dragPrivate()->data;
- QDragMoveEvent qDMEvent(posDrag, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
- if (QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).lastAction != Qt::IgnoreAction
- && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).buttons == qDMEvent.mouseButtons()
- && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).modifiers == qDMEvent.keyboardModifiers())
- qDMEvent.setDropAction(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).lastAction);
- qDMEvent.accept();
- QApplication::sendEvent(qwidget, &qDMEvent);
-
- NSDragOperation operation = qt_mac_mapDropAction(qDMEvent.dropAction());
- if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction) {
- // ignore this event (we will still receive further notifications)
- operation = NSDragOperationNone;
- // Save as ignored in the answer rect.
- qDMEvent.setDropAction(Qt::IgnoreAction);
- }
- qt_mac_copy_answer_rect(qDMEvent);
- [self changeDraggingCursor:operation];
- return operation;
-}
-
-- (void)draggingExited:(id < NSDraggingInfo >)sender
-{
- // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly
- // from Cocoa. They modify the drag target, and might fake enter/leave events.
- Q_UNUSED(sender);
- dragEnterSequence = -1;
- // drag enter event was rejected, so ignore the move event.
- if (dropData) {
- QDragLeaveEvent de;
- QApplication::sendEvent(qwidget, &de);
- [self removeDropData];
- }
- [self changeDraggingCursor:NSDragOperationEvery];
-
-}
-
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
-{
- // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly
- // from Cocoa. They modify the drag target, and might fake enter/leave events.
- NSPoint windowPoint = [sender draggingLocation];
- dragEnterSequence = -1;
- [self addDropData:sender];
-
- NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
- QPoint posDrop(localPoint.x, localPoint.y);
-
- NSDragOperation nsActions = [sender draggingSourceOperationMask];
- Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions);
- QMimeData *mimeData = dropData;
- if (QDragManager::self()->source())
- mimeData = QDragManager::self()->dragPrivate()->data;
- // send the drop event to the widget.
- QDropEvent de(posDrop, qtAllowed, mimeData,
- QApplication::mouseButtons(), QApplication::keyboardModifiers());
- if (QDragManager::self()->object)
- QDragManager::self()->dragPrivate()->target = qwidget;
- QApplication::sendEvent(qwidget, &de);
- if (QDragManager::self()->object)
- QDragManager::self()->dragPrivate()->executed_action = de.dropAction();
- if (!de.isAccepted())
- return NO;
- else
- return YES;
-}
-
- (void)dealloc
{
+ QMacCocoaAutoReleasePool pool;
delete composingText;
[[NSNotificationCenter defaultCenter] removeObserver:self];
#ifdef ALIEN_DEBUG
--qCocoaViewCount;
- qDebug() << "qCocoaViewCount is" << qCocoaViewCount;
+ qDebug() << "Alien: widget deallocated. qCocoaViewCount is:" << qCocoaViewCount;
#endif
[super dealloc];
@@ -529,9 +246,8 @@ static int qCocoaViewCount = 0;
{
if (!qwidget)
return;
-
- // We use a different graphics system.
if (QApplicationPrivate::graphicsSystem() != 0 && !qwidgetprivate->isInUnifiedToolbar) {
+ // INVARIANT: We use a different graphics system.
// Qt handles the painting occuring inside the window.
// Cocoa also keeps track of all widgets as NSView and therefore might
@@ -558,7 +274,7 @@ static int qCocoaViewCount = 0;
qwidgetprivate->hd = cg;
// We steal the CGContext for flushing in the unified toolbar with the raster engine.
- if (QApplicationPrivate::graphicsSystem() != 0 && qwidgetprivate->isInUnifiedToolbar) {
+ if (QApplicationPrivate::graphicsSystem() != 0 && qwidgetprivate->isInUnifiedToolbar && qwidgetprivate->unifiedSurface) {
qwidgetprivate->cgContext = cg;
qwidgetprivate->hasOwnContext = true;
qwidgetprivate->unifiedSurface->flush(qwidget, qwidgetprivate->ut_rg, qwidgetprivate->ut_pt);
@@ -574,13 +290,13 @@ static int qCocoaViewCount = 0;
const QRect qrect = QRect(aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height);
QRegion qrgn;
- const NSRect *rects;
- NSInteger count;
- [self getRectsBeingDrawn:&rects count:&count];
- for (int i = 0; i < count; ++i) {
- QRect tmpRect = QRect(rects[i].origin.x, rects[i].origin.y, rects[i].size.width, rects[i].size.height);
- qrgn += tmpRect;
- }
+ const NSRect *rects;
+ NSInteger count;
+ [self getRectsBeingDrawn:&rects count:&count];
+ for (int i = 0; i < count; ++i) {
+ QRect tmpRect = QRect(rects[i].origin.x, rects[i].origin.y, rects[i].size.width, rects[i].size.height);
+ qrgn += tmpRect;
+ }
if (!qwidget->isWindow() && !qobject_cast<QAbstractScrollArea *>(qwidget->parent())) {
const QRegion &parentMask = qwidget->window()->mask();
@@ -610,38 +326,27 @@ static int qCocoaViewCount = 0;
}
if (qwidget->isWindow() && !qwidgetprivate->isOpaque
- && !qwidget->testAttribute(Qt::WA_MacBrushedMetal)) {
+ && !qwidget->testAttribute(Qt::WA_MacBrushedMetal)) {
CGContextClearRect(cg, NSRectToCGRect(aRect));
}
- // Check for alien widgets, use qwidgetPrivate->drawWidget() to draw the widget if this
- // is the case. This makes sure child widgets are drawn as well, Cocoa does not know about
- // those and wont send them drawRect calls.
- if (qwidget->testAttribute(Qt::WA_NativeWindow) && qt_widget_private(qwidget)->hasAlienChildren == false) {
- if ((engine && !qwidget->testAttribute(Qt::WA_NoSystemBackground)
- && (qwidget->isWindow() || qwidget->autoFillBackground()))
- || qwidget->testAttribute(Qt::WA_TintedBackground)
- || qwidget->testAttribute(Qt::WA_StyledBackground)) {
-#ifdef DEBUG_WIDGET_PAINT
- if(doDebug)
- qDebug(" Handling erase for [%s::%s]", qwidget->metaObject()->className(),
- qwidget->objectName().local8Bit().data());
-#endif
- QPainter p(qwidget);
- qwidgetprivate->paintBackground(&p, qrgn,
- qwidget->isWindow() ? QWidgetPrivate::DrawAsRoot : 0);
- p.end();
- }
- QPaintEvent e(qrgn);
-#ifdef QT3_SUPPORT
- e.setErased(true);
-#endif
- qt_sendSpontaneousEvent(qwidget, &e);
- } else {
- qwidget->setAttribute(Qt::WA_WState_InPaintEvent, false); // QWidgetPrivate::drawWidget sets this
- QWidgetPrivate *qwidgetPrivate = qt_widget_private(qwidget);
- qwidgetPrivate->drawWidget(qwidget, qrgn, QPoint(), QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawPaintOnScreen | QWidgetPrivate::DrawRecursive, 0);
- }
+ qwidget->setAttribute(Qt::WA_WState_InPaintEvent, false);
+ QWidgetPrivate *qwidgetPrivate = qt_widget_private(qwidget);
+
+ // We specify that we want to draw the widget itself, and
+ // all its children recursive. But we skip native children, because
+ // they will receive drawRect calls by themselves as needed:
+ int flags = QWidgetPrivate::DrawPaintOnScreen
+ | QWidgetPrivate::DrawRecursive
+ | QWidgetPrivate::DontDrawNativeChildren;
+
+ if (qwidget->isWindow())
+ flags |= QWidgetPrivate::DrawAsRoot;
+
+ // Start to draw:
+ qt_mac_clearDirtyOnWidgetInsideDrawWidget = true;
+ qwidgetPrivate->drawWidget(qwidget, qrgn, QPoint(), flags, 0);
+ qt_mac_clearDirtyOnWidgetInsideDrawWidget = false;
if (!redirectionOffset.isNull())
QPainter::restoreRedirected(qwidget);
@@ -650,7 +355,7 @@ static int qCocoaViewCount = 0;
qwidget->setAttribute(Qt::WA_WState_InPaintEvent, false);
if(!qwidget->testAttribute(Qt::WA_PaintOutsidePaintEvent) && qwidget->paintingActive())
qWarning("QWidget: It is dangerous to leave painters active on a"
- " widget outside of the PaintEvent");
+ " widget outside of the PaintEvent");
}
qwidgetprivate->hd = 0;
CGContextRestoreGState(cg);
@@ -659,11 +364,13 @@ static int qCocoaViewCount = 0;
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
{
- if (!qwidget)
+ // Find the widget that should receive the event:
+ QPoint qlocal, qglobal;
+ QWidget *widgetToGetMouse = qt_mac_getTargetForMouseEvent(theEvent, QEvent::MouseButtonPress, qlocal, qglobal, qwidget, 0);
+ if (!widgetToGetMouse)
return NO;
- Q_UNUSED(theEvent);
- return !qwidget->testAttribute(Qt::WA_MacNoClickThrough);
+ return !widgetToGetMouse->testAttribute(Qt::WA_MacNoClickThrough);
}
- (NSView *)hitTest:(NSPoint)aPoint
@@ -714,161 +421,120 @@ static int qCocoaViewCount = 0;
- (void)mouseEntered:(NSEvent *)event
{
- if (!qwidget)
- return;
- if (qwidgetprivate->data.in_destructor)
- return;
-
- if (!qAppInstance()->activeModalWidget() || QApplicationPrivate::tryModalHelper(qwidget, 0)) {
- QEvent enterEvent(QEvent::Enter);
- NSPoint windowPoint = [event locationInWindow];
- NSPoint globalPoint = [[event window] convertBaseToScreen:windowPoint];
- NSPoint viewPoint = [self convertPoint:windowPoint fromView:nil];
- QApplication::sendEvent(qwidget, &enterEvent);
- qt_mouseover = qwidget;
-
- // Update cursor icon:
- qt_mac_update_cursor_at_global_pos(flipPoint(globalPoint).toPoint());
-
- // Send mouse move and hover events as well:
- if (!qAppInstance()->activePopupWidget() || qAppInstance()->activePopupWidget() == qwidget->window()) {
- // This mouse move event should be sendt, even when mouse
- // tracking is switched off (to trigger tooltips):
- NSEvent *mouseEvent = [NSEvent mouseEventWithType:NSMouseMoved
- location:windowPoint modifierFlags:[event modifierFlags] timestamp:[event timestamp]
- windowNumber:[event windowNumber] context:[event context] eventNumber:[event eventNumber]
- clickCount:0 pressure:0];
- qt_mac_handleMouseEvent(self, mouseEvent, QEvent::MouseMove, Qt::NoButton);
-
- if (qwidget->testAttribute(Qt::WA_Hover)) {
- QHoverEvent he(QEvent::HoverEnter, QPoint(viewPoint.x, viewPoint.y), QPoint(-1, -1));
- QApplicationPrivate::instance()->notify_helper(qwidget, &he);
- }
- }
- }
+ // Cocoa will not send a move event on mouseEnter. But since
+ // Qt expect this, we fake one now. See also mouseExited below
+ // for info about enter/leave event handling
+ NSEvent *nsmoveEvent = [NSEvent
+ mouseEventWithType:NSMouseMoved
+ location:[[self window] mouseLocationOutsideOfEventStream]
+ modifierFlags: [event modifierFlags]
+ timestamp: [event timestamp]
+ windowNumber: [event windowNumber]
+ context: [event context]
+ eventNumber: [event eventNumber]
+ clickCount: 0
+ pressure: 0];
+
+ // Important: Cocoa sends us mouseEnter on all views under the mouse
+ // and not just the one on top. Therefore, to we cannot use qwidget
+ // as native widget for this case. Instead, we let qt_mac_handleMouseEvent
+ // resolve it (last argument set to 0):
+ qt_mac_handleMouseEvent(nsmoveEvent, QEvent::MouseMove, Qt::NoButton, 0);
}
- (void)mouseExited:(NSEvent *)event
{
- if (!qwidget)
- return;
-
- QEvent leaveEvent(QEvent::Leave);
- NSPoint globalPoint = [[event window] convertBaseToScreen:[event locationInWindow]];
- if (!qAppInstance()->activeModalWidget() || QApplicationPrivate::tryModalHelper(qwidget, 0)) {
- QApplication::sendEvent(qwidget, &leaveEvent);
-
- // ### Think about if it is necessary to update the cursor, should only be for a few cases.
- qt_mac_update_cursor_at_global_pos(flipPoint(globalPoint).toPoint());
- if (qwidget->testAttribute(Qt::WA_Hover)
- && (!qAppInstance()->activePopupWidget() || qAppInstance()->activePopupWidget() == qwidget->window())) {
- QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1),
- qwidget->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos));
- QApplicationPrivate::instance()->notify_helper(qwidget, &he);
+ // Note: normal enter/leave handling is done from within mouseMove. This handler
+ // catches the case when the mouse moves out of the window (which mouseMove do not).
+ // Updating the mouse cursor follows the same logic as enter/leave. And we update
+ // neither if a grab exists (even if the grab points to this widget, it seems, ref X11)
+ Q_UNUSED(event);
+ if (self == [[self window] contentView] && !qt_button_down && !QWidget::mouseGrabber()) {
+ qt_mac_update_cursor();
+ // If the mouse exits the content view, but qt_mac_getTargetForMouseEvent still
+ // reports a target, it means that either there is a grab involved, or the mouse
+ // hovered over another window in the application. In both cases, move events will
+ // cause qt_mac_handleMouseEvent to be called, which will handle enter/leave.
+ QPoint qlocal, qglobal;
+ QWidget *widgetUnderMouse = 0;
+ qt_mac_getTargetForMouseEvent(event, QEvent::Leave, qlocal, qglobal, qwidget, &widgetUnderMouse);
+
+ if (widgetUnderMouse == 0) {
+ QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver);
+ qt_last_mouse_receiver = 0;
+ qt_last_native_mouse_receiver = 0;
}
}
}
- (void)flagsChanged:(NSEvent *)theEvent
{
- if (!qwidget)
+ QWidget *widgetToGetKey = qt_mac_getTargetForKeyEvent(qwidget);
+ if (!widgetToGetKey)
return;
- QWidget *widgetToGetKey = qwidget;
-
- QWidget *popup = qAppInstance()->activePopupWidget();
- if (popup && popup != qwidget->window())
- widgetToGetKey = popup->focusWidget() ? popup->focusWidget() : popup;
qt_dispatchModifiersChanged(theEvent, widgetToGetKey);
[super flagsChanged:theEvent];
}
- (void)mouseMoved:(NSEvent *)theEvent
{
- if (!qwidget)
- return;
-
- // We always enable mouse tracking for all QCocoaView-s. In cases where we have
- // child views, we will receive mouseMoved for both parent & the child (if
- // mouse is over the child). We need to ignore the parent mouseMoved in such
- // cases.
- NSPoint windowPoint = [theEvent locationInWindow];
- NSView *candidateView = [[[self window] contentView] hitTest:windowPoint];
- if (candidateView && candidateView == self) {
- qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
- }
+ // Important: this method will only be called when the view's window is _not_ inside
+ // QCocoaWindow/QCocoaPanel. Otherwise, [QCocoaWindow sendEvent] will handle the event
+ // before it ends up here. So, this method is added for supporting QMacNativeWidget.
+ // TODO: Cocoa send move events to all views under the mouse. So make sure we only
+ // handle the event for the widget on top when using QMacNativeWidget.
+ qt_mac_handleMouseEvent(theEvent, QEvent::MouseMove, Qt::NoButton, qwidget);
}
- (void)mouseDown:(NSEvent *)theEvent
{
- if (!qt_button_down)
- qt_button_down = qwidget;
-
- qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, Qt::LeftButton);
+ qt_mac_handleMouseEvent(theEvent, QEvent::MouseButtonPress, Qt::LeftButton, qwidget);
// Don't call super here. This prevents us from getting the mouseUp event,
// which we need to send even if the mouseDown event was not accepted.
// (this is standard Qt behavior.)
}
-
- (void)mouseUp:(NSEvent *)theEvent
{
- qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonRelease, Qt::LeftButton);
-
- qt_button_down = 0;
+ qt_mac_handleMouseEvent(theEvent, QEvent::MouseButtonRelease, Qt::LeftButton, qwidget);
}
- (void)rightMouseDown:(NSEvent *)theEvent
{
- if (!qt_button_down)
- qt_button_down = qwidget;
-
- qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, Qt::RightButton);
+ qt_mac_handleMouseEvent(theEvent, QEvent::MouseButtonPress, Qt::RightButton, qwidget);
}
- (void)rightMouseUp:(NSEvent *)theEvent
{
- qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonRelease, Qt::RightButton);
-
- qt_button_down = 0;
+ qt_mac_handleMouseEvent(theEvent, QEvent::MouseButtonRelease, Qt::RightButton, qwidget);
}
- (void)otherMouseDown:(NSEvent *)theEvent
{
- if (!qt_button_down)
- qt_button_down = qwidget;
-
Qt::MouseButton mouseButton = cocoaButton2QtButton([theEvent buttonNumber]);
- qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, mouseButton);
+ qt_mac_handleMouseEvent(theEvent, QEvent::MouseButtonPress, mouseButton, qwidget);
}
- (void)otherMouseUp:(NSEvent *)theEvent
{
Qt::MouseButton mouseButton = cocoaButton2QtButton([theEvent buttonNumber]);
- qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonRelease, mouseButton);
-
- qt_button_down = 0;
+ qt_mac_handleMouseEvent(theEvent, QEvent::MouseButtonRelease, mouseButton, qwidget);
}
- (void)mouseDragged:(NSEvent *)theEvent
{
- qMacDnDParams()->view = self;
- qMacDnDParams()->theEvent = theEvent;
- qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
+ qt_mac_handleMouseEvent(theEvent, QEvent::MouseMove, Qt::NoButton, qwidget);
}
- (void)rightMouseDragged:(NSEvent *)theEvent
{
- qMacDnDParams()->view = self;
- qMacDnDParams()->theEvent = theEvent;
- qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
+ qt_mac_handleMouseEvent(theEvent, QEvent::MouseMove, Qt::NoButton, qwidget);
}
- (void)otherMouseDragged:(NSEvent *)theEvent
{
- qMacDnDParams()->view = self;
- qMacDnDParams()->theEvent = theEvent;
- qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
+ qt_mac_handleMouseEvent(theEvent, QEvent::MouseMove, Qt::NoButton, qwidget);
}
- (void)scrollWheel:(NSEvent *)theEvent
@@ -879,21 +545,14 @@ static int qCocoaViewCount = 0;
[currentIManager handleMouseEvent:theEvent];
}
- NSPoint windowPoint = [theEvent locationInWindow];
- NSPoint globalPoint = [[theEvent window] convertBaseToScreen:windowPoint];
- NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
- QPoint qlocal = QPoint(localPoint.x, localPoint.y);
- QPoint qglobal = QPoint(globalPoint.x, flipYCoordinate(globalPoint.y));
Qt::MouseButtons buttons = QApplication::mouseButtons();
- bool wheelOK = false;
Qt::KeyboardModifiers keyMods = qt_cocoaModifiers2QtModifiers([theEvent modifierFlags]);
- QWidget *widgetToGetMouse = qwidget;
- // if popup is open it should get wheel events if the cursor is over the popup,
- // otherwise the event should be ignored.
- if (QWidget *popup = qAppInstance()->activePopupWidget()) {
- if (!popup->geometry().contains(qglobal))
- return;
- }
+
+ // Find the widget that should receive the event:
+ QPoint qlocal, qglobal;
+ QWidget *widgetToGetMouse = qt_mac_getTargetForMouseEvent(theEvent, QEvent::Wheel, qlocal, qglobal, qwidget, 0);
+ if (!widgetToGetMouse)
+ return;
int deltaX = 0;
int deltaY = 0;
@@ -922,46 +581,30 @@ static int qCocoaViewCount = 0;
}
#ifndef QT_NO_WHEELEVENT
+ // ### Qt 5: Send one QWheelEvent with dx, dy and dz
+
+ if (deltaX != 0 && deltaY != 0)
+ QMacScrollOptimization::initDelayedScroll();
+
if (deltaX != 0) {
QWheelEvent qwe(qlocal, qglobal, deltaX, buttons, keyMods, Qt::Horizontal);
qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
- wheelOK = qwe.isAccepted();
- if (!wheelOK && QApplicationPrivate::focus_widget
- && QApplicationPrivate::focus_widget != widgetToGetMouse) {
- QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal,
- deltaX, buttons, keyMods, Qt::Horizontal);
- qt_sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
- wheelOK = qwe2.isAccepted();
- }
}
- if (deltaY) {
+ if (deltaY != 0) {
QWheelEvent qwe(qlocal, qglobal, deltaY, buttons, keyMods, Qt::Vertical);
qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
- wheelOK = qwe.isAccepted();
- if (!wheelOK && QApplicationPrivate::focus_widget
- && QApplicationPrivate::focus_widget != widgetToGetMouse) {
- QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal,
- deltaY, buttons, keyMods, Qt::Vertical);
- qt_sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
- wheelOK = qwe2.isAccepted();
- }
}
- if (deltaZ) {
+ if (deltaZ != 0) {
// Qt doesn't explicitly support wheels with a Z component. In a misguided attempt to
// try to be ahead of the pack, I'm adding this extra value.
QWheelEvent qwe(qlocal, qglobal, deltaZ, buttons, keyMods, (Qt::Orientation)3);
qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
- wheelOK = qwe.isAccepted();
- if (!wheelOK && QApplicationPrivate::focus_widget
- && QApplicationPrivate::focus_widget != widgetToGetMouse) {
- QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal,
- deltaZ, buttons, keyMods, (Qt::Orientation)3);
- qt_sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
- wheelOK = qwe2.isAccepted();
- }
}
+
+ if (deltaX != 0 && deltaY != 0)
+ QMacScrollOptimization::performDelayedScroll();
#endif //QT_NO_WHEELEVENT
}
@@ -976,35 +619,14 @@ static int qCocoaViewCount = 0;
[super tabletPoint:tabletEvent];
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
-- (void)touchesBeganWithEvent:(NSEvent *)event
-{
- bool all = qwidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
- qt_translateRawTouchEvent(qwidget, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
-}
-
-- (void)touchesMovedWithEvent:(NSEvent *)event
-{
- bool all = qwidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
- qt_translateRawTouchEvent(qwidget, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
-}
-
-- (void)touchesEndedWithEvent:(NSEvent *)event
-{
- bool all = qwidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
- qt_translateRawTouchEvent(qwidget, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
-}
-
-- (void)touchesCancelledWithEvent:(NSEvent *)event
-{
- bool all = qwidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
- qt_translateRawTouchEvent(qwidget, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
-}
-#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
-
- (void)magnifyWithEvent:(NSEvent *)event
{
- if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ QPoint qlocal, qglobal;
+ QWidget *widgetToGetGesture = 0;
+ qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, qwidget, &widgetToGetGesture);
+ if (!widgetToGetGesture)
+ return;
+ if (!QApplicationPrivate::tryModalHelper(widgetToGetGesture, 0))
return;
#ifndef QT_NO_GESTURES
@@ -1013,13 +635,18 @@ static int qCocoaViewCount = 0;
NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
qNGEvent.position = flipPoint(p).toPoint();
qNGEvent.percentage = [event magnification];
- qt_sendSpontaneousEvent(qwidget, &qNGEvent);
+ qt_sendSpontaneousEvent(widgetToGetGesture, &qNGEvent);
#endif // QT_NO_GESTURES
}
- (void)rotateWithEvent:(NSEvent *)event
{
- if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ QPoint qlocal, qglobal;
+ QWidget *widgetToGetGesture = 0;
+ qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, qwidget, &widgetToGetGesture);
+ if (!widgetToGetGesture)
+ return;
+ if (!QApplicationPrivate::tryModalHelper(widgetToGetGesture, 0))
return;
#ifndef QT_NO_GESTURES
@@ -1028,13 +655,18 @@ static int qCocoaViewCount = 0;
NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
qNGEvent.position = flipPoint(p).toPoint();
qNGEvent.percentage = -[event rotation];
- qt_sendSpontaneousEvent(qwidget, &qNGEvent);
+ qt_sendSpontaneousEvent(widgetToGetGesture, &qNGEvent);
#endif // QT_NO_GESTURES
}
- (void)swipeWithEvent:(NSEvent *)event
{
- if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ QPoint qlocal, qglobal;
+ QWidget *widgetToGetGesture = 0;
+ qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, qwidget, &widgetToGetGesture);
+ if (!widgetToGetGesture)
+ return;
+ if (!QApplicationPrivate::tryModalHelper(widgetToGetGesture, 0))
return;
#ifndef QT_NO_GESTURES
@@ -1050,13 +682,18 @@ static int qCocoaViewCount = 0;
qNGEvent.angle = 90.0f;
else if ([event deltaY] == -1)
qNGEvent.angle = 270.0f;
- qt_sendSpontaneousEvent(qwidget, &qNGEvent);
+ qt_sendSpontaneousEvent(widgetToGetGesture, &qNGEvent);
#endif // QT_NO_GESTURES
}
- (void)beginGestureWithEvent:(NSEvent *)event
{
- if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ QPoint qlocal, qglobal;
+ QWidget *widgetToGetGesture = 0;
+ qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, qwidget, &widgetToGetGesture);
+ if (!widgetToGetGesture)
+ return;
+ if (!QApplicationPrivate::tryModalHelper(widgetToGetGesture, 0))
return;
#ifndef QT_NO_GESTURES
@@ -1064,13 +701,18 @@ static int qCocoaViewCount = 0;
qNGEvent.gestureType = QNativeGestureEvent::GestureBegin;
NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
qNGEvent.position = flipPoint(p).toPoint();
- qt_sendSpontaneousEvent(qwidget, &qNGEvent);
+ qt_sendSpontaneousEvent(widgetToGetGesture, &qNGEvent);
#endif // QT_NO_GESTURES
}
- (void)endGestureWithEvent:(NSEvent *)event
{
- if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ QPoint qlocal, qglobal;
+ QWidget *widgetToGetGesture = 0;
+ qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, qwidget, &widgetToGetGesture);
+ if (!widgetToGetGesture)
+ return;
+ if (!QApplicationPrivate::tryModalHelper(widgetToGetGesture, 0))
return;
#ifndef QT_NO_GESTURES
@@ -1078,9 +720,9 @@ static int qCocoaViewCount = 0;
qNGEvent.gestureType = QNativeGestureEvent::GestureEnd;
NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
qNGEvent.position = flipPoint(p).toPoint();
- qt_sendSpontaneousEvent(qwidget, &qNGEvent);
-#endif // QT_NO_GESTURES
+ qt_sendSpontaneousEvent(widgetToGetGesture, &qNGEvent);
}
+#endif // QT_NO_GESTURES
- (void)frameDidChange:(NSNotification *)note
{
@@ -1123,27 +765,46 @@ static int qCocoaViewCount = 0;
{
if (!qwidget)
return NO;
- // disabled widget shouldn't get focus even if it's a window.
+
+ // Disabled widget shouldn't get focus even if it's a window.
// hence disabled windows will not get any key or mouse events.
if (!qwidget->isEnabled())
return NO;
- // Before accepting the focus for a window, we check that
- // the focusWidget (if any) is not contained in the same window.
- if (qwidget->isWindow() && !qt_widget_private(qwidget)->topData()->embedded
- && (!qApp->focusWidget() || qApp->focusWidget()->window() != qwidget)) {
- return YES; // Always do it, so that windows can accept key press events.
+
+ if (qwidget->isWindow() && !qt_widget_private(qwidget)->topData()->embedded) {
+ QWidget *focusWidget = qApp->focusWidget();
+ if (!focusWidget) {
+ // There is no focus widget, but we still want to receive key events
+ // for shortcut handling etc. So we accept first responer for the
+ // content view as a last resort:
+ return YES;
+ }
+ if (!focusWidget->internalWinId() && focusWidget->nativeParentWidget() == qwidget) {
+ // The current focus widget is alien, and hence, cannot get acceptsFirstResponder
+ // calls. Since the focus widget is a child of qwidget, we let this view say YES:
+ return YES;
+ }
+ if (focusWidget->window() != qwidget) {
+ // The current focus widget is in another window. Since cocoa
+ // suggest that this window should be key now, we accept:
+ return YES;
+ }
}
+
return qwidget->focusPolicy() != Qt::NoFocus;
}
- (BOOL)resignFirstResponder
{
if (!qwidget)
- return NO;
+ return YES;
+
// Seems like the following test only triggers if this
// view is inside a QMacNativeWidget:
- if (qwidget == QApplication::focusWidget())
- qwidget->clearFocus();
+// if (QWidget *fw = QApplication::focusWidget()) {
+// if (qwidget == fw || qwidget == fw->nativeParentWidget())
+// fw->clearFocus();
+// }
return YES;
}
@@ -1172,11 +833,11 @@ static int qCocoaViewCount = 0;
{
Q_UNUSED(anImage);
Q_UNUSED(aPoint);
- qMacDnDParams()->performedAction = operation;
+ macCurrentDnDParameters()->performedAction = operation;
if (QDragManager::self()->object
&& QDragManager::self()->dragPrivate()->executed_action != Qt::ActionMask) {
- qMacDnDParams()->performedAction =
- qt_mac_mapDropAction(QDragManager::self()->dragPrivate()->executed_action);
+ macCurrentDnDParameters()->performedAction =
+ qt_mac_mapDropAction(QDragManager::self()->dragPrivate()->executed_action);
}
}
@@ -1191,51 +852,37 @@ static int qCocoaViewCount = 0;
qwidgetprivate = 0;
}
-- (BOOL)qt_leftButtonIsRightButton
-{
- return leftButtonIsRightButton;
-}
-
-- (void)qt_setLeftButtonIsRightButton:(BOOL)isSwapped
-{
- leftButtonIsRightButton = isSwapped;
-}
-
-+ (DnDParams*)currentMouseEvent
-{
- return qMacDnDParams();
-}
-
- (void)keyDown:(NSEvent *)theEvent
{
- sendKeyEvents = true;
-
- QWidget *widgetToGetKey = qwidget;
+ if (!qwidget)
+ return;
+ QWidget *widgetToGetKey = qt_mac_getTargetForKeyEvent(qwidget);
+ if (!widgetToGetKey)
+ return;
- QWidget *popup = qAppInstance()->activePopupWidget();
- bool sendToPopup = false;
- if (popup && popup != qwidget->window()) {
- widgetToGetKey = popup->focusWidget() ? popup->focusWidget() : popup;
- sendToPopup = true;
- }
+ sendKeyEvents = true;
if (widgetToGetKey->testAttribute(Qt::WA_InputMethodEnabled)
&& !(widgetToGetKey->inputMethodHints() & Qt::ImhDigitsOnly
|| widgetToGetKey->inputMethodHints() & Qt::ImhFormattedNumbersOnly
|| widgetToGetKey->inputMethodHints() & Qt::ImhHiddenText)) {
fromKeyDownEvent = true;
- [qt_mac_nativeview_for(widgetToGetKey) interpretKeyEvents:[NSArray arrayWithObject: theEvent]];
+ [qt_mac_nativeview_for(qwidget) interpretKeyEvents:[NSArray arrayWithObject: theEvent]];
fromKeyDownEvent = false;
}
+
if (sendKeyEvents && !composing) {
- bool keyOK = qt_dispatchKeyEvent(theEvent, widgetToGetKey);
- if (!keyOK && !sendToPopup) {
- // find the first responder that is not created by Qt and forward
- // the event to it (for example if Qt widget is embedded into native).
+ bool keyEventEaten = qt_dispatchKeyEvent(theEvent, widgetToGetKey);
+ if (!keyEventEaten && qwidget) {
+ // The event is not yet eaten, and if Qt is embedded inside a native
+ // cocoa application, send it to first responder not owned by Qt.
+ // The exception is if widgetToGetKey was redirected to a popup.
QWidget *toplevel = qwidget->window();
- if (toplevel && qt_widget_private(toplevel)->topData()->embedded) {
- if (NSResponder *w = [qt_mac_nativeview_for(toplevel) superview])
- [w keyDown:theEvent];
+ if (toplevel == widgetToGetKey->window()) {
+ if (qt_widget_private(toplevel)->topData()->embedded) {
+ if (NSResponder *w = [qt_mac_nativeview_for(toplevel) superview])
+ [w keyDown:theEvent];
+ }
}
}
}
@@ -1245,12 +892,21 @@ static int qCocoaViewCount = 0;
- (void)keyUp:(NSEvent *)theEvent
{
if (sendKeyEvents) {
- bool keyOK = qt_dispatchKeyEvent(theEvent, qwidget);
- if (!keyOK) {
+ QWidget *widgetToGetKey = qt_mac_getTargetForKeyEvent(qwidget);
+ if (!widgetToGetKey)
+ return;
+
+ bool keyEventEaten = qt_dispatchKeyEvent(theEvent, widgetToGetKey);
+ if (!keyEventEaten && qwidget) {
+ // The event is not yet eaten, and if Qt is embedded inside a native
+ // cocoa application, send it to first responder not owned by Qt.
+ // The exception is if widgetToGetKey was redirected to a popup.
QWidget *toplevel = qwidget->window();
- if (toplevel && qt_widget_private(toplevel)->topData()->embedded) {
- if (NSResponder *w = [qt_mac_nativeview_for(toplevel) superview])
- [w keyUp:theEvent];
+ if (toplevel == widgetToGetKey->window()) {
+ if (qt_widget_private(toplevel)->topData()->embedded) {
+ if (NSResponder *w = [qt_mac_nativeview_for(toplevel) superview])
+ [w keyUp:theEvent];
+ }
}
}
}
@@ -1298,13 +954,14 @@ static int qCocoaViewCount = 0;
// When entering characters through Character Viewer or Keyboard Viewer, the text is passed
// through this insertText method. Since we dont receive a keyDown Event in such cases, the
// composing flag will be false.
- if (([aString length] && composing) || !fromKeyDownEvent) {
+ if (([aString length] && composing) || !fromKeyDownEvent) {
// Send the commit string to the widget.
composing = false;
sendKeyEvents = false;
QInputMethodEvent e;
e.setCommitString(commitText);
- qt_sendSpontaneousEvent(qwidget, &e);
+ if (QWidget *widgetToGetKey = qt_mac_getTargetForKeyEvent(qwidget))
+ qt_sendSpontaneousEvent(widgetToGetKey, &e);
} else {
// The key sequence "`q" on a French Keyboard will generate two calls to insertText before
// it returns from interpretKeyEvents. The first call will turn off 'composing' and accept
@@ -1368,8 +1025,11 @@ static int qCocoaViewCount = 0;
0, composingLength, format);
}
*composingText = qtText;
+
QInputMethodEvent e(qtText, attrs);
- qt_sendSpontaneousEvent(qwidget, &e);
+ if (QWidget *widgetToGetKey = qt_mac_getTargetForKeyEvent(qwidget))
+ qt_sendSpontaneousEvent(widgetToGetKey, &e);
+
if (!composingLength)
composing = false;
}
@@ -1379,7 +1039,8 @@ static int qCocoaViewCount = 0;
if (composing) {
QInputMethodEvent e;
e.setCommitString(*composingText);
- qt_sendSpontaneousEvent(qwidget, &e);
+ if (QWidget *widgetToGetKey = qt_mac_getTargetForKeyEvent(qwidget))
+ qt_sendSpontaneousEvent(widgetToGetKey, &e);
}
composingText->clear();
composing = false;
@@ -1452,8 +1113,12 @@ static int qCocoaViewCount = 0;
{
Q_UNUSED(theRange);
// The returned rect is always based on the internal cursor.
- QRect mr(qwidget->inputMethodQuery(Qt::ImMicroFocus).toRect());
- QPoint mp(qwidget->mapToGlobal(QPoint(mr.bottomLeft())));
+ QWidget *widgetToGetKey = qt_mac_getTargetForKeyEvent(qwidget);
+ if (!widgetToGetKey)
+ return NSZeroRect;
+
+ QRect mr(widgetToGetKey->inputMethodQuery(Qt::ImMicroFocus).toRect());
+ QPoint mp(widgetToGetKey->mapToGlobal(QPoint(mr.bottomLeft())));
NSRect rect ;
rect.origin.x = mp.x();
rect.origin.y = flipYCoordinate(mp.y());
@@ -1471,10 +1136,11 @@ static int qCocoaViewCount = 0;
- (NSArray*) validAttributesForMarkedText
{
- if (qwidget == 0)
+ QWidget *widgetToGetKey = qt_mac_getTargetForKeyEvent(qwidget);
+ if (!widgetToGetKey)
return nil;
- if (!qwidget->testAttribute(Qt::WA_InputMethodEnabled))
+ if (!widgetToGetKey->testAttribute(Qt::WA_InputMethodEnabled))
return nil; // Not sure if that's correct, but it's saves a malloc.
// Support only underline color/style.
@@ -1488,7 +1154,7 @@ void QMacInputContext::reset()
{
QWidget *w = QInputContext::focusWidget();
if (w) {
- NSView *view = qt_mac_nativeview_for(w);
+ NSView *view = qt_mac_effectiveview_for(w);
if ([view isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]]) {
QMacCocoaAutoReleasePool pool;
QT_MANGLE_NAMESPACE(QCocoaView) *qc = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(view);
@@ -1505,7 +1171,7 @@ bool QMacInputContext::isComposing() const
{
QWidget *w = QInputContext::focusWidget();
if (w) {
- NSView *view = qt_mac_nativeview_for(w);
+ NSView *view = qt_mac_effectiveview_for(w);
if ([view isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]]) {
return [static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(view) isComposing];
}
@@ -1598,38 +1264,45 @@ Qt::DropAction QDragManager::drag(QDrag *o)
} else {
hotspot = dragPrivate()->hotspot;
}
- // convert the image to NSImage.
+
+ // Convert the image to NSImage:
NSImage *image = (NSImage *)qt_mac_create_nsimage(pix);
[image retain];
- DnDParams dndParams = *[QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent];
- // save supported actions
- [dndParams.view setSupportedActions: qt_mac_mapDropActions(dragPrivate()->possible_actions)];
- NSPoint imageLoc = {dndParams.localPoint.x - hotspot.x(),
- dndParams.localPoint.y + pix.height() - hotspot.y()};
+
+ DnDParams *dndParams = macCurrentDnDParameters();
+ QT_MANGLE_NAMESPACE(QCocoaView) *theView = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(dndParams->view);
+
+ // Save supported actions:
+ [theView setSupportedActions: qt_mac_mapDropActions(dragPrivate()->possible_actions)];
+ QPoint pointInView = [theView qt_qwidget]->mapFromGlobal(dndParams->globalPoint);
+ NSPoint imageLoc = {pointInView.x() - hotspot.x(), pointInView.y() + pix.height() - hotspot.y()};
NSSize mouseOffset = {0.0, 0.0};
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
dragPrivate()->executed_action = Qt::ActionMask;
- // do the drag
- [dndParams.view retain];
- [dndParams.view dragImage:image
- at:imageLoc
- offset:mouseOffset
- event:dndParams.theEvent
- pasteboard:pboard
- source:dndParams.view
- slideBack:YES];
- // reset the implicit grab widget when drag ends because we will not
- // receive the mouse release event when DND is active.
+
+ // Execute the drag:
+ [theView retain];
+ [theView dragImage:image
+ at:imageLoc
+ offset:mouseOffset
+ event:dndParams->theEvent
+ pasteboard:pboard
+ source:theView
+ slideBack:YES];
+
+ // Reset the implicit grab widget when drag ends because we will not
+ // receive the mouse release event when DND is active:
qt_button_down = 0;
- [dndParams.view release];
+ [theView release];
[image release];
if (dragPrivate())
dragPrivate()->executed_action = Qt::IgnoreAction;
object = 0;
- Qt::DropAction performedAction(qt_mac_mapNSDragOperation(qMacDnDParams()->performedAction));
- // do post drag processing, if required.
- if(performedAction != Qt::IgnoreAction) {
- // check if the receiver points us to a file location.
+ Qt::DropAction performedAction(qt_mac_mapNSDragOperation(dndParams->performedAction));
+
+ // Do post drag processing, if required.
+ if (performedAction != Qt::IgnoreAction) {
+ // Check if the receiver points us to a file location.
// if so, we need to do the file copy/move ourselves.
QCFType<CFURLRef> pasteLocation = 0;
PasteboardCopyPasteLocation(dragBoard.pasteBoard(), &pasteLocation);
@@ -1646,6 +1319,8 @@ Qt::DropAction QDragManager::drag(QDrag *o)
}
}
}
+
+ // Clean-up:
o->setMimeData(0);
o->deleteLater();
return performedAction;
diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h
index 8d57f95..cc79b67 100644
--- a/src/gui/kernel/qcocoaview_mac_p.h
+++ b/src/gui/kernel/qcocoaview_mac_p.h
@@ -58,57 +58,30 @@
QT_FORWARD_DECLARE_CLASS(QWidgetPrivate);
QT_FORWARD_DECLARE_CLASS(QWidget);
QT_FORWARD_DECLARE_CLASS(QEvent);
-QT_FORWARD_DECLARE_CLASS(QCocoaDropData);
QT_FORWARD_DECLARE_CLASS(QString);
QT_FORWARD_DECLARE_CLASS(QStringList);
-QT_BEGIN_NAMESPACE
-struct DnDParams
-{
- QT_MANGLE_NAMESPACE(QCocoaView) *view;
- NSEvent *theEvent;
- NSPoint localPoint;
- NSDragOperation performedAction;
- NSPoint activeDragEnterPos;
-};
-
-QT_END_NAMESPACE
-
-QT_FORWARD_DECLARE_STRUCT(DnDParams);
-
Q_GUI_EXPORT
@interface QT_MANGLE_NAMESPACE(QCocoaView) : NSControl <NSTextInput> {
QWidget *qwidget;
QWidgetPrivate *qwidgetprivate;
- bool leftButtonIsRightButton;
- QCocoaDropData *dropData;
NSDragOperation supportedActions;
bool composing;
int composingLength;
bool sendKeyEvents;
bool fromKeyDownEvent;
QString *composingText;
- NSInteger dragEnterSequence;
+ @public int alienTouchCount;
}
- (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
- (void) finishInitWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
- (void)frameDidChange:(NSNotification *)note;
-- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
-- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender;
-- (void)draggingExited:(id < NSDraggingInfo >)sender;
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
-- (void)removeDropData;
-- (void)addDropData:(id <NSDraggingInfo>)sender;
- (void)setSupportedActions:(NSDragOperation)actions;
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal;
- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation;
- (BOOL)isComposing;
- (QWidget *)qt_qwidget;
- (void) qt_clearQWidget;
-- (BOOL)qt_leftButtonIsRightButton;
-- (void)qt_setLeftButtonIsRightButton:(BOOL)isSwapped;
-- (void)changeDraggingCursor:(NSDragOperation)newOperation;
-+ (DnDParams*)currentMouseEvent;
@end
#endif
diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/gui/kernel/qcocoawindow_mac.mm
index 28f09ad..6e5023a 100644
--- a/src/gui/kernel/qcocoawindow_mac.mm
+++ b/src/gui/kernel/qcocoawindow_mac.mm
@@ -47,6 +47,8 @@
#import <private/qt_cocoa_helpers_mac_p.h>
#import <private/qcocoawindowcustomthemeframe_mac_p.h>
#import <private/qcocoaapplication_mac_p.h>
+#import <private/qdnd_p.h>
+#import <private/qmultitouch_mac_p.h>
#include <QtGui/QWidget>
diff --git a/src/gui/kernel/qcocoawindow_mac_p.h b/src/gui/kernel/qcocoawindow_mac_p.h
index 81e0be1..e6b50f5 100644
--- a/src/gui/kernel/qcocoawindow_mac_p.h
+++ b/src/gui/kernel/qcocoawindow_mac_p.h
@@ -50,17 +50,20 @@
// We mean it.
//
+#ifndef QCOCOAWINDOW_MAC_P
+#define QCOCOAWINDOW_MAC_P
+
#ifdef QT_MAC_USE_COCOA
#include "qmacdefines_mac.h"
#import <Cocoa/Cocoa.h>
#include <private/qapplication_p.h>
#include <private/qbackingstore_p.h>
-
enum { QtMacCustomizeWindow = 1 << 21 }; // This will one day be run over by
QT_FORWARD_DECLARE_CLASS(QWidget);
QT_FORWARD_DECLARE_CLASS(QStringList);
+QT_FORWARD_DECLARE_CLASS(QCocoaDropData);
@interface NSWindow (QtCoverForHackWithCategory)
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask;
@@ -72,13 +75,16 @@ QT_FORWARD_DECLARE_CLASS(QStringList);
@end
@interface QT_MANGLE_NAMESPACE(QCocoaWindow) : NSWindow {
- bool leftButtonIsRightButton;
QStringList *currentCustomDragTypes;
+ QCocoaDropData *dropData;
+ NSInteger dragEnterSequence;
}
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask;
- (void)registerDragTypes;
+- (void)drawRectOriginal:(NSRect)rect;
@end
#endif
+#endif
diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h
index d90375da..c993763 100644
--- a/src/gui/kernel/qcursor.h
+++ b/src/gui/kernel/qcursor.h
@@ -77,7 +77,7 @@ class QBitmap;
class QPixmap;
#if defined(Q_WS_MAC)
-void qt_mac_set_cursor(const QCursor *c, const QPoint &p);
+void qt_mac_set_cursor(const QCursor *c);
#endif
#if defined(Q_OS_SYMBIAN)
extern void qt_symbian_show_pointer_sprite();
@@ -141,7 +141,8 @@ private:
QCursorData *d;
#if defined(Q_WS_MAC)
friend void *qt_mac_nsCursorForQCursor(const QCursor &c);
- friend void qt_mac_set_cursor(const QCursor *c, const QPoint &p);
+ friend void qt_mac_set_cursor(const QCursor *c);
+ friend void qt_mac_updateCursorWithWidgetUnderMouse(QWidget *widgetUnderMouse);
#endif
#if defined(Q_OS_SYMBIAN)
friend void qt_symbian_show_pointer_sprite();
diff --git a/src/gui/kernel/qcursor_mac.mm b/src/gui/kernel/qcursor_mac.mm
index 1a82a68..0d57b85 100644
--- a/src/gui/kernel/qcursor_mac.mm
+++ b/src/gui/kernel/qcursor_mac.mm
@@ -50,6 +50,7 @@
#include <AppKit/NSCursor.h>
#include <qpainter.h>
#include <private/qt_cocoa_helpers_mac_p.h>
+#include <private/qapplication_p.h>
QT_BEGIN_NAMESPACE
@@ -60,6 +61,7 @@ extern QCursorData *qt_cursorTable[Qt::LastCursor + 1];
extern OSWindowRef qt_mac_window_for(const QWidget *); //qwidget_mac.cpp
extern GrafPtr qt_mac_qd_context(const QPaintDevice *); //qpaintdevice_mac.cpp
extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); //qapplication_mac.cpp
+extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
/*****************************************************************************
Internal QCursorData class
@@ -95,18 +97,19 @@ protected:
}
};
-void *qt_mac_nsCursorForQCursor(const QCursor &c)
+inline void *qt_mac_nsCursorForQCursor(const QCursor &c)
{
c.d->update();
return [[static_cast<NSCursor *>(c.d->curs.cp.nscursor) retain] autorelease];
}
static QCursorData *currentCursor = 0; //current cursor
-void qt_mac_set_cursor(const QCursor *c, const QPoint &)
+
+void qt_mac_set_cursor(const QCursor *c)
{
#ifdef QT_MAC_USE_COCOA
- Q_UNUSED(c);
- return;
+ QMacCocoaAutoReleasePool pool;
+ [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(*c)) set];
#else
if (!c) {
currentCursor = 0;
@@ -128,35 +131,122 @@ void qt_mac_set_cursor(const QCursor *c, const QPoint &)
c->d->curs.tc.anim->start(c->d->curs.tc.curs);
}
}
+
currentCursor = c->d;
#endif
}
-void qt_mac_update_cursor_at_global_pos(const QPoint &globalPos)
+static QPointer<QWidget> lastWidgetUnderMouse = 0;
+static QPointer<QWidget> lastMouseCursorWidget = 0;
+static bool qt_button_down_on_prev_call = false;
+static QCursor *grabCursor = 0;
+
+void qt_mac_updateCursorWithWidgetUnderMouse(QWidget *widgetUnderMouse)
{
-#ifdef QT_MAC_USE_COCOA
- Q_UNUSED(globalPos);
- return;
-#else
QCursor cursor(Qt::ArrowCursor);
+ if (qt_button_down) {
+ // The widget that is currently pressed
+ // grabs the mouse cursor:
+ widgetUnderMouse = qt_button_down;
+ qt_button_down_on_prev_call = true;
+ } else if (qt_button_down_on_prev_call) {
+ // Grab has been released, so do
+ // a full check:
+ qt_button_down_on_prev_call = false;
+ lastWidgetUnderMouse = 0;
+ lastMouseCursorWidget = 0;
+ }
+
if (QApplication::overrideCursor()) {
cursor = *QApplication::overrideCursor();
- } else {
- for(QWidget *w = QApplication::widgetAt(globalPos); w; w = w->parentWidget()) {
- if(w->testAttribute(Qt::WA_SetCursor)) {
- cursor = w->cursor();
- break;
+ } else if (grabCursor) {
+ cursor = *grabCursor;
+ } else if (widgetUnderMouse) {
+ if (widgetUnderMouse == lastWidgetUnderMouse) {
+ // Optimization that should hit when the widget under
+ // the mouse does not change as the mouse moves:
+ if (lastMouseCursorWidget)
+ cursor = lastMouseCursorWidget->cursor();
+ } else {
+ QWidget *w = widgetUnderMouse;
+ for (; w; w = w->parentWidget()) {
+ if (w->testAttribute(Qt::WA_SetCursor)) {
+ cursor = w->cursor();
+ break;
+ }
+ if (w->isWindow())
+ break;
}
+ // One final check in case we ran out of parents in the loop:
+ if (w && !w->testAttribute(Qt::WA_SetCursor))
+ w = 0;
+
+ lastWidgetUnderMouse = widgetUnderMouse;
+ lastMouseCursorWidget = w;
}
}
- qt_mac_set_cursor(&cursor, globalPos);
+
+#ifdef QT_MAC_USE_COCOA
+ cursor.d->update();
+ NSCursor *nsCursor = static_cast<NSCursor *>(cursor.d->curs.cp.nscursor);
+ if ([NSCursor currentCursor] != nsCursor) {
+ QMacCocoaAutoReleasePool pool;
+ [nsCursor set];
+ }
+#else
+ qt_mac_set_cursor(&cursor);
#endif
}
void qt_mac_update_cursor()
{
- qt_mac_update_cursor_at_global_pos(QCursor::pos());
+ // This function is similar to qt_mac_updateCursorWithWidgetUnderMouse
+ // except that is clears the optimization cache, and finds the widget
+ // under mouse itself. Clearing the cache is useful in cases where the
+ // application has been deactivated/activated etc.
+ // NB: since we dont have any true native widget, the call to
+ // qt_mac_getTargetForMouseEvent will fail when the mouse is over QMacNativeWidgets.
+#ifdef QT_MAC_USE_COCOA
+ lastWidgetUnderMouse = 0;
+ lastMouseCursorWidget = 0;
+ QWidget *widgetUnderMouse = 0;
+
+ if (qt_button_down) {
+ widgetUnderMouse = qt_button_down;
+ } else {
+ QPoint localPoint;
+ QPoint globalPoint = QCursor::pos();
+ qt_mac_getTargetForMouseEvent(0, QEvent::None, localPoint, globalPoint, 0, &widgetUnderMouse);
+ }
+ qt_mac_updateCursorWithWidgetUnderMouse(widgetUnderMouse);
+#else
+ qt_mac_updateCursorWithWidgetUnderMouse(QApplication::widgetAt(QCursor::pos()));
+#endif
+}
+
+void qt_mac_setMouseGrabCursor(bool set, QCursor *const cursor = 0)
+{
+ if (grabCursor) {
+ delete grabCursor;
+ grabCursor = 0;
+ }
+ if (set) {
+ if (cursor)
+ grabCursor = new QCursor(*cursor);
+ else if (lastMouseCursorWidget)
+ grabCursor = new QCursor(lastMouseCursorWidget->cursor());
+ else
+ grabCursor = new QCursor(Qt::ArrowCursor);
+ }
+ qt_mac_update_cursor();
+}
+
+#ifndef QT_MAC_USE_COCOA
+void qt_mac_update_cursor_at_global_pos(const QPoint &globalPos)
+{
+ qt_mac_updateCursorWithWidgetUnderMouse(QApplication::widgetAt(globalPos));
}
+#endif
static int nextCursorId = Qt::BitmapCursor;
@@ -427,7 +517,8 @@ void QCursorData::update()
break;
case Qt::DragCopyCursor:
type = QCursorData::TYPE_ThemeCursor;
- curs.cp.nscursor = [NSCursor dragCopyCursor];
+ if ([NSCursor respondsToSelector:@selector(dragCopyCursor)])
+ curs.cp.nscursor = [NSCursor performSelector:@selector(dragCopyCursor)];
break;
case Qt::DragMoveCursor:
type = QCursorData::TYPE_ThemeCursor;
@@ -435,7 +526,8 @@ void QCursorData::update()
break;
case Qt::DragLinkCursor:
type = QCursorData::TYPE_ThemeCursor;
- curs.cp.nscursor = [NSCursor dragLinkCursor];
+ if ([NSCursor respondsToSelector:@selector(dragLinkCursor)])
+ curs.cp.nscursor = [NSCursor performSelector:@selector(dragLinkCursor)];
break;
#define QT_USE_APPROXIMATE_CURSORS
#ifdef QT_USE_APPROXIMATE_CURSORS
diff --git a/src/gui/kernel/qdnd_mac.mm b/src/gui/kernel/qdnd_mac.mm
index d630faa..3af2ba0 100644
--- a/src/gui/kernel/qdnd_mac.mm
+++ b/src/gui/kernel/qdnd_mac.mm
@@ -491,7 +491,7 @@ bool QWidgetPrivate::qt_mac_dnd_event(uint kind, DragRef dragRef)
SetThemeCursor(cursor);
}
if(found_cursor) {
- qt_mac_set_cursor(0, QPoint()); //just use our's
+ qt_mac_set_cursor(0); //just use our's
} else {
QCursor cursor(Qt::ArrowCursor);
if(qApp && qApp->overrideCursor()) {
@@ -504,7 +504,7 @@ bool QWidgetPrivate::qt_mac_dnd_event(uint kind, DragRef dragRef)
}
}
}
- qt_mac_set_cursor(&cursor, QPoint(mouse.h, mouse.v));
+ qt_mac_set_cursor(&cursor);
}
//idle things
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index db25da3..277a5e8 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -54,6 +54,10 @@
#include "qgesture.h"
#include "qgesture_p.h"
+#ifdef Q_OS_SYMBIAN
+#include "private/qcore_symbian_p.h"
+#endif
+
QT_BEGIN_NAMESPACE
/*!
@@ -725,12 +729,12 @@ QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
or QEvent::ShortcutOverride.
- Int \a key is the code for the Qt::Key that the event loop should listen
- for. If \a key is 0, the event is not a result of a known key; for
+ Int \a key is the code for the Qt::Key that the event loop should listen
+ for. If \a key is 0, the event is not a result of a known key; for
example, it may be the result of a compose sequence or keyboard macro.
- The \a modifiers holds the keyboard modifiers, and the given \a text
- is the Unicode text that the key generated. If \a autorep is true,
- isAutoRepeat() will be true. \a count is the number of keys involved
+ The \a modifiers holds the keyboard modifiers, and the given \a text
+ is the Unicode text that the key generated. If \a autorep is true,
+ isAutoRepeat() will be true. \a count is the number of keys involved
in the event.
*/
QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,
@@ -1659,7 +1663,7 @@ Qt::ButtonState QContextMenuEvent::state() const
string is controlled by the widget only). The AttributeType enum
describes the different attributes that can be set.
- A class implementing QWidget::inputMethodEvent() or
+ A class implementing QWidget::inputMethodEvent() or
QGraphicsItem::inputMethodEvent() should at least understand and
honor the \l TextFormat and \l Cursor attributes.
@@ -3024,9 +3028,16 @@ QShowEvent::~QShowEvent()
This event is only used to notify the application of a request.
It may be safely ignored.
- \note This class is currently supported for Mac OS X only.
+ \note This class is currently supported for Mac OS X and Symbian only.
*/
+QFileOpenEventPrivate::~QFileOpenEventPrivate()
+{
+#ifdef Q_OS_SYMBIAN
+ file.Close();
+#endif
+}
+
/*!
\internal
@@ -3050,6 +3061,22 @@ QFileOpenEvent::QFileOpenEvent(const QUrl &url)
f = url.toLocalFile();
}
+#ifdef Q_OS_SYMBIAN
+/*! \internal
+*/
+QFileOpenEvent::QFileOpenEvent(const RFile &fileHandle)
+ : QEvent(FileOpen)
+{
+ TFileName fullName;
+ fileHandle.FullName(fullName);
+ f = qt_TDesC2QString(fullName);
+ QScopedPointer<QFileOpenEventPrivate> priv(new QFileOpenEventPrivate(QUrl::fromLocalFile(f)));
+ // Duplicate here allows the file handle to be valid after S60 app construction is complete.
+ qt_symbian_throwIfError(priv->file.Duplicate(fileHandle));
+ d = reinterpret_cast<QEventPrivate *>(priv.take());
+}
+#endif
+
/*! \internal
*/
QFileOpenEvent::~QFileOpenEvent()
@@ -3075,6 +3102,39 @@ QUrl QFileOpenEvent::url() const
return reinterpret_cast<const QFileOpenEventPrivate *>(d)->url;
}
+/*!
+ \fn bool openFile(QFile &file, QIODevice::OpenMode flags) const
+
+ Opens a QFile on the file referenced by this event.
+ Returns true if successful; otherwise returns false.
+
+ This is necessary as some files cannot be opened by name, but require specific
+ information stored in this event.
+ For example, if this QFileOpenEvent contains a request to open a Symbian data caged file,
+ the QFile could only be opened from the Symbian RFile used in the construction of this event.
+
+ \since 4.8
+*/
+bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
+{
+ file.setFileName(f);
+#ifdef Q_OS_SYMBIAN
+ const QFileOpenEventPrivate *priv = reinterpret_cast<const QFileOpenEventPrivate *>(d);
+ if (priv->file.SubSessionHandle()) {
+ RFile dup;
+ // Duplicate here means that the opened QFile will continue to be valid beyond the lifetime of this QFileOpenEvent.
+ // It also allows openFile to be used in threads other than the thread in which the QFileOpenEvent was created.
+ if (dup.Duplicate(priv->file) == KErrNone) {
+ QScopedPointer<RFile, QScopedPointerRCloser<RFile> > dupCloser(&dup);
+ bool open = file.open(dup, flags, QFile::AutoCloseHandle);
+ dupCloser.take();
+ return open;
+ }
+ }
+#endif
+ return file.open(flags);
+}
+
#ifndef QT_NO_TOOLBAR
/*!
\internal
@@ -3623,7 +3683,7 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
#endif
-/*!
+/*!
\class QTouchEvent
\brief The QTouchEvent class contains parameters that describe a touch event.
\since 4.6
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index a7b06f4..93c2bc5 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -54,6 +54,11 @@
#include <QtCore/qvariant.h>
#include <QtCore/qmap.h>
#include <QtCore/qset.h>
+#include <QtCore/qfile.h>
+
+#ifdef Q_OS_SYMBIAN
+class RFile;
+#endif
QT_BEGIN_HEADER
@@ -641,10 +646,14 @@ class Q_GUI_EXPORT QFileOpenEvent : public QEvent
public:
QFileOpenEvent(const QString &file);
QFileOpenEvent(const QUrl &url);
+#ifdef Q_OS_SYMBIAN
+ QFileOpenEvent(const RFile &fileHandle);
+#endif
~QFileOpenEvent();
inline QString file() const { return f; }
QUrl url() const;
+ bool openFile(QFile &file, QIODevice::OpenMode flags) const;
private:
QString f;
};
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index 3a27023..b79f372 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -46,6 +46,10 @@
#include <QtCore/qurl.h>
#include <QtGui/qevent.h>
+#ifdef Q_OS_SYMBIAN
+#include <f32file.h>
+#endif
+
QT_BEGIN_NAMESPACE
//
@@ -174,8 +178,12 @@ public:
: url(url)
{
}
+ ~QFileOpenEventPrivate();
QUrl url;
+#ifdef Q_OS_SYMBIAN
+ RFile file;
+#endif
};
diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
index 17ede02..56daba2 100644
--- a/src/gui/kernel/qgesture.cpp
+++ b/src/gui/kernel/qgesture.cpp
@@ -332,7 +332,7 @@ void QPanGesture::setAcceleration(qreal value)
/*!
\class QPinchGesture
\since 4.6
- \brief The QPinchGesture class describes a pinch gesture made my the user.
+ \brief The QPinchGesture class describes a pinch gesture made by the user.
\ingroup touch
\ingroup gestures
diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h
index 7a7c6a5..ec2d849 100644
--- a/src/gui/kernel/qkeymapper_p.h
+++ b/src/gui/kernel/qkeymapper_p.h
@@ -213,6 +213,7 @@ public:
int mapS60ScanCodesToQt(TUint s60key);
int mapQtToS60Key(int qtKey);
int mapQtToS60ScanCodes(int qtKey);
+ void updateInputLanguage();
#endif
};
diff --git a/src/gui/kernel/qkeymapper_s60.cpp b/src/gui/kernel/qkeymapper_s60.cpp
index f0b17ac..bcf32a5 100644
--- a/src/gui/kernel/qkeymapper_s60.cpp
+++ b/src/gui/kernel/qkeymapper_s60.cpp
@@ -40,7 +40,11 @@
****************************************************************************/
#include "private/qkeymapper_p.h"
+#include <private/qcore_symbian_p.h>
#include <e32keys.h>
+#include <e32cmn.h>
+#include <centralrepository.h>
+#include <biditext.h>
QT_BEGIN_NAMESPACE
@@ -214,4 +218,32 @@ int QKeyMapperPrivate::mapQtToS60ScanCodes(int qtKey)
}
return res;
}
+
+void QKeyMapperPrivate::updateInputLanguage()
+{
+#ifdef Q_WS_S60
+ TInt err;
+ CRepository *repo;
+ const TUid KCRUidAknFep = TUid::Uid(0x101F876D);
+ const TUint32 KAknFepInputTxtLang = 0x00000005;
+ TRAP(err, repo = CRepository::NewL(KCRUidAknFep));
+ if (err != KErrNone)
+ return;
+
+ TInt symbianLang;
+ err = repo->Get(KAknFepInputTxtLang, symbianLang);
+ delete repo;
+ if (err != KErrNone)
+ return;
+
+ QString qtLang = QString::fromAscii(qt_symbianLocaleName(symbianLang));
+ keyboardInputLocale = QLocale(qtLang);
+ keyboardInputDirection = (TBidiText::ScriptDirectionality(TLanguage(symbianLang)) == TBidiText::ERightToLeft)
+ ? Qt::RightToLeft : Qt::LeftToRight;
+#else
+ keyboardInputLocale = QLocale();
+ keyboardInputDirection = Qt::LeftToRight;
+#endif
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qkeymapper_x11_p.cpp b/src/gui/kernel/qkeymapper_x11_p.cpp
index 1fad4b0..2dbe1e7 100644
--- a/src/gui/kernel/qkeymapper_x11_p.cpp
+++ b/src/gui/kernel/qkeymapper_x11_p.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
// This file is auto-generated, do not edit!
+// (Generated using util/xkbdatagen)
static struct {
const char *layout;
diff --git a/src/gui/kernel/qlayout.cpp b/src/gui/kernel/qlayout.cpp
index 1eeaf8e..e014ec8 100644
--- a/src/gui/kernel/qlayout.cpp
+++ b/src/gui/kernel/qlayout.cpp
@@ -980,10 +980,10 @@ void QLayoutPrivate::reparentChildWidgets(QWidget *mw)
/*!
This function is called from \c addWidget() functions in
- subclasses to add \a w as a child widget.
+ subclasses to add \a w as a managed widget of a layout.
- If \a w is already in a layout, this function will give a warning
- and remove \a w from the layout. This function must therefore be
+ If \a w is already managed by a layout, this function will give a warning
+ and remove \a w from that layout. This function must therefore be
called before adding \a w to the layout's data structure.
*/
void QLayout::addChildWidget(QWidget *w)
diff --git a/src/gui/kernel/qmacgesturerecognizer_mac.mm b/src/gui/kernel/qmacgesturerecognizer_mac.mm
index 0e432f3..6a4f0bb 100644
--- a/src/gui/kernel/qmacgesturerecognizer_mac.mm
+++ b/src/gui/kernel/qmacgesturerecognizer_mac.mm
@@ -69,6 +69,7 @@ QMacSwipeGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *e
case QNativeGestureEvent::Swipe: {
QSwipeGesture *g = static_cast<QSwipeGesture *>(gesture);
g->setSwipeAngle(ev->angle);
+ g->setHotSpot(ev->position);
return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint;
break; }
default:
@@ -110,6 +111,7 @@ QMacPinchGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *e
g->setCenterPoint(g->startCenterPoint());
g->setChangeFlags(QPinchGesture::CenterPointChanged);
g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags());
+ g->setHotSpot(ev->position);
return QGestureRecognizer::MayBeGesture | QGestureRecognizer::ConsumeEventHint;
case QNativeGestureEvent::Rotate: {
g->setLastScaleFactor(g->scaleFactor());
@@ -117,6 +119,7 @@ QMacPinchGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *e
g->setRotationAngle(g->rotationAngle() + ev->percentage);
g->setChangeFlags(QPinchGesture::RotationAngleChanged);
g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags());
+ g->setHotSpot(ev->position);
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
}
case QNativeGestureEvent::Zoom:
@@ -125,6 +128,7 @@ QMacPinchGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *e
g->setScaleFactor(g->scaleFactor() * (1 + ev->percentage));
g->setChangeFlags(QPinchGesture::ScaleFactorChanged);
g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags());
+ g->setHotSpot(ev->position);
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
case QNativeGestureEvent::GestureEnd:
return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint;
@@ -221,6 +225,7 @@ QMacPanGestureRecognizer::recognize(QGesture *gesture, QObject *target, QEvent *
const QPointF posOffset = p - _startPos;
g->setLastOffset(g->offset());
g->setOffset(QPointF(posOffset.x(), posOffset.y()));
+ g->setHotSpot(_startPos);
return QGestureRecognizer::TriggerGesture;
}
} else if (_panTimer.isActive()) {
@@ -239,6 +244,7 @@ QMacPanGestureRecognizer::recognize(QGesture *gesture, QObject *target, QEvent *
break;
// Begin new pan session!
_startPos = QCursor::pos();
+ g->setHotSpot(_startPos);
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
}
break; }
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index b2d9ca6..98f62ca 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -89,9 +89,16 @@
#include <private/qcocoaview_mac_p.h>
#include <private/qkeymapper_p.h>
#include <private/qwidget_p.h>
+#include <private/qcocoawindow_mac_p.h>
QT_BEGIN_NAMESPACE
+#ifdef QT_MAC_USE_COCOA
+// Cmd + left mousebutton should produce a right button
+// press (mainly for mac users with one-button mice):
+static bool qt_leftButtonIsRightButton = false;
+#endif
+
Q_GLOBAL_STATIC(QMacWindowFader, macwindowFader);
QMacWindowFader::QMacWindowFader()
@@ -141,6 +148,9 @@ void QMacWindowFader::performFade()
extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // qapplication.cpp;
extern QWidget * mac_mouse_grabber;
extern QWidget *qt_button_down; //qapplication_mac.cpp
+extern QPointer<QWidget> qt_last_mouse_receiver;
+extern OSViewRef qt_mac_effectiveview_for(const QWidget *w);
+extern void qt_mac_updateCursorWithWidgetUnderMouse(QWidget *widgetUnderMouse); // qcursor_mac.mm
void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds)
{
@@ -167,6 +177,70 @@ void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds)
}
}
}
+struct dndenum_mapper
+{
+ NSDragOperation mac_code;
+ Qt::DropAction qt_code;
+ bool Qt2Mac;
+};
+
+#ifdef QT_MAC_USE_COCOA && __OBJC__
+
+static dndenum_mapper dnd_enums[] = {
+ { NSDragOperationLink, Qt::LinkAction, true },
+ { NSDragOperationMove, Qt::MoveAction, true },
+ { NSDragOperationCopy, Qt::CopyAction, true },
+ { NSDragOperationGeneric, Qt::CopyAction, false },
+ { NSDragOperationEvery, Qt::ActionMask, false },
+ { NSDragOperationNone, Qt::IgnoreAction, false }
+};
+
+NSDragOperation qt_mac_mapDropAction(Qt::DropAction action)
+{
+ for (int i=0; dnd_enums[i].qt_code; i++) {
+ if (dnd_enums[i].Qt2Mac && (action & dnd_enums[i].qt_code)) {
+ return dnd_enums[i].mac_code;
+ }
+ }
+ return NSDragOperationNone;
+}
+
+NSDragOperation qt_mac_mapDropActions(Qt::DropActions actions)
+{
+ NSDragOperation nsActions = NSDragOperationNone;
+ for (int i=0; dnd_enums[i].qt_code; i++) {
+ if (dnd_enums[i].Qt2Mac && (actions & dnd_enums[i].qt_code))
+ nsActions |= dnd_enums[i].mac_code;
+ }
+ return nsActions;
+}
+
+Qt::DropAction qt_mac_mapNSDragOperation(NSDragOperation nsActions)
+{
+ Qt::DropAction action = Qt::IgnoreAction;
+ for (int i=0; dnd_enums[i].mac_code; i++) {
+ if (nsActions & dnd_enums[i].mac_code)
+ return dnd_enums[i].qt_code;
+ }
+ return action;
+}
+
+Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions)
+{
+ Qt::DropActions actions = Qt::IgnoreAction;
+ for (int i=0; dnd_enums[i].mac_code; i++) {
+ if (nsActions & dnd_enums[i].mac_code)
+ actions |= dnd_enums[i].qt_code;
+ }
+ return actions;
+}
+
+Q_GLOBAL_STATIC(DnDParams, currentDnDParameters);
+DnDParams *macCurrentDnDParameters()
+{
+ return currentDnDParameters();
+}
+#endif
bool macWindowIsTextured( void * /*OSWindowRef*/ window )
{
@@ -301,7 +375,7 @@ bool qt_mac_checkForNativeSizeGrip(const QWidget *widget)
HIViewFindByID(HIViewGetRoot(HIViewGetWindow(HIViewRef(widget->winId()))), kHIViewWindowGrowBoxID, &nativeSizeGrip);
return (nativeSizeGrip != 0);
#else
- return [[reinterpret_cast<NSView *>(widget->winId()) window] showsResizeIndicator];
+ return [[reinterpret_cast<NSView *>(widget->effectiveWinId()) window] showsResizeIndicator];
#endif
}
struct qt_mac_enum_mapper
@@ -517,8 +591,12 @@ static const KeyPair entries[NumEntries] = {
{ NSNewlineCharacter, Qt::Key_Return },
{ NSCarriageReturnCharacter, Qt::Key_Return },
{ NSBackTabCharacter, Qt::Key_Backtab },
- { NSDeleteCharacter, Qt::Key_Delete },
{ kEscapeCharCode, Qt::Key_Escape },
+ // Cocoa sends us delete when pressing backspace!
+ // (NB when we reverse this list in qtKey2CocoaKey, there
+ // will be two indices of Qt::Key_Backspace. But is seems to work
+ // ok for menu shortcuts (which uses that function):
+ { NSDeleteCharacter, Qt::Key_Backspace },
{ NSUpArrowFunctionKey, Qt::Key_Up },
{ NSDownArrowFunctionKey, Qt::Key_Down },
{ NSLeftArrowFunctionKey, Qt::Key_Left },
@@ -731,7 +809,6 @@ Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
return Qt::NoButton;
}
-// Helper to share code between QCocoaWindow and QCocoaView
bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEvent)
{
#ifndef QT_MAC_USE_COCOA
@@ -743,6 +820,7 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve
EventRef key_event = static_cast<EventRef>(const_cast<void *>([event eventRef]));
Q_ASSERT(key_event);
unsigned int info = 0;
+
if ([event type] == NSKeyDown) {
NSString *characters = [event characters];
if ([characters length]) {
@@ -752,19 +830,12 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve
}
}
- // Redirect keys to alien widgets.
- if (widgetToGetEvent->testAttribute(Qt::WA_NativeWindow) == false) {
- widgetToGetEvent = qApp->focusWidget();
- }
-
- if (widgetToGetEvent == 0)
- return false;
-
if (qt_mac_sendMacEventToWidget(widgetToGetEvent, key_event))
return true;
if (mustUseCocoaKeyEvent())
return qt_dispatchKeyEventWithCocoa(keyEvent, widgetToGetEvent);
+
bool consumed = qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &info, true);
return consumed && (info != 0);
#endif
@@ -788,7 +859,6 @@ void qt_dispatchModifiersChanged(void * /*NSEvent * */flagsChangedEvent, QWidget
#endif
}
-
QPointF flipPoint(const NSPoint &p)
{
return QPointF(p.x, flipYCoordinate(p.y));
@@ -804,21 +874,15 @@ NSPoint flipPoint(const QPointF &p)
return NSMakePoint(p.x(), flipYCoordinate(p.y()));
}
-void qt_mac_dispatchNCMouseMessage(void * /* NSWindow* */eventWindow, void * /* NSEvent* */mouseEvent,
- QWidget *widgetToGetEvent, bool &leftButtonIsRightButton)
+#if QT_MAC_USE_COCOA && __OBJC__
+
+void qt_mac_handleNonClientAreaMouseEvent(NSWindow *window, NSEvent *event)
{
-#ifndef QT_MAC_USE_COCOA
- Q_UNUSED(eventWindow);
- Q_UNUSED(mouseEvent);
- Q_UNUSED(widgetToGetEvent);
- Q_UNUSED(leftButtonIsRightButton);
-#else
+ QWidget *widgetToGetEvent = [window QT_MANGLE_NAMESPACE(qt_qwidget)];
if (widgetToGetEvent == 0)
return;
- NSWindow *window = static_cast<NSWindow *>(eventWindow);
- NSEvent *event = static_cast<NSEvent *>(mouseEvent);
- NSEventType evtType = [event type];
+ NSEventType evtType = [event type];
QPoint qlocalPoint;
QPoint qglobalPoint;
bool processThisEvent = false;
@@ -936,12 +1000,12 @@ void qt_mac_dispatchNCMouseMessage(void * /* NSWindow* */eventWindow, void * /*
: QEvent::MouseButtonDblClick;
if (button == Qt::LeftButton && (keyMods & Qt::MetaModifier)) {
button = Qt::RightButton;
- leftButtonIsRightButton = true;
+ qt_leftButtonIsRightButton = true;
}
} else if (eventType == QEvent::NonClientAreaMouseButtonRelease || eventType == QEvent::MouseButtonRelease) {
- if (button == Qt::LeftButton && leftButtonIsRightButton) {
+ if (button == Qt::LeftButton && qt_leftButtonIsRightButton) {
button = Qt::RightButton;
- leftButtonIsRightButton = false;
+ qt_leftButtonIsRightButton = false;
}
}
@@ -961,155 +1025,265 @@ void qt_mac_dispatchNCMouseMessage(void * /* NSWindow* */eventWindow, void * /*
// However we might need to unset it if the event is Release.
if (eventType == QEvent::MouseButtonRelease)
qt_button_down = 0;
-#endif
}
-bool qt_mac_handleMouseEvent(void * /* NSView * */view, void * /* NSEvent * */event, QEvent::Type eventType, Qt::MouseButton button)
+QWidget *qt_mac_getTargetForKeyEvent(QWidget *widgetThatReceivedEvent)
{
-#ifndef QT_MAC_USE_COCOA
- Q_UNUSED(view);
- Q_UNUSED(event);
- Q_UNUSED(eventType);
- Q_UNUSED(button);
- return false;
-#else
- QT_MANGLE_NAMESPACE(QCocoaView) *theView = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(view);
- NSEvent *theEvent = static_cast<NSEvent *>(event);
+ if (QWidget *popup = QApplication::activePopupWidget()) {
+ QWidget *focusInPopup = popup->focusWidget();
+ return focusInPopup ? focusInPopup : popup;
+ }
- // Give the Input Manager a chance to process the mouse events.
- NSInputManager *currentIManager = [NSInputManager currentInputManager];
- if (currentIManager && [currentIManager wantsToHandleMouseEvents]) {
- [currentIManager handleMouseEvent:theEvent];
- }
+ QWidget *widgetToGetKey = qApp->focusWidget();
+ if (!widgetToGetKey)
+ widgetToGetKey = widgetThatReceivedEvent;
- // Handle tablet events (if any) first.
- if (qt_mac_handleTabletEvent(theView, theEvent)) {
- // Tablet event was handled. In Qt we aren't supposed to send the mouse event.
- return true;
+ return widgetToGetKey;
+}
+
+// This function will find the widget that should receive the
+// mouse event. Because of explicit/implicit mouse grabs, popups,
+// etc, this might not end up being the same as the widget under
+// the mouse (which is more interresting when handling enter/leave
+// events
+QWidget *qt_mac_getTargetForMouseEvent(
+ // You can call this function without providing an event.
+ // If so, set returnGlobalPoint before the call.
+ NSEvent *event,
+ QEvent::Type eventType,
+ QPoint &returnLocalPoint,
+ QPoint &returnGlobalPoint,
+ QWidget *nativeWidget,
+ QWidget **returnWidgetUnderMouse)
+{
+ Q_UNUSED(event);
+ returnGlobalPoint = flipPoint([NSEvent mouseLocation]).toPoint();
+ QWidget *mouseGrabber = QWidget::mouseGrabber();
+ bool buttonDownNotBlockedByModal = qt_button_down && !QApplicationPrivate::isBlockedByModal(qt_button_down);
+ QWidget *popup = QApplication::activePopupWidget();
+
+ // Resolve the widget under the mouse:
+ QWidget *widgetUnderMouse = 0;
+ if (popup || qt_button_down || !nativeWidget || !nativeWidget->isVisible()) {
+ // Using QApplication::widgetAt for finding the widget under the mouse
+ // is most safe, since it ignores cocoas own mouse down redirections (which
+ // we need to be prepared for when using nativeWidget as starting point).
+ // (the only exception is for QMacNativeWidget, where QApplication::widgetAt fails).
+ // But it is also slower (I guess), so we try to avoid it and use nativeWidget if we can:
+ widgetUnderMouse = QApplication::widgetAt(returnGlobalPoint);
}
- NSPoint windowPoint = [theEvent locationInWindow];
- NSPoint globalPoint = [[theEvent window] convertBaseToScreen:windowPoint];
+ if (!widgetUnderMouse && nativeWidget) {
+ // Entering here should be the common case. We
+ // also handle the QMacNativeWidget fallback case.
+ QPoint p = nativeWidget->mapFromGlobal(returnGlobalPoint);
+ widgetUnderMouse = nativeWidget->childAt(p);
+ if (!widgetUnderMouse && nativeWidget->rect().contains(p))
+ widgetUnderMouse = nativeWidget;
+ }
- // Find the widget that *should* get the event (e.g., maybe it was a pop-up,
- // they always get the mouse event).
- QWidget *qwidget = [theView qt_qwidget];
- QWidget *widgetToGetMouse = 0;
- NSView *tmpView = 0;
- QWidget *popup = qAppInstance()->activePopupWidget();
- QPoint qglobalPoint(flipPoint(globalPoint).toPoint());
+ if (widgetUnderMouse) {
+ // Check if widgetUnderMouse is blocked by a modal
+ // window, or the mouse if over the frame strut:
+ if (widgetUnderMouse == qt_button_down) {
+ // Small optimization to avoid an extra call to isBlockedByModal:
+ if (buttonDownNotBlockedByModal == false)
+ widgetUnderMouse = 0;
+ } else if (QApplicationPrivate::isBlockedByModal(widgetUnderMouse)) {
+ widgetUnderMouse = 0;
+ }
- if (popup) {
- widgetToGetMouse = popup;
- tmpView = qt_mac_nativeview_for(popup);
- windowPoint = [[tmpView window] convertScreenToBase:globalPoint];
-
- QPoint qWindowPoint(windowPoint.x, windowPoint.y);
- if (widgetToGetMouse->rect().contains(qWindowPoint)) {
- // Keeping the mouse pressed on a combobox button will make
- // the popup pop in front of the mouse. But all mouse events
- // will be sendt to the button. Since we want mouse events
- // to be sendt to widgets inside the popup, we search for the
- // widget in front of the mouse:
- tmpView = [tmpView hitTest:windowPoint];
- if (!tmpView)
- return false;
- widgetToGetMouse =
- [static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(tmpView) qt_qwidget];
+ if (widgetUnderMouse && widgetUnderMouse->isWindow()) {
+ // Exclude the titlebar (and frame strut) when finding widget under mouse:
+ QPoint p = widgetUnderMouse->mapFromGlobal(returnGlobalPoint);
+ if (!widgetUnderMouse->rect().contains(p))
+ widgetUnderMouse = 0;
+ }
+ }
+ if (returnWidgetUnderMouse)
+ *returnWidgetUnderMouse = widgetUnderMouse;
+
+ // Resolve the target for the mouse event. Default will be
+ // widgetUnderMouse, except if there is a grab (popup/mouse/button-down):
+ if (popup && !mouseGrabber) {
+ // We special case handling of popups, since they have an implicitt mouse grab.
+ QWidget *candidate = buttonDownNotBlockedByModal ? qt_button_down : widgetUnderMouse;
+ if (!popup->isAncestorOf(candidate)) {
+ // INVARIANT: we have a popup, but the candidate is not
+ // in it. But the popup will grab the mouse anyway,
+ // except if the user scrolls:
+ if (eventType == QEvent::Wheel)
+ return 0;
+ returnLocalPoint = popup->mapFromGlobal(returnGlobalPoint);
+ return popup;
+ } else if (popup == candidate) {
+ // INVARIANT: The candidate is the popup itself, and not a child:
+ returnLocalPoint = popup->mapFromGlobal(returnGlobalPoint);
+ return popup;
+ } else {
+ // INVARIANT: The candidate is a child inside the popup:
+ returnLocalPoint = candidate->mapFromGlobal(returnGlobalPoint);
+ return candidate;
}
+ }
+
+ QWidget *target = mouseGrabber;
+ if (!target && buttonDownNotBlockedByModal)
+ target = qt_button_down;
+ if (!target)
+ target = widgetUnderMouse;
+ if (!target)
+ return 0;
+
+ returnLocalPoint = target->mapFromGlobal(returnGlobalPoint);
+ return target;
+}
+
+QPointer<QWidget> qt_last_native_mouse_receiver = 0;
+
+static inline void qt_mac_checkEnterLeaveForNativeWidgets(QWidget *maybeEnterWidget)
+{
+ // Dispatch enter/leave for the cases where QApplicationPrivate::sendMouseEvent do
+ // not. This will in general be the cases when alien widgets are not involved:
+ // 1. from a native widget to another native widget or
+ // 2. from a native widget to no widget
+ // 3. from no widget to a native or alien widget
+
+ if (qt_button_down || QWidget::mouseGrabber())
+ return;
+
+ if ((maybeEnterWidget == qt_last_native_mouse_receiver) && qt_last_native_mouse_receiver)
+ return;
+ if (maybeEnterWidget) {
+ if (!qt_last_native_mouse_receiver) {
+ // case 3
+ QApplicationPrivate::dispatchEnterLeave(maybeEnterWidget, 0);
+ qt_last_native_mouse_receiver = maybeEnterWidget->internalWinId() ? maybeEnterWidget : maybeEnterWidget->nativeParentWidget();
+ } else if (maybeEnterWidget->internalWinId()) {
+ // case 1
+ QApplicationPrivate::dispatchEnterLeave(maybeEnterWidget, qt_last_native_mouse_receiver);
+ qt_last_native_mouse_receiver = maybeEnterWidget->internalWinId() ? maybeEnterWidget : maybeEnterWidget->nativeParentWidget();
+ } // else at lest one of the widgets are alien, so enter/leave will be handled in QApplicationPrivate
} else {
- extern QWidget * qt_button_down; //qapplication_mac.cpp
- QPoint pos;
- widgetToGetMouse = QApplicationPrivate::pickMouseReceiver(qwidget, qglobalPoint,
- pos, eventType,
- button, qt_button_down, 0);
- if (widgetToGetMouse)
- tmpView = qt_mac_nativeview_for(widgetToGetMouse);
+ if (qt_last_native_mouse_receiver) {
+ // case 2
+ QApplicationPrivate::dispatchEnterLeave(0, qt_last_native_mouse_receiver);
+ qt_last_mouse_receiver = 0;
+ qt_last_native_mouse_receiver = 0;
+ }
}
+}
+
+bool qt_mac_handleMouseEvent(NSEvent *event, QEvent::Type eventType, Qt::MouseButton button, QWidget *nativeWidget)
+{
+ // Give the Input Manager a chance to process the mouse events.
+ NSInputManager *currentIManager = [NSInputManager currentInputManager];
+ if (currentIManager && [currentIManager wantsToHandleMouseEvents]) {
+ [currentIManager handleMouseEvent:event];
+ }
+
+ // Find the widget that should receive the event, and the widget under the mouse. Those
+ // can differ if an implicit or explicit mouse grab is active:
+ QWidget *widgetUnderMouse = 0;
+ QPoint localPoint, globalPoint;
+ QWidget *widgetToGetMouse = qt_mac_getTargetForMouseEvent(event, eventType, localPoint, globalPoint, nativeWidget, &widgetUnderMouse);
if (!widgetToGetMouse)
return false;
- NSPoint localPoint = [tmpView convertPoint:windowPoint fromView:nil];
- QPoint qlocalPoint = QPoint(localPoint.x, localPoint.y);
+ // From here on, we let nativeWidget actually be the native widget under widgetUnderMouse. The reason
+ // for this, is that qt_mac_getTargetForMouseEvent will set cocoa's mouse event redirection aside when
+ // determining which widget is under the mouse (in other words, it will usually ignore nativeWidget).
+ // nativeWidget will be used in QApplicationPrivate::sendMouseEvent to correctly dispatch enter/leave events.
+ if (widgetUnderMouse)
+ nativeWidget = widgetUnderMouse->internalWinId() ? widgetUnderMouse : widgetUnderMouse->nativeParentWidget();
+ if (!nativeWidget)
+ return false;
+ NSView *view = qt_mac_effectiveview_for(nativeWidget);
- // Search for alien child widgets (either on this qwidget or on the popup)
- if (widgetToGetMouse->testAttribute(Qt::WA_NativeWindow) == false || qt_widget_private(widgetToGetMouse)->hasAlienChildren) {
- QPoint qScreenPoint = flipPoint(globalPoint).toPoint();
-#ifdef ALIEN_DEBUG
- qDebug() << "alien mouse event" << qScreenPoint << possibleAlien;
-#endif
- QWidget *possibleAlien = widgetToGetMouse->childAt(qlocalPoint);
- if (possibleAlien) {
- qlocalPoint = possibleAlien->mapFromGlobal(widgetToGetMouse->mapToGlobal(qlocalPoint));
- widgetToGetMouse = possibleAlien;
- }
+ // Handle tablet events (if any) first.
+ if (qt_mac_handleTabletEvent(view, event)) {
+ // Tablet event was handled. In Qt we aren't supposed to send the mouse event.
+ return true;
}
- EventRef carbonEvent = static_cast<EventRef>(const_cast<void *>([theEvent eventRef]));
+ EventRef carbonEvent = static_cast<EventRef>(const_cast<void *>([event eventRef]));
if (qt_mac_sendMacEventToWidget(widgetToGetMouse, carbonEvent))
return true;
- // Yay! All the special cases are handled, it really is just a normal mouse event.
- Qt::KeyboardModifiers keyMods = qt_cocoaModifiers2QtModifiers([theEvent modifierFlags]);
- NSInteger clickCount = [theEvent clickCount];
- Qt::MouseButtons buttons = 0;
+ // Keep previousButton to make sure we don't send double click
+ // events when the user double clicks using two different buttons:
static Qt::MouseButton previousButton = Qt::NoButton;
+
+ Qt::KeyboardModifiers keyMods = qt_cocoaModifiers2QtModifiers([event modifierFlags]);
+ NSInteger clickCount = [event clickCount];
+ Qt::MouseButtons buttons = 0;
{
UInt32 mac_buttons;
if (GetEventParameter(carbonEvent, kEventParamMouseChord, typeUInt32, 0,
sizeof(mac_buttons), 0, &mac_buttons) == noErr)
buttons = qt_mac_get_buttons(mac_buttons);
}
+
+ // Send enter/leave events for the cases when QApplicationPrivate::sendMouseEvent do not:
+ qt_mac_checkEnterLeaveForNativeWidgets(widgetUnderMouse);
+
switch (eventType) {
default:
qWarning("not handled! %d", eventType);
break;
case QEvent::MouseMove:
+ if (button == Qt::LeftButton && qt_leftButtonIsRightButton)
+ button = Qt::RightButton;
break;
case QEvent::MouseButtonPress:
- [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->view = theView;
- [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->theEvent = theEvent;
-#ifndef QT_NAMESPACE
- Q_ASSERT(clickCount > 0);
-#endif
+ qt_button_down = widgetUnderMouse;
if (clickCount % 2 == 0 && (previousButton == Qt::NoButton || previousButton == button))
eventType = QEvent::MouseButtonDblClick;
if (button == Qt::LeftButton && (keyMods & Qt::MetaModifier)) {
button = Qt::RightButton;
- [theView qt_setLeftButtonIsRightButton: true];
+ qt_leftButtonIsRightButton = true;
}
break;
case QEvent::MouseButtonRelease:
- if (button == Qt::LeftButton && [theView qt_leftButtonIsRightButton]) {
+ if (button == Qt::LeftButton && qt_leftButtonIsRightButton) {
button = Qt::RightButton;
- [theView qt_setLeftButtonIsRightButton: false];
+ qt_leftButtonIsRightButton = false;
}
qt_button_down = 0;
break;
}
- [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->localPoint = localPoint;
- QMouseEvent qme(eventType, qlocalPoint, qglobalPoint, button, buttons, keyMods);
-#ifdef ALIEN_DEBUG
- qDebug() << "sending mouse event to" << widgetToGetMouse;
-#endif
- extern QWidget *qt_button_down;
- extern QPointer<QWidget> qt_last_mouse_receiver;
+ qt_mac_updateCursorWithWidgetUnderMouse(widgetUnderMouse);
- if (qwidget->testAttribute(Qt::WA_NativeWindow) && qt_widget_private(qwidget)->hasAlienChildren == false)
- qt_sendSpontaneousEvent(widgetToGetMouse, &qme);
- else
- QApplicationPrivate::sendMouseEvent(widgetToGetMouse, &qme, widgetToGetMouse, qwidget, &qt_button_down,
- qt_last_mouse_receiver);
+ DnDParams *dndParams = currentDnDParameters();
+ dndParams->view = view;
+ dndParams->theEvent = event;
+ dndParams->globalPoint = globalPoint;
+
+ // Send the mouse event:
+ QMouseEvent qme(eventType, localPoint, globalPoint, button, buttons, keyMods);
+ QApplicationPrivate::sendMouseEvent(
+ widgetToGetMouse, &qme, widgetUnderMouse, nativeWidget,
+ &qt_button_down, qt_last_mouse_receiver, true);
if (eventType == QEvent::MouseButtonPress && button == Qt::RightButton) {
- QContextMenuEvent qcme(QContextMenuEvent::Mouse, qlocalPoint, qglobalPoint, keyMods);
+ QContextMenuEvent qcme(QContextMenuEvent::Mouse, localPoint, globalPoint, keyMods);
qt_sendSpontaneousEvent(widgetToGetMouse, &qcme);
}
+
+ if (eventType == QEvent::MouseButtonRelease) {
+ // A mouse button was released, which means that the implicit grab was
+ // released. We therefore need to re-check if should send (delayed) enter leave events:
+ // qt_button_down has now become NULL since the call at the top of the function. Also, since
+ // the relase might have closed a window, we dont give the nativeWidget hint
+ qt_mac_getTargetForMouseEvent(0, QEvent::None, localPoint, globalPoint, nativeWidget, &widgetUnderMouse);
+ qt_mac_checkEnterLeaveForNativeWidgets(widgetUnderMouse);
+ }
+
previousButton = button;
return true;
-#endif
}
+#endif
bool qt_mac_handleTabletEvent(void * /*QCocoaView * */view, void * /*NSEvent * */tabletEvent)
{
@@ -1293,17 +1467,17 @@ void qt_mac_replaceDrawRectOriginal(void * /*OSWindowRef */window, QWidgetPrivat
}
#endif // QT_MAC_USE_COCOA
+#if QT_MAC_USE_COCOA
void qt_mac_showBaseLineSeparator(void * /*OSWindowRef */window, bool show)
{
if(!window)
return;
-#if QT_MAC_USE_COCOA
QMacCocoaAutoReleasePool pool;
OSWindowRef theWindow = static_cast<OSWindowRef>(window);
NSToolbar *macToolbar = [theWindow toolbar];
[macToolbar setShowsBaselineSeparator:show];
-#endif // QT_MAC_USE_COCOA
}
+#endif // QT_MAC_USE_COCOA
QStringList qt_mac_NSArrayToQStringList(void *nsarray)
{
@@ -1323,6 +1497,7 @@ void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list)
return result;
}
+#if QT_MAC_USE_COCOA
void qt_syncCocoaTitleBarButtons(OSWindowRef window, QWidget *widgetForWindow)
{
if (!widgetForWindow)
@@ -1347,6 +1522,7 @@ void qt_syncCocoaTitleBarButtons(OSWindowRef window, QWidget *widgetForWindow)
[window setShowsToolbarButton:uint(flags & Qt::MacWindowToolBarButtonHint) != 0];
}
+#endif // QT_MAC_USE_COCOA
// Carbon: Make sure you call QDEndContext on the context when done with it.
CGContextRef qt_mac_graphicsContextFor(QWidget *widget)
@@ -1448,8 +1624,10 @@ void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayI
}
}
+#ifdef QT_MAC_USE_COCOA
void qt_mac_menu_collapseSeparators(void */*NSMenu **/ theMenu, bool collapse)
{
+ QMacCocoaAutoReleasePool pool;
OSMenuRef menu = static_cast<OSMenuRef>(theMenu);
if (collapse) {
bool previousIsSeparator = true; // setting to true kills all the separators placed at the top.
@@ -1481,12 +1659,24 @@ void qt_mac_menu_collapseSeparators(void */*NSMenu **/ theMenu, bool collapse)
}
}
-#ifdef QT_MAC_USE_COCOA
-void qt_cocoaChangeOverrideCursor(const QCursor &cursor)
+class CocoaPostMessageAfterEventLoopExitHelp : public QObject
{
- QMacCocoaAutoReleasePool pool;
- [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(cursor)) set];
-}
+ id target;
+ SEL selector;
+ int argCount;
+ id arg1;
+ id arg2;
+public:
+ CocoaPostMessageAfterEventLoopExitHelp(id target, SEL selector, int argCount, id arg1, id arg2)
+ : target(target), selector(selector), argCount(argCount), arg1(arg1), arg2(arg2){
+ deleteLater();
+ }
+
+ ~CocoaPostMessageAfterEventLoopExitHelp()
+ {
+ qt_cocoaPostMessage(target, selector, argCount, arg1, arg2);
+ }
+};
void qt_cocoaPostMessage(id target, SEL selector, int argCount, id arg1, id arg2)
{
@@ -1500,6 +1690,15 @@ void qt_cocoaPostMessage(id target, SEL selector, int argCount, id arg1, id arg2
context:nil subtype:QtCocoaEventSubTypePostMessage data1:lower data2:upper];
[NSApp postEvent:e atStart:NO];
}
+
+void qt_cocoaPostMessageAfterEventLoopExit(id target, SEL selector, int argCount, id arg1, id arg2)
+{
+ if (QApplicationPrivate::instance()->threadData->eventLoops.size() <= 1)
+ qt_cocoaPostMessage(target, selector, argCount, arg1, arg2);
+ else
+ new CocoaPostMessageAfterEventLoopExitHelp(target, selector, argCount, arg1, arg2);
+}
+
#endif
QMacCocoaAutoReleasePool::QMacCocoaAutoReleasePool()
@@ -1523,6 +1722,12 @@ void qt_mac_post_retranslateAppMenu()
#endif
}
+QWidgetPrivate *QMacScrollOptimization::_target = 0;
+bool QMacScrollOptimization::_inWheelEvent = false;
+int QMacScrollOptimization::_dx = 0;
+int QMacScrollOptimization::_dy = 0;
+QRect QMacScrollOptimization::_scrollRect = QRect(0, 0, -1, -1);
+
#ifdef QT_MAC_USE_COCOA
// This method implements the magic for the drawRectSpecial method.
// We draw a line at the upper edge of the content view in order to
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
index d61c00f..334d9e8 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h
+++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
@@ -103,6 +103,7 @@
#include <qtimer.h>
#include <qtooltip.h>
#include <private/qeffects_p.h>
+#include <private/qwidget_p.h>
#include <qtextdocument.h>
#include <qdebug.h>
#include <qpoint.h>
@@ -144,18 +145,14 @@ bool qt_mac_checkForNativeSizeGrip(const QWidget *widget);
void qt_dispatchTabletProximityEvent(void * /*NSEvent * */ tabletEvent);
#ifdef QT_MAC_USE_COCOA
bool qt_dispatchKeyEventWithCocoa(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEvent);
-void qt_cocoaChangeOverrideCursor(const QCursor &cursor);
// These methods exists only for supporting unified mode.
void macDrawRectOnTop(void * /*OSWindowRef */ window);
void macSyncDrawingOnFirstInvocation(void * /*OSWindowRef */window);
void qt_cocoaStackChildWindowOnTopOfOtherChildren(QWidget *widget);
-#endif
void qt_mac_menu_collapseSeparators(void * /*NSMenu */ menu, bool collapse);
+#endif
bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEvent);
void qt_dispatchModifiersChanged(void * /*NSEvent * */flagsChangedEvent, QWidget *widgetToGetEvent);
-void qt_mac_dispatchNCMouseMessage(void */* NSWindow* */eventWindow, void */* NSEvent* */mouseEvent,
- QWidget *widgetToGetEvent, bool &leftButtonIsRightButton);
-bool qt_mac_handleMouseEvent(void * /*QCocoaView * */view, void * /*NSEvent * */event, QEvent::Type eventType, Qt::MouseButton button);
bool qt_mac_handleTabletEvent(void * /*QCocoaView * */view, void * /*NSEvent * */event);
inline QApplication *qAppInstance() { return static_cast<QApplication *>(QCoreApplication::instance()); }
struct ::TabletProximityRec;
@@ -165,6 +162,29 @@ Qt::KeyboardModifiers qt_cocoaDragOperation2QtModifiers(uint dragOperations);
QPixmap qt_mac_convert_iconref(const IconRef icon, int width, int height);
void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayIcon, QIcon *retIcon,
QStyle::StandardPixmap standardIcon = QStyle::SP_CustomBase);
+
+#if QT_MAC_USE_COCOA && __OBJC__
+struct DnDParams
+{
+ NSView *view;
+ NSEvent *theEvent;
+ QPoint globalPoint;
+ NSDragOperation performedAction;
+};
+
+DnDParams *macCurrentDnDParameters();
+NSDragOperation qt_mac_mapDropAction(Qt::DropAction action);
+NSDragOperation qt_mac_mapDropActions(Qt::DropActions actions);
+Qt::DropAction qt_mac_mapNSDragOperation(NSDragOperation nsActions);
+Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions);
+
+QWidget *qt_mac_getTargetForKeyEvent(QWidget *widgetThatReceivedEvent);
+QWidget *qt_mac_getTargetForMouseEvent(NSEvent *event, QEvent::Type eventType,
+ QPoint &returnLocalPoint, QPoint &returnGlobalPoint, QWidget *nativeWidget, QWidget **returnWidgetUnderMouse);
+bool qt_mac_handleMouseEvent(NSEvent *event, QEvent::Type eventType, Qt::MouseButton button, QWidget *nativeWidget);
+void qt_mac_handleNonClientAreaMouseEvent(NSWindow *window, NSEvent *event);
+#endif
+
inline int flipYCoordinate(int y)
{
return QApplication::desktop()->screenGeometry(0).height() - y;
@@ -221,10 +241,64 @@ public:
}
};
void qt_cocoaPostMessage(id target, SEL selector, int argCount=0, id arg1=0, id arg2=0);
+void qt_cocoaPostMessageAfterEventLoopExit(id target, SEL selector, int argCount=0, id arg1=0, id arg2=0);
#endif
#endif
+class QMacScrollOptimization {
+ // This class is made to optimize for the case when the user
+ // scrolls both horizontally and vertically at the same
+ // time. This will result in two QWheelEvents (one for each
+ // direction), which will typically result in two calls to
+ // QWidget::_scroll_sys. Rather than copying pixels twize on
+ // screen because of this, we add this helper class to try to
+ // get away with only one blit.
+ static QWidgetPrivate *_target;
+ static bool _inWheelEvent;
+ static int _dx;
+ static int _dy;
+ static QRect _scrollRect;
+
+public:
+ static void initDelayedScroll()
+ {
+ _inWheelEvent = true;
+ }
+
+ static bool delayScroll(QWidgetPrivate *target, int dx, int dy, const QRect &scrollRect)
+ {
+ if (!_inWheelEvent)
+ return false;
+ if (_target && _target != target)
+ return false;
+ if (_scrollRect.width() != -1 && _scrollRect != scrollRect)
+ return false;
+
+ _target = target;
+ _dx += dx;
+ _dy += dy;
+ _scrollRect = scrollRect;
+ return true;
+ }
+
+ static void performDelayedScroll()
+ {
+ if (!_inWheelEvent)
+ return;
+ _inWheelEvent = false;
+ if (!_target)
+ return;
+
+ _target->scroll_sys(_dx, _dy, _scrollRect);
+
+ _target = 0;
+ _dx = 0;
+ _dy = 0;
+ _scrollRect = QRect(0, 0, -1, -1);
+ }
+};
+
void qt_mac_post_retranslateAppMenu();
void qt_mac_display(QWidget *widget);
diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h
index fdb35d5..40697bf 100644
--- a/src/gui/kernel/qt_s60_p.h
+++ b/src/gui/kernel/qt_s60_p.h
@@ -141,6 +141,7 @@ public:
int supportsPremultipliedAlpha : 1;
int avkonComponentsSupportTransparency : 1;
int menuBeingConstructed : 1;
+ int orientationSet : 1;
QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type
static CEikButtonGroupContainer *cba;
@@ -295,6 +296,7 @@ inline QS60Data::QS60Data()
supportsPremultipliedAlpha(0),
avkonComponentsSupportTransparency(0),
menuBeingConstructed(0),
+ orientationSet(0),
s60ApplicationFactory(0)
#ifdef Q_OS_SYMBIAN
,s60InstalledTrapHandler(0)
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 4ba0ef8..bf9f6f9 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -127,6 +127,10 @@
#include "qtabwidget.h" // Needed in inTabWidget()
#endif // QT_KEYPAD_NAVIGATION
+#ifdef Q_WS_S60
+#include <aknappui.h>
+#endif
+
// widget/widget data creation count
//#define QWIDGET_EXTRA_DEBUG
//#define ALIEN_DEBUG
@@ -144,6 +148,10 @@ Q_GUI_EXPORT void qt_x11_set_global_double_buffer(bool enable)
}
#endif
+#if defined(QT_MAC_USE_COCOA)
+bool qt_mac_clearDirtyOnWidgetInsideDrawWidget = false;
+#endif
+
static inline bool qRectIntersects(const QRect &r1, const QRect &r2)
{
return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right()) &&
@@ -300,7 +308,6 @@ QWidgetPrivate::QWidgetPrivate(int version)
#endif
#elif defined(Q_WS_MAC)
, needWindowChange(0)
- , hasAlienChildren(0)
, window_event(0)
, qd_hd(0)
#endif
@@ -322,6 +329,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
hasOwnContext = false;
isInUnifiedToolbar = false;
unifiedSurface = 0;
+ touchEventsEnabled = false;
#endif // QT_MAC_USE_COCOA
#ifdef QWIDGET_EXTRA_DEBUG
static int count = 0;
@@ -395,11 +403,24 @@ void QWidgetPrivate::scrollChildren(int dx, int dy)
}
}
+QInputContext *QWidgetPrivate::assignedInputContext() const
+{
+#ifndef QT_NO_IM
+ const QWidget *widget = q_func();
+ while (widget) {
+ if (QInputContext *qic = widget->d_func()->ic)
+ return qic;
+ widget = widget->parentWidget();
+ }
+#endif
+ return 0;
+}
+
QInputContext *QWidgetPrivate::inputContext() const
{
#ifndef QT_NO_IM
- if (ic)
- return ic;
+ if (QInputContext *qic = assignedInputContext())
+ return qic;
return qApp->inputContext();
#else
return 0;
@@ -1303,9 +1324,9 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
if (f & Qt::MSWindowsOwnDC)
q->setAttribute(Qt::WA_NativeWindow);
-#ifdef Q_WS_MAC
- q->setAttribute(Qt::WA_NativeWindow);
-#endif
+//#ifdef Q_WS_MAC
+// q->setAttribute(Qt::WA_NativeWindow);
+//#endif
q->setAttribute(Qt::WA_QuitOnClose); // might be cleared in adjustQuitOnCloseAttribute()
adjustQuitOnCloseAttribute();
@@ -1412,10 +1433,6 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
#ifndef Q_WS_QPA
if (QWidget *parent = parentWidget()) {
-#ifdef Q_WS_MAC
- if (testAttribute(Qt::WA_NativeWindow) == false)
- parent->d_func()->hasAlienChildren = true;
-#endif
if (type & Qt::Window) {
if (!parent->testAttribute(Qt::WA_WState_Created))
parent->createWinId();
@@ -5399,6 +5416,9 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
return;
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+ if (qt_mac_clearDirtyOnWidgetInsideDrawWidget)
+ dirtyOnWidget = QRegion();
+
// We disable the rendering of QToolBar in the backingStore if
// it's supposed to be in the unified toolbar on Mac OS X.
if (backingStore && isInUnifiedToolbar)
@@ -5486,7 +5506,6 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
//paint the background
if ((asRoot || q->autoFillBackground() || onScreen || q->testAttribute(Qt::WA_StyledBackground))
&& !q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) {
-
QPainter p(q);
paintBackground(&p, toBePainted, (asRoot || onScreen) ? flags | DrawAsRoot : 0);
}
@@ -5668,10 +5687,12 @@ void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectLis
QRect boundingRect;
bool dirtyBoundingRect = true;
const bool exludeOpaqueChildren = (flags & DontDrawOpaqueChildren);
+ const bool excludeNativeChildren = (flags & DontDrawNativeChildren);
do {
QWidget *x = qobject_cast<QWidget*>(siblings.at(index));
- if (x && !(exludeOpaqueChildren && x->d_func()->isOpaque) && !x->isHidden() && !x->isWindow()) {
+ if (x && !(exludeOpaqueChildren && x->d_func()->isOpaque) && !x->isHidden() && !x->isWindow()
+ && !(excludeNativeChildren && x->internalWinId())) {
if (dirtyBoundingRect) {
boundingRect = rgn.boundingRect();
dirtyBoundingRect = false;
@@ -10075,7 +10096,13 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
if (newParent && parent && !desktopWidget) {
- if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings))
+ if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)
+#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+ // On Mac, toolbars inside the unified title bar will never overlap with
+ // siblings in the content view. So we skip enforce native siblings in that case
+ && !d->isInUnifiedToolbar && parentWidget() && parentWidget()->isWindow()
+#endif // Q_WS_MAC && QT_MAC_USE_COCOA
+ )
parent->d_func()->enforceNativeChildren();
else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))
setAttribute(Qt::WA_NativeWindow);
@@ -10722,7 +10749,13 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
ic->setFocusWidget(0);
}
}
- if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget())
+ if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()
+#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+ // On Mac, toolbars inside the unified title bar will never overlap with
+ // siblings in the content view. So we skip enforce native siblings in that case
+ && !d->isInUnifiedToolbar && parentWidget()->isWindow()
+#endif // Q_WS_MAC && QT_MAC_USE_COCOA
+ )
parentWidget()->d_func()->enforceNativeChildren();
if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
d->createWinId();
@@ -10762,7 +10795,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
case Qt::WA_InputMethodEnabled: {
#ifndef QT_NO_IM
QWidget *focusWidget = d->effectiveFocusWidget();
- QInputContext *ic = focusWidget->d_func()->ic;
+ QInputContext *ic = focusWidget->d_func()->assignedInputContext();
if (!ic && (!on || hasFocus()))
ic = focusWidget->d_func()->inputContext();
if (ic) {
@@ -10855,6 +10888,42 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
d->registerTouchWindow();
#endif
break;
+ case Qt::WA_LockPortraitOrientation:
+ case Qt::WA_LockLandscapeOrientation:
+ case Qt::WA_AutoOrientation: {
+ const Qt::WidgetAttribute orientations[3] = {
+ Qt::WA_LockPortraitOrientation,
+ Qt::WA_LockLandscapeOrientation,
+ Qt::WA_AutoOrientation
+ };
+
+ if (on) {
+ // We can only have one of these set at a time
+ for (int i = 0; i < 3; ++i) {
+ if (orientations[i] != attribute)
+ setAttribute_internal(orientations[i], false, data, d);
+ }
+ }
+
+#ifdef Q_WS_S60
+ CAknAppUiBase* appUi = static_cast<CAknAppUiBase*>(CEikonEnv::Static()->EikAppUi());
+ const CAknAppUiBase::TAppUiOrientation s60orientations[] = {
+ CAknAppUiBase::EAppUiOrientationPortrait,
+ CAknAppUiBase::EAppUiOrientationLandscape,
+ CAknAppUiBase::EAppUiOrientationAutomatic
+ };
+ CAknAppUiBase::TAppUiOrientation s60orientation = CAknAppUiBase::EAppUiOrientationUnspecified;
+ for (int i = 0; i < 3; ++i) {
+ if (testAttribute(orientations[i])) {
+ s60orientation = s60orientations[i];
+ break;
+ }
+ }
+ QT_TRAP_THROWING(appUi->SetOrientationL(s60orientation));
+ S60->orientationSet = true;
+#endif
+ break;
+ }
default:
break;
}
@@ -11213,7 +11282,7 @@ void QWidget::updateMicroFocus()
#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
Q_D(QWidget);
// and optimization to update input context only it has already been created.
- if (d->ic || qApp->d_func()->inputContext) {
+ if (d->assignedInputContext() || qApp->d_func()->inputContext) {
QInputContext *ic = inputContext();
if (ic)
ic->update();
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 376999e..9a5a5f1 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -155,7 +155,6 @@ static bool qt_mac_raise_process = true;
static OSWindowRef qt_root_win = 0;
QWidget *mac_mouse_grabber = 0;
QWidget *mac_keyboard_grabber = 0;
-extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
#ifndef QT_MAC_USE_COCOA
#ifdef QT_NAMESPACE
@@ -179,13 +178,15 @@ static CFStringRef kObjectQWidget = CFSTR("com.trolltech.qt.widget");
/*****************************************************************************
Externals
*****************************************************************************/
+extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
extern QWidget *qt_mac_modal_blocked(QWidget *); //qapplication_mac.mm
extern void qt_event_request_activate(QWidget *); //qapplication_mac.mm
extern bool qt_event_remove_activate(); //qapplication_mac.mm
extern void qt_mac_event_release(QWidget *w); //qapplication_mac.mm
extern void qt_event_request_showsheet(QWidget *); //qapplication_mac.mm
extern void qt_event_request_window_change(QWidget *); //qapplication_mac.mm
-extern QPointer<QWidget> qt_mouseover; //qapplication_mac.mm
+extern QPointer<QWidget> qt_last_mouse_receiver; //qapplication_mac.mm
+extern QPointer<QWidget> qt_last_native_mouse_receiver; //qt_cocoa_helpers_mac.mm
extern IconRef qt_mac_create_iconref(const QPixmap &); //qpixmap_mac.cpp
extern void qt_mac_set_cursor(const QCursor *, const QPoint &); //qcursor_mac.mm
extern void qt_mac_update_cursor(); //qcursor_mac.mm
@@ -193,7 +194,8 @@ extern bool qt_nograb();
extern CGImageRef qt_mac_create_cgimage(const QPixmap &, bool); //qpixmap_mac.cpp
extern RgnHandle qt_mac_get_rgn(); //qregion_mac.cpp
extern QRegion qt_mac_convert_mac_region(RgnHandle rgn); //qregion_mac.cpp
-
+extern void qt_mac_setMouseGrabCursor(bool set, QCursor *cursor = 0); // qcursor_mac.mm
+extern QPointer<QWidget> topLevelAt_cache; // qapplication_mac.mm
/*****************************************************************************
QWidget utility functions
*****************************************************************************/
@@ -217,22 +219,13 @@ static QSize qt_mac_desktopSize()
#ifdef QT_MAC_USE_COCOA
static NSDrawer *qt_mac_drawer_for(const QWidget *widget)
{
- // This only goes one level below the content view so start with the window.
- // This works fine for straight Qt stuff, but runs into problems if we are
- // embedding, but if that's the case, they probably want to be using
- // NSDrawer directly.
- NSView *widgetView = reinterpret_cast<NSView *>(widget->window()->winId());
+ NSView *widgetView = reinterpret_cast<NSView *>(widget->window()->effectiveWinId());
NSArray *windows = [NSApp windows];
for (NSWindow *window in windows) {
NSArray *drawers = [window drawers];
for (NSDrawer *drawer in drawers) {
if ([drawer contentView] == widgetView)
return drawer;
- NSArray *views = [[drawer contentView] subviews];
- for (NSView *view in views) {
- if (view == widgetView)
- return drawer;
- }
}
}
return 0;
@@ -314,7 +307,7 @@ bool qt_mac_is_macdrawer(const QWidget *w)
bool qt_mac_insideKeyWindow(const QWidget *w)
{
#ifdef QT_MAC_USE_COCOA
- return [[reinterpret_cast<NSView *>(w->winId()) window] isKeyWindow];
+ return [[reinterpret_cast<NSView *>(w->effectiveWinId()) window] isKeyWindow];
#else
Q_UNUSED(w);
#endif
@@ -421,7 +414,14 @@ inline static void qt_mac_set_fullscreen_mode(bool b)
Q_GUI_EXPORT OSViewRef qt_mac_nativeview_for(const QWidget *w)
{
- return reinterpret_cast<OSViewRef>(w->data->winid);
+ return reinterpret_cast<OSViewRef>(w->internalWinId());
+}
+
+Q_GUI_EXPORT OSViewRef qt_mac_effectiveview_for(const QWidget *w)
+{
+ // Get the first non-alien (parent) widget for
+ // w, and return its NSView (if it has one):
+ return reinterpret_cast<OSViewRef>(w->effectiveWinId());
}
Q_GUI_EXPORT OSViewRef qt_mac_get_contentview_for(OSWindowRef w)
@@ -479,11 +479,12 @@ bool qt_isGenuineQWidget(const QWidget *window)
Q_GUI_EXPORT OSWindowRef qt_mac_window_for(const QWidget *w)
{
- OSViewRef hiview = qt_mac_nativeview_for(w);
- if (hiview){
+ if (OSViewRef hiview = qt_mac_effectiveview_for(w)) {
OSWindowRef window = qt_mac_window_for(hiview);
- if (!window && qt_isGenuineQWidget(hiview)) {
- QWidget *myWindow = w->window();
+ if (window)
+ return window;
+
+ if (qt_isGenuineQWidget(hiview)) {
// This is a workaround for NSToolbar. When a widget is hidden
// by clicking the toolbar button, Cocoa reparents the widgets
// to another window (but Qt doesn't know about it).
@@ -491,18 +492,22 @@ Q_GUI_EXPORT OSWindowRef qt_mac_window_for(const QWidget *w)
// but at this point it's window is nil, but the window it's being brought
// into (the Qt one) is for sure created.
// This stops the hierarchy moving under our feet.
- if (myWindow != w && qt_mac_window_for(qt_mac_nativeview_for(myWindow)))
- return qt_mac_window_for(qt_mac_nativeview_for(myWindow));
+ QWidget *toplevel = w->window();
+ if (toplevel != w) {
+ hiview = qt_mac_nativeview_for(toplevel);
+ if (OSWindowRef w = qt_mac_window_for(hiview))
+ return w;
+ }
- myWindow->d_func()->createWindow_sys();
- // Reget the hiview since the "create window could potentially move the view (I guess).
- hiview = qt_mac_nativeview_for(w);
- window = qt_mac_window_for(hiview);
+ toplevel->d_func()->createWindow_sys();
+ // Reget the hiview since "create window" could potentially move the view (I guess).
+ hiview = qt_mac_nativeview_for(toplevel);
+ return qt_mac_window_for(hiview);
}
- return window;
}
return 0;
}
+
#ifndef QT_MAC_USE_COCOA
/* Checks if the current group is a 'stay on top' group. If so, the
group gets removed from the hash table */
@@ -580,25 +585,6 @@ inline static void qt_mac_set_window_group_to_popup(OSWindowRef window)
}
#endif
-#ifdef QT_MAC_USE_COCOA
-void qt_mac_set_needs_display(QWidget *widget, QRegion region)
-{
- NSView *theNSView = qt_mac_nativeview_for(widget);
- if (region.isEmpty()) {
- [theNSView setNeedsDisplay:YES];
- return;
- }
-
- QVector<QRect> rects = region.rects();
- for (int i = 0; i<rects.count(); ++i) {
- const QRect &rect = rects.at(i);
- NSRect nsrect = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
- [theNSView setNeedsDisplayInRect:nsrect];
- }
-
-}
-#endif
-
inline static bool updateRedirectedToGraphicsProxyWidget(QWidget *widget, const QRect &rect)
{
if (!widget)
@@ -636,6 +622,51 @@ inline static bool updateRedirectedToGraphicsProxyWidget(QWidget *widget, const
return false;
}
+void QWidgetPrivate::macSetNeedsDisplay(QRegion region)
+{
+ Q_Q(QWidget);
+#ifndef QT_MAC_USE_COCOA
+ if (region.isEmpty())
+ HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true);
+ else if (RgnHandle rgnHandle = region.toQDRgnForUpdate_sys())
+ HIViewSetNeedsDisplayInRegion(qt_mac_nativeview_for(q), QMacSmartQuickDrawRegion(rgnHandle), true);
+ else
+ HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true); // do a complete repaint on overflow.
+#else
+ if (NSView *nativeView = qt_mac_nativeview_for(q)) {
+ // INVARIANT: q is _not_ alien. So we can optimize a little:
+ if (region.isEmpty()) {
+ [nativeView setNeedsDisplay:YES];
+ } else {
+ QVector<QRect> rects = region.rects();
+ for (int i = 0; i<rects.count(); ++i) {
+ const QRect &rect = rects.at(i);
+ NSRect nsrect = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
+ [nativeView setNeedsDisplayInRect:nsrect];
+ }
+ }
+ } else if (QWidget *effectiveWidget = q->nativeParentWidget()) {
+ // INVARIANT: q is alien, and effectiveWidget is native.
+ if (NSView *effectiveView = qt_mac_nativeview_for(effectiveWidget)) {
+ if (region.isEmpty()) {
+ const QRect &rect = q->rect();
+ QPoint p = q->mapTo(effectiveWidget, rect.topLeft());
+ NSRect nsrect = NSMakeRect(p.x(), p.y(), rect.width(), rect.height());
+ [effectiveView setNeedsDisplayInRect:nsrect];
+ } else {
+ QVector<QRect> rects = region.rects();
+ for (int i = 0; i<rects.count(); ++i) {
+ const QRect &rect = rects.at(i);
+ QPoint p = q->mapTo(effectiveWidget, rect.topLeft());
+ NSRect nsrect = NSMakeRect(p.x(), p.y(), rect.width(), rect.height());
+ [effectiveView setNeedsDisplayInRect:nsrect];
+ }
+ }
+ }
+ }
+#endif
+}
+
void QWidgetPrivate::macUpdateIsOpaque()
{
Q_Q(QWidget);
@@ -1569,6 +1600,11 @@ OSViewRef qt_mac_create_widget(QWidget *widget, QWidgetPrivate *widgetPrivate, O
#ifdef QT_MAC_USE_COCOA
QMacCocoaAutoReleasePool pool;
QT_MANGLE_NAMESPACE(QCocoaView) *view = [[QT_MANGLE_NAMESPACE(QCocoaView) alloc] initWithQWidget:widget widgetPrivate:widgetPrivate];
+
+#ifdef ALIEN_DEBUG
+ qDebug() << "Creating NSView for" << widget;
+#endif
+
if (view && parent)
[parent addSubview:view];
return view;
@@ -1635,7 +1671,7 @@ bool QWidgetPrivate::qt_mac_update_sizer(QWidget *w, int up)
// to happen, prevent that here (you really want the thing hidden).
if (up >= 0 || topData->resizer != 0)
topData->resizer += up;
- OSWindowRef windowRef = qt_mac_window_for(OSViewRef(w->winId()));
+ OSWindowRef windowRef = qt_mac_window_for(OSViewRef(w->effectiveWinId()));
{
#ifndef QT_MAC_USE_COCOA
WindowClass wclass;
@@ -1670,6 +1706,7 @@ bool QWidgetPrivate::qt_mac_update_sizer(QWidget *w, int up)
void QWidgetPrivate::qt_clean_root_win()
{
#ifdef QT_MAC_USE_COCOA
+ QMacCocoaAutoReleasePool pool;
[qt_root_win release];
#else
if(!qt_root_win)
@@ -2310,15 +2347,12 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin
}
[windowRef setContentView:nsview];
[nsview setHidden:NO];
- if (q->testAttribute(Qt::WA_DropSiteRegistered))
- registerDropSite(true);
transferChildren();
// Tell Cocoa explicit that we wan't the view to receive key events
// (regardless of focus policy) because this is how it works on other
// platforms (and in the carbon port):
- if (!qApp->focusWidget())
- [windowRef makeFirstResponder:nsview];
+ [windowRef makeFirstResponder:nsview];
if (topExtra->posFromMove) {
updateFrameStrut();
@@ -2349,8 +2383,9 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin
q->setAttribute(Qt::WA_WState_WindowOpacitySet, false);
}
- if (qApp->overrideCursor())
- [windowRef disableCursorRects];
+ // Its more performant to handle the mouse cursor
+ // ourselves, expecially when using alien widgets:
+ [windowRef disableCursorRects];
setWindowLevel();
macUpdateHideOnSuspend();
@@ -2468,8 +2503,6 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
data.crect.setRect(0, 0, desktopSize.width(), desktopSize.height());
dialog = popup = false; // force these flags off
} else {
- q->setAttribute(Qt::WA_WState_Visible, false);
-
if (topLevel && (type != Qt::Drawer)) {
if (QDesktopWidget *dsk = QApplication::desktop()) { // calc pos/size from screen
const bool wasResized = q->testAttribute(Qt::WA_Resized);
@@ -2559,6 +2592,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
transfer = true;
} else if (parentWidget) {
// I need to be added to my parent, therefore my parent needs an NSView
+ // Alien note: a 'window' was supplied as argument, meaning this widget
+ // is not alien. So therefore the parent cannot be alien either.
parentWidget->createWinId();
parent = qt_mac_nativeview_for(parentWidget);
}
@@ -2630,11 +2665,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
data.fstrut_dirty = false; // non-toplevel widgets don't have a frame, so no need to update the strut
#ifdef QT_MAC_USE_COCOA
- if (q->testAttribute(Qt::WA_NativeWindow) == false ||
- q->internalWinId() != 0) {
-#ifdef ALIEN_DEBUG
- qDebug() << "Skipping native widget creation for" << this;
-#endif
+ if (q->testAttribute(Qt::WA_NativeWindow) == false || q->internalWinId() != 0) {
+ // INVARIANT: q is Alien, and we should not create an NSView to back it up.
} else
#endif
if (OSViewRef osview = qt_mac_create_widget(q, this, qt_mac_nativeview_for(parentWidget))) {
@@ -2646,21 +2678,26 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
NSRect bounds = NSMakeRect(data.crect.x(), data.crect.y(), data.crect.width(), data.crect.height());
[osview setFrame:bounds];
setWinId((WId)osview);
+ if (q->isVisible()) {
+ // If q were Alien before, but now became native (e.g. if a call to
+ // winId was done from somewhere), we need to show the view immidiatly:
+ QMacCocoaAutoReleasePool pool;
+ [osview setHidden:NO];
+ }
#endif
- if (q->testAttribute(Qt::WA_DropSiteRegistered))
- registerDropSite(true);
}
}
updateIsOpaque();
+
+ if (q->testAttribute(Qt::WA_DropSiteRegistered))
+ registerDropSite(true);
if (q->hasFocus())
setFocus_sys();
if (!topLevel && initializeWindow)
setWSGeometry();
if (destroyid)
qt_mac_destructView(destroyid);
- if (q->testAttribute(Qt::WA_AcceptTouchEvents))
- registerTouchWindow();
}
/*!
@@ -2694,16 +2731,29 @@ QWidget::macCGHandle() const
return handle();
}
+void qt_mac_repaintParentUnderAlienWidget(QWidget *alienWidget)
+{
+ QWidget *nativeParent = alienWidget->nativeParentWidget();
+ if (!nativeParent)
+ return;
+
+ QPoint globalPos = alienWidget->mapToGlobal(QPoint(0, 0));
+ QRect dirtyRect = QRect(nativeParent->mapFromGlobal(globalPos), alienWidget->size());
+ nativeParent->repaint(dirtyRect);
+}
+
void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
{
Q_D(QWidget);
+ QMacCocoaAutoReleasePool pool;
d->aboutToDestroy();
if (!isWindow() && parentWidget())
parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
+ if (!internalWinId())
+ qt_mac_repaintParentUnderAlienWidget(this);
d->deactivateWidgetCleanup();
qt_mac_event_release(this);
if(testAttribute(Qt::WA_WState_Created)) {
- QMacCocoaAutoReleasePool pool;
setAttribute(Qt::WA_WState_Created, false);
QObjectList chldrn = children();
for(int i = 0; i < chldrn.size(); i++) { // destroy all widget children
@@ -2759,7 +2809,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
void QWidgetPrivate::transferChildren()
{
Q_Q(QWidget);
- if (!q->testAttribute(Qt::WA_WState_Created))
+ if (!q->internalWinId())
return; // Can't add any views anyway
QObjectList chlist = q->children();
@@ -2771,7 +2821,7 @@ void QWidgetPrivate::transferChildren()
// This seems weird, no need to call it in a loop right?
if (!topData()->caption.isEmpty())
setWindowTitle_helper(extra->topextra->caption);
- if (w->testAttribute(Qt::WA_WState_Created)) {
+ if (w->internalWinId()) {
#ifndef QT_MAC_USE_COCOA
HIViewAddSubview(qt_mac_nativeview_for(q), qt_mac_nativeview_for(w));
#else
@@ -2900,11 +2950,11 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
#ifndef QT_MAC_USE_COCOA
old_window_event = window_event;
#else
- OSWindowRef oldWindow = qt_mac_window_for(old_id);
if (qt_mac_is_macdrawer(q)) {
oldDrawer = qt_mac_drawer_for(q);
}
if (wasWindow) {
+ OSWindowRef oldWindow = qt_mac_window_for(old_id);
oldToolbar = [oldWindow toolbar];
if (oldToolbar) {
[oldToolbar retain];
@@ -3026,7 +3076,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
QPoint QWidget::mapToGlobal(const QPoint &pos) const
{
Q_D(const QWidget);
- if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
+ if (!internalWinId()) {
QPoint p = pos + data->crect.topLeft();
return isWindow() ? p : parentWidget()->mapToGlobal(p);
}
@@ -3053,7 +3103,7 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const
QPoint QWidget::mapFromGlobal(const QPoint &pos) const
{
Q_D(const QWidget);
- if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
+ if (!internalWinId()) {
QPoint p = isWindow() ? pos : parentWidget()->mapFromGlobal(pos);
return p - data->crect.topLeft();
}
@@ -3080,28 +3130,12 @@ void QWidgetPrivate::updateSystemBackground()
void QWidgetPrivate::setCursor_sys(const QCursor &)
{
-#ifndef QT_MAC_USE_COCOA
qt_mac_update_cursor();
-#else
- Q_Q(QWidget);
- if (q->testAttribute(Qt::WA_WState_Created)) {
- QMacCocoaAutoReleasePool pool;
- [qt_mac_window_for(q) invalidateCursorRectsForView:qt_mac_nativeview_for(q)];
- }
-#endif
}
void QWidgetPrivate::unsetCursor_sys()
{
-#ifndef QT_MAC_USE_COCOA
qt_mac_update_cursor();
-#else
- Q_Q(QWidget);
- if (q->testAttribute(Qt::WA_WState_Created)) {
- QMacCocoaAutoReleasePool pool;
- [qt_mac_window_for(q) invalidateCursorRectsForView:qt_mac_nativeview_for(q)];
- }
-#endif
}
void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
@@ -3243,24 +3277,28 @@ void QWidget::grabMouse()
if(mac_mouse_grabber)
mac_mouse_grabber->releaseMouse();
mac_mouse_grabber=this;
+ qt_mac_setMouseGrabCursor(true);
}
}
#ifndef QT_NO_CURSOR
-void QWidget::grabMouse(const QCursor &)
+void QWidget::grabMouse(const QCursor &cursor)
{
if(isVisible() && !qt_nograb()) {
if(mac_mouse_grabber)
mac_mouse_grabber->releaseMouse();
mac_mouse_grabber=this;
+ qt_mac_setMouseGrabCursor(true, const_cast<QCursor *>(&cursor));
}
}
#endif
void QWidget::releaseMouse()
{
- if(!qt_nograb() && mac_mouse_grabber == this)
+ if(!qt_nograb() && mac_mouse_grabber == this) {
mac_mouse_grabber = 0;
+ qt_mac_setMouseGrabCursor(false);
+ }
}
void QWidget::grabKeyboard()
@@ -3345,35 +3383,10 @@ QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys()
void QWidgetPrivate::update_sys(const QRect &r)
{
Q_Q(QWidget);
- if (r == q->rect()) {
- if (updateRedirectedToGraphicsProxyWidget(q, r))
- return;
- dirtyOnWidget += r;
-#ifndef QT_MAC_USE_COCOA
- HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true);
-#else
- qt_mac_set_needs_display(q, QRegion());
-#endif
+ if (updateRedirectedToGraphicsProxyWidget(q, r))
return;
- }
-
- int x = r.x(), y = r.y(), w = r.width(), h = r.height();
- if (w < 0)
- w = q->data->crect.width() - x;
- if (h < 0)
- h = q->data->crect.height() - y;
- if (w && h) {
- const QRect updateRect = QRect(x, y, w, h);
- if (updateRedirectedToGraphicsProxyWidget(q, updateRect))
- return;
-#ifndef QT_MAC_USE_COCOA
- dirtyOnWidget += updateRect;
- HIRect r = CGRectMake(x, y, w, h);
- HIViewSetNeedsDisplayInRect(qt_mac_nativeview_for(q), &r, true);
-#else
- [qt_mac_nativeview_for(q) setNeedsDisplayInRect:NSMakeRect(x, y, w, h)];
-#endif
- }
+ dirtyOnWidget += r;
+ macSetNeedsDisplay(r != q->rect() ? r : QRegion());
}
void QWidgetPrivate::update_sys(const QRegion &rgn)
@@ -3382,33 +3395,7 @@ void QWidgetPrivate::update_sys(const QRegion &rgn)
if (updateRedirectedToGraphicsProxyWidget(q, rgn))
return;
dirtyOnWidget += rgn;
-#ifndef QT_MAC_USE_COCOA
- RgnHandle rgnHandle = rgn.toQDRgnForUpdate_sys();
- if (rgnHandle)
- HIViewSetNeedsDisplayInRegion(qt_mac_nativeview_for(q), QMacSmartQuickDrawRegion(rgnHandle), true);
- else {
- HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true); // do a complete repaint on overflow.
- }
-#else
- // Alien support: get the first native ancestor widget (will be q itself in the non-alien case),
- // map the coordinates from q space to NSView space and invalidate the rect.
- QWidget *nativeParent = q->internalWinId() ? q : q->nativeParentWidget();
- if (nativeParent == 0)
- return;
-
- QVector<QRect> rects = rgn.rects();
- for (int i = 0; i < rects.count(); ++i) {
- const QRect &rect = rects.at(i);
-
- const QRect nativeBoundingRect = QRect(
- QPoint(q->mapTo(nativeParent, rect.topLeft())),
- QSize(rect.size()));
-
- [qt_mac_nativeview_for(nativeParent) setNeedsDisplayInRect:NSMakeRect(nativeBoundingRect.x(),
- nativeBoundingRect.y(), nativeBoundingRect.width(),
- nativeBoundingRect.height())];
- }
-#endif
+ macSetNeedsDisplay(rgn);
}
bool QWidgetPrivate::isRealWindow() const
@@ -3447,7 +3434,6 @@ void QWidgetPrivate::show_sys()
data.fstrut_dirty = true;
if (realWindow) {
- // Delegates can change window state, so record some things earlier.
bool isCurrentlyMinimized = (q->windowState() & Qt::WindowMinimized);
setModal_sys();
OSWindowRef window = qt_mac_window_for(q);
@@ -3494,9 +3480,11 @@ void QWidgetPrivate::show_sys()
}
}
setSubWindowStacking(true);
+ qt_mac_update_cursor();
#endif
if (q->windowType() == Qt::Popup) {
- if (q->focusWidget())
+ qt_button_down = 0;
+ if (q->focusWidget())
q->focusWidget()->d_func()->setFocus_sys();
else
setFocus_sys();
@@ -3518,21 +3506,34 @@ void QWidgetPrivate::show_sys()
#ifndef QT_MAC_USE_COCOA
HIViewSetVisible(qt_mac_nativeview_for(q), true);
#else
- [qt_mac_nativeview_for(q) setHidden:NO];
-
+ if (NSView *view = qt_mac_nativeview_for(q)) {
+ // INVARIANT: q is native. Just show the view:
+ [view setHidden:NO];
+ } else {
+ // INVARIANT: q is alien. Repaint q instead:
+ q->repaint();
+ }
#endif
}
- if (!QWidget::mouseGrabber()){
- QWidget *enterWidget = QApplication::widgetAt(QCursor::pos());
- QApplicationPrivate::dispatchEnterLeave(enterWidget, qt_mouseover);
- qt_mouseover = enterWidget;
+#ifdef QT_MAC_USE_COCOA
+ if ([NSApp isActive] && !qt_button_down && !QWidget::mouseGrabber()){
+ // Update enter/leave immidiatly, don't wait for a move event. But only
+ // if no grab exists (even if the grab points to this widget, it seems, ref X11)
+ QPoint qlocal, qglobal;
+ QWidget *widgetUnderMouse = 0;
+ qt_mac_getTargetForMouseEvent(0, QEvent::Enter, qlocal, qglobal, 0, &widgetUnderMouse);
+ QApplicationPrivate::dispatchEnterLeave(widgetUnderMouse, qt_last_mouse_receiver);
+ qt_last_mouse_receiver = widgetUnderMouse;
+ qt_last_native_mouse_receiver = widgetUnderMouse ?
+ (widgetUnderMouse->internalWinId() ? widgetUnderMouse : widgetUnderMouse->nativeParentWidget()) : 0;
}
+#endif
+ topLevelAt_cache = 0;
qt_event_request_window_change(q);
}
-
QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt)
{
#ifndef QT_MAC_USE_COCOA
@@ -3613,6 +3614,7 @@ void QWidgetPrivate::hide_sys()
}
#endif
toggleDrawers(false);
+ qt_mac_update_cursor();
#ifndef QT_MAC_USE_COCOA
// Clear modality (because it seems something that we've always done).
if (data.window_modality != Qt::NonModal) {
@@ -3660,18 +3662,31 @@ void QWidgetPrivate::hide_sys()
#ifndef QT_MAC_USE_COCOA
HIViewSetVisible(qt_mac_nativeview_for(q), false);
#else
- [qt_mac_nativeview_for(q) setHidden:YES];
+ if (NSView *view = qt_mac_nativeview_for(q)) {
+ // INVARIANT: q is native. Just hide the view:
+ [view setHidden:YES];
+ } else {
+ // INVARIANT: q is alien. Repaint where q is placed instead:
+ qt_mac_repaintParentUnderAlienWidget(q);
+ }
#endif
}
- if (!QWidget::mouseGrabber()){
- QWidget *enterWidget = QApplication::widgetAt(QCursor::pos());
- if (enterWidget && enterWidget->data->in_destructor)
- enterWidget = 0;
- QApplicationPrivate::dispatchEnterLeave(enterWidget, qt_mouseover);
- qt_mouseover = enterWidget;
- }
-
+#ifdef QT_MAC_USE_COCOA
+ if ([NSApp isActive] && !qt_button_down && !QWidget::mouseGrabber()){
+ // Update enter/leave immidiatly, don't wait for a move event. But only
+ // if no grab exists (even if the grab points to this widget, it seems, ref X11)
+ QPoint qlocal, qglobal;
+ QWidget *widgetUnderMouse = 0;
+ qt_mac_getTargetForMouseEvent(0, QEvent::Leave, qlocal, qglobal, 0, &widgetUnderMouse);
+ QApplicationPrivate::dispatchEnterLeave(widgetUnderMouse, qt_last_native_mouse_receiver);
+ qt_last_mouse_receiver = widgetUnderMouse;
+ qt_last_native_mouse_receiver = widgetUnderMouse ?
+ (widgetUnderMouse->internalWinId() ? widgetUnderMouse : widgetUnderMouse->nativeParentWidget()) : 0;
+ }
+#endif
+
+ topLevelAt_cache = 0;
qt_event_request_window_change(q);
deactivateWidgetCleanup();
qt_mac_event_release(q);
@@ -3894,12 +3909,14 @@ void QWidgetPrivate::raise_sys()
QWidget *parentWidget = q->parentWidget();
if(parentWidget) {
OSWindowRef parentWindow = qt_mac_window_for(parentWidget);
- if(parentWindow && [parentWindow isOnActiveSpace]) {
- // The window was created in a different space. Therefore if we want
- // to show it in the current space we need to recreate it in the new
- // space.
- recreateMacWindow();
- window = qt_mac_window_for(q);
+ if(parentWindow && [parentWindow respondsToSelector:@selector(isOnActiveSpace)]) {
+ if ([parentWindow performSelector:@selector(isOnActiveSpace)]) {
+ // The window was created in a different space. Therefore if we want
+ // to show it in the current space we need to recreate it in the new
+ // space.
+ recreateMacWindow();
+ window = qt_mac_window_for(q);
+ }
}
}
}
@@ -3916,6 +3933,7 @@ void QWidgetPrivate::raise_sys()
NSView *parentView = [view superview];
[parentView sortSubviewsUsingFunction:compareViews2Raise context:reinterpret_cast<void *>(view)];
}
+ topLevelAt_cache = 0;
#else
if(q->isWindow()) {
//raise this window
@@ -3956,6 +3974,7 @@ void QWidgetPrivate::lower_sys()
NSView *parentView = [view superview];
[parentView sortSubviewsUsingFunction:compareViews2Lower context:reinterpret_cast<void *>(view)];
}
+ topLevelAt_cache = 0;
#else
if(q->isWindow()) {
SendBehind(qt_mac_window_for(q), 0);
@@ -4012,6 +4031,7 @@ void QWidgetPrivate::stackUnder_sys(QWidget *w)
#endif
}
+#ifndef QT_MAC_USE_COCOA
/*
Modifies the bounds for a widgets backing HIView during moves and resizes. Also updates the
widget, either by scrolling its contents or repainting, depending on the WA_StaticContents
@@ -4019,7 +4039,6 @@ void QWidgetPrivate::stackUnder_sys(QWidget *w)
*/
static void qt_mac_update_widget_position(QWidget *q, QRect oldRect, QRect newRect)
{
-#ifndef QT_MAC_USE_COCOA
HIRect bounds = CGRectMake(newRect.x(), newRect.y(),
newRect.width(), newRect.height());
@@ -4111,13 +4130,8 @@ static void qt_mac_update_widget_position(QWidget *q, QRect oldRect, QRect newRe
HIViewSetNeedsDisplayInRect(view, &verticalSlice, true);
const HIRect horizontalSlice = CGRectMake(0, starty, startx, stopy);
HIViewSetNeedsDisplayInRect(view, &horizontalSlice, true);
-#else
- Q_UNUSED(oldRect);
- NSRect bounds = NSMakeRect(newRect.x(), newRect.y(),
- newRect.width(), newRect.height());
- [qt_mac_nativeview_for(q) setFrame:bounds];
-#endif
}
+#endif
/*
Helper function for non-toplevel widgets. Helps to map Qt's 32bit
@@ -4138,7 +4152,15 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
{
Q_Q(QWidget);
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
- Q_UNUSED(oldRect);
+
+ if (!q->internalWinId() && QApplicationPrivate::graphicsSystem() != 0) {
+ // We have no view to move, and no paint engine that
+ // we can update dirty regions on. So just return:
+ return;
+ }
+
+ QMacCocoaAutoReleasePool pool;
+
/*
There are up to four different coordinate systems here:
Qt coordinate system for this widget.
@@ -4146,13 +4168,31 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
Qt coordinate system for parent
X coordinate system for parent (relative to parent's wrect).
*/
+
+ // wrect is the same as crect, except that it is
+ // clipped to fit inside parent (and screen):
QRect wrect;
- //xrect is the X geometry of my X widget. (starts out in parent's Qt coord sys, and ends up in parent's X coord sys)
- QRect xrect = data.crect;
+ // wrectInParentCoordSys will be the same as wrect, except that it is
+ // originated in q's parent rather than q itself. It starts out in
+ // parent's Qt coord system, and ends up in parent's coordinate system:
+ QRect wrectInParentCoordSys = data.crect;
+
+ // If q's parent has been clipped, parentWRect will
+ // be filled with the parents clipped crect:
QRect parentWRect;
+
+ // Embedded have different meaning on each platform, and on
+ // Mac, it means that q is a QMacNativeWidget.
bool isEmbeddedWindow = (q->isWindow() && topData()->embedded);
- if (isEmbeddedWindow) {
+#ifdef QT_MAC_USE_COCOA
+ NSView *nsview = qt_mac_nativeview_for(q);
+#endif
+ if (!isEmbeddedWindow) {
+ parentWRect = q->parentWidget()->data->wrect;
+ } else {
+ // INVARIANT: q's parent view is not owned by Qt. So we need to
+ // do some extra calls to get the clipped rect of the parent view:
#ifndef QT_MAC_USE_COCOA
HIViewRef parentView = HIViewGetSuperview(qt_mac_nativeview_for(q));
#else
@@ -4171,43 +4211,57 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
const QRect wrectRange(-WRECT_MAX,-WRECT_MAX, 2*WRECT_MAX, 2*WRECT_MAX);
parentWRect = wrectRange;
}
- } else {
- parentWRect = q->parentWidget()->data->wrect;
}
if (parentWRect.isValid()) {
- // parent is clipped, and we have to clip to the same limit as parent
- if (!parentWRect.contains(xrect) && !isEmbeddedWindow) {
- xrect &= parentWRect;
- wrect = xrect;
- //translate from parent's to my Qt coord sys
+ // INVARIANT: q's parent has been clipped.
+ // So we fit our own wrects inside it:
+ if (!parentWRect.contains(wrectInParentCoordSys) && !isEmbeddedWindow) {
+ wrectInParentCoordSys &= parentWRect;
+ wrect = wrectInParentCoordSys;
+ // Make sure wrect is originated in q's coordinate system:
wrect.translate(-data.crect.topLeft());
}
- //translate from parent's Qt coords to parent's X coords
- xrect.translate(-parentWRect.topLeft());
-
+ // // Make sure wrectInParentCoordSys originated in q's parent coordinate system:
+ wrectInParentCoordSys.translate(-parentWRect.topLeft());
} else {
- // parent is not clipped, we may or may not have to clip
+ // INVARIANT: we dont know yet the clipping rect of q's parent.
+ // So we may or may not have to adjust our wrects:
if (data.wrect.isValid() && QRect(QPoint(),data.crect.size()).contains(data.wrect)) {
- // This is where the main optimization is: we are already
- // clipped, and if our clip is still valid, we can just
- // move our window, and do not need to move or clip
- // children
+ // This is where the main optimization is: we have an old wrect from an earlier
+ // setGeometry call, and the new crect is smaller than it. If the final wrect is
+ // also inside the old wrect, we can just move q and its children to the new
+ // location without any clipping:
+
+ // vrect will be the part of q that's will be visible inside
+ // q's parent. If it inside the old wrect, then we can just move:
+ QRect vrect = wrectInParentCoordSys & q->parentWidget()->rect();
+ vrect.translate(-data.crect.topLeft());
- QRect vrect = xrect & q->parentWidget()->rect();
- vrect.translate(-data.crect.topLeft()); //the part of me that's visible through parent, in my Qt coords
if (data.wrect.contains(vrect)) {
- xrect = data.wrect;
- xrect.translate(data.crect.topLeft());
+ wrectInParentCoordSys = data.wrect;
+ wrectInParentCoordSys.translate(data.crect.topLeft());
#ifndef QT_MAC_USE_COCOA
- HIRect bounds = CGRectMake(xrect.x(), xrect.y(),
- xrect.width(), xrect.height());
+ HIRect bounds = CGRectMake(wrectInParentCoordSys.x(), wrectInParentCoordSys.y(),
+ wrectInParentCoordSys.width(), wrectInParentCoordSys.height());
HIViewSetFrame(qt_mac_nativeview_for(q), &bounds);
#else
- NSRect bounds = NSMakeRect(xrect.x(), xrect.y(),
- xrect.width(), xrect.height());
- [qt_mac_nativeview_for(q) setFrame:bounds];
+ if (nsview) {
+ // INVARIANT: q is native. Set view frame:
+ NSRect bounds = NSMakeRect(wrectInParentCoordSys.x(), wrectInParentCoordSys.y(),
+ wrectInParentCoordSys.width(), wrectInParentCoordSys.height());
+ [nsview setFrame:bounds];
+ } else {
+ // INVARIANT: q is alien. Repaint wrect instead (includes old and new wrect):
+ QWidget *parent = q->parentWidget();
+ QPoint globalPosWRect = parent->mapToGlobal(data.wrect.topLeft());
+
+ QWidget *nativeParent = q->nativeParentWidget();
+ QRect dirtyWRect = QRect(nativeParent->mapFromGlobal(globalPosWRect), data.wrect.size());
+
+ nativeParent->update(dirtyWRect);
+ }
#endif
if (q->testAttribute(Qt::WA_OutsideWSRange)) {
q->setAttribute(Qt::WA_OutsideWSRange, false);
@@ -4216,7 +4270,8 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
#ifndef QT_MAC_USE_COCOA
HIViewSetVisible(qt_mac_nativeview_for(q), true);
#else
- [qt_mac_nativeview_for(q) setHidden:NO];
+ // If q is Alien, the following call does nothing:
+ [nsview setHidden:NO];
#endif
}
}
@@ -4226,8 +4281,8 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
#ifndef QT_MAC_USE_COCOA
const QRect validRange(-XCOORD_MAX,-XCOORD_MAX, 2*XCOORD_MAX, 2*XCOORD_MAX);
- if (!validRange.contains(xrect)) {
- // we are too big, and must clip
+ if (!validRange.contains(wrectInParentCoordSys)) {
+ // We're too big, and must clip:
QPoint screenOffset(0, 0); // offset of the part being on screen
const QWidget *parentWidget = q->parentWidget();
while (parentWidget && !parentWidget->isWindow()) {
@@ -4239,15 +4294,15 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
2*WRECT_MAX,
2*WRECT_MAX);
- xrect &=cropRect;
- wrect = xrect;
- wrect.translate(-data.crect.topLeft()); // translate wrect in my Qt coordinates
+ wrectInParentCoordSys &=cropRect;
+ wrect = wrectInParentCoordSys;
+ wrect.translate(-data.crect.topLeft());
}
#endif //QT_MAC_USE_COCOA
}
// unmap if we are outside the valid window system coord system
- bool outsideRange = !xrect.isValid();
+ bool outsideRange = !wrectInParentCoordSys.isValid();
bool mapWindow = false;
if (q->testAttribute(Qt::WA_OutsideWSRange) != outsideRange) {
q->setAttribute(Qt::WA_OutsideWSRange, outsideRange);
@@ -4255,7 +4310,8 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
#ifndef QT_MAC_USE_COCOA
HIViewSetVisible(qt_mac_nativeview_for(q), false);
#else
- [qt_mac_nativeview_for(q) setHidden:YES];
+ // If q is Alien, the following call does nothing:
+ [nsview setHidden:YES];
#endif
q->setAttribute(Qt::WA_Mapped, false);
} else if (!q->isHidden()) {
@@ -4266,10 +4322,10 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
if (outsideRange)
return;
+ // Store the new clipped rect:
bool jump = (data.wrect != wrect);
data.wrect = wrect;
-
// and now recursively for all children...
// ### can be optimized
for (int i = 0; i < children.size(); ++i) {
@@ -4281,17 +4337,56 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
}
}
- qt_mac_update_widget_position(q, oldRect, xrect);
-
- if (jump)
+#ifndef QT_MAC_USE_COCOA
+ // Move the actual HIView:
+ qt_mac_update_widget_position(q, oldRect, wrectInParentCoordSys);
+ if (jump)
q->update();
+#else
+ if (nsview) {
+ // INVARIANT: q is native. Move the actual NSView:
+ NSRect bounds = NSMakeRect(
+ wrectInParentCoordSys.x(), wrectInParentCoordSys.y(),
+ wrectInParentCoordSys.width(), wrectInParentCoordSys.height());
+ [nsview setFrame:bounds];
+ if (jump)
+ q->update();
+ } else if (QApplicationPrivate::graphicsSystem() == 0){
+ // INVARIANT: q is alien and we use native paint engine.
+ // Schedule updates where q is moved from and to:
+ const QWidget *parent = q->parentWidget();
+ const QPoint globalPosOldWRect = parent->mapToGlobal(oldRect.topLeft());
+ const QPoint globalPosNewWRect = parent->mapToGlobal(wrectInParentCoordSys.topLeft());
+
+ QWidget *nativeParent = q->nativeParentWidget();
+ const QRegion dirtyOldWRect = QRect(nativeParent->mapFromGlobal(globalPosOldWRect), oldRect.size());
+ const QRegion dirtyNewWRect = QRect(nativeParent->mapFromGlobal(globalPosNewWRect), wrectInParentCoordSys.size());
+
+ const bool sizeUnchanged = oldRect.size() == wrectInParentCoordSys.size();
+ const bool posUnchanged = oldRect.topLeft() == wrectInParentCoordSys.topLeft();
+
+ // Resolve/minimize the region that needs to update:
+ if (sizeUnchanged && q->testAttribute(Qt::WA_OpaquePaintEvent)) {
+ // INVARIANT: q is opaque, and is only moved (not resized). So in theory we only
+ // need to blit pixels, and skip a repaint. But we can only make this work if we
+ // had access to the backbuffer, so we need to update all:
+ nativeParent->update(dirtyOldWRect | dirtyNewWRect);
+ } else if (posUnchanged && q->testAttribute(Qt::WA_StaticContents)) {
+ // We only need to redraw exposed areas:
+ nativeParent->update(dirtyNewWRect - dirtyOldWRect);
+ } else {
+ nativeParent->update(dirtyOldWRect | dirtyNewWRect);
+ }
+ }
+#endif
if (mapWindow && !dontShow) {
q->setAttribute(Qt::WA_Mapped);
#ifndef QT_MAC_USE_COCOA
HIViewSetVisible(qt_mac_nativeview_for(q), true);
#else
- [qt_mac_nativeview_for(q) setHidden:NO];
+ // If q is Alien, the following call does nothing:
+ [nsview setHidden:NO];
#endif
}
}
@@ -4353,7 +4448,6 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
QMacCocoaAutoReleasePool pool;
bool realWindow = isRealWindow();
- BOOL needDisplay = realWindow ? YES : NO;
if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen)){
adjustWithinMaxAndMinSize(w, h);
@@ -4401,7 +4495,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
if (currTopLeft.x() == x && currTopLeft.y() == y
&& cocoaFrameRect.size.width != 0
&& cocoaFrameRect.size.height != 0) {
- [window setFrame:cocoaFrameRect display:needDisplay];
+ [window setFrame:cocoaFrameRect display:realWindow];
} else {
// The window is moved and resized (or resized to zero).
// Since Cocoa usually only sends us a resize callback after
@@ -4410,7 +4504,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
// would have the same origin as the setFrame call) we shift the
// window back and forth inbetween.
cocoaFrameRect.origin.y += 1;
- [window setFrame:cocoaFrameRect display:needDisplay];
+ [window setFrame:cocoaFrameRect display:realWindow];
cocoaFrameRect.origin.y -= 1;
[window setFrameOrigin:cocoaFrameRect.origin];
}
@@ -4418,6 +4512,8 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
} else {
setGeometry_sys_helper(x, y, w, h, isMove);
}
+
+ topLevelAt_cache = 0;
}
void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isMove)
@@ -4468,17 +4564,11 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM
const QRect oldRect(oldp, olds);
if (!isResize && QApplicationPrivate::graphicsSystem())
moveRect(oldRect, x - oldp.x(), y - oldp.y());
+
setWSGeometry(false, oldRect);
- if (isResize && QApplicationPrivate::graphicsSystem()) {
- invalidateBuffer(q->rect());
- if (extra && !graphicsEffect && !extra->mask.isEmpty()) {
- QRegion oldRegion(extra->mask.translated(oldp));
- oldRegion &= oldRect;
- q->parentWidget()->d_func()->invalidateBuffer(oldRegion);
- } else {
- q->parentWidget()->d_func()->invalidateBuffer(effectiveRectFor(oldRect));
- }
- }
+
+ if (isResize && QApplicationPrivate::graphicsSystem())
+ invalidateBuffer_resizeHelper(oldp, olds);
}
if(isMove || isResize) {
@@ -4558,6 +4648,7 @@ void QWidgetPrivate::updateMaximizeButton_sys()
void QWidgetPrivate::scroll_sys(int dx, int dy)
{
if (QApplicationPrivate::graphicsSystem() && !paintOnScreen()) {
+ // INVARIANT: Alien paint engine
scrollChildren(dx, dy);
scrollRect(q_func()->rect(), dx, dy);
} else {
@@ -4565,37 +4656,81 @@ void QWidgetPrivate::scroll_sys(int dx, int dy)
}
}
-void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
+void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &qscrollRect)
{
- Q_Q(QWidget);
+ if (QMacScrollOptimization::delayScroll(this, dx, dy, qscrollRect))
+ return;
+ Q_Q(QWidget);
if (QApplicationPrivate::graphicsSystem() && !paintOnScreen()) {
- scrollRect(r, dx, dy);
+ // INVARIANT: Alien paint engine
+ scrollRect(qscrollRect, dx, dy);
return;
}
- const bool valid_rect = r.isValid();
- if (!q->updatesEnabled() && (valid_rect || q->children().isEmpty()))
- return;
+ static int accelEnv = -1;
+ if (accelEnv == -1) {
+ accelEnv = qgetenv("QT_NO_FAST_SCROLL").toInt() == 0;
+ }
- qt_event_request_window_change(q);
+ // Scroll the whole widget if qscrollRect is not valid:
+ QRect validScrollRect = qscrollRect.isValid() ? qscrollRect : q->rect();
+ validScrollRect &= clipRect();
+
+ // If q is overlapped by other widgets, we cannot just blit pixels since
+ // this will move overlapping widgets as well. In case we just update:
+ const bool overlapped = isOverlapped(validScrollRect.translated(data.crect.topLeft()));
+ const bool accelerateScroll = accelEnv && isOpaque && !overlapped;
+ const bool isAlien = (q->internalWinId() == 0);
+ const QPoint scrollDelta(dx, dy);
+
+ // If qscrollRect is valid, we are _not_ supposed to scroll q's children (as documented).
+ // But we do scroll children (and the whole of q) if qscrollRect is invalid. This case is
+ // documented as undefined, but we exploit it to help factor our code into one function.
+ const bool scrollChildren = !qscrollRect.isValid();
+
+ if (!q->updatesEnabled()) {
+ // We are told not to update anything on q at this point. So unless
+ // we are supposed to scroll children, we bail out early:
+ if (!scrollChildren || q->children().isEmpty())
+ return;
+ }
+
+ if (!accelerateScroll) {
+ if (overlapped) {
+ QRegion region(validScrollRect);
+ subtractOpaqueSiblings(region);
+ update_sys(region);
+ }else {
+ update_sys(qscrollRect);
+ }
+ return;
+ }
#ifdef QT_MAC_USE_COCOA
QMacCocoaAutoReleasePool pool;
+#else
+ Q_UNUSED(isAlien);
+ // We're not sure what the following call is supposed to achive
+ // but until we see what it breaks, we don't bring it into the
+ // Cocoa port:
+ qt_event_request_window_change(q);
#endif
- if(!valid_rect) { // scroll children
- QPoint pd(dx, dy);
- QWidgetList moved;
- QObjectList chldrn = q->children();
- for(int i = 0; i < chldrn.size(); i++) { //first move all children
- QObject *obj = chldrn.at(i);
- if(obj->isWidgetType()) {
- QWidget *w = (QWidget*)obj;
- if(!w->isWindow()) {
- w->data->crect = QRect(w->pos() + pd, w->size());
- if (w->testAttribute(Qt::WA_WState_Created)) {
+ // First move all native children. Alien children will indirectly be
+ // moved when the parent is scrolled. All directly or indirectly moved
+ // children will receive a move event before the function call returns.
+ QWidgetList movedChildren;
+ if (scrollChildren) {
+ QObjectList children = q->children();
+
+ for (int i=0; i<children.size(); i++) {
+ QObject *obj = children.at(i);
+ if (QWidget *w = qobject_cast<QWidget*>(obj)) {
+ if (!w->isWindow()) {
+ w->data->crect = QRect(w->pos() + scrollDelta, w->size());
#ifndef QT_MAC_USE_COCOA
+ if (w->testAttribute(Qt::WA_WState_Created)) {
HIRect bounds = CGRectMake(w->data->crect.x(), w->data->crect.y(),
w->data->crect.width(), w->data->crect.height());
HIViewRef hiview = qt_mac_nativeview_for(w);
@@ -4606,83 +4741,118 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
HIViewSetFrame(hiview, &bounds);
if (opaque)
HIViewSetDrawingEnabled(hiview, true);
+ }
#else
- [qt_mac_nativeview_for(w)
- setFrame:NSMakeRect(w->data->crect.x(), w->data->crect.y(),
- w->data->crect.width(), w->data->crect.height())];
-#endif
+ if (NSView *view = qt_mac_nativeview_for(w)) {
+ // INVARIANT: w is not alien
+ [view setFrame:NSMakeRect(
+ w->data->crect.x(), w->data->crect.y(),
+ w->data->crect.width(), w->data->crect.height())];
}
- moved.append(w);
+#endif
+ movedChildren.append(w);
}
}
}
- //now send move events (do not do this in the above loop, breaks QAquaFocusWidget)
- for(int i = 0; i < moved.size(); i++) {
- QWidget *w = moved.at(i);
- QMoveEvent e(w->pos(), w->pos() - pd);
- QApplication::sendEvent(w, &e);
- }
}
- if (!q->testAttribute(Qt::WA_WState_Created) || !q->isVisible())
- return;
+ if (q->testAttribute(Qt::WA_WState_Created) && q->isVisible()) {
+ // Scroll q itself according to the qscrollRect, and
+ // call update on any exposed areas so that they get redrawn:
- OSViewRef view = qt_mac_nativeview_for(q);
#ifndef QT_MAC_USE_COCOA
- HIRect scrollrect = CGRectMake(r.x(), r.y(), r.width(), r.height());
- OSStatus err = _HIViewScrollRectWithOptions(view, valid_rect ? &scrollrect : 0, dx, dy, kHIViewScrollRectAdjustInvalid);
- if (err) {
- // The only parameter that can go wrong, is the rect.
- qWarning("QWidget::scroll: Your rectangle was too big for the widget, clipping rect");
- scrollrect = CGRectMake(qMax(r.x(), 0), qMax(r.y(), 0),
- qMin(r.width(), q->width()), qMin(r.height(), q->height()));
- _HIViewScrollRectWithOptions(view, valid_rect ? &scrollrect : 0, dx, dy, kHIViewScrollRectAdjustInvalid);
- }
+ OSViewRef view = qt_mac_nativeview_for(q);
+ HIRect scrollrect = CGRectMake(qscrollRect.x(), qscrollRect.y(), qscrollRect.width(), qscrollRect.height());
+ OSStatus err = _HIViewScrollRectWithOptions(view, qscrollRect.isValid() ? &scrollrect : 0, dx, dy, kHIViewScrollRectAdjustInvalid);
+ if (err) {
+ // The only parameter that can go wrong, is the rect.
+ qWarning("QWidget::scroll: Your rectangle was too big for the widget, clipping rect");
+ scrollrect = CGRectMake(qMax(qscrollRect.x(), 0), qMax(qscrollRect.y(), 0),
+ qMin(qscrollRect.width(), q->width()), qMin(qscrollRect.height(), q->height()));
+ _HIViewScrollRectWithOptions(view, qscrollRect.isValid() ? &scrollrect : 0, dx, dy, kHIViewScrollRectAdjustInvalid);
+ }
#else
- NSRect scrollRect = valid_rect ? NSMakeRect(r.x(), r.y(), r.width(), r.height())
- : NSMakeRect(0, 0, q->width(), q->height());
+ QWidget *nativeWidget = isAlien ? q->nativeParentWidget() : q;
+ if (!nativeWidget)
+ return;
+ OSViewRef view = qt_mac_nativeview_for(nativeWidget);
+ if (!view)
+ return;
- // calc the updateRect
- NSRect deltaXRect = { {0, 0}, {0, 0} };
- NSRect deltaYRect = { {0, 0}, {0, 0} };
- if (dy != 0) {
- deltaYRect.size.width = scrollRect.size.width;
- if (dy > 0) {
- deltaYRect.size.height = dy;
- } else {
- deltaYRect.size.height = -dy;
- deltaYRect.origin.y = scrollRect.size.height + dy;
+ // Calculate the rectangles that needs to be redrawn
+ // after the scroll. This will be source rect minus destination rect:
+ QRect deltaXRect;
+ if (dx != 0) {
+ deltaXRect.setY(validScrollRect.y());
+ deltaXRect.setHeight(validScrollRect.height());
+ if (dx > 0) {
+ deltaXRect.setX(validScrollRect.x());
+ deltaXRect.setWidth(dx);
+ } else {
+ deltaXRect.setX(validScrollRect.x() + validScrollRect.width() + dx);
+ deltaXRect.setWidth(-dx);
+ }
}
- }
- if (dx != 0) {
- deltaXRect.size.height = scrollRect.size.height;
- if (dx > 0) {
- deltaXRect.size.width = dx;
- } else {
- deltaXRect.size.width = -dx;
- deltaXRect.origin.x = scrollRect.size.width + dx;
+
+ QRect deltaYRect;
+ if (dy != 0) {
+ deltaYRect.setX(validScrollRect.x());
+ deltaYRect.setWidth(validScrollRect.width());
+ if (dy > 0) {
+ deltaYRect.setY(validScrollRect.y());
+ deltaYRect.setHeight(dy);
+ } else {
+ deltaYRect.setY(validScrollRect.y() + validScrollRect.height() + dy);
+ deltaYRect.setHeight(-dy);
+ }
}
- }
- // ### Scroll the dirty regions as well, the following is not correct.
- QRegion displayRegion = r.isNull() ? dirtyOnWidget : (dirtyOnWidget & r);
- const QVector<QRect> &rects = dirtyOnWidget.rects();
- const QVector<QRect>::const_iterator end = rects.end();
- QVector<QRect>::const_iterator it = rects.begin();
- while (it != end) {
- const QRect rect = *it;
- const NSRect dirtyRect = NSMakeRect(rect.x() + dx, rect.y() + dy,
- rect.width(), rect.height());
- [view setNeedsDisplayInRect:dirtyRect];
- ++it;
- }
+ if (isAlien) {
+ // Adjust the scroll rect to the location as seen from the native parent:
+ QPoint scrollTopLeftInsideNative = nativeWidget->mapFromGlobal(q->mapToGlobal(validScrollRect.topLeft()));
+ validScrollRect.moveTo(scrollTopLeftInsideNative);
+ }
+
+ // Make the pixel copy rect within the validScrollRect bounds:
+ NSRect nsscrollRect = NSMakeRect(
+ validScrollRect.x() + (dx < 0 ? -dx : 0),
+ validScrollRect.y() + (dy < 0 ? -dy : 0),
+ validScrollRect.width() + (dx > 0 ? -dx : 0),
+ validScrollRect.height() + (dy > 0 ? -dy : 0));
+
+ NSSize deltaSize = NSMakeSize(dx, dy);
+ [view scrollRect:nsscrollRect by:deltaSize];
+
+ // Some areas inside the scroll rect might have been marked as dirty from before, which
+ // means that they are scheduled to be redrawn. But as we now scroll, those dirty rects
+ // should also move along to ensure that q receives repaints on the correct places.
+ // Since some of the dirty rects might lay outside, or only intersect with, the scroll
+ // rect, the old calls to setNeedsDisplay still makes sense.
+ // NB: Using [view translateRectsNeedingDisplayInRect:nsscrollRect by:deltaSize] have
+ // so far not been proven fruitful to solve this problem.
+ const QVector<QRect> &dirtyRectsToScroll = dirtyOnWidget.rects();
+ for (int i=0; i<dirtyRectsToScroll.size(); ++i) {
+ QRect qdirtyRect = dirtyRectsToScroll[i];
+ qdirtyRect.translate(dx, dy);
+ update_sys(qdirtyRect);
+ }
+
+ // Update newly exposed areas. This will generate new dirty areas on
+ // q, and therefore, we do it after updating the old dirty rects above:
+ if (dx != 0)
+ update_sys(deltaXRect);
+ if (dy != 0)
+ update_sys(deltaYRect);
- NSSize deltaSize = NSMakeSize(dx, dy);
- [view scrollRect:scrollRect by:deltaSize];
- [view setNeedsDisplayInRect:deltaXRect];
- [view setNeedsDisplayInRect:deltaYRect];
#endif // QT_MAC_USE_COCOA
+ }
+
+ for (int i=0; i<movedChildren.size(); i++) {
+ QWidget *w = movedChildren.at(i);
+ QMoveEvent e(w->pos(), w->pos() - scrollDelta);
+ QApplication::sendEvent(w, &e);
+ }
}
int QWidget::metric(PaintDeviceMetric m) const
@@ -4693,16 +4863,19 @@ int QWidget::metric(PaintDeviceMetric m) const
case PdmWidthMM:
return qRound(metric(PdmWidth) * 25.4 / qreal(metric(PdmDpiX)));
case PdmHeight:
- case PdmWidth: {
+ case PdmWidth:
#ifndef QT_MAC_USE_COCOA
- HIRect rect;
+ { HIRect rect;
HIViewGetFrame(qt_mac_nativeview_for(this), &rect);
-#else
- NSRect rect = [qt_mac_nativeview_for(this) frame];
-#endif
if(m == PdmWidth)
return (int)rect.size.width;
return (int)rect.size.height; }
+#else
+ if (m == PdmWidth)
+ return data->crect.width();
+ else
+ return data->crect.height();
+#endif
case PdmDepth:
return 32;
case PdmNumColors:
@@ -4817,19 +4990,35 @@ void QWidgetPrivate::registerDropSite(bool on)
#endif
}
-void QWidgetPrivate::registerTouchWindow()
+void QWidgetPrivate::registerTouchWindow(bool enable)
{
+ Q_UNUSED(enable);
+#ifdef QT_MAC_USE_COCOA
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_6)
return;
+
Q_Q(QWidget);
- if (!q->testAttribute(Qt::WA_WState_Created))
+ if (enable == touchEventsEnabled)
return;
-#ifndef QT_MAC_USE_COCOA
- // Needs implementation!
-#else
- NSView *view = qt_mac_nativeview_for(q);
- [view setAcceptsTouchEvents:YES];
+
+ QCocoaView *view = static_cast<QCocoaView *>(qt_mac_effectiveview_for(q));
+ if (!view)
+ return;
+
+ if (enable) {
+ ++view->alienTouchCount;
+ if (view->alienTouchCount == 1) {
+ touchEventsEnabled = true;
+ [view setAcceptsTouchEvents:YES];
+ }
+ } else {
+ --view->alienTouchCount;
+ if (view->alienTouchCount == 0) {
+ touchEventsEnabled = false;
+ [view setAcceptsTouchEvents:NO];
+ }
+ }
#endif
#endif
}
@@ -4837,13 +5026,17 @@ void QWidgetPrivate::registerTouchWindow()
void QWidgetPrivate::setMask_sys(const QRegion &region)
{
Q_UNUSED(region);
-#ifndef QT_MAC_USE_COCOA
Q_Q(QWidget);
+
+#ifndef QT_MAC_USE_COCOA
if (q->isWindow())
ReshapeCustomWindow(qt_mac_window_for(q));
else
HIViewReshapeStructure(qt_mac_nativeview_for(q));
#else
+ if (!q->internalWinId())
+ return;
+
if (extra->mask.isEmpty()) {
extra->maskBits = QImage();
finishCocoaMaskSetup();
@@ -4851,6 +5044,7 @@ void QWidgetPrivate::setMask_sys(const QRegion &region)
syncCocoaMask();
}
+ topLevelAt_cache = 0;
#endif
}
@@ -4928,7 +5122,7 @@ void QWidgetPrivate::finishCocoaMaskSetup()
[window setOpaque:(extra->imageMask == 0)];
[window invalidateShadow];
}
- qt_mac_set_needs_display(q, QRegion());
+ macSetNeedsDisplay(QRegion());
}
#endif
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 2e82aa6..1083a1f 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -361,7 +361,8 @@ public:
DrawInvisible = 0x08,
DontSubtractOpaqueChildren = 0x10,
DontSetCompositionMode = 0x20,
- DontDrawOpaqueChildren = 0x40
+ DontDrawOpaqueChildren = 0x40,
+ DontDrawNativeChildren = 0x80
};
enum CloseMode {
@@ -567,6 +568,7 @@ public:
// sub-classes that their internals are about to be released.
virtual void aboutToDestroy() {}
+ QInputContext *assignedInputContext() const;
QInputContext *inputContext() const;
inline QWidget *effectiveFocusWidget() {
QWidget *w = q_func();
@@ -775,6 +777,8 @@ public:
void x11UpdateIsOpaque();
bool isBackgroundInherited() const;
void updateX11AcceptFocus();
+ QPoint mapToGlobal(const QPoint &pos) const;
+ QPoint mapFromGlobal(const QPoint &pos) const;
#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
#ifndef QT_NO_GESTURES
@@ -793,7 +797,6 @@ public:
#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
// This is new stuff
uint needWindowChange : 1;
- uint hasAlienChildren : 1;
// Each wiget keeps a list of all its child and grandchild OpenGL widgets.
// This list is used to update the gl context whenever a parent and a granparent
@@ -824,6 +827,7 @@ public:
void macUpdateIgnoreMouseEvents();
void macUpdateMetalAttribute();
void macUpdateIsOpaque();
+ void macSetNeedsDisplay(QRegion region);
void setEnabled_helper_sys(bool enable);
bool isRealWindow() const;
void adjustWithinMaxAndMinSize(int &w, int &h);
@@ -859,6 +863,7 @@ public:
bool isInUnifiedToolbar;
QWindowSurface *unifiedSurface;
QPoint toolbar_offset;
+ bool touchEventsEnabled;
#endif
void determineWindowClass();
void transferChildren();
@@ -871,7 +876,7 @@ public:
static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
- void registerTouchWindow();
+ void registerTouchWindow(bool enable = true);
#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
void setMaxWindowState_helper();
void setFullScreenSize_helper();
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index cb72800..85164d2 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -63,6 +63,19 @@
// CCoeControl objects until after the CONE event handler has finished running.
Q_DECLARE_METATYPE(WId)
+// Workaround for the fact that S60 SDKs 3.x do not contain the akntoolbar.h
+// header, even though the documentation says that it should be there, and indeed
+// it is present in the library.
+class CAknToolbar : public CAknControl,
+ public MCoeControlObserver,
+ public MCoeControlBackground,
+ public MEikCommandObserver,
+ public MAknFadedComponent
+{
+public:
+ IMPORT_C void SetToolbarVisibility(const TBool visible);
+};
+
QT_BEGIN_NAMESPACE
extern bool qt_nograb();
@@ -488,6 +501,7 @@ void QWidgetPrivate::show_sys()
QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId());
const bool isFullscreen = q->windowState() & Qt::WindowFullScreen;
+ const TBool cbaRequested = q->windowFlags() & Qt::WindowSoftkeysVisibleHint;
#ifdef Q_WS_S60
// Lazily initialize the S60 screen furniture when the first window is shown.
@@ -507,11 +521,25 @@ void QWidgetPrivate::show_sys()
CEikButtonGroupContainer *cba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba,
CEikButtonGroupContainer::EHorizontal,ui,R_AVKON_SOFTKEYS_EMPTY_WITH_IDS);
+ if (isFullscreen && !cbaRequested)
+ cba->MakeVisible(false);
CEikButtonGroupContainer *oldCba = factory->SwapButtonGroup(cba);
Q_ASSERT(!oldCba);
S60->setButtonGroupContainer(cba);
+ // If the creation of the first widget is delayed, for example by doing it
+ // inside the event loop, S60 somehow "forgets" to set the visibility of the
+ // toolbar (the three middle softkeys) when you flip the phone over, so we
+ // need to do it ourselves to avoid a "hole" in the application, even though
+ // Qt itself does not use the toolbar directly..
+ CAknAppUi *appui = dynamic_cast<CAknAppUi *>(CEikonEnv::Static()->AppUi());
+ if (appui) {
+ CAknToolbar *toolbar = appui->PopupToolbar();
+ if (toolbar && !toolbar->IsVisible())
+ toolbar->SetToolbarVisibility(ETrue);
+ }
+
CEikMenuBar *menuBar = new(ELeave) CEikMenuBar;
menuBar->ConstructL(ui, 0, R_AVKON_MENUPANE_EMPTY);
menuBar->SetMenuType(CEikMenuBar::EMenuOptions);
@@ -1160,14 +1188,17 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
}
#ifdef Q_WS_S60
- // Hide window decoration when switching to fullsccreen / minimized otherwise show decoration.
- // The window decoration visibility has to be changed before doing actual window state
- // change since in that order the availableGeometry will return directly the right size and
- // we will avoid unnecessarty redraws
- const bool visible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized));
- const bool statusPaneVisibility = visible;
- const bool buttonGroupVisibility = (visible || (isFullscreen && cbaRequested));
- S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility);
+ bool decorationsVisible(false);
+ if (!parentWidget()) { // Only top level native windows have control over cba/status pane
+ // Hide window decoration when switching to fullscreen / minimized otherwise show decoration.
+ // The window decoration visibility has to be changed before doing actual window state
+ // change since in that order the availableGeometry will return directly the right size and
+ // we will avoid unnecessary redraws
+ decorationsVisible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized));
+ const bool statusPaneVisibility = decorationsVisible;
+ const bool buttonGroupVisibility = (decorationsVisible || (isFullscreen && cbaRequested));
+ S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility);
+ }
#endif // Q_WS_S60
// Ensure the initial size is valid, since we store it as normalGeometry below.
@@ -1191,7 +1222,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
// accurate because it did not consider the status pane. This means that when returning
// normal mode after showing the status pane, the geometry would overlap so we should
// move it if it never had an explicit position.
- if (!wasMoved && S60->statusPane() && visible) {
+ if (!wasMoved && S60->statusPane() && decorationsVisible) {
TPoint tl = static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl;
normalGeometry.setTopLeft(QPoint(tl.iX, tl.iY));
}
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index cf23981..b378b78 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -444,6 +444,7 @@ static QVector<Atom> getNetWmState(QWidget *w)
&& actualType == XA_ATOM && actualFormat == 32) {
returnValue.resize(bytesLeft / 4);
XFree((char*) propertyData);
+ propertyData = 0;
// fetch all data
if (XGetWindowProperty(X11->display, w->internalWinId(), ATOM(_NET_WM_STATE), 0,
@@ -458,7 +459,8 @@ static QVector<Atom> getNetWmState(QWidget *w)
if (!returnValue.isEmpty()) {
memcpy(returnValue.data(), propertyData, returnValue.size() * sizeof(Atom));
}
- XFree((char*) propertyData);
+ if (propertyData)
+ XFree((char*) propertyData);
}
return returnValue;
@@ -1289,39 +1291,49 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
#endif
}
-
-QPoint QWidget::mapToGlobal(const QPoint &pos) const
+QPoint QWidgetPrivate::mapToGlobal(const QPoint &pos) const
{
- Q_D(const QWidget);
- if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
- QPoint p = pos + data->crect.topLeft();
+ Q_Q(const QWidget);
+ if (!q->testAttribute(Qt::WA_WState_Created) || !q->internalWinId()) {
+ QPoint p = pos + q->data->crect.topLeft();
//cannot trust that !isWindow() implies parentWidget() before create
- return (isWindow() || !parentWidget()) ? p : parentWidget()->mapToGlobal(p);
+ return (q->isWindow() || !q->parentWidget()) ? p : q->parentWidget()->d_func()->mapToGlobal(p);
}
- int x, y;
+ int x, y;
Window child;
- QPoint p = d->mapToWS(pos);
- XTranslateCoordinates(X11->display, internalWinId(),
- QApplication::desktop()->screen(d->xinfo.screen())->internalWinId(),
+ QPoint p = mapToWS(pos);
+ XTranslateCoordinates(X11->display, q->internalWinId(),
+ QApplication::desktop()->screen(xinfo.screen())->internalWinId(),
p.x(), p.y(), &x, &y, &child);
return QPoint(x, y);
}
-
-QPoint QWidget::mapFromGlobal(const QPoint &pos) const
+QPoint QWidgetPrivate::mapFromGlobal(const QPoint &pos) const
{
- Q_D(const QWidget);
- if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
+ Q_Q(const QWidget);
+ if (!q->testAttribute(Qt::WA_WState_Created) || !q->internalWinId()) {
//cannot trust that !isWindow() implies parentWidget() before create
- QPoint p = (isWindow() || !parentWidget()) ? pos : parentWidget()->mapFromGlobal(pos);
- return p - data->crect.topLeft();
+ QPoint p = (q->isWindow() || !q->parentWidget()) ? pos : q->parentWidget()->d_func()->mapFromGlobal(pos);
+ return p - q->data->crect.topLeft();
}
- int x, y;
+ int x, y;
Window child;
XTranslateCoordinates(X11->display,
- QApplication::desktop()->screen(d->xinfo.screen())->internalWinId(),
- internalWinId(), pos.x(), pos.y(), &x, &y, &child);
- return d->mapFromWS(QPoint(x, y));
+ QApplication::desktop()->screen(xinfo.screen())->internalWinId(),
+ q->internalWinId(), pos.x(), pos.y(), &x, &y, &child);
+ return mapFromWS(QPoint(x, y));
+}
+
+QPoint QWidget::mapToGlobal(const QPoint &pos) const
+{
+ Q_D(const QWidget);
+ return d->mapToGlobal(pos);
+}
+
+QPoint QWidget::mapFromGlobal(const QPoint &pos) const
+{
+ Q_D(const QWidget);
+ return d->mapFromGlobal(pos);
}
void QWidgetPrivate::updateSystemBackground()
diff --git a/src/gui/kernel/qx11embed_x11.cpp b/src/gui/kernel/qx11embed_x11.cpp
index 47cefe4..49a8194 100644
--- a/src/gui/kernel/qx11embed_x11.cpp
+++ b/src/gui/kernel/qx11embed_x11.cpp
@@ -415,8 +415,9 @@ static Bool functor(Display *display, XEvent *event, XPointer arg)
status = XGetWindowProperty(display, data->id, ATOM(WM_STATE), 0, 2, False, ATOM(WM_STATE),
&ret, &format, &nitems, &after, &retval );
if (status == Success && ret == ATOM(WM_STATE) && format == 32 && nitems > 0) {
- long *state = (long *)retval;
- if (state[0] == WithdrawnState) {
+ long state = *(long *)retval;
+ XFree(retval);
+ if (state == WithdrawnState) {
data->clearedWmState = true;
return true;
}
@@ -833,6 +834,8 @@ bool QX11EmbedWidget::x11Event(XEvent *event)
XUnmapWindow(x11Info().display(), internalWinId());
}
}
+ if (prop_return)
+ XFree(prop_return);
}
}
diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h
index d9aef20..181eda8 100644
--- a/src/gui/math3d/qgenericmatrix.h
+++ b/src/gui/math3d/qgenericmatrix.h
@@ -79,9 +79,9 @@ public:
void copyDataTo(T *values) const;
- T *data() { return m[0]; }
- const T *data() const { return m[0]; }
- const T *constData() const { return m[0]; }
+ T *data() { return *m; }
+ const T *data() const { return *m; }
+ const T *constData() const { return *m; }
#if !defined(Q_NO_TEMPLATE_FRIENDS)
template<int NN, int MM, typename TT>
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index 706450a..ad05116 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -173,8 +173,8 @@ public:
QGenericMatrix<N, M, qreal> toGenericMatrix() const;
inline qreal *data();
- inline const qreal *data() const { return m[0]; }
- inline const qreal *constData() const { return m[0]; }
+ inline const qreal *data() const { return *m; }
+ inline const qreal *constData() const { return *m; }
void optimize();
@@ -974,7 +974,7 @@ inline qreal *QMatrix4x4::data()
// We have to assume that the caller will modify the matrix elements,
// so we flip it over to "General" mode.
flagBits = General;
- return m[0];
+ return *m;
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/painting/qbackingstore_p.h b/src/gui/painting/qbackingstore_p.h
index e2b21c3..47387ab 100644
--- a/src/gui/painting/qbackingstore_p.h
+++ b/src/gui/painting/qbackingstore_p.h
@@ -209,8 +209,9 @@ private:
{
#ifdef Q_WS_QWS
return tlw->frameGeometry();
-#endif
+#else
return tlw->data->crect;
+#endif
}
inline void appendDirtyOnScreenWidget(QWidget *widget)
diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp
index dc90003..10674f8 100644
--- a/src/gui/painting/qblendfunctions.cpp
+++ b/src/gui/painting/qblendfunctions.cpp
@@ -309,7 +309,7 @@ template <typename T> void qt_blend_argb24_on_rgb16(uchar *destPixels, int dbpl,
const uchar *src = srcPixels + y * sbpl;
const uchar *srcEnd = src + srcOffset;
while (src < srcEnd) {
-#if defined(QT_ARCH_ARMV5) || defined(QT_ARCH_POWERPC) || defined(QT_ARCH_SH) || defined(QT_ARCH_AVR32) || (defined(QT_ARCH_WINDOWSCE) && !defined(_X86_)) || (defined(QT_ARCH_SPARC) && defined(Q_CC_GNU))
+#if defined(QT_ARCH_ARMV5) || defined(QT_ARCH_POWERPC) || defined(QT_ARCH_SH) || defined(QT_ARCH_AVR32) || (defined(QT_ARCH_WINDOWSCE) && !defined(_X86_)) || (defined(QT_ARCH_SPARC) && defined(Q_CC_GNU)) || (defined(QT_ARCH_INTEGRITY) && !defined(_X86_))
// non-16-bit aligned memory access is not possible on PowerPC,
// ARM <v6 (QT_ARCH_ARMV5) & SH & AVR32 & SPARC w/GCC
quint16 spix = (quint16(src[2])<<8) + src[1];
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 5741667..811f3ae 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -1217,14 +1217,14 @@ QDataStream &operator>>(QDataStream &s, QBrush &b)
Each of the types is represented by a subclass of QGradient:
\table
- \row
- \o \inlineimage qgradient-linear.png
- \o \inlineimage qgradient-radial.png
- \o \inlineimage qgradient-conical.png
\header
\o QLinearGradient
\o QRadialGradient
\o QConicalGradient
+ \row
+ \o \inlineimage qgradient-linear.png
+ \o \inlineimage qgradient-radial.png
+ \o \inlineimage qgradient-conical.png
\endtable
The colors in a gradient are defined using stop points of the
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index dea3a72..73a6ed8 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -78,12 +78,12 @@ QT_BEGIN_NAMESPACE
names.
\table
+ \header
+ \o RGB \o HSV \o CMYK
\row
\o \inlineimage qcolor-rgb.png
\o \inlineimage qcolor-hsv.png
\o \inlineimage qcolor-cmyk.png
- \header
- \o RGB \o HSV \o CMYK
\endtable
The QColor constructor creates the color based on RGB values. To
@@ -1781,7 +1781,7 @@ QColor QColor::toHsl() const
color.ct.ahsl.lightness = qRound(lightness * USHRT_MAX);
if (qFuzzyIsNull(delta)) {
// achromatic case, hue is undefined
- color.ct.ahsl.hue = 0;
+ color.ct.ahsl.hue = USHRT_MAX;
color.ct.ahsl.saturation = 0;
} else {
// chromatic case
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 9928dea..5904296 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -43,7 +43,9 @@
#include <private/qpaintengine_raster_p.h>
#include <private/qpainter_p.h>
#include <private/qdrawhelper_x86_p.h>
+#ifdef QT_HAVE_ARM_SIMD
#include <private/qdrawhelper_arm_simd_p.h>
+#endif
#include <private/qdrawhelper_neon_p.h>
#include <private/qmath_p.h>
#include <qmath.h>
diff --git a/src/gui/painting/qdrawhelper_arm_simd.cpp b/src/gui/painting/qdrawhelper_arm_simd.cpp
index 806df29..af9854c 100644
--- a/src/gui/painting/qdrawhelper_arm_simd.cpp
+++ b/src/gui/painting/qdrawhelper_arm_simd.cpp
@@ -201,8 +201,8 @@ argb32constalpha_next_pixel
uxtb16 r10, r9
uxtb16 r6, r9, ror #8
- // Negate r11 and extract src alpha
- mvn r9, r11 // bitwise not
+ // Negate r8 and extract src alpha
+ mvn r9, r8 // bitwise not
uxtb r9, r9, ror #24
mla r10, r9, r10, r14
diff --git a/src/gui/painting/qgraphicssystem_runtime.cpp b/src/gui/painting/qgraphicssystem_runtime.cpp
index 0294c4b..5841d40 100644
--- a/src/gui/painting/qgraphicssystem_runtime.cpp
+++ b/src/gui/painting/qgraphicssystem_runtime.cpp
@@ -285,6 +285,7 @@ void QRuntimeWindowSurface::flush(QWidget *widget, const QRegion &region,
void QRuntimeWindowSurface::setGeometry(const QRect &rect)
{
+ QWindowSurface::setGeometry(rect);
m_windowSurface->setGeometry(rect);
}
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 47caa9f..9242fb6 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -662,19 +662,19 @@ QRasterPaintEngineState::QRasterPaintEngineState()
QRasterPaintEngineState::QRasterPaintEngineState(QRasterPaintEngineState &s)
: QPainterState(s)
+ , lastPen(s.lastPen)
+ , penData(s.penData)
, stroker(s.stroker)
+ , strokeFlags(s.strokeFlags)
, lastBrush(s.lastBrush)
, brushData(s.brushData)
- , lastPen(s.lastPen)
- , penData(s.penData)
, fillFlags(s.fillFlags)
- , strokeFlags(s.strokeFlags)
, pixmapFlags(s.pixmapFlags)
, intOpacity(s.intOpacity)
, txscale(s.txscale)
- , flag_bits(s.flag_bits)
, clip(s.clip)
, dirty(s.dirty)
+ , flag_bits(s.flag_bits)
{
brushData.tempImage = 0;
penData.tempImage = 0;
@@ -3716,6 +3716,13 @@ void QRasterPaintEnginePrivate::rasterizeLine_dashed(QLineF line,
const bool squareCap = (pen.capStyle() == Qt::SquareCap);
const QVector<qreal> pattern = pen.dashPattern();
+ qreal patternLength = 0;
+ for (int i = 0; i < pattern.size(); ++i)
+ patternLength += pattern.at(i);
+
+ if (patternLength <= 0)
+ return;
+
qreal length = line.length();
Q_ASSERT(length > 0);
while (length > 0) {
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index a5f4251..2c25e70 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -1126,14 +1126,14 @@ void QPainterPrivate::updateState(QPainterState *newState)
the range of available patterns.
\table
- \row
- \o \inlineimage qpainter-vectordeformation.png
- \o \inlineimage qpainter-gradients.png
- \o \inlineimage qpainter-pathstroking.png
\header
\o \l {demos/deform}{Vector Deformation}
\o \l {demos/gradients}{Gradients}
\o \l {demos/pathstroke}{Path Stroking}
+ \row
+ \o \inlineimage qpainter-vectordeformation.png
+ \o \inlineimage qpainter-gradients.png
+ \o \inlineimage qpainter-pathstroking.png
\endtable
@@ -1206,13 +1206,13 @@ void QPainterPrivate::updateState(QPainterState *newState)
coordinate transformations.
\table
+ \header
+ \o nop \o rotate() \o scale() \o translate()
\row
\o \inlineimage qpainter-clock.png
\o \inlineimage qpainter-rotation.png
\o \inlineimage qpainter-scale.png
\o \inlineimage qpainter-translation.png
- \header
- \o nop \o rotate() \o scale() \o translate()
\endtable
The most commonly used transformations are scaling, rotation,
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index 9f49b2f..8bff021 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -240,12 +240,12 @@ static void qt_debug_path(const QPainterPath &path)
provides two methods for filling paths:
\table
- \row
- \o \inlineimage qt-fillrule-oddeven.png
- \o \inlineimage qt-fillrule-winding.png
\header
\o Qt::OddEvenFill
\o Qt::WindingFill
+ \row
+ \o \inlineimage qt-fillrule-oddeven.png
+ \o \inlineimage qt-fillrule-winding.png
\endtable
See the Qt::FillRule documentation for the definition of the
@@ -315,12 +315,12 @@ static void qt_debug_path(const QPainterPath &path)
QPainterPath to draw text.
\table
- \row
- \o \inlineimage qpainterpath-example.png
- \o \inlineimage qpainterpath-demo.png
\header
\o \l {painting/painterpaths}{Painter Paths Example}
\o \l {demos/deform}{Vector Deformation Demo}
+ \row
+ \o \inlineimage qpainterpath-example.png
+ \o \inlineimage qpainterpath-demo.png
\endtable
\sa QPainterPathStroker, QPainter, QRegion, {Painter Paths Example}
@@ -874,7 +874,7 @@ void QPainterPath::arcTo(const QRectF &rect, qreal startAngle, qreal sweepLength
rect.x(), rect.y(), rect.width(), rect.height(), startAngle, sweepLength);
#endif
- if (!qt_is_finite(rect.x()) && !qt_is_finite(rect.y()) || !qt_is_finite(rect.width()) || !qt_is_finite(rect.height())
+ if ((!qt_is_finite(rect.x()) && !qt_is_finite(rect.y())) || !qt_is_finite(rect.width()) || !qt_is_finite(rect.height())
|| !qt_is_finite(startAngle) || !qt_is_finite(sweepLength)) {
#ifndef QT_NO_DEBUG
qWarning("QPainterPath::arcTo: Adding arc where a parameter is NaN or Inf, ignoring call");
@@ -1279,12 +1279,12 @@ Qt::FillRule QPainterPath::fillRule() const
fillRule. Qt provides two methods for filling paths:
\table
- \row
- \o \inlineimage qt-fillrule-oddeven.png
- \o \inlineimage qt-fillrule-winding.png
\header
\o Qt::OddEvenFill (default)
\o Qt::WindingFill
+ \row
+ \o \inlineimage qt-fillrule-oddeven.png
+ \o \inlineimage qt-fillrule-winding.png
\endtable
\sa fillRule()
@@ -2923,9 +2923,12 @@ QPointF QPainterPath::pointAtPercent(qreal t) const
return QPointF();
}
- if (isEmpty())
+ if (!d_ptr || d_ptr->elements.size() == 0)
return QPointF();
+ if (d_ptr->elements.size() == 1)
+ return d_ptr->elements.at(0);
+
qreal totalLength = length();
qreal curLen = 0;
qreal bezierLen = 0;
diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp
index 80353bc..fca46b4 100644
--- a/src/gui/painting/qstroker.cpp
+++ b/src/gui/painting/qstroker.cpp
@@ -668,26 +668,28 @@ template <class Iterator> bool qt_stroke_side(Iterator *it,
#endif
QLineF line(qt_fixed_to_real(prev.x), qt_fixed_to_real(prev.y),
qt_fixed_to_real(e.x), qt_fixed_to_real(e.y));
- QLineF normal = line.normalVector();
- normal.setLength(offset);
- line.translate(normal.dx(), normal.dy());
-
- // If we are starting a new subpath, move to correct starting point.
- if (first) {
- if (capFirst)
- stroker->joinPoints(prev.x, prev.y, line, stroker->capStyleMode());
- else
- stroker->emitMoveTo(qt_real_to_fixed(line.x1()), qt_real_to_fixed(line.y1()));
- *startTangent = line;
- first = false;
- } else {
- stroker->joinPoints(prev.x, prev.y, line, stroker->joinStyleMode());
- }
+ if (line.p1() != line.p2()) {
+ QLineF normal = line.normalVector();
+ normal.setLength(offset);
+ line.translate(normal.dx(), normal.dy());
+
+ // If we are starting a new subpath, move to correct starting point.
+ if (first) {
+ if (capFirst)
+ stroker->joinPoints(prev.x, prev.y, line, stroker->capStyleMode());
+ else
+ stroker->emitMoveTo(qt_real_to_fixed(line.x1()), qt_real_to_fixed(line.y1()));
+ *startTangent = line;
+ first = false;
+ } else {
+ stroker->joinPoints(prev.x, prev.y, line, stroker->joinStyleMode());
+ }
- // Add the stroke for this line.
- stroker->emitLineTo(qt_real_to_fixed(line.x2()),
- qt_real_to_fixed(line.y2()));
- prev = e;
+ // Add the stroke for this line.
+ stroker->emitLineTo(qt_real_to_fixed(line.x2()),
+ qt_real_to_fixed(line.y2()));
+ prev = e;
+ }
// CurveToElement
} else if (e.isCurveTo()) {
diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp
index d0b9239..419518ac 100644
--- a/src/gui/painting/qwindowsurface_raster.cpp
+++ b/src/gui/painting/qwindowsurface_raster.cpp
@@ -78,6 +78,9 @@ public:
#ifdef Q_WS_X11
GC gc;
+#ifndef QT_NO_MITSHM
+ uint needsSync : 1;
+#endif
#ifndef QT_NO_XRENDER
uint translucentBackground : 1;
#endif
@@ -94,6 +97,9 @@ QRasterWindowSurface::QRasterWindowSurface(QWidget *window, bool setDefaultSurfa
d_ptr->translucentBackground = X11->use_xrender
&& window->x11Info().depth() == 32;
#endif
+#ifndef QT_NO_MITHSM
+ d_ptr->needsSync = false;
+#endif
#endif
d_ptr->image = 0;
d_ptr->inSetGeometry = false;
@@ -116,8 +122,23 @@ QPaintDevice *QRasterWindowSurface::paintDevice()
return &d_ptr->image->image;
}
+#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
+void QRasterWindowSurface::syncX()
+{
+ // delay writing to the backbuffer until we know for sure X is done reading from it
+ if (d_ptr->needsSync) {
+ XSync(X11->display, false);
+ d_ptr->needsSync = false;
+ }
+}
+#endif
+
void QRasterWindowSurface::beginPaint(const QRegion &rgn)
{
+#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
+ syncX();
+#endif
+
#if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_WS_WINCE))
if (!qt_widget_private(window())->isOpaque && window()->testAttribute(Qt::WA_TranslucentBackground)) {
#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
@@ -217,13 +238,13 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
if (d_ptr->image->xshmpm) {
XCopyArea(X11->display, d_ptr->image->xshmpm, widget->handle(), d_ptr->gc,
br.x(), br.y(), br.width(), br.height(), wbr.x(), wbr.y());
- XSync(X11->display, False);
+ d_ptr->needsSync = true;
} else if (d_ptr->image->xshmimg) {
const QImage &src = d->image->image;
br = br.intersected(src.rect());
XShmPutImage(X11->display, widget->handle(), d_ptr->gc, d_ptr->image->xshmimg,
br.x(), br.y(), wbr.x(), wbr.y(), br.width(), br.height(), False);
- XSync(X11->display, False);
+ d_ptr->needsSync = true;
} else
#endif
{
@@ -282,6 +303,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
QDBeginCGContext(port, &context);
#else
+ QMacCocoaAutoReleasePool pool;
extern CGContextRef qt_mac_graphicsContextFor(QWidget *);
CGContextRef context = qt_mac_graphicsContextFor(widget);
#endif
@@ -391,6 +413,10 @@ bool QRasterWindowSurface::scroll(const QRegion &area, int dx, int dy)
if (!d->image || d->image->image.isNull())
return false;
+#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
+ syncX();
+#endif
+
const QVector<QRect> rects = area.rects();
for (int i = 0; i < rects.size(); ++i)
qt_scrollRectInImage(d->image->image, rects.at(i), QPoint(dx, dy));
diff --git a/src/gui/painting/qwindowsurface_raster_p.h b/src/gui/painting/qwindowsurface_raster_p.h
index b6e61e1..903810b 100644
--- a/src/gui/painting/qwindowsurface_raster_p.h
+++ b/src/gui/painting/qwindowsurface_raster_p.h
@@ -107,6 +107,9 @@ public:
bool scroll(const QRegion &area, int dx, int dy);
private:
+#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
+ void syncX();
+#endif
void prepareBuffer(QImage::Format format, QWidget *widget);
Q_DECLARE_PRIVATE(QRasterWindowSurface)
QScopedPointer<QRasterWindowSurfacePrivate> d_ptr;
diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp
index a860818..71556d7 100644
--- a/src/gui/painting/qwindowsurface_s60.cpp
+++ b/src/gui/painting/qwindowsurface_s60.cpp
@@ -61,13 +61,11 @@ struct QS60WindowSurfacePrivate
QList<QImage*> bufferImages;
};
-QS60WindowSurface::QS60WindowSurface(QWidget* widget)
- : QWindowSurface(widget), d_ptr(new QS60WindowSurfacePrivate)
+TDisplayMode displayMode(bool opaque)
{
TDisplayMode mode = S60->screenDevice()->DisplayMode();
- bool isOpaque = qt_widget_private(widget)->isOpaque;
- if (isOpaque) {
+ if (opaque) {
mode = EColor16MU;
} else {
if (QSysInfo::symbianVersion() >= QSysInfo::SV_SF_3)
@@ -75,7 +73,13 @@ QS60WindowSurface::QS60WindowSurface(QWidget* widget)
else
mode = EColor16MA; // Symbian prior to Symbian^3 sw accelerates EColor16MA
}
+ return mode;
+}
+QS60WindowSurface::QS60WindowSurface(QWidget* widget)
+ : QWindowSurface(widget), d_ptr(new QS60WindowSurfacePrivate)
+{
+ TDisplayMode mode = displayMode(qt_widget_private(widget)->isOpaque);
// We create empty CFbsBitmap here -> it will be resized in setGeometry
CFbsBitmap *bitmap = new CFbsBitmap; // CBase derived object needs check on new
Q_CHECK_PTR(bitmap);
@@ -122,6 +126,11 @@ void QS60WindowSurface::beginPaint(const QRegion &rgn)
if (!qt_widget_private(window())->isOpaque) {
QS60PixmapData *pixmapData = static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data());
+
+ TDisplayMode mode = displayMode(false);
+ if (pixmapData->cfbsBitmap->DisplayMode() != mode)
+ pixmapData->convertToDisplayMode(mode);
+
pixmapData->beginDataAccess();
QPainter p(&pixmapData->image);
diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp
index b5b8b81..0c99f80 100644
--- a/src/gui/s60framework/qs60mainappui.cpp
+++ b/src/gui/s60framework/qs60mainappui.cpp
@@ -49,6 +49,7 @@
#include <avkon.rsg>
#endif
#include <barsread.h>
+#include <coeutils.h>
#include <qconfig.h>
#include "qs60mainappui.h"
@@ -401,6 +402,16 @@ void QS60MainAppUi::HandleForegroundEventL(TBool aForeground)
QS60MainAppUiBase::HandleForegroundEventL(aForeground);
}
+/*!
+ \internal
+*/
+TBool QS60MainAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/, TFileName &/*aDocumentName*/, const TDesC8 &/*aTail*/)
+{
+ // bypass CEikAppUi::ProcessCommandParametersL(..) which modifies aDocumentName, preventing apparc document opening from working.
+ // The return value is effectively unused in Qt apps (see QS60MainDocument::OpenFileL)
+ return EFalse;
+}
+
#ifndef Q_WS_S60
void QS60StubAknAppUi::HandleViewDeactivation(const TVwsViewId &, const TVwsViewId &) {}
diff --git a/src/gui/s60framework/qs60mainappui.h b/src/gui/s60framework/qs60mainappui.h
index ce3b5b0..bf118ff 100644
--- a/src/gui/s60framework/qs60mainappui.h
+++ b/src/gui/s60framework/qs60mainappui.h
@@ -131,6 +131,7 @@ public:
virtual void HandleViewDeactivation(const TVwsViewId &aViewIdToBeDeactivated, const TVwsViewId &aNewlyActivatedViewId);
virtual void PrepareToExit();
virtual void HandleTouchPaneSizeChange();
+ virtual TBool ProcessCommandParametersL(TApaCommand aCommand, TFileName &aDocumentName, const TDesC8 &aTail);
protected:
virtual void HandleScreenDeviceChangedL();
diff --git a/src/gui/s60framework/qs60maindocument.cpp b/src/gui/s60framework/qs60maindocument.cpp
index a8886ac..37bd55f 100644
--- a/src/gui/s60framework/qs60maindocument.cpp
+++ b/src/gui/s60framework/qs60maindocument.cpp
@@ -41,6 +41,9 @@
#include "qs60mainappui.h"
#include "qs60maindocument.h"
+#include "qcoreapplication.h"
+#include "qevent.h"
+#include "private/qcore_symbian_p.h"
#include <exception>
@@ -108,9 +111,15 @@ CEikAppUi *QS60MainDocument::CreateAppUiL()
/*!
\internal
*/
-CFileStore *QS60MainDocument::OpenFileL(TBool aDoOpen, const TDesC &aFilename, RFs &aFs)
+CFileStore *QS60MainDocument::OpenFileL(TBool /*aDoOpen*/, const TDesC &aFilename, RFs &/*aFs*/)
{
- return QS60MainDocumentBase::OpenFileL(aDoOpen, aFilename, aFs);
+ QT_TRYCATCH_LEAVING( {
+ QCoreApplication* app = QCoreApplication::instance();
+ QString qname = qt_TDesC2QString(aFilename);
+ QFileOpenEvent* event = new QFileOpenEvent(qname);
+ app->postEvent(app, event);
+ })
+ return 0;
}
/*!
@@ -118,7 +127,12 @@ CFileStore *QS60MainDocument::OpenFileL(TBool aDoOpen, const TDesC &aFilename, R
*/
void QS60MainDocument::OpenFileL(CFileStore *&aFileStore, RFile &aFile)
{
- QS60MainDocumentBase::OpenFileL(aFileStore, aFile);
+ QT_TRYCATCH_LEAVING( {
+ QCoreApplication* app = QCoreApplication::instance();
+ QFileOpenEvent* event = new QFileOpenEvent(aFile);
+ app->postEvent(app, event);
+ aFileStore = 0;
+ })
}
QT_END_NAMESPACE
diff --git a/src/gui/statemachine/qguistatemachine.cpp b/src/gui/statemachine/qguistatemachine.cpp
index eadb8ff..2a0de3c 100644
--- a/src/gui/statemachine/qguistatemachine.cpp
+++ b/src/gui/statemachine/qguistatemachine.cpp
@@ -404,6 +404,7 @@ static QEvent *cloneEvent(QEvent *e)
we2->setButtons(we->buttons());
we2->setModifiers(we->modifiers());
we2->setOrientation(we->orientation());
+ we2->setDelta(we->delta());
return we2;
}
#endif
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index c5e95f2e..ecc2539 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -96,7 +96,8 @@ const layoutHeader QS60StylePrivate::m_layoutHeaders[] = {
{320,240,1,19,"QVGA Portrait"},
{360,640,1,19,"NHD Landscape"},
{640,360,1,19,"NHD Portrait"},
-{352,800,1,12,"E90 Landscape"}
+{352,800,1,12,"E90 Landscape"},
+{480,640,1,19,"VGA Landscape"}
// *** End of generated data ***
};
const int QS60StylePrivate::m_numberOfLayouts =
@@ -108,7 +109,8 @@ const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = {
{5,0,-909,0,0,1,0,2,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,28,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1,106},
{7,0,-909,0,0,2,0,5,-1,25,69,46,37,37,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,44,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,13,3,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135},
{7,0,-909,0,0,2,0,5,-1,25,68,46,37,37,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,52,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,12,3,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135},
-{7,0,-909,0,0,2,0,2,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,30,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1,106}
+{7,0,-909,0,0,2,0,2,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,30,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1,106},
+{9,0,-909,0,0,2,0,5,-1,34,99,76,51,51,25,352,-909,-909,-909,29,25,7,0,0,43,34,42,76,7,7,2,-909,-909,0,9,14,0,23,39,30,30,37,37,9,391,40,0,-909,-909,-909,-909,0,0,29,2,-909,0,0,-909,29,-909,-909,-909,-909,115,37,96,48,96,19,19,9,1,25,-909,9,101,24,9,0,7,7,7,16,7,7,-909,3,-909,-909,-909,-909,9,9,3,1,184}
// *** End of generated data ***
};
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index 04c40aa..605872e 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -1378,12 +1378,13 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size, Skin
QPixmap QS60StylePrivate::backgroundTexture()
{
bool createNewBackground = false;
+ TRect applicationRect = (static_cast<CEikAppUi*>(S60->appUi())->ApplicationRect());
if (!m_background) {
createNewBackground = true;
} else {
//if background brush does not match screensize, re-create it
- if (m_background->width() != S60->screenWidthInPixels ||
- m_background->height() != S60->screenHeightInPixels) {
+ if (m_background->width() != applicationRect.Width() ||
+ m_background->height() != applicationRect.Height()) {
delete m_background;
createNewBackground = true;
}
@@ -1391,7 +1392,7 @@ QPixmap QS60StylePrivate::backgroundTexture()
if (createNewBackground) {
QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen,
- QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), 0, SkinElementFlags());
+ QSize(applicationRect.Width(), applicationRect.Height()), 0, SkinElementFlags());
m_background = new QPixmap(background);
}
return *m_background;
@@ -1411,7 +1412,6 @@ QS60Style::QS60Style()
void QS60StylePrivate::handleDynamicLayoutVariantSwitch()
{
clearCaches(QS60StylePrivate::CC_LayoutChange);
- setBackgroundTexture(qApp);
setActiveLayout();
refreshUI();
foreach (QWidget *widget, QApplication::allWidgets())
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 4b591e2..ecf924c 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -4238,7 +4238,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
return;
case PE_Widget:
- if (!rule.hasDrawable()) {
+ if (w && !rule.hasDrawable()) {
QWidget *container = containerWidget(w);
if (styleSheetCaches->autoFillDisabledWidgets.contains(container)
&& (container == w || !renderRule(container, opt).hasBackground())) {
diff --git a/src/gui/styles/qstylesheetstyle_default.cpp b/src/gui/styles/qstylesheetstyle_default.cpp
index 002dcff..76ffac8 100644
--- a/src/gui/styles/qstylesheetstyle_default.cpp
+++ b/src/gui/styles/qstylesheetstyle_default.cpp
@@ -151,7 +151,7 @@ StyleSheet QStyleSheetStyle::getDefaultStyleSheet() const
BasicSelector bSelector;
Selector selector;
Declaration decl;
- Value value;
+ QCss::Value value;
Pseudo pseudo;
AttributeSelector attr;
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 54ca7cc..052dc72 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -649,7 +649,7 @@ bool ValueExtractor::extractOutline(int *borders, QBrush *colors, BorderStyle *s
return hit;
}
-static Qt::Alignment parseAlignment(const Value *values, int count)
+static Qt::Alignment parseAlignment(const QCss::Value *values, int count)
{
Qt::Alignment a[2] = { 0, 0 };
for (int i = 0; i < qMin(2, count); i++) {
@@ -672,7 +672,7 @@ static Qt::Alignment parseAlignment(const Value *values, int count)
return a[0] | a[1];
}
-static ColorData parseColorValue(Value v)
+static ColorData parseColorValue(QCss::Value v)
{
if (v.type == Value::Identifier || v.type == Value::String) {
v.variant.convert(QVariant::Color);
@@ -706,7 +706,7 @@ static ColorData parseColorValue(Value v)
if (!p.testExpr())
return ColorData();
- QVector<Value> colorDigits;
+ QVector<QCss::Value> colorDigits;
if (!p.parseExpr(&colorDigits))
return ColorData();
@@ -738,7 +738,7 @@ static QColor colorFromData(const ColorData& c, const QPalette &pal)
return QColor();
}
-static BrushData parseBrushValue(const Value &v, const QPalette &pal)
+static BrushData parseBrushValue(const QCss::Value &v, const QPalette &pal)
{
ColorData c = parseColorValue(v);
if (c.type == ColorData::Color) {
@@ -780,7 +780,7 @@ static BrushData parseBrushValue(const Value &v, const QPalette &pal)
return BrushData();
parser.skipSpace();
if (attr.compare(QLatin1String("stop"), Qt::CaseInsensitive) == 0) {
- Value stop, color;
+ QCss::Value stop, color;
parser.next();
if (!parser.parseTerm(&stop)) return BrushData();
parser.skipSpace();
@@ -792,7 +792,7 @@ static BrushData parseBrushValue(const Value &v, const QPalette &pal)
stops.append(QGradientStop(stop.variant.toReal(), colorFromData(cd, pal)));
} else {
parser.next();
- Value value;
+ QCss::Value value;
(void)parser.parseTerm(&value);
if (attr.compare(QLatin1String("spread"), Qt::CaseInsensitive) == 0) {
spread = spreads.indexOf(value.variant.toString());
@@ -856,7 +856,7 @@ static QBrush brushFromData(const BrushData& c, const QPalette &pal)
}
}
-static BorderStyle parseStyleValue(Value v)
+static BorderStyle parseStyleValue(QCss::Value v)
{
if (v.type == Value::KnownIdentifier) {
switch (v.variant.toInt()) {
@@ -941,7 +941,7 @@ void ValueExtractor::borderValue(const Declaration &decl, int *width, QCss::Bord
decl.d->parsed = QVariant::fromValue<BorderData>(data);
}
-static void parseShorthandBackgroundProperty(const QVector<Value> &values, BrushData *brush, QString *image, Repeat *repeat, Qt::Alignment *alignment, const QPalette &pal)
+static void parseShorthandBackgroundProperty(const QVector<QCss::Value> &values, BrushData *brush, QString *image, Repeat *repeat, Qt::Alignment *alignment, const QPalette &pal)
{
*brush = BrushData();
*image = QString();
@@ -949,7 +949,7 @@ static void parseShorthandBackgroundProperty(const QVector<Value> &values, Brush
*alignment = Qt::AlignTop | Qt::AlignLeft;
for (int i = 0; i < values.count(); ++i) {
- const Value &v = values.at(i);
+ const QCss::Value &v = values.at(i);
if (v.type == Value::Uri) {
*image = v.variant.toString();
continue;
@@ -996,7 +996,7 @@ bool ValueExtractor::extractBackground(QBrush *brush, QString *image, Repeat *re
const Declaration &decl = declarations.at(i);
if (decl.d->values.isEmpty())
continue;
- const Value &val = decl.d->values.at(0);
+ const QCss::Value &val = decl.d->values.at(0);
switch (decl.d->propertyId) {
case BackgroundColor:
*brush = decl.brushValue();
@@ -1050,7 +1050,7 @@ bool ValueExtractor::extractBackground(QBrush *brush, QString *image, Repeat *re
return hit;
}
-static bool setFontSizeFromValue(Value value, QFont *font, int *fontSizeAdjustment)
+static bool setFontSizeFromValue(QCss::Value value, QFont *font, int *fontSizeAdjustment)
{
if (value.type == Value::KnownIdentifier) {
bool valid = true;
@@ -1087,7 +1087,7 @@ static bool setFontSizeFromValue(Value value, QFont *font, int *fontSizeAdjustme
return valid;
}
-static bool setFontStyleFromValue(const Value &value, QFont *font)
+static bool setFontStyleFromValue(const QCss::Value &value, QFont *font)
{
if (value.type != Value::KnownIdentifier)
return false ;
@@ -1100,7 +1100,7 @@ static bool setFontStyleFromValue(const Value &value, QFont *font)
return false;
}
-static bool setFontWeightFromValue(const Value &value, QFont *font)
+static bool setFontWeightFromValue(const QCss::Value &value, QFont *font)
{
if (value.type == Value::KnownIdentifier) {
switch (value.variant.toInt()) {
@@ -1121,12 +1121,12 @@ static bool setFontWeightFromValue(const Value &value, QFont *font)
* and set it the \a font
* \returns true if a family was extracted.
*/
-static bool setFontFamilyFromValues(const QVector<Value> &values, QFont *font, int start = 0)
+static bool setFontFamilyFromValues(const QVector<QCss::Value> &values, QFont *font, int start = 0)
{
QString family;
bool shouldAddSpace = false;
for (int i = start; i < values.count(); ++i) {
- const Value &v = values.at(i);
+ const QCss::Value &v = values.at(i);
if (v.type == Value::TermOperatorComma) {
family += QLatin1Char(',');
shouldAddSpace = false;
@@ -1146,7 +1146,7 @@ static bool setFontFamilyFromValues(const QVector<Value> &values, QFont *font, i
return true;
}
-static void setTextDecorationFromValues(const QVector<Value> &values, QFont *font)
+static void setTextDecorationFromValues(const QVector<QCss::Value> &values, QFont *font)
{
for (int i = 0; i < values.count(); ++i) {
if (values.at(i).type != Value::KnownIdentifier)
@@ -1165,7 +1165,7 @@ static void setTextDecorationFromValues(const QVector<Value> &values, QFont *fon
}
}
-static void parseShorthandFontProperty(const QVector<Value> &values, QFont *font, int *fontSizeAdjustment)
+static void parseShorthandFontProperty(const QVector<QCss::Value> &values, QFont *font, int *fontSizeAdjustment)
{
font->setStyle(QFont::StyleNormal);
font->setWeight(QFont::Normal);
@@ -1190,7 +1190,7 @@ static void parseShorthandFontProperty(const QVector<Value> &values, QFont *font
}
}
-static void setFontVariantFromValue(const Value &value, QFont *font)
+static void setFontVariantFromValue(const QCss::Value &value, QFont *font)
{
if (value.type == Value::KnownIdentifier) {
switch (value.variant.toInt()) {
@@ -1201,7 +1201,7 @@ static void setFontVariantFromValue(const Value &value, QFont *font)
}
}
-static void setTextTransformFromValue(const Value &value, QFont *font)
+static void setTextTransformFromValue(const QCss::Value &value, QFont *font)
{
if (value.type == Value::KnownIdentifier) {
switch (value.variant.toInt()) {
@@ -1226,7 +1226,7 @@ bool ValueExtractor::extractFont(QFont *font, int *fontSizeAdjustment)
const Declaration &decl = declarations.at(i);
if (decl.d->values.isEmpty())
continue;
- const Value &val = decl.d->values.at(0);
+ const QCss::Value &val = decl.d->values.at(0);
switch (decl.d->propertyId) {
case FontSize: setFontSizeFromValue(val, font, fontSizeAdjustment); break;
case FontStyle: setFontStyleFromValue(val, font); break;
@@ -1411,7 +1411,7 @@ bool Declaration::realValue(qreal *real, const char *unit) const
return ok;
}
-static bool intValueHelper(const Value &v, int *i, const char *unit)
+static bool intValueHelper(const QCss::Value &v, int *i, const char *unit)
{
if (unit && v.type != Value::Length)
return false;
@@ -1460,7 +1460,7 @@ QRect Declaration::rectValue() const
if (d->parsed.isValid())
return qvariant_cast<QRect>(d->parsed);
- const Value &v = d->values.at(0);
+ const QCss::Value &v = d->values.at(0);
if (v.type != Value::Function)
return QRect();
QStringList func = v.variant.toStringList();
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index 79c46b3..86bafc9 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -71,6 +71,9 @@
#if defined(Q_OS_VXWORKS) && defined(NONE)
# undef NONE
#endif
+#if defined(Q_OS_INTEGRITY)
+# undef Value
+#endif
QT_BEGIN_NAMESPACE
diff --git a/src/gui/text/qfont_s60.cpp b/src/gui/text/qfont_s60.cpp
index c7d36ef..114191d 100644
--- a/src/gui/text/qfont_s60.cpp
+++ b/src/gui/text/qfont_s60.cpp
@@ -49,13 +49,14 @@ QT_BEGIN_NAMESPACE
#ifdef QT_NO_FREETYPE
Q_GLOBAL_STATIC(QMutex, lastResortFamilyMutex);
+#endif // QT_NO_FREETYPE
+
extern QStringList qt_symbian_fontFamiliesOnFontServer(); // qfontdatabase_s60.cpp
Q_GLOBAL_STATIC_WITH_INITIALIZER(QStringList, fontFamiliesOnFontServer, {
// We are only interested in the initial font families. No Application fonts.
// Therefore, we are allowed to cache the list.
x->append(qt_symbian_fontFamiliesOnFontServer());
});
-#endif // QT_NO_FREETYPE
QString QFont::lastResortFont() const
{
@@ -95,7 +96,20 @@ QString QFont::lastResortFamily() const
const bool isJapaneseOrChineseSystem =
User::Language() == ELangJapanese || User::Language() == ELangPrcChinese;
- return QLatin1String(isJapaneseOrChineseSystem?"Heisei Kaku Gothic S60":"Series 60 Sans");
+ static QString family;
+ if (family.isEmpty()) {
+ QStringList families = qt_symbian_fontFamiliesOnFontServer();
+ const char* const preferredFamilies[] = {"Nokia Sans S60", "Series 60 Sans"};
+ for (int i = 0; i < sizeof preferredFamilies / sizeof preferredFamilies[0]; ++i) {
+ const QString preferredFamily = QLatin1String(preferredFamilies[i]);
+ if (families.contains(preferredFamily)) {
+ family = preferredFamily;
+ break;
+ }
+ }
+ }
+
+ return QLatin1String(isJapaneseOrChineseSystem?"Heisei Kaku Gothic S60":family.toLatin1());
#endif // QT_NO_FREETYPE
}
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 20c72dd..8e92b1a 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -646,6 +646,10 @@ public:
{ }
~QFontDatabasePrivate() {
free();
+#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
+ if (symbianExtras)
+ delete symbianExtras;
+#endif
}
QtFontFamily *family(const QString &f, bool = false);
void free() {
@@ -654,12 +658,6 @@ public:
::free(families);
families = 0;
count = 0;
-#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
- if (symbianExtras) {
- delete symbianExtras;
- symbianExtras = 0;
- }
-#endif
// don't clear the memory fonts!
}
@@ -678,6 +676,10 @@ public:
QVector<FONTSIGNATURE> signatures;
#elif defined(Q_WS_MAC)
ATSFontContainerRef handle;
+#elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
+ QString temporaryFileName;
+ TInt screenDeviceFontFileId;
+ TUid fontStoreFontFileUid;
#endif
QStringList families;
};
@@ -704,7 +706,7 @@ public:
#if defined(Q_WS_QWS)
QDataStream *stream;
#elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
- const QSymbianFontDatabaseExtras *symbianExtras;
+ QSymbianFontDatabaseExtras *symbianExtras;
#endif
#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
QStringList fallbackFamilies;
@@ -2573,6 +2575,8 @@ bool QFontDatabasePrivate::isApplicationFont(const QString &fileName)
\note Adding application fonts on Unix/X11 platforms without fontconfig is
currently not supported.
+ \note On Symbian, the font family names get truncated to a length of 20 characters.
+
\sa addApplicationFontFromData(), applicationFontFamilies(), removeApplicationFont()
*/
int QFontDatabase::addApplicationFont(const QString &fileName)
@@ -2603,6 +2607,8 @@ int QFontDatabase::addApplicationFont(const QString &fileName)
\bold{Note:} Adding application fonts on Unix/X11 platforms without fontconfig is
currently not supported.
+ \note On Symbian, the font family names get truncated to a length of 20 characters.
+
\sa addApplicationFont(), applicationFontFamilies(), removeApplicationFont()
*/
int QFontDatabase::addApplicationFontFromData(const QByteArray &fontData)
diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp
index 6ba035e..6d3970e 100644
--- a/src/gui/text/qfontdatabase_s60.cpp
+++ b/src/gui/text/qfontdatabase_s60.cpp
@@ -45,6 +45,8 @@
#include "qfontengine_s60_p.h"
#include "qabstractfileengine.h"
#include "qdesktopservices.h"
+#include "qtemporaryfile.h"
+#include "qtextcodec.h"
#include <private/qpixmap_s60_p.h>
#include <private/qt_s60_p.h>
#include "qendian.h"
@@ -114,7 +116,14 @@ public:
~QSymbianFontDatabaseExtrasImplementation();
const QSymbianTypeFaceExtras *extras(const QString &typeface, bool bold, bool italic) const;
- void addFontFileToFontStore(const QFileInfo &fontFileInfo);
+ void removeAppFontData(QFontDatabasePrivate::ApplicationFont *fnt);
+ static inline bool appFontLimitReached();
+ TUid addFontFileToFontStore(const QFileInfo &fontFileInfo);
+ static void clear();
+
+ static inline QString tempAppFontFolder();
+ static const QString appFontMarkerPrefix;
+ static QString appFontMarker(); // 'qaf<shortUid[+shortPid]>'
struct CFontFromFontStoreReleaser {
static inline void cleanup(CFont *font)
@@ -144,8 +153,75 @@ public:
mutable QList<const QSymbianTypeFaceExtras *> m_extras;
mutable QHash<QString, const QSymbianTypeFaceExtras *> m_extrasHash;
+ mutable QSet<QString> m_applicationFontFamilies;
};
+const QString QSymbianFontDatabaseExtrasImplementation::appFontMarkerPrefix =
+ QLatin1String("Q");
+
+inline QString QSymbianFontDatabaseExtrasImplementation::tempAppFontFolder()
+{
+ return QDir::toNativeSeparators(QDir::tempPath()) + QLatin1Char('\\');
+}
+
+QString QSymbianFontDatabaseExtrasImplementation::appFontMarker()
+{
+ static QString result;
+ if (result.isEmpty()) {
+ quint16 id = 0;
+ if (QSymbianTypeFaceExtras::symbianFontTableApiAvailable()) {
+ // We are allowed to load app fonts even from previous, crashed runs
+ // of this application, since we can access the font tables.
+ const quint32 uid = RProcess().Type().MostDerived().iUid;
+ id = static_cast<quint16>(uid + (uid >> 16));
+ } else {
+ // If no font table Api is available, we must not even load a font
+ // from a previous (crashed) run of this application. Reason: we
+ // won't get the font tables, they are not in the CFontStore.
+ // So, we use the pid, for more uniqueness.
+ id = static_cast<quint16>(RProcess().Id().Id());
+ }
+ result = appFontMarkerPrefix + QString::fromLatin1("%1").arg(id & 0x7fff, 3, 32, QLatin1Char('0'));
+ Q_ASSERT(appFontMarkerPrefix.length() == 1 && result.length() == 4);
+ }
+ return result;
+}
+
+static inline bool qt_symbian_fontNameHasAppFontMarker(const QString &fontName)
+{
+ const int idLength = 3; // Keep in sync with id length in appFontMarker().
+ const QString &prefix = QSymbianFontDatabaseExtrasImplementation::appFontMarkerPrefix;
+ if (fontName.length() < prefix.length() + idLength
+ || fontName.mid(fontName.length() - idLength - prefix.length(), prefix.length()) != prefix)
+ return false;
+ // Testing if the the id is base32 data
+ for (int i = fontName.length() - idLength; i < fontName.length(); ++i) {
+ const QChar &c = fontName.at(i);
+ if (!(c >= QLatin1Char('0') && c <= QLatin1Char('9')
+ || c >= QLatin1Char('a') && c <= QLatin1Char('v')))
+ return false;
+ }
+ return true;
+}
+
+// If fontName is an application font of this app, prepend the app font marker
+QString qt_symbian_fontNameWithAppFontMarker(const QString &fontName)
+{
+ QFontDatabasePrivate *db = privateDb();
+ Q_ASSERT(db);
+ const QSymbianFontDatabaseExtrasImplementation *dbExtras =
+ static_cast<const QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras);
+ return dbExtras->m_applicationFontFamilies.contains(fontName) ?
+ fontName + QSymbianFontDatabaseExtrasImplementation::appFontMarker()
+ : fontName;
+}
+
+static inline QString qt_symbian_appFontNameWithoutMarker(const QString &markedFontName)
+{
+ return markedFontName.left(markedFontName.length()
+ - QSymbianFontDatabaseExtrasImplementation::appFontMarker().length());
+}
+
QSymbianFontDatabaseExtrasImplementation::QSymbianFontDatabaseExtrasImplementation()
{
if (!QSymbianTypeFaceExtras::symbianFontTableApiAvailable()) {
@@ -170,10 +246,13 @@ QSymbianFontDatabaseExtrasImplementation::QSymbianFontDatabaseExtrasImplementati
}
}
-void qt_cleanup_symbianFontDatabaseExtras()
+void QSymbianFontDatabaseExtrasImplementation::clear()
{
+ QFontDatabasePrivate *db = privateDb();
+ if (!db)
+ return;
const QSymbianFontDatabaseExtrasImplementation *dbExtras =
- static_cast<const QSymbianFontDatabaseExtrasImplementation*>(privateDb()->symbianExtras);
+ static_cast<const QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras);
if (!dbExtras)
return; // initializeDb() has never been called
if (QSymbianTypeFaceExtras::symbianFontTableApiAvailable()) {
@@ -189,9 +268,32 @@ void qt_cleanup_symbianFontDatabaseExtras()
dbExtras->m_extrasHash.clear();
}
+void qt_cleanup_symbianFontDatabase()
+{
+ QFontDatabasePrivate *db = privateDb();
+ if (!db)
+ return;
+
+ QSymbianFontDatabaseExtrasImplementation::clear();
+
+ if (!db->applicationFonts.isEmpty()) {
+ QFontDatabase::removeAllApplicationFonts();
+ // We remove the left over temporary font files of Qt application.
+ // Active fonts are undeletable since the font server holds a handle
+ // on them, so we do not need to worry to delete other running
+ // applications' fonts.
+ const QDir dir(QSymbianFontDatabaseExtrasImplementation::tempAppFontFolder());
+ const QStringList filter(
+ QSymbianFontDatabaseExtrasImplementation::appFontMarkerPrefix + QLatin1String("*.ttf"));
+ foreach (const QFileInfo &ttfFile, dir.entryInfoList(filter))
+ QFile(ttfFile.absoluteFilePath()).remove();
+ db->applicationFonts.clear();
+ }
+}
+
QSymbianFontDatabaseExtrasImplementation::~QSymbianFontDatabaseExtrasImplementation()
{
- qt_cleanup_symbianFontDatabaseExtras();
+ qt_cleanup_symbianFontDatabase();
if (!QSymbianTypeFaceExtras::symbianFontTableApiAvailable()) {
delete m_store;
m_heap->Close();
@@ -215,9 +317,10 @@ COpenFont* OpenFontFromBitmapFont(const CBitmapFont* aBitmapFont)
}
#endif // FNTSTORE_H_INLINES_SUPPORT_FMM
-const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(const QString &typeface,
+const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(const QString &aTypeface,
bool bold, bool italic) const
{
+ const QString typeface = qt_symbian_fontNameWithAppFontMarker(aTypeface);
const QString searchKey = typeface + QString::number(int(bold)) + QString::number(int(italic));
if (!m_extrasHash.contains(searchKey)) {
TFontSpec searchSpec(qt_QString2TPtrC(typeface), 1);
@@ -263,12 +366,42 @@ const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(c
return m_extrasHash.value(searchKey);
}
-void QSymbianFontDatabaseExtrasImplementation::addFontFileToFontStore(const QFileInfo &fontFileInfo)
+void QSymbianFontDatabaseExtrasImplementation::removeAppFontData(
+ QFontDatabasePrivate::ApplicationFont *fnt)
+{
+ clear();
+ if (!QSymbianTypeFaceExtras::symbianFontTableApiAvailable()
+ && fnt->fontStoreFontFileUid.iUid != 0)
+ m_store->RemoveFile(fnt->fontStoreFontFileUid);
+ if (!fnt->families.isEmpty())
+ m_applicationFontFamilies.remove(fnt->families.first());
+ if (fnt->screenDeviceFontFileId != 0)
+ S60->screenDevice()->RemoveFile(fnt->screenDeviceFontFileId);
+ QFile::remove(fnt->temporaryFileName);
+ *fnt = QFontDatabasePrivate::ApplicationFont();
+}
+
+bool QSymbianFontDatabaseExtrasImplementation::appFontLimitReached()
+{
+ QFontDatabasePrivate *db = privateDb();
+ if (!db)
+ return false;
+ const int maxAppFonts = 5;
+ int registeredAppFonts = 0;
+ foreach (const QFontDatabasePrivate::ApplicationFont &appFont, db->applicationFonts)
+ if (!appFont.families.isEmpty() && ++registeredAppFonts == maxAppFonts)
+ return true;
+ return false;
+}
+
+TUid QSymbianFontDatabaseExtrasImplementation::addFontFileToFontStore(const QFileInfo &fontFileInfo)
{
Q_ASSERT(!QSymbianTypeFaceExtras::symbianFontTableApiAvailable());
const QString fontFile = QDir::toNativeSeparators(fontFileInfo.absoluteFilePath());
- TPtrC fontFilePtr(qt_QString2TPtrC(fontFile));
- QT_TRAP_THROWING(m_store->AddFileL(fontFilePtr));
+ const TPtrC fontFilePtr(qt_QString2TPtrC(fontFile));
+ TUid fontUid = {0};
+ TRAP_IGNORE(fontUid = m_store->AddFileL(fontFilePtr));
+ return fontUid;
}
#else // QT_NO_FREETYPE
@@ -331,11 +464,24 @@ void QFontEngineMultiS60::loadEngine(int at)
Q_ASSERT(engines[at]);
}
-static bool addFontToScreenDevice(int screenDeviceFontIndex,
- const QSymbianFontDatabaseExtrasImplementation *dbExtras)
-{
+#ifdef QT_NO_FREETYPE
+static bool registerScreenDeviceFont(int screenDeviceFontIndex,
+ const QSymbianFontDatabaseExtrasImplementation *dbExtras)
+{
TTypefaceSupport typefaceSupport;
S60->screenDevice()->TypefaceSupport(typefaceSupport, screenDeviceFontIndex);
+
+ QString familyName((const QChar*)typefaceSupport.iTypeface.iName.Ptr(), typefaceSupport.iTypeface.iName.Length());
+ if (qt_symbian_fontNameHasAppFontMarker(familyName)) {
+ const QString &marker = QSymbianFontDatabaseExtrasImplementation::appFontMarker();
+ if (familyName.endsWith(marker)) {
+ familyName = qt_symbian_appFontNameWithoutMarker(familyName);
+ dbExtras->m_applicationFontFamilies.insert(familyName);
+ } else {
+ return false; // This was somebody else's application font. Skip it.
+ }
+ }
+
CFont *font; // We have to get a font instance in order to know all the details
TFontSpec fontSpec(typefaceSupport.iTypeface.iName, 11);
if (S60->screenDevice()->GetNearestFontInPixels(font, fontSpec) != KErrNone)
@@ -351,7 +497,6 @@ static bool addFontToScreenDevice(int screenDeviceFontIndex,
styleKey.style = faceAttrib.IsItalic()?QFont::StyleItalic:QFont::StyleNormal;
styleKey.weight = faceAttrib.IsBold()?QFont::Bold:QFont::Normal;
- QString familyName((const QChar *)typefaceSupport.iTypeface.iName.Ptr(), typefaceSupport.iTypeface.iName.Length());
QtFontFamily *family = privateDb()->family(familyName, true);
family->fixedPitch = faceAttrib.IsMonoWidth();
QtFontFoundry *foundry = family->foundry(QString(), true);
@@ -381,6 +526,7 @@ static bool addFontToScreenDevice(int screenDeviceFontIndex,
family->writingSystems[system] = QtFontFamily::Supported;
return true;
}
+#endif
static void initializeDb()
{
@@ -398,7 +544,12 @@ static void initializeDb()
const QSymbianFontDatabaseExtrasImplementation *dbExtras =
static_cast<const QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras);
for (int i = 0; i < numTypeFaces; i++)
- addFontToScreenDevice(i, dbExtras);
+ registerScreenDeviceFont(i, dbExtras);
+
+ // We have to clear/release all CFonts, here, in case one of the fonts is
+ // an application font of another running Qt app. Otherwise the other Qt app
+ // cannot remove it's application font, anymore -> "Zombie Font".
+ QSymbianFontDatabaseExtrasImplementation::clear();
lock.relock();
@@ -421,20 +572,386 @@ static inline void load(const QString &family = QString(), int script = -1)
initializeDb();
}
+struct OffsetTable {
+ quint32 sfntVersion;
+ quint16 numTables, searchRange, entrySelector, rangeShift;
+};
+
+struct TableRecord {
+ quint32 tag, checkSum, offset, length;
+};
+
+struct NameTableHead {
+ quint16 format, count, stringOffset;
+};
+
+struct NameRecord {
+ quint16 platformID, encodingID, languageID, nameID, length, offset;
+};
+
+static quint32 ttfCalcChecksum(const char *data, quint32 bytesCount)
+{
+ quint32 result = 0;
+ const quint32 *ptr = reinterpret_cast<const quint32*>(data);
+ const quint32 *endPtr =
+ ptr + (bytesCount + sizeof(quint32) - 1) / sizeof(quint32);
+ while (ptr < endPtr) {
+ const quint32 unit32Value = *ptr++;
+ result += qFromBigEndian(unit32Value);
+ }
+ return result;
+}
+
+static inline quint32 toDWordBoundary(quint32 value)
+{
+ return (value + 3) & ~3;
+}
+
+static inline quint32 dWordPadding(quint32 value)
+{
+ return (4 - (value & 3)) & 3;
+}
+
+static inline bool ttfMarkNameTable(QByteArray &table, const QString &marker)
+{
+ const quint32 tableLength = static_cast<quint32>(table.size());
+
+ if (tableLength > 50000 // hard limit
+ || tableLength < sizeof(NameTableHead)) // corrupt name table
+ return false;
+
+ const NameTableHead *head = reinterpret_cast<const NameTableHead*>(table.constData());
+ const quint16 count = qFromBigEndian(head->count);
+ const quint16 stringOffset = qFromBigEndian(head->stringOffset);
+ if (count > 200 // hard limit
+ || stringOffset >= tableLength // corrupt name table
+ || sizeof(NameTableHead) + count * sizeof(NameRecord) >= tableLength) // corrupt name table
+ return false;
+
+ QTextEncoder encoder(QTextCodec::codecForName("UTF-16BE"), QTextCodec::IgnoreHeader);
+ const QByteArray markerUtf16BE = encoder.fromUnicode(marker);
+ const QByteArray markerAscii = marker.toAscii();
+
+ QByteArray markedTable;
+ markedTable.reserve(tableLength + marker.length() * 20); // Original size plus some extra
+ markedTable.append(table, stringOffset);
+ QByteArray markedStrings;
+ quint32 stringDataCount = stringOffset;
+ for (quint16 i = 0; i < count; ++i) {
+ const quint32 nameRecordOffset = sizeof(NameTableHead) + sizeof(NameRecord) * i;
+ NameRecord *nameRecord =
+ reinterpret_cast<NameRecord*>(markedTable.data() + nameRecordOffset);
+ const quint16 nameID = qFromBigEndian(nameRecord->nameID);
+ const quint16 platformID = qFromBigEndian(nameRecord->platformID);
+ const quint16 encodingID = qFromBigEndian(nameRecord->encodingID);
+ const quint16 offset = qFromBigEndian(nameRecord->offset);
+ const quint16 length = qFromBigEndian(nameRecord->length);
+ stringDataCount += length;
+ if (stringDataCount > 80000 // hard limit. String data may be > name table size. Multiple records can reference the same string.
+ || static_cast<quint32>(stringOffset + offset + length) > tableLength) // String outside bounds
+ return false;
+ const bool needsMarker =
+ nameID == 1 || nameID == 3 || nameID == 4 || nameID == 16 || nameID == 21;
+ const bool isUnicode =
+ platformID == 0 || platformID == 3 && encodingID == 1;
+ const QByteArray originalString =
+ QByteArray::fromRawData(table.constData() + stringOffset + offset, length);
+ QByteArray markedString;
+ if (needsMarker) {
+ const int maxBytesLength = (KMaxTypefaceNameLength - marker.length()) * (isUnicode ? 2 : 1);
+ markedString = originalString.left(maxBytesLength) + (isUnicode ? markerUtf16BE : markerAscii);
+ } else {
+ markedString = originalString;
+ }
+ nameRecord->offset = qToBigEndian(static_cast<quint16>(markedStrings.length()));
+ nameRecord->length = qToBigEndian(static_cast<quint16>(markedString.length()));
+ markedStrings.append(markedString);
+ }
+ markedTable.append(markedStrings);
+ table = markedTable;
+ return true;
+}
+
+const quint32 ttfMaxFileSize = 3500000;
+
+static inline bool ttfMarkAppFont(QByteArray &ttf, const QString &marker)
+{
+ const quint32 ttfChecksumNumber = 0xb1b0afba;
+ const quint32 alignment = 4;
+ const quint32 ttfLength = static_cast<quint32>(ttf.size());
+ if (ttfLength > ttfMaxFileSize // hard limit
+ || ttfLength % alignment != 0 // ttf sizes are always factors of 4
+ || ttfLength <= sizeof(OffsetTable) // ttf too short
+ || ttfCalcChecksum(ttf.constData(), ttf.size()) != ttfChecksumNumber) // ttf checksum is invalid
+ return false;
+
+ const OffsetTable *offsetTable = reinterpret_cast<const OffsetTable*>(ttf.constData());
+ const quint16 numTables = qFromBigEndian(offsetTable->numTables);
+ const quint32 recordsLength =
+ toDWordBoundary(sizeof(OffsetTable) + numTables * sizeof(TableRecord));
+ if (numTables > 30 // hard limit
+ || recordsLength + numTables * alignment > ttfLength) // Corrupt ttf. Tables would not fit, even if empty.
+ return false;
+
+ QByteArray markedTtf;
+ markedTtf.reserve(ttfLength + marker.length() * 20); // Original size plus some extra
+ markedTtf.append(ttf.constData(), recordsLength);
+
+ const quint32 ttfCheckSumAdjustmentOffset = 8; // Offset from the start of 'head'
+ int indexOfHeadTable = -1;
+ quint32 ttfDataSize = recordsLength;
+ typedef QPair<quint32, quint32> Range;
+ QList<Range> memoryRanges;
+ memoryRanges.reserve(numTables);
+ for (int i = 0; i < numTables; ++i) {
+ TableRecord *tableRecord =
+ reinterpret_cast<TableRecord*>(markedTtf.data() + sizeof(OffsetTable) + i * sizeof(TableRecord));
+ const quint32 offset = qFromBigEndian(tableRecord->offset);
+ const quint32 length = qFromBigEndian(tableRecord->length);
+ const quint32 lengthAligned = toDWordBoundary(length);
+ ttfDataSize += lengthAligned;
+ if (offset < recordsLength // must not intersect ttf header/records
+ || offset % alignment != 0 // must be aligned
+ || offset > ttfLength - alignment // table out of bounds
+ || offset + lengthAligned > ttfLength // table out of bounds
+ || ttfDataSize > ttfLength) // tables would not fit into the ttf
+ return false;
+
+ foreach (const Range &range, memoryRanges)
+ if (offset < range.first + range.second && offset + lengthAligned > range.first)
+ return false; // Overlaps with another table
+ memoryRanges.append(Range(offset, lengthAligned));
+
+ quint32 checkSum = qFromBigEndian(tableRecord->checkSum);
+ if (tableRecord->tag == qToBigEndian(static_cast<quint32>('head'))) {
+ if (length < ttfCheckSumAdjustmentOffset + sizeof(quint32))
+ return false; // Invalid 'head' table
+ const quint32 *checkSumAdjustmentTag =
+ reinterpret_cast<const quint32*>(ttf.constData() + offset + ttfCheckSumAdjustmentOffset);
+ const quint32 checkSumAdjustment = qFromBigEndian(*checkSumAdjustmentTag);
+ checkSum += checkSumAdjustment;
+ indexOfHeadTable = i; // For the ttf checksum re-calculation, later
+ }
+ if (checkSum != ttfCalcChecksum(ttf.constData() + offset, length))
+ return false; // Table checksum is invalid
+
+ bool updateTableChecksum = false;
+ QByteArray table;
+ if (tableRecord->tag == qToBigEndian(static_cast<quint32>('name'))) {
+ table = QByteArray(ttf.constData() + offset, length);
+ if (!ttfMarkNameTable(table, marker))
+ return false; // Name table was not markable.
+ updateTableChecksum = true;
+ } else {
+ table = QByteArray::fromRawData(ttf.constData() + offset, length);
+ }
+
+ tableRecord->offset = qToBigEndian(markedTtf.size());
+ tableRecord->length = qToBigEndian(table.size());
+ markedTtf.append(table);
+ markedTtf.append(QByteArray(dWordPadding(table.size()), 0)); // 0-padding
+ if (updateTableChecksum) {
+ TableRecord *tableRecord = // Need to recalculate, since markedTtf changed
+ reinterpret_cast<TableRecord*>(markedTtf.data() + sizeof(OffsetTable) + i * sizeof(TableRecord));
+ const quint32 offset = qFromBigEndian(tableRecord->offset);
+ const quint32 length = qFromBigEndian(tableRecord->length);
+ tableRecord->checkSum = qToBigEndian(ttfCalcChecksum(markedTtf.constData() + offset, length));
+ }
+ }
+ if (indexOfHeadTable == -1 // 'head' table is mandatory
+ || ttfDataSize != ttfLength) // We do not allow ttf data "holes". Neither does Symbian.
+ return false;
+ TableRecord *headRecord =
+ reinterpret_cast<TableRecord*>(markedTtf.data() + sizeof(OffsetTable) + indexOfHeadTable * sizeof(TableRecord));
+ quint32 *checkSumAdjustmentTag =
+ reinterpret_cast<quint32*>(markedTtf.data() + qFromBigEndian(headRecord->offset) + ttfCheckSumAdjustmentOffset);
+ *checkSumAdjustmentTag = 0;
+ const quint32 ttfChecksum = ttfCalcChecksum(markedTtf.constData(), markedTtf.count());
+ *checkSumAdjustmentTag = qToBigEndian(ttfChecksumNumber - ttfChecksum);
+ ttf = markedTtf;
+ return true;
+}
+
+static inline bool ttfCanSymbianLoadFont(const QByteArray &data, const QString &fileName)
+{
+ bool result = false;
+ QString ttfFileName;
+ QFile tempFileGuard;
+ QFileInfo info(fileName);
+ if (!data.isEmpty()) {
+ QTemporaryFile tempfile(QSymbianFontDatabaseExtrasImplementation::tempAppFontFolder()
+ + QSymbianFontDatabaseExtrasImplementation::appFontMarker()
+ + QLatin1String("XXXXXX.ttf"));
+ if (!tempfile.open() || tempfile.write(data) == -1)
+ return false;
+ ttfFileName = QDir::toNativeSeparators(QFileInfo(tempfile).canonicalFilePath());
+ tempfile.setAutoRemove(false);
+ tempfile.close();
+ tempFileGuard.setFileName(ttfFileName);
+ if (!tempFileGuard.open(QIODevice::ReadOnly))
+ return false;
+ } else if (info.isFile()) {
+ ttfFileName = QDir::toNativeSeparators(info.canonicalFilePath());
+ } else {
+ return false;
+ }
+
+ CFontStore *store = 0;
+ RHeap* heap = User::ChunkHeap(NULL, 0x1000, 0x20000);
+ if (heap) {
+ QT_TRAP_THROWING(
+ CleanupClosePushL(*heap);
+ store = CFontStore::NewL(heap);
+ CleanupStack::PushL(store);
+ COpenFontRasterizer *rasterizer = COpenFontRasterizer::NewL(TUid::Uid(0x101F7F5E));
+ CleanupStack::PushL(rasterizer);
+ store->InstallRasterizerL(rasterizer);
+ CleanupStack::Pop(rasterizer);
+ TUid fontUid = {-1};
+ TRAP_IGNORE(fontUid = store->AddFileL(qt_QString2TPtrC(ttfFileName)));
+ if (fontUid.iUid != -1)
+ result = true;
+ CleanupStack::PopAndDestroy(2, heap); // heap, store
+ );
+ }
+
+ if (tempFileGuard.isOpen())
+ tempFileGuard.remove();
+
+ return result;
+}
+
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
{
- Q_UNUSED(fnt);
+ if (QSymbianFontDatabaseExtrasImplementation::appFontLimitReached()
+ || fnt->data.size() > ttfMaxFileSize // hard limit
+ || fnt->data.isEmpty() && (!fnt->fileName.endsWith(QLatin1String(".ttf"), Qt::CaseInsensitive) // Only buffer or .ttf
+ || QFileInfo(fnt->fileName).size() > ttfMaxFileSize)) // hard limit
+ return;
+
+// Using ttfCanSymbianLoadFont() causes crashes on app destruction (Symbian^3|PR1 and lower).
+// Therefore, not using it for now, but eventually in a later version.
+// if (!ttfCanSymbianLoadFont(fnt->data, fnt->fileName))
+// return;
+
+ QFontDatabasePrivate *db = privateDb();
+ if (!db)
+ return;
+
+ if (!db->count)
+ initializeDb();
+
+ QSymbianFontDatabaseExtrasImplementation *dbExtras =
+ static_cast<QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras);
+ if (!dbExtras)
+ return;
+
+ const QString &marker = QSymbianFontDatabaseExtrasImplementation::appFontMarker();
+
+ // The QTemporaryFile object being used in the following section must be
+ // destructed before letting Symbian load the TTF file. Symbian would not
+ // load it otherwise, because QTemporaryFile will still keep some handle
+ // on it. The scope is used to reduce the life time of the QTemporaryFile.
+ // In order to prevent other processes from modifying the file between the
+ // moment where the QTemporaryFile is destructed and the file is loaded by
+ // Symbian, we have a QFile "tempFileGuard" outside the scope which opens
+ // the file in ReadOnly mode while the QTemporaryFile is still alive.
+ QFile tempFileGuard;
+ {
+ QTemporaryFile tempfile(QSymbianFontDatabaseExtrasImplementation::tempAppFontFolder()
+ + marker + QLatin1String("XXXXXX.ttf"));
+ if (!tempfile.open())
+ return;
+ const QString tempFileName = QFileInfo(tempfile).canonicalFilePath();
+ if (fnt->data.isEmpty()) {
+ QFile sourceFile(fnt->fileName);
+ if (!sourceFile.open(QIODevice::ReadOnly))
+ return;
+ fnt->data = sourceFile.readAll();
+ }
+ if (!ttfMarkAppFont(fnt->data, marker) || tempfile.write(fnt->data) == -1)
+ return;
+ tempfile.setAutoRemove(false);
+ tempfile.close(); // Tempfile still keeps a file handle, forbidding write access
+ fnt->data.clear(); // The TTF data was marked and saved. Not needed in memory, anymore.
+ tempFileGuard.setFileName(tempFileName);
+ if (!tempFileGuard.open(QIODevice::ReadOnly))
+ return;
+ fnt->temporaryFileName = tempFileName;
+ }
+
+ const QString fullFileName = QDir::toNativeSeparators(fnt->temporaryFileName);
+ QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
+ const QStringList fontsOnServerBefore = qt_symbian_fontFamiliesOnFontServer();
+ const TInt err =
+ S60->screenDevice()->AddFile(qt_QString2TPtrC(fullFileName), fnt->screenDeviceFontFileId);
+ tempFileGuard.close(); // Did its job
+ const QStringList fontsOnServerAfter = qt_symbian_fontFamiliesOnFontServer();
+ if (err == KErrNone && fontsOnServerBefore.count() < fontsOnServerAfter.count()) { // Added to screen device?
+ int fontOnServerIndex = fontsOnServerAfter.count() - 1;
+ for (int i = 0; i < fontsOnServerBefore.count(); i++) {
+ if (fontsOnServerBefore.at(i) != fontsOnServerAfter.at(i)) {
+ fontOnServerIndex = i;
+ break;
+ }
+ }
+
+ // Must remove all font engines with their CFonts, first.
+ QFontCache::instance()->clear();
+ db->free();
+ QSymbianFontDatabaseExtrasImplementation::clear();
+
+ if (!QSymbianTypeFaceExtras::symbianFontTableApiAvailable())
+ fnt->fontStoreFontFileUid = dbExtras->addFontFileToFontStore(QFileInfo(fullFileName));
+
+ const QString &appFontName = fontsOnServerAfter.at(fontOnServerIndex);
+ fnt->families.append(qt_symbian_appFontNameWithoutMarker(appFontName));
+ if (!qt_symbian_fontNameHasAppFontMarker(appFontName)
+ || !registerScreenDeviceFont(fontOnServerIndex, dbExtras))
+ dbExtras->removeAppFontData(fnt);
+ } else {
+ if (fnt->screenDeviceFontFileId > 0)
+ S60->screenDevice()->RemoveFile(fnt->screenDeviceFontFileId); // May still have the file open!
+ QFile::remove(fnt->temporaryFileName);
+ *fnt = QFontDatabasePrivate::ApplicationFont();
+ }
+ lock.relock();
}
bool QFontDatabase::removeApplicationFont(int handle)
{
- Q_UNUSED(handle);
- return false;
+ QMutexLocker locker(fontDatabaseMutex());
+
+ QFontDatabasePrivate *db = privateDb();
+ if (!db || handle < 0 || handle >= db->applicationFonts.count())
+ return false;
+ QSymbianFontDatabaseExtrasImplementation *dbExtras =
+ static_cast<QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras);
+ if (!dbExtras)
+ return false;
+
+ QFontDatabasePrivate::ApplicationFont *fnt = &db->applicationFonts[handle];
+ if (fnt->families.isEmpty())
+ return true; // Nothing to remove. Return peacefully.
+
+ // Must remove all font engines with their CFonts, first
+ QFontCache::instance()->clear();
+ db->free();
+ dbExtras->removeAppFontData(fnt);
+
+ db->invalidate(); // This will just emit 'fontDatabaseChanged()'
+ return true;
}
bool QFontDatabase::removeAllApplicationFonts()
{
- return false;
+ QMutexLocker locker(fontDatabaseMutex());
+
+ const int applicationFontsCount = privateDb()->applicationFonts.count();
+ for (int i = 0; i < applicationFontsCount; ++i)
+ if (!removeApplicationFont(i))
+ return false;
+ return true;
}
bool QFontDatabase::supportsThreadedFontRendering()
@@ -467,7 +984,7 @@ QFontEngine *QFontDatabase::findFont(int script, const QFontPrivate *d, const QF
QFontDatabasePrivate *db = privateDb();
QtFontDesc desc;
QList<int> blacklistedFamilies;
- match(script, req, req.family, QString(), -1, &desc, blacklistedFamilies);
+ match(script, key.def, key.def.family, QString(), -1, &desc, blacklistedFamilies);
if (!desc.family) // falling back to application font
desc.family = db->family(QApplication::font().defaultFamily());
Q_ASSERT(desc.family);
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp
index 2186058..f923d87 100644
--- a/src/gui/text/qfontdatabase_x11.cpp
+++ b/src/gui/text/qfontdatabase_x11.cpp
@@ -1972,17 +1972,6 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
#ifndef QT_NO_FONTCONFIG
} else if (X11->has_fontconfig) {
fe = loadFc(d, script, req);
- if (fe != 0 && fe->fontDef.pixelSize != req.pixelSize && mainThread && qt_is_gui_used) {
- QFontEngine *xlfdFontEngine = loadXlfd(d->screen, script, req);
- if (xlfdFontEngine->fontDef.family == fe->fontDef.family) {
- delete fe;
- fe = xlfdFontEngine;
- } else {
- delete xlfdFontEngine;
- }
- }
-
-
#endif
} else if (mainThread && qt_is_gui_used) {
fe = loadXlfd(d->screen, script, req);
diff --git a/src/gui/text/qfontengine_qws.cpp b/src/gui/text/qfontengine_qws.cpp
index 4802b94..b71c4a7 100644
--- a/src/gui/text/qfontengine_qws.cpp
+++ b/src/gui/text/qfontengine_qws.cpp
@@ -288,13 +288,16 @@ private:
#else
void readNode(QIODevice& f)
{
- uchar rw = f.getch();
- uchar cl = f.getch();
+ char rw;
+ char cl;
+ f.getChar(&rw);
+ f.getChar(&cl);
min = (rw << 8) | cl;
- rw = f.getch();
- cl = f.getch();
+ f.getChar(&rw);
+ f.getChar(&cl);
max = (rw << 8) | cl;
- int flags = f.getch();
+ char flags;
+ f.getChar(&flags);
if ( flags & 1 )
less = new QPFGlyphTree;
else
@@ -332,7 +335,7 @@ private:
int n = max-min+1;
for (int i=0; i<n; i++) {
glyph[i].metrics = new QPFGlyphMetrics;
- f.readBlock((char*)glyph[i].metrics, sizeof(QPFGlyphMetrics));
+ f.read((char*)glyph[i].metrics, sizeof(QPFGlyphMetrics));
}
if ( less )
less->readMetrics(f);
@@ -365,7 +368,7 @@ private:
//############### s = qt_screen->mapToDevice( s );
uint datasize = glyph[i].metrics->linestep * s.height();
glyph[i].data = new uchar[datasize]; // ### deleted?
- f.readBlock((char*)glyph[i].data, datasize);
+ f.read((char*)glyph[i].data, datasize);
}
if ( less )
less->readData(f);
@@ -385,6 +388,32 @@ public:
size_t mmapLength;
};
+#if defined(Q_OS_INTEGRITY)
+static void *qt_mmap(void *start, size_t length, int /*prot*/, int /*flags*/, int fd, off_t offset)
+{
+ // INTEGRITY cannot mmap local files - load it into a local buffer
+ if (::lseek(fd, offset, SEEK_SET) == -1) {
+# if defined(DEBUG_FONTENGINE)
+ perror("lseek failed");
+# endif
+ }
+ void *buf = malloc(length);
+ if (::read(fd, buf, length) != (ssize_t)length) {
+# if defined(DEBUG_FONTENGINE)
+ perror("read failed");
+# endif
+ }
+
+ return buf;
+}
+#else
+static inline void *qt_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
+{
+ return mmap(start, length, prot, flags, fd, offset);
+}
+#endif
+
+
QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn)
{
@@ -395,16 +424,18 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn)
QT_STATBUF st;
if ( QT_FSTAT( f, &st ) )
qFatal("Failed to stat %s",QFile::encodeName(fn).data());
- uchar* data = (uchar*)mmap( 0, // any address
+ uchar* data = (uchar*)qt_mmap( 0, // any address
st.st_size, // whole file
PROT_READ, // read-only memory
-#if !defined(Q_OS_SOLARIS) && !defined(Q_OS_QNX4) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_VXWORKS)
+#if defined(Q_OS_INTEGRITY)
+ 0,
+#elif !defined(Q_OS_SOLARIS) && !defined(Q_OS_QNX4) && !defined(Q_OS_VXWORKS)
MAP_FILE | MAP_PRIVATE, // swap-backed map from file
#else
MAP_PRIVATE,
#endif
f, 0 ); // from offset 0 of f
-#if defined(Q_OS_QNX4) && !defined(MAP_FAILED)
+#if !defined(MAP_FAILED) && (defined(Q_OS_QNX4) || defined(Q_OS_INTEGRITY))
#define MAP_FAILED ((void *)-1)
#endif
if ( !data || data == (uchar*)MAP_FAILED )
diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp
index 4317ee6..e9b54e3 100644
--- a/src/gui/text/qfontengine_s60.cpp
+++ b/src/gui/text/qfontengine_s60.cpp
@@ -244,10 +244,13 @@ static inline unsigned int getChar(const QChar *str, int &i, const int len)
return uc;
}
+extern QString qt_symbian_fontNameWithAppFontMarker(const QString &fontName); // qfontdatabase_s60.cpp
+
CFont *QFontEngineS60::fontWithSize(qreal size) const
{
CFont *result = 0;
- TFontSpec fontSpec(qt_QString2TPtrC(QFontEngine::fontDef.family), TInt(size));
+ const QString family = qt_symbian_fontNameWithAppFontMarker(QFontEngine::fontDef.family);
+ TFontSpec fontSpec(qt_QString2TPtrC(family), TInt(size));
fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
fontSpec.iFontStyle.SetPosture(QFontEngine::fontDef.style == QFont::StyleNormal?EPostureUpright:EPostureItalic);
fontSpec.iFontStyle.SetStrokeWeight(QFontEngine::fontDef.weight > QFont::Normal?EStrokeWeightBold:EStrokeWeightNormal);
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index 89ca6bf..46f1d62 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -115,6 +115,7 @@ static QTextLine currentTextLine(const QTextCursor &cursor)
QTextControlPrivate::QTextControlPrivate()
: doc(0), cursorOn(false), cursorIsFocusIndicator(false),
interactionFlags(Qt::TextEditorInteraction),
+ dragEnabled(true),
#ifndef QT_NO_DRAGANDDROP
mousePressed(false), mightStartDrag(false),
#endif
@@ -129,7 +130,8 @@ QTextControlPrivate::QTextControlPrivate()
isEnabled(true),
hadSelectionOnMousePress(false),
ignoreUnusedNavigationEvents(false),
- openExternalLinks(false)
+ openExternalLinks(false),
+ wordSelectionEnabled(false)
{}
bool QTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
@@ -931,15 +933,18 @@ void QTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget *conte
break; }
case QEvent::MouseMove: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mouseMoveEvent(ev->buttons(), matrix.map(ev->pos()));
+ d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
+ ev->buttons(), ev->globalPos());
break; }
case QEvent::MouseButtonRelease: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mouseReleaseEvent(ev->button(), matrix.map(ev->pos()));
+ d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
+ ev->buttons(), ev->globalPos());
break; }
case QEvent::MouseButtonDblClick: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mouseDoubleClickEvent(e, ev->button(), matrix.map(ev->pos()));
+ d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
+ ev->buttons(), ev->globalPos());
break; }
case QEvent::InputMethod:
d->inputMethodEvent(static_cast<QInputMethodEvent *>(e));
@@ -999,15 +1004,18 @@ void QTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget *conte
break; }
case QEvent::GraphicsSceneMouseMove: {
QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
- d->mouseMoveEvent(ev->buttons(), matrix.map(ev->pos()));
+ d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
+ ev->screenPos());
break; }
case QEvent::GraphicsSceneMouseRelease: {
QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
- d->mouseReleaseEvent(ev->button(), matrix.map(ev->pos()));
+ d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
+ ev->screenPos());
break; }
case QEvent::GraphicsSceneMouseDoubleClick: {
QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
- d->mouseDoubleClickEvent(e, ev->button(), matrix.map(ev->pos()));
+ d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
+ ev->screenPos());
break; }
case QEvent::GraphicsSceneContextMenu: {
QGraphicsSceneContextMenuEvent *ev = static_cast<QGraphicsSceneContextMenuEvent *>(e);
@@ -1016,7 +1024,8 @@ void QTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget *conte
case QEvent::GraphicsSceneHoverMove: {
QGraphicsSceneHoverEvent *ev = static_cast<QGraphicsSceneHoverEvent *>(e);
- d->mouseMoveEvent(Qt::NoButton, matrix.map(ev->pos()));
+ d->mouseMoveEvent(ev, Qt::NoButton, matrix.map(ev->pos()), ev->modifiers(),Qt::NoButton,
+ ev->screenPos());
break; }
case QEvent::GraphicsSceneDragEnter: {
@@ -1486,6 +1495,11 @@ void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, con
{
Q_Q(QTextControl);
+ if (sendMouseEventToInputContext(
+ e, QEvent::MouseButtonPress, button, pos, modifiers, buttons, globalPos)) {
+ return;
+ }
+
if (interactionFlags & Qt::LinksAccessibleByMouse) {
anchorOnMousePress = q->anchorAt(pos);
@@ -1528,31 +1542,22 @@ void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, con
return;
}
-#if !defined(QT_NO_IM)
- QTextLayout *layout = cursor.block().layout();
- if (contextWidget && layout && !layout->preeditAreaText().isEmpty()) {
- QInputContext *ctx = inputContext();
- if (ctx) {
- QMouseEvent ev(QEvent::MouseButtonPress, contextWidget->mapFromGlobal(globalPos), globalPos,
- button, buttons, modifiers);
- ctx->mouseHandler(cursorPos - cursor.position(), &ev);
+ if (modifiers == Qt::ShiftModifier && (interactionFlags & Qt::TextSelectableByMouse)) {
+ if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) {
+ selectedWordOnDoubleClick = cursor;
+ selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor);
}
- if (!layout->preeditAreaText().isEmpty()) {
- e->ignore();
- return;
- }
- }
-#endif
- if (modifiers == Qt::ShiftModifier) {
+
if (selectedBlockOnTrippleClick.hasSelection())
extendBlockwiseSelection(cursorPos);
else if (selectedWordOnDoubleClick.hasSelection())
extendWordwiseSelection(cursorPos, pos.x());
- else
+ else if (wordSelectionEnabled)
setCursorPosition(cursorPos, QTextCursor::KeepAnchor);
} else {
- if (cursor.hasSelection()
+ if (dragEnabled
+ && cursor.hasSelection()
&& !cursorIsFocusIndicator
&& cursorPos >= cursor.selectionStart()
&& cursorPos <= cursor.selectionEnd()
@@ -1582,10 +1587,16 @@ void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, con
hadSelectionOnMousePress = cursor.hasSelection();
}
-void QTextControlPrivate::mouseMoveEvent(Qt::MouseButtons buttons, const QPointF &mousePos)
+void QTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button, const QPointF &mousePos, Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons, const QPoint &globalPos)
{
Q_Q(QTextControl);
+ if (sendMouseEventToInputContext(
+ e, QEvent::MouseMove, button, mousePos, modifiers, buttons, globalPos)) {
+ return;
+ }
+
if (interactionFlags & Qt::LinksAccessibleByMouse) {
QString anchor = q->anchorAt(mousePos);
if (anchor != highlightedAnchor) {
@@ -1615,21 +1626,20 @@ void QTextControlPrivate::mouseMoveEvent(Qt::MouseButtons buttons, const QPointF
}
const qreal mouseX = qreal(mousePos.x());
-#if !defined(QT_NO_IM)
- QTextLayout *layout = cursor.block().layout();
- if (layout && !layout->preeditAreaText().isEmpty())
- return;
-#endif
-
int newCursorPos = q->hitTest(mousePos, Qt::FuzzyHit);
if (newCursorPos == -1)
return;
+ if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) {
+ selectedWordOnDoubleClick = cursor;
+ selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor);
+ }
+
if (selectedBlockOnTrippleClick.hasSelection())
extendBlockwiseSelection(newCursorPos);
else if (selectedWordOnDoubleClick.hasSelection())
extendWordwiseSelection(newCursorPos, mouseX);
- else
+ else if (interactionFlags & Qt::TextSelectableByMouse)
setCursorPosition(newCursorPos, QTextCursor::KeepAnchor);
if (interactionFlags & Qt::TextEditable) {
@@ -1653,10 +1663,16 @@ void QTextControlPrivate::mouseMoveEvent(Qt::MouseButtons buttons, const QPointF
repaintOldAndNewSelection(oldSelection);
}
-void QTextControlPrivate::mouseReleaseEvent(Qt::MouseButton button, const QPointF &pos)
+void QTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons, const QPoint &globalPos)
{
Q_Q(QTextControl);
+ if (sendMouseEventToInputContext(
+ e, QEvent::MouseButtonRelease, button, pos, modifiers, buttons, globalPos)) {
+ return;
+ }
+
const QTextCursor oldSelection = cursor;
const int oldCursorPos = cursor.position();
@@ -1714,19 +1730,21 @@ void QTextControlPrivate::mouseReleaseEvent(Qt::MouseButton button, const QPoint
}
}
-void QTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos)
+void QTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons, const QPoint &globalPos)
{
Q_Q(QTextControl);
+
+ if (sendMouseEventToInputContext(
+ e, QEvent::MouseButtonDblClick, button, pos, modifiers, buttons, globalPos)) {
+ return;
+ }
+
if (button != Qt::LeftButton
|| !(interactionFlags & Qt::TextSelectableByMouse)) {
e->ignore();
return;
}
-#if !defined(QT_NO_IM)
- QTextLayout *layout = cursor.block().layout();
- if (layout && !layout->preeditAreaText().isEmpty())
- return;
-#endif
#ifndef QT_NO_DRAGANDDROP
mightStartDrag = false;
@@ -1755,6 +1773,45 @@ void QTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton butto
}
}
+bool QTextControlPrivate::sendMouseEventToInputContext(
+ QEvent *e, QEvent::Type eventType, Qt::MouseButton button, const QPointF &pos,
+ Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint &globalPos)
+{
+#if !defined(QT_NO_IM)
+ Q_Q(QTextControl);
+
+ QTextLayout *layout = cursor.block().layout();
+ if (contextWidget && layout && !layout->preeditAreaText().isEmpty()) {
+ QInputContext *ctx = inputContext();
+ int cursorPos = q->hitTest(pos, Qt::FuzzyHit) - cursor.position();
+
+ if (cursorPos < 0 || cursorPos > layout->preeditAreaText().length()) {
+ cursorPos = -1;
+ // don't send move events outside the preedit area
+ if (eventType == QEvent::MouseMove)
+ return true;
+ }
+ if (ctx) {
+ QMouseEvent ev(eventType, contextWidget->mapFromGlobal(globalPos), globalPos,
+ button, buttons, modifiers);
+ ctx->mouseHandler(cursorPos, &ev);
+ e->setAccepted(ev.isAccepted());
+ }
+ if (!layout->preeditAreaText().isEmpty())
+ return true;
+ }
+#else
+ Q_UNUSED(e);
+ Q_UNUSED(eventType);
+ Q_UNUSED(button);
+ Q_UNUSED(pos);
+ Q_UNUSED(modifiers);
+ Q_UNUSED(buttons);
+ Q_UNUSED(globalPos);
+#endif
+ return false;
+}
+
void QTextControlPrivate::contextMenuEvent(const QPoint &screenPos, const QPointF &docPos, QWidget *contextWidget)
{
#ifdef QT_NO_CONTEXTMENU
@@ -2331,6 +2388,31 @@ bool QTextControl::cursorIsFocusIndicator() const
return d->cursorIsFocusIndicator;
}
+
+void QTextControl::setDragEnabled(bool enabled)
+{
+ Q_D(QTextControl);
+ d->dragEnabled = enabled;
+}
+
+bool QTextControl::isDragEnabled() const
+{
+ Q_D(const QTextControl);
+ return d->dragEnabled;
+}
+
+void QTextControl::setWordSelectionEnabled(bool enabled)
+{
+ Q_D(QTextControl);
+ d->wordSelectionEnabled = enabled;
+}
+
+bool QTextControl::isWordSelectionEnabled() const
+{
+ Q_D(const QTextControl);
+ return d->wordSelectionEnabled;
+}
+
#ifndef QT_NO_PRINTER
void QTextControl::print(QPrinter *printer) const
{
diff --git a/src/gui/text/qtextcontrol_p.h b/src/gui/text/qtextcontrol_p.h
index 6540f4f..31fa843 100644
--- a/src/gui/text/qtextcontrol_p.h
+++ b/src/gui/text/qtextcontrol_p.h
@@ -175,6 +175,12 @@ public:
void setCursorIsFocusIndicator(bool b);
bool cursorIsFocusIndicator() const;
+ void setDragEnabled(bool enabled);
+ bool isDragEnabled() const;
+
+ bool isWordSelectionEnabled() const;
+ void setWordSelectionEnabled(bool enabled);
+
#ifndef QT_NO_PRINTER
void print(QPrinter *printer) const;
#endif
@@ -183,8 +189,6 @@ public:
virtual QRectF blockBoundingRect(const QTextBlock &block) const;
QAbstractTextDocumentLayout::PaintContext getPaintContext(QWidget *widget) const;
-
-
public Q_SLOTS:
void setPlainText(const QString &text);
void setHtml(const QString &text);
diff --git a/src/gui/text/qtextcontrol_p_p.h b/src/gui/text/qtextcontrol_p_p.h
index 04f4c75..94670e2 100644
--- a/src/gui/text/qtextcontrol_p_p.h
+++ b/src/gui/text/qtextcontrol_p_p.h
@@ -135,9 +135,23 @@ public:
Qt::KeyboardModifiers modifiers,
Qt::MouseButtons buttons,
const QPoint &globalPos);
- void mouseMoveEvent(Qt::MouseButtons buttons, const QPointF &pos);
- void mouseReleaseEvent(Qt::MouseButton button, const QPointF &pos);
- void mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos);
+ void mouseMoveEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
+ Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons,
+ const QPoint &globalPos);
+ void mouseReleaseEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
+ Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons,
+ const QPoint &globalPos);
+ void mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
+ Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons,
+ const QPoint &globalPos);
+ bool sendMouseEventToInputContext(QEvent *e, QEvent::Type eventType, Qt::MouseButton button,
+ const QPointF &pos,
+ Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons,
+ const QPoint &globalPos);
void contextMenuEvent(const QPoint &screenPos, const QPointF &docPos, QWidget *contextWidget);
void focusEvent(QFocusEvent *e);
#ifdef QT_KEYPAD_NAVIGATION
@@ -174,6 +188,8 @@ public:
QBasicTimer trippleClickTimer;
QPointF trippleClickPoint;
+ bool dragEnabled;
+
bool mousePressed;
bool mightStartDrag;
@@ -209,6 +225,8 @@ public:
bool ignoreUnusedNavigationEvents;
bool openExternalLinks;
+ bool wordSelectionEnabled;
+
QString linkToCopy;
void _q_copyLink();
void _q_updateBlock(const QTextBlock &);
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 498a432..2172f74 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -663,7 +663,8 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O
Q_ASSERT(blocks.length() == fragments.length());
- finishEdit();
+ if (!blockCursorAdjustment)
+ finishEdit();
}
void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operation op)
@@ -678,6 +679,7 @@ void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operati
curs->changed = true;
}
}
+ finishEdit();
}
void QTextDocumentPrivate::setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode)
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index 157b7bc..838face 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -2510,6 +2510,7 @@ static inline void getLineHeightParams(const QTextBlockFormat &blockFormat, cons
QFixed *lineAdjustment, QFixed *lineBreakHeight, QFixed *lineHeight)
{
*lineHeight = QFixed::fromReal(blockFormat.lineHeight(line.height(), scaling));
+
if (blockFormat.lineHeightType() == QTextBlockFormat::FixedHeight || blockFormat.lineHeightType() == QTextBlockFormat::MinimumHeight) {
*lineBreakHeight = *lineHeight;
if (blockFormat.lineHeightType() == QTextBlockFormat::FixedHeight)
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 415fa4b..a63fdbf 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1385,6 +1385,15 @@ void QTextEngine::shape(int item) const
}
}
+static inline void releaseCachedFontEngine(QFontEngine *fontEngine)
+{
+ if (fontEngine) {
+ fontEngine->ref.deref();
+ if (fontEngine->cache_count == 0 && fontEngine->ref == 0)
+ delete fontEngine;
+ }
+}
+
void QTextEngine::invalidate()
{
freeMemory();
@@ -1392,6 +1401,9 @@ void QTextEngine::invalidate()
maxWidth = 0;
if (specialData)
specialData->resolvedFormatIndices.clear();
+
+ releaseCachedFontEngine(feCache.prevFontEngine);
+ releaseCachedFontEngine(feCache.prevScaledFontEngine);
feCache.reset();
}
@@ -1824,7 +1836,11 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
scaledEngine = font.d->engineForScript(script);
}
feCache.prevFontEngine = engine;
+ if (engine)
+ engine->ref.ref();
feCache.prevScaledFontEngine = scaledEngine;
+ if (scaledEngine)
+ scaledEngine->ref.ref();
feCache.prevScript = script;
feCache.prevPosition = si.position;
feCache.prevLength = length(&si);
@@ -1835,6 +1851,8 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
else {
engine = font.d->engineForScript(script);
feCache.prevFontEngine = engine;
+ if (engine)
+ engine->ref.ref();
feCache.prevScript = script;
feCache.prevPosition = -1;
feCache.prevLength = -1;
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index daafdd9..d3e8f2d 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -147,8 +147,8 @@ symbian {
text/qfontengine_s60.cpp
HEADERS += \
text/qfontengine_s60_p.h
- LIBS += -lfntstr -lecom
}
+ LIBS += -lfntstr -lecom
}
!qpa {
diff --git a/src/gui/widgets/qcocoamenu_mac.mm b/src/gui/widgets/qcocoamenu_mac.mm
index d5c8eb8..dff37b4 100644
--- a/src/gui/widgets/qcocoamenu_mac.mm
+++ b/src/gui/widgets/qcocoamenu_mac.mm
@@ -48,6 +48,7 @@
#include <private/qt_cocoa_helpers_mac_p.h>
#include <private/qapplication_p.h>
#include <private/qaction_p.h>
+#include <private/qcocoaapplication_mac_p.h>
#include <QtGui/QMenu>
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 7946137..b5dda5a 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -2486,10 +2486,18 @@ void QComboBox::showPopup()
listRect.setWidth(listRect.height());
//by default popup is centered on screen in landscape
listRect.moveCenter(screen.center());
- if (staConTopRect.IsEmpty() && AknLayoutUtils::CbaLocation() != AknLayoutUtils::EAknCbaLocationBottom) {
- // landscape without stacon, menu should be at the right
- (opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) :
- listRect.setLeft(screen.left());
+ if (staConTopRect.IsEmpty()) {
+ TRect cbaRect = TRect();
+ AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane, cbaRect);
+ AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation();
+ switch (cbaLocation) {
+ case AknLayoutUtils::EAknCbaLocationRight:
+ listRect.setRight(screen.right());
+ break;
+ case AknLayoutUtils::EAknCbaLocationLeft:
+ listRect.setLeft(screen.left());
+ break;
+ }
}
}
#endif
diff --git a/src/gui/widgets/qfocusframe.cpp b/src/gui/widgets/qfocusframe.cpp
index c159a1e..6508c31 100644
--- a/src/gui/widgets/qfocusframe.cpp
+++ b/src/gui/widgets/qfocusframe.cpp
@@ -85,6 +85,9 @@ void QFocusFramePrivate::update()
void QFocusFramePrivate::updateSize()
{
Q_Q(QFocusFrame);
+ if (!widget)
+ return;
+
int vmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameVMargin),
hmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameHMargin);
QPoint pos(widget->x(), widget->y());
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index 062bb61..023b9ee 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -456,6 +456,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event)
#ifndef QT_NO_IM
setPreeditArea(m_cursor, event->preeditString());
#endif //QT_NO_IM
+ const int oldPreeditCursor = m_preeditCursor;
m_preeditCursor = event->preeditString().length();
m_hideCursor = false;
QList<QTextLayout::FormatRange> formats;
@@ -479,6 +480,8 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event)
updateDisplayText(/*force*/ true);
if (cursorPositionChanged)
emitCursorPositionChanged();
+ else if (m_preeditCursor != oldPreeditCursor)
+ emit updateMicroFocus();
if (isGettingInput)
finishChange(priorState);
}
@@ -541,10 +544,13 @@ void QLineControl::draw(QPainter *painter, const QPoint &offset, const QRect &cl
*/
void QLineControl::selectWordAtPos(int cursor)
{
- int c = m_textLayout.previousCursorPosition(cursor, QTextLayout::SkipWords);
+ int next = cursor + 1;
+ if(next > end())
+ --next;
+ int c = m_textLayout.previousCursorPosition(next, QTextLayout::SkipWords);
moveCursor(c, false);
// ## text layout should support end of words.
- int end = m_textLayout.nextCursorPosition(cursor, QTextLayout::SkipWords);
+ int end = m_textLayout.nextCursorPosition(c, QTextLayout::SkipWords);
while (end > cursor && m_text[end-1].isSpace())
--end;
moveCursor(end, true);
diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h
index bfe50fe..3c505c8 100644
--- a/src/gui/widgets/qlinecontrol_p.h
+++ b/src/gui/widgets/qlinecontrol_p.h
@@ -425,6 +425,7 @@ Q_SIGNALS:
void textEdited(const QString &);
void resetInputContext();
+ void updateMicroFocus();
void accepted();
void editingFinished();
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index a786e2f..fd61783 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -1516,11 +1516,6 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set)
if (!isWindow() || d->useHIToolBar == set || QSysInfo::MacintoshVersion < QSysInfo::MV_10_3)
return;
- // ### Disable when using alien widgets
- if (testAttribute(Qt::WA_NativeWindow) == false) {
- return;
- }
-
d->useHIToolBar = set;
createWinId(); // We need the hiview for down below.
diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm
index 9a23ca7..e428ffc 100644
--- a/src/gui/widgets/qmainwindowlayout_mac.mm
+++ b/src/gui/widgets/qmainwindowlayout_mac.mm
@@ -355,7 +355,11 @@ void QMainWindowLayout::updateHIToolBarStatus()
// Move everything out of the HIToolbar into the main toolbar.
while (!qtoolbarsInUnifiedToolbarList.isEmpty()) {
// Should shrink the list by one every time.
- layoutState.mainWindow->addToolBar(Qt::TopToolBarArea, qtoolbarsInUnifiedToolbarList.first());
+ QToolBar *toolbar = qtoolbarsInUnifiedToolbarList.first();
+ layoutState.mainWindow->addToolBar(Qt::TopToolBarArea, toolbar);
+#if defined(QT_MAC_USE_COCOA)
+ toolbar->d_func()->isInUnifiedToolbar = false;
+#endif
}
macWindowToolbarSet(qt_mac_window_for(layoutState.mainWindow), 0);
} else {
@@ -363,7 +367,8 @@ void QMainWindowLayout::updateHIToolBarStatus()
for (int i = 0; i < toolbars.size(); ++i) {
QToolBar *toolbar = toolbars.at(i);
if (toolBarArea(toolbar) == Qt::TopToolBarArea) {
- removeWidget(toolbar); // Do this here, because we are in an in-between state.
+ // Do this here, because we are in an in-between state.
+ removeWidget(toolbar);
layoutState.mainWindow->addToolBar(Qt::TopToolBarArea, toolbar);
}
}
@@ -387,10 +392,20 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
if (toolbar == 0)
return;
+#if defined(QT_MAC_USE_COCOA)
+ // toolbar will now become native (if not allready) since we need
+ // an nsview for it inside the corresponding NSToolbarItem.
+ // Setting isInUnifiedToolbar will (among other things) stop alien
+ // siblings from becoming native when this happends since the toolbar
+ // will not overlap with other children of the QMainWindow. NB: Switching
+ // unified toolbar off after this stage is not supported, as this means
+ // that either the menubar must be alien again, or the sibling must
+ // be backed by an nsview to protect from overlapping issues:
+ toolbar->d_func()->isInUnifiedToolbar = true;
+#endif
QToolBarLayout *toolbarLayout = static_cast<QToolBarLayout *>(toolbar->layout());
- toolbarSaveState.insert(toolbar, ToolBarSaveState(toolbar->isMovable(),
- toolbar->maximumSize()));
+ toolbarSaveState.insert(toolbar, ToolBarSaveState(toolbar->isMovable(), toolbar->maximumSize()));
if (toolbarLayout->hasExpandFlag() == false)
toolbar->setMaximumSize(toolbar->sizeHint());
@@ -399,8 +414,8 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
toolbarLayout->setUsePopupMenu(true);
// Make the toolbar a child of the mainwindow to avoid creating a window.
toolbar->setParent(layoutState.mainWindow);
- toolbar->createWinId(); // Now create the OSViewRef.
+ toolbar->winId(); // Now create the OSViewRef.
layoutState.mainWindow->createWinId();
OSWindowRef window = qt_mac_window_for(layoutState.mainWindow);
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index dda5aba..5bfac9a 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -1073,8 +1073,11 @@ void QMenuBar::paintEvent(QPaintEvent *e)
void QMenuBar::setVisible(bool visible)
{
#if defined(Q_WS_MAC) || defined(Q_OS_WINCE) || defined(Q_WS_S60)
- if (isNativeMenuBar())
+ if (isNativeMenuBar()) {
+ if (!visible)
+ QWidget::setVisible(false);
return;
+ }
#endif
QWidget::setVisible(visible);
}
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index d3af9e1..7435691 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -967,7 +967,7 @@ void QPlainTextEditPrivate::_q_adjustScrollbars()
++lineNumber;
}
if (lineNumber < layoutLineCount)
- visibleFromBottom += (layoutLineCount - lineNumber - 1);
+ visibleFromBottom += (layoutLineCount - lineNumber);
break;
}
diff --git a/src/gui/widgets/qscrollbar.cpp b/src/gui/widgets/qscrollbar.cpp
index 67f34eb..c895b1b 100644
--- a/src/gui/widgets/qscrollbar.cpp
+++ b/src/gui/widgets/qscrollbar.cpp
@@ -82,21 +82,21 @@ QT_BEGIN_NAMESPACE
needs.
\table
- \row \i \image qscrollbar-picture.png
- \i Scroll bars typically include four separate controls: a slider,
+ \row \o \image qscrollbar-picture.png
+ \o Scroll bars typically include four separate controls: a slider,
scroll arrows, and a page control.
\list
- \i a. The slider provides a way to quickly go to any part of the
+ \o a. The slider provides a way to quickly go to any part of the
document, but does not support accurate navigation within large
documents.
- \i b. The scroll arrows are push buttons which can be used to accurately
+ \o b. The scroll arrows are push buttons which can be used to accurately
navigate to a particular place in a document. For a vertical scroll bar
connected to a text editor, these typically move the current position one
"line" up or down, and adjust the position of the slider by a small
amount. In editors and list boxes a "line" might mean one line of text;
in an image viewer it might mean 20 pixels.
- \i c. The page control is the area over which the slider is dragged (the
+ \o c. The page control is the area over which the slider is dragged (the
scroll bar's background). Clicking here moves the scroll bar towards
the click by one "page". This value is usually the same as the length of
the slider.
@@ -134,13 +134,12 @@ QT_BEGIN_NAMESPACE
value of 80. This would give us a scroll bar with five "pages".
\table
- \row \i \inlineimage qscrollbar-values.png
- \i The relationship between a document length, the range of values used
+ \row \o \inlineimage qscrollbar-values.png
+ \o The relationship between a document length, the range of values used
in a scroll bar, and the page step is simple in many common situations.
The scroll bar's range of values is determined by subtracting a
chosen page step from some value representing the length of the document.
In such cases, the following equation is useful:
-
\e{document length} = maximum() - minimum() + pageStep().
\endtable
@@ -153,18 +152,18 @@ QT_BEGIN_NAMESPACE
ScrollBar inherits a comprehensive set of signals from QAbstractSlider:
\list
- \i \l{QAbstractSlider::valueChanged()}{valueChanged()} is emitted when the
+ \o \l{QAbstractSlider::valueChanged()}{valueChanged()} is emitted when the
scroll bar's value has changed. The tracking() determines whether this
signal is emitted during user interaction.
- \i \l{QAbstractSlider::rangeChanged()}{rangeChanged()} is emitted when the
+ \o \l{QAbstractSlider::rangeChanged()}{rangeChanged()} is emitted when the
scroll bar's range of values has changed.
- \i \l{QAbstractSlider::sliderPressed()}{sliderPressed()} is emitted when
+ \o \l{QAbstractSlider::sliderPressed()}{sliderPressed()} is emitted when
the user starts to drag the slider.
- \i \l{QAbstractSlider::sliderMoved()}{sliderMoved()} is emitted when the user
+ \o \l{QAbstractSlider::sliderMoved()}{sliderMoved()} is emitted when the user
drags the slider.
- \i \l{QAbstractSlider::sliderReleased()}{sliderReleased()} is emitted when
+ \o \l{QAbstractSlider::sliderReleased()}{sliderReleased()} is emitted when
the user releases the slider.
- \i \l{QAbstractSlider::actionTriggered()}{actionTriggered()} is emitted
+ \o \l{QAbstractSlider::actionTriggered()}{actionTriggered()} is emitted
when the scroll bar is changed by user interaction or via the
\l{QAbstractSlider::triggerAction()}{triggerAction()} function.
\endlist
@@ -173,12 +172,12 @@ QT_BEGIN_NAMESPACE
default focusPolicy() of Qt::NoFocus. Use setFocusPolicy() to
enable keyboard interaction with the scroll bar:
\list
- \i Left/Right move a horizontal scroll bar by one single step.
- \i Up/Down move a vertical scroll bar by one single step.
- \i PageUp moves up one page.
- \i PageDown moves down one page.
- \i Home moves to the start (mininum).
- \i End moves to the end (maximum).
+ \o Left/Right move a horizontal scroll bar by one single step.
+ \o Up/Down move a vertical scroll bar by one single step.
+ \o PageUp moves up one page.
+ \o PageDown moves down one page.
+ \o Home moves to the start (mininum).
+ \o End moves to the end (maximum).
\endlist
The slider itself can be controlled by using the
diff --git a/src/gui/widgets/qsizegrip.cpp b/src/gui/widgets/qsizegrip.cpp
index f2ea1bf..630aecf 100644
--- a/src/gui/widgets/qsizegrip.cpp
+++ b/src/gui/widgets/qsizegrip.cpp
@@ -309,6 +309,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
#ifdef Q_WS_X11
// Use a native X11 sizegrip for "real" top-level windows if supported.
if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE))
+ && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
&& !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
XEvent xev;
xev.xclient.type = ClientMessage;
@@ -420,7 +421,8 @@ void QSizeGrip::mouseMoveEvent(QMouseEvent * e)
#ifdef Q_WS_X11
if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE))
- && tlw->isTopLevel() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth())
+ && tlw->isTopLevel() && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
+ && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth())
return;
#endif
#ifdef Q_WS_WIN
diff --git a/src/imports/gestures/qdeclarativegesturearea.cpp b/src/imports/gestures/qdeclarativegesturearea.cpp
index ba3adc5..1b6e723 100644
--- a/src/imports/gestures/qdeclarativegesturearea.cpp
+++ b/src/imports/gestures/qdeclarativegesturearea.cpp
@@ -86,22 +86,22 @@ public:
A GestureArea is like a MouseArea, but it has signals for gesture events.
- \e {Elements in the Qt.labs module are not guaranteed to remain compatible
- in future versions.}
+ \warning Elements in the Qt.labs module are not guaranteed to remain compatible
+ in future versions.
- \e {This element is only functional on devices with touch input.}
+ \note This element is only functional on devices with touch input.
\qml
import Qt.labs.gestures 1.0
GestureArea {
anchors.fill: parent
- onPan: ... gesture.acceleration ...
- onPinch: ... gesture.rotationAngle ...
- onSwipe: ...
- onTapAndHold: ...
- onTap: ...
- onGesture: ...
+ // onPan: ... gesture.acceleration ...
+ // onPinch: ... gesture.rotationAngle ...
+ // onSwipe: ...
+ // onTapAndHold: ...
+ // onTap: ...
+ // onGesture: ...
}
\endqml
diff --git a/src/multimedia/audio/qaudiooutput_symbian_p.cpp b/src/multimedia/audio/qaudiooutput_symbian_p.cpp
index ea7cd9f..5db7099 100644
--- a/src/multimedia/audio/qaudiooutput_symbian_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_symbian_p.cpp
@@ -436,8 +436,8 @@ void QAudioOutputPrivate::writePaddingData()
unsigned char *ptr = const_cast<unsigned char*>(outputBuffer.Ptr());
Mem::FillZ(ptr, paddingBytes);
outputBuffer.SetLength(outputBuffer.Length() + paddingBytes);
+ Q_ASSERT(m_bytesPadding >= paddingBytes);
m_bytesPadding -= paddingBytes;
- Q_ASSERT(m_bytesPadding >= 0);
if (m_pullMode && m_source->atEnd())
lastBufferFilled();
diff --git a/src/network/access/access.pri b/src/network/access/access.pri
index f8dfda6..7497c1a 100644
--- a/src/network/access/access.pri
+++ b/src/network/access/access.pri
@@ -8,6 +8,7 @@ HEADERS += \
access/qhttpnetworkreply_p.h \
access/qhttpnetworkconnection_p.h \
access/qhttpnetworkconnectionchannel_p.h \
+ access/qnetworkaccessauthenticationmanager_p.h \
access/qnetworkaccessmanager.h \
access/qnetworkaccessmanager_p.h \
access/qnetworkaccesscache_p.h \
@@ -42,6 +43,7 @@ SOURCES += \
access/qhttpnetworkreply.cpp \
access/qhttpnetworkconnection.cpp \
access/qhttpnetworkconnectionchannel.cpp \
+ access/qnetworkaccessauthenticationmanager.cpp \
access/qnetworkaccessmanager.cpp \
access/qnetworkaccesscache.cpp \
access/qnetworkaccessbackend.cpp \
diff --git a/src/network/access/qnetworkaccessauthenticationmanager.cpp b/src/network/access/qnetworkaccessauthenticationmanager.cpp
new file mode 100644
index 0000000..d2bf00a
--- /dev/null
+++ b/src/network/access/qnetworkaccessauthenticationmanager.cpp
@@ -0,0 +1,297 @@
+/****************************************************************************
+**
+** 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 QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the 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 "qnetworkaccessmanager.h"
+#include "qnetworkaccessmanager_p.h"
+#include "qnetworkaccessauthenticationmanager_p.h"
+
+#include "QtCore/qbuffer.h"
+#include "QtCore/qurl.h"
+#include "QtCore/qvector.h"
+#include "QtCore/QMutexLocker"
+#include "QtNetwork/qauthenticator.h"
+
+QT_BEGIN_NAMESPACE
+
+
+
+
+class QNetworkAuthenticationCache: private QVector<QNetworkAuthenticationCredential>,
+ public QNetworkAccessCache::CacheableObject
+{
+public:
+ QNetworkAuthenticationCache()
+ {
+ setExpires(false);
+ setShareable(true);
+ reserve(1);
+ }
+
+ QNetworkAuthenticationCredential *findClosestMatch(const QString &domain)
+ {
+ iterator it = qLowerBound(begin(), end(), domain);
+ if (it == end() && !isEmpty())
+ --it;
+ if (it == end() || !domain.startsWith(it->domain))
+ return 0;
+ return &*it;
+ }
+
+ void insert(const QString &domain, const QString &user, const QString &password)
+ {
+ QNetworkAuthenticationCredential *closestMatch = findClosestMatch(domain);
+ if (closestMatch && closestMatch->domain == domain) {
+ // we're overriding the current credentials
+ closestMatch->user = user;
+ closestMatch->password = password;
+ } else {
+ QNetworkAuthenticationCredential newCredential;
+ newCredential.domain = domain;
+ newCredential.user = user;
+ newCredential.password = password;
+
+ if (closestMatch)
+ QVector<QNetworkAuthenticationCredential>::insert(++closestMatch, newCredential);
+ else
+ QVector<QNetworkAuthenticationCredential>::insert(end(), newCredential);
+ }
+ }
+
+ virtual void dispose() { delete this; }
+};
+
+#ifndef QT_NO_NETWORKPROXY
+static QByteArray proxyAuthenticationKey(const QNetworkProxy &proxy, const QString &realm)
+{
+ QUrl key;
+
+ switch (proxy.type()) {
+ case QNetworkProxy::Socks5Proxy:
+ key.setScheme(QLatin1String("proxy-socks5"));
+ break;
+
+ case QNetworkProxy::HttpProxy:
+ case QNetworkProxy::HttpCachingProxy:
+ key.setScheme(QLatin1String("proxy-http"));
+ break;
+
+ case QNetworkProxy::FtpCachingProxy:
+ key.setScheme(QLatin1String("proxy-ftp"));
+ break;
+
+ case QNetworkProxy::DefaultProxy:
+ case QNetworkProxy::NoProxy:
+ // shouldn't happen
+ return QByteArray();
+
+ // no default:
+ // let there be errors if a new proxy type is added in the future
+ }
+
+ if (key.scheme().isEmpty())
+ // proxy type not handled
+ return QByteArray();
+
+ key.setUserName(proxy.user());
+ key.setHost(proxy.hostName());
+ key.setPort(proxy.port());
+ key.setFragment(realm);
+ return "auth:" + key.toEncoded();
+}
+#endif
+
+static inline QByteArray authenticationKey(const QUrl &url, const QString &realm)
+{
+ QUrl copy = url;
+ copy.setFragment(realm);
+ return "auth:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery);
+}
+
+
+#ifndef QT_NO_NETWORKPROXY
+void QNetworkAccessAuthenticationManager::cacheProxyCredentials(const QNetworkProxy &p,
+ const QAuthenticator *authenticator)
+{
+ Q_ASSERT(authenticator);
+ Q_ASSERT(p.type() != QNetworkProxy::DefaultProxy);
+ Q_ASSERT(p.type() != QNetworkProxy::NoProxy);
+
+ QMutexLocker mutexLocker(&mutex);
+
+ QString realm = authenticator->realm();
+ QNetworkProxy proxy = p;
+ proxy.setUser(authenticator->user());
+ // Set two credentials: one with the username and one without
+ do {
+ // Set two credentials actually: one with and one without the realm
+ do {
+ QByteArray cacheKey = proxyAuthenticationKey(proxy, realm);
+ if (cacheKey.isEmpty())
+ return; // should not happen
+
+ QNetworkAuthenticationCache *auth = new QNetworkAuthenticationCache;
+ auth->insert(QString(), authenticator->user(), authenticator->password());
+ authenticationCache.addEntry(cacheKey, auth); // replace the existing one, if there's any
+
+ if (realm.isEmpty()) {
+ break;
+ } else {
+ realm.clear();
+ }
+ } while (true);
+
+ if (proxy.user().isEmpty())
+ break;
+ else
+ proxy.setUser(QString());
+ } while (true);
+}
+
+QNetworkAuthenticationCredential
+QNetworkAccessAuthenticationManager::fetchCachedProxyCredentials(const QNetworkProxy &p,
+ const QAuthenticator *authenticator)
+{
+ QNetworkProxy proxy = p;
+ if (proxy.type() == QNetworkProxy::DefaultProxy) {
+ proxy = QNetworkProxy::applicationProxy();
+ }
+ if (!proxy.password().isEmpty())
+ return QNetworkAuthenticationCredential(); // no need to set credentials if it already has them
+
+ QString realm;
+ if (authenticator)
+ realm = authenticator->realm();
+
+ QMutexLocker mutexLocker(&mutex);
+ QByteArray cacheKey = proxyAuthenticationKey(proxy, realm);
+ if (cacheKey.isEmpty())
+ return QNetworkAuthenticationCredential();
+ if (!authenticationCache.hasEntry(cacheKey))
+ return QNetworkAuthenticationCredential();
+
+ QNetworkAuthenticationCache *auth =
+ static_cast<QNetworkAuthenticationCache *>(authenticationCache.requestEntryNow(cacheKey));
+ QNetworkAuthenticationCredential cred = *auth->findClosestMatch(QString());
+ authenticationCache.releaseEntry(cacheKey);
+
+ // proxy cache credentials always have exactly one item
+ Q_ASSERT_X(!cred.isNull(), "QNetworkAccessManager",
+ "Internal inconsistency: found a cache key for a proxy, but it's empty");
+ return cred;
+}
+
+#endif
+
+void QNetworkAccessAuthenticationManager::cacheCredentials(const QUrl &url,
+ const QAuthenticator *authenticator)
+{
+ Q_ASSERT(authenticator);
+ QString domain = QString::fromLatin1("/"); // FIXME: make QAuthenticator return the domain
+ QString realm = authenticator->realm();
+
+ QMutexLocker mutexLocker(&mutex);
+
+ // Set two credentials actually: one with and one without the username in the URL
+ QUrl copy = url;
+ copy.setUserName(authenticator->user());
+ do {
+ QByteArray cacheKey = authenticationKey(copy, realm);
+ if (authenticationCache.hasEntry(cacheKey)) {
+ QNetworkAuthenticationCache *auth =
+ static_cast<QNetworkAuthenticationCache *>(authenticationCache.requestEntryNow(cacheKey));
+ auth->insert(domain, authenticator->user(), authenticator->password());
+ authenticationCache.releaseEntry(cacheKey);
+ } else {
+ QNetworkAuthenticationCache *auth = new QNetworkAuthenticationCache;
+ auth->insert(domain, authenticator->user(), authenticator->password());
+ authenticationCache.addEntry(cacheKey, auth);
+ }
+
+ if (copy.userName().isEmpty()) {
+ break;
+ } else {
+ copy.setUserName(QString());
+ }
+ } while (true);
+}
+
+/*!
+ Fetch the credential data from the credential cache.
+
+ If auth is 0 (as it is when called from createRequest()), this will try to
+ look up with an empty realm. That fails in most cases for HTTP (because the
+ realm is seldom empty for HTTP challenges). In any case, QHttpNetworkConnection
+ never sends the credentials on the first attempt: it needs to find out what
+ authentication methods the server supports.
+
+ For FTP, realm is always empty.
+*/
+QNetworkAuthenticationCredential
+QNetworkAccessAuthenticationManager::fetchCachedCredentials(const QUrl &url,
+ const QAuthenticator *authentication)
+{
+ if (!url.password().isEmpty())
+ return QNetworkAuthenticationCredential(); // no need to set credentials if it already has them
+
+ QString realm;
+ if (authentication)
+ realm = authentication->realm();
+
+ QByteArray cacheKey = authenticationKey(url, realm);
+
+ QMutexLocker mutexLocker(&mutex);
+ if (!authenticationCache.hasEntry(cacheKey))
+ return QNetworkAuthenticationCredential();
+
+ QNetworkAuthenticationCache *auth =
+ static_cast<QNetworkAuthenticationCache *>(authenticationCache.requestEntryNow(cacheKey));
+ QNetworkAuthenticationCredential cred = *auth->findClosestMatch(url.path());
+ authenticationCache.releaseEntry(cacheKey);
+ return cred;
+}
+
+void QNetworkAccessAuthenticationManager::clearCache()
+{
+ authenticationCache.clear();
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/network/access/qnetworkaccessauthenticationmanager_p.h b/src/network/access/qnetworkaccessauthenticationmanager_p.h
new file mode 100644
index 0000000..d2347b1
--- /dev/null
+++ b/src/network/access/qnetworkaccessauthenticationmanager_p.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** 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 QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the 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 QNETWORKACCESSAUTHENTICATIONMANAGER_P_H
+#define QNETWORKACCESSAUTHENTICATIONMANAGER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the Network Access API. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qnetworkaccessmanager.h"
+#include "qnetworkaccesscache_p.h"
+#include "qnetworkaccessbackend_p.h"
+#include "QtNetwork/qnetworkproxy.h"
+#include "QtCore/QMutex"
+
+QT_BEGIN_NAMESPACE
+
+class QAuthenticator;
+class QAbstractNetworkCache;
+class QNetworkAuthenticationCredential;
+class QNetworkCookieJar;
+
+class QNetworkAuthenticationCredential
+{
+public:
+ QString domain;
+ QString user;
+ QString password;
+ bool isNull() {
+ return domain.isNull();
+ }
+};
+Q_DECLARE_TYPEINFO(QNetworkAuthenticationCredential, Q_MOVABLE_TYPE);
+inline bool operator<(const QNetworkAuthenticationCredential &t1, const QString &t2)
+{ return t1.domain < t2; }
+
+class QNetworkAccessAuthenticationManager
+{
+public:
+ QNetworkAccessAuthenticationManager() { };
+
+ void cacheCredentials(const QUrl &url, const QAuthenticator *auth);
+ QNetworkAuthenticationCredential fetchCachedCredentials(const QUrl &url,
+ const QAuthenticator *auth = 0);
+
+#ifndef QT_NO_NETWORKPROXY
+ void cacheProxyCredentials(const QNetworkProxy &proxy, const QAuthenticator *auth);
+ QNetworkAuthenticationCredential fetchCachedProxyCredentials(const QNetworkProxy &proxy,
+ const QAuthenticator *auth = 0);
+#endif
+
+ void clearCache();
+
+protected:
+ QNetworkAccessCache authenticationCache;
+ QMutex mutex;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp
index fd1fa60..53ae29e 100644
--- a/src/network/access/qnetworkaccessbackend.cpp
+++ b/src/network/access/qnetworkaccessbackend.cpp
@@ -329,7 +329,7 @@ void QNetworkAccessBackend::authenticationRequired(QAuthenticator *authenticator
void QNetworkAccessBackend::cacheCredentials(QAuthenticator *authenticator)
{
- manager->cacheCredentials(this->reply->url, authenticator);
+ manager->authenticationManager->cacheCredentials(this->reply->url, authenticator);
}
void QNetworkAccessBackend::metaDataChanged()
diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp
index bad010f..e34e6bb 100644
--- a/src/network/access/qnetworkaccessftpbackend.cpp
+++ b/src/network/access/qnetworkaccessftpbackend.cpp
@@ -307,8 +307,10 @@ void QNetworkAccessFtpBackend::ftpDone()
// logged in successfully, send the stat requests (if supported)
QString command = url().path();
command.prepend(QLatin1String("%1 "));
- if (supportsSize)
+ if (supportsSize) {
+ ftp->rawCommand(QLatin1String("TYPE I"));
sizeId = ftp->rawCommand(command.arg(QLatin1String("SIZE"))); // get size
+ }
if (supportsMdtm)
mdtmId = ftp->rawCommand(command.arg(QLatin1String("MDTM"))); // get modified time
if (!supportsSize && !supportsMdtm)
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 27b7945..22f62cb 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -48,6 +48,7 @@
#include "qabstractnetworkcache.h"
#include "QtNetwork/qnetworksession.h"
+#include "QtNetwork/private/qsharednetworksession_p.h"
#include "qnetworkaccesshttpbackend_p.h"
#include "qnetworkaccessftpbackend_p.h"
@@ -340,107 +341,6 @@ static void ensureInitialized()
QNetworkReply::sslConfiguration(), QNetworkReply::ignoreSslErrors()
*/
-class QNetworkAuthenticationCredential
-{
-public:
- QString domain;
- QString user;
- QString password;
-};
-Q_DECLARE_TYPEINFO(QNetworkAuthenticationCredential, Q_MOVABLE_TYPE);
-inline bool operator<(const QNetworkAuthenticationCredential &t1, const QString &t2)
-{ return t1.domain < t2; }
-
-class QNetworkAuthenticationCache: private QVector<QNetworkAuthenticationCredential>,
- public QNetworkAccessCache::CacheableObject
-{
-public:
- QNetworkAuthenticationCache()
- {
- setExpires(false);
- setShareable(true);
- reserve(1);
- }
-
- QNetworkAuthenticationCredential *findClosestMatch(const QString &domain)
- {
- iterator it = qLowerBound(begin(), end(), domain);
- if (it == end() && !isEmpty())
- --it;
- if (it == end() || !domain.startsWith(it->domain))
- return 0;
- return &*it;
- }
-
- void insert(const QString &domain, const QString &user, const QString &password)
- {
- QNetworkAuthenticationCredential *closestMatch = findClosestMatch(domain);
- if (closestMatch && closestMatch->domain == domain) {
- // we're overriding the current credentials
- closestMatch->user = user;
- closestMatch->password = password;
- } else {
- QNetworkAuthenticationCredential newCredential;
- newCredential.domain = domain;
- newCredential.user = user;
- newCredential.password = password;
-
- if (closestMatch)
- QVector<QNetworkAuthenticationCredential>::insert(++closestMatch, newCredential);
- else
- QVector<QNetworkAuthenticationCredential>::insert(end(), newCredential);
- }
- }
-
- virtual void dispose() { delete this; }
-};
-
-#ifndef QT_NO_NETWORKPROXY
-static QByteArray proxyAuthenticationKey(const QNetworkProxy &proxy, const QString &realm)
-{
- QUrl key;
-
- switch (proxy.type()) {
- case QNetworkProxy::Socks5Proxy:
- key.setScheme(QLatin1String("proxy-socks5"));
- break;
-
- case QNetworkProxy::HttpProxy:
- case QNetworkProxy::HttpCachingProxy:
- key.setScheme(QLatin1String("proxy-http"));
- break;
-
- case QNetworkProxy::FtpCachingProxy:
- key.setScheme(QLatin1String("proxy-ftp"));
- break;
-
- case QNetworkProxy::DefaultProxy:
- case QNetworkProxy::NoProxy:
- // shouldn't happen
- return QByteArray();
-
- // no default:
- // let there be errors if a new proxy type is added in the future
- }
-
- if (key.scheme().isEmpty())
- // proxy type not handled
- return QByteArray();
-
- key.setUserName(proxy.user());
- key.setHost(proxy.hostName());
- key.setPort(proxy.port());
- key.setFragment(realm);
- return "auth:" + key.toEncoded();
-}
-#endif
-
-static inline QByteArray authenticationKey(const QUrl &url, const QString &realm)
-{
- QUrl copy = url;
- copy.setFragment(realm);
- return "auth:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery);
-}
/*!
Constructs a QNetworkAccessManager object that is the center of
@@ -1123,10 +1023,10 @@ void QNetworkAccessManagerPrivate::authenticationRequired(QNetworkAccessBackend
// also called when last URL is empty, e.g. on first call
if (backend->reply->urlForLastAuthentication.isEmpty()
|| url != backend->reply->urlForLastAuthentication) {
- QNetworkAuthenticationCredential *cred = fetchCachedCredentials(url, authenticator);
- if (cred) {
- authenticator->setUser(cred->user);
- authenticator->setPassword(cred->password);
+ QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedCredentials(url, authenticator);
+ if (!cred.isNull()) {
+ authenticator->setUser(cred.user);
+ authenticator->setPassword(cred.password);
backend->reply->urlForLastAuthentication = url;
return;
}
@@ -1139,7 +1039,7 @@ void QNetworkAccessManagerPrivate::authenticationRequired(QNetworkAccessBackend
backend->reply->urlForLastAuthentication = url;
emit q->authenticationRequired(backend->reply->q_func(), authenticator);
- cacheCredentials(url, authenticator);
+ authenticationManager->cacheCredentials(url, authenticator);
}
#ifndef QT_NO_NETWORKPROXY
@@ -1156,10 +1056,10 @@ void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(QNetworkAccessBac
// possible solution: some tracking inside the authenticator
// or a new function proxyAuthenticationSucceeded(true|false)
if (proxy != backend->reply->lastProxyAuthentication) {
- QNetworkAuthenticationCredential *cred = fetchCachedProxyCredentials(proxy);
- if (cred) {
- authenticator->setUser(cred->user);
- authenticator->setPassword(cred->password);
+ QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedProxyCredentials(proxy);
+ if (!cred.isNull()) {
+ authenticator->setUser(cred.user);
+ authenticator->setPassword(cred.password);
return;
}
}
@@ -1171,75 +1071,7 @@ void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(QNetworkAccessBac
backend->reply->lastProxyAuthentication = proxy;
emit q->proxyAuthenticationRequired(proxy, authenticator);
- cacheProxyCredentials(proxy, authenticator);
-}
-
-void QNetworkAccessManagerPrivate::cacheProxyCredentials(const QNetworkProxy &p,
- const QAuthenticator *authenticator)
-{
- Q_ASSERT(authenticator);
- Q_ASSERT(p.type() != QNetworkProxy::DefaultProxy);
- Q_ASSERT(p.type() != QNetworkProxy::NoProxy);
-
- QString realm = authenticator->realm();
- QNetworkProxy proxy = p;
- proxy.setUser(authenticator->user());
- // Set two credentials: one with the username and one without
- do {
- // Set two credentials actually: one with and one without the realm
- do {
- QByteArray cacheKey = proxyAuthenticationKey(proxy, realm);
- if (cacheKey.isEmpty())
- return; // should not happen
-
- QNetworkAuthenticationCache *auth = new QNetworkAuthenticationCache;
- auth->insert(QString(), authenticator->user(), authenticator->password());
- objectCache.addEntry(cacheKey, auth); // replace the existing one, if there's any
-
- if (realm.isEmpty()) {
- break;
- } else {
- realm.clear();
- }
- } while (true);
-
- if (proxy.user().isEmpty())
- break;
- else
- proxy.setUser(QString());
- } while (true);
-}
-
-QNetworkAuthenticationCredential *
-QNetworkAccessManagerPrivate::fetchCachedProxyCredentials(const QNetworkProxy &p,
- const QAuthenticator *authenticator)
-{
- QNetworkProxy proxy = p;
- if (proxy.type() == QNetworkProxy::DefaultProxy) {
- proxy = QNetworkProxy::applicationProxy();
- }
- if (!proxy.password().isEmpty())
- return 0; // no need to set credentials if it already has them
-
- QString realm;
- if (authenticator)
- realm = authenticator->realm();
-
- QByteArray cacheKey = proxyAuthenticationKey(proxy, realm);
- if (cacheKey.isEmpty())
- return 0;
- if (!objectCache.hasEntry(cacheKey))
- return 0;
-
- QNetworkAuthenticationCache *auth =
- static_cast<QNetworkAuthenticationCache *>(objectCache.requestEntryNow(cacheKey));
- QNetworkAuthenticationCredential *cred = auth->findClosestMatch(QString());
- objectCache.releaseEntry(cacheKey);
-
- // proxy cache credentials always have exactly one item
- Q_ASSERT_X(cred, "QNetworkAccessManager",
- "Internal inconsistency: found a cache key for a proxy, but it's empty");
- return cred;
+ authenticationManager->cacheProxyCredentials(proxy, authenticator);
}
QList<QNetworkProxy> QNetworkAccessManagerPrivate::queryProxy(const QNetworkProxyQuery &query)
@@ -1263,73 +1095,10 @@ QList<QNetworkProxy> QNetworkAccessManagerPrivate::queryProxy(const QNetworkProx
}
#endif
-void QNetworkAccessManagerPrivate::cacheCredentials(const QUrl &url,
- const QAuthenticator *authenticator)
-{
- Q_ASSERT(authenticator);
- QString domain = QString::fromLatin1("/"); // FIXME: make QAuthenticator return the domain
- QString realm = authenticator->realm();
-
- // Set two credentials actually: one with and one without the username in the URL
- QUrl copy = url;
- copy.setUserName(authenticator->user());
- do {
- QByteArray cacheKey = authenticationKey(copy, realm);
- if (objectCache.hasEntry(cacheKey)) {
- QNetworkAuthenticationCache *auth =
- static_cast<QNetworkAuthenticationCache *>(objectCache.requestEntryNow(cacheKey));
- auth->insert(domain, authenticator->user(), authenticator->password());
- objectCache.releaseEntry(cacheKey);
- } else {
- QNetworkAuthenticationCache *auth = new QNetworkAuthenticationCache;
- auth->insert(domain, authenticator->user(), authenticator->password());
- objectCache.addEntry(cacheKey, auth);
- }
-
- if (copy.userName().isEmpty()) {
- break;
- } else {
- copy.setUserName(QString());
- }
- } while (true);
-}
-
-/*!
- Fetch the credential data from the credential cache.
-
- If auth is 0 (as it is when called from createRequest()), this will try to
- look up with an empty realm. That fails in most cases for HTTP (because the
- realm is seldom empty for HTTP challenges). In any case, QHttpNetworkConnection
- never sends the credentials on the first attempt: it needs to find out what
- authentication methods the server supports.
-
- For FTP, realm is always empty.
-*/
-QNetworkAuthenticationCredential *
-QNetworkAccessManagerPrivate::fetchCachedCredentials(const QUrl &url,
- const QAuthenticator *authentication)
-{
- if (!url.password().isEmpty())
- return 0; // no need to set credentials if it already has them
-
- QString realm;
- if (authentication)
- realm = authentication->realm();
-
- QByteArray cacheKey = authenticationKey(url, realm);
- if (!objectCache.hasEntry(cacheKey))
- return 0;
-
- QNetworkAuthenticationCache *auth =
- static_cast<QNetworkAuthenticationCache *>(objectCache.requestEntryNow(cacheKey));
- QNetworkAuthenticationCredential *cred = auth->findClosestMatch(url.path());
- objectCache.releaseEntry(cacheKey);
- return cred;
-}
-
void QNetworkAccessManagerPrivate::clearCache(QNetworkAccessManager *manager)
{
manager->d_func()->objectCache.clear();
+ manager->d_func()->authenticationManager->clearCache();
}
QNetworkAccessManagerPrivate::~QNetworkAccessManagerPrivate()
@@ -1343,11 +1112,8 @@ void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &co
initializeSession = false;
- if (networkSession)
- delete networkSession;
-
if (!config.isValid()) {
- networkSession = 0;
+ networkSession.clear();
online = false;
if (networkAccessible == QNetworkAccessManager::NotAccessible)
@@ -1358,18 +1124,13 @@ void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &co
return;
}
- networkSession = new QNetworkSession(config, q);
+ networkSession = QSharedNetworkSessionManager::getSession(config);
- QObject::connect(networkSession, SIGNAL(opened()), q, SIGNAL(networkSessionConnected()));
- QObject::connect(networkSession, SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()));
- QObject::connect(networkSession, SIGNAL(stateChanged(QNetworkSession::State)),
- q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)));
- QObject::connect(networkSession, SIGNAL(newConfigurationActivated()),
- q, SLOT(_q_networkSessionNewConfigurationActivated()));
- QObject::connect(networkSession,
- SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)),
- q,
- SLOT(_q_networkSessionPreferredConfigurationChanged(QNetworkConfiguration,bool)));
+ QObject::connect(networkSession.data(), SIGNAL(opened()), q, SIGNAL(networkSessionConnected()), Qt::QueuedConnection);
+ //QueuedConnection is used to avoid deleting the networkSession inside its closed signal
+ QObject::connect(networkSession.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()), Qt::QueuedConnection);
+ QObject::connect(networkSession.data(), SIGNAL(stateChanged(QNetworkSession::State)),
+ q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)), Qt::QueuedConnection);
_q_networkSessionStateChanged(networkSession->state());
}
@@ -1379,32 +1140,16 @@ void QNetworkAccessManagerPrivate::_q_networkSessionClosed()
if (networkSession) {
networkConfiguration = networkSession->configuration().identifier();
- networkSession->deleteLater();
- networkSession = 0;
- }
-}
-
-void QNetworkAccessManagerPrivate::_q_networkSessionNewConfigurationActivated()
-{
- Q_Q(QNetworkAccessManager);
-
- if (networkSession) {
- networkSession->accept();
-
- emit q->networkSessionConnected();
+ networkSession.clear();
}
}
-void QNetworkAccessManagerPrivate::_q_networkSessionPreferredConfigurationChanged(const QNetworkConfiguration &, bool)
-{
- if (networkSession)
- networkSession->migrate();
-}
-
void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession::State state)
{
Q_Q(QNetworkAccessManager);
+ if (state == QNetworkSession::Connected)
+ emit q->networkSessionConnected();
if (online) {
if (state != QNetworkSession::Connected && state != QNetworkSession::Roaming) {
online = false;
diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h
index f3e502c..7ef009f 100644
--- a/src/network/access/qnetworkaccessmanager.h
+++ b/src/network/access/qnetworkaccessmanager.h
@@ -161,8 +161,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_replySslErrors(QList<QSslError>))
#if !defined(QT_NO_BEARERMANAGEMENT) && !defined(QT_MOBILITY_BEARER)
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionClosed())
- Q_PRIVATE_SLOT(d_func(), void _q_networkSessionNewConfigurationActivated())
- Q_PRIVATE_SLOT(d_func(), void _q_networkSessionPreferredConfigurationChanged(QNetworkConfiguration,bool))
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionStateChanged(QNetworkSession::State))
#endif
};
diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h
index ee16c25..dba1fd2 100644
--- a/src/network/access/qnetworkaccessmanager_p.h
+++ b/src/network/access/qnetworkaccessmanager_p.h
@@ -59,6 +59,7 @@
#include "private/qobject_p.h"
#include "QtNetwork/qnetworkproxy.h"
#include "QtNetwork/qnetworksession.h"
+#include "qnetworkaccessauthenticationmanager_p.h"
QT_BEGIN_NAMESPACE
@@ -81,7 +82,8 @@ public:
online(false),
initializeSession(true),
#endif
- cookieJarCreated(false)
+ cookieJarCreated(false),
+ authenticationManager(new QNetworkAccessAuthenticationManager)
{ }
~QNetworkAccessManagerPrivate();
@@ -128,7 +130,7 @@ public:
#endif
#ifndef QT_NO_BEARERMANAGEMENT
- QNetworkSession *networkSession;
+ QSharedPointer<QNetworkSession> networkSession;
QString networkConfiguration;
QNetworkAccessManager::NetworkAccessibility networkAccessible;
bool online;
@@ -137,6 +139,9 @@ public:
bool cookieJarCreated;
+ // The cache with authorization data:
+ QNetworkAccessAuthenticationManager* authenticationManager;
+
// this cache can be used by individual backends to cache e.g. their TCP connections to a server
// and use the connections for multiple requests.
QNetworkAccessCache objectCache;
diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp
index d35f0ce..2040b01 100644
--- a/src/network/access/qnetworkdiskcache.cpp
+++ b/src/network/access/qnetworkdiskcache.cpp
@@ -404,7 +404,7 @@ QIODevice *QNetworkDiskCache::data(const QUrl &url)
// ### verify that QFile uses the fd size and not the file name
qint64 size = file->size() - file->pos();
const uchar *p = 0;
-#ifndef Q_OS_WINCE
+#if !defined(Q_OS_WINCE) && !defined(Q_OS_INTEGRITY)
p = file->map(file->pos(), size);
#endif
if (p) {
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 50dbcc2..41a6c62 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -97,7 +97,7 @@ void QNetworkReplyImplPrivate::_q_startOperation()
// state changes.
state = WaitingForSession;
- QNetworkSession *session = manager->d_func()->networkSession;
+ QNetworkSession *session = manager->d_func()->networkSession.data();
if (session) {
Q_Q(QNetworkReplyImpl);
@@ -115,7 +115,7 @@ void QNetworkReplyImplPrivate::_q_startOperation()
}
#endif
- if (backend->isSynchronous()) {
+ if (backend && backend->isSynchronous()) {
state = Finished;
q_func()->setFinished(true);
} else {
@@ -257,7 +257,7 @@ void QNetworkReplyImplPrivate::_q_networkSessionConnected()
if (manager.isNull())
return;
- QNetworkSession *session = manager->d_func()->networkSession;
+ QNetworkSession *session = manager->d_func()->networkSession.data();
if (!session)
return;
@@ -307,7 +307,7 @@ void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const
// in QtWebKit.
QVariant synchronousHttpAttribute = req.attribute(
static_cast<QNetworkRequest::Attribute>(QNetworkRequest::DownloadBufferAttribute + 1));
- if (synchronousHttpAttribute.toBool()) {
+ if (backend && synchronousHttpAttribute.toBool()) {
backend->setSynchronous(true);
if (outgoingData && outgoingData->isSequential()) {
outgoingDataBuffer = new QRingBuffer();
@@ -362,7 +362,7 @@ void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const
QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
}
#else
- if (backend->isSynchronous())
+ if (backend && backend->isSynchronous())
_q_startOperation();
else
QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
@@ -693,7 +693,7 @@ void QNetworkReplyImplPrivate::finished()
if (!manager.isNull()) {
#ifndef QT_NO_BEARERMANAGEMENT
- QNetworkSession *session = manager->d_func()->networkSession;
+ QNetworkSession *session = manager->d_func()->networkSession.data();
if (session && session->state() == QNetworkSession::Roaming &&
state == Working && errorCode != QNetworkReply::OperationCanceledError) {
// only content with a known size will fail with a temporary network failure error
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index fc33e8d..8d46003 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -529,8 +529,9 @@ QSslConfiguration QNetworkRequest::sslConfiguration() const
/*!
Sets this network request's SSL configuration to be \a config. The
settings that apply are the private key, the local certificate,
- the SSL protocol (SSLv2, SSLv3, TLSv1 where applicable) and the
- ciphers that the SSL backend is allowed to use.
+ the SSL protocol (SSLv2, SSLv3, TLSv1 where applicable), the CA
+ certificates and the ciphers that the SSL backend is allowed to
+ use.
By default, no SSL configuration is set, which allows the backends
to choose freely what configuration is best for them.
diff --git a/src/network/bearer/bearer.pri b/src/network/bearer/bearer.pri
index bc5b0b5..d58d5ec 100644
--- a/src/network/bearer/bearer.pri
+++ b/src/network/bearer/bearer.pri
@@ -7,11 +7,13 @@ HEADERS += bearer/qnetworkconfiguration.h \
bearer/qnetworkconfiguration_p.h \
bearer/qnetworksession_p.h \
bearer/qbearerengine_p.h \
- bearer/qbearerplugin_p.h
+ bearer/qbearerplugin_p.h \
+ bearer/qsharednetworksession_p.h
SOURCES += bearer/qnetworksession.cpp \
bearer/qnetworkconfigmanager.cpp \
bearer/qnetworkconfiguration.cpp \
bearer/qnetworkconfigmanager_p.cpp \
bearer/qbearerengine.cpp \
- bearer/qbearerplugin.cpp
+ bearer/qbearerplugin.cpp \
+ bearer/qsharednetworksession.cpp
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index 9927f29..2a46229 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -57,16 +57,17 @@ QT_BEGIN_NAMESPACE
{ \
delete this_##NAME.pointer; \
this_##NAME.pointer = 0; \
- this_##NAME.destroyed = true; \
} \
static TYPE *NAME() \
{ \
- if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
+ if (!this_##NAME.pointer) { \
TYPE *x = new TYPE; \
if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \
delete x; \
- else \
+ else { \
qAddPostRoutine(NAME##_cleanup); \
+ this_##NAME.pointer->updateConfigurations(); \
+ } \
} \
return this_##NAME.pointer; \
}
@@ -75,15 +76,7 @@ Q_GLOBAL_STATIC_QAPP_DESTRUCTION(QNetworkConfigurationManagerPrivate, connManage
QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
{
- static bool initialized = false;
-
- QNetworkConfigurationManagerPrivate *m = connManager();
- if (!initialized) {
- initialized = true;
- m->updateConfigurations();
- }
-
- return m;
+ return connManager();
}
/*!
diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp
index 143d9b5..af60a43 100644
--- a/src/network/bearer/qnetworksession.cpp
+++ b/src/network/bearer/qnetworksession.cpp
@@ -250,6 +250,9 @@ QNetworkSession::QNetworkSession(const QNetworkConfiguration &connectionConfig,
}
}
}
+
+ qRegisterMetaType<QNetworkSession::State>();
+ qRegisterMetaType<QNetworkSession::SessionError>();
}
/*!
@@ -677,7 +680,7 @@ void QNetworkSession::connectNotify(const char *signal)
//check for preferredConfigurationChanged() signal connect notification
//This is not required on all platforms
- if (QLatin1String(signal) == SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)))
+ if (qstrcmp(signal, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool))) == 0)
d->setALREnabled(true);
}
@@ -698,7 +701,7 @@ void QNetworkSession::disconnectNotify(const char *signal)
//check for preferredConfigurationChanged() signal disconnect notification
//This is not required on all platforms
- if (QLatin1String(signal) == SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)))
+ if (qstrcmp(signal, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool))) == 0)
d->setALREnabled(false);
}
diff --git a/src/network/bearer/qnetworksession.h b/src/network/bearer/qnetworksession.h
index a4baec3..688f37e 100644
--- a/src/network/bearer/qnetworksession.h
+++ b/src/network/bearer/qnetworksession.h
@@ -142,6 +142,8 @@ private:
#ifndef QT_MOBILITY_BEARER
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QNetworkSession::State)
+Q_DECLARE_METATYPE(QNetworkSession::SessionError)
#else
QTM_END_NAMESPACE
#endif
diff --git a/src/network/bearer/qsharednetworksession.cpp b/src/network/bearer/qsharednetworksession.cpp
new file mode 100644
index 0000000..51b3a32
--- /dev/null
+++ b/src/network/bearer/qsharednetworksession.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the 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 "qsharednetworksession_p.h"
+#include "qbearerengine_p.h"
+#include <QThreadStorage>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+
+QT_BEGIN_NAMESPACE
+
+QThreadStorage<QSharedNetworkSessionManager *> tls;
+
+inline QSharedNetworkSessionManager* sharedNetworkSessionManager()
+{
+ QSharedNetworkSessionManager* rv = tls.localData();
+ if (!rv) {
+ rv = new QSharedNetworkSessionManager;
+ tls.setLocalData(rv);
+ }
+ return rv;
+}
+
+QSharedPointer<QNetworkSession> QSharedNetworkSessionManager::getSession(QNetworkConfiguration config)
+{
+ QSharedNetworkSessionManager *m(sharedNetworkSessionManager());
+ //if already have a session, return it
+ if (m->sessions.contains(config)) {
+ QSharedPointer<QNetworkSession> p = m->sessions.value(config).toStrongRef();
+ if (!p.isNull())
+ return p;
+ }
+ //otherwise make one
+ QSharedPointer<QNetworkSession> session(new QNetworkSession(config));
+ m->sessions[config] = session;
+ return session;
+}
+
+void QSharedNetworkSessionManager::setSession(QNetworkConfiguration config, QSharedPointer<QNetworkSession> session)
+{
+ QSharedNetworkSessionManager *m(sharedNetworkSessionManager());
+ m->sessions[config] = session;
+}
+
+uint qHash(const QNetworkConfiguration& config)
+{
+ return ((uint)config.type()) | (((uint)config.bearerType()) << 8) | (((uint)config.purpose()) << 16);
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/network/bearer/qsharednetworksession_p.h b/src/network/bearer/qsharednetworksession_p.h
new file mode 100644
index 0000000..dc84166
--- /dev/null
+++ b/src/network/bearer/qsharednetworksession_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the 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 QSHAREDNETWORKSESSIONPRIVATE_H
+#define QSHAREDNETWORKSESSIONPRIVATE_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 "qnetworksession.h"
+#include "qnetworkconfiguration.h"
+#include <QHash>
+#include <QSharedPointer>
+#include <QWeakPointer>
+#include <QMutex>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+
+QT_BEGIN_NAMESPACE
+
+class QSharedNetworkSessionManager
+{
+public:
+ static QSharedPointer<QNetworkSession> getSession(QNetworkConfiguration config);
+ static void setSession(QNetworkConfiguration config, QSharedPointer<QNetworkSession> session);
+private:
+ QHash<QNetworkConfiguration, QWeakPointer<QNetworkSession> > sessions;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_BEARERMANAGEMENT
+
+#endif //QSHAREDNETWORKSESSIONPRIVATE_H
+
diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri
index 66e87c9..bd3e6ec 100644
--- a/src/network/kernel/kernel.pri
+++ b/src/network/kernel/kernel.pri
@@ -23,6 +23,7 @@ SOURCES += kernel/qauthenticator.cpp \
symbian: SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_symbian.cpp
unix:!symbian:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
win32:SOURCES += kernel/qhostinfo_win.cpp kernel/qnetworkinterface_win.cpp
+integrity:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
mac:LIBS_PRIVATE += -framework SystemConfiguration -framework CoreFoundation
mac:SOURCES += kernel/qnetworkproxy_mac.cpp
diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp
index 73143e1..d61d3b7 100644
--- a/src/network/kernel/qauthenticator.cpp
+++ b/src/network/kernel/qauthenticator.cpp
@@ -213,24 +213,6 @@ void QAuthenticator::setUser(const QString &user)
int separatorPosn = 0;
switch(d->method) {
- case QAuthenticatorPrivate::DigestMd5:
- if((separatorPosn = user.indexOf(QLatin1String("\\"))) != -1) {
- //domain name is present
- d->userDomain.clear();
- d->realm = user.left(separatorPosn);
- d->user = user.mid(separatorPosn + 1);
- } else if((separatorPosn = user.indexOf(QLatin1String("@"))) != -1) {
- //domain name is present
- d->userDomain.clear();
- d->realm = user.mid(separatorPosn + 1);
- d->user = user.left(separatorPosn);
- } else {
- d->user = user;
- d->realm.clear();
- d->userDomain.clear();
- }
- break;
-
case QAuthenticatorPrivate::Ntlm:
if((separatorPosn = user.indexOf(QLatin1String("\\"))) != -1) {
//domain name is present
@@ -253,6 +235,7 @@ void QAuthenticator::setUser(const QString &user)
break;
default:
d->user = user;
+ d->userDomain.clear();
break;
}
}
diff --git a/src/network/kernel/qnetworkinterface_symbian.cpp b/src/network/kernel/qnetworkinterface_symbian.cpp
index 03133d0..8e5db3c 100644
--- a/src/network/kernel/qnetworkinterface_symbian.cpp
+++ b/src/network/kernel/qnetworkinterface_symbian.cpp
@@ -43,7 +43,7 @@
#include "qnetworkinterface.h"
#include "qnetworkinterface_p.h"
-#include "../corelib/kernel/qcore_symbian_p.h"
+#include <private/qcore_symbian_p.h>
#ifndef QT_NO_NETWORKINTERFACE
diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp
index 8fa4b92..9a2b0ba 100644
--- a/src/network/socket/qlocalsocket.cpp
+++ b/src/network/socket/qlocalsocket.cpp
@@ -346,7 +346,7 @@ QLocalSocket::QLocalSocket(QObject * parent)
QLocalSocket::~QLocalSocket()
{
close();
-#ifndef Q_OS_WIN
+#if !defined(Q_OS_WIN) && !defined(QT_LOCALSOCKET_TCP)
Q_D(QLocalSocket);
d->unixSocket.setParent(0);
#endif
diff --git a/src/network/socket/socket.pri b/src/network/socket/socket.pri
index 2bafe13..3ccc8e0 100644
--- a/src/network/socket/socket.pri
+++ b/src/network/socket/socket.pri
@@ -43,3 +43,13 @@ wince*: {
DEFINES += QT_LOCALSOCKET_TCP
}
+
+integrity: {
+ SOURCES -= socket/qlocalsocket_unix.cpp \
+ socket/qlocalserver_unix.cpp
+ SOURCES += socket/qlocalsocket_tcp.cpp \
+ socket/qlocalserver_tcp.cpp \
+ socket/qnativesocketengine_unix.cpp
+
+ DEFINES += QT_LOCALSOCKET_TCP
+}
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index 7d21bd3..84e14ff 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -780,6 +780,7 @@ QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates()
systemCerts.append(QSslCertificate::fromData(rawCert, QSsl::Der));
}
}
+ CFRelease(cfCerts);
}
else {
// no detailed error handling here
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index cc02eb7..bbb75bc 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -102,7 +102,7 @@ extern Q_GUI_EXPORT bool qt_cleartype_enabled;
extern bool qt_applefontsmoothing_enabled;
#endif
-Q_DECL_IMPORT extern QImage qt_imageForBrush(int brushStyle, bool invert);
+Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert);
////////////////////////////////// Private Methods //////////////////////////////////////////
@@ -1174,7 +1174,7 @@ void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush)
d->fill(path);
}
-extern Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp
+Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp
void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
@@ -1503,7 +1503,7 @@ namespace {
{
public:
QOpenGLStaticTextUserData()
- : QStaticTextUserData(OpenGLUserData), cacheSize(0, 0)
+ : QStaticTextUserData(OpenGLUserData), cacheSize(0, 0), cacheSerialNumber(0)
{
}
@@ -1515,6 +1515,7 @@ namespace {
QGL2PEXVertexArray vertexCoordinateArray;
QGL2PEXVertexArray textureCoordinateArray;
QFontEngineGlyphCache::Type glyphType;
+ int cacheSerialNumber;
};
}
@@ -1538,8 +1539,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
staticTextItem->fontEngine()->setGlyphCache(cacheKey, cache);
cache->insert(ctx, cache);
recreateVertexArrays = true;
- } else if (cache->context() == 0) { // Old context has been destroyed, new context has same ptr value
- cache->setContext(ctx);
}
if (staticTextItem->userDataNeedsUpdate) {
@@ -1550,8 +1549,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
recreateVertexArrays = true;
} else {
QOpenGLStaticTextUserData *userData = static_cast<QOpenGLStaticTextUserData *>(staticTextItem->userData());
- if (userData->glyphType != glyphType)
+ if (userData->glyphType != glyphType) {
recreateVertexArrays = true;
+ } else if (userData->cacheSerialNumber != cache->serialNumber()) {
+ recreateVertexArrays = true;
+ }
}
// We only need to update the cache with new glyphs if we are actually going to recreate the vertex arrays.
@@ -1592,6 +1594,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
}
userData->glyphType = glyphType;
+ userData->cacheSerialNumber = cache->serialNumber();
// Use cache if backend optimizations is turned on
vertexCoordinates = &userData->vertexCoordinateArray;
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
index eb38947..4362c0a 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
@@ -53,12 +53,15 @@ QT_BEGIN_NAMESPACE
extern Q_GUI_EXPORT bool qt_cleartype_enabled;
#endif
+QBasicAtomicInt qgltextureglyphcache_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1);
+
QGLTextureGlyphCache::QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix)
: QImageTextureGlyphCache(type, matrix), QGLContextGroupResourceBase()
, ctx(0)
, pex(0)
, m_blitProgram(0)
, m_filterMode(Nearest)
+ , m_serialNumber(qgltextureglyphcache_serial_number.fetchAndAddRelaxed(1))
{
#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG
qDebug(" -> QGLTextureGlyphCache() %p for context %p.", this, ctx);
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
index c5c8985..cc6de28 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
@@ -133,6 +133,8 @@ public:
void setContext(const QGLContext *context);
inline const QGLContext *context() const { return ctx; }
+ inline int serialNumber() const { return m_serialNumber; }
+
enum FilterMode {
Nearest,
Linear
@@ -152,6 +154,8 @@ private:
GLfloat m_vertexCoordinateArray[8];
GLfloat m_textureCoordinateArray[8];
+
+ int m_serialNumber;
};
QT_END_NAMESPACE
diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro
index 8b587cf..08ae774 100644
--- a/src/opengl/opengl.pro
+++ b/src/opengl/opengl.pro
@@ -163,6 +163,13 @@ symbian {
HEADERS += qgl_egl_p.h
+ contains(QT_CONFIG, freetype) {
+ DEFINES += QT_NO_FONTCONFIG
+ INCLUDEPATH += \
+ ../3rdparty/freetype/src \
+ ../3rdparty/freetype/include
+ }
+
symbian:TARGET.UID3 = 0x2002131A
}
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index ffde515..cd23847 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1791,7 +1791,7 @@ static void convertFromGLImage(QImage &img, int w, int h, bool alpha_format, boo
QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha)
{
- QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32
+ QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32_Premultiplied
: QImage::Format_RGB32);
int w = size.width();
int h = size.height();
diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp
index 82b66f5..a9e2248 100644
--- a/src/opengl/qgl_symbian.cpp
+++ b/src/opengl/qgl_symbian.cpp
@@ -44,12 +44,14 @@
#include <coemain.h>
#include <coecntrl.h>
#include <w32std.h>
+#include <private/qt_s60_p.h>
#include <private/qpixmap_s60_p.h>
#include <private/qimagepixmapcleanuphooks_p.h>
#include <private/qgl_p.h>
#include <private/qpaintengine_opengl_p.h>
#include <private/qwidget_p.h> // to access QWExtra
#include "qgl_egl_p.h"
+#include "qpixmapdata_gl_p.h"
#include "qcolormap.h"
#include <QDebug>
@@ -358,5 +360,117 @@ void QGLWidgetPrivate::recreateEglSurface()
eglSurfaceWindowId = currentId;
}
+/*
+ * Symbian specific QGLPixmapData functions
+ */
+
+static CFbsBitmap* createBlitCopy(CFbsBitmap* bitmap)
+{
+ CFbsBitmap *copy = q_check_ptr(new CFbsBitmap);
+ if (!copy)
+ return 0;
+
+ if (copy->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()) != KErrNone) {
+ delete copy;
+ copy = 0;
+
+ return 0;
+ }
+
+ CFbsBitmapDevice* bitmapDevice = 0;
+ CFbsBitGc *bitmapGc = 0;
+ QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(copy));
+ QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL());
+ bitmapGc->Activate(bitmapDevice);
+
+ bitmapGc->BitBlt(TPoint(), bitmap);
+
+ delete bitmapGc;
+ delete bitmapDevice;
+
+ return copy;
+}
+
+void QGLPixmapData::fromNativeType(void* pixmap, NativeType type)
+{
+ if (type == QPixmapData::FbsBitmap) {
+ CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap*>(pixmap);
+
+ bool deleteSourceBitmap = false;
+#ifdef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE
+
+ // Rasterize extended bitmaps
+
+ TUid extendedBitmapType = bitmap->ExtendedBitmapType();
+ if (extendedBitmapType != KNullUid) {
+ bitmap = createBlitCopy(bitmap);
+ deleteSourceBitmap = true;
+ }
+#endif
+
+ if (bitmap->IsCompressedInRAM()) {
+ bitmap = createBlitCopy(bitmap);
+ deleteSourceBitmap = true;
+ }
+
+ TDisplayMode displayMode = bitmap->DisplayMode();
+ QImage::Format format = qt_TDisplayMode2Format(displayMode);
+
+ TSize size = bitmap->SizeInPixels();
+ int bytesPerLine = bitmap->ScanLineLength(size.iWidth, displayMode);
+
+ bitmap->BeginDataAccess();
+ uchar *bytes = (uchar*)bitmap->DataAddress();
+ QImage img = QImage(bytes, size.iWidth, size.iHeight, bytesPerLine, format);
+ img = img.copy();
+ bitmap->EndDataAccess();
+
+ if (displayMode == EGray2) {
+ //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid
+ //So invert mono bitmaps so that masks work correctly.
+ img.invertPixels();
+ } else if (displayMode == EColor16M) {
+ img = img.rgbSwapped(); // EColor16M is BGR
+ }
+
+ fromImage(img, Qt::AutoColor);
+
+ if (deleteSourceBitmap)
+ delete bitmap;
+ }
+}
+
+void* QGLPixmapData::toNativeType(NativeType type)
+{
+ if (type == QPixmapData::FbsBitmap) {
+ CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap);
+
+ if (bitmap) {
+ QImage image = toImage();
+
+ TDisplayMode displayMode(EColor16MU);
+ if (image.format()==QImage::Format_ARGB32_Premultiplied)
+ displayMode = EColor16MAP;
+
+ if (bitmap->Create(TSize(image.width(), image.height()),
+ displayMode) == KErrNone) {
+ const uchar *sptr = const_cast<const QImage&>(image).bits();
+ bitmap->BeginDataAccess();
+
+ uchar *dptr = (uchar*)bitmap->DataAddress();
+ Mem::Copy(dptr, sptr, image.byteCount());
+
+ bitmap->EndDataAccess();
+ } else {
+ delete bitmap;
+ bitmap = 0;
+ }
+ }
+
+ return reinterpret_cast<void*>(bitmap);
+ }
+ return 0;
+}
+
QT_END_NAMESPACE
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index 031837f..cda1c79 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -1216,8 +1216,8 @@ void QGLFramebufferObject::drawTexture(const QPointF &point, QMacCompatGLuint te
}
#endif
-Q_DECL_IMPORT extern int qt_defaultDpiX();
-Q_DECL_IMPORT extern int qt_defaultDpiY();
+Q_GUI_EXPORT int qt_defaultDpiX();
+Q_GUI_EXPORT int qt_defaultDpiY();
/*! \reimp */
int QGLFramebufferObject::metric(PaintDeviceMetric metric) const
diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp
index 3ce912a..ec6ac4c 100644
--- a/src/opengl/qglpixelbuffer.cpp
+++ b/src/opengl/qglpixelbuffer.cpp
@@ -424,8 +424,8 @@ QPaintEngine *QGLPixelBuffer::paintEngine() const
#endif
}
-Q_DECL_IMPORT extern int qt_defaultDpiX();
-Q_DECL_IMPORT extern int qt_defaultDpiY();
+Q_GUI_EXPORT int qt_defaultDpiX();
+Q_GUI_EXPORT int qt_defaultDpiY();
/*! \reimp */
int QGLPixelBuffer::metric(PaintDeviceMetric metric) const
diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp
index a3867dd..aa07561 100644
--- a/src/opengl/qglpixmapfilter.cpp
+++ b/src/opengl/qglpixmapfilter.cpp
@@ -63,8 +63,8 @@
QT_BEGIN_NAMESPACE
// qpixmapfilter.cpp
-Q_DECL_IMPORT void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0);
-Q_DECL_IMPORT QImage qt_halfScaled(const QImage &source);
+Q_GUI_EXPORT void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0);
+Q_GUI_EXPORT QImage qt_halfScaled(const QImage &source);
void QGLPixmapFilterBase::bindTexture(const QPixmap &src) const
{
@@ -425,7 +425,7 @@ static inline uint nextMultiple(uint x, uint multiplier)
return x + multiplier - mod;
}
-Q_DECL_IMPORT void qt_memrotate90_gl(const quint32 *src, int srcWidth, int srcHeight, int srcStride,
+Q_GUI_EXPORT void qt_memrotate90_gl(const quint32 *src, int srcWidth, int srcHeight, int srcStride,
quint32 *dest, int dstStride);
bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const QPixmap &src, const QRectF &) const
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index 7f41339..4598bff 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -261,14 +261,14 @@ bool QGLShaderPrivate::compile(QGLShader *q)
log = QString::fromLatin1(logbuf);
QString name = q->objectName();
- char *types[] = {
+ const char *types[] = {
"Fragment",
"Vertex",
"Geometry",
""
};
- char *type = types[3];
+ const char *type = types[3];
if (shaderType == QGLShader::Fragment)
type = types[0];
else if (shaderType == QGLShader::Vertex)
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index 2f1b8fd..2c01ac4 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -79,7 +79,7 @@
QT_BEGIN_NAMESPACE
-Q_DECL_IMPORT extern QImage qt_imageForBrush(int brushStyle, bool invert); //in qbrush.cpp
+Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert); //in qbrush.cpp
#ifdef QT_MAC_USE_COCOA
extern void *qt_current_nsopengl_context(); // qgl_mac.mm
#endif
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp
index e522386..04de1bd 100644
--- a/src/opengl/qpixmapdata_gl.cpp
+++ b/src/opengl/qpixmapdata_gl.cpp
@@ -55,6 +55,7 @@
#include <qdesktopwidget.h>
#include <qfile.h>
#include <qimagereader.h>
+#include <qbuffer.h>
QT_BEGIN_NAMESPACE
@@ -369,40 +370,18 @@ void QGLPixmapData::ensureCreated() const
void QGLPixmapData::fromImage(const QImage &image,
Qt::ImageConversionFlags flags)
{
- if (image.size() == QSize(w, h))
- setSerialNumber(++qt_gl_pixmap_serial);
- resize(image.width(), image.height());
-
- if (pixelType() == BitmapType) {
- m_source = image.convertToFormat(QImage::Format_MonoLSB);
-
- } else {
- QImage::Format format = QImage::Format_RGB32;
- if (qApp->desktop()->depth() == 16)
- format = QImage::Format_RGB16;
-
- if (image.hasAlphaChannel()
- && ((flags & Qt::NoOpaqueDetection)
- || const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()))
- format = QImage::Format_ARGB32_Premultiplied;;
-
- m_source = image.convertToFormat(format);
- }
-
- m_dirty = true;
- m_hasFillColor = false;
+ QImage img = image;
+ createPixmapForImage(img, flags, false);
+}
- m_hasAlpha = m_source.hasAlphaChannel();
- w = image.width();
- h = image.height();
- is_null = (w <= 0 || h <= 0);
- d = m_source.depth();
+void QGLPixmapData::fromImageReader(QImageReader *imageReader,
+ Qt::ImageConversionFlags flags)
+{
+ QImage image = imageReader->read();
+ if (image.isNull())
+ return;
- if (m_texture.id) {
- QGLShareContextScope ctx(qt_gl_share_context());
- glDeleteTextures(1, &m_texture.id);
- m_texture.id = 0;
- }
+ createPixmapForImage(image, flags, true);
}
bool QGLPixmapData::fromFile(const QString &filename, const char *format,
@@ -411,31 +390,37 @@ bool QGLPixmapData::fromFile(const QString &filename, const char *format,
if (pixelType() == QPixmapData::BitmapType)
return QPixmapData::fromFile(filename, format, flags);
QFile file(filename);
- if (!file.open(QIODevice::ReadOnly))
- return false;
- QByteArray data = file.peek(64);
- bool alpha;
- if (m_texture.canBindCompressedTexture
- (data.constData(), data.size(), format, &alpha)) {
- resize(0, 0);
- data = file.readAll();
- file.close();
- QGLShareContextScope ctx(qt_gl_share_context());
- QSize size = m_texture.bindCompressedTexture
- (data.constData(), data.size(), format);
- if (!size.isEmpty()) {
- w = size.width();
- h = size.height();
- is_null = false;
- d = 32;
- m_hasAlpha = alpha;
- m_source = QImage();
- m_dirty = isValid();
- return true;
+ if (file.open(QIODevice::ReadOnly)) {
+ QByteArray data = file.peek(64);
+ bool alpha;
+ if (m_texture.canBindCompressedTexture
+ (data.constData(), data.size(), format, &alpha)) {
+ resize(0, 0);
+ data = file.readAll();
+ file.close();
+ QGLShareContextScope ctx(qt_gl_share_context());
+ QSize size = m_texture.bindCompressedTexture
+ (data.constData(), data.size(), format);
+ if (!size.isEmpty()) {
+ w = size.width();
+ h = size.height();
+ is_null = false;
+ d = 32;
+ m_hasAlpha = alpha;
+ m_source = QImage();
+ m_dirty = isValid();
+ return true;
+ }
+ return false;
}
- return false;
}
- fromImage(QImageReader(&file, format).read(), flags);
+
+ QImage image = QImageReader(filename, format).read();
+ if (image.isNull())
+ return false;
+
+ createPixmapForImage(image, flags, true);
+
return !isNull();
}
@@ -459,7 +444,67 @@ bool QGLPixmapData::fromData(const uchar *buffer, uint len, const char *format,
return true;
}
}
- return QPixmapData::fromData(buffer, len, format, flags);
+
+ QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(buffer), len);
+ QBuffer b(&a);
+ b.open(QIODevice::ReadOnly);
+ QImage image = QImageReader(&b, format).read();
+ if (image.isNull())
+ return false;
+
+ createPixmapForImage(image, flags, true);
+
+ return !isNull();
+}
+
+/*!
+ out-of-place conversion (inPlace == false) will always detach()
+ */
+void QGLPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace)
+{
+ if (image.size() == QSize(w, h))
+ setSerialNumber(++qt_gl_pixmap_serial);
+
+ resize(image.width(), image.height());
+
+ if (pixelType() == BitmapType) {
+ m_source = image.convertToFormat(QImage::Format_MonoLSB);
+
+ } else {
+ QImage::Format format = QImage::Format_RGB32;
+ if (qApp->desktop()->depth() == 16)
+ format = QImage::Format_RGB16;
+
+ if (image.hasAlphaChannel()
+ && ((flags & Qt::NoOpaqueDetection)
+ || const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()))
+ format = QImage::Format_ARGB32_Premultiplied;;
+
+ if (inPlace && image.data_ptr()->convertInPlace(format, flags)) {
+ m_source = image;
+ } else {
+ m_source = image.convertToFormat(format);
+
+ // convertToFormat won't detach the image if format stays the same.
+ if (image.format() == format)
+ m_source.detach();
+ }
+ }
+
+ m_dirty = true;
+ m_hasFillColor = false;
+
+ m_hasAlpha = m_source.hasAlphaChannel();
+ w = image.width();
+ h = image.height();
+ is_null = (w <= 0 || h <= 0);
+ d = m_source.depth();
+
+ if (m_texture.id) {
+ QGLShareContextScope ctx(qt_gl_share_context());
+ glDeleteTextures(1, &m_texture.id);
+ m_texture.id = 0;
+ }
}
bool QGLPixmapData::scroll(int dx, int dy, const QRect &rect)
@@ -586,6 +631,12 @@ QImage QGLPixmapData::toImage() const
if (m_renderFbo) {
copyBackFromRenderFbo(true);
} else if (!m_source.isNull()) {
+ QImageData *data = const_cast<QImage &>(m_source).data_ptr();
+ if (data->paintEngine && data->paintEngine->isActive()
+ && data->paintEngine->paintDevice() == &m_source)
+ {
+ return m_source.copy();
+ }
return m_source;
} else if (m_dirty || m_hasFillColor) {
return fillImage(m_fillColor);
@@ -739,8 +790,8 @@ QGLTexture* QGLPixmapData::texture() const
return &m_texture;
}
-Q_DECL_IMPORT extern int qt_defaultDpiX();
-Q_DECL_IMPORT extern int qt_defaultDpiY();
+Q_GUI_EXPORT int qt_defaultDpiX();
+Q_GUI_EXPORT int qt_defaultDpiY();
int QGLPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
{
diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h
index 5545d3c..a4066fd 100644
--- a/src/opengl/qpixmapdata_gl_p.h
+++ b/src/opengl/qpixmapdata_gl_p.h
@@ -107,6 +107,8 @@ public:
// Re-implemented from QPixmapData:
void resize(int width, int height);
void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
+ void fromImageReader(QImageReader *imageReader,
+ Qt::ImageConversionFlags flags);
bool fromFile(const QString &filename, const char *format,
Qt::ImageConversionFlags flags);
bool fromData(const uchar *buffer, uint len, const char *format,
@@ -127,6 +129,11 @@ public:
GLuint bind(bool copyBack = true) const;
QGLTexture *texture() const;
+#if defined(Q_OS_SYMBIAN)
+ void* toNativeType(NativeType type);
+ void fromNativeType(void* pixmap, NativeType type);
+#endif
+
private:
bool isValid() const;
@@ -149,6 +156,8 @@ private:
QImage fillImage(const QColor &color) const;
+ void createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace);
+
mutable QGLFramebufferObject *m_renderFbo;
mutable QPaintEngine *m_engine;
mutable QGLContext *m_ctx;
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 5a783ca..cdd3eb9 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -363,7 +363,6 @@ QGLWindowSurface::~QGLWindowSurface()
*ctx = 0;
}
#endif
-
delete d_ptr->pb;
delete d_ptr->fbo;
delete d_ptr;
@@ -812,20 +811,25 @@ void QGLWindowSurface::updateGeometry() {
return;
d_ptr->geometry_updated = false;
-#ifdef Q_WS_QPA
- QSize surfSize = size();
-#else
- QSize surfSize = geometry().size();
-#endif
+ bool hijack(true);
+ QWidgetPrivate *wd = window()->d_func();
+ if (wd->extraData() && wd->extraData()->glContext)
+ hijack = false; // we already have gl context for widget
- hijackWindow(window());
- QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext);
+ if (hijack)
+ hijackWindow(window());
+
+ QGLContext *ctx = reinterpret_cast<QGLContext *>(wd->extraData()->glContext);
#ifdef Q_WS_MAC
ctx->updatePaintDevice();
#endif
- const GLenum target = GL_TEXTURE_2D;
+#ifdef Q_WS_QPA
+ QSize surfSize = size();
+#else
+ QSize surfSize = geometry().size();
+#endif
if (surfSize.width() <= 0 || surfSize.height() <= 0)
return;
@@ -835,6 +839,27 @@ void QGLWindowSurface::updateGeometry() {
d_ptr->size = surfSize;
+#ifdef Q_OS_SYMBIAN
+ if (!hijack) { // Symbian needs to recreate EGL surface when native window size changes
+ if (ctx->d_func()->eglSurface != EGL_NO_SURFACE) {
+ eglDestroySurface(ctx->d_func()->eglContext->display(),
+ ctx->d_func()->eglSurface);
+ }
+
+ ctx->d_func()->eglSurface = QEgl::createSurface(ctx->device(),
+ ctx->d_func()->eglContext->config());
+
+#if !defined(QGL_NO_PRESERVED_SWAP)
+ eglGetError(); // Clear error state first.
+ eglSurfaceAttrib(QEgl::display(), ctx->d_func()->eglSurface,
+ EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
+ if (eglGetError() != EGL_SUCCESS) {
+ qWarning("QGLWindowSurface: could not restore preserved swap behaviour");
+ }
+#endif
+ }
+#endif
+
if (d_ptr->ctx) {
#ifndef QT_OPENGL_ES_2
if (d_ptr->destructive_swap_buffers)
@@ -843,6 +868,7 @@ void QGLWindowSurface::updateGeometry() {
return;
}
+ const GLenum target = GL_TEXTURE_2D;
if (d_ptr->destructive_swap_buffers
&& (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject)
&& (d_ptr->fbo || !d_ptr->tried_fbo)
diff --git a/src/openvg/openvg.pro b/src/openvg/openvg.pro
index e7ed890..e185949 100644
--- a/src/openvg/openvg.pro
+++ b/src/openvg/openvg.pro
@@ -38,6 +38,13 @@ symbian {
DEFINES += QVG_RECREATE_ON_SIZE_CHANGE QVG_BUFFER_SCROLLING QVG_SCISSOR_CLIP
SOURCES += \
qvg_symbian.cpp
+
+ contains(QT_CONFIG, freetype) {
+ DEFINES += QT_NO_FONTCONFIG
+ INCLUDEPATH += \
+ ../3rdparty/freetype/src \
+ ../3rdparty/freetype/include
+ }
}
include(../qbase.pri)
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 09cbc36..22cbbf5 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -77,8 +77,8 @@ static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
#if !defined(QVG_NO_DRAW_GLYPHS)
-Q_DECL_IMPORT extern int qt_defaultDpiX();
-Q_DECL_IMPORT extern int qt_defaultDpiY();
+Q_GUI_EXPORT int qt_defaultDpiX();
+Q_GUI_EXPORT int qt_defaultDpiY();
class QVGPaintEnginePrivate;
@@ -526,7 +526,7 @@ void QVGPaintEnginePrivate::setTransform
vgLoadMatrix(mat);
}
-Q_DECL_IMPORT extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale);
+Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale);
void QVGPaintEnginePrivate::updateTransform(QPaintDevice *pdev)
{
@@ -994,7 +994,7 @@ VGPath QVGPaintEnginePrivate::roundedRectPath(const QRectF &rect, qreal xRadius,
return vgpath;
}
-Q_DECL_IMPORT extern QImage qt_imageForBrush(int style, bool invert);
+Q_GUI_EXPORT QImage qt_imageForBrush(int style, bool invert);
static QImage colorizeBitmap(const QImage &image, const QColor &color)
{
@@ -1472,7 +1472,7 @@ void QVGPaintEnginePrivate::draw
(VGPath path, const QPen& pen, const QBrush& brush, VGint rule)
{
VGbitfield mode = 0;
- if (pen.style() != Qt::NoPen) {
+ if (qpen_style(pen) != Qt::NoPen && qbrush_style(qpen_brush(pen)) != Qt::NoBrush) {
ensurePen(pen);
mode |= VG_STROKE_PATH;
}
@@ -2201,6 +2201,12 @@ void QVGPaintEngine::updateScissor()
#if defined(QVG_SCISSOR_CLIP)
// Using the scissor to do clipping, so combine the systemClip
// with the current painting clipRegion.
+
+ if (d->maskValid) {
+ vgSeti(VG_MASKING, VG_FALSE);
+ d->maskValid = false;
+ }
+
QVGPainterState *s = state();
if (s->clipEnabled) {
if (region.isEmpty())
@@ -2250,8 +2256,33 @@ void QVGPaintEngine::updateScissor()
QVector<QRect> rects = region.rects();
int count = rects.count();
- if (count > d->maxScissorRects)
- count = d->maxScissorRects;
+ if (count > d->maxScissorRects) {
+#if !defined(QVG_SCISSOR_CLIP)
+ count = d->maxScissorRects;
+#else
+ // Use masking
+ int width = paintDevice()->width();
+ int height = paintDevice()->height();
+ vgMask(VG_INVALID_HANDLE, VG_CLEAR_MASK,
+ 0, 0, width, height);
+ for (int i = 0; i < rects.size(); ++i) {
+ vgMask(VG_INVALID_HANDLE, VG_FILL_MASK,
+ rects[i].x(), height - rects[i].y() - rects[i].height(),
+ rects[i].width(), rects[i].height());
+ }
+
+ vgSeti(VG_SCISSORING, VG_FALSE);
+ vgSeti(VG_MASKING, VG_TRUE);
+ d->maskValid = true;
+ d->maskIsSet = false;
+ d->scissorMask = false;
+ d->scissorActive = false;
+ d->scissorDirty = false;
+ d->scissorRegion = region;
+ return;
+#endif
+ }
+
QVarLengthArray<VGint> params(count * 4);
int height = paintDevice()->height();
for (int i = 0; i < count; ++i) {
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
index 3f768fd..732b484 100644
--- a/src/openvg/qpixmapdata_vg.cpp
+++ b/src/openvg/qpixmapdata_vg.cpp
@@ -200,6 +200,9 @@ bool QVGPixmapData::fromData(const uchar *buffer, uint len, const char *format,
return !isNull();
}
+/*!
+ out-of-place conversion (inPlace == false) will always detach()
+ */
void QVGPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace)
{
if (image.size() == QSize(w, h))
@@ -216,11 +219,16 @@ void QVGPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags
else
format = image.hasAlphaChannel() ? sourceFormat() : QImage::Format_RGB32;
- if (inPlace && image.data_ptr()->convertInPlace(format, flags))
+ if (inPlace && image.data_ptr()->convertInPlace(format, flags)) {
source = image;
- else
+ } else {
source = image.convertToFormat(format);
+ // convertToFormat won't detach the image if format stays the same.
+ if (image.format() == format)
+ source.detach();
+ }
+
recreate = true;
}
@@ -404,8 +412,8 @@ void QVGPixmapData::reclaimImages()
destroyImages();
}
-Q_DECL_IMPORT extern int qt_defaultDpiX();
-Q_DECL_IMPORT extern int qt_defaultDpiY();
+Q_GUI_EXPORT int qt_defaultDpiX();
+Q_GUI_EXPORT int qt_defaultDpiY();
int QVGPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
{
diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp
index b813800..ff0ab13 100644
--- a/src/openvg/qvg_symbian.cpp
+++ b/src/openvg/qvg_symbian.cpp
@@ -148,7 +148,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
destroyImages();
prevSize = QSize();
- VGImage vgImage = sgImageToVGImage(context, *sgImage);
+ vgImage = sgImageToVGImage(context, *sgImage);
if (vgImage != VG_INVALID_HANDLE) {
w = vgGetParameteri(vgImage, VG_IMAGE_WIDTH);
h = vgGetParameteri(vgImage, VG_IMAGE_HEIGHT);
diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp
index c6db869..ca80886 100644
--- a/src/openvg/qwindowsurface_vgegl.cpp
+++ b/src/openvg/qwindowsurface_vgegl.cpp
@@ -267,10 +267,7 @@ static QEglContext *createContext(QPaintDevice *device)
int redSize = configProps.value(EGL_RED_SIZE);
if (redSize == EGL_DONT_CARE || redSize == 0)
configProps.setPixelFormat(QImage::Format_ARGB32); // XXX
-#ifndef QVG_SCISSOR_CLIP
- // If we are using the mask to clip, then explicitly request a mask.
configProps.setValue(EGL_ALPHA_MASK_SIZE, 1);
-#endif
#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT |
EGL_VG_ALPHA_FORMAT_PRE_BIT);
diff --git a/src/plugins/bearer/icd/dbusdispatcher.cpp b/src/plugins/bearer/icd/dbusdispatcher.cpp
index 5fc2a38..13cd8a9 100644
--- a/src/plugins/bearer/icd/dbusdispatcher.cpp
+++ b/src/plugins/bearer/icd/dbusdispatcher.cpp
@@ -51,10 +51,10 @@
namespace Maemo {
/*!
- \class DBusDispatcher
+ \class Maemo::DBusDispatcher
- \brief DBusDispatcher is a class, which is able to send DBUS method call
- messages and receive unicast signals from DBUS object.
+ \brief DBusDispatcher is a class that can send DBUS method call
+ messages and receive unicast signals from DBUS objects.
*/
class DBusDispatcherPrivate
@@ -468,7 +468,7 @@ void DBusDispatcher::setupDBus()
d_ptr->signal_vtable.message_function = signalHandler;
dbus_connection_set_exit_on_disconnect(d_ptr->connection, FALSE);
- dbus_connection_setup_with_g_main(d_ptr->connection, NULL);
+ dbus_connection_setup_with_g_main(d_ptr->connection, g_main_context_get_thread_default());
dbus_connection_register_object_path(d_ptr->connection,
d_ptr->signalPath.toLatin1(),
&d_ptr->signal_vtable,
diff --git a/src/plugins/bearer/icd/qnetworksession_impl.cpp b/src/plugins/bearer/icd/qnetworksession_impl.cpp
index 6d578d3..af5d85e 100644
--- a/src/plugins/bearer/icd/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/icd/qnetworksession_impl.cpp
@@ -125,9 +125,6 @@ static QString get_network_interface();
void QNetworkSessionPrivateImpl::iapStateChanged(const QString& iapid, uint icd_connection_state)
{
- if ((publicConfig.type() == QNetworkConfiguration::UserChoice) && opened) {
- updateIdentifier(iapid);
- }
if (((publicConfig.type() == QNetworkConfiguration::UserChoice) &&
(activeConfig.identifier() == iapid)) ||
@@ -149,6 +146,9 @@ void QNetworkSessionPrivateImpl::iapStateChanged(const QString& iapid, uint icd_
break;
}
}
+ if (publicConfig.type() == QNetworkConfiguration::UserChoice) {
+ updateIdentifier(iapid);
+ }
}
void QNetworkSessionPrivateImpl::cleanupSession(void)
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
index 30d6b50..6b37b38 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
@@ -213,6 +213,11 @@ void QNetworkManagerEngine::connectToId(const QString &id)
dbusDevicePath = devicePath.path();
break;
}
+ else if (device.deviceType() == DEVICE_TYPE_GSM &&
+ connectionType == QLatin1String("gsm")) {
+ dbusDevicePath = devicePath.path();
+ break;
+ }
}
const QString service = connection->connectionInterface()->service();
diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp
index 433eef6..741f8c5 100644
--- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp
@@ -1552,8 +1552,8 @@ void ConnectionProgressNotifier::StartNotifications()
{
if (!IsActive()) {
SetActive();
+ iConnection.ProgressNotification(iProgress, iStatus);
}
- iConnection.ProgressNotification(iProgress, iStatus);
}
void ConnectionProgressNotifier::StopNotifications()
@@ -1569,10 +1569,10 @@ void ConnectionProgressNotifier::DoCancel()
void ConnectionProgressNotifier::RunL()
{
if (iStatus == KErrNone) {
- QT_TRYCATCH_LEAVING(iOwner.handleSymbianConnectionStatusChange(iProgress().iStage, iProgress().iError));
-
SetActive();
iConnection.ProgressNotification(iProgress, iStatus);
+ // warning, this object may be deleted in the callback - do nothing after handleSymbianConnectionStatusChange
+ QT_TRYCATCH_LEAVING(iOwner.handleSymbianConnectionStatusChange(iProgress().iStage, iProgress().iError));
}
}
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
index 6639983..eaff74a 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
@@ -245,10 +245,9 @@ bool QDirectFBPixmapData::fromDataBufferDescription(const DFBDataBufferDescripti
QDirectFBPointer<IDirectFBDataBuffer> dataBuffer(dataBufferPtr);
IDirectFBImageProvider *providerPtr;
- if ((result = dataBuffer->CreateImageProvider(dataBuffer.data(), &providerPtr)) != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::fromDataBufferDescription(): Can't create image provider", result);
+ if ((result = dataBuffer->CreateImageProvider(dataBuffer.data(), &providerPtr)) != DFB_OK)
return false;
- }
+
QDirectFBPointer<IDirectFBImageProvider> provider(providerPtr);
DFBImageDescription imageDescription;
@@ -300,40 +299,26 @@ void QDirectFBPixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags
{
alpha = QDirectFBPixmapData::hasAlphaChannel(img, flags);
imageFormat = alpha ? screen->alphaPixmapFormat() : screen->pixelFormat();
+
QImage image;
if ((flags & ~Qt::NoOpaqueDetection) != Qt::AutoColor) {
image = img.convertToFormat(imageFormat, flags);
flags = Qt::AutoColor;
} else if (img.format() == QImage::Format_RGB32 || img.depth() == 1) {
image = img.convertToFormat(imageFormat, flags);
+ } else if (img.format() != imageFormat) {
+ image = img.convertToFormat(imageFormat, flags);
} else {
image = img;
}
- IDirectFBSurface *imageSurface = screen->createDFBSurface(image, image.format(), QDirectFBScreen::DontTrackSurface);
- if (!imageSurface) {
- qWarning("QDirectFBPixmapData::fromImage()");
- invalidate();
- return;
- }
-
- dfbSurface = screen->createDFBSurface(image.size(), imageFormat, QDirectFBScreen::TrackSurface);
+ dfbSurface = screen->createDFBSurface(image, image.format(), QDirectFBScreen::NoPreallocated | QDirectFBScreen::TrackSurface);
if (!dfbSurface) {
qWarning("QDirectFBPixmapData::fromImage()");
invalidate();
return;
}
- if (image.hasAlphaChannel()) {
- dfbSurface->Clear(dfbSurface, 0, 0, 0, 0);
- dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_BLEND_ALPHACHANNEL);
- } else {
- dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
- }
-
- dfbSurface->Blit(dfbSurface, imageSurface, 0, 0, 0);
- imageSurface->Release(imageSurface);
-
w = image.width();
h = image.height();
is_null = (w <= 0 || h <= 0);
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index 09cc465..ff15078 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -1285,7 +1285,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
result = d_ptr->primarySurface->GetSize(d_ptr->primarySurface, &w, &h);
#elif (Q_DIRECTFB_VERSION >= 0x010000)
IDirectFBSurface *layerSurface;
- if (d_ptr->dfbLayer->GetSurface(d_ptr->dfbLayer, &layerSurface) != DFB_OK) {
+ if (d_ptr->dfbLayer->GetSurface(d_ptr->dfbLayer, &layerSurface) == DFB_OK) {
result = layerSurface->GetSize(layerSurface, &w, &h);
layerSurface->Release(layerSurface);
}
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
index d0056a7..3d8cf50 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
@@ -55,7 +55,6 @@ QT_BEGIN_NAMESPACE
QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr)
: QDirectFBPaintDevice(scr)
- , sibling(0)
#ifndef QT_NO_DIRECTFB_WM
, dfbWindow(0)
#endif
@@ -75,7 +74,6 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect
QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr, QWidget *widget)
: QWSWindowSurface(widget), QDirectFBPaintDevice(scr)
- , sibling(0)
#ifndef QT_NO_DIRECTFB_WM
, dfbWindow(0)
#endif
@@ -123,7 +121,7 @@ void QDirectFBWindowSurface::raise()
IDirectFBWindow *QDirectFBWindowSurface::directFBWindow() const
{
- return (dfbWindow ? dfbWindow : (sibling ? sibling->dfbWindow : 0));
+ return dfbWindow;
}
void QDirectFBWindowSurface::createWindow(const QRect &rect)
@@ -287,17 +285,40 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect)
QByteArray QDirectFBWindowSurface::permanentState() const
{
- QByteArray state(sizeof(this), 0);
- *reinterpret_cast<const QDirectFBWindowSurface**>(state.data()) = this;
+ QByteArray state(sizeof(SurfaceFlags) + sizeof(DFBWindowID), 0);
+ char *ptr = state.data();
+ SurfaceFlags flags = surfaceFlags();
+ memcpy(ptr, &flags, sizeof(SurfaceFlags));
+ ptr += sizeof(SurfaceFlags);
+ DFBWindowID did = (DFBWindowID)(-1);
+ if (dfbWindow)
+ dfbWindow->GetID(dfbWindow, &did);
+ memcpy(ptr, &did, sizeof(DFBWindowID));
return state;
}
void QDirectFBWindowSurface::setPermanentState(const QByteArray &state)
{
- if (state.size() == sizeof(this)) {
- sibling = *reinterpret_cast<QDirectFBWindowSurface *const*>(state.constData());
- Q_ASSERT(sibling);
- setSurfaceFlags(sibling->surfaceFlags());
+ const char *ptr = state.constData();
+ IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer();
+ SurfaceFlags flags;
+ memcpy(&flags, ptr, sizeof(SurfaceFlags));
+
+ setSurfaceFlags(flags);
+ ptr += sizeof(SurfaceFlags);
+ DFBWindowID id;
+ memcpy(&id, ptr, sizeof(DFBWindowID));
+ if (dfbSurface)
+ dfbSurface->Release(dfbSurface);
+ if (id != (DFBWindowID)-1) {
+ IDirectFBWindow *dw;
+ layer->GetWindow(layer, id, &dw);
+ if (dw->GetSurface(dw, &dfbSurface) != DFB_OK)
+ dfbSurface = 0;
+ dw->Release(dw);
+ }
+ else {
+ dfbSurface = 0;
}
}
@@ -406,8 +427,6 @@ void QDirectFBWindowSurface::endPaint(const QRegion &)
IDirectFBSurface *QDirectFBWindowSurface::directFBSurface() const
{
- if (!dfbSurface && sibling && sibling->dfbSurface)
- return sibling->dfbSurface;
return dfbSurface;
}
@@ -415,11 +434,8 @@ IDirectFBSurface *QDirectFBWindowSurface::directFBSurface() const
IDirectFBSurface *QDirectFBWindowSurface::surfaceForWidget(const QWidget *widget, QRect *rect) const
{
Q_ASSERT(widget);
- if (!dfbSurface) {
- if (sibling && (!sibling->sibling || sibling->dfbSurface))
- return sibling->surfaceForWidget(widget, rect);
+ if (!dfbSurface)
return 0;
- }
QWidget *win = window();
Q_ASSERT(win);
if (rect) {
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
index f683fc8..75d462b 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
@@ -100,7 +100,6 @@ private:
void updateIsOpaque();
void setOpaque(bool opaque);
void releaseSurface();
- QDirectFBWindowSurface *sibling;
#ifdef QT_DIRECTFB_WM
void createWindow(const QRect &rect);
diff --git a/src/plugins/graphicssystems/meego/dithering.cpp b/src/plugins/graphicssystems/meego/dithering.cpp
index 91e3337..2561c22 100644
--- a/src/plugins/graphicssystems/meego/dithering.cpp
+++ b/src/plugins/graphicssystems/meego/dithering.cpp
@@ -39,15 +39,22 @@
**
****************************************************************************/
-// This is an implementation of the 32bit => 16bit Floyd-Steinberg dithering.
+// Implements two dithering methods:
+//
+// * convertRGBA32_to_RGB565
+//
+// This is implemented using Ordered Bayer Dithering. The code has been adapted
+// from QX11PixmapData::fromImage. This method was originally implemented using
+// Floyd-Steinberg dithering but was later changed to Ordered Dithering because
+// of the better quality of the results.
+//
+// * convertRGBA32_to_RGBA4444
+//
+// This is implemented using Floyd-Steinberg dithering.
+//
// The alghorithm used here is not the fastest possible but it's prolly fast enough:
// uses look-up tables, integer-only arthmetics and works in one pass on two lines
// at a time. It's a high-quality dithering using 1/8 diffusion precission.
-// Two functions here to look at:
-//
-// * convertRGBA32_to_RGB565
-// * convertRGBA32_to_RGBA4444
-//
// Each channel (RGBA) is diffused independently and alpha is dithered too.
#include <string.h>
@@ -76,113 +83,63 @@
// Converts incoming RGB32 (QImage::Format_RGB32) to RGB565. Returns the newly allocated data.
unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int height, int stride)
{
+ static bool thresholdMapInitialized = false;
+ static int thresholdMap[16][16];
+
+ if (!thresholdMapInitialized) {
+ int i;
+ int j;
+ int n;
+
+ thresholdMap[0][0] = 0;
+ thresholdMap[1][0] = 2;
+ thresholdMap[0][1] = 3;
+ thresholdMap[1][1] = 1;
+
+ for (n=2; n<16; n*=2) {
+ for (i=0; i<n; i++) {
+ for (j=0; j<n; j++) {
+ thresholdMap[i][j] *= 4;
+ thresholdMap[i+n][j] = thresholdMap[i][j] + 2;
+ thresholdMap[i][j+n] = thresholdMap[i][j] + 3;
+ thresholdMap[i+n][j+n] = thresholdMap[i][j] + 1;
+ }
+ }
+ }
+
+ thresholdMapInitialized = true;
+ }
+
// Output line stride. Aligned to 4 bytes.
int alignedWidth = width;
if (alignedWidth % 2 > 0)
alignedWidth++;
// Will store output
- unsigned short *out = (unsigned short *) malloc(alignedWidth * height * 2);
-
- // Lookup tables for the 8bit => 6bit and 8bit => 5bit conversion
- unsigned char lookup_8bit_to_5bit[256];
- short lookup_8bit_to_5bit_diff[256];
- unsigned char lookup_8bit_to_6bit[256];
- short lookup_8bit_to_6bit_diff[256];
-
- // Macros for the conversion using the lookup table.
- #define CONVERT_8BIT_TO_5BIT(v) (lookup_8bit_to_5bit[v])
- #define DIFF_8BIT_TO_5BIT(v) (lookup_8bit_to_5bit_diff[v])
-
- #define CONVERT_8BIT_TO_6BIT(v) (lookup_8bit_to_6bit[v])
- #define DIFF_8BIT_TO_6BIT(v) (lookup_8bit_to_6bit_diff[v])
-
- int i;
- int x, y, c; // Pixel we're processing. c is component number (0, 1, 2 for r, b, b)
- short component[3]; // Stores the new components (r, g, b) for pixel produced during conversion
- short diff; // The difference between the converted value and the original one. To be accumulated.
- QVarLengthArray <short> accumulatorData(3 * width * 2); // Data for three acumulators for r, g, b. Each accumulator is two lines.
- short *accumulator[3]; // Helper for accessing the accumulator on a per-channel basis more easily.
- accumulator[0] = accumulatorData.data();
- accumulator[1] = accumulatorData.data() + width;
- accumulator[2] = accumulatorData.data() + (width * 2);
-
- // Produce the conversion lookup tables.
- for (i = 0; i < 256; i++) {
- lookup_8bit_to_5bit[i] = round(i / 8.0);
-
- // Before bitshifts: (i * 8) - (... * 8 * 8)
- lookup_8bit_to_5bit_diff[i] = (i << 3) - (lookup_8bit_to_5bit[i] << 6);
- if (lookup_8bit_to_5bit[i] > 31)
- lookup_8bit_to_5bit[i] -= 1;
-
- lookup_8bit_to_6bit[i] = round(i / 4.0);
-
- // Before bitshifts: (i * 8) - (... * 4 * 8)
- lookup_8bit_to_6bit_diff[i] = (i << 3) - (lookup_8bit_to_6bit[i] << 5);
- if (lookup_8bit_to_6bit[i] > 63)
- lookup_8bit_to_6bit[i] -= 1;
- }
+ unsigned short *out = (unsigned short *)malloc (alignedWidth * height * 2);
- // Clear the accumulators
- memset(accumulator[0], 0, width * 4);
- memset(accumulator[1], 0, width * 4);
- memset(accumulator[2], 0, width * 4);
+ int x;
+ int y;
+ int threshold;
// For each line...
for (y = 0; y < height; y++) {
- // For each accumulator, move the second line (index 1) to replace the first line (index 0).
- // Clear the second line (index 1)
- memcpy(accumulator[0], accumulator[0] + width, width * 2);
- memset(accumulator[0] + width, 0, width * 2);
-
- memcpy(accumulator[1], accumulator[1] + width, width * 2);
- memset(accumulator[1] + width, 0, width * 2);
-
- memcpy(accumulator[2], accumulator[2] + width, width * 2);
- memset(accumulator[2] + width, 0, width * 2);
-
// For each column....
for (x = 0; x < width; x++) {
- // For each component (r, g, b)...
- for (c = 0; c < 3; c++) {
+ int r = GET_RGBA_COMPONENT(in, x, y, stride, 0);
+ int g = GET_RGBA_COMPONENT(in, x, y, stride, 1);
+ int b = GET_RGBA_COMPONENT(in, x, y, stride, 2);
- // Get the 8bit value from the original image
- component[c] = GET_RGBA_COMPONENT(in, x, y, stride, c);
-
- // Add the diffusion for this pixel we stored in the accumulator.
- // >> 7 because the values in accumulator are stored * 128
- if (x != 0 && x != (width - 1)) {
- if (accumulator[c][x] >> 7 != 0)
- component[c] += rand() % accumulator[c][x] >> 7;
- }
-
- // Make sure we're not over the boundaries.
- CLAMP_256(component[c]);
-
- // For green component we use 6 bits. Otherwise 5 bits.
- // Store the difference from converting 8bit => 6 bit and the orig pixel.
- // Convert 8bit => 6(5) bit.
- if (c == 1) {
- diff = DIFF_8BIT_TO_6BIT(component[c]);
- component[c] = CONVERT_8BIT_TO_6BIT(component[c]);
- } else {
- diff = DIFF_8BIT_TO_5BIT(component[c]);
- component[c] = CONVERT_8BIT_TO_5BIT(component[c]);
- }
+ threshold = thresholdMap[x%16][y%16];
- // Distribute the difference according to the matrix in the
- // accumulation bufffer.
- ACCUMULATE(accumulator[c], x + 1, 0, width, diff * 3);
- ACCUMULATE(accumulator[c], x - 1, 1, width, diff * 5);
- ACCUMULATE(accumulator[c], x, 1, width, diff * 5);
- ACCUMULATE(accumulator[c], x + 1, 1, width, diff * 3);
- }
+ if (r <= (255-(1<<3)) && ((r<<5) & 255) > threshold) r += (1<<3);
+ if (g <= (255-(1<<2)) && ((g<<6) & 255) > threshold) g += (1<<2);
+ if (b <= (255-(1<<3)) && ((b<<5) & 255) > threshold) b += (1<<3);
// Write the newly produced pixel
- PUT_565(out, x, y, alignedWidth, component[2], component[1], component[0]);
+ PUT_565(out, x, y, alignedWidth, ((b >> 3) & 0x1f), ((g >> 2) & 0x3f), ((r >> 3) & 0x1f));
}
}
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
index 20b092e..a70d232 100644
--- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
+++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
@@ -42,6 +42,7 @@
#include <QDebug>
#include <private/qpixmap_raster_p.h>
#include <private/qwindowsurface_gl_p.h>
+#include <private/qwindowsurface_raster_p.h>
#include <private/qegl_p.h>
#include <private/qglextensions_p.h>
#include <private/qgl_p.h>
@@ -75,7 +76,12 @@ QMeeGoGraphicsSystem::~QMeeGoGraphicsSystem()
QWindowSurface* QMeeGoGraphicsSystem::createWindowSurface(QWidget *widget) const
{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QGLWidget *shareWidget = qt_gl_share_widget();
+
+ if (!shareWidget)
+ return new QRasterWindowSurface(widget);
+
+ QGLShareContextScope ctx(shareWidget->context());
QMeeGoGraphicsSystem::surfaceWasCreated = true;
QWindowSurface *surface = new QGLWindowSurface(widget);
diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp
index 5aa26d3..701207d 100644
--- a/src/plugins/imageformats/ico/qicohandler.cpp
+++ b/src/plugins/imageformats/ico/qicohandler.cpp
@@ -559,6 +559,8 @@ QImage ICOReader::iconAt(int index)
icoAttrib.ncolors = 0;
else // # colors used
icoAttrib.ncolors = header.biClrUsed ? header.biClrUsed : 1 << icoAttrib.nbits;
+ if (icoAttrib.ncolors > 256) //color table can't be more than 256
+ return img;
icoAttrib.w = iconEntry.bWidth;
if (icoAttrib.w == 0)
icoAttrib.w = header.biWidth;
diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro
index 5b21211..7c7c1d7 100644
--- a/src/plugins/phonon/mmf/mmf.pro
+++ b/src/plugins/phonon/mmf/mmf.pro
@@ -132,7 +132,7 @@ symbian {
}
# This is to allow IAP to be specified
- LIBS += -lCommDb
+ LIBS += -lcommdb
# This is needed for having the .qtplugin file properly created on Symbian.
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 5b0b6f3..3e7da0e 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -15,4 +15,4 @@ symbian:SUBDIRS += s60
contains(QT_CONFIG, phonon): SUBDIRS *= phonon
contains(QT_CONFIG, multimedia): SUBDIRS *= audio
qpa:SUBDIRS += platforms
-
+contains(QT_CONFIG, declarative): SUBDIRS *= qmltooling
diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro
new file mode 100644
index 0000000..01cf1a9
--- /dev/null
+++ b/src/plugins/qmltooling/qmltooling.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+SUBDIRS = tcpserver
+
diff --git a/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp
new file mode 100644
index 0000000..69c1ef5
--- /dev/null
+++ b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 "qtcpserverconnection.h"
+
+#include <QtNetwork/qtcpserver.h>
+#include <QtNetwork/qtcpsocket.h>
+
+#include <private/qdeclarativedebugserver_p.h>
+#include <private/qpacketprotocol_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QTcpServerConnectionPrivate {
+public:
+ QTcpServerConnectionPrivate();
+
+ int port;
+ QTcpSocket *socket;
+ QPacketProtocol *protocol;
+ QTcpServer *tcpServer;
+
+ QDeclarativeDebugServer *debugServer;
+};
+
+QTcpServerConnectionPrivate::QTcpServerConnectionPrivate() :
+ port(0),
+ socket(0),
+ protocol(0),
+ tcpServer(0),
+ debugServer(0)
+{
+}
+
+QTcpServerConnection::QTcpServerConnection() :
+ d_ptr(new QTcpServerConnectionPrivate)
+{
+
+}
+
+QTcpServerConnection::~QTcpServerConnection()
+{
+ delete d_ptr;
+}
+
+void QTcpServerConnection::setServer(QDeclarativeDebugServer *server)
+{
+ Q_D(QTcpServerConnection);
+ d->debugServer = server;
+}
+
+bool QTcpServerConnection::isConnected() const
+{
+ Q_D(const QTcpServerConnection);
+ return d->socket && d->socket->state() == QTcpSocket::ConnectedState;
+}
+
+void QTcpServerConnection::send(const QByteArray &message)
+{
+ Q_D(QTcpServerConnection);
+
+ if (!isConnected())
+ return;
+
+ QPacket pack;
+ pack.writeRawData(message.data(), message.length());
+
+ d->protocol->send(pack);
+ d->socket->flush();
+}
+
+void QTcpServerConnection::disconnect()
+{
+ Q_D(QTcpServerConnection);
+
+ delete d->protocol;
+ d->protocol = 0;
+ delete d->socket;
+ d->socket = 0;
+}
+
+void QTcpServerConnection::setPort(int port, bool block)
+{
+ Q_D(QTcpServerConnection);
+ d->port = port;
+
+ listen();
+ if (block)
+ d->tcpServer->waitForNewConnection(-1);
+}
+
+void QTcpServerConnection::listen()
+{
+ Q_D(QTcpServerConnection);
+
+ d->tcpServer = new QTcpServer(this);
+ QObject::connect(d->tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection()));
+ if (d->tcpServer->listen(QHostAddress::Any, d->port))
+ qWarning("QDeclarativeDebugServer: Waiting for connection on port %d...", d->port);
+ else
+ qWarning("QDeclarativeDebugServer: Unable to listen on port %d", d->port);
+}
+
+
+void QTcpServerConnection::readyRead()
+{
+ Q_D(QTcpServerConnection);
+ QPacket packet = d->protocol->read();
+
+ QByteArray content = packet.data();
+ d->debugServer->receiveMessage(content);
+}
+
+void QTcpServerConnection::newConnection()
+{
+ Q_D(QTcpServerConnection);
+
+ if (d->socket) {
+ qWarning("QDeclarativeDebugServer: Another client is already connected");
+ QTcpSocket *faultyConnection = d->tcpServer->nextPendingConnection();
+ delete faultyConnection;
+ return;
+ }
+
+ d->socket = d->tcpServer->nextPendingConnection();
+ d->socket->setParent(this);
+ d->protocol = new QPacketProtocol(d->socket, this);
+ QObject::connect(d->protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
+}
+
+
+Q_EXPORT_PLUGIN2(tcpserver, QTcpServerConnection)
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/qmltooling/tcpserver/qtcpserverconnection.h b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.h
new file mode 100644
index 0000000..a6e17e6
--- /dev/null
+++ b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 QTCPSERVERCONNECTION_H
+#define QTCPSERVERCONNECTION_H
+
+#include <QtGui/QStylePlugin>
+#include <QtDeclarative/private/qdeclarativedebugserverconnection_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeDebugServer;
+class QTcpServerConnectionPrivate;
+class QTcpServerConnection : public QObject, public QDeclarativeDebugServerConnection
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QTcpServerConnection)
+ Q_DISABLE_COPY(QTcpServerConnection)
+ Q_INTERFACES(QDeclarativeDebugServerConnection)
+
+
+public:
+ QTcpServerConnection();
+ ~QTcpServerConnection();
+
+ void setServer(QDeclarativeDebugServer *server);
+ void setPort(int port, bool bock);
+
+ bool isConnected() const;
+ void send(const QByteArray &message);
+ void disconnect();
+
+ void listen();
+ void waitForConnection();
+
+private Q_SLOTS:
+ void readyRead();
+ void newConnection();
+
+private:
+ QTcpServerConnectionPrivate *d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTCPSERVERCONNECTION_H
diff --git a/src/plugins/qmltooling/tcpserver/tcpserver.pro b/src/plugins/qmltooling/tcpserver/tcpserver.pro
new file mode 100644
index 0000000..f4f2666
--- /dev/null
+++ b/src/plugins/qmltooling/tcpserver/tcpserver.pro
@@ -0,0 +1,18 @@
+TARGET = tcpserver
+QT += declarative network
+
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/qmltooling
+QTDIR_build:REQUIRES += "contains(QT_CONFIG, declarative)"
+
+SOURCES += \
+ qtcpserverconnection.cpp
+
+HEADERS += \
+ qtcpserverconnection.h
+
+target.path += $$[QT_INSTALL_PLUGINS]/qmltooling
+INSTALLS += target
+
+symbian:TARGET.UID3=0x20031E90 \ No newline at end of file
diff --git a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri
index ebeccc9..b7a87f3 100644
--- a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri
+++ b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri
@@ -34,6 +34,12 @@
silent:symbian_sqlite3_dso.commands = @echo unzipping $@ && $$symbian_sqlite3_dso.commands
QMAKE_EXTRA_COMPILERS += symbian_sqlite3_dso
+ # Workaround for the fact that make doesn't understand that sqlite3.dso
+ # is the same as $OBJECTS_DIR/sqlite3.dso
+ symbian_sqlite3_dso_standalone.target = sqlite3.dso
+ symbian_sqlite3_dso_standalone.depends = $$symbian_sqlite3_dso.output
+ QMAKE_EXTRA_TARGETS += symbian_sqlite3_dso_standalone
+
symbian_sqlite3_ver_dso.input = symbian_sqlite3_zip_file
symbian_sqlite3_ver_dso.output = sqlite3{00060003}.dso
!isEmpty(OBJECTS_DIR):symbian_sqlite3_ver_dso.output = $$OBJECTS_DIR/$$symbian_sqlite3_ver_dso.output
diff --git a/src/qbase.pri b/src/qbase.pri
index 4d835bd..ce69757 100644
--- a/src/qbase.pri
+++ b/src/qbase.pri
@@ -197,7 +197,7 @@ symbian {
# Partial upgrade SIS file
vendorinfo = \
"; Localised Vendor name" \
- "%{\"Nokia, Qt\"}" \
+ "%{\"Nokia\"}" \
" " \
"; Unique Vendor name" \
":\"Nokia, Qt\"" \
diff --git a/src/qt3support/network/q3dns.cpp b/src/qt3support/network/q3dns.cpp
index c95edc1..d489652 100644
--- a/src/qt3support/network/q3dns.cpp
+++ b/src/qt3support/network/q3dns.cpp
@@ -2009,15 +2009,20 @@ Q3ValueList<QHostAddress> Q3Dns::addresses() const
\class Q3Dns::MailServer
\brief The Q3Dns::MailServer class is described in Q3Dns::mailServers().
- \internal
+*/
+
+
+/*! \fn Q3Dns::MailServer::MailServer(const QString& n, Q_UINT16 p)
+ The constructor sets the public data members name and priority.
+ \a n is the name and \a p is the priority.
*/
/*!
Returns a list of mail servers if the record type is \c Mx. The
class Q3Dns::MailServer contains the following public variables:
\list
- \i QString Q3Dns::MailServer::name
- \i Q_UINT16 Q3Dns::MailServer::priority
+ \o QString Q3Dns::MailServer::name
+ \o Q_UINT16 Q3Dns::MailServer::priority
\endlist
Note that if you want to iterate over the list, you should iterate
@@ -2048,22 +2053,26 @@ Q3ValueList<Q3Dns::MailServer> Q3Dns::mailServers() const
return result;
}
-
/*!
\class Q3Dns::Server
\brief The Q3Dns::Server class is described in Q3Dns::servers().
- \internal
+*/
+
+/*! \fn Q3Dns::Server::Server(const QString& n, Q_UINT16 p, Q_UINT16 w, Q_UINT16 po)
+ The constructor sets the public data members name, priority,
+ weight, and port. \a n is the name, \a p is the priority,
+ \a w is the weight, and \a po is the port.
*/
/*!
Returns a list of servers if the record type is \c Srv. The class
Q3Dns::Server contains the following public variables:
\list
- \i QString Q3Dns::Server::name
- \i Q_UINT16 Q3Dns::Server::priority
- \i Q_UINT16 Q3Dns::Server::weight
- \i Q_UINT16 Q3Dns::Server::port
+ \o QString Q3Dns::Server::name
+ \o Q_UINT16 Q3Dns::Server::priority
+ \o Q_UINT16 Q3Dns::Server::weight
+ \o Q_UINT16 Q3Dns::Server::port
\endlist
Note that if you want to iterate over the list, you should iterate
diff --git a/src/qt3support/tools/q3memarray.qdoc b/src/qt3support/tools/q3memarray.qdoc
index 9f2f1cc..f05f433 100644
--- a/src/qt3support/tools/q3memarray.qdoc
+++ b/src/qt3support/tools/q3memarray.qdoc
@@ -221,8 +221,8 @@
New elements are not initialized.
- \a optim is either Q3GArray::MemOptim (the default) or
- Q3GArray::SpeedOptim. When optimizing for speed rather than memory
+ \a optim is either \c MemOptim (the default) or
+ \c SpeedOptim. When optimizing for speed rather than memory
consumption, the array uses a smart grow and shrink algorithm that
might allocate more memory than is actually needed for \a size
elements. This speeds up subsequent resize operations, for example
diff --git a/src/qt3support/tools/q3ptrlist.qdoc b/src/qt3support/tools/q3ptrlist.qdoc
index c4fdf4f..13e478e 100644
--- a/src/qt3support/tools/q3ptrlist.qdoc
+++ b/src/qt3support/tools/q3ptrlist.qdoc
@@ -93,7 +93,8 @@
also holds pointers to the next and previous list items. The
functions currentNode(), removeNode(), and takeNode() operate
directly on the Q3LNode, but they should be used with care. The
- data component of the node is available through Q3LNode::getData().
+ data component of the node is available through Q3LNode's getData()
+ function.
The Q3StrList class is a list of \c char*.
It reimplements newItem(), deleteItem() and compareItems(). (But
diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def
index a2692f7..dd7d588 100644
--- a/src/s60installs/bwins/QtCoreu.def
+++ b/src/s60installs/bwins/QtCoreu.def
@@ -4603,4 +4603,6 @@ EXPORTS
??XQPoint@@QAEAAV0@N@Z @ 4602 NONAME ; class QPoint & QPoint::operator*=(double)
??XQPoint@@QAEAAV0@H@Z @ 4603 NONAME ; class QPoint & QPoint::operator*=(int)
?hasError@QXmlStreamWriter@@QBE_NXZ @ 4604 NONAME ; bool QXmlStreamWriter::hasError(void) const
+ ?revision@QMetaProperty@@QBEHXZ @ 4605 NONAME ; int QMetaProperty::revision(void) const
+ ?revision@QMetaMethod@@QBEHXZ @ 4606 NONAME ; int QMetaMethod::revision(void) const
diff --git a/src/s60installs/bwins/QtDeclarativeu.def b/src/s60installs/bwins/QtDeclarativeu.def
index 9e88df7..7d0a83e 100644
--- a/src/s60installs/bwins/QtDeclarativeu.def
+++ b/src/s60installs/bwins/QtDeclarativeu.def
@@ -52,7 +52,7 @@ EXPORTS
?isDesignable@QMetaPropertyBuilder@@QBE_NXZ @ 51 NONAME ABSENT ; bool QMetaPropertyBuilder::isDesignable(void) const
?tr@QDeclarativeStateGroup@@SA?AVQString@@PBD0H@Z @ 52 NONAME ; class QString QDeclarativeStateGroup::tr(char const *, char const *, int)
?errors@QDeclarativeView@@QBE?AV?$QList@VQDeclarativeError@@@@XZ @ 53 NONAME ; class QList<class QDeclarativeError> QDeclarativeView::errors(void) const
- ??0QPacket@@QAE@ABV0@@Z @ 54 NONAME ABSENT ; QPacket::QPacket(class QPacket const &)
+ ??0QPacket@@QAE@ABV0@@Z @ 54 NONAME ; QPacket::QPacket(class QPacket const &)
??1QDeclarativeDebugObjectExpressionWatch@@UAE@XZ @ 55 NONAME ABSENT ; QDeclarativeDebugObjectExpressionWatch::~QDeclarativeDebugObjectExpressionWatch(void)
?status@QDeclarativePixmap@@QBE?AW4Status@1@XZ @ 56 NONAME ; enum QDeclarativePixmap::Status QDeclarativePixmap::status(void) const
?bottom@QDeclarativeAnchors@@QBE?AVQDeclarativeAnchorLine@@XZ @ 57 NONAME ABSENT ; class QDeclarativeAnchorLine QDeclarativeAnchors::bottom(void) const
@@ -69,7 +69,7 @@ EXPORTS
??0Variant@QDeclarativeParser@@QAE@ABVQString@@@Z @ 68 NONAME ; QDeclarativeParser::Variant::Variant(class QString const &)
?paintedSizeChanged@QDeclarativeText@@IAEXXZ @ 69 NONAME ABSENT ; void QDeclarativeText::paintedSizeChanged(void)
??1QDeclarativeDebugClient@@UAE@XZ @ 70 NONAME ABSENT ; QDeclarativeDebugClient::~QDeclarativeDebugClient(void)
- ?trUtf8@QPacketProtocol@@SA?AVQString@@PBD0@Z @ 71 NONAME ABSENT ; class QString QPacketProtocol::trUtf8(char const *, char const *)
+ ?trUtf8@QPacketProtocol@@SA?AVQString@@PBD0@Z @ 71 NONAME ; class QString QPacketProtocol::trUtf8(char const *, char const *)
?trUtf8@QDeclarativeListModel@@SA?AVQString@@PBD0@Z @ 72 NONAME ABSENT ; class QString QDeclarativeListModel::trUtf8(char const *, char const *)
?qt_metacast@QDeclarativeState@@UAEPAXPBD@Z @ 73 NONAME ; void * QDeclarativeState::qt_metacast(char const *)
??1QDeclarativeDebugContextReference@@QAE@XZ @ 74 NONAME ABSENT ; QDeclarativeDebugContextReference::~QDeclarativeDebugContextReference(void)
@@ -126,7 +126,7 @@ EXPORTS
?addToObject@QDeclarativeAbstractBinding@@QAEXPAVQObject@@@Z @ 125 NONAME ABSENT ; void QDeclarativeAbstractBinding::addToObject(class QObject *)
?trUtf8@QDeclarativeView@@SA?AVQString@@PBD0H@Z @ 126 NONAME ; class QString QDeclarativeView::trUtf8(char const *, char const *, int)
?d_func@QDeclarativeAnchors@@AAEPAVQDeclarativeAnchorsPrivate@@XZ @ 127 NONAME ABSENT ; class QDeclarativeAnchorsPrivate * QDeclarativeAnchors::d_func(void)
- ??1QPacket@@UAE@XZ @ 128 NONAME ABSENT ; QPacket::~QPacket(void)
+ ??1QPacket@@UAE@XZ @ 128 NONAME ; QPacket::~QPacket(void)
?top@QDeclarativeScaleGrid@@QBEHXZ @ 129 NONAME ABSENT ; int QDeclarativeScaleGrid::top(void) const
?setExpression@QDeclarativeExpression@@QAEXABVQString@@@Z @ 130 NONAME ; void QDeclarativeExpression::setExpression(class QString const &)
??1QDeclarativeDebugEngineReference@@QAE@XZ @ 131 NONAME ABSENT ; QDeclarativeDebugEngineReference::~QDeclarativeDebugEngineReference(void)
@@ -252,7 +252,7 @@ EXPORTS
??4QDeclarativeDomValueLiteral@@QAEAAV0@ABV0@@Z @ 251 NONAME ABSENT ; class QDeclarativeDomValueLiteral & QDeclarativeDomValueLiteral::operator=(class QDeclarativeDomValueLiteral const &)
?setScript@QDeclarativeScriptString@@QAEXABVQString@@@Z @ 252 NONAME ; void QDeclarativeScriptString::setScript(class QString const &)
?requestImage@QDeclarativeImageProvider@@UAE?AVQImage@@ABVQString@@PAVQSize@@ABV4@@Z @ 253 NONAME ; class QImage QDeclarativeImageProvider::requestImage(class QString const &, class QSize *, class QSize const &)
- ?qt_metacast@QPacketProtocol@@UAEPAXPBD@Z @ 254 NONAME ABSENT ; void * QPacketProtocol::qt_metacast(char const *)
+ ?qt_metacast@QPacketProtocol@@UAEPAXPBD@Z @ 254 NONAME ; void * QPacketProtocol::qt_metacast(char const *)
?addMetaObject@QMetaObjectBuilder@@QAEXPBUQMetaObject@@V?$QFlags@W4AddMember@QMetaObjectBuilder@@@@@Z @ 255 NONAME ABSENT ; void QMetaObjectBuilder::addMetaObject(struct QMetaObject const *, class QFlags<enum QMetaObjectBuilder::AddMember>)
?trUtf8@QDeclarativeRectangle@@SA?AVQString@@PBD0H@Z @ 256 NONAME ABSENT ; class QString QDeclarativeRectangle::trUtf8(char const *, char const *, int)
?qt_metacast@QDeclarativeText@@UAEPAXPBD@Z @ 257 NONAME ABSENT ; void * QDeclarativeText::qt_metacast(char const *)
@@ -263,7 +263,7 @@ EXPORTS
?create@QDeclarativeType@@QBEPAVQObject@@XZ @ 262 NONAME ABSENT ; class QObject * QDeclarativeType::create(void) const
?metaObject@QDeclarativeDebugExpressionQuery@@UBEPBUQMetaObject@@XZ @ 263 NONAME ABSENT ; struct QMetaObject const * QDeclarativeDebugExpressionQuery::metaObject(void) const
?engine@QDeclarativeView@@QBEPAVQDeclarativeEngine@@XZ @ 264 NONAME ; class QDeclarativeEngine * QDeclarativeView::engine(void) const
- ?readyRead@QPacketProtocol@@IAEXXZ @ 265 NONAME ABSENT ; void QPacketProtocol::readyRead(void)
+ ?readyRead@QPacketProtocol@@IAEXXZ @ 265 NONAME ; void QPacketProtocol::readyRead(void)
?qt_metacall@QDeclarativeValueType@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 266 NONAME ABSENT ; int QDeclarativeValueType::qt_metacall(enum QMetaObject::Call, int, void * *)
?propertyType@QDeclarativePropertyPrivate@@QBEHXZ @ 267 NONAME ABSENT ; int QDeclarativePropertyPrivate::propertyType(void) const
?inputMethodQuery@QDeclarativeItem@@MBE?AVQVariant@@W4InputMethodQuery@Qt@@@Z @ 268 NONAME ; class QVariant QDeclarativeItem::inputMethodQuery(enum Qt::InputMethodQuery) const
@@ -310,7 +310,7 @@ EXPORTS
?setSmooth@QDeclarativeItem@@QAEX_N@Z @ 309 NONAME ; void QDeclarativeItem::setSmooth(bool)
?value@QDeclarativeDebugPropertyReference@@QBE?AVQVariant@@XZ @ 310 NONAME ABSENT ; class QVariant QDeclarativeDebugPropertyReference::value(void) const
?resources@QDeclarativeItemPrivate@@QAE?AV?$QDeclarativeListProperty@VQObject@@@@XZ @ 311 NONAME ; class QDeclarativeListProperty<class QObject> QDeclarativeItemPrivate::resources(void)
- ?clear@QPacketProtocol@@QAEXXZ @ 312 NONAME ABSENT ; void QPacketProtocol::clear(void)
+ ?clear@QPacketProtocol@@QAEXXZ @ 312 NONAME ; void QPacketProtocol::clear(void)
?setState@QDeclarativeItemPrivate@@QAEXABVQString@@@Z @ 313 NONAME ; void QDeclarativeItemPrivate::setState(class QString const &)
??4QDeclarativeDebugPropertyReference@@QAEAAV0@ABV0@@Z @ 314 NONAME ABSENT ; class QDeclarativeDebugPropertyReference & QDeclarativeDebugPropertyReference::operator=(class QDeclarativeDebugPropertyReference const &)
?metaObject@QDeclarativeView@@UBEPBUQMetaObject@@XZ @ 315 NONAME ; struct QMetaObject const * QDeclarativeView::metaObject(void) const
@@ -377,7 +377,7 @@ EXPORTS
?status@QDeclarativeView@@QBE?AW4Status@1@XZ @ 376 NONAME ; enum QDeclarativeView::Status QDeclarativeView::status(void) const
??0QDeclarativeEngineDebug@@QAE@PAVQDeclarativeDebugConnection@@PAVQObject@@@Z @ 377 NONAME ABSENT ; QDeclarativeEngineDebug::QDeclarativeEngineDebug(class QDeclarativeDebugConnection *, class QObject *)
?create@QDeclarativeComponent@@UAEPAVQObject@@PAVQDeclarativeContext@@@Z @ 378 NONAME ; class QObject * QDeclarativeComponent::create(class QDeclarativeContext *)
- ??_EQPacket@@UAE@I@Z @ 379 NONAME ABSENT ; QPacket::~QPacket(unsigned int)
+ ??_EQPacket@@UAE@I@Z @ 379 NONAME ; QPacket::~QPacket(unsigned int)
?trUtf8@QDeclarativeScaleGrid@@SA?AVQString@@PBD0H@Z @ 380 NONAME ABSENT ; class QString QDeclarativeScaleGrid::trUtf8(char const *, char const *, int)
?isResettable@QDeclarativeProperty@@QBE_NXZ @ 381 NONAME ; bool QDeclarativeProperty::isResettable(void) const
?isList@QDeclarativeCustomParserProperty@@QBE_NXZ @ 382 NONAME ; bool QDeclarativeCustomParserProperty::isList(void) const
@@ -428,7 +428,7 @@ EXPORTS
?line@QDeclarativeError@@QBEHXZ @ 427 NONAME ; int QDeclarativeError::line(void) const
?heightValid@QDeclarativeItem@@IBE_NXZ @ 428 NONAME ; bool QDeclarativeItem::heightValid(void) const
??1QDeclarativeOpenMetaObject@@UAE@XZ @ 429 NONAME ABSENT ; QDeclarativeOpenMetaObject::~QDeclarativeOpenMetaObject(void)
- ??0QPacket@@QAE@XZ @ 430 NONAME ABSENT ; QPacket::QPacket(void)
+ ??0QPacket@@QAE@XZ @ 430 NONAME ; QPacket::QPacket(void)
?trUtf8@QDeclarativePropertyMap@@SA?AVQString@@PBD0H@Z @ 431 NONAME ; class QString QDeclarativePropertyMap::trUtf8(char const *, char const *, int)
?trUtf8@QDeclarativeEngine@@SA?AVQString@@PBD0H@Z @ 432 NONAME ; class QString QDeclarativeEngine::trUtf8(char const *, char const *, int)
??0QDeclarativeDebugEngineReference@@QAE@XZ @ 433 NONAME ABSENT ; QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(void)
@@ -485,7 +485,7 @@ EXPORTS
?staticMetaObject@QDeclarativeDebugService@@2UQMetaObject@@B @ 484 NONAME ABSENT ; struct QMetaObject const QDeclarativeDebugService::staticMetaObject
?topMargin@QDeclarativeAnchors@@QBEMXZ @ 485 NONAME ABSENT ; float QDeclarativeAnchors::topMargin(void) const
??0QDeclarativeDebugExpressionQuery@@AAE@PAVQObject@@@Z @ 486 NONAME ABSENT ; QDeclarativeDebugExpressionQuery::QDeclarativeDebugExpressionQuery(class QObject *)
- ??0QPacket@@IAE@ABVQByteArray@@@Z @ 487 NONAME ABSENT ; QPacket::QPacket(class QByteArray const &)
+ ??0QPacket@@IAE@ABVQByteArray@@@Z @ 487 NONAME ; QPacket::QPacket(class QByteArray const &)
?implicitSize@QDeclarativePixmap@@QBEABVQSize@@XZ @ 488 NONAME ; class QSize const & QDeclarativePixmap::implicitSize(void) const
?setFlags@QMetaObjectBuilder@@QAEXV?$QFlags@W4MetaObjectFlag@QMetaObjectBuilder@@@@@Z @ 489 NONAME ABSENT ; void QMetaObjectBuilder::setFlags(class QFlags<enum QMetaObjectBuilder::MetaObjectFlag>)
?horizontalCenterChanged@QDeclarativeAnchors@@IAEXXZ @ 490 NONAME ABSENT ; void QDeclarativeAnchors::horizontalCenterChanged(void)
@@ -502,7 +502,7 @@ EXPORTS
?qmlAttachedPropertiesObject@@YAPAVQObject@@PAHPBV1@PBUQMetaObject@@_N@Z @ 501 NONAME ; class QObject * qmlAttachedPropertiesObject(int *, class QObject const *, struct QMetaObject const *, bool)
??_EQDeclarativeDebugClient@@UAE@I@Z @ 502 NONAME ABSENT ; QDeclarativeDebugClient::~QDeclarativeDebugClient(unsigned int)
??4QDeclarativeDomComponent@@QAEAAV0@ABV0@@Z @ 503 NONAME ABSENT ; class QDeclarativeDomComponent & QDeclarativeDomComponent::operator=(class QDeclarativeDomComponent const &)
- ?tr@QPacketProtocol@@SA?AVQString@@PBD0@Z @ 504 NONAME ABSENT ; class QString QPacketProtocol::tr(char const *, char const *)
+ ?tr@QPacketProtocol@@SA?AVQString@@PBD0@Z @ 504 NONAME ; class QString QPacketProtocol::tr(char const *, char const *)
?setFont@QDeclarativeText@@QAEXABVQFont@@@Z @ 505 NONAME ABSENT ; void QDeclarativeText::setFont(class QFont const &)
?fromChanged@QDeclarativeTransition@@IAEXXZ @ 506 NONAME ; void QDeclarativeTransition::fromChanged(void)
?addMethod@QMetaObjectBuilder@@QAE?AVQMetaMethodBuilder@@ABVQMetaMethod@@@Z @ 507 NONAME ABSENT ; class QMetaMethodBuilder QMetaObjectBuilder::addMethod(class QMetaMethod const &)
@@ -610,7 +610,7 @@ EXPORTS
??0QDeclarativeListReference@@QAE@PAVQObject@@PBDPAVQDeclarativeEngine@@@Z @ 609 NONAME ; QDeclarativeListReference::QDeclarativeListReference(class QObject *, char const *, class QDeclarativeEngine *)
?setData@QListModelInterface@@UAE_NHABV?$QHash@HVQVariant@@@@@Z @ 610 NONAME ABSENT ; bool QListModelInterface::setData(int, class QHash<int, class QVariant> const &)
??0QDeclarativePen@@QAE@PAVQObject@@@Z @ 611 NONAME ABSENT ; QDeclarativePen::QDeclarativePen(class QObject *)
- ?trUtf8@QPacketProtocol@@SA?AVQString@@PBD0H@Z @ 612 NONAME ABSENT ; class QString QPacketProtocol::trUtf8(char const *, char const *, int)
+ ?trUtf8@QPacketProtocol@@SA?AVQString@@PBD0H@Z @ 612 NONAME ; class QString QPacketProtocol::trUtf8(char const *, char const *, int)
?setContextObject@QDeclarativeContext@@QAEXPAVQObject@@@Z @ 613 NONAME ; void QDeclarativeContext::setContextObject(class QObject *)
??_EQDeclarativeState@@UAE@I@Z @ 614 NONAME ; QDeclarativeState::~QDeclarativeState(unsigned int)
?expression@QDeclarativeExpression@@QBE?AVQString@@XZ @ 615 NONAME ; class QString QDeclarativeExpression::expression(void) const
@@ -668,7 +668,7 @@ EXPORTS
?setStdCppSet@QMetaPropertyBuilder@@QAEX_N@Z @ 667 NONAME ABSENT ; void QMetaPropertyBuilder::setStdCppSet(bool)
??0QDeclarativeItemPrivate@@QAE@XZ @ 668 NONAME ; QDeclarativeItemPrivate::QDeclarativeItemPrivate(void)
??0QDeclarativeDebugService@@QAE@ABVQString@@PAVQObject@@@Z @ 669 NONAME ABSENT ; QDeclarativeDebugService::QDeclarativeDebugService(class QString const &, class QObject *)
- ?load@QDeclarativePixmap@@QAEXPAVQDeclarativeEngine@@ABVQUrl@@_N@Z @ 670 NONAME ; void QDeclarativePixmap::load(class QDeclarativeEngine *, class QUrl const &, bool)
+ ?load@QDeclarativePixmap@@QAEXPAVQDeclarativeEngine@@ABVQUrl@@_N@Z @ 670 NONAME ABSENT ; void QDeclarativePixmap::load(class QDeclarativeEngine *, class QUrl const &, bool)
??_EQPacketAutoSend@@UAE@I@Z @ 671 NONAME ABSENT ; QPacketAutoSend::~QPacketAutoSend(unsigned int)
?saveValueType@QDeclarativePropertyPrivate@@SA?AVQByteArray@@PBUQMetaObject@@H0H@Z @ 672 NONAME ABSENT ; class QByteArray QDeclarativePropertyPrivate::saveValueType(struct QMetaObject const *, int, struct QMetaObject const *, int)
?resetHeight@QDeclarativeItem@@QAEXXZ @ 673 NONAME ; void QDeclarativeItem::resetHeight(void)
@@ -688,7 +688,7 @@ EXPORTS
?d_func@QDeclarativeDebugClient@@AAEPAVQDeclarativeDebugClientPrivate@@XZ @ 687 NONAME ABSENT ; class QDeclarativeDebugClientPrivate * QDeclarativeDebugClient::d_func(void)
??1QDeclarativeType@@AAE@XZ @ 688 NONAME ABSENT ; QDeclarativeType::~QDeclarativeType(void)
?colorFromString@QDeclarativeStringConverters@@YA?AVQColor@@ABVQString@@PA_N@Z @ 689 NONAME ABSENT ; class QColor QDeclarativeStringConverters::colorFromString(class QString const &, bool *)
- ??_EQPacketProtocol@@UAE@I@Z @ 690 NONAME ABSENT ; QPacketProtocol::~QPacketProtocol(unsigned int)
+ ??_EQPacketProtocol@@UAE@I@Z @ 690 NONAME ; QPacketProtocol::~QPacketProtocol(unsigned int)
?tr@QDeclarativeListModel@@SA?AVQString@@PBD0@Z @ 691 NONAME ABSENT ; class QString QDeclarativeListModel::tr(char const *, char const *)
??0QDeclarativePixmap@@QAE@XZ @ 692 NONAME ; QDeclarativePixmap::QDeclarativePixmap(void)
??0QDeclarativeDebugObjectReference@@QAE@XZ @ 693 NONAME ABSENT ; QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(void)
@@ -704,7 +704,7 @@ EXPORTS
??4QDeclarativeDomDocument@@QAEAAV0@ABV0@@Z @ 703 NONAME ABSENT ; class QDeclarativeDomDocument & QDeclarativeDomDocument::operator=(class QDeclarativeDomDocument const &)
??0QDeclarativeOpenMetaObject@@QAE@PAVQObject@@PAVQDeclarativeOpenMetaObjectType@@_N@Z @ 704 NONAME ABSENT ; QDeclarativeOpenMetaObject::QDeclarativeOpenMetaObject(class QObject *, class QDeclarativeOpenMetaObjectType *, bool)
?trUtf8@QDeclarativeExpression@@SA?AVQString@@PBD0@Z @ 705 NONAME ; class QString QDeclarativeExpression::trUtf8(char const *, char const *)
- ??0QPacketProtocol@@QAE@PAVQIODevice@@PAVQObject@@@Z @ 706 NONAME ABSENT ; QPacketProtocol::QPacketProtocol(class QIODevice *, class QObject *)
+ ??0QPacketProtocol@@QAE@PAVQIODevice@@PAVQObject@@@Z @ 706 NONAME ; QPacketProtocol::QPacketProtocol(class QIODevice *, class QObject *)
??1QDeclarativeListReference@@QAE@XZ @ 707 NONAME ; QDeclarativeListReference::~QDeclarativeListReference(void)
?clearError@QDeclarativeExpression@@QAEXXZ @ 708 NONAME ; void QDeclarativeExpression::clearError(void)
?setLineNumber@QDeclarativeDebugFileReference@@QAEXH@Z @ 709 NONAME ABSENT ; void QDeclarativeDebugFileReference::setLineNumber(int)
@@ -757,7 +757,7 @@ EXPORTS
??4QDeclarativeDomValueBinding@@QAEAAV0@ABV0@@Z @ 756 NONAME ABSENT ; class QDeclarativeDomValueBinding & QDeclarativeDomValueBinding::operator=(class QDeclarativeDomValueBinding const &)
??0QDeclarativeExpression@@QAE@XZ @ 757 NONAME ; QDeclarativeExpression::QDeclarativeExpression(void)
?paint@QDeclarativeItem@@UAEXPAVQPainter@@PBVQStyleOptionGraphicsItem@@PAVQWidget@@@Z @ 758 NONAME ; void QDeclarativeItem::paint(class QPainter *, class QStyleOptionGraphicsItem const *, class QWidget *)
- ?send@QPacketProtocol@@QAE?AVQPacketAutoSend@@XZ @ 759 NONAME ABSENT ; class QPacketAutoSend QPacketProtocol::send(void)
+ ?send@QPacketProtocol@@QAE?AVQPacketAutoSend@@XZ @ 759 NONAME ; class QPacketAutoSend QPacketProtocol::send(void)
?countChanged@QDeclarativeListModel@@IAEXXZ @ 760 NONAME ABSENT ; void QDeclarativeListModel::countChanged(void)
??0QDeclarativeGridScaledImage@@QAE@PAVQIODevice@@@Z @ 761 NONAME ABSENT ; QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(class QIODevice *)
??_EQDeclarativeBinding@@UAE@I@Z @ 762 NONAME ABSENT ; QDeclarativeBinding::~QDeclarativeBinding(unsigned int)
@@ -776,7 +776,7 @@ EXPORTS
?hasNotifySignal@QDeclarativeProperty@@QBE_NXZ @ 775 NONAME ; bool QDeclarativeProperty::hasNotifySignal(void) const
?create@QDeclarativeType@@QBEXPAPAVQObject@@PAPAXI@Z @ 776 NONAME ABSENT ; void QDeclarativeType::create(class QObject * *, void * *, unsigned int) const
?reversible@QDeclarativeTransition@@QBE_NXZ @ 777 NONAME ; bool QDeclarativeTransition::reversible(void) const
- ?invalidPacket@QPacketProtocol@@IAEXXZ @ 778 NONAME ABSENT ; void QPacketProtocol::invalidPacket(void)
+ ?invalidPacket@QPacketProtocol@@IAEXXZ @ 778 NONAME ; void QPacketProtocol::invalidPacket(void)
??0QDeclarativeDebugObjectReference@@QAE@H@Z @ 779 NONAME ABSENT ; QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(int)
?superClass@QMetaObjectBuilder@@QBEPBUQMetaObject@@XZ @ 780 NONAME ABSENT ; struct QMetaObject const * QMetaObjectBuilder::superClass(void) const
?isValid@QDeclarativeListReference@@QBE_NXZ @ 781 NONAME ; bool QDeclarativeListReference::isValid(void) const
@@ -813,7 +813,7 @@ EXPORTS
??_EQDeclarativeDebugQuery@@UAE@I@Z @ 812 NONAME ABSENT ; QDeclarativeDebugQuery::~QDeclarativeDebugQuery(unsigned int)
?update@QDeclarativeAbstractBinding@@QAEXXZ @ 813 NONAME ABSENT ; void QDeclarativeAbstractBinding::update(void)
?tr@QDeclarativeBehavior@@SA?AVQString@@PBD0H@Z @ 814 NONAME ABSENT ; class QString QDeclarativeBehavior::tr(char const *, char const *, int)
- ?read@QPacketProtocol@@QAE?AVQPacket@@XZ @ 815 NONAME ABSENT ; class QPacket QPacketProtocol::read(void)
+ ?read@QPacketProtocol@@QAE?AVQPacket@@XZ @ 815 NONAME ; class QPacket QPacketProtocol::read(void)
?setParentItem@QDeclarativeItem@@QAEXPAV1@@Z @ 816 NONAME ; void QDeclarativeItem::setParentItem(class QDeclarativeItem *)
?qmlAttachedProperties@QDeclarativeComponent@@SAPAVQDeclarativeComponentAttached@@PAVQObject@@@Z @ 817 NONAME ; class QDeclarativeComponentAttached * QDeclarativeComponent::qmlAttachedProperties(class QObject *)
??0QDeclarativeView@@QAE@ABVQUrl@@PAVQWidget@@@Z @ 818 NONAME ; QDeclarativeView::QDeclarativeView(class QUrl const &, class QWidget *)
@@ -821,7 +821,7 @@ EXPORTS
??_EQDeclarativeView@@UAE@I@Z @ 820 NONAME ; QDeclarativeView::~QDeclarativeView(unsigned int)
?trUtf8@QDeclarativeStateGroup@@SA?AVQString@@PBD0H@Z @ 821 NONAME ; class QString QDeclarativeStateGroup::trUtf8(char const *, char const *, int)
?tag@QMetaMethodBuilder@@QBE?AVQByteArray@@XZ @ 822 NONAME ABSENT ; class QByteArray QMetaMethodBuilder::tag(void) const
- ?getStaticMetaObject@QPacketProtocol@@SAABUQMetaObject@@XZ @ 823 NONAME ABSENT ; struct QMetaObject const & QPacketProtocol::getStaticMetaObject(void)
+ ?getStaticMetaObject@QPacketProtocol@@SAABUQMetaObject@@XZ @ 823 NONAME ; struct QMetaObject const & QPacketProtocol::getStaticMetaObject(void)
?setContext@QDeclarativeScriptString@@QAEXPAVQDeclarativeContext@@@Z @ 824 NONAME ; void QDeclarativeScriptString::setContext(class QDeclarativeContext *)
?addImageProvider@QDeclarativeEngine@@QAEXABVQString@@PAVQDeclarativeImageProvider@@@Z @ 825 NONAME ; void QDeclarativeEngine::addImageProvider(class QString const &, class QDeclarativeImageProvider *)
?d_func@QDeclarativeStateGroup@@ABEPBVQDeclarativeStateGroupPrivate@@XZ @ 826 NONAME ; class QDeclarativeStateGroupPrivate const * QDeclarativeStateGroup::d_func(void) const
@@ -1013,7 +1013,7 @@ EXPORTS
?agent@QDeclarativeListModel@@QAEPAVQDeclarativeListModelWorkerAgent@@XZ @ 1012 NONAME ABSENT ; class QDeclarativeListModelWorkerAgent * QDeclarativeListModel::agent(void)
?engine@QDeclarativeExpression@@QBEPAVQDeclarativeEngine@@XZ @ 1013 NONAME ; class QDeclarativeEngine * QDeclarativeExpression::engine(void) const
??_EQDeclarativeDebugWatch@@UAE@I@Z @ 1014 NONAME ABSENT ; QDeclarativeDebugWatch::~QDeclarativeDebugWatch(unsigned int)
- ?isEmpty@QPacket@@QBE_NXZ @ 1015 NONAME ABSENT ; bool QPacket::isEmpty(void) const
+ ?isEmpty@QPacket@@QBE_NXZ @ 1015 NONAME ; bool QPacket::isEmpty(void) const
?qmlType@QDeclarativeMetaType@@SAPAVQDeclarativeType@@PBUQMetaObject@@@Z @ 1016 NONAME ABSENT ; class QDeclarativeType * QDeclarativeMetaType::qmlType(struct QMetaObject const *)
?setFill@QDeclarativeAnchors@@QAEXPAVQGraphicsObject@@@Z @ 1017 NONAME ABSENT ; void QDeclarativeAnchors::setFill(class QGraphicsObject *)
?setHAlign@QDeclarativeText@@QAEXW4HAlignment@1@@Z @ 1018 NONAME ABSENT ; void QDeclarativeText::setHAlign(enum QDeclarativeText::HAlignment)
@@ -1029,7 +1029,7 @@ EXPORTS
?staticMetaObject@QDeclarativeText@@2UQMetaObject@@B @ 1028 NONAME ABSENT ; struct QMetaObject const QDeclarativeText::staticMetaObject
?color@QDeclarativeRectangle@@QBE?AVQColor@@XZ @ 1029 NONAME ABSENT ; class QColor QDeclarativeRectangle::color(void) const
?isEnabled@QDeclarativeDebugClient@@QBE_NXZ @ 1030 NONAME ABSENT ; bool QDeclarativeDebugClient::isEnabled(void) const
- ?send@QPacketProtocol@@QAEXABVQPacket@@@Z @ 1031 NONAME ABSENT ; void QPacketProtocol::send(class QPacket const &)
+ ?send@QPacketProtocol@@QAEXABVQPacket@@@Z @ 1031 NONAME ; void QPacketProtocol::send(class QPacket const &)
?width@QDeclarativePixmap@@QBEHXZ @ 1032 NONAME ; int QDeclarativePixmap::width(void) const
?error@QDeclarativeCustomParser@@IAEXABVQDeclarativeCustomParserNode@@ABVQString@@@Z @ 1033 NONAME ; void QDeclarativeCustomParser::error(class QDeclarativeCustomParserNode const &, class QString const &)
?defaultProperty@QDeclarativeMetaType@@SA?AVQMetaProperty@@PBUQMetaObject@@@Z @ 1034 NONAME ABSENT ; class QMetaProperty QDeclarativeMetaType::defaultProperty(struct QMetaObject const *)
@@ -1043,7 +1043,7 @@ EXPORTS
?trUtf8@QDeclarativeAnchors@@SA?AVQString@@PBD0@Z @ 1042 NONAME ABSENT ; class QString QDeclarativeAnchors::trUtf8(char const *, char const *)
?getStaticMetaObject@QDeclarativeValueType@@SAABUQMetaObject@@XZ @ 1043 NONAME ABSENT ; struct QMetaObject const & QDeclarativeValueType::getStaticMetaObject(void)
?valueChanged@QDeclarativePropertyMap@@IAEXABVQString@@ABVQVariant@@@Z @ 1044 NONAME ; void QDeclarativePropertyMap::valueChanged(class QString const &, class QVariant const &)
- ?staticMetaObject@QPacketProtocol@@2UQMetaObject@@B @ 1045 NONAME ABSENT ; struct QMetaObject const QPacketProtocol::staticMetaObject
+ ?staticMetaObject@QPacketProtocol@@2UQMetaObject@@B @ 1045 NONAME ; struct QMetaObject const QPacketProtocol::staticMetaObject
?tr@QDeclarativeListModel@@SA?AVQString@@PBD0H@Z @ 1046 NONAME ABSENT ; class QString QDeclarativeListModel::tr(char const *, char const *, int)
??0QDeclarativeScriptString@@QAE@XZ @ 1047 NONAME ; QDeclarativeScriptString::QDeclarativeScriptString(void)
?tr@QListModelInterface@@SA?AVQString@@PBD0@Z @ 1048 NONAME ABSENT ; class QString QListModelInterface::tr(char const *, char const *)
@@ -1088,7 +1088,7 @@ EXPORTS
?resetWidth@QDeclarativeItemPrivate@@UAEXXZ @ 1087 NONAME ; void QDeclarativeItemPrivate::resetWidth(void)
??AQDeclarativeOpenMetaObject@@QAEAAVQVariant@@ABVQByteArray@@@Z @ 1088 NONAME ABSENT ; class QVariant & QDeclarativeOpenMetaObject::operator[](class QByteArray const &)
?bottom@QDeclarativeItemPrivate@@QBE?AVQDeclarativeAnchorLine@@XZ @ 1089 NONAME ; class QDeclarativeAnchorLine QDeclarativeItemPrivate::bottom(void) const
- ?device@QPacketProtocol@@QAEPAVQIODevice@@XZ @ 1090 NONAME ABSENT ; class QIODevice * QPacketProtocol::device(void)
+ ?device@QPacketProtocol@@QAEPAVQIODevice@@XZ @ 1090 NONAME ; class QIODevice * QPacketProtocol::device(void)
?trUtf8@QDeclarativeStateGroup@@SA?AVQString@@PBD0@Z @ 1091 NONAME ; class QString QDeclarativeStateGroup::trUtf8(char const *, char const *)
?variantFromString@QDeclarativeStringConverters@@YA?AVQVariant@@ABVQString@@HPA_N@Z @ 1092 NONAME ABSENT ; class QVariant QDeclarativeStringConverters::variantFromString(class QString const &, int, bool *)
?metaObject@QDeclarativeComponent@@UBEPBUQMetaObject@@XZ @ 1093 NONAME ; struct QMetaObject const * QDeclarativeComponent::metaObject(void) const
@@ -1110,7 +1110,7 @@ EXPORTS
??0QDeclarativeDebugFileReference@@QAE@XZ @ 1109 NONAME ABSENT ; QDeclarativeDebugFileReference::QDeclarativeDebugFileReference(void)
?mapFromItem@QDeclarativeItem@@QBE?AVQScriptValue@@ABV2@MM@Z @ 1110 NONAME ; class QScriptValue QDeclarativeItem::mapFromItem(class QScriptValue const &, float, float) const
?trUtf8@QDeclarativeStateOperation@@SA?AVQString@@PBD0H@Z @ 1111 NONAME ; class QString QDeclarativeStateOperation::trUtf8(char const *, char const *, int)
- ?tr@QPacketProtocol@@SA?AVQString@@PBD0H@Z @ 1112 NONAME ABSENT ; class QString QPacketProtocol::tr(char const *, char const *, int)
+ ?tr@QPacketProtocol@@SA?AVQString@@PBD0H@Z @ 1112 NONAME ; class QString QPacketProtocol::tr(char const *, char const *, int)
?d_func@QDeclarativeAnchors@@ABEPBVQDeclarativeAnchorsPrivate@@XZ @ 1113 NONAME ABSENT ; class QDeclarativeAnchorsPrivate const * QDeclarativeAnchors::d_func(void) const
?setNotifySignal@QMetaPropertyBuilder@@QAEXABVQMetaMethodBuilder@@@Z @ 1114 NONAME ABSENT ; void QMetaPropertyBuilder::setNotifySignal(class QMetaMethodBuilder const &)
?enabled@QDeclarativeBehavior@@QBE_NXZ @ 1115 NONAME ABSENT ; bool QDeclarativeBehavior::enabled(void) const
@@ -1132,7 +1132,7 @@ EXPORTS
?noCreationReason@QDeclarativeType@@QBE?AVQString@@XZ @ 1131 NONAME ABSENT ; class QString QDeclarativeType::noCreationReason(void) const
?setUrl@QDeclarativeDebugFileReference@@QAEXABVQUrl@@@Z @ 1132 NONAME ABSENT ; void QDeclarativeDebugFileReference::setUrl(class QUrl const &)
??1QDeclarativeCustomParserProperty@@QAE@XZ @ 1133 NONAME ; QDeclarativeCustomParserProperty::~QDeclarativeCustomParserProperty(void)
- ??1QPacketProtocol@@UAE@XZ @ 1134 NONAME ABSENT ; QPacketProtocol::~QPacketProtocol(void)
+ ??1QPacketProtocol@@UAE@XZ @ 1134 NONAME ; QPacketProtocol::~QPacketProtocol(void)
??1QDeclarativeAbstractBinding@@MAE@XZ @ 1135 NONAME ABSENT ; QDeclarativeAbstractBinding::~QDeclarativeAbstractBinding(void)
?indexOfEnumerator@QMetaObjectBuilder@@QAEHABVQByteArray@@@Z @ 1136 NONAME ABSENT ; int QMetaObjectBuilder::indexOfEnumerator(class QByteArray const &)
?qt_metacast@QDeclarativePen@@UAEPAXPBD@Z @ 1137 NONAME ABSENT ; void * QDeclarativePen::qt_metacast(char const *)
@@ -1222,7 +1222,7 @@ EXPORTS
?statusChanged@QDeclarativeComponent@@IAEXW4Status@1@@Z @ 1221 NONAME ; void QDeclarativeComponent::statusChanged(enum QDeclarativeComponent::Status)
?setTarget@QDeclarativeBinding@@QAEXABVQDeclarativeProperty@@@Z @ 1222 NONAME ABSENT ; void QDeclarativeBinding::setTarget(class QDeclarativeProperty const &)
?imageProvider@QDeclarativeEngine@@QBEPAVQDeclarativeImageProvider@@ABVQString@@@Z @ 1223 NONAME ; class QDeclarativeImageProvider * QDeclarativeEngine::imageProvider(class QString const &) const
- ?packetsAvailable@QPacketProtocol@@QBE_JXZ @ 1224 NONAME ABSENT ; long long QPacketProtocol::packetsAvailable(void) const
+ ?packetsAvailable@QPacketProtocol@@QBE_JXZ @ 1224 NONAME ; long long QPacketProtocol::packetsAvailable(void) const
?state@QDeclarativeDebugWatch@@QBE?AW4State@1@XZ @ 1225 NONAME ABSENT ; enum QDeclarativeDebugWatch::State QDeclarativeDebugWatch::state(void) const
?attachedPropertiesFuncById@QDeclarativeMetaType@@SAP6APAVQObject@@PAV2@@ZH@Z @ 1226 NONAME ABSENT ; class QObject * (*)(class QObject *) QDeclarativeMetaType::attachedPropertiesFuncById(int)
?resetBaseline@QDeclarativeAnchors@@QAEXXZ @ 1227 NONAME ABSENT ; void QDeclarativeAnchors::resetBaseline(void)
@@ -1341,7 +1341,7 @@ EXPORTS
?implicitWidth@QDeclarativeItem@@QBEMXZ @ 1340 NONAME ; float QDeclarativeItem::implicitWidth(void) const
?metaObject@QDeclarativeContext@@UBEPBUQMetaObject@@XZ @ 1341 NONAME ; struct QMetaObject const * QDeclarativeContext::metaObject(void) const
??0QDeclarativeContext@@AAE@PAVQDeclarativeContextData@@@Z @ 1342 NONAME ; QDeclarativeContext::QDeclarativeContext(class QDeclarativeContextData *)
- ?maximumPacketSize@QPacketProtocol@@QBEHXZ @ 1343 NONAME ABSENT ; int QPacketProtocol::maximumPacketSize(void) const
+ ?maximumPacketSize@QPacketProtocol@@QBEHXZ @ 1343 NONAME ; int QPacketProtocol::maximumPacketSize(void) const
??_EQDeclarativeDebuggerStatus@@UAE@I@Z @ 1344 NONAME ABSENT ; QDeclarativeDebuggerStatus::~QDeclarativeDebuggerStatus(unsigned int)
?error@QDeclarativeCustomParser@@IAEXABVQString@@@Z @ 1345 NONAME ; void QDeclarativeCustomParser::error(class QString const &)
?messageReceived@QDeclarativeDebugService@@MAEXABVQByteArray@@@Z @ 1346 NONAME ABSENT ; void QDeclarativeDebugService::messageReceived(class QByteArray const &)
@@ -1389,12 +1389,12 @@ EXPORTS
?setEnabled@QDeclarativeDebugClient@@QAEX_N@Z @ 1388 NONAME ABSENT ; void QDeclarativeDebugClient::setEnabled(bool)
??1QMetaObjectBuilder@@UAE@XZ @ 1389 NONAME ABSENT ; QMetaObjectBuilder::~QMetaObjectBuilder(void)
?tr@QDeclarativeStateOperation@@SA?AVQString@@PBD0@Z @ 1390 NONAME ; class QString QDeclarativeStateOperation::tr(char const *, char const *)
- ?clear@QPacket@@QAEXXZ @ 1391 NONAME ABSENT ; void QPacket::clear(void)
+ ?clear@QPacket@@QAEXXZ @ 1391 NONAME ; void QPacket::clear(void)
?getStaticMetaObject@QDeclarativeDebugClient@@SAABUQMetaObject@@XZ @ 1392 NONAME ABSENT ; struct QMetaObject const & QDeclarativeDebugClient::getStaticMetaObject(void)
??0QDeclarativeDomList@@QAE@ABV0@@Z @ 1393 NONAME ABSENT ; QDeclarativeDomList::QDeclarativeDomList(class QDeclarativeDomList const &)
?gridTop@QDeclarativeGridScaledImage@@QBEHXZ @ 1394 NONAME ABSENT ; int QDeclarativeGridScaledImage::gridTop(void) const
?setUrl@QDeclarativeError@@QAEXABVQUrl@@@Z @ 1395 NONAME ; void QDeclarativeError::setUrl(class QUrl const &)
- ?setMaximumPacketSize@QPacketProtocol@@QAEHH@Z @ 1396 NONAME ABSENT ; int QPacketProtocol::setMaximumPacketSize(int)
+ ?setMaximumPacketSize@QPacketProtocol@@QAEHH@Z @ 1396 NONAME ; int QPacketProtocol::setMaximumPacketSize(int)
??_EQDeclarativeAction@@QAE@I@Z @ 1397 NONAME ABSENT ; QDeclarativeAction::~QDeclarativeAction(unsigned int)
?trUtf8@QDeclarativeDebugWatch@@SA?AVQString@@PBD0@Z @ 1398 NONAME ABSENT ; class QString QDeclarativeDebugWatch::trUtf8(char const *, char const *)
?read@QDeclarativeProperty@@SA?AVQVariant@@PAVQObject@@ABVQString@@@Z @ 1399 NONAME ; class QVariant QDeclarativeProperty::read(class QObject *, class QString const &)
@@ -1472,7 +1472,7 @@ EXPORTS
?signalExpression@QDeclarativePropertyPrivate@@SAPAVQDeclarativeExpression@@ABVQDeclarativeProperty@@@Z @ 1471 NONAME ABSENT ; class QDeclarativeExpression * QDeclarativePropertyPrivate::signalExpression(class QDeclarativeProperty const &)
?networkAccessManagerFactory@QDeclarativeEngine@@QBEPAVQDeclarativeNetworkAccessManagerFactory@@XZ @ 1472 NONAME ; class QDeclarativeNetworkAccessManagerFactory * QDeclarativeEngine::networkAccessManagerFactory(void) const
?isStringList@Variant@QDeclarativeParser@@QBE_NXZ @ 1473 NONAME ; bool QDeclarativeParser::Variant::isStringList(void) const
- ?packetWritten@QPacketProtocol@@IAEXXZ @ 1474 NONAME ABSENT ; void QPacketProtocol::packetWritten(void)
+ ?packetWritten@QPacketProtocol@@IAEXXZ @ 1474 NONAME ; void QPacketProtocol::packetWritten(void)
?getStaticMetaObject@QDeclarativeDebugObjectQuery@@SAABUQMetaObject@@XZ @ 1475 NONAME ABSENT ; struct QMetaObject const & QDeclarativeDebugObjectQuery::getStaticMetaObject(void)
?isSignalProperty@QDeclarativeProperty@@QBE_NXZ @ 1476 NONAME ; bool QDeclarativeProperty::isSignalProperty(void) const
?d_func@QDeclarativeDebugService@@AAEPAVQDeclarativeDebugServicePrivate@@XZ @ 1477 NONAME ABSENT ; class QDeclarativeDebugServicePrivate * QDeclarativeDebugService::d_func(void)
@@ -1488,7 +1488,7 @@ EXPORTS
?qt_metacast@QDeclarativePropertyMap@@UAEPAXPBD@Z @ 1487 NONAME ; void * QDeclarativePropertyMap::qt_metacast(char const *)
?classBegin@QDeclarativeAnchors@@QAEXXZ @ 1488 NONAME ABSENT ; void QDeclarativeAnchors::classBegin(void)
?color@QDeclarativeText@@QBE?AVQColor@@XZ @ 1489 NONAME ABSENT ; class QColor QDeclarativeText::color(void) const
- ?metaObject@QPacketProtocol@@UBEPBUQMetaObject@@XZ @ 1490 NONAME ABSENT ; struct QMetaObject const * QPacketProtocol::metaObject(void) const
+ ?metaObject@QPacketProtocol@@UBEPBUQMetaObject@@XZ @ 1490 NONAME ; struct QMetaObject const * QPacketProtocol::metaObject(void) const
??4QDeclarativeGridScaledImage@@QAEAAV0@ABV0@@Z @ 1491 NONAME ABSENT ; class QDeclarativeGridScaledImage & QDeclarativeGridScaledImage::operator=(class QDeclarativeGridScaledImage const &)
?tr@QDeclarativeScaleGrid@@SA?AVQString@@PBD0@Z @ 1492 NONAME ABSENT ; class QString QDeclarativeScaleGrid::tr(char const *, char const *)
??1QDeclarativeScriptString@@QAE@XZ @ 1493 NONAME ; QDeclarativeScriptString::~QDeclarativeScriptString(void)
@@ -1619,7 +1619,7 @@ EXPORTS
?metaObject@QDeclarativeItem@@UBEPBUQMetaObject@@XZ @ 1618 NONAME ; struct QMetaObject const * QDeclarativeItem::metaObject(void) const
?clear@QDeclarativeAbstractBinding@@IAEXXZ @ 1619 NONAME ABSENT ; void QDeclarativeAbstractBinding::clear(void)
?start@QDeclarativeItemPrivate@@SAXAAVQElapsedTimer@@@Z @ 1620 NONAME ; void QDeclarativeItemPrivate::start(class QElapsedTimer &)
- ?load@QDeclarativePixmap@@QAEXPAVQDeclarativeEngine@@ABVQUrl@@ABVQSize@@_N@Z @ 1621 NONAME ; void QDeclarativePixmap::load(class QDeclarativeEngine *, class QUrl const &, class QSize const &, bool)
+ ?load@QDeclarativePixmap@@QAEXPAVQDeclarativeEngine@@ABVQUrl@@ABVQSize@@_N@Z @ 1621 NONAME ABSENT ; void QDeclarativePixmap::load(class QDeclarativeEngine *, class QUrl const &, class QSize const &, bool)
?stringToRule@QDeclarativeGridScaledImage@@CA?AW4TileMode@QDeclarativeBorderImage@@ABVQString@@@Z @ 1622 NONAME ABSENT ; enum QDeclarativeBorderImage::TileMode QDeclarativeGridScaledImage::stringToRule(class QString const &)
?setHorizontalCenter@QDeclarativeAnchors@@QAEXABVQDeclarativeAnchorLine@@@Z @ 1623 NONAME ABSENT ; void QDeclarativeAnchors::setHorizontalCenter(class QDeclarativeAnchorLine const &)
?setFocus@QDeclarativeItem@@QAEX_N@Z @ 1624 NONAME ; void QDeclarativeItem::setFocus(bool)
@@ -1631,7 +1631,7 @@ EXPORTS
??0QDeclarativeContext@@AAE@PAVQDeclarativeEngine@@_N@Z @ 1630 NONAME ; QDeclarativeContext::QDeclarativeContext(class QDeclarativeEngine *, bool)
?initialValue@QDeclarativeOpenMetaObject@@UAE?AVQVariant@@H@Z @ 1631 NONAME ABSENT ; class QVariant QDeclarativeOpenMetaObject::initialValue(int)
?tr@QDeclarativeView@@SA?AVQString@@PBD0@Z @ 1632 NONAME ; class QString QDeclarativeView::tr(char const *, char const *)
- ?qt_metacall@QPacketProtocol@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1633 NONAME ABSENT ; int QPacketProtocol::qt_metacall(enum QMetaObject::Call, int, void * *)
+ ?qt_metacall@QPacketProtocol@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1633 NONAME ; int QPacketProtocol::qt_metacall(enum QMetaObject::Call, int, void * *)
??0QDeclarativeItem@@QAE@PAV0@@Z @ 1634 NONAME ; QDeclarativeItem::QDeclarativeItem(class QDeclarativeItem *)
?hasDebuggingClient@QDeclarativeDebugService@@SA_NXZ @ 1635 NONAME ABSENT ; bool QDeclarativeDebugService::hasDebuggingClient(void)
?staticMetaObject@QDeclarativeContext@@2UQMetaObject@@B @ 1636 NONAME ; struct QMetaObject const QDeclarativeContext::staticMetaObject
@@ -1645,15 +1645,15 @@ EXPORTS
??_EQDeclarativePropertyChanges@@UAE@I@Z @ 1644 NONAME ABSENT ; QDeclarativePropertyChanges::~QDeclarativePropertyChanges(unsigned int)
?setObject@QDeclarativePropertyChanges@@QAEXPAVQObject@@@Z @ 1645 NONAME ABSENT ; void QDeclarativePropertyChanges::setObject(class QObject *)
?staticMetaObject@QDeclarativePropertyChanges@@2UQMetaObject@@B @ 1646 NONAME ABSENT ; struct QMetaObject const QDeclarativePropertyChanges::staticMetaObject
- ?removeEntryFromRevertList@QDeclarativeState@@QAE_NPAVQObject@@ABVQByteArray@@@Z @ 1647 NONAME ; bool QDeclarativeState::removeEntryFromRevertList(class QObject *, class QByteArray const &)
+ ?removeEntryFromRevertList@QDeclarativeState@@QAE_NPAVQObject@@ABVQByteArray@@@Z @ 1647 NONAME ABSENT ; bool QDeclarativeState::removeEntryFromRevertList(class QObject *, class QByteArray const &)
?restoreEntryValues@QDeclarativePropertyChanges@@QBE_NXZ @ 1648 NONAME ABSENT ; bool QDeclarativePropertyChanges::restoreEntryValues(void) const
?setRestoreEntryValues@QDeclarativePropertyChanges@@QAEX_N@Z @ 1649 NONAME ABSENT ; void QDeclarativePropertyChanges::setRestoreEntryValues(bool)
?changeValue@QDeclarativePropertyChanges@@QAEXABVQByteArray@@ABVQVariant@@@Z @ 1650 NONAME ABSENT ; void QDeclarativePropertyChanges::changeValue(class QByteArray const &, class QVariant const &)
?metaObject@QDeclarativePropertyChanges@@UBEPBUQMetaObject@@XZ @ 1651 NONAME ABSENT ; struct QMetaObject const * QDeclarativePropertyChanges::metaObject(void) const
?data_clear@QDeclarativeItemPrivate@@SAXPAV?$QDeclarativeListProperty@VQObject@@@@@Z @ 1652 NONAME ; void QDeclarativeItemPrivate::data_clear(class QDeclarativeListProperty<class QObject> *)
- ?containsPropertyInRevertList@QDeclarativeState@@QBE_NPAVQObject@@ABVQByteArray@@@Z @ 1653 NONAME ; bool QDeclarativeState::containsPropertyInRevertList(class QObject *, class QByteArray const &) const
+ ?containsPropertyInRevertList@QDeclarativeState@@QBE_NPAVQObject@@ABVQByteArray@@@Z @ 1653 NONAME ABSENT ; bool QDeclarativeState::containsPropertyInRevertList(class QObject *, class QByteArray const &) const
?containsValue@QDeclarativePropertyChanges@@QBE_NABVQByteArray@@@Z @ 1654 NONAME ABSENT ; bool QDeclarativePropertyChanges::containsValue(class QByteArray const &) const
- ?bindingInRevertList@QDeclarativeState@@QBEPAVQDeclarativeAbstractBinding@@PAVQObject@@ABVQByteArray@@@Z @ 1655 NONAME ; class QDeclarativeAbstractBinding * QDeclarativeState::bindingInRevertList(class QObject *, class QByteArray const &) const
+ ?bindingInRevertList@QDeclarativeState@@QBEPAVQDeclarativeAbstractBinding@@PAVQObject@@ABVQByteArray@@@Z @ 1655 NONAME ABSENT ; class QDeclarativeAbstractBinding * QDeclarativeState::bindingInRevertList(class QObject *, class QByteArray const &) const
?d_func@QDeclarativePropertyChanges@@ABEPBVQDeclarativePropertyChangesPrivate@@XZ @ 1656 NONAME ABSENT ; class QDeclarativePropertyChangesPrivate const * QDeclarativePropertyChanges::d_func(void) const
?containsProperty@QDeclarativePropertyChanges@@QBE_NABVQByteArray@@@Z @ 1657 NONAME ABSENT ; bool QDeclarativePropertyChanges::containsProperty(class QByteArray const &) const
?trUtf8@QDeclarativePropertyChanges@@SA?AVQString@@PBD0H@Z @ 1658 NONAME ABSENT ; class QString QDeclarativePropertyChanges::trUtf8(char const *, char const *, int)
@@ -1677,17 +1677,17 @@ EXPORTS
?addEntriesToRevertList@QDeclarativeState@@QAEXABV?$QList@VQDeclarativeAction@@@@@Z @ 1676 NONAME ; void QDeclarativeState::addEntriesToRevertList(class QList<class QDeclarativeAction> const &)
?expression@QDeclarativePropertyChanges@@QBE?AVQString@@ABVQByteArray@@@Z @ 1677 NONAME ABSENT ; class QString QDeclarativePropertyChanges::expression(class QByteArray const &) const
?object@QDeclarativePropertyChanges@@QBEPAVQObject@@XZ @ 1678 NONAME ABSENT ; class QObject * QDeclarativePropertyChanges::object(void) const
- ?valueInRevertList@QDeclarativeState@@QBE?AVQVariant@@PAVQObject@@ABVQByteArray@@@Z @ 1679 NONAME ; class QVariant QDeclarativeState::valueInRevertList(class QObject *, class QByteArray const &) const
+ ?valueInRevertList@QDeclarativeState@@QBE?AVQVariant@@PAVQObject@@ABVQByteArray@@@Z @ 1679 NONAME ABSENT ; class QVariant QDeclarativeState::valueInRevertList(class QObject *, class QByteArray const &) const
?removeAllEntriesFromRevertList@QDeclarativeState@@QAEXPAVQObject@@@Z @ 1680 NONAME ; void QDeclarativeState::removeAllEntriesFromRevertList(class QObject *)
?d_func@QDeclarativeStateOperation@@AAEPAVQDeclarativeStateOperationPrivate@@XZ @ 1681 NONAME ; class QDeclarativeStateOperationPrivate * QDeclarativeStateOperation::d_func(void)
- ?changeValueInRevertList@QDeclarativeState@@QAE_NPAVQObject@@ABVQByteArray@@ABVQVariant@@@Z @ 1682 NONAME ; bool QDeclarativeState::changeValueInRevertList(class QObject *, class QByteArray const &, class QVariant const &)
+ ?changeValueInRevertList@QDeclarativeState@@QAE_NPAVQObject@@ABVQByteArray@@ABVQVariant@@@Z @ 1682 NONAME ABSENT ; bool QDeclarativeState::changeValueInRevertList(class QObject *, class QByteArray const &, class QVariant const &)
?setIsExplicit@QDeclarativePropertyChanges@@QAEX_N@Z @ 1683 NONAME ABSENT ; void QDeclarativePropertyChanges::setIsExplicit(bool)
?isStateActive@QDeclarativeState@@QBE_NXZ @ 1684 NONAME ; bool QDeclarativeState::isStateActive(void) const
?data_count@QDeclarativeItemPrivate@@SAHPAV?$QDeclarativeListProperty@VQObject@@@@@Z @ 1685 NONAME ; int QDeclarativeItemPrivate::data_count(class QDeclarativeListProperty<class QObject> *)
?removeProperty@QDeclarativePropertyChanges@@QAEXABVQByteArray@@@Z @ 1686 NONAME ABSENT ; void QDeclarativePropertyChanges::removeProperty(class QByteArray const &)
?data_at@QDeclarativeItemPrivate@@SAPAVQObject@@PAV?$QDeclarativeListProperty@VQObject@@@@H@Z @ 1687 NONAME ; class QObject * QDeclarativeItemPrivate::data_at(class QDeclarativeListProperty<class QObject> *, int)
?tr@QDeclarativePropertyChanges@@SA?AVQString@@PBD0@Z @ 1688 NONAME ABSENT ; class QString QDeclarativePropertyChanges::tr(char const *, char const *)
- ?changeBindingInRevertList@QDeclarativeState@@QAE_NPAVQObject@@ABVQByteArray@@PAVQDeclarativeAbstractBinding@@@Z @ 1689 NONAME ; bool QDeclarativeState::changeBindingInRevertList(class QObject *, class QByteArray const &, class QDeclarativeAbstractBinding *)
+ ?changeBindingInRevertList@QDeclarativeState@@QAE_NPAVQObject@@ABVQByteArray@@PAVQDeclarativeAbstractBinding@@@Z @ 1689 NONAME ABSENT ; bool QDeclarativeState::changeBindingInRevertList(class QObject *, class QByteArray const &, class QDeclarativeAbstractBinding *)
?getStaticMetaObject@QDeclarativePropertyChanges@@SAABUQMetaObject@@XZ @ 1690 NONAME ABSENT ; struct QMetaObject const & QDeclarativePropertyChanges::getStaticMetaObject(void)
?weakPointer@QDeclarativeAbstractBinding@@QAE?AV?$QWeakPointer@VQDeclarativeAbstractBinding@@@@XZ @ 1691 NONAME ABSENT ; class QWeakPointer<class QDeclarativeAbstractBinding> QDeclarativeAbstractBinding::weakPointer(void)
?getStaticMetaObject@QDeclarativeScriptAction@@SAABUQMetaObject@@XZ @ 1692 NONAME ABSENT ; struct QMetaObject const & QDeclarativeScriptAction::getStaticMetaObject(void)
@@ -1840,4 +1840,52 @@ EXPORTS
?qt_metacall@QDeclarativeAbstractAnimation@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1839 NONAME ABSENT ; int QDeclarativeAbstractAnimation::qt_metacall(enum QMetaObject::Call, int, void * *)
?enableDebugging@QDeclarativeDebugHelper@@SAXXZ @ 1840 NONAME ; void QDeclarativeDebugHelper::enableDebugging(void)
?connect@QDeclarativePropertyPrivate@@SA_NPBVQObject@@H0HHPAH@Z @ 1841 NONAME ABSENT ; bool QDeclarativePropertyPrivate::connect(class QObject const *, int, class QObject const *, int, int, int *)
+ ?qt_metacall@QDeclarativeDebugServer@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1842 NONAME ; int QDeclarativeDebugServer::qt_metacall(enum QMetaObject::Call, int, void * *)
+ ?implicitHeight@QDeclarativeItemPrivate@@UBEMXZ @ 1843 NONAME ; float QDeclarativeItemPrivate::implicitHeight(void) const
+ ?instance@QDeclarativeDebugServer@@SAPAV1@XZ @ 1844 NONAME ; class QDeclarativeDebugServer * QDeclarativeDebugServer::instance(void)
+ ?addService@QDeclarativeDebugServer@@QAE_NPAVQDeclarativeDebugService@@@Z @ 1845 NONAME ; bool QDeclarativeDebugServer::addService(class QDeclarativeDebugService *)
+ ?containsPropertyInRevertList@QDeclarativeState@@QBE_NPAVQObject@@ABVQString@@@Z @ 1846 NONAME ; bool QDeclarativeState::containsPropertyInRevertList(class QObject *, class QString const &) const
+ ?data@QPacket@@QBE?AVQByteArray@@XZ @ 1847 NONAME ; class QByteArray QPacket::data(void) const
+ ?removeService@QDeclarativeDebugServer@@QAE_NPAVQDeclarativeDebugService@@@Z @ 1848 NONAME ; bool QDeclarativeDebugServer::removeService(class QDeclarativeDebugService *)
+ ?serviceNames@QDeclarativeDebugServer@@QBE?AVQStringList@@XZ @ 1849 NONAME ; class QStringList QDeclarativeDebugServer::serviceNames(void) const
+ ??_EQDeclarativeDebugServer@@UAE@I@Z @ 1850 NONAME ; QDeclarativeDebugServer::~QDeclarativeDebugServer(unsigned int)
+ ?staticMetaObject@QDeclarativeDebugServer@@2UQMetaObject@@B @ 1851 NONAME ; struct QMetaObject const QDeclarativeDebugServer::staticMetaObject
+ ?services@QDeclarativeDebugServer@@QBE?AV?$QList@PAVQDeclarativeDebugService@@@@XZ @ 1852 NONAME ; class QList<class QDeclarativeDebugService *> QDeclarativeDebugServer::services(void) const
+ ?rewriteBinding@QDeclarativeCustomParser@@IAEHABVQString@@ABVQByteArray@@@Z @ 1853 NONAME ; int QDeclarativeCustomParser::rewriteBinding(class QString const &, class QByteArray const &)
+ ?changeValueInRevertList@QDeclarativeState@@QAE_NPAVQObject@@ABVQString@@ABVQVariant@@@Z @ 1854 NONAME ; bool QDeclarativeState::changeValueInRevertList(class QObject *, class QString const &, class QVariant const &)
+ ?load@QDeclarativePixmap@@QAEXPAVQDeclarativeEngine@@ABVQUrl@@ABVQSize@@V?$QFlags@W4Option@QDeclarativePixmap@@@@@Z @ 1855 NONAME ; void QDeclarativePixmap::load(class QDeclarativeEngine *, class QUrl const &, class QSize const &, class QFlags<enum QDeclarativePixmap::Option>)
+ ?implicitHeightChanged@QDeclarativeItemPrivate@@UAEXXZ @ 1856 NONAME ; void QDeclarativeItemPrivate::implicitHeightChanged(void)
+ ?implicitWidthChanged@QDeclarativeItem@@IAEXXZ @ 1857 NONAME ; void QDeclarativeItem::implicitWidthChanged(void)
+ ?implicitWidthChanged@QDeclarativeItemPrivate@@UAEXXZ @ 1858 NONAME ; void QDeclarativeItemPrivate::implicitWidthChanged(void)
+ ?trUtf8@QDeclarativeDebugServer@@SA?AVQString@@PBD0H@Z @ 1859 NONAME ; class QString QDeclarativeDebugServer::trUtf8(char const *, char const *, int)
+ ?implicitHeightChanged@QDeclarativeItem@@IAEXXZ @ 1860 NONAME ; void QDeclarativeItem::implicitHeightChanged(void)
+ ?load@QDeclarativePixmap@@QAEXPAVQDeclarativeEngine@@ABVQUrl@@V?$QFlags@W4Option@QDeclarativePixmap@@@@@Z @ 1861 NONAME ; void QDeclarativePixmap::load(class QDeclarativeEngine *, class QUrl const &, class QFlags<enum QDeclarativePixmap::Option>)
+ ?trUtf8@QDeclarativeDebugServer@@SA?AVQString@@PBD0@Z @ 1862 NONAME ; class QString QDeclarativeDebugServer::trUtf8(char const *, char const *)
+ ??_EQDeclarativeDebugServerConnection@@UAE@I@Z @ 1863 NONAME ; QDeclarativeDebugServerConnection::~QDeclarativeDebugServerConnection(unsigned int)
+ ?receiveMessage@QDeclarativeDebugServer@@QAEXABVQByteArray@@@Z @ 1864 NONAME ; void QDeclarativeDebugServer::receiveMessage(class QByteArray const &)
+ ??0QDeclarativeDebugServer@@AAE@XZ @ 1865 NONAME ; QDeclarativeDebugServer::QDeclarativeDebugServer(void)
+ ?tr@QDeclarativeDebugServer@@SA?AVQString@@PBD0@Z @ 1866 NONAME ; class QString QDeclarativeDebugServer::tr(char const *, char const *)
+ ??1QDeclarativeDebugServer@@UAE@XZ @ 1867 NONAME ; QDeclarativeDebugServer::~QDeclarativeDebugServer(void)
+ ?sendMessage@QDeclarativeDebugServer@@QAEXPAVQDeclarativeDebugService@@ABVQByteArray@@@Z @ 1868 NONAME ; void QDeclarativeDebugServer::sendMessage(class QDeclarativeDebugService *, class QByteArray const &)
+ ??1QDeclarativeDebugServerConnection@@UAE@XZ @ 1869 NONAME ; QDeclarativeDebugServerConnection::~QDeclarativeDebugServerConnection(void)
+ ?qt_metacast@QDeclarativeDebugServer@@UAEPAXPBD@Z @ 1870 NONAME ; void * QDeclarativeDebugServer::qt_metacast(char const *)
+ ?hasDebuggingClient@QDeclarativeDebugServer@@QBE_NXZ @ 1871 NONAME ; bool QDeclarativeDebugServer::hasDebuggingClient(void) const
+ ?bindingInRevertList@QDeclarativeState@@QBEPAVQDeclarativeAbstractBinding@@PAVQObject@@ABVQString@@@Z @ 1872 NONAME ; class QDeclarativeAbstractBinding * QDeclarativeState::bindingInRevertList(class QObject *, class QString const &) const
+ ?getStaticMetaObject@QDeclarativeDebugServer@@SAABUQMetaObject@@XZ @ 1873 NONAME ; struct QMetaObject const & QDeclarativeDebugServer::getStaticMetaObject(void)
+ ?metaObject@QDeclarativeDebugServer@@UBEPBUQMetaObject@@XZ @ 1874 NONAME ; struct QMetaObject const * QDeclarativeDebugServer::metaObject(void) const
+ ?d_func@QDeclarativeDebugServer@@ABEPBVQDeclarativeDebugServerPrivate@@XZ @ 1875 NONAME ; class QDeclarativeDebugServerPrivate const * QDeclarativeDebugServer::d_func(void) const
+ ??0QDeclarativeExpression@@IAE@PAVQDeclarativeContextData@@PAVQObject@@ABVQScriptValue@@AAVQDeclarativeExpressionPrivate@@@Z @ 1876 NONAME ; QDeclarativeExpression::QDeclarativeExpression(class QDeclarativeContextData *, class QObject *, class QScriptValue const &, class QDeclarativeExpressionPrivate &)
+ ?createObject@QDeclarativeComponent@@IAE?AVQScriptValue@@PAVQObject@@ABV2@@Z @ 1877 NONAME ; class QScriptValue QDeclarativeComponent::createObject(class QObject *, class QScriptValue const &)
+ ?changeBindingInRevertList@QDeclarativeState@@QAE_NPAVQObject@@ABVQString@@PAVQDeclarativeAbstractBinding@@@Z @ 1878 NONAME ; bool QDeclarativeState::changeBindingInRevertList(class QObject *, class QString const &, class QDeclarativeAbstractBinding *)
+ ??0QDeclarativeDebugServerConnection@@QAE@XZ @ 1879 NONAME ; QDeclarativeDebugServerConnection::QDeclarativeDebugServerConnection(void)
+ ?valueInRevertList@QDeclarativeState@@QBE?AVQVariant@@PAVQObject@@ABVQString@@@Z @ 1880 NONAME ; class QVariant QDeclarativeState::valueInRevertList(class QObject *, class QString const &) const
+ ?removeEntryFromRevertList@QDeclarativeState@@QAE_NPAVQObject@@ABVQString@@@Z @ 1881 NONAME ; bool QDeclarativeState::removeEntryFromRevertList(class QObject *, class QString const &)
+ ?d_func@QDeclarativeDebugServer@@AAEPAVQDeclarativeDebugServerPrivate@@XZ @ 1882 NONAME ; class QDeclarativeDebugServerPrivate * QDeclarativeDebugServer::d_func(void)
+ ?tr@QDeclarativeDebugServer@@SA?AVQString@@PBD0H@Z @ 1883 NONAME ; class QString QDeclarativeDebugServer::tr(char const *, char const *, int)
+ ?implicitWidth@QDeclarativeItemPrivate@@UBEMXZ @ 1884 NONAME ; float QDeclarativeItemPrivate::implicitWidth(void) const
+ ??_EQDeclarativeRefCount@@UAE@I@Z @ 1885 NONAME ; QDeclarativeRefCount::~QDeclarativeRefCount(unsigned int)
+ ??0QDeclarativeRefCount@@QAE@XZ @ 1886 NONAME ; QDeclarativeRefCount::QDeclarativeRefCount(void)
+ ??1QDeclarativeRefCount@@UAE@XZ @ 1887 NONAME ; QDeclarativeRefCount::~QDeclarativeRefCount(void)
+ ?addref@QDeclarativeRefCount@@QAEXXZ @ 1888 NONAME ; void QDeclarativeRefCount::addref(void)
+ ?release@QDeclarativeRefCount@@QAEXXZ @ 1889 NONAME ; void QDeclarativeRefCount::release(void)
diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def
index 322d88b..9b4c0f7 100644
--- a/src/s60installs/bwins/QtGuiu.def
+++ b/src/s60installs/bwins/QtGuiu.def
@@ -13142,4 +13142,10 @@ EXPORTS
?viewportSize@QScrollPrepareEvent@@QBE?AVQSizeF@@XZ @ 13141 NONAME ; class QSizeF QScrollPrepareEvent::viewportSize(void) const
?staticMetaObject@QScroller@@2UQMetaObject@@B @ 13142 NONAME ; struct QMetaObject const QScroller::staticMetaObject
?staticMetaObject@QFlickGesture@@2UQMetaObject@@B @ 13143 NONAME ; struct QMetaObject const QFlickGesture::staticMetaObject
-
+ ?isDragEnabled@QTextControl@@QBE_NXZ @ 13144 NONAME ; bool QTextControl::isDragEnabled(void) const
+ ?setWordSelectionEnabled@QTextControl@@QAEX_N@Z @ 13145 NONAME ; void QTextControl::setWordSelectionEnabled(bool)
+ ?setDragEnabled@QTextControl@@QAEX_N@Z @ 13146 NONAME ; void QTextControl::setDragEnabled(bool)
+ ?isWordSelectionEnabled@QTextControl@@QBE_NXZ @ 13147 NONAME ; bool QTextControl::isWordSelectionEnabled(void) const
+ ?ProcessCommandParametersL@QS60MainAppUi@@UAEHW4TApaCommand@@AAV?$TBuf@$0BAA@@@ABVTDesC8@@@Z @ 13148 NONAME ; int QS60MainAppUi::ProcessCommandParametersL(enum TApaCommand, class TBuf<256> &, class TDesC8 const &)
+ ?openFile@QFileOpenEvent@@QBE_NAAVQFile@@V?$QFlags@W4OpenModeFlag@QIODevice@@@@@Z @ 13149 NONAME ; bool QFileOpenEvent::openFile(class QFile &, class QFlags<enum QIODevice::OpenModeFlag>) const
+ ??0QFileOpenEvent@@QAE@ABVRFile@@@Z @ 13150 NONAME ; QFileOpenEvent::QFileOpenEvent(class RFile const &)
diff --git a/src/s60installs/bwins/QtScriptu.def b/src/s60installs/bwins/QtScriptu.def
index 9d998ca..02a0819 100644
--- a/src/s60installs/bwins/QtScriptu.def
+++ b/src/s60installs/bwins/QtScriptu.def
@@ -403,4 +403,6 @@ EXPORTS
??0Value@QScriptDeclarativeClass@@QAE@PAVQScriptContext@@H@Z @ 402 NONAME ; QScriptDeclarativeClass::Value::Value(class QScriptContext *, int)
??0PersistentIdentifier@QScriptDeclarativeClass@@AAE@PAVQScriptEnginePrivate@@@Z @ 403 NONAME ; QScriptDeclarativeClass::PersistentIdentifier::PersistentIdentifier(class QScriptEnginePrivate *)
?compare@QScriptDeclarativeClass@@UAE_NPAUObject@1@0@Z @ 404 NONAME ; bool QScriptDeclarativeClass::compare(struct QScriptDeclarativeClass::Object *, struct QScriptDeclarativeClass::Object *)
+ ?toString@PersistentIdentifier@QScriptDeclarativeClass@@QBE?AVQString@@XZ @ 405 NONAME ; class QString QScriptDeclarativeClass::PersistentIdentifier::toString(void) const
+ ?startsWithUpper@QScriptDeclarativeClass@@QAE_NABQAX@Z @ 406 NONAME ; bool QScriptDeclarativeClass::startsWithUpper(void * const const &)
diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def
index 0488d0c..207447f 100644
--- a/src/s60installs/eabi/QtCoreu.def
+++ b/src/s60installs/eabi/QtCoreu.def
@@ -3804,4 +3804,6 @@ EXPORTS
_ZN23QCoreApplicationPrivate18symbianCommandLineEv @ 3803 NONAME
_ZNK16QXmlStreamWriter8hasErrorEv @ 3804 NONAME
_ZNK13QElapsedTimer12nsecsElapsedEv @ 3805 NONAME
+ _ZNK11QMetaMethod8revisionEv @ 3806 NONAME
+ _ZNK13QMetaProperty8revisionEv @ 3807 NONAME
diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def
index b0efab4..95180d4 100644
--- a/src/s60installs/eabi/QtDeclarativeu.def
+++ b/src/s60installs/eabi/QtDeclarativeu.def
@@ -19,24 +19,24 @@ EXPORTS
_ZN15QPacketAutoSendD0Ev @ 18 NONAME ABSENT
_ZN15QPacketAutoSendD1Ev @ 19 NONAME ABSENT
_ZN15QPacketAutoSendD2Ev @ 20 NONAME ABSENT
- _ZN15QPacketProtocol11qt_metacallEN11QMetaObject4CallEiPPv @ 21 NONAME ABSENT
- _ZN15QPacketProtocol11qt_metacastEPKc @ 22 NONAME ABSENT
- _ZN15QPacketProtocol13invalidPacketEv @ 23 NONAME ABSENT
- _ZN15QPacketProtocol13packetWrittenEv @ 24 NONAME ABSENT
- _ZN15QPacketProtocol16staticMetaObjectE @ 25 NONAME DATA 16 ABSENT
- _ZN15QPacketProtocol19getStaticMetaObjectEv @ 26 NONAME ABSENT
- _ZN15QPacketProtocol20setMaximumPacketSizeEi @ 27 NONAME ABSENT
- _ZN15QPacketProtocol4readEv @ 28 NONAME ABSENT
- _ZN15QPacketProtocol4sendERK7QPacket @ 29 NONAME ABSENT
- _ZN15QPacketProtocol4sendEv @ 30 NONAME ABSENT
- _ZN15QPacketProtocol5clearEv @ 31 NONAME ABSENT
- _ZN15QPacketProtocol6deviceEv @ 32 NONAME ABSENT
- _ZN15QPacketProtocol9readyReadEv @ 33 NONAME ABSENT
- _ZN15QPacketProtocolC1EP9QIODeviceP7QObject @ 34 NONAME ABSENT
- _ZN15QPacketProtocolC2EP9QIODeviceP7QObject @ 35 NONAME ABSENT
- _ZN15QPacketProtocolD0Ev @ 36 NONAME ABSENT
- _ZN15QPacketProtocolD1Ev @ 37 NONAME ABSENT
- _ZN15QPacketProtocolD2Ev @ 38 NONAME ABSENT
+ _ZN15QPacketProtocol11qt_metacallEN11QMetaObject4CallEiPPv @ 21 NONAME
+ _ZN15QPacketProtocol11qt_metacastEPKc @ 22 NONAME
+ _ZN15QPacketProtocol13invalidPacketEv @ 23 NONAME
+ _ZN15QPacketProtocol13packetWrittenEv @ 24 NONAME
+ _ZN15QPacketProtocol16staticMetaObjectE @ 25 NONAME DATA 16
+ _ZN15QPacketProtocol19getStaticMetaObjectEv @ 26 NONAME
+ _ZN15QPacketProtocol20setMaximumPacketSizeEi @ 27 NONAME
+ _ZN15QPacketProtocol4readEv @ 28 NONAME
+ _ZN15QPacketProtocol4sendERK7QPacket @ 29 NONAME
+ _ZN15QPacketProtocol4sendEv @ 30 NONAME
+ _ZN15QPacketProtocol5clearEv @ 31 NONAME
+ _ZN15QPacketProtocol6deviceEv @ 32 NONAME
+ _ZN15QPacketProtocol9readyReadEv @ 33 NONAME
+ _ZN15QPacketProtocolC1EP9QIODeviceP7QObject @ 34 NONAME
+ _ZN15QPacketProtocolC2EP9QIODeviceP7QObject @ 35 NONAME
+ _ZN15QPacketProtocolD0Ev @ 36 NONAME
+ _ZN15QPacketProtocolD1Ev @ 37 NONAME
+ _ZN15QPacketProtocolD2Ev @ 38 NONAME
_ZN16QDeclarativeInfoC1EP23QDeclarativeInfoPrivate @ 39 NONAME
_ZN16QDeclarativeInfoC1ERKS_ @ 40 NONAME
_ZN16QDeclarativeInfoC2EP23QDeclarativeInfoPrivate @ 41 NONAME
@@ -241,8 +241,8 @@ EXPORTS
_ZN18QDeclarativePixmap23connectDownloadProgressEP7QObjecti @ 240 NONAME
_ZN18QDeclarativePixmap4loadEP18QDeclarativeEngineRK4QUrl @ 241 NONAME
_ZN18QDeclarativePixmap4loadEP18QDeclarativeEngineRK4QUrlRK5QSize @ 242 NONAME
- _ZN18QDeclarativePixmap4loadEP18QDeclarativeEngineRK4QUrlRK5QSizeb @ 243 NONAME
- _ZN18QDeclarativePixmap4loadEP18QDeclarativeEngineRK4QUrlb @ 244 NONAME
+ _ZN18QDeclarativePixmap4loadEP18QDeclarativeEngineRK4QUrlRK5QSizeb @ 243 NONAME ABSENT
+ _ZN18QDeclarativePixmap4loadEP18QDeclarativeEngineRK4QUrlb @ 244 NONAME ABSENT
_ZN18QDeclarativePixmap5clearEP7QObject @ 245 NONAME
_ZN18QDeclarativePixmap5clearEv @ 246 NONAME
_ZN18QDeclarativePixmap9setPixmapERK7QPixmap @ 247 NONAME
@@ -1059,20 +1059,20 @@ EXPORTS
_ZN39QDeclarativeNetworkAccessManagerFactoryD0Ev @ 1058 NONAME
_ZN39QDeclarativeNetworkAccessManagerFactoryD1Ev @ 1059 NONAME
_ZN39QDeclarativeNetworkAccessManagerFactoryD2Ev @ 1060 NONAME
- _ZN7QPacket5clearEv @ 1061 NONAME ABSENT
- _ZN7QPacketC1ERK10QByteArray @ 1062 NONAME ABSENT
- _ZN7QPacketC1ERKS_ @ 1063 NONAME ABSENT
- _ZN7QPacketC1Ev @ 1064 NONAME ABSENT
- _ZN7QPacketC2ERK10QByteArray @ 1065 NONAME ABSENT
- _ZN7QPacketC2ERKS_ @ 1066 NONAME ABSENT
- _ZN7QPacketC2Ev @ 1067 NONAME ABSENT
- _ZN7QPacketD0Ev @ 1068 NONAME ABSENT
- _ZN7QPacketD1Ev @ 1069 NONAME ABSENT
- _ZN7QPacketD2Ev @ 1070 NONAME ABSENT
+ _ZN7QPacket5clearEv @ 1061 NONAME
+ _ZN7QPacketC1ERK10QByteArray @ 1062 NONAME
+ _ZN7QPacketC1ERKS_ @ 1063 NONAME
+ _ZN7QPacketC1Ev @ 1064 NONAME
+ _ZN7QPacketC2ERK10QByteArray @ 1065 NONAME
+ _ZN7QPacketC2ERKS_ @ 1066 NONAME
+ _ZN7QPacketC2Ev @ 1067 NONAME
+ _ZN7QPacketD0Ev @ 1068 NONAME
+ _ZN7QPacketD1Ev @ 1069 NONAME
+ _ZN7QPacketD2Ev @ 1070 NONAME
_ZNK15QDeclarativePen10metaObjectEv @ 1071 NONAME ABSENT
- _ZNK15QPacketProtocol10metaObjectEv @ 1072 NONAME ABSENT
- _ZNK15QPacketProtocol16packetsAvailableEv @ 1073 NONAME ABSENT
- _ZNK15QPacketProtocol17maximumPacketSizeEv @ 1074 NONAME ABSENT
+ _ZNK15QPacketProtocol10metaObjectEv @ 1072 NONAME
+ _ZNK15QPacketProtocol16packetsAvailableEv @ 1073 NONAME
+ _ZNK15QPacketProtocol17maximumPacketSizeEv @ 1074 NONAME
_ZNK16QDeclarativeItem10metaObjectEv @ 1075 NONAME
_ZNK16QDeclarativeItem10parentItemEv @ 1076 NONAME
_ZNK16QDeclarativeItem10widthValidEv @ 1077 NONAME
@@ -1524,10 +1524,10 @@ EXPORTS
_ZNK36QDeclarativeDomValueValueInterceptor6objectEv @ 1523 NONAME ABSENT
_ZNK38QDeclarativeDebugObjectExpressionWatch10expressionEv @ 1524 NONAME ABSENT
_ZNK38QDeclarativeDebugObjectExpressionWatch10metaObjectEv @ 1525 NONAME ABSENT
- _ZNK7QPacket7isEmptyEv @ 1526 NONAME ABSENT
+ _ZNK7QPacket7isEmptyEv @ 1526 NONAME
_ZTI15QDeclarativePen @ 1527 NONAME ABSENT
_ZTI15QPacketAutoSend @ 1528 NONAME ABSENT
- _ZTI15QPacketProtocol @ 1529 NONAME ABSENT
+ _ZTI15QPacketProtocol @ 1529 NONAME
_ZTI16QDeclarativeItem @ 1530 NONAME
_ZTI16QDeclarativeText @ 1531 NONAME ABSENT
_ZTI16QDeclarativeView @ 1532 NONAME
@@ -1574,10 +1574,10 @@ EXPORTS
_ZTI36QDeclarativePropertyValueInterceptor @ 1573 NONAME
_ZTI38QDeclarativeDebugObjectExpressionWatch @ 1574 NONAME ABSENT
_ZTI39QDeclarativeNetworkAccessManagerFactory @ 1575 NONAME
- _ZTI7QPacket @ 1576 NONAME ABSENT
+ _ZTI7QPacket @ 1576 NONAME
_ZTV15QDeclarativePen @ 1577 NONAME ABSENT
_ZTV15QPacketAutoSend @ 1578 NONAME ABSENT
- _ZTV15QPacketProtocol @ 1579 NONAME ABSENT
+ _ZTV15QPacketProtocol @ 1579 NONAME
_ZTV16QDeclarativeItem @ 1580 NONAME
_ZTV16QDeclarativeText @ 1581 NONAME ABSENT
_ZTV16QDeclarativeView @ 1582 NONAME
@@ -1623,7 +1623,7 @@ EXPORTS
_ZTV36QDeclarativePropertyValueInterceptor @ 1622 NONAME
_ZTV38QDeclarativeDebugObjectExpressionWatch @ 1623 NONAME ABSENT
_ZTV39QDeclarativeNetworkAccessManagerFactory @ 1624 NONAME
- _ZTV7QPacket @ 1625 NONAME ABSENT
+ _ZTV7QPacket @ 1625 NONAME
_ZThn16_N16QDeclarativeItem10classBeginEv @ 1626 NONAME
_ZThn16_N16QDeclarativeItem17componentCompleteEv @ 1627 NONAME
_ZThn16_N16QDeclarativeItemD0Ev @ 1628 NONAME
@@ -1677,9 +1677,9 @@ EXPORTS
_ZN23QDeclarativeEngineDebug10newObjectsEv @ 1676 NONAME ABSENT
_ZN17QDeclarativeState20addEntryToRevertListERK18QDeclarativeAction @ 1677 NONAME
_ZN17QDeclarativeState22addEntriesToRevertListERK5QListI18QDeclarativeActionE @ 1678 NONAME
- _ZN17QDeclarativeState23changeValueInRevertListEP7QObjectRK10QByteArrayRK8QVariant @ 1679 NONAME
- _ZN17QDeclarativeState25changeBindingInRevertListEP7QObjectRK10QByteArrayP27QDeclarativeAbstractBinding @ 1680 NONAME
- _ZN17QDeclarativeState25removeEntryFromRevertListEP7QObjectRK10QByteArray @ 1681 NONAME
+ _ZN17QDeclarativeState23changeValueInRevertListEP7QObjectRK10QByteArrayRK8QVariant @ 1679 NONAME ABSENT
+ _ZN17QDeclarativeState25changeBindingInRevertListEP7QObjectRK10QByteArrayP27QDeclarativeAbstractBinding @ 1680 NONAME ABSENT
+ _ZN17QDeclarativeState25removeEntryFromRevertListEP7QObjectRK10QByteArray @ 1681 NONAME ABSENT
_ZN17QDeclarativeState30removeAllEntriesFromRevertListEP7QObject @ 1682 NONAME
_ZN23QDeclarativeItemPrivate10data_clearEP24QDeclarativeListPropertyI7QObjectE @ 1683 NONAME
_ZN23QDeclarativeItemPrivate10data_countEP24QDeclarativeListPropertyI7QObjectE @ 1684 NONAME
@@ -1706,9 +1706,9 @@ EXPORTS
_ZN27QDeclarativePropertyChangesD1Ev @ 1705 NONAME ABSENT
_ZN27QDeclarativePropertyChangesD2Ev @ 1706 NONAME ABSENT
_ZNK17QDeclarativeState13isStateActiveEv @ 1707 NONAME
- _ZNK17QDeclarativeState17valueInRevertListEP7QObjectRK10QByteArray @ 1708 NONAME
- _ZNK17QDeclarativeState19bindingInRevertListEP7QObjectRK10QByteArray @ 1709 NONAME
- _ZNK17QDeclarativeState28containsPropertyInRevertListEP7QObjectRK10QByteArray @ 1710 NONAME
+ _ZNK17QDeclarativeState17valueInRevertListEP7QObjectRK10QByteArray @ 1708 NONAME ABSENT
+ _ZNK17QDeclarativeState19bindingInRevertListEP7QObjectRK10QByteArray @ 1709 NONAME ABSENT
+ _ZNK17QDeclarativeState28containsPropertyInRevertListEP7QObjectRK10QByteArray @ 1710 NONAME ABSENT
_ZNK26QDeclarativeStateOperation5stateEv @ 1711 NONAME
_ZNK27QDeclarativePropertyChanges10expressionERK10QByteArray @ 1712 NONAME ABSENT
_ZNK27QDeclarativePropertyChanges10isExplicitEv @ 1713 NONAME ABSENT
@@ -1885,4 +1885,49 @@ EXPORTS
_ZThn8_N29QDeclarativeAbstractAnimationD1Ev @ 1884 NONAME ABSENT
_ZN23QDeclarativeDebugHelper15enableDebuggingEv @ 1885 NONAME
_ZN27QDeclarativePropertyPrivate7connectEPK7QObjectiS2_iiPi @ 1886 NONAME ABSENT
+ _ZN16QDeclarativeItem20implicitWidthChangedEv @ 1887 NONAME
+ _ZN16QDeclarativeItem21implicitHeightChangedEv @ 1888 NONAME
+ _ZN17QDeclarativeState23changeValueInRevertListEP7QObjectRK7QStringRK8QVariant @ 1889 NONAME
+ _ZN17QDeclarativeState25changeBindingInRevertListEP7QObjectRK7QStringP27QDeclarativeAbstractBinding @ 1890 NONAME
+ _ZN17QDeclarativeState25removeEntryFromRevertListEP7QObjectRK7QString @ 1891 NONAME
+ _ZN18QDeclarativePixmap4loadEP18QDeclarativeEngineRK4QUrl6QFlagsINS_6OptionEE @ 1892 NONAME
+ _ZN18QDeclarativePixmap4loadEP18QDeclarativeEngineRK4QUrlRK5QSize6QFlagsINS_6OptionEE @ 1893 NONAME
+ _ZN21QDeclarativeComponent12createObjectEP7QObjectRK12QScriptValue @ 1894 NONAME
+ _ZN22QDeclarativeExpressionC1EP23QDeclarativeContextDataP7QObjectRK12QScriptValueR29QDeclarativeExpressionPrivate @ 1895 NONAME
+ _ZN22QDeclarativeExpressionC2EP23QDeclarativeContextDataP7QObjectRK12QScriptValueR29QDeclarativeExpressionPrivate @ 1896 NONAME
+ _ZN23QDeclarativeDebugServer10addServiceEP24QDeclarativeDebugService @ 1897 NONAME
+ _ZN23QDeclarativeDebugServer11qt_metacallEN11QMetaObject4CallEiPPv @ 1898 NONAME
+ _ZN23QDeclarativeDebugServer11qt_metacastEPKc @ 1899 NONAME
+ _ZN23QDeclarativeDebugServer11sendMessageEP24QDeclarativeDebugServiceRK10QByteArray @ 1900 NONAME
+ _ZN23QDeclarativeDebugServer13removeServiceEP24QDeclarativeDebugService @ 1901 NONAME
+ _ZN23QDeclarativeDebugServer14receiveMessageERK10QByteArray @ 1902 NONAME
+ _ZN23QDeclarativeDebugServer16staticMetaObjectE @ 1903 NONAME DATA 16
+ _ZN23QDeclarativeDebugServer19getStaticMetaObjectEv @ 1904 NONAME
+ _ZN23QDeclarativeDebugServer8instanceEv @ 1905 NONAME
+ _ZN23QDeclarativeDebugServerC1Ev @ 1906 NONAME
+ _ZN23QDeclarativeDebugServerC2Ev @ 1907 NONAME
+ _ZN23QDeclarativeItemPrivate20implicitWidthChangedEv @ 1908 NONAME
+ _ZN23QDeclarativeItemPrivate21implicitHeightChangedEv @ 1909 NONAME
+ _ZN24QDeclarativeCustomParser14rewriteBindingERK7QStringRK10QByteArray @ 1910 NONAME
+ _ZNK17QDeclarativeState17valueInRevertListEP7QObjectRK7QString @ 1911 NONAME
+ _ZNK17QDeclarativeState19bindingInRevertListEP7QObjectRK7QString @ 1912 NONAME
+ _ZNK17QDeclarativeState28containsPropertyInRevertListEP7QObjectRK7QString @ 1913 NONAME
+ _ZNK23QDeclarativeDebugServer10metaObjectEv @ 1914 NONAME
+ _ZNK23QDeclarativeDebugServer12serviceNamesEv @ 1915 NONAME
+ _ZNK23QDeclarativeDebugServer18hasDebuggingClientEv @ 1916 NONAME
+ _ZNK23QDeclarativeDebugServer8servicesEv @ 1917 NONAME
+ _ZNK23QDeclarativeItemPrivate13implicitWidthEv @ 1918 NONAME
+ _ZNK23QDeclarativeItemPrivate14implicitHeightEv @ 1919 NONAME
+ _ZNK7QPacket4dataEv @ 1920 NONAME
+ _ZTI23QDeclarativeDebugServer @ 1921 NONAME
+ _ZTV23QDeclarativeDebugServer @ 1922 NONAME
+ _ZN20QDeclarativeRefCount6addrefEv @ 1923 NONAME
+ _ZN20QDeclarativeRefCount7releaseEv @ 1924 NONAME
+ _ZN20QDeclarativeRefCountC1Ev @ 1925 NONAME
+ _ZN20QDeclarativeRefCountC2Ev @ 1926 NONAME
+ _ZN20QDeclarativeRefCountD0Ev @ 1927 NONAME
+ _ZN20QDeclarativeRefCountD1Ev @ 1928 NONAME
+ _ZN20QDeclarativeRefCountD2Ev @ 1929 NONAME
+ _ZTI20QDeclarativeRefCount @ 1930 NONAME
+ _ZTV20QDeclarativeRefCount @ 1931 NONAME
diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def
index 8064fa3..722dee8 100644
--- a/src/s60installs/eabi/QtGuiu.def
+++ b/src/s60installs/eabi/QtGuiu.def
@@ -12227,10 +12227,10 @@ EXPORTS
_ZTV19QBlitterPaintEngine @ 12226 NONAME
_ZTV20QBlittablePixmapData @ 12227 NONAME
_Zls6QDebugPK13QSymbianEvent @ 12228 NONAME
- _ZN13QS60MainAppUi25ProcessCommandParametersLE11TApaCommandR4TBufILi256EERK6TDesC8 @ 12229 NONAME ABSENT
- _ZN14QFileOpenEventC1ERK5RFile @ 12230 NONAME ABSENT
- _ZN14QFileOpenEventC2ERK5RFile @ 12231 NONAME ABSENT
- _ZNK14QFileOpenEvent8openFileER5QFile6QFlagsIN9QIODevice12OpenModeFlagEE @ 12232 NONAME ABSENT
+ _ZN13QS60MainAppUi25ProcessCommandParametersLE11TApaCommandR4TBufILi256EERK6TDesC8 @ 12229 NONAME
+ _ZN14QFileOpenEventC1ERK5RFile @ 12230 NONAME
+ _ZN14QFileOpenEventC2ERK5RFile @ 12231 NONAME
+ _ZNK14QFileOpenEvent8openFileER5QFile6QFlagsIN9QIODevice12OpenModeFlagEE @ 12232 NONAME
_ZN11QFontEngine16alphaMapForGlyphEj6QFixed @ 12233 NONAME
_ZN11QFontEngine16alphaMapForGlyphEj6QFixedRK10QTransform @ 12234 NONAME
_Z32qGamma_correct_back_to_linear_csP6QImage @ 12235 NONAME
@@ -12333,4 +12333,8 @@ EXPORTS
_ZTV19QScrollPrepareEvent @ 12332 NONAME
_ZTV19QScrollerProperties @ 12333 NONAME
_ZTV9QScroller @ 12334 NONAME
+ _ZN12QTextControl14setDragEnabledEb @ 12335 NONAME
+ _ZN12QTextControl23setWordSelectionEnabledEb @ 12336 NONAME
+ _ZNK12QTextControl13isDragEnabledEv @ 12337 NONAME
+ _ZNK12QTextControl22isWordSelectionEnabledEv @ 12338 NONAME
diff --git a/src/s60installs/eabi/QtScriptu.def b/src/s60installs/eabi/QtScriptu.def
index b26f9c7..f7da892 100644
--- a/src/s60installs/eabi/QtScriptu.def
+++ b/src/s60installs/eabi/QtScriptu.def
@@ -441,4 +441,6 @@ EXPORTS
_ZN25QScriptEngineAgentPrivate18didReachBreakpointERKN5QTJSC17DebuggerCallFrameEii @ 440 NONAME
_ZNK23QScriptDeclarativeClass12supportsCallEv @ 441 NONAME
_ZNK23QScriptDeclarativeClass5Value13toScriptValueEP13QScriptEngine @ 442 NONAME
+ _ZN23QScriptDeclarativeClass15startsWithUpperERKPv @ 443 NONAME
+ _ZNK23QScriptDeclarativeClass20PersistentIdentifier8toStringEv @ 444 NONAME
diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro
index cd3102e..1c91422 100644
--- a/src/s60installs/s60installs.pro
+++ b/src/s60installs/s60installs.pro
@@ -11,23 +11,6 @@ symbian: {
isEmpty(QT_LIBINFIX) {
TARGET.UID3 = 0x2001E61C
-
- # Sqlite3 is expected to be already found on phone if infixed configuration is built.
- # It is also expected that devices newer than those based on S60 5.0 all have sqlite3.dll.
- contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- BLD_INF_RULES.prj_exports += \
- "sqlite3.sis /epoc32/data/qt/sis/sqlite3.sis"
- symbian-abld|symbian-sbsv2 {
- sqlitedeployment = \
- "; Deploy sqlite onto phone that does not have it already" \
- "@\"$${EPOCROOT}epoc32/data/qt/sis/sqlite3.sis\", (0x2002af5f)"
- } else {
- sqlitedeployment = \
- "; Deploy sqlite onto phone that does not have it already" \
- "@\"$${PWD}/sqlite3.sis\", (0x2002af5f)"
- }
- qtlibraries.pkg_postrules += sqlitedeployment
- }
} else {
# Always use experimental UID for infixed configuration to avoid UID clash
TARGET.UID3 = 0xE001E61C
@@ -92,7 +75,7 @@ symbian: {
vendorinfo = \
"; Localised Vendor name" \
- "%{\"Nokia, Qt\"}" \
+ "%{\"Nokia\"}" \
" " \
"; Unique Vendor name" \
":\"Nokia, Qt\"" \
@@ -183,10 +166,6 @@ symbian: {
contains(QT_CONFIG, openvg) {
qtlibraries.files += $$QMAKE_LIBDIR_QT/QtOpenVG$${QT_LIBINFIX}.dll
graphicssystems_plugins.files += $$QT_BUILD_TREE/plugins/graphicssystems/qvggraphicssystem$${QT_LIBINFIX}.dll
- # OpenVG requires Symbian^3 or later
- pkg_platform_dependencies = \
- "[0x20022E6D],0,0,0,{\"S60ProductID\"}" \
- "[0x20032DE7],0,0,0,{\"S60ProductID\"}"
}
contains(QT_CONFIG, opengl) {
diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp
index 59ea52d..2468a46 100644
--- a/src/script/api/qscriptcontext.cpp
+++ b/src/script/api/qscriptcontext.cpp
@@ -299,6 +299,12 @@ QScriptValue QScriptContext::argumentsObject() const
//for a js function
if (frame->codeBlock() && frame->callee()) {
+ if (!QScriptEnginePrivate::hasValidCodeBlockRegister(frame)) {
+ // We have a built-in JS host call.
+ // codeBlock is needed by retrieveArguments(), but since it
+ // contains junk, we would crash. Return an invalid value for now.
+ return QScriptValue();
+ }
JSC::JSValue result = frame->interpreter()->retrieveArguments(frame, JSC::asFunction(frame->callee()));
return QScript::scriptEngineFromExec(frame)->scriptValueFromJSCValue(result);
}
@@ -309,7 +315,8 @@ QScriptValue QScriptContext::argumentsObject() const
}
//for a native function
- if (!frame->optionalCalleeArguments()) {
+ if (!frame->optionalCalleeArguments()
+ && QScriptEnginePrivate::hasValidCodeBlockRegister(frame)) { // Make sure we don't go here for host JSFunctions
Q_ASSERT(frame->argumentCount() > 0); //we need at least 'this' otherwise we'll crash later
JSC::Arguments* arguments = new (&frame->globalData())JSC::Arguments(frame, JSC::Arguments::NoParameters);
frame->setCalleeArguments(arguments);
diff --git a/src/script/api/qscriptcontextinfo.cpp b/src/script/api/qscriptcontextinfo.cpp
index db6b2d7..0f9de1d 100644
--- a/src/script/api/qscriptcontextinfo.cpp
+++ b/src/script/api/qscriptcontextinfo.cpp
@@ -157,7 +157,7 @@ QScriptContextInfoPrivate::QScriptContextInfoPrivate(const QScriptContext *conte
JSC::Instruction *returnPC = rewindContext->returnPC();
JSC::CodeBlock *codeBlock = frame->codeBlock();
- if (returnPC && codeBlock) {
+ if (returnPC && codeBlock && QScriptEnginePrivate::hasValidCodeBlockRegister(frame)) {
#if ENABLE(JIT)
unsigned bytecodeOffset = codeBlock->getBytecodeIndex(frame, JSC::ReturnAddressPtr(returnPC));
#else
@@ -171,7 +171,7 @@ QScriptContextInfoPrivate::QScriptContextInfoPrivate(const QScriptContext *conte
// Get the filename and the scriptId:
JSC::CodeBlock *codeBlock = frame->codeBlock();
- if (codeBlock) {
+ if (codeBlock && QScriptEnginePrivate::hasValidCodeBlockRegister(frame)) {
JSC::SourceProvider *source = codeBlock->source();
scriptId = source->asID();
fileName = source->url();
@@ -181,7 +181,8 @@ QScriptContextInfoPrivate::QScriptContextInfoPrivate(const QScriptContext *conte
JSC::JSObject *callee = frame->callee();
if (callee && callee->inherits(&JSC::InternalFunction::info))
functionName = JSC::asInternalFunction(callee)->name(frame);
- if (callee && callee->inherits(&JSC::JSFunction::info)) {
+ if (callee && callee->inherits(&JSC::JSFunction::info)
+ && !JSC::asFunction(callee)->isHostFunction()) {
functionType = QScriptContextInfo::ScriptFunction;
JSC::FunctionExecutable *body = JSC::asFunction(callee)->jsExecutable();
functionStartLineNumber = body->lineNo();
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 004e3a5..14ab2eb 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -858,7 +858,8 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS
{
JSC::ExecState *frame = exec->callerFrame()->removeHostCallFrameFlag();
while (frame) {
- if (frame->codeBlock() && frame->codeBlock()->source()
+ if (frame->codeBlock() && QScriptEnginePrivate::hasValidCodeBlockRegister(frame)
+ && frame->codeBlock()->source()
&& !frame->codeBlock()->source()->url().isEmpty()) {
context = engine->translationContextFromUrl(frame->codeBlock()->source()->url());
break;
@@ -1022,6 +1023,7 @@ QScriptEnginePrivate::~QScriptEnginePrivate()
while (!ownedAgents.isEmpty())
delete ownedAgents.takeFirst();
+ detachAllRegisteredScriptPrograms();
detachAllRegisteredScriptValues();
detachAllRegisteredScriptStrings();
qDeleteAll(m_qobjectData);
@@ -1576,6 +1578,14 @@ bool QScriptEnginePrivate::scriptDisconnect(JSC::JSValue signal, JSC::JSValue re
#endif
+void QScriptEnginePrivate::detachAllRegisteredScriptPrograms()
+{
+ QSet<QScriptProgramPrivate*>::const_iterator it;
+ for (it = registeredScriptPrograms.constBegin(); it != registeredScriptPrograms.constEnd(); ++it)
+ (*it)->detachFromEngine();
+ registeredScriptPrograms.clear();
+}
+
void QScriptEnginePrivate::detachAllRegisteredScriptValues()
{
QScriptValuePrivate *it;
@@ -2078,10 +2088,10 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionSignature fun,
JSC::ExecState* exec = d->currentFrame;
JSC::JSValue function = new (exec)QScript::FunctionWrapper(exec, length, JSC::Identifier(exec, ""), fun);
QScriptValue result = d->scriptValueFromJSCValue(function);
- result.setProperty(QLatin1String("prototype"), prototype, QScriptValue::Undeletable);
+ result.setProperty(QLatin1String("prototype"), prototype,
+ QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
const_cast<QScriptValue&>(prototype)
- .setProperty(QLatin1String("constructor"), result,
- QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ .setProperty(QLatin1String("constructor"), result, QScriptValue::SkipInEnumeration);
return result;
}
@@ -2347,9 +2357,9 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionSignature fun, in
JSC::JSValue function = new (exec)QScript::FunctionWrapper(exec, length, JSC::Identifier(exec, ""), fun);
QScriptValue result = d->scriptValueFromJSCValue(function);
QScriptValue proto = newObject();
- result.setProperty(QLatin1String("prototype"), proto, QScriptValue::Undeletable);
- proto.setProperty(QLatin1String("constructor"), result,
- QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ result.setProperty(QLatin1String("prototype"), proto,
+ QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ proto.setProperty(QLatin1String("constructor"), result, QScriptValue::SkipInEnumeration);
return result;
}
@@ -2365,9 +2375,9 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionWithArgSignature
JSC::JSValue function = new (exec)QScript::FunctionWithArgWrapper(exec, /*length=*/0, JSC::Identifier(exec, ""), fun, arg);
QScriptValue result = d->scriptValueFromJSCValue(function);
QScriptValue proto = newObject();
- result.setProperty(QLatin1String("prototype"), proto, QScriptValue::Undeletable);
- proto.setProperty(QLatin1String("constructor"), result,
- QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ result.setProperty(QLatin1String("prototype"), proto,
+ QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ proto.setProperty(QLatin1String("constructor"), result, QScriptValue::SkipInEnumeration);
return result;
}
@@ -2753,9 +2763,7 @@ JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSV
if (!clearScopeChain) {
newCallFrame->init(0, /*vPC=*/0, exec->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee);
} else {
- JSC::JSObject *jscObject = originalGlobalObject();
- JSC::ScopeChainNode *scn = new JSC::ScopeChainNode(0, jscObject, &exec->globalData(), exec->lexicalGlobalObject(), jscObject);
- newCallFrame->init(0, /*vPC=*/0, scn, exec, flags | ShouldRestoreCallFrame, argc, callee);
+ newCallFrame->init(0, /*vPC=*/0, globalExec()->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee);
}
} else {
setContextFlags(newCallFrame, flags);
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index 05a8901..94d195e 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -56,6 +56,7 @@
#include "Debugger.h"
#include "ErrorInstance.h"
#include "JSArray.h"
+#include "Executable.h"
#include "Lexer.h"
#include "RefPtr.h"
#include "RegExpConstructor.h"
@@ -87,6 +88,7 @@ class QScriptEngineAgent;
class QScriptEnginePrivate;
class QScriptSyntaxCheckResult;
class QScriptEngine;
+class QScriptProgramPrivate;
namespace QScript
{
@@ -230,6 +232,8 @@ public:
static inline JSC::ExecState *frameForContext(QScriptContext *context);
static inline const JSC::ExecState *frameForContext(const QScriptContext *context);
+ static inline bool hasValidCodeBlockRegister(JSC::ExecState *frame);
+
JSC::JSGlobalObject *originalGlobalObject() const;
JSC::JSObject *getOriginalGlobalObjectProxy();
JSC::JSObject *customGlobalObject() const;
@@ -273,6 +277,10 @@ public:
static QScriptSyntaxCheckResult checkSyntax(const QString &program);
static bool canEvaluate(const QString &program);
+ inline void registerScriptProgram(QScriptProgramPrivate *program);
+ inline void unregisterScriptProgram(QScriptProgramPrivate *program);
+ void detachAllRegisteredScriptPrograms();
+
inline QScriptValuePrivate *allocateScriptValuePrivate(size_t);
inline void freeScriptValuePrivate(QScriptValuePrivate *p);
@@ -368,6 +376,7 @@ public:
static const int maxFreeScriptValues = 256;
int freeScriptValuesCount;
QScriptStringPrivate *registeredScriptStrings;
+ QSet<QScriptProgramPrivate*> registeredScriptPrograms;
QHash<int, QScriptTypeInfo*> m_typeInfos;
int processEventsInterval;
QScriptValue abortResult;
@@ -566,6 +575,18 @@ inline QByteArray convertToLatin1(const JSC::UString &str)
} // namespace QScript
+inline void QScriptEnginePrivate::registerScriptProgram(QScriptProgramPrivate *program)
+{
+ Q_ASSERT(!registeredScriptPrograms.contains(program));
+ registeredScriptPrograms.insert(program);
+}
+
+inline void QScriptEnginePrivate::unregisterScriptProgram(QScriptProgramPrivate *program)
+{
+ Q_ASSERT(registeredScriptPrograms.contains(program));
+ registeredScriptPrograms.remove(program);
+}
+
inline QScriptValuePrivate *QScriptEnginePrivate::allocateScriptValuePrivate(size_t size)
{
if (freeScriptValues) {
@@ -844,6 +865,21 @@ inline const JSC::ExecState *QScriptEnginePrivate::frameForContext(const QScript
return reinterpret_cast<const JSC::ExecState*>(context);
}
+inline bool QScriptEnginePrivate::hasValidCodeBlockRegister(JSC::ExecState *frame)
+{
+#if ENABLE(JIT)
+ // Frames created by the VM don't have their CodeBlock register
+ // initialized. We can detect such frames by checking if the
+ // callee is a host JSFunction.
+ JSC::JSObject *callee = frame->callee();
+ return !(callee && callee->inherits(&JSC::JSFunction::info)
+ && JSC::asFunction(callee)->isHostFunction());
+#else
+ Q_UNUSED(frame);
+ return true;
+#endif
+}
+
inline JSC::ExecState *QScriptEnginePrivate::globalExec() const
{
return originalGlobalObject()->globalExec();
diff --git a/src/script/api/qscriptprogram.cpp b/src/script/api/qscriptprogram.cpp
index da103bb..c0e2656 100644
--- a/src/script/api/qscriptprogram.cpp
+++ b/src/script/api/qscriptprogram.cpp
@@ -27,6 +27,7 @@
#include "qscriptengine.h"
#include "qscriptengine_p.h"
+#include "SamplingTool.h"
#include "Executable.h"
QT_BEGIN_NAMESPACE
@@ -64,6 +65,7 @@ QScriptProgramPrivate::~QScriptProgramPrivate()
if (engine) {
QScript::APIShim shim(engine);
_executable.clear();
+ engine->unregisterScriptProgram(this);
}
}
@@ -78,7 +80,10 @@ JSC::EvalExecutable *QScriptProgramPrivate::executable(JSC::ExecState *exec,
if (_executable) {
if (eng == engine)
return _executable.get();
- _executable = 0;
+ // "Migrating" to another engine; clean up old state
+ QScript::APIShim shim(engine);
+ _executable.clear();
+ engine->unregisterScriptProgram(this);
}
WTF::PassRefPtr<QScript::UStringSourceProviderWithFeedback> provider
= QScript::UStringSourceProviderWithFeedback::create(sourceCode, fileName, firstLineNumber, eng);
@@ -86,10 +91,19 @@ JSC::EvalExecutable *QScriptProgramPrivate::executable(JSC::ExecState *exec,
JSC::SourceCode source(provider, firstLineNumber); //after construction of SourceCode provider variable will be null.
_executable = JSC::EvalExecutable::create(exec, source);
engine = eng;
+ engine->registerScriptProgram(this);
isCompiled = false;
return _executable.get();
}
+void QScriptProgramPrivate::detachFromEngine()
+{
+ _executable.clear();
+ sourceId = -1;
+ isCompiled = false;
+ engine = 0;
+}
+
/*!
Constructs a null QScriptProgram.
*/
@@ -122,9 +136,6 @@ QScriptProgram::QScriptProgram(const QScriptProgram &other)
*/
QScriptProgram::~QScriptProgram()
{
- // Q_D(QScriptProgram);
- // if (d->engine && (d->ref == 1))
- // d->engine->unregisterScriptProgram(d);
}
/*!
@@ -132,9 +143,6 @@ QScriptProgram::~QScriptProgram()
*/
QScriptProgram &QScriptProgram::operator=(const QScriptProgram &other)
{
- // if (d_func() && d_func()->engine && (d_func()->ref == 1))
- // d_func()->engine->unregisterScriptProgram(d_func());
- // }
d_ptr = other.d_ptr;
return *this;
}
diff --git a/src/script/api/qscriptprogram_p.h b/src/script/api/qscriptprogram_p.h
index d2fd234..e7809ab 100644
--- a/src/script/api/qscriptprogram_p.h
+++ b/src/script/api/qscriptprogram_p.h
@@ -61,6 +61,7 @@ public:
JSC::EvalExecutable *executable(JSC::ExecState *exec,
QScriptEnginePrivate *engine);
+ void detachFromEngine();
QBasicAtomicInt ref;
diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp
index 9285883..2085756 100644
--- a/src/script/bridge/qscriptclassobject.cpp
+++ b/src/script/bridge/qscriptclassobject.cpp
@@ -183,6 +183,10 @@ void ClassObjectDelegate::getOwnPropertyNames(QScriptObject* object, JSC::ExecSt
JSC::PropertyNameArray &propertyNames,
JSC::EnumerationMode mode)
{
+ // For compatibility with the old back-end, normal JS properties
+ // are added first.
+ QScriptObjectDelegate::getOwnPropertyNames(object, exec, propertyNames, mode);
+
QScriptEnginePrivate *engine = scriptEngineFromExec(exec);
QScript::SaveFrameHelper saveFrame(engine, exec);
QScriptValue scriptObject = engine->scriptValueFromJSCValue(object);
@@ -195,7 +199,6 @@ void ClassObjectDelegate::getOwnPropertyNames(QScriptObject* object, JSC::ExecSt
}
delete it;
}
- QScriptObjectDelegate::getOwnPropertyNames(object, exec, propertyNames, mode);
}
JSC::CallType ClassObjectDelegate::getCallData(QScriptObject*, JSC::CallData &callData)
diff --git a/src/script/bridge/qscriptdeclarativeclass.cpp b/src/script/bridge/qscriptdeclarativeclass.cpp
index 0dcf1ec..6126b32 100644
--- a/src/script/bridge/qscriptdeclarativeclass.cpp
+++ b/src/script/bridge/qscriptdeclarativeclass.cpp
@@ -179,6 +179,11 @@ QScriptDeclarativeClass::PersistentIdentifier::operator=(const PersistentIdentif
return *this;
}
+QString QScriptDeclarativeClass::PersistentIdentifier::toString() const
+{
+ return ((JSC::Identifier &)d).ustring();
+}
+
QScriptDeclarativeClass::QScriptDeclarativeClass(QScriptEngine *engine)
: d_ptr(new QScriptDeclarativeClassPrivate)
{
@@ -468,6 +473,14 @@ QString QScriptDeclarativeClass::toString(const Identifier &identifier)
return QString((QChar *)r->data(), r->size());
}
+bool QScriptDeclarativeClass::startsWithUpper(const Identifier &identifier)
+{
+ JSC::UString::Rep *r = (JSC::UString::Rep *)identifier;
+ if (r->size() < 1)
+ return false;
+ return QChar::category((ushort)(r->data()[0])) == QChar::Letter_Uppercase;
+}
+
quint32 QScriptDeclarativeClass::toArrayIndex(const Identifier &identifier, bool *ok)
{
JSC::UString::Rep *r = (JSC::UString::Rep *)identifier;
diff --git a/src/script/bridge/qscriptdeclarativeclass_p.h b/src/script/bridge/qscriptdeclarativeclass_p.h
index 25dc396..e4c18f5 100644
--- a/src/script/bridge/qscriptdeclarativeclass_p.h
+++ b/src/script/bridge/qscriptdeclarativeclass_p.h
@@ -107,6 +107,7 @@ public:
PersistentIdentifier(const PersistentIdentifier &other);
PersistentIdentifier &operator=(const PersistentIdentifier &other);
+ QString toString() const;
private:
friend class QScriptDeclarativeClass;
PersistentIdentifier(QScriptEnginePrivate *e) : identifier(0), engine(e), d(0) {}
@@ -126,6 +127,7 @@ public:
PersistentIdentifier createPersistentIdentifier(const Identifier &);
QString toString(const Identifier &);
+ bool startsWithUpper(const Identifier &);
quint32 toArrayIndex(const Identifier &, bool *ok);
virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
diff --git a/src/script/script.pro b/src/script/script.pro
index 34f4a88..ce5c778 100644
--- a/src/script/script.pro
+++ b/src/script/script.pro
@@ -89,7 +89,6 @@ include(script.pri)
symbian {
TARGET.UID3=0x2001B2E1
- LIBS += -lhal
}
symbian {
@@ -102,5 +101,9 @@ symbian {
QMAKE_CXXFLAGS.ARMCC += -OTime -O3
}
+integrity {
+ CFLAGS += --diag_remark=236,82
+}
+
# WebKit doesn't compile in C++0x mode
*-g++*:QMAKE_CXXFLAGS -= -std=c++0x -std=gnu++0x
diff --git a/src/sql/drivers/oci/qsql_oci.h b/src/sql/drivers/oci/qsql_oci.h
index 51fd14c..22bd78d 100644
--- a/src/sql/drivers/oci/qsql_oci.h
+++ b/src/sql/drivers/oci/qsql_oci.h
@@ -54,6 +54,9 @@
QT_BEGIN_HEADER
+typedef struct OCIEnv OCIEnv;
+typedef struct OCISvcCtx OCISvcCtx;
+
QT_BEGIN_NAMESPACE
class QOCIDriver;
@@ -61,9 +64,6 @@ class QOCICols;
struct QOCIDriverPrivate;
struct QOCIResultPrivate;
-typedef struct OCIEnv OCIEnv;
-typedef struct OCISvcCtx OCISvcCtx;
-
class Q_EXPORT_SQLDRIVER_OCI QOCIResult : public QSqlCachedResult
{
friend class QOCIDriver;
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index 1573d02..0b534d9 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -214,7 +214,7 @@ static QString qWarnODBCHandle(int handleType, SQLHANDLE handle, int *nativeCode
state_,
&nativeCode_,
0,
- NULL,
+ 0,
&msgLen);
if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && msgLen > 0)
description_.resize(msgLen+1);
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index 5a32d1a..34277b3 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -1021,6 +1021,9 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const
stmt = stmt.arg(QString::fromLatin1("pg_class.relnamespace = (select oid from "
"pg_namespace where pg_namespace.nspname = '%1') AND ").arg(schema));
break;
+ case QPSQLDriver::VersionUnknown:
+ qFatal("PSQL version is unknown");
+ break;
}
i.exec(stmt.arg(tbl));
@@ -1110,6 +1113,9 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const
stmt = stmt.arg(QString::fromLatin1("pg_class.relnamespace = (select oid from "
"pg_namespace where pg_namespace.nspname = '%1')").arg(schema));
break;
+ case QPSQLDriver::VersionUnknown:
+ qFatal("PSQL version is unknown");
+ break;
}
QSqlQuery query(createResult());
diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp
index 66808c8..b0ae8d9 100644
--- a/src/sql/kernel/qsqldatabase.cpp
+++ b/src/sql/kernel/qsqldatabase.cpp
@@ -798,7 +798,7 @@ void QSqlDatabasePrivate::init(const QString &type)
Destroys the object and frees any allocated resources.
If this is the last QSqlDatabase object that uses a certain
- database connection, the is automatically closed.
+ database connection, the database connection is automatically closed.
\sa close()
*/
diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp
index 4b92a3e..3cdc8b1 100644
--- a/src/sql/kernel/qsqlquery.cpp
+++ b/src/sql/kernel/qsqlquery.cpp
@@ -272,7 +272,7 @@ static void qInit(QSqlQuery *q, const QString& query, QSqlDatabase db)
/*!
Constructs a QSqlQuery object using the SQL \a query and the
- database \a db. If \a db is not specified, the application's
+ database \a db. If \a db is not specified, or is invalid, the application's
default database is used. If \a query is not an empty string, it
will be executed.
@@ -286,6 +286,7 @@ QSqlQuery::QSqlQuery(const QString& query, QSqlDatabase db)
/*!
Constructs a QSqlQuery object using the database \a db.
+ If \a db is invalid, the application's default database will be used.
\sa QSqlDatabase
*/
diff --git a/src/sql/models/qsqlquerymodel.cpp b/src/sql/models/qsqlquerymodel.cpp
index 8730192..d1051de 100644
--- a/src/sql/models/qsqlquerymodel.cpp
+++ b/src/sql/models/qsqlquerymodel.cpp
@@ -279,7 +279,11 @@ QVariant QSqlQueryModel::headerData(int section, Qt::Orientation orientation, in
val = d->headers.value(section).value(Qt::EditRole);
if (val.isValid())
return val;
- if (role == Qt::DisplayRole && d->rec.count() > section)
+
+ // See if it's an inserted column (iiq.column() != -1)
+ QModelIndex dItem = indexInQuery(createIndex(0, section));
+
+ if (role == Qt::DisplayRole && d->rec.count() > section && dItem.column() != -1)
return d->rec.fieldName(section);
}
return QAbstractItemModel::headerData(section, orientation, role);
@@ -306,6 +310,8 @@ void QSqlQueryModel::queryChange()
lastError() can be used to retrieve verbose information if there
was an error setting the query.
+ \note Calling setQuery() will remove any inserted columns.
+
\sa query(), QSqlQuery::isActive(), QSqlQuery::setForwardOnly(), lastError()
*/
void QSqlQueryModel::setQuery(const QSqlQuery &query)
@@ -370,7 +376,8 @@ void QSqlQueryModel::setQuery(const QSqlQuery &query)
/*! \overload
Executes the query \a query for the given database connection \a
- db. If no database is specified, the default connection is used.
+ db. If no database (or an invalid database) is specified, the
+ default connection is used.
lastError() can be used to retrieve verbose information if there
was an error setting the query.
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index 3bb46cc..bf7c0aa 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -393,6 +393,8 @@ QString QSqlTableModel::tableName() const
specified filter and sort condition, and returns true if successful; otherwise
returns false.
+ \note Calling select() will revert any unsubmitted changes and remove any inserted columns.
+
\sa setTable(), setFilter(), selectStatement()
*/
bool QSqlTableModel::select()
@@ -423,6 +425,10 @@ QVariant QSqlTableModel::data(const QModelIndex &index, int role) const
if (!index.isValid() || (role != Qt::DisplayRole && role != Qt::EditRole))
return QVariant();
+ // Problem.. we need to use QSQM::indexInQuery to handle inserted columns
+ // but inserted rows we need to handle
+ // and indexInQuery is not virtual (grrr) so any values we pass to QSQM need
+ // to handle the insertedRows
QModelIndex item = indexInQuery(index);
switch (d->strategy) {
@@ -450,7 +456,9 @@ QVariant QSqlTableModel::data(const QModelIndex &index, int role) const
return var;
break; }
}
- return QSqlQueryModel::data(item, role);
+
+ // We need to handle row mapping here, but not column mapping
+ return QSqlQueryModel::data(index.sibling(item.row(), index.column()), role);
}
/*!
@@ -649,7 +657,7 @@ bool QSqlTableModel::insertRowIntoTable(const QSqlRecord &values)
return false;
}
- return d->exec(stmt, prepStatement, rec);
+ return d->exec(stmt, prepStatement, rec, QSqlRecord() /* no where values */);
}
/*!
@@ -687,7 +695,7 @@ bool QSqlTableModel::deleteRowFromTable(int row)
}
stmt.append(QLatin1Char(' ')).append(where);
- return d->exec(stmt, prepStatement, whereValues);
+ return d->exec(stmt, prepStatement, QSqlRecord() /* no new values */, whereValues);
}
/*!
@@ -1095,9 +1103,12 @@ bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent)
int idx = row + i;
if (idx >= rowCount())
return false;
- if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert)
+ if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert) {
revertRow(idx);
- else {
+ // Reverting a row means all the other cache entries have been adjusted downwards
+ // so fake this by adjusting row
+ --row;
+ } else {
d->cache[idx].op = QSqlTableModelPrivate::Delete;
d->cache[idx].primaryValues = d->primaryValues(indexInQuery(createIndex(idx, 0)).row());
emit headerDataChanged(Qt::Vertical, idx, idx);
@@ -1225,7 +1236,7 @@ int QSqlTableModel::rowCount(const QModelIndex &parent) const
QModelIndex QSqlTableModel::indexInQuery(const QModelIndex &item) const
{
Q_D(const QSqlTableModel);
- const QModelIndex it = QSqlQueryModel::indexInQuery(item);
+ const QModelIndex it = QSqlQueryModel::indexInQuery(item); // this adjusts columns only
if (d->strategy == OnManualSubmit) {
int rowOffset = 0;
QSqlTableModelPrivate::CacheMap::ConstIterator i = d->cache.constBegin();
@@ -1332,6 +1343,9 @@ bool QSqlTableModel::setRecord(int row, const QSqlRecord &record)
else
mrow.rec.setValue(idx, record.value(i));
}
+
+ if (isOk)
+ emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1));
return isOk; }
}
return false;
diff --git a/src/sql/models/qsqltablemodel_p.h b/src/sql/models/qsqltablemodel_p.h
index d2b96e6..f4f3811 100644
--- a/src/sql/models/qsqltablemodel_p.h
+++ b/src/sql/models/qsqltablemodel_p.h
@@ -75,7 +75,7 @@ public:
QSqlRecord record(const QVector<QVariant> &values) const;
bool exec(const QString &stmt, bool prepStatement,
- const QSqlRecord &rec, const QSqlRecord &whereValues = QSqlRecord());
+ const QSqlRecord &rec, const QSqlRecord &whereValues);
virtual void revertCachedRow(int row);
void revertInsertedRow();
bool setRecord(int row, const QSqlRecord &record);
diff --git a/src/sql/sql.pro b/src/sql/sql.pro
index 54f4289..81aa3c0 100644
--- a/src/sql/sql.pro
+++ b/src/sql/sql.pro
@@ -20,7 +20,10 @@ include(models/models.pri)
symbian: {
TARGET.UID3=0x2001E61D
- # Workaroud for problems with paging this dll
- MMP_RULES -= PAGED
- MMP_RULES *= UNPAGED
+ # Problems using data exports from this DLL mean that we can't page it on releases that don't support
+ # data exports (currently that's any release before Symbian^3)
+ pagingBlock = "$${LITERAL_HASH}ifndef SYMBIAN_DLL_DATA_EXPORTS_SUPPORTED" \
+ "UNPAGED" \
+ "$${LITERAL_HASH}endif"
+ MMP_RULES += pagingBlock
}
diff --git a/src/src.pro b/src/src.pro
index c07d399..0908911 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -109,10 +109,11 @@ src_webkit_declarative.target = sub-webkitdeclarative
src_phonon.depends = src_gui
src_multimedia.depends = src_gui
contains(QT_CONFIG, opengl):src_multimedia.depends += src_opengl
- src_tools_activeqt.depends = src_tools_idc src_gui
+ src_activeqt.depends = src_tools_idc src_gui
src_declarative.depends = src_gui src_script src_network
src_plugins.depends = src_gui src_sql src_svg
contains(QT_CONFIG, multimedia):src_plugins.depends += src_multimedia
+ contains(QT_CONFIG, declarative):src_plugins.depends += src_declarative
src_s60installs.depends = $$TOOLS_SUBDIRS $$SRC_SUBDIRS
src_s60installs.depends -= src_s60installs
src_imports.depends = src_gui src_declarative
diff --git a/src/testlib/qbenchmark_p.h b/src/testlib/qbenchmark_p.h
index 9a83a1a..ace17db 100644
--- a/src/testlib/qbenchmark_p.h
+++ b/src/testlib/qbenchmark_p.h
@@ -130,7 +130,7 @@ public:
QBenchmarkGlobalData:current is created at the beginning of qExec()
and cleared at the end.
*/
-class QBenchmarkGlobalData
+class Q_TESTLIB_EXPORT QBenchmarkGlobalData
{
public:
static QBenchmarkGlobalData *current;
@@ -161,7 +161,7 @@ private:
created at the beginning of qInvokeTestMethod() and cleared at
the end.
*/
-class QBenchmarkTestMethodData
+class Q_TESTLIB_EXPORT QBenchmarkTestMethodData
{
public:
static QBenchmarkTestMethodData *current;
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 55f5fbe..287d8e6 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1014,6 +1014,10 @@ static bool isValidSlot(const QMetaMethod &sl)
return true;
}
+Q_TESTLIB_EXPORT bool printAvailableFunctions = false;
+Q_TESTLIB_EXPORT QStringList testFunctions;
+Q_TESTLIB_EXPORT QStringList testTags;
+
static void qPrintTestSlots()
{
for (int i = 0; i < QTest::currentTestObject->metaObject()->methodCount(); ++i) {
@@ -1034,7 +1038,7 @@ static int qToInt(char *str)
return l;
}
-static void qParseArgs(int argc, char *argv[])
+Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
{
const char *testOptions =
" options:\n"
@@ -1084,8 +1088,12 @@ static void qParseArgs(int argc, char *argv[])
"%s", argv[0], testOptions);
exit(0);
} else if (strcmp(argv[i], "-functions") == 0) {
- qPrintTestSlots();
- exit(0);
+ if (qml) {
+ QTest::printAvailableFunctions = true;
+ } else {
+ qPrintTestSlots();
+ exit(0);
+ }
} else if(strcmp(argv[i], "-xunitxml") == 0){
QTestLog::setLogMode(QTestLog::XunitXML);
} else if (strcmp(argv[i], "-xml") == 0) {
@@ -1221,6 +1229,32 @@ static void qParseArgs(int argc, char *argv[])
} else if (argv[i][0] == '-') {
printf("Unknown option: '%s'\n\n%s", argv[i], testOptions);
exit(1);
+ } else if (qml) {
+ // We can't check the availability of test functions until
+ // we load the QML files. So just store the data for now.
+ int colon = -1;
+ int offset;
+ for(offset = 0; *(argv[i]+offset); ++offset) {
+ if (*(argv[i]+offset) == ':') {
+ if (*(argv[i]+offset+1) == ':') {
+ // "::" is used as a test name separator.
+ // e.g. "ClickTests::test_click:row1".
+ ++offset;
+ } else {
+ colon = offset;
+ break;
+ }
+ }
+ }
+ if (colon == -1) {
+ QTest::testFunctions += QString::fromLatin1(argv[i]);
+ QTest::testTags += QString();
+ } else {
+ QTest::testFunctions +=
+ QString::fromLatin1(argv[i], colon);
+ QTest::testTags +=
+ QString::fromLatin1(argv[i] + colon + 1);
+ }
} else {
if (!QTest::testFuncs) {
QTest::testFuncs = new QTest::TestFunction[512];
@@ -1625,6 +1659,14 @@ private:
void FatalSignalHandler::signal(int signum)
{
qFatal("Received signal %d", signum);
+#if defined(Q_OS_INTEGRITY)
+ {
+ struct sigaction act;
+ memset(&act, 0, sizeof(struct sigaction));
+ act.sa_handler = SIG_DFL;
+ sigaction(signum, &act, NULL);
+ }
+#endif
}
FatalSignalHandler::FatalSignalHandler()
@@ -1639,8 +1681,9 @@ FatalSignalHandler::FatalSignalHandler()
act.sa_handler = FatalSignalHandler::signal;
// Remove the handler after it is invoked.
+#if !defined(Q_OS_INTEGRITY)
act.sa_flags = SA_RESETHAND;
-
+#endif
// Block all fatal signals in our signal handler so we don't try to close
// the testlog twice.
sigemptyset(&act.sa_mask);
@@ -1785,7 +1828,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
QTEST_ASSERT(metaObject);
QTestResult::setCurrentTestObject(metaObject->className());
- qParseArgs(argc, argv);
+ qtest_qParseArgs(argc, argv, false);
if (QTest::randomOrder) {
seedRandom();
}
diff --git a/src/testlib/qtestlog_p.h b/src/testlib/qtestlog_p.h
index 59282fd..a892d3d 100644
--- a/src/testlib/qtestlog_p.h
+++ b/src/testlib/qtestlog_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
class QBenchmarkResult;
-class QTestLog
+class Q_TESTLIB_EXPORT QTestLog
{
public:
enum LogMode { Plain = 0, XML, LightXML, XunitXML };
diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h
index 35752b0..5abb019 100644
--- a/src/testlib/qtestmouse.h
+++ b/src/testlib/qtestmouse.h
@@ -107,7 +107,11 @@ namespace QTest
break;
case MouseMove:
QCursor::setPos(widget->mapToGlobal(pos));
+#ifdef QT_MAC_USE_COCOA
+ QTest::qWait(20);
+#else
qApp->processEvents();
+#endif
return;
default:
QTEST_ASSERT(false);
diff --git a/src/testlib/qtestresult_p.h b/src/testlib/qtestresult_p.h
index 15523f5..7ff120a 100644
--- a/src/testlib/qtestresult_p.h
+++ b/src/testlib/qtestresult_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
class QTestResultPrivate;
class QTestData;
-class QTestResult
+class Q_TESTLIB_EXPORT QTestResult
{
public:
enum TestLocation { NoWhere = 0, DataFunc = 1, InitFunc = 2, Func = 3, CleanupFunc = 4 };
diff --git a/src/testlib/qtesttable_p.h b/src/testlib/qtesttable_p.h
index d085b57..f835506 100644
--- a/src/testlib/qtesttable_p.h
+++ b/src/testlib/qtesttable_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
class QTestData;
class QTestTablePrivate;
-class QTestTable
+class Q_TESTLIB_EXPORT QTestTable
{
public:
QTestTable();
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index 222e5f6..4df7ae5 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -181,10 +181,14 @@ void Generator::generateCode()
int methodCount = cdef->signalList.count() + cdef->slotList.count() + cdef->methodList.count();
fprintf(out, " %4d, %4d, // methods\n", methodCount, methodCount ? index : 0);
index += methodCount * 5;
+ if (cdef->revisionedMethods)
+ index += methodCount;
fprintf(out, " %4d, %4d, // properties\n", cdef->propertyList.count(), cdef->propertyList.count() ? index : 0);
index += cdef->propertyList.count() * 3;
if(cdef->notifyableProperties)
index += cdef->propertyList.count();
+ if (cdef->revisionedProperties)
+ index += cdef->propertyList.count();
fprintf(out, " %4d, %4d, // enums/sets\n", cdef->enumList.count(), cdef->enumList.count() ? index : 0);
int enumsIndex = index;
@@ -217,6 +221,14 @@ void Generator::generateCode()
//
generateFunctions(cdef->methodList, "method", MethodMethod);
+//
+// Build method version arrays
+//
+ if (cdef->revisionedMethods) {
+ generateFunctionRevisions(cdef->signalList, "signal");
+ generateFunctionRevisions(cdef->slotList, "slot");
+ generateFunctionRevisions(cdef->methodList, "method");
+ }
//
// Build property array
@@ -456,7 +468,7 @@ void Generator::generateFunctions(QList<FunctionDef>& list, const char *functype
}
sig += ')';
- char flags = type;
+ unsigned char flags = type;
if (f.access == FunctionDef::Private)
flags |= AccessPrivate;
else if (f.access == FunctionDef::Public)
@@ -475,11 +487,23 @@ void Generator::generateFunctions(QList<FunctionDef>& list, const char *functype
flags |= MethodCloned;
if (f.isScriptable)
flags |= MethodScriptable;
+ if (f.revision > 0)
+ flags |= MethodRevisioned;
fprintf(out, " %4d, %4d, %4d, %4d, 0x%02x,\n", strreg(sig),
strreg(arguments), strreg(f.normalizedType), strreg(f.tag), flags);
}
}
+void Generator::generateFunctionRevisions(QList<FunctionDef>& list, const char *functype)
+{
+ if (list.count())
+ fprintf(out, "\n // %ss: revision\n", functype);
+ for (int i = 0; i < list.count(); ++i) {
+ const FunctionDef &f = list.at(i);
+ fprintf(out, " %4d,\n", f.revision);
+ }
+}
+
void Generator::generateProperties()
{
//
@@ -537,6 +561,9 @@ void Generator::generateProperties()
if (p.notifyId != -1)
flags |= Notify;
+ if (p.revision > 0)
+ flags |= Revisioned;
+
if (p.constant)
flags |= Constant;
if (p.final)
@@ -562,6 +589,13 @@ void Generator::generateProperties()
p.notifyId);
}
}
+ if (cdef->revisionedProperties) {
+ fprintf(out, "\n // properties: revision\n");
+ for (int i = 0; i < cdef->propertyList.count(); ++i) {
+ const PropertyDef &p = cdef->propertyList.at(i);
+ fprintf(out, " %4d,\n", p.revision);
+ }
+ }
}
void Generator::generateEnums(int index)
diff --git a/src/tools/moc/generator.h b/src/tools/moc/generator.h
index 63605eb..ed0980e 100644
--- a/src/tools/moc/generator.h
+++ b/src/tools/moc/generator.h
@@ -58,6 +58,7 @@ public:
private:
void generateClassInfos();
void generateFunctions(QList<FunctionDef> &list, const char *functype, int type);
+ void generateFunctionRevisions(QList<FunctionDef>& list, const char *functype);
void generateEnums(int index);
void generateProperties();
void generateMetacall();
diff --git a/src/tools/moc/keywords.cpp b/src/tools/moc/keywords.cpp
index 0eca110..9a8aa41 100644
--- a/src/tools/moc/keywords.cpp
+++ b/src/tools/moc/keywords.cpp
@@ -43,12 +43,12 @@
// DO NOT EDIT.
static const short keyword_trans[][128] = {
- {0,0,0,0,0,0,0,0,0,533,530,0,0,0,0,0,
+ {0,0,0,0,0,0,0,0,0,541,538,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 533,252,531,534,0,38,239,532,25,26,236,234,30,235,27,237,
+ 541,252,539,542,0,38,239,540,25,26,236,234,30,235,27,237,
22,22,22,22,22,22,22,22,22,22,34,41,23,39,24,43,
0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
- 8,21,8,8,8,8,8,8,8,8,8,31,535,32,238,8,
+ 8,21,8,8,8,8,8,8,8,8,8,31,543,32,238,8,
0,1,2,3,4,5,6,7,8,9,8,8,10,11,12,13,
14,8,15,16,17,18,19,20,8,8,8,36,245,37,248,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -190,7 +190,7 @@ static const short keyword_trans[][128] = {
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,42,0,0,0,28,0,
- 538,538,538,538,538,538,538,538,538,538,0,0,0,0,0,0,
+ 546,546,546,546,546,546,546,546,546,546,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -349,7 +349,7 @@ static const short keyword_trans[][128] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,537,0,0,0,0,536,
+ 0,0,0,0,0,0,0,0,0,0,545,0,0,0,0,544,
0,0,0,0,0,0,0,0,0,0,0,0,0,258,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -392,7 +392,7 @@ static const short keyword_trans[][128] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,439,388,378,383,364,0,448,0,0,0,0,0,358,
- 370,0,0,436,0,0,0,0,0,0,0,0,0,0,0,0,
+ 370,0,530,436,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -983,6 +983,14 @@ static const struct
{CHARACTER, 0, 84, 528, CHARACTER},
{CHARACTER, 0, 89, 529, CHARACTER},
{Q_PRIVATE_PROPERTY_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 69, 531, CHARACTER},
+ {CHARACTER, 0, 86, 532, CHARACTER},
+ {CHARACTER, 0, 73, 533, CHARACTER},
+ {CHARACTER, 0, 83, 534, CHARACTER},
+ {CHARACTER, 0, 73, 535, CHARACTER},
+ {CHARACTER, 0, 79, 536, CHARACTER},
+ {CHARACTER, 0, 78, 537, CHARACTER},
+ {Q_REVISION_TOKEN, 0, 0, 0, CHARACTER},
{NEWLINE, 0, 0, 0, NOTOKEN},
{QUOTE, 0, 0, 0, NOTOKEN},
{SINGLEQUOTE, 0, 0, 0, NOTOKEN},
diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp
index 1ecb7e5..ecff105 100644
--- a/src/tools/moc/main.cpp
+++ b/src/tools/moc/main.cpp
@@ -111,6 +111,7 @@ void error(const char *msg = "Invalid argument")
" -i do not generate an #include statement\n"
" -p<path> path prefix for included file\n"
" -f[<file>] force #include, optional file name\n"
+ " -nn do not display notes\n"
" -nw do not display warnings\n"
" @<file> read additional options from file\n"
" -v display version of moc\n");
@@ -333,9 +334,12 @@ int runMoc(int _argc, char **_argv)
case 'n': // don't display warnings
if (ignoreConflictingOptions)
break;
- if (opt != "nw")
+ if (opt == "nw")
+ moc.displayWarnings = moc.displayNotes = false;
+ else if (opt == "nn")
+ moc.displayNotes = false;
+ else
error();
- moc.displayWarnings = false;
break;
case 'h': // help
if (more && opt != "help")
@@ -425,7 +429,7 @@ int runMoc(int _argc, char **_argv)
fprintf(out, "%s\n", composePreprocessorOutput(moc.symbols).constData());
} else {
if (moc.classList.isEmpty())
- moc.warning("No relevant classes found. No output generated.");
+ moc.note("No relevant classes found. No output generated.");
else
moc.generate(out);
}
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index f72bdf5..2cf2412 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -335,6 +335,23 @@ bool Moc::testFunctionAttribute(Token tok, FunctionDef *def)
return false;
}
+bool Moc::testFunctionRevision(FunctionDef *def)
+{
+ if (test(Q_REVISION_TOKEN)) {
+ next(LPAREN);
+ QByteArray revision = lexemUntil(RPAREN);
+ revision.remove(0, 1);
+ revision.chop(1);
+ bool ok = false;
+ def->revision = revision.toInt(&ok);
+ if (!ok || def->revision < 0)
+ error("Invalid revision");
+ return true;
+ }
+
+ return false;
+}
+
// returns false if the function should be ignored
bool Moc::parseFunction(FunctionDef *def, bool inMacro)
{
@@ -342,7 +359,7 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro)
//skip modifiers and attributes
while (test(INLINE) || test(STATIC) ||
(test(VIRTUAL) && (def->isVirtual = true)) //mark as virtual
- || testFunctionAttribute(def)) {}
+ || testFunctionAttribute(def) || testFunctionRevision(def)) {}
bool templateFunction = (lookup() == TEMPLATE);
def->type = parseType();
if (def->type.name.isEmpty()) {
@@ -433,7 +450,7 @@ bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def)
//skip modifiers and attributes
while (test(EXPLICIT) || test(INLINE) || test(STATIC) ||
(test(VIRTUAL) && (def->isVirtual = true)) //mark as virtual
- || testFunctionAttribute(def)) {}
+ || testFunctionAttribute(def) || testFunctionRevision(def)) {}
bool tilde = test(TILDE);
def->type = parseType();
if (def->type.name.isEmpty())
@@ -694,6 +711,8 @@ void Moc::parse()
funcDef.arguments.removeLast();
def.slotList += funcDef;
}
+ if (funcDef.revision > 0)
+ ++def.revisionedMethods;
} else if (funcDef.isSignal) {
def.signalList += funcDef;
while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
@@ -701,6 +720,8 @@ void Moc::parse()
funcDef.arguments.removeLast();
def.signalList += funcDef;
}
+ if (funcDef.revision > 0)
+ ++def.revisionedMethods;
} else if (funcDef.isInvokable) {
def.methodList += funcDef;
while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
@@ -708,6 +729,8 @@ void Moc::parse()
funcDef.arguments.removeLast();
def.methodList += funcDef;
}
+ if (funcDef.revision > 0)
+ ++def.revisionedMethods;
}
}
} else {
@@ -806,6 +829,18 @@ QList<QMetaObject*> Moc::generate(bool ignoreProperties)
void Moc::parseSlots(ClassDef *def, FunctionDef::Access access)
{
+ int defaultRevision = -1;
+ if (test(Q_REVISION_TOKEN)) {
+ next(LPAREN);
+ QByteArray revision = lexemUntil(RPAREN);
+ revision.remove(0, 1);
+ revision.chop(1);
+ bool ok = false;
+ defaultRevision = revision.toInt(&ok);
+ if (!ok || defaultRevision < 0)
+ error("Invalid revision");
+ }
+
next(COLON);
while (inClass(def) && hasNext()) {
switch (next()) {
@@ -831,6 +866,12 @@ void Moc::parseSlots(ClassDef *def, FunctionDef::Access access)
funcDef.access = access;
if (!parseFunction(&funcDef))
continue;
+ if (funcDef.revision > 0) {
+ ++def->revisionedMethods;
+ } else if (defaultRevision != -1) {
+ funcDef.revision = defaultRevision;
+ ++def->revisionedMethods;
+ }
def->slotList += funcDef;
while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
funcDef.wasCloned = true;
@@ -842,6 +883,18 @@ void Moc::parseSlots(ClassDef *def, FunctionDef::Access access)
void Moc::parseSignals(ClassDef *def)
{
+ int defaultRevision = -1;
+ if (test(Q_REVISION_TOKEN)) {
+ next(LPAREN);
+ QByteArray revision = lexemUntil(RPAREN);
+ revision.remove(0, 1);
+ revision.chop(1);
+ bool ok = false;
+ defaultRevision = revision.toInt(&ok);
+ if (!ok || defaultRevision < 0)
+ error("Invalid revision");
+ }
+
next(COLON);
while (inClass(def) && hasNext()) {
switch (next()) {
@@ -869,6 +922,12 @@ void Moc::parseSignals(ClassDef *def)
warning("Signals cannot be declared virtual");
if (funcDef.inlineCode)
error("Not a signal declaration");
+ if (funcDef.revision > 0) {
+ ++def->revisionedMethods;
+ } else if (defaultRevision != -1) {
+ funcDef.revision = defaultRevision;
+ ++def->revisionedMethods;
+ }
def->signalList += funcDef;
while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
funcDef.wasCloned = true;
@@ -911,7 +970,6 @@ void Moc::createPropertyDef(PropertyDef &propDef)
propDef.name = lexem();
while (test(IDENTIFIER)) {
QByteArray l = lexem();
-
if (l[0] == 'C' && l == "CONSTANT") {
propDef.constant = true;
continue;
@@ -923,6 +981,10 @@ void Moc::createPropertyDef(PropertyDef &propDef)
QByteArray v, v2;
if (test(LPAREN)) {
v = lexemUntil(RPAREN);
+ } else if (test(INTEGER_LITERAL)) {
+ v = lexem();
+ if (l != "REVISION")
+ error(1);
} else {
next(IDENTIFIER);
v = lexem();
@@ -937,7 +999,12 @@ void Moc::createPropertyDef(PropertyDef &propDef)
propDef.read = v;
else if (l == "RESET")
propDef.reset = v + v2;
- else
+ else if (l == "REVISION") {
+ bool ok = false;
+ propDef.revision = v.toInt(&ok);
+ if (!ok || propDef.revision < 0)
+ error(1);
+ } else
error(2);
break;
case 'S':
@@ -1002,6 +1069,8 @@ void Moc::parseProperty(ClassDef *def)
if(!propDef.notify.isEmpty())
def->notifyableProperties++;
+ if (propDef.revision > 0)
+ ++def->revisionedProperties;
def->propertyList += propDef;
}
@@ -1028,6 +1097,8 @@ void Moc::parsePrivateProperty(ClassDef *def)
if(!propDef.notify.isEmpty())
def->notifyableProperties++;
+ if (propDef.revision > 0)
+ ++def->revisionedProperties;
def->propertyList += propDef;
}
@@ -1177,6 +1248,9 @@ void Moc::parseSlotInPrivate(ClassDef *def, FunctionDef::Access access)
funcDef.arguments.removeLast();
def->slotList += funcDef;
}
+ if (funcDef.revision > 0)
+ ++def->revisionedMethods;
+
}
QByteArray Moc::lexemUntil(Token target)
diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h
index 9543a05..38c3917 100644
--- a/src/tools/moc/moc.h
+++ b/src/tools/moc/moc.h
@@ -86,7 +86,7 @@ struct FunctionDef
FunctionDef(): returnTypeIsVolatile(false), access(Private), isConst(false), isVirtual(false),
inlineCode(false), wasCloned(false), isCompat(false), isInvokable(false),
isScriptable(false), isSlot(false), isSignal(false),
- isConstructor(false), isDestructor(false), isAbstract(false) {}
+ isConstructor(false), isDestructor(false), isAbstract(false), revision(0) {}
Type type;
QByteArray normalizedType;
QByteArray tag;
@@ -111,11 +111,13 @@ struct FunctionDef
bool isConstructor;
bool isDestructor;
bool isAbstract;
+
+ int revision;
};
struct PropertyDef
{
- PropertyDef():notifyId(-1), constant(false), final(false), gspec(ValueSpec){}
+ PropertyDef():notifyId(-1), constant(false), final(false), gspec(ValueSpec), revision(0){}
QByteArray name, type, read, write, reset, designable, scriptable, editable, stored, user, notify, inPrivateClass;
int notifyId;
bool constant;
@@ -128,6 +130,7 @@ struct PropertyDef
s += name.mid(1);
return (s == write);
}
+ int revision;
};
@@ -139,7 +142,8 @@ struct ClassInfoDef
struct ClassDef {
ClassDef():
- hasQObject(false), hasQGadget(false), notifyableProperties(0), begin(0), end(0){}
+ hasQObject(false), hasQGadget(false), notifyableProperties(0)
+ , revisionedMethods(0), revisionedProperties(0), begin(0), end(0){}
QByteArray classname;
QByteArray qualified;
QList<QPair<QByteArray, FunctionDef::Access> > superclassList;
@@ -164,6 +168,8 @@ struct ClassDef {
QMap<QByteArray, bool> enumDeclarations;
QList<EnumDef> enumList;
QMap<QByteArray, QByteArray> flagAliases;
+ int revisionedMethods;
+ int revisionedProperties;
int begin;
int end;
@@ -236,6 +242,7 @@ public:
// in FunctionDef accordingly
bool testFunctionAttribute(FunctionDef *def);
bool testFunctionAttribute(Token tok, FunctionDef *def);
+ bool testFunctionRevision(FunctionDef *def);
void checkSuperClasses(ClassDef *def);
void checkProperties(ClassDef* cdef);
diff --git a/src/tools/moc/parser.cpp b/src/tools/moc/parser.cpp
index 1fa1401..b6f0837 100644
--- a/src/tools/moc/parser.cpp
+++ b/src/tools/moc/parser.cpp
@@ -78,4 +78,10 @@ void Parser::warning(const char *msg) {
currentFilenames.top().constData(), qMax(0, index > 0 ? symbol().lineNum : 0), msg);
}
+void Parser::note(const char *msg) {
+ if (displayNotes && msg)
+ fprintf(stderr, ErrorFormatString "Note: %s\n",
+ currentFilenames.top().constData(), qMax(0, index > 0 ? symbol().lineNum : 0), msg);
+}
+
QT_END_NAMESPACE
diff --git a/src/tools/moc/parser.h b/src/tools/moc/parser.h
index 8356449..a874248 100644
--- a/src/tools/moc/parser.h
+++ b/src/tools/moc/parser.h
@@ -50,10 +50,11 @@ QT_BEGIN_NAMESPACE
class Parser
{
public:
- Parser():index(0), displayWarnings(true){}
+ Parser():index(0), displayWarnings(true), displayNotes(true) {}
Symbols symbols;
int index;
bool displayWarnings;
+ bool displayNotes;
QStack<QByteArray> currentFilenames;
@@ -73,6 +74,7 @@ public:
void error(int rollback);
void error(const char *msg = 0);
void warning(const char * = 0);
+ void note(const char * = 0);
};
diff --git a/src/tools/moc/token.cpp b/src/tools/moc/token.cpp
index 733a17e..9d07c48 100644
--- a/src/tools/moc/token.cpp
+++ b/src/tools/moc/token.cpp
@@ -180,6 +180,7 @@ const char *tokenTypeName(Token t)
case Q_SLOT_TOKEN: return "Q_SLOT_TOKEN";
case Q_PRIVATE_SLOT_TOKEN: return "Q_PRIVATE_SLOT_TOKEN";
case Q_PRIVATE_PROPERTY_TOKEN: return "Q_PRIVATE_PROPERTY_TOKEN";
+ case Q_REVISION_TOKEN: return "Q_REVISION_TOKEN";
case SPECIAL_TREATMENT_MARK: return "SPECIAL_TREATMENT_MARK";
case MOC_INCLUDE_BEGIN: return "MOC_INCLUDE_BEGIN";
case MOC_INCLUDE_END: return "MOC_INCLUDE_END";
diff --git a/src/tools/moc/token.h b/src/tools/moc/token.h
index edbb567..95f17c2 100644
--- a/src/tools/moc/token.h
+++ b/src/tools/moc/token.h
@@ -186,6 +186,7 @@ enum Token {
Q_INVOKABLE_TOKEN,
Q_SCRIPTABLE_TOKEN,
Q_PRIVATE_PROPERTY_TOKEN,
+ Q_REVISION_TOKEN,
Q_META_TOKEN_END,
SPECIAL_TREATMENT_MARK = Q_META_TOKEN_END,
MOC_INCLUDE_BEGIN,
diff --git a/src/tools/moc/util/generate_keywords.cpp b/src/tools/moc/util/generate_keywords.cpp
index 777bf3f..26f7a19 100644
--- a/src/tools/moc/util/generate_keywords.cpp
+++ b/src/tools/moc/util/generate_keywords.cpp
@@ -249,6 +249,7 @@ static const Keyword keywords[] = {
{ "Q_SLOT", "Q_SLOT_TOKEN" },
{ "Q_SCRIPTABLE", "Q_SCRIPTABLE_TOKEN" },
{ "Q_PRIVATE_PROPERTY", "Q_PRIVATE_PROPERTY_TOKEN" },
+ { "Q_REVISION", "Q_REVISION_TOKEN" },
{ "\n", "NEWLINE" },
{ "\"", "QUOTE" },
{ "\'", "SINGLEQUOTE" },